From b38e3526ffbbafbabe85a537bbd7b56a63120d20 Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Wed, 6 Apr 2022 16:26:11 -0600 Subject: [PATCH 001/236] EXODUS: refactor field metadata attribute output --- .../exodus/src/ex_put_field_metadata.c | 72 ++++++++----------- 1 file changed, 28 insertions(+), 44 deletions(-) diff --git a/packages/seacas/libraries/exodus/src/ex_put_field_metadata.c b/packages/seacas/libraries/exodus/src/ex_put_field_metadata.c index e2a5cc5b6f..efeac0fb09 100644 --- a/packages/seacas/libraries/exodus/src/ex_put_field_metadata.c +++ b/packages/seacas/libraries/exodus/src/ex_put_field_metadata.c @@ -92,41 +92,25 @@ int ex_put_field_metadata(int exoid, const ex_field field) return EX_NOERR; } -int ex__put_basis_i_attribute(int exoid, const char *basis_name, const char *type, - ex_entity_type entity_type, ex_entity_id id, int cardinality, - const int *basis_entry) +int ex__put_basis_attribute(int exoid, const char *basis_name, const char *type, + ex_entity_type entity_type, ex_entity_id id, ex_type value_type, + int cardinality, const void *basis_entry) { char attribute_name[NC_MAX_NAME + 1]; static char *basis_template = "Basis@%s"; - int status; if (basis_entry != NULL) { sprintf(attribute_name, basis_template, type); - if ((status = ex_put_integer_attribute(exoid, entity_type, id, attribute_name, cardinality, - basis_entry)) != EX_NOERR) { - char errmsg[MAX_ERR_LENGTH]; - snprintf(errmsg, MAX_ERR_LENGTH, - "ERROR: failed to store %s for basis '%s' on %s with id %" PRId64 " in file id %d", - type, basis_name, ex_name_of_object(entity_type), id, exoid); - ex_err_fn(exoid, __func__, errmsg, status); - return EX_FATAL; + int status; + if (value_type == EX_INTEGER) { + status = ex_put_integer_attribute(exoid, entity_type, id, attribute_name, cardinality, + basis_entry); } - } - return EX_NOERR; -} - -int ex__put_basis_d_attribute(int exoid, const char *basis_name, const char *type, - ex_entity_type entity_type, ex_entity_id id, int cardinality, - const double *basis_entry) -{ - char attribute_name[NC_MAX_NAME + 1]; - static char *basis_template = "Basis@%s"; - int status; - - if (basis_entry != NULL) { - sprintf(attribute_name, basis_template, type); - if ((status = ex_put_double_attribute(exoid, entity_type, id, attribute_name, cardinality, - basis_entry)) != EX_NOERR) { + else if (value_type == EX_DOUBLE) { + status = + ex_put_double_attribute(exoid, entity_type, id, attribute_name, cardinality, basis_entry); + } + if (status != EX_NOERR) { char errmsg[MAX_ERR_LENGTH]; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store %s for basis '%s' on %s with id %" PRId64 " in file id %d", @@ -166,43 +150,43 @@ int ex_put_basis_metadata(int exoid, ex_entity_type entity_type, ex_entity_id en return EX_FATAL; } - if (ex__put_basis_i_attribute(exoid, basis.name, "cardinality", entity_type, entity_id, 1, - &basis.cardinality) != EX_NOERR) { + if (ex__put_basis_attribute(exoid, basis.name, "cardinality", entity_type, entity_id, EX_INTEGER, + 1, &basis.cardinality) != EX_NOERR) { return EX_FATAL; } - if (ex__put_basis_i_attribute(exoid, basis.name, "subc_dim", entity_type, entity_id, - basis.cardinality, basis.subc_dim) != EX_NOERR) { + if (ex__put_basis_attribute(exoid, basis.name, "subc_dim", entity_type, entity_id, EX_INTEGER, + basis.cardinality, basis.subc_dim) != EX_NOERR) { return EX_FATAL; } - if (ex__put_basis_i_attribute(exoid, basis.name, "subc_ordinal", entity_type, entity_id, - basis.cardinality, basis.subc_ordinal) != EX_NOERR) { + if (ex__put_basis_attribute(exoid, basis.name, "subc_ordinal", entity_type, entity_id, EX_INTEGER, + basis.cardinality, basis.subc_ordinal) != EX_NOERR) { return EX_FATAL; } - if (ex__put_basis_i_attribute(exoid, basis.name, "subc_dof_ordinal", entity_type, entity_id, - basis.cardinality, basis.subc_dof_ordinal) != EX_NOERR) { + if (ex__put_basis_attribute(exoid, basis.name, "subc_dof_ordinal", entity_type, entity_id, + EX_INTEGER, basis.cardinality, basis.subc_dof_ordinal) != EX_NOERR) { return EX_FATAL; } - if (ex__put_basis_i_attribute(exoid, basis.name, "subc_num_dof", entity_type, entity_id, - basis.cardinality, basis.subc_num_dof) != EX_NOERR) { + if (ex__put_basis_attribute(exoid, basis.name, "subc_num_dof", entity_type, entity_id, EX_INTEGER, + basis.cardinality, basis.subc_num_dof) != EX_NOERR) { return EX_FATAL; } - if (ex__put_basis_d_attribute(exoid, basis.name, "xi", entity_type, entity_id, basis.cardinality, - basis.xi) != EX_NOERR) { + if (ex__put_basis_attribute(exoid, basis.name, "xi", entity_type, entity_id, EX_DOUBLE, + basis.cardinality, basis.xi) != EX_NOERR) { return EX_FATAL; } - if (ex__put_basis_d_attribute(exoid, basis.name, "eta", entity_type, entity_id, basis.cardinality, - basis.eta) != EX_NOERR) { + if (ex__put_basis_attribute(exoid, basis.name, "eta", entity_type, entity_id, EX_DOUBLE, + basis.cardinality, basis.eta) != EX_NOERR) { return EX_FATAL; } - if (ex__put_basis_d_attribute(exoid, basis.name, "zeta", entity_type, entity_id, - basis.cardinality, basis.zeta) != EX_NOERR) { + if (ex__put_basis_attribute(exoid, basis.name, "zeta", entity_type, entity_id, EX_DOUBLE, + basis.cardinality, basis.zeta) != EX_NOERR) { return EX_FATAL; } return EX_NOERR; From 313d43dcb1a276242e3e1147d33821040768adc7 Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Wed, 6 Apr 2022 16:26:39 -0600 Subject: [PATCH 002/236] EXODUS: Beginnings of basis read --- .../libraries/exodus/include/exodusII.h | 10 +++- .../exodus/src/ex_get_field_metadata.c | 57 +++++++++++++++++++ .../exodus/test/testrd-field-metadata.c | 12 ++++ 3 files changed, 76 insertions(+), 3 deletions(-) diff --git a/packages/seacas/libraries/exodus/include/exodusII.h b/packages/seacas/libraries/exodus/include/exodusII.h index f980c37632..14caba1bb7 100644 --- a/packages/seacas/libraries/exodus/include/exodusII.h +++ b/packages/seacas/libraries/exodus/include/exodusII.h @@ -1021,13 +1021,17 @@ EXODUS_EXPORT int ex_get_blobs(int exoid, struct ex_blob *blobs); EXODUS_EXPORT int ex_put_field_metadata(int exoid, const ex_field field); EXODUS_EXPORT int ex_put_field_suffices(int exoid, const ex_field field, const char *suffices); -EXODUS_EXPORT int ex_put_basis_metadata(int exoid, ex_entity_type entity_type, ex_entity_id id, - const ex_basis basis); -EXODUS_EXPORT int ex_put_quadrature_metadata(int exoid, const ex_field field); EXODUS_EXPORT int ex_get_field_metadata(int exoid, ex_field *field); EXODUS_EXPORT int ex_get_field_metadata_count(int exoid, ex_entity_type obj_type, ex_entity_id id); EXODUS_EXPORT int ex_get_field_suffices(int exoid, const ex_field field, char *suffices); +EXODUS_EXPORT int ex_put_basis_metadata(int exoid, ex_entity_type entity_type, ex_entity_id id, + const ex_basis basis); +EXODUS_EXPORT int ex_get_basis_metadata(int exoid, ex_entity_type entity_type, + ex_entity_id entity_id, ex_basis *basis); + +EXODUS_EXPORT int ex_put_quadrature_metadata(int exoid, const ex_field field); + /* Write arbitrary integer, double, or text attributes on an entity */ EXODUS_EXPORT int ex_put_attribute(int exoid, const ex_attribute attributes); EXODUS_EXPORT int ex_put_attributes(int exoid, size_t attr_count, const ex_attribute *attributes); diff --git a/packages/seacas/libraries/exodus/src/ex_get_field_metadata.c b/packages/seacas/libraries/exodus/src/ex_get_field_metadata.c index b950368a40..2e48c86941 100644 --- a/packages/seacas/libraries/exodus/src/ex_get_field_metadata.c +++ b/packages/seacas/libraries/exodus/src/ex_get_field_metadata.c @@ -245,3 +245,60 @@ int ex_get_field_metadata(int exoid, ex_field *field) } EX_FUNC_LEAVE(EX_NOERR); } + +int ex__get_basis_name(int exoid, ex_entity_type entity_type, ex_entity_id entity_id, char *name) +{ + int varid; + if (entity_type == EX_GLOBAL) { + varid = NC_GLOBAL; + } + else { + varid = ex__get_varid(exoid, entity_type, entity_id); + if (varid <= 0) { + /* Error message handled in ex__get_varid */ + EX_FUNC_LEAVE(varid); + } + } + + int status; + if ((status = nc_get_att(exoid, varid, "Basis@name", name)) != NC_NOERR) { + char errmsg[MAX_ERR_LENGTH]; + snprintf(errmsg, MAX_ERR_LENGTH, + "ERROR: failed to read basis name on %s with id %" PRId64 " in file id %d", + ex_name_of_object(entity_type), entity_id, exoid); + ex_err_fn(exoid, __func__, errmsg, status); + return EX_FATAL; + } + return EX_NOERR; +} + +int ex_get_basis_metadata(int exoid, ex_entity_type entity_type, ex_entity_id entity_id, + ex_basis *basis) +{ + /* + * -- There is at most 1 basis definition on an entity. + * -- If this function is called an there is no basis metadata on the + * entity, it will return EX_NOTFOUND; otherwise it will populate + * (portions of) `basis` and return EX_NOERR. + * + * -- name and cardinality will be populated if empty at time of call. + * -- other fields will be populated if they are non-null. + * -- so, can call first time with empty `basis' with 'NULL' on all pointer members. + * - `name` and `cardinality` will be populated + * - Then malloc/calloc the pointer members that you want populated + * - then call again. `name` will not be populated if non-empty. + * - `cardinality` will be checked and must be >= to value on database. + * - assumed to be the size of the pointer member allocated space. + * - if > value on database, will be set to value on database. + * - if < value on database, error unless 0. + * - pointer members will be populated if non-NULL. + */ + + int status; + if ((status = ex__get_basis_name(exoid, entity_type, entity_id, basis->name)) != EX_NOERR) { + /* Error message printed in `ex__get_basis_name` */ + return EX_NOTFOUND; + } + fprintf(stderr, "Basis is named '%s'\n", basis->name); + return EX_NOERR; +} diff --git a/packages/seacas/libraries/exodus/test/testrd-field-metadata.c b/packages/seacas/libraries/exodus/test/testrd-field-metadata.c index daaa219fd3..6809bd8d30 100644 --- a/packages/seacas/libraries/exodus/test/testrd-field-metadata.c +++ b/packages/seacas/libraries/exodus/test/testrd-field-metadata.c @@ -65,6 +65,18 @@ int main(int argc, char **argv) fields[1].entity_id = 11; EXCHECK(ex_get_field_metadata(exoid, fields)); + struct ex_basis basis = (ex_basis){.name = "", + .cardinality = 0, + .subc_dim = NULL, + .subc_ordinal = NULL, + .subc_dof_ordinal = NULL, + .subc_num_dof = NULL, + .xi = NULL, + .eta = NULL, + .zeta = NULL}; + EXCHECK(ex_get_basis_metadata(exoid, EX_ELEM_BLOCK, 10, &basis)); + EXCHECK(ex_get_basis_metadata(exoid, EX_ELEM_BLOCK, 11, &basis)); + int error = ex_close(exoid); printf("\nafter ex_close, error = %3d\n", error); return 0; From 665558e7923341cb0490222c154894fa97cc5a92 Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Thu, 7 Apr 2022 09:45:21 -0600 Subject: [PATCH 003/236] EXODUS: basis query --- .../exodus/src/ex_get_field_metadata.c | 139 +++++++++++------- .../seacas/libraries/exodus/src/ex_utils.c | 1 - .../exodus/test/testrd-field-metadata.c | 19 ++- 3 files changed, 104 insertions(+), 55 deletions(-) diff --git a/packages/seacas/libraries/exodus/src/ex_get_field_metadata.c b/packages/seacas/libraries/exodus/src/ex_get_field_metadata.c index 2e48c86941..ed35607212 100644 --- a/packages/seacas/libraries/exodus/src/ex_get_field_metadata.c +++ b/packages/seacas/libraries/exodus/src/ex_get_field_metadata.c @@ -87,8 +87,7 @@ static int ex__get_attribute_count(int exoid, ex_entity_type obj_type, ex_entity if ((status = nc_inq(exoid, NULL, NULL, &att_count, NULL)) != NC_NOERR) { char errmsg[MAX_ERR_LENGTH]; - snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get GLOBAL attribute count in file id %d", - exoid); + snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get GLOBAL attribute count"); ex_err_fn(exoid, __func__, errmsg, status); return EX_FATAL; } @@ -103,8 +102,8 @@ static int ex__get_attribute_count(int exoid, ex_entity_type obj_type, ex_entity if ((status = nc_inq_var(exoid, *varid, NULL, NULL, NULL, NULL, &att_count)) != NC_NOERR) { char errmsg[MAX_ERR_LENGTH]; snprintf(errmsg, MAX_ERR_LENGTH, - "ERROR: failed to get attribute count on %s with id %" PRId64 " in file id %d", - ex_name_of_object(obj_type), id, exoid); + "ERROR: failed to get attribute count on %s with id %" PRId64, + ex_name_of_object(obj_type), id); ex_err_fn(exoid, __func__, errmsg, status); return EX_FATAL; } @@ -120,9 +119,8 @@ int ex_get_field_metadata_count(int exoid, ex_entity_type obj_type, ex_entity_id int att_count = ex__get_attribute_count(exoid, obj_type, id, &varid); if (att_count < 0) { char errmsg[MAX_ERR_LENGTH]; - snprintf(errmsg, MAX_ERR_LENGTH, - "ERROR: Negative attribute count (%d) on %s with id %" PRId64 " in file id %d", - att_count, ex_name_of_object(obj_type), id, exoid); + snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Negative attribute count (%d) on %s with id %" PRId64, + att_count, ex_name_of_object(obj_type), id); ex_err_fn(exoid, __func__, errmsg, EX_INTERNAL); EX_FUNC_LEAVE(EX_FATAL); } @@ -135,8 +133,8 @@ int ex_get_field_metadata_count(int exoid, ex_entity_type obj_type, ex_entity_id if ((status = nc_inq_attname(exoid, varid, i, name)) != NC_NOERR) { char errmsg[MAX_ERR_LENGTH]; snprintf(errmsg, MAX_ERR_LENGTH, - "ERROR: failed to get attribute named %s on %s with id %" PRId64 " in file id %d", - name, ex_name_of_object(obj_type), id, exoid); + "ERROR: failed to get attribute named %s on %s with id %" PRId64, name, + ex_name_of_object(obj_type), id); ex_err_fn(exoid, __func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } @@ -156,9 +154,8 @@ int ex_get_field_metadata(int exoid, ex_field *field) int att_count = ex__get_attribute_count(exoid, field->entity_type, field->entity_id, &varid); if (att_count < 0) { char errmsg[MAX_ERR_LENGTH]; - snprintf(errmsg, MAX_ERR_LENGTH, - "ERROR: Negative attribute count (%d) on %s with id %" PRId64 " in file id %d", - att_count, ex_name_of_object(field->entity_type), field->entity_id, exoid); + snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Negative attribute count (%d) on %s with id %" PRId64, + att_count, ex_name_of_object(field->entity_type), field->entity_id); ex_err_fn(exoid, __func__, errmsg, EX_INTERNAL); EX_FUNC_LEAVE(EX_FATAL); } @@ -171,8 +168,8 @@ int ex_get_field_metadata(int exoid, ex_field *field) if ((status = nc_inq_attname(exoid, varid, i, attr_name)) != NC_NOERR) { char errmsg[MAX_ERR_LENGTH]; snprintf(errmsg, MAX_ERR_LENGTH, - "ERROR: failed to get attribute named %s on %s with id %" PRId64 " in file id %d", - attr_name, ex_name_of_object(field->entity_type), field->entity_id, exoid); + "ERROR: failed to get attribute named %s on %s with id %" PRId64, attr_name, + ex_name_of_object(field->entity_type), field->entity_id); ex_err_fn(exoid, __func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } @@ -194,9 +191,8 @@ int ex_get_field_metadata(int exoid, ex_field *field) if ((status = nc_inq_att(exoid, varid, attr_name, &type, &val_count)) != NC_NOERR) { char errmsg[MAX_ERR_LENGTH]; snprintf(errmsg, MAX_ERR_LENGTH, - "ERROR: failed to get parameters for attribute named %s on %s with id %" PRId64 - " in file id %d", - attr_name, ex_name_of_object(field->entity_type), field->entity_id, exoid); + "ERROR: failed to get parameters for attribute named %s on %s with id %" PRId64, + attr_name, ex_name_of_object(field->entity_type), field->entity_id); ex_err_fn(exoid, __func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } @@ -225,9 +221,8 @@ int ex_get_field_metadata(int exoid, ex_field *field) char errmsg[MAX_ERR_LENGTH]; snprintf( errmsg, MAX_ERR_LENGTH, - "ERROR: Invalid field metadata attribute type %s on field %s on %s with id %" PRId64 - " in file id %d", - fld_type, fld_name, ex_name_of_object(field->entity_type), field->entity_id, exoid); + "ERROR: Invalid field metadata attribute type %s on field %s on %s with id %" PRId64, + fld_type, fld_name, ex_name_of_object(field->entity_type), field->entity_id); ex_err_fn(exoid, __func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } @@ -235,9 +230,8 @@ int ex_get_field_metadata(int exoid, ex_field *field) char errmsg[MAX_ERR_LENGTH]; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to read field metadata attribute type %s on field %s on %s with id " - "%" PRId64 " in file id %d", - fld_type, fld_name, ex_name_of_object(field->entity_type), field->entity_id, - exoid); + "%" PRId64, + fld_type, fld_name, ex_name_of_object(field->entity_type), field->entity_id); ex_err_fn(exoid, __func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); } @@ -246,32 +240,6 @@ int ex_get_field_metadata(int exoid, ex_field *field) EX_FUNC_LEAVE(EX_NOERR); } -int ex__get_basis_name(int exoid, ex_entity_type entity_type, ex_entity_id entity_id, char *name) -{ - int varid; - if (entity_type == EX_GLOBAL) { - varid = NC_GLOBAL; - } - else { - varid = ex__get_varid(exoid, entity_type, entity_id); - if (varid <= 0) { - /* Error message handled in ex__get_varid */ - EX_FUNC_LEAVE(varid); - } - } - - int status; - if ((status = nc_get_att(exoid, varid, "Basis@name", name)) != NC_NOERR) { - char errmsg[MAX_ERR_LENGTH]; - snprintf(errmsg, MAX_ERR_LENGTH, - "ERROR: failed to read basis name on %s with id %" PRId64 " in file id %d", - ex_name_of_object(entity_type), entity_id, exoid); - ex_err_fn(exoid, __func__, errmsg, status); - return EX_FATAL; - } - return EX_NOERR; -} - int ex_get_basis_metadata(int exoid, ex_entity_type entity_type, ex_entity_id entity_id, ex_basis *basis) { @@ -294,11 +262,76 @@ int ex_get_basis_metadata(int exoid, ex_entity_type entity_type, ex_entity_id en * - pointer members will be populated if non-NULL. */ - int status; - if ((status = ex__get_basis_name(exoid, entity_type, entity_id, basis->name)) != EX_NOERR) { - /* Error message printed in `ex__get_basis_name` */ + int status; + char errmsg[MAX_ERR_LENGTH]; + int varid; + + if (entity_type == EX_GLOBAL) { + varid = NC_GLOBAL; + } + else { + varid = ex__get_varid(exoid, entity_type, entity_id); + if (varid <= 0) { + /* Error message handled in ex__get_varid */ + return varid; + } + } + + /* Get name of the basis (if it exists) */ + if ((status = nc_get_att(exoid, varid, "Basis@name", basis->name)) != NC_NOERR) { + /* Basis not found... Return EX_NOTFOUND */ + snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to read basis name on %s with id %" PRId64, + ex_name_of_object(entity_type), entity_id); + ex_err_fn(exoid, __func__, errmsg, status); return EX_NOTFOUND; } - fprintf(stderr, "Basis is named '%s'\n", basis->name); + + /* Get the basis cardinality... We know there is a basis and cardinality is required parameter. */ + const char attr_name[] = "Basis@cardinality"; + int cardinality[1]; + if ((status = nc_get_att(exoid, varid, attr_name, cardinality)) != NC_NOERR) { + snprintf(errmsg, MAX_ERR_LENGTH, + "ERROR: failed to get basis cardinality on %s with id %" PRId64, + ex_name_of_object(entity_type), entity_id); + ex_err_fn(exoid, __func__, errmsg, status); + return EX_FATAL; + } + + if (basis->cardinality != 0 && basis->cardinality < cardinality[0]) { + snprintf(errmsg, MAX_ERR_LENGTH, + "ERROR: Basis cardinality on the database is %d, but the value passed in the basis " + "struct is %d.\n\tThis indicates that" + " not enough memory has been allocated to store the other basis fields\n\ton %s with " + "id %" PRId64 ".", + cardinality[0], basis->cardinality, ex_name_of_object(entity_type), entity_id); + ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM); + return EX_FATAL; + } + basis->cardinality = cardinality[0]; + fprintf(stderr, "Basis is named '%s' with cardinality %d\n", basis->name, basis->cardinality); + + /* Now, for each non-NULL parameter of `basis`, query the data... */ + if (basis->subc_dim != NULL) { + status = nc_get_att(exoid, varid, "Basis@subc_dim", basis->subc_dim); + } + if (basis->subc_ordinal != NULL) { + status = nc_get_att(exoid, varid, "Basis@subc_dim", basis->subc_ordinal); + } + if (basis->subc_dof_ordinal != NULL) { + status = nc_get_att(exoid, varid, "Basis@subc_dim", basis->subc_dof_ordinal); + } + if (basis->subc_num_dof != NULL) { + status = nc_get_att(exoid, varid, "Basis@subc_dim", basis->subc_num_dof); + } + if (basis->xi != NULL) { + status = nc_get_att(exoid, varid, "Basis@subc_dim", basis->xi); + } + if (basis->eta != NULL) { + status = nc_get_att(exoid, varid, "Basis@subc_dim", basis->eta); + } + if (basis->zeta != NULL) { + status = nc_get_att(exoid, varid, "Basis@subc_dim", basis->zeta); + } + return EX_NOERR; } diff --git a/packages/seacas/libraries/exodus/src/ex_utils.c b/packages/seacas/libraries/exodus/src/ex_utils.c index 7f130332dc..d9eedcd8e3 100644 --- a/packages/seacas/libraries/exodus/src/ex_utils.c +++ b/packages/seacas/libraries/exodus/src/ex_utils.c @@ -2379,4 +2379,3 @@ int ex__get_varid(int exoid, ex_entity_type obj_type, ex_entity_id id) } return varid; } - diff --git a/packages/seacas/libraries/exodus/test/testrd-field-metadata.c b/packages/seacas/libraries/exodus/test/testrd-field-metadata.c index 6809bd8d30..5f9db4f018 100644 --- a/packages/seacas/libraries/exodus/test/testrd-field-metadata.c +++ b/packages/seacas/libraries/exodus/test/testrd-field-metadata.c @@ -74,7 +74,24 @@ int main(int argc, char **argv) .xi = NULL, .eta = NULL, .zeta = NULL}; - EXCHECK(ex_get_basis_metadata(exoid, EX_ELEM_BLOCK, 10, &basis)); + /* Query basis on a block where it doesn't exist */ + int status = ex_get_basis_metadata(exoid, EX_ELEM_BLOCK, 10, &basis); + if (status != EX_NOTFOUND) { + fprintf(stderr, + "Error calling ex_get_basis for non-existant basis. Should return EX_NOTFOUND"); + } + + EXCHECK(ex_get_basis_metadata(exoid, EX_ELEM_BLOCK, 11, &basis)); + /* + * Now, allocate memory for all pointer members of basis and call to populate... + */ + basis.subc_dim = calloc(basis.cardinality, sizeof(int)); + basis.subc_ordinal = calloc(basis.cardinality, sizeof(int)); + basis.subc_dof_ordinal = calloc(basis.cardinality, sizeof(int)); + basis.subc_num_dof = calloc(basis.cardinality, sizeof(int)); + basis.xi = calloc(basis.cardinality, sizeof(double)); + basis.eta = calloc(basis.cardinality, sizeof(double)); + basis.zeta = calloc(basis.cardinality, sizeof(double)); EXCHECK(ex_get_basis_metadata(exoid, EX_ELEM_BLOCK, 11, &basis)); int error = ex_close(exoid); From 1da4a6caf7109b29787f0570b6093d226fea2e80 Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Thu, 7 Apr 2022 14:31:53 -0600 Subject: [PATCH 004/236] EXODUS: these got lost with some branch mishaps --- .../libraries/exodus/include/exodusII.h | 98 ++++- .../libraries/exodus/src/ex_field_utils.c | 350 ++++++++++++++++++ .../libraries/exodus/src/ex_get_attribute.c | 57 +-- .../libraries/exodus/src/ex_put_attribute.c | 82 ---- .../libraries/exodus/test/CMakeLists.txt | 2 + .../exodus/test/testwt-field-metadata.c | 194 ++++++++++ 6 files changed, 640 insertions(+), 143 deletions(-) create mode 100644 packages/seacas/libraries/exodus/src/ex_field_utils.c create mode 100644 packages/seacas/libraries/exodus/test/testwt-field-metadata.c diff --git a/packages/seacas/libraries/exodus/include/exodusII.h b/packages/seacas/libraries/exodus/include/exodusII.h index 0ae0c91162..14caba1bb7 100644 --- a/packages/seacas/libraries/exodus/include/exodusII.h +++ b/packages/seacas/libraries/exodus/include/exodusII.h @@ -49,6 +49,9 @@ #include #include +/** Maximum length of name permitted by NetCDF */ +#define EX_MAX_NAME NC_MAX_NAME + #ifndef NC_INT64 #error "NetCDF version 4.1.2 or later is required." #endif @@ -284,6 +287,84 @@ enum ex_entity_type { }; typedef enum ex_entity_type ex_entity_type; +enum ex_field_type { + EX_FIELD_TYPE_INVALID = 0, + EX_FIELD_TYPE_USER_DEFINED, + EX_FIELD_TYPE_SEQUENCE, + EX_BASIS, + EX_QUADRATURE, + EX_SCALAR, + EX_VECTOR_1D, + EX_VECTOR_2D, + EX_VECTOR_3D, + EX_QUATERNION_2D, + EX_QUATERNION_3D, + EX_FULL_TENSOR_36, + EX_FULL_TENSOR_32, + EX_FULL_TENSOR_22, + EX_FULL_TENSOR_16, + EX_FULL_TENSOR_12, + EX_SYM_TENSOR_33, + EX_SYM_TENSOR_31, + EX_SYM_TENSOR_21, + EX_SYM_TENSOR_13, + EX_SYM_TENSOR_11, + EX_SYM_TENSOR_10, + EX_ASYM_TENSOR_03, + EX_ASYM_TENSOR_02, + EX_ASYM_TENSOR_01, + EX_MATRIX_2X2, + EX_MATRIX_3X3 +}; +typedef enum ex_field_type ex_field_type; + +#define EX_MAX_FIELD_NESTING 4 +typedef struct ex_field +{ + ex_entity_type entity_type; + int64_t entity_id; + char name[EX_MAX_NAME + 1]; /* Name of the field */ + int nesting; /* Number of composite fields (vector at each quadrature point = 2) */ + ex_field_type type[EX_MAX_FIELD_NESTING]; /* ex_field_type of each nested field */ + int cardinality[EX_MAX_FIELD_NESTING]; /* 0 to calculate based on type */ + char component_separator[EX_MAX_FIELD_NESTING + + 1]; /* empty defaults to '_'; +1 so can be a string... */ +} ex_field; + +typedef struct ex_basis +{ + /* + * subc_dim: dimension of the subcell associated with the specified DoF ordinal -- 0 node, 1 edge, + * 2 face, 3 volume [Range: 0..3] subc_ordinal: ordinal of the subcell relative to its parent cell + * -- 0..n for each ordinal with the same subc dim [Range: <= DoF ordinal] subc_dof_ordinal: + * ordinal of the DoF relative to the subcell subc_num_dof: cardinality of the DoF set associated + * with this subcell. xi, eta, mu (ξ, η, ζ): Parametric coordinate location of the DoF (Only first + * ndim values are valid) + */ + char name[EX_MAX_NAME + 1]; + int cardinality; /* number of `basis` points == dimension of non-null subc_*, xi, eta, mu */ + int *subc_dim; + int *subc_ordinal; + int *subc_dof_ordinal; + int *subc_num_dof; + double *xi; + double *eta; + double *zeta; +} ex_basis; + +typedef struct ex_quadrature +{ + char name[EX_MAX_NAME + 1]; + int cardinality; /* Number of quadrature points */ + int dimension; /* 1,2,3 -- spatial dimension of points */ + double *xi; /* xi (x) coordinate of points; dimension = cardinality or NULL */ + double * + eta; /* eta (y) coordinate of points; dimension = cardinality if dimension = 2 or 3 or NULL */ + double + *zeta; /* zeta (z) coordinate of points; dimension = cardinality if dimension == 3. or NULL */ + double *weight; /* weights for each point; dimension = cardinality or NULL */ +} ex_quadrature; + /*! * ex_opts() function codes - codes are OR'ed into exopts */ @@ -307,9 +388,6 @@ typedef enum ex_options ex_options; * @{ */ -/** Maximum length of name permitted by NetCDF */ -#define EX_MAX_NAME NC_MAX_NAME - /** Maximum length of QA record, element type name */ #define MAX_STR_LENGTH 32L /** Default maximum length of an entity name, attribute name, variable name. @@ -371,10 +449,11 @@ typedef struct ex_attribute { ex_entity_type entity_type; int64_t entity_id; - char name[NC_MAX_NAME + 1]; + char name[EX_MAX_NAME + 1]; ex_type type; /* int, double, text */ size_t value_count; - void *values; /* not accessed if NULL */ + void *values; /* not accessed if NULL */ + int variable_index; /* For variable attributes only */ } ex_attribute; typedef struct ex_blob @@ -717,6 +796,9 @@ ex_put_loadbal_param_cc(int exoid, /* NetCDF/Exodus file ID /* Utility function to replace strncpy, strcpy -- guarantee null termination */ char *ex_copy_string(char *dest, char const *source, size_t elements); +/* Utility function to find variable to store entity attribute on */ +int ex__get_varid(int exoid, ex_entity_type obj_type, ex_entity_id id); + /*! * \addtogroup ModelDescription * @{ @@ -1199,6 +1281,12 @@ EXODUS_EXPORT int ex_put_elem_cmap(int exoid, /**< NetCDF/Exodus int processor /**< This processor ID */ ); +EXODUS_EXPORT const char *ex_field_component_name(ex_field_type field_type, int component); +EXODUS_EXPORT int ex_field_cardinality(const ex_field_type field_type); +EXODUS_EXPORT const char *const ex_field_name(const ex_field_type field_type); +EXODUS_EXPORT ex_field_type ex_field_string_to_field_type(const char *field_name); +EXODUS_EXPORT const char *const ex_field_type_enum_to_string(const ex_field_type field_type); + /*! @} */ /* Deprecated Code Handling Options: diff --git a/packages/seacas/libraries/exodus/src/ex_field_utils.c b/packages/seacas/libraries/exodus/src/ex_field_utils.c new file mode 100644 index 0000000000..8e3b6abbe6 --- /dev/null +++ b/packages/seacas/libraries/exodus/src/ex_field_utils.c @@ -0,0 +1,350 @@ +/* + * Copyright(C) 1999-2022 National Technology & Engineering Solutions + * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with + * NTESS, the U.S. Government retains certain rights in this software. + * + * See packages/seacas/LICENSE for details + */ + +#include "exodusII.h" // for ex_err, etc +#include "exodusII_int.h" // for EX_FATAL, etc +#include + +#define SIZE(X) sizeof(X) / sizeof(X[0]) + +static void verify_valid_component(int component, size_t cardinality, size_t suffix_size) +{ + assert(cardinality == suffix_size); + assert(component - 1 < suffix_size); +} + +const char *ex_field_component_name(ex_field_type field_type, int component) +{ + static char *const X = "x"; + static char *const Y = "y"; + static char *const Z = "z"; + static char *const Q = "q"; + static char *const S = "s"; + + static char *const XX = "xx"; + static char *const YY = "yy"; + static char *const ZZ = "zz"; + static char *const XY = "xy"; + static char *const YZ = "yz"; + static char *const ZX = "zx"; + static char *const YX = "yx"; + static char *const ZY = "zy"; + static char *const XZ = "xz"; + + switch (field_type) { + case EX_VECTOR_1D: { + static const char *suffix[] = {X}; + verify_valid_component(component, ex_field_cardinality(field_type), SIZE(suffix)); + return suffix[component - 1]; + } + case EX_VECTOR_2D: { + static const char *suffix[] = {X, Y}; + verify_valid_component(component, ex_field_cardinality(field_type), SIZE(suffix)); + return suffix[component - 1]; + } + case EX_VECTOR_3D: { + static const char *suffix[] = {X, Y, Z}; + verify_valid_component(component, ex_field_cardinality(field_type), SIZE(suffix)); + return suffix[component - 1]; + } + case EX_QUATERNION_2D: { + static const char *suffix[] = {S, Q}; + verify_valid_component(component, ex_field_cardinality(field_type), SIZE(suffix)); + return suffix[component - 1]; + } + case EX_QUATERNION_3D: { + static const char *suffix[] = {X, Y, Z, Q}; + verify_valid_component(component, ex_field_cardinality(field_type), SIZE(suffix)); + return suffix[component - 1]; + } + case EX_FULL_TENSOR_36: { + static const char *suffix[] = {XX, YY, ZZ, XY, YZ, ZX, YX, ZY, XZ}; + verify_valid_component(component, ex_field_cardinality(field_type), SIZE(suffix)); + return suffix[component - 1]; + } + case EX_FULL_TENSOR_32: { + static const char *suffix[] = {XX, YY, ZZ, XY, YX}; + verify_valid_component(component, ex_field_cardinality(field_type), SIZE(suffix)); + return suffix[component - 1]; + } + case EX_FULL_TENSOR_22: { + static const char *suffix[] = {XX, YY, XY, YX}; + verify_valid_component(component, ex_field_cardinality(field_type), SIZE(suffix)); + return suffix[component - 1]; + } + case EX_FULL_TENSOR_16: { + static const char *suffix[] = {XX, XY, YZ, ZX, YX, ZY, XZ}; + verify_valid_component(component, ex_field_cardinality(field_type), SIZE(suffix)); + return suffix[component - 1]; + } + case EX_FULL_TENSOR_12: { + static const char *suffix[] = {XX, XY, YX}; + verify_valid_component(component, ex_field_cardinality(field_type), SIZE(suffix)); + return suffix[component - 1]; + } + case EX_SYM_TENSOR_33: { + static const char *suffix[] = {XX, YY, ZZ, XY, YZ, ZX}; + verify_valid_component(component, ex_field_cardinality(field_type), SIZE(suffix)); + return suffix[component - 1]; + } + case EX_SYM_TENSOR_31: { + static const char *suffix[] = {XX, YY, ZZ, XY}; + verify_valid_component(component, ex_field_cardinality(field_type), SIZE(suffix)); + return suffix[component - 1]; + } + case EX_SYM_TENSOR_21: { + static const char *suffix[] = {XX, YY, XY}; + verify_valid_component(component, ex_field_cardinality(field_type), SIZE(suffix)); + return suffix[component - 1]; + } + case EX_SYM_TENSOR_13: { + static const char *suffix[] = {XX, XY, YZ, ZX}; + verify_valid_component(component, ex_field_cardinality(field_type), SIZE(suffix)); + return suffix[component - 1]; + } + case EX_SYM_TENSOR_11: { + static const char *suffix[] = {XX, XY}; + verify_valid_component(component, ex_field_cardinality(field_type), SIZE(suffix)); + return suffix[component - 1]; + } + case EX_SYM_TENSOR_10: { + static const char *suffix[] = {XX}; + verify_valid_component(component, ex_field_cardinality(field_type), SIZE(suffix)); + return suffix[component - 1]; + } + case EX_ASYM_TENSOR_03: { + static const char *suffix[] = {XY, YZ, ZX}; + verify_valid_component(component, ex_field_cardinality(field_type), SIZE(suffix)); + return suffix[component - 1]; + } + case EX_ASYM_TENSOR_02: { + static const char *suffix[] = {XY, YZ}; + verify_valid_component(component, ex_field_cardinality(field_type), SIZE(suffix)); + return suffix[component - 1]; + } + case EX_ASYM_TENSOR_01: { + static const char *suffix[] = {XY}; + verify_valid_component(component, ex_field_cardinality(field_type), SIZE(suffix)); + return suffix[component - 1]; + } + case EX_MATRIX_2X2: { + static const char *suffix[] = {"11", "12", "21", "22"}; + verify_valid_component(component, ex_field_cardinality(field_type), SIZE(suffix)); + return suffix[component - 1]; + } + case EX_MATRIX_3X3: { + static const char *suffix[] = {"11", "12", "13", "21", "22", "23", "31", "32", "33"}; + verify_valid_component(component, ex_field_cardinality(field_type), SIZE(suffix)); + return suffix[component - 1]; + } + case EX_FIELD_TYPE_USER_DEFINED: + case EX_FIELD_TYPE_SEQUENCE: + case EX_QUADRATURE: + case EX_BASIS: + case EX_SCALAR: + case EX_FIELD_TYPE_INVALID: + default: return "invalid"; + } +} + +int ex_field_cardinality(const ex_field_type field_type) +{ + switch (field_type) { + case EX_FIELD_TYPE_USER_DEFINED: return -1; + case EX_FIELD_TYPE_SEQUENCE: return -1; + case EX_QUADRATURE: return -1; + case EX_BASIS: return -1; + case EX_SCALAR: return 1; + case EX_VECTOR_1D: return 1; + case EX_VECTOR_2D: return 2; + case EX_VECTOR_3D: return 3; + case EX_QUATERNION_2D: return 2; + case EX_QUATERNION_3D: return 4; + case EX_FULL_TENSOR_36: return 9; + case EX_FULL_TENSOR_32: return 5; + case EX_FULL_TENSOR_22: return 4; + case EX_FULL_TENSOR_16: return 7; + case EX_FULL_TENSOR_12: return 3; + case EX_SYM_TENSOR_33: return 6; + case EX_SYM_TENSOR_31: return 4; + case EX_SYM_TENSOR_21: return 3; + case EX_SYM_TENSOR_13: return 4; + case EX_SYM_TENSOR_11: return 2; + case EX_SYM_TENSOR_10: return 1; + case EX_ASYM_TENSOR_03: return 3; + case EX_ASYM_TENSOR_02: return 2; + case EX_ASYM_TENSOR_01: return 1; + case EX_MATRIX_2X2: return 4; + case EX_MATRIX_3X3: return 9; + case EX_FIELD_TYPE_INVALID: return -1; + } + return -1; +} + +/** The reverse of `field_type_enum_to_string` Used to convert the + * string into a `field_type` enum. The string is parsed from the + * database as a user-readable attribute. For example, EX_VECTOR_2D + * is on the database instead of a raw number 2 + */ +ex_field_type ex_field_string_to_field_type(const char *field_name) +{ + if (strcmp(field_name, "EX_FIELD_TYPE_USER_DEFINED") == 0) { + return EX_FIELD_TYPE_USER_DEFINED; + } + if (strcmp(field_name, "EX_FIELD_TYPE_SEQUENCE") == 0) { + return EX_FIELD_TYPE_SEQUENCE; + } + if (strcmp(field_name, "EX_BASIS") == 0) { + return EX_BASIS; + } + if (strcmp(field_name, "EX_QUADRATURE") == 0) { + return EX_QUADRATURE; + } + if (strcmp(field_name, "EX_SCALAR") == 0) { + return EX_SCALAR; + } + if (strcmp(field_name, "EX_VECTOR_1D") == 0) { + return EX_VECTOR_1D; + } + if (strcmp(field_name, "EX_VECTOR_2D") == 0) { + return EX_VECTOR_2D; + } + if (strcmp(field_name, "EX_VECTOR_3D") == 0) { + return EX_VECTOR_3D; + } + if (strcmp(field_name, "EX_QUATERNION_2D") == 0) { + return EX_QUATERNION_2D; + } + if (strcmp(field_name, "EX_QUATERNION_3D") == 0) { + return EX_QUATERNION_3D; + } + if (strcmp(field_name, "EX_FULL_TENSOR_36") == 0) { + return EX_FULL_TENSOR_36; + } + if (strcmp(field_name, "EX_FULL_TENSOR_32") == 0) { + return EX_FULL_TENSOR_32; + } + if (strcmp(field_name, "EX_FULL_TENSOR_22") == 0) { + return EX_FULL_TENSOR_22; + } + if (strcmp(field_name, "EX_FULL_TENSOR_16") == 0) { + return EX_FULL_TENSOR_16; + } + if (strcmp(field_name, "EX_FULL_TENSOR_12") == 0) { + return EX_FULL_TENSOR_12; + } + if (strcmp(field_name, "EX_SYMMETRIC_TENSOR_33") == 0) { + return EX_SYM_TENSOR_33; + } + if (strcmp(field_name, "EX_SYMMETRIC_TENSOR_31") == 0) { + return EX_SYM_TENSOR_31; + } + if (strcmp(field_name, "EX_SYMMETRIC_TENSOR_21") == 0) { + return EX_SYM_TENSOR_21; + } + if (strcmp(field_name, "EX_SYMMETRIC_TENSOR_13") == 0) { + return EX_SYM_TENSOR_13; + } + if (strcmp(field_name, "EX_SYMMETRIC_TENSOR_11") == 0) { + return EX_SYM_TENSOR_11; + } + if (strcmp(field_name, "EX_SYMMETRIC_TENSOR_10") == 0) { + return EX_SYM_TENSOR_10; + } + if (strcmp(field_name, "EX_ASYMMETRIC_TENSOR_03") == 0) { + return EX_ASYM_TENSOR_03; + } + if (strcmp(field_name, "EX_ASYMMETRIC_TENSOR_02") == 0) { + return EX_ASYM_TENSOR_02; + } + if (strcmp(field_name, "EX_ASYMMETRIC_TENSOR_01") == 0) { + return EX_ASYM_TENSOR_01; + } + if (strcmp(field_name, "EX_MATRIX_2X2") == 0) { + return EX_MATRIX_2X2; + } + if (strcmp(field_name, "EX_MATRIX_3X3") == 0) { + return EX_MATRIX_3X3; + } + if (strcmp(field_name, "EX_FIELD_TYPE_INVALID") == 0) { + return EX_FIELD_TYPE_INVALID; + } + return EX_FIELD_TYPE_INVALID; +} + +/** Used to convert a `field_type` enum to a string so it can be + * written to the database as a user-readable attribute. For + * example, EX_VECTOR_2D would appear instead of a raw number 2 + */ +const char *const ex_field_type_enum_to_string(const ex_field_type field_type) +{ + switch (field_type) { + case EX_FIELD_TYPE_USER_DEFINED: return "EX_FIELD_TYPE_USER_DEFINED"; + case EX_FIELD_TYPE_SEQUENCE: return "EX_FIELD_TYPE_SEQUENCE"; + case EX_BASIS: return "EX_BASIS"; + case EX_QUADRATURE: return "EX_QUADRATURE"; + case EX_SCALAR: return "EX_SCALAR"; + case EX_VECTOR_1D: return "EX_VECTOR_1D"; + case EX_VECTOR_2D: return "EX_VECTOR_2D"; + case EX_VECTOR_3D: return "EX_VECTOR_3D"; + case EX_QUATERNION_2D: return "EX_QUATERNION_2D"; + case EX_QUATERNION_3D: return "EX_QUATERNION_3D"; + case EX_FULL_TENSOR_36: return "EX_FULL_TENSOR_36"; + case EX_FULL_TENSOR_32: return "EX_FULL_TENSOR_32"; + case EX_FULL_TENSOR_22: return "EX_FULL_TENSOR_22"; + case EX_FULL_TENSOR_16: return "EX_FULL_TENSOR_16"; + case EX_FULL_TENSOR_12: return "EX_FULL_TENSOR_12"; + case EX_SYM_TENSOR_33: return "EX_SYMMETRIC_TENSOR_33"; + case EX_SYM_TENSOR_31: return "EX_SYMMETRIC_TENSOR_31"; + case EX_SYM_TENSOR_21: return "EX_SYMMETRIC_TENSOR_21"; + case EX_SYM_TENSOR_13: return "EX_SYMMETRIC_TENSOR_13"; + case EX_SYM_TENSOR_11: return "EX_SYMMETRIC_TENSOR_11"; + case EX_SYM_TENSOR_10: return "EX_SYMMETRIC_TENSOR_10"; + case EX_ASYM_TENSOR_03: return "EX_ASYMMETRIC_TENSOR_03"; + case EX_ASYM_TENSOR_02: return "EX_ASYMMETRIC_TENSOR_02"; + case EX_ASYM_TENSOR_01: return "EX_ASYMMETRIC_TENSOR_01"; + case EX_MATRIX_2X2: return "EX_MATRIX_2X2"; + case EX_MATRIX_3X3: return "EX_MATRIX_3X3"; + case EX_FIELD_TYPE_INVALID: return "EX_FIELD_TYPE_INVALID"; + } + return "EX_FIELD_TYPE_INVALID"; +} + +const char *const ex_field_name(const ex_field_type field_type) +{ + switch (field_type) { + case EX_FIELD_TYPE_USER_DEFINED: return "user defined"; + case EX_FIELD_TYPE_SEQUENCE: return "sequence"; + case EX_BASIS: return "basis"; + case EX_QUADRATURE: return "quadrature"; + case EX_SCALAR: return "scalar"; + case EX_VECTOR_1D: return "vector 1D"; + case EX_VECTOR_2D: return "vector 2D"; + case EX_VECTOR_3D: return "vector 3D"; + case EX_QUATERNION_2D: return "quaternion 2D"; + case EX_QUATERNION_3D: return "quaternion 3D"; + case EX_FULL_TENSOR_36: return "full tensor 36"; + case EX_FULL_TENSOR_32: return "full tensor 32"; + case EX_FULL_TENSOR_22: return "full tensor 22"; + case EX_FULL_TENSOR_16: return "full tensor 16"; + case EX_FULL_TENSOR_12: return "full tensor 12"; + case EX_SYM_TENSOR_33: return "symmetric tensor 33"; + case EX_SYM_TENSOR_31: return "symmetric tensor 31"; + case EX_SYM_TENSOR_21: return "symmetric tensor 21"; + case EX_SYM_TENSOR_13: return "symmetric tensor 13"; + case EX_SYM_TENSOR_11: return "symmetric tensor 11"; + case EX_SYM_TENSOR_10: return "symmetric tensor 10"; + case EX_ASYM_TENSOR_03: return "asymmetric tensor 03"; + case EX_ASYM_TENSOR_02: return "asymmetric tensor 02"; + case EX_ASYM_TENSOR_01: return "asymmetric tensor 01"; + case EX_MATRIX_2X2: return "matrix 2x2"; + case EX_MATRIX_3X3: return "matrix 3x3"; + case EX_FIELD_TYPE_INVALID: return "invalid"; + } + return "invalid"; +} diff --git a/packages/seacas/libraries/exodus/src/ex_get_attribute.c b/packages/seacas/libraries/exodus/src/ex_get_attribute.c index c08fedaddb..7620bdf1a8 100644 --- a/packages/seacas/libraries/exodus/src/ex_get_attribute.c +++ b/packages/seacas/libraries/exodus/src/ex_get_attribute.c @@ -28,7 +28,7 @@ static bool ex__is_internal_attribute(const char *name, ex_entity_type obj_type) if (name[0] == '_') { return true; } - else if ((strcmp(name, "elem_type") == 0) || (strcmp(name, "entity_type1") == 0) || + else if ((strcmp(name, ATT_NAME_ELB) == 0) || (strcmp(name, "entity_type1") == 0) || (strcmp(name, "entity_type2") == 0)) { return true; } @@ -45,61 +45,6 @@ static bool ex__is_internal_attribute(const char *name, ex_entity_type obj_type) return false; } -static int ex__get_varid(int exoid, ex_entity_type obj_type, ex_entity_id id) -{ - char errmsg[MAX_ERR_LENGTH]; - int status = 0; - - if (ex__check_valid_file_id(exoid, __func__) == EX_FATAL) { - return (EX_FATAL); - } - - /* First, locate index of this objects id `obj_type` id array */ - int id_ndx = ex__id_lkup(exoid, obj_type, id); - if (id_ndx <= 0) { - ex_get_err(NULL, NULL, &status); - if (status != 0) { - if (status == EX_NULLENTITY) { /* NULL object? */ - return EX_NOERR; - } - snprintf(errmsg, MAX_ERR_LENGTH, - "ERROR: failed to locate %s id %" PRId64 " in id array in file id %d", - ex_name_of_object(obj_type), id, exoid); - ex_err_fn(exoid, __func__, errmsg, status); - return EX_FATAL; - } - } - - const char *entryptr = NULL; - switch (obj_type) { - case EX_ASSEMBLY: entryptr = VAR_ENTITY_ASSEMBLY(id_ndx); break; - case EX_BLOB: entryptr = VAR_ENTITY_BLOB(id_ndx); break; - case EX_NODE_SET: entryptr = VAR_NODE_NS(id_ndx); break; - case EX_EDGE_SET: entryptr = VAR_EDGE_ES(id_ndx); break; - case EX_FACE_SET: entryptr = VAR_FACE_FS(id_ndx); break; - case EX_SIDE_SET: entryptr = VAR_ELEM_SS(id_ndx); break; - case EX_ELEM_SET: entryptr = VAR_ELEM_ELS(id_ndx); break; - case EX_EDGE_BLOCK: entryptr = VAR_EBCONN(id_ndx); break; - case EX_FACE_BLOCK: entryptr = VAR_FBCONN(id_ndx); break; - case EX_ELEM_BLOCK: entryptr = VAR_CONN(id_ndx); break; - default: - snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: object type %d not supported in call to %s", obj_type, - __func__); - ex_err(__func__, errmsg, EX_BADPARAM); - return EX_FATAL; - } - - int varid = 0; - if ((status = nc_inq_varid(exoid, entryptr, &varid)) != NC_NOERR) { - snprintf(errmsg, MAX_ERR_LENGTH, - "ERROR: failed to locate entity list array for %s %" PRId64 " in file id %d", - ex_name_of_object(obj_type), id, exoid); - ex_err_fn(exoid, __func__, errmsg, status); - return EX_FATAL; - } - return varid; -} - static int ex__get_attribute_count(int exoid, ex_entity_type obj_type, ex_entity_id id, int *varid) { int att_count = 0; diff --git a/packages/seacas/libraries/exodus/src/ex_put_attribute.c b/packages/seacas/libraries/exodus/src/ex_put_attribute.c index 716e3786d1..af29af2bed 100644 --- a/packages/seacas/libraries/exodus/src/ex_put_attribute.c +++ b/packages/seacas/libraries/exodus/src/ex_put_attribute.c @@ -22,88 +22,6 @@ attributes which are currently supported in Exodus. */ -static int ex__get_varid(int exoid, ex_entity_type obj_type, ex_entity_id id) -{ - const char *entryptr = NULL; - char errmsg[MAX_ERR_LENGTH]; - - int id_ndx = 0; - int status = 0; - int varid = 0; - - if (ex__check_valid_file_id(exoid, __func__) == EX_FATAL) { - EX_FUNC_LEAVE(EX_FATAL); - } - - if (obj_type == EX_GLOBAL) { - return NC_GLOBAL; - } - - if (obj_type == EX_ASSEMBLY) { - if ((status = nc_inq_varid(exoid, VAR_ENTITY_ASSEMBLY(id), &varid)) != NC_NOERR) { - snprintf(errmsg, MAX_ERR_LENGTH, - "ERROR: failed to locate %s id %" PRId64 " in id array in file id %d", - ex_name_of_object(obj_type), id, exoid); - ex_err_fn(exoid, __func__, errmsg, status); - return EX_FATAL; - } - return varid; - } - - if (obj_type == EX_BLOB) { - if ((status = nc_inq_varid(exoid, VAR_ENTITY_BLOB(id), &varid)) != NC_NOERR) { - snprintf(errmsg, MAX_ERR_LENGTH, - "ERROR: failed to locate %s id %" PRId64 " in id array in file id %d", - ex_name_of_object(obj_type), id, exoid); - ex_err_fn(exoid, __func__, errmsg, status); - return EX_FATAL; - } - return varid; - } - - /* Everything else ... */ - /* First, locate index of this objects id `obj_type` id array */ - id_ndx = ex__id_lkup(exoid, obj_type, id); - if (id_ndx <= 0) { - ex_get_err(NULL, NULL, &status); - if (status != 0) { - if (status == EX_NULLENTITY) { /* NULL object? */ - return EX_NOERR; - } - snprintf(errmsg, MAX_ERR_LENGTH, - "ERROR: failed to locate %s id %" PRId64 " in id array in file id %d", - ex_name_of_object(obj_type), id, exoid); - ex_err_fn(exoid, __func__, errmsg, status); - return EX_FATAL; - } - } - - switch (obj_type) { - case EX_NODE_SET: entryptr = VAR_NODE_NS(id_ndx); break; - case EX_EDGE_SET: entryptr = VAR_EDGE_ES(id_ndx); break; - case EX_FACE_SET: entryptr = VAR_FACE_FS(id_ndx); break; - case EX_SIDE_SET: entryptr = VAR_ELEM_SS(id_ndx); break; - case EX_ELEM_SET: entryptr = VAR_ELEM_ELS(id_ndx); break; - case EX_EDGE_BLOCK: entryptr = VAR_EBCONN(id_ndx); break; - case EX_FACE_BLOCK: entryptr = VAR_FBCONN(id_ndx); break; - case EX_ELEM_BLOCK: entryptr = VAR_CONN(id_ndx); break; - default: - snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: object type %d not supported in call to %s", obj_type, - __func__); - ex_err(__func__, errmsg, EX_BADPARAM); - return EX_FATAL; - } - - if ((status = nc_inq_varid(exoid, entryptr, &varid)) != NC_NOERR) { - snprintf(errmsg, MAX_ERR_LENGTH, - "ERROR: failed to locate entity list array for %s %" PRId64 " in file id %d", - ex_name_of_object(obj_type), id, exoid); - ex_err_fn(exoid, __func__, errmsg, status); - return EX_FATAL; - } - return varid; -} - /* define and output a double attribute */ int ex_put_double_attribute(int exoid, ex_entity_type obj_type, ex_entity_id id, const char *atr_name, int num_values, const double *values) diff --git a/packages/seacas/libraries/exodus/test/CMakeLists.txt b/packages/seacas/libraries/exodus/test/CMakeLists.txt index 357a1efa5b..fc55ee7d21 100644 --- a/packages/seacas/libraries/exodus/test/CMakeLists.txt +++ b/packages/seacas/libraries/exodus/test/CMakeLists.txt @@ -107,6 +107,8 @@ IF ( NETCDF_NCDUMP_BINARY ) test-add-assembly testwt-blob testrd-blob + testwt-field-metadata + testrd-field-metadata ) IF (SEACASExodus_ENABLE_THREADSAFE) diff --git a/packages/seacas/libraries/exodus/test/testwt-field-metadata.c b/packages/seacas/libraries/exodus/test/testwt-field-metadata.c new file mode 100644 index 0000000000..4907836f34 --- /dev/null +++ b/packages/seacas/libraries/exodus/test/testwt-field-metadata.c @@ -0,0 +1,194 @@ +/* + * Copyright(C) 2022 National Technology & Engineering Solutions + * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with + * NTESS, the U.S. Government retains certain rights in this software. + * + * See packages/seacas/LICENSE for details + */ + +#include +#include +#include + +#include "exodusII.h" + +#define STRINGIFY(x) #x +#define TOSTRING(x) STRINGIFY(x) + +#define EXCHECK(funcall) \ + do { \ + int error = (funcall); \ + printf("after %s, error = %d\n", TOSTRING(funcall), error); \ + if (error != EX_NOERR) { \ + fprintf(stderr, "Error calling %s\n", TOSTRING(funcall)); \ + ex_close(exoid); \ + exit(-1); \ + } \ + } while (0) + +int main(int argc, char **argv) +{ + ex_opts(EX_VERBOSE); + + /* Specify compute and i/o word size */ + int CPU_word_size = 8; + int IO_word_size = 8; + + /* create EXODUS II file */ + int exoid = ex_create("test-field-metadata.exo", /* filename path */ + EX_CLOBBER, /* create mode */ + &CPU_word_size, /* CPU double word size in bytes */ + &IO_word_size); /* I/O double word size in bytes */ + printf("after ex_create for test.exo, exoid = %d\n", exoid); + printf(" cpu word size: %d io word size: %d\n", CPU_word_size, IO_word_size); + + int num_elem_blk = 3; + { + ex_init_params par = {.num_dim = 3, + .num_nodes = 1, + .num_elem = 7, + .num_elem_blk = num_elem_blk, + .num_node_sets = 0, + .num_side_sets = 0, + .num_assembly = 0}; + + char *title = "This is a test"; + ex_copy_string(par.title, title, MAX_LINE_LENGTH + 1); + EXCHECK(ex_put_init_ext(exoid, &par)); + } + + double coord[] = {0.0}; + EXCHECK(ex_put_coord(exoid, coord, coord, coord)); + + /* ======================================================================== */ + /* write element block parameters */ + struct ex_block blocks[num_elem_blk]; + for (int i = 0; i < num_elem_blk; i++) { + blocks[i] = (ex_block){.type = EX_ELEM_BLOCK, .num_entry = 1, .id = i + 10}; + ex_copy_string(blocks[i].topology, "sphere", MAX_STR_LENGTH + 1); + blocks[i].num_nodes_per_entry = 1; + } + + EXCHECK(ex_put_block_params(exoid, num_elem_blk, blocks)); + + int connect[] = {1}; + for (int i = 0; i < num_elem_blk; i++) { + EXCHECK(ex_put_conn(exoid, EX_ELEM_BLOCK, blocks[i].id, connect, NULL, NULL)); + } + + /* Write element block names */ + for (int i = 0; i < num_elem_blk; i++) { + char block_names[32]; + sprintf(block_names, "block_%c", i + 'A'); + EXCHECK(ex_put_name(exoid, EX_ELEM_BLOCK, blocks[i].id, block_names)); + } + + { + int units[] = {1, 0, 0, -1}; + + EXCHECK(ex_put_integer_attribute(exoid, EX_ELEM_BLOCK, 11, "Units", 4, units)); + EXCHECK(ex_put_text_attribute(exoid, EX_GLOBAL, 0, "SOLID_MODEL", "STEP-X-43-1547836-Rev 0")); + } + + /* ======================================================================== */ + /* Transient Variables */ + char *var_names[] = { + "Disp-X", "Disp-Y", "Disp-Z", "Velocity%X", "Velocity%Y", + "Velocity%Z", "Gradient-X$0", "Gradient-Y$0", "Gradient-Z$0", "Gradient-X$1", + "Gradient-Y$1", "Gradient-Z$1", "Gradient-X$2", "Gradient-Y$2", "Gradient-Z$2", + "Gradient-X$3", "Gradient-Y$3", "Gradient-Z$3", "Gradient-X$4", "Gradient-Y$4", + "Gradient-Z$4", "Gradient-X$5", "Gradient-Y$5", "Gradient-Z$5", "Gradient-X$6", + "Gradient-Y$6", "Gradient-Z$6", "Gradient-X$7", "Gradient-Y$7", "Gradient-Z$7", + "Gradient-X$8", "Gradient-Y$8", "Gradient-Z$8", "User_h2o", "User_gas", + "User_ch4", "User_methane"}; + int num_block_vars = sizeof(var_names) / sizeof(var_names[0]); + + EXCHECK(ex_put_variable_param(exoid, EX_ELEM_BLOCK, num_block_vars)); + EXCHECK(ex_put_variable_names(exoid, EX_ELEM_BLOCK, num_block_vars, var_names)); + + { + struct ex_field field = (ex_field){.entity_type = EX_ELEM_BLOCK, + .entity_id = blocks[0].id, + .name = "Disp", + .type = {EX_VECTOR_3D}, + .nesting = 1, + .component_separator = "-"}; + EXCHECK(ex_put_field_metadata(exoid, field)); + } + + { + struct ex_field field = (ex_field){.entity_type = EX_ELEM_BLOCK, + .entity_id = blocks[0].id, + .name = "Velocity", + .type = {EX_VECTOR_3D}, + .nesting = 1, + .component_separator = "%"}; + EXCHECK(ex_put_field_metadata(exoid, field)); + } + + { + int subc_dim[] = {0, 0, 0, 0, 1, 1, 1, 1, 2}; + int subc_ordinal[] = {0, 1, 2, 3, 0, 1, 2, 3, 0}; + int subc_dof_ordinal[] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; + int subc_num_dof[] = {1, 1, 1, 1, 1, 1, 1, 1, 1}; + double xi[] = {-1.0, 1.0, 1.0, -1.0, 0.0, 1.0, 0.0, -1.0, 0.0}; + double eta[] = {-1.0, -1.0, 1.0, 1.0, -1.0, 0.0, 1.0, 0.0, 0.0}; + + struct ex_basis basis = (ex_basis){.name = "HGRAD_QUAD_C2_FEM", + .cardinality = 9, + .subc_dim = subc_dim, + .subc_ordinal = subc_ordinal, + .subc_dof_ordinal = subc_dof_ordinal, + .subc_num_dof = subc_num_dof, + .xi = xi, + .eta = eta, + .zeta = NULL}; + EXCHECK(ex_put_basis_metadata(exoid, EX_ELEM_BLOCK, blocks[1].id, basis)); + + struct ex_field field = (ex_field){.entity_type = EX_ELEM_BLOCK, + .entity_id = blocks[1].id, + .name = "Gradient", + .type = {EX_VECTOR_3D, EX_BASIS}, + .nesting = 2, + .component_separator = "-$"}; + EXCHECK(ex_put_field_metadata(exoid, field)); + } + + { + struct ex_field field = (ex_field){.entity_type = EX_ELEM_BLOCK, + .entity_id = blocks[1].id, + .name = "User", + .type = {EX_FIELD_TYPE_USER_DEFINED}, + .nesting = 1, + .cardinality = {4}, + .component_separator = "_"}; + EXCHECK(ex_put_field_metadata(exoid, field)); + EXCHECK(ex_put_field_suffices(exoid, field, "h2o,gas,ch4,methane")); + } + + { /* Output time steps ... */ + for (int ts = 0; ts < 1; ts++) { + double time_val = (double)(ts + 1) / 100.0; + + EXCHECK(ex_put_time(exoid, ts + 1, &time_val)); + + /* write variables */ + for (int k = 0; k < num_elem_blk; k++) { + double *var_vals = (double *)calloc(blocks[k].num_entry, CPU_word_size); + for (int var_idx = 0; var_idx < num_block_vars; var_idx++) { + for (int elem = 0; elem < blocks[k].num_entry; elem++) { + var_vals[elem] = (double)(var_idx + 2) * time_val + elem; + } + EXCHECK(ex_put_var(exoid, ts + 1, EX_ELEM_BLOCK, var_idx + 1, blocks[k].id, + blocks[k].num_entry, var_vals)); + } + free(var_vals); + } + } + } + + /* close the EXODUS files + */ + EXCHECK(ex_close(exoid)); + return 0; +} From 3b7d86fe0b212fc326b7cd1b3d3a7f925aa614d7 Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Fri, 8 Apr 2022 08:24:54 -0600 Subject: [PATCH 005/236] EXODUS: Spelling fix --- packages/seacas/libraries/exodus/test/testrd-field-metadata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/seacas/libraries/exodus/test/testrd-field-metadata.c b/packages/seacas/libraries/exodus/test/testrd-field-metadata.c index 5f9db4f018..a98c1eca55 100644 --- a/packages/seacas/libraries/exodus/test/testrd-field-metadata.c +++ b/packages/seacas/libraries/exodus/test/testrd-field-metadata.c @@ -78,7 +78,7 @@ int main(int argc, char **argv) int status = ex_get_basis_metadata(exoid, EX_ELEM_BLOCK, 10, &basis); if (status != EX_NOTFOUND) { fprintf(stderr, - "Error calling ex_get_basis for non-existant basis. Should return EX_NOTFOUND"); + "Error calling ex_get_basis for non-existent basis. Should return EX_NOTFOUND"); } EXCHECK(ex_get_basis_metadata(exoid, EX_ELEM_BLOCK, 11, &basis)); From f1f69ddab99b299c121dea4f6b99d257d05886da Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Fri, 8 Apr 2022 09:03:05 -0600 Subject: [PATCH 006/236] EXODUS: See if can fix intel errors --- .../libraries/exodus/include/exodusII.h | 10 +++--- .../libraries/exodus/src/ex_field_utils.c | 32 +++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/packages/seacas/libraries/exodus/include/exodusII.h b/packages/seacas/libraries/exodus/include/exodusII.h index 14caba1bb7..a3793873a7 100644 --- a/packages/seacas/libraries/exodus/include/exodusII.h +++ b/packages/seacas/libraries/exodus/include/exodusII.h @@ -1281,11 +1281,11 @@ EXODUS_EXPORT int ex_put_elem_cmap(int exoid, /**< NetCDF/Exodus int processor /**< This processor ID */ ); -EXODUS_EXPORT const char *ex_field_component_name(ex_field_type field_type, int component); -EXODUS_EXPORT int ex_field_cardinality(const ex_field_type field_type); -EXODUS_EXPORT const char *const ex_field_name(const ex_field_type field_type); -EXODUS_EXPORT ex_field_type ex_field_string_to_field_type(const char *field_name); -EXODUS_EXPORT const char *const ex_field_type_enum_to_string(const ex_field_type field_type); +EXODUS_EXPORT const char *ex_field_component_name(ex_field_type field_type, int component); +EXODUS_EXPORT int ex_field_cardinality(const ex_field_type field_type); +EXODUS_EXPORT const char *ex_field_name(const ex_field_type field_type); +EXODUS_EXPORT ex_field_type ex_field_string_to_field_type(const char *field_name); +EXODUS_EXPORT const char *ex_field_type_enum_to_string(const ex_field_type field_type); /*! @} */ diff --git a/packages/seacas/libraries/exodus/src/ex_field_utils.c b/packages/seacas/libraries/exodus/src/ex_field_utils.c index 8e3b6abbe6..0b2c8d485a 100644 --- a/packages/seacas/libraries/exodus/src/ex_field_utils.c +++ b/packages/seacas/libraries/exodus/src/ex_field_utils.c @@ -20,21 +20,21 @@ static void verify_valid_component(int component, size_t cardinality, size_t suf const char *ex_field_component_name(ex_field_type field_type, int component) { - static char *const X = "x"; - static char *const Y = "y"; - static char *const Z = "z"; - static char *const Q = "q"; - static char *const S = "s"; + static const char *const X = "x"; + static const char *const Y = "y"; + static const char *const Z = "z"; + static const char *const Q = "q"; + static const char *const S = "s"; - static char *const XX = "xx"; - static char *const YY = "yy"; - static char *const ZZ = "zz"; - static char *const XY = "xy"; - static char *const YZ = "yz"; - static char *const ZX = "zx"; - static char *const YX = "yx"; - static char *const ZY = "zy"; - static char *const XZ = "xz"; + static const char *const XX = "xx"; + static const char *const YY = "yy"; + static const char *const ZZ = "zz"; + static const char *const XY = "xy"; + static const char *const YZ = "yz"; + static const char *const ZX = "zx"; + static const char *const YX = "yx"; + static const char *const ZY = "zy"; + static const char *const XZ = "xz"; switch (field_type) { case EX_VECTOR_1D: { @@ -281,7 +281,7 @@ ex_field_type ex_field_string_to_field_type(const char *field_name) * written to the database as a user-readable attribute. For * example, EX_VECTOR_2D would appear instead of a raw number 2 */ -const char *const ex_field_type_enum_to_string(const ex_field_type field_type) +const char *ex_field_type_enum_to_string(const ex_field_type field_type) { switch (field_type) { case EX_FIELD_TYPE_USER_DEFINED: return "EX_FIELD_TYPE_USER_DEFINED"; @@ -315,7 +315,7 @@ const char *const ex_field_type_enum_to_string(const ex_field_type field_type) return "EX_FIELD_TYPE_INVALID"; } -const char *const ex_field_name(const ex_field_type field_type) +const char *ex_field_name(const ex_field_type field_type) { switch (field_type) { case EX_FIELD_TYPE_USER_DEFINED: return "user defined"; From d7e98d2335f11774d767b062570150e18e05ef3e Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Fri, 8 Apr 2022 09:49:18 -0600 Subject: [PATCH 007/236] EXODUS: Fix intel build --- .../libraries/exodus/src/ex_field_utils.c | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/seacas/libraries/exodus/src/ex_field_utils.c b/packages/seacas/libraries/exodus/src/ex_field_utils.c index 0b2c8d485a..bd6236ff5f 100644 --- a/packages/seacas/libraries/exodus/src/ex_field_utils.c +++ b/packages/seacas/libraries/exodus/src/ex_field_utils.c @@ -20,21 +20,21 @@ static void verify_valid_component(int component, size_t cardinality, size_t suf const char *ex_field_component_name(ex_field_type field_type, int component) { - static const char *const X = "x"; - static const char *const Y = "y"; - static const char *const Z = "z"; - static const char *const Q = "q"; - static const char *const S = "s"; +#define X "x" +#define Y "y" +#define Z "z" +#define Q "q" +#define S "s" - static const char *const XX = "xx"; - static const char *const YY = "yy"; - static const char *const ZZ = "zz"; - static const char *const XY = "xy"; - static const char *const YZ = "yz"; - static const char *const ZX = "zx"; - static const char *const YX = "yx"; - static const char *const ZY = "zy"; - static const char *const XZ = "xz"; +#define XX "xx" +#define YY "yy" +#define ZZ "zz" +#define XY "xy" +#define YZ "yz" +#define ZX "zx" +#define YX "yx" +#define ZY "zy" +#define XZ "xz" switch (field_type) { case EX_VECTOR_1D: { From 4b057e3913bbe4a89dd328b5ec50ad0e6b56712f Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Mon, 11 Apr 2022 16:06:48 -0600 Subject: [PATCH 008/236] EXODUS: Move internal function to correct header --- packages/seacas/libraries/exodus/include/exodusII.h | 3 --- packages/seacas/libraries/exodus/include/exodusII_int.h | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/seacas/libraries/exodus/include/exodusII.h b/packages/seacas/libraries/exodus/include/exodusII.h index a3793873a7..599b530640 100644 --- a/packages/seacas/libraries/exodus/include/exodusII.h +++ b/packages/seacas/libraries/exodus/include/exodusII.h @@ -796,9 +796,6 @@ ex_put_loadbal_param_cc(int exoid, /* NetCDF/Exodus file ID /* Utility function to replace strncpy, strcpy -- guarantee null termination */ char *ex_copy_string(char *dest, char const *source, size_t elements); -/* Utility function to find variable to store entity attribute on */ -int ex__get_varid(int exoid, ex_entity_type obj_type, ex_entity_id id); - /*! * \addtogroup ModelDescription * @{ diff --git a/packages/seacas/libraries/exodus/include/exodusII_int.h b/packages/seacas/libraries/exodus/include/exodusII_int.h index 34e3fa86e9..9452526296 100644 --- a/packages/seacas/libraries/exodus/include/exodusII_int.h +++ b/packages/seacas/libraries/exodus/include/exodusII_int.h @@ -86,6 +86,9 @@ extern "C" { #define EX_FILE_ID_MASK (0xffff0000) /**< Must match FILE_ID_MASK in NetCDF nc4internal.h */ #define EX_GRP_ID_MASK (0x0000ffff) /**< Must match GRP_ID_MASK in NetCDF nc4internal.h */ +/* Utility function to find variable to store entity attribute on */ +int ex__get_varid(int exoid, ex_entity_type obj_type, ex_entity_id id); + void ex__reset_error_status(void); #if defined(EXODUS_THREADSAFE) From be7b749286dbe33ea644c91bff60a8cf0845e29c Mon Sep 17 00:00:00 2001 From: Utkarsh Ayachit Date: Mon, 18 Apr 2022 14:46:52 -0400 Subject: [PATCH 009/236] Windows fixes: make functions non-inline Making certain functions in Ioss::Utils non-inline to avoid export errors on Windows. Accessing the non-exported static variables was causing errors. This avoids that. Also added API to access current values for various streams. --- .../seacas/libraries/ioss/src/Ioss_Utils.C | 37 +++++++++++++++++++ .../seacas/libraries/ioss/src/Ioss_Utils.h | 28 ++++++++------ 2 files changed, 53 insertions(+), 12 deletions(-) diff --git a/packages/seacas/libraries/ioss/src/Ioss_Utils.C b/packages/seacas/libraries/ioss/src/Ioss_Utils.C index 470cfd1e3f..a70a9a12b1 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_Utils.C +++ b/packages/seacas/libraries/ioss/src/Ioss_Utils.C @@ -144,6 +144,43 @@ namespace { } } // namespace +void Ioss::Utils::set_all_streams(std::ostream &out_stream) +{ + m_outputStream = &out_stream; + m_debugStream = &out_stream; + m_warningStream = &out_stream; +} + +void Ioss::Utils::set_output_stream(std::ostream &out_stream) +{ + m_outputStream = &out_stream; +} + +void Ioss::Utils::set_debug_stream(std::ostream &out_stream) +{ + m_debugStream = &out_stream; +} + +void Ioss::Utils::set_warning_stream(std::ostream &out_stream) +{ + m_warningStream = &out_stream; +} + +std::ostream& Ioss::Utils::get_output_stream() +{ + return *m_outputStream; +} + +std::ostream& Ioss::Utils::get_warning_stream() +{ + return *m_warningStream; +} + +std::ostream& Ioss::Utils::get_debug_stream() +{ + return *m_debugStream; +} + void Ioss::Utils::time_and_date(char *time_string, char *date_string, size_t length) { std::time_t t = std::time(nullptr); diff --git a/packages/seacas/libraries/ioss/src/Ioss_Utils.h b/packages/seacas/libraries/ioss/src/Ioss_Utils.h index 28e42d93bf..a3c0cf91ba 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_Utils.h +++ b/packages/seacas/libraries/ioss/src/Ioss_Utils.h @@ -79,27 +79,31 @@ namespace Ioss { /** \brief set the stream for all streams (output, debug, and warning) to the specified * `out_stream` */ - static void set_all_streams(std::ostream &out_stream) - { - m_outputStream = &out_stream; - m_debugStream = &out_stream; - m_warningStream = &out_stream; - } + static void set_all_streams(std::ostream &out_stream); + + /** \brief get the debug stream. + */ + static std::ostream& get_debug_stream(); + + /** \brief get the warning stream. + */ + static std::ostream& get_warning_stream(); + + /** \brief get the output stream. + */ + static std::ostream& get_output_stream(); /** \brief set the output stream to the specified `output_stream` */ - static void set_output_stream(std::ostream &output_stream) { m_outputStream = &output_stream; } + static void set_output_stream(std::ostream &output_stream); /** \brief set the debug stream to the specified `debug_stream` */ - static void set_debug_stream(std::ostream &debug_stream) { m_debugStream = &debug_stream; } + static void set_debug_stream(std::ostream &debug_stream); /** \brief set the warning stream to the specified `warning_stream` */ - static void set_warning_stream(std::ostream &warning_stream) - { - m_warningStream = &warning_stream; - } + static void set_warning_stream(std::ostream &warning_stream); /** \brief set the pre-warning text * Sets the text output prior to a warning to the specified text. From db1de2296e44446c27f18d052723d812e7f30d3d Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Wed, 20 Apr 2022 12:44:46 -0600 Subject: [PATCH 010/236] eliminate warnings --- packages/seacas/libraries/exodus/test/testrd.c | 4 +++- packages/seacas/libraries/ioss/src/Ioss_FaceGenerator.C | 6 ++++-- packages/seacas/libraries/ioss/src/cgns/Iocgns_Utils.C | 2 -- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/seacas/libraries/exodus/test/testrd.c b/packages/seacas/libraries/exodus/test/testrd.c index b115e0b504..d9f2935680 100644 --- a/packages/seacas/libraries/exodus/test/testrd.c +++ b/packages/seacas/libraries/exodus/test/testrd.c @@ -234,7 +234,9 @@ int main(int argc, char **argv) } /* Read per-block id map and compare to overall id map... */ +#if 0 int offset = 0; +#endif for (int i = 0; i < num_elem_blk; i++) { int *block_map = (int *)calloc(num_elem_in_block[i], sizeof(int)); error = ex_get_block_id_map(exoid, EX_ELEM_BLOCK, ids[i], block_map); @@ -244,8 +246,8 @@ int main(int argc, char **argv) for (int j = 0; j < num_elem_in_block[i]; j++) { assert(block_map[j] == elem_map[offset + j]); } -#endif offset += num_elem_in_block[i]; +#endif free(block_map); } diff --git a/packages/seacas/libraries/ioss/src/Ioss_FaceGenerator.C b/packages/seacas/libraries/ioss/src/Ioss_FaceGenerator.C index 10cb61e8c0..964e6c0b18 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_FaceGenerator.C +++ b/packages/seacas/libraries/ioss/src/Ioss_FaceGenerator.C @@ -392,12 +392,14 @@ namespace Ioss { #if DO_TIMING auto endf = std::chrono::steady_clock::now(); #endif - size_t face_count = 0; for (auto &eb : ebs) { resolve_parallel_faces(region_, faces_[eb->name()], hashIds_, (INT)0); - face_count += faces_[eb->name()].size(); } #if DO_TIMING + size_t face_count = 0; + for (auto &eb : ebs) { + face_count += faces_[eb->name()].size(); + } auto endp = std::chrono::steady_clock::now(); auto diffh = endh - starth; auto difff = endf - endh; diff --git a/packages/seacas/libraries/ioss/src/cgns/Iocgns_Utils.C b/packages/seacas/libraries/ioss/src/cgns/Iocgns_Utils.C index fa5f14ff99..0ef0b7d6ff 100644 --- a/packages/seacas/libraries/ioss/src/cgns/Iocgns_Utils.C +++ b/packages/seacas/libraries/ioss/src/cgns/Iocgns_Utils.C @@ -2633,14 +2633,12 @@ int Iocgns::Utils::pre_split(std::vector &zones, d int new_zone_id = static_cast(zones.size()) + 1; // See if can split each zone over a set of procs... - double total_work = 0.0; std::vector splits(zones.size()); for (size_t i = 0; i < zones.size(); i++) { auto zone = zones[i]; if (zone->m_lineOrdinal != 7) { double work = zone->work(); - total_work += work; if (load_balance <= 1.2) { splits[i] = int(std::ceil(work / avg_work)); } From ac006ff96681ff686eba1a005166b77af842aabe Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Wed, 20 Apr 2022 12:45:33 -0600 Subject: [PATCH 011/236] IOSS: cgns - do not create assemblies from Unspecified VC --- packages/seacas/libraries/ioss/src/cgns/Iocgns_Utils.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/seacas/libraries/ioss/src/cgns/Iocgns_Utils.C b/packages/seacas/libraries/ioss/src/cgns/Iocgns_Utils.C index 0ef0b7d6ff..719b55f017 100644 --- a/packages/seacas/libraries/ioss/src/cgns/Iocgns_Utils.C +++ b/packages/seacas/libraries/ioss/src/cgns/Iocgns_Utils.C @@ -1685,7 +1685,7 @@ void Iocgns::Utils::add_assemblies(int cgns_file_ptr, Ioss::DatabaseIO *db) } cg_free(dtext); } - if (!assem_name.empty()) { + if (!assem_name.empty() && assem_name != "Unspecified") { // Create an assembly with this name... auto *assem = new Ioss::Assembly(db, assem_name); db->get_region()->add(assem); From a4621ed1891ded544e28ed1a9e0336d36027018c Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Thu, 21 Apr 2022 13:19:53 -0600 Subject: [PATCH 012/236] Getting kokkos build working again [ci skip] --- cmake/tribits/common_tpls/FindTPLKokkos.cmake | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 cmake/tribits/common_tpls/FindTPLKokkos.cmake diff --git a/cmake/tribits/common_tpls/FindTPLKokkos.cmake b/cmake/tribits/common_tpls/FindTPLKokkos.cmake new file mode 100644 index 0000000000..b5f87293c5 --- /dev/null +++ b/cmake/tribits/common_tpls/FindTPLKokkos.cmake @@ -0,0 +1,83 @@ +# @HEADER +# ************************************************************************ +# +# TriBITS: Tribal Build, Integrate, and Test System +# Copyright 2016, 2022 Sandia Corporation +# +# Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +# the U.S. Government retains certain rights in this software. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# 3. Neither the name of the Corporation nor the names of the +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# ************************************************************************ +# @HEADER + +# +# First, set up the variables for the (backward-compatible) TriBITS way of +# finding Netcdf. These are used in case find_package(NetCDF ...) is not +# called or does not find NetCDF. Also, these variables need to be non-null +# in order to trigger the right behavior in the function +# tribits_tpl_find_include_dirs_and_libraries(). +# +set(REQUIRED_HEADERS Kokkos_Core.h) +set(REQUIRED_LIBS_NAMES kokkos) + +# +# Second, search for Netcdf components (if allowed) using the standard +# find_package(CGNS ...). +# +tribits_tpl_allow_pre_find_package(Kokkos Kokkos_ALLOW_PREFIND) +if (Kokkos_ALLOW_PREFIND) + + message("-- Using find_package(Kokkos ...) ...") + + set(CMAKE_MODULE_PATH + "${CMAKE_MODULE_PATH}" + "${CMAKE_CURRENT_LIST_DIR}/find_modules" + "${CMAKE_CURRENT_LIST_DIR}/utils" + ) + + find_package(Kokkos) + + if (Kokkos_FOUND) + set(TPL_Kokkos_LIBRARY_DIRS ${_hdf5_LIBRARY_SEARCH_DIRS} CACHE PATH + "${DOCSTR} library files") + set(TPL_Kokkos_LIBRARIES ${Kokkos_LIBRARIES} CACHE PATH + "List of semi-colon seprated (full) paths to the Kokkos libraries") + set(TPL_Kokkos_INCLUDE_DIRS ${Kokkos_INCLUDE_DIRS} CACHE PATH + "List of semi-colon seprated list of directories containing Kokkos header files") + endif() + +endif() + +# +# Third, call tribits_tpl_find_include_dirs_and_libraries() +# +tribits_tpl_find_include_dirs_and_libraries( Kokkos + REQUIRED_HEADERS ${REQUIRED_HEADERS} + REQUIRED_LIBS_NAMES ${REQUIRED_LIBS_NAMES}) From 8269793c5fd40c81e3c13071afbde87d32573daf Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Mon, 25 Apr 2022 15:50:46 -0600 Subject: [PATCH 013/236] TEST: Enable kokkos build --- .github/workflows/build_variant.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/build_variant.yml b/.github/workflows/build_variant.yml index c17cdfa9cd..e1b6abf949 100644 --- a/.github/workflows/build_variant.yml +++ b/.github/workflows/build_variant.yml @@ -213,6 +213,20 @@ jobs: extra: "", sanitizer: "NO" # address, integer, thread, memory, undefined } + - { + name: "KOKKOS, parallel", + os: ubuntu-latest, + compiler: "mpi", + debug: "NO", + threadsafe: "NO", + fortran: "YES", + use_kokkos: "YES", + use_adios2: "NO", + use_catalyst2: "NO", + gtest: "NO", + extra: "", + sanitizer: "NO" # address, integer, thread, memory, undefined + } steps: - uses: actions/checkout@v2 From c5a657609f6219e398e3c7f75c4edd4524eaa5d5 Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Tue, 26 Apr 2022 08:25:30 -0600 Subject: [PATCH 014/236] IOSS: Change byte-size output to debug --- packages/seacas/libraries/ioss/src/exodus/Ioex_BaseDatabaseIO.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/seacas/libraries/ioss/src/exodus/Ioex_BaseDatabaseIO.C b/packages/seacas/libraries/ioss/src/exodus/Ioex_BaseDatabaseIO.C index 27982540fd..676fc0dd88 100644 --- a/packages/seacas/libraries/ioss/src/exodus/Ioex_BaseDatabaseIO.C +++ b/packages/seacas/libraries/ioss/src/exodus/Ioex_BaseDatabaseIO.C @@ -441,7 +441,7 @@ namespace Ioex { // Check byte-size of integers stored on the database... if ((ex_int64_status(m_exodusFilePtr) & EX_ALL_INT64_DB) != 0) { if (myProcessor == 0 && !sixty_four_bit_message_output) { - fmt::print(Ioss::OUTPUT(), + fmt::print(Ioss::DEBUG(), "IOSS: Input database contains 8-byte integers. Setting Ioss to use " "8-byte integers.\n"); sixty_four_bit_message_output = true; From bb5e227ba64c58c2fb63ba957c10364e22668259 Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Tue, 26 Apr 2022 08:55:11 -0600 Subject: [PATCH 015/236] shellcheck recommendations --- install-tpl.sh | 138 ++++++++++++++++++++++++------------------------- 1 file changed, 69 insertions(+), 69 deletions(-) diff --git a/install-tpl.sh b/install-tpl.sh index cabad44e5d..0e177d4e7f 100755 --- a/install-tpl.sh +++ b/install-tpl.sh @@ -226,8 +226,8 @@ then echo "${txtgrn}+++ SZIP (via libaec library)${txtrst}" szip_version="1.0.4" - cd $ACCESS - cd TPL/szip + cd $ACCESS || exit + cd TPL/szip || exit if [ "$DOWNLOAD" == "YES" ] then echo "${txtgrn}+++ Downloading...${txtrst}" @@ -241,9 +241,9 @@ then if [ "$BUILD" == "YES" ] then echo "${txtgrn}+++ Configuring, Building, and Installing...${txtrst}" - cd libaec-${szip_version} + cd libaec-${szip_version} || exit mkdir build - cd build + cd build || exit CRAY=${CRAY} SHARED=${SHARED} DEBUG=${DEBUG} MPI=${MPI} bash -x ../../runcmake.sh @@ -268,8 +268,8 @@ else echo "${txtgrn}+++ SZIP${txtrst}" szip_version="2.1.1" - cd $ACCESS - cd TPL/szip + cd $ACCESS || exit + cd TPL/szip || exit if [ "$DOWNLOAD" == "YES" ] then echo "${txtgrn}+++ Downloading...${txtrst}" @@ -283,9 +283,9 @@ else if [ "$BUILD" == "YES" ] then echo "${txtgrn}+++ Configuring, Building, and Installing...${txtrst}" - cd szip-${szip_version} + cd szip-${szip_version} || exit # mkdir build - # cd build + # cd build || exit ./configure --prefix=${INSTALL_PATH} # CRAY=${CRAY} SHARED=${SHARED} DEBUG=${DEBUG} MPI=${MPI} bash -x ../../runcmake.sh @@ -317,8 +317,8 @@ then echo "${txtgrn}+++ ZLIB-NG${txtrst}" zlib_ng_version="develop" - cd $ACCESS - cd TPL + cd $ACCESS || exit + cd TPL || exit if [ "$DOWNLOAD" == "YES" ] then echo "${txtgrn}+++ Downloading...${txtrst}" @@ -329,7 +329,7 @@ then if [ "$BUILD" == "YES" ] then echo "${txtgrn}+++ Configuring, Building, and Installing...${txtrst}" - cd zlib-ng + cd zlib-ng || exit git checkout ${zlib_ng_version} rm -rf build mkdir build @@ -351,8 +351,8 @@ then echo "${txtgrn}+++ ZLIB${txtrst}" zlib_version="1.2.12" - cd $ACCESS - cd TPL + cd $ACCESS || exit + cd TPL || exit if [ "$DOWNLOAD" == "YES" ] then echo "${txtgrn}+++ Downloading...${txtrst}" @@ -366,7 +366,7 @@ then if [ "$BUILD" == "YES" ] then echo "${txtgrn}+++ Configuring, Building, and Installing...${txtrst}" - cd zlib-${zlib_version} + cd zlib-${zlib_version} || exit ./configure --prefix=${INSTALL_PATH} if [[ $? != 0 ]] then @@ -405,8 +405,8 @@ then exit 1 fi - cd $ACCESS - cd TPL/hdf5 + cd $ACCESS || exit + cd TPL/hdf5 || exit if [ "$DOWNLOAD" == "YES" ] then echo "${txtgrn}+++ Downloading...${txtrst}" @@ -437,10 +437,10 @@ then if [ "$BUILD" == "YES" ] then echo "${txtgrn}+++ Configuring, Building, and Installing...${txtrst}" - cd hdf5-${hdf_version} + cd hdf5-${hdf_version} || exit rm -rf build mkdir build - cd build + cd build || exit CRAY=${CRAY} H5VERSION=${H5VERSION} DEBUG=${DEBUG} SHARED=${SHARED} NEEDS_ZLIB=${NEEDS_ZLIB} NEEDS_SZIP=${NEEDS_SZIP} MPI=${MPI} bash -x ../../runcmake.sh #CRAY=${CRAY} H5VERSION=${H5VERSION} DEBUG=${DEBUG} SHARED=${SHARED} NEEDS_ZLIB=${NEEDS_ZLIB} NEEDS_SZIP=${NEEDS_SZIP} MPI=${MPI} bash ../runconfigure.sh if [[ $? != 0 ]] @@ -467,8 +467,8 @@ then echo "${txtgrn}+++ PnetCDF${txtrst}" pnet_version="1.12.2" pnet_base="pnetcdf" - cd $ACCESS - cd TPL/pnetcdf + cd $ACCESS || exit + cd TPL/pnetcdf || exit if [ "$DOWNLOAD" == "YES" ] then echo "${txtgrn}+++ Downloading...${txtrst}" @@ -482,7 +482,7 @@ then if [ "$BUILD" == "YES" ] then echo "${txtgrn}+++ Configuring, Building, and Installing...${txtrst}" - cd ${pnet_base}-${pnet_version} + cd ${pnet_base}-${pnet_version} || exit CRAY=${CRAY} BB=${BB} DEBUG=${DEBUG} SHARED=${SHARED} bash ../runconfigure.sh if [[ $? != 0 ]] then @@ -512,8 +512,8 @@ fi if [ "$FORCE" == "YES" ] || ! [ -e $INSTALL_PATH/lib/libnetcdf.${LD_EXT} ] then echo "${txtgrn}+++ NetCDF${txtrst}" - cd $ACCESS - cd TPL/netcdf + cd $ACCESS || exit + cd TPL/netcdf || exit if [ "$DOWNLOAD" == "YES" ] then echo "${txtgrn}+++ Downloading...${txtrst}" @@ -527,14 +527,14 @@ then if [ "$BUILD" == "YES" ] then echo "${txtgrn}+++ Configuring, Building, and Installing...${txtrst}" - cd netcdf-c + cd netcdf-c || exit if [ "$net_version" != "master" ] then git checkout $net_version fi rm -rf build mkdir build - cd build + cd build || exit CRAY=${CRAY} SHARED=${SHARED} DEBUG=${DEBUG} NEEDS_ZLIB=${NEEDS_ZLIB} MPI=${MPI} bash -x ../../runcmake.sh if [[ $? != 0 ]] then @@ -558,8 +558,8 @@ then if [ "$FORCE" == "YES" ] || ! [ -e $INSTALL_PATH/lib/libcgns.${LD_EXT} ] then echo "${txtgrn}+++ CGNS${txtrst}" - cd $ACCESS - cd TPL/cgns + cd $ACCESS || exit + cd TPL/cgns || exit if [ "$DOWNLOAD" == "YES" ] then echo "${txtgrn}+++ Downloading...${txtrst}" @@ -570,11 +570,11 @@ then if [ "$BUILD" == "YES" ] then echo "${txtgrn}+++ Configuring, Building, and Installing...${txtrst}" - cd CGNS + cd CGNS || exit git checkout v4.3.0 rm -rf build mkdir build - cd build + cd build || exit CRAY=${CRAY} SHARED=${SHARED} DEBUG=${DEBUG} NEEDS_ZLIB=${NEEDS_ZLIB} MPI=${MPI} bash ../../runcmake.sh if [[ $? != 0 ]] then @@ -600,8 +600,8 @@ then if [ "$FORCE" == "YES" ] || ! [ -e $INSTALL_PATH/lib/libmetis.a ] then echo "${txtgrn}+++ Metis${txtrst}" - cd $ACCESS - cd TPL/metis + cd $ACCESS || exit + cd TPL/metis || exit if [ "$DOWNLOAD" == "YES" ] then echo "${txtgrn}+++ Downloading...${txtrst}" @@ -614,7 +614,7 @@ then if [ "$BUILD" == "YES" ] then echo "${txtgrn}+++ Configuring, Building, and Installing...${txtrst}" - cd METIS-5.1.0.1 + cd METIS-5.1.0.1 || exit sed 's/TYPEWIDTH 32/TYPEWIDTH 64/' src/include/metis.h > tmp mv tmp src/include/metis.h CRAY=${CRAY} SHARED=${SHARED} DEBUG=${DEBUG} bash ../runconfigure.sh @@ -623,7 +623,7 @@ then echo 1>&2 ${txtred}couldn\'t configure Metis. exiting.${txtrst} exit 1 fi - cd build; make -j${JOBS} && ${SUDO} make install + cd build || exit; make -j${JOBS} && ${SUDO} make install if [[ $? != 0 ]] then echo 1>&2 ${txtred}couldn\'t build Metis. exiting.${txtrst} @@ -642,8 +642,8 @@ then if [ "$FORCE" == "YES" ] || ! [ -e $INSTALL_PATH/lib/libparmetis.a ] then echo "${txtgrn}+++ ParMETIS${txtrst}" - cd $ACCESS - cd TPL/parmetis + cd $ACCESS || exit + cd TPL/parmetis || exit if [ "$DOWNLOAD" == "YES" ] then echo "${txtgrn}+++ Downloading...${txtrst}" @@ -654,7 +654,7 @@ then if [ "$BUILD" == "YES" ] then echo "${txtgrn}+++ Configuring, Building, and Installing...${txtrst}" - cd parmetis + cd parmetis || exit CRAY=${CRAY} MPI=${MPI} SHARED=${SHARED} DEBUG=${DEBUG} bash ../runconfigure.sh if [[ $? != 0 ]] then @@ -685,8 +685,8 @@ then if [ "$FORCE" == "YES" ] || ! [ -e $INSTALL_PATH/lib/libmatio.${LD_EXT} ] then echo "${txtgrn}+++ MatIO${txtrst}" - cd $ACCESS - cd TPL/matio + cd $ACCESS || exit + cd TPL/matio || exit if [ "$DOWNLOAD" == "YES" ] then echo "${txtgrn}+++ Downloading...${txtrst}" @@ -697,10 +697,10 @@ then if [ "$BUILD" == "YES" ] then echo "${txtgrn}+++ Configuring, Building, and Installing...${txtrst}" - cd matio + cd matio || exit rm -rf build mkdir build - cd build + cd build || exit CRAY=${CRAY} SHARED=${SHARED} DEBUG=${DEBUG} NEEDS_ZLIB=${NEEDS_ZLIB} bash -x ../../runcmake.sh if [[ $? != 0 ]] then @@ -725,8 +725,8 @@ then if [ "$FORCE" == "YES" ] || ! [ -e $INSTALL_PATH/include/fmt/core.h ] then echo "${txtgrn}+++ FMT${txtrst}" - cd $ACCESS - cd TPL/fmt + cd $ACCESS || exit + cd TPL/fmt || exit if [ "$DOWNLOAD" == "YES" ] then echo "${txtgrn}+++ Downloading...${txtrst}" @@ -737,10 +737,10 @@ then if [ "$BUILD" == "YES" ] then echo "${txtgrn}+++ Configuring, Building, and Installing...${txtrst}" - cd fmt + cd fmt || exit rm -rf build mkdir build - cd build + cd build || exit cmake -DCMAKE_CXX_COMPILER:FILEPATH=${CXX} -DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PATH} -DCMAKE_INSTALL_LIBDIR:PATH=lib -DFMT_TEST:BOOL=OFF -DBUILD_SHARED_LIBS=${SHARED} .. if [[ $? != 0 ]] then @@ -767,8 +767,8 @@ then then kokkos_version="2.8.00" echo "${txtgrn}+++ KOKKOS${txtrst}" - cd $ACCESS - cd TPL/kokkos + cd $ACCESS || exit + cd TPL/kokkos || exit if [ "$DOWNLOAD" == "YES" ] then echo "${txtgrn}+++ Downloading...${txtrst}" @@ -782,10 +782,10 @@ then if [ "$BUILD" == "YES" ] then echo "${txtgrn}+++ Configuring, Building, and Installing...${txtrst}" - cd kokkos-${kokkos_version} + cd kokkos-${kokkos_version} || exit rm -rf build mkdir build - cd build + cd build || exit CUDA=${CUDA} SHARED=${SHARED} DEBUG=${DEBUG} MPI=${MPI} bash ../../runcmake.sh if [[ $? != 0 ]] then @@ -811,8 +811,8 @@ then if [ "$FORCE" == "YES" ] || ! [ -e $INSTALL_PATH/lib/libadios2.${LD_EXT} ] then echo "${txtgrn}+++ ADIOS2${txtrst}" - cd $ACCESS - cd TPL/adios2 + cd $ACCESS || exit + cd TPL/adios2 || exit if [ "$DOWNLOAD" == "YES" ] then echo "${txtgrn}+++ Downloading...${txtrst}" @@ -823,11 +823,11 @@ then if [ "$BUILD" == "YES" ] then echo "${txtgrn}+++ Configuring, Building, and Installing...${txtrst}" - cd ADIOS2 + cd ADIOS2 || exit git checkout v2.5.0 rm -rf build mkdir build - cd build + cd build || exit CRAY=${CRAY} SHARED=${SHARED} MPI=${MPI} DEBUG=${DEBUG} bash -x ../../runcmake.sh if [[ $? != 0 ]] then @@ -853,8 +853,8 @@ then if [ "$FORCE" == "YES" ] || ! [ -e $INSTALL_PATH/lib/libcatalyst.${LD_EXT} ] then echo "${txtgrn}+++ Catalyst2${txtrst}" - cd $ACCESS - cd TPL/catalyst2 + cd $ACCESS || exit + cd TPL/catalyst2 || exit if [ "$DOWNLOAD" == "YES" ] then echo "${txtgrn}+++ Downloading...${txtrst}" @@ -865,11 +865,11 @@ then if [ "$BUILD" == "YES" ] then echo "${txtgrn}+++ Configuring, Building, and Installing...${txtrst}" - cd catalyst + cd catalyst || exit git checkout master #todo: a specific version rm -rf build mkdir build - cd build + cd build || exit CRAY=${CRAY} SHARED=${SHARED} MPI=${MPI} DEBUG=${DEBUG} bash -x ../../runcmake.sh if [[ $? != 0 ]] then @@ -895,8 +895,8 @@ then if [ "$FORCE" == "YES" ] || ! [ -e $INSTALL_PATH/lib/libgtest.${LD_EXT} ] then echo "${txtgrn}+++ gtest${txtrst}" - cd $ACCESS - cd TPL/gtest + cd $ACCESS || exit + cd TPL/gtest || exit if [ "$DOWNLOAD" == "YES" ] then echo "${txtgrn}+++ Downloading...${txtrst}" @@ -907,11 +907,11 @@ then if [ "$BUILD" == "YES" ] then echo "${txtgrn}+++ Configuring, Building, and Installing...${txtrst}" - cd googletest + cd googletest || exit git checkout release-1.11.0 rm -rf build mkdir build - cd build + cd build || exit CRAY=${CRAY} SHARED=${SHARED} DEBUG=${DEBUG} bash -x ../../runcmake.sh if [[ $? != 0 ]] then @@ -937,8 +937,8 @@ then if [ "$FORCE" == "YES" ] || ! [ -e $INSTALL_PATH/bin/env_parallel ] then echo "${txtgrn}+++ GNU Parallel${txtrst}" - cd $ACCESS - cd TPL/parallel + cd $ACCESS || exit + cd TPL/parallel || exit if [ "$DOWNLOAD" == "YES" ] then echo "${txtgrn}+++ Downloading...${txtrst}" @@ -951,7 +951,7 @@ then if [ "$BUILD" == "YES" ] then echo "${txtgrn}+++ Configuring, Building, and Installing...${txtrst}" - cd parallel-* + cd parallel-* || exit bash ../runconfigure.sh if [[ $? != 0 ]] then @@ -977,8 +977,8 @@ then then faodel_base="faodel" echo "${txtgrn}+++ Faodel${txtrst}" - cd $ACCESS - cd TPL/faodel + cd $ACCESS || exit + cd TPL/faodel || exit if [ "$DOWNLOAD" == "YES" ] then echo "${txtgrn}+++ Downloading...${txtrst}" @@ -990,7 +990,7 @@ then then echo "${txtgrn}+++ Configuring, Building, and Installing...${txtrst}" mkdir ${faodel_base}/build - cd ${faodel_base}/build + cd ${faodel_base}/build || exit echo "------------- ${faodel_base}" echo "------------- $(pwd)" MPI=${MPI} bash ../../runcmake.sh @@ -1018,12 +1018,12 @@ then if [ "$FORCE" == "YES" ] || ! [ -e $INSTALL_PATH/include/cereal/archives/portable_binary.hpp ] then echo "${txtgrn}+++ Cereal${txtrst}" - cd $ACCESS + cd $ACCESS || exit CEREAL_DIR="TPL/cereal" if [ ! -d "${CEREAL_DIR}" ]; then mkdir ${CEREAL_DIR} fi - cd ${CEREAL} + cd ${CEREAL} || exit if [ "$DOWNLOAD" == "YES" ] then echo "${txtgrn}+++ Downloading...${txtrst}" @@ -1044,7 +1044,7 @@ then fi # ================================== -cd $ACCESS +cd $ACCESS || exit #ls -l include #ls -l bin #ls -l lib From e0029fbc756ab8965e54f7f7aa74dfed6c1f9fa2 Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Tue, 26 Apr 2022 08:57:24 -0600 Subject: [PATCH 016/236] TESTING: Remove adios2 until figure out issues --- .github/workflows/build_variant.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.github/workflows/build_variant.yml b/.github/workflows/build_variant.yml index e1b6abf949..0c2b8bd5c9 100644 --- a/.github/workflows/build_variant.yml +++ b/.github/workflows/build_variant.yml @@ -185,20 +185,6 @@ jobs: extra: "APPLICATIONS=NO LEGACY=NO", sanitizer: "NO" # address, integer, thread, memory, undefined } - - { - name: "ADIOS2, parallel", - os: ubuntu-latest, - compiler: "mpi", - debug: "NO", - threadsafe: "NO", - fortran: "YES", - use_kokkos: "NO", - use_adios2: "YES", - use_catalyst2: "NO", - gtest: "NO", - extra: "", - sanitizer: "NO" # address, integer, thread, memory, undefined - } - { name: "CATALYST2, serial", os: ubuntu-latest, From 7dc85205e8661cfdc7e208a20252d7abfc230de3 Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Wed, 27 Apr 2022 08:44:57 -0600 Subject: [PATCH 017/236] EPU: Minor improvement in message (plural vs singular) --- packages/seacas/applications/epu/epu.C | 39 ++++++-------------------- 1 file changed, 8 insertions(+), 31 deletions(-) diff --git a/packages/seacas/applications/epu/epu.C b/packages/seacas/applications/epu/epu.C index 2c2bd7dcc3..7295ce0e4b 100644 --- a/packages/seacas/applications/epu/epu.C +++ b/packages/seacas/applications/epu/epu.C @@ -34,11 +34,8 @@ #include "sys_info.h" #include "time_stamp.h" -#define USE_STD_SORT 1 -#if !USE_STD_SORT -#include "pdqsort.h" -#endif #include "hwm.h" +#include "suplib_sort.h" // Enable SMART_ASSERT even in Release mode... #define SMART_ASSERT_DEBUG_MODE 1 @@ -238,11 +235,7 @@ namespace { template static void uniquify(std::vector &vec) { -#if USE_STD_SORT - std::sort(vec.begin(), vec.end()); -#else - pdqsort(vec.begin(), vec.end()); -#endif + suplib_sort(vec.begin(), vec.end()); vec.resize(unique(vec)); vec.shrink_to_fit(); } @@ -2408,12 +2401,7 @@ namespace { } // Now, sort the global_element_map array. -#if USE_STD_SORT - std::sort(global_element_map.begin(), global_element_map.end()); -#else - pdqsort(global_element_map.begin(), global_element_map.end()); -#endif - + suplib_sort(global_element_map.begin(), global_element_map.end()); global->elementCount = global_element_map.size(); // See if any duplicates... @@ -2585,11 +2573,7 @@ namespace { } // Now, sort the global_edge_map array. -#if USE_STD_SORT - std::sort(global_edge_map.begin(), global_edge_map.end()); -#else - pdqsort(global_edge_map.begin(), global_edge_map.end()); -#endif + suplib_sort(global_edge_map.begin(), global_edge_map.end()); global->edgeCount = global_edge_map.size(); @@ -2762,11 +2746,7 @@ namespace { } // Now, sort the global_face_map array. -#if USE_STD_SORT - std::sort(global_face_map.begin(), global_face_map.end()); -#else - pdqsort(global_face_map.begin(), global_face_map.end()); -#endif + suplib_sort(global_face_map.begin(), global_face_map.end()); global->faceCount = global_face_map.size(); @@ -2942,11 +2922,7 @@ namespace { } // Now, sort the global_node_map array and remove duplicates... -#if USE_STD_SORT - std::sort(global_node_map.begin(), global_node_map.end()); -#else - pdqsort(global_node_map.begin(), global_node_map.end()); -#endif + suplib_sort(global_node_map.begin(), global_node_map.end()); global_node_map.resize(unique(global_node_map)); global_node_map.shrink_to_fit(); @@ -3047,7 +3023,8 @@ namespace { } if (rank == 0) { - fmt::print("Found {} {} variables.\n\t", vars.count(InOut::OUT), vars.label()); + fmt::print("Found {} {} variable{}.\n\t", vars.count(InOut::OUT), vars.label(), + vars.count(InOut::OUT) > 1 ? "s" : ""); int i = 0; int ifld = 1; while (i < vars.count(InOut::OUT)) { From b5c1bf2f3075746b0e1312634443ca04c84c707d Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Wed, 27 Apr 2022 08:55:12 -0600 Subject: [PATCH 018/236] IOSS: Rename qsort to sort --- .../seacas/libraries/ioss/src/Ioss_Decomposition.C | 2 +- packages/seacas/libraries/ioss/src/Ioss_Sort.h | 2 +- .../seacas/libraries/ioss/src/utest/Utst_sort.C | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/seacas/libraries/ioss/src/Ioss_Decomposition.C b/packages/seacas/libraries/ioss/src/Ioss_Decomposition.C index e90e8fe961..cbcfb6ff81 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_Decomposition.C +++ b/packages/seacas/libraries/ioss/src/Ioss_Decomposition.C @@ -341,7 +341,7 @@ namespace Ioss { } show_progress("\tfinished with decomposition method"); - Ioss::qsort(importElementMap); + Ioss::sort(importElementMap); show_progress("\tfinished with sort"); std::copy(importElementCount.begin(), importElementCount.end(), importElementIndex.begin()); diff --git a/packages/seacas/libraries/ioss/src/Ioss_Sort.h b/packages/seacas/libraries/ioss/src/Ioss_Sort.h index d53aa4a898..84e99e3c33 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_Sort.h +++ b/packages/seacas/libraries/ioss/src/Ioss_Sort.h @@ -118,7 +118,7 @@ namespace { #endif namespace Ioss { - template void qsort(std::vector &v) + template void sort(std::vector &v) { if (v.size() <= 1) { return; diff --git a/packages/seacas/libraries/ioss/src/utest/Utst_sort.C b/packages/seacas/libraries/ioss/src/utest/Utst_sort.C index c229d8e7a8..5dec169f23 100644 --- a/packages/seacas/libraries/ioss/src/utest/Utst_sort.C +++ b/packages/seacas/libraries/ioss/src/utest/Utst_sort.C @@ -1,4 +1,4 @@ -// Copyright(C) 1999-2020 National Technology & Engineering Solutions +// Copyright(C) 1999-2020, 2022 National Technology & Engineering Solutions // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with // NTESS, the U.S. Government retains certain rights in this software. // @@ -72,32 +72,32 @@ int main() } auto xsave = x; - Ioss::qsort(x); // Copy of x + Ioss::sort(x); // Copy of x assert(verify_sorted(x)); x = xsave; std::reverse(x.begin(), x.end()); // Reversed - Ioss::qsort(x); + Ioss::sort(x); assert(verify_sorted(x)); x = xsave; std::reverse(&x[0], &x[n / 2]); // Front half reversed - Ioss::qsort(x); + Ioss::sort(x); assert(verify_sorted(x)); x = xsave; std::reverse(&x[n / 2], &x[n]); // Back half reversed - Ioss::qsort(x); + Ioss::sort(x); assert(verify_sorted(x)); - Ioss::qsort(x); // Already sorted + Ioss::sort(x); // Already sorted assert(verify_sorted(x)); x = xsave; for (size_t p = 0; p < n; p++) { x[p] += p % 5; } - Ioss::qsort(x); // Dithered + Ioss::sort(x); // Dithered assert(verify_sorted(x)); } } From c621b45e8c0fa3eb3bbcc1bd53916a798d8849cc Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Wed, 27 Apr 2022 15:51:06 -0600 Subject: [PATCH 019/236] IO_MODIFY: Better help output --- .../libraries/ioss/src/main/io_modify.C | 102 +++++++++++------- 1 file changed, 64 insertions(+), 38 deletions(-) diff --git a/packages/seacas/libraries/ioss/src/main/io_modify.C b/packages/seacas/libraries/ioss/src/main/io_modify.C index fe645007ae..07200d1c1e 100644 --- a/packages/seacas/libraries/ioss/src/main/io_modify.C +++ b/packages/seacas/libraries/ioss/src/main/io_modify.C @@ -79,7 +79,7 @@ using real = double; namespace { std::string codename; - std::string version = "2.01 (2022-03-28)"; + std::string version = "2.02 (2022-04-27)"; std::vector attributes_modified; @@ -535,13 +535,14 @@ namespace { { bool all = Ioss::Utils::substr_equal(topic, "help"); if (all) { - fmt::print("\n\tHELP [list | assembly | graph | attribute | regex | glob]\n"); - fmt::print("\n\tEND | EXIT\n"); + fmt::print(fmt::emphasis::bold, "\n\tHELP"); + fmt::print(" [list | assembly | graph | attribute | regex | glob]\n"); + fmt::print(fmt::emphasis::bold, "\n\tEND | EXIT\n"); fmt::print("\t\tEnd command input and output changed assembly definitions (if any).\n"); - fmt::print("\n\tQUIT\n"); + fmt::print(fmt::emphasis::bold, "\n\tQUIT\n"); fmt::print("\t\tEnd command input and exit with no changes to database.\n"); - fmt::print("\n\tALLOW MODIFICATIONS\n"); + fmt::print(fmt::emphasis::bold, "\n\tALLOW MODIFICATIONS\n"); fmt::print("\t\tBy default, io_modify will only allow creation of new assemblies.\n" "\t\tIf this command is specified, then can modify assemblies that already exist " "in database.\n" @@ -549,97 +550,122 @@ namespace { "updated in place.\n"); } if (all || Ioss::Utils::substr_equal(topic, "list")) { + fmt::print(fmt::emphasis::bold, "\n\tLIST "); fmt::print( - "\n\tLIST " "elementblock|block|structuredblock|assembly|nodeset|sideset|blob|times|summary\n"); - fmt::print("\tLIST elementblock|block|structuredblock|assembly|nodeset|sideset|blob " + fmt::print(fmt::emphasis::bold, "\tLIST "); + fmt::print("elementblock|block|structuredblock|assembly|nodeset|sideset|blob " "{{names...}}\n"); - fmt::print("\tLIST elementblock|block|structuredblock|assembly|nodeset|sideset|blob " + fmt::print(fmt::emphasis::bold, "\tLIST "); + fmt::print("elementblock|block|structuredblock|assembly|nodeset|sideset|blob " "MATCHES {{regex}}\n"); - fmt::print("\tLIST elementblock|block|structuredblock|assembly|nodeset|sideset|blob " + fmt::print(fmt::emphasis::bold, "\tLIST "); + fmt::print("elementblock|block|structuredblock|assembly|nodeset|sideset|blob " "GLOB {{glob}}\n"); } if (all || Ioss::Utils::substr_equal(topic, "assembly")) { fmt::print("\n\tFor all commands, if an assembly named `name` does not exist, it will be " "created.\n"); - fmt::print("\tASSEMBLY {{name}}\n"); + fmt::print(fmt::emphasis::bold, "\tASSEMBLY "); + fmt::print("{{name}}\n"); fmt::print("\t\tCreates an empty assembly named `name` if it does not exist.\n"); - fmt::print("\n\tASSEMBLY {{name}} ADD {{name1}} {{name2}} ... {{nameL}}\n"); + fmt::print(fmt::emphasis::bold, "\n\tASSEMBLY "); + fmt::print("{{name}} ADD {{name1}} {{name2}} ... {{nameL}}\n"); fmt::print("\t\tAdds the specified entities to the assembly. All entities must be the same " "type.\n"); - fmt::print("\n\tASSEMBLY {{name}} REMOVE {{name1}} {{name2}} ... {{nameL}}\n"); + fmt::print(fmt::emphasis::bold, "\n\tASSEMBLY "); + fmt::print("{{name}} REMOVE {{name1}} {{name2}} ... {{nameL}}\n"); fmt::print("\t\tRemoves the specified entities from the assembly.\n"); - fmt::print("\n\tASSEMBLY {{name}} TYPE {{type}} MATCHES {{regex}}\n"); + fmt::print(fmt::emphasis::bold, "\n\tASSEMBLY "); + fmt::print("{{name}} TYPE {{type}} MATCHES {{regex}}\n"); fmt::print("\t\tAdds the entities of the specified type to the assembly.\n" "\t\tAll entities whose name matches the {{regex}} will be added.\n"); - fmt::print("\n\tASSEMBLY {{name}} TYPE {{type}} GLOB {{glob}}\n"); + fmt::print(fmt::emphasis::bold, "\n\tASSEMBLY "); + fmt::print("{{name}} TYPE {{type}} GLOB {{glob}}\n"); fmt::print("\t\tAdds the entities of the specified type to the assembly.\n" "\t\tAll entities whose name matches the {{glob}} will be added.\n"); - fmt::print("\n\tASSEMBLY {{name}} TYPE {{type}} NAMED {{list of one or more names}}\n"); + fmt::print(fmt::emphasis::bold, "\n\tASSEMBLY "); + fmt::print("{{name}} TYPE {{type}} NAMED {{list of one or more names}}\n"); fmt::print("\t\tAdds the entities of the specified type to the assembly.\n" "\t\tAll entities whose names are listed will be added.\n"); - fmt::print("\n\tASSEMBLY {{name}} TYPE {{type}} RANGE {{id}} TO {{id}} BY {{step}}\n"); + fmt::print(fmt::emphasis::bold, "\n\tASSEMBLY "); + fmt::print("{{name}} TYPE {{type}} RANGE {{id}} TO {{id}} BY {{step}}\n"); fmt::print("\t\tAdds the entities of the specified type to the assembly.\n" "\t\tAll entities whose id matches the specified range will be added.\n" "\t\tNo message will be output for ids not matching an entity.\n"); - fmt::print("\n\tASSEMBLY {{name}} TYPE {{type}} IDS {{id}}, {{id2}}, ..., {{idL}}\n"); + fmt::print(fmt::emphasis::bold, "\n\tASSEMBLY "); + fmt::print("{{name}} TYPE {{type}} IDS {{id}}, {{id2}}, ..., {{idL}}\n"); fmt::print( "\t\tAdds the entities of the specified type to the assembly.\n" "\t\tAll entities whose id matches an id in the list will be added.\n" "\t\tA warning message will be output if there is no entity with the requested id.\n"); - fmt::print("\n\tDELETE {{name}}\n"); + fmt::print(fmt::emphasis::bold, "\n\tDELETE "); + fmt::print("{{name}}\n"); fmt::print("\t\tRemove the assembly with the specified name.\n" "\t\tCurrently only supported for assemblies created during this execution; not " "for assemblies\n" "\t\texisting on the input database.\n"); } if (all || Ioss::Utils::substr_equal(topic, "graph")) { - fmt::print("\n\tGRAPH OUTPUT [filename]\n"); + fmt::print(fmt::emphasis::bold, "\n\tGRAPH OUTPUT "); + fmt::print("[filename]\n"); fmt::print( "\t\tCreate a 'dot' input file with the structure of the assembly graph.\n" "\t\tFile is named 'filename' or defaults to 'assembly.dot' if filename not given.\n"); - fmt::print("\tGRAPH CHECK\n"); + fmt::print(fmt::emphasis::bold, "\tGRAPH CHECK\n"); fmt::print("\t\tCheck validity of assembly graph--are there any cycles.\n"); } if (all || Ioss::Utils::substr_equal(topic, "attribute")) { - fmt::print("\n\tATTRIBUTE {{ent_name}} ADD {{att_name}} STRING {{values...}}\n"); - fmt::print("\tATTRIBUTE {{ent_name}} ADD {{att_name}} DOUBLE {{values...}}\n"); - fmt::print("\tATTRIBUTE {{ent_name}} NAME {{att_name}} INTEGER {{values...}}\n"); + fmt::print(fmt::emphasis::bold, "\n\tATTRIBUTE "); + fmt::print("{{ent_name}} ADD {{att_name}} STRING {{values...}}\n"); + fmt::print(fmt::emphasis::bold, "\tATTRIBUTE "); + fmt::print("{{ent_name}} ADD {{att_name}} DOUBLE {{values...}}\n"); + fmt::print(fmt::emphasis::bold, "\tATTRIBUTE "); + fmt::print("{{ent_name}} NAME {{att_name}} INTEGER {{values...}}\n"); fmt::print("\t\tAdd an attribute to the specified entity ('type' and 'name').\n" "\t\tThe attribute will be named 'att_name' with value(s) 'values...'\n" "\t\tCan also modify the values of an existing attribute.'\n"); - fmt::print("\tATTRIBUTE LIST {{ent_name...}}\n" + fmt::print(fmt::emphasis::bold, "\tATTRIBUTE LIST "); + fmt::print("{{ent_name...}}\n" "\t\tList attributes for the selected entities\n"); - fmt::print("\tATTRIBUTE {{ent_type}} LIST\n" + fmt::print(fmt::emphasis::bold, "\tATTRIBUTE "); + fmt::print("{{ent_type}} LIST\n" "\t\tList attributes for all entities in the specified entity type\n"); - fmt::print("\tATTRIBUTE {{ent_type}} MATCH {{regex}}\n" + fmt::print(fmt::emphasis::bold, "\tATTRIBUTE "); + fmt::print("{{ent_type}} MATCH {{regex}}\n" "\t\tList attributes for all entities in the specified entity type whose name " "matches the regex.\n"); - fmt::print("\tATTRIBUTE {{ent_type}} GLOB {{glob}}\n" + fmt::print(fmt::emphasis::bold, "\tATTRIBUTE "); + fmt::print("{{ent_type}} GLOB {{glob}}\n" "\t\tList attributes for all entities in the specified entity type whose name " "matches the glob.\n"); } if (all || Ioss::Utils::substr_equal(topic, "geometry")) { - fmt::print("\n\tGEOMETRY ROTATE {{X|Y|Z}} {{angle}}\n"); - fmt::print("\tGEOMETRY SCALE {{x}} {{y}} {{z}}\n"); - fmt::print("\tGEOMETRY OFFSET {{x}} {{y}} {{z}}\n"); - fmt::print( - "\tGEOMETRY ROTATE {{ELEMENTBLOCKS|BLOCKS|ASSEMBLY}} {{names}} {{X|Y|Z}} {{angle}}\n"); - fmt::print( - "\tGEOMETRY SCALE {{ELEMENTBLOCKS|BLOCKS|ASSEMBLY}} {{names}} {{x}} {{y}} {{z}}\n"); - fmt::print( - "\tGEOMETRY OFFSET {{ELEMENTBLOCKS|BLOCKS|ASSEMBLY}} {{names}} {{x}} {{y}} {{z}}\n"); + fmt::print(fmt::emphasis::bold, "\n\tGEOMETRY ROTATE "); + fmt::print("{{X|Y|Z}} {{angle}}\n"); + fmt::print(fmt::emphasis::bold, "\tGEOMETRY SCALE "); + fmt::print("{{x}} {{y}} {{z}}\n"); + fmt::print(fmt::emphasis::bold, "\tGEOMETRY OFFSET "); + fmt::print("{{x}} {{y}} {{z}}\n"); + fmt::print(fmt::emphasis::bold, "\tGEOMETRY ROTATE "); + fmt::print("{{ELEMENTBLOCKS|BLOCKS|ASSEMBLY}} {{names}} {{X|Y|Z}} {{angle}}\n"); + fmt::print(fmt::emphasis::bold, "\tGEOMETRY SCALE "); + fmt::print("{{ELEMENTBLOCKS|BLOCKS|ASSEMBLY}} {{names}} {{x}} {{y}} {{z}}\n"); + fmt::print(fmt::emphasis::bold, "\tGEOMETRY OFFSET "); + fmt::print("{{ELEMENTBLOCKS|BLOCKS|ASSEMBLY}} {{names}} {{x}} {{y}} {{z}}\n"); } if (all || Ioss::Utils::substr_equal(topic, "time")) { - fmt::print("\tTIME SCALE {{scale}} (T_out = T_in * {{scale}})\n"); - fmt::print("\tTIME OFFSET {{offset}} (T_out = T_in + {{offset}})\n"); + fmt::print(fmt::emphasis::bold, "\n\tTIME SCALE "); + fmt::print("{{scale}} (T_out = T_in * {{scale}})\n"); + fmt::print(fmt::emphasis::bold, "\tTIME OFFSET "); + fmt::print("{{offset}} (T_out = T_in + {{offset}})\n"); } if (all || Ioss::Utils::substr_equal(topic, "regex")) { fmt::print("\n\tRegular Expression help (used in ASSEMBLY MATCHES and LIST MATCHES and " From 99ce49ddf1ce73f6578e49017d0cb612ac4f711d Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Wed, 27 Apr 2022 15:52:47 -0600 Subject: [PATCH 020/236] IO_MODIFY: clean-up comment [ci skip] --- packages/seacas/libraries/ioss/src/main/io_modify.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/seacas/libraries/ioss/src/main/io_modify.C b/packages/seacas/libraries/ioss/src/main/io_modify.C index 07200d1c1e..7e035b3ccb 100644 --- a/packages/seacas/libraries/ioss/src/main/io_modify.C +++ b/packages/seacas/libraries/ioss/src/main/io_modify.C @@ -629,7 +629,7 @@ namespace { fmt::print("{{ent_name}} ADD {{att_name}} DOUBLE {{values...}}\n"); fmt::print(fmt::emphasis::bold, "\tATTRIBUTE "); fmt::print("{{ent_name}} NAME {{att_name}} INTEGER {{values...}}\n"); - fmt::print("\t\tAdd an attribute to the specified entity ('type' and 'name').\n" + fmt::print("\t\tAdd an attribute to the specified entity 'ent_name'.\n" "\t\tThe attribute will be named 'att_name' with value(s) 'values...'\n" "\t\tCan also modify the values of an existing attribute.'\n"); fmt::print(fmt::emphasis::bold, "\tATTRIBUTE LIST "); From d93b5dc2fdd4185427abaf1398d49e0a11ee2a93 Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Wed, 27 Apr 2022 16:09:05 -0600 Subject: [PATCH 021/236] Revert "EPU: Minor improvement in message (plural vs singular)" This reverts commit 6ca490ce687c42aa2b6ca0636b6107c14b2bd595. --- packages/seacas/applications/epu/epu.C | 39 ++++++++++++++++++++------ 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/packages/seacas/applications/epu/epu.C b/packages/seacas/applications/epu/epu.C index 7295ce0e4b..2c2bd7dcc3 100644 --- a/packages/seacas/applications/epu/epu.C +++ b/packages/seacas/applications/epu/epu.C @@ -34,8 +34,11 @@ #include "sys_info.h" #include "time_stamp.h" +#define USE_STD_SORT 1 +#if !USE_STD_SORT +#include "pdqsort.h" +#endif #include "hwm.h" -#include "suplib_sort.h" // Enable SMART_ASSERT even in Release mode... #define SMART_ASSERT_DEBUG_MODE 1 @@ -235,7 +238,11 @@ namespace { template static void uniquify(std::vector &vec) { - suplib_sort(vec.begin(), vec.end()); +#if USE_STD_SORT + std::sort(vec.begin(), vec.end()); +#else + pdqsort(vec.begin(), vec.end()); +#endif vec.resize(unique(vec)); vec.shrink_to_fit(); } @@ -2401,7 +2408,12 @@ namespace { } // Now, sort the global_element_map array. - suplib_sort(global_element_map.begin(), global_element_map.end()); +#if USE_STD_SORT + std::sort(global_element_map.begin(), global_element_map.end()); +#else + pdqsort(global_element_map.begin(), global_element_map.end()); +#endif + global->elementCount = global_element_map.size(); // See if any duplicates... @@ -2573,7 +2585,11 @@ namespace { } // Now, sort the global_edge_map array. - suplib_sort(global_edge_map.begin(), global_edge_map.end()); +#if USE_STD_SORT + std::sort(global_edge_map.begin(), global_edge_map.end()); +#else + pdqsort(global_edge_map.begin(), global_edge_map.end()); +#endif global->edgeCount = global_edge_map.size(); @@ -2746,7 +2762,11 @@ namespace { } // Now, sort the global_face_map array. - suplib_sort(global_face_map.begin(), global_face_map.end()); +#if USE_STD_SORT + std::sort(global_face_map.begin(), global_face_map.end()); +#else + pdqsort(global_face_map.begin(), global_face_map.end()); +#endif global->faceCount = global_face_map.size(); @@ -2922,7 +2942,11 @@ namespace { } // Now, sort the global_node_map array and remove duplicates... - suplib_sort(global_node_map.begin(), global_node_map.end()); +#if USE_STD_SORT + std::sort(global_node_map.begin(), global_node_map.end()); +#else + pdqsort(global_node_map.begin(), global_node_map.end()); +#endif global_node_map.resize(unique(global_node_map)); global_node_map.shrink_to_fit(); @@ -3023,8 +3047,7 @@ namespace { } if (rank == 0) { - fmt::print("Found {} {} variable{}.\n\t", vars.count(InOut::OUT), vars.label(), - vars.count(InOut::OUT) > 1 ? "s" : ""); + fmt::print("Found {} {} variables.\n\t", vars.count(InOut::OUT), vars.label()); int i = 0; int ifld = 1; while (i < vars.count(InOut::OUT)) { From 009ac76b4224ce05f26ba20ab8d5d68fcc4a0da8 Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Thu, 28 Apr 2022 09:51:11 -0600 Subject: [PATCH 022/236] IOSS: Switch to using doctest from Catch2 --- .../libraries/ioss/src/adios/utest/Ut_ioad.C | 11 +- packages/seacas/libraries/ioss/src/catch.hpp | 17966 ---------------- packages/seacas/libraries/ioss/src/doctest.h | 7018 ++++++ .../ioss/src/utest/Utst_IofxDatabaseIO.C | 32 +- .../libraries/ioss/src/utest/Utst_map.C | 51 +- .../ioss/src/utest/Utst_structured_decomp.C | 111 +- .../src/utest/Utst_structured_decomp_herron.C | 10 +- .../src/utest/Utst_structured_decomp_rocket.C | 8 +- .../libraries/ioss/src/utest/Utst_utils.C | 63 +- 9 files changed, 7171 insertions(+), 18099 deletions(-) delete mode 100644 packages/seacas/libraries/ioss/src/catch.hpp create mode 100644 packages/seacas/libraries/ioss/src/doctest.h diff --git a/packages/seacas/libraries/ioss/src/adios/utest/Ut_ioad.C b/packages/seacas/libraries/ioss/src/adios/utest/Ut_ioad.C index 746fce8540..657376fa55 100644 --- a/packages/seacas/libraries/ioss/src/adios/utest/Ut_ioad.C +++ b/packages/seacas/libraries/ioss/src/adios/utest/Ut_ioad.C @@ -3,9 +3,8 @@ // NTESS, the U.S. Government retains certain rights in this software. // // See packages/seacas/LICENSE for details - -#define CATCH_CONFIG_RUNNER -#include +#define DOCTEST_CONFIG_IMPLEMENT +#include #include "Ioss_CodeTypes.h" #include "Ioss_CommSet.h" // for CommSet @@ -53,7 +52,7 @@ int main(int argc, char *argv[]) #ifdef SEACAS_HAVE_MPI MPI_Init(&argc, &argv); #endif - const int result = Catch::Session().run(argc, argv); + const int result = doctest::Context().run(argc, argv); #ifdef SEACAS_HAVE_MPI MPI_Finalize(); #endif @@ -422,7 +421,7 @@ void create_database(std::string type, std::string file_name) db->closeDatabase(); } -TEST_CASE("Ioad", "[Ioad]") +DOCTEST_TEST_CASE("Ioad") { Ioss::Init::Initializer::initialize_ioss(); @@ -468,7 +467,7 @@ template <> const std::string get_entity_type_test() return sideblock.type_string(); } -TEST_CASE("Ioad_BlockNames", "[Ioad]") +DOCTEST_TEST_CASE("Ioad_BlockNames") { REQUIRE(get_entity_type_test() == Ioad::get_entity_type()); REQUIRE(get_entity_type_test() == Ioad::get_entity_type()); diff --git a/packages/seacas/libraries/ioss/src/catch.hpp b/packages/seacas/libraries/ioss/src/catch.hpp deleted file mode 100644 index db1fed3b98..0000000000 --- a/packages/seacas/libraries/ioss/src/catch.hpp +++ /dev/null @@ -1,17966 +0,0 @@ -/* - * Catch v2.13.8 - * Generated: 2022-01-03 21:20:09.589503 - * ---------------------------------------------------------- - * This file has been merged from multiple headers. Please don't edit it directly - * Copyright (c) 2022 Two Blue Cubes Ltd. All rights reserved. - * - * Distributed under the Boost Software License, Version 1.0. (See accompanying - * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - */ -#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED -#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED -// start catch.hpp - - -#define CATCH_VERSION_MAJOR 2 -#define CATCH_VERSION_MINOR 13 -#define CATCH_VERSION_PATCH 8 - -#ifdef __clang__ -# pragma clang system_header -#elif defined __GNUC__ -# pragma GCC system_header -#endif - -// start catch_suppress_warnings.h - -#ifdef __clang__ -# ifdef __ICC // icpc defines the __clang__ macro -# pragma warning(push) -# pragma warning(disable: 161 1682) -# else // __ICC -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wpadded" -# pragma clang diagnostic ignored "-Wswitch-enum" -# pragma clang diagnostic ignored "-Wcovered-switch-default" -# endif -#elif defined __GNUC__ - // Because REQUIREs trigger GCC's -Wparentheses, and because still - // supported version of g++ have only buggy support for _Pragmas, - // Wparentheses have to be suppressed globally. -# pragma GCC diagnostic ignored "-Wparentheses" // See #674 for details - -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wunused-variable" -# pragma GCC diagnostic ignored "-Wpadded" -#endif -// end catch_suppress_warnings.h -#if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER) -# define CATCH_IMPL -# define CATCH_CONFIG_ALL_PARTS -#endif - -// In the impl file, we want to have access to all parts of the headers -// Can also be used to sanely support PCHs -#if defined(CATCH_CONFIG_ALL_PARTS) -# define CATCH_CONFIG_EXTERNAL_INTERFACES -# if defined(CATCH_CONFIG_DISABLE_MATCHERS) -# undef CATCH_CONFIG_DISABLE_MATCHERS -# endif -# if !defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER) -# define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER -# endif -#endif - -#if !defined(CATCH_CONFIG_IMPL_ONLY) -// start catch_platform.h - -// See e.g.: -// https://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/TargetConditionals.h.auto.html -#ifdef __APPLE__ -# include -# if (defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1) || \ - (defined(TARGET_OS_MAC) && TARGET_OS_MAC == 1) -# define CATCH_PLATFORM_MAC -# elif (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1) -# define CATCH_PLATFORM_IPHONE -# endif - -#elif defined(linux) || defined(__linux) || defined(__linux__) -# define CATCH_PLATFORM_LINUX - -#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__) -# define CATCH_PLATFORM_WINDOWS -#endif - -// end catch_platform.h - -#ifdef CATCH_IMPL -# ifndef CLARA_CONFIG_MAIN -# define CLARA_CONFIG_MAIN_NOT_DEFINED -# define CLARA_CONFIG_MAIN -# endif -#endif - -// start catch_user_interfaces.h - -namespace Catch { - unsigned int rngSeed(); -} - -// end catch_user_interfaces.h -// start catch_tag_alias_autoregistrar.h - -// start catch_common.h - -// start catch_compiler_capabilities.h - -// Detect a number of compiler features - by compiler -// The following features are defined: -// -// CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported? -// CATCH_CONFIG_WINDOWS_SEH : is Windows SEH supported? -// CATCH_CONFIG_POSIX_SIGNALS : are POSIX signals supported? -// CATCH_CONFIG_DISABLE_EXCEPTIONS : Are exceptions enabled? -// **************** -// Note to maintainers: if new toggles are added please document them -// in configuration.md, too -// **************** - -// In general each macro has a _NO_ form -// (e.g. CATCH_CONFIG_NO_POSIX_SIGNALS) which disables the feature. -// Many features, at point of detection, define an _INTERNAL_ macro, so they -// can be combined, en-mass, with the _NO_ forms later. - -#ifdef __cplusplus - -# if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) -# define CATCH_CPP14_OR_GREATER -# endif - -# if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) -# define CATCH_CPP17_OR_GREATER -# endif - -#endif - -// Only GCC compiler should be used in this block, so other compilers trying to -// mask themselves as GCC should be ignored. -#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && !defined(__CUDACC__) && !defined(__LCC__) -# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic push" ) -# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic pop" ) - -# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) - -#endif - -#if defined(__clang__) - -# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic push" ) -# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic pop" ) - -// As of this writing, IBM XL's implementation of __builtin_constant_p has a bug -// which results in calls to destructors being emitted for each temporary, -// without a matching initialization. In practice, this can result in something -// like `std::string::~string` being called on an uninitialized value. -// -// For example, this code will likely segfault under IBM XL: -// ``` -// REQUIRE(std::string("12") + "34" == "1234") -// ``` -// -// Therefore, `CATCH_INTERNAL_IGNORE_BUT_WARN` is not implemented. -# if !defined(__ibmxl__) && !defined(__CUDACC__) -# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) /* NOLINT(cppcoreguidelines-pro-type-vararg, hicpp-vararg) */ -# endif - -# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) \ - _Pragma( "clang diagnostic ignored \"-Wglobal-constructors\"") - -# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wparentheses\"" ) - -# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wunused-variable\"" ) - -# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\"" ) - -# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wunused-template\"" ) - -#endif // __clang__ - -//////////////////////////////////////////////////////////////////////////////// -// Assume that non-Windows platforms support posix signals by default -#if !defined(CATCH_PLATFORM_WINDOWS) - #define CATCH_INTERNAL_CONFIG_POSIX_SIGNALS -#endif - -//////////////////////////////////////////////////////////////////////////////// -// We know some environments not to support full POSIX signals -#if defined(__CYGWIN__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(__DJGPP__) - #define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS -#endif - -#ifdef __OS400__ -# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS -# define CATCH_CONFIG_COLOUR_NONE -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Android somehow still does not support std::to_string -#if defined(__ANDROID__) -# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING -# define CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Not all Windows environments support SEH properly -#if defined(__MINGW32__) -# define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH -#endif - -//////////////////////////////////////////////////////////////////////////////// -// PS4 -#if defined(__ORBIS__) -# define CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Cygwin -#ifdef __CYGWIN__ - -// Required for some versions of Cygwin to declare gettimeofday -// see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin -# define _BSD_SOURCE -// some versions of cygwin (most) do not support std::to_string. Use the libstd check. -// https://gcc.gnu.org/onlinedocs/gcc-4.8.2/libstdc++/api/a01053_source.html line 2812-2813 -# if !((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \ - && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)) - -# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING - -# endif -#endif // __CYGWIN__ - -//////////////////////////////////////////////////////////////////////////////// -// Visual C++ -#if defined(_MSC_VER) - -// Universal Windows platform does not support SEH -// Or console colours (or console at all...) -# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) -# define CATCH_CONFIG_COLOUR_NONE -# else -# define CATCH_INTERNAL_CONFIG_WINDOWS_SEH -# endif - -# if !defined(__clang__) // Handle Clang masquerading for msvc - -// MSVC traditional preprocessor needs some workaround for __VA_ARGS__ -// _MSVC_TRADITIONAL == 0 means new conformant preprocessor -// _MSVC_TRADITIONAL == 1 means old traditional non-conformant preprocessor -# if !defined(_MSVC_TRADITIONAL) || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL) -# define CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -# endif // MSVC_TRADITIONAL - -// Only do this if we're not using clang on Windows, which uses `diagnostic push` & `diagnostic pop` -# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma( warning(push) ) -# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION __pragma( warning(pop) ) -# endif // __clang__ - -#endif // _MSC_VER - -#if defined(_REENTRANT) || defined(_MSC_VER) -// Enable async processing, as -pthread is specified or no additional linking is required -# define CATCH_INTERNAL_CONFIG_USE_ASYNC -#endif // _MSC_VER - -//////////////////////////////////////////////////////////////////////////////// -// Check if we are compiled with -fno-exceptions or equivalent -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) -# define CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED -#endif - -//////////////////////////////////////////////////////////////////////////////// -// DJGPP -#ifdef __DJGPP__ -# define CATCH_INTERNAL_CONFIG_NO_WCHAR -#endif // __DJGPP__ - -//////////////////////////////////////////////////////////////////////////////// -// Embarcadero C++Build -#if defined(__BORLANDC__) - #define CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN -#endif - -//////////////////////////////////////////////////////////////////////////////// - -// Use of __COUNTER__ is suppressed during code analysis in -// CLion/AppCode 2017.2.x and former, because __COUNTER__ is not properly -// handled by it. -// Otherwise all supported compilers support COUNTER macro, -// but user still might want to turn it off -#if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L ) - #define CATCH_INTERNAL_CONFIG_COUNTER -#endif - -//////////////////////////////////////////////////////////////////////////////// - -// RTX is a special version of Windows that is real time. -// This means that it is detected as Windows, but does not provide -// the same set of capabilities as real Windows does. -#if defined(UNDER_RTSS) || defined(RTX64_BUILD) - #define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH - #define CATCH_INTERNAL_CONFIG_NO_ASYNC - #define CATCH_CONFIG_COLOUR_NONE -#endif - -#if !defined(_GLIBCXX_USE_C99_MATH_TR1) -#define CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER -#endif - -// Various stdlib support checks that require __has_include -#if defined(__has_include) - // Check if string_view is available and usable - #if __has_include() && defined(CATCH_CPP17_OR_GREATER) - # define CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW - #endif - - // Check if optional is available and usable - # if __has_include() && defined(CATCH_CPP17_OR_GREATER) - # define CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL - # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) - - // Check if byte is available and usable - # if __has_include() && defined(CATCH_CPP17_OR_GREATER) - # include - # if defined(__cpp_lib_byte) && (__cpp_lib_byte > 0) - # define CATCH_INTERNAL_CONFIG_CPP17_BYTE - # endif - # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) - - // Check if variant is available and usable - # if __has_include() && defined(CATCH_CPP17_OR_GREATER) - # if defined(__clang__) && (__clang_major__ < 8) - // work around clang bug with libstdc++ https://bugs.llvm.org/show_bug.cgi?id=31852 - // fix should be in clang 8, workaround in libstdc++ 8.2 - # include - # if defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) - # define CATCH_CONFIG_NO_CPP17_VARIANT - # else - # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT - # endif // defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) - # else - # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT - # endif // defined(__clang__) && (__clang_major__ < 8) - # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) -#endif // defined(__has_include) - -#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER) -# define CATCH_CONFIG_COUNTER -#endif -#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH) && !defined(CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH) -# define CATCH_CONFIG_WINDOWS_SEH -#endif -// This is set by default, because we assume that unix compilers are posix-signal-compatible by default. -#if defined(CATCH_INTERNAL_CONFIG_POSIX_SIGNALS) && !defined(CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_POSIX_SIGNALS) -# define CATCH_CONFIG_POSIX_SIGNALS -#endif -// This is set by default, because we assume that compilers with no wchar_t support are just rare exceptions. -#if !defined(CATCH_INTERNAL_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_WCHAR) -# define CATCH_CONFIG_WCHAR -#endif - -#if !defined(CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_CPP11_TO_STRING) -# define CATCH_CONFIG_CPP11_TO_STRING -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_NO_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_CPP17_OPTIONAL) -# define CATCH_CONFIG_CPP17_OPTIONAL -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_NO_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_CPP17_STRING_VIEW) -# define CATCH_CONFIG_CPP17_STRING_VIEW -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_VARIANT) && !defined(CATCH_CONFIG_NO_CPP17_VARIANT) && !defined(CATCH_CONFIG_CPP17_VARIANT) -# define CATCH_CONFIG_CPP17_VARIANT -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_BYTE) && !defined(CATCH_CONFIG_NO_CPP17_BYTE) && !defined(CATCH_CONFIG_CPP17_BYTE) -# define CATCH_CONFIG_CPP17_BYTE -#endif - -#if defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT) -# define CATCH_INTERNAL_CONFIG_NEW_CAPTURE -#endif - -#if defined(CATCH_INTERNAL_CONFIG_NEW_CAPTURE) && !defined(CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NEW_CAPTURE) -# define CATCH_CONFIG_NEW_CAPTURE -#endif - -#if !defined(CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED) && !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) -# define CATCH_CONFIG_DISABLE_EXCEPTIONS -#endif - -#if defined(CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_NO_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_POLYFILL_ISNAN) -# define CATCH_CONFIG_POLYFILL_ISNAN -#endif - -#if defined(CATCH_INTERNAL_CONFIG_USE_ASYNC) && !defined(CATCH_INTERNAL_CONFIG_NO_ASYNC) && !defined(CATCH_CONFIG_NO_USE_ASYNC) && !defined(CATCH_CONFIG_USE_ASYNC) -# define CATCH_CONFIG_USE_ASYNC -#endif - -#if defined(CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_NO_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_ANDROID_LOGWRITE) -# define CATCH_CONFIG_ANDROID_LOGWRITE -#endif - -#if defined(CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_NO_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_GLOBAL_NEXTAFTER) -# define CATCH_CONFIG_GLOBAL_NEXTAFTER -#endif - -// Even if we do not think the compiler has that warning, we still have -// to provide a macro that can be used by the code. -#if !defined(CATCH_INTERNAL_START_WARNINGS_SUPPRESSION) -# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION -#endif -#if !defined(CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION) -# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS -#endif - -// The goal of this macro is to avoid evaluation of the arguments, but -// still have the compiler warn on problems inside... -#if !defined(CATCH_INTERNAL_IGNORE_BUT_WARN) -# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) -#endif - -#if defined(__APPLE__) && defined(__apple_build_version__) && (__clang_major__ < 10) -# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS -#elif defined(__clang__) && (__clang_major__ < 5) -# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS -#endif - -#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS -#endif - -#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) -#define CATCH_TRY if ((true)) -#define CATCH_CATCH_ALL if ((false)) -#define CATCH_CATCH_ANON(type) if ((false)) -#else -#define CATCH_TRY try -#define CATCH_CATCH_ALL catch (...) -#define CATCH_CATCH_ANON(type) catch (type) -#endif - -#if defined(CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_NO_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) -#define CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#endif - -// end catch_compiler_capabilities.h -#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line -#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) -#ifdef CATCH_CONFIG_COUNTER -# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ ) -#else -# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ ) -#endif - -#include -#include -#include - -// We need a dummy global operator<< so we can bring it into Catch namespace later -struct Catch_global_namespace_dummy {}; -std::ostream& operator<<(std::ostream&, Catch_global_namespace_dummy); - -namespace Catch { - - struct CaseSensitive { enum Choice { - Yes, - No - }; }; - - class NonCopyable { - NonCopyable( NonCopyable const& ) = delete; - NonCopyable( NonCopyable && ) = delete; - NonCopyable& operator = ( NonCopyable const& ) = delete; - NonCopyable& operator = ( NonCopyable && ) = delete; - - protected: - NonCopyable(); - virtual ~NonCopyable(); - }; - - struct SourceLineInfo { - - SourceLineInfo() = delete; - SourceLineInfo( char const* _file, std::size_t _line ) noexcept - : file( _file ), - line( _line ) - {} - - SourceLineInfo( SourceLineInfo const& other ) = default; - SourceLineInfo& operator = ( SourceLineInfo const& ) = default; - SourceLineInfo( SourceLineInfo&& ) noexcept = default; - SourceLineInfo& operator = ( SourceLineInfo&& ) noexcept = default; - - bool empty() const noexcept { return file[0] == '\0'; } - bool operator == ( SourceLineInfo const& other ) const noexcept; - bool operator < ( SourceLineInfo const& other ) const noexcept; - - char const* file; - std::size_t line; - }; - - std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ); - - // Bring in operator<< from global namespace into Catch namespace - // This is necessary because the overload of operator<< above makes - // lookup stop at namespace Catch - using ::operator<<; - - // Use this in variadic streaming macros to allow - // >> +StreamEndStop - // as well as - // >> stuff +StreamEndStop - struct StreamEndStop { - std::string operator+() const; - }; - template - T const& operator + ( T const& value, StreamEndStop ) { - return value; - } -} - -#define CATCH_INTERNAL_LINEINFO \ - ::Catch::SourceLineInfo( __FILE__, static_cast( __LINE__ ) ) - -// end catch_common.h -namespace Catch { - - struct RegistrarForTagAliases { - RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ); - }; - -} // end namespace Catch - -#define CATCH_REGISTER_TAG_ALIAS( alias, spec ) \ - CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ - CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ - namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); } \ - CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION - -// end catch_tag_alias_autoregistrar.h -// start catch_test_registry.h - -// start catch_interfaces_testcase.h - -#include - -namespace Catch { - - class TestSpec; - - struct ITestInvoker { - virtual void invoke () const = 0; - virtual ~ITestInvoker(); - }; - - class TestCase; - struct IConfig; - - struct ITestCaseRegistry { - virtual ~ITestCaseRegistry(); - virtual std::vector const& getAllTests() const = 0; - virtual std::vector const& getAllTestsSorted( IConfig const& config ) const = 0; - }; - - bool isThrowSafe( TestCase const& testCase, IConfig const& config ); - bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ); - std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ); - std::vector const& getAllTestCasesSorted( IConfig const& config ); - -} - -// end catch_interfaces_testcase.h -// start catch_stringref.h - -#include -#include -#include -#include - -namespace Catch { - - /// A non-owning string class (similar to the forthcoming std::string_view) - /// Note that, because a StringRef may be a substring of another string, - /// it may not be null terminated. - class StringRef { - public: - using size_type = std::size_t; - using const_iterator = const char*; - - private: - static constexpr char const* const s_empty = ""; - - char const* m_start = s_empty; - size_type m_size = 0; - - public: // construction - constexpr StringRef() noexcept = default; - - StringRef( char const* rawChars ) noexcept; - - constexpr StringRef( char const* rawChars, size_type size ) noexcept - : m_start( rawChars ), - m_size( size ) - {} - - StringRef( std::string const& stdString ) noexcept - : m_start( stdString.c_str() ), - m_size( stdString.size() ) - {} - - explicit operator std::string() const { - return std::string(m_start, m_size); - } - - public: // operators - auto operator == ( StringRef const& other ) const noexcept -> bool; - auto operator != (StringRef const& other) const noexcept -> bool { - return !(*this == other); - } - - auto operator[] ( size_type index ) const noexcept -> char { - assert(index < m_size); - return m_start[index]; - } - - public: // named queries - constexpr auto empty() const noexcept -> bool { - return m_size == 0; - } - constexpr auto size() const noexcept -> size_type { - return m_size; - } - - // Returns the current start pointer. If the StringRef is not - // null-terminated, throws std::domain_exception - auto c_str() const -> char const*; - - public: // substrings and searches - // Returns a substring of [start, start + length). - // If start + length > size(), then the substring is [start, size()). - // If start > size(), then the substring is empty. - auto substr( size_type start, size_type length ) const noexcept -> StringRef; - - // Returns the current start pointer. May not be null-terminated. - auto data() const noexcept -> char const*; - - constexpr auto isNullTerminated() const noexcept -> bool { - return m_start[m_size] == '\0'; - } - - public: // iterators - constexpr const_iterator begin() const { return m_start; } - constexpr const_iterator end() const { return m_start + m_size; } - }; - - auto operator += ( std::string& lhs, StringRef const& sr ) -> std::string&; - auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&; - - constexpr auto operator "" _sr( char const* rawChars, std::size_t size ) noexcept -> StringRef { - return StringRef( rawChars, size ); - } -} // namespace Catch - -constexpr auto operator "" _catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef { - return Catch::StringRef( rawChars, size ); -} - -// end catch_stringref.h -// start catch_preprocessor.hpp - - -#define CATCH_RECURSION_LEVEL0(...) __VA_ARGS__ -#define CATCH_RECURSION_LEVEL1(...) CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL2(...) CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL3(...) CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL4(...) CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL5(...) CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(__VA_ARGS__))) - -#ifdef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#define INTERNAL_CATCH_EXPAND_VARGS(...) __VA_ARGS__ -// MSVC needs more evaluations -#define CATCH_RECURSION_LEVEL6(...) CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(__VA_ARGS__))) -#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL6(CATCH_RECURSION_LEVEL6(__VA_ARGS__)) -#else -#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL5(__VA_ARGS__) -#endif - -#define CATCH_REC_END(...) -#define CATCH_REC_OUT - -#define CATCH_EMPTY() -#define CATCH_DEFER(id) id CATCH_EMPTY() - -#define CATCH_REC_GET_END2() 0, CATCH_REC_END -#define CATCH_REC_GET_END1(...) CATCH_REC_GET_END2 -#define CATCH_REC_GET_END(...) CATCH_REC_GET_END1 -#define CATCH_REC_NEXT0(test, next, ...) next CATCH_REC_OUT -#define CATCH_REC_NEXT1(test, next) CATCH_DEFER ( CATCH_REC_NEXT0 ) ( test, next, 0) -#define CATCH_REC_NEXT(test, next) CATCH_REC_NEXT1(CATCH_REC_GET_END test, next) - -#define CATCH_REC_LIST0(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST1(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0) ) ( f, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST2(f, x, peek, ...) f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ ) - -#define CATCH_REC_LIST0_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST1_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0_UD) ) ( f, userdata, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST2_UD(f, userdata, x, peek, ...) f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ ) - -// Applies the function macro `f` to each of the remaining parameters, inserts commas between the results, -// and passes userdata as the first parameter to each invocation, -// e.g. CATCH_REC_LIST_UD(f, x, a, b, c) evaluates to f(x, a), f(x, b), f(x, c) -#define CATCH_REC_LIST_UD(f, userdata, ...) CATCH_RECURSE(CATCH_REC_LIST2_UD(f, userdata, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) - -#define CATCH_REC_LIST(f, ...) CATCH_RECURSE(CATCH_REC_LIST2(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) - -#define INTERNAL_CATCH_EXPAND1(param) INTERNAL_CATCH_EXPAND2(param) -#define INTERNAL_CATCH_EXPAND2(...) INTERNAL_CATCH_NO## __VA_ARGS__ -#define INTERNAL_CATCH_DEF(...) INTERNAL_CATCH_DEF __VA_ARGS__ -#define INTERNAL_CATCH_NOINTERNAL_CATCH_DEF -#define INTERNAL_CATCH_STRINGIZE(...) INTERNAL_CATCH_STRINGIZE2(__VA_ARGS__) -#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#define INTERNAL_CATCH_STRINGIZE2(...) #__VA_ARGS__ -#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) -#else -// MSVC is adding extra space and needs another indirection to expand INTERNAL_CATCH_NOINTERNAL_CATCH_DEF -#define INTERNAL_CATCH_STRINGIZE2(...) INTERNAL_CATCH_STRINGIZE3(__VA_ARGS__) -#define INTERNAL_CATCH_STRINGIZE3(...) #__VA_ARGS__ -#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) (INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) + 1) -#endif - -#define INTERNAL_CATCH_MAKE_NAMESPACE2(...) ns_##__VA_ARGS__ -#define INTERNAL_CATCH_MAKE_NAMESPACE(name) INTERNAL_CATCH_MAKE_NAMESPACE2(name) - -#define INTERNAL_CATCH_REMOVE_PARENS(...) INTERNAL_CATCH_EXPAND1(INTERNAL_CATCH_DEF __VA_ARGS__) - -#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) decltype(get_wrapper()) -#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__)) -#else -#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) INTERNAL_CATCH_EXPAND_VARGS(decltype(get_wrapper())) -#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__))) -#endif - -#define INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(...)\ - CATCH_REC_LIST(INTERNAL_CATCH_MAKE_TYPE_LIST,__VA_ARGS__) - -#define INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_0) INTERNAL_CATCH_REMOVE_PARENS(_0) -#define INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_0, _1) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_1) -#define INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_0, _1, _2) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_1, _2) -#define INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_0, _1, _2, _3) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_1, _2, _3) -#define INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_0, _1, _2, _3, _4) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_1, _2, _3, _4) -#define INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_0, _1, _2, _3, _4, _5) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_1, _2, _3, _4, _5) -#define INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_0, _1, _2, _3, _4, _5, _6) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_1, _2, _3, _4, _5, _6) -#define INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_0, _1, _2, _3, _4, _5, _6, _7) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_1, _2, _3, _4, _5, _6, _7) -#define INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_1, _2, _3, _4, _5, _6, _7, _8) -#define INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9) -#define INTERNAL_CATCH_REMOVE_PARENS_11_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10) - -#define INTERNAL_CATCH_VA_NARGS_IMPL(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N - -#define INTERNAL_CATCH_TYPE_GEN\ - template struct TypeList {};\ - template\ - constexpr auto get_wrapper() noexcept -> TypeList { return {}; }\ - template class...> struct TemplateTypeList{};\ - template class...Cs>\ - constexpr auto get_wrapper() noexcept -> TemplateTypeList { return {}; }\ - template\ - struct append;\ - template\ - struct rewrap;\ - template class, typename...>\ - struct create;\ - template class, typename>\ - struct convert;\ - \ - template \ - struct append { using type = T; };\ - template< template class L1, typename...E1, template class L2, typename...E2, typename...Rest>\ - struct append, L2, Rest...> { using type = typename append, Rest...>::type; };\ - template< template class L1, typename...E1, typename...Rest>\ - struct append, TypeList, Rest...> { using type = L1; };\ - \ - template< template class Container, template class List, typename...elems>\ - struct rewrap, List> { using type = TypeList>; };\ - template< template class Container, template class List, class...Elems, typename...Elements>\ - struct rewrap, List, Elements...> { using type = typename append>, typename rewrap, Elements...>::type>::type; };\ - \ - template