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/)
-   -   adding source term to interDyMFoam (https://www.cfd-online.com/Forums/openfoam-programming-development/141195-adding-source-term-interdymfoam.html)

agar_shod September 2, 2014 03:27

adding source term to interDyMFoam
 
2 Attachment(s)
I am new in openFoam programming.
I am going to add a source term in momentum equation in interDyMFoam which equation is shown in the picture.
as you can see there are different term which are in x and y directions ,the most important thing is the source term should be actived for x>x1 which x1 is an specific location in domain and the source term is dependent on x.
Is there any idea?
thanks a lot
:)

ssss September 2, 2014 03:32

You could set a field name alphaSources, which should be 0 where you don't want to have the sources terms, and 1 if you want to have de sources. This can be done with groovyBC or funkySetFields , and you'll need to modify the createFields.H in the solver to read the new field

After that just multiply sources*alphaSources, taking care that both have the same type definition. You may have to play a bit with it.

agar_shod September 2, 2014 05:57

thanks, its seems to be a good idea...
the variable Ca which defined in the picture is dependent to x. does openfoam recognize the x??? or should we have to define the x?? if yes how???

ssss September 2, 2014 06:38

Quote:

Originally Posted by agar_shod (Post 508794)
thanks, its seems to be a good idea...
the variable Ca which defined in the picture is dependent to x. does openfoam recognize the x??? or should we have to define the x?? if yes how???

You can define anote field with funkySetFields or setFields (search in google, there are tons of information).This utilities let you set the fields with conditionals, and you can access the position as you want (pos().x)

jhoepken September 2, 2014 10:34

Have a look at fvOptions. I would select all relevant cells via a cellZone and then code my own fvOption, which can be added to the solver at runtime. If you hardcode that into the solver, you have to recompile it and have your own custom solver, which is not as versatile as the fvOptions approach.

agar_shod September 6, 2014 03:11

thanks for your attention
should I use funky set field in order to define two conditional function ?
how can I define two conditions in funkysetfields?
In all of examples which I have seen just one condition were set.
thanks in advance


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