|
[Sponsors] | |||||
|
|
|
#1 |
|
Senior Member
Jiang
Join Date: Oct 2009
Location: Japan
Posts: 186
Rep Power: 5 ![]() |
Dear foamers,
I want to export all face centre Coordinate in my "OUTLET" patch during sampling. In sampledPatchTemplates.C , it export patch fieldValues like this: template <class Type> Foam::tmp<Foam::Field<Type> > Foam::sampledPatch::sampleField ( const GeometricField<Type, fvPatchField, volMesh>& vField ) const { // One value per face tmp<Field<Type> > tvalues(new Field<Type>(patchFaceLabels_.size())); Field<Type>& values = tvalues(); if (patchIndex() != -1) { const Field<Type>& bField = vField.boundaryField()[patchIndex()]; forAll(patchFaceLabels_, elemI) { values[elemI] = bField[patchFaceLabels_[elemI]]; } } return tvalues; } I don't know how to export patch face centre coordinate, which correspond to these fieldValues. I write a utility like this: volVectorField::GeometricBoundaryField& fcpatches = fc.boundaryField(); label patchI = mesh.boundaryMesh().findPatchID("OUTLET"); fixedValueFvPatchVectorField& fcpatch = refCast<fixedValueFvPatchVectorField>(fcpatches[patchI]); const vectorField& faceCentres = mesh.Cf().boundaryField()[patchI]; forAll(faceCentres, facei) { scalar x = faceCentres[facei].x(); scalar y = faceCentres[facei].y(); scalar z = faceCentres[facei].z(); fcpatch[facei] = vector(x, y, z); } fc.write(); who can tell me if this is the coordinate which I want ? Thank you very much. |
|
|
|
|
|
|
|
|
#2 |
|
Member
MSR CHANDRA MURTHY
Join Date: Mar 2009
Posts: 30
Rep Power: 6 ![]() |
I don't know whether this is useful to you or not. For the benifit of the community, i am keeping a small code to write the face centres of the given patch by its name.
#include <fstream> #include <iostream> //#include "fvMesh.H" #include "Time.H" //#include "primitiveMesh.H" #include "argList.H" #include "polyMesh.H" int main(int argc, char *argv[]) { # include "setRootCase.H" # include "createTime.H" # include "createPolyMesh.H" using namespace Foam; Info<< "Dump face centres of given patch\n" << endl; //change the patch name to your boundary name label patchI = mesh.boundaryMesh().findPatchID("bot_wall_inner"); forAll(mesh.boundaryMesh()[patchI].faceCentres(), faceI) { scalar x = mesh.boundaryMesh()[patchI].faceCentres()[faceI].x(); scalar y = mesh.boundaryMesh()[patchI].faceCentres()[faceI].y(); scalar z = mesh.boundaryMesh()[patchI].faceCentres()[faceI].z(); Info<<faceI<<" "<<x<<" "<<y<<" "<<z<<" "<<endl; } } Further file handling can be included with run time selectable patch names, something like faceCentreDict |
|
|
|
|
|
|
|
|
#3 |
|
New Member
bruce
Join Date: Aug 2011
Posts: 3
Rep Power: 3 ![]() |
hello!
when finish the wmake, can you tell me how to output this data in the case (as specific as possible)? thank you very much! |
|
|
|
|
|
|
|
|
#4 |
|
Member
MSR CHANDRA MURTHY
Join Date: Mar 2009
Posts: 30
Rep Power: 6 ![]() |
Just add file handling syntax in the above code, instead of printing to the console, it dumps to TEXT file. To achive this, you can use either Foam inbuild File handler IOobjet or in simplest way you can use C++ file stream.
|
|
|
|
|
|
|
|
|
#5 |
|
New Member
bruce
Join Date: Aug 2011
Posts: 3
Rep Power: 3 ![]() |
yes, i got it !
I added this syntax into simpleFoam, which can be done well. try to modify like following: label PatchI = mesh.boundaryMesh().findPatchID("patchName"); // const vectorField& faceCentres = mesh.boundaryMesh()[patchI].faceCentres(); const fvPatchVectorField& faceCentres = mesh.C().boundaryField()[PatchI]; forAll(faceCentres, faceI) { // get coordinate for face centre const vector& c = faceCentres[faceI]; //c[0]:x coordinate, c[1]: y coordinate, c[2]: z coordinate Info << faceI <<" " << c[0] << " " << c[1] << " " << c[2] << ")" << endl;} it can get the same result (face centre coordinate). so i think that object mesh.C().boundaryField()[patchI] returns the corresponding geometric coordinate of patch face centres , that object U.boundaryField()[patchI] returns vector U of corresponding patch face centres. in a word, mesh.C() and U belong to geometicField<type> which has the function of boundaryField(). |
|
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Import netgen mesh to OpenFOAM | hsieh | Open Source Meshers: Gmsh, Netgen, CGNS, ... | 32 | September 13, 2011 05:50 |
| OpenFOAM on MinGW crosscompiler hosted on Linux | allenzhao | OpenFOAM Installation | 127 | January 30, 2009 19:08 |
| BlockMeshmergePatchPairs | hjasak | OpenFOAM Native Meshers: blockMesh | 11 | August 15, 2008 07:36 |
| fluent add additional zones for the mesh file | SSL | FLUENT | 2 | January 26, 2008 11:55 |
| Axisymmetrical mesh | Rasmus Gjesing (Gjesing) | OpenFOAM Native Meshers: blockMesh | 10 | April 2, 2007 14:00 |