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

Add API for runtime remeshing #224

Merged
merged 5 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions changelog-entries/224.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Added API function `reset_mesh()`
4 changes: 4 additions & 0 deletions cyprecice/Participant.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ cdef extern from "precice/Participant.hpp" namespace "precice":

void setMeshTetrahedra (const string& meshName, vector[int] vertices)

# remeshing

void resetMesh (const string& meshName)

# data access

void writeData (const string& meshName, const string& dataName, vector[int] vertices, vector[double] values)
Expand Down
36 changes: 36 additions & 0 deletions cyprecice/cyprecice.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,42 @@ cdef class Participant:

self.thisptr.setMeshTetrahedra (convert(mesh_name), cpp_vertices)

# remeshing


def reset_mesh (self, mesh_name):
"""
Resets a mesh and allows setting it using set_mesh functions again.

Parameters
----------
mesh_name : str
Name of the mesh to reset.

Notes
-----
This function is still experimental.
Please refer to the documentation on how to enable and use it.

Previous calls:
advance() been called
fsimonis marked this conversation as resolved.
Show resolved Hide resolved

Examples
--------
Set mesh vertices for a 2D problem with 5 mesh vertices.
fsimonis marked this conversation as resolved.
Show resolved Hide resolved

>>> positions = np.array([[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]])
>>> mesh_name = "MeshOne"
>>> vertex_ids = participant.set_mesh_vertices(mesh_name, positions)
>>> # later in the coupling loop
>>> if remeshing_required():
>>> participant.reset_mesh(mesh_name)
>>> positions = np.array([[1, 1], [3, 3], [5, 5]])
>>> vertex_ids = participant.set_mesh_vertices(mesh_name, positions)
"""

self.thisptr.resetMesh (convert(mesh_name))

IshaanDesai marked this conversation as resolved.
Show resolved Hide resolved
# data access

def write_data (self, mesh_name, data_name, vertex_ids, values):
Expand Down
7 changes: 6 additions & 1 deletion test/Participant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,11 @@ void Participant::setMeshTetrahedra
precice::span<const precice::VertexID> vertices)
{}

void Participant::resetMesh
(
precice::string_view meshName)
{}
IshaanDesai marked this conversation as resolved.
Show resolved Hide resolved

void Participant:: writeData
(
precice::string_view meshName,
Expand Down Expand Up @@ -320,4 +325,4 @@ std::string getVersionInformation()
return fake_version;
}

} // namespace precice
} // namespace precice
Loading