CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Pre-Processing

How to get coordinate of maxpressure on patch surface

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 16, 2018, 01:01
Default How to get coordinate of maxpressure on patch surface
  #1
New Member
 
sorry_forbidden
Join Date: May 2018
Posts: 4
Rep Power: 8
terry@man is on a distinguished road
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
terry@man is offline   Reply With Quote

Old   May 16, 2018, 05:15
Default
  #2
Senior Member
 
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 14
simrego is on a distinguished road
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.
simrego is offline   Reply With Quote

Old   May 16, 2018, 20:30
Default
  #3
New Member
 
sorry_forbidden
Join Date: May 2018
Posts: 4
Rep Power: 8
terry@man is on a distinguished road
Thank you for your answer

I study it and try.
terry@man is offline   Reply With Quote

Old   May 29, 2018, 04:41
Default
  #4
New Member
 
Dr. Peyman Davvalo Khongar
Join Date: Mar 2018
Location: Helsinki (Finland)
Posts: 16
Rep Power: 8
peyman.davvalo.khongar is on a distinguished road
Quote:
Originally Posted by terry@man View Post
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

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;

       #};
    }
Moikka,

Peyman
peyman.davvalo.khongar is offline   Reply With Quote

Old   June 4, 2018, 23:13
Default
  #5
New Member
 
sorry_forbidden
Join Date: May 2018
Posts: 4
Rep Power: 8
terry@man is on a distinguished road
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,
terry@man is offline   Reply With Quote

Old   June 6, 2018, 02:56
Default
  #6
New Member
 
sorry_forbidden
Join Date: May 2018
Posts: 4
Rep Power: 8
terry@man is on a distinguished road
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
.
.
terry@man is offline   Reply With Quote

Reply

Tags
function objects


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 13:20.