CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Indentify internal field value at specific patch (http://www.cfd-online.com/Forums/openfoam-programming-development/116050-indentify-internal-field-value-specific-patch.html)

Giancarlo_IngChimico April 11, 2013 17:18

Indentify internal field value at specific patch
 
Hi guys,
I have a patch named "fluid_to solid" in my mesh. In order to copy the values of a field in correspondence to this specific field I have written the following code:

Code:

forAll( TFluid[j].boundaryField(), patchi)
    {
        label patchID = fluidRegions[j].boundaryMesh().findPatchID("fluid_to_solid");
        forAll( TFluid[j].boundaryField()[patchID], facei)
            {
                Tf[facei+1] = TFluid[j].boundaryField()[patchID][facei];
            }
                   
    }

It seems to work fine.

My problem now is copy the internal values of the same field at the patch "fluid_to_solid"...

Can anyone help me?


Best


Giancarlo

immortality April 13, 2013 13:54

i need to do such work.i didn't grasp.what does this code do exactly? And where in code should it be added?(i use rhoPimpleFoam)
Thanks.

Giancarlo_IngChimico April 13, 2013 20:05

This is my solver that I have developed. I need to know the value of internalField only of the cells located at interface. (named "fluid_to_solid")

Lieven April 13, 2013 20:28

Hi Giancarlo,

I hope this is what you were looking for. Once you have the right patchID you can use something like:
Code:

const fvPatchVectorField& Uw = U.boundaryField()[patchI];
forAll(Uw,faceI)
{
    // The value inside the cell
    const scalar& Up = Uw.patchInternalField()[faceI];
}

It's just from the heart, I haven't tested it so it might not compile immediately but this might give you a direction.

Cheers,

L

ngj April 14, 2013 04:47

Good morning,

As an alternative, you can also work with the faceCells in case you have access to the whole of the volume field. This goes something along these lines, and assume that you have a fvPatch called "patch".

Code:

const polyPatch & pp = patch.patch();
const labelList & faceCells( pp.faceCells() );

forAll( faceCells, facei )
{
    // A bit of pseudo code
    myBoundaryField[facei] = someOperation<myVolumeField[faceCells[facei]]>;
}

This piece of code is particular interesting, if the volume field, which you need to access, is not the field on which the boundary condition is defined. E.g. accessing the velocity field in the boundary condition for pressure.

Kind regards

Niels

Giancarlo_IngChimico April 14, 2013 06:10

Thanks all,
I have solved in this manner:

Code:


const fvPatchList& patches = fluidRegions[j].boundary();
   
    forAll(patches, patchI)
    {
        const fvPatch& cPatch = patches[patchI];
        if(cPatch.name() == "fluid_to_solid")
        forAll(cPatch, celli)
        {
        Tf[celli+1] = TFluid[j].internalField()[celli];
        }
    }

Kind regards

Giancarlo

fredo490 April 16, 2013 12:29

I use this kind of code, I don't know if it works for multi region mesh:

Code:

label patchWall = mesh.boundaryMesh().findPatchID("wall"); //patchID = id of the patch wall
const fvPatch& cPatch = mesh.boundary()[patchWall];

    forAll(cPatch, facei) //facei = id of the face
    {
}

You can maybe adapt it to include your region selection.


All times are GMT -4. The time now is 18:38.