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

How to access p and U within rotatingMotion.C/H

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 30, 2016, 18:24
Default How to access p and U within rotatingMotion.C/H
  #1
Member
 
Join Date: Nov 2009
Posts: 65
Rep Power: 16
waku2005 is on a distinguished road
Hi all,

I try to modify "rotatingMotion.C/H" of solidBodyMotionFunctions as those can calculate moment vector from p(pressure) and U(viscousity).
Thus, I hope to obtain p and U from previous timestep results.
I'd like to know the way to access such results if available.

Another question. rotatingMotion class has a constructer as below.
It uses runTime as time_, and runTime is a objectRegistory.
I can access to p and U via runTime(i.e.,time_) ?

Thanks in advance,
waku2005

Code:
        //- Construct from components
        rotatingMotion
        (
            const dictionary& SBMFCoeffs,
            const Time& runTime
        );

        //- Construct and return a clone
        virtual autoPtr<solidBodyMotionFunction> clone() const
        {
            return autoPtr<solidBodyMotionFunction>
            (
                new rotatingMotion
                (
                    SBMFCoeffs_,
                    time_
                )
            );
        }
waku2005 is offline   Reply With Quote

Old   December 2, 2016, 03:51
Default
  #2
Senior Member
 
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,266
Blog Entries: 1
Rep Power: 24
nimasam is on a distinguished road
you can use following structure to read U or p from solver:

Quote:
const volVectorField& U = db().lookupObject<volVectorField>("U");
__________________
My Personal Website (http://nimasamkhaniani.ir/)
Telegram channel (https://t.me/cfd_foam)
nimasam is offline   Reply With Quote

Old   December 4, 2016, 19:43
Default
  #3
Member
 
Join Date: Nov 2009
Posts: 65
Rep Power: 16
waku2005 is on a distinguished road
Hi, nimasam

Thank you for your reply.

I added "#include "volFields.H"" and the line you mentioned.
Code:
#include "DDrotatingMotion.H"
#include "addToRunTimeSelectionTable.H"
#include "mathematicalConstants.H"

#include "volFields.H"  //<-- added
Code:
// * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //

Foam::septernion
Foam::directDrivenMotionFunctions::DDrotatingMotion::transformation() const
{
    scalar t = time_.value();

    // Rotation around axis
    scalar angle = omega_->integrate(0, t);

    const volVectorField& U = db().lookupObject<volVectorField>("U");  //<-- added
    
    quaternion R(axis_, angle);
    septernion TR(septernion(-origin_)*R*septernion(origin_));

    DebugInFunction << "Time = " << t << " transformation: " << TR << endl;

    return TR;
}
Unfortunately build was failed as bellow:

Code:
directDrivenMotionFunctions/DDrotatingMotion/DDrotatingMotion.C: In member function ‘virtual Foam::septernion Foam::directDrivenMotionFunctions::DDrotatingMotion::transformation() const’:
directDrivenMotionFunctions/DDrotatingMotion/DDrotatingMotion.C:82:34: error: ‘db’ was not declared in this scope
     const volVectorField& U = db().lookupObject<volVectorField>("U");
                                  ^
directDrivenMotionFunctions/DDrotatingMotion/DDrotatingMotion.C:82:63: error: expected primary-expression before ‘>’ token
     const volVectorField& U = db().lookupObject<volVectorField>("U");
# DDrotatingMotion.C (and .H) is my own function file but they are still the same with the original rotaitngMotion.C (and .H).

How do I access to db() ?

Best regards
waku2005
waku2005 is offline   Reply With Quote

Old   December 5, 2016, 01:34
Default
  #4
Member
 
Join Date: Nov 2009
Posts: 65
Rep Power: 16
waku2005 is on a distinguished road
Hi

I changed the line to:
Code:
    const volVectorField& U = time_.db().lookupObject<volVectorField>("U");
and the build was in success, but failed with runtime error as bellow:
Code:
--> FOAM FATAL ERROR: 

    request for volVectorField U from objectRegistry mixerVesselAMI2D failed
    available objects of type volVectorField are
0()
db() has no registerdObject ?

waku2005
waku2005 is offline   Reply With Quote

Old   January 18, 2017, 04:13
Default
  #5
Member
 
Alexander Nekris
Join Date: Feb 2015
Location: France
Posts: 32
Rep Power: 11
Neka is on a distinguished road
Hi waku2005,

I'm struggling with a similar Problem.

I have to define an additional function in the class multiComponentMixture and for this new function I need to access the volScalarField rho at each time step.

Did you succeed to resolve this issue?

Best regards
Neka
Neka is offline   Reply With Quote

Old   January 26, 2017, 12:03
Default
  #6
Member
 
Alexander Nekris
Join Date: Feb 2015
Location: France
Posts: 32
Rep Power: 11
Neka is on a distinguished road
Here is one possibility:

Accessing fields calculated in a solver within a class
Neka 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
[DesignModeler] DesignModeler Scripting: How to get Full Command Access ANT ANSYS Meshing & Geometry 53 February 16, 2020 15:13
DPM, access particle data - number of tries wsaac Fluent UDF and Scheme Programming 1 July 31, 2018 02:40
Is there a way to access the gradient limiter in Fluent ? CFDYourself FLUENT 1 February 16, 2016 05:49
Online libraries - with access to Journals momentum_waves Main CFD Forum 2 December 12, 2007 10:08
Error: access: unbound variable,HELP sudhakar FLUENT 0 January 15, 2007 23:21


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