CFD Online Logo CFD Online URL
Home > Forums > OpenFOAM Programming & Development

how to change a volScalarField in bc?

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

Like Tree7Likes

LinkBack Thread Tools Display Modes
Old   February 2, 2012, 07:10
Senior Member
Join Date: Jun 2010
Posts: 107
Rep Power: 8
Fransje is on a distinguished road
Originally Posted by tomislav_maric View Post



void parabolicVelocityFvPatchVectorField::updateCoeffs()
    if (updated())

    // 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
vectorField::operator=  blah blah
, this converts "this" (the class, in this case parabolicBlah...) to a vectorField.

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,

Fransje is offline   Reply With Quote


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
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 17: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 05:12

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