CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   couple cells from different meshes in parallel (https://www.cfd-online.com/Forums/openfoam-programming-development/68020-couple-cells-different-meshes-parallel.html)

sylvester September 3, 2009 09:48

couple cells from different meshes in parallel
 
Hi,

To calculate the thermal interaction between the coolant in a radiator and the air flowing through the radiator, I want to couple the cells of two overlapping regions (air/coolant) in order to match their heat transfer (in a later part of the code).

The coolant mesh has identical cells as the radiator zone in the air mesh.
In serial the coupling is achieved without problems with the following code:

Code:

const volVectorField& CAir = meshAir.C(); //Air cell centres

labelList cellIDAir.setSize(meshCoolant.nCells()); //initilize list of matching Air cell ID's
labelList cellIDCoolant.setSize(meshAir.nCells()); //initilize list of matching Coolant cell ID's

label cellZoneID = meshAir.cellZones().findZoneID(radiatorZone); //radiatorZone is located in Air
const cellZone& zoneAir = meshAir.cellZones()[cellZoneID];
const cellZoneMesh& zoneMeshAir = zoneAir.zoneMesh();
const labelList& cellsAirZone = zoneMeshAir[cellZoneID]; //list of all radiatorZone cell ID's

//loop over all cells in radiatorZone
forAll(cellsAirZone, cellI)
{
    // take one cell out of cellsAirZone list
    cellAirZone = cellsAirZone[cellI];

    //take cell centre of this Air cell
    vector AirCellCentre = CAir[cellAirZone];

    //locate matching Coolant cell
    cellIDCoolant[cellAirZone] = meshCoolant.findCell(AirCellCentre); //this fails in parallel

    //set matching Air cell
    cellIDAir[cellIDCoolant[cellAirZone]] = cellAirZone;
}

As the coolant mesh is much smaller than the total air mesh, the overlapping cells will, in general, not be assigned to the same processor.
This causes the .findCell function to fail when running in parallel.

How can I best solve (or circumvent) this problem?

Any help is much appreciated.

Best regards,
Sylvester

mkraposhin September 7, 2009 15:40

Hi, sylvester

I have the same trouble. Had you got any ideas?

sylvester September 9, 2009 06:57

Hi Matvej,

I circumvented the problem by making sure that all water cells are on the same processor as the associated air cells. This leaves some processors without any water cells, but this does not seem to cause any problems.

regards,
Sylvester

mkraposhin September 9, 2009 15:45

Hi, Sylvester

thank you for your reply. But i think, that it is not an elegant way of organizing parallel computations.

After looking through forum, i found that this problem can be solved by using MPI API.

As i understand, this could be done in a such way:
In master process:
1) Gather values of field from slave processes
2) Assembly whole field (for whole domain)
3) Update field
4) Send updated field values (parts of the field) to slave processes

But i still don't understand how to do this. For now, i'm examining OpenFOAM source code and forum for examples or similar cases.

sylvester September 10, 2009 06:36

Hi Matvej,

Yes, my solution might not be very elegant, but it works. And it works for me now, which is very important to me.

I'm still interested in a proper solution though, so please share it when you find it.

regards,
Sylvester

bastil September 11, 2009 16:05

Sylvester,

how do you ensure all cells to be on the same cpu? Which entry do you use in decomposParDICT? Thanks.

BastiL

sylvester September 14, 2009 07:37

Hi BastiL,

First decompose the first mesh with the -cellDist argument.
Next map the created cellDist file to the second mesh using mapFields.
Then make the new cellDist file suitable for decomposePar by deleting the unnecessary stuff.
Finally decompose the second mesh with the method specified as 'manual' in decomposeParDict. Make sure it uses your new cellDist file.

regards,
Sylvester

bastil September 29, 2009 04:32

Sylveser, mkraposhin,

your parallelisation seems quite complex to me. Would a
preserveFaceZones (zonename);
in decomposepardict not do the job?

I am interested in how your code looks like? Is it in a solver or a functionObject? Would it be possible sharing it with me?

Thanks BastiL

sylvester September 29, 2009 05:04

Hi BastiL,

As the coupling required by me was on the volume cell level, I do not expect that preserveFaceZones would have been sufficient. But with the method described in my previous message I can get the code running without problems.

The code snippet I have given before is used in a solver. I cannot release more of it, but that snippet should be enough to get you started.

regards,
Sylvester


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