Manual limiter of velocity doesn't work
Hi to everyone guys!
I'm experiencing this problem and I really don' t know what to do: I'm running with the solver adjointShapeOptimizationFoam, but now I'm trying to modify it a little, since sometimes the equations diverge. What I want to do is to use a manual limiter, that limits the value of the velocity in each cell if it raises too much, so I've inserted these lines at the bottom of the solver: forAll(Ua,cellI) { Ua[cellI].component(0)=min(Ua[cellI].component(0), 200); Ua[cellI].component(1)=min(Ua[cellI].component(1), 200); Ua[cellI].component(2)=min(Ua[cellI].component(2), 200); } forAll(Ua,cellJ) { Ua[cellJ].component(0)=max(Ua[cellJ].component(0), -200); Ua[cellJ].component(1)=max(Ua[cellJ].component(1), -200); Ua[cellJ].component(2)=max(Ua[cellJ].component(2), -200); } I'm expecting that these lines behave like a threshold value for each component of the velocity at each iteration, but I've run a simulation and I discovered that the values of the velocity were bigger than the range [-200:200]. Maybe the lines I've added are wrong? Any help is really appreciated. Thanks in advance Simone P.s. I'm running in parallel, but I hope this is not a problem for the code I've added. |
Please guy, is there someone that can help?
|
You will need to limit the values on the patches also (all faces on patches)
forAll(U.boundaryField(),patchI) { forAll(U.boundaryField()[patchI],faceI) { U.boundaryField()[patchI][faceI].component(0)=some value; } } Also your solver might adjust U values not only after solving momentum equation. So make sure that your are limiting after each calculation step of U |
Thank you Omkar! The problem was exactly on the patches, since I had forgotten to loop on them. By adding your lines now it seems to work perfectly.
|
hi Simone
I think limiting velocity can also resolve my problem. Could you send me your modified solver? Thanks. |
where should i add them exactly?
|
can use velocity limiters only on a patch not entire the domain?
|
hi Omkar
Could you send me the code with added expressions for rhoPimpleFoam? |
My code consists of combination of above two codes.
Like I said, it did not work for me so I erased that code. The codes in this forum clearly explain how to limit velocity in the domain and the patches |
Hi immortality!
With respect to the adjointShapeOptimizationFoam solver, you should put the " two" limiter just above the lines Quote:
If you want to "limit" only the patches you should insert only the lines that doubtsincfd suggested. If, instead, you asked to limit only one specific patch you can use something like this: Quote:
Simone |
thanks.where the codes should be added in rhoPimpleFoam?
rhoPimpleFoam.C is this: Code:
#include "fvCFD.H" Code:
// Solve the Momentum equation Code:
{ Code:
rho = thermo.rho(); |
In my opinion after
Code:
if (pimple.turbCorr()) |
thank you dear Simone for your help
so I added it.is it correct?why you have wrote patchName2 in findPatchID? I put U[cellI] instead of Ua[cellI] due to use in rhoPimpleFoam does it have any problem? I want not to let U becomes higher than sound speed(flow should be subsonic) will it be true that I write sqrt(1.4*287.14*T[cellI]) instead of 500 I have put now? I want to be certain to compile the modified solver. thanks again. Code:
word patchName = "left"; |
I used it for the patch.but velocity in cells near the inflow boundary are supersonic.
where I add the expressions to limit velocity on top of domain? and what do you mean from cellI and cellJ in this expressions: forAll(Ua,cellI) { Ua[cellI].component(0)=min(Ua[cellI].component(0), 200); Ua[cellI].component(1)=min(Ua[cellI].component(1), 200); Ua[cellI].component(2)=min(Ua[cellI].component(2), 200); } forAll(Ua,cellJ) { Ua[cellJ].component(0)=max(Ua[cellJ].component(0), -200); Ua[cellJ].component(1)=max(Ua[cellJ].component(1), -200); Ua[cellJ].component(2)=max(Ua[cellJ].component(2), -200); } |
You have to put those line before the ones to limit the boundary. cellI and cellJ are two (unuseful) different counters. You can use the same for both cycles.
|
thank you dear Simone again
is this correct now?: Code:
forAll(U,cellI) thanks. |
when compiled it this error occurred:
Code:
ehsan@Ehsan-com:~/Desktop/rhoPimpleFoamLimited$ wmakeMaking dependency list for source file rhoPimpleFoamLimited.C |
Actually I don't know if OF will allow you such a statement:
Code:
U[cellI].component(0)= I don't know if you can use something like this: Code:
U[cellI].component(0)= Hope this help. |
thank you.
yes Simone you understood well. I modified it as so: Code:
forAll(U,cellI) Code:
ehsan@Ehsan-com:~/Desktop/rhoPimpleFoamLimited$ wmakeMaking dependency list for source file rhoPimpleFoamLimited.C |
it's
Code:
T[cellI] Code:
T.[cellI] |
thanks.but the error persists:
Code:
ehsan@Ehsan-com:~/Desktop/rhoPimpleFoamLimited$ wmake |
the code is now:
Code:
forAll(U,cellI) |
hi
did you find a reason for this error and not compiling? |
Maybe the first error (the one at line 90) is because you are trying to subtract T and the scalar value 30, but I'm not sure about it.
The second error (line 94) it's because you are using [cellI] variable into a loop with [cellJ]. The third (line 100) it's because, probably, you can't write T.boundaryField[patchID][faceI] since, I think, T doesn't have the access class "boundaryField". Try instead Code:
T.boundary[patchID][faceI] Hope this helps Simone |
thanks dear Simone.I changed it so:
Code:
forAll(U,cellI) Code:
rhoPimpleFoamLimited.C: In function ‘int main(int, char**)’: |
How have you defined T?
|
it seems it has trouble with T field.I only put it:
Code:
forAll(U,cellI) Code:
rhoPimpleFoamLimited.C: In function ‘int main(int, char**)’: |
it seems it has trouble with T field.I only put it:
Code:
forAll(U,cellI) Code:
rhoPimpleFoamLimited.C: In function ‘int main(int, char**)’: |
it seems it has trouble with T field.I only put it:
Code:
forAll(U,cellI) Code:
rhoPimpleFoamLimited.C: In function ‘int main(int, char**)’: |
oh.it wasn't sending but three of it send at a same time!
what do you mean by defining T? OF doesn't recognize T field itself? |
You are modifying a solver that was already present, right? Check in the associated createFields.H file how is T defined!
And then try to have a look to the access functions that can be used for that particular "T" field. Cheers Simone |
its total of creatFields.H!
its seemed that T is not defined explicitly in it. should I add it?like rho? where can find access functions? Code:
Info<< "Reading thermophysical properties\n" << endl; |
I defined T as:
Code:
volScalarField T is it true now? but another question,how T is written in time folders when it is not defined directly in creatFields.H? |
but the error now is:
Code:
ehsan@Ehsan-com:~/Desktop/rhoPimpleFoamLimited$ wmake thank you. |
what is incorrect in T now?I've defined it.
Another question is if this limiting true in aspect of CFD results?i mean does it lead to correct results with limiting?whats its influence in your opinion? |
did anyone find a reason and solution of the problem?
|
I believe it would help if you put
Code:
Foam:: Kind regards, Niels |
thank you very very so much dear Niels!!:D
it resolved. may you tell me the reason?is the sqrt a class object? how could i find the access functions for fields? |
It is my understand that the compiler does not know, whether to use the std:: or Foam:: class definition of sqrt, since the Foam:: is probably derived from std::.
Kind regards, Niels |
i have a subsonic problem but velocity at early time steps goes higher than sonic velocity and so i've limited it to sonic values as you can see above.
I have a doubt about the effect of this work on last results. Because running takes much time i decided to ask first. The CFD problem is unsteady compressible if important. |
All times are GMT -4. The time now is 06:45. |