-
Notifications
You must be signed in to change notification settings - Fork 8
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/gridedit 588 change to bounded array #182
Feature/gridedit 588 change to bounded array #182
Conversation
Smaller changes to be able to build using gcc 13.1. Added missing header Changed unique_ptr with "new char" to std::array Added default_delete to shared_ptr
In a 2d mesh, for the edges-faces array, change the std::vector to a std::array constrained with size 2. This change is ok, because each edge can only have, at most, two neighbouring faces (boundary edges will have 1). This results in fewer allocations of small (size 2) vectors and a small performace improvement.
Changed interface for IsEqual, the third parameter is now the relative tolerance rather than a tolerance multiplier. This gives a more meaningful statement if the value is passed and saves on a multiply in the function. FindFacesRecursive Replaced some emplace_back with push_back, this has a small improvement on performance. ComputeFaceCircumenter Replaced vector with array, the maximum size is known at compile time.
tools/test_utils/src/MakeMeshes.cpp
Outdated
std::shared_ptr<int> edge_nodes(new int[num_edges * 2]); | ||
std::shared_ptr<int> edge_type(new int[num_edges]); | ||
nc_inq_dim(ncidp, dimid, read_name.data(), &num_edges); | ||
std::shared_ptr<double> node_x(new double[num_nodes], std::default_delete<double[]>()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we simply use vectors instead of shared_ptr? this requires using the data method instead of get in the calls nc_* below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I did think about that, but went for the least disruptive option.
I will change these to std::vector.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use make_shared, and avoid new?
tools/test_utils/src/MakeMeshes.cpp
Outdated
@@ -251,8 +253,8 @@ MakeRectangularMeshForApiTesting( | |||
auto num_x = num_columns + static_cast<size_t>(1); | |||
|
|||
std::vector<std::vector<size_t>> indicesValues(num_x, std::vector<size_t>(num_y)); | |||
std::shared_ptr<double> node_x(new double[num_x * num_y]); | |||
std::shared_ptr<double> node_y(new double[num_x * num_y]); | |||
std::shared_ptr<double> node_x(new double[num_x * num_y], std::default_delete<double[]>()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
tools/test_utils/src/MakeMeshes.cpp
Outdated
std::shared_ptr<double> node_x(new double[num_x * num_y]); | ||
std::shared_ptr<double> node_y(new double[num_x * num_y]); | ||
std::shared_ptr<double> node_x(new double[num_x * num_y], std::default_delete<double[]>()); | ||
std::shared_ptr<double> node_y(new double[num_x * num_y], std::default_delete<double[]>()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
tools/test_utils/src/MakeMeshes.cpp
Outdated
@@ -267,7 +269,7 @@ MakeRectangularMeshForApiTesting( | |||
} | |||
} | |||
|
|||
std::shared_ptr<int> edge_nodes(new int[((num_x - 1) * num_y + (num_y - 1) * num_x) * 2]); | |||
std::shared_ptr<int> edge_nodes(new int[((num_x - 1) * num_y + (num_y - 1) * num_x) * 2], std::default_delete<int[]>()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
In places where compilation failed using gcc 13.1
tools/test_utils/src/MakeMeshes.cpp
Outdated
std::shared_ptr<int> edge_nodes(new int[num_edges * 2]); | ||
std::shared_ptr<int> edge_type(new int[num_edges]); | ||
nc_inq_dim(ncidp, dimid, read_name.data(), &num_edges); | ||
std::shared_ptr<double> node_x(new double[num_nodes], std::default_delete<double[]>()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use make_shared, and avoid new?
No description provided.