Debian Codegraph @

packages/seacas/applications/nem_spread/rf_mesh_param.C

raw
1 /*
2 * Copyright(C) 1999-2022, 2025 National Technology & Engineering Solutions
3 * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
4 * NTESS, the U.S. Government retains certain rights in this software.
5 *
6 * See packages/seacas/LICENSE for details
7 */
8
9 #include "copy_string_cpp.h"
10 #include "exodusII.h" // for MAX_LINE_LENGTH, ex_close, etc
11 #include "fmt/ostream.h"
12 #include "globals.h"
13 #include "nem_spread.h"
14 #include "rf_io_const.h" // for Debug_Flag, ExoFile
15 #include <cstdio> // for stderr
16 #include <cstdlib> // for exit
17 #include <cstring> // for memset
18
19 /* need to hang on to this to write it out to the proc 0 file */
20 std::string GeomTitle;
21
22 template void NemSpread<double, int>::read_mesh_param();
23 template void NemSpread<float, int>::read_mesh_param();
24 template void NemSpread<double, int64_t>::read_mesh_param();
25 template void NemSpread<float, int64_t>::read_mesh_param();
26
27 template <typename T, typename INT> void NemSpread<T, INT>::read_mesh_param()
28
29 /*
30 * Function which reads the sizing parameters from the EXODUS II database,
31 * which contains the mesh. This is used to cross-check against the
32 * load balancer file.
33 *
34 * ------------------------------------------------------------------------
35 *
36 * Functions called:
37 *
38 * check_exodus_error -- function which handles the error code returned by
39 * calls to EXODUS II API routines.
40 *
41 * ------------------------------------------------------------------------
42 */
43 {
44
45 /* Local variables */
46 std::string exofile;
47 int exoid;
48 int error;
49 int cpu_ws;
50 float version;
51
52 /**************************** execution begins *******************************/
53 cpu_ws = sizeof(float);
54
55 /*
56 * Generate the name of the parallel mesh file for this processor.
57 * Note: Default case is the scalar mesh file.
58 */
59
60 exofile = ExoFile;
61
62 /* initialize the io word size on all of the processors */
63 io_ws = 0;
64
65 int mode = EX_READ | int64api;
66
67 /* Open the EXODUS II mesh file */
68 exoid = ex_open(exofile.c_str(), mode, &cpu_ws, &io_ws, &version);
69 if (exoid == -1) {
70 fmt::print(stderr, "{}: ERROR opening up the mesh exoII file, {}\n", __func__, exofile);
71 exit(-1);
72 }
73 exoid += selected_change_set;
74
75 /* Read the initialization parameters */
76 ex_init_params info{};
77 info.title[0] = '\0';
78 error = ex_get_init_ext(exoid, &info);
79 check_exodus_error(error, "ex_get_init");
80
81 GeomTitle = info.title;
82 globals.Num_Dim = info.num_dim;
83 globals.Num_Node = info.num_nodes;
84 globals.Num_Elem = info.num_elem;
85 globals.Num_Elem_Blk = info.num_elem_blk;
86 globals.Num_Node_Set = info.num_node_sets;
87 globals.Num_Side_Set = info.num_side_sets;
88
89 fmt::print("\nExodus file ({})\n", exofile);
90 fmt::print("\tTitle of file: '{}'\n", GeomTitle);
91 fmt::print("\tDimensionality of problem = {:14}\n", fmt::group_digits(globals.Num_Dim));
92 fmt::print("\tNumber of nodes = {:14}\n", fmt::group_digits(globals.Num_Node));
93 fmt::print("\tNumber of elements = {:14}\n", fmt::group_digits(globals.Num_Elem));
94 fmt::print("\tNumber of element blocks = {:14}\n", fmt::group_digits(globals.Num_Elem_Blk));
95 fmt::print("\tNumber of node sets = {:14}\n", fmt::group_digits(globals.Num_Node_Set));
96 fmt::print("\tNumber of side sets = {:14}\n\n", fmt::group_digits(globals.Num_Side_Set));
97
98 /* Close the file */
99 error = ex_close(exoid);
100 check_exodus_error(error, "ex_close");
101
102 } /* END of routine read_mesh_params *****************************************/