This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

MeshEditor with MPI

0 votes

Dear all,

I am starting a project that needs to locally modify a mesh (in C++). Now, the task right now is simple: I'd like to remove one cell, and in the future add some new cells, of course. In order to get used to MeshEditor, I am playing with a square mesh, and extracting the boundary vertices.

However, it crashes (*). It seems that I am creating an invalid mesh, but since I am using a pre-existing mesh, I am puzzled. I think I don't understand how to use MeshEditor, I thought I could modify meshes, but it can only create ones.

So, how can I locally modify a mesh?

Should I create a new mesh, each process adding its own old vertices (from the old mesh) except the chosen process that will use an updated vertex list? It seems quite a waste of memory...

Thanks!

(*)

    // Local mesh data, may be useless
    LocalMeshData local(squareMesh);

    BoundaryMesh bdry(squareMesh, "local");
    File bfile(dumpPath() + "localboundary.pvd", "compressed");
    bfile << bdry;

    MeshEditor e;
    e.open(squareMesh, 2, 2);

    // Print cell
    if (num > 0)
    {
        info("Only rank %d will proceed", rank);

        info("+++ RANK %d SIZE %d POS %d", rank, squareMesh.coordinates().size(), t.pos());
        double coords[6];
        t->get_vertex_coordinates(coords);

        for (double q : coords)
            info("    coord %f", q);

        info("+++ vertXcell %d globV %d globC %d", local.num_vertices_per_cell, local.num_global_vertices, local.num_global_cells);
        for (VertexIterator v(bdry); !v.end(); ++v)
        {
            info("   V [%f, %f]", bdry.geometry().x(v->index())[0], bdry.geometry().x(v->index())[1]);
        }
    }

    e.close();
asked Oct 9, 2015 by senseiwa FEniCS User (2,620 points)

1 Answer

+2 votes
 
Best answer

Yes, you need to create a new Mesh. Changing a Mesh in place causes too many headaches, as many things may depend on it, e.g. dofmaps, MeshFunctions etc.

answered Oct 10, 2015 by chris_richardson FEniCS Expert (31,740 points)
selected Oct 10, 2015 by senseiwa

Thanks Chris, I will try to create a new mesh then.

...