Skip to content

Commit

Permalink
Merge pull request #75 from Angelyr/ac/describe-mesh
Browse files Browse the repository at this point in the history
Describe Mesh
  • Loading branch information
cwsmith authored Dec 4, 2023
2 parents 050c804 + 2ab0360 commit 0b19ae4
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ jobs:
working-directory: ${{runner.workspace}}/build
shell: bash
run: ctest

- name: Print
if: always()
run: cat ${{runner.workspace}}/build/Testing/Temporary/LastTest.log
9 changes: 8 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ macro(osh_add_util EXE_NAME)
bob_export_target(${EXE_NAME})
endmacro(osh_add_util)

osh_add_util(describe)
osh_add_util(msh2osh)
osh_add_util(osh2vtk)
osh_add_util(oshdiff)
Expand Down Expand Up @@ -321,7 +322,7 @@ if(BUILD_TESTING)
endif()
endif()

function(test_func_impl TEST_NAME NUM_PROCS)
function(test_func_impl TEST_NAME NUM_PROCS)

if (ENABLE_CTEST_MEMPOOL)
set(CTEST_MEMPOOL_ARG "--osh-pool")
Expand Down Expand Up @@ -571,6 +572,12 @@ if(BUILD_TESTING)
endif()
osh_add_exe(shape_test)
test_basefunc(run_shape_test 1 ./shape_test)

if(Omega_h_USE_MPI)
test_func(describe_partitioned 2 ./describe ${CMAKE_SOURCE_DIR}/meshes/box_3d_2p.osh)
else()
test_func(describe_serial 1 ./describe ${CMAKE_SOURCE_DIR}/meshes/box_3d.osh)
endif()
endif()

bob_config_header("${CMAKE_CURRENT_BINARY_DIR}/Omega_h_config.h")
Expand Down
47 changes: 47 additions & 0 deletions src/describe.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include <Omega_h_element.hpp>
#include <Omega_h_file.hpp>


int main(int argc, char** argv)
{
auto lib = Omega_h::Library(&argc, &argv);
Omega_h::Mesh mesh = Omega_h::read_mesh_file(argv[1], lib.world());
std::ostringstream oss;

#ifdef OMEGA_H_USE_MPI
int comm_rank;
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
oss << "\nComm Rank: " << comm_rank << "\n";
#endif

oss << "\nMesh Entity Count by Dimension: (Dim, Entities Count)\n";
for(int dim=0; dim < mesh.dim(); dim++)
oss << "(" << dim << ", " << mesh.nents(dim) << ")\n";

oss << "\nImbalance by Dimension: (Dim, Imbalance)\n";
for(int dim=0; dim < mesh.dim(); dim++)
oss << "(" << dim << ", " << mesh.imbalance(dim) << ")\n";

oss << "\nMesh Family: " << Omega_h::topological_singular_name(mesh.family(), mesh.dim()-1) << "\n";

oss << "\nTags by Dimension: (Dim, Tag, Size per Entity)\n";
for (int dim=0; dim < mesh.dim(); dim++)
for (int tag=0; tag < mesh.ntags(dim); tag++) {
auto tagbase = mesh.get_tag(dim, tag);
int size;
if (tagbase->type() == OMEGA_H_I8)
size = mesh.get_tag<Omega_h::I8>(dim, tagbase->name())->array().size();
if (tagbase->type() == OMEGA_H_I32)
size = mesh.get_tag<Omega_h::I32>(dim, tagbase->name())->array().size();
if (tagbase->type() == OMEGA_H_I64)
size = mesh.get_tag<Omega_h::I64>(dim, tagbase->name())->array().size();
if (tagbase->type() == OMEGA_H_F64)
size = mesh.get_tag<Omega_h::Real>(dim, tagbase->name())->array().size();

size /= mesh.nents(dim);
oss << "(" << dim << ", " << tagbase->name().c_str() << ", " << size << ")\n";
}

oss << "\n--------------------------------------------------------\n";
std::cout << oss.str();
}

0 comments on commit 0b19ae4

Please sign in to comment.