A coupling library for partitioned multi-physics simulations, including, but not restricted to fluid-structure interaction and conjugate heat transfer simulations.
We currently have slight variations of the same code that handles adding one mesh to another.
void Mesh::addMesh(Mesh const& diff); adds the diff to the current mesh.
void ReceivedPartition::filterMesh(mesh::Mesh &filteredMesh, const bool filterByBB)
This adds the internal mesh to filteredMesh and filters vertices based on a predicate: tagged vertices, or vertices inside a bounding-box.
Both functions can be generalized to:
// Generalized version filtering vertices based on a given unary predicate.
template<typename UnaryPredicate>
void Mesh::addMesh(Mesh const& other, UnaryPredicate p);
// Version that simply adds the Mesh
void Mesh::addMesh(Mesh const& other) {
addMesh(other, [](mesh::Vertex const &) { return true; });
}
// The new possible implementation.
void ReceivedPartition::filterMesh(mesh::Mesh &filteredMesh, const bool filterByBB) {
if (filterByBB) {
filteredMesh.addMesh(_mesh,
[this](mesh::Vertex const & v){ return this->isVertexinBB(v);});
} else {
filteredMesh.addMesh(_mesh,
[](mesh::Vertex const & v){ return v.isTagged();});
}
}
This makes the code DRY, easier to maintain and allows us to optimize a single function.
We currently have slight variations of the same code that handles adding one mesh to another.
void Mesh::addMesh(Mesh const& diff);
adds thediff
to the current mesh.void ReceivedPartition::filterMesh(mesh::Mesh &filteredMesh, const bool filterByBB)
This adds the internal mesh tofilteredMesh
and filters vertices based on a predicate: tagged vertices, or vertices inside a bounding-box.Both functions can be generalized to:
This makes the code DRY, easier to maintain and allows us to optimize a single function.