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/)
-   -   MotionUBoundaryPatch assignment HowTo (https://www.cfd-online.com/Forums/openfoam-solving/58621-motionuboundarypatch-assignment-howto.html)

bfa March 20, 2008 08: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 =
refCast<fixedvaluetetpolypatchvectorfield>
(
motionU.boundaryField()[movingBottomID]
);


(4) assign the motionU (i.e. displacement/timeStep) to motionUBodyPatch
There is the problem: If I try
motionUBodyPatch==boundaryMesh[patchID].localPoints()
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?

regards,
Bjoern

lr103476 March 20, 2008 08: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();
if
(
motionU.boundaryField()[bodyPatchID_].type()
== fixedValuePointPatchVectorField::typeName
)
{
fixedValuePointPatchVectorField& motionUBodyPatch =
refCast<fixedvaluepointpatchvectorfield>
(
motionU.boundaryField()[bodyPatchID_]
);

motionUBodyPatch == ( dispRot + dispTrans );

}

bfa March 20, 2008 08: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 09: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.

See: http://www.opencfd.co.uk/openfoam/do...aseNotes-1.4.1

Regards, Frank

bfa March 26, 2008 12:26

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

volScalarField& displacementY = mSolver.cellDisplacement();
displacementY.boundaryField()[bodyPatchID_] == calculatedDisplacement_;
fvMesh::movePoints(motionPtr_->newPoints());

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?

puzzled,
Bjorn

bfa March 26, 2008 13: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
Bjorn

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?

Regards,
Christoph

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,
Christoph

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

Johan

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

Johan

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

Johan

grtabor March 17, 2009 10: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

mesh.boundaryMesh()[0].points()

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.

Gavin

elorriaux March 19, 2009 05: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 :

mesh.boundaryMesh()[patchID].localPoints();

Sincerely,

Etienne.

grtabor March 19, 2009 05:54

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

Gavin

andreho February 11, 2010 09: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,

andreas

ngj February 11, 2010 10:19

Hi Andreas

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

tetPointVectorField & motionU
(
const_cast<tetPointVectorField&>
(
mesh.objectRegistry::lookupObject<tetPointVectorFi eld>
(
"motionU"
)
)
);

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:

EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
$(WM_DECOMP_INC) \
-I$(LIB_SRC)/tetDecompositionFiniteElement/lnInclude \
-I$(LIB_SRC)/tetDecompositionMotionSolver/lnInclude

LIB_LIBS = \
-lfiniteVolume \
-lmeshTools \
-ldynamicFvMesh \
-ldynamicMesh \

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

Good luck,

Niels

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?

Arne

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;

Code:

#include "tetPolyPatchInterpolation.H"

        // Boundary motion specified for the tetDecompositionMotionSolver
        tetPointVectorField& motionU = const_cast<tetPointVectorField&>
        (
            mesh.lookupObject<tetPointVectorField>("motionU")
        );

        // 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].patch()
            )
        );

        motionU.boundaryField()[index] ==
        (
            interpolator.pointToPointInterpolate
            (
                dispField/mesh.time().deltaT().value()
            )
        );

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

Arnoldinho October 18, 2011 10:52

Thanks guys, that was fast and helpful!

Although the interpolation is already given now, I will have a closer look into freeSurface.C.

At the moment I'm trying to figure out which of the mesh motion solvers fits my needs best. laplaceFaceDecomposition seems to be used quite often, although I'm not sure if its fast and really works in parallel. If I remember right, I already discussed some bugs with deepsterblue. So far, I tried displacementLaplacian, but already encountered problems with distorted meshes - which of course led to a crash.

Thanks again,
Arne

ngj October 18, 2011 11:00

Hi Arne

My pleasure.

My experience with the mesh motion and morphology/scour is that you need to use laplaceFaceDecomposition, as non of the other methods actually gives you a solution in the boundary layer, which does not invalidate the mesh - even if you constraint the mesh Courant number to say less than 0.2.

- Niels

Arnoldinho November 24, 2011 11:52

Hi all,

again a question regarding the mesh motion and now esp. the mesh Courant number is coming up:

For long-term simulations of sediment movement and therefore mesh deformation I'm using a procedure of

1. calculate and store the flow and stress field etc. in defined time steps for lets say a period of 1 second
2. loop over the stored flow field values several times (so x times 1s) and solve the sediment transport equation + move the mesh (by modifying motionU bottom boundary patch and updating the mesh afterwards).

The mesh Courant number is calculated each time after the mesh is updated. What I get here, and don't really understand is that the mesh Courant number rises from updating to updating time step within the loop.

I guess that I missed something in the updating process, but am not sure what it is. So is there enything else necessary besides:

- motionU.boundaryField()[patchi] == motionUInterpolator.pointToPointInterpolate();
- mesh.update(); ?

I tested this as well by modifying the interDyMFoam solver by adding a loop over mesh.update() several times. The mesh courant number rises here as well:

Quote:

DICPCG: Solving for motionUx, Initial residual = 0, Final residual = 0, No Iterations 0
DICPCG: Solving for motionUy, Initial residual = 0, Final residual = 0, No Iterations 0
DICPCG: Solving for motionUz, Initial residual = 5.2212515e-07, Final residual = 8.5333674e-10, No Iterations 27
Mesh Courant Number mean: 0.01134146 max: 0.69139148
Correct mesh motion diffusion field.
DICPCG: Solving for motionUx, Initial residual = 0, Final residual = 0, No Iterations 0
DICPCG: Solving for motionUy, Initial residual = 0, Final residual = 0, No Iterations 0
DICPCG: Solving for motionUz, Initial residual = 5.0995321e-07, Final residual = 6.895588e-10, No Iterations 27
Mesh Courant Number mean: 0.017007733 max: 1.0168678
Correct mesh motion diffusion field.
DICPCG: Solving for motionUx, Initial residual = 0, Final residual = 0, No Iterations 0
DICPCG: Solving for motionUy, Initial residual = 0, Final residual = 0, No Iterations 0
DICPCG: Solving for motionUz, Initial residual = 4.9787755e-07, Final residual = 9.5845278e-10, No Iterations 24
Mesh Courant Number mean: 0.022671192 max: 1.3301477
Any explanations?

Arne


All times are GMT -4. The time now is 15:20.