How to get coordinate of maxpressure on patch surface
Hello Formers,
I want to get coordinate of maxpressure on patch surface. Because I am trying cavitaion and erosion analysis and want to know which area(point) happened big pressure , critical erosion. But fuction object(fieldminmax,facesource) doesn't match my needs. If you have any ideas, please teach me. Thank you |
Hi!
What if you use codedFunctionObject? You just have to go through all of your faces on a given patch. And it will give the face center where you have the bigest pressure. |
Thank you for your answer
I study it and try. |
Quote:
Moi! Here is a simple code using codedFunctionObject. It is tested with OpenFOAM dev version. defaultFaces is the name of the patch you want to get the max of pressure. The result will be shown in the terminal, although you can work with IO to write it in a file. Code:
minMaxPatch Peyman |
Hi peyman
Thank you your code! I confirmed that it works good. By the way , I migth as well introdude my wrong code. It operates properly with only single core, but When I choose parallel, It outputs wrong data. peyman's code uses boudaryfield my code uses boundaryMesh func { type coded; redirectType test; code #{ const volScalarField& p = mesh().lookupObject<volScalarField>("p"); label pieceID = mesh().boundaryMesh().findPatchID("piece"); const polyPatch &pp =mesh().boundaryMesh()[pieceID]; const scalarField& patchPressure =p.boundaryField()[pieceID]; const scalar &pmax = max(patchPressure); float py; float pz; for(int i=0; i<patchPressure.size(); i++){ if(patchPressure[i]==pmax){ py = pp.faceCentres()[i].y(); pz = pp.faceCentres()[i].z(); break; } } Info << "py = " <<py <<endl; Info << "pz = " <<pz <<endl; #}; outputControl timeStep; outputInterval 1; } thanks, |
Hi peyman
May I ask you question? Your code operates properly with single core, but when I choose parallel ,your code output wrong maxpressure and coordinte just like my code. I output follow data for checking the cause of this situation. ---------------p.boundaryField()[patchID]------------------------ Single: piece { type fixedFluxPressure; gradient uniform 0; value nonuniform List<scalar> 10640 ( 500000 500000 . . . Parallel: piece { type fixedFluxPressure; gradient nonuniform 0(); value nonuniform 0(); } --------------------------------------------------- As a result, If I choose parallel , patch(piece) faces are divided and distributed to each processor(Example↓). Therefore, in the situation of parallel, p.boundaryField()[patchID] accesses no data . Do you know the solution of this situation or anybody knows? Example) procBoundary0to1 { type processor; value nonuniform List<scalar> 5816 ( 500014 . . |
All times are GMT -4. The time now is 23:35. |