|
[Sponsors] |
November 24, 2009, 03:43 |
How to get the heighth,length of a 2D cell?
|
#1 |
Member
jingjing
Join Date: Mar 2009
Location: shanghai,China
Posts: 30
Rep Power: 17 |
I want to improve my postprocessing tool for my wave tank to make it suitable for a wave tank with non-uniform mesh.In order to get the average value of a field with non-uniform mesh,I have to calculate the size of each cell (the heigt,length,width of a rectangular cell) as a weight factor,but I don't know how to get this kind of geomertric information of a cell.
One method is to get the coordinate value of the vertices of a cell,then make one subtract another.But I can't go on at the detail. Code:
forAll(mesh.cellCentres,cellid) { if(abs(mesh.cellCentres[cellid].x()-x)<=deltaX/2) //deltaX:the length of a cell, choose out the cells at the x point along the 2D wave tank { ncells++; sumField+=field[cellid]*deltaY;//deltaY: the height of a cell weight+=deltaY; Info<<ncells<<"cell No"<< cellid <<"field value"<<field[cellid]<<endl; } } sumField=sumField/weight; //the average value of the gamma field at the x point along the wave tank in the following short script: Code:
const labelList patchCells = this->patch().faceCells(); const fvPatchScalarField& gamma=patch().lookupPatchField<volScalarField,scalar >("gamma"); const pointField& points = mesh.points(); forAll(patchCells,i) { labelList cellpoints=mesh.cellPoints(patchCells[i]); label size=cellpoints.size(); for(int j=0,j<size,j++) //???如何读取单元尺寸 { points[cellpoints[j]].y() ... gamma[patchCells[i]]*... waveAtWavemaker_=... } Is there anyone can help me?Thanks two attachments: the old version of the wave tank postprocessing tool, and another is a new version waiting to be improved to postprocess the non-uniform mesh wave tank. |
|
December 2, 2009, 21:05 |
|
#2 |
Member
Richard Kenny
Join Date: Mar 2009
Posts: 64
Rep Power: 18 |
isn't it possible to simply use gAverage (volume averaging)?
Richard |
|
May 4, 2014, 16:49 |
|
#3 |
New Member
Join Date: Oct 2013
Posts: 19
Rep Power: 12 |
Hey guys,
Do you know how i can find the deltaX, deltaY and deltaZ of a cell? I can use some thing like "scalar dx = mesh.C()[0].x() * 2.;" for serial, but for parallel case it needs many considerations... So do you know any simple function? |
|
March 25, 2015, 06:47 |
Did you get an answer to get dx, dy and dz?
|
#4 |
New Member
Sam Fredriksson
Join Date: Dec 2010
Posts: 20
Rep Power: 15 |
Did you get an answer to get dx, dy and dz?
|
|
June 8, 2016, 06:59 |
|
#5 | |
Member
Lennart
Join Date: Feb 2016
Posts: 46
Rep Power: 10 |
Hey guys,
Quote:
Code:
mesh.delta() Code:
forAll(owner, facei) { delta[facei] = C[neighbour[facei]] - C[owner[facei]]; } |
||
January 8, 2018, 18:16 |
|
#6 |
Senior Member
Taher Chegini
Join Date: Nov 2014
Location: Houston, Texas
Posts: 125
Rep Power: 12 |
In case someone was looking for a complete answer, here is the code to get the deltas in each direction for each cell:
Code:
const surfaceVectorField& deltas = mesh().delta(); forAll(deltas, I) { Info<< "dx[" << I << "] = " << deltas[I].x() <<endl; Info<< "dy[" << I << "] = " << deltas[I].y() <<endl; } |
|
July 15, 2018, 10:25 |
what does x,y,z mean here?
|
#7 | |
Member
王莹
Join Date: May 2017
Posts: 51
Rep Power: 8 |
Hello,
I am focusing on the definition of deltax, deltay and deltaz in OF. I am so happy to see your answer and it really give me some ideas! However I still have some problems. Does it mean that when I want to use deltax(or deltay, etc) in a piece of code, I just need define "deltas" first (like your code "const surfaceVectorField& deltas = mesh().delta(); ") and use deltas[I].x() in loops? Another puzzle is what x, y, z represent. Does x, y, z here represent three directions in Cartesian coordinates? However, in fluid mechanics, x,y,z represent streamwise direction, normal direction and spanwise direction. A typical physical quantity is y+(yplus). Thanks a lot! Anyone who can give me some suggestions is welome! Alisa. Quote:
|
||
July 15, 2018, 11:11 |
|
#8 |
Senior Member
Taher Chegini
Join Date: Nov 2014
Location: Houston, Texas
Posts: 125
Rep Power: 12 |
Here is how delta is defined in OF:
Code:
forAll(owner, facei) { delta[facei] = C[neighbour[facei]] - C[owner[facei]]; } |
|
July 15, 2018, 23:27 |
|
#9 | |
Member
王莹
Join Date: May 2017
Posts: 51
Rep Power: 8 |
What I want is xyz in dynamic mechanics level. However, your idea makes me understand OF frame more clearly. Thank you!
Quote:
|
||
April 27, 2021, 05:54 |
x,y,z length in every cell
|
#10 | |
New Member
shiyu
Join Date: Mar 2018
Location: london
Posts: 7
Rep Power: 8 |
Quote:
I am wondering if you have found a better solution of x,y,z lengths in every cell, instead of the delta distance between every two cells. Thanks BR, Shiyu |
||
April 30, 2021, 07:44 |
|
#11 | |
Member
Daniel
Join Date: May 2018
Posts: 43
Rep Power: 7 |
Hello everybody,
am I right that this code give you the deltas in x, y and z for every cell, I mean the dimensions of each cell or is it the distance between two cell center points? Quote:
Is there maybe a more efficient way than using a forAll loop? I guess this may be rather time consuming for large meshes? Many thanks for your help! Last edited by CFDanielGER; April 30, 2021 at 14:37. |
||
Thread Tools | Search this Thread |
Display Modes | |
|
|
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 13:17 |
How to determine the direction of cell face vectors on processor patches | sebastian_vogl | OpenFOAM Running, Solving & CFD | 0 | October 27, 2009 08:47 |
[Commercial meshers] Trimmed cell and embedded refinement mesh conversion issues | michele | OpenFOAM Meshing & Mesh Conversion | 2 | July 15, 2005 04:15 |
Warning 097- | AB | Siemens | 6 | November 15, 2004 04:41 |
cell to cell relation | CMB | Siemens | 1 | December 4, 2003 04:05 |