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

Need to define a particular field

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

Like Tree1Likes
  • 1 Post By kathrin_kissling

Reply
 
LinkBack Thread Tools Display Modes
Old   October 17, 2012, 02:38
Exclamation Need to define a particular field
  #1
Member
 
Simone
Join Date: Sep 2012
Posts: 95
Rep Power: 4
batta31 is on a distinguished road
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
batta31 is offline   Reply With Quote

Old   October 18, 2012, 04:53
Default
  #2
Senior Member
 
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 8
kathrin_kissling is on a distinguished road
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...
mm.abdollahzadeh likes this.
kathrin_kissling is offline   Reply With Quote

Old   October 18, 2012, 05:11
Default
  #3
Member
 
Simone
Join Date: Sep 2012
Posts: 95
Rep Power: 4
batta31 is on a distinguished road
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 is offline   Reply With Quote

Old   October 18, 2012, 06:10
Default
  #4
Member
 
Simone
Join Date: Sep 2012
Posts: 95
Rep Power: 4
batta31 is on a distinguished road
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 is offline   Reply With Quote

Old   October 18, 2012, 06:16
Default
  #5
Member
 
Simone
Join Date: Sep 2012
Posts: 95
Rep Power: 4
batta31 is on a distinguished road
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!!
batta31 is offline   Reply With Quote

Old   October 18, 2012, 06:29
Default
  #6
Senior Member
 
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 8
kathrin_kissling is on a distinguished road
fvc::average will do the trick!

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


Best

Kathrin
kathrin_kissling is offline   Reply With Quote

Old   October 18, 2012, 08:13
Default
  #7
Member
 
Simone
Join Date: Sep 2012
Posts: 95
Rep Power: 4
batta31 is on a distinguished road
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 is offline   Reply With Quote

Old   October 18, 2012, 10:48
Default
  #8
Member
 
Simone
Join Date: Sep 2012
Posts: 95
Rep Power: 4
batta31 is on a distinguished road
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
batta31 is offline   Reply With Quote

Reply

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
How to define multiple boundary field names waku2005 OpenFOAM 4 May 9, 2011 08:28
problems after decomposing for running alessio.nz OpenFOAM 5 April 20, 2011 08:44
Missing math.h header Travis FLUENT 4 January 15, 2009 12:48
Problem with rhoSimpleFoam matteo_gautero OpenFOAM Running, Solving & CFD 0 February 28, 2008 07:51
REAL GAS UDF brian FLUENT 6 September 11, 2006 08:23


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