Skip to content

Commit

Permalink
fix failing meshsim2osh test
Browse files Browse the repository at this point in the history
Comparing meshes between builds was resulting in failed diffs. Looking at the 'old' gold mesh that was stored in the repo and a 'new' mesh, the global orderings (generated by osh_reorder) were different. It seems more likely that changing the simmetrix library version caused the differences.
  • Loading branch information
cwsmith committed Aug 29, 2024
1 parent 4977812 commit 18d3215
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 14 deletions.
Binary file removed meshes/d3d/d3d-coreMesh-gold.osh/0.osh
Binary file not shown.
Binary file removed meshes/d3d/d3d-coreMesh-numbered-gold.osh/0.osh
Binary file not shown.
23 changes: 12 additions & 11 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -400,30 +400,31 @@ if(BUILD_TESTING)

if(Omega_h_USE_SimModSuite)
set(d3dMesh ${CMAKE_SOURCE_DIR}/meshes/d3d)
test_func(run_tri_convert_gold 1 ./meshsim2osh
${d3dMesh}/d3d-coreMesh.sms
${d3dMesh}/d3d.smd
${d3dMesh}/d3d-coreMesh-gold.osh)
test_func(run_tri_convert 1 ./meshsim2osh
${d3dMesh}/d3d-coreMesh.sms
${d3dMesh}/d3d.smd
${d3dMesh}/d3d-coreMesh.osh)
#osh_diff requires a 'global' tag, the osh_reorder utility creates the tag
# and was used to generate the tag on the known-to-be-correct ('gold') mesh
#see #40 for additional discussion
test_func(run_tri_convert_reorder 1 ./osh_reorder
${d3dMesh}/d3d-coreMesh.osh
${d3dMesh}/d3d-coreMesh-reordered.osh)
#ensure determinism (with same build) of meshsim2osh
test_func(diff_tri_convert 1 ./oshdiff
${d3dMesh}/d3d-coreMesh-gold.osh
${d3dMesh}/d3d-coreMesh-reordered.osh)
${d3dMesh}/d3d-coreMesh.osh)
test_func(run_tri_convert_numbering_gold 1 ./meshsim2osh
${d3dMesh}/d3d-coreMesh.sms
${d3dMesh}/d3d.smd
${d3dMesh}/d3d-coreMesh-numbered-gold.osh
-numbering ${d3dMesh}/d3d-coreMesh.nex)
test_func(run_tri_convert_numbering 1 ./meshsim2osh
${d3dMesh}/d3d-coreMesh.sms
${d3dMesh}/d3d.smd
${d3dMesh}/d3d-coreMesh-numbered.osh
-numbering ${d3dMesh}/d3d-coreMesh.nex)
test_func(run_tri_convert_numbering_reorder 1 ./osh_reorder
${d3dMesh}/d3d-coreMesh-numbered.osh
${d3dMesh}/d3d-coreMesh-numbered-reordered.osh)
test_func(diff_tri_convert_numbering 1 ./oshdiff
${d3dMesh}/d3d-coreMesh-numbered-gold.osh
${d3dMesh}/d3d-coreMesh-numbered-reordered.osh)
${d3dMesh}/d3d-coreMesh-numbered.osh)

osh_add_exe(mixed_writeMesh)
set(TEST_EXES ${TEST_EXES} mixed_writeMesh)
Expand Down
21 changes: 18 additions & 3 deletions src/meshsim2osh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,20 @@
#include "Omega_h_cmdline.hpp"
#include "Omega_h_file.hpp"
#include "Omega_h_mesh.hpp"

#include "Omega_h_build.hpp"
#include "Omega_h_for.hpp"

void localToGlobal(Omega_h::Mesh* mesh, int entDim) {
OMEGA_H_CHECK(entDim >= 0 && entDim <= mesh->dim());
std::string kernelName = "local_to_global_" + entDim;
Omega_h::Write<Omega_h::GO> global(mesh->nents(entDim));
Omega_h::parallel_for(kernelName.c_str(), mesh->nents(entDim),
OMEGA_H_LAMBDA(int i) { global[i] = static_cast<Omega_h::GO>(i); }
);
mesh->add_tag<Omega_h::GO>(entDim, "global", 1, Omega_h::read(global));
}


int main(int argc, char** argv) {
auto lib = Omega_h::Library(&argc, &argv);
auto comm = lib.world();
Expand All @@ -27,13 +39,16 @@ int main(int argc, char** argv) {
}
auto isMixed = Omega_h::meshsim::isMixed(mesh_in, model_in);
std::cerr << "isMixed " << isMixed << "\n";
//TODO - call the correct reader (mixed vs mono)
if( !isMixed ) {
auto mesh = Omega_h::meshsim::read(mesh_in, model_in, numbering_in, comm);
//convert the local numbering to global
//needed for oshdiff, see github issue #40
for(int entDim=0; entDim<=mesh.dim(); entDim++) {
localToGlobal(&mesh,entDim);
}
Omega_h::binary::write(mesh_out, &mesh);
} else {
auto mesh = Omega_h::meshsim::readMixed(mesh_in, model_in, comm);
}

return 0;
}

0 comments on commit 18d3215

Please sign in to comment.