-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make CellArrays mutable #110
Comments
first of all, to be sure that we are on the same page, note that
using CellArrays, StaticArrays
function main_CellArrays()
nel = 2
celldims = (3, 3)
Cell = SMatrix{celldims..., Float64, prod(celldims)}
C = CPUCellArray{Cell}(undef, nel)
C.data .= 0.0
# The aims is to change te values of each 3x3 matrix
# 1 - with a double loop for each element: it works
for e=1:nel
for i=1:celldims[1]
for j=1:celldims[2]
field(C,i,j)[e] = 1.0
end
end
end
@show C
# 2 - assigning cell by cell
for e=1:nel
C[e] = Cell(ones(celldims))
end
@show C
# 3 - assiging all data at once
C.data .= 9.0
@show C
end
main_CellArrays() Check out the documentation of CellArrays for more information.
I think i think it should work to create an alternative indexing on top of the indexing created by @CellType. If you can work something out that is robust and performance, then we would be happy for a pull request in CellArrays.jl for this additional functionality on top of the existing functionality. |
Thanks, I understand much better how I find too often I try to reinvent the wheel. When in doubt, someone smarter in Julia than I has thought of these things. For my purposes, storing the state vector of my system of equations in a |
@TakeTwiceDailey: |
@omlins Oh, I see. I would certainly like to run on a GPU at some point, but I have many problems to surmount before what I want to do is working on the CPU. If I were to run this on the GPU, we would not only need to make |
I found the documentation on the
@CellType
macro to be quite interesting and potentially useful for me.For example, if I am trying to solve a system of tensor equations, then having this ability to store the elements of a symmetric tensor on the grid like the given example
@CellType SymmetricTensor2D fieldnames=(xx, zz, xz)
would be useful.But I found that (as far as I can tell from the docs and my testing) there is no way to make the cell type mutable, which is necessary when the tensor makes up the state vector of my system of equations, and thus must be modified at each time step. Since this ultimately comes from StaticArrays.jl, there are mutable types available in there, so this functionality could be added.
Also, it would be nice to have the
CellType
act as the tensor it is meant to represent, while still only storing the needed values. For example, defining@CellType SymmetricTensor2D fieldnames=(xx, zz, xz)
I could then overloadgetindex
I don't know if this is the best way to go about this, although it does work. It might be nice to be able to define an index mapping in
@CellType
so that general tensors can index however they are needed to.The text was updated successfully, but these errors were encountered: