|
[Sponsors] |
April 9, 2015, 04:21 |
output the face area vectors
|
#1 |
Senior Member
Join Date: Jan 2013
Posts: 372
Rep Power: 14 |
Dear All, I write a small utility code to output the face area vectors (it is modified from GradU utility):
Code:
/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. Application FaceAreaVector Description output the face area vector of internal faces \*---------------------------------------------------------------------------*/ #include <fstream> #include <iostream> #include "fvMesh.H" #include "Time.H" //#include "primitiveMesh.H" #include "argList.H" #include "polyMesh.H" using namespace std; int main(int argc, char *argv[]) { # include "setRootCase.H" # include "createTime.H" # include "createMesh.H" using namespace Foam; Info<< "Output face vectors of faces\n" << endl; label iFace = 39; scalar x[iFace]; scalar y[iFace]; scalar z[iFace]; Line 53 forAll(mesh.Sf(), faceI) { x[faceI] = mesh.Sf()[faceI].x(); y[faceI] = mesh.Sf()[faceI].y(); z[faceI] = mesh.Sf()[faceI].z(); } /* ofstream o_file; o_file.open("Internal_Face_Vectors.txt"); if(o_file.is_open()) { for(label i=0;i<=iFace-1;i++) { o_file<<x[i]<<" "<<y[i]<<" "<<z[i]<<" "<<endl; } } o_file.close(); */ } // ************************************************************************* // Code:
FaceAreaVector.C:53:5: error: invalid use of incomplete type ‘const struct Foam::surfaceVectorField’ /home/user/OpenFOAM/OpenFOAM-2.1.1/src/OpenFOAM/lnInclude/pointFieldsFwd.H:52:7: error: declaration of ‘const struct Foam::surfaceVectorField’ FaceAreaVector.C:55:35: error: no match for ‘operator[]’ in ‘mesh.Foam::fvMesh::Sf()[faceI]’ FaceAreaVector.C:56:35: error: no match for ‘operator[]’ in ‘mesh.Foam::fvMesh::Sf()[faceI]’ FaceAreaVector.C:57:35: error: no match for ‘operator[]’ in ‘mesh.Foam::fvMesh::Sf()[faceI]’ OFFO |
|
April 9, 2015, 04:36 |
|
#2 |
Senior Member
|
Hi,
Compiler tried to give you a hint: Code:
FaceAreaVector.C:53:5: error: invalid use of incomplete type ‘const struct Foam::surfaceVectorField’ Are you sure you have got only 39 internal faces? |
|
April 9, 2015, 04:44 |
|
#3 | |
Senior Member
Join Date: Jan 2013
Posts: 372
Rep Power: 14 |
Thank you so much. I can compile it now.
39 is just an assumed for code debugging. But this is also my question. 39 is hard coded, how can I make the code know automatically about the number of internal faces and boundary faces? Thank you. Quote:
|
||
April 9, 2015, 04:53 |
|
#4 |
Senior Member
|
Hi,
fvMesh has nInternalFaces (http://foam.sourceforge.net/docs/cpp...b8ffda0dced7bb) and nFaces (http://foam.sourceforge.net/docs/cpp...153de7da0e92e8) methods inherited from primitiveMesh. You can use Lists (http://foam.sourceforge.net/docs/cpp/a01366.html) to store x, y, and z. It has append method, which automatically adjusts the size of list. Also you can write coordinates directly to a file without intermediate storage. |
|
April 9, 2015, 05:18 |
|
#5 | |
Senior Member
Join Date: Jan 2013
Posts: 372
Rep Power: 14 |
Thank you so much for your help. When I also tried to write out the area vector of boundary faces, the code is as follows:
Code:
/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. Application FaceAreaVector Description output the face area vector of internal faces \*---------------------------------------------------------------------------*/ #include <fstream> #include <iostream> #include "fvMesh.H" #include "Time.H" //#include "primitiveMesh.H" #include "argList.H" #include "polyMesh.H" #include "surfaceFields.H" using namespace std; int main(int argc, char *argv[]) { # include "setRootCase.H" # include "createTime.H" # include "createMesh.H" using namespace Foam; Info<< "Output face vectors of internal faces\n" << endl; label iFace = 253375; scalar x[iFace]; scalar y[iFace]; scalar z[iFace]; forAll(mesh.Sf(), faceI) { x[faceI] = mesh.Sf()[faceI].x(); y[faceI] = mesh.Sf()[faceI].y(); z[faceI] = mesh.Sf()[faceI].z(); } ofstream o_file; o_file.open("Internal_Face_Vectors.txt"); if(o_file.is_open()) { for(label i=0;i<=iFace-1;i++) { o_file<<x[i]<<" "<<y[i]<<" "<<z[i]<<" "<<endl; } } o_file.close(); Info<< "Output face vectors of boundary faces\n" << endl; label ibcFace = 4275; scalar xbc[ibcFace]; scalar ybc[ibcFace]; scalar zbc[ibcFace]; forAll(mesh.boundaryMesh(), patchI) { Line 85 forAll(mesh.boundaryMesh()[patchI].Sf(), faceI) { xbc[faceI] = mesh.boundaryMesh()[patchI].Sf()[faceI].x(); ybc[faceI] = mesh.boundaryMesh()[patchI].Sf()[faceI].y(); zbc[faceI] = mesh.boundaryMesh()[patchI].Sf()[faceI].z(); } } ofstream o_file_bc; o_file_bc.open("Boundary_Face_Vectors.txt"); if(o_file_bc.is_open()) { for(label i=0;i<=ibcFace-1;i++) { o_file_bc<<xbc[i]<<" "<<ybc[i]<<" "<<zbc[i]<<" "<<endl; } } } // ************************************************************************* // Code:
FaceAreaVector.C:85:9: error: ‘const class Foam::polyPatch’ has no member named ‘Sf’ FaceAreaVector.C:87:54: error: ‘const class Foam::polyPatch’ has no member named ‘Sf’ FaceAreaVector.C:88:54: error: ‘const class Foam::polyPatch’ has no member named ‘Sf’ FaceAreaVector.C:89:54: error: ‘const class Foam::polyPatch’ has no member named ‘Sf’ OFFO Quote:
|
||
April 9, 2015, 05:36 |
|
#6 |
Senior Member
|
Well, you can try using documentation without my help. It is true, polyPatch does not have Sf method, it has faceAreas method (http://foam.sourceforge.net/docs/cpp...10863a66b838fa).
Alternatively, you can explicitly demand mesh.boundaryMesh()[patchI] as const fvPatch& using assignment before nested loop, fvPatch has Sf method (http://foam.sourceforge.net/docs/cpp...6f373b993f0690). |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] outputTime in Swak function | immortality | OpenFOAM Community Contributions | 20 | October 6, 2022 12:08 |
[blockMesh] Internal walls of zero thickness | anger | OpenFOAM Meshing & Mesh Conversion | 23 | February 6, 2020 18:25 |
axisymetric-WARNING:non-positive face area exist | JORDI | FLUENT | 9 | March 9, 2011 05:15 |
[blockMesh] BlockMesh FOAM warning | gaottino | OpenFOAM Meshing & Mesh Conversion | 7 | July 19, 2010 14:11 |
[blockMesh] BlockMeshmergePatchPairs | hjasak | OpenFOAM Meshing & Mesh Conversion | 11 | August 15, 2008 07:36 |