Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding API to write nodal variable at once #47

Merged
merged 1 commit into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions include/exodusIIcppFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,13 @@ class File {
/// @param var_names Names of global variables
void write_global_var_names(const std::vector<std::string> & 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<double> & values);

/// Write nodal variable value to the ExodusII file
///
/// @param step_num Time step index
Expand Down
7 changes: 7 additions & 0 deletions src/exodusIIcppFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,13 @@
write_variable_names(this->exoid, EX_GLOBAL, var_names);
}

void
File::write_nodal_var(int step_num, int var_index, const std::vector<double> & values)

Check warning on line 689 in src/exodusIIcppFile.cpp

View workflow job for this annotation

GitHub Actions / c++ linter

src/exodusIIcppFile.cpp:689:7 [readability-make-member-function-const]

method 'write_nodal_var' can be made const
{
EXODUSIICPP_CHECK_ERROR(

Check warning on line 691 in src/exodusIIcppFile.cpp

View workflow job for this annotation

GitHub Actions / c++ linter

src/exodusIIcppFile.cpp:691:5 [cppcoreguidelines-pro-bounds-array-to-pointer-decay]

do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead
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,
Expand Down
7 changes: 7 additions & 0 deletions test/File_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ TEST(FileTest, create_edge2)
std::vector<int> connect1 = { 1, 2, 2, 3 };
f.write_block(1, "BAR2", 2, connect1);

f.write_time(1, 1.);

std::vector<std::string> 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
Expand Down
Loading