├── .gitmodules ├── .travis.yml ├── CMakeLists.txt ├── LICENSE ├── README.md ├── RELEASE-NOTES.md ├── cmake ├── MSTKConfig.cmake.in └── modules │ ├── FindExodusII.cmake │ ├── FindMETIS.cmake │ ├── FindPTScotch.cmake │ ├── FindParMETIS.cmake │ ├── FindUnitTest++.cmake │ ├── FindZoltan.cmake │ └── FindnetCDF.cmake ├── config ├── application_cmake │ ├── CMakeLists.txt │ └── do-configure-app └── do-configure-mstk ├── docs ├── MSTK-present.tex ├── MSTK.dvi ├── MSTK.pdf ├── MSTK.ps ├── MSTK.tex ├── figures │ ├── MFs_Join.eps │ ├── MFs_Join.obj │ ├── MFs_Join.pdf │ ├── classfn.eps │ ├── classfn.obj │ ├── classfn.pdf │ ├── examplemesh.eps │ ├── examplemesh.obj │ ├── examplemesh.pdf │ ├── examplemodel.eps │ ├── examplemodel.obj │ ├── examplemodel.pdf │ ├── face_def.eps │ ├── face_def.obj │ ├── face_def.pdf │ ├── flow.png │ ├── reg_conventions.eps │ ├── reg_conventions.obj │ ├── reg_conventions.pdf │ ├── repF1.eps │ ├── repF1.pdf │ ├── repF4.eps │ ├── repF4.pdf │ ├── repR1.eps │ ├── repR1.obj │ ├── repR1.pdf │ ├── repR2.eps │ ├── repR2.pdf │ ├── repR4.eps │ └── repR4.pdf ├── parallel.lyx └── parallel.pdf ├── example ├── CMakeLists.txt ├── Makefile.standalone ├── README-examples ├── src │ ├── parallel_example.c │ └── serial_example.c └── test │ ├── example-F1.mstk │ ├── example-R1.mstk │ ├── parallel_example_mesh.mstk │ └── serial_example_mesh.mstk ├── include ├── Hash.h ├── List.h ├── MAttrib.h ├── MEdge.h ├── MEdge_jmp.h ├── MEntity.h ├── MFace.h ├── MFace_jmp.h ├── MNode.h ├── MRegion.h ├── MRegion_jmp.h ├── MSTK.h ├── MSTK_VecFuncs.h ├── MSTK_defines.h ├── MSTK_externs.h ├── MSTK_globals.h ├── MSTK_private.h ├── MSTK_types.h ├── MSTK_util.h ├── MSet.h ├── MVertex.h ├── MVertex_jmp.h └── Mesh.h ├── src ├── CMakeLists.txt ├── base │ ├── MAttrib.c │ ├── MESH_Copy.c │ ├── MESH_InitFromFile.c │ ├── MESH_WriteToFile.c │ ├── ME_Face_Funcs_R1R2.c │ ├── ME_Face_Funcs_R3R4.c │ ├── ME_Geometry.c │ ├── ME_Region_Funcs_RN.c │ ├── MEdge.c │ ├── MEdge_F1.c │ ├── MEdge_F4.c │ ├── MEdge_R1.c │ ├── MEdge_R2.c │ ├── MEdge_R4.c │ ├── MEntity.c │ ├── MF_Edge_Funcs_F1F3.c │ ├── MF_Edge_Funcs_F2F4.c │ ├── MF_Edge_Funcs_R1.c │ ├── MF_Edge_Funcs_R2.c │ ├── MF_Edge_Funcs_R4.c │ ├── MF_Region_Funcs_F1F3.c │ ├── MF_Region_Funcs_F2F4.c │ ├── MF_Region_Funcs_R1.c │ ├── MF_Region_Funcs_R2.c │ ├── MF_Region_Funcs_R4.c │ ├── MF_Vertex_Funcs_F1F3.c │ ├── MF_Vertex_Funcs_F2F4.c │ ├── MF_Vertex_Funcs_R1.c │ ├── MF_Vertex_Funcs_R2.c │ ├── MF_Vertex_Funcs_R4.c │ ├── MFace.c │ ├── MFace_F1.c │ ├── MFace_F4.c │ ├── MFace_R1.c │ ├── MFace_R2.c │ ├── MFace_R4.c │ ├── MR_Edge_Funcs_FN.c │ ├── MR_Edge_Funcs_R1.c │ ├── MR_Edge_Funcs_R2.c │ ├── MR_Edge_Funcs_R3R4.c │ ├── MR_Face_Funcs_FNR3R4.c │ ├── MR_Face_Funcs_R1.c │ ├── MR_Face_Funcs_R2.c │ ├── MR_Vertex_Funcs_FNR3R4.c │ ├── MR_Vertex_Funcs_R1.c │ ├── MR_Vertex_Funcs_R2.c │ ├── MRegion.c │ ├── MRegion_F1.c │ ├── MRegion_F4.c │ ├── MRegion_FNR3R4.c │ ├── MRegion_R1.c │ ├── MRegion_R2.c │ ├── MRegion_R4.c │ ├── MSTK.c │ ├── MSet.c │ ├── MVertex.c │ ├── MVertex_F1.c │ ├── MVertex_F4.c │ ├── MVertex_R1.c │ ├── MVertex_R2.c │ ├── MVertex_R4.c │ └── Mesh.c ├── hilev │ ├── MESH_BuildClassfn.c │ ├── MESH_BuildEdgeClassfn.c │ ├── MESH_BuildFaceClassfn.c │ ├── MESH_BuildVertexClassfn.c │ ├── MESH_CheckTopo.c │ ├── MESH_DelInterior.c │ ├── MESH_Gen_Structured.c │ ├── MESH_GetElementGraph.c │ ├── MESH_InitFromGenDesc.c │ ├── MESH_Renumber.c │ ├── MESH_Tet2Hex.c │ ├── MESH_Tri2Quad.c │ ├── MEs_Angle.c │ ├── MF_Coords.c │ ├── MFs_DihedralAngle.c │ └── MR_Coords.c ├── io │ ├── ExodusII_GetElementGraph.c │ ├── MESH_ExportToDX.c │ ├── MESH_ExportToDXBin.c │ ├── MESH_ExportToExodusII.c │ ├── MESH_ExportToFLAGX3D.c │ ├── MESH_ExportToFile.c │ ├── MESH_ExportToGMV.c │ ├── MESH_ExportToOFF.c │ ├── MESH_ExportToSTL.c │ ├── MESH_ImportFromExodusII.c │ ├── MESH_ImportFromFLAGX3D.c │ ├── MESH_ImportFromFile.c │ ├── MESH_ImportFromGMV.c │ ├── MESH_ImportFromNemesisI.c │ ├── MESH_ReadExodusII_Partial.c │ └── MESH_ReadExodusII_Serial.c ├── misc │ ├── List_PrintID.c │ ├── MF_CondNums.c │ ├── MSTK_Print.c │ ├── MSTK_VecFuncs.c │ └── compare_funcs.c ├── mod │ ├── ME_Collapse.c │ ├── ME_MultiSplit.c │ ├── ME_Split.c │ ├── ME_Split_SimplexMesh.c │ ├── ME_Swap2D.c │ ├── MEs_Merge.c │ ├── MEs_Merge_FN.c │ ├── MEs_Merge_RN.c │ ├── MF_Split.c │ ├── MF_Split_SimplexMesh.c │ ├── MF_Split_with_Edge.c │ ├── MFs_Join.c │ ├── MFs_Merge.c │ ├── MFs_Merge_FN.c │ ├── MFs_Merge_R1R2.c │ ├── MFs_Merge_R3R4.c │ ├── MR_Split_with_EdgeLoop.c │ ├── MRs_Join.c │ ├── MVs_Merge.c │ ├── MVs_Merge_FN.c │ ├── MVs_Merge_R1R2.c │ └── MVs_Merge_R3R4.c ├── par │ ├── FixColumnPartitions.c │ ├── MESH_AddGhost.c │ ├── MESH_AssignGlobalIDs.c │ ├── MESH_AssignGlobalIDs_point.c │ ├── MESH_BuildConnection.c │ ├── MESH_BuildGhostList.c │ ├── MESH_BuildPBoundary.c │ ├── MESH_BuildSubMesh.c │ ├── MESH_ConcatSubMesh.c │ ├── MESH_CopyAttr.c │ ├── MESH_CopySet.c │ ├── MESH_GathScat1Attribute.c │ ├── MESH_Get_Partitioning.c │ ├── MESH_LabelPType.c │ ├── MESH_ParallelAdj.c │ ├── MESH_Parallel_AddGhost.c │ ├── MESH_Parallel_Check.c │ ├── MESH_Partition.c │ ├── MESH_PartitionWithMetis.c │ ├── MESH_PartitionWithZoltan.c │ ├── MESH_Partition_and_Send.c │ ├── MESH_RecvMesh.c │ ├── MESH_Recv_Attribute.c │ ├── MESH_Recv_AttributeMetaData.c │ ├── MESH_Recv_MSet.c │ ├── MESH_Recv_MSetMetaData.c │ ├── MESH_Recv_MetaData.c │ ├── MESH_Recv_NonVertexEntities.c │ ├── MESH_Recv_VertexCoords.c │ ├── MESH_Recv_Vertices.c │ ├── MESH_Renumber_GlobalIDs.c │ ├── MESH_SendMesh.c │ ├── MESH_Send_Attribute.c │ ├── MESH_Send_AttributeMetaData.c │ ├── MESH_Send_MSet.c │ ├── MESH_Send_MSetMetaData.c │ ├── MESH_Send_MetaData.c │ ├── MESH_Send_NonVertexEntities.c │ ├── MESH_Send_VertexCoords.c │ ├── MESH_Send_Vertices.c │ ├── MESH_Update1Attribute.c │ ├── MESH_UpdateAttributes.c │ ├── MESH_UpdateVertexCoords.c │ ├── MESH_XchngEdgeFaceAttrib.c │ ├── MSTK_Mesh_Distribute.c │ ├── MSTK_Mesh_Read_Distribute.c │ └── MSTK_Weave_DistributedMeshes.c └── util │ ├── Graph_renumber.c │ ├── Hash.c │ ├── List.c │ ├── MSTK_Report.c │ ├── MSTK_Version.c │ └── mstk_quicksort.c ├── unittests ├── CMakeLists.txt ├── parallel │ ├── 4proc │ │ ├── Main.cc │ │ ├── Test_RenumberGlobalIDs.cc │ │ ├── Test_UpdAtt.cc │ │ ├── Test_UpdVtxCoords.cc │ │ ├── Test_partition.cc │ │ ├── Test_partition2D_ExodusII.cc │ │ ├── Test_weave2D.cc │ │ ├── mesh5x5-skewed.exo │ │ ├── mixed_pinchout.par.4.0 │ │ ├── mixed_pinchout.par.4.1 │ │ ├── mixed_pinchout.par.4.2 │ │ ├── mixed_pinchout.par.4.3 │ │ ├── quad10x10.mstk │ │ ├── quad3x2.mstk.0 │ │ ├── quad3x2.mstk.1 │ │ ├── quad3x2.mstk.2 │ │ ├── quad3x2.mstk.3 │ │ ├── quad4x3.mstk.4.0 │ │ ├── quad4x3.mstk.4.1 │ │ ├── quad4x3.mstk.4.2 │ │ ├── quad4x3.mstk.4.3 │ │ ├── quad6x5.mstk │ │ └── test_ME_Collapse_4proc.cc │ └── 8proc │ │ ├── Main.cc │ │ ├── Test_partition3D.cc │ │ ├── Test_partition3D_ExodusII.cc │ │ ├── Test_weave3D.cc │ │ ├── hex2x2x2.mstk │ │ ├── hex3x2x2.mstk.0 │ │ ├── hex3x2x2.mstk.1 │ │ ├── hex3x2x2.mstk.2 │ │ ├── hex3x2x2.mstk.3 │ │ ├── hex3x2x2.mstk.4 │ │ ├── hex3x2x2.mstk.5 │ │ ├── hex3x2x2.mstk.6 │ │ ├── hex3x2x2.mstk.7 │ │ ├── hex4x4x2.mstk │ │ └── hex_3x3x3_ss.exo └── serial │ ├── Main.cc │ ├── degenpoly3.exo │ ├── mesh5x5-skewed.exo │ ├── mixed_pinchout.exo │ ├── multiblock-poly3.exo │ ├── onehex.mstk │ ├── onepolyhed.mstk │ ├── oneprism.mstk │ ├── onepyramid.mstk │ ├── onetet.mstk │ ├── poly2.exo │ ├── reghex3D.mstk │ ├── regquad2D.mstk │ ├── test_Attributes.cc │ ├── test_Graph_Read_ExodusII.cc │ ├── test_ME_Collapse.cc │ ├── test_ME_Split.cc │ ├── test_ME_Split_SimplexMesh.cc │ ├── test_MF_Rem_Edge_F1F3.cc │ ├── test_MF_Split.cc │ ├── test_MF_Split_SimplexMesh.cc │ ├── test_MF_Split_with_Edge.cc │ ├── test_MFs_Dihedral_Angle.cc │ ├── test_MR_Edges_Hex_FN.cc │ ├── test_MR_Edges_Polyhed_FN.cc │ ├── test_MR_Edges_Prism_FN.cc │ ├── test_MR_Edges_Pyramid_FN.cc │ ├── test_MR_Edges_Tet_FN.cc │ ├── test_MR_Rem_Face_FNR3R4.cc │ ├── test_MR_Vertices_Hex_FN.cc │ ├── test_MR_Vertices_Polyhed_FN.cc │ ├── test_MR_Vertices_Prism_FN.cc │ ├── test_MR_Vertices_Pyramid_FN.cc │ ├── test_MR_Vertices_Tet_FN.cc │ ├── test_Markers.cc │ ├── test_Read_Write_ExodusII.cc │ ├── twohex.mstk │ └── twotets.mstk └── utils ├── CMakeLists.txt ├── chkmesh ├── CMakeLists.txt └── src │ ├── chkmesh.c │ └── geom.c ├── exoatt ├── CMakeLists.txt ├── doc │ └── exoatt.txt ├── src │ └── exoatt.c └── unittests │ ├── CMakeLists.txt │ ├── Main.cc │ ├── reghex3D.exo │ └── verify_exoatt.cc ├── meshconvert ├── CMakeLists.txt └── src │ └── meshconvert.c ├── mkstruc ├── CMakeLists.txt └── src │ ├── mkstruc.c │ ├── mkstruc.h │ └── transform_xyz.c ├── tet2hex ├── CMakeLists.txt └── src │ └── tet2hex.c ├── tri2quad ├── CMakeLists.txt └── src │ └── tri2quad.c └── vizpart ├── CMakeLists.txt └── src └── vizpart.c /.gitmodules: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeshToolkit/MSTK/fd1c0c477e635fac34b207e443331aed145fdd96/.gitmodules -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | 3 | sudo: required 4 | dist: bionic 5 | 6 | addons: 7 | apt: 8 | packages: 9 | - libopenmpi-dev 10 | - openmpi-bin 11 | - libmetis-dev 12 | - libhdf5-openmpi-dev 13 | - libnetcdf-dev 14 | - libexodusii-dev 15 | - libexodusii5 16 | - libnemesis3 17 | - libunittest++-dev 18 | - libtrilinos-zoltan-dev 19 | env: 20 | global: 21 | - CCACHE_CPP2=yes 22 | matrix: 23 | - PARALLEL=ON 24 | - PARALLEL=OFF 25 | 26 | before_install: 27 | - test -n $CC && unset CC 28 | - test -n $CXX && unset CXX 29 | 30 | after_failure: 31 | - echo $TRAVIS_TEST_RESULT 32 | - cat Testing/Temporary/LastTest.log 33 | 34 | script: 35 | - > 36 | mkdir build && 37 | cd build && 38 | cmake 39 | -DCMAKE_BUILD_TYPE=Release 40 | -DCMAKE_INSTALL_PREFIX=$HOME 41 | -DCMAKE_PREFIX_PATH=/usr/include/trilinos 42 | -DENABLE_PARALLEL=$PARALLEL 43 | -DENABLE_METIS=yes 44 | -DENABLE_ZOLTAN=yes 45 | -DENABLE_ExodusII=yes 46 | -DENABLE_Tests=yes 47 | .. && 48 | make VERBOSE=1 -j2 && 49 | make test && 50 | make install 51 | 52 | cache: 53 | - ccache 54 | 55 | compiler: 56 | - gcc 57 | - clang 58 | 59 | notifications: 60 | email: 61 | - raovgarimella@gmail.com 62 | on_success: never 63 | on_failure: always 64 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2019, Triad National Security, LLC 2 | All rights reserved. 3 | 4 | Copyright 2019 Triad National Security, LLC. This software was produced 5 | under U.S. Government contract 89233218CNA000001 for Los Alamos National 6 | Laboratory (LANL), which is operated by Los Alamos National Security, LLC for 7 | the U.S. Department of Energy/National Nuclear Safety Administration. 8 | 9 | All rights in the program are reserved by Triad National Security, 10 | LLC, and the U.S. Department of Energy/National Nuclear Security 11 | Administration. The Government is granted for itself and others acting 12 | on its behalf a nonexclusive, paid-up, irrevocable worldwide license 13 | in this material to reproduce, prepare derivative works, distribute 14 | copies to the public, perform publicly and display publicly, and to 15 | permit others to do so. 16 | 17 | This is open source software; you can you can redistribute it and/or modify it 18 | under the terms of the 3-Clause BSD License. If software is modified to produce 19 | derivative works, such modified software should be clearly marked, so 20 | as not to confuse it with the version available from LANL. 21 | 22 | Additionally, redistribution and use in source and binary forms, with or 23 | without modification, are permitted provided that the following conditions are 24 | met: 25 | 26 | 1. Redistributions of source code must retain the above copyright notice, 27 | this list of conditions and the following disclaimer. 28 | 2. Redistributions in binary form must reproduce the above copyright 29 | notice, this list of conditions and the following disclaimer in the 30 | documentation and/or other materials provided with the distribution. 31 | 3. Neither the name of Los Alamos National Security, LLC, Los Alamos 32 | National Laboratory, LANL, the U.S. Government, nor the names of its 33 | contributors may be used to endorse or promote products derived from this 34 | software without specific prior written permission. 35 | 36 | THIS SOFTWARE IS PROVIDED BY TRIAD NATIONAL SECURITY, LLC AND 37 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 38 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 39 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 40 | TRIAD NATIONAL SECURITY, LLC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 41 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 42 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 43 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 44 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 45 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 46 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 47 | POSSIBILITY OF SUCH DAMAGE. 48 | -------------------------------------------------------------------------------- /config/application_cmake/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Triad National Security, LLC. All rights reserved. 2 | # 3 | # This file is part of the MSTK project. Please see the license file at 4 | # the root of this repository or at 5 | # https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 6 | 7 | project (OPTMESH) 8 | 9 | cmake_minimum_required(VERSION 2.8) 10 | 11 | set(ARCHOS ${CMAKE_SYSTEM_PROCESSOR}_${CMAKE_SYSTEM_NAME}) 12 | 13 | # 14 | # MSTK Libraries and includes 15 | # 16 | 17 | if (NOT MSTK_DIR) 18 | message(FATAL_ERROR "Error: MSTK top level installation dir must be defined") 19 | endif() 20 | 21 | # Look for the cmake configuration of the MSTK build (if it exists) 22 | 23 | find_file(MSTK_CONFIG_FILE MSTKConfig.cmake PATH ${MSTK_DIR}/share/cmake) 24 | 25 | 26 | if (MSTK_CONFIG_FILE) 27 | 28 | # if we found the MSTK config file get all the required info from it 29 | 30 | include(${MSTK_CONFIG_FILE}) 31 | 32 | find_library(MSTK_LIBRARY ${MSTK_LIBRARY_NAME} PATH ${MSTK_LIBRARY_DIR}) 33 | if (NOT MSTK_LIBRARY) 34 | message(FATAL_ERROR "Could not find MSTK_LIBRARY with name ${MSTK_LIBRARY_NAME}") 35 | endif() 36 | 37 | else () 38 | 39 | # Did not find the MSTK cmake configuration file 40 | # We have to discover all the libraries and includes ourselves 41 | # 42 | # To keep example simple, just quit 43 | 44 | message(FATAL_ERROR "Could not find MSTK configuration file") 45 | 46 | endif() 47 | 48 | # Now gather the source files for this application, 49 | # and link executable 50 | 51 | file (GLOB appsrcfiles src/*.c) 52 | 53 | add_executable(myapp ${appsrcfiles}) 54 | include_directories(${PROJECT_SOURCE_DIR}/include ${MSTK_INCLUDE_DIR}) 55 | target_link_libraries(myapp ${MSTK_LIBRARY} ${MSTK_TPL_LIBRARIES} z m) 56 | 57 | 58 | # install 59 | 60 | if (CMAKE_INSTALL_PREFIX) 61 | install(TARGETS myapp DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/${ARCHOS}/myapp) 62 | else () 63 | install(TARGETS myapp DESTINATION ${PROJECT_SOURCE_DIR}/bin/${ARCHOS}/myapp) 64 | endif () 65 | 66 | 67 | -------------------------------------------------------------------------------- /config/application_cmake/do-configure-app: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Configure script to build MSTK based application using MSTK config file 4 | # 5 | # Run this script in a separate build directory 6 | # DO NOT RUN THIS SCRIPT IN THE TOP LEVEL DIRECTORY OF THE PROJECT 7 | # 8 | # Run this script as ./do_configure and then run 'make install' 9 | # or 'make' followed by 'make install' 10 | # 11 | # If you compiled MSTK with parallel support, find_package(MPI) and 12 | # use mpicc and mpiCC as your C and C++ compilers within your 13 | # CMakeLists.txt so that the right MPI includes and libraries are 14 | # found 15 | # 16 | # Unless your MSTK installation specifically excluded ExodusII support, 17 | # you must specify where the ExodusII and NetCDF packages are installed 18 | # through ExodusII_DIR or ExodusII_LIB_DIR and NetCDF_DIR or NetCDF_LIB_DIR 19 | # 20 | # 21 | # Use CMAKE_BUILD_TYPE:STRING="Release" for optimized code and 22 | # ="Debug" for debug code 23 | # ="RelWithDebugInfo" for optimized code with debug symbols 24 | # ="MinSizeRel" for min size optimized library 25 | # 26 | 27 | # CMAKE_INSTALL_PREFIX indicates the top level directory for the installation 28 | # the project executable or library and include files 29 | # 30 | # 31 | 32 | 33 | rm -f CMakeCache.txt 34 | 35 | SOURCE=path_to_my_app_source 36 | 37 | /usr/bin/cmake \ 38 | -D CMAKE_PREFIX_PATH:FILEPATH="semicolon/separated;list/of;directories/where/tpls/are;located" \ 39 | -D CMAKE_C_COMPILER:FILEPATH="mpicc" \ 40 | -D CMAKE_BUILD_TYPE:STRING="Debug" \ 41 | -D CMAKE_INSTALL_PREFIX:FILEPATH=$SOURCE \ 42 | -D MSTK_ROOT:FILEPATH=path_to_mstk_installation \ 43 | $SOURCE 44 | -------------------------------------------------------------------------------- /docs/MSTK.dvi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeshToolkit/MSTK/fd1c0c477e635fac34b207e443331aed145fdd96/docs/MSTK.dvi -------------------------------------------------------------------------------- /docs/MSTK.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeshToolkit/MSTK/fd1c0c477e635fac34b207e443331aed145fdd96/docs/MSTK.pdf -------------------------------------------------------------------------------- /docs/figures/MFs_Join.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeshToolkit/MSTK/fd1c0c477e635fac34b207e443331aed145fdd96/docs/figures/MFs_Join.pdf -------------------------------------------------------------------------------- /docs/figures/classfn.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeshToolkit/MSTK/fd1c0c477e635fac34b207e443331aed145fdd96/docs/figures/classfn.pdf -------------------------------------------------------------------------------- /docs/figures/examplemesh.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeshToolkit/MSTK/fd1c0c477e635fac34b207e443331aed145fdd96/docs/figures/examplemesh.pdf -------------------------------------------------------------------------------- /docs/figures/examplemodel.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeshToolkit/MSTK/fd1c0c477e635fac34b207e443331aed145fdd96/docs/figures/examplemodel.pdf -------------------------------------------------------------------------------- /docs/figures/face_def.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeshToolkit/MSTK/fd1c0c477e635fac34b207e443331aed145fdd96/docs/figures/face_def.pdf -------------------------------------------------------------------------------- /docs/figures/flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeshToolkit/MSTK/fd1c0c477e635fac34b207e443331aed145fdd96/docs/figures/flow.png -------------------------------------------------------------------------------- /docs/figures/reg_conventions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeshToolkit/MSTK/fd1c0c477e635fac34b207e443331aed145fdd96/docs/figures/reg_conventions.pdf -------------------------------------------------------------------------------- /docs/figures/repF1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeshToolkit/MSTK/fd1c0c477e635fac34b207e443331aed145fdd96/docs/figures/repF1.pdf -------------------------------------------------------------------------------- /docs/figures/repF4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeshToolkit/MSTK/fd1c0c477e635fac34b207e443331aed145fdd96/docs/figures/repF4.pdf -------------------------------------------------------------------------------- /docs/figures/repR1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeshToolkit/MSTK/fd1c0c477e635fac34b207e443331aed145fdd96/docs/figures/repR1.pdf -------------------------------------------------------------------------------- /docs/figures/repR2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeshToolkit/MSTK/fd1c0c477e635fac34b207e443331aed145fdd96/docs/figures/repR2.pdf -------------------------------------------------------------------------------- /docs/figures/repR4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeshToolkit/MSTK/fd1c0c477e635fac34b207e443331aed145fdd96/docs/figures/repR4.pdf -------------------------------------------------------------------------------- /docs/parallel.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeshToolkit/MSTK/fd1c0c477e635fac34b207e443331aed145fdd96/docs/parallel.pdf -------------------------------------------------------------------------------- /example/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Triad National Security, LLC. All rights reserved. 2 | # 3 | # This file is part of the MSTK project. Please see the license file at 4 | # the root of this repository or at 5 | # https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 6 | 7 | 8 | include_directories(${PROJECT_BINARY_DIR}/include) 9 | 10 | 11 | add_executable(serial_example src/serial_example.c) 12 | target_link_libraries(serial_example 13 | ${MSTKLIB} 14 | ${ExodusII_LIBRARIES} 15 | ${NetCDF_LIBRARIES} 16 | ${HDF5_LIBRARIES} 17 | ${METIS_LIBRARIES} 18 | ${ZOLTAN_LIBRARIES} 19 | m) 20 | install(TARGETS serial_example DESTINATION ${PROJECT_SOURCE_DIR}/example) 21 | 22 | if (ENABLE_PARALLEL) 23 | add_executable(parallel_example src/parallel_example.c) 24 | target_link_libraries(parallel_example 25 | ${MSTKLIB} 26 | ${ExodusII_LIBRARIES} 27 | ${NetCDF_LIBRARIES} 28 | ${HDF5_LIBRARIES} 29 | ${METIS_LIBRARIES} 30 | ${ZOLTAN_LIBRARIES} 31 | m) 32 | install(TARGETS parallel_example DESTINATION ${PROJECT_SOURCE_DIR}/example) 33 | endif () 34 | -------------------------------------------------------------------------------- /example/README-examples: -------------------------------------------------------------------------------- 1 | 2 | After building the executables serial_example and parallel_examples, cd into 3 | the test directory and execute 4 | 5 | ../serial_example serial_example_mesh.mstk 6 | 7 | mpirun -n 4 ../parallel_example parallel_example_mesh.mstk 8 | 9 | 10 | -------------------------------------------------------------------------------- /example/test/example-F1.mstk: -------------------------------------------------------------------------------- 1 | MSTK 1.0 2 | F1 18 31 14 0 3 | vertices 4 | 0.00 0.00 0.00 0 1 5 | 0.33 0.00 0.00 1 1 6 | 0.66 0.00 0.00 1 1 7 | 1.00 0.00 0.00 0 2 8 | 0.00 0.33 0.00 1 4 9 | 0.66 0.66 0.00 2 1 10 | 0.66 1.00 0.00 1 3 11 | 0.16 0.84 0.00 2 1 12 | 0.00 0.66 0.00 1 4 13 | 0.16 0.33 0.00 2 1 14 | 0.50 0.33 0.00 2 1 15 | 0.40 0.84 0.00 2 1 16 | 1.00 0.66 0.00 1 2 17 | 0.00 1.00 0.00 0 4 18 | 1.00 1.00 0.00 0 3 19 | 0.66 0.50 0.00 2 1 20 | 0.33 1.00 0.00 1 3 21 | 1.00 0.33 0.00 1 2 22 | edges 23 | 2 1 1 1 24 | 2 3 1 1 25 | 3 4 1 1 26 | 4 18 1 2 27 | 2 11 2 1 28 | 15 7 1 3 29 | 14 8 2 1 30 | 18 16 2 1 31 | 12 16 2 1 32 | 10 5 2 1 33 | 11 16 2 1 34 | 15 13 1 2 35 | 14 17 1 3 36 | 17 7 1 3 37 | 8 9 2 1 38 | 18 13 1 2 39 | 14 9 1 4 40 | 10 11 2 1 41 | 10 2 2 1 42 | 9 10 2 1 43 | 16 6 2 1 44 | 6 13 2 1 45 | 7 6 2 1 46 | 17 12 2 1 47 | 8 17 2 1 48 | 3 11 2 1 49 | 11 18 2 1 50 | 1 5 1 4 51 | 5 9 1 4 52 | 7 12 2 1 53 | 8 12 2 1 54 | faces edge 55 | 4 3 4 -27 -26 2 1 56 | 6 18 11 -9 -31 15 20 2 1 57 | 3 25 -13 7 2 1 58 | 3 31 -24 -25 2 1 59 | 3 2 26 -5 2 1 60 | 4 -28 -1 -19 10 2 1 61 | 4 16 -22 -21 -8 2 1 62 | 4 22 -12 6 23 2 1 63 | 3 -30 -14 24 2 1 64 | 3 -10 -20 -29 2 1 65 | 3 19 5 -18 2 1 66 | 4 9 21 -23 30 2 1 67 | 3 -15 -7 17 2 1 68 | 3 27 8 -11 2 1 69 | attributes 70 | velocity 71 | VECTOR 72 | 3 73 | MVERTEX 74 | 18 75 | 0 1 0.0 0.0 0.0 76 | 0 2 3.3 0.0 0.0 77 | 0 3 6.6 0.0 0.0 78 | 0 4 10.0 0.0 0.0 79 | 0 5 0.0 3.3 0.0 80 | 0 6 6.6 6.6 0.0 81 | 0 7 6.6 10.0 0.0 82 | 0 8 1.6 8.4 0.0 83 | 0 9 0.0 6.6 0.0 84 | 0 10 1.6 3.3 0.0 85 | 0 11 5.0 3.3 0.0 86 | 0 12 4.0 6.6 0.0 87 | 0 13 10.0 6.6 0.0 88 | 0 14 0.0 10.0 0.0 89 | 0 15 10.0 10.0 0.0 90 | 0 16 6.6 5.0 0.0 91 | 0 17 3.3 10.0 0.0 92 | 0 18 10.0 3.3 0.0 93 | diffusity 94 | TENSOR 95 | 3 96 | MFACE 97 | 14 98 | 2 1 1.0 10.0 2.0 99 | 2 2 1.0 10.0 2.0 100 | 2 3 1.0 10.0 2.0 101 | 2 4 1.0 10.0 2.0 102 | 2 5 1.0 10.0 2.0 103 | 2 6 1.0 10.0 2.0 104 | 2 7 1.0 10.0 2.0 105 | 2 8 1.0 10.0 2.0 106 | 2 9 1.0 10.0 2.0 107 | 2 10 1.0 10.0 2.0 108 | 2 11 1.0 10.0 2.0 109 | 2 12 1.0 10.0 2.0 110 | 2 13 1.0 10.0 2.0 111 | 2 14 1.0 10.0 2.0 112 | -------------------------------------------------------------------------------- /example/test/example-R1.mstk: -------------------------------------------------------------------------------- 1 | MSTK 1.0 2 | R1 18 0 14 0 3 | vertices 4 | 0.00 0.00 0.00 0 1 5 | 0.33 0.00 0.00 1 1 6 | 0.66 0.00 0.00 1 1 7 | 1.00 0.00 0.00 0 2 8 | 0.00 0.33 0.00 1 4 9 | 0.66 0.66 0.00 2 1 10 | 0.66 1.00 0.00 1 3 11 | 0.16 0.84 0.00 2 1 12 | 0.00 0.66 0.00 1 4 13 | 0.16 0.33 0.00 2 1 14 | 0.50 0.33 0.00 2 1 15 | 0.40 0.84 0.00 2 1 16 | 1.00 0.66 0.00 1 2 17 | 0.00 1.00 0.00 0 4 18 | 1.00 1.00 0.00 0 3 19 | 0.66 0.50 0.00 2 1 20 | 0.33 1.00 0.00 1 3 21 | 1.00 0.33 0.00 1 2 22 | faces vertex 23 | 4 3 4 18 11 2 1 24 | 6 9 10 11 16 12 8 2 1 25 | 3 14 8 17 2 1 26 | 3 8 12 17 2 1 27 | 3 2 3 11 2 1 28 | 4 1 2 10 5 2 1 29 | 4 6 16 18 13 2 1 30 | 4 6 13 15 7 2 1 31 | 3 7 17 12 2 1 32 | 3 5 10 9 2 1 33 | 3 2 11 10 2 1 34 | 4 12 16 6 7 2 1 35 | 3 9 8 14 2 1 36 | 3 11 18 16 2 1 37 | -------------------------------------------------------------------------------- /example/test/serial_example_mesh.mstk: -------------------------------------------------------------------------------- 1 | MSTK 1.0 2 | F1 9 16 8 0 3 | vertices 4 | -0.500000000 0.500000000 0.000000000 0 1 5 | 0.500000000 0.500000000 0.000000000 0 2 6 | 0.500000000 -0.500000000 0.000000000 0 3 7 | -0.500000000 -0.500000000 0.000000000 0 4 8 | -0.500000000 0.100000000 0.000000000 1 1 9 | -0.200000000 -0.500000000 0.000000000 1 2 10 | 0.500000000 -0.200000000 0.000000000 1 3 11 | -0.150000000 0.500000000 0.000000000 1 4 12 | -0.200000000 0.225000000 0.000000000 2 1 13 | edges 14 | 4 5 1 1 15 | 5 1 1 1 16 | 4 6 1 2 17 | 6 3 1 2 18 | 3 7 1 3 19 | 7 2 1 3 20 | 1 8 1 4 21 | 8 2 1 4 22 | 5 6 2 1 23 | 5 8 2 1 24 | 6 7 2 1 25 | 7 8 2 1 26 | 5 9 2 1 27 | 6 9 2 1 28 | 7 9 2 1 29 | 8 9 2 1 30 | faces edge 31 | 3 3 -9 -1 2 1 32 | 3 -7 -2 10 2 1 33 | 3 5 -11 4 2 1 34 | 3 -8 -12 6 2 1 35 | 3 -13 9 14 2 1 36 | 3 -14 11 15 2 1 37 | 3 13 -16 -10 2 1 38 | 3 -15 12 16 2 1 39 | regions face 40 | -------------------------------------------------------------------------------- /include/Hash.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #ifndef _H_HASH 10 | #define _H_HASH 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include "MSTK_types.h" 17 | #include "MSTK_defines.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | #ifdef _H_Hash_Private 24 | typedef struct Hash { 25 | unsigned int nentdat; 26 | void **entry; 27 | } Hash, *Hash_ptr; 28 | 29 | void pvtHash_Get_Pars(Hash_ptr h, unsigned int *nent, unsigned int *p, int *t); 30 | unsigned int pvtHash_Get_Nent(Hash_ptr h); 31 | unsigned int pvtHash_Get_Size(Hash_ptr h); 32 | void pvtHash_Set_Pars(Hash_ptr h, unsigned int nent, unsigned int p, int t); 33 | unsigned int pvtHash_Function(unsigned int np, void* *p); 34 | unsigned int pvtHash_Enlarge(Hash_ptr h); 35 | int pvtHash_CheckKeys(unsigned int np1, void* *p1, unsigned int np2, void* *p2); 36 | void pvtHash_CheckSize(Hash_ptr h); 37 | #else 38 | typedef void *Hash_ptr; 39 | #endif 40 | 41 | Hash_ptr Hash_New(unsigned int inisize, int type); 42 | void Hash_Delete(Hash_ptr h); 43 | 44 | Hash_ptr Hash_Add(Hash_ptr h, void *entry, unsigned int np, void* *p); 45 | Hash_ptr Hash_ChknAdd(Hash_ptr h, void *entry, unsigned int np, void* *p); 46 | int Hash_Rem(Hash_ptr h, void *entry, unsigned int np, void* *p); 47 | void *Hash_Entry(Hash_ptr h, unsigned int np, void* *p); 48 | int Hash_Num_Entries(Hash_ptr h); 49 | List_ptr Hash_Entries(Hash_ptr h); 50 | 51 | void Hash_Print(Hash_ptr h); 52 | 53 | void Hash_Lock(int *plock); 54 | void Hash_UnLock(int *plock); 55 | int Hash_IsLocked(int lock); 56 | 57 | int Hash_AutoRemove(Hash_ptr h); 58 | void Hash_Set_AutoRemove(Hash_ptr h, int t); 59 | unsigned int Hash_Remove_Unused(Hash_ptr h); 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif 66 | 67 | -------------------------------------------------------------------------------- /include/List.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #ifndef _H_LIST 10 | #define _H_LIST 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include "MSTK_types.h" 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | #ifdef _H_List_Private 23 | typedef struct List { 24 | unsigned int nentdat; 25 | unsigned int *remdat; 26 | void **entry; 27 | } List, *List_ptr; 28 | 29 | void pvtList_Get_Pars(List_ptr l, int *nent, int *p, int *nrem, int *rem1); 30 | int pvtList_Get_Nent(List_ptr l); 31 | void pvtList_Set_Pars(List_ptr l, int nent, int p, int nrem, int rem1); 32 | #else 33 | typedef void *List_ptr; 34 | #endif 35 | 36 | List_ptr List_New(int inisize); 37 | void List_Delete(List_ptr list); 38 | List_ptr List_Compress(List_ptr list); 39 | List_ptr List_Copy(List_ptr list); 40 | 41 | List_ptr List_Add(List_ptr l, void *entry); 42 | List_ptr List_ChknAdd(List_ptr l, void *entry); 43 | List_ptr List_Insert(List_ptr l, void *nuentry, void *b4entry); 44 | List_ptr List_Inserti(List_ptr l, void *nuentry, int i); 45 | int List_Rem(List_ptr l, void *entry); 46 | int List_Remi(List_ptr l, int i); 47 | int List_Remi_Raw(List_ptr l, int i); 48 | int List_RemSorted(List_ptr l, void *entry, int (*entry2int)(void *)); 49 | int List_Replace(List_ptr l, void *entry, void *nuentry); 50 | int List_Replacei(List_ptr l, int i, void *nuentry); 51 | int List_Contains(List_ptr l, void *entry); 52 | int List_Locate(List_ptr l, void *entry); 53 | void *List_Entry(List_ptr l, int i); 54 | void *List_Entry_Raw(List_ptr l, int i); 55 | void *List_Next_Entry(List_ptr l, int *i); 56 | int List_Num_Entries(List_ptr l); 57 | int List_Num_Entries_Raw(List_ptr l); 58 | List_ptr List_Cat(List_ptr dest, List_ptr src); 59 | void List_Sort(List_ptr l, size_t num, size_t size, 60 | int(*comp)(const void *,const void *)); 61 | void *List_Search(List_ptr l, const void *key, size_t num, size_t size, 62 | int(*comp)(const void *,const void *)); 63 | 64 | #ifdef DEBUG 65 | void List_Print(List_ptr l); 66 | #endif 67 | 68 | /* Extra functionality for hash-tables */ 69 | 70 | void* *List_Entries(List_ptr l); 71 | 72 | 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /include/MAttrib.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #ifndef _H_MATTRIB 10 | #define _H_MATTRIB 11 | 12 | 13 | #include "MSTK_defines.h" 14 | #include "MSTK_types.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #ifdef _H_MAttrib_Private 21 | typedef struct MAttrib { /* Attribute Definition */ 22 | char *name; 23 | MAttType type; 24 | int ncomp; 25 | MType entdim; 26 | Mesh_ptr mesh; 27 | } MAttrib, *MAttrib_ptr; 28 | 29 | typedef struct MAttIns { /* Instance of an attribute */ 30 | MAttrib_ptr attrib; 31 | union { 32 | int ival; 33 | double lval; 34 | void *pval; 35 | } att_val; 36 | } MAttIns, *MAttIns_ptr; 37 | #endif 38 | 39 | 40 | MAttIns_ptr MAttIns_New(MAttrib_ptr attrib); 41 | MAttrib_ptr MAttIns_Attrib(MAttIns_ptr att); 42 | void MAttIns_Set_Value(MAttIns_ptr att, int ival, double rval, void *pval); 43 | int MAttIns_Get_Value(MAttIns_ptr att, int *ival, double *rval, void **pval); 44 | void MAttIns_Delete(MAttIns_ptr att); 45 | 46 | 47 | MAttrib_ptr MAttrib_New(Mesh_ptr mesh, const char *att_name, MAttType att_type, MType entdim, ...); 48 | char *MAttrib_Get_Name(MAttrib_ptr attrib, char *att_name); 49 | MAttType MAttrib_Get_Type(MAttrib_ptr attrib); 50 | MType MAttrib_Get_EntDim(MAttrib_ptr attrib); 51 | int MAttrib_Get_NumComps(MAttrib_ptr attrib); 52 | void MAttrib_Delete(MAttrib_ptr attrib); 53 | void MAttrib_Clear(MAttrib_ptr attrib); 54 | 55 | 56 | 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /include/MNode.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #ifndef _H_MNode 10 | #define _H_MNode 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | 17 | typedef struct MNode { 18 | int id; 19 | int floating; 20 | double coord[3]; 21 | Mesh_ptr mesh; 22 | MTopoEntity_ptr mentity; 23 | } MNode, *MNode_ptr; 24 | 25 | int MN_ID(MNode_ptr mnode); 26 | int MN_Is_Floating(MNode_ptr mnode); 27 | void MN_SetCoords(MNode_ptr mnode); 28 | void MN_Coords(MNode_ptr mnode, double *xyz); 29 | int MN_MTopoDim(MNode_ptr mnode); 30 | MTopoEntity_ptr MN_MTopoEntity(MNode_ptr mnode); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | -------------------------------------------------------------------------------- /include/MSTK_VecFuncs.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #ifndef _H_MSTK_VecFuncs 10 | #define _H_MSTK_VecFuncs 11 | 12 | 13 | /* Vector functions for internal use in MSTK */ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | void MSTK_VDiff3(double *a, double *b, double *c); 20 | void MSTK_VSum3(double *a, double *b, double *c); 21 | void MSTK_VScale3(double *a, double s); 22 | double MSTK_VLen3(double *a); 23 | double MSTK_VLenSqr3(double *a); 24 | void MSTK_VNormalize3(double *a); 25 | double MSTK_VDot3(double *a, double *b); 26 | void MSTK_VCross3(double *a, double *b, double *x); 27 | void MSTK_VCopy3(double *a, double *b); 28 | void MSTK_VNeg3(double *a); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /include/MSTK_defines.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #ifndef _H_MSTK_DEFINES 10 | #define _H_MSTK_DEFINES 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | 17 | /* The following lines (MSTK_*_VERSION and if present, #define 18 | * MSTK_HAVE_MPI) are filled in by CMake during installation */ 19 | 20 | #define MSTK_VERSION_MAJOR @MSTK_VERSION_MAJOR@ 21 | #define MSTK_VERSION_MINOR @MSTK_VERSION_MINOR@ 22 | #define MSTK_VERSION_PATCH @MSTK_VERSION_PATCH@ 23 | 24 | #cmakedefine MSTK_HAVE_MPI 25 | 26 | 27 | 28 | #define MSTK_FILE_VER 1.0 29 | 30 | #define MSTK_UNKNOWN -1 31 | 32 | #define MSTK_MAXREP 10 33 | 34 | /* Number of edges (or vertices) in a polygon and number of faces in a 35 | polyhedron is determined by how much space we have to store their 36 | directions */ 37 | 38 | #define MAXPV2 30 39 | #define MAXPV3 200 40 | #define MAXPF3 16*(8*sizeof(unsigned int)) /* Actually it is unlimited */ 41 | 42 | #define NMAXATT 10 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /include/MSTK_externs.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #ifndef _H_MSTK_EXTERN 10 | #define _H_MSTK_EXTERN 11 | 12 | /* If the compiler complains, change first line to 13 | #ifndef _H_MSTK_EXTERN && _H_MSTK_GLOBALVARS 14 | */ 15 | 16 | #include "MSTK_types.h" 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | /* Templates for TETS, PYRAMIDS, PRISMS and HEXS (move to global file?) */ 23 | 24 | /* Number of faces for standard regions */ 25 | extern int const MSTK_nrf_template[5]; 26 | 27 | /* Number of edges for standard regions */ 28 | extern int const MSTK_nre_template[5]; 29 | 30 | /* Translate number of vertices to standard region types */ 31 | extern const MRType MSTK_nv2rtype[9]; 32 | 33 | /* Face-vertex templates for standard regions */ 34 | extern const int MSTK_rfv_template[5][6][5]; 35 | 36 | /* Face direction templates for standard regions */ 37 | extern const int MSTK_rfdir_template[5][6]; 38 | 39 | /* Face-edge templates for standard regions */ 40 | extern const int MSTK_rfe_template[5][6][5]; 41 | 42 | /* Face-edge templates for standard regions */ 43 | extern const int MSTK_rfedir_template[5][6][5]; 44 | 45 | /* Edge-vertex templates for standard regions */ 46 | extern const int MSTK_rev_template[5][12][2]; 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /include/MSTK_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #ifndef _H_MSTKUTIL 10 | #define _H_MSTKUTIL 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | typedef enum ErrType {MSTK_MESG=0, MSTK_WARN, MSTK_ERROR, MSTK_FATAL} ErrType; 17 | 18 | void MSTK_Report(const char *, const char *, ErrType); 19 | void MSTK_Version(int *major_version, int *minor_version, int *patch_version, 20 | char **version_string); 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /include/MSet.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #ifndef _H_MSet 10 | #define _H_MSet 11 | 12 | 13 | #include "MSTK_defines.h" 14 | #include "MSTK_types.h" 15 | 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #ifdef _H_MSet_Private 22 | typedef struct MSet { /* Set Definition */ 23 | char *name; 24 | Mesh_ptr mesh; 25 | MType entdim; 26 | List_ptr entlist; 27 | } MSet, *MSet_ptr; 28 | #else 29 | typedef void *MSet_ptr; 30 | #endif 31 | 32 | 33 | 34 | MSet_ptr MSet_New(Mesh_ptr mesh, const char *set_name, MType entdim); 35 | char *MSet_Name(MSet_ptr set, char *set_name); 36 | Mesh_ptr MSet_Mesh(MSet_ptr); 37 | MType MSet_EntDim(MSet_ptr set); 38 | void MSet_Delete(MSet_ptr set); 39 | 40 | void MSet_Rename(MSet_ptr set, char *newname); 41 | MSet_ptr MSet_Add(MSet_ptr set, void *entry); 42 | MSet_ptr MSet_ChknAdd(MSet_ptr set, void *entry); 43 | MSet_ptr MSet_Insert(MSet_ptr set, void *nuentry, void *b4entry); 44 | MSet_ptr MSet_Inserti(MSet_ptr set, void *nuentry, int i); 45 | int MSet_Rem(MSet_ptr set, void *entry); 46 | int MSet_Remi(MSet_ptr set, int i); 47 | int MSet_Replace(MSet_ptr set, void *entry, void *nuentry); 48 | int MSet_Replacei(MSet_ptr set, int i, void *nuentry); 49 | int MSet_Contains(MSet_ptr set, void *entry); 50 | int MSet_Locate(MSet_ptr set, void *entry); 51 | void *MSet_Entry(MSet_ptr set, int i); 52 | void *MSet_Next_Entry(MSet_ptr set, int *i); 53 | int MSet_Num_Entries(MSet_ptr set); 54 | MSet_ptr MSet_Cat(MSet_ptr dest, MSet_ptr src); 55 | MSet_ptr MSet_Copy(MSet_ptr oldset); 56 | 57 | MSet_ptr MSets_Union(MSet_ptr s1, MSet_ptr s2); 58 | MSet_ptr MSets_Intersect(MSet_ptr s1, MSet_ptr s2); 59 | MSet_ptr MSets_Subtract(MSet_ptr s1, MSet_ptr s2); 60 | 61 | #ifdef DEBUG 62 | void MSet_Print(MSet_ptr set); 63 | #endif 64 | 65 | 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Triad National Security, LLC. All rights reserved. 2 | # 3 | # This file is part of the MSTK project. Please see the license file at 4 | # the root of this repository or at 5 | # https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 6 | 7 | # Copyright 2019 Triad National Security, LLC. All rights reserved. 8 | # 9 | # This file is part of the MSTK project. Please see the license file at 10 | # the root of this repository or at 11 | # https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 12 | 13 | file (GLOB FILES base/*.c) 14 | foreach (FILE ${FILES}) 15 | set (basefiles ${basefiles} ${FILE}) 16 | endforeach () 17 | 18 | file (GLOB FILES hilev/*.c) 19 | foreach (FILE ${FILES}) 20 | set (hilevfiles ${hilevfiles} ${FILE}) 21 | endforeach () 22 | 23 | file (GLOB FILES io/*.c) 24 | foreach (FILE ${FILES}) 25 | get_filename_component(RELFILE ${FILE} NAME) 26 | if (${RELFILE} MATCHES ExodusII OR ${RELFILE} MATCHES NemesisI) 27 | if (ENABLE_ExodusII) 28 | set (iofiles ${iofiles} ${FILE}) 29 | endif () 30 | else () 31 | set (iofiles ${iofiles} ${FILE}) 32 | endif () 33 | endforeach () 34 | 35 | file (GLOB FILES misc/*.c) 36 | foreach (FILE ${FILES}) 37 | set (miscfiles ${miscfiles} ${FILE}) 38 | endforeach () 39 | 40 | file (GLOB FILES util/*.c) 41 | foreach (FILE ${FILES}) 42 | set (utilfiles ${utilfiles} ${FILE}) 43 | endforeach () 44 | 45 | file (GLOB FILES mod/*.c) 46 | foreach (FILE ${FILES}) 47 | set (modfiles ${modfiles} ${FILE}) 48 | endforeach () 49 | 50 | if (ENABLE_PARALLEL) 51 | file (GLOB FILES par/*.c) 52 | foreach (FILE ${FILES}) 53 | get_filename_component(RELFILE ${FILE} NAME) 54 | if (${RELFILE} MATCHES Metis) 55 | if (ENABLE_METIS) 56 | set (parfiles ${parfiles} ${FILE}) 57 | endif () 58 | elseif (${RELFILE} MATCHES Zoltan) 59 | if (ENABLE_ZOLTAN) 60 | set (parfiles ${parfiles} ${FILE}) 61 | endif () 62 | else () 63 | set (parfiles ${parfiles} ${FILE}) 64 | endif () 65 | endforeach () 66 | endif () 67 | 68 | set(mstkfiles ${basefiles} ${hilevfiles} ${iofiles} ${miscfiles} ${utilfiles} ${modfiles} ${parfiles} PARENT_SCOPE) 69 | 70 | -------------------------------------------------------------------------------- /src/base/ME_Face_Funcs_R1R2.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #define _H_MEdge_Private 10 | 11 | #include "MEdge.h" 12 | #include "MEdge_jmp.h" 13 | #include "MSTK_private.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | int ME_Num_Faces_R1R2(MEdge_ptr e) { 20 | int nf; 21 | List_ptr efaces = ME_Faces(e); 22 | 23 | if (efaces) { 24 | nf = List_Num_Entries(efaces); 25 | List_Delete(efaces); 26 | } 27 | else 28 | nf = 0; 29 | 30 | return nf; 31 | } 32 | 33 | List_ptr ME_Faces_R1R2(MEdge_ptr e) { 34 | int idx, idx1, idx2, found; 35 | MFace_ptr face, lstface; 36 | MRegion_ptr reg; 37 | List_ptr rfaces, vfaces1, efaces, vregs0, vregs1, cmnregs=NULL; 38 | 39 | efaces = List_New(0); 40 | 41 | vregs0 = MV_Regions(e->vertex[0]); 42 | vregs1 = MV_Regions(e->vertex[1]); 43 | if (vregs0 || vregs1) { 44 | if (vregs0 && vregs1) { 45 | cmnregs = List_New(0); 46 | 47 | idx = 0; 48 | while ((reg = List_Next_Entry(vregs0,&idx))) { 49 | if (List_Contains(vregs1,reg)) 50 | List_Add(cmnregs,reg); 51 | } 52 | } 53 | if (vregs0) 54 | List_Delete(vregs0); 55 | if (vregs1) 56 | List_Delete(vregs1); 57 | 58 | if (!List_Num_Entries(cmnregs)) { 59 | List_Delete(cmnregs); 60 | return NULL; 61 | } 62 | 63 | idx = 0; 64 | while ((reg = List_Next_Entry(cmnregs,&idx))) { 65 | rfaces = MR_Faces(reg); 66 | 67 | idx1 = 0; 68 | while ((face = List_Next_Entry(rfaces,&idx1))) { 69 | if (MF_UsesEntity(face,(MEntity_ptr) e,MEDGE)) { 70 | 71 | idx2 = 0; found = 0; 72 | while ((lstface = List_Next_Entry(efaces,&idx2))) { 73 | if (MFs_AreSame(face,lstface)) { 74 | found = 1; 75 | break; 76 | } 77 | } 78 | 79 | if (!found) 80 | List_Add(efaces,face); 81 | } 82 | } 83 | 84 | List_Delete(rfaces); 85 | } 86 | List_Delete(cmnregs); 87 | } 88 | else { /* Must be only faces are connected to edge */ 89 | 90 | vfaces1 = MV_Faces(e->vertex[0]); 91 | 92 | if (vfaces1) { 93 | idx = 0; 94 | while ((face = List_Next_Entry(vfaces1,&idx))) { 95 | if (MF_UsesEntity(face,e->vertex[1],MVERTEX)) 96 | List_Add(efaces,face); 97 | } 98 | } 99 | 100 | } 101 | 102 | if (List_Num_Entries(efaces)) 103 | return efaces; 104 | else { 105 | List_Delete(efaces); 106 | return NULL; 107 | } 108 | } 109 | 110 | void ME_FaceIDs_R1R2(MEdge_ptr e, int *nef, int *efaceids) { 111 | List_ptr efaces = ME_Faces_R1R2(e); 112 | if (efaces) { 113 | int i; 114 | *nef = List_Num_Entries(efaces); 115 | for (i = 0; i < *nef; i++) 116 | efaceids[i] = MEnt_ID(List_Entry(efaces,i)); 117 | } 118 | else 119 | *nef = 0; 120 | } 121 | 122 | #ifdef __cplusplus 123 | } 124 | #endif 125 | 126 | -------------------------------------------------------------------------------- /src/base/ME_Face_Funcs_R3R4.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #define _H_MEdge_Private 10 | 11 | #include "MEdge.h" 12 | #include "MEdge_jmp.h" 13 | #include "MSTK_private.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | int ME_Num_Faces_R3R4(MEdge_ptr e) { 20 | List_ptr efaces; 21 | int nf; 22 | 23 | #ifdef DEBUG 24 | MSTK_Report("ME_Num_Faces", 25 | "Inefficient to call this routine with this representation", 26 | MSTK_MESG); 27 | #endif 28 | 29 | efaces = ME_Faces(e); 30 | nf = efaces ? List_Num_Entries(efaces) : 0; 31 | if (efaces) List_Delete(efaces); 32 | 33 | return nf; 34 | } 35 | 36 | List_ptr ME_Faces_R3R4(MEdge_ptr e) { 37 | int i, j, nef, nvf, nv, found; 38 | List_ptr efaces, vfaces, fverts; 39 | MFace_ptr vface; 40 | MVertex_ptr ev[2]; 41 | 42 | nef = 0; 43 | efaces = List_New(10); 44 | 45 | for (i = 0; i < 2; i++) 46 | ev[i] = ME_Vertex(e,i); 47 | 48 | vfaces = MV_Faces(ev[0]); 49 | nvf = List_Num_Entries(vfaces); 50 | 51 | /* Go through all faces connected to ev[0] and pick out ones which 52 | use this edge. Do this by checking if ev[0] and ev[1] are 53 | consecutive vertices in the face */ 54 | for (i = 0; i < nvf; i++) { 55 | vface = List_Entry(vfaces,i); 56 | 57 | /* Get vertices of i'th face connected to ev[0] */ 58 | fverts = MF_Vertices(vface,1,0); 59 | nv = MF_Num_Vertices(vface); 60 | 61 | /* If the j'th vertex is ev[0], check if the next or the 62 | previous vertex is ev[1]; If it is then the edge is used by 63 | the face */ 64 | 65 | found = 0; 66 | for (j = 0; j < nv; j++) { 67 | if (ev[0] == List_Entry(fverts,j) && 68 | (ev[1] == List_Entry(fverts,(j+1)%nv) || 69 | ev[1] == List_Entry(fverts,(j+nv-1)%nv))) { 70 | found = 1; 71 | break; 72 | } 73 | } 74 | List_Delete(fverts); 75 | 76 | if (found) { 77 | List_Add(efaces,vface); 78 | nef++; 79 | } 80 | } 81 | List_Delete(vfaces); 82 | 83 | if (nef) 84 | return efaces; 85 | else { 86 | List_Delete(efaces); 87 | return 0; 88 | } 89 | } 90 | 91 | void ME_FaceIDs_R3R4(MEdge_ptr e, int *nef, int *efaceids) { 92 | List_ptr efaces = ME_Faces_R1R2(e); 93 | if (efaces) { 94 | int i; 95 | *nef = List_Num_Entries(efaces); 96 | for (i = 0; i < *nef; i++) 97 | efaceids[i] = MEnt_ID(List_Entry(efaces,i)); 98 | } 99 | else 100 | *nef = 0; 101 | } 102 | 103 | #ifdef __cplusplus 104 | } 105 | #endif 106 | 107 | -------------------------------------------------------------------------------- /src/base/ME_Geometry.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #define _H_MEdge_Private 10 | 11 | #include 12 | #include "MEdge.h" 13 | #include "MEdge_jmp.h" 14 | #include "MSTK_private.h" 15 | 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | double ME_LenSqr(MEdge_ptr e) { 22 | double xyz0[3],xyz1[3],len2; 23 | 24 | MV_Coords(e->vertex[0],xyz0); 25 | MV_Coords(e->vertex[1],xyz1); 26 | 27 | len2 = ((xyz1[0]-xyz0[0])*(xyz1[0]-xyz0[0])+ 28 | (xyz1[1]-xyz0[1])*(xyz1[1]-xyz0[1])+ 29 | (xyz1[2]-xyz0[2])*(xyz1[2]-xyz0[2])); 30 | 31 | return len2; 32 | } 33 | 34 | double ME_Len(MEdge_ptr e) { 35 | return sqrt(ME_LenSqr(e)); 36 | } 37 | 38 | void ME_Vec(MEdge_ptr e, double *evec) { 39 | double xyz0[3],xyz1[3]; 40 | int i; 41 | 42 | MV_Coords(e->vertex[0],xyz0); 43 | MV_Coords(e->vertex[1],xyz1); 44 | 45 | for (i = 0; i < 3; i++) 46 | evec[i] = xyz1[i]-xyz0[i]; 47 | } 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | -------------------------------------------------------------------------------- /src/base/ME_Region_Funcs_RN.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #define _H_MEdge_Private 10 | 11 | #include "MEdge.h" 12 | #include "MEdge_jmp.h" 13 | #include "MSTK_private.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | int ME_Num_Regions_RN(MEdge_ptr e) { 20 | int ne, idx; 21 | MRegion_ptr reg; 22 | List_ptr vregs; 23 | 24 | ne = 0; 25 | 26 | vregs = MV_Regions(e->vertex[0]); 27 | idx = 0; 28 | while ((reg = List_Next_Entry(vregs,&idx))) { 29 | if (MR_UsesEntity(reg,e->vertex[1],MVERTEX)) 30 | ne++; 31 | } 32 | 33 | return ne; 34 | } 35 | 36 | List_ptr ME_Regions_RN(MEdge_ptr e) { 37 | int idx; 38 | MRegion_ptr reg; 39 | List_ptr eregs, vregs; 40 | 41 | eregs = List_New(0); 42 | 43 | vregs = MV_Regions(e->vertex[0]); 44 | idx = 0; 45 | while ((reg = List_Next_Entry(vregs,&idx))) { 46 | if (MR_UsesEntity(reg,e->vertex[1],MVERTEX)) 47 | List_Add(eregs,reg); 48 | } 49 | 50 | if (List_Num_Entries(eregs)) 51 | return eregs; 52 | else { 53 | List_Delete(eregs); 54 | return NULL; 55 | } 56 | } 57 | 58 | void ME_RegionIDs_RN(MEdge_ptr e, int *ner, int *eregids) { 59 | int i; 60 | List_ptr eregs = ME_Regions_RN(e); 61 | if (eregs) { 62 | *ner = List_Num_Entries(eregs); 63 | for (i = 0; i < *ner; i++) 64 | eregids[i] = MEnt_ID(List_Entry(eregs,i)); 65 | } 66 | else 67 | *ner = 0; 68 | } 69 | 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | 74 | -------------------------------------------------------------------------------- /src/base/MEdge_R1.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #define _H_MEdge_Private 10 | 11 | #include 12 | #include "MEdge.h" 13 | #include "MEdge_jmp.h" 14 | #include "MSTK_private.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | void ME_Set_RepType_R1(MEdge_ptr e) { 21 | MEdge_Adj_RN *adj; 22 | 23 | adj = e->adj = (MEdge_Adj_RN *) malloc(sizeof(MEdge_Adj_RN)); 24 | adj->hnext = NULL; 25 | adj->lock = 0; 26 | } 27 | 28 | void ME_Delete_R1(MEdge_ptr e, int keep) { 29 | MEdge_Adj_RN *adj; 30 | 31 | if (!keep) { 32 | adj = (MEdge_Adj_RN *) e->adj; 33 | if (adj) { 34 | free(adj); 35 | } 36 | MEnt_Set_DelFlag((MEntity_ptr) e); 37 | } 38 | return; 39 | } 40 | 41 | void ME_Destroy_For_MESH_Delete_R1(MEdge_ptr e) { 42 | return; 43 | } 44 | 45 | int ME_Num_Faces_R1(MEdge_ptr e) { 46 | return ME_Num_Faces_R1R2(e); 47 | } 48 | 49 | List_ptr ME_Faces_R1(MEdge_ptr e) { 50 | return ME_Faces_R1R2(e); 51 | } 52 | 53 | int ME_Num_Regions_R1(MEdge_ptr e) { 54 | return ME_Num_Regions_RN(e); 55 | } 56 | 57 | List_ptr ME_Regions_R1(MEdge_ptr e) { 58 | return ME_Regions_RN(e); 59 | } 60 | 61 | void ME_Add_Face_R1(MEdge_ptr e, MFace_ptr f) { 62 | #ifdef DEBUG 63 | MSTK_Report("ME_Add_Face", 64 | "Function call not suitable for this representation",MSTK_WARN); 65 | #endif 66 | } 67 | 68 | void ME_Rem_Face_R1(MEdge_ptr e, MFace_ptr f) { 69 | #ifdef DEBUG 70 | MSTK_Report("ME_Rem_Face", 71 | "Function call not suitable for this representation",MSTK_WARN); 72 | #endif 73 | } 74 | 75 | void ME_Add_Region_R1(MEdge_ptr e, MRegion_ptr r) { 76 | #ifdef DEBUG 77 | MSTK_Report("ME_Add_Region", 78 | "Function call not suitable for this representation",MSTK_WARN); 79 | #endif 80 | } 81 | 82 | void ME_Rem_Region_R1(MEdge_ptr e, MRegion_ptr r) { 83 | #ifdef DEBUG 84 | MSTK_Report("ME_Rem_Region", 85 | "Function call not suitable for this representation",MSTK_WARN); 86 | #endif 87 | } 88 | 89 | MEdge_ptr ME_NextInHash_R1(MEdge_ptr e) { 90 | MEdge_ptr hnext = ((MEdge_Adj_RN *)e->adj)->hnext; 91 | return hnext; 92 | } 93 | 94 | void ME_Set_NextInHash_R1(MEdge_ptr e, MEdge_ptr next) { 95 | MEdge_Adj_RN *adj = (MEdge_Adj_RN *)e->adj; 96 | adj->hnext = next; 97 | } 98 | 99 | void ME_Lock_R1(MEdge_ptr e) { 100 | MEdge_Adj_RN *adj = (MEdge_Adj_RN *)e->adj; 101 | Hash_Lock(&adj->lock); 102 | } 103 | 104 | void ME_UnLock_R1(MEdge_ptr e) { 105 | MEdge_Adj_RN *adj = (MEdge_Adj_RN *)e->adj; 106 | Hash_UnLock(&adj->lock); 107 | } 108 | 109 | int ME_IsLocked_R1(MEdge_ptr e) { 110 | MEdge_Adj_RN *adj = (MEdge_Adj_RN *)e->adj; 111 | return Hash_IsLocked(adj->lock); 112 | } 113 | 114 | #ifdef __cplusplus 115 | } 116 | #endif 117 | 118 | -------------------------------------------------------------------------------- /src/base/MEdge_R2.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #define _H_MEdge_Private 10 | 11 | #include 12 | #include "MEdge.h" 13 | #include "MEdge_jmp.h" 14 | #include "MSTK_private.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | void ME_Set_RepType_R2(MEdge_ptr e) { 21 | MEdge_Adj_RN *adj; 22 | 23 | adj = e->adj = (MEdge_Adj_RN *) malloc(sizeof(MEdge_Adj_RN)); 24 | adj->hnext = NULL; 25 | } 26 | 27 | void ME_Delete_R2(MEdge_ptr e, int keep) { 28 | return; 29 | } 30 | 31 | void ME_Destroy_For_MESH_Delete_R2(MEdge_ptr e) { 32 | return; 33 | } 34 | 35 | int ME_Num_Faces_R2(MEdge_ptr e) { 36 | return ME_Num_Faces_R1R2(e); 37 | } 38 | 39 | int ME_Num_Regions_R2(MEdge_ptr e) { 40 | return ME_Num_Regions_RN(e); 41 | } 42 | 43 | List_ptr ME_Faces_R2(MEdge_ptr e) { 44 | return ME_Faces_R1R2(e); 45 | } 46 | 47 | List_ptr ME_Regions_R2(MEdge_ptr e) { 48 | return ME_Regions_RN(e); 49 | } 50 | 51 | void ME_Add_Face_R2(MEdge_ptr e, MFace_ptr f) { 52 | #ifdef DEBUG 53 | MSTK_Report("ME_Add_Face", 54 | "Function call not suitable for this representation",MSTK_WARN); 55 | #endif 56 | } 57 | 58 | void ME_Rem_Face_R2(MEdge_ptr e, MFace_ptr f) { 59 | #ifdef DEBUG 60 | MSTK_Report("ME_Rem_Face", 61 | "Function call not suitable for this representation",MSTK_WARN); 62 | #endif 63 | } 64 | 65 | void ME_Add_Region_R2(MEdge_ptr e, MRegion_ptr r) { 66 | #ifdef DEBUG 67 | MSTK_Report("ME_Add_Region", 68 | "Function call not suitable for this representation",MSTK_WARN); 69 | #endif 70 | } 71 | 72 | void ME_Rem_Region_R2(MEdge_ptr e, MRegion_ptr r) { 73 | #ifdef DEBUG 74 | MSTK_Report("ME_Rem_Region", 75 | "Function call not suitable for this representation",MSTK_WARN); 76 | #endif 77 | } 78 | 79 | MEdge_ptr ME_NextInHash_R2(MEdge_ptr e) { 80 | MEdge_ptr hnext = ((MEdge_Adj_RN *)e->adj)->hnext; 81 | return hnext; 82 | } 83 | 84 | void ME_Set_NextInHash_R2(MEdge_ptr e, MEdge_ptr next) { 85 | MEdge_Adj_RN *adj = (MEdge_Adj_RN *)e->adj; 86 | adj->hnext = next; 87 | } 88 | 89 | void ME_Lock_R2(MEdge_ptr e) { 90 | MEdge_Adj_RN *adj = (MEdge_Adj_RN *)e->adj; 91 | Hash_Lock(&adj->lock); 92 | } 93 | 94 | void ME_UnLock_R2(MEdge_ptr e) { 95 | MEdge_Adj_RN *adj = (MEdge_Adj_RN *)e->adj; 96 | Hash_UnLock(&adj->lock); 97 | } 98 | 99 | int ME_IsLocked_R2(MEdge_ptr e) { 100 | MEdge_Adj_RN *adj = (MEdge_Adj_RN *)e->adj; 101 | return Hash_IsLocked(adj->lock); 102 | } 103 | 104 | #ifdef __cplusplus 105 | } 106 | #endif 107 | 108 | -------------------------------------------------------------------------------- /src/base/MEdge_R4.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #define _H_MEdge_Private 10 | 11 | #include 12 | #include "MEdge.h" 13 | #include "MEdge_jmp.h" 14 | #include "MSTK_private.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | void ME_Set_RepType_R4(MEdge_ptr e) { 21 | MEdge_Adj_RN *adj; 22 | 23 | adj = e->adj = (MEdge_Adj_RN *) malloc(sizeof(MEdge_Adj_RN)); 24 | adj->hnext = NULL; 25 | } 26 | 27 | void ME_Delete_R4(MEdge_ptr e, int keep) { 28 | return; 29 | } 30 | 31 | void ME_Destroy_For_MESH_Delete_R4(MEdge_ptr e) { 32 | return; 33 | } 34 | 35 | int ME_Num_Faces_R4(MEdge_ptr e) { 36 | return ME_Num_Faces_R3R4(e); 37 | } 38 | 39 | int ME_Num_Regions_R4(MEdge_ptr e) { 40 | return ME_Num_Regions_RN(e); 41 | } 42 | 43 | List_ptr ME_Faces_R4(MEdge_ptr e) { 44 | return ME_Faces_R3R4(e); 45 | } 46 | 47 | List_ptr ME_Regions_R4(MEdge_ptr e) { 48 | return ME_Regions_RN(e); 49 | } 50 | 51 | void ME_Add_Face_R4(MEdge_ptr e, MFace_ptr f) { 52 | #ifdef DEBUG 53 | MSTK_Report("ME_Add_Face", 54 | "Function call not suitable for this representation",MSTK_WARN); 55 | #endif 56 | } 57 | 58 | void ME_Rem_Face_R4(MEdge_ptr e, MFace_ptr f) { 59 | #ifdef DEBUG 60 | MSTK_Report("ME_Rem_Face", 61 | "Function call not suitable for this representation",MSTK_WARN); 62 | #endif 63 | } 64 | 65 | void ME_Add_Region_R4(MEdge_ptr e, MRegion_ptr r) { 66 | #ifdef DEBUG 67 | MSTK_Report("ME_Add_Region", 68 | "Function call not suitable for this representation",MSTK_WARN); 69 | #endif 70 | } 71 | 72 | void ME_Rem_Region_R4(MEdge_ptr e, MRegion_ptr r) { 73 | #ifdef DEBUG 74 | MSTK_Report("ME_Rem_Region", 75 | "Function call not suitable for this representation",MSTK_WARN); 76 | #endif 77 | } 78 | 79 | MEdge_ptr ME_NextInHash_R4(MEdge_ptr e) { 80 | MEdge_ptr hnext = ((MEdge_Adj_RN *)e->adj)->hnext; 81 | return hnext; 82 | } 83 | 84 | void ME_Set_NextInHash_R4(MEdge_ptr e, MEdge_ptr next) { 85 | MEdge_Adj_RN *adj = (MEdge_Adj_RN *)e->adj; 86 | adj->hnext = next; 87 | } 88 | 89 | void ME_Lock_R4(MEdge_ptr e) { 90 | MEdge_Adj_RN *adj = (MEdge_Adj_RN *)e->adj; 91 | Hash_Lock(&adj->lock); 92 | } 93 | 94 | void ME_UnLock_R4(MEdge_ptr e) { 95 | MEdge_Adj_RN *adj = (MEdge_Adj_RN *)e->adj; 96 | Hash_UnLock(&adj->lock); 97 | } 98 | 99 | int ME_IsLocked_R4(MEdge_ptr e) { 100 | MEdge_Adj_RN *adj = (MEdge_Adj_RN *)e->adj; 101 | return Hash_IsLocked(adj->lock); 102 | } 103 | 104 | #ifdef __cplusplus 105 | } 106 | #endif 107 | 108 | -------------------------------------------------------------------------------- /src/base/MF_Region_Funcs_F1F3.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #define _H_MFace_Private 10 | 11 | #include "MFace.h" 12 | #include "MSTK_private.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | 19 | List_ptr MF_Regions_F1F3(MFace_ptr f) { 20 | List_ptr fregs = NULL; 21 | MFace_Adj_F1F3 *adj; 22 | 23 | adj = (MFace_Adj_F1F3 *) f->adj; 24 | if (adj->fregions[0]) { 25 | fregs = List_New(2); 26 | List_Add(fregs,adj->fregions[0]); 27 | } 28 | if (adj->fregions[1]) { 29 | if (!fregs) 30 | fregs = List_New(1); 31 | List_Add(fregs,adj->fregions[1]); 32 | } 33 | 34 | return fregs; 35 | } 36 | 37 | void MF_RegionIDs_F1F3(MFace_ptr f, int *nfr, int *fregids) { 38 | MFace_Adj_F1F3 *adj = (MFace_Adj_F1F3 *) f->adj; 39 | 40 | *nfr = 0; 41 | if (adj->fregions[0]) 42 | fregids[(*nfr)++] = MEnt_ID(adj->fregions[0]); 43 | if (adj->fregions[1]) 44 | fregids[(*nfr)++] = MEnt_ID(adj->fregions[1]); 45 | 46 | } 47 | 48 | MRegion_ptr MF_Region_F1F3(MFace_ptr f, int i) { 49 | return ((MFace_Adj_F1F3 *) f->adj)->fregions[i]; 50 | } 51 | 52 | int MF_RegionID_F1F3(MFace_ptr f, int i) { 53 | return MEnt_ID(((MFace_Adj_F1F3 *) f->adj)->fregions[i]); 54 | } 55 | 56 | void MF_Add_Region_F1F3(MFace_ptr f, MRegion_ptr r, int side) { 57 | MFace_Adj_F1F3 *adj; 58 | 59 | 60 | adj = (MFace_Adj_F1F3 *) f->adj; 61 | 62 | if (side == MSTK_UNKNOWN) { 63 | if (MR_FaceDir(r,f)) 64 | adj->fregions[0] = r; 65 | else 66 | adj->fregions[1] = r; 67 | } 68 | else 69 | adj->fregions[side] = r; 70 | } 71 | 72 | void MF_Rem_Region_F1F3(MFace_ptr f, MRegion_ptr r) { 73 | MFace_Adj_F1F3 *adj; 74 | 75 | 76 | adj = (MFace_Adj_F1F3 *) f->adj; 77 | 78 | if (adj->fregions[0] == r) 79 | adj->fregions[0] = NULL; 80 | else if (adj->fregions[1] == r) 81 | adj->fregions[1] = NULL; 82 | else 83 | MSTK_Report("MF_Rem_Region_F1F3","Region not connected to face",MSTK_ERROR); 84 | } 85 | 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | -------------------------------------------------------------------------------- /src/base/MF_Region_Funcs_F2F4.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #define _H_MFace_Private 10 | 11 | #include "MFace.h" 12 | #include "MSTK_private.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | 19 | List_ptr MF_Regions_F2F4(MFace_ptr f) { 20 | List_ptr fregs, eregs; 21 | MRegion_ptr r; 22 | MEdge_ptr e; 23 | MFace_Adj_F2F4 *adj; 24 | int i, k=0, nr; 25 | 26 | adj = (MFace_Adj_F2F4 *) f->adj; 27 | 28 | fregs = List_New(2); 29 | e = List_Entry(adj->fedges,0); 30 | 31 | eregs = ME_Regions(e); 32 | if (eregs) { 33 | nr = List_Num_Entries(eregs); 34 | 35 | for (i = 0; i < nr; i++) { 36 | r = List_Entry(eregs,i); 37 | if (MR_UsesEntity(r,(MEntity_ptr) f,2)) { 38 | List_Add(fregs,r); 39 | k++; 40 | } 41 | if (k == 2) 42 | break; 43 | } 44 | 45 | List_Delete(eregs); 46 | } 47 | 48 | 49 | if (k) 50 | return fregs; 51 | else { 52 | List_Delete(fregs); 53 | return 0; 54 | } 55 | } 56 | 57 | void MF_RegionIDs_F2F4(MFace_ptr f, int *nfr, int *fregids) { 58 | int i; 59 | List_ptr fregs = MF_Regions_F2F4(f); 60 | *nfr = List_Num_Entries(fregs); 61 | for (i = 0; i < *nfr; i++) 62 | fregids[i] = MEnt_ID(List_Entry(fregs,i)); 63 | List_Delete(fregs); 64 | } 65 | 66 | MRegion_ptr MF_Region_F2F4(MFace_ptr f, int ir) { 67 | List_ptr eregs; 68 | MRegion_ptr r, r1; 69 | MEdge_ptr e; 70 | int nr, i, dir, fdir; 71 | MFace_Adj_F2F4 *adj; 72 | 73 | #ifdef DEBUG 74 | MSTK_Report("MF_Region_F4","More efficient to use MF_Regions",MSTK_MESG); 75 | #endif 76 | 77 | dir = (ir) ? 0 : 1; 78 | 79 | adj = (MFace_Adj_F2F4 *) f->adj; 80 | e = List_Entry(adj->fedges,0); 81 | 82 | eregs = ME_Regions(e); 83 | if (eregs) { 84 | nr = List_Num_Entries(eregs); 85 | 86 | r1 = 0; 87 | for (i = 0; i < nr; i++) { 88 | r = List_Entry(eregs,i); 89 | fdir = MR_FaceDir(r,f); 90 | if (fdir == !dir) { 91 | r1 = r; 92 | break; 93 | } 94 | } 95 | List_Delete(eregs); 96 | 97 | return r1; 98 | } 99 | 100 | return 0; 101 | } 102 | 103 | int MF_RegionID_F2F4(MFace_ptr f, int ir) { 104 | MRegion_ptr r = MF_Region_F2F4(f,ir); 105 | return r ? MEnt_ID(r) : 0; 106 | } 107 | 108 | void MF_Add_Region_F2F4(MFace_ptr f, MRegion_ptr r, int side) { 109 | #ifdef DEBUG 110 | MSTK_Report("MF_Add_Region", 111 | "Function call unsuitable for this representation", 112 | MSTK_WARN); 113 | #endif 114 | } 115 | 116 | void MF_Rem_Region_F2F4(MFace_ptr f, MRegion_ptr r) { 117 | #ifdef DEBUG 118 | MSTK_Report("MF_Rem_Region", 119 | "Function call unsuitable for this representation", 120 | MSTK_WARN); 121 | #endif 122 | } 123 | 124 | 125 | #ifdef __cplusplus 126 | } 127 | #endif 128 | -------------------------------------------------------------------------------- /src/base/MF_Region_Funcs_R1.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #define _H_MFace_Private 10 | 11 | #include "MFace.h" 12 | #include "MSTK_private.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | List_ptr MF_Regions_R1(MFace_ptr f) { 19 | MFace_Adj_R1 *adj = (MFace_Adj_R1 *) f->adj; 20 | MVertex_ptr v, rv; 21 | MRegion_ptr r; 22 | List_ptr vregs, rverts, fregs; 23 | int nfv, nr, idx, i, fnd=0, idx1; 24 | 25 | v = List_Entry(adj->fvertices,0); 26 | vregs = MV_Regions(v); 27 | if (!vregs) 28 | return NULL; 29 | 30 | nfv = List_Num_Entries(adj->fvertices); 31 | nr = 0; 32 | fregs = List_New(2); 33 | 34 | idx = 0; 35 | while (nr < 2 && (r = List_Next_Entry(vregs,&idx))) { 36 | rverts = MR_Vertices(r); 37 | 38 | for (i = 1; i < nfv; i++) { 39 | v = List_Entry(adj->fvertices,i); 40 | idx1 = 0; 41 | fnd = 0; 42 | while ((rv = List_Next_Entry(rverts,&idx1))) { 43 | if (rv == v) { 44 | fnd = 1; 45 | break; 46 | } 47 | } 48 | if (!fnd) 49 | break; 50 | } 51 | 52 | List_Delete(rverts); 53 | 54 | if (fnd) { 55 | List_Add(fregs,r); 56 | nr++; 57 | } 58 | } 59 | List_Delete(vregs); 60 | if (nr) 61 | return fregs; 62 | else { 63 | List_Delete(fregs); 64 | return 0; 65 | } 66 | } 67 | 68 | void MF_RegionIDs_R1(MFace_ptr f, int *nfr, int *fregids) { 69 | int i; 70 | List_ptr fregs = MF_Regions_R1(f); 71 | *nfr = List_Num_Entries(fregs); 72 | for (i = 0; i < *nfr; i++) 73 | fregids[i] = MEnt_ID(List_Entry(fregs,i)); 74 | List_Delete(fregs); 75 | } 76 | 77 | 78 | MRegion_ptr MF_Region_R1(MFace_ptr f, int dir) { 79 | List_ptr fregs; 80 | int nr; 81 | MRegion_ptr reg, ret = NULL; 82 | 83 | #ifdef DEBUG 84 | MSTK_Report("MF_Region_R1", 85 | "May be more efficient to call MF_Regions",MSTK_WARN); 86 | #endif 87 | 88 | fregs = MF_Regions_R1(f); 89 | if (!fregs) 90 | return NULL; 91 | 92 | nr = List_Num_Entries(fregs); 93 | 94 | reg = List_Entry(fregs,0); 95 | if (MR_FaceDir(reg,f) == !dir) { 96 | ret = reg; 97 | } 98 | else if (nr == 2) { 99 | reg = List_Entry(fregs,1); 100 | if (MR_FaceDir(reg,f) == !dir) { 101 | ret = reg; 102 | } 103 | } 104 | 105 | List_Delete(fregs); 106 | 107 | return ret; 108 | } 109 | 110 | int MF_RegionID_R1(MFace_ptr f, int ir) { 111 | MRegion_ptr r = MF_Region_R1(f,ir); 112 | return r ? MEnt_ID(r) : 0; 113 | } 114 | 115 | 116 | #ifdef __cplusplus 117 | } 118 | #endif 119 | -------------------------------------------------------------------------------- /src/base/MF_Region_Funcs_R2.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #define _H_MFace_Private 10 | 11 | #include "MFace.h" 12 | #include "MSTK_private.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | List_ptr MF_Regions_R2(MFace_ptr f) { 19 | MFace_Adj_R1 *adj = (MFace_Adj_R1 *) f->adj; 20 | MVertex_ptr v, rv; 21 | MRegion_ptr r; 22 | List_ptr vregs, rverts, fregs; 23 | int nfv, nr, idx, i, fnd=0, idx1; 24 | 25 | v = List_Entry(adj->fvertices,0); 26 | vregs = MV_Regions(v); 27 | if (!vregs) 28 | return NULL; 29 | 30 | nfv = List_Num_Entries(adj->fvertices); 31 | nr = 0; 32 | fregs = List_New(2); 33 | 34 | idx = 0; 35 | while (nr < 2 && (r = List_Next_Entry(vregs,&idx))) { 36 | rverts = MR_Vertices(r); 37 | 38 | for (i = 1; i < nfv; i++) { 39 | v = List_Entry(adj->fvertices,i); 40 | idx1 = 0; 41 | fnd = 0; 42 | while ((rv = List_Next_Entry(rverts,&idx1))) { 43 | if (rv == v) { 44 | fnd = 1; 45 | break; 46 | } 47 | } 48 | if (!fnd) 49 | break; 50 | } 51 | 52 | List_Delete(rverts); 53 | 54 | if (fnd) { 55 | List_Add(fregs,r); 56 | nr++; 57 | } 58 | } 59 | List_Delete(vregs); 60 | if (nr) 61 | return fregs; 62 | else { 63 | List_Delete(fregs); 64 | return 0; 65 | } 66 | } 67 | 68 | void MF_RegionIDs_R2(MFace_ptr f, int *nfr, int *fregids) { 69 | int i; 70 | List_ptr fregs = MF_Regions_R2(f); 71 | *nfr = List_Num_Entries(fregs); 72 | for (i = 0; i < *nfr; i++) 73 | fregids[i] = MEnt_ID(List_Entry(fregs,i)); 74 | List_Delete(fregs); 75 | } 76 | 77 | MRegion_ptr MF_Region_R2(MFace_ptr f, int dir) { 78 | List_ptr fregs; 79 | int nr; 80 | MRegion_ptr reg, ret = NULL; 81 | 82 | #ifdef DEBUG 83 | MSTK_Report("MF_Region_R2", 84 | "May be more efficient to call MF_Regions",MSTK_WARN); 85 | #endif 86 | 87 | fregs = MF_Regions_R2(f); 88 | if (!fregs) 89 | return NULL; 90 | 91 | nr = List_Num_Entries(fregs); 92 | 93 | reg = List_Entry(fregs,0); 94 | if (MR_FaceDir(reg,f) == !dir) { 95 | ret = reg; 96 | } 97 | else if (nr == 2) { 98 | reg = List_Entry(fregs,1); 99 | if (MR_FaceDir(reg,f) == !dir) { 100 | ret = reg; 101 | } 102 | } 103 | 104 | List_Delete(fregs); 105 | 106 | return ret; 107 | } 108 | 109 | int MF_RegionID_R2(MFace_ptr f, int ir) { 110 | MRegion_ptr r = MF_Region_R2(f,ir); 111 | return r ? MEnt_ID(r) : 0; 112 | } 113 | 114 | 115 | #ifdef __cplusplus 116 | } 117 | #endif 118 | -------------------------------------------------------------------------------- /src/base/MF_Region_Funcs_R4.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #define _H_MFace_Private 10 | 11 | #include "MFace.h" 12 | #include "MSTK_private.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | 19 | List_ptr MF_Regions_R4(MFace_ptr f) { 20 | List_ptr fregs; 21 | MFace_Adj_R3 *adj; 22 | 23 | adj = (MFace_Adj_R3 *) f->adj; 24 | 25 | fregs = List_New(2); 26 | if (adj->fregions[0]) 27 | List_Add(fregs,adj->fregions[0]); 28 | if (adj->fregions[1]) 29 | List_Add(fregs,adj->fregions[1]); 30 | 31 | return fregs; 32 | } 33 | 34 | void MF_RegionIDs_R4(MFace_ptr f, int *nfr, int *fregids) { 35 | MFace_Adj_F1F3 *adj = (MFace_Adj_F1F3 *) f->adj; 36 | 37 | *nfr = 0; 38 | if (adj->fregions[0]) 39 | fregids[(*nfr)++] = MEnt_ID(adj->fregions[0]); 40 | if (adj->fregions[1]) 41 | fregids[(*nfr)++] = MEnt_ID(adj->fregions[1]); 42 | 43 | } 44 | 45 | 46 | MRegion_ptr MF_Region_R4(MFace_ptr f, int i) { 47 | return ((MFace_Adj_R3 *) f->adj)->fregions[i]; 48 | } 49 | 50 | int MF_RegionID_R4(MFace_ptr f, int i) { 51 | return MEnt_ID(((MFace_Adj_R4 *) f->adj)->fregions[i]); 52 | } 53 | 54 | void MF_Add_Region_R4(MFace_ptr f, MRegion_ptr r, int side) { 55 | MFace_Adj_R3 *adj; 56 | 57 | adj = (MFace_Adj_R3 *) f->adj; 58 | 59 | if (side == MSTK_UNKNOWN) { 60 | if (MR_FaceDir(r,f)) 61 | adj->fregions[0] = r; 62 | else 63 | adj->fregions[1] = r; 64 | } 65 | else 66 | adj->fregions[side] = r; 67 | } 68 | 69 | void MF_Rem_Region_R4(MFace_ptr f, MRegion_ptr r) { 70 | MFace_Adj_R3 *adj; 71 | 72 | adj = (MFace_Adj_R3 *) f->adj; 73 | 74 | if (adj->fregions[0] == r) 75 | adj->fregions[0] = NULL; 76 | else if (adj->fregions[1] == r) 77 | adj->fregions[1] = NULL; 78 | else 79 | MSTK_Report("MF_Rem_Region_R4","Region not connected to face",MSTK_ERROR); 80 | } 81 | 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif 86 | -------------------------------------------------------------------------------- /src/hilev/MESH_BuildClassfn.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include "MSTK.h" 14 | #include "MSTK_private.h" 15 | 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | 22 | /* Routine to build classification for mesh entities given a mesh no 23 | information or model ID info only for the highest level entities 24 | (typically regions in volume meshes and faces in surface meshes) 25 | 26 | if use_geometry is 1, then the algorithm will try to use boundary 27 | geometry to subdivide the boundary into smaller smoother faces/edges 28 | This is time consuming and in the case of rough geometry, it can 29 | lead to many unwanted new geometric entity IDs 30 | 31 | */ 32 | 33 | 34 | int MESH_BuildClassfn(Mesh_ptr mesh, int use_geometry) { 35 | int ok, idx, gid; 36 | int max_greg_id, zeroid; 37 | double PI=3.141592, ang; 38 | MRegion_ptr region; 39 | 40 | ang = 5*PI/6.0; /* 75 degrees */ 41 | 42 | /* MESH REGIONS >>>>>>>>>>>>>>> */ 43 | 44 | /* Verify that mesh regions have classification information; if 45 | not, assign all regions to the same model region */ 46 | 47 | zeroid = 0; 48 | max_greg_id = 0; 49 | idx = 0; 50 | while ((region = MESH_Next_Region(mesh,&idx))) { 51 | gid = MR_GEntID(region); 52 | if (gid) { 53 | if (gid > max_greg_id) 54 | max_greg_id = gid; 55 | } 56 | else 57 | zeroid = 1; 58 | } 59 | 60 | if (zeroid) { 61 | idx = 0; 62 | while ((region = MESH_Next_Region(mesh,&idx))) { 63 | /* Make sure region is not classified on zero or -ve ID model region */ 64 | 65 | if (MR_GEntID(region) <= 0) 66 | MR_Set_GEntID(region,(max_greg_id+1)); 67 | } 68 | } 69 | 70 | 71 | /* MESH FACES >>>>>>>>>>>>>>> */ 72 | 73 | ok = MESH_BuildFaceClassfn(mesh,use_geometry); 74 | 75 | 76 | /* MESH EDGES >>>>>>>>>>>>>>> */ 77 | 78 | ok = MESH_BuildEdgeClassfn(mesh,use_geometry); 79 | 80 | 81 | /* MESH VERTICES >>>>>>>>>>>>>>> */ 82 | 83 | ok = MESH_BuildVertexClassfn(mesh,use_geometry); 84 | 85 | 86 | 87 | 88 | return 1; 89 | } 90 | 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | -------------------------------------------------------------------------------- /src/hilev/MESH_DelInterior.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include "MSTK.h" 14 | 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | 21 | /* Routine to remove interior of a mesh and only leave a boundary mesh. 22 | For 3D meshes, only a surface mesh is left 23 | For 2D meshes, only the boundary edge mesh is left 24 | For 1D meshes, only the bounding vertices are left 25 | Does not do anything if the mesh has only vertices 26 | */ 27 | 28 | int MESH_DelInterior(Mesh_ptr mesh) { 29 | int i, dim=-1, nr, nf, ne, nv; 30 | MVertex_ptr vertex; 31 | MEdge_ptr edge; 32 | MFace_ptr face; 33 | MRegion_ptr region; 34 | 35 | nr = MESH_Num_Regions(mesh); 36 | nf = MESH_Num_Faces(mesh); 37 | ne = MESH_Num_Edges(mesh); 38 | nv = MESH_Num_Vertices(mesh); 39 | 40 | if (nr) 41 | dim = 3; 42 | else if (nf) 43 | dim = 2; 44 | else if (ne) 45 | dim = 1; 46 | else { 47 | /* Only vertices */ 48 | return 0; 49 | } 50 | 51 | /* With the current storage scheme for mesh entities or more generally lists, 52 | it is more efficient to delete elements starting from the back */ 53 | 54 | for (i = nr-1; i >= 0; i--) { 55 | region = MESH_Region(mesh,i); 56 | MR_Delete(region,0); 57 | } 58 | 59 | for (i = nf-1; i >= 0; i--) { 60 | face = MESH_Face(mesh,i); 61 | if (MF_GEntDim(face) == dim) 62 | MF_Delete(face,0); 63 | } 64 | 65 | for (i = ne-1; i >= 0; i--) { 66 | edge = MESH_Edge(mesh,i); 67 | if (ME_GEntDim(edge) == dim) 68 | ME_Delete(edge,0); 69 | } 70 | 71 | for (i = nv-1; i >= 0; i--) { 72 | vertex = MESH_Vertex(mesh,i); 73 | if (MV_GEntDim(vertex) == dim) 74 | MV_Delete(vertex,0); 75 | } 76 | 77 | return 1; 78 | } 79 | 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | -------------------------------------------------------------------------------- /src/hilev/MESH_GetElementGraph.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include "Mesh.h" 14 | #include "MSTK.h" 15 | #include "MSTK_private.h" 16 | 17 | /* Get the element adjacency graph for a mesh */ 18 | /* adjbeg - pointer to array containing the offsets of the adjelems list at */ 19 | /* which the adjacent elements are enumerated for each element */ 20 | 21 | int MESH_GetElementGraph(Mesh_ptr mesh, int *nelems, int **adjbeg, 22 | int **adjelems) { 23 | 24 | *nelems = MESH_Num_Regions(mesh); 25 | if (*nelems) { /* 3D mesh */ 26 | 27 | /* Now build the graph */ 28 | *adjbeg = (int *) malloc((*nelems+1)*sizeof(int)); 29 | int nalloc = 4*(*nelems); /* start with assuming 4 nbrs per entity */ 30 | *adjelems = (int *) malloc(nalloc*sizeof(int)); 31 | 32 | int pos = 0; 33 | int i = 0; 34 | int idx = 0; 35 | MRegion_ptr mr; 36 | while ((mr = MESH_Next_Region(mesh, &idx))) { 37 | (*adjbeg)[i] = pos; 38 | 39 | List_ptr rfaces = MR_Faces(mr); 40 | int idx2 = 0; 41 | MFace_ptr rf; 42 | while ((rf = List_Next_Entry(rfaces, &idx2))) { 43 | List_ptr fregs = MF_Regions(rf); 44 | if (List_Num_Entries(fregs) == 1) continue; 45 | 46 | MRegion_ptr oppr; 47 | if (List_Entry(fregs,0) == mr) 48 | oppr = List_Entry(fregs,1); 49 | else 50 | oppr = List_Entry(fregs,0); 51 | if (pos == nalloc) { 52 | nalloc *= 2; 53 | *adjelems = (int *) realloc(adjelems, nalloc*sizeof(int)); 54 | } 55 | (*adjelems)[pos] = MR_ID(oppr)-1; 56 | pos++; 57 | 58 | List_Delete(fregs); 59 | } 60 | List_Delete(rfaces); 61 | i++; 62 | } 63 | (*adjbeg)[*nelems] = pos; 64 | 65 | } else { 66 | 67 | *nelems = MESH_Num_Faces(mesh); 68 | 69 | *adjbeg = (int *) malloc((*nelems+1)*sizeof(int)); 70 | int nalloc = 4*(*nelems); /* start with assuming 4 nbrs per entity */ 71 | *adjelems = (int *) malloc(nalloc*sizeof(int)); 72 | 73 | int pos = 0; 74 | int i = 0; 75 | int idx = 0; 76 | MFace_ptr mf; 77 | while ((mf = MESH_Next_Face(mesh, &idx))) { 78 | (*adjbeg)[i] = pos; 79 | 80 | List_ptr fedges = MF_Edges(mf, 1, 0); 81 | int idx2 = 0; 82 | MEdge_ptr fe; 83 | while ((fe = List_Next_Entry(fedges, &idx2))) { 84 | List_ptr efaces = ME_Faces(fe); 85 | if (List_Num_Entries(efaces) == 1) continue; 86 | 87 | /* have to account for non-manifold configurations */ 88 | int idx3 = 0; 89 | MFace_ptr ef; 90 | while ((ef = List_Next_Entry(efaces, &idx3))) { 91 | if (ef != mf) { 92 | if (pos == nalloc) { 93 | nalloc *= 2; 94 | *adjelems = (int *) realloc(*adjelems, nalloc*sizeof(int)); 95 | } 96 | (*adjelems)[pos] = MF_ID(ef)-1; 97 | pos++; 98 | } 99 | } 100 | List_Delete(efaces); 101 | } 102 | List_Delete(fedges); 103 | i++; 104 | } 105 | (*adjbeg)[*nelems] = pos; 106 | } 107 | 108 | return 1; 109 | } 110 | -------------------------------------------------------------------------------- /src/hilev/MEs_Angle.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include "MSTK.h" 14 | #include "MSTK_VecFuncs.h" 15 | 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | /* ***COSINE*** of Angle between two mesh edges if they share a 22 | vertex. The angle will be the smaller of the two possible 23 | angles. */ 24 | 25 | double MEs_Angle(MEdge_ptr edge1, MEdge_ptr edge2) { 26 | int i, j, fnd; 27 | double exyz[2][3], vec1[3], vec2[3], dp; 28 | MVertex_ptr ev1[2], ev2[2]; 29 | 30 | ev1[0] = ME_Vertex(edge1,0); 31 | ev1[1] = ME_Vertex(edge1,1); 32 | ev2[0] = ME_Vertex(edge2,0); 33 | ev2[1] = ME_Vertex(edge2,1); 34 | 35 | fnd = 1; 36 | if (ev1[0] == ev2[0]) { 37 | i = 0; j = 0; 38 | } 39 | else if (ev1[0] == ev2[1]) { 40 | i = 0; j = 1; 41 | } 42 | else if (ev1[1] == ev2[0]) { 43 | i = 1; j = 0; 44 | } 45 | else if (ev1[1] == ev2[1]) { 46 | i = 1; j = 1; 47 | } 48 | else { 49 | MSTK_Report("MEs_Angle","Edges do not share common vertex",MSTK_ERROR); 50 | return 0.0; 51 | } 52 | 53 | /* Edge vector 1 going away from common vertex */ 54 | 55 | MV_Coords(ev1[i],exyz[0]); 56 | MV_Coords(ev1[1-i],exyz[1]); 57 | 58 | MSTK_VDiff3(exyz[1],exyz[0],vec1); 59 | MSTK_VNormalize3(vec1); 60 | 61 | /* Edge vector 2 going away from common vertex */ 62 | 63 | MV_Coords(ev2[j],exyz[0]); 64 | MV_Coords(ev2[1-j],exyz[1]); 65 | MSTK_VDiff3(exyz[1],exyz[0],vec2); 66 | MSTK_VNormalize3(vec2); 67 | 68 | /* Angle between vectors */ 69 | 70 | dp = MSTK_VDot3(vec1,vec2); 71 | 72 | return dp; 73 | } 74 | 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | -------------------------------------------------------------------------------- /src/hilev/MF_Coords.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include "MSTK.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | void MF_Coords(MFace_ptr f, int *n, double (*xyz)[3]) { 18 | int i; 19 | MVertex_ptr fv; 20 | List_ptr fverts; 21 | 22 | fverts = MF_Vertices(f,1,0); 23 | *n = List_Num_Entries(fverts); 24 | 25 | for (i = 0; i < *n; i++) { 26 | fv = List_Entry(fverts,i); 27 | MV_Coords(fv,xyz[i]); 28 | } 29 | List_Delete(fverts); 30 | } 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | -------------------------------------------------------------------------------- /src/hilev/MR_Coords.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include "MSTK.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | void MR_Coords(MRegion_ptr r, int *n, double (*xyz)[3]) { 18 | int i; 19 | MVertex_ptr rv; 20 | List_ptr rverts; 21 | 22 | rverts = MR_Vertices(r); 23 | *n = List_Num_Entries(rverts); 24 | 25 | for (i = 0; i < *n; i++) { 26 | rv = List_Entry(rverts,i); 27 | MV_Coords(rv,xyz[i]); 28 | } 29 | List_Delete(rverts); 30 | } 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | -------------------------------------------------------------------------------- /src/io/MESH_ExportToDX.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "MSTK.h" 14 | 15 | int MESH_ExportToDXBin(Mesh_ptr, const char *fname); 16 | 17 | int MESH_ExportToDX(Mesh_ptr mesh, const char *fname, int binary) { 18 | 19 | return MESH_ExportToDXBin(mesh, fname); 20 | 21 | } 22 | 23 | -------------------------------------------------------------------------------- /src/io/MESH_ExportToFile.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | /* Function to export MSTK mesh to MSTK and other formats */ 18 | 19 | /* if natt = 0, all attributes are written out 20 | if natt = -1, no attributes are written out 21 | if natt > 0, only attributes specified in attnames are written out 22 | 23 | opts is an array of flags that controls how mesh is exported and is 24 | specific to each format. See the specific MESH_ExportTo"Format" file 25 | 26 | If you want default options, call the functions as 27 | 28 | MESH_ExportToFile(mymesh,myfile,myformat,0,NULL,NULL,NULL); 29 | */ 30 | 31 | int MESH_ExportToFile(Mesh_ptr mesh, const char *outfilename, const char *outformat, 32 | const int natt, const char **attnames, const int *opts, MSTK_Comm comm) { 33 | 34 | char format[16]; 35 | 36 | if (outformat) 37 | strcpy(format,outformat); 38 | else { 39 | char *ext; 40 | if (outfilename[0] == '.') { 41 | ext = strchr(outfilename,'.'); 42 | ++ext; 43 | ext = strchr(ext,'.'); 44 | } 45 | else 46 | ext = strchr(outfilename,'.'); 47 | if (ext != NULL) { 48 | ++ext; /* go past the . */ 49 | if (strcmp(ext,"mstk") == 0) 50 | strcpy(format,"mstk"); 51 | else if (strcmp(ext,"gmv") == 0) 52 | strcpy(format,"gmv"); 53 | else if (strcmp(ext,"exo") == 0) 54 | strcpy(format,"exodusii"); 55 | else if (strcmp(ext,"off") == 0) 56 | strcpy(format,"off"); 57 | else { 58 | fprintf(stderr,"Unknown file format\n"); 59 | return -1; 60 | } 61 | } 62 | else { 63 | fprintf(stderr,"Unknown file format\n"); 64 | return -1; 65 | } 66 | } 67 | 68 | 69 | if (strncmp(format,"mstk",4) == 0) 70 | return MESH_WriteToFile(mesh,outfilename,MESH_RepType(mesh),comm); 71 | else if (strncmp(format,"gmv",3) == 0) 72 | return MESH_ExportToGMV(mesh,outfilename,natt,attnames,opts,comm); 73 | else if (strncmp(format,"x3d",4) == 0) 74 | return MESH_ExportToFLAGX3D(mesh,outfilename,natt,attnames,opts,comm); 75 | else if (strncmp(format,"exo",3) == 0) { 76 | #ifdef ENABLE_ExodusII 77 | return MESH_ExportToExodusII(mesh,outfilename,natt,attnames,opts,comm); 78 | #else 79 | MSTK_Report("MESH_ExportFromFile","Exodus II file support not built in",MSTK_ERROR); 80 | #endif 81 | } 82 | else if (strncmp(format, "stl", 3) == 0) 83 | return MESH_ExportToSTL(mesh,outfilename); 84 | else if (strncmp(format, "off", 3) == 0) 85 | return MESH_ExportToOFF(mesh,outfilename); 86 | else if (strncmp(format, "dx", 3) == 0) 87 | return MESH_ExportToDX(mesh,outfilename,1); /* binary export */ 88 | 89 | 90 | MSTK_Report("MESH_ExportFromFile","Unsupported export format",MSTK_ERROR); 91 | return 0; 92 | 93 | } 94 | 95 | #ifdef __cplusplus 96 | } 97 | #endif 98 | -------------------------------------------------------------------------------- /src/io/MESH_ExportToOFF.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "MSTK.h" 16 | 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | 23 | int MESH_ExportToOFF(Mesh_ptr mesh, const char *filename) { 24 | FILE *fp; 25 | char mesg[256]; 26 | 27 | 28 | if (MESH_Num_Regions(mesh) || !MESH_Num_Faces(mesh)) { 29 | MSTK_Report("MESH_ExportToOFF", "Only surface meshes can be exported to OFF format", MSTK_ERROR); 30 | return 0; 31 | } 32 | 33 | if (!(fp = fopen(filename,"w"))) { 34 | sprintf(mesg,"Couldn't open output file %s\n",filename); 35 | MSTK_Report("MESH_ExportToSTL",mesg,MSTK_ERROR); 36 | return 0; 37 | } 38 | 39 | /* Write header */ 40 | 41 | fprintf(fp,"OFF\n"); // Apparently optional; turn off if it causes problems 42 | fprintf(fp,"%d %d %d\n",MESH_Num_Vertices(mesh), MESH_Num_Faces(mesh), MESH_Num_Edges(mesh)); 43 | 44 | 45 | /* Write vertex info */ 46 | 47 | int idx = 0; 48 | MVertex_ptr mv; 49 | while ((mv = MESH_Next_Vertex(mesh, &idx))) { 50 | double xyz[3]; 51 | MV_Coords(mv, xyz); 52 | fprintf(fp,"%20.12lf %20.12lf %20.12lf\n",xyz[0],xyz[1],xyz[2]); 53 | } 54 | 55 | 56 | /* Write face vertex info */ 57 | MFace_ptr mf; 58 | idx = 0; 59 | while ((mf = MESH_Next_Face(mesh, &idx))) { 60 | List_ptr fverts = MF_Vertices(mf,1,0); 61 | fprintf(fp,"%d ",List_Num_Entries(fverts)); 62 | for (int i = 0; i < List_Num_Entries(fverts); i++) 63 | fprintf(fp," %d",MV_ID(List_Entry(fverts,i))); 64 | fprintf(fp,"\n"); 65 | List_Delete(fverts); 66 | } 67 | 68 | return 1; 69 | } 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /src/io/MESH_ExportToSTL.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "MSTK.h" 16 | 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | 23 | int MESH_ExportToSTL(Mesh_ptr mesh, const char *filename) { 24 | List_ptr fverts; 25 | MFace_ptr face; 26 | char mesg[256]; 27 | int i, j, nfv, idx; 28 | double fxyz[MAXPV2][3], normal[3], len, vec1[3], vec2[3]; 29 | FILE *fp; 30 | 31 | 32 | if (!(fp = fopen(filename,"w"))) { 33 | sprintf(mesg,"Couldn't open output file %s\n",filename); 34 | MSTK_Report("MESH_ExportToSTL",mesg,MSTK_ERROR); 35 | return 0; 36 | } 37 | 38 | if (MESH_Num_Regions(mesh)) { 39 | MSTK_Report("MESH_ExportToSTL","Cannot export solid meshes\n",MSTK_ERROR); 40 | return 0; 41 | } 42 | 43 | idx = 0; 44 | while ((face = MESH_Next_Face(mesh,&idx))) { 45 | if (MF_Num_Edges(face) != 3) { 46 | MSTK_Report("MESH_ExportToSTL","Can only export triangular meshes to STL\n",MSTK_ERROR); 47 | MSTK_Report("MESH_ExportToSTL","If you need polygonal meshes to be exported\n",MSTK_MESG); 48 | MSTK_Report("MESH_ExportToSTL","as a triangulated surface mesh to STL, \n",MSTK_MESG); 49 | MSTK_Report("MESH_ExportToSTL","please send a mail to rao@lanl.gov\n",MSTK_MESG); 50 | return 0; 51 | } 52 | } 53 | 54 | 55 | /* Opening line for STL file */ 56 | fprintf(fp,"solid\n"); 57 | 58 | idx = 0; 59 | while ((face = MESH_Next_Face(mesh,&idx))) { 60 | 61 | fverts = MF_Vertices(face,1,0); 62 | nfv = List_Num_Entries(fverts); 63 | 64 | for (i = 0; i < nfv; i++) 65 | MV_Coords(List_Entry(fverts,i),fxyz[i]); 66 | 67 | { 68 | vec1[0] = fxyz[1][0]-fxyz[0][0]; 69 | vec1[1] = fxyz[1][1]-fxyz[0][1]; 70 | vec1[2] = fxyz[1][2]-fxyz[0][2]; 71 | 72 | vec2[0] = fxyz[2][0]-fxyz[0][0]; 73 | vec2[1] = fxyz[2][1]-fxyz[0][1]; 74 | vec2[2] = fxyz[2][2]-fxyz[0][2]; 75 | 76 | normal[0] = vec1[1]*vec2[2] - vec1[2]*vec2[1]; 77 | normal[1] = vec1[2]*vec2[0] - vec1[0]*vec2[2]; 78 | normal[2] = vec1[0]*vec2[1] - vec1[1]*vec2[0]; 79 | 80 | len = sqrt(normal[0]*normal[0]+normal[1]*normal[1]+normal[2]*normal[2]); 81 | 82 | normal[0] /= len; normal[1] /= len; normal[2] /= len; 83 | } 84 | 85 | fprintf(fp,"facet normal %12.8lf %12.8lf %12.8lf\n",normal[0],normal[1],normal[2]); 86 | fprintf(fp," outer loop\n"); 87 | for (j = 0; j < 3; j++) 88 | fprintf(fp," vertex %20.10lf %20.10lf %20.10lf\n",fxyz[j][0],fxyz[j][1],fxyz[j][2]); 89 | fprintf(fp,"endloop"); 90 | fprintf(fp,"endfacet"); 91 | } 92 | 93 | fprintf(fp,"endsolid"); 94 | 95 | fclose(fp); 96 | 97 | return 1; 98 | } 99 | 100 | #ifdef __cplusplus 101 | } 102 | #endif 103 | 104 | -------------------------------------------------------------------------------- /src/io/MESH_ImportFromFile.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | int MESH_ImportFromFile(Mesh_ptr mesh, const char *infilename, const char *informat, int *opts, MSTK_Comm comm) { 19 | 20 | char format[16]; 21 | 22 | if (informat) 23 | strcpy(format,informat); 24 | else { 25 | char *ext; 26 | if (infilename[0] == '.') { 27 | ext = strchr(infilename,'.'); 28 | ++ext; 29 | ext = strchr(ext,'.'); 30 | } 31 | else 32 | ext = strchr(infilename,'.'); 33 | if (ext != NULL) { 34 | ++ext; /* go past the . */ 35 | if (strcmp(ext,"mstk") == 0) 36 | strcpy(format,"mstk"); 37 | else if (strcmp(ext,"gmv") == 0) 38 | strcpy(format,"gmv"); 39 | else if (strcmp(ext,"exo") == 0) 40 | strcpy(format,"exodusii"); 41 | else if (strcmp(ext,"par") == 0) 42 | strcpy(format,"nemesisi"); 43 | else if (strcmp(ext,"x3d") == 0) 44 | strcpy(format,"x3d"); 45 | else { 46 | fprintf(stderr,"Unknown file format\n"); 47 | return -1; 48 | } 49 | } 50 | else { 51 | fprintf(stderr,"Unknown file format\n"); 52 | return -1; 53 | } 54 | } 55 | 56 | 57 | if (strcmp(format,"mstk") == 0) 58 | return MESH_InitFromFile(mesh,infilename,comm); 59 | else { 60 | if (MESH_RepType(mesh) == UNKNOWN_REP) 61 | MESH_SetRepType(mesh,F1); 62 | 63 | if (strcmp(format,"gmv") == 0) 64 | return MESH_ImportFromGMV(mesh,infilename,comm); 65 | else if (strcmp(format,"exodusii") == 0) { 66 | #ifdef ENABLE_ExodusII 67 | return MESH_ImportFromExodusII(mesh,infilename,opts,comm); 68 | #else 69 | MSTK_Report("MESH_ImportFromFile","Exodus II file support not built in",MSTK_ERROR); 70 | #endif 71 | } 72 | else if (strcmp(format,"nemesisi") == 0) { 73 | #ifdef ENABLE_ExodusII 74 | return MESH_ImportFromNemesisI(mesh,infilename,opts,comm); 75 | #else 76 | MSTK_Report("MESH_ImportFromFile","Exodus II/Nemesis I file support not built in",MSTK_ERROR); 77 | #endif 78 | } 79 | else if (strcmp(format,"x3d") == 0) { 80 | return MESH_ImportFromFLAGX3D(mesh,infilename,opts,comm); 81 | } 82 | } 83 | 84 | MSTK_Report("MESH_ImportFromFile","Unsupported import format",MSTK_ERROR); 85 | return 0; 86 | 87 | } 88 | 89 | #ifdef __cplusplus 90 | } 91 | #endif 92 | -------------------------------------------------------------------------------- /src/misc/List_PrintID.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include "MSTK.h" 12 | 13 | #ifdef DEBUG 14 | 15 | void List_PrintID(List_ptr l) { 16 | int i, k, num; 17 | MEntity_ptr entry; 18 | 19 | num = List_Num_Entries(l); 20 | 21 | fprintf(stderr,"List %p:\n",l); 22 | for (i = 0, k = 0; i < num; i++) { 23 | entry = List_Entry(l,i); 24 | 25 | fprintf(stderr,"%d ",MEnt_ID(entry)); 26 | k++; 27 | if (k%10 == 0) 28 | fprintf(stderr,"\n"); 29 | } 30 | fprintf(stderr,"\n"); 31 | } 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/misc/MF_CondNums.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include "MSTK.h" 12 | 13 | 14 | /* Condition number of polygon corners */ 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | void MF_CondNums(MFace_ptr f, int *n, double *conds) { 21 | double xyz[MAXPV2][3], L10_sqr, L20_sqr, L21_sqr, A; 22 | double xyz1[3][3], eps=1.0E-14; 23 | int i, k, nfv; 24 | MVertex_ptr vtx[MAXPV2]; 25 | List_ptr fverts; 26 | 27 | fverts = MF_Vertices(f,1,0); 28 | nfv = List_Num_Entries(fverts); 29 | for (i = 0; i < nfv; i++) { 30 | vtx[i] = List_Entry(fverts,i); 31 | MV_Coords(vtx[i],xyz[i]); 32 | } 33 | List_Delete(fverts); 34 | 35 | 36 | for (i = 0; i < nfv; i++) { 37 | for (k = 0; k < 3; k++) 38 | xyz1[0][k] = xyz[i][k]; 39 | for (k = 0; k < 3; k++) 40 | xyz1[1][k] = xyz[(i+1)%nfv][k]; 41 | for (k = 0; k < 3; k++) 42 | xyz1[2][k] = xyz[(i+nfv-1)%nfv][k]; 43 | 44 | L10_sqr = ((xyz1[1][0]-xyz1[0][0])*(xyz1[1][0]-xyz1[0][0]) + 45 | (xyz1[1][1]-xyz1[0][1])*(xyz1[1][1]-xyz1[0][1]) + 46 | (xyz1[1][2]-xyz1[0][2])*(xyz1[1][2]-xyz1[0][2])); 47 | 48 | if (L10_sqr < eps*eps) 49 | L10_sqr = eps*eps; 50 | 51 | L20_sqr = ((xyz1[2][0]-xyz1[0][0])*(xyz1[2][0]-xyz1[0][0]) + 52 | (xyz1[2][1]-xyz1[0][1])*(xyz1[2][1]-xyz1[0][1]) + 53 | (xyz1[2][2]-xyz1[0][2])*(xyz1[2][2]-xyz1[0][2])); 54 | 55 | if (L20_sqr < eps*eps) 56 | L20_sqr = eps*eps; 57 | 58 | L21_sqr = ((xyz1[2][0]-xyz1[1][0])*(xyz1[2][0]-xyz1[1][0]) + 59 | (xyz1[2][1]-xyz1[1][1])*(xyz1[2][1]-xyz1[1][1]) + 60 | (xyz1[2][2]-xyz1[1][2])*(xyz1[2][2]-xyz1[1][2])); 61 | 62 | if (L21_sqr < eps*eps) 63 | L21_sqr = eps*eps; 64 | 65 | /* modified version of Herron's formula sqrt(s*(s-a)*(s-b)*(s-c)) */ 66 | A = 0.25*sqrt(4*L10_sqr*L20_sqr - (L10_sqr+L20_sqr-L21_sqr)*(L10_sqr+L20_sqr-L21_sqr)); 67 | 68 | /* Need the extra 2 in the denominator if the cond num of the ideal 69 | is to be 1 */ 70 | conds[i] = (L10_sqr+L20_sqr)/(2*2*A); 71 | } 72 | 73 | *n = nfv; 74 | 75 | return; 76 | } 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | 82 | -------------------------------------------------------------------------------- /src/misc/MSTK_VecFuncs.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include "MSTK_VecFuncs.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | void MSTK_VDiff3(double *a, double *b, double *c) { 18 | c[0] = a[0]-b[0]; c[1] = a[1]-b[1]; c[2] = a[2]-b[2]; 19 | } 20 | 21 | void MSTK_VSum3(double *a, double *b, double *c) { 22 | c[0] = a[0]+b[0]; c[1] = a[1]+b[1]; c[2] = a[2]+b[2]; 23 | } 24 | 25 | void MSTK_VScale3(double *a, double s) { 26 | a[0] *= s; a[1] *= s; a[2] *= s; 27 | } 28 | 29 | double MSTK_VLen3(double *a) { 30 | return sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]); 31 | } 32 | 33 | double MSTK_VLenSqr3(double *a) { 34 | return (a[0]*a[0]+a[1]*a[1]+a[2]*a[2]); 35 | } 36 | 37 | void MSTK_VNormalize3(double *a) { 38 | double len = sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]); 39 | 40 | if (len <= 1.0e-28) { 41 | return; 42 | #ifdef DEBUG 43 | fprintf(stderr,"Zero Length vector\n"); 44 | #endif 45 | } 46 | 47 | a[0] /= len; a[1] /= len; a[2] /= len; 48 | } 49 | 50 | double MSTK_VDot3(double *a, double *b) { 51 | return (a[0]*b[0]+a[1]*b[1]+a[2]*b[2]); 52 | } 53 | 54 | void MSTK_VCross3(double *a, double *b, double *x) { 55 | x[0] = a[1]*b[2]-a[2]*b[1]; 56 | x[1] = a[2]*b[0]-a[0]*b[2]; 57 | x[2] = a[0]*b[1]-a[1]*b[0]; 58 | } 59 | 60 | void MSTK_VCopy3(double *a, double *b) { 61 | a[0] = b[0]; a[1] = b[1]; a[2] = b[2]; 62 | } 63 | 64 | void MSTK_VNeg3(double *a) { 65 | a[0] = -a[0]; a[1] = -a[1]; a[2] = -a[2]; 66 | } 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | -------------------------------------------------------------------------------- /src/mod/ME_Split.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include "MSTK.h" 13 | 14 | /* Routine to split an edge at a given location - two new edges are 15 | created in place of this edge and the faces connected to the old 16 | edge are updated to reflect the new topology. The split edge is 17 | deleted */ 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | MVertex_ptr ME_Split(MEdge_ptr esplit, double *xyz) { 24 | MVertex_ptr vnew, v[2]; 25 | MEdge_ptr enew; 26 | List_ptr elist; 27 | double vxyz[3]; 28 | 29 | #ifdef DEBUG 30 | v[0] = ME_Vertex(esplit,0); 31 | v[1] = ME_Vertex(esplit,1); 32 | #endif 33 | 34 | if (xyz) { 35 | memcpy(vxyz,xyz,3*sizeof(double)); 36 | elist = ME_MultiSplit(esplit,1,&vxyz); 37 | } 38 | else 39 | elist = ME_MultiSplit(esplit,1,NULL); 40 | 41 | enew = List_Entry(elist,0); 42 | vnew = ME_Vertex(enew,1); 43 | 44 | #ifdef DEBUG 45 | if (vnew == v[0] || vnew == v[1]) { 46 | MSTK_Report("ME_Split","Unexpected failure to retrieve split vertex", 47 | MSTK_FATAL); 48 | } 49 | #endif 50 | 51 | List_Delete(elist); 52 | 53 | return vnew; 54 | } 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | -------------------------------------------------------------------------------- /src/mod/MEs_Merge.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include "MEdge_jmp.h" 12 | #include "MSTK_private.h" 13 | 14 | /* topoflag = 1 means respect model topology (as given by mesh entity 15 | classification) and do not allow dimensional reduction in the mesh 16 | 17 | topoflag = 0 means the caller does not care about classification 18 | and would like the two edges to be merged as requested */ 19 | 20 | MEdge_ptr MEs_Merge(MEdge_ptr e1, MEdge_ptr e2, int topoflag) { 21 | RepType rtype = MESH_RepType(ME_Mesh(e1)); 22 | 23 | return (*MEs_Merge_jmp[rtype])(e1,e2,topoflag); 24 | } 25 | -------------------------------------------------------------------------------- /src/mod/MEs_Merge_FN.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include "MEdge_jmp.h" 12 | #include "MSTK_private.h" 13 | 14 | /* Replace e2 with e1 in all the faces using e2 and delete e2 */ 15 | 16 | MEdge_ptr MEs_Merge_FN(MEdge_ptr e1, MEdge_ptr e2, int topoflag) { 17 | int i, idx, gdim1, gid1, gdim2, gid2, nsets; 18 | MVertex_ptr v11, v12, v21, v22; 19 | MFace_ptr face; 20 | Mesh_ptr mesh; 21 | List_ptr efaces2; 22 | MSet_ptr mset; 23 | 24 | mesh = ME_Mesh(e1); 25 | gid1 = ME_GEntID(e1); 26 | gdim1 = ME_GEntDim(e1); 27 | gid2 = ME_GEntID(e2); 28 | gdim2 = ME_GEntDim(e2); 29 | 30 | if (mesh != MF_Mesh(e2)) { 31 | MSTK_Report("MEs_Merge","Edges not from same mesh - Cannot merge",MSTK_ERROR); 32 | return 0; 33 | } 34 | else if (topoflag) { /* Make sure model topology is not violated */ 35 | if (gdim1 == gdim2) { 36 | if (gid1 != gid2) { 37 | MSTK_Report("MEs_Merge","Edges are on different geometric entities of the same dimension - Cannot merge",MSTK_ERROR); 38 | return 0; 39 | } 40 | } 41 | else if (gdim2 < gdim1) { 42 | MSTK_Report("MEs_Merge","Cannot merge edge on lower dimensional geometric entity to edge on higher dimensional geometric entity",MSTK_ERROR); 43 | return 0; 44 | } 45 | } 46 | 47 | v11 = ME_Vertex(e1,0); v12 = ME_Vertex(e1,1); 48 | v21 = ME_Vertex(e2,0); v22 = ME_Vertex(e2,1); 49 | 50 | if ((v11 != v21 && v11 != v22) || 51 | (v12 != v21 && v12 != v22)) { 52 | MSTK_Report("MEs_Merge","Vertices of edges must be merged before attempting to merge edges",MSTK_ERROR); 53 | return 0; 54 | } 55 | 56 | 57 | efaces2 = ME_Faces(e2); 58 | 59 | if (efaces2) { 60 | idx = 0; 61 | while ((face = List_Next_Entry(efaces2,&idx))) 62 | MF_Replace_Edges(face,1,&e2,1,&e1); 63 | 64 | List_Delete(efaces2); 65 | } 66 | 67 | nsets = MESH_Num_MSets(mesh); 68 | if(nsets) { 69 | idx = 0; 70 | while ((mset = (MSet_ptr) MESH_Next_MSet(mesh,&idx))) { 71 | if (MSet_Contains(mset, e2)) { 72 | if(MSet_Contains(mset, e1)) 73 | MSet_Rem(mset, e2); 74 | else 75 | MSet_Replace(mset, e2, e1); 76 | } 77 | } 78 | } 79 | 80 | ME_Delete(e2,1); 81 | 82 | return e1; 83 | } 84 | -------------------------------------------------------------------------------- /src/mod/MEs_Merge_RN.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include "MEdge_jmp.h" 12 | #include "MSTK_private.h" 13 | 14 | 15 | MEdge_ptr MEs_Merge_RN(MEdge_ptr e1, MEdge_ptr e2, int topoflag) { 16 | 17 | /* Edges are not explicit entities in reduced representations - 18 | nothing to do */ 19 | 20 | ME_Delete(e2,0); 21 | return e1; 22 | } 23 | -------------------------------------------------------------------------------- /src/mod/MF_Split.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | #include "MSTK.h" 13 | 14 | /* Routine to split a face at a point in the face. New triangular 15 | faces are created using the split vertex and each edge of the 16 | face. The new faces are incorporated into connected regions. There 17 | is no check to ensure that the point is actually in the face and 18 | not on its boundary or outside the face. This is a strictly 19 | topological routine and geometric checks for validity must be done 20 | elsewhere */ 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | MVertex_ptr MF_Split(MFace_ptr fsplit, double *splitxyz) { 27 | Mesh_ptr mesh; 28 | MVertex_ptr vsplit, fv[3]; 29 | MEdge_ptr enew, *fedges0, *fedges1, fe; 30 | MFace_ptr fnew[MAXPV2]; 31 | MRegion_ptr fr; 32 | int gid, gdim, i, j, idx, nnew; 33 | int nfv, fnewdir[MAXPV2], rfdir; 34 | List_ptr fregs, fverts; 35 | 36 | gdim = MF_GEntDim(fsplit); 37 | gid = MF_GEntID(fsplit); 38 | 39 | /* Collect information */ 40 | 41 | mesh = MF_Mesh(fsplit); 42 | 43 | /* Regions connected to face */ 44 | 45 | fregs = MF_Regions(fsplit); 46 | 47 | /* Vertices of face */ 48 | 49 | fverts = MF_Vertices(fsplit,1,0); 50 | nfv = List_Num_Entries(fverts); 51 | 52 | /* Create the splitting vertex */ 53 | 54 | vsplit = MV_New(mesh); 55 | MV_Set_Coords(vsplit,splitxyz); 56 | MV_Set_GEntDim(vsplit,gdim); 57 | MV_Set_GEntID(vsplit,gid); 58 | 59 | /* Create the 'nfe' faces */ 60 | 61 | for (i = 0; i < nfv; i++) { 62 | fv[0] = vsplit; 63 | fv[1] = List_Entry(fverts,i); 64 | fv[2] = List_Entry(fverts,(i+1)%nfv); 65 | 66 | fnew[i] = MF_New(mesh); 67 | MF_Set_GEntDim(fnew[i],gdim); 68 | MF_Set_GEntID(fnew[i],gid); 69 | MF_Set_Vertices(fnew[i],3,fv); 70 | } 71 | List_Delete(fverts); 72 | nnew = nfv; 73 | 74 | 75 | if (fregs) { 76 | for (i = 0; i < List_Num_Entries(fregs); i++) { 77 | fr = List_Entry(fregs,i); 78 | rfdir = MR_FaceDir(fr,fsplit); 79 | for (j = 0; j < nnew; j++) 80 | fnewdir[j] = rfdir; 81 | MR_Replace_Faces(fr,1,&fsplit,nnew,fnew,fnewdir); 82 | } 83 | List_Delete(fregs); 84 | } 85 | 86 | MF_Delete(fsplit,0); 87 | 88 | return vsplit; 89 | } 90 | 91 | #ifdef __cplusplus 92 | } 93 | #endif 94 | -------------------------------------------------------------------------------- /src/mod/MFs_Merge.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include "MFace_jmp.h" 12 | #include "MSTK_private.h" 13 | 14 | /* topoflag = 1 means respect model topology (as given by mesh entity 15 | classification) and do not allow dimensional reduction in the mesh 16 | 17 | topoflag = 0 means the caller does not care about classification 18 | and would like the two faces to be merged as requested */ 19 | 20 | MFace_ptr MFs_Merge(MFace_ptr f1, MFace_ptr f2, int topoflag) { 21 | RepType rtype = MESH_RepType(MF_Mesh(f1)); 22 | 23 | return (*MFs_Merge_jmp[rtype])(f1,f2,topoflag); 24 | } 25 | -------------------------------------------------------------------------------- /src/mod/MFs_Merge_R1R2.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include "MFace_jmp.h" 12 | #include "MSTK_private.h" 13 | 14 | 15 | MFace_ptr MFs_Merge_R1R2(MFace_ptr f1, MFace_ptr f2, int topoflag) { 16 | 17 | /* Faces are not explicit entities in reduced representations - 18 | nothing to do */ 19 | 20 | MF_Delete(f2,0); 21 | return f1; 22 | } 23 | -------------------------------------------------------------------------------- /src/mod/MFs_Merge_R3R4.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include "MFace_jmp.h" 12 | #include "MSTK_private.h" 13 | 14 | /* Replace f2 with f1 in all the regions using f2 and delete f2 */ 15 | 16 | MFace_ptr MFs_Merge_R3R4(MFace_ptr f1, MFace_ptr f2, int topoflag) { 17 | int i, idx, gdim, gid, dir, nsets; 18 | MRegion_ptr reg; 19 | Mesh_ptr mesh; 20 | List_ptr fregs2, fverts1, fverts2; 21 | MSet_ptr mset; 22 | 23 | 24 | /* Check that we are not violating topological conformity with geometric model */ 25 | 26 | mesh = MF_Mesh(f1); 27 | gid = MF_GEntID(f1); 28 | gdim = MF_GEntDim(f1); 29 | 30 | if (mesh != MF_Mesh(f2)) { 31 | MSTK_Report("MFs_Merge","Faces not from same mesh - Cannot merge",MSTK_ERROR); 32 | return 0; 33 | } 34 | else if (topoflag) { /* Make sure model topology is not violated */ 35 | if (gid != MF_GEntID(f2) || gdim != MF_GEntDim(f2)) { 36 | MSTK_Report("MFs_Merge","Faces not from same geometric entity - Cannot merge",MSTK_ERROR); 37 | return 0; 38 | } 39 | } 40 | 41 | 42 | /* Debug check to make sure edges of faces are identical */ 43 | 44 | #ifdef DEBUG 45 | { 46 | List_ptr fverts1, fverts2; 47 | MVertex_ptr fv1; 48 | 49 | fverts1 = MF_Vertices(f1,1,0); 50 | fverts2 = MF_Vertices(f2,1,0); 51 | 52 | if (List_Num_Entries(f1) != List_Num_Entries(f2)) { 53 | MSTK_Report("MFs_Merge", 54 | "To-be-merged faces have different number of edges", 55 | MSTK_ERROR); 56 | return 0; 57 | } 58 | 59 | idx = 0; 60 | while ((fv1 = List_Next_Entry(fverts1,&idx))) { 61 | if (!List_Contains(fverts2,fv1)) { 62 | MSTK_Report("MFs_Merge", 63 | "Vertices of faces must be merged before merging faces", 64 | MSTK_ERROR); 65 | return 0; 66 | } 67 | } 68 | 69 | List_Delete(fverts1); 70 | List_Delete(fverts2); 71 | } 72 | #endif 73 | 74 | 75 | /* Replace f2 with f1 in all regions connected to f2 */ 76 | 77 | fregs2 = MF_Regions(f2); 78 | 79 | if (fregs2) { 80 | idx = 0; 81 | while ((reg = List_Next_Entry(fregs2,&idx))) { 82 | dir = MR_FaceDir(reg,f2); 83 | MR_Replace_Faces(reg,1,&f2,1,&f1,&dir); 84 | } 85 | 86 | List_Delete(fregs2); 87 | } 88 | 89 | nsets = MESH_Num_MSets(mesh); 90 | if(nsets) { 91 | idx = 0; 92 | while ((mset = (MSet_ptr) MESH_Next_MSet(mesh,&idx))) { 93 | if (MSet_Contains(mset, f2)) { 94 | if(MSet_Contains(mset, f1)) 95 | MSet_Rem(mset, f2); 96 | else 97 | MSet_Replace(mset, f2, f1); 98 | } 99 | } 100 | } 101 | 102 | MF_Delete(f2,1); 103 | 104 | return f1; 105 | } 106 | -------------------------------------------------------------------------------- /src/mod/MRs_Join.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | /* Join two regions sharing a common face. The faces of the second 10 | region (excluding the common face) are added to the first 11 | region. The common face and the second region are deleted and the 12 | first region is returned */ 13 | 14 | #include 15 | #include 16 | #include "MSTK.h" 17 | 18 | 19 | MRegion_ptr MRs_Join(MRegion_ptr r1, MRegion_ptr r2, MFace_ptr f) { 20 | int i, j, nrf1, nrf2, gdim, gid, *rfdir2; 21 | MFace_ptr *rf2, fcmn=f; 22 | Mesh_ptr mesh; 23 | List_ptr rfaces2; 24 | 25 | 26 | mesh = MF_Mesh(r1); 27 | gid = MF_GEntID(r1); 28 | 29 | if (mesh != MF_Mesh(r2)) { 30 | MSTK_Report("MRs_Join","Regions not from same mesh",MSTK_ERROR); 31 | return 0; 32 | } 33 | else if (gid != MR_GEntID(r2)) { 34 | MSTK_Report("MRs_Join","Regions not from same geometric entity",MSTK_ERROR); 35 | return 0; 36 | } 37 | 38 | 39 | rfaces2 = MR_Faces(r2); 40 | nrf2 = List_Num_Entries(rfaces2); 41 | 42 | if (fcmn) { 43 | if (!MR_UsesEntity(r1,fcmn,MFACE)) { 44 | MSTK_Report("MRs_Join","Cannot find common face in region",MSTK_ERROR); 45 | return 0; 46 | } 47 | } 48 | else { /* find the common face */ 49 | 50 | List_ptr rfaces1 = MR_Faces(r1); 51 | 52 | int idx = 0; 53 | MFace_ptr rf; 54 | while ((rf = List_Next_Entry(rfaces2,&idx))) { 55 | if (List_Contains(rfaces1,rf)) { 56 | fcmn = rf; 57 | break; 58 | } 59 | } 60 | 61 | List_Delete(rfaces1); 62 | 63 | } 64 | 65 | rf2 = (MFace_ptr) malloc(nrf2*sizeof(MFace_ptr)); 66 | rfdir2 = (int *) malloc(nrf2*sizeof(int)); 67 | 68 | int found; 69 | for (i = 0, j = 0, found = 0; i < nrf2; i++) { 70 | MFace_ptr rface = List_Entry(rfaces2,i); 71 | if (rface == fcmn) 72 | found = 1; 73 | else { 74 | rf2[j] = rface; 75 | rfdir2[j] = MR_FaceDir_i(r2,i); 76 | j++; 77 | } 78 | } 79 | List_Delete(rfaces2); 80 | 81 | if (!found) { 82 | MSTK_Report("MRs_Join","Cannot find common face in region",MSTK_ERROR); 83 | return 0; 84 | } 85 | 86 | MR_Delete(r2,0); 87 | 88 | MR_Replace_Faces(r1,1,&fcmn,nrf2-1,rf2,rfdir2); 89 | 90 | MF_Delete(fcmn,0); 91 | 92 | free(rf2); free(rfdir2); 93 | 94 | return r1; 95 | } 96 | -------------------------------------------------------------------------------- /src/mod/MVs_Merge.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include "MVertex_jmp.h" 12 | #include "MSTK_private.h" 13 | 14 | /* topoflag = 1 means respect model topology given by mesh entity 15 | classification and don't allow for dimensional reduction 16 | 17 | topoflag = 0 means the caller doesn't care about classifition and 18 | would like to merge the two vertices under all circumstances */ 19 | 20 | MVertex_ptr MVs_Merge(MVertex_ptr v1, MVertex_ptr v2, int topoflag) { 21 | RepType rtype = MESH_RepType(MV_Mesh(v1)); 22 | 23 | return (*MVs_Merge_jmp[rtype])(v1,v2,topoflag); 24 | } 25 | -------------------------------------------------------------------------------- /src/mod/MVs_Merge_FN.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include "MVertex_jmp.h" 12 | #include "MSTK_private.h" 13 | 14 | 15 | MVertex_ptr MVs_Merge_FN(MVertex_ptr v1, MVertex_ptr v2, int topoflag) { 16 | int idx, gdim, gid, nsets; 17 | MEdge_ptr edge; 18 | Mesh_ptr mesh; 19 | List_ptr vedges2; 20 | MSet_ptr mset; 21 | 22 | mesh = MV_Mesh(v1); 23 | gid = MV_GEntID(v1); 24 | gdim = MV_GEntDim(v1); 25 | 26 | if (mesh != MF_Mesh(v2)) { 27 | MSTK_Report("MVs_Join","Vertices not from same mesh",MSTK_ERROR); 28 | return 0; 29 | } 30 | else if (topoflag) { /* Make sure model topology is not violated */ 31 | if (gid != MV_GEntID(v2) || gdim != MV_GEntDim(v2)) { 32 | MSTK_Report("MFs_Join","Faces not from same geometric entity",MSTK_ERROR); 33 | return 0; 34 | } 35 | } 36 | 37 | vedges2 = MV_Edges(v2); 38 | 39 | if (vedges2) { 40 | idx = 0; 41 | while ((edge = List_Next_Entry(vedges2,&idx))) 42 | ME_Replace_Vertex(edge,v2,v1); 43 | 44 | List_Delete(vedges2); 45 | } 46 | 47 | nsets = MESH_Num_MSets(mesh); 48 | if(nsets) { 49 | idx = 0; 50 | while ((mset = (MSet_ptr) MESH_Next_MSet(mesh,&idx))) { 51 | if (MSet_Contains(mset, v2)) { 52 | if(MSet_Contains(mset, v1)) 53 | MSet_Rem(mset, v2); 54 | else 55 | MSet_Replace(mset, v2, v1); 56 | } 57 | } 58 | } 59 | 60 | MV_Delete(v2,1); 61 | 62 | return v1; 63 | } 64 | -------------------------------------------------------------------------------- /src/mod/MVs_Merge_R1R2.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include "MVertex_jmp.h" 12 | #include "MSTK_private.h" 13 | 14 | 15 | MVertex_ptr MVs_Merge_R1R2(MVertex_ptr v1, MVertex_ptr v2, int topoflag) { 16 | int i, idx, gdim, gid, nsets; 17 | MFace_ptr face; 18 | MRegion_ptr region; 19 | Mesh_ptr mesh; 20 | List_ptr vfaces2, vregions2; 21 | MSet_ptr mset; 22 | 23 | mesh = MV_Mesh(v1); 24 | gid = MV_GEntID(v1); 25 | gdim = MV_GEntDim(v1); 26 | 27 | if (mesh != MF_Mesh(v2)) { 28 | MSTK_Report("MVs_Join","Vertices not from same mesh",MSTK_ERROR); 29 | return 0; 30 | } 31 | else if (topoflag) { /* make sure geometric model topology is not violated */ 32 | if (gid != MV_GEntID(v2) || gdim != MV_GEntDim(v2)) { 33 | MSTK_Report("MFs_Join","Faces not from same geometric entity",MSTK_ERROR); 34 | return 0; 35 | } 36 | } 37 | 38 | 39 | vfaces2 = MV_Faces(v2); 40 | 41 | if (vfaces2) { 42 | 43 | idx = 0; 44 | while ((face = List_Next_Entry(vfaces2,&idx))) 45 | MF_Replace_Vertex(face,v2,v1); 46 | 47 | List_Delete(vfaces2); 48 | } 49 | 50 | 51 | vregions2 = MV_Regions(v2); 52 | 53 | if (vregions2) { 54 | 55 | idx = 0; 56 | while ((region = List_Next_Entry(vregions2,&idx))) 57 | MR_Replace_Vertex(region,v2,v1); 58 | 59 | List_Delete(vregions2); 60 | } 61 | 62 | nsets = MESH_Num_MSets(mesh); 63 | if(nsets) { 64 | idx = 0; 65 | while ((mset = (MSet_ptr) MESH_Next_MSet(mesh,&idx))) { 66 | if (MSet_Contains(mset, v2)) { 67 | if(MSet_Contains(mset, v1)) 68 | MSet_Rem(mset, v2); 69 | else 70 | MSet_Replace(mset, v2, v1); 71 | } 72 | } 73 | } 74 | 75 | MV_Delete(v2,1); 76 | 77 | return v1; 78 | } 79 | -------------------------------------------------------------------------------- /src/mod/MVs_Merge_R3R4.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include "MVertex_jmp.h" 12 | #include "MSTK_private.h" 13 | 14 | 15 | MVertex_ptr MVs_Merge_R3R4(MVertex_ptr v1, MVertex_ptr v2, int topoflag) { 16 | int idx, gdim, gid, nsets; 17 | MFace_ptr face; 18 | Mesh_ptr mesh; 19 | List_ptr vfaces2; 20 | MSet_ptr mset; 21 | 22 | mesh = MV_Mesh(v1); 23 | gid = MV_GEntID(v1); 24 | gdim = MV_GEntDim(v1); 25 | 26 | if (mesh != MF_Mesh(v2)) { 27 | MSTK_Report("MVs_Join","Vertices not from same mesh",MSTK_ERROR); 28 | return 0; 29 | } 30 | else if (topoflag) { /* Make sure model topology is not violated */ 31 | if (gid != MV_GEntID(v2) || gdim != MV_GEntDim(v2)) { 32 | MSTK_Report("MFs_Join","Faces not from same geometric entity",MSTK_ERROR); 33 | return 0; 34 | } 35 | } 36 | 37 | vfaces2 = MV_Faces(v2); 38 | 39 | if (vfaces2) { 40 | 41 | idx = 0; 42 | while ((face = List_Next_Entry(vfaces2,&idx))) 43 | MF_Replace_Vertex(face,v2,v1); 44 | 45 | List_Delete(vfaces2); 46 | } 47 | 48 | nsets = MESH_Num_MSets(mesh); 49 | if(nsets) { 50 | idx = 0; 51 | while ((mset = (MSet_ptr) MESH_Next_MSet(mesh,&idx))) { 52 | if (MSet_Contains(mset, v2)) { 53 | if(MSet_Contains(mset, v1)) 54 | MSet_Rem(mset, v2); 55 | else 56 | MSet_Replace(mset, v2, v1); 57 | } 58 | } 59 | } 60 | 61 | MV_Delete(v2,1); 62 | 63 | return v1; 64 | } 65 | -------------------------------------------------------------------------------- /src/par/MESH_CopySet.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "MSTK.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | /* 21 | this function copy set information from mesh to submesh 22 | mset_global - Set in the global_mesh 23 | Create the set in the submesh if it is not there 24 | 25 | */ 26 | 27 | int MESH_CopySet(Mesh_ptr mesh, int num, Mesh_ptr *submeshes, MSet_ptr gmset) { 28 | int i, idx, idx2, found; 29 | MType mtype; 30 | MEntity_ptr lment, gment; 31 | MSet_ptr lmset; 32 | char msetname[256]; 33 | void *loc; 34 | MAttrib_ptr g2latt; 35 | List_ptr lmentlist; 36 | MSet_ptr *lmset_array; 37 | Mesh_ptr submesh; 38 | 39 | lmset_array = (MSet_ptr *) calloc(num,sizeof(MSet_ptr)); 40 | 41 | g2latt = MESH_AttribByName(mesh,"Global2Local"); 42 | 43 | MSet_Name(gmset,msetname); 44 | mtype = MSet_EntDim(gmset); 45 | 46 | for (i = 0; i < num; ++i) { 47 | lmset_array[i] = MESH_MSetByName(submeshes[i],msetname); 48 | if (!lmset_array[i]) 49 | lmset_array[i] = MSet_New(submeshes[i],msetname,mtype); 50 | } 51 | 52 | 53 | 54 | idx = 0; 55 | while ((gment = MSet_Next_Entry(gmset,&idx))) { 56 | MEnt_Get_AttVal(gment,g2latt,0,0,&lmentlist); 57 | 58 | idx2 = 0; 59 | while ((lment = List_Next_Entry(lmentlist,&idx2))) { 60 | submesh = MEnt_Mesh(lment); 61 | 62 | for (i = 0; i < num; ++i) { 63 | if (submesh == submeshes[i]) { 64 | lmset = lmset_array[i]; 65 | MSet_Add(lmset,lment); 66 | break; 67 | } 68 | } 69 | 70 | } 71 | } 72 | 73 | free(lmset_array); 74 | return 1; 75 | } 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | -------------------------------------------------------------------------------- /src/par/MESH_RecvMesh.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "MSTK.h" 15 | #include "MSTK_private.h" 16 | 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | /* 23 | This function receives mesh from processor rank in communicator comm 24 | 25 | Author(s): Rao Garimella 26 | Duo Wang 27 | */ 28 | 29 | 30 | int MESH_RecvMesh(Mesh_ptr mesh, int fromrank, int with_attr, 31 | MSTK_Comm comm) { 32 | int i, j, a, m; 33 | int nv, ne, nf, nr; 34 | RepType rtype; 35 | MAttrib_ptr attrib; 36 | MSet_ptr mset; 37 | MPI_Status status; 38 | char mesg[256], errorstr[256], funcname[256]="MESH_RecvMesh"; 39 | int errcode, len, nreq=0; 40 | 41 | int rank; 42 | MPI_Comm_rank(comm,&rank); 43 | 44 | 45 | /* Receive meta data about mesh */ 46 | 47 | MESH_Recv_MetaData(mesh,fromrank,&rtype,&nv,&ne,&nf,&nr,comm); 48 | 49 | /* Receive mesh vertex info */ 50 | 51 | MESH_Recv_Vertices(mesh,fromrank,nv,comm); 52 | 53 | 54 | /* Receive mesh vertex coordinate info */ 55 | 56 | MESH_Recv_VertexCoords(mesh,fromrank,nv,comm); 57 | 58 | 59 | /* Receive higher dimensional entities */ 60 | 61 | MESH_Recv_NonVertexEntities(mesh,fromrank,ne,nf,nr,comm); 62 | 63 | 64 | if (with_attr) { 65 | 66 | /* Receive attribute meta data and create attributes */ 67 | 68 | MESH_Recv_AttributeMetaData(mesh,fromrank,comm); 69 | 70 | /* Receive each attribute - assumption is this processor is 71 | receiving attributes in the same order that the sending 72 | processor put them out */ 73 | 74 | int natt_local = MESH_Num_Attribs(mesh); 75 | 76 | for (a = 0; a < natt_local; a++) { 77 | attrib = MESH_Attrib(mesh,a); 78 | MESH_Recv_Attribute(mesh,attrib,fromrank,comm); 79 | } 80 | 81 | /* Receive mesh set meta data and create mesh sets */ 82 | 83 | MESH_Recv_MSetMetaData(mesh,fromrank,comm); 84 | 85 | /* Receive each mesh set - assumption is this processor is 86 | receiving mesh sets in the same order that the sending 87 | processor put them out */ 88 | 89 | int nset_local = MESH_Num_MSets(mesh); 90 | 91 | for (m = 0; m < nset_local; m++) { 92 | mset = MESH_MSet(mesh,m); 93 | MESH_Recv_MSet(mesh,mset,fromrank,comm); 94 | } 95 | 96 | } /* if (with_attr) */ 97 | 98 | return 1; 99 | } 100 | 101 | 102 | #ifdef __cplusplus 103 | } 104 | #endif 105 | 106 | -------------------------------------------------------------------------------- /src/par/MESH_Recv_MSetMetaData.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "MSTK.h" 15 | #include "MSTK_private.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | 22 | /* Receive meta data about entity sets (number of sets, their names, 23 | types of entities) of a mesh from distributing processor 24 | 25 | Authors: Rao Garimella 26 | */ 27 | 28 | int MESH_Recv_MSetMetaData(Mesh_ptr mesh, int fromrank, MSTK_Comm comm) { 29 | int i, nset, errcode, rank, len; 30 | int mtype; 31 | char msetname[256], mesg[256], errorstr[256]; 32 | MSet_ptr mset; 33 | char funcname[256] = "MESH_RecvMSets"; 34 | int *list_mset_types; 35 | char *list_mset_names; 36 | MPI_Status status; 37 | 38 | MPI_Comm_rank(comm,&rank); 39 | 40 | /* receive number of mesh sets and meta data about them */ 41 | 42 | errcode = MPI_Recv(&nset,1,MPI_INT,fromrank,rank,comm,&status); 43 | if (errcode != MPI_SUCCESS) { 44 | MPI_Error_string(errcode,errorstr,&len); 45 | sprintf(mesg,"MPI_Recv failed with error %s",errorstr); 46 | MSTK_Report(funcname,mesg,MSTK_FATAL); 47 | } 48 | 49 | if (!nset) return 1; 50 | 51 | list_mset_types = (int *) malloc(nset*sizeof(int)); 52 | 53 | errcode = MPI_Recv(list_mset_types,nset,MPI_INT,fromrank,rank,comm,&status); 54 | if (errcode != MPI_SUCCESS) { 55 | MPI_Error_string(errcode,errorstr,&len); 56 | sprintf(mesg,"MPI_Recv failed with error %s",errorstr); 57 | MSTK_Report(funcname,mesg,MSTK_FATAL); 58 | } 59 | 60 | 61 | list_mset_names = (char *) malloc(nset*256*sizeof(char)); 62 | errcode = MPI_Recv(list_mset_names,nset*256,MPI_CHAR,fromrank,rank,comm, 63 | &status); 64 | if (errcode != MPI_SUCCESS) { 65 | MPI_Error_string(errcode,errorstr,&len); 66 | sprintf(mesg,"MPI_Recv failed with error %s",errorstr); 67 | MSTK_Report(funcname,mesg,MSTK_FATAL); 68 | } 69 | 70 | 71 | for(i = 0; i < nset; i++) { 72 | strcpy(msetname,&list_mset_names[i*256]); 73 | if (MESH_MSetByName(mesh,msetname)) { 74 | sprintf(mesg,"Mesh set by the name %s already exists on partition %d", 75 | msetname,rank); 76 | MSTK_Report(funcname,mesg,MSTK_FATAL); 77 | } 78 | 79 | mtype = list_mset_types[i]; 80 | mset = MSet_New(mesh, msetname, mtype); 81 | } 82 | 83 | if (nset) { 84 | free(list_mset_types); 85 | free(list_mset_names); 86 | } 87 | 88 | return 1; 89 | } 90 | 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | -------------------------------------------------------------------------------- /src/par/MESH_Recv_MetaData.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "MSTK.h" 15 | #include "MSTK_private.h" 16 | 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | /* 23 | This function receives mesh from processor rank in communicator comm 24 | attrib list is received, but no attrib values. 25 | call MESH_RecvAttr() to update entity attribute values 26 | fromrank: the rank of sending processor 27 | rank: the rank of receiving processor 28 | 29 | Author(s): Duo Wang, Rao Garimella 30 | */ 31 | 32 | 33 | int MESH_Recv_MetaData(Mesh_ptr mesh, int fromrank, RepType *rtype, 34 | int *nv, int *ne, int *nf, int *nr, 35 | MSTK_Comm comm) { 36 | int mesh_info[5], count; 37 | MPI_Request request; 38 | MPI_Status status; 39 | char mesg[256], errorstr[256]; 40 | int len, errcode; 41 | 42 | int rank; 43 | MPI_Comm_rank(comm,&rank); 44 | 45 | /* mesh_info store the mesh reptype, nv, nf, nfvs */ 46 | /* receive mesh_info */ 47 | 48 | errcode = MPI_Recv(mesh_info,5,MPI_INT,fromrank,rank,comm,&status); 49 | if (errcode != MPI_SUCCESS) { 50 | MPI_Error_string(errcode,errorstr,&len); 51 | sprintf(mesg,"MPI_Recv failed with error %s",errorstr); 52 | MSTK_Report("MESH_Recv_MetaData",mesg,MSTK_FATAL); 53 | } 54 | 55 | *rtype = mesh_info[0]; 56 | MESH_SetRepType(mesh,*rtype); 57 | 58 | *nv = mesh_info[1]; 59 | *ne = mesh_info[2]; 60 | *nf = mesh_info[3]; 61 | *nr = mesh_info[4]; 62 | 63 | return 1; 64 | } 65 | 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | 71 | -------------------------------------------------------------------------------- /src/par/MESH_Recv_VertexCoords.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "MSTK.h" 15 | #include "MSTK_private.h" 16 | 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | /* 23 | This function receives mesh vertices from processor 'fromrank' 24 | 25 | Author(s): Rao Garimella 26 | */ 27 | 28 | 29 | int MESH_Recv_VertexCoords(Mesh_ptr mesh, int fromrank, int nvertices, 30 | MSTK_Comm comm) { 31 | int i; 32 | MVertex_ptr v; 33 | double coor[3]; 34 | MPI_Status status; 35 | MPI_Request vrequest[2]; 36 | char mesg[256], errorstr[256], funcname[256]="MESH_Recv_VertexCoords"; 37 | int errcode, len, nreq=0; 38 | 39 | int rank; 40 | MPI_Comm_rank(comm,&rank); 41 | 42 | /* allocate receive buffer */ 43 | double *list_coor = (double *) malloc(3*nvertices*sizeof(double)); 44 | 45 | errcode = MPI_Recv(list_coor,3*nvertices,MPI_DOUBLE,fromrank,rank,comm, 46 | &status); 47 | if (errcode != MPI_SUCCESS) 48 | MSTK_Report(funcname,"Trouble receiving mesh coordinate info",MSTK_FATAL); 49 | 50 | 51 | for(i = 0; i < nvertices; i++) { 52 | v = MESH_Vertex(mesh,i); 53 | MV_Set_Coords(v,list_coor+3*i); 54 | } 55 | 56 | free(list_coor); 57 | 58 | return 1; 59 | } 60 | 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | -------------------------------------------------------------------------------- /src/par/MESH_Recv_Vertices.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "MSTK.h" 15 | #include "MSTK_private.h" 16 | 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | /* 23 | This function receives mesh vertices from processor 'fromrank' 24 | 25 | Author(s): Rao Garimella 26 | */ 27 | 28 | 29 | int MESH_Recv_Vertices(Mesh_ptr mesh, int fromrank, int nvertices, 30 | MSTK_Comm comm) { 31 | int i; 32 | MVertex_ptr v; 33 | MPI_Status status; 34 | MPI_Request request; 35 | char mesg[256], errorstr[256], funcname[256]="MESH_Recv_Vertices"; 36 | int errcode, len, nreq=0; 37 | 38 | int rank; 39 | MPI_Comm_rank(comm,&rank); 40 | 41 | /* allocate receive buffer */ 42 | int *list_vertex = (int *) malloc(3*nvertices*sizeof(int)); 43 | 44 | /* receive vertex info */ 45 | errcode = MPI_Irecv(list_vertex,3*nvertices,MPI_INT,fromrank,rank,comm, 46 | &request); 47 | if (errcode != MPI_SUCCESS) 48 | MSTK_Report(funcname,"Trouble receiving mesh vertex info",MSTK_FATAL); 49 | 50 | 51 | /* Create the vertices while waiting for the message to complete */ 52 | 53 | for (i = 0; i < nvertices; i++) 54 | v = MV_New(mesh); 55 | 56 | 57 | errcode = MPI_Wait(&request,MPI_STATUS_IGNORE); 58 | if (errcode != MPI_SUCCESS) 59 | MSTK_Report(funcname,"Trouble receiving mesh vertex info",MSTK_FATAL); 60 | 61 | for(i = 0; i < nvertices; i++) { 62 | v = MESH_Vertex(mesh,i); 63 | int gentdim = list_vertex[3*i] & 7; /* first 3 bits; 7 is 0...00111 */ 64 | int gentid = list_vertex[3*i] >> 3; /* All but the first 3 bits */ 65 | MV_Set_GEntDim(v,gentdim); 66 | MV_Set_GEntID(v,gentid); 67 | 68 | int ptype = list_vertex[3*i+1] & 3; /* first 2 bits; 3 is 0...00011 */ 69 | int on_par_bdry = list_vertex[3*i+1] & 4; /* 3rd bit; 4 is 0...00100 */ 70 | int masterparid = list_vertex[3*i+1] >> 3; /* All but the first 3 bits */ 71 | MV_Set_PType(v,ptype); 72 | if (on_par_bdry) 73 | MV_Flag_OnParBoundary(v); 74 | MV_Set_MasterParID(v,masterparid); 75 | 76 | MV_Set_GlobalID(v,list_vertex[3*i+2]); 77 | } 78 | 79 | free(list_vertex); 80 | 81 | return 1; 82 | } 83 | 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | -------------------------------------------------------------------------------- /src/par/MESH_Send_MSet.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "MSTK.h" 15 | #include "MSTK_private.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | /* Send one mesh set to a particular processor 22 | 23 | Author: Rao Garimella 24 | */ 25 | 26 | 27 | int MESH_Send_MSet(Mesh_ptr mesh, MSet_ptr mset, int torank, 28 | MSTK_Comm comm, int *numreq, int *maxreq, 29 | MPI_Request **requests, int *numptrs2free, 30 | int *maxptrs2free, void ***ptrs2free) { 31 | int i, idx; 32 | int num, nent; 33 | int *list_info, *list_value_int; 34 | MType mtype; 35 | MEntity_ptr ment; 36 | MPI_Request mpirequest; 37 | 38 | if (requests == NULL) 39 | MSTK_Report("MSTK_SendMSet","Invalid MPI request buffer",MSTK_FATAL); 40 | 41 | if (*maxreq == 0) { 42 | *maxreq = 10; 43 | *requests = (MPI_Request *) malloc(*maxreq*sizeof(MPI_Request)); 44 | *numreq = 0; 45 | } 46 | else if (*maxreq < (*numreq) + 2) { 47 | *maxreq *= 2; 48 | *requests = (MPI_Request *) realloc(*requests,*maxreq*sizeof(MPI_Request)); 49 | } 50 | 51 | mtype = MSet_EntDim(mset); 52 | nent = MSet_Num_Entries(mset); 53 | 54 | list_info = (int *)malloc(sizeof(int)); 55 | list_info[0] = nent; 56 | 57 | MPI_Isend(list_info,1,MPI_INT,torank,torank,comm,&mpirequest); 58 | (*requests)[*numreq] = mpirequest; 59 | (*numreq)++; 60 | 61 | if (!nent) { 62 | free(list_info); 63 | return 1; 64 | } 65 | 66 | /* attribute index and global id */ 67 | num = 2*nent; 68 | list_value_int = (int *)malloc(num*sizeof(int)); 69 | 70 | idx = 0; i = 0; 71 | while ((ment = MSet_Next_Entry(mset,&idx))) { 72 | list_value_int[i++] = MEnt_Dim(ment); 73 | list_value_int[i++] = MEnt_GlobalID(ment); 74 | } 75 | 76 | 77 | /* send info */ 78 | MPI_Isend(list_value_int,num,MPI_INT,torank,torank,comm,&mpirequest); 79 | (*requests)[*numreq] = mpirequest; 80 | (*numreq)++; 81 | 82 | /* track the buffers used for sending */ 83 | 84 | if (*maxptrs2free == 0) { 85 | *maxptrs2free = 25; 86 | *ptrs2free = (void **) malloc(*maxptrs2free*sizeof(void *)); 87 | *numptrs2free = 0; 88 | } 89 | else if (*maxptrs2free < (*numptrs2free) + 2) { 90 | *maxptrs2free = 2*(*maxptrs2free) + 2 ; 91 | *ptrs2free = (void **) realloc(*ptrs2free,(*maxptrs2free)*sizeof(void *)); 92 | } 93 | 94 | (*ptrs2free)[(*numptrs2free)++] = list_info; 95 | (*ptrs2free)[(*numptrs2free)++] = list_value_int; 96 | 97 | return 1; 98 | } 99 | 100 | 101 | 102 | #ifdef __cplusplus 103 | } 104 | #endif 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /src/par/MESH_Send_VertexCoords.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "MSTK.h" 15 | #include "MSTK_private.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | 22 | 23 | /* 24 | This function send mesh to processor torank in communicator comm 25 | attr list is sent but no attribute value is sent. 26 | call MESH_SendAttr() to send attribute values of entities 27 | 28 | Author(s): Duo Wang, Rao Garimella 29 | */ 30 | 31 | 32 | 33 | int MESH_Send_VertexCoords(Mesh_ptr mesh, int torank, MSTK_Comm comm, 34 | int *numreq, int *maxreq, MPI_Request **requests, 35 | int *numptrs2free, int *maxptrs2free, 36 | void ***ptrs2free) { 37 | int i, j, nv; 38 | MVertex_ptr mv; 39 | double coor[3]; 40 | MPI_Request mpirequest; 41 | 42 | if (requests == NULL) 43 | MSTK_Report("MESH_Surf_SendMesh","MPI requests array is NULL",MSTK_FATAL); 44 | 45 | if (*maxreq == 0) { 46 | *maxreq = 25; 47 | *requests = (MPI_Request *) malloc(*maxreq*sizeof(MPI_Request)); 48 | *numreq = 0; 49 | } 50 | else if (*maxreq < (*numreq) + 11) { 51 | *maxreq = 2*(*maxreq) + 11; 52 | *requests = (MPI_Request *) realloc(*requests,*maxreq*sizeof(MPI_Request)); 53 | } 54 | 55 | 56 | /* Now send out detailed vertex info */ 57 | 58 | nv = MESH_Num_Vertices(mesh); 59 | double *list_coor = (double *) malloc(3*nv*sizeof(double)); 60 | 61 | /* Store the 3 auxilliary data fields */ 62 | for(i = 0; i < nv; i++) { 63 | mv = MESH_Vertex(mesh,i); 64 | MV_Coords(mv,list_coor+i*3); 65 | } 66 | 67 | MPI_Isend(list_coor,3*nv,MPI_DOUBLE,torank,torank,comm,&mpirequest); 68 | (*requests)[*numreq] = mpirequest; 69 | (*numreq)++;; 70 | 71 | 72 | int nptrs = 1; 73 | 74 | if (*maxptrs2free == 0) { 75 | *maxptrs2free = 25; 76 | *ptrs2free = (void **) malloc(*maxptrs2free*sizeof(void *)); 77 | *numptrs2free = 0; 78 | } 79 | else if (*maxptrs2free < (*numptrs2free) + nptrs) { 80 | *maxptrs2free = 2*(*maxptrs2free) + nptrs; 81 | *ptrs2free = (void **) realloc(*ptrs2free,(*maxptrs2free)*sizeof(void *)); 82 | } 83 | 84 | (*ptrs2free)[(*numptrs2free)++] = list_coor; 85 | 86 | return 1; 87 | } 88 | 89 | #ifdef __cplusplus 90 | } 91 | #endif 92 | 93 | -------------------------------------------------------------------------------- /src/par/MESH_Send_Vertices.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "MSTK.h" 15 | #include "MSTK_private.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | 22 | 23 | /* 24 | This function send mesh to processor torank in communicator comm 25 | attr list is sent but no attribute value is sent. 26 | call MESH_SendAttr() to send attribute values of entities 27 | 28 | Author(s): Duo Wang, Rao Garimella 29 | */ 30 | 31 | 32 | 33 | int MESH_Send_Vertices(Mesh_ptr mesh, int torank, MSTK_Comm comm, 34 | int *numreq, int *maxreq, MPI_Request **requests, 35 | int *numptrs2free, int *maxptrs2free, 36 | void ***ptrs2free) { 37 | int i, j, nv; 38 | MVertex_ptr mv; 39 | double coor[3]; 40 | MPI_Request mpirequest; 41 | 42 | if (requests == NULL) 43 | MSTK_Report("MESH_Surf_SendMesh","MPI requests array is NULL",MSTK_FATAL); 44 | 45 | if (*maxreq == 0) { 46 | *maxreq = 25; 47 | *requests = (MPI_Request *) malloc(*maxreq*sizeof(MPI_Request)); 48 | *numreq = 0; 49 | } 50 | else if (*maxreq < (*numreq) + 11) { 51 | *maxreq = 2*(*maxreq) + 11; 52 | *requests = (MPI_Request *) realloc(*requests,*maxreq*sizeof(MPI_Request)); 53 | } 54 | 55 | 56 | /* Now send out detailed vertex info */ 57 | 58 | nv = MESH_Num_Vertices(mesh); 59 | int *list_vertex = (int *) malloc(3*nv*sizeof(int)); 60 | 61 | /* Store the 3 auxilliary data fields - would be nice if we didn't 62 | * have to send the data in such an error prone way (with bit 63 | * shifting) that requires knowledge of the internal structure of 64 | * MEntity */ 65 | 66 | for(i = 0; i < nv; i++) { 67 | mv = MESH_Vertex(mesh,i); 68 | list_vertex[3*i] = (MV_GEntID(mv)<<3) | (MV_GEntDim(mv)); 69 | list_vertex[3*i+1] = (MV_MasterParID(mv) <<3) | MV_OnParBoundary(mv)<<2 | (MV_PType(mv)); 70 | list_vertex[3*i+2] = MV_GlobalID(mv); 71 | } 72 | 73 | /* send vertices */ 74 | MPI_Isend(list_vertex,3*nv,MPI_INT,torank,torank,comm,&mpirequest); 75 | (*requests)[*numreq] = mpirequest; 76 | (*numreq)++;; 77 | 78 | int nptrs = 1; 79 | 80 | if (*maxptrs2free == 0) { 81 | *maxptrs2free = 25; 82 | *ptrs2free = (void **) malloc(*maxptrs2free*sizeof(void *)); 83 | *numptrs2free = 0; 84 | } 85 | else if (*maxptrs2free < (*numptrs2free) + nptrs) { 86 | *maxptrs2free = 2*(*maxptrs2free) + nptrs; 87 | *ptrs2free = (void **) realloc(*ptrs2free,(*maxptrs2free)*sizeof(void *)); 88 | } 89 | 90 | (*ptrs2free)[(*numptrs2free)++] = list_vertex; 91 | 92 | return 1; 93 | } 94 | 95 | #ifdef __cplusplus 96 | } 97 | #endif 98 | 99 | -------------------------------------------------------------------------------- /src/par/MESH_UpdateAttributes.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "MSTK.h" 15 | #include "MSTK_private.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | /* Update attributes on partitions 22 | 23 | Authors: Duo Wang 24 | Rao Garimella 25 | */ 26 | 27 | int MESH_UpdateAttributes(Mesh_ptr mesh, MSTK_Comm comm) { 28 | int i, natt, attr_type; 29 | char attr_name[256]; 30 | MAttrib_ptr attrib; 31 | 32 | natt = MESH_Num_Attribs(mesh); 33 | for(i = 0; i < natt; i++) { 34 | attrib = MESH_Attrib(mesh,i); 35 | attr_type = MAttrib_Get_Type(attrib); 36 | if (attr_type == POINTER) continue; 37 | 38 | MAttrib_Get_Name(attrib,attr_name); 39 | MPI_Barrier(comm); 40 | MESH_Update1Attribute(mesh,attrib,comm); 41 | } 42 | 43 | return 1; 44 | } 45 | 46 | /* Keep this for backward compatibility */ 47 | 48 | int MSTK_UpdateAttr(Mesh_ptr mesh, MSTK_Comm comm) { 49 | 50 | #ifdef DEBUG 51 | MSTK_Report("MSTK_UpdateAttr","MSTK_UpdateAttr is deprecated. Use MESH_UpdateAttributes",MSTK_WARN); 52 | #endif 53 | 54 | return MESH_UpdateAttributes(mesh,comm); 55 | } 56 | 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | -------------------------------------------------------------------------------- /src/par/MSTK_Mesh_Read_Distribute.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "MSTK.h" 15 | #include "MSTK_private.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | 22 | 23 | /* Read a mesh in, partition it and distribute it to 'num' processors 24 | 25 | Authors: Duo Wang 26 | Rao Garimella 27 | */ 28 | 29 | int MSTK_Mesh_Read_Distribute(Mesh_ptr *recv_mesh, 30 | const char* global_mesh_name, 31 | int *dim, int ring, int with_attr, 32 | int method, MSTK_Comm comm) { 33 | 34 | int i, ok; 35 | 36 | int rank; 37 | MPI_Comm_rank(comm,&rank); 38 | 39 | Mesh_ptr mesh=NULL; 40 | if(rank == 0) { 41 | mesh = MESH_New(UNKNOWN_REP); 42 | ok = MESH_InitFromFile(mesh,global_mesh_name,comm); 43 | if (!ok) { 44 | fprintf(stderr,"Cannot open input file %s\n\n\n",global_mesh_name); 45 | exit(-1); 46 | } 47 | fprintf(stdout,"mstk mesh %s read in successfully\n",global_mesh_name); 48 | 49 | *dim = MESH_Num_Regions(mesh) ? 3 : 2; 50 | } 51 | 52 | int del_inmesh = 1; 53 | MSTK_Mesh_Distribute(mesh, recv_mesh, dim, ring, with_attr, method, 54 | del_inmesh, comm); 55 | 56 | return 1; 57 | } 58 | 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /src/par/MSTK_Weave_DistributedMeshes.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "MSTK.h" 15 | #include "MSTK_private.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | 22 | 23 | /* Weave a set of distributed mesh partitions together to build the 24 | parallel connections and ghost info. 25 | 26 | input_type indicates what info is already present on the mesh 27 | 28 | 0 -- we are given NO information about how these meshes are connected 29 | other than the knowledge that they come from the partitioning of 30 | a single mesh 31 | 32 | 1 -- we are given partitioned meshes with a unique global ID on 33 | each mesh vertex 34 | 35 | 2 -- we are given parallel neighbor information, but no global ID on 36 | each mesh vertex 37 | 38 | 39 | */ 40 | 41 | 42 | 43 | int MSTK_Weave_DistributedMeshes(Mesh_ptr mesh, int topodim, 44 | int num_ghost_layers, int input_type, 45 | MSTK_Comm comm) { 46 | 47 | int have_GIDs = 0; 48 | int rank, num; 49 | 50 | MPI_Comm_rank(comm,&rank); 51 | MPI_Comm_size(comm,&num); 52 | 53 | if (num_ghost_layers > 1) 54 | MSTK_Report("MSTK_Weave_DistributedMeshes", "Only 1 ghost layer supported currently", MSTK_FATAL); 55 | 56 | if (input_type > 2) 57 | MSTK_Report("MSTK_Weave_DistributedMeshes","Unrecognized input type for meshes", MSTK_WARN); 58 | 59 | // This partition does not have a mesh or has an empty mesh which is ok 60 | 61 | if (mesh == NULL) 62 | MSTK_Report("MSTK_Weave_DistributedMeshes","MESH is null on this processor",MSTK_FATAL); 63 | 64 | 65 | MESH_Set_Prtn(mesh, rank, num); 66 | 67 | if (input_type == 0) 68 | have_GIDs = 0; 69 | else if (input_type == 1) 70 | have_GIDs = 1; 71 | 72 | if (input_type == 0 || input_type == 1) { 73 | /* MESH_MatchEnts_ParBdry(mesh, have_GIDs, rank, num, comm); */ 74 | MESH_AssignGlobalIDs(mesh, topodim, have_GIDs, comm); 75 | MESH_BuildConnection(mesh, topodim, comm); 76 | } 77 | else if (input_type == 2) 78 | MESH_AssignGlobalIDs_p2p(mesh, topodim, comm); 79 | 80 | MESH_LabelPType(mesh, topodim, comm); 81 | 82 | if (num_ghost_layers) /* num_ghost_layers = 0 not well tested */ 83 | MESH_Parallel_AddGhost(mesh, topodim, comm); 84 | 85 | /* Even with no ghost layer of elements, lower dimensional ghosts 86 | * can exist */ 87 | MESH_Build_GhostLists(mesh, topodim); 88 | 89 | 90 | MESH_Update_ParallelAdj(mesh, comm); 91 | return 1; 92 | } 93 | 94 | 95 | #ifdef __cplusplus 96 | } 97 | #endif 98 | 99 | -------------------------------------------------------------------------------- /src/util/MSTK_Report.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include "MSTK_util.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | void MSTK_Report(const char *funcname, const char *message, ErrType type) { 19 | static char last_message[1024]; 20 | int len; 21 | 22 | if (strcmp(last_message,message) == 0) 23 | return; 24 | 25 | 26 | len = strlen(message); 27 | memcpy(last_message,message,len*sizeof(char)); 28 | last_message[len] = '\0'; 29 | 30 | switch (type) { 31 | case MSTK_MESG: 32 | fprintf(stdout, "\n%s: %s\n",funcname,message); 33 | break; 34 | case MSTK_WARN: 35 | fprintf(stderr, "\nWarning!! in %s: %s\n",funcname,message); 36 | break; 37 | case MSTK_ERROR: 38 | fprintf(stderr, "\nERROR!! in %s: %s\n",funcname,message); 39 | break; 40 | case MSTK_FATAL: 41 | fprintf(stderr, "\nFATAL ERROR!! in %s: %s\n",funcname,message); 42 | exit(-1); 43 | } 44 | } 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | -------------------------------------------------------------------------------- /src/util/MSTK_Version.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include "MSTK.h" 14 | #include "MSTK_util.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | void MSTK_Version(int *major_version, int *minor_version, int *patch_version, 21 | char **version_string) { 22 | *major_version = MSTK_VERSION_MAJOR; 23 | *minor_version = MSTK_VERSION_MINOR; 24 | *patch_version = MSTK_VERSION_PATCH; 25 | sprintf(*version_string,"%d.%d.%d",*major_version, *minor_version, *patch_version); 26 | } 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | -------------------------------------------------------------------------------- /unittests/parallel/4proc/Main.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | int main(int argc, char *argv[]) 15 | { 16 | int status; 17 | 18 | MPI_Init(&argc, &argv); 19 | 20 | status = UnitTest::RunAllTests (); 21 | 22 | MPI_Finalize(); 23 | 24 | return status; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /unittests/parallel/4proc/Test_partition2D_ExodusII.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | 11 | #include "MSTK.h" 12 | 13 | SUITE(Parallel) { 14 | 15 | TEST(Partition2D_1ring_exo) { 16 | 17 | int opts[10], status, nproc, rank; 18 | Mesh_ptr mesh; 19 | 20 | MSTK_Init(); 21 | MSTK_Comm comm = MPI_COMM_WORLD; 22 | 23 | MPI_Comm_size(comm,&nproc); 24 | MPI_Comm_rank(comm,&rank); 25 | 26 | mesh = MESH_New(F1); 27 | 28 | opts[0] = 1; // Partition the input mesh 29 | opts[1] = 0; // use the default method for distributing mesh 30 | opts[2] = 1; // build 1 layer of ghosts 31 | opts[3] = 0; // use Metis as the partitioner if available 32 | 33 | status = MESH_ImportFromFile(mesh,"parallel/4proc/mesh5x5-skewed.exo",NULL,opts,comm); 34 | 35 | CHECK(status); 36 | 37 | return; 38 | } 39 | 40 | TEST(ParRead_2D_exo) { 41 | 42 | int opts[10], status, nproc, rank; 43 | Mesh_ptr mesh; 44 | 45 | MSTK_Init(); 46 | MSTK_Comm comm = MPI_COMM_WORLD; 47 | 48 | MPI_Comm_size(comm,&nproc); 49 | MPI_Comm_rank(comm,&rank); 50 | 51 | mesh = MESH_New(F1); 52 | 53 | opts[0] = 1; // Partition the input mesh 54 | opts[1] = 1; // Partition the graph and read portions of mesh 55 | opts[2] = 1; // build 1 layer of ghosts 56 | opts[3] = 0; // use metis as the partitioner if available 57 | 58 | status = MESH_ImportFromFile(mesh,"parallel/4proc/mesh5x5-skewed.exo",NULL,opts,comm); 59 | 60 | CHECK(status); 61 | 62 | return; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /unittests/parallel/4proc/mesh5x5-skewed.exo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeshToolkit/MSTK/fd1c0c477e635fac34b207e443331aed145fdd96/unittests/parallel/4proc/mesh5x5-skewed.exo -------------------------------------------------------------------------------- /unittests/parallel/4proc/mixed_pinchout.par.4.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeshToolkit/MSTK/fd1c0c477e635fac34b207e443331aed145fdd96/unittests/parallel/4proc/mixed_pinchout.par.4.0 -------------------------------------------------------------------------------- /unittests/parallel/4proc/mixed_pinchout.par.4.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeshToolkit/MSTK/fd1c0c477e635fac34b207e443331aed145fdd96/unittests/parallel/4proc/mixed_pinchout.par.4.1 -------------------------------------------------------------------------------- /unittests/parallel/4proc/mixed_pinchout.par.4.2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeshToolkit/MSTK/fd1c0c477e635fac34b207e443331aed145fdd96/unittests/parallel/4proc/mixed_pinchout.par.4.2 -------------------------------------------------------------------------------- /unittests/parallel/4proc/mixed_pinchout.par.4.3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeshToolkit/MSTK/fd1c0c477e635fac34b207e443331aed145fdd96/unittests/parallel/4proc/mixed_pinchout.par.4.3 -------------------------------------------------------------------------------- /unittests/parallel/4proc/quad3x2.mstk.0: -------------------------------------------------------------------------------- 1 | MSTK 1.0 2 | F1 6 7 2 0 3 | vertices 4 | 0.0000000000000000 0.0000000000000000 0.0000000000000000 0 1 5 | 1.0000000000000000 0.0000000000000000 0.0000000000000000 1 1 6 | 2.0000000000000000 0.0000000000000000 0.0000000000000000 1 1 7 | 0.0000000000000000 1.0000000000000000 0.0000000000000000 1 4 8 | 1.0000000000000000 1.0000000000000000 0.0000000000000000 2 1 9 | 2.0000000000000000 1.0000000000000000 0.0000000000000000 2 1 10 | edges 11 | 1 2 1 1 12 | 2 5 2 1 13 | 5 4 2 1 14 | 4 1 1 4 15 | 2 3 1 1 16 | 3 6 2 1 17 | 6 5 2 1 18 | faces edge 19 | 4 1 2 3 4 2 1 20 | 4 5 6 7 -2 2 1 21 | -------------------------------------------------------------------------------- /unittests/parallel/4proc/quad3x2.mstk.1: -------------------------------------------------------------------------------- 1 | MSTK 1.0 2 | F1 4 4 1 0 3 | vertices 4 | 2.0000000000000000 0.0000000000000000 0.0000000000000000 1 1 5 | 3.0000000000000000 0.0000000000000000 0.0000000000000000 0 2 6 | 2.0000000000000000 1.0000000000000000 0.0000000000000000 2 1 7 | 3.0000000000000000 1.0000000000000000 0.0000000000000000 1 2 8 | edges 9 | 1 2 1 1 10 | 2 4 1 2 11 | 4 3 2 1 12 | 3 1 2 1 13 | faces edge 14 | 4 1 2 3 4 2 1 15 | -------------------------------------------------------------------------------- /unittests/parallel/4proc/quad3x2.mstk.2: -------------------------------------------------------------------------------- 1 | MSTK 1.0 2 | F1 6 7 2 0 3 | vertices 4 | 0.0000000000000000 1.0000000000000000 0.0000000000000000 1 4 5 | 1.0000000000000000 1.0000000000000000 0.0000000000000000 2 1 6 | 2.0000000000000000 1.0000000000000000 0.0000000000000000 2 1 7 | 0.0000000000000000 2.0000000000000000 0.0000000000000000 0 4 8 | 1.0000000000000000 2.0000000000000000 0.0000000000000000 1 3 9 | 2.0000000000000000 2.0000000000000000 0.0000000000000000 1 3 10 | edges 11 | 1 2 2 1 12 | 2 5 2 1 13 | 5 4 1 3 14 | 4 1 1 4 15 | 2 3 2 1 16 | 3 6 2 1 17 | 6 5 1 3 18 | faces edge 19 | 4 1 2 3 4 2 1 20 | 4 5 6 7 -2 2 1 21 | -------------------------------------------------------------------------------- /unittests/parallel/4proc/quad3x2.mstk.3: -------------------------------------------------------------------------------- 1 | MSTK 1.0 2 | F1 4 4 1 0 3 | vertices 4 | 2.0000000000000000 1.0000000000000000 0.0000000000000000 2 1 5 | 3.0000000000000000 1.0000000000000000 0.0000000000000000 1 2 6 | 2.0000000000000000 2.0000000000000000 0.0000000000000000 1 3 7 | 3.0000000000000000 2.0000000000000000 0.0000000000000000 0 3 8 | edges 9 | 1 2 2 1 10 | 2 4 1 2 11 | 4 3 1 3 12 | 3 1 2 1 13 | faces edge 14 | 4 1 2 3 4 2 1 15 | -------------------------------------------------------------------------------- /unittests/parallel/4proc/quad4x3.mstk.4.0: -------------------------------------------------------------------------------- 1 | MSTK 1.0 2 | F1 8 10 3 0 3 | vertices 4 | 0.2500000000000000 0.6666666666666666 0.0000000000000000 1 1 5 | 0.0000000000000000 0.6666666666666666 0.0000000000000000 1 1 6 | 0.2500000000000000 1.0000000000000000 0.0000000000000000 1 1 7 | 0.0000000000000000 1.0000000000000000 0.0000000000000000 1 1 8 | 0.5000000000000000 0.3333333333333333 0.0000000000000000 1 1 9 | 0.2500000000000000 0.3333333333333333 0.0000000000000000 1 1 10 | 0.5000000000000000 0.6666666666666666 0.0000000000000000 1 1 11 | 0.5000000000000000 1.0000000000000000 0.0000000000000000 1 1 12 | edges 13 | 2 1 1 1 14 | 1 3 2 1 15 | 3 4 1 1 16 | 4 2 1 1 17 | 6 5 1 1 18 | 5 7 1 1 19 | 7 1 2 1 20 | 1 6 1 1 21 | 7 8 1 1 22 | 8 3 1 1 23 | faces edge 24 | 4 1 2 3 4 2 1 25 | 4 5 6 7 8 2 1 26 | 4 -7 9 10 -2 2 1 27 | attributes 28 | node_map 29 | INT 30 | 1 31 | MVERTEX 32 | 8 33 | 0 1 1 34 | 0 2 2 35 | 0 3 3 36 | 0 4 4 37 | 0 5 5 38 | 0 6 6 39 | 0 7 7 40 | 0 8 8 41 | elemblock 42 | INT 43 | 1 44 | MFACE 45 | 3 46 | 2 1 1 47 | 2 2 1 48 | 2 3 1 49 | elem_map 50 | INT 51 | 1 52 | MFACE 53 | 3 54 | 2 1 1 55 | 2 2 2 56 | 2 3 3 57 | -------------------------------------------------------------------------------- /unittests/parallel/4proc/quad4x3.mstk.4.1: -------------------------------------------------------------------------------- 1 | MSTK 1.0 2 | F1 8 10 3 0 3 | vertices 4 | 0.0000000000000000 0.0000000000000000 0.0000000000000000 1 1 5 | 0.2500000000000000 0.0000000000000000 0.0000000000000000 1 1 6 | 0.2500000000000000 0.3333333333333333 0.0000000000000000 1 1 7 | 0.0000000000000000 0.3333333333333333 0.0000000000000000 1 1 8 | 0.2500000000000000 0.6666666666666666 0.0000000000000000 1 1 9 | 0.0000000000000000 0.6666666666666666 0.0000000000000000 1 1 10 | 0.5000000000000000 0.0000000000000000 0.0000000000000000 1 1 11 | 0.5000000000000000 0.3333333333333333 0.0000000000000000 1 1 12 | edges 13 | 1 2 1 1 14 | 2 3 2 1 15 | 3 4 2 1 16 | 4 1 1 1 17 | 3 5 1 1 18 | 5 6 1 1 19 | 6 4 1 1 20 | 2 7 1 1 21 | 7 8 1 1 22 | 8 3 1 1 23 | faces edge 24 | 4 1 2 3 4 2 1 25 | 4 -3 5 6 7 2 1 26 | 4 8 9 10 -2 2 1 27 | attributes 28 | node_map 29 | INT 30 | 1 31 | MVERTEX 32 | 8 33 | 0 1 9 34 | 0 2 10 35 | 0 3 6 36 | 0 4 11 37 | 0 5 1 38 | 0 6 2 39 | 0 7 12 40 | 0 8 5 41 | elemblock 42 | INT 43 | 1 44 | MFACE 45 | 3 46 | 2 1 1 47 | 2 2 1 48 | 2 3 1 49 | elem_map 50 | INT 51 | 1 52 | MFACE 53 | 3 54 | 2 1 4 55 | 2 2 5 56 | 2 3 6 57 | -------------------------------------------------------------------------------- /unittests/parallel/4proc/quad4x3.mstk.4.2: -------------------------------------------------------------------------------- 1 | MSTK 1.0 2 | F1 8 10 3 0 3 | vertices 4 | 0.7500000000000000 0.0000000000000000 0.0000000000000000 1 1 5 | 1.0000000000000000 0.0000000000000000 0.0000000000000000 1 1 6 | 1.0000000000000000 0.3333333333333333 0.0000000000000000 1 1 7 | 0.7500000000000000 0.3333333333333333 0.0000000000000000 1 1 8 | 1.0000000000000000 0.6666666666666666 0.0000000000000000 1 1 9 | 0.7500000000000000 0.6666666666666666 0.0000000000000000 1 1 10 | 1.0000000000000000 1.0000000000000000 0.0000000000000000 1 1 11 | 0.7500000000000000 1.0000000000000000 0.0000000000000000 1 1 12 | edges 13 | 1 2 1 1 14 | 2 3 1 1 15 | 3 4 2 1 16 | 4 1 1 1 17 | 3 5 1 1 18 | 5 6 2 1 19 | 6 4 1 1 20 | 5 7 1 1 21 | 7 8 1 1 22 | 8 6 1 1 23 | faces edge 24 | 4 1 2 3 4 2 1 25 | 4 -3 5 6 7 2 1 26 | 4 -6 8 9 10 2 1 27 | attributes 28 | node_map 29 | INT 30 | 1 31 | MVERTEX 32 | 8 33 | 0 1 13 34 | 0 2 14 35 | 0 3 15 36 | 0 4 16 37 | 0 5 17 38 | 0 6 18 39 | 0 7 19 40 | 0 8 20 41 | elemblock 42 | INT 43 | 1 44 | MFACE 45 | 3 46 | 2 1 1 47 | 2 2 1 48 | 2 3 1 49 | elem_map 50 | INT 51 | 1 52 | MFACE 53 | 3 54 | 2 1 7 55 | 2 2 8 56 | 2 3 9 57 | -------------------------------------------------------------------------------- /unittests/parallel/4proc/quad4x3.mstk.4.3: -------------------------------------------------------------------------------- 1 | MSTK 1.0 2 | F1 8 10 3 0 3 | vertices 4 | 0.5000000000000000 0.0000000000000000 0.0000000000000000 1 1 5 | 0.7500000000000000 0.0000000000000000 0.0000000000000000 1 1 6 | 0.7500000000000000 0.3333333333333333 0.0000000000000000 1 1 7 | 0.5000000000000000 0.3333333333333333 0.0000000000000000 1 1 8 | 0.7500000000000000 0.6666666666666666 0.0000000000000000 1 1 9 | 0.5000000000000000 0.6666666666666666 0.0000000000000000 1 1 10 | 0.7500000000000000 1.0000000000000000 0.0000000000000000 1 1 11 | 0.5000000000000000 1.0000000000000000 0.0000000000000000 1 1 12 | edges 13 | 1 2 1 1 14 | 2 3 1 1 15 | 3 4 2 1 16 | 4 1 1 1 17 | 3 5 1 1 18 | 5 6 2 1 19 | 6 4 1 1 20 | 5 7 1 1 21 | 7 8 1 1 22 | 8 6 1 1 23 | faces edge 24 | 4 1 2 3 4 2 1 25 | 4 -3 5 6 7 2 1 26 | 4 -6 8 9 10 2 1 27 | attributes 28 | node_map 29 | INT 30 | 1 31 | MVERTEX 32 | 8 33 | 0 1 12 34 | 0 2 13 35 | 0 3 16 36 | 0 4 5 37 | 0 5 18 38 | 0 6 7 39 | 0 7 20 40 | 0 8 8 41 | elemblock 42 | INT 43 | 1 44 | MFACE 45 | 3 46 | 2 1 1 47 | 2 2 1 48 | 2 3 1 49 | elem_map 50 | INT 51 | 1 52 | MFACE 53 | 3 54 | 2 1 10 55 | 2 2 11 56 | 2 3 12 57 | -------------------------------------------------------------------------------- /unittests/parallel/8proc/Main.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | int main(int argc, char *argv[]) 15 | { 16 | int status; 17 | 18 | MPI_Init(&argc, &argv); 19 | 20 | status = UnitTest::RunAllTests (); 21 | 22 | MPI_Finalize(); 23 | 24 | return status; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /unittests/parallel/8proc/Test_partition3D_ExodusII.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | 11 | #include "MSTK.h" 12 | 13 | SUITE(Parallel) { 14 | 15 | TEST(Partition3D_sym_1ring_exo) { 16 | 17 | int opts[10], status, nproc, rank; 18 | Mesh_ptr mesh; 19 | 20 | MSTK_Init(); 21 | MSTK_Comm comm = MPI_COMM_WORLD; 22 | 23 | MPI_Comm_size(comm,&nproc); 24 | MPI_Comm_rank(comm,&rank); 25 | 26 | mesh = MESH_New(F1); 27 | 28 | opts[0] = 1; // Partition the input mesh 29 | opts[1] = 0; // use the default method for distributing mesh 30 | opts[2] = 1; // build 1 layer of ghosts 31 | opts[3] = 0; // use Metis as the partitioner if available 32 | 33 | status = MESH_ImportFromFile(mesh,"parallel/8proc/hex_3x3x3_ss.exo",NULL,opts,comm); 34 | 35 | CHECK(status); 36 | 37 | return; 38 | } 39 | 40 | TEST(ParRead_3D_exo) { 41 | 42 | int opts[10], status, nproc, rank; 43 | Mesh_ptr mesh1, mesh2; 44 | 45 | MSTK_Init(); 46 | MSTK_Comm comm = MPI_COMM_WORLD; 47 | 48 | MPI_Comm_size(comm,&nproc); 49 | MPI_Comm_rank(comm,&rank); 50 | 51 | mesh1 = MESH_New(F1); 52 | 53 | opts[0] = 1; // Partition the input mesh 54 | opts[2] = 1; // build 1 layer of ghosts 55 | opts[3] = 0; // use metis as the partitioner if available 56 | 57 | opts[1] = 0; // Read on processor 0, partition and distribute 58 | 59 | status = MESH_ImportFromFile(mesh1,"parallel/8proc/hex_3x3x3_ss.exo",NULL, 60 | opts,comm); 61 | 62 | CHECK(status); 63 | 64 | mesh2 = MESH_New(F1); 65 | 66 | opts[1] = 1; // Partition the graph and read portions of mesh 67 | 68 | status = MESH_ImportFromFile(mesh2,"parallel/8proc/hex_3x3x3_ss.exo",NULL, 69 | opts,comm); 70 | 71 | CHECK(status); 72 | 73 | 74 | // Since we are partitioning the same graph either from a full mesh 75 | // or from sparse elemental information read from the file, we 76 | // should get the same counts (we cannot guarantee the numbering though) 77 | 78 | CHECK(MESH_Num_Vertices(mesh1) == MESH_Num_Vertices(mesh2)); 79 | CHECK(MESH_Num_Edges(mesh1) == MESH_Num_Edges(mesh2)); 80 | CHECK(MESH_Num_Faces(mesh1) == MESH_Num_Faces(mesh2)); 81 | CHECK(MESH_Num_Regions(mesh1) == MESH_Num_Regions(mesh2)); 82 | 83 | CHECK(MESH_Num_GhostVertices(mesh1) == MESH_Num_GhostVertices(mesh2)); 84 | CHECK(MESH_Num_GhostEdges(mesh1) == MESH_Num_GhostEdges(mesh2)); 85 | CHECK(MESH_Num_GhostFaces(mesh1) == MESH_Num_GhostFaces(mesh2)); 86 | CHECK(MESH_Num_GhostRegions(mesh1) == MESH_Num_GhostRegions(mesh2)); 87 | 88 | CHECK(MESH_Num_OverlapVertices(mesh1) == MESH_Num_OverlapVertices(mesh2)); 89 | CHECK(MESH_Num_OverlapEdges(mesh1) == MESH_Num_OverlapEdges(mesh2)); 90 | CHECK(MESH_Num_OverlapFaces(mesh1) == MESH_Num_OverlapFaces(mesh2)); 91 | CHECK(MESH_Num_OverlapRegions(mesh1) == MESH_Num_OverlapRegions(mesh2)); 92 | 93 | return; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /unittests/parallel/8proc/hex3x2x2.mstk.0: -------------------------------------------------------------------------------- 1 | MSTK 1.0 2 | F1 12 20 11 2 3 | vertices 4 | 0.0000000000000000 0.0000000000000000 0.0000000000000000 0 1 5 | 1.0000000000000000 0.0000000000000000 0.0000000000000000 1 1 6 | 2.0000000000000000 0.0000000000000000 0.0000000000000000 1 1 7 | 0.0000000000000000 1.0000000000000000 0.0000000000000000 1 4 8 | 1.0000000000000000 1.0000000000000000 0.0000000000000000 2 1 9 | 2.0000000000000000 1.0000000000000000 0.0000000000000000 2 1 10 | 0.0000000000000000 0.0000000000000000 1.0000000000000000 1 9 11 | 1.0000000000000000 0.0000000000000000 1.0000000000000000 2 3 12 | 2.0000000000000000 0.0000000000000000 1.0000000000000000 2 3 13 | 0.0000000000000000 1.0000000000000000 1.0000000000000000 2 6 14 | 1.0000000000000000 1.0000000000000000 1.0000000000000000 3 1 15 | 2.0000000000000000 1.0000000000000000 1.0000000000000000 3 1 16 | edges 17 | 1 7 1 9 18 | 4 10 2 6 19 | 2 8 2 3 20 | 5 11 3 1 21 | 3 9 2 3 22 | 6 12 3 1 23 | 1 4 1 4 24 | 7 10 2 6 25 | 2 5 2 1 26 | 8 11 3 1 27 | 3 6 2 1 28 | 9 12 3 1 29 | 1 2 1 1 30 | 2 3 1 1 31 | 7 8 2 3 32 | 8 9 2 3 33 | 4 5 2 1 34 | 5 6 2 1 35 | 10 11 3 1 36 | 11 12 3 1 37 | faces edge 38 | 4 7 2 -8 -1 2 6 39 | 4 9 4 -10 -3 3 1 40 | 4 11 6 -12 -5 3 1 41 | 4 13 3 -15 -1 2 3 42 | 4 14 5 -16 -3 2 3 43 | 4 17 4 -19 -2 3 1 44 | 4 18 6 -20 -4 3 1 45 | 4 13 9 -17 -7 2 1 46 | 4 14 11 -18 -9 2 1 47 | 4 15 10 -19 -8 3 1 48 | 4 16 12 -20 -10 3 1 49 | regions face 50 | 6 -8 10 4 2 -6 -1 3 1 51 | 6 -9 11 5 3 -7 -2 3 1 52 | -------------------------------------------------------------------------------- /unittests/parallel/8proc/hex3x2x2.mstk.1: -------------------------------------------------------------------------------- 1 | MSTK 1.0 2 | F1 8 12 6 1 3 | vertices 4 | 2.0000000000000000 0.0000000000000000 0.0000000000000000 1 1 5 | 3.0000000000000000 0.0000000000000000 0.0000000000000000 0 2 6 | 2.0000000000000000 1.0000000000000000 0.0000000000000000 2 1 7 | 3.0000000000000000 1.0000000000000000 0.0000000000000000 1 2 8 | 2.0000000000000000 0.0000000000000000 1.0000000000000000 2 3 9 | 3.0000000000000000 0.0000000000000000 1.0000000000000000 1 10 10 | 2.0000000000000000 1.0000000000000000 1.0000000000000000 3 1 11 | 3.0000000000000000 1.0000000000000000 1.0000000000000000 2 4 12 | edges 13 | 1 5 2 3 14 | 3 7 3 1 15 | 2 6 1 10 16 | 4 8 2 4 17 | 1 3 2 1 18 | 5 7 3 1 19 | 2 4 1 2 20 | 6 8 2 4 21 | 1 2 1 1 22 | 5 6 2 3 23 | 3 4 2 1 24 | 7 8 3 1 25 | faces edge 26 | 4 5 2 -6 -1 3 1 27 | 4 7 4 -8 -3 2 4 28 | 4 9 3 -10 -1 2 3 29 | 4 11 4 -12 -2 3 1 30 | 4 9 7 -11 -5 2 1 31 | 4 10 8 -12 -6 3 1 32 | regions face 33 | 6 -5 6 3 2 -4 -1 3 1 34 | -------------------------------------------------------------------------------- /unittests/parallel/8proc/hex3x2x2.mstk.2: -------------------------------------------------------------------------------- 1 | MSTK 1.0 2 | F1 12 20 11 2 3 | vertices 4 | 0.0000000000000000 1.0000000000000000 0.0000000000000000 1 4 5 | 1.0000000000000000 1.0000000000000000 0.0000000000000000 2 1 6 | 2.0000000000000000 1.0000000000000000 0.0000000000000000 2 1 7 | 0.0000000000000000 2.0000000000000000 0.0000000000000000 0 3 8 | 1.0000000000000000 2.0000000000000000 0.0000000000000000 1 3 9 | 2.0000000000000000 2.0000000000000000 0.0000000000000000 1 3 10 | 0.0000000000000000 1.0000000000000000 1.0000000000000000 2 6 11 | 1.0000000000000000 1.0000000000000000 1.0000000000000000 3 1 12 | 2.0000000000000000 1.0000000000000000 1.0000000000000000 3 1 13 | 0.0000000000000000 2.0000000000000000 1.0000000000000000 1 12 14 | 1.0000000000000000 2.0000000000000000 1.0000000000000000 2 5 15 | 2.0000000000000000 2.0000000000000000 1.0000000000000000 2 5 16 | edges 17 | 1 7 2 6 18 | 4 10 1 12 19 | 2 8 3 1 20 | 5 11 2 5 21 | 3 9 3 1 22 | 6 12 2 5 23 | 1 4 1 4 24 | 7 10 2 6 25 | 2 5 2 1 26 | 8 11 3 1 27 | 3 6 2 6 28 | 9 12 3 1 29 | 1 2 2 1 30 | 2 3 2 1 31 | 7 8 3 1 32 | 8 9 3 1 33 | 4 5 1 3 34 | 5 6 1 3 35 | 10 11 2 5 36 | 11 12 2 5 37 | faces edge 38 | 4 7 2 -8 -1 2 6 39 | 4 9 4 -10 -3 3 1 40 | 4 11 6 -12 -5 3 1 41 | 4 13 3 -15 -1 3 1 42 | 4 14 5 -16 -3 3 1 43 | 4 17 4 -19 -2 2 5 44 | 4 18 6 -20 -4 2 5 45 | 4 13 9 -17 -7 2 1 46 | 4 14 11 -18 -9 2 1 47 | 4 15 10 -19 -8 3 1 48 | 4 16 12 -20 -10 3 1 49 | regions face 50 | 6 -8 10 4 2 -6 -1 3 1 51 | 6 -9 11 5 3 -7 -2 3 1 52 | -------------------------------------------------------------------------------- /unittests/parallel/8proc/hex3x2x2.mstk.3: -------------------------------------------------------------------------------- 1 | MSTK 1.0 2 | F1 8 12 6 1 3 | vertices 4 | 2.0000000000000000 1.0000000000000000 0.0000000000000000 2 1 5 | 3.0000000000000000 1.0000000000000000 0.0000000000000000 1 2 6 | 2.0000000000000000 2.0000000000000000 0.0000000000000000 1 3 7 | 3.0000000000000000 2.0000000000000000 0.0000000000000000 0 4 8 | 2.0000000000000000 1.0000000000000000 1.0000000000000000 3 1 9 | 3.0000000000000000 1.0000000000000000 1.0000000000000000 2 4 10 | 2.0000000000000000 2.0000000000000000 1.0000000000000000 2 5 11 | 3.0000000000000000 2.0000000000000000 1.0000000000000000 1 11 12 | edges 13 | 1 5 3 1 14 | 3 7 2 5 15 | 2 6 2 5 16 | 4 8 1 11 17 | 1 3 2 1 18 | 5 7 3 1 19 | 2 4 1 2 20 | 6 8 2 4 21 | 1 2 2 1 22 | 5 6 3 1 23 | 3 4 1 3 24 | 7 8 2 5 25 | faces edge 26 | 4 5 2 -6 -1 3 1 27 | 4 7 4 -8 -3 2 4 28 | 4 9 3 -10 -1 3 1 29 | 4 11 4 -12 -2 2 5 30 | 4 9 7 -11 -5 2 1 31 | 4 10 8 -12 -6 3 1 32 | regions face 33 | 6 -5 6 3 2 -4 -1 3 1 34 | -------------------------------------------------------------------------------- /unittests/parallel/8proc/hex3x2x2.mstk.4: -------------------------------------------------------------------------------- 1 | MSTK 1.0 2 | F1 12 20 11 2 3 | vertices 4 | 0.0000000000000000 1.0000000000000000 1.0000000000000000 2 6 5 | 1.0000000000000000 1.0000000000000000 1.0000000000000000 3 1 6 | 2.0000000000000000 1.0000000000000000 1.0000000000000000 3 1 7 | 0.0000000000000000 2.0000000000000000 1.0000000000000000 1 12 8 | 1.0000000000000000 2.0000000000000000 1.0000000000000000 2 5 9 | 2.0000000000000000 2.0000000000000000 1.0000000000000000 2 5 10 | 0.0000000000000000 1.0000000000000000 2.0000000000000000 1 8 11 | 1.0000000000000000 1.0000000000000000 2.0000000000000000 2 2 12 | 2.0000000000000000 1.0000000000000000 2.0000000000000000 2 2 13 | 0.0000000000000000 2.0000000000000000 2.0000000000000000 0 7 14 | 1.0000000000000000 2.0000000000000000 2.0000000000000000 1 7 15 | 2.0000000000000000 2.0000000000000000 2.0000000000000000 1 7 16 | edges 17 | 1 7 2 6 18 | 4 10 1 12 19 | 2 8 3 1 20 | 5 11 2 5 21 | 3 9 3 1 22 | 6 12 2 5 23 | 1 4 2 6 24 | 7 10 1 8 25 | 2 5 3 1 26 | 8 11 2 2 27 | 3 6 3 1 28 | 9 12 2 2 29 | 1 2 3 1 30 | 2 3 3 1 31 | 7 8 2 2 32 | 8 9 2 2 33 | 4 5 2 5 34 | 5 6 2 5 35 | 10 11 1 7 36 | 11 12 1 7 37 | faces edge 38 | 4 7 2 -8 -1 2 6 39 | 4 9 4 -10 -3 3 1 40 | 4 11 6 -12 -5 3 1 41 | 4 13 3 -15 -1 3 1 42 | 4 14 5 -16 -3 3 1 43 | 4 17 4 -19 -2 2 5 44 | 4 18 6 -20 -4 2 5 45 | 4 13 9 -17 -7 3 1 46 | 4 14 11 -18 -9 3 1 47 | 4 15 10 -19 -8 2 2 48 | 4 16 12 -20 -10 2 2 49 | regions face 50 | 6 -8 10 4 2 -6 -1 3 1 51 | 6 -9 11 5 3 -7 -2 3 1 52 | -------------------------------------------------------------------------------- /unittests/parallel/8proc/hex3x2x2.mstk.5: -------------------------------------------------------------------------------- 1 | MSTK 1.0 2 | F1 8 12 6 1 3 | vertices 4 | 2.0000000000000000 0.0000000000000000 1.0000000000000000 2 3 5 | 3.0000000000000000 0.0000000000000000 1.0000000000000000 1 10 6 | 2.0000000000000000 1.0000000000000000 1.0000000000000000 3 1 7 | 3.0000000000000000 1.0000000000000000 1.0000000000000000 2 4 8 | 2.0000000000000000 0.0000000000000000 2.0000000000000000 1 5 9 | 3.0000000000000000 0.0000000000000000 2.0000000000000000 0 8 10 | 2.0000000000000000 1.0000000000000000 2.0000000000000000 2 2 11 | 3.0000000000000000 1.0000000000000000 2.0000000000000000 1 6 12 | edges 13 | 1 5 2 3 14 | 3 7 3 1 15 | 2 6 1 10 16 | 4 8 2 4 17 | 1 3 3 1 18 | 5 7 2 2 19 | 2 4 2 4 20 | 6 8 1 6 21 | 1 2 2 3 22 | 5 6 1 5 23 | 3 4 3 1 24 | 7 8 2 2 25 | faces edge 26 | 4 5 2 -6 -1 3 1 27 | 4 7 4 -8 -3 2 4 28 | 4 9 3 -10 -1 2 3 29 | 4 11 4 -12 -2 3 1 30 | 4 9 7 -11 -5 3 1 31 | 4 10 8 -12 -6 2 2 32 | regions face 33 | 6 -5 6 3 2 -4 -1 3 1 34 | -------------------------------------------------------------------------------- /unittests/parallel/8proc/hex3x2x2.mstk.6: -------------------------------------------------------------------------------- 1 | MSTK 1.0 2 | F1 12 20 11 2 3 | vertices 4 | 0.0000000000000000 0.0000000000000000 1.0000000000000000 1 9 5 | 1.0000000000000000 0.0000000000000000 1.0000000000000000 2 3 6 | 2.0000000000000000 0.0000000000000000 1.0000000000000000 2 3 7 | 0.0000000000000000 1.0000000000000000 1.0000000000000000 2 6 8 | 1.0000000000000000 1.0000000000000000 1.0000000000000000 3 1 9 | 2.0000000000000000 1.0000000000000000 1.0000000000000000 3 1 10 | 0.0000000000000000 0.0000000000000000 2.0000000000000000 0 5 11 | 1.0000000000000000 0.0000000000000000 2.0000000000000000 1 5 12 | 2.0000000000000000 0.0000000000000000 2.0000000000000000 1 5 13 | 0.0000000000000000 1.0000000000000000 2.0000000000000000 1 8 14 | 1.0000000000000000 1.0000000000000000 2.0000000000000000 2 2 15 | 2.0000000000000000 1.0000000000000000 2.0000000000000000 2 2 16 | edges 17 | 1 7 1 9 18 | 4 10 2 6 19 | 2 8 2 3 20 | 5 11 3 1 21 | 3 9 2 3 22 | 6 12 3 1 23 | 1 4 2 6 24 | 7 10 1 8 25 | 2 5 3 1 26 | 8 11 2 2 27 | 3 6 3 1 28 | 9 12 2 2 29 | 1 2 3 1 30 | 2 3 3 1 31 | 7 8 1 5 32 | 8 9 1 5 33 | 4 5 3 1 34 | 5 6 3 1 35 | 10 11 2 2 36 | 11 12 2 2 37 | faces edge 38 | 4 7 2 -8 -1 2 6 39 | 4 9 4 -10 -3 3 1 40 | 4 11 6 -12 -5 3 1 41 | 4 13 3 -15 -1 2 3 42 | 4 14 5 -16 -3 2 3 43 | 4 17 4 -19 -2 3 1 44 | 4 18 6 -20 -4 3 1 45 | 4 13 9 -17 -7 3 1 46 | 4 14 11 -18 -9 3 1 47 | 4 15 10 -19 -8 2 2 48 | 4 16 12 -20 -10 2 2 49 | regions face 50 | 6 -8 10 4 2 -6 -1 3 1 51 | 6 -9 11 5 3 -7 -2 3 1 52 | -------------------------------------------------------------------------------- /unittests/parallel/8proc/hex3x2x2.mstk.7: -------------------------------------------------------------------------------- 1 | MSTK 1.0 2 | F1 8 12 6 1 3 | vertices 4 | 2.0000000000000000 1.0000000000000000 1.0000000000000000 3 1 5 | 3.0000000000000000 1.0000000000000000 1.0000000000000000 2 4 6 | 2.0000000000000000 2.0000000000000000 1.0000000000000000 2 5 7 | 3.0000000000000000 2.0000000000000000 1.0000000000000000 1 11 8 | 2.0000000000000000 1.0000000000000000 2.0000000000000000 2 2 9 | 3.0000000000000000 1.0000000000000000 2.0000000000000000 1 6 10 | 2.0000000000000000 2.0000000000000000 2.0000000000000000 1 7 11 | 3.0000000000000000 2.0000000000000000 2.0000000000000000 0 8 12 | edges 13 | 1 5 3 1 14 | 3 7 2 5 15 | 2 6 2 4 16 | 4 8 1 11 17 | 1 3 3 1 18 | 5 7 2 2 19 | 2 4 2 4 20 | 6 8 1 6 21 | 1 2 3 1 22 | 5 6 2 2 23 | 3 4 2 5 24 | 7 8 1 7 25 | faces edge 26 | 4 5 2 -6 -1 3 1 27 | 4 7 4 -8 -3 2 4 28 | 4 9 3 -10 -1 3 1 29 | 4 11 4 -12 -2 2 5 30 | 4 9 7 -11 -5 3 1 31 | 4 10 8 -12 -6 2 2 32 | regions face 33 | 6 -5 6 3 2 -4 -1 3 1 34 | -------------------------------------------------------------------------------- /unittests/parallel/8proc/hex_3x3x3_ss.exo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeshToolkit/MSTK/fd1c0c477e635fac34b207e443331aed145fdd96/unittests/parallel/8proc/hex_3x3x3_ss.exo -------------------------------------------------------------------------------- /unittests/serial/Main.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | #ifdef MSTK_HAVE_MPI 13 | #include 14 | #endif 15 | 16 | int main(int argc, char *argv[]) 17 | { 18 | 19 | return UnitTest::RunAllTests (); 20 | 21 | } 22 | 23 | -------------------------------------------------------------------------------- /unittests/serial/degenpoly3.exo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeshToolkit/MSTK/fd1c0c477e635fac34b207e443331aed145fdd96/unittests/serial/degenpoly3.exo -------------------------------------------------------------------------------- /unittests/serial/mesh5x5-skewed.exo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeshToolkit/MSTK/fd1c0c477e635fac34b207e443331aed145fdd96/unittests/serial/mesh5x5-skewed.exo -------------------------------------------------------------------------------- /unittests/serial/mixed_pinchout.exo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeshToolkit/MSTK/fd1c0c477e635fac34b207e443331aed145fdd96/unittests/serial/mixed_pinchout.exo -------------------------------------------------------------------------------- /unittests/serial/multiblock-poly3.exo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeshToolkit/MSTK/fd1c0c477e635fac34b207e443331aed145fdd96/unittests/serial/multiblock-poly3.exo -------------------------------------------------------------------------------- /unittests/serial/onehex.mstk: -------------------------------------------------------------------------------- 1 | MSTK 1.0 2 | F1 8 12 6 1 3 | vertices 4 | 0.0 0.0 0.0 4 -1 5 | 1.0 0.0 1.0 4 -1 6 | 1.0 1.0 1.0 4 -1 7 | 0.0 1.0 0.0 4 -1 8 | 0.0 0.0 1.0 4 -1 9 | 0.0 1.0 1.0 4 -1 10 | 1.0 1.0 0.0 4 -1 11 | 1.0 0.0 0.0 4 -1 12 | edges 13 | 1 8 4 -1 14 | 8 2 4 -1 15 | 3 6 4 -1 16 | 5 6 4 -1 17 | 5 1 4 -1 18 | 7 3 4 -1 19 | 7 4 4 -1 20 | 4 6 4 -1 21 | 7 8 4 -1 22 | 1 4 4 -1 23 | 2 3 4 -1 24 | 5 2 4 -1 25 | faces edge 26 | 4 2 -12 5 1 4 -1 27 | 4 5 10 8 -4 4 -1 28 | 4 1 -9 7 -10 4 -1 29 | 4 -6 9 2 11 4 -1 30 | 4 -8 -7 6 3 4 -1 31 | 4 3 -4 12 11 4 -1 32 | regions face 33 | 6 -5 1 -4 -2 -3 6 4 -1 -------------------------------------------------------------------------------- /unittests/serial/onepolyhed.mstk: -------------------------------------------------------------------------------- 1 | MSTK 1.0 2 | F1 9 15 8 1 3 | vertices 4 | 1.0 0.0 1.0 4 -1 5 | 1.0 1.0 1.0 4 -1 6 | 0.0 0.0 0.0 4 -1 7 | 0.0 0.0 1.0 4 -1 8 | 0.5 0.5 1.5 4 -1 9 | 1.0 0.0 0.0 4 -1 10 | 1.0 1.0 0.0 4 -1 11 | 0.0 1.0 0.0 4 -1 12 | 0.0 1.0 1.0 4 -1 13 | edges 14 | 9 2 4 -1 15 | 3 6 4 -1 16 | 4 5 4 -1 17 | 5 2 4 -1 18 | 6 1 4 -1 19 | 3 4 4 -1 20 | 3 8 4 -1 21 | 8 9 4 -1 22 | 9 5 4 -1 23 | 9 4 4 -1 24 | 1 5 4 -1 25 | 6 7 4 -1 26 | 8 7 4 -1 27 | 1 2 4 -1 28 | 7 2 4 -1 29 | faces edge 30 | 5 2 5 11 -3 -6 4 -1 31 | 4 14 -15 -12 5 4 -1 32 | 3 11 4 -14 4 -1 33 | 4 7 8 10 6 4 -1 34 | 4 12 -13 -7 2 4 -1 35 | 4 13 15 -1 -8 4 -1 36 | 3 3 -9 10 4 -1 37 | 3 1 -4 -9 4 -1 38 | regions face 39 | 8 1 -2 -3 -4 -5 -6 7 -8 4 -1 40 | 41 | -------------------------------------------------------------------------------- /unittests/serial/oneprism.mstk: -------------------------------------------------------------------------------- 1 | MSTK 1.0 2 | F1 6 9 5 1 3 | vertices 4 | 0.0 0.0 0.0 4 -1 5 | 1.0 0.0 1.0 4 -1 6 | 0.5 1.0 1.0 4 -1 7 | 0.5 1.0 0.0 4 -1 8 | 1.0 0.0 0.0 4 -1 9 | 0.0 0.0 1.0 4 -1 10 | edges 11 | 1 5 4 -1 12 | 5 2 4 -1 13 | 2 3 4 -1 14 | 3 6 4 -1 15 | 1 4 4 -1 16 | 1 6 4 -1 17 | 5 4 4 -1 18 | 2 6 4 -1 19 | 4 3 4 -1 20 | faces edge 21 | 4 1 2 8 -6 4 -1 22 | 3 8 -4 -3 4 -1 23 | 4 -7 2 3 -9 4 -1 24 | 3 -7 -1 5 4 -1 25 | 4 4 -6 5 9 4 -1 26 | regions face 27 | 5 1 -3 -2 5 4 4 -1 -------------------------------------------------------------------------------- /unittests/serial/onepyramid.mstk: -------------------------------------------------------------------------------- 1 | MSTK 1.0 2 | F1 5 8 5 1 3 | vertices 4 | 1.0 0.0 0.0 4 -1 5 | 0.5 0.5 1.0 4 -1 6 | 1.0 1.0 0.0 4 -1 7 | 0.0 1.0 0.0 4 -1 8 | 0.0 0.0 0.0 4 -1 9 | edges 10 | 3 2 4 -1 11 | 2 1 4 -1 12 | 5 1 4 -1 13 | 1 3 4 -1 14 | 5 2 4 -1 15 | 4 2 4 -1 16 | 5 4 4 -1 17 | 3 4 4 -1 18 | faces edge 19 | 3 2 -3 5 4 -1 20 | 4 3 4 8 -7 4 -1 21 | 3 1 2 4 4 -1 22 | 3 1 -6 -8 4 -1 23 | 3 -7 5 -6 4 -1 24 | regions face 25 | 5 1 -2 3 5 -4 4 -1 26 | 27 | -------------------------------------------------------------------------------- /unittests/serial/onetet.mstk: -------------------------------------------------------------------------------- 1 | MSTK 1.0 2 | F1 4 6 4 1 3 | vertices 4 | 0.5 0.5 1.0 4 -1 5 | 0.5 1.0 0.0 4 -1 6 | 1.0 0.0 0.0 4 -1 7 | 0.0 0.0 0.0 4 -1 8 | edges 9 | 2 1 4 -1 10 | 4 1 4 -1 11 | 4 3 4 -1 12 | 1 3 4 -1 13 | 4 2 4 -1 14 | 3 2 4 -1 15 | faces edge 16 | 3 -6 -3 5 4 -1 17 | 3 -4 -1 -6 4 -1 18 | 3 3 -4 -2 4 -1 19 | 3 5 1 -2 4 -1 20 | regions face 21 | 4 1 3 -2 4 4 -1 22 | 23 | 24 | -------------------------------------------------------------------------------- /unittests/serial/poly2.exo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeshToolkit/MSTK/fd1c0c477e635fac34b207e443331aed145fdd96/unittests/serial/poly2.exo -------------------------------------------------------------------------------- /unittests/serial/regquad2D.mstk: -------------------------------------------------------------------------------- 1 | MSTK 1.0 2 | F1 9 12 4 0 3 | vertices 4 | 0.0000000000000000 0.0000000000000000 0.0000000000000000 0 1 5 | 0.5000000000000000 0.0000000000000000 0.0000000000000000 1 1 6 | 1.0000000000000000 0.0000000000000000 0.0000000000000000 0 2 7 | 0.0000000000000000 0.5000000000000000 0.0000000000000000 1 4 8 | 0.5000000000000000 0.5000000000000000 0.0000000000000000 2 1 9 | 1.0000000000000000 0.5000000000000000 0.0000000000000000 1 2 10 | 0.0000000000000000 1.0000000000000000 0.0000000000000000 0 4 11 | 0.5000000000000000 1.0000000000000000 0.0000000000000000 1 3 12 | 1.0000000000000000 1.0000000000000000 0.0000000000000000 0 3 13 | edges 14 | 1 2 1 1 15 | 2 5 2 1 16 | 5 4 2 1 17 | 4 1 1 4 18 | 5 8 2 1 19 | 8 7 1 3 20 | 7 4 1 4 21 | 2 3 1 1 22 | 3 6 1 2 23 | 6 5 2 1 24 | 6 9 1 2 25 | 9 8 1 3 26 | faces edge 27 | 4 1 2 3 4 2 1 28 | 4 -3 5 6 7 2 1 29 | 4 8 9 10 -2 2 1 30 | 4 -10 11 12 -5 2 1 31 | -------------------------------------------------------------------------------- /unittests/serial/test_ME_Collapse.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | 11 | #include "MSTK.h" 12 | 13 | // Test if we can collapse degenerate edges correctly in a 3D mesh 14 | // Here we are not worrying about correct classification of entities with 15 | // respect to a model, only if the mesh topology is correct at the end 16 | 17 | TEST(ME_MultiCollapse) { 18 | Mesh_ptr mesh; 19 | 20 | MSTK_Init(); 21 | 22 | mesh = MESH_New(F1); 23 | int ok = MESH_ImportFromExodusII(mesh, "serial/mixed_pinchout.exo", NULL, 24 | NULL); 25 | CHECK_EQUAL(1, ok); 26 | 27 | CHECK_EQUAL(1, MESH_CheckTopo(mesh)); 28 | 29 | int idx = 0; 30 | MEdge_ptr me; 31 | while ((me = MESH_Next_Edge(mesh, &idx))) { 32 | if (ME_LenSqr(me) < 1.0e-12) { 33 | MVertex_ptr ev0 = ME_Vertex(me, 0); 34 | MVertex_ptr ev1 = ME_Vertex(me, 1); 35 | int gdim0 = MV_GEntDim(ev0); 36 | int gdim1 = MV_GEntDim(ev1); 37 | int gid0 = MV_GlobalID(ev0); 38 | int gid1 = MV_GlobalID(ev1); 39 | 40 | MVertex_ptr vkeep, vdel; 41 | if (gid0 < gid1) { 42 | vkeep = ev0; 43 | vdel = ev1; 44 | } else { 45 | vkeep = ev1; 46 | vdel = ev0; 47 | } 48 | 49 | int topoflag = 0; // don't worry about violation of consistency with some 50 | // some notion of a geometric model 51 | List_ptr deleted_ents = NULL, merged_entity_pairs = NULL; 52 | vkeep = ME_Collapse(me, vkeep, topoflag, &deleted_ents, 53 | &merged_entity_pairs); 54 | 55 | if (!vkeep) { 56 | vkeep = vdel; 57 | vdel = (vkeep == ev0) ? ev1 : ev0; 58 | vkeep = ME_Collapse(me, vkeep, topoflag, &deleted_ents, 59 | &merged_entity_pairs); 60 | } 61 | CHECK(vkeep != NULL); 62 | 63 | if (deleted_ents) 64 | List_Delete(deleted_ents); 65 | if (merged_entity_pairs) 66 | List_Delete(merged_entity_pairs); 67 | } 68 | } 69 | 70 | CHECK_EQUAL(1, MESH_CheckTopo(mesh)); 71 | 72 | MESH_Delete(mesh); 73 | } 74 | -------------------------------------------------------------------------------- /unittests/serial/test_MF_Rem_Edge_F1F3.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | 11 | #include "MSTK.h" 12 | 13 | // Test if we can remove a face correctly from a region (check list of 14 | // remaining faces and their directions) 15 | 16 | TEST(MF_Rem_Edge_F1F3) 17 | { 18 | int ok, i, j, nfe, nv=5; 19 | Mesh_ptr mesh; 20 | MFace_ptr mf; 21 | MVertex_ptr verts[5]; 22 | List_ptr felist; 23 | double xyz[5][3] = {{0.0,0.0,0.0}, 24 | {1.0,0.0,0.0}, 25 | {1.5,0.5,0.0}, 26 | {1.0,1.0,0.0}, 27 | {0.0,1.0,0.0}}; 28 | int evidx[5][2] = {{0,1},{2,1},{2,3},{4,3},{4,0}}; 29 | int fedirs[5] = {1,0,1,0,1}; 30 | MEdge_ptr fedges[5]; 31 | 32 | 33 | MSTK_Init(); 34 | 35 | mesh = MESH_New(F1); 36 | 37 | 38 | for (i = 0; i < nv; i++) { 39 | verts[i] = MV_New(mesh); 40 | MV_Set_Coords(verts[i],xyz[i]); 41 | } 42 | 43 | for (i = 0; i < nv; i++) { 44 | fedges[i] = ME_New(mesh); 45 | ME_Set_Vertex(fedges[i],0,verts[evidx[i][0]]); 46 | ME_Set_Vertex(fedges[i],1,verts[evidx[i][1]]); 47 | } 48 | 49 | mf = MF_New(mesh); 50 | MF_Set_Edges(mf,nv,fedges,fedirs); 51 | 52 | // Remove edges from face one by one and see if 53 | // the leftover edges have the right IDs and dirs 54 | 55 | for (i = 0; i < nv; i++) { 56 | MF_Rem_Edge(mf,fedges[i]); 57 | 58 | felist = MF_Edges(mf,1,0); 59 | nfe = List_Num_Entries(felist); 60 | 61 | CHECK_EQUAL(nv-(i+1),nfe); // Right number of edges? 62 | 63 | for (j = 0; j < nfe; j++) { 64 | CHECK_EQUAL(fedges[i+1+j],List_Entry(felist,j)); 65 | CHECK_EQUAL(fedirs[i+1+j],MF_EdgeDir_i(mf,j)); 66 | } 67 | 68 | List_Delete(felist); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /unittests/serial/test_MF_Split.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | 11 | #include "MSTK.h" 12 | 13 | // Test if we can split a face correctly in a general 3D mesh 14 | 15 | TEST(MF_Split) 16 | { 17 | int idx, i, j, n, nfv, ok; 18 | Mesh_ptr mesh; 19 | MVertex_ptr vsplit; 20 | MFace_ptr mf; 21 | MRegion_ptr fr; 22 | List_ptr fregions, vfaces; 23 | double fxyz[MAXPV2][3], cxyz[3]; 24 | 25 | MSTK_Init(); 26 | 27 | mesh = MESH_New(UNKNOWN_REP); 28 | ok = MESH_InitFromFile(mesh,"serial/reghex3D.mstk",NULL); 29 | CHECK_EQUAL(ok,1); 30 | 31 | CHECK(MESH_Num_Vertices(mesh) > 0); 32 | 33 | idx = 0; n = 0; 34 | while ((mf = MESH_Next_Face(mesh,&idx))) { 35 | if (MF_GEntDim(mf) == 3) { 36 | 37 | /* Store regions of face before it gets deleted */ 38 | fregions = MF_Regions(mf); 39 | 40 | MF_Coords(mf,&nfv,fxyz); 41 | cxyz[0] = cxyz[1] = cxyz[2] = 0.0; 42 | for (i = 0; i < nfv; i++) { 43 | for (j = 0; j < 3; j++) 44 | cxyz[j] += fxyz[i][j]; 45 | } 46 | for (j = 0; j < 3; j++) 47 | cxyz[j] /= nfv; 48 | 49 | vsplit = MF_Split(mf,cxyz); 50 | CHECK(vsplit); 51 | 52 | vfaces = MV_Faces(vsplit); 53 | CHECK_EQUAL(nfv,List_Num_Entries(vfaces)); 54 | 55 | for (i = 0; i < nfv; i++) { 56 | MFace_ptr vf = List_Entry(vfaces,i); 57 | idx = 0; 58 | while ((fr = List_Next_Entry(fregions,&idx))) 59 | CHECK(MR_UsesEntity(fr,vf,MFACE)); 60 | } 61 | List_Delete(fregions); 62 | 63 | n++; 64 | if (n > 2) 65 | break; 66 | } 67 | } 68 | 69 | MESH_Delete(mesh); 70 | } 71 | -------------------------------------------------------------------------------- /unittests/serial/test_MFs_Dihedral_Angle.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | 11 | #include "MSTK.h" 12 | 13 | TEST(MFs_DihedralAngle) { 14 | 15 | 16 | MSTK_Init(); 17 | 18 | Mesh_ptr mesh = MESH_New(UNKNOWN_REP); 19 | 20 | int ok = MESH_InitFromFile(mesh,"serial/twohex.mstk",NULL); 21 | CHECK_EQUAL(1,ok); 22 | 23 | 24 | // Get the top center edge of the mesh 25 | 26 | MVertex_ptr mv0 = MESH_VertexFromID(mesh,8); 27 | MVertex_ptr mv1 = MESH_VertexFromID(mesh,11); 28 | MEdge_ptr me = MVs_CommonEdge(mv0,mv1); 29 | CHECK(me); 30 | 31 | List_ptr efaces = ME_Faces(me); 32 | CHECK_EQUAL(3,List_Num_Entries(efaces)); 33 | 34 | MFace_ptr f0=NULL, f1=NULL; 35 | for (int i = 0; i < 3; i++) { 36 | MFace_ptr ef = List_Entry(efaces,i); 37 | if (MF_GEntDim(ef) == 3) continue; 38 | if (f0) 39 | f1 = ef; 40 | else 41 | f0 = ef; 42 | } 43 | List_Delete(efaces); 44 | 45 | // The cosine of the dihedral angle between these two faces (being 46 | // the top horizontal faces) should be -1.0 (180 degrees angle) 47 | 48 | CHECK_CLOSE(-1.0,MFs_DihedralAngle(f0,f1,me),1.e-02); 49 | CHECK_CLOSE(-1.0,MFs_DihedralAngle(f1,f0,me),1.e-02); 50 | 51 | 52 | // Now get an edge bottom left corner 53 | 54 | mv0 = MESH_VertexFromID(mesh,1); 55 | mv1 = MESH_VertexFromID(mesh,4); 56 | me = MVs_CommonEdge(mv0,mv1); 57 | CHECK(me); 58 | 59 | efaces = ME_Faces(me); 60 | CHECK_EQUAL(2,List_Num_Entries(efaces)); 61 | f0 = List_Entry(efaces,0); 62 | f1 = List_Entry(efaces,1); 63 | List_Delete(efaces); 64 | 65 | // The cosine of the dihedral angle between these two faces (being at 66 | // a corner) should be 0.0 (90 or 270 degrees angle) 67 | 68 | CHECK_CLOSE(0.0,MFs_DihedralAngle(f0,f1,me),1.0e-02); 69 | CHECK_CLOSE(0.0,MFs_DihedralAngle(f1,f0,me),1.0e-02); 70 | 71 | MESH_Delete(mesh); 72 | 73 | } 74 | -------------------------------------------------------------------------------- /unittests/serial/test_MR_Edges_Hex_FN.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | 11 | #include "MSTK.h" 12 | 13 | TEST(MR_Edges_Hex_FN) 14 | { 15 | int ok, i, ne, eids[12]; 16 | Mesh_ptr mesh; 17 | MRegion_ptr mr; 18 | List_ptr redges; 19 | 20 | int exp_ne = 12; 21 | int exp_eids[12] = {8,7,6,3, 22 | 5,1,2,12, 23 | 4,10,9,11}; 24 | 25 | MSTK_Init(); 26 | 27 | mesh = MESH_New(UNKNOWN_REP); 28 | 29 | ok = MESH_InitFromFile(mesh,"serial/onehex.mstk",NULL); 30 | CHECK_EQUAL(1,ok); 31 | 32 | CHECK_EQUAL(F1,MESH_RepType(mesh)); 33 | 34 | CHECK_EQUAL(1,MESH_Num_Regions(mesh)); 35 | 36 | CHECK_EQUAL(exp_ne,MESH_Num_Edges(mesh)); 37 | 38 | mr = MESH_Region(mesh,0); 39 | 40 | /* Check if we can retrieve edges of a hex */ 41 | 42 | redges = MR_Edges(mr); 43 | 44 | for (i = 0; i < exp_ne; i++) { 45 | MEdge_ptr e = List_Entry(redges,i); 46 | int eid = ME_ID(e); 47 | CHECK_EQUAL(exp_eids[i],eid); 48 | } 49 | 50 | List_Delete(redges); 51 | 52 | /* Check if we can directly retrieve the IDs of edges of a hex */ 53 | 54 | MR_EdgeIDs(mr,&ne,eids); 55 | 56 | CHECK_EQUAL(ne,exp_ne); 57 | CHECK_ARRAY_EQUAL(exp_eids,eids,exp_ne); 58 | } 59 | -------------------------------------------------------------------------------- /unittests/serial/test_MR_Edges_Polyhed_FN.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | 11 | #include "MSTK.h" 12 | 13 | TEST(MR_Edges_polyhed_FN) 14 | { 15 | int ok, i, ne, eids[15]; 16 | Mesh_ptr mesh; 17 | MRegion_ptr mr; 18 | List_ptr redges; 19 | 20 | int exp_ne = 15; 21 | int exp_eids[15] = {6,3,11,5,2,14,15,12,4,7,8,10,13,1,9}; 22 | 23 | MSTK_Init(); 24 | 25 | mesh = MESH_New(UNKNOWN_REP); 26 | 27 | ok = MESH_InitFromFile(mesh,"serial/onepolyhed.mstk",NULL); 28 | CHECK_EQUAL(1,ok); 29 | 30 | CHECK_EQUAL(F1,MESH_RepType(mesh)); 31 | 32 | CHECK_EQUAL(1,MESH_Num_Regions(mesh)); 33 | 34 | CHECK_EQUAL(exp_ne,MESH_Num_Edges(mesh)); 35 | 36 | mr = MESH_Region(mesh,0); 37 | 38 | /* Check if we can retrieve the edges of a polyhedron */ 39 | 40 | redges = MR_Edges(mr); 41 | 42 | for (i = 0; i < exp_ne; i++) { 43 | MEdge_ptr e = List_Entry(redges,i); 44 | int eid = ME_ID(e); 45 | CHECK_EQUAL(exp_eids[i],eid); 46 | } 47 | 48 | List_Delete(redges); 49 | 50 | /* Check if we can directly retrieve the IDs of edges of a polyhedron */ 51 | 52 | MR_EdgeIDs(mr,&ne,eids); 53 | 54 | CHECK_EQUAL(ne,exp_ne); 55 | CHECK_ARRAY_EQUAL(exp_eids,eids,exp_ne); 56 | 57 | } 58 | -------------------------------------------------------------------------------- /unittests/serial/test_MR_Edges_Prism_FN.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | 11 | #include "MSTK.h" 12 | 13 | TEST(MR_Edges_Prism_FN) 14 | { 15 | int ok, i, ne, eids[9]; 16 | Mesh_ptr mesh; 17 | MRegion_ptr mr; 18 | List_ptr redges; 19 | 20 | int exp_ne = 9; 21 | int exp_eids[9] = {8, 4, 3, 22 | 1, 5, 7, 23 | 2, 6, 9}; 24 | 25 | MSTK_Init(); 26 | 27 | mesh = MESH_New(UNKNOWN_REP); 28 | 29 | ok = MESH_InitFromFile(mesh,"serial/oneprism.mstk",NULL); 30 | CHECK_EQUAL(1,ok); 31 | 32 | CHECK_EQUAL(F1,MESH_RepType(mesh)); 33 | 34 | CHECK_EQUAL(1,MESH_Num_Regions(mesh)); 35 | 36 | CHECK_EQUAL(exp_ne,MESH_Num_Edges(mesh)); 37 | 38 | mr = MESH_Region(mesh,0); 39 | 40 | /* Check if acn retrieve edges of a prism */ 41 | 42 | redges = MR_Edges(mr); 43 | 44 | for (i = 0; i < exp_ne; i++) { 45 | MEdge_ptr e = List_Entry(redges,i); 46 | int eid = ME_ID(e); 47 | CHECK_EQUAL(exp_eids[i],eid); 48 | } 49 | 50 | List_Delete(redges); 51 | 52 | /* Check if we can directly retrieve the IDs of edges of a prism */ 53 | 54 | MR_EdgeIDs(mr,&ne,eids); 55 | 56 | CHECK_EQUAL(ne,exp_ne); 57 | CHECK_ARRAY_EQUAL(exp_eids,eids,exp_ne); 58 | 59 | } 60 | -------------------------------------------------------------------------------- /unittests/serial/test_MR_Edges_Pyramid_FN.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | 11 | #include "MSTK.h" 12 | 13 | TEST(MR_Edges_Pyramid_FN) 14 | { 15 | int ok, i, ne, eids[8]; 16 | Mesh_ptr mesh; 17 | MRegion_ptr mr; 18 | List_ptr redges; 19 | 20 | int exp_ne = 8; 21 | int exp_eids[8] = {3,4,8,7,5,2,1,6}; 22 | 23 | MSTK_Init(); 24 | 25 | mesh = MESH_New(UNKNOWN_REP); 26 | 27 | ok = MESH_InitFromFile(mesh,"serial/onepyramid.mstk",NULL); 28 | CHECK_EQUAL(1,ok); 29 | 30 | CHECK_EQUAL(F1,MESH_RepType(mesh)); 31 | 32 | CHECK_EQUAL(1,MESH_Num_Regions(mesh)); 33 | 34 | CHECK_EQUAL(exp_ne,MESH_Num_Edges(mesh)); 35 | 36 | mr = MESH_Region(mesh,0); 37 | 38 | /* Check if we can retrieve edges of a pyramid */ 39 | 40 | redges = MR_Edges(mr); 41 | 42 | for (i = 0; i < exp_ne; i++) { 43 | MEdge_ptr e = List_Entry(redges,i); 44 | int eid = ME_ID(e); 45 | CHECK_EQUAL(exp_eids[i],eid); 46 | } 47 | 48 | List_Delete(redges); 49 | 50 | /* Check if we can directly retrieve the IDs of edges of a pyramid */ 51 | 52 | MR_EdgeIDs(mr,&ne,eids); 53 | 54 | CHECK_EQUAL(ne,exp_ne); 55 | CHECK_ARRAY_EQUAL(exp_eids,eids,exp_ne); 56 | 57 | } 58 | -------------------------------------------------------------------------------- /unittests/serial/test_MR_Edges_Tet_FN.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | 11 | #include "MSTK.h" 12 | 13 | TEST(MR_Edges_Tet_FN) 14 | { 15 | int ok, i, ne, eids[6]; 16 | Mesh_ptr mesh; 17 | MRegion_ptr mr; 18 | List_ptr redges; 19 | 20 | int exp_ne = 6; 21 | int exp_eids[6] = {5,3,6,1,2,4}; 22 | 23 | MSTK_Init(); 24 | 25 | mesh = MESH_New(UNKNOWN_REP); 26 | 27 | ok = MESH_InitFromFile(mesh,"serial/onetet.mstk",NULL); 28 | CHECK_EQUAL(1,ok); 29 | 30 | CHECK_EQUAL(F1,MESH_RepType(mesh)); 31 | 32 | CHECK_EQUAL(1,MESH_Num_Regions(mesh)); 33 | 34 | CHECK_EQUAL(exp_ne,MESH_Num_Edges(mesh)); 35 | 36 | mr = MESH_Region(mesh,0); 37 | 38 | /* Check if we can retrieve edges of a tet */ 39 | 40 | redges = MR_Edges(mr); 41 | 42 | for (i = 0; i < exp_ne; i++) { 43 | MEdge_ptr e = List_Entry(redges,i); 44 | int eid = ME_ID(e); 45 | CHECK_EQUAL(exp_eids[i],eid); 46 | } 47 | 48 | List_Delete(redges); 49 | 50 | /* Check if we can directly retrieve the IDs of edges of a tet */ 51 | 52 | MR_EdgeIDs(mr,&ne,eids); 53 | 54 | CHECK_EQUAL(ne,exp_ne); 55 | CHECK_ARRAY_EQUAL(exp_eids,eids,exp_ne); 56 | } 57 | -------------------------------------------------------------------------------- /unittests/serial/test_MR_Rem_Face_FNR3R4.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | 11 | #include "MSTK.h" 12 | 13 | // Test if we can remove a face correctly from a region (check list of 14 | // remaining faces and their directions) 15 | 16 | TEST(MR_Rem_Face_FNR3R4) 17 | { 18 | int ok, i, j, nrf; 19 | Mesh_ptr mesh; 20 | MRegion_ptr mr; 21 | List_ptr rflist; 22 | MFace_ptr rfaces[6]; 23 | int rfdirs[6]; 24 | 25 | 26 | MSTK_Init(); 27 | 28 | mesh = MESH_New(UNKNOWN_REP); 29 | 30 | ok = MESH_InitFromFile(mesh,"serial/onehex.mstk",NULL); 31 | CHECK_EQUAL(1,ok); 32 | 33 | mr = MESH_Region(mesh,0); 34 | rflist = MR_Faces(mr); 35 | 36 | for (i = 0; i < 6; i++) { 37 | rfaces[i] = List_Entry(rflist,i); 38 | rfdirs[i] = MR_FaceDir_i(mr,i); 39 | } 40 | 41 | List_Delete(rflist); 42 | 43 | // Remove faces from region 1 by 1 and see if 44 | // the leftover faces have the right IDs and dirs 45 | 46 | for (i = 0; i < 6; i++) { 47 | MR_Rem_Face(mr,rfaces[i]); 48 | 49 | rflist = MR_Faces(mr); 50 | nrf = List_Num_Entries(rflist); 51 | 52 | CHECK_EQUAL(6-(i+1),nrf); // Right number of faces? 53 | 54 | for (j = 0; j < nrf; j++) { 55 | CHECK_EQUAL(rfaces[i+1+j],List_Entry(rflist,j)); 56 | CHECK_EQUAL(rfdirs[i+1+j],MR_FaceDir_i(mr,j)); 57 | } 58 | 59 | List_Delete(rflist); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /unittests/serial/test_MR_Vertices_Hex_FN.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | 11 | #include "MSTK.h" 12 | 13 | TEST(MR_Vertices_Hex_FN) 14 | { 15 | int ok, i, nv, vids[8]; 16 | Mesh_ptr mesh; 17 | MRegion_ptr mr; 18 | List_ptr rverts; 19 | 20 | int exp_nv = 8; 21 | int exp_vids[8] = {6,4,7,3,5,1,8,2}; 22 | 23 | MSTK_Init(); 24 | 25 | mesh = MESH_New(UNKNOWN_REP); 26 | 27 | ok = MESH_InitFromFile(mesh,"serial/onehex.mstk",NULL); 28 | CHECK_EQUAL(1,ok); 29 | 30 | CHECK_EQUAL(F1,MESH_RepType(mesh)); 31 | 32 | CHECK_EQUAL(1,MESH_Num_Regions(mesh)); 33 | 34 | CHECK_EQUAL(exp_nv,MESH_Num_Vertices(mesh)); 35 | 36 | mr = MESH_Region(mesh,0); 37 | 38 | /* Check if we can get the correct vertices of a hex */ 39 | 40 | rverts = MR_Vertices(mr); 41 | 42 | for (i = 0; i < exp_nv; i++) { 43 | MVertex_ptr v = List_Entry(rverts,i); 44 | int vid = MV_ID(v); 45 | CHECK_EQUAL(exp_vids[i],vid); 46 | } 47 | 48 | List_Delete(rverts); 49 | 50 | /* Check if we get the correct result when we get the IDs directly */ 51 | 52 | MR_VertexIDs(mr,&nv,vids); 53 | 54 | CHECK_EQUAL(nv,exp_nv); 55 | CHECK_ARRAY_EQUAL(exp_vids,vids,exp_nv); 56 | 57 | } 58 | -------------------------------------------------------------------------------- /unittests/serial/test_MR_Vertices_Polyhed_FN.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | 11 | #include "MSTK.h" 12 | 13 | TEST(MR_Vertices_polyhed_FN) 14 | { 15 | int ok, i, nv, vids[9]; 16 | Mesh_ptr mesh; 17 | MRegion_ptr mr; 18 | List_ptr rverts; 19 | 20 | int exp_nv = 9; 21 | int exp_vids[9] = {3,4,5,1,6,2,7,8,9}; 22 | 23 | MSTK_Init(); 24 | 25 | mesh = MESH_New(UNKNOWN_REP); 26 | 27 | ok = MESH_InitFromFile(mesh,"serial/onepolyhed.mstk",NULL); 28 | CHECK_EQUAL(1,ok); 29 | 30 | CHECK_EQUAL(F1,MESH_RepType(mesh)); 31 | 32 | CHECK_EQUAL(1,MESH_Num_Regions(mesh)); 33 | 34 | CHECK_EQUAL(exp_nv,MESH_Num_Vertices(mesh)); 35 | 36 | mr = MESH_Region(mesh,0); 37 | 38 | /* Check if we can get the correct vertices for a polyhedron */ 39 | 40 | rverts = MR_Vertices(mr); 41 | 42 | for (i = 0; i < exp_nv; i++) { 43 | MVertex_ptr v = List_Entry(rverts,i); 44 | int vid = MV_ID(v); 45 | CHECK_EQUAL(exp_vids[i],vid); 46 | } 47 | 48 | List_Delete(rverts); 49 | 50 | /* Check if we get the correct result when we get the IDs directly */ 51 | 52 | MR_VertexIDs(mr,&nv,vids); 53 | 54 | CHECK_EQUAL(nv,exp_nv); 55 | CHECK_ARRAY_EQUAL(exp_vids,vids,exp_nv); 56 | } 57 | -------------------------------------------------------------------------------- /unittests/serial/test_MR_Vertices_Prism_FN.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | 11 | #include "MSTK.h" 12 | 13 | TEST(MR_Vertices_Prism_FN) 14 | { 15 | int ok, i, nv, vids[6]; 16 | Mesh_ptr mesh; 17 | MRegion_ptr mr; 18 | List_ptr rverts; 19 | 20 | int exp_nv = 6; 21 | int exp_vids[6] = {2,6,3,5,1,4}; 22 | 23 | MSTK_Init(); 24 | 25 | mesh = MESH_New(UNKNOWN_REP); 26 | 27 | ok = MESH_InitFromFile(mesh,"serial/oneprism.mstk",NULL); 28 | CHECK_EQUAL(1,ok); 29 | 30 | CHECK_EQUAL(F1,MESH_RepType(mesh)); 31 | 32 | CHECK_EQUAL(1,MESH_Num_Regions(mesh)); 33 | 34 | CHECK_EQUAL(exp_nv,MESH_Num_Vertices(mesh)); 35 | 36 | mr = MESH_Region(mesh,0); 37 | 38 | /* Check if we can get the correct vertices of a prism */ 39 | 40 | rverts = MR_Vertices(mr); 41 | 42 | for (i = 0; i < exp_nv; i++) { 43 | MVertex_ptr v = List_Entry(rverts,i); 44 | int vid = MV_ID(v); 45 | CHECK_EQUAL(exp_vids[i],vid); 46 | } 47 | 48 | List_Delete(rverts); 49 | 50 | /* Check if we get the correct result when we get the IDs directly */ 51 | 52 | MR_VertexIDs(mr,&nv,vids); 53 | 54 | CHECK_EQUAL(nv,exp_nv); 55 | CHECK_ARRAY_EQUAL(exp_vids,vids,exp_nv); 56 | } 57 | -------------------------------------------------------------------------------- /unittests/serial/test_MR_Vertices_Pyramid_FN.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | 11 | #include "MSTK.h" 12 | 13 | TEST(MR_Vertices_Pyramid_FN) 14 | { 15 | int ok, i, nv, vids[5]; 16 | Mesh_ptr mesh; 17 | MRegion_ptr mr; 18 | List_ptr rverts; 19 | 20 | int exp_nv = 5; 21 | int exp_vids[5] = {5,1,3,4,2}; 22 | 23 | MSTK_Init(); 24 | 25 | mesh = MESH_New(UNKNOWN_REP); 26 | 27 | ok = MESH_InitFromFile(mesh,"serial/onepyramid.mstk",NULL); 28 | CHECK_EQUAL(1,ok); 29 | 30 | CHECK_EQUAL(F1,MESH_RepType(mesh)); 31 | 32 | CHECK_EQUAL(1,MESH_Num_Regions(mesh)); 33 | 34 | CHECK_EQUAL(exp_nv,MESH_Num_Vertices(mesh)); 35 | 36 | mr = MESH_Region(mesh,0); 37 | 38 | rverts = MR_Vertices(mr); 39 | 40 | for (i = 0; i < exp_nv; i++) { 41 | MVertex_ptr v = List_Entry(rverts,i); 42 | int vid = MV_ID(v); 43 | CHECK_EQUAL(exp_vids[i],vid); 44 | } 45 | 46 | List_Delete(rverts); 47 | 48 | /* Check if we get the correct result when we get the IDs directly */ 49 | 50 | MR_VertexIDs(mr,&nv,vids); 51 | 52 | CHECK_EQUAL(nv,exp_nv); 53 | CHECK_ARRAY_EQUAL(exp_vids,vids,exp_nv); 54 | 55 | } 56 | -------------------------------------------------------------------------------- /unittests/serial/test_MR_Vertices_Tet_FN.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | 11 | #include "MSTK.h" 12 | 13 | TEST(MR_Vertices_Tet_FN) 14 | { 15 | int ok, i, nv, vids[4]; 16 | Mesh_ptr mesh; 17 | MRegion_ptr mr; 18 | List_ptr rverts; 19 | 20 | int exp_nv = 4; 21 | int exp_vids[4] = {2,4,3,1}; 22 | 23 | MSTK_Init(); 24 | 25 | mesh = MESH_New(UNKNOWN_REP); 26 | 27 | ok = MESH_InitFromFile(mesh,"serial/onetet.mstk",NULL); 28 | CHECK_EQUAL(1,ok); 29 | 30 | CHECK_EQUAL(F1,MESH_RepType(mesh)); 31 | 32 | CHECK_EQUAL(1,MESH_Num_Regions(mesh)); 33 | 34 | CHECK_EQUAL(exp_nv,MESH_Num_Vertices(mesh)); 35 | 36 | mr = MESH_Region(mesh,0); 37 | 38 | /* Check if we can get the correct vertices of a tet */ 39 | 40 | rverts = MR_Vertices(mr); 41 | 42 | for (i = 0; i < exp_nv; i++) { 43 | MVertex_ptr v = List_Entry(rverts,i); 44 | int vid = MV_ID(v); 45 | CHECK_EQUAL(exp_vids[i],vid); 46 | } 47 | 48 | List_Delete(rverts); 49 | 50 | /* Check if we get the correct result when we get the IDs directly */ 51 | 52 | MR_VertexIDs(mr,&nv,vids); 53 | 54 | CHECK_EQUAL(nv,exp_nv); 55 | CHECK_ARRAY_EQUAL(exp_vids,vids,exp_nv); 56 | } 57 | -------------------------------------------------------------------------------- /unittests/serial/twohex.mstk: -------------------------------------------------------------------------------- 1 | MSTK 1.0 2 | F1 12 20 11 2 3 | vertices 4 | 0.0000000000000000 0.0000000000000000 0.0000000000000000 2 1 5 | 1.0000000000000000 0.0000000000000000 0.0000000000000000 2 1 6 | 2.0000000000000000 0.0000000000000000 0.0000000000000000 2 1 7 | 0.0000000000000000 1.0000000000000000 0.0000000000000000 2 1 8 | 1.0000000000000000 1.0000000000000000 0.0000000000000000 2 1 9 | 2.0000000000000000 1.0000000000000000 0.0000000000000000 2 1 10 | 0.0000000000000000 0.0000000000000000 1.0000000000000000 2 1 11 | 1.0000000000000000 0.0000000000000000 1.0000000000000000 2 1 12 | 2.0000000000000000 0.0000000000000000 1.0000000000000000 2 1 13 | 0.0000000000000000 1.0000000000000000 1.0000000000000000 2 1 14 | 1.0000000000000000 1.0000000000000000 1.0000000000000000 2 1 15 | 2.0000000000000000 1.0000000000000000 1.0000000000000000 2 1 16 | edges 17 | 7 8 2 1 18 | 8 11 2 1 19 | 11 10 2 1 20 | 10 7 2 1 21 | 1 2 2 1 22 | 2 5 2 1 23 | 5 4 2 1 24 | 4 1 2 1 25 | 7 1 2 1 26 | 8 2 2 1 27 | 11 5 2 1 28 | 10 4 2 1 29 | 8 9 2 1 30 | 9 12 2 1 31 | 12 11 2 1 32 | 2 3 2 1 33 | 3 6 2 1 34 | 6 5 2 1 35 | 9 3 2 1 36 | 12 6 2 1 37 | faces edge 38 | 4 -4 -3 -2 -1 2 1 39 | 4 5 6 7 8 2 1 40 | 4 1 10 -5 -9 2 1 41 | 4 2 11 -6 -10 3 1 42 | 4 3 12 -7 -11 2 1 43 | 4 4 9 -8 -12 2 1 44 | 4 2 -15 -14 -13 2 1 45 | 4 16 17 18 -6 2 1 46 | 4 13 19 -16 -10 2 1 47 | 4 14 20 -17 -19 2 1 48 | 4 15 11 -18 -20 2 1 49 | regions face 50 | 6 1 2 3 4 5 6 3 1 51 | 6 7 8 9 10 11 -4 3 1 52 | -------------------------------------------------------------------------------- /unittests/serial/twotets.mstk: -------------------------------------------------------------------------------- 1 | MSTK 1.0 2 | F1 5 9 7 2 3 | vertices 4 | 0.0000000000000000 0.0000000000000000 0.0000000000000000 2 1 5 | 1.0000000000000000 0.0000000000000000 0.0000000000000000 2 1 6 | 1.0000000000000000 1.0000000000000000 0.0000000000000000 2 1 7 | 0.0000000000000000 1.0000000000000000 0.0000000000000000 2 1 8 | 0.5000000000000000 0.5000000000000000 1.0000000000000000 2 1 9 | edges 10 | 1 4 2 1 11 | 4 2 2 1 12 | 2 1 2 1 13 | 1 5 2 1 14 | 4 5 2 1 15 | 2 5 2 1 16 | 2 3 2 1 17 | 3 5 2 1 18 | 3 4 2 1 19 | faces edge 20 | 3 -3 -2 -1 2 1 21 | 3 1 5 -4 2 1 22 | 3 2 6 -5 3 1 23 | 3 3 4 -6 2 1 24 | 3 6 -8 -7 2 1 25 | 3 7 9 2 2 1 26 | 3 8 -5 -9 2 1 27 | regions face 28 | 4 1 2 3 4 3 1 29 | 4 5 6 7 -3 3 1 30 | -------------------------------------------------------------------------------- /utils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Triad National Security, LLC. All rights reserved. 2 | # 3 | # This file is part of the MSTK project. Please see the license file at 4 | # the root of this repository or at 5 | # https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 6 | 7 | # -*- mode: cmake -*- 8 | # 9 | # Mesh Utilities 10 | # 11 | # Author: Rao Garimella (rao@lanl.gov) 12 | # 13 | 14 | 15 | 16 | ############################################################################# 17 | # Mesh conversion utility 18 | ############################################################################### 19 | 20 | add_subdirectory(meshconvert) 21 | 22 | 23 | ############################################################################# 24 | # Mesh checking utility 25 | ############################################################################### 26 | 27 | add_subdirectory(chkmesh) 28 | 29 | 30 | ############################################################################### 31 | # Utility to attach auxilliary attributes to exodus mesh 32 | ############################################################################### 33 | 34 | if (ENABLE_ExodusII) 35 | add_subdirectory(exoatt) 36 | endif (ENABLE_ExodusII) 37 | 38 | ############################################################################# 39 | # Partition visualization 40 | ############################################################################### 41 | 42 | if (ENABLE_PARALLEL) 43 | add_subdirectory(vizpart) 44 | endif (ENABLE_PARALLEL) 45 | 46 | 47 | ############################################################################## 48 | # Rectangular mesh creation 49 | ############################################################################## 50 | 51 | add_subdirectory(mkstruc) 52 | 53 | ############################################################################## 54 | # Tet 2 Hex mesh conversion 55 | ############################################################################## 56 | 57 | add_subdirectory(tet2hex) 58 | 59 | ############################################################################## 60 | # Tri 2 Quad mesh conversion 61 | ############################################################################## 62 | 63 | add_subdirectory(tri2quad) 64 | -------------------------------------------------------------------------------- /utils/chkmesh/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Triad National Security, LLC. All rights reserved. 2 | # 3 | # This file is part of the MSTK project. Please see the license file at 4 | # the root of this repository or at 5 | # https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 6 | 7 | 8 | add_executable(chkmesh src/chkmesh.c src/geom.c) 9 | target_link_libraries(chkmesh ${MSTKLIB}) 10 | target_include_directories(chkmesh PRIVATE ${PROJECT_BINARY_DIR}/include) 11 | 12 | install(TARGETS chkmesh DESTINATION bin) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /utils/exoatt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Triad National Security, LLC. All rights reserved. 2 | # 3 | # This file is part of the MSTK project. Please see the license file at 4 | # the root of this repository or at 5 | # https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 6 | 7 | 8 | 9 | add_executable(exoatt src/exoatt.c) 10 | target_link_libraries(exoatt ${MSTKLIB}) 11 | target_include_directories(exoatt PRIVATE ${PROJECT_BINARY_DIR}/include) 12 | 13 | install(TARGETS exoatt DESTINATION bin) 14 | 15 | # Unittests 16 | 17 | if (ENABLE_Tests) 18 | add_subdirectory(unittests) 19 | endif() 20 | -------------------------------------------------------------------------------- /utils/exoatt/unittests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Triad National Security, LLC. All rights reserved. 2 | # 3 | # This file is part of the MSTK project. Please see the license file at 4 | # the root of this repository or at 5 | # https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 6 | 7 | 8 | if (BUILD_TESTS) 9 | 10 | # Need to copy files for tests otherwise the input files aren't accessible 11 | 12 | if (NOT (${PROJECT_SOURCE_DIR} EQUAL ${PROJECT_BINARY_DIR})) 13 | execute_process(COMMAND ${CMAKE_COMMAND} -E 14 | copy_directory ${PROJECT_SOURCE_DIR}/utils/exoatt/unittests ${PROJECT_BINARY_DIR}/utils/exoatt/unittests) 15 | endif () 16 | 17 | file (GLOB FILES *.cc) 18 | foreach (FILE ${FILES}) 19 | get_filename_component(RELFILE ${FILE} NAME) 20 | if (${RELFILE} MATCHES ExodusII OR $(RELFILE) MATCHES NemesisI) 21 | if (ENABLE_ExodusII) 22 | set (testfiles ${testfiles} ${FILE}) 23 | endif () 24 | else () 25 | set (testfiles ${testfiles} ${FILE}) 26 | endif () 27 | endforeach () 28 | 29 | add_executable(exoatt_unit_tests ${testfiles}) 30 | 31 | target_include_directories(exoatt_unit_tests 32 | PRIVATE ${UnitTest++_INCLUDE_DIRS} ${PROJECT_BINARY_DIR}/include) 33 | 34 | target_link_libraries(exoatt_unit_tests 35 | ${MSTKLIB} 36 | ${METIS_LIBRARIES} 37 | ${ZOLTAN_LIBRARIES} 38 | ${ExodusII_LIBRARIES} 39 | ${NetCDF_LIBRARIES} 40 | ${HDF5_LIBRARIES} 41 | UnitTest++) 42 | 43 | add_test(NAME exoatt_unittests COMMAND exoatt_unit_tests) 44 | 45 | 46 | endif(BUILD_TESTS) 47 | -------------------------------------------------------------------------------- /utils/exoatt/unittests/Main.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | #ifdef MSTK_HAVE_MPI 13 | #include 14 | #endif 15 | 16 | int main(int argc, char *argv[]) 17 | { 18 | 19 | return UnitTest::RunAllTests (); 20 | 21 | } 22 | 23 | -------------------------------------------------------------------------------- /utils/exoatt/unittests/reghex3D.exo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeshToolkit/MSTK/fd1c0c477e635fac34b207e443331aed145fdd96/utils/exoatt/unittests/reghex3D.exo -------------------------------------------------------------------------------- /utils/meshconvert/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Triad National Security, LLC. All rights reserved. 2 | # 3 | # This file is part of the MSTK project. Please see the license file at 4 | # the root of this repository or at 5 | # https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 6 | 7 | 8 | add_executable(meshconvert src/meshconvert.c) 9 | target_link_libraries(meshconvert ${MSTKLIB}) 10 | target_include_directories(meshconvert PRIVATE ${PROJECT_BINARY_DIR}/include) 11 | 12 | install(TARGETS meshconvert DESTINATION bin) 13 | 14 | 15 | -------------------------------------------------------------------------------- /utils/mkstruc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Triad National Security, LLC. All rights reserved. 2 | # 3 | # This file is part of the MSTK project. Please see the license file at 4 | # the root of this repository or at 5 | # https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 6 | 7 | 8 | add_executable(mkstruc src/mkstruc.c src/transform_xyz.c) 9 | target_link_libraries(mkstruc ${MSTKLIB}) 10 | target_include_directories(mkstruc PRIVATE ${PROJECT_BINARY_DIR}/include) 11 | 12 | 13 | install(TARGETS mkstruc DESTINATION bin) 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /utils/mkstruc/src/mkstruc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #ifndef _H_MKSTRUC 10 | #define _H_MKSTRUC 11 | 12 | /* function to transform coordinates */ 13 | /* assume that xyz is 3 dimensional */ 14 | /* 'boundary' = 1 indicates that point is on the domain boundary */ 15 | /* = 0 indicates that point is in domain interior */ 16 | 17 | void transform_xyz(double *xyz, int boundary); 18 | 19 | 20 | 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /utils/mkstruc/src/transform_xyz.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Triad National Security, LLC. All rights reserved. 3 | 4 | This file is part of the MSTK project. Please see the license file at 5 | the root of this repository or at 6 | https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "mkstruc.h" 15 | 16 | void transform_xyz(double *xyz, int boundary) { 17 | 18 | if (boundary) { 19 | /* do something or nothing */ 20 | } 21 | else { 22 | /* do something else */ 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /utils/tet2hex/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Triad National Security, LLC. All rights reserved. 2 | # 3 | # This file is part of the MSTK project. Please see the license file at 4 | # the root of this repository or at 5 | # https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 6 | 7 | 8 | add_executable(tet2hex src/tet2hex.c) 9 | target_link_libraries(tet2hex ${MSTKLIB}) 10 | target_include_directories(tet2hex PRIVATE ${PROJECT_BINARY_DIR}/include) 11 | 12 | 13 | install(TARGETS tet2hex DESTINATION bin) 14 | 15 | 16 | -------------------------------------------------------------------------------- /utils/tri2quad/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Triad National Security, LLC. All rights reserved. 2 | # 3 | # This file is part of the MSTK project. Please see the license file at 4 | # the root of this repository or at 5 | # https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 6 | 7 | 8 | 9 | add_executable(tri2quad src/tri2quad.c) 10 | target_link_libraries(tri2quad ${MSTKLIB}) 11 | target_include_directories(tri2quad PRIVATE ${PROJECT_BINARY_DIR}/include) 12 | 13 | install(TARGETS tri2quad DESTINATION bin) 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /utils/vizpart/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Triad National Security, LLC. All rights reserved. 2 | # 3 | # This file is part of the MSTK project. Please see the license file at 4 | # the root of this repository or at 5 | # https://github.com/MeshToolkit/MSTK/blob/master/LICENSE 6 | 7 | 8 | add_executable(vizpart src/vizpart.c) 9 | target_link_libraries(vizpart ${MSTKLIB}) 10 | target_include_directories(vizpart PRIVATE ${PROJECT_BINARY_DIR}/include) 11 | 12 | install(TARGETS vizpart DESTINATION bin) 13 | 14 | 15 | --------------------------------------------------------------------------------