CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Addition of a New boundry Condition (http://www.cfd-online.com/Forums/openfoam-programming-development/63512-addition-new-boundry-condition.html)

ubaid April 10, 2009 09:54

Addition of a New boundry Condition
 
Hi friends,

I want to introduce a new condition in the file which has the following link.

src/finiteVolum/fileds/fvPatchFields/derived/oscillatingFixedValue

if you go to the file

OscillatinFixedValueFvPatchField.c

you will see that it calculates the frequency value by the following formula

1.0 + amplitude_*
sin(2*mathematicalConstant::pi*frequency_*this->db().time().value());
actually i want to introduce the angle theta as a phase angle into the above formula,

I am new into C++, could you guys give me tips how could i proceed it.

Thanks a lot.

Regards

bfa April 22, 2009 05:42

Quote:

Originally Posted by ubaid (Post 212553)

1.0 + amplitude_*
sin(2*mathematicalConstant::pi*frequency_*this->db().time().value());

actually i want to introduce the angle theta as a phase angle into the above formula,


If your theta is just a phase shift, simply add it inside the sin() function:
Code:

        sin(theta+2*mathematicalConstant::Pi*frequency_*this->db().time().value());
If theta is constant throughout your computation you could add it to the dictionary and read it from there like it is done with the amplitude and frequency variables (see the constructor of oscillatingFixedValueFvPatchField starting in line 81 of the source file). Of course you need to provide storage for a scalar in oscillatingFixedValueFvPatchField.H.
Just take a look at amplitude_ and copy it's behaviour, just changing the name of the variable to theta_ for example.

Have fun,
Bjoern

PS: To get the hang of C++, I recommend the book "The C++ Programming Language" by Bjarne Stroustrup. Or check out the great tutorial at http://www.cplusplus.com/doc/tutorial/

ubaid April 22, 2009 12:06

Boundry Condition
 
Dear bfg,

I did it the same way, as you have mentioned. after doing these changes. I wrote the "wmake libso" command in the directory of the finitevolume, and the compiler has created the .so file, and at last i also compiled the rhoTurbFoam file.

But when i used the rhoTurbFoam to solve my case, it created two more folders named 0.200 and 0.400 (according to the times).

In my 0.00 folder, i have added another term that is "angle" after frequency in the U file, but i didnt get the term "angle" in the U file in the folder 0.200.

there is no error, but on execution, the compiler, is not giving the output. I dont know whats the problem. May be I am doing a simple mistake that I cannot find it out.

Please help me out. Actually, this is my semester project and it is taking too much time now.

Thanks a lot for co-operation.

Best Regards,

isabel July 24, 2009 14:00

Sorry for bother you. Do you know how to correct my error?
My code is:

forAll(levelSet,gI)
{
if (levelSet[gI] > 0.0002 )
H[gI] = 1;
else
{
if (levelSet[gI] < 0.0002 )
H[gI] = 0;
else
H[gI] = sin(levelSet[gI]);
}
}


And when I compile, I have this error in the line " H[gI] = sin(levelSet[gI]) " :

levelSetEqn.H:91: error: call of overloaded ‘sin(double&)’ is ambiguous

henrik July 24, 2009 14:11

Isabel,

try

Foam::sin(levelSet[gI])

Henrik


isabel July 24, 2009 14:19

Thank you very much, Henrik
Now it works.


All times are GMT -4. The time now is 23:19.