- **OpenFOAM**
(*https://www.cfd-online.com/Forums/openfoam/*)

- - **Splitting Momentum Eqns and Adding Extra Terms to Each**
(*https://www.cfd-online.com/Forums/openfoam/217188-splitting-momentum-eqns-adding-extra-terms-each.html*)

Splitting Momentum Eqns and Adding Extra Terms to EachGreetings again!
I am trying to validate a case, but my implementation doesn't work properly so I wanna try something different, well, actually the original. I made my research but couldn't find answers to my questions. 1) Is it possible to add different terms to x and y momentum equation? I am thinking of call them UxEqn and UyEqn and make two loops for UEqn in total. Thats how I did in CFD class with MATLAB in past. 2) How can I add those terms? Can I just type: - (BT)*(Uy*sine(y)*cosine(y)-Ux*sine^2(y)) BT=thonf*B^2/rhonf I don't think so, doesn't look right. I am adding corresponding momentum equations, units are matching no problem there.(note: all extra terms are scalar excluding u-v) Any help would be great! https://i.ibb.co/RgTJ02L/mhd.jpg |

Hi,
1. You can always turn two scalars into vector multiplying them by corresponding unit vectors. I.e. vector = scalarx*i + scalary*j + scalarz*k. So your terms with sines and cosines could be rewritten as single term. 2. What is gamma? 3. The first term in the second expression is just buoyancy term. Select appropriate solver. |

Quote:
1) How? I clearly can't think a way since I am newbie to OpenFOAM. 2) Its angle between Bx By vectors(magnetic field) 3) I did, I modified and re-compiled buoyantBoussinesqPimpleFoam and its working but It solves maxwell equations. I want to do exactly like this and my problem is with sine-cosine terms. |

Sorry about late reply, I got forbidden error, after that I got another error. I had to switch browser.
Sorry for not beign clear. gamma= tan-1(By/Bx) B0= sqrt(By^2+Bx^2) When I am solving maxwell equations, B is a volVectorField. But in that(like in the picture) NS form I can identify them as a transportproperty. At least I think that will work, I might be wrong. About the 2nd equation, but that will be: sqr(cos(gamma))*vector(0, 1, 0) + sin(gamma)*cos(gamma)*vector(1, 0, 0) Am I right? but when adding those terms how do I implement them into: -fvm::grad( ) ? |

Hi,
You have got the idea correctly, though, I lost minus sign before sqr in my code example. So, the first term is: Code:
`T1 = -sqr(sin(gamma))*vector(1, 0, 0) + sin(gamma)*cos(gamma)*vector(0, 1, 0)` Code:
`T2 = -sqr(cos(gamma))*vector(0, 1, 0) + sin(gamma)*cos(gamma)*vector(1, 0, 0)` Code:
`U & (T1 + T2)` |

Thank you sir!
But as I said I am totally newbie, So I need just a little more assistance. So, I created volVectorFields V1 and V2, created corresponding variables and Ueqn as following: Code: Code:
` // Momentum Eqns` And I am getting these errors: Code:
` UEqn.H:4:37: error: no match for call to ‘(Foam::volVectorField {aka Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>}) (int, int, int)’` Code:
`UEqn.H:4:37: error: no match for call to ‘(Foam::volVectorField {aka Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>}) (int, int, int)’` Code:
` ` It says no match for call to but I have these lines inside createFields,H Code:
`Info<< "Reading field V1\n" << endl;` |

So why you have decided you write U(1, 0, 0)?
dvc was (obviously) my typo. Yet I can not understand why do you need to put those expressions under grad operator. There are no grads in your original equations. |

Because of my ignorance. I though you were saying corresponding vector by that.
Code:
`// Solve the momentum equation` And I really havent understood the U&(V1+V2) Term. When I implement it, it doesn't work. What does "&" stands for? And in this form(my code) it is obviously wrong, I have to give BC's to V1 and V2 which will be absurd, vectors corresponding to nothing(or do they because they are in Ueqn?). when I try Code:
` fvVectorMatrix UEqn` Code:
`UEqn.H:11:10: error: no match for ‘operator&’ (operand types are ‘Foam::tmp<Foam::fvMatrix<Foam::Vector<double> > >’ and ‘Foam::tmp<Foam::fvMatrix<Foam::Vector<double> > >’)` |

Well, yes, it is a little bit more complicated. & is overloaded operator and it means scalar product of two vectors. So to write source terms from your first post it is necessary to have something like:
Code:
`T1 = -sqr(sin(gamma))*vector(1, 0, 0) + sin(gamma)*cos(gamma)*vector(0, 1, 0)` But if you are trying to add Lorentz force and, in fact, your source term is You can use either mhdFoam, where this term is already in equations, and equations for magnetic field are also solved. Or you can write this term directly using OpenFOAM(R) operator notation. Now it is a little bit clearer why you wanted to put something into grad operator. |

Well, yes. I actually implemented Maxwell equations into buoyantBoussinesqPimpleFoam, it is working nicely and it really wasn't diffucult like this(at least for me). But in paper they are using this formulation so I wanted to try this one.
So, I tried that formulation and I am getting error: no match for 'operator=' Sv = U & V2 This error. I think this error is happens when left hand side is not same type as right hand side. I defined T1, T2, Su, Sv, SU as volVectorField(which will be problem because it will ask for boundary conditions, but that is another days problem I think...) What am I missing? |

You do not need to declare them as MUST_READ / AUTO_WRITE, since they are calculated fields, so you do not read them. And these fields are for calculation of volumetric force, so BCs are of calculated type.
T1 is vector field, U is vector field, so U & T1 (scalar product) is scalar field. Assignment is a bit of pseudocode. In real solver, you should use constructor a la: Code:
`const vector iHat(1, 0, 0);` |

Thank you so much for your patience and answers Dr. Matheichev. I prematurely tried to include the Lorenz force, so I went back to study on my hydrodynamics.
And I found this http://www.tfd.chalmers.se/~hani/kur...desTassone.pdf Anyone willing to add lorenz force can follow up here. And I must say even student projects are really good in this University. I'll probably apply to post doc after my PhD, I am amazed by their thesis studies. |

Quote:
Is it possible to use fvOptions for the same source term? |

All times are GMT -4. The time now is 10:08. |