Skip to content

Commit

Permalink
v9.34.13
Browse files Browse the repository at this point in the history
  • Loading branch information
ibaned committed Sep 28, 2022
2 parents 6af8f60 + e6b19ea commit dc23545
Show file tree
Hide file tree
Showing 3 changed files with 368 additions and 31 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.7.0...${CMAKE_VERSION})

project(Omega_h VERSION 9.34.12 LANGUAGES CXX)
project(Omega_h VERSION 9.34.13 LANGUAGES CXX)

set(Omega_h_USE_STK_DEFAULT OFF)
option(Omega_h_USE_STK "Whether to build the STK interface" ${Omega_h_USE_STK_DEFAULT})
Expand Down
32 changes: 24 additions & 8 deletions src/Omega_h_gmsh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,15 +552,15 @@ Mesh read_parallel(filesystem::path filename, CommPtr comm) {
if (nnodes == 0) {
Omega_h_fail("Please check that filename is correct!\n");
}

std::map<GO, LO> node_number_map;
HostWrite<GO> host_vert_globals(nnodes);
Write<GO> vert_globals_w(nnodes);
for (LO local_index = 0; local_index < nnodes; ++local_index) {
const auto global_index =
static_cast<GO>(node_tags[static_cast<std::size_t>(local_index)]);
node_number_map[global_index] = local_index;
host_vert_globals[local_index] = global_index;
vert_globals_w[local_index] = global_index;
}
Read<GO> vert_globals(host_vert_globals.write());

std::array<std::vector<int>, 4> ent_class_ids;
std::array<std::vector<LO>, 4> ent_nodes;
Expand Down Expand Up @@ -631,6 +631,23 @@ Mesh read_parallel(filesystem::path filename, CommPtr comm) {
Omega_h_fail("There were no Elements of dimension higher than zero!\n");
}

// function to decrement the values of container given in parameter
// by the minimum value of the container across all ranks
auto shift_container_values = [&](auto& container) {
auto local_min_it = std::min_element(container.begin(), container.end());
OMEGA_H_CHECK(local_min_it != container.end());
auto global_min = comm->allreduce(*local_min_it, OMEGA_H_MIN);
if (global_min != 0) {
for (auto& id : container) {
id -= global_min;
}
}
};
// shift elements global identifiers so that they start at 0
shift_container_values(ent_globals[max_dim]);
// shift vertices global identifiers so that they start at 0
shift_container_values(vert_globals_w);

HostWrite<Real> host_coords(nnodes * max_dim);
for (LO local_index = 0; local_index < nnodes; ++local_index) {
for (LO j = 0; j < max_dim; ++j) {
Expand All @@ -640,7 +657,7 @@ Mesh read_parallel(filesystem::path filename, CommPtr comm) {
}
for (Int ent_dim = max_dim; ent_dim >= 0; --ent_dim) {
const auto ndim_ents = static_cast<LO>(ent_globals[ent_dim].size());
HostWrite<GO> host_elem_globals(ndim_ents);
Write<GO> host_elem_globals(ndim_ents);
HostWrite<LO> host_class_id(ndim_ents);
HostWrite<LO> host_ev2v(ent_nodes[ent_dim].size());
if (ndim_ents > 0) {
Expand All @@ -660,21 +677,20 @@ Mesh read_parallel(filesystem::path filename, CommPtr comm) {
}
LOs eqv2v(host_ev2v.write());
if (ent_dim == max_dim) {
Read<GO> elem_globals(host_elem_globals.write());
// build_from_elems2verts(
// &mesh, mesh.library()->self(), OMEGA_H_SIMPLEX, dim, eqv2v,
// vert_globals);
mesh.set_comm(comm);
mesh.set_parting(OMEGA_H_ELEM_BASED);
mesh.set_family(family);
mesh.set_dim(ent_dim);
build_verts_from_globals(&mesh, vert_globals);
build_verts_from_globals(&mesh, vert_globals_w);
// build_ents_from_elems2verts(&mesh, eqv2v, vert_globals, elem_globals);
for (Int mdim = 1; mdim < ent_dim; ++mdim) {
auto mv2v = find_unique(eqv2v, mesh.family(), ent_dim, mdim);
add_ents2verts(&mesh, mdim, mv2v, vert_globals, GOs());
add_ents2verts(&mesh, mdim, mv2v, vert_globals_w, GOs());
}
add_ents2verts(&mesh, ent_dim, eqv2v, vert_globals, elem_globals);
add_ents2verts(&mesh, ent_dim, eqv2v, vert_globals_w, host_elem_globals);
// if (!comm->reduce_and(is_sorted(vert_globals))) {
// reorder_by_globals(&mesh);
//}
Expand Down
Loading

0 comments on commit dc23545

Please sign in to comment.