137 {
138
140
141 try {
142 moab::Core mb_instance;
143 moab::Interface &moab = mb_instance;
144
148
150
151 const std::string expected_ksp_type =
152 readStringOption("-expected_ksp_type");
153 const std::string expected_pc_type = readStringOption("-expected_pc_type");
154 std::string expected_file_name;
155
156 if (readStringOption("-ksp_type") != expected_ksp_type) {
158 "Unexpected -ksp_type value");
159 }
160 if (readStringOption("-pc_type") != expected_pc_type) {
162 "Unexpected -pc_type value");
163 }
164 assertNear(readRealOption("-ksp_rtol"), 1e-8, 1e-14,
165 "Unexpected -ksp_rtol");
166 if (readIntOption("-order") != 2) {
168 "Unexpected -order value");
169 }
170 if (readIntOption("-atom_test") != 1) {
172 "Unexpected -atom_test value");
173 }
174 if (!hasOption("-log_no_color")) {
176 "Expected -log_no_color option to be set");
177 }
178 if (readOptionalStringOption("-expected_file_name", expected_file_name)) {
179 if (readStringOption("-file_name") != expected_file_name) {
181 "Unexpected -file_name value");
182 }
183 }
184
187
194 "bodyforces_domain");
197 "int_electric_custom");
203
205 {"charge_density", "mobility", "scale"});
207 CHKERR json_config->applyMeshsets();
208
209 const bool shared_types_same_blockset_test =
210 hasOption("-shared_types_same_blockset_test");
211 if (shared_types_same_blockset_test) {
212 const auto elastic_params =
213 json_config->getParamsFromBlockset("MAT_ELASTIC", 1001);
214 if (elastic_params.at("young") != 1000.0 ||
215 elastic_params.at("poisson") != 0.3) {
217 "Unexpected shared-block MAT_ELASTIC params from JSON");
218 }
219 const auto elastic_string_params =
220 json_config->getStringParamsFromBlockset("MAT_ELASTIC", 1001);
221 if (elastic_string_params.at("model_spec") != "incompressible") {
223 "Unexpected shared-block MAT_ELASTIC string params from JSON");
224 }
225
226 const auto thermal_params =
227 json_config->getParamsFromBlockset("MAT_THERMAL", 1001);
228 if (thermal_params.at("conductivity") != 11.0 ||
229 thermal_params.at("heatcapacity") != 22.0) {
231 "Unexpected shared-block MAT_THERMAL params from JSON");
232 }
233 const auto thermal_string_params =
234 json_config->getStringParamsFromBlockset("MAT_THERMAL", 1001);
235 if (thermal_string_params.at("load_history") !=
236 "~/thermal_load_case.txt") {
238 "Unexpected shared-block MAT_THERMAL string params from JSON");
239 }
240
241 const int elastic_id = assertBlockAttributesByName(
242 m_field, "MAT_ELASTIC_elastic_domain_1001", {1000.0, 0.3},
243 "MAT_ELASTIC");
244 const int thermal_id = assertBlockAttributesByName(
245 m_field, "MAT_THERMAL_elastic_domain_3003", {11.0, 22.0},
246 "MAT_THERMAL");
247 if (elastic_id == thermal_id) {
249 "Expected distinct blocksets for shared source meshset name");
250 }
251
252 const auto thermal_target_params =
253 json_config->getParamsFromBlockset("MAT_THERMAL", thermal_id);
254 if (thermal_target_params.at("conductivity") != 11.0 ||
255 thermal_target_params.at("heatcapacity") != 22.0) {
257 "Unexpected shared-block MAT_THERMAL params for target id");
258 }
259 const auto thermal_target_string_params =
260 json_config->getStringParamsFromBlockset("MAT_THERMAL", thermal_id);
261 if (thermal_target_string_params.at("load_history") !=
262 "~/thermal_load_case.txt") {
263 SETERRQ(
265 "Unexpected shared-block MAT_THERMAL string params for target id");
266 }
267 }
268
269 if (!shared_types_same_blockset_test) {
270 const bool expect_multiple_python_scripts =
271 hasOption("-expect_multiple_python_scripts");
272 if (json_config->getMoabMeshByKey("primary") != "json_primary_mesh.h5m") {
274 "Unexpected keyed MOAB mesh lookup result");
275 }
276 if (!json_config->getMoabMeshByKey("missing_mesh").empty()) {
278 "Unexpected missing keyed MOAB mesh lookup result");
279 }
280 if (expect_multiple_python_scripts) {
281 if (json_config->getMoabMeshByKey("background_mesh") !=
282 "rectangle_quad.h5m") {
284 "Unexpected auxiliary keyed MOAB mesh lookup result");
285 }
286 if (json_config->getPythonScriptByKey("python_script_1") !=
287 "./sdf_files/sdf_hertz_2d_plane.py" ||
288 json_config->getPythonScriptByKey("python_script_2") !=
289 "./sdf_files/sdf_hertz_2d_plane_2.py") {
291 "Unexpected keyed Python script lookup result");
292 }
293 } else {
294 if (json_config->getPythonScriptByKey("python_script") !=
295 "./sdf_files/sdf_hertz_2d_plane.py") {
297 "Unexpected keyed Python script lookup result");
298 }
299 }
300 if (!json_config->getPythonScriptByKey("missing_script").empty()) {
302 "Unexpected missing keyed Python script lookup result");
303 }
304
305 const auto elastic_params =
306 json_config->getParamsFromBlockset("hencky", 1001);
307 if (elastic_params.at("young") != 1000.0 ||
308 elastic_params.at("poisson") != 0.3) {
310 "Unexpected hencky params from JSON");
311 }
312 if (hasOption("-expect_string_params")) {
313 const auto elastic_string_params =
314 json_config->getStringParamsFromBlockset("hencky", 1001);
315 if (elastic_string_params.at("model_spec") != "incompressible" ||
316 elastic_string_params.at("load_history") != "~/load_case1.txt") {
318 "Unexpected hencky string params from JSON");
319 }
320 }
321
322 const auto generic_params =
323 json_config->getParamsFromBlockset("GENERIC_BLOCK", 1007);
324 if (generic_params.at("user1") != 9.0 ||
325 generic_params.at("user1b") != 8.0) {
327 "Unexpected GENERIC_BLOCK params from JSON");
328 }
329
330 const auto int_electric_custom_params =
331 json_config->getParamsFromBlockset("INT_ELECTRIC_CUSTOM", 1008);
332 if (int_electric_custom_params.at("charge_density") != 12.0 ||
333 int_electric_custom_params.at("mobility") != 13.0 ||
334 int_electric_custom_params.at("scale") != 14.0) {
336 "Unexpected INT_ELECTRIC_CUSTOM params from JSON");
337 }
338
339 const auto mooney_rivlin_params =
340 json_config->getParamsFromBlockset("MAT_MOONEY_RIVLIN", 1004);
341 const bool has_mooney_rivlin_params = !mooney_rivlin_params.empty();
342
343 const auto displacement_params =
344 json_config->getParamsFromBlockset("DISPLACEMENT", 2001);
345 if (displacement_params.at("flag1") != 1.0 ||
346 displacement_params.at("flag2") != 1.0 ||
347 displacement_params.at("flag3") != 0.0 ||
348 displacement_params.at("value3") != 3.0) {
350 "Unexpected DISPLACEMENT params from JSON");
351 }
352
353 const auto force_params =
354 json_config->getParamsFromBlockset("FORCE", 2002);
355 if (force_params.at("force_magnitude") != 10.0 ||
356 force_params.at("moment_magnitude") != 11.0 ||
357 force_params.at("moment_my") != 1.0) {
359 "Unexpected FORCE params from JSON");
360 }
361
362 const auto temperature_params =
363 json_config->getParamsFromBlockset("TEMPERATURE", 2003);
364 if (temperature_params.at("flag1") != 1.0 ||
365 temperature_params.at("value1") != 123.0) {
367 "Unexpected TEMPERATURE params from JSON");
368 }
369
370 const auto pressure_params =
371 json_config->getParamsFromBlockset("PRESSURE", 3001);
372 if (pressure_params.at("flag2") != 1.0 ||
373 pressure_params.at("value1") != 12.5) {
375 "Unexpected PRESSURE params from JSON");
376 }
377
378 const auto heatflux_params =
379 json_config->getParamsFromBlockset("HEATFLUX", 3002);
380 if (heatflux_params.at("flag1") != 1.0 ||
381 heatflux_params.at("value1") != 99.0) {
383 "Unexpected HEATFLUX params from JSON");
384 }
385
386 if (!json_config->getParamsFromBlockset("UNKNOWN_TYPE", 1007).empty()) {
388 "Unexpected params returned for unknown blockset type");
389 }
390 if (!json_config->getStringParamsFromBlockset("UNKNOWN_TYPE", 1007)
391 .empty()) {
393 "Unexpected string params returned for unknown blockset type");
394 }
395
396 assertBlockAttributes(m_field, 1001, {1000.0, 0.3, 1e-5, 7.0}, "hencky");
397 assertBlockAttributes(m_field, 1002, {1.0, 2.0, 3.0, 4.0, 5.0},
398 "MAT_ELASTIC_TRANSISO");
399 assertBlockAttributes(m_field, 1003, {11.0, 22.0}, "MAT_THERMAL");
400 if (has_mooney_rivlin_params) {
401 assertBlockAttributes(m_field, 1004, {2.0, 3.0, 4.0, 0.5},
402 "MAT_MOONEY_RIVLIN");
403 }
404 assertBlockAttributes(m_field, 1005, {10.0, 20.0, 30.0, 40.0},
405 "MAT_INTERF");
406 assertBlockAttributes(m_field, 1006, {100.0, 1.0, 2.0, 3.0},
407 "BODYFORCES");
408 assertBlockAttributes(m_field, 1007, {9.0}, "GENERIC_BLOCK");
409 assertBlockAttributes(m_field, 1008, {12.0, 13.0, 14.0},
410 "INT_ELECTRIC_CUSTOM");
411 assertBlockAttributes(m_field, 2001, {1.0, 1.0, 0.0, 1.0, 2.0, 3.0},
412 "DISPLACEMENT");
413 assertBlockAttributes(
414 m_field, 2002, {10.0, 11.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0}, "FORCE");
415 assertBlockAttributes(m_field, 2003, {1.0, 123.0}, "TEMPERATURE");
416 assertBlockAttributes(m_field, 3001, {1.0, 12.5}, "PRESSURE");
417 assertBlockAttributes(m_field, 3002, {1.0, 99.0}, "HEATFLUX");
418 }
419 }
421
423}
#define CATCH_ERRORS
Catch errors.
@ MOFEM_ATOM_TEST_INVALID
#define CHKERR
Inline error check.
MoFEMErrorCode addMeshset(const CubitBCType cubit_bc_type, const int ms_id, const std::string name="")
Add CUBIT meshset to manager.
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Deprecated interface functions.
static MoFEMErrorCode addCanonicalAttributeNames(const std::vector< std::string > &names)
MoFEMErrorCode getSubInterfaceOptions()
Interface for managing meshsets containing materials and boundary conditions.
MoFEMErrorCode setMeshsetFromFile(const string file_name, const bool clean_file_options=true)
add blocksets reading config file
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.