PtrList with shape of mesh or something similar
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<double>" (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 |
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<Matrix> pointerList (nCells) Code:
inline Foam::label Foam::Kmesh::index |
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 :D ? 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) greetings maybee |
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. |
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] Code:
matrix[index(1,4,2,nn)] |
All times are GMT -4. The time now is 10:09. |