Mesh perturbation in C++

More
3 years 10 months ago #3542 by JBalis
Hello,

I am using a C++ HDG solver which interfaces Netgen. For a project, I would like to perturb the Netgen mesh by changing vertex coordinates.

I have a shared_ptr<MeshAccess> pointer to access the mesh nodes and I tried to perturb them this way:
Code:
Vec<D> vertex; double eps = 1E-8; for (int j = 0; j < VolumeVertices.size(); ++j) { ma->GetPoint(VolumeVertices[j], vertex); for (int dd = 0; dd < D; ++dd){ vertex(dd) = vertex(dd)+eps; } }

but that does not work because I am not updating the actual vertices inside Netgen.

What I would like is to have two pointers, one to the initial unperturbed mesh and one to the deformed mesh but I do not really know how to proceed.

Could you indicate me how to change user-defined vertex coordinates and update the mesh metrics in C++ while keeping an access to the initial mesh? I could not find how to do that when browsing the mesh classes of Netgen.

Thank you very much,

Joachim
More
3 years 10 months ago - 3 years 10 months ago #3543 by cwinters
Replied by cwinters on topic Mesh perturbation in C++
Hi Joachim,

the shared_ptr<MeshAccess> holds a shared pointer to the Netgen class Mesh (in libsrc/meshing/meshclass.hpp), which can be accessed by "GetNetgenMesh()".
Having the Mesh object on the Netgen side, you can get a reference to the points using the member function "Points()", which allows you to modify them.

I guess you have to start with two meshes on the Netgen side and perturb one of them, otherwise you won't be able to keep initial mesh.

Best,
Christoph
Last edit: 3 years 10 months ago by cwinters.
More
3 years 10 months ago #3547 by JBalis
Replied by JBalis on topic Mesh perturbation in C++
Dear Christoph,

Thank you very much for your reply! With your advice, I managed to modify the vertices coordinates.

What I would like is to keep the solution field the same before and after mesh perturbation, and just modify the mesh metrics. I am thus wondering which routines I should call to update the mesh topology properly (Jacobians, face normals, etc.)?

Right now, I am doing:
Code:
shared_ptr<MeshAccess> ma; shared_ptr<netgen::Mesh> ngmesh = ma->GetNetgenMesh(); MeshManipulation(); ma->UpdateBuffers(); ngmesh->UpdateTopology();

Is it sufficient to do it this way or are there other functions that I need to call?

Thanks again,

Joachim
More
3 years 10 months ago #3551 by cwinters
Replied by cwinters on topic Mesh perturbation in C++
Hi Joachim,

since you just change the coordinates of the points and not the topology (like number of vertices, edges, ...) I think you need neither of them.
Jacobians, normals and so on are calculated based on the ElementTransformation, which loads the coordinates of the points when it is created. Thus you should get the updated ones.

Another option came into my mind, which is used for ALE. You could use
Code:
MeshAccess :: SetDeformation (shared_ptr<GridFunction> def)
to set a mesh deformation, which is also considered when Jacobians and normals are calculated.

Best,
Christoph
The following user(s) said Thank You: JBalis
More
3 years 10 months ago #3552 by JBalis
Replied by JBalis on topic Mesh perturbation in C++
Dear Christoph,

Thank you very much for your kind input, I will continue working on that.

Best,

Joachim
Time to create page: 0.130 seconds