Skip to content

Include instructions to remove .data() in readData function#313

Merged
fsimonis merged 5 commits intoprecice-v3from
carme-hp-patch-1
Dec 14, 2023
Merged

Include instructions to remove .data() in readData function#313
fsimonis merged 5 commits intoprecice-v3from
carme-hp-patch-1

Conversation

@carme-hp
Copy link
Copy Markdown
Member

Calling .data() is not needed anymore because the data objects are now vectors. The porting guide did not have any instructions on this

- Directly define face elements or cells of your coupling mesh available in your solver by passing their vectices to preCICE, which automatically handles edges of triangles etc. See [Mesh Connectivity](couple-your-code-defining-mesh-connectivity) for more information.
- Rename `setMeshTriangleWithEdges` to `setMeshTriangle` and `setMeshQuadWithEdges` to `setMeshQuad`. The edge-based implementation was removed.
- Use the new bulk functions to reduce sanitization overhead: `setMeshEdges`, `setMeshTriangles`, `setMeshQuads`, `setMeshTetrahedra`.
- Replace pointer data structures by vectors, e.g., `double* forces = new double[vertexSize*dim]` to `std::vector<double> forces(vertexSize*dim)`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In this example, forces is a data structure create and handled by the user. The way we used it in our example API was just one version of how such a data structure could look like and how to use it with preCICE. However, both versions (i.e. what you call pointer data structure and vectors) work with the v2 API as well as the v3 API. The C-style array we use in our v2 example is not really a C++ way of doing things and I would expect C++ codes to use vectors anyway. Having this in mind, I am not sure about this hint in the porting guide. We should mention somewhere that the signature (of e.g. readData) changed from a raw pointer to a span.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Okay, I agree that using raw pointers is just one specific case.

We should mention somewhere that the signature (of e.g. readData) changed from a raw pointer to a span.

Stating this should be sufficient, since this already clarifies that raw pointers can no longer be an argument to readData.

In any case my motivation for this was a case in v2 of a std::vector<double> forces that was given to readData as forces.data(). So when I ported to v3 to me it was not obvious that I should drop the data.().

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe we could explain the change to span and then give @carme-hp 's situation as an example? Could be relevant for more users.

@carme-hp
Copy link
Copy Markdown
Member Author

I tried to do what @uekerman suggested. Let me know if this is better.

@fsimonis
Copy link
Copy Markdown
Member

fsimonis commented Dec 12, 2023

@carme-hp I think a major point of confusion is that we don't only change the interfaces from pointers to spans in the examples, but we simultaneously change the types that hold the data from C array to vector.

I attempted to make this a bit clearer in #316. Do you think this is easier to follow?

@fsimonis
Copy link
Copy Markdown
Member

I missed the last commit. This makes things way cleaner. I'll merge this and then rebase further overhauls on it.

@fsimonis fsimonis changed the base branch from master to precice-v3 December 14, 2023 06:33
@fsimonis fsimonis merged commit 4b167ce into precice-v3 Dec 14, 2023
uekerman added a commit that referenced this pull request Feb 12, 2024
* Fix whitespace.

* Update action config docs to v3 (#254)

* Update Roadmap

* Update fundamentals-roadmap.md

* Use time step, not timestep. (#259)

* v3: Update documentation w.r.t getMaxTimeStep(). (#258)

* Update documentation w.r.t getMaxTimeStep().
* Implements changes from precice/precice#1623

---------

Co-authored-by: Benjamin Uekermann <[email protected]>

* Minor follow-up for #258.

* Update documentation for initialize (#186)

* Documentation for data initialization changes introduced in v3.0.0.
* Cleanup initializeData.

---------

Co-authored-by: Benjamin Uekermann <[email protected]>
Co-authored-by: Benjamin Uekermann <[email protected]>

* Update profiling section (#266)

* Update profiling section

* Update examples in profiling section

* Apply suggestions from code review

Co-authored-by: Benjamin Uekermann <[email protected]>

* Add motivation for custom tool

* Wording tweaks

* More rewording

* Update event files in output files

---------

Co-authored-by: Benjamin Uekermann <[email protected]>

* Fix typo in profiling

* Update profiling info in guide

* Update CMake variables to new names (#289)

* Clarify some instructions in porting guide (#287)

Co-authored-by: Gerasimos Chourdakis <[email protected]>

* Fix minor issues in tooling/performance-analysis (#272)

* Rename events to profiling

according to precice/precice #1787

* Mention where to find the precice-profiling

* Add hint regarding the event flag in precice-profiling

* Add recommendation for `imvj-restart-mode` in configuration of acceleration (#296)

* Update configuration-acceleration.md

Add recommendation to use restart mode in `IQN-IMVJ` method for large-scale simulations.

* Update pages/docs/configuration/configuration-acceleration.md

Improve descriptive accuracy

Co-authored-by: Benjamin Uekermann <[email protected]>

---------

Co-authored-by: Benjamin Uekermann <[email protected]>

* Apply trivial renaming changes.

* Fix naming.

* Add note.

* Update breaking API changes (#299)

---------

Co-authored-by: Gerasimos Chourdakis <[email protected]>

* Fix token

* Fix arg

* Bump preCICE version

* Update hint on formatting configuration files

* Refer to precice.hpp instead of participant.hpp

* Update version in docs sidebar

* Rewrite mapping docs (#308)

* Add overview figure

* Work in progress

* Fix links

* Transform pdfs to svgs

* Update kernel method section

* Also write about GPU executors

* Language edits by Benjamin and Makis

Co-authored-by: Gerasimos Chourdakis <[email protected]>
Co-authored-by: Benjamin Uekermann <[email protected]>

* Review updates

* Makis language edits

Co-authored-by: Gerasimos Chourdakis <[email protected]>

* Fix typos via aspell

---------

Co-authored-by: Gerasimos Chourdakis <[email protected]>
Co-authored-by: Benjamin Uekermann <[email protected]>

* Fix some outdated solver-interface and dimensions (#314)

* Migrate use-mesh to provide/receive-mesh

* Migrate binprecice to precice-tools

* Update config-visualizer page

* Include instructions to remove .data() in readData function (#313)

* Include instructions to remove .data() in readData function
* Mention span replacing raw pointers
* Remove raw pointers from general porting example

* Cleanup porting guide example

* Update couple your code

* Remove obsolete section regarding IDs

* Apply suggestions from code review

Co-authored-by: Ishaan Desai <[email protected]>

* This PR adds C++ STL linking from Doxygen to cppreference

* Fix WD

* Link to porting guides from the source docs

* Add list of porting guides to overview

* Add new solid solver to Nutils adapter overview page (#325)

* Geometric Multiscale Documentation (#205)

Co-authored-by: Gerasimos Chourdakis <[email protected]>

* Update submodules

* Ignore tooling in images

* Update xmlreference to v3.0.0

* Cleanup porting guide API+Config (#317)

Co-authored-by: Ishaan Desai <[email protected]>
Co-authored-by: Gerasimos Chourdakis <[email protected]>

* Update the rust bindings page

* Fix link

* Make dt in readData mandatory in documentation (#257)

* v3: Make dt mandatory in documentation

* Update read data functions to use relativeReadTime.

* change precice_dt to preciceDt and solver_dt to solverDt to follow
conventions.

* Add missing.

* Shorten a bit.

* Minor follow-up for #258.

* Add figure.

* Remove outdated note.

* Use dt properly.

* Remove unnecessary pdf.

* Partial update of documentation w.r.t breaking changes.

* Redice diff.

* Redice diff.

* Reduce diff.

* Fix some more breaking changes.

* Add how dt is computed. See #257.

* Apply suggestions from code review

Co-authored-by: Gerasimos Chourdakis <[email protected]>

* Remove unneeded.

* Add pointer to interpolation section.

* Fix format.

* Add advice on precice/precice#1866.

* Apply suggestions from code review

* Update some minor, obviously outdated points.

* Update png.

* Update pages/docs/couple-your-code/couple-your-code-mesh-and-data-access.md

Co-authored-by: Frédéric Simonis <[email protected]>

* Update heading.

* Moved changes to #326.

* Update pages/docs/couple-your-code/couple-your-code-mesh-and-data-access.md

* Update pages/docs/couple-your-code/couple-your-code-waveform.md

---------

Co-authored-by: Gerasimos Chourdakis <[email protected]>
Co-authored-by: Frédéric Simonis <[email protected]>
Co-authored-by: Benjamin Uekermann <[email protected]>

* Update submodules

* Remove v3 tip from roadmap

* Add rust bindings to installation overview

* Update libprecice2 to libprecice3 on Ubuntu packages page

* Update header names in installation-linking

* Update porting information on configuration overview page

* Update several things on configuration basics page

* Update configuration communication page

* Revert tweaks in configuration basics page

Previously, I changed from precice to participant as name for the preCICE handle and I used "Force" instead of "Forces" to be consistent with the tutorial guidelines. But both changes would also need updates on many other pages. Thus, I left them for the moment for consistency.

* Refer to QN default values on acceleration configuration

* Update porting info and mention Rust on couple your code start

* Change global dim to mesh dim in step 3

* Remove dim handling from step 6

* Fix getDataDim arguments in step 3

* Fix dim handling in step 9

* Fix dim in direct access

* Fix and tweak porting guide

* Make linter happy

* Make linter happier

* Add missing tutorials in the sidebar and overview (#334)

* Add partitioned-pipe-two-phase to sidebar and overview

* Add oscillator overlap in sidebar and overview

* Add partitioned-heat-conduction-overlap to the sidebar and overview

* Add volume-coupled-flow to sidebar and overview

* Add two-scale-heat-conduction to sidebar and overview

* Update pages/tutorials/tutorials.md

Co-authored-by: Ishaan Desai <[email protected]>

* Update pages/tutorials/tutorials.md

---------

Co-authored-by: Benjamin Uekermann <[email protected]>
Co-authored-by: Ishaan Desai <[email protected]>

* Update bindings overview picture (#333)

* Update bindings overview picture

* Move arrow of Python bindings to precice.hpp

* Add Rust bindings

---------

Co-authored-by: Benjamin Rodenberg <[email protected]>
Co-authored-by: Gerasimos Chourdakis <[email protected]>
Co-authored-by: Benjamin Rodenberg <[email protected]>
Co-authored-by: Frédéric Simonis <[email protected]>
Co-authored-by: David Schneider <[email protected]>
Co-authored-by: carme-hp <[email protected]>
Co-authored-by: June <[email protected]>
Co-authored-by: homspons <ge35joj>
Co-authored-by: Ishaan Desai <[email protected]>
Co-authored-by: Elia Zonta <[email protected]>
Co-authored-by: precice-bot <[email protected]>
Co-authored-by: Ishaan Desai <[email protected]>
@carme-hp carme-hp deleted the carme-hp-patch-1 branch February 14, 2024 12:37
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.

4 participants