CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Using Omega from MRFZones (https://www.cfd-online.com/Forums/openfoam-solving/115431-using-omega-mrfzones.html)

edalmau March 30, 2013 16:33

Using Omega from MRFZones
 
Hi to all foamers,

I'm quite new in this and I want to call the parameter "omega" defined in the MRFZones in my solver to change my gravity direction. I decomposed g into my axes but the angle will be found by multiplying omega and t.

First of all I tried with an scalar and it worked. Now I want to add omega to that but I have no clue to how call it. I've tried lots of different calls used in the c++ codes but none worked (omega, omega.value, omega(),....)

This is the line where I call the omega. The MRFZones.h is already included so this is not the problem.

Code:

g=gunits*Foam::sin(runTime.value()*(omega))*vector(1,0,0)-gunits*Foam::cos(runTime.value()*(omega))*vector(0,1,0);
Then the MRFZones file:

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.1.1                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    location    "constant";
    object      MRFZones;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

1
(
    tank
    {
        // Fixed patches (by default they 'move' with the MRF zone)
        nonRotatingPatches (atmosfera);

        origin    origin [0 1 0 0 0 0 0]  (0.5 0.5 0);
        axis      axis  [0 0 0 0 0 0 0]  (0 0 1);
        omega    omega  [0 0 -1 0 0 0 0] -1.75;
    }
)

// ************************************************************************* //

Thanks!

edalmau March 30, 2013 18:48

I looked up to the cfdtools of MRFZones and it seems like the correct definition is Omega_ for the vector and omega_ for the scalar value but it keep not working.

Here you can see part of the MRFZone.C where they use this names:

Code:

// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

Foam::MRFZone::MRFZone(const fvMesh& mesh, Istream& is)
:
    mesh_(mesh),
    name_(is),
    dict_(is),
    cellZoneID_(mesh_.cellZones().findZoneID(name_)),
    excludedPatchNames_
    (
        dict_.lookupOrDefault("nonRotatingPatches", wordList(0))
    ),
    origin_(dict_.lookup("origin")),
    axis_(dict_.lookup("axis")),
    omega_(dict_.lookup("omega")),
    Omega_("Omega", omega_*axis_)

As before I tried lots of combinations with 0 success so I'm quite disappointed with that.

Anyone can give me some advices???

edalmau April 1, 2013 09:36

Anyone can help me please?

edalmau April 1, 2013 12:39

After more research in how to read from MRFZones dictionary I found a thread here about calling constant values from dictionaries but it seems it doesn't work in my case but I don't know why is not working.

I add this code in my createFields.h:
Code:

IOdictionary MRFZones
    (
    IOobject
        (
          "MRFZones",
          runTime.constant(),
          mesh,
          IOobject::MUST_READ,
          IOobject::NO_WRITE
        )
    );
    dimensionedScalar omega_("omega", dimensionSet(0,0,0,0,0,0,0), scalar(0.0));
    omega_ = MRFZones.lookup("omega");

I put this editing a code found in this thread.

Now I don't have the same error when compiling but the new error is more strange to me cause I've not edited the createMRFZones.H from the original MRFInterFoam so I'm so surprised on that failing. Here you have the error I have when compiling:

Code:

In file included from MRFSpinInterFoam.C:61:0:
createMRFZones.H: In function ‘int main(int, char**)’:
createMRFZones.H:1:14: error: expected ‘;’ before ‘mrfZones’
createMRFZones.H:1:28: warning: statement has no effect [-Wunused-value]
createMRFZones.H:2:5: error: ‘mrfZones’ was not declared in this scope

Anybody knows why????

Thanks!

immortality April 2, 2013 00:55

dear my friend Eric.
im interested in your problem but didn't have an experiment in MRF concept.i hope your difficulty be resolved.
Search in this forum more.
Why don't you use scalar omega?is it variable in time?i know the underscore is not belonging to the name of variable.so try without _
And be patient.it certainly have a simple solution.please let me know your progress.

edalmau April 2, 2013 02:15

Hey immortality!

After a long research I found a public function in Openfoam 2.2.0 called "Omega()" which returns the value of the vector Omega. The problem is that I want to use it at my solver and it crashes due to "object issues".

The code where I call the function:
Code:

double omega;
    omega = mag(Foam::MRFZone::Omega());

I define a double called omega, and then I want to set it as the magnitude of the vector Omega cause I want a scalar not the whole vector.

When compiling the solver this error occurs:
Code:

MRFSpinInterFoam.C: In function ‘int main(int, char**)’:
MRFSpinInterFoam.C:65:38: error: cannot call member function ‘Foam::vector Foam::MRFZone::Omega() const’ without object

I'm not an expert in c++, but as I see I've to create an object in the class MRFZone to solve it but I still don't know how to do it, and maybe there is an easier solution for that.

The function Omega() suits very well in my case cause in other files (e.g. UEqn) I've to use it as a vector for the centrifugal force but I don't know how to use it. In that file I saw how they use other MRF functions and they use in OF2.2.0 the mrfZones.addCoriolis but, whem using the same sintaxis with the function Omega() it doesn't works cause in this new version mrfZones is used for another class IOMRFZoneList if I remember correctly (sorry but I ran so many times different sintaxis and I'm not sure).

Another problem I've to solve is making this Omega variable in time but first I want to call it in my solver properly and not adding a scalar in the equations because if I simulate different angular velocities I've to compile again and again.

If anyone can give some advices it would be awesome.

Thanks,
Eric

edalmau April 3, 2013 06:25

As nobody knows it or has read this thread yet. I'll ask you another question related to the subject. Is there any website, code, document or whatever where I can find how are named/labeled all the variables used in the different solvers?

For example I know that to call deltaT I've to type:

Code:

runTime.deltaTValue()
So is there any way to know how to "call" all the other variables used in the solvers? Or I've to search in all the .H and .C that my solver uses to find out?

Thanks in advance,

edalmau April 4, 2013 11:01

I tried again to use the Omega() function in MRFZone class.

The problem now is that I create an object of that class. But the compiler don't want to compile due to no matching. The code I tried to compile is this:
Code:

MRFZone velangular;
double omega = mag(velangular.Omega());

As you can see I define the object velangular as MRFZone. Then I want to use the function and assign the value of the magnitude of Omega to a double called omega.

The error that appears is:
Code:

MRF-interfoam.C:81:10: error: no matching function for call to ‘Foam::MRFZone::MRFZone()’
MRF-interfoam.C:81:10: note: candidates are:
/opt/openfoam220/src/finiteVolume/lnInclude/MRFZone.H:147:9: note: Foam::MRFZone::MRFZone(const Foam::word&, const Foam::fvMesh&, const Foam::dictionary&, const Foam::word&)
/opt/openfoam220/src/finiteVolume/lnInclude/MRFZone.H:147:9: note:  candidate expects 4 arguments, 0 provided
/opt/openfoam220/src/finiteVolume/lnInclude/MRFZone.H:132:9: note: Foam::MRFZone::MRFZone(const Foam::MRFZone&)
/opt/openfoam220/src/finiteVolume/lnInclude/MRFZone.H:132:9: note:  candidate expects 1 argument, 0 provided

As far as I know in C++ when defining an object you only have to do what I've already done so I don't know how I can define it to not be "ambiguous".

I'll apreciate any advice, help or comment.

Thanks!

edalmau April 4, 2013 17:10

After more tries I compiled the solver in OF 2.2.0 but I guess that the object definition is wrong because I don't really understand what is each of the 4 parameters I've to put.
The definition you can find in OpenFoam Programmers documentation:
Code:

MRFZone (const word &name, const fvMesh &mesh, const dictionary &dict, const word &cellZoneName=word::null)
What I put is that:
Code:

MRFZone velangular("zone1",mesh, mrfZones, "tank");
The error displayed is:
Code:

--> FOAM FATAL IO ERROR:
keyword origin is undefined in dictionary "/home/eric/PFC/Carpeta_nova/constant/MRFProperties"

It seems like the dictionary I put on the declaration is not correct but I don't know which is the good one. The file MRFProperties is OK cause it runs with MRFInterFoam.

Any ideas?

Anticipated thanks,
Eric

edalmau April 23, 2013 10:16

After some more attempts, and with the help of my tutor we finally found out a solution and it seems to work.

The problem was that inside the MRFProperties dictionary there are some subdictionaries in my case the name is "tank".

So the solution to declare an object in the class MRFZone is this:

Code:

MRFZone velangular("zone1",mesh, mrfZones.subDict("name_subdict"), "tank");
Then you can call all functions by using:
Code:

velangular.Omega()
(e.g. gives you the vector Omega)

Hope its helpful for someone.

fredo490 April 23, 2013 13:08

Quote:

Originally Posted by edalmau (Post 418047)
As nobody knows it or has read this thread yet. I'll ask you another question related to the subject. Is there any website, code, document or whatever where I can find how are named/labeled all the variables used in the different solvers?

For example I know that to call deltaT I've to type:

Code:

runTime.deltaTValue()
So is there any way to know how to "call" all the other variables used in the solvers? Or I've to search in all the .H and .C that my solver uses to find out?

Thanks in advance,

Do you mean something like that:
http://foam.sourceforge.net/docs/cpp/a02299.html

There is a good search tool ;)
Edit: or you can use a google search of this kind "sourceforge openfoam deltaTValue members"

Edit: on sourceforge with a simple search of "MRFZone" you would have found: http://foam.sourceforge.net/docs/cpp...d88ad5c0540a37

edalmau April 23, 2013 18:31

Quote:

Originally Posted by fredo490 (Post 422672)
Do you mean something like that:
http://foam.sourceforge.net/docs/cpp/a02299.html

There is a good search tool ;)
Edit: or you can use a google search of this kind "sourceforge openfoam deltaTValue members"

Edit: on sourceforge with a simple search of "MRFZone" you would have found: http://foam.sourceforge.net/docs/cpp...d88ad5c0540a37

I was already aware of that website when I posted all that stuff. The deal was that I didn't know how to create it, what I should put in each parameter the function asks for.

The reason of my last post today was to answer my own question by in case someone in future has the same problem I had.

Thanks for posting now I've new thread for the BC so you may be useful there. ;)


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