| 1 |
// Copyright(C) 1999-2020, 2023 National Technology & Engineering Solutions |
| 2 |
// of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with |
| 3 |
// NTESS, the U.S. Government retains certain rights in this software. |
| 4 |
// |
| 5 |
// See packages/seacas/LICENSE for details |
| 6 |
|
| 7 |
#include <iostream> |
| 8 |
#include <string> |
| 9 |
#include <vector> |
| 10 |
|
| 11 |
#ifdef SEACAS_HAVE_MPI |
| 12 |
#include <mpi.h> |
| 13 |
#endif |
| 14 |
|
| 15 |
#undef NDEBUG |
| 16 |
#include "Ioss_ConcreteVariableType.h" |
| 17 |
#include "exodus/Ioex_SuperElement.h" |
| 18 |
#include <cassert> |
| 19 |
#include <stdlib.h> |
| 20 |
|
| 21 |
#include "Ioss_Field.h" |
| 22 |
#include "Ioss_Property.h" |
| 23 |
#include "Ioss_ScopeGuard.h" |
| 24 |
#include "Ioss_Utils.h" |
| 25 |
|
| 26 |
int main(int argc, char *argv[]) |
| 27 |
{ |
| 28 |
#ifdef SEACAS_HAVE_MPI |
| 29 |
MPI_Init(&argc, &argv); |
| 30 |
ON_BLOCK_EXIT(MPI_Finalize); |
| 31 |
#endif |
| 32 |
|
| 33 |
Ioss::StorageInitializer initialize_storage; |
| 34 |
|
| 35 |
std::string input_file = std::string(argv[argc - 1]); |
| 36 |
if (input_file.empty()) { |
| 37 |
std::cerr << "Error: No input file specified\n"; |
| 38 |
return (EXIT_FAILURE); |
| 39 |
} |
| 40 |
|
| 41 |
std::string cwd; |
| 42 |
|
| 43 |
input_file = Ioss::Utils::local_filename(input_file, "text", cwd); |
| 44 |
|
| 45 |
Ioex::SuperElement se(input_file, "superelement"); |
| 46 |
|
| 47 |
size_t numDOF = se.get_property("numDOF").get_int(); |
| 48 |
size_t numEIG = se.get_property("numEIG").get_int(); |
| 49 |
size_t numCon = se.get_property("numConstraints").get_int(); |
| 50 |
|
| 51 |
std::cerr << "DOF count = " << numDOF << "\n"; |
| 52 |
std::cerr << "EIG count = " << numEIG << "\n"; |
| 53 |
std::cerr << "Constraint dof count = " << numCon << "\n"; |
| 54 |
assert(numCon == numDOF - numEIG); |
| 55 |
|
| 56 |
// List the fields on the superelement... |
| 57 |
if (!se.field_exists("Kr")) { |
| 58 |
std::cerr << "ERROR: Stiffness matrix field 'Kr' not found\n"; |
| 59 |
} |
| 60 |
else { |
| 61 |
Ioss::Field kr = se.get_field("Kr"); |
| 62 |
assert(kr.raw_count() == numDOF * numDOF); |
| 63 |
} |
| 64 |
|
| 65 |
if (!se.field_exists("Mr")) { |
| 66 |
std::cerr << "ERROR: Mass matrix field 'Mr' not found\n"; |
| 67 |
} |
| 68 |
else { |
| 69 |
Ioss::Field mr = se.get_field("Mr"); |
| 70 |
assert(mr.raw_count() == numDOF * numDOF); |
| 71 |
} |
| 72 |
|
| 73 |
std::vector<double> stiff_mat(numDOF * numDOF); |
| 74 |
std::vector<double> mass_mat(numDOF * numDOF); |
| 75 |
size_t kr_size = se.get_field_data("Kr", stiff_mat); |
| 76 |
size_t mr_size = se.get_field_data("Mr", mass_mat); |
| 77 |
assert(kr_size == numDOF * numDOF); |
| 78 |
assert(mr_size == numDOF * numDOF); |
| 79 |
|
| 80 |
std::cerr << "\nSIERRA execution successful." << '\n'; |
| 81 |
return EXIT_SUCCESS; |
| 82 |
} |