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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 2, 2012, 07:10
Default
  #21
Senior Member
 
Francois
Join Date: Jun 2010
Posts: 107
Rep Power: 21
Fransje will become famous soon enough
Quote:
Originally Posted by tomislav_maric View Post
From

OpenFOAM-1.6-ext/src/finiteVolume/fields/fvPatchFields/derived/parabolicVelocity

comes:

Code:
void parabolicVelocityFvPatchVectorField::updateCoeffs()
{
    if (updated())
    {
        return;
    }

    // Get range and orientation
    boundBox bb(patch().patch().localPoints(), true);

    vector ctr = 0.5*(bb.max() + bb.min());

    const vectorField& c = patch().Cf();

    // Calculate local 1-D coordinate for the parabolic profile
    scalarField coord = 2*((c - ctr) & y_)/((bb.max() - bb.min()) & y_);

    vectorField::operator=(n_*maxValue_*(1.0 - sqr(coord)));
}
This is called upcasting in C++: stripping the inherited object to the base class. All bcs are hidden *fields. No need for *_cast magic.

Just so you don't miss it , the key line is
Code:
vectorField::operator=  blah blah
, this converts "this" (the class, in this case parabolicBlah...) to a vectorField.

T.
Dear Tomislav,

Thank you for your contribution, but this is missing the point slightly.
The const_cast< > here is used to be able to change an object / variable in the database, which is of type const, so theoretically not modifiable.

Kind regards,

Francois.
Fransje is offline   Reply With Quote

Reply


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 07:37
Change cell zone index/thread during simulation neilduffy1024 FLUENT 0 January 17, 2011 10:40
Is there a way to change the name a volScalarField liu OpenFOAM Running, Solving & CFD 2 October 18, 2007 18:49
no enthalpy change across the momentum source Atit Koonsrisuk CFX 2 December 19, 2005 03:33
Multicomponent fluid Andrea CFX 2 October 11, 2004 06:12


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