CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Problem in defining patch deformation

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 21, 2010, 05:54
Default Problem in defining patch deformation
  #1
New Member
 
Paul Bomke
Join Date: Mar 2010
Location: Bremen, Germany
Posts: 16
Rep Power: 16
paul b is on a distinguished road
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
File Type: gz fishUndulation.tar.gz (40.5 KB, 8 views)
File Type: gz caseFishUndulation1D.tar.gz (4.2 KB, 11 views)
paul b is offline   Reply With Quote

Old   April 26, 2010, 11:54
Default
  #2
New Member
 
Paul Bomke
Join Date: Mar 2010
Location: Bremen, Germany
Posts: 16
Rep Power: 16
paul b is on a distinguished road
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
paul b is offline   Reply With Quote

Old   April 26, 2010, 12:59
Default
  #3
New Member
 
Paul Bomke
Join Date: Mar 2010
Location: Bremen, Germany
Posts: 16
Rep Power: 16
paul b is on a distinguished road
@ mods: if this is not the appropriate subforum for this question, please be so kind as to move the thread.
thanks,
paul
paul b is offline   Reply With Quote

Old   April 27, 2010, 01:31
Default
  #4
Member
 
John Wang
Join Date: Mar 2009
Location: Singapore
Posts: 73
Rep Power: 17
cwang5 is on a distinguished road
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 05:22. Reason: Solution Found
cwang5 is offline   Reply With Quote

Reply


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 Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
mapFields : internal edges Gearb0x OpenFOAM Running, Solving & CFD 3 April 19, 2010 10:02
URGENT icoDymFoam multiple patch problem pi06jl6 OpenFOAM Running, Solving & CFD 1 December 11, 2008 11:32
Problem with rotational mesh deformation: Part II NymphadoraTonks CFX 2 November 4, 2004 04:05
Problem with rotational mesh deformation NymphadoraTonks CFX 1 October 17, 2004 19:43
Multicomponent fluid Andrea CFX 2 October 11, 2004 06:12


All times are GMT -4. The time now is 05:17.