CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   How to change meshpoint coordiantes (https://www.cfd-online.com/Forums/openfoam-solving/58650-how-change-meshpoint-coordiantes.html)

thomas July 27, 2007 02:02

Hello everyone, in my solve
 
Hello everyone,

in my solver I need to change the coordinates of a meshpoint during running.
So I want to write something like:

point pos;
pos.x()=...
pos.y()=...
pos.z()=...

mesh.points()[indexmesh] = pos;

This gives me an compilation error, because mesh.point() is protected.

Does someone know, how to assign and change the point coordiantes?


Many Thanks
Thomas

martin July 27, 2007 02:25

Hi Thomas, Have you test to
 
Hi Thomas,

Have you test to wrap the points from the data base?
This might work (I haven't test it):
pointField& points=const_cast<pointfield&>(mesh.objectRegistry ::lookupObject<pointfield>("po int")); //Message board might destroy this line. It should be pointField and not pointfield, point and not po int

point pos;
pos.x()=...
pos.y()=...
pos.z()=...
points[indexmesh] = pos;

Regards,
Martin

thomas July 27, 2007 03:02

Hi Martin, thanks for your
 
Hi Martin,

thanks for your reply!

I just tested and compiling works, but while running Foam crashes with the following error:

--> FOAM FATAL ERROR :
request for Field point from objectRegistry region0 failed
available objects of type Field are

0
(
)

From function
objectRegistry::lookupObject<type>(const word&) const

So, as I understand, the field "point" does not exist.

Any suggestion?

thomas July 27, 2007 03:20

Sorry for the last prosting.
 
Sorry for the last prosting.

Just asking for "points" in the const_cast call solved the problem and now I can access the point coordinates.

Again, thanks very much!

braennstroem August 14, 2008 08:30

Hi, I have trouble with a s
 
Hi,

I have trouble with a similar approach during runtime:

pointField newPointAdded = zeroPoints + newPoints;
mesh.polyMesh::movePoints(newPointsmorphed);
mesh.write();

The new mesh works, but for the calculation the mesh needs some kind of an update otherwise it crashes. Does anyone know, how to tell openfoam, that there exist a new mesh? Would be nice, if anyone has a hint!?
Fabian

braennstroem August 14, 2008 09:37

It seems that I can reread the
 
It seems that I can reread the fields with the general 'createFields.H' (e.g. the one of simpleFoam) after defining the new points, but if this is done every iteration it could be time consuming. There is probably a more elegant way.

Fabian

aPostrophic February 17, 2011 04:25

I had the same problem.

Just use createDynamicMesh
.H instead of createMesh.H

and mesh.fvMesh::movePoints(newPointsmorphed); instead of mesh.polyMesh::movePoints(newPointsmorphed) and it works.

aPostrophic February 18, 2011 17:40

Does anybody know how i can set the velocity in ( pointMotionU) for a special point on a patch?


All times are GMT -4. The time now is 19:02.