# Problem in defining patch deformation

 Register Blogs Members List Search Today's Posts Mark Forums Read

April 21, 2010, 04:54
Problem in defining patch deformation
#1
New Member

Paul Bomke
Join Date: Mar 2010
Location: Bremen, Germany
Posts: 16
Rep Power: 9
Hello Forum,

i'm not new to OpenFOAM but I just started changing code a few days ago, so please excuse if my question may seem trivial...

I am trying to set up a library which performs a fish-like undulatory deformation of a given patch. I have had a look at the stuff in OpenFoam-1.6.x/src/fvMotionSolver/pointPatchFields/derived/ and also at the library that can be found here: http://www.tfd.chalmers.se/~hani/kurser/OS_CFD_2008/EysteinnHelgason/EH_PatchDeform.tgz

I then took the code that can be found in the link and changed it according to my needs.
What I do in my code is take a patch and shift it to a given origin:

Code:
```// Patch relative to the given origin is created.
vectorField p0Rel = p0_ - origin_;```
I rotate it onto the xy-plane:

Code:
```// The patch is rotated using the rotation matrix.
vectorField p0RelRot = p0Rel & Rrot;```
Then I change the z-values according to a given function (a simple oscillation to start with). This is done in a loop for every single point:

Code:
```// Vectors for an individual point of the rotated Patch are declared.
//vector pointRotOld;
vector pointRotNew;

// The new deformed patch is declared using the undeformed patch.
vectorField p0RelRotNew = p0RelRot;

forAll(p0RelRot,iter)
{

// The new z-Value of the current point is calculated from its x- and y-values.
pointRotNew=vector(0, 0, (s_*sin(omega_*t.value())));    //- pointRotOld[2]);    //-phi_*p0RotOrig[0])*(a_*pow(p0RotOrig[0],2)+b_*p0RotOrig[0]+c_));

// THe current point is written into the patch.
p0RelRotNew[iter]=pointRotNew;

};```
Then the whole thing is rotated it back and moved back into its original position.

Code:
```// The new patch is rotated back into its original position
vectorField p0RelNew = p0RelRotNew & RrotInv;

// The patch is moved back to its original position
vectorField p0New=p0RelNew + origin_;```
After this comes what seems to be an essential part whos function I don't quite understand:

Code:
```vectorField::operator=
(
p0New
);```
The problem is: The new positions of the points are somehow not just taken from my function but added to the ones from the previous timestep. So I don't end up with a nice sinus-like oscillation around z=0, but with half an oscillation into one direction and back.
I don't really understand how this can be. I think the problem lies in the part of the loop where the individual points are written into the patch. It seems to me that

Code:
`p0RelRotNew[iter]=pointRotNew;`
does not assign the value on the right to pointRotNew, but add it. Since pointRotNew contains the value (0,0,someZValue) the patch p0RelRotNew would have to end up with all its points having x- and y-values of 0, but it does not, which is a good thing in this case. But in the same manner the z-values of pointRotNew are just added to the points of the patch which is not what i want.

What am I getting wrong here? May be I don't understand the function of "="?

I would appreciate any help!
Thanks in advance and best regards,

Paul

P.S.: a case using PimplyDyFoam and the code of my library is attached...
Attached Files
 fishUndulation.tar.gz (40.5 KB, 6 views) caseFishUndulation1D.tar.gz (4.2 KB, 9 views)

 April 26, 2010, 10:54 #2 New Member   Paul Bomke Join Date: Mar 2010 Location: Bremen, Germany Posts: 16 Rep Power: 9 Ok, in case this is too special or maybe just too stupid, lets start with some simple questions that may lead me to finding my mistake: 1: What is the purpose of Code: ```vectorField::operator= ( whatever );``` 2: Sounds very stupid but just to make sure: Does the velocityLaplacian motion solver require the velocities of the moved points or does the term "velocity" in its name refer to something else? 3: Is there an overview of the different motion solvers? Hope someone could comment on this! Thanks and best regards, Paul

 April 26, 2010, 11:59 #3 New Member   Paul Bomke Join Date: Mar 2010 Location: Bremen, Germany Posts: 16 Rep Power: 9 @ mods: if this is not the appropriate subforum for this question, please be so kind as to move the thread. thanks, paul

 April 27, 2010, 00:31 #4 Member   John Wang Join Date: Mar 2009 Location: Singapore Posts: 72 Rep Power: 10 Hi Paul, Just a quick question. I'm trying to get the rotation working for my code (I'm still fairly clueless with C++ programming, even though I've been using OpenFOAM for a year now). I defined the initial position of the points using the following code Code: ```label patchi = iter.key(); vectorField oldCell = mesh.C().boundaryField()[patchi]; pointField oldPoint = mesh.boundaryMesh()[patchi].localPoints();``` and the rotation tensor using the quaternion function Code: ```quaternion Rotation(angle, axis); tensor R = Rotation.R();``` and proceed with the rotation using Code: ```vectorField newCell = oldCell & R; pointField newPoint = oldPoint & R;``` I'm not sure what I did wrong, but when I tried to compile the code I got the error: Code: ```'oldCell' was not declared in this scope 'oldPoint' was not declared in this scope``` Do you have any idea what might have lead to the error? Thanks. John EDIT: Nevermind, I messed up the patchi loop. It's working now. Last edited by cwang5; April 27, 2010 at 04:22. Reason: Solution Found

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Gearb0x OpenFOAM Running, Solving & CFD 3 April 19, 2010 09:02 pi06jl6 OpenFOAM Running, Solving & CFD 1 December 11, 2008 11:32 NymphadoraTonks CFX 2 November 4, 2004 04:05 NymphadoraTonks CFX 1 October 17, 2004 18:43 Andrea CFX 2 October 11, 2004 05:12

All times are GMT -4. The time now is 13:42.