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

Saving Patch cell centres as an IOobject

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By cosimobianchini

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 27, 2007, 08:01
Default Dear OpenFoam Users I need
  #1
Senior Member
 
Join Date: Mar 2009
Posts: 248
Rep Power: 18
jaswi is on a distinguished road
Dear OpenFoam Users

I need to save a boundary patch as an IOobject. This is what I am adding to createFields.H:


1-->label patchID = mesh.boundaryMesh().findPatchID("walls");

2-->const fvPatch& cPatch = mesh.boundaryMesh()[patchID];

3-->const vectorField& faceCentres = cPatch.Cf();

The above changes have been suggested in :
http://www.cfd-online.com/OpenFOAM_D...ges/1/174.html

to access faceCentres and save it as a vectorField but compiling this gives following error and it comes from line # 2:

createFields.H:105: error: invalid initialization of reference of type 'const Foam::fvPatch&' from expression of type 'const Foam::polyPatch'

Once I have the faceCentres, i would like to save it as an IOobject and this is what i have in mind

surfaceVectorField WALLPOS=faceCentres
(
IOobject
(
"WALLPOS",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh
);


Please take a look and suggest what am I doing wrong.

With Best Regards
Jaswinder
jaswi is offline   Reply With Quote

Old   June 27, 2007, 09:57
Default Hi Jaswinder! For your comp
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Hi Jaswinder!

For your compilation problem:

Try this line:

const fvPatch& cPatch = mesh.boundary()[patchID];
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   June 27, 2007, 10:08
Default mesh.boundaryMesh() calls the
  #3
Member
 
cosimo bianchini
Join Date: Mar 2009
Location: Florence, Tuscany, Italy
Posts: 88
Rep Power: 17
cosimobianchini is on a distinguished road
Send a message via Skype™ to cosimobianchini
mesh.boundaryMesh() calls the inherited method polyMesh::boundaryMesh() which returns a polyBoundaryMesh that is a List<polypatch>.

To let it work you just need to change line 2 to:

const fvPatch& cPatch = mesh.boundary()[patchID];

and everything should work.

I guess you are working with OF-1.4 or OF-1.3: the suggestion in the other thread refers to an older version.

Hope this might help
Cosimo
__________________
Cosimo Bianchini

Ergon Research s.r.l.
Via Panciatichi, 92
50127 Florence - ITALY
Tel: +39 055 0763716
Mob: +39 320 9460153
e-mail: cosimo.bianchini@ergonresearch.it
URL: www.ergonresearch.it
cosimobianchini is offline   Reply With Quote

Old   June 27, 2007, 10:24
Default Hi Bernhard, Cosimo Thanks
  #4
Senior Member
 
Join Date: Mar 2009
Posts: 248
Rep Power: 18
jaswi is on a distinguished road
Hi Bernhard, Cosimo

Thanks alot

It works partially !!!!

After adding :
1--> label patchID = mesh.boundaryMesh().findPatchID("walls");

2--> const fvPatch& cPatch = mesh.boundary()[patchID]; <-- Corrected as per suggestion


3-->const vectorField& faceCentres = cPatch.Cf();

I do get a vectorField faceCentres but when I try to save it as an IOobject in this way :

surfaceVectorField WALLPOS=faceCentres
(
IOobject
(
"WALLPOS",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh
);

I get following error

createFields.H: In function 'int main(int, char**)':
createFields.H:124: error: no match for call to '(const Foam::Field<foam::vector<double> >) (Foam::IOobject, Foam::fvMesh&)'


Please take a look and suggest what I am doing wrong.

Thanks alot
With Best Regards
Jaswinder
jaswi is offline   Reply With Quote

Old   June 27, 2007, 11:01
Default It depends on what you want to
  #5
Member
 
cosimo bianchini
Join Date: Mar 2009
Location: Florence, Tuscany, Italy
Posts: 88
Rep Power: 17
cosimobianchini is on a distinguished road
Send a message via Skype™ to cosimobianchini
It depends on what you want to do: faceCentres is defined only on a single patch while WALLPOS is defined on all faces.
If you want to build up a surfaceVectorField storing all faces centre vectors, it might be easier to instantiate it in this way:

surfaceVectorField WALLPOS
(
IOobject
(
"WALLPOS",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh.Cf()
);

otherwise if you want have a null field everywhere apart from the patch you might want to do something like:

surfaceVectorField WALLPOS
(
IOobject
(
"WALLPOS",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedVector("null",dimensionSet(0, 0, 0, 0, 0), vector::zero)
);

WALLPOS.boundaryField()[patchID] = faceCentres;

Hopefully these should work
good luck
HuZexi likes this.
__________________
Cosimo Bianchini

Ergon Research s.r.l.
Via Panciatichi, 92
50127 Florence - ITALY
Tel: +39 055 0763716
Mob: +39 320 9460153
e-mail: cosimo.bianchini@ergonresearch.it
URL: www.ergonresearch.it
cosimobianchini 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
Saving patch motion as an IOobject jaswi OpenFOAM Running, Solving & CFD 1 June 26, 2007 14:07
Patch face centres order shrina OpenFOAM Running, Solving & CFD 1 October 3, 2006 04:48
How to get the value of one cell in a patch tangd OpenFOAM Running, Solving & CFD 1 August 17, 2006 03:00
Cell centres Tom Main CFD Forum 5 June 4, 2003 15:54
Saving variables on a user patch with physical coordinates Zoltan Turzo CFX 2 April 20, 2000 16:05


All times are GMT -4. The time now is 04:41.