9const std::array<std::string, 3> prefixes{
10 "MED_IRRA_ALLIRRA_",
"MED_TEMP_ALLNEUT_",
"MED_CORR_ALLNEUT_"};
12double value(
int quantity,
int step,
const double *x) {
13 return 100 * quantity + 10 * step + x[0] + 2 * x[1] + 3 * x[2];
26 const double coordinates[8][3] = {{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0},
27 {0, 0, 1}, {1, 0, 1}, {1, 1, 1}, {0, 1, 1}};
28 EntityHandle nodes[8], cell;
29 for (
int i = 0;
i != 8; ++
i) {
32 CHKERR mb.tag_set_data(
mb.globalId_tag(), nodes +
i, 1, &
id);
34 CHKERR mb.create_element(MBHEX, nodes, 8, cell);
36 CHKERR mb.tag_set_data(
mb.globalId_tag(), &cell, 1, &
id);
37 for (
int q = 0;
q != 3; ++
q)
38 for (
int step = 0; step != 3; ++step) {
40 CHKERR mb.tag_get_handle((prefixes[
q] + std::to_string(step)).c_str(), 1,
42 MB_TAG_SPARSE | MB_TAG_CREAT);
43 for (
int i = 0;
i != 8; ++
i) {
55 char source_file[PETSC_MAX_PATH_LEN] =
"";
57 source_file,
sizeof(source_file),
nullptr);
58 int local_error =
field.get_comm_rank() == 0 ? writeSource(source_file) : 0;
60 CHKERR MPI_Allreduce(&local_error, &error, 1, MPI_INT, MPI_MAX,
64 const double shift = .01 *
field.get_comm_rank();
65 const double coordinates[4][3] = {{.1 + shift, .1, .1},
68 {.1 + shift, .1, .8}};
69 EntityHandle nodes[4], cell;
70 for (
int i = 0;
i != 4; ++
i) {
72 const int id = 101 + 4 *
field.get_comm_rank() +
i;
73 CHKERR mb.tag_set_data(
mb.globalId_tag(), nodes +
i, 1, &
id);
75 CHKERR mb.create_element(MBTET, nodes, 4, cell);
76 const int id =
field.get_comm_rank() + 101;
77 CHKERR mb.tag_set_data(
mb.globalId_tag(), &cell, 1, &
id);
79 const double default_value = -17;
80 CHKERR mb.tag_get_handle(
"MED_IRRA_ALLIRRA_99", 1, MB_TYPE_DOUBLE, existing,
81 MB_TAG_DENSE | MB_TAG_CREAT, &default_value);
83 CHKERR mb.get_entities_by_handle(0, before);
84 Range target_elements;
85 target_elements.insert(cell);
87 CHKERR transfer.transfer(source_file, target_elements);
89 CHKERR mb.get_entities_by_handle(0, after);
90 CHKERR require(before == after,
"Tag transfer left source entities behind");
91 const auto check = [&]() {
93 for (
int q = 0;
q != 3; ++
q)
94 for (
int step = 0; step != 3; ++step) {
96 CHKERR mb.tag_get_handle((prefixes[
q] + std::to_string(step)).c_str(),
100 for (
int i = 0;
i != 4; ++
i)
103 "Environmental snapshot interpolation is incorrect");
106 CHKERR mb.tag_get_data(existing, nodes, 4, untouched);
107 for (
double v : untouched)
108 CHKERR require(
v == default_value,
109 "Target-only snapshot was overwritten");
113 for (
int i = 0;
i != 4; ++
i) {
116 CHKERR mb.set_coords(nodes +
i, 1, x.data());
118 CHKERR PetscPushErrorHandler(PetscReturnErrorHandler,
nullptr);
119 error = transfer.transfer(source_file, target_elements);
120 CHKERR PetscPopErrorHandler();
121 CHKERR require(error != 0,
"Transfer accepted vertices outside the source");
123 CHKERR mb.get_entities_by_handle(0, after);
124 CHKERR require(before == after,
125 "Failed transfer left source entities behind");
126 MOFEM_LOG(
"WORLD", Sev::inform) <<
"UMAT tag transfer checks passed";
131int main(
int argc,
char **argv) {
Reusable transfer of ageing environmental snapshot tags.
std::vector< std::array< double, 3 > > coordinates
SmartPetscObj< Vec > values
#define CATCH_ERRORS
Catch errors.
#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.
#define MOFEM_LOG(channel, severity)
Log.
FTensor::Index< 'i', SPACE_DIM > i
const double v
phase velocity of light in medium (cm/ns)
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
MoFEMErrorCode run(MoFEM::Interface &m_field)
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.