Setup

Setup API

FerriteAssembly.DomainSpecType
DomainSpec(sdh::SubDofHandler, material, fe_values; set=_getcellset(sdh), colors_or_chunks=nothing, user_data=nothing)
DomainSpec(dh::DofHandler, material, fe_values; set=1:getncells(dh), colors=nothing, chunks=nothing, user_data=nothing)

Create a DomainSpec that can be used to set up a domain buffer.

  • sdh/dh: Give the DofHandler for the domain in question, or a SubDofHandler in case there are more than one in DofHandler (See Ferrite.jl's documentation)
  • material: Used for dispatch on the utilized worker's function.
  • fe_values: CellValues or FacetValues depending on the type of domain.
  • set: The items in the domain, the element type determines the type of domain
    • Cell domain: Int
    • Facet domain: FacetIndex
  • colors::Vector{Vector{I}}: used to avoid race conditions when multithreading. For cell domains, I=Int, and for facet domains, I can be either Int (denoting cell numbers) or FacetIndex for actual facets. If I=Int, it will be converted to FacetIndex internally. If colors=nothing and chunks=nothing, Ferrite.jl's default coloring algorithm is used.
  • chunks::Vector{Vector{Vector{I}}}. During multithreading, each task works with items in one chunk::Vector{I} at a time. Items in chunks[k][i] and chunks[k][j] should be independent (i.e. not share dofs). If given, this input takes precedence over colors. For chunks, I must be Int for cell domains and FacetIndex for facet domains.
  • user_data: Can be whatever the user wants to and is passed along by reference everywhere. It is accessible from the ItemBuffer (e.g. CellBuffer) given to the worker's function via the get_user_data function. However, since it is passed by reference, modifying values during work, care must be taken to ensure thread safety. To avoid allocations, caches can be created separately with allocate_cell_cache and allocate_facet_cache.
source
FerriteAssembly.setup_domainbufferFunction
setup_domainbuffer(domain::DomainSpec; a=nothing, threading=false, autodiffbuffer=false)

Setup a domain buffer for a single grid domain, domain.

  • a::Vector: The global degree of freedom values are used to pass the local element dof values to the create_cell_state function, making it possible to create the initial state dependent on the initial conditions for the field variables.
  • threading: Should a ThreadedDomainBuffer be created to work the grid multithreaded if supported by the used worker?
  • autodiffbuffer: Should a custom itembuffer be used to speed up the automatic differentiation (if supported by the itembuffer)
source
FerriteAssembly.setup_domainbuffersFunction
setup_domainbuffers(domains::Dict{String,DomainSpec}, suppress_warnings = false; kwargs...)

Setup multiple domain buffers, one for each DomainSpec in domains. Set suppress_warnings = true to suppress warnings checking for typical input errors when setting up multiple domains. See setup_domainbuffer for description of the keyword arguments.

source

AbstractDomainBuffer

The domain buffer be a DomainBuffer, ThreadedDomainBuffer, or a Dict{String} with eltype of one of the former. The following functions are defined for these buffers:

FerriteAssembly.get_materialMethod
get_material(dbs::Dict{String,AbstractDomainBuffer}, domain::String)
get_material(db::AbstractDomainBuffer)
get_material(sim::Simulation)

Get the material for the domain represented by db or dbs[domain].

source
FerriteAssembly.get_dofhandlerMethod
get_dofhandler(dbs::Dict{String,AbstractDomainBuffer})
get_dofhandler(db::AbstractDomainBuffer)
get_dofhandler(sim::Simulation)

Get the dofhandler stored in db. Note that this is the global dofhandler, and not the SubDofHandler that is local to a specific domain.

source
FerriteAssembly.get_stateMethod
get_state(dbs::Dict{String,AbstractDomainBuffer}, domain::String)
get_state(db::Union{AbstractDomainBuffer,Dict{String,AbstractDomainBuffer}})
get_state(sim::Simulation[, domain::String])

Get the states::Dict{Int,S}, where S type of the state for each entity in the domain, stored in the db or dbs[domain]. If no domain is given for multiple domains, a Dict{String} is returned with state variables for each domain

source
FerriteAssembly.get_old_stateMethod
get_old_state(dbs::Dict{String,AbstractDomainBuffer}, domain::String)
get_old_state(db::Union{AbstractDomainBuffer,Dict{String,AbstractDomainBuffer}})
get_old_state(sim::Simulation[, domain::String])

Get the states::Dict{Int,S}, where S type of the state for each entity in the domain, stored in the db or dbs[domain]. If no domain is given for multiple domains, a Dict{String} is returned with state variables for each domain

source
FerriteAssembly.getsetFunction
getset(dbs::Dict{String,AbstractDomainBuffer}, domain::String)
getset(db::AbstractDomainBuffer)
getset(sim::Simulation[, domain::String])

Get the set of items stored in db or dbs[domain]

source
FerriteAssembly.update_states!Method
update_states!(db::Dict{String,AbstractDomainBuffer})
update_states!(db::AbstractDomainBuffer)
update_states!(sim::Simulation)

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.set_time_increment!Method
set_time_increment!(db::Dict{String,AbstractDomainBuffer}, Δt)
set_time_increment!(db::AbstractDomainBuffer, Δt)
set_time_increment!(sim::Simulation, Δt)

Update the time increment stored in db, which is passed on to the stored AbstractItemBuffer

source

Coupled simulations

The Simulation type contains an abstract domain buffer, along with (optionally) the global degree of freedom values, which are used to get the local values for each item. The main purpose is to conveniently collect these when passing into work!, especially in the case of CoupledSimulations.

The idea behind the coupled simulation setup is to give access to values from a different simulation at the item level. For example, when solving two separate problems in parallel, and using staggered iterations. See the Phase-field fracture tutorial for an example.

FerriteAssembly.SimulationType
Simulation(db, a = nothing, aold = nothing)

A Simulation is a collection of the simulation domain(s) db, and the global degree of freedom vectors, a and aold.

Note: If a or aold are not provided, the local vectors will have NaN values.

source
FerriteAssembly.couple_buffersFunction
couple_buffers(dbs::Dict{String, <:AbstractDomainBuffer}; kwargs::Dict{String, <:AbstractDomainBuffer}...)
couple_buffers(db::AbstractDomainBuffer; kwargs::AbstractDomainBuffer...)

Return new buffer(s) that are coupled with the buffers provided as keyword arguments. The key is used in get_coupled_buffer to get the coupled itembuffer, such that its values may be queried.

Note

This functionality assumes that each setup has the same grid, and in case of multiple domains, these should also match.

source
FerriteAssembly.CoupledSimulationsType
CoupledSimulations(; key1 = sim1::Simulation, key2 = sim2::Simulation, ...)

Setup the collection of coupled simulations to allow values (such as state variables and local dof-values from these simulations to be available when work!ing another simulation, if the buffers have been coupled with couple_buffers. The coupled itembuffer on the local level is accessed with get_coupled_buffer.

source