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

Feature: Add a scalar and vector data field to VTK write test [2/3] #1488

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

holke
Copy link
Collaborator

@holke holke commented Mar 20, 2025

Describe your changes here:

The first step towards #1487.
The vtk_writer example did not write any user data.
Extended the example with 2 data fields, one scalar, one vector and dummy data.
The data fields do already contain values for the ghost elements.

All these boxes must be checked by the AUTHOR before requesting review:

  • The PR is small enough to be reviewed easily. If not, consider splitting up the changes in multiple PRs.
  • The title starts with one of the following prefixes: Documentation:, Bugfix:, Feature:, Improvement: or Other:.
  • If the PR is related to an issue, make sure to link it.
  • The author made sure that, as a reviewer, he/she would check all boxes below.

All these boxes must be checked by the REVIEWERS before merging the pull request:

As a reviewer please read through all the code lines and make sure that the code is fully understood, bug free, well-documented and well-structured.

General

  • The reviewer executed the new code features at least once and checked the results manually.
  • The code follows the t8code coding guidelines.
  • New source/header files are properly added to the CMake files.
  • The code is well documented. In particular, all function declarations, structs/classes and their members have a proper doxygen documentation.
  • All new algorithms and data structures are sufficiently optimal in terms of memory and runtime (If this should be merged, but there is still potential for optimization, create a new issue).

Tests

  • The code is covered in an existing or new test case using Google Test.

If the Pull request introduces code that is not covered by the github action (for example coupling with a new library):

  • Should this use case be added to the github action?
  • If not, does the specific use case compile and all tests pass (check manually).

Scripts and Wiki

  • If a new directory with source files is added, it must be covered by the script/find_all_source_files.scp to check the indentation of these files.
  • If this PR introduces a new feature, it must be covered in an example or tutorial and a Wiki article.

Tag Label

  • The author added the patch/minor/major label in accordance to semantic versioning.

License

  • The author added a BSD statement to doc/ (or already has one).

@holke
Copy link
Collaborator Author

holke commented Mar 20, 2025

Note: even though writing of ghosts was set true (and not changed by this commit), the ghost elements do not seem to be written, which is odd.

@holke
Copy link
Collaborator Author

holke commented Mar 20, 2025

Note: even though writing of ghosts was set true (and not changed by this commit), the ghost elements do not seem to be written, which is odd.

Could be resolved, the forest in the example was build without a ghost layer.

@holke holke changed the title Feature: Add a scalar and vector data field to VTK write test Feature: Add a scalar and vector data field to VTK write test [2/3] Mar 21, 2025
…iter' into feature-extend_vtk_test_with_data
@holke
Copy link
Collaborator Author

holke commented Mar 21, 2025

The tests fail in VTK API mode due to a ghost tree being requested by grid_element_shape and the function expecting only local trees.
@Davknapp is working on a solution.

void
vtk_writer_test_fill_data (const t8_locidx_t cells_to_write_count, std::vector<double> &scalar_data,
std::vector<double> &vector_data)
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{
{
scalar_data.resize (cells_to_write_count);
vector_data.resize (3 * cells_to_write_count);

I think it is better to use a single allocation instead of cells_to_write_count many

// vector[n] = (n/10.)
// Fill vector data vector with entries (0, 0, 42), (0.1,-0.1,42), ...
// vector[n] = (n/10.,-n/10., 42)
for (t8_locidx_t icell = 0; icell < cells_to_write_count; ++icell) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (t8_locidx_t icell = 0; icell < cells_to_write_count; ++icell) {
std::iota(scalar_data.begin(), scalar_data.end(), 0);
std::transform(scalar_data.begin(), scalar_data.end(), scalar_data.begin(), [](double val) { return val / 10.; });
std::generate(vector_data.begin(), vector_data.end(), [n = 0]() mutable {
double scalar_value = (n / 10.);
double vector_values[3] = { scalar_value, -scalar_value, 42. };
return vector_values[n++ % 3];
});

we could replace the loop by stl commands then. It has the drawback of looping three times over the arrray, though, so I would be okay with just removing the allocation from the loop too.

@Davknapp Davknapp assigned Davknapp and holke and unassigned Davknapp Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants