Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

mfem

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

How to offset a Mesh?#4638

Unanswered
M8kmyday asked this question inQ&A
Dec 22, 2024· 1 comments· 1 reply
Discussion options

For debugging, I would like to offset a 3D Mesh by moving it in 3D space by a distance given by delx, dely, and delz. Are these the only two steps that are required or is something else needed?

  1. loop through the vertices and apply the offset like this:
void offsetMesh (Mesh *mesh, real_t delx, real_t dely, real_t delz){   int i=0;   while (i < mesh->GetNV()) {      real_t *vertex=mesh->GetVertex(i);      vertex[0]+=delx;      vertex[1]+=dely;      vertex[2]+=delz;      i++;   }}
  1. call FinalizeMesh
You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

If the mesh is high order, the vertex coordinates don't matter (thenodes grid function does) and the above will not be enough.

The best way in general is to useMesh::Transform instead. This will work in both cases and will allow for more general geometry transformations.

If you have to do it once, a convenient way may be to useMesh Explorer by first modifying its internaltransformation() function.

You must be logged in to vote
1 reply
@pazner
Comment options

As@tzanio mentioned, the best way to do this is withMesh::Transform. In your example, you can do the following:

VectorFunctionCoefficienttransf_coeff(3, [delx,dely,delz](const Vector &x_in, Vector &x_out){   x_out[0] = x_in[0] + delx;   x_out[1] = x_in[1] + dely;   x_out[2] = x_in[2] + delz;});mesh.Transform(transf_coeff);
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
3 participants
@M8kmyday@tzanio@pazner

[8]ページ先頭

©2009-2025 Movatter.jp