|
[Sponsors] |
How to get coordinate of maxpressure on patch surface |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 16, 2018, 01:01 |
How to get coordinate of maxpressure on patch surface
|
#1 |
New Member
sorry_forbidden
Join Date: May 2018
Posts: 4
Rep Power: 8 |
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 |
|
May 16, 2018, 05:15 |
|
#2 |
Senior Member
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 14 |
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. |
|
May 16, 2018, 20:30 |
|
#3 |
New Member
sorry_forbidden
Join Date: May 2018
Posts: 4
Rep Power: 8 |
Thank you for your answer
I study it and try. |
|
May 29, 2018, 04:41 |
|
#4 | |
New Member
Dr. Peyman Davvalo Khongar
Join Date: Mar 2018
Location: Helsinki (Finland)
Posts: 16
Rep Power: 8 |
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 { functionObjectLibs ( "libutilityFunctionObjects.so" ); enabled true; type coded; executeControl writeTime; executeInterval 1; redirectType minMaxPatch; writeControl writeTime; writeInterval 1; codeOptions #{ -I$(LIB_SRC)/meshTools/lnInclude #}; codeExecute #{ label patchID = mesh().boundaryMesh().findPatchID("defaultFaces"); const volScalarField& p ( mesh().lookupObject<volScalarField>("p") ); scalar maxP = max(p.boundaryField()[patchID]); scalar xmax = 0; scalar ymax = 0; scalar zmax = 0; forAll(p.boundaryField()[patchID], faceI) { if (p.boundaryField()[patchID][faceI]==maxP) { xmax = mesh().Cf().boundaryField()[patchID][faceI].x(); ymax = mesh().Cf().boundaryField()[patchID][faceI].y(); zmax = mesh().Cf().boundaryField()[patchID][faceI].z(); } } Info << "Max pressure is: " << maxP << "at location "<<"("<<xmax <<","<< ymax<<","<<zmax<<")"<<endl; #}; } Peyman |
||
June 4, 2018, 23:13 |
|
#5 |
New Member
sorry_forbidden
Join Date: May 2018
Posts: 4
Rep Power: 8 |
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, |
|
June 6, 2018, 02:56 |
|
#6 |
New Member
sorry_forbidden
Join Date: May 2018
Posts: 4
Rep Power: 8 |
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 . . |
|
Tags |
function objects |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[snappyHexMesh] Bad meshing result on corrugated metal sheet | UebertreibeR | OpenFOAM Meshing & Mesh Conversion | 1 | August 19, 2016 05:55 |
[Gmsh] Problem with Gmsh | nishant_hull | OpenFOAM Meshing & Mesh Conversion | 23 | August 5, 2015 03:09 |
Possible Bug in pimpleFoam (or createPatch) (or fluent3DMeshToFoam) | cfdonline2mohsen | OpenFOAM | 3 | October 21, 2013 10:28 |
[GAMBIT] periodic faces not matching | Aadhavan | ANSYS Meshing & Geometry | 6 | August 31, 2013 12:25 |
chtMultiRegionFoam Tutorial | m.nichols19 | OpenFOAM | 12 | September 9, 2010 12:56 |