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.LoadHandler
— TypeLoadHandler(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
FerriteAssembly.Neumann
— TypeNeumann(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 abstractfv_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 offieldname
and the output off
.QuadratureRule
matching the interpolation forfieldname
for facets infacetset
FacetValues
are deduced from the output off
FacetValues
matching the interpolation forfieldname
for the facets infacetset
and output off
facetset
describes which facets the BC is applied to
FerriteAssembly.BodyLoad
— TypeBodyLoad(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 actcv_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 offieldname
and the output off
.QuadratureRule
matching the interpolation forfieldname
for cells incellset
.CellValues
are deduced from the output off
CellValues
matching the interpolation forfieldname
for the cells incellset
and output off
cellset
describes which cells the load is applied to. If not given, the load is applied to all cells
FerriteAssembly.DofLoad
— TypeDofLoad(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
.