# PtrList with shape of mesh or something similar

 Register Blogs Members List Search Today's Posts Mark Forums Read

 April 9, 2014, 15:54 PtrList with shape of mesh or something similar #1 Senior Member   Join Date: Jan 2012 Posts: 159 Rep Power: 6 hi, in one of the equations I am implementing is a really complex source term where one equation part returns 4 values for each cell of the mesh that are currently stored in an object of type "Mat" (Matrix class of library armadillo) :/. Is it possible to create a PtrList with the shape of mesh where each pointer points to a matrix or something similar? The main reason is, that I need to multiplicate these matrices with another part of the equation for each cell and if I want to use matrix operations it would be best if I could keep the matrices in a kind of PtrList or List with the shape of mesh. greetings maybee

 April 10, 2014, 01:13 #2 Member   Christian Butcher Join Date: Jul 2013 Location: Japan Posts: 85 Rep Power: 5 Not quite sure what you mean here, but I'm guessing you have a matrix for each cell in your mesh, and you want to be able to easily find each matrix? My (third or fourth) thought on this is that you might be able to use a Code: ```PtrList pointerList (nCells) forAll(pointerList, i) { pointerList[i] = MatrixList[i] // Not sure if you can // get a list of your matrices very easily - perhaps not or else this // would be fairly trivial? // If you create the matrices by formula which depends on your value // of i, you could use pointerList.append(matrixI) instead, and probably // construct the PtrList as null? }``` and write a function with something like the code used in Kmesh for referencing, where nn is the size of the dimensions, eg 3(2 4 5) for a 2x4x5 matrix. Code: ```inline Foam::label Foam::Kmesh::index ( const label i, const label j, const label k, const labelList& nn ) { return (k + j*nn[2] + i*nn[1]*nn[2]); }``` Taken a step further, you could probably define an operator overload for the [] operator? Not sure, but seems doable in principle?

 April 10, 2014, 06:36 #3 Senior Member   Join Date: Jan 2012 Posts: 159 Rep Power: 6 hi, thx for the help. 1.I also thought about doing something like your first code, but there is one specific reason I asked this question. Will it be sufficient to create a PtrList with the size of the mesh cells? I thought it would also be necessary to pass some kind of "global cell structure" (shape of the mesh) to the list (?). How is the structure of the mesh preserved within fields like volScalarField, surfaceScalarField, i.e. how does OpenFOAM know which value of the field (in my case PtrList) will belong to which cell? -> Therefore I was not sure if it will be sufficient just to create the PtrList with the cell number. To me it generally would be nice to know how OpenFOAM handles its field, especially how it assigns the values to the right cells/surfaces. 2. What exactly do you mean by your second code ? If I have stored the matrices in a PtrList where each matrice is "stored in the right cell" I can already access them like Code: ```forAll (PtrListMatrices, celli) { ... }``` -> mission accomplished . greetings maybee

 April 10, 2014, 20:35 #4 Member   Christian Butcher Join Date: Jul 2013 Location: Japan Posts: 85 Rep Power: 5 I wouldn't swear to it, but I'm pretty sure that the fields have no knowledge of the shape of the mesh by themselves. The mesh class (whichever you're using, eg fvMesh) holds the positions of cells, along with their connectivity (connected-ness? I know that isn't a word, but seems like connectivity might describe a different concept?). The owners and neighbours of faces, at least This allows the calculation of fluxes, I suppose? The fields are as far as I know, just lists of vectors, values, etc. maybee likes this.

 April 10, 2014, 20:37 #5 Member   Christian Butcher Join Date: Jul 2013 Location: Japan Posts: 85 Rep Power: 5 Oh, and as for the 2nd piece of code, I thought you were wanting to access the members by coordinate, like Code: `matrix[1, 4, 2]` or something - the second piece of code would allow Code: `matrix[index(1,4,2,nn)]` or similar, whereas an overloading of the []operator might allow you to directly use the first example, matrix[x,y,z].

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Anorky ANSYS Meshing & Geometry 4 November 12, 2014 01:27 Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 06:20 eddyy19g ANSYS Meshing & Geometry 3 February 13, 2014 10:36 Ganesh FLUENT 13 January 22, 2014 05:11 froztbear ANSYS Meshing & Geometry 1 November 10, 2011 09:52

All times are GMT -4. The time now is 16:53.