Romin Tomasetti (9b477e5b) at 17 Aug 11:11
Romin Tomasetti (9b477e5b) at 10 Aug 09:10
api(c++): move semantics for addMEdge
and addMFace
This PR adds move semantic for GModel::addMEdge
and GModel::addMFace
.
I also added GModel::getNumMFaces
and GModel::getNumMEdges
to help making proper std::vector::reserve
whenever possible.
Romin Tomasetti (b84f2135) at 10 Aug 09:04
api(c++): move semantics for addMEdge
and addMFace
... and 166 more commits
Our internal mesh representation is in terms of:
Our "GMSH mesh" to "internal mesh" converter goes through 3 successive steps:
At the "read geometry" stage, we have a vector of unique node tags in a specific order, and we want to retrieve their coordinates.
This vector of nodes:
getNodes(/*dim*/-1, /*tag*/ -1)
, and then reordergetNode(itag)
in a for loop over our vector of node tags.The drawback of getNode
is that it also computes parametric coordinates that we don't need, and thereby "wastes" CPU time.
We see 2 limitations associated with the current API:
getNodes
loops over entities and pushes back (because it does not know the number of nodes in advance). Therefore, it cannot be parallelized.getNode
for now "wastes" CPU cycles to compute parametric coordinates even if they are not needed.We could still ask the user to write the for loop, and decide whether or not he wants to make it parallel.
Also, for 1D or 2D models, the z
coordinate may be useless.
// We intentionally forgot the 'parametric' stuff to keep it short.
void getNodeCoordinates(const size_t nodeTag, double* coords, const unsigned short dim, const bool parametric = false)
{
// Uses the node cache
const MVertex *v = GModel::current()->getMeshVertexByTag(nodeTag);
coords[0] = v->x();
if(dim > 1) {
coords[1] = v->y();
if(dim > 2) {
coords[2] = v->z();
}
}
}
Instead of double*
, an iterator could also be given. I think GMSH is not yet on C++ 20 so std::span
is not a solution...
If a user has a list of node tags, and wants to retrieve their coordinates, I think there is no straightforward way of doing it. For now, it seems a for loop
querying getNode
on the user side is needed. Moreover, getNodes
does "unnecessary" stuff in this case (such as returning the entity it belongs to, returning both parametric and normal coordinates, and so on).
Here is a code snippet.
/**
* Return the (parametric) coordinates of nodes.
*/
GMSH_API void gmsh::model::mesh::getNodesCoordinates(const std::vector<std::size_t>& nodeTags,
std::vector<double> &coords,
const bool parametric = false)
{
if(!_checkInit()) return;
const short ss = parametric ? 2 : 3;
coords.resize(ss * nodeTags.size());
for(size_t inode = 0; inode < nodeTags.size(); ++inode) {
const MVertex *v = GModel::current()->getMeshVertexByTag(nodeTags.at(inode));
if(!v) {
Msg::Error("Unknown node %d", nodeTag);
return;
}
if(!parametric) {
coord[inode * 3 + 0] = v->x();
coord[inode * 3 + 1] = v->y();
coord[inode * 3 + 2] = v->z();
} else {
double u;
if(v->getParameter(0, u)) parametricCoord.push_back(u);
if(v->getParameter(1, u)) parametricCoord.push_back(u);
}
}
}
Romin Tomasetti (0c268f21) at 15 Feb 08:57
move semantics for addMEdge
and addMFace
@geuzaine I guess any function that has const int dim = -1
would receive this additional argument ? That would lead to modifying:
It would be nice that getters of the C++ API like getPhysicalGroups
or getEntities
could also return all objects up to a dimension at once, to avoid a user-side for loop over dimensions.
An embryo of the changes is available there:
Romin Tomasetti (20856524) at 11 Feb 13:37
api(c++): get more from getPhysicalGroups and getEntities
... and 105 more commits
Romin Tomasetti (0df8fbf2) at 11 Feb 12:51
This MR addresses #2173.
libgmsh.so
does not expose MPI symbols MUMPS.py
to ensure fvisibility=hidden
is passed to it when compiled using awk
(that will fail if the patch cannot be applied) @geuzaine The patch could also be a real patch
file, that would need to be stored somewhere in your repository. If the current approach is okay for you, just let me know
To do before merging:
onelab
image for the CI to pass scp
line and remove fix-mpi-symbols-leak@romin.tomasetti/gmsh
only rule in the CI Romin Tomasetti (0df8fbf2) at 11 Nov 17:02
fix(symbols): removing leaking MPI symbols (see #2173)
Romin Tomasetti (94875bea) at 11 Nov 12:40
fix(symbols): removing leaking MPI symbols (see #2173)
Romin Tomasetti (469bc290) at 11 Nov 12:15
fix(symbols): removing leaking MPI symbols (see #2173)
Romin Tomasetti (e4737bc5) at 11 Nov 11:58
fix(symbols): removing leaking MPI symbols (see #2173)
Romin Tomasetti (fa9ec1bf) at 11 Nov 11:40
fix(symbols): removing leaking MPI symbols (see #2173)
Romin Tomasetti (676ca52c) at 11 Nov 11:29
fix(symbols): removing leaking MPI symbols (see #2173)
Romin Tomasetti (ceca4e62) at 11 Nov 11:10
fix(symbols): removing leaking MPI symbols (see #2173)
Romin Tomasetti (274e49d3) at 11 Nov 11:07
fix(symbols): removing leaking MPI symbols (see #2173)