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

write cell volumes

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree6Likes

Reply
 
LinkBack Thread Tools Display Modes
Old   January 28, 2011, 12:58
Default
  #21
Senior Member
 
Martin
Join Date: Oct 2009
Location: Aachen, Germany
Posts: 252
Rep Power: 11
MartinB is on a distinguished road
Hi again,

I found the bug: a bracket related problem... so here comes the (hopefully) correct parallel version:
Code:
#include "RASModel.H"
// write matlab file

{
    Info << "Writing Area of the cells on the patch!" << endl;

    word wallPatchName = "obstacle";
    Info << "Searching for patch " << wallPatchName << endl;

    // Check, if the patch name exists:
    label patchID = mesh.boundaryMesh().findPatchID(wallPatchName);
    if (patchID < 0)
    {
        Info << "No patch found with name \"" << wallPatchName << "\"!"
        << endl;
    }

    // Pointer to the patch we want to have shear stress for:
    const polyPatch& cPatch = mesh.boundaryMesh()[patchID];
    label nFaces = cPatch.size();

    pointField faceAreas(nFaces, vector(0,0,0));

    label runFaces = 0;

    // collecting the interesting data
    for (int i=0; i<nFaces; i++)
    {
        faceAreas[runFaces] = mesh.Sf().boundaryField()[patchID][i];
        runFaces++;
    }

    // for parallel
    reduce(nFaces, sumOp<label>());
    Info << "Number of global faces: " << nFaces << endl;

    // make a cute filename
    fileName casePath = cwd();//casePath.name();
    fileName caseName = casePath.name();
    fileName myFile = "area.dat";
    Info << "Data is written to file " << myFile << endl;

    // create a new file
    OFstream *myStream = NULL;
    if (Pstream::master())
    {
        myStream = new OFstream(myFile);
    }

    // slaves send data to master, master writes data to file
    if (Pstream::parRun())
    {
        if (Pstream::myProcNo() != Pstream::masterNo())
        {
            OPstream toMaster(Pstream::blocking, Pstream::masterNo());
            toMaster << faceAreas;
        }
        else // master part
        {
            // first write own data
            for (int i=0; i<faceAreas.size(); i++)
            {
                *myStream << i << ";"
                << mag(faceAreas[i]) << endl;

            }

            label run = faceAreas.size();

            // then receive slave data and write
            pointField bufferFaceAreas;

            for (int slave=Pstream::firstSlave(); slave <= Pstream::lastSlave(); slave++)
            {
                IPstream fromSlave(Pstream::blocking, slave);
                fromSlave >> bufferFaceAreas;

                for (int i=0; i<bufferFaceAreas.size(); i++)
                {
                    *myStream << run << "; "
                    << mag(bufferFaceAreas[i]) << endl;
                    run++;
                }
            }
        }
    }
    else // single processor only
    {
        for (int i=0; i<nFaces; i++)
        {
            *myStream << i << "; "
            << mag(mesh.Sf().boundaryField()[patchID][i]) << endl;
        }
    }

}
Have fun

Martin
MartinB is offline   Reply With Quote

Old   January 31, 2011, 06:21
Default
  #22
Senior Member
 
Andrea Ferrari
Join Date: Dec 2010
Posts: 275
Rep Power: 7
Andrea_85 is on a distinguished road
Hi Martin,

after wclean and wmake i got this error (i dont know if the instructions that you had given to compile simpleFoam are the same for interFoam (the solver that i use) but seems that there is some error on #include RASModel.H)

Making dependency list for source file interFoam.C
could not open file RASModel.H for source file interFoam.C
SOURCE=interFoam.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-40 -I/opt/OpenFOAM/OpenFOAM-1.7.0/src/transportModels -I/opt/OpenFOAM/OpenFOAM-1.7.0/src/transportModels/incompressible/lnInclude -I/opt/OpenFOAM/OpenFOAM-1.7.0/src/transportModels/interfaceProperties/lnInclude -I/opt/OpenFOAM/OpenFOAM-1.7.0/src/turbulenceModels/incompressible/turbulenceModel -I/opt/OpenFOAM/OpenFOAM-1.7.0/src/finiteVolume/lnInclude -IlnInclude -I. -I/opt/OpenFOAM/OpenFOAM-1.7.0/src/OpenFOAM/lnInclude -I/opt/OpenFOAM/OpenFOAM-1.7.0/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/interFoam.o
In file included from interFoam.C:125:
write.H:1:22: error: RASModel.H: No such file or directory
/opt/OpenFOAM/OpenFOAM-1.7.0/src/finiteVolume/lnInclude/readPISOControls.H: In function :
/opt/OpenFOAM/OpenFOAM-1.7.0/src/finiteVolume/lnInclude/readPISOControls.H:11: warning: unused variable
/opt/OpenFOAM/OpenFOAM-1.7.0/src/finiteVolume/lnInclude/readPISOControls.H:14: warning: unused variable
/opt/OpenFOAM/OpenFOAM-1.7.0/src/finiteVolume/lnInclude/readPISOControls.H:3: warning: unused variable
/opt/OpenFOAM/OpenFOAM-1.7.0/src/finiteVolume/lnInclude/readPISOControls.H:8: warning: unused variable
/opt/OpenFOAM/OpenFOAM-1.7.0/src/finiteVolume/lnInclude/readPISOControls.H:11: warning: unused variable
/opt/OpenFOAM/OpenFOAM-1.7.0/src/finiteVolume/lnInclude/readPISOControls.H:14: warning: unused variable

make: *** [Make/linux64GccDPOpt/interFoam.o] Error 1


Thanks again

Andrea
Andrea_85 is offline   Reply With Quote

Old   January 31, 2011, 08:20
Default
  #23
Senior Member
 
Martin
Join Date: Oct 2009
Location: Aachen, Germany
Posts: 252
Rep Power: 11
MartinB is on a distinguished road
Hi Andrea,

just remove the line "#include RASModel.H". It was necessary for wall shear stress calculation in the original piece of code...

Martin
MartinB is offline   Reply With Quote

Old   January 31, 2011, 09:55
Default
  #24
Senior Member
 
Andrea Ferrari
Join Date: Dec 2010
Posts: 275
Rep Power: 7
Andrea_85 is on a distinguished road
I figured that was enough to remove that line. I just launched a test. I write to you in case there are errors. Thank you very much for all your help.

Andrea
Andrea_85 is offline   Reply With Quote

Old   February 11, 2011, 06:19
Default
  #25
Senior Member
 
Andrea Ferrari
Join Date: Dec 2010
Posts: 275
Rep Power: 7
Andrea_85 is on a distinguished road
Hi Martin, everything works fine!

I am taking advantage of your patience to ask another thing. I would like to calculate the gradient of alpha1 for each cell and each time step. I tried to write this piece of code: writeGradientAlpha1.C (writeCellVolumes.C them).
Please look if is ok. I do not know if i have included the right source file (.H).
I guess the function to calculate gradient is fvcGrad:field).

Code:
#include "argList.H"
#include "timeSelector.H"
#include "Time.H"
#include "fvMesh.H"
#include "vectorIOField.H"
#include "volFields.H"
#include "fvcGrad.H"

using namespace Foam;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

// Main program:

int main(int argc, char *argv[])
{
    timeSelector::addOptions();

#   include "setRootCase.H"
#   include "createTime.H"

    instantList timeDirs = timeSelector::select0(runTime, args);

#   include "createMesh.H"

    forAll(timeDirs, timeI)
    {
        runTime.setTime(timeDirs[timeI], timeI);

        Info<< "Time = " << runTime.timeName() << endl;

        // Check for new mesh
        mesh.readUpdate();

        volVectorField gradAlpha1
    (
            IOobject
            (
                    "GradAlpha1",
                    runTime.timeName(),
                    mesh,
                    IOobject::NO_READ,
                    IOobject::AUTO_WRITE
            ),
            volVectorField gradAlpha1 = fvc::grad(alpha1)

    );



         Info<< "Writing gradAlpha1 to " << gradAlpha1.name() << " in "
             << runTime.timeName() << endl;

         gradAlpha1.write();

    }

    Info<< "\nEnd" << endl;

    return 0;
}


// ************************************************************************* //
thanks a lot
andrea
Andrea_85 is offline   Reply With Quote

Old   February 11, 2011, 11:15
Default
  #26
Senior Member
 
Martin
Join Date: Oct 2009
Location: Aachen, Germany
Posts: 252
Rep Power: 11
MartinB is on a distinguished road
Hi Andrea,

you must read the alpha1 field from disk first, otherwise your tool doesn't know what to work on.

Extract the attached tool to your user directory, for example .../OpenFOAM/andrea-1.7.1/ and call wmake in the new folder.

Have fun

Martin
Attached Files
File Type: gz writeGradientAlpha1.tar.gz (1.4 KB, 16 views)
pyt likes this.
MartinB is offline   Reply With Quote

Old   February 11, 2011, 11:22
Default
  #27
Senior Member
 
Andrea Ferrari
Join Date: Dec 2010
Posts: 275
Rep Power: 7
Andrea_85 is on a distinguished road
Hi,

can i put this code in the /home/../applications/utilities/postProcessing/miscellaneous/ like writeCellCenter?

for the next help I guess I will have to pay!!

Thanks

andrea
Andrea_85 is offline   Reply With Quote

Old   February 11, 2011, 11:26
Default
  #28
Senior Member
 
Martin
Join Date: Oct 2009
Location: Aachen, Germany
Posts: 252
Rep Power: 11
MartinB is on a distinguished road
Yes, you can.

Please have a look at the file
Make/options

Right now the executable is written to
$(FOAM_USER_APPBIN)
so only you have access to it. If you want to make it available globally (for other users), you may want to change this variable to
$(FOAM_APPBIN)

Martin
MartinB is offline   Reply With Quote

Old   February 11, 2011, 12:11
Default
  #29
Senior Member
 
Andrea Ferrari
Join Date: Dec 2010
Posts: 275
Rep Power: 7
Andrea_85 is on a distinguished road
Yes, i know that.

Thanks a lot
andrea
Andrea_85 is offline   Reply With Quote

Old   February 14, 2011, 07:40
Default
  #30
Senior Member
 
Andrea Ferrari
Join Date: Dec 2010
Posts: 275
Rep Power: 7
Andrea_85 is on a distinguished road
Hi Martin,
I have copied all file in the right directory and then wmake. When i call writeGradientAlpha1 from my case directory i got this error:

| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
Build : 1.7.0-21131bcbd876
Exec : writeGradientAlpha1
Date : Feb 14 2011
Time : 12:28:14
Host : master.cluster
PID : 25375
Case : /home/aferrari/Simulation/OstacoliRandom/simm2e-2alpha30/simmetricou2e-2
nProcs : 1
SigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0

Time = 0
Reading field alpha1



--> FOAM FATAL IO ERROR:
Unknown patchField type constantAlphaContactAngle for patch type wall

Valid patchField types are :

41
(
advective
buoyantPressure
calculated
cyclic
directMapped
directionMixed
empty
fan
fixedFluxPressure
fixedGradient
fixedInternalValue
fixedPressureCompressibleDensity
fixedValue
freestream
freestreamPressure
inletOutlet
inletOutletTotalTemperature
mixed
oscillatingFixedValue
outletInlet
partialSlip
processor
rotatingTotalPressure
sliced
slip
symmetryPlane
syringePressure
timeVaryingMappedFixedValue
timeVaryingMappedTotalPressure
timeVaryingTotalPressure
timeVaryingUniformFixedValue
timeVaryingUniformInletOutlet
totalPressure
totalTemperature
turbulentInlet
turbulentIntensityKineticEnergyInlet
uniformDensityHydrostaticPressure
uniformFixedValue
waveTransmissive
wedge
zeroGradient
)


file: /home/aferrari/Simulation/OstacoliRandom/simm2e-2alpha30/simmetricou2e-2/0/alpha1::boundaryField::wall.4 from line 263883 to line 263885.

From function fvPatchField<Type>::New(const fvPatch&, const DimensionedField<Type, volMesh>&, const dictionary&)
in file /opt/OpenFOAM/OpenFOAM-1.7.0/src/finiteVolume/lnInclude/newFvPatchField.C at line 110.


I use constantAlphaContactAngle patch instead of simply wall.

Thanks
andrea
Andrea_85 is offline   Reply With Quote

Old   February 14, 2011, 08:16
Default
  #31
Senior Member
 
Martin
Join Date: Oct 2009
Location: Aachen, Germany
Posts: 252
Rep Power: 11
MartinB is on a distinguished road
Hi Andrea,

to use the writeGradientAlpha1 tool in OpenFOAM-1.7.0 replace the lines in writeGradientAlpha1/Make/options with:
Code:
EXE_INC = \
    -I$(LIB_SRC)/transportModels \
    -I$(LIB_SRC)/transportModels/incompressible/lnInclude \
    -I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \
    -I$(LIB_SRC)/turbulenceModels/incompressible/turbulenceModel \
    -I$(LIB_SRC)/finiteVolume/lnInclude

EXE_LIBS = \
    -ltwoPhaseInterfaceProperties \
    -lincompressibleTransportModels \
    -lincompressibleTurbulenceModel \
    -lincompressibleRASModels \
    -lincompressibleLESModels \
    -lfiniteVolume
Rebuild with
wclean
wmake

Martin
pyt likes this.
MartinB is offline   Reply With Quote

Old   February 14, 2011, 08:57
Default
  #32
Senior Member
 
Andrea Ferrari
Join Date: Dec 2010
Posts: 275
Rep Power: 7
Andrea_85 is on a distinguished road
Thanks Martin,

the correct library for the interface properties is : -linterfaceProperties \ .
I had an error with -ltwoPhaseInterfaceProperties \.

Thanks again

andrea
Andrea_85 is offline   Reply With Quote

Old   February 17, 2011, 09:13
Default
  #33
Senior Member
 
Andrea Ferrari
Join Date: Dec 2010
Posts: 275
Rep Power: 7
Andrea_85 is on a distinguished road
Hi Martin

I tried to edit your file to calculate the curvature of the interface, according to the calculations found in interfaceProperties.C
Attached my writeCurvature.C.

i got this error
SOURCE=writeCurvature.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-40 -I/opt/OpenFOAM/OpenFOAM-1.7.0/src/transportModels -I/opt/OpenFOAM/OpenFOAM-1.7.0/src/transportModels/incompressible/lnInclude -I/opt/OpenFOAM/OpenFOAM-1.7.0/src/transportModels/interfaceProperties/lnInclude -I/opt/OpenFOAM/OpenFOAM-1.7.0/src/turbulenceModels/incompressible/turbulenceModel -I/opt/OpenFOAM/OpenFOAM-1.7.0/src/finiteVolume/lnInclude -IlnInclude -I. -I/opt/OpenFOAM/OpenFOAM-1.7.0/src/OpenFOAM/lnInclude -I/opt/OpenFOAM/OpenFOAM-1.7.0/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/writeCurvature.o
In file included from /opt/OpenFOAM/OpenFOAM-1.7.0/src/OpenFOAM/lnInclude/GeometricField.C:1273,
from /opt/OpenFOAM/OpenFOAM-1.7.0/src/OpenFOAM/lnInclude/GeometricField.H:586,
from /opt/OpenFOAM/OpenFOAM-1.7.0/src/OpenFOAM/lnInclude/GeometricScalarField.H:38,
from /opt/OpenFOAM/OpenFOAM-1.7.0/src/OpenFOAM/lnInclude/GeometricFields.H:34,
from /opt/OpenFOAM/OpenFOAM-1.7.0/src/finiteVolume/lnInclude/volFields.H:37,
from writeCurvature.C:35:
/opt/OpenFOAM/OpenFOAM-1.7.0/src/OpenFOAM/lnInclude/GeometricFieldFunctions.C: In function :
/opt/OpenFOAM/OpenFOAM-1.7.0/src/OpenFOAM/lnInclude/GeometricFieldFunctions.C:950: instantiated from
writeCurvature.C:98: instantiated from here
/opt/OpenFOAM/OpenFOAM-1.7.0/src/OpenFOAM/lnInclude/GeometricFieldFunctions.C:950: error: no matching function for call to
/opt/OpenFOAM/OpenFOAM-1.7.0/src/OpenFOAM/lnInclude/scalarField.H:77: note: candidates are: void Foam::add(Foam::Field<double>&, const Foam::scalar&, const Foam::UList<double>&)
/opt/OpenFOAM/OpenFOAM-1.7.0/src/OpenFOAM/lnInclude/scalarField.H:77: note: void Foam::add(Foam::Field<double>&, const Foam::UList<double>&, const Foam::scalar&)
/opt/OpenFOAM/OpenFOAM-1.7.0/src/OpenFOAM/lnInclude/labelField.H:53: note: void Foam::add(Foam::Field<int>&, const Foam::label&, const Foam::UList<int>&)
/opt/OpenFOAM/OpenFOAM-1.7.0/src/OpenFOAM/lnInclude/labelField.H:53: note: void Foam::add(Foam::Field<int>&, const Foam::UList<int>&, const Foam::label&)
/opt/OpenFOAM/OpenFOAM-1.7.0/src/OpenFOAM/lnInclude/GeometricFieldFunctions.C:950: instantiated from
writeCurvature.C:98: instantiated from here
/opt/OpenFOAM/OpenFOAM-1.7.0/src/OpenFOAM/lnInclude/GeometricFieldFunctions.C:950: error: no matching function for call to
/opt/OpenFOAM/OpenFOAM-1.7.0/src/OpenFOAM/lnInclude/scalarField.H:77: note: candidates are: void Foam::add(Foam::Field<double>&, const Foam::scalar&, const Foam::UList<double>&)
/opt/OpenFOAM/OpenFOAM-1.7.0/src/OpenFOAM/lnInclude/scalarField.H:77: note: void Foam::add(Foam::Field<double>&, const Foam::UList<double>&, const Foam::scalar&)
/opt/OpenFOAM/OpenFOAM-1.7.0/src/OpenFOAM/lnInclude/labelField.H:53: note: void Foam::add(Foam::Field<int>&, const Foam::label&, const Foam::UList<int>&)
/opt/OpenFOAM/OpenFOAM-1.7.0/src/OpenFOAM/lnInclude/labelField.H:53: note: void Foam::add(Foam::Field<int>&, const Foam::UList<int>&, const Foam::label&)
make: *** [Make/linux64GccDPOpt/writeCurvature.o] Error 1


what the problem for you?

andrea
Attached Files
File Type: c writeCurvature.C (3.3 KB, 9 views)
Andrea_85 is offline   Reply With Quote

Old   February 17, 2011, 09:36
Default
  #34
Senior Member
 
Martin
Join Date: Oct 2009
Location: Aachen, Germany
Posts: 252
Rep Power: 11
MartinB is on a distinguished road
Hi Andrea,

without doing testing, just removed some typos... have a look...

Martin
Attached Files
File Type: c writeCurvature.C (3.4 KB, 32 views)
MartinB is offline   Reply With Quote

Old   February 22, 2011, 06:50
Default
  #35
Senior Member
 
Andrea Ferrari
Join Date: Dec 2010
Posts: 275
Rep Power: 7
Andrea_85 is on a distinguished road
It runs!

do you know what OF calculate in these lines?

const surfaceVectorField& Sf = mesh.Sf();
surfaceScalarField nHatf_ = nHatfv & Sf;

thanks
andrea
Andrea_85 is offline   Reply With Quote

Old   February 22, 2011, 06:58
Default
  #36
Senior Member
 
Martin
Join Date: Oct 2009
Location: Aachen, Germany
Posts: 252
Rep Power: 11
MartinB is on a distinguished road
The face unit interface normal flux...

See the comments here, line 00113ff:
http://foam.sourceforge.net/doc/Doxy...8C_source.html

Martin
MartinB is offline   Reply With Quote

Old   February 22, 2011, 08:21
Default
  #37
Senior Member
 
Andrea Ferrari
Join Date: Dec 2010
Posts: 275
Rep Power: 7
Andrea_85 is on a distinguished road
Yeah,
but what does it means? If i want the geometric curvature of the interface ([1/L]) which is linked to the capillary pressure that i would like to calculate, do i need the flux? Or is OF that needs the flux to calculate the interfacial forces to put in the equation?

thanks
andrea
Andrea_85 is offline   Reply With Quote

Old   February 25, 2011, 11:37
Default
  #38
Senior Member
 
Andrea Ferrari
Join Date: Dec 2010
Posts: 275
Rep Power: 7
Andrea_85 is on a distinguished road
Hi,

I still have a problem when i calculate the curvature. I find high value of curvature where there is no interface (values higher than the values at the interface!!)and that's no possible.
what is wrong?

thanks
andrea
Andrea_85 is offline   Reply With Quote

Reply

Tags
cell volume, mesh.v, volume

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cells with t below lower limit Purushothama CD-adapco 2 May 31, 2010 21:58
mesh file for flow over a circular cylinder Ardalan Main CFD Forum 6 April 17, 2010 23:40
how to write the value of every cell in a volume? Ralf Schmidt FLUENT 0 January 9, 2006 06:18
Trimmed cell and embedded refinement mesh conversion issues michele OpenFOAM Other Meshers: ICEM, Star, Ansys, Pointwise, GridPro, Ansa, ... 2 July 15, 2005 04:15
Warning 097- AB CD-adapco 6 November 15, 2004 05:41


All times are GMT -4. The time now is 06:43.