CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

how to change a volScalarField in bc?

Register Blogs Community New Posts Updated Threads Search

Like Tree14Likes

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   January 5, 2012, 11:19
Default how to change a volScalarField in bc?
  #1
New Member
 
Kathrin
Join Date: Nov 2011
Posts: 15
Rep Power: 14
Katl is on a distinguished road
I need to add a source term in the time loop, which is calculated in one of my boundary conditions.

First I defined the following field in createFields.H:
Code:
 Info<< "Creating field sourceH\n" << endl;
    volScalarField sourceH
    (
        IOobject
        (
            "sourceH",
            runTime.timeName(),
            mesh,
            IOobject::READ_IF_PRESENT,
            IOobject::AUTO_WRITE
        ),
         Hclip/dim_s*0
    );
It is set to zero by "Hclip/dim_s*0" in the beginning and should be changed/updated in a specific boundary condition.

But how can I change the values of the field in the bc???

I tried the following:
Code:
scalarField sourceH = patch().lookupPatchField<volScalarField, scalar>("sourceH").patchInternalField();
scalar groundArea = 1.0; 
scalarField srcH = (HU.boundaryField()[patchNr]&n)/groundArea;
scalar cellSource = (gSum(srcH))/patch().size();
 for (int celli = 0; celli <= patch().size(); celli++) 
      {
       sourceH[celli]=cellSource;
      }
But "sourceH" is still zero...
atulkjoy likes this.
Katl is offline   Reply With Quote

 


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Solid/liquid phase change fabian_roesler OpenFOAM 10 December 24, 2012 06:37
Change cell zone index/thread during simulation neilduffy1024 FLUENT 0 January 17, 2011 09:40
Is there a way to change the name a volScalarField liu OpenFOAM Running, Solving & CFD 2 October 18, 2007 17:49
no enthalpy change across the momentum source Atit Koonsrisuk CFX 2 December 19, 2005 02:33
Multicomponent fluid Andrea CFX 2 October 11, 2004 05:12


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