State variables

The state variable for a given cell is determined by the material type, via overloading the create_cell_state function. To update old states to the new states, use update_states!.

The state variable datastructure

The state variables are created when calling setup_domainbuffer or setup_domainbuffers, and stored inside the buffers. The states for a given domain are accessed with get_state and get_old_state, where the state for a particular cell is indexed by its cell number. (The output from the mentioned functions are Dict{Int})

API

FerriteAssembly.create_cell_stateFunction
create_cell_state(material, cellvalues, x, ae, dofrange)

Defaults to returning nothing.

Overload this function to create the state which should be passed into the element_routine!/element_residual! for the given material and cellvalues. x is the cell's coordinates, ae the element degree of freedom values, and dofrange::NamedTuple containing the local dof range for each field. As for the element routines, ae, is filled with NaN unless the global degree of freedom vector is given to the setup_domainbuffer function.

source
FerriteAssembly.create_cell_state(m::MMB.AbstractMaterial, cv::AbstractCellValues, args...)

Create a Vector{<:MMM.AbstractMaterialState} where each element is the output from MMB.initial_material_state(m) and the length is the number of quadrature points in cv.

source
FerriteAssembly.update_states!Function
update_states!(db::Dict{String,AbstractDomainBuffer})
update_states!(db::AbstractDomainBuffer)

Update the states such that old_states = states for the states stored in db.

This method tries to avoid allocating new values where possible. Currently, if create_cell_state returns T or Vector{T} where isbitstype(T), this works. If needed/wanted, it should be relatively easy to provide an interface to make it possible to have allocation free for custom cell states.

source
FerriteAssembly.remove_dualFunction
remove_dual(x::T) where {T <: Number}
remove_dual(x::AbstractTensor{<:Any, <:Any, T}) where {T}

Removes the dual part if T <: ForwardDiff.Dual, extract the value part. Typically used when assigning state variables during differentiation calls.

source