
[Sponsors] 
November 8, 2013, 02:32 
get values of a scalar in a matrix

#1 
Member
Join Date: Aug 2011
Posts: 81
Rep Power: 6 
At the moment I am facing the following problem:
Iīve got a cut plane from my 3d grid. At this plane I have liquid at the bottom (alpha = 1) and gas above (alpha = 0). What I want to have is the value of alpha in every cell in a matrix and the matrix has the form of the cut plane. For example, my cut plane is a square. At the bottom Iīve got two rows of cells which are filled with liquid and three rows with gas above it. Iīve got 5 columns. The array looks like this: 0 0 0 0 0 Gas 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 Liquid 1 1 1 1 1 Is it possible to get those matrix of a cut plane calculated with OpenFOAM? I only get a list of coordinates (x,y,z) and alpha after it with sample. Can anybody help? Or has an idea how to get to this point? Thanks a lot 

November 11, 2013, 13:33 

#2 
New Member
Adam
Join Date: Mar 2012
Location: St. Paul, MN
Posts: 12
Rep Power: 5 
Is this for postprocessing? I had to get the "matrix" look a few months ago the only way that worked for me was to manipulate the data from the list of coordinates using Matlab. First I exported the data, using either a slice in paraView or the alpha1 value and cell centers (using the writeCellCentres utility) from the time directory. Then arrange the x values in ascending order, ensuring that all other columns follow the same arrangement. Then arrange y values in ascending order. Determine the # of x values, and that will be the # of columns in your matrix. Build a matrix that creates a new row each time you reach the final # of x values. Each row corresponds with a y value. Assign your alpha1 values to the matrix. It's a work around, but if you want to do this for many time steps it's easy to import them all and run them through this program since they all have the same format.


November 23, 2013, 06:41 

#3 
Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,964
Blog Entries: 34
Rep Power: 92 
Greetings to all!
What comes to mind is the following procedure:
Bruno
__________________
Last edited by wyldckat; December 30, 2013 at 08:51. Reason: see "edit:" 

November 28, 2013, 03:43 

#4 
Member
Christian Butcher
Join Date: Jul 2013
Location: Japan
Posts: 84
Rep Power: 4 
Is it possible to use this idea to generate a much smaller data set recording the position of just the interface? (if this is already what this thread describes, apologies for misunderstanding)
What I mean is to output a file which lists for example, the coordinate positions of all the cells whose value of alpha1 lies between 0.01 and 0.99 or something. My guess is that this would be much more quickly rendered in paraview/visit/other postprocessing software than the whole dataset, coloured by alpha1, and the only loss would be some pretty colour for the regions with alpha1 =0 or =1. 

November 29, 2013, 15:53 

#5 
Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,964
Blog Entries: 34
Rep Power: 92 
Greetings Christian,
AFAIK, there are at least two ways to extract the surface interface between 2 fluids, as defined in the field "alpha":
Best regards, Bruno
__________________


December 17, 2013, 05:09 

#6 
Member
Join Date: Aug 2011
Posts: 81
Rep Power: 6 
Hello Bruno,
I tried to follow your description, but I have some problems. As far as I understand you I need to create a list of points so that sample can extract the values at these points. (step 6) This list is created with writeCellCentre and topoSet. But I donīt get it. When I did writeCellCentre (step 1), I have in every timefolder the files ccx, ccy and ccz. Do they have to "communicate" with topoSet (step 2)? But what is sample doing then there? (step 3) Could you explain me the steps a bit in detail? Thanks a lot idefix 

December 30, 2013, 09:27 

#7  
Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,964
Blog Entries: 34
Rep Power: 92 
Hi idefix,
Sorry about that. I didn't mange to get it a test myself, so I didn't confirm if sample could handle "cellSet"s. I've edited the other post and added the following information: Quote:
Now that I think about it, sample could use the feature to export data from a "cellSet", "faceSet" and/or "pointSet". I'll see what I can do in the next few days. Nonetheless, in the meantime, you can rely on using this command, as explained in post #8 on that other thread: Code:
foamToVTK cellSet c0 latestTime poly As for what topoSet does, you can see and example here: irregular model simulation with chtMultiregionFoam post #22. Best regards, Bruno
__________________


January 3, 2014, 06:20 

#8 
Member
Join Date: Aug 2011
Posts: 81
Rep Power: 6 
Hello Bruno,
thatīs very interesting to know but I have many time steps for which I want to do this postprocessing. So I start to program a little tool which is based on your ideas: The main thing is the following (at the moment I am only interesting in the coordinates and alpha1): Code:
forAll(timeDirs, timeI) { // timeI > 0 is necessary to ignore the constant folder if (timeI > 0) { Info << "time: " << timeDirs[timeI].name() << endl; volScalarField alpha1 ( IOobject ( "alpha1", timeDirs[timeI].name(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ), mesh ); forAll(alpha1, cellI) { // only the celll centres in this box are considered if ((mesh.cellCentres()[cellI][0] > xMin) && (mesh.cellCentres()[cellI][0] < xMax) && (mesh.cellCentres()[cellI][1] > yMin) && (mesh.cellCentres()[cellI][1] < yMax) && (mesh.cellCentres()[cellI][2] > zMin) && (mesh.cellCentres()[cellI][2] < zMax) ) { // x,y,zvalues und alpha1 are saved in the vector data data[zeileDaten][0] = mesh.cellCentres()[cellI][0]; data[zeileDaten][1] = mesh.cellCentres()[cellI][1]; data[zeileDaten][2] = mesh.cellCentres()[cellI][2]; data[zeileDaten][3] = alpha1[cellI]; } } } } Thanks again for your help. Idefix 

Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
problems concerning mass conservativity in bubbleFoam with custom scalar transport  cutter  OpenFOAM Programming & Development  3  February 10, 2015 05:25 
Ensight  node values cell values  leo  FLUENT  1  May 12, 2010 08:47 
strange node values @ solid/fluid interface  help  JB  FLUENT  2  November 1, 2008 13:04 
solving passive scalar by user function in AVLFIRE  huyp  Main CFD Forum  0  September 4, 2008 10:21 
STARCD userdefined scalar  Murali  CDadapco  0  February 12, 2003 23:52 