CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

the global index for cells and facess in parallel computation

Register Blogs Community New Posts Updated Threads Search

Like Tree34Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 27, 2020, 06:15
Default
  #41
Member
 
David Andersson
Join Date: Oct 2019
Posts: 46
Rep Power: 7
sippanspojk is on a distinguished road
Hi @mkraposhin,

I am facing a similar challange as openfoammaofnepo did however, mine is a bit different.

I am writing a functionObject that I use for parallel computing. I define one or a few patches (let's say I select Building from Inlet, Outlet, Tunnel & Building) and I read the face pressure values on that patch. Then I do some computations and lastly write that to a custom made field.

My problem is that I don't know how to refer the pressure value of a face on one processor with the global face ID. Meaning I could read the p-value on face A, do my computations and then write my new value to face C.

I found this thread and it seams to be more or less my answer however, I do have some quesitions:

1) How would I implement a patch selection? I have a dict file where I define some patch names and that files is read into the list patchSet, which is a list of integers.

2) Can I implement your example code directly in my functionObject or do I need to do that in a solver?

I would be very gratefull for your help on this.

Cheers,
David
sippanspojk is offline   Reply With Quote

Old   April 27, 2020, 06:17
Default
  #42
Member
 
David Andersson
Join Date: Oct 2019
Posts: 46
Rep Power: 7
sippanspojk is on a distinguished road
Hi @mkraposhin,

I am facing a similar challange as openfoammaofnepo did however, mine is a bit different.

I am writing a functionObject that I use for parallel computing. I define one or a few patches (let's say I select Building from Inlet, Outlet, Tunnel & Building) and I read the face pressure values on that patch. Then I do some computations and lastly write that to a custom made field.

My problem is that I don't know how to refer the pressure value of a face on one processor with the global face ID. Meaning I could read the p-value on face A, do my computations and then write my new value to face C.

I found this thread and it seams to be more or less my answer however, I do have some quesitions:

1) How would I implement a patch selection? I have a dict file where I define some patch names and that files is read into the list patchSet, which is a list of integers.

2) Can I implement your example code directly in my functionObject or do I need to do that in a solver?

I would be very gratefull for your help on this.

Cheers,
David
sippanspojk is offline   Reply With Quote

Old   April 11, 2024, 11:06
Default
  #43
Member
 
bany
Join Date: Nov 2019
Posts: 50
Rep Power: 8
bany is on a distinguished road
Quote:
Originally Posted by openfoammaofnepo View Post
Dear Matvey,

How did you define the "localmesh" in the following:

Code:
    //read local cell addressing
    labelIOList localCellProcAddr
    (
        IOobject
        (
            "cellProcAddressing",
            localMesh.facesInstance(),
            localMesh.meshSubDir,
            localMesh,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
         )
    );
Thank you. When I compiled, I have the error information:

Code:
CFD_Cell_Local2Glob.H(27): error: identifier "localMesh" is undefined
            localMesh.facesInstance(),

The error can be solved by :
Code:
const fvMesh& localMesh(mesh);
In addition, the code can be simplfied by using
Code:
gatherList
Code:
List<List<label>> processCellToGlobalAddr_;
List<label> globalCellToProcessAddr_;

if (Pstream::parRun())
{
	processCellToGlobalAddr_.resize(Pstream::nProcs());
	 const fvMesh& localMesh(mesh);

	//read local cell addressing
	labelIOList localCellProcAddr
	(
	    IOobject
	    (
			"cellProcAddressing",
			localMesh.facesInstance(),
			localMesh.meshSubDir,
			localMesh,
			IOobject::MUST_READ,
			IOobject::NO_WRITE
	    )
	);
	
	processCellToGlobalAddr_[Pstream::myProcNo()] = localCellProcAddr;
	Pstream::gatherList(processCellToGlobalAddr_);
}
If the usage of "gatherList" has errors, please let me know.
bany is offline   Reply With Quote

Reply


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



All times are GMT -4. The time now is 21:18.