|
[Sponsors] |
November 29, 2010, 11:04 |
Getting cell ID from Patches
|
#1 |
Senior Member
Anne Gerdes
Join Date: Aug 2010
Location: Hamburg
Posts: 168
Rep Power: 16 |
Hey to all,
I need a little help. I have written a little postProcessing Tool which works similar to WallShearStress, i.e. it computes a gradient at the wall. Now I need to treat these gradients which are computed at each node of the boundary as a n-dimensional vector which has to me multiplied by a 3xn matrix (!) which I get from another program (ANSA). I have not yet computed this matrix but I ask how shall I compute the vector with the matrix if I do not know how my vector is sorted. So my question is: How do I get the cellID for each value in order to be able to sort it? Cell ID is just the first which came to my mind, any criteria how to sort this vector would help me because I need it to be sorted if I want to multiply it with the matrix. Do you have any ideas? Thank you very much in advance. Anne |
|
April 13, 2012, 12:46 |
|
#2 |
New Member
Darío López
Join Date: Oct 2011
Location: Vigo, Spain
Posts: 10
Rep Power: 15 |
Hi Anne.
Have you resolved your problem?? I am interesting in find the cellID's from Patches in order to program a Simpson rule. Do you have any suggestion? Regards. Darío. |
|
April 16, 2012, 06:44 |
|
#3 |
Senior Member
Anne Gerdes
Join Date: Aug 2010
Location: Hamburg
Posts: 168
Rep Power: 16 |
Hey Dario,
I solved my problem by outputting the x-y-and z- coordinate of each cell. Then I sorted the cells in the unix shell with sort -k1 -k2 -k3. The result is a sorted vector, first sort criteria x-coordinate, second one y-coordinate and third one z-coordinate so that it is a clear order. You can also look at the sample-utility of OpenFOAM, maybe this can help. So far, I do not know another solution. |
|
November 16, 2012, 14:19 |
|
#4 |
Member
Jamal
Join Date: May 2012
Location: Freiburg
Posts: 54
Rep Power: 13 |
Dear
I am a new user to OF. I am facing a problem to get Cell ID or cell coordinates so that i can get field values at prescribed locations. I need to know what to use and where to use a code/file to get this. Thanks aujamal |
|
December 11, 2012, 06:30 |
|
#5 |
Senior Member
Anne Gerdes
Join Date: Aug 2010
Location: Hamburg
Posts: 168
Rep Power: 16 |
Hey Aujamal,
you can output the data with Paraview. For my result-analysis I did the following steps 1.) In time folder delete all properties which are not needed (k, epsilon, whatever) 2.) Run foamToVTK 3.) Open the VTK-folder with paraview. 4.) Extract the regions, which you would like to analyze, with slice/clip or other filter tools. 5.) Output the data with File -> Save Data -> Points as .csv - File. 6.) In the csv-File you will find the x,y and z-coorindates and the respective values for velocity, pressure 7.) You can now sort the data, plot it, analyze it, whatever. I hope this helped? Kind Regards Anne |
|
May 9, 2013, 10:30 |
|
#6 | |
Senior Member
|
Quote:
Hi, do you have any idea in how to get cell IDs of the cells (face cells) which are located in a specific region (which is extracted using slice/clip tools)? I want to use these cell IDs to be able to use nonUniform BC. for example I have a large domain. in a specific region of this domain I want x_value to be 0.1 and for the rest of the domain I want x_value to be 0.2. Do you have any idea how can I achieve this? I am trying to know cell IDs of the specific region in order to assign these cells my desired values, later. Thank you, Mojtaba
__________________
Learn OpenFOAM in Persian SFO (StarCCM+ FLUENT OpenFOAM) Project Team Member Complex Heat & Flow Simulation Research Group If you can't explain it simply, you don't understand it well enough. "Richard Feynman" |
||
May 10, 2013, 08:53 |
|
#7 |
Member
Jamal
Join Date: May 2012
Location: Freiburg
Posts: 54
Rep Power: 13 |
Hello Mojtaba,
I am not sure what you really want to do, but the utility setFieldsDict might help you in this regard to set the particular values of the field variable at different locations/(set of cells) within the domain. Please let me know if find any alternate. Thanks |
|
May 10, 2013, 14:21 |
|
#8 | |
Senior Member
|
Quote:
Well I am trying to define a nonUniform boundary condition. as you know nonUniform boundary condition has a form like this: value nonuniform List<scalar> 'No.ofOverallCells' ( //data entered here ); Unfortunately In OF I couldn't find any order for numbering of the cells and thus I don't know how to write the list. For instance I have a nonUniform boundary like this: value nonuniform List<scalar> 5 ( 1 2 3 4 5 ); How can I know that which cell in boundary has the value of '1' or any other values? actually I have found the solution to this particular issue, and that's by using paraview, but it is not applicable for boundaries with large number of cells. Do you have any idea how I can set value for each cell in a boundary? In addition I haven't used setFields utility yet, I don't know if it is capable of selecting my desired group of cells. my cell region is not a common shape like rectangular or circle to define it easily. Therefor I don't know how to define it using setFields. Thank you, Mojtaba
__________________
Learn OpenFOAM in Persian SFO (StarCCM+ FLUENT OpenFOAM) Project Team Member Complex Heat & Flow Simulation Research Group If you can't explain it simply, you don't understand it well enough. "Richard Feynman" |
||
May 13, 2013, 04:23 |
|
#9 |
Senior Member
Anne Gerdes
Join Date: Aug 2010
Location: Hamburg
Posts: 168
Rep Power: 16 |
Hey Mojtaba,
I set the values with setFieldsDict concerning the internal Field. So far I have not used a non-uniform condition on the boundary itself. I got the numbers of the cells with paraview as I wrote before.... why doesn't this work in your case? Here is an example of a setFieldsDict. It sets alpha equal to 200 on the cellSet face_hole_1 and zero elsewhere. You can generate the cellSet from a cellZone in polyMesh/cellZones where you define it with the numbers obtained from paraview. I hope this helps.... Kind Regards Anne HTML Code:
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 1.7.0 | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; location "system"; object setFieldsDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // defaultFieldValues ( volScalarFieldValue alpha 0 ) ; regions ( cellToCell { set face_hole_1; fieldValues ( volScalarFieldValue alpha 200 ); } ) |
|
May 13, 2013, 13:09 |
|
#10 | |
Senior Member
|
Quote:
Well this really helped. My problem is a little bit different. Here is the boundary I am trying to define in nut boundary condition file. ground { type nutkAtmRoughWallFunction; z0 $z0; value uniform 0.0; } I have different z0 values for different cellSets. As far as z0 is not directly a field (correct me if I am wrong about this), I can not use setFields utility to set values for it. Therefore I am trying to use nonUniform BC which I got to know cell positions. As you mentioned I can find cell numbers in paraview, but I need to sort the list manually for nonUniform BC. Do you have any idea that how can I set this?
__________________
Learn OpenFOAM in Persian SFO (StarCCM+ FLUENT OpenFOAM) Project Team Member Complex Heat & Flow Simulation Research Group If you can't explain it simply, you don't understand it well enough. "Richard Feynman" |
||
May 14, 2013, 05:14 |
Getting cell IDs from patches
|
#11 |
Senior Member
Albrecht vBoetticher
Join Date: Aug 2010
Location: Zürich, Swizerland
Posts: 240
Rep Power: 17 |
Maybe this code snippet helps, I once had to implement fludi structure interaction between InderDyMFoam and a DEM code so I needed the nodes of the boundary. I define the Patch name in a couplingProperties dictionary in constant folder and write the node coordinates to a file. The advantage is that it allows you to adress more things than yust coordinates once you added the code. Part of the code was written at the chair of structural analysis at TU Munich (TUM)
//open dictionary couplingProperties in directory: casename/constant IOdictionary couplingProperties ( IOobject ( "couplingProperties", runTime.constant(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ) ); word coupledPatchName = couplingProperties.lookup("coupledPatchName"); label coupledPatchID=mesh.boundaryMesh().findPatchID(cou pledPatchName); scalar interval = readScalar(couplingProperties.lookup("interactionI nterval")); //pointer to points and faces const pointField& patchPoints = mesh.boundaryMesh()[coupledPatchID].localPoints(); //const faceList& patchFaces = mesh.boundaryMesh()[coupledPatchIDs].localFaces(); //typeFace[patchI]=patchFaces[0].size(); int numNodes = patchPoints.size(); nodeCoords = new double[3*numNodes]; int j=0; for(int i=0;i<numNodes;i++){ nodeCoords[j ] = patchPoints[i].x(); nodeCoords[j+1] = patchPoints[i].y(); nodeCoords[j+2] = patchPoints[i].z(); j=j+3; } // write nodeCoords to file named 'nodeCoord' OFstream nodeCoordFile(runTime.path()/"nodeCoord"); j=0; for(int i=0;i<numNodes;i++) { nodeCoordFile << nodeCoords[j ] <<'\t' << nodeCoords[j+1] <<'\t' << nodeCoords[j+2] << endl; j=j+3; } the cells of the patch you get with: const labelList& patchCells = mesh.boundaryMesh()[coupledPatchID].faceCells(); If it is to find cells within the mesh due to the space they lie in: // Loop over all the cells in the mesh: forAll(mesh.cells(), cellI) const vector& cellCenter = mesh.C()[cellI]; const scalar x = cellCenter[0]; const scalar y = cellCenter[1]; const scalar z = cellCenter[2]; if ( x < //... && y ... && z ... all your restrictions where the cells you need are situated) label selectedCellID = cellI; Last edited by vonboett; May 14, 2013 at 05:37. |
|
May 15, 2013, 04:50 |
|
#12 |
Senior Member
Anne Gerdes
Join Date: Aug 2010
Location: Hamburg
Posts: 168
Rep Power: 16 |
I think "setFields" will work, as is sets values depending on the cellZones/cellSets that you define. But the problem will be to define those cellZones.
What do you mean with different values for z0? What is z0? There are possibilities in OpenFoam to define cellZones with "cellSet" and a proper cellSetDict for example all cells inside a defined box. How do the cellZones that you want to generate look like? Kind Regards Anne |
|
May 15, 2013, 10:21 |
|
#13 | |||
Senior Member
|
Quote:
This is interesting. Let me compile the code to see if it can help me solve my problem. Quote:
Well z0 is the roughness parameter for any wall type BC. this roughness values are defined in nut file. Maybe I was not clear in my last post. The BC is something like this: nut ---------- ground { type nutkAtmRoughWallFunction; z0 uniform 0.1; value uniform 0.0; } Or if I want a nonUniform distribution of z0, I have something like this: ground { type nutkAtmRoughWallFunction; z0 nonuniform List<scalar> 5 ( 0.1 0.1 0.2 0.3 0.3 ); value uniform 0.0; } I am new to setFields utility. my region is surrounded by straight lines. For example a region which is surrounded by: y=0 x=0 y=-x+1 In this post: http://www.cfd-online.com/Forums/ope...tml#post427038 gschaider has solved this problem for me. As he says: Quote:
In my case (to set values of z0) what will be the replacement for alpha? Or generally how this code will work for me to set values of z0 in nut file? Warmest Wishes, Mojtaba
__________________
Learn OpenFOAM in Persian SFO (StarCCM+ FLUENT OpenFOAM) Project Team Member Complex Heat & Flow Simulation Research Group If you can't explain it simply, you don't understand it well enough. "Richard Feynman" |
||||
May 15, 2013, 10:36 |
|
#14 |
Senior Member
Anne Gerdes
Join Date: Aug 2010
Location: Hamburg
Posts: 168
Rep Power: 16 |
I am not familiar with funkySetFields. But if it is possible to apply this to a field alpha, you can also run it for a field z0 and then transfer the z0 to the nut-environment (simplest but not very elegant way: just copy the non-uniform list to the nut-environment. But there have to be other possibilities).
The z0 has different values in your case (0.1, 0.2,...). Is there a function how this z0 is computed? Is it related for example to "x"- or "y"-coordinates? |
|
May 15, 2013, 20:41 |
|
#15 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
||
May 16, 2013, 06:15 |
|
#16 | ||
Senior Member
|
Quote:
I haven't tried this method yet. Let me see if it works. Well as I said my region is surrounded by multiple straight lines which these lines themselves have functions. For example y=-x+1 is one border. Quote:
Well z0 is not changing (Thanks god ). I am not familiar with this tool. is it similar to funkySetFields? can you give me a little sample on how I can use this? Thanks for your valuable time, Best wishes, Mojtaba
__________________
Learn OpenFOAM in Persian SFO (StarCCM+ FLUENT OpenFOAM) Project Team Member Complex Heat & Flow Simulation Research Group If you can't explain it simply, you don't understand it well enough. "Richard Feynman" |
|||
May 16, 2013, 06:45 |
|
#17 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Code:
dropIn { field alpha1; expressions ( { target inletValue; patchName atmosphere; variables "maxX=max(pts().x);thres1=0.4*maxX;thres2=0.6*maxX;"; expression "(pos().x>thres1 && pos().x<thres2) ? 1 : 0"; } ); }
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
||
May 16, 2013, 15:28 |
|
#18 | |
Senior Member
|
Quote:
I got to play with it a little bit to see how it works. Thank you very much gschaider, Anne and anybody who helped me here. Best wishes, Mojtaba
__________________
Learn OpenFOAM in Persian SFO (StarCCM+ FLUENT OpenFOAM) Project Team Member Complex Heat & Flow Simulation Research Group If you can't explain it simply, you don't understand it well enough. "Richard Feynman" |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to determine the direction of cell face vectors on processor patches | sebastian_vogl | OpenFOAM Programming & Development | 1 | October 11, 2016 14:17 |
Cells with t below lower limit | Purushothama | Siemens | 2 | May 31, 2010 22:58 |
How to determine the direction of cell face vectors on processor patches | sebastian_vogl | OpenFOAM Running, Solving & CFD | 0 | October 27, 2009 09:47 |
[Commercial meshers] Trimmed cell and embedded refinement mesh conversion issues | michele | OpenFOAM Meshing & Mesh Conversion | 2 | July 15, 2005 05:15 |
Warning 097- | AB | Siemens | 6 | November 15, 2004 05:41 |