18 {.1, .25, 1}, {.1, .25, -1}, {0, -1, -.5}};
19 source.vertexIds = {1, 2, 3, 4, 5, 6};
20 source.cells = {{0, 1, 2, 3}, {0, 1, 2, 4}, {0, 1, 4, 5}};
21 source.partitions = {0, last, last};
23 std::reverse(
source.points.begin(),
source.points.end());
24 std::reverse(
source.vertexIds.begin(),
source.vertexIds.end());
29 std::reverse(
source.partitions.begin(),
source.partitions.end());
31 Range old_entities, children;
36 output.
points = {{-1, 0, 0}, {1, 0, 0}, {0, 1, 0},
37 {.1, .25, 1}, {.1, .25, -1}, {0, -1, -.5}};
39 output.
cells = {{0, 1, 3, 4}, {1, 2, 3, 4}, {2, 0, 3, 4}, {0, 1, 4, 5}};
46 for (
auto child : subtract(children, old_entities).subset_by_type(MBTET)) {
49 const EntityHandle *conn;
51 std::array<int, 4> ids;
53 CHKERR mb.tag_get_data(
mb.globalId_tag(), conn, 4, ids.data());
54 std::sort(ids.begin(), ids.end());
55 if (ids != std::array<int, 4>{1, 2, 3, 4})
57 "Flip parent depends on local creation order");
60 if (std::none_of(range.first, range.second,
61 [&](
const auto &p) { return p->getEnt() == child; }))
63 "Parent index is stale");
65 CHKERR comm->inheritPartitions(old_entities, children);
72 "Inactive source copies retain output bit");
75 std::map<EntityHandle, std::array<double, 3>>
coordinates;
76 for (
auto vertex : children.subset_by_type(MBVERTEX)) {
78 CHKERR mb.get_coords(&vertex, 1, x.data());
80 CHKERR mb.set_coords(&vertex, 1, x.data());
83 CHKERR comm->gatherMesh(children.subset_by_type(MBTET), unregistered, last);
85 for (
size_t i = 0;
i != unregistered.
vertexIds.size(); ++
i) {
87 const int producer =
id == 6 ? last : 0;
88 auto expected = output.
points[
id - 1];
89 expected[0] += .01 * producer;
90 if (unregistered.
points[
i] != expected)
92 "Unregistered collection did not select the lowest producer");
94 CHKERR comm->synchroniseByConnectivity(children);
95 for (
const auto &[vertex, expected] :
coordinates) {
96 std::array<double, 3> x;
97 CHKERR mb.get_coords(&vertex, 1, x.data());
100 "Topological synchronisation changed vertex coordinates");
102 const int local_cells = children.subset_by_type(MBTET).size();
104 CHKERR MPI_Allreduce(&local_cells, &global_cells, 1, MPI_INT, MPI_SUM,
106 if (global_cells != 4 ||
107 (m_field.
get_comm_rank() == 0 && local_cells != (last ? 3 : 4)) ||
108 (last && m_field.get_comm_rank() == last && local_cells != 1))
110 "Cell partitions were not inherited");
113 CHKERR mb.tag_get_handle(
"RECONSTRUCTION_EXCHANGE", 1, MB_TYPE_INTEGER,
tag,
114 MB_TAG_DENSE | MB_TAG_CREAT, &zero);
115 for (
auto e : children) {
122 for (
auto e : children) {
126 if (value !=
owner + 10)
128 "New sharing cannot exchange tags");
130 CHKERR pc->check_all_shared_handles();
131 std::array<int, 6> local_owners, owners;
132 local_owners.fill(-1);
133 for (
auto vertex : children.subset_by_type(MBVERTEX)) {
135 CHKERR mb.tag_get_data(
mb.globalId_tag(), &vertex, 1, &
id);
138 local_owners[
id - 1] =
owner;
140 CHKERR MPI_Allreduce(local_owners.data(), owners.data(), owners.size(),
141 MPI_INT, MPI_MAX, m_field.
get_comm());
143 CHKERR comm->gatherMesh(children.subset_by_type(MBTET), gathered, last);
145 if (gathered.
points.size() != 6 || gathered.
cells.size() != 4)
147 "Nonzero-producer collection lost topology or vertex identities");
148 for (
size_t i = 0;
i != gathered.
vertexIds.size(); ++
i) {
150 auto expected = output.
points[
id - 1];
151 expected[0] += .01 * owners[
id - 1];
152 if (owners[
id - 1] < 0 || gathered.
points[
i] != expected)
154 "Collection did not select the owning rank's coordinates");
160int main(
int argc,
char *argv[]) {
162 "Reconnection communication checks\n");
166 const auto error =
run(core);
168 MPI_Abort(PETSC_COMM_WORLD, error);
CGALInterfaceImpl & owner
std::map< EntityHandle, int > index
std::vector< int > source
std::vector< int > parent
std::vector< Cell > cells
std::vector< std::array< double, 3 > > coordinates
#define CATCH_ERRORS
Catch errors.
#define MYPCOMM_INDEX
default communicator number PCOMM
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_ATOM_TEST_INVALID
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
virtual const RefEntity_multiIndex * get_ref_ents() const =0
Get the ref ents object.
FTensor::Index< 'i', SPACE_DIM > i
const double c
speed of light (cm/ns)
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
implementation of Data Operators for Forces and Sources
MoFEMErrorCode run(MoFEM::Interface &m_field)
virtual int get_comm_size() const =0
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =0
virtual int get_comm_rank() const =0
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Deprecated interface functions.
Mesh refinement interface.
std::vector< std::array< int, 4 > > cells
Zero-based point indices.
std::vector< std::array< double, 3 > > points
std::vector< int > vertexIds
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.