Assembly
Ferrite.start_assemble — Function
start_assemble(K::AbstractSparseMatrixCSC{Tv}; fillzero = true, atomic = false) -> CSCAssembler{Tv}
start_assemble(K::AbstractSparseMatrixCSC{Tv}, f::Vector{Tv}; fillzero = true, atomic = false) -> CSCAssembler{Tv}Create a CSCAssembler{Tv} from the matrix K and optional vector f with value type Tv.
start_assemble(K::Symmetric{AbstractSparseMatrixCSC{Tv}}; fillzero = true, atomic = false) -> SymmetricCSCAssembler{Tv}start_assemble(K::Symmetric{AbstractSparseMatrixCSC{Tv}}, f::Vector = Tv[]; fillzero = true, atomic = false) -> SymmetricCSCAssembler{Tv}Create a SymmetricCSCAssembler{Tv} from the matrix K and optional vector f with value type Tv.
CSCAssembler and SymmetricCSCAssembler allocate workspace necessary for efficient matrix assembly. To assemble the contribution from an element, use assemble!.
The keyword argument fillzero can be set to false if K and f should not be zeroed out, but instead keep their current values.
The keyword argument atomic can be set to true to make the accumulation into K and f use atomic additions. This makes it safe to assemble from multiple concurrent tasks without partitioning the cells into independent sets ("grid coloring"), at the cost of some overhead and a non-deterministic result: the order in which contributions are added to a given entry depends on the task scheduling, and floating point addition is not associative. Atomic accumulation is only supported for value types Float32 and Float64 (other value types throw an ArgumentError). Note that each task still needs its own assembler since the assembler contains buffers that are modified during assemble!. Note also that the value of atomic determines a type parameter of the returned assembler, so for a type stable setup the value should be a literal (or otherwise a compile time constant). See the howto on multithreaded assembly for more details.
Depending on the loaded extensions more assembly formats become available through this interface.
Ferrite.assemble! — Function
assemble!(a::COOAssembler, dofs, Ke)
assemble!(a::COOAssembler, dofs, Ke, fe)Assembles the element matrix Ke and element vector fe into a.
assemble!(a::COOAssembler, rowdofs, coldofs, Ke)Assembles the matrix Ke into a according to the dofs specified by rowdofs and coldofs.
assemble!(g, dofs, ge)Assembles the element residual ge into the global residual vector g.
assemble!(A::Ferrite.AbstractAssembler, dofs::AbstractVector{Int}, Ke::AbstractMatrix)
assemble!(A::Ferrite.AbstractAssembler, dofs::AbstractVector{Int}, Ke::AbstractMatrix, fe::AbstractVector)Assemble the square element stiffness matrix Ke (and optional force vector fe) into the global stiffness (and force) in A, given the element degrees of freedom dofs.
This is equivalent to K[dofs, dofs] += Ke and f[dofs] += fe, where K is the global stiffness matrix and f the global force/residual vector, but more efficient.
assemble!(A::Ferrite.AbstractAssembler, rowdofs::AbstractVector{Int}, coldofs::AbstractVector{Int}, Ke::AbstractMatrix)assemble!(A::Ferrite.AbstractAssembler, rowdofs::AbstractVector{Int}, coldofs::AbstractVector{Int}, Ke::AbstractMatrix, fe::AbstractVector)Assemble the element stiffness matrix Ke (and optional force vector fe) into the global stiffness (and force) in A, given the element row degrees of freedom, rowdofs, and element column degrees of freedom, coldofs. This is equivalent to K[rowdofs, coldofs] += Ke and f[rowdofs] += fe, but more efficient.
Ferrite.finish_assemble — Function
finish_assemble(a::COOAssembler) -> K, fFinalize the assembly and return the sparse matrix K::SparseMatrixCSC and vector f::Vector. If the assembler has not been used for vector assembly, f is an empty vector.