diff --git a/include/exodusIIcppFile.h b/include/exodusIIcppFile.h index ce8d062..491103f 100644 --- a/include/exodusIIcppFile.h +++ b/include/exodusIIcppFile.h @@ -374,6 +374,13 @@ class File { /// @param var_names Names of global variables void write_global_var_names(const std::vector & var_names); + /// Write nodal variable values to the ExodusII file + /// + /// @param step_num Time step index + /// @param var_index Variable index + /// @param values Values to write + void write_nodal_var(int step_num, int var_index, const std::vector & values); + /// Write nodal variable value to the ExodusII file /// /// @param step_num Time step index diff --git a/src/exodusIIcppFile.cpp b/src/exodusIIcppFile.cpp index d3c3667..bb1eb27 100644 --- a/src/exodusIIcppFile.cpp +++ b/src/exodusIIcppFile.cpp @@ -685,6 +685,13 @@ File::write_global_var_names(const std::vector & var_names) write_variable_names(this->exoid, EX_GLOBAL, var_names); } +void +File::write_nodal_var(int step_num, int var_index, const std::vector & values) +{ + EXODUSIICPP_CHECK_ERROR( + ex_put_var(this->exoid, step_num, EX_NODAL, var_index, 0, values.size(), values.data())); +} + void File::write_partial_nodal_var(int step_num, int var_index, diff --git a/test/File_test.cpp b/test/File_test.cpp index e5bf132..d737635 100644 --- a/test/File_test.cpp +++ b/test/File_test.cpp @@ -169,6 +169,13 @@ TEST(FileTest, create_edge2) std::vector connect1 = { 1, 2, 2, 3 }; f.write_block(1, "BAR2", 2, connect1); + f.write_time(1, 1.); + + std::vector nv_names = { "nv1" }; + f.write_nodal_var_names(nv_names); + f.write_nodal_var(1, 1, { 10, 11, 12 }); + f.update(); + f.close(); // check the file that we created