Could I add new vertices and cell connectivities to the current mesh directly?

If I have a triangle mesh cell, [0,1,2], I hope to add vertices on the edges to refine by hand and add connectivity between vertices.

For example, I add nodes [4,5,6] on the edge(0,1), edge(1,2), edge(0,2), separately and connect (4,5), (4,6), (5,6). Is there any effective way helping this? So one cell becomes four cells.

I may do this to many meshes.

My current way:

I generate edges from cells firstly. ( I do not know if there are any functions helping me do this, I write it in python and seem not very effective. I do not find such functions in the docs)

Generate new vertices according to my strategy and add new nodes, connectivity.

At last, I use mesheditor to generator a new mesh from nothing according to the new connectivity.

Because I use python to accomplish this, and it seems not very smart. Is there any way helping do this splitting mesh process?

refine(mesh) does exactly the same thing, right ?

And if you only want to do it for a subset of cells, consider: https://bitbucket.org/fenics-project/dolfin/src/946dbd3e268dc20c64778eb5b734941ca5c343e5/python/demo/undocumented/refinement/demo_refinement.py#lines-52

1 Like

Thank you for the example and replies! Because I want to refine every cell of the mesh in my own ways, for example, maybe I do not want to add the points at the middle point of the edge or I want to change the edge connectivity strategy of the new nodes, which may be different from the refine function. Could it also be achieved by using refine function?

You could combine the refine with an ALE.move command, which contains the corresponding movement per cell. After refinement, i.e.
First refine the cells in question, then perturb the vertex coordinates.

1 Like

Thank you for answer my newbie questions! I do not know this before.

Quick questions for the edge connectivity. As you could see the mesh below, the refine function generates three new nodes at the bottom left conner. Could I also change the connectivity edge from (0,0) (0.25,0.25) to (0.25,0.0) (0.0, 0.25) ?

Init mesh: init_mesh
New mesh: move_mesh

I do not know how can do that with the built in refinement algorithm.

Our of curiousity, why are you refining your mesh in this particular way, and are you planning to use this approach of very local control of refinement on large scale meshes?