|
[Sponsors] |
PtrList with shape of mesh or something similar |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 9, 2014, 15:54 |
PtrList with shape of mesh or something similar
|
#1 |
Senior Member
Join Date: Jan 2012
Posts: 166
Rep Power: 14 |
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 |
|
April 10, 2014, 01:13 |
|
#2 |
Member
Christian Butcher
Join Date: Jul 2013
Location: Japan
Posts: 85
Rep Power: 12 |
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) 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? } 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]); } |
|
April 10, 2014, 06:36 |
|
#3 |
Senior Member
Join Date: Jan 2012
Posts: 166
Rep Power: 14 |
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) { ... } greetings maybee |
|
April 10, 2014, 20:35 |
|
#4 |
Member
Christian Butcher
Join Date: Jul 2013
Location: Japan
Posts: 85
Rep Power: 12 |
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. |
|
April 10, 2014, 20:37 |
|
#5 |
Member
Christian Butcher
Join Date: Jul 2013
Location: Japan
Posts: 85
Rep Power: 12 |
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)] |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
how to set periodic boundary conditions | Ganesh | FLUENT | 15 | November 18, 2020 06:09 |
[ICEM] Hexa mesh, curve mesh setup, bunching law | Anorky | ANSYS Meshing & Geometry | 4 | November 12, 2014 00:27 |
Moving mesh | Niklas Wikstrom (Wikstrom) | OpenFOAM Running, Solving & CFD | 122 | June 15, 2014 06:20 |
[ICEM] Orthogonality/Skew issues in 3D unstructured mesh | eddyy19g | ANSYS Meshing & Geometry | 3 | February 13, 2014 09:36 |
[ICEM] Problem making structural mesh on a surface | froztbear | ANSYS Meshing & Geometry | 1 | November 10, 2011 08:52 |