Accessing local cell index with global cell index in functionObject
Hello to all,
In a functionObject I am coding, I need to access the values of pressure of cellID {20, 70, 30, 50, 90}, in this order. I using a 2D square domain with 10x10 cells for testing decomposed in 2 processors. I have the following code. Code:
List<scalar> cellIds{20, 70, 30, 50, 90}; sField[70], it will give me the following error: Code:
[1] Is it possible of access the local cellID on each processor based on the global cellID? Any builtin function to do this? Best Regards |
Quote:
Let us give it a bit more consideration to what you are attempting. You have some cellIDs known in serial based on a particular geometry. If you change your mesh resolution (coarser/fine mesh), or swap the corners of the origination blockMesh you will have completely different cellIDs (in serial!). If you decompose onto multiple processors, which cells land where will depend on your decomposition method. To be really nasty about things, let us assume we are using the "random" decomposition method. This is my personal favourite. It is likely the worst possible decomposition you can imagine since each cell is randomly redistributed: horrible for calculation, great for debugging. I hope by now you see where all of this is going. Working with some arbitrary cellIDs that you have specified in serial is never going to work. Instead it would make sense to work directly with how you obtained these IDs in the first place. I would assume that you picked them out based on some x/y/z positions. From these sample points (starting to look a lot like sampledSets) you can find the nearest location in mesh on each processor and reduce the result to find the best location. I guess you could also do things by hand, define an ijkMesh based on the global mesh bounding box and use that as a voxel type of selection. You'll have to see what fits best for you. |
Hello Mr. Olesen,
Thanks for the reply. I will give more context into what I am trying to do. OpenFoam has the runTimeControl function object (https://www.openfoam.com/documentati...e-control.html) which I would like to make work for defining a steady state criteria based on the difference of properties between iterations i.e., at several locations x,y,z when the velocity and pressure difference between iterations is less than 1e-5 stop the simulation (steady criteria). The intent is to make this work with probes. But for now, I am asking the user to specify a number of random cells to keep track of some properties , e.g., pressure. The random points are selected with: Code:
// Get numbers of cells in the domain Afterwards in the execute() function of the funtionObject. Code:
bool Foam::functionObjects::steadyStateCheck::execute() This procedure works in serial with: Code:
runTimeControl1 Do you know if OF 2012 has any feature that already performs this task? Best regards. |
All times are GMT -4. The time now is 04:05. |