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

output the face area vectors

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 9, 2015, 04:21
Default output the face area vectors
  #1
Senior Member
 
Join Date: Jan 2013
Posts: 372
Rep Power: 14
openfoammaofnepo is on a distinguished road
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(); 
*/

}


// ************************************************************************* //
But I have the following errors:

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]’
Could anyone tell what causes the problems? I checked many times but did not find the reason. Thank you in advance!

OFFO
openfoammaofnepo is offline   Reply With Quote

Old   April 9, 2015, 04:36
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

Compiler tried to give you a hint:

Code:
FaceAreaVector.C:53:5: error: invalid use of incomplete type ‘const struct Foam::surfaceVectorField’
Basically it says "I don't know what Foam::surfaceVectorField is". You should include surfaceFields.H.

Are you sure you have got only 39 internal faces?
alexeym is offline   Reply With Quote

Old   April 9, 2015, 04:44
Default
  #3
Senior Member
 
Join Date: Jan 2013
Posts: 372
Rep Power: 14
openfoammaofnepo is on a distinguished road
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:
Originally Posted by alexeym View Post
Hi,

Compiler tried to give you a hint:

Code:
FaceAreaVector.C:53:5: error: invalid use of incomplete type ‘const struct Foam::surfaceVectorField’
Basically it says "I don't know what Foam::surfaceVectorField is". You should include surfaceFields.H.

Are you sure you have got only 39 internal faces?
openfoammaofnepo is offline   Reply With Quote

Old   April 9, 2015, 04:53
Default
  #4
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
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.
alexeym is offline   Reply With Quote

Old   April 9, 2015, 05:18
Default
  #5
Senior Member
 
Join Date: Jan 2013
Posts: 372
Rep Power: 14
openfoammaofnepo is on a distinguished road
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;
        } 
    }
}


// ************************************************************************* //
But unfornutely there are still some errors:

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’
Could you please help me have a look at this error information? Thank you so much.
OFFO

Quote:
Originally Posted by alexeym View Post
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.
openfoammaofnepo is offline   Reply With Quote

Old   April 9, 2015, 05:36
Default
  #6
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
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).
alexeym 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
[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


All times are GMT -4. The time now is 20:50.