CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Accessing a quantity for representative cell

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By fumiya

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 1, 2015, 12:44
Default Accessing a quantity for representative cell
  #1
Senior Member
 
Mehdi Asghari
Join Date: Feb 2010
Posts: 127
Rep Power: 16
Asghari_M is on a distinguished road
Dear Foamers;

In my problem, I have a few zones and cell zones.
I need to select a cell located on center of a zone after problem solution.
How can I access that cell ?
Then, for example I want to access some values (quantities) such as temperature for that cell. How can I do these operations;
Thx in advance for any answer and help.

M.Asghari
Asghari_M is offline   Reply With Quote

Old   May 2, 2015, 15:06
Default
  #2
Senior Member
 
Mehdi Asghari
Join Date: Feb 2010
Posts: 127
Rep Power: 16
Asghari_M is on a distinguished road
Dear OF users,
For example, in Chtmultiregionfoam, I'd like to write T(nx/2, ny/2) for heater Zone in a .dat text file (nx, ny are x and y mesh numbers for heater zone,respectively ).
Can anybody help me ?
Asghari_M is offline   Reply With Quote

Old   May 8, 2015, 12:53
Default
  #3
Senior Member
 
fumiya's Avatar
 
Fumiya Nozaki
Join Date: Jun 2010
Location: Yokohama, Japan
Posts: 266
Blog Entries: 1
Rep Power: 19
fumiya is on a distinguished road
You can get the label list of cells in the particular cellZone.
I hope my slide(p.7) will be of help:
http://www.slideshare.net/fumiyanoza...ogramming-tips
__________________
[Personal]
fumiya is offline   Reply With Quote

Old   May 9, 2015, 05:32
Default
  #4
Senior Member
 
Mehdi Asghari
Join Date: Feb 2010
Posts: 127
Rep Power: 16
Asghari_M is on a distinguished road
Hi Fumiya.
I don't have any username ,pass for slideshare.net.
Can you send your slide my email address, please?
My address is: badzohreh.h57@gmail.com
Best Regards;
Asghari_M is offline   Reply With Quote

Old   May 9, 2015, 10:20
Default
  #5
Senior Member
 
fumiya's Avatar
 
Fumiya Nozaki
Join Date: Jun 2010
Location: Yokohama, Japan
Posts: 266
Blog Entries: 1
Rep Power: 19
fumiya is on a distinguished road
Hi,

This is an example:

Code:
label cellZoneID = mesh.cellZones().findZoneID("your_cellZone_name");
const labelList& cellLabels = mesh.cellZones()[cellZoneID];

// Loop over the cells that are in the specified cellZone and output temperature
forAll(cellLabels, i)
{
    label cellI = cellLabels[i];       // label of a cell that is in your cellZone
    Info<< mesh.C()[cellI] << " " << T[cellI] << endl; // Write cell center coordinate and temperature
}
I hope this will be of some help.
Fumiya
BlnPhoenix likes this.
__________________
[Personal]

Last edited by fumiya; May 9, 2015 at 19:22.
fumiya is offline   Reply With Quote

Old   May 9, 2015, 14:50
Default
  #6
Senior Member
 
Mehdi Asghari
Join Date: Feb 2010
Posts: 127
Rep Power: 16
Asghari_M is on a distinguished road
Dear Fumiya;
Thanks for your suggested code.
However, I don't know how to use ur suggested code.
1-Where should I use it in?
2-Really, I have geometrical coordinate of a point in a specified zone and I want to access its cell number and then I want to obtain temperature of that cell Id (lable),
What's the relation between your suggested sub-code and my purpose?
3-What 's the meaning of Info command and its supplements in following your suggested sub-code?
Code:
    Info<< mesh.C()[cellI] << " " << T[cellI] << endl; // T: your variable name
}
Thanks in advance for your help.
Asghari_M is offline   Reply With Quote

Old   May 9, 2015, 19:52
Default
  #7
Senior Member
 
fumiya's Avatar
 
Fumiya Nozaki
Join Date: Jun 2010
Location: Yokohama, Japan
Posts: 266
Blog Entries: 1
Rep Power: 19
fumiya is on a distinguished road
Hi,
My code in #5 outputs temperature in each cell that is in your cellZone.

1. What is your solver?
2. If you know the geometrical coordinate of a point in a specified zone,
you can use findCell(const point & location) command to find the cell containing the point.

Code:
vector probePoint(x,y,z);
label probeCell = mesh.findCell(probePoint);
You can access the temperature at the cell center by T[probeCell].

3. Info command output to the terminal. If you want to output to your text file,
you can use OFstream. You might want to consult the following thread:
http://www.cfd-online.com/Forums/ope...scii-file.html

Hope this helps,
Fumiya
__________________
[Personal]
fumiya is offline   Reply With Quote

Old   May 10, 2015, 05:07
Default
  #8
Senior Member
 
Mehdi Asghari
Join Date: Feb 2010
Posts: 127
Rep Power: 16
Asghari_M is on a distinguished road
Dear Fumiya;
Thanks for ur kindly helps.
My solver is OpenFoam 2.3.1.
I am not familiar with these commands & symbols and where they are written.
Code:
vector probePoint(x,y,z); label probeCell = mesh.findCell(probePoint);

How can I download OFstream? Is it a part of OF2.3.1?
I'm reading ur suggested thread. It seems to be interesting & helpful.

Best Regards.

M.Asghari
Asghari_M is offline   Reply With Quote

Reply

Tags
cell selecting, centeroid cells, find value


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Other] refineWallLayer Error Yuby OpenFOAM Meshing & Mesh Conversion 2 November 11, 2021 12:04
FvMatrix coefficients shrina OpenFOAM Running, Solving & CFD 10 October 3, 2013 15:38
Accessing Cell Properties arkangel OpenFOAM 0 March 29, 2010 13:00
Dynamic Mesh.. Layering.. cell addition kedarj14 OpenFOAM Programming & Development 0 January 29, 2010 02:48
Accessing Neighbouring Cell info Murali Siemens 1 December 9, 2002 07:10


All times are GMT -4. The time now is 20:33.