|
[Sponsors] |
June 27, 2007, 08:01 |
Dear OpenFoam Users
I need
|
#1 |
Senior Member
Join Date: Mar 2009
Posts: 248
Rep Power: 18 |
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 |
|
June 27, 2007, 09:57 |
Hi Jaswinder!
For your comp
|
#2 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
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 |
|
June 27, 2007, 10:08 |
mesh.boundaryMesh() calls the
|
#3 |
Member
|
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 |
|
June 27, 2007, 10:24 |
Hi Bernhard, Cosimo
Thanks
|
#4 |
Senior Member
Join Date: Mar 2009
Posts: 248
Rep Power: 18 |
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 |
|
June 27, 2007, 11:01 |
It depends on what you want to
|
#5 |
Member
|
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
__________________
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 |
|
|
|
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 |