CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   Problem saving value on boundary face (http://www.cfd-online.com/Forums/openfoam/93068-problem-saving-value-boundary-face.html)

robertmaier9 October 4, 2011 09:05

Problem saving value on boundary face
 
Hello,

I am having a problem saving a calculated value on to the boundary faces of a variable I call "f1". The variable f1 is a surfaceScalarField. I have no problems saving to the internal faces, it is only the boundary faces that are giving me trouble. I have a test case that has one cell, with 6 faces which have 5 boundary patches as 2 faces are defined together (for 2D case). Below is a little excert from the code. Further explaination comes below.

Code:

forAll(mesh.faces(), facei)
{
    xFaceNormal= mesh.Sf()[facei].component(0);
    label patchID = mesh.boundaryMesh().whichPatch(facei);
    Info << "f1 boundary is " << f1.boundaryField().size() << "spaces long" << endl;
    if(patchID > -1)
    {
        Info << "patchID = " << patchID << endl;
        Info << "facei = " << facei << endl;
        Info << "mesh.Sf()[facei] = " << mesh.Sf()[facei] << endl;

        double gAlphaX = gradAlphaX[facei];
        double gAlphaY = gradAlphaY[facei];
        betaCellDegNormal = Foam::atan(gAlphaX/(gAlphaY+0.000001))*2/3.14159;

        if((mesh.Sf()[facei].component(2) == 0))
        {
              if( xFaceNormal == 0 )
              {
                    alphacalc = alphaF.boundaryField()[patchID][facei];
                    alpha1percent = alphaF.boundaryField()[patchID][facei]*100;
                    #include "f1Eqn.H"
                    f1.boundaryField()[patchID][facei] = f1temp;
                    Info << "f1 = " << f1temp << endl;
                      Info << "It's a Y cell" << endl;
                }
            }
        }
    }

When running the code on the 1 cell test case, I get the following error:
Code:

#0  Foam::error::printStack(Foam::Ostream&) in "/usr/local/OpenFOAM/OpenFOAM-1.6.x/lib/linux64GccDPOpt/libOpenFOAM.so"
#1  Foam::sigSegv::sigSegvHandler(int) in "/usr/local/OpenFOAM/OpenFOAM-1.6.x/lib/linux64GccDPOpt/libOpenFOAM.so"
#2  ?? in "/lib64/libc.so.6"
#3  main in "/home/rm/OpenFOAM/rm-1.6.x/applications/bin/linux64GccDPOpt/interFoamHeatTransferBlending"
#4  __libc_start_main in "/lib64/libc.so.6"
#5  __gxx_personality_v0 in "/home/rm/OpenFOAM/rm-1.6.x/applications/bin/linux64GccDPOpt/interFoamHeatTransferBlending"
Speicherzugriffsfehler

It seems like the calculated value for f1 is being stored outside of the defined array, and some evidence supports this.

When I save the value of "f1temp" to the face of concern for f1, it is done with the following syntax:
Code:

f1.boundaryField()[patchID][facei] = f1temp;
If I call the value by the following code it gives me the correct value:
Code:

Info << f1.boundaryField()[patchID][facei] << endl;
If I call up all values of f1 like:
Code:

Info << f1 << endl;
the value is not saved where I would have expected it, and the values for f1, are still as defined in the initial condition, so no change to f1! Might any one have any ideas as to what I am doing wrong?

I can comment out saving the boundary value of f1 (f1.boundaryField()[patchID][facei]), and everything works fine.

robertmaier9 October 4, 2011 09:58

Problem Solved
 
I found someone at the institute to help me out here. The code that works I have paraphrased below for the purpose of documentation.

I looped first through patches, and then the faces of the given patch. Somehow this works rather than looping through the faces, and calling up patchID. Might anyone have a reason for why this works?

Code:

forAll(mesh.boundaryMesh(), patchi)
{
    forAll(mesh.boundaryMesh()[patchi], facei)
    {

Thanks.


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