CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   MotionUBoundaryPatch assignment HowTo (

bfa March 20, 2008 09:37

Hi all, first a rather long e
Hi all,
first a rather long explanation of what I'm trying to achieve:
I want to apply location-based displacement to boundary points of my mesh. I do the following so far inside my dynamicFvMesh derivative:

(1) grab all points from a boundaryPatch and move them according to a mathematical function. in pseudo code:
for all points()
if(point is in boundaryPatch.localPoints())
move point

Works fine so far

(2) movePoints(newPoints)

(3) get motionU for this patch

tetPointVectorField& motionU = mSolver.motionU();
fixedValueTetPolyPatchVectorField& motionUBodyPatch =

(4) assign the motionU (i.e. displacement/timeStep) to motionUBodyPatch
There is the problem: If I try
I only get the points of the un-tetragonized mesh. So I would need boundaryMesh.faceCentres additionally

My first Idea was to merge these two pointLists, but I think I'll run into trouble with the ordering.
Second Idea would be to decompose the boundaryMesh and get a tetPolyBoundaryMeshFaceDecomp, but so far I didn't manage to do so. Trying to construct these classes from polyMesh leads to compiler problems, since the constructors are private due to several layers of explicit functions and derivation.

Does anyone know how to do this decomposition in code?


lr103476 March 20, 2008 09:48

You could try to use a dynamic
You could try to use a dynamicFvMesh library based on the displacement fvMotionSolvers.......You will get something like:

pointVectorField& motionU = mSolver.pointDisplacement();
== fixedValuePointPatchVectorField::typeName
fixedValuePointPatchVectorField& motionUBodyPatch =

motionUBodyPatch == ( dispRot + dispTrans );


bfa March 20, 2008 09:58

Hi Frank, your suggestion wor
Hi Frank,
your suggestion works fine for rigid boundary, but in my case dispRot and dispTrans are different for _each_ point on my boundary. So motionU isn't fixedValue on the patch but non-uniform.

And additionally I intend to use the laplaceTetDecomposition motionsolver because the standard laplacian motionsolver does not lead to the desired result (doing a couple of periodic movements makes the mesh look like "worn out" after a period, i.e. moving the boundary fro and back should be complentary operations, but aren't)

lr103476 March 20, 2008 10:10

Hi Bjorn, You mesh is "worn
Hi Bjorn,

You mesh is "worn out" because you are using velocity based motion solvers.....Try using displacement laplacian to recover the original mesh after each period.


Regards, Frank

bfa March 26, 2008 13:26

Hmmm, I tried the following:
I tried the following:

volScalarField& displacementY = mSolver.cellDisplacement();
displacementY.boundaryField()[bodyPatchID_] == calculatedDisplacement_;

But somehow it only updates cellDisplacementy file but not pointDisplacementy. How can I make it propagate my displacement? Unfortunately I can't access pointDisplacementy directly (I think there's a reason, though I can't see it). Do I have to call some kind of cell-to-point-interpolation?


bfa March 26, 2008 14:28

Well, I kinda got a solution:
Well, I kinda got a solution:
1) to access pointDisplacementy I used the following (C++-is-my-favourite-language):
pointScalarField& ptDispY = const_cast<pointscalarfield&>(objectRegistry::look upObject<pointscalarfield>("po intDisplacementy"));

2) the displacement stored in cellDisplacementy and pointDisplacementy is relative to the original geometry, while I thought it would be relative to my last timestep. So the displacements I used were simply too small to be seen

Anyway, now it looks like it's working and it's time to go home.

Thanks anyway

christoph_heinrich May 19, 2008 12:24

Hi there, I'd like to have ac
Hi there,
I'd like to have access to pointDisplacement within the icoDyMFoam solver. So I tried:

pointVectorField& disp = const_cast<pointvectorfield&>(mesh.objectRegistry: :lookupObject<pointvectorfield >("pointDisplacement"));

When compiling, I get the following error message:

myIcoDyMFoam.C: In function 'int main(int, char**)':
myIcoDyMFoam.C:152: error: expected type-specifier before 'pointvectorfield'
myIcoDyMFoam.C:152: error: expected `>' before 'pointvectorfield'
myIcoDyMFoam.C:152: error: expected `(' before 'pointvectorfield'
myIcoDyMFoam.C:152: error: 'pointvectorfield' was not declared in this scope
myIcoDyMFoam.C:152: error: expected primary-expression before '>' token
myIcoDyMFoam.C:152: error: 'pointvectorfield' cannot appear in a constant-expression
myIcoDyMFoam.C:152: error: no matching function for call to 'Foam::dynamicFvMesh::lookupObject(const char [18])'
myIcoDyMFoam.C:152: error: expected `)' before ';' token

Can anyone help me? What went wrong? Do I have to include a special Header-file?


deepsterblue May 19, 2008 17:44

Case sensitive: pointvectorfie
Case sensitive: pointvectorfield

Should be pointVectorField, maybe?

christoph_heinrich May 20, 2008 02:55

Yes, you're right. I was conf
Yes, you're right.
I was confused, because I found it everywhere written small here.
So now the correct line:

pointVectorField& disp = const_cast<pointvectorfield&>(mesh.objectRegistry: :lookupObject<pointvectorfield >("pointDisplacement"));

And first I had to
#include "pointFields.H"

Thanks a lot,

pi06jl6 August 21, 2008 16:31

Hi all! When i implement di
Hi all!

When i implement displacement solver, should i move all boundary points or do i need only to specify facecenter change and using slip? The point is that if you move along normal then only facecenter value is needed. Further, how to implement pointdisplacement, as above with patch, since i get the message that i cannot cast pointdisplacement to slip/fixedvalue type. I would truly appriciate some help here since my automesh just produce crap fields.

Best Regards


pi06jl6 August 21, 2008 18:42

Greetings all! Disregard th
Greetings all!

Disregard the previous notion about slip/moving along face normals. Just me late in the nite trying to ask for help in how to implement a motion solver for a precribed motion of the boundary. This thread is interesting and i tried to implement it but i got error while reading the pointdisplacement file, telling me that the type is not matching.

Best Regards


pi06jl6 August 21, 2008 19:06

Hello again, I have scavang
Hello again,

I have scavanged the whole forum for information, but from what i have understood is the following, using cellDisplacement requires only the move of faceCentres() (= number of cells to be moved), using pointDisplacement, then whole boundaryfield shall be moved. Please correct me if am wrong. But the problem i have still is that i dont know what type i shall enter for the pointdisplacement file, fixedValue/slip all return unknown "type". Do i need to recast the pointVectorField?

Best Regards


grtabor March 17, 2009 11:01

Finding mesh points
Hi. I'm sorting out a simulation of a peristaltic pump, which involves a hump in one wall moving along the wall. I'm doing this by moving the points making up the wall in and out dynamically, by changing the values in the pointDisplacement field on the appropriate boundary individually. This works fine, and I'm getting a nice ripple running along the mesh.

However to set up the simulation in full I need to find the original location of the vertices. For most field quantities I would just ask for a boundaryField or something similar, but I can't work out what I need to ask to get the correct information. I've tried


but this seems to give me all the points in the mesh, not just the ones on the 0th patch (which is what I want). Any suggestions as to how I can get the required information? I could of course hardcode this but thats inelegant.


elorriaux March 19, 2009 06:37

Hello Gavin,

i'm not sure to understand what you are trying to do.

To get the points of the boundary mesh, i would try something like :




grtabor March 19, 2009 06:54

Thanks - that works! I could have sworn I had tried just that earlier, and something had gone wrong, but never mind. Thanks again.


andreho February 11, 2010 10:47

Hi all,

Iím using OpenFOAM 1.6 with dynamic mesh. I would like to have access to the boundary patch motion field. Therefore, I included in pimpleDyMFoam.C:

fixedValuePointPatchVectorField& motPat = refCast<fixedValuePointPatchVectorField>(motionU.boundaryField()[PatchID]);

before mesh.update();

However, I receive the error message
ĎmotionUí was not declared in this scope

Do I have to include some more files? Have any declarations changed in OpenFOAM 1.6?

I would be very happy, if anybody could answer this question.

Best regards,


ngj February 11, 2010 11:19

Hi Andreas

First, you need to access the motionU object, which I do in the following way:

tetPointVectorField & motionU
mesh.objectRegistry::lookupObject<tetPointVectorFi eld>

Further, you will need to include some header files. The following list might be excessive, though I have not tested which are actually needed:

#include "tetFemMatrices.H"
#include "tetPointFields.H"
#include "faceTetPolyPatch.H"
#include "tetPolyPatchInterpolation.H"
#include "fixedValueTetPolyPatchFields.H"

This off cource means that you will need to change the option file under Make, which in my case includes the following:

-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/tetDecompositionFiniteElement/lnInclude \

-lfiniteVolume \
-lmeshTools \
-ldynamicFvMesh \
-ldynamicMesh \

These option files I believe I have stripped from somewhere on the Forum.

Good luck,


Arnoldinho October 18, 2011 10:32

Hi all,

I'm digging up this older thread...

Using the method above, one is able to access the motionU object during runtime. If I want to change the point velocity on a boundary patch now, I have the problem that my points are calculated for the "normal" mesh, whereas points in motionU are "tet-decomposed" ones. Otherwise I have incompatible fields, because some additional points of the tet mesh are missing.

So am I right that an interpolation from "original" mesh points on the boundary to the points of the FE mesh is needed? If so, how can this be done?


ngj October 18, 2011 10:44

Hi Arne

Yes, you would need to perform an interpolation. I suggest that you look into e.g. freeSurface.C in 1.6-ext and look how it is being done.

Especially, you will gain insight into a method that will allow you to use different mesh motion methods instead of restricting yourself to one particular method (even though your choice is generally sane).

It should be said, however, that the applied interpolation method is not taking boundary conditions into consideration, thus it could lead to a small mass conservation problem for your bed level change, however, I suspect it to be of negligible importance in your case.

- Niels

deepsterblue October 18, 2011 10:45

Simple. Use this snippet;


#include "tetPolyPatchInterpolation.H"

        // Boundary motion specified for the tetDecompositionMotionSolver
        tetPointVectorField& motionU = const_cast<tetPointVectorField&>

        // Assign boundary conditions to the motion solver

        // The face-decomposition solver includes points at face-centres,
        // thus point motion has to be interpolated to these points
        tetPolyPatchInterpolation interpolator
            refCast<const faceTetPolyPatch>

        motionU.boundaryField()[index] ==

This is typically applicable to faceDecomposition. With cellDecomposition, the step can be avoided and assigned directly.

All times are GMT -4. The time now is 08:55.