External loading

In many simulations, there is a need to add contributions to the weak form in the form of external loads, either as source terms/body loads, or as non-zero Neumann boundary conditions. FerriteAssembly provides a LoadHandler for this purpose, such that it is not necessary to implement those terms into the specific elements directly. This avoid having to pass information to the elements about changes to the load levels etc.

FerriteAssembly.LoadHandlerType
LoadHandler(dh::AbstractDofHandler)

Create a load handler for external loads to be applied on the finite element simulation defined by a dofhandler dh. It can be used to apply the Neumann, BodyLoad, and DofLoad contributions to the external "force"-vector, fext:

fext = zeros(ndofs(dh))
lh=LoadHandler(dh)
add!(lh, Neumann(...))  # Add Neumann boundary conditions
add!(lh, BodyLoad(...)) # Add body load
add!(lh, DofLoad(...))  # Add load to specific degrees of freedom
for t in timesteps
    fill!(fext, 0)
    apply!(fext, lh, t) # Add contributions to `fext`
    ...
end
source
FerriteAssembly.NeumannType
Neumann(field_name::Symbol, fv_info::Union{FacetValues,QuadratureRule,Int}, facetset::AbstractSet{FacetIndex}, f)

Define a Neumann contribution with the weak forms according to

\[\int_{\Gamma} f \ \delta u \ \mathrm{d}\Gamma, \quad \text{Scalar fields} \\ \int_{\Gamma} \boldsymbol{f} \cdot \boldsymbol{\delta u} \ \mathrm{d}\Gamma, \quad \text{Vector fields} \]

where $\Gamma$ is the boundary where the contribution is active. $f$, or $\boldsymbol{f}$, is the prescribed Neumann value, defined by a function with signatures

f(x::Vec, t::Real, n::Vec) -> Number (Scalar field)

f(x::Vec, t::Real, n::Vec) -> Vec{dim} (Vector field)

where x is the spatial position of the current quadrature point, t is the current time, and n is the facet normal vector. The remaining input arguments are

  • fieldname describes the field on which the boundary condition should abstract
  • fv_info gives required input to determine the facetvalues. The following input types are accepted:
    • Int giving the integration order to use. FacetValues are deduced from the interpolation of fieldname and the output of f.
    • QuadratureRule matching the interpolation for fieldname for facets in facetset FacetValues are deduced from the output of f
    • FacetValues matching the interpolation for fieldname for the facets in facetset and output of f
  • facetset describes which facets the BC is applied to
source
FerriteAssembly.BodyLoadType
BodyLoad(field_name::Symbol, cv_info::Union{CellValues,QuadratureRule,Int}, cellset::Set{Int}, f)
BodyLoad(field_name::Symbol, cv_info::Union{CellValues,QuadratureRule,Int}, f)

Define a body load contribution with the weak forms according to

\[\int_{\Omega} f \ \delta u \ \mathrm{d}\Omega, \quad \text{Scalar fields} \\ \int_{\Omega} \boldsymbol{f} \cdot \boldsymbol{\delta u} \ \mathrm{d}\Omega, \quad \text{Vector fields} \]

where $\Omega$ is the region where the contribution is active. $f$, or $\boldsymbol{f}$, is the prescribed volumetric contribution (e.g. force/volume), defined by a function with signatures

f(x::Vec, t::Real) -> Number (Scalar field)

f(x::Vec, t::Real) -> Vec{dim} (Vector field)

where x is the spatial position of the current quadrature point and t is the current time. The remaining input arguments are

  • fieldname describes the field on which the load should act

  • cv_info gives required input to determine the cellvalues. The following input types are accepted:

    • Int giving the integration order to use. CellValues are deduced from the interpolation of fieldname and the output of f.
    • QuadratureRule matching the interpolation for fieldname for cells in cellset. CellValues are deduced from the output of f
    • CellValues matching the interpolation for fieldname for the cells in cellset and output of f
  • cellset describes which cells the load is applied to. If not given, the load is applied to all cells

source
FerriteAssembly.DofLoadType
DofLoad(dofs::Union{Int, Vector{Int}}, load_function::Function)

Adds load_function(t) to f[d] for each degree of freedom number d in dofs. Here, t is the simulation time passed to the LoadHandler.

source