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/gridedit 588 change to bounded array #182

Merged

Conversation

BillSenior
Copy link
Contributor

No description provided.

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.
@BillSenior BillSenior changed the base branch from master to release/v2.0.0 June 29, 2023 11:06
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[]>());
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

Copy link
Contributor

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?

@@ -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[]>());
Copy link
Contributor

Choose a reason for hiding this comment

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

same

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[]>());
Copy link
Contributor

Choose a reason for hiding this comment

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

same

@@ -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[]>());
Copy link
Contributor

Choose a reason for hiding this comment

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

same

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[]>());
Copy link
Contributor

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?

@ahmad-el-sayed ahmad-el-sayed merged commit c4dc6a6 into release/v2.0.0 Jun 29, 2023
11 of 12 checks passed
@BillSenior BillSenior deleted the feature/GRIDEDIT-588_change_to_bounded_array branch July 25, 2023 09:19
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.

None yet

3 participants