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

How to get motionU_

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 12, 2006, 17:31
Default I found class tetDecomposition
  #1
liu
Senior Member
 
Xiaofeng Liu
Join Date: Mar 2009
Location: State College, PA, USA
Posts: 118
Rep Power: 17
liu is on a distinguished road
I found class tetDecompositionMotionSolver has a member function which returns motionU_ reference. But I only get a pointer to motionSolver by following line in my code:
autoPtr<foam::motionsolver> motionPtr = motionSolver::New(mesh);

I know the code created an instance of class laplaceTetDecompositionMotionSolver (which is derived from tetDecompositionMotionSolver).

My question is: how can I get the motionU_ field on which I want to do some operation?
__________________
Xiaofeng Liu, Ph.D., P.E.,
Assistant Professor
Department of Civil and Environmental Engineering
Penn State University
223B Sackett Building
University Park, PA 16802


Web: http://water.engr.psu.edu/liu/
liu is offline   Reply With Quote

Old   June 13, 2006, 02:39
Default Look it up from the database,
  #2
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,907
Rep Power: 33
hjasak will become famous soon enough
Look it up from the database, e.g.

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


Hrv
__________________
Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk
hjasak is offline   Reply With Quote

Old   June 13, 2006, 10:00
Default Thank you, Hrv. It's a wor
  #3
liu
Senior Member
 
Xiaofeng Liu
Join Date: Mar 2009
Location: State College, PA, USA
Posts: 118
Rep Power: 17
liu is on a distinguished road
Thank you, Hrv.

It's a work around. But I am still wondering whether it is better to have motionU() as an virtual member function of class motionSolver.
__________________
Xiaofeng Liu, Ph.D., P.E.,
Assistant Professor
Department of Civil and Environmental Engineering
Penn State University
223B Sackett Building
University Park, PA 16802


Web: http://water.engr.psu.edu/liu/
liu is offline   Reply With Quote

Old   June 13, 2006, 10:14
Default Nope. The virtual base class
  #4
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,907
Rep Power: 33
hjasak will become famous soon enough
Nope. The virtual base class also supports various other kinds of mesh motion that do not involve my tet decomposition FEM motion solver. Therefore, it is possible to move the mesh without having the motionU.

Additionally, the virtual base class for all tet FEM motion solvers is tetDecompositionMotionSolver in tetDecompositionMotionSolver/tetDecompositionMotionSolver/tetDecompositionMotion Solver.H

and that one has got the motionU() member function. However, it's no good for you because you only know the base-base class.

Hrv
__________________
Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk
hjasak is offline   Reply With Quote

Old   June 13, 2006, 10:16
Default I tried to add the following l
  #5
liu
Senior Member
 
Xiaofeng Liu
Join Date: Mar 2009
Location: State College, PA, USA
Posts: 118
Rep Power: 17
liu is on a distinguished road
I tried to add the following line to motionSolver.H:
//- Return motionU_
virtual tetPointVectorField& motionU() = 0;
It works fine now. Need a lot of time to recompile though.
Now I can construct motionSolver object and get the motionU field like this:
autoPtr<foam::motionsolver> motionPtr = motionSolver::New(mesh);
tetPointVectorField& motionU = motionPtr->motionU();
...
__________________
Xiaofeng Liu, Ph.D., P.E.,
Assistant Professor
Department of Civil and Environmental Engineering
Penn State University
223B Sackett Building
University Park, PA 16802


Web: http://water.engr.psu.edu/liu/
liu is offline   Reply With Quote

Old   June 13, 2006, 10:20
Default You are a bad boy - this is pr
  #6
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,907
Rep Power: 33
hjasak will become famous soon enough
You are a bad boy - this is precisely what I don't like. Now, if I move the mesh by simple geometrical motion I need to lie in virtual functions.

Bad boy, bad boy....

Hrv
__________________
Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk
hjasak is offline   Reply With Quote

Old   June 13, 2006, 10:23
Default Yes, I know exactly what you m
  #7
liu
Senior Member
 
Xiaofeng Liu
Join Date: Mar 2009
Location: State College, PA, USA
Posts: 118
Rep Power: 17
liu is on a distinguished road
Yes, I know exactly what you mean.
But how can I get an object of tetDecompositionMotionSolver such that calling motionU() is possible?

All I can see to use motion solver is like this:
autoPtr<foam::motionsolver> motionPtr = motionSolver::New(mesh);
and the motion solver type is run time selectable.
__________________
Xiaofeng Liu, Ph.D., P.E.,
Assistant Professor
Department of Civil and Environmental Engineering
Penn State University
223B Sackett Building
University Park, PA 16802


Web: http://water.engr.psu.edu/liu/
liu is offline   Reply With Quote

Old   June 13, 2006, 10:27
Default You can then case you motionSo
  #8
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,907
Rep Power: 33
hjasak will become famous soon enough
You can then case you motionSolver pointer into tetDecompositionMotionSolver and call the function. Anyway, I prefer the database trick: this is why we had it in the first place.

Hrv
__________________
Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk
hjasak is offline   Reply With Quote

Old   August 6, 2006, 12:18
Default Hi, The symbol you need is
  #9
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,907
Rep Power: 33
hjasak will become famous soon enough
Hi,

The symbol you need is defined in the tetDecompositionFiniteElement library, but you have to be csareful regarding the face and cell decompisition. In Make/options you need to have 2 entries:

Under EXE_INC $(WM_DECOMP_INC)

Under EXE_LIBS $(WM_DECOMP_LIBS)

Check the variables to see which one you're running + make sure you don't explicitly refer to any of the "FaceDecomp" or "CellDecomp" stuff bacause this is handled through the macros.

Incidentally, have a look at some animations of my new fluid-structure interaction stuff using my automatic mesh motion solver and all the mapping and integration tools.
__________________
Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk
hjasak is offline   Reply With Quote

Old   August 6, 2006, 14:15
Default Thanks Hrv - I had just tracke
  #10
irc
New Member
 
Ian Cowan
Join Date: Mar 2009
Location: London, UK
Posts: 28
Rep Power: 17
irc is on a distinguished road
Thanks Hrv - I had just tracked down the tetDecompositionFiniteElement library as you posted your reply, through searching through the Make options in the src\tetDecompositionFiniteElement directory.

I can now find the relevant patch and print out the initial motionU settings - all well so far. They match what I specify in the 0/motionU dictionary. I am now trying to work out how to change the values. The following plainly has no effect:

motionU.boundaryField()[movingPatchI] = vector (0.003, cylVelocity, 0.0);

which probably shows a total lack of understanding on my part! Back to the Doxygen pages, and perhaps a little more thought.
irc is offline   Reply With Quote

Old   August 6, 2006, 15:25
Default Try double equals (==) - I bet
  #11
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,907
Rep Power: 33
hjasak will become famous soon enough
Try double equals (==) - I bet you are forcing assignment on a fixed value patch.

Hrv
__________________
Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk
hjasak is offline   Reply With Quote

Old   August 6, 2006, 15:50
Default Fantastic - that does indeed d
  #12
irc
New Member
 
Ian Cowan
Join Date: Mar 2009
Location: London, UK
Posts: 28
Rep Power: 17
irc is on a distinguished road
Fantastic - that does indeed do the trick. I had wondered what the == operator was doing.

Can you explain one other (basic) thing to me: motionU.boundaryField()[movingPatchI] contains a list of data for the patch in question, size 120 in my case (from .size()), but my assignment is to a single vector:
motionU.boundaryField()[movingPatchI] == vector (0.003, cylVelocity, 0.0)
How does this work? Is this built into the class definition?

In the Doxygen documentation, for the GeometricField class template (http://foam.sourceforge.net/doc/Doxygen/html/de/d5c/classFoam_1_1GeometricField. html#a49) I tracked down the following member function definition:
void operator== (const dimensioned<type>&)
Is this answering my above question?

Apologies for asking some basic stuff, but if I can understand how to use Doxygen effectively, then I should be able to work things out myself in the future. There's a healthy optimism!
irc is offline   Reply With Quote

Old   August 22, 2006, 09:00
Default Hi, I have a similar question
  #13
New Member
 
Martin Karlsson
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 13
Rep Power: 17
martin is on a distinguished road
Hi,
I have a similar question. I need to define the boundary motion for each point in the boundaryField due to a function that will change over the boundaryField and time. I don't have any problem to define the motion for the whole boundaryField for example like (I am testing this in a icoDyMFoam based application):

motionU.boundaryField()[movingWallPatchI] == vector(2.0, 0.0, 0.0);

But I can't change the motion for one point (pointI). I have tried it like:

motionU.boundaryField()[movingWallPatchID][pointI]==vector(2.0, 0.0, 0.0);

which result in the following compilation error:

error: no match for 'operator[]' in '((Foam::GeometricField<foam::vector<double>, Foam::tetPolyPatchField, Foam::tetPointMesh>::GeometricBoundaryField*)((Foa m::tetPointVectorField*)motion U)->Foam::GeometricField<type,>::boundaryField [with Type = Foam::Vector<double>, PatchField = Foam::tetPolyPatchField, GeoMesh = Foam::tetPointMesh]())->Foam::GeometricField<foam::vector<double>, Foam::tetPolyPatchField, Foam::tetPointMesh>::GeometricBoundaryField::<anon ymous>.Foam::FieldField<foam:: tetpolypatchfield,> >::<anonymous>.Foam::PtrList<t>::operator[] [with T = Foam::tetPolyPatchField<foam::vector<double> >](movingWallPatchID)[pointI]'

How should I define the motion for one point of the boundaryField?

Regards,
Martin
martin is offline   Reply With Quote

Old   September 6, 2006, 15:02
Default I solved the problem with a wa
  #14
New Member
 
Martin Karlsson
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 13
Rep Power: 17
martin is on a distinguished road
I solved the problem with a walk around, see the example below (not implemented in a general manner yet).

//Initialization

tetPointVectorField& motion=const_cast<tetpointvectorfield&>(mesh.objec tRegistry::lockupObject<tetpoi ntvectorfield>("motionU")); //Look up motionU from the data base as above.

tetPolyMesh& tetMesh=const_cast<tetpolymesh&>(motionU.mesh()); //Look up tetMesh from the data base. See http://www.cfd-online.com/OpenFOAM_D...ges/1/101.html

const vectorField& tetBoundaryPoints=tetMesh.boundary()[movingWallPatchID].localPoints(); //Reference to coordinates for the boundary points.

tetPolyPatchVectorField& motionUMovingPatch(motionU.boundaryField()[movingWallPatchID]); //Reference to the motionU vector field of the moving patch.

vectorField calculatedMotionU(motionUMovingPatch.size());


//Calculate new boundary motion as a function of point coordinate
forAll(calculatedMotionU, pointI)
{
calculatedMotionU[pointI] = vector(0.01, 0.0, 0.0) * (vector(0.0, 1.0, 0.0) & tetBoundaryPoints[pointI])
}

// Alternative method
calculatedMotionU = vector(0.01, 0.0, 0.0) * (vector(0.0, 1.0, 0.0) & tetBoundaryPoints)

//Set motionU
motionUMovingPatch ==calculatedMotionU;

Does anyone have a better idea of how to change motionU for one or more point(s)?

Regards
Martin
martin is offline   Reply With Quote

Old   September 6, 2006, 19:00
Default Hi, tetPointVectorField&
  #15
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,907
Rep Power: 33
hjasak will become famous soon enough
Hi,


tetPointVectorField& motion = const_cast<tetpointvectorfield&>
(
mesh.objectRegistry::lookupObject<tetpointvectorfi eld>("motionU")
);


Fine. All you need then is to throw away all the wrapping and it will look elegant:

motionU.boundaryField()[movingWallPatchID] ==
vector(0.01, 0.0, 0.0)*
(
vector(0.0, 1.0, 0.0)
& tetMesh.boundary()[movingWallPatchID].localPoints()
);


This looks like FOAM to me :-) Do you have a problem that I cannot see?

Hrv
__________________
Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk
hjasak is offline   Reply With Quote

Old   September 7, 2006, 08:26
Default Hi Hrv, No I claim I don't
  #16
New Member
 
Martin Karlsson
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 13
Rep Power: 17
martin is on a distinguished road
Hi Hrv,

No I claim I don't have a problem you cannot see ☺ Just wanted a hint if I implemented this in good manner. Next I need to define the motion different if the y-coordinate is less than a given value, therefore I use a loop, does this look like FOAM for you or should I do it in some other way?

forAll(calculatedMotion, pointI)
{
if(tetMesh.boundary()[movingWallPatchID].localPoints()[pointI][1] > 0.
01)
{

calculatedMotion[pointI] = vector(0.01, 0.0, 0.0)*
(
vector(0.0, 1.0, 0.0)
& tetMesh.boundary()[movingWallPatchID].localPoints()[pointI]
);

}
}

motionU.boundaryField()[movingWallPatchID] == calculatedMotion;

Thanks,
Martin
martin is offline   Reply With Quote

Old   September 7, 2006, 09:30
Default Hehe, Try using: pos(tet
  #17
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,907
Rep Power: 33
hjasak will become famous soon enough
Hehe,

Try using:

pos(tetMesh.boundary()[movingWallPatchID].localPoints().component(vector::Y))

The first bit takes the y-component of point position and returns it as a scalar field. pos(...) returns 1 if this is positive and 0 if negative.

I am sure you can work out the rest.

Enjoy,

Hrv
__________________
Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk
hjasak is offline   Reply With Quote

Old   September 7, 2006, 10:06
Default Nice, I will check that. T
  #18
New Member
 
Martin Karlsson
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 13
Rep Power: 17
martin is on a distinguished road
Nice, I will check that.

Thanks,
Martin
martin is offline   Reply With Quote

Old   June 20, 2007, 14:34
Default Hi everybody, I'm trying to a
  #19
New Member
 
Marcelo Raschi
Join Date: Mar 2009
Posts: 1
Rep Power: 0
chiconuclear is on a distinguished road
Hi everybody,
I'm trying to assign to the motionU field a non uniform value for a patch. I am having problems with the mapping.
For the initialization I have:

volVectorField velEspesores
(
IOobject
(
"velEspesores",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedVector("vE",dimLength/dimTime,vector::zero)
);

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

Then the program calculates velEspesores, and what I want is to assign those values to motionU, basically,

motionU.boundaryField()[patchID] == velEspesores.boundaryField()[patchID];

I know that I need to do some mapping, but I can't figure out how to do it. If I do nothing it compiles but the run finishes with

--> FOAM FATAL ERROR : given patch field does not correspond to the mesh. Field size: 73672 mesh size: 15320

From function
void PointPatchField<patchfield,>::setInInternalField(F ield<type1>& iF, const Field<type1>& iF) const
in file /nfs/hjlnx/home/hj/OpenFOAM/OpenFOAM-1.3/src/OpenFOAM/lnInclude/PointPatchField. C at line 351.

FOAM aborting

The BC in motionU for the patch I want to move is fixedValue. I am using OpenFOAM 1.3, 28-03-07 development version.

Thanks in advance,
Marcelo
chiconuclear 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



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