|
[Sponsors] |
September 24, 2015, 11:16 |
|
#41 |
Member
Xinguang Wang
Join Date: Feb 2015
Posts: 45
Rep Power: 11 |
Hi Su
Do you have any idea on how to access the neighbour cells of cell(i) in y direction. The cell P is known now, which is close to the wall, and I want to use the label of cell N which is above P, and the face label of n, which is between cell P and cell N. Thanks a lot. |
|
September 24, 2015, 12:47 |
|
#42 | |
Member
Xinguang Wang
Join Date: Feb 2015
Posts: 45
Rep Power: 11 |
Quote:
Have you found a way to your questions? I meet the same situation. Thanks a lot. Xinguang |
||
October 13, 2015, 12:09 |
|
#43 |
Senior Member
Dr. Fabian Schlegel
Join Date: Apr 2009
Location: Dresden, Germany
Posts: 222
Rep Power: 18 |
I am currently facing with this problem as well. Unfortunately, the idea of a compass like navigation is not possible for unstructured non-orthogonal meshes to my opinion. However, for playing around I assumed a orthogonal mesh aligned with the coordinate axis and by this it is possible to detect the direction of the neighbour by calculating the vector between the cell centres of the neighbour and the master cell. Some quick & and dirty piece of code would look like this
Code:
forAll(mesh_.cells(),cellI) { vector cellCenter = mesh_.C()[cellI]; labelList neighbours = mesh_.cellCells()[cellI]; forAll(neighbours,cellJ) { vector direction = mesh_.C()[neighbours[cellJ]] - cellCenter; label axis = 0; for(label i=0; i<3;i++) { if (mag(direction[i])>=mag(direction[axis])) { axis = i; } } switch(axis) { case 0: Info << "Seems like x-Axis" << endl; break; case 1: Info << "Seems like y-Axis" << endl; break; case 2: Info << "Seems like z-Axis" << endl; break; } } } Fabian |
|
March 7, 2016, 08:51 |
Neighbours within a radius
|
#44 |
New Member
Robert R.
Join Date: Feb 2016
Location: Braunschweig, Germany
Posts: 7
Rep Power: 10 |
Hey,
I need to check a value (temperature) of cells within a radius around the celli. Do I understand it right, that it is just possible to get the direct neighbors of the celli with your code? Right now I have no ideo how to implement such loop over all cells into my code. Do you got any proposals? Thank you |
|
March 16, 2016, 05:09 |
|
#45 |
Senior Member
Dr. Fabian Schlegel
Join Date: Apr 2009
Location: Dresden, Germany
Posts: 222
Rep Power: 18 |
I would say yes, you can do it with my code sniplet. However, there are some tools who create cellZones and cellSets and have a option to create spheres around a given centre. I would suggest to look into this tools and see how the handle the creation of spheres. As a starting point look at meshTools/sets/cellSources/sphereToCell/sphereToCell.C
Best regrads Fabian |
|
March 16, 2016, 07:08 |
|
#46 |
New Member
Robert R.
Join Date: Feb 2016
Location: Braunschweig, Germany
Posts: 7
Rep Power: 10 |
Thanks for the response.
I do understand the usage of sphereToCell just to refine the mesh, but not to create a virtual value to identify the cell temperatures within this sphere. Maybe you can write a short code to show what you mean. Thanks a lot |
|
March 16, 2016, 11:12 |
|
#47 |
Senior Member
Dr. Fabian Schlegel
Join Date: Apr 2009
Location: Dresden, Germany
Posts: 222
Rep Power: 18 |
I think the solution is already included in sphereToCell.C in the function combine:
Code:
//This gets all cell centres of all mesh cells const pointField& ctrs = mesh_.cellCentres(); //This calculates the radius of your sphere const scalar radSquared = radius_*radius_; //Loop over all cells forAll(ctrs, cellI) { //calculates the distance between the cell centre and the current cell //with the index cellI scalar offset = magSqr(centre_ - ctrs[cellI]); if (offset <= radSquared) { //Do something, e.g. store the current cell id in a list } } Best regards Fabian |
|
March 17, 2016, 11:16 |
|
#48 |
New Member
Robert R.
Join Date: Feb 2016
Location: Braunschweig, Germany
Posts: 7
Rep Power: 10 |
This sounds great and I think that's the right way to get what I need. My problem is that I don't know how to use sphereToCell. I always find the usage within the preprocessor "setFields".
Thank's for the response. |
|
March 17, 2016, 11:36 |
|
#49 |
Senior Member
Dr. Fabian Schlegel
Join Date: Apr 2009
Location: Dresden, Germany
Posts: 222
Rep Power: 18 |
My suggestion was NOT to use sphereToCell. You have to write your own utility and copy the parts of the code of sphereThoCell which helps you to solve your problem. May be it is possible to use a utility or a function of swak4Foam to yield the same result, but I do not know that at the moment.
|
|
April 7, 2016, 09:36 |
|
#50 |
New Member
sina
Join Date: Jul 2013
Posts: 21
Rep Power: 13 |
||
June 13, 2017, 12:00 |
|
#51 |
Member
Mahdi
Join Date: Jul 2012
Posts: 53
Rep Power: 14 |
I read many threads, but I have a question which can be related to this thread:
Is it possible to access each cell neighbor and assign the value of every 2 cells to an temporary cell list? Let's imagine we have a 64x64 structured 2D domain. I want to take every two cells in X-direction and Y-direction, and make a 32x32 imaginary domain with the cell center values coming from surrounding cells. It is like to hold a magnifier in hand, and zoom out what we see!. Then the cell center values in the 32x32 imaginary domain can be calculated as average of the every 4 cell center (it is just a temporary list not really a mesh). |
|
June 15, 2017, 07:39 |
|
#52 |
Senior Member
Dr. Fabian Schlegel
Join Date: Apr 2009
Location: Dresden, Germany
Posts: 222
Rep Power: 18 |
I do not have a solution for your problem, but I would like to add a comment and an idea
You have to have in mind that OpenFOAM uses an unstructured mesh which could consist of tetrahedra, hexahedra or whatever. Furthermore, the mesh in OpenFOAM is face based, which means every face knows about the cells which it belongs to. To conclude, this means you can get a list of all cells, you also can get a list of faces that belong to a certain cell and with this it is possible to get the neighbouring cell for each face. But than you get stuck, because the mesh is unstructured band you do not know which direction you have to move on. Everything you can do is a very costly search, checking the distanced and so on. What you are describing is very easy on structured meshes, especially on equidistant meshes. However, OpenFOAM is built for unstructured meshes and, hence, you are somewhat limited. But there is the possibility to map between meshes with "mapFields". To create a coarse mesh with blockMesh is quite simple. Furthermore, there are various tools available to manipulate the mesh, e.g., refineMesh. May be this helps to solve your problem. Best regards Fabian |
|
June 15, 2017, 08:46 |
|
#53 | |
Member
Mahdi
Join Date: Jul 2012
Posts: 53
Rep Power: 14 |
Quote:
Thanks for your contribution to this discussion, I understand your point as I also spent much time on that. Unlike the equidistant structured grids that we can create with any kind of programming tool, OpenFOAM has this limitation. Regarding the other ideas like mapping, I think this is not also possible, because I would need this so-called imaginary "coarse grid" during the simulation in every time step. In other words, it is going to act as an intermediate container list storing average of every 4 cells in the intersecting vertex. Then it will be deleted/updated in the next time step. Therefore, this is something completely independent of the mesh, while I assume mapping is something in pre-proceesing phase. What do you think? |
||
June 16, 2017, 03:41 |
|
#54 |
Senior Member
Dr. Fabian Schlegel
Join Date: Apr 2009
Location: Dresden, Germany
Posts: 222
Rep Power: 18 |
A possible idea could be, in the case you do not use a moving mesh or mesh refinement, to do before starting the simulation a search run and store the relationships between your simulation mesh and the coarse mesh. You can use the pointInCell and findCell functions of polymesh to check if a cell center is located within a certain range of another one. However, I tried this once and it is really a slow process. So you will not be able to do it every time step. Another idea would be to have a second coarse mesh during runtime and instead of averaging do an interpolation?
Best regards Fabian |
|
June 16, 2017, 04:15 |
|
#55 | |
Member
Mahdi
Join Date: Jul 2012
Posts: 53
Rep Power: 14 |
Quote:
Your first suggestion is something very demanding as you said because, in the case of having a fine grid, it would take too long for even one step. But I am interested in the second idea. You mean having both grids on the simulation, but using "fine" for the simulation and "coarse" for just interpolation of values?Is this doable in OpenFOAM? This is actually what I wanted to to do from the beginning, but I assumed only one mesh can be imported to the OpenFOAM not two. In addition, I also tried to have two meshes connected at one patch, but this would also result in other issues like BC for the intersection! Perhaps I have gone too far and there is an easier way to proceed with this interpolation idea you also suggested. Could you please tell me if any of OF tutorials does this?Or in any post on this forum has been already discussed? |
||
June 16, 2017, 12:12 |
overset grid
|
#56 | |
New Member
sina
Join Date: Jul 2013
Posts: 21
Rep Power: 13 |
Quote:
|
||
June 17, 2017, 04:40 |
|
#57 | |
Member
Mahdi
Join Date: Jul 2012
Posts: 53
Rep Power: 14 |
Quote:
I have actually heard about overset (not touched though), but as far as I know, this is something for complicated geometries for that a normal uniform meshing is not practical. The domain can use this feature to make a connection between the different type of meshes to cover the whole geometry. Therefore, in overset all the grids are really involved in the solution. But what I am looking for is much simpler (in concept): The coarser grid is going to be used only as the container of (the averaged values of) what is computed over the finer grid at each time step. So, no involvement in the simulation from the coarse grid is needed. Have you seen something similar before? |
||
June 19, 2017, 03:46 |
|
#58 |
Senior Member
Dr. Fabian Schlegel
Join Date: Apr 2009
Location: Dresden, Germany
Posts: 222
Rep Power: 18 |
I think what you are aiming at is often named as chimera grids. I never used it but I have seen a couple of presentations at the OpenFOAM User Conference. I think the mapping between the grids is the most important issue. As far as I know people use external library for mapping, but I am not sure as I never used it, e.g., SUGGAR++ (http://celeritassimtech.com/?page_id=21).
Best regards Fabian |
|
June 19, 2017, 04:22 |
|
#59 | |
New Member
sina
Join Date: Jul 2013
Posts: 21
Rep Power: 13 |
Quote:
|
||
November 20, 2017, 01:40 |
|
#60 | |
Member
Vishwesh Ravi Shrimali
Join Date: Aug 2017
Posts: 43
Rep Power: 9 |
Hi!
My problem can also get some help from sphereToCell. I have written a solver which can identify the centre and the radius of the sphere. I want to get all the cells inside that sphere and modify their alpha values. My question is can I directly use the combine function given in sphereToCell.C by putting sphereToCell.C, and other relevant files in the same folder, adding them to Make/files file, including them in the main solver and using the function combine? Thanks Vishwesh Quote:
|
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[mesh manipulation] Importing Multiple Meshes | thomasnwalshiii | OpenFOAM Meshing & Mesh Conversion | 18 | December 19, 2015 19:57 |
Determining cell neighbours on unstructured grid | orxan.shibli | Main CFD Forum | 4 | September 25, 2011 06:29 |
Help Me, what's the Cell Above any given cell in 3D. | gomane8 | Main CFD Forum | 3 | September 11, 2011 22:29 |
neighbours of a cell | Asghari | FLUENT | 17 | October 7, 2010 18:41 |
neighbours of a cell | Asghari | FLUENT | 0 | July 9, 2006 14:28 |