v0.16.3
Loading...
Searching...
No Matches
abaqus_450t_mesh_check.cpp
Go to the documentation of this file.
1/** \file abaqus_450t_mesh_check.cpp
2 * \brief Check accepted one-hex state against the 450T Abaqus workbook.
3 */
4#include <MoFEM.hpp>
5using namespace MoFEM;
6
7#include <array>
8#include <cmath>
9#include <cstdio>
10#include <string>
11#include <vector>
12
13namespace {
14
15struct SensitivityCase {
16 const char *name;
17 std::array<double, 4> temperature;
18 std::array<double, 4> youngModulus;
19 std::array<double, 4> p1;
20 bool checkP1;
21};
22
23const std::array<SensitivityCase, 3> cases{{
24 {"base",
25 {20, 450, 450, 450},
26 {11890, 22252.4, 21894.7, 21516.6},
27 {1, 1.5195, 1.57151, 1.57161},
28 true},
29 {"S1",
30 {20, 235, 450, 450},
31 {11890, 19588, 21429.4, 21475},
32 {1, 1.33448, 1.54454, 1.57156},
33 true},
34 {"S2", {20, 20, 235, 450}, {11890, 17483.2, 19802.5, 21679.3}, {}, false},
35}};
36constexpr std::array<double, 4> dose{{0.003, 7.25, 14.5, 21.75}};
37constexpr std::array<int, 4> outputStep{{1, 9, 17, 25}};
38
39MoFEMErrorCode checkTag(moab::Core &mb, const Range &vertices,
40 const std::string &tag_name, double expected,
41 double tolerance, const char *case_name, int step) {
43 Tag tag;
44 CHKERR mb.tag_get_handle(tag_name.c_str(), tag);
45 std::vector<double> values(vertices.size());
46 CHKERR mb.tag_get_data(tag, vertices, values.data());
47 for (const auto value : values)
48 if (!std::isfinite(value) || std::abs(value - expected) > tolerance)
49 SETERRQ(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
50 "%s step %d: %s = %.12g, Abaqus = %.12g (tolerance %.3g)",
51 case_name, step, tag_name.c_str(), value, expected, tolerance);
53}
54
55MoFEMErrorCode checkCase(const SensitivityCase &test_case,
56 const std::string &directory) {
58 for (int i = 0; i != outputStep.size(); ++i) {
59 const int step = i + 1;
60 const auto filename =
61 directory + "/out_vertices_" + std::to_string(outputStep[i]) + ".h5m";
62 moab::Core mb;
63 CHKERR mb.load_file(filename.c_str());
65 CHKERR mb.get_entities_by_type(0, MBVERTEX, vertices);
66 if (vertices.empty())
67 SETERRQ(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
68 "%s has no integration-point vertices", filename.c_str());
69 CHKERR checkTag(mb, vertices, "AMENTUM_FIELD_IRRA", dose[i], 1e-8,
70 test_case.name, step);
71 CHKERR checkTag(mb, vertices, "AMENTUM_FIELD_PREDEF_TEMP",
72 test_case.temperature[i], 1e-8, test_case.name, step);
73 CHKERR checkTag(mb, vertices, "UMAT_STATEV_7", test_case.youngModulus[i],
74 0.05, test_case.name, step);
75 if (test_case.checkP1)
76 CHKERR checkTag(mb, vertices, "UMAT_STATEV_79", test_case.p1[i], 5e-6,
77 test_case.name, step);
78 if (i > 0) {
79 CHKERR checkTag(mb, vertices, "UMAT_STATEV_0", i == 1 ? 3.6235 : 3.625,
80 1e-8, test_case.name, step);
81 CHKERR checkTag(mb, vertices, "UMAT_STATEV_1", dose[i], 1e-8,
82 test_case.name, step);
83 CHKERR checkTag(mb, vertices, "UMAT_STATEV_2", test_case.temperature[i],
84 1e-8, test_case.name, step);
85 CHKERR checkTag(mb, vertices, "UMAT_STATEV_6", 0.25, 1e-12,
86 test_case.name, step);
87 }
88 PetscPrintf(PETSC_COMM_WORLD, "%s one-hex step %d passed\n", test_case.name,
89 step);
90 }
92}
93
94} // namespace
95
96int main(int argc, char **argv) {
97 if (argc != 3) {
98 std::fprintf(stderr, "usage: %s {base|S1|S2} output-directory\n", argv[0]);
99 return 2;
100 }
101 int mofem_argc = 1;
102 char *mofem_argv[] = {argv[0], nullptr};
103 char **mofem_argv_ptr = mofem_argv;
104 MoFEM::Core::Initialize(&mofem_argc, &mofem_argv_ptr, nullptr, nullptr);
105 try {
106 const std::string case_name = argv[1];
107 const std::string directory = argv[2];
108 for (const auto &test_case : cases)
109 if (case_name == test_case.name) {
110 CHKERR checkCase(test_case, directory);
112 return 0;
113 }
114 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "Unknown case %s",
115 case_name.c_str());
116 }
119 return 1;
120}
double tolerance
Radians.
std::vector< int > vertices
moab::Interface & mb
Tag tag
SmartPetscObj< Vec > values
std::string name
int main()
#define CATCH_ERRORS
Catch errors.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_ATOM_TEST_INVALID
Definition definitions.h:40
@ MOFEM_INVALID_DATA
Definition definitions.h:36
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
FTensor::Index< 'i', SPACE_DIM > i
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
Definition Core.cpp:68
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition Core.cpp:123