CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Need to define a particular field (https://www.cfd-online.com/Forums/openfoam-solving/108194-need-define-particular-field.html)

batta31 October 17, 2012 02:38

Need to define a particular field
 
Hi to everyone!
I need to define a new scalar field but just over a patch that represents an airfoil and later I want to be able to see it in paraFoam. Which is a possible solution to do that? I've been looking for something similar but I can't find anything.

Cheers,
Simone

kathrin_kissling October 18, 2012 04:53

Hey Simione,

define yourself a new volScalarField

Code:

volScalarField myField
(
    IOobject
    (
        "myField",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::AUTO_WRITE
    ),
    mesh,
    0.
);

in this case it is initialized with 0. everywhere. The boundary fields will be of type calculated.

Get to your airfoil patch

Code:

word patchName = "airfoil"; //or whatever

        label patchID = mesh.boundary().findPatchID(patchName);

alternatively


Code:

const fvBoundaryMesh& bdy = mesh.boundary();
    label patchID = -1;

    forAll (bdy, patchI)
    {
        if (bdy[patchI].name() == "freeSurface")
        {
            patchID = patchI;
        }
    }

Calculate whatever you want on the boundary...
Code:

myField.boundaryField()[patchID] = /*put your computation here*/;
Visualize the field myField in paraview.

Hope this helps...

batta31 October 18, 2012 05:11

kathrin_kissling,
thank you really much for your answer. I'll try your advice soon and let you know if it works!

By the way I've got also another trouble now: I know that there is fvc::interpolate function to get the value of a volumeField on to a surfaceField. But my question is: is there a function that can interpolate the value of a surfaceField on to a volumeField?? I really need it right now.

Thanks for your help
Simone

batta31 October 18, 2012 06:10

It doesn't work :(. Here's the error:

Quote:

#0 Foam::error:: printStack(Foam::Ostream&) in "/tmp/openFoam/OpenFOAM-2.1.1/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#1 Foam::sigSegv::sigHandler(int) in "/tmp/openFoam/OpenFOAM-2.1.1/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#2 in "/lib64/libc.so.6"
#3
in "/tmp/openFoam/OpenFOAM-2.1.1/platforms/linux64GccDPOpt/bin/adjointShapeFoam"
#4 __libc_start_main in "/lib64/libc.so.6"
#5
in "/tmp/openFoam/OpenFOAM-2.1.1/platforms/linux64GccDPOpt/bin/adjointShapeFoam"
Segmentation fault
and here's the piece of code that I've added to the solver:

Quote:

word patchName = "airfoil_top";
label patchID = mesh.boundary().findPatchID(patchName);
beta.boundaryField()[patchID]=0;
Any suggestion?

batta31 October 18, 2012 06:16

Now everything is ok! I had put the wrong name for the patch :). Now it remains the problem about interpolation..:)

Any suggestion is really appreciated!!

kathrin_kissling October 18, 2012 06:29

fvc::average will do the trick!

directly from fvcAverage.H:
Area-weighted average a surfaceField creating a volField


Best

Kathrin

batta31 October 18, 2012 08:13

Thanks again!!
If I want to evaluate some variable only on the patch just defined, let's say U, I only have to do something like:

mypatch.boundaryField()[patchID]= U.boundaryField()[patchID]...

right?

batta31 October 18, 2012 10:48

And, by the way, how would you impose a set of "nonuniform" but fixedValue BC over a patch?

What I need is, substantially, to impose different normal velocities over an airfoil.

Cheers
Simone


All times are GMT -4. The time now is 17:35.