138int main(
int argc,
char *argv[]) {
143 moab::Core mb_instance;
144 moab::Interface &moab = mb_instance;
152 const std::string expected_ksp_type =
153 readStringOption(
"-expected_ksp_type");
154 const std::string expected_pc_type =
155 readStringOption(
"-expected_pc_type");
156 std::string expected_file_name;
158 if (readStringOption(
"-ksp_type") != expected_ksp_type) {
160 "Unexpected -ksp_type value");
162 if (readStringOption(
"-pc_type") != expected_pc_type) {
164 "Unexpected -pc_type value");
166 assertNear(readRealOption(
"-ksp_rtol"), 1e-8, 1e-14,
167 "Unexpected -ksp_rtol");
168 if (readIntOption(
"-order") != 2) {
170 "Unexpected -order value");
172 if (readIntOption(
"-atom_test") != 1) {
174 "Unexpected -atom_test value");
176 if (!hasOption(
"-log_no_color")) {
178 "Expected -log_no_color option to be set");
180 if (readOptionalStringOption(
"-expected_file_name", expected_file_name)) {
181 if (readStringOption(
"-file_name") != expected_file_name) {
183 "Unexpected -file_name value");
205 CHKERR json_config->applyMeshsets();
207 const bool shared_types_same_blockset_test =
208 hasOption(
"-shared_types_same_blockset_test");
209 if (shared_types_same_blockset_test) {
210 const auto elastic_params =
211 json_config->getParamsFromBlockset(
"MAT_ELASTIC", 1001);
212 if (elastic_params.at(
"young") != 1000.0 ||
213 elastic_params.at(
"poisson") != 0.3) {
215 "Unexpected shared-block MAT_ELASTIC params from JSON");
218 const auto thermal_params =
219 json_config->getParamsFromBlockset(
"MAT_THERMAL", 1001);
220 if (thermal_params.at(
"conductivity") != 11.0 ||
221 thermal_params.at(
"heatcapacity") != 22.0) {
223 "Unexpected shared-block MAT_THERMAL params from JSON");
226 const int elastic_id = assertBlockAttributesByName(
227 m_field,
"MAT_ELASTIC_elastic_domain_1001", {1000.0, 0.3},
229 const int thermal_id = assertBlockAttributesByName(
230 m_field,
"MAT_THERMAL_elastic_domain_3003", {11.0, 22.0},
232 if (elastic_id == thermal_id) {
234 "Expected distinct blocksets for shared source meshset name");
237 const auto thermal_target_params =
238 json_config->getParamsFromBlockset(
"MAT_THERMAL", thermal_id);
239 if (thermal_target_params.at(
"conductivity") != 11.0 ||
240 thermal_target_params.at(
"heatcapacity") != 22.0) {
242 "Unexpected shared-block MAT_THERMAL params for target id");
246 if (!shared_types_same_blockset_test) {
247 const bool expect_multiple_python_scripts =
248 hasOption(
"-expect_multiple_python_scripts");
249 if (json_config->getMoabMeshByKey(
"primary") !=
"json_primary_mesh.h5m") {
251 "Unexpected keyed MOAB mesh lookup result");
253 if (!json_config->getMoabMeshByKey(
"missing_mesh").empty()) {
255 "Unexpected missing keyed MOAB mesh lookup result");
257 if (expect_multiple_python_scripts) {
258 if (json_config->getMoabMeshByKey(
"background_mesh") !=
259 "rectangle_quad.h5m") {
261 "Unexpected auxiliary keyed MOAB mesh lookup result");
263 if (json_config->getPythonScriptByKey(
"python_script_1") !=
264 "./sdf_files/sdf_hertz_2d_plane.py" ||
265 json_config->getPythonScriptByKey(
"python_script_2") !=
266 "./sdf_files/sdf_hertz_2d_plane_2.py") {
268 "Unexpected keyed Python script lookup result");
271 if (json_config->getPythonScriptByKey(
"python_script") !=
272 "./sdf_files/sdf_hertz_2d_plane.py") {
274 "Unexpected keyed Python script lookup result");
277 if (!json_config->getPythonScriptByKey(
"missing_script").empty()) {
279 "Unexpected missing keyed Python script lookup result");
282 const auto elastic_params =
283 json_config->getParamsFromBlockset(
"hencky", 1001);
284 if (elastic_params.at(
"young") != 1000.0 ||
285 elastic_params.at(
"poisson") != 0.3) {
287 "Unexpected hencky params from JSON");
290 const auto generic_params =
291 json_config->getParamsFromBlockset(
"GENERIC_BLOCK", 1007);
292 if (generic_params.at(
"user1") != 9.0 ||
293 generic_params.at(
"user1b") != 8.0) {
295 "Unexpected GENERIC_BLOCK params from JSON");
298 const auto int_electric_custom_params =
299 json_config->getParamsFromBlockset(
"INT_ELECTRIC_CUSTOM", 1008);
300 if (int_electric_custom_params.at(
"charge_density") != 12.0 ||
301 int_electric_custom_params.at(
"mobility") != 13.0 ||
302 int_electric_custom_params.at(
"scale") != 14.0) {
304 "Unexpected INT_ELECTRIC_CUSTOM params from JSON");
307 const auto displacement_params =
308 json_config->getParamsFromBlockset(
"DISPLACEMENT", 2001);
309 if (displacement_params.at(
"flag1") != 1.0 ||
310 displacement_params.at(
"flag2") != 1.0 ||
311 displacement_params.at(
"flag3") != 0.0 ||
312 displacement_params.at(
"value3") != 3.0) {
314 "Unexpected DISPLACEMENT params from JSON");
317 const auto force_params =
318 json_config->getParamsFromBlockset(
"FORCE", 2002);
319 if (force_params.at(
"force_magnitude") != 10.0 ||
320 force_params.at(
"moment_magnitude") != 11.0 ||
321 force_params.at(
"moment_my") != 1.0) {
323 "Unexpected FORCE params from JSON");
326 const auto temperature_params =
327 json_config->getParamsFromBlockset(
"TEMPERATURE", 2003);
328 if (temperature_params.at(
"flag1") != 1.0 ||
329 temperature_params.at(
"value1") != 123.0) {
331 "Unexpected TEMPERATURE params from JSON");
334 const auto pressure_params =
335 json_config->getParamsFromBlockset(
"PRESSURE", 3001);
336 if (pressure_params.at(
"flag2") != 1.0 ||
337 pressure_params.at(
"value1") != 12.5) {
339 "Unexpected PRESSURE params from JSON");
342 const auto heatflux_params =
343 json_config->getParamsFromBlockset(
"HEATFLUX", 3002);
344 if (heatflux_params.at(
"flag1") != 1.0 ||
345 heatflux_params.at(
"value1") != 99.0) {
347 "Unexpected HEATFLUX params from JSON");
350 if (!json_config->getParamsFromBlockset(
"UNKNOWN_TYPE", 1007).empty()) {
352 "Unexpected params returned for unknown blockset type");
355 assertBlockAttributes(m_field, 1001, {1000.0, 0.3, 1e-5, 7.0},
357 assertBlockAttributes(m_field, 1002, {1.0, 2.0, 3.0, 4.0, 5.0},
358 "MAT_ELASTIC_TRANSISO");
359 assertBlockAttributes(m_field, 1003, {11.0, 22.0},
"MAT_THERMAL");
360 assertBlockAttributes(m_field, 1005, {10.0, 20.0, 30.0, 40.0},
362 assertBlockAttributes(m_field, 1006, {100.0, 1.0, 2.0, 3.0},
364 assertBlockAttributes(m_field, 1007, {9.0, 8.0},
"GENERIC_BLOCK");
365 assertBlockAttributes(m_field, 1008, {12.0, 13.0, 14.0},
366 "INT_ELECTRIC_CUSTOM");
367 assertBlockAttributes(m_field, 2001, {1.0, 1.0, 0.0, 1.0, 2.0, 3.0},
369 assertBlockAttributes(m_field, 2002,
370 {10.0, 11.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0},
372 assertBlockAttributes(m_field, 2003, {1.0, 123.0},
"TEMPERATURE");
373 assertBlockAttributes(m_field, 3001, {1.0, 12.5},
"PRESSURE");
374 assertBlockAttributes(m_field, 3002, {1.0, 99.0},
"HEATFLUX");