CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Getting value of omega from a specific file. (https://www.cfd-online.com/Forums/openfoam-programming-development/171906-getting-value-omega-specific-file.html)

13msmemusman May 19, 2016 13:27

Getting value of omega from a specific file.
 
Hi i am talking specificly about in dynamicFVMesh there is a class oscillatingRotatingMotion. In oscillatingRotatingMotion.C there is a code


bool Foam::solidBodyMotionFunctions::oscillatingRotatin gMotion::read
(
const dictionary& SBMFCoeffs
)
{
solidBodyMotionFunction::read(SBMFCoeffs);

SBMFCoeffs_.lookup("origin") >> origin_;
SBMFCoeffs_.lookup("amplitude") >> amplitude_;
SBMFCoeffs_.lookup("omega") >> omega_;


I want to read value of omega from a file which is stored in case directory. I want it to be read at every time step..... The most important is it should be read at every time step. I dont know its basic structure for further work i will make it in such a way that at first time step first line of file will be read at 2nd iteration 2nd line will be read...... and so on. Please help me

teuk May 20, 2016 07:43

Hi 13msmemusman,

I'm not sure about this one but maybe something like:


Code:

scalar newOmega = readScalar(<dictionaryName>.lookupEntry("omega"));
in your time loop will do the trick for you?


regards,
teuk

13msmemusman May 20, 2016 12:06

But i dont want a new variable newOmega. i just want to update this variable omega at every time step

13msmemusman May 20, 2016 13:35

I have tried something. I thought i should use interpolationTable to give different Amplitude or Omega values at different time steps. So i added in solver.H (creatFields.H) file


// Read the data file and initialise the interpolation table
interpolationTable<scalar> timeSeriesAmplitude
(
runTime.path()/runTime.constant()/"amplitude.dat"
);


Then added in interDyMFoam.C file

amplitude.value() = timeSeriesAmplitude(runTime.value());


But the complier say that amplitude is not declared.

Please guide me what should i do...... amplitude if function of dynamicFVMesh or solidBodyMotionFvMesh or one of the oscillatingRotatingMotionCoeffs. i dont know and i could not figure out.

teuk May 21, 2016 09:11

Hi,


looks promising to me. But you need to assign your value from the table to the omega variable. Like you said:

Quote:

But i dont want a new variable newOmega. i just want to update this variable omega at every time step
Coming from:

Code:

SBMFCoeffs_.lookup("omega") >> omega_;
Probably something like:
Code:

omega_.value() = timeSeriesAmplitude(runTime.value());
Did you get this idea from tables in BCs?
Because thats what I used a couple of month ago. A BC where you can apply a table of inlet values. I used it for volume fraction if I remember correct. Maybe you'll have a look to that, too.

regards,
teuk

13msmemusman May 21, 2016 09:28

Actually i got the idea from variable acceleration problem i had to solve couple of months ago. For that i used interpolationTables. This is what i am again trying to do. I want to get omega value from a file in which i will write the omega value while algorithm is running. here is piece of code where exactly the omega is defined.

It is in the end of oscillatingRotatingMotion.C you can read this file in openfoam source code

bool Foam::solidBodyMotionFunctions::oscillatingRotatin gMotion::read
(
const dictionary& SBMFCoeffs
)
{
solidBodyMotionFunction::read(SBMFCoeffs);

SBMFCoeffs_.lookup("origin") >> origin_;
SBMFCoeffs_.lookup("amplitude") >> amplitude_;
SBMFCoeffs_.lookup("omega") >> omega_;

return true;
}


Please help me


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