CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (https://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   Reading values of internal faces (https://www.cfd-online.com/Forums/openfoam-post-processing/66210-reading-values-internal-faces.html)

sega July 9, 2009 04:17

Reading values of internal faces
 
Hello World.

I need to read the values on some internal faces.
I thought of interpolating the volume field to the surfaces with e.g.
surfaceScalarField s = fvc::interpolate(p)

After this step I want to read the center value of the surface field for a set of specific faces I declared in faceSet.

How can I access this information?

Thanks.

olesen July 10, 2009 02:17

Check how large your surfaceScalarField is (ie, how many faces it has).
Access the ones you want.

sega July 10, 2009 02:22

Quote:

Originally Posted by olesen (Post 222175)
Access the ones you want.

How can I do that?
I don't know the code!

Furthermore: how can I loop through I set of faces I selected with faceSet prior?

olesen July 10, 2009 02:46

Quote:

Originally Posted by sega (Post 222177)
How can I do that?
I don't know the code!

Furthermore: how can I loop through I set of faces I selected with faceSet prior?

A faceSet is essentially a labelHashSet, you thus have all the usual methods as per HashSet. There are plently of places in the code that use some form of HashSet.
The command "git grep HashSet" is a quick way to find them all.

sega July 19, 2009 08:16

Hello World.

No that it comes to the implementation of this internal field reading stuff I'm experiencing strange errors with a very simple tryout.

This is the code:
Code:

    for (label i=startTime; i<endTime; i++)
    {

    runTime.setTime(Times[i], i);
        Info<< "Time = " << runTime.timeName() << endl;

    // Reading field  p
    volScalarField p
    (
        IOobject
        (
        "p",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ,
        IOobject::AUTO_WRITE
        ),
        mesh
    );

    //Create face values from field values
    surfaceScalarField ps = fvc::interpolate(p);
 
    Info<< "face value on face 61103"<< ps[61103]<< endl;
    }

which compiles smoothly. But when hitting the case this is the message:

Code:

Attempt to cast type patch to type lduInterface#0  Foam::error::printStack(Foam::Ostream&) in "/home/sega/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt/libOpenFOAM.so"
#1  Foam::error::abort() in "/home/sega/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt/libOpenFOAM.so"
#2  Foam::Ostream& Foam::operator<< <Foam::error>(Foam::Ostream&, Foam::errorManip<Foam::error>) in "/home/sega/OpenFOAM/sega-1.5/applications/bin/linux64GccDPOpt/listFaceSet"
#3  Foam::lduInterface const& Foam::refCast<Foam::lduInterface const, Foam::fvPatch const>(Foam::fvPatch const&) in "/home/sega/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt/libfiniteVolume.so"
#4  Foam::cyclicFvPatchField<double>::cyclicFvPatchField(Foam::fvPatch const&, Foam::DimensionedField<double, Foam::volMesh> const&, Foam::dictionary const&) in "/home/sega/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt/libfiniteVolume.so"
#5  Foam::fvPatchField<double>::adddictionaryConstructorToTable<Foam::cyclicFvPatchField<double> >::New(Foam::fvPatch const&, Foam::DimensionedField<double, Foam::volMesh> const&,Foam::dictionary const&) in "/home/sega/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt/libfiniteVolume.so"
#6  Foam::fvPatchField<double>::New(Foam::fvPatch const&, Foam::DimensionedField<double, Foam::volMesh> const&, Foam::dictionary const&) in "/home/sega/OpenFOAM/sega-1.5/applications/bin/linux64GccDPOpt/listFaceSet"
#7  Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricBoundaryField::GeometricBoundaryField(Foam::fvBoundaryMesh const&, Foam::DimensionedField<double, Foam::volMesh> const&, Foam::dictionary const&) in "/home/sega/OpenFOAM/sega-1.5/applications/bin/linux64GccDPOpt/listFaceSet"
#8  Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::readField(Foam::Istream&) in "/home/sega/OpenFOAM/sega-1.5/applications/bin/linux64GccDPOpt/listFaceSet"
#9  Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField(Foam::IOobject const&, Foam::fvMesh const&) in "/home/sega/OpenFOAM/sega-1.5/applications/bin/linux64GccDPOpt/listFaceSet"
#10  main in "/home/sega/OpenFOAM/sega-1.5/applications/bin/linux64GccDPOpt/listFaceSet"
#11  __libc_start_main in "/lib/libc.so.6"
#12  _start at /build/buildd/glibc-2.9/csu/../sysdeps/x86_64/elf/start.S:116


    From function refCast<To>(From&)
    in file /home/dm2/henry/OpenFOAM/OpenFOAM-dev/src/OpenFOAM/lnInclude/typeInfo.H at line 106.

FOAM aborting

Which looks very strange to me, as there is something about cyclic patches, which are not involved in this case...

Any ideas?

sega July 19, 2009 10:24

Stupid. There were cyclics involved. Who put them there? :mad:
Must have been me... :rolleyes:
Sorry.

So far it's working, but I bet I'm coming back ...

Sugajen August 29, 2017 21:09

Hi all,

I am trying to access and modify a field value on a face using this code
Code:

//Create face values from field values
surfaceScalarField ps = fvc::interpolate(p);

But getting an error,
Code:

error: assignment of read-only location
Is it possible to access and change internal face values of a cell in OpenFOAM?

Thanks,
Sugajen


All times are GMT -4. The time now is 22:53.