licenses
sequencelengths 1
3
| version
stringclasses 677
values | tree_hash
stringlengths 40
40
| path
stringclasses 1
value | type
stringclasses 2
values | size
stringlengths 2
8
| text
stringlengths 25
67.1M
| package_name
stringlengths 2
41
| repo
stringlengths 33
86
|
---|---|---|---|---|---|---|---|---|
[
"MIT"
] | 1.3.2 | 20ceb97a9f5eab5b460f7683ee70f48db43bd69c | docs | 6487 | # [Stochastic Processes] (@id StochasticProcesses)
`KadanoffBaym.jl` can also be used to simulate _stochastic processes_. Below, we will give the simplest example to illustrate how to do this. In cases where [other methods](https://diffeq.sciml.ai/stable/tutorials/sde_example/) are too expensive or inapplicable, this approach can be an economic and insightful alternative.
!!! tip
More background on the connection between `KadanoffBaym.jl` and stochastic processes can be found in section 4.2 of [our paper](https://doi.org/10.21468/SciPostPhysCore.5.2.030) and also [here](https://doi.org/10.1088/1751-8121/ac73c6).
## [Ornstein-Uhlenbeck Process] (@id OUProcess)
The Ornstein-Uhlenbeck (OU) process\cite{VanKampen2007, gardiner1985handbook} is defined by the stochastic differential equation (SDE)
```math
\begin{align*}
\mathrm{d} x(t) = -\theta x(t)\mathrm{d} t + \sqrt{D}\mathrm{d} W(t)
\end{align*}
```
where ``W(t)``, ``t >0`` is a one-dimensional Brownian motion and ``\theta > 0``. The Onsager-Machlup path integral
```math
\begin{align*}
\int\mathcal{D}x\exp{\left\{-\frac{1}{2D}\int\mathrm{d}t\, \left(\partial_t{x}(t) +\theta x(t)\right)^2\right\}}
\end{align*}
```
is a possible starting point to derive the corresponding MSR action via a Hubbard-Stratonovich transformation. The classical MSR action
```math
\begin{align*}
S[x, \hat{x}] = \int\mathrm{d}t\,\left[ \mathrm{i}\hat{x}(t)(\partial_t{x}(t) + \theta x(t)) + D \hat{x}^2(t)/2 \right]
\end{align*}
```
is then equivalent to it. Note also that we are employing It\^o regularisation for simplicity. It is also common to define a purely imaginary response field ``\tilde{\hat{x}} = \mathrm{i}\hat{x}``, which is then integrated along the imaginary axis. The retarded Green function ``G^R`` and the statistical propagator ``F`` are then commonly defined as
```math
\begin{align*}
G^R(t, t') &= \langle{x(t)\hat{x}(t')}\rangle, \\
F(t, t') &= \langle{x(t)x(t')}\rangle - \langle{x(t)}\rangle \langle{x(t')}\rangle.
\end{align*}
```
The equations of motion of the response Green functions are
```math
\begin{align*}
\delta(t - t') &= -\mathrm{i}\partial_t G^A(t, t') + \mathrm{i}\theta G^A(t, t'), \\
\delta(t - t') &= \phantom{-}\mathrm{i}\partial_t G^R(t, t') + \mathrm{i}\theta G^R(t, t'),
\end{align*}
```
admitting the solutions
```math
\begin{align*}
G^A(t, t') = G^A(t - t') = -\mathrm{i}\Theta(t' - t)\mathrm{e}^{-\theta{(t' - t)}}, \\
G^R(t, t') = G^R(t - t') = -\mathrm{i}\Theta(t - t')\mathrm{e}^{-\theta{(t - t')}}.
\end{align*}
```
The equations of motion of the statistical propagator in "vertical" time ``t`` and "horizontal" time ``t'`` read
```math
\begin{align*}
\partial_t F(t, t') & = -\theta F(t, t') + \mathrm{i} DG^A(t, t'), \\
\partial_{t'} F(t, t') & = -\theta F(t, t') + \mathrm{i} DG^R(t, t'),
\end{align*}
```
respectively, while in Wigner coordinates ``T = (t+t')/2``, ``\tau = t - t'``, we find
```math
\begin{align*}
\partial_{T} F(T, \tau)_W & = -2\theta F(T, \tau)_W + \mathrm{i} D\left( G^A(T, \tau)_W + G^R(T, \tau)_W \right), \\
\partial_{\tau} F(T, \tau)_W & = \frac{\mathrm{i} D}{2} \left( G^A(T, \tau)_W - G^R(T, \tau)_W \right).
\end{align*}
```
To cover the two-time mesh completely, one could in principle use any two of the four equations for ``F``. Our convention is to pick the equation in "vertical" time ``t`` with ``t>t'`` and the equation in "diagonal" time ``T`` with ``\tau=0``, such that together with the symmetries relations of the classical Green functiosn, the problem is fully determined by the initial conditions and these two equations:
```math
\begin{align*}
\partial_t F(t, t') & = -\theta F(t, t') + \mathrm{i} DG^A(t, t'), \\
\partial_{T} F(T, 0)_W & = -2\theta F(T, 0)_W + D,
\end{align*}
```
where we have used the response identity ``G^A(T, 0)_W + G^R(T, 0)_W = -\mathrm{i}``, and ``G^A(t, t') = 0`` when ``t > t'``. For comparison, the analytical solution for the variance or statistical propagator reads
```math
\begin{align*}
\mathcal{F}(t, t') &= \mathcal{F}(0, 0)\mathrm{e}^{-\theta(t + t')} - \frac{D}{2\theta} \left( \mathrm{e}^{-\theta(t + t')} - \mathrm{e}^{-\theta |t - t'|} \right)\\
&= \left( \mathcal{F}(0, 0) - \frac{D}{2\theta} \right)\mathrm{e}^{-\theta(t + t')} + \frac{\mathrm{i} D}{2\theta}\left( G^A(t, t') + G^R(t, t') \right).
\end{align*}
```
To apply `KadanoffBaym.jl`, we begin by defining parameters and initial conditions:
```julia
# Final time
tmax = 4.0
# Drift
θ = 1.
# Diffusion strength (in units of θ)
D = 8.0
# Initial condition
N₀ = 1.0
F = GreenFunction(N₀ * ones(1, 1), Symmetrical)
```
!!! note
Observe how we have used the symmetry `Symmetrical` to define the _classical_ type of [`GreenFunction`](@ref).
Now the equation in "vertical" time ``t`` is simply
```julia
# Right-hand side for the "vertical" evolution
function fv!(out, _, _, _, t1, t2)
out[1] = -θ * F[t1, t2]
end
```
!!! warning
In this numerical version of the analytical equation above, we have made explicit use of the fact that ``G^A(t, t') = 0`` when ``t > t'``. However, since `KadanoffBaym.jl` uses a so-called _multi-step predictor-corrector method_ to solve equations (i.e. a method using not a single point but _multiple_ points from the past to predict the next point), it can happen that points with ``t' > t`` are actually accessed, in which case the ``G^A(t, t')`` term in the above equation _does_ contribute. One way to prevent this would be to restrict the solver to using a one-step method early on, i.e. until enough points with ``t > t'`` are known.
In "diagonal" time ``T`` we have
```julia
# Right-hand side for the "diagonal" evolution
function fd!(out, _, _, _, t1, t2)
out[1] = -θ * 2F[t1, t2] + D
end
```
To learn about the signatures `(out, _, _, _, t1, t2)` of `fv!` and `fd!`, consult the documentation of [`kbsolve!`](@ref). All we need to do now is
```julia
# Call the solver
sol = kbsolve!(fv!, fd!, [F], (0.0, tmax); atol=1e-8, rtol=1e-6)
```
The numerical results obtained with `KadanoffBaym.jl` are shown in [our paper](https://doi.org/10.21468/SciPostPhysCore.5.2.030) and are in agreement with the analytical solutions.
!!! hint
A [Jupyter notebook](https://github.com/NonequilibriumDynamics/KadanoffBaym.jl/blob/master/examples/brownian-motion.ipynb) for this example is available in our [examples folder](https://github.com/NonequilibriumDynamics/KadanoffBaym.jl/tree/master/examples). | KadanoffBaym | https://github.com/NonequilibriumDynamics/KadanoffBaym.jl.git |
|
[
"MIT"
] | 1.3.2 | 20ceb97a9f5eab5b460f7683ee70f48db43bd69c | docs | 4355 | # [Tight-Binding Model] (@id TightBinding)
To get a feeling for how to use `KadanoffBaym.jl`, we begin by solving a simple example, the so-called tight-binding model:
```math
\begin{align*}
\hat{H} &= \sum_{i=1}^L \varepsilon_i \hat{c}_i^{\dagger} \hat{c}_i^{\phantom{\dagger}} + J \sum_{\langle i, j\rangle}\left(\hat{c}_i^{\dagger} \hat{c}_j^{\phantom{\dagger}} + \hat{c}_j^{\dagger} \hat{c}_i^{\phantom{\dagger}}\right),
\end{align*}
```
where the ``\hat{c}_i^{\dagger},\, \hat{c}_i^{\phantom{\dagger}}`` are fermionic creation and annihilation operators. The model describes a bunch of electrons on a lattice that can hop to neighbouring sites via the coupling ``J``. The usual quantities of interest can be obtained from the so-called *lesser* and *greater* Green functions defined by
```math
\begin{align*}
\left[\boldsymbol{G}^<(t, t')\right]_{ij} &= G^<_{ij}(t, t') = \phantom{-} i\left\langle{\hat{c}_j^{{\dagger}}(t')\hat{c}_i^{\phantom{\dagger}}(t)}\right\rangle, \\
\left[\boldsymbol{G}^>(t, t')\right]_{ij} &= G^>_{ij}(t, t') = -i\left\langle{\hat{c}_i^{\phantom{\dagger}}(t)\hat{c}_j^{{\dagger}}(t')}\right\rangle.
\end{align*}
```
The equations of motion for these Green functions in "vertical" and "diagonal" time have a simple form and can be written compactly as
```math
\begin{align*}
\partial_t \boldsymbol{G}^{\lessgtr}(t, t') &= -i\boldsymbol{H} \boldsymbol{G}^{\lessgtr}(t, t') \\
\partial_T \boldsymbol{G}^{\lessgtr}(T, 0)_W &= -i[\boldsymbol{H},\boldsymbol{G}^{\lessgtr}(T, 0)_W],
\end{align*}
```
where the square brackets denote the commutator, and the Hamiltonian matrix is given by
```math
\begin{align*}
\boldsymbol{H} &=
\begin{pmatrix}
\varepsilon_1 & J & & \\
J & \ddots & \ddots & \\
& \ddots & \ddots & J \\
& & J & \varepsilon_L
\end{pmatrix}.
\end{align*}
```
Remember also that in Wigner coordinates, the "forward" time is defined by ``T = \frac{t+t'}{2}`` and ``\partial_T = \partial_t + \partial_{t'}``.
First, we import `KadanoffBaym.jl` alongside Julia's linear-algebra package:
```julia
using KadanoffBaym, LinearAlgebra
```
Then, we use the built-in data structure [`GreenFunction`](@ref) to define our lesser and greater Green functions
```julia
# Lattice size
L = 10
# Allocate the initial lesser and greater Green functions (time arguments at the end)
GL = GreenFunction(zeros(ComplexF64, L, L, 1, 1), SkewHermitian)
GG = GreenFunction(zeros(ComplexF64, L, L, 1, 1), SkewHermitian)
```
As our initial condition, we put a single electron on lattice site one:
```julia
# Initial occupation
N_0 = 1.0
GL[1, 1] = zeros(ComplexF64, L, L)
GL[1, 1, 1, 1] = 1.0im
# Greater function follows from lesser by anti-commutation
GG[1, 1] = -im * I(L) + GL[1, 1]
```
Note how accessing [`GreenFunction`](@ref) with only *two* arguments gives the whole matrix at a given time, i.e. `GL[1, 1]` is equivalent to `GL[:, :, 1, 1]`.
For illustration, we use a Hamiltonian matrix ``\boldsymbol{H}`` with unit hopping ``J=1`` defined as
```julia
# Spacing of energy levels
ε = 5e-2
# Hamiltonian with on-site energies and nearest-neighbour hopping
H = SymTridiagonal([ε * (i-1) for i in 1:L], -ones(L))
```
We define the equation of motion in the "vertical" time ``t`` as
```julia
# Right-hand side for the "vertical" evolution
function fv!(out, times, h1, h2, t1, t2)
out[1] = -im * H * GL[t1, t2]
out[2] = -im * H * GG[t1, t2]
end
```
Finally, the the equation of motion in the "diagonal" time ``T`` follows by subtracting its own adjoint from the vertical equation:
```julia
# Right-hand side for the "diagonal" evolution
function fd!(out, times, h1, h2, t1, t2)
fv!(out, times, h1, h2, t1, t2)
out[1] -= adjoint(out[1])
out[2] -= adjoint(out[2])
end
```
Note that the unused arguments `times, h1, h2` are indeed only necessary when solving *interacting* systems (i.e. systems with integrals in their equations of motion). All that remains to be done is give our definitions to [`kbsolve!`](@ref):
```julia
# Call the solver
@time sol = kbsolve!(fv!, fd!, [GL, GG], (0.0, 20.0); atol=1e-8, rtol=1e-6)
```
When we `plot(sol.t, mapreduce(permutedims, vcat, [imag(diag(GL[t, t])) for t in eachindex(sol.t)]))`, we obtain

| KadanoffBaym | https://github.com/NonequilibriumDynamics/KadanoffBaym.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 498 | using Documenter, FinEtools, FinEtoolsDeforLinear
makedocs(
modules = [FinEtoolsDeforLinear],
doctest = false, clean = true,
warnonly = Documenter.except(:linkcheck, :footnote),
format = Documenter.HTML(prettyurls = false),
authors = "Petr Krysl",
sitename = "FinEtoolsDeforLinear.jl",
pages = Any[
"Home" => "index.md",
"How to guide" => "guide/guide.md",
"Reference" => Any[
"man/man.md"]
]
)
deploydocs(
repo = "github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git",
)
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 290 | using Pkg; Pkg.activate("."); Pkg.instantiate();
include(raw"C:\Users\pkonl\Documents\00WIP\FinEtoolsDeforLinear.jl\examples\statics\3-d\solver_examples.jl")
using .Main.solver_examples; Main.solver_examples.example_wop(30)
using .Main.solver_examples; Main.solver_examples.example_wop(30) | FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 6955 | module TEST13H_examples
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!, matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using LinearAlgebra
using Arpack
using PGFPlotsX
function TEST13H_hva()
# Harmonic forced vibration problem is solved for a homogeneous square plate,
# simply-supported on the circumference.
# This is the TEST 13H from the Abaqus v 6.12 Benchmarks manual.
# The test is recommended by the National Agency for Finite Element Methods and Standards (U.K.):
# Test 13 from NAFEMS “Selected Benchmarks for Forced Vibration,” R0016, March 1993.
#
#
# The plate is discretized with hexahedral solid elements. The simple support
# condition is approximated by distributed rollers on the boundary.
# Because only the out of plane displacements are prevented, the structure
# has three rigid body modes in the plane of the plate.
#
#
# The nonzero benchmark frequencies are (in hertz): 2.377, 5.961, 5.961,
# 9.483, 12.133, 12.133, 15.468, 15.468 [Hz].
println("""
Homogeneous square plate, simply-supported on the circumference from
the test 13 from NAFEMS “Selected Benchmarks for Forced Vibration,” R0016, March 1993.
The nonzero benchmark frequencies are (in hertz): 2.377, 5.961, 5.961,
9.483, 12.133, 12.133, 15.468, 15.468 [Hz].
""")
# t0 = time()
E = 200 * phun("GPa")# Young's modulus
nu = 0.3# Poisson ratio
rho = 8000 * phun("KG*M^-3")# mass density
qmagn = 100.0 * phun("Pa")
L = 10.0 * phun("M") # side of the square plate
t = 0.05 * phun("M") # thickness of the square plate
nL = 16
nt = 4
tolerance = t / nt / 100
# neigvs = 11;
# OmegaShift = (2*pi*0.5) ^ 2; # to resolve rigid body modes
frequencies = vcat(linearspace(0.0, 2.377, 20), linearspace(2.377, 15.0, 70))
# Compute the parameters of Rayleigh damping. For the two selected
# frequencies we have the relationship between the damping ratio and
# the Rayleigh parameters
# $\xi_m=a_0/\omega_m+a_1\omega_m$
# where $m=1,2$. Solving for the Rayleigh parameters $a_0,a_1$ yields:
zeta1 = 0.02
zeta2 = 0.02
o1 = 2 * pi * 2.377
o2 = 2 * pi * 15.468
Rayleigh_mass = 2 * (o1 * o2) / (o2^2 - o1^2) * (o2 * zeta1 - o1 * zeta2)# a0
Rayleigh_stiffness = 2 * (o1 * o2) / (o2^2 - o1^2) * (-1 / o2 * zeta1 + 1 / o1 * zeta2)# a1
Rayleigh_mass = Rayleigh_mass
Rayleigh_stiffness = Rayleigh_stiffness
MR = DeforModelRed3D
fens, fes = H8block(L, L, t, nL, nL, nt)
geom = NodalField(fens.xyz)
u = NodalField(zeros(Complex{Float64}, size(fens.xyz, 1), 3)) # displacement field
nl = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
setebc!(u, nl, true, 3)
nl = selectnode(fens, box = [L L -Inf Inf -Inf Inf], inflate = tolerance)
setebc!(u, nl, true, 3)
nl = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
setebc!(u, nl, true, 3)
nl = selectnode(fens, box = [-Inf Inf L L -Inf Inf], inflate = tolerance)
setebc!(u, nl, true, 3)
applyebc!(u)
numberdofs!(u)
println("nfreedofs = $(nfreedofs(u))")
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 3)), material)
M = mass(femm, geom, u)
C = Rayleigh_mass * M + Rayleigh_stiffness * K
K_ff = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[:ff]
M_ff = matrix_blocked(M, nfreedofs(u), nfreedofs(u))[:ff]
C_ff = matrix_blocked(C, nfreedofs(u), nfreedofs(u))[:ff]
# if true
# t0 = time()
# d,v,nev,nconv = eigs(K+OmegaShift*M, M; nev=neigvs, which=:SM)
# d = d - OmegaShift;
# fs = real(sqrt.(complex(d)))/(2*pi)
# println("Reference Eigenvalues: $fs [Hz]")
# println("eigs solution ($(time() - t0) sec)")
# end
bdryfes = meshboundary(fes)
topbfl = selectelem(fens, bdryfes, facing = true, direction = [0.0 0.0 1.0])
el1femm = FEMMBase(IntegDomain(subset(bdryfes, topbfl), GaussRule(2, 2)))
function pfun(forceout::Vector{T}, XYZ, tangents, feid, qpid) where {T}
forceout .= [0.0, 0.0, -qmagn]
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F = distribloads(el1femm, geom, u, fi, 2)
F_f = vector_blocked(F, nfreedofs(u))[:f]
U_f = zeros(Complex{Flowat64}, nfreedofs(u), length(frequencies))
for k in eachindex(frequencies)
frequency = frequencies[k]
omega = 2 * pi * frequency
U_f[:, k] = (-omega^2 * M_ff + 1im * omega * C_ff + K_ff) \ F_f
end
midpoint = selectnode(fens, box = [L / 2 L / 2 L / 2 L / 2 0 0], inflate = tolerance)
midpointdof = u.dofnums[midpoint, 3]
umidAmpl = abs.(U_f[midpointdof, :]) / phun("MM")
@pgf _a = SemiLogXAxis(
{
xlabel = "Frequency [Hz]",
ylabel = "Midpoint displacement amplitude [mm]",
grid = "major",
legend_pos = "south east",
title = "Thin plate midpoint Amplitude FRF",
},
Plot(
{"red", mark = "triangle"},
Table([:x => vec(frequencies), :y => vec(umidAmpl)]),
),
LegendEntry("FEA"),
)
display(_a)
umidReal = real.(U_f[midpointdof, :]) / phun("MM")
umidImag = imag.(U_f[midpointdof, :]) / phun("MM")
@pgf _a = SemiLogXAxis(
{
xlabel = "Frequency [Hz]",
ylabel = "Displacement amplitude [mm]",
grid = "major",
legend_pos = "south east",
title = "Thin plate midpoint Real/Imag FRF",
},
Plot(
{"red", mark = "triangle"},
Table([:x => vec(frequencies), :y => vec(umidReal)]),
),
LegendEntry("real"),
Plot(
{"blue", mark = "circle"},
Table([:x => vec(frequencies), :y => vec(umidImag)]),
),
LegendEntry("imag"),
)
display(_a)
umidPhase = atan.(umidImag, umidReal) / pi * 180
@pgf _a = SemiLogXAxis(
{
xlabel = "Frequency [Hz]",
ylabel = "Phase shift [deg]",
grid = "major",
legend_pos = "south east",
title = "Thin plate midpoint Real/Imag FRF",
},
Plot(
{"red", mark = "triangle"},
Table([:x => vec(frequencies), :y => vec(umidPhase)]),
),
LegendEntry("imag"),
)
display(_a)
true
end # TEST13H_hva
function allrun()
println("#####################################################")
println("# TEST13H_hva ")
TEST13H_hva()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 7087 | module TEST13H_in_fluid_examples
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule: ssit
using LinearAlgebra
using Arpack
using PGFPlotsX
function TEST13H_hva()
# Harmonic forced vibration problem is solved for a homogeneous square plate,
# simply-supported on the circumference.
# This is the TEST 13H from the Abaqus v 6.12 Benchmarks manual.
# The test is recommended by the National Agency for Finite Element Methods and Standards (U.K.):
# Test 13 from NAFEMS “Selected Benchmarks for Forced Vibration,” R0016, March 1993.
#
#
# The plate is discretized with hexahedral solid elements. The simple support
# condition is approximated by distributed rollers on the boundary.
# Because only the out of plane displacements are prevented, the structure
# has three rigid body modes in the plane of the plate.
#
#
# The nonzero benchmark frequencies are (in hertz): 2.377, 5.961, 5.961,
# 9.483, 12.133, 12.133, 15.468, 15.468 [Hz].
println(""" Homogeneous square plate, simply-supported on the circumference,
from the test 13 from NAFEMS “Selected Benchmarks for Forced Vibration,”
R0016, March 1993. The nonzero benchmark frequencies are (in hertz): 2.377,
5.961, 5.961, 9.483, 12.133, 12.133, 15.468, 15.468 [Hz].
This problem is extended by including fluid-induced damping by the
surrounding air using a matrix expressing the ABC with dampers along the
boundary.
""")
# t0 = time()
E = 200 * phun("GPa")# Young's modulus
nu = 0.3# Poisson ratio
rho = 8000 * phun("KG*M^-3")# mass density
qmagn = 100.0 * phun("Pa")
L = 10.0 * phun("M") # side of the square plate
t = 0.05 * phun("M") # thickness of the square plate
nL = 16
nt = 4
tolerance = t / nt / 100
# neigvs = 11;
# OmegaShift = (2*pi*0.5) ^ 2; # to resolve rigid body modes
frequencies = vcat(linearspace(0.0, 2.377, 20), linearspace(2.377, 15.0, 70))
rho_fluid = 1.3 * phun("kg*m^3")
c_fluid = 341 * phun("m/s")
# Compute the parameters of Rayleigh damping. For the two selected
# frequencies we have the relationship between the damping ratio and
# the Rayleigh parameters
# $\xi_m=a_0/\omega_m+a_1\omega_m$
# where $m=1,2$. Solving for the Rayleigh parameters $a_0,a_1$ yields:
zeta1 = 0.02
zeta2 = 0.02
o1 = 2 * pi * 2.377
o2 = 2 * pi * 15.468
Rayleigh_mass = 2 * (o1 * o2) / (o2^2 - o1^2) * (o2 * zeta1 - o1 * zeta2)# a0
Rayleigh_stiffness = 2 * (o1 * o2) / (o2^2 - o1^2) * (-1 / o2 * zeta1 + 1 / o1 * zeta2)# a1
MR = DeforModelRed3D
fens, fes = H8block(L, L, t, nL, nL, nt)
geom = NodalField(fens.xyz)
u = NodalField(zeros(FCplxFlt, size(fens.xyz, 1), 3)) # displacement field
nl = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
setebc!(u, nl, true, 3)
nl = selectnode(fens, box = [L L -Inf Inf -Inf Inf], inflate = tolerance)
setebc!(u, nl, true, 3)
nl = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
setebc!(u, nl, true, 3)
nl = selectnode(fens, box = [-Inf Inf L L -Inf Inf], inflate = tolerance)
setebc!(u, nl, true, 3)
applyebc!(u)
numberdofs!(u)
println("nfreedofs = $(u.nfreedofs)")
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 3)), material)
M = mass(femm, geom, u)
C = Rayleigh_mass * M + Rayleigh_stiffness * K
bfes = meshboundary(fes)
sfemm = FEMMDeforSurfaceDamping(IntegDomain(bfes, GaussRule(2, 3)))
impedance = rho_fluid * c_fluid
D = dampingABC(sfemm, geom, u, impedance, SurfaceNormal(3))
# if true
# t0 = time()
# d,v,nev,nconv = eigs(K+OmegaShift*M, M; nev=neigvs, which=:SM)
# d = d - OmegaShift;
# fs = real(sqrt.(complex(d)))/(2*pi)
# println("Reference Eigenvalues: $fs [Hz]")
# println("eigs solution ($(time() - t0) sec)")
# end
bdryfes = meshboundary(fes)
topbfl = selectelem(fens, bdryfes, facing = true, direction = [0.0 0.0 1.0])
el1femm = FEMMBase(IntegDomain(subset(bdryfes, topbfl), GaussRule(2, 2)))
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
) where {T}
forceout .= [0.0, 0.0, -qmagn]
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F = distribloads(el1femm, geom, u, fi, 2)
U1 = zeros(FCplxFlt, u.nfreedofs, length(frequencies))
for k in eachindex(frequencies)
frequency = frequencies[k]
omega = 2 * pi * frequency
U1[:, k] = (-omega^2 * M + 1im * omega * (C + D) + K) \ F
end
midpoint = selectnode(fens, box = [L / 2 L / 2 L / 2 L / 2 0 0], inflate = tolerance)
midpointdof = u.dofnums[midpoint, 3]
umidAmpl = abs.(U1[midpointdof, :]) / phun("MM")
@pgf _a = SemiLogXAxis(
{
xlabel = "Frequency [Hz]",
ylabel = "Midpoint displacement amplitude [mm]",
grid = "major",
legend_pos = "south east",
title = "Thin plate midpoint Amplitude FRF",
},
Plot(
{"red", mark = "triangle"},
Table([:x => vec(frequencies), :y => vec(umidAmpl)]),
),
LegendEntry("FEA"),
)
display(_a)
umidReal = real.(U1[midpointdof, :]) / phun("MM")
umidImag = imag.(U1[midpointdof, :]) / phun("MM")
@pgf _a = SemiLogXAxis(
{
xlabel = "Frequency [Hz]",
ylabel = "Displacement amplitude [mm]",
grid = "major",
legend_pos = "south east",
title = "Thin plate midpoint Real/Imag FRF",
},
Plot(
{"red", mark = "triangle"},
Table([:x => vec(frequencies), :y => vec(umidReal)]),
),
LegendEntry("real"),
Plot(
{"blue", mark = "circle"},
Table([:x => vec(frequencies), :y => vec(umidImag)]),
),
LegendEntry("imag"),
)
display(_a)
umidPhase = atan.(umidImag, umidReal) / pi * 180
@pgf _a = SemiLogXAxis(
{
xlabel = "Frequency [Hz]",
ylabel = "Phase shift [deg]",
grid = "major",
legend_pos = "south east",
title = "Thin plate midpoint Real/Imag FRF",
},
Plot(
{"red", mark = "triangle"},
Table([:x => vec(frequencies), :y => vec(umidPhase)]),
),
LegendEntry("imag"),
)
display(_a)
true
end # TEST13H_hva
function allrun()
println("#####################################################")
println("# TEST13H_hva ")
TEST13H_hva()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 7008 | module TEST13H_in_water_examples
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule: ssit
using LinearAlgebra
using Arpack
using PGFPlotsX
function TEST13H_hva()
# Harmonic forced vibration problem is solved for a homogeneous square plate,
# simply-supported on the circumference.
# This is the TEST 13H from the Abaqus v 6.12 Benchmarks manual.
# The test is recommended by the National Agency for Finite Element Methods and Standards (U.K.):
# Test 13 from NAFEMS “Selected Benchmarks for Forced Vibration,” R0016, March 1993.
#
#
# The plate is discretized with hexahedral solid elements. The simple support
# condition is approximated by distributed rollers on the boundary.
# Because only the out of plane displacements are prevented, the structure
# has three rigid body modes in the plane of the plate.
#
#
# The nonzero benchmark frequencies are (in hertz): 2.377, 5.961, 5.961,
# 9.483, 12.133, 12.133, 15.468, 15.468 [Hz].
println("""
Homogeneous square plate, simply-supported on the circumference from
the test 13 from NAFEMS “Selected Benchmarks for Forced Vibration,” R0016, March 1993.
The nonzero benchmark frequencies are (in hertz): 2.377, 5.961, 5.961,
9.483, 12.133, 12.133, 15.468, 15.468 [Hz].
""")
# t0 = time()
E = 200 * phun("GPa")# Young's modulus
nu = 0.3# Poisson ratio
rho = 8000 * phun("KG*M^-3")# mass density
qmagn = 100.0 * phun("Pa")
L = 10.0 * phun("M") # side of the square plate
t = 0.05 * phun("M") # thickness of the square plate
nL = 16
nt = 4
tolerance = t / nt / 100
# neigvs = 11;
# OmegaShift = (2*pi*0.5) ^ 2; # to resolve rigid body modes
frequencies = vcat(linearspace(0.0, 2.377, 20), linearspace(2.377, 15.0, 70))
rho_water = 1000 * phun("kg*m^3")
c_water = 1500 * phun("m/s")
# Compute the parameters of Rayleigh damping. For the two selected
# frequencies we have the relationship between the damping ratio and
# the Rayleigh parameters
# $\xi_m=a_0/\omega_m+a_1\omega_m$
# where $m=1,2$. Solving for the Rayleigh parameters $a_0,a_1$ yields:
zeta1 = 0.02
zeta2 = 0.02
o1 = 2 * pi * 2.377
o2 = 2 * pi * 15.468
Rayleigh_mass = 2 * (o1 * o2) / (o2^2 - o1^2) * (o2 * zeta1 - o1 * zeta2)# a0
Rayleigh_stiffness = 2 * (o1 * o2) / (o2^2 - o1^2) * (-1 / o2 * zeta1 + 1 / o1 * zeta2)# a1
Rayleigh_mass = Rayleigh_mass
Rayleigh_stiffness = Rayleigh_stiffness
MR = DeforModelRed3D
fens, fes = H8block(L, L, t, nL, nL, nt)
geom = NodalField(fens.xyz)
u = NodalField(zeros(FCplxFlt, size(fens.xyz, 1), 3)) # displacement field
nl = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
setebc!(u, nl, true, 3)
nl = selectnode(fens, box = [L L -Inf Inf -Inf Inf], inflate = tolerance)
setebc!(u, nl, true, 3)
nl = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
setebc!(u, nl, true, 3)
nl = selectnode(fens, box = [-Inf Inf L L -Inf Inf], inflate = tolerance)
setebc!(u, nl, true, 3)
applyebc!(u)
numberdofs!(u)
println("nfreedofs = $(u.nfreedofs)")
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 3)), material)
M = mass(femm, geom, u)
C = Rayleigh_mass * M + Rayleigh_stiffness * K
bfes = meshboundary(fes)
sfemm = FEMMDeforSurfaceDamping(IntegDomain(bfes, GaussRule(2, 3)))
impedance = rho_water * c_water
D = dampingABC(sfemm, geom, u, impedance, SurfaceNormal(3))
# if true
# t0 = time()
# d,v,nev,nconv = eigs(K+OmegaShift*M, M; nev=neigvs, which=:SM)
# d = d - OmegaShift;
# fs = real(sqrt.(complex(d)))/(2*pi)
# println("Reference Eigenvalues: $fs [Hz]")
# println("eigs solution ($(time() - t0) sec)")
# end
bdryfes = meshboundary(fes)
topbfl = selectelem(fens, bdryfes, facing = true, direction = [0.0 0.0 1.0])
el1femm = FEMMBase(IntegDomain(subset(bdryfes, topbfl), GaussRule(2, 2)))
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
) where {T}
forceout .= [0.0, 0.0, -qmagn]
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F = distribloads(el1femm, geom, u, fi, 2)
U1 = zeros(FCplxFlt, u.nfreedofs, length(frequencies))
for k in eachindex(frequencies)
frequency = frequencies[k]
omega = 2 * pi * frequency
U1[:, k] = (-omega^2 * M + 1im * omega * (C + D) + K) \ F
end
midpoint = selectnode(fens, box = [L / 2 L / 2 L / 2 L / 2 0 0], inflate = tolerance)
midpointdof = u.dofnums[midpoint, 3]
umidAmpl = abs.(U1[midpointdof, :]) / phun("MM")
@pgf _a = SemiLogXAxis(
{
xlabel = "Frequency [Hz]",
ylabel = "Midpoint displacement amplitude [mm]",
grid = "major",
legend_pos = "south east",
title = "Thin plate midpoint Amplitude FRF",
},
Plot(
{"red", mark = "triangle"},
Table([:x => vec(frequencies), :y => vec(umidAmpl)]),
),
LegendEntry("FEA"),
)
display(_a)
umidReal = real.(U1[midpointdof, :]) / phun("MM")
umidImag = imag.(U1[midpointdof, :]) / phun("MM")
@pgf _a = SemiLogXAxis(
{
xlabel = "Frequency [Hz]",
ylabel = "Displacement amplitude [mm]",
grid = "major",
legend_pos = "south east",
title = "Thin plate midpoint Real/Imag FRF",
},
Plot(
{"red", mark = "triangle"},
Table([:x => vec(frequencies), :y => vec(umidReal)]),
),
LegendEntry("real"),
Plot(
{"blue", mark = "circle"},
Table([:x => vec(frequencies), :y => vec(umidImag)]),
),
LegendEntry("imag"),
)
display(_a)
umidPhase = atan.(umidImag, umidReal) / pi * 180
@pgf _a = SemiLogXAxis(
{
xlabel = "Frequency [Hz]",
ylabel = "Phase shift [deg]",
grid = "major",
legend_pos = "south east",
title = "Thin plate midpoint Real/Imag FRF",
},
Plot(
{"red", mark = "triangle"},
Table([:x => vec(frequencies), :y => vec(umidPhase)]),
),
LegendEntry("imag"),
)
display(_a)
true
end # TEST13H_hva
function allrun()
println("#####################################################")
println("# TEST13H_hva ")
TEST13H_hva()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 5424 | module NAFEMS_examples
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!, matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using LinearAlgebra
using Arpack
function NAFEMS_FV32_algo()
println("""
FV32: Cantilevered tapered membrane
This is a test recommended by the National Agency for Finite Element Methods and
Standards (U.K.): Test FV32 from NAFEMS publication TNSB, Rev. 3, “The Standard
NAFEMS Benchmarks,” October 1990.
Reference solution: 44.623 130.03 162.70 246.05 379.90 391.44 for the first
six modes.
""")
t0 = time()
E = 200 * phun("GPA")
nu = 0.3
rho = 8000 * phun("KG/M^3")
L = 10 * phun("M")
W0 = 5 * phun("M")
WL = 1 * phun("M")
nL, nW = 28, 14 # How many element edges per side?
neigvs = 10 # how many eigenvalues
Reffs = [44.623 130.03 162.70 246.05 379.90 391.44]
fens, fes = Q8block(1.0, 2.0, nL, nW)
for i = 1:count(fens)
xi, eta = fens.xyz[i, :]
eta = eta - 1.0
fens.xyz[i, :] .= (xi * L, eta * (1.0 - 0.8 * xi) * W0 / 2)
end
# File = "mesh.vtk"
# vtkexportmesh(File, fens, fes)
# @async run(`"paraview.exe" $File`)
# Make the region
MR = DeforModelRed2DStress
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
region1 = FDataDict(
"femm" => FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 2)), material),
"femm_mass" => FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 3)), material),
)
nl1 = selectnode(fens; plane = [1.0 0.0 0.0], thickness = L / 1.0e4)
ebc1 = FDataDict("node_list" => nl1, "component" => 1, "displacement" => 0.0)
ebc2 = FDataDict("node_list" => nl1, "component" => 2, "displacement" => 0.0)
# Make model data
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [ebc1 ebc2],
"neigvs" => neigvs,
)
# Solve
modeldata = AlgoDeforLinearModule.modal(modeldata)
fs = modeldata["omega"] / (2 * pi)
println("Frequencies: $(fs[1:6]) [Hz]")
println("Percentage frequency errors: $((vec(fs[1:6]) - vec(Reffs))./vec(Reffs)*100)")
modeldata["postprocessing"] = FDataDict("file" => "FV32-modes", "mode" => 1:10)
modeldata = AlgoDeforLinearModule.exportmode(modeldata)
@async run(`"paraview.exe" $(modeldata["postprocessing"]["file"]*"1.vtk")`)
true
end # NAFEMS_FV32_algo
function NAFEMS_FV32_algo_interior()
println("""
FV32: Cantilevered tapered membrane
This is a test recommended by the National Agency for Finite Element Methods and
Standards (U.K.): Test FV32 from NAFEMS publication TNSB, Rev. 3, “The Standard
NAFEMS Benchmarks,” October 1990.
Reference solution: 44.623 130.03 162.70 246.05 379.90 391.44 for the first
six modes.
""")
t0 = time()
E = 200 * phun("GPA")
nu = 0.3
rho = 8000 * phun("KG/M^3")
L = 10 * phun("M")
W0 = 5 * phun("M")
WL = 1 * phun("M")
nL, nW = 28, 14 # How many element edges per side?
neigvs = 10 # how many eigenvalues
Reffs = [44.623 130.03 162.70 246.05 379.90 391.44]
fens, fes = Q8block(1.0, 2.0, nL, nW)
for i = 1:count(fens)
xi, eta = fens.xyz[i, :]
eta = eta - 1.0
fens.xyz[i, :] .= (xi * L, eta * (1.0 - 0.8 * xi) * W0 / 2)
end
# File = "mesh.vtk"
# vtkexportmesh(File, fens, fes)
# @async run(`"paraview.exe" $File`)
# Make the region
MR = DeforModelRed2DStress
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
region1 = FDataDict(
"femm" => FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 2)), material),
"femm_mass" => FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 3)), material),
)
nl1 = selectnode(fens; plane = [1.0 0.0 0.0], thickness = L / 1.0e4)
ebc1 = FDataDict("node_list" => nl1, "component" => 1, "displacement" => 0.0)
ebc2 = FDataDict("node_list" => nl1, "component" => 2, "displacement" => 0.0)
nl2 = connectednodes(meshboundary(fes))
ebc3 = FDataDict("node_list" => nl2, "component" => 1, "displacement" => 0.0)
ebc4 = FDataDict("node_list" => nl2, "component" => 2, "displacement" => 0.0)
# Make model data
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [ebc1 ebc2 ebc3 ebc4],
"neigvs" => neigvs,
)
# Solve
modeldata = AlgoDeforLinearModule.modal(modeldata)
fs = modeldata["omega"] / (2 * pi)
println("Frequencies: $(fs[1:6]) [Hz]")
println("Percentage frequency errors: $((vec(fs[1:6]) - vec(Reffs))./vec(Reffs)*100)")
modeldata["postprocessing"] = FDataDict("file" => "FV32-modes", "mode" => 1:10)
modeldata = AlgoDeforLinearModule.exportmode(modeldata)
@async run(`"paraview.exe" $(modeldata["postprocessing"]["file"]*"1.vtk")`)
true
end # NAFEMS_FV32_algo
function allrun()
println("#####################################################")
println("# NAFEMS_FV32_algo ")
NAFEMS_FV32_algo()
println("#####################################################")
println("# NAFEMS_FV32_algo_interior ")
NAFEMS_FV32_algo_interior()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 5301 | module ESNICE_examples
using Statistics
using FinEtools
using FinEtools.MeshImportModule
using FinEtools.MeshExportModule
using FinEtoolsDeforLinear
using LinearAlgebra: dot
using Arpack
using LinearAlgebra
using SparseArrays
using PGFPlotsX
using Test
using StatsBase
function ESNICE_energies()
E = 1e6 * phun("PA")
nu = 0.0
L = 2 * phun("M")
hs = L * collect(10 .^ range(-4.0, stop = 0.0, length = 10))
mag = 0.001
rs = Float64[]
PEs = Float64[]
APEs = Float64[]
for h in hs
xs = collect(linearspace(0.0, L, 2))
ys = collect(linearspace(0.0, h, 2))
zs = collect(linearspace(0.0, h, 2))
global fens
global fes
fens, fes = T4blockx(xs, ys, zs, :a)
fens.xyz[:, 3] .-= h / 2
MR = DeforModelRed3D
global geom = NodalField(fens.xyz)
global u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
l1 = selectnode(fens; plane = [1.0 0.0 0.0 0.0], thickness = h / 1000)
for i in l1
x, y, z = geom.values[i, :]
u.values[i, 1] = z * mag
end
l1 = selectnode(fens; plane = [1.0 0.0 0.0 L], thickness = h / 1000)
for i in l1
x, y, z = geom.values[i, :]
u.values[i, 1] = -z * mag
end
@show h, u.values
material = MatDeforElastIso(MR, E, nu)
global femm = FEMMDeforLinear(MR, IntegDomain(fes, TetRule(1)), material)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
U = gathersysvec(u)
PE = dot(U, K * U) / 2.0
push!(PEs, PE)
I = h * h^3 / 12
APE = 2 * E * I * mag^2 / L
push!(APEs, APE)
# ars = []
# for i = 1:count(fes)
# res = FinEtoolsDeforLinear.FEMMDeforLinearESNICEModule.aspectratio(geom.values[collect(fes.conn[i]), :])
# ar = sort([res[1], res[2], res[3], res[4]])
# push!(ars, mean([ar[2:3]...]))
# end
# @show h/L, ars
# push!(rs, minimum(ars))
push!(rs, h / L)
end
@show rPE = PEs ./ APEs
# Least-squares fit
A = hcat([-log10(r) for r in rs], [-1 for r in rPE])
b = [log10(r - 1) for r in rPE]
p = A \ b
@show p
a = p[1]
b = 10^p[2]
@show a, b
@pgf a = Axis(
{
xlabel = "Aspect ratio",
ylabel = "Relative Potential Energy",
grid = "major",
legend_pos = "north east",
},
Plot({color = "red"}, Table([:x => log10.(vec(rs)), :y => log10.(vec(rPE))])),
Plot(
{"only marks", mark = "x"},
Table([
:x => log10.(vec(rs)),
:y => log10.(vec([1 / (b * r^a) + 1 for r in rs])),
]),
),
)
display(a)
# fld = fieldfromintegpoints(femm, geom, u, :Cauchy, 1)
# File = "mt4energy2.vtk"
# vtkexportmesh(File, fens, fes; scalars=[("sigmax", fld.values)], vectors=[("u", u.values)])
# @async run(`"paraview.exe" $File`)
true
end
function ESNICE_vibration()
E = 70000 * phun("MPa")
nu = 0.33
rho = 2700 * phun("KG/M^3")
radius = 0.5 * phun("ft")
neigvs = 20 # how many eigenvalues
OmegaShift = (10.0 * 2 * pi)^2
MR = DeforModelRed3D
output = import_ABAQUS(joinpath(@__DIR__, "alum_cyl.inp"))
fens, fes = output["fens"], output["fesets"][1]
fens.xyz .*= phun("mm") # The input is provided in SI(mm) units
fens, fes = T10toT4(fens, fes)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinearESNICET4(MR, IntegDomain(fes, NodalSimplexRule(3)), material)
associategeometry!(femm, geom)
@show minimum(vec(femm.nphis)), maximum(vec(femm.nphis))
@pgf a = Axis(
{
xlabel = "Entity",
ylabel = "Stabilization factor",
grid = "major",
legend_pos = "north east",
},
Plot({mark = "circle"}, Table([:x => vec(1:count(fes)), :y => vec(femm.ephis)])),
)
display(a)
K = stiffness(femm, geom, u)
M = mass(femm, geom, u)
d, v, nconv =
eigs(K + OmegaShift * M, M; nev = neigvs, which = :SM, explicittransform = :none)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
println("Eigenvalues: $fs [Hz]")
vectors = []
for i = 7:length(fs)
scattersysvec!(u, v[:, i])
push!(vectors, ("Mode_$i", deepcopy(u.values)))
end
File = "alum_cyl_mode_shapes.vtk"
vtkexportmesh(
File,
connasarray(fes),
fens.xyz,
FinEtools.MeshExportModule.VTK.T4;
vectors = vectors,
)
@async run(`"paraview.exe" $File`)
true
end # function
function allrun()
println("#####################################################")
println("# ESNICE_energies ")
ESNICE_energies()
println("#####################################################")
println("# ESNICE_vibration ")
ESNICE_vibration()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 2209 | module FV12_plate_examples
using Statistics
using FinEtools
using FinEtools.MeshImportModule
using FinEtools.MeshExportModule
using FinEtoolsDeforLinear
using SubSIt
using LinearAlgebra: dot
using Arpack
using LinearAlgebra
using SparseArrays
# using PGFPlotsX
using Test
E = 200e3 * phun("MPa")
nu = 0.3
rho = 8000 * phun("KG/M^3")
L = 10.00 * phun("M")
t = 0.05 * phun("M")
nL = 8
nt = 4
neigvs = 14 # how many eigenvalues
OmegaShift = (1.0 * 2 * pi)^2
# Fundamental frequency
f_analytical = [0 0 0 0 0 0 1.622 2.360 2.922 4.190 4.190 7.356 7.356 7.668]
function FV12_plate_esnice()
global a, b, h, na, nb, nh
MR = DeforModelRed3D
fens, fes = T4block(L, L, t, nL, nL, nt)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinearESNICET4(MR, IntegDomain(fes, NodalSimplexRule(3)), material)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
M = mass(femm, geom, u)
d, v, nconv = eigs(K + OmegaShift * M, M; nev = neigvs, which = :SM)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
println("Eigenvalues: $fs [Hz]")
println("f/f_analytical % = $(fs[7:10] ./ f_analytical[7:10] .* 100) %")
vectors = []
for i = 7:length(fs)
scattersysvec!(u, v[:, i])
push!(vectors, ("Mode_$i", deepcopy(u.values)))
end
File = "rectangular_plate_esnice.vtk"
vtkexportmesh(
File,
connasarray(fes),
fens.xyz,
FinEtools.MeshExportModule.VTK.T4;
vectors = vectors,
)
@async run(`"paraview.exe" $File`)
d, v, nconv = SubSIt.ssit(K + OmegaShift * M, M; nev = neigvs)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
println("Eigenvalues: $fs [Hz]")
true
end # function
function allrun()
println("#####################################################")
println("# FV12_plate_esnice ")
FV12_plate_esnice()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 6326 | module NAFEMS_examples
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!, matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using LinearAlgebra
using Arpack
function NAFEMS_FV32_algo()
println("""
FV32: Cantilevered tapered membrane
This is a test recommended by the National Agency for Finite Element Methods and
Standards (U.K.): Test FV32 from NAFEMS publication TNSB, Rev. 3, “The Standard
NAFEMS Benchmarks,” October 1990.
Reference solution: 44.623 130.03 162.70 246.05 379.90 391.44 for the first
six modes.
""")
t0 = time()
E = 200 * phun("GPA")
nu = 0.3
rho = 8000 * phun("KG/M^3")
L = 10 * phun("M")
W0 = 5 * phun("M")
WL = 1 * phun("M")
H = 0.05 * phun("M")
nL, nW, nH = 8, 4, 1# How many element edges per side?
neigvs = 20 # how many eigenvalues
Reffs = [44.623 130.03 162.70 246.05 379.90 391.44]
fens, fes = H20block(1.0, 2.0, 1.0, nL, nW, nH)
for i = 1:count(fens)
xi, eta, theta = fens.xyz[i, :]
eta = eta - 1.0
fens.xyz[i, :] = [xi * L eta * (1.0 - 0.8 * xi) * W0 / 2 theta * H / 2]
end
# File = "mesh.vtk"
# vtkexportmesh(File, fens, fes)
# @async run(`"paraview.exe" $File`)
# Make the region
MR = DeforModelRed3D
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
region1 = FDataDict(
"femm" => FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material),
"femm_mass" => FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 3)), material),
)
nl1 = selectnode(fens; plane = [1.0 0.0 0.0 0.0], thickness = H / 1.0e4)
ebc1 = FDataDict("node_list" => nl1, "component" => 1, "displacement" => 0.0)
ebc2 = FDataDict("node_list" => nl1, "component" => 2, "displacement" => 0.0)
ebc3 = FDataDict("node_list" => nl1, "component" => 3, "displacement" => 0.0)
nl4 = selectnode(fens; plane = [0.0 0.0 1.0 0.0], thickness = H / 1.0e4)
ebc4 = FDataDict("node_list" => nl4, "component" => 3, "displacement" => 0.0)
# Make model data
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [ebc1 ebc2 ebc3 ebc4],
"neigvs" => neigvs,
)
# Solve
modeldata = AlgoDeforLinearModule.modal(modeldata)
fs = modeldata["omega"] / (2 * pi)
println("Frequencies: $(fs[1:6]) [Hz]")
println("Percentage frequency errors: $((vec(fs[1:6]) - vec(Reffs))./vec(Reffs)*100)")
modeldata["postprocessing"] = FDataDict("file" => "FV32-modes", "mode" => 1:10)
modeldata = AlgoDeforLinearModule.exportmode(modeldata)
@async run(`"paraview.exe" $(modeldata["postprocessing"]["file"]*"1.vtk")`)
true
end # NAFEMS_FV32_algo
function NAFEMS_TEST13H_vib()
# Harmonic forced vibration problem is solved for a homogeneous square plate,
# simply-supported on the circumference.
# This is the TEST 13H from the Abaqus v 6.12 Benchmarks manual.
# The test is recommended by the National Agency for Finite Element Methods and Standards (U.K.):
# Test 13 from NAFEMS “Selected Benchmarks for Forced Vibration,” R0016, March 1993.
#
#
# The plate is discretized with hexahedral solid elements. The simple support
# condition is approximated by distributed rollers on the boundary.
# Because only the out of plane displacements are prevented, the structure
# has three rigid body modes in the plane of the plate.
#
#
# The nonzero benchmark frequencies are (in hertz): 2.377, 5.961, 5.961,
# 9.483, 12.133, 12.133, 15.468, 15.468 [Hz].
println("""
Homogeneous square plate, simply-supported on the circumference from
the test 13 from NAFEMS “Selected Benchmarks for Forced Vibration,” R0016, March 1993.
The nonzero benchmark frequencies are (in hertz): 2.377, 5.961, 5.961,
9.483, 12.133, 12.133, 15.468, 15.468 [Hz].
""")
# t0 = time()
E = 200 * phun("GPa")# Young's modulus
nu = 0.3# Poisson ratio
rho = 8000 * phun("KG*M^-3")# mass density
L = 10.0 * phun("M") # side of the square plate
t = 0.05 * phun("M") # thickness of the square plate
nL = 8
nt = 4
tolerance = t / nt / 100
neigvs = 11
OmegaShift = (2 * pi * 0.5)^2 # to resolve rigid body modes
MR = DeforModelRed3D
fens, fes = H8block(L, L, t, nL, nL, nt)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
nl = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
setebc!(u, nl, true, 3)
nl = selectnode(fens, box = [L L -Inf Inf -Inf Inf], inflate = tolerance)
setebc!(u, nl, true, 3)
nl = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
setebc!(u, nl, true, 3)
nl = selectnode(fens, box = [-Inf Inf L L -Inf Inf], inflate = tolerance)
setebc!(u, nl, true, 3)
applyebc!(u)
numberdofs!(u)
println("nfreedofs = $(nfreedofs(u))")
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 3)), material)
M = mass(femm, geom, u)
K_ff = matrix_blocked(K, nfreedofs(u))[:ff]
M_ff = matrix_blocked(M, nfreedofs(u))[:ff]
if true
t0 = time()
d, v, nev, nconv = eigs(
K_ff + OmegaShift * M_ff,
M_ff;
nev = neigvs,
which = :SM,
explicittransform = :none,
)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
println("Reference frequencies: $fs [Hz]")
println("eigs solution ($(time() - t0) sec)")
end
true
end # NAFEMS_TEST13H_vib
function allrun()
println("#####################################################")
println("# NAFEMS_FV32_algo ")
NAFEMS_FV32_algo()
println("#####################################################")
println("# NAFEMS_TEST13H_vib ")
NAFEMS_TEST13H_vib()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 17739 | module alum_cyl_mode_examples
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!, matrix_blocked, vector_blocked
using FinEtools.MeshExportModule
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.FEMMDeforLinearESNICEModule
using LinearAlgebra
using Arpack
E = 70000 * phun("MPa")
nu = 0.33
rho = 2700 * phun("KG/M^3")
R = 0.5 * phun("ft")
L = 2.0 * phun("ft")
neigvs = 200 # how many eigenvalues
OmegaShift = (2 * pi * 2500.0)^2
nR, nL = 10 * [1, 4]
# Mesh alum_cyl.inp
# Abaqus with the Standard isoparametric C3D4 tetrahedron:
C3D4 = [
1 0
2 0
3 6.63586E-005
4 0.000171053
5 0.000211299
6 0.000244378
7 2564.63
8 2568.09
9 2597.26
10 4094.38
11 4714.36
12 4717.19
13 5181.98
14 6865.13
15 6868.17
16 6962.86
17 6965.67
18 7024.97
19 7029.44
20 7108.54
]
# Abaqus with the standard quadratic tetrahedron:
C3D10 = [
1 0
2 0
3 0
4 0.000139365
5 0.000221551
6 0.000291805
7 2546.81
8 2546.81
9 2560.69
10 4100
11 4693.55
12 4693.56
13 5121.57
14 6841.21
15 6841.24
16 6914.22
17 6914.23
18 6950.64
19 6950.66
20 7000.64
]
function __fullcylinder(R, L, nR = 5, nL = 20, tet10 = false)
nR = Int(round(nR))
nL = Int(round(nL))
fens, fes = T4quartercyln(R, L, nR, nL)
renumb = (c) -> c[[1, 3, 2, 4]]
if tet10
renumb = (c) -> c[[1, 3, 2, 4, 7, 6, 5, 8, 10, 9]]
fens, fes = T4toT10(fens, fes)
end
bfes = meshboundary(fes)
el = selectelem(fens, bfes, facing = true, direction = [1.0, 1.0, 0.0])
cbfes = subset(bfes, el)
for i = 1:count(cbfes)
for k in cbfes.conn[i]
fens.xyz[k, 1:2] = fens.xyz[k, 1:2] * R / norm(fens.xyz[k, 1:2])
end
end
fens1, fes1 = mirrormesh(fens, fes, [0.0, -1.0, 0.0], [0.0, 0.0, 0.0], renumb = renumb)
meshes = Array{Tuple{FENodeSet,AbstractFESet},1}()
push!(meshes, (fens, fes))
push!(meshes, (fens1, fes1))
fens, fesa = mergenmeshes(meshes, 0.0001)
fes = cat(fesa[1], fesa[2])
fens1, fes1 = mirrormesh(fens, fes, [-1.0, 0.0, 0.0], [0.0, 0.0, 0.0], renumb = renumb)
meshes = Array{Tuple{FENodeSet,AbstractFESet},1}()
push!(meshes, (fens, fes))
push!(meshes, (fens1, fes1))
fens, fesa = mergenmeshes(meshes, 0.0001)
fes = cat(fesa[1], fesa[2])
return fens, fes
end
function alum_cyl_modal_t4()
tet10 = false
nip = 1
fens, fes = __fullcylinder(R, L, nR, nL, tet10)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3))
numberdofs!(u)
MR = DeforModelRed3D
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinear(MR, IntegDomain(fes, TetRule(nip)), material)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
M = mass(femm, geom, u)
K_ff = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[:ff]
M_ff = matrix_blocked(M, nfreedofs(u), nfreedofs(u))[:ff]
d, v, nev, nconv = eigs(
Symmetric(K_ff + OmegaShift * M_ff),
Symmetric(M_ff);
nev = neigvs,
which = :SM,
explicittransform = :none,
)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
println("alum_cyl_modal_t4")
println("Eigenvalues: $fs [Hz]")
mode = neigvs
scattersysvec!(u, v[:, mode])
File = "alum_cyl_modal_t4-$mode.vtk"
vtkexportmesh(File, fens, fes; vectors = [("mode$mode", u.values)])
# @async run(`"paraview.exe" $File`)
true
end # alum_cyl_modes
function alum_cyl_modal_t10()
tet10 = true
nip = 4
fens, fes = __fullcylinder(R, L, nR / 2, nL / 2, tet10)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3))
numberdofs!(u)
MR = DeforModelRed3D
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinear(MR, IntegDomain(fes, TetRule(nip)), material)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
M = mass(femm, geom, u)
K_ff = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[:ff]
M_ff = matrix_blocked(M, nfreedofs(u), nfreedofs(u))[:ff]
d, v, nev, nconv = eigs(
Symmetric(K_ff + OmegaShift * M_ff),
Symmetric(M_ff);
nev = neigvs,
which = :SM,
explicittransform = :none,
)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
println("alum_cyl_modal_t10")
println("Eigenvalues: $fs [Hz]")
mode = neigvs
scattersysvec!(u, v[:, mode])
File = "alum_cyl_modal_t10-$mode.vtk"
vtkexportmesh(File, fens, fes; vectors = [("mode$mode", u.values)])
true
end # alum_cyl_modes
function alum_cyl_modal_esnicet4()
tet10 = false
nip = 1
fens, fes = __fullcylinder(R, L, nR, nL, tet10)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3))
numberdofs!(u)
MR = DeforModelRed3D
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinearESNICET4(MR, IntegDomain(fes, NodalSimplexRule(3)), material)
associategeometry!(femm, geom; stabilization_parameters = (2.0, 3.0))
K = stiffness(femm, geom, u)
M = mass(femm, geom, u)
K_ff = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[:ff]
M_ff = matrix_blocked(M, nfreedofs(u), nfreedofs(u))[:ff]
d, v, nev, nconv = eigs(
Symmetric(K_ff + OmegaShift * M_ff),
Symmetric(M_ff);
nev = neigvs,
which = :SM,
explicittransform = :none,
)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
println("alum_cyl_modal_esnicet4")
println("Eigenvalues: $fs [Hz]")
mode = neigvs
scattersysvec!(u, v[:, mode])
File = "alum_cyl_modal_esnicet4-$mode.vtk"
vtkexportmesh(File, fens, fes; vectors = [("mode$mode", u.values)])
# @async run(`"paraview.exe" $File`)
true
end # alum_cyl_modes
function alum_cyl_modal_h20()
fens, fes = H8cylindern(R, L, Int(nR / 2), Int(nL / 2))
fens, fes = H8toH20(fens, fes)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3))
numberdofs!(u)
MR = DeforModelRed3D
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
M = mass(femm, geom, u)
K_ff = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[:ff]
M_ff = matrix_blocked(M, nfreedofs(u), nfreedofs(u))[:ff]
d, v, nev, nconv = eigs(
Symmetric(K_ff + OmegaShift * M_ff),
Symmetric(M_ff);
nev = neigvs,
which = :SM,
explicittransform = :none,
)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
println("alum_cyl_modal_h20")
println("Eigenvalues: $fs [Hz]")
mode = neigvs
scattersysvec!(u, v[:, mode])
File = "alum_cyl_modal_h20-$mode.vtk"
vtkexportmesh(File, fens, fes; vectors = [("mode$mode", u.values)])
true
end # alum_cyl_modes
function alum_cyl_mode_t4()
stabfact = 0.0062
MR = DeforModelRed3D
output = import_ABAQUS(joinpath(@__DIR__, "alum_cyl.inp"))
fens, fes = output["fens"], output["fesets"][1]
fens.xyz .*= phun("mm") # The input is provided in SI(mm) units
fens, fes = T10toT4(fens, fes)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinear(MR, IntegDomain(fes, TetRule(1)), material)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
M = mass(femm, geom, u)
K_ff = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[:ff]
M_ff = matrix_blocked(M, nfreedofs(u), nfreedofs(u))[:ff]
d, v, nev, nconv = eigs(
Symmetric(K_ff + OmegaShift * M_ff),
Symmetric(M_ff);
nev = neigvs,
which = :SM,
explicittransform = :none,
)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
println("Eigenvalues: $fs [Hz]")
true
end # alum_cyl_modes
function alum_cyl_mode_nice_t4()
stabfact = 0.0062
MR = DeforModelRed3D
output = import_ABAQUS(joinpath(@__DIR__, "alum_cyl.inp"))
fens, fes = output["fens"], output["fesets"][1]
fens.xyz .*= phun("mm") # The input is provided in SI(mm) units
fens, fes = T10toT4(fens, fes)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm =
FEMMDeforLinearNICET4(MR, IntegDomain(fes, NodalSimplexRule(3)), material, stabfact)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
M = mass(femm, geom, u)
K_ff = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[:ff]
M_ff = matrix_blocked(M, nfreedofs(u), nfreedofs(u))[:ff]
d, v, nev, nconv = eigs(
Symmetric(K_ff + OmegaShift * M_ff),
Symmetric(M_ff);
nev = neigvs,
which = :SM,
explicittransform = :none,
)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
println("Eigenvalues: $fs [Hz]")
true
end # alum_cyl_modes
function alum_cyl_mode_esnice_t4()
MR = DeforModelRed3D
output = import_ABAQUS(joinpath(@__DIR__, "alum_cyl.inp"))
fens, fes = output["fens"], output["fesets"][1]
fens.xyz .*= phun("mm") # The input is provided in SI(mm) units
fens, fes = T10toT4(fens, fes)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinearESNICET4(MR, IntegDomain(fes, NodalSimplexRule(3)), material)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
M = mass(femm, geom, u)
K_ff = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[:ff]
M_ff = matrix_blocked(M, nfreedofs(u), nfreedofs(u))[:ff]
d, v, nev, nconv = eigs(
Symmetric(K_ff + OmegaShift * M_ff),
Symmetric(M_ff);
nev = neigvs,
which = :SM,
explicittransform = :none,
)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
println("Eigenvalues: $fs [Hz]")
true
end
# function alum_cyl_modes_algo()
# fens,fes =H20block(a,b,h, na,nb,nh)
# # Make the region
# MR = DeforModelRed3D
# material = MatDeforElastIso(MR, rho, E, nu, 0.0)
# region1 = FDataDict("femm"=>FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3,2)),
# material), "femm_mass"=>FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3,3)),
# material))
# # Make model data
# modeldata = FDataDict(
# "fens"=> fens, "regions"=> [region1],
# "omega_shift"=>omega_shift, "neigvs"=>neigvs)
# # Solve
# modeldata = FinEtools.AlgoDeforLinearModule.modal(modeldata)
# fs = modeldata["omega"]/(2*pi)
# println("Eigenvalues: $fs [Hz]")
# modeldata["postprocessing"] = FDataDict("file"=>"alum_cyl_mode",
# "mode"=>10)
# modeldata=FinEtools.AlgoDeforLinearModule.exportmode(modeldata)
# @async run(`"paraview.exe" $(modeldata["postprocessing"]["file"]*"1.vtk")`)
# true
# end #
# function alum_cyl_modes_export()
# println("""
# Vibration modes of unit cube of almost incompressible material.
# This example EXPORTS the model to Abaqus.
# Reference: Puso MA, Solberg J (2006) A stabilized nodally integrated
# tetrahedral. International Journal for Numerical Methods in
# Engineering 67: 841-867.
# """)
# t0 = time()
# E = 1*phun("PA");
# nu = 0.499;
# rho = 1*phun("KG/M^3");
# a = 1*phun("M"); b = a; h = a;
# n1 = 5;# How many element edges per side?
# na = n1; nb = n1; nh = n1;
# neigvs = 20 # how many eigenvalues
# OmegaShift = (0.01*2*pi)^2;
# MR = DeforModelRed3D
# fens,fes = H20block(a,b,h, na,nb,nh)
# geom = NodalField(fens.xyz)
# u = NodalField(zeros(size(fens.xyz,1),3)) # displacement field
# numberdofs!(u)
# material=MatDeforElastIso(MR, rho, E, nu, 0.0)
# femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3,2)), material)
# K =stiffness(femm, geom, u)
# femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3,3)), material)
# M =mass(femm, geom, u)
# d,v,nev,nconv = eigs(Symmetric(K+OmegaShift*M), Symmetric(M); nev=neigvs, which=:SM, explicittransform=:none)
# d = d - OmegaShift;
# fs = real(sqrt.(complex(d)))/(2*pi)
# println("Eigenvalues: $fs [Hz]")
# mode = 7
# scattersysvec!(u, v[:,mode])
# File = "alum_cyl_modes.vtk"
# vtkexportmesh(File, fens, fes; vectors=[("mode$mode", u.values)])
# @async run(`"paraview.exe" $File`)
# AE = AbaqusExporter("alum_cyl_modes_h20");
# # AE.ios = STDOUT;
# HEADING(AE, "Vibration modes of unit cube of almost incompressible material.");
# COMMENT(AE, "The first six frequencies are rigid body modes.");
# COMMENT(AE, "The first nonzero frequency (7) should be around 0.26 Hz");
# PART(AE, "part1");
# END_PART(AE);
# ASSEMBLY(AE, "ASSEM1");
# INSTANCE(AE, "INSTNC1", "PART1");
# NODE(AE, fens.xyz);
# COMMENT(AE, "The hybrid form of the serendipity hexahedron is chosen because");
# COMMENT(AE, "the material is nearly incompressible.");
# ELEMENT(AE, "c3d20rh", "AllElements", 1, connasarray(fes))
# ORIENTATION(AE, "GlobalOrientation", vec([1. 0 0]), vec([0 1. 0]));
# SOLID_SECTION(AE, "elasticity", "GlobalOrientation", "AllElements");
# END_INSTANCE(AE);
# END_ASSEMBLY(AE);
# MATERIAL(AE, "elasticity")
# ELASTIC(AE, E, nu)
# DENSITY(AE, rho)
# STEP_FREQUENCY(AE, neigvs)
# END_STEP(AE)
# close(AE)
# true
# end # alum_cyl_modes_export
# function alum_cyl_modes_msh8_algo()
# println("""
# % Vibration modes of unit cube of almost incompressible material.
# % Mean-strain hexahedron.
# % Reference: Puso MA, Solberg J (2006) A stabilized nodally integrated
# % tetrahedral. International Journal for Numerical Methods in
# % Engineering 67: 841-867.""")
# t0 = time()
# E = 1*phun("PA");
# nu = 0.499;
# rho= 1*phun("KG/M^3");
# a=1*phun("M"); b=a; h= a;
# n1=8 # How many element edges per side?
# na= n1; nb= n1; nh =n1;
# neigvs=20 # how many eigenvalues
# omega_shift=(0.1*2*pi)^2;
# fens,fes = H8block(a,b,h, na,nb,nh)
# # Make the region
# MR = DeforModelRed3D
# material = MatDeforElastIso(MR, rho, E, nu, 0.0)
# region1 = FDataDict("femm"=>FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3,2)),
# material), "femm_mass"=>FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3,3)),
# material))
# # Make model data
# modeldata = FDataDict(
# "fens"=> fens, "regions"=> [region1],
# "omega_shift"=>omega_shift, "neigvs"=>neigvs)
# # Solve
# modeldata = FinEtools.AlgoDeforLinearModule.modal(modeldata)
# fs = modeldata["omega"]/(2*pi)
# println("Eigenvalues: $fs [Hz]")
# modeldata["postprocessing"] = FDataDict("file"=>"alum_cyl_mode",
# "mode"=>10)
# modeldata=FinEtools.AlgoDeforLinearModule.exportmode(modeldata)
# @async run(`"paraview.exe" $(modeldata["postprocessing"]["file"]*"1.vtk")`)
# true
# end # alum_cyl_modes_msh8_algo
function alum_cyl_mode_esnice_h8()
E = 70000 * phun("MPa")
nu = 0.33
rho = 2700 * phun("KG/M^3")
radius = 0.5 * phun("ft")
OmegaShift = (10.0 * 2 * pi)^2
MR = DeforModelRed3D
output = import_ABAQUS(joinpath(@__DIR__, "alum_cyl.inp"))
fens, fes = output["fens"], output["fesets"][1]
fens.xyz .*= phun("mm") # The input is provided in SI(mm) units
fens, fes = T10toT4(fens, fes)
fens, fes = T4toH8(fens, fes)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm =
FEMMDeforLinearESNICEH8(MR, IntegDomain(fes, NodalTensorProductRule(3)), material)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
M = mass(femm, geom, u)
d, v, nev, nconv = eigs(
Symmetric(K + OmegaShift * M),
Symmetric(M);
nev = neigvs,
which = :SM,
explicittransform = :none,
)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
println("Eigenvalues: $fs [Hz]")
# @show v' * M * v
# @test norm(fs - [0.00000e+00, 0.00000e+00, 0.00000e+00, 5.54160e-06, 8.64750e-05, 1.18749e-04, 2.49815e+03, 2.49888e+03, 2.51331e+03, 4.08265e+03, 4.58599e+03, 4.58642e+03, 4.98701e+03, 6.64802e+03, 6.64848e+03, 6.67904e+03, 6.68216e+03, 6.77789e+03, 6.78059e+03, 6.79936e+03, 6.80400e+03, 7.38167e+03, 7.45600e+03, 7.47771e+03]) < 0.01
true
end # alum_cyl_modes
function allrun()
println("#####################################################")
println("# alum_cyl_mode_nice_t4 ")
alum_cyl_mode_nice_t4()
println("#####################################################")
println("# alum_cyl_mode_t4 ")
alum_cyl_mode_t4()
println("#####################################################")
println("# alum_cyl_mode_esnice_t4 ")
alum_cyl_mode_esnice_t4()
println("#####################################################")
println("# alum_cyl_mode_esnice_h8 ")
alum_cyl_mode_esnice_h8()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
# alum_cyl_modal_h20()
# alum_cyl_modal_t10()
# alum_cyl_modal_t4()
# alum_cyl_modal_esnicet4()
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 3056 | module multimaterial_nas_examples
using FinEtools
using FinEtools.MeshExportModule: MESH
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtoolsDeforLinear
using LinearAlgebra
using SparseArrays
using Arpack
function multimaterial_nas()
println("""
Vibration modes of block composed of two materials. NASTRAN input file.
""")
materials = Dict(
1 => (
name = "steel",
E = 205000 * phun("MPa"),
nu = 0.3,
rho = 7850 * phun("KG*M^-3"),
),
2 => (
name = "aluminum",
E = 70000 * phun("MPa"),
nu = 0.34,
rho = 2700 * phun("KG*M^-3"),
),
)
OmegaShift = (2 * pi * 100)^2 # to resolve rigid body modes
neigvs = 20
# No need to change anything below this line ##########
MR = DeforModelRed3D
output = import_NASTRAN(joinpath(@__DIR__, "twoblocks.nas"))
fens, fesets, pids = output["fens"], output["fesets"], output["property_ids"]
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
K = spzeros(nalldofs(u), nalldofs(u))
M = spzeros(nalldofs(u), nalldofs(u))
allfes = nothing
for i in eachindex(fesets)
pid = pids[i]
@show E, nu, rho = materials[pid].E, materials[pid].nu, materials[pid].rho
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinearESNICET4(
MR,
IntegDomain(fesets[i], NodalSimplexRule(3)),
material,
)
femm = associategeometry!(femm, geom)
K += stiffness(femm, geom, u)
M += mass(femm, geom, u)
if allfes === nothing
allfes = fesets[i]
else
allfes = cat(allfes, fesets[i])
end
end
# eigs returns the nev requested eigenvalues in d, the corresponding Ritz vectors
# v (only if ritzvec=true), the number of converged eigenvalues nconv, the number
# of iterations niter and the number of matrix vector multiplications nmult, as
# well as the final residual vector resid.
if true
d, v, nev, nconv = eigs(K + OmegaShift * M, M; nev = neigvs, which = :SM)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
println("Eigenvalues: $fs [Hz]")
mode = 7
scattersysvec!(u, v[:, mode])
File = "multimaterial_nas.vtk"
vtkexportmesh(File, fens, allfes; vectors = [("mode$mode", u.values)])
@async run(`"paraview.exe" $File`)
end
# Extract the boundary
bfes = meshboundary(allfes)
bconn = connasarray(bfes)
MESH.write_MESH("multimaterial_nas.mesh", fens, bfes)
true
end # multimaterial
function allrun()
println("#####################################################")
println("# multimaterial_nas ")
multimaterial_nas()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 2498 | module rectangular_plate_examples
using Statistics
using FinEtools
using FinEtools.MeshImportModule
using FinEtools.MeshExportModule
using FinEtoolsDeforLinear
using SubSIt
using LinearAlgebra: dot
using Arpack
using LinearAlgebra
using SparseArrays
using PGFPlotsX
using Test
E = 210e3 * phun("MPa")
nu = 0.3
rho = 7850 * phun("KG/M^3")
a = 4.00 * phun("M")
b = 1.00 * phun("M")
h = 0.1 * phun("M")
na = 10
nb = 5
nh = 2
na = 2 * 10
nb = 2 * 5
nh = 8
neigvs = 20 # how many eigenvalues
OmegaShift = (10.0 * 2 * pi)^2
# Fundamental frequency
f_analytical = [0 0 0 0 0 0 33.78 82.28 92.99 170.06]
function rectangular_plate_esnice()
global a, b, h, na, nb, nh
MR = DeforModelRed3D
fens, fes = T4block(a, b, h, na, nb, nh)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinearESNICET4(MR, IntegDomain(fes, NodalSimplexRule(3)), material)
associategeometry!(femm, geom)
@show minimum(vec(femm.nphis)), maximum(vec(femm.nphis))
@pgf a = Axis(
{
xlabel = "Entity",
ylabel = "Stabilization factor",
grid = "major",
legend_pos = "north east",
},
Plot(
{"only marks", mark = "+"},
Table([:x => vec(1:count(fes)), :y => vec(femm.ephis)]),
),
)
display(a)
K = stiffness(femm, geom, u)
M = mass(femm, geom, u)
d, v, nev, nconv = eigs(K + OmegaShift * M, M; nev = neigvs, which = :SM)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
println("Eigenvalues: $fs [Hz]")
println("f/f_analytical = $(fs[7:10] ./ f_analytical[7:10] .* 100) %")
vectors = []
for i = 7:length(fs)
scattersysvec!(u, v[:, i])
push!(vectors, ("Mode_$i", deepcopy(u.values)))
end
File = "rectangular_plate_esnice.vtk"
vtkexportmesh(
File,
connasarray(fes),
fens.xyz,
FinEtools.MeshExportModule.VTK.T4;
vectors = vectors,
)
@async run(`"paraview.exe" $File`)
true
end # function
function allrun()
println("#####################################################")
println("# rectangular_plate_esnice ")
rectangular_plate_esnice()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 5824 | module trunc_cyl_shell_examples
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!, matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using LinearAlgebra
using Arpack
using SubSIt
function trunc_cyl_shell()
println("""
Vibration modes of truncated cylindrical shell.
""")
# t0 = time()
E = 205000 * phun("MPa")# Young's modulus
nu = 0.3# Poisson ratio
rho = 7850 * phun("KG*M^-3")# mass density
OmegaShift = (2 * pi * 100)^2 # to resolve rigid body modes
h = 0.05 * phun("M")
l = 10 * h
Rmed = h / 0.2
psi = 0 # Cylinder
nh = 5
nl = 12
nc = 40
tolerance = h / nh / 100
neigvs = 20
MR = DeforModelRed3D
fens, fes = H8block(h, l, 2 * pi, nh, nl, nc)
# Shape into a cylinder
R = zeros(3, 3)
for i = 1:count(fens)
x, y, z = fens.xyz[i, :]
rotmat3!(R, [0, z, 0])
Q = [
cos(psi * pi / 180) sin(psi * pi / 180) 0
-sin(psi * pi / 180) cos(psi * pi / 180) 0
0 0 1
]
fens.xyz[i, :] = reshape([x + Rmed - h / 2, y - l / 2, 0], 1, 3) * Q * R
end
candidates = selectnode(fens, plane = [0.0 0.0 1.0 0.0], thickness = h / 1000)
fens, fes = mergenodes(fens, fes, tolerance, candidates)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 3)), material)
M = mass(femm, geom, u)
K_ff = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[:ff]
M_ff = matrix_blocked(M, nfreedofs(u), nfreedofs(u))[:ff]
# eigs returns the nev requested eigenvalues in d, the corresponding Ritz vectors
# v (only if ritzvec=true), the number of converged eigenvalues nconv, the number
# of iterations niter and the number of matrix vector multiplications nmult, as
# well as the final residual vector resid.
if true
d, v, nev, nconv = eigs(
Symmetric(K_ff + OmegaShift * M_ff),
Symmetric(M_ff);
nev = neigvs,
which = :SM,
explicittransform = :none,
)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
println("Eigenvalues: $fs [Hz]")
mode = 7
scattersysvec!(u, v[:, mode])
File = "trunc_cyl_shell.vtk"
vtkexportmesh(File, fens, fes; vectors = [("mode$mode", u.values)])
@async run(`"paraview.exe" $File`)
end
if true
solver = SubSIt.ssit
v0 = rand(size(K_ff, 1), 2 * neigvs)
tol = 1.0e-2
maxiter = 20
lamb, v, nconv, niter, lamberr = solver(
K_ff + OmegaShift .* M_ff,
M_ff;
nev = neigvs,
X = v0,
tol = tol,
maxiter = maxiter,
)
if nconv < neigvs
println("NOT converged")
end
lamb = lamb .- OmegaShift
fs = real(sqrt.(complex(lamb))) / (2 * pi)
println("Eigenvalues: $fs [Hz]")
println("Eigenvalue errors: $lamberr [ND]")
mode = 7
scattersysvec!(u, v[:, mode])
File = "trunc_cyl_shell.vtk"
vtkexportmesh(File, fens, fes; vectors = [("mode$mode", u.values)])
@async run(`"paraview.exe" $File`)
end
true
end # trunc_cyl_shell
function trunc_cyl_shell_nas()
println("""
Vibration modes of truncated cylindrical shell. NASTRAN input file.
""")
# t0 = time()
E = 205000 * phun("MPa")# Young's modulus
nu = 0.3# Poisson ratio
rho = 7850 * phun("KG*M^-3")# mass density
OmegaShift = (2 * pi * 100)^2 # to resolve rigid body modes
h = 0.05 * phun("M")
l = 10 * h
Rmed = h / 0.2
psi = 0 # Cylinder
nh = 5
nl = 12
nc = 40
tolerance = h / nh / 100
neigvs = 20
MR = DeforModelRed3D
output = import_NASTRAN(joinpath(@__DIR__, "trunc_cyl_shell_2.nas"))
fens, fes = output["fens"], output["fesets"][1]
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinearESNICET4(MR, IntegDomain(fes, NodalSimplexRule(3)), material)
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
M = mass(femm, geom, u)
# eigs returns the nev requested eigenvalues in d, the corresponding Ritz vectors
# v (only if ritzvec=true), the number of converged eigenvalues nconv, the number
# of iterations niter and the number of matrix vector multiplications nmult, as
# well as the final residual vector resid.
if true
d, v, nev, nconv = eigs(K + OmegaShift * M, M; nev = neigvs, which = :SM)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
println("Eigenvalues: $fs [Hz]")
mode = 7
scattersysvec!(u, v[:, mode])
File = "trunc_cyl_shell_nas.vtk"
vtkexportmesh(File, fens, fes; vectors = [("mode$mode", u.values)])
@async run(`"paraview.exe" $File`)
end
true
end # trunc_cyl_shell
function allrun()
println("#####################################################")
println("# trunc_cyl_shell ")
trunc_cyl_shell()
println("#####################################################")
println("# trunc_cyl_shell_nas ")
trunc_cyl_shell_nas()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 10176 | module unit_cube_mode_examples
using FinEtools
using FinEtools.MeshExportModule
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using LinearAlgebra
using GEPHelpers: gep_smallest, check_M_orthogonality, check_K_orthogonality
using Arpack
function unit_cube_modes()
println("""
Vibration modes of unit cube of almost incompressible material.
%
Reference: Puso MA, Solberg J (2006) A stabilized nodally integrated
tetrahedral. International Journal for Numerical Methods in
Engineering 67: 841-867.
""")
t0 = time()
E = 1 * phun("PA")
nu = 0.499
rho = 1 * phun("KG/M^3")
a = 1 * phun("M")
b = a
h = a
n1 = 10# How many element edges per side?
na = n1
nb = n1
nh = n1
neigvs = 20 # how many eigenvalues
OmegaShift = (0.01 * 2 * pi)^2
MR = DeforModelRed3D
fens, fes = H20block(a, b, h, na, nb, nh)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
@time K = stiffness(femm, geom, u)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 3)), material)
@time M = mass(femm, geom, u)
d, v, nconv = gep_smallest(K + OmegaShift * M, M, neigvs, which = :SM)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
println("Eigenvalues: $fs [Hz]")
@info check_K_orthogonality(d, v, K)
@info check_M_orthogonality(v, M)
@info norm(K * v - M * v * Diagonal(d))
vectors = []
File = "unit_cube_modes.vtk"
for mode = 1:neigvs
scattersysvec!(u, v[:, mode])
push!(vectors, ("mode$mode", deepcopy(u.values)))
end
vtkexportmesh(File, fens, fes; vectors = vectors)
true
end # unit_cube_modes
function unit_cube_modes_arnoldimethod()
println("""
Vibration modes of unit cube of almost incompressible material.
%
Reference: Puso MA, Solberg J (2006) A stabilized nodally integrated
tetrahedral. International Journal for Numerical Methods in
Engineering 67: 841-867.
""")
t0 = time()
E = 1 * phun("PA")
nu = 0.499
rho = 1 * phun("KG/M^3")
a = 1 * phun("M")
b = a
h = a
n1 = 10# How many element edges per side?
na = n1
nb = n1
nh = n1
neigvs = 20 # how many eigenvalues
OmegaShift = (0.01 * 2 * pi)^2
MR = DeforModelRed3D
fens, fes = H20block(a, b, h, na, nb, nh)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
@time K = stiffness(femm, geom, u)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 3)), material)
@time M = mass(femm, geom, u)
d, v, nconv = gep_smallest(
K + OmegaShift * M,
M,
neigvs;
method = :ArnoldiMethod,
orthogonalize = true,
which = :SM,
)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
println("Eigenvalues: $fs [Hz]")
@info check_K_orthogonality(d, v, K)
@info check_M_orthogonality(v, M)
@info norm(K * v - M * v * Diagonal(d))
vectors = []
File = "unit_cube_modes_arnoldimethod.vtk"
for mode = 1:neigvs
scattersysvec!(u, v[:, mode])
push!(vectors, ("mode$mode", deepcopy(u.values)))
end
vtkexportmesh(File, fens, fes; vectors = vectors)
true
end # unit_cube_modes
function unit_cube_modes_algo()
println("""
% Vibration modes of unit cube of almost incompressible material.
%
% Reference: Puso MA, Solberg J (2006) A stabilized nodally integrated
% tetrahedral. International Journal for Numerical Methods in
% Engineering 67: 841-867.""")
t0 = time()
E = 1 * phun("PA")
nu = 0.499
rho = 1 * phun("KG/M^3")
a = 1 * phun("M")
b = a
h = a
n1 = 2# How many element edges per side?
na = n1
nb = n1
nh = n1
neigvs = 20 # how many eigenvalues
omega_shift = (0.1 * 2 * pi)^2
fens, fes = H20block(a, b, h, na, nb, nh)
# Make the region
MR = DeforModelRed3D
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
region1 = FDataDict(
"femm" => FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material),
"femm_mass" => FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 3)), material),
)
# Make model data
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"omega_shift" => omega_shift,
"neigvs" => neigvs,
)
# Solve
modeldata = AlgoDeforLinearModule.modal(modeldata)
fs = modeldata["omega"] / (2 * pi)
println("Eigenvalues: $fs [Hz]")
modeldata["postprocessing"] = FDataDict("file" => "unit_cube_mode", "mode" => 10)
modeldata = AlgoDeforLinearModule.exportmode(modeldata)
@async run(`"paraview.exe" $(modeldata["postprocessing"]["file"]*"1.vtk")`)
true
end # unit_cube_modes_algo
function unit_cube_modes_export()
println("""
Vibration modes of unit cube of almost incompressible material.
This example EXPORTS the model to Abaqus.
Reference: Puso MA, Solberg J (2006) A stabilized nodally integrated
tetrahedral. International Journal for Numerical Methods in
Engineering 67: 841-867.
""")
t0 = time()
E = 1 * phun("PA")
nu = 0.499
rho = 1 * phun("KG/M^3")
a = 1 * phun("M")
b = a
h = a
n1 = 5# How many element edges per side?
na = n1
nb = n1
nh = n1
neigvs = 20 # how many eigenvalues
OmegaShift = (0.01 * 2 * pi)^2
MR = DeforModelRed3D
fens, fes = H20block(a, b, h, na, nb, nh)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
K = stiffness(femm, geom, u)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 3)), material)
M = mass(femm, geom, u)
d, v, nconv = gep_smallest(K + OmegaShift * M, M, neigvs, which = :SM)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
println("Eigenvalues: $fs [Hz]")
mode = 7
scattersysvec!(u, v[:, mode])
File = "unit_cube_modes.vtk"
vtkexportmesh(File, fens, fes; vectors = [("mode$mode", u.values)])
@async run(`"paraview.exe" $File`)
AE = AbaqusExporter("unit_cube_modes_h20")
# AE.ios = STDOUT;
HEADING(AE, "Vibration modes of unit cube of almost incompressible material.")
COMMENT(AE, "The first six frequencies are rigid body modes.")
COMMENT(AE, "The first nonzero frequency (7) should be around 0.26 Hz")
PART(AE, "part1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
COMMENT(AE, "The hybrid form of the serendipity hexahedron is chosen because")
COMMENT(AE, "the material is nearly incompressible.")
ELEMENT(AE, "c3d20rh", "AllElements", 1, connasarray(fes))
ORIENTATION(AE, "GlobalOrientation", vec([1.0 0 0]), vec([0 1.0 0]))
SOLID_SECTION(AE, "elasticity", "GlobalOrientation", "AllElements")
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "elasticity")
ELASTIC(AE, E, nu)
DENSITY(AE, rho)
STEP_FREQUENCY(AE, neigvs)
END_STEP(AE)
close(AE)
true
end # unit_cube_modes_export
function unit_cube_modes_msh8_algo()
println("""
% Vibration modes of unit cube of almost incompressible material.
% Mean-strain hexahedron.
% Reference: Puso MA, Solberg J (2006) A stabilized nodally integrated
% tetrahedral. International Journal for Numerical Methods in
% Engineering 67: 841-867.""")
t0 = time()
E = 1 * phun("PA")
nu = 0.499
rho = 1 * phun("KG/M^3")
a = 1 * phun("M")
b = a
h = a
n1 = 8 # How many element edges per side?
na = n1
nb = n1
nh = n1
neigvs = 20 # how many eigenvalues
omega_shift = (0.1 * 2 * pi)^2
fens, fes = H8block(a, b, h, na, nb, nh)
# Make the region
MR = DeforModelRed3D
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
region1 = FDataDict(
"femm" => FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material),
"femm_mass" =>
FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 3)), material),
)
# Make model data
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"omega_shift" => omega_shift,
"neigvs" => neigvs,
)
# Solve
modeldata = AlgoDeforLinearModule.modal(modeldata)
fs = modeldata["omega"] / (2 * pi)
println("Eigenvalues: $fs [Hz]")
modeldata["postprocessing"] = FDataDict("file" => "unit_cube_mode", "mode" => 10)
modeldata = AlgoDeforLinearModule.exportmode(modeldata)
@async run(`"paraview.exe" $(modeldata["postprocessing"]["file"]*"1.vtk")`)
true
end # unit_cube_modes_msh8_algo
function allrun()
println("#####################################################")
println("# unit_cube_modes ")
unit_cube_modes()
println("#####################################################")
println("# unit_cube_modes_arnoldimethod ")
unit_cube_modes_arnoldimethod()
# println("#####################################################")
# println("# unit_cube_modes_algo ")
# unit_cube_modes_algo()
# println("#####################################################")
# println("# unit_cube_modes_export ")
# unit_cube_modes_export()
# println("#####################################################")
# println("# unit_cube_modes_msh8_algo ")
# unit_cube_modes_msh8_algo()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 4918 | module unit_cube_tet_examples
using FinEtools
using FinEtools.MeshExportModule
using FinEtoolsDeforLinear
using SubSIt: ssit
using LinearAlgebra
using Arpack
using DataDrop
using VibrationGEPHelpers
E = 1 * phun("PA")
nu = 0.499
rho = 1 * phun("KG/M^3")
a = 1 * phun("M")
b = a
h = a
n1 = 16# How many element edges per side?
na = n1
nb = n1
nh = n1
neigvs = 20 # how many eigenvalues
OmegaShift = (0.1 * 2 * pi)^2
function unit_cube_esnice()
println("""
Vibration modes of unit cube of almost incompressible material.
Reference: Puso MA, Solberg J (2006) A stabilized nodally integrated
tetrahedral. International Journal for Numerical Methods in
Engineering 67: 841-867.
""")
MR = DeforModelRed3D
fens, fes = T4block(a, b, h, na, nb, nh)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinearESNICET4(MR, IntegDomain(fes, NodalSimplexRule(3)), material)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
M = mass(femm, geom, u)
# DataDrop.store_matrix("unit_cube_tet-$n1.h5", "/K", K)
# DataDrop.store_matrix("unit_cube_tet-$n1.h5", "/M", M)
@time d, v, nconv = eigs(K + OmegaShift * M, M; nev = neigvs, which = :SM)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
println("Eigenvalues: $fs [Hz]")
# DataDrop.store_matrix("unit_cube_tet-$n1.h5", "frequencies", fs)
mode = 17
scattersysvec!(u, v[:, mode])
File = "unit_cube_esnice.vtk"
vtkexportmesh(File, fens, fes; vectors = [("mode$mode", u.values)])
#@async run(`"paraview.exe" $File`)
true
end # unit_cube_esnice
function unit_cube_esnice_ssit()
println("""
Vibration modes of unit cube of almost incompressible material.
Reference: Puso MA, Solberg J (2006) A stabilized nodally integrated
tetrahedral. International Journal for Numerical Methods in
Engineering 67: 841-867.
""")
MR = DeforModelRed3D
fens, fes = T4block(a, b, h, na, nb, nh)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinearESNICET4(MR, IntegDomain(fes, NodalSimplexRule(3)), material)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
M = mass(femm, geom, u)
@time d, v, nconv = ssit(K + OmegaShift * M, M; nev = neigvs)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
println("Eigenvalues: $fs [Hz]")
mode = 17
scattersysvec!(u, v[:, mode])
File = "unit_cube_esnice.vtk"
vtkexportmesh(File, fens, fes; vectors = [("mode$mode", u.values)])
#@async run(`"paraview.exe" $File`)
true
end # unit_cube_esnice
function unit_cube_esnice_helpers()
println("""
Vibration modes of unit cube of almost incompressible material.
Reference: Puso MA, Solberg J (2006) A stabilized nodally integrated
tetrahedral. International Journal for Numerical Methods in
Engineering 67: 841-867.
""")
MR = DeforModelRed3D
fens, fes = T4block(a, b, h, na, nb, nh)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinearESNICET4(MR, IntegDomain(fes, NodalSimplexRule(3)), material)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
M = mass(femm, geom, u)
@time d, v, nconv = VibrationGEPHelpers.gep_smallest(
K + OmegaShift * M,
M,
neigvs;
method = :ArnoldiMethod,
)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
println("Eigenvalues: $fs [Hz]")
@show VibrationGEPHelpers.check_K_orthogonality(d, v, K)
@show VibrationGEPHelpers.check_M_orthogonality(v, M)
File = "unit_cube_esnice_helpers-ArnoldiMethod.vtk"
vectors = []
for mode in eachindex(fs)
scattersysvec!(u, v[:, mode])
push!(vectors, ("mode#$mode", deepcopy(u.values)))
end
vtkexportmesh(File, fens, fes; vectors = vectors)
#@async run(`"paraview.exe" $File`)
true
end # unit_cube_esnice
function allrun()
println("#####################################################")
println("# unit_cube_esnice ")
unit_cube_esnice()
println("#####################################################")
println("# unit_cube_esnice_ssit ")
unit_cube_esnice_ssit()
println("#####################################################")
println("# unit_cube_esnice_helpers ")
unit_cube_esnice_helpers()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 3603 | module uxo_mode_examples
using FinEtools
using FinEtoolsDeforLinear
using FinEtools.MeshExportModule
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using LinearAlgebra
using Arpack
using CSV
function uxo_mode_esnice_t4()
E = 70000 * phun("MPa")
nu = 0.33
rho = 2700 * phun("KG/M^3")
radius = 0.5 * phun("ft")
neigvs = 20 # how many eigenvalues
OmegaShift = (10.0 * 2 * pi)^2
MR = DeforModelRed3D
output = import_NASTRAN(joinpath(@__DIR__, "UXO.nas"))
fens, fes = output["fens"], output["fesets"][1]
fens.xyz .*= phun("mm") # The input is provided in SI(mm) units
@show count(fens)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinearESNICET4(MR, IntegDomain(fes, NodalSimplexRule(3)), material)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
M = mass(femm, geom, u)
d, v, nev, nconv = eigs(
Symmetric(K + OmegaShift * M),
Symmetric(M);
nev = neigvs,
which = :SM,
explicittransform = :none,
)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
println("Eigenvalues: $fs [Hz]")
true
end # uxo_modes
# function uxo_mode_swept_h8()
# E = 70000*phun("MPa");
# nu = 0.33;
# rho = 2700*phun("KG/M^3");
# radius = 0.5*phun("ft");
# neigvs = 20 # how many eigenvalues
# OmegaShift = (1.0*2*pi)^2;
# MR = DeforModelRed3D
# xyzrows = CSV.File(joinpath(@__DIR__, "UXO-swept-mesh-xyz.csv"), header=0)
# xyz = fill(0.0, length(xyzrows), 3)
# for i in 1:size(xyz, 1)
# xyz[i, :] .= xyzrows[i]
# end
# connrows = CSV.File(joinpath(@__DIR__, "UXO-swept-mesh-conn.csv"), header=0)
# conn = fill(0, length(connrows), 8)
# for i in 1:size(conn, 1)
# conn[i, :] .= connrows[i]
# end
# fens = FENodeSet(xyz)
# fes = FESetH8(conn)
# # fens.xyz .*= phun("mm") # The input is provided in SI(mm) units
# geom = NodalField(fens.xyz)
# u = NodalField(zeros(size(fens.xyz,1),3)) # displacement field
# numberdofs!(u)
# material = MatDeforElastIso(MR, rho, E, nu, 0.0)
# femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
# # femm = FEMMDeforLinearESNICEH8(MR, IntegDomain(fes, NodalTensorProductRule(3)), material)
# associategeometry!(femm, geom)
# K = stiffness(femm, geom, u)
# M = mass(femm, geom, u)
# d,v,nev = eigs(Symmetric(K+OmegaShift*M), Symmetric(M); nev=neigvs, which=:SM, explicittransform=:none)
# d = d .- OmegaShift;
# fs = real(sqrt.(complex(d)))/(2*pi)
# println("Eigenvalues: $fs [Hz]")
# File = "uxo_mode_swept_h8.vtk"
# vtkexportmesh(File, fens, fes)
# for mode = 1:7
# scattersysvec!(u, v[:,mode])
# File = "uxo_mode-$(mode).vtk"
# vtkexportmesh(File, fens, fes; vectors=[("mode$mode", u.values)])
# end
# true
# end # uxo_modes
function allrun()
println("#####################################################")
println("# uxo_mode_nice_t4 omitted due to significant size")
# uxo_mode_esnice_t4()
# println("#####################################################")
# println("# uxo_mode_esnice_t4 ")
# uxo_mode_swept_h8()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module uxo_mode_examples
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 14606 | module material_eigen_examples
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtoolsDeforLinear.MatDeforLinearElasticModule: tangentmoduli!
# using IterativeSolvers
using Statistics: mean
using LinearAlgebra: inv, cholesky, norm, eigen
function iso()
E = 1.0e3 * phun("Pa")
nu = 0.4999999
CTE = 0.0
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
D = fill(0.0, 6, 6)
t::FFlt, dt::FFlt, loc::FFltMat, label::FInt = 0.0, 0.0, [0.0 0.0 0.0], 0
tangentmoduli!(material, D, t, dt, loc, label)
@show dec = eigen(D)
@show idec = eigen(inv(D))
true
end # iso
function ortho()
E1s = 100.0 * phun("GPa")
E2s = 1.0 * phun("MPa")
E3s = E2s
nu23s = nu12s = nu13s = 0.25
G12s = 0.13 * phun("GPa")
G23s = G13s = G12s
CTE1 = 0.0
CTE2 = 0.0
CTE3 = 0.0
MR = DeforModelRed3D
material = MatDeforElastOrtho(
MR,
0.0,
E1s,
E2s,
E3s,
nu12s,
nu13s,
nu23s,
G12s,
G13s,
G23s,
CTE1,
CTE2,
CTE3,
)
D = fill(0.0, 6, 6)
t::FFlt, dt::FFlt, loc::FFltMat, label::FInt = 0.0, 0.0, [0.0 0.0 0.0], 0
tangentmoduli!(material, D, t, dt, loc, label)
@show dec = eigen(D)
@show idec = eigen(inv(D))
true
end # iso
# function fiber_reinf_cant_yn_strong()
# println("""
# Cantilever example. Strongly orthotropic material. Orientation "y".
# @article{
# author = {Krysl, P.},
# title = {Mean-strain 8-node hexahedron with optimized energy-sampling stabilization},
# journal = {Finite Elements in Analysis and Design},
# volume = {108}, pages = {41-53}, DOI = {10.1016/j.finel.2015.09.008}, year = {2016}
# }
# """)
# t0 = time()
# # # Orthotropic material
# E1s = 100000.0*phun("GPa")
# E2s = 1.0*phun("GPa")
# E3s = E2s
# nu23s = nu12s = nu13s = 0.25
# G12s = 0.2*phun("GPa")
# G23s = G13s = G12s
# CTE1 = 0.0
# CTE2 = 0.0
# CTE3 = 0.0
# # # Isotropic material
# # E = 1.0e9*phun("Pa")
# # nu = 0.25
# # CTE = 0.0
# # Reference value for the vertical deflection of the tip
# uz_ref = -1.027498445054843e-05;
# a = 90.0*phun("mm") # length of the cantilever
# b = 10.0*phun("mm") # width of the cross-section
# t = 20.0*phun("mm") # height of the cross-section
# q0 = -1000.0*phun("Pa") # shear traction
# dT = 0*phun("K") # temperature rise
# tolerance = 0.00001*t
# # Generate mesh
# n = 4
# na = 8*n # number of elements lengthwise
# nb = n # number of elements through the wwith
# nt = n # number of elements through the thickness
# xs = collect(linearspace(0.0, a, na+1))
# ys = collect(linearspace(0.0, b, nb+1))
# ts = collect(linearspace(0.0, t, nt+1))
# fens,fes = H8blockx(xs, ys, ts)
# fens,fes = H8toH20(fens,fes)
# bfes = meshboundary(fes)
# # end cross-section surface for the shear loading
# sshearl = selectelem(fens, bfes; facing=true, direction = [+1.0 0.0 0.0])
# MR = DeforModelRed3D
# material = MatDeforElastOrtho(MR,
# 0.0, E1s, E2s, E3s,
# nu12s, nu13s, nu23s,
# G12s, G13s, G23s,
# CTE1, CTE2, CTE3)
# # material = MatDeforElastIso(MR,
# # 0.0, E, nu, CTE)
# # Material orientation matrix
# csmat = zeros(3, 3)
# rotmat3!(csmat, -45.0/180.0*pi*[0,1,0])
# function updatecs!(csmatout::FFltMat, XYZ::FFltMat, tangents::FFltMat, fe_label::FInt)
# copyto!(csmatout, csmat)
# end
# gr = GaussRule(3, 2)
# region = FDataDict("femm"=>FEMMDeforLinear(MR, IntegDomain(fes, gr), CSys(3, 3, updatecs!), material))
# lx0 = selectnode(fens, box=[0.0 0.0 -Inf Inf -Inf Inf], inflate=tolerance)
# ex01 = FDataDict( "displacement"=> 0.0, "component"=> 1, "node_list"=>lx0 )
# ex02 = FDataDict( "displacement"=> 0.0, "component"=> 2, "node_list"=>lx0 )
# ex03 = FDataDict( "displacement"=> 0.0, "component"=> 3, "node_list"=>lx0 )
# function getshr!(forceout::FFltVec, XYZ::FFltMat, tangents::FFltMat, fe_label::FInt)
# copyto!(forceout, q0*[0.0; 0.0; 1.0])
# end
# Trac = FDataDict("traction_vector"=>getshr!, "femm"=>FEMMBase(IntegDomain(subset(bfes, sshearl), GaussRule(2, 3))))
# modeldata = FDataDict("fens"=>fens,
# "regions"=>[region],
# "essential_bcs"=>[ex01, ex02, ex03],
# "traction_bcs"=>[Trac],
# "temperature_change"=>FDataDict("temperature"=>dT)
# )
# modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
# u = modeldata["u"]
# geom = modeldata["geom"]
# Tipl = selectnode(fens, box=[a a b b 0. 0.], inflate=tolerance)
# utip = mean(u.values[Tipl, 3])
# println("Deflection $utip, normalized: $(utip/uz_ref)")
# println("Solution: $( time()-t0 )")
# # File = "NAFEMS-R0031-2-plate.vtk"
# # vtkexportmesh(File, fes.conn, geom.values, FinEtools.MeshExportModule.H20;
# # scalars = [("Layer", fes.label)], vectors = [("displacement", u.values)])
# # @async run(`"paraview.exe" $File`)
# modeldata["postprocessing"] = FDataDict("file"=>"fiber_reinf_cant_yn_strong", "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy, "component"=>5)
# modeldata = AlgoDeforLinearModule.exportstress(modeldata)
# File = modeldata["postprocessing"]["exported"][1]["file"]
# @async run(`"paraview.exe" $File`)
# # modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
# # File = modeldata["postprocessing"]["exported"][1]["file"]
# # @async run(`"paraview.exe" $File`)
# println("Done: $( time()-t0 )")
# true
# end # fiber_reinf_cant_yn_strong
# function fiber_reinf_cant_yn_strong_no_algo()
# println("""
# Cantilever example. Strongly orthotropic material. Orientation "y".
# @article{
# author = {Krysl, P.},
# title = {Mean-strain 8-node hexahedron with optimized energy-sampling stabilization},
# journal = {Finite Elements in Analysis and Design},
# volume = {108}, pages = {41-53}, DOI = {10.1016/j.finel.2015.09.008}, year = {2016}
# }
# """)
# t0 = time()
# pu = ustring -> phun(ustring; system_of_units = :SIMM)
# # # Orthotropic material
# E1s = 100000.0*pu("GPa")
# E2s = 1.0*pu("GPa")
# E3s = E2s
# nu23s = nu12s = nu13s = 0.25
# G12s = 0.2*pu("GPa")
# G23s = G13s = G12s
# CTE1 = 0.0
# CTE2 = 0.0
# CTE3 = 0.0
# # # Isotropic material
# # E = 1.0e9*pu("Pa")
# # nu = 0.25
# # CTE = 0.0
# # Reference value for the vertical deflection of the tip
# uz_ref = -1.027498445054843e-05*pu("m");
# a = 90.0*pu("mm") # length of the cantilever
# b = 10.0*pu("mm") # width of the cross-section
# t = 20.0*pu("mm") # height of the cross-section
# q0 = -1000.0*pu("Pa") # shear traction
# dT = 0*pu("K") # temperature rise
# tolerance = 0.00001*t
# # Generate mesh
# n = 10
# na = n # number of elements lengthwise
# nb = n # number of elements through the wwith
# nt = n # number of elements through the thickness
# xs = collect(linearspace(0.0, a, na+1))
# ys = collect(linearspace(0.0, b, nb+1))
# ts = collect(linearspace(0.0, t, nt+1))
# println("fens,fes = H8blockx(xs, ys, ts)")
# @time fens,fes = H8blockx(xs, ys, ts)
# println("fens,fes = H8toH20(fens,fes)")
# @time fens,fes = H8toH20(fens,fes)
# println("bfes = meshboundary(fes)")
# @time bfes = meshboundary(fes)
# # end cross-section surface for the shear loading
# sshearl = selectelem(fens, bfes; facing=true, direction = [+1.0 0.0 0.0])
# MR = DeforModelRed3D
# material = MatDeforElastOrtho(MR,
# 0.0, E1s, E2s, E3s,
# nu12s, nu13s, nu23s,
# G12s, G13s, G23s,
# CTE1, CTE2, CTE3)
# # material = MatDeforElastIso(MR,
# # 0.0, E, nu, CTE)
# # Material orientation matrix
# csmat = zeros(3, 3)
# rotmat3!(csmat, -45.0/180.0*pi*[0,1,0])
# function updatecs!(csmatout::FFltMat, XYZ::FFltMat, tangents::FFltMat, fe_label::FInt)
# copyto!(csmatout, csmat)
# end
# gr = GaussRule(3, 2)
# femm = FEMMDeforLinear(MR, IntegDomain(fes, gr), CSys(3, 3, updatecs!), material)
# lx0 = selectnode(fens, box=[0.0 0.0 -Inf Inf -Inf Inf], inflate=tolerance)
# geom = NodalField(fens.xyz)
# u = NodalField(zeros(size(fens.xyz,1),3)) # displacement field
# nnodes(geom)
# setebc!(u, lx0, true, 1, zeros(size(lx0)))
# setebc!(u, lx0, true, 2, zeros(size(lx0)))
# setebc!(u, lx0, true, 3, zeros(size(lx0)))
# applyebc!(u)
# S = connectionmatrix(femm, nnodes(geom))
# numberdofs!(u)
# function getshr!(forceout::FFltVec, XYZ::FFltMat, tangents::FFltMat, fe_label::FInt)
# copyto!(forceout, q0*[0.0; 0.0; 1.0])
# end
# Tracfemm = FEMMBase(IntegDomain(subset(bfes, sshearl), GaussRule(2, 3)))
# println("K = stiffness(femm, geom, u)")
# @time K = stiffness(femm, geom, u)
# fi = ForceIntensity(Float64, 3, getshr!);
# println("F = distribloads(Tracfemm, geom, u, fi, 2);")
# @time F = distribloads(Tracfemm, geom, u, fi, 2);
# println("K = cholesky(K)")
# K = (K + K')/2;
# @time K = cholesky(Symmetric(K))
# println("U = K\\F")
# @time U = K\F
# # println("U = cg(K, F; tol=1e-3, maxiter=2000)")
# # @time U = cg(K, F; tol=1e-3, maxiter=2000)
# scattersysvec!(u, U[:])
# Tipl = selectnode(fens, box=[a a b b 0. 0.], inflate=tolerance)
# utip = mean(u.values[Tipl, 3])
# println("Deflection $utip, normalized: $(utip/uz_ref)")
# println("Solution: $( time()-t0 )")
# println("Done: $( time()-t0 )")
# true
# end # fiber_reinf_cant_yn_strong_no_algo
# function fiber_reinf_cant_zn_strong()
# println("""
# Cantilever example. Strongly orthotropic material. Orientation "z".
# @article{
# author = {Krysl, P.},
# title = {Mean-strain 8-node hexahedron with optimized energy-sampling stabilization},
# journal = {Finite Elements in Analysis and Design},
# volume = {108}, pages = {41-53}, DOI = {10.1016/j.finel.2015.09.008}, year = {2016}
# }
# """)
# t0 = time()
# # # Orthotropic material
# E1s = 100000.0*phun("GPa")
# E2s = 1.0*phun("GPa")
# E3s = E2s
# nu23s = nu12s = nu13s = 0.25
# G12s = 0.2*phun("GPa")
# G23s = G13s = G12s
# CTE1 = 0.0
# CTE2 = 0.0
# CTE3 = 0.0
# # # Isotropic material
# # E = 1.0e9*phun("Pa")
# # nu = 0.25
# # CTE = 0.0
# # Reference value for the vertical deflection of the tip
# uz_ref = -1.119145781010554e-05;
# a = 90.0*phun("mm") # length of the cantilever
# b = 10.0*phun("mm") # width of the cross-section
# t = 20.0*phun("mm") # height of the cross-section
# q0 = -1000.0*phun("Pa") # shear traction
# dT = 0*phun("K") # temperature rise
# tolerance = 0.00001*t
# # Generate mesh
# n = 8
# na = 8*n # number of elements lengthwise
# nb = n # number of elements through the wwith
# nt = n # number of elements through the thickness
# xs = collect(linearspace(0.0, a, na+1))
# ys = collect(linearspace(0.0, b, nb+1))
# ts = collect(linearspace(0.0, t, nt+1))
# fens,fes = H8blockx(xs, ys, ts)
# fens,fes = H8toH20(fens,fes)
# bfes = meshboundary(fes)
# # end cross-section surface for the shear loading
# sshearl = selectelem(fens, bfes; facing=true, direction = [+1.0 0.0 0.0])
# MR = DeforModelRed3D
# material = MatDeforElastOrtho(MR,
# 0.0, E1s, E2s, E3s,
# nu12s, nu13s, nu23s,
# G12s, G13s, G23s,
# CTE1, CTE2, CTE3)
# # material = MatDeforElastIso(MR,
# # 0.0, E, nu, CTE)
# # Material orientation matrix
# csmat = zeros(3, 3)
# rotmat3!(csmat, -45.0/180.0*pi*[0,0,1])
# function updatecs!(csmatout::FFltMat, XYZ::FFltMat, tangents::FFltMat, fe_label::FInt)
# copyto!(csmatout, csmat)
# end
# gr = GaussRule(3, 2)
# region = FDataDict("femm"=>FEMMDeforLinear(MR, IntegDomain(fes, gr), CSys(3, 3, updatecs!), material))
# lx0 = selectnode(fens, box=[0.0 0.0 -Inf Inf -Inf Inf], inflate=tolerance)
# ex01 = FDataDict( "displacement"=> 0.0, "component"=> 1, "node_list"=>lx0 )
# ex02 = FDataDict( "displacement"=> 0.0, "component"=> 2, "node_list"=>lx0 )
# ex03 = FDataDict( "displacement"=> 0.0, "component"=> 3, "node_list"=>lx0 )
# function getshr!(forceout::FFltVec, XYZ::FFltMat, tangents::FFltMat, fe_label::FInt)
# copyto!(forceout, q0*[0.0; 0.0; 1.0])
# end
# Trac = FDataDict("traction_vector"=>getshr!, "femm"=>FEMMBase(IntegDomain(subset(bfes, sshearl), GaussRule(2, 3))))
# modeldata = FDataDict("fens"=>fens,
# "regions"=>[region],
# "essential_bcs"=>[ex01, ex02, ex03],
# "traction_bcs"=>[Trac],
# "temperature_change"=>FDataDict("temperature"=>dT)
# )
# modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
# u = modeldata["u"]
# geom = modeldata["geom"]
# Tipl = selectnode(fens, box=[a a b b 0. 0.], inflate=tolerance)
# utip = mean(u.values[Tipl, 3])
# println("Deflection $utip, normalized: $(utip/uz_ref)")
# println("Solution: $( time()-t0 )")
# # File = "NAFEMS-R0031-2-plate.vtk"
# # vtkexportmesh(File, fes.conn, geom.values, FinEtools.MeshExportModule.H20;
# # scalars = [("Layer", fes.label)], vectors = [("displacement", u.values)])
# # @async run(`"paraview.exe" $File`)
# modeldata["postprocessing"] = FDataDict("file"=>"fiber_reinf_cant_yn_strong", "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy, "component"=>5)
# modeldata = AlgoDeforLinearModule.exportstress(modeldata)
# File = modeldata["postprocessing"]["exported"][1]["file"]
# @async run(`"paraview.exe" $File`)
# # modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
# # File = modeldata["postprocessing"]["exported"][1]["file"]
# # @async run(`"paraview.exe" $File`)
# println("Done: $( time()-t0 )")
# true
# end # fiber_reinf_cant_zn_strong
function allrun()
println("#####################################################")
println("# iso ")
iso()
println("#####################################################")
println("# ortho ")
ortho()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 10362 | module bend_hex_spectrum_examples
using FinEtools
using FinEtools.MeshExportModule.CSV: savecsv
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtools.AlgoBaseModule: evalconvergencestudy
using FinEtoolsDeforLinear.AlgoDeforLinearModule:
linearstatics, exportstresselementwise, exportstress
using Statistics: mean
using LinearAlgebra: Symmetric, cholesky, eigen
using PGFPlotsX
# Isotropic material
E = 1.0
nu = 0.3
aspects = [1.0 10.0 100.0 1000.0]
# julia> rand(8,3) .* 2 .- 1.0
xyzperturbation =
[
0.0767656 -0.983206 -0.14343
0.45767 0.981479 0.450997
-0.295854 0.542922 0.321333
-0.85204 -0.97824 -0.772874
-0.0539756 0.994907 0.822798
0.447173 0.528742 0.0445352
-0.468417 0.00673427 0.953151
-0.898513 -0.915871 0.933237
] ./ 15.0
# Lambda1 = vec([-1.0 1.0 1.0 -1.0 -1.0 1.0 1.0 -1.0])
# Lambda2 = vec([-1.0 -1.0 1.0 1.0 -1.0 -1.0 1.0 1.0])
# Gamma1 = vec([1.0 1.0 -1.0 -1.0 -1.0 -1.0 1.0 1.0])
# xyzperturbation = zeros((8,3))
# xyzperturbation[:, 1] .= Lambda2 ./ 10.0
# xyzperturbation[:, 2] .= Lambda1 ./ 10.0
# xyzperturbation[:, 3] .= Gamma1 ./ 20.0
function mesh()
(
FinEtools.FENodeSetModule.FENodeSet(
[
0.0 0.0 0.0
1.0 0.0 0.0
1.0 1.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0
1.0 0.0 1.0
1.0 1.0 1.0
0.0 1.0 1.0
],
),
FinEtools.FESetModule.FESetH8(reshape([1, 2, 3, 4, 5, 6, 7, 8], 1, 8)),
)
end
function bend_hex_spectrum_full()
function sim(aspect)
fens, fes = mesh()
fens.xyz += xyzperturbation
fens.xyz[:, 1] .*= aspect
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
applyebc!(u)
numberdofs!(u)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
vol = integratefunction(femm, geom, x -> 1.0; m = 3)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
D = eigen(Matrix(K))
File = "bend_hex_spectrum_full.vtk"
vectors = [
(
"ev_$(idx)_$(round(D.values[idx] * 10000) / 10000)",
deepcopy(scattersysvec!(u, D.vectors[:, idx]).values),
) for idx = 1:length(D.values)
]
vtkexportmesh(File, fens, fes; vectors = vectors)
# @async run(`"paraview.exe" $File`)
savecsv("bend_hex_spectrum_full-aspect=$(aspect).csv", eigenvalues = vec(D.values))
@pgf _a = SemiLogYAxis(
{
xlabel = "Mode [ND]",
ylabel = "Generalized stiffness [N/m]",
grid = "major",
legend_pos = "south east",
title = "Hexahedron spectrum, aspect=$(aspect)",
},
Plot(
{"red", mark = "triangle"},
Table([:x => vec(7:size(K, 1)), :y => vec(D.values[7:end])]),
),
LegendEntry("FEA"),
)
display(_a)
true
end
for aspect in aspects
sim(aspect)
end
end # bend_hex_spectrum_full
function bend_hex_spectrum_underintegrated()
function sim(aspect)
fens, fes = mesh()
fens.xyz[:, 1] .*= aspect
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
applyebc!(u)
numberdofs!(u)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 1)), material)
vol = integratefunction(femm, geom, x -> 1.0; m = 3)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
D = eigen(Matrix(K))
# File = "bend_hex_spectrum_full.vtk"
# vectors = [("ev_$(idx)_$(round(D.values[idx] * 10000) / 10000)", deepcopy(scattersysvec!(u, D.vectors[:,idx]).values)) for idx in 1:length(D.values)]
# vtkexportmesh(File, fens, fes; vectors=vectors)
# @async run(`"paraview.exe" $File`)
savecsv(
"bend_hex_spectrum_underintegrated-aspect=$(aspect).csv",
eigenvalues = vec(D.values),
)
true
end
for aspect in aspects
sim(aspect)
end
end # bend_hex_spectrum_underintegrated
function bend_hex_spectrum_ms()
function sim(aspect)
fens, fes = mesh()
fens.xyz[:, 1] .*= aspect
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
applyebc!(u)
numberdofs!(u)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
vol = integratefunction(femm, geom, x -> 1.0; m = 3)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
D = eigen(Matrix(K))
savecsv("bend_hex_spectrum_ms-aspect=$(aspect).csv", eigenvalues = vec(D.values))
@pgf _a = SemiLogYAxis(
{
xlabel = "Mode [ND]",
ylabel = "Generalized stiffness [N/m]",
grid = "major",
legend_pos = "south east",
title = "Hexahedron spectrum, aspect=$(aspect)",
},
Plot(
{"red", mark = "triangle"},
Table([:x => vec(7:size(K, 1)), :y => vec(D.values[7:end])]),
),
LegendEntry("MS"),
)
display(_a)
# File = "bend_hex_spectrum_ms.vtk"
# vectors = [("ev_$(idx)_$(round(D.values[idx] * 10000) / 10000)", deepcopy(scattersysvec!(u, D.vectors[:,idx]).values)) for idx in 1:length(D.values)]
# vtkexportmesh(File, fens, fes; vectors=vectors)
# @async run(`"paraview.exe" $File`)
true
end
for aspect in aspects
sim(aspect)
end
end # bend_hex_spectrum_ms
function bend_hex_spectrum_im_9()
function sim(aspect)
fens, fes = mesh()
fens.xyz += xyzperturbation
fens.xyz[:, 1] .*= aspect
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
applyebc!(u)
numberdofs!(u)
femm = FEMMDeforLinearIMH8(MR, IntegDomain(fes, GaussRule(3, 2)), material, 9)
vol = integratefunction(femm, geom, x -> 1.0; m = 3)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
D = eigen(Matrix(K))
savecsv("bend_hex_spectrum_im-aspect=$(aspect).csv", eigenvalues = vec(D.values))
@pgf _a = SemiLogYAxis(
{
xlabel = "Mode [ND]",
ylabel = "Generalized stiffness [N/m]",
grid = "major",
legend_pos = "south east",
title = "Hexahedron spectrum, aspect=$(aspect)",
},
Plot(
{"red", mark = "triangle"},
Table([:x => vec(7:size(K, 1)), :y => vec(D.values[7:end])]),
),
LegendEntry("IM 9"),
)
display(_a)
# File = "bend_hex_spectrum_im.vtk"
# vectors = [("ev_$(idx)_$(round(D.values[idx] * 10000) / 10000)", deepcopy(scattersysvec!(u, D.vectors[:,idx]).values)) for idx in 1:length(D.values)]
# vtkexportmesh(File, fens, fes; vectors=vectors)
# @async run(`"paraview.exe" $File`)
true
end
for aspect in aspects
sim(aspect)
end
end # bend_hex_spectrum_im
function bend_hex_spectrum_im_12()
function sim(aspect)
fens, fes = mesh()
fens.xyz += xyzperturbation
fens.xyz[:, 1] .*= aspect
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
applyebc!(u)
numberdofs!(u)
femm = FEMMDeforLinearIMH8(MR, IntegDomain(fes, GaussRule(3, 2)), material, 12)
vol = integratefunction(femm, geom, x -> 1.0; m = 3)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
D = eigen(Matrix(K))
savecsv("bend_hex_spectrum_im-aspect=$(aspect).csv", eigenvalues = vec(D.values))
@pgf _a = SemiLogYAxis(
{
xlabel = "Mode [ND]",
ylabel = "Generalized stiffness [N/m]",
grid = "major",
legend_pos = "south east",
title = "Hexahedron spectrum, aspect=$(aspect)",
},
Plot(
{"red", mark = "triangle"},
Table([:x => vec(7:size(K, 1)), :y => vec(D.values[7:end])]),
),
LegendEntry("IM 12"),
)
display(_a)
# File = "bend_hex_spectrum_im.vtk"
# vectors = [("ev_$(idx)_$(round(D.values[idx] * 10000) / 10000)", deepcopy(scattersysvec!(u, D.vectors[:,idx]).values)) for idx in 1:length(D.values)]
# vtkexportmesh(File, fens, fes; vectors=vectors)
# @async run(`"paraview.exe" $File`)
true
end
for aspect in aspects
sim(aspect)
end
end # bend_hex_spectrum_im
function allrun()
println("#####################################################")
println("# bend_hex_spectrum_full ")
bend_hex_spectrum_full()
println("#####################################################")
println("# bend_hex_spectrum_underintegrated ")
bend_hex_spectrum_underintegrated()
println("#####################################################")
println("# bend_hex_spectrum_ms ")
bend_hex_spectrum_ms()
println("#####################################################")
println("# bend_hex_spectrum_im_9 ")
bend_hex_spectrum_im_9()
println("#####################################################")
println("# bend_hex_spectrum_im_12 ")
bend_hex_spectrum_im_12()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 7190 | module comp_hex_spectrum_examples
using FinEtools
using FinEtools.MeshExportModule.CSV: savecsv
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtools.AlgoBaseModule: evalconvergencestudy
using FinEtoolsDeforLinear.AlgoDeforLinearModule:
linearstatics, exportstresselementwise, exportstress
using Statistics: mean
using LinearAlgebra: Symmetric, cholesky, eigen
using PGFPlotsX
# Isotropic material
E = 1.0
nus = [0.3 0.49 0.4999 0.499999]
# julia> rand(8,3) .* 2 .- 1.0
xyzperturbation =
[
0.0767656 -0.983206 -0.14343
0.45767 0.981479 0.450997
-0.295854 0.542922 0.321333
-0.85204 -0.97824 -0.772874
-0.0539756 0.994907 0.822798
0.447173 0.528742 0.0445352
-0.468417 0.00673427 0.953151
-0.898513 -0.915871 0.933237
] ./ 15.0
# Lambda1 = vec([-1.0 1.0 1.0 -1.0 -1.0 1.0 1.0 -1.0])
# Lambda2 = vec([-1.0 -1.0 1.0 1.0 -1.0 -1.0 1.0 1.0])
# Gamma1 = vec([1.0 1.0 -1.0 -1.0 -1.0 -1.0 1.0 1.0])
# xyzperturbation = zeros((8,3))
# xyzperturbation[:, 1] .= Lambda2 ./ 10.0
# xyzperturbation[:, 2] .= Lambda1 ./ 10.0
# xyzperturbation[:, 3] .= Gamma1 ./ 20.0
function mesh()
(
FinEtools.FENodeSetModule.FENodeSet(
[
0.0 0.0 0.0
1.0 0.0 0.0
1.0 1.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0
1.0 0.0 1.0
1.0 1.0 1.0
0.0 1.0 1.0
],
),
FinEtools.FESetModule.FESetH8(reshape([1, 2, 3, 4, 5, 6, 7, 8], 1, 8)),
)
end
function comp_hex_spectrum_full()
function sim(nu)
fens, fes = mesh()
fens.xyz += xyzperturbation
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
applyebc!(u)
numberdofs!(u)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
vol = integratefunction(femm, geom, x -> 1.0; m = 3)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
D = eigen(Matrix(K))
# File = "comp_hex_spectrum_full.vtk"
# vectors = [("ev_$(idx)_$(round(D.values[idx] * 10000) / 10000)", deepcopy(scattersysvec!(u, D.vectors[:,idx]).values)) for idx in 1:length(D.values)]
# vtkexportmesh(File, fens, fes; vectors=vectors)
# @async run(`"paraview.exe" $File`)
savecsv("comp_hex_spectrum_full-nu=$(nu).csv", eigenvalues = vec(D.values))
# @pgf _a = SemiLogYAxis({
# xlabel = "Mode [ND]",
# ylabel = "Generalized stiffness [N/m]",
# grid="major",
# legend_pos = "south east",
# title = "Hexahedron spectrum, \\nu=$(nu)"
# },
# Plot({"red", mark="triangle"}, Table([:x => vec(7:size(K, 1)), :y => vec(D.values[7:end])])), LegendEntry("FEA"))
# display(_a)
true
end
for nu in nus
sim(nu)
end
end # comp_hex_spectrum_full
function comp_hex_spectrum_underintegrated()
function sim(nu)
fens, fes = mesh()
fens.xyz += xyzperturbation
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
applyebc!(u)
numberdofs!(u)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 1)), material)
vol = integratefunction(femm, geom, x -> 1.0; m = 3)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
D = eigen(Matrix(K))
# File = "comp_hex_spectrum_full.vtk"
# vectors = [("ev_$(idx)_$(round(D.values[idx] * 10000) / 10000)", deepcopy(scattersysvec!(u, D.vectors[:,idx]).values)) for idx in 1:length(D.values)]
# vtkexportmesh(File, fens, fes; vectors=vectors)
# @async run(`"paraview.exe" $File`)
savecsv(
"comp_hex_spectrum_underintegrated-nu=$(nu).csv",
eigenvalues = vec(D.values),
)
true
end
for nu in nus
sim(nu)
end
end # comp_hex_spectrum_underintegrated
function comp_hex_spectrum_ms()
function sim(nu)
fens, fes = mesh()
fens.xyz += xyzperturbation
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
applyebc!(u)
numberdofs!(u)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
vol = integratefunction(femm, geom, x -> 1.0; m = 3)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
D = eigen(Matrix(K))
savecsv("comp_hex_spectrum_ms-nu=$(nu).csv", eigenvalues = vec(D.values))
# File = "comp_hex_spectrum_ms.vtk"
# vectors = [("ev_$(idx)_$(round(D.values[idx] * 10000) / 10000)", deepcopy(scattersysvec!(u, D.vectors[:,idx]).values)) for idx in 1:length(D.values)]
# vtkexportmesh(File, fens, fes; vectors=vectors)
# @async run(`"paraview.exe" $File`)
true
end
for nu in nus
sim(nu)
end
end # comp_hex_spectrum_ms
function comp_hex_spectrum_im()
function sim(nu)
fens, fes = mesh()
fens.xyz += xyzperturbation
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
applyebc!(u)
numberdofs!(u)
femm = FEMMDeforLinearIMH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
vol = integratefunction(femm, geom, x -> 1.0; m = 3)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
D = eigen(Matrix(K))
savecsv("comp_hex_spectrum_im-nu=$(nu).csv", eigenvalues = vec(D.values))
# File = "comp_hex_spectrum_ms.vtk"
# vectors = [("ev_$(idx)_$(round(D.values[idx] * 10000) / 10000)", deepcopy(scattersysvec!(u, D.vectors[:,idx]).values)) for idx in 1:length(D.values)]
# vtkexportmesh(File, fens, fes; vectors=vectors)
# @async run(`"paraview.exe" $File`)
true
end
for nu in nus
sim(nu)
end
end # comp_hex_spectrum_im
function allrun()
println("#####################################################")
println("# comp_hex_spectrum_full ")
comp_hex_spectrum_full()
println("#####################################################")
println("# comp_hex_spectrum_underintegrated ")
comp_hex_spectrum_underintegrated()
println("#####################################################")
println("# comp_hex_spectrum_ms ")
comp_hex_spectrum_ms()
println("#####################################################")
println("# comp_hex_spectrum_im ")
comp_hex_spectrum_im()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 2767 | module hex_ip_constr_examples
using FinEtools
using FinEtools.MeshExportModule.CSV: savecsv
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtools.AlgoBaseModule: evalconvergencestudy
using FinEtoolsDeforLinear.AlgoDeforLinearModule:
linearstatics, exportstresselementwise, exportstress
using Statistics: mean
using LinearAlgebra: Symmetric, cholesky, eigen, svd
using PGFPlotsX
function mesh()
(
FinEtools.FENodeSetModule.FENodeSet(
[
0.0 0.0 0.0
1.0 0.0 0.0
1.0 1.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0
1.0 0.0 1.0
1.0 1.0 1.0
0.0 1.0 1.0
],
),
FinEtools.FESetModule.FESetH8(reshape([1, 2, 3, 4, 5, 6, 7, 8], 1, 8)),
)
end
function hex_ip_constr_par()
fens, fes = mesh()
# integration_rule = TrapezoidalRule(3)
integration_rule = GaussRule(3, 1)
pc = integration_rule.param_coords
w = integration_rule.weights
npts = integration_rule.npts
Q = fill(0.0, npts, 24)
for j = 1:npts
gradNpar = bfundpar(fes, vec(pc[j, :]))
k = 1
for i in axes(gradNpar, 1)
Q[j, k:(k+2)] .= gradNpar[i, :]
k = k + 3
end
end
decomp = svd(Q)
@show decomp.S
true
end # hex_ip_constr_par
function hex_ip_constr_xyz()
xyzperturbation =
[
0.0767656 -0.983206 -0.14343
0.45767 0.981479 0.450997
-0.295854 0.542922 0.321333
-0.85204 -0.97824 -0.772874
-0.0539756 0.994907 0.822798
0.447173 0.528742 0.0445352
-0.468417 0.00673427 0.953151
-0.898513 -0.915871 0.933237
] ./ 5.0
fens, fes = mesh()
fens.xyz .+= xyzperturbation
# integration_rule = TrapezoidalRule(3)
integration_rule = GaussRule(3, 2)
pc = integration_rule.param_coords
w = integration_rule.weights
npts = integration_rule.npts
Q = fill(0.0, npts, 24)
for j = 1:npts
gradNpar = bfundpar(fes, vec(pc[j, :]))
J = (transpose(fens.xyz) * gradNpar)
@show gradN = gradNpar / J
k = 1
for i in axes(gradN, 1)
Q[j, k:(k+2)] .= gradN[i, :]
k = k + 3
end
end
decomp = svd(Q)
@show decomp.S
true
end # hex_ip_constr_xyz
function allrun()
println("#####################################################")
println("# hex_ip_constr_par ")
hex_ip_constr_par()
println("#####################################################")
println("# hex_ip_constr_xyz ")
hex_ip_constr_xyz()
return true
end # function allrun
end # module hex_ip_constr_examples
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 1493 | using DelimitedFiles
using PGFPlotsX
loadcsv(n) = (
open(n) do f
return readdlm(f, skipstart = 1)
end
)
table(data) = Table([:x => vec(7:length(data)), :y => vec(data[7:end])])
addtoitems!(items, n, color, mark, style) = begin
t = table(loadcsv(n))
@pgf(_p = Plot({"only marks"}, t))
_p["color"] = color
_p["style"] = style
_p["mark"] = mark
push!(items, _p)
# @pgf(_p = Plot({color, style}, t))
@pgf(_p = Plot({}, t))
_p["color"] = color
_p["style"] = style
push!(items, _p)
return items
end
styles = vec([
"solid"
"densely dashed"
"dashed"
"densely dotted"
"dotted"
"loosely dotted"
])
colors = vec(
["red" "green" "blue" "magenta" "black" "yellow" "brown" "teal" "orange" "violet" "cyan" "gray"],
)
marks = vec(["*" "square*" "triangle*" "star" "pentagon*" "diamond*" "otimes*" "p" "a"])
items = []
# ["bend_hex_spectrum_full", "bend_hex_spectrum_underintegrated", "bend_hex_spectrum_ms", "bend_hex_spectrum_im"]
for (j, basen) in enumerate(["bend_hex_spectrum_full", "bend_hex_spectrum_im"])
for (i, aspect) in enumerate([1.0 10.0 100.0 1000.0])
tag = "aspect=$(aspect)"
n = "$(basen)-$(tag).csv"
addtoitems!(items, n, colors[j], marks[j], styles[i])
end
end
@pgf _a = SemiLogYAxis(
{
xlabel = "Mode [ND]",
ylabel = "Generalized stiffness [N/m]",
grid = "major",
legend_pos = "north west",
},
items...,
)
display(_a)
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 1484 | using DelimitedFiles
using PGFPlotsX
loadcsv(n) = (
open(n) do f
return readdlm(f, skipstart = 1)
end
)
table(data) = Table([:x => vec(7:length(data)), :y => vec(data[7:end])])
addtoitems!(items, n, color, mark, style) = begin
t = table(loadcsv(n))
@pgf(_p = Plot({"only marks"}, t))
_p["color"] = color
_p["style"] = style
_p["mark"] = mark
push!(items, _p)
# @pgf(_p = Plot({color, style}, t))
@pgf(_p = Plot({}, t))
_p["color"] = color
_p["style"] = style
push!(items, _p)
return items
end
styles = vec([
"solid"
"densely dashed"
"dashed"
"densely dotted"
"dotted"
"loosely dotted"
])
colors = vec(
["red" "green" "blue" "magenta" "black" "yellow" "brown" "teal" "orange" "violet" "cyan" "gray"],
)
marks = vec(["*" "square*" "triangle*" "star" "pentagon*" "diamond*" "otimes*" "p" "a"])
items = []
# ["comp_hex_spectrum_full", "comp_hex_spectrum_underintegrated", "comp_hex_spectrum_ms", "comp_hex_spectrum_im"]
for (j, basen) in enumerate(["comp_hex_spectrum_full", "comp_hex_spectrum_im"])
for (i, nu) in enumerate([0.3 0.49 0.4999 0.499999])
tag = "nu=$(nu)"
n = "$(basen)-$(tag).csv"
addtoitems!(items, n, colors[j], marks[j], styles[i])
end
end
@pgf _a = SemiLogYAxis(
{
xlabel = "Mode [ND]",
ylabel = "Generalized stiffness [N/m]",
grid = "major",
legend_pos = "north west",
},
items...,
)
display(_a)
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 6706 | module single_hex_examples
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtools.AlgoBaseModule: evalconvergencestudy
using FinEtoolsDeforLinear.AlgoDeforLinearModule:
linearstatics, exportstresselementwise, exportstress
using Statistics: mean
using LinearAlgebra: Symmetric, cholesky, eigen, norm
# Isotropic material
E = 1.0
nu = 0.3
# julia> rand(8,3) .* 2 .- 1.0
xyzperturbation =
[
0.0767656 -0.983206 -0.14343
0.45767 0.981479 0.450997
-0.295854 0.542922 0.321333
-0.85204 -0.97824 -0.772874
-0.0539756 0.994907 0.822798
0.447173 0.528742 0.0445352
-0.468417 0.00673427 0.953151
-0.898513 -0.915871 0.933237
] ./ 5.0
# Lambda1 = vec([-1.0 1.0 1.0 -1.0 -1.0 1.0 1.0 -1.0])
# Lambda2 = vec([-1.0 -1.0 1.0 1.0 -1.0 -1.0 1.0 1.0])
# Gamma1 = vec([1.0 1.0 -1.0 -1.0 -1.0 -1.0 1.0 1.0])
# xyzperturbation = zeros((8,3))
# xyzperturbation[:, 1] .= Lambda2 ./ 10.0
# xyzperturbation[:, 2] .= Lambda1 ./ 10.0
# xyzperturbation[:, 3] .= Gamma1 ./ 20.0
function mesh(alpha = 0)
(
FinEtools.FENodeSetModule.FENodeSet(
[
0.0 0.0 0.0
1.0 0.0 0.0
1.0 1.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0
1.0 0.0 1.0
1.0 1.0 1.0
0.0 1.0 1.0
] + alpha * xyzperturbation,
),
FinEtools.FESetModule.FESetH8(reshape([1, 2, 3, 4, 5, 6, 7, 8], 1, 8)),
)
end
function single_hex_perfect_cube()
fens, fes = mesh()
File = "single_hex_perfect_cube.vtk"
vtkexportmesh(File, fens, fes)
@async run(`"paraview.exe" $File`)
true
end # single_hex_perfect_cube
function single_hex_full()
fens, fes = mesh()
fens.xyz += xyzperturbation
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
applyebc!(u)
numberdofs!(u)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
@show vol = integratefunction(femm, geom, x -> 1.0; m = 3)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
D = eigen(Matrix(K))
File = "single_hex_full.vtk"
vectors = [
(
"ev_$(idx)_$(round(D.values[idx] * 10000) / 10000)",
deepcopy(scattersysvec!(u, D.vectors[:, idx]).values),
) for idx = 1:length(D.values)
]
vtkexportmesh(File, fens, fes; vectors = vectors)
@async run(`"paraview.exe" $File`)
true
end # single_hex_full
function single_hex_underintegrated()
fens, fes = mesh()
fens.xyz += xyzperturbation
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
applyebc!(u)
numberdofs!(u)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 1)), material)
@show vol = integratefunction(femm, geom, x -> 1.0; m = 3)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
D = eigen(Matrix(K))
File = "single_hex_underintegrated.vtk"
vectors = [
(
"ev_$(idx)_$(round(D.values[idx] * 10000) / 10000)",
deepcopy(scattersysvec!(u, D.vectors[:, idx]).values),
) for idx = 1:length(D.values)
]
vtkexportmesh(File, fens, fes; vectors = vectors)
@async run(`"paraview.exe" $File`)
true
end # single_hex_underintegrated
function single_hex_ms()
fens, fes = mesh()
fens.xyz += xyzperturbation
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
applyebc!(u)
numberdofs!(u)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
@show vol = integratefunction(femm, geom, x -> 1.0; m = 3)
associategeometry!(femm, geom)
fill!(femm.phis, 0.0)
K = stiffness(femm, geom, u)
D = eigen(Matrix(K))
File = "single_hex_ms.vtk"
vectors = [
(
"ev_$(idx)_$(round(D.values[idx] * 10000) / 10000)",
deepcopy(scattersysvec!(u, D.vectors[:, idx]).values),
) for idx = 1:length(D.values)
]
vtkexportmesh(File, fens, fes; vectors = vectors)
@async run(`"paraview.exe" $File`)
true
end # single_hex_ms
function single_hex_full_scaling()
fens, fes = mesh(1.0)
@show fens.xyz
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
applyebc!(u)
numberdofs!(u)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
# @show vol = integratefunction(femm, geom, x -> 1.0; m=3)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K1 = Matrix(K)
fens, fes = mesh(1.0)
fens.xyz .*= 10
geom = NodalField(fens.xyz)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K10 = Matrix(K)
@show norm(K1 - K10) / norm(K1)
fens, fes = mesh(1.0)
fens.xyz .*= 1
geom = NodalField(fens.xyz)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K1b = Matrix(K)
@show norm(K1 - K1b) / norm(K1)
fens, fes = mesh(1.0)
fens.xyz .*= 2
geom = NodalField(fens.xyz)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K2 = Matrix(K)
@show norm(K1 - K2) / norm(K1)
fens, fes = mesh(1.0)
fens.xyz .*= 200
geom = NodalField(fens.xyz)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K200 = Matrix(K)
@show norm(K1 - K200) / norm(K1)
true
end # single_hex_full
function allrun()
println("#####################################################")
println("# single_hex_full_scaling ")
single_hex_full_scaling()
println("#####################################################")
println("# single_hex_perfect_cube ")
single_hex_perfect_cube()
println("#####################################################")
println("# single_hex_full ")
single_hex_full()
println("#####################################################")
println("# single_hex_underintegrated ")
single_hex_underintegrated()
println("#####################################################")
println("# single_hex_ms ")
single_hex_ms()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 20111 | module LE11NAFEMS_examples
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
function LE11NAFEMS_Q8_algo()
# NAFEMS LE11 benchmark with Q8 elements.
# # This is a test recommended by the National Agency for Finite Element
# # Methods and Standards (U.K.): Test LE11 from NAFEMS Publication TNSB,
# # Rev. 3, “The Standard NAFEMS Benchmarks,” October 1990.
# #
# # Target solution: Direct stress, = –105 MPa at point A.
#function LE11NAFEMS()
# Parameters:
Ea = 210000 * phun("MEGA*Pa")
nua = 0.3
alphaa = 2.3e-4 # thermal expansion coefficient
sigmaA = -105 * phun("MEGA*Pa")
nref = 1 # how many times should we refine the mesh?
X =
[
1.0 0.0#A
1.4 0.0#B
0.995184726672197 0.098017140329561
1.393258617341076 0.137223996461385
0.980785 0.195090#
1.37309939 0.27312645
0.956940335732209 0.290284677254462
1.339716470025092 0.406398548156247
0.9238795 0.38268#C
1.2124 0.7#D
0.7071 0.7071#E
1.1062 1.045#F
0.7071 (0.7071+1.79)/2#(E+H)/2
1.0 1.39#G
0.7071 1.79#H
1.0 1.79
] * phun("M")
tolerance = 1.e-6 * phun("M")
##
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the axial symmetry
# assumption.
MR = DeforModelRed2DAxisymm
fens = FENodeSet(X)
fes = FESetQ4([
1 2 4 3
3 4 6 5
5 6 8 7
7 8 10 9
9 10 12 11
11 12 14 13
13 14 16 15
])
for ref = 1:nref
fens, fes = Q4refine(fens, fes)
list = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = [0.0 0.0],
inflate = tolerance,
)
fens.xyz[list, :] = FinEtools.MeshUtilModule.ontosphere(fens.xyz[list, :], 1.0)
end
fens, fes = Q4toQ8(fens, fes)
list = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = [0.0 0.0],
inflate = tolerance,
)
fens.xyz[list, :] = FinEtools.MeshUtilModule.ontosphere(fens.xyz[list, :], 1.0)
# EBC's
l1 = selectnode(fens, box = [-Inf Inf 0 0], inflate = tolerance)
e1 = FDataDict("node_list" => l1, "component" => 2, "displacement" => x -> 0.0)
l1 = selectnode(fens, box = [-Inf Inf 1.79 1.79], inflate = tolerance)
e2 = FDataDict("node_list" => l1, "component" => 2, "displacement" => x -> 0.0)
# Temperature field
dtemp = FDataDict("temperature" => x -> x[1] + x[2])
# Property and material
material = MatDeforElastIso(MR, 0.0, Ea, nua, alphaa)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 3), true), material)
# Make region 1
region = FDataDict("femm" => femm)
# Make model data
modeldata = FDataDict(
"fens" => fens,
"regions" => [region],
"essential_bcs" => [e1, e2],
"temperature_change" => dtemp,
)
# Call the solver
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
geom = modeldata["geom"]
u = modeldata["u"]
dT = modeldata["temp"]
nA = selectnode(fens, box = FFlt[1.0 1.0 0.0 0.0], inflate = tolerance)
fld = fieldfromintegpoints(femm, geom, u, dT, :Cauchy, 2)
File = "LE11NAFEMS_Q8_sigmay.vtk"
vtkexportmesh(
File,
fens,
fes;
scalars = [("sigmay", fld.values)],
vectors = [("u", u.values)],
)
println("range of sigmay = $((minimum(fld.values), maximum(fld.values)))")
@async run(`"paraview.exe" $File`)
sA = fld.values[nA] / phun("MEGA*Pa")
sAn = fld.values[nA] / sigmaA
println("Stress at point A: $(sA) i. e. $( sAn*100 )% of reference value")
fen2fe = FENodeToFEMap(fes.conn, nnodes(geom))
function inspector(idat, elnum, conn, xe, out, xq)
println("loc = $( xq ) : $( transpose(out)/phun("MEGA*Pa") )")
return idat
end
inspectintegpoints(
femm,
geom,
u,
dT,
fen2fe.map[nA[1]],
inspector,
[];
quantity = :Cauchy,
)
end # LE11NAFEMS_Q8_algo
function LE11NAFEMS_Q8_algo2()
# NAFEMS LE11 benchmark with Q8 elements.
# # This is a test recommended by the National Agency for Finite Element
# # Methods and Standards (U.K.): Test LE11 from NAFEMS Publication TNSB,
# # Rev. 3, “The Standard NAFEMS Benchmarks,” October 1990.
# #
# # Target solution: Direct stress, = –105 MPa at point A.
#function LE11NAFEMS()
# Parameters:
Ea = 210000 * phun("MEGA*Pa")
nua = 0.3
alphaa = 2.3e-4 # thermal expansion coefficient
sigmaA = -105 * phun("MEGA*Pa")
nref = 1 # how many times should we refine the mesh?
X =
[
1.0 0.0#A
1.4 0.0#B
0.995184726672197 0.098017140329561
1.393258617341076 0.137223996461385
0.980785 0.195090#
1.37309939 0.27312645
0.956940335732209 0.290284677254462
1.339716470025092 0.406398548156247
0.9238795 0.38268#C
1.2124 0.7#D
0.7071 0.7071#E
1.1062 1.045#F
0.7071 (0.7071+1.79)/2#(E+H)/2
1.0 1.39#G
0.7071 1.79#H
1.0 1.79
] * phun("M")
tolerance = 1.e-6 * phun("M")
##
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the axial symmetry
# assumption.
MR = DeforModelRed2DAxisymm
fens = FENodeSet(X)
fes = FESetQ4([
1 2 4 3
3 4 6 5
5 6 8 7
7 8 10 9
9 10 12 11
11 12 14 13
13 14 16 15
])
for ref = 1:nref
fens, fes = Q4refine(fens, fes)
list = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = [0.0 0.0],
inflate = tolerance,
)
fens.xyz[list, :] = FinEtools.MeshUtilModule.ontosphere(fens.xyz[list, :], 1.0)
end
fens, fes = Q4toQ8(fens, fes)
list = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = [0.0 0.0],
inflate = tolerance,
)
fens.xyz[list, :] = FinEtools.MeshUtilModule.ontosphere(fens.xyz[list, :], 1.0)
# EBC's
l1 = selectnode(fens, box = [-Inf Inf 0 0], inflate = tolerance)
e1 = FDataDict("node_list" => l1, "component" => 2, "displacement" => x -> 0.0)
l1 = selectnode(fens, box = [-Inf Inf 1.79 1.79], inflate = tolerance)
e2 = FDataDict("node_list" => l1, "component" => 2, "displacement" => x -> 0.0)
# Temperature field
dtemp = FDataDict("temperature" => x -> x[1] + x[2])
# Property and material
material = MatDeforElastIso(MR, 0.0, Ea, nua, alphaa)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 3), true), material)
# Make region 1
region = FDataDict("femm" => femm)
# Make model data
modeldata = FDataDict(
"fens" => fens,
"regions" => [region],
"essential_bcs" => [e1, e2],
"temperature_change" => dtemp,
)
# Call the solver
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
geom = modeldata["geom"]
u = modeldata["u"]
dT = modeldata["temp"]
modeldata["postprocessing"] =
FDataDict("boundary_only" => true, "file" => "LE11NAFEMS_Q8_deformation.vtk")
modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
@async run(`"paraview.exe" $(modeldata["postprocessing"]["exported"][1]["file"])`)
nA = selectnode(fens, box = FFlt[1.0 1.0 0.0 0.0], inflate = tolerance)
modeldata["postprocessing"] = FDataDict(
"boundary_only" => true,
"file" => "LE11NAFEMS_Q8_sigmay.vtk",
"quantity" => :Cauchy,
"component" => 2,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
modeldata["postprocessing"] = FDataDict(
"boundary_only" => false,
"file" => "LE11NAFEMS_Q8_sigmay.vtk",
"quantity" => :Cauchy,
"component" => 2,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
@async run(`"paraview.exe" $(modeldata["postprocessing"]["exported"][1]["file"])`)
fld = modeldata["postprocessing"]["exported"][1]["field"]
sA = fld.values[nA] / phun("MEGA*Pa")
sAn = fld.values[nA] / sigmaA
println("Stress at point A: $(sA) i. e. $( sAn*100 )% of reference value")
# Loop over only those elements that share the node nA
fen2fe = FENodeToFEMap(fes.conn, nnodes(geom))
function inspector(idat, elnum, conn, xe, out, xq)
println("loc = $( xq ) : $( transpose(out)/phun("MEGA*Pa") )")
return idat
end
inspectintegpoints(
femm,
geom,
u,
dT,
fen2fe.map[nA[1]],
inspector,
[];
quantity = :Cauchy,
)
modeldata["postprocessing"] = FDataDict(
"boundary_only" => false,
"file" => "LE11NAFEMS_Q8_sigmay_ew.vtk",
"quantity" => :Cauchy,
"component" => 2,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
@async run(`"paraview.exe" $(modeldata["postprocessing"]["exported"][1]["file"])`)
end # LE11NAFEMS_Q8_algo2
function LE11NAFEMS_Q8_export_stress()
# NAFEMS LE11 benchmark with Q8 elements.
# # This is a test recommended by the National Agency for Finite Element
# # Methods and Standards (U.K.): Test LE11 from NAFEMS Publication TNSB,
# # Rev. 3, “The Standard NAFEMS Benchmarks,” October 1990.
# #
# # Target solution: Direct stress, = –105 MPa at point A.
#function LE11NAFEMS()
# Parameters:
Ea = 210000 * phun("MEGA*Pa")
nua = 0.3
alphaa = 2.3e-4 # thermal expansion coefficient
sigmaA = -105 * phun("MEGA*Pa")
nref = 2 # how many times should we refine the mesh?
X =
[
1.0 0.0#A
1.4 0.0#B
0.995184726672197 0.098017140329561
1.393258617341076 0.137223996461385
0.980785 0.195090#
1.37309939 0.27312645
0.956940335732209 0.290284677254462
1.339716470025092 0.406398548156247
0.9238795 0.38268#C
1.2124 0.7#D
0.7071 0.7071#E
1.1062 1.045#F
0.7071 (0.7071+1.79)/2#(E+H)/2
1.0 1.39#G
0.7071 1.79#H
1.0 1.79
] * phun("M")
tolerance = 1.e-6 * phun("M")
##
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the axial symmetry
# assumption.
MR = DeforModelRed2DAxisymm
fens = FENodeSet(X)
fes = FESetQ4([
1 2 4 3
3 4 6 5
5 6 8 7
7 8 10 9
9 10 12 11
11 12 14 13
13 14 16 15
])
for ref = 1:nref
fens, fes = Q4refine(fens, fes)
list = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = [0.0 0.0],
inflate = tolerance,
)
fens.xyz[list, :] = FinEtools.MeshUtilModule.ontosphere(fens.xyz[list, :], 1.0)
end
fens, fes = Q4toQ8(fens, fes)
list = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = [0.0 0.0],
inflate = tolerance,
)
fens.xyz[list, :] = FinEtools.MeshUtilModule.ontosphere(fens.xyz[list, :], 1.0)
# File = "mesh.vtk"
# vtkexportmesh(File, fens, fes)
# now we create the geometry and displacement fields
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
# Apply EBC's
lbottom = selectnode(fens, box = [-Inf Inf 0 0], inflate = tolerance)
setebc!(u, lbottom, true, 2, 00.0)
ltop = selectnode(fens, box = [-Inf Inf 1.79 1.79], inflate = tolerance)
setebc!(u, ltop, true, 2, 00.0)
applyebc!(u)
numberdofs!(u)
# Temperature field
dT = NodalField(reshape(fens.xyz[:, 1] + fens.xyz[:, 2], size(fens.xyz, 1), 1))
# Property and material
material = MatDeforElastIso(MR, 0.0, Ea, nua, alphaa)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 3), true), material)
K = stiffness(femm, geom, u)
F = thermalstrainloads(femm, geom, u, dT)
#K = cholesky(K)
U = K \ F
scattersysvec!(u, U[:])
nA = selectnode(fens, box = FFlt[1.0 1.0 0.0 0.0], inflate = tolerance)
fld = fieldfromintegpoints(femm, geom, u, dT, :Cauchy, 2)
File = "LE11NAFEMS_Q8_sigmay.vtk"
vtkexportmesh(
File,
fens,
fes;
scalars = [("sigmay", fld.values)],
vectors = [("u", u.values)],
)
println("range of sigmay = $((minimum(fld.values), maximum(fld.values)))")
@async run(`"paraview.exe" $File`)
sA = fld.values[nA] / phun("MEGA*Pa")
sAn = fld.values[nA] / sigmaA
println("Stress at point A: $(sA) i. e. $( sAn*100 )% of reference value")
fen2fe = FENodeToFEMap(fes.conn, nnodes(geom))
function inspector(idat, elnum, conn, xe, out, xq)
# println("loc = $( xq ) : $( transpose(out)/phun("MEGA*Pa") )")
return idat
end
inspectintegpoints(
femm,
geom,
u,
dT,
fen2fe.map[nA[1]],
inspector,
[];
quantity = :Cauchy,
)
fld = fieldfromintegpoints(femm, geom, u, dT, :Pressure, 1)
File = "LE11NAFEMS_Q8_pressure.vtk"
vtkexportmesh(
File,
fens,
fes;
scalars = [("pressure", fld.values)],
vectors = [("u", u.values)],
)
println("range of pressure = $((minimum(fld.values), maximum(fld.values)))")
@async run(`"paraview.exe" $File`)
fld = fieldfromintegpoints(femm, geom, u, dT, :vm, 1)
File = "LE11NAFEMS_Q8_vm.vtk"
vtkexportmesh(
File,
fens,
fes;
scalars = [("pressure", fld.values)],
vectors = [("u", u.values)],
)
println("range of von Mises = $((minimum(fld.values), maximum(fld.values)))")
@async run(`"paraview.exe" $File`)
AE = AbaqusExporter("LE11NAFEMS_Q8_export_stress")
HEADING(AE, "NAFEMS LE11 benchmark with Q8 elements.")
COMMENT(AE, "sigmaA = -105 MPa ")
PART(AE, "part1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
ELEMENT(AE, "cax8", "AllElements", 1, connasarray(fes))
NSET_NSET(AE, "ltop", ltop)
NSET_NSET(AE, "lbottom", lbottom)
ORIENTATION(AE, "GlobalOrientation", vec([1.0 0 0]), vec([0 1.0 0]))
SOLID_SECTION(AE, "elasticity", "GlobalOrientation", "AllElements")
SURFACE_SECTION(AE, "TractionElements")
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "elasticity")
ELASTIC(AE, Ea, nua)
EXPANSION(AE, alphaa)
STEP_PERTURBATION_STATIC(AE)
BOUNDARY(AE, "ASSEM1.INSTNC1.ltop", 2)
BOUNDARY(AE, "ASSEM1.INSTNC1.lbottom", 2)
TEMPERATURE(AE, "ASSEM1.INSTNC1.", collect(1:count(fens)), vec(dT.values))
END_STEP(AE)
close(AE)
end # LE11NAFEMS_Q8_export_stress
function LE11NAFEMS_Q8_stress()
# NAFEMS LE11 benchmark with Q8 elements.
# # This is a test recommended by the National Agency for Finite Element
# # Methods and Standards (U.K.): Test LE11 from NAFEMS Publication TNSB,
# # Rev. 3, “The Standard NAFEMS Benchmarks,” October 1990.
# #
# # Target solution: Direct stress, = –105 MPa at point A.
#function LE11NAFEMS()
# Parameters:
Ea = 210000 * phun("MEGA*Pa")
nua = 0.3
alphaa = 2.3e-4 # thermal expansion coefficient
sigmaA = -105 * phun("MEGA*Pa")
nref = 1 # how many times should we refine the mesh?
X =
[
1.0 0.0#A
1.4 0.0#B
0.995184726672197 0.098017140329561
1.393258617341076 0.137223996461385
0.980785 0.195090#
1.37309939 0.27312645
0.956940335732209 0.290284677254462
1.339716470025092 0.406398548156247
0.9238795 0.38268#C
1.2124 0.7#D
0.7071 0.7071#E
1.1062 1.045#F
0.7071 (0.7071+1.79)/2#(E+H)/2
1.0 1.39#G
0.7071 1.79#H
1.0 1.79
] * phun("M")
tolerance = 1.e-6 * phun("M")
##
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the axial symmetry
# assumption.
MR = DeforModelRed2DAxisymm
fens = FENodeSet(X)
fes = FESetQ4([
1 2 4 3
3 4 6 5
5 6 8 7
7 8 10 9
9 10 12 11
11 12 14 13
13 14 16 15
])
for ref = 1:nref
fens, fes = Q4refine(fens, fes)
list = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = [0.0 0.0],
inflate = tolerance,
)
fens.xyz[list, :] = FinEtools.MeshUtilModule.ontosphere(fens.xyz[list, :], 1.0)
end
fens, fes = Q4toQ8(fens, fes)
list = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = [0.0 0.0],
inflate = tolerance,
)
fens.xyz[list, :] = FinEtools.MeshUtilModule.ontosphere(fens.xyz[list, :], 1.0)
# File = "mesh.vtk"
# vtkexportmesh(File, fens, fes)
# now we create the geometry and displacement fields
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
# Apply EBC's
l1 = selectnode(fens, box = [-Inf Inf 0 0], inflate = tolerance)
setebc!(u, l1, true, 2, 00.0)
l1 = selectnode(fens, box = [-Inf Inf 1.79 1.79], inflate = tolerance)
setebc!(u, l1, true, 2, 00.0)
applyebc!(u)
numberdofs!(u)
# Temperature field
dT = NodalField(reshape(fens.xyz[:, 1] + fens.xyz[:, 2], size(fens.xyz, 1), 1))
# Property and material
material = MatDeforElastIso(MR, 0.0, Ea, nua, alphaa)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 3), true), material)
K = stiffness(femm, geom, u)
F = thermalstrainloads(femm, geom, u, dT)
#K = cholesky(K)
U = K \ F
scattersysvec!(u, U[:])
nA = selectnode(fens, box = FFlt[1.0 1.0 0.0 0.0], inflate = tolerance)
fld = fieldfromintegpoints(femm, geom, u, dT, :Cauchy, 2)
File = "LE11NAFEMS_Q8_sigmay.vtk"
vtkexportmesh(
File,
fens,
fes;
scalars = [("sigmay", fld.values)],
vectors = [("u", u.values)],
)
println("range of sigmay = $((minimum(fld.values), maximum(fld.values)))")
@async run(`"paraview.exe" $File`)
sA = fld.values[nA] / phun("MEGA*Pa")
sAn = fld.values[nA] / sigmaA
println("Stress at point A: $(sA) i. e. $( sAn*100 )% of reference value")
fen2fe = FENodeToFEMap(fes.conn, nnodes(geom))
function inspector(idat, elnum, conn, xe, out, xq)
println("loc = $( xq ) : $( transpose(out)/phun("MEGA*Pa") )")
return idat
end
inspectintegpoints(
femm,
geom,
u,
dT,
fen2fe.map[nA[1]],
inspector,
[];
quantity = :Cauchy,
)
end # LE11NAFEMS_Q8_stress
function allrun()
println("#####################################################")
println("# LE11NAFEMS_Q8_algo ")
LE11NAFEMS_Q8_algo()
println("#####################################################")
println("# LE11NAFEMS_Q8_algo2 ")
LE11NAFEMS_Q8_algo2()
println("#####################################################")
println("# LE11NAFEMS_Q8_export_stress ")
LE11NAFEMS_Q8_export_stress()
println("#####################################################")
println("# LE11NAFEMS_Q8_stress ")
LE11NAFEMS_Q8_stress()
return true
end # function allrun
end # module LE11NAFEMS_examples
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 9765 | module LE1NAFEMS_examples
using FinEtools
using FinEtoolsDeforLinear
using FinEtools.MeshExportModule
using LinearAlgebra: cholesky, norm
using PGFPlotsX
function LE1NAFEMS()
println("LE1NAFEMS, plane stress.")
t0 = time()
E = 210e3 * phun("MEGA*PA")# 210e3 MPa
nu = 0.3
p = 10 * phun("MEGA*PA")# 10 MPA Outward pressure on the outside ellipse
sigma_yD = 92.7 * phun("MEGA*PA")# tensile stress at [2.0, 0.0] meters
Radius = 1.0 * phun("m")
n = 64 # number of elements per side
tolerance = 1.0 / n / 1000.0#Geometrical tolerance
fens, fes = Q4block(1.0, pi / 2, n, n * 2)
bdryfes = meshboundary(fes)
icl = selectelem(fens, bdryfes, box = [1.0, 1.0, 0.0, pi / 2], inflate = tolerance)
for i = 1:count(fens)
t = fens.xyz[i, 1]
a = fens.xyz[i, 2]
fens.xyz[i, :] =
[(t * 3.25 + (1 - t) * 2) * cos(a) (t * 2.75 + (1 - t) * 1) * sin(a)]
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
l1 = selectnode(fens; box = [0.0 Inf 0.0 0.0], inflate = tolerance)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(fens; box = [0.0 0.0 0.0 Inf], inflate = tolerance)
setebc!(u, l1, true, 1, 0.0)
applyebc!(u)
numberdofs!(u)
el1femm = FEMMBase(IntegDomain(subset(bdryfes, icl), GaussRule(1, 2)))
function pfun(forceout::FFltVec, x::FFltMat, J::FFltMat, l::FInt)
pt = [2.75 / 3.25 * x[1] 3.25 / 2.75 * x[2]]
copyto!(forceout, vec(p * pt / norm(pt)))
return forceout
end
fi = ForceIntensity(Float64, 2, pfun)
F2 = distribloads(el1femm, geom, u, fi, 2)
MR = DeforModelRed2DStress
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 2)), material)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (F2)
scattersysvec!(u, U[:])
nl = selectnode(fens, box = [2.0, 2.0, 0.0, 0.0], inflate = tolerance)
thecorneru = zeros(FFlt, 1, 2)
gathervalues_asmat!(u, thecorneru, nl)
thecorneru = thecorneru / phun("mm")
println(
"$(time()-t0) [s]; displacement =$(thecorneru) [MM] as compared to reference [-0.10215,0] [MM]",
)
fld = fieldfromintegpoints(femm, geom, u, :Cauchy, 2)
println(
" Target stress: $(fld.values[nl][1]/phun("MEGA*PA")) compared to $(sigma_yD/phun("MEGA*PA"))",
)
File = "a.vtk"
vtkexportmesh(
File,
fes.conn,
geom.values,
FinEtools.MeshExportModule.Q4;
vectors = [("u", u.values)],
)
@async run(`"paraview.exe" $File`)
true
end # LE1NAFEMS
function LE1NAFEMS_Q4_convergence()
println("LE1NAFEMS, 2D version.")
t0 = time()
E = 210e3 * phun("MEGA*PA")
nu = 0.3
p = 10 * phun("MEGA*PA")# 10 MPA Outward pressure on the outside ellipse
sigma_yD = 92.7 * phun("MEGA*PA")# tensile stress at [2.0, 0.0] meters
Radius = 1.0 * phun("m")
Thickness = 0.1 * phun("m")
sigyderrs = Dict{Symbol,FFltVec}()
nelems = []
for extrapolation in [:extrapmean]
sigyderrs[extrapolation] = FFltVec[]
nelems = []
for n in [16, 32, 64, 128, 256, 512]
tolerance = 1.0 / n / 1000.0 # Geometrical tolerance
fens, fes = Q4block(1.0, pi / 2, n, n)
bdryfes = meshboundary(fes)
icl = selectelem(
fens,
bdryfes,
box = [1.0, 1.0, 0.0, pi / 2],
inflate = tolerance,
)
for i = 1:count(fens)
t = fens.xyz[i, 1]
a = fens.xyz[i, 2]
fens.xyz[i, :] =
[(t * 3.25 + (1 - t) * 2) * cos(a), (t * 2.75 + (1 - t) * 1) * sin(a)]
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
l1 = selectnode(fens; box = [0.0, Inf, 0.0, 0.0], inflate = tolerance)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(fens; box = [0.0, 0.0, 0.0, Inf], inflate = tolerance)
setebc!(u, l1, true, 1, 0.0)
applyebc!(u)
numberdofs!(u)
el1femm =
FEMMBase(IntegDomain(subset(bdryfes, icl), GaussRule(1, 2), Thickness))
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
) where {T}
pt = [2.75 / 3.25 * XYZ[1], 3.25 / 2.75 * XYZ[2]]
forceout .= vec(p * pt / norm(pt))
return forceout
end
fi = ForceIntensity(Float64, 2, pfun)
F2 = distribloads(el1femm, geom, u, fi, 2)
# Note that the material object needs to be created for plane stress.
MR = DeforModelRed2DStress
material = MatDeforElastIso(MR, E, nu)
femm =
FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 2), Thickness), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (F2)
scattersysvec!(u, U[:])
nl = selectnode(fens, box = [2.0, 2.0, 0.0, 0.0], inflate = tolerance)
thecorneru = zeros(FFlt, 1, 2)
gathervalues_asmat!(u, thecorneru, nl)
thecorneru = thecorneru / phun("mm")
println(
"$(time()-t0) [s]; displacement =$(thecorneru) [MM] as compared to reference [-0.10215,0] [MM]",
)
fld = fieldfromintegpoints(femm, geom, u, :Cauchy, 2)
println(
"Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) vs $(sigma_yD/phun("MPa")) [MPa]",
)
println("$(n), $(fld.values[nl,1][1]/phun("MPa"))")
push!(nelems, count(fes))
push!(sigyderrs[extrapolation], abs(fld.values[nl, 1][1] / sigma_yD - 1.0))
# File = "a.vtk"
# vtkexportmesh(File, fes.conn, geom.values,
# FinEtools.MeshExportModule.H8; vectors=[("u", u.values)],
# scalars=[("sigmay", fld.values)])
# @async run(`"paraview.exe" $File`)
end
end
@pgf a = LogLogAxis(
{
xlabel = "Number of elements",
ylabel = "Norm. approx. error",
title = "Convergence",
},
Plot(Table([:x => vec(Float64.(nelems)), :y => vec(sigyderrs[:extrapmean])])),
LegendEntry("Extrapolated stress"),
)
display(a)
true
end # LE1NAFEMS_Q4_convergence
function LE1NAFEMS_Q8_stress()
println("LE1NAFEMS, plane stress.")
t0 = time()
E = 210e3 * phun("MEGA*PA")# 210e3 MPa
nu = 0.3
p = 10 * phun("MEGA*PA")# 10 MPA Outward pressure on the outside ellipse
sigma_yD = 92.7 * phun("MEGA*PA")# tensile stress at [2.0, 0.0] meters
Radius = 1.0 * phun("m")
n = 20 # number of elements per side
tolerance = 1.0 / n / 1000.0#Geometrical tolerance
fens, fes = Q8block(1.0, pi / 2, n, n * 2)
bdryfes = meshboundary(fes)
icl = selectelem(fens, bdryfes, box = [1.0, 1.0, 0.0, pi / 2], inflate = tolerance)
for i = 1:count(fens)
t = fens.xyz[i, 1]
a = fens.xyz[i, 2]
fens.xyz[i, :] =
[(t * 3.25 + (1 - t) * 2) * cos(a) (t * 2.75 + (1 - t) * 1) * sin(a)]
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
l1 = selectnode(fens; box = [0.0 Inf 0.0 0.0], inflate = tolerance)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(fens; box = [0.0 0.0 0.0 Inf], inflate = tolerance)
setebc!(u, l1, true, 1, 0.0)
applyebc!(u)
numberdofs!(u)
el1femm = FEMMBase(IntegDomain(subset(bdryfes, icl), GaussRule(1, 3)))
function pfun(forceout::FFltVec, x::FFltMat, J::FFltMat, l::FInt)
pt = [2.75 / 3.25 * x[1] 3.25 / 2.75 * x[2]]
copyto!(forceout, vec(p * pt / norm(pt)))
return forceout
end
fi = ForceIntensity(Float64, 2, pfun)
F2 = distribloads(el1femm, geom, u, fi, 2)
MR = DeforModelRed2DStress
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 3)), material)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (F2)
scattersysvec!(u, U[:])
nl = selectnode(fens, box = [2.0, 2.0, 0.0, 0.0], inflate = tolerance)
thecorneru = zeros(FFlt, 1, 2)
gathervalues_asmat!(u, thecorneru, nl)
thecorneru = thecorneru / phun("mm")
println(
"$(time()-t0) [s]; displacement =$(thecorneru) [MM] as compared to reference [-0.10215,0] [MM]",
)
fld = fieldfromintegpoints(femm, geom, u, :Cauchy, 2)
println(
" Target stress: $(fld.values[nl][1]/phun("MEGA*PA")) compared to $(sigma_yD/phun("MEGA*PA"))",
)
File = "a.vtk"
vtkexportmesh(
File,
fes.conn,
geom.values,
FinEtools.MeshExportModule.Q8;
vectors = [("u", u.values)],
scalars = [("sigy", fld.values)],
)
@async run(`"paraview.exe" $File`)
true
end # LE1NAFEMS_Q8_stress
function allrun()
println("#####################################################")
println("# LE1NAFEMS ")
LE1NAFEMS()
println("#####################################################")
println("# LE1NAFEMS_Q4_convergence ")
LE1NAFEMS_Q4_convergence()
println("#####################################################")
println("# LE1NAFEMS_Q8_stress ")
LE1NAFEMS_Q8_stress()
return true
end # function allrun
end # module LE1NAFEMS_examples
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 2492 | module Planar_truss_examples
using FinEtools
using FinEtoolsDeforLinear
using FinEtools.FENodeSetModule
using FinEtools.MeshExportModule
using LinearAlgebra
function Planar_truss()
# Planar truss structure loaded with concentrated forces at some nodes.
# The nodal displacements should be
# 0 0
# 0 0
# 0.0213 0.0408
# -0.0160 0.0462
# 0.0427 0.1501
# -0.0053 0.1661
Area = 1.5
E = 1.0e7 # Young's modulus
nu = 0.0
alpha = 0.0
fens = FENodeSetModule.FENodeSet([
0.0 0
0 40
40 0
40 40
80 0
80 40
])
fes = FESetL2([
1 3
1 4
2 4
3 4
3 5
5 4
6 4
5 6
])
MR = DeforModelRed1D
material = MatDeforElastIso(MR, 0.0, E, nu, alpha)
# display(material )
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
setebc!(u, 1)
setebc!(u, 2)
applyebc!(u)
numberdofs!(u)
display(u)
integdata = IntegDomain(fes, GaussRule(1, 1), (loc, conn, N) -> Area, false)
femm = FEMMDeforLinear(MR, integdata, CSys(2, 1), material)
display(femm.mcsys)
K = stiffness(femm, geom, u)
fi = ForceIntensity(vec([0 -2000.0]))
lfemm = FEMMBase(IntegDomain(FESetP1(reshape([3], 1, 1)), PointRule()))
F = distribloads(lfemm, geom, u, fi, 3)
fi = ForceIntensity(vec([+2000.0 0]))
lfemm = FEMMBase(IntegDomain(FESetP1(reshape([5], 1, 1)), PointRule()))
F = F + distribloads(lfemm, geom, u, fi, 3)
fi = ForceIntensity(vec([+4000.0 +6000.0]))
lfemm = FEMMBase(IntegDomain(FESetP1(reshape([6], 1, 1)), PointRule()))
F = F + distribloads(lfemm, geom, u, fi, 3)
K = cholesky(K)
U = K \ F
scattersysvec!(u, U[:])
sfld = elemfieldfromintegpoints(femm, geom, u, :Cauchy, 1)
display(sfld)
println("Cauchy = $(sfld.values)")
vfld = elemfieldfromintegpoints(femm, geom, u, :vm, 1)
display(vfld)
File = "Planar_truss.vtk"
MeshExportModule.vtkexportmesh(
File,
fens,
fes;
scalars = [("sx", sfld.values), ("vm", vfld.values)],
)
@async run(`"paraview.exe" $File`)
# try rm(File) catch end
end # Planar_truss
function allrun()
println("#####################################################")
println("# Planar_truss ")
Planar_truss()
return true
end # function allrun
end # module Planar_truss_examples
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 13259 | module cookstrain_examples
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtools.MeshExportModule
function cookstrain_algo_export()
E = 1.0
nu = 1.0 / 3
width = 48.0
height = 44.0
thickness = 1.0
free_height = 16.0
Mid_edge = [48.0, 52.0]# Location of tracked deflection
magn = 1.0 / (free_height * thickness)# Density of applied load
convutip = 23.97
n = 30# number of elements per side
tolerance = minimum([width, height]) / n / 1000.0#Geometrical tolerance
fens, fes = T3block(width, height, n, n)
# Reshape into a trapezoidal panel
for i in eachindex(fens)
fens.xyz[i, 2] =
fens.xyz[i, 2] +
(fens.xyz[i, 1] / width) *
(height - fens.xyz[i, 2] / height * (height - free_height))
end
# Clamped edge of the membrane
l1 = selectnode(fens; box = [0.0, 0.0, -Inf, Inf], inflate = tolerance)
ess1 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => l1)
ess2 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => l1)
# Traction on the opposite edge
boundaryfes = meshboundary(fes)
Toplist =
selectelem(fens, boundaryfes, box = [width, width, -Inf, Inf], inflate = tolerance)
el1femm =
FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(1, 2), thickness))
flux1 = FDataDict("traction_vector" => [0.0, +magn], "femm" => el1femm)
# Make the region
MR = DeforModelRed2DStrain
material = MatDeforElastIso(MR, 0.0, E, nu, 0.0)
region1 = FDataDict(
"femm" =>
FEMMDeforLinear(MR, IntegDomain(fes, TriRule(1), thickness), material),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [ess1, ess2],
"traction_bcs" => [flux1],
)
# Call the solver
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# Extract the solution
nl = selectnode(
fens,
box = [Mid_edge[1], Mid_edge[1], Mid_edge[2], Mid_edge[2]],
inflate = tolerance,
)
theutip = u.values[nl, :]
println("displacement =$(theutip[2]) as compared to converged $convutip")
modeldata["postprocessing"] =
FDataDict("file" => "cookstress-ew", "quantity" => :Cauchy, "component" => :xy)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
println("range of Cauchy_xy = $((minimum(fld.values), maximum(fld.values)))")
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`)
modeldata["postprocessing"] =
FDataDict("file" => "cookstress-ew-vm", "quantity" => :vm, "component" => 1)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
println("range of vm = $((minimum(fld.values), maximum(fld.values)))")
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`)
modeldata["postprocessing"] = FDataDict(
"file" => "cookstress-ew-pressure",
"quantity" => :pressure,
"component" => 1,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
println("range of pressure = $((minimum(fld.values), maximum(fld.values)))")
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`)
modeldata["postprocessing"] = FDataDict(
"file" => "cookstress-ew-princ1",
"quantity" => :princCauchy,
"component" => 1,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
println("range of princCauchy Max = $((minimum(fld.values), maximum(fld.values)))")
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`)
modeldata["postprocessing"] = FDataDict(
"file" => "cookstress-ew-princ3",
"quantity" => :princCauchy,
"component" => 3,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
println("range of princCauchy Min = $((minimum(fld.values), maximum(fld.values)))")
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`)
AE = AbaqusExporter("Cookstress_algo_stress")
HEADING(AE, "Cook trapezoidal panel, plane stress")
COMMENT(AE, "Converged free mid-edge displacement = 23.97")
PART(AE, "part1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
COMMENT(AE, "We are assuming three node triangles in plane-stress")
COMMENT(AE, "CPE3 are pretty poor-accuracy elements, but here we don't care about it.")
@assert nodesperelem(modeldata["regions"][1]["femm"].integdomain.fes) == 3
ELEMENT(
AE,
"CPE3",
"AllElements",
connasarray(modeldata["regions"][1]["femm"].integdomain.fes),
)
NSET_NSET(AE, "clamped", modeldata["essential_bcs"][1]["node_list"])
ORIENTATION(AE, "GlobalOrientation", vec([1.0 0 0]), vec([0 1.0 0]))
SOLID_SECTION(AE, "elasticity", "GlobalOrientation", "AllElements", thickness)
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "elasticity")
ELASTIC(AE, E, nu)
STEP_PERTURBATION_STATIC(AE)
BOUNDARY(AE, "ASSEM1.INSTNC1.clamped", 1)
BOUNDARY(AE, "ASSEM1.INSTNC1.clamped", 2)
bfes = modeldata["traction_bcs"][1]["femm"].integdomain.fes
COMMENT(AE, "Concentrated loads: we are assuming that the elements on the boundary")
COMMENT(AE, "have two nodes each and also that they are the same length.")
COMMENT(AE, "Then the concentrated loads below will be correctly lumped.")
nl = connectednodes(bfes)
F = zeros(count(modeldata["fens"]))
for ix in eachindex(bfes)
for jx = 1:2
F[bfes.conn[ix][jx]] += 1.0 / n / 2 / thickness
end
end
for ixxxx in eachindex(F)
if F[ixxxx] != 0.0
CLOAD(AE, "ASSEM1.INSTNC1.$(ixxxx)", 2, F[ixxxx])
end
end
END_STEP(AE)
close(AE)
true
end # cookstrain_algo_export
function cookstrain_algo_export_ortho()
E = 1.0
nu = 1.0 / 3
width = 48.0
height = 44.0
thickness = 1.0
free_height = 16.0
Mid_edge = [48.0, 52.0]# Location of tracked deflection
magn = 1.0 / (free_height * thickness)# Density of applied load
convutip = 23.97
n = 30# number of elements per side
tolerance = minimum([width, height]) / n / 1000.0#Geometrical tolerance
fens, fes = T3block(width, height, n, n)
# Reshape into a trapezoidal panel
for i in eachindex(fens)
fens.xyz[i, 2] =
fens.xyz[i, 2] +
(fens.xyz[i, 1] / width) *
(height - fens.xyz[i, 2] / height * (height - free_height))
end
# Clamped edge of the membrane
l1 = selectnode(fens; box = [0.0, 0.0, -Inf, Inf], inflate = tolerance)
ess1 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => l1)
ess2 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => l1)
# Traction on the opposite edge
boundaryfes = meshboundary(fes)
Toplist =
selectelem(fens, boundaryfes, box = [width, width, -Inf, Inf], inflate = tolerance)
el1femm =
FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(1, 2), thickness))
flux1 = FDataDict("traction_vector" => [0.0, +magn], "femm" => el1femm)
# Make the region
MR = DeforModelRed2DStrain
material = MatDeforElastOrtho(MR, 0.0, E, nu, 0.0)
region1 = FDataDict(
"femm" =>
FEMMDeforLinear(MR, IntegDomain(fes, TriRule(1), thickness), material),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [ess1, ess2],
"traction_bcs" => [flux1],
)
# Call the solver
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# Extract the solution
nl = selectnode(
fens,
box = [Mid_edge[1], Mid_edge[1], Mid_edge[2], Mid_edge[2]],
inflate = tolerance,
)
theutip = u.values[nl, :]
println("displacement =$(theutip[2]) as compared to converged $convutip")
modeldata["postprocessing"] =
FDataDict("file" => "cookstress-ew", "quantity" => :Cauchy, "component" => :xy)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
println("range of Cauchy_xy = $((minimum(fld.values), maximum(fld.values)))")
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`)
modeldata["postprocessing"] =
FDataDict("file" => "cookstress-ew-vm", "quantity" => :vm, "component" => 1)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
println("range of vm = $((minimum(fld.values), maximum(fld.values)))")
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`)
modeldata["postprocessing"] = FDataDict(
"file" => "cookstress-ew-pressure",
"quantity" => :pressure,
"component" => 1,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
println("range of pressure = $((minimum(fld.values), maximum(fld.values)))")
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`)
modeldata["postprocessing"] = FDataDict(
"file" => "cookstress-ew-princ1",
"quantity" => :princCauchy,
"component" => 1,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
println("range of princCauchy Max = $((minimum(fld.values), maximum(fld.values)))")
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`)
modeldata["postprocessing"] = FDataDict(
"file" => "cookstress-ew-princ3",
"quantity" => :princCauchy,
"component" => 3,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
println("range of princCauchy Min = $((minimum(fld.values), maximum(fld.values)))")
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`)
AE = AbaqusExporter("Cookstress_algo_stress")
HEADING(AE, "Cook trapezoidal panel, plane stress")
COMMENT(AE, "Converged free mid-edge displacement = 23.97")
PART(AE, "part1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
COMMENT(AE, "We are assuming three node triangles in plane-stress")
COMMENT(AE, "CPE3 are pretty poor-accuracy elements, but here we don't care about it.")
@assert nodesperelem(modeldata["regions"][1]["femm"].integdomain.fes) == 3
ELEMENT(
AE,
"CPE3",
"AllElements",
connasarray(modeldata["regions"][1]["femm"].integdomain.fes),
)
NSET_NSET(AE, "clamped", modeldata["essential_bcs"][1]["node_list"])
ORIENTATION(AE, "GlobalOrientation", vec([1.0 0 0]), vec([0 1.0 0]))
SOLID_SECTION(AE, "elasticity", "GlobalOrientation", "AllElements", thickness)
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "elasticity")
ELASTIC(AE, E, nu)
STEP_PERTURBATION_STATIC(AE)
BOUNDARY(AE, "ASSEM1.INSTNC1.clamped", 1)
BOUNDARY(AE, "ASSEM1.INSTNC1.clamped", 2)
bfes = modeldata["traction_bcs"][1]["femm"].integdomain.fes
COMMENT(AE, "Concentrated loads: we are assuming that the elements on the boundary")
COMMENT(AE, "have two nodes each and also that they are the same length.")
COMMENT(AE, "Then the concentrated loads below will be correctly lumped.")
nl = connectednodes(bfes)
F = zeros(count(modeldata["fens"]))
for ix in eachindex(bfes)
for jx = 1:2
F[bfes.conn[ix][jx]] += 1.0 / n / 2 / thickness
end
end
for ixxxx in eachindex(F)
if F[ixxxx] != 0.0
CLOAD(AE, "ASSEM1.INSTNC1.$(ixxxx)", 2, F[ixxxx])
end
end
END_STEP(AE)
close(AE)
true
end # cookstrain_algo_export_ortho
function allrun()
println("#####################################################")
println("# cookstrain_algo_export ")
cookstrain_algo_export()
println("#####################################################")
println("# cookstrain_algo_export_ortho ")
cookstrain_algo_export_ortho()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module cookstrain_examples
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 27384 | module cookstress_examples
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtools.MeshExportModule
import LinearAlgebra: cholesky
using ILUZero
using SkylineSolvers
using SuiteSparse
using SparseArrays
using SymRCM
using UnicodePlots
function cookstress()
println("Cook membrane problem, plane stress.")
t0 = time()
E = 1.0
nu = 1.0 / 3
width = 48.0
height = 44.0
thickness = 1.0
free_height = 16.0
Mid_edge = [48.0, 52.0]# Location of tracked deflection
magn = 1.0 / free_height# Magnitude of applied load
convutip = 23.97
n = 32#*int(round(sqrt(170.)/2.)); # number of elements per side
tolerance = minimum([width, height]) / n / 1000.0#Geometrical tolerance
fens, fes = T3block(width, height, n, n)
# Reshape into a trapezoidal panel
for i in eachindex(fens)
fens.xyz[i, 2] =
fens.xyz[i, 2] +
(fens.xyz[i, 1] / width) *
(height - fens.xyz[i, 2] / height * (height - free_height))
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
l1 = selectnode(fens; box = [0, 0, -Inf, Inf], inflate = tolerance)
setebc!(u, l1, 1, 0.0)
setebc!(u, l1, 2, 0.0)
applyebc!(u)
numberdofs!(u)
@time boundaryfes = meshboundary(fes)
Toplist =
selectelem(fens, boundaryfes, box = [width, width, -Inf, Inf], inflate = tolerance)
el1femm = FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(1, 2)))
fi = ForceIntensity([0.0, +magn])
F2 = distribloads(el1femm, geom, u, fi, 2)
MR = DeforModelRed2DStress
material = MatDeforElastIso(MR, 0.0, E, nu, 0.0)
femm = FEMMDeforLinear(MR, IntegDomain(fes, TriRule(1)), material)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (F2)
scattersysvec!(u, U[:])
nl = selectnode(
fens,
box = [Mid_edge[1], Mid_edge[1], Mid_edge[2], Mid_edge[2]],
inflate = tolerance,
)
theutip = zeros(FFlt, 1, 2)
gathervalues_asmat!(u, theutip, nl)
println(
"$(time()-t0) [s]; displacement =$(theutip[2]) as compared to converged $convutip",
)
File = "a.vtk"
vtkexportmesh(
File,
fes.conn,
geom.values + u.values,
FinEtools.MeshExportModule.T3;
vectors = [("u", u.values)],
)
true
end # cookstress
function cookstress_algo()
E = 1.0
nu = 1.0 / 3
width = 48.0
height = 44.0
thickness = 1.0
free_height = 16.0
Mid_edge = [48.0, 52.0]# Location of tracked deflection
magn = 1.0 / free_height# Magnitude of applied load
convutip = 23.97
n = 20#*int(round(sqrt(170.)/2.)); # number of elements per side
tolerance = minimum([width, height]) / n / 1000.0#Geometrical tolerance
fens, fes = T3block(width, height, n, n)
# Reshape into a trapezoidal panel
for i in eachindex(fens)
fens.xyz[i, 2] =
fens.xyz[i, 2] +
(fens.xyz[i, 1] / width) *
(height - fens.xyz[i, 2] / height * (height - free_height))
end
# Clamped edge of the membrane
l1 = selectnode(fens; box = [0.0, 0.0, -Inf, Inf], inflate = tolerance)
ess1 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => l1)
ess2 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => l1)
# Traction on the opposite edge
boundaryfes = meshboundary(fes)
Toplist =
selectelem(fens, boundaryfes, box = [width, width, -Inf, Inf], inflate = tolerance)
el1femm = FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(1, 2)))
flux1 = FDataDict("traction_vector" => [0.0, +magn], "femm" => el1femm)
# Make the region
MR = DeforModelRed2DStress
material = MatDeforElastIso(MR, 0.0, E, nu, 0.0)
region1 =
FDataDict("femm" => FEMMDeforLinear(MR, IntegDomain(fes, TriRule(1)), material))
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [ess1, ess2],
"traction_bcs" => [flux1],
)
# Call the solver
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# Extract the solution
nl = selectnode(
fens,
box = [Mid_edge[1], Mid_edge[1], Mid_edge[2], Mid_edge[2]],
inflate = tolerance,
)
theutip = u.values[nl, :]
println("displacement =$(theutip[2]) as compared to converged $convutip")
modeldata["postprocessing"] =
FDataDict("file" => "cookstress", "quantity" => :Cauchy, "component" => :xy)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
true
end # cookstress_algo
function cookstress_algo_export()
E = 1.0
nu = 1.0 / 3
width = 48.0
height = 44.0
thickness = 1.0
free_height = 16.0
Mid_edge = [48.0, 52.0]# Location of tracked deflection
magn = 1.0 / (free_height * thickness)# Density of applied load
convutip = 23.97
n = 30# number of elements per side
tolerance = minimum([width, height]) / n / 1000.0#Geometrical tolerance
fens, fes = T3block(width, height, n, n)
# Reshape into a trapezoidal panel
for i in eachindex(fens)
fens.xyz[i, 2] =
fens.xyz[i, 2] +
(fens.xyz[i, 1] / width) *
(height - fens.xyz[i, 2] / height * (height - free_height))
end
# Clamped edge of the membrane
l1 = selectnode(fens; box = [0.0, 0.0, -Inf, Inf], inflate = tolerance)
ess1 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => l1)
ess2 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => l1)
# Traction on the opposite edge
boundaryfes = meshboundary(fes)
Toplist =
selectelem(fens, boundaryfes, box = [width, width, -Inf, Inf], inflate = tolerance)
el1femm =
FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(1, 2), thickness))
flux1 = FDataDict("traction_vector" => [0.0, +magn], "femm" => el1femm)
# Make the region
MR = DeforModelRed2DStress
material = MatDeforElastIso(MR, 0.0, E, nu, 0.0)
region1 = FDataDict(
"femm" =>
FEMMDeforLinear(MR, IntegDomain(fes, TriRule(1), thickness), material),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [ess1, ess2],
"traction_bcs" => [flux1],
)
# Call the solver
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# Extract the solution
nl = selectnode(
fens,
box = [Mid_edge[1], Mid_edge[1], Mid_edge[2], Mid_edge[2]],
inflate = tolerance,
)
theutip = u.values[nl, :]
println("displacement =$(theutip[2]) as compared to converged $convutip")
modeldata["postprocessing"] =
FDataDict("file" => "cookstress-ew", "quantity" => :Cauchy, "component" => :xy)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
println("range of Cauchy_xy = $((minimum(fld.values), maximum(fld.values)))")
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`)
modeldata["postprocessing"] =
FDataDict("file" => "cookstress-ew-vm", "quantity" => :vm, "component" => 1)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
println("range of vm = $((minimum(fld.values), maximum(fld.values)))")
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`)
modeldata["postprocessing"] = FDataDict(
"file" => "cookstress-ew-pressure",
"quantity" => :pressure,
"component" => 1,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
println("range of pressure = $((minimum(fld.values), maximum(fld.values)))")
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`)
modeldata["postprocessing"] = FDataDict(
"file" => "cookstress-ew-princ1",
"quantity" => :princCauchy,
"component" => 1,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
println("range of princCauchy Max = $((minimum(fld.values), maximum(fld.values)))")
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`)
modeldata["postprocessing"] = FDataDict(
"file" => "cookstress-ew-princ2",
"quantity" => :princCauchy,
"component" => 2,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
println("range of princCauchy Min = $((minimum(fld.values), maximum(fld.values)))")
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`)
AE = AbaqusExporter("Cookstress_algo_stress")
HEADING(AE, "Cook trapezoidal panel, plane stress")
COMMENT(AE, "Converged free mid-edge displacement = 23.97")
PART(AE, "part1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
COMMENT(AE, "We are assuming three node triangles in plane-stress")
COMMENT(AE, "CPS3 are pretty poor-accuracy elements, but here we don't care about it.")
@assert nodesperelem(modeldata["regions"][1]["femm"].integdomain.fes) == 3
ELEMENT(
AE,
"CPS3",
"AllElements",
connasarray(modeldata["regions"][1]["femm"].integdomain.fes),
)
NSET_NSET(AE, "clamped", modeldata["essential_bcs"][1]["node_list"])
ORIENTATION(AE, "GlobalOrientation", vec([1.0 0 0]), vec([0 1.0 0]))
SOLID_SECTION(AE, "elasticity", "GlobalOrientation", "AllElements", thickness)
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "elasticity")
ELASTIC(AE, E, nu)
STEP_PERTURBATION_STATIC(AE)
BOUNDARY(AE, "ASSEM1.INSTNC1.clamped", 1)
BOUNDARY(AE, "ASSEM1.INSTNC1.clamped", 2)
bfes = modeldata["traction_bcs"][1]["femm"].integdomain.fes
COMMENT(AE, "Concentrated loads: we are assuming that the elements on the boundary")
COMMENT(AE, "have two nodes each and also that they are the same length.")
COMMENT(AE, "Then the concentrated loads below will be correctly lumped.")
nl = connectednodes(bfes)
F = zeros(count(modeldata["fens"]))
for ix in eachindex(bfes)
for jx = 1:2
F[bfes.conn[ix][jx]] += 1.0 / n / 2 / thickness
end
end
for ixxxx in eachindex(F)
if F[ixxxx] != 0.0
CLOAD(AE, "ASSEM1.INSTNC1.$(ixxxx)", 2, F[ixxxx])
end
end
END_STEP(AE)
close(AE)
true
end # cookstress_algo_export
function cookstress_algo_export_ortho()
E = 1.0
nu = 1.0 / 3
width = 48.0
height = 44.0
thickness = 1.0
free_height = 16.0
Mid_edge = [48.0, 52.0]# Location of tracked deflection
magn = 1.0 / (free_height * thickness)# Density of applied load
convutip = 23.97
n = 30# number of elements per side
tolerance = minimum([width, height]) / n / 1000.0#Geometrical tolerance
fens, fes = T3block(width, height, n, n)
# Reshape into a trapezoidal panel
for i in eachindex(fens)
fens.xyz[i, 2] =
fens.xyz[i, 2] +
(fens.xyz[i, 1] / width) *
(height - fens.xyz[i, 2] / height * (height - free_height))
end
# Clamped edge of the membrane
l1 = selectnode(fens; box = [0.0, 0.0, -Inf, Inf], inflate = tolerance)
ess1 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => l1)
ess2 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => l1)
# Traction on the opposite edge
boundaryfes = meshboundary(fes)
Toplist =
selectelem(fens, boundaryfes, box = [width, width, -Inf, Inf], inflate = tolerance)
el1femm =
FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(1, 2), thickness))
flux1 = FDataDict("traction_vector" => [0.0, +magn], "femm" => el1femm)
# Make the region
MR = DeforModelRed2DStress
material = MatDeforElastOrtho(MR, 0.0, E, nu, 0.0)
region1 = FDataDict(
"femm" =>
FEMMDeforLinear(MR, IntegDomain(fes, TriRule(1), thickness), material),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [ess1, ess2],
"traction_bcs" => [flux1],
)
# Call the solver
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# Extract the solution
nl = selectnode(
fens,
box = [Mid_edge[1], Mid_edge[1], Mid_edge[2], Mid_edge[2]],
inflate = tolerance,
)
theutip = u.values[nl, :]
println("displacement =$(theutip[2]) as compared to converged $convutip")
modeldata["postprocessing"] =
FDataDict("file" => "cookstress-ew", "quantity" => :Cauchy, "component" => :xy)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
println("range of Cauchy_xy = $((minimum(fld.values), maximum(fld.values)))")
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`)
modeldata["postprocessing"] =
FDataDict("file" => "cookstress-ew-vm", "quantity" => :vm, "component" => 1)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
println("range of vm = $((minimum(fld.values), maximum(fld.values)))")
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`)
modeldata["postprocessing"] = FDataDict(
"file" => "cookstress-ew-pressure",
"quantity" => :pressure,
"component" => 1,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
println("range of pressure = $((minimum(fld.values), maximum(fld.values)))")
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`)
modeldata["postprocessing"] = FDataDict(
"file" => "cookstress-ew-princ1",
"quantity" => :princCauchy,
"component" => 1,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
println("range of princCauchy Max = $((minimum(fld.values), maximum(fld.values)))")
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`)
modeldata["postprocessing"] = FDataDict(
"file" => "cookstress-ew-princ2",
"quantity" => :princCauchy,
"component" => 2,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
println("range of princCauchy Min = $((minimum(fld.values), maximum(fld.values)))")
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`)
AE = AbaqusExporter("Cookstress_algo_stress")
HEADING(AE, "Cook trapezoidal panel, plane stress")
COMMENT(AE, "Converged free mid-edge displacement = 23.97")
PART(AE, "part1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
COMMENT(AE, "We are assuming three node triangles in plane-stress")
COMMENT(AE, "CPS3 are pretty poor-accuracy elements, but here we don't care about it.")
@assert nodesperelem(modeldata["regions"][1]["femm"].integdomain.fes) == 3
ELEMENT(
AE,
"CPS3",
"AllElements",
connasarray(modeldata["regions"][1]["femm"].integdomain.fes),
)
NSET_NSET(AE, "clamped", modeldata["essential_bcs"][1]["node_list"])
ORIENTATION(AE, "GlobalOrientation", vec([1.0 0 0]), vec([0 1.0 0]))
SOLID_SECTION(AE, "elasticity", "GlobalOrientation", "AllElements", thickness)
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "elasticity")
ELASTIC(AE, E, nu)
STEP_PERTURBATION_STATIC(AE)
BOUNDARY(AE, "ASSEM1.INSTNC1.clamped", 1)
BOUNDARY(AE, "ASSEM1.INSTNC1.clamped", 2)
bfes = modeldata["traction_bcs"][1]["femm"].integdomain.fes
COMMENT(AE, "Concentrated loads: we are assuming that the elements on the boundary")
COMMENT(AE, "have two nodes each and also that they are the same length.")
COMMENT(AE, "Then the concentrated loads below will be correctly lumped.")
nl = connectednodes(bfes)
F = zeros(count(modeldata["fens"]))
for ix in eachindex(bfes)
for jx = 1:2
F[bfes.conn[ix][jx]] += 1.0 / n / 2 / thickness
end
end
for ixxxx in eachindex(F)
if F[ixxxx] != 0.0
CLOAD(AE, "ASSEM1.INSTNC1.$(ixxxx)", 2, F[ixxxx])
end
end
END_STEP(AE)
close(AE)
true
end # cookstress_algo_export_ortho
function cookstress_t6_algo()
println("Cook plane stress, with quadratic triangles.")
E = 1.0
nu = 1.0 / 3
width = 48.0
height = 44.0
thickness = 1.0
free_height = 16.0
Mid_edge = [48.0, 52.0]# Location of tracked deflection
magn = 1.0 / free_height# Magnitude of applied load
convutip = 23.97
n = 10#*int(round(sqrt(170.)/2.)); # number of elements per side
tolerance = minimum([width, height]) / n / 1000.0#Geometrical tolerance
fens, fes = T6block(width, height, n, n)
# Reshape into a trapezoidal panel
for i in eachindex(fens)
fens.xyz[i, 2] =
fens.xyz[i, 2] +
(fens.xyz[i, 1] / width) *
(height - fens.xyz[i, 2] / height * (height - free_height))
end
# Clamped edge of the membrane
l1 = selectnode(fens; box = [0.0, 0.0, -Inf, Inf], inflate = tolerance)
ess1 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => l1)
ess2 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => l1)
# Traction on the opposite edge
boundaryfes = meshboundary(fes)
Toplist =
selectelem(fens, boundaryfes, box = [width, width, -Inf, Inf], inflate = tolerance)
el1femm = FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(1, 3)))
flux1 = FDataDict("traction_vector" => [0.0, +magn], "femm" => el1femm)
# Make the region
MR = DeforModelRed2DStress
material = MatDeforElastIso(MR, 0.0, E, nu, 0.0)
region1 =
FDataDict("femm" => FEMMDeforLinear(MR, IntegDomain(fes, TriRule(3)), material))
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [ess1, ess2],
"traction_bcs" => [flux1],
)
# Call the solver
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# Extract the solution
nl = selectnode(
fens,
box = [Mid_edge[1], Mid_edge[1], Mid_edge[2], Mid_edge[2]],
inflate = tolerance,
)
theutip = u.values[nl, :]
println("displacement =$(theutip[2]) as compared to converged $convutip")
modeldata["postprocessing"] =
FDataDict("file" => "cookstress", "quantity" => :Cauchy, "component" => :xy)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`)
fld = modeldata["postprocessing"]["exported"][1]["field"]
println("$(minimum(fld.values)) $(maximum(fld.values))")
true
end # cookstress_t6_algo
function cookstress_t6_ortho2iso_algo()
println(
"Cook plane stress, with quadratic triangles. With orthotropic material model.",
)
E = 1.0
nu = 1.0 / 3
E1 = E2 = E3 = E
nu12 = nu13 = nu23 = nu
G12 = G13 = G23 = E / 2.0 / (1 + nu)
width = 48.0
height = 44.0
thickness = 1.0
free_height = 16.0
Mid_edge = [48.0, 52.0]# Location of tracked deflection
magn = 1.0 / free_height# Magnitude of applied load
convutip = 23.97
n = 10#*int(round(sqrt(170.)/2.)); # number of elements per side
tolerance = minimum([width, height]) / n / 1000.0#Geometrical tolerance
fens, fes = T6block(width, height, n, n)
# Reshape into a trapezoidal panel
for i in eachindex(fens)
fens.xyz[i, 2] =
fens.xyz[i, 2] +
(fens.xyz[i, 1] / width) *
(height - fens.xyz[i, 2] / height * (height - free_height))
end
# Clamped edge of the membrane
l1 = selectnode(fens; box = [0.0, 0.0, -Inf, Inf], inflate = tolerance)
ess1 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => l1)
ess2 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => l1)
# Traction on the opposite edge
boundaryfes = meshboundary(fes)
Toplist =
selectelem(fens, boundaryfes, box = [width, width, -Inf, Inf], inflate = tolerance)
el1femm = FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(1, 3)))
flux1 = FDataDict("traction_vector" => [0.0, +magn], "femm" => el1femm)
# Make the region
MR = DeforModelRed2DStress
# This material model is orthotropic, but the input parameters correspond to an
# isotropiic material model..
material = MatDeforElastOrtho(MR, E1, E2, E3, nu12, nu13, nu23, G12, G13, G23)
region1 =
FDataDict("femm" => FEMMDeforLinear(MR, IntegDomain(fes, TriRule(3)), material))
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [ess1, ess2],
"traction_bcs" => [flux1],
)
# Call the solver
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# Extract the solution
nl = selectnode(
fens,
box = [Mid_edge[1], Mid_edge[1], Mid_edge[2], Mid_edge[2]],
inflate = tolerance,
)
theutip = u.values[nl, :]
println("displacement =$(theutip[2]) as compared to converged $convutip")
modeldata["postprocessing"] =
FDataDict("file" => "cookstress", "quantity" => :Cauchy, "component" => :xy)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`)
fld = modeldata["postprocessing"]["exported"][1]["field"]
println("$(minimum(fld.values)) $(maximum(fld.values))")
true
end # cookstress_t6_ortho2iso_algo
function cookstress_big(n = 10, solver = :suitesparse)
println("Cook membrane problem, plane stress. Big model.")
t0 = time()
E = 1.0
nu = 1.0 / 3
width = 48.0
height = 44.0
thickness = 1.0
free_height = 16.0
Mid_edge = [48.0, 52.0]# Location of tracked deflection
magn = 1.0 / free_height# Magnitude of applied load
convutip = 23.97
tolerance = minimum([width, height]) / n / 1000.0#Geometrical tolerance
fens, fes = T3block(width, height, n, n)
# Reshape into a trapezoidal panel
for i in eachindex(fens)
fens.xyz[i, 2] =
fens.xyz[i, 2] +
(fens.xyz[i, 1] / width) *
(height - fens.xyz[i, 2] / height * (height - free_height))
end
# Renumber the nodes
femm = FEMMBase(IntegDomain(fes, GaussRule(3, 2)))
C = connectionmatrix(femm, count(fens))
display(spy(C, canvas = DotCanvas))
I, J, V = findnz(C)
@show bw = maximum(I .- J) + 1
perm = symrcm(C)
display(spy(C[perm, perm], canvas = DotCanvas))
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
l1 = selectnode(fens; box = [0, 0, -Inf, Inf], inflate = tolerance)
setebc!(u, l1, 1, 10.0)
setebc!(u, l1, 2, 10.0)
applyebc!(u)
numberdofs!(u, perm)
# numberdofs!(u)
@time boundaryfes = meshboundary(fes)
Toplist =
selectelem(fens, boundaryfes, box = [width, width, -Inf, Inf], inflate = tolerance)
el1femm = FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(1, 2)))
fi = ForceIntensity([0.0, +magn])
F2 = distribloads(el1femm, geom, u, fi, 2)
MR = DeforModelRed2DStress
material = MatDeforElastIso(MR, 0.0, E, nu, 0.0)
femm = FEMMDeforLinear(MR, IntegDomain(fes, TriRule(1)), material)
K = stiffness(femm, geom, u)
@show count(fens)
if solver == :suitesparse
@time K = SuiteSparse.CHOLMOD.cholesky(K)
@time U = K \ (F2)
elseif solver == :cg
n = size(K, 1)
mKd = mean(diag(K))
# @time factor = ilu(K, τ = mKd / 100.0) # This may work for compressible materials
@time factor = ilu(K, τ = mKd / 1000000.0) # This may work for incompressible materials
# factor = ilu0(K)
@show nnz(factor) / nnz(K)
opM = LinearOperator(Float64, n, n, false, false, (y, v) -> ldiv!(y, factor, v))
@time (U, stats) = Krylov.cg(K, F2; M = opM, itmax = Int(round(n / 2)), verbose = 1)
elseif solver == :skyline
I, J, V = SkylineSolvers.Ldlt.findnz(K)
@show bw = maximum(abs.(I .- J)) + 1
M = size(K, 1)
K = nothing
GC.gc()
sky = SkylineSolvers.Ldlt.SkylineMatrix(I, J, V, M)
I = nothing
J = nothing
V = nothing
GC.gc()
@show SkylineSolvers.Ldlt.nnz(sky)
@time SkylineSolvers.Ldlt.factorize!(sky)
@time U = SkylineSolvers.Ldlt.solve(sky, F2)
end
scattersysvec!(u, U[:])
nl = selectnode(
fens,
box = [Mid_edge[1], Mid_edge[1], Mid_edge[2], Mid_edge[2]],
inflate = tolerance,
)
theutip = zeros(FFlt, 1, 2)
gathervalues_asmat!(u, theutip, nl)
println(
"$(time()-t0) [s]; displacement =$(theutip[2]) as compared to converged $convutip",
)
# File = "a.vtk"
# vtkexportmesh(File, fes.conn, geom.values+u.values,
# FinEtools.MeshExportModule.T3; vectors=[("u", u.values)])
true
end # cookstress
function allrun()
println("#####################################################")
println("# cookstress ")
cookstress()
println("#####################################################")
println("# cookstress_algo ")
cookstress_algo()
println("#####################################################")
println("# cookstress_algo_export ")
cookstress_algo_export()
println("#####################################################")
println("# cookstress_algo_export_ortho ")
cookstress_algo_export_ortho()
println("#####################################################")
println("# cookstress_t6_algo ")
cookstress_t6_algo()
println("#####################################################")
println("# cookstress_t6_ortho2iso_algo ")
cookstress_t6_ortho2iso_algo()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module cookstress_examples
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 7998 | module cylinder_examples
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
function cylinder_bend()
# Cylinder bent by edge by enforced displacement, axially symmetric model
println("Cylinder bent by edge by enforced displacement, axially symmetric model")
# Parameters:
E1 = 1.0
E2 = 1.0
E3 = 3.0
nu12 = 0.29
nu13 = 0.29
nu23 = 0.19
G12 = 0.3
G13 = 0.3
G23 = 0.3
p = 0.15
rin = 1.0
rex = 1.2
Length = 1 * rex
ua = -0.05 * Length
tolerance = rin / 1000.0
##
# Note that the FinEtools objects needs to be created with the proper
# model-dimension reduction at hand. In this case that is the axial symmetry
# assumption.
MR = DeforModelRed2DAxisymm
# Create the mesh and initialize the geometry. First we are going
# to construct the block of elements with the first coordinate
# corresponding to the thickness in the radial direction, and the second
# coordinate is the thickness in the axial direction.
fens, fes = Q4block(rex - rin, Length, 5, 20)
fens.xyz[:, 1] .+= rin
bdryfes = meshboundary(fes)
# now we create the geometry and displacement fields
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
# the symmetry plane
l1 = selectnode(fens; box = [0 rex 0 0], inflate = tolerance)
setebc!(u, l1, true, 2, 0.0)
# The other end
l1 = selectnode(fens; box = [0 rex Length Length], inflate = tolerance)
for ixxxx in eachindex(l1)
r = fens.xyz[l1[ixxxx], 1]
setebc!(u, [l1[ixxxx]], true, 2, (r - (rex + rin) / 2) / ((rex + rin) / 2) * ua)
end
applyebc!(u)
numberdofs!(u)
println("Number of degrees of freedom = $(u.nfreedofs)")
# Property and material
material = MatDeforElastOrtho(MR, E1, E2, E3, nu12, nu13, nu23, G12, G13, G23)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 2), true), material)
K = stiffness(femm, geom, u)
F = nzebcloadsstiffness(femm, geom, u)
U = K \ (F)
scattersysvec!(u, U[:])
# Produce a plot of the radial stress component in the cylindrical
# coordinate system. Note that this is the usual representation of
# stress using nodal stress field.
fld = fieldfromintegpoints(femm, geom, u, :Cauchy, 2)
println("Minimum/maximum = $(minimum(fld.values))/$(maximum(fld.values))")
File = "cylinder_bend_sigmaz.vtk"
vtkexportmesh(
File,
fens,
fes;
scalars = [("sigmaz", fld.values)],
vectors = [("u", u.values)],
)
@async run(`"paraview.exe" $File`)
end # cylinder_bend
function cylinder_pull()
# Cylinder pulled by enforced displacement, axially symmetric model
println("Cylinder pulled by enforced displacement, axially symmetric model")
# Parameters:
E1 = 1.0
E2 = 1.0
E3 = 3.0
nu12 = 0.29
nu13 = 0.29
nu23 = 0.19
G12 = 0.3
G13 = 0.3
G23 = 0.3
p = 0.15
rin = 1.0
rex = 1.2
Length = 1 * rex
ua = -0.05 * Length
tolerance = rin / 1000.0
##
# Note that the FinEtools objects needs to be created with the proper
# model-dimension reduction at hand. In this case that is the axial symmetry
# assumption.
MR = DeforModelRed2DAxisymm
# Create the mesh and initialize the geometry. First we are going
# to construct the block of elements with the first coordinate
# corresponding to the thickness in the radial direction, and the second
# coordinate is the thickness in the axial direction.
fens, fes = Q4block(rex - rin, Length, 5, 20)
fens.xyz[:, 1] .+= rin
bdryfes = meshboundary(fes)
# now we create the geometry and displacement fields
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
# the symmetry plane
l1 = selectnode(fens; box = [0 rex 0 0], inflate = tolerance)
setebc!(u, l1, true, 2, 0.0)
# The other end
l1 = selectnode(fens; box = [0 rex Length Length], inflate = tolerance)
setebc!(u, l1, true, 2, ua)
applyebc!(u)
numberdofs!(u)
println("Number of degrees of freedom = $(u.nfreedofs)")
# Property and material
material = MatDeforElastOrtho(MR, E1, E2, E3, nu12, nu13, nu23, G12, G13, G23)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 2), true), material)
K = stiffness(femm, geom, u)
F = nzebcloadsstiffness(femm, geom, u)
U = K \ (F)
scattersysvec!(u, U[:])
# Produce a plot of the radial stress component in the cylindrical
# coordinate system. Note that this is the usual representation of
# stress using nodal stress field.
fld = fieldfromintegpoints(femm, geom, u, :Cauchy, 2)
println("Minimum/maximum = $(minimum(fld.values))/$(maximum(fld.values))")
File = "orthoballoon_sigmaz.vtk"
vtkexportmesh(
File,
fens,
fes;
scalars = [("sigmaz", fld.values)],
vectors = [("u", u.values)],
)
@async run(`"paraview.exe" $File`)
end # cylinder_pull
function cylinder_pull_algo()
# Cylinder pulled by enforced displacement, axially symmetric model
# Parameters:
E1 = 1.0
E2 = 1.0
E3 = 3.0
nu12 = 0.29
nu13 = 0.29
nu23 = 0.19
G12 = 0.3
G13 = 0.3
G23 = 0.3
p = 0.15
rin = 1.0
rex = 1.2
Length = 1 * rex
ua = -0.05 * Length
tolerance = rin / 1000.0
##
# Note that the FinEtools objects needs to be created with the proper
# model-dimension reduction at hand. In this case that is the axial symmetry
# assumption.
MR = DeforModelRed2DAxisymm
# Create the mesh and initialize the geometry. First we are going
# to construct the block of elements with the first coordinate
# corresponding to the thickness in the radial direction, and the second
# coordinate is the thickness in the axial direction.
fens, fes = Q4block(rex - rin, Length, 5, 20)
fens.xyz[:, 1] .+= rin
bdryfes = meshboundary(fes)
# the symmetry plane
la1 = selectnode(fens; box = [0 rex 0 0], inflate = tolerance)
# The other end
la2 = selectnode(fens; box = [0 rex Length Length], inflate = tolerance)
e1 = FDataDict("node_list" => la1, "component" => 2, "displacement" => x -> 0.0)
e2 = FDataDict("node_list" => la2, "component" => 2, "displacement" => x -> ua)
# Property and material
material = MatDeforElastOrtho(MR, E1, E2, E3, nu12, nu13, nu23, G12, G13, G23)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 2), true), material)
# Make region
region = FDataDict("femm" => femm)
# Make model data
modeldata =
FDataDict("fens" => fens, "regions" => [region], "essential_bcs" => [e1, e2])
# Call the solver
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
geom = modeldata["geom"]
u = modeldata["u"]
# Produce a plot of the radial stress component in the cylindrical
# coordinate system. Note that this is the usual representation of
# stress using nodal stress field.
fld = fieldfromintegpoints(femm, geom, u, :Cauchy, 2)
println("Minimum/maximum = $(minimum(fld.values))/$(maximum(fld.values))")
File = "orthoballoon_sigmaz.vtk"
vtkexportmesh(
File,
fens,
fes;
scalars = [("sigmaz", fld.values)],
vectors = [("u", u.values)],
)
@async run(`"paraview.exe" $File`)
end # cylinder_pull_algo
function allrun()
println("#####################################################")
println("# cylinder_bend ")
cylinder_bend()
println("#####################################################")
println("# cylinder_pull ")
cylinder_pull()
println("#####################################################")
println("# cylinder_pull_algo ")
cylinder_pull_algo()
return true
end # function allrun
end # module cylinder_examples
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 6972 | module orthoballoon_examples
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!, matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using LinearAlgebra
function orthoballoon()
# Orthotropic balloon inflation, axially symmetric model
# Parameters:
E1 = 1.0
E2 = 1.0
E3 = 3.0
nu12 = 0.29
nu13 = 0.29
nu23 = 0.19
G12 = 0.3
G13 = 0.3
G23 = 0.3
p = 0.15
rin = 1.0
rex = 1.2
tolerance = rin / 1000.0
##
# Note that the FinEtools objects needs to be created with the proper
# model-dimension reduction at hand. In this case that is the axial symmetry
# assumption.
MR = DeforModelRed2DAxisymm
# Create the mesh and initialize the geometry. First we are going
# to construct the block of elements with the first coordinate
# corresponding to the thickness in the radial direction, and the second
# coordinate is the thickness in the axial direction.
fens, fes = Q4block(rex - rin, pi / 2, 5, 20)
bdryfes = meshboundary(fes)
icl = selectelem(fens, bdryfes, box = [0.0, 0.0, 0.0, pi / 2], inflate = tolerance)
for i = 1:count(fens)
r = rin + fens.xyz[i, 1]
a = fens.xyz[i, 2]
fens.xyz[i, :] = [r * cos(a) r * sin(a)]
end
# now we create the geometry and displacement fields
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
# the symmetry plane
l1 = selectnode(fens; box = [0 rex 0 0], inflate = tolerance)
setebc!(u, l1, true, 2, 0.0)
# the axis of symmetry
l1 = selectnode(fens; box = [0 0 0 rex], inflate = tolerance)
setebc!(u, l1, true, 1, 0.0)
applyebc!(u)
numberdofs!(u)
println("Number of degrees of freedom = $(nfreedofs(u))")
# The traction boundary condition is applied in the radial
# direction.
el1femm = FEMMBase(IntegDomain(subset(bdryfes, icl), GaussRule(1, 3), true))
function pressureloading!(
forceout::FFltVec,
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
)
copyto!(forceout, XYZ / norm(XYZ) * p)
return forceout
end
fi = ForceIntensity(Float64, 2, pressureloading!) # pressure normal to the internal cylindrical surface
F2 = distribloads(el1femm, geom, u, fi, 2)
# Property and material
material = MatDeforElastOrtho(MR, E1, E2, E3, nu12, nu13, nu23, G12, G13, G23)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 2), true), material)
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K, F2)
# Produce a plot of the radial stress component in the cylindrical
# coordinate system. Note that this is the usual representation of
# stress using nodal stress field.
fld = fieldfromintegpoints(femm, geom, u, :Cauchy, 3)
println("Minimum/maximum = $(minimum(fld.values))/$(maximum(fld.values))")
File = "orthoballoon_sigmaz.vtk"
vtkexportmesh(
File,
fens,
fes;
scalars = [("sigmaz", fld.values)],
vectors = [("u", u.values)],
)
@async run(`"paraview.exe" $File`)
#pub_thick_pipe_axi()
end # orthoballoon
function orthoballoon_penalty()
# Orthotropic balloon inflation, axially symmetric model
# Parameters:
E1 = 1.0
E2 = 1.0
E3 = 3.0
nu12 = 0.29
nu13 = 0.29
nu23 = 0.19
G12 = 0.3
G13 = 0.3
G23 = 0.3
p = 0.15
rin = 1.0
rex = 1.2
tolerance = rin / 1000.0
MR = DeforModelRed2DAxisymm
fens, fes = Q4block(rex - rin, pi / 2, 5, 20)
bdryfes = meshboundary(fes)
icl = selectelem(fens, bdryfes, box = [0.0, 0.0, 0.0, pi / 2], inflate = tolerance)
for i = 1:count(fens)
r = rin + fens.xyz[i, 1]
a = fens.xyz[i, 2]
fens.xyz[i, :] = [r * cos(a) r * sin(a)]
end
# now we create the geometry and displacement fields
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
# the symmetry plane
ly = selectelem(fens, bdryfes; box = [0 rex 0 0], inflate = tolerance)
# the axis of symmetry
lx = selectelem(fens, bdryfes; box = [0 0 0 rex], inflate = tolerance)
# No EBC
applyebc!(u)
numberdofs!(u)
println("Number of degrees of freedom = $(nfreedofs(u))")
# The traction boundary condition is applied in the radial
# direction.
el1femm = FEMMBase(IntegDomain(subset(bdryfes, icl), GaussRule(1, 3), true))
function pressureloading!(
forceout::FFltVec,
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
)
copyto!(forceout, XYZ / norm(XYZ) * p)
return forceout
end
fi = ForceIntensity(Float64, 2, pressureloading!) # pressure normal to the internal cylindrical surface
F2 = distribloads(el1femm, geom, u, fi, 2)
# Property and material
material = MatDeforElastOrtho(MR, E1, E2, E3, nu12, nu13, nu23, G12, G13, G23)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 2), true), material)
##
# The restraints of the nodes on the bounding cross-sections in the direction
# of the normal to the plane of the cross-section in the
# circumferential direction are introduced using a penalty formulation.
# For that purpose we introduce a finite element model machine for the
# surface finite elements on the cross-sections.
springcoefficient = 1.0e9 / (abs(p) / E1)
xsfemm = FEMMDeforWinkler(IntegDomain(subset(bdryfes, lx), GaussRule(1, 3), true))
ysfemm = FEMMDeforWinkler(IntegDomain(subset(bdryfes, ly), GaussRule(1, 3), true))
H =
surfacenormalspringstiffness(xsfemm, geom, u, springcoefficient, SurfaceNormal(3)) +
surfacenormalspringstiffness(ysfemm, geom, u, springcoefficient, SurfaceNormal(3))
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K + H, F2)
# Produce a plot of the radial stress component in the cylindrical
# coordinate system. Note that this is the usual representation of
# stress using nodal stress field.
fld = fieldfromintegpoints(femm, geom, u, :Cauchy, 3)
println("Minimum/maximum = $(minimum(fld.values))/$(maximum(fld.values))")
File = "orthoballoon_penalty_sigmaz.vtk"
vtkexportmesh(
File,
fens,
fes;
scalars = [("sigmaz", fld.values)],
vectors = [("u", u.values)],
)
@async run(`"paraview.exe" $File`)
#pub_thick_pipe_axi()
end # orthoballoon_penalty
function allrun()
println("#####################################################")
println("# orthoballoon ")
orthoballoon()
println("#####################################################")
println("# orthoballoon_penalty ")
orthoballoon_penalty()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module orthoballoon_examples
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 4269 | module patch_test_2d_examples
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtools.MeshExportModule
import LinearAlgebra: cholesky
function q4_stress()
println("Q4. Plane stress.")
E = 1.0
nu = 1.0 / 3
alpha, beta, gamma, delta, eta, phi =
1.0 / 30, 1.0 / 34, -1.0 / 21, -1.0 / 51, -1.0 / 26, -1.0 / 35
ux(x, y) = alpha + beta * x + gamma * y
uy(x, y) = delta + eta * x + phi * y
MR = DeforModelRed2DStress
fens = FENodeSet(
[
1.0 -0.3
2.3 -0.3
2.3 0.95
1.0 0.95
1.4 0.05
1.9 -0.03
1.7 0.5
1.3 0.6
],
)
fes = FESetQ4([1 2 6 5; 6 2 3 7; 7 3 4 8; 8 4 1 5; 5 6 7 8])
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
# Apply prescribed displacements to exterior nodes
for i = 1:4
setebc!(u, [i], 1, ux(fens.xyz[i, :]...))
setebc!(u, [i], 2, uy(fens.xyz[i, :]...))
end
applyebc!(u)
numberdofs!(u)
material = MatDeforElastIso(MR, 0.0, E, nu, 0.0)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 2)), material)
F = nzebcloadsstiffness(femm, geom, u)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (F)
scattersysvec!(u, U[:])
for i = 5:8
uexact = [ux(fens.xyz[i, :]...), uy(fens.xyz[i, :]...)]
println("u.values[$i, :] = $(u.values[i, :]), uexact = [$(uexact)]")
end
File = "a.vtk"
vtkexportmesh(
File,
fes.conn,
geom.values,
FinEtools.MeshExportModule.Q4;
vectors = [("u", u.values)],
)
true
end # cookstress
function q4_stress_export()
println("Q4. Plane stress.")
E = 1.0
nu = 1.0 / 3
alpha, beta, gamma, delta, eta, phi =
1.0 / 30, 1.0 / 34, -1.0 / 21, -1.0 / 51, -1.0 / 26, -1.0 / 35
ux(x, y) = alpha + beta * x + gamma * y
uy(x, y) = delta + eta * x + phi * y
MR = DeforModelRed2DStress
fens = FENodeSet(
[
1.0 -0.3
2.3 -0.3
2.3 0.95
1.0 0.95
1.4 0.05
1.9 -0.03
1.7 0.5
1.3 0.6
],
)
fes = FESetQ4([1 2 6 5; 6 2 3 7; 7 3 4 8; 8 4 1 5; 5 6 7 8])
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
# Apply prescribed displacements to exterior nodes
for i = 1:4
setebc!(u, [i], 1, ux(fens.xyz[i, :]...))
setebc!(u, [i], 2, uy(fens.xyz[i, :]...))
end
applyebc!(u)
numberdofs!(u)
material = MatDeforElastIso(MR, 0.0, E, nu, 0.0)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 2)), material)
F = nzebcloadsstiffness(femm, geom, u)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (F)
scattersysvec!(u, U[:])
for i = 5:8
uexact = [ux(fens.xyz[i, :]...), uy(fens.xyz[i, :]...)]
println("u.values[$i, :] = $(u.values[i, :]), uexact = [$(uexact)]")
end
AE = AbaqusExporter("q4_stress_export")
HEADING(AE, "q4_stress_export")
COMMENT(AE, "")
PART(AE, "part1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
ELEMENT(AE, "CPS4", "AllElements", connasarray(fes))
NSET_NSET(AE, "clamped", 1:4)
ORIENTATION(AE, "GlobalOrientation", vec([1.0 0 0]), vec([0 1.0 0]))
SOLID_SECTION(AE, "elasticity", "GlobalOrientation", "AllElements", 1.0)
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "elasticity")
ELASTIC(AE, E, nu)
STEP_PERTURBATION_STATIC(AE)
BOUNDARY(
AE,
"ASSEM1.INSTNC1",
1:4,
fill(true, 4, 2),
[[ux(fens.xyz[i, :]...) for i = 1:4] [uy(fens.xyz[i, :]...) for i = 1:4]],
)
END_STEP(AE)
close(AE)
true
end # cookstress
function allrun()
println("#####################################################")
println("# q4_stress ")
q4_stress()
println("#####################################################")
println("# q4_stress_export ")
q4_stress_export()
return true
end # function allrun
end # module patch_test_2d_examples
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 27958 | module thick_pipe_examples
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!, matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using PGFPlotsX
using Statistics
using LinearAlgebra
struct MyIData
c::FInt
r::FFltVec
s::FFltVec
end
function thick_pipe_axi()
println("Thick pipe with internal pressure: axially symmetric model")
#=
This is a simple modification of the full three-dimensional simulation of
the tutorial pub_thick_pipe that implements the axially-symmetric model
reduction procedure.
An infinitely long thick walled cylindrical pipe
with inner boundary radius of 3 mm and outer boundary radius of 9 mm is
subjected to an internal pressure of 1.0 MPa. A wedge with thickness of
2 mm and a 90-degree angle sector is considered for the finite element
analysis. The material properties are taken as isotropic linear elastic
with $E=1000$ MPa and $\nu=0.4999$ to represent nearly incompressible
behavior. This problem has been proposed to by MacNeal and Harder as a
test of an element's ability to represent the response of a nearly
incompressible material. The plane-strain condition is assumed in the
axial direction of the pipe which together with the radial symmetry
confines the material in all but the radial direction and therefore
amplifies the numerical difficulties associated with the confinement of
the nearly incompressible material.
There is an analytical solution to this problem. Timoshenko and Goodier
presented the original solution of Lame in their textbook. We are going
to compare with both the stress distribution (radial and hoop stresses)
and the displacement of the inner cylindrical surface.
References:
- Macneal RH, Harder RL (1985) A proposed standard set of problems to test
finite element accuracy. Finite Elements in Analysis and Design 1: 3-20.
- Timoshenko S. and Goodier J. N., Theory of Elasticity, McGraw-Hill, 2nd ed., 1951.
=#
# Internal radius of the pipe.
a = 3 * phun("MM")
##
# External radius of the pipe.
b = 9 * phun("MM")
##
# Thickness of the slice.
t = 2 * phun("MM")
##
# Geometrical tolerance.
tolerance = a / 10000.0
##
# Young's modulus and Poisson's ratio.
E = 1000 * phun("MEGA*PA")
nu = 0.499
##
# Applied pressure on the internal surface.
press = 1.0 * phun("MEGA*PA")
##
# Analytical solutions. Radial stress:
radial_stress(r) = press * a^2 / (b^2 - a^2) * (1 - b^2.0 / r^2)
##
# Circumferential (hoop) stress:
hoop_stress(r) = press * a^2 / (b^2 - a^2) * (1 + b^2.0 / r^2)
##
# Radial displacement:
function radial_displacement(r)
press * a^2 * (1 + nu) * (b^2 + r^2 * (1 - 2 * nu)) / (E * (b^2 - a^2) * r)
end
##
# Therefore the radial displacement of the loaded surface will be:
urex = radial_displacement(a)
##
# The mesh parameters: The numbers of element edges axially,
# and through the thickness of the pipe wall (radially).
na = 1
nt = 10
##
# Note that the material object needs to be created with the proper
# model-dimension reduction in effect. In this case that is the axial symmetry
# assumption.
MR = DeforModelRed2DAxisymm
axisymmetric = true
# Create the mesh and initialize the geometry. First we are going
# to construct the block of elements with the first coordinate
# corresponding to the thickness in the radial direction, and the second
# coordinate is the thickness in the axial direction.
fens, fes = Q8block(b - a, t, nt, na)
# Extract the boundary and mark the finite elements on the
# interior surface.
bdryfes = meshboundary(fes)
bcl = selectelem(fens, bdryfes, box = [0.0, 0.0, -Inf, Inf], inflate = tolerance)
internal_fenids = connectednodes(subset(bdryfes, bcl))
# Now shape the block into the actual wedge piece of the pipe.
for i = 1:count(fens)
fens.xyz[i, :] = fens.xyz[i, :] + [a; 0.0]
end
# now we create the geometry and displacement fields
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
# The plane-strain condition in the axial direction is specified by selecting nodes
# on the plane y=0 and y=t.
l1 = selectnode(fens; box = [-Inf Inf 0.0 0.0], inflate = tolerance)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(fens; box = [-Inf Inf t t], inflate = tolerance)
setebc!(u, l1, true, 2, 0.0)
applyebc!(u)
numberdofs!(u)
# The traction boundary condition is applied in the radial
# direction.
el1femm = FEMMBase(IntegDomain(subset(bdryfes, bcl), GaussRule(1, 3), axisymmetric))
fi = ForceIntensity([press; 0.0])
F2 = distribloads(el1femm, geom, u, fi, 2)
# Property and material
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 2), axisymmetric), material)
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K, F2)
# Transfer the solution of the displacement to the nodes on the
# internal cylindrical surface and convert to
# cylindrical-coordinate displacements there.
uv = u.values[internal_fenids, :]
# Report the relative displacement on the internal surface:
println(
"(Approximate/true displacement) at the internal surface: $( mean(uv[:,1])/urex*100 ) %",
)
# Produce a plot of the radial stress component in the cylindrical
# coordinate system. Note that this is the usual representation of
# stress using nodal stress field.
fld = fieldfromintegpoints(femm, geom, u, :Cauchy, 1)
File = "thick_pipe_sigmax.vtk"
vtkexportmesh(File, fens, fes; scalars = [("sigmax", fld.values)])
# Produce a plot of the solution components in the cylindrical
# coordinate system.
function inspector(idat::MyIData, elnum, conn, xe, out, xq)
push!(idat.r, xq[1])
push!(idat.s, out[idat.c])
return idat
end
idat = MyIData(1, FFltVec[], FFltVec[])
idat =
inspectintegpoints(femm, geom, u, collect(1:count(fes)), inspector, idat, :Cauchy)
# Plot the analytical solution.
r = linearspace(a, b, 100)
@pgf a = Axis(
{
xlabel = "Radial distance",
ylabel = "Radial stress",
grid = "major",
legend_pos = "south east",
},
Plot({mark = "dot"}, Table([:x => vec(r), :y => vec(radial_stress.(r))])),
LegendEntry("Analytical"),
Plot(
{"only marks", "red", mark = "triangle"},
Table([:x => vec(idat.r), :y => vec(idat.s)]),
),
LegendEntry("FEA"),
)
display(a)
# print_tex(a)
# ##
# # *Regular quadratic triangle*
# ##
# # We start with the workhorse of most commonly used finite element
# # packages, the quadratic triangle. Similarly to the quadratic
# # tetrahedron in the 3-D version of this tutorial (pub_thick_pipe), the
# # stress is polluted with oscillations. Definitely not as bad as in the
# # plane-strain simulations when the triangles were distorted into
# # shapes with curved edges, but the disturbances are there.
# description ='T6';# tetrahedron
# mf =@T6_block;
# femmf =@(fes)femm_deformation_linear(struct('fes',fes,...
# 'material',mater,'integration_rule',tri_rule(struct('npts',3))));
# surface_integration_rule=gauss_rule(struct('dim',1, 'order', 3));
# execute_simulation (description, mf, femmf, surface_integration_rule);
# ##
# # The same remedy of selective reduced integration as in full 3-D models
# # will also work here. Is demonstrated by the simulation with the
# # selective reduced integration quadratic triangle.
# ##
# # *Selective reduced
# # integration quadratic triangle*
# description ='T6-SRI';
# mf =@T6_block;
# femmf =@(fes)femm_deformation_linear_sri(struct('fes',fes,...
# 'material',mater,...
# 'integration_rule_volumetric',tri_rule(struct('npts',1)),...
# 'integration_rule_deviatoric',tri_rule(struct('npts',3))));
# surface_integration_rule=gauss_rule(struct('dim',1, 'order', 3));
# execute_simulation (description, mf, femmf, surface_integration_rule);
# ##
# # The selective reduced integration works very well with the T6 triangle.
# ##
# # An element that is often used in these situations is the uniformly
# # under integrated serendipity (8-node) quadrilateral.
# ##
# # *Reduced integration serendipity quadrilateral*
# ##
# # The same finite
# # element model machine as above is used, and the integration is the 2
# # x 2 Gauss rule (one order lower than that required for full
# # integration which would be 3 x 3).
# description ='Q8R';
# mf =@Q8_block;
# femmf =@(fes)femm_deformation_linear(struct('fes',fes,...
# 'material',mater,...
# 'integration_rule',gauss_rule(struct('dim',2, 'order',2))));
# surface_integration_rule=gauss_rule(struct('dim',1, 'order',3));
# execute_simulation (description, mf, femmf, surface_integration_rule);
# ##
# # *Full integration serendipity quadrilateral*
# ##
# # Using the full-integration Gauss rule of 3 x 3 points clearly leads to disaster.
# description ='Q8';
# mf =@Q8_block;
# femmf =@(fes)femm_deformation_linear(struct('fes',fes,...
# 'material',mater,...
# 'integration_rule',gauss_rule(struct('dim',2, 'order',3))));
# surface_integration_rule=gauss_rule(struct('dim',1, 'order',3));
# execute_simulation (description, mf, femmf, surface_integration_rule);
##
# The stress is now totally unacceptable.
## Discussion
#
##
# The axially symmetric model is clearly very effective
# computationally, as the size is much reduced compared to the 3-D
# model. In conjunction with uniform or selective reduced integration
# it can be very accurate as well.
#pub_thick_pipe_axi()
# end
end # thick_pipe_axi
function thick_pipe_ps()
## Thick pipe with internal pressure: plane strain
#
##
# Link to the <matlab:edit('pub_thick_pipe_ps') m-file>.
## Description
##
# This is a simple modification of the full three-dimensional simulation of
# the tutorial pub_thick_pipe takes advantage of the plane-strain model
# reduction procedure.
##
# An infinitely long thick walled cylindrical pipe
# with inner boundary radius of 3 mm and outer boundary radius of 9 mm is
# subjected to an internal pressure of 1.0 MPa. A wedge with thickness of
# 2 mm and a 90-degree angle sector is considered for the finite element
# analysis. The material properties are taken as isotropic linear elastic
# with $E=1000$ MPa and $\nu=0.4999$ to represent nearly incompressible
# behavior. This problem has been proposed to by MacNeal and Harder as a
# test of an element's ability to represent the response of a nearly
# incompressible material. The plane-strain condition is assumed in the
# axial direction of the pipe which together with the radial symmetry
# confines the material in all but the radial direction and therefore
# amplifies the numerical difficulties associated with the confinement of
# the nearly incompressible material.
##
# There is an analytical solution to this problem. Timoshenko and Goodier
# presented the original solution of Lame in their textbook. We are going
# to compare with both the stress distribution (radial and hoop stresses)
# and the displacement of the inner cylindrical surface.
##
#
# <html>
# <table border=0><tr><td>
# <img src="../docs/pub_thick_pipe_ps.png" width = "30#">
# </td></tr>
# <tr><td>Figure 1. Definition of the geometry of the internally pressurized thick pipe</td></tr>
# </table>
# </html>
##
# References:
#
# # Macneal RH, Harder RL (1985) A proposed standard set of problems to test
# finite element accuracy. Finite Elements in Analysis and Design 1: 3-20.
#
# # Timoshenko S. and Goodier J. N., Theory of Elasticity, McGraw-Hill, 2nd ed., 1951.
## Solution
#
##
# Internal radius of the pipe.
a = 3 * phun("MM")
##
# External radius of the pipe.
b = 9 * phun("MM")
##
# Thickness of the slice.
t = 2 * phun("MM")
##
# Geometrical tolerance.
tolerance = a / 10000.0
##
# Young's modulus and Poisson's ratio.
E = 1000 * phun("MEGA*PA")
nu = 0.499
##
# Applied pressure on the internal surface.
press = 1.0 * phun("MEGA*PA")
##
# Analytical solutions. Radial stress:
radial_stress(r) = press * a .^ 2 / (b^2 - a^2) .* (1 - (b^2) ./ r .^ 2)
##
# Circumferential (hoop) stress:
hoop_stress(r) = press * a .^ 2 / (b^2 - a^2) .* (1 + (b^2) ./ r .^ 2)
##
# Radial displacement:
function radial_displacement(r)
press * a^2 * (1 + nu) * (b^2 + r .^ 2 * (1 - 2 * nu)) / (E * (b^2 - a^2) .* r)
end
##
# Therefore the radial displacement of the loaded surface will be:
urex = radial_displacement(a)
##
# The mesh parameters: The numbers of element edges axially,
# and through the thickness of the pipe wall (radially).
nc = 3
nt = 3
##
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the axial symmetry
# assumption.
MR = DeforModelRed2DStrain
# Create the mesh and initialize the geometry. First we are going
# to construct the block of elements with the first coordinate
# corresponding to the angle, and the second
# coordinate is the thickness in the radial direction.
anglrrange = 90.0 / 180 * pi
fens, fes = Q8block(anglrrange, b - a, nc, nt)
# Extract the boundary and mark the finite elements on the
# interior surface.
bdryfes = meshboundary(fes)
bcl = selectelem(fens, bdryfes, box = [-Inf, Inf, 0.0, 0.0], inflate = tolerance)
internal_fenids = connectednodes(subset(bdryfes, bcl))
# Now shape the block into the actual wedge piece of the pipe.
ayr = fens.xyz
for i = 1:count(fens)
angl = ayr[i, 1]
r = a + ayr[i, 2]
fens.xyz[i, :] = [r * sin(angl), (r * cos(angl))]
end
# now we create the geometry and displacement fields
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
# The symmetry boundary condition is specified by selecting nodes
# on the plane x=0.
l1 = selectnode(fens; box = [0.0 0.0 -Inf Inf], inflate = tolerance)
setebc!(u, l1, true, 1, 0.0)
# The second symmetry boundary condition is specified by selecting
# nodes on the plane y=0.
l1 = selectnode(fens; box = [-Inf Inf 0.0 0.0], inflate = tolerance)
setebc!(u, l1, true, 2, 0.0)
applyebc!(u)
numberdofs!(u)
# The traction boundary condition is applied in the radial
# direction.
el1femm = FEMMBase(IntegDomain(subset(bdryfes, bcl), GaussRule(1, 3)))
function pressureloading!(
forceout::FFltVec,
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
)
copyto!(forceout, XYZ / norm(XYZ) * press)
return forceout
end
fi = ForceIntensity(Float64, 2, pressureloading!) # pressure normal to the internal cylindrical surface
F2 = distribloads(el1femm, geom, u, fi, 2)
# Property and material
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 2)), material)
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K, F2)
# Transfer the solution of the displacement to the nodes on the
# internal cylindrical surface and convert to
# cylindrical-coordinate displacements there.
uv = u.values[internal_fenids, :]
ur = zeros(FFlt, length(internal_fenids))
for j in eachindex(internal_fenids)
n = fens.xyz[internal_fenids[j], :]
n = n' / norm(n)# normal to the cylindrical internal surface
ur[j] = dot(vec(uv[j, :]), vec(n))
end
# Report the relative displacement on the internal surface:
println(
"(Approximate/true displacement) at the internal surface: $( mean(ur)/urex*100 ) %",
)
# Produce a plot of the radial stress component in the cylindrical
# coordinate system. Note that this is the usual representation of
# stress using nodal stress field.
fld = fieldfromintegpoints(femm, geom, u, :Cauchy, 1)
File = "thick_pipe_sigmax.vtk"
vtkexportmesh(File, fens, fes; scalars = [("sigmax", fld.values)])
# Produce a plot of the solution components in the cylindrical
# coordinate system.
# Plot the analytical solution.
function inspector(idat::MyIData, elnum, conn, xe, out, xq)
function outputRm(c)
theNormal = c
r = norm(theNormal)# distance from the axis of symmetry
theNormal = theNormal / r# compute the unit normal vector
e1p = [theNormal'; 0.0]# local cylind. coordinate basis vectors
e3p = [0.0, 0.0, 1.0]'# this one points along the axis of the cylinder
e2p = cross(vec(e3p), vec(e1p))# this one is along the hoop direction
R = [vec(e1p) vec(e2p) vec(e3p)]# transformation matrix for the stress
return R
end
Rm = outputRm(xq)
tm = zeros(FFlt, 3, 3)
stressvtot!(MR, tm, out)# stress in global XYZ
tpm = Rm' * tm * Rm# stress matrix in cylindrical coordinates
sp = zeros(FFlt, 6)
stressttov!(MR, sp, tpm)# stress vector in cylindr. coord.
push!(idat.r, norm(xq))
push!(idat.s, sp[idat.c])
return idat
end
idat = MyIData(1, FFltVec[], FFltVec[])
idat =
inspectintegpoints(femm, geom, u, collect(1:count(fes)), inspector, idat, :Cauchy)
# show(idat)
# Plot the analytical solution.
r = linearspace(a, b, 100)
@pgf a = Axis(
{
xlabel = "Radial distance",
ylabel = "Radial stress",
grid = "major",
legend_pos = "south east",
},
Plot({mark = "dot"}, Table([:x => vec(r), :y => vec(radial_stress.(r))])),
LegendEntry("Analytical"),
Plot(
{"only marks", "red", mark = "triangle"},
Table([:x => vec(idat.r), :y => vec(idat.s)]),
),
LegendEntry("FEA"),
)
display(a)
end # thick_pipe_ps
function thick_pipe_ps_T6()
## Thick pipe with internal pressure: plane strain
#
##
# Link to the <matlab:edit('pub_thick_pipe_ps') m-file>.
## Description
##
# This is a simple modification of the full three-dimensional simulation of
# the tutorial pub_thick_pipe takes advantage of the plane-strain model
# reduction procedure.
##
# An infinitely long thick walled cylindrical pipe
# with inner boundary radius of 3 mm and outer boundary radius of 9 mm is
# subjected to an internal pressure of 1.0 MPa. A wedge with thickness of
# 2 mm and a 90-degree angle sector is considered for the finite element
# analysis. The material properties are taken as isotropic linear elastic
# with $E=1000$ MPa and $\nu=0.4999$ to represent nearly incompressible
# behavior. This problem has been proposed to by MacNeal and Harder as a
# test of an element's ability to represent the response of a nearly
# incompressible material. The plane-strain condition is assumed in the
# axial direction of the pipe which together with the radial symmetry
# confines the material in all but the radial direction and therefore
# amplifies the numerical difficulties associated with the confinement of
# the nearly incompressible material.
##
# There is an analytical solution to this problem. Timoshenko and Goodier
# presented the original solution of Lame in their textbook. We are going
# to compare with both the stress distribution (radial and hoop stresses)
# and the displacement of the inner cylindrical surface.
##
#
# <html>
# <table border=0><tr><td>
# <img src="../docs/pub_thick_pipe_ps.png" width = "30#">
# </td></tr>
# <tr><td>Figure 1. Definition of the geometry of the internally pressurized thick pipe</td></tr>
# </table>
# </html>
##
# References:
#
# # Macneal RH, Harder RL (1985) A proposed standard set of problems to test
# finite element accuracy. Finite Elements in Analysis and Design 1: 3-20.
#
# # Timoshenko S. and Goodier J. N., Theory of Elasticity, McGraw-Hill, 2nd ed., 1951.
## Solution
#
##
# Internal radius of the pipe.
a = 3 * phun("MM")
##
# External radius of the pipe.
b = 9 * phun("MM")
##
# Thickness of the slice.
t = 2 * phun("MM")
##
# Geometrical tolerance.
tolerance = a / 10000.0
##
# Young's modulus and Poisson's ratio.
E = 1000 * phun("MEGA*PA")
nu = 0.499
##
# Applied pressure on the internal surface.
press = 1.0 * phun("MEGA*PA")
##
# Analytical solutions. Radial stress:
radial_stress(r) = press * a .^ 2 / (b^2 - a^2) .* (1 - (b^2) ./ r .^ 2)
##
# Circumferential (hoop) stress:
hoop_stress(r) = press * a .^ 2 / (b^2 - a^2) .* (1 + (b^2) ./ r .^ 2)
##
# Radial displacement:
function radial_displacement(r)
press * a^2 * (1 + nu) * (b^2 + r .^ 2 * (1 - 2 * nu)) / (E * (b^2 - a^2) .* r)
end
##
# Therefore the radial displacement of the loaded surface will be:
urex = radial_displacement(a)
##
# The mesh parameters: The numbers of element edges axially,
# and through the thickness of the pipe wall (radially).
nc = 3
nt = 3
##
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the axial symmetry
# assumption.
MR = DeforModelRed2DStrain
# Create the mesh and initialize the geometry. First we are going
# to construct the block of elements with the first coordinate
# corresponding to the angle, and the second
# coordinate is the thickness in the radial direction.
anglrrange = 90.0 / 180 * pi
fens, fes = T6block(anglrrange, b - a, nc, nt)
# Extract the boundary and mark the finite elements on the
# interior surface.
bdryfes = meshboundary(fes)
bcl = selectelem(fens, bdryfes, box = [-Inf, Inf, 0.0, 0.0], inflate = tolerance)
internal_fenids = connectednodes(subset(bdryfes, bcl))
# Now shape the block into the actual wedge piece of the pipe.
ayr = fens.xyz
for i = 1:count(fens)
angl = ayr[i, 1]
r = a + ayr[i, 2]
fens.xyz[i, :] = [r * sin(angl), (r * cos(angl))]
end
# now we create the geometry and displacement fields
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
# The symmetry boundary condition is specified by selecting nodes
# on the plane x=0.
l1 = selectnode(fens; box = [0.0 0.0 -Inf Inf], inflate = tolerance)
setebc!(u, l1, true, 1, 0.0)
# The second symmetry boundary condition is specified by selecting
# nodes on the plane y=0.
l1 = selectnode(fens; box = [-Inf Inf 0.0 0.0], inflate = tolerance)
setebc!(u, l1, true, 2, 0.0)
applyebc!(u)
numberdofs!(u)
# The traction boundary condition is applied in the radial
# direction.
el1femm = FEMMBase(IntegDomain(subset(bdryfes, bcl), GaussRule(1, 3)))
function pressureloading!(
forceout::FFltVec,
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
)
copyto!(forceout, XYZ / norm(XYZ) * press)
return forceout
end
fi = ForceIntensity(Float64, 2, pressureloading!) # pressure normal to the internal cylindrical surface
F2 = distribloads(el1femm, geom, u, fi, 2)
# Property and material
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinear(MR, IntegDomain(fes, TriRule(3)), material)
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K, F2)
# Transfer the solution of the displacement to the nodes on the
# internal cylindrical surface and convert to
# cylindrical-coordinate displacements there.
uv = u.values[internal_fenids, :]
ur = zeros(FFlt, length(internal_fenids))
for j in eachindex(internal_fenids)
n = fens.xyz[internal_fenids[j], :]
n = n' / norm(n)# normal to the cylindrical internal surface
ur[j] = dot(vec(uv[j, :]), vec(n))
end
# Report the relative displacement on the internal surface:
println(
"(Approximate/true displacement) at the internal surface: $( mean(ur)/urex*100 ) %",
)
# Produce a plot of the radial stress component in the cylindrical
# coordinate system. Note that this is the usual representation of
# stress using nodal stress field.
fld = fieldfromintegpoints(femm, geom, u, :Cauchy, 1)
File = "thick_pipe_sigmax.vtk"
vtkexportmesh(File, fens, fes; scalars = [("sigmax", fld.values)])
# Produce a plot of the solution components in the cylindrical
# coordinate system.
# Plot the analytical solution.
function inspector(idat::MyIData, elnum, conn, xe, out, xq)
function outputRm(c)
theNormal = c
r = norm(theNormal)# distance from the axis of symmetry
theNormal = theNormal / r# compute the unit normal vector
e1p = [theNormal'; 0.0]# local cylind. coordinate basis vectors
e3p = [0.0, 0.0, 1.0]'# this one points along the axis of the cylinder
e2p = cross(vec(e3p), vec(e1p))# this one is along the hoop direction
R = [vec(e1p) vec(e2p) vec(e3p)]# transformation matrix for the stress
return R
end
Rm = outputRm(xq)
tm = zeros(FFlt, 3, 3)
stressvtot!(MR, tm, out)# stress in global XYZ
tpm = Rm' * tm * Rm# stress matrix in cylindrical coordinates
sp = zeros(FFlt, 6)
stressttov!(MR, sp, tpm)# stress vector in cylindr. coord.
push!(idat.r, norm(xq))
push!(idat.s, sp[idat.c])
return idat
end
idat = MyIData(1, FFltVec[], FFltVec[])
idat =
inspectintegpoints(femm, geom, u, collect(1:count(fes)), inspector, idat, :Cauchy)
# show(idat)
# Plot the analytical solution.
r = linearspace(a, b, 100)
@pgf a = Axis(
{
xlabel = "Radial distance",
ylabel = "Radial stress",
grid = "major",
legend_pos = "south east",
},
Plot({mark = "dot"}, Table([:x => vec(r), :y => vec(radial_stress.(r))])),
LegendEntry("Analytical"),
Plot(
{"only marks", "red", mark = "triangle"},
Table([:x => vec(idat.r), :y => vec(idat.s)]),
),
LegendEntry("FEA"),
)
display(a)
#pub_thick_pipe_ps()
end # thick_pipe_ps_T6
function allrun()
println("#####################################################")
println("# thick_pipe_axi ")
thick_pipe_axi()
println("#####################################################")
println("# thick_pipe_ps ")
thick_pipe_ps()
println("#####################################################")
println("# thick_pipe_ps_T6 ")
thick_pipe_ps_T6()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module thick_pipe_examples
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 28520 | module All_EBC_2dir_examples
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtools.MeshUtilModule
using FinEtools.AlgoBaseModule
using LinearAlgebra
# Orthotropic material
E1 = 2.5e6 * phun("PSI")
E2 = 1e6 * phun("PSI")
E3 = E2
G12 = 0.5e6 * phun("PSI")
G13 = G12
G23 = 0.2e6 * phun("PSI")
nu12 = 0.25
nu13 = 0.25
nu23 = 0.25
# Coefficients of thermal expansion
CTE1 = CTE2 = CTE3 = 0.0
angles = vec([-15.0])
nLayers = length(angles)
# dimensions of the plate
a = 100.0 * phun("mm")
b = 100.0 * phun("mm")
t = 100.0 * phun("mm")
tolerance = 0.0001 * t
Refinements = [2, 5, 10, 20, 40] # For the paper
Refinements = [2, 4, 8, 16] # for testing
# Here we define the layout and the thicknesses of the layers.
ts = t / nLayers * ones(nLayers) # layer thicknesses
# The material coordinate system function is defined as:
function updatecs!(csmatout::FFltMat, XYZ::FFltMat, tangents::FFltMat, fe_label::FInt)
rotmat3!(csmatout, angles[fe_label] / 180.0 * pi * [0.0; 1.0; 0.0])
end
function displacement_fun_x(x)
dot(
[0.0, 0.001, 0.0, 0.001, 0.0, -0.001, 0.0, 0.002, 0.0, 0.001],
[
1.0,
x[1],
x[2],
x[3],
x[1] * x[2],
x[1] * x[3],
x[2] * x[3],
x[1]^2,
x[2]^2,
x[3]^2,
],
)
end
function displacement_fun_y(x)
dot(
[0.0, 0.0, 0.0003, 0.0, 0.003, -0.002, 0.007, 0.0, 0.008, -0.007],
[
1.0,
x[1],
x[2],
x[3],
x[1] * x[2],
x[1] * x[3],
x[2] * x[3],
x[1]^2,
x[2]^2,
x[3]^2,
],
)
end
function displacement_fun_z(x)
dot(
[0.0, 0.0, 0.0, 0.00007, 0.008, 0.003, -0.015, 0.002, -0.003, 0.0001],
[
1.0,
x[1],
x[2],
x[3],
x[1] * x[2],
x[1] * x[3],
x[2] * x[3],
x[1]^2,
x[2]^2,
x[3]^2,
],
)
end
function All_EBC_2dir_MST10_conv()
elementtag = "MST10"
println("""
Fiber-reinforced block: $(elementtag)
""")
modeldatasequence = FDataDict[]
for Refinement in Refinements
MR = DeforModelRed3D
material = MatDeforElastOrtho(
MR,
0.0,
E1,
E2,
E3,
nu12,
nu13,
nu23,
G12,
G13,
G23,
CTE1,
CTE2,
CTE3,
)
# Select how fine the mesh should be
nts = Refinement * ones(Int, nLayers)# number of elements per layer
tnts = sum(nts)
na, nb = tnts, tnts
xs = collect(linearspace(0.0, a, na + 1))
ys = collect(linearspace(0.0, b, nb + 1))
fens, fes = T10layeredplatex(xs, ys, ts, nts)
println("Mesh: na, nb, nts = $na, $nb, $nts")
println("count(fens) = $(count(fens))")
# The volume integrals are evaluated using this rule
gr = SimplexRule(3, 4)
# We will create one region per layer
regions = FDataDict[]
for layer = 1:nLayers
rls = selectelem(fens, fes, label = layer)
push!(
regions,
FDataDict(
"femm" => FEMMDeforLinearMST10(
MR,
IntegDomain(subset(fes, rls), gr),
CSys(3, 3, updatecs!),
material,
),
),
)
end
# The essential boundary conditions: the entire surface
bfes = meshboundary(fes)
lx0 = connectednodes(bfes)
eclamped1 = FDataDict(
"displacement" => displacement_fun_x,
"component" => 1,
"node_list" => lx0,
)
eclamped2 = FDataDict(
"displacement" => displacement_fun_y,
"component" => 2,
"node_list" => lx0,
)
eclamped3 = FDataDict(
"displacement" => displacement_fun_z,
"component" => 3,
"node_list" => lx0,
)
modeldata = FDataDict(
"fens" => fens,
"regions" => regions,
"essential_bcs" => [eclamped1, eclamped2, eclamped3],
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
modeldata["elementsize"] = t / Refinement
modeldata["geometricaltolerance"] = tolerance
push!(modeldatasequence, modeldata)
end # for refinement
for (extrap, nodevalmeth) in
zip([:extrapmean, :extraptrend, :default], [:averaging, :averaging, :invdistance])
filebase = "All_EBC_2dir_$(elementtag)_$(extrap)"
for modeldata in modeldatasequence
u = modeldata["u"]
geom = modeldata["geom"]
modeldata["postprocessing"] = FDataDict(
"file" => filebase * "-s",
"quantity" => :Cauchy,
"component" => collect(1:6),
"outputcsys" => CSys(3),
"nodevalmethod" => nodevalmeth,
"reportat" => extrap,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
end
println("")
println("Stress RMS error")
for md in modeldatasequence
md["targetfields"] = [e["field"] for e in md["postprocessing"]["exported"]]
end
elementsizes, errornorms, p = AlgoBaseModule.evalconvergencestudy(modeldatasequence)
println("Normalized Approximate Error = $(errornorms)")
f = log.(vec(errornorms))
A = hcat(log.(vec(elementsizes[1:(end-1)])), ones(size(f)))
p = A \ f
println("Linear log-log fit: p = $(p)")
csvFile = filebase * "_Stress" * ".CSV"
savecsv(
csvFile,
elementsizes = vec(elementsizes[1:(end-1)]),
elementsizes2 = vec(elementsizes[1:(end-1)] .^ 2),
elementsizes3 = vec(elementsizes[1:(end-1)] .^ 3),
errornorms = vec(errornorms),
)
println("Wrote $csvFile")
println("")
println("Displacement RMS error")
for md in modeldatasequence
md["targetfields"] = [md["u"] for r in md["regions"]]
end
elementsizes, errornorms, p = AlgoBaseModule.evalconvergencestudy(modeldatasequence)
println("Normalized Approximate Error = $(errornorms)")
f = log.(vec(errornorms))
A = hcat(log.(vec(elementsizes[1:(end-1)])), ones(size(f)))
p = A \ f
println("Linear log-log fit: p = $(p)")
csvFile = filebase * "_Displ" * ".CSV"
savecsv(
csvFile,
elementsizes = vec(elementsizes[1:(end-1)]),
elementsizes2 = vec(elementsizes[1:(end-1)] .^ 2),
elementsizes3 = vec(elementsizes[1:(end-1)] .^ 3),
errornorms = vec(errornorms),
)
println("Wrote $csvFile")
end
println("Done")
end # All_EBC_2dir_MST10_conv
function All_EBC_2dir_MSH8_conv()
elementtag = "MSH8"
println("""
Fiber-reinforced block: $(elementtag)
""")
modeldatasequence = FDataDict[]
for Refinement in Refinements
# This is the material model
MR = DeforModelRed3D
material = MatDeforElastOrtho(
MR,
0.0,
E1,
E2,
E3,
nu12,
nu13,
nu23,
G12,
G13,
G23,
CTE1,
CTE2,
CTE3,
)
# Select how fine the mesh should be
nts = Refinement * ones(Int, nLayers)# number of elements per layer
tnts = sum(nts)
na, nb = tnts, tnts
xs = collect(linearspace(0.0, a, na + 1))
ys = collect(linearspace(0.0, b, nb + 1))
fens, fes = H8layeredplatex(xs, ys, ts, nts)
println("Mesh: na, nb, nts = $na, $nb, $nts")
println("count(fens) = $(count(fens))")
# The volume integrals are evaluated using this rule
gr = GaussRule(3, 2)
# We will create one region per layer
regions = FDataDict[]
for layer = 1:nLayers
rls = selectelem(fens, fes, label = layer)
push!(
regions,
FDataDict(
"femm" => FEMMDeforLinearMSH8(
MR,
IntegDomain(subset(fes, rls), gr),
CSys(3, 3, updatecs!),
material,
),
),
)
end
# The essential boundary conditions: the entire surface
bfes = meshboundary(fes)
lx0 = connectednodes(bfes)
eclamped1 = FDataDict(
"displacement" => displacement_fun_x,
"component" => 1,
"node_list" => lx0,
)
eclamped2 = FDataDict(
"displacement" => displacement_fun_y,
"component" => 2,
"node_list" => lx0,
)
eclamped3 = FDataDict(
"displacement" => displacement_fun_z,
"component" => 3,
"node_list" => lx0,
)
modeldata = FDataDict(
"fens" => fens,
"regions" => regions,
"essential_bcs" => [eclamped1, eclamped2, eclamped3],
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
modeldata["elementsize"] = t / Refinement
modeldata["geometricaltolerance"] = tolerance
push!(modeldatasequence, modeldata)
end # for refinement
for (extrap, nodevalmeth) in
zip([:extrapmean, :extraptrend, :default], [:averaging, :averaging, :invdistance])
filebase = "All_EBC_2dir_$(elementtag)_$(extrap)"
for modeldata in modeldatasequence
u = modeldata["u"]
geom = modeldata["geom"]
modeldata["postprocessing"] = FDataDict(
"file" => filebase * "-s",
"quantity" => :Cauchy,
"component" => collect(1:6),
"outputcsys" => CSys(3),
"nodevalmethod" => nodevalmeth,
"reportat" => extrap,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
end
println("")
println("Stress RMS error")
for md in modeldatasequence
md["targetfields"] = [e["field"] for e in md["postprocessing"]["exported"]]
end
elementsizes, errornorms, p = AlgoBaseModule.evalconvergencestudy(modeldatasequence)
println("Normalized Approximate Error = $(errornorms)")
f = log.(vec(errornorms))
A = hcat(log.(vec(elementsizes[1:(end-1)])), ones(size(f)))
p = A \ f
println("Linear log-log fit: p = $(p)")
csvFile = filebase * "_Stress" * ".CSV"
savecsv(
csvFile,
elementsizes = vec(elementsizes[1:(end-1)]),
elementsizes2 = vec(elementsizes[1:(end-1)] .^ 2),
elementsizes3 = vec(elementsizes[1:(end-1)] .^ 3),
errornorms = vec(errornorms),
)
println("Wrote $csvFile")
println("")
println("Displacement RMS error")
for md in modeldatasequence
md["targetfields"] = [md["u"] for r in md["regions"]]
end
elementsizes, errornorms, p = AlgoBaseModule.evalconvergencestudy(modeldatasequence)
println("Normalized Approximate Error = $(errornorms)")
f = log.(vec(errornorms))
A = hcat(log.(vec(elementsizes[1:(end-1)])), ones(size(f)))
p = A \ f
println("Linear log-log fit: p = $(p)")
csvFile = filebase * "_Displ" * ".CSV"
savecsv(
csvFile,
elementsizes = vec(elementsizes[1:(end-1)]),
elementsizes2 = vec(elementsizes[1:(end-1)] .^ 2),
elementsizes3 = vec(elementsizes[1:(end-1)] .^ 3),
errornorms = vec(errornorms),
)
println("Wrote $csvFile")
# @async run(`"paraview.exe" $csvFile`)
end # extrap
println("Done")
end # All_EBC_2dir_MSH8_conv
function All_EBC_2dir_MSH8_conv_alt()
elementtag = "MSH8"
println("""
Fiber-reinforced block: $(elementtag) Trapezoidal rule
""")
modeldatasequence = FDataDict[]
for Refinement in Refinements
# This is the material model
MR = DeforModelRed3D
material = MatDeforElastOrtho(
MR,
0.0,
E1,
E2,
E3,
nu12,
nu13,
nu23,
G12,
G13,
G23,
CTE1,
CTE2,
CTE3,
)
# Select how fine the mesh should be
nts = Refinement * ones(Int, nLayers)# number of elements per layer
tnts = sum(nts)
na, nb = tnts, tnts
xs = collect(linearspace(0.0, a, na + 1))
ys = collect(linearspace(0.0, b, nb + 1))
fens, fes = H8layeredplatex(xs, ys, ts, nts)
println("Mesh: na, nb, nts = $na, $nb, $nts")
println("count(fens) = $(count(fens))")
# The volume integrals are evaluated using this rule
gr = TrapezoidalRule(3)
# We will create one region per layer
regions = FDataDict[]
for layer = 1:nLayers
rls = selectelem(fens, fes, label = layer)
push!(
regions,
FDataDict(
"femm" => FEMMDeforLinearMSH8(
MR,
IntegDomain(subset(fes, rls), gr),
CSys(3, 3, updatecs!),
material,
),
),
)
end
# The essential boundary conditions: the entire surface
bfes = meshboundary(fes)
lx0 = connectednodes(bfes)
eclamped1 = FDataDict(
"displacement" => displacement_fun_x,
"component" => 1,
"node_list" => lx0,
)
eclamped2 = FDataDict(
"displacement" => displacement_fun_y,
"component" => 2,
"node_list" => lx0,
)
eclamped3 = FDataDict(
"displacement" => displacement_fun_z,
"component" => 3,
"node_list" => lx0,
)
modeldata = FDataDict(
"fens" => fens,
"regions" => regions,
"essential_bcs" => [eclamped1, eclamped2, eclamped3],
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
modeldata["elementsize"] = t / Refinement
modeldata["geometricaltolerance"] = tolerance
push!(modeldatasequence, modeldata)
end # for refinement
for (extrap, nodevalmeth) in
zip([:extrapmean, :extraptrend, :default], [:averaging, :averaging, :invdistance])
filebase = "All_EBC_2dir_$(elementtag)_$(extrap)_trapezoidal"
for modeldata in modeldatasequence
u = modeldata["u"]
geom = modeldata["geom"]
modeldata["postprocessing"] = FDataDict(
"file" => filebase * "-s",
"quantity" => :Cauchy,
"component" => collect(1:6),
"outputcsys" => CSys(3),
"nodevalmethod" => nodevalmeth,
"reportat" => extrap,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
end
println("")
println("Stress RMS error")
for md in modeldatasequence
md["targetfields"] = [e["field"] for e in md["postprocessing"]["exported"]]
end
elementsizes, errornorms, p = AlgoBaseModule.evalconvergencestudy(modeldatasequence)
println("Normalized Approximate Error = $(errornorms)")
f = log.(vec(errornorms))
A = hcat(log.(vec(elementsizes[1:(end-1)])), ones(size(f)))
p = A \ f
println("Linear log-log fit: p = $(p)")
csvFile = filebase * "_Stress" * ".CSV"
savecsv(
csvFile,
elementsizes = vec(elementsizes[1:(end-1)]),
elementsizes2 = vec(elementsizes[1:(end-1)] .^ 2),
elementsizes3 = vec(elementsizes[1:(end-1)] .^ 3),
errornorms = vec(errornorms),
)
println("Wrote $csvFile")
println("")
println("Displacement RMS error")
for md in modeldatasequence
md["targetfields"] = [md["u"] for r in md["regions"]]
end
elementsizes, errornorms, p = AlgoBaseModule.evalconvergencestudy(modeldatasequence)
println("Normalized Approximate Error = $(errornorms)")
f = log.(vec(errornorms))
A = hcat(log.(vec(elementsizes[1:(end-1)])), ones(size(f)))
p = A \ f
println("Linear log-log fit: p = $(p)")
csvFile = filebase * "_Displ" * ".CSV"
savecsv(
csvFile,
elementsizes = vec(elementsizes[1:(end-1)]),
elementsizes2 = vec(elementsizes[1:(end-1)] .^ 2),
elementsizes3 = vec(elementsizes[1:(end-1)] .^ 3),
errornorms = vec(errornorms),
)
println("Wrote $csvFile")
# @async run(`"paraview.exe" $csvFile`)
end # extrap
println("Done")
end # All_EBC_2dir_MSH8_conv_alt
function All_EBC_2dir_T10_conv()
elementtag = "T10"
println("""
Fiber-reinforced block: $(elementtag)
""")
modeldatasequence = FDataDict[]
for Refinement in Refinements
# This is the material model
MR = DeforModelRed3D
material = MatDeforElastOrtho(
MR,
0.0,
E1,
E2,
E3,
nu12,
nu13,
nu23,
G12,
G13,
G23,
CTE1,
CTE2,
CTE3,
)
# Select how fine the mesh should be
nts = Refinement * ones(Int, nLayers)# number of elements per layer
tnts = sum(nts)
na, nb = tnts, tnts
xs = collect(linearspace(0.0, a, na + 1))
ys = collect(linearspace(0.0, b, nb + 1))
fens, fes = T10layeredplatex(xs, ys, ts, nts)
println("Mesh: na, nb, nts = $na, $nb, $nts")
println("count(fens) = $(count(fens))")
# The volume integrals are evaluated using this rule
gr = SimplexRule(3, 4)
# We will create one region per layer
regions = FDataDict[]
for layer = 1:nLayers
rls = selectelem(fens, fes, label = layer)
push!(
regions,
FDataDict(
"femm" => FEMMDeforLinear(
MR,
IntegDomain(subset(fes, rls), gr),
CSys(3, 3, updatecs!),
material,
),
),
)
end
# The essential boundary conditions: the entire surface
bfes = meshboundary(fes)
lx0 = connectednodes(bfes)
eclamped1 = FDataDict(
"displacement" => displacement_fun_x,
"component" => 1,
"node_list" => lx0,
)
eclamped2 = FDataDict(
"displacement" => displacement_fun_y,
"component" => 2,
"node_list" => lx0,
)
eclamped3 = FDataDict(
"displacement" => displacement_fun_z,
"component" => 3,
"node_list" => lx0,
)
modeldata = FDataDict(
"fens" => fens,
"regions" => regions,
"essential_bcs" => [eclamped1, eclamped2, eclamped3],
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
modeldata["elementsize"] = t / Refinement
modeldata["geometricaltolerance"] = tolerance
push!(modeldatasequence, modeldata)
end # for refinement
for (extrap, nodevalmeth) in zip([:default], [:invdistance])
filebase = "All_EBC_2dir_$(elementtag)_$(extrap)"
for modeldata in modeldatasequence
u = modeldata["u"]
geom = modeldata["geom"]
modeldata["postprocessing"] = FDataDict(
"file" => filebase * "-s",
"quantity" => :Cauchy,
"component" => collect(1:6),
"outputcsys" => CSys(3),
"nodevalmethod" => nodevalmeth,
"reportat" => extrap,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
end
println("")
println("Stress RMS error")
for md in modeldatasequence
md["targetfields"] = [e["field"] for e in md["postprocessing"]["exported"]]
end
elementsizes, errornorms, p = AlgoBaseModule.evalconvergencestudy(modeldatasequence)
println("Normalized Approximate Error = $(errornorms)")
f = log.(vec(errornorms))
A = hcat(log.(vec(elementsizes[1:(end-1)])), ones(size(f)))
p = A \ f
println("Linear log-log fit: p = $(p)")
csvFile = filebase * "_Stress" * ".CSV"
savecsv(
csvFile,
elementsizes = vec(elementsizes[1:(end-1)]),
elementsizes2 = vec(elementsizes[1:(end-1)] .^ 2),
elementsizes3 = vec(elementsizes[1:(end-1)] .^ 3),
errornorms = vec(errornorms),
)
println("Wrote $csvFile")
println("")
println("Displacement RMS error")
for md in modeldatasequence
md["targetfields"] = [md["u"] for r in md["regions"]]
end
elementsizes, errornorms, p = AlgoBaseModule.evalconvergencestudy(modeldatasequence)
println("Normalized Approximate Error = $(errornorms)")
f = log.(vec(errornorms))
A = hcat(log.(vec(elementsizes[1:(end-1)])), ones(size(f)))
p = A \ f
println("Linear log-log fit: p = $(p)")
csvFile = filebase * "_Displ" * ".CSV"
savecsv(
csvFile,
elementsizes = vec(elementsizes[1:(end-1)]),
elementsizes2 = vec(elementsizes[1:(end-1)] .^ 2),
elementsizes3 = vec(elementsizes[1:(end-1)] .^ 3),
errornorms = vec(errornorms),
)
println("Wrote $csvFile")
# @async run(`"paraview.exe" $csvFile`)
end # extrap
println("Done")
end # All_EBC_2dir_T10_conv
function All_EBC_2dir_H8_conv()
elementtag = "H8"
println("""
Fiber-reinforced block: $(elementtag)
""")
modeldatasequence = FDataDict[]
for Refinement in Refinements
# This is the material model
MR = DeforModelRed3D
material = MatDeforElastOrtho(
MR,
0.0,
E1,
E2,
E3,
nu12,
nu13,
nu23,
G12,
G13,
G23,
CTE1,
CTE2,
CTE3,
)
# Select how fine the mesh should be
nts = Refinement * ones(Int, nLayers)# number of elements per layer
tnts = sum(nts)
na, nb = tnts, tnts
xs = collect(linearspace(0.0, a, na + 1))
ys = collect(linearspace(0.0, b, nb + 1))
fens, fes = H8layeredplatex(xs, ys, ts, nts)
println("Mesh: na, nb, nts = $na, $nb, $nts")
println("count(fens) = $(count(fens))")
# The volume integrals are evaluated using this rule
gr = GaussRule(3, 2)
# We will create one region per layer
regions = FDataDict[]
for layer = 1:nLayers
rls = selectelem(fens, fes, label = layer)
push!(
regions,
FDataDict(
"femm" => FEMMDeforLinear(
MR,
IntegDomain(subset(fes, rls), gr),
CSys(3, 3, updatecs!),
material,
),
),
)
end
# The essential boundary conditions: the entire surface
bfes = meshboundary(fes)
lx0 = connectednodes(bfes)
eclamped1 = FDataDict(
"displacement" => displacement_fun_x,
"component" => 1,
"node_list" => lx0,
)
eclamped2 = FDataDict(
"displacement" => displacement_fun_y,
"component" => 2,
"node_list" => lx0,
)
eclamped3 = FDataDict(
"displacement" => displacement_fun_z,
"component" => 3,
"node_list" => lx0,
)
modeldata = FDataDict(
"fens" => fens,
"regions" => regions,
"essential_bcs" => [eclamped1, eclamped2, eclamped3],
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
modeldata["elementsize"] = t / Refinement
modeldata["geometricaltolerance"] = tolerance
push!(modeldatasequence, modeldata)
end # for refinement
for (extrap, nodevalmeth) in zip([:default], [:invdistance])
filebase = "All_EBC_2dir_$(elementtag)_$(extrap)"
for modeldata in modeldatasequence
u = modeldata["u"]
geom = modeldata["geom"]
modeldata["postprocessing"] = FDataDict(
"file" => filebase * "-s",
"quantity" => :Cauchy,
"component" => collect(1:6),
"outputcsys" => CSys(3),
"nodevalmethod" => nodevalmeth,
"reportat" => extrap,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
end
println("")
println("Stress RMS error")
for md in modeldatasequence
md["targetfields"] = [e["field"] for e in md["postprocessing"]["exported"]]
end
elementsizes, errornorms, p = AlgoBaseModule.evalconvergencestudy(modeldatasequence)
println("Normalized Approximate Error = $(errornorms)")
f = log.(vec(errornorms))
A = hcat(log.(vec(elementsizes[1:(end-1)])), ones(size(f)))
p = A \ f
println("Linear log-log fit: p = $(p)")
csvFile = filebase * "_Stress" * ".CSV"
savecsv(
csvFile,
elementsizes = vec(elementsizes[1:(end-1)]),
elementsizes2 = vec(elementsizes[1:(end-1)] .^ 2),
elementsizes3 = vec(elementsizes[1:(end-1)] .^ 3),
errornorms = vec(errornorms),
)
println("Wrote $csvFile")
println("")
println("Displacement RMS error")
for md in modeldatasequence
md["targetfields"] = [md["u"] for r in md["regions"]]
end
elementsizes, errornorms, p = AlgoBaseModule.evalconvergencestudy(modeldatasequence)
println("Normalized Approximate Error = $(errornorms)")
f = log.(vec(errornorms))
A = hcat(log.(vec(elementsizes[1:(end-1)])), ones(size(f)))
p = A \ f
println("Linear log-log fit: p = $(p)")
csvFile = filebase * "_Displ" * ".CSV"
savecsv(
csvFile,
elementsizes = vec(elementsizes[1:(end-1)]),
elementsizes2 = vec(elementsizes[1:(end-1)] .^ 2),
elementsizes3 = vec(elementsizes[1:(end-1)] .^ 3),
errornorms = vec(errornorms),
)
println("Wrote $csvFile")
# @async run(`"paraview.exe" $csvFile`)
end # extrap
println("Done")
end # All_EBC_2dir_H8_conv
function allrun()
println("#####################################################")
println("# All_EBC_2dir_MSH8_conv_alt ")
All_EBC_2dir_MSH8_conv_alt()
println("#####################################################")
println("# All_EBC_2dir_MST10_conv ")
All_EBC_2dir_MST10_conv()
println("#####################################################")
println("# All_EBC_2dir_MSH8_conv ")
All_EBC_2dir_MSH8_conv()
println("#####################################################")
println("# All_EBC_2dir_T10_conv ")
All_EBC_2dir_T10_conv()
println("#####################################################")
println("# All_EBC_2dir_H8_conv ")
All_EBC_2dir_H8_conv()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 7253 | using Gaston
# using PyCall
using DelimitedFiles
function loadcsv(inputcsv)
contents = readdlm(inputcsv, ',', Float64, '\n'; header = true)
return contents
end
function coldata(inputcsv, theset)
contents = loadcsv(inputcsv)
return contents[1][:, theset]
end
set(
axis = "loglog",
plotstyle = "linespoints",
linewidth = 2,
pointsize = 2,
xrange = "[0.002:0.1]",
xlabel = "Element size",
ylabel = "Approximate error",
grid = "on",
title = "",
)
# inputcsv = "All_EBC_2dir_T10_default_Stress.CSV"
# x = coldata(inputcsv, 1)
# y = coldata(inputcsv, 4)
# plot(x, abs.(y), legend = "T10", color = "black", marker = "x")
# inputcsv = "All_EBC_2dir_MST10_extrapmean_Stress.CSV"
# x = coldata(inputcsv, 1)
# y = coldata(inputcsv, 4)
# plot!(x, abs.(y), legend="MSOE", color = "black", marker = "edmd")
# inputcsv = "All_EBC_2dir_MST10_extraptrend_Stress.CSV"
# x = coldata(inputcsv, 1)
# y = coldata(inputcsv, 4)
# plot!(x, abs.(y), legend="TBE", color = "black", marker = "ecircle")
f = figure()
inputcsv = "All_EBC_2dir_MSH8_extraptrend_trapezoidal_Stress.CSV"
x = coldata(inputcsv, 1)
y = coldata(inputcsv, 4)
plot!(x, abs.(y), legend = "Trapezoidal", color = "black", marker = "x")
inputcsv = "All_EBC_2dir_MSH8_extraptrend_Stress.CSV"
x = coldata(inputcsv, 1)
y = coldata(inputcsv, 4)
plot!(x, abs.(y), legend = "Gauss", color = "black", marker = "ecircle")
figure(f)
# inputcsv = "All_EBC_2dir_MST10_extrapmean_Stress.CSV"
# x = coldata(inputcsv, 1)
# y = coldata(inputcsv, 4)
# plot!(x, abs.(y), legend="MSOE", color = "black", marker = "edmd")
# inputcsv = "All_EBC_2dir_MST10_extraptrend_Stress.CSV"
# x = coldata(inputcsv, 1)
# y = coldata(inputcsv, 4)
# plot!(x, abs.(y), legend="TBE", color = "black", marker = "ecircle")
# julia> include("All_EBC_2dir_examples.jl"); All_EBC_2dir_examples.allrun()
# WARNING: replacing module All_EBC_2dir_examples.
# #####################################################
# # All_EBC_2dir_MST10_conv
# Fiber-reinforced block: MST10
# Mesh: na, nb, nts = 3, 3, [3]
# count(fens) = 343
# Mesh: na, nb, nts = 6, 6, [6]
# count(fens) = 2197
# Mesh: na, nb, nts = 12, 12, [12]
# count(fens) = 15625
# Mesh: na, nb, nts = 24, 24, [24]
# count(fens) = 117649
# Stress RMS error
# Normalized Approximate Error = [0.0192602, 0.00861774, 0.00354827]
# Linear log-log fit: p = [1.22022, 0.214338]
# Wrote All_EBC_2dir_MST10_extrapmean_Stress.CSV
# Displacement RMS error
# Normalized Approximate Error = [0.00508317, 0.00143038, 0.000373055]
# Linear log-log fit: p = [1.88413, 1.13915]
# Wrote All_EBC_2dir_MST10_extrapmean_Displ.CSV
# Mesh: na, nb, nts = 3, 3, [3]
# count(fens) = 343
# Mesh: na, nb, nts = 6, 6, [6]
# count(fens) = 2197
# Mesh: na, nb, nts = 12, 12, [12]
# count(fens) = 15625
# Mesh: na, nb, nts = 24, 24, [24]
# count(fens) = 117649
# Stress RMS error
# Normalized Approximate Error = [0.0167626, 0.00613563, 0.00220595]
# Linear log-log fit: p = [1.46289, 0.889953]
# Wrote All_EBC_2dir_MST10_extraptrend_Stress.CSV
# Displacement RMS error
# Normalized Approximate Error = [0.00508317, 0.00143038, 0.000373055]
# Linear log-log fit: p = [1.88413, 1.13915]
# Wrote All_EBC_2dir_MST10_extraptrend_Displ.CSV
# Mesh: na, nb, nts = 3, 3, [3]
# count(fens) = 343
# Mesh: na, nb, nts = 6, 6, [6]
# count(fens) = 2197
# Mesh: na, nb, nts = 12, 12, [12]
# count(fens) = 15625
# Mesh: na, nb, nts = 24, 24, [24]
# count(fens) = 117649
# Stress RMS error
# Normalized Approximate Error = [0.017322, 0.00778243, 0.00321]
# Linear log-log fit: p = [1.21598, 0.0942623]
# Wrote All_EBC_2dir_MST10_default_Stress.CSV
# Displacement RMS error
# Normalized Approximate Error = [0.00508317, 0.00143038, 0.000373055]
# Linear log-log fit: p = [1.88413, 1.13915]
# Wrote All_EBC_2dir_MST10_default_Displ.CSV
# Done
# #####################################################
# # All_EBC_2dir_MST10_conv
# Fiber-reinforced block: MST10
# Mesh: na, nb, nts = 3, 3, [3]
# count(fens) = 64
# Mesh: na, nb, nts = 6, 6, [6]
# count(fens) = 343
# Mesh: na, nb, nts = 12, 12, [12]
# count(fens) = 2197
# Mesh: na, nb, nts = 24, 24, [24]
# count(fens) = 15625
# Stress RMS error
# Normalized Approximate Error = [0.0288266, 0.0128894, 0.00580383]
# Linear log-log fit: p = [1.15616, 0.384708]
# Wrote All_EBC_2dir_MST10_extrapmean_Stress.CSV
# Displacement RMS error
# Normalized Approximate Error = [0.00947204, 0.00264193, 0.000695543]
# Linear log-log fit: p = [1.88373, 1.75715]
# Wrote All_EBC_2dir_MST10_extrapmean_Displ.CSV
# Mesh: na, nb, nts = 3, 3, [3]
# count(fens) = 64
# Mesh: na, nb, nts = 6, 6, [6]
# count(fens) = 343
# Mesh: na, nb, nts = 12, 12, [12]
# count(fens) = 2197
# Mesh: na, nb, nts = 24, 24, [24]
# count(fens) = 15625
# Stress RMS error
# Normalized Approximate Error = [0.0253678, 0.0103545, 0.00442978]
# Linear log-log fit: p = [1.25885, 0.599482]
# Wrote All_EBC_2dir_MST10_extraptrend_Stress.CSV
# Displacement RMS error
# Normalized Approximate Error = [0.00947204, 0.00264193, 0.000695543]
# Linear log-log fit: p = [1.88373, 1.75715]
# Wrote All_EBC_2dir_MST10_extraptrend_Displ.CSV
# Mesh: na, nb, nts = 3, 3, [3]
# count(fens) = 64
# Mesh: na, nb, nts = 6, 6, [6]
# count(fens) = 343
# Mesh: na, nb, nts = 12, 12, [12]
# count(fens) = 2197
# Mesh: na, nb, nts = 24, 24, [24]
# count(fens) = 15625
# Stress RMS error
# Normalized Approximate Error = [0.0288266, 0.0128894, 0.00580383]
# Linear log-log fit: p = [1.15616, 0.384708]
# Wrote All_EBC_2dir_MST10_default_Stress.CSV
# Displacement RMS error
# Normalized Approximate Error = [0.00947204, 0.00264193, 0.000695543]
# Linear log-log fit: p = [1.88373, 1.75715]
# Wrote All_EBC_2dir_MST10_default_Displ.CSV
# Done
# #####################################################
# # All_EBC_2dir_T10_conv
# Fiber-reinforced block: T10
# Mesh: na, nb, nts = 3, 3, [3]
# count(fens) = 343
# Mesh: na, nb, nts = 6, 6, [6]
# count(fens) = 2197
# Mesh: na, nb, nts = 12, 12, [12]
# count(fens) = 15625
# Mesh: na, nb, nts = 24, 24, [24]
# count(fens) = 117649
# Stress RMS error
# Normalized Approximate Error = [0.0129395, 0.00559644, 0.00226381]
# Linear log-log fit: p = [1.25748, -0.0593887]
# Wrote All_EBC_2dir_T10_default_Stress.CSV
# Displacement RMS error
# Normalized Approximate Error = [0.00289237, 0.000501187, 8.09591e-5]
# Linear log-log fit: p = [2.57946, 2.93927]
# Wrote All_EBC_2dir_T10_default_Displ.CSV
# Done
# #####################################################
# # All_EBC_2dir_T10_conv
# Fiber-reinforced block: T10
# Mesh: na, nb, nts = 3, 3, [3]
# count(fens) = 64
# Mesh: na, nb, nts = 6, 6, [6]
# count(fens) = 343
# Mesh: na, nb, nts = 12, 12, [12]
# count(fens) = 2197
# Mesh: na, nb, nts = 24, 24, [24]
# count(fens) = 15625
# Stress RMS error
# Normalized Approximate Error = [0.023016, 0.0101339, 0.00453253]
# Linear log-log fit: p = [1.17213, 0.212446]
# Wrote All_EBC_2dir_T10_default_Stress.CSV
# Displacement RMS error
# Normalized Approximate Error = [0.00929339, 0.00262218, 0.00069389]
# Linear log-log fit: p = [1.87171, 1.69831]
# Wrote All_EBC_2dir_T10_default_Displ.CSV
# Done
# true
# julia> include("All_EBC_2dir_plots.jl")
# 1
# julia> include("All_EBC_2dir_plots.jl")
# 1
# julia> include("All_EBC_2dir_plots.jl")
# 1
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 126027 | module LE10NAFEMS_examples
using FinEtools
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule:
linearstatics, exportstresselementwise, exportstress
using FinEtools.MeshExportModule
using FinEtools.MeshImportModule
using FinEtools.AlgoBaseModule: evalconvergencestudy
using LinearAlgebra: cholesky
function LE10NAFEMS_Abaqus_fine_MST10()
# Thick elliptical plate with an elliptical hole is clamped on its exterior
# boundary and is loaded with transverse pressure.
# This is a NAFEMS Benchmark, Test No. LE10.
# The plate is discretized with solid elements.
# Because of the symmetries of the geometry and load, only quarter of the plate is modeled.
# The $\sigma_y=\sigma_2$ at the point $P$ is to be determined. Since the
# target point is on the boundary of the domain it will not be an
# integration node as we use Gauss quadrature. The reference value is -5.38 MPa.
println("LE10NAFEMS: Transverse deflection of elliptical plate with elliptical hole.")
t0 = time()
E = 210e3 * phun("MEGA*PA")# 210e3 MPa
nu = 0.3
qmagn = 1.0 * phun("MEGA*PA")# transverse pressure
sigma_yP = -5.38 * phun("MEGA*PA")# tensile stress at [2.0, 0.0] meters
Ae = 3.25 * phun("m") # Major radius of the exterior ellipse
Be = 2.75 * phun("m") # Minor radius of the exterior ellipse
Ai = 2.0 * phun("m") # Major radius of the interior ellipse
Bi = 1.0 * phun("m") # Minor radius of the interior ellipse
Thickness = 0.6 * phun("m")
tolerance = Thickness / 1000.0 # Geometrical tolerance
INP_file = """
*HEADING
NAFEMS TEST NLE10, REFINED MESH, C3D10HS ELEMENTS --
**
**RESTART, WRITE, FREQUENCY=1
**
*NODE
1, 0., 2.75
2, 0., 2.45825
3, 0., 2.1665
4, 0., 1.87475
5, 0., 1.583
6, 0.349721, 1.84088
7, 0.464205, 2.7218
8, 0.407787, 2.14399
9, 0.351377, 1.56618
10, 0.460635, 2.40185
11, 0.92127, 2.6372
12, 0.865807, 2.35672
13, 0.810348, 2.07624
14, 0.754893, 1.79575
15, 0.699442, 1.51527
16, 1.24873, 2.21951
17, 1.36358, 2.4963
18, 1.20166, 1.96267
19, 1.0404, 1.42884
20, 1.13781, 1.65854
21, 1.783, 2.29921
22, 1.67959, 2.05051
23, 1.57618, 1.80182
24, 1.47278, 1.55312
25, 1.36937, 1.30443
26, 0., 2.75, 0.15
27, 0., 2.45825, 0.15
28, 0., 2.1665, 0.15
29, 0., 1.87475, 0.15
30, 0., 1.583, 0.15
31, 0.46408, 2.72182, 0.15
32, 0.407685, 2.14401, 0.15
33, 0.351362, 1.56618, 0.15
34, 0.92127, 2.6372, 0.15
35, 0.865839, 2.35671, 0.150001
36, 0.810348, 2.07624, 0.15
37, 0.754865, 1.79576, 0.15
38, 0.699442, 1.51527, 0.15
39, 1.36318, 2.49645, 0.15
40, 1.2017, 1.96266, 0.15
41, 1.04034, 1.42886, 0.15
42, 1.783, 2.29921, 0.15
43, 1.67959, 2.05051, 0.15
44, 1.57618, 1.80182, 0.15
45, 1.47278, 1.55312, 0.15
46, 1.36937, 1.30443, 0.15
47, 0., 2.75, 0.3
48, 0., 2.45825, 0.3
49, 0., 2.1665, 0.3
50, 0., 1.87475, 0.3
51, 0., 1.583, 0.3
52, 0.405174, 2.41312, 0.3
53, 0.464205, 2.7218, 0.3
54, 0.407787, 2.14399, 0.3
55, 0.351377, 1.56618, 0.3
56, 0.405174, 1.82962, 0.3
57, 0.92127, 2.6372, 0.3
58, 0.865807, 2.35672, 0.3
59, 0.810348, 2.07624, 0.3
60, 0.754893, 1.79575, 0.3
61, 0.699442, 1.51527, 0.3
62, 1.08986, 1.69033, 0.3
63, 1.36358, 2.4963, 0.3
64, 1.20166, 1.96267, 0.3
65, 1.0404, 1.42884, 0.3
66, 1.29667, 2.18772, 0.3
67, 1.783, 2.29921, 0.3
68, 1.67959, 2.05051, 0.3
69, 1.57618, 1.80182, 0.3
70, 1.47278, 1.55312, 0.3
71, 1.36937, 1.30443, 0.3
72, 0., 2.75, 0.45
73, 0., 2.45825, 0.45
74, 0., 2.1665, 0.45
75, 0., 1.87475, 0.45
76, 0., 1.583, 0.45
77, 0.46408, 2.72182, 0.45
78, 0.407685, 2.14401, 0.45
79, 0.351362, 1.56618, 0.45
80, 0.92127, 2.6372, 0.45
81, 0.865774, 2.35673, 0.45
82, 0.810348, 2.07624, 0.45
83, 0.754921, 1.79575, 0.45
84, 0.699442, 1.51527, 0.45
85, 1.36318, 2.49645, 0.45
86, 1.2017, 1.96266, 0.45
87, 1.04034, 1.42886, 0.45
88, 1.783, 2.29921, 0.45
89, 1.67959, 2.05051, 0.45
90, 1.57618, 1.80182, 0.45
91, 1.47278, 1.55312, 0.45
92, 1.36937, 1.30443, 0.45
93, 0., 2.75, 0.6
94, 0., 2.45825, 0.6
95, 0., 2.1665, 0.6
96, 0., 1.87475, 0.6
97, 0., 1.583, 0.6
98, 0.349721, 1.84088, 0.6
99, 0.464205, 2.7218, 0.6
100, 0.407787, 2.14399, 0.6
101, 0.351377, 1.56618, 0.6
102, 0.460635, 2.40185, 0.6
103, 0.92127, 2.6372, 0.6
104, 0.865807, 2.35672, 0.6
105, 0.810348, 2.07624, 0.6
106, 0.754893, 1.79575, 0.6
107, 0.699442, 1.51527, 0.6
108, 1.24873, 2.21951, 0.6
109, 1.36358, 2.4963, 0.6
110, 1.20166, 1.96267, 0.6
111, 1.0404, 1.42884, 0.6
112, 1.13781, 1.65854, 0.6
113, 1.783, 2.29921, 0.6
114, 1.67959, 2.05051, 0.6
115, 1.57618, 1.80182, 0.6
116, 1.47278, 1.55312, 0.6
117, 1.36937, 1.30443, 0.6
119, 0., 1.43725
120, 0., 1.2915
121, 0., 1.14575
122, 0., 1.
123, 0.295266, 1.12346
125, 0.323749, 1.27758
126, 0.29612, 0.988978
127, 0.349721, 1.40338
129, 0.672214, 1.3753
130, 0.644987, 1.23534
131, 0.617759, 1.09538
132, 0.590531, 0.955415
133, 0.983313, 1.28695
135, 0.960781, 1.16328
136, 0.881158, 0.897714
137, 0.928857, 1.00702
139, 1.31828, 1.18153
140, 1.26718, 1.05863
141, 1.21609, 0.93573
142, 1.165, 0.812831
144, 0., 1.43725, 0.15
145, 0., 1.2915, 0.15
146, 0., 1.14575, 0.15
147, 0., 1., 0.15
149, 0.323718, 1.27758, 0.15
150, 0.296109, 0.988979, 0.15
152, 0.672215, 1.3753, 0.15
153, 0.644987, 1.23534, 0.15
154, 0.617759, 1.09538, 0.15
155, 0.590531, 0.955415, 0.15
157, 0.960677, 1.1633, 0.15
158, 0.881104, 0.897727, 0.15
160, 1.31828, 1.18153, 0.15
161, 1.26718, 1.05863, 0.15
162, 1.21609, 0.93573, 0.15
163, 1.165, 0.812831, 0.15
165, 0., 1.43725, 0.3
166, 0., 1.2915, 0.3
167, 0., 1.14575, 0.3
168, 0., 1., 0.3
169, 0.322493, 1.40917, 0.3
171, 0.323749, 1.27758, 0.3
172, 0.29612, 0.988978, 0.3
173, 0.322493, 1.11767, 0.3
175, 0.672214, 1.3753, 0.3
176, 0.644987, 1.23534, 0.3
177, 0.617759, 1.09538, 0.3
178, 0.590531, 0.955415, 0.3
179, 0.904993, 1.02409, 0.3
181, 0.960781, 1.16328, 0.3
182, 0.881158, 0.897714, 0.3
183, 1.00718, 1.26988, 0.3
185, 1.31828, 1.18153, 0.3
186, 1.26718, 1.05863, 0.3
187, 1.21609, 0.93573, 0.3
188, 1.165, 0.812831, 0.3
190, 0., 1.43725, 0.45
191, 0., 1.2915, 0.45
192, 0., 1.14575, 0.45
193, 0., 1., 0.45
195, 0.323718, 1.27758, 0.45
196, 0.296109, 0.988979, 0.45
198, 0.672214, 1.3753, 0.45
199, 0.644987, 1.23534, 0.45
200, 0.617759, 1.09538, 0.45
201, 0.590531, 0.955415, 0.45
203, 0.960677, 1.1633, 0.45
204, 0.881104, 0.897727, 0.45
206, 1.31828, 1.18153, 0.45
207, 1.26718, 1.05863, 0.45
208, 1.21609, 0.93573, 0.45
209, 1.165, 0.812831, 0.45
211, 0., 1.43725, 0.6
212, 0., 1.2915, 0.6
213, 0., 1.14575, 0.6
214, 0., 1., 0.6
215, 0.295266, 1.12346, 0.6
217, 0.323749, 1.27758, 0.6
218, 0.29612, 0.988978, 0.6
219, 0.349721, 1.40338, 0.6
221, 0.672214, 1.3753, 0.6
222, 0.644987, 1.23534, 0.6
223, 0.617759, 1.09538, 0.6
224, 0.590531, 0.955415, 0.6
225, 0.983313, 1.28695, 0.6
227, 0.960781, 1.16328, 0.6
228, 0.881158, 0.897714, 0.6
229, 0.928857, 1.00702, 0.6
231, 1.31828, 1.18153, 0.6
232, 1.26718, 1.05863, 0.6
233, 1.21609, 0.93573, 0.6
234, 1.165, 0.812831, 0.6
240, 1.67882, 1.43583
241, 2.08558, 2.10909
242, 1.83339, 1.65317
243, 1.58119, 1.19726
244, 1.97057, 1.84405
245, 2.36495, 1.88628
246, 2.21908, 1.68217
247, 2.0732, 1.47806
248, 1.92733, 1.27395
249, 1.78146, 1.06984
250, 2.42305, 1.46733
251, 2.61589, 1.63192
252, 2.29099, 1.27633
253, 1.9661, 0.920737
254, 2.13131, 1.05911
255, 2.83277, 1.348
256, 2.65696, 1.19818
257, 2.48116, 1.04837
258, 2.30535, 0.898553
259, 2.12955, 0.748738
265, 2.08556, 2.10911, 0.15
266, 1.83332, 1.65322, 0.15
267, 1.58116, 1.19728, 0.15
268, 2.36495, 1.88628, 0.15
269, 2.21908, 1.68217, 0.15
270, 2.0732, 1.47806, 0.15
271, 1.92733, 1.27395, 0.15
272, 1.78146, 1.06984, 0.15
273, 2.61586, 1.63196, 0.15
274, 2.29096, 1.27636, 0.15
275, 1.96604, 0.920794, 0.15
276, 2.83277, 1.348, 0.15
277, 2.65696, 1.19818, 0.15
278, 2.48116, 1.04837, 0.15
279, 2.30535, 0.898553, 0.15
280, 2.12955, 0.748738, 0.15
286, 1.9281, 1.88863, 0.3
287, 2.08558, 2.10909, 0.3
288, 1.83339, 1.65317, 0.3
289, 1.58119, 1.19726, 0.3
290, 1.72129, 1.39125, 0.3
291, 2.36495, 1.88628, 0.3
292, 2.21908, 1.68217, 0.3
293, 2.0732, 1.47806, 0.3
294, 1.92733, 1.27395, 0.3
295, 1.78146, 1.06984, 0.3
296, 2.10137, 1.1134, 0.3
297, 2.61589, 1.63192, 0.3
298, 2.29099, 1.27633, 0.3
299, 1.9661, 0.920737, 0.3
300, 2.45298, 1.41303, 0.3
301, 2.83277, 1.348, 0.3
302, 2.65696, 1.19818, 0.3
303, 2.48116, 1.04837, 0.3
304, 2.30535, 0.898553, 0.3
305, 2.12955, 0.748738, 0.3
311, 2.08556, 2.10911, 0.45
312, 1.83332, 1.65322, 0.45
313, 1.58116, 1.19728, 0.45
314, 2.36495, 1.88628, 0.45
315, 2.21908, 1.68217, 0.45
316, 2.0732, 1.47806, 0.45
317, 1.92733, 1.27395, 0.45
318, 1.78146, 1.06984, 0.45
319, 2.61586, 1.63196, 0.45
320, 2.29096, 1.27636, 0.45
321, 1.96604, 0.920794, 0.45
322, 2.83277, 1.348, 0.45
323, 2.65696, 1.19818, 0.45
324, 2.48116, 1.04837, 0.45
325, 2.30535, 0.898553, 0.45
326, 2.12955, 0.748738, 0.45
332, 1.67882, 1.43583, 0.6
333, 2.08558, 2.10909, 0.6
334, 1.83339, 1.65317, 0.6
335, 1.58119, 1.19726, 0.6
336, 1.97057, 1.84405, 0.6
337, 2.36495, 1.88628, 0.6
338, 2.21908, 1.68217, 0.6
339, 2.0732, 1.47806, 0.6
340, 1.92733, 1.27395, 0.6
341, 1.78146, 1.06984, 0.6
342, 2.42305, 1.46733, 0.6
343, 2.61589, 1.63192, 0.6
344, 2.29099, 1.27633, 0.6
345, 1.9661, 0.920737, 0.6
346, 2.13131, 1.05911, 0.6
347, 2.83277, 1.348, 0.6
348, 2.65696, 1.19818, 0.6
349, 2.48116, 1.04837, 0.6
350, 2.30535, 0.898553, 0.6
351, 2.12955, 0.748738, 0.6
357, 1.3802, 0.861948
359, 1.45669, 0.971566
360, 1.33218, 0.74587
361, 1.52432, 1.06424
363, 1.7094, 0.9687
364, 1.63734, 0.867555
365, 1.56528, 0.76641
366, 1.49321, 0.665266
367, 1.86887, 0.835357
369, 1.80562, 0.7447
370, 1.64514, 0.568662
371, 1.72475, 0.633067
373, 2.04291, 0.674803
374, 1.95628, 0.600869
375, 1.86965, 0.526934
376, 1.78302, 0.453
383, 1.45663, 0.971598, 0.15
384, 1.33216, 0.745881, 0.15
386, 1.7094, 0.9687, 0.15
387, 1.63734, 0.867555, 0.15
388, 1.56527, 0.766411, 0.15
389, 1.49321, 0.665266, 0.15
391, 1.80555, 0.744761, 0.15
392, 1.64506, 0.568725, 0.15
394, 2.04291, 0.674803, 0.15
395, 1.95628, 0.600869, 0.15
396, 1.86965, 0.526934, 0.15
397, 1.78302, 0.453, 0.15
403, 1.50335, 1.08599, 0.3
405, 1.45669, 0.971566, 0.3
406, 1.33218, 0.74587, 0.3
407, 1.40117, 0.840193, 0.3
409, 1.7094, 0.9687, 0.3
410, 1.63734, 0.867555, 0.3
411, 1.56528, 0.76641, 0.3
412, 1.49321, 0.665266, 0.3
413, 1.71018, 0.660278, 0.3
415, 1.80562, 0.7447, 0.3
416, 1.64514, 0.568662, 0.3
417, 1.88344, 0.808146, 0.3
419, 2.04291, 0.674803, 0.3
420, 1.95628, 0.600869, 0.3
421, 1.86965, 0.526934, 0.3
422, 1.78302, 0.453, 0.3
429, 1.45663, 0.971598, 0.45
430, 1.33216, 0.745881, 0.45
432, 1.7094, 0.9687, 0.45
433, 1.63734, 0.867555, 0.45
434, 1.56528, 0.76641, 0.45
435, 1.49321, 0.665266, 0.45
437, 1.80555, 0.744761, 0.45
438, 1.64506, 0.568725, 0.45
440, 2.04291, 0.674803, 0.45
441, 1.95628, 0.600869, 0.45
442, 1.86965, 0.526934, 0.45
443, 1.78302, 0.453, 0.45
449, 1.3802, 0.861948, 0.6
451, 1.45669, 0.971566, 0.6
452, 1.33218, 0.74587, 0.6
453, 1.52432, 1.06424, 0.6
455, 1.7094, 0.9687, 0.6
456, 1.63734, 0.867555, 0.6
457, 1.56528, 0.76641, 0.6
458, 1.49321, 0.665266, 0.6
459, 1.86887, 0.835357, 0.6
461, 1.80562, 0.7447, 0.6
462, 1.64514, 0.568662, 0.6
463, 1.72475, 0.633067, 0.6
465, 2.04291, 0.674803, 0.6
466, 1.95628, 0.600869, 0.6
467, 1.86965, 0.526934, 0.6
468, 1.78302, 0.453, 0.6
474, 1.94695, 0.424348
475, 2.24798, 0.58156
476, 2.05826, 0.469066
477, 1.86854, 0.356567
478, 2.14776, 0.499577
479, 2.33925, 0.398285
480, 2.23884, 0.360673
481, 2.13843, 0.323059
482, 2.03802, 0.285444
483, 1.93761, 0.247826
484, 2.27387, 0.199143
485, 2.39752, 0.202727
486, 2.19052, 0.165412
487, 1.98365, 0.127605
488, 2.07305, 0.123912
489, 2.417, 0.
490, 2.31275, 0.
491, 2.2085, 0.
492, 2.10425, 0.
493, 2., 0.
499, 2.24792, 0.581668, 0.15
500, 2.0582, 0.46915, 0.15
501, 1.86848, 0.356646, 0.15
502, 2.33925, 0.398285, 0.15
503, 2.23884, 0.360665, 0.15
504, 2.13843, 0.323059, 0.15
505, 2.03801, 0.28545, 0.15
506, 1.93761, 0.247826, 0.15
507, 2.3973, 0.203669, 0.15
508, 2.19046, 0.16566, 0.15
509, 1.98362, 0.127728, 0.15
510, 2.417, 0., 0.15
511, 2.31275, 0., 0.15
512, 2.2085, 0., 0.15
513, 2.10425, 0., 0.15
514, 2., 0., 0.15
520, 2.13399, 0.535899, 0.3
521, 2.24798, 0.58156, 0.3
522, 2.05826, 0.469066, 0.3
523, 1.86854, 0.356567, 0.3
524, 1.96072, 0.38803, 0.3
525, 2.33925, 0.398285, 0.3
526, 2.23884, 0.360673, 0.3
527, 2.13843, 0.323059, 0.3
528, 2.03802, 0.285444, 0.3
529, 1.93761, 0.247826, 0.3
530, 2.06921, 0.16153, 0.3
531, 2.39752, 0.202727, 0.3
532, 2.19052, 0.165412, 0.3
533, 1.98365, 0.127605, 0.3
534, 2.27771, 0.16153, 0.3
535, 2.417, 0., 0.3
536, 2.31275, 0., 0.3
537, 2.2085, 0., 0.3
538, 2.10425, 0., 0.3
539, 2., 0., 0.3
545, 2.24792, 0.581668, 0.45
546, 2.0582, 0.46915, 0.45
547, 1.86848, 0.356646, 0.45
548, 2.33925, 0.398285, 0.45
549, 2.23883, 0.360682, 0.45
550, 2.13843, 0.323059, 0.45
551, 2.03802, 0.285437, 0.45
552, 1.93761, 0.247826, 0.45
553, 2.3973, 0.203669, 0.45
554, 2.19046, 0.16566, 0.45
555, 1.98362, 0.127728, 0.45
556, 2.417, 0., 0.45
557, 2.31275, 0., 0.45
558, 2.2085, 0., 0.45
559, 2.10425, 0., 0.45
560, 2., 0., 0.45
566, 1.94695, 0.424348, 0.6
567, 2.24798, 0.58156, 0.6
568, 2.05826, 0.469066, 0.6
569, 1.86854, 0.356567, 0.6
570, 2.14776, 0.499577, 0.6
571, 2.33925, 0.398285, 0.6
572, 2.23884, 0.360673, 0.6
573, 2.13843, 0.323059, 0.6
574, 2.03802, 0.285444, 0.6
575, 1.93761, 0.247826, 0.6
576, 2.27387, 0.199143, 0.6
577, 2.39752, 0.202727, 0.6
578, 2.19052, 0.165412, 0.6
579, 1.98365, 0.127605, 0.6
580, 2.07305, 0.123912, 0.6
581, 2.417, 0., 0.6
582, 2.31275, 0., 0.6
583, 2.2085, 0., 0.6
584, 2.10425, 0., 0.6
585, 2., 0., 0.6
591, 2.4102, 0.723327
592, 3.00992, 1.03732
593, 2.62895, 0.809437
595, 2.81131, 0.876575
596, 3.14145, 0.704781
597, 2.9409, 0.628151
598, 2.74035, 0.551525
599, 2.5398, 0.474903
601, 2.98748, 0.352391
603, 3.22257, 0.356518
604, 2.81014, 0.279227
605, 2.58637, 0.199143
606, 3.25, 0.
607, 3.04175, 0.
608, 2.8335, 0.
609, 2.62525, 0.
616, 3.0099, 1.03736, 0.15
617, 2.62893, 0.809477, 0.15
619, 3.14145, 0.704781, 0.15
620, 2.9409, 0.628168, 0.15
621, 2.74035, 0.551525, 0.15
622, 2.53981, 0.47489, 0.15
625, 2.81, 0.279967, 0.15
626, 3.22257, 0.356538, 0.15
627, 3.25, 0., 0.15
628, 3.04175, 0., 0.15
629, 2.8335, 0., 0.15
630, 2.62525, 0., 0.15
637, 2.78656, 0.949762, 0.3
638, 3.00992, 1.03732, 0.3
639, 2.62895, 0.809437, 0.3
641, 2.43495, 0.650131, 0.3
642, 3.14145, 0.704781, 0.3
643, 2.9409, 0.628151, 0.3
644, 2.74035, 0.551525, 0.3
645, 2.5398, 0.474903, 0.3
647, 2.57868, 0.275762, 0.3
648, 3.22257, 0.356518, 0.3
650, 2.81014, 0.279227, 0.3
651, 2.99518, 0.275762, 0.3
652, 3.25, 0., 0.3
653, 3.04175, 0., 0.3
654, 2.8335, 0., 0.3
655, 2.62525, 0., 0.3
662, 3.0099, 1.03736, 0.45
663, 2.62893, 0.809477, 0.45
665, 3.14145, 0.704781, 0.45
666, 2.94091, 0.628134, 0.45
667, 2.74035, 0.551525, 0.45
668, 2.5398, 0.474916, 0.45
671, 2.81, 0.279967, 0.45
672, 3.22257, 0.356538, 0.45
673, 3.25, 0., 0.45
674, 3.04175, 0., 0.45
675, 2.8335, 0., 0.45
676, 2.62525, 0., 0.45
683, 2.4102, 0.723327, 0.6
684, 3.00992, 1.03732, 0.6
685, 2.62895, 0.809437, 0.6
687, 2.81131, 0.876575, 0.6
688, 3.14145, 0.704781, 0.6
689, 2.9409, 0.628151, 0.6
690, 2.74035, 0.551525, 0.6
691, 2.5398, 0.474903, 0.6
693, 2.98748, 0.352391, 0.6
695, 3.22257, 0.356518, 0.6
696, 2.81014, 0.279227, 0.6
697, 2.58637, 0.199143, 0.6
698, 3.25, 0., 0.6
699, 3.04175, 0., 0.6
700, 2.8335, 0., 0.6
701, 2.62525, 0., 0.6
**
**
*ELEMENT, TYPE=C3D10HS, ELSET=EALL
1, 1, 11, 47, 3, 7, 31, 26,
2, 10, 27
2, 57, 47, 11, 59, 53, 31, 34,
58, 52, 35
3, 13, 3, 59, 11, 8, 32, 36,
12, 10, 35
4, 49, 59, 3, 47, 54, 32, 28,
48, 52, 27
5, 3, 11, 47, 59, 10, 31, 27,
32, 35, 52
6, 13, 59, 3, 15, 36, 32, 8,
14, 37, 6
7, 49, 3, 59, 51, 28, 32, 54,
50, 29, 56
8, 5, 51, 15, 3, 30, 33, 9,
4, 29, 6
9, 61, 15, 51, 59, 38, 33, 55,
60, 37, 56
10, 3, 15, 59, 51, 6, 37, 32,
29, 33, 56
11, 21, 67, 11, 23, 42, 39, 17,
22, 43, 16
12, 57, 11, 67, 59, 34, 39, 63,
58, 35, 66
13, 13, 59, 23, 11, 36, 40, 18,
12, 35, 16
14, 69, 23, 59, 67, 44, 40, 64,
68, 43, 66
15, 11, 23, 67, 59, 16, 43, 39,
35, 40, 66
16, 13, 23, 59, 15, 18, 40, 36,
14, 20, 37
17, 69, 59, 23, 71, 64, 40, 44,
70, 62, 45
18, 25, 15, 71, 23, 19, 41, 46,
24, 20, 45
19, 61, 71, 15, 59, 65, 41, 38,
60, 62, 37
20, 15, 23, 59, 71, 20, 40, 37,
41, 45, 62
21, 57, 103, 47, 59, 80, 77, 53,
58, 81, 52
22, 93, 47, 103, 95, 72, 77, 99,
94, 73, 102
23, 49, 95, 59, 47, 74, 78, 54,
48, 73, 52
24, 105, 59, 95, 103, 82, 78, 100,
104, 81, 102
25, 47, 59, 103, 95, 52, 81, 77,
73, 78, 102
26, 49, 59, 95, 51, 54, 78, 74,
50, 56, 75
27, 105, 95, 59, 107, 100, 78, 82,
106, 98, 83
28, 61, 51, 107, 59, 55, 79, 84,
60, 56, 83
29, 97, 107, 51, 95, 101, 79, 76,
96, 98, 75
30, 51, 59, 95, 107, 56, 78, 75,
79, 83, 98
31, 57, 67, 103, 59, 63, 85, 80,
58, 66, 81
32, 113, 103, 67, 115, 109, 85, 88,
114, 108, 89
33, 69, 59, 115, 67, 64, 86, 90,
68, 66, 89
34, 105, 115, 59, 103, 110, 86, 82,
104, 108, 81
35, 59, 67, 103, 115, 66, 85, 81,
86, 89, 108
36, 69, 115, 59, 71, 90, 86, 64,
70, 91, 62
37, 105, 59, 115, 107, 82, 86, 110,
106, 83, 112
38, 61, 107, 71, 59, 84, 87, 65,
60, 83, 62
39, 117, 71, 107, 115, 92, 87, 111,
116, 91, 112
40, 59, 71, 115, 107, 62, 91, 86,
83, 87, 112
41, 5, 15, 51, 120, 9, 33, 30,
119, 127, 144
42, 61, 51, 15, 176, 55, 33, 38,
175, 169, 152
43, 130, 120, 176, 15, 125, 149, 153,
129, 127, 152
44, 166, 176, 120, 51, 171, 149, 145,
165, 169, 144
45, 120, 15, 51, 176, 127, 33, 144,
149, 152, 169
46, 130, 176, 120, 132, 153, 149, 125,
131, 154, 123
47, 166, 120, 176, 168, 145, 149, 171,
167, 146, 173
48, 122, 168, 132, 120, 147, 150, 126,
121, 146, 123
49, 178, 132, 168, 176, 155, 150, 172,
177, 154, 173
50, 120, 132, 176, 168, 123, 154, 149,
146, 150, 173
51, 25, 71, 15, 140, 46, 41, 19,
139, 160, 133
52, 61, 15, 71, 176, 38, 41, 65,
175, 152, 183
53, 130, 176, 140, 15, 153, 157, 135,
129, 152, 133
54, 186, 140, 176, 71, 161, 157, 181,
185, 160, 183
55, 15, 140, 71, 176, 133, 160, 41,
152, 157, 183
56, 130, 140, 176, 132, 135, 157, 153,
131, 137, 154
57, 186, 176, 140, 188, 181, 157, 161,
187, 179, 162
58, 142, 132, 188, 140, 136, 158, 163,
141, 137, 162
59, 178, 188, 132, 176, 182, 158, 155,
177, 179, 154
60, 132, 140, 176, 188, 137, 157, 154,
158, 162, 179
61, 61, 107, 51, 176, 84, 79, 55,
175, 198, 169
62, 97, 51, 107, 212, 76, 79, 101,
211, 190, 219
63, 166, 212, 176, 51, 191, 195, 171,
165, 190, 169
64, 222, 176, 212, 107, 199, 195, 217,
221, 198, 219
65, 51, 176, 107, 212, 169, 198, 79,
190, 195, 219
66, 166, 176, 212, 168, 171, 195, 191,
167, 173, 192
67, 222, 212, 176, 224, 217, 195, 199,
223, 215, 200
68, 178, 168, 224, 176, 172, 196, 201,
177, 173, 200
69, 214, 224, 168, 212, 218, 196, 193,
213, 215, 192
70, 168, 176, 212, 224, 173, 195, 192,
196, 200, 215
71, 61, 71, 107, 176, 65, 87, 84,
175, 183, 198
72, 117, 107, 71, 232, 111, 87, 92,
231, 225, 206
73, 186, 176, 232, 71, 181, 203, 207,
185, 183, 206
74, 222, 232, 176, 107, 227, 203, 199,
221, 225, 198
75, 176, 71, 107, 232, 183, 87, 198,
203, 206, 225
76, 186, 232, 176, 188, 207, 203, 181,
187, 208, 179
77, 222, 176, 232, 224, 199, 203, 227,
223, 200, 229
78, 178, 224, 188, 176, 201, 204, 182,
177, 200, 179
79, 234, 188, 224, 232, 209, 204, 228,
233, 208, 229
80, 176, 188, 232, 224, 179, 208, 203,
200, 204, 229
81, 21, 245, 67, 23, 241, 265, 42,
22, 244, 43
82, 291, 67, 245, 293, 287, 265, 268,
292, 286, 269
83, 247, 23, 293, 245, 242, 266, 270,
246, 244, 269
84, 69, 293, 23, 67, 288, 266, 44,
68, 286, 43
85, 23, 245, 67, 293, 244, 265, 43,
266, 269, 286
86, 247, 293, 23, 249, 270, 266, 242,
248, 271, 240
87, 69, 23, 293, 71, 44, 266, 288,
70, 45, 290
88, 25, 71, 249, 23, 46, 267, 243,
24, 45, 240
89, 295, 249, 71, 293, 272, 267, 289,
294, 271, 290
90, 23, 249, 293, 71, 240, 271, 266,
45, 267, 290
91, 255, 301, 245, 257, 276, 273, 251,
256, 277, 250
92, 291, 245, 301, 293, 268, 273, 297,
292, 269, 300
93, 247, 293, 257, 245, 270, 274, 252,
246, 269, 250
94, 303, 257, 293, 301, 278, 274, 298,
302, 277, 300
95, 245, 257, 301, 293, 250, 277, 273,
269, 274, 300
96, 247, 257, 293, 249, 252, 274, 270,
248, 254, 271
97, 303, 293, 257, 305, 298, 274, 278,
304, 296, 279
98, 259, 249, 305, 257, 253, 275, 280,
258, 254, 279
99, 295, 305, 249, 293, 299, 275, 272,
294, 296, 271
100, 249, 257, 293, 305, 254, 274, 271,
275, 279, 296
101, 291, 337, 67, 293, 314, 311, 287,
292, 315, 286
102, 113, 67, 337, 115, 88, 311, 333,
114, 89, 336
103, 69, 115, 293, 67, 90, 312, 288,
68, 89, 286
104, 339, 293, 115, 337, 316, 312, 334,
338, 315, 336
105, 67, 293, 337, 115, 286, 315, 311,
89, 312, 336
106, 69, 293, 115, 71, 288, 312, 90,
70, 290, 91
107, 339, 115, 293, 341, 334, 312, 316,
340, 332, 317
108, 295, 71, 341, 293, 289, 313, 318,
294, 290, 317
109, 117, 341, 71, 115, 335, 313, 92,
116, 332, 91
110, 71, 293, 115, 341, 290, 312, 91,
313, 317, 332
111, 291, 301, 337, 293, 297, 319, 314,
292, 300, 315
112, 347, 337, 301, 349, 343, 319, 322,
348, 342, 323
113, 303, 293, 349, 301, 298, 320, 324,
302, 300, 323
114, 339, 349, 293, 337, 344, 320, 316,
338, 342, 315
115, 293, 301, 337, 349, 300, 319, 315,
320, 323, 342
116, 303, 349, 293, 305, 324, 320, 298,
304, 325, 296
117, 339, 293, 349, 341, 316, 320, 344,
340, 317, 346
118, 295, 341, 305, 293, 318, 321, 299,
294, 317, 296
119, 351, 305, 341, 349, 326, 321, 345,
350, 325, 346
120, 293, 305, 349, 341, 296, 325, 320,
317, 321, 346
121, 25, 249, 71, 140, 243, 267, 46,
139, 361, 160
122, 295, 71, 249, 410, 289, 267, 272,
409, 403, 386
123, 364, 140, 410, 249, 359, 383, 387,
363, 361, 386
124, 186, 410, 140, 71, 405, 383, 161,
185, 403, 160
125, 140, 249, 71, 410, 361, 267, 160,
383, 386, 403
126, 364, 410, 140, 366, 387, 383, 359,
365, 388, 357
127, 186, 140, 410, 188, 161, 383, 405,
187, 162, 407
128, 142, 188, 366, 140, 163, 384, 360,
141, 162, 357
129, 412, 366, 188, 410, 389, 384, 406,
411, 388, 407
130, 140, 366, 410, 188, 357, 388, 383,
162, 384, 407
131, 259, 305, 249, 374, 280, 275, 253,
373, 394, 367
132, 295, 249, 305, 410, 272, 275, 299,
409, 386, 417
133, 364, 410, 374, 249, 387, 391, 369,
363, 386, 367
134, 420, 374, 410, 305, 395, 391, 415,
419, 394, 417
135, 249, 374, 305, 410, 367, 394, 275,
386, 391, 417
136, 364, 374, 410, 366, 369, 391, 387,
365, 371, 388
137, 420, 410, 374, 422, 415, 391, 395,
421, 413, 396
138, 376, 366, 422, 374, 370, 392, 397,
375, 371, 396
139, 412, 422, 366, 410, 416, 392, 389,
411, 413, 388
140, 366, 374, 410, 422, 371, 391, 388,
392, 396, 413
141, 295, 341, 71, 410, 318, 313, 289,
409, 432, 403
142, 117, 71, 341, 232, 92, 313, 335,
231, 206, 453
143, 186, 232, 410, 71, 207, 429, 405,
185, 206, 403
144, 456, 410, 232, 341, 433, 429, 451,
455, 432, 453
145, 71, 410, 341, 232, 403, 432, 313,
206, 429, 453
146, 186, 410, 232, 188, 405, 429, 207,
187, 407, 208
147, 456, 232, 410, 458, 451, 429, 433,
457, 449, 434
148, 412, 188, 458, 410, 406, 430, 435,
411, 407, 434
149, 234, 458, 188, 232, 452, 430, 209,
233, 449, 208
150, 188, 410, 232, 458, 407, 429, 208,
430, 434, 449
151, 295, 305, 341, 410, 299, 321, 318,
409, 417, 432
152, 351, 341, 305, 466, 345, 321, 326,
465, 459, 440
153, 420, 410, 466, 305, 415, 437, 441,
419, 417, 440
154, 456, 466, 410, 341, 461, 437, 433,
455, 459, 432
155, 410, 305, 341, 466, 417, 321, 432,
437, 440, 459
156, 420, 466, 410, 422, 441, 437, 415,
421, 442, 413
157, 456, 410, 466, 458, 433, 437, 461,
457, 434, 463
158, 412, 458, 422, 410, 435, 438, 416,
411, 434, 413
159, 468, 422, 458, 466, 443, 438, 462,
467, 442, 463
160, 410, 422, 466, 458, 413, 442, 437,
434, 438, 463
161, 259, 479, 305, 374, 475, 499, 280,
373, 478, 394
162, 525, 305, 479, 527, 521, 499, 502,
526, 520, 503
163, 481, 374, 527, 479, 476, 500, 504,
480, 478, 503
164, 420, 527, 374, 305, 522, 500, 395,
419, 520, 394
165, 374, 479, 305, 527, 478, 499, 394,
500, 503, 520
166, 481, 527, 374, 483, 504, 500, 476,
482, 505, 474
167, 420, 374, 527, 422, 395, 500, 522,
421, 396, 524
168, 376, 422, 483, 374, 397, 501, 477,
375, 396, 474
169, 529, 483, 422, 527, 506, 501, 523,
528, 505, 524
170, 374, 483, 527, 422, 474, 505, 500,
396, 501, 524
171, 489, 535, 479, 491, 510, 507, 485,
490, 511, 484
172, 525, 479, 535, 527, 502, 507, 531,
526, 503, 534
173, 481, 527, 491, 479, 504, 508, 486,
480, 503, 484
174, 537, 491, 527, 535, 512, 508, 532,
536, 511, 534
175, 479, 491, 535, 527, 484, 511, 507,
503, 508, 534
176, 481, 491, 527, 483, 486, 508, 504,
482, 488, 505
177, 537, 527, 491, 539, 532, 508, 512,
538, 530, 513
178, 493, 483, 539, 491, 487, 509, 514,
492, 488, 513
179, 529, 539, 483, 527, 533, 509, 506,
528, 530, 505
180, 483, 491, 527, 539, 488, 508, 505,
509, 513, 530
181, 525, 571, 305, 527, 548, 545, 521,
526, 549, 520
182, 351, 305, 571, 466, 326, 545, 567,
465, 440, 570
183, 420, 466, 527, 305, 441, 546, 522,
419, 440, 520
184, 573, 527, 466, 571, 550, 546, 568,
572, 549, 570
185, 305, 527, 571, 466, 520, 549, 545,
440, 546, 570
186, 420, 527, 466, 422, 522, 546, 441,
421, 524, 442
187, 573, 466, 527, 575, 568, 546, 550,
574, 566, 551
188, 529, 422, 575, 527, 523, 547, 552,
528, 524, 551
189, 468, 575, 422, 466, 569, 547, 443,
467, 566, 442
190, 422, 527, 466, 575, 524, 546, 442,
547, 551, 566
191, 525, 535, 571, 527, 531, 553, 548,
526, 534, 549
192, 581, 571, 535, 583, 577, 553, 556,
582, 576, 557
193, 537, 527, 583, 535, 532, 554, 558,
536, 534, 557
194, 573, 583, 527, 571, 578, 554, 550,
572, 576, 549
195, 527, 535, 571, 583, 534, 553, 549,
554, 557, 576
196, 537, 583, 527, 539, 558, 554, 532,
538, 559, 530
197, 573, 527, 583, 575, 550, 554, 578,
574, 551, 580
198, 529, 575, 539, 527, 552, 555, 533,
528, 551, 530
199, 585, 539, 575, 583, 560, 555, 579,
584, 559, 580
200, 527, 539, 583, 575, 530, 559, 554,
551, 555, 580
201, 255, 596, 301, 257, 592, 616, 276,
256, 595, 277
202, 642, 301, 596, 644, 638, 616, 619,
643, 637, 620
203, 598, 257, 644, 596, 593, 617, 621,
597, 595, 620
204, 303, 644, 257, 301, 639, 617, 278,
302, 637, 277
205, 257, 596, 301, 644, 595, 616, 277,
617, 620, 637
206, 598, 644, 257, 479, 621, 617, 593,
599, 622, 591
207, 303, 257, 644, 305, 278, 617, 639,
304, 279, 641
208, 259, 305, 479, 257, 280, 499, 475,
258, 279, 591
209, 525, 479, 305, 644, 502, 499, 521,
645, 622, 641
210, 257, 479, 644, 305, 591, 622, 617,
279, 499, 641
211, 606, 652, 596, 608, 627, 626, 603,
607, 628, 601
212, 642, 596, 652, 644, 619, 626, 648,
643, 620, 651
213, 598, 644, 608, 596, 621, 625, 604,
597, 620, 601
214, 654, 608, 644, 652, 629, 625, 650,
653, 628, 651
215, 596, 608, 652, 644, 601, 628, 626,
620, 625, 651
216, 598, 608, 644, 479, 604, 625, 621,
599, 605, 622
217, 654, 644, 608, 535, 650, 625, 629,
655, 647, 630
218, 489, 479, 535, 608, 485, 507, 510,
609, 605, 630
219, 525, 535, 479, 644, 531, 507, 502,
645, 647, 622
220, 479, 608, 644, 535, 605, 625, 622,
507, 630, 647
221, 642, 688, 301, 644, 665, 662, 638,
643, 666, 637
222, 347, 301, 688, 349, 322, 662, 684,
348, 323, 687
223, 303, 349, 644, 301, 324, 663, 639,
302, 323, 637
224, 690, 644, 349, 688, 667, 663, 685,
689, 666, 687
225, 301, 644, 688, 349, 637, 666, 662,
323, 663, 687
226, 303, 644, 349, 305, 639, 663, 324,
304, 641, 325
227, 690, 349, 644, 571, 685, 663, 667,
691, 683, 668
228, 525, 305, 571, 644, 521, 545, 548,
645, 641, 668
229, 351, 571, 305, 349, 567, 545, 326,
350, 683, 325
230, 305, 644, 349, 571, 641, 663, 325,
545, 668, 683
231, 642, 652, 688, 644, 648, 672, 665,
643, 651, 666
232, 698, 688, 652, 700, 695, 672, 673,
699, 693, 674
233, 654, 644, 700, 652, 650, 671, 675,
653, 651, 674
234, 690, 700, 644, 688, 696, 671, 667,
689, 693, 666
235, 644, 652, 688, 700, 651, 672, 666,
671, 674, 693
236, 654, 700, 644, 535, 675, 671, 650,
655, 676, 647
237, 690, 644, 700, 571, 667, 671, 696,
691, 668, 697
238, 525, 571, 535, 644, 548, 553, 531,
645, 668, 647
239, 581, 535, 571, 700, 556, 553, 577,
701, 676, 697
240, 644, 535, 700, 571, 647, 676, 671,
668, 553, 697
**
** eall
**
*SOLID SECTION, ELSET=EALL, MATERIAL=STEEL
1.,
**
** steel
** Date: 23-May-96 Time: 17:30:54
**
*MATERIAL, NAME=STEEL
**
*ELASTIC, TYPE=ISO
2.1E+11, 0.3
*NSET,NSET=ZFIX
47,53,57,63,67,287,291,297,301,638,642,648,652
*ELSET,ELSET=EOUT
199,
**
** step 1,Default
**
*STEP, PERT
This load case is the default load case that always appears
*STATIC
**
** yfix
**
*BOUNDARY, OP=NEW
489, 2,, 0.
490, 2,, 0.
491, 2,, 0.
492, 2,, 0.
493, 2,, 0.
510, 2,, 0.
511, 2,, 0.
512, 2,, 0.
513, 2,, 0.
514, 2,, 0.
535, 2,, 0.
536, 2,, 0.
537, 2,, 0.
538, 2,, 0.
539, 2,, 0.
556, 2,, 0.
557, 2,, 0.
558, 2,, 0.
559, 2,, 0.
560, 2,, 0.
581, 2,, 0.
582, 2,, 0.
583, 2,, 0.
584, 2,, 0.
585, 2,, 0.
607, 2,, 0.
608, 2,, 0.
609, 2,, 0.
628, 2,, 0.
629, 2,, 0.
630, 2,, 0.
653, 2,, 0.
654, 2,, 0.
655, 2,, 0.
674, 2,, 0.
675, 2,, 0.
676, 2,, 0.
699, 2,, 0.
700, 2,, 0.
701, 2,, 0.
ZFIX,3,,0.
**
** xfix
**
*BOUNDARY, OP=NEW
2, 1,, 0.
3, 1,, 0.
4, 1,, 0.
5, 1,, 0.
27, 1,, 0.
28, 1,, 0.
29, 1,, 0.
30, 1,, 0.
48, 1,, 0.
49, 1,, 0.
50, 1,, 0.
51, 1,, 0.
73, 1,, 0.
74, 1,, 0.
75, 1,, 0.
76, 1,, 0.
94, 1,, 0.
95, 1,, 0.
96, 1,, 0.
97, 1,, 0.
119, 1,, 0.
120, 1,, 0.
121, 1,, 0.
122, 1,, 0.
144, 1,, 0.
145, 1,, 0.
146, 1,, 0.
147, 1,, 0.
165, 1,, 0.
166, 1,, 0.
167, 1,, 0.
168, 1,, 0.
190, 1,, 0.
191, 1,, 0.
192, 1,, 0.
193, 1,, 0.
211, 1,, 0.
212, 1,, 0.
213, 1,, 0.
214, 1,, 0.
**
** curvefix
**
*BOUNDARY, OP=NEW
1, 1,, 0.
1, 2,, 0.
7, 1,, 0.
7, 2,, 0.
11, 1,, 0.
11, 2,, 0.
17, 1,, 0.
17, 2,, 0.
21, 1,, 0.
21, 2,, 0.
26, 1,, 0.
26, 2,, 0.
31, 1,, 0.
31, 2,, 0.
34, 1,, 0.
34, 2,, 0.
39, 1,, 0.
39, 2,, 0.
42, 1,, 0.
42, 2,, 0.
47, 1,, 0.
47, 2,, 0.
53, 1,, 0.
53, 2,, 0.
57, 1,, 0.
57, 2,, 0.
63, 1,, 0.
63, 2,, 0.
67, 1,, 0.
67, 2,, 0.
72, 1,, 0.
72, 2,, 0.
77, 1,, 0.
77, 2,, 0.
80, 1,, 0.
80, 2,, 0.
85, 1,, 0.
85, 2,, 0.
88, 1,, 0.
88, 2,, 0.
93, 1,, 0.
93, 2,, 0.
99, 1,, 0.
99, 2,, 0.
103, 1,, 0.
103, 2,, 0.
109, 1,, 0.
109, 2,, 0.
113, 1,, 0.
113, 2,, 0.
241, 1,, 0.
241, 2,, 0.
245, 1,, 0.
245, 2,, 0.
251, 1,, 0.
251, 2,, 0.
255, 1,, 0.
255, 2,, 0.
265, 1,, 0.
265, 2,, 0.
268, 1,, 0.
268, 2,, 0.
273, 1,, 0.
273, 2,, 0.
276, 1,, 0.
276, 2,, 0.
287, 1,, 0.
287, 2,, 0.
291, 1,, 0.
291, 2,, 0.
297, 1,, 0.
297, 2,, 0.
301, 1,, 0.
301, 2,, 0.
311, 1,, 0.
311, 2,, 0.
314, 1,, 0.
314, 2,, 0.
319, 1,, 0.
319, 2,, 0.
322, 1,, 0.
322, 2,, 0.
333, 1,, 0.
333, 2,, 0.
337, 1,, 0.
337, 2,, 0.
343, 1,, 0.
343, 2,, 0.
347, 1,, 0.
347, 2,, 0.
592, 1,, 0.
592, 2,, 0.
596, 1,, 0.
596, 2,, 0.
603, 1,, 0.
603, 2,, 0.
606, 1,, 0.
606, 2,, 0.
616, 1,, 0.
616, 2,, 0.
619, 1,, 0.
619, 2,, 0.
626, 1,, 0.
626, 2,, 0.
627, 1,, 0.
627, 2,, 0.
638, 1,, 0.
638, 2,, 0.
642, 1,, 0.
642, 2,, 0.
648, 1,, 0.
648, 2,, 0.
652, 1,, 0.
652, 2,, 0.
662, 1,, 0.
662, 2,, 0.
665, 1,, 0.
665, 2,, 0.
672, 1,, 0.
672, 2,, 0.
673, 1,, 0.
673, 2,, 0.
684, 1,, 0.
684, 2,, 0.
688, 1,, 0.
688, 2,, 0.
695, 1,, 0.
695, 2,, 0.
698, 1,, 0.
698, 2,, 0.
**
** load
**
*DLOAD, OP=NEW
22, P4, 1.E+6
24, P4, 1.E+6
27, P2, 1.E+6
29, P2, 1.E+6
32, P2, 1.E+6
34, P2, 1.E+6
37, P4, 1.E+6
39, P4, 1.E+6
62, P4, 1.E+6
64, P4, 1.E+6
67, P2, 1.E+6
69, P2, 1.E+6
72, P2, 1.E+6
74, P2, 1.E+6
77, P4, 1.E+6
79, P4, 1.E+6
102, P4, 1.E+6
104, P4, 1.E+6
107, P2, 1.E+6
109, P2, 1.E+6
112, P2, 1.E+6
114, P2, 1.E+6
117, P4, 1.E+6
119, P4, 1.E+6
142, P4, 1.E+6
144, P4, 1.E+6
147, P2, 1.E+6
149, P2, 1.E+6
152, P2, 1.E+6
154, P2, 1.E+6
157, P4, 1.E+6
159, P4, 1.E+6
182, P4, 1.E+6
184, P4, 1.E+6
187, P2, 1.E+6
189, P2, 1.E+6
192, P2, 1.E+6
194, P2, 1.E+6
197, P4, 1.E+6
199, P4, 1.E+6
222, P4, 1.E+6
224, P4, 1.E+6
227, P2, 1.E+6
229, P2, 1.E+6
232, P2, 1.E+6
234, P2, 1.E+6
237, P4, 1.E+6
239, P4, 1.E+6
**
*NODE PRINT, FREQ=0
U,
*EL PRINT,FREQ=1,ELSET=EOUT,POSITION=AVERAGED AT NODES
S,
**
*EL FILE, POSITION=AVERAGED AT NODES, FREQ=1,ELSET=EOUT
S,
**
*END STEP
"""
write("NLE10.inp", INP_file)
output = MeshImportModule.import_ABAQUS("NLE10.inp")
fens, fes = output["fens"], output["fesets"][1]
# Select the boundary faces, on the boundary that is clamped, and on the part
# of the boundary that is loaded with the transverse pressure
bdryfes = meshboundary(fes)
exteriorbfl = selectelem(fens, bdryfes, facing = true, direction = [1.0, 1.0, 0.0])
topbfl = selectelem(
fens,
bdryfes,
box = [0.0, Inf, 0.0, Inf, Thickness, Thickness],
inflate = tolerance,
)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
L12 = connectednodes(subset(bdryfes, exteriorbfl)) # external boundary
setebc!(u, L12, true, 1, 0.0)
setebc!(u, L12, true, 2, 0.0)
LL = selectnode(
fens;
box = [0.0, Inf, 0.0, Inf, Thickness / 2.0, Thickness / 2.0],
inflate = tolerance,
)
L3 = intersect(LL, connectednodes(subset(bdryfes, exteriorbfl)))
setebc!(u, L3, true, 3, 0.0)
L1 = selectnode(fens; box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness], inflate = tolerance)
setebc!(u, L1, true, 1, 0.0) # symmetry plane X = 0
L2 = selectnode(fens; box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness], inflate = tolerance)
setebc!(u, L2, true, 2, 0.0) # symmetry plane Y = 0
applyebc!(u)
numberdofs!(u)
eL1femm = FEMMBase(IntegDomain(subset(bdryfes, topbfl), TriRule(3)))
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
) where {T}
forceout .= [0.0, 0.0, -qmagn]
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(eL1femm, geom, u, fi, 2)
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the fully three-dimensional solid.
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMST10(MR, IntegDomain(fes, TetRule(4)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (F2)
scattersysvec!(u, U[:])
nl = selectnode(fens, box = [Ai, Ai, 0, 0, Thickness, Thickness], inflate = tolerance)
thecorneru = zeros(FFlt, 1, 3)
gathervalues_asmat!(u, thecorneru, nl)
thecorneru = thecorneru / phun("mm")
println(
"displacement =$(thecorneru) [MM] as compared to reference [-0.030939, 0, -0.10488] [MM]",
)
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = :extrapmean,
)#
println(
"Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yP = $(sigma_yP/phun("MPa")) [MPa]",
)
println("Mean-stress: $(fld.values[nl,1][1]/phun("MPa"))")
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = :extraptrend,
)#
println(
"Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yP = $(sigma_yP/phun("MPa")) [MPa]",
)
println("Trend estimation: $(fld.values[nl,1][1]/phun("MPa"))")
File = "LE10NAFEMS_MST10_sigmay.vtk"
vtkexportmesh(
File,
fes.conn,
geom.values,
FinEtools.MeshExportModule.VTK.T10;
vectors = [("u", u.values)],
scalars = [("sigmay", fld.values)],
)
@async run(`"paraview.exe" $File`)
true
AE = AbaqusExporter("LE10NAFEMS_MST10")
HEADING(
AE,
"LE10NAFEMS: Transverse deflection of elliptical plate with elliptical hole.",
)
PART(AE, "part1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
ELEMENT(AE, "c3d10", "AllElements", 1, femm.integdata.fes.conn)
ELEMENT(
AE,
"SFM3D6",
"TractionElements",
1 + count(femm.integdata.fes),
eL1femm.integdata.fes.conn,
)
NSET_NSET(AE, "L1", L1)
NSET_NSET(AE, "L2", L2)
NSET_NSET(AE, "L3", L3)
NSET_NSET(AE, "L12", L12)
ORIENTATION(AE, "GlobalOrientation", vec([1.0 0 0]), vec([0 1.0 0]))
SOLID_SECTION(AE, "elasticity", "GlobalOrientation", "AllElements", "Hourglassctl")
SURFACE_SECTION(AE, "TractionElements")
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "elasticity")
ELASTIC(AE, E, nu)
SECTION_CONTROLS(AE, "Hourglassctl", "HOURGLASS=ENHANCED")
STEP_PERTURBATION_STATIC(AE)
BOUNDARY(AE, "ASSEM1.INSTNC1.L1", 1)
BOUNDARY(AE, "ASSEM1.INSTNC1.L2", 2)
BOUNDARY(AE, "ASSEM1.INSTNC1.L3", 3)
BOUNDARY(AE, "ASSEM1.INSTNC1.L12", 1)
BOUNDARY(AE, "ASSEM1.INSTNC1.L12", 2)
DLOAD(AE, "ASSEM1.INSTNC1.TractionElements", vec([0.0, 0.0, -qmagn]))
END_STEP(AE)
close(AE)
output = MeshImportModule.import_ABAQUS(AE.filename)
fens, fes = output["fens"], output["fesets"][1]
# Select the boundary faces, on the boundary that is clamped, and on the part
# of the boundary that is loaded with the transverse pressure
bdryfes = meshboundary(fes)
exteriorbfl = selectelem(fens, bdryfes, facing = true, direction = [1.0, 1.0, 0.0])
topbfl = selectelem(
fens,
bdryfes,
box = [0.0, Inf, 0.0, Inf, Thickness, Thickness],
inflate = tolerance,
)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
L12 = connectednodes(subset(bdryfes, exteriorbfl)) # external boundary
setebc!(u, L12, true, 1, 0.0)
setebc!(u, L12, true, 2, 0.0)
LL = selectnode(
fens;
box = [0.0, Inf, 0.0, Inf, Thickness / 2.0, Thickness / 2.0],
inflate = tolerance,
)
L3 = intersect(LL, connectednodes(subset(bdryfes, exteriorbfl)))
setebc!(u, L3, true, 3, 0.0)
L1 = selectnode(fens; box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness], inflate = tolerance)
setebc!(u, L1, true, 1, 0.0) # symmetry plane X = 0
L2 = selectnode(fens; box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness], inflate = tolerance)
setebc!(u, L2, true, 2, 0.0) # symmetry plane Y = 0
applyebc!(u)
numberdofs!(u)
eL1femm = FEMMBase(IntegDomain(subset(bdryfes, topbfl), TriRule(3)))
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(eL1femm, geom, u, fi, 2)
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the fully three-dimensional solid.
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMST10(MR, IntegDomain(fes, TetRule(4)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (F2)
scattersysvec!(u, U[:])
nl = selectnode(fens, box = [Ai, Ai, 0, 0, Thickness, Thickness], inflate = tolerance)
thecorneru = zeros(FFlt, 1, 3)
gathervalues_asmat!(u, thecorneru, nl)
thecorneru = thecorneru / phun("mm")
println(
"displacement =$(thecorneru) [MM] as compared to reference [-0.030939, 0, -0.10488] [MM]",
)
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = :extrapmean,
)#
println(
"Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yP = $(sigma_yP/phun("MPa")) [MPa]",
)
println("Mean-stress: $(fld.values[nl,1][1]/phun("MPa"))")
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = :extraptrend,
)#
println(
"Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yP = $(sigma_yP/phun("MPa")) [MPa]",
)
println("Trend estimation: $(fld.values[nl,1][1]/phun("MPa"))")
File = "LE10NAFEMS_MST10_sigmay.vtk"
vtkexportmesh(
File,
fes.conn,
geom.values,
FinEtools.MeshExportModule.T10;
vectors = [("u", u.values)],
scalars = [("sigmay", fld.values)],
)
@async run(`"paraview.exe" $File`)
true
end # LE10NAFEMS_Abaqus_fine_MST10
function LE10NAFEMS_Abaqus_MST10()
# Thick elliptical plate with an elliptical hole is clamped on its exterior
# boundary and is loaded with transverse pressure.
# This is a NAFEMS Benchmark, Test No. LE10.
# The plate is discretized with solid elements.
# Because of the symmetries of the geometry and load, only quarter of the plate is modeled.
# The $\sigma_y=\sigma_2$ at the point $P$ is to be determined. Since the
# target point is on the boundary of the domain it will not be an
# integration node as we use Gauss quadrature. The reference value is -5.38 MPa.
println("LE10NAFEMS: Transverse deflection of elliptical plate with elliptical hole.")
t0 = time()
E = 210e3 * phun("MEGA*PA")# 210e3 MPa
nu = 0.3
qmagn = 1.0 * phun("MEGA*PA")# transverse pressure
sigma_yP = -5.38 * phun("MEGA*PA")# tensile stress at [2.0, 0.0] meters
Ae = 3.25 * phun("m") # Major radius of the exterior ellipse
Be = 2.75 * phun("m") # Minor radius of the exterior ellipse
Ai = 2.0 * phun("m") # Major radius of the interior ellipse
Bi = 1.0 * phun("m") # Minor radius of the interior ellipse
Thickness = 0.6 * phun("m")
tolerance = Thickness / 1000.0 # Geometrical tolerance
INP_file = """
*HEADING
NAFEMS TEST NLE10, COARSE MESH, C3D10M ELEMENTS
*NODE
1, 2.83277, 1.348
2, 2.48116, 1.04837
3, 2.12955, 0.748738
4, 3.14146, 0.704779
5, 2.33893, 0.399071
6, 2.68977, 0.374369
7, 3.25, 0.
8, 2.8335, 0.
9, 2.417, 0.
10, 2.83277, 1.348, 0.15
11, 2.48116, 1.04837, 0.15
12, 2.12955, 0.748738, 0.15
13, 2.33841, 0.400381, 0.15
14, 3.14128, 0.70533, 0.15
15, 3.25, 0., 0.15
16, 2.8335, 0., 0.15
17, 2.417, 0., 0.15
18, 2.83277, 1.348, 0.3
19, 2.48116, 1.04837, 0.3
20, 2.12955, 0.748738, 0.3
21, 2.62488, 0.674, 0.3
22, 2.33893, 0.399071, 0.3
23, 3.14146, 0.704779, 0.3
24, 3.25, 0., 0.3
25, 2.8335, 0., 0.3
26, 2.417, 0., 0.3
27, 2.83277, 1.348, 0.45
28, 2.48116, 1.04837, 0.45
29, 2.12955, 0.748738, 0.45
30, 2.33841, 0.400381, 0.45
31, 3.14128, 0.70533, 0.45
32, 3.25, 0., 0.45
33, 2.8335, 0., 0.45
34, 2.417, 0., 0.45
35, 2.83277, 1.348, 0.6
36, 2.48116, 1.04837, 0.6
37, 2.12955, 0.748738, 0.6
38, 3.14146, 0.704779, 0.6
39, 2.33893, 0.399071, 0.6
40, 2.68977, 0.374369, 0.6
41, 3.25, 0., 0.6
42, 2.8335, 0., 0.6
43, 2.417, 0., 0.6
45, 1.95628, 0.600869
46, 1.78302, 0.453
47, 2.06477, 0.374369
48, 1.93715, 0.248725
51, 2.2085, 0.
52, 2., 0.
54, 1.95628, 0.600869, 0.15
55, 1.78302, 0.453, 0.15
56, 1.93661, 0.249767, 0.15
59, 2.2085, 0., 0.15
60, 2., 0., 0.15
62, 1.95628, 0.600869, 0.3
63, 1.78302, 0.453, 0.3
64, 1.93715, 0.248725, 0.3
66, 2.10001, 0.2265, 0.3
68, 2.2085, 0., 0.3
69, 2., 0., 0.3
71, 1.95628, 0.600869, 0.45
72, 1.78302, 0.453, 0.45
74, 1.93661, 0.249767, 0.45
76, 2.2085, 0., 0.45
77, 2., 0., 0.45
79, 1.95628, 0.600869, 0.6
80, 1.78302, 0.453, 0.6
81, 2.06477, 0.374369, 0.6
83, 1.93715, 0.248725, 0.6
85, 2.2085, 0., 0.6
86, 2., 0., 0.6
87, 1.783, 2.29921
88, 1.57618, 1.80182
89, 1.36937, 1.30443
90, 1.95627, 1.52397
91, 2.36495, 1.88628
92, 1.78146, 1.06985
96, 1.783, 2.29921, 0.15
97, 1.57618, 1.80182, 0.15
98, 1.36937, 1.30443, 0.15
99, 1.78071, 1.07038, 0.15
100, 2.36449, 1.88669, 0.15
104, 1.783, 2.29921, 0.3
105, 1.57618, 1.80182, 0.3
106, 1.36937, 1.30443, 0.3
107, 2.36495, 1.88628, 0.3
108, 1.78146, 1.06985, 0.3
109, 2.10107, 1.32621, 0.3
113, 1.783, 2.29921, 0.45
114, 1.57618, 1.80182, 0.45
115, 1.36937, 1.30443, 0.45
116, 2.36449, 1.88669, 0.45
117, 1.78071, 1.07038, 0.45
121, 1.783, 2.29921, 0.6
122, 1.57618, 1.80182, 0.6
123, 1.36937, 1.30443, 0.6
124, 1.95627, 1.52397, 0.6
125, 2.36495, 1.88628, 0.6
126, 1.78146, 1.06985, 0.6
131, 1.26718, 1.05863
132, 1.165, 0.812831
134, 1.49321, 0.665266
135, 1.64727, 0.780784
140, 1.26718, 1.05863, 0.15
141, 1.165, 0.812831, 0.15
143, 1.4924, 0.665723, 0.15
148, 1.26718, 1.05863, 0.3
149, 1.165, 0.812831, 0.3
150, 1.57619, 0.878714, 0.3
152, 1.49321, 0.665266, 0.3
157, 1.26718, 1.05863, 0.45
158, 1.165, 0.812831, 0.45
160, 1.4924, 0.665723, 0.45
165, 1.26718, 1.05863, 0.6
166, 1.165, 0.812831, 0.6
168, 1.49321, 0.665266, 0.6
169, 1.64727, 0.780784, 0.6
173, 0., 1.583
174, 0., 1.2915
175, 0., 1.
176, 0.5825, 1.19792
177, 0.699442, 1.51527
178, 0.590531, 0.955415
182, 0., 1.583, 0.15
183, 0., 1.2915, 0.15
184, 0., 1., 0.15
185, 0.698861, 1.51538, 0.15
186, 0.590076, 0.955486, 0.15
190, 0., 1.583, 0.3
191, 0., 1.2915, 0.3
192, 0., 1., 0.3
193, 0.699442, 1.51527, 0.3
194, 0.590531, 0.955415, 0.3
195, 0.684684, 1.15221, 0.3
199, 0., 1.583, 0.45
200, 0., 1.2915, 0.45
201, 0., 1., 0.45
202, 0.698861, 1.51538, 0.45
203, 0.590076, 0.955486, 0.45
207, 0., 1.583, 0.6
208, 0., 1.2915, 0.6
209, 0., 1., 0.6
210, 0.5825, 1.19792, 0.6
211, 0.699442, 1.51527, 0.6
212, 0.590531, 0.955415, 0.6
216, 0., 2.75
217, 0., 2.1665
219, 0.920251, 2.63745
221, 0.8915, 1.9411
225, 0., 2.75, 0.15
226, 0., 2.1665, 0.15
228, 0.919707, 2.63759, 0.15
233, 0., 2.75, 0.3
234, 0., 2.1665, 0.3
236, 0.684684, 2.02721, 0.3
237, 0.920251, 2.63745, 0.3
242, 0., 2.75, 0.45
243, 0., 2.1665, 0.45
245, 0.919707, 2.63759, 0.45
250, 0., 2.75, 0.6
251, 0., 2.1665, 0.6
253, 0.920251, 2.63745, 0.6
255, 0.8915, 1.9411, 0.6
**
**
*ELEMENT, TYPE=C3D10M, ELSET=EALL
1, 1, 7, 18, 3, 4, 14, 10,
2, 6, 11
2, 24, 18, 7, 26, 23, 14, 15,
25, 21, 16
3, 9, 3, 26, 7, 5, 13, 17,
8, 6, 16
4, 20, 26, 3, 18, 22, 13, 12,
19, 21, 11
5, 3, 7, 18, 26, 6, 14, 11,
13, 16, 21
6, 24, 41, 18, 26, 32, 31, 23,
25, 33, 21
7, 35, 18, 41, 37, 27, 31, 38,
36, 28, 40
8, 20, 37, 26, 18, 29, 30, 22,
19, 28, 21
9, 43, 26, 37, 41, 34, 30, 39,
42, 33, 40
10, 18, 26, 41, 37, 21, 33, 31,
28, 30, 40
11, 9, 26, 3, 52, 17, 13, 5,
51, 59, 47
12, 20, 3, 26, 63, 12, 13, 22,
62, 54, 66
13, 46, 63, 52, 3, 55, 56, 48,
45, 54, 47
14, 69, 52, 63, 26, 60, 56, 64,
68, 59, 66
15, 3, 52, 26, 63, 47, 59, 13,
54, 56, 66
16, 20, 26, 37, 63, 22, 30, 29,
62, 66, 71
17, 43, 37, 26, 86, 39, 30, 34,
85, 81, 76
18, 69, 63, 86, 26, 64, 74, 77,
68, 66, 76
19, 80, 86, 63, 37, 83, 74, 72,
79, 81, 71
20, 63, 26, 37, 86, 66, 30, 71,
74, 76, 81
21, 1, 18, 87, 3, 10, 100, 91,
2, 11, 90
22, 104, 87, 18, 106, 96, 100, 107,
105, 97, 109
23, 89, 106, 3, 87, 98, 99, 92,
88, 97, 90
24, 20, 3, 106, 18, 12, 99, 108,
19, 11, 109
25, 87, 3, 18, 106, 90, 11, 100,
97, 99, 109
26, 104, 18, 121, 106, 107, 116, 113,
105, 109, 114
27, 35, 121, 18, 37, 125, 116, 27,
36, 124, 28
28, 20, 106, 37, 18, 108, 117, 29,
19, 109, 28
29, 123, 37, 106, 121, 126, 117, 115,
122, 124, 114
30, 106, 18, 121, 37, 109, 116, 114,
117, 28, 124
31, 89, 3, 106, 132, 92, 99, 98,
131, 135, 140
32, 20, 106, 3, 63, 108, 99, 12,
62, 150, 54
33, 46, 132, 63, 3, 134, 143, 55,
45, 135, 54
34, 149, 63, 132, 106, 152, 143, 141,
148, 150, 140
35, 132, 3, 106, 63, 135, 99, 140,
143, 54, 150
36, 20, 37, 106, 63, 29, 117, 108,
62, 71, 150
37, 123, 106, 37, 166, 115, 117, 126,
165, 157, 169
38, 149, 166, 63, 106, 158, 160, 152,
148, 157, 150
39, 80, 63, 166, 37, 72, 160, 168,
79, 71, 169
40, 106, 63, 37, 166, 150, 71, 117,
157, 160, 169
41, 89, 106, 173, 132, 98, 185, 177,
131, 140, 176
42, 190, 173, 106, 192, 182, 185, 193,
191, 183, 195
43, 175, 192, 132, 173, 184, 186, 178,
174, 183, 176
44, 149, 132, 192, 106, 141, 186, 194,
148, 140, 195
45, 173, 132, 106, 192, 176, 140, 185,
183, 186, 195
46, 190, 106, 207, 192, 193, 202, 199,
191, 195, 200
47, 123, 207, 106, 166, 211, 202, 115,
165, 210, 157
48, 149, 192, 166, 106, 194, 203, 158,
148, 195, 157
49, 209, 166, 192, 207, 212, 203, 201,
208, 210, 200
50, 192, 106, 207, 166, 195, 202, 200,
203, 157, 210
51, 216, 87, 233, 173, 219, 228, 225,
217, 221, 226
52, 104, 233, 87, 106, 237, 228, 96,
105, 236, 97
53, 89, 173, 106, 87, 177, 185, 98,
88, 221, 97
54, 190, 106, 173, 233, 193, 185, 182,
234, 236, 226
55, 173, 87, 233, 106, 221, 228, 226,
185, 97, 236
56, 104, 121, 233, 106, 113, 245, 237,
105, 114, 236
57, 250, 233, 121, 207, 242, 245, 253,
251, 243, 255
58, 190, 207, 106, 233, 199, 202, 193,
234, 243, 236
59, 123, 106, 207, 121, 115, 202, 211,
122, 114, 255
60, 233, 106, 121, 207, 236, 114, 245,
243, 202, 255
"""
write("NLE10.inp", INP_file)
output = MeshImportModule.import_ABAQUS("NLE10.inp")
fens, fes = output["fens"], output["fesets"][1]
# Select the boundary faces, on the boundary that is clamped, and on the part
# of the boundary that is loaded with the transverse pressure
bdryfes = meshboundary(fes)
exteriorbfl = selectelem(fens, bdryfes, facing = true, direction = [1.0, 1.0, 0.0])
topbfl = selectelem(
fens,
bdryfes,
box = [0.0, Inf, 0.0, Inf, Thickness, Thickness],
inflate = tolerance,
)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
L12 = connectednodes(subset(bdryfes, exteriorbfl)) # external boundary
setebc!(u, L12, true, 1, 0.0)
setebc!(u, L12, true, 2, 0.0)
LL = selectnode(
fens;
box = [0.0, Inf, 0.0, Inf, Thickness / 2.0, Thickness / 2.0],
inflate = tolerance,
)
L3 = intersect(LL, connectednodes(subset(bdryfes, exteriorbfl)))
setebc!(u, L3, true, 3, 0.0)
L1 = selectnode(fens; box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness], inflate = tolerance)
setebc!(u, L1, true, 1, 0.0) # symmetry plane X = 0
L2 = selectnode(fens; box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness], inflate = tolerance)
setebc!(u, L2, true, 2, 0.0) # symmetry plane Y = 0
applyebc!(u)
numberdofs!(u)
eL1femm = FEMMBase(IntegDomain(subset(bdryfes, topbfl), TriRule(3)))
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
) where {T}
forceout .= [0.0, 0.0, -qmagn]
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(eL1femm, geom, u, fi, 2)
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the fully three-dimensional solid.
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMST10(MR, IntegDomain(fes, TetRule(4)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (F2)
scattersysvec!(u, U[:])
nl = selectnode(fens, box = [Ai, Ai, 0, 0, Thickness, Thickness], inflate = tolerance)
thecorneru = zeros(FFlt, 1, 3)
gathervalues_asmat!(u, thecorneru, nl)
thecorneru = thecorneru / phun("mm")
println(
"displacement =$(thecorneru) [MM] as compared to reference [-0.030939, 0, -0.10488] [MM]",
)
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = :extrapmean,
)#
println(
"Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yP = $(sigma_yP/phun("MPa")) [MPa]",
)
println("Mean-stress: $(fld.values[nl,1][1]/phun("MPa"))")
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = :extraptrend,
)#
println(
"Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yP = $(sigma_yP/phun("MPa")) [MPa]",
)
println("Trend estimation: $(fld.values[nl,1][1]/phun("MPa"))")
File = "LE10NAFEMS_MST10_sigmay.vtk"
vtkexportmesh(
File,
fes.conn,
geom.values,
FinEtools.MeshExportModule.T10;
vectors = [("u", u.values)],
scalars = [("sigmay", fld.values)],
)
@async run(`"paraview.exe" $File`)
true
AE = AbaqusExporter("LE10NAFEMS_MST10")
HEADING(
AE,
"LE10NAFEMS: Transverse deflection of elliptical plate with elliptical hole.",
)
PART(AE, "part1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
ELEMENT(AE, "c3d10", "AllElements", 1, femm.integdata.fes.conn)
ELEMENT(
AE,
"SFM3D6",
"TractionElements",
1 + count(femm.integdata.fes),
eL1femm.integdata.fes.conn,
)
NSET_NSET(AE, "L1", L1)
NSET_NSET(AE, "L2", L2)
NSET_NSET(AE, "L3", L3)
NSET_NSET(AE, "L12", L12)
ORIENTATION(AE, "GlobalOrientation", vec([1.0 0 0]), vec([0 1.0 0]))
SOLID_SECTION(AE, "elasticity", "GlobalOrientation", "AllElements", "Hourglassctl")
SURFACE_SECTION(AE, "TractionElements")
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "elasticity")
ELASTIC(AE, E, nu)
SECTION_CONTROLS(AE, "Hourglassctl", "HOURGLASS=ENHANCED")
STEP_PERTURBATION_STATIC(AE)
BOUNDARY(AE, "ASSEM1.INSTNC1.L1", 1)
BOUNDARY(AE, "ASSEM1.INSTNC1.L2", 2)
BOUNDARY(AE, "ASSEM1.INSTNC1.L3", 3)
BOUNDARY(AE, "ASSEM1.INSTNC1.L12", 1)
BOUNDARY(AE, "ASSEM1.INSTNC1.L12", 2)
DLOAD(AE, "ASSEM1.INSTNC1.TractionElements", vec([0.0, 0.0, -qmagn]))
END_STEP(AE)
close(AE)
output = MeshImportModule.import_ABAQUS(AE.filename)
fens, fes = output["fens"], output["fesets"][1]
# Select the boundary faces, on the boundary that is clamped, and on the part
# of the boundary that is loaded with the transverse pressure
bdryfes = meshboundary(fes)
exteriorbfl = selectelem(fens, bdryfes, facing = true, direction = [1.0, 1.0, 0.0])
topbfl = selectelem(
fens,
bdryfes,
box = [0.0, Inf, 0.0, Inf, Thickness, Thickness],
inflate = tolerance,
)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
L12 = connectednodes(subset(bdryfes, exteriorbfl)) # external boundary
setebc!(u, L12, true, 1, 0.0)
setebc!(u, L12, true, 2, 0.0)
LL = selectnode(
fens;
box = [0.0, Inf, 0.0, Inf, Thickness / 2.0, Thickness / 2.0],
inflate = tolerance,
)
L3 = intersect(LL, connectednodes(subset(bdryfes, exteriorbfl)))
setebc!(u, L3, true, 3, 0.0)
L1 = selectnode(fens; box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness], inflate = tolerance)
setebc!(u, L1, true, 1, 0.0) # symmetry plane X = 0
L2 = selectnode(fens; box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness], inflate = tolerance)
setebc!(u, L2, true, 2, 0.0) # symmetry plane Y = 0
applyebc!(u)
numberdofs!(u)
eL1femm = FEMMBase(IntegDomain(subset(bdryfes, topbfl), TriRule(3)))
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(eL1femm, geom, u, fi, 2)
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the fully three-dimensional solid.
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMST10(MR, IntegDomain(fes, TetRule(4)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (F2)
scattersysvec!(u, U[:])
nl = selectnode(fens, box = [Ai, Ai, 0, 0, Thickness, Thickness], inflate = tolerance)
thecorneru = zeros(FFlt, 1, 3)
gathervalues_asmat!(u, thecorneru, nl)
thecorneru = thecorneru / phun("mm")
println(
"displacement =$(thecorneru) [MM] as compared to reference [-0.030939, 0, -0.10488] [MM]",
)
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = :extrapmean,
)#
println(
"Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yP = $(sigma_yP/phun("MPa")) [MPa]",
)
println("Mean-stress: $(fld.values[nl,1][1]/phun("MPa"))")
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = :extraptrend,
)#
println(
"Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yP = $(sigma_yP/phun("MPa")) [MPa]",
)
println("Trend estimation: $(fld.values[nl,1][1]/phun("MPa"))")
File = "LE10NAFEMS_MST10_sigmay.vtk"
vtkexportmesh(
File,
fes.conn,
geom.values,
FinEtools.MeshExportModule.T10;
vectors = [("u", u.values)],
scalars = [("sigmay", fld.values)],
)
@async run(`"paraview.exe" $File`)
true
end # LE10NAFEMS_Abaqus_MST10
function LE10NAFEMS_MSH8()
# Thick elliptical plate with an elliptical hole is clamped on its exterior
# boundary and is loaded with transverse pressure.
# This is a NAFEMS Benchmark, Test No. LE10.
# The plate is discretized with solid elements.
# Because of the symmetries of the geometry and load, only quarter of the plate is modeled.
# The $\sigma_y=\sigma_2$ at the point $P$ is to be determined. Since the
# target point is on the boundary of the domain it will not be an
# integration node as we use Gauss quadrature. The reference value is -5.38 MPa.
println("LE10NAFEMS: Transverse deflection of elliptical plate with elliptical hole.")
t0 = time()
E = 210e3 * phun("MEGA*PA")# 210e3 MPa
nu = 0.3
qmagn = 1.0 * phun("MEGA*PA")# transverse pressure
sigma_yP = -5.38 * phun("MEGA*PA")# tensile stress at [2.0, 0.0] meters
Ae = 3.25 * phun("m") # Major radius of the exterior ellipse
Be = 2.75 * phun("m") # Minor radius of the exterior ellipse
Ai = 2.0 * phun("m") # Major radius of the interior ellipse
Bi = 1.0 * phun("m") # Minor radius of the interior ellipse
Thickness = 0.6 * phun("m")
nc = 6 # number of elements per side
nr = 5 # number of elements per side
nt = 2 # number of elements through the thickness
nc = 26 # number of elements per side
nr = 25 # number of elements per side
nt = 18 # number of elements through the thickness
tolerance = Thickness / nt / 1000.0 # Geometrical tolerance
fens, fes = Q4block(1.0, pi / 2, nr, nc)
#
@assert nt % 2 == 0 "Number of elements through the thickness must be even"
fens, fes = H8extrudeQ4(
fens,
fes,
nt,
(xyz, layer) -> [xyz[1], xyz[2], (layer) / nt * Thickness],
)
# Select the boundary faces, on the boundary that is clamped, and on the part
# of the boundary that is loaded with the transverse pressure
bdryfes = meshboundary(fes)
exteriorbfl = selectelem(
fens,
bdryfes,
box = [1.0, 1.0, 0.0, pi / 2, 0.0, Thickness],
inflate = tolerance,
)
topbfl = selectelem(
fens,
bdryfes,
box = [0.0, 1.0, 0.0, pi / 2, Thickness, Thickness],
inflate = tolerance,
)
# Reshape the generated block into the elliptical plate
for i = 1:count(fens)
r = fens.xyz[i, 1]
a = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] =
[(r * Ae + (1 - r) * Ai) * cos(a) (r * Be + (1 - r) * Bi) * sin(a) z]
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l1 = connectednodes(subset(bdryfes, exteriorbfl)) # external boundary
setebc!(u, l1, true, 1, 0.0)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(
fens;
box = [0.0, Inf, 0.0, Inf, Thickness / 2.0, Thickness / 2.0],
inflate = tolerance,
)
l1 = intersect(l1, connectednodes(subset(bdryfes, exteriorbfl)))
setebc!(u, l1, true, 3, 0.0)
l1 = selectnode(fens; box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness], inflate = tolerance)
setebc!(u, l1, true, 1, 0.0) # symmetry plane X = 0
l1 = selectnode(fens; box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness], inflate = tolerance)
setebc!(u, l1, true, 2, 0.0) # symmetry plane Y = 0
applyebc!(u)
numberdofs!(u)
el1femm = FEMMBase(IntegDomain(subset(bdryfes, topbfl), GaussRule(2, 2)))
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
) where {T}
forceout .= [0.0, 0.0, -qmagn]
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(el1femm, geom, u, fi, 2)
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the fully three-dimensional solid.
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (F2)
scattersysvec!(u, U[:])
nl = selectnode(fens, box = [Ai, Ai, 0, 0, Thickness, Thickness], inflate = tolerance)
thecorneru = zeros(FFlt, 1, 3)
gathervalues_asmat!(u, thecorneru, nl)
thecorneru = thecorneru / phun("mm")
println(
"displacement =$(thecorneru) [MM] as compared to reference [-0.030939, 0, -0.10488] [MM]",
)
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = :extraptrend,
)#
println(
"Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yP = $(sigma_yP/phun("MPa")) [MPa]",
)
println("$((nc, nr, nt)), $(fld.values[nl,1][1]/phun("MPa"))")
File = "LE10NAFEMS_sigmay.vtk"
vtkexportmesh(
File,
fes.conn,
geom.values,
FinEtools.MeshExportModule.H8;
vectors = [("u", u.values)],
scalars = [("sigmay", fld.values)],
)
@async run(`"paraview.exe" $File`)
true
end # LE10NAFEMS_MSH8
function LE10NAFEMS_MSH8_alt_export()
# Thick elliptical plate with an elliptical hole is clamped on its exterior
# boundary and is loaded with transverse pressure.
# This is a NAFEMS Benchmark, Test No. LE10.
# The plate is discretized with solid elements.
# Because of the symmetries of the geometry and load, only quarter of the plate is modeled.
# The $\sigma_y=\sigma_2$ at the point $P$ is to be determined. Since the
# target point is on the boundary of the domain it will not be an
# integration node as we use Gauss quadrature. The reference value is -5.38 MPa.
println("LE10NAFEMS: Transverse deflection of elliptical plate with elliptical hole.")
t0 = time()
E = 210e3 * phun("MEGA*PA")# 210e3 MPa
nu = 0.3
qmagn = 1.0 * phun("MEGA*PA")# transverse pressure
sigma_yP = -5.38 * phun("MEGA*PA")# tensile stress at [2.0, 0.0] meters
Ae = 3.25 * phun("m") # Major radius of the exterior ellipse
Be = 2.75 * phun("m") # Minor radius of the exterior ellipse
Ai = 2.0 * phun("m") # Major radius of the interior ellipse
Bi = 1.0 * phun("m") # Minor radius of the interior ellipse
Thickness = 0.6 * phun("m")
nc = 6 # number of elements per side
nr = 5 # number of elements per side
nt = 2 # number of elements through the thickness
# nc = 26; # number of elements per side
# nr = 25; # number of elements per side
# nt = 18; # number of elements through the thickness
tolerance = Thickness / nt / 1000.0 # Geometrical tolerance
fens, fes = Q4block(1.0, pi / 2, nr, nc)
#
@assert nt % 2 == 0 "Number of elements through the thickness must be even"
fens, fes = H8extrudeQ4(
fens,
fes,
nt,
(xyz, layer) -> [xyz[1], xyz[2], (layer) / nt * Thickness],
)
# Select the boundary faces, on the boundary that is clamped, and on the part
# of the boundary that is loaded with the transverse pressure
bdryfes = meshboundary(fes)
exteriorbfl = selectelem(
fens,
bdryfes,
box = [1.0, 1.0, 0.0, pi / 2, 0.0, Thickness],
inflate = tolerance,
)
topbfl = selectelem(
fens,
bdryfes,
box = [0.0, 1.0, 0.0, pi / 2, Thickness, Thickness],
inflate = tolerance,
)
# Reshape the generated block into the elliptical plate
for i = 1:count(fens)
r = fens.xyz[i, 1]
a = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] =
[(r * Ae + (1 - r) * Ai) * cos(a) (r * Be + (1 - r) * Bi) * sin(a) z]
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l12 = connectednodes(subset(bdryfes, exteriorbfl)) # external boundary
setebc!(u, l12, true, 1, 0.0)
setebc!(u, l12, true, 2, 0.0)
ll = selectnode(
fens;
box = [0.0, Inf, 0.0, Inf, Thickness / 2.0, Thickness / 2.0],
inflate = tolerance,
)
l3 = intersect(ll, connectednodes(subset(bdryfes, exteriorbfl)))
setebc!(u, l3, true, 3, 0.0)
l1 = selectnode(fens; box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness], inflate = tolerance)
setebc!(u, l1, true, 1, 0.0) # symmetry plane X = 0
l2 = selectnode(fens; box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness], inflate = tolerance)
setebc!(u, l2, true, 2, 0.0) # symmetry plane Y = 0
applyebc!(u)
numberdofs!(u)
el1femm = FEMMBase(IntegDomain(subset(bdryfes, topbfl), GaussRule(2, 2)))
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
) where {T}
forceout .= [0.0, 0.0, -qmagn]
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(el1femm, geom, u, fi, 2)
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the fully three-dimensional solid.
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (F2)
scattersysvec!(u, U[:])
nl = selectnode(fens, box = [Ai, Ai, 0, 0, Thickness, Thickness], inflate = tolerance)
thecorneru = zeros(FFlt, 1, 3)
gathervalues_asmat!(u, thecorneru, nl)
thecorneru = thecorneru / phun("mm")
println(
"displacement =$(thecorneru) [MM] as compared to reference [-0.030939, 0, -0.10488] [MM]",
)
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = :extraptrend,
)#
println(
"Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yP = $(sigma_yP/phun("MPa")) [MPa]",
)
println("$((nc, nr, nt)), $(fld.values[nl,1][1]/phun("MPa"))")
# File = "LE10NAFEMS_sigmay.vtk"
# vtkexportmesh(File, fes.conn, geom.values,
# FinEtools.MeshExportModule.H8; vectors=[("u", u.values)],
# scalars=[("sigmay", fld.values)])
# @async run(`"paraview.exe" $File`)
# true
AE = AbaqusExporter("LE10NAFEMS_H8")
HEADING(
AE,
"LE10NAFEMS: Transverse deflection of elliptical plate with elliptical hole.",
)
PART(AE, "part1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
ELEMENT(AE, "c3d8rh", "AllElements", 1, femm.integdata.fes.conn)
ELEMENT(
AE,
"SFM3D4",
"TractionElements",
1 + count(femm.integdata.fes),
el1femm.integdata.fes.conn,
)
NSET_NSET(AE, "l1", l1)
NSET_NSET(AE, "l2", l2)
NSET_NSET(AE, "l3", l3)
NSET_NSET(AE, "l12", l12)
ORIENTATION(AE, "GlobalOrientation", vec([1.0 0 0]), vec([0 1.0 0]))
SOLID_SECTION(AE, "elasticity", "GlobalOrientation", "AllElements", "Hourglassctl")
SURFACE_SECTION(AE, "TractionElements")
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "elasticity")
ELASTIC(AE, E, nu)
SECTION_CONTROLS(AE, "Hourglassctl", "HOURGLASS=ENHANCED")
STEP_PERTURBATION_STATIC(AE)
BOUNDARY(AE, "ASSEM1.INSTNC1.", u.is_fixed, u.fixed_values)
DLOAD(AE, "ASSEM1.INSTNC1.TractionElements", vec([0.0, 0.0, -qmagn]))
END_STEP(AE)
close(AE)
end # LE10NAFEMS_MSH8_alt_export
function LE10NAFEMS_MSH8_export()
# Thick elliptical plate with an elliptical hole is clamped on its exterior
# boundary and is loaded with transverse pressure.
# This is a NAFEMS Benchmark, Test No. LE10.
# The plate is discretized with solid elements.
# Because of the symmetries of the geometry and load, only quarter of the plate is modeled.
# The $\sigma_y=\sigma_2$ at the point $P$ is to be determined. Since the
# target point is on the boundary of the domain it will not be an
# integration node as we use Gauss quadrature. The reference value is -5.38 MPa.
println("LE10NAFEMS: Transverse deflection of elliptical plate with elliptical hole.")
t0 = time()
E = 210e3 * phun("MEGA*PA")# 210e3 MPa
nu = 0.3
qmagn = 1.0 * phun("MEGA*PA")# transverse pressure
sigma_yP = -5.38 * phun("MEGA*PA")# tensile stress at [2.0, 0.0] meters
Ae = 3.25 * phun("m") # Major radius of the exterior ellipse
Be = 2.75 * phun("m") # Minor radius of the exterior ellipse
Ai = 2.0 * phun("m") # Major radius of the interior ellipse
Bi = 1.0 * phun("m") # Minor radius of the interior ellipse
Thickness = 0.6 * phun("m")
nc = 6 # number of elements per side
nr = 5 # number of elements per side
nt = 2 # number of elements through the thickness
# nc = 26; # number of elements per side
# nr = 25; # number of elements per side
# nt = 18; # number of elements through the thickness
tolerance = Thickness / nt / 1000.0 # Geometrical tolerance
fens, fes = Q4block(1.0, pi / 2, nr, nc)
#
@assert nt % 2 == 0 "Number of elements through the thickness must be even"
fens, fes = H8extrudeQ4(
fens,
fes,
nt,
(xyz, layer) -> [xyz[1], xyz[2], (layer) / nt * Thickness],
)
# Select the boundary faces, on the boundary that is clamped, and on the part
# of the boundary that is loaded with the transverse pressure
bdryfes = meshboundary(fes)
exteriorbfl = selectelem(
fens,
bdryfes,
box = [1.0, 1.0, 0.0, pi / 2, 0.0, Thickness],
inflate = tolerance,
)
topbfl = selectelem(
fens,
bdryfes,
box = [0.0, 1.0, 0.0, pi / 2, Thickness, Thickness],
inflate = tolerance,
)
# Reshape the generated block into the elliptical plate
for i = 1:count(fens)
r = fens.xyz[i, 1]
a = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] =
[(r * Ae + (1 - r) * Ai) * cos(a) (r * Be + (1 - r) * Bi) * sin(a) z]
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l12 = connectednodes(subset(bdryfes, exteriorbfl)) # external boundary
setebc!(u, l12, true, 1, 0.0)
setebc!(u, l12, true, 2, 0.0)
ll = selectnode(
fens;
box = [0.0, Inf, 0.0, Inf, Thickness / 2.0, Thickness / 2.0],
inflate = tolerance,
)
l3 = intersect(ll, connectednodes(subset(bdryfes, exteriorbfl)))
setebc!(u, l3, true, 3, 0.0)
l1 = selectnode(fens; box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness], inflate = tolerance)
setebc!(u, l1, true, 1, 0.0) # symmetry plane X = 0
l2 = selectnode(fens; box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness], inflate = tolerance)
setebc!(u, l2, true, 2, 0.0) # symmetry plane Y = 0
applyebc!(u)
numberdofs!(u)
el1femm = FEMMBase(IntegDomain(subset(bdryfes, topbfl), GaussRule(2, 2)))
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
) where {T}
forceout .= [0.0, 0.0, -qmagn]
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(el1femm, geom, u, fi, 2)
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the fully three-dimensional solid.
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (F2)
scattersysvec!(u, U[:])
nl = selectnode(fens, box = [Ai, Ai, 0, 0, Thickness, Thickness], inflate = tolerance)
thecorneru = zeros(FFlt, 1, 3)
gathervalues_asmat!(u, thecorneru, nl)
thecorneru = thecorneru / phun("mm")
println(
"displacement =$(thecorneru) [MM] as compared to reference [-0.030939, 0, -0.10488] [MM]",
)
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = :extraptrend,
)#
println(
"Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yP = $(sigma_yP/phun("MPa")) [MPa]",
)
println("$((nc, nr, nt)), $(fld.values[nl,1][1]/phun("MPa"))")
# File = "LE10NAFEMS_sigmay.vtk"
# vtkexportmesh(File, fes.conn, geom.values,
# FinEtools.MeshExportModule.H8; vectors=[("u", u.values)],
# scalars=[("sigmay", fld.values)])
# @async run(`"paraview.exe" $File`)
# true
AE = AbaqusExporter("LE10NAFEMS_H8")
HEADING(
AE,
"LE10NAFEMS: Transverse deflection of elliptical plate with elliptical hole.",
)
PART(AE, "part1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
ELEMENT(AE, "c3d8rh", "AllElements", 1, femm.integdata.fes.conn)
ELEMENT(
AE,
"SFM3D4",
"TractionElements",
1 + count(femm.integdata.fes),
el1femm.integdata.fes.conn,
)
NSET_NSET(AE, "l1", l1)
NSET_NSET(AE, "l2", l2)
NSET_NSET(AE, "l3", l3)
NSET_NSET(AE, "l12", l12)
ORIENTATION(AE, "GlobalOrientation", vec([1.0 0 0]), vec([0 1.0 0]))
SOLID_SECTION(AE, "elasticity", "GlobalOrientation", "AllElements", "Hourglassctl")
SURFACE_SECTION(AE, "TractionElements")
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "elasticity")
ELASTIC(AE, E, nu)
SECTION_CONTROLS(AE, "Hourglassctl", "HOURGLASS=ENHANCED")
STEP_PERTURBATION_STATIC(AE)
BOUNDARY(AE, "ASSEM1.INSTNC1.l1", 1)
BOUNDARY(AE, "ASSEM1.INSTNC1.l2", 2)
BOUNDARY(AE, "ASSEM1.INSTNC1.l3", 3)
BOUNDARY(AE, "ASSEM1.INSTNC1.l12", 1)
BOUNDARY(AE, "ASSEM1.INSTNC1.l12", 2)
DLOAD(AE, "ASSEM1.INSTNC1.TractionElements", vec([0.0, 0.0, -qmagn]))
END_STEP(AE)
close(AE)
end # LE10NAFEMS_MSH8_export
function LE10NAFEMS_MST10()
# Thick elliptical plate with an elliptical hole is clamped on its exterior
# boundary and is loaded with transverse pressure.
# This is a NAFEMS Benchmark, Test No. LE10.
# The plate is discretized with solid elements.
# Because of the symmetries of the geometry and load, only quarter of the plate is modeled.
# The $\sigma_y=\sigma_2$ at the point $P$ is to be determined. Since the
# target point is on the boundary of the domain it will not be an
# integration node as we use Gauss quadrature. The reference value is -5.38 MPa.
println("LE10NAFEMS: Transverse deflection of elliptical plate with elliptical hole.")
t0 = time()
E = 210e3 * phun("MEGA*PA")# 210e3 MPa
nu = 0.3
qmagn = 1.0 * phun("MEGA*PA")# transverse pressure
sigma_yP = -5.38 * phun("MEGA*PA")# tensile stress at [2.0, 0.0] meters
Ae = 3.25 * phun("m") # Major radius of the exterior ellipse
Be = 2.75 * phun("m") # Minor radius of the exterior ellipse
Ai = 2.0 * phun("m") # Major radius of the interior ellipse
Bi = 1.0 * phun("m") # Minor radius of the interior ellipse
Thickness = 0.6 * phun("m")
ref = 2
nc = 2^ref * 6 # number of elements per side
nr = 2^ref * 5 # number of elements per side
nt = 2^ref * 2 # number of elements through the thickness
tolerance = Thickness / nt / 1000.0 # Geometrical tolerance
@assert nt % 2 == 0 "Number of elements through the thickness must be even"
fens, fes = T10block(1.0, pi / 2, Thickness, nr, nc, nt, orientation = :b)
# Select the boundary faces, on the boundary that is clamped, and on the part
# of the boundary that is loaded with the transverse pressure
bdryfes = meshboundary(fes)
exteriorbfl = selectelem(
fens,
bdryfes,
box = [1.0, 1.0, 0.0, pi / 2, 0.0, Thickness],
inflate = tolerance,
)
topbfl = selectelem(
fens,
bdryfes,
box = [0.0, 1.0, 0.0, pi / 2, Thickness, Thickness],
inflate = tolerance,
)
# Reshape the generated block into the elliptical plate
for i = 1:count(fens)
r = fens.xyz[i, 1]
a = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] =
[(r * Ae + (1 - r) * Ai) * cos(a) (r * Be + (1 - r) * Bi) * sin(a) z]
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l12 = connectednodes(subset(bdryfes, exteriorbfl)) # external boundary
setebc!(u, l12, true, 1, 0.0)
setebc!(u, l12, true, 2, 0.0)
ll = selectnode(
fens;
box = [0.0, Inf, 0.0, Inf, Thickness / 2.0, Thickness / 2.0],
inflate = tolerance,
)
l3 = intersect(ll, connectednodes(subset(bdryfes, exteriorbfl)))
setebc!(u, l3, true, 3, 0.0)
l1 = selectnode(fens; box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness], inflate = tolerance)
setebc!(u, l1, true, 1, 0.0) # symmetry plane X = 0
l2 = selectnode(fens; box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness], inflate = tolerance)
setebc!(u, l2, true, 2, 0.0) # symmetry plane Y = 0
applyebc!(u)
numberdofs!(u)
el1femm = FEMMBase(IntegDomain(subset(bdryfes, topbfl), TriRule(3)))
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
) where {T}
forceout .= [0.0, 0.0, -qmagn]
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(el1femm, geom, u, fi, 2)
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the fully three-dimensional solid.
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMST10(MR, IntegDomain(fes, TetRule(4)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (F2)
scattersysvec!(u, U[:])
nl = selectnode(fens, box = [Ai, Ai, 0, 0, Thickness, Thickness], inflate = tolerance)
thecorneru = zeros(FFlt, 1, 3)
gathervalues_asmat!(u, thecorneru, nl)
thecorneru = thecorneru / phun("mm")
println(
"displacement =$(thecorneru) [MM] as compared to reference [-0.030939, 0, -0.10488] [MM]",
)
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = :extraptrend,
)#
println(
"Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yP = $(sigma_yP/phun("MPa")) [MPa]",
)
println("$((nc, nr, nt)), $(fld.values[nl,1][1]/phun("MPa"))")
# File = "LE10NAFEMS_MST10_sigmay.vtk"
# vtkexportmesh(File, fes.conn, geom.values,
# FinEtools.MeshExportModule.T10; vectors=[("u", u.values)],
# scalars=[("sigmay", fld.values)])
# @async run(`"paraview.exe" $File`)
# true
AE = AbaqusExporter("LE10NAFEMS_MST10")
HEADING(
AE,
"LE10NAFEMS: Transverse deflection of elliptical plate with elliptical hole.",
)
PART(AE, "part1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
ELEMENT(AE, "c3d10", "AllElements", 1, femm.integdata.fes.conn)
ELEMENT(
AE,
"SFM3D6",
"TractionElements",
1 + count(femm.integdata.fes),
el1femm.integdata.fes.conn,
)
NSET_NSET(AE, "l1", l1)
NSET_NSET(AE, "l2", l2)
NSET_NSET(AE, "l3", l3)
NSET_NSET(AE, "l12", l12)
ORIENTATION(AE, "GlobalOrientation", vec([1.0 0 0]), vec([0 1.0 0]))
SOLID_SECTION(AE, "elasticity", "GlobalOrientation", "AllElements", "Hourglassctl")
SURFACE_SECTION(AE, "TractionElements")
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "elasticity")
ELASTIC(AE, E, nu)
SECTION_CONTROLS(AE, "Hourglassctl", "HOURGLASS=ENHANCED")
STEP_PERTURBATION_STATIC(AE)
BOUNDARY(AE, "ASSEM1.INSTNC1.l1", 1)
BOUNDARY(AE, "ASSEM1.INSTNC1.l2", 2)
BOUNDARY(AE, "ASSEM1.INSTNC1.l3", 3)
BOUNDARY(AE, "ASSEM1.INSTNC1.l12", 1)
BOUNDARY(AE, "ASSEM1.INSTNC1.l12", 2)
DLOAD(AE, "ASSEM1.INSTNC1.TractionElements", vec([0.0, 0.0, -qmagn]))
END_STEP(AE)
close(AE)
end # LE10NAFEMS_MST10
function evaluateerrors(filebase, modeldatasequence)
println("")
println("RMS error")
elementsizes, errornorms, p = evalconvergencestudy(modeldatasequence)
println("Normalized Approximate Error = $(errornorms)")
f = log.(vec(errornorms))
A = hcat(log.(vec(elementsizes[1:(end-1)])), ones(size(f)))
p = A \ f
println("Linear log-log fit: p = $(p)")
csvFile = filebase * "_Stress" * ".CSV"
savecsv(
csvFile,
elementsizes = vec(elementsizes[1:(end-1)]),
elementsizes2 = vec(elementsizes[1:(end-1)] .^ 2),
elementsizes3 = vec(elementsizes[1:(end-1)] .^ 3),
errornorms = vec(errornorms),
)
println("Wrote $csvFile")
end
function LE10NAFEMS_MST10_stresses_nodal()
# Note: the stresses measured in the RMS norm will not converge very well: there is a singularity around the clamped face.
elementtag = "MST10"
println("LE10NAFEMS, 3D version. Element: $(elementtag)")
E = 210e3 * phun("MEGA*PA")# 210e3 MPa
nu = 0.3
qmagn = 1.0 * phun("MEGA*PA")# transverse pressure
sigma_yP = -5.38 * phun("MEGA*PA")# tensile stress at [2.0, 0.0] meters
Ae = 3.25 * phun("m") # Major radius of the exterior ellipse
Be = 2.75 * phun("m") # Minor radius of the exterior ellipse
Ai = 2.0 * phun("m") # Major radius of the interior ellipse
Bi = 1.0 * phun("m") # Minor radius of the interior ellipse
Thickness = 0.6 * phun("m")
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
) where {T}
forceout .= [0.0, 0.0, -qmagn]
return forceout
end
for extrapolation in [:extraptrend :extrapmean]
modeldatasequence = FDataDict[]
for ref in [0, 1, 2, 3]
tolerance = Thickness / 2^ref / 1000.0 # Geometrical tolerance
# nr, nc, nt = 2^ref*5, 2^ref*6, 2^ref*2 # July 5, 2018
nr, nc, nt = 2^ref * 3, 2^ref * 4, 2^ref * 2
@assert nt % 2 == 0 "Number of elements through the thickness must be even"
fens, fes = T10block(1.0, pi / 2, Thickness, nr, nc, nt, orientation = :b)
# Select the boundary faces, on the boundary that is clamped, and on the part
# of the boundary that is loaded with the transverse pressure
bdryfes = meshboundary(fes)
exteriorbfl = selectelem(
fens,
bdryfes,
box = [1.0, 1.0, 0.0, pi / 2, 0.0, Thickness],
inflate = tolerance,
)
topbfl = selectelem(
fens,
bdryfes,
box = [0.0, 1.0, 0.0, pi / 2, Thickness, Thickness],
inflate = tolerance,
)
# Reshape the generated block into the elliptical plate
for i = 1:count(fens)
r = fens.xyz[i, 1]
a = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] =
[(r * Ae + (1 - r) * Ai) * cos(a) (r * Be + (1 - r) * Bi) * sin(a) z]
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l12 = connectednodes(subset(bdryfes, exteriorbfl)) # external boundary
setebc!(u, l12, true, 1, 0.0)
setebc!(u, l12, true, 2, 0.0)
ll = selectnode(
fens;
box = [0.0, Inf, 0.0, Inf, Thickness / 2.0, Thickness / 2.0],
inflate = tolerance,
)
l3 = intersect(ll, connectednodes(subset(bdryfes, exteriorbfl)))
setebc!(u, l3, true, 3, 0.0)
l1 = selectnode(
fens;
box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 1, 0.0) # symmetry plane X = 0
l2 = selectnode(
fens;
box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l2, true, 2, 0.0) # symmetry plane Y = 0
applyebc!(u)
numberdofs!(u)
el1femm = FEMMBase(IntegDomain(subset(bdryfes, topbfl), TriRule(3)))
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(el1femm, geom, u, fi, 2)
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the fully three-dimensional solid.
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMST10(MR, IntegDomain(fes, TetRule(4)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (F2)
scattersysvec!(u, U[:])
nl = selectnode(
fens,
box = [Ai, Ai, 0, 0, Thickness, Thickness],
inflate = tolerance,
)
thecorneru = zeros(FFlt, 1, 3)
gathervalues_asmat!(u, thecorneru, nl)
thecorneru = thecorneru / phun("mm")
println(
"displacement =$(thecorneru) [MM] as compared to reference [-0.030939, 0, -0.10488] [MM]",
)
stressfield = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
collect(1:6);
nodevalmethod = :averaging,
reportat = extrapolation,
)
# File = "LE10NAFEMS_MST10_sigmay.vtk"
# vtkexportmesh(File, fes.conn, geom.values,
# FinEtools.MeshExportModule.T10; vectors=[("u", u.values)],
# scalars=[("sig", stressfield.values)])
# @async run(`"paraview.exe" $File`)
modeldata = FDataDict()
modeldata["fens"] = fens
modeldata["regions"] = [FDataDict("femm" => femm)]
modeldata["targetfields"] = [stressfield]
modeldata["geom"] = geom
modeldata["geometricaltolerance"] = tolerance
modeldata["elementsize"] = 1.0 / 2^ref
push!(modeldatasequence, modeldata)
end # for ref
filebase = "LE10NAFEMS_MST10_stresses_nodal_$(extrapolation)"
evaluateerrors(filebase, modeldatasequence)
end # for extrapolation
end # LE10NAFEMS_MST10_stresses_nodal
function LE10NAFEMS_MSH8_stresses_nodal()
# Note: the stresses measured in the RMS norm will not converge very well: there is a singularity around the clamped face.
elementtag = "MSH8"
println("LE10NAFEMS, 3D version. Element: $(elementtag)")
E = 210e3 * phun("MEGA*PA")# 210e3 MPa
nu = 0.3
qmagn = 1.0 * phun("MEGA*PA")# transverse pressure
sigma_yP = -5.38 * phun("MEGA*PA")# tensile stress at [2.0, 0.0] meters
Ae = 3.25 * phun("m") # Major radius of the exterior ellipse
Be = 2.75 * phun("m") # Minor radius of the exterior ellipse
Ai = 2.0 * phun("m") # Major radius of the interior ellipse
Bi = 1.0 * phun("m") # Minor radius of the interior ellipse
Thickness = 0.6 * phun("m")
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
) where {T}
forceout .= [0.0, 0.0, -qmagn]
return forceout
end
for extrapolation in [:extraptrend :extrapmean]
modeldatasequence = FDataDict[]
for ref in [0, 1, 2, 3]
tolerance = Thickness / 2^ref / 1000.0 # Geometrical tolerance
nr, nc, nt = 2^ref * 5, 2^ref * 6, 2^ref * 2
@assert nt % 2 == 0 "Number of elements through the thickness must be even"
fens, fes = H8block(1.0, pi / 2, Thickness, nr, nc, nt)
# Select the boundary faces, on the boundary that is clamped, and on the part
# of the boundary that is loaded with the transverse pressure
bdryfes = meshboundary(fes)
exteriorbfl = selectelem(
fens,
bdryfes,
box = [1.0, 1.0, 0.0, pi / 2, 0.0, Thickness],
inflate = tolerance,
)
topbfl = selectelem(
fens,
bdryfes,
box = [0.0, 1.0, 0.0, pi / 2, Thickness, Thickness],
inflate = tolerance,
)
# Reshape the generated block into the elliptical plate
for i = 1:count(fens)
r = fens.xyz[i, 1]
a = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] =
[(r * Ae + (1 - r) * Ai) * cos(a) (r * Be + (1 - r) * Bi) * sin(a) z]
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l12 = connectednodes(subset(bdryfes, exteriorbfl)) # external boundary
setebc!(u, l12, true, 1, 0.0)
setebc!(u, l12, true, 2, 0.0)
ll = selectnode(
fens;
box = [0.0, Inf, 0.0, Inf, Thickness / 2.0, Thickness / 2.0],
inflate = tolerance,
)
l3 = intersect(ll, connectednodes(subset(bdryfes, exteriorbfl)))
setebc!(u, l3, true, 3, 0.0)
l1 = selectnode(
fens;
box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 1, 0.0) # symmetry plane X = 0
l2 = selectnode(
fens;
box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l2, true, 2, 0.0) # symmetry plane Y = 0
applyebc!(u)
numberdofs!(u)
el1femm = FEMMBase(IntegDomain(subset(bdryfes, topbfl), GaussRule(2, 2)))
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(el1femm, geom, u, fi, 2)
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the fully three-dimensional solid.
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (F2)
scattersysvec!(u, U[:])
nl = selectnode(
fens,
box = [Ai, Ai, 0, 0, Thickness, Thickness],
inflate = tolerance,
)
thecorneru = zeros(FFlt, 1, 3)
gathervalues_asmat!(u, thecorneru, nl)
thecorneru = thecorneru / phun("mm")
println(
"displacement =$(thecorneru) [MM] as compared to reference [-0.030939, 0, -0.10488] [MM]",
)
stressfield = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
collect(1:6);
nodevalmethod = :averaging,
reportat = extrapolation,
)
println(
"Sigma_y =$(stressfield.values[nl,2][1]/phun("MPa")) as compared to reference sigma_yP = $(sigma_yP/phun("MPa")) [MPa]",
)
# File = "LE10NAFEMS_MST10_sigmay.vtk"
# vtkexportmesh(File, fes.conn, geom.values,
# FinEtools.MeshExportModule.T10; vectors=[("u", u.values)],
# scalars=[("sig", stressfield.values)])
# @async run(`"paraview.exe" $File`)
modeldata = FDataDict()
modeldata["fens"] = fens
modeldata["regions"] = [FDataDict("femm" => femm)]
modeldata["targetfields"] = [stressfield]
modeldata["geom"] = geom
modeldata["geometricaltolerance"] = Thickness / 2^ref
modeldata["parametrictolerance"] = 0.01
modeldata["elementsize"] = 1.0 / 2^ref
push!(modeldatasequence, modeldata)
end # for ref
filebase = "LE10NAFEMS_MST10_stresses_nodal_$(extrapolation)"
evaluateerrors(filebase, modeldatasequence)
end # for extrapolation
end # LE10NAFEMS_MSH8_stresses_nodal
function allrun()
println("#####################################################")
println("# LE10NAFEMS_Abaqus_fine_MST10 ")
LE10NAFEMS_Abaqus_fine_MST10()
println("#####################################################")
println("# LE10NAFEMS_Abaqus_MST10 ")
LE10NAFEMS_Abaqus_MST10()
println("#####################################################")
println("# LE10NAFEMS_MSH8 ")
LE10NAFEMS_MSH8()
println("#####################################################")
println("# LE10NAFEMS_MSH8_alt_export ")
LE10NAFEMS_MSH8_alt_export()
println("#####################################################")
println("# LE10NAFEMS_MSH8_export ")
LE10NAFEMS_MSH8_export()
println("#####################################################")
println("# LE10NAFEMS_MST10 ")
LE10NAFEMS_MST10()
println("#####################################################")
println("# LE10NAFEMS_MST10_stresses_nodal ")
LE10NAFEMS_MST10_stresses_nodal()
println("#####################################################")
println("# LE10NAFEMS_MSH8_stresses_nodal ")
LE10NAFEMS_MSH8_stresses_nodal()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 10991 | module LE11NAFEMS_examples
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!, matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using Statistics
function LE11NAFEMS_H20()
## Solid cylinder/taper/sphere—-temperature loading; quadratic brick mesh
#
## Description
#
# The solid cylinder/taper/sphere axially-symmetric part represented in
# Figure 1 is exposed to linearly varying temperature in the plane of the
# cross-section. The temperature in the coordinates $r$ (the coordinate)
# and $z$ (the axial ccoordinate) is given as $T=r+z$. The goal is to find
# the mechanical stress at the point A induced by the thermal expansion.
#
##
# The part is constrained against axial expansion along the faces of HIH'I'
# and ABA'B'. The Young's modulus is 210 GPa, the Poisson's ratio is .3,
# and the coefficient of thermal expansion is 2.3e-4/degree Celsius.
##
# This is a test recommended by the National Agency for Finite Element
# Methods and Standards (U.K.): Test LE11 from NAFEMS Publication TNSB,
# Rev. 3, “The Standard NAFEMS Benchmarks,” October 1990.
#
# Target solution: Compressive axial stress $\sigma_z$ = –105 MPa along
# the circle passing through point A.
##
# The toolkit has a helpful physical-units facility. The function phun()
# allows use of basic units and basic
# multipliers (for instance, mega).
##
# Set the material properties.
Ea = 210000 * phun("MEGA*PA")# Young's modulus
nua = 0.3# Poisson ratio
alphaa = 2.3e-4# coefficient of thermal expansion
##
# This is the target stress value.
sigmaA = -105 * phun("MEGA*PA")
##
# The mesh will be created in a very coarse representation from the
# key points in the drawing. The first coordinate is radial, the second coordinate is axial.
rz =
[
1.0 0.0#A
1.4 0.0#B
0.995184726672197 0.098017140329561
1.393258617341076 0.137223996461385
0.980785 0.195090#
1.37309939 0.27312645
0.956940335732209 0.290284677254462
1.339716470025092 0.406398548156247
0.9238795 0.38268#C
1.2124 0.7#D
0.7071 0.7071#E
1.1062 1.045#F
0.7071 (0.7071+1.79)/2#(E+H)/2
1.0 1.39#G
0.7071 1.79#H
1.0 1.79
] * phun("M")
tolerance = 1.e-6 * phun("M")
##
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the fully three-dimensional solid.
MR = DeforModelRed3D
# This is the quadrilateral mesh of the cross-section. It will be modified and
# refined as we go.
fens = FENodeSet(rz)
fes = FESetQ4([
1 2 4 3
3 4 6 5
5 6 8 7
7 8 10 9
9 10 12 11
11 12 14 13
13 14 16 15
])
##
# If needed, the initial mesh can be refined by bisection. Just set
# `nref` greater than zero. Note that the nodes located along the
# edges are moved onto the spherical surface when they _should be_ on
# the spherical surface. This is important in order to ensure
# convergence to the proper value of the stress. Just refining the
# initial mesh without repositioning of the nodes onto the spherical surface would mean that the
# refinement would preserve a concave corner where in reality there is
# none. The stress would be artificially raised and convergence would
# not be guaranteed.
nref = 0
for ref = 1:nref
fens, fes = Q4refine(fens, fes)
list = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = [0.0 0.0],
inflate = tolerance,
)
fens.xyz[list, :] = FinEtools.MeshUtilModule.ontosphere(fens.xyz[list, :], 1.0)
end
##
# The mesh is extruded by sweeping around the axis of symmetry.
# Only a single layer of elements is generated of internal angle
# |angslice|.
nLayers = 7
angslice = 5 * pi / 16
##
# First the mesh is extruded to a block whose third dimension
# represents the angular coordinate.
fens, fes = H8extrudeQ4(
fens,
fes,
nLayers,
(rz, k) -> [rz[1], rz[2], 0.0] - (k) / nLayers * [0.0, 0.0, angslice],
)
##
# The mesh is now converted to the serendipity 20-node elements.
# We will reposition the nodes later.
fens, fes = H8toH20(fens, fes)
##
# The boundary of the block is extracted and the faces of the mesh on
# the bounding cross-sections are identified. Recall that this is just
# about the topology (connectivity), the geometry does not matter at
# this point.
bfes = meshboundary(fes)
f1l =
selectelem(fens, bfes, box = [-Inf, Inf, -Inf, Inf, 0.0, 0.0], inflate = tolerance)
f2l = selectelem(
fens,
bfes,
box = [-Inf, Inf, -Inf, Inf, -angslice, -angslice],
inflate = tolerance,
)
##
# The block is now converted to the axially symmetric geometry by using the
# third (angular) coordinate to sweep out an axially symmetric domain. The
# ccoordinates of the nodes at this point are |rza|, radial distance,
# Z-coordinate, angle.
function sweep(rza)
[
-rza[1] * sin(rza[3] + angslice / 2.0),
rza[1] * cos(rza[3] + angslice / 2.0),
rza[2],
]
end
for j = 1:size(fens.xyz, 1)
fens.xyz[j, :] = sweep(fens.xyz[j, :])
end
##
# The nodes within the radial distance of 1.0 of the origin (i. e.
# those on the spherical surface) are repositioned one more time to be
# located on the spherical surface for sure. (Recall that we have
# inserted additional nodes at the midpoints of the edges when the mesh
# was converted to quadratic elements.)
list = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = [0.0 0.0 0.0],
inflate = tolerance,
)
fens.xyz[list, :] = FinEtools.MeshUtilModule.ontosphere(fens.xyz[list, :], 1.0)
##
# We are ready to create the finite element model machine and to use
# it to construct the global system for the displacements.
##
# The material is created from the property object. Note that the
# |alpha| attribute is the thermal expansion coefficient.
# Create isotropic elastic material
material = MatDeforElastIso(MR, 1.0, Ea, nua, alphaa)
##
# The finite element model machine puts together the material, the
# finite elements, and the integration rule. The Gauss quadrature with
# 3x3x3 points gives good accuracy in this case. Compare it with 2x2x2
# quadrature to appreciate the difference.
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 3)), material)
##
# The geometry nodal field is created from the node set. The
# displacement field is created by cloning the geometry and then
# zeroing out the nodal parameters.
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
nnodes(geom)
##
# The EBCs are applied next. Only the axial (Z) degrees of freedom at
# the bottom and top are fixed to zero.
l1 = selectnode(fens, box = [-Inf Inf -Inf Inf 0.0 0.0], inflate = tolerance)
setebc!(u, l1, true, 3, zeros(size(l1)))
l1 = selectnode(fens, box = [-Inf Inf -Inf Inf 1.79 1.79], inflate = tolerance)
setebc!(u, l1, true, 3, zeros(size(l1)))
applyebc!(u)
numberdofs!(u)
##
# The restraints of the nodes on the bounding cross-sections in the direction
# of the normal to the plane of the cross-section in the
# circumferential direction are introduced using a penalty formulation.
# For that purpose we introduce a finite element model machine for the
# surface finite elements on the cross-sections.
springcoefficient = 1.0 / ((abs(sigmaA) / 1.0e12) / Ea)
fl = vcat(f1l, f2l)
xsfemm = FEMMDeforWinkler(IntegDomain(subset(bfes, fl), GaussRule(2, 3)))
##
# We create the temperature field using the formula $T=r+z$.
dT = NodalField(
reshape(
sqrt.(fens.xyz[:, 1] .^ 2 + fens.xyz[:, 2] .^ 2) + fens.xyz[:, 3],
size(fens.xyz, 1),
1,
),
)
##
# And we are ready to assemble the system matrix. Both the elastic stiffness of
# the hexahedral elements ...
K = stiffness(femm, geom, u)
# ... and the elastic stiffness of the springs on the contact surfaces of the cross-sections.
H = surfacenormalspringstiffness(xsfemm, geom, u, springcoefficient, SurfaceNormal(3))
##
# The mechanical loads are computed from the thermal strains.
F = thermalstrainloads(femm, geom, u, dT)
##
# And the solution for the free degrees of freedom is obtained.
u = solve_blocked!(u, K + H, F)
##
# The stress is recovered from the stress calculated at the
# integration points.
fld = fieldfromintegpoints(femm, geom, u, dT, :Cauchy, 3)
##
# Now that we have the nodal field for the axial stress, we can plot
# the axial stress painted on the deformed geometry.
File = "LE11NAFEMS_H20_sigmaz.vtk"
vtkexportmesh(
File,
fens,
fes;
scalars = [("sigmaz", fld.values)],
vectors = [("u", u.values)],
)
@async run(`"paraview.exe" $File`)
# File = "LE11NAFEMS_H20_dT.vtk"
# vtkexportmesh(File, fens, fes; scalars=dT.values,scalars_name ="dT", vectors=u.values,vectors_name="u")
##
# The computed stress at the node that is located at the point A is
# going to be now extracted from the nodal field for the stress.
# Nodes at level Z=0.0
l1 = selectnode(fens, box = FFlt[-Inf Inf -Inf Inf 0.0 0.0], inflate = tolerance)
l2 = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = FFlt[0.0 0.0 0.0],
inflate = tolerance,
)
nA = intersect(l1, l2)
sA = mean(fld.values[nA]) / phun("MEGA*Pa")
sAn = mean(fld.values[nA]) / sigmaA
println("Stress at point A: $(sA) i. e. $( sAn*100 )% of reference value")
## Discussion
#
##
# The 3-D solution corresponds well to the 2-D axially symmetric model.
# We also see good correspondence to other published solutions for
# comparable finite element models. For instance, Abaqus 6.11
# Benchmark manual lists very similar numbers.
end # LE11NAFEMS_H20
function allrun()
println("#####################################################")
println("# LE11NAFEMS_H20 ")
LE11NAFEMS_H20()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 42097 | module LE1NAFEMS_examples
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtools.MeshExportModule
using FinEtools.MeshImportModule: import_ABAQUS
using Statistics: mean
using LinearAlgebra: Symmetric, cholesky, norm
# function LE1NAFEMS_compare_meshes()
# Thick0 = 0.1*phun("m")/2.0 # to account for the symmetry reduction
# ref = 0
# Thickness = Thick0
# tolerance = Thickness/2^ref/300.; # Geometrical tolerance
# fens,fes = T10block(1.0, pi/2, Thickness, 2^ref*5, 2^ref*6, 1; orientation = :b)
# for i=1:count(fens)
# t=fens.xyz[i,1]; a=fens.xyz[i,2]; z=fens.xyz[i,3]
# fens.xyz[i,:]=[(t*3.25+(1-t)*2)*cos(a), (t*2.75+(1-t)*1)*sin(a), z];
# end
# println("$((count(fens), count(fes)))")
# output = import_ABAQUS("LE1AbaqusExport-C3D10HS-5-6-1.inp")
# fens1, fes1 = output["fens"], output["fesets"][1]
# println("$((count(fens1), count(fes1[1])))")
# fens, newfes1, fes2 = mergemeshes(fens,fes, fens1,fes1[1], tolerance)
# # fes = cat(fes2, newfes1)
# # println("$((count(fens), count(fes)))")
# File = "a1.vtk"
# vtkexportmesh(File, newfes1.conn, fens.xyz,
# FinEtools.MeshExportModule.T10)
# @async run(`"paraview.exe" $File`)
# File = "a2.vtk"
# vtkexportmesh(File, fes2.conn, fens.xyz,
# FinEtools.MeshExportModule.T10)
# @async run(`"paraview.exe" $File`)
# #
# # fens,fes = H8block(1.0, pi/2, Thickness, 2^ref*5, 2^ref*6, 1)
# # for i=1:count(fens)
# # t=fens.xyz[i,1]; a=fens.xyz[i,2]; z=fens.xyz[i,3]
# # fens.xyz[i,:]=[(t*3.25+(1-t)*2)*cos(a), (t*2.75+(1-t)*1)*sin(a), z];
# # end
# # println("$((count(fens), count(fes)))")
# #
# # fens1,fes1 = import_ABAQUS("LE1AbaqusExport-C3D8S-80-96-1.inp")
# # println("$((count(fens1), count(fes1[1])))")
# #
# # fens, newfes1, fes2 = mergemeshes(fens,fes, fens1,fes1[1], tolerance)
# # fes = cat(fes2, newfes1)
# # println("$((count(fens), count(fes)))")
# #
# # File = "a.vtk"
# # vtkexportmesh(File, fes.conn, fens.xyz,
# # FinEtools.MeshExportModule.H8)
# # @async run(`"paraview.exe" $File`)
# true
# end # LE1NAFEMS_compare_meshes
function LE1NAFEMS_MSH8()
println("LE1NAFEMS, 3D version.")
t0 = time()
E = 210e3 * phun("MEGA*PA")# 210e3 MPa
nu = 0.3
p = 10 * phun("MEGA*PA")# 10 MPA Outward pressure on the outside ellipse
sigma_yD = 92.7 * phun("MEGA*PA")# tensile stress at [2.0, 0.0] meters
Radius = 1.0 * phun("m")
Thickness = 0.1 * phun("m")
n = 2 # number of elements per side
tolerance = 1.0 / n / 1000.0 # Geometrical tolerance
fens, fes = Q4block(1.0, pi / 2, n, n * 2)
fens, fes =
H8extrudeQ4(fens, fes, 1, (xyz, layer) -> [xyz[1], xyz[2], (layer) * Thickness])
bdryfes = meshboundary(fes)
icl = selectelem(
fens,
bdryfes,
box = [1.0, 1.0, 0.0, pi / 2, 0.0, Thickness],
inflate = tolerance,
)
for i = 1:count(fens)
t = fens.xyz[i, 1]
a = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] =
[(t * 3.25 + (1 - t) * 2) * cos(a), (t * 2.75 + (1 - t) * 1) * sin(a), z]
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l1 = selectnode(fens; box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness], inflate = tolerance)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(fens; box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness], inflate = tolerance)
setebc!(u, l1, true, 1, 0.0)
l1 = selectnode(fens; box = [0.0, Inf, 0.0, Inf, 0.0, 0.0], inflate = tolerance)
setebc!(u, l1, true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
el1femm = FEMMBase(IntegDomain(subset(bdryfes, icl), GaussRule(2, 2)))
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) where {T}
pt = [2.75 / 3.25 * XYZ[1], 3.25 / 2.75 * XYZ[2], 0.0]
forceout .= vec(p * pt / norm(pt))
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(el1femm, geom, u, fi, 2)
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the fully three-dimensional solid.
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K, F2)
nl = selectnode(fens, box = [2.0, 2.0, 0.0, 0.0, 0.0, 0.0], inflate = tolerance)
thecorneru = zeros(FFlt, 1, 3)
gathervalues_asmat!(u, thecorneru, nl)
thecorneru = thecorneru / phun("mm")
println(
"$(time()-t0) [s]; displacement =$(thecorneru) [MM] as compared to reference [-0.10215,0] [MM]",
)
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = :meanonly,
)
println(
"Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yD = $(sigma_yD/phun("MPa")) [MPa]",
)
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = :extrapmean,
)
println(
"Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yD = $(sigma_yD/phun("MPa")) [MPa]",
)
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = :extraptrend,
)
println(
"Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yD = $(sigma_yD/phun("MPa")) [MPa]",
)
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :invdistance,
reportat = :meanonly,
)
println(
"Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yD = $(sigma_yD/phun("MPa")) [MPa]",
)
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = :extrapmean,
)
println(
"Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yD = $(sigma_yD/phun("MPa")) [MPa]",
)
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = :extraptrend,
)
println(
"Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yD = $(sigma_yD/phun("MPa")) [MPa]",
)
println("$(n), $(fld.values[nl,1][1]/phun("MPa"))")
File = "a.vtk"
vtkexportmesh(
File,
fes.conn,
geom.values,
FinEtools.MeshExportModule.VTK.H8;
vectors = [("u", u.values)],
scalars = [("sigmay", fld.values)],
)
@async run(`"paraview.exe" $File`)
true
end # LE1NAFEMS_MSH8
function LE1NAFEMS_MSH8_convergence()
# Example from the "Improved Stress Recovery for Mean-strain Finite Elements" paper by Sivapuram and Krysl, 2017
println("LE1NAFEMS, 3D version. MSH8")
t0 = time()
E = 210e3 * phun("MEGA*PA")# 210e3 MPa
nu = 0.3
p = 10 * phun("MEGA*PA")# 10 MPA Outward pressure on the outside ellipse
sigma_yD = 92.7 * phun("MEGA*PA")# tensile stress at [2.0, 0.0] meters
Thick0 = 0.1 * phun("m") / 2.0 # to account for the symmetry reduction
sigyderrs = Dict{Symbol,FFltVec}()
nnodes = []
for extrapolation in [:extraptrend :extrapmean]
sigyderrs[extrapolation] = FFltVec[]
nnodes = []
for ref = 0:1:4
# Thickness = Thick0
Thickness = Thick0 / 2^ref
tolerance = Thickness / 2^ref / 1000.0 # Geometrical tolerance
fens, fes = H8block(1.0, pi / 2, Thickness, 2^ref * 5, 2^ref * 6, 1)
bdryfes = meshboundary(fes)
icl = selectelem(
fens,
bdryfes,
box = [1.0, 1.0, 0.0, pi / 2, 0.0, Thickness],
inflate = tolerance,
)
for i = 1:count(fens)
t = fens.xyz[i, 1]
a = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] = [
(t * 3.25 + (1 - t) * 2) * cos(a),
(t * 2.75 + (1 - t) * 1) * sin(a),
z,
]
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l1 = selectnode(
fens;
box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(
fens;
box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 1, 0.0)
l1 = selectnode(fens; box = [0.0, Inf, 0.0, Inf, 0.0, 0.0], inflate = tolerance)
setebc!(u, l1, true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
el1femm = FEMMBase(IntegDomain(subset(bdryfes, icl), GaussRule(2, 2)))
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) where {T}
pt = [2.75 / 3.25 * XYZ[1], 3.25 / 2.75 * XYZ[2], 0.0]
forceout .= vec(p * pt / norm(pt))
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(el1femm, geom, u, fi, 2)
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the fully three-dimensional solid.
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K, F2)
nl = selectnode(
fens,
box = [2.0, 2.0, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
thecorneru = zeros(FFlt, length(nl), 3)
gathervalues_asmat!(u, thecorneru, nl)
thecorneru = mean(thecorneru, dims = 1)[1] / phun("mm")
println("displacement =$(thecorneru) vs -0.10215 [MM]")
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = extrapolation,
)
sigyd = mean(fld.values[nl, 1], dims = 1)[1]
println("Sigma_y =$(sigyd/phun("MPa")) vs $(sigma_yD/phun("MPa")) [MPa]")
println("$extrapolation, $(count(fes)), $(sigyd/phun("MPa"))")
push!(nnodes, count(fes))
push!(sigyderrs[extrapolation], (sigyd / sigma_yD - 1.0))
# File = "a.vtk"
# vtkexportmesh(File, fes.conn, geom.values,
# FinEtools.MeshExportModule.H8; vectors=[("u", u.values)],
# scalars=[("sigmay", fld.values)])
# @async run(`"paraview.exe" $File`)
end
end
File = "LE1NAFEMS_MSH8_convergence.CSV"
savecsv(
File,
nnodes = vec(nnodes),
sigyderrtrend = vec(sigyderrs[:extraptrend]),
sigyderrmean = vec(sigyderrs[:extrapmean]),
)
end # LE1NAFEMS_MSH8_convergence
function LE1NAFEMS_MSH8_export()
println("LE1NAFEMS, 3D version.")
t0 = time()
E = 210e3 * phun("MEGA*PA")# 210e3 MPa
nu = 0.3
p = 10 * phun("MEGA*PA")# 10 MPA Outward pressure on the outside ellipse
sigma_yD = 92.7 * phun("MEGA*PA")# tensile stress at [2.0, 0.0] meters
Radius = 1.0 * phun("m")
Thickness = 0.1 * phun("m")
n = 64 # number of elements per side
tolerance = 1.0 / n / 1000.0 # Geometrical tolerance
fens, fes = Q4block(1.0, pi / 2, n, n * 2)
fens, fes =
H8extrudeQ4(fens, fes, 1, (xyz, layer) -> [xyz[1], xyz[2], (layer) * Thickness])
bdryfes = meshboundary(fes)
icl = selectelem(
fens,
bdryfes,
box = [1.0, 1.0, 0.0, pi / 2, 0.0, Thickness],
inflate = tolerance,
)
for i = 1:count(fens)
t = fens.xyz[i, 1]
a = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] =
[(t * 3.25 + (1 - t) * 2) * cos(a), (t * 2.75 + (1 - t) * 1) * sin(a), z]
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l1 = selectnode(fens; box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness], inflate = tolerance)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(fens; box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness], inflate = tolerance)
setebc!(u, l1, true, 1, 0.0)
l1 = selectnode(fens; box = [0.0, Inf, 0.0, Inf, 0.0, 0.0], inflate = tolerance)
setebc!(u, l1, true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
el1femm = FEMMBase(IntegDomain(subset(bdryfes, icl), GaussRule(2, 2)))
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) where {T}
pt = [2.75 / 3.25 * XYZ[1], 3.25 / 2.75 * XYZ[2], 0.0]
forceout .= vec(p * pt / norm(pt))
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(el1femm, geom, u, fi, 2)
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the fully three-dimensional solid.
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K, F2)
nl = selectnode(fens, box = [2.0, 2.0, 0.0, 0.0, 0.0, 0.0], inflate = tolerance)
thecorneru = zeros(FFlt, 1, 3)
gathervalues_asmat!(u, thecorneru, nl)
thecorneru = thecorneru / phun("mm")
println(
"$(time()-t0) [s]; displacement =$(thecorneru) [MM] as compared to reference [-0.10215,0] [MM]",
)
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = :extraptrend,
)
println(
"Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yD = $(sigma_yD/phun("MPa")) [MPa]",
)
println("$(n), $(fld.values[nl,1][1]/phun("MPa"))")
File = "a.vtk"
vtkexportmesh(
File,
fes.conn,
geom.values,
FinEtools.MeshExportModule.VTK.H8;
vectors = [("u", u.values)],
scalars = [("sigmay", fld.values)],
)
@async run(`"paraview.exe" $File`)
true
end # LE1NAFEMS_MSH8_export
function LE1NAFEMS_MST10_convergence()
# Example from the "Improved Stress Recovery for Mean-strain Finite Elements" paper by Sivapuram and Krysl, 2017
println("LE1NAFEMS, 3D version. MST10")
t0 = time()
E = 210e3 * phun("MEGA*PA")# 210e3 MPa
nu = 0.3
p = 10 * phun("MEGA*PA")# 10 MPA Outward pressure on the outside ellipse
sigma_yD = 92.7 * phun("MEGA*PA")# tensile stress at [2.0, 0.0] meters
Thick0 = 0.1 * phun("m") / 2.0 # to account for the symmetry reduction
sigyderrs = Dict{Symbol,FFltVec}()
nnodes = []
for extrapolation in [:extraptrend :extrapmean]
sigyderrs[extrapolation] = FFltVec[]
nnodes = []
for ref = 0:1:4
# Thickness = Thick0
Thickness = Thick0 / 2^ref
tolerance = Thickness / 2^ref / 1000.0 # Geometrical tolerance
fens, fes =
T10block(1.0, pi / 2, Thickness, 2^ref * 5, 2^ref * 6, 1; orientation = :b)
bdryfes = meshboundary(fes)
icl = selectelem(
fens,
bdryfes,
box = [1.0, 1.0, 0.0, pi / 2, 0.0, Thickness],
inflate = tolerance,
)
for i = 1:count(fens)
t = fens.xyz[i, 1]
a = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] = [
(t * 3.25 + (1 - t) * 2) * cos(a),
(t * 2.75 + (1 - t) * 1) * sin(a),
z,
]
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l1 = selectnode(
fens;
box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(
fens;
box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 1, 0.0)
l1 = selectnode(fens; box = [0.0, Inf, 0.0, Inf, 0.0, 0.0], inflate = tolerance)
setebc!(u, l1, true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
el1femm = FEMMBase(IntegDomain(subset(bdryfes, icl), TriRule(3)))
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) where {T}
pt = [2.75 / 3.25 * XYZ[1], 3.25 / 2.75 * XYZ[2], 0.0]
forceout .= vec(p * pt / norm(pt))
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(el1femm, geom, u, fi, 2)
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the fully three-dimensional solid.
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMST10(MR, IntegDomain(fes, TetRule(4)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K, F2)
nl = selectnode(
fens,
box = [2.0, 2.0, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
thecorneru = zeros(FFlt, length(nl), 3)
gathervalues_asmat!(u, thecorneru, nl)
thecorneru = mean(thecorneru, dims = 1)[1] / phun("mm")
println("displacement =$(thecorneru) vs -0.10215 [MM]")
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = extrapolation,
)
sigyd = mean(fld.values[nl, 1], dims = 1)[1]
println("Sigma_y =$(sigyd/phun("MPa")) vs $(sigma_yD/phun("MPa")) [MPa]")
println("$extrapolation, $(count(fes)), $(sigyd/phun("MPa"))")
push!(nnodes, count(fens))
push!(sigyderrs[extrapolation], abs(sigyd / sigma_yD - 1.0))
# File = "a.vtk"
# vtkexportmesh(File, fes.conn, geom.values,
# FinEtools.MeshExportModule.H8; vectors=[("u", u.values)],
# scalars=[("sigmay", fld.values)])
# @async run(`"paraview.exe" $File`)
end
end
File = "LE1NAFEMS_MST10_convergence.CSV"
savecsv(
File,
nnodes = vec(nnodes),
sigyderrtrend = vec(sigyderrs[:extraptrend]),
sigyderrdefault = vec(sigyderrs[:extrapmean]),
)
end # LE1NAFEMS_MST10_convergence
function LE1NAFEMS_MST10_one()
println("LE1NAFEMS, 3D version.")
t0 = time()
E = 210e3 * phun("MEGA*PA")# 210e3 MPa
nu = 0.3
p = 10 * phun("MEGA*PA")# 10 MPA Outward pressure on the outside ellipse
sigma_yD = 92.7 * phun("MEGA*PA")# tensile stress at [2.0, 0.0] meters
Thick0 = 0.1 * phun("m") / 2.0 # to account for the symmetry reduction
sigyderrs = Dict{Symbol,FFltVec}()
for extrapolation in [:extraptrend]
sigyderrs[extrapolation] = FFltVec[]
nnodes = []
for ref = 1:1
Thickness = Thick0
# Thickness = Thick0/2^ref
tolerance = Thickness / 2^ref / 1000.0 # Geometrical tolerance
fens, fes =
T10block(1.0, pi / 2, Thickness, 2^ref * 5, 2^ref * 6, 1; orientation = :b)
bdryfes = meshboundary(fes)
icl = selectelem(
fens,
bdryfes,
box = [1.0, 1.0, 0.0, pi / 2, 0.0, Thickness],
inflate = tolerance,
)
for i = 1:count(fens)
t = fens.xyz[i, 1]
a = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] = [
(t * 3.25 + (1 - t) * 2) * cos(a),
(t * 2.75 + (1 - t) * 1) * sin(a),
z,
]
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l1 = selectnode(
fens;
box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(
fens;
box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 1, 0.0)
l1 = selectnode(fens; box = [0.0, Inf, 0.0, Inf, 0.0, 0.0], inflate = tolerance)
setebc!(u, l1, true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
el1femm = FEMMBase(IntegDomain(subset(bdryfes, icl), TriRule(3)))
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) where {T}
pt = [2.75 / 3.25 * XYZ[1], 3.25 / 2.75 * XYZ[2], 0.0]
forceout .= vec(p * pt / norm(pt))
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(el1femm, geom, u, fi, 2)
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the fully three-dimensional solid.
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMST10(MR, IntegDomain(fes, TetRule(4)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K, F2)
nl = selectnode(
fens,
box = [2.0, 2.0, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
thecorneru = zeros(FFlt, length(nl), 3)
gathervalues_asmat!(u, thecorneru, nl)
thecorneru = mean(thecorneru, dims = 1)[1] / phun("mm")
println("displacement =$(thecorneru) vs -0.10215 [MM]")
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = extrapolation,
)
sigyd = mean(fld.values[nl, 1], dims = 1)[1]
println("Sigma_y =$(sigyd/phun("MPa")) vs $(sigma_yD/phun("MPa")) [MPa]")
println("$extrapolation, $(count(fes)), $(sigyd/phun("MPa"))")
push!(nnodes, count(fens))
push!(sigyderrs[extrapolation], abs(sigyd / sigma_yD - 1.0))
File = "LE1NAFEMS_MST10_a.vtk"
vtkexportmesh(
File,
fes.conn,
geom.values,
FinEtools.MeshExportModule.VTK.T10;
vectors = [("u", u.values)],
scalars = [("sigmay", fld.values)],
)
@async run(`"paraview.exe" $File`)
end
end
#
#
# using DataFrames
# using CSV
#
# df = DataFrame(nnodes=vec(nnodes),
# sigyderrtrend=vec(sigyderrs[:extraptrend]),
# sigyderrdefault=vec(sigyderrs[:extrapmean]))
# File = "LE1NAFEMS_MST10_convergence.CSV"
# CSV.write(File, df)
# @async run(`"paraview.exe" $File`)
end # LE1NAFEMS_MST10_one
# using SymPy
# function LE1NAFEMS_MST10_single()
# @vars ua ub uc ud
# @vars va vb vc vd
# @vars wa wb wc wd
# @vars x y z
# u(x, y, z) = ua*x + ub*y + uc*z + ud
# v(x, y, z) = va*x + vb*y + vc*z + vd
# w(x, y, z) = wa*x + wb*y + wc*z + wd
# ex = diff(u(x, y, z), x)
# ey = diff(v(x, y, z), y)
# ez = diff(w(x, y, z), z)
# gxy = diff(v(x, y, z), x) + diff(u(x, y, z), y)
# gxz = diff(w(x, y, z), x) + diff(u(x, y, z), z)
# gyz = diff(w(x, y, z), y) + diff(v(x, y, z), z)
# display(ex)
# display(ey)
# display(ez)
# display(gxy)
# display(gxz)
# display(gyz)
# end # LE1NAFEMS_MST10_single
function LE1NAFEMS_MST10_stresses_nodal()
elementtag = "MST10"
println("LE1NAFEMS, 3D version. Element: $(elementtag)")
E = 210e3 * phun("MEGA*PA")# 210e3 MPa
nu = 0.3
p = 10 * phun("MEGA*PA")# 10 MPA Outward pressure on the outside ellipse
sigma_yD = 92.7 * phun("MEGA*PA")# tensile stress at [2.0, 0.0] meters
Thick0 = 0.1 * phun("m") / 2.0 # to account for the symmetry reduction
for extrapolation in [:extraptrend :extrapmean]
convergencestudy = FDataDict[]
for ref in [0, 1, 2, 3, 4]
Thickness = Thick0
tolerance = Thickness / 2^ref / 1000.0 # Geometrical tolerance
fens, fes =
T10block(1.0, pi / 2, Thickness, 2^ref * 2, 2^ref * 3, 1; orientation = :b)
bdryfes = meshboundary(fes)
icl = selectelem(
fens,
bdryfes,
box = [1.0, 1.0, 0.0, pi / 2, 0.0, Thickness],
inflate = tolerance,
)
for i = 1:count(fens)
t = fens.xyz[i, 1]
a = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] = [
(t * 3.25 + (1 - t) * 2) * cos(a),
(t * 2.75 + (1 - t) * 1) * sin(a),
z,
]
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l1 = selectnode(
fens;
box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(
fens;
box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 1, 0.0)
l1 = selectnode(fens; box = [0.0, Inf, 0.0, Inf, 0.0, 0.0], inflate = tolerance)
setebc!(u, l1, true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
el1femm = FEMMBase(IntegDomain(subset(bdryfes, icl), TriRule(3)))
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) where {T}
pt = [2.75 / 3.25 * XYZ[1], 3.25 / 2.75 * XYZ[2], 0.0]
forceout .= vec(p * pt / norm(pt))
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(el1femm, geom, u, fi, 2)
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the fully three-dimensional solid.
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMST10(MR, IntegDomain(fes, TetRule(4)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K, F2)
nl = selectnode(
fens,
box = [2.0, 2.0, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
thecorneru = zeros(FFlt, length(nl), 3)
gathervalues_asmat!(u, thecorneru, nl)
thecorneru = mean(thecorneru, dims = 1)[1] / phun("mm")
println("displacement =$(thecorneru) vs -0.10215 [MM]")
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = extrapolation,
)
sigyd = mean(fld.values[nl, 1], dims = 1)[1]
println("Sigma_y =$(sigyd/phun("MPa")) vs $(sigma_yD/phun("MPa")) [MPa]")
stressfield = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
collect(1:6);
nodevalmethod = :averaging,
reportat = extrapolation,
)
# File = "LE1NAFEMS_MST10_sigma.vtk"
# vtkexportmesh(File, fes.conn, geom.values,
# FinEtools.MeshExportModule.T10; vectors=[("u", u.values)],
# scalars=[("sig", stressfield.values)])
# @async run(`"paraview.exe" $File`)
push!(
convergencestudy,
FDataDict(
"elementsize" => 1.0 / (2^ref),
"fens" => fens,
"fes" => fes,
"geom" => geom,
"u" => u,
"femm" => femm,
"integrationrule" => femm.integdomain.integration_rule,
"stressfields" => [stressfield],
"tolerance" => tolerance,
),
)
end # for ref
# File = "LE1NAFEMS_MST10_stresses_nodal_convergence_$(elementtag)_$(extrapolation)"
# open(File * ".jls", "w") do file
# serialize(file, convergencestudy)
# end
end # for extrapolation
end # LE1NAFEMS_MST10_stresses_nodal
function LE1NAFEMS_MST10_S_convergence()
println("LE1NAFEMS, 3D version.")
t0 = time()
E = 210e3 * phun("MEGA*PA")# 210e3 MPa
nu = 0.3
p = 10 * phun("MEGA*PA")# 10 MPA Outward pressure on the outside ellipse
sigma_yD = 92.7 * phun("MEGA*PA")# tensile stress at [2.0, 0.0] meters
Thick0 = 0.1 * phun("m") / 2.0 # to account for the symmetry reduction
sigyderrs = Dict{Symbol,FFltVec}()
nnodes = []
for extrapolation in [:extraptrend :extrapmean]
sigyderrs[extrapolation] = FFltVec[]
nnodes = []
for ref = 0:1:4
Thickness = Thick0
# Thickness = Thick0/2^ref
tolerance = Thickness / 2^ref / 1000.0 # Geometrical tolerance
fens, fes = T4block(1.0, pi / 2, Thickness, 2^ref * 5, 2^ref * 6, 1)
bdryfes = meshboundary(fes)
icl = selectelem(
fens,
bdryfes,
box = [1.0, 1.0, 0.0, pi / 2, 0.0, Thickness],
inflate = tolerance,
)
for i = 1:count(fens)
t = fens.xyz[i, 1]
a = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] = [
(t * 3.25 + (1 - t) * 2) * cos(a),
(t * 2.75 + (1 - t) * 1) * sin(a),
z,
]
end
fens, fes = T4toT10(fens, fes)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l1 = selectnode(
fens;
box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(
fens;
box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 1, 0.0)
l1 = selectnode(fens; box = [0.0, Inf, 0.0, Inf, 0.0, 0.0], inflate = tolerance)
setebc!(u, l1, true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
el1femm = FEMMBase(IntegDomain(subset(bdryfes, icl), TriRule(3)))
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) where {T}
pt = [2.75 / 3.25 * XYZ[1], 3.25 / 2.75 * XYZ[2], 0.0]
forceout .= vec(p * pt / norm(pt))
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(el1femm, geom, u, fi, 2)
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the fully three-dimensional solid.
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMST10(MR, IntegDomain(fes, TetRule(4)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K, F2)
nl = selectnode(
fens,
box = [2.0, 2.0, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
thecorneru = zeros(FFlt, length(nl), 3)
gathervalues_asmat!(u, thecorneru, nl)
thecorneru = mean(thecorneru, dims = 1)[1] / phun("mm")
println("displacement =$(thecorneru) vs -0.10215 [MM]")
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = extrapolation,
)
sigyd = mean(fld.values[nl, 1], dims = 1)[1]
println("Sigma_y =$(sigyd/phun("MPa")) vs $(sigma_yD/phun("MPa")) [MPa]")
println("$extrapolation, $(count(fes)), $(sigyd/phun("MPa"))")
push!(nnodes, count(fens))
push!(sigyderrs[extrapolation], abs(sigyd / sigma_yD - 1.0))
# File = "a.vtk"
# vtkexportmesh(File, fes.conn, geom.values,
# FinEtools.MeshExportModule.H8; vectors=[("u", u.values)],
# scalars=[("sigmay", fld.values)])
# @async run(`"paraview.exe" $File`)
end
end
File = "LE1NAFEMS_MST10_S_convergence.CSV"
savecsv(
File,
nnodes = vec(nnodes),
sigyderrtrend = vec(sigyderrs[:extraptrend]),
sigyderrdefault = vec(sigyderrs[:extrapmean]),
)
end # LE1NAFEMS_MST10_S_convergence
function LE1NAFEMS_T10_stresses_nodal()
elementtag = "T10"
println("LE1NAFEMS, 3D version. Element: $(elementtag)")
E = 210e3 * phun("MEGA*PA")# 210e3 MPa
nu = 0.3
p = 10 * phun("MEGA*PA")# 10 MPA Outward pressure on the outside ellipse
sigma_yD = 92.7 * phun("MEGA*PA")# tensile stress at [2.0, 0.0] meters
Thick0 = 0.1 * phun("m") / 2.0 # to account for the symmetry reduction
convergencestudy = FDataDict[]
for ref in [0, 1, 2, 3, 4]
Thickness = Thick0
tolerance = Thickness / 2^ref / 1000.0 # Geometrical tolerance
fens, fes =
T10block(1.0, pi / 2, Thickness, 2^ref * 2, 2^ref * 3, 1; orientation = :b)
bdryfes = meshboundary(fes)
icl = selectelem(
fens,
bdryfes,
box = [1.0, 1.0, 0.0, pi / 2, 0.0, Thickness],
inflate = tolerance,
)
for i = 1:count(fens)
t = fens.xyz[i, 1]
a = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] =
[(t * 3.25 + (1 - t) * 2) * cos(a), (t * 2.75 + (1 - t) * 1) * sin(a), z]
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l1 = selectnode(
fens;
box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(
fens;
box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 1, 0.0)
l1 = selectnode(fens; box = [0.0, Inf, 0.0, Inf, 0.0, 0.0], inflate = tolerance)
setebc!(u, l1, true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
el1femm = FEMMBase(IntegDomain(subset(bdryfes, icl), TriRule(3)))
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) where {T}
pt = [2.75 / 3.25 * XYZ[1], 3.25 / 2.75 * XYZ[2], 0.0]
forceout .= vec(p * pt / norm(pt))
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(el1femm, geom, u, fi, 2)
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the fully three-dimensional solid.
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinear(MR, IntegDomain(fes, TetRule(4)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K, F2)
nl = selectnode(
fens,
box = [2.0, 2.0, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
thecorneru = zeros(FFlt, length(nl), 3)
gathervalues_asmat!(u, thecorneru, nl)
thecorneru = mean(thecorneru, dims = 1)[1] / phun("mm")
println("displacement =$(thecorneru) vs -0.10215 [MM]")
fld = fieldfromintegpoints(femm, geom, u, :Cauchy, 2)
sigyd = mean(fld.values[nl, 1], dims = 1)[1]
println("Sigma_y =$(sigyd/phun("MPa")) vs $(sigma_yD/phun("MPa")) [MPa]")
stressfield = fieldfromintegpoints(femm, geom, u, :Cauchy, collect(1:6))
# File = "LE1NAFEMS_T10_sigma.vtk"
# vtkexportmesh(File, fes.conn, geom.values,
# FinEtools.MeshExportModule.T10; vectors=[("u", u.values)],
# scalars=[("sig", stressfield.values)])
# @async run(`"paraview.exe" $File`)
push!(
convergencestudy,
FDataDict(
"elementsize" => 1.0 / (2^ref),
"fens" => fens,
"fes" => fes,
"geom" => geom,
"u" => u,
"femm" => femm,
"integrationrule" => femm.integdomain.integration_rule,
"stressfields" => [stressfield],
"tolerance" => tolerance,
),
)
end # for ref
# File = "LE1NAFEMS_T10_stresses_nodal_convergence_$(elementtag)"
# open(File * ".jls", "w") do file
# serialize(file, convergencestudy)
# end
end # LE1NAFEMS_T10_stresses_nodal
function allrun()
println("#####################################################")
println("# LE1NAFEMS_MSH8 ")
LE1NAFEMS_MSH8()
println("#####################################################")
println("# LE1NAFEMS_MSH8_convergence ")
LE1NAFEMS_MSH8_convergence()
println("#####################################################")
println("# LE1NAFEMS_MSH8_export ")
LE1NAFEMS_MSH8_export()
println("#####################################################")
println("# LE1NAFEMS_MST10_convergence ")
LE1NAFEMS_MST10_convergence()
println("#####################################################")
println("# LE1NAFEMS_MST10_one ")
LE1NAFEMS_MST10_one()
# println("#####################################################")
# println("# LE1NAFEMS_MST10_single ")
# LE1NAFEMS_MST10_single()
println("#####################################################")
println("# LE1NAFEMS_MST10_stresses_nodal ")
LE1NAFEMS_MST10_stresses_nodal()
println("#####################################################")
println("# LE1NAFEMS_MST10_S_convergence ")
LE1NAFEMS_MST10_S_convergence()
println("#####################################################")
println("# LE1NAFEMS_T10_stresses_nodal ")
LE1NAFEMS_T10_stresses_nodal()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 1097 | using Gaston
# using PyCall
using DelimitedFiles
function loadcsv(inputcsv)
contents = readdlm(inputcsv, ',', Float64, '\n'; header = true)
return contents
end
function coldata(inputcsv, theset)
contents = loadcsv(inputcsv)
return contents[1][:, theset]
end
set(
axis = "loglog",
plotstyle = "linespoints",
linewidth = 2,
pointsize = 2,
color = "black",
xlabel = "Number of nodes",
ylabel = "Relative error",
grid = "on",
title = "",
)
inputcsv = "LE1NAFEMS_MSH8_convergence.CSV"
x = coldata(inputcsv, 1)
y = coldata(inputcsv, 3)
plot(x, abs.(y), legend = "MSOE", marker = "edmd")
inputcsv = "LE1NAFEMS_MSH8_convergence.CSV"
x = coldata(inputcsv, 1)
y = coldata(inputcsv, 2)
plot!(x, abs.(y), legend = "TBE", marker = "ecircle")
# inputcsv = "LE1NAFEMS_MST10_convergence.CSV"
# x = coldata(inputcsv, 1)
# y = coldata(inputcsv, 3)
# plot(x, abs.(y), legend = "MSOE", marker = "edmd")
# inputcsv = "LE1NAFEMS_MST10_convergence.CSV"
# x = coldata(inputcsv, 1)
# y = coldata(inputcsv, 2)
# plot!(x, abs.(y), legend="TBE", marker = "ecircle")
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 91407 | module Meyer_Piening_examples
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtools.MeshUtilModule
function Meyer_Piening_sandwich()
println("""
Meyer-Piening sandwich plate
""")
# Reference results from:
# [1] Application of the Elasticity Solution
# to Linear Sandwich Beam, Plate
# and Shell Analyses
# H.-R. MEYER -PIENING
# Journal of SANDWICH STRUCTURES AND MATERIALS , Vol. 6—July 2004
# Assessment of the refined sinus plate finite element:
# Free edge effect and Meyer-Piening sandwich test
# P. Vidal, O. Polit, M. D'Ottavio, E. Valot
# http://dx.doi.org/10.1016/j.finel.2014.08.004
#
# The second study deals with a benchmark problem proposed
# by Meyer-Piening [14]. It involves a simply -supported rectangular
# sandwich plate submitted to a localized pressure applied on an
# area of 5x20 mm. The geometry of the sandwich structure is
# given in Fig.13. Due to the symmetry, only one quarter of the plate
# is meshed. The faces have different thicknesses: h = 0.5 mm
# (bottom face), h = 0.1 mm (top face). The thickness of the core
# is h = 11.4 mm. The material properties are given in Table 3.
# Note that this benchmark involves strong heterogeneities (very
# different geometric and constitutive properties between core and
# face) and local stress gradient due to the localized pressure load.
#
# [14] H.-R. Meyer-Piening, Experiences with exact linear sandwich beam and plate
# analyses regarding bending, instability and frequency investigations, in:
# Proceedings of the Fifth International Conference On Sandwich Constructions,
# September 5–7, vol. I, Zurich, Switzerland, 2000, pp. 37–48.
t0 = time()
# Orthotropic material for the SKIN
E1s = 70000.0 * phun("MPa")
E2s = 71000.0 * phun("MPa")
E3s = 69000.0 * phun("MPa")
nu12s = nu13s = nu23s = 0.3
G12s = G13s = G23s = 26000.0 * phun("MPa")
CTE1 = CTE2 = CTE3 = 0.0
# Orthotropic material for the CORE
E1c = 3.0 * phun("MPa")
E2c = 3.0 * phun("MPa")
E3c = 2.8 * phun("MPa")
nu12c = nu13c = nu23c = 0.25
G12c = G13c = G23c = 1.0 * phun("MPa")
CTE1 = CTE2 = CTE3 = 0.0
Lx = 5.0 * phun("mm") # length of loaded rectangle
Ly = 20.0 * phun("mm") # length of loaded rectangle
Sx = 100.0 * phun("mm") # span of the plate
Sy = 200.0 * phun("mm") # span of the plate
# Here we define the layout and the thicknesses of the layers.
angles = vec([0.0 0.0 0.0])
ts = vec([0.5 11.4 0.1]) * phun("mm") # layer thicknesses
TH = sum(ts) # total thickness of the plate
tolerance = 0.0001 * TH
# The line load is in the negative Z direction.
q0 = 1 * phun("MPa") # line load
# Reference deflection under the load is
wtopref = -3.789 * phun("mm") # From [1]
wbottomref = -2.16 * phun("mm") # Not given in [1]; guessed from the figure
# Select how find the mesh should be
Refinement = 5
nL = Refinement * 1
nSx = nL + Refinement * 4
nSy = 2 * nSx
# Each layer is modeled with a single element.
nts = Refinement * [1, 2, 1]# number of elements per layer
strength = 1.5
xs = unique(
vcat(
reverse(collect(MeshUtilModule.gradedspace(Lx / 2, 0.0, nL + 1, strength))),
collect(MeshUtilModule.gradedspace(Lx / 2, Sx / 2, nSx - nL + 1, strength)),
),
)
ys = unique(
vcat(
reverse(collect(MeshUtilModule.gradedspace(Ly / 2, 0.0, nL + 1, strength))),
collect(MeshUtilModule.gradedspace(Ly / 2, Sy / 2, nSy - nL + 1, strength)),
),
)
fens, fes = H8layeredplatex(xs, ys, ts, nts)
# This is the material model
MR = DeforModelRed3D
skinmaterial = MatDeforElastOrtho(
MR,
0.0,
E1s,
E2s,
E3s,
nu12s,
nu13s,
nu23s,
G12s,
G13s,
G23s,
CTE1,
CTE2,
CTE3,
)
corematerial = MatDeforElastOrtho(
MR,
0.0,
E1c,
E2c,
E3c,
nu12c,
nu13c,
nu23c,
G12c,
G13c,
G23c,
CTE1,
CTE2,
CTE3,
)
# The material coordinate system function is defined as:
function _updatecs!(csmatout::FFltMat, feid::FInt, label)
rotmat3!(csmatout, angles[label] / 180.0 * pi * [0.0; 0.0; 1.0])
csmatout
end
# The vvolume integrals are evaluated using this rule
gr = GaussRule(3, 2)
# We will create three regions, two for the skin, and one for the core.
rfes = subset(fes, selectelem(fens, fes, label = 1))
botskinregion = FDataDict(
"femm" => FEMMDeforLinearMSH8(
MR,
IntegDomain(rfes, gr),
CSys(
3,
3,
(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) -> _updatecs!(csmatout, feid, 1),
),
skinmaterial,
),
)
rfes = subset(fes, selectelem(fens, fes, label = 3))
topskinregion = FDataDict(
"femm" => FEMMDeforLinearMSH8(
MR,
IntegDomain(rfes, gr),
CSys(
3,
3,
(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) -> _updatecs!(csmatout, feid, 3),
),
skinmaterial,
),
)
rfes = subset(fes, selectelem(fens, fes, label = 2))
coreregion = FDataDict(
"femm" => FEMMDeforLinearMSH8(
MR,
IntegDomain(rfes, gr),
CSys(
3,
3,
(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) -> _updatecs!(csmatout, feid, 2),
),
corematerial,
),
)
# File = "Meyer_Piening_sandwich-r1.vtk"
# vtkexportmesh(File, skinregion["femm"].integdomain.fes.conn, fens.xyz, FinEtools.MeshExportModule.H8)
# # @async run(`"paraview.exe" $File`)
# File = "Meyer_Piening_sandwich-r2.vtk"
# vtkexportmesh(File, coreregion["femm"].integdomain.fes.conn, fens.xyz, FinEtools.MeshExportModule.H8)
# @async run(`"paraview.exe" $File`)
# The essential boundary conditions are applied on the symmetry planes.
# First the plane X=0;...
lx0 = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
ex0 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lx0)
# ... and then the plane Y=0.
ly0 = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
ey0 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => ly0)
# The transverse displacement is fixed around the circumference.
lz0 = vcat(
selectnode(fens, box = [Sx / 2 Sx / 2 -Inf Inf -Inf Inf], inflate = tolerance),
selectnode(fens, box = [-Inf Inf Sy / 2 Sy / 2 -Inf Inf], inflate = tolerance),
)
ez0 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lz0)
# The traction boundary condition is applied along rectangle in the middle of the plate.
bfes = meshboundary(fes)
# From the entire boundary we select those quadrilaterals that lie on the plane
# Z = thickness
tl = selectelem(fens, bfes, box = [0.0 Lx / 2 0 Ly / 2 TH TH], inflate = tolerance)
Trac = FDataDict(
"traction_vector" => vec([0.0; 0.0; -q0]),
"femm" => FEMMBase(IntegDomain(subset(bfes, tl), GaussRule(2, 2))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [botskinregion, coreregion, topskinregion],
"essential_bcs" => [ex0, ey0, ez0],
"traction_bcs" => [Trac],
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
modeldata["postprocessing"] = FDataDict("file" => "Meyer_Piening_sandwich")
modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# The results of the displacement and stresses will be reported at
# nodes located at the appropriate points.
nbottomcenter = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 0.0], inflate = tolerance)
ntopcenter = selectnode(fens, box = [0.0 0.0 0.0 0.0 TH TH], inflate = tolerance)
ncenterline = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 TH], inflate = tolerance)
nintertop = selectnode(
fens,
box = [-Inf Inf 0.0 0.0 sum(ts[1:2]) sum(ts[1:2])],
inflate = tolerance,
)
ninterbot = selectnode(
fens,
box = [-Inf Inf 0.0 0.0 sum(ts[1:1]) sum(ts[1:1])],
inflate = tolerance,
)
zclo = sortperm(vec(geom.values[ncenterline, 3]))
centerz = geom.values[ncenterline[zclo], 3]
xclotop = sortperm(vec(geom.values[nintertop, 1]))
topx = geom.values[nintertop[xclotop], 1]
xclobot = sortperm(vec(geom.values[ninterbot, 1]))
botx = geom.values[ninterbot[xclobot], 1]
conninbotskin =
intersect(connectednodes(botskinregion["femm"].integdomain.fes), ncenterline)
connincore = intersect(connectednodes(coreregion["femm"].integdomain.fes), ncenterline)
connintopskin =
intersect(connectednodes(topskinregion["femm"].integdomain.fes), ncenterline)
inbotskin = [n in conninbotskin for n in ncenterline]
incore = [n in connincore for n in ncenterline]
intopskin = [n in connintopskin for n in ncenterline]
println("")
println("Top Center deflection: $(u.values[ntopcenter, 3]/phun("mm")) [mm]")
println("Bottom Center deflection: $(u.values[nbottomcenter, 3]/phun("mm")) [mm]")
# # extrap = :extrapmean
# extrap = :extraptrend
# nodevalmeth = :averaging
extrap = :default
nodevalmeth = :invdistance
# Normal stress in the X direction
modeldata["postprocessing"] = FDataDict(
"file" => "Meyer_Piening_sandwich-sx",
"quantity" => :Cauchy,
"component" => 1,
"outputcsys" => CSys(3),
"nodevalmethod" => nodevalmeth,
"reportat" => extrap,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
s = modeldata["postprocessing"]["exported"][1]["field"]
sxbot = s.values[ncenterline[zclo], 1]
s = modeldata["postprocessing"]["exported"][2]["field"]
sxcore = s.values[ncenterline[zclo], 1]
s = modeldata["postprocessing"]["exported"][3]["field"]
sxtop = s.values[ncenterline[zclo], 1]
# The graph data needs to be collected by going through each layer separately.
# Some quantities may be discontinuous between layers.
zs = vcat(
[z for (j, z) in enumerate(centerz) if inbotskin[j]],
[z for (j, z) in enumerate(centerz) if incore[j]],
[z for (j, z) in enumerate(centerz) if intopskin[j]],
)
sxs = vcat(
[sxbot[j] for (j, z) in enumerate(centerz) if inbotskin[j]],
[sxcore[j] for (j, z) in enumerate(centerz) if incore[j]],
[sxtop[j] for (j, z) in enumerate(centerz) if intopskin[j]],
)
File = "Meyer_Piening_sandwich-sx-$(extrap).CSV"
savecsv(File, zs = vec(zs) / phun("mm"), sx = vec(sxs) / phun("MPa"))
# @async run(`"paraview.exe" $File`)
# Inter laminar stress between the skin and the core
modeldata["postprocessing"] = FDataDict(
"file" => "Meyer_Piening_sandwich-sxz",
"quantity" => :Cauchy,
"component" => 5,
"outputcsys" => CSys(3),
"nodevalmethod" => nodevalmeth,
"reportat" => extrap,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
s = modeldata["postprocessing"]["exported"][1]["field"]
sxzskinbot = s.values[ninterbot[xclobot], 1]
s = modeldata["postprocessing"]["exported"][2]["field"]
sxzcoretop = s.values[nintertop[xclotop], 1]
sxzcorebot = s.values[ninterbot[xclobot], 1]
s = modeldata["postprocessing"]["exported"][3]["field"]
sxzskintop = s.values[nintertop[xclotop], 1]
File = "Meyer_Piening_sandwich-sxz-$(extrap).CSV"
savecsv(
File,
xstop = vec(topx[xclotop]) / phun("mm"),
sxzskintop = vec(sxzskintop[xclotop]) / phun("MPa"),
sxzcoretop = vec(sxzcoretop[xclotop]) / phun("MPa"),
thexsbot = vec(botx[xclobot]) / phun("mm"),
sxzskinbot = vec(sxzskinbot[xclobot]) / phun("MPa"),
sxzcorebot = vec(sxzcorebot[xclobot]) / phun("MPa"),
)
println("Done")
true
end # Meyer_Piening_sandwich
function Meyer_Piening_sandwich_H20()
println("""
Meyer-Piening sandwich plate, serendipity H20
""")
# Reference results from:
# [1] Application of the Elasticity Solution
# to Linear Sandwich Beam, Plate
# and Shell Analyses
# H.-R. MEYER -PIENING
# Journal of SANDWICH STRUCTURES AND MATERIALS , Vol. 6—July 2004
# Assessment of the refined sinus plate finite element:
# Free edge effect and Meyer-Piening sandwich test
# P. Vidal, O. Polit, M. D'Ottavio, E. Valot
# http://dx.doi.org/10.1016/j.finel.2014.08.004
#
# The second study deals with a benchmark problem proposed
# by Meyer-Piening [14]. It involves a simply -supported rectangular
# sandwich plate submitted to a localized pressure applied on an
# area of 5x20 mm. The geometry of the sandwich structure is
# given in Fig.13. Due to the symmetry, only one quarter of the plate
# is meshed. The faces have different thicknesses: h = 0.5 mm
# (bottom face), h = 0.1 mm (top face). The thickness of the core
# is h = 11.4 mm. The material properties are given in Table 3.
# Note that this benchmark involves strong heterogeneities (very
# different geometric and constitutive properties between core and
# face) and local stress gradient due to the localized pressure load.
#
# [14] H.-R. Meyer-Piening, Experiences with exact linear sandwich beam and plate
# analyses regarding bending, instability and frequency investigations, in:
# Proceedings of the Fifth International Conference On Sandwich Constructions,
# September 5–7, vol. I, Zurich, Switzerland, 2000, pp. 37–48.
filebase = "Meyer-Piening-sandwich-H20"
t0 = time()
# Orthotropic material for the SKIN
E1s = 70000.0 * phun("MPa")
E2s = 71000.0 * phun("MPa")
E3s = 69000.0 * phun("MPa")
nu12s = nu13s = nu23s = 0.3
G12s = G13s = G23s = 26000.0 * phun("MPa")
CTE1 = CTE2 = CTE3 = 0.0
# Orthotropic material for the CORE
E1c = 3.0 * phun("MPa")
E2c = 3.0 * phun("MPa")
E3c = 2.8 * phun("MPa")
nu12c = nu13c = nu23c = 0.25
G12c = G13c = G23c = 1.0 * phun("MPa")
CTE1 = CTE2 = CTE3 = 0.0
Lx = 5.0 * phun("mm") # length of loaded rectangle
Ly = 20.0 * phun("mm") # length of loaded rectangle
Sx = 100.0 * phun("mm") # span of the plate
Sy = 200.0 * phun("mm") # span of the plate
# Here we define the layout and the thicknesses of the layers.
angles = vec([0.0 0.0 0.0])
ts = vec([0.5 11.4 0.1]) * phun("mm") # layer thicknesses
TH = sum(ts) # total thickness of the plate
tolerance = 0.0001 * TH
# The line load is in the negative Z direction.
q0 = 1 * phun("MPa") # line load
# Reference deflection under the load is
wtopref = -3.789 * phun("mm") # From [1]
wbottomref = -2.16 * phun("mm") # Not given in [1]; guessed from the figure
# Select how find the mesh should be
Refinement = 3
nL = Refinement * 1
nSx = nL + Refinement * 4
nSy = 2 * nSx
# Each layer is modeled with a single element.
nts = Refinement * [1, 2, 1]# number of elements per layer
strength = 1.5
sp = (a, b, n) -> MeshUtilModule.gradedspace(a, b, n, strength)
sp = (a, b, n) -> linearspace(a, b, n)
xs = unique(
vcat(
reverse(collect(sp(Lx / 2, 0.0, nL + 1))),
collect(sp(Lx / 2, Sx / 2, nSx - nL + 1)),
),
)
ys = unique(
vcat(
reverse(collect(MeshUtilModule.gradedspace(Ly / 2, 0.0, nL + 1))),
collect(sp(Ly / 2, Sy / 2, nSy - nL + 1)),
),
)
fens, fes = H8layeredplatex(xs, ys, ts, nts)
fens, fes = H8toH20(fens, fes)
# This is the material model
MR = DeforModelRed3D
skinmaterial = MatDeforElastOrtho(
MR,
0.0,
E1s,
E2s,
E3s,
nu12s,
nu13s,
nu23s,
G12s,
G13s,
G23s,
CTE1,
CTE2,
CTE3,
)
corematerial = MatDeforElastOrtho(
MR,
0.0,
E1c,
E2c,
E3c,
nu12c,
nu13c,
nu23c,
G12c,
G13c,
G23c,
CTE1,
CTE2,
CTE3,
)
# The material coordinate system function is defined as:
function _updatecs!(csmatout::FFltMat, feid::FInt, label)
rotmat3!(csmatout, angles[label] / 180.0 * pi * [0.0; 0.0; 1.0])
csmatout
end
# The volume integrals are evaluated using this rule
gr = GaussRule(3, 3)
# We will create three regions, two for the skin, and one for the core.
rfes = subset(fes, selectelem(fens, fes, label = 1))
botskinregion = FDataDict(
"femm" => FEMMDeforLinear(
MR,
IntegDomain(rfes, gr),
CSys(
3,
3,
(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) -> _updatecs!(csmatout, feid, 1),
),
skinmaterial,
),
)
rfes = subset(fes, selectelem(fens, fes, label = 3))
topskinregion = FDataDict(
"femm" => FEMMDeforLinear(
MR,
IntegDomain(rfes, gr),
CSys(
3,
3,
(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) -> _updatecs!(csmatout, feid, 3),
),
skinmaterial,
),
)
rfes = subset(fes, selectelem(fens, fes, label = 2))
coreregion = FDataDict(
"femm" => FEMMDeforLinear(
MR,
IntegDomain(rfes, gr),
CSys(
3,
3,
(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) -> _updatecs!(csmatout, feid, 2),
),
corematerial,
),
)
# File = "Meyer_Piening_sandwich-r1.vtk"
# vtkexportmesh(File, skinregion["femm"].integdomain.fes.conn, fens.xyz, FinEtools.MeshExportModule.H8)
# # @async run(`"paraview.exe" $File`)
# File = "Meyer_Piening_sandwich-r2.vtk"
# vtkexportmesh(File, coreregion["femm"].integdomain.fes.conn, fens.xyz, FinEtools.MeshExportModule.H8)
# @async run(`"paraview.exe" $File`)
# The essential boundary conditions are applied on the symmetry planes.
# First the plane X=0;...
lx0 = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
ex0 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lx0)
# ... and then the plane Y=0.
ly0 = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
ey0 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => ly0)
# The transverse displacement is fixed around the circumference.
lz0 = vcat(
selectnode(fens, box = [Sx / 2 Sx / 2 -Inf Inf -Inf Inf], inflate = tolerance),
selectnode(fens, box = [-Inf Inf Sy / 2 Sy / 2 -Inf Inf], inflate = tolerance),
)
ez0 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lz0)
# The traction boundary condition is applied along rectangle in the middle of the plate.
bfes = meshboundary(fes)
# From the entire boundary we select those quadrilaterals that lie on the plane
# Z = thickness
tl = selectelem(fens, bfes, box = [0.0 Lx / 2 0 Ly / 2 TH TH], inflate = tolerance)
Trac = FDataDict(
"traction_vector" => vec([0.0; 0.0; -q0]),
"femm" => FEMMBase(IntegDomain(subset(bfes, tl), GaussRule(2, 3))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [botskinregion, coreregion, topskinregion],
"essential_bcs" => [ex0, ey0, ez0],
"traction_bcs" => [Trac],
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
modeldata["postprocessing"] = FDataDict("file" => filebase * "-u")
modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# The results of the displacement and stresses will be reported at
# nodes located at the appropriate points.
nbottomcenter = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 0.0], inflate = tolerance)
ntopcenter = selectnode(fens, box = [0.0 0.0 0.0 0.0 TH TH], inflate = tolerance)
ncenterline = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 TH], inflate = tolerance)
nintertop = selectnode(
fens,
box = [-Inf Inf 0.0 0.0 sum(ts[1:2]) sum(ts[1:2])],
inflate = tolerance,
)
ninterbot = selectnode(
fens,
box = [-Inf Inf 0.0 0.0 sum(ts[1:1]) sum(ts[1:1])],
inflate = tolerance,
)
zclo = sortperm(vec(geom.values[ncenterline, 3]))
ncenterline = ncenterline[zclo]
centerz = geom.values[ncenterline, 3]
zclo = nothing
xclotop = sortperm(vec(geom.values[nintertop, 1]))
nintertop = nintertop[xclotop]
topx = geom.values[nintertop, 1]
xclobot = sortperm(vec(geom.values[ninterbot, 1]))
ninterbot = ninterbot[xclobot]
botx = geom.values[ninterbot, 1]
xclotop = xclobot = nothing
conninbotskin =
intersect(connectednodes(botskinregion["femm"].integdomain.fes), ncenterline)
connincore = intersect(connectednodes(coreregion["femm"].integdomain.fes), ncenterline)
connintopskin =
intersect(connectednodes(topskinregion["femm"].integdomain.fes), ncenterline)
inbotskin = [n in conninbotskin for n in ncenterline]
incore = [n in connincore for n in ncenterline]
intopskin = [n in connintopskin for n in ncenterline]
println("")
println("Top Center deflection: $(u.values[ntopcenter, 3]/phun("mm")) [mm]")
println("Bottom Center deflection: $(u.values[nbottomcenter, 3]/phun("mm")) [mm]")
# # extrap = :extrapmean
# extrap = :extraptrend
# nodevalmeth = :averaging
extrap = :default
nodevalmeth = :invdistance
# Normal stress in the X direction
modeldata["postprocessing"] = FDataDict(
"file" => filebase * "-sx",
"quantity" => :Cauchy,
"component" => 1,
"outputcsys" => CSys(3),
"nodevalmethod" => nodevalmeth,
"reportat" => extrap,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
s = modeldata["postprocessing"]["exported"][1]["field"]
sxbot = s.values[ncenterline, 1]
s = modeldata["postprocessing"]["exported"][2]["field"]
sxcore = s.values[ncenterline, 1]
s = modeldata["postprocessing"]["exported"][3]["field"]
sxtop = s.values[ncenterline, 1]
# The graph data needs to be collected by going through each layer separately.
# Some quantities may be discontinuous between layers.
zs = vcat(
[z for (j, z) in enumerate(centerz) if inbotskin[j]],
[z for (j, z) in enumerate(centerz) if incore[j]],
[z for (j, z) in enumerate(centerz) if intopskin[j]],
)
sxs = vcat(
[sxbot[j] for (j, z) in enumerate(centerz) if inbotskin[j]],
[sxcore[j] for (j, z) in enumerate(centerz) if incore[j]],
[sxtop[j] for (j, z) in enumerate(centerz) if intopskin[j]],
)
File = filebase * "-sx-$(extrap).CSV"
savecsv(File, zs = vec(zs) / phun("mm"), sx = vec(sxs) / phun("MPa"))
# @async run(`"paraview.exe" $File`)
# Inter laminar stress between the skin and the core
modeldata["postprocessing"] = FDataDict(
"file" => filebase * "-sxz",
"quantity" => :Cauchy,
"component" => 5,
"outputcsys" => CSys(3),
"nodevalmethod" => nodevalmeth,
"reportat" => extrap,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
s = modeldata["postprocessing"]["exported"][1]["field"]
sxzskinbot = s.values[ninterbot, 1]
s = modeldata["postprocessing"]["exported"][2]["field"]
sxzcoretop = s.values[nintertop, 1]
sxzcorebot = s.values[ninterbot, 1]
s = modeldata["postprocessing"]["exported"][3]["field"]
sxzskintop = s.values[nintertop, 1]
File = filebase * "-sxz-$(extrap).CSV"
savecsv(
File,
xstop = vec(topx) / phun("mm"),
sxzskintop = vec(sxzskintop) / phun("MPa"),
sxzcoretop = vec(sxzcoretop) / phun("MPa"),
xsbot = vec(botx) / phun("mm"),
sxzskinbot = vec(sxzskinbot) / phun("MPa"),
sxzcorebot = vec(sxzcorebot) / phun("MPa"),
)
@async run(`"paraview.exe" $File`)
println("Done")
true
end # Meyer_Piening_sandwich_H20
function Meyer_Piening_sandwich_H8()
println("""
Meyer-Piening sandwich plate, plain-vanilla H8
""")
# Reference results from:
# [1] Application of the Elasticity Solution
# to Linear Sandwich Beam, Plate
# and Shell Analyses
# H.-R. MEYER -PIENING
# Journal of SANDWICH STRUCTURES AND MATERIALS , Vol. 6—July 2004
# Assessment of the refined sinus plate finite element:
# Free edge effect and Meyer-Piening sandwich test
# P. Vidal, O. Polit, M. D'Ottavio, E. Valot
# http://dx.doi.org/10.1016/j.finel.2014.08.004
#
# The second study deals with a benchmark problem proposed
# by Meyer-Piening [14]. It involves a simply -supported rectangular
# sandwich plate submitted to a localized pressure applied on an
# area of 5x20 mm. The geometry of the sandwich structure is
# given in Fig.13. Due to the symmetry, only one quarter of the plate
# is meshed. The faces have different thicknesses: h = 0.5 mm
# (bottom face), h = 0.1 mm (top face). The thickness of the core
# is h = 11.4 mm. The material properties are given in Table 3.
# Note that this benchmark involves strong heterogeneities (very
# different geometric and constitutive properties between core and
# face) and local stress gradient due to the localized pressure load.
#
# [14] H.-R. Meyer-Piening, Experiences with exact linear sandwich beam and plate
# analyses regarding bending, instability and frequency investigations, in:
# Proceedings of the Fifth International Conference On Sandwich Constructions,
# September 5–7, vol. I, Zurich, Switzerland, 2000, pp. 37–48.
t0 = time()
# Orthotropic material for the SKIN
E1s = 70000.0 * phun("MPa")
E2s = 71000.0 * phun("MPa")
E3s = 69000.0 * phun("MPa")
nu12s = nu13s = nu23s = 0.3
G12s = G13s = G23s = 26000.0 * phun("MPa")
CTE1 = CTE2 = CTE3 = 0.0
# Orthotropic material for the CORE
E1c = 3.0 * phun("MPa")
E2c = 3.0 * phun("MPa")
E3c = 2.8 * phun("MPa")
nu12c = nu13c = nu23c = 0.25
G12c = G13c = G23c = 1.0 * phun("MPa")
CTE1 = CTE2 = CTE3 = 0.0
Lx = 5.0 * phun("mm") # length of loaded rectangle
Ly = 20.0 * phun("mm") # length of loaded rectangle
Sx = 100.0 * phun("mm") # span of the plate
Sy = 200.0 * phun("mm") # span of the plate
# Here we define the layout and the thicknesses of the layers.
angles = vec([0.0 0.0 0.0])
ts = vec([0.5 11.4 0.1]) * phun("mm") # layer thicknesses
TH = sum(ts) # total thickness of the plate
tolerance = 0.0001 * TH
# The line load is in the negative Z direction.
q0 = 1 * phun("MPa") # line load
# Reference deflection under the load is
wtopref = -3.789 * phun("mm") # From [1]
wbottomref = -2.16 * phun("mm") # Not given in [1]; guessed from the figure
# Select how find the mesh should be
Refinement = 5
nL = Refinement * 1
nSx = nL + Refinement * 4
nSy = 2 * nSx
# Each layer is modeled with a single element.
nts = Refinement * [1, 2, 1]# number of elements per layer
strength = 1.5
xs = unique(
vcat(
reverse(collect(MeshUtilModule.gradedspace(Lx / 2, 0.0, nL + 1, strength))),
collect(MeshUtilModule.gradedspace(Lx / 2, Sx / 2, nSx - nL + 1, strength)),
),
)
ys = unique(
vcat(
reverse(collect(MeshUtilModule.gradedspace(Ly / 2, 0.0, nL + 1, strength))),
collect(MeshUtilModule.gradedspace(Ly / 2, Sy / 2, nSy - nL + 1, strength)),
),
)
fens, fes = H8layeredplatex(xs, ys, ts, nts)
# This is the material model
MR = DeforModelRed3D
skinmaterial = MatDeforElastOrtho(
MR,
0.0,
E1s,
E2s,
E3s,
nu12s,
nu13s,
nu23s,
G12s,
G13s,
G23s,
CTE1,
CTE2,
CTE3,
)
corematerial = MatDeforElastOrtho(
MR,
0.0,
E1c,
E2c,
E3c,
nu12c,
nu13c,
nu23c,
G12c,
G13c,
G23c,
CTE1,
CTE2,
CTE3,
)
# The material coordinate system function is defined as:
function _updatecs!(csmatout::FFltMat, feid::FInt, label)
rotmat3!(csmatout, angles[label] / 180.0 * pi * [0.0; 0.0; 1.0])
csmatout
end
# The vvolume integrals are evaluated using this rule
gr = GaussRule(3, 2)
# We will create three regions, two for the skin, and one for the core.
rfes = subset(fes, selectelem(fens, fes, label = 1))
botskinregion = FDataDict(
"femm" => FEMMDeforLinear(
MR,
IntegDomain(rfes, gr),
CSys(
3,
3,
(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) -> _updatecs!(csmatout, feid, 1),
),
skinmaterial,
),
)
rfes = subset(fes, selectelem(fens, fes, label = 3))
topskinregion = FDataDict(
"femm" => FEMMDeforLinear(
MR,
IntegDomain(rfes, gr),
CSys(
3,
3,
(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) -> _updatecs!(csmatout, feid, 3),
),
skinmaterial,
),
)
rfes = subset(fes, selectelem(fens, fes, label = 2))
coreregion = FDataDict(
"femm" => FEMMDeforLinear(
MR,
IntegDomain(rfes, gr),
CSys(
3,
3,
(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) -> _updatecs!(csmatout, feid, 2),
),
corematerial,
),
)
# File = "Meyer_Piening_sandwich-r1.vtk"
# vtkexportmesh(File, skinregion["femm"].integdomain.fes.conn, fens.xyz, FinEtools.MeshExportModule.H8)
# # @async run(`"paraview.exe" $File`)
# File = "Meyer_Piening_sandwich-r2.vtk"
# vtkexportmesh(File, coreregion["femm"].integdomain.fes.conn, fens.xyz, FinEtools.MeshExportModule.H8)
# @async run(`"paraview.exe" $File`)
# The essential boundary conditions are applied on the symmetry planes.
# First the plane X=0;...
lx0 = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
ex0 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lx0)
# ... and then the plane Y=0.
ly0 = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
ey0 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => ly0)
# The transverse displacement is fixed around the circumference.
lz0 = vcat(
selectnode(fens, box = [Sx / 2 Sx / 2 -Inf Inf -Inf Inf], inflate = tolerance),
selectnode(fens, box = [-Inf Inf Sy / 2 Sy / 2 -Inf Inf], inflate = tolerance),
)
ez0 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lz0)
# The traction boundary condition is applied along rectangle in the middle of the plate.
bfes = meshboundary(fes)
# From the entire boundary we select those quadrilaterals that lie on the plane
# Z = thickness
tl = selectelem(fens, bfes, box = [0.0 Lx / 2 0 Ly / 2 TH TH], inflate = tolerance)
Trac = FDataDict(
"traction_vector" => vec([0.0; 0.0; -q0]),
"femm" => FEMMBase(IntegDomain(subset(bfes, tl), GaussRule(2, 2))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [botskinregion, coreregion, topskinregion],
"essential_bcs" => [ex0, ey0, ez0],
"traction_bcs" => [Trac],
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
modeldata["postprocessing"] = FDataDict("file" => "Meyer_Piening_sandwich")
modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# The results of the displacement and stresses will be reported at
# nodes located at the appropriate points.
nbottomcenter = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 0.0], inflate = tolerance)
ntopcenter = selectnode(fens, box = [0.0 0.0 0.0 0.0 TH TH], inflate = tolerance)
ncenterline = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 TH], inflate = tolerance)
nintertop = selectnode(
fens,
box = [-Inf Inf 0.0 0.0 sum(ts[1:2]) sum(ts[1:2])],
inflate = tolerance,
)
ninterbot = selectnode(
fens,
box = [-Inf Inf 0.0 0.0 sum(ts[1:1]) sum(ts[1:1])],
inflate = tolerance,
)
zclo = sortperm(vec(geom.values[ncenterline, 3]))
centerz = geom.values[ncenterline[zclo], 3]
xclotop = sortperm(vec(geom.values[nintertop, 1]))
topx = geom.values[nintertop[xclotop], 1]
xclobot = sortperm(vec(geom.values[ninterbot, 1]))
botx = geom.values[ninterbot[xclobot], 1]
conninbotskin =
intersect(connectednodes(botskinregion["femm"].integdomain.fes), ncenterline)
connincore = intersect(connectednodes(coreregion["femm"].integdomain.fes), ncenterline)
connintopskin =
intersect(connectednodes(topskinregion["femm"].integdomain.fes), ncenterline)
inbotskin = [n in conninbotskin for n in ncenterline]
incore = [n in connincore for n in ncenterline]
intopskin = [n in connintopskin for n in ncenterline]
println("")
println("Top Center deflection: $(u.values[ntopcenter, 3]/phun("mm")) [mm]")
println("Bottom Center deflection: $(u.values[nbottomcenter, 3]/phun("mm")) [mm]")
# # extrap = :extrapmean
# extrap = :extraptrend
# nodevalmeth = :averaging
extrap = :default
nodevalmeth = :invdistance
# Normal stress in the X direction
modeldata["postprocessing"] = FDataDict(
"file" => "Meyer_Piening_sandwich-sx",
"quantity" => :Cauchy,
"component" => 1,
"outputcsys" => CSys(3),
"nodevalmethod" => nodevalmeth,
"reportat" => extrap,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
s = modeldata["postprocessing"]["exported"][1]["field"]
sxbot = s.values[ncenterline[zclo], 1]
s = modeldata["postprocessing"]["exported"][2]["field"]
sxcore = s.values[ncenterline[zclo], 1]
s = modeldata["postprocessing"]["exported"][3]["field"]
sxtop = s.values[ncenterline[zclo], 1]
# The graph data needs to be collected by going through each layer separately.
# Some quantities may be discontinuous between layers.
zs = vcat(
[z for (j, z) in enumerate(centerz) if inbotskin[j]],
[z for (j, z) in enumerate(centerz) if incore[j]],
[z for (j, z) in enumerate(centerz) if intopskin[j]],
)
sxs = vcat(
[sxbot[j] for (j, z) in enumerate(centerz) if inbotskin[j]],
[sxcore[j] for (j, z) in enumerate(centerz) if incore[j]],
[sxtop[j] for (j, z) in enumerate(centerz) if intopskin[j]],
)
File = "Meyer_Piening_sandwich-sx-$(extrap).CSV"
savecsv(File, zs = vec(zs) / phun("mm"), sx = vec(sxs) / phun("MPa"))
# @async run(`"paraview.exe" $File`)
# Inter laminar stress between the skin and the core
modeldata["postprocessing"] = FDataDict(
"file" => "Meyer_Piening_sandwich-sxz",
"quantity" => :Cauchy,
"component" => 5,
"outputcsys" => CSys(3),
"nodevalmethod" => nodevalmeth,
"reportat" => extrap,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
s = modeldata["postprocessing"]["exported"][1]["field"]
sxzskinbot = s.values[ninterbot[xclobot], 1]
s = modeldata["postprocessing"]["exported"][2]["field"]
sxzcoretop = s.values[nintertop[xclotop], 1]
sxzcorebot = s.values[ninterbot[xclobot], 1]
s = modeldata["postprocessing"]["exported"][3]["field"]
sxzskintop = s.values[nintertop[xclotop], 1]
File = "Meyer_Piening_sandwich-sxz-$(extrap).CSV"
savecsv(
File,
xstop = vec(topx[xclotop]) / phun("mm"),
sxzskintop = vec(sxzskintop[xclotop]) / phun("MPa"),
sxzcoretop = vec(sxzcoretop[xclotop]) / phun("MPa"),
xsbot = vec(botx[xclobot]) / phun("mm"),
sxzskinbot = vec(sxzskinbot[xclobot]) / phun("MPa"),
sxzcorebot = vec(sxzcorebot[xclobot]) / phun("MPa"),
)
@async run(`"paraview.exe" $File`)
println("Done")
true
end # Meyer_Piening_sandwich_H8
function Meyer_Piening_sandwich_MSH8()
println("""
Meyer-Piening sandwich plate: mean-strain hexahedron
""")
# Reference results from:
# [1] Application of the Elasticity Solution
# to Linear Sandwich Beam, Plate
# and Shell Analyses
# H.-R. MEYER -PIENING
# Journal of SANDWICH STRUCTURES AND MATERIALS , Vol. 6—July 2004
# Assessment of the refined sinus plate finite element:
# Free edge effect and Meyer-Piening sandwich test
# P. Vidal, O. Polit, M. D'Ottavio, E. Valot
# http://dx.doi.org/10.1016/j.finel.2014.08.004
#
# The second study deals with a benchmark problem proposed
# by Meyer-Piening [14]. It involves a simply -supported rectangular
# sandwich plate submitted to a localized pressure applied on an
# area of 5x20 mm. The geometry of the sandwich structure is
# given in Fig.13. Due to the symmetry, only one quarter of the plate
# is meshed. The faces have different thicknesses: h = 0.5 mm
# (bottom face), h = 0.1 mm (top face). The thickness of the core
# is h = 11.4 mm. The material properties are given in Table 3.
# Note that this benchmark involves strong heterogeneities (very
# different geometric and constitutive properties between core and
# face) and local stress gradient due to the localized pressure load.
#
# [14] H.-R. Meyer-Piening, Experiences with exact linear sandwich beam and plate
# analyses regarding bending, instability and frequency investigations, in:
# Proceedings of the Fifth International Conference On Sandwich Constructions,
# September 5–7, vol. I, Zurich, Switzerland, 2000, pp. 37–48.
filebase = "Meyer-Piening-sandwich-MSH8"
t0 = time()
# Orthotropic material for the SKIN
E1s = 70000.0 * phun("MPa")
E2s = 71000.0 * phun("MPa")
E3s = 69000.0 * phun("MPa")
nu12s = nu13s = nu23s = 0.3
G12s = G13s = G23s = 26000.0 * phun("MPa")
CTE1 = CTE2 = CTE3 = 0.0
# Orthotropic material for the CORE
E1c = 3.0 * phun("MPa")
E2c = 3.0 * phun("MPa")
E3c = 2.8 * phun("MPa")
nu12c = nu13c = nu23c = 0.25
G12c = G13c = G23c = 1.0 * phun("MPa")
CTE1 = CTE2 = CTE3 = 0.0
Lx = 5.0 * phun("mm") # length of loaded rectangle
Ly = 20.0 * phun("mm") # length of loaded rectangle
Sx = 100.0 * phun("mm") # span of the plate
Sy = 200.0 * phun("mm") # span of the plate
# Here we define the layout and the thicknesses of the layers.
angles = vec([0.0 0.0 0.0])
ts = vec([0.5 11.4 0.1]) * phun("mm") # layer thicknesses
TH = sum(ts) # total thickness of the plate
tolerance = 0.0001 * TH
# The line load is in the negative Z direction.
q0 = 1 * phun("MPa") # line load
# Reference deflection under the load is
wtopref = -3.789 * phun("mm") # From [1]
wbottomref = -2.16 * phun("mm") # Not given in [1]; guessed from the figure
# Select how find the mesh should be
Refinement = 7
nL = Refinement * 1
nSx = nL + Refinement * 4
nSy = 2 * nSx
# Each layer is modeled with a single element.
nts = Refinement * [1, 2, 1]# number of elements per layer
strength = 1.5
sp = (a, b, n) -> MeshUtilModule.gradedspace(a, b, n, strength)
sp = (a, b, n) -> linearspace(a, b, n)
xs = unique(
vcat(
reverse(collect(sp(Lx / 2, 0.0, nL + 1))),
collect(sp(Lx / 2, Sx / 2, nSx - nL + 1)),
),
)
ys = unique(
vcat(
reverse(collect(MeshUtilModule.gradedspace(Ly / 2, 0.0, nL + 1))),
collect(sp(Ly / 2, Sy / 2, nSy - nL + 1)),
),
)
fens, fes = H8layeredplatex(xs, ys, ts, nts)
# This is the material model
MR = DeforModelRed3D
skinmaterial = MatDeforElastOrtho(
MR,
0.0,
E1s,
E2s,
E3s,
nu12s,
nu13s,
nu23s,
G12s,
G13s,
G23s,
CTE1,
CTE2,
CTE3,
)
corematerial = MatDeforElastOrtho(
MR,
0.0,
E1c,
E2c,
E3c,
nu12c,
nu13c,
nu23c,
G12c,
G13c,
G23c,
CTE1,
CTE2,
CTE3,
)
# The material coordinate system function is defined as:
function _updatecs!(csmatout::FFltMat, feid::FInt, label)
rotmat3!(csmatout, angles[label] / 180.0 * pi * [0.0; 0.0; 1.0])
csmatout
end
# The vvolume integrals are evaluated using this rule
gr = GaussRule(3, 2)
# We will create three regions, two for the skin, and one for the core.
rfes = subset(fes, selectelem(fens, fes, label = 1))
botskinregion = FDataDict(
"femm" => FEMMDeforLinearMSH8(
MR,
IntegDomain(rfes, gr),
CSys(
3,
3,
(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) -> _updatecs!(csmatout, feid, 1),
),
skinmaterial,
),
)
rfes = subset(fes, selectelem(fens, fes, label = 3))
topskinregion = FDataDict(
"femm" => FEMMDeforLinearMSH8(
MR,
IntegDomain(rfes, gr),
CSys(
3,
3,
(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) -> _updatecs!(csmatout, feid, 3),
),
skinmaterial,
),
)
rfes = subset(fes, selectelem(fens, fes, label = 2))
coreregion = FDataDict(
"femm" => FEMMDeforLinearMSH8(
MR,
IntegDomain(rfes, gr),
CSys(
3,
3,
(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) -> _updatecs!(csmatout, feid, 2),
),
corematerial,
),
)
# File = "Meyer_Piening_sandwich-r1.vtk"
# vtkexportmesh(File, skinregion["femm"].integdomain.fes.conn, fens.xyz, FinEtools.MeshExportModule.H8)
# # @async run(`"paraview.exe" $File`)
# File = "Meyer_Piening_sandwich-r2.vtk"
# vtkexportmesh(File, coreregion["femm"].integdomain.fes.conn, fens.xyz, FinEtools.MeshExportModule.H8)
# @async run(`"paraview.exe" $File`)
# The essential boundary conditions are applied on the symmetry planes.
# First the plane X=0;...
lx0 = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
ex0 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lx0)
# ... and then the plane Y=0.
ly0 = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
ey0 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => ly0)
# The transverse displacement is fixed around the circumference.
lz0 = vcat(
selectnode(fens, box = [Sx / 2 Sx / 2 -Inf Inf -Inf Inf], inflate = tolerance),
selectnode(fens, box = [-Inf Inf Sy / 2 Sy / 2 -Inf Inf], inflate = tolerance),
)
ez0 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lz0)
# The traction boundary condition is applied along rectangle in the middle of the plate.
bfes = meshboundary(fes)
# From the entire boundary we select those quadrilaterals that lie on the plane
# Z = thickness
tl = selectelem(fens, bfes, box = [0.0 Lx / 2 0 Ly / 2 TH TH], inflate = tolerance)
Trac = FDataDict(
"traction_vector" => vec([0.0; 0.0; -q0]),
"femm" => FEMMBase(IntegDomain(subset(bfes, tl), GaussRule(2, 2))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [botskinregion, coreregion, topskinregion],
"essential_bcs" => [ex0, ey0, ez0],
"traction_bcs" => [Trac],
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
modeldata["postprocessing"] = FDataDict("file" => filebase * "-u")
modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# The results of the displacement and stresses will be reported at
# nodes located at the appropriate points.
nbottomcenter = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 0.0], inflate = tolerance)
ntopcenter = selectnode(fens, box = [0.0 0.0 0.0 0.0 TH TH], inflate = tolerance)
ncenterline = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 TH], inflate = tolerance)
nintertop = selectnode(
fens,
box = [-Inf Inf 0.0 0.0 sum(ts[1:2]) sum(ts[1:2])],
inflate = tolerance,
)
ninterbot = selectnode(
fens,
box = [-Inf Inf 0.0 0.0 sum(ts[1:1]) sum(ts[1:1])],
inflate = tolerance,
)
zclo = sortperm(vec(geom.values[ncenterline, 3]))
ncenterline = ncenterline[zclo]
centerz = geom.values[ncenterline, 3]
zclo = nothing
xclotop = sortperm(vec(geom.values[nintertop, 1]))
nintertop = nintertop[xclotop]
topx = geom.values[nintertop, 1]
xclobot = sortperm(vec(geom.values[ninterbot, 1]))
ninterbot = ninterbot[xclobot]
botx = geom.values[ninterbot, 1]
xclotop = xclobot = nothing
conninbotskin =
intersect(connectednodes(botskinregion["femm"].integdomain.fes), ncenterline)
connincore = intersect(connectednodes(coreregion["femm"].integdomain.fes), ncenterline)
connintopskin =
intersect(connectednodes(topskinregion["femm"].integdomain.fes), ncenterline)
inbotskin = [n in conninbotskin for n in ncenterline]
incore = [n in connincore for n in ncenterline]
intopskin = [n in connintopskin for n in ncenterline]
println("")
println("Top Center deflection: $(u.values[ntopcenter, 3]/phun("mm")) [mm]")
println("Bottom Center deflection: $(u.values[nbottomcenter, 3]/phun("mm")) [mm]")
# # extrap = :extrapmean
extrap = :extraptrend
nodevalmeth = :averaging
# extrap = :default
# nodevalmeth = :invdistance
# Normal stress in the X direction
modeldata["postprocessing"] = FDataDict(
"file" => filebase * "-sx",
"quantity" => :Cauchy,
"component" => 1,
"outputcsys" => CSys(3),
"nodevalmethod" => nodevalmeth,
"reportat" => extrap,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
s = modeldata["postprocessing"]["exported"][1]["field"]
sxbot = s.values[ncenterline, 1]
s = modeldata["postprocessing"]["exported"][2]["field"]
sxcore = s.values[ncenterline, 1]
s = modeldata["postprocessing"]["exported"][3]["field"]
sxtop = s.values[ncenterline, 1]
# The graph data needs to be collected by going through each layer separately.
# Some quantities may be discontinuous between layers.
zs = vcat(
[z for (j, z) in enumerate(centerz) if inbotskin[j]],
[z for (j, z) in enumerate(centerz) if incore[j]],
[z for (j, z) in enumerate(centerz) if intopskin[j]],
)
sxs = vcat(
[sxbot[j] for (j, z) in enumerate(centerz) if inbotskin[j]],
[sxcore[j] for (j, z) in enumerate(centerz) if incore[j]],
[sxtop[j] for (j, z) in enumerate(centerz) if intopskin[j]],
)
File = filebase * "-sx-$(extrap).CSV"
savecsv(File, zs = vec(zs) / phun("mm"), sx = vec(sxs) / phun("MPa"))
# @async run(`"paraview.exe" $File`)
# Inter laminar stress between the skin and the core
modeldata["postprocessing"] = FDataDict(
"file" => filebase * "-sxz",
"quantity" => :Cauchy,
"component" => 5,
"outputcsys" => CSys(3),
"nodevalmethod" => nodevalmeth,
"reportat" => extrap,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
s = modeldata["postprocessing"]["exported"][1]["field"]
sxzskinbot = s.values[ninterbot, 1]
s = modeldata["postprocessing"]["exported"][2]["field"]
sxzcoretop = s.values[nintertop, 1]
sxzcorebot = s.values[ninterbot, 1]
s = modeldata["postprocessing"]["exported"][3]["field"]
sxzskintop = s.values[nintertop, 1]
File = filebase * "-sxz-$(extrap).CSV"
savecsv(
File,
xstop = vec(topx) / phun("mm"),
sxzskintop = vec(sxzskintop) / phun("MPa"),
sxzcoretop = vec(sxzcoretop) / phun("MPa"),
xsbot = vec(botx) / phun("mm"),
sxzskinbot = vec(sxzskinbot) / phun("MPa"),
sxzcorebot = vec(sxzcorebot) / phun("MPa"),
)
@async run(`"paraview.exe" $File`)
println("Done")
true
end # Meyer_Piening_sandwich_MSH8
function Meyer_Piening_sandwich_MST10()
println("""
Meyer-Piening sandwich plate, mean-strain MST10
""")
# Reference results from:
# [1] Application of the Elasticity Solution
# to Linear Sandwich Beam, Plate
# and Shell Analyses
# H.-R. MEYER -PIENING
# Journal of SANDWICH STRUCTURES AND MATERIALS , Vol. 6—July 2004
# Assessment of the refined sinus plate finite element:
# Free edge effect and Meyer-Piening sandwich test
# P. Vidal, O. Polit, M. D'Ottavio, E. Valot
# http://dx.doi.org/10.1016/j.finel.2014.08.004
#
# The second study deals with a benchmark problem proposed
# by Meyer-Piening [14]. It involves a simply -supported rectangular
# sandwich plate submitted to a localized pressure applied on an
# area of 5x20 mm. The geometry of the sandwich structure is
# given in Fig.13. Due to the symmetry, only one quarter of the plate
# is meshed. The faces have different thicknesses: h = 0.5 mm
# (bottom face), h = 0.1 mm (top face). The thickness of the core
# is h = 11.4 mm. The material properties are given in Table 3.
# Note that this benchmark involves strong heterogeneities (very
# different geometric and constitutive properties between core and
# face) and local stress gradient due to the localized pressure load.
#
# [14] H.-R. Meyer-Piening, Experiences with exact linear sandwich beam and plate
# analyses regarding bending, instability and frequency investigations, in:
# Proceedings of the Fifth International Conference On Sandwich Constructions,
# September 5–7, vol. I, Zurich, Switzerland, 2000, pp. 37–48.
filebase = "Meyer-Piening-sandwich-MST10"
t0 = time()
# Orthotropic material for the SKIN
E1s = 70000.0 * phun("MPa")
E2s = 71000.0 * phun("MPa")
E3s = 69000.0 * phun("MPa")
nu12s = nu13s = nu23s = 0.3
G12s = G13s = G23s = 26000.0 * phun("MPa")
CTE1 = CTE2 = CTE3 = 0.0
# Orthotropic material for the CORE
E1c = 3.0 * phun("MPa")
E2c = 3.0 * phun("MPa")
E3c = 2.8 * phun("MPa")
nu12c = nu13c = nu23c = 0.25
G12c = G13c = G23c = 1.0 * phun("MPa")
CTE1 = CTE2 = CTE3 = 0.0
Lx = 5.0 * phun("mm") # length of loaded rectangle
Ly = 20.0 * phun("mm") # length of loaded rectangle
Sx = 100.0 * phun("mm") # span of the plate
Sy = 200.0 * phun("mm") # span of the plate
# Here we define the layout and the thicknesses of the layers.
angles = vec([0.0 0.0 0.0])
ts = vec([0.5 11.4 0.1]) * phun("mm") # layer thicknesses
TH = sum(ts) # total thickness of the plate
tolerance = 0.0001 * TH
# The line load is in the negative Z direction.
q0 = 1 * phun("MPa") # line load
# Reference deflection under the load is
wtopref = -3.789 * phun("mm") # From [1]
wbottomref = -2.16 * phun("mm") # Not given in [1]; guessed from the figure
# Select how find the mesh should be
Refinement = 3
nL = Refinement * 1
nSx = nL + Refinement * 4
nSy = 2 * nSx
# Each layer is modeled with a single element.
nts = Refinement * [1, 2, 1]# number of elements per layer
strength = 1.5
sp = (a, b, n) -> MeshUtilModule.gradedspace(a, b, n, strength)
sp = (a, b, n) -> linearspace(a, b, n)
xs = unique(
vcat(
reverse(collect(sp(Lx / 2, 0.0, nL + 1))),
collect(sp(Lx / 2, Sx / 2, nSx - nL + 1)),
),
)
ys = unique(
vcat(
reverse(collect(MeshUtilModule.gradedspace(Ly / 2, 0.0, nL + 1))),
collect(sp(Ly / 2, Sy / 2, nSy - nL + 1)),
),
)
fens, fes = T10layeredplatex(xs, ys, ts, nts)
# This is the material model
MR = DeforModelRed3D
skinmaterial = MatDeforElastOrtho(
MR,
0.0,
E1s,
E2s,
E3s,
nu12s,
nu13s,
nu23s,
G12s,
G13s,
G23s,
CTE1,
CTE2,
CTE3,
)
corematerial = MatDeforElastOrtho(
MR,
0.0,
E1c,
E2c,
E3c,
nu12c,
nu13c,
nu23c,
G12c,
G13c,
G23c,
CTE1,
CTE2,
CTE3,
)
# The material coordinate system function is defined as:
function _updatecs!(csmatout::FFltMat, feid::FInt, label)
rotmat3!(csmatout, angles[label] / 180.0 * pi * [0.0; 0.0; 1.0])
csmatout
end
# The volume integrals are evaluated using this rule
gr = SimplexRule(3, 4)
# We will create three regions, two for the skin, and one for the core.
rfes = subset(fes, selectelem(fens, fes, label = 1))
botskinregion = FDataDict(
"femm" => FEMMDeforLinearMST10(
MR,
IntegDomain(rfes, gr),
CSys(
3,
3,
(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) -> _updatecs!(csmatout, feid, 1),
),
skinmaterial,
),
)
rfes = subset(fes, selectelem(fens, fes, label = 3))
topskinregion = FDataDict(
"femm" => FEMMDeforLinearMST10(
MR,
IntegDomain(rfes, gr),
CSys(
3,
3,
(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) -> _updatecs!(csmatout, feid, 3),
),
skinmaterial,
),
)
rfes = subset(fes, selectelem(fens, fes, label = 2))
coreregion = FDataDict(
"femm" => FEMMDeforLinearMST10(
MR,
IntegDomain(rfes, gr),
CSys(
3,
3,
(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) -> _updatecs!(csmatout, feid, 2),
),
corematerial,
),
)
# File = "Meyer_Piening_sandwich-r1.vtk"
# vtkexportmesh(File, botskinregion["femm"].integdomain.fes.conn, fens.xyz,
# FinEtools.MeshExportModule.T10)
# # @async run(`"paraview.exe" $File`)
# File = "Meyer_Piening_sandwich-r2.vtk"
# vtkexportmesh(File, coreregion["femm"].integdomain.fes.conn, fens.xyz,
# FinEtools.MeshExportModule.T10)
# @async run(`"paraview.exe" $File`)
# The essential boundary conditions are applied on the symmetry planes.
# First the plane X=0;...
lx0 = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
ex0 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lx0)
# ... and then the plane Y=0.
ly0 = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
ey0 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => ly0)
# The transverse displacement is fixed around the circumference.
lz0 = vcat(
selectnode(fens, box = [Sx / 2 Sx / 2 -Inf Inf -Inf Inf], inflate = tolerance),
selectnode(fens, box = [-Inf Inf Sy / 2 Sy / 2 -Inf Inf], inflate = tolerance),
)
ez0 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lz0)
# The traction boundary condition is applied along rectangle in the middle of the plate.
bfes = meshboundary(fes)
# From the entire boundary we select those quadrilaterals that lie on the plane
# Z = thickness
tl = selectelem(fens, bfes, box = [0.0 Lx / 2 0 Ly / 2 TH TH], inflate = tolerance)
Trac = FDataDict(
"traction_vector" => vec([0.0; 0.0; -q0]),
"femm" => FEMMBase(IntegDomain(subset(bfes, tl), SimplexRule(2, 3))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [botskinregion, coreregion, topskinregion],
"essential_bcs" => [ex0, ey0, ez0],
"traction_bcs" => [Trac],
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
modeldata["postprocessing"] = FDataDict("file" => filebase * "-u")
modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# The results of the displacement and stresses will be reported at
# nodes located at the appropriate points.
nbottomcenter = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 0.0], inflate = tolerance)
ntopcenter = selectnode(fens, box = [0.0 0.0 0.0 0.0 TH TH], inflate = tolerance)
ncenterline = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 TH], inflate = tolerance)
nintertop = selectnode(
fens,
box = [-Inf Inf 0.0 0.0 sum(ts[1:2]) sum(ts[1:2])],
inflate = tolerance,
)
ninterbot = selectnode(
fens,
box = [-Inf Inf 0.0 0.0 sum(ts[1:1]) sum(ts[1:1])],
inflate = tolerance,
)
zclo = sortperm(vec(geom.values[ncenterline, 3]))
ncenterline = ncenterline[zclo]
centerz = geom.values[ncenterline, 3]
zclo = nothing
xclotop = sortperm(vec(geom.values[nintertop, 1]))
nintertop = nintertop[xclotop]
topx = geom.values[nintertop, 1]
xclobot = sortperm(vec(geom.values[ninterbot, 1]))
ninterbot = ninterbot[xclobot]
botx = geom.values[ninterbot, 1]
xclotop = xclobot = nothing
conninbotskin =
intersect(connectednodes(botskinregion["femm"].integdomain.fes), ncenterline)
connincore = intersect(connectednodes(coreregion["femm"].integdomain.fes), ncenterline)
connintopskin =
intersect(connectednodes(topskinregion["femm"].integdomain.fes), ncenterline)
inbotskin = [n in conninbotskin for n in ncenterline]
incore = [n in connincore for n in ncenterline]
intopskin = [n in connintopskin for n in ncenterline]
println("")
println("Top Center deflection: $(u.values[ntopcenter, 3]/phun("mm")) [mm]")
println("Bottom Center deflection: $(u.values[nbottomcenter, 3]/phun("mm")) [mm]")
# # extrap = :extrapmean
extrap = :extraptrend
nodevalmeth = :averaging
# extrap = :default
# nodevalmeth = :invdistance
# Normal stress in the X direction
modeldata["postprocessing"] = FDataDict(
"file" => filebase * "-sx",
"quantity" => :Cauchy,
"component" => 1,
"outputcsys" => CSys(3),
"nodevalmethod" => nodevalmeth,
"reportat" => extrap,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
s = modeldata["postprocessing"]["exported"][1]["field"]
sxbot = s.values[ncenterline, 1]
s = modeldata["postprocessing"]["exported"][2]["field"]
sxcore = s.values[ncenterline, 1]
s = modeldata["postprocessing"]["exported"][3]["field"]
sxtop = s.values[ncenterline, 1]
# The graph data needs to be collected by going through each layer separately.
# Some quantities may be discontinuous between layers.
zs = vcat(
[z for (j, z) in enumerate(centerz) if inbotskin[j]],
[z for (j, z) in enumerate(centerz) if incore[j]],
[z for (j, z) in enumerate(centerz) if intopskin[j]],
)
sxs = vcat(
[sxbot[j] for (j, z) in enumerate(centerz) if inbotskin[j]],
[sxcore[j] for (j, z) in enumerate(centerz) if incore[j]],
[sxtop[j] for (j, z) in enumerate(centerz) if intopskin[j]],
)
File = filebase * "-sx-$(extrap).CSV"
savecsv(File, zs = vec(zs) / phun("mm"), sx = vec(sxs) / phun("MPa"))
# @async run(`"paraview.exe" $File`)
# Inter laminar stress between the skin and the core
modeldata["postprocessing"] = FDataDict(
"file" => filebase * "-sxz",
"quantity" => :Cauchy,
"component" => 5,
"outputcsys" => CSys(3),
"nodevalmethod" => nodevalmeth,
"reportat" => extrap,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
s = modeldata["postprocessing"]["exported"][1]["field"]
sxzskinbot = s.values[ninterbot, 1]
s = modeldata["postprocessing"]["exported"][2]["field"]
sxzcoretop = s.values[nintertop, 1]
sxzcorebot = s.values[ninterbot, 1]
s = modeldata["postprocessing"]["exported"][3]["field"]
sxzskintop = s.values[nintertop, 1]
File = filebase * "-sxz-$(extrap).CSV"
savecsv(
File,
xstop = vec(topx) / phun("mm"),
sxzskintop = vec(sxzskintop) / phun("MPa"),
sxzcoretop = vec(sxzcoretop) / phun("MPa"),
xsbot = vec(botx) / phun("mm"),
sxzskinbot = vec(sxzskinbot) / phun("MPa"),
sxzcorebot = vec(sxzcorebot) / phun("MPa"),
)
@async run(`"paraview.exe" $File`)
println("Done")
true
end # Meyer_Piening_sandwich_MST10
function Meyer_Piening_sandwich_MST10_timing()
println("""
Meyer-Piening sandwich plate, mean-strain MST10
""")
# Reference results from:
# [1] Application of the Elasticity Solution
# to Linear Sandwich Beam, Plate
# and Shell Analyses
# H.-R. MEYER -PIENING
# Journal of SANDWICH STRUCTURES AND MATERIALS , Vol. 6—July 2004
# Assessment of the refined sinus plate finite element:
# Free edge effect and Meyer-Piening sandwich test
# P. Vidal, O. Polit, M. D'Ottavio, E. Valot
# http://dx.doi.org/10.1016/j.finel.2014.08.004
#
# The second study deals with a benchmark problem proposed
# by Meyer-Piening [14]. It involves a simply -supported rectangular
# sandwich plate submitted to a localized pressure applied on an
# area of 5x20 mm. The geometry of the sandwich structure is
# given in Fig.13. Due to the symmetry, only one quarter of the plate
# is meshed. The faces have different thicknesses: h = 0.5 mm
# (bottom face), h = 0.1 mm (top face). The thickness of the core
# is h = 11.4 mm. The material properties are given in Table 3.
# Note that this benchmark involves strong heterogeneities (very
# different geometric and constitutive properties between core and
# face) and local stress gradient due to the localized pressure load.
#
# [14] H.-R. Meyer-Piening, Experiences with exact linear sandwich beam and plate
# analyses regarding bending, instability and frequency investigations, in:
# Proceedings of the Fifth International Conference On Sandwich Constructions,
# September 5–7, vol. I, Zurich, Switzerland, 2000, pp. 37–48.
filebase = "Meyer-Piening-sandwich-MST10"
t0 = time()
# Orthotropic material for the SKIN
E1s = 70000.0 * phun("MPa")
E2s = 71000.0 * phun("MPa")
E3s = 69000.0 * phun("MPa")
nu12s = nu13s = nu23s = 0.3
G12s = G13s = G23s = 26000.0 * phun("MPa")
CTE1 = CTE2 = CTE3 = 0.0
# Orthotropic material for the CORE
E1c = 3.0 * phun("MPa")
E2c = 3.0 * phun("MPa")
E3c = 2.8 * phun("MPa")
nu12c = nu13c = nu23c = 0.25
G12c = G13c = G23c = 1.0 * phun("MPa")
CTE1 = CTE2 = CTE3 = 0.0
Lx = 5.0 * phun("mm") # length of loaded rectangle
Ly = 20.0 * phun("mm") # length of loaded rectangle
Sx = 100.0 * phun("mm") # span of the plate
Sy = 200.0 * phun("mm") # span of the plate
# Here we define the layout and the thicknesses of the layers.
angles = vec([0.0 0.0 0.0])
ts = vec([0.5 11.4 0.1]) * phun("mm") # layer thicknesses
TH = sum(ts) # total thickness of the plate
tolerance = 0.0001 * TH
# The line load is in the negative Z direction.
q0 = 1 * phun("MPa") # line load
# Reference deflection under the load is
wtopref = -3.789 * phun("mm") # From [1]
wbottomref = -2.16 * phun("mm") # Not given in [1]; guessed from the figure
# Select how find the mesh should be
Refinement = 3
nL = Refinement * 1
nSx = nL + Refinement * 4
nSy = 2 * nSx
# Each layer is modeled with a single element.
nts = Refinement * [1, 2, 1]# number of elements per layer
strength = 1.5
sp = (a, b, n) -> MeshUtilModule.gradedspace(a, b, n, strength)
sp = (a, b, n) -> linearspace(a, b, n)
xs = unique(
vcat(
reverse(collect(sp(Lx / 2, 0.0, nL + 1))),
collect(sp(Lx / 2, Sx / 2, nSx - nL + 1)),
),
)
ys = unique(
vcat(
reverse(collect(MeshUtilModule.gradedspace(Ly / 2, 0.0, nL + 1))),
collect(sp(Ly / 2, Sy / 2, nSy - nL + 1)),
),
)
fens, fes = T10layeredplatex(xs, ys, ts, nts)
# This is the material model
MR = DeforModelRed3D
skinmaterial = MatDeforElastOrtho(
MR,
0.0,
E1s,
E2s,
E3s,
nu12s,
nu13s,
nu23s,
G12s,
G13s,
G23s,
CTE1,
CTE2,
CTE3,
)
corematerial = MatDeforElastOrtho(
MR,
0.0,
E1c,
E2c,
E3c,
nu12c,
nu13c,
nu23c,
G12c,
G13c,
G23c,
CTE1,
CTE2,
CTE3,
)
# The material coordinate system function is defined as:
function _updatecs!(csmatout::FFltMat, feid::FInt, label)
rotmat3!(csmatout, angles[label] / 180.0 * pi * [0.0; 0.0; 1.0])
csmatout
end
# The volume integrals are evaluated using this rule
gr = SimplexRule(3, 4)
# We will create three regions, two for the skin, and one for the core.
rfes = subset(fes, selectelem(fens, fes, label = 1))
botskinregion = FDataDict(
"femm" => FEMMDeforLinearMST10(
MR,
IntegDomain(rfes, gr),
CSys(
3,
3,
(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) -> _updatecs!(csmatout, feid, 1),
),
skinmaterial,
),
)
rfes = subset(fes, selectelem(fens, fes, label = 3))
topskinregion = FDataDict(
"femm" => FEMMDeforLinearMST10(
MR,
IntegDomain(rfes, gr),
CSys(
3,
3,
(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) -> _updatecs!(csmatout, feid, 3),
),
skinmaterial,
),
)
rfes = subset(fes, selectelem(fens, fes, label = 2))
coreregion = FDataDict(
"femm" => FEMMDeforLinearMST10(
MR,
IntegDomain(rfes, gr),
CSys(
3,
3,
(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) -> _updatecs!(csmatout, feid, 2),
),
corematerial,
),
)
# File = "Meyer_Piening_sandwich-r1.vtk"
# vtkexportmesh(File, botskinregion["femm"].integdomain.fes.conn, fens.xyz,
# FinEtools.MeshExportModule.T10)
# # @async run(`"paraview.exe" $File`)
# File = "Meyer_Piening_sandwich-r2.vtk"
# vtkexportmesh(File, coreregion["femm"].integdomain.fes.conn, fens.xyz,
# FinEtools.MeshExportModule.T10)
# @async run(`"paraview.exe" $File`)
# The essential boundary conditions are applied on the symmetry planes.
# First the plane X=0;...
lx0 = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
ex0 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lx0)
# ... and then the plane Y=0.
ly0 = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
ey0 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => ly0)
# The transverse displacement is fixed around the circumference.
lz0 = vcat(
selectnode(fens, box = [Sx / 2 Sx / 2 -Inf Inf -Inf Inf], inflate = tolerance),
selectnode(fens, box = [-Inf Inf Sy / 2 Sy / 2 -Inf Inf], inflate = tolerance),
)
ez0 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lz0)
# The traction boundary condition is applied along rectangle in the middle of the plate.
bfes = meshboundary(fes)
# From the entire boundary we select those quadrilaterals that lie on the plane
# Z = thickness
tl = selectelem(fens, bfes, box = [0.0 Lx / 2 0 Ly / 2 TH TH], inflate = tolerance)
Trac = FDataDict(
"traction_vector" => vec([0.0; 0.0; -q0]),
"femm" => FEMMBase(IntegDomain(subset(bfes, tl), SimplexRule(2, 3))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [botskinregion, coreregion, topskinregion],
"essential_bcs" => [ex0, ey0, ez0],
"traction_bcs" => [Trac],
)
t0 = time()
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
tstiffness = modeldata["timing"]["stiffness"]
tsolution = modeldata["timing"]["solution"]
println("count(fes) = $(count(fes))")
println("Timing: Assembly $(tstiffness), Solution $(tsolution)")
modeldata["postprocessing"] = FDataDict("file" => filebase * "-u")
modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# The results of the displacement and stresses will be reported at
# nodes located at the appropriate points.
nbottomcenter = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 0.0], inflate = tolerance)
ntopcenter = selectnode(fens, box = [0.0 0.0 0.0 0.0 TH TH], inflate = tolerance)
# ncenterline = selectnode(fens, box=[0.0 0.0 0.0 0.0 0.0 TH], inflate=tolerance)
# nintertop = selectnode(fens, box=[-Inf Inf 0.0 0.0 sum(ts[1:2]) sum(ts[1:2])], inflate=tolerance)
# ninterbot = selectnode(fens, box=[-Inf Inf 0.0 0.0 sum(ts[1:1]) sum(ts[1:1])], inflate=tolerance)
#
# zclo = sortperm(vec(geom.values[ncenterline, 3]))
# ncenterline = ncenterline[zclo]
# centerz = geom.values[ncenterline, 3]
# zclo = nothing
#
# xclotop = sortperm(vec(geom.values[nintertop, 1]))
# nintertop = nintertop[xclotop]
# topx = geom.values[nintertop, 1]
# xclobot = sortperm(vec(geom.values[ninterbot, 1]))
# ninterbot = ninterbot[xclobot]
# botx = geom.values[ninterbot, 1]
# xclotop = xclobot = nothing
#
# conninbotskin = intersect(connectednodes(botskinregion["femm"].integdomain.fes), ncenterline)
# connincore = intersect(connectednodes(coreregion["femm"].integdomain.fes), ncenterline)
# connintopskin = intersect(connectednodes(topskinregion["femm"].integdomain.fes), ncenterline)
# inbotskin = [n in conninbotskin for n in ncenterline]
# incore = [n in connincore for n in ncenterline]
# intopskin = [n in connintopskin for n in ncenterline]
println("")
println("Top Center deflection: $(u.values[ntopcenter, 3]/phun("mm")) [mm]")
println("Bottom Center deflection: $(u.values[nbottomcenter, 3]/phun("mm")) [mm]")
# # # extrap = :extrapmean
# extrap = :extraptrend
# nodevalmeth = :averaging
# # extrap = :default
# # nodevalmeth = :invdistance
#
# # Normal stress in the X direction
# modeldata["postprocessing"] = FDataDict("file"=>filebase * "-sx",
# "quantity"=>:Cauchy, "component"=>1, "outputcsys"=>CSys(3),
# "nodevalmethod"=>nodevalmeth, "reportat"=>extrap)
# modeldata = AlgoDeforLinearModule.exportstress(modeldata)
# s = modeldata["postprocessing"]["exported"][1]["field"]
# sxbot = s.values[ncenterline, 1]
# s = modeldata["postprocessing"]["exported"][2]["field"]
# sxcore = s.values[ncenterline, 1]
# s = modeldata["postprocessing"]["exported"][3]["field"]
# sxtop = s.values[ncenterline, 1]
#
# # The graph data needs to be collected by going through each layer separately.
# # Some quantities may be discontinuous between layers.
# zs = vcat( [z for (j,z) in enumerate(centerz) if inbotskin[j]],
# [z for (j,z) in enumerate(centerz) if incore[j]],
# [z for (j,z) in enumerate(centerz) if intopskin[j]]
# )
# sxs = vcat( [sxbot[j] for (j,z) in enumerate(centerz) if inbotskin[j]],
# [sxcore[j] for (j,z) in enumerate(centerz) if incore[j]],
# [sxtop[j] for (j,z) in enumerate(centerz) if intopskin[j]]
# )
# File = filebase * "-sx-$(extrap).CSV"
# savecsv(File, zs=vec(zs)/phun("mm"), sx=vec(sxs)/phun("MPa"))
#
# # @async run(`"paraview.exe" $File`)
#
# # Inter laminar stress between the skin and the core
# modeldata["postprocessing"] = FDataDict("file"=>filebase * "-sxz",
# "quantity"=>:Cauchy, "component"=>5, "outputcsys"=>CSys(3),
# "nodevalmethod"=>nodevalmeth, "reportat"=>extrap)
# modeldata = AlgoDeforLinearModule.exportstress(modeldata)
# s = modeldata["postprocessing"]["exported"][1]["field"]
# sxzskinbot = s.values[ninterbot, 1]
# s = modeldata["postprocessing"]["exported"][2]["field"]
# sxzcoretop = s.values[nintertop, 1]
# sxzcorebot = s.values[ninterbot, 1]
# s = modeldata["postprocessing"]["exported"][3]["field"]
# sxzskintop = s.values[nintertop, 1]
# File = filebase * "-sxz-$(extrap).CSV"
# savecsv(File, xstop=vec(topx)/phun("mm"),
# sxzskintop=vec(sxzskintop)/phun("MPa"),
# sxzcoretop=vec(sxzcoretop)/phun("MPa"),
# xsbot=vec(botx)/phun("mm"),
# sxzskinbot=vec(sxzskinbot)/phun("MPa"),
# sxzcorebot=vec(sxzcorebot)/phun("MPa"))
#
# @async run(`"paraview.exe" $File`)
println("count(fes) = $(count(fes))")
println("Timing: $( time() - t0 )")
true
end # Meyer_Piening_sandwich_MST10_timing
function Meyer_Piening_sandwich_T10_timing()
println("""
Meyer-Piening sandwich plate, mean-strain T10
""")
# Reference results from:
# [1] Application of the Elasticity Solution
# to Linear Sandwich Beam, Plate
# and Shell Analyses
# H.-R. MEYER -PIENING
# Journal of SANDWICH STRUCTURES AND MATERIALS , Vol. 6—July 2004
# Assessment of the refined sinus plate finite element:
# Free edge effect and Meyer-Piening sandwich test
# P. Vidal, O. Polit, M. D'Ottavio, E. Valot
# http://dx.doi.org/10.1016/j.finel.2014.08.004
#
# The second study deals with a benchmark problem proposed
# by Meyer-Piening [14]. It involves a simply -supported rectangular
# sandwich plate submitted to a localized pressure applied on an
# area of 5x20 mm. The geometry of the sandwich structure is
# given in Fig.13. Due to the symmetry, only one quarter of the plate
# is meshed. The faces have different thicknesses: h = 0.5 mm
# (bottom face), h = 0.1 mm (top face). The thickness of the core
# is h = 11.4 mm. The material properties are given in Table 3.
# Note that this benchmark involves strong heterogeneities (very
# different geometric and constitutive properties between core and
# face) and local stress gradient due to the localized pressure load.
#
# [14] H.-R. Meyer-Piening, Experiences with exact linear sandwich beam and plate
# analyses regarding bending, instability and frequency investigations, in:
# Proceedings of the Fifth International Conference On Sandwich Constructions,
# September 5–7, vol. I, Zurich, Switzerland, 2000, pp. 37–48.
filebase = "Meyer-Piening-sandwich-T10"
# Orthotropic material for the SKIN
E1s = 70000.0 * phun("MPa")
E2s = 71000.0 * phun("MPa")
E3s = 69000.0 * phun("MPa")
nu12s = nu13s = nu23s = 0.3
G12s = G13s = G23s = 26000.0 * phun("MPa")
CTE1 = CTE2 = CTE3 = 0.0
# Orthotropic material for the CORE
E1c = 3.0 * phun("MPa")
E2c = 3.0 * phun("MPa")
E3c = 2.8 * phun("MPa")
nu12c = nu13c = nu23c = 0.25
G12c = G13c = G23c = 1.0 * phun("MPa")
CTE1 = CTE2 = CTE3 = 0.0
Lx = 5.0 * phun("mm") # length of loaded rectangle
Ly = 20.0 * phun("mm") # length of loaded rectangle
Sx = 100.0 * phun("mm") # span of the plate
Sy = 200.0 * phun("mm") # span of the plate
# Here we define the layout and the thicknesses of the layers.
angles = vec([0.0 0.0 0.0])
ts = vec([0.5 11.4 0.1]) * phun("mm") # layer thicknesses
TH = sum(ts) # total thickness of the plate
tolerance = 0.0001 * TH
# The line load is in the negative Z direction.
q0 = 1 * phun("MPa") # line load
# Reference deflection under the load is
wtopref = -3.789 * phun("mm") # From [1]
wbottomref = -2.16 * phun("mm") # Not given in [1]; guessed from the figure
# Select how find the mesh should be
Refinement = 3
nL = Refinement * 1
nSx = nL + Refinement * 4
nSy = 2 * nSx
# Each layer is modeled with a single element.
nts = Refinement * [1, 2, 1]# number of elements per layer
strength = 1.5
sp = (a, b, n) -> MeshUtilModule.gradedspace(a, b, n, strength)
sp = (a, b, n) -> linearspace(a, b, n)
xs = unique(
vcat(
reverse(collect(sp(Lx / 2, 0.0, nL + 1))),
collect(sp(Lx / 2, Sx / 2, nSx - nL + 1)),
),
)
ys = unique(
vcat(
reverse(collect(MeshUtilModule.gradedspace(Ly / 2, 0.0, nL + 1))),
collect(sp(Ly / 2, Sy / 2, nSy - nL + 1)),
),
)
fens, fes = T10layeredplatex(xs, ys, ts, nts)
# This is the material model
MR = DeforModelRed3D
skinmaterial = MatDeforElastOrtho(
MR,
0.0,
E1s,
E2s,
E3s,
nu12s,
nu13s,
nu23s,
G12s,
G13s,
G23s,
CTE1,
CTE2,
CTE3,
)
corematerial = MatDeforElastOrtho(
MR,
0.0,
E1c,
E2c,
E3c,
nu12c,
nu13c,
nu23c,
G12c,
G13c,
G23c,
CTE1,
CTE2,
CTE3,
)
# The material coordinate system function is defined as:
function _updatecs!(csmatout::FFltMat, feid::FInt, label)
rotmat3!(csmatout, angles[label] / 180.0 * pi * [0.0; 0.0; 1.0])
csmatout
end
# The volume integrals are evaluated using this rule
gr = SimplexRule(3, 4)
# We will create three regions, two for the skin, and one for the core.
rfes = subset(fes, selectelem(fens, fes, label = 1))
botskinregion = FDataDict(
"femm" => FEMMDeforLinearMST10(
MR,
IntegDomain(rfes, gr),
CSys(
3,
3,
(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) -> _updatecs!(csmatout, feid, 1),
),
skinmaterial,
),
)
rfes = subset(fes, selectelem(fens, fes, label = 3))
topskinregion = FDataDict(
"femm" => FEMMDeforLinearMST10(
MR,
IntegDomain(rfes, gr),
CSys(
3,
3,
(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) -> _updatecs!(csmatout, feid, 3),
),
skinmaterial,
),
)
rfes = subset(fes, selectelem(fens, fes, label = 2))
coreregion = FDataDict(
"femm" => FEMMDeforLinearMST10(
MR,
IntegDomain(rfes, gr),
CSys(
3,
3,
(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) -> _updatecs!(csmatout, feid, 2),
),
corematerial,
),
)
# File = "Meyer_Piening_sandwich-r1.vtk"
# vtkexportmesh(File, botskinregion["femm"].integdomain.fes.conn, fens.xyz,
# FinEtools.MeshExportModule.T10)
# # @async run(`"paraview.exe" $File`)
# File = "Meyer_Piening_sandwich-r2.vtk"
# vtkexportmesh(File, coreregion["femm"].integdomain.fes.conn, fens.xyz,
# FinEtools.MeshExportModule.T10)
# @async run(`"paraview.exe" $File`)
# The essential boundary conditions are applied on the symmetry planes.
# First the plane X=0;...
lx0 = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
ex0 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lx0)
# ... and then the plane Y=0.
ly0 = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
ey0 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => ly0)
# The transverse displacement is fixed around the circumference.
lz0 = vcat(
selectnode(fens, box = [Sx / 2 Sx / 2 -Inf Inf -Inf Inf], inflate = tolerance),
selectnode(fens, box = [-Inf Inf Sy / 2 Sy / 2 -Inf Inf], inflate = tolerance),
)
ez0 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lz0)
# The traction boundary condition is applied along rectangle in the middle of the plate.
bfes = meshboundary(fes)
# From the entire boundary we select those quadrilaterals that lie on the plane
# Z = thickness
tl = selectelem(fens, bfes, box = [0.0 Lx / 2 0 Ly / 2 TH TH], inflate = tolerance)
Trac = FDataDict(
"traction_vector" => vec([0.0; 0.0; -q0]),
"femm" => FEMMBase(IntegDomain(subset(bfes, tl), SimplexRule(2, 3))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [botskinregion, coreregion, topskinregion],
"essential_bcs" => [ex0, ey0, ez0],
"traction_bcs" => [Trac],
)
t0 = time()
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
tstiffness = modeldata["timing"]["stiffness"]
tsolution = modeldata["timing"]["solution"]
println("count(fes) = $(count(fes))")
println("Timing: Assembly $(tstiffness), Solution $(tsolution)")
modeldata["postprocessing"] = FDataDict("file" => filebase * "-u")
modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# The results of the displacement and stresses will be reported at
# nodes located at the appropriate points.
nbottomcenter = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 0.0], inflate = tolerance)
ntopcenter = selectnode(fens, box = [0.0 0.0 0.0 0.0 TH TH], inflate = tolerance)
# ncenterline = selectnode(fens, box=[0.0 0.0 0.0 0.0 0.0 TH], inflate=tolerance)
# nintertop = selectnode(fens, box=[-Inf Inf 0.0 0.0 sum(ts[1:2]) sum(ts[1:2])], inflate=tolerance)
# ninterbot = selectnode(fens, box=[-Inf Inf 0.0 0.0 sum(ts[1:1]) sum(ts[1:1])], inflate=tolerance)
#
# zclo = sortperm(vec(geom.values[ncenterline, 3]))
# ncenterline = ncenterline[zclo]
# centerz = geom.values[ncenterline, 3]
# zclo = nothing
#
# xclotop = sortperm(vec(geom.values[nintertop, 1]))
# nintertop = nintertop[xclotop]
# topx = geom.values[nintertop, 1]
# xclobot = sortperm(vec(geom.values[ninterbot, 1]))
# ninterbot = ninterbot[xclobot]
# botx = geom.values[ninterbot, 1]
# xclotop = xclobot = nothing
#
# conninbotskin = intersect(connectednodes(botskinregion["femm"].integdomain.fes), ncenterline)
# connincore = intersect(connectednodes(coreregion["femm"].integdomain.fes), ncenterline)
# connintopskin = intersect(connectednodes(topskinregion["femm"].integdomain.fes), ncenterline)
# inbotskin = [n in conninbotskin for n in ncenterline]
# incore = [n in connincore for n in ncenterline]
# intopskin = [n in connintopskin for n in ncenterline]
println("")
println("Top Center deflection: $(u.values[ntopcenter, 3]/phun("mm")) [mm]")
println("Bottom Center deflection: $(u.values[nbottomcenter, 3]/phun("mm")) [mm]")
# # # extrap = :extrapmean
# extrap = :extraptrend
# nodevalmeth = :averaging
# # extrap = :default
# # nodevalmeth = :invdistance
#
# # Normal stress in the X direction
# modeldata["postprocessing"] = FDataDict("file"=>filebase * "-sx",
# "quantity"=>:Cauchy, "component"=>1, "outputcsys"=>CSys(3),
# "nodevalmethod"=>nodevalmeth, "reportat"=>extrap)
# modeldata = AlgoDeforLinearModule.exportstress(modeldata)
# s = modeldata["postprocessing"]["exported"][1]["field"]
# sxbot = s.values[ncenterline, 1]
# s = modeldata["postprocessing"]["exported"][2]["field"]
# sxcore = s.values[ncenterline, 1]
# s = modeldata["postprocessing"]["exported"][3]["field"]
# sxtop = s.values[ncenterline, 1]
#
# # The graph data needs to be collected by going through each layer separately.
# # Some quantities may be discontinuous between layers.
# zs = vcat( [z for (j,z) in enumerate(centerz) if inbotskin[j]],
# [z for (j,z) in enumerate(centerz) if incore[j]],
# [z for (j,z) in enumerate(centerz) if intopskin[j]]
# )
# sxs = vcat( [sxbot[j] for (j,z) in enumerate(centerz) if inbotskin[j]],
# [sxcore[j] for (j,z) in enumerate(centerz) if incore[j]],
# [sxtop[j] for (j,z) in enumerate(centerz) if intopskin[j]]
# )
# File = filebase * "-sx-$(extrap).CSV"
# savecsv(File, zs=vec(zs)/phun("mm"), sx=vec(sxs)/phun("MPa"))
#
# # @async run(`"paraview.exe" $File`)
#
# # Inter laminar stress between the skin and the core
# modeldata["postprocessing"] = FDataDict("file"=>filebase * "-sxz",
# "quantity"=>:Cauchy, "component"=>5, "outputcsys"=>CSys(3),
# "nodevalmethod"=>nodevalmeth, "reportat"=>extrap)
# modeldata = AlgoDeforLinearModule.exportstress(modeldata)
# s = modeldata["postprocessing"]["exported"][1]["field"]
# sxzskinbot = s.values[ninterbot, 1]
# s = modeldata["postprocessing"]["exported"][2]["field"]
# sxzcoretop = s.values[nintertop, 1]
# sxzcorebot = s.values[ninterbot, 1]
# s = modeldata["postprocessing"]["exported"][3]["field"]
# sxzskintop = s.values[nintertop, 1]
# File = filebase * "-sxz-$(extrap).CSV"
# savecsv(File, xstop=vec(topx)/phun("mm"),
# sxzskintop=vec(sxzskintop)/phun("MPa"),
# sxzcoretop=vec(sxzcoretop)/phun("MPa"),
# xsbot=vec(botx)/phun("mm"),
# sxzskinbot=vec(sxzskinbot)/phun("MPa"),
# sxzcorebot=vec(sxzcorebot)/phun("MPa"))
#
# @async run(`"paraview.exe" $File`)
true
end # Meyer_Piening_sandwich_T10_timing
function allrun()
println("#####################################################")
println("# Meyer_Piening_sandwich ")
Meyer_Piening_sandwich()
println("#####################################################")
println("# Meyer_Piening_sandwich_H20 ")
Meyer_Piening_sandwich_H20()
println("#####################################################")
println("# Meyer_Piening_sandwich_H8 ")
Meyer_Piening_sandwich_H8()
println("#####################################################")
println("# Meyer_Piening_sandwich_MSH8 ")
Meyer_Piening_sandwich_MSH8()
println("#####################################################")
println("# Meyer_Piening_sandwich_MST10 ")
Meyer_Piening_sandwich_MST10()
println("#####################################################")
println("# Meyer_Piening_sandwich_MST10_timing ")
Meyer_Piening_sandwich_MST10_timing()
println("#####################################################")
println("# Meyer_Piening_sandwich_T10_timing ")
Meyer_Piening_sandwich_T10_timing()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 47171 | """
Composite tests
R0031(1): Laminated strip under three-point bending
R0031(2): Wrapped thick cylinder under pressure and thermal loading
R0031(3): Three-layer sandwich shell under normal pressure loading
"""
module NAFEMS_R0031_examples
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using Statistics: mean
using LinearAlgebra: norm, cross
function NAFEMS_R0031_1_msh8()
println("""
Laminated Strip Under Three-Point Bending. Mean-strain h8 elements.
""")
# Determine the central transverse displacement in a simply-supported seven
# layer symmetric strip with a central line load. A 0/90/0/90/0/90/0
# material lay-up is specified with the center ply being four times as
# thick as the others.
# Reference: NAFEMS Report R0031, Test No.1, 17-Dec-1998.
# Because of the symmetries of the geometry and load, only the
# first-quadrant (in XY) quarter of the plate is modeled.
# The coordinate system is centered at point E (at the difference with
# respect to the original benchmark definition). The load is applied
# along a curve passing through point C. The simple support is applied
# along the curve passing through point B.
# We realize the simple supports along the lines A, B and the line load at
# point C are illegal from the point of view of convergence. No
# convergence can be hoped for as the stress underneath the load and above
# the simple supports is infinite in the limit (these locations are stress
# singularities). However, for relatively coarse meshes the results away
# from the singularities are still meaningful.
# The target quantities are displacement at the bottom surface at point E,
# the tensile axial stress at the same point, and of the transverse shear
# stress at point D in between the bottommost two layers (See figure 1).
t0 = time()
# Orthotropic material parameters of the material of the layers
E1s = 100.0 * phun("GPa")
E2s = E3s = 5.0 * phun("GPa")
nu12s = 0.4
nu13s = 0.3
nu23s = 0.3
G12s = 3.0 * phun("GPa")
G13s = G23s = 2.0 * phun("GPa")
CTE1 = 3.0e-6
CTE2 = 2.0e-5
CTE3 = 2.0e-5
AB = 30.0 * phun("mm") # span between simple supports
CD = 4.0 * phun("mm") # distance between the point D and the center
OH = 10.0 * phun("mm") # overhang
W = 10.0 * phun("mm") # width of the strip
# Here we define the layout and the thicknesses of the layers.
angles = vec([0 90 0 90 0 90 0])
ts = vec([0.1 0.1 0.1 0.4 0.1 0.1 0.1]) * phun("mm") # layer thicknesses
TH = sum(ts) # total thickness of the plate
tolerance = 0.0001 * TH
# The line load is in the negative Z direction.
q0 = 10 * phun("N/mm") # line load
# Reference deflection under the load is
wEref = -1.06 * phun("mm")
# The reference tensile stress at the bottom of the lowest layer is
sigma11Eref = 684 * phun("MPa")
# Because we model the first-quadrant quarter of the plate using
# coordinate axes centered at the point E the shear at the point D is
# positive instead of negative as in the benchmark where the coordinate
# system is located at the outer corner of the strip.
sigma13Dref = 4.1 * phun("MPa")
Refinement = 10
# We select 8 elements spanwise and 2 elements widthwise. The overhang
# of the plate is given one element.
nL = Refinement * 4
nO = Refinement * 1
nW = Refinement * 1
# Each layer is modeled with a single element.
nts = Refinement * ones(Int, length(angles))# number of elements per layer
xs = unique(
vcat(
collect(linearspace(0.0, AB / 2, nL + 1)),
[CD],
collect(linearspace(AB / 2, AB / 2 + OH, nO + 1)),
),
)
xs = xs[sortperm(xs)]
ys = collect(linearspace(0.0, W / 2, nW + 1))
fens, fes = H8layeredplatex(xs, ys, ts, nts)
# This is the material model
MR = DeforModelRed3D
material = MatDeforElastOrtho(
MR,
0.0,
E1s,
E2s,
E3s,
nu12s,
nu13s,
nu23s,
G12s,
G13s,
G23s,
CTE1,
CTE2,
CTE3,
)
# The material coordinate system function is defined as:
function _updatecs!(csmatout, feid, labels)
rotmat3!(csmatout, angles[labels[feid]] / 180.0 * pi * [0.0; 0.0; 1.0])
csmatout
end
# The vvolume integrals are evaluated using this rule
gr = GaussRule(3, 2)
# We will create two regions, one for the layers with 0° orientation,
# and one for the layers with 90° orientation.
rl1 = vcat(
selectelem(fens, fes, label = 1),
selectelem(fens, fes, label = 3),
selectelem(fens, fes, label = 5),
selectelem(fens, fes, label = 7),
)
rfes1 = subset(fes, rl1)
region1 = FDataDict(
"femm" => FEMMDeforLinearMSH8(
MR,
IntegDomain(rfes1, gr),
CSys(
3,
3,
(csmatout, XYZ, tangents, feid, qpid) ->
_updatecs!(csmatout, feid, rfes1.label),
),
material,
),
)
rl2 = vcat(
selectelem(fens, fes, label = 2),
selectelem(fens, fes, label = 4),
selectelem(fens, fes, label = 6),
)
rfes2 = subset(fes, rl2)
region2 = FDataDict(
"femm" => FEMMDeforLinearMSH8(
MR,
IntegDomain(rfes2, gr),
CSys(
3,
3,
(csmatout, XYZ, tangents, feid, qpid) ->
_updatecs!(csmatout, feid, rfes2.label),
),
material,
),
)
# File = "NAFEMS-R0031-1-plate-r1.vtk"
# vtkexportmesh(File, region1["femm"].integdomain.fes.conn, fens.xyz, FinEtools.MeshExportModule.H8)
# # @async run(`"paraview.exe" $File`)
# File = "NAFEMS-R0031-1-plate-r2.vtk"
# vtkexportmesh(File, region2["femm"].integdomain.fes.conn, fens.xyz, FinEtools.MeshExportModule.H8)
# @async run(`"paraview.exe" $File`)
# The essential boundary conditions are applied on the symmetry planes.
# First the plane X=0;...
lx0 = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
ex0 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lx0)
# ... and then the plane Y=0.
ly0 = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
ey0 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => ly0)
# The transverse displacement is fixed along the line passing through
# point B. The nodes are fixed in the box along this line in the Z
# direction.
lz0 = selectnode(fens, box = [AB / 2 AB / 2 -Inf Inf -Inf Inf], inflate = tolerance)
ez0 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lz0)
# The traction boundary condition is applied along the edge of the
# mesh passing through point C at the top surface of the strip. First
# we extract the boundary of the hexahedral mesh.
bfes = meshboundary(fes)
# From the entire boundary we select those quadrilaterals that lie on the plane
# X = 0
xl = selectelem(fens, bfes, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
# Now we extract the boundary of these selected quadrilaterals
bbfes = meshboundary(subset(bfes, xl))
# … And from these we extract the ones at the top
zl = selectelem(fens, bbfes, box = [0.0 0.0 -Inf Inf TH TH], inflate = tolerance)
# Note that we have to apply only half of the line load given that
# were modeling just one quarter of the geometry and we are splitting
# the line load with the symmetry plane X=0. Also note that the
# quadrature rule is one-dimensional since we are integrating along
# a curve.
Trac = FDataDict(
"traction_vector" => vec([0.0; 0.0; -q0 / 2]),
"femm" => FEMMBase(IntegDomain(subset(bbfes, zl), GaussRule(1, 3))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1, region2],
"essential_bcs" => [ex0, ey0, ez0],
"traction_bcs" => [Trac],
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
modeldata["postprocessing"] = FDataDict("file" => "NAFEMS_R0031_1_msh8-plate")
modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# The results of the displacement and stresses will be reported at
# nodes located at the appropriate points.
nE = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 0.0], inflate = tolerance)
nC = selectnode(fens, box = [0.0 0.0 0.0 0.0 TH TH], inflate = tolerance)
nD = selectnode(fens, box = [CD CD 0.0 0.0 ts[1] ts[1]], inflate = tolerance)
n0z = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 TH], inflate = tolerance)
ix = sortperm(geom.values[n0z, 3])
# println("ix = $(ix)")
cdis = mean(u.values[nE, 3])
println("")
println("Normalized Center deflection: $(cdis/wEref)")
extrap = :extraptrend
# # extrap = :extrapmean
inspectormeth = :averaging
# extrap = :default
# inspectormeth = :invdistance
modeldata["postprocessing"] = FDataDict(
"file" => "NAFEMS_R0031_1_msh8-plate-sx",
"quantity" => :Cauchy,
"component" => 1,
"outputcsys" => CSys(3),
"nodevalmethod" => inspectormeth,
"reportat" => extrap,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
s = modeldata["postprocessing"]["exported"][1]["field"]
println("sx@E = $(s.values[nE]/phun("MPa")) [MPa]")
println("Reference sx@E = $(sigma11Eref/phun("MPa")) [MPa]")
modeldata["postprocessing"] = FDataDict(
"file" => "NAFEMS_R0031_1_msh8-plate-sxz",
"quantity" => :Cauchy,
"component" => 5,
"outputcsys" => CSys(3),
"nodevalmethod" => inspectormeth,
"reportat" => extrap,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
s = modeldata["postprocessing"]["exported"][1]["field"]
println("sxz@D_1 = $(s.values[nD]/phun("MPa")) [MPa]")
s = modeldata["postprocessing"]["exported"][2]["field"]
println("sxz@D_2 = $(s.values[nD]/phun("MPa")) [MPa]")
println("Reference sxz@D = $(sigma13Dref/phun("MPa")) [MPa]")
println("Done")
true
end # NAFEMS_R0031_1
function NAFEMS_R0031_1_esnice_h8()
println("""
Laminated Strip Under Three-Point Bending. ESNICE h8 elements.
""")
# Determine the central transverse displacement in a simply-supported seven
# layer symmetric strip with a central line load. A 0/90/0/90/0/90/0
# material lay-up is specified with the center ply being four times as
# thick as the others.
# Reference: NAFEMS Report R0031, Test No.1, 17-Dec-1998.
# Because of the symmetries of the geometry and load, only the
# first-quadrant (in XY) quarter of the plate is modeled.
# The coordinate system is centered at point E (at the difference with
# respect to the original benchmark definition). The load is applied
# along a curve passing through point C. The simple support is applied
# along the curve passing through point B.
# We realize the simple supports along the lines A, B and the line load at
# point C are illegal from the point of view of convergence. No
# convergence can be hoped for as the stress underneath the load and above
# the simple supports is infinite in the limit (these locations are stress
# singularities). However, for relatively coarse meshes the results away
# from the singularities are still meaningful.
# The target quantities are displacement at the bottom surface at point E,
# the tensile axial stress at the same point, and of the transverse shear
# stress at point D in between the bottommost two layers (See figure 1).
t0 = time()
# Orthotropic material parameters of the material of the layers
E1s = 100.0 * phun("GPa")
E2s = E3s = 5.0 * phun("GPa")
nu12s = 0.4
nu13s = 0.3
nu23s = 0.3
G12s = 3.0 * phun("GPa")
G13s = G23s = 2.0 * phun("GPa")
CTE1 = 3.0e-6
CTE2 = 2.0e-5
CTE3 = 2.0e-5
AB = 30.0 * phun("mm") # span between simple supports
CD = 4.0 * phun("mm") # distance between the point D and the center
OH = 10.0 * phun("mm") # overhang
W = 10.0 * phun("mm") # width of the strip
# Here we define the layout and the thicknesses of the layers. Region 1 has
# orientation 0 degrees, and region 2 has orientation 90 degrees.
angles = vec([0 90])
ts = vec([0.1 0.1 0.1 0.4 0.1 0.1 0.1]) * phun("mm") # layer thicknesses
TH = sum(ts) # total thickness of the plate
tolerance = 0.0001 * TH
# The line load is in the negative Z direction.
q0 = 10 * phun("N/mm") # line load
# Reference deflection under the load is
wEref = -1.06 * phun("mm")
# The reference tensile stress at the bottom of the lowest layer is
sigma11Eref = 684 * phun("MPa")
# Because we model the first-quadrant quarter of the plate using
# coordinate axes centered at the point E the shear at the point D is
# positive instead of negative as in the benchmark where the coordinate
# system is located at the outer corner of the strip.
sigma13Dref = 4.1 * phun("MPa")
Refinement = 4
# We select 8 elements spanwise and 2 elements widthwise. The overhang
# of the plate is given one element.
nL = Refinement * 4
nO = Refinement * 1
nW = Refinement * 1
# Each layer is modeled with a single element.
nts = Refinement * ones(Int, length(ts))# number of elements per layer
xs = unique(
vcat(
collect(linearspace(0.0, AB / 2, nL + 1)),
[CD],
collect(linearspace(AB / 2, AB / 2 + OH, nO + 1)),
),
)
xs = xs[sortperm(xs)]
ys = collect(linearspace(0.0, W / 2, nW + 1))
fens, fes = H8layeredplatex(xs, ys, ts, nts)
# This is the material model
MR = DeforModelRed3D
material = MatDeforElastOrtho(
MR,
0.0,
E1s,
E2s,
E3s,
nu12s,
nu13s,
nu23s,
G12s,
G13s,
G23s,
CTE1,
CTE2,
CTE3,
)
# The material coordinate system function is defined as:
function _updatecs!(csmatout, feid, labels)
rotmat3!(csmatout, angles[feid] / 180.0 * pi * [0.0; 0.0; 1.0])
csmatout
end
# The vvolume integrals are evaluated using this rule
gr = TrapezoidalRule(3)
# We will create two regions, one for the layers with 0° orientation,
# and one for the layers with 90° orientation.
rl1 = vcat(
selectelem(fens, fes, label = 1),
selectelem(fens, fes, label = 3),
selectelem(fens, fes, label = 5),
selectelem(fens, fes, label = 7),
)
rfes1 = subset(fes, rl1)
region1 = FDataDict(
"femm" => FEMMDeforLinearESNICEH8(
MR,
IntegDomain(rfes1, gr),
CSys(
3,
3,
(csmatout, XYZ, tangents, feid, qpid) -> _updatecs!(csmatout, 1, []),
),
material,
),
)
rl2 = vcat(
selectelem(fens, fes, label = 2),
selectelem(fens, fes, label = 4),
selectelem(fens, fes, label = 6),
)
rfes2 = subset(fes, rl2)
region2 = FDataDict(
"femm" => FEMMDeforLinearESNICEH8(
MR,
IntegDomain(rfes2, gr),
CSys(
3,
3,
(csmatout, XYZ, tangents, feid, qpid) -> _updatecs!(csmatout, 2, []),
),
material,
),
)
# File = "NAFEMS-R0031-1-plate-r1.vtk"
# vtkexportmesh(File, region1["femm"].integdomain.fes.conn, fens.xyz, FinEtools.MeshExportModule.H8)
# # @async run(`"paraview.exe" $File`)
# File = "NAFEMS-R0031-1-plate-r2.vtk"
# vtkexportmesh(File, region2["femm"].integdomain.fes.conn, fens.xyz, FinEtools.MeshExportModule.H8)
# @async run(`"paraview.exe" $File`)
# The essential boundary conditions are applied on the symmetry planes.
# First the plane X=0;...
lx0 = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
ex0 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lx0)
# ... and then the plane Y=0.
ly0 = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
ey0 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => ly0)
# The transverse displacement is fixed along the line passing through
# point B. The nodes are fixed in the box along this line in the Z
# direction.
lz0 = selectnode(fens, box = [AB / 2 AB / 2 -Inf Inf -Inf Inf], inflate = tolerance)
ez0 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lz0)
# The traction boundary condition is applied along the edge of the
# mesh passing through point C at the top surface of the strip. First
# we extract the boundary of the hexahedral mesh.
bfes = meshboundary(fes)
# From the entire boundary we select those quadrilaterals that lie on the plane
# X = 0
xl = selectelem(fens, bfes, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
# Now we extract the boundary of these selected quadrilaterals
bbfes = meshboundary(subset(bfes, xl))
# … And from these we extract the ones at the top
zl = selectelem(fens, bbfes, box = [0.0 0.0 -Inf Inf TH TH], inflate = tolerance)
# Note that we have to apply only half of the line load given that
# were modeling just one quarter of the geometry and we are splitting
# the line load with the symmetry plane X=0. Also note that the
# quadrature rule is one-dimensional since we are integrating along
# a curve.
Trac = FDataDict(
"traction_vector" => vec([0.0; 0.0; -q0 / 2]),
"femm" => FEMMBase(IntegDomain(subset(bbfes, zl), TrapezoidalRule(1))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1, region2],
"essential_bcs" => [ex0, ey0, ez0],
"traction_bcs" => [Trac],
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
modeldata["postprocessing"] = FDataDict("file" => "NAFEMS-R0031-1-plate-esnice-h8")
modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# The results of the displacement and stresses will be reported at
# nodes located at the appropriate points.
nE = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 0.0], inflate = tolerance)
nC = selectnode(fens, box = [0.0 0.0 0.0 0.0 TH TH], inflate = tolerance)
nD = selectnode(fens, box = [CD CD 0.0 0.0 ts[1] ts[1]], inflate = tolerance)
n0z = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 TH], inflate = tolerance)
ix = sortperm(geom.values[n0z, 3])
# println("ix = $(ix)")
cdis = mean(u.values[nE, 3])
println("")
println("Normalized Center deflection: $(cdis/wEref)")
extrap = :extraptrend
# # extrap = :extrapmean
inspectormeth = :averaging
# extrap = :default
# inspectormeth = :invdistance
modeldata["postprocessing"] = FDataDict(
"file" => "NAFEMS-R0031-1-plate-esnice-h8-sx",
"quantity" => :Cauchy,
"component" => 1,
"outputcsys" => CSys(3),
"nodevalmethod" => inspectormeth,
"reportat" => extrap,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
s = modeldata["postprocessing"]["exported"][1]["field"]
println("sx@E = $(s.values[nE]/phun("MPa")) [MPa]")
println("Reference sx@E = $(sigma11Eref/phun("MPa")) [MPa]")
modeldata["postprocessing"] = FDataDict(
"file" => "NAFEMS-R0031-1-plate-esnice-h8-sxz",
"quantity" => :Cauchy,
"component" => 5,
"outputcsys" => CSys(3),
"nodevalmethod" => inspectormeth,
"reportat" => extrap,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
s = modeldata["postprocessing"]["exported"][1]["field"]
println("sxz@D_1 = $(s.values[nD]/phun("MPa")) [MPa]")
s = modeldata["postprocessing"]["exported"][2]["field"]
println("sxz@D_2 = $(s.values[nD]/phun("MPa")) [MPa]")
println("Reference sxz@D = $(sigma13Dref/phun("MPa")) [MPa]")
#
# s = fieldfromintegpoints(region1["femm"], geom, u, :Cauchy, 1;
# outputcsys = CSys(3), nodevalmethod = inspectormeth, reportat = extrap)
# println("sx@E = $(s.values[nE]/phun("MPa")) [MPa]")
# sx_z = s.values[n0z]/phun("MPa")
# println("sx(z)_1 = $(sx_z)")
#
# s = fieldfromintegpoints(region1["femm"], geom, u, :Cauchy, 5;
# outputcsys = CSys(3), nodevalmethod = inspectormeth, reportat = extrap)
# println("sxz@D_1 = $(s.values[nD]/phun("MPa")) [MPa]")
# sxz_z_1 = s.values[n0z]/phun("MPa")
# println("sxz(z)_1 = $(sxz_z_1)")
# s = fieldfromintegpoints(region2["femm"], geom, u, :Cauchy, 5;
# outputcsys = CSys(3), nodevalmethod = inspectormeth, reportat = extrap)
# println("sxz@D_2 = $(s.values[nD]/phun("MPa")) [MPa]")
# sxz_z_2 = s.values[n0z]/phun("MPa")
# println("sxz(z)_2 = $(sxz_z_2)")
# function _inspector(idat, elnum, conn, xe, out, xq)
# # xe = coordinates of the nodes of the element
# # xq = coordinate of the quadrature point
# println("@$(xq): $(out/1.0e6)")
# return idat
# end
#
# felist = selectelem(fens, region1["femm"].integdomain.fes,
# box=[0.0 0.0 0.0 0.0 0.0 0.0], inflate=tolerance, allin = false)
#
# inspectintegpoints(region1["femm"], geom, u, felist,
# _inspector, 0, quantity=:Cauchy, outputcsys = CSys(3))
#
# femm = deepcopy(region1["femm"])
# femm.integdomain.fes = subset(femm.integdomain.fes, felist)
# associategeometry!(femm, geom)
# s = fieldfromintegpoints(femm, geom, u, :Cauchy, 5;
# outputcsys = CSys(3), nodevalmethod = inspectormeth, reportat = extrap)
# println("sxz@D_1 = $(s.values[nD]/phun("MPa")) [MPa]")
# felist = selectelem(fens, region2["femm"].integdomain.fes,
# box=[0.0 0.0 0.0 0.0 0.0 TH], inflate=tolerance, allin = false)
#
# inspectintegpoints(region2["femm"], geom, u, felist,
# _inspector, 0, quantity=:Cauchy, outputcsys = CSys(3))
println("Done")
true
end # NAFEMS_R0031_1
function NAFEMS_R0031_1_H20()
println("""
Laminated Strip Under Three-Point Bending. H20 hexahedral elements.
""")
# Determine the central transverse displacement in a simply-supported seven
# layer symmetric strip with a central line load. A 0/90/0/90/0/90/0
# material lay-up is specified with the center ply being four times as
# thick as the others.
# Reference: NAFEMS Report R0031, Test No.1, 17-Dec-1998.
# Because of the symmetries of the geometry and load, only the
# first-quadrant (in XY) quarter of the plate is modeled.
# The coordinate system is centered at point E (at the difference with
# respect to the original benchmark definition). The load is applied
# along a curve passing through point C. The simple support is applied
# along the curve passing through point B.
# We realize the simple supports along the lines A, B and the line load at
# point C are illegal from the point of view of convergence. No
# convergence can be hoped for as the stress underneath the load and above
# the simple supports is infinite in the limit (these locations are stress
# singularities). However, for relatively coarse meshes the results away
# from the singularities are still meaningful.
# The target quantities are displacement at the bottom surface at point E,
# the tensile axial stress at the same point, and of the transverse shear
# stress at point D in between the bottommost two layers (See figure 1).
t0 = time()
# Orthotropic material parameters of the material of the layers
E1s = 100.0 * phun("GPa")
E2s = E3s = 5.0 * phun("GPa")
nu12s = 0.4
nu13s = 0.3
nu23s = 0.3
G12s = 3.0 * phun("GPa")
G13s = G23s = 2.0 * phun("GPa")
CTE1 = 3.0e-6
CTE2 = 2.0e-5
CTE3 = 2.0e-5
AB = 30.0 * phun("mm") # span between simple supports
CD = 4.0 * phun("mm") # distance between the point D and the center
OH = 10.0 * phun("mm") # overhang
W = 10.0 * phun("mm") # width of the strip
# Here we define the layout and the thicknesses of the layers.
angles = vec([0 90 0 90 0 90 0])
ts = vec([0.1 0.1 0.1 0.4 0.1 0.1 0.1]) * phun("mm") # layer thicknesses
TH = sum(ts) # total thickness of the plate
tolerance = 0.0001 * TH
# The line load is in the negative Z direction.
q0 = 10 * phun("N/mm") # line load
# Reference deflection under the load is
wEref = -1.06 * phun("mm")
# The reference tensile stress at the bottom of the lowest layer is
sigma11Eref = 684 * phun("MPa")
# Because we model the first-quadrant quarter of the plate using
# coordinate axes centered at the point E the shear at the point D is
# positive instead of negative as in the benchmark where the coordinate
# system is located at the outer corner of the strip.
sigma13Dref = 4.1 * phun("MPa")
Refinement = 8
# We select 8 elements spanwise and 2 elements widthwise. The overhang
# of the plate is given one element.
nL = Refinement * 4
nO = Refinement * 1
nW = Refinement * 1
# Each layer is modeled with a single element.
nts = Refinement * ones(Int, length(angles))# number of elements per layer
xs = unique(
vcat(
collect(linearspace(0.0, AB / 2, nL + 1)),
[CD],
collect(linearspace(AB / 2, AB / 2 + OH, nO + 1)),
),
)
xs = xs[sortperm(xs)]
ys = collect(linearspace(0.0, W / 2, nW + 1))
fens, fes = H8layeredplatex(xs, ys, ts, nts)
fens, fes = H8toH20(fens, fes)
# This is the material model
MR = DeforModelRed3D
material = MatDeforElastOrtho(
MR,
0.0,
E1s,
E2s,
E3s,
nu12s,
nu13s,
nu23s,
G12s,
G13s,
G23s,
CTE1,
CTE2,
CTE3,
)
# The material coordinate system function is defined as:
function _updatecs!(csmatout, feid, labels)
rotmat3!(csmatout, angles[labels[feid]] / 180.0 * pi * [0.0; 0.0; 1.0])
csmatout
end
# The vvolume integrals are evaluated using this rule
gr = GaussRule(3, 3)
# We will create two regions, one for the layers with 0° orientation,
# and one for the layers with 90° orientation.
rl1 = vcat(
selectelem(fens, fes, label = 1),
selectelem(fens, fes, label = 3),
selectelem(fens, fes, label = 5),
selectelem(fens, fes, label = 7),
)
rfes1 = subset(fes, rl1)
region1 = FDataDict(
"femm" => FEMMDeforLinear(
MR,
IntegDomain(rfes1, gr),
CSys(
3,
3,
(csmatout, XYZ, tangents, feid, qpid) ->
_updatecs!(csmatout, feid, rfes1.label),
),
material,
),
)
rl2 = vcat(
selectelem(fens, fes, label = 2),
selectelem(fens, fes, label = 4),
selectelem(fens, fes, label = 6),
)
rfes2 = subset(fes, rl2)
region2 = FDataDict(
"femm" => FEMMDeforLinear(
MR,
IntegDomain(rfes2, gr),
CSys(
3,
3,
(csmatout, XYZ, tangents, feid, qpid) ->
_updatecs!(csmatout, feid, rfes2.label),
),
material,
),
)
# File = "NAFEMS-R0031-1-plate-r1.vtk"
# vtkexportmesh(File, region1["femm"].integdomain.fes.conn, fens.xyz, FinEtools.MeshExportModule.H8)
# # @async run(`"paraview.exe" $File`)
# File = "NAFEMS-R0031-1-plate-r2.vtk"
# vtkexportmesh(File, region2["femm"].integdomain.fes.conn, fens.xyz, FinEtools.MeshExportModule.H8)
# @async run(`"paraview.exe" $File`)
# The essential boundary conditions are applied on the symmetry planes.
# First the plane X=0;...
lx0 = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
ex0 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lx0)
# ... and then the plane Y=0.
ly0 = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
ey0 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => ly0)
# The transverse displacement is fixed along the line passing through
# point B. The nodes are fixed in the box along this line in the Z
# direction.
lz0 = selectnode(fens, box = [AB / 2 AB / 2 -Inf Inf 0.0 0.0], inflate = tolerance)
ez0 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lz0)
# The traction boundary condition is applied along the edge of the
# mesh passing through point C at the top surface of the strip. First
# we extract the boundary of the hexahedral mesh.
bfes = meshboundary(fes)
# From the entire boundary we select those quadrilaterals that lie on the plane
# X = 0
xl = selectelem(fens, bfes, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
# Now we extract the boundary of these selected quadrilaterals
bbfes = meshboundary(subset(bfes, xl))
# … And from these we extract the ones at the top
zl = selectelem(fens, bbfes, box = [0.0 0.0 -Inf Inf TH TH], inflate = tolerance)
# Note that we have to apply only half of the line load given that
# were modeling just one quarter of the geometry and we are splitting
# the line load with the symmetry plane X=0. Also note that the
# quadrature rule is one-dimensional since we are integrating along
# a curve.
Trac = FDataDict(
"traction_vector" => vec([0.0; 0.0; -q0 / 2]),
"femm" => FEMMBase(IntegDomain(subset(bbfes, zl), GaussRule(1, 3))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1, region2],
"essential_bcs" => [ex0, ey0, ez0],
"traction_bcs" => [Trac],
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
modeldata["postprocessing"] = FDataDict("file" => "NAFEMS_R0031_1_H20-plate")
modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# The results of the displacement and stresses will be reported at
# nodes located at the appropriate points.
nE = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 0.0], inflate = tolerance)
nC = selectnode(fens, box = [0.0 0.0 0.0 0.0 TH TH], inflate = tolerance)
nD = selectnode(fens, box = [CD CD 0.0 0.0 ts[1] ts[1]], inflate = tolerance)
cdis = mean(u.values[nE, 3])
println("")
println("Normalized Center deflection: $(cdis/wEref)")
modeldata["postprocessing"] = FDataDict(
"file" => "NAFEMS_R0031_1_H20-plate-sx",
"quantity" => :Cauchy,
"component" => 1,
"outputcsys" => CSys(3),
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
s = modeldata["postprocessing"]["exported"][1]["field"]
println("sx@E = $(s.values[nE]/phun("MPa")) [MPa]")
println("Reference sx@E = $(sigma11Eref/phun("MPa")) [MPa]")
modeldata["postprocessing"] = FDataDict(
"file" => "NAFEMS_R0031_1_H20-plate-sxz",
"quantity" => :Cauchy,
"component" => 5,
"outputcsys" => CSys(3),
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
s = modeldata["postprocessing"]["exported"][1]["field"]
println("sxz@D = $(s.values[nD]/phun("MPa")) [MPa]")
s = modeldata["postprocessing"]["exported"][2]["field"]
println("sxz@D = $(s.values[nD]/phun("MPa")) [MPa]")
println("Reference sxz@D = $(sigma13Dref/phun("MPa")) [MPa]")
println("Done")
true
end # NAFEMS_R0031_1_H20
function NAFEMS_R0031_2_thermal_and_pressure()
println("""
R0031(2): Wrapped thick cylinder under pressure and thermal loading.
""")
t0 = time()
pu = ustring -> phun(ustring; system_of_units = :SIMM)
# Orthotropic material parameters of the outer cylinder
E1s = 130.0 * pu("GPa")
E2s = 5.0 * pu("GPa")
E3s = E2s
nu12s = nu13s = 0.25
nu23s = 0.0
G12s = 10.0 * pu("GPa")
G13s = G12s
G23s = 5.0 * pu("GPa")
CTE1 = 3.0e-6
CTE2 = 2.0e-5
CTE3 = 2.0e-5
# Isotropic material parameters of the inner cylinder
E = 2.1e5 * pu("MPa")
nu = 0.3
CTE = 2.0e-5
L = 200.0 * pu("mm") # length of the cylinder
ri = 23.0 * pu("mm") # inner radius of the cylinder
ti = 2.0 * pu("mm") # thickness of the inner cylinder
te = 2.0 * pu("mm") # thickness of the outer cylinder
q0 = 200.0 * pu("MPa") # inner pressure
dT = 130 * pu("K") # temperature rise
tolerance = 0.0001 * ti
# Generate mesh
nL = 16 # number of elements lengthwise
nc = 8 # number of elements circumferentially
xs = collect(linearspace(0.0, L / 2, nL + 1))
ys = collect(linearspace(0.0, pi / 2, nc + 1))
ts = [ti; te]# layer thicknesses
nts = 6 * ones(Int, length(ts))# number of elements per layer
fens, fes = H8layeredplatex(xs, ys, ts, nts)
fens, fes = H8toH20(fens, fes)
bfes = meshboundary(fes)
# inner surface for the pressure loading
intl = selectelem(fens, bfes; facing = true, direction = [0.0 0.0 -1.0])
# Shape into a cylinder
for i = 1:count(fens)
z = fens.xyz[i, 1]
a = fens.xyz[i, 2]
t = fens.xyz[i, 3]
fens.xyz[i, :] = [(ri + t) * cos(pi / 2 - a) (ri + t) * sin(pi / 2 - a) z]
end
MR = DeforModelRed3D
outermaterial = MatDeforElastOrtho(
MR,
0.0,
E1s,
E2s,
E3s,
nu12s,
nu13s,
nu23s,
G12s,
G13s,
G23s,
CTE1,
CTE2,
CTE3,
)
innermaterial = MatDeforElastIso(MR, 0.0, E, nu, CTE)
function cylcs!(csmatout, XYZ)
csmatout[:, 2] = [0.0 0.0 1.0]
csmatout[:, 3] = XYZ
csmatout[3, 3] = 0.0
csmatout[:, 3] = csmatout[:, 3] / norm(csmatout[:, 3])
csmatout[:, 1] = cross(csmatout[:, 2], csmatout[:, 3])
end
function updatecs!(csmatout, XYZ, tangents, feid, qpid)
cylcs!(csmatout, XYZ)
csmatout
end
gr = GaussRule(3, 3)
rli = selectelem(fens, fes, label = 1)
innerregion = FDataDict(
"femm" => FEMMDeforLinear(MR, IntegDomain(subset(fes, rli), gr), innermaterial),
)
rle = selectelem(fens, fes, label = 2)
outerregion = FDataDict(
"femm" => FEMMDeforLinear(
MR,
IntegDomain(subset(fes, rle), gr),
CSys(3, 3, updatecs!),
outermaterial,
),
)
lx0 = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
ly0 = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
lz0 = selectnode(fens, box = [-Inf Inf -Inf Inf 0.0 0.0], inflate = tolerance)
ex0 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lx0)
ey0 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => ly0)
ez0 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lz0)
function getpr!(forceout, XYZ, tangents, feid, qpid)
csmatout = zeros(3, 3)
cylcs!(csmatout, XYZ)
copy!(forceout, q0 * csmatout[:, 3])
return forceout
end
Trac = FDataDict(
"traction_vector" => getpr!,
"femm" => FEMMBase(IntegDomain(subset(bfes, intl), GaussRule(2, 3))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [innerregion, outerregion],
"essential_bcs" => [ex0, ey0, ez0],
"traction_bcs" => [Trac],
"temperature_change" => FDataDict("temperature" => dT),
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# File = "NAFEMS-R0031-2-plate.vtk"
# vtkexportmesh(File, fes.conn, geom.values, FinEtools.MeshExportModule.H20;
# scalars = [("Layer", fes.label)], vectors = [("displacement", u.values)])
# @async run(`"paraview.exe" $File`)
modeldata["postprocessing"] = FDataDict(
"file" => "NAFEMS-R0031-2",
"outputcsys" => CSys(3, 3, updatecs!),
"quantity" => :Cauchy,
"component" => 6,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
modeldata["postprocessing"] = FDataDict(
"file" => "NAFEMS-R0031-2-elem",
"outputcsys" => CSys(3, 3, updatecs!),
"quantity" => :Cauchy,
"component" => 6,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
println("Done")
true
end # NAFEMS_R0031_2_thermal_and_pressure
function NAFEMS_R0031_2_pressure()
println("""
R0031(2): Wrapped thick cylinder under pressure and thermal loading.
""")
t0 = time()
# Orthotropic material parameters of the outer cylinder
E1s = 130.0 * phun("GPa")
E2s = 5.0 * phun("GPa")
E3s = E2s
nu12s = nu13s = 0.25
nu23s = 0.0
G12s = 10.0 * phun("GPa")
G13s = G12s
G23s = 5.0 * phun("GPa")
CTE1 = 3.0e-6
CTE2 = 2.0e-5
CTE3 = 2.0e-5
# Isotropic material parameters of the inner cylinder
E = 2.1e5 * phun("MPa")
nu = 0.3
CTE = 2.0e-5
L = 200.0 * phun("mm") # length of the cylinder
ri = 23.0 * phun("mm") # inner radius of the cylinder
ti = 2.0 * phun("mm") # thickness of the inner cylinder
te = 2.0 * phun("mm") # thickness of the outer cylinder
q0 = 200.0 * phun("MPa") # inner pressure
dT = 0 * phun("K") # NO temperature rise
tolerance = 0.0001 * ti
# Generate mesh
nL = 18 # number of elements lengthwise
nc = 18 # number of elements circumferentially
xs = collect(linearspace(0.0, L / 2, nL + 1))
ys = collect(linearspace(0.0, pi / 2, nc + 1))
ts = [ti; te]# layer thicknesses
nts = 6 * ones(Int, length(ts))# number of elements per layer
fens, fes = H8layeredplatex(xs, ys, ts, nts)
fens, fes = H8toH20(fens, fes)
bfes = meshboundary(fes)
# inner surface for the pressure loading
intl = selectelem(fens, bfes; facing = true, direction = [0.0 0.0 -1.0])
# Shape into a cylinder
for i = 1:count(fens)
z = fens.xyz[i, 1]
a = fens.xyz[i, 2]
t = fens.xyz[i, 3]
fens.xyz[i, :] = [(ri + t) * cos(pi / 2 - a) (ri + t) * sin(pi / 2 - a) z]
end
MR = DeforModelRed3D
outermaterial = MatDeforElastOrtho(
MR,
0.0,
E1s,
E2s,
E3s,
nu12s,
nu13s,
nu23s,
G12s,
G13s,
G23s,
CTE1,
CTE2,
CTE3,
)
innermaterial = MatDeforElastIso(MR, 0.0, E, nu, CTE)
function _cylcs!(csmatout, XYZ)
csmatout[:, 2] = [0.0 0.0 1.0]
radial = XYZ
radial[3] = 0.0
csmatout[:, 3] = radial / norm(radial)
csmatout[:, 1] = cross(csmatout[:, 2], csmatout[:, 3])
return csmatout
end
function updatecs!(csmatout, XYZ, tangents, feid, qpid)
return _cylcs!(csmatout, XYZ)
end
gr = GaussRule(3, 3)
rli = selectelem(fens, fes, label = 1)
innerregion = FDataDict(
"femm" => FEMMDeforLinear(MR, IntegDomain(subset(fes, rli), gr), innermaterial),
)
rle = selectelem(fens, fes, label = 2)
outerregion = FDataDict(
"femm" => FEMMDeforLinear(
MR,
IntegDomain(subset(fes, rle), gr),
CSys(3, 3, updatecs!),
outermaterial,
),
)
lx0 = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
ly0 = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
lz0 = selectnode(fens, box = [-Inf Inf -Inf Inf 0.0 0.0], inflate = tolerance)
ex0 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lx0)
ey0 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => ly0)
ez0 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lz0)
function getpr!(forceout, XYZ, tangents, feid, qpid)
csmatout = zeros(3, 3)
_cylcs!(csmatout, XYZ)
copy!(forceout, q0 * csmatout[:, 3])
return forceout
end
Trac = FDataDict(
"traction_vector" => getpr!,
"femm" => FEMMBase(IntegDomain(subset(bfes, intl), GaussRule(2, 3))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [innerregion, outerregion],
"essential_bcs" => [ex0, ey0, ez0],
"traction_bcs" => [Trac],
"temperature_change" => FDataDict("temperature" => dT),
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# lcenter = selectnode(fens, box=[a/2 a/2 b/2 b/2 -Inf Inf], inflate=tolerance)
# cdis = abs(mean(u.values[lcenter, 3]))
# println("")
# println("Normalized Center deflection: $(cdis/wc_analytical)")
File = "NAFEMS-R0031-2-plate.vtk"
vtkexportmesh(
File,
fes.conn,
geom.values,
FinEtools.MeshExportModule.VTK.H20;
scalars = [("Layer", fes.label)],
vectors = [("displacement", u.values)],
)
@async run(`"paraview.exe" $File`)
println("Done")
true
end # NAFEMS_R0031_2_pressure
function NAFEMS_R0031_3()
println("""
NAFEMS publication R0031/3 Composite plate test.
Simply supported on all four edges. Uniform transverse loading.
The modeled part is one quarter of the full plate here.
""")
# This is a test recommended by the National Agency for Finite Element Methods
# and Standards (U.K.): Test R0031/3 from NAFEMS publication R0031, “Composites
# Benchmarks,” February 1995.
t0 = time()
# Skin (face) material parameters
E1s = 1.0e7 * phun("psi")
E2s = 0.4e7 * phun("psi")
E3s = 0.4e7 * phun("psi")
nu12s = 0.3
nu13s = 0.3
nu23s = 0.3
G12s = 0.1875e7 * phun("psi")
G13s = 0.1875e7 * phun("psi")
G23s = 0.1875e7 * phun("psi")
# Core material parameters
E1c = 10.0 * phun("psi")
E2c = 10.0 * phun("psi")
E3c = 10e4 .* phun("psi")
nu12c = 0.0
nu13c = 0.0
nu23c = 0.0
G12c = 10.0 * phun("psi")
G13c = 3.0e4 * phun("psi")
G23c = 1.2e4 * phun("psi")
L = 10.0 * phun("in") # side of the square plate
nL = 8 # number of elements along the side of the plate
tolerance = 0.0001 * phun("in")
xs = collect(linearspace(0.0, L / 2, nL + 1))
ys = collect(linearspace(0.0, L / 2, nL + 1))
ts = [0.028; 0.75; 0.028] * phun("in")
nts = [2; 3; 2] # number of elements through the thickness
tmag = 100 * phun("psi")
# Generate mesh
fens, fes = H8layeredplatex(xs, ys, ts, nts)
fens, fes = H8toH20(fens, fes)
MR = DeforModelRed3D
skinmaterial = MatDeforElastOrtho(
MR,
0.0,
E1s,
E2s,
E3s,
nu12s,
nu13s,
nu23s,
G12s,
G13s,
G23s,
0.0,
0.0,
0.0,
)
corematerial = MatDeforElastOrtho(
MR,
0.0,
E1c,
E2c,
E3c,
nu12c,
nu13c,
nu23c,
G12c,
G13c,
G23c,
0.0,
0.0,
0.0,
)
gr = GaussRule(3, 3)
rl1 = selectelem(fens, fes, label = 1)
skinbot = FDataDict(
"femm" => FEMMDeforLinear(MR, IntegDomain(subset(fes, rl1), gr), skinmaterial),
)
rl3 = selectelem(fens, fes, label = 3)
skintop = FDataDict(
"femm" => FEMMDeforLinear(MR, IntegDomain(subset(fes, rl3), gr), skinmaterial),
)
rl2 = selectelem(fens, fes, label = 2)
core = FDataDict(
"femm" => FEMMDeforLinear(MR, IntegDomain(subset(fes, rl2), gr), corematerial),
)
lx0 = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
lxL2 = selectnode(fens, box = [L / 2 L / 2 -Inf Inf -Inf Inf], inflate = tolerance)
ly0 = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
lyL2 = selectnode(fens, box = [-Inf Inf L / 2 L / 2 -Inf Inf], inflate = tolerance)
ex0 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lx0)
exL2 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lxL2)
ey0 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => ly0)
eyL2 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => lyL2)
bfes = meshboundary(fes)
ttopl = selectelem(fens, bfes; facing = true, direction = [0.0 0.0 1.0])
Trac = FDataDict(
"traction_vector" => [0.0; 0.0; -tmag],
"femm" => FEMMBase(IntegDomain(subset(bfes, ttopl), GaussRule(2, 3))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [skinbot, core, skintop],
"essential_bcs" => [ex0, exL2, ey0, eyL2],
"traction_bcs" => [Trac],
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
lcenter =
selectnode(fens, box = [L / 2 L / 2 L / 2 L / 2 -Inf Inf], inflate = tolerance)
cdis = mean(u.values[lcenter, 3]) / phun("in")
println("Center node displacements $(cdis) [in]; NAFEMS-R0031-3 lists –0.123 [in]")
println("")
File = "NAFEMS-R0031-3-plate.vtk"
vtkexportmesh(
File,
fes.conn,
geom.values,
FinEtools.MeshExportModule.VTK.H20;
scalars = [("Layer", fes.label)],
vectors = [("displacement", u.values)],
)
@async run(`"paraview.exe" $File`)
println("Done")
true
end # NAFEMS_R0031_3
function allrun()
println("#####################################################")
println("# NAFEMS_R0031_1_msh8 ")
NAFEMS_R0031_1_msh8()
println("#####################################################")
println("# NAFEMS_R0031_1_esnice_h8 ")
NAFEMS_R0031_1_esnice_h8()
println("#####################################################")
println("# NAFEMS_R0031_1_H20 ")
NAFEMS_R0031_1_H20()
println("#####################################################")
println("# NAFEMS_R0031_2_pressure ")
NAFEMS_R0031_2_pressure()
println("#####################################################")
println("# NAFEMS_R0031_2_thermal_and_pressure ")
NAFEMS_R0031_2_thermal_and_pressure()
println("#####################################################")
println("# NAFEMS_R0031_3 ")
NAFEMS_R0031_3()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 43167 | module Pagano_examples
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtools.MeshUtilModule
using FinEtools.AlgoBaseModule
using Statistics: mean
function Pagano_3lay_cyl_bend_MST10_conv()
elementtag = "MST10"
println("""
Pagano 3layer cylindrical bending: $(elementtag)
""")
# This example provides three-dimensional finite element model for the
# transverse shear stress calculations. The problem consists of a one-, two- or
# three-layer plate subjected to a sinusoidal distributed load, as
# described by Pagano (1969). The resulting transverse shear and axial
# stresses through the thickness of the plate are compared to two existing
# analytical solutions by Pagano (1969). The first solution is derived from
# classical laminated plate theory (CPT), while the second is an exact
# solution from linear elasticity theory.
for (extrap, nodevalmeth) in
zip([:extrapmean, :extraptrend, :default], [:averaging, :averaging, :invdistance])
for Span_to_thickness in [4, 50]
filebase = "Pagano_3lay_cyl_bend_conv_$(elementtag)_$(Span_to_thickness)_$(extrap)"
modeldatasequence = FDataDict[]
for Refinement in [1, 2, 4, 8]
# Orthotropic material for the 3 layers
E1 = 25e6 * phun("PSI")
E2 = 1e6 * phun("PSI")
E3 = E2
G12 = 0.5e6 * phun("PSI")
G13 = G12
G23 = 0.2e6 * phun("PSI")
nu12 = 0.25
nu13 = 0.25
nu23 = 0.25
T = 2.5 * phun("in") # total thickness of the plate
L = Span_to_thickness * T
h = 1.0 / Refinement * phun("in") # depth of the plate
q0 = 1 * phun("PSI")
CTE1 = CTE2 = CTE3 = 0.0
# Here we define the layout and the thicknesses of the layers.
angles = vec([0.0 90.0 0.0])
nLayers = length(angles)
ts = T / nLayers * ones(nLayers) # layer thicknesses
tolerance = 0.0001 * T
# Select how fine the mesh should be
nL, nh = Refinement * 2 * 6, 1
nts = Refinement * 2 * ones(Int, nLayers)# number of elements per layer
xs = collect(linearspace(0.0, L, nL + 1))
ys = collect(linearspace(0.0, h, nh + 1))
fens, fes = T10layeredplatex(xs, ys, ts, nts)
display(typeof(fes))
println("Mesh: nL, nh, nts = $nL, $nh, $nts")
println("count(fens) = $(count(fens))")
# This is the material model
MR = DeforModelRed3D
skinmaterial = MatDeforElastOrtho(
MR,
0.0,
E1,
E2,
E3,
nu12,
nu13,
nu23,
G12,
G13,
G23,
CTE1,
CTE2,
CTE3,
)
# The material coordinate system function is defined as:
function _updatecs!(csmatout::FFltMat, layer::FInt)
rotmat3!(csmatout, angles[layer] / 180.0 * pi * [0.0; 0.0; 1.0])
csmatout
end
# The vvolume integrals are evaluated using this rule
gr = SimplexRule(3, 4)
# We will create 3 regions, one for each of the layers
regions = FDataDict[]
for layer = 1:nLayers
rls = selectelem(fens, fes, label = layer)
push!(
regions,
FDataDict(
"femm" => FEMMDeforLinearMST10(
MR,
IntegDomain(subset(fes, rls), gr),
CSys(
3,
3,
(csmatout, XYZ, tangents, feid, qpid) ->
_updatecs!(csmatout, layer),
),
skinmaterial,
),
),
)
end
# The essential boundary conditions are applied to enforce the plane strain constraint.
ly0 =
selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
lyh = selectnode(fens, box = [-Inf Inf h h -Inf Inf], inflate = tolerance)
ey = FDataDict(
"displacement" => 0.0,
"component" => 2,
"node_list" => vcat(ly0, lyh),
)
# The transverse displacement is fixed at the two ends.
lz0 =
selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
lzL = selectnode(fens, box = [L L -Inf Inf -Inf Inf], inflate = tolerance)
ez = FDataDict(
"displacement" => 0.0,
"component" => 3,
"node_list" => vcat(lz0, lzL),
)
ex = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => [1])
# The traction boundary condition is applied at the top of the plate.
bfes = meshboundary(fes)
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) where {T}
forceout[1] = 0.0
forceout[2] = 0.0
forceout[3] = -q0 * sin(pi * XYZ[1] / L)
return forceout
end
# From the entire boundary we select those quadrilaterals that lie on the plane
# Z = thickness
tl = selectelem(
fens,
bfes,
box = [-Inf Inf -Inf Inf T T],
inflate = tolerance,
)
Trac = FDataDict(
"traction_vector" => pfun,
"femm" =>
FEMMBase(IntegDomain(subset(bfes, tl), SimplexRule(2, 3))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => regions,
"essential_bcs" => [ex, ey, ez],
"traction_bcs" => [Trac],
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
# modeldata["postprocessing"] = FDataDict("file"=>filebase * "-u")
# modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# The results of the displacement and stresses will be reported at
# nodes located at the appropriate points.
ntopcenter =
selectnode(fens, box = [L / 2 L / 2 0.0 h T T], inflate = tolerance)
ncenterline =
selectnode(fens, box = [L / 2 L / 2 0.0 0.0 0.0 T], inflate = tolerance)
nx0line =
selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 T], inflate = tolerance)
zclo = sortperm(vec(geom.values[ncenterline, 3]))
ncenterline = ncenterline[zclo]
centerz = geom.values[ncenterline, 3]
println(
"Top Center deflection: $(mean(u.values[ntopcenter, 3], dims = 1)/phun("in")) [in]",
)
# Compute all stresses
modeldata["postprocessing"] = FDataDict(
"file" => filebase * "-s",
"quantity" => :Cauchy,
"component" => collect(1:6),
"outputcsys" => CSys(3),
"nodevalmethod" => nodevalmeth,
"reportat" => extrap,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
modeldata["elementsize"] = T / Refinement
modeldata["geometricaltolerance"] = tolerance
push!(modeldatasequence, modeldata)
end # for refinement
println("")
println("Stress RMS error")
for md in modeldatasequence
md["targetfields"] = [e["field"] for e in md["postprocessing"]["exported"]]
end
elementsizes, errornorms, p =
AlgoBaseModule.evalconvergencestudy(modeldatasequence)
println("Normalized Approximate Error = $(errornorms)")
f = log.(vec(errornorms))
A = hcat(log.(vec(elementsizes[1:(end-1)])), ones(size(f)))
p = A \ f
println("Linear log-log fit: p = $(p)")
csvFile = filebase * "_Stress" * ".CSV"
savecsv(
csvFile,
elementsizes = vec(elementsizes[1:(end-1)]),
elementsizes2 = vec(elementsizes[1:(end-1)] .^ 2),
elementsizes3 = vec(elementsizes[1:(end-1)] .^ 3),
errornorms = vec(errornorms),
)
println("Wrote $csvFile")
println("")
println("Displacement RMS error")
for md in modeldatasequence
md["targetfields"] = [md["u"] for r in md["regions"]]
end
elementsizes, errornorms, p =
AlgoBaseModule.evalconvergencestudy(modeldatasequence)
println("Normalized Approximate Error = $(errornorms)")
f = log.(vec(errornorms))
A = hcat(log.(vec(elementsizes[1:(end-1)])), ones(size(f)))
p = A \ f
println("Linear log-log fit: p = $(p)")
csvFile = filebase * "_Displ" * ".CSV"
savecsv(
csvFile,
elementsizes = vec(elementsizes[1:(end-1)]),
elementsizes2 = vec(elementsizes[1:(end-1)] .^ 2),
elementsizes3 = vec(elementsizes[1:(end-1)] .^ 3),
errornorms = vec(errornorms),
)
println("Wrote $csvFile")
# @async run(`"paraview.exe" $csvFile`)
end # Span_to_thickness
end # extrap
println("Done")
end # Pagano_3lay_cyl_bend_MST10_conv
function Pagano_3lay_cyl_bend_H8_conv()
elementtag = "H8"
println("""
Pagano 3layer cylindrical bending: $(elementtag)
""")
# This example provides three-dimensional finite element model for the
# transverse shear stress calculations. The problem consists of a one-, two- or
# three-layer plate subjected to a sinusoidal distributed load, as
# described by Pagano (1969). The resulting transverse shear and axial
# stresses through the thickness of the plate are compared to two existing
# analytical solutions by Pagano (1969). The first solution is derived from
# classical laminated plate theory (CPT), while the second is an exact
# solution from linear elasticity theory.
for (extrap, nodevalmeth) in
zip([:extrapmean, :extraptrend, :default], [:averaging, :averaging, :invdistance])
for Span_to_thickness in [4, 50]
filebase = "Pagano_3lay_cyl_bend_conv_$(elementtag)_$(Span_to_thickness)_$(extrap)"
modeldatasequence = FDataDict[]
for Refinement in [1, 2, 4, 8]
# Orthotropic material for the 3 layers
E1 = 25e6 * phun("PSI")
E2 = 1e6 * phun("PSI")
E3 = E2
G12 = 0.5e6 * phun("PSI")
G13 = G12
G23 = 0.2e6 * phun("PSI")
nu12 = 0.25
nu13 = 0.25
nu23 = 0.25
T = 2.5 * phun("in") # total thickness of the plate
L = Span_to_thickness * T
h = 1.0 / Refinement * phun("in") # depth of the plate
q0 = 1 * phun("PSI")
CTE1 = CTE2 = CTE3 = 0.0
# Here we define the layout and the thicknesses of the layers.
angles = vec([0.0 90.0 0.0])
nLayers = length(angles)
ts = T / nLayers * ones(nLayers) # layer thicknesses
tolerance = 0.0001 * T
# Select how fine the mesh should be
nL, nh = Refinement * 2 * 6, 1
nts = Refinement * 2 * ones(Int, nLayers)# number of elements per layer
xs = collect(linearspace(0.0, L, nL + 1))
ys = collect(linearspace(0.0, h, nh + 1))
fens, fes = H8layeredplatex(xs, ys, ts, nts)
println("Mesh: nL, nh, nts = $nL, $nh, $nts")
println("count(fens) = $(count(fens))")
# This is the material model
MR = DeforModelRed3D
skinmaterial = MatDeforElastOrtho(
MR,
0.0,
E1,
E2,
E3,
nu12,
nu13,
nu23,
G12,
G13,
G23,
CTE1,
CTE2,
CTE3,
)
# The material coordinate system function is defined as:
function _updatecs!(csmatout::FFltMat, layer::FInt)
rotmat3!(csmatout, angles[layer] / 180.0 * pi * [0.0; 0.0; 1.0])
csmatout
end
# The vvolume integrals are evaluated using this rule
gr = GaussRule(3, 2)
# We will create 3 regions, one for each of the layers
regions = FDataDict[]
for layer = 1:nLayers
rls = selectelem(fens, fes, label = layer)
push!(
regions,
FDataDict(
"femm" => FEMMDeforLinear(
MR,
IntegDomain(subset(fes, rls), gr),
CSys(
3,
3,
(csmatout, XYZ, tangents, feid, qpid) ->
_updatecs!(csmatout, layer),
),
skinmaterial,
),
),
)
end
# The essential boundary conditions are applied to enforce the plane strain constraint.
ly0 =
selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
lyh = selectnode(fens, box = [-Inf Inf h h -Inf Inf], inflate = tolerance)
ey = FDataDict(
"displacement" => 0.0,
"component" => 2,
"node_list" => vcat(ly0, lyh),
)
# The transverse displacement is fixed at the two ends.
lz0 =
selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
lzL = selectnode(fens, box = [L L -Inf Inf -Inf Inf], inflate = tolerance)
ez = FDataDict(
"displacement" => 0.0,
"component" => 3,
"node_list" => vcat(lz0, lzL),
)
ex = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => [1])
# The traction boundary condition is applied at the top of the plate.
bfes = meshboundary(fes)
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) where {T}
forceout[1] = 0.0
forceout[2] = 0.0
forceout[3] = -q0 * sin(pi * XYZ[1] / L)
return forceout
end
# From the entire boundary we select those quadrilaterals that lie on the plane
# Z = thickness
tl = selectelem(
fens,
bfes,
box = [-Inf Inf -Inf Inf T T],
inflate = tolerance,
)
Trac = FDataDict(
"traction_vector" => pfun,
"femm" => FEMMBase(IntegDomain(subset(bfes, tl), GaussRule(2, 2))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => regions,
"essential_bcs" => [ex, ey, ez],
"traction_bcs" => [Trac],
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
# modeldata["postprocessing"] = FDataDict("file"=>filebase * "-u")
# modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# The results of the displacement and stresses will be reported at
# nodes located at the appropriate points.
ntopcenter =
selectnode(fens, box = [L / 2 L / 2 0.0 h T T], inflate = tolerance)
ncenterline =
selectnode(fens, box = [L / 2 L / 2 0.0 0.0 0.0 T], inflate = tolerance)
nx0line =
selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 T], inflate = tolerance)
zclo = sortperm(vec(geom.values[ncenterline, 3]))
ncenterline = ncenterline[zclo]
centerz = geom.values[ncenterline, 3]
println(
"Top Center deflection: $(mean(u.values[ntopcenter, 3], dims = 1)/phun("in")) [in]",
)
# Compute all stresses
modeldata["postprocessing"] = FDataDict(
"file" => filebase * "-s",
"quantity" => :Cauchy,
"component" => collect(1:6),
"outputcsys" => CSys(3),
"nodevalmethod" => nodevalmeth,
"reportat" => extrap,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
modeldata["elementsize"] = T / Refinement
modeldata["geometricaltolerance"] = tolerance
push!(modeldatasequence, modeldata)
end # for refinement
println("")
println("Stress RMS error")
for md in modeldatasequence
md["targetfields"] = [e["field"] for e in md["postprocessing"]["exported"]]
end
elementsizes, errornorms, p =
AlgoBaseModule.evalconvergencestudy(modeldatasequence)
println("Normalized Approximate Error = $(errornorms)")
f = log.(vec(errornorms))
A = hcat(log.(vec(elementsizes[1:(end-1)])), ones(size(f)))
p = A \ f
println("Linear log-log fit: p = $(p)")
csvFile = filebase * "_Stress" * ".CSV"
savecsv(
csvFile,
elementsizes = vec(elementsizes[1:(end-1)]),
elementsizes2 = vec(elementsizes[1:(end-1)] .^ 2),
elementsizes3 = vec(elementsizes[1:(end-1)] .^ 3),
errornorms = vec(errornorms),
)
println("Wrote $csvFile")
println("")
println("Displacement RMS error")
for md in modeldatasequence
md["targetfields"] = [md["u"] for r in md["regions"]]
end
elementsizes, errornorms, p =
AlgoBaseModule.evalconvergencestudy(modeldatasequence)
println("Normalized Approximate Error = $(errornorms)")
f = log.(vec(errornorms))
A = hcat(log.(vec(elementsizes[1:(end-1)])), ones(size(f)))
p = A \ f
println("Linear log-log fit: p = $(p)")
csvFile = filebase * "_Displ" * ".CSV"
savecsv(
csvFile,
elementsizes = vec(elementsizes[1:(end-1)]),
elementsizes2 = vec(elementsizes[1:(end-1)] .^ 2),
elementsizes3 = vec(elementsizes[1:(end-1)] .^ 3),
errornorms = vec(errornorms),
)
println("Wrote $csvFile")
# @async run(`"paraview.exe" $csvFile`)
end # Span_to_thickness
end # extrap
println("Done")
end # Pagano_3lay_cyl_bend_H8_conv
function Pagano_3lay_cyl_bend_MSH8_conv()
elementtag = "MSH8"
println("""
Pagano 3layer cylindrical bending: $(elementtag)
""")
# This example provides three-dimensional finite element model for the
# transverse shear stress calculations. The problem consists of a one-, two- or
# three-layer plate subjected to a sinusoidal distributed load, as
# described by Pagano (1969). The resulting transverse shear and axial
# stresses through the thickness of the plate are compared to two existing
# analytical solutions by Pagano (1969). The first solution is derived from
# classical laminated plate theory (CPT), while the second is an exact
# solution from linear elasticity theory.
for (extrap, nodevalmeth) in
zip([:extrapmean, :extraptrend, :default], [:averaging, :averaging, :invdistance])
for Span_to_thickness in [4, 50]
filebase = "Pagano_3lay_cyl_bend_conv_$(elementtag)_$(Span_to_thickness)_$(extrap)"
modeldatasequence = FDataDict[]
for Refinement in [1, 2, 4, 8]
# Orthotropic material for the 3 layers
E1 = 25e6 * phun("PSI")
E2 = 1e6 * phun("PSI")
E3 = E2
G12 = 0.5e6 * phun("PSI")
G13 = G12
G23 = 0.2e6 * phun("PSI")
nu12 = 0.25
nu13 = 0.25
nu23 = 0.25
T = 2.5 * phun("in") # total thickness of the plate
L = Span_to_thickness * T
h = 1.0 / Refinement * phun("in") # depth of the plate
q0 = 1 * phun("PSI")
CTE1 = CTE2 = CTE3 = 0.0
# Here we define the layout and the thicknesses of the layers.
angles = vec([0.0 90.0 0.0])
nLayers = length(angles)
ts = T / nLayers * ones(nLayers) # layer thicknesses
tolerance = 0.0001 * T
# Select how fine the mesh should be
nL, nh = Refinement * 2 * 6, 1
nts = Refinement * 2 * ones(Int, nLayers)# number of elements per layer
xs = collect(linearspace(0.0, L, nL + 1))
ys = collect(linearspace(0.0, h, nh + 1))
fens, fes = H8layeredplatex(xs, ys, ts, nts)
println("Mesh: nL, nh, nts = $nL, $nh, $nts")
println("count(fens) = $(count(fens))")
# This is the material model
MR = DeforModelRed3D
skinmaterial = MatDeforElastOrtho(
MR,
0.0,
E1,
E2,
E3,
nu12,
nu13,
nu23,
G12,
G13,
G23,
CTE1,
CTE2,
CTE3,
)
# The material coordinate system function is defined as:
function _updatecs!(csmatout::FFltMat, layer::FInt)
rotmat3!(csmatout, angles[layer] / 180.0 * pi * [0.0; 0.0; 1.0])
csmatout
end
# The vvolume integrals are evaluated using this rule
gr = GaussRule(3, 2)
# We will create 3 regions, one for each of the layers
regions = FDataDict[]
for layer = 1:nLayers
rls = selectelem(fens, fes, label = layer)
push!(
regions,
FDataDict(
"femm" => FEMMDeforLinearMSH8(
MR,
IntegDomain(subset(fes, rls), gr),
CSys(
3,
3,
(csmatout, XYZ, tangents, feid, qpid) ->
_updatecs!(csmatout, layer),
),
skinmaterial,
),
),
)
end
# The essential boundary conditions are applied to enforce the plane strain constraint.
ly0 =
selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
lyh = selectnode(fens, box = [-Inf Inf h h -Inf Inf], inflate = tolerance)
ey = FDataDict(
"displacement" => 0.0,
"component" => 2,
"node_list" => vcat(ly0, lyh),
)
# The transverse displacement is fixed at the two ends.
lz0 =
selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
lzL = selectnode(fens, box = [L L -Inf Inf -Inf Inf], inflate = tolerance)
ez = FDataDict(
"displacement" => 0.0,
"component" => 3,
"node_list" => vcat(lz0, lzL),
)
ex = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => [1])
# The traction boundary condition is applied at the top of the plate.
bfes = meshboundary(fes)
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) where {T}
forceout[1] = 0.0
forceout[2] = 0.0
forceout[3] = -q0 * sin(pi * XYZ[1] / L)
return forceout
end
# From the entire boundary we select those quadrilaterals that lie on the plane
# Z = thickness
tl = selectelem(
fens,
bfes,
box = [-Inf Inf -Inf Inf T T],
inflate = tolerance,
)
Trac = FDataDict(
"traction_vector" => pfun,
"femm" => FEMMBase(IntegDomain(subset(bfes, tl), GaussRule(2, 2))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => regions,
"essential_bcs" => [ex, ey, ez],
"traction_bcs" => [Trac],
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
# modeldata["postprocessing"] = FDataDict("file"=>filebase * "-u")
# modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# The results of the displacement and stresses will be reported at
# nodes located at the appropriate points.
ntopcenter =
selectnode(fens, box = [L / 2 L / 2 0.0 h T T], inflate = tolerance)
ncenterline =
selectnode(fens, box = [L / 2 L / 2 0.0 0.0 0.0 T], inflate = tolerance)
nx0line =
selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 T], inflate = tolerance)
zclo = sortperm(vec(geom.values[ncenterline, 3]))
ncenterline = ncenterline[zclo]
centerz = geom.values[ncenterline, 3]
println(
"Top Center deflection: $(mean(u.values[ntopcenter, 3], dims = 1)/phun("in")) [in]",
)
# Compute all stresses
modeldata["postprocessing"] = FDataDict(
"file" => filebase * "-s",
"quantity" => :Cauchy,
"component" => collect(1:6),
"outputcsys" => CSys(3),
"nodevalmethod" => nodevalmeth,
"reportat" => extrap,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
modeldata["elementsize"] = T / Refinement
modeldata["geometricaltolerance"] = tolerance
push!(modeldatasequence, modeldata)
end # for refinement
println("")
println("Stress RMS error")
for md in modeldatasequence
md["targetfields"] = [e["field"] for e in md["postprocessing"]["exported"]]
end
elementsizes, errornorms, p =
AlgoBaseModule.evalconvergencestudy(modeldatasequence)
println("Normalized Approximate Error = $(errornorms)")
f = log.(vec(errornorms))
A = hcat(log.(vec(elementsizes[1:(end-1)])), ones(size(f)))
p = A \ f
println("Linear log-log fit: p = $(p)")
csvFile = filebase * "_Stress" * ".CSV"
savecsv(
csvFile,
elementsizes = vec(elementsizes[1:(end-1)]),
elementsizes2 = vec(elementsizes[1:(end-1)] .^ 2),
elementsizes3 = vec(elementsizes[1:(end-1)] .^ 3),
errornorms = vec(errornorms),
)
println("Wrote $csvFile")
println("")
println("Displacement RMS error")
for md in modeldatasequence
md["targetfields"] = [md["u"] for r in md["regions"]]
end
elementsizes, errornorms, p =
AlgoBaseModule.evalconvergencestudy(modeldatasequence)
println("Normalized Approximate Error = $(errornorms)")
f = log.(vec(errornorms))
A = hcat(log.(vec(elementsizes[1:(end-1)])), ones(size(f)))
p = A \ f
println("Linear log-log fit: p = $(p)")
csvFile = filebase * "_Displ" * ".CSV"
savecsv(
csvFile,
elementsizes = vec(elementsizes[1:(end-1)]),
elementsizes2 = vec(elementsizes[1:(end-1)] .^ 2),
elementsizes3 = vec(elementsizes[1:(end-1)] .^ 3),
errornorms = vec(errornorms),
)
println("Wrote $csvFile")
# @async run(`"paraview.exe" $csvFile`)
end # Span_to_thickness
end # extrap
println("Done")
end # Pagano_3lay_cyl_bend_MSH8_conv
function Pagano_3lay_cyl_bend_T10_conv()
elementtag = "T10"
println("""
Pagano 3layer cylindrical bending: $(elementtag)
""")
# This example provides three-dimensional finite element model for the
# transverse shear stress calculations. The problem consists of a one-, two- or
# three-layer plate subjected to a sinusoidal distributed load, as
# described by Pagano (1969). The resulting transverse shear and axial
# stresses through the thickness of the plate are compared to two existing
# analytical solutions by Pagano (1969). The first solution is derived from
# classical laminated plate theory (CPT), while the second is an exact
# solution from linear elasticity theory.
for (extrap, nodevalmeth) in zip([:default], [:invdistance])
for Span_to_thickness in [4, 50]
filebase = "Pagano_3lay_cyl_bend_conv_$(elementtag)_$(Span_to_thickness)_$(extrap)"
modeldatasequence = FDataDict[]
for Refinement in [1, 2, 4, 8]
# Orthotropic material for the 3 layers
E1 = 25e6 * phun("PSI")
E2 = 1e6 * phun("PSI")
E3 = E2
G12 = 0.5e6 * phun("PSI")
G13 = G12
G23 = 0.2e6 * phun("PSI")
nu12 = 0.25
nu13 = 0.25
nu23 = 0.25
T = 2.5 * phun("in") # total thickness of the plate
L = Span_to_thickness * T
h = 1.0 / Refinement * phun("in") # depth of the plate
q0 = 1 * phun("PSI")
CTE1 = CTE2 = CTE3 = 0.0
# Here we define the layout and the thicknesses of the layers.
angles = vec([0.0 90.0 0.0])
nLayers = length(angles)
ts = T / nLayers * ones(nLayers) # layer thicknesses
tolerance = 0.0001 * T
# Select how fine the mesh should be
nL, nh = Refinement * 2 * 6, 1
nts = Refinement * 2 * ones(Int, nLayers)# number of elements per layer
xs = collect(linearspace(0.0, L, nL + 1))
ys = collect(linearspace(0.0, h, nh + 1))
fens, fes = T10layeredplatex(xs, ys, ts, nts)
println("Mesh: nL, nh, nts = $nL, $nh, $nts")
println("count(fens) = $(count(fens))")
# This is the material model
MR = DeforModelRed3D
skinmaterial = MatDeforElastOrtho(
MR,
0.0,
E1,
E2,
E3,
nu12,
nu13,
nu23,
G12,
G13,
G23,
CTE1,
CTE2,
CTE3,
)
# The material coordinate system function is defined as:
function _updatecs!(csmatout::FFltMat, layer::FInt)
rotmat3!(csmatout, angles[layer] / 180.0 * pi * [0.0; 0.0; 1.0])
csmatout
end
# The vvolume integrals are evaluated using this rule
gr = SimplexRule(3, 4)
# We will create 3 regions, one for each of the layers
regions = FDataDict[]
for layer = 1:nLayers
rls = selectelem(fens, fes, label = layer)
push!(
regions,
FDataDict(
"femm" => FEMMDeforLinear(
MR,
IntegDomain(subset(fes, rls), gr),
CSys(
3,
3,
(csmatout, XYZ, tangents, feid, qpid) ->
_updatecs!(csmatout, layer),
),
skinmaterial,
),
),
)
end
# The essential boundary conditions are applied to enforce the plane strain constraint.
ly0 =
selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
lyh = selectnode(fens, box = [-Inf Inf h h -Inf Inf], inflate = tolerance)
ey = FDataDict(
"displacement" => 0.0,
"component" => 2,
"node_list" => vcat(ly0, lyh),
)
# The transverse displacement is fixed at the two ends.
lz0 =
selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
lzL = selectnode(fens, box = [L L -Inf Inf -Inf Inf], inflate = tolerance)
ez = FDataDict(
"displacement" => 0.0,
"component" => 3,
"node_list" => vcat(lz0, lzL),
)
ex = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => [1])
# The traction boundary condition is applied at the top of the plate.
bfes = meshboundary(fes)
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) where {T}
forceout[1] = 0.0
forceout[2] = 0.0
forceout[3] = -q0 * sin(pi * XYZ[1] / L)
return forceout
end
# From the entire boundary we select those quadrilaterals that lie on the plane
# Z = thickness
tl = selectelem(
fens,
bfes,
box = [-Inf Inf -Inf Inf T T],
inflate = tolerance,
)
Trac = FDataDict(
"traction_vector" => pfun,
"femm" =>
FEMMBase(IntegDomain(subset(bfes, tl), SimplexRule(2, 3))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => regions,
"essential_bcs" => [ex, ey, ez],
"traction_bcs" => [Trac],
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
# modeldata["postprocessing"] = FDataDict("file"=>filebase * "-u")
# modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# The results of the displacement and stresses will be reported at
# nodes located at the appropriate points.
ntopcenter =
selectnode(fens, box = [L / 2 L / 2 0.0 h T T], inflate = tolerance)
ncenterline =
selectnode(fens, box = [L / 2 L / 2 0.0 0.0 0.0 T], inflate = tolerance)
nx0line =
selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 T], inflate = tolerance)
zclo = sortperm(vec(geom.values[ncenterline, 3]))
ncenterline = ncenterline[zclo]
centerz = geom.values[ncenterline, 3]
println(
"Top Center deflection: $(mean(u.values[ntopcenter, 3], dims = 1)/phun("in")) [in]",
)
# Compute all stresses
modeldata["postprocessing"] = FDataDict(
"file" => filebase * "-s",
"quantity" => :Cauchy,
"component" => collect(1:6),
"outputcsys" => CSys(3),
"nodevalmethod" => nodevalmeth,
"reportat" => extrap,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
modeldata["elementsize"] = T / Refinement
modeldata["geometricaltolerance"] = tolerance
push!(modeldatasequence, modeldata)
end # for refinement
println("")
println("Stress RMS error")
for md in modeldatasequence
md["targetfields"] = [e["field"] for e in md["postprocessing"]["exported"]]
end
elementsizes, errornorms, p =
AlgoBaseModule.evalconvergencestudy(modeldatasequence)
println("Normalized Approximate Error = $(errornorms)")
f = log.(vec(errornorms))
A = hcat(log.(vec(elementsizes[1:(end-1)])), ones(size(f)))
p = A \ f
println("Linear log-log fit: p = $(p)")
csvFile = filebase * "_Stress" * ".CSV"
savecsv(
csvFile,
elementsizes = vec(elementsizes[1:(end-1)]),
elementsizes2 = vec(elementsizes[1:(end-1)] .^ 2),
elementsizes3 = vec(elementsizes[1:(end-1)] .^ 3),
errornorms = vec(errornorms),
)
println("Wrote $csvFile")
println("")
println("Displacement RMS error")
for md in modeldatasequence
md["targetfields"] = [md["u"] for r in md["regions"]]
end
elementsizes, errornorms, p =
AlgoBaseModule.evalconvergencestudy(modeldatasequence)
println("Normalized Approximate Error = $(errornorms)")
f = log.(vec(errornorms))
A = hcat(log.(vec(elementsizes[1:(end-1)])), ones(size(f)))
p = A \ f
println("Linear log-log fit: p = $(p)")
csvFile = filebase * "_Displ" * ".CSV"
savecsv(
csvFile,
elementsizes = vec(elementsizes[1:(end-1)]),
elementsizes2 = vec(elementsizes[1:(end-1)] .^ 2),
elementsizes3 = vec(elementsizes[1:(end-1)] .^ 3),
errornorms = vec(errornorms),
)
println("Wrote $csvFile")
# @async run(`"paraview.exe" $csvFile`)
end # Span_to_thickness
end # extrap
println("Done")
end # Pagano_3lay_cyl_bend_T10_conv
function allrun()
println("#####################################################")
println("# Pagano_3lay_cyl_bend_MST10_conv ")
Pagano_3lay_cyl_bend_MST10_conv()
println("#####################################################")
println("# Pagano_3lay_cyl_bend_MSH8_conv ")
Pagano_3lay_cyl_bend_MSH8_conv()
println("#####################################################")
println("# Pagano_3lay_cyl_bend_H8_conv ")
Pagano_3lay_cyl_bend_H8_conv()
println("#####################################################")
println("# Pagano_3lay_cyl_bend_MSH8_conv ")
Pagano_3lay_cyl_bend_MSH8_conv()
println("#####################################################")
println("# Pagano_3lay_cyl_bend_T10_conv ")
Pagano_3lay_cyl_bend_T10_conv()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 9199 | module THICK_plate_2dir_strong_examples
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtools.MeshUtilModule
using FinEtools.AlgoBaseModule
using Statistics
function THICK_plate_2dir_strong_MST10_conv()
elementtag = "MST10"
println("""
Fiber-reinforced cantilever plate: $(elementtag)
""")
# This example provides three-dimensional finite element model for the
# transverse shear stress calculations. The problem consists of a one-, two- or
# three-layer plate subjected to a sinusoidal distributed load, as
# described by Pagano (1969). The resulting transverse shear and axial
# stresses through the thickness of the plate are compared to two existing
# analytical solutions by Pagano (1969). The first solution is derived from
# classical laminated plate theory (CPT), while the second is an exact
# solution from linear elasticity theory.
for (extrap, nodevalmeth) in
zip([:extrapmean, :extraptrend, :default], [:averaging, :averaging, :invdistance])
filebase = "THICK_plate_2dir_strong_MST10_conv_$(elementtag)_$(extrap)"
modeldatasequence = FDataDict[]
for Refinement in [1, 2, 4, 8]
# Orthotropic material
E1 = 1000.0e9 * phun("Pa")
E2 = 1000.0e9 * phun("Pa")
E3 = 1.0e9 * phun("Pa")
G12 = 0.2e9 * phun("Pa")
G13 = G12
G23 = 0.2e9 * phun("Pa")
nu12 = nu13 = nu23 = 0.25
# dimensions of the plate
a = 70.0 * phun("mm")
b = 100.0 * phun("mm")
t = 50.0 * phun("mm")
# Transverse loading
q0 = 1000.0 * phun("Pa")
# Coefficients of thermal expansion
CTE1 = CTE2 = CTE3 = 0.0
# Here we define the layout and the thicknesses of the layers.
angles = vec([45.0])
nLayers = length(angles)
ts = t / nLayers * ones(nLayers) # layer thicknesses
tolerance = 0.0001 * t
# Select how fine the mesh should be
nts = Refinement * ones(Int, nLayers)# number of elements per layer
tnts = sum(nts)
na, nb = 4 * tnts, 4 * tnts
xs = collect(linearspace(0.0, a, na + 1))
ys = collect(linearspace(0.0, b, nb + 1))
fens, fes = T10layeredplatex(xs, ys, ts, nts)
println("Mesh: na, nb, nts = $na, $nb, $nts")
println("count(fens) = $(count(fens))")
# This is the material model
MR = DeforModelRed3D
material = MatDeforElastOrtho(
MR,
0.0,
E1,
E2,
E3,
nu12,
nu13,
nu23,
G12,
G13,
G23,
CTE1,
CTE2,
CTE3,
)
# The material coordinate system function is defined as:
function _updatecs!(csmatout::FFltMat, layer::FInt)
rotmat3!(csmatout, angles[layer] / 180.0 * pi * [0.0; 0.0; 1.0])
csmatout
end
# The volume integrals are evaluated using this rule
gr = SimplexRule(3, 4)
# We will create 3 regions, one for each of the layers
regions = FDataDict[]
for layer = 1:nLayers
rls = selectelem(fens, fes, label = layer)
push!(
regions,
FDataDict(
"femm" => FEMMDeforLinearMST10(
MR,
IntegDomain(subset(fes, rls), gr),
CSys(
3,
3,
(csmatout, XYZ, tangents, feid, qpid) ->
_updatecs!(csmatout, layer),
),
material,
),
),
)
end
# The essential boundary conditions: clamped face
lx0 = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
eclamped1 =
FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lx0)
eclamped2 =
FDataDict("displacement" => 0.0, "component" => 2, "node_list" => lx0)
eclamped3 =
FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lx0)
# The traction boundary condition is applied at the free face opposite the clamped face.
bfes = meshboundary(fes)
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
) where {T}
forceout[1] = 0.0
forceout[2] = 0.0
forceout[3] = -q0
return forceout
end
# From the entire boundary we select those quadrilaterals that lie on the plane
# Z = thickness
tl = selectelem(fens, bfes, box = [a a -Inf Inf -Inf Inf], inflate = tolerance)
Trac = FDataDict(
"traction_vector" => pfun,
"femm" => FEMMBase(IntegDomain(subset(bfes, tl), SimplexRule(2, 3))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => regions,
"essential_bcs" => [eclamped1, eclamped2, eclamped3],
"traction_bcs" => [Trac],
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
# modeldata["postprocessing"] = FDataDict("file"=>filebase * "-u")
# modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# The results of the displacement and stresses will be reported at
# nodes located at the appropriate points.
nbottomedge = selectnode(fens, box = [a a 0.0 0.0 0.0 0.0], inflate = tolerance)
println(
"bottom edge deflection: $(mean(u.values[nbottomedge, 3], dims=1)/phun("mm")) [mm]",
)
# Compute all stresses
modeldata["postprocessing"] = FDataDict(
"file" => filebase * "-s",
"quantity" => :Cauchy,
"component" => collect(1:6),
"outputcsys" => CSys(3),
"nodevalmethod" => nodevalmeth,
"reportat" => extrap,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
modeldata["elementsize"] = t / Refinement
modeldata["geometricaltolerance"] = tolerance
push!(modeldatasequence, modeldata)
end # for refinement
println("")
println("Stress RMS error")
for md in modeldatasequence
md["targetfields"] = [e["field"] for e in md["postprocessing"]["exported"]]
end
elementsizes, errornorms, p = AlgoBaseModule.evalconvergencestudy(modeldatasequence)
println("Normalized Approximate Error = $(errornorms)")
f = log.(vec(errornorms))
A = hcat(log.(vec(elementsizes[1:(end-1)])), ones(size(f)))
p = A \ f
println("Linear log-log fit: p = $(p)")
csvFile = filebase * "_Stress" * ".CSV"
savecsv(
csvFile,
elementsizes = vec(elementsizes[1:(end-1)]),
elementsizes2 = vec(elementsizes[1:(end-1)] .^ 2),
elementsizes3 = vec(elementsizes[1:(end-1)] .^ 3),
errornorms = vec(errornorms),
)
println("Wrote $csvFile")
println("")
println("Displacement RMS error")
for md in modeldatasequence
md["targetfields"] = [md["u"] for r in md["regions"]]
end
elementsizes, errornorms, p = AlgoBaseModule.evalconvergencestudy(modeldatasequence)
println("Normalized Approximate Error = $(errornorms)")
f = log.(vec(errornorms))
A = hcat(log.(vec(elementsizes[1:(end-1)])), ones(size(f)))
p = A \ f
println("Linear log-log fit: p = $(p)")
csvFile = filebase * "_Displ" * ".CSV"
savecsv(
csvFile,
elementsizes = vec(elementsizes[1:(end-1)]),
elementsizes2 = vec(elementsizes[1:(end-1)] .^ 2),
elementsizes3 = vec(elementsizes[1:(end-1)] .^ 3),
errornorms = vec(errornorms),
)
println("Wrote $csvFile")
# @async run(`"paraview.exe" $csvFile`)
end # extrap
println("Done")
end #
function allrun()
println("#####################################################")
println("# THICK_plate_2dir_strong_MST10_conv ")
THICK_plate_2dir_strong_MST10_conv()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 4843 | module Z_laminate_examples
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using Statistics
function Z_laminate_u_ss()
println("""
% Three-dimensional Elasticity Solution for Uniformly Loaded Cross-ply
% Laminates and Sandwich Plates
% Ashraf M. Zenkour, Journal of Sandwich Structures and Materials 2007 9: 213-238
% DOI: 10.1177/1099636207065675
""")
t0 = time()
# Lamina material parameters
E1s = 25.0e6 * phun("psi")
E2s = 1.0e6 * phun("psi")
E3s = E2s
nu12s = nu13s = nu23s = 0.25
G12s = 0.5e6 * phun("psi")
G13s = G12s
G23s = 0.2e6 * phun("psi")
a = 200.0 * phun("mm") # side of the square plate
b = 600.0 * phun("mm") # side of the square plate
q0 = 1.0 * phun("psi")
# The below values come from Table 2
# h = a/4; wc_analytical = 3.65511/(100*E3s*h^3/a^4/q0);
# h = a/10; wc_analytical = 1.16899/(100*E3s*h^3/a^4/q0);
# h = a/50; wc_analytical = 0.66675/(100*E3s*h^3/a^4/q0);
h = a / 100
wc_analytical = 0.65071 / (100 * E3s * h^3 / a^4 / q0)
angles = [0, 90, 0]
nLayers = length(angles)
tolerance = 0.0001 * h
# Generate mesh
na = 10 # number of elements along the side of the plate
nb = 30 # number of elements along the side of the plate
xs = collect(linearspace(0.0, a, na + 1))
ys = collect(linearspace(0.0, b, nb + 1))
ts = h / nLayers * ones(nLayers)# layer thicknesses
nts = 3 * ones(Int, nLayers)# number of elements per layer
fens, fes = H8layeredplatex(xs, ys, ts, nts)
fens, fes = H8toH20(fens, fes)
MR = DeforModelRed3D
laminamaterial = MatDeforElastOrtho(
MR,
0.0,
E1s,
E2s,
E3s,
nu12s,
nu13s,
nu23s,
G12s,
G13s,
G23s,
0.0,
0.0,
0.0,
)
function _updatecs!(csmatout::FFltMat, feid::FInt, labels)
rotmat3!(csmatout, angles[labels[feid]] / 180.0 * pi * [0.0; 0.0; 1.0])
csmatout
end
gr = GaussRule(3, 3)
region = FDataDict(
"femm" => FEMMDeforLinear(
MR,
IntegDomain(fes, gr),
CSys(
3,
3,
(csmatout, XYZ, tangents, feid, qpid) ->
_updatecs!(csmatout, feid, fes.label),
),
laminamaterial,
),
)
lx0 = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
lxa = selectnode(fens, box = [a a -Inf Inf -Inf Inf], inflate = tolerance)
ly0 = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
lyb = selectnode(fens, box = [-Inf Inf b b -Inf Inf], inflate = tolerance)
ex02 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => lx0)
ex03 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lx0)
exa2 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => lxa)
exa3 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lxa)
ey01 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => ly0)
ey03 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => ly0)
eyb1 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lyb)
eyb3 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lyb)
bfes = meshboundary(fes)
ttopl = selectelem(fens, bfes; facing = true, direction = [0.0 0.0 1.0])
Trac = FDataDict(
"traction_vector" => [0.0; 0.0; -q0],
"femm" => FEMMBase(IntegDomain(subset(bfes, ttopl), GaussRule(2, 3))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [region],
"essential_bcs" => [ex02, ex03, exa2, exa3, ey01, ey03, eyb1, eyb3],
"traction_bcs" => [Trac],
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
lcenter =
selectnode(fens, box = [a / 2 a / 2 b / 2 b / 2 -Inf Inf], inflate = tolerance)
cdis = abs(mean(u.values[lcenter, 3]))
println("")
println("Normalized Center deflection: $(cdis/wc_analytical)")
File = "Z_laminate_u_ss.vtk"
vtkexportmesh(
File,
fes.conn,
geom.values,
FinEtools.MeshExportModule.VTK.H20;
scalars = [("Layer", fes.label)],
vectors = [("displacement", u.values)],
)
@async run(`"paraview.exe" $File`)
println("Done")
true
end # Z_laminate_u_ss
function allrun()
println("#####################################################")
println("# Z_laminate_u_ss ")
Z_laminate_u_ss()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 21612 | module bushing_examples
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!, matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtools.MeshExportModule
using Statistics: mean
E = 3.0
nu = 0.4999999 # This is the correct Poisson ratio
Ri = 0.25
Re = 1.0
L = Ri / 2
ang = 180 / 180 * pi
iuz = Ri / 15
p = 0.27
tolerance = min(L, Re - Ri, ang) / 1000
nR, nc, nt = 7, 14, 1
function bushing_h8_full()
fens, fes = H8block(ang, L, Re - Ri, nc, nt, nR)
internal_fenids = selectnode(fens, box = [0 ang 0 L 0 0], inflate = tolerance)
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
boundaryfes = meshboundary(fes)
ibcl = selectelem(fens, boundaryfes, box = [0 ang 0 L 0 0], inflate = tolerance)
ebcl = selectelem(
fens,
boundaryfes,
box = [0 ang 0 L Re - Ri Re - Ri],
inflate = tolerance,
)
for i = 1:count(fens)
a = fens.xyz[i, 1]
y = fens.xyz[i, 2]
r = fens.xyz[i, 3] + Ri
fens.xyz[i, :] .= (r * sin(a), y, r * cos(a))
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
x0nl = selectnode(fens, box = [0 0 -Inf Inf -Inf Inf], inflate = tolerance)
setebc!(u, x0nl, true, 1, 0.0)
y0nl = selectnode(fens, box = [-Inf Inf 0 0 -Inf Inf], inflate = tolerance)
setebc!(u, y0nl, true, 2, 0.0)
yLnl = selectnode(fens, box = [-Inf Inf L L -Inf Inf], inflate = tolerance)
setebc!(u, yLnl, true, 2, 0.0)
enl = connectednodes(subset(boundaryfes, ebcl))
setebc!(u, enl, true, [1; 2; 3], 0.0)
inl = connectednodes(subset(boundaryfes, ibcl))
setebc!(u, inl, true, [1; 2], 0.0)
setebc!(u, inl, true, [3], iuz)
applyebc!(u)
numberdofs!(u)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K, fill(0.0, nalldofs(u)))
File = "bushing_h8_full_u.vtk"
vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
@async run(`"paraview.exe" $File`)
true
end # bushing_h8_full
function bushing_h8_algo_full()
fens, fes = H8block(ang, L, Re - Ri, nc, nt, nR)
internal_fenids = selectnode(fens, box = [0 ang 0 L 0 0], inflate = tolerance)
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
regions = FDataDict[FDataDict("femm" => femm)]
boundaryfes = meshboundary(fes)
ibcl = selectelem(fens, boundaryfes, box = [0 ang 0 L 0 0], inflate = tolerance)
ebcl = selectelem(
fens,
boundaryfes,
box = [0 ang 0 L Re - Ri Re - Ri],
inflate = tolerance,
)
for i = 1:count(fens)
a = fens.xyz[i, 1]
y = fens.xyz[i, 2]
r = fens.xyz[i, 3] + Ri
fens.xyz[i, :] .= (r * sin(a), y, r * cos(a))
end
essential_bcs = FDataDict[]
x0nl = selectnode(fens, box = [0 0 -Inf Inf -Inf Inf], inflate = tolerance)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 1, "node_list" => x0nl),
)
y0nl = selectnode(fens, box = [-Inf Inf 0 0 -Inf Inf], inflate = tolerance)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 2, "node_list" => y0nl),
)
yLnl = selectnode(fens, box = [-Inf Inf L L -Inf Inf], inflate = tolerance)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 2, "node_list" => yLnl),
)
enl = connectednodes(subset(boundaryfes, ebcl))
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 1, "node_list" => enl),
)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 2, "node_list" => enl),
)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 3, "node_list" => enl),
)
inl = connectednodes(subset(boundaryfes, ibcl))
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 1, "node_list" => inl),
)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 2, "node_list" => inl),
)
push!(
essential_bcs,
FDataDict("displacement" => iuz, "component" => 3, "node_list" => inl),
)
modeldata =
FDataDict("fens" => fens, "regions" => regions, "essential_bcs" => essential_bcs)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
filebase = "bushing_h8_algo_full"
modeldata["postprocessing"] = FDataDict(
"file" => filebase * "-s",
"quantity" => :pressure,
"component" => collect(1:1),
"nodevalmethod" => :averaging,
"reportat" => :extraptrend,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
true
end # bushing_h8_algo_full
function bushing_h8_algo_ms()
fens, fes = H8block(ang, L, Re - Ri, nc, nt, nR)
internal_fenids = selectnode(fens, box = [0 ang 0 L 0 0], inflate = tolerance)
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
regions = FDataDict[FDataDict("femm" => femm)]
boundaryfes = meshboundary(fes)
ibcl = selectelem(fens, boundaryfes, box = [0 ang 0 L 0 0], inflate = tolerance)
ebcl = selectelem(
fens,
boundaryfes,
box = [0 ang 0 L Re - Ri Re - Ri],
inflate = tolerance,
)
for i = 1:count(fens)
a = fens.xyz[i, 1]
y = fens.xyz[i, 2]
r = fens.xyz[i, 3] + Ri
fens.xyz[i, :] .= (r * sin(a), y, r * cos(a))
end
essential_bcs = FDataDict[]
x0nl = selectnode(fens, box = [0 0 -Inf Inf -Inf Inf], inflate = tolerance)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 1, "node_list" => x0nl),
)
y0nl = selectnode(fens, box = [-Inf Inf 0 0 -Inf Inf], inflate = tolerance)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 2, "node_list" => y0nl),
)
yLnl = selectnode(fens, box = [-Inf Inf L L -Inf Inf], inflate = tolerance)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 2, "node_list" => yLnl),
)
enl = connectednodes(subset(boundaryfes, ebcl))
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 1, "node_list" => enl),
)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 2, "node_list" => enl),
)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 3, "node_list" => enl),
)
inl = connectednodes(subset(boundaryfes, ibcl))
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 1, "node_list" => inl),
)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 2, "node_list" => inl),
)
push!(
essential_bcs,
FDataDict("displacement" => iuz, "component" => 3, "node_list" => inl),
)
modeldata =
FDataDict("fens" => fens, "regions" => regions, "essential_bcs" => essential_bcs)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
filebase = "bushing_h8_algo_ms"
modeldata["postprocessing"] = FDataDict(
"file" => filebase * "-nodal-",
"quantity" => :pressure,
"component" => collect(1:1),
"nodevalmethod" => :averaging,
"reportat" => :extraptrend,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
modeldata["postprocessing"] = FDataDict(
"file" => filebase * "-elwise-",
"quantity" => :pressure,
"component" => collect(1:1),
"nodevalmethod" => :averaging,
"reportat" => :extraptrend,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
true
end # bushing_h8_algo_ms
function bushing_h8u_algo_ms()
fens, fes = T4block(ang, L, Re - Ri, Int.(round.((nc, nt, nR) ./ 2) .+ 1)...)
fens, fes = T4toH8(fens, fes)
internal_fenids = selectnode(fens, box = [0 ang 0 L 0 0], inflate = tolerance)
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
regions = FDataDict[FDataDict("femm" => femm)]
boundaryfes = meshboundary(fes)
ibcl = selectelem(fens, boundaryfes, box = [0 ang 0 L 0 0], inflate = tolerance)
ebcl = selectelem(
fens,
boundaryfes,
box = [0 ang 0 L Re - Ri Re - Ri],
inflate = tolerance,
)
for i = 1:count(fens)
a = fens.xyz[i, 1]
y = fens.xyz[i, 2]
r = fens.xyz[i, 3] + Ri
fens.xyz[i, :] .= (r * sin(a), y, r * cos(a))
end
essential_bcs = FDataDict[]
x0nl = selectnode(fens, box = [0 0 -Inf Inf -Inf Inf], inflate = tolerance)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 1, "node_list" => x0nl),
)
y0nl = selectnode(fens, box = [-Inf Inf 0 0 -Inf Inf], inflate = tolerance)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 2, "node_list" => y0nl),
)
yLnl = selectnode(fens, box = [-Inf Inf L L -Inf Inf], inflate = tolerance)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 2, "node_list" => yLnl),
)
enl = connectednodes(subset(boundaryfes, ebcl))
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 1, "node_list" => enl),
)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 2, "node_list" => enl),
)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 3, "node_list" => enl),
)
inl = connectednodes(subset(boundaryfes, ibcl))
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 1, "node_list" => inl),
)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 2, "node_list" => inl),
)
push!(
essential_bcs,
FDataDict("displacement" => iuz, "component" => 3, "node_list" => inl),
)
modeldata =
FDataDict("fens" => fens, "regions" => regions, "essential_bcs" => essential_bcs)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
filebase = "bushing_h8u_algo_ms"
modeldata["postprocessing"] = FDataDict(
"file" => filebase * "-nodal-",
"quantity" => :pressure,
"component" => collect(1:1),
"nodevalmethod" => :averaging,
"reportat" => :extraptrend,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
modeldata["postprocessing"] = FDataDict(
"file" => filebase * "-elwise-",
"quantity" => :pressure,
"component" => collect(1:1),
"nodevalmethod" => :averaging,
"reportat" => :extraptrend,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
true
end # bushing_h8u_algo_ms
function bushing_h8_export()
nt = 1
for nperradius in [2, 4, 8]
nt = nt + 1
fens, fes = Q4circlen(R, nperradius)
fens, fes = H8extrudeQ4(fens, fes, nt, (x, k) -> [x[1], x[2], k * thickness / nt])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
boundaryfes = meshboundary(fes)
topl = selectelem(
fens,
boundaryfes,
box = [-Inf Inf -Inf Inf thickness thickness],
inflate = tolerance,
)
botl = selectelem(
fens,
boundaryfes,
box = [-Inf Inf -Inf Inf 0.0 0.0],
inflate = tolerance,
)
x0l = selectelem(
fens,
boundaryfes,
box = [0.0 0.0 -Inf Inf 0.0 thickness],
inflate = tolerance,
)
y0l = selectelem(
fens,
boundaryfes,
box = [-Inf Inf 0.0 0.0 0.0 thickness],
inflate = tolerance,
)
cyll = setdiff(1:count(boundaryfes), topl, botl, x0l, y0l)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
x0nl = connectednodes(subset(boundaryfes, x0l))
setebc!(u, x0nl, true, 1, 0.0)
y0nl = connectednodes(subset(boundaryfes, y0l))
setebc!(u, y0nl, true, 2, 0.0)
cylnl = connectednodes(subset(boundaryfes, cyll))
setebc!(u, cylnl, true, 1, 0.0)
setebc!(u, cylnl, true, 2, 0.0)
setebc!(u, cylnl, true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
cnl = selectnode(fens; box = [0 0 0 0 0 thickness], inflate = tolerance)
AE = AbaqusExporter("clcircularplatecl_h8_export_$(nperradius)")
HEADING(AE, "Clamped square plate with concentrated force")
PART(AE, "part1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
ELEMENT(AE, "c3d8rh", "AllElements", 1, connasarray(femm.integdomain.fes))
NSET_NSET(AE, "cnl", cnl)
NSET_NSET(AE, "x0nl", x0nl)
NSET_NSET(AE, "y0nl", y0nl)
NSET_NSET(AE, "cylnl", cylnl)
ORIENTATION(AE, "GlobalOrientation", vec([1.0 0 0]), vec([0 1.0 0]))
SOLID_SECTION(AE, "elasticity", "GlobalOrientation", "AllElements", "Hourglassctl")
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "elasticity")
ELASTIC(AE, E, nu)
SECTION_CONTROLS(AE, "Hourglassctl", "HOURGLASS=ENHANCED")
STEP_PERTURBATION_STATIC(AE)
BOUNDARY(AE, "ASSEM1.INSTNC1.x0nl", 1)
BOUNDARY(AE, "ASSEM1.INSTNC1.y0nl", 2)
BOUNDARY(AE, "ASSEM1.INSTNC1.cylnl", 1)
BOUNDARY(AE, "ASSEM1.INSTNC1.cylnl", 2)
BOUNDARY(AE, "ASSEM1.INSTNC1.cylnl", 3)
CLOAD(AE, "ASSEM1.INSTNC1.cnl", 3, Magnitude / 4 / length(cnl))
END_STEP(AE)
close(AE)
# File = "clcircularplatecl_h8_export_$(nperradius).vtk"
# vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
# @async run(`"paraview.exe" $File`)
end
true
end # bushing_h8_export
function bushing_t10_algo_ms()
fens, fes = T10block(ang, L, Re - Ri, nc, nt, nR)
internal_fenids = selectnode(fens, box = [0 ang 0 L 0 0], inflate = tolerance)
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMST10(MR, IntegDomain(fes, TetRule(4)), material)
regions = FDataDict[FDataDict("femm" => femm)]
boundaryfes = meshboundary(fes)
ibcl = selectelem(fens, boundaryfes, box = [0 ang 0 L 0 0], inflate = tolerance)
ebcl = selectelem(
fens,
boundaryfes,
box = [0 ang 0 L Re - Ri Re - Ri],
inflate = tolerance,
)
for i = 1:count(fens)
a = fens.xyz[i, 1]
y = fens.xyz[i, 2]
r = fens.xyz[i, 3] + Ri
fens.xyz[i, :] .= (r * sin(a), y, r * cos(a))
end
essential_bcs = FDataDict[]
x0nl = selectnode(fens, box = [0 0 -Inf Inf -Inf Inf], inflate = tolerance)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 1, "node_list" => x0nl),
)
y0nl = selectnode(fens, box = [-Inf Inf 0 0 -Inf Inf], inflate = tolerance)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 2, "node_list" => y0nl),
)
yLnl = selectnode(fens, box = [-Inf Inf L L -Inf Inf], inflate = tolerance)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 2, "node_list" => yLnl),
)
enl = connectednodes(subset(boundaryfes, ebcl))
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 1, "node_list" => enl),
)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 2, "node_list" => enl),
)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 3, "node_list" => enl),
)
inl = connectednodes(subset(boundaryfes, ibcl))
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 1, "node_list" => inl),
)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 2, "node_list" => inl),
)
push!(
essential_bcs,
FDataDict("displacement" => iuz, "component" => 3, "node_list" => inl),
)
modeldata =
FDataDict("fens" => fens, "regions" => regions, "essential_bcs" => essential_bcs)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
filebase = "bushing_T10_algo_ms"
modeldata["postprocessing"] = FDataDict(
"file" => filebase * "-nodal-",
"quantity" => :pressure,
"component" => collect(1:1),
"nodevalmethod" => :averaging,
"reportat" => :extraptrend,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
modeldata["postprocessing"] = FDataDict(
"file" => filebase * "-elwise-",
"quantity" => :pressure,
"component" => collect(1:1),
"nodevalmethod" => :averaging,
"reportat" => :extraptrend,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
true
end # bushing_t10_algo_ms
function bushing_t10_algo()
fens, fes = T10block(ang, L, Re - Ri, nc, nt, nR)
internal_fenids = selectnode(fens, box = [0 ang 0 L 0 0], inflate = tolerance)
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinear(MR, IntegDomain(fes, TetRule(4)), material)
regions = FDataDict[FDataDict("femm" => femm)]
boundaryfes = meshboundary(fes)
ibcl = selectelem(fens, boundaryfes, box = [0 ang 0 L 0 0], inflate = tolerance)
ebcl = selectelem(
fens,
boundaryfes,
box = [0 ang 0 L Re - Ri Re - Ri],
inflate = tolerance,
)
for i = 1:count(fens)
a = fens.xyz[i, 1]
y = fens.xyz[i, 2]
r = fens.xyz[i, 3] + Ri
fens.xyz[i, :] .= (r * sin(a), y, r * cos(a))
end
essential_bcs = FDataDict[]
x0nl = selectnode(fens, box = [0 0 -Inf Inf -Inf Inf], inflate = tolerance)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 1, "node_list" => x0nl),
)
y0nl = selectnode(fens, box = [-Inf Inf 0 0 -Inf Inf], inflate = tolerance)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 2, "node_list" => y0nl),
)
yLnl = selectnode(fens, box = [-Inf Inf L L -Inf Inf], inflate = tolerance)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 2, "node_list" => yLnl),
)
enl = connectednodes(subset(boundaryfes, ebcl))
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 1, "node_list" => enl),
)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 2, "node_list" => enl),
)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 3, "node_list" => enl),
)
inl = connectednodes(subset(boundaryfes, ibcl))
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 1, "node_list" => inl),
)
push!(
essential_bcs,
FDataDict("displacement" => 0.0, "component" => 2, "node_list" => inl),
)
push!(
essential_bcs,
FDataDict("displacement" => iuz, "component" => 3, "node_list" => inl),
)
modeldata =
FDataDict("fens" => fens, "regions" => regions, "essential_bcs" => essential_bcs)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
filebase = "bushing_T10_algo"
modeldata["postprocessing"] = FDataDict(
"file" => filebase * "-nodal-",
"quantity" => :pressure,
"component" => collect(1:1),
"nodevalmethod" => :averaging,
"reportat" => :extraptrend,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
modeldata["postprocessing"] = FDataDict(
"file" => filebase * "-elwise-",
"quantity" => :pressure,
"component" => collect(1:1),
"nodevalmethod" => :averaging,
"reportat" => :extraptrend,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
true
end # bushing_t10_algo_ms
# true
# end # twisted_beam_export
function allrun()
println("#####################################################")
println("# bushing_h8_full ")
bushing_h8_full()
println("#####################################################")
println("# bushing_h8_algo_full ")
bushing_h8_algo_full()
println("#####################################################")
println("# bushing_h8_algo_ms ")
bushing_h8_algo_ms()
println("#####################################################")
println("# bushing_h8u_algo_ms ")
bushing_h8u_algo_ms()
println("#####################################################")
println("# bushing_t10_algo_ms")
bushing_t10_algo_ms()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 14886 | module clcircularplatecl_examples
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtools.MeshExportModule
using Statistics: mean
# Clamped square plate with concentrated force
# Data listed in the Simo 1990 paper 'A class of... '
# Analytical solution for the vertical deflection under the load
# Zienkiewicz, Taylor, The finite element method, fifth edition, volume 2,
# analyt_sol = 3*(1-nu^2)*Magnitude*R^2/(4*pi*E*thickness^3);
E = 1e7
nu = 0.3
Magnitude = 10
R = 100.0
thickness = 2.5
tolerance = 0.0001 * thickness
@show analyt_sol = 3 * (1 - nu^2) * Magnitude * R^2 / (4 * pi * E * thickness^3)
function clcircularplatecl_h8_full()
nt = 1
for nperradius in [2, 4, 8]
nt = nt + 1
fens, fes = Q4circlen(R, nperradius)
fens, fes = H8extrudeQ4(fens, fes, nt, (x, k) -> [x[1], x[2], k * thickness / nt])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
boundaryfes = meshboundary(fes)
topl = selectelem(
fens,
boundaryfes,
box = [-Inf Inf -Inf Inf thickness thickness],
inflate = tolerance,
)
botl = selectelem(
fens,
boundaryfes,
box = [-Inf Inf -Inf Inf 0.0 0.0],
inflate = tolerance,
)
x0l = selectelem(
fens,
boundaryfes,
box = [0.0 0.0 -Inf Inf 0.0 thickness],
inflate = tolerance,
)
y0l = selectelem(
fens,
boundaryfes,
box = [-Inf Inf 0.0 0.0 0.0 thickness],
inflate = tolerance,
)
cyll = setdiff(1:count(boundaryfes), topl, botl, x0l, y0l)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
x0nl = connectednodes(subset(boundaryfes, x0l))
setebc!(u, x0nl, true, 1, 0.0)
y0nl = connectednodes(subset(boundaryfes, y0l))
setebc!(u, y0nl, true, 2, 0.0)
cylnl = connectednodes(subset(boundaryfes, cyll))
setebc!(u, cylnl, true, 1, 0.0)
setebc!(u, cylnl, true, 2, 0.0)
setebc!(u, cylnl, true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
cnl = selectnode(fens; box = [0 0 0 0 0 thickness], inflate = tolerance)
nfemm = FEMMBase(IntegDomain(FESetP1(reshape(cnl, length(cnl), 1)), PointRule()))
F = distribloads(
nfemm,
geom,
u,
ForceIntensity([0; 0; Magnitude / 4 / length(cnl)]),
3,
)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
scattersysvec!(u, K \ F)
u0z = mean(u.values[cnl, 3])
println(
"Deflection under the load: $(round((u0z / analyt_sol)* 100000)/100000*100) %",
)
# File = "clcircularplatecl_1_$(nperradius).vtk"
# vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
# @async run(`"paraview.exe" $File`)
end
true
end # clcircularplatecl_h8_full
function clcircularplatecl_h8_uri()
nt = 1
for nperradius in [2, 4, 8]
nt = nt + 1
fens, fes = Q4circlen(R, nperradius)
fens, fes = H8extrudeQ4(fens, fes, nt, (x, k) -> [x[1], x[2], k * thickness / nt])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 1)), material)
boundaryfes = meshboundary(fes)
topl = selectelem(
fens,
boundaryfes,
box = [-Inf Inf -Inf Inf thickness thickness],
inflate = tolerance,
)
botl = selectelem(
fens,
boundaryfes,
box = [-Inf Inf -Inf Inf 0.0 0.0],
inflate = tolerance,
)
x0l = selectelem(
fens,
boundaryfes,
box = [0.0 0.0 -Inf Inf 0.0 thickness],
inflate = tolerance,
)
y0l = selectelem(
fens,
boundaryfes,
box = [-Inf Inf 0.0 0.0 0.0 thickness],
inflate = tolerance,
)
cyll = setdiff(1:count(boundaryfes), topl, botl, x0l, y0l)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
x0nl = connectednodes(subset(boundaryfes, x0l))
setebc!(u, x0nl, true, 1, 0.0)
y0nl = connectednodes(subset(boundaryfes, y0l))
setebc!(u, y0nl, true, 2, 0.0)
cylnl = connectednodes(subset(boundaryfes, cyll))
setebc!(u, cylnl, true, 1, 0.0)
setebc!(u, cylnl, true, 2, 0.0)
setebc!(u, cylnl, true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
cnl = selectnode(fens; box = [0 0 0 0 0 thickness], inflate = tolerance)
nfemm = FEMMBase(IntegDomain(FESetP1(reshape(cnl, length(cnl), 1)), PointRule()))
F = distribloads(
nfemm,
geom,
u,
ForceIntensity([0; 0; Magnitude / 4 / length(cnl)]),
3,
)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
scattersysvec!(u, K \ F)
u0z = mean(u.values[cnl, 3])
println(
"Deflection under the load: $(round((u0z / analyt_sol)* 100000)/100000*100) %",
)
# File = "clcircularplatecl_1_$(nperradius).vtk"
# vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
# @async run(`"paraview.exe" $File`)
end
true
end # clcircularplatecl_h8_uri
function clcircularplatecl_h8_ms()
nt = 1
for nperradius in [2, 4, 8]
nt = nt + 1
fens, fes = Q4circlen(R, nperradius)
fens, fes = H8extrudeQ4(fens, fes, nt, (x, k) -> [x[1], x[2], k * thickness / nt])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
boundaryfes = meshboundary(fes)
topl = selectelem(
fens,
boundaryfes,
box = [-Inf Inf -Inf Inf thickness thickness],
inflate = tolerance,
)
botl = selectelem(
fens,
boundaryfes,
box = [-Inf Inf -Inf Inf 0.0 0.0],
inflate = tolerance,
)
x0l = selectelem(
fens,
boundaryfes,
box = [0.0 0.0 -Inf Inf 0.0 thickness],
inflate = tolerance,
)
y0l = selectelem(
fens,
boundaryfes,
box = [-Inf Inf 0.0 0.0 0.0 thickness],
inflate = tolerance,
)
cyll = setdiff(1:count(boundaryfes), topl, botl, x0l, y0l)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
x0nl = connectednodes(subset(boundaryfes, x0l))
setebc!(u, x0nl, true, 1, 0.0)
y0nl = connectednodes(subset(boundaryfes, y0l))
setebc!(u, y0nl, true, 2, 0.0)
cylnl = connectednodes(subset(boundaryfes, cyll))
setebc!(u, cylnl, true, 1, 0.0)
setebc!(u, cylnl, true, 2, 0.0)
setebc!(u, cylnl, true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
cnl = selectnode(fens; box = [0 0 0 0 0 thickness], inflate = tolerance)
nfemm = FEMMBase(IntegDomain(FESetP1(reshape(cnl, length(cnl), 1)), PointRule()))
F = distribloads(
nfemm,
geom,
u,
ForceIntensity([0; 0; Magnitude / 4 / length(cnl)]),
3,
)
associategeometry!(femm, geom)
@show minimum(femm.phis), maximum(femm.phis)
K = stiffness(femm, geom, u)
scattersysvec!(u, K \ F)
u0z = mean(u.values[cnl, 3])
println(
"Deflection under the load: $(round((u0z / analyt_sol)* 100000)/100000*100) %",
)
# File = "clcircularplatecl_1_$(nperradius).vtk"
# vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
# @async run(`"paraview.exe" $File`)
end
true
end # clcircularplatecl_h8_ms
function clcircularplatecl_h8u_ms()
nt = 1
for nperradius in [2, 4, 8]
nt = nt + 1
fens, fes = T4quartercyln(R, thickness, nperradius, nt)
fens, fes = T4toH8(fens, fes)
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
boundaryfes = meshboundary(fes)
topl = selectelem(
fens,
boundaryfes,
box = [-Inf Inf -Inf Inf thickness thickness],
inflate = tolerance,
)
botl = selectelem(
fens,
boundaryfes,
box = [-Inf Inf -Inf Inf 0.0 0.0],
inflate = tolerance,
)
x0l = selectelem(
fens,
boundaryfes,
box = [0.0 0.0 -Inf Inf 0.0 thickness],
inflate = tolerance,
)
y0l = selectelem(
fens,
boundaryfes,
box = [-Inf Inf 0.0 0.0 0.0 thickness],
inflate = tolerance,
)
cyll = setdiff(1:count(boundaryfes), topl, botl, x0l, y0l)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
x0nl = connectednodes(subset(boundaryfes, x0l))
setebc!(u, x0nl, true, 1, 0.0)
y0nl = connectednodes(subset(boundaryfes, y0l))
setebc!(u, y0nl, true, 2, 0.0)
cylnl = connectednodes(subset(boundaryfes, cyll))
setebc!(u, cylnl, true, 1, 0.0)
setebc!(u, cylnl, true, 2, 0.0)
setebc!(u, cylnl, true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
cnl = selectnode(fens; box = [0 0 0 0 0 thickness], inflate = tolerance)
nfemm = FEMMBase(IntegDomain(FESetP1(reshape(cnl, length(cnl), 1)), PointRule()))
F = distribloads(
nfemm,
geom,
u,
ForceIntensity([0; 0; Magnitude / 4 / length(cnl)]),
3,
)
associategeometry!(femm, geom)
@show minimum(femm.phis), maximum(femm.phis)
K = stiffness(femm, geom, u)
scattersysvec!(u, K \ F)
u0z = mean(u.values[cnl, 3])
println(
"Deflection under the load: $(round((u0z / analyt_sol)* 100000)/100000*100) %",
)
File = "clcircularplatecl_h8u_ms_$(nperradius).vtk"
vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
@async run(`"paraview.exe" $File`)
end
true
end # clcircularplatecl_h8u_ms
function clcircularplatecl_h8_export()
nt = 1
for nperradius in [2, 4, 8]
nt = nt + 1
fens, fes = Q4circlen(R, nperradius)
fens, fes = H8extrudeQ4(fens, fes, nt, (x, k) -> [x[1], x[2], k * thickness / nt])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
boundaryfes = meshboundary(fes)
topl = selectelem(
fens,
boundaryfes,
box = [-Inf Inf -Inf Inf thickness thickness],
inflate = tolerance,
)
botl = selectelem(
fens,
boundaryfes,
box = [-Inf Inf -Inf Inf 0.0 0.0],
inflate = tolerance,
)
x0l = selectelem(
fens,
boundaryfes,
box = [0.0 0.0 -Inf Inf 0.0 thickness],
inflate = tolerance,
)
y0l = selectelem(
fens,
boundaryfes,
box = [-Inf Inf 0.0 0.0 0.0 thickness],
inflate = tolerance,
)
cyll = setdiff(1:count(boundaryfes), topl, botl, x0l, y0l)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
x0nl = connectednodes(subset(boundaryfes, x0l))
setebc!(u, x0nl, true, 1, 0.0)
y0nl = connectednodes(subset(boundaryfes, y0l))
setebc!(u, y0nl, true, 2, 0.0)
cylnl = connectednodes(subset(boundaryfes, cyll))
setebc!(u, cylnl, true, 1, 0.0)
setebc!(u, cylnl, true, 2, 0.0)
setebc!(u, cylnl, true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
cnl = selectnode(fens; box = [0 0 0 0 0 thickness], inflate = tolerance)
AE = AbaqusExporter("clcircularplatecl_h8_export_$(nperradius)")
HEADING(AE, "Clamped square plate with concentrated force")
PART(AE, "part1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
ELEMENT(AE, "c3d8rh", "AllElements", 1, connasarray(femm.integdomain.fes))
NSET_NSET(AE, "cnl", cnl)
NSET_NSET(AE, "x0nl", x0nl)
NSET_NSET(AE, "y0nl", y0nl)
NSET_NSET(AE, "cylnl", cylnl)
ORIENTATION(AE, "GlobalOrientation", vec([1.0 0 0]), vec([0 1.0 0]))
SOLID_SECTION(AE, "elasticity", "GlobalOrientation", "AllElements", "Hourglassctl")
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "elasticity")
ELASTIC(AE, E, nu)
SECTION_CONTROLS(AE, "Hourglassctl", "HOURGLASS=ENHANCED")
STEP_PERTURBATION_STATIC(AE)
BOUNDARY(AE, "ASSEM1.INSTNC1.x0nl", 1)
BOUNDARY(AE, "ASSEM1.INSTNC1.y0nl", 2)
BOUNDARY(AE, "ASSEM1.INSTNC1.cylnl", 1)
BOUNDARY(AE, "ASSEM1.INSTNC1.cylnl", 2)
BOUNDARY(AE, "ASSEM1.INSTNC1.cylnl", 3)
CLOAD(AE, "ASSEM1.INSTNC1.cnl", 3, Magnitude / 4 / length(cnl))
END_STEP(AE)
close(AE)
# File = "clcircularplatecl_h8_export_$(nperradius).vtk"
# vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
# @async run(`"paraview.exe" $File`)
end
true
end # clcircularplatecl_h8_export
# true
# end # twisted_beam_export
function allrun()
println("#####################################################")
println("# clcircularplatecl_h8_full ")
clcircularplatecl_h8_full()
println("#####################################################")
println("# clcircularplatecl_h8_uri ")
clcircularplatecl_h8_uri()
println("#####################################################")
println("# clcircularplatecl_h8_ms ")
clcircularplatecl_h8_ms()
println("#####################################################")
println("# clcircularplatecl_h8_export ")
clcircularplatecl_h8_export()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 4897 | module cook_like_examples
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtools.MeshExportModule
using Statistics
function allrun()
mu = 756000
nu = 0.49546
E = 2 * (1.0 + nu) * mu
width = 48.0
height = 44.0
thickness = 10.0
free_height = 16.0
Mid_edge = [48.0 52.0 0.0]# Location of tracked deflection
magn = 1.0 / (free_height * thickness)# Density of applied load
nt = 1
n = 16 * nt# number of elements per side
tolerance = minimum([width, height]) / n / 1000.0#Geometrical tolerance
fens, fes = T10block(width, height, thickness, n, n, nt)
# Reshape into a trapezoidal panel
for i = 1:count(fens)
fens.xyz[i, 2] =
fens.xyz[i, 2] +
(fens.xyz[i, 1] / width) *
(height - fens.xyz[i, 2] / height * (height - free_height))
end
# Clamped edge of the membrane
l1 = selectnode(fens; box = [0.0, 0.0, -Inf, Inf, -Inf, Inf], inflate = tolerance)
ess1 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => l1)
ess2 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => l1)
ess3 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => l1)
# Traction on the opposite edge
boundaryfes = meshboundary(fes)
Toplist = selectelem(
fens,
boundaryfes,
box = [width, width, -Inf, Inf, -Inf, Inf],
inflate = tolerance,
)
el1femm = FEMMBase(IntegDomain(subset(boundaryfes, Toplist), SimplexRule(2, 3)))
flux1 = FDataDict("traction_vector" => [0.0, 0.0, +magn], "femm" => el1femm)
# Make the region
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, 0.0)
region1 = FDataDict(
"femm" =>
FEMMDeforLinearMST10(MR, IntegDomain(fes, SimplexRule(3, 4)), material),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [ess1, ess2, ess3],
"traction_bcs" => [flux1],
)
# Call the solver
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# Extract the solution
nl = selectnode(
fens,
box = [Mid_edge[1], Mid_edge[1], Mid_edge[2], Mid_edge[2], -Inf, Inf],
inflate = tolerance,
)
theutip = mean(u.values[nl, :], dims = 1)
println("displacement =$(theutip[2]) ")
modeldata["postprocessing"] =
FDataDict("file" => "cook_like-ew", "quantity" => :Cauchy, "component" => :xy)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
println("range of Cauchy_xy = $((minimum(fld.values), maximum(fld.values)))")
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`)
modeldata["postprocessing"] =
FDataDict("file" => "cook_like-ew-vm", "quantity" => :vm, "component" => 1)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
println("range of vm = $((minimum(fld.values), maximum(fld.values)))")
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`)
modeldata["postprocessing"] = FDataDict(
"file" => "cook_like-ew-pressure",
"quantity" => :pressure,
"component" => 1,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
println("range of pressure = $((minimum(fld.values), maximum(fld.values)))")
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`)
modeldata["postprocessing"] = FDataDict(
"file" => "cook_like-ew-princ1",
"quantity" => :princCauchy,
"component" => 1,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
println("range of princCauchy Max = $((minimum(fld.values), maximum(fld.values)))")
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`)
modeldata["postprocessing"] = FDataDict(
"file" => "cook_like-ew-princ3",
"quantity" => :princCauchy,
"component" => 3,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
println("range of princCauchy Min = $((minimum(fld.values), maximum(fld.values)))")
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`)
true
end
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 12171 | module distorted_block_infsup_examples
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtools.MeshExportModule
using FinEtoolsDeforLinear.FEMMDeforLinearBaseModule: infsup_gh, infsup_sh
using Test
import LinearAlgebra: norm, cholesky, I, eigen
using UnicodePlots
function distorted_block_infsup_T10()
lambdatol = sqrt(1e8 * eps(1.0))
E = 1000.0
nu = 0.24
parshiftmult = 0.002
A = [1.44 -0.741 -0.53; -0.626 1.589 -0.913; -0.55 0.43 1.756] + 1.0I
lambdamin = Float64[]
h = Float64[]
for ne in [2, 3, 4]
Length::FFlt,
Width::FFlt,
Height::FFlt,
nL::FInt,
nW::FInt,
nH::FInt,
orientation::Symbol = (6.0, 6.0, 6.0, ne, ne, ne, :a)
fens, fes = T4block(
Length::FFlt,
Width::FFlt,
Height::FFlt,
nL::FInt,
nW::FInt,
nH::FInt,
orientation::Symbol,
)
fens, fes = T4toT10(fens, fes)
# @show connasarray(fes)
for i = 1:count(fens)
fens.xyz[i, :] = fens.xyz[i, :] + vec(reshape(fens.xyz[i, :], 1, 3) * A)
end
# @show fens.xyz
# File = "minfsuptest1.vtk"
# vtkexportmesh(File, fens, fes)
# try rm(File); catch end
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
bfes = meshboundary(fes)
l1 = connectednodes(bfes)
setebc!(u, l1, true, 1, 0.0)
setebc!(u, l1, true, 2, 0.0)
setebc!(u, l1, true, 3, 0.0)
numberdofs!(u)
femm = FEMMDeforLinear(MR, IntegDomain(fes, TetRule(1)), material)
Gh = infsup_gh(femm, geom, u)
femm = FEMMDeforLinear(MR, IntegDomain(fes, TetRule(1)), material)
Sh = infsup_sh(femm, geom, u)
lambda, modes = eigen(Matrix(Gh), Matrix(Sh))
# @show lambda
abslambda = real.(filter(y -> !isnan(y), lambda))
ix = findall(y -> y < 0.0, abslambda)
if !isempty(ix)
abslambda[ix] .= 0
end
abslambda = sqrt.(sort(abslambda))
ix = findall(y -> y > 0.0, abslambda)
a = lineplot(
1:length(abslambda[ix]),
log.(abslambda[ix]),
name = "infsup",
xlabel = "eigenvalue",
ylabel = "log(eigenvalue)",
canvas = DotCanvas,
)
display(a)
ix = findall(y -> y >= lambdatol, abslambda)
if isempty(ix)
@error "Bad guess of the number of eigenvalues"
end
push!(lambdamin, abslambda[ix[1]])
push!(h, 1.0 / (count(fens))^(1 / 3))
end
@show lambdamin
a = lineplot(
log.(h),
log.(lambdamin),
name = "infsup",
xlabel = "log(Element Size)",
ylabel = "log(minimum eigenvalue)",
canvas = DotCanvas,
)
display(a)
# @test norm(lambdamin - [0.262065, 0.1709, 0.126159, 0.100228, 0.0828139]) / norm(lambdamin) <= 1.0e-4
end
function distorted_block_infsup_T4()
lambdatol = sqrt(1e8 * eps(1.0))
E = 1000.0
nu = 0.24
parshiftmult = 0.002
A = [1.44 -0.741 -0.53; -0.626 1.589 -0.913; -0.55 0.43 1.756] + 1.0I
lambdamin = Float64[]
h = Float64[]
for ne in [2, 3, 4]
Length::FFlt,
Width::FFlt,
Height::FFlt,
nL::FInt,
nW::FInt,
nH::FInt,
orientation::Symbol = (6.0, 6.0, 6.0, ne, ne, ne, :a)
fens, fes = T4block(
Length::FFlt,
Width::FFlt,
Height::FFlt,
nL::FInt,
nW::FInt,
nH::FInt,
orientation::Symbol,
)
# fens, fes = T4toT10(fens, fes)
# @show connasarray(fes)
for i = 1:count(fens)
fens.xyz[i, :] = fens.xyz[i, :] + vec(reshape(fens.xyz[i, :], 1, 3) * A)
end
# @show fens.xyz
# File = "minfsuptest1.vtk"
# vtkexportmesh(File, fens, fes)
# try rm(File); catch end
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
bfes = meshboundary(fes)
l1 = connectednodes(bfes)
setebc!(u, l1, true, 1, 0.0)
setebc!(u, l1, true, 2, 0.0)
setebc!(u, l1, true, 3, 0.0)
numberdofs!(u)
femm = FEMMDeforLinear(MR, IntegDomain(fes, TetRule(1)), material)
Gh = infsup_gh(femm, geom, u)
femm = FEMMDeforLinear(MR, IntegDomain(fes, TetRule(1)), material)
Sh = infsup_sh(femm, geom, u)
lambda, modes = eigen(Matrix(Gh), Matrix(Sh))
# @show lambda
abslambda = real.(filter(y -> !isnan(y), lambda))
ix = findall(y -> y < 0.0, abslambda)
if !isempty(ix)
abslambda[ix] .= 0
end
abslambda = sqrt.(sort(abslambda))
ix = findall(y -> y > 0.0, abslambda)
a = lineplot(
1:length(abslambda[ix]),
log.(abslambda[ix]),
name = "infsup",
xlabel = "eigenvalue",
ylabel = "log(eigenvalue)",
canvas = DotCanvas,
)
display(a)
ix = findall(y -> y >= lambdatol, abslambda)
if isempty(ix)
@error "Bad guess of the number of eigenvalues"
end
push!(lambdamin, abslambda[ix[1]])
push!(h, 1.0 / (count(fens))^(1 / 3))
end
@show lambdamin
a = lineplot(
log.(h),
log.(lambdamin),
name = "infsup",
xlabel = "log(Element Size)",
ylabel = "log(minimum eigenvalue)",
canvas = DotCanvas,
)
display(a)
# @test norm(lambdamin - [0.262065, 0.1709, 0.126159, 0.100228, 0.0828139]) / norm(lambdamin) <= 1.0e-4
end
function distorted_block_infsup_H8()
lambdatol = sqrt(1e8 * eps(1.0))
E = 1000.0
nu = 0.24
parshiftmult = 0.002
A = [1.44 -0.741 -0.53; -0.626 1.589 -0.913; -0.55 0.43 1.756] + 1.0I
lambdamin = Float64[]
h = Float64[]
for ne in [2, 3, 4]
Length::FFlt,
Width::FFlt,
Height::FFlt,
nL::FInt,
nW::FInt,
nH::FInt,
orientation::Symbol = (6.0, 6.0, 6.0, ne, ne, ne, :a)
fens, fes =
H8block(Length::FFlt, Width::FFlt, Height::FFlt, nL::FInt, nW::FInt, nH::FInt)
# fens, fes = T4toT10(fens, fes)
# @show connasarray(fes)
for i = 1:count(fens)
fens.xyz[i, :] = fens.xyz[i, :] + vec(reshape(fens.xyz[i, :], 1, 3) * A)
end
# @show fens.xyz
# File = "minfsuptest1.vtk"
# vtkexportmesh(File, fens, fes)
# try rm(File); catch end
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
bfes = meshboundary(fes)
l1 = connectednodes(bfes)
setebc!(u, l1, true, 1, 0.0)
setebc!(u, l1, true, 2, 0.0)
setebc!(u, l1, true, 3, 0.0)
numberdofs!(u)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 1)), material)
Gh = infsup_gh(femm, geom, u)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 1)), material)
Sh = infsup_sh(femm, geom, u)
lambda, modes = eigen(Matrix(Gh), Matrix(Sh))
# @show lambda
abslambda = real.(filter(y -> !isnan(y), lambda))
ix = findall(y -> y < 0.0, abslambda)
if !isempty(ix)
abslambda[ix] .= 0
end
abslambda = sqrt.(sort(abslambda))
ix = findall(y -> y > 0.0, abslambda)
a = lineplot(
1:length(abslambda[ix]),
log.(abslambda[ix]),
name = "infsup",
xlabel = "eigenvalue",
ylabel = "log(eigenvalue)",
canvas = DotCanvas,
)
display(a)
ix = findall(y -> y >= lambdatol, abslambda)
if isempty(ix)
@error "Bad guess of the number of eigenvalues"
end
push!(lambdamin, abslambda[ix[1]])
push!(h, 1.0 / (count(fens))^(1 / 3))
end
@show lambdamin
a = lineplot(
log.(h),
log.(lambdamin),
name = "infsup",
xlabel = "log(Element Size)",
ylabel = "log(minimum eigenvalue)",
canvas = DotCanvas,
)
display(a)
# @test norm(lambdamin - [0.262065, 0.1709, 0.126159, 0.100228, 0.0828139]) / norm(lambdamin) <= 1.0e-4
end
function distorted_block_infsup_H20()
lambdatol = sqrt(1e8 * eps(1.0))
E = 1000.0
nu = 0.24
parshiftmult = 0.002
A = [1.44 -0.741 -0.53; -0.626 1.589 -0.913; -0.55 0.43 1.756] + 1.0I
lambdamin = Float64[]
h = Float64[]
for ne in [2, 3, 4]
Length::FFlt,
Width::FFlt,
Height::FFlt,
nL::FInt,
nW::FInt,
nH::FInt,
orientation::Symbol = (6.0, 6.0, 6.0, ne, ne, ne, :a)
fens, fes =
H20block(Length::FFlt, Width::FFlt, Height::FFlt, nL::FInt, nW::FInt, nH::FInt)
# fens, fes = T4toT10(fens, fes)
# @show connasarray(fes)
for i = 1:count(fens)
fens.xyz[i, :] = fens.xyz[i, :] + vec(reshape(fens.xyz[i, :], 1, 3) * A)
end
# @show fens.xyz
# File = "minfsuptest1.vtk"
# vtkexportmesh(File, fens, fes)
# try rm(File); catch end
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
bfes = meshboundary(fes)
l1 = connectednodes(bfes)
setebc!(u, l1, true, 1, 0.0)
setebc!(u, l1, true, 2, 0.0)
setebc!(u, l1, true, 3, 0.0)
numberdofs!(u)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
Gh = infsup_gh(femm, geom, u)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
Sh = infsup_sh(femm, geom, u)
lambda, modes = eigen(Matrix(Gh), Matrix(Sh))
# @show lambda
abslambda = real.(filter(y -> !isnan(y), lambda))
ix = findall(y -> y < 0.0, abslambda)
if !isempty(ix)
abslambda[ix] .= 0
end
abslambda = sqrt.(sort(abslambda))
ix = findall(y -> y > 0.0, abslambda)
a = lineplot(
1:length(abslambda[ix]),
log.(abslambda[ix]),
name = "infsup",
xlabel = "eigenvalue",
ylabel = "log(eigenvalue)",
canvas = DotCanvas,
)
display(a)
ix = findall(y -> y >= lambdatol, abslambda)
if isempty(ix)
@error "Bad guess of the number of eigenvalues"
end
push!(lambdamin, abslambda[ix[1]])
push!(h, 1.0 / (count(fens))^(1 / 3))
end
@show lambdamin
a = lineplot(
log.(h),
log.(lambdamin),
name = "infsup",
xlabel = "log(Element Size)",
ylabel = "log(minimum eigenvalue)",
canvas = DotCanvas,
)
display(a)
# @test norm(lambdamin - [0.262065, 0.1709, 0.126159, 0.100228, 0.0828139]) / norm(lambdamin) <= 1.0e-4
end
function allrun()
println("#####################################################")
println("# distorted_block_infsup_T4 ")
distorted_block_infsup_T4()
println("#####################################################")
println("# distorted_block_infsup_H8 ")
distorted_block_infsup_H8()
println("#####################################################")
println("# distorted_block_infsup_T10 ")
distorted_block_infsup_T10()
println("#####################################################")
println("# distorted_block_infsup_H20 ")
distorted_block_infsup_H20()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 32788 | module fiber_reinf_cant_examples
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
# using IterativeSolvers
using Statistics: mean
using LinearAlgebra: Symmetric, cholesky, norm
function fiber_reinf_cant_iso()
println("""
Cantilever example. Isotropic material.
@article{
author = {Krysl, P.},
title = {Mean-strain 8-node hexahedron with optimized energy-sampling stabilization},
journal = {Finite Elements in Analysis and Design},
volume = {108}, pages = {41-53}, DOI = {10.1016/j.finel.2015.09.008}, year = {2016}
}
""")
t0 = time()
# # Orthotropic material parameters of the external cylinder
# E1s = 130.0*phun("GPa")
# E2s = 5.0*phun("GPa")
# E3s = E2s
# nu12s = nu13s = 0.25
# nu23s = 0.0
# G12s = 10.0*phun("GPa")
# G13s = G12s
# G23s = 5.0*phun("GPa")
# CTE1 = 3.0e-6
# CTE2 = 2.0e-5
# CTE3 = 2.0e-5
# Isotropic material
E = 1.0e9 * phun("Pa")
nu = 0.25
CTE = 0.0
# Reference value for the vertical deflection of the tip
uz_ref = -7.516310912734678e-06
a = 90.0 * phun("mm") # length of the cantilever
b = 10.0 * phun("mm") # width of the cross-section
t = 20.0 * phun("mm") # height of the cross-section
q0 = -1000.0 * phun("Pa") # shear traction
dT = 0 * phun("K") # temperature rise
tolerance = 0.00001 * t
# Generate mesh
n = 16
na = n # number of elements lengthwise
nb = n # number of elements through the wwith
nt = n # number of elements through the thickness
xs = collect(linearspace(0.0, a, na + 1))
ys = collect(linearspace(0.0, b, nb + 1))
ts = collect(linearspace(0.0, t, nt + 1))
fens, fes = H8blockx(xs, ys, ts)
fens, fes = H8toH20(fens, fes)
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sshearl = selectelem(fens, bfes; facing = true, direction = [+1.0 0.0 0.0])
MR = DeforModelRed3D
# externalmaterial = MatDeforElastOrtho(MR,
# 0.0, E1s, E2s, E3s,
# nu12s, nu13s, nu23s,
# G12s, G13s, G23s,
# CTE1, CTE2, CTE3)
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
# Material orientation matrix
csmat = [i == j ? one(FFlt) : zero(FFlt) for i = 1:3, j = 1:3]
function updatecs!(csmatout::FFltMat, XYZ::FFltMat, tangents::FFltMat, fe_label::FInt)
copyto!(csmatout, csmat)
end
gr = GaussRule(3, 2)
region = FDataDict("femm" => FEMMDeforLinear(MR, IntegDomain(fes, gr), material))
lx0 = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
ex01 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lx0)
ex02 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => lx0)
ex03 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lx0)
function getshr!(forceout::FFltVec, XYZ::FFltMat, tangents::FFltMat, fe_label::FInt)
copyto!(forceout, q0 * [0.0; 0.0; 1.0])
end
Trac = FDataDict(
"traction_vector" => getshr!,
"femm" => FEMMBase(IntegDomain(subset(bfes, sshearl), GaussRule(2, 3))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [region],
"essential_bcs" => [ex01, ex02, ex03],
"traction_bcs" => [Trac],
"temperature_change" => FDataDict("temperature" => dT),
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
Tipl = selectnode(fens, box = [a a b b 0.0 0.0], inflate = tolerance)
utip = mean(u.values[Tipl, 3])
println(" Normalized deflection: $(utip/uz_ref)")
println("Solution: $( time()-t0 )")
# File = "NAFEMS-R0031-2-plate.vtk"
# vtkexportmesh(File, fes.conn, geom.values, FinEtools.MeshExportModule.H20;
# scalars = [("Layer", fes.label)], vectors = [("displacement", u.values)])
# @async run(`"paraview.exe" $File`)
modeldata["postprocessing"] = FDataDict(
"file" => "fiber_reinf_cant_iso",
"outputcsys" => CSys(3, 3, updatecs!),
"quantity" => :Cauchy,
"component" => 5,
)
# modeldata = AlgoDeforLinearModule.exportstress(modeldata)
modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
println("Done: $( time()-t0 )")
true
end # fiber_reinf_cant_iso
function fiber_reinf_cant_iso_stresses()
println("""
Cantilever example. Isotropic material.
@article{
author = {Krysl, P.},
title = {Mean-strain 8-node hexahedron with optimized energy-sampling stabilization},
journal = {Finite Elements in Analysis and Design},
volume = {108}, pages = {41-53}, DOI = {10.1016/j.finel.2015.09.008}, year = {2016}
}
""")
# Isotropic material
E = 1.0e9 * phun("Pa")
nu = 0.25
CTE = 0.0
# Reference value for the vertical deflection of the tip
uz_ref = -7.516310912734678e-06
a = 90.0 * phun("mm") # length of the cantilever
b = 10.0 * phun("mm") # width of the cross-section
t = 20.0 * phun("mm") # height of the cross-section
q0 = -1000.0 * phun("Pa") # shear traction
dT = 0 * phun("K") # temperature rise
tolerance = 0.00001 * t
# Generate mesh
for n in [2 4 8 16 32]
na = n # number of elements lengthwise
nb = n # number of elements through the wwith
nt = n # number of elements through the thickness
xs = collect(linearspace(0.0, a, na + 1))
ys = collect(linearspace(0.0, b, nb + 1))
ts = collect(linearspace(0.0, t, nt + 1))
fens, fes = H8blockx(xs, ys, ts)
# fens,fes = H8toH20(fens,fes)
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sshearl = selectelem(fens, bfes; facing = true, direction = [+1.0 0.0 0.0])
MR = DeforModelRed3D
# externalmaterial = MatDeforElastOrtho(MR,
# 0.0, E1s, E2s, E3s,
# nu12s, nu13s, nu23s,
# G12s, G13s, G23s,
# CTE1, CTE2, CTE3)
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
# Material orientation matrix
csmat = [i == j ? one(FFlt) : zero(FFlt) for i = 1:3, j = 1:3]
function updatecs!(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
)
copyto!(csmatout, csmat)
end
gr = GaussRule(3, 2)
region =
FDataDict("femm" => FEMMDeforLinearMSH8(MR, IntegDomain(fes, gr), material))
lx0 = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
ex01 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lx0)
ex02 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => lx0)
ex03 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lx0)
function getshr!(forceout::FFltVec, XYZ::FFltMat, tangents::FFltMat, fe_label::FInt)
copyto!(forceout, q0 * [0.0; 0.0; 1.0])
end
Trac = FDataDict(
"traction_vector" => getshr!,
"femm" => FEMMBase(IntegDomain(subset(bfes, sshearl), GaussRule(2, 3))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [region],
"essential_bcs" => [ex01, ex02, ex03],
"traction_bcs" => [Trac],
"temperature_change" => FDataDict("temperature" => dT),
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
Tipl = selectnode(fens, box = [a a b b 0.0 0.0], inflate = tolerance)
utip = mean(u.values[Tipl, 3])
println(" Normalized deflection: $(utip/uz_ref)")
stressfields = NodalField[]
for c = 1:6
modeldata["postprocessing"] = FDataDict(
"file" => "fiber_reinf_cant_iso",
"outputcsys" => CSys(3, 3, updatecs!),
"quantity" => :Cauchy,
"component" => c,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
push!(stressfields, modeldata["postprocessing"]["exported"][1]["field"])
end
# println("@__FILE__ = $(@__FILE__)")
# jldopen("fiber_reinf_cant_iso_stresses" * "n=$(n)" * ".jld", "w") do file
# write(file, "n", n)
# write(file, "fens", fens)
# write(file, "fes", fes)
# write(file, "geom", geom)
# write(file, "u", u)
# # write(file, "femm", region["femm"])
# write(file, "integrationrule", region["femm"].integdomain.integration_rule)
# write(file, "stressfields", stressfields)
# write(file, "tolerance", tolerance)
# end
end
true
end # fiber_reinf_cant_iso_stresses
function fiber_reinf_cant_iso_stresses_MST10()
elementtag = "MST10"
println("""
Cantilever example. Isotropic material.
############### $(elementtag) ###############
@article{
author = {Krysl, P.},
title = {Mean-strain 8-node hexahedron with optimized energy-sampling stabilization},
journal = {Finite Elements in Analysis and Design},
volume = {108}, pages = {41-53}, DOI = {10.1016/j.finel.2015.09.008}, year = {2016}
}
""")
# Isotropic material
E = 1.0e9 * phun("Pa")
nu = 0.25
CTE = 0.0
# Reference value for the vertical deflection of the tip
uz_ref = -7.516310912734678e-06
a = 90.0 * phun("mm") # length of the cantilever
b = 10.0 * phun("mm") # width of the cross-section
t = 20.0 * phun("mm") # height of the cross-section
q0 = -1000.0 * phun("Pa") # shear traction
dT = 0 * phun("K") # temperature rise
tolerance = 0.00001 * t
convergencestudy = FDataDict[]
for n in [1 2 4 8 16]
na = n # number of elements lengthwise
nb = n # number of elements through the wwith
nt = n # number of elements through the thickness
xs = collect(linearspace(0.0, a, na + 1))
ys = collect(linearspace(0.0, b, nb + 1))
ts = collect(linearspace(0.0, t, nt + 1))
fens, fes = T10blockx(xs, ys, ts)
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sshearl = selectelem(fens, bfes; facing = true, direction = [+1.0 0.0 0.0])
MR = DeforModelRed3D
# externalmaterial = MatDeforElastOrtho(MR,
# 0.0, E1s, E2s, E3s,
# nu12s, nu13s, nu23s,
# G12s, G13s, G23s,
# CTE1, CTE2, CTE3)
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
# Material orientation matrix
csmat = [i == j ? one(FFlt) : zero(FFlt) for i = 1:3, j = 1:3]
function updatecs!(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
)
copyto!(csmatout, csmat)
end
gr = SimplexRule(3, 4)
region =
FDataDict("femm" => FEMMDeforLinearMST10(MR, IntegDomain(fes, gr), material))
lx0 = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
ex01 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lx0)
ex02 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => lx0)
ex03 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lx0)
function getshr!(forceout::FFltVec, XYZ::FFltMat, tangents::FFltMat, fe_label::FInt)
copyto!(forceout, q0 * [0.0; 0.0; 1.0])
end
Trac = FDataDict(
"traction_vector" => getshr!,
"femm" => FEMMBase(IntegDomain(subset(bfes, sshearl), SimplexRule(2, 3))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [region],
"essential_bcs" => [ex01, ex02, ex03],
"traction_bcs" => [Trac],
"temperature_change" => FDataDict("temperature" => dT),
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
Tipl = selectnode(fens, box = [a a b b 0.0 0.0], inflate = tolerance)
utip = mean(u.values[Tipl, 3])
println(" Normalized deflection: $(utip/uz_ref)")
modeldata["postprocessing"] = FDataDict(
"file" => "fiber_reinf_cant_iso_stresses_$(elementtag)",
"outputcsys" => CSys(3, 3, updatecs!),
"quantity" => :Cauchy,
"component" => [5],
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
modeldata["postprocessing"] = FDataDict(
"file" => "fiber_reinf_cant_iso_stresses_$(elementtag)",
"outputcsys" => CSys(3, 3, updatecs!),
"quantity" => :Cauchy,
"component" => collect(1:6),
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
stressfields = ElementalField[modeldata["postprocessing"]["exported"][1]["field"]]
push!(
convergencestudy,
FDataDict(
"elementsize" => 1.0 / n,
"fens" => fens,
"fes" => fes,
"geom" => geom,
"u" => u,
"femm" => region["femm"],
"integrationrule" => region["femm"].integdomain.integration_rule,
"stressfields" => stressfields,
"tolerance" => tolerance,
),
)
end
# File = "fiber_reinf_cant_iso_stresses_$(elementtag)"
# open(File * ".jls", "w") do file
# serialize(file, convergencestudy)
# end
true
end # fiber_reinf_cant_iso_stresses_MST10
function fiber_reinf_cant_iso_stresses_T10()
elementtag = "T10"
println("""
Cantilever example. Isotropic material.
############### $(elementtag) ###############
@article{
author = {Krysl, P.},
title = {Mean-strain 8-node hexahedron with optimized energy-sampling stabilization},
journal = {Finite Elements in Analysis and Design},
volume = {108}, pages = {41-53}, DOI = {10.1016/j.finel.2015.09.008}, year = {2016}
}
""")
# Isotropic material
E = 1.0e9 * phun("Pa")
nu = 0.25
CTE = 0.0
# Reference value for the vertical deflection of the tip
uz_ref = -7.516310912734678e-06
a = 90.0 * phun("mm") # length of the cantilever
b = 10.0 * phun("mm") # width of the cross-section
t = 20.0 * phun("mm") # height of the cross-section
q0 = -1000.0 * phun("Pa") # shear traction
dT = 0 * phun("K") # temperature rise
tolerance = 0.00001 * t
convergencestudy = FDataDict[]
for n in [1 2 4 8 16]
na = n # number of elements lengthwise
nb = n # number of elements through the wwith
nt = n # number of elements through the thickness
xs = collect(linearspace(0.0, a, na + 1))
ys = collect(linearspace(0.0, b, nb + 1))
ts = collect(linearspace(0.0, t, nt + 1))
fens, fes = T10blockx(xs, ys, ts)
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sshearl = selectelem(fens, bfes; facing = true, direction = [+1.0 0.0 0.0])
MR = DeforModelRed3D
# externalmaterial = MatDeforElastOrtho(MR,
# 0.0, E1s, E2s, E3s,
# nu12s, nu13s, nu23s,
# G12s, G13s, G23s,
# CTE1, CTE2, CTE3)
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
# Material orientation matrix
csmat = [i == j ? one(FFlt) : zero(FFlt) for i = 1:3, j = 1:3]
function updatecs!(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
)
copyto!(csmatout, csmat)
end
gr = SimplexRule(3, 4)
region = FDataDict("femm" => FEMMDeforLinear(MR, IntegDomain(fes, gr), material))
lx0 = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
ex01 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lx0)
ex02 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => lx0)
ex03 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lx0)
function getshr!(forceout::FFltVec, XYZ::FFltMat, tangents::FFltMat, fe_label::FInt)
copyto!(forceout, q0 * [0.0; 0.0; 1.0])
end
Trac = FDataDict(
"traction_vector" => getshr!,
"femm" => FEMMBase(IntegDomain(subset(bfes, sshearl), SimplexRule(2, 3))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [region],
"essential_bcs" => [ex01, ex02, ex03],
"traction_bcs" => [Trac],
"temperature_change" => FDataDict("temperature" => dT),
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
Tipl = selectnode(fens, box = [a a b b 0.0 0.0], inflate = tolerance)
utip = mean(u.values[Tipl, 3])
println(" Normalized deflection: $(utip/uz_ref)")
modeldata["postprocessing"] = FDataDict(
"file" => "fiber_reinf_cant_iso_stresses_$(elementtag)",
"outputcsys" => CSys(3, 3, updatecs!),
"quantity" => :Cauchy,
"component" => [5],
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
modeldata["postprocessing"] = FDataDict(
"file" => "fiber_reinf_cant_iso_stresses_$(elementtag)",
"outputcsys" => CSys(3, 3, updatecs!),
"quantity" => :Cauchy,
"component" => collect(1:6),
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
stressfields = ElementalField[modeldata["postprocessing"]["exported"][1]["field"]]
push!(
convergencestudy,
FDataDict(
"elementsize" => 1.0 / n,
"fens" => fens,
"fes" => fes,
"geom" => geom,
"u" => u,
"femm" => region["femm"],
"integrationrule" => region["femm"].integdomain.integration_rule,
"stressfields" => stressfields,
"tolerance" => tolerance,
),
)
end
# File = "fiber_reinf_cant_iso_stresses_$(elementtag)"
# open(File * ".jls", "w") do file
# serialize(file, convergencestudy)
# end
true
end # fiber_reinf_cant_iso_stresses_T10
function fiber_reinf_cant_yn_strong()
println("""
Cantilever example. Strongly orthotropic material. Orientation "y".
@article{
author = {Krysl, P.},
title = {Mean-strain 8-node hexahedron with optimized energy-sampling stabilization},
journal = {Finite Elements in Analysis and Design},
volume = {108}, pages = {41-53}, DOI = {10.1016/j.finel.2015.09.008}, year = {2016}
}
""")
t0 = time()
# # Orthotropic material
E1s = 100000.0 * phun("GPa")
E2s = 1.0 * phun("GPa")
E3s = E2s
nu23s = nu12s = nu13s = 0.25
G12s = 0.2 * phun("GPa")
G23s = G13s = G12s
CTE1 = 0.0
CTE2 = 0.0
CTE3 = 0.0
# # Isotropic material
# E = 1.0e9*phun("Pa")
# nu = 0.25
# CTE = 0.0
# Reference value for the vertical deflection of the tip
uz_ref = -1.027498445054843e-05
a = 90.0 * phun("mm") # length of the cantilever
b = 10.0 * phun("mm") # width of the cross-section
t = 20.0 * phun("mm") # height of the cross-section
q0 = -1000.0 * phun("Pa") # shear traction
dT = 0 * phun("K") # temperature rise
tolerance = 0.00001 * t
# Generate mesh
n = 4
na = 8 * n # number of elements lengthwise
nb = n # number of elements through the wwith
nt = n # number of elements through the thickness
xs = collect(linearspace(0.0, a, na + 1))
ys = collect(linearspace(0.0, b, nb + 1))
ts = collect(linearspace(0.0, t, nt + 1))
fens, fes = H8blockx(xs, ys, ts)
fens, fes = H8toH20(fens, fes)
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sshearl = selectelem(fens, bfes; facing = true, direction = [+1.0 0.0 0.0])
MR = DeforModelRed3D
material = MatDeforElastOrtho(
MR,
0.0,
E1s,
E2s,
E3s,
nu12s,
nu13s,
nu23s,
G12s,
G13s,
G23s,
CTE1,
CTE2,
CTE3,
)
# material = MatDeforElastIso(MR,
# 0.0, E, nu, CTE)
# Material orientation matrix
csmat = zeros(3, 3)
rotmat3!(csmat, -45.0 / 180.0 * pi * [0, 1, 0])
function updatecs!(csmatout::FFltMat, XYZ::FFltMat, tangents::FFltMat, fe_label::FInt)
copyto!(csmatout, csmat)
end
gr = GaussRule(3, 2)
region = FDataDict(
"femm" =>
FEMMDeforLinear(MR, IntegDomain(fes, gr), CSys(3, 3, updatecs!), material),
)
lx0 = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
ex01 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lx0)
ex02 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => lx0)
ex03 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lx0)
function getshr!(forceout::FFltVec, XYZ::FFltMat, tangents::FFltMat, fe_label::FInt)
copyto!(forceout, q0 * [0.0; 0.0; 1.0])
end
Trac = FDataDict(
"traction_vector" => getshr!,
"femm" => FEMMBase(IntegDomain(subset(bfes, sshearl), GaussRule(2, 3))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [region],
"essential_bcs" => [ex01, ex02, ex03],
"traction_bcs" => [Trac],
"temperature_change" => FDataDict("temperature" => dT),
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
Tipl = selectnode(fens, box = [a a b b 0.0 0.0], inflate = tolerance)
utip = mean(u.values[Tipl, 3])
println("Deflection $utip, normalized: $(utip/uz_ref)")
println("Solution: $( time()-t0 )")
# File = "NAFEMS-R0031-2-plate.vtk"
# vtkexportmesh(File, fes.conn, geom.values, FinEtools.MeshExportModule.H20;
# scalars = [("Layer", fes.label)], vectors = [("displacement", u.values)])
# @async run(`"paraview.exe" $File`)
modeldata["postprocessing"] = FDataDict(
"file" => "fiber_reinf_cant_yn_strong",
"outputcsys" => CSys(3, 3, updatecs!),
"quantity" => :Cauchy,
"component" => 5,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`)
# modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
# File = modeldata["postprocessing"]["exported"][1]["file"]
# @async run(`"paraview.exe" $File`)
println("Done: $( time()-t0 )")
true
end # fiber_reinf_cant_yn_strong
function fiber_reinf_cant_yn_strong_no_algo()
println("""
Cantilever example. Strongly orthotropic material. Orientation "y".
@article{
author = {Krysl, P.},
title = {Mean-strain 8-node hexahedron with optimized energy-sampling stabilization},
journal = {Finite Elements in Analysis and Design},
volume = {108}, pages = {41-53}, DOI = {10.1016/j.finel.2015.09.008}, year = {2016}
}
""")
t0 = time()
pu = ustring -> phun(ustring; system_of_units = :SIMM)
# # Orthotropic material
E1s = 100000.0 * pu("GPa")
E2s = 1.0 * pu("GPa")
E3s = E2s
nu23s = nu12s = nu13s = 0.25
G12s = 0.2 * pu("GPa")
G23s = G13s = G12s
CTE1 = 0.0
CTE2 = 0.0
CTE3 = 0.0
# # Isotropic material
# E = 1.0e9*pu("Pa")
# nu = 0.25
# CTE = 0.0
# Reference value for the vertical deflection of the tip
uz_ref = -1.027498445054843e-05 * pu("m")
a = 90.0 * pu("mm") # length of the cantilever
b = 10.0 * pu("mm") # width of the cross-section
t = 20.0 * pu("mm") # height of the cross-section
q0 = -1000.0 * pu("Pa") # shear traction
dT = 0 * pu("K") # temperature rise
tolerance = 0.00001 * t
# Generate mesh
n = 10
na = n # number of elements lengthwise
nb = n # number of elements through the wwith
nt = n # number of elements through the thickness
xs = collect(linearspace(0.0, a, na + 1))
ys = collect(linearspace(0.0, b, nb + 1))
ts = collect(linearspace(0.0, t, nt + 1))
println("fens,fes = H8blockx(xs, ys, ts)")
@time fens, fes = H8blockx(xs, ys, ts)
println("fens,fes = H8toH20(fens,fes)")
@time fens, fes = H8toH20(fens, fes)
println("bfes = meshboundary(fes)")
@time bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sshearl = selectelem(fens, bfes; facing = true, direction = [+1.0 0.0 0.0])
MR = DeforModelRed3D
material = MatDeforElastOrtho(
MR,
0.0,
E1s,
E2s,
E3s,
nu12s,
nu13s,
nu23s,
G12s,
G13s,
G23s,
CTE1,
CTE2,
CTE3,
)
# material = MatDeforElastIso(MR,
# 0.0, E, nu, CTE)
# Material orientation matrix
csmat = zeros(3, 3)
rotmat3!(csmat, -45.0 / 180.0 * pi * [0, 1, 0])
function updatecs!(csmatout::FFltMat, XYZ::FFltMat, tangents::FFltMat, fe_label::FInt)
copyto!(csmatout, csmat)
end
gr = GaussRule(3, 2)
femm = FEMMDeforLinear(MR, IntegDomain(fes, gr), CSys(3, 3, updatecs!), material)
lx0 = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
nnodes(geom)
setebc!(u, lx0, true, 1, zeros(size(lx0)))
setebc!(u, lx0, true, 2, zeros(size(lx0)))
setebc!(u, lx0, true, 3, zeros(size(lx0)))
applyebc!(u)
S = connectionmatrix(femm, nnodes(geom))
numberdofs!(u)
function getshr!(forceout::FFltVec, XYZ::FFltMat, tangents::FFltMat, fe_label::FInt)
copyto!(forceout, q0 * [0.0; 0.0; 1.0])
end
Tracfemm = FEMMBase(IntegDomain(subset(bfes, sshearl), GaussRule(2, 3)))
println("K = stiffness(femm, geom, u)")
@time K = stiffness(femm, geom, u)
fi = ForceIntensity(Float64, 3, getshr!)
println("F = distribloads(Tracfemm, geom, u, fi, 2);")
@time F = distribloads(Tracfemm, geom, u, fi, 2)
println("K = cholesky(K)")
K = (K + K') / 2
@time K = cholesky(Symmetric(K))
println("U = K\\F")
@time U = K \ F
# println("U = cg(K, F; tol=1e-3, maxiter=2000)")
# @time U = cg(K, F; tol=1e-3, maxiter=2000)
scattersysvec!(u, U[:])
Tipl = selectnode(fens, box = [a a b b 0.0 0.0], inflate = tolerance)
utip = mean(u.values[Tipl, 3])
println("Deflection $utip, normalized: $(utip/uz_ref)")
println("Solution: $( time()-t0 )")
println("Done: $( time()-t0 )")
true
end # fiber_reinf_cant_yn_strong_no_algo
function fiber_reinf_cant_zn_strong()
println("""
Cantilever example. Strongly orthotropic material. Orientation "z".
@article{
author = {Krysl, P.},
title = {Mean-strain 8-node hexahedron with optimized energy-sampling stabilization},
journal = {Finite Elements in Analysis and Design},
volume = {108}, pages = {41-53}, DOI = {10.1016/j.finel.2015.09.008}, year = {2016}
}
""")
t0 = time()
# # Orthotropic material
E1s = 100000.0 * phun("GPa")
E2s = 1.0 * phun("GPa")
E3s = E2s
nu23s = nu12s = nu13s = 0.25
G12s = 0.2 * phun("GPa")
G23s = G13s = G12s
CTE1 = 0.0
CTE2 = 0.0
CTE3 = 0.0
# # Isotropic material
# E = 1.0e9*phun("Pa")
# nu = 0.25
# CTE = 0.0
# Reference value for the vertical deflection of the tip
uz_ref = -1.119145781010554e-05
a = 90.0 * phun("mm") # length of the cantilever
b = 10.0 * phun("mm") # width of the cross-section
t = 20.0 * phun("mm") # height of the cross-section
q0 = -1000.0 * phun("Pa") # shear traction
dT = 0 * phun("K") # temperature rise
tolerance = 0.00001 * t
# Generate mesh
n = 8
na = 8 * n # number of elements lengthwise
nb = n # number of elements through the wwith
nt = n # number of elements through the thickness
xs = collect(linearspace(0.0, a, na + 1))
ys = collect(linearspace(0.0, b, nb + 1))
ts = collect(linearspace(0.0, t, nt + 1))
fens, fes = H8blockx(xs, ys, ts)
fens, fes = H8toH20(fens, fes)
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sshearl = selectelem(fens, bfes; facing = true, direction = [+1.0 0.0 0.0])
MR = DeforModelRed3D
material = MatDeforElastOrtho(
MR,
0.0,
E1s,
E2s,
E3s,
nu12s,
nu13s,
nu23s,
G12s,
G13s,
G23s,
CTE1,
CTE2,
CTE3,
)
# material = MatDeforElastIso(MR,
# 0.0, E, nu, CTE)
# Material orientation matrix
csmat = zeros(3, 3)
rotmat3!(csmat, -45.0 / 180.0 * pi * [0, 0, 1])
function updatecs!(csmatout::FFltMat, XYZ::FFltMat, tangents::FFltMat, fe_label::FInt)
copyto!(csmatout, csmat)
end
gr = GaussRule(3, 2)
region = FDataDict(
"femm" =>
FEMMDeforLinear(MR, IntegDomain(fes, gr), CSys(3, 3, updatecs!), material),
)
lx0 = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
ex01 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lx0)
ex02 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => lx0)
ex03 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lx0)
function getshr!(forceout::FFltVec, XYZ::FFltMat, tangents::FFltMat, fe_label::FInt)
copyto!(forceout, q0 * [0.0; 0.0; 1.0])
end
Trac = FDataDict(
"traction_vector" => getshr!,
"femm" => FEMMBase(IntegDomain(subset(bfes, sshearl), GaussRule(2, 3))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [region],
"essential_bcs" => [ex01, ex02, ex03],
"traction_bcs" => [Trac],
"temperature_change" => FDataDict("temperature" => dT),
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
Tipl = selectnode(fens, box = [a a b b 0.0 0.0], inflate = tolerance)
utip = mean(u.values[Tipl, 3])
println("Deflection $utip, normalized: $(utip/uz_ref)")
println("Solution: $( time()-t0 )")
# File = "NAFEMS-R0031-2-plate.vtk"
# vtkexportmesh(File, fes.conn, geom.values, FinEtools.MeshExportModule.H20;
# scalars = [("Layer", fes.label)], vectors = [("displacement", u.values)])
# @async run(`"paraview.exe" $File`)
modeldata["postprocessing"] = FDataDict(
"file" => "fiber_reinf_cant_yn_strong",
"outputcsys" => CSys(3, 3, updatecs!),
"quantity" => :Cauchy,
"component" => 5,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`)
# modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
# File = modeldata["postprocessing"]["exported"][1]["file"]
# @async run(`"paraview.exe" $File`)
println("Done: $( time()-t0 )")
true
end # fiber_reinf_cant_zn_strong
function allrun()
println("#####################################################")
println("# fiber_reinf_cant_iso ")
fiber_reinf_cant_iso()
println("#####################################################")
println("# fiber_reinf_cant_iso_stresses ")
fiber_reinf_cant_iso_stresses()
println("#####################################################")
println("# fiber_reinf_cant_iso_stresses_MST10 ")
fiber_reinf_cant_iso_stresses_MST10()
println("#####################################################")
println("# fiber_reinf_cant_iso_stresses_T10 ")
fiber_reinf_cant_iso_stresses_T10()
println("#####################################################")
println("# fiber_reinf_cant_yn_strong ")
fiber_reinf_cant_yn_strong()
println("#####################################################")
println("# fiber_reinf_cant_yn_strong_no_algo ")
fiber_reinf_cant_yn_strong_no_algo()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 2849 | module hex_ip_constr_examples
using FinEtools
using FinEtools.MeshExportModule.CSV: savecsv
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtools.AlgoBaseModule: evalconvergencestudy
using FinEtoolsDeforLinear.AlgoDeforLinearModule:
linearstatics, exportstresselementwise, exportstress
using Statistics: mean
using LinearAlgebra: Symmetric, cholesky, eigen, svd
using PGFPlotsX
function mesh()
(
FinEtools.FENodeSetModule.FENodeSet(
[
0.0 0.0 0.0
1.0 0.0 0.0
1.0 1.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0
1.0 0.0 1.0
1.0 1.0 1.0
0.0 1.0 1.0
],
),
FinEtools.FESetModule.FESetH8(reshape([1, 2, 3, 4, 5, 6, 7, 8], 1, 8)),
)
end
function hex_ip_constr_par()
fens, fes = mesh()
# integration_rule = TrapezoidalRule(3)
integration_rule = GaussRule(3, 2)
pc = integration_rule.param_coords
w = integration_rule.weights
npts = integration_rule.npts
Q = fill(0.0, npts, 24)
for j = 1:npts
gradNpar = bfundpar(fes, vec(pc[j, :]))
k = 1
for i in axes(gradNpar, 1)
Q[j, k:(k+2)] .= gradNpar[i, :]
k = k + 3
end
end
decomp = svd(Q)
@show decomp.S
true
end # hex_ip_constr_par
function hex_ip_constr_xyz()
xyzperturbation =
[
0.0767656 -0.983206 -0.14343
0.45767 0.981479 0.450997
-0.295854 0.542922 0.321333
-0.85204 -0.97824 -0.772874
-0.0539756 0.994907 0.822798
0.447173 0.528742 0.0445352
-0.468417 0.00673427 0.953151
-0.898513 -0.915871 0.933237
] ./ 5.0
fens, fes = mesh()
fens.xyz .+= xyzperturbation
# integration_rule = TrapezoidalRule(3)
integration_rule = GaussRule(3, 2)
pc = integration_rule.param_coords
w = integration_rule.weights
npts = integration_rule.npts
Q = fill(0.0, npts, 24)
for j = 1:npts
gradNpar = bfundpar(fes, vec(pc[j, :]))
J = (transpose(fens.xyz) * gradNpar)
gradN = gradNpar / J
k = 1
for i in axes(gradN, 1)
Q[j, k:(k+2)] .= gradN[i, :]
k = k + 3
end
end
decomp = svd(Q)
@show decomp.S
true
end # hex_ip_constr_xyz
function allrun()
println("#####################################################")
println("# hex_ip_constr_par ")
hex_ip_constr_par()
println("#####################################################")
println("# hex_ip_constr_xyz ")
hex_ip_constr_xyz()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 48836 | module hughes_cantilever_examples
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtools.AlgoBaseModule: evalconvergencestudy
using FinEtoolsDeforLinear.AlgoDeforLinearModule:
linearstatics, exportstresselementwise, exportstress
using Statistics: mean
using LinearAlgebra: Symmetric, cholesky
# Example from TJR Hughes, The Finite Element Method: Linear Static and Dynamic Finite Element Analysis, 1987.
# Two-dimensional plane-elasticity Solution of beam deflection. Shear force P at one end, and corresponding reactions (tractions) at the other end. The Analytical solution is plane-strain.
# Find out: where does the exact solution come from?
# Isotropic material
E = 1.0
P = 1.0
L = 16.0
c = 2.0
h = 1.0
W = 2 / 3 * h * c^3
CTE = 0.0
tolerance = 0.00001 * c
function getfrcL!(forceout::FFltVec, XYZ::FFltMat, tangents::FFltMat, fe_label::FInt)
copyto!(forceout, [0.0; 0.0; P / 2 / W * (c^2 - XYZ[3]^2)])
end
function getfrc0!(forceout::FFltVec, XYZ::FFltMat, tangents::FFltMat, fe_label::FInt)
copyto!(forceout, [P * L / W * XYZ[3]; 0.0; -P / 2 / W * (c^2 - XYZ[3]^2)])
end
function evaluateerrors(filebase, modeldatasequence)
println("")
println("Stress RMS error")
for md in modeldatasequence
md["targetfields"] = [e["field"] for e in md["postprocessing"]["exported"]]
end
elementsizes, errornorms, p = evalconvergencestudy(modeldatasequence)
println("Normalized Approximate Error = $(errornorms)")
f = log.(vec(errornorms))
A = hcat(log.(vec(elementsizes[1:(end-1)])), ones(size(f)))
p = A \ f
println("Linear log-log fit: p = $(p)")
csvFile = filebase * "_Stress" * ".CSV"
savecsv(
csvFile,
elementsizes = vec(elementsizes[1:(end-1)]),
elementsizes2 = vec(elementsizes[1:(end-1)] .^ 2),
elementsizes3 = vec(elementsizes[1:(end-1)] .^ 3),
errornorms = vec(errornorms),
)
println("Wrote $csvFile")
println("")
println("Displacement RMS error")
for md in modeldatasequence
md["targetfields"] = [md["u"] for r in md["regions"]]
end
elementsizes, errornorms, p = evalconvergencestudy(modeldatasequence)
println("Normalized Approximate Error = $(errornorms)")
f = log.(vec(errornorms))
A = hcat(log.(vec(elementsizes[1:(end-1)])), ones(size(f)))
p = A \ f
println("Linear log-log fit: p = $(p)")
csvFile = filebase * "_Displ" * ".CSV"
savecsv(
csvFile,
elementsizes = vec(elementsizes[1:(end-1)]),
elementsizes2 = vec(elementsizes[1:(end-1)] .^ 2),
elementsizes3 = vec(elementsizes[1:(end-1)] .^ 3),
errornorms = vec(errornorms),
)
println("Wrote $csvFile")
end
function hughes_cantilever_stresses_H8_by_hand()
elementtag = "H8"
println("""
Cantilever example. Hughes 1987. Element: $(elementtag)
""")
nu = 0.3 # COMPRESSIBLE
E1 = E / (1 - nu^2) # Plane strain
nu1 = nu / (1 - nu)
I = h * (2 * c)^3 / 12
function exactux(x, y)
(P / (6 * E1 * I) * (-y) * (3 * (L^2 - (L - x)^2) + (2 + nu1) * (y^2 - c^2)))
end
function exactuy(x, y)
(
P / (6 * E1 * I) * (
((L - x)^3 - L^3) - ((4 + 5 * nu1) * c^2 + 3 * L^2) * (L - x - L) +
3 * nu1 * (L - x) * y^2
)
)
end
n = 2 #
nL = 3 * n # number of elements lengthwise
nc = 2 * n # number of elements through the depth
nh = 1 # number of elements through the thickness
xs = collect(linearspace(0.0, L, nL + 1))
ys = collect(linearspace(0.0, h, nh + 1))
zs = collect(linearspace(-c, +c, nc + 1))
fens, fes = H8blockx(xs, ys, zs)
# fens,fes = H8toH20(fens,fes)
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sshearL = selectelem(fens, bfes; facing = true, direction = [+1.0 0.0 0.0])
# 0 cross-section surface for the reactions
sshear0 = selectelem(fens, bfes; facing = true, direction = [-1.0 0.0 0.0])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
# Material orientation matrix
csmat = [i == j ? one(FFlt) : zero(FFlt) for i = 1:3, j = 1:3]
function updatecs!(csmatout::FFltMat, XYZ::FFltMat, tangents::FFltMat, fe_label::FInt)
copyto!(csmatout, csmat)
end
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
lx0 = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 0.0], inflate = tolerance)
setebc!(u, lx0, true, 1, 0.0)
setebc!(u, lx0, true, 2, 0.0)
setebc!(u, lx0, true, 3, 0.0)
lx1 = selectnode(fens, box = [0.0 0.0 0.0 0.0 c c], inflate = tolerance)
lx2 = selectnode(fens, box = [0.0 0.0 0.0 0.0 -c -c], inflate = tolerance)
setebc!(u, vcat(lx1, lx2), true, 1, 0.0)
ly1 = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
ly2 = selectnode(fens, box = [-Inf Inf h h -Inf Inf], inflate = tolerance)
setebc!(u, vcat(ly1, ly2), true, 2, 0.0)
applyebc!(u)
numberdofs!(u)
fi = ForceIntensity(Float64, 3, getfrc0!)
el1femm = FEMMBase(IntegDomain(subset(bfes, sshear0), GaussRule(2, 2)))
F1 = distribloads(el1femm, geom, u, fi, 2)
fi = ForceIntensity(Float64, 3, getfrcL!)
el2femm = FEMMBase(IntegDomain(subset(bfes, sshearL), GaussRule(2, 2)))
F2 = distribloads(el2femm, geom, u, fi, 2)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (F1 + F2)
scattersysvec!(u, U[:])
Tipl = selectnode(fens, box = [L L 0.0 0.0 0.0 0.0], inflate = tolerance)
utip = mean(u.values[Tipl, 3])
println("Deflection: $(utip), compared to $(exactuy(L,0.0))")
File = "hughes_cantilever_stresses_H8_by_hand.vtk"
vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
@async run(`"paraview.exe" $File`)
# modeldata["postprocessing"] = FDataDict("file"=>"hughes_cantilever_stresses_$(elementtag)", "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy, "component"=>[5])
# modeldata = exportstresselementwise(modeldata)
# modeldata["postprocessing"] = FDataDict("file"=>"hughes_cantilever_stresses_$(elementtag)",
# "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy,
# "component"=>collect(1:6))
# modeldata = exportstresselementwise(modeldata)
# stressfields = ElementalField[modeldata["postprocessing"]["exported"][1]["field"]]
true
end # hughes_cantilever_stresses_H8_by_hand
function hughes_cantilever_stresses_H20_by_hand()
elementtag = "H20"
println("""
Cantilever example. Hughes 1987. Element: $(elementtag)
""")
nu = 0.3 # COMPRESSIBLE
E1 = E / (1 - nu^2) # Plane strain
nu1 = nu / (1 - nu)
I = h * (2 * c)^3 / 12
function exactux(x, y)
(P / (6 * E1 * I) * (-y) * (3 * (L^2 - (L - x)^2) + (2 + nu1) * (y^2 - c^2)))
end
function exactuy(x, y)
(
P / (6 * E1 * I) * (
((L - x)^3 - L^3) - ((4 + 5 * nu1) * c^2 + 3 * L^2) * (L - x - L) +
3 * nu1 * (L - x) * y^2
)
)
end
n = 8 #
nL = 3 * n # number of elements lengthwise
nc = 2 * n # number of elements through the depth
nh = 1 # number of elements through the thickness
xs = collect(linearspace(0.0, L, nL + 1))
ys = collect(linearspace(0.0, h, nh + 1))
zs = collect(linearspace(-c, +c, nc + 1))
fens, fes = H8blockx(xs, ys, zs)
fens, fes = H8toH20(fens, fes)
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sshearL = selectelem(fens, bfes; facing = true, direction = [+1.0 0.0 0.0])
# 0 cross-section surface for the reactions
sshear0 = selectelem(fens, bfes; facing = true, direction = [-1.0 0.0 0.0])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
# Material orientation matrix
csmat = [i == j ? one(FFlt) : zero(FFlt) for i = 1:3, j = 1:3]
function updatecs!(csmatout::FFltMat, XYZ::FFltMat, tangents::FFltMat, fe_label::FInt)
copyto!(csmatout, csmat)
end
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
lx0 = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 0.0], inflate = tolerance)
setebc!(u, lx0, true, 1, 0.0)
setebc!(u, lx0, true, 2, 0.0)
setebc!(u, lx0, true, 3, 0.0)
lx1 = selectnode(fens, box = [0.0 0.0 0.0 0.0 c c], inflate = tolerance)
lx2 = selectnode(fens, box = [0.0 0.0 0.0 0.0 -c -c], inflate = tolerance)
setebc!(u, vcat(lx1, lx2), true, 1, 0.0)
ly1 = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
ly2 = selectnode(fens, box = [-Inf Inf h h -Inf Inf], inflate = tolerance)
setebc!(u, vcat(ly1, ly2), true, 2, 0.0)
applyebc!(u)
numberdofs!(u)
u
fi = ForceIntensity(Float64, 3, getfrc0!)
el1femm = FEMMBase(IntegDomain(subset(bfes, sshear0), GaussRule(2, 2)))
F1 = distribloads(el1femm, geom, u, fi, 2)
fi = ForceIntensity(Float64, 3, getfrcL!)
el2femm = FEMMBase(IntegDomain(subset(bfes, sshearL), GaussRule(2, 2)))
F2 = distribloads(el2femm, geom, u, fi, 2)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (F1 + F2)
scattersysvec!(u, U[:])
Tipl = selectnode(fens, box = [L L 0.0 0.0 0.0 0.0], inflate = tolerance)
utip = mean(u.values[Tipl, 3])
println("Deflection: $(utip), compared to $(exactuy(L,0.0))")
File = "hughes_cantilever_stresses_H8_by_hand.vtk"
vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
@async run(`"paraview.exe" $File`)
# modeldata["postprocessing"] = FDataDict("file"=>"hughes_cantilever_stresses_$(elementtag)", "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy, "component"=>[5])
# modeldata = exportstresselementwise(modeldata)
# modeldata["postprocessing"] = FDataDict("file"=>"hughes_cantilever_stresses_$(elementtag)",
# "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy,
# "component"=>collect(1:6))
# modeldata = exportstresselementwise(modeldata)
# stressfields = ElementalField[modeldata["postprocessing"]["exported"][1]["field"]]
true
end # hughes_cantilever_stresses_MST10
function hughes_cantilever_stresses_T10_by_hand()
elementtag = "T10"
println("""
Cantilever example. Hughes 1987. Element: $(elementtag)
""")
nu = 0.3 # COMPRESSIBLE
E1 = E / (1 - nu^2) # Plane strain
nu1 = nu / (1 - nu)
I = h * (2 * c)^3 / 12
function exactux(x, y)
(P / (6 * E1 * I) * (-y) * (3 * (L^2 - (L - x)^2) + (2 + nu1) * (y^2 - c^2)))
end
function exactuy(x, y)
(
P / (6 * E1 * I) * (
((L - x)^3 - L^3) - ((4 + 5 * nu1) * c^2 + 3 * L^2) * (L - x - L) +
3 * nu1 * (L - x) * y^2
)
)
end
n = 2 #
nL = 3 * n # number of elements lengthwise
nc = 2 * n # number of elements through the depth
nh = n # number of elements through the thickness
xs = collect(linearspace(0.0, L, nL + 1))
ys = collect(linearspace(0.0, h, nh + 1))
zs = collect(linearspace(-c, +c, nc + 1))
fens, fes = T10blockx(xs, ys, zs)
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sshearL = selectelem(fens, bfes; facing = true, direction = [+1.0 0.0 0.0])
# 0 cross-section surface for the reactions
sshear0 = selectelem(fens, bfes; facing = true, direction = [-1.0 0.0 0.0])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
# Material orientation matrix
csmat = [i == j ? one(FFlt) : zero(FFlt) for i = 1:3, j = 1:3]
function updatecs!(csmatout::FFltMat, XYZ::FFltMat, tangents::FFltMat, fe_label::FInt)
copyto!(csmatout, csmat)
end
gr = SimplexRule(3, 4)
femm = FEMMDeforLinear(MR, IntegDomain(fes, gr), material)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
lx0 = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 0.0], inflate = tolerance)
setebc!(u, lx0, true, 1, 0.0)
setebc!(u, lx0, true, 2, 0.0)
setebc!(u, lx0, true, 3, 0.0)
lx1 = selectnode(fens, box = [0.0 0.0 0.0 0.0 c c], inflate = tolerance)
lx2 = selectnode(fens, box = [0.0 0.0 0.0 0.0 -c -c], inflate = tolerance)
setebc!(u, vcat(lx1, lx2), true, 1, 0.0)
ly1 = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
ly2 = selectnode(fens, box = [-Inf Inf h h -Inf Inf], inflate = tolerance)
setebc!(u, vcat(ly1, ly2), true, 2, 0.0)
applyebc!(u)
numberdofs!(u)
fi = ForceIntensity(Float64, 3, getfrc0!)
el1femm = FEMMBase(IntegDomain(subset(bfes, sshear0), SimplexRule(2, 3)))
F1 = distribloads(el1femm, geom, u, fi, 2)
fi = ForceIntensity(Float64, 3, getfrcL!)
el2femm = FEMMBase(IntegDomain(subset(bfes, sshearL), SimplexRule(2, 3)))
F2 = distribloads(el2femm, geom, u, fi, 2)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (F1 + F2)
scattersysvec!(u, U[:])
Tipl = selectnode(fens, box = [L L 0.0 0.0 0.0 0.0], inflate = tolerance)
utip = mean(u.values[Tipl, 3])
println("Deflection: $(utip), compared to $(exactuy(L,0.0))")
File = "hughes_cantilever_stresses_T10_by_hand.vtk"
vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
@async run(`"paraview.exe" $File`)
# modeldata["postprocessing"] = FDataDict("file"=>"hughes_cantilever_stresses_$(elementtag)", "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy, "component"=>[5])
# modeldata = exportstresselementwise(modeldata)
# modeldata["postprocessing"] = FDataDict("file"=>"hughes_cantilever_stresses_$(elementtag)",
# "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy,
# "component"=>collect(1:6))
# modeldata = exportstresselementwise(modeldata)
# stressfields = ElementalField[modeldata["postprocessing"]["exported"][1]["field"]]
true
end # hughes_cantilever_stresses_MST10
function hughes_cantilever_stresses_MST10_by_hand()
elementtag = "MST10"
println("""
Cantilever example. Hughes 1987. Element: $(elementtag)
""")
nu = 0.3 # COMPRESSIBLE
E1 = E / (1 - nu^2) # Plane strain
nu1 = nu / (1 - nu)
I = h * (2 * c)^3 / 12
function exactux(x, y)
(P / (6 * E1 * I) * (-y) * (3 * (L^2 - (L - x)^2) + (2 + nu1) * (y^2 - c^2)))
end
function exactuy(x, y)
(
P / (6 * E1 * I) * (
((L - x)^3 - L^3) - ((4 + 5 * nu1) * c^2 + 3 * L^2) * (L - x - L) +
3 * nu1 * (L - x) * y^2
)
)
end
n = 2 #
nL = 3 * n # number of elements lengthwise
nc = 2 * n # number of elements through the depth
nh = n # number of elements through the thickness
xs = collect(linearspace(0.0, L, nL + 1))
ys = collect(linearspace(0.0, h, nh + 1))
zs = collect(linearspace(-c, +c, nc + 1))
fens, fes = T10blockx(xs, ys, zs)
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sshearL = selectelem(fens, bfes; facing = true, direction = [+1.0 0.0 0.0])
# 0 cross-section surface for the reactions
sshear0 = selectelem(fens, bfes; facing = true, direction = [-1.0 0.0 0.0])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
# Material orientation matrix
csmat = [i == j ? one(FFlt) : zero(FFlt) for i = 1:3, j = 1:3]
function updatecs!(csmatout::FFltMat, XYZ::FFltMat, tangents::FFltMat, fe_label::FInt)
copyto!(csmatout, csmat)
end
gr = SimplexRule(3, 4)
femm = FEMMDeforLinearMST10(MR, IntegDomain(fes, gr), material)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
lx0 = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 0.0], inflate = tolerance)
setebc!(u, lx0, true, 1, 0.0)
setebc!(u, lx0, true, 2, 0.0)
setebc!(u, lx0, true, 3, 0.0)
lx1 = selectnode(fens, box = [0.0 0.0 0.0 0.0 c c], inflate = tolerance)
lx2 = selectnode(fens, box = [0.0 0.0 0.0 0.0 -c -c], inflate = tolerance)
setebc!(u, vcat(lx1, lx2), true, 1, 0.0)
ly1 = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
ly2 = selectnode(fens, box = [-Inf Inf h h -Inf Inf], inflate = tolerance)
setebc!(u, vcat(ly1, ly2), true, 2, 0.0)
applyebc!(u)
numberdofs!(u)
fi = ForceIntensity(Float64, 3, getfrc0!)
el1femm = FEMMBase(IntegDomain(subset(bfes, sshear0), SimplexRule(2, 3)))
F1 = distribloads(el1femm, geom, u, fi, 2)
fi = ForceIntensity(Float64, 3, getfrcL!)
el2femm = FEMMBase(IntegDomain(subset(bfes, sshearL), SimplexRule(2, 3)))
F2 = distribloads(el2femm, geom, u, fi, 2)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (F1 + F2)
scattersysvec!(u, U[:])
Tipl = selectnode(fens, box = [L L 0.0 0.0 0.0 0.0], inflate = tolerance)
utip = mean(u.values[Tipl, 3])
println("Deflection: $(utip), compared to $(exactuy(L,0.0))")
# modeldata["postprocessing"] = FDataDict("file"=>"hughes_cantilever_stresses_$(elementtag)", "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy, "component"=>[5])
# modeldata = exportstresselementwise(modeldata)
# modeldata["postprocessing"] = FDataDict("file"=>"hughes_cantilever_stresses_$(elementtag)",
# "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy,
# "component"=>collect(1:6))
# modeldata = exportstresselementwise(modeldata)
# stressfields = ElementalField[modeldata["postprocessing"]["exported"][1]["field"]]
true
end # hughes_cantilever_stresses_MST10
function hughes_cantilever_stresses_MST10()
elementtag = "MST10"
println("""
Cantilever example. Hughes 1987. Element: $(elementtag)
""")
nu = 0.3 # COMPRESSIBLE
E1 = E / (1 - nu^2) # Plane strain
nu1 = nu / (1 - nu)
I = h * (2 * c)^3 / 12
function exactux(x, y)
(P / (6 * E1 * I) * (-y) * (3 * (L^2 - (L - x)^2) + (2 + nu1) * (y^2 - c^2)))
end
function exactuy(x, y)
(
P / (6 * E1 * I) * (
((L - x)^3 - L^3) - ((4 + 5 * nu1) * c^2 + 3 * L^2) * (L - x - L) +
3 * nu1 * (L - x) * y^2
)
)
end
modeldatasequence = FDataDict[]
for n in [1 2 4 8] #
nL = 3 * n # number of elements lengthwise
nc = 2 * n # number of elements through the depth
nh = n # number of elements through the thickness
xs = collect(linearspace(0.0, L, nL + 1))
ys = collect(linearspace(0.0, h, nh + 1))
zs = collect(linearspace(-c, +c, nc + 1))
fens, fes = T10blockx(xs, ys, zs)
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sshearL = selectelem(fens, bfes; facing = true, direction = [+1.0 0.0 0.0])
# 0 cross-section surface for the reactions
sshear0 = selectelem(fens, bfes; facing = true, direction = [-1.0 0.0 0.0])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
# Material orientation matrix
csmat = [i == j ? one(FFlt) : zero(FFlt) for i = 1:3, j = 1:3]
function updatecs!(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
)
copyto!(csmatout, csmat)
end
gr = SimplexRule(3, 4)
region =
FDataDict("femm" => FEMMDeforLinearMST10(MR, IntegDomain(fes, gr), material))
lx0 = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 0.0], inflate = tolerance)
# println("lx0 = $(lx0)")
ex01 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lx0)
ex02 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => lx0)
ex03 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lx0)
lx1 = selectnode(fens, box = [0.0 0.0 0.0 0.0 c c], inflate = tolerance)
lx2 = selectnode(fens, box = [0.0 0.0 0.0 0.0 -c -c], inflate = tolerance)
# println("vcat(lx1, lx2) = $(vcat(lx1, lx2))")
ex04 = FDataDict(
"displacement" => 0.0,
"component" => 1,
"node_list" => vcat(lx1, lx2),
)
ly1 = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
ly2 = selectnode(fens, box = [-Inf Inf h h -Inf Inf], inflate = tolerance)
# println("vcat(ly1, ly2) = $(vcat(ly1, ly2))")
ey01 = FDataDict(
"displacement" => 0.0,
"component" => 2,
"node_list" => vcat(ly1, ly2),
)
Trac0 = FDataDict(
"traction_vector" => getfrc0!,
"femm" => FEMMBase(IntegDomain(subset(bfes, sshear0), SimplexRule(2, 3))),
)
TracL = FDataDict(
"traction_vector" => getfrcL!,
"femm" => FEMMBase(IntegDomain(subset(bfes, sshearL), SimplexRule(2, 3))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [region],
"essential_bcs" => [ex01, ex02, ex03, ex04, ey01],
"traction_bcs" => [Trac0, TracL],
"temperature_change" => FDataDict("temperature" => 0.0),
)
modeldata = linearstatics(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
Tipl = selectnode(fens, box = [L L 0.0 0.0 0.0 0.0], inflate = tolerance)
utip = mean(u.values[Tipl, 3])
println("Deflection: $(utip), compared to $(exactuy(L,0.0))")
modeldata["postprocessing"] = FDataDict(
"file" => "hughes_cantilever_stresses_$(elementtag)",
"outputcsys" => CSys(3, 3, updatecs!),
"quantity" => :Cauchy,
"component" => [5],
)
modeldata = exportstresselementwise(modeldata)
modeldata["postprocessing"] = FDataDict(
"file" => "hughes_cantilever_stresses_$(elementtag)",
"outputcsys" => CSys(3, 3, updatecs!),
"quantity" => :Cauchy,
"component" => collect(1:6),
)
modeldata = exportstresselementwise(modeldata)
stressfields = ElementalField[modeldata["postprocessing"]["exported"][1]["field"]]
modeldata["geometricaltolerance"] = tolerance
modeldata["elementsize"] = 1.0 / n
push!(modeldatasequence, modeldata)
end
filebase = "hughes_cantilever_stresses_$(elementtag)"
evaluateerrors(filebase, modeldatasequence)
true
end # hughes_cantilever_stresses_MST10
function hughes_cantilever_stresses_MST10_incompressible()
elementtag = "MST10"
println("""
Cantilever example. Hughes 1987. Element: $(elementtag)
""")
nu = 0.499999999 # INCOMPRESSIBLE
E1 = E / (1 - nu^2) # Plane strain
nu1 = nu / (1 - nu)
I = h * (2 * c)^3 / 12
function exactux(x, y)
(P / (6 * E1 * I) * (-y) * (3 * (L^2 - (L - x)^2) + (2 + nu1) * (y^2 - c^2)))
end
function exactuy(x, y)
(
P / (6 * E1 * I) * (
((L - x)^3 - L^3) - ((4 + 5 * nu1) * c^2 + 3 * L^2) * (L - x - L) +
3 * nu1 * (L - x) * y^2
)
)
end
modeldatasequence = FDataDict[]
for n in [1 2 4 8] #
nL = 3 * n # number of elements lengthwise
nc = 2 * n # number of elements through the wwith
nh = n # number of elements through the thickness
xs = collect(linearspace(0.0, L, nL + 1))
ys = collect(linearspace(0.0, h, nh + 1))
zs = collect(linearspace(-c, +c, nc + 1))
fens, fes = T10blockx(xs, ys, zs)
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sshearL = selectelem(fens, bfes; facing = true, direction = [+1.0 0.0 0.0])
# 0 cross-section surface for the reactions
sshear0 = selectelem(fens, bfes; facing = true, direction = [-1.0 0.0 0.0])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
# Material orientation matrix
csmat = [i == j ? one(FFlt) : zero(FFlt) for i = 1:3, j = 1:3]
function updatecs!(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
)
copyto!(csmatout, csmat)
end
gr = SimplexRule(3, 4)
region =
FDataDict("femm" => FEMMDeforLinearMST10(MR, IntegDomain(fes, gr), material))
lx0 = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 0.0], inflate = tolerance)
# println("lx0 = $(lx0)")
ex01 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lx0)
ex02 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => lx0)
ex03 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lx0)
lx1 = selectnode(fens, box = [0.0 0.0 0.0 0.0 c c], inflate = tolerance)
lx2 = selectnode(fens, box = [0.0 0.0 0.0 0.0 -c -c], inflate = tolerance)
# println("vcat(lx1, lx2) = $(vcat(lx1, lx2))")
ex04 = FDataDict(
"displacement" => 0.0,
"component" => 1,
"node_list" => vcat(lx1, lx2),
)
ly1 = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
ly2 = selectnode(fens, box = [-Inf Inf h h -Inf Inf], inflate = tolerance)
# println("vcat(ly1, ly2) = $(vcat(ly1, ly2))")
ey01 = FDataDict(
"displacement" => 0.0,
"component" => 2,
"node_list" => vcat(ly1, ly2),
)
Trac0 = FDataDict(
"traction_vector" => getfrc0!,
"femm" => FEMMBase(IntegDomain(subset(bfes, sshear0), SimplexRule(2, 3))),
)
TracL = FDataDict(
"traction_vector" => getfrcL!,
"femm" => FEMMBase(IntegDomain(subset(bfes, sshearL), SimplexRule(2, 3))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [region],
"essential_bcs" => [ex01, ex02, ex03, ex04, ey01],
"traction_bcs" => [Trac0, TracL],
"temperature_change" => FDataDict("temperature" => 0.0),
)
modeldata = linearstatics(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
Tipl = selectnode(fens, box = [L L 0.0 0.0 0.0 0.0], inflate = tolerance)
utip = mean(u.values[Tipl, 3])
println("Deflection: $(utip), compared to $(exactuy(L,0.0))")
modeldata["postprocessing"] = FDataDict(
"file" => "hughes_cantilever_stresses_$(elementtag)",
"outputcsys" => CSys(3, 3, updatecs!),
"quantity" => :Cauchy,
"component" => [5],
)
modeldata = exportstresselementwise(modeldata)
modeldata["postprocessing"] = FDataDict(
"file" => "hughes_cantilever_stresses_$(elementtag)",
"outputcsys" => CSys(3, 3, updatecs!),
"quantity" => :Cauchy,
"component" => collect(1:6),
)
modeldata = exportstresselementwise(modeldata)
stressfields = ElementalField[modeldata["postprocessing"]["exported"][1]["field"]]
modeldata["geometricaltolerance"] = tolerance
modeldata["elementsize"] = 1.0 / n
push!(modeldatasequence, modeldata)
end
filebase = "hughes_cantilever_stresses_incompressible_$(elementtag)"
evaluateerrors(filebase, modeldatasequence)
true
end # hughes_cantilever_stresses_MST10_incompressible
function hughes_cantilever_stresses_nodal_MST10()
elementtag = "MST10"
println("""
Cantilever example. Hughes 1987. Element: $(elementtag)
""")
nu = 0.3 # COMPRESSIBLE
E1 = E / (1 - nu^2) # Plane strain
nu1 = nu / (1 - nu)
I = h * (2 * c)^3 / 12
function exactux(x, y)
(P / (6 * E1 * I) * (-y) * (3 * (L^2 - (L - x)^2) + (2 + nu1) * (y^2 - c^2)))
end
function exactuy(x, y)
(
P / (6 * E1 * I) * (
((L - x)^3 - L^3) - ((4 + 5 * nu1) * c^2 + 3 * L^2) * (L - x - L) +
3 * nu1 * (L - x) * y^2
)
)
end
modeldatasequence = FDataDict[]
for n in [1 2 4 8] #
nL = 3 * n # number of elements lengthwise
nc = 2 * n # number of elements through the wwith
nh = n # number of elements through the thickness
xs = collect(linearspace(0.0, L, nL + 1))
ys = collect(linearspace(0.0, h, nh + 1))
zs = collect(linearspace(-c, +c, nc + 1))
fens, fes = T10blockx(xs, ys, zs)
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sshearL = selectelem(fens, bfes; facing = true, direction = [+1.0 0.0 0.0])
# 0 cross-section surface for the reactions
sshear0 = selectelem(fens, bfes; facing = true, direction = [-1.0 0.0 0.0])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
# Material orientation matrix
csmat = [i == j ? one(FFlt) : zero(FFlt) for i = 1:3, j = 1:3]
function updatecs!(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
)
copyto!(csmatout, csmat)
end
gr = SimplexRule(3, 4) # rule for tetrahedral meshes
region =
FDataDict("femm" => FEMMDeforLinearMST10(MR, IntegDomain(fes, gr), material))
lx0 = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 0.0], inflate = tolerance)
# println("lx0 = $(lx0)")
ex01 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lx0)
ex02 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => lx0)
ex03 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lx0)
lx1 = selectnode(fens, box = [0.0 0.0 0.0 0.0 c c], inflate = tolerance)
lx2 = selectnode(fens, box = [0.0 0.0 0.0 0.0 -c -c], inflate = tolerance)
# println("vcat(lx1, lx2) = $(vcat(lx1, lx2))")
ex04 = FDataDict(
"displacement" => 0.0,
"component" => 1,
"node_list" => vcat(lx1, lx2),
)
ly1 = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
ly2 = selectnode(fens, box = [-Inf Inf h h -Inf Inf], inflate = tolerance)
# println("vcat(ly1, ly2) = $(vcat(ly1, ly2))")
ey01 = FDataDict(
"displacement" => 0.0,
"component" => 2,
"node_list" => vcat(ly1, ly2),
)
Trac0 = FDataDict(
"traction_vector" => getfrc0!,
"femm" => FEMMBase(IntegDomain(subset(bfes, sshear0), SimplexRule(2, 3))),
)
TracL = FDataDict(
"traction_vector" => getfrcL!,
"femm" => FEMMBase(IntegDomain(subset(bfes, sshearL), SimplexRule(2, 3))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [region],
"essential_bcs" => [ex01, ex02, ex03, ex04, ey01],
"traction_bcs" => [Trac0, TracL],
"temperature_change" => FDataDict("temperature" => 0.0),
)
modeldata = linearstatics(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
Tipl = selectnode(fens, box = [L L 0.0 0.0 0.0 0.0], inflate = tolerance)
utip = mean(u.values[Tipl, 3])
println("Deflection: $(utip), compared to $(exactuy(L,0.0))")
modeldata["postprocessing"] = FDataDict(
"file" => "hughes_cantilever_stresses_nodal_$(elementtag)",
"outputcsys" => CSys(3, 3, updatecs!),
"quantity" => :Cauchy,
"component" => collect(1:6),
"nodevalmethod" => :averaging,
"reportat" => :extraptrend,
)
modeldata = exportstress(modeldata)
stressfields = NodalField[modeldata["postprocessing"]["exported"][1]["field"]]
modeldata["geometricaltolerance"] = tolerance
modeldata["elementsize"] = 1.0 / n
push!(modeldatasequence, modeldata)
end
filebase = "hughes_cantilever_stresses_nodal_$(elementtag)"
evaluateerrors(filebase, modeldatasequence)
true
end # hughes_cantilever_stresses_nodal_MST10
function hughes_cantilever_stresses_nodal_T10()
elementtag = "T10"
println("""
Cantilever example. Hughes 1987. Element: $(elementtag)
""")
nu = 0.3 # COMPRESSIBLE
E1 = E / (1 - nu^2) # Plane strain
nu1 = nu / (1 - nu)
I = h * (2 * c)^3 / 12
function exactux(x, y)
(P / (6 * E1 * I) * (-y) * (3 * (L^2 - (L - x)^2) + (2 + nu1) * (y^2 - c^2)))
end
function exactuy(x, y)
(
P / (6 * E1 * I) * (
((L - x)^3 - L^3) - ((4 + 5 * nu1) * c^2 + 3 * L^2) * (L - x - L) +
3 * nu1 * (L - x) * y^2
)
)
end
modeldatasequence = FDataDict[]
for n in [1 2 4 8] #
nL = 3 * n # number of elements lengthwise
nc = 2 * n # number of elements through the wwith
nh = n # number of elements through the thickness
xs = collect(linearspace(0.0, L, nL + 1))
ys = collect(linearspace(0.0, h, nh + 1))
zs = collect(linearspace(-c, +c, nc + 1))
fens, fes = T10blockx(xs, ys, zs)
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sshearL = selectelem(fens, bfes; facing = true, direction = [+1.0 0.0 0.0])
# 0 cross-section surface for the reactions
sshear0 = selectelem(fens, bfes; facing = true, direction = [-1.0 0.0 0.0])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
# Material orientation matrix
csmat = [i == j ? 1.0 : 0.0 for i = 1:3, j = 1:3]
function updatecs!(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
)
copyto!(csmatout, csmat)
end
gr = SimplexRule(3, 4)
region = FDataDict("femm" => FEMMDeforLinear(MR, IntegDomain(fes, gr), material))
lx0 = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 0.0], inflate = tolerance)
# println("lx0 = $(lx0)")
ex01 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lx0)
ex02 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => lx0)
ex03 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lx0)
lx1 = selectnode(fens, box = [0.0 0.0 0.0 0.0 c c], inflate = tolerance)
lx2 = selectnode(fens, box = [0.0 0.0 0.0 0.0 -c -c], inflate = tolerance)
# println("vcat(lx1, lx2) = $(vcat(lx1, lx2))")
ex04 = FDataDict(
"displacement" => 0.0,
"component" => 1,
"node_list" => vcat(lx1, lx2),
)
ly1 = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
ly2 = selectnode(fens, box = [-Inf Inf h h -Inf Inf], inflate = tolerance)
# println("vcat(ly1, ly2) = $(vcat(ly1, ly2))")
ey01 = FDataDict(
"displacement" => 0.0,
"component" => 2,
"node_list" => vcat(ly1, ly2),
)
Trac0 = FDataDict(
"traction_vector" => getfrc0!,
"femm" => FEMMBase(IntegDomain(subset(bfes, sshear0), SimplexRule(2, 3))),
)
TracL = FDataDict(
"traction_vector" => getfrcL!,
"femm" => FEMMBase(IntegDomain(subset(bfes, sshearL), SimplexRule(2, 3))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [region],
"essential_bcs" => [ex01, ex02, ex03, ex04, ey01],
"traction_bcs" => [Trac0, TracL],
"temperature_change" => FDataDict("temperature" => 0.0),
)
modeldata = linearstatics(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
Tipl = selectnode(fens, box = [L L 0.0 0.0 0.0 0.0], inflate = tolerance)
utip = mean(u.values[Tipl, 3])
println("Deflection: $(utip), compared to $(exactuy(L,0.0))")
modeldata["postprocessing"] = FDataDict(
"file" => "hughes_cantilever_stresses_nodal_$(elementtag)",
"outputcsys" => CSys(3, 3, updatecs!),
"quantity" => :Cauchy,
"component" => collect(1:6),
)
modeldata = exportstress(modeldata)
stressfields = NodalField[modeldata["postprocessing"]["exported"][1]["field"]]
modeldata["geometricaltolerance"] = tolerance
modeldata["elementsize"] = 1.0 / n
push!(modeldatasequence, modeldata)
end
filebase = "hughes_cantilever_stresses_nodal_$(elementtag)"
evaluateerrors(filebase, modeldatasequence)
true
end # hughes_cantilever_stresses_nodal_T10
function hughes_cantilever_stresses_T10()
elementtag = "T10"
println("""
Cantilever example. Hughes 1987. Element: $(elementtag)
""")
nu = 0.3 # COMPRESSIBLE
E1 = E / (1 - nu^2) # Plane strain
nu1 = nu / (1 - nu)
I = h * (2 * c)^3 / 12
function exactux(x, y)
(P / (6 * E1 * I) * (-y) * (3 * (L^2 - (L - x)^2) + (2 + nu1) * (y^2 - c^2)))
end
function exactuy(x, y)
(
P / (6 * E1 * I) * (
((L - x)^3 - L^3) - ((4 + 5 * nu1) * c^2 + 3 * L^2) * (L - x - L) +
3 * nu1 * (L - x) * y^2
)
)
end
modeldatasequence = FDataDict[]
for n in [1 2 4 8] #
nL = 3 * n # number of elements lengthwise
nc = 2 * n # number of elements through the wwith
nh = n # number of elements through the thickness
xs = collect(linearspace(0.0, L, nL + 1))
ys = collect(linearspace(0.0, h, nh + 1))
zs = collect(linearspace(-c, +c, nc + 1))
fens, fes = T10blockx(xs, ys, zs)
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sshearL = selectelem(fens, bfes; facing = true, direction = [+1.0 0.0 0.0])
# 0 cross-section surface for the reactions
sshear0 = selectelem(fens, bfes; facing = true, direction = [-1.0 0.0 0.0])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
# Material orientation matrix
csmat = [i == j ? one(FFlt) : zero(FFlt) for i = 1:3, j = 1:3]
function updatecs!(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
)
copyto!(csmatout, csmat)
end
gr = SimplexRule(3, 4)
region = FDataDict("femm" => FEMMDeforLinear(MR, IntegDomain(fes, gr), material))
lx0 = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 0.0], inflate = tolerance)
# println("lx0 = $(lx0)")
ex01 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lx0)
ex02 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => lx0)
ex03 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lx0)
lx1 = selectnode(fens, box = [0.0 0.0 0.0 0.0 c c], inflate = tolerance)
lx2 = selectnode(fens, box = [0.0 0.0 0.0 0.0 -c -c], inflate = tolerance)
# println("vcat(lx1, lx2) = $(vcat(lx1, lx2))")
ex04 = FDataDict(
"displacement" => 0.0,
"component" => 1,
"node_list" => vcat(lx1, lx2),
)
ly1 = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
ly2 = selectnode(fens, box = [-Inf Inf h h -Inf Inf], inflate = tolerance)
# println("vcat(ly1, ly2) = $(vcat(ly1, ly2))")
ey01 = FDataDict(
"displacement" => 0.0,
"component" => 2,
"node_list" => vcat(ly1, ly2),
)
Trac0 = FDataDict(
"traction_vector" => getfrc0!,
"femm" => FEMMBase(IntegDomain(subset(bfes, sshear0), SimplexRule(2, 3))),
)
TracL = FDataDict(
"traction_vector" => getfrcL!,
"femm" => FEMMBase(IntegDomain(subset(bfes, sshearL), SimplexRule(2, 3))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [region],
"essential_bcs" => [ex01, ex02, ex03, ex04, ey01],
"traction_bcs" => [Trac0, TracL],
"temperature_change" => FDataDict("temperature" => 0.0),
)
modeldata = linearstatics(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
Tipl = selectnode(fens, box = [L L 0.0 0.0 0.0 0.0], inflate = tolerance)
utip = mean(u.values[Tipl, 3])
println("Deflection: $(utip), compared to $(exactuy(L,0.0))")
modeldata["postprocessing"] = FDataDict(
"file" => "hughes_cantilever_stresses_$(elementtag)",
"outputcsys" => CSys(3, 3, updatecs!),
"quantity" => :Cauchy,
"component" => [5],
)
modeldata = exportstresselementwise(modeldata)
modeldata["postprocessing"] = FDataDict(
"file" => "hughes_cantilever_stresses_$(elementtag)",
"outputcsys" => CSys(3, 3, updatecs!),
"quantity" => :Cauchy,
"component" => collect(1:6),
)
modeldata = exportstresselementwise(modeldata)
stressfields = ElementalField[modeldata["postprocessing"]["exported"][1]["field"]]
modeldata["geometricaltolerance"] = tolerance
modeldata["elementsize"] = 1.0 / n
push!(modeldatasequence, modeldata)
end
filebase = "hughes_cantilever_stresses_$(elementtag)"
evaluateerrors(filebase, modeldatasequence)
true
end # hughes_cantilever_stresses_T10
function hughes_cantilever_stresses_T10_incompressible()
elementtag = "T10"
println("""
Cantilever example. Hughes 1987. Element: $(elementtag)
""")
nu = 0.499999999 # INCOMPRESSIBLE
E1 = E / (1 - nu^2) # Plane strain
nu1 = nu / (1 - nu)
I = h * (2 * c)^3 / 12
function exactux(x, y)
(P / (6 * E1 * I) * (-y) * (3 * (L^2 - (L - x)^2) + (2 + nu1) * (y^2 - c^2)))
end
function exactuy(x, y)
(
P / (6 * E1 * I) * (
((L - x)^3 - L^3) - ((4 + 5 * nu1) * c^2 + 3 * L^2) * (L - x - L) +
3 * nu1 * (L - x) * y^2
)
)
end
modeldatasequence = FDataDict[]
for n in [1 2 4 8] #
nL = 3 * n # number of elements lengthwise
nc = 2 * n # number of elements through the wwith
nh = n # number of elements through the thickness
xs = collect(linearspace(0.0, L, nL + 1))
ys = collect(linearspace(0.0, h, nh + 1))
zs = collect(linearspace(-c, +c, nc + 1))
fens, fes = T10blockx(xs, ys, zs)
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sshearL = selectelem(fens, bfes; facing = true, direction = [+1.0 0.0 0.0])
# 0 cross-section surface for the reactions
sshear0 = selectelem(fens, bfes; facing = true, direction = [-1.0 0.0 0.0])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
# Material orientation matrix
csmat = [i == j ? one(FFlt) : zero(FFlt) for i = 1:3, j = 1:3]
function updatecs!(
csmatout::FFltMat,
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
)
copyto!(csmatout, csmat)
end
gr = SimplexRule(3, 4)
region = FDataDict("femm" => FEMMDeforLinear(MR, IntegDomain(fes, gr), material))
lx0 = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 0.0], inflate = tolerance)
# println("lx0 = $(lx0)")
ex01 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lx0)
ex02 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => lx0)
ex03 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lx0)
lx1 = selectnode(fens, box = [0.0 0.0 0.0 0.0 c c], inflate = tolerance)
lx2 = selectnode(fens, box = [0.0 0.0 0.0 0.0 -c -c], inflate = tolerance)
# println("vcat(lx1, lx2) = $(vcat(lx1, lx2))")
ex04 = FDataDict(
"displacement" => 0.0,
"component" => 1,
"node_list" => vcat(lx1, lx2),
)
ly1 = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
ly2 = selectnode(fens, box = [-Inf Inf h h -Inf Inf], inflate = tolerance)
# println("vcat(ly1, ly2) = $(vcat(ly1, ly2))")
ey01 = FDataDict(
"displacement" => 0.0,
"component" => 2,
"node_list" => vcat(ly1, ly2),
)
Trac0 = FDataDict(
"traction_vector" => getfrc0!,
"femm" => FEMMBase(IntegDomain(subset(bfes, sshear0), SimplexRule(2, 3))),
)
TracL = FDataDict(
"traction_vector" => getfrcL!,
"femm" => FEMMBase(IntegDomain(subset(bfes, sshearL), SimplexRule(2, 3))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [region],
"essential_bcs" => [ex01, ex02, ex03, ex04, ey01],
"traction_bcs" => [Trac0, TracL],
"temperature_change" => FDataDict("temperature" => 0.0),
)
modeldata = linearstatics(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
Tipl = selectnode(fens, box = [L L 0.0 0.0 0.0 0.0], inflate = tolerance)
utip = mean(u.values[Tipl, 3])
println("Deflection: $(utip), compared to $(exactuy(L,0.0))")
modeldata["postprocessing"] = FDataDict(
"file" => "hughes_cantilever_stresses_$(elementtag)",
"outputcsys" => CSys(3, 3, updatecs!),
"quantity" => :Cauchy,
"component" => [5],
)
modeldata = exportstresselementwise(modeldata)
modeldata["postprocessing"] = FDataDict(
"file" => "hughes_cantilever_stresses_$(elementtag)",
"outputcsys" => CSys(3, 3, updatecs!),
"quantity" => :Cauchy,
"component" => collect(1:6),
)
modeldata = exportstresselementwise(modeldata)
stressfields = ElementalField[modeldata["postprocessing"]["exported"][1]["field"]]
modeldata["geometricaltolerance"] = tolerance
modeldata["elementsize"] = 1.0 / n
push!(modeldatasequence, modeldata)
end
filebase = "hughes_cantilever_stresses_incompressible_$(elementtag)"
evaluateerrors(filebase, modeldatasequence)
true
end # hughes_cantilever_stresses_T10_incompressible
function allrun()
println("#####################################################")
println("# hughes_cantilever_stresses_H8_by_hand ")
hughes_cantilever_stresses_H8_by_hand()
println("#####################################################")
println("# hughes_cantilever_stresses_H20_by_hand ")
hughes_cantilever_stresses_H20_by_hand()
println("#####################################################")
println("# hughes_cantilever_stresses_T10_by_hand ")
hughes_cantilever_stresses_T10_by_hand()
println("#####################################################")
println("# hughes_cantilever_stresses_MST10 ")
hughes_cantilever_stresses_MST10()
println("#####################################################")
println("# hughes_cantilever_stresses_MST10_incompressible ")
hughes_cantilever_stresses_MST10_incompressible()
println("#####################################################")
println("# hughes_cantilever_stresses_nodal_MST10 ")
hughes_cantilever_stresses_nodal_MST10()
println("#####################################################")
println("# hughes_cantilever_stresses_nodal_T10 ")
hughes_cantilever_stresses_nodal_T10()
println("#####################################################")
println("# hughes_cantilever_stresses_T10 ")
hughes_cantilever_stresses_T10()
println("#####################################################")
println("# hughes_cantilever_stresses_T10_incompressible ")
hughes_cantilever_stresses_T10_incompressible()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 3853 | module multimaterial_beam_examples
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtools.MeshExportModule
function multimaterial_beam_algo()
println("""
Multi-material beam. Rubber-like and metal-like halves,
clamped, with shear traction at free end.
""")
E1 = 0.29e3
nu1 = 0.49
E2 = 0.4e4
nu2 = 0.3
W = 4.1
L = 12.0
t = 6.5
nl = 2
nt = 1
nw = 1
ref = 9
p = 200.0 / W / t
# Loading in the Z direction
loadv = [0; 0; p]
dir = 3
tolerance = t / 1000
fens, fes = H20block(L, W, t, nl * ref, nw * ref, nt * ref)
# Clamped end of the beam
l1 = selectnode(fens; box = [0 0 -Inf Inf -Inf Inf], inflate = tolerance)
e1 = FDataDict("node_list" => l1, "component" => 1, "displacement" => 0.0)
e2 = FDataDict("node_list" => l1, "component" => 2, "displacement" => 0.0)
e3 = FDataDict("node_list" => l1, "component" => 3, "displacement" => 0.0)
# Traction on the opposite edge
boundaryfes = meshboundary(fes)
Toplist =
selectelem(fens, boundaryfes, box = [L L -Inf Inf -Inf Inf], inflate = tolerance)
el1femm = FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(2, 2)))
flux1 = FDataDict("femm" => el1femm, "traction_vector" => loadv)
r1list = selectelem(fens, fes, box = [0 L / 2.0 -Inf Inf -Inf Inf], inflate = tolerance)
r2list = selectelem(fens, fes, box = [L / 2.0 L -Inf Inf -Inf Inf], inflate = tolerance)
# Model reduction type
MR = DeforModelRed3D
# Make region 1
region1 = FDataDict(
"femm" => FEMMDeforLinear(
MR,
IntegDomain(subset(fes, r1list), GaussRule(3, 2)),
MatDeforElastIso(MR, 0.0, E1, nu1, 0.0),
),
)
# Make region 2
region2 = FDataDict(
"femm" => FEMMDeforLinear(
MR,
IntegDomain(subset(fes, r2list), GaussRule(3, 2)),
MatDeforElastIso(MR, 0.0, E2, nu2, 0.0),
),
)
# Make model data
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1, region2],
"essential_bcs" => [e1, e2, e3],
"traction_bcs" => [flux1],
)
# Call the solver
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
geom = modeldata["geom"]
u = modeldata["u"]
# Write out mesh with displacements
modeldata["postprocessing"] = FDataDict("file" => "multimaterial_beam")
modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
# Write out mesh with stresses
modeldata["postprocessing"] = FDataDict(
"file" => "multimaterial_beam_xy",
"quantity" => :Cauchy,
"component" => :xy,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
# Write out mesh with stresses
modeldata["postprocessing"] = FDataDict(
"file" => "multimaterial_beam_xz",
"quantity" => :Cauchy,
"component" => :xz,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
# Write out mesh with von Mises stresses
modeldata["postprocessing"] =
FDataDict("file" => "multimaterial_beam_vm", "quantity" => :vm)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
# Write out mesh with von Mises stresses, elementwise
modeldata["postprocessing"] =
FDataDict("file" => "multimaterial_beam_vm-ew", "quantity" => :vm)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
end # multimaterial_beam_algo
function allrun()
println("#####################################################")
println("# multimaterial_beam_algo ")
multimaterial_beam_algo()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 4328 | """
This is an example that shows scaling with threading assembly that can be
compared with Ferrite.
"""
println("Current folder: $(pwd())")
using Pkg
Pkg.activate(".")
Pkg.instantiate()
Pkg.add(url="https://github.com/PetrKryslUCSD/FinEtools.jl.git#main")
Pkg.add(url="https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git")
Pkg.add(url="https://github.com/PetrKryslUCSD/ParFEM.jl.git")
Pkg.add("ChunkSplitters")
Pkg.add("SymRCM")
Pkg.add("ThreadPinning")
Pkg.update()
Pkg.status()
module par_assembly_examples
using FinEtools
using FinEtoolsDeforLinear
using ChunkSplitters
using SymRCM
using ParFEM: parallel_make_csc_matrix
function run_example(N = 10, ntasks = 2, do_serial = false)
E = 1000.0
nu = 0.4999 #Taylor data
W = 25.0
H = 50.0
L = 50.0
CTE = 0.0
fens, fes = H8block(W, L, H, N, N, 10*N)
#C = connectionmatrix(FEMMBase(IntegDomain(fes, GaussRule(3, 1))), count(fens))
#ordering = symrcm(C)
#fens, fes = reordermesh(fens, fes, ordering)
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
ir = GaussRule(3, 2)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
if do_serial
@info "Serial Assembly"
@time femm = FEMMDeforLinear(MR, IntegDomain(fes, ir), material)
@time associategeometry!(femm, geom)
@time K = stiffness(femm, geom, u)
end
@info "Parallel Assembly with $(ntasks) Tasks"
function matrixcomputation!(femm, assembler)
stiffness(femm, assembler, geom, u)
end
femms = FEMMDeforLinear[]
@time for (ch, j) in chunks(1:count(fes), ntasks)
femm = FEMMDeforLinear(MR, IntegDomain(subset(fes, ch), ir), material)
associategeometry!(femm, geom)
push!(femms, femm)
end
@time assembler = make_assembler(femms, SysmatAssemblerSparseSymm, u)
@time start_assembler!(assembler)
@time assemblers = make_task_assemblers(femms, assembler, SysmatAssemblerSparseSymm, u)
@time parallel_matrix_assembly(femms, assemblers, matrixcomputation!)
@time K = make_matrix!(assembler)
true
end # run_example
function run_example2(N = 10, ntasks = 2, do_serial = false)
E = 1000.0
nu = 0.4999 #Taylor data
W = 25.0
H = 50.0
L = 50.0
CTE = 0.0
fens, fes = H8block(W, L, H, N, N, 10*N)
#C = connectionmatrix(FEMMBase(IntegDomain(fes, GaussRule(3, 1))), count(fens))
#ordering = symrcm(C)
#fens, fes = reordermesh(fens, fes, ordering)
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
ir = GaussRule(3, 2)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
if do_serial
@info "Serial Assembly"
@time femm = FEMMDeforLinear(MR, IntegDomain(fes, ir), material)
@time associategeometry!(femm, geom)
@time K = stiffness(femm, geom, u)
end
@info "Parallel Assembly with $(ntasks) Tasks"
function matrixcomputation!(femm, assembler)
associategeometry!(femm, geom)
stiffness(femm, assembler, geom, u)
end
function createsubdomain(fessubset)
FEMMDeforLinear(MR, IntegDomain(fessubset, GaussRule(3, 2)), material)
end
@time K = parallel_make_csc_matrix(fes, u, createsubdomain, matrixcomputation!, ntasks)
# femms = FEMMDeforLinear[]
# @time for (ch, j) in chunks(1:count(fes), ntasks)
# femm = FEMMDeforLinear(MR, IntegDomain(subset(fes, ch), ir), material)
# associategeometry!(femm, geom)
# push!(femms, femm)
# end
# @time assembler = make_assembler(femms, SysmatAssemblerSparseSymm, u)
# @time start_assembler!(assembler)
# @time assemblers = make_task_assemblers(femms, assembler, SysmatAssemblerSparseSymm, u)
# @time parallel_matrix_assembly(femms, assemblers, matrixcomputation!)
# @time K = make_matrix!(assembler)
true
end # run_example2
end # module
@show Threads.nthreads()
using ThreadPinning
pinthreads(:cores)
@show N = parse(Int, ARGS[1])
@show ntasks = parse(Int, ARGS[2])
using .Main.par_assembly_examples;
ex = Main.par_assembly_examples.run_example2
ex(N, 1, true)
ex(N, 1, true)
ex(N, ntasks, false)
ex(N, ntasks, false)
nothing | FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 8464 | module parallel_examples
using FinEtools
using FinEtools.AlgoBaseModule: evalconvergencestudy, solve_blocked!
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule:
linearstatics, exportstresselementwise, exportstress
using Statistics: mean
using LinearAlgebra
using SparseArrays
using LinearSolve
using SciMLOperators
using IncompleteLU
using Printf
using SymRCM
using SparseMatricesCSR
using ThreadedSparseCSR
using UnicodePlots
using PlotlyJS
# using Infiltrator
using Random
using DataDrop
using ChunkSplitters
using ParFEM: make_assembler, start_assembler!, make_task_assemblers, parallel_matrix_assembly, csc_matrix_pattern, add_to_matrix!, subdomainfemms
using ParFEM: parallel_make_csc_matrix
# Isotropic material
E = 1000.0
nu = 0.4999 # Taylor data: nearly incompressible material
nu = 0.3 # Compressible material
W = 25.0
H = 50.0
L = 50.0
htol = minimum([L, H, W]) / 1000
uzex = -0.16
magn = 0.2 * (-12.6) / 4
Force = magn * W * H * 2
CTE = 0.0
n = 5 #
function getfrcL!(forceout, XYZ, tangents, feid, qpid)
copyto!(forceout, [0.0; 0.0; magn])
end
function example(n = 10; precond = :ilu, alg = :cg, other...)
elementtag = "H8"
println("""
Stubby corbel example. Element: $(elementtag)
""")
fens, fes = H8block(W, L, H, n, 2 * n, 2 * n)
println("Number of elements: $(count(fes))")
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sectionL = selectelem(fens, bfes; facing = true, direction = [0.0 +1.0 0.0])
# 0 cross-section surface for the reactions
section0 = selectelem(fens, bfes; facing = true, direction = [0.0 -1.0 0.0])
# 0 cross-section surface for the reactions
sectionlateral = selectelem(fens, bfes; facing = true, direction = [1.0 0.0 0.0])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
# Material orientation matrix
csmat = [i == j ? one(Float64) : zero(Float64) for i = 1:3, j = 1:3]
function updatecs!(csmatout, XYZ, tangents, feid, qpid)
copyto!(csmatout, csmat)
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
# Renumber the nodes
femm = FEMMBase(IntegDomain(fes, GaussRule(3, 2)))
C = connectionmatrix(femm, count(fens))
perm = symrcm(C)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
lx0 = connectednodes(subset(bfes, section0))
setebc!(u, lx0, true, 1, 0.0)
setebc!(u, lx0, true, 2, 0.0)
setebc!(u, lx0, true, 3, 0.0)
lx1 = connectednodes(subset(bfes, sectionlateral))
setebc!(u, lx1, true, 1, 0.0)
applyebc!(u)
numberdofs!(u, perm)
# numberdofs!(u)
println("nfreedofs(u) = $(nfreedofs(u))")
fi = ForceIntensity(Float64, 3, getfrcL!)
el2femm = FEMMBase(IntegDomain(subset(bfes, sectionL), GaussRule(2, 2)))
F = distribloads(el2femm, geom, u, fi, 2)
F_f = vector_blocked_f(F, nfreedofs(u))
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K_ff = matrix_blocked_ff(K, nfreedofs(u))
K = nothing
println("Stiffness: number of non zeros = $(nnz(K_ff)) [ND]")
println("Sparsity = $(nnz(K_ff)/size(K_ff, 1)/size(K_ff, 2)) [ND]")
# display(spy(K_ff, canvas = DotCanvas))
Tipl = selectnode(fens, box = [0 W L L 0 H], inflate = htol)
if precond == :ilu
mK_ffd = mean(diag(K_ff))
PRECOND = ilu(K_ff, τ = mK_ffd / 100.0)
elseif precond == :kdiag
PRECOND = Diagonal(diag(K_ff))
end
if alg == :cg
ALG = KrylovJL_CG
elseif alg == :gmres
ALG = KrylovJL_GMRES
end
verbose = haskey(other, :verbose) ? other[:verbose] : false
prob = LinearProblem(K_ff, F_f)
@time sol = solve(prob, ALG(), Pl=PRECOND, verbose=verbose)
scattersysvec!(u, sol.u[:])
utip = mean(u.values[Tipl, 3], dims = 1)
println("Deflection: $(utip), compared to $(uzex)")
File = "example-n=$(n).vtk"
vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
@async run(`"paraview.exe" $File`)
true
end # example
function example_wop(n = 10; ntasks = Threads.nthreads(), precond = :ilu, alg = :cg, other...)
elementtag = "H8"
println("""
Stubby corbel example. Element: $(elementtag)
""")
fens, fes = H8block(W, L, H, n, 2 * n, 2 * n)
println("Number of elements: $(count(fes))")
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sectionL = selectelem(fens, bfes; facing = true, direction = [0.0 +1.0 0.0])
# 0 cross-section surface for the reactions
section0 = selectelem(fens, bfes; facing = true, direction = [0.0 -1.0 0.0])
# 0 cross-section surface for the reactions
sectionlateral = selectelem(fens, bfes; facing = true, direction = [1.0 0.0 0.0])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
# Material orientation matrix
csmat = [i == j ? one(Float64) : zero(Float64) for i = 1:3, j = 1:3]
function updatecs!(csmatout, XYZ, tangents, feid, qpid)
copyto!(csmatout, csmat)
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
# Renumber the nodes
femm = FEMMBase(IntegDomain(fes, GaussRule(3, 2)))
C = connectionmatrix(femm, count(fens))
perm = symrcm(C)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
lx0 = connectednodes(subset(bfes, section0))
setebc!(u, lx0, true, 1, 0.0)
setebc!(u, lx0, true, 2, 0.0)
setebc!(u, lx0, true, 3, 0.0)
lx1 = connectednodes(subset(bfes, sectionlateral))
setebc!(u, lx1, true, 1, 0.0)
applyebc!(u)
numberdofs!(u, perm)
# numberdofs!(u)
println("nfreedofs(u) = $(nfreedofs(u))")
fi = ForceIntensity(Float64, 3, getfrcL!)
el2femm = FEMMBase(IntegDomain(subset(bfes, sectionL), GaussRule(2, 2)))
F = distribloads(el2femm, geom, u, fi, 2)
F_f = vector_blocked_f(F, nfreedofs(u))
function matrixcomputation!(femm, assembler)
stiffness(femm, assembler, geom, u)
end
function createsubdomain(fessubset)
FEMMDeforLinear(MR, IntegDomain(fessubset, GaussRule(3, 2)), material)
end
@time K = parallel_make_csc_matrix(fes, u, createsubdomain, matrixcomputation!, ntasks)
# femms = subdomainfemms(fes, ntasks, createsubdomain)
# @time assembler = make_assembler(femms, SysmatAssemblerSparse, u)
# @time start_assembler!(assembler)
# @time assemblers = make_task_assemblers(femms, assembler, SysmatAssemblerSparse, u)
# @time parallel_matrix_assembly(femms, assemblers, matrixcomputation!)
# @time K = csc_matrix_pattern(fes, u)
# @time add_to_matrix!(K, assembler)
K_ff = matrix_blocked_ff(K, nfreedofs(u))
K = nothing
println("Stiffness: number of non zeros = $(nnz(K_ff)) [ND]")
println("Sparsity = $(nnz(K_ff)/size(K_ff, 1)/size(K_ff, 2)) [ND]")
# display(spy(K_ff, canvas = DotCanvas))
Tipl = selectnode(fens, box = [0 W L L 0 H], inflate = htol)
if precond == :ilu
mK_ffd = mean(diag(K_ff))
PRECOND = ilu(K_ff, τ = mK_ffd / 100.0)
elseif precond == :kdiag
PRECOND = Diagonal(diag(K_ff))
end
if alg == :cg
ALG = KrylovJL_CG
elseif alg == :gmres
ALG = KrylovJL_GMRES
end
verbose = haskey(other, :verbose) ? other[:verbose] : false
# mop = MatrixOperator(K_ff)
# prob = LinearProblem(mop, F_f)
K_ff = SparseMatricesCSR.SparseMatrixCSR(Transpose(K_ff))
fop = FunctionOperator((v, u, p, t) -> bmul!(v, K_ff, u), F_f, zeros(length(F_f)))
# fop = FunctionOperator((v, u, p, t) -> mul!(v, K_ff, u), F_f, zeros(length(F_f)); ifcache = false)
prob = LinearProblem(fop, F_f)
@time sol = solve(prob, ALG(), Pl=PRECOND, verbose=verbose)
scattersysvec!(u, sol.u[:])
utip = mean(u.values[Tipl, 3], dims = 1)
println("Deflection: $(utip), compared to $(uzex)")
File = "example-n=$(n).vtk"
vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
# @async run(`"paraview.exe" $File`)
true
end # example_wop
function allrun(n = 10; args...)
println("#####################################################")
println("# example ")
example_wop(n; args...)
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 23596 | module pinchcyl_examples
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!, matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtools.MeshExportModule
using Statistics: mean
E = 3e6
nu = 0.3
thickness = 3.0
uzex = -1.82488e-5 # analytical solution for the vertical deflection under the load
R = 300
L = 600
ref = 32
tolerance = thickness / 1000
load = [0; 0; 1.0]
function pinchcyl_h8_full()
let (n, nt) = (ref, 2)
fens, fes = H8block(90 / 360 * 2 * pi, L / 2, thickness, n, n, nt)
for i = 1:count(fens)
a = fens.xyz[i, 1]
y = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] .=
((R - thickness / 2 + z) * sin(a), y, (R - thickness / 2 + z) * cos(a))
end
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
boundaryfes = meshboundary(fes)
topl = selectelem(
fens,
boundaryfes,
box = [-Inf Inf -Inf Inf thickness thickness],
inflate = tolerance,
)
botl = selectelem(
fens,
boundaryfes,
box = [-Inf Inf -Inf Inf 0.0 0.0],
inflate = tolerance,
)
x0l = selectelem(
fens,
boundaryfes,
box = [0.0 0.0 -Inf Inf 0.0 thickness],
inflate = tolerance,
)
y0l = selectelem(
fens,
boundaryfes,
box = [-Inf Inf 0.0 0.0 0.0 thickness],
inflate = tolerance,
)
cyll = setdiff(1:count(boundaryfes), topl, botl, x0l, y0l)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
y0nl = selectnode(fens, box = [-Inf Inf 0 0 -Inf Inf], inflate = tolerance)
setebc!(u, y0nl, true, [1; 3], 0.0)
yL2nl = selectnode(fens, box = [-Inf Inf L / 2 L / 2 -Inf Inf], inflate = tolerance)
setebc!(u, yL2nl, true, [2], 0.0)
x0nl = selectnode(fens, box = [0 0 -Inf Inf -Inf Inf], inflate = tolerance)
setebc!(u, x0nl, true, [1], 0.0)
z0nl = selectnode(fens, box = [-Inf Inf -Inf Inf 0 0], inflate = tolerance)
setebc!(u, z0nl, true, [3], 0.0)
applyebc!(u)
numberdofs!(u)
loadnl = selectnode(fens; box = [0 0 L / 2 L / 2 -Inf Inf], inflate = tolerance)
nfemm =
FEMMBase(IntegDomain(FESetP1(reshape(loadnl, length(loadnl), 1)), PointRule()))
F = distribloads(
nfemm,
geom,
u,
ForceIntensity([0; 0; -1.0 / 4 / length(loadnl)]),
3,
)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K, F)
u0z = mean(u.values[loadnl, 3])
println("Deflection under the load: $(round((u0z / uzex)* 100000)/100000*100) %")
File = "pinchcyl_h8_full_$(n)x$(nt).vtk"
vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
@async run(`"paraview.exe" $File`)
end
true
end # pinchcyl_h8_full
function pinchcyl_h8_uri()
nt = 1
for nperradius in [2, 4, 8]
nt = nt + 1
fens, fes = Q4circlen(R, nperradius)
fens, fes = H8extrudeQ4(fens, fes, nt, (x, k) -> [x[1], x[2], k * thickness / nt])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 1)), material)
boundaryfes = meshboundary(fes)
topl = selectelem(
fens,
boundaryfes,
box = [-Inf Inf -Inf Inf thickness thickness],
inflate = tolerance,
)
botl = selectelem(
fens,
boundaryfes,
box = [-Inf Inf -Inf Inf 0.0 0.0],
inflate = tolerance,
)
x0l = selectelem(
fens,
boundaryfes,
box = [0.0 0.0 -Inf Inf 0.0 thickness],
inflate = tolerance,
)
y0l = selectelem(
fens,
boundaryfes,
box = [-Inf Inf 0.0 0.0 0.0 thickness],
inflate = tolerance,
)
cyll = setdiff(1:count(boundaryfes), topl, botl, x0l, y0l)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
x0nl = connectednodes(subset(boundaryfes, x0l))
setebc!(u, x0nl, true, 1, 0.0)
y0nl = connectednodes(subset(boundaryfes, y0l))
setebc!(u, y0nl, true, 2, 0.0)
cylnl = connectednodes(subset(boundaryfes, cyll))
setebc!(u, cylnl, true, 1, 0.0)
setebc!(u, cylnl, true, 2, 0.0)
setebc!(u, cylnl, true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
cnl = selectnode(fens; box = [0 0 0 0 0 thickness], inflate = tolerance)
nfemm = FEMMBase(IntegDomain(FESetP1(reshape(cnl, length(cnl), 1)), PointRule()))
F = distribloads(
nfemm,
geom,
u,
ForceIntensity([0; 0; Magnitude / 4 / length(cnl)]),
3,
)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K, F)
u0z = mean(u.values[cnl, 3])
println(
"Deflection under the load: $(round((u0z / analyt_sol)* 100000)/100000*100) %",
)
# File = "pinchcyl_1_$(nperradius).vtk"
# vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
# @async run(`"paraview.exe" $File`)
end
true
end # pinchcyl_h8_uri
function pinchcyl_h8_ms()
let (n, nt) = (ref, 4)
fens, fes = H8block(90 / 360 * 2 * pi, L / 2, thickness, n, n, nt)
for i = 1:count(fens)
a = fens.xyz[i, 1]
y = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] .=
((R - thickness / 2 + z) * sin(a), y, (R - thickness / 2 + z) * cos(a))
end
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
boundaryfes = meshboundary(fes)
topl = selectelem(
fens,
boundaryfes,
box = [-Inf Inf -Inf Inf thickness thickness],
inflate = tolerance,
)
botl = selectelem(
fens,
boundaryfes,
box = [-Inf Inf -Inf Inf 0.0 0.0],
inflate = tolerance,
)
x0l = selectelem(
fens,
boundaryfes,
box = [0.0 0.0 -Inf Inf 0.0 thickness],
inflate = tolerance,
)
y0l = selectelem(
fens,
boundaryfes,
box = [-Inf Inf 0.0 0.0 0.0 thickness],
inflate = tolerance,
)
cyll = setdiff(1:count(boundaryfes), topl, botl, x0l, y0l)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
y0nl = selectnode(fens, box = [-Inf Inf 0 0 -Inf Inf], inflate = tolerance)
setebc!(u, y0nl, true, [1; 3], 0.0)
yL2nl = selectnode(fens, box = [-Inf Inf L / 2 L / 2 -Inf Inf], inflate = tolerance)
setebc!(u, yL2nl, true, [2], 0.0)
x0nl = selectnode(fens, box = [0 0 -Inf Inf -Inf Inf], inflate = tolerance)
setebc!(u, x0nl, true, [1], 0.0)
z0nl = selectnode(fens, box = [-Inf Inf -Inf Inf 0 0], inflate = tolerance)
setebc!(u, z0nl, true, [3], 0.0)
applyebc!(u)
numberdofs!(u)
loadnl = selectnode(fens; box = [0 0 L / 2 L / 2 -Inf Inf], inflate = tolerance)
nfemm =
FEMMBase(IntegDomain(FESetP1(reshape(loadnl, length(loadnl), 1)), PointRule()))
F = distribloads(
nfemm,
geom,
u,
ForceIntensity([0; 0; -1.0 / 4 / length(loadnl)]),
3,
)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K, F)
u0z = mean(u.values[loadnl, 3])
println("Deflection under the load: $(round((u0z / uzex)* 100000)/100000*100) %")
File = "pinchcyl_h8_ms_$(n)x$(nt).vtk"
vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
@async run(`"paraview.exe" $File`)
end
true
end # pinchcyl_h8_ms
function pinchcyl_h8_export()
nt = 1
for nperradius in [2, 4, 8]
nt = nt + 1
fens, fes = Q4circlen(R, nperradius)
fens, fes = H8extrudeQ4(fens, fes, nt, (x, k) -> [x[1], x[2], k * thickness / nt])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
boundaryfes = meshboundary(fes)
topl = selectelem(
fens,
boundaryfes,
box = [-Inf Inf -Inf Inf thickness thickness],
inflate = tolerance,
)
botl = selectelem(
fens,
boundaryfes,
box = [-Inf Inf -Inf Inf 0.0 0.0],
inflate = tolerance,
)
x0l = selectelem(
fens,
boundaryfes,
box = [0.0 0.0 -Inf Inf 0.0 thickness],
inflate = tolerance,
)
y0l = selectelem(
fens,
boundaryfes,
box = [-Inf Inf 0.0 0.0 0.0 thickness],
inflate = tolerance,
)
cyll = setdiff(1:count(boundaryfes), topl, botl, x0l, y0l)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
x0nl = connectednodes(subset(boundaryfes, x0l))
setebc!(u, x0nl, true, 1, 0.0)
y0nl = connectednodes(subset(boundaryfes, y0l))
setebc!(u, y0nl, true, 2, 0.0)
cylnl = connectednodes(subset(boundaryfes, cyll))
setebc!(u, cylnl, true, 1, 0.0)
setebc!(u, cylnl, true, 2, 0.0)
setebc!(u, cylnl, true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
cnl = selectnode(fens; box = [0 0 0 0 0 thickness], inflate = tolerance)
AE = AbaqusExporter("pinchcyl_h8_export_$(nperradius)")
HEADING(AE, "Clamped square plate with concentrated force")
PART(AE, "part1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
ELEMENT(AE, "c3d8rh", "AllElements", 1, connasarray(femm.integdomain.fes))
NSET_NSET(AE, "cnl", cnl)
NSET_NSET(AE, "x0nl", x0nl)
NSET_NSET(AE, "y0nl", y0nl)
NSET_NSET(AE, "cylnl", cylnl)
ORIENTATION(AE, "GlobalOrientation", vec([1.0 0 0]), vec([0 1.0 0]))
SOLID_SECTION(AE, "elasticity", "GlobalOrientation", "AllElements", "Hourglassctl")
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "elasticity")
ELASTIC(AE, E, nu)
SECTION_CONTROLS(AE, "Hourglassctl", "HOURGLASS=ENHANCED")
STEP_PERTURBATION_STATIC(AE)
BOUNDARY(AE, "ASSEM1.INSTNC1.x0nl", 1)
BOUNDARY(AE, "ASSEM1.INSTNC1.y0nl", 2)
BOUNDARY(AE, "ASSEM1.INSTNC1.cylnl", 1)
BOUNDARY(AE, "ASSEM1.INSTNC1.cylnl", 2)
BOUNDARY(AE, "ASSEM1.INSTNC1.cylnl", 3)
CLOAD(AE, "ASSEM1.INSTNC1.cnl", 3, Magnitude / 4 / length(cnl))
END_STEP(AE)
close(AE)
# File = "pinchcyl_h8_export_$(nperradius).vtk"
# vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
# @async run(`"paraview.exe" $File`)
end
true
end # pinchcyl_h8_export
function pinchcyl_h20r()
let (n, nt) = (ref, 4)
fens, fes = H20block(90 / 360 * 2 * pi, L / 2, thickness, n, n, nt)
for i = 1:count(fens)
a = fens.xyz[i, 1]
y = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] .=
((R - thickness / 2 + z) * sin(a), y, (R - thickness / 2 + z) * cos(a))
end
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
boundaryfes = meshboundary(fes)
topl = selectelem(
fens,
boundaryfes,
box = [-Inf Inf -Inf Inf thickness thickness],
inflate = tolerance,
)
botl = selectelem(
fens,
boundaryfes,
box = [-Inf Inf -Inf Inf 0.0 0.0],
inflate = tolerance,
)
x0l = selectelem(
fens,
boundaryfes,
box = [0.0 0.0 -Inf Inf 0.0 thickness],
inflate = tolerance,
)
y0l = selectelem(
fens,
boundaryfes,
box = [-Inf Inf 0.0 0.0 0.0 thickness],
inflate = tolerance,
)
cyll = setdiff(1:count(boundaryfes), topl, botl, x0l, y0l)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
y0nl = selectnode(fens, box = [-Inf Inf 0 0 -Inf Inf], inflate = tolerance)
setebc!(u, y0nl, true, [1; 3], 0.0)
yL2nl = selectnode(fens, box = [-Inf Inf L / 2 L / 2 -Inf Inf], inflate = tolerance)
setebc!(u, yL2nl, true, [2], 0.0)
x0nl = selectnode(fens, box = [0 0 -Inf Inf -Inf Inf], inflate = tolerance)
setebc!(u, x0nl, true, [1], 0.0)
z0nl = selectnode(fens, box = [-Inf Inf -Inf Inf 0 0], inflate = tolerance)
setebc!(u, z0nl, true, [3], 0.0)
applyebc!(u)
numberdofs!(u)
loadnl = selectnode(fens; box = [0 0 L / 2 L / 2 -Inf Inf], inflate = tolerance)
nfemm =
FEMMBase(IntegDomain(FESetP1(reshape(loadnl, length(loadnl), 1)), PointRule()))
F = distribloads(
nfemm,
geom,
u,
ForceIntensity([0; 0; -1.0 / 4 / length(loadnl)]),
3,
)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K, F)
u0z = mean(u.values[loadnl, 3])
println("Deflection under the load: $(round((u0z / uzex)* 100000)/100000*100) %")
File = "pinchcyl_h20r_$(n)x$(nt).vtk"
vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
@async run(`"paraview.exe" $File`)
end
true
end # pinchcyl_h20r
function pinchcyl_h20()
let (n, nt) = (ref, 4)
fens, fes = H20block(90 / 360 * 2 * pi, L / 2, thickness, n, n, nt)
for i = 1:count(fens)
a = fens.xyz[i, 1]
y = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] .=
((R - thickness / 2 + z) * sin(a), y, (R - thickness / 2 + z) * cos(a))
end
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 3)), material)
boundaryfes = meshboundary(fes)
topl = selectelem(
fens,
boundaryfes,
box = [-Inf Inf -Inf Inf thickness thickness],
inflate = tolerance,
)
botl = selectelem(
fens,
boundaryfes,
box = [-Inf Inf -Inf Inf 0.0 0.0],
inflate = tolerance,
)
x0l = selectelem(
fens,
boundaryfes,
box = [0.0 0.0 -Inf Inf 0.0 thickness],
inflate = tolerance,
)
y0l = selectelem(
fens,
boundaryfes,
box = [-Inf Inf 0.0 0.0 0.0 thickness],
inflate = tolerance,
)
cyll = setdiff(1:count(boundaryfes), topl, botl, x0l, y0l)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
y0nl = selectnode(fens, box = [-Inf Inf 0 0 -Inf Inf], inflate = tolerance)
setebc!(u, y0nl, true, [1; 3], 0.0)
yL2nl = selectnode(fens, box = [-Inf Inf L / 2 L / 2 -Inf Inf], inflate = tolerance)
setebc!(u, yL2nl, true, [2], 0.0)
x0nl = selectnode(fens, box = [0 0 -Inf Inf -Inf Inf], inflate = tolerance)
setebc!(u, x0nl, true, [1], 0.0)
z0nl = selectnode(fens, box = [-Inf Inf -Inf Inf 0 0], inflate = tolerance)
setebc!(u, z0nl, true, [3], 0.0)
applyebc!(u)
numberdofs!(u)
loadnl = selectnode(fens; box = [0 0 L / 2 L / 2 -Inf Inf], inflate = tolerance)
nfemm =
FEMMBase(IntegDomain(FESetP1(reshape(loadnl, length(loadnl), 1)), PointRule()))
F = distribloads(
nfemm,
geom,
u,
ForceIntensity([0; 0; -1.0 / 4 / length(loadnl)]),
3,
)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K, F)
u0z = mean(u.values[loadnl, 3])
println("Deflection under the load: $(round((u0z / uzex)* 100000)/100000*100) %")
File = "pinchcyl_h20_$(n)x$(nt).vtk"
vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
@async run(`"paraview.exe" $File`)
end
true
end # pinchcyl_h20
function pinchcyl_t10_ms()
let (n, nt) = (ref, 4)
fens, fes = T10block(90 / 360 * 2 * pi, L / 2, thickness, n, n, nt)
for i = 1:count(fens)
a = fens.xyz[i, 1]
y = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] .=
((R - thickness / 2 + z) * sin(a), y, (R - thickness / 2 + z) * cos(a))
end
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMST10(MR, IntegDomain(fes, TetRule(4)), material)
boundaryfes = meshboundary(fes)
topl = selectelem(
fens,
boundaryfes,
box = [-Inf Inf -Inf Inf thickness thickness],
inflate = tolerance,
)
botl = selectelem(
fens,
boundaryfes,
box = [-Inf Inf -Inf Inf 0.0 0.0],
inflate = tolerance,
)
x0l = selectelem(
fens,
boundaryfes,
box = [0.0 0.0 -Inf Inf 0.0 thickness],
inflate = tolerance,
)
y0l = selectelem(
fens,
boundaryfes,
box = [-Inf Inf 0.0 0.0 0.0 thickness],
inflate = tolerance,
)
cyll = setdiff(1:count(boundaryfes), topl, botl, x0l, y0l)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
y0nl = selectnode(fens, box = [-Inf Inf 0 0 -Inf Inf], inflate = tolerance)
setebc!(u, y0nl, true, [1; 3], 0.0)
yL2nl = selectnode(fens, box = [-Inf Inf L / 2 L / 2 -Inf Inf], inflate = tolerance)
setebc!(u, yL2nl, true, [2], 0.0)
x0nl = selectnode(fens, box = [0 0 -Inf Inf -Inf Inf], inflate = tolerance)
setebc!(u, x0nl, true, [1], 0.0)
z0nl = selectnode(fens, box = [-Inf Inf -Inf Inf 0 0], inflate = tolerance)
setebc!(u, z0nl, true, [3], 0.0)
applyebc!(u)
numberdofs!(u)
loadnl = selectnode(fens; box = [0 0 L / 2 L / 2 -Inf Inf], inflate = tolerance)
nfemm =
FEMMBase(IntegDomain(FESetP1(reshape(loadnl, length(loadnl), 1)), PointRule()))
F = distribloads(
nfemm,
geom,
u,
ForceIntensity([0; 0; -1.0 / 4 / length(loadnl)]),
3,
)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K, F)
u0z = mean(u.values[loadnl, 3])
println("Deflection under the load: $(round((u0z / uzex)* 100000)/100000*100) %")
File = "pinchcyl_t10_ms_$(n)x$(nt).vtk"
vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
@async run(`"paraview.exe" $File`)
end
true
end # pinchcyl_t10_ms
function pinchcyl_t10()
let (n, nt) = (ref, 4)
fens, fes = T10block(90 / 360 * 2 * pi, L / 2, thickness, n, n, nt)
for i = 1:count(fens)
a = fens.xyz[i, 1]
y = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] .=
((R - thickness / 2 + z) * sin(a), y, (R - thickness / 2 + z) * cos(a))
end
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinear(MR, IntegDomain(fes, TetRule(4)), material)
boundaryfes = meshboundary(fes)
topl = selectelem(
fens,
boundaryfes,
box = [-Inf Inf -Inf Inf thickness thickness],
inflate = tolerance,
)
botl = selectelem(
fens,
boundaryfes,
box = [-Inf Inf -Inf Inf 0.0 0.0],
inflate = tolerance,
)
x0l = selectelem(
fens,
boundaryfes,
box = [0.0 0.0 -Inf Inf 0.0 thickness],
inflate = tolerance,
)
y0l = selectelem(
fens,
boundaryfes,
box = [-Inf Inf 0.0 0.0 0.0 thickness],
inflate = tolerance,
)
cyll = setdiff(1:count(boundaryfes), topl, botl, x0l, y0l)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
y0nl = selectnode(fens, box = [-Inf Inf 0 0 -Inf Inf], inflate = tolerance)
setebc!(u, y0nl, true, [1; 3], 0.0)
yL2nl = selectnode(fens, box = [-Inf Inf L / 2 L / 2 -Inf Inf], inflate = tolerance)
setebc!(u, yL2nl, true, [2], 0.0)
x0nl = selectnode(fens, box = [0 0 -Inf Inf -Inf Inf], inflate = tolerance)
setebc!(u, x0nl, true, [1], 0.0)
z0nl = selectnode(fens, box = [-Inf Inf -Inf Inf 0 0], inflate = tolerance)
setebc!(u, z0nl, true, [3], 0.0)
applyebc!(u)
numberdofs!(u)
loadnl = selectnode(fens; box = [0 0 L / 2 L / 2 -Inf Inf], inflate = tolerance)
nfemm =
FEMMBase(IntegDomain(FESetP1(reshape(loadnl, length(loadnl), 1)), PointRule()))
F = distribloads(
nfemm,
geom,
u,
ForceIntensity([0; 0; -1.0 / 4 / length(loadnl)]),
3,
)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K, F)
u0z = mean(u.values[loadnl, 3])
println("Deflection under the load: $(round((u0z / uzex)* 100000)/100000*100) %")
File = "pinchcyl_t10_$(n)x$(nt).vtk"
vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
@async run(`"paraview.exe" $File`)
end
true
end # pinchcyl_t10
# true
# end # twisted_beam_export
function allrun()
println("#####################################################")
println("# pinchcyl_h8_full ")
pinchcyl_h8_full()
println("#####################################################")
println("# pinchcyl_h8_ms ")
pinchcyl_h8_ms()
println("#####################################################")
println("# pinchcyl_t10_ms ")
pinchcyl_t10_ms()
println("#####################################################")
println("# pinchcyl_h20r ")
pinchcyl_h20r()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 74080 | module plate_w_hole_examples
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtools.MeshExportModule
using LinearAlgebra: norm
using SparseArrays: cholesky
using Statistics: mean
function plate_w_hole_H20_stress()
E = 2.4 * phun("MEGA*PA")# 210e3 MPa
nu = 0.3
Re = 0.3 * phun("M") # outer radius
Ri = 0.1 * phun("M") # hole radius
H = 0.1 * phun("M") # thickness of the plate
nRadial, nCircumferential, nThickness = 6, 8, 1
sigma0 = 1 * phun("MEGA*PA")
function sigmaxx(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 * (
1 - Ri^2 / r^2 * (3 / 2 * cos(2 * th) + cos(4 * th)) +
3 / 2 * Ri^4 / r^4 * cos(4 * th)
)
end
function sigmayy(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 * (
Ri^2 / r^2 * (1 / 2 * cos(2 * th) - cos(4 * th)) +
3 / 2 * Ri^4 / r^4 * cos(4 * th)
)
end
function sigmaxy(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 * (
Ri^2 / r^2 * (1 / 2 * sin(2 * th) + sin(4 * th)) -
3 / 2 * Ri^4 / r^4 * sin(4 * th)
)
end
function sigmarr(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 / 2 * (1 - Ri^2 / r^2) +
sigma0 / 2 * (1 - 4 * Ri^2 / r^2 + 3 * Ri^4 / r^4) * cos(2 * th)
end
function sigmatt(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 / 2 * (1 + Ri^2 / r^2) -
sigma0 / 2 * (1 + 3 * Ri^4 / r^4) * cos(2 * th)
end
function sigmart(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 / 2 * (1 + 2 * Ri^2 / r^2 - 3 * Ri^4 / r^4) * sin(2 * th)
end
convergencestudy = FDataDict[]
for ref = 0:1:2
println("ref = $(ref)")
# Thickness = H
Thickness = H / 2^ref
tolerance = Thickness / 2^ref / 1000.0 # Geometrical tolerance
fens, fes = H20block(
1.0,
pi / 2,
Thickness,
2^ref * nRadial,
2^ref * nCircumferential,
2^ref * nThickness,
)
bdryfes = meshboundary(fes)
icl = selectelem(
fens,
bdryfes,
box = [1.0, 1.0, 0.0, pi / 2, 0.0, Thickness],
inflate = tolerance,
)
for i = 1:count(fens)
t = fens.xyz[i, 1]
a = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] =
[(t * Re + (1 - t) * Ri) * cos(a), (t * Re + (1 - t) * Ri) * sin(a), z]
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l1 = selectnode(
fens;
box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(
fens;
box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 1, 0.0)
# Plane-stress constraint: assume the plane z=0 is the plane of symmetry of the plate
l1 = selectnode(fens; box = [0.0, Inf, 0.0, Inf, 0.0, 0.0], inflate = tolerance)
setebc!(u, l1, true, 3, 0.0)
# If this was enabled, the plane-strain constraint would be enforced.
# l1 =selectnode(fens; box=[0.0, Inf, 0.0, Inf, Thickness, Thickness], inflate = tolerance)
# setebc!(u,l1,true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
el1femm = FEMMBase(IntegDomain(subset(bdryfes, icl), GaussRule(2, 3)))
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
) where {T}
local r = sqrt(XYZ[1]^2 + XYZ[2]^2)
nx = XYZ[1] / r
ny = XYZ[2] / r
forceout[1] = sigmarr(XYZ) * nx - sigmart(XYZ) * ny
forceout[2] = sigmarr(XYZ) * ny + sigmart(XYZ) * nx
forceout[3] = 0.0
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(el1femm, geom, u, fi, 2)
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (F2)
scattersysvec!(u, U[:])
stressfields = elemfieldfromintegpoints(femm, geom, u, :Cauchy, collect(1:6))
push!(
convergencestudy,
FDataDict(
"elementsize" => 1.0 / 2^ref,
"fens" => fens,
"fes" => fes,
"geom" => geom,
"u" => u,
"femm" => femm,
"stressfields" => [stressfields],
"tolerance" => tolerance,
),
)
end # for ref in
# File = "mplate_w_hole_H20m_stress"
# open(File * ".jls", "w") do file
# serialize(file, convergencestudy)
# end
end # plate_w_hole_H20_stress
function plate_w_hole_MSH8_convergence()
E = 2.4 * phun("MEGA*PA")# 210e3 MPa
nu = 0.49995
Re = 0.3 * phun("M") # outer radius
Ri = 0.1 * phun("M") # hole radius
H = 0.1 * phun("M") # thickness of the plate
nRadial, nCircumferential = 3, 5
sigma0 = 1 * phun("MEGA*PA")
function sigmaxx(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 * (
1 - Ri^2 / r^2 * (3 / 2 * cos(2 * th) + cos(4 * th)) +
3 / 2 * Ri^4 / r^4 * cos(4 * th)
)
end
function sigmayy(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 * (
Ri^2 / r^2 * (1 / 2 * cos(2 * th) - cos(4 * th)) +
3 / 2 * Ri^4 / r^4 * cos(4 * th)
)
end
function sigmaxy(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 * (
Ri^2 / r^2 * (1 / 2 * sin(2 * th) + sin(4 * th)) -
3 / 2 * Ri^4 / r^4 * sin(4 * th)
)
end
function sigmarr(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 / 2 * (1 - Ri^2 / r^2) +
sigma0 / 2 * (1 - 4 * Ri^2 / r^2 + 3 * Ri^4 / r^4) * cos(2 * th)
end
function sigmatt(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 / 2 * (1 + Ri^2 / r^2) -
sigma0 / 2 * (1 + 3 * Ri^4 / r^4) * cos(2 * th)
end
function sigmart(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 / 2 * (1 + 2 * Ri^2 / r^2 - 3 * Ri^4 / r^4) * sin(2 * th)
end
sigxderrs = Dict{Symbol,FFltVec}()
sigyderrs = Dict{Symbol,FFltVec}()
numelements = []
numnodes = []
for extrap in [:extraptrend :extrapmean]
sigxderrs[extrap] = FFltVec[]
sigyderrs[extrap] = FFltVec[]
numelements = []
numnodes = []
for ref = 0:1:2
# Thickness = H
Thickness = H / 2^ref
tolerance = Thickness / 2^ref / 1000.0 # Geometrical tolerance
fens, fes = H8block(
1.0,
pi / 2,
Thickness,
2^ref * nRadial,
2^ref * nCircumferential,
1,
)
bdryfes = meshboundary(fes)
icl = selectelem(
fens,
bdryfes,
box = [1.0, 1.0, 0.0, pi / 2, 0.0, Thickness],
inflate = tolerance,
)
for i = 1:count(fens)
t = fens.xyz[i, 1]
a = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] =
[(t * Re + (1 - t) * Ri) * cos(a), (t * Re + (1 - t) * Ri) * sin(a), z]
end
# File = "a.vtk"
# vtkexportmesh(File, fes.conn, fens.xyz,
# FinEtools.MeshExportModule.H8)
# @async run(`"paraview.exe" $File`)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l1 = selectnode(
fens;
box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(
fens;
box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 1, 0.0)
# Plane-stress constraint: assume the plane z=0 is the plane of symmetry of the plate
l1 = selectnode(fens; box = [0.0, Inf, 0.0, Inf, 0.0, 0.0], inflate = tolerance)
setebc!(u, l1, true, 3, 0.0)
# If this was enabled, the plane-strain constraint would be enforced.
# l1 =selectnode(fens; box=[0.0, Inf, 0.0, Inf, Thickness, Thickness], inflate = tolerance)
# setebc!(u,l1,true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
el1femm = FEMMBase(IntegDomain(subset(bdryfes, icl), GaussRule(2, 2)))
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
) where {T}
local r = sqrt(XYZ[1]^2 + XYZ[2]^2)
nx = XYZ[1] / r
ny = XYZ[2] / r
# local sx, sy, txy
# sx, sy, txy = sigmaxx(XYZ), sigmayy(XYZ), sigmaxy(XYZ)
# sn = sx * nx^2 + sy * ny^2 + 2 * nx * ny * txy
# tn = -(sx - sy) * nx * ny + (nx^2 - ny^2) * txy
# forceout[1] = sn * nx - tn * ny
# forceout[2] = sn * ny + tn * nx
# forceout[3] = 0.0
forceout[1] = sigmarr(XYZ) * nx - sigmart(XYZ) * ny
forceout[2] = sigmarr(XYZ) * ny + sigmart(XYZ) * nx
forceout[3] = 0.0
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(el1femm, geom, u, fi, 2)
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (F2)
scattersysvec!(u, U[:])
nlA = selectnode(
fens,
box = [Ri, Ri, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
nlB = selectnode(
fens,
box = [0.0, 0.0, Ri, Ri, 0.0, Thickness],
inflate = tolerance,
)
# thecorneru = zeros(FFlt,length(nlA),3)
# gathervalues_asmat!(u, thecorneru, nl);
# thecorneru = mean(thecorneru, 1)[1]/phun("mm")
# println("displacement = $(thecorneru) vs -0.10215 [MM]")
println("Extrapolation: $( extrap )--------------- ")
sigx = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
1;
nodevalmethod = :averaging,
reportat = extrap,
)
sigy = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = extrap,
)
sigyA = mean(sigy.values[nlA, 1], dims = 1)[1]
sigyAtrue = sigmatt([Ri, 0.0, 0.0])
println("sig_y@A =$(sigyA/phun("MPa")) vs $(sigyAtrue/phun("MPa")) [MPa]")
sigxB = mean(sigx.values[nlB, 1], dims = 1)[1]
sigxBtrue = sigmatt([0.0, Ri, 0.0])
println("sig_x@B =$(sigxB/phun("MPa")) vs $(sigxBtrue/phun("MPa")) [MPa]")
push!(numnodes, count(fens))
push!(numelements, count(fes))
push!(sigxderrs[extrap], abs(sigxB / sigxBtrue - 1.0))
push!(sigyderrs[extrap], abs(sigyA / sigyAtrue - 1.0))
# File = "a.vtk"
# vtkexportmesh(File, fes.conn, geom.values,
# FinEtools.MeshExportModule.H8; vectors=[("u", u.values)],
# scalars=[("sigmax", sigx.values/phun("MEGA*PA"))])
# @async run(`"paraview.exe" $File`)
end
end
File = "plate_w_hole_MSH8_convergence.CSV"
savecsv(
File,
numelements = vec(numelements),
numnodes = vec(numnodes),
sigxderrtrend = vec(sigxderrs[:extraptrend]),
sigxderrdefault = vec(sigxderrs[:extrapmean]),
sigyderrtrend = vec(sigyderrs[:extraptrend]),
sigyderrdefault = vec(sigyderrs[:extrapmean]),
)
end # plate_w_hole_MSH8_convergence
function plate_w_hole_MSH8_PE_convergence()
E = 2.4 * phun("MEGA*PA")# 210e3 MPa
nu = 0.49995
Re = 0.3 * phun("M") # outer radius
Ri = 0.1 * phun("M") # hole radius
H = 0.1 * phun("M") # thickness of the plate
nRadial, nCircumferential = 3, 5
sigma0 = 1 * phun("MEGA*PA")
function sigmaxx(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 * (
1 - Ri^2 / r^2 * (3 / 2 * cos(2 * th) + cos(4 * th)) +
3 / 2 * Ri^4 / r^4 * cos(4 * th)
)
end
function sigmayy(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 * (
Ri^2 / r^2 * (1 / 2 * cos(2 * th) - cos(4 * th)) +
3 / 2 * Ri^4 / r^4 * cos(4 * th)
)
end
function sigmaxy(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 * (
Ri^2 / r^2 * (1 / 2 * sin(2 * th) + sin(4 * th)) -
3 / 2 * Ri^4 / r^4 * sin(4 * th)
)
end
function sigmarr(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 / 2 * (1 - Ri^2 / r^2) +
sigma0 / 2 * (1 - 4 * Ri^2 / r^2 + 3 * Ri^4 / r^4) * cos(2 * th)
end
function sigmatt(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 / 2 * (1 + Ri^2 / r^2) -
sigma0 / 2 * (1 + 3 * Ri^4 / r^4) * cos(2 * th)
end
function sigmart(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 / 2 * (1 + 2 * Ri^2 / r^2 - 3 * Ri^4 / r^4) * sin(2 * th)
end
sigxderrs = Dict{Symbol,FFltVec}()
sigyderrs = Dict{Symbol,FFltVec}()
numelements = []
numnodes = []
for extrapolation in [:extraptrend :extrapmean]
sigxderrs[extrapolation] = FFltVec[]
sigyderrs[extrapolation] = FFltVec[]
numelements = []
numnodes = []
for ref = 0:1:2
# Thickness = H
Thickness = H / 2^ref
tolerance = Thickness / 2^ref / 1000.0 # Geometrical tolerance
fens, fes = H8block(
1.0,
pi / 2,
Thickness,
2^ref * nRadial,
2^ref * nCircumferential,
1,
)
bdryfes = meshboundary(fes)
icl = selectelem(
fens,
bdryfes,
box = [1.0, 1.0, 0.0, pi / 2, 0.0, Thickness],
inflate = tolerance,
)
for i = 1:count(fens)
t = fens.xyz[i, 1]
a = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] =
[(t * Re + (1 - t) * Ri) * cos(a), (t * Re + (1 - t) * Ri) * sin(a), z]
end
# File = "a.vtk"
# vtkexportmesh(File, fes.conn, fens.xyz,
# FinEtools.MeshExportModule.H8)
# @async run(`"paraview.exe" $File`)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l1 = selectnode(
fens;
box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(
fens;
box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 1, 0.0)
# Plane-stress constraint: assume the plane z=0 is the plane of symmetry of the plate
l1 = selectnode(fens; box = [0.0, Inf, 0.0, Inf, 0.0, 0.0], inflate = tolerance)
setebc!(u, l1, true, 3, 0.0)
# If this was enabled, the plane-strain constraint would be enforced.
l1 = selectnode(
fens;
box = [0.0, Inf, 0.0, Inf, Thickness, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
el1femm = FEMMBase(IntegDomain(subset(bdryfes, icl), GaussRule(2, 2)))
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
) where {T}
local r = sqrt(XYZ[1]^2 + XYZ[2]^2)
nx = XYZ[1] / r
ny = XYZ[2] / r
# local sx, sy, txy
# sx, sy, txy = sigmaxx(XYZ), sigmayy(XYZ), sigmaxy(XYZ)
# sn = sx * nx^2 + sy * ny^2 + 2 * nx * ny * txy
# tn = -(sx - sy) * nx * ny + (nx^2 - ny^2) * txy
# forceout[1] = sn * nx - tn * ny
# forceout[2] = sn * ny + tn * nx
# forceout[3] = 0.0
forceout[1] = sigmarr(XYZ) * nx - sigmart(XYZ) * ny
forceout[2] = sigmarr(XYZ) * ny + sigmart(XYZ) * nx
forceout[3] = 0.0
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(el1femm, geom, u, fi, 2)
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (F2)
scattersysvec!(u, U[:])
nlA = selectnode(
fens,
box = [Ri, Ri, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
nlB = selectnode(
fens,
box = [0.0, 0.0, Ri, Ri, 0.0, Thickness],
inflate = tolerance,
)
# thecorneru = zeros(FFlt,length(nlA),3)
# gathervalues_asmat!(u, thecorneru, nl);
# thecorneru = mean(thecorneru, 1)[1]/phun("mm")
# println("displacement = $(thecorneru) vs -0.10215 [MM]")
println("Extrapolation: $( extrapolation )")
sigx = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
1;
nodevalmethod = :averaging,
reportat = extrapolation,
)
sigy = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = extrapolation,
)
sigyA = mean(sigy.values[nlA, 1], dims = 1)[1]
sigyAtrue = sigmatt([Ri, 0.0, 0.0])
println("sig_y@A =$(sigyA/phun("MPa")) vs $(sigyAtrue/phun("MPa")) [MPa]")
sigxB = mean(sigx.values[nlB, 1], dims = 1)[1]
sigxBtrue = sigmatt([0.0, Ri, 0.0])
println("sig_x@B =$(sigxB/phun("MPa")) vs $(sigxBtrue/phun("MPa")) [MPa]")
push!(numnodes, count(fens))
push!(numelements, count(fes))
push!(sigxderrs[extrapolation], abs(sigxB / sigxBtrue - 1.0))
push!(sigyderrs[extrapolation], abs(sigyA / sigyAtrue - 1.0))
# File = "a.vtk"
# vtkexportmesh(File, fes.conn, geom.values,
# FinEtools.MeshExportModule.H8; vectors=[("u", u.values)],
# scalars=[("sigmax", sigx.values/phun("MEGA*PA"))])
# @async run(`"paraview.exe" $File`)
end
end
File = "plate_w_hole_PE_MSH8_convergence.CSV"
savecsv(
File,
numelements = vec(numelements),
numnodes = vec(numnodes),
sigxderrtrend = vec(sigxderrs[:extraptrend]),
sigxderrdefault = vec(sigxderrs[:extrapmean]),
sigyderrtrend = vec(sigyderrs[:extraptrend]),
sigyderrdefault = vec(sigyderrs[:extrapmean]),
)
end # plate_w_hole_MSH8_PE_convergence
function plate_w_hole_MST10_convergence()
E = 2.4 * phun("MEGA*PA")# 210e3 MPa
nu = 0.49995
Re = 0.3 * phun("M") # outer radius
Ri = 0.1 * phun("M") # hole radius
H = 0.1 * phun("M") # thickness of the plate
nRadial, nCircumferential = 3, 5
sigma0 = 1 * phun("MEGA*PA")
function sigmaxx(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 * (
1 - Ri^2 / r^2 * (3 / 2 * cos(2 * th) + cos(4 * th)) +
3 / 2 * Ri^4 / r^4 * cos(4 * th)
)
end
function sigmayy(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 * (
Ri^2 / r^2 * (1 / 2 * cos(2 * th) - cos(4 * th)) +
3 / 2 * Ri^4 / r^4 * cos(4 * th)
)
end
function sigmaxy(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 * (
Ri^2 / r^2 * (1 / 2 * sin(2 * th) + sin(4 * th)) -
3 / 2 * Ri^4 / r^4 * sin(4 * th)
)
end
function sigmarr(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 / 2 * (1 - Ri^2 / r^2) +
sigma0 / 2 * (1 - 4 * Ri^2 / r^2 + 3 * Ri^4 / r^4) * cos(2 * th)
end
function sigmatt(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 / 2 * (1 + Ri^2 / r^2) -
sigma0 / 2 * (1 + 3 * Ri^4 / r^4) * cos(2 * th)
end
function sigmart(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 / 2 * (1 + 2 * Ri^2 / r^2 - 3 * Ri^4 / r^4) * sin(2 * th)
end
sigxderrs = Dict{Symbol,FFltVec}()
sigyderrs = Dict{Symbol,FFltVec}()
numelements = []
numnodes = []
for extrapolation in [:extraptrend :extrapmean]
sigxderrs[extrapolation] = FFltVec[]
sigyderrs[extrapolation] = FFltVec[]
numelements = []
numnodes = []
for ref = 0:1:3
# Thickness = H
Thickness = H / 2^ref
tolerance = Thickness / 2^ref / 1000.0 # Geometrical tolerance
fens, fes = T10block(
1.0,
pi / 2,
Thickness,
2^ref * nRadial,
2^ref * nCircumferential,
1,
)
bdryfes = meshboundary(fes)
icl = selectelem(
fens,
bdryfes,
box = [1.0, 1.0, 0.0, pi / 2, 0.0, Thickness],
inflate = tolerance,
)
for i = 1:count(fens)
t = fens.xyz[i, 1]
a = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] =
[(t * Re + (1 - t) * Ri) * cos(a), (t * Re + (1 - t) * Ri) * sin(a), z]
end
# File = "a.vtk"
# vtkexportmesh(File, fes.conn, fens.xyz,
# FinEtools.MeshExportModule.H8)
# @async run(`"paraview.exe" $File`)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l1 = selectnode(
fens;
box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(
fens;
box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 1, 0.0)
# Plane-stress constraint: assume the plane z=0 is the plane of symmetry of the plate
l1 = selectnode(fens; box = [0.0, Inf, 0.0, Inf, 0.0, 0.0], inflate = tolerance)
setebc!(u, l1, true, 3, 0.0)
# If this was enabled, the plane-strain constraint would be enforced.
# l1 =selectnode(fens; box=[0.0, Inf, 0.0, Inf, Thickness, Thickness], inflate = tolerance)
# setebc!(u,l1,true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
el1femm = FEMMBase(IntegDomain(subset(bdryfes, icl), TriRule(3)))
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
) where {T}
local r = sqrt(XYZ[1]^2 + XYZ[2]^2)
nx = XYZ[1] / r
ny = XYZ[2] / r
# local sx, sy, txy
# sx, sy, txy = sigmaxx(XYZ), sigmayy(XYZ), sigmaxy(XYZ)
# sn = sx * nx^2 + sy * ny^2 + 2 * nx * ny * txy
# tn = -(sx - sy) * nx * ny + (nx^2 - ny^2) * txy
# forceout[1] = sn * nx - tn * ny
# forceout[2] = sn * ny + tn * nx
# forceout[3] = 0.0
forceout[1] = sigmarr(XYZ) * nx - sigmart(XYZ) * ny
forceout[2] = sigmarr(XYZ) * ny + sigmart(XYZ) * nx
forceout[3] = 0.0
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(el1femm, geom, u, fi, 2)
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMST10(MR, IntegDomain(fes, TetRule(4)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (F2)
scattersysvec!(u, U[:])
nlA = selectnode(
fens,
box = [Ri, Ri, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
nlB = selectnode(
fens,
box = [0.0, 0.0, Ri, Ri, 0.0, Thickness],
inflate = tolerance,
)
# thecorneru = zeros(FFlt,length(nlA),3)
# gathervalues_asmat!(u, thecorneru, nl);
# thecorneru = mean(thecorneru, 1)[1]/phun("mm")
# println("displacement = $(thecorneru) vs -0.10215 [MM]")
println("Extrapolation: $( extrapolation )")
sigx = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
1;
nodevalmethod = :averaging,
reportat = extrapolation,
)
sigy = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = extrapolation,
)
sigyA = mean(sigy.values[nlA, 1], dims = 1)[1]
sigyAtrue = sigmatt([Ri, 0.0, 0.0])
println("sig_y@A =$(sigyA/phun("MPa")) vs $(sigyAtrue/phun("MPa")) [MPa]")
sigxB = mean(sigx.values[nlB, 1], dims = 1)[1]
sigxBtrue = sigmatt([0.0, Ri, 0.0])
println("sig_x@B =$(sigxB/phun("MPa")) vs $(sigxBtrue/phun("MPa")) [MPa]")
push!(numnodes, count(fens))
push!(numelements, count(fes))
push!(sigxderrs[extrapolation], abs(sigxB / sigxBtrue - 1.0))
push!(sigyderrs[extrapolation], abs(sigyA / sigyAtrue - 1.0))
# File = "a.vtk"
# vtkexportmesh(File, fes.conn, geom.values,
# FinEtools.MeshExportModule.H8; vectors=[("u", u.values)],
# scalars=[("sigmax", sigx.values/phun("MEGA*PA"))])
# @async run(`"paraview.exe" $File`)
end
end
File = "plate_w_hole_MST10_convergence.CSV"
savecsv(
File,
numelements = vec(numelements),
numnodes = vec(numnodes),
sigxderrtrend = vec(sigxderrs[:extraptrend]),
sigxderrdefault = vec(sigxderrs[:extrapmean]),
sigyderrtrend = vec(sigyderrs[:extraptrend]),
sigyderrdefault = vec(sigyderrs[:extrapmean]),
)
end # plate_w_hole_MST10_convergence
function plate_w_hole_MST10_PE_convergence()
E = 2.4 * phun("MEGA*PA")# 210e3 MPa
nu = 0.49995
Re = 0.3 * phun("M") # outer radius
Ri = 0.1 * phun("M") # hole radius
H = 0.1 * phun("M") # thickness of the plate
nRadial, nCircumferential = 3, 5
sigma0 = 1 * phun("MEGA*PA")
function sigmaxx(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 * (
1 - Ri^2 / r^2 * (3 / 2 * cos(2 * th) + cos(4 * th)) +
3 / 2 * Ri^4 / r^4 * cos(4 * th)
)
end
function sigmayy(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 * (
Ri^2 / r^2 * (1 / 2 * cos(2 * th) - cos(4 * th)) +
3 / 2 * Ri^4 / r^4 * cos(4 * th)
)
end
function sigmaxy(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 * (
Ri^2 / r^2 * (1 / 2 * sin(2 * th) + sin(4 * th)) -
3 / 2 * Ri^4 / r^4 * sin(4 * th)
)
end
function sigmarr(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 / 2 * (1 - Ri^2 / r^2) +
sigma0 / 2 * (1 - 4 * Ri^2 / r^2 + 3 * Ri^4 / r^4) * cos(2 * th)
end
function sigmatt(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 / 2 * (1 + Ri^2 / r^2) -
sigma0 / 2 * (1 + 3 * Ri^4 / r^4) * cos(2 * th)
end
function sigmart(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 / 2 * (1 + 2 * Ri^2 / r^2 - 3 * Ri^4 / r^4) * sin(2 * th)
end
sigxderrs = Dict{Symbol,FFltVec}()
sigyderrs = Dict{Symbol,FFltVec}()
numelements = []
numnodes = []
for extrapolation in [:extraptrend :extrapmean]
sigxderrs[extrapolation] = FFltVec[]
sigyderrs[extrapolation] = FFltVec[]
numelements = []
numnodes = []
for ref = 0:1:3
# Thickness = H
Thickness = H / 2^ref
tolerance = Thickness / 2^ref / 1000.0 # Geometrical tolerance
fens, fes = T10block(
1.0,
pi / 2,
Thickness,
2^ref * nRadial,
2^ref * nCircumferential,
1,
)
bdryfes = meshboundary(fes)
icl = selectelem(
fens,
bdryfes,
box = [1.0, 1.0, 0.0, pi / 2, 0.0, Thickness],
inflate = tolerance,
)
for i = 1:count(fens)
t = fens.xyz[i, 1]
a = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] =
[(t * Re + (1 - t) * Ri) * cos(a), (t * Re + (1 - t) * Ri) * sin(a), z]
end
# File = "a.vtk"
# vtkexportmesh(File, fes.conn, fens.xyz,
# FinEtools.MeshExportModule.H8)
# @async run(`"paraview.exe" $File`)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l1 = selectnode(
fens;
box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(
fens;
box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 1, 0.0)
# Plane-stress constraint: assume the plane z=0 is the plane of symmetry of the plate
l1 = selectnode(fens; box = [0.0, Inf, 0.0, Inf, 0.0, 0.0], inflate = tolerance)
setebc!(u, l1, true, 3, 0.0)
# If this was enabled, the plane-strain constraint would be enforced.
l1 = selectnode(
fens;
box = [0.0, Inf, 0.0, Inf, Thickness, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
el1femm = FEMMBase(IntegDomain(subset(bdryfes, icl), TriRule(3)))
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
) where {T}
local r = sqrt(XYZ[1]^2 + XYZ[2]^2)
nx = XYZ[1] / r
ny = XYZ[2] / r
# local sx, sy, txy
# sx, sy, txy = sigmaxx(XYZ), sigmayy(XYZ), sigmaxy(XYZ)
# sn = sx * nx^2 + sy * ny^2 + 2 * nx * ny * txy
# tn = -(sx - sy) * nx * ny + (nx^2 - ny^2) * txy
# forceout[1] = sn * nx - tn * ny
# forceout[2] = sn * ny + tn * nx
# forceout[3] = 0.0
forceout[1] = sigmarr(XYZ) * nx - sigmart(XYZ) * ny
forceout[2] = sigmarr(XYZ) * ny + sigmart(XYZ) * nx
forceout[3] = 0.0
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(el1femm, geom, u, fi, 2)
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMST10(MR, IntegDomain(fes, TetRule(4)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (F2)
scattersysvec!(u, U[:])
nlA = selectnode(
fens,
box = [Ri, Ri, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
nlB = selectnode(
fens,
box = [0.0, 0.0, Ri, Ri, 0.0, Thickness],
inflate = tolerance,
)
# thecorneru = zeros(FFlt,length(nlA),3)
# gathervalues_asmat!(u, thecorneru, nl);
# thecorneru = mean(thecorneru, 1)[1]/phun("mm")
# println("displacement = $(thecorneru) vs -0.10215 [MM]")
println("Extrapolation: $( extrapolation )")
sigx = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
1;
nodevalmethod = :averaging,
reportat = extrapolation,
)
sigy = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = extrapolation,
)
sigyA = mean(sigy.values[nlA, 1], dims = 1)[1]
sigyAtrue = sigmatt([Ri, 0.0, 0.0])
println("sig_y@A =$(sigyA/phun("MPa")) vs $(sigyAtrue/phun("MPa")) [MPa]")
sigxB = mean(sigx.values[nlB, 1], dims = 1)[1]
sigxBtrue = sigmatt([0.0, Ri, 0.0])
println("sig_x@B =$(sigxB/phun("MPa")) vs $(sigxBtrue/phun("MPa")) [MPa]")
push!(numnodes, count(fens))
push!(numelements, count(fes))
push!(sigxderrs[extrapolation], abs(sigxB / sigxBtrue - 1.0))
push!(sigyderrs[extrapolation], abs(sigyA / sigyAtrue - 1.0))
# File = "a.vtk"
# vtkexportmesh(File, fes.conn, geom.values,
# FinEtools.MeshExportModule.H8; vectors=[("u", u.values)],
# scalars=[("sigmax", sigx.values/phun("MEGA*PA"))])
# @async run(`"paraview.exe" $File`)
end
end
File = "plate_w_hole_PE_MST10_convergence.CSV"
savecsv(
File,
numelements = vec(numelements),
numnodes = vec(numnodes),
sigxderrtrend = vec(sigxderrs[:extraptrend]),
sigxderrdefault = vec(sigxderrs[:extrapmean]),
sigyderrtrend = vec(sigyderrs[:extraptrend]),
sigyderrdefault = vec(sigyderrs[:extrapmean]),
)
end # plate_w_hole_MST10_PE_convergence
function plate_w_hole_MST10_stress()
E = 2.4 * phun("MEGA*PA")# 210e3 MPa
nu = 0.3
Re = 0.3 * phun("M") # outer radius
Ri = 0.1 * phun("M") # hole radius
H = 0.1 * phun("M") # thickness of the plate
nRadial, nCircumferential, nThickness = 6, 8, 1
sigma0 = 1 * phun("MEGA*PA")
function sigmaxx(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 * (
1 - Ri^2 / r^2 * (3 / 2 * cos(2 * th) + cos(4 * th)) +
3 / 2 * Ri^4 / r^4 * cos(4 * th)
)
end
function sigmayy(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 * (
Ri^2 / r^2 * (1 / 2 * cos(2 * th) - cos(4 * th)) +
3 / 2 * Ri^4 / r^4 * cos(4 * th)
)
end
function sigmaxy(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 * (
Ri^2 / r^2 * (1 / 2 * sin(2 * th) + sin(4 * th)) -
3 / 2 * Ri^4 / r^4 * sin(4 * th)
)
end
function sigmarr(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 / 2 * (1 - Ri^2 / r^2) +
sigma0 / 2 * (1 - 4 * Ri^2 / r^2 + 3 * Ri^4 / r^4) * cos(2 * th)
end
function sigmatt(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 / 2 * (1 + Ri^2 / r^2) -
sigma0 / 2 * (1 + 3 * Ri^4 / r^4) * cos(2 * th)
end
function sigmart(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 / 2 * (1 + 2 * Ri^2 / r^2 - 3 * Ri^4 / r^4) * sin(2 * th)
end
convergencestudy = FDataDict[]
for ref = 0:1:2
println("ref = $(ref)")
# Thickness = H
Thickness = H / 2^ref
tolerance = Thickness / 2^ref / 1000.0 # Geometrical tolerance
fens, fes = T10block(
1.0,
pi / 2,
Thickness,
2^ref * nRadial,
2^ref * nCircumferential,
2^ref * nThickness,
)
bdryfes = meshboundary(fes)
icl = selectelem(
fens,
bdryfes,
box = [1.0, 1.0, 0.0, pi / 2, 0.0, Thickness],
inflate = tolerance,
)
for i = 1:count(fens)
t = fens.xyz[i, 1]
a = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] =
[(t * Re + (1 - t) * Ri) * cos(a), (t * Re + (1 - t) * Ri) * sin(a), z]
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l1 = selectnode(
fens;
box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(
fens;
box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 1, 0.0)
# Plane-stress constraint: assume the plane z=0 is the plane of symmetry of the plate
l1 = selectnode(fens; box = [0.0, Inf, 0.0, Inf, 0.0, 0.0], inflate = tolerance)
setebc!(u, l1, true, 3, 0.0)
# If this was enabled, the plane-strain constraint would be enforced.
# l1 =selectnode(fens; box=[0.0, Inf, 0.0, Inf, Thickness, Thickness], inflate = tolerance)
# setebc!(u,l1,true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
el1femm = FEMMBase(IntegDomain(subset(bdryfes, icl), TriRule(3)))
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
) where {T}
local r = sqrt(XYZ[1]^2 + XYZ[2]^2)
nx = XYZ[1] / r
ny = XYZ[2] / r
forceout[1] = sigmarr(XYZ) * nx - sigmart(XYZ) * ny
forceout[2] = sigmarr(XYZ) * ny + sigmart(XYZ) * nx
forceout[3] = 0.0
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(el1femm, geom, u, fi, 2)
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMST10(MR, IntegDomain(fes, TetRule(4)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (F2)
scattersysvec!(u, U[:])
stressfields = elemfieldfromintegpoints(femm, geom, u, :Cauchy, collect(1:6))
push!(
convergencestudy,
FDataDict(
"elementsize" => 1.0 / 2^ref,
"fens" => fens,
"fes" => fes,
"geom" => geom,
"u" => u,
"femm" => femm,
"stressfields" => [stressfields],
"tolerance" => tolerance,
),
)
end # for ref in
# File = "mplate_w_hole_MST10m_stress"
# open(File * ".jls", "w") do file
# serialize(file, convergencestudy)
# end
end # plate_w_hole_MST10_stress
function plate_w_hole_RECT_H20_convergence()
E = 210000 * phun("MEGA*PA")# 210e3 MPa
nu = 0.3
Ri = 0.15 * phun("M") # hole radius
Re = 2 * Ri # outer radius
H = 0.01 * phun("M") # thickness of the plate
nRadial, nCircumferential = 6, 3
sigma0 = 1 * phun("MEGA*PA")
function sigmaxx(x)
local r = norm(vec(x[1:2]))
local th = atan(x[2], x[1])
return sigma0 * (
1 - Ri^2 / r^2 * (3 / 2 * cos(2 * th) + cos(4 * th)) +
3 / 2 * Ri^4 / r^4 * cos(4 * th)
)
end
function sigmayy(x)
local r = norm(vec(x[1:2]))
local th = atan(x[2], x[1])
return -sigma0 * (
Ri^2 / r^2 * (1 / 2 * cos(2 * th) - cos(4 * th)) +
3 / 2 * Ri^4 / r^4 * cos(4 * th)
)
end
function sigmaxy(x)
local r = norm(vec(x[1:2]))
local th = atan(x[2], x[1])
return -sigma0 * (
Ri^2 / r^2 * (1 / 2 * sin(2 * th) + sin(4 * th)) -
3 / 2 * Ri^4 / r^4 * sin(4 * th)
)
end
function sigmarr(x)
local r = norm(vec(x[1:2]))
local th = atan(x[2], x[1])
return sigma0 / 2 * (1 - Ri^2 / r^2) +
sigma0 / 2 * (1 - 4 * Ri^2 / r^2 + 3 * Ri^4 / r^4) * cos(2 * th)
end
function sigmatt(x)
local r = norm(vec(x[1:2]))
local th = atan(x[2], x[1])
return sigma0 / 2 * (1 + Ri^2 / r^2) -
sigma0 / 2 * (1 + 3 * Ri^4 / r^4) * cos(2 * th)
end
function sigmart(x)
local r = norm(vec(x[1:2]))
local th = atan(x[2], x[1])
return -sigma0 / 2 * (1 + 2 * Ri^2 / r^2 - 3 * Ri^4 / r^4) * sin(2 * th)
end
sigyderrs = Dict{Symbol,FFltVec}()
nelems = []
for extrapolation in [:meanonly]
sigyderrs[extrapolation] = FFltVec[]
nelems = []
for ref in [1]
Thickness = H
# Thickness = H/2^ref
tolerance = Thickness / 2^ref / 1000.0 # Geometrical tolerance
fens, fes = H8elliphole(
Ri,
Ri,
Re,
Re,
Thickness,
2^ref * nCircumferential,
2^ref * nCircumferential,
2^ref * nRadial,
1,
)
fens, fes = H8toH20(fens, fes)
# File = "a.vtk"
# vtkexportmesh(File, fes.conn, fens.xyz,
# FinEtools.MeshExportModule.H20)
# @async run(`"paraview.cexe" $File`)
println("My mesh=>$((count(fens), count(fes)))")
#
# output = import_ABAQUS("plane_w_hole_m_debug.inp")
# fens1,fes1 = output["fens"], output["fesets"][1]
# println("Matlab mesh=>$((count(fens1), count(fes1[1])))")
#
# fens3, newfes1, fes2 = mergemeshes(fens,fes, fens1,fes1[1], tolerance)
# fes3 = cat(2, newfes1)
# println("Merged mesh=>$((count(fens3), count(fes3)))")
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l1 = selectnode(
fens;
box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(
fens;
box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 1, 0.0)
l1 = selectnode(fens; box = [0.0, Inf, 0.0, Inf, 0.0, 0.0], inflate = tolerance)
setebc!(u, l1, true, 3, 0.0)
# l1 =selectnode(fens; box=[0.0, Inf, 0.0, Inf, Thickness, Thickness], inflate = tolerance)
# setebc!(u,l1,true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
bdryfes = meshboundary(fes)
# ixl = selectelem(fens, bdryfes, plane=[1.0, 0.0, 0.0, Re], thickness=tolerance);
ixl = selectelem(
fens,
bdryfes,
box = [Re, Re, -Inf, +Inf, -Inf, +Inf],
inflate = tolerance,
)
elxfemm = FEMMBase(IntegDomain(subset(bdryfes, ixl), GaussRule(2, 2)))
function pfunx(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
) where {T}
forceout[1] = sigmaxx(XYZ)
forceout[2] = sigmaxy(XYZ)
forceout[3] = 0.0
return forceout
end
fi = ForceIntensity(Float64, 3, pfunx)
Fx = distribloads(elxfemm, geom, u, fi, 2)
# iyl = selectelem(fens, bdryfes, plane=[0.0, 1.0, 0.0, Re], thickness=tolerance);
iyl = selectelem(
fens,
bdryfes,
box = [-Inf, +Inf, Re, Re, -Inf, +Inf],
inflate = tolerance,
)
elyfemm = FEMMBase(IntegDomain(subset(bdryfes, iyl), GaussRule(2, 2)))
function pfuny(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
) where {T}
forceout[1] = sigmaxy(XYZ)
forceout[2] = sigmayy(XYZ)
forceout[3] = 0.0
return forceout
end
fi = ForceIntensity(Float64, 3, pfuny)
Fy = distribloads(elyfemm, geom, u, fi, 2)
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (Fx + Fy)
scattersysvec!(u, U[:])
println("oof load = $(norm(Fx + Fy, 2))")
nlA = selectnode(fens, box = [Ri, Ri, 0.0, 0.0, 0.0, 00.0], inflate = tolerance)
pointu = zeros(FFlt, length(nlA), 3)
gathervalues_asmat!(u, pointu, nlA)
println("disp@A = $(pointu/phun("mm")) [MM]")
nlB = selectnode(fens, box = [0.0, 0.0, Ri, Ri, 0.0, 0.0], inflate = tolerance)
pointu = zeros(FFlt, length(nlB), 3)
gathervalues_asmat!(u, pointu, nlB)
println("disp@B = $(pointu/phun("mm")) [MM]")
nlC = selectnode(
fens,
box = [Re, Re, Re, Re, Thickness, Thickness],
inflate = tolerance,
)
pointu = zeros(FFlt, length(nlC), 3)
gathervalues_asmat!(u, pointu, nlC)
println("disp@C = $(pointu/phun("mm")) [MM]")
nlAallz = selectnode(
fens,
box = [Ri, Ri, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
nlBallz = selectnode(
fens,
box = [0.0, 0.0, Ri, Ri, 0.0, Thickness],
inflate = tolerance,
)
sigx = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
1;
nodevalmethod = :invdistance,
reportat = extrapolation,
)
sigy = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :invdistance,
reportat = extrapolation,
)
sigyA = mean(sigy.values[nlAallz, 1], dims = 1)[1]
sigyAtrue = sigmayy([Ri, 0.0, 0.0])
println("sig_y@A =$(sigyA/phun("MPa")) vs $(sigyAtrue/phun("MPa")) [MPa]")
sigxB = mean(sigx.values[nlBallz, 1], dims = 1)[1]
sigxBtrue = sigmaxx([0.0, Ri, 0.0])
println("sig_x@B =$(sigxB/phun("MPa")) vs $(sigxBtrue/phun("MPa")) [MPa]")
# println("$extrapolation, $(count(fes)), $(sigyd/phun("MPa"))")
# push!(nelems, count(fes))
# push!(sigyderrs[extrapolation], abs(sigyd/sigma_yD - 1.0))
File = "a.vtk"
vtkexportmesh(
File,
fes.conn,
geom.values,
FinEtools.MeshExportModule.H20;
vectors = [("u", u.values)],
scalars = [
("sigmax", sigx.values / phun("MEGA*PA")),
("sigmay", sigy.values / phun("MEGA*PA")),
],
)
@async run(`"paraview.exe" $File`)
end
end
# df = DataFrame(nelems=vec(nelems),
# sigyderrtrend=vec(sigyderrs[:extraptrend]),
# sigyderrdefault=vec(sigyderrs[:extrapmean]))
# File = "LE1NAFEMS_MSH8_convergence.CSV"
# CSV.write(File, df)
# @async run(`"paraview.exe" $File`)
end # plate_w_hole_RECT_H20_convergence
function plate_w_hole_RECT_MSH8_convergence()
E = 210000 * phun("MEGA*PA")# 210e3 MPa
nu = 0.3
Ri = 0.1 * phun("M") # hole radius
Re = 2 * Ri # outer radius
H = 0.01 * phun("M") # thickness of the plate
nRadial, nCircumferential = 6, 3
sigma0 = 1 * phun("MEGA*PA")
function sigmaxx(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 * (
1 - Ri^2 / r^2 * (3 / 2 * cos(2 * th) + cos(4 * th)) +
3 / 2 * Ri^4 / r^4 * cos(4 * th)
)
end
function sigmayy(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 * (
Ri^2 / r^2 * (1 / 2 * cos(2 * th) - cos(4 * th)) +
3 / 2 * Ri^4 / r^4 * cos(4 * th)
)
end
function sigmaxy(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 * (
Ri^2 / r^2 * (1 / 2 * sin(2 * th) + sin(4 * th)) -
3 / 2 * Ri^4 / r^4 * sin(4 * th)
)
end
function sigmarr(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 / 2 * (1 - Ri^2 / r^2) +
sigma0 / 2 * (1 - 4 * Ri^2 / r^2 + 3 * Ri^4 / r^4) * cos(2 * th)
end
function sigmatt(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 / 2 * (1 + Ri^2 / r^2) -
sigma0 / 2 * (1 + 3 * Ri^4 / r^4) * cos(2 * th)
end
function sigmart(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 / 2 * (1 + 2 * Ri^2 / r^2 - 3 * Ri^4 / r^4) * sin(2 * th)
end
sigyderrs = Dict{Symbol,FFltVec}()
nelems = []
for extrapolation in [:extraptrend :extrapmean]
sigyderrs[extrapolation] = FFltVec[]
nelems = []
for ref in [2]
# Thickness = H
Thickness = H / 2^ref
tolerance = Thickness / 2^ref / 1000.0 # Geometrical tolerance
fens, fes = H8elliphole(
Ri,
Ri,
Re,
Re,
Thickness,
2^ref * nCircumferential,
2^ref * nCircumferential,
2^ref * nRadial,
1,
)
# File = "a.vtk"
# vtkexportmesh(File, fes.conn, fens.xyz,
# FinEtools.MeshExportModule.H8)
# @async run(`"paraview.exe" $File`)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l1 = selectnode(
fens;
box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(
fens;
box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 1, 0.0)
l1 = selectnode(fens; box = [0.0, Inf, 0.0, Inf, 0.0, 0.0], inflate = tolerance)
setebc!(u, l1, true, 3, 0.0)
# l1 =selectnode(fens; box=[0.0, Inf, 0.0, Inf, Thickness, Thickness], inflate = tolerance)
# setebc!(u,l1,true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
bdryfes = meshboundary(fes)
ixl = selectelem(
fens,
bdryfes,
plane = [1.0, 0.0, 0.0, Re],
thickness = tolerance,
)
elxfemm = FEMMBase(IntegDomain(subset(bdryfes, ixl), GaussRule(2, 2)))
function pfunx(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
) where {T}
forceout[1] = sigmaxx(XYZ)
forceout[2] = sigmaxy(XYZ)
forceout[3] = 0.0
return forceout
end
fi = ForceIntensity(Float64, 3, pfunx)
Fx = distribloads(elxfemm, geom, u, fi, 2)
iyl = selectelem(
fens,
bdryfes,
plane = [0.0, 1.0, 0.0, Re],
thickness = tolerance,
)
elyfemm = FEMMBase(IntegDomain(subset(bdryfes, iyl), GaussRule(2, 2)))
function pfuny(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
) where {T}
forceout[1] = -sigmaxy(XYZ)
forceout[2] = sigmayy(XYZ)
forceout[3] = 0.0
return forceout
end
fi = ForceIntensity(Float64, 3, pfuny)
Fy = distribloads(elyfemm, geom, u, fi, 2)
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (Fx + Fy)
scattersysvec!(u, U[:])
nlA = selectnode(
fens,
box = [Ri, Ri, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
nlB = selectnode(
fens,
box = [0.0, 0.0, Ri, Ri, 0.0, Thickness],
inflate = tolerance,
)
# thecorneru = zeros(FFlt,length(nlA),3)
# gathervalues_asmat!(u, thecorneru, nl);
# thecorneru = mean(thecorneru, 1)[1]/phun("mm")
# println("displacement = $(thecorneru) vs -0.10215 [MM]")
println("Extrapolation: $( extrapolation )")
sigx = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
1;
nodevalmethod = :averaging,
reportat = extrapolation,
)
sigy = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = extrapolation,
)
sigyA = mean(sigy.values[nlA, 1], dims = 1)[1]
sigyAtrue = sigmatt([Ri, 0.0, 0.0])
println("sig_y@A =$(sigyA/phun("MPa")) vs $(sigyAtrue/phun("MPa")) [MPa]")
sigxB = mean(sigx.values[nlB, 1], dims = 1)[1]
sigxBtrue = sigmatt([0.0, Ri, 0.0])
println("sig_x@B =$(sigxB/phun("MPa")) vs $(sigxBtrue/phun("MPa")) [MPa]")
# println("$extrapolation, $(count(fes)), $(sigyd/phun("MPa"))")
# push!(nelems, count(fes))
# push!(sigyderrs[extrapolation], abs(sigyd/sigma_yD - 1.0))
File = "a.vtk"
vtkexportmesh(
File,
fes.conn,
geom.values,
FinEtools.MeshExportModule.H8;
vectors = [("u", u.values)],
scalars = [
("sigmax", sigx.values / phun("MEGA*PA")),
("sigmay", sigy.values / phun("MEGA*PA")),
],
)
@async run(`"paraview.exe" $File`)
end
end
# df = DataFrame(nelems=vec(nelems),
# sigyderrtrend=vec(sigyderrs[:extraptrend]),
# sigyderrdefault=vec(sigyderrs[:extrapmean]))
# File = "LE1NAFEMS_MSH8_convergence.CSV"
# CSV.write(File, df)
# @async run(`"paraview.exe" $File`)
end # plate_w_hole_RECT_MSH8_convergence
function plate_w_hole_T10_PE_convergence()
E = 2.4 * phun("MEGA*PA")# 210e3 MPa
nu = 0.49995
Re = 0.3 * phun("M") # outer radius
Ri = 0.1 * phun("M") # hole radius
H = 0.1 * phun("M") # thickness of the plate
nRadial, nCircumferential = 3, 5
sigma0 = 1 * phun("MEGA*PA")
function sigmaxx(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 * (
1 - Ri^2 / r^2 * (3 / 2 * cos(2 * th) + cos(4 * th)) +
3 / 2 * Ri^4 / r^4 * cos(4 * th)
)
end
function sigmayy(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 * (
Ri^2 / r^2 * (1 / 2 * cos(2 * th) - cos(4 * th)) +
3 / 2 * Ri^4 / r^4 * cos(4 * th)
)
end
function sigmaxy(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 * (
Ri^2 / r^2 * (1 / 2 * sin(2 * th) + sin(4 * th)) -
3 / 2 * Ri^4 / r^4 * sin(4 * th)
)
end
function sigmarr(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 / 2 * (1 - Ri^2 / r^2) +
sigma0 / 2 * (1 - 4 * Ri^2 / r^2 + 3 * Ri^4 / r^4) * cos(2 * th)
end
function sigmatt(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 / 2 * (1 + Ri^2 / r^2) -
sigma0 / 2 * (1 + 3 * Ri^4 / r^4) * cos(2 * th)
end
function sigmart(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 / 2 * (1 + 2 * Ri^2 / r^2 - 3 * Ri^4 / r^4) * sin(2 * th)
end
sigxderrs = Dict{Symbol,FFltVec}()
sigyderrs = Dict{Symbol,FFltVec}()
numelements = []
numnodes = []
for extrapolation in [:extraptrend :extrapmean]
sigxderrs[extrapolation] = FFltVec[]
sigyderrs[extrapolation] = FFltVec[]
numelements = []
numnodes = []
for ref = 0:1:2
# Thickness = H
Thickness = H / 2^ref
tolerance = Thickness / 2^ref / 1000.0 # Geometrical tolerance
fens, fes = T10block(
1.0,
pi / 2,
Thickness,
2^ref * nRadial,
2^ref * nCircumferential,
1,
)
bdryfes = meshboundary(fes)
icl = selectelem(
fens,
bdryfes,
box = [1.0, 1.0, 0.0, pi / 2, 0.0, Thickness],
inflate = tolerance,
)
for i = 1:count(fens)
t = fens.xyz[i, 1]
a = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] =
[(t * Re + (1 - t) * Ri) * cos(a), (t * Re + (1 - t) * Ri) * sin(a), z]
end
# File = "a.vtk"
# vtkexportmesh(File, fes.conn, fens.xyz,
# FinEtools.MeshExportModule.H8)
# @async run(`"paraview.exe" $File`)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l1 = selectnode(
fens;
box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(
fens;
box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 1, 0.0)
# Plane-stress constraint: assume the plane z=0 is the plane of symmetry of the plate
l1 = selectnode(fens; box = [0.0, Inf, 0.0, Inf, 0.0, 0.0], inflate = tolerance)
setebc!(u, l1, true, 3, 0.0)
# If this was enabled, the plane-strain constraint would be enforced.
l1 = selectnode(
fens;
box = [0.0, Inf, 0.0, Inf, Thickness, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
el1femm = FEMMBase(IntegDomain(subset(bdryfes, icl), TriRule(3)))
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
) where {T}
local r = sqrt(XYZ[1]^2 + XYZ[2]^2)
nx = XYZ[1] / r
ny = XYZ[2] / r
# local sx, sy, txy
# sx, sy, txy = sigmaxx(XYZ), sigmayy(XYZ), sigmaxy(XYZ)
# sn = sx * nx^2 + sy * ny^2 + 2 * nx * ny * txy
# tn = -(sx - sy) * nx * ny + (nx^2 - ny^2) * txy
# forceout[1] = sn * nx - tn * ny
# forceout[2] = sn * ny + tn * nx
# forceout[3] = 0.0
forceout[1] = sigmarr(XYZ) * nx - sigmart(XYZ) * ny
forceout[2] = sigmarr(XYZ) * ny + sigmart(XYZ) * nx
forceout[3] = 0.0
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(el1femm, geom, u, fi, 2)
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinear(MR, IntegDomain(fes, TetRule(4)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (F2)
scattersysvec!(u, U[:])
nlA = selectnode(
fens,
box = [Ri, Ri, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
nlB = selectnode(
fens,
box = [0.0, 0.0, Ri, Ri, 0.0, Thickness],
inflate = tolerance,
)
# thecorneru = zeros(FFlt,length(nlA),3)
# gathervalues_asmat!(u, thecorneru, nl);
# thecorneru = mean(thecorneru, 1)[1]/phun("mm")
# println("displacement = $(thecorneru) vs -0.10215 [MM]")
println("Extrapolation: $( extrapolation )")
sigx = fieldfromintegpoints(femm, geom, u, :Cauchy, 1)
sigy = fieldfromintegpoints(femm, geom, u, :Cauchy, 2)
sigyA = mean(sigy.values[nlA, 1], dims = 1)[1]
sigyAtrue = sigmatt([Ri, 0.0, 0.0])
println("sig_y@A =$(sigyA/phun("MPa")) vs $(sigyAtrue/phun("MPa")) [MPa]")
sigxB = mean(sigx.values[nlB, 1], dims = 1)[1]
sigxBtrue = sigmatt([0.0, Ri, 0.0])
println("sig_x@B =$(sigxB/phun("MPa")) vs $(sigxBtrue/phun("MPa")) [MPa]")
push!(numnodes, count(fens))
push!(numelements, count(fes))
push!(sigxderrs[extrapolation], abs(sigxB / sigxBtrue - 1.0))
push!(sigyderrs[extrapolation], abs(sigyA / sigyAtrue - 1.0))
# File = "a.vtk"
# vtkexportmesh(File, fes.conn, geom.values,
# FinEtools.MeshExportModule.H8; vectors=[("u", u.values)],
# scalars=[("sigmax", sigx.values/phun("MEGA*PA"))])
# @async run(`"paraview.exe" $File`)
end
end
File = "plate_w_hole_PE_T10_convergence.CSV"
savecsv(
File,
numelements = vec(numelements),
numnodes = vec(numnodes),
sigxderrtrend = vec(sigxderrs[:extraptrend]),
sigxderrdefault = vec(sigxderrs[:extrapmean]),
sigyderrtrend = vec(sigyderrs[:extraptrend]),
sigyderrdefault = vec(sigyderrs[:extrapmean]),
)
end # plate_w_hole_T10_PE_convergence
function plate_w_hole_T10_stress()
E = 2.4 * phun("MEGA*PA")# 210e3 MPa
nu = 0.3
Re = 0.3 * phun("M") # outer radius
Ri = 0.1 * phun("M") # hole radius
H = 0.1 * phun("M") # thickness of the plate
nRadial, nCircumferential, nThickness = 6, 8, 1
sigma0 = 1 * phun("MEGA*PA")
function sigmaxx(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 * (
1 - Ri^2 / r^2 * (3 / 2 * cos(2 * th) + cos(4 * th)) +
3 / 2 * Ri^4 / r^4 * cos(4 * th)
)
end
function sigmayy(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 * (
Ri^2 / r^2 * (1 / 2 * cos(2 * th) - cos(4 * th)) +
3 / 2 * Ri^4 / r^4 * cos(4 * th)
)
end
function sigmaxy(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 * (
Ri^2 / r^2 * (1 / 2 * sin(2 * th) + sin(4 * th)) -
3 / 2 * Ri^4 / r^4 * sin(4 * th)
)
end
function sigmarr(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 / 2 * (1 - Ri^2 / r^2) +
sigma0 / 2 * (1 - 4 * Ri^2 / r^2 + 3 * Ri^4 / r^4) * cos(2 * th)
end
function sigmatt(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 / 2 * (1 + Ri^2 / r^2) -
sigma0 / 2 * (1 + 3 * Ri^4 / r^4) * cos(2 * th)
end
function sigmart(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 / 2 * (1 + 2 * Ri^2 / r^2 - 3 * Ri^4 / r^4) * sin(2 * th)
end
convergencestudy = FDataDict[]
for ref = 0:1:2
println("ref = $(ref)")
# Thickness = H
Thickness = H / 2^ref
tolerance = Thickness / 2^ref / 1000.0 # Geometrical tolerance
fens, fes = T10block(
1.0,
pi / 2,
Thickness,
2^ref * nRadial,
2^ref * nCircumferential,
2^ref * nThickness,
)
bdryfes = meshboundary(fes)
icl = selectelem(
fens,
bdryfes,
box = [1.0, 1.0, 0.0, pi / 2, 0.0, Thickness],
inflate = tolerance,
)
for i = 1:count(fens)
t = fens.xyz[i, 1]
a = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] =
[(t * Re + (1 - t) * Ri) * cos(a), (t * Re + (1 - t) * Ri) * sin(a), z]
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l1 = selectnode(
fens;
box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(
fens;
box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 1, 0.0)
# Plane-stress constraint: assume the plane z=0 is the plane of symmetry of the plate
l1 = selectnode(fens; box = [0.0, Inf, 0.0, Inf, 0.0, 0.0], inflate = tolerance)
setebc!(u, l1, true, 3, 0.0)
# If this was enabled, the plane-strain constraint would be enforced.
# l1 =selectnode(fens; box=[0.0, Inf, 0.0, Inf, Thickness, Thickness], inflate = tolerance)
# setebc!(u,l1,true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
el1femm = FEMMBase(IntegDomain(subset(bdryfes, icl), TriRule(3)))
function pfun(
forceout::FVec{T},
XYZ::FFltMat,
tangents::FFltMat,
fe_label::FInt,
) where {T}
local r = sqrt(XYZ[1]^2 + XYZ[2]^2)
nx = XYZ[1] / r
ny = XYZ[2] / r
forceout[1] = sigmarr(XYZ) * nx - sigmart(XYZ) * ny
forceout[2] = sigmarr(XYZ) * ny + sigmart(XYZ) * nx
forceout[3] = 0.0
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(el1femm, geom, u, fi, 2)
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinear(MR, IntegDomain(fes, TetRule(4)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K = cholesky(K)
U = K \ (F2)
scattersysvec!(u, U[:])
stressfields = elemfieldfromintegpoints(femm, geom, u, :Cauchy, collect(1:6))
push!(
convergencestudy,
FDataDict(
"elementsize" => 1.0 / 2^ref,
"fens" => fens,
"fes" => fes,
"geom" => geom,
"u" => u,
"femm" => femm,
"stressfields" => [stressfields],
"tolerance" => tolerance,
),
)
end # for ref in
# File = "mplate_w_hole_T10m_stress"
# open(File * ".jls", "w") do file
# serialize(file, convergencestudy)
# end
end # plate_w_hole_T10_stress
function allrun()
println("#####################################################")
println("# plate_w_hole_T10_PE_convergence ")
plate_w_hole_T10_PE_convergence()
# println("#####################################################")
# println("# plate_w_hole_T10_stress ")
# plate_w_hole_T10_stress()
# println("#####################################################")
# println("# plate_w_hole_RECT_MSH8_convergence ")
# plate_w_hole_RECT_MSH8_convergence()
# println("#####################################################")
# println("# plate_w_hole_H20_stress ")
# plate_w_hole_H20_stress()
# println("#####################################################")
# println("# plate_w_hole_MSH8_convergence ")
# plate_w_hole_MSH8_convergence()
# println("#####################################################")
# println("# plate_w_hole_MSH8_PE_convergence ")
# plate_w_hole_MSH8_PE_convergence()
# println("#####################################################")
# println("# plate_w_hole_MST10_convergence ")
# plate_w_hole_MST10_convergence()
# println("#####################################################")
# println("# plate_w_hole_MST10_PE_convergence ")
# plate_w_hole_MST10_PE_convergence()
# println("#####################################################")
# println("# plate_w_hole_MST10_stress ")
# plate_w_hole_MST10_stress()
# println("#####################################################")
# println("# plate_w_hole_RECT_H20_convergence ")
# plate_w_hole_RECT_H20_convergence()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 12749 | module rltb_examples
using FinEtools
using FinEtools.AlgoBaseModule: evalconvergencestudy, solve_blocked!
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule:
linearstatics, exportstresselementwise, exportstress
using Statistics: mean
using LinearAlgebra: Symmetric, cholesky
# Isotropic material
E = 1000.0
nu = 0.4999 # Taylor data
nu = 0.3 # Taylor data
W = 2.5
H = 5.0
L = 50.0
htol = minimum([L, H, W]) / 1000
uzex = -12.6
magn = 0.2 * uzex / 4
Force = magn * W * H * 2
CTE = 0.0
mult = 8
n = 3 #
function getfrcL!(
forceout,
XYZ,
tangents,
feid,
qpid,
)
copyto!(forceout, [0.0; 0.0; magn])
return forceout
end
function rltb_H8_by_hand()
elementtag = "H8"
println("""
Taylor Cantilever example. Element: $(elementtag)
""")
fens, fes = H8block(W, L, H, n, mult * n, 2 * n)
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sectionL = selectelem(fens, bfes; facing = true, direction = [0.0 +1.0 0.0])
# 0 cross-section surface for the reactions
section0 = selectelem(fens, bfes; facing = true, direction = [0.0 -1.0 0.0])
# 0 cross-section surface for the reactions
sectionlateral = selectelem(fens, bfes; facing = true, direction = [1.0 0.0 0.0])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
# Material orientation matrix
csmat = [i == j ? one(Float64) : zero(Float64) for i = 1:3, j = 1:3]
function updatecs!(
csmatout,
XYZ,
tangents,
feid,
qpid,
)
copyto!(csmatout, csmat)
return csmatout
end
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
lx0 = connectednodes(subset(bfes, section0))
setebc!(u, lx0, true, 1, 0.0)
setebc!(u, lx0, true, 2, 0.0)
setebc!(u, lx0, true, 3, 0.0)
lx1 = connectednodes(subset(bfes, sectionlateral))
setebc!(u, lx1, true, 1, 0.0)
applyebc!(u)
numberdofs!(u)
fi = ForceIntensity(Float64, 3, getfrcL!)
el2femm = FEMMBase(IntegDomain(subset(bfes, sectionL), GaussRule(2, 2)))
F2 = distribloads(el2femm, geom, u, fi, 2)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K, F2)
Tipl = selectnode(fens, box = [0 W L L 0 H], inflate = htol)
utip = mean(u.values[Tipl, 3], dims = 1)
println("Deflection: $(utip), compared to $(uzex)")
File = "rltb_H8_by_hand.vtk"
vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
# @async run(`"paraview.exe" $File`)
# modeldata["postprocessing"] = FDataDict("file"=>"hughes_cantilever_stresses_$(elementtag)", "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy, "component"=>[5])
# modeldata = exportstresselementwise(modeldata)
# modeldata["postprocessing"] = FDataDict("file"=>"hughes_cantilever_stresses_$(elementtag)",
# "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy,
# "component"=>collect(1:6))
# modeldata = exportstresselementwise(modeldata)
# stressfields = ElementalField[modeldata["postprocessing"]["exported"][1]["field"]]
true
end # rltb_H8_by_hand
function rltb_H8_sri_by_hand()
elementtag = "H8-SRI"
println("""
Taylor Cantilever example. Element: $(elementtag)
""")
fens, fes = H8block(W, L, H, n, mult * n, 2 * n)
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sectionL = selectelem(fens, bfes; facing = true, direction = [0.0 +1.0 0.0])
# 0 cross-section surface for the reactions
section0 = selectelem(fens, bfes; facing = true, direction = [0.0 -1.0 0.0])
# 0 cross-section surface for the reactions
sectionlateral = selectelem(fens, bfes; facing = true, direction = [1.0 0.0 0.0])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
# Material orientation matrix
csmat = [i == j ? one(Float64) : zero(Float64) for i = 1:3, j = 1:3]
function updatecs!(
csmatout,
XYZ,
tangents,
feid,
qpid,
)
copyto!(csmatout, csmat)
return csmatout
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
lx0 = connectednodes(subset(bfes, section0))
setebc!(u, lx0, true, 1, 0.0)
setebc!(u, lx0, true, 2, 0.0)
setebc!(u, lx0, true, 3, 0.0)
lx1 = connectednodes(subset(bfes, sectionlateral))
setebc!(u, lx1, true, 1, 0.0)
applyebc!(u)
numberdofs!(u)
fi = ForceIntensity(Float64, 3, getfrcL!)
el2femm = FEMMBase(IntegDomain(subset(bfes, sectionL), GaussRule(2, 2)))
F2 = distribloads(el2femm, geom, u, fi, 2)
# First compute the bulk portion of the stiffness matrix
material.D .= FinEtoolsDeforLinear.MatDeforElastIsoModule.bulk_split_tangent_moduli_bulk(E, nu)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 1)), material)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
# Next add the shear portion of the stiffness matrix
material.D .= FinEtoolsDeforLinear.MatDeforElastIsoModule.bulk_split_tangent_moduli_shear(E, nu)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
associategeometry!(femm, geom)
K += stiffness(femm, geom, u)
u = solve_blocked!(u, K, F2)
Tipl = selectnode(fens, box = [0 W L L 0 H], inflate = htol)
utip = mean(u.values[Tipl, 3], dims = 1)
println("Deflection: $(utip), compared to $(uzex)")
File = "rltb_H8_by_hand.vtk"
vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
# @async run(`"paraview.exe" $File`)
# modeldata["postprocessing"] = FDataDict("file"=>"hughes_cantilever_stresses_$(elementtag)", "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy, "component"=>[5])
# modeldata = exportstresselementwise(modeldata)
# modeldata["postprocessing"] = FDataDict("file"=>"hughes_cantilever_stresses_$(elementtag)",
# "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy,
# "component"=>collect(1:6))
# modeldata = exportstresselementwise(modeldata)
# stressfields = ElementalField[modeldata["postprocessing"]["exported"][1]["field"]]
true
end # rltb_H8_sri_by_hand
function rltb_H20_by_hand()
elementtag = "H20"
println("""
Taylor Cantilever example. Element: $(elementtag)
""")
fens, fes = H20block(W, L, H, n, mult * n, 2 * n)
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sectionL = selectelem(fens, bfes; facing = true, direction = [0.0 +1.0 0.0])
# 0 cross-section surface for the reactions
section0 = selectelem(fens, bfes; facing = true, direction = [0.0 -1.0 0.0])
# 0 cross-section surface for the reactions
sectionlateral = selectelem(fens, bfes; facing = true, direction = [1.0 0.0 0.0])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
# Material orientation matrix
csmat = [i == j ? one(Float64) : zero(Float64) for i = 1:3, j = 1:3]
function updatecs!(csmatout, XYZ, tangents, feid)
copyto!(csmatout, csmat)
end
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
lx0 = connectednodes(subset(bfes, section0))
setebc!(u, lx0, true, 1, 0.0)
setebc!(u, lx0, true, 2, 0.0)
setebc!(u, lx0, true, 3, 0.0)
lx1 = connectednodes(subset(bfes, sectionlateral))
setebc!(u, lx1, true, 1, 0.0)
applyebc!(u)
numberdofs!(u)
fi = ForceIntensity(Float64, 3, getfrcL!)
el2femm = FEMMBase(IntegDomain(subset(bfes, sectionL), GaussRule(2, 2)))
F2 = distribloads(el2femm, geom, u, fi, 2)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K, F2)
Tipl = selectnode(fens, box = [0 W L L 0 H], inflate = htol)
utip = mean(u.values[Tipl, 3], dims = 1)
println("Deflection: $(utip), compared to $(uzex)")
File = "rltb_H20_by_hand.vtk"
vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
# @async run(`"paraview.exe" $File`)
# modeldata["postprocessing"] = FDataDict("file"=>"hughes_cantilever_stresses_$(elementtag)", "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy, "component"=>[5])
# modeldata = exportstresselementwise(modeldata)
# modeldata["postprocessing"] = FDataDict("file"=>"hughes_cantilever_stresses_$(elementtag)",
# "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy,
# "component"=>collect(1:6))
# modeldata = exportstresselementwise(modeldata)
# stressfields = ElementalField[modeldata["postprocessing"]["exported"][1]["field"]]
true
end # rltb_H20_by_hand
function rltb_H8_abaqus_export()
elementtag = "H8"
println("""
Taylor Cantilever example. Element: $(elementtag)
""")
fens, fes = H8block(W, L, H, n, mult * n, 2 * n)
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sectionL = selectelem(fens, bfes; facing = true, direction = [0.0 +1.0 0.0])
# 0 cross-section surface for the reactions
section0 = selectelem(fens, bfes; facing = true, direction = [0.0 -1.0 0.0])
# 0 cross-section surface for the reactions
sectionlateral = selectelem(fens, bfes; facing = true, direction = [1.0 0.0 0.0])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
# Material orientation matrix
csmat = [i == j ? one(Float64) : zero(Float64) for i = 1:3, j = 1:3]
function updatecs!(
csmatout,
XYZ,
tangents,
feid,
qpid,
)
copyto!(csmatout, csmat)
return csmatout
end
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
lx0 = connectednodes(subset(bfes, section0))
setebc!(u, lx0, true, 1, 0.0)
setebc!(u, lx0, true, 2, 0.0)
setebc!(u, lx0, true, 3, 0.0)
lx1 = connectednodes(subset(bfes, sectionlateral))
setebc!(u, lx1, true, 1, 0.0)
applyebc!(u)
numberdofs!(u)
fi = ForceIntensity(Float64, 3, getfrcL!)
el2femm = FEMMBase(IntegDomain(subset(bfes, sectionL), GaussRule(2, 2)))
F2 = distribloads(el2femm, geom, u, fi, 2)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K, F2)
Tipl = selectnode(fens, box = [0 W L L 0 H], inflate = htol)
utip = mean(u.values[Tipl, 3], dims = 1)
println("Deflection: $(utip), compared to $(uzex)")
AE = AbaqusExporter("rltb_H8_abaqus_export")
HEADING(
AE,
"Taylor Cantilever example. Element: $(elementtag)",
)
PART(AE, "PART1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
ELEMENT(AE, "C3D8", "ALLELEMENTS", 1, finite_elements(femm).conn)
ELEMENT(
AE,
"SFM3D4",
"TRACTIONELEMENTS",
1 + count(finite_elements(femm)),
finite_elements(el2femm).conn,
)
NSET_NSET(AE, "LX0", lx0)
NSET_NSET(AE, "LX1", lx1)
ORIENTATION(AE, "GLOBALORIENTATION", vec([1.0 0 0]), vec([0 1.0 0]))
SOLID_SECTION(AE, "ELASTICITY", "GLOBALORIENTATION", "ALLELEMENTS", "HOURGLASSCTL")
SURFACE_SECTION(AE, "TRACTIONELEMENTS")
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "ELASTICITY")
ELASTIC(AE, E, nu)
SECTION_CONTROLS(AE, "HOURGLASSCTL", "HOURGLASS=ENHANCED")
STEP_PERTURBATION_STATIC(AE)
BOUNDARY(AE, "ASSEM1.INSTNC1.LX0", 1)
BOUNDARY(AE, "ASSEM1.INSTNC1.LX0", 2)
BOUNDARY(AE, "ASSEM1.INSTNC1.LX0", 3)
BOUNDARY(AE, "ASSEM1.INSTNC1.LX1", 1)
DLOAD(AE, "ASSEM1.INSTNC1.TRACTIONELEMENTS", vec([0.0, 0.0, -magn]))
END_STEP(AE)
close(AE)
true
end # rltb_H8_by_hand
function allrun()
println("#####################################################")
println("# rltb_H8_by_hand ")
rltb_H8_by_hand()
println("#####################################################")
println("# rltb_H8_sri_by_hand ")
rltb_H8_sri_by_hand()
println("#####################################################")
println("# rltb_H20_by_hand ")
rltb_H20_by_hand()
println("#####################################################")
println("# rltb_H8_abaqus_export ")
rltb_H8_abaqus_export()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 7544 | module solver_examples
using FinEtools
using FinEtools.AlgoBaseModule: evalconvergencestudy, solve_blocked!
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule:
linearstatics, exportstresselementwise, exportstress
using Statistics: mean
using LinearAlgebra
using SparseArrays
using LinearSolve
using SciMLOperators
using IncompleteLU
using Printf
using SymRCM
using SparseMatricesCSR
using ThreadedSparseCSR
using UnicodePlots
using PlotlyJS
# using Infiltrator
using Random
using DataDrop
# Isotropic material
E = 1000.0
nu = 0.4999 # Taylor data: nearly incompressible material
nu = 0.3 # Compressible material
W = 25.0
H = 50.0
L = 50.0
htol = minimum([L, H, W]) / 1000
uzex = -0.16
magn = 0.2 * (-12.6) / 4
Force = magn * W * H * 2
CTE = 0.0
n = 5 #
function getfrcL!(forceout, XYZ, tangents, feid, qpid)
copyto!(forceout, [0.0; 0.0; magn])
end
function example(n = 10; precond = :ilu, alg = :cg, other...)
elementtag = "H8"
println("""
Stubby corbel example. Element: $(elementtag)
""")
fens, fes = H8block(W, L, H, n, 2 * n, 2 * n)
println("Number of elements: $(count(fes))")
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sectionL = selectelem(fens, bfes; facing = true, direction = [0.0 +1.0 0.0])
# 0 cross-section surface for the reactions
section0 = selectelem(fens, bfes; facing = true, direction = [0.0 -1.0 0.0])
# 0 cross-section surface for the reactions
sectionlateral = selectelem(fens, bfes; facing = true, direction = [1.0 0.0 0.0])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
# Material orientation matrix
csmat = [i == j ? one(Float64) : zero(Float64) for i = 1:3, j = 1:3]
function updatecs!(csmatout, XYZ, tangents, feid, qpid)
copyto!(csmatout, csmat)
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
# Renumber the nodes
femm = FEMMBase(IntegDomain(fes, GaussRule(3, 2)))
C = connectionmatrix(femm, count(fens))
perm = symrcm(C)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
lx0 = connectednodes(subset(bfes, section0))
setebc!(u, lx0, true, 1, 0.0)
setebc!(u, lx0, true, 2, 0.0)
setebc!(u, lx0, true, 3, 0.0)
lx1 = connectednodes(subset(bfes, sectionlateral))
setebc!(u, lx1, true, 1, 0.0)
applyebc!(u)
numberdofs!(u, perm)
# numberdofs!(u)
println("nfreedofs(u) = $(nfreedofs(u))")
fi = ForceIntensity(Float64, 3, getfrcL!)
el2femm = FEMMBase(IntegDomain(subset(bfes, sectionL), GaussRule(2, 2)))
F = distribloads(el2femm, geom, u, fi, 2)
F_f = vector_blocked_f(F, nfreedofs(u))
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K_ff = matrix_blocked_ff(K, nfreedofs(u))
K = nothing
println("Stiffness: number of non zeros = $(nnz(K_ff)) [ND]")
println("Sparsity = $(nnz(K_ff)/size(K_ff, 1)/size(K_ff, 2)) [ND]")
# display(spy(K_ff, canvas = DotCanvas))
Tipl = selectnode(fens, box = [0 W L L 0 H], inflate = htol)
if precond == :ilu
mK_ffd = mean(diag(K_ff))
PRECOND = ilu(K_ff, τ = mK_ffd / 100.0)
elseif precond == :kdiag
PRECOND = Diagonal(diag(K_ff))
end
if alg == :cg
ALG = KrylovJL_CG
elseif alg == :gmres
ALG = KrylovJL_GMRES
end
verbose = haskey(other, :verbose) ? other[:verbose] : false
prob = LinearProblem(K_ff, F_f)
@time sol = solve(prob, ALG(), Pl=PRECOND, verbose=verbose)
scattersysvec!(u, sol.u[:])
utip = mean(u.values[Tipl, 3], dims = 1)
println("Deflection: $(utip), compared to $(uzex)")
File = "example-n=$(n).vtk"
vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
@async run(`"paraview.exe" $File`)
true
end # example
function example_wop(n = 10; precond = :ilu, alg = :cg, other...)
elementtag = "H8"
println("""
Stubby corbel example. Element: $(elementtag)
""")
fens, fes = H8block(W, L, H, n, 2 * n, 2 * n)
println("Number of elements: $(count(fes))")
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sectionL = selectelem(fens, bfes; facing = true, direction = [0.0 +1.0 0.0])
# 0 cross-section surface for the reactions
section0 = selectelem(fens, bfes; facing = true, direction = [0.0 -1.0 0.0])
# 0 cross-section surface for the reactions
sectionlateral = selectelem(fens, bfes; facing = true, direction = [1.0 0.0 0.0])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
# Material orientation matrix
csmat = [i == j ? one(Float64) : zero(Float64) for i = 1:3, j = 1:3]
function updatecs!(csmatout, XYZ, tangents, feid, qpid)
copyto!(csmatout, csmat)
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
# Renumber the nodes
femm = FEMMBase(IntegDomain(fes, GaussRule(3, 2)))
C = connectionmatrix(femm, count(fens))
perm = symrcm(C)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
lx0 = connectednodes(subset(bfes, section0))
setebc!(u, lx0, true, 1, 0.0)
setebc!(u, lx0, true, 2, 0.0)
setebc!(u, lx0, true, 3, 0.0)
lx1 = connectednodes(subset(bfes, sectionlateral))
setebc!(u, lx1, true, 1, 0.0)
applyebc!(u)
numberdofs!(u, perm)
# numberdofs!(u)
println("nfreedofs(u) = $(nfreedofs(u))")
fi = ForceIntensity(Float64, 3, getfrcL!)
el2femm = FEMMBase(IntegDomain(subset(bfes, sectionL), GaussRule(2, 2)))
F = distribloads(el2femm, geom, u, fi, 2)
F_f = vector_blocked_f(F, nfreedofs(u))
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K_ff = matrix_blocked_ff(K, nfreedofs(u))
K = nothing
println("Stiffness: number of non zeros = $(nnz(K_ff)) [ND]")
println("Sparsity = $(nnz(K_ff)/size(K_ff, 1)/size(K_ff, 2)) [ND]")
# display(spy(K_ff, canvas = DotCanvas))
Tipl = selectnode(fens, box = [0 W L L 0 H], inflate = htol)
if precond == :ilu
mK_ffd = mean(diag(K_ff))
PRECOND = ilu(K_ff, τ = mK_ffd / 100.0)
elseif precond == :kdiag
PRECOND = Diagonal(diag(K_ff))
end
if alg == :cg
ALG = KrylovJL_CG
elseif alg == :gmres
ALG = KrylovJL_GMRES
end
verbose = haskey(other, :verbose) ? other[:verbose] : false
# mop = MatrixOperator(K_ff)
# prob = LinearProblem(mop, F_f)
K_ff = SparseMatricesCSR.SparseMatrixCSR(Transpose(K_ff))
fop = FunctionOperator((v, u, p, t) -> bmul!(v, K_ff, u), F_f, zeros(length(F_f)))
# fop = FunctionOperator((v, u, p, t) -> mul!(v, K_ff, u), F_f, zeros(length(F_f)); ifcache = false)
prob = LinearProblem(fop, F_f)
@time sol = solve(prob, ALG(), Pl=PRECOND, verbose=verbose)
scattersysvec!(u, sol.u[:])
utip = mean(u.values[Tipl, 3], dims = 1)
println("Deflection: $(utip), compared to $(uzex)")
File = "example-n=$(n).vtk"
vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
# @async run(`"paraview.exe" $File`)
true
end # example_wop
function allrun(n = 10; args...)
println("#####################################################")
println("# example ")
example(n; args...)
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 3696 | module sparse_examples
using FinEtools
using FinEtools.AlgoBaseModule: evalconvergencestudy, solve_blocked!
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule:
linearstatics, exportstresselementwise, exportstress
using Statistics: mean
using LinearAlgebra
using SparseArrays
using LinearSolve
using SciMLOperators
using IncompleteLU
using Printf
using SymRCM
using SimplySparse
using SparseMatricesCSR
using ThreadedSparseCSR
using UnicodePlots
using PlotlyJS
using Random
using DataDrop
# Isotropic material
E = 1000.0
nu = 0.4999 # Taylor data: nearly incompressible material
nu = 0.3 # Compressible material
W = 25.0
H = 50.0
L = 50.0
htol = minimum([L, H, W]) / 1000
uzex = -0.16
magn = 0.2 * (-12.6) / 4
Force = magn * W * H * 2
CTE = 0.0
n = 5 #
function getfrcL!(forceout, XYZ, tangents, feid, qpid)
copyto!(forceout, [0.0; 0.0; magn])
end
function example(n = 10; precond = :ilu, alg = :cg, other...)
elementtag = "H8"
println("""
Stubby corbel example. Element: $(elementtag), n=$(n)
""")
fens, fes = H8block(W, L, H, n, 2 * n, 2 * n)
println("Number of elements: $(count(fes))")
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sectionL = selectelem(fens, bfes; facing = true, direction = [0.0 +1.0 0.0])
# 0 cross-section surface for the reactions
section0 = selectelem(fens, bfes; facing = true, direction = [0.0 -1.0 0.0])
# 0 cross-section surface for the reactions
sectionlateral = selectelem(fens, bfes; facing = true, direction = [1.0 0.0 0.0])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
# Material orientation matrix
csmat = [i == j ? one(Float64) : zero(Float64) for i = 1:3, j = 1:3]
function updatecs!(csmatout, XYZ, tangents, feid, qpid)
copyto!(csmatout, csmat)
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
# Renumber the nodes
femm = FEMMBase(IntegDomain(fes, GaussRule(3, 2)))
C = connectionmatrix(femm, count(fens))
perm = symrcm(C)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
lx0 = connectednodes(subset(bfes, section0))
setebc!(u, lx0, true, 1, 0.0)
setebc!(u, lx0, true, 2, 0.0)
setebc!(u, lx0, true, 3, 0.0)
lx1 = connectednodes(subset(bfes, sectionlateral))
setebc!(u, lx1, true, 1, 0.0)
applyebc!(u)
numberdofs!(u, perm)
# numberdofs!(u)
println("nalldofs(u) = $(nalldofs(u))")
fi = ForceIntensity(Float64, 3, getfrcL!)
el2femm = FEMMBase(IntegDomain(subset(bfes, sectionL), GaussRule(2, 2)))
F = distribloads(el2femm, geom, u, fi, 2)
F_f = vector_blocked_f(F, nfreedofs(u))
associategeometry!(femm, geom)
ass = SysmatAssemblerSparse(0.0)
setnomatrixresult(ass, false)
K = stiffness(femm, ass, geom, u)
I, J, V = deepcopy(ass._rowbuffer), deepcopy(ass._colbuffer), deepcopy(ass._matbuffer)
println("Stiffness: number of non zeros = $(length(I)) [ND]")
@time S = sparse(I, J, V, nalldofs(u), nalldofs(u))
# @time S = SimplySparse.sparse(I, J, V, nalldofs(u), nalldofs(u))
I, J, V = deepcopy(ass._rowbuffer), deepcopy(ass._colbuffer), deepcopy(ass._matbuffer)
@time S = SimplySparse.par_sparse(I, J, V, nalldofs(u), nalldofs(u))
true
end # example
function allrun(n = 30; args...)
println("#####################################################")
println("# example ")
example(n; args...)
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 5549 | module sparsity_examples
using FinEtools
using FinEtools.AlgoBaseModule: evalconvergencestudy, solve_blocked!
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule:
linearstatics, exportstresselementwise, exportstress
using Statistics: mean
using LinearAlgebra
using SparseArrays
using LinearSolve
using SciMLOperators
using IncompleteLU
using Printf
using SymRCM
using SimplySparse
using SparseMatricesCSR
using ThreadedSparseCSR
using UnicodePlots
using PlotlyJS
using Random
using DataDrop
using DataStructures
using AddToSparse
# Isotropic material
E = 1000.0
nu = 0.4999 # Taylor data: nearly incompressible material
nu = 0.3 # Compressible material
W = 25.0
H = 50.0
L = 50.0
htol = minimum([L, H, W]) / 1000
uzex = -0.16
magn = 0.2 * (-12.6) / 4
Force = magn * W * H * 2
CTE = 0.0
n = 5 #
function __collect_unique_node_neighbors(ellist, conn, npe)
totn = length(ellist) * npe
nodes = fill(zero(eltype(conn[1])), totn)
p = 1
for i in ellist
for k in conn[i]
nodes[p] = k
p += 1
end
end
sort!(nodes)
unique!(nodes)
return nodes
end
function _unique_nodes(n2e, conn)
npe = length(conn[1])
unique_nodes = fill(Vector{eltype(n2e.map[1])}(), length(n2e.map))
Base.Threads.@threads for i in 1:length(n2e.map) # run this in PARALLEL
unique_nodes[i] = __collect_unique_node_neighbors(n2e.map[i], conn, npe)
end
return unique_nodes
end
function _populate_dofs(n, n2n, dofnums, start, dofs)
nd = size(dofnums, 2)
totd = length(n2n[n]) * nd
_dofs = fill(zero(eltype(dofs)), totd)
p = 1
for k in n2n[n]
for d in axes(dofnums, 2)
_dofs[p] = dofnums[k, d]
p += 1
end
end
sort!(_dofs)
for d in axes(dofnums, 2)
j = dofnums[n, d]
s = start[j]
p = 0
for m in eachindex(_dofs)
dofs[s+p] = _dofs[m]
p += 1
end
end
return nothing
end
function _prepare_start_dofs(IT, n2n, dofnums)
nd = size(dofnums, 2)
total_dofs = length(n2n) * nd
lengths = Vector{IT}(undef, total_dofs+1)
for k in eachindex(n2n)
kl = length(n2n[k]) * nd
for d in axes(dofnums, 2)
j = dofnums[k, d]
lengths[j] = kl
end
end
lengths[end] = 0
# Now we start overwriting the lengths array with the starts
start = lengths
sumlen = 0
len = start[1]
sumlen += len
start[1] = 1
plen = len
for k in 2:total_dofs
len = start[k]
sumlen += len
start[k] = start[k-1] + plen
plen = len
end
start[end] = sumlen+1
dofs = Vector{IT}(undef, sumlen)
return start, dofs
end
function example(n=10; precond=:ilu, alg=:cg, other...)
elementtag = "H8"
println("""
Stubby corbel example. Element: $(elementtag), n=$(n)
""")
fens, fes = H8block(W, L, H, n, 2 * n, 2 * n)
println("Number of elements: $(count(fes))")
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sectionL = selectelem(fens, bfes; facing=true, direction=[0.0 +1.0 0.0])
# 0 cross-section surface for the reactions
section0 = selectelem(fens, bfes; facing=true, direction=[0.0 -1.0 0.0])
# 0 cross-section surface for the reactions
sectionlateral = selectelem(fens, bfes; facing=true, direction=[1.0 0.0 0.0])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
# Material orientation matrix
csmat = [i == j ? one(Float64) : zero(Float64) for i = 1:3, j = 1:3]
function updatecs!(csmatout, XYZ, tangents, feid, qpid)
copyto!(csmatout, csmat)
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
# Renumber the nodes
femm = FEMMBase(IntegDomain(fes, GaussRule(3, 2)))
C = connectionmatrix(femm, count(fens))
perm = symrcm(C)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 3)), material)
lx0 = connectednodes(subset(bfes, section0))
setebc!(u, lx0, true, 1, 0.0)
setebc!(u, lx0, true, 2, 0.0)
setebc!(u, lx0, true, 3, 0.0)
lx1 = connectednodes(subset(bfes, sectionlateral))
setebc!(u, lx1, true, 1, 0.0)
applyebc!(u)
numberdofs!(u, perm)
# numberdofs!(u)
println("nalldofs(u) = $(nalldofs(u))")
associategeometry!(femm, geom)
ass = SysmatAssemblerSparse(0.0)
setnomatrixresult(ass, false)
K = stiffness(femm, ass, geom, u)
I, J, V = deepcopy(ass._rowbuffer), deepcopy(ass._colbuffer), deepcopy(ass._matbuffer)
@time K = sparse(I, J, V, nalldofs(u), nalldofs(u))
# @show K.colptr
# @show K.rowval
IT = eltype(u.dofnums)
@time n2e = FENodeToFEMap(fes.conn, count(fens))
@time n2n = _unique_nodes(n2e, fes.conn)
@time start, dofs = _prepare_start_dofs(IT, n2n, u.dofnums)
@time Base.Threads.@threads for n in 1:count(fens)
_populate_dofs(n, n2n, u.dofnums, start, dofs)
end
# @show start
# @show dofs
S = SparseMatrixCSC(size(K)..., start, dofs, fill(0.0, length(dofs)))
AddToSparse.addtosparse(S, I, J, V)
@show norm(K - S) / norm(K)
true
end # example
function allrun(n=3; args...)
println("#####################################################")
println("# example ")
example(n; args...)
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 6044 | module ss_beam_examples
using FinEtools
using FinEtools.AlgoBaseModule: evalconvergencestudy, solve_blocked!
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule:
linearstatics, exportstresselementwise, exportstress
using Statistics: mean
using LinearAlgebra: Symmetric, cholesky
# Isotropic material
E = 209000.0
nu = 0.3 #Taylor data
W = 30.0
H = 16.25
L = 200.0
htol = minimum([L, H, W]) / 1000
magn = 1.0
uzex = -5 / 384 * magn * W * L^4 / (E * W * H^3 / 12)
n = 8 #
function getfrcL!(
forceout::FFltVec,
XYZ::FFltMat,
tangents::FFltMat,
feid::FInt,
qpid::FInt,
)
copyto!(forceout, [0.0; 0.0; -magn])
forceout
end
function test_h8()
elementtag = "H8"
println("""
SS beam example. Element: $(elementtag)
""")
fens, fes = H8block(L, W, H, n, 2, 1)
bfes = meshboundary(fes)
# Simple support
sectionL = selectelem(fens, bfes; facing = true, direction = [+1.0 0.0 0.0])
# Simple support
section0 = selectelem(fens, bfes; facing = true, direction = [-1.0 0.0 0.0])
# Top loaded surface
sectionlateral = selectelem(fens, bfes; facing = true, direction = [0.0 0.0 1.0])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, 0.0)
# Material orientation matrix
csmat = [i == j ? one(FFlt) : zero(FFlt) for i = 1:3, j = 1:3]
function updatecs!(csmatout::FFltMat, XYZ::FFltMat, tangents::FFltMat, feid::FInt)
copyto!(csmatout, csmat)
end
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
lx0 = connectednodes(subset(bfes, section0))
setebc!(u, lx0, true, 2, 0.0)
setebc!(u, lx0, true, 3, 0.0)
lx0 = connectednodes(subset(bfes, sectionL))
setebc!(u, lx0, true, 2, 0.0)
setebc!(u, lx0, true, 3, 0.0)
# Fix one node in the X direction
lx1 = connectednodes(subset(bfes, sectionlateral))[1]
setebc!(u, lx1, true, 1, 0.0)
applyebc!(u)
numberdofs!(u)
fi = ForceIntensity(Float64, 3, getfrcL!)
el2femm = FEMMBase(IntegDomain(subset(bfes, sectionlateral), GaussRule(2, 2)))
F2 = distribloads(el2femm, geom, u, fi, 2)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K, F2)
utip = minimum(u.values[:, 3])
println("Deflection: $(utip), compared to $(uzex)")
File = "test_h8.vtk"
vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
@async run(`"paraview.exe" $File`)
# modeldata["postprocessing"] = FDataDict("file"=>"hughes_cantilever_stresses_$(elementtag)", "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy, "component"=>[5])
# modeldata = exportstresselementwise(modeldata)
# modeldata["postprocessing"] = FDataDict("file"=>"hughes_cantilever_stresses_$(elementtag)",
# "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy,
# "component"=>collect(1:6))
# modeldata = exportstresselementwise(modeldata)
# stressfields = ElementalField[modeldata["postprocessing"]["exported"][1]["field"]]
true
end # test_h8
function test_h20r()
elementtag = "H20R"
println("""
SS beam example. Element: $(elementtag)
""")
fens, fes = H20block(L, W, H, n, 2, 1)
bfes = meshboundary(fes)
# Simple support
sectionL = selectelem(fens, bfes; facing = true, direction = [+1.0 0.0 0.0])
# Simple support
section0 = selectelem(fens, bfes; facing = true, direction = [-1.0 0.0 0.0])
# Top loaded surface
sectionlateral = selectelem(fens, bfes; facing = true, direction = [0.0 0.0 1.0])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, 0.0)
# Material orientation matrix
csmat = [i == j ? one(FFlt) : zero(FFlt) for i = 1:3, j = 1:3]
function updatecs!(csmatout::FFltMat, XYZ::FFltMat, tangents::FFltMat, feid::FInt)
copyto!(csmatout, csmat)
end
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
lx0 = connectednodes(subset(bfes, section0))
setebc!(u, lx0, true, 2, 0.0)
setebc!(u, lx0, true, 3, 0.0)
lx0 = connectednodes(subset(bfes, sectionL))
setebc!(u, lx0, true, 2, 0.0)
setebc!(u, lx0, true, 3, 0.0)
# Fix one node in the X direction
lx1 = connectednodes(subset(bfes, sectionlateral))[1]
setebc!(u, lx1, true, 1, 0.0)
applyebc!(u)
numberdofs!(u)
fi = ForceIntensity(Float64, 3, getfrcL!)
el2femm = FEMMBase(IntegDomain(subset(bfes, sectionlateral), GaussRule(2, 2)))
F2 = distribloads(el2femm, geom, u, fi, 2)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K, F2)
utip = minimum(u.values[:, 3])
println("Deflection: $(utip), compared to $(uzex)")
File = "test_h20r.vtk"
vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
@async run(`"paraview.exe" $File`)
# modeldata["postprocessing"] = FDataDict("file"=>"hughes_cantilever_stresses_$(elementtag)", "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy, "component"=>[5])
# modeldata = exportstresselementwise(modeldata)
# modeldata["postprocessing"] = FDataDict("file"=>"hughes_cantilever_stresses_$(elementtag)",
# "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy,
# "component"=>collect(1:6))
# modeldata = exportstresselementwise(modeldata)
# stressfields = ElementalField[modeldata["postprocessing"]["exported"][1]["field"]]
true
end # test_h8
function allrun()
println("#####################################################")
println("# test_h8 ")
test_h8()
println("#####################################################")
println("# test_h20r ")
test_h20r()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 33373 | module stubby_corbel_examples
using FinEtools
using FinEtools.AlgoBaseModule: evalconvergencestudy, solve_blocked!
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule:
linearstatics, exportstresselementwise, exportstress
using Statistics: mean
using LinearAlgebra
using Krylov, LinearOperators, IncompleteLU
using SparseArrays
using SuiteSparse
using Printf
using SymRCM
using UnicodePlots
using PlotlyJS
# using Infiltrator
using Random
using ILUZero
# using SkylineSolvers
using LDLFactorizations
using LimitedLDLFactorizations, LinearOperators, Krylov
using FinEtoolsMultithreading.Exports
using FinEtoolsMultithreading: domain_decomposition,
parallel_matrix_assembly!, SysmatAssemblerSparsePatt
using FinEtoolsMultithreading
using DataDrop
import CoNCMOR: CoNCData, transfmatrix, LegendreBasis, SineCosineBasis
# Isotropic material
E = 1000.0
nu = 0.4999 # Taylor data: nearly incompressible material
nu = 0.3 # Compressible material
W = 25.0
H = 50.0
L = 50.0
htol = minimum([L, H, W]) / 1000
uzex = -0.16
magn = 0.2 * (-12.6) / 4
Force = magn * W * H * 2
CTE = 0.0
n = 5 #
function getfrcL!(forceout, XYZ, tangents, feid, qpid)
copyto!(forceout, [0.0; 0.0; magn])
end
transfm(m, t, tT) = (tT * m * t)
transfv(v, t, tT) = (tT * v)
function morprecon2d(y, v, Phi, Kd, K, mixprop)
Kr = transfm(K, Phi, Phi')
y .= (1 - mixprop) * (Kd \ v) + mixprop * (Phi * (Kr \ (Phi' * v)))
return y
end
function morprecond3(y, v, Phi, Kd, Kr, mixprop)
y .= (1 - mixprop) * (Kd \ v) + mixprop * (Phi * (Kr \ (Phi' * v)))
return y
end
function morprecond4(y, v, Phi, Kd, Kr, mixprop)
y .= (Phi * (((1 - mixprop) * (Phi' * Kd * Phi) + mixprop * Kr) \ (Phi' * v)))
return y
end
# morprecond3nomix(y, v, Phi, Kd, Kr, mixprop) = begin
# y .= (Kd \ v) + (Phi * (Kr \ (Phi' * v)))
# return y
# end
function ildl(K::AbstractMatrix{T}; kwargs...) where {T}
F = lldl(K; kwargs...)
F.D .= abs.(F.D)
n = length(F.D)
return LinearOperator(T, n, n, true, true, (y, v) -> ldiv!(y, F, v))
end
function stubby_corbel_H8_by_hand()
elementtag = "H8"
println("""
Stubby corbel example. Element: $(elementtag)
""")
fens, fes = H8block(W, L, H, n, 2 * n, 2 * n)
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sectionL = selectelem(fens, bfes; facing = true, direction = [0.0 +1.0 0.0])
# 0 cross-section surface for the reactions
section0 = selectelem(fens, bfes; facing = true, direction = [0.0 -1.0 0.0])
# 0 cross-section surface for the reactions
sectionlateral = selectelem(fens, bfes; facing = true, direction = [1.0 0.0 0.0])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
# Material orientation matrix
csmat = [i == j ? one(Float64) : zero(Float64) for i = 1:3, j = 1:3]
function updatecs!(csmatout, XYZ, tangents, feid, qpid)
copyto!(csmatout, csmat)
end
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
lx0 = connectednodes(subset(bfes, section0))
setebc!(u, lx0, true, 1, 0.0)
setebc!(u, lx0, true, 2, 0.0)
setebc!(u, lx0, true, 3, 0.0)
lx1 = connectednodes(subset(bfes, sectionlateral))
setebc!(u, lx1, true, 1, 0.0)
applyebc!(u)
numberdofs!(u)
println("nfreedofs(u) = $(nfreedofs(u))")
fi = ForceIntensity(Float64, 3, getfrcL!)
el2femm = FEMMBase(IntegDomain(subset(bfes, sectionL), GaussRule(2, 2)))
F = distribloads(el2femm, geom, u, fi, 2)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
@time solve_blocked!(u, K, F)
Tipl = selectnode(fens, box = [0 W L L 0 H], inflate = htol)
utip = mean(u.values[Tipl, 3], dims = 1)
println("Deflection: $(utip), compared to $(uzex)")
File = "stubby_corbel_H8_by_hand.vtk"
vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
@async run(`"paraview.exe" $File`)
# modeldata["postprocessing"] = FDataDict("file"=>"hughes_cantilever_stresses_$(elementtag)", "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy, "component"=>[5])
# modeldata = exportstresselementwise(modeldata)
# modeldata["postprocessing"] = FDataDict("file"=>"hughes_cantilever_stresses_$(elementtag)",
# "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy,
# "component"=>collect(1:6))
# modeldata = exportstresselementwise(modeldata)
# stressfields = ElementalField[modeldata["postprocessing"]["exported"][1]["field"]]
true
end # stubby_corbel_H8_by_hand
function stubby_corbel_H8_big_iso(n = 10, solver = :suitesparse)
elementtag = "H8"
println("""
Stubby corbel example. Element: $(elementtag)
""")
fens, fes = H8block(W, L, H, n, 2 * n, 2 * n)
println("Number of elements: $(count(fes))")
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sectionL = selectelem(fens, bfes; facing = true, direction = [0.0 +1.0 0.0])
# 0 cross-section surface for the reactions
section0 = selectelem(fens, bfes; facing = true, direction = [0.0 -1.0 0.0])
# 0 cross-section surface for the reactions
sectionlateral = selectelem(fens, bfes; facing = true, direction = [1.0 0.0 0.0])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
# Material orientation matrix
csmat = [i == j ? one(Float64) : zero(Float64) for i = 1:3, j = 1:3]
function updatecs!(csmatout, XYZ, tangents, feid, qpid)
copyto!(csmatout, csmat)
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
# Renumber the nodes
femm = FEMMBase(IntegDomain(fes, GaussRule(3, 2)))
C = connectionmatrix(femm, count(fens))
# display(spy(C, canvas = DotCanvas))
# I, J, V = findnz(C)
# @show bw = maximum(I .- J) + 1
perm = symrcm(C)
# C = C[perm, perm]
# display(spy(C, canvas = DotCanvas))
# I, J, V = findnz(C)
# @show bw = maximum(I .- J) + 1
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
lx0 = connectednodes(subset(bfes, section0))
setebc!(u, lx0, true, 1, 0.0)
setebc!(u, lx0, true, 2, 0.0)
setebc!(u, lx0, true, 3, 0.0)
lx1 = connectednodes(subset(bfes, sectionlateral))
setebc!(u, lx1, true, 1, 0.0)
applyebc!(u)
numberdofs!(u, perm)
# numberdofs!(u)
println("nfreedofs(u) = $(nfreedofs(u))")
fi = ForceIntensity(Float64, 3, getfrcL!)
el2femm = FEMMBase(IntegDomain(subset(bfes, sectionL), GaussRule(2, 2)))
F = distribloads(el2femm, geom, u, fi, 2)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
println("Stiffness: number of non zeros = $(nnz(K)) [ND]")
println("Sparsity = $(nnz(K)/size(K, 1)/size(K, 2)) [ND]")
display(spy(K, canvas = DotCanvas))
# DataDrop.store_matrix("K", K)
Tipl = selectnode(fens, box = [0 W L L 0 H], inflate = htol)
if solver == :suitesparse
# @show methods(SuiteSparse.CHOLMOD.ldlt, (typeof(K), ))
# @time K = SuiteSparse.CHOLMOD.ldlt(K)
@time K = SuiteSparse.CHOLMOD.cholesky(K)
# @time K = SparseArrays.ldlt(K)
# @time K = cholesky(K)
@time U = K \ (F)
elseif solver == :cg
n = size(K, 1)
mKd = mean(diag(K))
# @time factor = ilu(K, τ = mKd / 100.0) # This may work for compressible materials
@time factor = ilu(K, τ = mKd / 1000000.0) # This may work for incompressible materials
# factor = ilu0(K)
@show nnz(factor) / nnz(K)
opM = LinearOperator(Float64, n, n, false, false, (y, v) -> ldiv!(y, factor, v))
@time (U, stats) = Krylov.cg(K, F; M = opM, itmax = Int(round(n / 2)), verbose = 1)
elseif solver == :scaledcg
n = size(K, 1)
idKs = Diagonal(1.0 ./ sqrt.(diag(K)))
sK = idKs * K * idKs
@show mKd = mean(diag(sK))
# @time factor = ilu(sK, τ = 0.01) # This may work for compressible materials
@time factor = ilu(sK, τ = 0.000001) # This may work for incompressible materials
# @time factor = ilu0(sK)
@show nnz(factor) / nnz(K)
opM = LinearOperator(Float64, n, n, false, false, (y, v) -> ldiv!(y, factor, v))
@time (U, stats) =
Krylov.cg(sK, idKs * F; M = opM, itmax = Int(round(n / 2)), verbose = 1)
U = Vector(idKs * U)
elseif solver == :skyline
I, J, V = findnz(K)
@show bw = maximum(abs.(I .- J)) + 1
M = size(K, 1)
K = nothing
GC.gc()
sky = SkylineSolvers.Ldlt.SkylineMatrix(I, J, V, M)
I = nothing
J = nothing
V = nothing
GC.gc()
@show SkylineSolvers.Ldlt.nnz(sky)
@time SkylineSolvers.Ldlt.factorize!(sky)
@time U = SkylineSolvers.Ldlt.solve(sky, F)
elseif solver == :mor
Nc = 16
nbf1max = 3
mixprop = 0.5
partitioning = nodepartitioning(fens, Nc)
mor = CoNCData(fens, partitioning)
Phi = transfmatrix(mor, LegendreBasis, nbf1max, u)
transfm(m, t, tT) = (tT * m * t)
transfv(v, t, tT) = (tT * v)
PhiT = Phi'
Kr = transfm(K, Phi, PhiT)
@show size(Kr)
Krfactor = lu(Kr)
Ur = Phi * (Krfactor \ (PhiT * F))
scattersysvec!(u, Ur[:])
utip = mean(u.values[Tipl, 3], dims = 1)
println("First Guess of Deflection: $(utip), compared to $(uzex)")
R = F - K * Ur
n = size(K, 1)
Kd = Diagonal(diag(K))
Krd = fill(0.0, size(K, 1))
for i = 1:size(K, 1)
Krd = Phi[i, :] * Kr * PhiT[i, :]
end
trace1 = scatter(
x = 1:length(Krd),
y = Krd,
mode = "lines",
line_width = 1.5,
line_color = "RoyalBlue",
)
trace2 = scatter(
x = 1:length(Krd),
y = diag(K),
mode = "lines",
line_width = 1.5,
line_color = "red",
)
data = [trace1, trace2]
layout = Layout(; title = "Data Labels Hover")
display(plot(data, layout))
# @show mKd = mean(diag(K))
# @time factor0 = ilu(K, τ = mKd / 10.0) # This may work for incompressible materials
# itr = 0
function morprecond(y, v)
y .= (1 - mixprop) * (Kd \ v) + mixprop * (Phi * (Krfactor \ (PhiT * v)))
end
opM = LinearOperator(Float64, n, n, false, false, morprecond)
@time (DU, stats) = Krylov.cg(K, R; M = opM, itmax = 500, verbose = 1)
U = Ur + DU
else
@error "Solver not recognized"
end
scattersysvec!(u, U[:])
utip = mean(u.values[Tipl, 3], dims = 1)
println("Deflection: $(utip), compared to $(uzex)")
File = "stubby_corbel_H8_big.vtk"
vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
@async run(`"paraview.exe" $File`)
# modeldata["postprocessing"] = FDataDict("file"=>"hughes_cantilever_stresses_$(elementtag)", "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy, "component"=>[5])
# modeldata = exportstresselementwise(modeldata)
# modeldata["postprocessing"] = FDataDict("file"=>"hughes_cantilever_stresses_$(elementtag)",
# "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy,
# "component"=>collect(1:6))
# modeldata = exportstresselementwise(modeldata)
# stressfields = ElementalField[modeldata["postprocessing"]["exported"][1]["field"]]
true
end # stubby_corbel_H8_big_iso
function _cg(A, b, x0, maxiter)
x = deepcopy(x0)
g = x' * A - b'
d = -g'
for iter in 1:maxiter
Ad = A * d
rho = (d' * Ad)
alpha = (-g * d) / rho
x = x + alpha * d
g = x' * A - b'
beta = (g * Ad) / rho
d = beta * d - g'
end
return x
end
function stubby_corbel_H8_big_ms(n = 10, solver = :suitesparse)
elementtag = "H8"
println("""
Stubby corbel example. Element: $(elementtag)
""")
fens, fes = H8block(W, L, H, n, 2 * n, 2 * n)
println("Number of elements: $(count(fes))")
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sectionL = selectelem(fens, bfes; facing = true, direction = [0.0 +1.0 0.0])
# 0 cross-section surface for the reactions
section0 = selectelem(fens, bfes; facing = true, direction = [0.0 -1.0 0.0])
# 0 cross-section surface for the reactions
sectionlateral = selectelem(fens, bfes; facing = true, direction = [1.0 0.0 0.0])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
# Material orientation matrix
csmat = [i == j ? one(Float64) : zero(Float64) for i = 1:3, j = 1:3]
function updatecs!(csmatout, XYZ, tangents, feid, qpid)
copyto!(csmatout, csmat)
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
# Renumber the nodes
femm = FEMMBase(IntegDomain(fes, GaussRule(3, 2)))
C = connectionmatrix(femm, count(fens))
# display(spy(C, canvas = DotCanvas))
# I, J, V = findnz(C)
# @show bw = maximum(I .- J) + 1
perm = symrcm(C)
# C = C[perm, perm]
# display(spy(C, canvas = DotCanvas))
# I, J, V = findnz(C)
# @show bw = maximum(I .- J) + 1
# femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
lx0 = connectednodes(subset(bfes, section0))
setebc!(u, lx0, true, 1, 0.0)
setebc!(u, lx0, true, 2, 0.0)
setebc!(u, lx0, true, 3, 0.0)
lx1 = connectednodes(subset(bfes, sectionlateral))
setebc!(u, lx1, true, 1, 0.0)
applyebc!(u)
numberdofs!(u, perm)
# numberdofs!(u)
println("nfreedofs(u) = $(nfreedofs(u))")
fi = ForceIntensity(Float64, 3, getfrcL!)
el2femm = FEMMBase(IntegDomain(subset(bfes, sectionL), GaussRule(2, 2)))
F = distribloads(el2femm, geom, u, fi, 2)
F_f = vector_blocked_f(F, nfreedofs(u))
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K_ff = matrix_blocked_ff(K, nfreedofs(u))
K = nothing
println("Stiffness: number of non zeros = $(nnz(K_ff)) [ND]")
println("Sparsity = $(nnz(K_ff)/size(K_ff, 1)/size(K_ff, 2)) [ND]")
display(spy(K_ff, canvas = DotCanvas))
# DataDrop.store_matrix("K$(size(K, 1))", K)
# DataDrop.store_matrix("F$(size(F, 1))", F)
Tipl = selectnode(fens, box = [0 W L L 0 H], inflate = htol)
if solver == :suitesparse || solver == :default
# @show methods(SuiteSparse.CHOLMOD.ldlt, (typeof(K), ))
# @time K = SuiteSparse.CHOLMOD.ldlt(K)
@time K = SuiteSparse.CHOLMOD.cholesky(K)
@show nnz(K)
# @time K = SparseArrays.ldlt(K)
# @time K = cholesky(K)
@time U = K \ (F)
elseif solver == :cg
n = size(K_ff, 1)
mK_ffd = mean(diag(K_ff))
@time factor = ilu(K_ff, τ = mK_ffd / 100.0) # This may work for compressible materials
# @time factor = ilu(K, τ = mKd / 1000000.0) # This may work for incompressible materials
# factor = ilu0(K)
@show nnz(factor) / nnz(K_ff)
opM = LinearOperator(Float64, n, n, false, false, (y, v) -> ldiv!(y, factor, v))
@time (U, stats) = Krylov.cg(K_ff, F_f; M = opM, itmax = Int(round(n / 2)), verbose = 1)
elseif solver == :cgldl
n = size(K, 1)
atol = 1e-10
rtol = 0.0
memory = 2000
@time P = ildl(K, memory = memory)
# @time U, stats = bicgstab(K, F, N=P, atol=atol, rtol=rtol, verbose=1)
@time U, stats = cg(K, F, M = P, atol = atol, rtol = rtol, verbose = 1)
@show stats
elseif solver == :scaledcg
n = size(K, 1)
idKs = Diagonal(1.0 ./ sqrt.(diag(K)))
sK = idKs * K * idKs
@show mKd = mean(diag(sK))
# @time factor = ilu(sK, τ = 0.01) # This may work for compressible materials
@time factor = ilu(sK, τ = 0.000001) # This may work for incompressible materials
# @time factor = ilu0(sK)
@show nnz(factor) / nnz(K)
opM = LinearOperator(Float64, n, n, false, false, (y, v) -> ldiv!(y, factor, v))
@time (U, stats) =
Krylov.cg(sK, idKs * F; M = opM, itmax = Int(round(n / 2)), verbose = 1)
U = Vector(idKs * U)
elseif solver == :skyline
I, J, V = findnz(K)
@show bw = maximum(abs.(I .- J)) + 1
M = size(K, 1)
K = nothing
GC.gc()
sky = SkylineSolvers.Ldlt.SkylineMatrix(I, J, V, M)
I = nothing
J = nothing
V = nothing
GC.gc()
@show SkylineSolvers.Ldlt.nnz(sky)
@time SkylineSolvers.Ldlt.factorize!(sky)
@time U = SkylineSolvers.Ldlt.solve(sky, F)
elseif solver == :ldlfactorizations
@time factors = LDLFactorizations.ldlt(K)
@time U = factors \ F
elseif solver == :mor0
Nc = 32
nbf1max = 4
mixprop = 0.01
partitioning = nodepartitioning(fens, Nc)
mor = CoNCData(fens, partitioning)
Phi = transfmatrix(mor, LegendreBasis, nbf1max, u)
PhiT = Phi'
Kr = transfm(K, Phi, PhiT)
@show size(Kr)
Krfactor = lu(Kr)
Ur = Phi * (Krfactor \ (PhiT * F))
scattersysvec!(u, Ur[:])
utip = mean(u.values[Tipl, 3], dims = 1)
println("First Guess of Deflection: $(utip), compared to $(uzex)")
R = F - K * Ur
n = size(K, 1)
Kdinv = 1.0 ./ diag(K)
morprecond(y, v) = begin
y .= (1 - mixprop) * (Kdinv .* v)
y .+= mixprop * (Phi * (Krfactor \ (PhiT * v)))
end
morprecondnomix(y, v) = begin
y .= (Kdinv .* v) + (Phi * (Krfactor \ (PhiT * v)))
end
opM = LinearOperator(Float64, n, n, false, false, morprecond)
U = deepcopy(Ur)
for iter = 1:50
@show iter
(DU, stats) = Krylov.cg(K, F - K * U; M = opM, itmax = 5, verbose = 0)
U += DU
@show norm(DU) / norm(U)
scattersysvec!(u, U[:])
utip = mean(u.values[Tipl, 3], dims = 1)
println("Iterated Deflection: $(utip), compared to $(uzex)")
end
elseif solver == :mor1
rtol = 1.0e-9
Nc = 32
nbf1max = 4
mixprop = 1.0
partitioning = nodepartitioning(fens, Nc)
mor = CoNCData(fens, partitioning)
Phi = transfmatrix(mor, LegendreBasis, nbf1max, u)
PhiT = Phi'
Kr = transfm(K, Phi, PhiT)
@show size(Kr)
Krfactor = lu(Kr)
Kdinv = 1.0 ./ diag(K)
# invKrd = fill(0.0, size(K, 1))
# for i in 1:size(K, 1)
# invKrd[i] = @views dot(vec(Phi[i, :]), Krfactor \ Vector(Phi[i, :]))
# end
# @show norm(invKrd), norm(Kdinv)
# Kdinv .*= norm(invKrd) / norm(Kdinv)
# trace1 = scatter(x = 1:length(invKrd),
# y = invKrd,
# mode="points",
# line_width=1.5,
# line_color="RoyalBlue")
# trace2 = scatter(x = 1:length(invKrd),
# y = Kdinv,
# mode="lines",
# line_width=1.5,
# line_color="red")
# data = [trace1, trace2]
# # data = [trace2]
# layout = Layout(;title="Diagonals")
# display(plot(data, layout))
Ur = Phi * (Krfactor \ (PhiT * F))
scattersysvec!(u, Ur[:])
utip = mean(u.values[Tipl, 3], dims = 1)
println("First Guess of Deflection: $(utip), compared to $(uzex)")
R = F - K * Ur
n = size(K, 1)
# morprecondnomix(y, v) = begin
# y .= (Kdinv .* v) - (invKrd .* v) + (Phi * (Krfactor \ (PhiT * v)))
# end
opM = LinearOperator(
Float64,
n,
n,
false,
false,
(y, v) -> y .= mixprop .* (Kdinv .* v) .+ (Phi * (Krfactor \ (PhiT * v))),
)
U = deepcopy(Ur)
utipprev = utip
@time for iter = 1:50
@show iter
(DU, stats) = Krylov.cg(K, F - K * U; M = opM, itmax = 5, verbose = 0)
U += DU
@show norm(DU) / norm(U)
scattersysvec!(u, U[:])
utip = mean(u.values[Tipl, 3], dims = 1)
println("Iterated Deflection: $(utip), compared to $(uzex)")
if norm(utip - utipprev) / norm(utip) < rtol
break
end
utipprev = utip
end
elseif solver == :mor
Nc = 16
nbf1max = 4
mixprop = 0.05
partitioning = nodepartitioning(fens, Nc)
mor = CoNCData(fens, partitioning)
Phi = transfmatrix(mor, LegendreBasis, nbf1max, u)
PhiT = Phi'
Kr = transfm(K, Phi, PhiT)
@show size(Kr)
Ur = Phi * (Kr \ (PhiT * F))
scattersysvec!(u, Ur[:])
utip = mean(u.values[Tipl, 3], dims = 1)
println("First Guess of Deflection: $(utip), compared to $(uzex)")
Phi = hcat(Ur)
U = deepcopy(Ur)
Kd = Diagonal(diag(K))
n = size(K, 1)
for iter = 1:50
@show iter
Kr = transfm(K, Phi, Phi')
# Krd = Diagonal(diag(Phi * Kr * Phi'))
# @show mean(diag(Kd)), mean(diag(Krd))
# @show norm(diag(Kd) - diag(Krd)), norm(diag(Kd))
opM = LinearOperator(
Float64,
n,
n,
false,
false,
(y, v) -> morprecond3nomix(y, v, Phi, Kd, Kr, mixprop),
)
@time (DU, stats) = Krylov.cg(K, F - K * U; M = opM, itmax = 10, verbose = 0)
@show norm(DU) / norm(U)
Phi = hcat(Phi, DU)
factors = qr(Phi)
Phi = Matrix(factors.Q)
U += DU
scattersysvec!(u, U[:])
utip = mean(u.values[Tipl, 3], dims = 1)
println("Iterated Deflection: $(utip), compared to $(uzex)")
end
else
@error "Solver not recognized"
end
scattersysvec!(u, U[:])
utip = mean(u.values[Tipl, 3], dims = 1)
println("Deflection: $(utip), compared to $(uzex)")
File = "stubby_corbel_H8_big_ms.vtk"
vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
@async run(`"paraview.exe" $File`)
# modeldata["postprocessing"] = FDataDict("file"=>"hughes_cantilever_stresses_$(elementtag)", "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy, "component"=>[5])
# modeldata = exportstresselementwise(modeldata)
# modeldata["postprocessing"] = FDataDict("file"=>"hughes_cantilever_stresses_$(elementtag)",
# "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy,
# "component"=>collect(1:6))
# modeldata = exportstresselementwise(modeldata)
# stressfields = ElementalField[modeldata["postprocessing"]["exported"][1]["field"]]
true
end # stubby_corbel_H8_big_ms
function stubby_corbel_H8_big_ms_parallel(N = 10,
ntasks = Threads.nthreads(), assembly_only = false)
elementtag = "MSH8"
println("""
Stubby corbel example. Element: $(elementtag)
""")
times = Dict{String, Vector{Float64}}()
t1 = time()
fens, fes = H8block(W, L, H, N, 2 * N, 2 * N)
times["MeshGeneration"] = [time() - t1]
println("Number of elements: $(count(fes))")
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sectionL = selectelem(fens, bfes; facing = true, direction = [0.0 +1.0 0.0])
# 0 cross-section surface for the reactions
section0 = selectelem(fens, bfes; facing = true, direction = [0.0 -1.0 0.0])
# 0 cross-section surface for the reactions
sectionlateral = selectelem(fens, bfes; facing = true, direction = [1.0 0.0 0.0])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
# Material orientation matrix
csmat = [i == j ? one(Float64) : zero(Float64) for i = 1:3, j = 1:3]
function updatecs!(csmatout, XYZ, tangents, feid, qpid)
copyto!(csmatout, csmat)
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
lx0 = connectednodes(subset(bfes, section0))
setebc!(u, lx0, true, 1, 0.0)
setebc!(u, lx0, true, 2, 0.0)
setebc!(u, lx0, true, 3, 0.0)
lx1 = connectednodes(subset(bfes, sectionlateral))
setebc!(u, lx1, true, 1, 0.0)
applyebc!(u)
numberdofs!(u)
# numberdofs!(u)
println("nfreedofs(u) = $(nfreedofs(u))")
fi = ForceIntensity(Float64, 3, getfrcL!)
el2femm = FEMMBase(IntegDomain(subset(bfes, sectionL), GaussRule(2, 2)))
F = distribloads(el2femm, geom, u, fi, 2)
F_f = vector_blocked_f(F, nfreedofs(u))
function createsubdomain(fessubset)
FEMMDeforLinearMSH8(MR, IntegDomain(fessubset, GaussRule(3, 2)), material)
end
function matrixcomputation!(femm, assembler)
associategeometry!(femm, geom)
stiffness(femm, assembler, geom, u)
end
t1 = time()
n2e = FENodeToFEMap(fes.conn, nnodes(u))
times["FENodeToFEMap"] = [time() - t1]
println("Make node to element map = $(times["FENodeToFEMap"]) [s]")
println("Stiffness =============================================================")
GC.enable(false)
t0 = time();
t1 = time()
e2e = FEElemToNeighborsMap(n2e, fes)
times["FEElemToNeighborsMap"] = [time() - t1]
println(" Make element to neighbor map = $(times["FEElemToNeighborsMap"]) [s]")
t1 = time()
coloring = FinEtoolsMultithreading.element_coloring(fes, e2e)
times["ElementColors"] = [time() - t1]
println(" Compute element colors = $(times["ElementColors"]) [s]")
t1 = time()
n2n = FENodeToNeighborsMap(n2e, fes)
times["FENodeToNeighborsMap"] = [time() - t1]
println(" Make node to neighbor map = $(times["FENodeToNeighborsMap"]) [s]")
t1 = time()
K_pattern = sparse_symmetric_csc_pattern(u.dofnums, nalldofs(u), n2n, zero(eltype(u.values)))
times["SparsityPattern"] = [time() - t1]
println(" Sparsity pattern = $(times["SparsityPattern"]) [s]")
t1 = time()
decomposition = domain_decomposition(fes, coloring, createsubdomain, ntasks)
times["DomainDecomposition"] = [time() - t1]
println(" Domain decomposition = $(times["DomainDecomposition"]) [s]")
t1 = time()
K = parallel_matrix_assembly!(
SysmatAssemblerSparsePatt(K_pattern),
decomposition,
matrixcomputation!
)
times["AssemblyOfValues"] = [time() - t1]
println(" Add to matrix = $(times["AssemblyOfValues"]) [s]")
times["TotalAssembly"] = [time() - t0]
println("Assembly total = $(times["TotalAssembly"]) [s]")
GC.enable(true)
K_ff = matrix_blocked_ff(K, nfreedofs(u))
F_f = vector_blocked_f(F, nfreedofs(u))
println("Stiffness: number of non zeros = $(nnz(K_ff)) [ND]")
println("Sparsity = $(nnz(K_ff)/size(K_ff, 1)/size(K_ff, 2)) [ND]")
if assembly_only
isdir("$(N)") || mkdir("$(N)")
n = DataDrop.with_extension(joinpath("$(N)", "stubby_corbel_H8_big_ms_parallel-timing-nth=$(ntasks)"), "json")
if isfile(n)
storedtimes = DataDrop.retrieve_json(n)
for k in keys(storedtimes)
times[k] = cat(times[k], storedtimes[k], dims = 1)
end
end
DataDrop.store_json(n, times)
return
end
Tipl = selectnode(fens, box = [0 W L L 0 H], inflate = htol)
@show norm(K_ff - K_ff') / norm(K_ff)
@time K_ff_factors = SuiteSparse.CHOLMOD.cholesky(Symmetric(K_ff))
@show nnz(K_ff_factors)
# @time K = SparseArrays.ldlt(K)
# @time K = cholesky(K)
@time U_f = K_ff_factors \ (F_f)
scattersysvec!(u, U_f[:])
utip = mean(u.values[Tipl, 3], dims = 1)
println("Deflection: $(utip), compared to $(uzex)")
File = "stubby_corbel_H8_big_ms.vtk"
vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
# @async run(`"paraview.exe" $File`)
# modeldata["postprocessing"] = FDataDict("file"=>"hughes_cantilever_stresses_$(elementtag)", "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy, "component"=>[5])
# modeldata = exportstresselementwise(modeldata)
# modeldata["postprocessing"] = FDataDict("file"=>"hughes_cantilever_stresses_$(elementtag)",
# "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy,
# "component"=>collect(1:6))
# modeldata = exportstresselementwise(modeldata)
# stressfields = ElementalField[modeldata["postprocessing"]["exported"][1]["field"]]
true
end # stubby_corbel_H8_big_ms
function stubby_corbel_H8_big_ms_serial(N = 10, assembly_only = false)
elementtag = "MSH8"
println("""
Stubby corbel example. Element: $(elementtag). SERIAL
""")
times = Dict{String, Vector{Float64}}()
t1 = time()
fens, fes = H8block(W, L, H, N, 2 * N, 2 * N)
times["MeshGeneration"] = [time() - t1]
println("Number of elements: $(count(fes))")
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sectionL = selectelem(fens, bfes; facing = true, direction = [0.0 +1.0 0.0])
# 0 cross-section surface for the reactions
section0 = selectelem(fens, bfes; facing = true, direction = [0.0 -1.0 0.0])
# 0 cross-section surface for the reactions
sectionlateral = selectelem(fens, bfes; facing = true, direction = [1.0 0.0 0.0])
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, CTE)
# Material orientation matrix
csmat = [i == j ? one(Float64) : zero(Float64) for i = 1:3, j = 1:3]
function updatecs!(csmatout, XYZ, tangents, feid, qpid)
copyto!(csmatout, csmat)
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
lx0 = connectednodes(subset(bfes, section0))
setebc!(u, lx0, true, 1, 0.0)
setebc!(u, lx0, true, 2, 0.0)
setebc!(u, lx0, true, 3, 0.0)
lx1 = connectednodes(subset(bfes, sectionlateral))
setebc!(u, lx1, true, 1, 0.0)
applyebc!(u)
numberdofs!(u)
# numberdofs!(u)
println("nfreedofs(u) = $(nfreedofs(u))")
fi = ForceIntensity(Float64, 3, getfrcL!)
el2femm = FEMMBase(IntegDomain(subset(bfes, sectionL), GaussRule(2, 2)))
F = distribloads(el2femm, geom, u, fi, 2)
F_f = vector_blocked_f(F, nfreedofs(u))
# femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
t0 = time()
t1 = time()
associategeometry!(femm, geom)
assembler = SysmatAssemblerSparse(1.0)
setnomatrixresult(assembler, true)
stiffness(femm, assembler, geom, u)
times["ComputeCOO"] = [time() - t1]
t1 = time()
setnomatrixresult(assembler, false)
K = makematrix!(assembler)
times["BuildCSR"] = [time() - t1]
times["TotalAssembly"] = [time() - t0]
println("Assembly total = $(times["TotalAssembly"]) [s]")
K_ff = matrix_blocked_ff(K, nfreedofs(u))
F_f = vector_blocked_f(F, nfreedofs(u))
println("Stiffness: number of non zeros = $(nnz(K_ff)) [ND]")
println("Sparsity = $(nnz(K_ff)/size(K_ff, 1)/size(K_ff, 2)) [ND]")
if assembly_only
isdir("$(N)") || mkdir("$(N)")
n = DataDrop.with_extension(joinpath("$(N)", "stubby_corbel_H8_big_ms_parallel-timing-serial"), "json")
if isfile(n)
storedtimes = DataDrop.retrieve_json(n)
for k in keys(storedtimes)
times[k] = cat(times[k], storedtimes[k], dims = 1)
end
end
DataDrop.store_json(n, times)
return
end
Tipl = selectnode(fens, box = [0 W L L 0 H], inflate = htol)
@show norm(K_ff - K_ff') / norm(K_ff)
@time K_ff_factors = SuiteSparse.CHOLMOD.cholesky(Symmetric(K_ff))
@show nnz(K_ff_factors)
# @time K = SparseArrays.ldlt(K)
# @time K = cholesky(K)
@time U_f = K_ff_factors \ (F_f)
scattersysvec!(u, U_f[:])
utip = mean(u.values[Tipl, 3], dims = 1)
println("Deflection: $(utip), compared to $(uzex)")
File = "stubby_corbel_H8_big_ms.vtk"
vtkexportmesh(File, fens, fes; vectors = [("u", u.values)])
# @async run(`"paraview.exe" $File`)
# modeldata["postprocessing"] = FDataDict("file"=>"hughes_cantilever_stresses_$(elementtag)", "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy, "component"=>[5])
# modeldata = exportstresselementwise(modeldata)
# modeldata["postprocessing"] = FDataDict("file"=>"hughes_cantilever_stresses_$(elementtag)",
# "outputcsys"=>CSys(3, 3, updatecs!), "quantity"=>:Cauchy,
# "component"=>collect(1:6))
# modeldata = exportstresselementwise(modeldata)
# stressfields = ElementalField[modeldata["postprocessing"]["exported"][1]["field"]]
true
end # stubby_corbel_H8_big_ms
function allrun()
println("#####################################################")
println("# stubby_corbel_H8_by_hand ")
stubby_corbel_H8_by_hand()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 26430 | module twisted_beam_examples
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtools.MeshExportModule
using Statistics
# The initially twisted cantilever beam is one of the standard test problems
# for verifying the finite-element accuracy [1]. The beam is clamped
# at one end and loaded either with unit in-plane or unit out-of-plane
# force at the other. The centroidal axis of the beam s straight at the
# undeformed configuration, while its cross-sections are twisted about the
# centroidal axis from 0 at the clamped end to pi/2 at the free end.
# Reference:
# Zupan D, Saje M (2004) On "A proposed standard set of problems to test
# finite element accuracy": the twisted beam. Finite Elements in Analysis
# and Design 40: 1445-1451.
function twisted_beam_algo()
E = 0.29e8
nu = 0.22
W = 1.1
L = 12.0
t = 0.32
nl = 2
nt = 1
nw = 1
ref = 7
p = 1 / W / t
# Loading in the Z direction
loadv = [0; 0; p]
dir = 3
uex = 0.005424534868469 # Harder: 5.424e-3;
# Loading in the Y direction
#loadv = [0;p;0]; dir = 2; uex = 0.001753248285256; # Harder: 1.754e-3;
tolerance = t / 1000
fens, fes = H20block(L, W, t, nl * ref, nw * ref, nt * ref)
# Reshape into a twisted beam shape
for i = 1:count(fens)
a = fens.xyz[i, 1] / L * (pi / 2)
y = fens.xyz[i, 2] - (W / 2)
z = fens.xyz[i, 3] - (t / 2)
fens.xyz[i, :] = [fens.xyz[i, 1], y * cos(a) - z * sin(a), y * sin(a) + z * cos(a)]
end
# Clamped end of the beam
l1 =
selectnode(fens; box = [0 0 -100 * W 100 * W -100 * W 100 * W], inflate = tolerance)
e1 = FDataDict("node_list" => l1, "component" => 1, "displacement" => 0.0)
e2 = FDataDict("node_list" => l1, "component" => 2, "displacement" => 0.0)
e3 = FDataDict("node_list" => l1, "component" => 3, "displacement" => 0.0)
# Traction on the opposite edge
boundaryfes = meshboundary(fes)
Toplist = selectelem(
fens,
boundaryfes,
box = [L L -100 * W 100 * W -100 * W 100 * W],
inflate = tolerance,
)
el1femm = FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(2, 2)))
flux1 = FDataDict("femm" => el1femm, "traction_vector" => loadv)
# Make the region
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 00.0, E, nu, 0.0)
region1 = FDataDict(
"femm" => FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material),
)
# Make model data
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [e1, e2, e3],
"traction_bcs" => [flux1],
)
# Call the solver
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
geom = modeldata["geom"]
u = modeldata["u"]
# Extract the solution
nl =
selectnode(fens, box = [L L -100 * W 100 * W -100 * W 100 * W], inflate = tolerance)
theutip = mean(u.values[nl, :], dims = 1)
println("displacement = $(theutip[dir]) as compared to converged $uex")
println("normalized displacement = $(theutip[dir]/uex*100) %")
# Write out mesh with displacements
modeldata["postprocessing"] = FDataDict("file" => "twisted_beam")
modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
# Write out mesh with stresses
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam", "quantity" => :Cauchy, "component" => :xy)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
# Write out mesh with stresses
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam", "quantity" => :Cauchy, "component" => :xz)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
# Write out mesh with von Mises stresses
modeldata["postprocessing"] = FDataDict("file" => "twisted_beam", "quantity" => :vm)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
# Write out mesh with von Mises stresses, elementwise
modeldata["postprocessing"] = FDataDict("file" => "twisted_beam-ew", "quantity" => :vm)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
vm = modeldata["postprocessing"]["exported"][1]["field"]
println("extremes of von Mises: $([minimum(vm.values), maximum(vm.values)])")
# Write out mesh with von Mises stresses, elementwise
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam-ew", "quantity" => :Cauchy, "component" => :xz)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
println("Done")
true
end # twisted_beam_algo
function twisted_beam_algo_stress()
E = 0.29e8
nu = 0.22
W = 1.1
L = 12.0
t = 0.32
nl = 2
nt = 1
nw = 1
ref = 4
p = 1 / W / t
# Loading in the Z direction
loadv = [0; 0; p]
dir = 3
uex = 0.005424534868469 # Harder: 5.424e-3;
# Loading in the Y direction
#loadv = [0;p;0]; dir = 2; uex = 0.001753248285256; # Harder: 1.754e-3;
tolerance = t / 1000
fens, fes = H20block(L, W, t, nl * ref, nw * ref, nt * ref)
# Reshape into a twisted beam shape
for i = 1:count(fens)
a = fens.xyz[i, 1] / L * (pi / 2)
y = fens.xyz[i, 2] - (W / 2)
z = fens.xyz[i, 3] - (t / 2)
fens.xyz[i, :] = [fens.xyz[i, 1], y * cos(a) - z * sin(a), y * sin(a) + z * cos(a)]
end
# Clamped end of the beam
l1 =
selectnode(fens; box = [0 0 -100 * W 100 * W -100 * W 100 * W], inflate = tolerance)
e1 = FDataDict("node_list" => l1, "component" => 1, "displacement" => 0.0)
e2 = FDataDict("node_list" => l1, "component" => 2, "displacement" => 0.0)
e3 = FDataDict("node_list" => l1, "component" => 3, "displacement" => 0.0)
# Traction on the opposite edge
boundaryfes = meshboundary(fes)
Toplist = selectelem(
fens,
boundaryfes,
box = [L L -100 * W 100 * W -100 * W 100 * W],
inflate = tolerance,
)
el1femm = FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(2, 2)))
flux1 = FDataDict("femm" => el1femm, "traction_vector" => loadv)
# Make the region
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 00.0, E, nu, 0.0)
region1 = FDataDict(
"femm" => FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material),
)
# Make model data
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [e1, e2, e3],
"traction_bcs" => [flux1],
)
# Call the solver
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
geom = modeldata["geom"]
u = modeldata["u"]
# Extract the solution
nl =
selectnode(fens, box = [L L -100 * W 100 * W -100 * W 100 * W], inflate = tolerance)
theutip = mean(u.values[nl, :], dims = 1)
println("displacement = $(theutip[dir]) as compared to converged $uex")
println("normalized displacement = $(theutip[dir]/uex*100) %")
# Write out mesh with displacements
modeldata["postprocessing"] = FDataDict("file" => "twisted_beam")
modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
# Write out mesh with stresses
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam", "quantity" => :Cauchy, "component" => :xy)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
# Write out mesh with stresses
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam", "quantity" => :Cauchy, "component" => :xz)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
# Write out mesh with von Mises stresses
modeldata["postprocessing"] = FDataDict("file" => "twisted_beam", "quantity" => :vm)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
# Write out mesh with von Mises stresses, elementwise
modeldata["postprocessing"] = FDataDict("file" => "twisted_beam-ew", "quantity" => :vm)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
vm = modeldata["postprocessing"]["exported"][1]["field"]
println("extremes of von Mises: $([minimum(vm.values), maximum(vm.values)])")
# Write out mesh with von Mises stresses, elementwise
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam-ew", "quantity" => :Cauchy, "component" => :xz)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
# Write out mesh with principal stresses, elementwise
modeldata["postprocessing"] = FDataDict(
"file" => "twisted_beam-principal-1-ew",
"quantity" => :princCauchy,
"component" => 1,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
ps = modeldata["postprocessing"]["exported"][1]["field"]
println(
"extremes of first principal stress: $([minimum(ps.values), maximum(ps.values)])",
)
# Write out mesh with principal stresses, elementwise
modeldata["postprocessing"] = FDataDict(
"file" => "twisted_beam-principal-3-ew",
"quantity" => :princCauchy,
"component" => 3,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
ps = modeldata["postprocessing"]["exported"][1]["field"]
println(
"extremes of third principal stress: $([minimum(ps.values), maximum(ps.values)])",
)
# Write out mesh with principal stresses, elementwise
modeldata["postprocessing"] = FDataDict(
"file" => "twisted_beam-press-ew",
"quantity" => :pressure,
"component" => 1,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
ps = modeldata["postprocessing"]["exported"][1]["field"]
println("extremes of pressure: $([minimum(ps.values), maximum(ps.values)])")
println("Done")
true
end # twisted_beam_algo_stress
function twisted_beam_export()
E = 0.29e8
nu = 0.22
W = 1.1
L = 12.0
t = 0.32
nl = 2
nt = 1
nw = 1
ref = 5
p = 1 / W / t
# Loading in the Z direction
loadv = [0; 0; p]
dir = 3
uex = 0.005424534868469 # Harder: 5.424e-3;
# Loading in the Y direction
#loadv = [0;p;0]; dir = 2; uex = 0.001753248285256; # Harder: 1.754e-3;
tolerance = t / 1000
fens, fes = H8block(L, W, t, nl * ref, nw * ref, nt * ref)
# Reshape into a twisted beam shape
for i = 1:count(fens)
a = fens.xyz[i, 1] / L * (pi / 2)
y = fens.xyz[i, 2] - (W / 2)
z = fens.xyz[i, 3] - (t / 2)
fens.xyz[i, :] = [fens.xyz[i, 1], y * cos(a) - z * sin(a), y * sin(a) + z * cos(a)]
end
# Clamped end of the beam
l1 =
selectnode(fens; box = [0 0 -100 * W 100 * W -100 * W 100 * W], inflate = tolerance)
e1 = FDataDict("node_list" => l1, "component" => 1, "displacement" => 0.0)
e2 = FDataDict("node_list" => l1, "component" => 2, "displacement" => 0.0)
e3 = FDataDict("node_list" => l1, "component" => 3, "displacement" => 0.0)
# Traction on the opposite edge
boundaryfes = meshboundary(fes)
Toplist = selectelem(
fens,
boundaryfes,
box = [L L -100 * W 100 * W -100 * W 100 * W],
inflate = tolerance,
)
el1femm = FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(2, 2)))
flux1 = FDataDict("femm" => el1femm, "traction_vector" => loadv)
# Make the region
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 00.0, E, nu, 0.0)
region1 = FDataDict(
"femm" => FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material),
)
# Make model data
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [e1, e2, e3],
"traction_bcs" => [flux1],
)
AE = AbaqusExporter("twisted_beam")
HEADING(AE, "Twisted beam example")
PART(AE, "part1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
ELEMENT(AE, "c3d8rh", "AllElements", 1, region1["femm"].integdomain.fes.conn)
ELEMENT(
AE,
"SFM3D4",
"TractionElements",
1 + count(region1["femm"].integdomain.fes),
flux1["femm"].integdomain.fes.conn,
)
NSET_NSET(AE, "l1", l1)
ORIENTATION(AE, "GlobalOrientation", vec([1.0 0 0]), vec([0 1.0 0]))
SOLID_SECTION(AE, "elasticity", "GlobalOrientation", "AllElements", "Hourglassctl")
SURFACE_SECTION(AE, "TractionElements")
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "elasticity")
ELASTIC(AE, E, nu)
SECTION_CONTROLS(AE, "Hourglassctl", "HOURGLASS=ENHANCED")
STEP_PERTURBATION_STATIC(AE)
BOUNDARY(AE, "ASSEM1.INSTNC1.l1", 1)
BOUNDARY(AE, "ASSEM1.INSTNC1.l1", 2)
BOUNDARY(AE, "ASSEM1.INSTNC1.l1", 3)
DLOAD(AE, "ASSEM1.INSTNC1.TractionElements", vec(flux1["traction_vector"]))
END_STEP(AE)
close(AE)
true
end # twisted_beam_export
function twisted_beam_export_nb()
E = 0.29e8
nu = 0.22
W = 1.1
L = 12.0
t = 0.32
nl = 2
nt = 1
nw = 1
ref = 4
p = 1 / W / t
# Loading in the Z direction
loadv = [0; 0; p]
dir = 3
uex = 0.005424534868469 # Harder: 5.424e-3;
# Loading in the Y direction
#loadv = [0;p;0]; dir = 2; uex = 0.001753248285256; # Harder: 1.754e-3;
tolerance = t / 1000
fens, fes = H8block(L, W, t, nl * ref, nw * ref, nt * ref)
# Reshape into a twisted beam shape
for i = 1:count(fens)
a = fens.xyz[i, 1] / L * (pi / 2)
y = fens.xyz[i, 2] - (W / 2)
z = fens.xyz[i, 3] - (t / 2)
fens.xyz[i, :] = [fens.xyz[i, 1], y * cos(a) - z * sin(a), y * sin(a) + z * cos(a)]
end
# Clamped end of the beam
l1 =
selectnode(fens; box = [0 0 -100 * W 100 * W -100 * W 100 * W], inflate = tolerance)
e1 = FDataDict("node_list" => l1, "component" => 1, "displacement" => 0.0)
e2 = FDataDict("node_list" => l1, "component" => 2, "displacement" => 0.0)
e3 = FDataDict("node_list" => l1, "component" => 3, "displacement" => 0.0)
# Traction on the opposite edge
boundaryfes = meshboundary(fes)
Toplist = selectelem(
fens,
boundaryfes,
box = [L L -100 * W 100 * W -100 * W 100 * W],
inflate = tolerance,
)
el1femm = FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(2, 2)))
flux1 = FDataDict("femm" => el1femm, "traction_vector" => loadv)
# Make the region
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 00.0, E, nu, 0.0)
region1 = FDataDict(
"femm" => FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material),
)
# Make model data
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [e1, e2, e3],
"traction_bcs" => [flux1],
)
AE = AbaqusExporter("twisted_beam")
# AE.ios = STDOUT;
HEADING(AE, "Twisted beam example")
PART(AE, "part1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
ELEMENT(AE, "c3d8rh", "AllElements", 1, region1["femm"].integdomain.fes.conn)
ELEMENT(
AE,
"SFM3D4",
"TractionElements",
1 + count(region1["femm"].integdomain.fes),
flux1["femm"].integdomain.fes.conn,
)
NSET_NSET(AE, "l1", l1)
ORIENTATION(AE, "GlobalOrientation", vec([1.0 0 0]), vec([0 1.0 0]))
SOLID_SECTION(AE, "elasticity", "GlobalOrientation", "AllElements", "Hourglassctl")
SURFACE_SECTION(AE, "TractionElements")
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "elasticity")
ELASTIC(AE, E, nu)
SECTION_CONTROLS(AE, "Hourglassctl", "HOURGLASS=ENHANCED")
STEP_PERTURBATION_STATIC(AE)
BOUNDARY(AE, "ASSEM1.INSTNC1.l1", 1)
BOUNDARY(AE, "ASSEM1.INSTNC1.l1", 2)
BOUNDARY(AE, "ASSEM1.INSTNC1.l1", 3)
DLOAD(AE, "ASSEM1.INSTNC1.TractionElements", vec(flux1["traction_vector"]))
END_STEP(AE)
close(AE)
end # twisted_beam_export_nb
function twisted_beam_msh8(dir = 2, ref = 7)
E = 0.29e8
nu = 0.22
W = 1.1
L = 12.0
t = 0.0032
nl = 12
nt = 1
nw = 1
p = 1 / W / t
if dir == 3
# Loading in the Z direction
loadv = [0; 0; p]
uex = 0.005424534868469 # Harder: 5.424e-3;
else
# Loading in the Y direction
loadv = [0; p; 0]
uex = 0.001753248285256 # Harder: 1.754e-3;
end
tolerance = t / 1000
fens, fes = H8block(L, W, t, nl * ref, nw * ref, nt * ref)
# Reshape into a twisted beam shape
for i = 1:count(fens)
a = fens.xyz[i, 1] / L * (pi / 2)
y = fens.xyz[i, 2] - (W / 2)
z = fens.xyz[i, 3] - (t / 2)
fens.xyz[i, :] = [fens.xyz[i, 1], y * cos(a) - z * sin(a), y * sin(a) + z * cos(a)]
end
# Clamped end of the beam
l1 =
selectnode(fens; box = [0 0 -100 * W 100 * W -100 * W 100 * W], inflate = tolerance)
e1 = FDataDict("node_list" => l1, "component" => 1, "displacement" => 0.0)
e2 = FDataDict("node_list" => l1, "component" => 2, "displacement" => 0.0)
e3 = FDataDict("node_list" => l1, "component" => 3, "displacement" => 0.0)
# Traction on the opposite edge
boundaryfes = meshboundary(fes)
Toplist = selectelem(
fens,
boundaryfes,
box = [L L -100 * W 100 * W -100 * W 100 * W],
inflate = tolerance,
)
el1femm = FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(2, 2)))
flux1 = FDataDict("femm" => el1femm, "traction_vector" => loadv)
# Make the region
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 00.0, E, nu, 0.0)
region1 = FDataDict(
"femm" => FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material),
)
# Make model data
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [e1, e2, e3],
"traction_bcs" => [flux1],
)
# Call the solver
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
geom = modeldata["geom"]
u = modeldata["u"]
# Extract the solution
nl =
selectnode(fens, box = [L L -100 * W 100 * W -100 * W 100 * W], inflate = tolerance)
theutip = mean(u.values[nl, :], dims = 1)
println("displacement = $(theutip[dir]) as compared to converged $uex")
# Write out mesh with displacements
modeldata["postprocessing"] = FDataDict("file" => "twisted_beam_msh8")
modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
# Write out mesh with stresses
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam_msh8", "quantity" => :Cauchy, "component" => :xy)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
# Write out mesh with stresses
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam_msh8", "quantity" => :Cauchy, "component" => :xz)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
# Write out mesh with von Mises stresses
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam_msh8", "quantity" => :vm)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
vm = modeldata["postprocessing"]["exported"][1]["field"]
println("extremes of vm, nodal: $([minimum(vm.values), maximum(vm.values)])")
# Write out mesh with von Mises stresses, elementwise
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam_msh8-ew", "quantity" => :vm)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
vm = modeldata["postprocessing"]["exported"][1]["field"]
println("extremes of vm, elemental: $([minimum(vm.values), maximum(vm.values)])")
# Write out mesh with von Mises stresses, elementwise
modeldata["postprocessing"] = FDataDict(
"file" => "twisted_beam_msh8-ew",
"quantity" => :Cauchy,
"component" => :xz,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
println("Done")
true
end # twisted_beam_msh8
function twisted_beam_msh8_algo_stress()
println("""
""")
E = 0.29e8
nu = 0.22
W = 1.1
L = 12.0
t = 0.32
nl = 2
nt = 1
nw = 1
ref = 4
p = 1 / W / t
# Loading in the Z direction
loadv = [0; 0; p]
dir = 3
uex = 0.005424534868469 # Harder: 5.424e-3;
# Loading in the Y direction
#loadv = [0;p;0]; dir = 2; uex = 0.001753248285256; # Harder: 1.754e-3;
tolerance = t / 1000
fens, fes = H8block(L, W, t, nl * ref, nw * ref, nt * ref)
# Reshape into a twisted beam shape
for i = 1:count(fens)
a = fens.xyz[i, 1] / L * (pi / 2)
y = fens.xyz[i, 2] - (W / 2)
z = fens.xyz[i, 3] - (t / 2)
fens.xyz[i, :] = [fens.xyz[i, 1], y * cos(a) - z * sin(a), y * sin(a) + z * cos(a)]
end
# Clamped end of the beam
l1 =
selectnode(fens; box = [0 0 -100 * W 100 * W -100 * W 100 * W], inflate = tolerance)
e1 = FDataDict("node_list" => l1, "component" => 1, "displacement" => 0.0)
e2 = FDataDict("node_list" => l1, "component" => 2, "displacement" => 0.0)
e3 = FDataDict("node_list" => l1, "component" => 3, "displacement" => 0.0)
# Traction on the opposite edge
boundaryfes = meshboundary(fes)
Toplist = selectelem(
fens,
boundaryfes,
box = [L L -100 * W 100 * W -100 * W 100 * W],
inflate = tolerance,
)
el1femm = FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(2, 2)))
flux1 = FDataDict("femm" => el1femm, "traction_vector" => loadv)
# Make the region
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 00.0, E, nu, 0.0)
region1 = FDataDict(
"femm" => FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material),
)
# Make model data
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [e1, e2, e3],
"traction_bcs" => [flux1],
)
# Call the solver
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
geom = modeldata["geom"]
u = modeldata["u"]
# Extract the solution
nl =
selectnode(fens, box = [L L -100 * W 100 * W -100 * W 100 * W], inflate = tolerance)
theutip = mean(u.values[nl, :], dims = 1)
println("displacement = $(theutip[dir]) as compared to converged $uex")
println("normalized displacement = $(theutip[dir]/uex*100) %")
# Write out mesh with displacements
modeldata["postprocessing"] = FDataDict("file" => "twisted_beam")
modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
# Write out mesh with stresses
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam", "quantity" => :Cauchy, "component" => :xy)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
# Write out mesh with stresses
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam", "quantity" => :Cauchy, "component" => :xz)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
# Write out mesh with von Mises stresses
modeldata["postprocessing"] = FDataDict("file" => "twisted_beam", "quantity" => :vm)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
# Write out mesh with von Mises stresses, elementwise
modeldata["postprocessing"] = FDataDict("file" => "twisted_beam-ew", "quantity" => :vm)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
vm = modeldata["postprocessing"]["exported"][1]["field"]
println("extremes of von Mises: $([minimum(vm.values), maximum(vm.values)])")
# Write out mesh with von Mises stresses, elementwise
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam-ew", "quantity" => :Cauchy, "component" => :xz)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
# Write out mesh with principal stresses, elementwise
modeldata["postprocessing"] = FDataDict(
"file" => "twisted_beam-principal-1-ew",
"quantity" => :princCauchy,
"component" => 1,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
ps = modeldata["postprocessing"]["exported"][1]["field"]
println(
"extremes of first principal stress: $([minimum(ps.values), maximum(ps.values)])",
)
# Write out mesh with principal stresses, elementwise
modeldata["postprocessing"] = FDataDict(
"file" => "twisted_beam-principal-3-ew",
"quantity" => :princCauchy,
"component" => 3,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
ps = modeldata["postprocessing"]["exported"][1]["field"]
println(
"extremes of third principal stress: $([minimum(ps.values), maximum(ps.values)])",
)
# Write out mesh with principal stresses, elementwise
modeldata["postprocessing"] = FDataDict(
"file" => "twisted_beam-press-ew",
"quantity" => :pressure,
"component" => 1,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
ps = modeldata["postprocessing"]["exported"][1]["field"]
println("extremes of pressure: $([minimum(ps.values), maximum(ps.values)])")
println("Done")
true
end # twisted_beam_msh8_algo_stress
function allrun()
println("#####################################################")
println("# twisted_beam_algo ")
twisted_beam_algo()
println("#####################################################")
println("# twisted_beam_algo_stress ")
twisted_beam_algo_stress()
println("#####################################################")
println("# twisted_beam_export ")
twisted_beam_export()
println("#####################################################")
println("# twisted_beam_export_nb ")
twisted_beam_export_nb()
println("#####################################################")
println("# twisted_beam_msh8 ")
twisted_beam_msh8()
println("#####################################################")
println("# twisted_beam_msh8_algo_stress ")
twisted_beam_msh8_algo_stress()
return true
end # function allrun
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")
end # module stubby_corbel_examples
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 33727 | """
Module for algorithms used in linear deformation models.
"""
module AlgoDeforLinearModule
__precompile__(true)
using FinEtools.FTypesModule: FDataDict
using FinEtools.AlgoBaseModule: dcheck!
using Arpack: eigs
using SparseArrays: spzeros
using FinEtools.FieldModule:
AbstractField,
ndofs,
setebc!,
numberdofs!,
applyebc!,
scattersysvec!,
nalldofs,
nfreedofs,
gathersysvec
using FinEtools.NodalFieldModule: NodalField, nnodes
import FinEtools.FEMMBaseModule:
associategeometry!, distribloads, fieldfromintegpoints, elemfieldfromintegpoints
using FinEtoolsDeforLinear.FEMMDeforLinearBaseModule:
stiffness, mass, thermalstrainloads, inspectintegpoints
using FinEtoolsDeforLinear.FEMMDeforLinearMSModule:
stiffness, mass, thermalstrainloads, inspectintegpoints
using FinEtools.DeforModelRedModule: stresscomponentmap
using FinEtools.AlgoBaseModule: matrix_blocked, vector_blocked
using FinEtools.ForceIntensityModule: ForceIntensity
using FinEtools.MeshModificationModule: meshboundary
using FinEtools.MeshExportModule.VTK: vtkexportmesh
using LinearAlgebra: mul!, norm, eigen, qr, dot, cholesky, Symmetric
my_A_mul_B!(C, A, B) = mul!(C, A, B)
"""
AlgoDeforLinearModule.linearstatics(modeldata::FDataDict)
Algorithm for static linear deformation (stress) analysis.
# Argument
`modeldata` = dictionary with values for keys
- `"fens"` = finite element node set
- `"regions"` = array of region dictionaries
- `"essential_bcs"` = array of essential boundary condition dictionaries
- `"traction_bcs"` = array of traction boundary condition dictionaries
- `"temperature_change"` = dictionary of data for temperature change
For each region (connected piece of the domain made of a particular material),
mandatory, the region dictionary contains values for keys:
- `"femm"` = finite element model machine (mandatory);
For essential boundary conditions (optional) each dictionary
would hold
- `"displacement"` = fixed (prescribed) displacement (scalar), or
a function with signature function `w = f(x)`.
If this value is not given, zero displacement is assumed.
- `"component"` = which component is prescribed (1, 2, 3)?
- `"node_list"` = list of nodes on the boundary to which the condition applies
(mandatory)
For traction boundary conditions (optional) each dictionary
would hold key-value pairs
- `"femm"` = finite element model machine (mandatory);
- `"traction_vector"` = traction vector, either a constant numerical
vector, or a function to be used to construct a `ForceIntensity`
object, or it could be the `ForceIntensity` object itself.
# Output
`modeldata` = the dictionary on input is augmented with the keys
- `"geom"` = the nodal field that is the geometry
- `"u"` = the nodal field that is the computed displacement
- `"temp"` = the nodal field that is the temperature change
- `"work"` = work of the applied loads
- `"timing"` = dictionary with timing results
"""
function linearstatics(modeldata::FDataDict)
# Lists of recognized keys for the data dictionaries:
modeldata_recognized_keys = [
"fens",
"regions",
"essential_bcs",
"traction_bcs",
"temperature_change",
"factorize",
]
essential_bcs_recognized_keys = ["displacement", "node_list", "component"]
traction_bcs_recognized_keys = ["femm", "traction_vector"]
regions_recognized_keys = ["femm", "body_load"]
temperature_change_recognized_keys = ["temperature"]
# Extract the nodes
fens = get(() -> error("Must get fens!"), modeldata, "fens")
# Construct the geometry field
geom = NodalField(fens.xyz)
# Construct the displacement field
u = NodalField(zeros(nnodes(geom), ndofs(geom)))
UFT = eltype(u.values)
# Construct the temperature field
temp = NodalField(zeros(nnodes(geom), 1))
modeldata["timing"] = FDataDict()
tstart = time()
# Apply the essential boundary conditions on the displacement field
essential_bcs = get(modeldata, "essential_bcs", nothing)
if (essential_bcs !== nothing)
for j in eachindex(essential_bcs)
ebc = essential_bcs[j]
dcheck!(ebc, essential_bcs_recognized_keys)
fenids = get(() -> error("Must get node list!"), ebc, "node_list")
displacement = get(ebc, "displacement", nothing)
u_fixed = zeros(UFT, length(fenids)) # default is zero displacement
if (displacement !== nothing) # if it is nonzero,
if (typeof(displacement) <: Function) # it could be a function
for k in eachindex(fenids)
u_fixed[k] = displacement(geom.values[fenids[k], :])[1]
end
else # or it could be a constant
fill!(u_fixed, displacement)
end
end
component = get(ebc, "component", 0) # which component?
setebc!(u, fenids[:], true, component, u_fixed)
end
applyebc!(u)
end
# Number the equations
numberdofs!(u) #,Renumbering_options); # NOT DONE
modeldata["timing"]["essential_bcs"] = time() - tstart
tstart = time()
# Initialize the heat loads vector
F = zeros(UFT, nalldofs(u))
# Construct the system stiffness matrix
K = spzeros(nalldofs(u), nalldofs(u)) # (all zeros, for the moment)
regions = get(() -> error("Must get region list!"), modeldata, "regions")
for i in eachindex(regions)
region = regions[i]
dcheck!(region, regions_recognized_keys)
femm = region["femm"]
# Give the FEMM a chance to precompute geometry-related quantities
femm = associategeometry!(femm, geom)
# Add up all the conductivity matrices for all the regions
K = K + stiffness(femm, geom, u)
end
tstart = time()
# Process the traction boundary condition
traction_bcs = get(modeldata, "traction_bcs", nothing)
if (traction_bcs !== nothing)
for j in eachindex(traction_bcs)
tractionbc = traction_bcs[j]
dcheck!(tractionbc, traction_bcs_recognized_keys)
traction_vector = tractionbc["traction_vector"]
if (typeof(traction_vector) <: Function)
fi = ForceIntensity(UFT, ndofs(geom), traction_vector)
elseif (typeof(traction_vector) <: ForceIntensity)
fi = traction_vector
else
fi = ForceIntensity(traction_vector)
end
femm = tractionbc["femm"]
F = F + distribloads(femm, geom, u, fi, 2)
end
end
modeldata["timing"]["traction_bcs"] = time() - tstart
tstart = time()
# Process the thermal strain loading
temperature_change = get(modeldata, "temperature_change", nothing)
if (temperature_change !== nothing)
dcheck!(temperature_change, temperature_change_recognized_keys)
# zero temperature change is a reasonable default
temp = NodalField(zeros(size(fens.xyz, 1), 1))
temperature = get(temperature_change, "temperature", nothing)
if (temperature !== nothing) # if it is nonzero,
if (typeof(temperature) <: Function) # it could be a function
for k in eachindex(fens)
temp.values[k] = temperature(geom.values[k, :])[1]
end
else # or it could be a constant
fill!(temp.values, temperature)
end
end
for i in eachindex(regions)
region = regions[i]
femm = region["femm"]
F = F + thermalstrainloads(femm, geom, u, temp)
end
end
modeldata["timing"]["temperature_change"] = time() - tstart
K_ff, K_fd = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[(:ff, :fd)]
F_f = vector_blocked(F, nfreedofs(u))[:f]
U_d = gathersysvec(u, :d)
# Loads due to the essential boundary conditions on the displacement field
essential_bcs = get(modeldata, "essential_bcs", nothing)
if (essential_bcs !== nothing) # there was at least one EBC applied
F_f = F_f - K_fd * U_d
end
modeldata["timing"]["stiffness"] = time() - tstart
# # Process the body load
# body_load = get(modeldata, "body_load", nothing);
# if (body_load !=nothing)
# for j=1:length(model_data.body_load)
# body_load =model_data.body_load{j};
# femm = femm_deformation_linear (struct ('material',[],...
# 'fes',body_load.fes,...
# 'integration_rule',body_load.integration_rule));
# fi= force_intensity(struct('magn',body_load.force));
# F = F + distrib_loads(femm, sysvec_assembler, geom, u, fi, 3);
# end
# clear body_load fi femm
# end
# # Process the nodal force boundary condition
# if (isfield(model_data.boundary_conditions, 'nodal_force' ))
# for j=1:length(model_data.boundary_conditions.nodal_force)
# nodal_force =model_data.boundary_conditions.nodal_force{j};
# femm = femm_deformation_linear (struct ('material',[],...
# 'fes',fe_set_P1(struct('conn',reshape(nodal_force.node_list,[],1))),...
# 'integration_rule',point_rule));
# fi= force_intensity(struct('magn',nodal_force.force));
# F = F + distrib_loads(femm, sysvec_assembler, geom, u, fi, 0);
# end
# clear nodal_force fi femm
# end
# # Apply multi point constraints
# if isfield(model_data,'mpc')
# for i=1:length(model_data.mpc)
# mpc =model_data.mpc{i};
# dofnums=0*mpc.umultipliers;# Construct an array of the degree of freedom numbers
# for kx=1:length(mpc.node_list)
# dofnums(kx)=u.dofnums(mpc.node_list(kx),mpc.dof_list(kx));
# end
# # Now call the utility function to calculate the constraint matrix
# [Kmpc,Fmpc]=apply_penalty_mpc(nalldofs(u),dofnums,mpc.umultipliers,0.0,mpc.penfact);
# K = K + Kmpc;
# F = F + Fmpc;
# end
# clear Kmpc Fmpc
# end
tstart = time()
# Solve the system of linear algebraic equations
U_f = K_ff \ F_f
scattersysvec!(u, U_f)
modeldata["timing"]["solution"] = time() - tstart
U = gathersysvec(u, :a)
# Update the model data
setindex!(modeldata, geom, "geom")
setindex!(modeldata, u, "u")
setindex!(modeldata, temp, "temp")
setindex!(modeldata, temp, "dT")
setindex!(modeldata, dot(F, U) / 2, "work")
return modeldata # ... And return the updated model data
end
"""
AlgoDeforLinearModule.exportdeformation(modeldata::FDataDict)
Algorithm for exporting of the deformation for visualization in Paraview.
# Argument
`modeldata` = dictionary with values for keys
- `"fens"` = finite element node set
- `"regions"` = array of region dictionaries
- `"geom"` = geometry field
- `"u"` = displacement field, or
- `"us"` = array of tuples (name, displacement field)
- `"postprocessing"` = dictionary with values for keys
+ `"boundary_only"` = should only the boundary of the regions be rendered?
Default is render the interior.
+ `"file"` = name of the postprocessing file
For each region (connected piece of the domain made of a particular material),
mandatory, the region dictionary contains values for keys:
- `"femm"` = finite element mmodel machine (mandatory);
# Output
`modeldata` updated with
- `modeldata["postprocessing"]["exported"]` = array of data dictionaries, one for
each exported file. The data is stored with the keys:
+ `"file"` - names of exported file
+ `"field"` - nodal or elemental field
"""
function exportdeformation(modeldata::FDataDict)
modeldata_recognized_keys = ["fens", "regions", "geom", "u", "postprocessing"]
postprocessing_recognized_keys = ["boundary_only", "file"]
# Defaults
boundary_only = false
ffile = "deformation"
dcheck!(modeldata, modeldata_recognized_keys)
# Let's have a look at what's been specified
postprocessing = get(modeldata, "postprocessing", nothing)
if (postprocessing !== nothing)
dcheck!(postprocessing, postprocessing_recognized_keys)
boundary_only = get(postprocessing, "boundary_only", boundary_only)
ffile = get(postprocessing, "file", ffile)
end
fens = get(() -> error("Must get fens!"), modeldata, "fens")
geom = get(() -> error("Must get geometry field!"), modeldata, "geom")
u = get(modeldata, "u", nothing)
UFT = eltype(u.values)
us = get(modeldata, "us", nothing)
if us === nothing
us = [("u", u)]
end
# Export one file for each region
modeldata["postprocessing"]["exported"] = Array{FDataDict,1}()
regions = get(() -> error("Must get region!"), modeldata, "regions")
for i in eachindex(regions)
region = regions[i]
femm = region["femm"]
rfile = ffile * "$i" * ".vtk"
vectors = Tuple{String,Matrix{UFT}}[]
for ixxxx in eachindex(us)
push!(vectors, (us[ixxxx][1], us[ixxxx][2].values))
end
if boundary_only
bfes = meshboundary(femm.integdomain.fes)
vtkexportmesh(rfile, fens, bfes; vectors = vectors)
else
vtkexportmesh(rfile, fens, femm.integdomain.fes; vectors = vectors)
end
ed = FDataDict(
"file" => rfile,
"field" => u,
"region" => i,
"type" => "displacement",
)
push!(modeldata["postprocessing"]["exported"], ed)
end
return modeldata
end
"""
AlgoDeforLinearModule.exportstress(modeldata::FDataDict)
Algorithm for exporting of the stress for visualization in Paraview.
# Argument
`modeldata` = dictionary with values for keys
- `"fens"` = finite element node set
- `"regions"` = array of region dictionaries
- `"geom"` = geometry field
- `"u"` = displacement field
- `"postprocessing"` = dictionary with values for keys
+ `"boundary_only"` = should only the boundary of the regions be rendered?
Default is render the interior.
+ `"file"` = name of the postprocessing file
+ `"quantity"` = quantity to be exported (default `:Cauchy`)
+ `"component"` = which component of the quantity?
+ `"outputcsys"` = output coordinate system
+ `"inspectormeth"` = inspector method to pass to `inspectintegpoints()`
+ `"extrap"` = method for extrapolating from the quadrature points to the nodes
within one element
For each region (connected piece of the domain made of a particular material),
mandatory, the region dictionary contains values for keys:
- `"femm"` = finite element mmodel machine (mandatory);
# Output
`modeldata` updated with
- `modeldata["postprocessing"]["exported"]` = array of data dictionaries, one for
each exported file. The data is stored with the keys:
+ `"file"` - name of exported file
+ `"field"` - nodal field
"""
function exportstress(modeldata::FDataDict)
modeldata_recognized_keys = ["fens", "regions", "geom", "u", "dT", "postprocessing"]
postprocessing_recognized_keys = [
"boundary_only",
"file",
"quantity",
"component",
"outputcsys",
"nodevalmethod",
"reportat",
]
# Defaults
boundary_only = false
ffile = "stress"
dcheck!(modeldata, modeldata_recognized_keys)
quantity = :Cauchy
component = 1
outputcsys = nothing
reportat = :default
nodevalmethod = :invdistance
# Let's have a look at what's been specified
postprocessing = get(modeldata, "postprocessing", nothing)
if (postprocessing !== nothing)
dcheck!(postprocessing, postprocessing_recognized_keys)
boundary_only = get(postprocessing, "boundary_only", boundary_only)
ffile = get(postprocessing, "file", ffile)
quantity = get(postprocessing, "quantity", quantity)
component = get(postprocessing, "component", component)
outputcsys = get(postprocessing, "outputcsys", outputcsys)
nodevalmethod = get(postprocessing, "nodevalmethod", nodevalmethod)
reportat = get(postprocessing, "reportat", reportat)
end
fens = get(() -> error("Must get fens!"), modeldata, "fens")
geom = get(() -> error("Must get geometry field!"), modeldata, "geom")
u = get(() -> error("Must get displacement field!"), modeldata, "u")
dT = get(modeldata, "dT", nothing)
context = []
if (outputcsys !== nothing)
push!(context, (:outputcsys, outputcsys))
end
if (nodevalmethod !== nothing)
push!(context, (:nodevalmethod, nodevalmethod))
end
if (reportat !== nothing)
push!(context, (:reportat, reportat))
end
# Export a file for each region
modeldata["postprocessing"]["exported"] = Array{FDataDict,1}()
regions = get(() -> error("Must get region!"), modeldata, "regions")
for i in eachindex(regions)
region = regions[i]
femm = region["femm"]
rfile = ffile * "-" * string(quantity) * string(component) * "-region $i" * ".vtk"
if (typeof(component) == Symbol)
componentnum = stresscomponentmap(femm.mr)[component]
else
componentnum = component
end
componentname = length(componentnum) > 1 ? "" : "$(componentnum)"
# Note that we are creating a field separately for each region. This is
# important for the following reason: if the regions were of different
# materials, or if they were of the same material but with different material
# axes orientation, averaging across the material interface would not make
# sense.
if (dT !== nothing)
fld =
fieldfromintegpoints(femm, geom, u, dT, quantity, componentnum; context...)
else
fld = fieldfromintegpoints(femm, geom, u, quantity, componentnum; context...)
end
if boundary_only
bfes = meshboundary(femm.integdomain.fes)
vtkexportmesh(
rfile,
fens,
bfes;
scalars = [(string(quantity) * componentname, fld.values)],
vectors = [("u", u.values)],
)
else
vtkexportmesh(
rfile,
fens,
femm.integdomain.fes;
scalars = [(string(quantity) * componentname, fld.values)],
vectors = [("u", u.values)],
)
end
ed = FDataDict(
"file" => rfile,
"field" => fld,
"region" => i,
"type" => "nodal stress",
"quantity" => quantity,
"component" => component,
"outputcsys" => outputcsys,
"nodevalmethod" => nodevalmethod,
"reportat" => reportat,
)
push!(modeldata["postprocessing"]["exported"], ed)
end
return modeldata
end
"""
AlgoDeforLinearModule.exportstresselementwise(modeldata::FDataDict)
Algorithm for exporting of the elementwise stress for visualization in Paraview.
# Argument
`modeldata` = dictionary with values for keys
- `"fens"` = finite element node set
- `"regions"` = array of region dictionaries
- `"geom"` = geometry field
- `"u"` = displacement field
- `"postprocessing"` = dictionary with values for keys
+ `"boundary_only"` = should only the boundary of the regions be rendered?
Default is render the interior.
+ `"file"` = name of the postprocessing file
+ `"quantity"` = quantity to be exported (default `:Cauchy`)
+ `"component"` = which component of the quantity?
+ `"outputcsys"` = output coordinate system
For each region (connected piece of the domain made of a particular material),
mandatory, the region dictionary contains values for keys:
- `"femm"` = finite element mmodel machine (mandatory);
# Output
`modeldata` updated with
- `modeldata["postprocessing"]["exported"]` = array of data dictionaries, one for
each exported file. The data is stored with the keys:
+ `"file"` - name of exported file
+ `"field"` - elemental field
"""
function exportstresselementwise(modeldata::FDataDict)
modeldata_recognized_keys = ["fens", "regions", "geom", "u", "dT", "postprocessing"]
postprocessing_recognized_keys =
["boundary_only", "file", "quantity", "component", "outputcsys"]
# Defaults
boundary_only = false
ffile = "stress"
dcheck!(modeldata, modeldata_recognized_keys)
quantity = :Cauchy
component = 1
outputcsys = nothing
# Let's have a look at what's been specified
postprocessing = get(modeldata, "postprocessing", nothing)
if (postprocessing !== nothing)
dcheck!(postprocessing, postprocessing_recognized_keys)
boundary_only = get(postprocessing, "boundary_only", boundary_only)
ffile = get(postprocessing, "file", ffile)
quantity = get(postprocessing, "quantity", quantity)
component = get(postprocessing, "component", component)
outputcsys = get(postprocessing, "outputcsys", outputcsys)
end
fens = get(() -> error("Must get fens!"), modeldata, "fens")
geom = get(() -> error("Must get geometry field!"), modeldata, "geom")
u = get(() -> error("Must get displacement field!"), modeldata, "u")
dT = get(modeldata, "dT", nothing)
context = []
if (outputcsys !== nothing)
push!(context, (:outputcsys, outputcsys))
end
# Export a file for each region
modeldata["postprocessing"]["exported"] = Array{FDataDict,1}()
regions = get(() -> error("Must get region!"), modeldata, "regions")
for i in eachindex(regions)
region = regions[i]
femm = region["femm"]
rfile = ffile * "-" * string(quantity) * string(component) * "-region $i" * ".vtk"
if (typeof(component) == Symbol)
componentnum = stresscomponentmap(femm.mr)[component]
else
componentnum = component
end
componentname = length(componentnum) > 1 ? "" : "$(componentnum)"
# Note that we are creating a field separately for each region. This is
# important for the following reason: if the regions were of different
# materials, or if they were of the same material but with different material
# axes orientation, averaging across the material interface would not make
# sense.
if (dT !== nothing)
fld = elemfieldfromintegpoints(
femm,
geom,
u,
dT,
quantity,
componentnum;
context...,
)
else
fld =
elemfieldfromintegpoints(femm, geom, u, quantity, componentnum; context...)
end
if boundary_only
bfes = meshboundary(femm.integdomain.fes)
vtkexportmesh(
rfile,
fens,
bfes;
scalars = [(string(quantity) * componentname, fld.values)],
vectors = [("u", u.values)],
)
else
vtkexportmesh(
rfile,
fens,
femm.integdomain.fes;
scalars = [(string(quantity) * componentname, fld.values)],
vectors = [("u", u.values)],
)
end
ed = FDataDict(
"file" => rfile,
"field" => fld,
"region" => i,
"type" => "elemental stress",
"quantity" => quantity,
"component" => component,
"outputcsys" => outputcsys,
)
push!(modeldata["postprocessing"]["exported"], ed)
end
return modeldata
end
"""
AlgoDeforLinearModule.modal(modeldata::FDataDict)
Modal (free-vibration) analysis solver.
# Argument
`modeldata` = dictionary with values for keys
- `"fens"` = finite element node set
- `"regions"` = array of region dictionaries
- `"essential_bcs"` = array of essential boundary condition dictionaries
For each region (connected piece of the domain made of a particular material),
mandatory, the region dictionary contains values for keys:
- `"femm"` = finite element mmodel machine (mandatory);
For essential boundary conditions (optional) each dictionary
would hold
- `"displacement"` = fixed (prescribed) displacement (scalar): only zero
displacement is allowed for modal analysis.
- `"component"` = which component is prescribed (1, 2, 3)?
- `"node_list"` = list of nodes on the boundary to which the condition applies
(mandatory)
Control parameters:
- `"neigvs"` = number of eigenvalues/eigenvectors to compute
- `"omega_shift"`= angular frequency shift for mass shifting
- `"use_lumped_mass"` = true or false? (Default is false: consistent mass)
# Output
`modeldata`= the dictionary on input is augmented with
- `"geom"` = the nodal field that is the geometry
- `"u"` = the nodal field that is the computed displacement
- `"neigvs"` = Number of computed eigenvectors
- `"W"` = Computed eigenvectors, neigvs columns
- `"omega"` = Computed angular frequencies, array of length neigvs # For multi point constraints (MPC) (optional):
- `"raw_eigenvalues"` = Raw computed eigenvalues # model_data.mpc= cell array of structs, each for one MPC.
"""
function modal(modeldata::FDataDict)
# For multi point constraints (MPC) (optional):
# model_data.mpc= cell array of structs, each for one MPC.
# mpc.node_list = list of node numbers involved in the MPC,
# mpc.dof_list= numbers of degrees of freedom for the nodes above,
# mpc.umultipliers=multipliers for the nodes above,
# mpc.penfact=the penalty factor to multiply the constraint matrix,
# The MPC looks like this: sum_i m_i u_{dof(i),node(i)} =0
# where m_i is the multiplier.
# Lists of recognized keys for the data dictionaries:
modeldata_recognized_keys =
["fens", "regions", "essential_bcs", "neigvs", "omega_shift", "use_lumped_mass"]
essential_bcs_recognized_keys = ["displacement", "node_list", "component"]
regions_recognized_keys = ["femm", "femm_stiffness", "femm_mass", "body_load"]
neigvs = get(modeldata, "neigvs", 7) # Number of eigenvalues
omega_shift = get(modeldata, "omega_shift", 0.0) # Mass shifting
use_factorization = get(modeldata, "use_factorization", false) # Factorization?
use_lumped_mass = get(modeldata, "use_lumped_mass", false) # Lumped mass?
# Extract the nodes
fens = get(() -> error("Must get fens!"), modeldata, "fens")
# Construct the geometry field
geom = NodalField(fens.xyz)
# Construct the displacement field
u = NodalField(zeros(nnodes(geom), ndofs(geom)))
UFT = eltype(u.values)
# Apply the essential boundary conditions on the displacement field
essential_bcs = get(modeldata, "essential_bcs", nothing)
if (essential_bcs !== nothing)
for j in eachindex(essential_bcs)
ebc = essential_bcs[j]
dcheck!(ebc, essential_bcs_recognized_keys)
fenids = get(() -> error("Must get node list!"), ebc, "node_list")
displacement = get(ebc, "displacement", nothing)
u_fixed = zeros(UFT, length(fenids)) # only zero displacement accepted
component = get(ebc, "component", 0) # which component?
setebc!(u, fenids[:], true, component, u_fixed)
end
applyebc!(u)
end
# Number the equations
numberdofs!(u) #,Renumbering_options); # NOT DONE
# Construct the system stiffness matrix
K = spzeros(nalldofs(u), nalldofs(u)) # (all zeros, for the moment)
regions = get(() -> error("Must get region list!"), modeldata, "regions")
for i in eachindex(regions)
region = regions[i]
dcheck!(region, regions_recognized_keys)
if "femm_stiffness" in keys(region)
femm = region["femm_stiffness"]
else
femm = get(() -> error("Must get femm or femm_stiffness!"), region, "femm")
end
# Give the FEMM a chance to precompute geometry-related quantities
femm = associategeometry!(femm, geom)
# Add up all the stiffness matrices for all the regions
K = K + stiffness(femm, geom, u)
end
# Construct the system mass matrix
M = spzeros(nalldofs(u), nalldofs(u)) # (all zeros, for the moment)
regions = get(() -> error("Must get region list!"), modeldata, "regions")
for i in eachindex(regions)
region = regions[i]
dcheck!(region, regions_recognized_keys)
if "femm_mass" in keys(region)
femm = region["femm_mass"]
else
femm = get(() -> error("Must get femm or femm_mass!"), region, "femm")
end
# Give the FEMM a chance to precompute geometry-related quantities
femm = associategeometry!(femm, geom)
# Add up all the mass matrices for all the regions
M = M + mass(femm, geom, u)
end
# Options for the eigenproblem solution
# Solve
# if (~ use_factorization )
# # This is one way of solving the eigenvalue problem, just pass the matrices
# [W,Omega]= eigs(K+omega_shift*M, M, neigvs, 'SM', evopts);
# else
# This form uses the factorized matrix and has the potential of being much faster
# Factorize the left-hand side matrix for efficiency (Choleski)
# [mA,status] = chol(K+omega_shift*M,'lower');#,'vector',prm
# if ( status ~= 0 ) error('Choleski factorization failed'), end
# clear K; # Not needed anymore
# mAt= mA';
# [W,Omega]= eigs(@(bv)mAt\(mA\bv), nalldofs(u), M, neigvs, 'SM', evopts);
# [W,Omega]= eigen(full(K+omega_shift*M), full(M));
K_ff = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[:ff]
M_ff = matrix_blocked(M, nfreedofs(u), nfreedofs(u))[:ff]
d, v, nconv = eigs(Symmetric(K_ff + omega_shift * M_ff), Symmetric(M_ff); nev = neigvs, which = :SM, explicittransform=:none)
# Subtract the mass-shifting Angular frequency
broadcast!(+, d, d, -omega_shift)
modeldata["raw_eigenvalues"] = d
# Better make sure the eigenvalues make sense: they should be all real.
if any(imag(d) .!= 0.0)
d = real.(d)
end
if any(real(d) .< 0.0)
d = abs.(d)
end
d = real.(d)
# Sort the angular frequencies by magnitude. Make sure all
# imaginary parts of the eigenvalues are removed.
ix = sortperm(d)
# Update the model data: store geometry
modeldata["geom"] = geom
# Store the displacement field
modeldata["u"] = u
# Number of computed eigenvectors
modeldata["neigvs"] = length(d)
# Computed eigenvectors: we are ignoring the imaginary part here
# because the modal analysis is presumed to have been performed for
# an undamped structure
modeldata["W"] = real(v[:, ix])
# Computed angular frequencies
modeldata["omega"] = sqrt.(d[ix])
return modeldata
end
"""
AlgoDeforLinearModule.exportmode(modeldata::FDataDict)
Algorithm for exporting of the mmode shape for visualization in Paraview.
# Argument
`modeldata` = dictionary with values for keys
- `"fens"` = finite element node set
- `"regions"` = array of region dictionaries
- `"geom"` = geometry field
- `"u"` = displacement field
- `"W"` = Computed free-vibration eigenvectors, `neigvs` columns
- `"omega"` = Computed free-vibration angular frequencies, array of length `neigvs`
- `"postprocessing"` = dictionary with values for keys
+ `"boundary_only"` = should only the boundary of the regions be rendered?
Default is render the interior.
+ `"file"` = name of the postprocessing file
+ `"mode"` = which mode should be visualized?
+ `"component"` = which component of the quantity?
+ `"outputcsys"` = output coordinate system
For each region (connected piece of the domain made of a particular material),
mandatory, the region dictionary contains values for keys:
- `"femm"` = finite element mmodel machine (mandatory);
# Output
`modeldata` updated with
- `modeldata["postprocessing"]["exported"]` = see `exportdeformation()`
"""
function exportmode(modeldata::FDataDict)
modeldata_recognized_keys =
["fens", "regions", "geom", "u", "omega", "W", "postprocessing"]
postprocessing_recognized_keys = ["boundary_only", "file", "mode"]
mode = 1
dcheck!(modeldata, modeldata_recognized_keys)
# Let's have a look at what's been specified
postprocessing = get(modeldata, "postprocessing", nothing)
if (postprocessing !== nothing)
dcheck!(postprocessing, postprocessing_recognized_keys)
mode = get(postprocessing, "mode", mode)
end
omega = modeldata["omega"]
# Scatter the desired mode
W = modeldata["W"]
if typeof(mode) <: Int
@assert 0 < mode <= length(omega) "Invalid mode number $mode"
scattersysvec!(modeldata["u"], W[:, mode])
else
us = Tuple{String,AbstractField}[]
u = modeldata["u"]
for ixxxx in mode
@assert 0 < ixxxx <= length(omega) "Invalid mode number $ixxxx"
scattersysvec!(u, W[:, ixxxx])
push!(us, ("mode_$(ixxxx)", deepcopy(u)))
end
modeldata["us"] = us
end
return exportdeformation(modeldata)
end
end
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 20589 | """
Base module for operations on interiors of domains to construct system matrices and
system vectors for linear deformation models.
"""
module FEMMDeforLinearBaseModule
__precompile__(true)
using FinEtools.FENodeSetModule: FENodeSet
using FinEtools.DataCacheModule: DataCache
using FinEtools.FESetModule: gradN!, nodesperelem, manifdim
using FinEtools.IntegDomainModule: IntegDomain, integrationdata, Jacobianvolume
using FinEtools.FieldModule:
ndofs,
gatherdofnums!,
gathervalues_asvec!,
gathervalues_asmat!,
nalldofs
using FinEtools.NodalFieldModule: NodalField, nnodes
using FinEtools.AssemblyModule:
AbstractSysvecAssembler,
AbstractSysmatAssembler,
SysmatAssemblerSparseSymm,
startassembly!,
assemble!,
makematrix!,
makevector!,
SysvecAssembler
using FinEtools.FEMMBaseModule: AbstractFEMM
import FinEtools.FEMMBaseModule: inspectintegpoints, bilform_dot, bilform_lin_elastic
using FinEtools.CSysModule: CSys, updatecsmat!, csmat
using FinEtools.DeforModelRedModule: nstressstrain, nthermstrain, blmat!, divmat, vgradmat
using FinEtools.MatrixUtilityModule:
add_btdb_ut_only!, complete_lt!, locjac!, add_nnt_ut_only!, add_btsigma!
using FinEtoolsDeforLinear.MatDeforModule: rotstressvec!
using FinEtools.MatModule: massdensity
using FinEtoolsDeforLinear.MatDeforLinearElasticModule:
tangentmoduli!, update!, thermalstrain!
using FinEtools.SurfaceNormalModule: SurfaceNormal, updatenormal!
using LinearAlgebra: Transpose, mul!
At_mul_B!(C, A, B) = mul!(C, Transpose(A), B)
A_mul_B!(C, A, B) = mul!(C, A, B)
using LinearAlgebra: norm, dot, I
using LinearAlgebra
"""
AbstractFEMMDeforLinear <: AbstractFEMMBase
Abstract type of FEMM for linear deformation.
"""
abstract type AbstractFEMMDeforLinear <: AbstractFEMM end
function _buffers(
self::AbstractFEMMDeforLinear,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {GFT,UFT}
fes = self.integdomain.fes
ndn = ndofs(u) # number of degrees of freedom per node
nne = nodesperelem(fes) # number of nodes for element
sdim = ndofs(geom) # number of space dimensions
mdim = manifdim(fes) # manifold dimension of the element
nstrs = nstressstrain(self.mr) # number of stresses
elmatdim = ndn * nne # dimension of the element matrix
# Prepare _buffers
ecoords = fill(zero(GFT), nne, ndofs(geom)) # array of Element coordinates
elmat = fill(zero(GFT), elmatdim, elmatdim) # element matrix -- buffer
dofnums = zeros(eltype(u.dofnums), elmatdim) # degree of freedom array -- buffer
loc = fill(zero(GFT), 1, sdim) # quadrature point location -- buffer
J = fill(zero(GFT), sdim, mdim) # Jacobian matrix -- buffer
csmatTJ = fill(zero(GFT), mdim, mdim) # intermediate result -- buffer
gradN = fill(zero(GFT), nne, mdim) # intermediate result -- buffer
D = fill(zero(GFT), nstrs, nstrs) # material stiffness matrix -- buffer
B = fill(zero(GFT), nstrs, elmatdim) # strain-displacement matrix -- buffer
DB = fill(zero(GFT), nstrs, elmatdim) # strain-displacement matrix -- buffer
elvecfix = fill(zero(UFT), elmatdim) # vector of prescribed displ. -- buffer
elvec = fill(zero(UFT), elmatdim) # element vector -- buffer
return ecoords, dofnums, loc, J, csmatTJ, gradN, D, B, DB, elmat, elvec, elvecfix
end
"""
mass(
self::AbstractFEMMDeforLinear,
assembler::A,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {A<:AbstractSysmatAssembler,GFT<:Number,UFT<:Number}
Compute the consistent mass matrix
This is a general routine for the abstract linear-deformation FEMM.
"""
function mass(
self::AbstractFEMMDeforLinear,
assembler::A,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {A<:AbstractSysmatAssembler,GFT<:Number,UFT<:Number}
cf = DataCache(massdensity(self.material) * LinearAlgebra.I(ndofs(u)))
return bilform_dot(self, assembler, geom, u, cf)
end
function mass(
self::AbstractFEMMDeforLinear,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {GFT<:Number,UFT<:Number}
assembler = SysmatAssemblerSparseSymm()
return mass(self, assembler, geom, u)
end
"""
stiffness(
self::FEMM,
assembler::A,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {FEMM<:AbstractFEMMDeforLinear,A<:AbstractSysmatAssembler,GFT<:Number,UFT<:Number}
Compute and assemble stiffness matrix.
!!! note "Only for homogeneous materials"
The material stiffness matrix is assumed to be the same at all the points of
the domain (homogeneous material).
"""
function stiffness(
self::FEMM,
assembler::A,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {FEMM<:AbstractFEMMDeforLinear,A<:AbstractSysmatAssembler,GFT<:Number,UFT<:Number}
sdim = ndofs(geom)
loc = fill(zero(GFT), 1, sdim)
nstrs = nstressstrain(self.mr)
D = fill(zero(GFT), nstrs, nstrs)
tangentmoduli!(self.material, D, 0.0, 0.0, loc, 0)
return bilform_lin_elastic(self, assembler, geom, u, self.mr, DataCache(D))
end
function stiffness(
self::FEMM,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {FEMM<:AbstractFEMMDeforLinear,GFT<:Number,UFT<:Number}
assembler = SysmatAssemblerSparseSymm()
return stiffness(self, assembler, geom, u)
end
"""
thermalstrainloads(
self::AbstractFEMMDeforLinear,
assembler::A,
geom::NodalField{GFT},
u::NodalField{UFT},
dT::NodalField{TFT},
) where {A<:AbstractSysvecAssembler,GFT<:Number,UFT<:Number,TFT<:Number}
Compute the thermal-strain load vector.
"""
function thermalstrainloads(
self::AbstractFEMMDeforLinear,
assembler::A,
geom::NodalField{GFT},
u::NodalField{UFT},
dT::NodalField{TFT},
) where {A<:AbstractSysvecAssembler,GFT<:Number,UFT<:Number,TFT<:Number}
fes = self.integdomain.fes
npts, Ns, gradNparams, w, pc = integrationdata(self.integdomain)
ecoords, dofnums, loc, J, csmatTJ, gradN, D, B, DB, elmat, elvec, elvecfix =
_buffers(self, geom, u)
t = 0.0
dt = 0.0
DeltaT = fill(zero(GFT), nodesperelem(fes))
strain = fill(zero(GFT), nstressstrain(self.mr)) # total strain -- buffer
thstrain = fill(zero(GFT), nthermstrain(self.mr)) # thermal strain -- buffer
thstress = fill(zero(GFT), nstressstrain(self.mr)) # thermal stress -- buffer
startassembly!(assembler, nalldofs(u))
for i in eachindex(fes) # Loop over elements
gathervalues_asvec!(dT, DeltaT, fes.conn[i])# retrieve element temperatures
if norm(DeltaT, Inf) != 0 # Is the thermal increment nonzero?
gathervalues_asmat!(geom, ecoords, fes.conn[i])
fill!(elvec, 0.0) # Initialize element matrix
for j = 1:npts # Loop over quadrature points
locjac!(loc, J, ecoords, Ns[j], gradNparams[j])
Jac = Jacobianvolume(self.integdomain, J, loc, fes.conn[i], Ns[j])
updatecsmat!(self.mcsys, loc, J, i, j)
At_mul_B!(csmatTJ, csmat(self.mcsys), J) # local Jacobian matrix
gradN!(fes, gradN, gradNparams[j], csmatTJ)#Do: gradN = gradNparams[j]/csmatTJ;
blmat!(self.mr, B, Ns[j], gradN, loc, csmat(self.mcsys))# strains in mater cs, displ in global cs
thermalstrain!(self.material, thstrain, dot(vec(Ns[j]), DeltaT))
thstress = update!(
self.material,
thstress,
thstress,
strain,
thstrain,
t,
dt,
loc,
fes.label[i],
:nothing,
)
add_btsigma!(elvec, B, (-1) * (Jac * w[j]), thstress)
end
gatherdofnums!(u, dofnums, fes.conn[i]) # retrieve degrees of freedom
assemble!(assembler, elvec, dofnums) # assemble element load vector
end
end # Loop over elements
return makevector!(assembler)
end
function thermalstrainloads(
self::AbstractFEMMDeforLinear,
geom::NodalField{GFT},
u::NodalField{UFT},
dT::NodalField{TFT},
) where {GFT<:Number,UFT<:Number,TFT<:Number}
assembler = SysvecAssembler()
return thermalstrainloads(self, assembler, geom, u, dT)
end
"""
inspectintegpoints(
self::FEMM,
geom::NodalField{GFT},
u::NodalField{UFT},
dT::NodalField{TFT},
felist::AbstractVector{IT},
inspector::F,
idat,
quantity = :Cauchy;
context...,
) where {
FEMM<:AbstractFEMMDeforLinear,
GFT<:Number,
UFT<:Number,
TFT<:Number,
IT<:Integer,
F<:Function,
}
Inspect integration point quantities.
# Arguments
- `geom` - reference geometry field
- `u` - displacement field
- `dT` - temperature difference field
- `felist` - indexes of the finite elements that are to be inspected:
The fes to be included are: `fes[felist]`.
- `context` - structure: see the update!() method of the material.
- `inspector` - functionwith the signature
idat = inspector(idat, j, conn, x, out, loc);
where
`idat` - a structure or an array that the inspector may
use to maintain some state, for instance minimum or maximum of
stress, `j` is the element number, `conn` is the element connectivity,
`out` is the output of the update!() method, `loc` is the location
of the integration point in the *reference* configuration.
# Return
The updated inspector data is returned.
"""
function inspectintegpoints(
self::FEMM,
geom::NodalField{GFT},
u::NodalField{UFT},
dT::NodalField{TFT},
felist::AbstractVector{IT},
inspector::F,
idat,
quantity = :Cauchy;
context...,
) where {
FEMM<:AbstractFEMMDeforLinear,
GFT<:Number,
UFT<:Number,
TFT<:Number,
IT<:Integer,
F<:Function,
}
fes = self.integdomain.fes
npts, Ns, gradNparams, w, pc = integrationdata(self.integdomain)
ecoords, dofnums, loc, J, csmatTJ, gradN, D, B, DB, elmat, elvec, elvecfix =
_buffers(self, geom, u)
# Sort out the output requirements
outputcsys = self.mcsys # default: report the stresses in the material coord system
for apair in pairs(context)
sy, val = apair
if sy == :outputcsys
outputcsys = val
end
end
t = 0.0
dt = 0.0
dTe = fill(zero(TFT), nodesperelem(fes)) # nodal temperatures -- buffer
ue = fill(zero(GFT), size(elmat, 1)) # array of node displacements -- buffer
nne = nodesperelem(fes) # number of nodes for element
sdim = ndofs(geom) # number of space dimensions
xe = fill(zero(GFT), nne, sdim) # array of node coordinates -- buffer
qpdT = 0.0 # node temperature increment
qpstrain = fill(zero(GFT), nstressstrain(self.mr), 1) # total strain -- buffer
qpthstrain = fill(zero(GFT), nthermstrain(self.mr)) # thermal strain -- buffer
qpstress = fill(zero(GFT), nstressstrain(self.mr)) # stress -- buffer
out1 = fill(zero(GFT), nstressstrain(self.mr)) # stress -- buffer
out = fill(zero(GFT), nstressstrain(self.mr))# output -- buffer
# Loop over all the elements and all the quadrature points within them
for ilist in eachindex(felist) # Loop over elements
i = felist[ilist]
gathervalues_asmat!(geom, ecoords, fes.conn[i])
gathervalues_asvec!(u, ue, fes.conn[i])# retrieve element displacements
gathervalues_asvec!(dT, dTe, fes.conn[i])# retrieve element temp. increments
for j in 1:npts # Loop over quadrature points
locjac!(loc, J, ecoords, Ns[j], gradNparams[j])
Jac = Jacobianvolume(self.integdomain, J, loc, fes.conn[i], Ns[j])
updatecsmat!(self.mcsys, loc, J, i, j)
At_mul_B!(csmatTJ, csmat(self.mcsys), J) # local Jacobian matrix
gradN!(fes, gradN, gradNparams[j], csmatTJ)
blmat!(self.mr, B, Ns[j], gradN, loc, csmat(self.mcsys))
updatecsmat!(outputcsys, loc, J, i, j)
# Quadrature point quantities
A_mul_B!(qpstrain, B, ue) # strain in material coordinates
qpdT = dot(vec(dTe), vec(Ns[j]))# Quadrature point temperature increment
thermalstrain!(self.material, qpthstrain, qpdT)
# Material updates the state and returns the output
out = update!(
self.material,
qpstress,
out,
vec(qpstrain),
qpthstrain,
t,
dt,
loc,
fes.label[i],
quantity,
)
if (quantity == :Cauchy) # Transform stress tensor, if that is "out"
(length(out1) >= length(out)) || (out1 = zeros(length(out)))
rotstressvec!(self.mr, out1, out, transpose(csmat(self.mcsys)))# To global coord sys
rotstressvec!(self.mr, out, out1, csmat(outputcsys))# To output coord sys
end
# Call the inspector
idat = inspector(idat, i, fes.conn[i], ecoords, out, loc)
end # Loop over quadrature points
end # Loop over elements
return idat # return the updated inspector data
end
function inspectintegpoints(
self::FEMM,
geom::NodalField{GFT},
u::NodalField{UFT},
felist::AbstractVector{IT},
inspector::F,
idat,
quantity = :Cauchy;
context...,
) where {FEMM<:AbstractFEMMDeforLinear,GFT<:Number,UFT<:Number,IT,F<:Function}
dT = NodalField(fill(zero(GFT), nnodes(geom), 1)) # zero difference in temperature
return inspectintegpoints(
self,
geom,
u,
dT,
felist,
inspector,
idat,
quantity;
context...,
)
end
function _buffers2(
self::AbstractFEMMDeforLinear,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {GFT,UFT}
fes = self.integdomain.fes
ndn = ndofs(u) # number of degrees of freedom per node
nne = nodesperelem(fes) # number of nodes for element
sdim = ndofs(geom) # number of space dimensions
mdim = manifdim(fes) # manifold dimension of the element
nstrs = nstressstrain(self.mr) # number of stresses
elmatdim = ndn * nne # dimension of the element matrix
# Prepare buffers
ecoords = fill(zero(GFT), nne, ndofs(geom)) # array of Element coordinates
elmat = fill(zero(GFT), elmatdim, elmatdim) # element matrix -- buffer
dofnums = zeros(eltype(u.dofnums), elmatdim) # degree of freedom array -- buffer
loc = fill(zero(GFT), 1, sdim) # quadrature point location -- buffer
J = fill(zero(GFT), sdim, mdim) # Jacobian matrix -- buffer
csmatTJ = fill(zero(GFT), mdim, mdim) # intermediate result -- buffer
gradN = fill(zero(GFT), nne, mdim) # intermediate result -- buffer
return ecoords, dofnums, loc, J, csmatTJ, gradN, elmat
end
"""
infsup_gh(
self::AbstractFEMMDeforLinear,
assembler::A,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {A<:AbstractSysmatAssembler,GFT,UFT}
Compute the matrix to produce the norm of the divergence of the displacement.
This matrix is used in the numerical infsup test (Klaus-Jurgen Bathe, The
inf-sup condition and its evaluation for mixed finite element methods, Computers
and Structures 79 (2001) 243-252.)
!!! note
This computation has not been optimized in any way.
It can be expected to be inefficient.
"""
function infsup_gh(
self::AbstractFEMMDeforLinear,
assembler::A,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {A<:AbstractSysmatAssembler,GFT,UFT}
fes = self.integdomain.fes
npts, Ns, gradNparams, w, pc = integrationdata(self.integdomain)
ecoords, dofnums, loc, J, csmatTJ, gradN, elmat = _buffers2(self, geom, u)
startassembly!(assembler, size(elmat)..., count(fes), nalldofs(u), nalldofs(u))
for i in eachindex(fes) # Loop over elements
gathervalues_asmat!(geom, ecoords, fes.conn[i])
fill!(elmat, 0.0) # Initialize element matrix
for j = 1:npts # Loop over quadrature points
locjac!(loc, J, ecoords, Ns[j], gradNparams[j])
Jac = Jacobianvolume(self.integdomain, J, loc, fes.conn[i], Ns[j])
updatecsmat!(self.mcsys, loc, J, i, j)
At_mul_B!(csmatTJ, csmat(self.mcsys), J) # local Jacobian matrix
gradN!(fes, gradN, gradNparams[j], csmatTJ)
divm = divmat(self.mr, Ns[j], gradN, loc)
elmat += (transpose(divm) * divm) * (Jac * w[j])
end # Loop over quadrature points
gatherdofnums!(u, dofnums, fes.conn[i]) # retrieve degrees of freedom
assemble!(assembler, (elmat + elmat') / 2, dofnums, dofnums) # assemble symmetric matrix
end # Loop over elements
return makematrix!(assembler)
end
function infsup_gh(
self::AbstractFEMMDeforLinear,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {GFT,UFT}
assembler = SysmatAssemblerSparseSymm()
return infsup_gh(self, assembler, geom, u)
end
function _buffers3(
self::AbstractFEMMDeforLinear,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {GFT,UFT}
fes = self.integdomain.fes
ndn = ndofs(u) # number of degrees of freedom per node
nne = nodesperelem(fes) # number of nodes for element
sdim = ndofs(geom) # number of space dimensions
mdim = manifdim(fes) # manifold dimension of the element
nstrs = nstressstrain(self.mr) # number of stresses
elmatdim = ndn * nne # dimension of the element matrix
# Prepare buffers
ecoords = fill(zero(GFT), nne, ndofs(geom)) # array of Element coordinates
elmat = fill(zero(GFT), elmatdim, elmatdim) # element matrix -- buffer
dofnums = zeros(eltype(u.dofnums), elmatdim) # degree of freedom array -- buffer
loc = fill(zero(GFT), 1, sdim) # quadrature point location -- buffer
J = fill(zero(GFT), sdim, mdim) # Jacobian matrix -- buffer
csmatTJ = fill(zero(GFT), mdim, mdim) # intermediate result -- buffer
gradN = fill(zero(GFT), nne, mdim) # intermediate result -- buffer
return ecoords, dofnums, loc, J, csmatTJ, gradN, elmat
end
"""
infsup_sh(
self::AbstractFEMMDeforLinear,
assembler::A,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {A<:AbstractSysmatAssembler,GFT<:Number,UFT<:Number}
Compute the matrix to produce the seminorm of the displacement (square root of
the sum of the squares of the derivatives of the components of displacement).
This matrix is used in the numerical infsup test (Klaus-Jurgen Bathe, The
inf-sup condition and its evaluation for mixed finite element methods, Computers
and Structures 79 (2001) 243-252.)
!!! note
This computation has not been optimized in any way. It can be expected to be inefficient.
"""
function infsup_sh(
self::AbstractFEMMDeforLinear,
assembler::A,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {A<:AbstractSysmatAssembler,GFT<:Number,UFT<:Number}
fes = self.integdomain.fes
npts, Ns, gradNparams, w, pc = integrationdata(self.integdomain)
ecoords, dofnums, loc, J, csmatTJ, gradN, elmat = _buffers3(self, geom, u)
startassembly!(assembler, size(elmat)..., count(fes), nalldofs(u), nalldofs(u))
for i in eachindex(fes) # Loop over elements
gathervalues_asmat!(geom, ecoords, fes.conn[i])
fill!(elmat, 0.0) # Initialize element matrix
for j = 1:npts # Loop over quadrature points
locjac!(loc, J, ecoords, Ns[j], gradNparams[j])
Jac = Jacobianvolume(self.integdomain, J, loc, fes.conn[i], Ns[j])
updatecsmat!(self.mcsys, loc, J, i, j)
At_mul_B!(csmatTJ, csmat(self.mcsys), J) # local Jacobian matrix
gradN!(fes, gradN, gradNparams[j], csmatTJ)
vgradm = vgradmat(self.mr, Ns[j], gradN, loc)
elmat += (transpose(vgradm) * vgradm) * (Jac * w[j])
end # Loop over quadrature points
gatherdofnums!(u, dofnums, fes.conn[i]) # retrieve degrees of freedom
assemble!(assembler, (elmat + elmat') / 2, dofnums, dofnums) # assemble symmetric matrix
end # Loop over elements
return makematrix!(assembler)
end
function infsup_sh(
self::AbstractFEMMDeforLinear,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {GFT<:Number,UFT<:Number}
assembler = SysmatAssemblerSparseSymm()
return infsup_sh(self, assembler, geom, u)
end
end
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 35920 | """
Formulation for the small displacement, small strain deformation
model for Nodally-Integrated Continuum Elements (NICE).
The approximation is originally from Dohrmann et al IJNME 47 (2000).
The formulation was subsequently developed in Krysl, P. and Zhu, B.
Locking-free continuum displacement finite elements with nodal
integration, International Journal for Numerical Methods in Engineering,
76,7,1020-1043,2008.
The stabilization scheme comes from papers on energy-sampling stabilization
for mean-strain elements (Krysl and coauthors).
"""
module FEMMDeforLinearESNICEModule
__precompile__(true)
using FinEtools.FENodeSetModule: FENodeSet
using FinEtools.FESetModule: AbstractFESet, FESetH8, FESetT4, manifdim, nodesperelem, gradN!
using FinEtools.IntegDomainModule: IntegDomain, integrationdata, Jacobianvolume
using FinEtoolsDeforLinear.FEMMDeforLinearBaseModule: AbstractFEMMDeforLinear
using FinEtools.DeforModelRedModule: AbstractDeforModelRed, DeforModelRed3D
using FinEtoolsDeforLinear.MatDeforLinearElasticModule:
AbstractMatDeforLinearElastic, tangentmoduli!, update!, thermalstrain!
using FinEtoolsDeforLinear.MatDeforElastIsoModule: MatDeforElastIso
using FinEtools.FieldModule:
ndofs,
gatherdofnums!,
gathervalues_asvec!,
gathervalues_asmat!,
nalldofs
using FinEtools.NodalFieldModule: NodalField, nnodes
using FinEtools.CSysModule: CSys, updatecsmat!, csmat
using FinEtools.FENodeToFEMapModule: FENodeToFEMap
using FinEtools.DeforModelRedModule: nstressstrain, nthermstrain, blmat!, divmat, vgradmat
using FinEtools.AssemblyModule:
AbstractSysvecAssembler,
AbstractSysmatAssembler,
SysmatAssemblerSparseSymm,
startassembly!,
assemble!,
makematrix!,
makevector!,
SysvecAssembler
using FinEtools.MatrixUtilityModule:
add_btdb_ut_only!, complete_lt!, loc!, jac!, locjac!, adjugate3!
import FinEtoolsDeforLinear.FEMMDeforLinearBaseModule:
stiffness, mass, thermalstrainloads, inspectintegpoints
import FinEtools.FEMMBaseModule: associategeometry!
using FinEtoolsDeforLinear.MatDeforModule: rotstressvec!
using FinEtools.MatModule: massdensity
using LinearAlgebra: mul!, Transpose, UpperTriangular, eigvals, det
At_mul_B!(C, A, B) = mul!(C, Transpose(A), B)
A_mul_B!(C, A, B) = mul!(C, A, B)
using LinearAlgebra: norm, qr, diag, dot, cond, I, cross
using Statistics: mean
const StabParamFloat = Float64
"""
AbstractFEMMDeforLinearESNICE <: AbstractFEMMDeforLinear
Abstract FEMM type for Nodally Integrated Continuum Elements (NICE) with
energy-sampling stabilization (ESNICE).
"""
abstract type AbstractFEMMDeforLinearESNICE <: AbstractFEMMDeforLinear end
# Tetrahedron
# The coefficient set below was obtained by fitting the ratio of energies
# true/approximate for the finite element model of six tetrahedra arranged
# into a rectangular block and subject to pure bending
# Fitting for a small aspect-ratio range (1.0 to 10)
_T4_stabilization_parameters = (2.101588423297799, 1.311321055432958)
mutable struct _NodalBasisFunctionGradients{FT,IT}
gradN::Matrix{FT}
patchconn::Vector{IT}
Vpatch::FT
end
function _make_stabilization_material(material::M) where {M}
ns = fieldnames(typeof(material))
E = 0.0
nu = 0.0
if :E in ns
E = material.E
if material.nu < 0.3
nu = material.nu
else
nu = 0.3 + (material.nu - 0.3) / 2.0
end
else
if :E1 in ns
E = mean([material.E1, material.E2, material.E3])
nu = min(material.nu12, material.nu13, material.nu23)
else
error("No clues on how to construct the stabilization material")
end
end
return MatDeforElastIso(material.mr, 0.0, E, nu, 0.0)
end
"""
mutable struct FEMMDeforLinearESNICET4{
MR<:AbstractDeforModelRed,
ID<:IntegDomain{S} where {S<:FESetT4},
CS<:CSys,
M<:AbstractMatDeforLinearElastic,
MS<:MatDeforElastIso,
} <: AbstractFEMMDeforLinearESNICE
FEMM type for Energy-sampling Stabilized Nodally Integrated Continuum Elements
(ESNICE) based on the 4-node tetrahedron.
"""
mutable struct FEMMDeforLinearESNICET4{
MR<:AbstractDeforModelRed,
ID<:IntegDomain{S} where {S<:FESetT4},
CS<:CSys,
M<:AbstractMatDeforLinearElastic,
MS<:MatDeforElastIso,
} <: AbstractFEMMDeforLinearESNICE
mr::Type{MR}
integdomain::ID # geometry data
mcsys::CS # updater of the material orientation matrix
material::M # material object
stabilization_material::MS
nodalbasisfunctiongrad::Vector{_NodalBasisFunctionGradients}
ephis::Vector{StabParamFloat}
nphis::Vector{StabParamFloat}
end
"""
mutable struct FEMMDeforLinearESNICEH8{
MR<:AbstractDeforModelRed,
ID<:IntegDomain{S} where {S<:FESetH8},
CS<:CSys,
M<:AbstractMatDeforLinearElastic,
MS<:MatDeforElastIso,
} <: AbstractFEMMDeforLinearESNICE
FEMM type for Energy-sampling Stabilized Nodally Integrated Continuum Elements
(ESNICE) based on the 8-node hexahedron.
"""
mutable struct FEMMDeforLinearESNICEH8{
MR<:AbstractDeforModelRed,
ID<:IntegDomain{S} where {S<:FESetH8},
CS<:CSys,
M<:AbstractMatDeforLinearElastic,
MS<:MatDeforElastIso,
} <: AbstractFEMMDeforLinearESNICE
mr::Type{MR}
integdomain::ID # geometry data
mcsys::CS # updater of the material orientation matrix
material::M # material object
stabilization_material::MS
nodalbasisfunctiongrad::Vector{_NodalBasisFunctionGradients}
ephis::Vector{StabParamFloat}
nphis::Vector{StabParamFloat}
end
"""
FEMMDeforLinearESNICET4(
mr::Type{MR},
integdomain::ID,
mcsys::CS,
material::M,
) where {
MR<:AbstractDeforModelRed,
ID<:IntegDomain{S} where {S<:FESetT4},
CS<:CSys,
M<:AbstractMatDeforLinearElastic,
}
Constructor.
"""
function FEMMDeforLinearESNICET4(
mr::Type{MR},
integdomain::ID,
mcsys::CS,
material::M,
) where {
MR<:AbstractDeforModelRed,
ID<:IntegDomain{S} where {S<:FESetT4},
CS<:CSys,
M<:AbstractMatDeforLinearElastic,
}
@assert mr == material.mr "Model reduction is mismatched"
@assert (mr == DeforModelRed3D) "3D model required"
stabilization_material = _make_stabilization_material(material)
return FEMMDeforLinearESNICET4(
mr,
integdomain,
mcsys,
material,
stabilization_material,
_NodalBasisFunctionGradients[],
fill(zero(StabParamFloat), 1),
fill(zero(StabParamFloat), 1),
)
end
"""
FEMMDeforLinearESNICET4(
mr::Type{MR},
integdomain::ID,
material::M,
) where {
MR<:AbstractDeforModelRed,
ID<:IntegDomain{S} where {S<:FESetT4},
M<:AbstractMatDeforLinearElastic,
}
Constructor.
"""
function FEMMDeforLinearESNICET4(
mr::Type{MR},
integdomain::ID,
material::M,
) where {
MR<:AbstractDeforModelRed,
ID<:IntegDomain{S} where {S<:FESetT4},
M<:AbstractMatDeforLinearElastic,
}
@assert mr == material.mr "Model reduction is mismatched"
@assert (mr == DeforModelRed3D) "3D model required"
stabilization_material = _make_stabilization_material(material)
return FEMMDeforLinearESNICET4(
mr,
integdomain,
CSys(manifdim(integdomain.fes)),
material,
stabilization_material,
_NodalBasisFunctionGradients[],
fill(zero(StabParamFloat), 1),
fill(zero(StabParamFloat), 1),
)
end
"""
FEMMDeforLinearESNICEH8(
mr::Type{MR},
integdomain::ID,
mcsys::CS,
material::M,
) where {
MR<:AbstractDeforModelRed,
ID<:IntegDomain{S} where {S<:FESetH8},
CS<:CSys,
M<:AbstractMatDeforLinearElastic,
}
Constructor.
"""
function FEMMDeforLinearESNICEH8(
mr::Type{MR},
integdomain::ID,
mcsys::CS,
material::M,
) where {
MR<:AbstractDeforModelRed,
ID<:IntegDomain{S} where {S<:FESetH8},
CS<:CSys,
M<:AbstractMatDeforLinearElastic,
}
@assert mr == material.mr "Model reduction is mismatched"
@assert (mr == DeforModelRed3D) "3D model required"
stabilization_material = _make_stabilization_material(material)
return FEMMDeforLinearESNICEH8(
mr,
integdomain,
mcsys,
material,
stabilization_material,
_NodalBasisFunctionGradients[],
fill(zero(StabParamFloat), 1),
fill(zero(StabParamFloat), 1),
)
end
"""
FEMMDeforLinearESNICEH8(
mr::Type{MR},
integdomain::ID,
material::M,
) where {
MR<:AbstractDeforModelRed,
ID<:IntegDomain{S} where {S<:FESetH8},
M<:AbstractMatDeforLinearElastic,
}
Constructor.
"""
function FEMMDeforLinearESNICEH8(
mr::Type{MR},
integdomain::ID,
material::M,
) where {
MR<:AbstractDeforModelRed,
ID<:IntegDomain{S} where {S<:FESetH8},
M<:AbstractMatDeforLinearElastic,
}
@assert mr == material.mr "Model reduction is mismatched"
@assert (mr == DeforModelRed3D) "3D model required"
stabilization_material = _make_stabilization_material(material)
return FEMMDeforLinearESNICEH8(
mr,
integdomain,
CSys(manifdim(integdomain.fes)),
material,
stabilization_material,
_NodalBasisFunctionGradients[],
fill(zero(StabParamFloat), 1),
fill(zero(StabParamFloat), 1),
)
end
function _buffers1(self::FEMM, geom::NodalField{GFT}) where {FEMM<:AbstractFEMMDeforLinearESNICE,GFT}
fes = self.integdomain.fes
nne = nodesperelem(fes) # number of nodes for element
sdim = ndofs(geom) # number of space dimensions
mdim = manifdim(fes) # manifold dimension of the element
# Prepare buffers
loc = fill(zero(GFT), 1, sdim) # quadrature point location -- buffer
J = fill(zero(GFT), sdim, mdim) # Jacobian matrix -- buffer
adjJ = fill(zero(GFT), sdim, mdim) # Jacobian matrix -- buffer
csmatTJ = fill(zero(GFT), mdim, mdim) # intermediate result -- buffer
gradN = fill(zero(GFT), nne, mdim)
xl = fill(zero(GFT), nne, mdim)
return loc, J, adjJ, csmatTJ, gradN, xl
end
function _buffers2(
self::FEMM,
geom::NodalField{GFT},
u::NodalField,
npts::Int,
) where {FEMM<:AbstractFEMMDeforLinearESNICE,GFT}
fes = self.integdomain.fes
ndn = ndofs(u) # number of degrees of freedom per node
nne = nodesperelem(fes) # number of nodes for element
sdim = ndofs(geom) # number of space dimensions
mdim = manifdim(fes) # manifold dimension of the element
nstrs = nstressstrain(self.mr) # number of stresses
elmatdim = ndn * nne # dimension of the element matrix
# Prepare buffers
ecoords = fill(zero(GFT), nne, ndofs(geom)) # array of Element coordinates
dofnums = zeros(eltype(u.dofnums), elmatdim) # degree of freedom array -- buffer
loc = fill(zero(GFT), 1, sdim) # quadrature point location -- buffer
J = fill(zero(GFT), sdim, mdim) # Jacobian matrix -- buffer
csmatTJ = fill(zero(GFT), mdim, mdim) # intermediate result -- buffer
Jac = fill(zero(GFT), npts)
D = fill(zero(GFT), nstrs, nstrs) # material stiffness matrix -- buffer
Dstab = fill(zero(GFT), nstrs, nstrs) # material stiffness matrix -- buffer
elmat = fill(zero(GFT), elmatdim, elmatdim) # element matrix -- buffer
B = fill(zero(GFT), nstrs, elmatdim) # strain-displacement matrix -- buffer
return ecoords, dofnums, loc, J, csmatTJ, Jac, D, Dstab, elmat, B
end
function _buffers3(
self::FEMM,
geom::NodalField{GFT},
u::NodalField,
) where {FEMM<:AbstractFEMMDeforLinearESNICE,GFT}
fes = self.integdomain.fes
ndn = ndofs(u) # number of degrees of freedom per node
nne = nodesperelem(fes) # number of nodes for element
sdim = ndofs(geom) # number of space dimensions
mdim = manifdim(fes) # manifold dimension of the element
nstrs = nstressstrain(self.mr) # number of stresses
elmatdim = ndn * nne # dimension of the element matrix
# Prepare buffers
elmat = fill(zero(GFT), elmatdim, elmatdim) # element matrix -- buffer
dofnums = zeros(eltype(u.dofnums), elmatdim) # degree of freedom array -- buffer
B = fill(zero(GFT), nstrs, elmatdim) # strain-displacement matrix -- buffer
DB = fill(zero(GFT), nstrs, elmatdim) # strain-displacement matrix -- buffer
elvecfix = fill(zero(GFT), elmatdim) # vector of prescribed displ. -- buffer
elvec = fill(zero(GFT), elmatdim) # element vector -- buffer
gradN = fill(zero(GFT), nne, mdim) # intermediate result -- buffer
return dofnums, B, DB, elmat, elvec, elvecfix, gradN
end
function _patchconn(fes, gl, thisnn)
# Generate patch connectivity for a given node (thisnn)
# from the connectivities of the finite elements attached to it.
return vcat(
collect(setdiff(Set([i for j in eachindex(gl) for i in fes.conn[gl[j]]]), thisnn)),
[thisnn],
)
end
function _computenodalbfungrads(self, geom)
# # Compute the nodal basis function gradients.
# # Return the cell array of structures with attributes
# % bfun_gradients{nix}.Nspd= basis function gradient matrix
# # bfun_gradients{nix}.Vpatch= nodal patch volume
# # bfun_gradients{nix}.patchconn= nodal patch connectivity
fes = self.integdomain.fes
npts, Ns, gradNparams, w, pc = integrationdata(self.integdomain)
loc, J, adjJ, csmatTJ, gradN, xl = _buffers1(self, geom)
# Get the inverse map from finite element nodes to geometric cells
fen2fe = FENodeToFEMap(fes.conn, nnodes(geom))
# Initialize the nodal gradients, nodal patch, and patch connectivity
bfungrads =
fill(_NodalBasisFunctionGradients(fill(0.0, 0, 0), fill(0, 0), 0.0), nnodes(geom))
# Now loop over all finite element nodes in the map
lnmap = fill(0, length(fen2fe.map)) # Local node map: buffer to speed up operations
for nix in eachindex(fen2fe.map)
gl = fen2fe.map[nix]
thisnn = nix # We are at this node
if !isempty(gl) # This node has an element patch in this block
# establish local numbering of all nodes of the patch @ node thisnn
p = _patchconn(fes, gl, thisnn)
np = length(p)
lnmap[p] .= 1:np# now store the local numbers
c = reshape(geom.values[thisnn, :], 1, ndofs(geom))
updatecsmat!(self.mcsys, c, J, nix, 0)
gradNavg = fill(0.0, np, ndofs(geom))# preallocate strain-displacement matrix
Vpatch = 0.0
for k in eachindex(gl)
i = gl[k]
kconn = collect(fes.conn[i])
pci = findfirst(cx -> cx == thisnn, kconn)# at which node in the element are we with this quadrature point?
@assert 1 <= pci <= nodesperelem(fes)
# centered coordinates of nodes in the material coordinate system
for cn in eachindex(kconn)
xl[cn, :] =
(reshape(geom.values[kconn[cn], :], 1, ndofs(geom)) - c) *
csmat(self.mcsys)
end
jac!(J, xl, gradNparams[pci])
At_mul_B!(csmatTJ, csmat(self.mcsys), J) # local Jacobian matrix
Jac = Jacobianvolume(self.integdomain, J, c, fes.conn[i], Ns[pci])
Vpatch += Jac * w[pci]
sgradN = gradNparams[pci] * adjugate3!(adjJ, J)
gradNavg[lnmap[kconn], :] += (w[pci] .* sgradN)
end
@assert Vpatch != 0
gradNavg ./= Vpatch
bfungrads[nix] = _NodalBasisFunctionGradients(gradNavg, p, Vpatch)
lnmap[p] .= 0 # Restore the buffer to pristine condition
end
end
self.nodalbasisfunctiongrad = bfungrads
return self
end
function _tetaspectratiovol(X)
edge1 = vec(X[2, :] - X[1, :])
edge2 = vec(X[3, :] - X[1, :])
edge3 = vec(X[4, :] - X[1, :])
edge4 = vec(X[3, :] - X[2, :])
edge5 = vec(X[4, :] - X[3, :])
edge6 = vec(X[4, :] - X[2, :])
V = dot(edge3, cross(edge1, edge2))
A1 = norm(cross(edge1, edge2)) # This is twice the area of the triangle
A2 = norm(cross(edge2, edge3))
A3 = norm(cross(edge3, edge1))
A4 = norm(cross(edge4, edge6))
#h1, h2, h3, h4 = V/A1, V/A2, V/A3, V/A4
L1, L2, L3, L4, L5, L6 =
norm(edge1), norm(edge2), norm(edge3), norm(edge4), norm(edge5), norm(edge6)
# the heights and the edge lengths will now be used to derive a composite
# index: aspect ratio index. If this cannot be computed without generating
# not-a-number or infinity, this number is assumed to be better represented
# with 1.0 (perfect ratio), so that the element shape is then governed by
# the other aspect ratio values.
f = maximum
f([L1, L2, L4]) != 0.0 && A1 != 0.0 ? ar1 = V / A1 / f([L1, L2, L4]) : ar1 = 1.0
f([L3, L2, L5]) != 0.0 && A2 != 0.0 ? ar2 = V / A2 / f([L3, L2, L5]) : ar2 = 1.0
f([L1, L3, L6]) != 0.0 && A3 != 0.0 ? ar3 = V / A3 / f([L1, L3, L6]) : ar3 = 1.0
f([L6, L5, L4]) != 0.0 && A4 != 0.0 ? ar4 = V / A4 / f([L6, L5, L4]) : ar4 = 1.0
return ar1, ar2, ar3, ar4, V / 6
end
"""
associategeometry!(
self::FEMM,
geom::NodalField{GFT};
stabilization_parameters = _T4_stabilization_parameters,
) where {FEMM<:FEMMDeforLinearESNICET4,GFT}
Associate geometry field with the FEMM.
Compute the correction factors to account for the shape of the elements.
"""
function associategeometry!(
self::FEMM,
geom::NodalField{GFT};
stabilization_parameters = _T4_stabilization_parameters,
) where {FEMM<:FEMMDeforLinearESNICET4,GFT}
(a, b) = stabilization_parameters
fes = self.integdomain.fes
self.ephis = fill(zero(StabParamFloat), count(fes))
evols = fill(zero(StabParamFloat), count(fes))
self.nphis = fill(zero(StabParamFloat), nnodes(geom))
nvols = fill(zero(StabParamFloat), nnodes(geom))
for i = 1:count(fes) # Loop over elements
ar1, ar2, ar3, ar4, V = _tetaspectratiovol(geom.values[collect(fes.conn[i]), :])
evols[i] = V
# If the aspect ratios are not reasonable, such as when the element is a
# sliver or inverted, we turn off the stabilization for the element
# by setting its stabilization factor to zero.
if min(ar1, ar2, ar3, ar4) <= 0
self.ephis[i] = 0.0
else
self.ephis[i] = (1.0 / (b * min(ar1, ar2, ar3, ar4)^a) + 1.0)^(-1)
end
# Accumulate: the stabilization factor at the node is the weighted mean
# of the stabilization factors of the elements at that node
for k = 1:nodesperelem(fes)
nvols[fes.conn[i][k]] += evols[i]
self.nphis[fes.conn[i][k]] += self.ephis[i] * evols[i]
end
end # Loop over elements
@assert any(isnan.(self.ephis)) == false
# Now scale the values at the nodes with the nodal volumes
for k in eachindex(nvols)
if nvols[k] != 0.0
self.nphis[k] /= nvols[k]
end
end
@assert any(isnan.(self.nphis)) == false
# Now calculate the nodal basis function gradients
return _computenodalbfungrads(self, geom)
end
"""
associategeometry!(
self::FEMM,
geom::NodalField{GFT},
) where {FEMM<:FEMMDeforLinearESNICEH8,GFT}
Associate geometry field with the FEMM.
Compute the correction factors to account for the shape of the elements.
"""
function associategeometry!(
self::FEMM,
geom::NodalField{GFT},
) where {FEMM<:FEMMDeforLinearESNICEH8,GFT}
fes = self.integdomain.fes
self.ephis = fill(zero(StabParamFloat), count(fes))
evols = fill(zero(StabParamFloat), count(fes))
self.nphis = fill(zero(StabParamFloat), nnodes(geom))
nvols = fill(zero(StabParamFloat), nnodes(geom))
npts, Ns, gradNparams, w, pc = integrationdata(self.integdomain)
for i = 1:count(fes) # Loop over elements
X = geom.values[collect(fes.conn[i]), :]
V = 0.0
for j = 1:npts
J = X' * gradNparams[j]
Jac = det(J)
@assert Jac > 0 "Nonpositive Jacobian"
V = V + Jac * w[j]
hs = sum(J .* J; dims = 1)
phi = 2 * (1.0 + self.stabilization_material.nu) * minimum(hs) / maximum(hs)
self.ephis[i] = max(self.ephis[i], phi / (1 + phi))
end
evols[i] = V
# Accumulate: the stabilization factor at the node is the weighted mean of the stabilization factors of the elements at that node
for k = 1:nodesperelem(fes)
nvols[fes.conn[i][k]] += evols[i]
self.nphis[fes.conn[i][k]] += self.ephis[i] * evols[i]
end
end # Loop over elements
# Now scale the values at the nodes with the nodal volumes
for k in eachindex(nvols)
self.nphis[k] /= nvols[k]
end
# Now calculate the nodal basis function gradients
return _computenodalbfungrads(self, geom)
end
"""
stiffness(
self::FEMM,
assembler::A,
geom::NodalField{GFT},
u::NodalField{T},
) where {FEMM<:AbstractFEMMDeforLinearESNICE,A<:AbstractSysmatAssembler,GFT<:Number,T<:Number}
Compute and assemble stiffness matrix.
"""
function stiffness(
self::FEMM,
assembler::A,
geom::NodalField{GFT},
u::NodalField{T},
) where {FEMM<:AbstractFEMMDeforLinearESNICE,A<:AbstractSysmatAssembler,GFT<:Number,T<:Number}
fes = self.integdomain.fes
npts, Ns, gradNparams, w, pc = integrationdata(self.integdomain)
ecoords, dofnums, loc, J, csmatTJ, Jac, D, Dstab = _buffers2(self, geom, u, npts)
tangentmoduli!(self.material, D, 0.0, 0.0, loc, 0)
tangentmoduli!(self.stabilization_material, Dstab, 0.0, 0.0, loc, 0)
elmatsizeguess = 4 * nodesperelem(fes) * ndofs(u)
startassembly!(assembler, elmatsizeguess, elmatsizeguess, nnodes(u), nalldofs(u), nalldofs(u))
for nix = 1:length(self.nodalbasisfunctiongrad)
gradN = self.nodalbasisfunctiongrad[nix].gradN
patchconn = self.nodalbasisfunctiongrad[nix].patchconn
Vpatch = self.nodalbasisfunctiongrad[nix].Vpatch
c = reshape(geom.values[nix, :], 1, ndofs(geom))
updatecsmat!(self.mcsys, c, J, nix, 0)
nd = length(patchconn) * ndofs(u)
Bnodal = fill(0.0, size(D, 1), nd)
blmat!(self.mr, Bnodal, Ns[1], gradN, c, csmat(self.mcsys))
elmat = fill(0.0, nd, nd) # Can we SPEED it UP?
DB = fill(0.0, size(D, 1), nd)
add_btdb_ut_only!(elmat, Bnodal, Vpatch, D, DB)
add_btdb_ut_only!(elmat, Bnodal, -self.nphis[nix] * Vpatch, Dstab, DB)
complete_lt!(elmat)
dofnums = fill(0, nd)
gatherdofnums!(u, dofnums, patchconn) # retrieve degrees of freedom
assemble!(assembler, elmat, dofnums, dofnums) # assemble symmetric matrix
end # Loop over elements
Kn = makematrix!(assembler)
dofnums, B, DB, elmat, elvec, elvecfix, gradN = _buffers3(self, geom, u)
# OPTIMIZATION: switch to a single-point quadrature rule here
startassembly!(
assembler,
nodesperelem(fes) * ndofs(u),
nodesperelem(fes) * ndofs(u),
count(fes),
nalldofs(u),
nalldofs(u),
)
for i = 1:count(fes) # Loop over elements
gathervalues_asmat!(geom, ecoords, fes.conn[i])
fill!(elmat, 0.0) # Initialize element matrix
for j = 1:npts # Loop over quadrature points
locjac!(loc, J, ecoords, Ns[j], gradNparams[j])
Jac = Jacobianvolume(self.integdomain, J, loc, fes.conn[i], Ns[j])
# Do the following only if the element is well shaped and the
# stabilization factor is positive; if the element is so distorted
# that its Jacobian is non-positive, skip the following step.
if self.ephis[i] > 0 && Jac != 0.0
updatecsmat!(self.mcsys, loc, J, i, j)
At_mul_B!(csmatTJ, csmat(self.mcsys), J) # local Jacobian matrix
gradN!(fes, gradN, gradNparams[j], csmatTJ)
blmat!(self.mr, B, Ns[j], gradN, loc, csmat(self.mcsys))
add_btdb_ut_only!(elmat, B, self.ephis[i] * Jac * w[j], Dstab, DB)
end
end # Loop over quadrature points
complete_lt!(elmat)
gatherdofnums!(u, dofnums, fes.conn[i]) # retrieve degrees of freedom
assemble!(assembler, elmat, dofnums, dofnums) # assemble symmetric matrix
end # Loop over elements
return makematrix!(assembler) + Kn
end
function stiffness(
self::FEMM,
geom::NodalField{GFT},
u::NodalField{T},
) where {FEMM<:AbstractFEMMDeforLinearESNICE,GFT<:Number,T<:Number}
assembler = SysmatAssemblerSparseSymm()
return stiffness(self, assembler, geom, u)
end
"""
inspectintegpoints(
self::FEMM,
geom::NodalField{GFT},
u::NodalField{UFT},
dT::NodalField{TFT},
felist::Vector{IT},
inspector::F,
idat,
quantity = :Cauchy;
context...,
) where {FEMM<:AbstractFEMMDeforLinearESNICE,GFT<:Number,UFT<:Number,TFT<:Number,IT<:Integer,F<:Function}
Inspect integration point quantities.
# Arguments
- `geom` - reference geometry field
- `u` - displacement field
- `dT` - temperature difference field
- `felist` - indexes of the finite elements that are to be inspected:
The fes to be included are: `fes[felist]`.
- `context` - structure: see the update!() method of the material.
- `inspector` - functionwith the signature
idat = inspector(idat, j, conn, x, out, loc);
where
`idat` - a structure or an array that the inspector may
use to maintain some state, for instance minimum or maximum of
stress, `j` is the element number, `conn` is the element connectivity,
`out` is the output of the update!() method, `loc` is the location
of the integration point in the *reference* configuration.
# Return
The updated inspector data is returned.
"""
function inspectintegpoints(
self::FEMM,
geom::NodalField{GFT},
u::NodalField{UFT},
dT::NodalField{TFT},
felist::Vector{IT},
inspector::F,
idat,
quantity = :Cauchy;
context...,
) where {FEMM<:AbstractFEMMDeforLinearESNICE,GFT<:Number,UFT<:Number,TFT<:Number,IT<:Integer,F<:Function}
fes = self.integdomain.fes
npts, Ns, gradNparams, w, pc = integrationdata(self.integdomain)
ecoords, dofnums, loc, J, csmatTJ, Jac, D, Dstab = _buffers2(self, geom, u, npts)
# Sort out the output requirements
outputcsys = self.mcsys # default: report the stresses in the material coord system
for apair in pairs(context)
sy, val = apair
if sy == :outputcsys
outputcsys = val
end
end
t = 0.0
dt = 0.0
qpdT = 0.0 # node temperature increment
qpstrain = fill(zero(GFT), nstressstrain(self.mr), 1) # total strain -- buffer
qpthstrain = fill(zero(GFT), nthermstrain(self.mr)) # thermal strain -- buffer
qpstress = fill(zero(GFT), nstressstrain(self.mr)) # stress -- buffer
out1 = fill(zero(GFT), nstressstrain(self.mr)) # stress -- buffer
out = fill(zero(GFT), nstressstrain(self.mr))# output -- buffer
outtot = fill(zero(GFT), nstressstrain(self.mr))# output -- buffer
xe = fill(0.0, nodesperelem(fes), ndofs(geom))
eue = fill(zero(UFT), nodesperelem(fes) * ndofs(u))
gradN = fill(zero(GFT), nodesperelem(fes), ndofs(u))
B = fill(zero(GFT), nstressstrain(self.mr), nodesperelem(fes) * ndofs(u))
# Loop over all the elements and all the quadrature points within them
for ilist = 1:length(felist) # Loop over elements
i = felist[ilist]
gathervalues_asmat!(geom, ecoords, fes.conn[i])# retrieve element coords
for nix in fes.conn[i] # For all nodes connected by this element
nodalgradN = self.nodalbasisfunctiongrad[nix].gradN
patchconn = self.nodalbasisfunctiongrad[nix].patchconn
Vpatch = self.nodalbasisfunctiongrad[nix].Vpatch
ue = fill(zero(UFT), length(patchconn) * ndofs(u))
gathervalues_asvec!(u, ue, patchconn)# retrieve element displacements
loc = reshape(geom.values[nix, :], 1, ndofs(geom))
updatecsmat!(self.mcsys, loc, J, nix, 1)
nd = length(patchconn) * ndofs(u)
Bnodal = fill(0.0, size(D, 1), nd)
blmat!(self.mr, Bnodal, Ns[1], nodalgradN, loc, csmat(self.mcsys))
updatecsmat!(outputcsys, loc, J, nix, 1) # Update output coordinate system
# Quadrature point quantities
A_mul_B!(qpstrain, Bnodal, ue) # strain in material coordinates
qpdT = dT.values[nix] # Quadrature point temperature increment
thermalstrain!(self.material, qpthstrain, qpdT)
# Real Material: update the state and return the output
out = update!(
self.material,
qpstress,
out,
vec(qpstrain),
qpthstrain,
t,
dt,
loc,
nix,
quantity,
)
copyto!(outtot, out)
# Stabilization Material: update the state and return the output
out = update!(
self.stabilization_material,
qpstress,
out,
vec(qpstrain),
qpthstrain,
t,
dt,
loc,
nix,
quantity,
)
outtot .+= -self.nphis[nix] .* out
pci = findfirst(cx -> cx == nix, fes.conn[i])# at which node are we?
locjac!(loc, J, ecoords, Ns[pci], gradNparams[pci])
updatecsmat!(self.mcsys, loc, J, i, 1)
At_mul_B!(csmatTJ, csmat(self.mcsys), J) # local Jacobian matrix
gradN!(fes, gradN, gradNparams[pci], csmatTJ)
blmat!(self.mr, B, Ns[pci], gradN, loc, csmat(self.mcsys))
gathervalues_asvec!(u, eue, fes.conn[i])# retrieve element displacements
A_mul_B!(qpstrain, B, eue) # strain in material coordinates
out = update!(
self.stabilization_material,
qpstress,
out,
vec(qpstrain),
qpthstrain,
t,
dt,
loc,
nix,
quantity,
)
outtot .+= +self.ephis[i] .* out
out, outtot = outtot, out # swap in the total output
if (quantity == :Cauchy) # Transform stress tensor, if that is "out"
(length(out1) >= length(out)) || (out1 = zeros(length(out)))
rotstressvec!(self.mr, out1, out, transpose(csmat(self.mcsys)))# To global coord sys
rotstressvec!(self.mr, out, out1, csmat(outputcsys))# To output coord sys
end
# Call the inspector
idat = inspector(idat, i, fes.conn[i], ecoords, out, loc)
end # Loop over nodes
end # Loop over elements
return idat
end
function inspectintegpoints(
self::FEMM,
geom::NodalField{GFT},
u::NodalField{UFT},
felist::Vector{IT},
inspector::F,
idat,
quantity = :Cauchy;
context...,
) where {FEMM<:AbstractFEMMDeforLinearESNICE,GFT<:Number,UFT<:Number,IT<:Integer,F<:Function}
dT = NodalField(fill(zero(GFT), nnodes(geom), 1)) # zero difference in temperature
return inspectintegpoints(
self,
geom,
u,
dT,
felist,
inspector,
idat,
quantity;
context...,
)
end
"""
infsup_gh(
self::FEMM,
assembler::A,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {FEMM<:AbstractFEMMDeforLinearESNICE,A<:AbstractSysmatAssembler,GFT<:Number,UFT<:Number}
Compute the matrix to produce the norm of the divergence of the displacement.
This matrix is used in the numerical infsup test (Klaus-Jurgen Bathe, The
inf-sup condition and its evaluation for mixed finite element methods, Computers
and Structures 79 (2001) 243-252.)
!!! note
This computation has not been optimized in any way. It can be expected
to be inefficient.
"""
function infsup_gh(
self::FEMM,
assembler::A,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {FEMM<:AbstractFEMMDeforLinearESNICE,A<:AbstractSysmatAssembler,GFT<:Number,UFT<:Number}
fes = self.integdomain.fes
npts, Ns, gradNparams, w, pc = integrationdata(self.integdomain)
elmatsizeguess = 4 * nodesperelem(fes) * ndofs(u)
startassembly!(
assembler,
elmatsizeguess,
elmatsizeguess,
nnodes(u) + count(fes),
u.nfreedofs,
u.nfreedofs,
)
for nix = 1:length(self.nodalbasisfunctiongrad)
gradN = self.nodalbasisfunctiongrad[nix].gradN
patchconn = self.nodalbasisfunctiongrad[nix].patchconn
Vpatch = self.nodalbasisfunctiongrad[nix].Vpatch
c = reshape(geom.values[nix, :], 1, ndofs(geom))
nd = length(patchconn) * ndofs(u)
divm = divmat(self.mr, Ns[1], gradN, c)
elmat = (transpose(divm) * divm) * Vpatch
dofnums = fill(0, nd)
gatherdofnums!(u, dofnums, patchconn) # retrieve degrees of freedom
assemble!(assembler, elmat, dofnums, dofnums) # assemble symmetric matrix
end # Loop over nodes
return makematrix!(assembler)
end
function infsup_gh(
self::AbstractFEMMDeforLinearESNICE,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {GFT<:Number,UFT<:Number}
assembler = SysmatAssemblerSparseSymm()
return infsup_gh(self, assembler, geom, u)
end
"""
infsup_sh(
self::AbstractFEMMDeforLinearESNICE,
assembler::A,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {A<:AbstractSysmatAssembler,GFT<:Number,UFT<:Number}
Compute the matrix to produce the seminorm of the displacement (square root of
the sum of the squares of the derivatives of the components of displacement).
This matrix is used in the numerical infsup test (Klaus-Jurgen Bathe, The
inf-sup condition and its evaluation for mixed finite element methods,
Computers and Structures 79 (2001) 243-252.)
!!! note
This computation has not been optimized in any way. It can be expected to be inefficient.
"""
function infsup_sh(
self::FEMM,
assembler::A,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {FEMM<:AbstractFEMMDeforLinearESNICE,A<:AbstractSysmatAssembler,GFT<:Number,UFT<:Number}
fes = self.integdomain.fes
npts, Ns, gradNparams, w, pc = integrationdata(self.integdomain)
elmatsizeguess = 4 * nodesperelem(fes) * ndofs(u)
startassembly!(
assembler,
elmatsizeguess,
elmatsizeguess,
nnodes(u) + count(fes),
u.nfreedofs,
u.nfreedofs,
)
for nix = 1:length(self.nodalbasisfunctiongrad)
gradN = self.nodalbasisfunctiongrad[nix].gradN
patchconn = self.nodalbasisfunctiongrad[nix].patchconn
Vpatch = self.nodalbasisfunctiongrad[nix].Vpatch
c = reshape(geom.values[nix, :], 1, ndofs(geom))
nd = length(patchconn) * ndofs(u)
vgradm = vgradmat(self.mr, Ns[1], gradN, c)
elmat = (transpose(vgradm) * vgradm) * Vpatch
dofnums = fill(0, nd)
gatherdofnums!(u, dofnums, patchconn) # retrieve degrees of freedom
assemble!(assembler, elmat, dofnums, dofnums) # assemble symmetric matrix
end # Loop over nodes
return makematrix!(assembler)
end
function infsup_sh(
self::FEMM,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {FEMM<:AbstractFEMMDeforLinearESNICE,GFT<:Number,UFT<:Number}
assembler = SysmatAssemblerSparseSymm()
return infsup_sh(self, assembler, geom, u)
end
end
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 13320 | """
Module for operations on interiors of domains to construct system matrices and
system vectors for linear deformation models: incompatible-mode formulation.
"""
module FEMMDeforLinearIMModule
__precompile__(true)
using FinEtools.FENodeSetModule: FENodeSet
using FinEtools.FESetModule:
AbstractFESet, FESetH8, FESetT10, manifdim, nodesperelem, gradN!, bfun, bfundpar
using FinEtools.IntegDomainModule: IntegDomain, integrationdata, Jacobianvolume
using FinEtools.IntegRuleModule: GaussRule
using FinEtoolsDeforLinear.FEMMDeforLinearBaseModule: AbstractFEMMDeforLinear
using FinEtools.DeforModelRedModule: AbstractDeforModelRed, DeforModelRed3D
using FinEtoolsDeforLinear.MatDeforLinearElasticModule:
AbstractMatDeforLinearElastic, tangentmoduli!, update!, thermalstrain!
using FinEtoolsDeforLinear.MatDeforElastIsoModule: MatDeforElastIso
using FinEtools.FieldModule:
ndofs,
gatherdofnums!,
gathervalues_asvec!,
gathervalues_asmat!,
nalldofs
using FinEtools.NodalFieldModule: NodalField
using FinEtools.CSysModule: CSys, updatecsmat!, csmat
using FinEtools.DeforModelRedModule: nstressstrain, nthermstrain, blmat!, divmat, vgradmat
using FinEtools.AssemblyModule:
AbstractSysvecAssembler,
AbstractSysmatAssembler,
SysmatAssemblerSparseSymm,
startassembly!,
assemble!,
makematrix!,
makevector!,
SysvecAssembler
using FinEtools.MatrixUtilityModule: add_btdb_ut_only!, complete_lt!, loc!, jac!, locjac!
import FinEtoolsDeforLinear.FEMMDeforLinearBaseModule:
stiffness, mass, thermalstrainloads, inspectintegpoints
import FinEtools.FEMMBaseModule: associategeometry!
using FinEtoolsDeforLinear.MatDeforModule: rotstressvec!
using LinearAlgebra: mul!, Transpose, UpperTriangular
using LinearAlgebra: Symmetric, cholesky, eigen
At_mul_B!(C, A, B) = mul!(C, Transpose(A), B)
A_mul_B!(C, A, B) = mul!(C, A, B)
using LinearAlgebra: norm, qr, diag, dot, cond
using Statistics: mean
"""
mutable struct FEMMDeforLinearIMH8{
MR<:AbstractDeforModelRed,
ID<:IntegDomain{S,F} where {S<:FESetH8,F<:Function},
CS<:CSys,
M<:AbstractMatDeforLinearElastic,
} <: AbstractFEMMDeforLinear
Type for mean-strain linear deformation FEMM based on eight-node hexahedral elements with incompatible modes.
Default number of incompatible modes is 12 (Simo formulation).
Alternative is 9 incompatible modes (Wilson formulation).
"""
mutable struct FEMMDeforLinearIMH8{
MR<:AbstractDeforModelRed,
ID<:IntegDomain{S,F} where {S<:FESetH8,F<:Function},
CS<:CSys,
M<:AbstractMatDeforLinearElastic,
} <: AbstractFEMMDeforLinear
mr::Type{MR}
integdomain::ID # geometry data
mcsys::CS # updater of the material orientation matrix
material::M # material object
nmodes::Int
end
"""
FEMMDeforLinearIMH8(
mr::Type{MR},
integdomain::ID,
mcsys::CS,
material::M,
) where {
MR<:AbstractDeforModelRed,
ID<:IntegDomain{S,F} where {S<:FESetH8,F<:Function},
CS<:CSys,
M<:AbstractMatDeforLinearElastic,
}
Constructor. Default number of incompatible modes.
"""
function FEMMDeforLinearIMH8(
mr::Type{MR},
integdomain::ID,
mcsys::CS,
material::M,
) where {
MR<:AbstractDeforModelRed,
ID<:IntegDomain{S,F} where {S<:FESetH8,F<:Function},
CS<:CSys,
M<:AbstractMatDeforLinearElastic,
}
@assert mr == material.mr "Model reduction is mismatched"
@assert (mr == DeforModelRed3D) "3D model required"
return FEMMDeforLinearIMH8(mr, integdomain, mcsys, material, 12)
end
"""
FEMMDeforLinearIMH8(
mr::Type{MR},
integdomain::ID,
material::M,
) where {
MR<:AbstractDeforModelRed,
ID<:IntegDomain{S,F} where {S<:FESetH8,F<:Function},
M<:AbstractMatDeforLinearElastic,
}
Constructor. Default number of incompatible modes.
"""
function FEMMDeforLinearIMH8(
mr::Type{MR},
integdomain::ID,
material::M,
) where {
MR<:AbstractDeforModelRed,
ID<:IntegDomain{S,F} where {S<:FESetH8,F<:Function},
M<:AbstractMatDeforLinearElastic,
}
@assert mr == material.mr "Model reduction is mismatched"
@assert (mr == DeforModelRed3D) "3D model required"
return FEMMDeforLinearIMH8(
mr,
integdomain,
CSys(manifdim(integdomain.fes)),
material,
12,
)
end
"""
FEMMDeforLinearIMH8(
mr::Type{MR},
integdomain::ID,
material::M,
nmodes::Int64,
) where {MR<:AbstractDeforModelRed, ID<:IntegDomain{S,F} where {S<:FESetH8,F<:Function}, M<:AbstractMatDeforLinearElastic}
Constructor, with optional configuration of the number of incompatible modes.
"""
function FEMMDeforLinearIMH8(
mr::Type{MR},
integdomain::ID,
material::M,
nmodes::Int64,
) where {
MR<:AbstractDeforModelRed,
ID<:IntegDomain{S,F} where {S<:FESetH8,F<:Function},
M<:AbstractMatDeforLinearElastic,
}
@assert mr == material.mr "Model reduction is mismatched"
@assert (mr == DeforModelRed3D) "3D model required"
return FEMMDeforLinearIMH8(
mr,
integdomain,
CSys(manifdim(integdomain.fes)),
material,
nmodes,
)
end
function __centroidintegrationdata(self)
integration_rule = GaussRule(3, 1)
pc = integration_rule.param_coords
w = integration_rule.weights
npts = integration_rule.npts
FT = eltype(pc)
# Precompute basis f. values + basis f. gradients wrt parametric coor
Ns = Matrix{FT}[]
gradNparams = Matrix{FT}[]
for j = 1:npts
push!(Ns, bfun(self.fes, vec(pc[j, :])))
push!(gradNparams, bfundpar(self.fes, vec(pc[j, :])))
end
@assert npts == 1
return npts, reshape(Ns, 1, npts), reshape(gradNparams, 1, npts), w, pc
end
function __imintegrationdata(nmodes, integration_rule)
pc = integration_rule.param_coords
w = integration_rule.weights
npts = integration_rule.npts
FT = eltype(pc)
function bfun(nmodes, pc)
if nmodes == 12 # Simo basis functions
N = [
0.5 * (pc[1]^2 - 1)
0.5 * (pc[2]^2 - 1)
0.5 * (pc[3]^2 - 1)
pc[1] * pc[2] * pc[3]
]
else # Wilson basis functions
N = [
0.5 * (pc[1]^2 - 1)
0.5 * (pc[2]^2 - 1)
0.5 * (pc[3]^2 - 1)
]
end
return reshape(N, length(N), 1)
end
function bfundpar(nmodes, pc)
if nmodes == 12 # Simo basis functions
gradN = [
pc[1] 0 0
0 pc[2] 0
0 0 pc[3]
(pc[2]*pc[3]) (pc[1]*pc[3]) (pc[1]*pc[2])
]
else # Wilson basis functions
gradN = [
pc[1] 0 0
0 pc[2] 0
0 0 pc[3]
]
end
return gradN
end
# Precompute basis f. values + basis f. gradients wrt parametric coor
Ns = Matrix{FT}[]
gradNparams = Matrix{FT}[]
for j = 1:npts
push!(Ns, bfun(nmodes, vec(pc[j, :])))
push!(gradNparams, bfundpar(nmodes, vec(pc[j, :])))
end
return reshape(Ns, 1, npts), reshape(gradNparams, 1, npts)
end
function __imblmat!(mr, imB, imNs, imgradN, loc0, csmat, nmodes)
blmat!(mr, imB, imNs, imgradN, loc0, csmat)
if nmodes == 12
imB[1:3, 10] .= imgradN[4, 1]
imB[1:3, 11] .= imgradN[4, 2]
imB[1:3, 12] .= imgradN[4, 3]
imB[4:6, 10:12] .= 0.0
end
end
function _buffers2(self, geom::NodalField{GFT}, u::NodalField{UFT}) where {GFT,UFT}
fes = self.integdomain.fes
ndn = ndofs(u) # number of degrees of freedom per node
nne = nodesperelem(fes) # number of nodes for element
sdim = ndofs(geom) # number of space dimensions
mdim = manifdim(fes) # manifold dimension of the element
nstrs = nstressstrain(self.mr) # number of stresses
if self.nmodes == 12
nimne = 4
else
nimne = 3
end
elmatdim = ndn * (nne + nimne) # dimension of the element matrix
elmatcdim = ndn * nne # dimension of the condensed element matrix
# Prepare buffers
ecoords = fill(zero(GFT), nne, ndofs(geom)) # array of Element coordinates
elmat = fill(zero(GFT), elmatdim, elmatdim) # element matrix -- buffer
elmatc = fill(zero(GFT), elmatcdim, elmatcdim) # element matrix -- buffer
dofnums = zeros(eltype(u.dofnums), 1, elmatcdim) # degree of freedom array -- buffer
loc = fill(zero(GFT), 1, sdim) # quadrature point location -- buffer
J = fill(zero(GFT), sdim, mdim) # Jacobian matrix -- buffer
csmatTJ = fill(zero(GFT), mdim, mdim) # intermediate result -- buffer
loc0 = fill(zero(GFT), 1, sdim) # quadrature point location -- buffer
J0 = fill(zero(GFT), sdim, mdim) # Jacobian matrix -- buffer
csmatTJ0 = fill(zero(GFT), mdim, mdim) # intermediate result -- buffer
gradN = fill(zero(GFT), nne, mdim) # intermediate result -- buffer
gradN0 = fill(zero(GFT), nne, mdim) # intermediate result -- buffer
imgradN = fill(zero(GFT), nimne, mdim) # intermediate result -- buffer
D = fill(zero(GFT), nstrs, nstrs) # material stiffness matrix -- buffer
B = fill(zero(GFT), nstrs, elmatdim) # strain-displacement matrix -- buffer
DB = fill(zero(GFT), nstrs, elmatdim) # strain-displacement matrix -- buffer
Bc = fill(zero(GFT), nstrs, elmatcdim) # strain-displacement matrix -- buffer
imB = fill(zero(GFT), nstrs, elmatdim - elmatcdim) # strain-displacement matrix -- buffer
return ecoords,
dofnums,
loc,
J,
csmatTJ,
loc0,
J0,
csmatTJ0,
gradN,
gradN0,
imgradN,
D,
B,
DB,
Bc,
imB,
elmatc,
elmat
end
"""
associategeometry!(self::F, geom::NodalField{GFT}) where {F<:FEMMDeforLinearIMH8, GFT}
Associate geometry field with the FEMM.
Compute the correction factors to account for the shape of the elements.
"""
function associategeometry!(
self::F,
geom::NodalField{GFT},
) where {F<:FEMMDeforLinearIMH8,GFT}
# Nothing needs to be done
return self
end
"""
stiffness(
self::FEMMDeforLinearIMH8,
assembler::A,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {A<:AbstractSysmatAssembler,GFT<:Number,UFT<:Number}
Compute and assemble stiffness matrix.
"""
function stiffness(
self::FEMMDeforLinearIMH8,
assembler::A,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {A<:AbstractSysmatAssembler,GFT<:Number,UFT<:Number}
fes = self.integdomain.fes
npts, Ns, gradNparams, w, pc = integrationdata(self.integdomain)
npts0, Ns0, gradNparams0, w0, pc0 = __centroidintegrationdata(self.integdomain)
imNs, imgradNparams = __imintegrationdata(self.nmodes, self.integdomain.integration_rule)
ecoords,
dofnums,
loc,
J,
csmatTJ,
loc0,
J0,
csmatTJ0,
gradN,
gradN0,
imgradN,
D,
B,
DB,
Bc,
imB,
elmatc,
elmat = _buffers2(self, geom, u)
tangentmoduli!(self.material, D, 0.0, 0.0, loc, 0)
startassembly!(
assembler,
size(elmatc)..., count(fes),
nalldofs(u),
nalldofs(u),
)
for i in eachindex(fes) # Loop over elements
gathervalues_asmat!(geom, ecoords, fes.conn[i])
# NOTE: the coordinate system should be evaluated at a single point within the
# element in order for the derivatives to be consistent at all quadrature points
# Centroid data
locjac!(loc0, J0, ecoords, Ns0[1], gradNparams0[1])
updatecsmat!(self.mcsys, loc0, J0, i, 0)
Jac0 = Jacobianvolume(self.integdomain, J0, loc0, fes.conn[i], Ns0[1])
At_mul_B!(csmatTJ0, csmat(self.mcsys), J0) # local Jacobian matrix
gradN!(fes, gradN0, gradNparams0[1], csmatTJ0)
fill!(elmat, 0.0) # Initialize element matrix
for j = 1:npts # Loop over quadrature points
locjac!(loc, J, ecoords, Ns[j], gradNparams[j])
Jac = Jacobianvolume(self.integdomain, J, loc, fes.conn[i], Ns[j])
At_mul_B!(csmatTJ, csmat(self.mcsys), J) # local Jacobian matrix
gradN!(fes, gradN, gradNparams[j], csmatTJ)
blmat!(self.mr, Bc, Ns[j], gradN, loc, csmat(self.mcsys))
B[:, 1:24] .= sqrt(Jac * w[j]) .* Bc
gradN!(fes, imgradN, imgradNparams[j], csmatTJ0)
__imblmat!(self.mr, imB, imNs[j], imgradN, loc0, csmat(self.mcsys), self.nmodes)
B[:, 25:end] .= sqrt(Jac0 * w[j]) .* imB
add_btdb_ut_only!(elmat, B, 1.0, D, DB)
end # Loop over quadrature points
complete_lt!(elmat)
# Static condensation
elmatc .=
elmat[1:24, 1:24] -
elmat[1:24, 25:end] * (elmat[25:end, 25:end] \ elmat[25:end, 1:24])
gatherdofnums!(u, dofnums, fes.conn[i]) # retrieve degrees of freedom
assemble!(assembler, elmatc, dofnums, dofnums) # assemble symmetric matrix
end # Loop over elements
return makematrix!(assembler)
end
function stiffness(
self::FEMMDeforLinearIMH8,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {GFT<:Number,UFT<:Number}
assembler = SysmatAssemblerSparseSymm()
return stiffness(self, assembler, geom, u)
end
end # module
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 41367 | """
Module for operations on interiors of domains to construct system matrices and
system vectors for linear deformation models: mean-strain formulation.
"""
module FEMMDeforLinearMSModule
__precompile__(true)
using FinEtools.FENodeSetModule: FENodeSet
using FinEtools.FESetModule:
AbstractFESet, FESetH8, FESetT10, manifdim, nodesperelem, gradN!
using FinEtools.IntegDomainModule: IntegDomain, integrationdata, Jacobianvolume
using FinEtoolsDeforLinear.FEMMDeforLinearBaseModule: AbstractFEMMDeforLinear
using FinEtools.DeforModelRedModule: AbstractDeforModelRed, DeforModelRed3D
using FinEtoolsDeforLinear.MatDeforLinearElasticModule:
AbstractMatDeforLinearElastic, tangentmoduli!, update!, thermalstrain!
using FinEtoolsDeforLinear.MatDeforElastIsoModule: MatDeforElastIso
using FinEtools.FieldModule:
ndofs,
gatherdofnums!,
gathervalues_asvec!,
gathervalues_asmat!,
nalldofs
using FinEtools.NodalFieldModule: NodalField
using FinEtools.CSysModule: CSys, updatecsmat!, csmat
using FinEtools.DeforModelRedModule: nstressstrain, nthermstrain, blmat!, divmat, vgradmat
using FinEtools.AssemblyModule:
AbstractSysvecAssembler,
AbstractSysmatAssembler,
SysmatAssemblerSparseSymm,
startassembly!,
assemble!,
makematrix!,
makevector!,
SysvecAssembler
using FinEtools.MatrixUtilityModule: add_btdb_ut_only!, complete_lt!, loc!, jac!, locjac!
import FinEtoolsDeforLinear.FEMMDeforLinearBaseModule:
stiffness, mass, thermalstrainloads, inspectintegpoints
import FinEtools.FEMMBaseModule: associategeometry!
using FinEtoolsDeforLinear.MatDeforModule: rotstressvec!
using LinearAlgebra: mul!, Transpose, UpperTriangular
At_mul_B!(C, A, B) = mul!(C, Transpose(A), B)
A_mul_B!(C, A, B) = mul!(C, A, B)
using LinearAlgebra: norm, qr, diag, dot, cond
using Statistics: mean
const StabParamFloat = Float64
"""
AbstractFEMMDeforLinearMS <: AbstractFEMMDeforLinear
Abstract type for mean-strain linear deformation FEMM.
"""
abstract type AbstractFEMMDeforLinearMS <: AbstractFEMMDeforLinear end
"""
mutable struct FEMMDeforLinearMSH8{
MR<:AbstractDeforModelRed,
ID<:IntegDomain{S,F} where {S<:FESetH8,F<:Function},
CS<:CSys,
M<:AbstractMatDeforLinearElastic,
MS<:MatDeforElastIso,
} <: AbstractFEMMDeforLinearMS
Type for mean-strain linear deformation FEMM based on eight-node hexahedral elements.
"""
mutable struct FEMMDeforLinearMSH8{
MR<:AbstractDeforModelRed,
ID<:IntegDomain{S,F} where {S<:FESetH8,F<:Function},
CS<:CSys,
M<:AbstractMatDeforLinearElastic,
MS<:MatDeforElastIso,
} <: AbstractFEMMDeforLinearMS
mr::Type{MR}
integdomain::ID # geometry data
mcsys::CS # updater of the material orientation matrix
material::M # material object
stabilization_material::MS
phis::Vector{StabParamFloat}
end
"""
FEMMDeforLinearMSH8(
mr::Type{MR},
integdomain::ID,
mcsys::CS,
material::M,
) where {MR<:AbstractDeforModelRed, ID<:IntegDomain{S} where {S<:FESetH8}, CS<:CSys, M<:AbstractMatDeforLinearElastic}
Constructor.
"""
function FEMMDeforLinearMSH8(
mr::Type{MR},
integdomain::ID,
mcsys::CS,
material::M,
) where {
MR<:AbstractDeforModelRed,
ID<:IntegDomain{S} where {S<:FESetH8},
CS<:CSys,
M<:AbstractMatDeforLinearElastic,
}
@assert mr == material.mr "Model reduction is mismatched"
@assert (mr == DeforModelRed3D) "3D model required"
stabilization_material = _make_stabilization_material(material)
return FEMMDeforLinearMSH8(
mr,
integdomain,
mcsys,
material,
stabilization_material,
fill(zero(StabParamFloat), 1),
)
end
"""
FEMMDeforLinearMSH8(
mr::Type{MR},
integdomain::ID,
material::M,
) where {MR<:AbstractDeforModelRed, ID<:IntegDomain{S} where {S<:FESetH8}, M<:AbstractMatDeforLinearElastic}
Constructor.
"""
function FEMMDeforLinearMSH8(
mr::Type{MR},
integdomain::ID,
material::M,
) where {
MR<:AbstractDeforModelRed,
ID<:IntegDomain{S} where {S<:FESetH8},
M<:AbstractMatDeforLinearElastic,
}
@assert mr == material.mr "Model reduction is mismatched"
@assert (mr == DeforModelRed3D) "3D model required"
stabilization_material = _make_stabilization_material(material)
return FEMMDeforLinearMSH8(
mr,
integdomain,
CSys(manifdim(integdomain.fes)),
material,
stabilization_material,
fill(zero(StabParamFloat), 1),
)
end
"""
mutable struct FEMMDeforLinearMST10{
MR<:AbstractDeforModelRed,
ID<:IntegDomain{S,F} where {S<:FESetT10,F<:Function},
CS<:CSys,
M<:AbstractMatDeforLinearElastic,
MS<:MatDeforElastIso,
} <: AbstractFEMMDeforLinearMS
Type for mean-strain linear deformation FEMM based on 10-node tetrahedral elements.
"""
mutable struct FEMMDeforLinearMST10{
MR<:AbstractDeforModelRed,
ID<:IntegDomain{S,F} where {S<:FESetT10,F<:Function},
CS<:CSys,
M<:AbstractMatDeforLinearElastic,
MS<:MatDeforElastIso,
} <: AbstractFEMMDeforLinearMS
mr::Type{MR}
integdomain::ID # geometry data
mcsys::CS # updater of the material orientation matrix
material::M # material object
stabilization_material::MS
phis::Vector{StabParamFloat}
end
"""
FEMMDeforLinearMST10(
mr::Type{MR},
integdomain::ID,
mcsys::CS,
material::M,
) where {MR<:AbstractDeforModelRed, ID<:IntegDomain{S} where {S<:FESetT10}, CS<:CSys, M<:AbstractMatDeforLinearElastic}
Constructor.
"""
function FEMMDeforLinearMST10(
mr::Type{MR},
integdomain::ID,
mcsys::CS,
material::M,
) where {
MR<:AbstractDeforModelRed,
ID<:IntegDomain{S} where {S<:FESetT10},
CS<:CSys,
M<:AbstractMatDeforLinearElastic,
}
@assert mr == material.mr "Model reduction is mismatched"
@assert (mr == DeforModelRed3D) "3D model required"
stabilization_material = _make_stabilization_material(material)
return FEMMDeforLinearMST10(
mr,
integdomain,
mcsys,
material,
stabilization_material,
fill(zero(StabParamFloat), 1),
)
end
"""
FEMMDeforLinearMST10(
mr::Type{MR},
integdomain::ID,
material::M,
) where {MR<:AbstractDeforModelRed, ID<:IntegDomain{S} where {S<:FESetT10}, M<:AbstractMatDeforLinearElastic}
Constructor.
"""
function FEMMDeforLinearMST10(
mr::Type{MR},
integdomain::ID,
material::M,
) where {
MR<:AbstractDeforModelRed,
ID<:IntegDomain{S} where {S<:FESetT10},
M<:AbstractMatDeforLinearElastic,
}
@assert mr == material.mr "Model reduction is mismatched"
@assert (mr == DeforModelRed3D) "3D model required"
stabilization_material = _make_stabilization_material(material)
return FEMMDeforLinearMST10(
mr,
integdomain,
CSys(manifdim(integdomain.fes)),
material,
stabilization_material,
fill(zero(StabParamFloat), 1),
)
end
function _make_stabilization_material(material::M) where {M}
ns = fieldnames(typeof(material))
E = 0.0
nu = 0.0
if :E in ns
E = material.E
if material.nu < 0.3
nu = material.nu
else
nu = 0.3 + (material.nu - 0.3) / 2.0
end
else
if :E1 in ns
E = mean([material.E1, material.E2, material.E3])
nu = min(material.nu12, material.nu13, material.nu23)
else
error("No clues on how to construct the stabilization material")
end
end
return MatDeforElastIso(material.mr, 0.0, E, nu, 0.0)
end
function _buffers1(
self::AbstractFEMMDeforLinearMS,
geom::NodalField{GFT},
npts::Int,
) where {GFT}
fes = self.integdomain.fes
nne = nodesperelem(fes) # number of nodes for element
sdim = ndofs(geom) # number of space dimensions
mdim = manifdim(fes) # manifold dimension of the element
# Prepare buffers
ecoords = fill(zero(GFT), nne, ndofs(geom)) # array of Element coordinates
loc = fill(zero(GFT), 1, sdim) # quadrature point location -- buffer
J = fill(zero(GFT), sdim, mdim) # Jacobian matrix -- buffer
csmatTJ = fill(zero(GFT), mdim, mdim) # intermediate result -- buffer
gradN = fill(zero(GFT), nne, mdim)
return ecoords, loc, J, csmatTJ, gradN
end
function _buffers2(
self::AbstractFEMMDeforLinearMS,
geom::NodalField{GFT},
u::NodalField,
npts::Int,
) where {GFT}
fes = self.integdomain.fes
ndn = ndofs(u) # number of degrees of freedom per node
nne = nodesperelem(fes) # number of nodes for element
sdim = ndofs(geom) # number of space dimensions
mdim = manifdim(fes) # manifold dimension of the element
nstrs = nstressstrain(self.mr) # number of stresses
elmatdim = ndn * nne # dimension of the element matrix
# Prepare buffers
ecoords = fill(zero(GFT), nne, ndofs(geom)) # array of Element coordinates
elmat = fill(zero(GFT), elmatdim, elmatdim) # element matrix -- buffer
dofnums = zeros(eltype(u.dofnums), 1, elmatdim) # degree of freedom array -- buffer
loc = fill(zero(GFT), 1, sdim) # quadrature point location -- buffer
J = fill(zero(GFT), sdim, mdim) # Jacobian matrix -- buffer
csmatTJ = fill(zero(GFT), mdim, mdim) # intermediate result -- buffer
AllgradN = Matrix{GFT}[]
for ixxxx = 1:npts
push!(AllgradN, fill(zero(GFT), nne, mdim))
end
Jac = fill(zero(GFT), npts)
MeangradN = fill(zero(GFT), nne, mdim) # intermediate result -- buffer
D = fill(zero(GFT), nstrs, nstrs) # material stiffness matrix -- buffer
Dstab = fill(zero(GFT), nstrs, nstrs) # material stiffness matrix -- buffer
B = fill(zero(GFT), nstrs, elmatdim) # strain-displacement matrix -- buffer
DB = fill(zero(GFT), nstrs, elmatdim) # strain-displacement matrix -- buffer
Bbar = fill(zero(GFT), nstrs, elmatdim) # strain-displacement matrix -- buffer
elvecfix = fill(zero(GFT), elmatdim) # vector of prescribed displ. -- buffer
elvec = fill(zero(GFT), elmatdim) # element vector -- buffer
return ecoords,
dofnums,
loc,
J,
csmatTJ,
AllgradN,
MeangradN,
Jac,
D,
Dstab,
B,
DB,
Bbar,
elmat,
elvec,
elvecfix
end
function __centroid!(self::F, loc, ecoords) where {F<:FEMMDeforLinearMSH8}
weights = [
0.125
0.125
0.125
0.125
0.125
0.125
0.125
0.125
]
return loc!(loc, ecoords, reshape(weights, 8, 1))
end
function __centroid!(self::F, loc, ecoords) where {F<:FEMMDeforLinearMST10}
weights = [
-0.125
-0.125
-0.125
-0.125
0.250
0.250
0.250
0.250
0.250
0.250
]
return loc!(loc, ecoords, reshape(weights, 10, 1))
end
"""
associategeometry!(
self::FEMMDeforLinearMSH8,
geom::NodalField{GFT},
) where {GFT}
Associate geometry field with the FEMM.
Compute the correction factors to account for the shape of the elements.
"""
function associategeometry!(
self::FEMMDeforLinearMSH8,
geom::NodalField{GFT},
) where {GFT}
fes = self.integdomain.fes
npts, Ns, gradNparams, w, pc = integrationdata(self.integdomain)
ecoords, loc, J, csmatTJ, gradN = _buffers1(self, geom, npts)
self.phis = fill(zero(StabParamFloat), count(fes))
for i = 1:count(fes) # Loop over elements
gathervalues_asmat!(geom, ecoords, fes.conn[i])
# NOTE: the coordinate system should be evaluated at a single point within the
# element in order for the derivatives to be consistent at all quadrature points
loc = __centroid!(self, loc, ecoords)
updatecsmat!(self.mcsys, loc, J, i, 0)
for j = 1:npts # Loop over quadrature points
jac!(J, ecoords, gradNparams[j])
At_mul_B!(csmatTJ, csmat(self.mcsys), J) # local Jacobian matrix
gradN!(fes, gradN, gradNparams[j], csmatTJ)
h2 = diag(transpose(csmatTJ) * csmatTJ)
cap_phi =
(2 * (1 + self.stabilization_material.nu) * (minimum(h2) / maximum(h2))) # Plane stress
phi = cap_phi / (1 + cap_phi)
self.phis[i] = max(self.phis[i], phi)
end # Loop over quadrature points
end # Loop over elements
return self
end
"""
associategeometry!(
self::FEMMDeforLinearMST10,
geom::NodalField{GFT},
) where {GFT}
Associate geometry field with the FEMM.
Compute the correction factors to account for the shape of the elements.
"""
function associategeometry!(
self::FEMMDeforLinearMST10,
geom::NodalField{GFT},
) where {GFT}
gamma = 2.6
C = 1e4
fes = self.integdomain.fes
npts, Ns, gradNparams, w, pc = integrationdata(self.integdomain)
ecoords, loc, J, csmatTJ, gradN = _buffers1(self, geom, npts)
self.phis = fill(zero(StabParamFloat), count(fes))
for i = 1:count(fes) # Loop over elements
gathervalues_asmat!(geom, ecoords, fes.conn[i])
# NOTE: the coordinate system should be evaluated at a single point within the
# element in order for the derivatives to be consistent at all quadrature points
loc = __centroid!(self, loc, ecoords)
updatecsmat!(self.mcsys, loc, J, i, 0)
for j = 1:npts # Loop over quadrature points
jac!(J, ecoords, gradNparams[j])
At_mul_B!(csmatTJ, csmat(self.mcsys), J) # local Jacobian matrix
condJ = cond(csmatTJ)
cap_phi = C * (1.0 / condJ)^(gamma)
phi = cap_phi / (1 + cap_phi)
self.phis[i] = max(self.phis[i], phi)
end # Loop over quadrature points
end # Loop over elements
return self
end
"""
stiffness(
self::FEMM,
assembler::A,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {FEMM<:AbstractFEMMDeforLinearMS,A<:AbstractSysmatAssembler,GFT<:Number,UFT<:Number}
Compute and assemble stiffness matrix.
"""
function stiffness(
self::FEMM,
assembler::A,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {FEMM<:AbstractFEMMDeforLinearMS,A<:AbstractSysmatAssembler,GFT<:Number,UFT<:Number}
fes = self.integdomain.fes
npts, Ns, gradNparams, w, pc = integrationdata(self.integdomain)
ecoords,
dofnums,
loc,
J,
csmatTJ,
AllgradN,
MeangradN,
Jac,
D,
Dstab,
B,
DB,
Bbar,
elmat,
elvec,
elvecfix = _buffers2(self, geom, u, npts)
realmat = self.material
stabmat = self.stabilization_material
tangentmoduli!(realmat, D, 0.0, 0.0, loc, 0)
tangentmoduli!(stabmat, Dstab, 0.0, 0.0, loc, 0)
startassembly!(assembler, size(elmat)..., count(fes), nalldofs(u), nalldofs(u))
for i = 1:count(fes) # Loop over elements
gathervalues_asmat!(geom, ecoords, fes.conn[i])
# NOTE: the coordinate system should be evaluated at a single point within the
# element in order for the derivatives to be consistent at all quadrature points
loc = __centroid!(self, loc, ecoords)
updatecsmat!(self.mcsys, loc, J, i, 0)
vol = 0.0 # volume of the element
fill!(MeangradN, 0.0) # mean basis function gradients
for j = 1:npts # Loop over quadrature points
jac!(J, ecoords, gradNparams[j])
Jac[j] = Jacobianvolume(self.integdomain, J, loc, fes.conn[i], Ns[j])
At_mul_B!(csmatTJ, csmat(self.mcsys), J) # local Jacobian matrix
gradN!(fes, AllgradN[j], gradNparams[j], csmatTJ)
dvol = Jac[j] * w[j]
MeangradN .= MeangradN .+ AllgradN[j] * dvol
vol = vol + dvol
end # Loop over quadrature points
MeangradN .= MeangradN / vol
blmat!(self.mr, Bbar, Ns[1], MeangradN, loc, csmat(self.mcsys))
fill!(elmat, 0.0) # Initialize element matrix
add_btdb_ut_only!(elmat, Bbar, vol, D, DB)
add_btdb_ut_only!(elmat, Bbar, -self.phis[i] * vol, Dstab, DB)
for j = 1:npts # Loop over quadrature points
blmat!(self.mr, B, Ns[j], AllgradN[j], loc, csmat(self.mcsys))
add_btdb_ut_only!(elmat, B, self.phis[i] * Jac[j] * w[j], Dstab, DB)
end # Loop over quadrature points
complete_lt!(elmat)
gatherdofnums!(u, dofnums, fes.conn[i]) # retrieve degrees of freedom
assemble!(assembler, elmat, dofnums, dofnums) # assemble symmetric matrix
end # Loop over elements
return makematrix!(assembler)
end
function _iip_meanonly(
self::AbstractFEMMDeforLinearMS,
geom::NodalField{GFT},
u::NodalField{UFT},
dT::NodalField{TFT},
felist::Vector{IT},
inspector::F,
idat,
quantity = :Cauchy;
context...,
) where {GFT<:Number,UFT<:Number,TFT<:Number,IT,F<:Function}
fes = self.integdomain.fes
npts, Ns, gradNparams, w, pc = integrationdata(self.integdomain)
ecoords,
dofnums,
loc,
J,
csmatTJ,
AllgradN,
MeangradN,
Jac,
D,
Dstab,
B,
DB,
Bbar,
elmat,
elvec,
elvecfix = _buffers2(self, geom, u, npts)
MeanN = deepcopy(Ns[1])
realmat = self.material
stabmat = self.stabilization_material
# Sort out the output requirements
outputcsys = deepcopy(self.mcsys) # default: report the stresses in the material coord system
for apair in pairs(context)
sy, val = apair
if sy == :outputcsys
outputcsys = deepcopy(val)
end
end
t = 0.0
dt = 0.0
nne = nodesperelem(fes) # number of nodes for element
sdim = ndofs(geom) # number of space dimensions
dTe = fill(zero(TFT), nodesperelem(fes)) # nodal temperatures -- buffer
ue = fill(zero(GFT), size(elmat, 1)) # array of node displacements -- buffer
qpdT = 0.0 # node temperature increment
qpstrain = fill(zero(GFT), nstressstrain(self.mr), 1) # total strain -- buffer
qpthstrain = fill(zero(GFT), nthermstrain(self.mr)) # thermal strain -- buffer
qpstress = fill(zero(GFT), nstressstrain(self.mr)) # stress -- buffer
out1 = fill(zero(GFT), nstressstrain(self.mr)) # stress -- buffer
out = fill(zero(GFT), nstressstrain(self.mr))# output -- buffer
# Loop over all the elements and all the quadrature points within them
for ilist = 1:length(felist) # Loop over elements
i = felist[ilist]
gathervalues_asmat!(geom, ecoords, fes.conn[i])# retrieve element coords
gathervalues_asvec!(u, ue, fes.conn[i])# retrieve element displacements
gathervalues_asvec!(dT, dTe, fes.conn[i])# retrieve element temperature increments
# NOTE: the coordinate system should be evaluated at a single point within the
# element in order for the derivatives to be consistent at all quadrature points
loc = __centroid!(self, loc, ecoords)
updatecsmat!(self.mcsys, loc, J, i, 0)
updatecsmat!(outputcsys, loc, J, i, 0)
vol = 0.0 # volume of the element
fill!(MeangradN, 0.0) # mean basis function gradients
fill!(MeanN, 0.0) # mean basis function gradients
for j = 1:npts # Loop over quadrature points
jac!(J, ecoords, gradNparams[j])
Jac[j] = Jacobianvolume(self.integdomain, J, loc, fes.conn[i], Ns[j])
At_mul_B!(csmatTJ, csmat(self.mcsys), J) # local Jacobian matrix
gradN!(fes, AllgradN[j], gradNparams[j], csmatTJ)
dvol = Jac[j] * w[j]
MeangradN .= MeangradN .+ AllgradN[j] * dvol
MeanN .= MeanN .+ Ns[j] * dvol
vol = vol + dvol
end # Loop over quadrature points
MeangradN .= MeangradN / vol
blmat!(self.mr, Bbar, MeanN, MeangradN, loc, csmat(self.mcsys))
MeanN .= MeanN / vol
qpdT = dot(vec(dTe), vec(MeanN))# Quadrature point temperature increment
# Quadrature point quantities
A_mul_B!(qpstrain, Bbar, ue) # strain in material coordinates
thermalstrain!(realmat, qpthstrain, qpdT)
# Material updates the state and returns the output
out = update!(
realmat,
qpstress,
out,
vec(qpstrain),
qpthstrain,
t,
dt,
loc,
fes.label[i],
quantity,
)
if (quantity == :Cauchy) # Transform stress tensor, if that is "quantity"
(length(out1) >= length(out)) || (out1 = zeros(length(out)))
rotstressvec!(self.mr, out1, out, transpose(csmat(self.mcsys)))# To global coord sys
rotstressvec!(self.mr, out, out1, csmat(outputcsys))# To output coord sys
end
# Call the inspector
idat = inspector(idat, i, fes.conn[i], ecoords, out, loc)
end # Loop over elements
return idat # return the updated inspector data
end
function _iip_extrapmean(
self::AbstractFEMMDeforLinearMS,
geom::NodalField{GFT},
u::NodalField{UFT},
dT::NodalField{TFT},
felist::Vector{IT},
inspector::F,
idat,
quantity = :Cauchy;
context...,
) where {GFT<:Number,UFT<:Number,TFT<:Number,IT,F<:Function}
fes = self.integdomain.fes
npts, Ns, gradNparams, w, pc = integrationdata(self.integdomain)
ecoords,
dofnums,
loc,
J,
csmatTJ,
AllgradN,
MeangradN,
Jac,
D,
Dstab,
B,
DB,
Bbar,
elmat,
elvec,
elvecfix = _buffers2(self, geom, u, npts)
MeanN = deepcopy(Ns[1])
realmat = self.material
stabmat = self.stabilization_material
# Sort out the output requirements
outputcsys = deepcopy(self.mcsys) # default: report the stresses in the material coord system
for apair in pairs(context)
sy, val = apair
if sy == :outputcsys
outputcsys = val
end
end
t = 0.0
dt = 0.0
nne = nodesperelem(fes) # number of nodes for element
sdim = ndofs(geom) # number of space dimensions
dTe = fill(zero(GFT), nodesperelem(fes)) # nodal temperatures -- buffer
ue = fill(zero(GFT), size(elmat, 1)) # array of node displacements -- buffer
qpdT = 0.0 # node temperature increment
qpstrain = fill(zero(GFT), nstressstrain(self.mr), 1) # total strain -- buffer
qpthstrain = fill(zero(GFT), nthermstrain(self.mr)) # thermal strain -- buffer
qpstress = fill(zero(GFT), nstressstrain(self.mr)) # stress -- buffer
out1 = fill(zero(GFT), nstressstrain(self.mr)) # stress -- buffer
out = fill(zero(GFT), nstressstrain(self.mr))# output -- buffer
# Loop over all the elements and all the quadrature points within them
for ilist = 1:length(felist) # Loop over elements
i = felist[ilist]
gathervalues_asmat!(geom, ecoords, fes.conn[i])# retrieve element coords
gathervalues_asvec!(u, ue, fes.conn[i])# retrieve element displacements
gathervalues_asvec!(dT, dTe, fes.conn[i])# retrieve element temperature increments
# NOTE: the coordinate system should be evaluated at a single point within the
# element in order for the derivatives to be consistent at all quadrature points
loc = __centroid!(self, loc, ecoords)
updatecsmat!(self.mcsys, loc, J, i, 0)
updatecsmat!(outputcsys, loc, J, i, 0)
vol = 0.0 # volume of the element
fill!(MeangradN, 0.0) # mean basis function gradients
fill!(MeanN, 0.0) # mean basis function gradients
for j = 1:npts # Loop over quadrature points
jac!(J, ecoords, gradNparams[j])
Jac[j] = Jacobianvolume(self.integdomain, J, loc, fes.conn[i], Ns[j])
At_mul_B!(csmatTJ, csmat(self.mcsys), J) # local Jacobian matrix
gradN!(fes, AllgradN[j], gradNparams[j], csmatTJ)
dvol = Jac[j] * w[j]
MeangradN .= MeangradN .+ AllgradN[j] * dvol
MeanN .= MeanN .+ Ns[j] * dvol
vol = vol + dvol
end # Loop over quadrature points
MeangradN .= MeangradN / vol
blmat!(self.mr, Bbar, MeanN, MeangradN, loc, csmat(self.mcsys))
MeanN .= MeanN / vol
qpdT = dot(vec(dTe), vec(MeanN))# Quadrature point temperature increment
# Quadrature point quantities
A_mul_B!(qpstrain, Bbar, ue) # strain in material coordinates
thermalstrain!(realmat, qpthstrain, qpdT)
# Material updates the state and returns the output
out = update!(
realmat,
qpstress,
out,
vec(qpstrain),
qpthstrain,
t,
dt,
loc,
fes.label[i],
quantity,
)
if (quantity == :Cauchy) # Transform stress tensor, if that is "quantity"
(length(out1) >= length(out)) || (out1 = zeros(length(out)))
rotstressvec!(self.mr, out1, out, transpose(csmat(self.mcsys)))# To global coord sys
rotstressvec!(self.mr, out, out1, csmat(outputcsys)) # To output coord sys
end
# Call the inspector for each node location
for nod in axes(ecoords, 1)
idat = inspector(idat, i, fes.conn[i], ecoords, out, ecoords[nod, :])
end
end # Loop over elements
return idat # return the updated inspector data
end
function _iip_extraptrend(
self::AbstractFEMMDeforLinearMS,
geom::NodalField{GFT},
u::NodalField{UFT},
dT::NodalField{TFT},
felist::Vector{IT},
inspector::F,
idat,
quantity = :Cauchy;
context...,
) where {GFT<:Number,UFT<:Number,TFT<:Number,IT,F<:Function}
fes = self.integdomain.fes
npts, Ns, gradNparams, w, pc = integrationdata(self.integdomain)
ecoords,
dofnums,
loc,
J,
csmatTJ,
AllgradN,
MeangradN,
Jac,
D,
Dstab,
B,
DB,
Bbar,
elmat,
elvec,
elvecfix = _buffers2(self, geom, u, npts)
MeanN = deepcopy(Ns[1])
realmat = self.material
stabmat = self.stabilization_material
# Sort out the output requirements
outputcsys = deepcopy(self.mcsys) # default: report the stresses in the material coord system
for apair in pairs(context)
sy, val = apair
if sy == :outputcsys
outputcsys = val
end
end
t = 0.0
dt = 0.0
nne = nodesperelem(fes) # number of nodes for element
sdim = ndofs(geom) # number of space dimensions
dTe = fill(zero(GFT), nodesperelem(fes)) # nodal temperatures -- buffer
ue = fill(zero(GFT), size(elmat, 1)) # array of node displacements -- buffer
qpdT = 0.0 # node temperature increment
qpstrain = fill(zero(GFT), nstressstrain(self.mr), 1) # total strain -- buffer
qpthstrain = fill(zero(GFT), nthermstrain(self.mr)) # thermal strain -- buffer
qpstress = fill(zero(GFT), nstressstrain(self.mr)) # stress -- buffer
rout1 = fill(zero(GFT), nstressstrain(self.mr)) # stress -- buffer
rout = fill(zero(GFT), nstressstrain(self.mr))# output -- buffer
sbout = deepcopy(rout)
sbout1 = deepcopy(sbout)
sout = deepcopy(rout)
sout1 = deepcopy(sout)
sqploc = deepcopy(loc)
sstoredout = fill(zero(GFT), npts, length(sout))
A = ones(GFT, npts, 4)
# Loop over all the elements and all the quadrature points within them
for ilist = 1:length(felist) # Loop over elements
i = felist[ilist]
gathervalues_asmat!(geom, ecoords, fes.conn[i])# retrieve element coords
gathervalues_asvec!(u, ue, fes.conn[i])# retrieve element displacements
gathervalues_asvec!(dT, dTe, fes.conn[i])# retrieve element temperature increments
# NOTE: the coordinate system should be evaluated at a single point within the
# element in order for the derivatives to be consistent at all quadrature points
loc = __centroid!(self, loc, ecoords)
updatecsmat!(self.mcsys, loc, J, i, 0)
updatecsmat!(outputcsys, loc, J, i, 0)
vol = 0.0 # volume of the element
fill!(MeangradN, 0.0) # mean basis function gradients
fill!(MeanN, 0.0) # mean basis function gradients
for j = 1:npts # Loop over quadrature points
jac!(J, ecoords, gradNparams[j])
Jac[j] = Jacobianvolume(self.integdomain, J, loc, fes.conn[i], Ns[j])
At_mul_B!(csmatTJ, csmat(self.mcsys), J) # local Jacobian matrix
gradN!(fes, AllgradN[j], gradNparams[j], csmatTJ)
dvol = Jac[j] * w[j]
MeangradN .= MeangradN .+ AllgradN[j] * dvol
MeanN .= MeanN .+ Ns[j] * dvol
vol = vol + dvol
end # Loop over quadrature points
MeangradN .= MeangradN / vol
blmat!(self.mr, Bbar, MeanN, MeangradN, loc, csmat(self.mcsys))
MeanN .= MeanN / vol
qpdT = dot(vec(dTe), vec(MeanN))# Quadrature point temperature increment
# Quadrature point quantities
A_mul_B!(qpstrain, Bbar, ue) # strain in material coordinates
thermalstrain!(realmat, qpthstrain, qpdT)
# REAL Material updates the state and returns the output
rout = update!(
realmat,
qpstress,
rout,
vec(qpstrain),
qpthstrain,
t,
dt,
loc,
fes.label[i],
quantity,
)
if (quantity == :Cauchy) # Transform stress tensor, if that is "quantity"
(length(rout1) >= length(rout)) || (rout1 = zeros(length(rout)))
rotstressvec!(self.mr, rout1, rout, transpose(csmat(self.mcsys)))# To global coord sys
rotstressvec!(self.mr, rout, rout1, csmat(outputcsys))# To output coord sys
end
# STABILIZATION Material updates the state and returns the output
sbout = update!(
stabmat,
qpstress,
sbout,
vec(qpstrain),
qpthstrain,
t,
dt,
loc,
fes.label[i],
quantity,
)
if (quantity == :Cauchy) # Transform stress tensor, if that is "quantity"
(length(sbout1) >= length(sbout)) || (sbout1 = zeros(length(sbout)))
rotstressvec!(self.mr, sbout1, sbout, transpose(csmat(self.mcsys)))# To global coord sys
rotstressvec!(self.mr, sbout, sbout1, csmat(outputcsys))# To output coord sys
end
for j = 1:npts # Loop over quadrature points (STABILIZATION material)
At_mul_B!(sqploc, Ns[j], ecoords)# Quadrature point location
A[j, 1:3] .= vec(sqploc - loc)
blmat!(self.mr, B, Ns[j], AllgradN[j], sqploc, csmat(self.mcsys))
qpdT = dot(vec(dTe), vec(Ns[j]))# Quadrature point temperature increment
# Quadrature point quantities
A_mul_B!(qpstrain, B, ue) # strain in material coordinates
thermalstrain!(stabmat, qpthstrain, qpdT)
# Material updates the state and returns the output
sout = update!(
stabmat,
qpstress,
sout,
vec(qpstrain),
qpthstrain,
t,
dt,
loc,
fes.label[i],
quantity,
)
if (quantity == :Cauchy) # Transform stress tensor, if that is "quantity"
(length(sout1) >= length(sout)) || (sout1 = zeros(length(sout)))
rotstressvec!(self.mr, sout1, sout, transpose(csmat(self.mcsys)))# To global coord sys
rotstressvec!(self.mr, sout, sout1, csmat(outputcsys))# To output coord sys
end
sstoredout[j, :] .= sout # store the output for this quadrature point
end # Loop over quadrature points
# Solve for the least-square fit parameters
fact = qr(A)
p = UpperTriangular(fact.R) \ (transpose(Array(fact.Q)) * sstoredout) # R \ (transpose(Q) * sstoredout)
for nod in axes(ecoords, 1)
# Predict the value of the output quantity at the node
xdel = vec(@view ecoords[nod, :]) - vec(loc)
nout =
rout +
self.phis[i] * (-sbout + vec(reshape(xdel, 1, 3) * p[1:3, :]) + p[4, :])
# Call the inspector for the node location
idat = inspector(idat, i, fes.conn[i], ecoords, nout, ecoords[nod, :])
end
end # Loop over elements
return idat # return the updated inspector data
end
"""
inspectintegpoints(
self::FEMM,
geom::NodalField{GFT},
u::NodalField{UFT},
dT::NodalField{TFT},
felist::Vector{IT},
inspector::F,
idat,
quantity = :Cauchy;
context...,
) where {FEMM<:AbstractFEMMDeforLinearMS,GFT<:Number,UFT<:Number,TFT<:Number,IT,F<:Function}
Inspect integration point quantities.
# Arguments
- `geom` - reference geometry field
- `u` - displacement field
- `dT` - temperature difference field
- `felist` - indexes of the finite elements that are to be inspected:
The fes to be included are: `fes[felist]`.
- `context` - structure: see the update!() method of the material.
- `inspector` - functionwith the signature
idat = inspector(idat, j, conn, x, out, loc);
where
`idat` - a structure or an array that the inspector may
use to maintain some state, for instance minimum or maximum of
stress, `j` is the element number, `conn` is the element connectivity,
`out` is the output of the update!() method, `loc` is the location
of the integration point in the *reference* configuration.
# Return
The updated inspector data is returned.
"""
function inspectintegpoints(
self::FEMM,
geom::NodalField{GFT},
u::NodalField{UFT},
dT::NodalField{TFT},
felist::Vector{IT},
inspector::F,
idat,
quantity = :Cauchy;
context...,
) where {FEMM<:AbstractFEMMDeforLinearMS,GFT<:Number,UFT<:Number,TFT<:Number,IT,F<:Function}
reportat = :meanonly
for apair in pairs(context)
sy, val = apair
if sy == :reportat
reportat = val
end
end
if reportat == :extraptrend
return _iip_extraptrend(
self,
geom,
u,
dT,
felist,
inspector,
idat,
quantity;
context...,
)
elseif reportat == :extrapmean
return _iip_extrapmean(
self,
geom,
u,
dT,
felist,
inspector,
idat,
quantity;
context...,
)
elseif reportat == :meanonly || true # this is the default
return _iip_meanonly(
self,
geom,
u,
dT,
felist,
inspector,
idat,
quantity;
context...,
)
end
return idat
end
function inspectintegpoints(
self::FEMM,
geom::NodalField{GFT},
u::NodalField{UFT},
felist::Vector{IT},
inspector::F,
idat,
quantity = :Cauchy;
context...,
) where {FEMM<:AbstractFEMMDeforLinearMS,GFT<:Number,UFT<:Number,IT,F<:Function}
dT = NodalField(fill(zero(GFT), nnodes(geom), 1)) # zero difference in temperature
return inspectintegpoints(
self,
geom,
u,
dT,
felist,
inspector,
idat,
quantity;
context...,
)
end
"""
infsup_gh(
self::FEMM,
assembler::A,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {FEMM<:AbstractFEMMDeforLinearMS,A<:AbstractSysmatAssembler,GFT<:Number,UFT<:Number}
Compute the matrix to produce the norm of the divergence of the displacement.
This matrix is used in the numerical infsup test (Klaus-Jurgen Bathe, The
inf-sup condition and its evaluation for mixed finite element methods,
Computers and Structures 79 (2001) 243-252.)
!!! note
This computation has not been optimized in any way. It can be expected to be inefficient.
"""
function infsup_gh(
self::FEMM,
assembler::A,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {FEMM<:AbstractFEMMDeforLinearMS,A<:AbstractSysmatAssembler,GFT<:Number,UFT<:Number}
fes = self.integdomain.fes
npts, Ns, gradNparams, w, pc = integrationdata(self.integdomain)
ecoords,
dofnums,
loc,
J,
csmatTJ,
AllgradN,
MeangradN,
Jac,
D,
Dstab,
B,
DB,
Bbar,
elmat,
elvec,
elvecfix = _buffers2(self, geom, u, npts)
startassembly!(
assembler,
size(elmat, 1),
size(elmat, 2),
count(fes),
u.nfreedofs,
u.nfreedofs,
)
for i = 1:count(fes) # Loop over elements
gathervalues_asmat!(geom, ecoords, fes.conn[i])
# NOTE: the coordinate system should be evaluated at a single point within the
# element in order for the derivatives to be consistent at all quadrature points
loc = __centroid!(self, loc, ecoords)
updatecsmat!(self.mcsys, loc, J, i, 0)
vol = 0.0 # volume of the element
fill!(MeangradN, 0.0) # mean basis function gradients
for j = 1:npts # Loop over quadrature points
jac!(J, ecoords, gradNparams[j])
Jac[j] = Jacobianvolume(self.integdomain, J, loc, fes.conn[i], Ns[j])
At_mul_B!(csmatTJ, csmat(self.mcsys), J) # local Jacobian matrix
gradN!(fes, AllgradN[j], gradNparams[j], csmatTJ)
dvol = Jac[j] * w[j]
MeangradN .= MeangradN .+ AllgradN[j] * dvol
vol = vol + dvol
end # Loop over quadrature points
MeangradN .= MeangradN / vol
fill!(elmat, 0.0) # Initialize element matrix
divm = divmat(self.mr, Ns[1], MeangradN, loc)
elmat += (transpose(divm) * divm) * vol
gatherdofnums!(u, dofnums, fes.conn[i]) # retrieve degrees of freedom
assemble!(assembler, (elmat + elmat') / 2, dofnums, dofnums) # assemble symmetric matrix
end # Loop over elements
return makematrix!(assembler)
end
function infsup_gh(
self::FEMM,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {FEMM<:AbstractFEMMDeforLinearMS,GFT<:Number,UFT<:Number}
assembler = SysmatAssemblerSparseSymm()
return infsup_gh(self, assembler, geom, u)
end
"""
infsup_sh(
self::FEMM,
assembler::A,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {FEMM<:AbstractFEMMDeforLinearMS,A<:AbstractSysmatAssembler,GFT<:Number,UFT<:Number}
Compute the matrix to produce the seminorm of the displacement (square root of
the sum of the squares of the derivatives of the components of displacement).
This matrix is used in the numerical infsup test (Klaus-Jurgen Bathe, The
inf-sup condition and its evaluation for mixed finite element methods,
Computers and Structures 79 (2001) 243-252.)
!!! note
This computation has not been optimized in any way. It can be expected to be inefficient.
"""
function infsup_sh(
self::FEMM,
assembler::A,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {FEMM<:AbstractFEMMDeforLinearMS,A<:AbstractSysmatAssembler,GFT<:Number,UFT<:Number}
fes = self.integdomain.fes
npts, Ns, gradNparams, w, pc = integrationdata(self.integdomain)
ecoords,
dofnums,
loc,
J,
csmatTJ,
AllgradN,
MeangradN,
Jac,
D,
Dstab,
B,
DB,
Bbar,
elmat,
elvec,
elvecfix = _buffers2(self, geom, u, npts)
startassembly!(
assembler,
size(elmat, 1),
size(elmat, 2),
count(fes),
u.nfreedofs,
u.nfreedofs,
)
for i = 1:count(fes) # Loop over elements
gathervalues_asmat!(geom, ecoords, fes.conn[i])
# NOTE: the coordinate system should be evaluated at a single point within the
# element in order for the derivatives to be consistent at all quadrature points
loc = __centroid!(self, loc, ecoords)
updatecsmat!(self.mcsys, loc, J, i, 0)
vol = 0.0 # volume of the element
fill!(MeangradN, 0.0) # mean basis function gradients
for j = 1:npts # Loop over quadrature points
jac!(J, ecoords, gradNparams[j])
Jac[j] = Jacobianvolume(self.integdomain, J, loc, fes.conn[i], Ns[j])
At_mul_B!(csmatTJ, csmat(self.mcsys), J) # local Jacobian matrix
gradN!(fes, AllgradN[j], gradNparams[j], csmatTJ)
dvol = Jac[j] * w[j]
MeangradN .= MeangradN .+ AllgradN[j] * dvol
vol = vol + dvol
end # Loop over quadrature points
MeangradN .= MeangradN / vol
fill!(elmat, 0.0) # Initialize element matrix
vgradm = vgradmat(self.mr, Ns[1], MeangradN, loc)
elmat = (transpose(vgradm) * vgradm) * vol
gatherdofnums!(u, dofnums, fes.conn[i]) # retrieve degrees of freedom
assemble!(assembler, (elmat + elmat') / 2, dofnums, dofnums) # assemble symmetric matrix
end # Loop over elements
return makematrix!(assembler)
end
function infsup_sh(
self::FEMM,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {FEMM<:AbstractFEMMDeforLinearMS,GFT<:Number,UFT<:Number}
assembler = SysmatAssemblerSparseSymm()
return infsup_sh(self, assembler, geom, u)
end
end
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 2047 | """
Module for operations on interiors of domains to construct system matrices and
system vectors for linear deformation models.
"""
module FEMMDeforLinearModule
__precompile__(true)
import FinEtools.FENodeSetModule: FENodeSet
import FinEtools.FESetModule: AbstractFESet, manifdim
import FinEtools.IntegDomainModule: IntegDomain
import FinEtoolsDeforLinear.FEMMDeforLinearBaseModule: AbstractFEMMDeforLinear
import FinEtools.DeforModelRedModule: AbstractDeforModelRed, DeforModelRed2DAxisymm
import FinEtoolsDeforLinear.MatDeforLinearElasticModule: AbstractMatDeforLinearElastic
import FinEtools.CSysModule: CSys
"""
mutable struct FEMMDeforLinear{
MR<:AbstractDeforModelRed,
ID<:IntegDomain,
CS<:CSys,
M<:AbstractMatDeforLinearElastic,
} <: AbstractFEMMDeforLinear
Type for linear deformation finite element modeling machine.
"""
mutable struct FEMMDeforLinear{
MR<:AbstractDeforModelRed,
ID<:IntegDomain,
CS<:CSys,
M<:AbstractMatDeforLinearElastic,
} <: AbstractFEMMDeforLinear
mr::Type{MR} # model reduction type
integdomain::ID # integration domain data
mcsys::CS # updater of the material orientation matrix
material::M # material object
end
"""
FEMMDeforLinear(
mr::Type{MR},
integdomain::IntegDomain{S,F},
material::M,
) where {
MR<:AbstractDeforModelRed,
S<:AbstractFESet,
F<:Function,
M<:AbstractMatDeforLinearElastic,
}
Constructor of linear deformation finite element modeling machine.
"""
function FEMMDeforLinear(
mr::Type{MR},
integdomain::IntegDomain{S,F},
material::M,
) where {
MR<:AbstractDeforModelRed,
S<:AbstractFESet,
F<:Function,
M<:AbstractMatDeforLinearElastic,
}
@assert mr == material.mr "Model reduction is mismatched"
@assert (integdomain.axisymmetric) || (mr != DeforModelRed2DAxisymm) "Axially symmetric requires axisymmetric to be true"
return FEMMDeforLinear(mr, integdomain, CSys(manifdim(integdomain.fes)), material)
end
end
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 15378 | """
Formulation for the small displacement, small strain deformation
model for Nodally-Integrated Continuum Elements (NICE).
The approximation is originally from Dohrmann et al IJNME 47 (2000).
The formulation was subsequently developed in Krysl, P. and Zhu, B.
Locking-free continuum displacement finite elements with nodal
integration, International Journal for Numerical Methods in Engineering,
76,7,1020-1043,2008.
This formulation is at this point obsolete (replaced with ESNICE).
"""
module FEMMDeforLinearNICEModule
__precompile__(true)
using FinEtools.FENodeSetModule: FENodeSet
using FinEtools.FESetModule: AbstractFESet, FESetH8, FESetT4, manifdim, nodesperelem, gradN!
using FinEtools.IntegDomainModule: IntegDomain, integrationdata, Jacobianvolume
using FinEtoolsDeforLinear.FEMMDeforLinearBaseModule: AbstractFEMMDeforLinear
using FinEtools.DeforModelRedModule: AbstractDeforModelRed, DeforModelRed3D
using FinEtoolsDeforLinear.MatDeforLinearElasticModule:
AbstractMatDeforLinearElastic, tangentmoduli!, update!, thermalstrain!
using FinEtools.FieldModule:
ndofs,
gatherdofnums!,
gathervalues_asvec!,
gathervalues_asmat!,
nalldofs
using FinEtools.NodalFieldModule: NodalField, nnodes
using FinEtools.CSysModule: CSys, updatecsmat!, csmat
using FinEtools.FENodeToFEMapModule: FENodeToFEMap
using FinEtools.DeforModelRedModule: nstressstrain, nthermstrain, blmat!
using FinEtools.AssemblyModule:
AbstractSysvecAssembler,
AbstractSysmatAssembler,
SysmatAssemblerSparseSymm,
startassembly!,
assemble!,
makematrix!,
makevector!,
SysvecAssembler
using FinEtools.MatrixUtilityModule:
add_btdb_ut_only!, complete_lt!, loc!, jac!, locjac!, adjugate3!
import FinEtoolsDeforLinear.FEMMDeforLinearBaseModule:
stiffness, mass, thermalstrainloads, inspectintegpoints
import FinEtools.FEMMBaseModule: associategeometry!
using FinEtoolsDeforLinear.MatDeforModule: rotstressvec!
using LinearAlgebra: mul!, Transpose, UpperTriangular, eigvals
At_mul_B!(C, A, B) = mul!(C, Transpose(A), B)
A_mul_B!(C, A, B) = mul!(C, A, B)
using LinearAlgebra: norm, qr, diag, dot, cond, I
using Statistics: mean
const StabParamFloat = Float64
"""
AbstractFEMMDeforLinearNICE <: AbstractFEMMDeforLinear
Abstract FEMM type for Nodally Integrated Continuum Elements (NICE).
"""
abstract type AbstractFEMMDeforLinearNICE <: AbstractFEMMDeforLinear end
mutable struct _NodalBasisFunctionGradients{FT,IT}
gradN::Matrix{FT}
patchconn::Vector{IT}
Vpatch::FT
end
"""
mutable struct FEMMDeforLinearNICEH8{
MR <: AbstractDeforModelRed,
S <: FESetH8,
F <: Function,
M <: AbstractMatDeforLinearElastic,
} <: AbstractFEMMDeforLinearNICE
FEMM type for Nodally Integrated Continuum Elements (NICE) based on the eight-node hexahedron.
"""
mutable struct FEMMDeforLinearNICEH8{
MR<:AbstractDeforModelRed,
ID<:IntegDomain{S,F} where {S<:FESetH8,F<:Function},
CS<:CSys,
M<:AbstractMatDeforLinearElastic,
} <: AbstractFEMMDeforLinearNICE
mr::Type{MR}
integdomain::ID # integration domain
mcsys::CS # updater of the material orientation matrix
material::M # material object
stabfact::StabParamFloat
nodalbasisfunctiongrad::Vector{_NodalBasisFunctionGradients}
end
function FEMMDeforLinearNICEH8(
mr::Type{MR},
integdomain::IntegDomain{S,F},
mcsys::CSys,
material::M,
) where {MR<:AbstractDeforModelRed,S<:FESetH8,F<:Function,M<:AbstractMatDeforLinearElastic}
@assert mr == material.mr "Model reduction is mismatched"
@assert (mr == DeforModelRed3D) "3D model required"
stabfact = 0.05
return FEMMDeforLinearNICEH8(
mr,
integdomain,
mcsys,
material,
stabfact,
_NodalBasisFunctionGradients[],
)
end
function FEMMDeforLinearNICEH8(
mr::Type{MR},
integdomain::IntegDomain{S,F},
material::M,
) where {MR<:AbstractDeforModelRed,S<:FESetH8,F<:Function,M<:AbstractMatDeforLinearElastic}
@assert mr == material.mr "Model reduction is mismatched"
@assert (mr == DeforModelRed3D) "3D model required"
stabfact = 0.05
return FEMMDeforLinearNICEH8(
mr,
integdomain,
CSys(manifdim(integdomain.fes)),
material,
stabfact,
_NodalBasisFunctionGradients[],
)
end
function FEMMDeforLinearNICEH8(
mr::Type{MR},
integdomain::IntegDomain{S,F},
material::M,
stabfact,
) where {MR<:AbstractDeforModelRed,S<:FESetH8,F<:Function,M<:AbstractMatDeforLinearElastic}
@assert mr == material.mr "Model reduction is mismatched"
@assert (mr == DeforModelRed3D) "3D model required"
return FEMMDeforLinearNICEH8(
mr,
integdomain,
CSys(manifdim(integdomain.fes)),
material,
stabfact,
_NodalBasisFunctionGradients[],
)
end
"""
mutable struct FEMMDeforLinearNICET4{
MR <: AbstractDeforModelRed,
S <: FESetT4,
F <: Function,
M <: AbstractMatDeforLinearElastic,
} <: AbstractFEMMDeforLinearNICE
FEMM type for Nodally Integrated Continuum Elements (NICE) based on the 4-node tetrahedron.
"""
mutable struct FEMMDeforLinearNICET4{
MR<:AbstractDeforModelRed,
ID<:IntegDomain{S,F} where {S<:FESetT4,F<:Function},
CS<:CSys,
M<:AbstractMatDeforLinearElastic,
} <: AbstractFEMMDeforLinearNICE
mr::Type{MR}
integdomain::ID # geometry data
mcsys::CS # updater of the material orientation matrix
material::M # material object
stabfact::StabParamFloat
nodalbasisfunctiongrad::Vector{_NodalBasisFunctionGradients}
end
function FEMMDeforLinearNICET4(
mr::Type{MR},
integdomain::IntegDomain{S,F},
mcsys::CSys,
material::M,
) where {MR<:AbstractDeforModelRed,S<:FESetT4,F<:Function,M<:AbstractMatDeforLinearElastic}
@assert mr == material.mr "Model reduction is mismatched"
@assert (mr == DeforModelRed3D) "3D model required"
stabfact = 0.015
return FEMMDeforLinearNICET4(
mr,
integdomain,
mcsys,
material,
stabfact,
_NodalBasisFunctionGradients[],
)
end
function FEMMDeforLinearNICET4(
mr::Type{MR},
integdomain::IntegDomain{S,F},
material::M,
) where {MR<:AbstractDeforModelRed,S<:FESetT4,F<:Function,M<:AbstractMatDeforLinearElastic}
@assert mr == material.mr "Model reduction is mismatched"
@assert (mr == DeforModelRed3D) "3D model required"
stabfact = 0.015
return FEMMDeforLinearNICET4(
mr,
integdomain,
CSys(manifdim(integdomain.fes)),
material,
stabfact,
_NodalBasisFunctionGradients[],
)
end
function FEMMDeforLinearNICET4(
mr::Type{MR},
integdomain::IntegDomain{S,F},
material::M,
stabfact,
) where {MR<:AbstractDeforModelRed,S<:FESetT4,F<:Function,M<:AbstractMatDeforLinearElastic}
@assert mr == material.mr "Model reduction is mismatched"
@assert (mr == DeforModelRed3D) "3D model required"
return FEMMDeforLinearNICET4(
mr,
integdomain,
CSys(manifdim(integdomain.fes)),
material,
stabfact,
_NodalBasisFunctionGradients[],
)
end
function _buffers1(
self::AbstractFEMMDeforLinearNICE,
geom::NodalField{GFT},
npts::Int,
) where {GFT}
fes = self.integdomain.fes
nne = nodesperelem(fes) # number of nodes for element
sdim = ndofs(geom) # number of space dimensions
mdim = manifdim(fes) # manifold dimension of the element
# Prepare buffers
loc = fill(zero(GFT), 1, sdim) # quadrature point location -- buffer
J = fill(zero(GFT), sdim, mdim) # Jacobian matrix -- buffer
adjJ = fill(zero(GFT), sdim, mdim) # Jacobian matrix -- buffer
csmatTJ = fill(zero(GFT), mdim, mdim) # intermediate result -- buffer
gradN = fill(zero(GFT), nne, mdim)
xl = fill(zero(GFT), nne, mdim)
return loc, J, adjJ, csmatTJ, gradN, xl
end
function _buffers2(
self::AbstractFEMMDeforLinearNICE,
geom::NodalField{GFT},
u::NodalField,
npts::Int,
) where {GFT}
fes = self.integdomain.fes
ndn = ndofs(u) # number of degrees of freedom per node
nne = nodesperelem(fes) # number of nodes for element
sdim = ndofs(geom) # number of space dimensions
mdim = manifdim(fes) # manifold dimension of the element
nstrs = nstressstrain(self.mr) # number of stresses
loc = fill(zero(GFT), 1, sdim) # quadrature point location -- buffer
J = fill(zero(GFT), sdim, mdim) # Jacobian matrix -- buffer
csmatTJ = fill(zero(GFT), mdim, mdim) # intermediate result -- buffer
Jac = fill(zero(GFT), npts)
D = fill(zero(GFT), nstrs, nstrs) # material stiffness matrix -- buffer
return loc, J, csmatTJ, Jac, D
end
function patchconn(fes, gl, thisnn)
# Generate patch connectivity for a given node (thisnn)
# from the connectivities of the finite elements attached to it.
return vcat(
collect(setdiff(Set([i for j in eachindex(gl) for i in fes.conn[gl[j]]]), thisnn)),
[thisnn],
)
end
function computenodalbfungrads(self, geom)
# # Compute the nodal basis function gradients.
# # Return the cell array of structures with attributes
# % bfun_gradients{nix}.Nspd= basis function gradient matrix
# # bfun_gradients{nix}.Vpatch= nodal patch volume
# # bfun_gradients{nix}.patchconn= nodal patch connectivity
fes = self.integdomain.fes
npts, Ns, gradNparams, w, pc = integrationdata(self.integdomain)
loc, J, adjJ, csmatTJ, gradN, xl = _buffers1(self, geom, npts)
# Get the inverse map from finite element nodes to geometric cells
fen2fe = FENodeToFEMap(fes.conn, nnodes(geom))
# Initialize the nodal gradients, nodal patch, and patch connectivity
bfungrads =
fill(_NodalBasisFunctionGradients(fill(0.0, 0, 0), fill(0, 0), 0.0), nnodes(geom))
# Now loop over all finite element nodes in the map
lnmap = fill(0, length(fen2fe.map)) # Local node map: buffer to speed up operations
for nix in eachindex(fen2fe.map)
gl = fen2fe.map[nix]
thisnn = nix # We are at this node
if !isempty(gl) # This node has an element patch in this block
# establish local numbering of all nodes of the patch @ node thisnn
p = patchconn(fes, gl, thisnn)
np = length(p)
lnmap[p] .= 1:np# now store the local numbers
c = reshape(geom.values[thisnn, :], 1, ndofs(geom))
updatecsmat!(self.mcsys, c, J, nix, 0)
gradNavg = fill(0.0, np, ndofs(geom))# preallocate strain-displacement matrix
Vpatch = 0.0
for k in eachindex(gl)
i = gl[k]
kconn = collect(fes.conn[i])
pci = findfirst(cx -> cx == thisnn, kconn)# at which node in the element are we with this quadrature point?
@assert 1 <= pci <= nodesperelem(fes)
# centered coordinates of nodes in the material coordinate system
for cn in eachindex(kconn)
xl[cn, :] =
(reshape(geom.values[kconn[cn], :], 1, ndofs(geom)) - c) *
csmat(self.mcsys)
end
jac!(J, xl, gradNparams[pci])
At_mul_B!(csmatTJ, csmat(self.mcsys), J) # local Jacobian matrix
Jac = Jacobianvolume(self.integdomain, J, c, fes.conn[i], Ns[pci])
Vpatch += Jac * w[pci]
sgradN = gradNparams[pci] * adjugate3!(adjJ, J)
gradNavg[lnmap[kconn], :] += (w[pci] .* sgradN)
end
@assert Vpatch != 0
gradNavg ./= Vpatch
bfungrads[nix] = _NodalBasisFunctionGradients(gradNavg, p, Vpatch)
lnmap[p] .= 0 # Restore the buffer to pristine condition
end
end
self.nodalbasisfunctiongrad = bfungrads
return self
end
"""
associategeometry!(self::F,
geom::NodalField{GFT}) where {F <: AbstractFEMMDeforLinearNICE, GFT}
Associate geometry field with the FEMM.
Compute the correction factors to account for the shape of the elements.
"""
function associategeometry!(
self::F,
geom::NodalField{GFT},
) where {F<:AbstractFEMMDeforLinearNICE,GFT}
return computenodalbfungrads(self, geom)
end
function Phi3(dim, np, lx, c)
lx[:, 1] = lx[:, 1] .- c[1]
lx[:, 2] = lx[:, 2] .- c[2]
lx[:, 3] = lx[:, 3] .- c[3]
Phi = fill(0.0, dim * np, 12)
Phi[1:dim:(end-1), 1] .= 1
Phi[1:dim:(end-1), 2] = lx[:, 1]'
Phi[1:dim:(end-1), 3] = lx[:, 2]'
Phi[1:dim:(end-1), 4] = lx[:, 3]'
Phi[2:dim:end, 5] .= 1
Phi[2:dim:end, 6] = lx[:, 1]'
Phi[2:dim:end, 7] = lx[:, 2]'
Phi[2:dim:end, 8] = lx[:, 3]'
Phi[3:dim:end, 9] .= 1
Phi[3:dim:end, 10] = lx[:, 1]'
Phi[3:dim:end, 11] = lx[:, 2]'
Phi[3:dim:end, 12] = lx[:, 3]'
return Phi
end
"""
stiffness(self::AbstractFEMMDeforLinearNICE,
assembler::A,
geom::NodalField{GFT},
u::NodalField{UFT}) where {A <: AbstractSysmatAssembler, GFT <: Number, UFT <: Number}
Compute and assemble stiffness matrix.
"""
function stiffness(
self::AbstractFEMMDeforLinearNICE,
assembler::A,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {A<:AbstractSysmatAssembler,GFT<:Number,UFT<:Number}
fes = self.integdomain.fes
npts, Ns, gradNparams, w, pc = integrationdata(self.integdomain)
loc, J, csmatTJ, Jac, D = _buffers2(self, geom, u, npts)
tangentmoduli!(self.material, D, 0.0, 0.0, loc, 0)
Dmod = sort(eigvals(D))
stabDmod = mean(Dmod[1:2]; dims = 1)
elmatsizeguess = 4 * nodesperelem(fes) * ndofs(u)
startassembly!(assembler, elmatsizeguess, elmatsizeguess, nnodes(u), nalldofs(u), nalldofs(u))
for nix in eachindex(self.nodalbasisfunctiongrad)
gradN = self.nodalbasisfunctiongrad[nix].gradN
patchconn = self.nodalbasisfunctiongrad[nix].patchconn
Vpatch = self.nodalbasisfunctiongrad[nix].Vpatch
c = reshape(geom.values[nix, :], 1, ndofs(geom))
updatecsmat!(self.mcsys, c, J, nix, 0)
nd = length(patchconn) * ndofs(u)
Bnodal = fill(0.0, size(D, 1), nd)
blmat!(self.mr, Bnodal, Ns[1], gradN, c, csmat(self.mcsys))
elmat = fill(0.0, nd, nd) # Can we SPEED it UP?
DB = fill(0.0, size(D, 1), nd)
add_btdb_ut_only!(elmat, Bnodal, Vpatch, D, DB)
complete_lt!(elmat)
if (self.stabfact > 0)
Phi = Phi3(ndofs(u), length(patchconn), geom.values[patchconn, :], c)
A1 = Phi * ((Phi' * Phi) \ Phi')
elmat += (self.stabfact * stabDmod) .* (I - A1)
end
dofnums = fill(0, nd)
gatherdofnums!(u, dofnums, patchconn) # retrieve degrees of freedom
assemble!(assembler, elmat, dofnums, dofnums) # assemble symmetric matrix
end # Loop over elements
return makematrix!(assembler)
end
"""
stiffness(self::AbstractFEMMDeforLinearNICE,
geom::NodalField{GFT},
u::NodalField{UFT}) where {GFT <: Number, UFT <: Number}
Compute and assemble stiffness matrix.
"""
function stiffness(
self::AbstractFEMMDeforLinearNICE,
geom::NodalField{GFT},
u::NodalField{UFT},
) where {GFT<:Number,UFT<:Number}
assembler = SysmatAssemblerSparseSymm()
return stiffness(self, assembler, geom, u)
end
end
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 4270 | """
Module for operations on the damping associated with absorbing boundary
conditions (ABC) representation of the effect of infinite extent
of inviscid fluid next to the surface.
"""
module FEMMDeforSurfaceDampingModule
__precompile__(true)
using FinEtools.FENodeSetModule: FENodeSet
using FinEtools.FESetModule: AbstractFESet, nodesperelem, manifdim
using FinEtools.IntegDomainModule: IntegDomain, integrationdata, Jacobiansurface
using FinEtools.FieldModule: ndofs, gatherdofnums!, gathervalues_asmat!, nalldofs
using FinEtools.NodalFieldModule: NodalField
using FinEtools.FEMMBaseModule: AbstractFEMM
using FinEtools.AssemblyModule:
AbstractSysvecAssembler,
AbstractSysmatAssembler,
SysmatAssemblerSparseSymm,
startassembly!,
assemble!,
makematrix!
using FinEtools.MatrixUtilityModule: add_nnt_ut_only!, complete_lt!, locjac!
using FinEtools.SurfaceNormalModule: SurfaceNormal, updatenormal!
using LinearAlgebra: norm, cross
"""
mutable struct FEMMDeforSurfaceDamping{ID<:IntegDomain} <: AbstractFEMM
Type for surface damping model.
"""
mutable struct FEMMDeforSurfaceDamping{ID<:IntegDomain} <: AbstractFEMM
integdomain::ID # geometry data
end
"""
dampingABC(
self::FEMMDeforSurfaceDamping,
assembler::A,
geom::NodalField{GFT},
u::NodalField{UFT},
impedance::FT,
surfacenormal::SurfaceNormal,
) where {A<:AbstractSysmatAssembler,GFT<:Number,UFT<:Number,FT<:Number}
Compute the damping matrix associated with absorbing boundary conditions (ABC).
Compute the damping matrix associated with absorbing boundary conditions (ABC)
representation of the effect of infinite extent of inviscid fluid next to
the surface.
"""
function dampingABC(
self::FEMMDeforSurfaceDamping,
assembler::A,
geom::NodalField{GFT},
u::NodalField{UFT},
impedance::FT,
surfacenormal::SurfaceNormal,
) where {A<:AbstractSysmatAssembler,GFT<:Number,UFT<:Number,FT<:Number}
fes = self.integdomain.fes
# Constants
nfes = count(fes) # number of finite elements
ndn = ndofs(u) # number of degrees of freedom per node
nne = nodesperelem(fes) # number of nodes per finite element
sdim = ndofs(geom) # spatial dimension
mdim = manifdim(fes) # manifold dimension of the finite elements
Cedim = ndn * nne # size of damping element matrix
# Precompute basis f. values + basis f. gradients wrt parametric coor
npts, Ns, gradNparams, w, pc = integrationdata(self.integdomain)
loc = zeros(GFT, 1, sdim) # quadrature point coordinate -- used as a buffer
J = zeros(GFT, sdim, mdim) # Jacobian matrix -- used as a buffer
ecoords = zeros(GFT, nne, sdim)
Ce = zeros(FT, Cedim, Cedim) # element damping matrix -- used as a buffer
Nn = zeros(GFT, Cedim) # column vector
dofnums = zeros(eltype(u.dofnums), Cedim) # degree of freedom array -- used as a buffer
# Prepare assembler and temporaries
startassembly!(assembler, Cedim, Cedim, nfes, nalldofs(u), nalldofs(u))
for i in eachindex(fes) # loop over finite elements
gathervalues_asmat!(geom, ecoords, fes.conn[i])
fill!(Ce, 0.0) # Initialize element damping matrix
for j = 1:npts # loop over quadrature points
locjac!(loc, J, ecoords, Ns[j], gradNparams[j])
Jac = Jacobiansurface(self.integdomain, J, loc, fes.conn[i], Ns[j])
n = updatenormal!(surfacenormal, loc, J, i, j)
for k = 1:nne
Nn[((k-1)*ndn+1):(k*ndn)] = n * Ns[j][k]
end
add_nnt_ut_only!(Ce, Nn, (+1) * impedance * Jac * w[j])
end # end loop over quadrature points
complete_lt!(Ce)
gatherdofnums!(u, dofnums, self.integdomain.fes.conn[i]) # retrieve degrees of freedom
assemble!(assembler, Ce, dofnums, dofnums) # assemble the element damping matrix
end # end loop over finite elements
return makematrix!(assembler)
end
function dampingABC(
self::FEMMDeforSurfaceDamping,
geom::NodalField{GFT},
u::NodalField{UFT},
impedance::FT,
surfacenormal::SurfaceNormal,
) where {GFT<:Number,UFT<:Number,FT<:Number}
assembler = SysmatAssemblerSparseSymm()
return dampingABC(self, assembler, geom, u, impedance, surfacenormal)
end
end
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 4588 | """
Module for operations on boundaries of domains to construct system matrices and
system vectors for linear deformation models with distributed-spring supports
(Winkler foundation model).
"""
module FEMMDeforWinklerModule
__precompile__(true)
import FinEtools.FENodeSetModule: FENodeSet
import FinEtools.FESetModule: AbstractFESet, nodesperelem, manifdim
import FinEtools.IntegDomainModule: IntegDomain, integrationdata, Jacobiansurface
import FinEtools.FieldModule: ndofs, gatherdofnums!, gathervalues_asmat!, nalldofs
import FinEtools.NodalFieldModule: NodalField
import FinEtools.FEMMBaseModule: AbstractFEMM
import FinEtools.AssemblyModule:
AbstractSysvecAssembler,
AbstractSysmatAssembler,
SysmatAssemblerSparseSymm,
startassembly!,
assemble!,
makematrix!
import FinEtools.MatrixUtilityModule: add_nnt_ut_only!, complete_lt!, locjac!
import FinEtools.SurfaceNormalModule: SurfaceNormal, updatenormal!
import LinearAlgebra: norm, cross
"""
mutable struct FEMMDeforWinkler{ID<:IntegDomain} <: AbstractFEMM
Type for normal spring support (Winkler).
"""
mutable struct FEMMDeforWinkler{ID<:IntegDomain} <: AbstractFEMM
integdomain::ID # geometry data
end
"""
surfacenormalspringstiffness(
self::FEMMDeforWinkler,
assembler::A,
geom::NodalField{GFT},
u::NodalField{UFT},
springconstant::UFT,
surfacenormal::SurfaceNormal,
) where {A<:AbstractSysmatAssembler,GFT<:Number,UFT<:Number}
Compute the stiffness matrix of surface normal spring.
Rationale: consider continuously distributed springs between the surface of the
solid body and the 'ground', in the direction normal to the surface. If the
spring coefficient becomes large, we have an approximate method of enforcing the
normal displacement to the surface.
"""
function surfacenormalspringstiffness(
self::FEMMDeforWinkler,
assembler::A,
geom::NodalField{GFT},
u::NodalField{UFT},
springconstant::UFT,
surfacenormal::SurfaceNormal,
) where {A<:AbstractSysmatAssembler,GFT<:Number,UFT<:Number}
integdomain = self.integdomain
# Constants
nfes = count(integdomain.fes) # number of finite elements in the set
ndn = ndofs(u) # number of degrees of freedom per node
nne = nodesperelem(integdomain.fes) # number of nodes for element
sdim = ndofs(geom) # number of space dimensions
mdim = manifdim(integdomain.fes) # manifold dimension of the element
Kedim = ndn * nne # dimension of the element matrix
# Precompute basis f. values + basis f. gradients wrt parametric coor
npts, Ns, gradNparams, w, pc = integrationdata(integdomain)
# Prepare assembler and temporaries
ecoords = fill(zero(GFT), nne, ndofs(geom)) # array of Element coordinates
Ke = zeros(UFT, Kedim, Kedim) # element matrix -- used as a buffer
dofnums = zeros(eltype(u.dofnums), Kedim) # degree of freedom array -- used as a buffer
loc = zeros(GFT, 1, sdim) # quadrature point location -- used as a buffer
J = fill(zero(GFT), sdim, mdim) # Jacobian matrix -- used as a buffer
Nn = zeros(GFT, Kedim) # column vector
startassembly!(assembler, Kedim, Kedim, nfes, nalldofs(u), nalldofs(u))
for i = 1:nfes # Loop over elements
gathervalues_asmat!(geom, ecoords, integdomain.fes.conn[i])
fill!(Ke, zero(UFT)) # Initialize element matrix
for j = 1:npts # Loop over quadrature points
locjac!(loc, J, ecoords, Ns[j], gradNparams[j])
Jac = Jacobiansurface(integdomain, J, loc, integdomain.fes.conn[i], Ns[j])
n = updatenormal!(surfacenormal, loc, J, i, j)
for k = 1:nne
for r = 1:sdim
Nn[(k-1)*sdim+r] = n[r] * Ns[j][k]
end
end
add_nnt_ut_only!(Ke, Nn, springconstant * Jac * w[j])
end # Loop over quadrature points
complete_lt!(Ke)
gatherdofnums!(u, dofnums, integdomain.fes.conn[i])# retrieve degrees of freedom
assemble!(assembler, Ke, dofnums, dofnums)# assemble symmetric matrix
end # Loop over elements
return makematrix!(assembler)
end
function surfacenormalspringstiffness(
self::FEMMDeforWinkler,
geom::NodalField{GFT},
u::NodalField{UFT},
springconstant::UFT,
surfacenormal::SurfaceNormal,
) where {GFT<:Number,UFT<:Number}
assembler = SysmatAssemblerSparseSymm()
return surfacenormalspringstiffness(
self,
assembler,
geom,
u,
springconstant,
surfacenormal,
)
end
end
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 4441 | """
FinEtoolsDeforLinear (C) 2017-2024, Petr Krysl
Finite Element tools. Julia implementation of the finite element method
for continuum mechanics. Package for linear static and dynamic stress analysis problems.
"""
module FinEtoolsDeforLinear
__precompile__(true)
include("allmodules.jl")
# Enable LSP look-up in test modules.
if false include("../test/runtests.jl") end
# Exports follow:
###########################################################################
# Linear deformation functionality
###########################################################################
using .MatDeforModule: AbstractMatDefor
# using .MatDeforModule: AbstractMatDefor, strain2x2tto3v!, strain3vto2x2t!, strain3x3tto6v!, strain6vto3x3t!, strain9vto3x3t!, strain3x3tto9v!, strain9vto6v!, strain6vto9v!, stress2x2to3v!, stress3vto2x2t!, stress3vto3x3t!, stress4vto3x3t!, stress6vto3x3t!, stress3x3tto6v!, stress9vto6v!, stress6vto9v!
using .MatDeforModule: rotstressvec!
using .MatDeforModule:
dett, strainvdet, strainvtr, strainttov!, strainvtot!, stressttov!, stressvtot!
using .MatDeforModule:
tens4checksymmetry,
tens4symmtto6x6t!,
tens4symmt6x6tot!,
tens4dot2!,
tens4ijkl!,
tens4ikjl!,
tens4iljk!,
tens4identity!,
tens4transposor!,
tens4tracor!,
tens4symmetrizor!,
tens4skewor!,
tens4deviator!
# Exported: abstract type for models of deformation, conversion methods for strain and stress, transformations of strain and stress
export AbstractMatDefor
export rotstressvec!
export dett, strainvdet, strainvtr, strainttov!, strainvtot!, stressttov!, stressvtot!
export tens4checksymmetry,
tens4symmtto6x6t!,
tens4symmt6x6tot!,
tens4dot2!,
tens4ijkl!,
tens4ikjl!,
tens4iljk!,
tens4identity!,
tens4transposor!,
tens4tracor!,
tens4symmetrizor!,
tens4skewor!,
tens4deviator!
using .MatDeforLinearElasticModule: AbstractMatDeforLinearElastic
# Exported: type of isotropic elastic material
export AbstractMatDeforLinearElastic
using .MatDeforElastIsoModule: MatDeforElastIso
# Exported: type of isotropic elastic material
export MatDeforElastIso
using .MatDeforElastOrthoModule: MatDeforElastOrtho
# Exported: type of orthotropic elastic material
export MatDeforElastOrtho
using .FEMMDeforLinearBaseModule:
AbstractFEMMDeforLinear, stiffness, thermalstrainloads, mass, inspectintegpoints
# Exported: abstract type for linear information, discretization methods for the abstract type
export AbstractFEMMDeforLinear, stiffness, thermalstrainloads, mass, inspectintegpoints
using .FEMMDeforLinearModule: FEMMDeforLinear
# Exported: type for linear deformation
export FEMMDeforLinear
using .FEMMDeforWinklerModule: FEMMDeforWinkler, surfacenormalspringstiffness
# Exported: type for distributed-spring support, discretization method
export FEMMDeforWinkler, surfacenormalspringstiffness
using .FEMMDeforLinearMSModule:
FEMMDeforLinearMSH8,
FEMMDeforLinearMST10,
stiffness,
thermalstrainloads,
inspectintegpoints
# Exported: type for mean-strain solid elements, discretization methods
export FEMMDeforLinearMSH8,
FEMMDeforLinearMST10, stiffness, thermalstrainloads, inspectintegpoints
using .FEMMDeforLinearIMModule:
FEMMDeforLinearIMH8, stiffness, thermalstrainloads, inspectintegpoints
# Exported: type for mean-strain solid elements, discretization methods
export FEMMDeforLinearIMH8, stiffness, thermalstrainloads, inspectintegpoints
using .FEMMDeforSurfaceDampingModule: FEMMDeforSurfaceDamping, dampingABC
#Exported: type for surface damping (absorbing boundary conditions)
export FEMMDeforSurfaceDamping, dampingABC
using .FEMMDeforLinearNICEModule:
FEMMDeforLinearNICEH8,
FEMMDeforLinearNICET4,
stiffness,
thermalstrainloads,
inspectintegpoints
# Exported: type for NICE (Nodally-integrated continuum elements) solid elements, discretization methods
export FEMMDeforLinearNICEH8,
FEMMDeforLinearNICET4, stiffness, thermalstrainloads, inspectintegpoints
using .FEMMDeforLinearESNICEModule:
FEMMDeforLinearESNICET4,
FEMMDeforLinearESNICEH8,
stiffness,
thermalstrainloads,
inspectintegpoints
# Exported: type for ESICE (Energy-sampling stabilized nodally-integrated continuum elements) solid elements, discretization methods
export FEMMDeforLinearESNICET4,
FEMMDeforLinearESNICEH8, stiffness, thermalstrainloads, inspectintegpoints
end # module
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 25232 | """
Module for linear isotropic elastic response.
"""
module MatDeforElastIsoModule
__precompile__(true)
using FinEtools.DeforModelRedModule:
AbstractDeforModelRed,
DeforModelRed3D,
DeforModelRed2DStrain,
DeforModelRed2DStress,
DeforModelRed2DAxisymm,
DeforModelRed1DStrain,
DeforModelRed1DStress,
nstressstrain,
nthermstrain
using FinEtoolsDeforLinear.MatDeforModule: AbstractMatDefor, stressvtot!
using FinEtoolsDeforLinear.MatDeforLinearElasticModule: AbstractMatDeforLinearElastic
using LinearAlgebra: Transpose, Diagonal, mul!
At_mul_B!(C, A, B) = mul!(C, Transpose(A), B)
A_mul_B!(C, A, B) = mul!(C, A, B)
using LinearAlgebra: eigen, eigvals, norm, cholesky, cross, dot, I
"""
struct MatDeforElastIso{
MR<:AbstractDeforModelRed,
FT,
MTAN<:Function,
MUPD<:Function,
MTHS<:Function,
} <: AbstractMatDeforLinearElastic
Linear isotropic elasticity material.
"""
struct MatDeforElastIso{
MR<:AbstractDeforModelRed,
FT,
MTAN<:Function,
MUPD<:Function,
MTHS<:Function,
} <: AbstractMatDeforLinearElastic
mr::Type{MR} # model reduction type
mass_density::FT # mass density
E::FT # Young's modulus
nu::FT # Poisson ratio
CTE::FT # Coefficient of Thermal Expansion
D::Matrix{FT} # cached matrix of 3D tangent moduli
tangentmoduli!::MTAN # Function to return the tangent moduli matrix
update!::MUPD # Function to update the material state
thermalstrain!::MTHS # Function to calculate the thermal strains
end
function _threedD(E, nu)
mI = Matrix(Diagonal([1.0, 1.0, 1.0, 0.5, 0.5, 0.5]))
m1 = [1.0, 1.0, 1.0, 0.0, 0.0, 0.0]
lambda = E * nu / (1 + nu) / (1 - 2 * (nu))
mu = E / 2.0 / (1 + nu)
D = lambda * m1 * m1' + 2.0 * mu * mI
return D
end
"""
MatDeforElastIso(
mr::Type{MR},
mass_density::N,
E::N,
nu::N,
CTE::N,
) where {MR<:AbstractDeforModelRed,N<:Number}
Create an isotropic elastic material providing all material parameters.
## Arguments
- `mr::Type{MR}`: The type of the deformation model.
- `mass_density::N`: The mass density of the material.
- `E::N`: The Young's modulus of the material.
- `nu::N`: The Poisson's ratio of the material.
- `CTE::N`: The coefficient of thermal expansion of the material.
"""
function MatDeforElastIso(
mr::Type{MR},
mass_density::N,
E::N,
nu::N,
CTE::N,
) where {MR<:AbstractDeforModelRed,N<:Number}
# Accept input data of any numerical type, then promote
return MatDeforElastIso(mr, float.(promote(mass_density, E, nu, CTE)))
end
"""
MatDeforElastIso(
mr::Type{MR},
E::N,
nu::N,
) where {MR<:AbstractDeforModelRed,N<:Number}
Create isotropic elastic material with default mass density and thermal expansion.
"""
function MatDeforElastIso(
mr::Type{MR},
E::N,
nu::N,
) where {MR<:AbstractDeforModelRed,N<:Number}
mass_density = 1.0
CTE = 0.0
return MatDeforElastIso(mr, float.(promote(mass_density, E, nu, CTE)))
end
################################################################################
# 3-D solid model
################################################################################
"""
MatDeforElastIso(mr::Type{DeforModelRed3D}, args::NTuple{4, FT}) where FT
Create elastic isotropic material for 3D stress models.
"""
function MatDeforElastIso(mr::Type{DeforModelRed3D}, args::NTuple{4,FT}) where {FT}
mass_density, E, nu, CTE = args
function tangentmoduli3d!(
self::MatDeforElastIso,
D::Matrix{FT},
t::FT,
dt::FT,
loc::Matrix{FT},
label::Int,
)
copyto!(D, self.D)
return D
end
function update3d!(
self::MatDeforElastIso,
stress::Vector{FT},
output::Vector{FT},
strain::Vector{FT},
thstrain::Vector{FT} = zeros(6),
t = 0.0,
dt = 0.0,
loc::Matrix{FT} = zeros(3, 1),
label::Int = 0,
quantity = :nothing,
)
@assert length(stress) == nstressstrain(self.mr)
A_mul_B!(stress, self.D, strain - thstrain)
if quantity == :nothing
#Nothing to be copied to the output array
elseif quantity == :cauchy || quantity == :Cauchy
(length(output) >= 6) || (output = zeros(6)) # make sure we can store it
copyto!(output, stress)
elseif quantity == :pressure || quantity == :Pressure
output[1] = -sum(stress[1:3]) / 3.0
elseif quantity == :princCauchy || quantity == :princcauchy
t = zeros(FT, 3, 3)
t = stressvtot!(mr, t, stress)
ep = eigen(t)
(length(output) >= 3) || (output = zeros(3)) # make sure we can store it
copyto!(output, sort(ep.values, rev = true))
elseif quantity == :maxshear
t = zeros(FT, 3, 3)
t = stressvtot!(mr, t, stress)
ep = eigen(t)
(length(output) >= 1) || (output = zeros(1)) # make sure we can store it
s = sort(ep.values, rev = true)
copyto!(output, s[1] - s[3])
elseif quantity == :vonMises ||
quantity == :vonmises ||
quantity == :von_mises ||
quantity == :vm
s1 = stress[1]
s2 = stress[2]
s3 = stress[3]
s4 = stress[4]
s5 = stress[5]
s6 = stress[6]
(length(output) >= 1) || (output = zeros(1)) # make sure we can store it
output[1] = sqrt(
1.0 / 2 *
((s1 - s2)^2 + (s1 - s3)^2 + (s2 - s3)^2 + 6 * (s4^2 + s5^2 + s6^2)),
)
end
return output
end
function thermalstrain3d!(self::MatDeforElastIso, thstrain::Vector{FT}, dT = 0.0)
@assert length(thstrain) == nthermstrain(self.mr)
thstrain[1] = self.CTE * dT
thstrain[2] = self.CTE * dT
thstrain[3] = self.CTE * dT
thstrain[4] = 0.0
thstrain[5] = 0.0
thstrain[6] = 0.0
return thstrain
end
return MatDeforElastIso(
mr,
mass_density,
E,
nu,
CTE,
_threedD(E, nu),
tangentmoduli3d!,
update3d!,
thermalstrain3d!,
)
end
################################################################################
# 2-D plane stress
################################################################################
"""
MatDeforElastIso(mr::Type{DeforModelRed2DStress}, args::NTuple{4, FT}) where FT
Create elastic isotropic material for 2D plane stress models.
"""
function MatDeforElastIso(mr::Type{DeforModelRed2DStress}, args::NTuple{4,FT}) where {FT}
mass_density, E, nu, CTE = args
function tangentmoduli2dstrs!(
self::MatDeforElastIso,
D::Matrix{FT},
t::FT,
dt::FT,
loc::Matrix{FT},
label::Int,
)
D[1:2, 1:2] =
self.D[1:2, 1:2] -
(reshape(self.D[1:2, 3], 2, 1) * reshape(self.D[3, 1:2], 1, 2)) / self.D[3, 3]
ix = [1, 2, 4]
for i = 1:3
D[3, i] = D[i, 3] = self.D[4, ix[i]]
end
return D
end
function update2dstrs!(
self::MatDeforElastIso,
stress::Vector{FT},
output::Vector{FT},
strain::Vector{FT},
thstrain::Vector{FT} = zeros(3),
t = 0.0,
dt = 0.0,
loc::Matrix{FT} = zeros(3, 1),
label::Int = 0,
quantity = :nothing,
)
@assert length(stress) == nstressstrain(self.mr)
D = zeros(3, 3)
tangentmoduli2dstrs!(self, D, t, dt, loc, label)
A_mul_B!(stress, D, strain - thstrain)
if quantity == :nothing
#Nothing to be copied to the output array
elseif quantity == :cauchy || quantity == :Cauchy
(length(output) >= 3) || (output = zeros(3)) # make sure we can store it
copyto!(output, stress)
elseif quantity == :pressure || quantity == :Pressure
(length(output) >= 1) || (output = zeros(1)) # make sure we can store it
output[1] = -sum(stress[1:2]) / 3.0
elseif quantity == :princCauchy || quantity == :princcauchy
t = zeros(FT, 2, 2)
t = stressvtot!(mr, t, stress)
ep = eigen(t)
(length(output) >= 2) || (output = zeros(2)) # make sure we can store it
copyto!(output, sort(ep.values, rev = true))
elseif quantity == :maxshear
t = zeros(FT, 2, 2)
t = stressvtot!(mr, t, stress)
ep = eigen(t)
(length(output) >= 1) || (output = zeros(1)) # make sure we can store it
s = sort(ep.values, rev = true)
copyto!(output, s[1] - s[2])
elseif quantity == :vonMises ||
quantity == :vonmises ||
quantity == :von_mises ||
quantity == :vm
s1 = stress[1]
s2 = stress[2]
s3 = 0.0
s4 = stress[3]
s5 = 0.0
s6 = 0.0
(length(output) >= 1) || (output = zeros(1)) # make sure we can store it
output[1] = sqrt(
1.0 / 2 *
((s1 - s2)^2 + (s1 - s3)^2 + (s2 - s3)^2 + 6 * (s4^2 + s5^2 + s6^2)),
)
end
return output
end
function thermalstrain2dstrs!(self::MatDeforElastIso, thstrain::Vector{FT}, dT = 0.0)
@assert length(thstrain) == nthermstrain(self.mr)
thstrain[1] = self.CTE * dT
thstrain[2] = self.CTE * dT
thstrain[3] = 0.0
return thstrain
end
return MatDeforElastIso(
mr,
mass_density,
E,
nu,
CTE,
_threedD(E, nu),
tangentmoduli2dstrs!,
update2dstrs!,
thermalstrain2dstrs!,
)
end
################################################################################
# 2-D plane strain
################################################################################
"""
MatDeforElastIso(mr::Type{DeforModelRed2DStrain}, args::NTuple{4, FT}) where FT
Create elastic isotropic material for 2D plane strain models.
"""
function MatDeforElastIso(mr::Type{DeforModelRed2DStrain}, args::NTuple{4,FT}) where {FT}
mass_density, E, nu, CTE = args
function tangentmoduli2dstrn!(
self::MatDeforElastIso,
D::Matrix{FT},
t,
dt,
loc::Matrix{FT},
label::Int,
)
ix = [1, 2, 4]
for i in eachindex(ix)
for j in eachindex(ix)
D[j, i] = self.D[ix[j], ix[i]]
end
end
return D
end
# Note on the principal stresses: The principal stresses are calculated for the
# fully three-dimensional stress state, that is not the "in-plane" maximum and
# minimum, but rather the three-dimensional maximum (1) and minimum (3).
# The intermediate principal stress is (2).
function update2dstrn!(
self::MatDeforElastIso,
stress::Vector{FT},
output::Vector{FT},
strain::Vector{FT},
thstrain::Vector{FT} = zeros(4),
t = 0.0,
dt = 0.0,
loc::Matrix{FT} = zeros(3, 1),
label::Int = 0,
quantity = :nothing,
)
@assert length(stress) == nstressstrain(self.mr)
D = zeros(3, 3)
tangentmoduli2dstrn!(self, D, t, dt, loc, label)
A_mul_B!(stress, D, strain - thstrain[1:3])
if quantity == :nothing
#Nothing to be copied to the output array
elseif quantity == :cauchy || quantity == :Cauchy
# sigmax, sigmay, tauxy, sigmaz
# thstrain[4] =The through the thickness thermal strain
sz =
dot(self.D[3, 1:2], strain[1:2] - thstrain[1:2]) -
self.D[3, 3] * thstrain[4]
(length(output) >= 4) || (output = zeros(4)) # make sure we can store it
copyto!(output, stress)
output[4] = sz
elseif quantity == :pressure || quantity == :Pressure
(length(output) >= 1) || (output = zeros(1)) # make sure we can store it
sz =
dot(self.D[3, 1:2], strain[1:2] - thstrain[1:2]) -
self.D[3, 3] * thstrain[4]
output[1] = -(sum(stress[[1, 2]]) + sz) / 3.0
elseif quantity == :princCauchy || quantity == :princcauchy
(length(output) >= 3) || (output = zeros(3)) # make sure we can store it
t = zeros(FT, 3, 3)
sz =
dot(self.D[3, 1:2], strain[1:2] - thstrain[1:2]) -
self.D[3, 3] * thstrain[4]
t = stressvtot!(mr, t, vcat(stress[1:3], [sz]))
ep = eigen(t)
(length(output) >= 3) || (output = zeros(3)) # make sure we can store it
copyto!(output, sort(ep.values, rev = true))
elseif quantity == :maxshear
(length(output) >= 3) || (output = zeros(3)) # make sure we can store it
t = zeros(FT, 3, 3)
sz =
dot(self.D[3, 1:2], strain[1:2] - thstrain[1:2]) -
self.D[3, 3] * thstrain[4]
t = stressvtot!(mr, t, vcat(stress[1:3], [sz]))
ep = eigen(t)
(length(output) >= 1) || (output = zeros(1)) # make sure we can store it
s = sort(ep.values, rev = true)
copyto!(output, s[1] - s[3])
elseif quantity == :vonMises ||
quantity == :vonmises ||
quantity == :von_mises ||
quantity == :vm
(length(output) >= 1) || (output = zeros(1)) # make sure we can store it
sz =
dot(self.D[3, 1:2], strain[1:2] - thstrain[1:2]) -
self.D[3, 3] * thstrain[4]
s1 = stress[1]
s2 = stress[2]
s3 = sz
s4 = stress[3]
s5 = 0.0
s6 = 0.0
(length(output) >= 1) || (output = zeros(1)) # make sure we can store it
output[1] = sqrt(
1.0 / 2 *
((s1 - s2)^2 + (s1 - s3)^2 + (s2 - s3)^2 + 6 * (s4^2 + s5^2 + s6^2)),
)
end
return output
end
function thermalstrain2dstrn!(self::MatDeforElastIso, thstrain::Vector{FT}, dT = 0.0)
@assert length(thstrain) == nthermstrain(self.mr)
thstrain[1] = self.CTE * dT
thstrain[2] = self.CTE * dT
thstrain[3] = 0.0
thstrain[4] = self.CTE * dT
return thstrain
end
return MatDeforElastIso(
mr,
mass_density,
E,
nu,
CTE,
_threedD(E, nu),
tangentmoduli2dstrn!,
update2dstrn!,
thermalstrain2dstrn!,
)
end
################################################################################
# 2-D axially symmetric
################################################################################
"""
MatDeforElastIso(mr::Type{DeforModelRed2DAxisymm}, args::NTuple{4, FT}) where FT
Create elastic isotropic material for 2D axially symmetric models.
"""
function MatDeforElastIso(mr::Type{DeforModelRed2DAxisymm}, args::NTuple{4,FT}) where {FT}
mass_density, E, nu, CTE = args
function tangentmoduli2daxi!(
self::MatDeforElastIso,
D::Matrix{FT},
t,
dt,
loc::Matrix{FT},
label::Int,
)
for i = 1:4
for j = 1:4
D[j, i] = self.D[i, j]
end
end
return D
end
function update2daxi!(
self::MatDeforElastIso,
stress::Vector{FT},
output::Vector{FT},
strain::Vector{FT},
thstrain::Vector{FT} = zeros(3),
t = 0.0,
dt = 0.0,
loc::Matrix{FT} = zeros(3, 1),
label::Int = 0,
quantity = :nothing,
)
@assert length(stress) == nstressstrain(self.mr)
D = zeros(4, 4)
tangentmoduli2daxi!(self, D, t, dt, loc, label)
A_mul_B!(stress, D, strain - thstrain)
if quantity == :nothing
#Nothing to be copied to the output array
elseif quantity == :cauchy || quantity == :Cauchy
(length(output) >= 4) || (output = zeros(4)) # make sure we can store it
copyto!(output, stress)
elseif quantity == :pressure || quantity == :Pressure
(length(output) >= 1) || (output = zeros(1)) # make sure we can store it
output[1] = -sum(stress[[1, 2, 3]]) / 3.0
elseif quantity == :princCauchy || quantity == :princcauchy
t = zeros(FT, 3, 3)
t = stressvtot!(mr, t, stress)
ep = eigen(t)
(length(output) >= 3) || (output = zeros(3)) # make sure we can store it
copyto!(output, sort(ep.values, rev = true))
elseif quantity == :maxshear
t = zeros(FT, 3, 3)
t = stressvtot!(mr, t, stress)
ep = eigen(t)
(length(output) >= 1) || (output = zeros(1)) # make sure we can store it
s = sort(ep.values, rev = true)
copyto!(output, s[1] - s[3])
elseif quantity == :vonMises ||
quantity == :vonmises ||
quantity == :von_mises ||
quantity == :vm
s1 = stress[1]
s2 = stress[2]
s3 = stress[3]
s4 = stress[4]
s5 = 0.0
s6 = 0.0
(length(output) >= 1) || (output = zeros(1)) # make sure we can store it
output[1] = sqrt(
1.0 / 2 *
((s1 - s2)^2 + (s1 - s3)^2 + (s2 - s3)^2 + 6 * (s4^2 + s5^2 + s6^2)),
)
end
return output
end
function thermalstrain2daxi!(self::MatDeforElastIso, thstrain::Vector{FT}, dT = 0.0)
@assert length(thstrain) == nthermstrain(self.mr)
thstrain[1] = self.CTE * dT
thstrain[2] = self.CTE * dT
thstrain[3] = self.CTE * dT
thstrain[4] = 0.0
return thstrain
end
return MatDeforElastIso(
mr,
mass_density,
E,
nu,
CTE,
_threedD(E, nu),
tangentmoduli2daxi!,
update2daxi!,
thermalstrain2daxi!,
)
end
################################################################################
# 1-D zero transverse strain
################################################################################
"""
MatDeforElastIso(mr::Type{DeforModelRed1DStrain}, args::NTuple{4, FT}) where FT
Create elastic isotropic material for 1D models.
"""
function MatDeforElastIso(mr::Type{DeforModelRed1DStrain}, args::NTuple{4,FT}) where {FT}
mass_density, E, nu, CTE = args
function tangentmoduli1d!(
self::MatDeforElastIso,
D::Matrix{FT},
t,
dt,
loc::Matrix{FT},
label::Int,
)
lambda = E * nu / (1 + nu) / (1 - 2 * (nu))
mu = E / 2.0 / (1 + nu)
D[1, 1] = lambda + 2 * mu
return D
end
function update1d!(
self::MatDeforElastIso,
stress::Vector{FT},
output::Vector{FT},
strain::Vector{FT},
thstrain::Vector{FT} = zeros(1),
t = 0.0,
dt = 0.0,
loc::Matrix{FT} = zeros(3, 1),
label::Int = 0,
quantity = :nothing,
)
@assert length(stress) == nstressstrain(self.mr)
D = zeros(1, 1)
tangentmoduli1d!(self, D, t, dt, loc, label)
A_mul_B!(stress, D, strain - thstrain)
if quantity == :nothing
#Nothing to be copied to the output array
elseif quantity == :cauchy || quantity == :Cauchy
(length(output) >= 1) || (output = zeros(1)) # make sure we can store it
copyto!(output, stress)
elseif quantity == :pressure || quantity == :Pressure
(length(output) >= 1) || (output = zeros(1)) # make sure we can store it
output[1] = -sum(stress[[1]]) / 3.0
elseif quantity == :princCauchy || quantity == :princcauchy
copyto!(output, stress[1])
elseif quantity == :vonMises ||
quantity == :vonmises ||
quantity == :von_mises ||
quantity == :vm
s1 = stress[1]
s2 = 0.0
s3 = 0.0
s4 = 0.0
s5 = 0.0
s6 = 0.0
(length(output) >= 1) || (output = zeros(1)) # make sure we can store it
output[1] = sqrt(
1.0 / 2 *
((s1 - s2)^2 + (s1 - s3)^2 + (s2 - s3)^2 + 6 * (s4^2 + s5^2 + s6^2)),
)
end
return output
end
function thermalstrain1d!(self::MatDeforElastIso, thstrain::Vector{FT}, dT = 0.0)
@assert length(thstrain) == nthermstrain(self.mr)
thstrain[1] = self.CTE * dT
return thstrain
end
return MatDeforElastIso(
mr,
mass_density,
E,
nu,
CTE,
_threedD(E, nu),
tangentmoduli1d!,
update1d!,
thermalstrain1d!,
)
end
################################################################################
# 1-D zero transverse stress
################################################################################
"""
MatDeforElastIso(mr::Type{DeforModelRed1DStress}, args::NTuple{4, FT}) where FT
Create elastic isotropic material for 1D models.
"""
function MatDeforElastIso(mr::Type{DeforModelRed1DStress}, args::NTuple{4,FT}) where {FT}
mass_density, E, nu, CTE = args
function tangentmoduli1d!(
self::MatDeforElastIso,
D::Matrix{FT},
t,
dt,
loc::Matrix{FT},
label::Int,
)
D3d = _threedD(E, nu)
D[1, 1] = D3d[1, 1] - transpose(D3d[1, 2:3]) * (D3d[2:3, 2:3] \ D3d[2:3, 1])
return D
end
function update1d!(
self::MatDeforElastIso,
stress::Vector{FT},
output::Vector{FT},
strain::Vector{FT},
thstrain::Vector{FT} = zeros(1),
t = 0.0,
dt = 0.0,
loc::Matrix{FT} = zeros(3, 1),
label::Int = 0,
quantity = :nothing,
)
@assert length(stress) == nstressstrain(self.mr)
D = zeros(1, 1)
tangentmoduli1d!(self, D, t, dt, loc, label)
A_mul_B!(stress, D, strain - thstrain)
if quantity == :nothing
#Nothing to be copied to the output array
elseif quantity == :cauchy || quantity == :Cauchy
(length(output) >= 1) || (output = zeros(1)) # make sure we can store it
copyto!(output, stress)
elseif quantity == :pressure || quantity == :Pressure
(length(output) >= 1) || (output = zeros(1)) # make sure we can store it
output[1] = -sum(stress[[1]]) / 3.0
elseif quantity == :princCauchy || quantity == :princcauchy
copyto!(output, stress[1])
elseif quantity == :vonMises ||
quantity == :vonmises ||
quantity == :von_mises ||
quantity == :vm
s1 = stress[1]
s2 = 0.0
s3 = 0.0
s4 = 0.0
s5 = 0.0
s6 = 0.0
(length(output) >= 1) || (output = zeros(1)) # make sure we can store it
output[1] = sqrt(
1.0 / 2 *
((s1 - s2)^2 + (s1 - s3)^2 + (s2 - s3)^2 + 6 * (s4^2 + s5^2 + s6^2)),
)
end
return output
end
function thermalstrain1d!(self::MatDeforElastIso, thstrain::Vector{FT}, dT = 0.0)
@assert length(thstrain) == nthermstrain(self.mr)
thstrain[1] = self.CTE * dT
return thstrain
end
return MatDeforElastIso(
mr,
mass_density,
E,
nu,
CTE,
_threedD(E, nu),
tangentmoduli1d!,
update1d!,
thermalstrain1d!,
)
end
# Lame split of the matrix of tangent moduli.
# Calculate the part of the material stiffness matrix that corresponds to
# the lambda Lame coefficient.
# Note: makes sense only for isotropic materials.
function lambda_split_tangent_moduli_lambda(E, nu)
lambda = E * nu / (1 + nu) / (1 - 2*(nu));
m1 = [1 1 1 0 0 0]';
return lambda * m1 * m1';
end
# Lame split of the matrix of tangent moduli.
# Calculate the part of the material stiffness matrix that corresponds to
# the mu Lame coefficient.
# Note: makes sense only for isotropic materials.
function lambda_split_tangent_moduli_shear(E, nu)
mu = E / (2 * (1 + nu));
mI = diag([1 1 1 0.5 0.5 0.5]);
return 2 * mu * mI;
end
# Bulk-shear split of the matrix of tangent moduli.
# Calculate the part of the material stiffness matrix that corresponds to
# the bulk modulus.
# Note: makes sense only for isotropic materials.
function bulk_split_tangent_moduli_bulk(E, nu)
B = E / 3 / (1 - 2*(nu));
m1 = [1 1 1 0 0 0]';
return B * m1 * m1';
end
# Bulk-shear split of the matrix of tangent moduli.
# Calculate the part of the material stiffness matrix that correspond to shear.
# Note: makes sense only for isotropic materials.
function bulk_split_tangent_moduli_shear(E, nu)
G = E / (2 * (1 + nu))
return G * [2/3*[2 -1 -1; -1 2 -1; -1 -1 2] zeros(3, 3); zeros(3, 3) I(3)]
end
end
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 21493 | """
Module for linear orthotropic elastic response.
"""
module MatDeforElastOrthoModule
__precompile__(true)
using FinEtools.DeforModelRedModule:
AbstractDeforModelRed,
DeforModelRed3D,
DeforModelRed2DStrain,
DeforModelRed2DStress,
DeforModelRed2DAxisymm,
DeforModelRed1D,
nstressstrain,
nthermstrain
using FinEtoolsDeforLinear.MatDeforModule: AbstractMatDefor, stressvtot!
using FinEtoolsDeforLinear.MatDeforLinearElasticModule: AbstractMatDeforLinearElastic
using LinearAlgebra: mul!
At_mul_B!(C, A, B) = mul!(C, Transpose(A), B)
A_mul_B!(C, A, B) = mul!(C, A, B)
using LinearAlgebra: eigen, eigvals, rank, dot
"""
struct MatDeforElastOrtho{
MR<:AbstractDeforModelRed,
FT,
MTAN<:Function,
MUPD<:Function,
MTHS<:Function,
} <: AbstractMatDeforLinearElastic
Linear orthotropic elasticity material.
"""
struct MatDeforElastOrtho{
MR<:AbstractDeforModelRed,
FT,
MTAN<:Function,
MUPD<:Function,
MTHS<:Function,
} <: AbstractMatDeforLinearElastic
mr::Type{MR}
mass_density::FT # mass density
E1::FT # Young's modulus for material direction 1
E2::FT # Young's modulus for material direction 2
E3::FT # Young's modulus for material direction 3
nu12::FT
nu13::FT
nu23::FT
G12::FT
G13::FT
G23::FT
CTE1::FT # three thermal expansion coefficients
CTE2::FT # three thermal expansion coefficients
CTE3::FT # three thermal expansion coefficients
D::Matrix{FT} # cached matrix of tangent moduli
tangentmoduli!::MTAN
update!::MUPD
thermalstrain!::MTHS
end
function _threedD(E1, E2, E3, nu12, nu13, nu23, G12, G13, G23)
C = [
1.0/E1 -nu12/E1 -nu13/E1 0.0 0.0 0.0
-nu12/E1 1.0/E2 -nu23/E2 0.0 0.0 0.0
-nu13/E1 -nu23/E2 1.0/E3 0.0 0.0 0.0
0.0 0.0 0.0 1/G12 0.0 0.0
0.0 0.0 0.0 0.0 1/G13 0.0
0.0 0.0 0.0 0.0 0.0 1/G23
]
D = inv(C)
if (rank(D) < 6)
error("Non-positive definite D!")
end
ev = eigvals(D)
for e in ev
#println("$e")
if (e < 0.0)
error("Indefinite D!")
end
end
return D
end
"""
MatDeforElastOrtho(
mr::Type{MR},
mass_density::N,
E1::N,
E2::N,
E3::N,
nu12::N,
nu13::N,
nu23::N,
G12::N,
G13::N,
G23::N,
CTE1::N,
CTE2::N,
CTE3::N,
) where {MR<:AbstractDeforModelRed,N<:Number}
Create elastic orthotropic material.
"""
function MatDeforElastOrtho(
mr::Type{MR},
mass_density::N,
E1::N,
E2::N,
E3::N,
nu12::N,
nu13::N,
nu23::N,
G12::N,
G13::N,
G23::N,
CTE1::N,
CTE2::N,
CTE3::N,
) where {MR<:AbstractDeforModelRed,N<:Number}
return MatDeforElastOrtho(
mr,
float.(
promote(
mass_density,
E1,
E2,
E3,
nu12,
nu13,
nu23,
G12,
G13,
G23,
CTE1,
CTE2,
CTE3,
)
),
)
end
"""
MatDeforElastOrtho(
mr::Type{MR},
E1::N,
E2::N,
E3::N,
nu12::N,
nu13::N,
nu23::N,
G12::N,
G13::N,
G23::N,
) where {MR<:AbstractDeforModelRed,N<:Number}
Create elastic orthotropic material.
Convenience version with only the specification of the elastic properties.
"""
function MatDeforElastOrtho(
mr::Type{MR},
E1::N,
E2::N,
E3::N,
nu12::N,
nu13::N,
nu23::N,
G12::N,
G13::N,
G23::N,
) where {MR<:AbstractDeforModelRed,N<:Number}
mass_density = 1.0
CTE1 = CTE2 = CTE3 = 0.0
return MatDeforElastOrtho(
mr,
float.(
promote(
mass_density,
E1,
E2,
E3,
nu12,
nu13,
nu23,
G12,
G13,
G23,
CTE1,
CTE2,
CTE3,
)
),
)
end
"""
MatDeforElastOrtho(
mr::Type{MR},
E::N,
nu::N,
) where {MR<:AbstractDeforModelRed,N<:Number}
Create elastic orthotropic material which is really isotropic.
Convenience version with only the specification of the elastic properties.
"""
function MatDeforElastOrtho(
mr::Type{MR},
E::N,
nu::N,
) where {MR<:AbstractDeforModelRed,N<:Number}
mass_density = 1.0
E1 = E2 = E3 = E
nu12 = nu13 = nu23 = nu
CTE1 = CTE2 = CTE3 = 0.0
G = E / 2.0 / (1 + nu)
G12 = G13 = G23 = G
return MatDeforElastOrtho(
mr,
float.(
promote(
mass_density,
E1,
E2,
E3,
nu12,
nu13,
nu23,
G12,
G13,
G23,
CTE1,
CTE2,
CTE3,
)
),
)
end
"""
MatDeforElastOrtho(
mr::Type{MR},
mass_density::N,
E::N,
nu::N,
CTE::N,
) where {MR<:AbstractDeforModelRed,N<:Number}
Create elastic orthotropic material which is really isotropic.
Convenience version with only the specification of the mass density, and
the elastic and thermal expansion properties.
"""
function MatDeforElastOrtho(
mr::Type{MR},
mass_density::N,
E::N,
nu::N,
CTE::N,
) where {MR<:AbstractDeforModelRed,N<:Number}
E1 = E2 = E3 = E
nu12 = nu13 = nu23 = nu
CTE1 = CTE2 = CTE3 = CTE
G = E / 2.0 / (1 + nu)
G12 = G13 = G23 = G
return MatDeforElastOrtho(
mr,
float.(
promote(
mass_density,
E1,
E2,
E3,
nu12,
nu13,
nu23,
G12,
G13,
G23,
CTE1,
CTE2,
CTE3,
)
),
)
end
"""
MatDeforElastOrtho(
mr::Type{MR},
E::N,
nu::N,
CTE::N,
) where {MR<:AbstractDeforModelRed,N<:Number}
Create elastic orthotropic material which is really isotropic.
Convenience version with only the specification of the elastic and thermal expansion properties.
"""
function MatDeforElastOrtho(
mr::Type{MR},
E::N,
nu::N,
CTE::N,
) where {MR<:AbstractDeforModelRed,N<:Number}
mass_density = 1.0
E1 = E2 = E3 = E
nu12 = nu13 = nu23 = nu
CTE1 = CTE2 = CTE3 = CTE
G = E / 2.0 / (1 + nu)
G12 = G13 = G23 = G
return MatDeforElastOrtho(
mr,
float.(
promote(
mass_density,
E1,
E2,
E3,
nu12,
nu13,
nu23,
G12,
G13,
G23,
CTE1,
CTE2,
CTE3,
)
),
)
end
################################################################################
# 3-D solid model
################################################################################
"""
MatDeforElastOrtho(mr::Type{DeforModelRed3D}, args::NTuple{13, FT}) where FT
Create elastic orthotropic material for 3D models.
"""
function MatDeforElastOrtho(mr::Type{DeforModelRed3D}, args::NTuple{13,FT}) where {FT}
mass_density, E1, E2, E3, nu12, nu13, nu23, G12, G13, G23, CTE1, CTE2, CTE3 = args
function tangentmoduli3d!(
self::MatDeforElastOrtho,
D::Matrix{FT},
t::FT,
dt::FT,
loc::Matrix{FT},
label::Int,
)
copyto!(D, self.D)
return D
end
function update3d!(
self::MatDeforElastOrtho,
stress::Vector{FT},
output::Vector{FT},
strain::Vector{FT},
thstrain::Vector{FT} = zeros(6),
t::FT = 0.0,
dt::FT = 0.0,
loc::Matrix{FT} = zeros(3, 1),
label::Int = 0,
quantity = :nothing,
)
@assert length(stress) == nstressstrain(self.mr)
A_mul_B!(stress, self.D, strain - thstrain)
if quantity == :nothing
#Nothing to be copied to the output array
elseif quantity == :cauchy || quantity == :Cauchy
(length(output) >= 6) || (output = zeros(6)) # make sure we can store it
copyto!(output, stress)
elseif quantity == :pressure || quantity == :Pressure
output[1] = -sum(stress[1:3]) / 3.0
elseif quantity == :princCauchy || quantity == :princcauchy
t = zeros(FT, 3, 3)
t = stressvtot!(mr, t, stress)
ep = eigen(t)
(length(output) >= 3) || (output = zeros(3)) # make sure we can store it
copyto!(output, sort(ep.values, rev = true))
elseif quantity == :vonMises ||
quantity == :vonmises ||
quantity == :von_mises ||
quantity == :vm
s1 = stress[1]
s2 = stress[2]
s3 = stress[3]
s4 = stress[4]
s5 = stress[5]
s6 = stress[6]
(length(output) >= 1) || (output = zeros(1)) # make sure we can store it
output[1] = sqrt(
1.0 / 2 *
((s1 - s2)^2 + (s1 - s3)^2 + (s2 - s3)^2 + 6 * (s4^2 + s5^2 + s6^2)),
)
end
return output
end
function thermalstrain3d!(self::MatDeforElastOrtho, thstrain::Vector{FT}, dT = 0.0)
thstrain[1] = self.CTE1 * dT
thstrain[2] = self.CTE2 * dT
thstrain[3] = self.CTE3 * dT
thstrain[4] = 0.0
thstrain[5] = 0.0
thstrain[6] = 0.0
return thstrain
end
return MatDeforElastOrtho(
mr,
mass_density,
E1,
E2,
E3,
nu12,
nu13,
nu23,
G12,
G13,
G23,
CTE1,
CTE2,
CTE3,
_threedD(E1, E2, E3, nu12, nu13, nu23, G12, G13, G23),
tangentmoduli3d!,
update3d!,
thermalstrain3d!,
)
end
################################################################################
# 2-D plane stress
################################################################################
"""
MatDeforElastOrtho(mr::Type{DeforModelRed2DStress}, args::NTuple{13, FT}) where FT
Create elastic orthotropic material for 2D plane stress models.
"""
function MatDeforElastOrtho(mr::Type{DeforModelRed2DStress}, args::NTuple{13,FT}) where {FT}
mass_density, E1, E2, E3, nu12, nu13, nu23, G12, G13, G23, CTE1, CTE2, CTE3 = args
function tangentmoduli2dstrs!(
self::MatDeforElastOrtho,
D::Matrix{FT},
t::FT,
dt::FT,
loc::Matrix{FT},
label::Int,
)
D[1:2, 1:2] =
self.D[1:2, 1:2] -
(reshape(self.D[1:2, 3], 2, 1) * reshape(self.D[3, 1:2], 1, 2)) / self.D[3, 3]
ix = [1, 2, 4]
for i = 1:3
D[3, i] = D[i, 3] = self.D[4, ix[i]]
end
return D
end
function update2dstrs!(
self::MatDeforElastOrtho,
stress::Vector{FT},
output::Vector{FT},
strain::Vector{FT},
thstrain::Vector{FT} = zeros(3),
t::FT = 0.0,
dt::FT = 0.0,
loc::Matrix{FT} = zeros(3, 1),
label::Int = 0,
quantity = :nothing,
)
@assert length(stress) == nstressstrain(self.mr)
D = zeros(3, 3)
tangentmoduli2dstrs!(self, D, t, dt, loc, label)
A_mul_B!(stress, D, strain - thstrain)
if quantity == :nothing
#Nothing to be copied to the output array
elseif quantity == :cauchy || quantity == :Cauchy
(length(output) >= 3) || (output = zeros(3)) # make sure we can store it
copyto!(output, stress)
elseif quantity == :pressure || quantity == :Pressure
(length(output) >= 1) || (output = zeros(1)) # make sure we can store it
output[1] = -sum(stress[1:2]) / 3.0
elseif quantity == :princCauchy || quantity == :princcauchy
t = zeros(FT, 2, 2)
t = stressvtot!(mr, t, stress)
ep = eigen(t)
(length(output) >= 2) || (output = zeros(2)) # make sure we can store it
copyto!(output, sort(ep.values, rev = true))
elseif quantity == :vonMises ||
quantity == :vonmises ||
quantity == :von_mises ||
quantity == :vm
s1 = stress[1]
s2 = stress[2]
s3 = 0.0
s4 = stress[3]
s5 = 0.0
s6 = 0.0
(length(output) >= 1) || (output = zeros(1)) # make sure we can store it
output[1] = sqrt(
1.0 / 2 *
((s1 - s2)^2 + (s1 - s3)^2 + (s2 - s3)^2 + 6 * (s4^2 + s5^2 + s6^2)),
)
end
return output
end
function thermalstrain2dstrs!(self::MatDeforElastOrtho, thstrain::Vector{FT}, dT = 0.0)
@assert length(thstrain) == nthermstrain(self.mr)
thstrain[1] = self.CTE1 * dT
thstrain[2] = self.CTE2 * dT
thstrain[3] = 0.0
return thstrain
end
return MatDeforElastOrtho(
mr,
mass_density,
E1,
E2,
E3,
nu12,
nu13,
nu23,
G12,
G13,
G23,
CTE1,
CTE2,
CTE3,
_threedD(E1, E2, E3, nu12, nu13, nu23, G12, G13, G23),
tangentmoduli2dstrs!,
update2dstrs!,
thermalstrain2dstrs!,
)
end
################################################################################
# 2-D plane strain
################################################################################
"""
MatDeforElastOrtho(mr::Type{DeforModelRed2DStrain}, args::NTuple{13, FT}) where FT
Create elastic orthotropic material for 2D plane strain models.
"""
function MatDeforElastOrtho(mr::Type{DeforModelRed2DStrain}, args::NTuple{13,FT}) where {FT}
mass_density, E1, E2, E3, nu12, nu13, nu23, G12, G13, G23, CTE1, CTE2, CTE3 = args
function tangentmoduli2dstrn!(
self::MatDeforElastOrtho,
D::Matrix{FT},
t::FT,
dt::FT,
loc::Matrix{FT},
label::Int,
)
ix = [1, 2, 4]
for i in eachindex(ix)
for j in eachindex(ix)
D[j, i] = self.D[ix[j], ix[i]]
end
end
return D
end
function update2dstrn!(
self::MatDeforElastOrtho,
stress::Vector{FT},
output::Vector{FT},
strain::Vector{FT},
thstrain::Vector{FT} = zeros(4),
t::FT = 0.0,
dt::FT = 0.0,
loc::Matrix{FT} = zeros(3, 1),
label::Int = 0,
quantity = :nothing,
)
@assert length(stress) == nstressstrain(self.mr)
D = zeros(3, 3)
tangentmoduli2dstrn!(self, D, t, dt, loc, label)
A_mul_B!(stress, D, strain - thstrain[1:3])
if quantity == :nothing
#Nothing to be copied to the output array
elseif quantity == :cauchy || quantity == :Cauchy
# sigmax, sigmay, tauxy, sigmaz
# thstrain[4] =The through the thickness thermal strain
sz =
dot(self.D[3, 1:2], strain[1:2] - thstrain[1:2]) -
self.D[3, 3] * thstrain[4]
(length(output) >= 4) || (output = zeros(4)) # make sure we can store it
copyto!(output, stress)
output[4] = sz
elseif quantity == :pressure || quantity == :Pressure
(length(output) >= 1) || (output = zeros(1)) # make sure we can store it
sz =
dot(self.D[3, 1:2], strain[1:2] - thstrain[1:2]) -
self.D[3, 3] * thstrain[4]
output[1] = -(sum(stress[[1, 2]]) + sz) / 3.0
elseif quantity == :princCauchy || quantity == :princcauchy
(length(output) >= 3) || (output = zeros(3)) # make sure we can store it
t = zeros(FT, 3, 3)
sz =
dot(self.D[3, 1:2], strain[1:2] - thstrain[1:2]) -
self.D[3, 3] * thstrain[4]
t = stressvtot!(mr, t, vcat(stress[1:3], [sz]))
ep = eigen(t)
(length(output) >= 3) || (output = zeros(3)) # make sure we can store it
copyto!(output, sort(ep.values, rev = true))
elseif quantity == :vonMises ||
quantity == :vonmises ||
quantity == :von_mises ||
quantity == :vm
(length(output) >= 1) || (output = zeros(1)) # make sure we can store it
sz =
dot(self.D[3, 1:2], strain[1:2] - thstrain[1:2]) -
self.D[3, 3] * thstrain[4]
s1 = stress[1]
s2 = stress[2]
s3 = sz
s4 = stress[3]
s5 = 0.0
s6 = 0.0
(length(output) >= 1) || (output = zeros(1)) # make sure we can store it
output[1] = sqrt(
1.0 / 2 *
((s1 - s2)^2 + (s1 - s3)^2 + (s2 - s3)^2 + 6 * (s4^2 + s5^2 + s6^2)),
)
end
return output
end
function thermalstrain2dstrn!(self::MatDeforElastOrtho, thstrain::Vector{FT}, dT = 0.0)
@assert length(thstrain) == nthermstrain(self.mr)
thstrain[1] = self.CTE1 * dT
thstrain[2] = self.CTE2 * dT
thstrain[3] = 0.0
thstrain[4] = self.CTE3 * dT
return thstrain
end
return MatDeforElastOrtho(
mr,
mass_density,
E1,
E2,
E3,
nu12,
nu13,
nu23,
G12,
G13,
G23,
CTE1,
CTE2,
CTE3,
_threedD(E1, E2, E3, nu12, nu13, nu23, G12, G13, G23),
tangentmoduli2dstrn!,
update2dstrn!,
thermalstrain2dstrn!,
)
end
################################################################################
# 2-D axially symmetric
################################################################################
"""
MatDeforElastOrtho(mr::Type{DeforModelRed2DAxisymm}, args::NTuple{13, FT}) where FT
Create elastic orthotropic material for 2D axially symmetric models.
"""
function MatDeforElastOrtho(
mr::Type{DeforModelRed2DAxisymm},
args::NTuple{13,FT},
) where {FT}
mass_density, E1, E2, E3, nu12, nu13, nu23, G12, G13, G23, CTE1, CTE2, CTE3 = args
function tangentmoduli2daxi!(
self::MatDeforElastOrtho,
D::Matrix{FT},
t::FT,
dt::FT,
loc::Matrix{FT},
label::Int,
)
for i = 1:4
for j = 1:4
D[i, j] = self.D[i, j]
end
end
return D
end
function update2daxi!(
self::MatDeforElastOrtho,
stress::Vector{FT},
output::Vector{FT},
strain::Vector{FT},
thstrain::Vector{FT} = zeros(3),
t::FT = 0.0,
dt::FT = 0.0,
loc::Matrix{FT} = zeros(3, 1),
label::Int = 0,
quantity = :nothing,
)
@assert length(stress) == nstressstrain(self.mr)
D = zeros(4, 4)
tangentmoduli2daxi!(self, D, t, dt, loc, label)
A_mul_B!(stress, D, strain - thstrain)
if quantity == :nothing
#Nothing to be copied to the output array
elseif quantity == :cauchy || quantity == :Cauchy
(length(output) >= 4) || (output = zeros(4)) # make sure we can store it
copyto!(output, stress)
elseif quantity == :pressure || quantity == :Pressure
(length(output) >= 1) || (output = zeros(1)) # make sure we can store it
output[1] = -sum(stress[[1, 2, 3]]) / 3.0
elseif quantity == :princCauchy || quantity == :princcauchy
t = zeros(FT, 3, 3)
t = stressvtot!(mr, t, stress)
ep = eigen(t)
(length(output) >= 3) || (output = zeros(3)) # make sure we can store it
copyto!(output, sort(ep.values, rev = true))
elseif quantity == :vonMises ||
quantity == :vonmises ||
quantity == :von_mises ||
quantity == :vm
s1 = stress[1]
s2 = stress[2]
s3 = stress[3]
s4 = stress[4]
s5 = 0.0
s6 = 0.0
(length(output) >= 1) || (output = zeros(1)) # make sure we can store it
output[1] = sqrt(
1.0 / 2 *
((s1 - s2)^2 + (s1 - s3)^2 + (s2 - s3)^2 + 6 * (s4^2 + s5^2 + s6^2)),
)
end
return output
end
function thermalstrain2daxi!(self::MatDeforElastOrtho, thstrain::Vector{FT}, dT = 0.0)
@assert length(thstrain) == nthermstrain(self.mr)
thstrain[1] = self.CTE1 * dT
thstrain[2] = self.CTE2 * dT
thstrain[3] = self.CTE3 * dT
thstrain[4] = 0.0
return thstrain
end
return MatDeforElastOrtho(
mr,
mass_density,
E1,
E2,
E3,
nu12,
nu13,
nu23,
G12,
G13,
G23,
CTE1,
CTE2,
CTE3,
_threedD(E1, E2, E3, nu12, nu13, nu23, G12, G13, G23),
tangentmoduli2daxi!,
update2daxi!,
thermalstrain2daxi!,
)
end
end
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 2802 | """
Basic functionality for linearly elastic materials.
"""
module MatDeforLinearElasticModule
__precompile__(true)
using FinEtools.DeforModelRedModule: AbstractDeforModelRed
using FinEtoolsDeforLinear.MatDeforModule: AbstractMatDefor
"""
AbstractMatDeforLinearElastic <: AbstractMatDefor
Abstract Linear Elasticity material.
"""
abstract type AbstractMatDeforLinearElastic <: AbstractMatDefor end
"""
tangentmoduli!(
self::AbstractMatDeforLinearElastic,
D::Matrix{FT},
t::FT,
dt::FT,
loc::Matrix{FT},
label::Int,
) where {FT}
Calculate the material stiffness matrix.
- `D` = matrix of tangent moduli, supplied as a buffer and overwritten. Returned
as output.
"""
function tangentmoduli!(
self::AbstractMatDeforLinearElastic,
D::Matrix{FT},
t::FT,
dt::FT,
loc::Matrix{FT},
label::Int,
) where {FT}
return self.tangentmoduli!(self, D, t, dt, loc, label)
end
"""
update!(
self::AbstractMatDeforLinearElastic,
stress::Vector{FT},
output::Vector{FT},
strain::Vector{FT},
thstrain::Vector{FT} = zeros(6),
t::FT = 0.0,
dt::FT = 0.0,
loc::Matrix{FT} = zeros(3, 1),
label::Int = 0,
quantity = :nothing,
) where {FT}
Update material state.
- `strain` = strain vector,
- `thstrain` = thermal strain vector,
- `t` = current time,
- `dt` = current time step,
- `loc` = location of the quadrature point in global Cartesian coordinates,
- `label` = label of the finite element in which the quadrature point is found.
# Output
- `stress` = stress vector, allocated by the caller with a size of the number of stress and
strain components, `nstressstrain`. The components of the stress vector are
calculated and stored in the `stress` vector.
- `output` = array which is (if necessary) allocated in an appropriate size, filled
with the output quantity, and returned.
"""
function update!(
self::AbstractMatDeforLinearElastic,
stress::Vector{FT},
output::Vector{FT},
strain::Vector{FT},
thstrain::Vector{FT} = zeros(6),
t::FT = 0.0,
dt::FT = 0.0,
loc::Matrix{FT} = zeros(3, 1),
label::Int = 0,
quantity = :nothing,
) where {FT}
return self.update!(self, stress, output, strain, thstrain, t, dt, loc, label, quantity)
end
"""
thermalstrain!(
self::AbstractMatDeforLinearElastic,
thstrain::Vector{FT},
dT = 0.0,
) where {FT}
Compute thermal strain from the supplied temperature increment.
- `thstrain` = thermal strain vector, supplied as buffer, returned as output.
"""
function thermalstrain!(
self::AbstractMatDeforLinearElastic,
thstrain::Vector{FT},
dT = 0.0,
) where {FT}
return self.thermalstrain!(self, thstrain, dT)
end
end
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 648 | """
MatDeforModule
Module to support general operations for deformation material models.
"""
module MatDeforModule
__precompile__(true)
using FinEtools.DeforModelRedModule:
DeforModelRed3D,
DeforModelRed2DStrain,
DeforModelRed2DStress,
DeforModelRed2DAxisymm,
DeforModelRed1D
using FinEtools.MatModule: AbstractMat
using LinearAlgebra
_RotationMatrix = Union{Array{T,2},Transpose{T,Array{T,2}}} where {T}
"""
AbstractMatDefor
Abstract type that represents deformable materials.
"""
abstract type AbstractMatDefor <: AbstractMat end
include("genconv.jl")
include("genrot.jl")
include("tens4impl.jl")
end # module
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 498 | include("MatDeforModule.jl")
include("MatDeforLinearElasticModule.jl")
include("MatDeforElastIsoModule.jl")
include("MatDeforElastOrthoModule.jl")
include("FEMMDeforLinearBaseModule.jl")
include("FEMMDeforLinearModule.jl")
include("FEMMDeforWinklerModule.jl")
include("FEMMDeforSurfaceDampingModule.jl")
include("FEMMDeforLinearIMModule.jl")
include("FEMMDeforLinearMSModule.jl")
include("FEMMDeforLinearNICEModule.jl")
include("FEMMDeforLinearESNICEModule.jl")
include("AlgoDeforLinearModule.jl")
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 7312 | ################################################################################
# 3-D model
"""
dett(::Type{DeforModelRed3D}, C::Matrix{T}) where {T}
Compute the determinant of a general square matrix.
"""
function dett(::Type{DeforModelRed3D}, C::Matrix{T}) where {T}
return (
C[1, 1] * C[2, 2] * C[3, 3] +
C[1, 2] * C[2, 3] * C[3, 1] +
C[1, 3] * C[2, 1] * C[3, 2] - C[1, 3] * C[2, 2] * C[3, 1] -
C[1, 2] * C[2, 1] * C[3, 3] - C[1, 1] * C[2, 3] * C[3, 2]
)
end
"""
strainvdet(::Type{DeforModelRed3D}, Cv::Vector{T}) where {T}
Compute the determinant of a symmetric strain-like square matrix represented
as a vector. Remember that the shear strain components are twice the entries
of the matrix representation.
"""
function strainvdet(::Type{DeforModelRed3D}, Cv::Vector{T}) where {T}
return (
Cv[1] * Cv[2] * Cv[3] +
Cv[4] / 2 * Cv[6] / 2 * Cv[5] / 2 +
Cv[5] / 2 * Cv[4] / 2 * Cv[6] / 2 - Cv[5] / 2 * Cv[2] * Cv[5] / 2 -
Cv[4] / 2 * Cv[4] / 2 * Cv[3] - Cv[1] * Cv[6] / 2 * Cv[6] / 2
)
end
"""
strainvtr(::Type{DeforModelRed3D}, Cv::Vector{T}) where {T}
Compute the trace of a symmetric strain-like square matrix represented as a
vector.
"""
function strainvtr(::Type{DeforModelRed3D}, Cv::Vector{T}) where {T}
return (Cv[1] + Cv[2] + Cv[3])
end
"""
strainttov!(::Type{DeforModelRed3D}, v::Vector{T}, t::Matrix{T}) where {T}
Convert a symmetric matrix of 3x3 strain components into a 6-component vector.
"""
function strainttov!(::Type{DeforModelRed3D}, v::Vector{T}, t::Matrix{T}) where {T}
v[1] = t[1, 1]
v[2] = t[2, 2]
v[3] = t[3, 3]
v[4] = t[1, 2] + t[2, 1]
v[5] = t[1, 3] + t[3, 1]
v[6] = t[3, 2] + t[2, 3]
return v
end
"""
strainvtot!(::Type{DeforModelRed3D}, t::Matrix{T}, v::Vector{T}) where {T}
Convert a strain 3-vector to a matrix of 2x2 strain components (symmetric tensor).
"""
function strainvtot!(::Type{DeforModelRed3D}, t::Matrix{T}, v::Vector{T}) where {T}
t[1, 1] = v[1]
t[2, 2] = v[2]
t[3, 3] = v[3]
t[1, 2] = v[4] / 2.0
t[2, 1] = v[4] / 2.0
t[1, 3] = v[5] / 2.0
t[3, 1] = v[5] / 2.0
t[3, 2] = v[6] / 2.0
t[2, 3] = v[6] / 2.0
return t
end
"""
stressttov!(::Type{DeforModelRed3D}, v::Vector{T}, t::Matrix{T}) where {T}
Convert a symmetric matrix of 3x3 stress components to a 6-component vector.
"""
function stressttov!(::Type{DeforModelRed3D}, v::Vector{T}, t::Matrix{T}) where {T}
v[1] = t[1, 1]
v[2] = t[2, 2]
v[3] = t[3, 3]
v[4] = 1 / 2.0 * (t[1, 2] + t[2, 1])
v[5] = 1 / 2.0 * (t[1, 3] + t[3, 1])
v[6] = 1 / 2.0 * (t[3, 2] + t[2, 3])
return v
end
"""
stressvtot!(::Type{DeforModelRed3D}, t::Matrix{T}, v::Vector{T}) where {T}
Convert a 6-vector to a matrix of 3x3 stress components (symmetric tensor).
"""
function stressvtot!(::Type{DeforModelRed3D}, t::Matrix{T}, v::Vector{T}) where {T}
t[1, 1] = v[1]
t[2, 2] = v[2]
t[3, 3] = v[3]
t[1, 2] = v[4]
t[2, 1] = v[4]
t[1, 3] = v[5]
t[3, 1] = v[5]
t[3, 2] = v[6]
t[2, 3] = v[6]
return t
end
################################################################################
# 2-D plane strain model
"""
dett(::Type{DeforModelRed2DStrain}, C::Matrix{T}) where {T}
Compute the determinant of a general square matrix.
"""
function dett(::Type{DeforModelRed2DStrain}, C::Matrix{T}) where {T}
return (C[1, 1] * C[2, 2] - C[1, 2] * C[2, 1])
end
"""
strainvdet(::Type{DeforModelRed2DStrain}, Cv::Vector{T}) where {T}
Compute the determinant of a symmetric strain-like square matrix represented
as a vector. Remember that the shear strain components are twice the entries
of the matrix representation.
"""
function strainvdet(::Type{DeforModelRed2DStrain}, Cv::Vector{T}) where {T}
return (Cv[1] * Cv[2] - Cv[3] / 2 * Cv[3] / 2)
end
"""
strainvtr(::Type{DeforModelRed2DStrain}, Cv::Vector{T}) where {T}
Compute the trace of a symmetric strain-like square matrix represented as a
vector.
"""
function strainvtr(::Type{DeforModelRed2DStrain}, Cv::Vector{T}) where {T}
return (Cv[1] + Cv[2])
end
"""
strainttov!(::Type{DeforModelRed2DStrain}, v::Vector{T}, t::Matrix{T}) where {T}
Convert a symmetric matrix of 2x2 strain components into a 3-component vector.
"""
function strainttov!(::Type{DeforModelRed2DStrain}, v::Vector{T}, t::Matrix{T}) where {T}
v[1] = t[1, 1]
v[2] = t[2, 2]
v[3] = t[1, 2] + t[2, 1]
return v
end
"""
strainvtot!(::Type{DeforModelRed2DStrain}, t::Matrix{T}, v::Vector{T}) where {T}
Convert a strain 3-vector to a matrix of 2x2 strain components (symmetric tensor).
"""
function strainvtot!(::Type{DeforModelRed2DStrain}, t::Matrix{T}, v::Vector{T}) where {T}
t[1, 1] = v[1]
t[2, 2] = v[2]
t[1, 2] = v[3] / 2.0
t[2, 1] = v[3] / 2.0
return t
end
"""
stressttov!(::Type{DeforModelRed2DStrain}, v::Vector{T}, t::Matrix{T}) where {T}
Convert a symmetric matrix of 2x2 stress components to a 3-component vector.
"""
function stressttov!(::Type{DeforModelRed2DStrain}, v::Vector{T}, t::Matrix{T}) where {T}
v[1] = t[1, 1]
v[2] = t[2, 2]
v[3] = 0.5 * (t[1, 2] + t[2, 1])
return v
end
"""
stressvtot!(::Type{DeforModelRed2DStrain}, t::Matrix{T}, v::Vector{T}) where {T}
Convert a vector to a matrix of 2x2 stress components (symmetric tensor).
If `v` has 4 entries, also the `t[3,3]` matrix entry is set.
The stress vector components need to be ordered as:
sigmax, sigmay, tauxy, sigmaz,
which is the ordering used for the plane-strain model reduction.
"""
function stressvtot!(::Type{DeforModelRed2DStrain}, t::Matrix{T}, v::Vector{T}) where {T}
t[1, 1] = v[1]
t[2, 2] = v[2]
t[1, 2] = v[3]
t[2, 1] = v[3]
(length(v) == 4) && (t[3, 3] = v[4])
return t
end
################################################################################
# 2-D plane stress model
"""
stressttov!(::Type{DeforModelRed2DStress}, v::Vector{T}, t::Matrix{T}) where {T}
Convert a symmetric matrix of 2x2 stress components to a 3-component vector.
"""
function stressttov!(::Type{DeforModelRed2DStress}, v::Vector{T}, t::Matrix{T}) where {T}
v[1] = t[1, 1]
v[2] = t[2, 2]
v[3] = 0.5 * (t[1, 2] + t[2, 1])
return v
end
"""
stressvtot!(::Type{DeforModelRed2DStress}, t::Matrix{T}, v::Vector{T}) where {T}
Convert a 3-vector to a matrix of 2x2 stress components (symmetric tensor).
"""
function stressvtot!(::Type{DeforModelRed2DStress}, t::Matrix{T}, v::Vector{T}) where {T}
t[1, 1] = v[1]
t[2, 2] = v[2]
t[1, 2] = v[3]
t[2, 1] = v[3]
return t
end
################################################################################
# 2-D axially symmetric stress model
"""
stressvtot!(::Type{DeforModelRed2DAxisymm}, t::Matrix{T}, v::Vector{T}) where {T}
Convert a 4-vector to a matrix of 3x3 stress components (tensor).
Convert a 4-vector to a *symmetric* matrix of 3x3 stress components (tensor).
The stress vector components need to be ordered as:
sigmax, sigmay, sigmaz, tauxy.
"""
function stressvtot!(::Type{DeforModelRed2DAxisymm}, t::Matrix{T}, v::Vector{T}) where {T}
t[1, 1] = v[1]
t[2, 2] = v[2]
t[1, 2] = v[4]
t[2, 1] = v[4]
t[3, 3] = v[3]
return t
end
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 9173 |
################################################################################
# 3-D model
"""
rotstressvec!(::Type{DeforModelRed3D}, outstress::Vector{T}, instress::Vector{T}, Rm::_RotationMatrix) where {T}
Rotate the stress vector by the supplied rotation matrix.
Calculate the rotation of the stress vector to the 'bar' coordinate system given
by the columns of the rotation matrix `Rm`.
- `outstress` = output stress vector, overwritten inside
- `instress` = input stress vector
- `Rm` = columns are components of 'bar' basis vectors on the 'plain'
basis vectors
"""
function rotstressvec!(
::Type{DeforModelRed3D},
outstress::Vector{T},
instress::Vector{T},
Rm::_RotationMatrix,
) where {T}
# # Derivation of the transformation matrix [T]
# #This is from Barbero''s book Finite element analysis of composite
# #materials using Abaqus. Note that his matrix "a" is the transpose of
# #the FinEALE matrix "Rm".
# # We also use the FinEALE numbering of the strains.
#
# syms T alpha R
# syms a a11 a12 a13 a21 a22 a23 a31 a32 a33 real
# a = [a11,a12,a13;
# a21,a22,a23;
# a31,a32,a33];
# a = a';#his matrix "a" is the transpose of the FinEALE matrix "Rm".
# # # it can be done in terms of l,m,n's as well
# # syms a l1 m1 n1 l2 m2 n2 l3 m3 n3
# # a = [l1,m1,n1;l2,m2,n2;l3,m3,n3]
# # We also use the FinEALE numbering of the strains.
# Numbering =[1,4,5;
# 4,2,6;
# 5,6,3];
# T(1:6,1:6) = 0;
# for i=1:1:3
# for j=1:1:3
# #if i==j; alpha = j; else alpha = 9-i-j; end
# alpha = Numbering(i,j);
# for p=1:1:3
# for q=1:1:3
# # if p==q beta = p; else beta = 9-p-q; end
# beta = Numbering(p,q);
# T(alpha,beta) = 0;
# if alpha<=3 & beta<= 3; T(alpha,beta)=a(i,p)*a(i,p); end
# if alpha> 3 & beta<= 3; T(alpha,beta)=a(i,p)*a(j,p); end
# if alpha<=3 & beta>3; T(alpha,beta)=a(i,q)*a(i,p)+a(i,p)*a(i,q);end
# if alpha>3 & beta>3; T(alpha,beta)=a(i,p)*a(j,q)+a(i,q)*a(j,p);end
# end
# end
# end
# end
# T
# R = eye(6,6); R(4,4)=2; R(5,5)=2; R(6,6)=2; # Reuter matrix
# Tbar = R*T*R^(-1)
a11 = Rm[1, 1]
a12 = Rm[1, 2]
a13 = Rm[1, 3]
a21 = Rm[2, 1]
a22 = Rm[2, 2]
a23 = Rm[2, 3]
a31 = Rm[3, 1]
a32 = Rm[3, 2]
a33 = Rm[3, 3]
outstress[1] =
(a11^2) * instress[1] +
(a21^2) * instress[2] +
(a31^2) * instress[3] +
(2 * a11 * a21) * instress[4] +
(2 * a11 * a31) * instress[5] +
(2 * a21 * a31) * instress[6]
outstress[2] =
(a12^2) * instress[1] +
(a22^2) * instress[2] +
(a32^2) * instress[3] +
(2 * a12 * a22) * instress[4] +
(2 * a12 * a32) * instress[5] +
(2 * a22 * a32) * instress[6]
outstress[3] =
(a13^2) * instress[1] +
(a23^2) * instress[2] +
(a33^2) * instress[3] +
(2 * a13 * a23) * instress[4] +
(2 * a13 * a33) * instress[5] +
(2 * a23 * a33) * instress[6]
outstress[4] =
a11 * a12 * instress[1] +
a21 * a22 * instress[2] +
a31 * a32 * instress[3] +
(a11 * a22 + a12 * a21) * instress[4] +
(a11 * a32 + a12 * a31) * instress[5] +
(a21 * a32 + a22 * a31) * instress[6]
outstress[5] =
(a11 * a13) * instress[1] +
(a21 * a23) * instress[2] +
(a31 * a33) * instress[3] +
(a11 * a23 + a13 * a21) * instress[4] +
(a11 * a33 + a13 * a31) * instress[5] +
(a21 * a33 + a23 * a31) * instress[6]
outstress[6] =
(a12 * a13) * instress[1] +
(a22 * a23) * instress[2] +
(a32 * a33) * instress[3] +
(a12 * a23 + a13 * a22) * instress[4] +
(a12 * a33 + a13 * a32) * instress[5] +
(a22 * a33 + a23 * a32) * instress[6]
return outstress
end
################################################################################
# 2-D plane strain model
"""
rotstressvec!(::Type{DeforModelRed2DStrain}, outstress::Vector{T}, instress::Vector{T}, Rm::_RotationMatrix) where {T}
Rotate the stress vector by the supplied rotation matrix.
Calculate the rotation of the stress vector to the 'bar' coordinate system given
by the columns of the rotation matrix `Rm`.
- `outstress` = output stress vector, overwritten inside
- `instress` = input stress vector
- `Rm` = columns are components of 'bar' basis vectors on the 'plain'
basis vectors
"""
function rotstressvec!(
::Type{DeforModelRed2DStrain},
outstress::Vector{T},
instress::Vector{T},
Rm::_RotationMatrix,
) where {T}
a11 = Rm[1, 1]
a12 = Rm[1, 2]
a13 = 0.0
a21 = Rm[2, 1]
a22 = Rm[2, 2]
a23 = 0.0
a31 = 0.0
a32 = 0.0
a33 = 1.0
# Note the special arrangement of the components for plane strain
outstress[1] =
(a11^2) * instress[1] +
(a21^2) * instress[2] +
(a31^2) * instress[4] +
(2 * a11 * a21) * instress[3]
outstress[2] =
(a12^2) * instress[1] +
(a22^2) * instress[2] +
(a32^2) * instress[4] +
(2 * a12 * a22) * instress[3]
outstress[4] =
(a13^2) * instress[1] +
(a23^2) * instress[2] +
(a33^2) * instress[4] +
(2 * a13 * a23) * instress[3]
outstress[3] =
a11 * a12 * instress[1] +
a21 * a22 * instress[2] +
a31 * a32 * instress[4] +
(a11 * a22 + a12 * a21) * instress[3]
return outstress
end
################################################################################
# 2-D plane stress model
"""
rotstressvec!(::Type{DeforModelRed2DStress}, outstress::Vector{T}, instress::Vector{T}, Rm::_RotationMatrix) where {T}
Rotate the stress vector by the supplied rotation matrix.
Calculate the rotation of the stress vector to the 'bar' coordinate system given
by the columns of the rotation matrix `Rm`.
- `outstress` = output stress vector, overwritten inside
- `instress` = input stress vector
- `Rm` = columns are components of 'bar' basis vectors on the 'plain'
basis vectors
"""
function rotstressvec!(
::Type{DeforModelRed2DStress},
outstress::Vector{T},
instress::Vector{T},
Rm::_RotationMatrix,
) where {T}
a11 = Rm[1, 1]
a12 = Rm[1, 2]
a21 = Rm[2, 1]
a22 = Rm[2, 2]
outstress[1] =
(a11^2) * instress[1] + (a21^2) * instress[2] + (2 * a11 * a21) * instress[3]
outstress[2] =
(a12^2) * instress[1] + (a22^2) * instress[2] + (2 * a12 * a22) * instress[3]
outstress[3] =
(a11 * a12) * instress[1] +
(a21 * a22) * instress[2] +
(a11 * a22 + a12 * a21) * instress[3]
return outstress
end
################################################################################
# 2-D axially symmetric stress model
"""
rotstressvec!(::Type{DeforModelRed2DAxisymm}, outstress::Vector{T}, instress::Vector{T}, Rm::_RotationMatrix) where {T}
Rotate the stress vector by the supplied rotation matrix.
Calculate the rotation of the stress vector to the 'bar' coordinate system given
by the columns of the rotation matrix `Rm`.
- `outstress` = output stress vector, overwritten inside
- `instress` = input stress vector
- `Rm` = columns are components of 'bar' basis vectors on the 'plain'
basis vectors
"""
function rotstressvec!(
::Type{DeforModelRed2DAxisymm},
outstress::Vector{T},
instress::Vector{T},
Rm::_RotationMatrix,
) where {T}
a11 = Rm[1, 1]
a12 = Rm[1, 2]
a21 = Rm[2, 1]
a22 = Rm[2, 2]
outstress[1] =
(a11^2) * instress[1] +
(a21^2) * instress[2] +
(0.0) * instress[3] +
(2 * a11 * a21) * instress[4]
outstress[2] =
(a12^2) * instress[1] +
(a22^2) * instress[2] +
(0.0) * instress[3] +
(2 * a12 * a22) * instress[4]
outstress[3] =
(0.0) * instress[1] +
(0.0) * instress[2] +
(1.0) * instress[3] +
(0.0) * instress[4]
outstress[4] =
(a11 * a12) * instress[1] +
(a21 * a22) * instress[2] +
(0.0) * instress[3] +
(a11 * a22 + a12 * a21) * instress[4]
return outstress
end
################################################################################
# 1-D stress model
"""
rotstressvec!(::Type{DeforModelRed1D}, outstress::Vector{T}, instress::Vector{T}, Rm::_RotationMatrix) where {T}
Rotate the stress vector by the supplied rotation matrix.
Calculate the rotation of the stress vector to the 'bar' coordinate system given
by the columns of the rotation matrix `Rm`.
- `outstress` = output stress vector, overwritten inside
- `instress` = input stress vector
- `Rm` = columns are components of 'bar' basis vectors on the 'plain'
basis vectors
"""
function rotstressvec!(
::Type{DeforModelRed1D},
outstress::Vector{T},
instress::Vector{T},
Rm::_RotationMatrix,
) where {T}
copyto!(outstress, instress)
return outstress
end
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 16302 |
# """
# strain2x2tto3v!(v::FVec{T}, t::FMat{T}) where {T}
# Convert a matrix of 2x2 strain components into a 3-component vector.
# """
# function strain2x2tto3v!(v::FVec{T}, t::FMat{T}) where {T}
# v[1] = t[1,1];
# v[2] = t[2,2];
# v[3] = t[1,2] + t[2,1];
# return v
# end
# """
# strain3vto2x2t!(t::FMat{T}, v::FVec{T}) where {T}
# Convert a strain 3-vector to a matrix of 2x2 strain components (symmetric tensor).
# """
# function strain3vto2x2t!(t::FMat{T}, v::FVec{T}) where {T}
# t[1,1] = v[1];
# t[2,2] = v[2];
# t[1,2] = v[3]/2.;
# t[2,1] = v[3]/2.;
# return t
# end
# """
# strain3x3tto6v!(v::FVec{T}, t::FMat{T}) where {T}
# Convert a matrix of 3x3 strain components to a 6-component vector.
# """
# function strain3x3tto6v!(v::FVec{T}, t::FMat{T}) where {T}
# v[1] = t[1,1];
# v[2] = t[2,2];
# v[3] = t[3,3];
# v[4] = t[1,2] + t[2,1];
# v[5] = t[1,3] + t[3,1];
# v[6] = t[3,2] + t[2,3];
# return v
# end
# """
# strain6vto3x3t!(t::FMat{T}, v::FVec{T}) where {T}
# Convert a strain 6-vector to a matrix of 3x3 strain components (symmetric tensor)..
# """
# function strain6vto3x3t!(t::FMat{T}, v::FVec{T}) where {T}
# t[1,1] = v[1];
# t[2,2] = v[2];
# t[3,3] = v[3];
# t[1,2] = v[4]/2.;
# t[2,1] = v[4]/2.;
# t[1,3] = v[5]/2.;
# t[3,1] = v[5]/2.;
# t[3,2] = v[6]/2.;
# t[2,3] = v[6]/2.;
# return t
# end
# """
# strain3x3tto9v!(v::FVec{T}, t::FMat{T}) where {T}
# Convert a matrix of 3x3 strain components to a 9-component vector.
# The strain components are in the order
# ex, ey, ez, gxy, gyx, gyz, gzy, gxz, gzx
# """
# function strain3x3tto9v!(v::FVec{T}, t::FMat{T}) where {T}
# v[1] = t[1,1];
# v[2] = t[2,2];
# v[3] = t[3,3];
# v[4] = t[1,2];
# v[5] = t[2,1];
# v[6] = t[2,3];
# v[7] = t[3,2];
# v[8] = t[1,3];
# v[9] = t[3,1];
# return v
# end
# """
# strain9vto3x3t!(v::FVec{T}, t::FMat{T}) where {T}
# Convert a matrix of 3x3 strain components to a 9-component vector.
# The strain components are in the order
# ex, ey, ez, gxy, gyx, gyz, gzy, gxz, gzx
# """
# function strain9vto3x3t!(t::FMat{T}, v::FVec{T}) where {T}
# t[1,1] = v[1];
# t[2,2] = v[2];
# t[3,3] = v[3];
# t[1,2] = v[4];
# t[2,1] = v[5];
# t[2,3] = v[6];
# t[3,2] = v[7];
# t[1,3] = v[8];
# t[3,1] = v[9];
# return t
# end
# """
# stress2x2to3v!(v::FVec{T}, t::FMat{T})
# Convert a symmetric matrix of 2x2 stress components to a 3-component vector.
# """
# function stress2x2to3v!(v::FVec{T}, t::FMat{T}) where {T}
# v[1] = t[1,1];
# v[2] = t[2,2];
# v[3] = 0.5*(t[1,2] + t[2,1]);
# return v
# end
# """
# stress3vto2x2t!(t::FMat{T}, v::FVec{T})
# Convert a 3-vector to a matrix of 2x2 stress components (symmetric tensor).
# """
# function stress3vto2x2t!(t::FMat{T}, v::FVec{T}) where {T}
# t[1,1] = v[1];
# t[2,2] = v[2];
# t[1,2] = v[3];
# t[2,1] = v[3];
# return t
# end
# """
# stress3vto3x3t!(t::FMat{T}, v::FVec{T}) where {T}
# Convert a 3-vector to a matrix of 3x3 stress components (symmetric tensor).
# """
# function stress3vto3x3t!(t::FMat{T}, v::FVec{T}) where {T}
# t[1,1] = v[1];
# t[2,2] = v[2];
# t[1,2] = v[3];
# t[2,1] = v[3];
# return t
# end
# """
# stress4vto3x3t!(t::FMat{T}, v::FVec{T}) where {T}
# Convert a 4-vector to a matrix of 3x3 stress components (tensor).
# Convert a 4-vector to a *symmetric*
# matrix of 3x3 stress components (tensor). This is
# conversion routine that would be useful for plane strain or
# axially symmetric conditions.
# The stress vector components need to be ordered as:
# sigmax, sigmay, tauxy, sigmaz,
# which is the ordering used for the plane-strain model reduction.
# Therefore, for axially symmetric analysis the components need to be
# reordered, as from the constitutive equation they come out
# as sigmax, sigmay, sigmaz, tauxy.
# """
# function stress4vto3x3t!(t::FMat{T}, v::FVec{T}) where {T}
# t[1,1] = v[1];
# t[2,2] = v[2];
# t[1,2] = v[3];
# t[2,1] = v[3];
# t[3,3] = v[4];
# return t
# end
# """
# stress6vto3x3t!(t::FMat{T}, v::FVec{T}) where {T}
# Convert a 6-vector to a matrix of 3x3 stress components (symmetric tensor).
# """
# function stress6vto3x3t!(t::FMat{T}, v::FVec{T}) where {T}
# t[1,1] = v[1];
# t[2,2] = v[2];
# t[3,3] = v[3];
# t[1,2] = v[4];
# t[2,1] = v[4];
# t[1,3] = v[5];
# t[3,1] = v[5];
# t[3,2] = v[6];
# t[2,3] = v[6];
# return t
# end
# """
# stress3x3tto6v!(v::FVec{T}, t::FMat{T}) where {T}
# Convert a matrix of 3x3 stress components to a 6-component vector.
# """
# function stress3x3tto6v!(v::FVec{T}, t::FMat{T}) where {T}
# v[1] = t[1,1];
# v[2] = t[2,2];
# v[3] = t[3,3];
# v[4] = 1/2.0*(t[1,2] + t[2,1]);
# v[5] = 1/2.0*(t[1,3] + t[3,1]);
# v[6] = 1/2.0*(t[3,2] + t[2,3]);
# return v
# end
# """
# strain9vto6v!(t::FVec{T}, v::FVec{T}) where {T}
# Convert a strain 9-vector to a strain 6-vector components (tensor).
# """
# function strain9vto6v!(t::FVec{T}, v::FVec{T}) where {T}
# t[1] = v[1];
# t[2] = v[2];
# t[3] = v[3];
# t[4] = v[4]+v[5];
# t[5] = v[8]+v[9];
# t[6] = v[6]+v[7];
# return t
# end
# """
# strain6vto9v!(t::FVec{T}, v::FVec{T}) where {T}
# Convert a strain 6-vector to a strain 9-vector components (tensor).
# The strain components are in the order
# ex, ey, ez, gxy/2, gxy/2, gyz/2, gyz/2, gxz/2, gxz/2
# """
# function strain6vto9v!(t::FVec{T}, v::FVec{T}) where {T}
# t[1] = v[1];
# t[2] = v[2];
# t[3] = v[3];
# t[4] = v[4]/2.;
# t[5] = v[4]/2.;
# t[6] = v[6]/2.;
# t[7] = v[6]/2.;
# t[8] = v[5]/2.;
# t[9] = v[5]/2.;
# return t
# end
# """
# stress9vto6v!(t::FVec{T}, v::FVec{T}) where {T}
# Convert a stress 9-vector (tensor) to a stress 6-vector components.
# The stress components are in the order
# sigx, sigy, sigz, tauxy, tauxy, tauyz, tauyz, tauxz, tauxz
# """
# function stress9vto6v!(t::FVec{T}, v::FVec{T}) where {T}
# t[1] = v[1];
# t[2] = v[2];
# t[3] = v[3];
# t[4] = v[4];
# t[5] = v[8];
# t[6] = v[6];
# return t
# end
# """
# stress6vto9v!(t::FVec{T}, v::FVec{T}) where {T}
# Convert a stress 6-vector to a stress 9-vector components (tensor).
# The stress components are in the order
# sigx, sigy, sigz, tauxy, tauxy, tauyz, tauyz, tauxz, tauxz
# """
# function stress6vto9v!(t::FVec{T}, v::FVec{T}) where {T}
# t[1] = v[1];
# t[2] = v[2];
# t[3] = v[3];
# t[4] = v[4];
# t[5] = v[4];
# t[6] = v[6];
# t[7] = v[6];
# t[8] = v[5];
# t[9] = v[5];
# return t
# end
# function stressvectorrotation{MR<:DeforModelRed2DStress}(::Type{MR},
# Rm::FMat{T})
#
# # Rm = columns are components of 'bar' basis vectors on the 'plain'
# # basis vectors
# #
# # Calculate the rotation of the 'plain' stress vector to the
# # 'bar' coordinate system given by the columns of the rotation matrix Rm.
# #
# # Example:
# # The stress vector "stress" is given in the material coordinate
# # system defined by the orientation matrix Rm. The following two
# # transformations are equivalent:
# #
# # t = stress_6v_to_3x3t (mat,stress);
# # t = (Rm*t*Rm');# in global coordinate system
# # t = (outputRm'*t*outputRm);# in output coordinate system
# # stress =stress_3x3t_to_6v (mat,t);# in output coordinate system
# #
# # stress =mat.stress_vector_rotation(outputRm)...
# # *mat.stress_vector_rotation(Rm')...
# # *stress;# in output coordinate system
#
# a11=Rm[1,1]; a12=Rm[1,2];
# a21=Rm[2,1]; a22=Rm[2,2];
# # switch self.reduction
# # case {'axisymm','strain'}
# # T =[[ a11^2, a21^2, 0, 2*a11*a21]
# # [ a12^2, a22^2, 0, 2*a12*a22]
# # [ 0, 0, 1, 0]
# # [ a11*a12, a21*a22, 0, a11*a22 + a12*a21]];
# # case 'stress'
# T =[[ a11^2 a21^2 2*a11*a21]
# [ a12^2 a22^2 2*a12*a22]
# [ a11*a12 a21*a22 a11*a22+a12*a21]];
# return T
# end
#
# function strainvectorrotation{MR<:DeforModelRed2DStress}(::Type{MR},
# Rm::FMat{T})
# # Calculate the rotation matrix for a strain vector.
# #
# # Tbar = strain_vector_rotation(self,Rm)
# #
# # Rm = columns are components of 'bar' basis vectors on the 'plain'
# # basis vectors
# #
# # Calculate the rotation of the 'plain' strain vector to the
# # 'bar' coordinate system given by the columns of the rotation matrix Rm.
# #
#
# a11=Rm[1,1]; a12=Rm[1,2];
# a21=Rm[2,1]; a22=Rm[2,2];
# # switch self.reduction
# # case {'axisymm','strain'}
# # Tbar =[ [ a11^2, a21^2, 0, a11*a21]
# # [ a12^2, a22^2, 0, a12*a22]
# # [ 0, 0, 1, 0]
# # [ 2*a11*a12, 2*a21*a22, 0, a11*a22 + a12*a21]];
# # case 'stress'
# Tbar =[ [ a11^2, a21^2, a11*a21]
# [ a12^2, a22^2, a12*a22]
# [ 2*a11*a12, 2*a21*a22, a11*a22 + a12*a21]];
# return Tbar
# end
#
#
# ################################################################################
# # 2-D plane axially symmetric model
#
# function stressvectorrotation(::Type{MR},
# Rm::FMat{T}) where {MR<:DeforModelRed2DAxisymm}
#
# # Rm = columns are components of 'bar' basis vectors on the 'plain'
# # basis vectors
# #
# # Calculate the rotation of the 'plain' stress vector to the
# # 'bar' coordinate system given by the columns of the rotation matrix Rm.
# #
# # Example:
# # The stress vector "stress" is given in the material coordinate
# # system defined by the orientation matrix Rm. The following two
# # transformations are equivalent:
# #
# # t = stress_6v_to_3x3t (mat,stress);
# # t = (Rm*t*Rm');# in global coordinate system
# # t = (outputRm'*t*outputRm);# in output coordinate system
# # stress =stress_3x3t_to_6v (mat,t);# in output coordinate system
# #
# # stress =mat.stress_vector_rotation(outputRm)...
# # *mat.stress_vector_rotation(Rm')...
# # *stress;# in output coordinate system
#
# a11=Rm[1,1]; a12=Rm[1,2];
# a21=Rm[2,1]; a22=Rm[2,2];
# T =[[ a11^2 a21^2 0 2*a11*a21]
# [ a12^2 a22^2 0 2*a12*a22]
# [ 0 0 1 0]
# [ a11*a12 a21*a22 0 a11*a22 + a12*a21]];
# return T
# end
#
# function strainvectorrotation(::Type{MR},
# Rm::FMat{T}) where {MR<:DeforModelRed2DAxisymm}
# # Calculate the rotation matrix for a strain vector.
# #
# # Tbar = strain_vector_rotation(self,Rm)
# #
# # Rm = columns are components of 'bar' basis vectors on the 'plain'
# # basis vectors
# #
# # Calculate the rotation of the 'plain' strain vector to the
# # 'bar' coordinate system given by the columns of the rotation matrix Rm.
# #
#
# a11=Rm[1,1]; a12=Rm[1,2];
# a21=Rm[2,1]; a22=Rm[2,2];
# Tbar =[ [ a11^2 a21^2 0 a11*a21]
# [ a12^2 a22^2 0 a12*a22]
# [ 0 0 1 0]
# [ 2*a11*a12 2*a21*a22 0 a11*a22 + a12*a21]];
# return Tbar
# end
#
# ################################################################################
# # Generic versions of rotations of stiffness and compliance matrices
#
# function rotatestiffness!(::Type{MR}, D::FMat{T},
# Rm::FMat{T}) where {MR<:DeforModelRed}
# # Rotate constitutive stiffness matrix of the material.
# #
# # function D=transform_stiffness(self,D,Rm)
# #
# # Rotate constitutive stiffness matrix of the material to the
# # coordinate system given by the columns of the rotation matrix Rm.
# T =stressvectorrotation(MR,Rm);
# D = T*D*T';
# return D
# end
#
# function rotatecompliance!(::Type{MR}, C::FMat{T},
# Rm::FMat{T}) where {MR<:DeforModelRed}
# # Rotate constitutive compliance matrix of the material.
# #
# # C = rotate_compliance(self,C,Rm)
# #
# # Rotate constitutive compliance matrix of the material to the
# # coordinate system given by the columns of the rotation matrix Rm.
# Tbar =strainvectorrotation(MR,Rm);
# C = Tbar*C*Tbar';
# return C
# end
# function stressvectorrotation(::Type{DeforModelRed2DStrain}, Rm::FMat{T})
#
# # Rm = columns are components of 'bar' basis vectors on the 'plain'
# # basis vectors
# #
# # Calculate the rotation of the 'plain' stress vector to the
# # 'bar' coordinate system given by the columns of the rotation matrix Rm.
# #
# # Example:
# # The stress vector "stress" is given in the material coordinate
# # system defined by the orientation matrix Rm. The following two
# # transformations are equivalent:
# #
# # t = stress_6v_to_3x3t (mat,stress);
# # t = (Rm*t*Rm');# in global coordinate system
# # t = (outputRm'*t*outputRm);# in output coordinate system
# # stress =stress_3x3t_to_6v (mat,t);# in output coordinate system
# #
# # stress =mat.stress_vector_rotation(outputRm)...
# # *mat.stress_vector_rotation(Rm')...
# # *stress;# in output coordinate system
#
# a11=Rm[1,1]; a12=Rm[1,2];
# a21=Rm[2,1]; a22=Rm[2,2];
# # sigmax, sigmay, sigmaz, tauxy
# T =[[ a11^2 a21^2 0 2*a11*a21]
# [ a12^2 a22^2 0 2*a12*a22]
# [ 0 0 1 0]
# [ a11*a12 a21*a22 0 a11*a22 + a12*a21]];
# return T
# end
#
# function strainvectorrotation(::Type{DeforModelRed2DStrain}, Rm::FMat{T})
# # Calculate the rotation matrix for a strain vector.
# #
# # Tbar = strain_vector_rotation(self,Rm)
# #
# # Rm = columns are components of 'bar' basis vectors on the 'plain'
# # basis vectors
# #
# # Calculate the rotation of the 'plain' strain vector to the
# # 'bar' coordinate system given by the columns of the rotation matrix Rm.
# #
#
# a11=Rm[1,1]; a12=Rm[1,2];
# a21=Rm[2,1]; a22=Rm[2,2];
# Tbar =[ [ a11^2 a21^2 0 a11*a21]
# [ a12^2 a22^2 0 a12*a22]
# [ 0 0 1 0]
# [ 2*a11*a12 2*a21*a22 0 a11*a22 + a12*a21]];
# return Tbar
# end
# function strainvectorrotation(::Type{DeforModelRed3D}, Rm::FMat{T})
# # Calculate the rotation matrix for a strain vector.
# #
# # Tbar = strain_vector_rotation(self,Rm)
# #
# # Rm = columns are components of 'bar' basis vectors on the 'plain'
# # basis vectors
# #
# # Calculate the rotation of the 'plain' strain vector to the
# # 'bar' coordinate system given by the columns of the rotation matrix Rm.
# #
#
# a11=Rm[1,1]; a12=Rm[1,2]; a13=Rm[1,3];
# a21=Rm[2,1]; a22=Rm[2,2]; a23=Rm[2,3];
# a31=Rm[3,1]; a32=Rm[3,2]; a33=Rm[3,3];
# Tbar =[
# [ a11^2 a21^2 a31^2 a11*a21 a11*a31 a21*a31]
# [ a12^2 a22^2 a32^2 a12*a22 a12*a32 a22*a32]
# [ a13^2 a23^2 a33^2 a13*a23 a13*a33 a23*a33]
# [ 2*a11*a12 2*a21*a22 2*a31*a32 a11*a22 + a12*a21 a11*a32 + a12*a31 a21*a32 + a22*a31]
# [ 2*a11*a13 2*a21*a23 2*a31*a33 a11*a23 + a13*a21 a11*a33 + a13*a31 a21*a33 + a23*a31]
# [ 2*a12*a13 2*a22*a23 2*a32*a33 a12*a23 + a13*a22 a12*a33 + a13*a32 a22*a33 + a23*a32]];
# return Tbar
# end
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 8641 | """
tens4checksymmetry(C4th)
If the fourth-order tensor of material elasticity has the full set of
symmetries, return true; otherwise false.
"""
function tens4checksymmetry(C4th)
for I = 1:3
for J = 1:3
for K = 1:3
for L = 1:3
C4th[I, J, K, L] != C4th[K, L, I, J] && return false
C4th[I, J, K, L] != C4th[J, I, K, L] && return false
C4th[I, J, K, L] != C4th[I, J, L, K] && return false
end
end
end
end
return true
end
"""
tens4symmtto6x6t!(M::Matrix{T}, ST::Array{T, 4}) where {T}
Convert a symmetric 4th-order tensor to a 6 x 6 matrix.
!!! Note
The order corresponds to the arrangement of the components of stress (or
strain) tensor, symmetric, three-dimensional, into a 6-component
vector.
# Example
```
J=tens4_ijkl(eye(3),eye(3))
produces the tracor:
T=rand(3);
sum(diag(T))*eye(3)
t= tens4_dot_2(J,T)
M= tens4_symm_to_6(ST)
```
"""
function tens4symmtto6x6t!(M::Matrix{T}, ST::Array{T,4}) where {T}
# This corresponds to the arrangement of the components of stress (or
# strain) tensor, symmetric, three-dimensional, into a 6-component
# vector.
ix = [1 1; 2 2; 3 3; 1 2; 1 3; 2 3]
for j = 1:6
for i = 1:6
M[i, j] = ST[ix[i, 1], ix[i, 2], ix[j, 1], ix[j, 2]]
end
end
return M
end
"""
tens4symmt6x6tot!(ST::Array{T, 4}, M::Matrix{T}) where {T}
Convert a symmetric 6 x 6 matrix to a symmetric 4th-order tensor.
!!! Note
The order corresponds to the arrangement of the components of stress (or
strain) tensor, symmetric, three-dimensional, into a 6-component
vector.
"""
function tens4symmt6x6tot!(ST::Array{T,4}, M::Matrix{T}) where {T}
ix = [1 4 5; 4 2 6; 5 6 3]
n = 3
for i = 1:n
for j = 1:n
for k = 1:n
for l = 1:n
ST[i, j, k, l] = M[ix[i, j], ix[k, l]]
end
end
end
end
return ST
end
"""
tens4dot2!(R::Array{T, 2}, F::Array{T, 4}, S::Array{T, 2}) where {T}
Compute the double contraction of a 4th-order and a 2nd-order tensors.
!!! note
The double contraction of two second-order sensors is defined as
`A:B = tr(A'*B) = A_ij B_ij`
The resulting second-order tensor is first zeroed out, and then the result is
accumulated.
"""
function tens4dot2!(R::Array{T,2}, F::Array{T,4}, S::Array{T,2}) where {T}
R .= zero(T)
for l = 1:3
for k = 1:3
for j = 1:3
for i = 1:3
R[i, j] += F[i, j, k, l] * S[k, l]
end
end
end
end
return R
end
"""
tens4ijkl!(t::Array{T, 4}, A::FA, B::FB, op = :+) where {T, FA, FB}
Fill a 4th-order tensor as a dyadic product of two 2nd-order tensors.
The `i,j,k,l` component is given as `t[i,j,k,l]=A(i,j)*B(k,l)`.
!!! note
The tensor is accumulated to. It needs to be initialized to zero, if that is
desired as the initial state.
# Example
```
t = fill(0.0, 3, 3, 3, 3)
delta = (I, J) -> I == J ? 1.0 : 0.0
tens4ijkl!(t, delta, delta)
S = rand(3, 3)
@show tr(S) * I
tS = fill(0.0, 3, 3)
@show tens4dot2!(tS, t, S)
```
"""
function tens4ijkl!(t::Array{T,4}, A::FA, B::FB) where {T,FA,FB}
for l = 1:3
for k = 1:3
for j = 1:3
for i = 1:3
t[i, j, k, l] += A(i, j) * B(k, l)
end
end
end
end
return t
end
"""
tens4ikjl!(t::Array{T, 4}, A::FA, B::FB) where {T, FA, FB}
Fill a 4th-order tensor as a dyadic product of two 2nd-order tensors.
The `i,j,k,l` component is given as `t[i,j,k,l]=A(i,k)*B(j,l)`.
!!! note
The tensor is accumulated to. It needs to be initialized to zero, if that is
desired as the initial state.
# Example
```
t = fill(0.0, 3, 3, 3, 3)
delta = (I, J) -> I == J ? 1.0 : 0.0
tens4ikjl!(t, delta, delta)
S = rand(3, 3)
@show transpose(S)
tS = fill(0.0, 3, 3)
@show transpose(S) - tens4dot2!(tS, t, S)
```
"""
function tens4ikjl!(t::Array{T,4}, A::FA, B::FB) where {T,FA,FB}
for l = 1:3
for k = 1:3
for j = 1:3
for i = 1:3
t[i, j, k, l] += A(i, k) * B(j, l)
end
end
end
end
return t
end
"""
tens4iljk!(t::Array{T, 4}, A::FA, B::FB) where {T, FA, FB}
Fill a 4th-order tensor as a dyadic product of two 2nd-order tensors.
The `i,j,k,l` component is given as `t[i,j,k,l]=A(i,l)*B(j,k)`.
!!! note
The tensor is accumulated to. It needs to be initialized to zero, if that is
desired as the initial state.
# Example
```
t = fill(0.0, 3, 3, 3, 3)
delta = (I, J) -> I == J ? 1.0 : 0.0
tens4iljk!(t, delta, delta)
S = rand(3, 3)
tS = fill(0.0, 3, 3)
@show S - tens4dot2!(tS, t, S)
```
"""
function tens4iljk!(t::Array{T,4}, A::FA, B::FB) where {T,FA,FB}
for l = 1:3
for k = 1:3
for j = 1:3
for i = 1:3
t[i, j, k, l] += A(i, l) * B(j, k)
end
end
end
end
return t
end
"""
tens4identity!(t::Array{T, 4}) where {T}
Compute 4th-order identity tensor.
# Example
The product of the identity tensor with the second-order tensor `S` is
```
t = fill(0.0, 3, 3, 3, 3)
tens4identity!(t)
S = rand(3, 3)
tS = fill(0.0, 3, 3)
tens4dot2!(tS, t, S)
@show S - tS
```
"""
function tens4identity!(t::Array{T,4}) where {T}
delta = (I, J) -> I == J ? 1.0 : 0.0
t .= zero(T)
return tens4ikjl!(t, delta, delta)
end
"""
tens4transposor!(t::Array{T, 4}) where {T}
Compute 4th-order transposor tensor.
# Example
The product of the transposor tensor with the second-order tensor `S` is
```
t = fill(0.0, 3, 3, 3, 3)
tens4transposor!(t)
S = rand(3, 3)
tS = fill(0.0, 3, 3)
tens4dot2!(tS, t, S)
@show S' - tS
```
"""
function tens4transposor!(t::Array{T,4}) where {T}
delta = (I, J) -> I == J ? 1.0 : 0.0
t .= zero(T)
return tens4iljk!(t, delta, delta)
end
"""
tens4tracor!(t::Array{T, 4}) where {T}
Compute 4th-order tracor tensor.
Double contraction of a second order tensor with this fourth-order tensor
produces the spherical part of the second order tensor.
# Example
The product of the tracor tensor with the second-order tensor `S` is
```
t = fill(0.0, 3, 3, 3, 3)
tens4tracor!(t)
S = rand(3, 3)
tS = fill(0.0, 3, 3)
tens4dot2!(tS, t, S)
@show tr(S) * I - tS
```
"""
function tens4tracor!(t::Array{T,4}) where {T}
delta = (I, J) -> I == J ? 1.0 : 0.0
t .= zero(T)
return tens4ijkl!(t, delta, delta)
end
"""
tens4symmetrizor!(t::Array{T, 4}) where {T}
Compute 4th-order symmetrizor tensor.
Double contraction of a second order tensor with this fourth-order tensor
produces the symmetric part of the second order tensor.
# Example
The product of the symmetrizor tensor with the second-order tensor `S` is
```
t = fill(0.0, 3, 3, 3, 3)
tens4symmetrizor!(t)
S = rand(3, 3)
tS = fill(0.0, 3, 3)
tens4dot2!(tS, t, S)
@show (S + S')/2 * I - tS
```
"""
function tens4symmetrizor!(t::Array{T,4}) where {T}
delta = (I, J) -> I == J ? 1.0 : 0.0
t .= zero(T)
tens4ikjl!(t, delta, delta) # identity
tens4iljk!(t, delta, delta) # transposor
t .*= 0.5
return t
end
"""
tens4skewor!(t::Array{T, 4}) where {T}
Compute 4th-order skewor tensor.
Double contraction of a second order tensor with this fourth-order tensor
produces the skew part of the second order tensor.
# Example
The product of the skewor tensor with the second-order tensor `S` is
```
t = fill(0.0, 3, 3, 3, 3)
tens4skewor!(t)
S = rand(3, 3)
tS = fill(0.0, 3, 3)
tens4dot2!(tS, t, S)
@show (S - S')/2 * I - tS
```
"""
function tens4skewor!(t::Array{T,4}) where {T}
delta = (I, J) -> I == J ? 1.0 : 0.0
t .= zero(T)
tens4iljk!(t, delta, delta) # transposor
t .= -t # subtract that part
tens4ikjl!(t, delta, delta) # identity
t .*= 0.5
return t
end
"""
tens4deviator!(t::Array{T, 4}) where {T}
Compute 4th-order deviator tensor.
Double contraction of a second order tensor with this fourth-order tensor
produces the deviator part of the second order tensor.
# Example
The product of the deviator tensor with the second-order tensor `S` is
```
t = fill(0.0, 3, 3, 3, 3)
tens4deviator!(t)
S = rand(3, 3)
tS = fill(0.0, 3, 3)
tens4dot2!(tS, t, S)
@show tr((S - tr(S)/3*I) ), tr(tS)
```
"""
function tens4deviator!(t::Array{T,4}) where {T}
delta = (I, J) -> I == J ? 1.0 : 0.0
t .= zero(T)
tens4tracor!(t) # tracor
t .= -(1.0 / 3) .* t # subtract (1/3) that part
tens4ikjl!(t, delta, delta) # identity
t .*= 0.5
return t
end
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 2266 |
module malum_cyl_mode_esnice_t4
using FinEtools
using FinEtoolsDeforLinear
using Test
using Arpack
using LinearAlgebra
using DataDrop
using InteractiveUtils
function test()
# Aluminum cylinder free vibration, mesh imported from Abaqus
# Mesh converted from quadratic tetrahedra to linear tetrahedra
# NICE tetrahedral elements used
E = 70000 * phun("MPa")
nu = 0.33
rho = 2700 * phun("KG/M^3")
radius = 0.5 * phun("ft")
neigvs = 20 # how many eigenvalues
OmegaShift = (10.0 * 2 * pi)^2
Eigenvalues = [
0.0,
0.0,
0.0,
1.8846e-5,
7.35917e-5,
0.000119445,
2498.15,
2498.88,
2513.31,
4082.65,
4585.99,
4586.42,
4987.01,
6648.02,
6648.48,
6679.04,
6682.16,
6777.89,
6780.59,
6799.36,
]
MR = DeforModelRed3D
output = import_ABAQUS("alum_cyl.inp")
fens, fes = output["fens"], output["fesets"][1]
fens.xyz .*= phun("mm") # The input is provided in SI(mm) units
@show boundingbox(fens.xyz)
fens, fes = T10toT4(fens, fes)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinearESNICET4(MR, IntegDomain(fes, NodalSimplexRule(3)), material)
associategeometry!(femm, geom)
@edit stiffness(femm, SysmatAssemblerSparse(), geom, u)
K = stiffness(femm, SysmatAssemblerSparse(), geom, u)
M = mass(femm, geom, u)
Kref = DataDrop.retrieve_matrix("rfK")
@show norm(Kref - K)
Mref = DataDrop.retrieve_matrix("rfM")
@show norm(Mref - M)
DataDrop.empty_hdf5_file("K")
DataDrop.empty_hdf5_file("M")
DataDrop.store_matrix("K", K)
DataDrop.store_matrix("M", M)
d, v, nev, nconv =
eigs(K + OmegaShift * M, M; nev = neigvs, which = :SM, explicittransform = :none)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
println("Eigenvalues: $fs [Hz]")
@show norm(vec(fs) .- vec(Eigenvalues)) < 1.0e-3 * maximum(vec(Eigenvalues))
nothing
end
end
using .malum_cyl_mode_esnice_t4
malum_cyl_mode_esnice_t4.test()
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 1056 | using Test
@time @testset "Linear deformation 1" begin
include("test_linear_defor_1.jl")
end
@time @testset "Linear deformation 2" begin
include("test_linear_defor_2.jl")
end
@time @testset "Linear deformation 3" begin
include("test_linear_defor_3.jl")
end
@time @testset "Linear deformation 4" begin
include("test_linear_defor_4.jl")
end
@time @testset "Linear deformation 5" begin
include("test_linear_defor_5.jl")
end
@time @testset "Linear deformation 6" begin
include("test_linear_defor_6.jl")
end
@time @testset "Linear deformation 7" begin
include("test_linear_defor_7.jl")
end
@time @testset "Linear deformation 8" begin
include("test_linear_defor_8.jl")
end
@time @testset "Linear deformation 9" begin
include("test_linear_defor_9.jl")
end
@time @testset "Linear deformation 10" begin
include("test_linear_defor_10.jl")
end
@time @testset "Linear deformation 11" begin
include("test_linear_defor_11.jl")
end
@time @testset "Linear deformation 12" begin
include("test_linear_defor_12.jl")
end
true
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 47897 | module mmLE11NAFEMSQ8algo2
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!, matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule:
linearstatics, exportdeformation, exportstress, exportstresselementwise
using Test
import LinearAlgebra: norm, cholesky, cross
function test()
# NAFEMS LE11 benchmark with Q8 elements.
# # This is a test recommended by the National Agency for Finite Element
# # Methods and Standards (U.K.): Test LE11 from NAFEMS Publication TNSB,
# # Rev. 3, “The Standard NAFEMS Benchmarks,” October 1990.
# #
# # Target solution: Direct stress, = –105 MPa at point A.
#function LE11NAFEMS()
# Parameters:
Ea = 210000 * phun("MEGA*Pa")
nua = 0.3
alphaa = 2.3e-4 # thermal expansion coefficient
sigmaA = -105 * phun("MEGA*Pa")
nref = 1 # how many times should we refine the mesh?
X =
[
1.0 0.0#A
1.4 0.0#B
0.995184726672197 0.098017140329561
1.393258617341076 0.137223996461385
0.980785 0.195090#
1.37309939 0.27312645
0.956940335732209 0.290284677254462
1.339716470025092 0.406398548156247
0.9238795 0.38268#C
1.2124 0.7#D
0.7071 0.7071#E
1.1062 1.045#F
0.7071 (0.7071+1.79)/2#(E+H)/2
1.0 1.39#G
0.7071 1.79#H
1.0 1.79#I
] * phun("M")
tolerance = 1.e-6 * phun("M")
##
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the axial symmetry
# assumption.
MR = DeforModelRed2DAxisymm
fens = FENodeSet(X)
fes =
FESetQ4([1 2 4 3; 3 4 6 5; 5 6 8 7; 7 8 10 9; 9 10 12 11; 11 12 14 13; 13 14 16 15])
for ref = 1:nref
fens, fes = Q4refine(fens, fes)
list = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = [0.0 0.0],
inflate = tolerance,
)
fens.xyz[list, :] = FinEtools.MeshUtilModule.ontosphere(fens.xyz[list, :], 1.0)
end
fens, fes = Q4toQ8(fens, fes)
list = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = [0.0 0.0],
inflate = tolerance,
)
fens.xyz[list, :] = FinEtools.MeshUtilModule.ontosphere(fens.xyz[list, :], 1.0)
# EBC's
l1 = selectnode(fens, box = [-Inf Inf 0 0], inflate = tolerance)
e1 = FDataDict("node_list" => l1, "component" => 2, "displacement" => x -> 0.0)
l1 = selectnode(fens, box = [-Inf Inf 1.79 1.79], inflate = tolerance)
e2 = FDataDict("node_list" => l1, "component" => 2, "displacement" => x -> 0.0)
# Temperature field
dtemp = FDataDict("temperature" => x -> x[1] + x[2])
# Property and material
material = MatDeforElastIso(MR, 0.0, Ea, nua, alphaa)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 3), true), material)
# Make region 1
region = FDataDict("femm" => femm)
# Make model data
modeldata = FDataDict(
"fens" => fens,
"regions" => [region],
"essential_bcs" => [e1, e2],
"temperature_change" => dtemp,
)
# Call the solver
modeldata = linearstatics(modeldata)
geom = modeldata["geom"]
u = modeldata["u"]
dT = modeldata["temp"]
modeldata["postprocessing"] =
FDataDict("boundary_only" => true, "file" => "LE11NAFEMS_Q8_deformation.vtk")
modeldata = exportdeformation(modeldata)
# @async run(`"paraview.exe" $(modeldata["postprocessing"]["exported"][1]["file"])`)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
nA = selectnode(fens, box = Float64[1.0 1.0 0.0 0.0], inflate = tolerance)
modeldata["postprocessing"] = FDataDict(
"boundary_only" => true,
"file" => "LE11NAFEMS_Q8_sigmay.vtk",
"quantity" => :Cauchy,
"component" => 2,
)
modeldata = exportstress(modeldata)
modeldata["postprocessing"] = FDataDict(
"boundary_only" => false,
"file" => "LE11NAFEMS_Q8_sigmay.vtk",
"quantity" => :Cauchy,
"component" => 2,
)
modeldata = exportstress(modeldata)
# @async run(`"paraview.exe" $(modeldata["postprocessing"]["exported"][1]["file"])`)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
fld = modeldata["postprocessing"]["exported"][1]["field"]
sA = fld.values[nA] / phun("MEGA*Pa")
sAn = fld.values[nA] / sigmaA
# println("Stress at point A: $(sA) i. e. $( sAn*100 )% of reference value")
@test norm(sA - [-93.8569]) < 1.0e-2
# Loop over only those elements that share the node nA
fen2fe = FENodeToFEMap(fes, nnodes(geom))
function inspector(idat, elnum, conn, xe, out, xq)
# println("loc = $( xq ) : $( transpose(out)/phun("MEGA*Pa") )")
return idat
end
inspectintegpoints(
femm,
geom,
u,
dT,
fen2fe.map[nA[1]],
inspector,
[];
quantity = :Cauchy,
)
modeldata["postprocessing"] = FDataDict(
"boundary_only" => false,
"file" => "LE11NAFEMS_Q8_sigmay_ew.vtk",
"quantity" => :Cauchy,
"component" => 2,
)
modeldata = exportstresselementwise(modeldata)
# @async run(`"paraview.exe" $(modeldata["postprocessing"]["exported"][1]["file"])`)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
end
end
using .mmLE11NAFEMSQ8algo2
mmLE11NAFEMSQ8algo2.test()
module sscratch_06112017
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!, matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using Test
import Statistics: mean
function test()
## Solid cylinder/taper/sphere—-temperature loading; quadratic brick mesh
#
## Description
#
# The solid cylinder/taper/sphere axially-symmetric part represented in
# Figure 1 is exposed to linearly varying temperature in the plane of the
# cross-section. The temperature in the coordinates $r$ (the coordinate)
# and $z$ (the axial ccoordinate) is given as $T=r+z$. The goal is to find
# the mechanical stress at the point A induced by the thermal expansion.
#
##
# The part is constrained against axial expansion along the faces of HIH'I'
# and ABA'B'. The Young's modulus is 210 GPa, the Poisson's ratio is .3,
# and the coefficient of thermal expansion is 2.3e-4/degree Celsius.
##
# This is a test recommended by the National Agency for Finite Element
# Methods and Standards (U.K.): Test LE11 from NAFEMS Publication TNSB,
# Rev. 3, “The Standard NAFEMS Benchmarks,” October 1990.
#
# Target solution: Compressive axial stress $\sigma_z$ = –105 MPa along
# the circle passing through point A.
##
# The toolkit has a helpful physical-units facility. The function phun()
# allows use of basic units and basic
# multipliers (for instance, mega).
##
# Set the material properties.
Ea = 210000 * phun("MEGA*PA")# Young's modulus
nua = 0.3# Poisson ratio
alphaa = 2.3e-4# coefficient of thermal expansion
##
# This is the target stress value.
sigmaA = -105 * phun("MEGA*PA")
##
# The mesh will be created in a very coarse representation from the
# key points in the drawing. The first coordinate is radial, the second coordinate is axial.
rz =
[
1.0 0.0#A
1.4 0.0#B
0.995184726672197 0.098017140329561
1.393258617341076 0.137223996461385
0.980785 0.195090#
1.37309939 0.27312645
0.956940335732209 0.290284677254462
1.339716470025092 0.406398548156247
0.9238795 0.38268#C
1.2124 0.7#D
0.7071 0.7071#E
1.1062 1.045#F
0.7071 (0.7071+1.79)/2#(E+H)/2
1.0 1.39#G
0.7071 1.79#H
1.0 1.79#I
] * phun("M")
tolerance = 1.e-6 * phun("M")
##
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the fully three-dimensional solid.
MR = DeforModelRed3D
# This is the quadrilateral mesh of the cross-section. It will be modified and
# refined as we go.
fens = FENodeSet(rz)
fes =
FESetQ4([1 2 4 3; 3 4 6 5; 5 6 8 7; 7 8 10 9; 9 10 12 11; 11 12 14 13; 13 14 16 15])
##
# If needed, the initial mesh can be refined by bisection. Just set
# `nref` greater than zero. Note that the nodes located along the
# edges are moved onto the spherical surface when they _should be_ on
# the spherical surface. This is important in order to ensure
# convergence to the proper value of the stress. Just refining the
# initial mesh without repositioning of the nodes onto the spherical surface would mean that the
# refinement would preserve a concave corner where in reality there is
# none. The stress would be artificially raised and convergence would
# not be guaranteed.
nref = 0
for ref = 1:nref
fens, fes = Q4refine(fens, fes)
list = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = [0.0 0.0],
inflate = tolerance,
)
fens.xyz[list, :] = FinEtools.MeshUtilModule.ontosphere(fens.xyz[list, :], 1.0)
end
##
# The mesh is extruded by sweeping around the axis of symmetry.
# Only a single layer of elements is generated of internal angle
# |angslice|.
nLayers = 7
angslice = 5 * pi / 16
##
# First the mesh is extruded to a block whose third dimension
# represents the angular coordinate.
fens, fes = H8extrudeQ4(
fens,
fes,
nLayers,
(rz, k) -> [rz[1], rz[2], 0.0] - (k) / nLayers * [0.0, 0.0, angslice],
)
##
# The mesh is now converted to the serendipity 20-node elements.
# We will reposition the nodes later.
fens, fes = H8toH20(fens, fes)
##
# The boundary of the block is extracted and the faces of the mesh on
# the bounding cross-sections are identified. Recall that this is just
# about the topology (connectivity), the geometry does not matter at
# this point.
bfes = meshboundary(fes)
f1l =
selectelem(fens, bfes, box = [-Inf, Inf, -Inf, Inf, 0.0, 0.0], inflate = tolerance)
f2l = selectelem(
fens,
bfes,
box = [-Inf, Inf, -Inf, Inf, -angslice, -angslice],
inflate = tolerance,
)
##
# The block is now converted to the axially symmetric geometry by using the
# third (angular) coordinate to sweep out an axially symmetric domain. The
# ccoordinates of the nodes at this point are |rza|, radial distance,
# Z-coordinate, angle.
sweep(rza) = [
-rza[1] * sin(rza[3] + angslice / 2.0),
rza[1] * cos(rza[3] + angslice / 2.0),
rza[2],
]
for j = 1:size(fens.xyz, 1)
fens.xyz[j, :] = sweep(fens.xyz[j, :])
end
##
# The nodes within the radial distance of 1.0 of the origin (i. e.
# those on the spherical surface) are repositioned one more time to be
# located on the spherical surface for sure. (Recall that we have
# inserted additional nodes at the midpoints of the edges when the mesh
# was converted to quadratic elements.)
list = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = [0.0 0.0 0.0],
inflate = tolerance,
)
fens.xyz[list, :] = FinEtools.MeshUtilModule.ontosphere(fens.xyz[list, :], 1.0)
##
# We are ready to create the finite element model machine and to use
# it to construct the global system for the displacements.
##
# The material is created from the property object. Note that the
# |alpha| attribute is the thermal expansion coefficient.
# Create isotropic elastic material
material = MatDeforElastIso(MR, 1.0, Ea, nua, alphaa)
##
# The finite element model machine puts together the material, the
# finite elements, and the integration rule. The Gauss quadrature with
# 3x3x3 points gives good accuracy in this case. Compare it with 2x2x2
# quadrature to appreciate the difference.
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 3)), material)
##
# The geometry nodal field is created from the node set. The
# displacement field is created by cloning the geometry and then
# zeroing out the nodal parameters.
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
nnodes(geom)
##
# The EBCs are applied next. Only the axial (Z) degrees of freedom at
# the bottom and top are fixed to zero.
l1 = selectnode(fens, box = [-Inf Inf -Inf Inf 0.0 0.0], inflate = tolerance)
setebc!(u, l1, true, 3, zeros(size(l1)))
l1 = selectnode(fens, box = [-Inf Inf -Inf Inf 1.79 1.79], inflate = tolerance)
setebc!(u, l1, true, 3, zeros(size(l1)))
applyebc!(u)
numberdofs!(u)
##
# The restraints of the nodes on the bounding cross-sections in the direction
# of the normal to the plane of the cross-section in the
# circumferential direction are introduced using a penalty formulation.
# For that purpose we introduce a finite element model machine for the
# surface finite elements on the cross-sections.
springcoefficient = 1.0 / ((abs(sigmaA) / 1.0e12) / Ea)
fl = vcat(f1l, f2l)
xsfemm = FEMMDeforWinkler(IntegDomain(subset(bfes, fl), GaussRule(2, 3)))
##
# We create the temperature field using the formula $T=r+z$.
dT = NodalField(
reshape(
sqrt.(fens.xyz[:, 1] .^ 2 + fens.xyz[:, 2] .^ 2) + fens.xyz[:, 3],
size(fens.xyz, 1),
1,
),
)
##
# And we are ready to assemble the system matrix. Both the elastic stiffness of
# the hexahedral elements ...
K = stiffness(femm, geom, u)
# ... and the elastic stiffness of the springs on the contact surfaces of the cross-sections.
H = surfacenormalspringstiffness(xsfemm, geom, u, springcoefficient, SurfaceNormal(3))
##
# The mechanical loads are computed from the thermal strains.
F = thermalstrainloads(femm, geom, u, dT)
##
# And the solution for the free degrees of freedom is obtained.
solve_blocked!(u, K+H, F)
##
# The stress is recovered from the stress calculated at the
# integration points.
fld = fieldfromintegpoints(femm, geom, u, dT, :Cauchy, 3)
##
# Now that we have the nodal field for the axial stress, we can plot
# the axial stress painted on the deformed geometry.
# File = "LE11NAFEMS_H20_sigmaz.vtk"
# vtkexportmesh(File, fens, fes;
# scalars=[("sigmaz", fld.values)], vectors=[("u", u.values)])
# @async run(`"paraview.exe" $File`)
# File = "LE11NAFEMS_H20_dT.vtk"
# vtkexportmesh(File, fens, fes; scalars=dT.values,scalars_name ="dT", vectors=u.values,vectors_name="u")
##
# The computed stress at the node that is located at the point A is
# going to be now extracted from the nodal field for the stress.
# Nodes at level Z=0.0
l1 = selectnode(fens, box = Float64[-Inf Inf -Inf Inf 0.0 0.0], inflate = tolerance)
l2 = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = Float64[0.0 0.0 0.0],
inflate = tolerance,
)
nA = intersect(l1, l2)
sA = mean(fld.values[nA]) / phun("MEGA*Pa")
sAn = mean(fld.values[nA]) / sigmaA
# println("Stress at point A: $(sA) i. e. $( sAn*100 )% of reference value")
@test abs(sA - (-83.7322285847101)) / (-83.7322285847101) < 1.e-3
## Discussion
#
##
# The 3-D solution corresponds well to the 2-D axially symmetric model.
# We also see good correspondence to other published solutions for
# comparable finite element models. For instance, Abaqus 6.11
# Benchmark manual lists very similar numbers.
end
end
using .sscratch_06112017
sscratch_06112017.test()
module cookstress_1
using Test
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!, matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using FinEtools.MeshExportModule
import LinearAlgebra: norm, cholesky, cross
function test()
# println("Cook membrane problem, plane stress." )
t0 = time()
E = 1.0
nu = 1.0 / 3
width = 48.0
height = 44.0
thickness = 1.0
free_height = 16.0
Mid_edge = [48.0, 52.0]# Location of tracked deflection
magn = 1.0 / free_height# Magnitude of applied load
convutip = 23.97
n = 32#*int(round(sqrt(170.)/2.)); # number of elements per side
tolerance = minimum([width, height]) / n / 1000.0#Geometrical tolerance
fens, fes = T3block(width, height, n, n)
# Reshape into a trapezoidal panel
for i = 1:count(fens)
fens.xyz[i, 2] =
fens.xyz[i, 2] +
(fens.xyz[i, 1] / width) *
(height - fens.xyz[i, 2] / height * (height - free_height))
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
l1 = selectnode(fens; box = [0, 0, -Inf, Inf], inflate = tolerance)
setebc!(u, l1, 1, 0.0)
setebc!(u, l1, 2, 0.0)
applyebc!(u)
numberdofs!(u)
boundaryfes = meshboundary(fes)
Toplist =
selectelem(fens, boundaryfes, box = [width, width, -Inf, Inf], inflate = tolerance)
el1femm = FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(1, 2)))
fi = ForceIntensity([0.0, +magn])
F2 = distribloads(el1femm, geom, u, fi, 2)
MR = DeforModelRed2DStress
material = MatDeforElastIso(MR, 0.0, E, nu, 0.0)
femm = FEMMDeforLinear(MR, IntegDomain(fes, TriRule(1)), material)
K = stiffness(femm, geom, u)
K_ff, K_fd = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[(:ff, :fd)]
F_f = vector_blocked(F2, nfreedofs(u))[:f]
U_f = K_ff \ (F_f)
scattersysvec!(u, U_f)
nl = selectnode(
fens,
box = [Mid_edge[1], Mid_edge[1], Mid_edge[2], Mid_edge[2]],
inflate = tolerance,
)
theutip = zeros(Float64, 1, 2)
gathervalues_asmat!(u, theutip, nl)
# println("$(time()-t0) [s]; displacement =$(theutip[2]) as compared to converged $convutip")
# File = "a.vtk"
# vtkexportmesh(File, fes.conn, geom.values+u.values,
# FinEtools.MeshExportModule.VTK.T3; vectors=[("u", u.values)])
@test abs(theutip[2] - 23.8155) / 23.8155 < 1.e-3 # FinEALE solution
end
end
using .cookstress_1
cookstress_1.test()
module scratch1_06092017
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!, matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using Test
mutable struct MyIData
c::Int
r::Vector{Float64}
s::Vector{Float64}
end
function test()
# println("Thick pipe with internal pressure: axially symmetric model")
#=
This is a simple modification of the full three-dimensional simulation of
the tutorial pub_thick_pipe that implements the axially-symmetric model
reduction procedure.
An infinitely long thick walled cylindrical pipe
with inner boundary radius of 3 mm and outer boundary radius of 9 mm is
subjected to an internal pressure of 1.0 MPa. A wedge with thickness of
2 mm and a 90-degree angle sector is considered for the finite element
analysis. The material properties are taken as isotropic linear elastic
with $E=1000$ MPa and $\nu=0.4999$ to represent nearly incompressible
behavior. This problem has been proposed to by MacNeal and Harder as a
test of an element's ability to represent the response of a nearly
incompressible material. The plane-strain condition is assumed in the
axial direction of the pipe which together with the radial symmetry
confines the material in all but the radial direction and therefore
amplifies the numerical difficulties associated with the confinement of
the nearly incompressible material.
There is an analytical solution to this problem. Timoshenko and Goodier
presented the original solution of Lame in their textbook. We are going
to compare with both the stress distribution (radial and hoop stresses)
and the displacement of the inner cylindrical surface.
References:
- Macneal RH, Harder RL (1985) A proposed standard set of problems to test
finite element accuracy. Finite Elements in Analysis and Design 1: 3-20.
- Timoshenko S. and Goodier J. N., Theory of Elasticity, McGraw-Hill, 2nd ed., 1951.
=#
# Internal radius of the pipe.
a = 3 * phun("MM")
##
# External radius of the pipe.
b = 9 * phun("MM")
##
# Thickness of the slice.
t = 2 * phun("MM")
##
# Geometrical tolerance.
tolerance = a / 10000.0
##
# Young's modulus and Poisson's ratio.
E = 1000 * phun("MEGA*PA")
nu = 0.499
##
# Applied pressure on the internal surface.
press = 1.0 * phun("MEGA*PA")
##
# Analytical solutions. Radial stress:
radial_stress(r) = press * a .^ 2 / (b^2 - a^2) .* (1 - (b^2) ./ r .^ 2)
##
# Circumferential (hoop) stress:
hoop_stress(r) = press * a .^ 2 / (b^2 - a^2) .* (1 + (b^2) ./ r .^ 2)
##
# Radial displacement:
radial_displacement(r) =
press * a^2 * (1 + nu) * (b^2 + r .^ 2 * (1 - 2 * nu)) / (E * (b^2 - a^2) .* r)
##
# Therefore the radial displacement of the loaded surface will be:
urex = radial_displacement(a)
##
# The mesh parameters: The numbers of element edges axially,
# and through the thickness of the pipe wall (radially).
na = 1
nt = 10
##
# Note that the material object needs to be created with the proper
# model-dimension reduction in effect. In this case that is the axial symmetry
# assumption.
MR = DeforModelRed2DAxisymm
axisymmetric = true
# Create the mesh and initialize the geometry. First we are going
# to construct the block of elements with the first coordinate
# corresponding to the thickness in the radial direction, and the second
# coordinate is the thickness in the axial direction.
fens, fes = Q8block(b - a, t, nt, na)
# Extract the boundary and mark the finite elements on the
# interior surface.
bdryfes = meshboundary(fes)
bcl = selectelem(fens, bdryfes, box = [0.0, 0.0, -Inf, Inf], inflate = tolerance)
internal_fenids = connectednodes(subset(bdryfes, bcl))
# Now shape the block into the actual wedge piece of the pipe.
for i = 1:count(fens)
fens.xyz[i, :] = fens.xyz[i, :] + [a; 0.0]
end
# now we create the geometry and displacement fields
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
# The plane-strain condition in the axial direction is specified by selecting nodes
# on the plane y=0 and y=t.
l1 = selectnode(fens; box = [-Inf Inf 0.0 0.0], inflate = tolerance)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(fens; box = [-Inf Inf t t], inflate = tolerance)
setebc!(u, l1, true, 2, 0.0)
applyebc!(u)
numberdofs!(u)
# The traction boundary condition is applied in the radial
# direction.
el1femm = FEMMBase(IntegDomain(subset(bdryfes, bcl), GaussRule(1, 3), axisymmetric))
fi = ForceIntensity([press; 0.0])
F2 = distribloads(el1femm, geom, u, fi, 2)
# Property and material
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 2), axisymmetric), material)
K = stiffness(femm, geom, u)
solve_blocked!(u, K, F2)
# Transfer the solution of the displacement to the nodes on the
# internal cylindrical surface and convert to
# cylindrical-coordinate displacements there.
uv = u.values[internal_fenids, :]
# Report the relative displacement on the internal surface:
# println("(Approximate/true displacement) at the internal surface: $( mean(uv[:,1])/urex*100 ) %")
# Produce a plot of the radial stress component in the cylindrical
# coordinate system. Note that this is the usual representation of
# stress using nodal stress field.
fld = fieldfromintegpoints(femm, geom, u, :Cauchy, 1)
# File = "thick_pipe_sigmax.vtk"
# vtkexportmesh(File, fens, fes; scalars=[("sigmax", fld.values)])
# Produce a plot of the solution components in the cylindrical
# coordinate system.
function inspector(idat::MyIData, elnum, conn, xe, out, xq)
push!(idat.r, xq[1])
push!(idat.s, out[idat.c])
return idat
end
idat = MyIData(1, Int[], Int[])
idat =
inspectintegpoints(femm, geom, u, collect(1:count(fes)), inspector, idat, :Cauchy)
# using Plots
# plotly()
#
# # Plot the analytical solution.
# r = linearspace(a,b,100);
# plot(r, radial_stress(r))
# # Plot the computed integration-point data
# plot!(idat.r, idat.s, m=:circle, color=:red)
# gui()
@test abs(idat.r[1] - 0.003126794919243112) < 1.0e-9
@test abs(idat.s[1] - -910911.9777008593) < 1.0e-2
## Discussion
#
##
# The axially symmetric model is clearly very effective
# computationally, as the size is much reduced compared to the 3-D
# model. In conjunction with uniform or selective reduced integration
# it can be very accurate as well.
end
end
using .scratch1_06092017
scratch1_06092017.test()
module scratch2_06102017
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!, matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using Test
import Arpack: eigs
function test()
# println("""
# % Vibration modes of unit cube of almost incompressible material.
# %
# % Reference: Puso MA, Solberg J (2006) A stabilized nodally integrated
# % tetrahedral. International Journal for Numerical Methods in
# % Engineering 67: 841-867.""")
# t0 = time()
E = 1 * phun("PA")
nu = 0.499
rho = 1 * phun("KG/M^3")
a = 1 * phun("M")
b = a
h = a
n1 = 10# How many element edges per side?
na = n1
nb = n1
nh = n1
neigvs = 20 # how many eigenvalues
OmegaShift = (0.01 * 2 * pi)^2
MR = DeforModelRed3D
fens, fes = H20block(a, b, h, na, nb, nh)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
K = stiffness(femm, geom, u)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 3)), material)
M = mass(femm, geom, u)
d, v, nev, nconv =
eigs(K + OmegaShift * M, M; nev = neigvs, which = :SM, explicittransform = :none)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
# println("Eigenvalues: $fs [Hz]")
# mode = 17
# scattersysvec!(u, v[:,mode])
# File = "unit_cube_modes.vtk"
# vtkexportmesh(File, fens, fes; vectors=[("mode$mode", u.values)])
@test abs(fs[7] - 0.26259869196259) < 1.0e-5
end
end
using .scratch2_06102017
scratch2_06102017.test()
module mxxxx1_06102017
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!, matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
import Statistics: mean
using Test
# println("""
# The initially twisted cantilever beam is one of the standard test
# problems for verifying the finite-element accuracy [1]. The beam is
# clamped at one end and loaded either with unit in-plane or
# unit out-of-plane force at the other. The centroidal axis of the beam is
# straight at the undeformed configuration, while its cross-sections are
# twisted about the centroidal axis from 0 at the clamped end to pi/2 at
# the free end.
#
# Reference:
# Zupan D, Saje M (2004) On "A proposed standard set of problems to test
# finite element accuracy": the twisted beam. Finite Elements in Analysis
# and Design 40: 1445-1451.
# """)
function Twisted_beam(dir)
E = 0.29e8
nu = 0.22
W = 1.1
L = 12.0
t = 0.32
nl = 2
nt = 1
nw = 1
ref = 7
p = 1 / W / t
# Loading in the Z direction
if dir == 2
loadv = [0; p; 0]
dir = 2
uex = 0.001753248285256 # Harder: 1.754e-3;
else
loadv = [0; 0; p]
dir = 3
uex = 0.005424534868469 # Harder: 5.424e-3;
end
# loadv = [0;0;p]; dir = 3; uex = 0.005424534868469; # Harder: 5.424e-3;
# Loading in the Y direction
#loadv = [0;p;0]; dir = 2; uex = 0.001753248285256; # Harder: 1.754e-3;
tolerance = t / 1000
fens, fes = H20block(L, W, t, nl * ref, nw * ref, nt * ref)
# Reshape into a twisted beam shape
for i = 1:count(fens)
a = fens.xyz[i, 1] / L * (pi / 2)
y = fens.xyz[i, 2] - (W / 2)
z = fens.xyz[i, 3] - (t / 2)
fens.xyz[i, :] = [fens.xyz[i, 1], y * cos(a) - z * sin(a), y * sin(a) + z * cos(a)]
end
# Clamped end of the beam
l1 =
selectnode(fens; box = [0 0 -100 * W 100 * W -100 * W 100 * W], inflate = tolerance)
e1 = FDataDict("node_list" => l1, "component" => 1, "displacement" => 0.0)
e2 = FDataDict("node_list" => l1, "component" => 2, "displacement" => 0.0)
e3 = FDataDict("node_list" => l1, "component" => 3, "displacement" => 0.0)
# Traction on the opposite edge
boundaryfes = meshboundary(fes)
Toplist = selectelem(
fens,
boundaryfes,
box = [L L -100 * W 100 * W -100 * W 100 * W],
inflate = tolerance,
)
el1femm = FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(2, 2)))
flux1 = FDataDict("femm" => el1femm, "traction_vector" => loadv)
# Make the region
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 00.0, E, nu, 0.0)
region1 = FDataDict(
"femm" => FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material),
)
# Make model data
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [e1, e2, e3],
"traction_bcs" => [flux1],
)
# Call the solver
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
geom = modeldata["geom"]
u = modeldata["u"]
# Extract the solution
nl =
selectnode(fens, box = [L L -100 * W 100 * W -100 * W 100 * W], inflate = tolerance)
nl1 = selectnode(
fens,
nearestto = fens.xyz[nl[1], :] + tolerance / 30 * rand(size(fens.xyz, 2)),
)
@test nl[1] == nl1[1]
theutip = mean(u.values[nl, :], dims = 1)
# println("displacement = $(theutip[dir]) as compared to converged $uex")
@test abs(theutip[dir] - uex) < 1.0e-5
# # Write out mesh with displacements
# modeldata["postprocessing"] = FDataDict("file"=>"twisted_beam")
# modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
#
# # Write out mesh with stresses
# modeldata["postprocessing"] = FDataDict("file"=>"twisted_beam",
# "quantity"=> :Cauchy, "component"=> :xy)
# modeldata = AlgoDeforLinearModule.exportstress(modeldata)
#
# # Write out mesh with stresses
# modeldata["postprocessing"] = FDataDict("file"=>"twisted_beam",
# "quantity"=> :Cauchy, "component"=> :xz)
# modeldata = AlgoDeforLinearModule.exportstress(modeldata)
#
# # Write out mesh with von Mises stresses
# modeldata["postprocessing"] = FDataDict("file"=>"twisted_beam",
# "quantity"=> :vm)
# modeldata = AlgoDeforLinearModule.exportstress(modeldata)
#
# # Write out mesh with von Mises stresses, elementwise
# modeldata["postprocessing"] = FDataDict("file"=>"twisted_beam-ew",
# "quantity"=> :vm)
# modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
#
# # Write out mesh with von Mises stresses, elementwise
# modeldata["postprocessing"] = FDataDict("file"=>"twisted_beam-ew",
# "quantity"=> :Cauchy, "component"=> :xz)
# modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
#
# println("Done")
true
end
function test()
Twisted_beam(2)
Twisted_beam(3)
end
end
using .mxxxx1_06102017
mxxxx1_06102017.test()
module mx_06112017
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!, matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using Test
import Statistics: mean
function test()
## Solid cylinder/taper/sphere—-temperature loading; quadratic brick mesh
#
## Description
#
# The solid cylinder/taper/sphere axially-symmetric part represented in
# Figure 1 is exposed to linearly varying temperature in the plane of the
# cross-section. The temperature in the coordinates $r$ (the coordinate)
# and $z$ (the axial ccoordinate) is given as $T=r+z$. The goal is to find
# the mechanical stress at the point A induced by the thermal expansion.
#
##
# The part is constrained against axial expansion along the faces of HIH'I'
# and ABA'B'. The Young's modulus is 210 GPa, the Poisson's ratio is .3,
# and the coefficient of thermal expansion is 2.3e-4/degree Celsius.
##
# This is a test recommended by the National Agency for Finite Element
# Methods and Standards (U.K.): Test LE11 from NAFEMS Publication TNSB,
# Rev. 3, “The Standard NAFEMS Benchmarks,” October 1990.
#
# Target solution: Compressive axial stress $\sigma_z$ = –105 MPa along
# the circle passing through point A.
##
# The toolkit has a helpful physical-units facility. The function phun()
# allows use of basic units and basic
# multipliers (for instance, mega).
##
# Set the material properties.
Ea = 210000 * phun("MEGA*PA")# Young's modulus
nua = 0.3# Poisson ratio
alphaa = 2.3e-4# coefficient of thermal expansion
##
# This is the target stress value.
sigmaA = -105 * phun("MEGA*PA")
##
# The mesh will be created in a very coarse representation from the
# key points in the drawing. The first coordinate is radial, the second coordinate is axial.
rz =
[
1.0 0.0#A
1.4 0.0#B
0.995184726672197 0.098017140329561
1.393258617341076 0.137223996461385
0.980785 0.195090#
1.37309939 0.27312645
0.956940335732209 0.290284677254462
1.339716470025092 0.406398548156247
0.9238795 0.38268#C
1.2124 0.7#D
0.7071 0.7071#E
1.1062 1.045#F
0.7071 (0.7071+1.79)/2#(E+H)/2
1.0 1.39#G
0.7071 1.79#H
1.0 1.79#I
] * phun("M")
tolerance = 1.e-6 * phun("M")
##
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the fully three-dimensional solid.
MR = DeforModelRed3D
# This is the quadrilateral mesh of the cross-section. It will be modified and
# refined as we go.
fens = FENodeSet(rz)
fes =
FESetQ4([1 2 4 3; 3 4 6 5; 5 6 8 7; 7 8 10 9; 9 10 12 11; 11 12 14 13; 13 14 16 15])
##
# If needed, the initial mesh can be refined by bisection. Just set
# `nref` greater than zero. Note that the nodes located along the
# edges are moved onto the spherical surface when they _should be_ on
# the spherical surface. This is important in order to ensure
# convergence to the proper value of the stress. Just refining the
# initial mesh without repositioning of the nodes onto the spherical surface would mean that the
# refinement would preserve a concave corner where in reality there is
# none. The stress would be artificially raised and convergence would
# not be guaranteed.
nref = 0
for ref = 1:nref
fens, fes = Q4refine(fens, fes)
list = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = [0.0 0.0],
inflate = tolerance,
)
fens.xyz[list, :] = FinEtools.MeshUtilModule.ontosphere(fens.xyz[list, :], 1.0)
end
##
# The mesh is extruded by sweeping around the axis of symmetry.
# Only a single layer of elements is generated of internal angle
# |angslice|.
nLayers = 7
angslice = 5 * pi / 16
##
# First the mesh is extruded to a block whose third dimension
# represents the angular coordinate.
fens, fes = H8extrudeQ4(
fens,
fes,
nLayers,
(rz, k) -> [rz[1], rz[2], 0.0] - (k) / nLayers * [0.0, 0.0, angslice],
)
##
# The mesh is now converted to the serendipity 20-node elements.
# We will reposition the nodes later.
fens, fes = H8toH20(fens, fes)
##
# The boundary of the block is extracted and the faces of the mesh on
# the bounding cross-sections are identified. Recall that this is just
# about the topology (connectivity), the geometry does not matter at
# this point.
bfes = meshboundary(fes)
f1l =
selectelem(fens, bfes, box = [-Inf, Inf, -Inf, Inf, 0.0, 0.0], inflate = tolerance)
f2l = selectelem(
fens,
bfes,
box = [-Inf, Inf, -Inf, Inf, -angslice, -angslice],
inflate = tolerance,
)
##
# The block is now converted to the axially symmetric geometry by using the
# third (angular) coordinate to sweep out an axially symmetric domain. The
# ccoordinates of the nodes at this point are |rza|, radial distance,
# Z-coordinate, angle.
sweep(rza) = [
-rza[1] * sin(rza[3] + angslice / 2.0),
rza[1] * cos(rza[3] + angslice / 2.0),
rza[2],
]
for j = 1:size(fens.xyz, 1)
fens.xyz[j, :] = sweep(fens.xyz[j, :])
end
##
# The nodes within the radial distance of 1.0 of the origin (i. e.
# those on the spherical surface) are repositioned one more time to be
# located on the spherical surface for sure. (Recall that we have
# inserted additional nodes at the midpoints of the edges when the mesh
# was converted to quadratic elements.)
list = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = [0.0 0.0 0.0],
inflate = tolerance,
)
fens.xyz[list, :] = FinEtools.MeshUtilModule.ontosphere(fens.xyz[list, :], 1.0)
##
# We are ready to create the finite element model machine and to use
# it to construct the global system for the displacements.
##
# The material is created from the property object. Note that the
# |alpha| attribute is the thermal expansion coefficient.
# Create isotropic elastic material
material = MatDeforElastIso(MR, 1.0, Ea, nua, alphaa)
##
# The finite element model machine puts together the material, the
# finite elements, and the integration rule. The Gauss quadrature with
# 3x3x3 points gives good accuracy in this case. Compare it with 2x2x2
# quadrature to appreciate the difference.
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 3)), material)
##
# The geometry nodal field is created from the node set. The
# displacement field is created by cloning the geometry and then
# zeroing out the nodal parameters.
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
nnodes(geom)
##
# The EBCs are applied next. Only the axial (Z) degrees of freedom at
# the bottom and top are fixed to zero.
l1 = selectnode(fens, box = [-Inf Inf -Inf Inf 0.0 0.0], inflate = tolerance)
setebc!(u, l1, true, 3, zeros(size(l1)))
l1 = selectnode(fens, box = [-Inf Inf -Inf Inf 1.79 1.79], inflate = tolerance)
setebc!(u, l1, true, 3, zeros(size(l1)))
applyebc!(u)
numberdofs!(u)
##
# The restraints of the nodes on the bounding cross-sections in the direction
# of the normal to the plane of the cross-section in the
# circumferential direction are introduced using a penalty formulation.
# For that purpose we introduce a finite element model machine for the
# surface finite elements on the cross-sections.
springcoefficient = 1.0 / ((abs(sigmaA) / 1.0e12) / Ea)
fl = vcat(f1l, f2l)
xsfemm = FEMMDeforWinkler(IntegDomain(subset(bfes, fl), GaussRule(2, 3)))
##
# We create the temperature field using the formula $T=r+z$.
dT = NodalField(
reshape(
sqrt.(fens.xyz[:, 1] .^ 2 + fens.xyz[:, 2] .^ 2) + fens.xyz[:, 3],
size(fens.xyz, 1),
1,
),
)
##
# And we are ready to assemble the system matrix. Both the elastic stiffness of
# the hexahedral elements ...
K = stiffness(femm, geom, u)
# ... and the elastic stiffness of the springs on the contact surfaces of the cross-sections.
H = surfacenormalspringstiffness(xsfemm, geom, u, springcoefficient, SurfaceNormal(3))
##
# The mechanical loads are computed from the thermal strains.
F = thermalstrainloads(femm, geom, u, dT)
##
# And the solution for the free degrees of freedom is obtained.
K_ff, K_fd = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[(:ff, :fd)]
H_ff, H_fd = matrix_blocked(H, nfreedofs(u), nfreedofs(u))[(:ff, :fd)]
F_f = vector_blocked(F, nfreedofs(u))[:f]
U_d = gathersysvec(u, :d)
U_f = (K_ff + H_ff) \ F_f
scattersysvec!(u, U_f)
##
# The stress is recovered from the stress calculated at the
# integration points.
fld = fieldfromintegpoints(femm, geom, u, dT, :Cauchy, 3)
##
# Now that we have the nodal field for the axial stress, we can plot
# the axial stress painted on the deformed geometry.
# File = "LE11NAFEMS_H20_sigmaz.vtk"
# vtkexportmesh(File, fens, fes;
# scalars=[("sigmaz", fld.values)], vectors=[("u", u.values)])
# @async run(`"paraview.exe" $File`)
# File = "LE11NAFEMS_H20_dT.vtk"
# vtkexportmesh(File, fens, fes; scalars=dT.values,scalars_name ="dT", vectors=u.values,vectors_name="u")
##
# The computed stress at the node that is located at the point A is
# going to be now extracted from the nodal field for the stress.
# Nodes at level Z=0.0
l1 = selectnode(fens, box = Float64[-Inf Inf -Inf Inf 0.0 0.0], inflate = tolerance)
l2 = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = Float64[0.0 0.0 0.0],
inflate = tolerance,
)
nA = intersect(l1, l2)
sA = mean(fld.values[nA]) / phun("MEGA*Pa")
sAn = mean(fld.values[nA]) / sigmaA
# println("Stress at point A: $(sA) i. e. $( sAn*100 )% of reference value")
@test abs(sA - (-83.7322285847101)) < 1e-4
## Discussion
#
##
# The 3-D solution corresponds well to the 2-D axially symmetric model.
# We also see good correspondence to other published solutions for
# comparable finite element models. For instance, Abaqus 6.11
# Benchmark manual lists very similar numbers.
end
end
using .mx_06112017
mx_06112017.test()
module my_06112017
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!, matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using Test
function test()
# NAFEMS LE11 benchmark with Q8 elements.
# # This is a test recommended by the National Agency for Finite Element
# # Methods and Standards (U.K.): Test LE11 from NAFEMS Publication TNSB,
# # Rev. 3, “The Standard NAFEMS Benchmarks,” October 1990.
# #
# # Target solution: Direct stress, = –105 MPa at point A.
#function LE11NAFEMS()
# Parameters:
Ea = 210000 * phun("MEGA*Pa")
nua = 0.3
alphaa = 2.3e-4 # thermal expansion coefficient
sigmaA = -105 * phun("MEGA*Pa")
nref = 1 # how many times should we refine the mesh?
X =
[
1.0 0.0#A
1.4 0.0#B
0.995184726672197 0.098017140329561
1.393258617341076 0.137223996461385
0.980785 0.195090#
1.37309939 0.27312645
0.956940335732209 0.290284677254462
1.339716470025092 0.406398548156247
0.9238795 0.38268#C
1.2124 0.7#D
0.7071 0.7071#E
1.1062 1.045#F
0.7071 (0.7071+1.79)/2#(E+H)/2
1.0 1.39#G
0.7071 1.79#H
1.0 1.79#I
] * phun("M")
tolerance = 1.e-6 * phun("M")
##
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the axial symmetry
# assumption.
MR = DeforModelRed2DAxisymm
fens = FENodeSet(X)
fes =
FESetQ4([1 2 4 3; 3 4 6 5; 5 6 8 7; 7 8 10 9; 9 10 12 11; 11 12 14 13; 13 14 16 15])
for ref = 1:nref
fens, fes = Q4refine(fens, fes)
list = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = [0.0 0.0],
inflate = tolerance,
)
fens.xyz[list, :] = FinEtools.MeshUtilModule.ontosphere(fens.xyz[list, :], 1.0)
end
fens, fes = Q4toQ8(fens, fes)
list = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = [0.0 0.0],
inflate = tolerance,
)
fens.xyz[list, :] = FinEtools.MeshUtilModule.ontosphere(fens.xyz[list, :], 1.0)
# File = "mesh.vtk"
# vtkexportmesh(File, fens, fes)
# now we create the geometry and displacement fields
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
# Apply EBC's
l1 = selectnode(fens, box = [-Inf Inf 0 0], inflate = tolerance)
setebc!(u, l1, true, 2, 00.0)
l1 = selectnode(fens, box = [-Inf Inf 1.79 1.79], inflate = tolerance)
setebc!(u, l1, true, 2, 00.0)
applyebc!(u)
numberdofs!(u)
# Temperature field
dT = NodalField(reshape(fens.xyz[:, 1] + fens.xyz[:, 2], size(fens.xyz, 1), 1))
# Property and material
material = MatDeforElastIso(MR, 0.0, Ea, nua, alphaa)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 3), true), material)
K = stiffness(femm, geom, u)
F = thermalstrainloads(femm, geom, u, dT)
#K = cholesky(K)
K_ff, K_fd = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[(:ff, :fd)]
F_f = vector_blocked(F, nfreedofs(u))[:f]
U_f = (K_ff) \ F_f
scattersysvec!(u, U_f)
nA = selectnode(fens, box = Float64[1.0 1.0 0.0 0.0], inflate = tolerance)
fld = fieldfromintegpoints(femm, geom, u, dT, :Cauchy, 2)
File = "LE11NAFEMS_Q8_sigmay.vtk"
vtkexportmesh(
File,
fens,
fes;
scalars = [("sigmay", fld.values)],
vectors = [("u", u.values)],
)
try
rm(File)
catch
end
sA = fld.values[nA] / phun("MEGA*Pa")
sAn = fld.values[nA] / sigmaA
# println("Stress at point A: $(sA) i. e. $( sAn*100 )% of reference value")
@test abs(sA[1] - (-93.8569)) < 1e-3
fen2fe = FENodeToFEMap(fes, nnodes(geom))
function inspector(idat, elnum, conn, xe, out, xq)
# println("loc = $( xq ) : $( transpose(out)/phun("MEGA*Pa") )")
return idat
end
inspectintegpoints(
femm,
geom,
u,
dT,
fen2fe.map[nA[1]],
inspector,
[];
quantity = :Cauchy,
)
#finealemesh(fens,fes,"meshmfile")
# end
# LE11NAFEMS()
end
end
using .my_06112017
my_06112017.test()
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 10509 | module mbaruniax1
using FinEtools
using FinEtoolsDeforLinear
using FinEtools.FENodeSetModule
using FinEtools.MeshExportModule
using FinEtoolsDeforLinear.MatDeforLinearElasticModule:
tangentmoduli!, update!, thermalstrain!
using Test
import LinearAlgebra: norm, cholesky, cross
function test()
E = 30e6 * phun("psi") # Young's modulus
alpha = 5.5e-6 * phun("in") / phun("in") / phun("F")
for nu in [0.0 0.3 0.45]
MR = DeforModelRed1DStress
material = MatDeforElastIso(MR, 0.0, E, nu, alpha)
D = fill(0.0, 1, 1)
t, dt, loc, label = 0.0, 0.0, [0.0 0.0 0.0], 0
tangentmoduli!(material, D, t, dt, loc, label)
@test D[1, 1] ≈ E
end
true
end
end
using .mbaruniax1
mbaruniax1.test()
module mbaruniax2
using FinEtools
using FinEtoolsDeforLinear
using FinEtools.FENodeSetModule
using FinEtools.MeshExportModule
using FinEtoolsDeforLinear.MatDeforLinearElasticModule:
tangentmoduli!, update!, thermalstrain!
using Test
import LinearAlgebra: norm, cholesky, cross
function test()
E = 30e6 * phun("psi") # Young's modulus
alpha = 5.5e-6 * phun("in") / phun("in") / phun("F")
for nu in [0.0 0.3 0.45]
MR = DeforModelRed1DStrain
material = MatDeforElastIso(MR, 0.0, E, nu, alpha)
D = fill(0.0, 1, 1)
t, dt, loc, label = 0.0, 0.0, [0.0 0.0 0.0], 0
tangentmoduli!(material, D, t, dt, loc, label)
lambda = E * nu / (1 + nu) / (1 - 2 * (nu))
mu = E / 2.0 / (1 + nu)
@test D[1, 1] ≈ lambda + 2 * mu
end
true
end
end
using .mbaruniax2
mbaruniax2.test()
module mTEST13H_in_fluid
using FinEtools
using FinEtools.AlgoBaseModule: matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using LinearAlgebra
using Arpack
using Test
function TEST13H_hva()
# Harmonic forced vibration problem is solved for a homogeneous square plate,
# simply-supported on the circumference.
# This is the TEST 13H from the Abaqus v 6.12 Benchmarks manual.
# The test is recommended by the National Agency for Finite Element Methods and Standards (U.K.):
# Test 13 from NAFEMS “Selected Benchmarks for Forced Vibration,” R0016, March 1993.
#
#
# The plate is discretized with hexahedral solid elements. The simple support
# condition is approximated by distributed rollers on the boundary.
# Because only the out of plane displacements are prevented, the structure
# has three rigid body modes in the plane of the plate.
#
#
# The nonzero benchmark frequencies are (in hertz): 2.377, 5.961, 5.961,
# 9.483, 12.133, 12.133, 15.468, 15.468 [Hz].
# println(""" Homogeneous square plate, simply-supported on the circumference,
# from the test 13 from NAFEMS “Selected Benchmarks for Forced Vibration,”
# R0016, March 1993. The nonzero benchmark frequencies are (in hertz): 2.377,
# 5.961, 5.961, 9.483, 12.133, 12.133, 15.468, 15.468 [Hz].
# This problem is extended by including fluid-induced damping by the
# surrounding air using a matrix expressing the ABC with dampers along the
# boundary.
# """)
# t0 = time()
E = 200 * phun("GPa")# Young's modulus
nu = 0.3# Poisson ratio
rho = 8000 * phun("KG*M^-3")# mass density
qmagn = 100.0 * phun("Pa")
L = 10.0 * phun("M") # side of the square plate
t = 0.05 * phun("M") # thickness of the square plate
nL = 16
nt = 4
tolerance = t / nt / 100
# neigvs = 11;
# OmegaShift = (2*pi*0.5) ^ 2; # to resolve rigid body modes
frequencies = vcat(linearspace(0.0, 2.377, 20), linearspace(2.377, 15.0, 70))
rho_fluid = 1.3 * phun("kg*m^3")
c_fluid = 341 * phun("m/s")
# Compute the parameters of Rayleigh damping. For the two selected
# frequencies we have the relationship between the damping ratio and
# the Rayleigh parameters
# $\xi_m=a_0/\omega_m+a_1\omega_m$
# where $m=1,2$. Solving for the Rayleigh parameters $a_0,a_1$ yields:
zeta1 = 0.02
zeta2 = 0.02
o1 = 2 * pi * 2.377
o2 = 2 * pi * 15.468
Rayleigh_mass = 2 * (o1 * o2) / (o2^2 - o1^2) * (o2 * zeta1 - o1 * zeta2)# a0
Rayleigh_stiffness = 2 * (o1 * o2) / (o2^2 - o1^2) * (-1 / o2 * zeta1 + 1 / o1 * zeta2)# a1
Rayleigh_mass = Rayleigh_mass
Rayleigh_stiffness = Rayleigh_stiffness
MR = DeforModelRed3D
fens, fes = H8block(L, L, t, nL, nL, nt)
geom = NodalField(fens.xyz)
u = NodalField(zeros(Complex{Float64}, size(fens.xyz, 1), 3)) # displacement field
nl = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
setebc!(u, nl, true, 3)
nl = selectnode(fens, box = [L L -Inf Inf -Inf Inf], inflate = tolerance)
setebc!(u, nl, true, 3)
nl = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
setebc!(u, nl, true, 3)
nl = selectnode(fens, box = [-Inf Inf L L -Inf Inf], inflate = tolerance)
setebc!(u, nl, true, 3)
applyebc!(u)
numberdofs!(u)
# println("nfreedofs = $(u.nfreedofs)")
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 3)), material)
M = mass(femm, geom, u)
C = Rayleigh_mass * M + Rayleigh_stiffness * K
bfes = meshboundary(fes)
sfemm = FEMMDeforSurfaceDamping(IntegDomain(bfes, GaussRule(2, 3)))
impedance = rho_fluid * c_fluid
D = dampingABC(sfemm, geom, u, impedance, SurfaceNormal(3))
# if true
# t0 = time()
# d,v,nev,nconv = eigs(K+OmegaShift*M, M; nev=neigvs, which=:SM)
# d = d - OmegaShift;
# fs = real(sqrt.(complex(d)))/(2*pi)
# println("Reference Eigenvalues: $fs [Hz]")
# println("eigs solution ($(time() - t0) sec)")
# end
bdryfes = meshboundary(fes)
topbfl = selectelem(fens, bdryfes, facing = true, direction = [0.0 0.0 1.0])
el1femm = FEMMBase(IntegDomain(subset(bdryfes, topbfl), GaussRule(2, 2)))
function pfun(forceout::Vector{T}, XYZ, tangents, feid, qpid) where {T}
forceout .= [0.0, 0.0, -qmagn]
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F = distribloads(el1femm, geom, u, fi, 2)
K_ff = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[:ff]
M_ff = matrix_blocked(M, nfreedofs(u), nfreedofs(u))[:ff]
D_ff = matrix_blocked(D, nfreedofs(u), nfreedofs(u))[:ff]
C_ff = matrix_blocked(C, nfreedofs(u), nfreedofs(u))[:ff]
F_f = vector_blocked(F, nfreedofs(u))[:f]
U_d = gathersysvec(u, :d)
U1 = zeros(Complex{Float64}, nfreedofs(u), length(frequencies))
for k in eachindex(frequencies)
frequency = frequencies[k]
omega = 2 * pi * frequency
U1[:, k] = (-omega^2 * M_ff + 1im * omega * (C_ff + D_ff) + K_ff) \ F_f
end
midpoint = selectnode(fens, box = [L / 2 L / 2 L / 2 L / 2 0 0], inflate = tolerance)
midpointdof = u.dofnums[midpoint, 3]
umidAmpl = abs.(U1[midpointdof, :]) / phun("MM")
@test abs(maximum(umidAmpl) - 9.56807e+00) < 1.0e-3 * 9.56807e+00
umidReal = real.(U1[midpointdof, :]) / phun("MM")
umidImag = imag.(U1[midpointdof, :]) / phun("MM")
umidPhase = atan.(umidImag, umidReal) / pi * 180
true
end # TEST13H_hva
TEST13H_hva()
end # module
module mdistorted_block_infsup1
using FinEtools
using FinEtools.AlgoBaseModule: matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtools.MeshExportModule
using FinEtoolsDeforLinear.FEMMDeforLinearBaseModule: infsup_gh, infsup_sh
using Test
import LinearAlgebra: norm, cholesky, I, eigen
# using UnicodePlots
function distorted_block_infsup_T4()
lambdatol = sqrt(1e8 * eps(1.0))
E = 1000.0
nu = 0.24
parshiftmult = 0.002
A = [1.44 -0.741 -0.53; -0.626 1.589 -0.913; -0.55 0.43 1.756] + 1.0I
lambdamin = Float64[]
h = Float64[]
for ne in [2, 3, 4]
Length, Width, Height, nL, nW, nH, orientation::Symbol =
(6.0, 6.0, 6.0, ne, ne, ne, :a)
fens, fes = T4block(Length, Width, Height, nL, nW, nH, orientation::Symbol)
# fens, fes = T4toT10(fens, fes)
# @show connasarray(fes)
for i = 1:count(fens)
fens.xyz[i, :] = fens.xyz[i, :] + vec(reshape(fens.xyz[i, :], 1, 3) * A)
end
# @show fens.xyz
# File = "minfsuptest1.vtk"
# vtkexportmesh(File, fens, fes)
# try rm(File); catch end
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
bfes = meshboundary(fes)
l1 = connectednodes(bfes)
setebc!(u, l1, true, 1, 0.0)
setebc!(u, l1, true, 2, 0.0)
setebc!(u, l1, true, 3, 0.0)
numberdofs!(u)
femm = FEMMDeforLinear(MR, IntegDomain(fes, TetRule(1)), material)
Gh = infsup_gh(femm, geom, u)
femm = FEMMDeforLinear(MR, IntegDomain(fes, TetRule(1)), material)
Sh = infsup_sh(femm, geom, u)
G_ff = matrix_blocked(Gh, nfreedofs(u), nfreedofs(u))[:ff]
S_ff = matrix_blocked(Sh, nfreedofs(u), nfreedofs(u))[:ff]
lambda, modes = eigen(Matrix(G_ff), Matrix(S_ff))
# @show lambda
abslambda = real.(filter(y -> !isnan(y), lambda))
ix = findall(y -> y < 0.0, abslambda)
if !isempty(ix)
abslambda[ix] .= 0
end
abslambda = sqrt.(sort(abslambda))
ix = findall(y -> y > 0.0, abslambda)
# a = lineplot(1:length(abslambda[ix]), log.(abslambda[ix]), name = "infsup", xlabel = "eigenvalue", ylabel = "log(eigenvalue)", canvas = DotCanvas)
# display(a)
ix = findall(y -> y >= lambdatol, abslambda)
if isempty(ix)
@error "Bad guess of the number of eigenvalues"
end
push!(lambdamin, abslambda[ix[1]])
push!(h, 1.0 / (count(fens))^(1 / 3))
end
# @show lambdamin
@test norm(lambdamin - [2.70777e-01, 1.79116e-01, 1.32893e-01]) < 1.0e-3
# a = lineplot(log.(h), log.(lambdamin), name = "infsup", xlabel = "log(Element Size)", ylabel = "log(minimum eigenvalue)", canvas = DotCanvas)
# display(a)
# @test norm(lambdamin - [0.262065, 0.1709, 0.126159, 0.100228, 0.0828139]) / norm(lambdamin) <= 1.0e-4
end
distorted_block_infsup_T4()
end # module
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 10065 | module test_alum_cyl_mode_examples
using FinEtools
using FinEtools.MeshExportModule
using FinEtoolsDeforLinear
using LinearAlgebra
using Arpack
using Test
# Mesh alum_cyl.inp
# Abaqus with the Standard isoparametric C3D4 tetrahedron:
C3D4 = [
1 0
2 0
3 6.63586E-005
4 0.000171053
5 0.000211299
6 0.000244378
7 2564.63
8 2568.09
9 2597.26
10 4094.38
11 4714.36
12 4717.19
13 5181.98
14 6865.13
15 6868.17
16 6962.86
17 6965.67
18 7024.97
19 7029.44
20 7108.54
]
# Abaqus with the standard quadratic tetrahedron:
C3D10 = [
1 0
2 0
3 0
4 0.000139365
5 0.000221551
6 0.000291805
7 2546.81
8 2546.81
9 2560.69
10 4100
11 4693.55
12 4693.56
13 5121.57
14 6841.21
15 6841.24
16 6914.22
17 6914.23
18 6950.64
19 6950.66
20 7000.64
]
neigvs = 24
function alum_cyl_mode_esnice_t4()
E = 70000 * phun("MPa")
nu = 0.33
rho = 2700 * phun("KG/M^3")
radius = 0.5 * phun("ft")
OmegaShift = (10.0 * 2 * pi)^2
MR = DeforModelRed3D
output = import_ABAQUS(joinpath(@__DIR__, "alum_cyl.inp"))
fens, fes = output["fens"], output["fesets"][1]
fens.xyz .*= phun("mm") # The input is provided in SI(mm) units
fens, fes = T10toT4(fens, fes)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
# println("Number of degrees of freedom: $(nfreedofs(u))")
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinearESNICET4(MR, IntegDomain(fes, NodalSimplexRule(3)), material)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
M = mass(femm, geom, u)
d, v, nev, nconv = eigs(
Symmetric(K + OmegaShift * M),
Symmetric(M);
nev = neigvs,
which = :SM,
explicittransform = :none,
)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
# println("Eigenvalues: $fs [Hz]")
# @show v' * M * v
@test norm(
fs - [
0.00000e+00,
0.00000e+00,
0.00000e+00,
5.54160e-06,
8.64750e-05,
1.18749e-04,
2.49815e+03,
2.49888e+03,
2.51331e+03,
4.08265e+03,
4.58599e+03,
4.58642e+03,
4.98701e+03,
6.64802e+03,
6.64848e+03,
6.67904e+03,
6.68216e+03,
6.77789e+03,
6.78059e+03,
6.79936e+03,
6.80400e+03,
7.38167e+03,
7.45600e+03,
7.47771e+03,
],
) < 0.01
true
end # alum_cyl_modes
function alum_cyl_mode_esnice_h8()
E = 70000 * phun("MPa")
nu = 0.33
rho = 2700 * phun("KG/M^3")
radius = 0.5 * phun("ft")
OmegaShift = (10.0 * 2 * pi)^2
neigvs = 15
MR = DeforModelRed3D
fens, fes = H8cylindern(radius, 4 * radius, 7, 28)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
# println("Number of degrees of freedom: $(nfreedofs(u))")
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm =
FEMMDeforLinearESNICEH8(MR, IntegDomain(fes, NodalTensorProductRule(3)), material)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
M = mass(femm, geom, u)
d, v, nev, nconv = eigs(
Symmetric(K + OmegaShift * M),
Symmetric(M);
nev = neigvs,
which = :SM,
explicittransform = :none,
)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
# println("Eigenvalues: $fs [Hz]")
# @show v' * M * v
@test norm(
fs - [
0.00000e+00,
0.00000e+00,
0.00000e+00,
0.00000e+00,
0.00000e+00,
0.00000e+00,
2.55691e+03,
2.55691e+03,
2.56007e+03,
4.09870e+03,
4.68757e+03,
4.68757e+03,
5.10331e+03,
6.81594e+03,
6.81594e+03,
],
) < 0.001 * norm(fs)
true
end # alum_cyl_modes
alum_cyl_mode_esnice_t4()
alum_cyl_mode_esnice_h8()
# alum_cyl_mode_esnice_t4_ssit()
# alum_cyl_mode_esnice_t4_ssit2()
end # module
nothing
module imspectrum01
using FinEtools
using FinEtools.MeshExportModule
using FinEtoolsDeforLinear
using LinearAlgebra
using Arpack
using Test
mesh() = (
FinEtools.FENodeSetModule.FENodeSet(
[
0.0 0.0 0.0
1.0 0.0 0.0
1.0 1.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0
1.0 0.0 1.0
1.0 1.0 1.0
0.0 1.0 1.0
],
),
FinEtools.FESetModule.FESetH8(reshape([1, 2, 3, 4, 5, 6, 7, 8], 1, 8)),
)
xyzperturbation =
[
0.0767656 -0.983206 -0.14343
0.45767 0.981479 0.450997
-0.295854 0.542922 0.321333
-0.85204 -0.97824 -0.772874
-0.0539756 0.994907 0.822798
0.447173 0.528742 0.0445352
-0.468417 0.00673427 0.953151
-0.898513 -0.915871 0.933237
] ./ 15.0
function bend_hex_spectrum_im()
aspect = 1.0
fens, fes = mesh()
fens.xyz += xyzperturbation
fens.xyz[:, 1] .*= aspect
E = 1.0
nu = 0.3
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
applyebc!(u)
numberdofs!(u)
femm = FEMMDeforLinearIMH8(MR, IntegDomain(fes, GaussRule(3, 2)), material, 9)
vol = integratefunction(femm, geom, x -> 1.0; m = 3)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
D = eigen(Matrix(K))
@test norm(
vec(D.values) - [
-4.58455e-17
-4.30053e-17
-2.66920e-17
-5.87832e-18
5.79305e-18
1.75741e-16
5.75036e-02
7.27270e-02
1.13685e-01
1.17365e-01
1.23125e-01
1.24759e-01
1.31453e-01
1.34094e-01
2.26511e-01
2.48770e-01
2.52006e-01
2.61382e-01
3.66797e-01
3.67082e-01
3.99538e-01
4.06751e-01
4.11962e-01
1.27359e+00
],
) < 0.001
# savecsv("bend_hex_spectrum_im-aspect=$(aspect).csv", eigenvalues = vec(D.values))
# @pgf _a = SemiLogYAxis({
# xlabel = "Mode [ND]",
# ylabel = "Generalized stiffness [N/m]",
# grid="major",
# legend_pos = "south east",
# title = "Hexahedron spectrum, aspect=$(aspect)"
# },
# Plot({"red", mark="triangle"}, Table([:x => vec(7:size(K, 1)), :y => vec(D.values[7:end])])), LegendEntry("IM"))
# display(_a)
# File = "bend_hex_spectrum_im.vtk"
# vectors = [("ev_$(idx)_$(round(D.values[idx] * 10000) / 10000)", deepcopy(scattersysvec!(u, D.vectors[:,idx]).values)) for idx in 1:length(D.values)]
# vtkexportmesh(File, fens, fes; vectors=vectors)
# @async run(`"paraview.exe" $File`)
true
end
bend_hex_spectrum_im()
end
module imspectrum02
using FinEtools
using FinEtools.MeshExportModule
using FinEtoolsDeforLinear
using LinearAlgebra
using Arpack
using Test
mesh() = (
FinEtools.FENodeSetModule.FENodeSet(
[
0.0 0.0 0.0
1.0 0.0 0.0
1.0 1.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0
1.0 0.0 1.0
1.0 1.0 1.0
0.0 1.0 1.0
],
),
FinEtools.FESetModule.FESetH8(reshape([1, 2, 3, 4, 5, 6, 7, 8], 1, 8)),
)
xyzperturbation =
[
0.0767656 -0.983206 -0.14343
0.45767 0.981479 0.450997
-0.295854 0.542922 0.321333
-0.85204 -0.97824 -0.772874
-0.0539756 0.994907 0.822798
0.447173 0.528742 0.0445352
-0.468417 0.00673427 0.953151
-0.898513 -0.915871 0.933237
] ./ 15.0
function bend_hex_spectrum_im()
aspect = 1.0
fens, fes = mesh()
fens.xyz += xyzperturbation
fens.xyz[:, 1] .*= aspect
E = 1.0
nu = 0.3
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
applyebc!(u)
numberdofs!(u)
femm = FEMMDeforLinearIMH8(MR, IntegDomain(fes, GaussRule(3, 2)), material, 12)
vol = integratefunction(femm, geom, x -> 1.0; m = 3)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
D = eigen(Matrix(K))
@test norm(
vec(D.values) - [-8.326672702176305e-17, -4.827453520116361e-17, -1.669460991334037e-17, -1.182337629536069e-17, 2.3661775396745044e-17, 5.210781206461985e-17, 0.05749523439988823, 0.07128305296214138, 0.07191559703272292, 0.07315367873032953, 0.07333313907279299, 0.1223734319272974, 0.13068791550072423, 0.13331802429413253, 0.2262389176079041, 0.24875817318694218, 0.251966284583263, 0.2612677200531636, 0.36679163524535935, 0.3670788597997576, 0.3994995351214447, 0.40671458702548835, 0.41188960354553344, 1.2735924014816593],
) < 0.001
# savecsv("bend_hex_spectrum_im-aspect=$(aspect).csv", eigenvalues = vec(D.values))
# @pgf _a = SemiLogYAxis({
# xlabel = "Mode [ND]",
# ylabel = "Generalized stiffness [N/m]",
# grid="major",
# legend_pos = "south east",
# title = "Hexahedron spectrum, aspect=$(aspect)"
# },
# Plot({"red", mark="triangle"}, Table([:x => vec(7:size(K, 1)), :y => vec(D.values[7:end])])), LegendEntry("IM"))
# display(_a)
# File = "bend_hex_spectrum_im.vtk"
# vectors = [("ev_$(idx)_$(round(D.values[idx] * 10000) / 10000)", deepcopy(scattersysvec!(u, D.vectors[:,idx]).values)) for idx in 1:length(D.values)]
# vtkexportmesh(File, fens, fes; vectors=vectors)
# @async run(`"paraview.exe" $File`)
true
end
bend_hex_spectrum_im()
end
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 30344 | """
Composite tests
R0031(1): Laminated strip under three-point bending
R0031(2): Wrapped thick cylinder under pressure and thermal loading
R0031(3): Three-layer sandwich shell under normal pressure loading
"""
module NAFEMS_R0031_1_test_msh8
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using Statistics: mean
using LinearAlgebra: norm, cross
using Test
function NAFEMS_R0031_1_msh8()
# println("""
# Laminated Strip Under Three-Point Bending. Mean-strain h8 elements.
# """)
# Determine the central transverse displacement in a simply-supported seven
# layer symmetric strip with a central line load. A 0/90/0/90/0/90/0
# material lay-up is specified with the center ply being four times as
# thick as the others.
# Reference: NAFEMS Report R0031, Test No.1, 17-Dec-1998.
# Because of the symmetries of the geometry and load, only the
# first-quadrant (in XY) quarter of the plate is modeled.
# The coordinate system is centered at point E (at the difference with
# respect to the original benchmark definition). The load is applied
# along a curve passing through point C. The simple support is applied
# along the curve passing through point B.
# We realize the simple supports along the lines A, B and the line load at
# point C are illegal from the point of view of convergence. No
# convergence can be hoped for as the stress underneath the load and above
# the simple supports is infinite in the limit (these locations are stress
# singularities). However, for relatively coarse meshes the results away
# from the singularities are still meaningful.
# The target quantities are displacement at the bottom surface at point E,
# the tensile axial stress at the same point, and of the transverse shear
# stress at point D in between the bottommost two layers (See figure 1).
t0 = time()
# Orthotropic material parameters of the material of the layers
E1s = 100.0 * phun("GPa")
E2s = E3s = 5.0 * phun("GPa")
nu12s = 0.4
nu13s = 0.3
nu23s = 0.3
G12s = 3.0 * phun("GPa")
G13s = G23s = 2.0 * phun("GPa")
CTE1 = 3.0e-6
CTE2 = 2.0e-5
CTE3 = 2.0e-5
AB = 30.0 * phun("mm") # span between simple supports
CD = 4.0 * phun("mm") # distance between the point D and the center
OH = 10.0 * phun("mm") # overhang
W = 10.0 * phun("mm") # width of the strip
# Here we define the layout and the thicknesses of the layers.
angles = vec([0 90 0 90 0 90 0])
ts = vec([0.1 0.1 0.1 0.4 0.1 0.1 0.1]) * phun("mm") # layer thicknesses
TH = sum(ts) # total thickness of the plate
tolerance = 0.0001 * TH
# The line load is in the negative Z direction.
q0 = 10 * phun("N/mm") # line load
# Reference deflection under the load is
wEref = -1.06 * phun("mm")
# The reference tensile stress at the bottom of the lowest layer is
sigma11Eref = 684 * phun("MPa")
# Because we model the first-quadrant quarter of the plate using
# coordinate axes centered at the point E the shear at the point D is
# positive instead of negative as in the benchmark where the coordinate
# system is located at the outer corner of the strip.
sigma13Dref = 4.1 * phun("MPa")
Refinement = 4
# We select 8 elements spanwise and 2 elements widthwise. The overhang
# of the plate is given one element.
nL = Refinement * 4
nO = Refinement * 1
nW = Refinement * 1
# Each layer is modeled with a single element times the refinement.
nts = Refinement * ones(Int, length(angles))# number of elements per layer
xs = unique(vcat(collect(linearspace(0.0, AB / 2, nL + 1)), [CD],
collect(linearspace(AB / 2, AB / 2 + OH, nO + 1))))
xs = xs[sortperm(xs)]
ys = collect(linearspace(0.0, W / 2, nW + 1))
fens, fes = H8layeredplatex(xs, ys, ts, nts)
# This is the material model
MR = DeforModelRed3D
material = MatDeforElastOrtho(MR,
0.0, E1s, E2s, E3s,
nu12s, nu13s, nu23s,
G12s, G13s, G23s,
CTE1, CTE2, CTE3)
# The material coordinate system function is defined as:
function _updatecs!(csmatout, feid, labels)
rotmat3!(csmatout, angles[labels[feid]] / 180.0 * pi * [0.0; 0.0; 1.0])
csmatout
end
# The vvolume integrals are evaluated using this rule
gr = GaussRule(3, 2)
# We will create two regions, one for the layers with 0° orientation,
# and one for the layers with 90° orientation.
rl1 = vcat(selectelem(fens, fes, label = 1),
selectelem(fens, fes, label = 3),
selectelem(fens, fes, label = 5),
selectelem(fens, fes, label = 7))
rfes1 = subset(fes, rl1)
region1 = FDataDict("femm" => FEMMDeforLinearMSH8(MR,
IntegDomain(rfes1, gr),
CSys(3,
3,
(csmatout, XYZ, tangents, feid, qpid) -> _updatecs!(csmatout,
feid,
rfes1.label)),
material))
rl2 = vcat(selectelem(fens, fes, label = 2),
selectelem(fens, fes, label = 4),
selectelem(fens, fes, label = 6))
rfes2 = subset(fes, rl2)
region2 = FDataDict("femm" => FEMMDeforLinearMSH8(MR,
IntegDomain(rfes2, gr),
CSys(3,
3,
(csmatout, XYZ, tangents, feid, qpid) -> _updatecs!(csmatout,
feid,
rfes2.label)),
material))
# File = "NAFEMS-R0031-1-plate-r1.vtk"
# vtkexportmesh(File, region1["femm"].integdomain.fes.conn, fens.xyz, FinEtools.MeshExportModule.H8)
# # @async run(`"paraview.exe" $File`)
# File = "NAFEMS-R0031-1-plate-r2.vtk"
# vtkexportmesh(File, region2["femm"].integdomain.fes.conn, fens.xyz, FinEtools.MeshExportModule.H8)
# @async run(`"paraview.exe" $File`)
# The essential boundary conditions are applied on the symmetry planes.
# First the plane X=0;...
lx0 = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
ex0 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lx0)
# ... and then the plane Y=0.
ly0 = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
ey0 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => ly0)
# The transverse displacement is fixed along the line passing through
# point B. The nodes are fixed in the box along this line in the Z
# direction.
lz0 = selectnode(fens, box = [AB / 2 AB / 2 -Inf Inf -Inf Inf], inflate = tolerance)
ez0 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lz0)
# The traction boundary condition is applied along the edge of the
# mesh passing through point C at the top surface of the strip. First
# we extract the boundary of the hexahedral mesh.
bfes = meshboundary(fes)
# From the entire boundary we select those quadrilaterals that lie on the plane
# X = 0
xl = selectelem(fens, bfes, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
# Now we extract the boundary of these selected quadrilaterals
bbfes = meshboundary(subset(bfes, xl))
# … And from these we extract the ones at the top
zl = selectelem(fens, bbfes, box = [0.0 0.0 -Inf Inf TH TH], inflate = tolerance)
# Note that we have to apply only half of the line load given that
# were modeling just one quarter of the geometry and we are splitting
# the line load with the symmetry plane X=0. Also note that the
# quadrature rule is one-dimensional since we are integrating along
# a curve.
Trac = FDataDict("traction_vector" => vec([0.0; 0.0; -q0 / 2]),
"femm" => FEMMBase(IntegDomain(subset(bbfes, zl), GaussRule(1, 3))))
modeldata = FDataDict("fens" => fens,
"regions" => [region1, region2],
"essential_bcs" => [ex0, ey0, ez0],
"traction_bcs" => [Trac])
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
modeldata["postprocessing"] = FDataDict("file" => "NAFEMS_R0031_1_msh8-plate")
modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# The results of the displacement and stresses will be reported at
# nodes located at the appropriate points.
nE = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 0.0], inflate = tolerance)
nC = selectnode(fens, box = [0.0 0.0 0.0 0.0 TH TH], inflate = tolerance)
nD = selectnode(fens, box = [CD CD 0.0 0.0 ts[1] ts[1]], inflate = tolerance)
n0z = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 TH], inflate = tolerance)
ix = sortperm(geom.values[n0z, 3])
# # println("ix = $(ix)")
cdis = mean(u.values[nE, 3])
# println("")
# println("Normalized Center deflection: $(cdis/wEref)")
extrap = :extraptrend
# # extrap = :extrapmean
inspectormeth = :averaging
# extrap = :default
# inspectormeth = :invdistance
modeldata["postprocessing"] = FDataDict("file" => "NAFEMS_R0031_1_msh8-plate-sx",
"quantity" => :Cauchy, "component" => 1, "outputcsys" => CSys(3),
"nodevalmethod" => inspectormeth, "reportat" => extrap)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
s = modeldata["postprocessing"]["exported"][1]["field"]
# println("sx@E = $(s.values[nE]/phun("MPa")) [MPa]")
# println("Reference sx@E = $(sigma11Eref/phun("MPa")) [MPa]")
@test norm(s.values[nE] .- 654.948 * phun("MPa")) / sigma11Eref < 1.0e-3
modeldata["postprocessing"] = FDataDict("file" => "NAFEMS_R0031_1_msh8-plate-sxz",
"quantity" => :Cauchy, "component" => 5, "outputcsys" => CSys(3),
"nodevalmethod" => inspectormeth, "reportat" => extrap)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
s = modeldata["postprocessing"]["exported"][1]["field"]
# println("sxz@D_1 = $(s.values[nD]/phun("MPa")) [MPa]")
@test norm(s.values[nD] .- 3.65590 * phun("MPa")) / sigma13Dref < 1.0e-3
s = modeldata["postprocessing"]["exported"][2]["field"]
# println("sxz@D_2 = $(s.values[nD]/phun("MPa")) [MPa]")
@test norm(s.values[nD] .- 4.14278 * phun("MPa")) / sigma13Dref < 1.0e-3
# println("Reference sxz@D = $(sigma13Dref/phun("MPa")) [MPa]")
# println("Done")
true
end # NAFEMS_R0031_1
NAFEMS_R0031_1_msh8()
end # module
nothing
module NAFEMS_R0031_1_test_esniceh8
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using Statistics: mean
using LinearAlgebra: norm, cross
using Test
function NAFEMS_R0031_1_esnice_h8()
# println("""
# Laminated Strip Under Three-Point Bending. ESNICE h8 elements.
# """)
# Determine the central transverse displacement in a simply-supported seven
# layer symmetric strip with a central line load. A 0/90/0/90/0/90/0
# material lay-up is specified with the center ply being four times as
# thick as the others.
# Reference: NAFEMS Report R0031, Test No.1, 17-Dec-1998.
# Because of the symmetries of the geometry and load, only the
# first-quadrant (in XY) quarter of the plate is modeled.
# The coordinate system is centered at point E (at the difference with
# respect to the original benchmark definition). The load is applied
# along a curve passing through point C. The simple support is applied
# along the curve passing through point B.
# We realize the simple supports along the lines A, B and the line load at
# point C are illegal from the point of view of convergence. No
# convergence can be hoped for as the stress underneath the load and above
# the simple supports is infinite in the limit (these locations are stress
# singularities). However, for relatively coarse meshes the results away
# from the singularities are still meaningful.
# The target quantities are displacement at the bottom surface at point E,
# the tensile axial stress at the same point, and of the transverse shear
# stress at point D in between the bottommost two layers (See figure 1).
t0 = time()
# Orthotropic material parameters of the material of the layers
E1s = 100.0 * phun("GPa")
E2s = E3s = 5.0 * phun("GPa")
nu12s = 0.4
nu13s = 0.3
nu23s = 0.3
G12s = 3.0 * phun("GPa")
G13s = G23s = 2.0 * phun("GPa")
CTE1 = 3.0e-6
CTE2 = 2.0e-5
CTE3 = 2.0e-5
AB = 30.0 * phun("mm") # span between simple supports
CD = 4.0 * phun("mm") # distance between the point D and the center
OH = 10.0 * phun("mm") # overhang
W = 10.0 * phun("mm") # width of the strip
# Here we define the layout and the thicknesses of the layers. Region 1 has
# orientation 0 degrees, and region 2 has orientation 90 degrees.
angles = vec([0 90])
ts = vec([0.1 0.1 0.1 0.4 0.1 0.1 0.1]) * phun("mm") # layer thicknesses
TH = sum(ts) # total thickness of the plate
tolerance = 0.0001 * TH
# The line load is in the negative Z direction.
q0 = 10 * phun("N/mm") # line load
# Reference deflection under the load is
wEref = -1.06 * phun("mm")
# The reference tensile stress at the bottom of the lowest layer is
sigma11Eref = 684 * phun("MPa")
# Because we model the first-quadrant quarter of the plate using
# coordinate axes centered at the point E the shear at the point D is
# positive instead of negative as in the benchmark where the coordinate
# system is located at the outer corner of the strip.
sigma13Dref = 4.1 * phun("MPa")
Refinement = 4
# We select 8 elements spanwise and 2 elements widthwise. The overhang
# of the plate is given one element.
nL = Refinement * 4
nO = Refinement * 1
nW = Refinement * 1
# Each layer is modeled with a single element times the refinement.
nts = Refinement * ones(Int, length(ts))# number of elements per layer
xs = unique(vcat(collect(linearspace(0.0, AB / 2, nL + 1)), [CD],
collect(linearspace(AB / 2, AB / 2 + OH, nO + 1))))
xs = xs[sortperm(xs)]
ys = collect(linearspace(0.0, W / 2, nW + 1))
fens, fes = H8layeredplatex(xs, ys, ts, nts)
# This is the material model
MR = DeforModelRed3D
material = MatDeforElastOrtho(MR,
0.0, E1s, E2s, E3s,
nu12s, nu13s, nu23s,
G12s, G13s, G23s,
CTE1, CTE2, CTE3)
# The material coordinate system function is defined as:
function _updatecs!(csmatout, feid, labels)
rotmat3!(csmatout, angles[feid] / 180.0 * pi * [0.0; 0.0; 1.0])
csmatout
end
# The vvolume integrals are evaluated using this rule
gr = TrapezoidalRule(3)
# We will create two regions, one for the layers with 0° orientation,
# and one for the layers with 90° orientation.
rl1 = vcat(selectelem(fens, fes, label = 1),
selectelem(fens, fes, label = 3),
selectelem(fens, fes, label = 5),
selectelem(fens, fes, label = 7))
rfes1 = subset(fes, rl1)
region1 = FDataDict("femm" => FEMMDeforLinearESNICEH8(MR,
IntegDomain(rfes1, gr),
CSys(3,
3,
(csmatout, XYZ, tangents, feid, qpid) -> _updatecs!(csmatout, 1, [])),
material))
rl2 = vcat(selectelem(fens, fes, label = 2),
selectelem(fens, fes, label = 4),
selectelem(fens, fes, label = 6))
rfes2 = subset(fes, rl2)
region2 = FDataDict("femm" => FEMMDeforLinearESNICEH8(MR,
IntegDomain(rfes2, gr),
CSys(3,
3,
(csmatout, XYZ, tangents, feid, qpid) -> _updatecs!(csmatout, 2, [])),
material))
# File = "NAFEMS-R0031-1-plate-r1.vtk"
# vtkexportmesh(File, region1["femm"].integdomain.fes.conn, fens.xyz, FinEtools.MeshExportModule.H8)
# # @async run(`"paraview.exe" $File`)
# File = "NAFEMS-R0031-1-plate-r2.vtk"
# vtkexportmesh(File, region2["femm"].integdomain.fes.conn, fens.xyz, FinEtools.MeshExportModule.H8)
# @async run(`"paraview.exe" $File`)
# The essential boundary conditions are applied on the symmetry planes.
# First the plane X=0;...
lx0 = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
ex0 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lx0)
# ... and then the plane Y=0.
ly0 = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
ey0 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => ly0)
# The transverse displacement is fixed along the line passing through
# point B. The nodes are fixed in the box along this line in the Z
# direction.
lz0 = selectnode(fens, box = [AB / 2 AB / 2 -Inf Inf -Inf Inf], inflate = tolerance)
ez0 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lz0)
# The traction boundary condition is applied along the edge of the
# mesh passing through point C at the top surface of the strip. First
# we extract the boundary of the hexahedral mesh.
bfes = meshboundary(fes)
# From the entire boundary we select those quadrilaterals that lie on the plane
# X = 0
xl = selectelem(fens, bfes, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
# Now we extract the boundary of these selected quadrilaterals
bbfes = meshboundary(subset(bfes, xl))
# … And from these we extract the ones at the top
zl = selectelem(fens, bbfes, box = [0.0 0.0 -Inf Inf TH TH], inflate = tolerance)
# Note that we have to apply only half of the line load given that
# were modeling just one quarter of the geometry and we are splitting
# the line load with the symmetry plane X=0. Also note that the
# quadrature rule is one-dimensional since we are integrating along
# a curve.
Trac = FDataDict("traction_vector" => vec([0.0; 0.0; -q0 / 2]),
"femm" => FEMMBase(IntegDomain(subset(bbfes, zl), TrapezoidalRule(1))))
modeldata = FDataDict("fens" => fens,
"regions" => [region1, region2],
"essential_bcs" => [ex0, ey0, ez0],
"traction_bcs" => [Trac])
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
modeldata["postprocessing"] = FDataDict("file" => "NAFEMS-R0031-1-plate-esnice-h8")
modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# The results of the displacement and stresses will be reported at
# nodes located at the appropriate points.
nE = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 0.0], inflate = tolerance)
nC = selectnode(fens, box = [0.0 0.0 0.0 0.0 TH TH], inflate = tolerance)
nD = selectnode(fens, box = [CD CD 0.0 0.0 ts[1] ts[1]], inflate = tolerance)
n0z = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 TH], inflate = tolerance)
ix = sortperm(geom.values[n0z, 3])
# # println("ix = $(ix)")
cdis = mean(u.values[nE, 3])
# println("")
# println("Normalized Center deflection: $(cdis/wEref)")
extrap = :extraptrend
# # extrap = :extrapmean
inspectormeth = :averaging
# extrap = :default
# inspectormeth = :invdistance
modeldata["postprocessing"] = FDataDict("file" => "NAFEMS-R0031-1-plate-esnice-h8-sx",
"quantity" => :Cauchy, "component" => 1, "outputcsys" => CSys(3),
"nodevalmethod" => inspectormeth, "reportat" => extrap)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
s = modeldata["postprocessing"]["exported"][1]["field"]
# println("sx@E = $(s.values[nE]/phun("MPa")) [MPa]")
# println("Reference sx@E = $(sigma11Eref/phun("MPa")) [MPa]")
@test norm(s.values[nE] .- 667.6985 * phun("MPa")) / sigma11Eref < 1.0e-3
modeldata["postprocessing"] = FDataDict("file" => "NAFEMS-R0031-1-plate-esnice-h8-sxz",
"quantity" => :Cauchy, "component" => 5, "outputcsys" => CSys(3),
"nodevalmethod" => inspectormeth, "reportat" => extrap)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
s = modeldata["postprocessing"]["exported"][1]["field"]
# println("sxz@D_1 = $(s.values[nD]/phun("MPa")) [MPa]")
@test norm(s.values[nD] .- 3.75795 * phun("MPa")) / sigma13Dref < 1.0e-3
s = modeldata["postprocessing"]["exported"][2]["field"]
# println("sxz@D_2 = $(s.values[nD]/phun("MPa")) [MPa]")
@test norm(s.values[nD] .- 4.36560 * phun("MPa")) / sigma13Dref < 1.0e-3
# println("Reference sxz@D = $(sigma13Dref/phun("MPa")) [MPa]")
# println("Done")
true
end # NAFEMS_R0031_1
NAFEMS_R0031_1_esnice_h8()
end # module
nothing
module NAFEMS_R0031_1_test_h20
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using Statistics: mean
using LinearAlgebra: norm, cross
using Test
function NAFEMS_R0031_1_H20()
# println("""
# Laminated Strip Under Three-Point Bending. H20 hexahedral elements.
# """)
# Determine the central transverse displacement in a simply-supported seven
# layer symmetric strip with a central line load. A 0/90/0/90/0/90/0
# material lay-up is specified with the center ply being four times as
# thick as the others.
# Reference: NAFEMS Report R0031, Test No.1, 17-Dec-1998.
# Because of the symmetries of the geometry and load, only the
# first-quadrant (in XY) quarter of the plate is modeled.
# The coordinate system is centered at point E (at the difference with
# respect to the original benchmark definition). The load is applied
# along a curve passing through point C. The simple support is applied
# along the curve passing through point B.
# We realize the simple supports along the lines A, B and the line load at
# point C are illegal from the point of view of convergence. No
# convergence can be hoped for as the stress underneath the load and above
# the simple supports is infinite in the limit (these locations are stress
# singularities). However, for relatively coarse meshes the results away
# from the singularities are still meaningful.
# The target quantities are displacement at the bottom surface at point E,
# the tensile axial stress at the same point, and of the transverse shear
# stress at point D in between the bottommost two layers (See figure 1).
t0 = time()
# Orthotropic material parameters of the material of the layers
E1s = 100.0 * phun("GPa")
E2s = E3s = 5.0 * phun("GPa")
nu12s = 0.4
nu13s = 0.3
nu23s = 0.3
G12s = 3.0 * phun("GPa")
G13s = G23s = 2.0 * phun("GPa")
CTE1 = 3.0e-6
CTE2 = 2.0e-5
CTE3 = 2.0e-5
AB = 30.0 * phun("mm") # span between simple supports
CD = 4.0 * phun("mm") # distance between the point D and the center
OH = 10.0 * phun("mm") # overhang
W = 10.0 * phun("mm") # width of the strip
# Here we define the layout and the thicknesses of the layers.
angles = vec([0 90 0 90 0 90 0])
ts = vec([0.1 0.1 0.1 0.4 0.1 0.1 0.1]) * phun("mm") # layer thicknesses
TH = sum(ts) # total thickness of the plate
tolerance = 0.0001 * TH
# The line load is in the negative Z direction.
q0 = 10 * phun("N/mm") # line load
# Reference deflection under the load is
wEref = -1.06 * phun("mm")
# The reference tensile stress at the bottom of the lowest layer is
sigma11Eref = 684 * phun("MPa")
# Because we model the first-quadrant quarter of the plate using
# coordinate axes centered at the point E the shear at the point D is
# positive instead of negative as in the benchmark where the coordinate
# system is located at the outer corner of the strip.
sigma13Dref = 4.1 * phun("MPa")
Refinement = 4
# We select 8 elements spanwise and 2 elements widthwise. The overhang
# of the plate is given one element.
nL = Refinement * 4
nO = Refinement * 1
nW = Refinement * 1
# Each layer is modeled with a single element times the refinementp.
nts = Refinement * ones(Int, length(angles))# number of elements per layer
xs = unique(vcat(collect(linearspace(0.0, AB / 2, nL + 1)), [CD],
collect(linearspace(AB / 2, AB / 2 + OH, nO + 1))))
xs = xs[sortperm(xs)]
ys = collect(linearspace(0.0, W / 2, nW + 1))
fens, fes = H8layeredplatex(xs, ys, ts, nts)
fens, fes = H8toH20(fens, fes)
# This is the material model
MR = DeforModelRed3D
material = MatDeforElastOrtho(MR,
0.0, E1s, E2s, E3s,
nu12s, nu13s, nu23s,
G12s, G13s, G23s,
CTE1, CTE2, CTE3)
# The material coordinate system function is defined as:
function _updatecs!(csmatout, feid, labels)
rotmat3!(csmatout, angles[labels[feid]] / 180.0 * pi * [0.0; 0.0; 1.0])
csmatout
end
# The vvolume integrals are evaluated using this rule
gr = GaussRule(3, 3)
# We will create two regions, one for the layers with 0° orientation,
# and one for the layers with 90° orientation.
rl1 = vcat(selectelem(fens, fes, label = 1),
selectelem(fens, fes, label = 3),
selectelem(fens, fes, label = 5),
selectelem(fens, fes, label = 7))
rfes1 = subset(fes, rl1)
region1 = FDataDict("femm" => FEMMDeforLinear(MR,
IntegDomain(rfes1, gr),
CSys(3,
3,
(csmatout, XYZ, tangents, feid, qpid) -> _updatecs!(csmatout,
feid,
rfes1.label)),
material))
rl2 = vcat(selectelem(fens, fes, label = 2),
selectelem(fens, fes, label = 4),
selectelem(fens, fes, label = 6))
rfes2 = subset(fes, rl2)
region2 = FDataDict("femm" => FEMMDeforLinear(MR,
IntegDomain(rfes2, gr),
CSys(3,
3,
(csmatout, XYZ, tangents, feid, qpid) -> _updatecs!(csmatout,
feid,
rfes2.label)),
material))
# File = "NAFEMS-R0031-1-plate-r1.vtk"
# vtkexportmesh(File, region1["femm"].integdomain.fes.conn, fens.xyz, FinEtools.MeshExportModule.H8)
# # @async run(`"paraview.exe" $File`)
# File = "NAFEMS-R0031-1-plate-r2.vtk"
# vtkexportmesh(File, region2["femm"].integdomain.fes.conn, fens.xyz, FinEtools.MeshExportModule.H8)
# @async run(`"paraview.exe" $File`)
# The essential boundary conditions are applied on the symmetry planes.
# First the plane X=0;...
lx0 = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
ex0 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lx0)
# ... and then the plane Y=0.
ly0 = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
ey0 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => ly0)
# The transverse displacement is fixed along the line passing through
# point B. The nodes are fixed in the box along this line in the Z
# direction.
lz0 = selectnode(fens, box = [AB / 2 AB / 2 -Inf Inf 0.0 0.0], inflate = tolerance)
ez0 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lz0)
# The traction boundary condition is applied along the edge of the
# mesh passing through point C at the top surface of the strip. First
# we extract the boundary of the hexahedral mesh.
bfes = meshboundary(fes)
# From the entire boundary we select those quadrilaterals that lie on the plane
# X = 0
xl = selectelem(fens, bfes, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
# Now we extract the boundary of these selected quadrilaterals
bbfes = meshboundary(subset(bfes, xl))
# … And from these we extract the ones at the top
zl = selectelem(fens, bbfes, box = [0.0 0.0 -Inf Inf TH TH], inflate = tolerance)
# Note that we have to apply only half of the line load given that
# were modeling just one quarter of the geometry and we are splitting
# the line load with the symmetry plane X=0. Also note that the
# quadrature rule is one-dimensional since we are integrating along
# a curve.
Trac = FDataDict("traction_vector" => vec([0.0; 0.0; -q0 / 2]),
"femm" => FEMMBase(IntegDomain(subset(bbfes, zl), GaussRule(1, 3))))
modeldata = FDataDict("fens" => fens,
"regions" => [region1, region2],
"essential_bcs" => [ex0, ey0, ez0],
"traction_bcs" => [Trac])
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
modeldata["postprocessing"] = FDataDict("file" => "NAFEMS_R0031_1_H20-plate")
modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# The results of the displacement and stresses will be reported at
# nodes located at the appropriate points.
nE = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 0.0], inflate = tolerance)
nC = selectnode(fens, box = [0.0 0.0 0.0 0.0 TH TH], inflate = tolerance)
nD = selectnode(fens, box = [CD CD 0.0 0.0 ts[1] ts[1]], inflate = tolerance)
cdis = mean(u.values[nE, 3])
# println("")
# println("Normalized Center deflection: $(cdis/wEref)")
modeldata["postprocessing"] = FDataDict("file" => "NAFEMS_R0031_1_H20-plate-sx",
"quantity" => :Cauchy, "component" => 1, "outputcsys" => CSys(3))
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
s = modeldata["postprocessing"]["exported"][1]["field"]
# println("sx@E = $(s.values[nE]/phun("MPa")) [MPa]")
# println("Reference sx@E = $(sigma11Eref/phun("MPa")) [MPa]")
@test norm(s.values[nE] .- 668.16037 * phun("MPa")) / sigma11Eref < 1.0e-3
modeldata["postprocessing"] = FDataDict("file" => "NAFEMS_R0031_1_H20-plate-sxz",
"quantity" => :Cauchy, "component" => 5, "outputcsys" => CSys(3))
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
s = modeldata["postprocessing"]["exported"][1]["field"]
# println("sxz@D = $(s.values[nD]/phun("MPa")) [MPa]")
@test norm(s.values[nD] .- 3.619757 * phun("MPa")) / sigma13Dref < 1.0e-3
s = modeldata["postprocessing"]["exported"][2]["field"]
# println("sxz@D = $(s.values[nD]/phun("MPa")) [MPa]")
@test norm(s.values[nD] .- 4.100860 * phun("MPa")) / sigma13Dref < 1.0e-3
# println("Reference sxz@D = $(sigma13Dref/phun("MPa")) [MPa]")
# println("Done")
true
end # NAFEMS_R0031_1_H20
NAFEMS_R0031_1_H20()
end # module
nothing
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 39013 |
module mmmNAFEMS_R0031_3m
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using Test
import Statistics: mean
function test()
# println("""
# NAFEMS publication R0031/3 Composite plate test.
# Simply supported on all four edges. Uniform transverse loading.
# The modeled part is one quarter of the full plate here.
# """)
# This is a test recommended by the National Agency for Finite Element Methods
# and Standards (U.K.): Test R0031/3 from NAFEMS publication R0031, “Composites
# Benchmarks,” February 1995.
t0 = time()
# Skin (face) material parameters
E1s = 1.0e7 * phun("psi")
E2s = 0.4e7 * phun("psi")
E3s = 0.4e7 * phun("psi")
nu12s = 0.3
nu13s = 0.3
nu23s = 0.3
G12s = 0.1875e7 * phun("psi")
G13s = 0.1875e7 * phun("psi")
G23s = 0.1875e7 * phun("psi")
# Core material parameters
E1c = 10.0 * phun("psi")
E2c = 10.0 * phun("psi")
E3c = 10e4 .* phun("psi")
nu12c = 0.0
nu13c = 0.0
nu23c = 0.0
G12c = 10.0 * phun("psi")
G13c = 3.0e4 * phun("psi")
G23c = 1.2e4 * phun("psi")
L = 10.0 * phun("in") # side of the square plate
nL = 8 # number of elements along the side of the plate
tolerance = 0.0001 * phun("in")
xs = collect(linearspace(0.0, L / 2, nL + 1))
ys = collect(linearspace(0.0, L / 2, nL + 1))
ts = [0.028; 0.75; 0.028] * phun("in")
nts = [2; 3; 2] # number of elements through the thickness
tmag = 100 * phun("psi")
# Generate mesh
fens, fes = H8layeredplatex(xs, ys, ts, nts)
fens, fes = H8toH20(fens, fes)
MR = DeforModelRed3D
skinmaterial = MatDeforElastOrtho(
MR,
0.0,
E1s,
E2s,
E3s,
nu12s,
nu13s,
nu23s,
G12s,
G13s,
G23s,
0.0,
0.0,
0.0,
)
corematerial = MatDeforElastOrtho(
MR,
0.0,
E1c,
E2c,
E3c,
nu12c,
nu13c,
nu23c,
G12c,
G13c,
G23c,
0.0,
0.0,
0.0,
)
gr = GaussRule(3, 3)
rl1 = selectelem(fens, fes, label = 1)
skinbot = FDataDict(
"femm" => FEMMDeforLinear(MR, IntegDomain(subset(fes, rl1), gr), skinmaterial),
)
rl3 = selectelem(fens, fes, label = 3)
skintop = FDataDict(
"femm" => FEMMDeforLinear(MR, IntegDomain(subset(fes, rl3), gr), skinmaterial),
)
rl2 = selectelem(fens, fes, label = 2)
core = FDataDict(
"femm" => FEMMDeforLinear(MR, IntegDomain(subset(fes, rl2), gr), corematerial),
)
lx0 = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
lxL2 = selectnode(fens, box = [L / 2 L / 2 -Inf Inf -Inf Inf], inflate = tolerance)
ly0 = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
lyL2 = selectnode(fens, box = [-Inf Inf L / 2 L / 2 -Inf Inf], inflate = tolerance)
ex0 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => lx0)
exL2 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => lxL2)
ey0 = FDataDict("displacement" => 0.0, "component" => 3, "node_list" => ly0)
eyL2 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => lyL2)
bfes = meshboundary(fes)
ttopl = selectelem(fens, bfes; facing = true, direction = [0.0 0.0 1.0])
Trac = FDataDict(
"traction_vector" => [0.0; 0.0; -tmag],
"femm" => FEMMBase(IntegDomain(subset(bfes, ttopl), GaussRule(2, 3))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [skinbot, core, skintop],
"essential_bcs" => [ex0, exL2, ey0, eyL2],
"traction_bcs" => [Trac],
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
lcenter =
selectnode(fens, box = [L / 2 L / 2 L / 2 L / 2 -Inf Inf], inflate = tolerance)
cdis = mean(u.values[lcenter, 3]) / phun("in")
# println("Center node displacements $(cdis) [in]; NAFEMS-R0031-3 lists –0.123 [in]")
# println("")
@test abs(cdis - (-0.13634800328800462)) < 1.0e-5
File = "NAFEMS-R0031-3-plate.vtk"
vtkexportmesh(
File,
connasarray(fes),
geom.values,
FinEtools.MeshExportModule.VTK.H20;
scalars = [("Layer", fes.label)],
vectors = [("displacement", u.values)],
)
# @async run(`"paraview.exe" $File`)
try
rm(File)
catch
end
end
end
using .mmmNAFEMS_R0031_3m
mmmNAFEMS_R0031_3m.test()
module mmtwistedmsh8mmm
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
import LinearAlgebra: norm, cholesky, cross
using Test
import Statistics: mean
function test()
# println("""
# The initially twisted cantilever beam is one of the standard test
# problems for verifying the finite-element accuracy [1]. The beam is
# clamped at one end and loaded either with unit in-plane or
# unit out-of-plane force at the other. The centroidal axis of the beam is
# straight at the undeformed configuration, while its cross-sections are
# twisted about the centroidal axis from 0 at the clamped end to pi/2 at
# the free end.
#
# Reference:
# Zupan D, Saje M (2004) On "A proposed standard set of problems to test
# finite element accuracy": the twisted beam. Finite Elements in Analysis
# and Design 40: 1445-1451.
# """)
E = 0.29e8
nu = 0.22
W = 1.1
L = 12.0
t = 0.32
nl = 2
nt = 1
nw = 1
ref = 7
p = 1 / W / t
# Loading in the Z direction
loadv = [0; 0; p]
dir = 3
uex = 0.005424534868469 # Harder: 5.424e-3;
# Loading in the Y direction
#loadv = [0;p;0]; dir = 2; uex = 0.001753248285256; # Harder: 1.754e-3;
tolerance = t / 1000
fens, fes = H8block(L, W, t, nl * ref, nw * ref, nt * ref)
# Reshape into a twisted beam shape
for i = 1:count(fens)
a = fens.xyz[i, 1] / L * (pi / 2)
y = fens.xyz[i, 2] - (W / 2)
z = fens.xyz[i, 3] - (t / 2)
fens.xyz[i, :] = [fens.xyz[i, 1], y * cos(a) - z * sin(a), y * sin(a) + z * cos(a)]
end
# Clamped end of the beam
l1 =
selectnode(fens; box = [0 0 -100 * W 100 * W -100 * W 100 * W], inflate = tolerance)
e1 = FDataDict("node_list" => l1, "component" => 1, "displacement" => 0.0)
e2 = FDataDict("node_list" => l1, "component" => 2, "displacement" => 0.0)
e3 = FDataDict("node_list" => l1, "component" => 3, "displacement" => 0.0)
# Traction on the opposite edge
boundaryfes = meshboundary(fes)
Toplist = selectelem(
fens,
boundaryfes,
box = [L L -100 * W 100 * W -100 * W 100 * W],
inflate = tolerance,
)
el1femm = FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(2, 2)))
flux1 = FDataDict("femm" => el1femm, "traction_vector" => loadv)
# Make the region
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 00.0, E, nu, 0.0)
region1 = FDataDict(
"femm" => FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material),
)
# Make model data
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [e1, e2, e3],
"traction_bcs" => [flux1],
)
# Call the solver
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
geom = modeldata["geom"]
u = modeldata["u"]
# Extract the solution
nl =
selectnode(fens, box = [L L -100 * W 100 * W -100 * W 100 * W], inflate = tolerance)
theutip = mean(u.values[nl, :], dims = 1)
# println("displacement = $(theutip[dir]) as compared to converged $uex")
@test abs(theutip[dir] - uex) / uex < 0.0012
# Write out mesh with displacements
modeldata["postprocessing"] = FDataDict("file" => "twisted_beam_msh8")
modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
# Write out mesh with stresses
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam_msh8", "quantity" => :Cauchy, "component" => :xy)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
# Write out mesh with stresses
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam_msh8", "quantity" => :Cauchy, "component" => :xz)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
# Write out mesh with von Mises stresses
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam_msh8", "quantity" => :vm)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
vm = modeldata["postprocessing"]["exported"][1]["field"]
# println("extremes of vm, nodal: $([minimum(vm.values), maximum(vm.values)])")
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
@test norm([minimum(vm.values), maximum(vm.values)] - [4.78774, 522.126]) < 0.01
# Write out mesh with von Mises stresses, elementwise
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam_msh8-ew", "quantity" => :vm)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
vm = modeldata["postprocessing"]["exported"][1]["field"]
# println("extremes of vm, elemental: $([minimum(vm.values), maximum(vm.values)])")
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
@test norm([minimum(vm.values), maximum(vm.values)] - [1.85882, 522.126]) < 0.01
# Write out mesh with von Mises stresses, elementwise
modeldata["postprocessing"] = FDataDict(
"file" => "twisted_beam_msh8-ew",
"quantity" => :Cauchy,
"component" => :xz,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
end
end
using .mmtwistedmsh8mmm
mmtwistedmsh8mmm.test()
module mmunitmmccubemmvibrationmmms
using FinEtools
using FinEtoolsDeforLinear
using Test
import LinearAlgebra: norm, cholesky, cross
function test()
# println("""
# % Vibration modes of unit cube of almost incompressible material.
# % Mean-strain hexahedron.
# % Reference: Puso MA, Solberg J (2006) A stabilized nodally integrated
# % tetrahedral. International Journal for Numerical Methods in
# % Engineering 67: 841-867.""")
t0 = time()
E = 1 * phun("PA")
nu = 0.499
rho = 1 * phun("KG/M^3")
a = 1 * phun("M")
b = a
h = a
n1 = 8 # How many element edges per side?
na = n1
nb = n1
nh = n1
neigvs = 20 # how many eigenvalues
omega_shift = (0.1 * 2 * pi)^2
fens, fes = H8block(a, b, h, na, nb, nh)
# Make the region
MR = DeforModelRed3D
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
region1 = FDataDict(
"femm" => FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material),
"femm_mass" =>
FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 3)), material),
)
# Make model data
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"omega_shift" => omega_shift,
"neigvs" => neigvs,
)
# Solve
modeldata = FinEtoolsDeforLinear.AlgoDeforLinearModule.modal(modeldata)
fs = modeldata["omega"] / (2 * pi)
# println("Eigenvalues: $fs [Hz]")
@test norm(
fs - [
1.92866e-7,
2.07497e-7,
2.16105e-7,
2.31656e-7,
2.35711e-7,
2.53067e-7,
0.266016,
0.266016,
0.364001,
0.364001,
0.364001,
0.366888,
0.366888,
0.366888,
0.415044,
0.415044,
0.41703,
0.467364,
0.467364,
0.467364,
],
) < 0.0001
modeldata["postprocessing"] = FDataDict("file" => "unit_cube_mode", "mode" => 10)
modeldata = FinEtoolsDeforLinear.AlgoDeforLinearModule.exportmode(modeldata)
# @async run(`"paraview.exe" $(modeldata["postprocessing"]["file"]*"1.vtk")`)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
true
end
end
using .mmunitmmccubemmvibrationmmms
mmunitmmccubemmvibrationmmms.test()
module mmtwistedbeamisomm
using FinEtools
using FinEtoolsDeforLinear
using Test
using FinEtoolsDeforLinear.AlgoDeforLinearModule
import LinearAlgebra: norm, cholesky, cross
import Statistics: mean
function test()
E = 0.29e8
nu = 0.22
W = 1.1
L = 12.0
t = 0.32
nl = 2
nt = 1
nw = 1
ref = 4
p = 1 / W / t
# Loading in the Z direction
loadv = [0; 0; p]
dir = 3
uex = 0.005424534868469 # Harder: 5.424e-3;
# Loading in the Y direction
#loadv = [0;p;0]; dir = 2; uex = 0.001753248285256; # Harder: 1.754e-3;
tolerance = t / 1000
fens, fes = H20block(L, W, t, nl * ref, nw * ref, nt * ref)
# Reshape into a twisted beam shape
for i = 1:count(fens)
a = fens.xyz[i, 1] / L * (pi / 2)
y = fens.xyz[i, 2] - (W / 2)
z = fens.xyz[i, 3] - (t / 2)
fens.xyz[i, :] = [fens.xyz[i, 1], y * cos(a) - z * sin(a), y * sin(a) + z * cos(a)]
end
# Clamped end of the beam
l1 =
selectnode(fens; box = [0 0 -100 * W 100 * W -100 * W 100 * W], inflate = tolerance)
e1 = FDataDict("node_list" => l1, "component" => 1, "displacement" => 0.0)
e2 = FDataDict("node_list" => l1, "component" => 2, "displacement" => 0.0)
e3 = FDataDict("node_list" => l1, "component" => 3, "displacement" => 0.0)
# Traction on the opposite edge
boundaryfes = meshboundary(fes)
Toplist = selectelem(
fens,
boundaryfes,
box = [L L -100 * W 100 * W -100 * W 100 * W],
inflate = tolerance,
)
el1femm = FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(2, 2)))
flux1 = FDataDict("femm" => el1femm, "traction_vector" => loadv)
# Make the region
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 00.0, E, nu, 0.0)
region1 = FDataDict(
"femm" => FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material),
)
# Make model data
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [e1, e2, e3],
"traction_bcs" => [flux1],
)
# Call the solver
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
geom = modeldata["geom"]
u = modeldata["u"]
# Extract the solution
nl =
selectnode(fens, box = [L L -100 * W 100 * W -100 * W 100 * W], inflate = tolerance)
theutip = mean(u.values[nl, :], dims = 1)
# println("displacement = $(theutip[dir]) as compared to converged $uex")
# println("normalized displacement = $(theutip[dir]/uex*100) %")
@test abs(theutip[dir] / uex * 100 - 99.85504856450584) < 1.0e-6
# Write out mesh with displacements
modeldata["postprocessing"] = FDataDict("file" => "twisted_beam")
modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
# Write out mesh with stresses
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam", "quantity" => :Cauchy, "component" => :xy)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
# Write out mesh with stresses
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam", "quantity" => :Cauchy, "component" => :xz)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
# Write out mesh with von Mises stresses
modeldata["postprocessing"] = FDataDict("file" => "twisted_beam", "quantity" => :vm)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
# Write out mesh with von Mises stresses, elementwise
modeldata["postprocessing"] = FDataDict("file" => "twisted_beam-ew", "quantity" => :vm)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
vm = modeldata["postprocessing"]["exported"][1]["field"]
# println("extremes of von Mises: $([minimum(vm.values), maximum(vm.values)])")
@test norm([minimum(vm.values), maximum(vm.values)] - [6.94796, 451.904]) < 1.e-3
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
# Write out mesh with von Mises stresses, elementwise
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam-ew", "quantity" => :Cauchy, "component" => :xz)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
# Write out mesh with principal stresses, elementwise
modeldata["postprocessing"] = FDataDict(
"file" => "twisted_beam-principal-1-ew",
"quantity" => :princCauchy,
"component" => 1,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
ps = modeldata["postprocessing"]["exported"][1]["field"]
# println("extremes of first principal stress: $([minimum(ps.values), maximum(ps.values)])")
@test norm([minimum(ps.values), maximum(ps.values)] - [0.493918, 459.106]) < 1.e-3
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
# Write out mesh with principal stresses, elementwise
modeldata["postprocessing"] = FDataDict(
"file" => "twisted_beam-principal-3-ew",
"quantity" => :princCauchy,
"component" => 3,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
ps = modeldata["postprocessing"]["exported"][1]["field"]
# println("extremes of third principal stress: $([minimum(ps.values), maximum(ps.values)])")
@test norm([minimum(ps.values), maximum(ps.values)] - [-459.106, -0.493918]) < 1.e-3
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
# Write out mesh with pressure, elementwise
modeldata["postprocessing"] = FDataDict(
"file" => "twisted_beam-press-ew",
"quantity" => :pressure,
"component" => 1,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
ps = modeldata["postprocessing"]["exported"][1]["field"]
# println("extremes of pressure: $([minimum(ps.values), maximum(ps.values)])")
@test norm([minimum(ps.values), maximum(ps.values)] - [-160.396, 160.396]) < 1.e-3
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
end
end
using .mmtwistedbeamisomm
mmtwistedbeamisomm.test()
module mmtwistedbeamoorthomm
using FinEtools
using FinEtoolsDeforLinear
using Test
import LinearAlgebra: norm, cholesky, cross
using FinEtoolsDeforLinear.AlgoDeforLinearModule
import Statistics: mean
function test()
E = 0.29e8
nu = 0.22
W = 1.1
L = 12.0
t = 0.32
nl = 2
nt = 1
nw = 1
ref = 4
p = 1 / W / t
# Loading in the Z direction
loadv = [0; 0; p]
dir = 3
uex = 0.005424534868469 # Harder: 5.424e-3;
# Loading in the Y direction
#loadv = [0;p;0]; dir = 2; uex = 0.001753248285256; # Harder: 1.754e-3;
tolerance = t / 1000
fens, fes = H20block(L, W, t, nl * ref, nw * ref, nt * ref)
# Reshape into a twisted beam shape
for i = 1:count(fens)
a = fens.xyz[i, 1] / L * (pi / 2)
y = fens.xyz[i, 2] - (W / 2)
z = fens.xyz[i, 3] - (t / 2)
fens.xyz[i, :] = [fens.xyz[i, 1], y * cos(a) - z * sin(a), y * sin(a) + z * cos(a)]
end
# Clamped end of the beam
l1 =
selectnode(fens; box = [0 0 -100 * W 100 * W -100 * W 100 * W], inflate = tolerance)
e1 = FDataDict("node_list" => l1, "component" => 1, "displacement" => 0.0)
e2 = FDataDict("node_list" => l1, "component" => 2, "displacement" => 0.0)
e3 = FDataDict("node_list" => l1, "component" => 3, "displacement" => 0.0)
# Traction on the opposite edge
boundaryfes = meshboundary(fes)
Toplist = selectelem(
fens,
boundaryfes,
box = [L L -100 * W 100 * W -100 * W 100 * W],
inflate = tolerance,
)
el1femm = FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(2, 2)))
flux1 = FDataDict("femm" => el1femm, "traction_vector" => loadv)
# Make the region
MR = DeforModelRed3D
material = MatDeforElastOrtho(MR, E, nu)
region1 = FDataDict(
"femm" => FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material),
)
# Make model data
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [e1, e2, e3],
"traction_bcs" => [flux1],
)
# Call the solver
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
geom = modeldata["geom"]
u = modeldata["u"]
# Extract the solution
nl =
selectnode(fens, box = [L L -100 * W 100 * W -100 * W 100 * W], inflate = tolerance)
theutip = mean(u.values[nl, :], dims = 1)
# println("displacement = $(theutip[dir]) as compared to converged $uex")
# println("normalized displacement = $(theutip[dir]/uex*100) %")
@test abs(theutip[dir] / uex * 100 - 99.85504856450584) < 1.0e-6
# Write out mesh with displacements
modeldata["postprocessing"] = FDataDict("file" => "twisted_beam")
modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
# Write out mesh with stresses
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam", "quantity" => :Cauchy, "component" => :xy)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
# Write out mesh with stresses
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam", "quantity" => :Cauchy, "component" => :xz)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
# Write out mesh with von Mises stresses
modeldata["postprocessing"] = FDataDict("file" => "twisted_beam", "quantity" => :vm)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
# Write out mesh with von Mises stresses, elementwise
modeldata["postprocessing"] = FDataDict("file" => "twisted_beam-ew", "quantity" => :vm)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
vm = modeldata["postprocessing"]["exported"][1]["field"]
# println("extremes of von Mises: $([minimum(vm.values), maximum(vm.values)])")
@test norm([minimum(vm.values), maximum(vm.values)] - [6.94796, 451.904]) < 1.e-3
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
# Write out mesh with von Mises stresses, elementwise
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam-ew", "quantity" => :Cauchy, "component" => :xz)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
# Write out mesh with principal stresses, elementwise
modeldata["postprocessing"] = FDataDict(
"file" => "twisted_beam-principal-1-ew",
"quantity" => :princCauchy,
"component" => 1,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
ps = modeldata["postprocessing"]["exported"][1]["field"]
# println("extremes of first principal stress: $([minimum(ps.values), maximum(ps.values)])")
@test norm([minimum(ps.values), maximum(ps.values)] - [0.493918, 459.106]) < 1.e-3
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
# Write out mesh with principal stresses, elementwise
modeldata["postprocessing"] = FDataDict(
"file" => "twisted_beam-principal-3-ew",
"quantity" => :princCauchy,
"component" => 3,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
ps = modeldata["postprocessing"]["exported"][1]["field"]
# println("extremes of third principal stress: $([minimum(ps.values), maximum(ps.values)])")
@test norm([minimum(ps.values), maximum(ps.values)] - [-459.106, -0.493918]) < 1.e-3
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
# Write out mesh with pressure, elementwise
modeldata["postprocessing"] = FDataDict(
"file" => "twisted_beam-press-ew",
"quantity" => :pressure,
"component" => 1,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
ps = modeldata["postprocessing"]["exported"][1]["field"]
# println("extremes of pressure: $([minimum(ps.values), maximum(ps.values)])")
@test norm([minimum(ps.values), maximum(ps.values)] - [-160.396, 160.396]) < 1.e-3
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
end
end
using .mmtwistedbeamoorthomm
mmtwistedbeamoorthomm.test()
module muunit_cube_modes_exportmmm
using FinEtools
using FinEtoolsDeforLinear
using FinEtools.MeshExportModule
using Test
import Arpack: eigs
import LinearAlgebra: norm, cholesky, cross
function test()
# println("""
# Vibration modes of unit cube of almost incompressible material.
#
# This example EXPORTS the model to Abaqus.
#
# Reference: Puso MA, Solberg J (2006) A stabilized nodally integrated
# tetrahedral. International Journal for Numerical Methods in
# Engineering 67: 841-867.
# """)
t0 = time()
E = 1 * phun("PA")
nu = 0.499
rho = 1 * phun("KG/M^3")
a = 1 * phun("M")
b = a
h = a
n1 = 5# How many element edges per side?
na = n1
nb = n1
nh = n1
neigvs = 20 # how many eigenvalues
OmegaShift = (0.01 * 2 * pi)^2
MR = DeforModelRed3D
fens, fes = H20block(a, b, h, na, nb, nh)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
K = stiffness(femm, geom, u)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 3)), material)
M = mass(femm, geom, u)
d, v, nev, nconv =
eigs(K + OmegaShift * M, M; nev = neigvs, which = :SM, explicittransform = :none)
d = broadcast(-, d, OmegaShift)
fs = real(sqrt.(complex(d))) / (2 * pi)
# println("Eigenvalues: $fs [Hz]")
@test norm(
fs - [
2.73674e-7,
3.00469e-7,
3.14245e-7,
3.19946e-7,
3.42634e-7,
3.56347e-7,
0.262723,
0.262723,
0.357791,
0.357791,
0.357791,
0.36088,
0.36088,
0.36088,
0.408199,
0.408397,
0.408397,
0.461756,
0.461756,
0.461756,
],
) < 1.0e-3
mode = 7
scattersysvec!(u, v[:, mode])
File = "unit_cube_modes.vtk"
vtkexportmesh(File, fens, fes; vectors = [("mode$mode", u.values)])
# @async run(`"paraview.exe" $File`)
try
rm(File)
catch
end
AE = AbaqusExporter("unit_cube_modes_h20")
# AE.ios = STDOUT;
HEADING(AE, "Vibration modes of unit cube of almost incompressible material.")
COMMENT(AE, "The first six frequencies are rigid body modes.")
COMMENT(AE, "The first nonzero frequency (7) should be around 0.26 Hz")
PART(AE, "part1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
COMMENT(AE, "The hybrid form of the serendipity hexahedron is chosen because")
COMMENT(AE, "the material is nearly incompressible.")
ELEMENT(AE, "c3d20rh", "AllElements", 1, connasarray(fes))
ORIENTATION(AE, "GlobalOrientation", vec([1.0 0 0]), vec([0 1.0 0]))
SOLID_SECTION(AE, "elasticity", "GlobalOrientation", "AllElements")
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "elasticity")
ELASTIC(AE, E, nu)
DENSITY(AE, rho)
STEP_FREQUENCY(AE, neigvs)
END_STEP(AE)
close(AE)
nlines = 0
open("unit_cube_modes_h20.inp") do f
s = readlines(f)
nlines = length(s)
end
@test nlines == 1409
rm("unit_cube_modes_h20.inp")
end
end
using .muunit_cube_modes_exportmmm
muunit_cube_modes_exportmmm.test()
module mmpipemmPSmorthom
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!
using FinEtoolsDeforLinear
using Test
using LinearAlgebra: norm, cholesky, cross, dot
using Statistics: mean
mutable struct MyIData
c::Int
r::Vector{Float64}
s::Vector{Float64}
end
function test()
## Thick pipe with internal pressure: plane strain
#
##
# Link to the <matlab:edit('pub_thick_pipe_ps') m-file>.
## Description
##
# This is a simple modification of the full three-dimensional simulation of
# the tutorial pub_thick_pipe takes advantage of the plane-strain model
# reduction procedure.
##
# An infinitely long thick walled cylindrical pipe
# with inner boundary radius of 3 mm and outer boundary radius of 9 mm is
# subjected to an internal pressure of 1.0 MPa. A wedge with thickness of
# 2 mm and a 90-degree angle sector is considered for the finite element
# analysis. The material properties are taken as isotropic linear elastic
# with $E=1000$ MPa and $\nu=0.4999$ to represent nearly incompressible
# behavior. This problem has been proposed to by MacNeal and Harder as a
# test of an element's ability to represent the response of a nearly
# incompressible material. The plane-strain condition is assumed in the
# axial direction of the pipe which together with the radial symmetry
# confines the material in all but the radial direction and therefore
# amplifies the numerical difficulties associated with the confinement of
# the nearly incompressible material.
##
# There is an analytical solution to this problem. Timoshenko and Goodier
# presented the original solution of Lame in their textbook. We are going
# to compare with both the stress distribution (radial and hoop stresses)
# and the displacement of the inner cylindrical surface.
##
#
# <html>
# <table border=0><tr><td>
# <img src="../docs/pub_thick_pipe_ps.png" width = "30#">
# </td></tr>
# <tr><td>Figure 1. Definition of the geometry of the internally pressurized thick pipe</td></tr>
# </table>
# </html>
##
# References:
#
# # Macneal RH, Harder RL (1985) A proposed standard set of problems to test
# finite element accuracy. Finite Elements in Analysis and Design 1: 3-20.
#
# # Timoshenko S. and Goodier J. N., Theory of Elasticity, McGraw-Hill, 2nd ed., 1951.
## Solution
#
##
# Internal radius of the pipe.
a = 3 * phun("MM")
##
# External radius of the pipe.
b = 9 * phun("MM")
##
# Thickness of the slice.
t = 2 * phun("MM")
##
# Geometrical tolerance.
tolerance = a / 10000.0
##
# Young's modulus and Poisson's ratio.
E = 1000 * phun("MEGA*PA")
nu = 0.499
##
# Applied pressure on the internal surface.
press = 1.0 * phun("MEGA*PA")
##
# Analytical solutions. Radial stress:
radial_stress(r) = press * a .^ 2 / (b^2 - a^2) .* (1 - (b^2) ./ r .^ 2)
##
# Circumferential (hoop) stress:
hoop_stress(r) = press * a .^ 2 / (b^2 - a^2) .* (1 + (b^2) ./ r .^ 2)
##
# Radial displacement:
radial_displacement(r) =
press * a^2 * (1 + nu) * (b^2 + r .^ 2 * (1 - 2 * nu)) / (E * (b^2 - a^2) .* r)
##
# Therefore the radial displacement of the loaded surface will be:
urex = radial_displacement(a)
##
# The mesh parameters: The numbers of element edges axially,
# and through the thickness of the pipe wall (radially).
nc = 3
nt = 3
##
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the axial symmetry
# assumption.
MR = DeforModelRed2DStrain
# Create the mesh and initialize the geometry. First we are going
# to construct the block of elements with the first coordinate
# corresponding to the angle, and the second
# coordinate is the thickness in the radial direction.
anglrrange = 90.0 / 180 * pi
fens, fes = Q8block(anglrrange, b - a, nc, nt)
# Extract the boundary and mark the finite elements on the
# interior surface.
bdryfes = meshboundary(fes)
bcl = selectelem(fens, bdryfes, box = [-Inf, Inf, 0.0, 0.0], inflate = tolerance)
internal_fenids = connectednodes(subset(bdryfes, bcl))
# Now shape the block into the actual wedge piece of the pipe.
ayr = fens.xyz
for i = 1:count(fens)
angl = ayr[i, 1]
r = a + ayr[i, 2]
fens.xyz[i, :] = [r * sin(angl), (r * cos(angl))]
end
# now we create the geometry and displacement fields
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
# The symmetry boundary condition is specified by selecting nodes
# on the plane x=0.
l1 = selectnode(fens; box = [0.0 0.0 -Inf Inf], inflate = tolerance)
setebc!(u, l1, true, 1, 0.0)
# The second symmetry boundary condition is specified by selecting
# nodes on the plane y=0.
l1 = selectnode(fens; box = [-Inf Inf 0.0 0.0], inflate = tolerance)
setebc!(u, l1, true, 2, 0.0)
applyebc!(u)
numberdofs!(u)
# The traction boundary condition is applied in the radial
# direction.
el1femm = FEMMBase(IntegDomain(subset(bdryfes, bcl), GaussRule(1, 3)))
function pressureloading!(
forceout::Vector{Float64},
XYZ::Matrix{Float64},
tangents::Matrix{Float64},
feid::Int,
qpid::Int,
)
copyto!(forceout, XYZ / norm(XYZ) * press)
return forceout
end
fi = ForceIntensity(Float64, 2, pressureloading!) # pressure normal to the internal cylindrical surface
F2 = distribloads(el1femm, geom, u, fi, 2)
# Property and material
material = MatDeforElastOrtho(MR, E, nu)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 2)), material)
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K, F2)
# Transfer the solution of the displacement to the nodes on the
# internal cylindrical surface and convert to
# cylindrical-coordinate displacements there.
uv = u.values[internal_fenids, :]
ur = zeros(Float64, length(internal_fenids))
for j in eachindex(internal_fenids)
n = fens.xyz[internal_fenids[j], :]
n = n' / norm(n)# normal to the cylindrical internal surface
ur[j] = dot(vec(uv[j, :]), vec(n))
end
# Report the relative displacement on the internal surface:
# println("(Approximate/true displacement) at the internal surface: $( mean(ur)/urex*100 ) %")
@test abs(mean(ur) / urex * 100 - 100) < 0.1
# Produce a plot of the radial stress component in the cylindrical
# coordinate system. Note that this is the usual representation of
# stress using nodal stress field.
fld = fieldfromintegpoints(femm, geom, u, :Cauchy, 1)
File = "thick_pipe_sigmax.vtk"
vtkexportmesh(File, fens, fes; scalars = [("sigmax", fld.values)])
try
rm(File)
catch
end
# Produce a plot of the solution components in the cylindrical
# coordinate system.
# Plot the analytical solution.
function inspector(idat::MyIData, elnum, conn, xe, out, xq)
function outputRm(c)
theNormal = c
r = norm(theNormal)# distance from the axis of symmetry
theNormal = theNormal / r# compute the unit normal vector
e1p = [theNormal'; 0.0]# local cylind. coordinate basis vectors
e3p = [0.0, 0.0, 1.0]'# this one points along the axis of the cylinder
e2p = cross(vec(e3p), vec(e1p))# this one is along the hoop direction
R = [vec(e1p) vec(e2p) vec(e3p)]# transformation matrix for the stress
return R
end
Rm = outputRm(xq)
tm = zeros(Float64, 3, 3)
stressvtot!(MR, tm, out)# stress in global XYZ
tpm = Rm' * tm * Rm# stress matrix in cylindrical coordinates
sp = zeros(Float64, 6)
stressttov!(MR, sp, tpm)# stress vector in cylindr. coord.
push!(idat.r, norm(xq))
push!(idat.s, sp[idat.c])
return idat
end
idat = MyIData(1, Vector{Float64}[], Vector{Float64}[])
idat =
inspectintegpoints(femm, geom, u, collect(1:count(fes)), inspector, idat, :Cauchy)
# show(idat)
@test norm(
idat.s - [
-7.44858e5,
-3.55143e5,
-7.44858e5,
-3.55143e5,
-2.19961e5,
-1.08612e5,
-2.19961e5,
-1.08612e5,
-58910.9,
-12517.6,
-58910.9,
-12517.6,
-7.44858e5,
-3.55143e5,
-7.44858e5,
-3.55143e5,
-2.19961e5,
-1.08612e5,
-2.19961e5,
-1.08612e5,
-58910.9,
-12517.6,
-58910.9,
-12517.6,
-7.44858e5,
-3.55143e5,
-7.44858e5,
-3.55143e5,
-2.19961e5,
-1.08612e5,
-2.19961e5,
-1.08612e5,
-58910.9,
-12517.6,
-58910.9,
-12517.6,
],
) / 1.0e5 < 1.e-3
# using Plots
# plotly()
#
# # Plot the analytical solution.
# r = linearspace(a,b,100);
# plot(r, radial_stress(r))
# # Plot the computed integration-point data
# scatter!(idat.r, idat.s, m=:circle, color=:red)
# gui()
end
end
using .mmpipemmPSmorthom
mmpipemmPSmorthom.test()
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 44863 |
module scratch1_06092017_ortho
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!
using FinEtoolsDeforLinear
using Test
mutable struct MyIData
c::Int
r::Vector{Float64}
s::Vector{Float64}
end
function test()
# println("Thick pipe with internal pressure: axially symmetric model")
#=
This is a simple modification of the full three-dimensional simulation of
the tutorial pub_thick_pipe that implements the axially-symmetric model
reduction procedure.
An infinitely long thick walled cylindrical pipe
with inner boundary radius of 3 mm and outer boundary radius of 9 mm is
subjected to an internal pressure of 1.0 MPa. A wedge with thickness of
2 mm and a 90-degree angle sector is considered for the finite element
analysis. The material properties are taken as isotropic linear elastic
with $E=1000$ MPa and $\nu=0.4999$ to represent nearly incompressible
behavior. This problem has been proposed to by MacNeal and Harder as a
test of an element's ability to represent the response of a nearly
incompressible material. The plane-strain condition is assumed in the
axial direction of the pipe which together with the radial symmetry
confines the material in all but the radial direction and therefore
amplifies the numerical difficulties associated with the confinement of
the nearly incompressible material.
There is an analytical solution to this problem. Timoshenko and Goodier
presented the original solution of Lame in their textbook. We are going
to compare with both the stress distribution (radial and hoop stresses)
and the displacement of the inner cylindrical surface.
References:
- Macneal RH, Harder RL (1985) A proposed standard set of problems to test
finite element accuracy. Finite Elements in Analysis and Design 1: 3-20.
- Timoshenko S. and Goodier J. N., Theory of Elasticity, McGraw-Hill, 2nd ed., 1951.
=#
# Internal radius of the pipe.
a = 3 * phun("MM")
##
# External radius of the pipe.
b = 9 * phun("MM")
##
# Thickness of the slice.
t = 2 * phun("MM")
##
# Geometrical tolerance.
tolerance = a / 10000.0
##
# Young's modulus and Poisson's ratio.
E = 1000 * phun("MEGA*PA")
nu = 0.499
##
# Applied pressure on the internal surface.
press = 1.0 * phun("MEGA*PA")
##
# Analytical solutions. Radial stress:
radial_stress(r) = press * a .^ 2 / (b^2 - a^2) .* (1 - (b^2) ./ r .^ 2)
##
# Circumferential (hoop) stress:
hoop_stress(r) = press * a .^ 2 / (b^2 - a^2) .* (1 + (b^2) ./ r .^ 2)
##
# Radial displacement:
radial_displacement(r) =
press * a^2 * (1 + nu) * (b^2 + r .^ 2 * (1 - 2 * nu)) / (E * (b^2 - a^2) .* r)
##
# Therefore the radial displacement of the loaded surface will be:
urex = radial_displacement(a)
##
# The mesh parameters: The numbers of element edges axially,
# and through the thickness of the pipe wall (radially).
na = 1
nt = 10
##
# Note that the material object needs to be created with the proper
# model-dimension reduction in effect. In this case that is the axial symmetry
# assumption.
MR = DeforModelRed2DAxisymm
axisymmetric = true
# Create the mesh and initialize the geometry. First we are going
# to construct the block of elements with the first coordinate
# corresponding to the thickness in the radial direction, and the second
# coordinate is the thickness in the axial direction.
fens, fes = Q8block(b - a, t, nt, na)
# Extract the boundary and mark the finite elements on the
# interior surface.
bdryfes = meshboundary(fes)
bcl = selectelem(fens, bdryfes, box = [0.0, 0.0, -Inf, Inf], inflate = tolerance)
internal_fenids = connectednodes(subset(bdryfes, bcl))
# Now shape the block into the actual wedge piece of the pipe.
for i = 1:count(fens)
fens.xyz[i, :] = fens.xyz[i, :] + [a; 0.0]
end
# now we create the geometry and displacement fields
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
# The plane-strain condition in the axial direction is specified by selecting nodes
# on the plane y=0 and y=t.
l1 = selectnode(fens; box = [-Inf Inf 0.0 0.0], inflate = tolerance)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(fens; box = [-Inf Inf t t], inflate = tolerance)
setebc!(u, l1, true, 2, 0.0)
applyebc!(u)
numberdofs!(u)
# The traction boundary condition is applied in the radial
# direction.
el1femm = FEMMBase(IntegDomain(subset(bdryfes, bcl), GaussRule(1, 3), axisymmetric))
fi = ForceIntensity([press; 0.0])
F2 = distribloads(el1femm, geom, u, fi, 2)
# Property and material
material = MatDeforElastOrtho(MR, E, nu)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 2), axisymmetric), material)
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K, F2)
# Transfer the solution of the displacement to the nodes on the
# internal cylindrical surface and convert to
# cylindrical-coordinate displacements there.
uv = u.values[internal_fenids, :]
# Report the relative displacement on the internal surface:
# println("(Approximate/true displacement) at the internal surface: $( mean(uv[:,1])/urex*100 ) %")
# Produce a plot of the radial stress component in the cylindrical
# coordinate system. Note that this is the usual representation of
# stress using nodal stress field.
fld = fieldfromintegpoints(femm, geom, u, :Cauchy, 1)
# File = "thick_pipe_sigmax.vtk"
# vtkexportmesh(File, fens, fes; scalars=[("sigmax", fld.values)])
# Produce a plot of the solution components in the cylindrical
# coordinate system.
function inspector(idat::MyIData, elnum, conn, xe, out, xq)
push!(idat.r, xq[1])
push!(idat.s, out[idat.c])
return idat
end
idat = MyIData(1, Int[], Int[])
idat =
inspectintegpoints(femm, geom, u, collect(1:count(fes)), inspector, idat, :Cauchy)
# using Plots
# plotly()
#
# # Plot the analytical solution.
# r = linearspace(a,b,100);
# plot(r, radial_stress(r))
# # Plot the computed integration-point data
# plot!(idat.r, idat.s, m=:circle, color=:red)
# gui()
@test abs(idat.r[1] - 0.003126794919243112) < 1.0e-9
@test abs(idat.s[1] - -910911.9777008593) < 1.0e-2
## Discussion
#
##
# The axially symmetric model is clearly very effective
# computationally, as the size is much reduced compared to the 3-D
# model. In conjunction with uniform or selective reduced integration
# it can be very accurate as well.
end
end
using .scratch1_06092017_ortho
scratch1_06092017_ortho.test()
module mmLE11Q8mm
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!
using FinEtoolsDeforLinear
using Test
import LinearAlgebra: norm, cholesky, cross
function test()
# NAFEMS LE11 benchmark with Q8 elements.
# # This is a test recommended by the National Agency for Finite Element
# # Methods and Standards (U.K.): Test LE11 from NAFEMS Publication TNSB,
# # Rev. 3, “The Standard NAFEMS Benchmarks,” October 1990.
# #
# # Target solution: Direct stress, = –105 MPa at point A.
#function LE11NAFEMS()
# Parameters:
Ea = 210000 * phun("MEGA*Pa")
nua = 0.3
alphaa = 2.3e-4 # thermal expansion coefficient
sigmaA = -105 * phun("MEGA*Pa")
nref = 1 # how many times should we refine the mesh?
X =
[
1.0 0.0#A
1.4 0.0#B
0.995184726672197 0.098017140329561
1.393258617341076 0.137223996461385
0.980785 0.195090#
1.37309939 0.27312645
0.956940335732209 0.290284677254462
1.339716470025092 0.406398548156247
0.9238795 0.38268#C
1.2124 0.7#D
0.7071 0.7071#E
1.1062 1.045#F
0.7071 (0.7071+1.79)/2#(E+H)/2
1.0 1.39#G
0.7071 1.79#H
1.0 1.79#I
] * phun("M")
tolerance = 1.e-6 * phun("M")
##
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the axial symmetry
# assumption.
MR = DeforModelRed2DAxisymm
fens = FENodeSet(X)
fes =
FESetQ4([1 2 4 3; 3 4 6 5; 5 6 8 7; 7 8 10 9; 9 10 12 11; 11 12 14 13; 13 14 16 15])
for ref = 1:nref
fens, fes = Q4refine(fens, fes)
list = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = [0.0 0.0],
inflate = tolerance,
)
fens.xyz[list, :] = FinEtools.MeshUtilModule.ontosphere(fens.xyz[list, :], 1.0)
end
fens, fes = Q4toQ8(fens, fes)
list = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = [0.0 0.0],
inflate = tolerance,
)
fens.xyz[list, :] = FinEtools.MeshUtilModule.ontosphere(fens.xyz[list, :], 1.0)
# File = "mesh.vtk"
# vtkexportmesh(File, fens, fes)
# now we create the geometry and displacement fields
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
# Apply EBC's
l1 = selectnode(fens, box = [-Inf Inf 0 0], inflate = tolerance)
setebc!(u, l1, true, 2, 00.0)
l1 = selectnode(fens, box = [-Inf Inf 1.79 1.79], inflate = tolerance)
setebc!(u, l1, true, 2, 00.0)
applyebc!(u)
numberdofs!(u)
# Temperature field
dT = NodalField(reshape(fens.xyz[:, 1] + fens.xyz[:, 2], size(fens.xyz, 1), 1))
# Property and material
material = MatDeforElastIso(MR, 0.0, Ea, nua, alphaa)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 3), true), material)
K = stiffness(femm, geom, u)
F = thermalstrainloads(femm, geom, u, dT)
u = solve_blocked!(u, K, F)
nA = selectnode(fens, box = Float64[1.0 1.0 0.0 0.0], inflate = tolerance)
fld = fieldfromintegpoints(femm, geom, u, dT, :Cauchy, 2)
File = "LE11NAFEMS_Q8_sigmay.vtk"
vtkexportmesh(
File,
fens,
fes;
scalars = [("sigmay", fld.values)],
vectors = [("u", u.values)],
)
# println("range of sigmay = $((minimum(fld.values), maximum(fld.values)))")
@test norm(
[minimum(fld.values), maximum(fld.values)] -
[-1.443052182185006e8, -1.4106181545272605e7],
) < 1.0e-2
# @async run(`"paraview.exe" $File`)
try
rm(File)
catch
end
sA = fld.values[nA] / phun("MEGA*Pa")
sAn = fld.values[nA] / sigmaA
# println("Stress at point A: $(sA) i. e. $( sAn*100 )% of reference value")
@test abs(sA[1] - (-93.8569)) < 1.0e-3
fen2fe = FENodeToFEMap(fes, nnodes(geom))
function inspector(idat, elnum, conn, xe, out, xq)
println("loc = $( xq ) : $( transpose(out)/phun("MEGA*Pa") )")
return idat
end
# inspectintegpoints(femm, geom, u, dT, fen2fe.map[nA[1]],
# inspector, []; quantity = :Cauchy)
end
end
using .mmLE11Q8mm
mmLE11Q8mm.test()
module mmLE11Q8mmortho
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!
using FinEtoolsDeforLinear
using Test
import LinearAlgebra: norm, cholesky, cross
function test()
# NAFEMS LE11 benchmark with Q8 elements.
# # This is a test recommended by the National Agency for Finite Element
# # Methods and Standards (U.K.): Test LE11 from NAFEMS Publication TNSB,
# # Rev. 3, “The Standard NAFEMS Benchmarks,” October 1990.
# #
# # Target solution: Direct stress, = –105 MPa at point A.
#function LE11NAFEMS()
# Parameters:
Ea = 210000 * phun("MEGA*Pa")
nua = 0.3
alphaa = 2.3e-4 # thermal expansion coefficient
sigmaA = -105 * phun("MEGA*Pa")
nref = 1 # how many times should we refine the mesh?
X =
[
1.0 0.0#A
1.4 0.0#B
0.995184726672197 0.098017140329561
1.393258617341076 0.137223996461385
0.980785 0.195090#
1.37309939 0.27312645
0.956940335732209 0.290284677254462
1.339716470025092 0.406398548156247
0.9238795 0.38268#C
1.2124 0.7#D
0.7071 0.7071#E
1.1062 1.045#F
0.7071 (0.7071+1.79)/2#(E+H)/2
1.0 1.39#G
0.7071 1.79#H
1.0 1.79#I
] * phun("M")
tolerance = 1.e-6 * phun("M")
##
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the axial symmetry
# assumption.
MR = DeforModelRed2DAxisymm
fens = FENodeSet(X)
fes =
FESetQ4([1 2 4 3; 3 4 6 5; 5 6 8 7; 7 8 10 9; 9 10 12 11; 11 12 14 13; 13 14 16 15])
for ref = 1:nref
fens, fes = Q4refine(fens, fes)
list = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = [0.0 0.0],
inflate = tolerance,
)
fens.xyz[list, :] = FinEtools.MeshUtilModule.ontosphere(fens.xyz[list, :], 1.0)
end
fens, fes = Q4toQ8(fens, fes)
list = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = [0.0 0.0],
inflate = tolerance,
)
fens.xyz[list, :] = FinEtools.MeshUtilModule.ontosphere(fens.xyz[list, :], 1.0)
# File = "mesh.vtk"
# vtkexportmesh(File, fens, fes)
# now we create the geometry and displacement fields
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
# Apply EBC's
l1 = selectnode(fens, box = [-Inf Inf 0 0], inflate = tolerance)
setebc!(u, l1, true, 2, 00.0)
l1 = selectnode(fens, box = [-Inf Inf 1.79 1.79], inflate = tolerance)
setebc!(u, l1, true, 2, 00.0)
applyebc!(u)
numberdofs!(u)
# Temperature field
dT = NodalField(reshape(fens.xyz[:, 1] + fens.xyz[:, 2], size(fens.xyz, 1), 1))
# Property and material
material = MatDeforElastOrtho(MR, 0.0, Ea, nua, alphaa)
# display(material )
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 3), true), material)
K = stiffness(femm, geom, u)
F = thermalstrainloads(femm, geom, u, dT)
u = solve_blocked!(u, K, F)
nA = selectnode(fens, box = Float64[1.0 1.0 0.0 0.0], inflate = tolerance)
fld = fieldfromintegpoints(femm, geom, u, dT, :Cauchy, 2)
File = "LE11NAFEMS_Q8_sigmay.vtk"
vtkexportmesh(
File,
fens,
fes;
scalars = [("sigmay", fld.values)],
vectors = [("u", u.values)],
)
# println("range of sigmay = $((minimum(fld.values), maximum(fld.values)))")
@test norm(
[minimum(fld.values), maximum(fld.values)] -
[-1.443052182185006e8, -1.4106181545272605e7],
) < 1.0e-2
# @async run(`"paraview.exe" $File`)
try
rm(File)
catch
end
sA = fld.values[nA] / phun("MEGA*Pa")
sAn = fld.values[nA] / sigmaA
# println("Stress at point A: $(sA) i. e. $( sAn*100 )% of reference value")
@test abs(sA[1] - (-93.8569)) < 1.0e-3
fen2fe = FENodeToFEMap(fes, nnodes(geom))
function inspector(idat, elnum, conn, xe, out, xq)
println("loc = $( xq ) : $( transpose(out)/phun("MEGA*Pa") )")
return idat
end
# inspectintegpoints(femm, geom, u, dT, fen2fe.map[nA[1]],
# inspector, []; quantity = :Cauchy)
end
end
using .mmLE11Q8mmortho
mmLE11Q8mmortho.test()
module mLE11Q8aximmm
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!
using FinEtoolsDeforLinear
using Test
import LinearAlgebra: norm, cholesky, cross
function test()
# NAFEMS LE11 benchmark with Q8 elements.
# # This is a test recommended by the National Agency for Finite Element
# # Methods and Standards (U.K.): Test LE11 from NAFEMS Publication TNSB,
# # Rev. 3, “The Standard NAFEMS Benchmarks,” October 1990.
# #
# # Target solution: Direct stress, = –105 MPa at point A.
#function LE11NAFEMS()
# Parameters:
Ea = 210000 * phun("MEGA*Pa")
nua = 0.3
alphaa = 2.3e-4 # thermal expansion coefficient
sigmaA = -105 * phun("MEGA*Pa")
nref = 2 # how many times should we refine the mesh?
X =
[
1.0 0.0#A
1.4 0.0#B
0.995184726672197 0.098017140329561
1.393258617341076 0.137223996461385
0.980785 0.195090#
1.37309939 0.27312645
0.956940335732209 0.290284677254462
1.339716470025092 0.406398548156247
0.9238795 0.38268#C
1.2124 0.7#D
0.7071 0.7071#E
1.1062 1.045#F
0.7071 (0.7071+1.79)/2#(E+H)/2
1.0 1.39#G
0.7071 1.79#H
1.0 1.79#I
] * phun("M")
tolerance = 1.e-6 * phun("M")
##
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the axial symmetry
# assumption.
MR = DeforModelRed2DAxisymm
fens = FENodeSet(X)
fes =
FESetQ4([1 2 4 3; 3 4 6 5; 5 6 8 7; 7 8 10 9; 9 10 12 11; 11 12 14 13; 13 14 16 15])
for ref = 1:nref
fens, fes = Q4refine(fens, fes)
list = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = [0.0 0.0],
inflate = tolerance,
)
fens.xyz[list, :] = FinEtools.MeshUtilModule.ontosphere(fens.xyz[list, :], 1.0)
end
fens, fes = Q4toQ8(fens, fes)
list = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = [0.0 0.0],
inflate = tolerance,
)
fens.xyz[list, :] = FinEtools.MeshUtilModule.ontosphere(fens.xyz[list, :], 1.0)
# File = "mesh.vtk"
# vtkexportmesh(File, fens, fes)
# now we create the geometry and displacement fields
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
# Apply EBC's
lbottom = selectnode(fens, box = [-Inf Inf 0 0], inflate = tolerance)
setebc!(u, lbottom, true, 2, 00.0)
ltop = selectnode(fens, box = [-Inf Inf 1.79 1.79], inflate = tolerance)
setebc!(u, ltop, true, 2, 00.0)
applyebc!(u)
numberdofs!(u)
# Temperature field
dT = NodalField(reshape(fens.xyz[:, 1] + fens.xyz[:, 2], size(fens.xyz, 1), 1))
# Property and material
material = MatDeforElastIso(MR, 0.0, Ea, nua, alphaa)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 3), true), material)
K = stiffness(femm, geom, u)
F = thermalstrainloads(femm, geom, u, dT)
u = solve_blocked!(u, K, F)
nA = selectnode(fens, box = Float64[1.0 1.0 0.0 0.0], inflate = tolerance)
fld = fieldfromintegpoints(femm, geom, u, dT, :Cauchy, 2)
File = "LE11NAFEMS_Q8_sigmay.vtk"
vtkexportmesh(
File,
fens,
fes;
scalars = [("sigmay", fld.values)],
vectors = [("u", u.values)],
)
# println("range of sigmay = $((minimum(fld.values), maximum(fld.values)))")
@test norm(
[minimum(fld.values), maximum(fld.values)] -
[-1.6338426447540134e8, -4.961956343464769e6],
) < 1.e-1
# @async run(`"paraview.exe" $File`)
try
rm(File)
catch
end
sA = fld.values[nA] / phun("MEGA*Pa")
sAn = fld.values[nA] / sigmaA
# println("Stress at point A: $(sA) i. e. $( sAn*100 )% of reference value")
fen2fe = FENodeToFEMap(fes, nnodes(geom))
function inspector(idat, elnum, conn, xe, out, xq)
# println("loc = $( xq ) : $( transpose(out)/phun("MEGA*Pa") )")
return idat
end
inspectintegpoints(
femm,
geom,
u,
dT,
fen2fe.map[nA[1]],
inspector,
[];
quantity = :Cauchy,
)
fld = fieldfromintegpoints(femm, geom, u, dT, :Pressure, 1)
File = "LE11NAFEMS_Q8_pressure.vtk"
vtkexportmesh(
File,
fens,
fes;
scalars = [("pressure", fld.values)],
vectors = [("u", u.values)],
)
# println("range of pressure = $((minimum(fld.values), maximum(fld.values)))")
@test norm(
[minimum(fld.values), maximum(fld.values)] -
[-1.1881819144904878e7, 7.555030948761216e7],
) < 1.e-1
# @async run(`"paraview.exe" $File`)
try
rm(File)
catch
end
fld = fieldfromintegpoints(femm, geom, u, dT, :vm, 1)
File = "LE11NAFEMS_Q8_vm.vtk"
vtkexportmesh(
File,
fens,
fes;
scalars = [("pressure", fld.values)],
vectors = [("u", u.values)],
)
# println("range of von Mises = $((minimum(fld.values), maximum(fld.values)))")
@test norm(
[minimum(fld.values), maximum(fld.values)] -
[3.221370699152578e7, 1.4437590830351183e8],
) < 1.e-1
# @async run(`"paraview.exe" $File`)
try
rm(File)
catch
end
AE = AbaqusExporter("LE11NAFEMS_Q8_export_stress")
HEADING(AE, "NAFEMS LE11 benchmark with Q8 elements.")
COMMENT(AE, "sigmaA = -105 MPa ")
PART(AE, "part1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
ELEMENT(AE, "cax8", "AllElements", 1, connasarray(fes))
NSET_NSET(AE, "ltop", ltop)
NSET_NSET(AE, "lbottom", lbottom)
ORIENTATION(AE, "GlobalOrientation", vec([1.0 0 0]), vec([0 1.0 0]))
SOLID_SECTION(AE, "elasticity", "GlobalOrientation", "AllElements")
SURFACE_SECTION(AE, "TractionElements")
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "elasticity")
ELASTIC(AE, Ea, nua)
EXPANSION(AE, alphaa)
STEP_PERTURBATION_STATIC(AE)
BOUNDARY(AE, "ASSEM1.INSTNC1.ltop", 2)
BOUNDARY(AE, "ASSEM1.INSTNC1.lbottom", 2)
TEMPERATURE(AE, "ASSEM1.INSTNC1.", collect(1:count(fens)), vec(dT.values))
END_STEP(AE)
close(AE)
nlines = 0
open(AE.filename) do f
s = readlines(f)
nlines = length(s)
end
@test nlines == 963
try
rm(AE.filename)
catch
end
end
end
using .mLE11Q8aximmm
mLE11Q8aximmm.test()
module mLE11Q8aximorthom
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!
using FinEtoolsDeforLinear
using Test
import LinearAlgebra: norm, cholesky, cross
function test()
# NAFEMS LE11 benchmark with Q8 elements.
# # This is a test recommended by the National Agency for Finite Element
# # Methods and Standards (U.K.): Test LE11 from NAFEMS Publication TNSB,
# # Rev. 3, “The Standard NAFEMS Benchmarks,” October 1990.
# #
# # Target solution: Direct stress, = –105 MPa at point A.
#function LE11NAFEMS()
# Parameters:
Ea = 210000 * phun("MEGA*Pa")
nua = 0.3
alphaa = 2.3e-4 # thermal expansion coefficient
sigmaA = -105 * phun("MEGA*Pa")
nref = 2 # how many times should we refine the mesh?
X =
[
1.0 0.0#A
1.4 0.0#B
0.995184726672197 0.098017140329561
1.393258617341076 0.137223996461385
0.980785 0.195090#
1.37309939 0.27312645
0.956940335732209 0.290284677254462
1.339716470025092 0.406398548156247
0.9238795 0.38268#C
1.2124 0.7#D
0.7071 0.7071#E
1.1062 1.045#F
0.7071 (0.7071+1.79)/2#(E+H)/2
1.0 1.39#G
0.7071 1.79#H
1.0 1.79#I
] * phun("M")
tolerance = 1.e-6 * phun("M")
##
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the axial symmetry
# assumption.
MR = DeforModelRed2DAxisymm
fens = FENodeSet(X)
fes =
FESetQ4([1 2 4 3; 3 4 6 5; 5 6 8 7; 7 8 10 9; 9 10 12 11; 11 12 14 13; 13 14 16 15])
for ref = 1:nref
fens, fes = Q4refine(fens, fes)
list = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = [0.0 0.0],
inflate = tolerance,
)
fens.xyz[list, :] = FinEtools.MeshUtilModule.ontosphere(fens.xyz[list, :], 1.0)
end
fens, fes = Q4toQ8(fens, fes)
list = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = [0.0 0.0],
inflate = tolerance,
)
fens.xyz[list, :] = FinEtools.MeshUtilModule.ontosphere(fens.xyz[list, :], 1.0)
# File = "mesh.vtk"
# vtkexportmesh(File, fens, fes)
# now we create the geometry and displacement fields
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
# Apply EBC's
lbottom = selectnode(fens, box = [-Inf Inf 0 0], inflate = tolerance)
setebc!(u, lbottom, true, 2, 00.0)
ltop = selectnode(fens, box = [-Inf Inf 1.79 1.79], inflate = tolerance)
setebc!(u, ltop, true, 2, 00.0)
applyebc!(u)
numberdofs!(u)
# Temperature field
dT = NodalField(reshape(fens.xyz[:, 1] + fens.xyz[:, 2], size(fens.xyz, 1), 1))
# Property and material
material = MatDeforElastOrtho(MR, 0.0, Ea, nua, alphaa)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 3), true), material)
K = stiffness(femm, geom, u)
F = thermalstrainloads(femm, geom, u, dT)
u = solve_blocked!(u, K, F)
nA = selectnode(fens, box = Float64[1.0 1.0 0.0 0.0], inflate = tolerance)
fld = fieldfromintegpoints(femm, geom, u, dT, :Cauchy, 2)
File = "LE11NAFEMS_Q8_sigmay.vtk"
vtkexportmesh(
File,
fens,
fes;
scalars = [("sigmay", fld.values)],
vectors = [("u", u.values)],
)
# println("range of sigmay = $((minimum(fld.values), maximum(fld.values)))")
@test norm(
[minimum(fld.values), maximum(fld.values)] -
[-1.6338426447540134e8, -4.961956343464769e6],
) < 1.e-1
# @async run(`"paraview.exe" $File`)
try
rm(File)
catch
end
sA = fld.values[nA] / phun("MEGA*Pa")
sAn = fld.values[nA] / sigmaA
# println("Stress at point A: $(sA) i. e. $( sAn*100 )% of reference value")
fen2fe = FENodeToFEMap(fes, nnodes(geom))
function inspector(idat, elnum, conn, xe, out, xq)
# println("loc = $( xq ) : $( transpose(out)/phun("MEGA*Pa") )")
return idat
end
inspectintegpoints(
femm,
geom,
u,
dT,
fen2fe.map[nA[1]],
inspector,
[];
quantity = :Cauchy,
)
fld = fieldfromintegpoints(femm, geom, u, dT, :Pressure, 1)
File = "LE11NAFEMS_Q8_pressure.vtk"
vtkexportmesh(
File,
fens,
fes;
scalars = [("pressure", fld.values)],
vectors = [("u", u.values)],
)
# println("range of pressure = $((minimum(fld.values), maximum(fld.values)))")
@test norm(
[minimum(fld.values), maximum(fld.values)] -
[-1.1881819144904878e7, 7.555030948761216e7],
) < 1.e-1
# @async run(`"paraview.exe" $File`)
try
rm(File)
catch
end
fld = fieldfromintegpoints(femm, geom, u, dT, :vm, 1)
File = "LE11NAFEMS_Q8_vm.vtk"
vtkexportmesh(
File,
fens,
fes;
scalars = [("pressure", fld.values)],
vectors = [("u", u.values)],
)
# println("range of von Mises = $((minimum(fld.values), maximum(fld.values)))")
@test norm(
[minimum(fld.values), maximum(fld.values)] -
[3.221370699152578e7, 1.4437590830351183e8],
) < 1.e-1
# @async run(`"paraview.exe" $File`)
try
rm(File)
catch
end
AE = AbaqusExporter("LE11NAFEMS_Q8_export_stress")
HEADING(AE, "NAFEMS LE11 benchmark with Q8 elements.")
COMMENT(AE, "sigmaA = -105 MPa ")
PART(AE, "part1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
ELEMENT(AE, "cax8", "AllElements", 1, connasarray(fes))
NSET_NSET(AE, "ltop", ltop)
NSET_NSET(AE, "lbottom", lbottom)
ORIENTATION(AE, "GlobalOrientation", vec([1.0 0 0]), vec([0 1.0 0]))
SOLID_SECTION(AE, "elasticity", "GlobalOrientation", "AllElements")
SURFACE_SECTION(AE, "TractionElements")
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "elasticity")
ELASTIC(AE, Ea, nua)
EXPANSION(AE, alphaa)
STEP_PERTURBATION_STATIC(AE)
BOUNDARY(AE, "ASSEM1.INSTNC1.ltop", 2)
BOUNDARY(AE, "ASSEM1.INSTNC1.lbottom", 2)
TEMPERATURE(AE, "ASSEM1.INSTNC1.", collect(1:count(fens)), vec(dT.values))
END_STEP(AE)
close(AE)
nlines = 0
open(AE.filename) do f
s = readlines(f)
nlines = length(s)
end
@test nlines == 963
try
rm(AE.filename)
catch
end
end
end
using .mLE11Q8aximorthom
mLE11Q8aximorthom.test()
module mmmCookmmstrainmmisommm
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtools.MeshExportModule
using Test
import LinearAlgebra: norm, cholesky, cross
function test()
E = 1.0
nu = 1.0 / 3
width = 48.0
height = 44.0
thickness = 1.0
free_height = 16.0
Mid_edge = [48.0, 52.0]# Location of tracked deflection
magn = 1.0 / (free_height * thickness)# Density of applied load
convutip = 23.97
n = 30# number of elements per side
tolerance = minimum([width, height]) / n / 1000.0#Geometrical tolerance
fens, fes = T3block(width, height, n, n)
# Reshape into a trapezoidal panel
for i = 1:count(fens)
fens.xyz[i, 2] =
fens.xyz[i, 2] +
(fens.xyz[i, 1] / width) *
(height - fens.xyz[i, 2] / height * (height - free_height))
end
# Clamped edge of the membrane
l1 = selectnode(fens; box = [0.0, 0.0, -Inf, Inf], inflate = tolerance)
ess1 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => l1)
ess2 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => l1)
# Traction on the opposite edge
boundaryfes = meshboundary(fes)
Toplist =
selectelem(fens, boundaryfes, box = [width, width, -Inf, Inf], inflate = tolerance)
el1femm =
FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(1, 2), thickness))
flux1 = FDataDict("traction_vector" => [0.0, +magn], "femm" => el1femm)
# Make the region
MR = DeforModelRed2DStrain
material = MatDeforElastIso(MR, 0.0, E, nu, 0.0)
region1 = FDataDict(
"femm" =>
FEMMDeforLinear(MR, IntegDomain(fes, TriRule(1), thickness), material),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [ess1, ess2],
"traction_bcs" => [flux1],
)
# Call the solver
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# Extract the solution
nl = selectnode(
fens,
box = [Mid_edge[1], Mid_edge[1], Mid_edge[2], Mid_edge[2]],
inflate = tolerance,
)
theutip = u.values[nl, :]
# println("displacement =$(theutip[2]) as compared to converged $convutip")
@test abs(theutip[2] - 21.35955642390279) < 1.0e-3
modeldata["postprocessing"] =
FDataDict("file" => "cookstress-ew", "quantity" => :Cauchy, "component" => :xy)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
# println("range of Cauchy_xy = $((minimum(fld.values), maximum(fld.values)))")
@test norm(
[minimum(fld.values), maximum(fld.values)] -
[-0.07028875155067116, 0.1301698279821655],
) < 1.0e-5
# File = modeldata["postprocessing"]["exported"][1]["file"]
# @async run(`"paraview.exe" $File`)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
modeldata["postprocessing"] =
FDataDict("file" => "cookstress-ew-vm", "quantity" => :vm, "component" => 1)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
# println("range of vm = $((minimum(fld.values), maximum(fld.values)))")
@test norm(
[minimum(fld.values), maximum(fld.values)] -
[0.007503804468283987, 0.33798754356331173],
) < 1.0e-5
# File = modeldata["postprocessing"]["exported"][1]["file"]
# @async run(`"paraview.exe" $File`)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
modeldata["postprocessing"] = FDataDict(
"file" => "cookstress-ew-pressure",
"quantity" => :pressure,
"component" => 1,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
# println("range of pressure = $((minimum(fld.values), maximum(fld.values)))")
@test norm(
[minimum(fld.values), maximum(fld.values)] -
[-0.11777749217431245, 0.23457099031101358],
) < 1.0e-5
# File = modeldata["postprocessing"]["exported"][1]["file"]
# @async run(`"paraview.exe" $File`)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
modeldata["postprocessing"] = FDataDict(
"file" => "cookstress-ew-princ1",
"quantity" => :princCauchy,
"component" => 1,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
# println("range of princCauchy Max = $((minimum(fld.values), maximum(fld.values)))")
@test norm(
[minimum(fld.values), maximum(fld.values)] -
[-0.16098150217425994, 0.24838761904231466],
) < 1.0e-5
# File = modeldata["postprocessing"]["exported"][1]["file"]
# @async run(`"paraview.exe" $File`)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
modeldata["postprocessing"] = FDataDict(
"file" => "cookstress-ew-princ3",
"quantity" => :princCauchy,
"component" => 3,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
# println("range of princCauchy Min = $((minimum(fld.values), maximum(fld.values)))")
@test norm(
[minimum(fld.values), maximum(fld.values)] -
[-0.4523049370669106, 0.02980811337406548],
) < 1.0e-5
# File = modeldata["postprocessing"]["exported"][1]["file"]
# @async run(`"paraview.exe" $File`)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
AE = AbaqusExporter("Cookstress_algo_stress")
HEADING(AE, "Cook trapezoidal panel, plane stress")
COMMENT(AE, "Converged free mid-edge displacement = 23.97")
PART(AE, "part1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
COMMENT(AE, "We are assuming three node triangles in plane-stress")
COMMENT(AE, "CPE3 are pretty poor-accuracy elements, but here we don't care about it.")
@test nodesperelem(modeldata["regions"][1]["femm"].integdomain.fes) == 3
ELEMENT(
AE,
"CPE3",
"AllElements",
connasarray(modeldata["regions"][1]["femm"].integdomain.fes),
)
NSET_NSET(AE, "clamped", modeldata["essential_bcs"][1]["node_list"])
ORIENTATION(AE, "GlobalOrientation", vec([1.0 0 0]), vec([0 1.0 0]))
SOLID_SECTION(AE, "elasticity", "GlobalOrientation", "AllElements", thickness)
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "elasticity")
ELASTIC(AE, E, nu)
STEP_PERTURBATION_STATIC(AE)
BOUNDARY(AE, "ASSEM1.INSTNC1.clamped", 1)
BOUNDARY(AE, "ASSEM1.INSTNC1.clamped", 2)
bfes = modeldata["traction_bcs"][1]["femm"].integdomain.fes
COMMENT(AE, "Concentrated loads: we are assuming that the elements on the boundary")
COMMENT(AE, "have two nodes each and also that they are the same length.")
COMMENT(AE, "Then the concentrated loads below will be correctly lumped.")
nl = connectednodes(bfes)
F = zeros(count(modeldata["fens"]))
for ix in eachindex(bfes)
for jx = 1:2
F[bfes.conn[ix][jx]] += 1.0 / n / 2 / thickness
end
end
for ixxxx in eachindex(F)
if F[ixxxx] != 0.0
CLOAD(AE, "ASSEM1.INSTNC1.$(ixxxx)", 2, F[ixxxx])
end
end
END_STEP(AE)
close(AE)
nlines = 0
open(AE.filename) do f
s = readlines(f)
nlines = length(s)
end
@test nlines == 2886
rm(AE.filename)
end
end
using .mmmCookmmstrainmmisommm
mmmCookmmstrainmmisommm.test()
module mmmCookmmstrainmorthommm
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtools.MeshExportModule
using Test
import LinearAlgebra: norm, cholesky, cross
function test()
E = 1.0
nu = 1.0 / 3
width = 48.0
height = 44.0
thickness = 1.0
free_height = 16.0
Mid_edge = [48.0, 52.0]# Location of tracked deflection
magn = 1.0 / (free_height * thickness)# Density of applied load
convutip = 23.97
n = 30# number of elements per side
tolerance = minimum([width, height]) / n / 1000.0#Geometrical tolerance
fens, fes = T3block(width, height, n, n)
# Reshape into a trapezoidal panel
for i = 1:count(fens)
fens.xyz[i, 2] =
fens.xyz[i, 2] +
(fens.xyz[i, 1] / width) *
(height - fens.xyz[i, 2] / height * (height - free_height))
end
# Clamped edge of the membrane
l1 = selectnode(fens; box = [0.0, 0.0, -Inf, Inf], inflate = tolerance)
ess1 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => l1)
ess2 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => l1)
# Traction on the opposite edge
boundaryfes = meshboundary(fes)
Toplist =
selectelem(fens, boundaryfes, box = [width, width, -Inf, Inf], inflate = tolerance)
el1femm =
FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(1, 2), thickness))
flux1 = FDataDict("traction_vector" => [0.0, +magn], "femm" => el1femm)
# Make the region
MR = DeforModelRed2DStrain
material = MatDeforElastOrtho(MR, 0.0, E, nu, 0.0)
region1 = FDataDict(
"femm" =>
FEMMDeforLinear(MR, IntegDomain(fes, TriRule(1), thickness), material),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [ess1, ess2],
"traction_bcs" => [flux1],
)
# Call the solver
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# Extract the solution
nl = selectnode(
fens,
box = [Mid_edge[1], Mid_edge[1], Mid_edge[2], Mid_edge[2]],
inflate = tolerance,
)
theutip = u.values[nl, :]
# println("displacement =$(theutip[2]) as compared to converged $convutip")
@test abs(theutip[2] - 21.35955642390279) < 1.0e-3
modeldata["postprocessing"] =
FDataDict("file" => "cookstress-ew", "quantity" => :Cauchy, "component" => :xy)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
# println("range of Cauchy_xy = $((minimum(fld.values), maximum(fld.values)))")
@test norm(
[minimum(fld.values), maximum(fld.values)] -
[-0.07028875155067116, 0.1301698279821655],
) < 1.0e-5
# File = modeldata["postprocessing"]["exported"][1]["file"]
# @async run(`"paraview.exe" $File`)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
modeldata["postprocessing"] =
FDataDict("file" => "cookstress-ew-vm", "quantity" => :vm, "component" => 1)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
# println("range of vm = $((minimum(fld.values), maximum(fld.values)))")
@test norm(
[minimum(fld.values), maximum(fld.values)] -
[0.007503804468283987, 0.33798754356331173],
) < 1.0e-5
# File = modeldata["postprocessing"]["exported"][1]["file"]
# @async run(`"paraview.exe" $File`)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
modeldata["postprocessing"] = FDataDict(
"file" => "cookstress-ew-pressure",
"quantity" => :pressure,
"component" => 1,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
# println("range of pressure = $((minimum(fld.values), maximum(fld.values)))")
@test norm(
[minimum(fld.values), maximum(fld.values)] -
[-0.11777749217431245, 0.23457099031101358],
) < 1.0e-5
# File = modeldata["postprocessing"]["exported"][1]["file"]
# @async run(`"paraview.exe" $File`)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
modeldata["postprocessing"] = FDataDict(
"file" => "cookstress-ew-princ1",
"quantity" => :princCauchy,
"component" => 1,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
# println("range of princCauchy Max = $((minimum(fld.values), maximum(fld.values)))")
@test norm(
[minimum(fld.values), maximum(fld.values)] -
[-0.16098150217425994, 0.24838761904231466],
) < 1.0e-5
# File = modeldata["postprocessing"]["exported"][1]["file"]
# @async run(`"paraview.exe" $File`)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
modeldata["postprocessing"] = FDataDict(
"file" => "cookstress-ew-princ3",
"quantity" => :princCauchy,
"component" => 3,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
# println("range of princCauchy Min = $((minimum(fld.values), maximum(fld.values)))")
@test norm(
[minimum(fld.values), maximum(fld.values)] -
[-0.4523049370669106, 0.02980811337406548],
) < 1.0e-5
# File = modeldata["postprocessing"]["exported"][1]["file"]
# @async run(`"paraview.exe" $File`)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
AE = AbaqusExporter("Cookstress_algo_stress")
HEADING(AE, "Cook trapezoidal panel, plane stress")
COMMENT(AE, "Converged free mid-edge displacement = 23.97")
PART(AE, "part1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
COMMENT(AE, "We are assuming three node triangles in plane-stress")
COMMENT(AE, "CPE3 are pretty poor-accuracy elements, but here we don't care about it.")
@test nodesperelem(modeldata["regions"][1]["femm"].integdomain.fes) == 3
ELEMENT(
AE,
"CPE3",
"AllElements",
connasarray(modeldata["regions"][1]["femm"].integdomain.fes),
)
NSET_NSET(AE, "clamped", modeldata["essential_bcs"][1]["node_list"])
ORIENTATION(AE, "GlobalOrientation", vec([1.0 0 0]), vec([0 1.0 0]))
SOLID_SECTION(AE, "elasticity", "GlobalOrientation", "AllElements", thickness)
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "elasticity")
ELASTIC(AE, E, nu)
STEP_PERTURBATION_STATIC(AE)
BOUNDARY(AE, "ASSEM1.INSTNC1.clamped", 1)
BOUNDARY(AE, "ASSEM1.INSTNC1.clamped", 2)
bfes = modeldata["traction_bcs"][1]["femm"].integdomain.fes
COMMENT(AE, "Concentrated loads: we are assuming that the elements on the boundary")
COMMENT(AE, "have two nodes each and also that they are the same length.")
COMMENT(AE, "Then the concentrated loads below will be correctly lumped.")
nl = connectednodes(bfes)
F = zeros(count(modeldata["fens"]))
for ix = 1:count(bfes)
for jx = 1:2
F[bfes.conn[ix][jx]] += 1.0 / n / 2 / thickness
end
end
for ixxxx in eachindex(F)
if F[ixxxx] != 0.0
CLOAD(AE, "ASSEM1.INSTNC1.$(ixxxx)", 2, F[ixxxx])
end
end
END_STEP(AE)
close(AE)
nlines = 0
open(AE.filename) do f
s = readlines(f)
nlines = length(s)
end
@test nlines == 2886
rm(AE.filename)
end
end
using .mmmCookmmstrainmorthommm
mmmCookmmstrainmorthommm.test()
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 51949 |
module mmmCookmstressmorthommm
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtools.MeshExportModule
using Test
import LinearAlgebra: norm, cholesky, cross
function test()
E = 1.0
nu = 1.0 / 3
width = 48.0
height = 44.0
thickness = 1.0
free_height = 16.0
Mid_edge = [48.0, 52.0]# Location of tracked deflection
magn = 1.0 / (free_height * thickness)# Density of applied load
convutip = 23.97
n = 30# number of elements per side
tolerance = minimum([width, height]) / n / 1000.0#Geometrical tolerance
fens, fes = T3block(width, height, n, n)
# Reshape into a trapezoidal panel
for i in eachindex(fens)
fens.xyz[i, 2] =
fens.xyz[i, 2] +
(fens.xyz[i, 1] / width) *
(height - fens.xyz[i, 2] / height * (height - free_height))
end
# Clamped edge of the membrane
l1 = selectnode(fens; box = [0.0, 0.0, -Inf, Inf], inflate = tolerance)
ess1 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => l1)
ess2 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => l1)
# Traction on the opposite edge
boundaryfes = meshboundary(fes)
Toplist =
selectelem(fens, boundaryfes, box = [width, width, -Inf, Inf], inflate = tolerance)
el1femm =
FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(1, 2), thickness))
flux1 = FDataDict("traction_vector" => [0.0, +magn], "femm" => el1femm)
# Make the region
MR = DeforModelRed2DStress
material = MatDeforElastOrtho(MR, 0.0, E, nu, 0.0)
region1 = FDataDict(
"femm" =>
FEMMDeforLinear(MR, IntegDomain(fes, TriRule(1), thickness), material),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [ess1, ess2],
"traction_bcs" => [flux1],
)
# Call the solver
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# Extract the solution
nl = selectnode(
fens,
box = [Mid_edge[1], Mid_edge[1], Mid_edge[2], Mid_edge[2]],
inflate = tolerance,
)
theutip = u.values[nl, :]
# println("displacement =$(theutip[2]) as compared to converged $convutip")
@test abs(theutip[2] - 23.79623002934245) < 1.0e-3
modeldata["postprocessing"] =
FDataDict("file" => "cookstress-ew", "quantity" => :Cauchy, "component" => :xy)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
# println("range of Cauchy_xy = $((minimum(fld.values), maximum(fld.values)))")
@test norm(
[minimum(fld.values), maximum(fld.values)] -
[-0.07275125002229098, 0.1309644027374448],
) < 1.0e-5
# File = modeldata["postprocessing"]["exported"][1]["file"]
# @async run(`"paraview.exe" $File`)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
modeldata["postprocessing"] =
FDataDict("file" => "cookstress-ew-vm", "quantity" => :vm, "component" => 1)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
# println("range of vm = $((minimum(fld.values), maximum(fld.values)))")
@test norm(
[minimum(fld.values), maximum(fld.values)] -
[0.014136291979824203, 0.4181381117075297],
) < 1.0e-5
# File = modeldata["postprocessing"]["exported"][1]["file"]
# @async run(`"paraview.exe" $File`)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
modeldata["postprocessing"] = FDataDict(
"file" => "cookstress-ew-pressure",
"quantity" => :pressure,
"component" => 1,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
# println("range of pressure = $((minimum(fld.values), maximum(fld.values)))")
# display(norm([minimum(fld.values), maximum(fld.values)] - [-0.12996180159464202, 0.2436183072544255]))
@test norm(
[minimum(fld.values), maximum(fld.values)] -
[-0.08664120106309468, 0.16241220483628366],
) < 1.0e-5
# File = modeldata["postprocessing"]["exported"][1]["file"]
# @async run(`"paraview.exe" $File`)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
modeldata["postprocessing"] = FDataDict(
"file" => "cookstress-ew-princ1",
"quantity" => :princCauchy,
"component" => 1,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
# println("range of princCauchy Max = $((minimum(fld.values), maximum(fld.values)))")
@test norm(
[minimum(fld.values), maximum(fld.values)] -
[-0.10280794467415574, 0.24831137383158813],
) < 1.0e-5
# File = modeldata["postprocessing"]["exported"][1]["file"]
# @async run(`"paraview.exe" $File`)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
modeldata["postprocessing"] = FDataDict(
"file" => "cookstress-ew-princ3",
"quantity" => :princCauchy,
"component" => 2,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
# println("range of princCauchy Min = $((minimum(fld.values), maximum(fld.values)))")
@test norm(
[minimum(fld.values), maximum(fld.values)] -
[-0.4398236425818378, 0.022575693063719465],
) < 1.0e-5
# File = modeldata["postprocessing"]["exported"][1]["file"]
# @async run(`"paraview.exe" $File`)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
AE = AbaqusExporter("Cookstress_algo_stress")
HEADING(AE, "Cook trapezoidal panel, plane stress")
COMMENT(AE, "Converged free mid-edge displacement = 23.97")
PART(AE, "part1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
COMMENT(AE, "We are assuming three node triangles in plane-stress")
COMMENT(AE, "CPS3 are pretty poor-accuracy elements, but here we don't care about it.")
@test nodesperelem(modeldata["regions"][1]["femm"].integdomain.fes) == 3
ELEMENT(
AE,
"CPS3",
"AllElements",
connasarray(modeldata["regions"][1]["femm"].integdomain.fes),
)
NSET_NSET(AE, "clamped", modeldata["essential_bcs"][1]["node_list"])
ORIENTATION(AE, "GlobalOrientation", vec([1.0 0 0]), vec([0 1.0 0]))
SOLID_SECTION(AE, "elasticity", "GlobalOrientation", "AllElements", thickness)
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "elasticity")
ELASTIC(AE, E, nu)
STEP_PERTURBATION_STATIC(AE)
BOUNDARY(AE, "ASSEM1.INSTNC1.clamped", 1)
BOUNDARY(AE, "ASSEM1.INSTNC1.clamped", 2)
bfes = modeldata["traction_bcs"][1]["femm"].integdomain.fes
COMMENT(AE, "Concentrated loads: we are assuming that the elements on the boundary")
COMMENT(AE, "have two nodes each and also that they are the same length.")
COMMENT(AE, "Then the concentrated loads below will be correctly lumped.")
nl = connectednodes(bfes)
F = zeros(count(modeldata["fens"]))
for ix in eachindex(bfes)
for jx = 1:2
F[bfes.conn[ix][jx]] += 1.0 / n / 2 / thickness
end
end
for ixxxx in eachindex(F)
if F[ixxxx] != 0.0
CLOAD(AE, "ASSEM1.INSTNC1.$(ixxxx)", 2, F[ixxxx])
end
end
END_STEP(AE)
close(AE)
nlines = 0
open(AE.filename) do f
s = readlines(f)
nlines = length(s)
end
@test nlines == 2886
rm(AE.filename)
end
end
using .mmmCookmstressmorthommm
mmmCookmstressmorthommm.test()
module mmmCookmstressisommm
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtools.MeshExportModule
using Test
import LinearAlgebra: norm, cholesky, cross
function test()
E = 1.0
nu = 1.0 / 3
width = 48.0
height = 44.0
thickness = 1.0
free_height = 16.0
Mid_edge = [48.0, 52.0]# Location of tracked deflection
magn = 1.0 / (free_height * thickness)# Density of applied load
convutip = 23.97
n = 30# number of elements per side
tolerance = minimum([width, height]) / n / 1000.0#Geometrical tolerance
fens, fes = T3block(width, height, n, n)
# Reshape into a trapezoidal panel
for i in eachindex(fens)
fens.xyz[i, 2] =
fens.xyz[i, 2] +
(fens.xyz[i, 1] / width) *
(height - fens.xyz[i, 2] / height * (height - free_height))
end
# Clamped edge of the membrane
l1 = selectnode(fens; box = [0.0, 0.0, -Inf, Inf], inflate = tolerance)
ess1 = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => l1)
ess2 = FDataDict("displacement" => 0.0, "component" => 2, "node_list" => l1)
# Traction on the opposite edge
boundaryfes = meshboundary(fes)
Toplist =
selectelem(fens, boundaryfes, box = [width, width, -Inf, Inf], inflate = tolerance)
el1femm =
FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(1, 2), thickness))
flux1 = FDataDict("traction_vector" => [0.0, +magn], "femm" => el1femm)
# Make the region
MR = DeforModelRed2DStress
material = MatDeforElastIso(MR, 0.0, E, nu, 0.0)
region1 = FDataDict(
"femm" =>
FEMMDeforLinear(MR, IntegDomain(fes, TriRule(1), thickness), material),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [ess1, ess2],
"traction_bcs" => [flux1],
)
# Call the solver
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
u = modeldata["u"]
geom = modeldata["geom"]
# Extract the solution
nl = selectnode(
fens,
box = [Mid_edge[1], Mid_edge[1], Mid_edge[2], Mid_edge[2]],
inflate = tolerance,
)
theutip = u.values[nl, :]
# println("displacement =$(theutip[2]) as compared to converged $convutip")
@test abs(theutip[2] - 23.79623002934245) < 1.0e-3
modeldata["postprocessing"] =
FDataDict("file" => "cookstress-ew", "quantity" => :Cauchy, "component" => :xy)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
# println("range of Cauchy_xy = $((minimum(fld.values), maximum(fld.values)))")
@test norm(
[minimum(fld.values), maximum(fld.values)] -
[-0.07275125002229098, 0.1309644027374448],
) < 1.0e-5
# File = modeldata["postprocessing"]["exported"][1]["file"]
# @async run(`"paraview.exe" $File`)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
modeldata["postprocessing"] =
FDataDict("file" => "cookstress-ew-vm", "quantity" => :vm, "component" => 1)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
# println("range of vm = $((minimum(fld.values), maximum(fld.values)))")
@test norm(
[minimum(fld.values), maximum(fld.values)] -
[0.014136291979824203, 0.4181381117075297],
) < 1.0e-5
# File = modeldata["postprocessing"]["exported"][1]["file"]
# @async run(`"paraview.exe" $File`)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
modeldata["postprocessing"] = FDataDict(
"file" => "cookstress-ew-pressure",
"quantity" => :pressure,
"component" => 1,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
# println("range of pressure = $((minimum(fld.values), maximum(fld.values)))")
@test norm(
[minimum(fld.values), maximum(fld.values)] -
[-0.08664120106309468, 0.16241220483628366],
) < 1.0e-5
# File = modeldata["postprocessing"]["exported"][1]["file"]
# @async run(`"paraview.exe" $File`)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
modeldata["postprocessing"] = FDataDict(
"file" => "cookstress-ew-princ1",
"quantity" => :princCauchy,
"component" => 1,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
# println("range of princCauchy Max = $((minimum(fld.values), maximum(fld.values)))")
@test norm(
[minimum(fld.values), maximum(fld.values)] -
[-0.10280794467415574, 0.24831137383158813],
) < 1.0e-5
# File = modeldata["postprocessing"]["exported"][1]["file"]
# @async run(`"paraview.exe" $File`)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
modeldata["postprocessing"] = FDataDict(
"file" => "cookstress-ew-princ3",
"quantity" => :princCauchy,
"component" => 2,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
fld = modeldata["postprocessing"]["exported"][1]["field"]
# println("range of princCauchy Min = $((minimum(fld.values), maximum(fld.values)))")
@test norm(
[minimum(fld.values), maximum(fld.values)] -
[-0.4398236425818378, 0.022575693063719465],
) < 1.0e-5
# File = modeldata["postprocessing"]["exported"][1]["file"]
# @async run(`"paraview.exe" $File`)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
AE = AbaqusExporter("Cookstress_algo_stress")
HEADING(AE, "Cook trapezoidal panel, plane stress")
COMMENT(AE, "Converged free mid-edge displacement = 23.97")
PART(AE, "part1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
COMMENT(AE, "We are assuming three node triangles in plane-stress")
COMMENT(AE, "CPS3 are pretty poor-accuracy elements, but here we don't care about it.")
@test nodesperelem(modeldata["regions"][1]["femm"].integdomain.fes) == 3
ELEMENT(
AE,
"CPS3",
"AllElements",
connasarray(modeldata["regions"][1]["femm"].integdomain.fes),
)
NSET_NSET(AE, "clamped", modeldata["essential_bcs"][1]["node_list"])
ORIENTATION(AE, "GlobalOrientation", vec([1.0 0 0]), vec([0 1.0 0]))
SOLID_SECTION(AE, "elasticity", "GlobalOrientation", "AllElements", thickness)
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "elasticity")
ELASTIC(AE, E, nu)
STEP_PERTURBATION_STATIC(AE)
BOUNDARY(AE, "ASSEM1.INSTNC1.clamped", 1)
BOUNDARY(AE, "ASSEM1.INSTNC1.clamped", 2)
bfes = modeldata["traction_bcs"][1]["femm"].integdomain.fes
COMMENT(AE, "Concentrated loads: we are assuming that the elements on the boundary")
COMMENT(AE, "have two nodes each and also that they are the same length.")
COMMENT(AE, "Then the concentrated loads below will be correctly lumped.")
nl = connectednodes(bfes)
F = zeros(count(modeldata["fens"]))
for ix in eachindex(bfes)
for jx = 1:2
F[bfes.conn[ix][jx]] += 1.0 / n / 2 / thickness
end
end
for ixxxx in eachindex(F)
if F[ixxxx] != 0.0
CLOAD(AE, "ASSEM1.INSTNC1.$(ixxxx)", 2, F[ixxxx])
end
end
END_STEP(AE)
close(AE)
nlines = 0
open(AE.filename) do f
s = readlines(f)
nlines = length(s)
end
@test nlines == 2886
rm(AE.filename)
end
end
using .mmmCookmstressisommm
mmmCookmstressisommm.test()
module mmLE10expimpmm
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!
using FinEtoolsDeforLinear
using FinEtools.MeshExportModule
using FinEtools.MeshImportModule
using Test
import LinearAlgebra: norm, cholesky, cross
function test()
# Thick elliptical plate with an elliptical hole is clamped on its exterior
# boundary and is loaded with transverse pressure.
# This is a NAFEMS Benchmark, Test No. LE10.
# The plate is discretized with solid elements.
# Because of the symmetries of the geometry and load, only quarter of the plate is modeled.
# The $\sigma_y=\sigma_2$ at the point $P$ is to be determined. Since the
# target point is on the boundary of the domain it will not be an
# integration node as we use Gauss quadrature. The reference value is -5.38 MPa.
# println("LE10NAFEMS: Transverse deflection of elliptical plate with elliptical hole." )
t0 = time()
E = 210e3 * phun("MEGA*PA")# 210e3 MPa
nu = 0.3
qmagn = 1.0 * phun("MEGA*PA")# transverse pressure
sigma_yP = -5.38 * phun("MEGA*PA")# tensile stress at [2.0, 0.0] meters
Ae = 3.25 * phun("m") # Major radius of the exterior ellipse
Be = 2.75 * phun("m") # Minor radius of the exterior ellipse
Ai = 2.0 * phun("m") # Major radius of the interior ellipse
Bi = 1.0 * phun("m") # Minor radius of the interior ellipse
Thickness = 0.6 * phun("m")
tolerance = Thickness / 1000.0 # Geometrical tolerance
INP_file = """
*HEADING
NAFEMS TEST NLE10, COARSE MESH, C3D10M ELEMENTS
*NODE
1, 2.83277, 1.348
2, 2.48116, 1.04837
3, 2.12955, 0.748738
4, 3.14146, 0.704779
5, 2.33893, 0.399071
6, 2.68977, 0.374369
7, 3.25, 0.
8, 2.8335, 0.
9, 2.417, 0.
10, 2.83277, 1.348, 0.15
11, 2.48116, 1.04837, 0.15
12, 2.12955, 0.748738, 0.15
13, 2.33841, 0.400381, 0.15
14, 3.14128, 0.70533, 0.15
15, 3.25, 0., 0.15
16, 2.8335, 0., 0.15
17, 2.417, 0., 0.15
18, 2.83277, 1.348, 0.3
19, 2.48116, 1.04837, 0.3
20, 2.12955, 0.748738, 0.3
21, 2.62488, 0.674, 0.3
22, 2.33893, 0.399071, 0.3
23, 3.14146, 0.704779, 0.3
24, 3.25, 0., 0.3
25, 2.8335, 0., 0.3
26, 2.417, 0., 0.3
27, 2.83277, 1.348, 0.45
28, 2.48116, 1.04837, 0.45
29, 2.12955, 0.748738, 0.45
30, 2.33841, 0.400381, 0.45
31, 3.14128, 0.70533, 0.45
32, 3.25, 0., 0.45
33, 2.8335, 0., 0.45
34, 2.417, 0., 0.45
35, 2.83277, 1.348, 0.6
36, 2.48116, 1.04837, 0.6
37, 2.12955, 0.748738, 0.6
38, 3.14146, 0.704779, 0.6
39, 2.33893, 0.399071, 0.6
40, 2.68977, 0.374369, 0.6
41, 3.25, 0., 0.6
42, 2.8335, 0., 0.6
43, 2.417, 0., 0.6
45, 1.95628, 0.600869
46, 1.78302, 0.453
47, 2.06477, 0.374369
48, 1.93715, 0.248725
51, 2.2085, 0.
52, 2., 0.
54, 1.95628, 0.600869, 0.15
55, 1.78302, 0.453, 0.15
56, 1.93661, 0.249767, 0.15
59, 2.2085, 0., 0.15
60, 2., 0., 0.15
62, 1.95628, 0.600869, 0.3
63, 1.78302, 0.453, 0.3
64, 1.93715, 0.248725, 0.3
66, 2.10001, 0.2265, 0.3
68, 2.2085, 0., 0.3
69, 2., 0., 0.3
71, 1.95628, 0.600869, 0.45
72, 1.78302, 0.453, 0.45
74, 1.93661, 0.249767, 0.45
76, 2.2085, 0., 0.45
77, 2., 0., 0.45
79, 1.95628, 0.600869, 0.6
80, 1.78302, 0.453, 0.6
81, 2.06477, 0.374369, 0.6
83, 1.93715, 0.248725, 0.6
85, 2.2085, 0., 0.6
86, 2., 0., 0.6
87, 1.783, 2.29921
88, 1.57618, 1.80182
89, 1.36937, 1.30443
90, 1.95627, 1.52397
91, 2.36495, 1.88628
92, 1.78146, 1.06985
96, 1.783, 2.29921, 0.15
97, 1.57618, 1.80182, 0.15
98, 1.36937, 1.30443, 0.15
99, 1.78071, 1.07038, 0.15
100, 2.36449, 1.88669, 0.15
104, 1.783, 2.29921, 0.3
105, 1.57618, 1.80182, 0.3
106, 1.36937, 1.30443, 0.3
107, 2.36495, 1.88628, 0.3
108, 1.78146, 1.06985, 0.3
109, 2.10107, 1.32621, 0.3
113, 1.783, 2.29921, 0.45
114, 1.57618, 1.80182, 0.45
115, 1.36937, 1.30443, 0.45
116, 2.36449, 1.88669, 0.45
117, 1.78071, 1.07038, 0.45
121, 1.783, 2.29921, 0.6
122, 1.57618, 1.80182, 0.6
123, 1.36937, 1.30443, 0.6
124, 1.95627, 1.52397, 0.6
125, 2.36495, 1.88628, 0.6
126, 1.78146, 1.06985, 0.6
131, 1.26718, 1.05863
132, 1.165, 0.812831
134, 1.49321, 0.665266
135, 1.64727, 0.780784
140, 1.26718, 1.05863, 0.15
141, 1.165, 0.812831, 0.15
143, 1.4924, 0.665723, 0.15
148, 1.26718, 1.05863, 0.3
149, 1.165, 0.812831, 0.3
150, 1.57619, 0.878714, 0.3
152, 1.49321, 0.665266, 0.3
157, 1.26718, 1.05863, 0.45
158, 1.165, 0.812831, 0.45
160, 1.4924, 0.665723, 0.45
165, 1.26718, 1.05863, 0.6
166, 1.165, 0.812831, 0.6
168, 1.49321, 0.665266, 0.6
169, 1.64727, 0.780784, 0.6
173, 0., 1.583
174, 0., 1.2915
175, 0., 1.
176, 0.5825, 1.19792
177, 0.699442, 1.51527
178, 0.590531, 0.955415
182, 0., 1.583, 0.15
183, 0., 1.2915, 0.15
184, 0., 1., 0.15
185, 0.698861, 1.51538, 0.15
186, 0.590076, 0.955486, 0.15
190, 0., 1.583, 0.3
191, 0., 1.2915, 0.3
192, 0., 1., 0.3
193, 0.699442, 1.51527, 0.3
194, 0.590531, 0.955415, 0.3
195, 0.684684, 1.15221, 0.3
199, 0., 1.583, 0.45
200, 0., 1.2915, 0.45
201, 0., 1., 0.45
202, 0.698861, 1.51538, 0.45
203, 0.590076, 0.955486, 0.45
207, 0., 1.583, 0.6
208, 0., 1.2915, 0.6
209, 0., 1., 0.6
210, 0.5825, 1.19792, 0.6
211, 0.699442, 1.51527, 0.6
212, 0.590531, 0.955415, 0.6
216, 0., 2.75
217, 0., 2.1665
219, 0.920251, 2.63745
221, 0.8915, 1.9411
225, 0., 2.75, 0.15
226, 0., 2.1665, 0.15
228, 0.919707, 2.63759, 0.15
233, 0., 2.75, 0.3
234, 0., 2.1665, 0.3
236, 0.684684, 2.02721, 0.3
237, 0.920251, 2.63745, 0.3
242, 0., 2.75, 0.45
243, 0., 2.1665, 0.45
245, 0.919707, 2.63759, 0.45
250, 0., 2.75, 0.6
251, 0., 2.1665, 0.6
253, 0.920251, 2.63745, 0.6
255, 0.8915, 1.9411, 0.6
**
**
*ELEMENT, TYPE=C3D10M, ELSET=EALL
1, 1, 7, 18, 3, 4, 14, 10,
2, 6, 11
2, 24, 18, 7, 26, 23, 14, 15,
25, 21, 16
3, 9, 3, 26, 7, 5, 13, 17,
8, 6, 16
4, 20, 26, 3, 18, 22, 13, 12,
19, 21, 11
5, 3, 7, 18, 26, 6, 14, 11,
13, 16, 21
6, 24, 41, 18, 26, 32, 31, 23,
25, 33, 21
7, 35, 18, 41, 37, 27, 31, 38,
36, 28, 40
8, 20, 37, 26, 18, 29, 30, 22,
19, 28, 21
9, 43, 26, 37, 41, 34, 30, 39,
42, 33, 40
10, 18, 26, 41, 37, 21, 33, 31,
28, 30, 40
11, 9, 26, 3, 52, 17, 13, 5,
51, 59, 47
12, 20, 3, 26, 63, 12, 13, 22,
62, 54, 66
13, 46, 63, 52, 3, 55, 56, 48,
45, 54, 47
14, 69, 52, 63, 26, 60, 56, 64,
68, 59, 66
15, 3, 52, 26, 63, 47, 59, 13,
54, 56, 66
16, 20, 26, 37, 63, 22, 30, 29,
62, 66, 71
17, 43, 37, 26, 86, 39, 30, 34,
85, 81, 76
18, 69, 63, 86, 26, 64, 74, 77,
68, 66, 76
19, 80, 86, 63, 37, 83, 74, 72,
79, 81, 71
20, 63, 26, 37, 86, 66, 30, 71,
74, 76, 81
21, 1, 18, 87, 3, 10, 100, 91,
2, 11, 90
22, 104, 87, 18, 106, 96, 100, 107,
105, 97, 109
23, 89, 106, 3, 87, 98, 99, 92,
88, 97, 90
24, 20, 3, 106, 18, 12, 99, 108,
19, 11, 109
25, 87, 3, 18, 106, 90, 11, 100,
97, 99, 109
26, 104, 18, 121, 106, 107, 116, 113,
105, 109, 114
27, 35, 121, 18, 37, 125, 116, 27,
36, 124, 28
28, 20, 106, 37, 18, 108, 117, 29,
19, 109, 28
29, 123, 37, 106, 121, 126, 117, 115,
122, 124, 114
30, 106, 18, 121, 37, 109, 116, 114,
117, 28, 124
31, 89, 3, 106, 132, 92, 99, 98,
131, 135, 140
32, 20, 106, 3, 63, 108, 99, 12,
62, 150, 54
33, 46, 132, 63, 3, 134, 143, 55,
45, 135, 54
34, 149, 63, 132, 106, 152, 143, 141,
148, 150, 140
35, 132, 3, 106, 63, 135, 99, 140,
143, 54, 150
36, 20, 37, 106, 63, 29, 117, 108,
62, 71, 150
37, 123, 106, 37, 166, 115, 117, 126,
165, 157, 169
38, 149, 166, 63, 106, 158, 160, 152,
148, 157, 150
39, 80, 63, 166, 37, 72, 160, 168,
79, 71, 169
40, 106, 63, 37, 166, 150, 71, 117,
157, 160, 169
41, 89, 106, 173, 132, 98, 185, 177,
131, 140, 176
42, 190, 173, 106, 192, 182, 185, 193,
191, 183, 195
43, 175, 192, 132, 173, 184, 186, 178,
174, 183, 176
44, 149, 132, 192, 106, 141, 186, 194,
148, 140, 195
45, 173, 132, 106, 192, 176, 140, 185,
183, 186, 195
46, 190, 106, 207, 192, 193, 202, 199,
191, 195, 200
47, 123, 207, 106, 166, 211, 202, 115,
165, 210, 157
48, 149, 192, 166, 106, 194, 203, 158,
148, 195, 157
49, 209, 166, 192, 207, 212, 203, 201,
208, 210, 200
50, 192, 106, 207, 166, 195, 202, 200,
203, 157, 210
51, 216, 87, 233, 173, 219, 228, 225,
217, 221, 226
52, 104, 233, 87, 106, 237, 228, 96,
105, 236, 97
53, 89, 173, 106, 87, 177, 185, 98,
88, 221, 97
54, 190, 106, 173, 233, 193, 185, 182,
234, 236, 226
55, 173, 87, 233, 106, 221, 228, 226,
185, 97, 236
56, 104, 121, 233, 106, 113, 245, 237,
105, 114, 236
57, 250, 233, 121, 207, 242, 245, 253,
251, 243, 255
58, 190, 207, 106, 233, 199, 202, 193,
234, 243, 236
59, 123, 106, 207, 121, 115, 202, 211,
122, 114, 255
60, 233, 106, 121, 207, 236, 114, 245,
243, 202, 255
"""
write("NLE10.inp", INP_file)
output = MeshImportModule.import_ABAQUS("NLE10.inp")
fens, fes = output["fens"], output["fesets"][1]
try
rm("NLE10.inp")
catch
end
# Select the boundary faces, on the boundary that is clamped, and on the part
# of the boundary that is loaded with the transverse pressure
bdryfes = meshboundary(fes)
exteriorbfl = selectelem(
fens,
bdryfes,
facing = true,
direction = [1.0, 1.0, 0.0],
dotmin = 0.001,
)
topbfl = selectelem(
fens,
bdryfes,
box = [0.0, Inf, 0.0, Inf, Thickness, Thickness],
inflate = tolerance,
)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
L12 = connectednodes(subset(bdryfes, exteriorbfl)) # external boundary
setebc!(u, L12, true, 1, 0.0)
setebc!(u, L12, true, 2, 0.0)
LL = selectnode(
fens;
box = [0.0, Inf, 0.0, Inf, Thickness / 2.0, Thickness / 2.0],
inflate = tolerance,
)
L3 = intersect(LL, connectednodes(subset(bdryfes, exteriorbfl)))
setebc!(u, L3, true, 3, 0.0)
L1 = selectnode(fens; box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness], inflate = tolerance)
setebc!(u, L1, true, 1, 0.0) # symmetry plane X = 0
L2 = selectnode(fens; box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness], inflate = tolerance)
setebc!(u, L2, true, 2, 0.0) # symmetry plane Y = 0
applyebc!(u)
numberdofs!(u)
eL1femm = FEMMBase(IntegDomain(subset(bdryfes, topbfl), TriRule(3)))
function pfun(forceout::Vector{T}, XYZ, tangents, feid, qpid) where {T}
forceout .= [0.0, 0.0, -qmagn]
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(eL1femm, geom, u, fi, 2)
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the fully three-dimensional solid.
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMST10(MR, IntegDomain(fes, TetRule(4)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K, F2)
nl = selectnode(fens, box = [Ai, Ai, 0, 0, Thickness, Thickness], inflate = tolerance)
thecorneru = zeros(Float64, 1, 3)
gathervalues_asmat!(u, thecorneru, nl)
thecorneru = thecorneru / phun("mm")
# println("displacement =$(thecorneru) [MM] as compared to reference [-0.030939, 0, -0.10488] [MM]")
@test norm(thecorneru - [-0.0268854 0.0 -0.0919955]) < 1.0e-5
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :invdistance,
reportat = :meanonly,
)#
# println("Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yP = $(sigma_yP/phun("MPa")) [MPa]")
@test abs(fld.values[nl, 1][1] / phun("MPa") - -2.2616980060965024) < 1.0e-3
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = :extrapmean,
)#
# println("Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yP = $(sigma_yP/phun("MPa")) [MPa]")
@test abs(fld.values[nl, 1][1] / phun("MPa") - -2.382478776709117) < 1.0e-3
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = :extraptrend,
)#
# println("Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yP = $(sigma_yP/phun("MPa")) [MPa]")
# println("$(fld.values[nl,1][1]/phun("MPa"))")
@test abs(fld.values[nl, 1][1] / phun("MPa") - -5.470291697493607) < 1.0e-3
File = "LE10NAFEMS_MST10_sigmay.vtk"
vtkexportmesh(
File,
connasarray(fes),
geom.values,
FinEtools.MeshExportModule.VTK.T10;
vectors = [("u", u.values)],
scalars = [("sigmay", fld.values)],
)
# @async run(`"paraview.exe" $File`)
try
rm(File)
catch
end
AE = AbaqusExporter("LE10NAFEMS_MST10")
HEADING(
AE,
"LE10NAFEMS: Transverse deflection of elliptical plate with elliptical hole.",
)
PART(AE, "part1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
ELEMENT(AE, "c3d10", "AllElements", 1, connasarray(femm.integdomain.fes))
ELEMENT(
AE,
"SFM3D6",
"TractionElements",
1 + count(femm.integdomain.fes),
connasarray(eL1femm.integdomain.fes),
)
NSET_NSET(AE, "L1", L1)
NSET_NSET(AE, "L2", L2)
NSET_NSET(AE, "L3", L3)
NSET_NSET(AE, "L12", L12)
ORIENTATION(AE, "GlobalOrientation", vec([1.0 0 0]), vec([0 1.0 0]))
SOLID_SECTION(AE, "elasticity", "GlobalOrientation", "AllElements", "Hourglassctl")
SURFACE_SECTION(AE, "TractionElements")
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "elasticity")
ELASTIC(AE, E, nu)
SECTION_CONTROLS(AE, "Hourglassctl", "HOURGLASS=ENHANCED")
STEP_PERTURBATION_STATIC(AE)
BOUNDARY(AE, "ASSEM1.INSTNC1.L1", 1)
BOUNDARY(AE, "ASSEM1.INSTNC1.L2", 2)
BOUNDARY(AE, "ASSEM1.INSTNC1.L3", 3)
BOUNDARY(AE, "ASSEM1.INSTNC1.L12", 1)
BOUNDARY(AE, "ASSEM1.INSTNC1.L12", 2)
DLOAD(AE, "ASSEM1.INSTNC1.TractionElements", vec([0.0, 0.0, -qmagn]))
END_STEP(AE)
close(AE)
output = MeshImportModule.import_ABAQUS(AE.filename)
fens, fes = output["fens"], output["fesets"][1]
try
rm(AE.filename)
catch
end
# Select the boundary faces, on the boundary that is clamped, and on the part
# of the boundary that is loaded with the transverse pressure
bdryfes = meshboundary(fes)
exteriorbfl = selectelem(
fens,
bdryfes,
facing = true,
direction = [1.0, 1.0, 0.0],
dotmin = 0.001,
)
topbfl = selectelem(
fens,
bdryfes,
box = [0.0, Inf, 0.0, Inf, Thickness, Thickness],
inflate = tolerance,
)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
L12 = connectednodes(subset(bdryfes, exteriorbfl)) # external boundary
setebc!(u, L12, true, 1, 0.0)
setebc!(u, L12, true, 2, 0.0)
LL = selectnode(
fens;
box = [0.0, Inf, 0.0, Inf, Thickness / 2.0, Thickness / 2.0],
inflate = tolerance,
)
L3 = intersect(LL, connectednodes(subset(bdryfes, exteriorbfl)))
setebc!(u, L3, true, 3, 0.0)
L1 = selectnode(fens; box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness], inflate = tolerance)
setebc!(u, L1, true, 1, 0.0) # symmetry plane X = 0
L2 = selectnode(fens; box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness], inflate = tolerance)
setebc!(u, L2, true, 2, 0.0) # symmetry plane Y = 0
applyebc!(u)
numberdofs!(u)
eL1femm = FEMMBase(IntegDomain(subset(bdryfes, topbfl), TriRule(3)))
# function pfun(forceout::FVec{T}, XYZ, tangents, feid) where {T}
# forceout .= [0.0, 0.0, -qmagn]
# return forceout
# end
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(eL1femm, geom, u, fi, 2)
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the fully three-dimensional solid.
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMST10(MR, IntegDomain(fes, TetRule(4)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
u = solve_blocked!(u, K, F2)
nl = selectnode(fens, box = [Ai, Ai, 0, 0, Thickness, Thickness], inflate = tolerance)
thecorneru = zeros(Float64, 1, 3)
gathervalues_asmat!(u, thecorneru, nl)
thecorneru = thecorneru / phun("mm")
# println("displacement =$(thecorneru) [MM] as compared to reference [-0.030939, 0, -0.10488] [MM]")
@test norm(thecorneru - [-0.0268854 0.0 -0.0919955]) < 1.0e-5
fld = fieldfromintegpoints(femm, geom, u, :Cauchy, 2; reportat = :meanonly)#
# println("Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yP = $(sigma_yP/phun("MPa")) [MPa]")
@test abs(fld.values[nl, 1][1] / phun("MPa") - -2.2616980060965024) < 1.0e-3
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = :extrapmean,
)#
# println("Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yP = $(sigma_yP/phun("MPa")) [MPa]")
@test abs(fld.values[nl, 1][1] / phun("MPa") - -2.382478776709117) < 1.0e-3
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = :extraptrend,
)#
# println("Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yP = $(sigma_yP/phun("MPa")) [MPa]")
# println("$(fld.values[nl,1][1]/phun("MPa"))")
@test abs(fld.values[nl, 1][1] / phun("MPa") - -5.470291697493607) < 1.0e-3
File = "LE10NAFEMS_MST10_sigmay.vtk"
vtkexportmesh(
File,
connasarray(fes),
geom.values,
FinEtools.MeshExportModule.VTK.T10;
vectors = [("u", u.values)],
scalars = [("sigmay", fld.values)],
)
# @async run(`"paraview.exe" $File`)
try
rm(File)
catch
end
end
end
using .mmLE10expimpmm
mmLE10expimpmm.test()
# module mmtruncatedmfreem1
# using FinEtools
# using FinEtoolsDeforLinear
# using FinEtoolsDeforLinear.AlgoDeforLinearModule
# using Test
# import Arpack: eigs
# import LinearAlgebra: norm, cholesky, cross
# function test()
# # println("""
# # Vibration modes of truncated cylindrical shell.
# # """)
# # t0 = time()
# E = 205000*phun("MPa");# Young's modulus
# nu = 0.3;# Poisson ratio
# rho = 7850*phun("KG*M^-3");# mass density
# OmegaShift = (2*pi*100) ^ 2; # to resolve rigid body modes
# h = 0.05*phun("M");
# l = 10*h;
# Rmed = h/0.2;
# psi = 0; # Cylinder
# nh = 5; nl = 12; nc = 40;
# tolerance = h/nh/100;
# neigvs = 20;
# MR = DeforModelRed3D
# fens,fes = H8block(h,l,2*pi,nh,nl,nc)
# # Shape into a cylinder
# R = zeros(3, 3)
# for i in eachindex(fens)
# x, y, z = fens.xyz[i,:];
# rotmat3!(R, [0, z, 0])
# Q = [cos(psi*pi/180) sin(psi*pi/180) 0;
# -sin(psi*pi/180) cos(psi*pi/180) 0;
# 0 0 1]
# fens.xyz[i,:] = reshape([x+Rmed-h/2, y-l/2, 0], 1, 3)*Q*R;
# end
# candidates = selectnode(fens, plane = [0.0 0.0 1.0 0.0], thickness = h/1000)
# fens,fes = mergenodes(fens, fes, tolerance, candidates);
# geom = NodalField(fens.xyz)
# u = NodalField(zeros(size(fens.xyz,1),3)) # displacement field
# numberdofs!(u)
# material=MatDeforElastIso(MR, rho, E, nu, 0.0)
# femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3,2)), material)
# femm = associategeometry!(femm, geom)
# K =stiffness(femm, geom, u)
# femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3,3)), material)
# M =mass(femm, geom, u)
# # eigs returns the nev requested eigenvalues in d, the corresponding Ritz vectors
# # v (only if ritzvec=true), the number of converged eigenvalues nconv, the number
# # of iterations niter and the number of matrix vector multiplications nmult, as
# # well as the final residual vector resid.
# if true
# d,v,nconv = eigs(K+OmegaShift*M, M; nev=neigvs, which=:SM, explicittransform=:none)
# d[:] = d .- OmegaShift;
# fs = real(sqrt.(complex(d)))/(2*pi)
# # println("Eigenvalues: $fs [Hz]")
# @test norm(sort(fs)[1:8] - [0.0, 0.0, 0.0, 0.0, 0.000166835, 0.000182134, 517.147, 517.147]) < 2.0e-2
# # mode = 7
# # scattersysvec!(u, v[:,mode])
# # File = "unit_cube_modes.vtk"
# # vtkexportmesh(File, fens, fes; vectors=[("mode$mode", u.values)])
# # @async run(`"paraview.exe" $File`)
# end
# v0 = [i==j ? one(Float64) : zero(Float64) for i=1:size(K,1), j=1:2*neigvs]
# tol = 1.0e-2
# maxiter = 20
# lamb, v, nconv, niter, lamberr =
# AlgoDeforLinearModule.ssit(K+OmegaShift*M, M; nev=neigvs, v0=v0, tol=tol, maxiter=maxiter)
# @test nconv == neigvs
# # if nconv < neigvs
# # println("NOT converged")
# # end
# broadcast!(+, lamb, lamb, - OmegaShift);
# fs = real(sqrt.(complex(lamb)))/(2*pi)
# # println("Eigenvalues: $fs [Hz]")
# # println("$(sort(fs))")
# @test norm(sort(fs)[1:8] - [0.0, 0.0, 0.0, 0.0, 7.9048e-5, 0.0, 517.147, 517.147]) < 2.0e-2
# # println("Eigenvalue errors: $lamberr [ND]")
# # mode = 7
# # scattersysvec!(u, v[:,mode])
# # File = "unit_cube_modes.vtk"
# # vtkexportmesh(File, fens, fes; vectors=[("mode$mode", u.values)])
# # @async run(`"paraview.exe" $File`)
# end
# end
# using .mmtruncatedmfreem1
# mmtruncatedmfreem1.test()
module mmFV32mm1
using FinEtools
using FinEtoolsDeforLinear
using Test
import LinearAlgebra: norm, cholesky, cross
function test()
# println("""
# FV32: Cantilevered tapered membrane
# This is a test recommended by the National Agency for Finite Element Methods and
# Standards (U.K.): Test FV32 from NAFEMS publication TNSB, Rev. 3, “The Standard
# NAFEMS Benchmarks,” October 1990.
#
# Reference solution: 44.623 130.03 162.70 246.05 379.90 391.44 for the first
# six modes.
# """)
t0 = time()
E = 200 * phun("GPA")
nu = 0.3
rho = 8000 * phun("KG/M^3")
L = 10 * phun("M")
W0 = 5 * phun("M")
WL = 1 * phun("M")
H = 0.05 * phun("M")
nL, nW, nH = 8, 4, 1# How many element edges per side?
neigvs = 20 # how many eigenvalues
Reffs = [44.623 130.03 162.70 246.05 379.90 391.44]
fens, fes = H20block(1.0, 2.0, 1.0, nL, nW, nH)
for i in eachindex(fens)
xi, eta, theta = fens.xyz[i, :]
eta = eta - 1.0
fens.xyz[i, :] = [xi * L eta * (1.0 - 0.8 * xi) * W0 / 2 theta * H / 2]
end
# File = "mesh.vtk"
# vtkexportmesh(File, fens, fes)
# @async run(`"paraview.exe" $File`)
# Make the region
MR = DeforModelRed3D
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
region1 = FDataDict(
"femm" => FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material),
"femm_mass" => FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 3)), material),
)
nl1 = selectnode(fens; plane = [1.0 0.0 0.0 0.0], thickness = H / 1.0e4)
ebc1 = FDataDict("node_list" => nl1, "component" => 1, "displacement" => 0.0)
ebc2 = FDataDict("node_list" => nl1, "component" => 2, "displacement" => 0.0)
ebc3 = FDataDict("node_list" => nl1, "component" => 3, "displacement" => 0.0)
nl4 = selectnode(fens; plane = [0.0 0.0 1.0 0.0], thickness = H / 1.0e4)
ebc4 = FDataDict("node_list" => nl4, "component" => 3, "displacement" => 0.0)
# Make model data
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [ebc1 ebc2 ebc3 ebc4],
"neigvs" => neigvs,
)
# Solve
modeldata = FinEtoolsDeforLinear.AlgoDeforLinearModule.modal(modeldata)
fs = modeldata["omega"] / (2 * pi)
#println("Eigenvalues: $fs [Hz]")
# println("Percentage frequency errors: $((vec(fs[1:6]) - vec(Reffs))./vec(Reffs)*100)")
@test norm(
(vec(fs[1:6]) - vec(Reffs)) ./ vec(Reffs) * 100 -
[0.0162775, 0.0623384, 0.00799148, 0.151669, 0.376663, 0.0191388],
) < 1.0e-6
modeldata["postprocessing"] = FDataDict("file" => "FV32-modes", "mode" => 1:10)
modeldata = FinEtoolsDeforLinear.AlgoDeforLinearModule.exportmode(modeldata)
# @async run(`"paraview.exe" $(modeldata["postprocessing"]["file"]*"1.vtk")`)
try
rm(modeldata["postprocessing"]["file"] * "1.vtk")
catch
end
end
end
using .mmFV32mm1
mmFV32mm1.test()
# module mmtruncatedmfreem2
# using FinEtools
# using FinEtoolsDeforLinear
# using FinEtoolsDeforLinear.AlgoDeforLinearModule
# using Test
# import Arpack: eigs
# import LinearAlgebra: norm, cholesky, cross
# function test()
# # println("""
# # Vibration modes of truncated cylindrical shell.
# # """)
# # t0 = time()
# E = 205000*phun("MPa");# Young's modulus
# nu = 0.3;# Poisson ratio
# rho = 7850*phun("KG*M^-3");# mass density
# OmegaShift = (2*pi*100) ^ 2; # to resolve rigid body modes
# h = 0.05*phun("M");
# l = 10*h;
# Rmed = h/0.2;
# psi = 0; # Cylinder
# nh = 5; nl = 12; nc = 40;
# tolerance = h/nh/100;
# neigvs = 20;
# MR = DeforModelRed3D
# fens,fes = H8block(h,l,2*pi,nh,nl,nc)
# # Shape into a cylinder
# R = zeros(3, 3)
# for i in eachindex(fens)
# x, y, z = fens.xyz[i,:];
# rotmat3!(R, [0, z, 0])
# Q = [cos(psi*pi/180) sin(psi*pi/180) 0;
# -sin(psi*pi/180) cos(psi*pi/180) 0;
# 0 0 1]
# fens.xyz[i,:] = reshape([x+Rmed-h/2, y-l/2, 0], 1, 3)*Q*R;
# end
# candidates = selectnode(fens, plane = [0.0 0.0 1.0 0.0], thickness = h/1000)
# fens,fes = mergenodes(fens, fes, tolerance, candidates);
# geom = NodalField(fens.xyz)
# u = NodalField(zeros(size(fens.xyz,1),3)) # displacement field
# numberdofs!(u)
# material=MatDeforElastIso(MR, rho, E, nu, 0.0)
# femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3,2)), material)
# femm = associategeometry!(femm, geom)
# K =stiffness(femm, geom, u)
# femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3,3)), material)
# M =mass(femm, geom, u)
# # eigs returns the nev requested eigenvalues in d, the corresponding Ritz vectors
# # v (only if ritzvec=true), the number of converged eigenvalues nconv, the number
# # of iterations niter and the number of matrix vector multiplications nmult, as
# # well as the final residual vector resid.
# if true
# d,v,nev,nconv = eigs(K+OmegaShift*M, M; nev=neigvs, which=:SM, explicittransform=:none)
# broadcast!(+, d, d, - OmegaShift);
# fs = real(sqrt.(complex(d)))/(2*pi)
# # println("Eigenvalues: $fs [Hz]")
# @test norm(sort(fs)[1:8] - [0.0, 0.0, 0.0, 0.0, 0.000166835, 0.000182134, 517.147, 517.147]) < 2.0e-2
# # mode = 7
# # scattersysvec!(u, v[:,mode])
# # File = "unit_cube_modes.vtk"
# # vtkexportmesh(File, fens, fes; vectors=[("mode$mode", u.values)])
# # @async run(`"paraview.exe" $File`)
# end
# v0 = [i==j ? one(Float64) : zero(Float64) for i=1:size(K,1), j=1:2*neigvs]
# tol = 1.0e-2
# maxiter = 20
# lamb, v, nconv, niter, lamberr =
# AlgoDeforLinearModule.ssit(K+OmegaShift*M, M; nev=neigvs, v0=v0, tol=tol, maxiter=maxiter)
# @test nconv == neigvs
# # if nconv < neigvs
# # println("NOT converged")
# # end
# lamb = lamb .- OmegaShift;
# fs = real(sqrt.(complex(lamb)))/(2*pi)
# # println("Eigenvalues: $fs [Hz]")
# # println("$(sort(fs))")
# @test norm(sort(fs)[1:8] - [0.0, 0.0, 0.0, 0.0, 7.9048e-5, 0.0, 517.147, 517.147]) < 2.0e-2
# # println("Eigenvalue errors: $lamberr [ND]")
# # mode = 7
# # scattersysvec!(u, v[:,mode])
# # File = "unit_cube_modes.vtk"
# # vtkexportmesh(File, fens, fes; vectors=[("mode$mode", u.values)])
# # @async run(`"paraview.exe" $File`)
# end
# end
# using .mmtruncatedmfreem2
# mmtruncatedmfreem2.test()
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 48125 |
module mfiber_reinf_cant_yn_strong_Abaqus
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!, matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using Test
using LinearAlgebra: Symmetric, cholesky
using Statistics: mean
function test()
# println("""
# Cantilever example. Strongly orthotropic material. Orientation "y".
# @article{
# author = {Krysl, P.},
# title = {Mean-strain 8-node hexahedron with optimized energy-sampling stabilization},
# journal = {Finite Elements in Analysis and Design},
# volume = {108}, pages = {41-53}, DOI = {10.1016/j.finel.2015.09.008}, year = {2016}
# }
# """)
t0 = time()
pu = ustring -> phun(ustring; system_of_units = :SIMM)
# # Orthotropic material
E1s = 100000.0 * pu("GPa")
E2s = 1.0 * pu("GPa")
E3s = E2s
nu23s = nu12s = nu13s = 0.25
G12s = 0.2 * pu("GPa")
G23s = G13s = G12s
CTE1 = 0.0
CTE2 = 0.0
CTE3 = 0.0
# # Isotropic material
# E = 1.0e9*pu("Pa")
# nu = 0.25
# CTE = 0.0
# Reference value for the vertical deflection of the tip
uz_ref = -1.027498445054843e-05 * pu("m")
a = 90.0 * pu("mm") # length of the cantilever
b = 10.0 * pu("mm") # width of the cross-section
t = 20.0 * pu("mm") # height of the cross-section
q0 = -1000.0 * pu("Pa") # shear traction
dT = 0 * pu("K") # temperature rise
tolerance = 0.00001 * t
# Generate mesh
n = 2
na = 4 * n # number of elements lengthwise
nb = 2 * n # number of elements through the depth
nt = n # number of elements through the thickness
xs = collect(linearspace(0.0, a, na + 1))
ys = collect(linearspace(0.0, b, nb + 1))
ts = collect(linearspace(0.0, t, nt + 1))
# println("Mesh generation")
fens, fes = H8blockx(xs, ys, ts)
fens, fes = H8toH20(fens, fes)
bfes = meshboundary(fes)
# end cross-section surface for the shear loading
sshearl = selectelem(fens, bfes; facing = true, direction = [+1.0 0.0 0.0])
MR = DeforModelRed3D
material = MatDeforElastOrtho(
MR,
0.0,
E1s,
E2s,
E3s,
nu12s,
nu13s,
nu23s,
G12s,
G13s,
G23s,
CTE1,
CTE2,
CTE3,
)
# material = MatDeforElastIso(MR,
# 0.0, E, nu, CTE)
# Material orientation matrix
csmat = zeros(3, 3)
rotmat3!(csmat, -45.0 / 180.0 * pi * [0, 1, 0])
function updatecs!(csmatout, XYZ, tangents, feid, qpid)
copyto!(csmatout, csmat)
end
femm = FEMMDeforLinear(
MR,
IntegDomain(fes, GaussRule(3, 2)),
CSys(3, 3, updatecs!),
material,
)
lx0 = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
nnodes(geom)
setebc!(u, lx0, true, 1, zeros(size(lx0)))
setebc!(u, lx0, true, 2, zeros(size(lx0)))
setebc!(u, lx0, true, 3, zeros(size(lx0)))
applyebc!(u)
# S = connectionmatrix(femm.femmbase, nnodes(geom))
numberdofs!(u)
function getshr!(forceout::Vector{Float64}, XYZ, tangents, feid, qpid)
copyto!(forceout, q0 * [0.0; 0.0; 1.0])
return forceout
end
Tracfemm = FEMMBase(IntegDomain(subset(bfes, sshearl), GaussRule(2, 3)))
# println("Stiffness")
K = stiffness(femm, geom, u)
fi = ForceIntensity(Float64, 3, getshr!)
# println("Traction loads")
F = distribloads(Tracfemm, geom, u, fi, 2)
K_ff, K_fd = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[(:ff, :fd)]
F_f = vector_blocked(F, nfreedofs(u))[:f]
U_d = gathersysvec(u, :d)
# println("Factorization")
factor = cholesky(Symmetric(K_ff))
# println("U = K\\F")
U_f = factor \ F_f
# # println("U = cg(K, F; tol=1e-3, maxiter=2000)")
# U = cg(K, F; tol=1e-3, maxiter=2000)
scattersysvec!(u, U_f)
Tipl = selectnode(fens, box = [a a b b 0.0 0.0], inflate = tolerance)
utip = mean(u.values[Tipl, 3])
# println("Deflection $utip, normalized: $(utip/uz_ref)")
@test abs(utip - -0.00653888266072445) / abs(utip) < 1.0e-6
# println("Solution: $( time()-t0 )")
AE = AbaqusExporter("fiber_reinf_cant_yn_strong_Abaqus")
HEADING(AE, "fiber_reinf_cant_yn_strong_Abaqus.")
PART(AE, "part1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
ELEMENT(AE, "c3d20r", "AllElements", connasarray(femm.integdomain.fes))
ELEMENT(AE, "SFM3D8", "TractionElements", connasarray(Tracfemm.integdomain.fes))
NSET_NSET(AE, "L1", lx0)
NSET_NSET(AE, "L2", lx0)
NSET_NSET(AE, "L3", lx0)
NSET_NSET(AE, "tip", Tipl)
ORIENTATION(AE, "GlobalOrientation", vec([1.0 0 0]), vec([0 1.0 0]))
ORIENTATION(AE, "MaterialOrientation", vec(csmat[:, 1]), vec(csmat[:, 2]))
SOLID_SECTION(AE, "elasticity", "MaterialOrientation", "AllElements", "Hourglassctl")
SURFACE_SECTION(AE, "TractionElements")
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "elasticity")
ELASTIC(AE, E1s, E2s, E3s, nu12s, nu13s, nu23s, G12s, G13s, G23s)
SECTION_CONTROLS(AE, "Hourglassctl", "HOURGLASS=ENHANCED")
STEP_PERTURBATION_STATIC(AE)
BOUNDARY(AE, "ASSEM1.INSTNC1.L1", 1)
BOUNDARY(AE, "ASSEM1.INSTNC1.L2", 2)
BOUNDARY(AE, "ASSEM1.INSTNC1.L3", 3)
DLOAD(AE, "ASSEM1.INSTNC1.TractionElements", vec([0.0, 0.0, q0]))
NODE_PRINT(AE, "ASSEM1.INSTNC1.tip")
ENERGY_PRINT(AE)
END_STEP(AE)
close(AE)
try
rm(AE.filename)
catch
end
# println("Done: $( time()-t0 )")
true
end
end
using .mfiber_reinf_cant_yn_strong_Abaqus
mfiber_reinf_cant_yn_strong_Abaqus.test()
module mmorthoballoonpenaltymm
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!, matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using Test
using LinearAlgebra: norm, cholesky, cross, Symmetric
function test()
# Orthotropic balloon inflation, axially symmetric model
# Parameters:
E1 = 1.0
E2 = 1.0
E3 = 3.0
nu12 = 0.29
nu13 = 0.29
nu23 = 0.19
G12 = 0.3
G13 = 0.3
G23 = 0.3
p = 0.15
rin = 1.0
rex = 1.2
tolerance = rin / 1000.0
MR = DeforModelRed2DAxisymm
fens, fes = Q4block(rex - rin, pi / 2, 5, 20)
bdryfes = meshboundary(fes)
icl = selectelem(fens, bdryfes, box = [0.0, 0.0, 0.0, pi / 2], inflate = tolerance)
for i = 1:count(fens)
r = rin + fens.xyz[i, 1]
a = fens.xyz[i, 2]
fens.xyz[i, :] = [r * cos(a) r * sin(a)]
end
# now we create the geometry and displacement fields
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
# the symmetry plane
ly = selectelem(fens, bdryfes; box = [0 rex 0 0], inflate = tolerance)
# the axis of symmetry
lx = selectelem(fens, bdryfes; box = [0 0 0 rex], inflate = tolerance)
# No EBC
applyebc!(u)
numberdofs!(u)
# println("Number of degrees of freedom = $(u.nfreedofs)")
# The traction boundary condition is applied in the radial
# direction.
el1femm = FEMMBase(IntegDomain(subset(bdryfes, icl), GaussRule(1, 3), true))
function pressureloading!(forceout::Vector{Float64}, XYZ, tangents, feid, qpid)
copyto!(forceout, XYZ / norm(XYZ) * p)
return forceout
end
fi = ForceIntensity(Float64, 2, pressureloading!) # pressure normal to the internal cylindrical surface
F2 = distribloads(el1femm, geom, u, fi, 2)
# Property and material
material = MatDeforElastOrtho(MR, E1, E2, E3, nu12, nu13, nu23, G12, G13, G23)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 2), true), material)
##
# The restraints of the nodes on the bounding cross-sections in the direction
# of the normal to the plane of the cross-section in the
# circumferential direction are introduced using a penalty formulation.
# For that purpose we introduce a finite element model machine for the
# surface finite elements on the cross-sections.
springcoefficient = 1.0e9 / (abs(p) / E1)
xsfemm = FEMMDeforWinkler(IntegDomain(subset(bdryfes, lx), GaussRule(1, 3), true))
ysfemm = FEMMDeforWinkler(IntegDomain(subset(bdryfes, ly), GaussRule(1, 3), true))
H =
surfacenormalspringstiffness(xsfemm, geom, u, springcoefficient, SurfaceNormal(3)) +
surfacenormalspringstiffness(ysfemm, geom, u, springcoefficient, SurfaceNormal(3))
K = stiffness(femm, geom, u)
U = (K + H) \ (F2)
scattersysvec!(u, U[:])
# Produce a plot of the radial stress component in the cylindrical
# coordinate system. Note that this is the usual representation of
# stress using nodal stress field.
fld = fieldfromintegpoints(femm, geom, u, :Cauchy, 3)
# println("Minimum/maximum = $(minimum(fld.values))/$(maximum(fld.values))")
@test abs(minimum(fld.values) - (-0.04635309320688638)) < 1.0e-5
@test abs(maximum(fld.values) - (0.5708149883384825)) < 1.0e-5
# File = "orthoballoon_penalty_sigmaz.vtk"
# vtkexportmesh(File, fens, fes; scalars=[("sigmaz", fld.values)],
# vectors=[("u", u.values)])
# @async run(`"paraview.exe" $File`)
end
end
using .mmorthoballoonpenaltymm
mmorthoballoonpenaltymm.test()
module mbar1
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!, matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using FinEtools.FENodeSetModule
using FinEtools.MeshExportModule
using Test
using LinearAlgebra: norm, cholesky, cross, Symmetric
function test()
Area = 2.0 * phun("in^2")
E = 30e6 * phun("psi") # Young's modulus
nu = 0.0
alpha = 5.5e-6 * phun("in") / phun("in") / phun("F")
fens = FENodeSetModule.FENodeSet([
10.0 -5 20
30 25 -15
] * phun("in"))
fes = FESetL2(reshape([1, 2], 1, 2))
integdomain = IntegDomain(fes, GaussRule(1, 2), (loc, conn, N) -> Area, false)
# display(IntegDomain)
MR = DeforModelRed1D
material = MatDeforElastIso(MR, 0.0, E, nu, alpha)
# display(material )
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
femm = FEMMDeforLinear(MR, integdomain, CSys(3, 1), material)
K = stiffness(femm, geom, u)
# println("K = $(K/(phun("lbf")/phun("in")))")
ref_K =
1.0e+05 * [
1.8916 2.8373 -3.3102 -1.8916 -2.8373 3.3102
2.8373 4.2560 -4.9653 -2.8373 -4.2560 4.9653
-3.3102 -4.9653 5.7929 3.3102 4.9653 -5.7929
-1.8916 -2.8373 3.3102 1.8916 2.8373 -3.3102
-2.8373 -4.2560 4.9653 2.8373 4.2560 -4.9653
3.3102 4.9653 -5.7929 -3.3102 -4.9653 5.7929
]
@test norm(K / (phun("lbf") / phun("in")) - ref_K) / 1.0e5 < 1.0e-3
dT = NodalField(broadcast(+, zeros(size(fens.xyz, 1), 1), 100 * phun("F"))) # temperature field
# display(dT)
F2 = thermalstrainloads(femm, geom, u, dT)
# println("F2 = $(F2/(phun("lbf")))")
ref_F =
1.0e+04 * [
-1.313449091077187
-1.970173636615779
2.298535909385076
1.313449091077187
1.970173636615779
-2.298535909385076
]
@test norm(F2 / (phun("lbf")) - ref_F) < 1.0e-2
# K = cholesky(K)
# U= K\(F2)
# scattersysvec!(u, U[:])
# File = "playground.vtk"
# MeshExportModule.VTK.vtkexportmesh(File, fens, fes)
# @async run(`"paraview.exe" $File`)
# try rm(File) catch end
end
end
using .mbar1
mbar1.test()
module mbar2
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!, matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using FinEtools.FENodeSetModule
using FinEtools.MeshExportModule
using Test
using LinearAlgebra: norm, cholesky, cross, Symmetric
function test()
Area = 1.5
E = 1.0e7 # Young's modulus
nu = 0.0
alpha = 0.0
fens = FENodeSetModule.FENodeSet([
0.0 0
0 40
40 0
40 40
80 0
80 40
])
fes = FESetL2([
1 3
1 4
2 4
3 4
3 5
5 4
6 4
5 6
])
MR = DeforModelRed1D
material = MatDeforElastIso(MR, 0.0, E, nu, alpha)
# display(material )
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
setebc!(u, 1)
setebc!(u, 2)
applyebc!(u)
numberdofs!(u)
# display(u)
femm = FEMMDeforLinear(
MR,
IntegDomain(fes, GaussRule(1, 1), (loc, conn, N) -> Area, false),
CSys(2, 1),
material,
)
K = stiffness(femm, geom, u)
fi = ForceIntensity(vec([0 -2000.0]))
lfemm = FEMMBase(IntegDomain(FESetP1(reshape([3], 1, 1)), PointRule()))
F = distribloads(lfemm, geom, u, fi, 3)
fi = ForceIntensity(vec([+2000.0 0]))
lfemm = FEMMBase(IntegDomain(FESetP1(reshape([5], 1, 1)), PointRule()))
F = F + distribloads(lfemm, geom, u, fi, 3)
fi = ForceIntensity(vec([+4000.0 +6000.0]))
lfemm = FEMMBase(IntegDomain(FESetP1(reshape([6], 1, 1)), PointRule()))
F = F + distribloads(lfemm, geom, u, fi, 3)
K_ff, K_fd = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[(:ff, :fd)]
F_f = vector_blocked(F, nfreedofs(u))[:f]
U_d = gathersysvec(u, :d)
factor = cholesky(Symmetric(K_ff))
U_f = factor \ F_f
scattersysvec!(u, U_f)
@test norm(
u.values - [
0.0 0.0
0.0 0.0
0.0213333 0.0408366
-0.016 0.0461699
0.0426667 0.150091
-0.00533333 0.166091
],
) < 1.0e-4
sfld = elemfieldfromintegpoints(femm, geom, u, :Cauchy, 1)
# display(sfld)
# println("Cauchy = $(sfld.values)")
@test norm(
sfld.values -
[5333.33; 3771.24; -4000.0; 1333.33; 5333.33; -5656.85; 2666.67; 4000.0],
) < 1.0e-2
vfld = elemfieldfromintegpoints(femm, geom, u, :vm, 1)
# display(vfld)
File = "Planar_truss.vtk"
MeshExportModule.VTK.vtkexportmesh(
File,
fens,
fes;
scalars = [("sx", sfld.values), ("vm", vfld.values)],
)
# @async run(`"paraview.exe" $File`)
try
rm(File)
catch
end
end
end
using .mbar2
mbar2.test()
module mmmLE10expiAbaqus2mmmm
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!, matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using FinEtools.MeshExportModule
using Test
using LinearAlgebra: norm, cholesky, cross, Symmetric
function test()
# Thick elliptical plate with an elliptical hole is clamped on its exterior
# boundary and is loaded with transverse pressure.
# This is a NAFEMS Benchmark, Test No. LE10.
# The plate is discretized with solid elements.
# Because of the symmetries of the geometry and load, only quarter of the plate is modeled.
# The $\sigma_y=\sigma_2$ at the point $P$ is to be determined. Since the
# target point is on the boundary of the domain it will not be an
# integration node as we use Gauss quadrature. The reference value is -5.38 MPa.
# println("LE10NAFEMS: Transverse deflection of elliptical plate with elliptical hole." )
t0 = time()
E = 210e3 * phun("MEGA*PA")# 210e3 MPa
nu = 0.3
qmagn = 1.0 * phun("MEGA*PA")# transverse pressure
sigma_yP = -5.38 * phun("MEGA*PA")# tensile stress at [2.0, 0.0] meters
Ae = 3.25 * phun("m") # Major radius of the exterior ellipse
Be = 2.75 * phun("m") # Minor radius of the exterior ellipse
Ai = 2.0 * phun("m") # Major radius of the interior ellipse
Bi = 1.0 * phun("m") # Minor radius of the interior ellipse
Thickness = 0.6 * phun("m")
nc = 6 # number of elements per side
nr = 5 # number of elements per side
nt = 2 # number of elements through the thickness
# nc = 26; # number of elements per side
# nr = 25; # number of elements per side
# nt = 18; # number of elements through the thickness
tolerance = Thickness / nt / 1000.0 # Geometrical tolerance
fens, fes = Q4block(1.0, pi / 2, nr, nc)
#
@test nt % 2 == 0
fens, fes = H8extrudeQ4(
fens,
fes,
nt,
(xyz, layer) -> [xyz[1], xyz[2], (layer) / nt * Thickness],
)
# Select the boundary faces, on the boundary that is clamped, and on the part
# of the boundary that is loaded with the transverse pressure
bdryfes = meshboundary(fes)
exteriorbfl = selectelem(
fens,
bdryfes,
box = [1.0, 1.0, 0.0, pi / 2, 0.0, Thickness],
inflate = tolerance,
)
topbfl = selectelem(
fens,
bdryfes,
box = [0.0, 1.0, 0.0, pi / 2, Thickness, Thickness],
inflate = tolerance,
)
# Reshape the generated block into the elliptical plate
for i = 1:count(fens)
r = fens.xyz[i, 1]
a = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] =
[(r * Ae + (1 - r) * Ai) * cos(a) (r * Be + (1 - r) * Bi) * sin(a) z]
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l12 = connectednodes(subset(bdryfes, exteriorbfl)) # external boundary
setebc!(u, l12, true, 1, 0.0)
setebc!(u, l12, true, 2, 0.0)
ll = selectnode(
fens;
box = [0.0, Inf, 0.0, Inf, Thickness / 2.0, Thickness / 2.0],
inflate = tolerance,
)
l3 = intersect(ll, connectednodes(subset(bdryfes, exteriorbfl)))
setebc!(u, l3, true, 3, 0.0)
l1 = selectnode(fens; box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness], inflate = tolerance)
setebc!(u, l1, true, 1, 0.0) # symmetry plane X = 0
l2 = selectnode(fens; box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness], inflate = tolerance)
setebc!(u, l2, true, 2, 0.0) # symmetry plane Y = 0
applyebc!(u)
numberdofs!(u)
el1femm = FEMMBase(IntegDomain(subset(bdryfes, topbfl), GaussRule(2, 2)))
function pfun(forceout::Vector{Float64}, XYZ, tangents, feid, qpid)
forceout .= [0.0, 0.0, -qmagn]
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(el1femm, geom, u, fi, 2)
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the fully three-dimensional solid.
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K_ff, K_fd = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[(:ff, :fd)]
F_f = vector_blocked(F2, nfreedofs(u))[:f]
U_d = gathersysvec(u, :d)
factor = cholesky(Symmetric(K_ff))
U_f = factor \ F_f
scattersysvec!(u, U_f)
nl = selectnode(fens, box = [Ai, Ai, 0, 0, Thickness, Thickness], inflate = tolerance)
thecorneru = zeros(Float64, 1, 3)
gathervalues_asmat!(u, thecorneru, nl)
thecorneru = thecorneru / phun("mm")
# println("displacement =$(thecorneru) [MM] as compared to reference [-0.030939, 0, -0.10488] [MM]")
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = :extraptrend,
)#
# println("Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yP = $(sigma_yP/phun("MPa")) [MPa]")
# println("$((nc, nr, nt)), $(fld.values[nl,1][1]/phun("MPa"))")
# println("$(fld.values[nl,1][1]/phun("MPa"))")
@test abs(fld.values[nl, 1][1] / phun("MPa") - -4.627214556813842) < 1.0e-3
# File = "LE10NAFEMS_sigmay.vtk"
# vtkexportmesh(File, fes.conn, geom.values,
# FinEtools.MeshExportModule.VTK.H8; vectors=[("u", u.values)],
# scalars=[("sigmay", fld.values)])
# @async run(`"paraview.exe" $File`)
# true
AE = AbaqusExporter("LE10NAFEMS_H8")
HEADING(
AE,
"LE10NAFEMS: Transverse deflection of elliptical plate with elliptical hole.",
)
PART(AE, "part1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
ELEMENT(AE, "c3d8rh", "AllElements", 1, connasarray(femm.integdomain.fes))
ELEMENT(
AE,
"SFM3D4",
"TractionElements",
1 + count(femm.integdomain.fes),
connasarray(el1femm.integdomain.fes),
)
NSET_NSET(AE, "l1", l1)
NSET_NSET(AE, "l2", l2)
NSET_NSET(AE, "l3", l3)
NSET_NSET(AE, "l12", l12)
ORIENTATION(AE, "GlobalOrientation", vec([1.0 0 0]), vec([0 1.0 0]))
SOLID_SECTION(AE, "elasticity", "GlobalOrientation", "AllElements", "Hourglassctl")
SURFACE_SECTION(AE, "TractionElements")
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "elasticity")
ELASTIC(AE, E, nu)
SECTION_CONTROLS(AE, "Hourglassctl", "HOURGLASS=ENHANCED")
STEP_PERTURBATION_STATIC(AE)
BOUNDARY(AE, "ASSEM1.INSTNC1", u.kind .== DOF_KIND_DATA, u.values)
DLOAD(AE, "ASSEM1.INSTNC1.TractionElements", vec([0.0, 0.0, -qmagn]))
END_STEP(AE)
close(AE)
lines = read(AE.filename)
@test length(lines) - 10270 == 0
try
rm(AE.filename)
catch
end
end
end
using .mmmLE10expiAbaqus2mmmm
mmmLE10expiAbaqus2mmmm.test()
module mplate_w_hole_RECT_MSH8m
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!, matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using FinEtools.MeshExportModule
# using DataFrames
# using CSV
using Test
using LinearAlgebra: norm, cholesky, cross, Symmetric
using Statistics: mean
function test()
E = 210000 * phun("MEGA*PA")# 210e3 MPa
nu = 0.3
Ri = 0.1 * phun("M") # hole radius
Re = 2 * Ri # outer radius
H = 0.01 * phun("M") # thickness of the plate
nRadial, nCircumferential = 6, 3
sigma0 = 1 * phun("MEGA*PA")
function sigmaxx(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 * (
1 - Ri^2 / r^2 * (3 / 2 * cos(2 * th) + cos(4 * th)) +
3 / 2 * Ri^4 / r^4 * cos(4 * th)
)
end
function sigmayy(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 * (
Ri^2 / r^2 * (1 / 2 * cos(2 * th) - cos(4 * th)) +
3 / 2 * Ri^4 / r^4 * cos(4 * th)
)
end
function sigmaxy(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 * (
Ri^2 / r^2 * (1 / 2 * sin(2 * th) + sin(4 * th)) -
3 / 2 * Ri^4 / r^4 * sin(4 * th)
)
end
function sigmarr(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 / 2 * (1 - Ri^2 / r^2) +
sigma0 / 2 * (1 - 4 * Ri^2 / r^2 + 3 * Ri^4 / r^4) * cos(2 * th)
end
function sigmatt(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 / 2 * (1 + Ri^2 / r^2) -
sigma0 / 2 * (1 + 3 * Ri^4 / r^4) * cos(2 * th)
end
function sigmart(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 / 2 * (1 + 2 * Ri^2 / r^2 - 3 * Ri^4 / r^4) * sin(2 * th)
end
sigyderrs = Dict{Symbol,Vector{Float64}}()
nelems = []
for extrapolation in [:extrapmean]
sigyderrs[extrapolation] = Vector{Float64}[]
nelems = []
for ref in [1]
# Thickness = H
Thickness = H / 2^ref
tolerance = Thickness / 2^ref / 1000.0 # Geometrical tolerance
fens, fes = H8elliphole(
Ri,
Ri,
Re,
Re,
Thickness,
2^ref * nCircumferential,
2^ref * nCircumferential,
2^ref * nRadial,
1,
)
@test count(fes) == 144
# File = "a.vtk"
# vtkexportmesh(File, fes.conn, fens.xyz,
# FinEtools.MeshExportModule.VTK.H8)
# @async run(`"paraview.exe" $File`)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l1 = selectnode(
fens;
box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(
fens;
box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 1, 0.0)
l1 = selectnode(fens; box = [0.0, Inf, 0.0, Inf, 0.0, 0.0], inflate = tolerance)
setebc!(u, l1, true, 3, 0.0)
# l1 =selectnode(fens; box=[0.0, Inf, 0.0, Inf, Thickness, Thickness], inflate = tolerance)
# setebc!(u,l1,true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
bdryfes = meshboundary(fes)
ixl = selectelem(
fens,
bdryfes,
plane = [1.0, 0.0, 0.0, Re],
thickness = tolerance,
)
elxfemm = FEMMBase(IntegDomain(subset(bdryfes, ixl), GaussRule(2, 2)))
function pfunx(forceout::Vector{Float64}, XYZ, tangents, feid, qpid)
forceout[1] = sigmaxx(XYZ)
forceout[2] = sigmaxy(XYZ)
forceout[3] = 0.0
return forceout
end
fi = ForceIntensity(Float64, 3, pfunx)
Fx = distribloads(elxfemm, geom, u, fi, 2)
iyl = selectelem(
fens,
bdryfes,
plane = [0.0, 1.0, 0.0, Re],
thickness = tolerance,
)
elyfemm = FEMMBase(IntegDomain(subset(bdryfes, iyl), GaussRule(2, 2)))
function pfuny(forceout::Vector{Float64}, XYZ, tangents, feid, qpid)
forceout[1] = -sigmaxy(XYZ)
forceout[2] = sigmayy(XYZ)
forceout[3] = 0.0
return forceout
end
fi = ForceIntensity(Float64, 3, pfuny)
Fy = distribloads(elyfemm, geom, u, fi, 2)
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K_ff, K_fd = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[(:ff, :fd)]
F_f = vector_blocked((Fx + Fy), nfreedofs(u))[:f]
U_d = gathersysvec(u, :d)
factor = cholesky(Symmetric(K_ff))
U_f = factor \ F_f
scattersysvec!(u, U_f)
nlA = selectnode(
fens,
box = [Ri, Ri, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
nlB = selectnode(
fens,
box = [0.0, 0.0, Ri, Ri, 0.0, Thickness],
inflate = tolerance,
)
# thecorneru = zeros(Float64,length(nlA),3)
# gathervalues_asmat!(u, thecorneru, nl);
# thecorneru = mean(thecorneru, 1)[1]/phun("mm")
# println("displacement = $(thecorneru) vs -0.10215 [MM]")
# println("Extrapolation: $( extrapolation )")
sigx = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
1;
nodevalmethod = :averaging,
reportat = extrapolation,
)
sigy = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = extrapolation,
)
sigyA = mean(sigy.values[nlA, 1], dims = 1)[1]
sigyAtrue = sigmatt([Ri, 0.0, 0.0])
# println("sig_y@A =$(sigyA/phun("MPa")) vs $(sigyAtrue/phun("MPa")) [MPa]")
@test abs(sigyA / phun("MPa") - -0.8521990950600441) < 1.0e-3
sigxB = mean(sigx.values[nlB, 1], dims = 1)[1]
sigxBtrue = sigmatt([0.0, Ri, 0.0])
# println("sig_x@B =$(sigxB/phun("MPa")) vs $(sigxBtrue/phun("MPa")) [MPa]")
@test abs(sigxB / phun("MPa") - 2.7749827820003374) < 1.0e-3
# println("$extrapolation, $(count(fes)), $(sigyd/phun("MPa"))")
# push!(nelems, count(fes))
# push!(sigyderrs[extrapolation], abs(sigyd/sigma_yD - 1.0))
# File = "a.vtk"
# vtkexportmesh(File, fes.conn, geom.values,
# FinEtools.MeshExportModule.VTK.H8; vectors=[("u", u.values)],
# scalars=[("sigmax", sigx.values/phun("MEGA*PA")),
# ("sigmay", sigy.values/phun("MEGA*PA"))])
# @async run(`"paraview.exe" $File`)
end
end
# df = DataFrame(nelems=vec(nelems),
# sigyderrtrend=vec(sigyderrs[:extraptrend]),
# sigyderrdefault=vec(sigyderrs[:extrapmean]))
# File = "LE1NAFEMS_MSH8_convergence.CSV"
# CSV.write(File, df)
# @async run(`"paraview.exe" $File`)
end
end
using .mplate_w_hole_RECT_MSH8m
mplate_w_hole_RECT_MSH8m.test()
module mplate_w_hole_RECT_H20m
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!, matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using FinEtools.MeshExportModule
using FinEtools.MeshImportModule: import_ABAQUS
# using DataFrames
# using CSV
using Test
using LinearAlgebra: norm, cholesky, cross, Symmetric
using Statistics: mean
function test()
E = 210000 * phun("MEGA*PA")# 210e3 MPa
nu = 0.3
Ri = 0.15 * phun("M") # hole radius
Re = 2 * Ri # outer radius
H = 0.01 * phun("M") # thickness of the plate
nRadial, nCircumferential = 6, 3
sigma0 = 1 * phun("MEGA*PA")
function sigmaxx(x)
local r = norm(vec(x[1:2]))
local th = atan(x[2], x[1])
return sigma0 * (
1 - Ri^2 / r^2 * (3 / 2 * cos(2 * th) + cos(4 * th)) +
3 / 2 * Ri^4 / r^4 * cos(4 * th)
)
end
function sigmayy(x)
local r = norm(vec(x[1:2]))
local th = atan(x[2], x[1])
return -sigma0 * (
Ri^2 / r^2 * (1 / 2 * cos(2 * th) - cos(4 * th)) +
3 / 2 * Ri^4 / r^4 * cos(4 * th)
)
end
function sigmaxy(x)
local r = norm(vec(x[1:2]))
local th = atan(x[2], x[1])
return -sigma0 * (
Ri^2 / r^2 * (1 / 2 * sin(2 * th) + sin(4 * th)) -
3 / 2 * Ri^4 / r^4 * sin(4 * th)
)
end
function sigmarr(x)
local r = norm(vec(x[1:2]))
local th = atan(x[2], x[1])
return sigma0 / 2 * (1 - Ri^2 / r^2) +
sigma0 / 2 * (1 - 4 * Ri^2 / r^2 + 3 * Ri^4 / r^4) * cos(2 * th)
end
function sigmatt(x)
local r = norm(vec(x[1:2]))
local th = atan(x[2], x[1])
return sigma0 / 2 * (1 + Ri^2 / r^2) -
sigma0 / 2 * (1 + 3 * Ri^4 / r^4) * cos(2 * th)
end
function sigmart(x)
local r = norm(vec(x[1:2]))
local th = atan(x[2], x[1])
return -sigma0 / 2 * (1 + 2 * Ri^2 / r^2 - 3 * Ri^4 / r^4) * sin(2 * th)
end
sigyderrs = Dict{Symbol,Vector{Float64}}()
nelems = []
for extrapolation in [:extrapmean]
sigyderrs[extrapolation] = Vector{Float64}[]
nelems = []
for ref in [1]
Thickness = H
# Thickness = H/2^ref
tolerance = Thickness / 2^ref / 1000.0 # Geometrical tolerance
fens, fes = H8elliphole(
Ri,
Ri,
Re,
Re,
Thickness,
2^ref * nCircumferential,
2^ref * nCircumferential,
2^ref * nRadial,
1,
)
fens, fes = H8toH20(fens, fes)
# File = "a.vtk"
# vtkexportmesh(File, fes.conn, fens.xyz,
# FinEtools.MeshExportModule.VTK.H20)
# @async run(`"paraview.cexe" $File`)
# println("My mesh=>$((count(fens), count(fes)))")
@test count(fens) == 1131
@test count(fes) == 144
#
# output = import_ABAQUS("plane_w_hole_m_debug.inp")
# fens1,fes1 = output["fens"], output["fesets"][1]
# println("Matlab mesh=>$((count(fens1), count(fes1[1])))")
#
# fens3, newfes1, fes2 = mergemeshes(fens,fes, fens1,fes1[1], tolerance)
# fes3 = cat(2, newfes1)
# println("Merged mesh=>$((count(fens3), count(fes3)))")
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l1 = selectnode(
fens;
box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(
fens;
box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 1, 0.0)
l1 = selectnode(fens; box = [0.0, Inf, 0.0, Inf, 0.0, 0.0], inflate = tolerance)
setebc!(u, l1, true, 3, 0.0)
# l1 =selectnode(fens; box=[0.0, Inf, 0.0, Inf, Thickness, Thickness], inflate = tolerance)
# setebc!(u,l1,true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
bdryfes = meshboundary(fes)
# ixl = selectelem(fens, bdryfes, plane=[1.0, 0.0, 0.0, Re], thickness=tolerance);
ixl = selectelem(
fens,
bdryfes,
box = [Re, Re, -Inf, +Inf, -Inf, +Inf],
inflate = tolerance,
)
elxfemm = FEMMBase(IntegDomain(subset(bdryfes, ixl), GaussRule(2, 2)))
function pfunx(forceout::Vector{Float64}, XYZ, tangents, feid, qpid)
forceout[1] = sigmaxx(XYZ)
forceout[2] = sigmaxy(XYZ)
forceout[3] = 0.0
return forceout
end
fi = ForceIntensity(Float64, 3, pfunx)
Fx = distribloads(elxfemm, geom, u, fi, 2)
# iyl = selectelem(fens, bdryfes, plane=[0.0, 1.0, 0.0, Re], thickness=tolerance);
iyl = selectelem(
fens,
bdryfes,
box = [-Inf, +Inf, Re, Re, -Inf, +Inf],
inflate = tolerance,
)
elyfemm = FEMMBase(IntegDomain(subset(bdryfes, iyl), GaussRule(2, 2)))
function pfuny(forceout::Vector{Float64}, XYZ, tangents, feid, qpid)
forceout[1] = sigmaxy(XYZ)
forceout[2] = sigmayy(XYZ)
forceout[3] = 0.0
return forceout
end
fi = ForceIntensity(Float64, 3, pfuny)
Fy = distribloads(elyfemm, geom, u, fi, 2)
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K_ff, K_fd = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[(:ff, :fd)]
F_f = vector_blocked((Fx + Fy), nfreedofs(u))[:f]
U_d = gathersysvec(u, :d)
factor = cholesky(Symmetric(K_ff))
U_f = factor \ F_f
scattersysvec!(u, U_f)
# println("oof load = $(norm(Fx + Fy, 2))")
@test abs(norm(F_f, 2) - 883.437848042617) < 1.0e-2
nlA = selectnode(fens, box = [Ri, Ri, 0.0, 0.0, 0.0, 00.0], inflate = tolerance)
pointu = zeros(Float64, length(nlA), 3)
gathervalues_asmat!(u, pointu, nlA)
# println("disp@A = $(pointu/phun("mm")) [MM]")
@test norm(pointu / phun("mm") - [0.00213238 0.0 0.0]) < 1.0e-4
nlB = selectnode(fens, box = [0.0, 0.0, Ri, Ri, 0.0, 0.0], inflate = tolerance)
pointu = zeros(Float64, length(nlB), 3)
gathervalues_asmat!(u, pointu, nlB)
# println("disp@B = $(pointu/phun("mm")) [MM]")
@test norm(pointu / phun("mm") - [0.0 -0.000708141 0.0]) < 1.0e-4
nlC = selectnode(
fens,
box = [Re, Re, Re, Re, Thickness, Thickness],
inflate = tolerance,
)
pointu = zeros(Float64, length(nlC), 3)
gathervalues_asmat!(u, pointu, nlC)
# println("disp@C = $(pointu/phun("mm")) [MM]")
@test norm(pointu / phun("mm") - [0.00168556 -0.000455007 -1.4286e-5]) < 1.0e-4
nlAallz = selectnode(
fens,
box = [Ri, Ri, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
nlBallz = selectnode(
fens,
box = [0.0, 0.0, Ri, Ri, 0.0, Thickness],
inflate = tolerance,
)
sigx = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
1;
nodevalmethod = :averaging,
reportat = extrapolation,
)
sigy = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = extrapolation,
)
sigyA = mean(sigy.values[nlAallz, 1], dims = 1)[1]
sigyAtrue = sigmayy([Ri, 0.0, 0.0])
# println("sig_y@A =$(sigyA/phun("MPa")) vs $(sigyAtrue/phun("MPa")) [MPa]")
@test abs(sigyA / phun("MPa") - -0.8513053526935438) /
(sigyAtrue / phun("MPa")) < 1.0e-4
sigxB = mean(sigx.values[nlBallz, 1], dims = 1)[1]
sigxBtrue = sigmaxx([0.0, Ri, 0.0])
# println("sig_x@B =$(sigxB/phun("MPa")) vs $(sigxBtrue/phun("MPa")) [MPa]")
# @test abs(sigxB/phun("MPa") - 2.789413093796375)/3.0 < 1.0e-4
# println("$extrapolation, $(count(fes)), $(sigyd/phun("MPa"))")
# push!(nelems, count(fes))
# push!(sigyderrs[extrapolation], abs(sigyd/sigma_yD - 1.0))
File = "a.vtk"
vtkexportmesh(
File,
connasarray(fes),
geom.values,
FinEtools.MeshExportModule.VTK.H20;
vectors = [("u", u.values)],
scalars = [
("sigmax", sigx.values / phun("MEGA*PA")),
("sigmay", sigy.values / phun("MEGA*PA")),
],
)
# @async run(`"paraview.exe" $File`)
try
rm(File)
catch
end
end
end
# df = DataFrame(nelems=vec(nelems),
# sigyderrtrend=vec(sigyderrs[:extraptrend]),
# sigyderrdefault=vec(sigyderrs[:extrapmean]))
# File = "LE1NAFEMS_MSH8_convergence.CSV"
# CSV.write(File, df)
# @async run(`"paraview.exe" $File`)
end
end
using .mplate_w_hole_RECT_H20m
mplate_w_hole_RECT_H20m.test()
module mplate_w_hole_MST10m
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!, matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using FinEtools.MeshExportModule
using Test
using LinearAlgebra: norm, cholesky, cross, Symmetric
using Statistics: mean
function test()
E = 2.4 * phun("MEGA*PA")# 210e3 MPa
nu = 0.49995
Re = 0.3 * phun("M") # outer radius
Ri = 0.1 * phun("M") # hole radius
H = 0.1 * phun("M") # thickness of the plate
nRadial, nCircumferential = 3, 5
sigma0 = 1 * phun("MEGA*PA")
function sigmaxx(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 * (
1 - Ri^2 / r^2 * (3 / 2 * cos(2 * th) + cos(4 * th)) +
3 / 2 * Ri^4 / r^4 * cos(4 * th)
)
end
function sigmayy(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 * (
Ri^2 / r^2 * (1 / 2 * cos(2 * th) - cos(4 * th)) +
3 / 2 * Ri^4 / r^4 * cos(4 * th)
)
end
function sigmaxy(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 * (
Ri^2 / r^2 * (1 / 2 * sin(2 * th) + sin(4 * th)) -
3 / 2 * Ri^4 / r^4 * sin(4 * th)
)
end
function sigmarr(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 / 2 * (1 - Ri^2 / r^2) +
sigma0 / 2 * (1 - 4 * Ri^2 / r^2 + 3 * Ri^4 / r^4) * cos(2 * th)
end
function sigmatt(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return sigma0 / 2 * (1 + Ri^2 / r^2) -
sigma0 / 2 * (1 + 3 * Ri^4 / r^4) * cos(2 * th)
end
function sigmart(x)
local r = norm(x[1:2])
local th = atan(x[2], x[1])
return -sigma0 / 2 * (1 + 2 * Ri^2 / r^2 - 3 * Ri^4 / r^4) * sin(2 * th)
end
sigxderrs = Dict{Symbol,Vector{Float64}}()
sigyderrs = Dict{Symbol,Vector{Float64}}()
numelements = []
numnodes = []
for extrapolation in [:extrapmean] # :extraptrend
sigxderrs[extrapolation] = Vector{Float64}[]
sigyderrs[extrapolation] = Vector{Float64}[]
numelements = []
numnodes = []
for ref = 1:1
# Thickness = H
Thickness = H / 2^ref
tolerance = Thickness / 2^ref / 1000.0 # Geometrical tolerance
fens, fes = T10block(
1.0,
pi / 2,
Thickness,
2^ref * nRadial,
2^ref * nCircumferential,
1,
)
bdryfes = meshboundary(fes)
icl = selectelem(
fens,
bdryfes,
box = [1.0, 1.0, 0.0, pi / 2, 0.0, Thickness],
inflate = tolerance,
)
for i = 1:count(fens)
t = fens.xyz[i, 1]
a = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] =
[(t * Re + (1 - t) * Ri) * cos(a), (t * Re + (1 - t) * Ri) * sin(a), z]
end
# File = "a.vtk"
# vtkexportmesh(File, fes.conn, fens.xyz,
# FinEtools.MeshExportModule.VTK.H8)
# @async run(`"paraview.exe" $File`)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l1 = selectnode(
fens;
box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(
fens;
box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness],
inflate = tolerance,
)
setebc!(u, l1, true, 1, 0.0)
# Plane-stress constraint: assume the plane z=0 is the plane of symmetry of the plate
l1 = selectnode(fens; box = [0.0, Inf, 0.0, Inf, 0.0, 0.0], inflate = tolerance)
setebc!(u, l1, true, 3, 0.0)
# If this was enabled, the plane-strain constraint would be enforced.
# l1 =selectnode(fens; box=[0.0, Inf, 0.0, Inf, Thickness, Thickness], inflate = tolerance)
# setebc!(u,l1,true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
el1femm = FEMMBase(IntegDomain(subset(bdryfes, icl), SimplexRule(2, 3)))
function pfun(forceout::Vector{Float64}, XYZ, tangents, feid, qpid)
local r = sqrt(XYZ[1]^2 + XYZ[2]^2)
nx = XYZ[1] / r
ny = XYZ[2] / r
# local sx, sy, txy
# sx, sy, txy = sigmaxx(XYZ), sigmayy(XYZ), sigmaxy(XYZ)
# sn = sx * nx^2 + sy * ny^2 + 2 * nx * ny * txy
# tn = -(sx - sy) * nx * ny + (nx^2 - ny^2) * txy
# forceout[1] = sn * nx - tn * ny
# forceout[2] = sn * ny + tn * nx
# forceout[3] = 0.0
forceout[1] = sigmarr(XYZ) * nx - sigmart(XYZ) * ny
forceout[2] = sigmarr(XYZ) * ny + sigmart(XYZ) * nx
forceout[3] = 0.0
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(el1femm, geom, u, fi, 2)
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMST10(MR, IntegDomain(fes, SimplexRule(3, 4)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K_ff, K_fd = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[(:ff, :fd)]
F_f = vector_blocked(F2, nfreedofs(u))[:f]
U_d = gathersysvec(u, :d)
# println("Factorization")
factor = cholesky(Symmetric(K_ff))
# println("U = K\\F")
U_f = factor \ F_f
# # println("U = cg(K, F; tol=1e-3, maxiter=2000)")
# U = cg(K, F; tol=1e-3, maxiter=2000)
scattersysvec!(u, U_f)
nlA = selectnode(
fens,
box = [Ri, Ri, 0.0, 0.0, 0.0, Thickness],
inflate = tolerance,
)
nlB = selectnode(
fens,
box = [0.0, 0.0, Ri, Ri, 0.0, Thickness],
inflate = tolerance,
)
# thecorneru = zeros(Float64,length(nlA),3)
# gathervalues_asmat!(u, thecorneru, nl);
# thecorneru = mean(thecorneru, 1)[1]/phun("mm")
# println("displacement = $(thecorneru) vs -0.10215 [MM]")
# println("Extrapolation: $( extrapolation )")
sigx = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
1;
nodevalmethod = :averaging,
reportat = extrapolation,
)
sigy = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = extrapolation,
)
sigyA = mean(sigy.values[nlA, 1], dims = 1)[1]
sigyAtrue = sigmatt([Ri, 0.0, 0.0])
# println("sig_y@A =$(sigyA/phun("MPa")) vs $(sigyAtrue/phun("MPa")) [MPa]")
@test abs(sigyA / phun("MPa") - -0.6705333234697736) /
(sigyAtrue / phun("MPa")) < 1.0e-4
sigxB = mean(sigx.values[nlB, 1], dims = 1)[1]
sigxBtrue = sigmatt([0.0, Ri, 0.0])
# println("sig_x@B =$(sigxB/phun("MPa")) vs $(sigxBtrue/phun("MPa")) [MPa]")
@test abs(sigxB / phun("MPa") - 2.301542874107758) / 3.0 < 1.0e-4
push!(numnodes, count(fens))
push!(numelements, count(fes))
push!(sigxderrs[extrapolation], abs(sigxB / sigxBtrue - 1.0))
push!(sigyderrs[extrapolation], abs(sigyA / sigyAtrue - 1.0))
# File = "a.vtk"
# vtkexportmesh(File, fes.conn, geom.values,
# FinEtools.MeshExportModule.VTK.H8; vectors=[("u", u.values)],
# scalars=[("sigmax", sigx.values/phun("MEGA*PA"))])
# @async run(`"paraview.exe" $File`)
end
end
end
end
using .mplate_w_hole_MST10m
mplate_w_hole_MST10m.test()
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 57178 |
module mmLE1NAFEMSsstress
using FinEtools
using FinEtools.AlgoBaseModule: matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using Test
using LinearAlgebra: norm, cholesky, cross, Symmetric
function test()
E = 210e3 * phun("MEGA*PA")# 210e3 MPa
nu = 0.3
p = 10 * phun("MEGA*PA")# 10 MPA Outward pressure on the outside ellipse
sigma_yD = 92.7 * phun("MEGA*PA")# tensile stress at [2.0, 0.0] meters
Radius = 1.0 * phun("m")
Thickness = 0.1 * phun("m")
n = 2 # number of elements per side
tolerance = 1.0 / n / 1000.0 # Geometrical tolerance
fens, fes = Q4block(1.0, pi / 2, n, n * 2)
fens, fes =
H8extrudeQ4(fens, fes, 1, (xyz, layer) -> [xyz[1], xyz[2], (layer) * Thickness])
bdryfes = meshboundary(fes)
icl = selectelem(
fens,
bdryfes,
box = [1.0, 1.0, 0.0, pi / 2, 0.0, Thickness],
inflate = tolerance,
)
for i = 1:count(fens)
t = fens.xyz[i, 1]
a = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] =
[(t * 3.25 + (1 - t) * 2) * cos(a), (t * 2.75 + (1 - t) * 1) * sin(a), z]
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l1 = selectnode(fens; box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness], inflate = tolerance)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(fens; box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness], inflate = tolerance)
setebc!(u, l1, true, 1, 0.0)
l1 = selectnode(fens; box = [0.0, Inf, 0.0, Inf, 0.0, 0.0], inflate = tolerance)
setebc!(u, l1, true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
el1femm = FEMMBase(IntegDomain(subset(bdryfes, icl), GaussRule(2, 2)))
function pfun(forceout::Vector{T}, XYZ, tangents, feid, qpid) where {T}
pt = [2.75 / 3.25 * XYZ[1], 3.25 / 2.75 * XYZ[2], 0.0]
forceout .= vec(p * pt / norm(pt))
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(el1femm, geom, u, fi, 2)
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the fully three-dimensional solid.
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K_ff, K_fd = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[(:ff, :fd)]
F_f = vector_blocked(F2, nfreedofs(u))[:f]
U_d = gathersysvec(u, :d)
factor = cholesky(Symmetric(K_ff))
U_f = factor \ F_f
scattersysvec!(u, U_f)
nl = selectnode(fens, box = [2.0, 2.0, 0.0, 0.0, 0.0, 0.0], inflate = tolerance)
thecorneru = zeros(Float64, 1, 3)
gathervalues_asmat!(u, thecorneru, nl)
thecorneru = thecorneru / phun("mm")
# println("displacement =$(thecorneru) [MM] as compared to reference [-0.10215,0] [MM]")
@test norm(thecorneru - [-0.107276 0.0 0.0]) < 1.0e-4
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :invdistance,
reportat = :meanonly,
)
# println("Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yD = $(sigma_yD/phun("MPa")) [MPa]")
@test abs(fld.values[nl, 1][1] / phun("MPa") - 42.54884174624546) < 1.0e-3
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = :extrapmean,
)
# println("Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yD = $(sigma_yD/phun("MPa")) [MPa]")
@test abs(fld.values[nl, 1][1] / phun("MPa") - 42.54884174624546) < 1.0e-3
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :averaging,
reportat = :extraptrend,
)
# println("Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yD = $(sigma_yD/phun("MPa")) [MPa]")
@test abs(fld.values[nl, 1][1] / phun("MPa") - 45.44562958746983) < 1.0e-3
fld = fieldfromintegpoints(
femm,
geom,
u,
:Cauchy,
2;
nodevalmethod = :invdistance,
reportat = :meanonly,
)
# println("Sigma_y =$(fld.values[nl,1][1]/phun("MPa")) as compared to reference sigma_yD = $(sigma_yD/phun("MPa")) [MPa]")
@test abs(fld.values[nl, 1][1] / phun("MPa") - 42.54884174624546) < 1.0e-3
end
end
using .mmLE1NAFEMSsstress
mmLE1NAFEMSsstress.test()
module mocylpullFun
using FinEtools
using FinEtools.AlgoBaseModule: matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using Test
function test()
# Cylinder pulled by enforced displacement, axially symmetric model
# Parameters:
E1 = 1.0
E2 = 1.0
E3 = 3.0
nu12 = 0.29
nu13 = 0.29
nu23 = 0.19
G12 = 0.3
G13 = 0.3
G23 = 0.3
p = 0.15
rin = 1.0
rex = 1.2
Length = 1 * rex
ua = -0.05 * Length
tolerance = rin / 1000.0
##
# Note that the FinEtools objects needs to be created with the proper
# model-dimension reduction at hand. In this case that is the axial symmetry
# assumption.
MR = DeforModelRed2DAxisymm
# Create the mesh and initialize the geometry. First we are going
# to construct the block of elements with the first coordinate
# corresponding to the thickness in the radial direction, and the second
# coordinate is the thickness in the axial direction.
fens, fes = Q4block(rex - rin, Length, 5, 20)
fens.xyz[:, 1] = fens.xyz[:, 1] .+ rin
bdryfes = meshboundary(fes)
# the symmetry plane
la1 = selectnode(fens; box = [0 rex 0 0], inflate = tolerance)
# The other end
la2 = selectnode(fens; box = [0 rex Length Length], inflate = tolerance)
e1 = FDataDict("node_list" => la1, "component" => 2, "displacement" => x -> 0.0)
e2 = FDataDict("node_list" => la2, "component" => 2, "displacement" => x -> ua)
# Property and material
material = MatDeforElastOrtho(MR, E1, E2, E3, nu12, nu13, nu23, G12, G13, G23)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 2), true), material)
# Make region
region = FDataDict("femm" => femm)
# Make model data
modeldata =
FDataDict("fens" => fens, "regions" => [region], "essential_bcs" => [e1, e2])
# Call the solver
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
geom = modeldata["geom"]
u = modeldata["u"]
# Produce a plot of the radial stress component in the cylindrical
# coordinate system. Note that this is the usual representation of
# stress using nodal stress field.
fld = fieldfromintegpoints(femm, geom, u, :Cauchy, 2)
# println("Minimum/maximum = $(minimum(fld.values))/$(maximum(fld.values))")
@test abs(minimum(fld.values) - -0.050318853446676574) < 1.0e-4
@test abs(maximum(fld.values) - -0.04973951673608955) < 1.0e-4
# File = "orthoballoon_sigmaz.vtk"
# vtkexportmesh(File, fens, fes; scalars=[("sigmaz", fld.values)],
# vectors=[("u", u.values)])
# @async run(`"paraview.exe" $File`)
end
end
using .mocylpullFun
mocylpullFun.test()
module mmLE11malgo
using FinEtools
using FinEtools.AlgoBaseModule: matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using Test
using LinearAlgebra: norm, cholesky, cross, Symmetric
function test()
# NAFEMS LE11 benchmark with Q8 elements.
# # This is a test recommended by the National Agency for Finite Element
# # Methods and Standards (U.K.): Test LE11 from NAFEMS Publication TNSB,
# # Rev. 3, “The Standard NAFEMS Benchmarks,” October 1990.
# #
# # Target solution: Direct stress, = –105 MPa at point A.
#function LE11NAFEMS()
# Parameters:
Ea = 210000 * phun("MEGA*Pa")
nua = 0.3
alphaa = 2.3e-4 # thermal expansion coefficient
sigmaA = -105 * phun("MEGA*Pa")
nref = 1 # how many times should we refine the mesh?
X =
[
1.0 0.0#A
1.4 0.0#B
0.995184726672197 0.098017140329561
1.393258617341076 0.137223996461385
0.980785 0.195090#
1.37309939 0.27312645
0.956940335732209 0.290284677254462
1.339716470025092 0.406398548156247
0.9238795 0.38268#C
1.2124 0.7#D
0.7071 0.7071#E
1.1062 1.045#F
0.7071 (0.7071+1.79)/2#(E+H)/2
1.0 1.39#G
0.7071 1.79#H
1.0 1.79#I
] * phun("M")
tolerance = 1.e-6 * phun("M")
##
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the axial symmetry
# assumption.
MR = DeforModelRed2DAxisymm
fens = FENodeSet(X)
fes =
FESetQ4([1 2 4 3; 3 4 6 5; 5 6 8 7; 7 8 10 9; 9 10 12 11; 11 12 14 13; 13 14 16 15])
for ref = 1:nref
fens, fes = Q4refine(fens, fes)
list = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = [0.0 0.0],
inflate = tolerance,
)
fens.xyz[list, :] = FinEtools.MeshUtilModule.ontosphere(fens.xyz[list, :], 1.0)
end
fens, fes = Q4toQ8(fens, fes)
list = selectnode(
fens,
distance = 1.0 + 0.1 / 2^nref,
from = [0.0 0.0],
inflate = tolerance,
)
fens.xyz[list, :] = FinEtools.MeshUtilModule.ontosphere(fens.xyz[list, :], 1.0)
# EBC's
l1 = selectnode(fens, box = [-Inf Inf 0 0], inflate = tolerance)
e1 = FDataDict("node_list" => l1, "component" => 2, "displacement" => x -> 0.0)
l1 = selectnode(fens, box = [-Inf Inf 1.79 1.79], inflate = tolerance)
e2 = FDataDict("node_list" => l1, "component" => 2, "displacement" => x -> 0.0)
# Temperature field
dtemp = FDataDict("temperature" => x -> x[1] + x[2])
# Property and material
material = MatDeforElastIso(MR, 0.0, Ea, nua, alphaa)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 3), true), material)
# Make region 1
region = FDataDict("femm" => femm)
# Make model data
modeldata = FDataDict(
"fens" => fens,
"regions" => [region],
"essential_bcs" => [e1, e2],
"temperature_change" => dtemp,
)
# Call the solver
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
geom = modeldata["geom"]
u = modeldata["u"]
dT = modeldata["temp"]
nA = selectnode(fens, box = Float64[1.0 1.0 0.0 0.0], inflate = tolerance)
fld = fieldfromintegpoints(femm, geom, u, dT, :Cauchy, 2)
File = "LE11NAFEMS_Q8_sigmay.vtk"
vtkexportmesh(
File,
fens,
fes;
scalars = [("sigmay", fld.values)],
vectors = [("u", u.values)],
)
# println("range of sigmay = $((minimum(fld.values), maximum(fld.values)))")
@test norm(
[minimum(fld.values), maximum(fld.values)] -
[-1.443052182185007e8, -1.4106181545272522e7],
) < 1.0e-1
# @async run(`"paraview.exe" $File`)
try
rm(File)
catch
end
sA = fld.values[nA] / phun("MEGA*Pa")
sAn = fld.values[nA] / sigmaA
# println("Stress at point A: $(sA) i. e. $( sAn*100 )% of reference value")
@test norm(sA .- -93.8569) < 1.0e-4
fen2fe = FENodeToFEMap(fes, nnodes(geom))
function inspector(idat, elnum, conn, xe, out, xq)
# println("loc = $( xq ) : $( transpose(out)/phun("MEGA*Pa") )")
return idat
end
inspectintegpoints(
femm,
geom,
u,
dT,
fen2fe.map[nA[1]],
inspector,
[];
quantity = :Cauchy,
)
end
end
using .mmLE11malgo
mmLE11malgo.test()
module mmtwistedmsh8ort
using FinEtools
using FinEtools.AlgoBaseModule: matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using Test
using LinearAlgebra: norm, cholesky, cross, Symmetric
import Statistics: mean
function test()
# println("""
# The initially twisted cantilever beam is one of the standard test
# problems for verifying the finite-element accuracy [1]. The beam is
# clamped at one end and loaded either with unit in-plane or
# unit out-of-plane force at the other. The centroidal axis of the beam is
# straight at the undeformed configuration, while its cross-sections are
# twisted about the centroidal axis from 0 at the clamped end to pi/2 at
# the free end.
#
# Reference:
# Zupan D, Saje M (2004) On "A proposed standard set of problems to test
# finite element accuracy": the twisted beam. Finite Elements in Analysis
# and Design 40: 1445-1451.
# """)
E1s = E2s = E3s = 0.29e8
nu12s = nu13s = nu23s = 0.22
G12s = G13s = G23s = E1s / 2 / (1 + nu12s)
# E = 0.29e8;
# nu = 0.22;
W = 1.1
L = 12.0
t = 0.32
nl = 2
nt = 1
nw = 1
ref = 7
p = 1 / W / t
# Loading in the Z direction
loadv = [0; 0; p]
dir = 3
uex = 0.005424534868469 # Harder: 5.424e-3;
# Loading in the Y direction
#loadv = [0;p;0]; dir = 2; uex = 0.001753248285256; # Harder: 1.754e-3;
tolerance = t / 1000
fens, fes = H8block(L, W, t, nl * ref, nw * ref, nt * ref)
# Reshape into a twisted beam shape
for i = 1:count(fens)
a = fens.xyz[i, 1] / L * (pi / 2)
y = fens.xyz[i, 2] - (W / 2)
z = fens.xyz[i, 3] - (t / 2)
fens.xyz[i, :] = [fens.xyz[i, 1], y * cos(a) - z * sin(a), y * sin(a) + z * cos(a)]
end
# Clamped end of the beam
l1 =
selectnode(fens; box = [0 0 -100 * W 100 * W -100 * W 100 * W], inflate = tolerance)
e1 = FDataDict("node_list" => l1, "component" => 1, "displacement" => 0.0)
e2 = FDataDict("node_list" => l1, "component" => 2, "displacement" => 0.0)
e3 = FDataDict("node_list" => l1, "component" => 3, "displacement" => 0.0)
# Traction on the opposite edge
boundaryfes = meshboundary(fes)
Toplist = selectelem(
fens,
boundaryfes,
box = [L L -100 * W 100 * W -100 * W 100 * W],
inflate = tolerance,
)
el1femm = FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(2, 2)))
flux1 = FDataDict("femm" => el1femm, "traction_vector" => loadv)
# Make the region
MR = DeforModelRed3D
material = MatDeforElastOrtho(
MR,
0.0,
E1s,
E2s,
E3s,
nu12s,
nu13s,
nu23s,
G12s,
G13s,
G23s,
0.0,
0.0,
0.0,
)
region1 = FDataDict(
"femm" => FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material),
)
# Make model data
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [e1, e2, e3],
"traction_bcs" => [flux1],
)
# Call the solver
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
geom = modeldata["geom"]
u = modeldata["u"]
# Extract the solution
nl =
selectnode(fens, box = [L L -100 * W 100 * W -100 * W 100 * W], inflate = tolerance)
theutip = mean(u.values[nl, :], dims = 1)
# println("displacement = $(theutip[dir]) as compared to converged $uex")
@test abs(theutip[dir] - uex) / uex < 0.0012
# Write out mesh with displacements
modeldata["postprocessing"] = FDataDict("file" => "twisted_beam_msh8")
modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
# Write out mesh with stresses
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam_msh8", "quantity" => :Cauchy, "component" => :xy)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
# Write out mesh with stresses
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam_msh8", "quantity" => :Cauchy, "component" => :xz)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
# Write out mesh with von Mises stresses
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam_msh8", "quantity" => :vm)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
vm = modeldata["postprocessing"]["exported"][1]["field"]
# println("extremes of vm, nodal: $([minimum(vm.values), maximum(vm.values)])")
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
@test norm([minimum(vm.values), maximum(vm.values)] - [4.78774, 522.126]) < 0.01
# Write out mesh with von Mises stresses, elementwise
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam_msh8-ew", "quantity" => :vm)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
vm = modeldata["postprocessing"]["exported"][1]["field"]
# println("extremes of vm, elemental: $([minimum(vm.values), maximum(vm.values)])")
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
@test norm([minimum(vm.values), maximum(vm.values)] - [1.85882, 522.126]) < 0.01
# Write out mesh with von Mises stresses, elementwise
modeldata["postprocessing"] = FDataDict(
"file" => "twisted_beam_msh8-ew",
"quantity" => :Cauchy,
"component" => :xz,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
end
end
using .mmtwistedmsh8ort
mmtwistedmsh8ort.test()
module mmtwistedmsh9ort
using FinEtools
using FinEtools.AlgoBaseModule: matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using Test
using LinearAlgebra: norm, cholesky, cross, Symmetric
import Statistics: mean
function test()
# println("""
# The initially twisted cantilever beam is one of the standard test
# problems for verifying the finite-element accuracy [1]. The beam is
# clamped at one end and loaded either with unit in-plane or
# unit out-of-plane force at the other. The centroidal axis of the beam is
# straight at the undeformed configuration, while its cross-sections are
# twisted about the centroidal axis from 0 at the clamped end to pi/2 at
# the free end.
#
# Reference:
# Zupan D, Saje M (2004) On "A proposed standard set of problems to test
# finite element accuracy": the twisted beam. Finite Elements in Analysis
# and Design 40: 1445-1451.
# """)
E1s = E2s = E3s = 0.29e8
nu12s = nu13s = nu23s = 0.22
G12s = G13s = G23s = E1s / 2 / (1 + nu12s)
# E = 0.29e8;
# nu = 0.22;
W = 1.1
L = 12.0
t = 0.32
nl = 2
nt = 1
nw = 1
ref = 7
p = 1 / W / t
# Loading in the Z direction
loadv = [0; 0; p]
dir = 3
uex = 0.005424534868469 # Harder: 5.424e-3;
# Loading in the Y direction
#loadv = [0;p;0]; dir = 2; uex = 0.001753248285256; # Harder: 1.754e-3;
tolerance = t / 1000
fens, fes = H8block(L, W, t, nl * ref, nw * ref, nt * ref)
# Reshape into a twisted beam shape
for i = 1:count(fens)
a = fens.xyz[i, 1] / L * (pi / 2)
y = fens.xyz[i, 2] - (W / 2)
z = fens.xyz[i, 3] - (t / 2)
fens.xyz[i, :] = [fens.xyz[i, 1], y * cos(a) - z * sin(a), y * sin(a) + z * cos(a)]
end
# Clamped end of the beam
l1 =
selectnode(fens; box = [0 0 -100 * W 100 * W -100 * W 100 * W], inflate = tolerance)
e1 = FDataDict("node_list" => l1, "component" => 1, "displacement" => 0.0)
e2 = FDataDict("node_list" => l1, "component" => 2, "displacement" => 0.0)
e3 = FDataDict("node_list" => l1, "component" => 3, "displacement" => 0.0)
# Traction on the opposite edge
boundaryfes = meshboundary(fes)
Toplist = selectelem(
fens,
boundaryfes,
box = [L L -100 * W 100 * W -100 * W 100 * W],
inflate = tolerance,
)
el1femm = FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(2, 2)))
flux1 = FDataDict("femm" => el1femm, "traction_vector" => loadv)
# Make the region
MR = DeforModelRed3D
material = MatDeforElastOrtho(
MR,
0.0,
E1s,
E2s,
E3s,
nu12s,
nu13s,
nu23s,
G12s,
G13s,
G23s,
0.0,
0.0,
0.0,
)
region1 = FDataDict(
"femm" => FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material),
)
# Make model data
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [e1, e2, e3],
"traction_bcs" => [flux1],
)
# Call the solver
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
geom = modeldata["geom"]
u = modeldata["u"]
# Extract the solution
nl =
selectnode(fens, box = [L L -100 * W 100 * W -100 * W 100 * W], inflate = tolerance)
theutip = mean(u.values[nl, :], dims = 1)
# println("displacement = $(theutip[dir]) as compared to converged $uex")
@test abs(theutip[dir] - uex) / uex < 0.0012
# Write out mesh with displacements
modeldata["postprocessing"] = FDataDict("file" => "twisted_beam_msh8")
modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
# Write out mesh with stresses
modeldata["postprocessing"] = FDataDict(
"file" => "twisted_beam_msh8",
"quantity" => :Cauchy,
"component" => :xy,
"outputcsys" => CSys(3),
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
# Write out mesh with stresses
modeldata["postprocessing"] = FDataDict(
"file" => "twisted_beam_msh8",
"quantity" => :Cauchy,
"component" => :xz,
"outputcsys" => CSys(3),
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
# Write out mesh with von Mises stresses
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam_msh8", "quantity" => :vm, "outputcsys" => CSys(3))
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
vm = modeldata["postprocessing"]["exported"][1]["field"]
# println("extremes of vm, nodal: $([minimum(vm.values), maximum(vm.values)])")
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
@test norm([minimum(vm.values), maximum(vm.values)] - [4.78774, 522.126]) < 0.01
# Write out mesh with von Mises stresses, elementwise
modeldata["postprocessing"] = FDataDict(
"file" => "twisted_beam_msh8-ew",
"quantity" => :vm,
"outputcsys" => CSys(3),
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
vm = modeldata["postprocessing"]["exported"][1]["field"]
# println("extremes of vm, elemental: $([minimum(vm.values), maximum(vm.values)])")
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
@test norm([minimum(vm.values), maximum(vm.values)] - [1.85882, 522.126]) < 0.01
# Write out mesh with von Mises stresses, elementwise
modeldata["postprocessing"] = FDataDict(
"file" => "twisted_beam_msh8-ew",
"quantity" => :Cauchy,
"component" => :xz,
"outputcsys" => CSys(3),
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
try
rm(modeldata["postprocessing"]["exported"][1]["file"])
catch
end
end
end
using .mmtwistedmsh9ort
mmtwistedmsh9ort.test()
module mxRMSerror3a1
using FinEtools
using FinEtools.AlgoBaseModule: matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using FinEtools.MeshUtilModule
using FinEtools.AlgoBaseModule
using Test
function test()
elementtag = "MSH8"
# println("""
# Pagano_3layer_cylindrical_bending: $(elementtag)
# """)
# This example provides three-dimensional finite element model for the
# transverse shear stress calculations. The problem consists of a one-, two- or
# three-layer plate subjected to a sinusoidal distributed load, as
# described by Pagano (1969). The resulting transverse shear and axial
# stresses through the thickness of the plate are compared to two existing
# analytical solutions by Pagano (1969). The first solution is derived from
# classical laminated plate theory (CPT), while the second is an exact
# solution from linear elasticity theory.
filebase = "Pagano_3layer_cylindrical_bending_$(elementtag)_convergence"
modeldatasequence = FDataDict[]
for Refinement in [1, 2, 4]
# Orthotropic material for the 3 layers
E1 = 25e6 * phun("PSI")
E2 = 1e6 * phun("PSI")
E3 = E2
G12 = 0.5e6 * phun("PSI")
G13 = G12
G23 = 0.2e6 * phun("PSI")
nu12 = 0.25
nu13 = 0.25
nu23 = 0.25
Span_to_thickness = 4.0
T = 2.5 * phun("in") # total thickness of the plate
L = Span_to_thickness * T
h = 1 * phun("in") # depth of the plate
q0 = 1 * phun("PSI")
CTE1 = CTE2 = CTE3 = 0.0
# Here we define the layout and the thicknesses of the layers.
angles = vec([0.0 90.0 0.0])
nLayers = length(angles)
ts = T / nLayers * ones(nLayers) # layer thicknesses
tolerance = 0.0001 * T
# Select how find the mesh should be
nL, nh = Refinement * 2 * 4, Refinement * 1
nts = Refinement * 2 * ones(Int, nLayers)# number of elements per layer
xs = collect(linearspace(0.0, L, nL + 1))
ys = collect(linearspace(0.0, h, nh + 1))
fens, fes = H8layeredplatex(xs, ys, ts, nts)
# println("count(fens) = $(count(fens))")
# This is the material model
MR = DeforModelRed3D
skinmaterial = MatDeforElastOrtho(
MR,
0.0,
E1,
E2,
E3,
nu12,
nu13,
nu23,
G12,
G13,
G23,
CTE1,
CTE2,
CTE3,
)
# The material coordinate system function is defined as:
function updatecs!(csmatout, feid, labels)
fe_label = labels[feid]
rotmat3!(csmatout, angles[fe_label] / 180.0 * pi * [0.0; 0.0; 1.0])
csmatout
end
# The vvolume integrals are evaluated using this rule
gr = GaussRule(3, 2)
# We will create 3 regions, one for each of the layers
regions = FDataDict[]
for layer = 1:nLayers
rls = selectelem(fens, fes, label = layer)
rfes = subset(fes, rls)
push!(
regions,
FDataDict(
"femm" => FEMMDeforLinearMSH8(
MR,
IntegDomain(rfes, gr),
CSys(
3,
3,
(csmatout, XYZ, tangents, feid, qpid) ->
updatecs!(csmatout, feid, rfes.label),
),
skinmaterial,
),
),
)
end
# File = "Meyer_Piening_sandwich-r1.vtk"
# vtkexportmesh(File, skinregion["femm"].integdomain.fes.conn, fens.xyz, FinEtools.MeshExportModule.VTK.VTK.H8)
# # @async run(`"paraview.exe" $File`)
# The essential boundary conditions are applied to enforce the plane strain constraint.
ly0 = selectnode(fens, box = [-Inf Inf 0.0 0.0 -Inf Inf], inflate = tolerance)
lyh = selectnode(fens, box = [-Inf Inf h h -Inf Inf], inflate = tolerance)
ey = FDataDict(
"displacement" => 0.0,
"component" => 2,
"node_list" => vcat(ly0, lyh),
)
# The transverse displacement is fixed at the two ends.
lz0 = selectnode(fens, box = [0.0 0.0 -Inf Inf -Inf Inf], inflate = tolerance)
lzL = selectnode(fens, box = [L L -Inf Inf -Inf Inf], inflate = tolerance)
ez = FDataDict(
"displacement" => 0.0,
"component" => 3,
"node_list" => vcat(lz0, lzL),
)
ex = FDataDict("displacement" => 0.0, "component" => 1, "node_list" => [1])
# The traction boundary condition is applied at the top of the plate.
bfes = meshboundary(fes)
function pfun(forceout::Vector{T}, XYZ, tangents, feid, qpid) where {T}
forceout[1] = 0.0
forceout[2] = 0.0
forceout[3] = -q0 * sin(pi * XYZ[1] / L)
return forceout
end
# From the entire boundary we select those quadrilaterals that lie on the plane
# Z = thickness
tl = selectelem(fens, bfes, box = [-Inf Inf -Inf Inf T T], inflate = tolerance)
Trac = FDataDict(
"traction_vector" => pfun,
"femm" => FEMMBase(IntegDomain(subset(bfes, tl), GaussRule(2, 2))),
)
modeldata = FDataDict(
"fens" => fens,
"regions" => regions,
"essential_bcs" => [ex, ey, ez],
"traction_bcs" => [Trac],
)
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
modeldata["postprocessing"] = FDataDict("file" => filebase * "-u")
modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
for e in modeldata["postprocessing"]["exported"]
try
rm(e["file"])
catch
end
end
u = modeldata["u"]
geom = modeldata["geom"]
# The results of the displacement and stresses will be reported at
# nodes located at the appropriate points.
ntopcenter = selectnode(fens, box = [L / 2 L / 2 0.0 h T T], inflate = tolerance)
ncenterline =
selectnode(fens, box = [L / 2 L / 2 0.0 0.0 0.0 T], inflate = tolerance)
nx0line = selectnode(fens, box = [0.0 0.0 0.0 0.0 0.0 T], inflate = tolerance)
zclo = sortperm(vec(geom.values[ncenterline, 3]))
ncenterline = ncenterline[zclo]
centerz = geom.values[ncenterline, 3]
# println("Top Center deflection: $(mean(u.values[ntopcenter, 3], 1)/phun("in")) [in]")
# # extrap = :extrapmean
extrap = :extraptrend
nodevalmeth = :averaging
# extrap = :default
# nodevalmeth = :invdistance
# Compute all stresses
modeldata["postprocessing"] = FDataDict(
"file" => filebase * "-s",
"quantity" => :Cauchy,
"component" => collect(1:6),
"outputcsys" => CSys(3),
"nodevalmethod" => nodevalmeth,
"reportat" => extrap,
)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
for e in modeldata["postprocessing"]["exported"]
try
rm(e["file"])
catch
end
end
modeldata["elementsize"] = 1.0 / Refinement
modeldata["geometricaltolerance"] = tolerance
modeldata["targetfields"] =
[e["field"] for e in modeldata["postprocessing"]["exported"]]
push!(modeldatasequence, modeldata)
end # for refinement
elementsizes, errornorms, p = AlgoBaseModule.evalconvergencestudy(modeldatasequence)
# println("")
# println("Normalized Approximate Error = $(errornorms)")
@test abs(p[1] - 1.3347513854727369) / 1.3347513854727369 < 1.0e-3
# csvFile = filebase * "_errors" * ".CSV"
# savecsv(csvFile,
# elementsizes=vec(elementsizes[1:end-1]),
# elementsizes2=vec(elementsizes[1:end-1].^2),
# elementsizes3=vec(elementsizes[1:end-1].^3),
# errornorms=vec(errornorms)
# )
# @async run(`"paraview.exe" $csvFile`)
# println("Done")
end
end
using .mxRMSerror3a1
mxRMSerror3a1.test()
module munit_cube_modes_nice_t4
using FinEtools
using FinEtools.AlgoBaseModule: matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using Test
using Arpack
using LinearAlgebra
function test()
# println("""
# Vibration modes of unit cube of almost incompressible material.
# %
# Reference: Puso MA, Solberg J (2006) A stabilized nodally integrated
# tetrahedral. International Journal for Numerical Methods in
# Engineering 67: 841-867.
# """)
t0 = time()
E = 1 * phun("PA")
nu = 0.499
rho = 1 * phun("KG/M^3")
a = 1 * phun("M")
b = a
h = a
n1 = 10# How many element edges per side?
na = n1
nb = n1
nh = n1
neigvs = 20 # how many eigenvalues
OmegaShift = (0.01 * 2 * pi)^2
stabfact = 0.015
Eigenvalues = [
0.0,
5.93656e-8,
7.54751e-8,
9.80131e-8,
1.14899e-7,
1.27725e-7,
0.264544,
0.266128,
0.350568,
0.352546,
0.355279,
0.357389,
0.357701,
0.359704,
0.402389,
0.402968,
0.404977,
0.45061,
0.450974,
0.452039,
]
MR = DeforModelRed3D
fens, fes = T4block(a, b, h, na, nb, nh)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm =
FEMMDeforLinearNICET4(MR, IntegDomain(fes, NodalSimplexRule(3)), material, stabfact)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
M = mass(femm, geom, u)
K_ff = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[:ff]
M_ff = matrix_blocked(M, nfreedofs(u), nfreedofs(u))[:ff]
d, v, nev, nconv = eigs(
K_ff + OmegaShift * M_ff,
M_ff;
nev = neigvs,
which = :SM,
explicittransform = :none,
)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
# # println("Eigenvalues: $fs [Hz]")
@test norm(vec(fs) .- vec(Eigenvalues)) < 1.0e-4 * maximum(vec(Eigenvalues))
# mode = 17
# scattersysvec!(u, v[:,mode])
# File = "unit_cube_modes.vtk"
# vtkexportmesh(File, fens, fes; vectors=[("mode$mode", u.values)])
true
end
end
using .munit_cube_modes_nice_t4
munit_cube_modes_nice_t4.test()
module malum_cyl_mode_nice_t4
using FinEtools
using FinEtools.AlgoBaseModule: matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using Test
using Arpack
using LinearAlgebra
function test()
# Aluminum cylinder free vibration, mesh imported from Abaqus
# Mesh converted from quadratic tetrahedra to linear tetrahedra
# NICE tetrahedral elements used
E = 70000 * phun("MPa")
nu = 0.33
rho = 2700 * phun("KG/M^3")
radius = 0.5 * phun("ft")
neigvs = 20 # how many eigenvalues
OmegaShift = (10.0 * 2 * pi)^2
stabfact = 0.005
Eigenvalues = [
4.54746e-5,
6.82231e-5,
8.7071e-5,
9.99708e-5,
0.000112778,
0.000116397,
2533.6,
2535.12,
2574.64,
4086.61,
4652.66,
4654.16,
5122.94,
6755.62,
6756.45,
6872.26,
6875.3,
6883.49,
6888.53,
6983.99,
]
MR = DeforModelRed3D
output = import_ABAQUS("alum_cyl.inp")
fens, fes = output["fens"], output["fesets"][1]
fens.xyz .*= phun("mm") # The input is provided in SI(mm) units
fens, fes = T10toT4(fens, fes)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm =
FEMMDeforLinearNICET4(MR, IntegDomain(fes, NodalSimplexRule(3)), material, stabfact)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
M = mass(femm, geom, u)
K_ff = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[:ff]
M_ff = matrix_blocked(M, nfreedofs(u), nfreedofs(u))[:ff]
d, v, nev, nconv = eigs(
K_ff + OmegaShift * M_ff,
M_ff;
nev = neigvs,
which = :SM,
explicittransform = :none,
)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
# # println("Eigenvalues: $fs [Hz]")
@test norm(vec(fs) .- vec(Eigenvalues)) < 1.0e-3 * maximum(vec(Eigenvalues))
true
end
end
using .malum_cyl_mode_nice_t4
malum_cyl_mode_nice_t4.test()
module malum_cyl_mode_esnice_t4
using FinEtools
using FinEtools.AlgoBaseModule: matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using Test
using Arpack
using LinearAlgebra
function test()
# Aluminum cylinder free vibration, mesh imported from Abaqus
# Mesh converted from quadratic tetrahedra to linear tetrahedra
# NICE tetrahedral elements used
E = 70000 * phun("MPa")
nu = 0.33
rho = 2700 * phun("KG/M^3")
radius = 0.5 * phun("ft")
neigvs = 20 # how many eigenvalues
OmegaShift = (10.0 * 2 * pi)^2
stabfact = 0.005
Eigenvalues = [
0.0,
0.0,
0.0,
1.8846e-5,
7.35917e-5,
0.000119445,
2498.15,
2498.88,
2513.31,
4082.65,
4585.99,
4586.42,
4987.01,
6648.02,
6648.48,
6679.04,
6682.16,
6777.89,
6780.59,
6799.36,
]
MR = DeforModelRed3D
output = import_ABAQUS("alum_cyl.inp")
fens, fes = output["fens"], output["fesets"][1]
fens.xyz .*= phun("mm") # The input is provided in SI(mm) units
fens, fes = T10toT4(fens, fes)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinearESNICET4(MR, IntegDomain(fes, NodalSimplexRule(3)), material)
associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
M = mass(femm, geom, u)
K_ff = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[:ff]
M_ff = matrix_blocked(M, nfreedofs(u), nfreedofs(u))[:ff]
d, v, nev, nconv = eigs(
K_ff + OmegaShift * M_ff,
M_ff;
nev = neigvs,
which = :SM,
explicittransform = :none,
)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
# println("Eigenvalues: $fs [Hz]")
@test norm(vec(fs) .- vec(Eigenvalues)) < 1.0e-3 * maximum(vec(Eigenvalues))
true
end
end
using .malum_cyl_mode_esnice_t4
malum_cyl_mode_esnice_t4.test()
module mocylpull14 # From linear deformation
using FinEtools
using FinEtools.AlgoBaseModule: matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using LinearAlgebra
using Test
function test()
# Cylinder compressed by enforced displacement, axially symmetric model
# Parameters:
E1 = 1.0
E2 = 1.0
E3 = 3.0
nu12 = 0.29
nu13 = 0.29
nu23 = 0.19
G12 = 0.3
G13 = 0.3
G23 = 0.3
p = 0.15
rin = 1.0
rex = 1.2
Length = 1 * rex
ua = -0.05 * Length
tolerance = rin / 1000.0
##
# Note that the FinEtools objects needs to be created with the proper
# model-dimension reduction at hand. In this case that is the axial symmetry
# assumption.
MR = DeforModelRed2DAxisymm
fens, fes = Q4block(rex - rin, Length, 5, 20)
fens.xyz[:, 1] = fens.xyz[:, 1] .+ rin
bdryfes = meshboundary(fes)
# now we create the geometry and displacement fields
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
# the symmetry plane
l1 = selectnode(fens; box = [0 rex 0 0], inflate = tolerance)
setebc!(u, l1, true, 2, 0.0)
# The other end
l1 = selectnode(fens; box = [0 rex Length Length], inflate = tolerance)
setebc!(u, l1, true, 2, ua)
applyebc!(u)
numberdofs!(u)
# println("Number of degrees of freedom = $(u.nfreedofs)")
@test nfreedofs(u) == 240
# Property and material
material = MatDeforElastIso(MR, 00.0, E1, nu23, 0.0)
# display(material)
# println("$(material.D)")
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 2), true), material)
K = stiffness(femm, geom, u)
K_ff, K_fd = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[(:ff, :fd)]
U_d = gathersysvec(u, :d)
factor = cholesky(Symmetric(K_ff))
U_f = factor \ (-K_fd * U_d)
scattersysvec!(u, U_f)
fld = fieldfromintegpoints(femm, geom, u, :princCauchy, 1)
# println("Minimum/maximum = $(minimum(fld.values))/$(maximum(fld.values))")
@test abs(minimum(fld.values) - 0.0) < 1.0e-5
@test abs(maximum(fld.values) - 0.0) < 1.0e-5
fld = fieldfromintegpoints(femm, geom, u, :princCauchy, 2)
# println("Minimum/maximum = $(minimum(fld.values))/$(maximum(fld.values))")
@test abs(minimum(fld.values) - 0.0) < 1.0e-5
@test abs(maximum(fld.values) - 0.0) < 1.0e-5
fld = fieldfromintegpoints(femm, geom, u, :princCauchy, 3)
# println("Minimum/maximum = $(minimum(fld.values))/$(maximum(fld.values))")
@test abs(minimum(fld.values) - -0.050) < 1.0e-5
@test abs(maximum(fld.values) - -0.04999999999999919) < 1.0e-5
# File = "mocylpull14.vtk"
# vtkexportmesh(File, fens, fes; scalars=[("sigmaz", fld.values)],
# vectors=[("u", u.values)])
# @async run(`"paraview.exe" $File`)
end
end
using .mocylpull14
mocylpull14.test()
module mocylpull1 # From deformation
using FinEtools
using FinEtools.AlgoBaseModule: matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using LinearAlgebra
using Test
function test()
# Cylinder pulled by enforced displacement, axially symmetric model
# Parameters:
E1 = 1.0
E2 = 1.0
E3 = 3.0
nu12 = 0.29
nu13 = 0.29
nu23 = 0.19
G12 = 0.3
G13 = 0.3
G23 = 0.3
p = 0.15
rin = 1.0
rex = 1.2
Length = 1 * rex
ua = -0.05 * Length
tolerance = rin / 1000.0
##
# Note that the FinEtools objects needs to be created with the proper
# model-dimension reduction at hand. In this case that is the axial symmetry
# assumption.
MR = DeforModelRed2DAxisymm
# Create the mesh and initialize the geometry. First we are going
# to construct the block of elements with the first coordinate
# corresponding to the thickness in the radial direction, and the second
# coordinate is the thickness in the axial direction.
fens, fes = Q4block(rex - rin, Length, 5, 20)
fens.xyz[:, 1] = fens.xyz[:, 1] .+ rin
bdryfes = meshboundary(fes)
# now we create the geometry and displacement fields
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
# the symmetry plane
l1 = selectnode(fens; box = [0 rex 0 0], inflate = tolerance)
setebc!(u, l1, true, 2, 0.0)
# The other end
l1 = selectnode(fens; box = [0 rex Length Length], inflate = tolerance)
setebc!(u, l1, true, 2, ua)
applyebc!(u)
numberdofs!(u)
# println("Number of degrees of freedom = $(u.nfreedofs)")
@test nfreedofs(u) == 240
# Property and material
material = MatDeforElastOrtho(MR, E1, E2, E3, nu12, nu13, nu23, G12, G13, G23)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 2), true), material)
K = stiffness(femm, geom, u)
K_ff, K_fd = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[(:ff, :fd)]
U_d = gathersysvec(u, :d)
factor = cholesky(Symmetric(K_ff))
U_f = factor \ (-K_fd * U_d)
scattersysvec!(u, U_f)
# Produce a plot of the radial stress component in the cylindrical
# coordinate system. Note that this is the usual representation of
# stress using nodal stress field.
fld = fieldfromintegpoints(femm, geom, u, :Cauchy, 2)
# println("Minimum/maximum = $(minimum(fld.values))/$(maximum(fld.values))")
@test abs(minimum(fld.values) - -0.050318853446676436) < 1.0e-5
@test abs(maximum(fld.values) - -0.0497395167360893) < 1.0e-5
# File = "orthoballoon_sigmaz.vtk"
# vtkexportmesh(File, fens, fes; scalars=[("sigmaz", fld.values)],
# vectors=[("u", u.values)])
# @async run(`"paraview.exe" $File`)
end
end
using .mocylpull1
mocylpull1.test()
module mmLE1NAFEMSsstressx1
using FinEtools
using FinEtools.AlgoBaseModule: matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using Test
using LinearAlgebra: norm, cholesky, cross, Symmetric
function test()
E = 210e3 * phun("MEGA*PA")# 210e3 MPa
nu = 0.3
p = 10 * phun("MEGA*PA")# 10 MPA Outward pressure on the outside ellipse
sigma_yD = 92.7 * phun("MEGA*PA")# tensile stress at [2.0, 0.0] meters
Radius = 1.0 * phun("m")
Thickness = 0.1 * phun("m")
n = 20 # number of elements per side
tolerance = 1.0 / n / 1000.0 # Geometrical tolerance
fens, fes = Q4block(1.0, pi / 2, n, n * 2)
fens, fes =
H8extrudeQ4(fens, fes, 1, (xyz, layer) -> [xyz[1], xyz[2], (layer) * Thickness])
bdryfes = meshboundary(fes)
icl = selectelem(
fens,
bdryfes,
box = [1.0, 1.0, 0.0, pi / 2, 0.0, Thickness],
inflate = tolerance,
)
for i = 1:count(fens)
t = fens.xyz[i, 1]
a = fens.xyz[i, 2]
z = fens.xyz[i, 3]
fens.xyz[i, :] =
[(t * 3.25 + (1 - t) * 2) * cos(a), (t * 2.75 + (1 - t) * 1) * sin(a), z]
end
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
l1 = selectnode(fens; box = [0.0, Inf, 0.0, 0.0, 0.0, Thickness], inflate = tolerance)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(fens; box = [0.0, 0.0, 0.0, Inf, 0.0, Thickness], inflate = tolerance)
setebc!(u, l1, true, 1, 0.0)
l1 = selectnode(fens; box = [0.0, Inf, 0.0, Inf, 0.0, 0.0], inflate = tolerance)
setebc!(u, l1, true, 3, 0.0)
applyebc!(u)
numberdofs!(u)
el1femm = FEMMBase(IntegDomain(subset(bdryfes, icl), GaussRule(2, 2)))
function pfun(forceout::Vector{T}, XYZ, tangents, feid, qpid) where {T}
pt = [2.75 / 3.25 * XYZ[1], 3.25 / 2.75 * XYZ[2], 0.0]
forceout .= vec(p * pt / norm(pt))
return forceout
end
fi = ForceIntensity(Float64, 3, pfun)
F2 = distribloads(el1femm, geom, u, fi, 2)
# Note that the material object needs to be created with the proper
# model-dimension reduction in mind. In this case that is the fully three-dimensional solid.
MR = DeforModelRed3D
material = MatDeforElastIso(MR, E, nu)
femm = FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material)
# The geometry field now needs to be associated with the FEMM
femm = associategeometry!(femm, geom)
K = stiffness(femm, geom, u)
K_ff, K_fd = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[(:ff, :fd)]
F_f = vector_blocked(F2, nfreedofs(u))[:f]
U_d = gathersysvec(u, :d)
factor = cholesky(Symmetric(K_ff))
U_f = factor \ F_f
scattersysvec!(u, U_f)
nl = selectnode(fens, box = [2.0, 2.0, 0.0, 0.0, 0.0, 0.0], inflate = tolerance)
thecorneru = zeros(Float64, 1, 3)
gathervalues_asmat!(u, thecorneru, nl)
thecorneru = thecorneru / phun("mm")
# println("displacement =$(thecorneru) [MM] as compared to reference [-0.10215,0] [MM]")
@test norm(thecorneru - [-0.10082864119023721 0.0 0.0]) < 1.0e-4
fld = fieldfromintegpoints(femm, geom, u, :princCauchy, 1)
@test norm(maximum(fld.values) - 8.190847372888073e7) / 8.190847372888073e7 <= 1.0e-4
# File = "mmLE1NAFEMSsstressx1-s1.vtk"
# vtkexportmesh(File, fens, fes; scalars=[("sigma_1", fld.values)], vectors=[("u", u.values)])
# @async run(`"paraview.exe" $File`)
fld = fieldfromintegpoints(femm, geom, u, :maxshear, 1)
@test norm(maximum(fld.values) - 8.19559427861603e7) / 8.190847372888073e7 <= 1.0e-4
# File = "mmLE1NAFEMSsstressx1-maxshear.vtk"
# vtkexportmesh(File, fens, fes; scalars=[("maxshear", fld.values)], vectors=[("u", u.values)])
# @async run(`"paraview.exe" $File`)
end
end
using .mmLE1NAFEMSsstressx1
mmLE1NAFEMSsstressx1.test()
module mholestr1
using FinEtools
using FinEtools.AlgoBaseModule: matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using Test
using LinearAlgebra: norm, cholesky, cross, Symmetric
function test()
E = 100.0
nu = 1.0 / 3
cte = 0.15
xradius = 1.0
yradius = 1.0
L = 3.0
H = 3.0
# nL = 50
# nH = 50
# nW = 70
nL = 100
nH = 100
nW = 120
tolerance = min(xradius, yradius, L, H) / min(nL, nH, nW) / 1000.0#Geometrical tolerance
fens, fes = Q4elliphole(xradius, yradius, L, H, nL, nH, nW)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
l1 = selectnode(fens; box = [0, 0, -Inf, Inf], inflate = tolerance)
setebc!(u, l1, 1, 0.0)
l2 = selectnode(fens; box = [-Inf, Inf, 0, 0], inflate = tolerance)
setebc!(u, l2, 2, 0.0)
applyebc!(u)
numberdofs!(u)
boundaryfes = meshboundary(fes)
lce = selectelem(
fens,
boundaryfes,
facing = true,
direction = x -> -x,
inflate = tolerance,
)
lc = connectednodes(subset(boundaryfes, lce))
le = selectelem(fens, boundaryfes, box = [-Inf, Inf, H, H], inflate = tolerance)
el1femm = FEMMBase(IntegDomain(subset(boundaryfes, le), GaussRule(1, 2)))
fi = ForceIntensity([0.0, 1.0])
Fm = distribloads(el1femm, geom, u, fi, 2)
le = selectelem(fens, boundaryfes, box = [L, L, -Inf, Inf], inflate = tolerance)
el2femm = FEMMBase(IntegDomain(subset(boundaryfes, le), GaussRule(1, 2)))
fi = ForceIntensity([1.0, 0.0])
Fm += distribloads(el2femm, geom, u, fi, 2)
MR = DeforModelRed2DStress
material = MatDeforElastIso(MR, 0.0, E, nu, cte)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 2)), material)
K = stiffness(femm, geom, u)
K_ff, K_fd = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[(:ff, :fd)]
F_f = vector_blocked(Fm, nfreedofs(u))[:f]
U_d = gathersysvec(u, :d)
factor = cholesky(Symmetric(K_ff))
U_f = factor \ F_f
scattersysvec!(u, U_f)
fld = fieldfromintegpoints(femm, geom, u, :princCauchy, 1)
# @test norm(maximum(fld.values) - 8.190847372888073e7)/8.190847372888073e7 <= 1.0e-4
# File = "mholestr1-s1.vtk"
# vtkexportmesh(File, fens, fes; scalars=[("sigma_1", fld.values)], vectors=[("u", u.values)])
# @async run(`"paraview.exe" $File`)
fld = fieldfromintegpoints(femm, geom, u, :maxshear, 1)
@test norm(maximum(fld.values) - 2.210557410276065) / 2.210557410276065 <= 1.0e-4
# File = "mholestr1-maxshear.vtk"
# vtkexportmesh(File, fens, fes; scalars=[("maxshear", fld.values)], vectors=[("u", u.values)])
# @async run(`"paraview.exe" $File`)
end
end
using .mholestr1
mholestr1.test()
module mholestr2
using FinEtools
using FinEtools.AlgoBaseModule: matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using Test
using LinearAlgebra: norm, cholesky, cross, Symmetric
function test()
E = 100.0
nu = 1.0 / 3
cte = 0.15
xradius = 1.0
yradius = 1.0
L = 3.0
H = 3.0
# nL = 50
# nH = 50
# nW = 70
nL = 100
nH = 100
nW = 120
tolerance = min(xradius, yradius, L, H) / min(nL, nH, nW) / 1000.0#Geometrical tolerance
fens, fes = Q4elliphole(xradius, yradius, L, H, nL, nH, nW)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
l1 = selectnode(fens; box = [0, 0, -Inf, Inf], inflate = tolerance)
setebc!(u, l1, 1, 0.0)
l2 = selectnode(fens; box = [-Inf, Inf, 0, 0], inflate = tolerance)
setebc!(u, l2, 2, 0.0)
applyebc!(u)
numberdofs!(u)
boundaryfes = meshboundary(fes)
lce = selectelem(
fens,
boundaryfes,
facing = true,
direction = x -> -x,
inflate = tolerance,
)
lc = connectednodes(subset(boundaryfes, lce))
le = selectelem(fens, boundaryfes, box = [-Inf, Inf, H, H], inflate = tolerance)
el1femm = FEMMBase(IntegDomain(subset(boundaryfes, le), GaussRule(1, 2)))
fi = ForceIntensity([0.0, 1.0])
Fm = distribloads(el1femm, geom, u, fi, 2)
le = selectelem(fens, boundaryfes, box = [L, L, -Inf, Inf], inflate = tolerance)
el2femm = FEMMBase(IntegDomain(subset(boundaryfes, le), GaussRule(1, 2)))
fi = ForceIntensity([1.0, 0.0])
Fm += distribloads(el2femm, geom, u, fi, 2)
MR = DeforModelRed2DStrain
material = MatDeforElastIso(MR, 0.0, E, nu, cte)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 2)), material)
K = stiffness(femm, geom, u)
K_ff, K_fd = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[(:ff, :fd)]
F_f = vector_blocked(Fm, nfreedofs(u))[:f]
U_d = gathersysvec(u, :d)
factor = cholesky(Symmetric(K_ff))
U_f = factor \ F_f
scattersysvec!(u, U_f)
fld = fieldfromintegpoints(femm, geom, u, :princCauchy, 1)
# @test norm(maximum(fld.values) - 8.190847372888073e7)/8.190847372888073e7 <= 1.0e-4
# File = "mholestr2-s1.vtk"
# vtkexportmesh(File, fens, fes; scalars=[("sigma_1", fld.values)], vectors=[("u", u.values)])
# @async run(`"paraview.exe" $File`)
fld = fieldfromintegpoints(femm, geom, u, :maxshear, 1)
@test norm(maximum(fld.values) - 2.2102738887214257) / 2.2102738887214257 <= 1.0e-4
# File = "mholestr2-maxshear.vtk"
# vtkexportmesh(File, fens, fes; scalars=[("maxshear", fld.values)], vectors=[("u", u.values)])
# @async run(`"paraview.exe" $File`)
end
end
using .mholestr2
mholestr2.test()
module mholestr3
using FinEtools
using FinEtools.AlgoBaseModule: matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using Test
using LinearAlgebra: norm, cholesky, cross, Symmetric
function test()
E = 100.0
nu = 1.0 / 3
cte = 0.15
xradius = 1.0
yradius = 1.0
L = 3.0
H = 3.0
# nL = 50
# nH = 50
# nW = 70
nL = 100
nH = 100
nW = 120
tolerance = min(xradius, yradius, L, H) / min(nL, nH, nW) / 1000.0#Geometrical tolerance
fens, fes = Q4elliphole(xradius, yradius, L, H, nL, nH, nW)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
l1 = selectnode(fens; box = [0, 0, -Inf, Inf], inflate = tolerance)
setebc!(u, l1, 1, 0.0)
l2 = selectnode(fens; box = [-Inf, Inf, 0, 0], inflate = tolerance)
setebc!(u, l2, 2, 0.0)
applyebc!(u)
numberdofs!(u)
boundaryfes = meshboundary(fes)
lce = selectelem(
fens,
boundaryfes,
facing = true,
direction = x -> -x,
inflate = tolerance,
)
lc = connectednodes(subset(boundaryfes, lce))
le = selectelem(fens, boundaryfes, box = [-Inf, Inf, H, H], inflate = tolerance)
el1femm = FEMMBase(IntegDomain(subset(boundaryfes, le), GaussRule(1, 2)))
fi = ForceIntensity([0.0, -1.0])
Fm = distribloads(el1femm, geom, u, fi, 2)
le = selectelem(fens, boundaryfes, box = [L, L, -Inf, Inf], inflate = tolerance)
el2femm = FEMMBase(IntegDomain(subset(boundaryfes, le), GaussRule(1, 2)))
fi = ForceIntensity([1.0, 0.0])
Fm += distribloads(el2femm, geom, u, fi, 2)
MR = DeforModelRed2DStress
material = MatDeforElastIso(MR, 0.0, E, nu, cte)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 2)), material)
K = stiffness(femm, geom, u)
K_ff, K_fd = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[(:ff, :fd)]
F_f = vector_blocked(Fm, nfreedofs(u))[:f]
U_d = gathersysvec(u, :d)
factor = cholesky(Symmetric(K_ff))
U_f = factor \ F_f
scattersysvec!(u, U_f)
fld = fieldfromintegpoints(femm, geom, u, :princCauchy, 1)
# @test norm(maximum(fld.values) - 8.190847372888073e7)/8.190847372888073e7 <= 1.0e-4
File = "mholestr3-s1.vtk"
vtkexportmesh(
File,
fens,
fes;
scalars = [("sigma_1", fld.values)],
vectors = [("u", u.values)],
)
#@async run(`"paraview.exe" $File`)
fld = fieldfromintegpoints(femm, geom, u, :maxshear, 1)
@test norm(maximum(fld.values) - 5.921999943843146) / 5.921999943843146 <= 1.0e-4
# File = "mholestr3-maxshear.vtk"
# vtkexportmesh(File, fens, fes; scalars=[("maxshear", fld.values)], vectors=[("u", u.values)])
# @async run(`"paraview.exe" $File`)
end
end
using .mholestr3
mholestr3.test()
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 37888 |
module m111ocylpull14nnn # From miscellaneous
using FinEtools
using FinEtools.AlgoBaseModule: matrix_blocked, vector_blocked
using FinEtoolsDeforLinear
using LinearAlgebra
using Test
function test()
# Cylinder compressed by enforced displacement, axially symmetric model
# Parameters:
E1 = 1.0
E2 = 1.0
E3 = 3.0
nu12 = 0.29
nu13 = 0.29
nu23 = 0.19
G12 = 0.3
G13 = 0.3
G23 = 0.3
p = 0.15
rin = 1.0
rex = 1.2
Length = 1 * rex
ua = -0.05 * Length
tolerance = rin / 1000.0
##
# Note that the FinEtools objects needs to be created with the proper
# model-dimension reduction at hand. In this case that is the axial symmetry
# assumption.
MR = DeforModelRed2DAxisymm
fens, fes = Q4block(rex - rin, Length, 5, 20)
fens.xyz[:, 1] = fens.xyz[:, 1] .+ rin
bdryfes = meshboundary(fes)
# now we create the geometry and displacement fields
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2)) # displacement field
# the symmetry plane
l1 = selectnode(fens; box = [0 rex 0 0], inflate = tolerance)
setebc!(u, l1, true, 2, 0.0)
# The other end
l1 = selectnode(fens; box = [0 rex Length Length], inflate = tolerance)
setebc!(u, l1, true, 2, ua)
applyebc!(u)
numberdofs!(u)
# println("Number of degrees of freedom = $(nfreedofs(u))")
@test nfreedofs(u) == 240
# Property and material
material = MatDeforElastIso(MR, 00.0, E1, nu23, 0.0)
# display(material)
# println("$(material.D)")
# @show MR
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 2), true), material)
K = stiffness(femm, geom, u)
K_ff, K_fd = matrix_blocked(K, nfreedofs(u), nfreedofs(u))[(:ff, :fd)]
U_d = gathersysvec(u, :d)
factor = cholesky(Symmetric(K_ff))
U_f = factor \ (-K_fd * U_d)
scattersysvec!(u, U_f)
fld = fieldfromintegpoints(femm, geom, u, :princCauchy, 1)
# println("Minimum/maximum = $(minimum(fld.values))/$(maximum(fld.values))")
@test abs(minimum(fld.values) - 0.0) < 1.0e-5
@test abs(maximum(fld.values) - 0.0) < 1.0e-5
fld = fieldfromintegpoints(femm, geom, u, :princCauchy, 2)
# println("Minimum/maximum = $(minimum(fld.values))/$(maximum(fld.values))")
@test abs(minimum(fld.values) - 0.0) < 1.0e-5
@test abs(maximum(fld.values) - 0.0) < 1.0e-5
fld = fieldfromintegpoints(femm, geom, u, :princCauchy, 3)
# println("Minimum/maximum = $(minimum(fld.values))/$(maximum(fld.values))")
@test abs(minimum(fld.values) - -0.050) < 1.0e-5
@test abs(maximum(fld.values) - -0.04999999999999919) < 1.0e-5
# File = "mocylpull14.vtk"
# vtkexportmesh(File, fens, fes; scalars=[("sigmaz", fld.values)],
# vectors=[("u", u.values)])
# @async run(`"paraview.exe" $File`)
end
end
using .m111ocylpull14nnn
m111ocylpull14nnn.test()
module mophysun13 # From miscellaneous
using FinEtools
using FinEtoolsDeforLinear
using Test
function test()
E1 = 1.0
nu23 = 0.19
rin = 1.0
rex = 1.2
Length = 1 * rex
tolerance = rin / 1000.0
MR = DeforModelRed2DAxisymm
fens, fes = Q4block(rex - rin, Length, 5, 20)
fens.xyz[:, 1] = fens.xyz[:, 1] .+ rin
bdryfes = meshboundary(fes)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 2))
l1 = selectnode(fens; box = [0 rex 0 0], inflate = tolerance)
setebc!(u, l1, true, 2, 0.0)
l1 = selectnode(fens; box = [0 rex Length Length], inflate = tolerance)
setebc!(u, l1, true, 2, 0.0)
applyebc!(u)
numberdofs!(u)
@test nfreedofs(u) == 240
material = MatDeforElastIso(MR, 00.0, E1, nu23, 0.0)
# println("success? ")
# @code_llvm FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 2), true), material, true)
# femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 2), true), material, true)
# println("failure? ")
# @code_llvm FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 2), true), material)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 2), true), material)
true
end
end
using .mophysun13
mophysun13.test()
module m111ocylpull14n1 # From miscellaneous
using FinEtools
using FinEtoolsDeforLinear
using Test
function test()
E1 = 1.0
nu23 = 0.19
rin = 1.0
rex = 1.2
Length = 1 * rex
MR = DeforModelRed2DAxisymm
fens, fes = Q4block(rex - rin, Length, 5, 20)
material = MatDeforElastIso(MR, 00.0, E1, nu23, 0.0)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(2, 2), true), material)
femm.mr == MR
true
end
end
using .m111ocylpull14n1
m111ocylpull14n1.test()
module mocylpull14a
using FinEtools
using FinEtoolsDeforLinear
using Test
function test()
MR = DeforModelRed2DAxisymm
material = MatDeforElastIso(MR, 0.0, 1.0, 0.0, 0.0)
@test MR == material.mr
femm = FEMMDeforLinear(
MR,
IntegDomain(FESetP1(reshape([1], 1, 1)), GaussRule(2, 2), true),
material,
)
end
end
using .mocylpull14a
mocylpull14a.test()
module mstressconversionm
using FinEtools
using FinEtoolsDeforLinear
using Test
import LinearAlgebra: norm
function test()
symmtens(N) = begin
t = rand(N, N)
t = (t + t') / 2.0
end
t = symmtens(2)
v = zeros(3)
strainttov!(DeforModelRed2DStrain, v, t)
to = zeros(2, 2)
strainvtot!(DeforModelRed2DStrain, to, v)
@test norm(t - to) < eps(1.0)
t = symmtens(3)
v = zeros(6)
strainttov!(DeforModelRed3D, v, t)
to = zeros(3, 3)
strainvtot!(DeforModelRed3D, to, v)
@test norm(t - to) < eps(1.0)
t = symmtens(2)
v = zeros(3)
stressttov!(DeforModelRed2DStress, v, t)
to = zeros(2, 2)
stressvtot!(DeforModelRed2DStress, to, v)
@test norm(t - to) < eps(1.0)
v = vec([1.0 2.0 3.0])
t = zeros(3, 3)
stressvtot!(DeforModelRed2DStrain, t, v)
to = [1.0 3.0 0; 3.0 2.0 0; 0 0 0]
@test norm(t - to) < eps(1.0)
v = vec([1.0 2 3 4])
t = zeros(3, 3)
stressvtot!(DeforModelRed2DStrain, t, v)
to = [1.0 3 0; 3 2 0; 0 0 4]
@test norm(t - to) < eps(1.0)
v = rand(6)
t = zeros(3, 3)
stressvtot!(DeforModelRed3D, t, v)
vo = zeros(6)
stressttov!(DeforModelRed3D, vo, t)
@test norm(v - vo) < eps(1.0)
# v = rand(9)
# t = zeros(3, 3)
# strain9vto3x3t!(t, v)
# t = (t + t')/2.0 # symmetrize
# strain3x3tto9v!(v, t)
# v6 = zeros(6)
# strain9vto6v!(v6, v)
# v9 = zeros(9)
# strain6vto9v!(v9, v6)
# @test norm(v-v9) < eps(1.0)
# v = vec([1. 2 3 4 4 5 5 6 6])
# v6 = zeros(6)
# stress9vto6v!(v6, v)
# v9 = zeros(9)
# stress6vto9v!(v9, v6)
# @test norm(v-v9) < eps(1.0)
end
end
using .mstressconversionm
mstressconversionm.test()
module mmmtdt1a
using FinEtools
using FinEtoolsDeforLinear
using LinearAlgebra
using Test
function test()
MR = DeforModelRed3D
symmet(a) = a + transpose(a)
a = rand(3, 3)
@test abs(det(a) - dett(MR, a)) / abs(det(a)) <= 1.0e-6
a = rand(3, 3)
@test abs(det(a) - dett(MR, a)) / abs(det(a)) <= 1.0e-6
a = rand(3, 3)
@test abs(det(a) - dett(MR, a)) / abs(det(a)) <= 1.0e-6
a = symmet(rand(3, 3))
@test abs(det(a) - dett(MR, a)) / abs(det(a)) <= 1.0e-6
a = rand(3, 3)
@test abs(det(a) - dett(MR, a)) / abs(det(a)) <= 1.0e-6
a = rand(3, 3)
@test abs(det(a) - dett(MR, a)) / abs(det(a)) <= 1.0e-6
a = rand(3, 3)
@test abs(det(a) - dett(MR, a)) / abs(det(a)) <= 1.0e-6
a = symmet(rand(3, 3))
@test abs(det(a) - dett(MR, a)) / abs(det(a)) <= 1.0e-6
a = symmet(rand(3, 3))
av = fill(zero(eltype(a)), 6)
strainttov!(MR, av, a)
@test abs(det(a) - strainvdet(MR, av)) / abs(det(a)) <= 1.0e-6
a = symmet(rand(3, 3))
av = fill(zero(eltype(a)), 6)
strainttov!(MR, av, a)
@test abs(det(a) - strainvdet(MR, av)) / abs(det(a)) <= 1.0e-6
a = symmet(rand(3, 3))
av = fill(zero(eltype(a)), 6)
strainttov!(MR, av, a)
@test abs(det(a) - strainvdet(MR, av)) / abs(det(a)) <= 1.0e-6
a = symmet(rand(3, 3))
av = fill(zero(eltype(a)), 6)
strainttov!(MR, av, a)
@test abs(det(a) - strainvdet(MR, av)) / abs(det(a)) <= 1.0e-6
a = symmet(rand(3, 3))
av = fill(zero(eltype(a)), 6)
strainttov!(MR, av, a)
@test abs(det(a) - strainvdet(MR, av)) / abs(det(a)) <= 1.0e-6
a = symmet(rand(3, 3))
av = fill(zero(eltype(a)), 6)
strainttov!(MR, av, a)
@test abs(det(a) - strainvdet(MR, av)) / abs(det(a)) <= 1.0e-6
a = symmet(rand(3, 3))
av = fill(zero(eltype(a)), 6)
strainttov!(MR, av, a)
@test abs(tr(a) - strainvtr(MR, av)) / abs(tr(a)) <= 1.0e-6
a = symmet(rand(3, 3))
av = fill(zero(eltype(a)), 6)
strainttov!(MR, av, a)
@test abs(tr(a) - strainvtr(MR, av)) / abs(tr(a)) <= 1.0e-6
a = symmet(rand(3, 3))
av = fill(zero(eltype(a)), 6)
strainttov!(MR, av, a)
@test abs(tr(a) - strainvtr(MR, av)) / abs(tr(a)) <= 1.0e-6
end
end
using .mmmtdt1a
mmmtdt1a.test()
module mmmtdt2
using FinEtools
using FinEtoolsDeforLinear
using LinearAlgebra
using Test
function test()
MR = DeforModelRed2DStrain
symmet(a) = a + transpose(a)
a = rand(2, 2)
@test abs(det(a) - dett(MR, a)) / abs(det(a)) <= 1.0e-6
a = rand(2, 2)
@test abs(det(a) - dett(MR, a)) / abs(det(a)) <= 1.0e-6
a = rand(2, 2)
@test abs(det(a) - dett(MR, a)) / abs(det(a)) <= 1.0e-6
a = symmet(rand(2, 2))
@test abs(det(a) - dett(MR, a)) / abs(det(a)) <= 1.0e-6
a = rand(2, 2)
@test abs(det(a) - dett(MR, a)) / abs(det(a)) <= 1.0e-6
a = rand(2, 2)
@test abs(det(a) - dett(MR, a)) / abs(det(a)) <= 1.0e-6
a = rand(2, 2)
@test abs(det(a) - dett(MR, a)) / abs(det(a)) <= 1.0e-6
a = symmet(rand(2, 2))
@test abs(det(a) - dett(MR, a)) / abs(det(a)) <= 1.0e-6
a = symmet(rand(2, 2))
av = fill(zero(eltype(a)), 6)
strainttov!(MR, av, a)
@test abs(det(a) - strainvdet(MR, av)) / abs(det(a)) <= 1.0e-6
a = symmet(rand(2, 2))
av = fill(zero(eltype(a)), 6)
strainttov!(MR, av, a)
@test abs(det(a) - strainvdet(MR, av)) / abs(det(a)) <= 1.0e-6
a = symmet(rand(2, 2))
av = fill(zero(eltype(a)), 6)
strainttov!(MR, av, a)
@test abs(det(a) - strainvdet(MR, av)) / abs(det(a)) <= 1.0e-6
a = symmet(rand(2, 2))
av = fill(zero(eltype(a)), 6)
strainttov!(MR, av, a)
@test abs(det(a) - strainvdet(MR, av)) / abs(det(a)) <= 1.0e-6
a = symmet(rand(2, 2))
av = fill(zero(eltype(a)), 6)
strainttov!(MR, av, a)
@test abs(det(a) - strainvdet(MR, av)) / abs(det(a)) <= 1.0e-6
a = symmet(rand(2, 2))
av = fill(zero(eltype(a)), 6)
strainttov!(MR, av, a)
@test abs(det(a) - strainvdet(MR, av)) / abs(det(a)) <= 1.0e-6
MR = DeforModelRed2DStrain
a = symmet(rand(2, 2))
av = fill(zero(eltype(a)), 3)
strainttov!(MR, av, a)
@test abs(tr(a) - strainvtr(MR, av)) / abs(tr(a)) <= 1.0e-6
a = symmet(rand(2, 2))
av = fill(zero(eltype(a)), 3)
strainttov!(MR, av, a)
@test abs(tr(a) - strainvtr(MR, av)) / abs(tr(a)) <= 1.0e-6
a = symmet(rand(2, 2))
av = fill(zero(eltype(a)), 3)
strainttov!(MR, av, a)
@test abs(tr(a) - strainvtr(MR, av)) / abs(tr(a)) <= 1.0e-6
end
end
using .mmmtdt2
mmmtdt2.test()
module mmtwistedeexportmm
using FinEtools
using FinEtoolsDeforLinear
using Test
using FinEtools.MeshExportModule
function test()
E = 0.29e8
nu = 0.22
W = 1.1
L = 12.0
t = 0.32
nl = 2
nt = 1
nw = 1
ref = 3
p = 1 / W / t
# Loading in the Z direction
loadv = [0; 0; p]
dir = 3
uex = 0.005424534868469 # Harder: 5.424e-3;
# Loading in the Y direction
#loadv = [0;p;0]; dir = 2; uex = 0.001753248285256; # Harder: 1.754e-3;
tolerance = t / 1000
fens, fes = H8block(L, W, t, nl * ref, nw * ref, nt * ref)
# Reshape into a twisted beam shape
for i = 1:count(fens)
a = fens.xyz[i, 1] / L * (pi / 2)
y = fens.xyz[i, 2] - (W / 2)
z = fens.xyz[i, 3] - (t / 2)
fens.xyz[i, :] = [fens.xyz[i, 1], y * cos(a) - z * sin(a), y * sin(a) + z * cos(a)]
end
# Clamped end of the beam
l1 =
selectnode(fens; box = [0 0 -100 * W 100 * W -100 * W 100 * W], inflate = tolerance)
e1 = FDataDict("node_list" => l1, "component" => 1, "displacement" => 0.0)
e2 = FDataDict("node_list" => l1, "component" => 2, "displacement" => 0.0)
e3 = FDataDict("node_list" => l1, "component" => 3, "displacement" => 0.0)
# Traction on the opposite edge
boundaryfes = meshboundary(fes)
Toplist = selectelem(
fens,
boundaryfes,
box = [L L -100 * W 100 * W -100 * W 100 * W],
inflate = tolerance,
)
el1femm = FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(2, 2)))
flux1 = FDataDict("femm" => el1femm, "traction_vector" => loadv)
# Make the region
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 00.0, E, nu, 0.0)
region1 = FDataDict(
"femm" => FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material),
)
# Make model data
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [e1, e2, e3],
"traction_bcs" => [flux1],
)
AE = AbaqusExporter("twisted_beam")
HEADING(AE, "Twisted beam example")
PART(AE, "part1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
ELEMENT(AE, "c3d8rh", "AllElements", 1, connasarray(region1["femm"].integdomain.fes))
ELEMENT(
AE,
"SFM3D4",
"TractionElements",
1 + count(region1["femm"].integdomain.fes),
connasarray(flux1["femm"].integdomain.fes),
)
NSET_NSET(AE, "l1", l1)
ORIENTATION(AE, "GlobalOrientation", vec([1.0 0 0]), vec([0 1.0 0]))
SOLID_SECTION(AE, "elasticity", "GlobalOrientation", "AllElements", "Hourglass")
SURFACE_SECTION(AE, "TractionElements")
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "elasticity")
ELASTIC(AE, E, nu)
SECTION_CONTROLS(AE, "section1", "HOURGLASS=ENHANCED")
STEP_PERTURBATION_STATIC(AE)
BOUNDARY(AE, "ASSEM1.INSTNC1.l1", 1)
BOUNDARY(AE, "ASSEM1.INSTNC1.l1", 2)
BOUNDARY(AE, "ASSEM1.INSTNC1.l1", 3)
DLOAD(AE, "ASSEM1.INSTNC1.TractionElements", vec(flux1["traction_vector"]))
END_STEP(AE)
close(AE)
nlines = 0
open("twisted_beam.inp") do f
s = readlines(f)
nlines = length(s)
end
@test nlines == 223
rm("twisted_beam.inp")
true
end
end
using .mmtwistedeexportmm
mmtwistedeexportmm.test()
module mmtwistedeexport2mm
using FinEtools
using FinEtoolsDeforLinear
using Test
using FinEtools.MeshExportModule
function test()
E = 0.29e8
nu = 0.22
W = 1.1
L = 12.0
t = 0.32
nl = 2
nt = 1
nw = 1
ref = 3
p = 1 / W / t
# Loading in the Z direction
loadv = [0; 0; p]
dir = 3
uex = 0.005424534868469 # Harder: 5.424e-3;
# Loading in the Y direction
#loadv = [0;p;0]; dir = 2; uex = 0.001753248285256; # Harder: 1.754e-3;
tolerance = t / 1000
fens, fes = H8block(L, W, t, nl * ref, nw * ref, nt * ref)
# Reshape into a twisted beam shape
for i = 1:count(fens)
a = fens.xyz[i, 1] / L * (pi / 2)
y = fens.xyz[i, 2] - (W / 2)
z = fens.xyz[i, 3] - (t / 2)
fens.xyz[i, :] = [fens.xyz[i, 1], y * cos(a) - z * sin(a), y * sin(a) + z * cos(a)]
end
# Clamped end of the beam
l1 =
selectnode(fens; box = [0 0 -100 * W 100 * W -100 * W 100 * W], inflate = tolerance)
e1 = FDataDict("node_list" => l1, "component" => 1, "displacement" => 0.0)
e2 = FDataDict("node_list" => l1, "component" => 2, "displacement" => 0.0)
e3 = FDataDict("node_list" => l1, "component" => 3, "displacement" => 0.0)
# Traction on the opposite edge
boundaryfes = meshboundary(fes)
Toplist = selectelem(
fens,
boundaryfes,
box = [L L -100 * W 100 * W -100 * W 100 * W],
inflate = tolerance,
)
el1femm = FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(2, 2)))
flux1 = FDataDict("femm" => el1femm, "traction_vector" => loadv)
# Make the region
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 00.0, E, nu, 0.0)
region1 = FDataDict(
"femm" => FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material),
)
# Make model data
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [e1, e2, e3],
"traction_bcs" => [flux1],
)
AE = AbaqusExporter("twisted_beam")
HEADING(AE, "Twisted beam example")
PART(AE, "part1")
END_PART(AE)
ASSEMBLY(AE, "ASSEM1")
INSTANCE(AE, "INSTNC1", "PART1")
NODE(AE, fens.xyz)
ELEMENT(AE, "c3d8rh", "AllElements", 1, connasarray(region1["femm"].integdomain.fes))
ELEMENT(
AE,
"SFM3D4",
"TractionElements",
1 + count(region1["femm"].integdomain.fes),
connasarray(flux1["femm"].integdomain.fes),
)
NSET_NSET(AE, "l1", l1)
ORIENTATION(AE, "GlobalOrientation", vec([1.0 0 0]), vec([0 1.0 0]))
SOLID_SECTION(AE, "elasticity", "GlobalOrientation", "AllElements", "Hourglass")
SURFACE_SECTION(AE, "TractionElements")
END_INSTANCE(AE)
END_ASSEMBLY(AE)
MATERIAL(AE, "elasticity")
ELASTIC(AE, E, nu)
SECTION_CONTROLS(AE, "section1", "HOURGLASS=ENHANCED")
STEP_PERTURBATION_STATIC(AE)
BOUNDARY(AE, "ASSEM1.INSTNC1.l1", 1, 0.0)
BOUNDARY(AE, "ASSEM1.INSTNC1.l1", 2, 0.0)
BOUNDARY(AE, "ASSEM1.INSTNC1.l1", 3, 0.0)
DLOAD(AE, "ASSEM1.INSTNC1.TractionElements", vec(flux1["traction_vector"]))
END_STEP(AE)
close(AE)
nlines = 0
open("twisted_beam.inp") do f
s = readlines(f)
nlines = length(s)
end
@test nlines == 223
rm("twisted_beam.inp")
true
end
end
using .mmtwistedeexport2mm
mmtwistedeexport2mm.test()
module mstresscomponentmap
using FinEtools
using FinEtoolsDeforLinear
using Test
function test()
MR = DeforModelRed1D
@test stresscomponentmap(MR)[:x] == 1
MR = DeforModelRed2DAxisymm
@test stresscomponentmap(MR)[:x] == 1
@test stresscomponentmap(MR)[:zz] == 3
end
end
using .mstresscomponentmap
mstresscomponentmap.test()
module mmMeasurement_3a
using FinEtools
using FinEtoolsDeforLinear
using Test
function test()
W = 1.1
L = 12.0
t = 3.32
nl, nt, nw = 5, 3, 4
Ea = 210000 * phun("MEGA*Pa")
nua = 0.3
# println("New segmentation fault?")
for orientation in [:a :b :ca :cb]
fens, fes = T4block(L, W, t, nl, nw, nt, orientation)
geom = NodalField(fens.xyz)
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, Ea, nua, 0.0)
femm = FEMMDeforLinearNICET4(MR, IntegDomain(fes, NodalSimplexRule(3)), material)
V = integratefunction(femm, geom, (x) -> 1.0)
@test abs(V - W * L * t) / V < 1.0e-5
end
end
end
using .mmMeasurement_3a
mmMeasurement_3a.test()
module mmvgradmat1
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.FEMMDeforLinearBaseModule: infsup_sh
using Test
import LinearAlgebra: norm, cholesky
function test()
Length, Width, Height, nL, nW, nH, orientation::Symbol = (1.0, 1.0, 1.0, 1, 1, 1, :a)
Ea, nua, alphaa = (1.0, 0.3, 0.0)
fens = FENodeSet(Float64[
0 0 0
0 3 3
0 0 3
3 0 3
])
fes = FESetT4(reshape([1 2 3 4], 1, 4))
MR = DeforModelRed3D
# Property and material
material = MatDeforElastIso(MR, 0.0, Ea, nua, alphaa)
femm = FEMMDeforLinear(MR, IntegDomain(fes, TetRule(1)), material)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
Sh = infsup_sh(femm, geom, u)
Sh1 = [
0.5 0 0 0 0 0 -0.5 0 0 -0.0000 0 0
0 0.5 0 0 0 0 0 -0.5 0 0 -0.0000 0
0 0 0.5 0 0 0 0 0 -0.5 0 0 -0.0000
0 0 0 0.5 0 0 -0.5 0 0 0 0 0
0 0 0 0 0.5 0 0 -0.5 0 0 0 0
0 0 0 0 0 0.5 0 0 -0.5 0 0 0
-0.5 0 0 -0.5 0 0 1.5000 0 0 -0.5 0 0
0 -0.5 0 0 -0.5 0 0 1.5000 0 0 -0.5 0
0 0 -0.5 0 0 -0.5 0 0 1.5000 0 0 -0.5
-0.0000 0 0 0 0 0 -0.5 0 0 0.5 0 0
0 -0.0000 0 0 0 0 0 -0.5 0 0 0.5 0
0 0 -0.0000 0 0 0 0 0 -0.5 0 0 0.5
]
@test norm(Sh - Sh1) <= 1.0e-9
end
end
using .mmvgradmat1
mmvgradmat1.test()
module mmdivmat2
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.FEMMDeforLinearBaseModule: infsup_gh
using Test
import LinearAlgebra: norm, cholesky
function test()
Length, Width, Height, nL, nW, nH, orientation::Symbol = (1.0, 1.0, 1.0, 1, 1, 1, :a)
Ea, nua, alphaa = (1.0, 0.3, 0.0)
fens = FENodeSet(
Float64[
0 0 0
-1.6200e-01 3.0000e+00 2.9791e+00
0 0 3.0000e+00
3.0000e+00 1.6200e-01 3.0000e+00
],
)
fes = FESetT4(reshape([1 2 3 4], 1, 4))
MR = DeforModelRed3D
# Property and material
material = MatDeforElastIso(MR, 0.0, Ea, nua, alphaa)
femm = FEMMDeforLinear(MR, IntegDomain(fes, TetRule(4)), material)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
Gh = infsup_gh(femm, geom, u)
Gh1 = [
7.0319e-08 -1.3022e-06 -1.8778e-04 -1.0111e-05 1.8724e-04 0 -1.7720e-04 -1.9604e-04 1.8778e-04 1.8724e-04 1.0111e-05 0
-1.3022e-06 2.4115e-05 3.4774e-03 1.8724e-04 -3.4673e-03 0 3.2814e-03 3.6305e-03 -3.4774e-03 -3.4673e-03 -1.8724e-04 0
-1.8778e-04 3.4774e-03 5.0146e-01 2.7000e-02 -5.0000e-01 0 4.7319e-01 5.2352e-01 -5.0146e-01 -5.0000e-01 -2.7000e-02 0
-1.0111e-05 1.8724e-04 2.7000e-02 1.4538e-03 -2.6921e-02 0 2.5478e-02 2.8188e-02 -2.7000e-02 -2.6921e-02 -1.4538e-03 0
1.8724e-04 -3.4673e-03 -5.0000e-01 -2.6921e-02 4.9855e-01 0 -4.7181e-01 -5.2200e-01 5.0000e-01 4.9855e-01 2.6921e-02 0
0 0 0 0 0 0 0 0 0 0 0 0
-1.7720e-04 3.2814e-03 4.7319e-01 2.5478e-02 -4.7181e-01 0 4.4651e-01 4.9401e-01 -4.7319e-01 -4.7181e-01 -2.5478e-02 0
-1.9604e-04 3.6305e-03 5.2352e-01 2.8188e-02 -5.2200e-01 0 4.9401e-01 5.4656e-01 -5.2352e-01 -5.2200e-01 -2.8188e-02 0
1.8778e-04 -3.4774e-03 -5.0146e-01 -2.7000e-02 5.0000e-01 0 -4.7319e-01 -5.2352e-01 5.0146e-01 5.0000e-01 2.7000e-02 0
1.8724e-04 -3.4673e-03 -5.0000e-01 -2.6921e-02 4.9855e-01 0 -4.7181e-01 -5.2200e-01 5.0000e-01 4.9855e-01 2.6921e-02 0
1.0111e-05 -1.8724e-04 -2.7000e-02 -1.4538e-03 2.6921e-02 0 -2.5478e-02 -2.8188e-02 2.7000e-02 2.6921e-02 1.4538e-03 0
0 0 0 0 0 0 0 0 0 0 0 0
]
# @show Matrix(Gh)
@test norm(Gh - Gh1) / norm(Gh1) <= 2.0e-5
end
end
using .mmdivmat2
mmdivmat2.test()
module mmvgradmat2
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.FEMMDeforLinearBaseModule: infsup_sh
using Test
import LinearAlgebra: norm, cholesky
function test()
Length, Width, Height, nL, nW, nH, orientation::Symbol = (1.0, 1.0, 1.0, 1, 1, 1, :a)
Ea, nua, alphaa = (1.0, 0.3, 0.0)
fens = FENodeSet(Float64[
0 0 0
-0.1620 3.0000 2.9791
0 0 3.0000
3.0000 0.1620 3.0000
])
fes = FESetT4(reshape([1 2 3 4], 1, 4))
MR = DeforModelRed3D
# Property and material
material = MatDeforElastIso(MR, 0.0, Ea, nua, alphaa)
femm = FEMMDeforLinear(MR, IntegDomain(fes, TetRule(1)), material)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
Sh = infsup_sh(femm, geom, u)
Sh1 = [
5.0148e-01 0 0 -3.4774e-03 0 0 -4.9800e-01 0 0 -2.6321e-17 0 0
0 5.0148e-01 0 0 -3.4774e-03 0 0 -4.9800e-01 0 0 -2.6321e-17 0
0 0 5.0148e-01 0 0 -3.4774e-03 0 0 -4.9800e-01 0 0 -2.6321e-17
-3.4774e-03 0 0 5.0000e-01 0 0 -4.9652e-01 0 0 -4.7374e-18 0 0
0 -3.4774e-03 0 0 5.0000e-01 0 0 -4.9652e-01 0 0 -4.7374e-18 0
0 0 -3.4774e-03 0 0 5.0000e-01 0 0 -4.9652e-01 0 0 -4.7374e-18
-4.9800e-01 0 0 -4.9652e-01 0 0 1.4945e+00 0 0 -5.0000e-01 0 0
0 -4.9800e-01 0 0 -4.9652e-01 0 0 1.4945e+00 0 0 -5.0000e-01 0
0 0 -4.9800e-01 0 0 -4.9652e-01 0 0 1.4945e+00 0 0 -5.0000e-01
-2.6321e-17 0 0 -4.7374e-18 0 0 -5.0000e-01 0 0 5.0000e-01 0 0
0 -2.6321e-17 0 0 -4.7374e-18 0 0 -5.0000e-01 0 0 5.0000e-01 0
0 0 -2.6321e-17 0 0 -4.7374e-18 0 0 -5.0000e-01 0 0 5.0000e-01
]
@test norm(Sh - Sh1) / norm(Sh1) <= 1.0e-4
end
end
using .mmvgradmat2
mmvgradmat2.test()
module mmdivmat1
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.FEMMDeforLinearBaseModule: infsup_gh
using Test
import LinearAlgebra: norm, cholesky
function test()
Length, Width, Height, nL, nW, nH, orientation::Symbol = (1.0, 1.0, 1.0, 1, 1, 1, :a)
Ea, nua, alphaa = (1.0, 0.3, 0.0)
fens = FENodeSet(Float64[
0 0 0
0 3 3
0 0 3
3 0 3
])
fes = FESetT4(reshape([1 2 3 4], 1, 4))
MR = DeforModelRed3D
# Property and material
material = MatDeforElastIso(MR, 0.0, Ea, nua, alphaa)
femm = FEMMDeforLinear(MR, IntegDomain(fes, TetRule(1)), material)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
Gh = infsup_gh(femm, geom, u)
Gh1 = [
0.0 0 0.0 0 -0.0 0 0.0 0.0 -0.0 -0.0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0.0 0 0.5 0 -0.5 0 0.5 0.5 -0.5 -0.5 0 0
0 0 0 0 0 0 0 0 0 0 0 0
-0.0 0 -0.5 0 0.5 0 -0.5 -0.5 0.5 0.5 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0.0 0 0.5 0 -0.5 0 0.5 0.5 -0.5 -0.5 0 0
0.0 0 0.5 0 -0.5 0 0.5 0.5 -0.5 -0.5 0 0
-0.0 0 -0.5 0 0.5 0 -0.5 -0.5 0.5 0.5 0 0
-0.0 0 -0.5 0 0.5 0 -0.5 -0.5 0.5 0.5 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
]
@test norm(Gh - Gh1) <= 1.0e-9
end
end
using .mmdivmat1
mmdivmat1.test()
module mmmMergem1
using FinEtools
using FinEtoolsDeforLinear
using Test
function test()
h = 0.05 * phun("M")
l = 10 * h
Rmed = h / 0.2
psi = 0 # Cylinder
nh = 12
nl = 40
nc = 120
nh = 6
nl = 20
nc = 60
# nh = 3; nl = 8; nc = 30;
tolerance = h / nh / 100
t0 = time()
MR = DeforModelRed3D
fens, fes = H8block(h, l, 2.0 * pi, nh, nl, nc)
# Shape into a cylinder
R = zeros(3, 3)
for i = 1:count(fens)
x, y, z = fens.xyz[i, :]
rotmat3!(R, [0, z, 0])
Q = [
cos(psi * pi / 180) sin(psi * pi / 180) 0
-sin(psi * pi / 180) cos(psi * pi / 180) 0
0 0 1
]
fens.xyz[i, :] = reshape([x + Rmed - h / 2, y - l / 2, 0], 1, 3) * Q * R
end
# println(" before merging = $(count(fens))")
@test count(fens) == 8967
# File = "unit_cube_modes.vtk"
# vtkexportmesh(File, fens, fes)
# @async run(`"paraview.exe" $File`)
candidates = selectnode(
fens,
box = boundingbox([Rmed-h -Inf 0.0; Rmed+h +Inf 0.0]),
inflate = tolerance,
)
fens, fes = mergenodes(fens, fes, tolerance, candidates)
@test count(fens) == 8820
# fens,fes = mergenodes(fens, fes, tolerance);
# println(" after merging = $(count(fens))")
#
# println("Mesh generation ($(time() - t0) sec)")
#
# File = "unit_cube_modes.vtk"
# vtkexportmesh(File, fens, fes)
# @async run(`"paraview.exe" $File`)
end
end
using .mmmMergem1
mmmMergem1.test()
module mmmMergem2
using FinEtools
using FinEtoolsDeforLinear
using Test
function test()
h = 0.05 * phun("M")
l = 10 * h
Rmed = h / 0.2
psi = 0 # Cylinder
nh = 12
nl = 40
nc = 120
nh = 6
nl = 20
nc = 60
# nh = 3; nl = 8; nc = 30;
tolerance = h / nh / 100
t0 = time()
MR = DeforModelRed3D
fens, fes = H8block(h, l, 2.0 * pi, nh, nl, nc)
# Shape into a cylinder
R = zeros(3, 3)
for i = 1:count(fens)
x, y, z = fens.xyz[i, :]
rotmat3!(R, [0, z, 0])
Q = [
cos(psi * pi / 180) sin(psi * pi / 180) 0
-sin(psi * pi / 180) cos(psi * pi / 180) 0
0 0 1
]
fens.xyz[i, :] = reshape([x + Rmed - h / 2, y - l / 2, 0], 1, 3) * Q * R
end
# println(" before merging = $(count(fens))")
@test count(fens) == 8967
# File = "unit_cube_modes.vtk"
# vtkexportmesh(File, fens, fes)
# @async run(`"paraview.exe" $File`)
candidates = selectnode(fens, plane = [0.0 0.0 1.0 0.0], inflate = tolerance)
fens, fes = mergenodes(fens, fes, tolerance, candidates)
@test count(fens) == 8820
# fens,fes = mergenodes(fens, fes, tolerance);
# println(" after merging = $(count(fens))")
#
# println("Mesh generation ($(time() - t0) sec)")
#
# File = "unit_cube_modes.vtk"
# vtkexportmesh(File, fens, fes)
# @async run(`"paraview.exe" $File`)
end
end
using .mmmMergem2
mmmMergem2.test()
module mmmMergem3
using FinEtools
using FinEtoolsDeforLinear
using Test
function test()
h = 0.05 * phun("M")
l = 10 * h
Rmed = h / 0.2
psi = 0 # Cylinder
nh = 12
nl = 40
nc = 120
nh = 6
nl = 20
nc = 60
# nh = 3; nl = 8; nc = 30;
tolerance = h / nh / 100
t0 = time()
MR = DeforModelRed3D
fens, fes = H8block(h, l, 2.0 * pi, nh, nl, nc)
# Shape into a cylinder
R = zeros(3, 3)
for i = 1:count(fens)
x, y, z = fens.xyz[i, :]
rotmat3!(R, [0, z, 0])
Q = [
cos(psi * pi / 180) sin(psi * pi / 180) 0
-sin(psi * pi / 180) cos(psi * pi / 180) 0
0 0 1
]
fens.xyz[i, :] = reshape([x + Rmed - h / 2, y - l / 2, 0], 1, 3) * Q * R
end
# println(" before merging = $(count(fens))")
@test count(fens) == 8967
# File = "unit_cube_modes.vtk"
# vtkexportmesh(File, fens, fes)
# @async run(`"paraview.exe" $File`)
candidates = selectnode(fens, plane = [0.0 0.0 1.0 0.0], thickness = h / 1000)
fens, fes = mergenodes(fens, fes, tolerance, candidates)
@test count(fens) == 8820
# fens,fes = mergenodes(fens, fes, tolerance);
# println(" after merging = $(count(fens))")
#
# println("Mesh generation ($(time() - t0) sec)")
#
# File = "unit_cube_modes.vtk"
# vtkexportmesh(File, fens, fes)
# @async run(`"paraview.exe" $File`)
end
end
using .mmmMergem3
mmmMergem3.test()
module mtwistedalgofin # From miscellaneous
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear.AlgoDeforLinearModule
using Statistics
using LinearAlgebra: norm
using Test
function test()
# println("""
# The initially twisted cantilever beam is one of the standard test problems for verifying the finite-element accuracy [1]. The beam is clamped at one end and loaded either with unit in-plane or unit out-of-plane force at the other. The centroidal axis of the beam s
# straight at the undeformed configuration, while its cross-sections are
# twisted about the centroidal axis from 0 at the clamped end to pi/2 at
# the free end.
#
# Reference:
# Zupan D, Saje M (2004) On "A proposed standard set of problems to test
# finite element accuracy": the twisted beam. Finite Elements in Analysis
# and Design 40: 1445-1451.
# """)
E = 0.29e8
nu = 0.22
W = 1.1
L = 12.0
t = 0.32
nl = 2
nt = 1
nw = 1
ref = 4
p = 1 / W / t
# Loading in the Z direction
loadv = [0; 0; p]
dir = 3
uex = 0.005424534868469 # Harder: 5.424e-3;
# Loading in the Y direction
#loadv = [0;p;0]; dir = 2; uex = 0.001753248285256; # Harder: 1.754e-3;
tolerance = t / 1000
fens, fes = H8block(L, W, t, nl * ref, nw * ref, nt * ref)
# Reshape into a twisted beam shape
for i = 1:count(fens)
a = fens.xyz[i, 1] / L * (pi / 2)
y = fens.xyz[i, 2] - (W / 2)
z = fens.xyz[i, 3] - (t / 2)
fens.xyz[i, :] = [fens.xyz[i, 1], y * cos(a) - z * sin(a), y * sin(a) + z * cos(a)]
end
# Clamped end of the beam
l1 =
selectnode(fens; box = [0 0 -100 * W 100 * W -100 * W 100 * W], inflate = tolerance)
e1 = FDataDict("node_list" => l1, "component" => 1, "displacement" => 0.0)
e2 = FDataDict("node_list" => l1, "component" => 2, "displacement" => 0.0)
e3 = FDataDict("node_list" => l1, "component" => 3, "displacement" => 0.0)
# Traction on the opposite edge
boundaryfes = meshboundary(fes)
Toplist = selectelem(
fens,
boundaryfes,
box = [L L -100 * W 100 * W -100 * W 100 * W],
inflate = tolerance,
)
el1femm = FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(2, 2)))
flux1 = FDataDict("femm" => el1femm, "traction_vector" => ForceIntensity(loadv))
# Make the region
MR = DeforModelRed3D
material = MatDeforElastIso(MR, 0.0, E, nu, 0.0)
region1 = FDataDict(
"femm" => FEMMDeforLinearMSH8(MR, IntegDomain(fes, GaussRule(3, 2)), material),
)
# Make model data
modeldata = FDataDict(
"fens" => fens,
"regions" => [region1],
"essential_bcs" => [e1, e2, e3],
"traction_bcs" => [flux1],
)
# Call the solver
modeldata = AlgoDeforLinearModule.linearstatics(modeldata)
geom = modeldata["geom"]
u = modeldata["u"]
# Extract the solution
nl =
selectnode(fens, box = [L L -100 * W 100 * W -100 * W 100 * W], inflate = tolerance)
theutip = mean(u.values[nl, :], dims = 1)
# println("displacement = $(theutip[dir]) as compared to converged $uex")
# println("normalized displacement = $(theutip[dir]/uex*100) %")
@test (theutip[dir] - 0.005443006890338948) / 0.005443006890338948 <= 1.0e-6
# Write out mesh with displacements
modeldata["postprocessing"] = FDataDict("file" => "twisted_beam")
modeldata = AlgoDeforLinearModule.exportdeformation(modeldata)
# Write out mesh with stresses
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam", "quantity" => :Cauchy, "component" => :xy)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
# Write out mesh with stresses
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam", "quantity" => :Cauchy, "component" => :xz)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
# Write out mesh with von Mises stresses
modeldata["postprocessing"] = FDataDict("file" => "twisted_beam", "quantity" => :vm)
modeldata = AlgoDeforLinearModule.exportstress(modeldata)
# Write out mesh with von Mises stresses, elementwise
modeldata["postprocessing"] = FDataDict("file" => "twisted_beam-ew", "quantity" => :vm)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
vm = modeldata["postprocessing"]["exported"][1]["field"]
# println("extremes of von Mises: $([minimum(vm.values), maximum(vm.values)])")
@test norm(
[minimum(vm.values), maximum(vm.values)] - [5.21266051216496, 452.7873821727328],
) <= 1.0e-3
# Write out mesh with von Mises stresses, elementwise
modeldata["postprocessing"] =
FDataDict("file" => "twisted_beam-ew", "quantity" => :Cauchy, "component" => :xz)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
# Write out mesh with principal stresses, elementwise
modeldata["postprocessing"] = FDataDict(
"file" => "twisted_beam-principal-1-ew",
"quantity" => :princCauchy,
"component" => 1,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
ps = modeldata["postprocessing"]["exported"][1]["field"]
# println("extremes of first principal stress: $([minimum(ps.values), maximum(ps.values)])")
@test norm(
[minimum(ps.values), maximum(ps.values)] - [-5.9919354276389285, 461.8866079275564],
) <= 1.0e-3
# Write out mesh with principal stresses, elementwise
modeldata["postprocessing"] = FDataDict(
"file" => "twisted_beam-principal-3-ew",
"quantity" => :princCauchy,
"component" => 3,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
ps = modeldata["postprocessing"]["exported"][1]["field"]
# println("extremes of third principal stress: $([minimum(ps.values), maximum(ps.values)])")
@test norm(
[minimum(ps.values), maximum(ps.values)] -
[-461.88660792935354, 5.9919354278587855],
) <= 1.0e-3
# Write out mesh with principal stresses, elementwise
modeldata["postprocessing"] = FDataDict(
"file" => "twisted_beam-press-ew",
"quantity" => :pressure,
"component" => 1,
)
modeldata = AlgoDeforLinearModule.exportstresselementwise(modeldata)
ps = modeldata["postprocessing"]["exported"][1]["field"]
# println("extremes of pressure: $([minimum(ps.values), maximum(ps.values)])")
@test norm(
[minimum(ps.values), maximum(ps.values)] - [-167.8998735447784, 167.89987354544647],
) <= 1.0e-3
try
for f in [
"twisted_beam-Cauchyxy-region 1.vtk",
"twisted_beam-press-ew-pressure1-region 1.vtk",
"twisted_beam-Cauchyxz-region 1.vtk",
"twisted_beam-principal-1-ew-princCauchy1-region 1.vtk",
"twisted_beam-ew-Cauchyxz-region 1.vtk",
"twisted_beam-principal-3-ew-princCauchy3-region 1.vtk",
"twisted_beam1.vtk",
"twisted_beam-ew-vm1-region 1.vtk",
"twisted_beam-vm1-region 1.vtk",
]
rm(f)
end
catch
end
# println("Done")
true
end
end
using .mtwistedalgofin
mtwistedalgofin.test()
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 8862 | module mmmtdt1
using FinEtools
using FinEtoolsDeforLinear
using LinearAlgebra
using Test
function test()
MR = DeforModelRed3D
symmet(a) = a + transpose(a)
a = rand(3, 3)
@test abs(det(a) - dett(MR, a)) / abs(det(a)) <= 1.0e-6
a = rand(3, 3)
@test abs(det(a) - dett(MR, a)) / abs(det(a)) <= 1.0e-6
a = rand(3, 3)
@test abs(det(a) - dett(MR, a)) / abs(det(a)) <= 1.0e-6
a = symmet(rand(3, 3))
@test abs(det(a) - dett(MR, a)) / abs(det(a)) <= 1.0e-6
a = rand(3, 3)
@test abs(det(a) - dett(MR, a)) / abs(det(a)) <= 1.0e-6
a = rand(3, 3)
@test abs(det(a) - dett(MR, a)) / abs(det(a)) <= 1.0e-6
a = rand(3, 3)
@test abs(det(a) - dett(MR, a)) / abs(det(a)) <= 1.0e-6
a = symmet(rand(3, 3))
@test abs(det(a) - dett(MR, a)) / abs(det(a)) <= 1.0e-6
a = symmet(rand(3, 3))
av = fill(zero(eltype(a)), 6)
strainttov!(MR, av, a)
@test abs(det(a) - strainvdet(MR, av)) / abs(det(a)) <= 1.0e-6
a = symmet(rand(3, 3))
av = fill(zero(eltype(a)), 6)
strainttov!(MR, av, a)
@test abs(det(a) - strainvdet(MR, av)) / abs(det(a)) <= 1.0e-6
a = symmet(rand(3, 3))
av = fill(zero(eltype(a)), 6)
strainttov!(MR, av, a)
@test abs(det(a) - strainvdet(MR, av)) / abs(det(a)) <= 1.0e-6
a = symmet(rand(3, 3))
av = fill(zero(eltype(a)), 6)
strainttov!(MR, av, a)
@test abs(det(a) - strainvdet(MR, av)) / abs(det(a)) <= 1.0e-6
a = symmet(rand(3, 3))
av = fill(zero(eltype(a)), 6)
strainttov!(MR, av, a)
@test abs(det(a) - strainvdet(MR, av)) / abs(det(a)) <= 1.0e-6
a = symmet(rand(3, 3))
av = fill(zero(eltype(a)), 6)
strainttov!(MR, av, a)
@test abs(det(a) - strainvdet(MR, av)) / abs(det(a)) <= 1.0e-6
a = symmet(rand(3, 3))
av = fill(zero(eltype(a)), 6)
strainttov!(MR, av, a)
@test abs(tr(a) - strainvtr(MR, av)) / abs(tr(a)) <= 1.0e-6
a = symmet(rand(3, 3))
av = fill(zero(eltype(a)), 6)
strainttov!(MR, av, a)
@test abs(tr(a) - strainvtr(MR, av)) / abs(tr(a)) <= 1.0e-6
a = symmet(rand(3, 3))
av = fill(zero(eltype(a)), 6)
strainttov!(MR, av, a)
@test abs(tr(a) - strainvtr(MR, av)) / abs(tr(a)) <= 1.0e-6
end
end
using .mmmtdt1
mmmtdt1.test()
module mmmtdtens4A1
using FinEtools
using FinEtoolsDeforLinear
using LinearAlgebra
using Test
function test()
delta = (I, J) -> I == J ? 1.0 : 0.0
lambda = 3.3
mu = 0.156
F = [1.02 0.03 -0.04; 0.01 0.99 -0.03; -0.01 0.02 0.95]
C = fill(0.0, 3, 3, 3, 3)
for I = 1:3, J = 1:3, K = 1:3, L = 1:3
C[I, J, K, L] =
lambda * delta(I, J) * delta(K, L) +
mu * (delta(I, K) * delta(J, L) + delta(I, L) * delta(J, K))
end
Cm = fill(0.0, 6, 6)
tens4symmtto6x6t!(Cm, C)
mI = Matrix(Diagonal([1.0, 1.0, 1.0, 0.5, 0.5, 0.5]))
m1 = [1.0, 1.0, 1.0, 0.0, 0.0, 0.0]
D = lambda * m1 * m1' + 2.0 * mu * mI
@test norm(Cm - D) <= 1.0e-6
return true
end
end
using .mmmtdtens4A1
mmmtdtens4A1.test()
module mmmtdtens4B1
using FinEtools
using FinEtoolsDeforLinear
using LinearAlgebra
using Test
# using BenchmarkTools
function test()
delta = (I, J) -> I == J ? 1.0 : 0.0
lambda = 3.3
mu = 0.156
t = fill(0.0, 3, 3, 3, 3)
delta = (I, J) -> I == J ? 1.0 : 0.0
tens4ijkl!(t, delta, delta)
S = rand(3, 3)
tS = fill(0.0, 3, 3)
@test norm(tr(S) * I - tens4dot2!(tS, t, S)) <= 1.0e-12
# @btime tens4dot2!($tS, $t, $S)
return true
end
end
using .mmmtdtens4B1
mmmtdtens4B1.test()
module mmmtdtens4B2
using FinEtools
using FinEtoolsDeforLinear
using LinearAlgebra
using Test
# using BenchmarkTools
function test()
delta = (I, J) -> I == J ? 1.0 : 0.0
lambda = 3.3
mu = 0.156
t = fill(0.0, 3, 3, 3, 3)
delta = (I, J) -> I == J ? 1.0 : 0.0
tens4iljk!(t, delta, delta)
S = rand(3, 3)
# @show transpose(S)
tS = fill(0.0, 3, 3)
# @show transpose(S) - tens4dot2!(tS, t, S)
@test norm(transpose(S) - tens4dot2!(tS, t, S)) <= 1.0e-12
# @btime tens4dot2!($tS, $t, $S)
return true
end
end
using .mmmtdtens4B2
mmmtdtens4B2.test()
module mmmtdtens4B3
using FinEtools
using FinEtoolsDeforLinear
using LinearAlgebra
using Test
# using BenchmarkTools
function test()
delta = (I, J) -> I == J ? 1.0 : 0.0
lambda = 3.3
mu = 0.156
t = fill(0.0, 3, 3, 3, 3)
delta = (I, J) -> I == J ? 1.0 : 0.0
tens4ikjl!(t, delta, delta)
S = rand(3, 3)
tS = fill(0.0, 3, 3)
# @show S - tens4dot2!(tS, t, S)
@test norm(S - tens4dot2!(tS, t, S)) <= 1.0e-12
# @btime tens4dot2!($tS, $t, $S)
return true
end
end
using .mmmtdtens4B3
mmmtdtens4B3.test()
module mmmtdtens4B4
using FinEtools
using FinEtoolsDeforLinear
using LinearAlgebra
using Test
# using BenchmarkTools
function test()
delta = (I, J) -> I == J ? 1.0 : 0.0
lambda = 3.3
mu = 0.156
t = fill(0.0, 3, 3, 3, 3)
S = rand(3, 3)
tS = fill(0.0, 3, 3)
tens4identity!(t)
@test norm(S - tens4dot2!(tS, t, S)) <= 1.0e-12
# @btime tens4dot2!($tS, $t, $S)
return true
end
end
using .mmmtdtens4B4
mmmtdtens4B4.test()
module mmmtdtens4B5
using FinEtools
using FinEtoolsDeforLinear
using LinearAlgebra
using Test
# using BenchmarkTools
function test()
delta = (I, J) -> I == J ? 1.0 : 0.0
lambda = 3.3
mu = 0.156
t = fill(0.0, 3, 3, 3, 3)
S = rand(3, 3)
tS = fill(0.0, 3, 3)
tens4transposor!(t)
@test norm(S' - tens4dot2!(tS, t, S)) <= 1.0e-12
# @btime tens4dot2!($tS, $t, $S)
return true
end
end
using .mmmtdtens4B5
mmmtdtens4B5.test()
module mmmtdtens4B6
using FinEtools
using FinEtoolsDeforLinear
using LinearAlgebra
using Test
# using BenchmarkTools
function test()
delta = (I, J) -> I == J ? 1.0 : 0.0
lambda = 3.3
mu = 0.156
t = fill(0.0, 3, 3, 3, 3)
S = rand(3, 3)
tS = fill(0.0, 3, 3)
tens4tracor!(t)
@test norm(tr(S) * 1I - tens4dot2!(tS, t, S)) <= 1.0e-12
# @btime tens4dot2!($tS, $t, $S)
return true
end
end
using .mmmtdtens4B6
mmmtdtens4B6.test()
module mmmtdtens4B8
using FinEtools
using FinEtoolsDeforLinear
using LinearAlgebra
using Test
# using BenchmarkTools
function test()
delta = (I, J) -> I == J ? 1.0 : 0.0
lambda = 3.3
mu = 0.156
t = fill(0.0, 3, 3, 3, 3)
S = rand(3, 3)
tens4skewor!(t)
tS = rand(3, 3)
@test norm((S - S') / 2 - tens4dot2!(tS, t, S)) <= 1.0e-12
# @btime tens4dot2!($tS, $t, $S)
return true
end
end
using .mmmtdtens4B8
mmmtdtens4B8.test()
module mmmtdtens4C1
using FinEtools
using FinEtoolsDeforLinear
using LinearAlgebra
using Test
# using BenchmarkTools
function test()
t = fill(0.0, 3, 3, 3, 3)
tens4identity!(t)
S = rand(3, 3)
tS = fill(0.0, 3, 3)
tens4dot2!(tS, t, S)
# @show S - tS
@test norm(S - tS) <= 1.0e-12
return true
end
end
using .mmmtdtens4C1
mmmtdtens4C1.test()
module mmmtdtens4C2
using FinEtools
using FinEtoolsDeforLinear
using LinearAlgebra
using Test
# using BenchmarkTools
function test()
t = fill(0.0, 3, 3, 3, 3)
tens4transposor!(t)
S = rand(3, 3)
tS = fill(0.0, 3, 3)
tens4dot2!(tS, t, S)
# @show S - tS
@test norm(S' - tS) <= 1.0e-12
return true
end
end
using .mmmtdtens4C2
mmmtdtens4C2.test()
module mmmtdtens4C3
using FinEtools
using FinEtoolsDeforLinear
using LinearAlgebra
using Test
# using BenchmarkTools
function test()
t = fill(0.0, 3, 3, 3, 3)
tens4tracor!(t)
S = rand(3, 3)
tS = fill(0.0, 3, 3)
tens4dot2!(tS, t, S)
# @show tr(S) * I - tS
@test norm(tr(S) * I - tS) <= 1.0e-12
return true
end
end
using .mmmtdtens4C3
mmmtdtens4C3.test()
module mmmtdtens4C4
using FinEtools
using FinEtoolsDeforLinear
using LinearAlgebra
using Test
# using BenchmarkTools
function test()
t = fill(0.0, 3, 3, 3, 3)
tens4symmetrizor!(t)
S = rand(3, 3)
tS = fill(0.0, 3, 3)
tens4dot2!(tS, t, S)
# @show (S + S')/2 * I - tS
@test norm((S + S') / 2 - tS) <= 1.0e-12
return true
end
end
using .mmmtdtens4C4
mmmtdtens4C4.test()
module mmmtdtens4C5
using FinEtools
using FinEtoolsDeforLinear
using LinearAlgebra
using Test
# using BenchmarkTools
function test()
t = fill(0.0, 3, 3, 3, 3)
tens4skewor!(t)
S = rand(3, 3)
tS = fill(0.0, 3, 3)
tens4dot2!(tS, t, S)
# @show (S - S')/2 * I - tS
@test norm((S - S') / 2 - tS) <= 1.0e-12
return true
end
end
using .mmmtdtens4C5
mmmtdtens4C5.test()
module mmmtdtens4C6
using FinEtools
using FinEtoolsDeforLinear
using LinearAlgebra
using Test
# using BenchmarkTools
function test()
t = fill(0.0, 3, 3, 3, 3)
tens4deviator!(t)
S = rand(3, 3)
tS = fill(0.0, 3, 3)
tens4dot2!(tS, t, S)
# @show tr((S - tr(S)/3*I) ), tr(tS)
@test norm(tr((S - tr(S) / 3 * I)) - tr(tS)) <= 1.0e-12
return true
end
end
using .mmmtdtens4C6
mmmtdtens4C6.test()
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 2124 | module m4thsymmcheck1
using FinEtools
using FinEtoolsDeforLinear: tens4checksymmetry, tens4symmt6x6tot!, tens4symmtto6x6t!
using LinearAlgebra
using Test
function test()
C = rand(6, 6)
C = C + C'
Co = deepcopy(C)
t = fill(0.0, 3, 3, 3, 3)
tens4symmt6x6tot!(t, C)
@test tens4checksymmetry(t)
tens4symmtto6x6t!(C, t)
@assert norm(C - C') <= eps(1.0)
@assert norm(C - Co) <= eps(1.0)
end
end
using .m4thsymmcheck1
m4thsymmcheck1.test()
module mlumpedmass1
using FinEtools
using FinEtoolsDeforLinear
using Test
import Arpack: eigs
function test()
E = 1 * phun("PA")
nu = 0.499
rho = 1 * phun("KG/M^3")
a = 1 * phun("M")
b = a
h = a
n1 = 10# How many element edges per side?
na = n1
nb = n1
nh = n1
neigvs = 20 # how many eigenvalues
OmegaShift = (0.01 * 2 * pi)^2
MR = DeforModelRed3D
fens, fes = H20block(a, b, h, na, nb, nh)
geom = NodalField(fens.xyz)
u = NodalField(zeros(size(fens.xyz, 1), 3)) # displacement field
numberdofs!(u)
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 2)), material)
K = stiffness(femm, geom, u)
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 3)), material)
M = mass(femm, geom, u)
d, v, nev, nconv = eigs(K + OmegaShift * M, M; nev = neigvs, which = :SM)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
@test abs(fs[7] - 0.26259869196259) < 1.0e-5
femm = FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3, 3)), material)
M = mass(femm, SysmatAssemblerSparseHRZLumpingSymm(), geom, u)
d, v, nev, nconv = eigs(K + OmegaShift * M, M; nev = neigvs, which = :SM)
d = d .- OmegaShift
fs = real(sqrt.(complex(d))) / (2 * pi)
@test abs(fs[7] - 0.2598164590380608) < 1.0e-5
# println("Eigenvalues: $fs [Hz]")
# mode = 17
# scattersysvec!(u, v[:,mode])
# File = "unit_cube_modes.vtk"
# vtkexportmesh(File, fens, fes; vectors=[("mode$mode", u.values)])
true
end
end
using .mlumpedmass1
mlumpedmass1.test()
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 7472 | # # Cook panel under plane stress
# Source code: [`Cook-plane-stress_tut.jl`](Cook-plane-stress_tut.jl)
# ## Description
# In this example we investigate the well-known benchmark of a tapered panel
# under plane stress conditions known under the name of Cook. The problem has
# been solved many times with a variety of finite element models and hence the
# solution is well-known.
# ## Goals
# - Show how to generate the mesh by creating a rectangular block and reshaping it.
# - Execute the simulation with a static-equilibrium algorithm (solver).
##
# ## Definitions
# The problem is solved in a script. We begin by `using` the top-level module `FinEtools`.
# Further, we use the linear-deformation application package.
using FinEtools
using FinEtoolsDeforLinear
# With the algorithm modules, the problem can be set up (the materials, boundary
# conditions, and mesh are defined) and handed off to an algorithm (in this
# case linear static solution). Then for postprocessing another set of
# algorithms can be invoked.
using FinEtoolsDeforLinear.AlgoDeforLinearModule
# A few input parameters are defined: the material parameters. Note: the units
# are consistent, but unnamed.
E = 1.0;
nu = 1.0/3;
# The geometry of the tapered panel.
width = 48.0; height = 44.0; thickness = 1.0;
free_height = 16.0;
# Location of tracked deflection is the midpoint of the loaded edge.
Mid_edge = [48.0, 52.0];
# The tapered panel is loaded along the free edge with a unit force, which is
# here converted to loading per unit area.
magn = 1.0/free_height/thickness;# Magnitude of applied load
# For the above input parameters the converged displacement of the tip of the
# tapered panel in the direction of the applied shear load is
convutip = 23.97;
# The mesh is generated as a rectangular block to begin with, and then the
# coordinates of the nodes are tweaked into the tapered panel shape. In this
# case we are using quadratic triangles (T6).
n = 10; # number of elements per side
fens, fes = T6block(width, height, n, n)
# Reshape the rectangle into a trapezoidal panel:
for i in 1:count(fens)
fens.xyz[i,2] += (fens.xyz[i,1]/width)*(height -fens.xyz[i,2]/height*(height-free_height));
end
# The boundary conditions are applied to selected finite element nodes. The
# selection is based on the inclusion in a selection "box".
tolerance = minimum([width, height])/n/1000.;#Geometrical tolerance
# Clamped edge of the membrane
l1 = selectnode(fens; box=[0.,0.,-Inf, Inf], inflate = tolerance);
# The list of the selected nodes is then used twice, to fix the degree of
# freedom in the direction 1 and in the direction 2. The essential-boundary
# condition data is stored in dictionaries: `ess1` and `ess2 `. These
# dictionaries are used below to compose the computational model.
ess1 = FDataDict("displacement"=> 0.0, "component"=> 1, "node_list"=>l1);
ess2 = FDataDict("displacement"=> 0.0, "component"=> 2, "node_list"=>l1);
# The traction boundary condition is applied to the finite elements on the boundary of the panel. First we generate the three-node "curve" elements on the entire boundary of the panel.
boundaryfes = meshboundary(fes);
# Then from these finite elements we choose the ones that are inside the box
# that captures the edge of the geometry to which the traction should be
# applied.
Toplist = selectelem(fens, boundaryfes, box= [width, width, -Inf, Inf ], inflate= tolerance);
# To apply the traction we create a finite element model machine (FEMM). For the
# evaluation of the traction it is sufficient to create a "base" FEMM. It
# consists of the geometry data `IntegDomain` (connectivity, integration rule,
# evaluation of the basis functions and basis function gradients with respect
# to the parametric coordinates). This object is composed of the list of the
# finite elements and an appropriate quadrature rule (Gauss rule here).
el1femm = FEMMBase(IntegDomain(subset(boundaryfes, Toplist), GaussRule(1, 3), thickness));
# The traction boundary condition is specified with a constant traction vector and the FEMM that will be used to evaluate the load vector.
flux1 = FDataDict("traction_vector"=>[0.0,+magn],
"femm"=>el1femm
);
# We make the dictionary for the region (the interior of the domain). The FEMM
# for the evaluation of the integrals over the interior of the domain (that is
# the stiffness matrix) and the material are needed. The geometry data now is
# equipped with the triangular three-point rule. Note the model-reduction
# type which is used to dispatch to appropriate specializations of the material
# routines and the FEMM which needs to execute different code for different
# reduced-dimension models. Here the model reduction is "plane stress".
MR = DeforModelRed2DStress
material = MatDeforElastIso(MR, 0.0, E, nu, 0.0)
region1 = FDataDict("femm"=>FEMMDeforLinear(MR, IntegDomain(fes, TriRule(3), thickness), material));
# The model data is a dictionary. In the present example it consists of the
# node set, the array of dictionaries for the regions, and arrays of
# dictionaries for each essential and natural boundary condition.
modeldata = FDataDict("fens"=>fens,
"regions"=>[region1],
"essential_bcs"=>[ess1, ess2],
"traction_bcs"=>[flux1]
);
# When the model data is defined, we simply pass it to the algorithm.
modeldata = AlgoDeforLinearModule.linearstatics(modeldata);
# The model data is augmented in the algorithm by the nodal field representing
# the geometry and the displacement field computed by solving the system of
# linear algebraic equations of equilibrium.
u = modeldata["u"];
geom = modeldata["geom"];
# The complete information returned from the algorithm is
@show keys(modeldata)
# Now we can extract the displacement at the mid-edge node and compare to the
# converged (reference) value. The code below selects the node inside a very
# small box of the size `tolerance` which presumably contains only a single
# node, the one at the midpoint of the edge.
nl = selectnode(fens, box=[Mid_edge[1],Mid_edge[1],Mid_edge[2],Mid_edge[2]],
inflate=tolerance);
theutip = u.values[nl,:]
println("displacement =$(theutip[2]) as compared to converged $convutip")
# For postprocessing we will export a VTK file with the displacement field
# (vectors) and one scalar field ($\sigma_{xy}$).
modeldata["postprocessing"] = FDataDict("file"=>"cookstress",
"quantity"=>:Cauchy, "component"=>:xy);
modeldata = AlgoDeforLinearModule.exportstress(modeldata);
# The attribute `"postprocessing"` holds additional data computed and returned
# by the algorithm:
@show keys(modeldata["postprocessing"])
# The exported data can be digested as follows: `modeldata["postprocessing"]
# ["exported"]` is an array of exported items.
display(keys(modeldata["postprocessing"]["exported"]))
# Each entry of the array is a dictionary:
display(keys(modeldata["postprocessing"]["exported"][1]))
# Provided we have `paraview` in the PATH, we can bring it up to display the
# exported data.
File = modeldata["postprocessing"]["exported"][1]["file"]
@async run(`"paraview.exe" $File`);
# We can also extract the minimum and maximum value of the shear stress
# (-0.06, and 0.12).
display(modeldata["postprocessing"]["exported"][1]["quantity"])
display(modeldata["postprocessing"]["exported"][1]["component"])
fld = modeldata["postprocessing"]["exported"][1]["field"]
println("$(minimum(fld.values)) $(maximum(fld.values))")
true
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 7418 | # # TEST FV32: Cantilevered tapered membrane, free vibration
# Source code: [`FV32_tut.jl`](FV32_tut.jl)
# ## Description
# FV32: Cantilevered tapered membrane is a test recommended by the National
# Agency for Finite Element Methods and Standards (U.K.): Test FV32 from NAFEMS
# publication TNSB, Rev. 3, “The Standard NAFEMS Benchmarks,” October 1990.
# Reference solution: 44.623, 130.03, 162.70, 246.05, 379.90, 391.44 Hz for the
# first six modes.
# The benchmark is originally for plane stress conditions. We simulate the
# plane-stress conditions with a three-dimensional mesh that is constrained
# along one plane of nodes to effect the constrained motion only in the plane
# of the trapezoidal membrane.
# 
# ## References
# [1] Test FV32 from NAFEMS publication TNSB, Rev. 3, “The Standard NAFEMS
# Benchmarks,” October 1990.
# ## Goals
# - Show how to generate hexahedral mesh in a rectangular block and shape it
# into a trapezoid.
# - Set up model data for the solution algorithms.
# - Use two different finite element model machines to evaluate the stiffness
# and the mass.
# - Execute the modal algorithm and export the results with another algorithm.
##
# ## Definitions
# Bring in the required support from the basic linear algebra, eigenvalue
# solvers, and the finite element tools.
using LinearAlgebra
using Arpack
using FinEtools
using FinEtools
using FinEtoolsDeforLinear
using FinEtoolsDeforLinear: AlgoDeforLinearModule
# The input data is given by the benchmark.
E = 200*phun("GPA");
nu = 0.3;
rho= 8000*phun("KG/M^3");
L = 10*phun("M");
W0 = 5*phun("M");
WL = 1*phun("M");
H = 0.05*phun("M");
# We shall generate a three-dimensional mesh. It should have 1 element through
# the thickness, and 8 and 4 elements in the plane of the membrane.
nL, nW, nH = 8, 4, 1;# How many element edges per side?
# The reference frequencies are obtained from [1].
Reffs = [44.623 130.03 162.70 246.05 379.90 391.44]
# The three-dimensional mesh of 20 node serendipity hexahedral should correspond
# to the plane-stress quadratic serendipity quadrilateral (CPS8R) used in the
# Abaqus benchmark. We simulate the plane-stress conditions with a
# three-dimensional mesh that is constrained along one plane of nodes to effect
# the constrained motion only in the plane of the trapezoidal membrane. No
# bending out of plane!
# First we generate mesh of a rectangular block.
fens,fes = H20block(1.0, 2.0, 1.0, nL, nW, nH)
# Now distort the rectangular block into the tapered plate.
for i in 1:count(fens)
xi, eta, theta = fens.xyz[i,:];
eta = eta - 1.0
fens.xyz[i,:] = [xi*L eta*(1.0 - 0.8*xi)*W0/2 theta*H/2];
end
# We can visualize the mesh with Paraview (for instance).
File = "FV32-mesh.vtk"
vtkexportmesh(File, fens, fes)
@async run(`"paraview.exe" $File`)
# The simulation will be executed with the help of algorithms defined in the
# package `FinEtoolsDeforLinear`. The algorithms accept a dictionary of model
# data. The model data dictionary will be built up as follows.
# First we make the interior region. The model reduction is for a three-dimensional finite element model.
MR = DeforModelRed3D
material = MatDeforElastIso(MR, rho, E, nu, 0.0)
# We shall create two separate finite element model machines. They are
# distinguished by the quadrature rule. The mass rule, in order to evaluate the
# mass matrix accurately, needs to be of higher order than the one we prefer to
# use for the stiffness.
region1 = FDataDict("femm"=>FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3,2)), material), "femm_mass"=>FEMMDeforLinear(MR, IntegDomain(fes, GaussRule(3,3)), material))
# Select nodes that will be clamped.
nl1 = selectnode(fens; plane=[1.0 0.0 0.0 0.0], thickness=H/1.0e4)
ebc1 = FDataDict("node_list"=>nl1, "component"=>1, "displacement"=>0.0)
ebc2 = FDataDict("node_list"=>nl1, "component"=>2, "displacement"=>0.0)
ebc3 = FDataDict("node_list"=>nl1, "component"=>3, "displacement"=>0.0)
# Export a VTK file to visualize the selected points. Choose the
# representation "Points", and select color and size approximately 4. These
# notes should correspond to the clamped base of the membrane.
File = "FV32-nl1.vtk"
vtkexportmesh(File, fens, FESetP1(reshape(nl1, length(nl1), 1)))
# Select all nodes on the plane Z = 0. This will be prevented from moving in the
# Z direction.
nl4 = selectnode(fens; plane=[0.0 0.0 1.0 0.0], thickness=H/1.0e4)
ebc4 = FDataDict("node_list"=>nl4, "component"=>3, "displacement"=>0.0)
# Export a VTK file to visualize the selected points. Choose the
# representation "Points", and select color and size approximately 4. These
# points all should be on the bottom face of the three-dimensional domain.
File = "FV32-nl4.vtk"
vtkexportmesh(File, fens, FESetP1(reshape(nl4, length(nl4), 1)))
# Make model data: the nodes, the regions, the boundary conditions, and the
# number of eigenvalues are set. Note that the number of eigenvalues needs to
# be set to 6+N, where 6 is the number of rigid body modes, and N is the
# number of deformation frequencies we are interested in.
neigvs = 10 # how many eigenvalues
modeldata = FDataDict("fens"=> fens, "regions"=> [region1], "essential_bcs"=>[ebc1 ebc2 ebc3 ebc4], "neigvs"=>neigvs)
# Solve using an algorithm: the modal solver. The solver will supplement the
# model data with the geometry and displacement fields, and the solution
# (eigenvalues, eigenvectors), and the data upon return can be extracted from
# the dictionary.
modeldata = AlgoDeforLinearModule.modal(modeldata)
# Here we extract the angular velocities corresponding to the natural frequencies.
fs = modeldata["omega"]/(2*pi)
println("Eigenvalues: $fs [Hz]")
println("Percentage frequency errors: $((vec(fs[1:6]) - vec(Reffs))./vec(Reffs)*100)")
# The problem was solved for instance with Abaqus, using plane stress eight node
# elements. The results were:
# | Element | Frequencies (relative errors) |
# | ------- | ---------------------------- |
# | CPS8R | 44.629 (0.02) 130.11 (0.06) 162.70 (0.00) 246.42 (0.15) 381.32 (0.37) 391.51 (0.02) |
# Compared these numbers with those computed by our three-dimensional model.
# The mode shapes may be visualized with `paraview`. Here is for instance mode
# 8:
# 
# The algorithm to export the mode shapes expects some input. We shall specify
# the filename and the numbers of modes to export.
modeldata["postprocessing"] = FDataDict("file"=>"FV32-modes", "mode"=>1:neigvs)
modeldata = AlgoDeforLinearModule.exportmode(modeldata)
# The algorithm attaches a little bit to the name of the exported file. If
# `paraview.exe` is installed, the command below should bring up the
# postprocessing file.
@async run(`"paraview.exe" $(modeldata["postprocessing"]["file"]*"1.vtk")`)
# To animate the mode shape in `Paraview` do the following:
# - Apply the filter "Warp by vector".
# - Turn on the "Animation view".
# - Add the mode shape data set ("WarpByVector1") by clicking the "+".
# - Double-click the line with the data set. The "Animation Keyframes" dialog
# will come up. Double-click "Ramp" interpolation, and change it
# to "Sinusoid". Set the frequency to 1.0. Change the "Value" from 0 to 100.
# - In the animation view, set the mode to "Real-time", and the duration to 4.0
# seconds.
# - Click on the "Play" button. If you wish, click on the "Loop" button.
true
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
|
[
"MIT"
] | 3.0.4 | c0a87e41e018a0cb93b6670b7f0e40e6615e5cf8 | code | 8705 | # # R0031/3 Composite plate test
# Source code: [`R0031-3-Composite-benchmark_tut.jl`](R0031-3-Composite-benchmark_tut.jl)
# ## Description
# This is a test recommended by the National Agency for Finite Element Methods and Standards (U.K.): Test R0031/3 from NAFEMS publication R0031, “Composites Benchmarks,” February 1995. It is a composite (sandwich) plate of square shape, simply supported along all four edges. Uniform transverse loading is applied to the top skin. The modeled part is one quarter of the full plate here. The serendipity quadratic hexahedra are used, with full integration.
# The solution can be compared with the benchmark results in the Abaqus manual ["Abaqus Benchmarks Guide"](http://130.149.89.49:2080/v6.7/books/bmk/default.htm?startat=ch04s09anf83.html).
# We begin by `using` the toolkit `FinEtools`.
using FinEtools
# Further, we use the linear-deformation application package.
using FinEtoolsDeforLinear
# The problem will be solved with a pre-packaged algorithm.
using FinEtoolsDeforLinear.AlgoDeforLinearModule
# For some basic statistics.
import Statistics: mean
# The material parameters are specified for an orthotropic material model. The units are attached using the `phun` function which can take the specification of the units and spits out the numerical multiplier. Here the benchmark specifies the input parameters in the English Imperial units. The skin material:
E1s = 1.0e7*phun("psi")
E2s = 0.4e7*phun("psi")
E3s = 0.4e7*phun("psi")
nu12s = 0.3
nu13s = 0.3
nu23s = 0.3
G12s = 0.1875e7*phun("psi")
G13s = 0.1875e7*phun("psi")
G23s = 0.1875e7*phun("psi");
# The core material:
E1c = 10.0*phun("psi")
E2c = 10.0*phun("psi")
E3c = 10e4.*phun("psi")
nu12c = 0.
nu13c = 0.
nu23c = 0.
G12c = 10.0*phun("psi")
G13c = 3.0e4*phun("psi")
G23c = 1.2e4*phun("psi");
# The magnitude of the distributed uniform transfers loading is
tmag = 100*phun("psi");
# Now we generate the mesh. The sandwich plate volume is divided into a regular Cartesian grid in the $X$ and $Y$ direction in the plane of the plate, and in the thickness direction it is divided into three layers, with each layer again subdivided into multiple elements.
L = 10.0*phun("in") # side of the square plate
nL = 8 # number of elements along the side of the plate
xs = collect(linearspace(0.0, L/2, nL+1))
ys = collect(linearspace(0.0, L/2, nL+1));;
# The thicknesses are specified from the bottom of the plate: skin, core, and then again skin.
ts = [0.028; 0.75; 0.028]*phun("in")
nts = [2; 3; 2]; # number of elements through the thickness for each layer
# The `H8layeredplatex` meshing function generates the mesh and marks the elements with a label identifying the layer to which they belong. We will use the label to create separate regions, with their own separate materials.
fens,fes = H8layeredplatex(xs, ys, ts, nts)
# The linear hexahedra are subsequently converted to serendipity (quadratic) elements.
fens,fes = H8toH20(fens,fes);
# The model reduction here simply says this is a fully three-dimensional model. The two orthotropic materials are created.
MR = DeforModelRed3D
skinmaterial = MatDeforElastOrtho(MR,
0.0, E1s, E2s, E3s,
nu12s, nu13s, nu23s,
G12s, G13s, G23s,
0.0, 0.0, 0.0)
corematerial = MatDeforElastOrtho(MR,
0.0, E1c, E2c, E3c,
nu12c, nu13c, nu23c,
G12c, G13c, G23c,
0.0, 0.0, 0.0);
# Now we are ready to create three material regions: one for the bottom skin, one for the core, and one for the top skin. The selection of the finite elements assigned to each of the three regions is based on the label. Full Gauss quadrature is used.
rl1 = selectelem(fens, fes, label=1)
skinbot = FDataDict("femm"=>FEMMDeforLinear(MR,
IntegDomain(subset(fes, rl1), GaussRule(3, 3)), skinmaterial))
rl3 = selectelem(fens, fes, label=3)
skintop = FDataDict("femm"=>FEMMDeforLinear(MR,
IntegDomain(subset(fes, rl3), GaussRule(3, 3)), skinmaterial))
rl2 = selectelem(fens, fes, label=2)
core = FDataDict("femm"=>FEMMDeforLinear(MR,
IntegDomain(subset(fes, rl2), GaussRule(3, 3)), corematerial));
# Note that since we did not specify the material coordinate system, the default is assumed (which is identical to the global Cartesian coordinate system).
@show skinbot["femm"].mcsys
# Next we select the nodes to which essential boundary conditions will be applied. A node is selected if it is within the specified box which for the purpose of the test is inflated in all directions by `tolerance`. The nodes on the planes of symmetry need to be selected, and also the nodes along the edges (faces) to be simply supported need to be identified.
tolerance = 0.0001*phun("in")
lx0 = selectnode(fens, box=[0.0 0.0 -Inf Inf -Inf Inf], inflate=tolerance)
lxL2 = selectnode(fens, box=[L/2 L/2 -Inf Inf -Inf Inf], inflate=tolerance)
ly0 = selectnode(fens, box=[-Inf Inf 0.0 0.0 -Inf Inf], inflate=tolerance)
lyL2 = selectnode(fens, box=[-Inf Inf L/2 L/2 -Inf Inf], inflate=tolerance);
# We have four sides of the quarter of the plate, two on each plane of symmetry, and two along the circumference. Hence we create four essential boundary condition definitions, one for each of the sides of the plate.
ex0 = FDataDict( "displacement"=> 0.0, "component"=> 3, "node_list"=>lx0 )
exL2 = FDataDict( "displacement"=> 0.0, "component"=> 1, "node_list"=>lxL2 )
ey0 = FDataDict( "displacement"=> 0.0, "component"=> 3, "node_list"=>ly0 )
eyL2 = FDataDict( "displacement"=> 0.0, "component"=> 2, "node_list"=>lyL2 );
# The traction on the top surface of the top skin is applied to the subset of the surface mesh of the entire domain. First we compute the boundary mesh, and then from the boundary mesh we select the surface finite elements that "face" upward (along the positive $Z$ axis).
bfes = meshboundary(fes)
ttopl = selectelem(fens, bfes; facing=true, direction = [0.0 0.0 1.0])
Trac = FDataDict("traction_vector"=>[0.0; 0.0; -tmag],
"femm"=>FEMMBase(IntegDomain(subset(bfes, ttopl), GaussRule(2, 3))));
# The model data is composed of the finite element nodes, an array of the regions, an array of the essential boundary condition definitions, and an array of the traction (natural) boundary condition definitions.
modeldata = FDataDict("fens"=>fens,
"regions"=>[skinbot, core, skintop], "essential_bcs"=>[ex0, exL2, ey0, eyL2],
"traction_bcs"=> [Trac]
);
# With the model data assembled, we can now call the algorithm.
modeldata = AlgoDeforLinearModule.linearstatics(modeldata);
# The computed solution can now be postprocessed. The displacement is reported at the center of the plate, along the line in the direction of the loading. We select all the nodes along this line.
u = modeldata["u"]
geom = modeldata["geom"]
lcenter = selectnode(fens, box=[L/2 L/2 L/2 L/2 -Inf Inf], inflate=tolerance);
# The variation of the displacement along this line can be plotted as (the bottom surface of the shell is at $Z=0$):
ix = sortperm(geom.values[lcenter, 3])
# Plot the data
using Gnuplot
Gnuplot.gpexec("reset session")
@gp "set terminal windows 0 " :-
@gp :- geom.values[lcenter, 3][ix] u.values[lcenter, 3][ix]./phun("in") " lw 2 with lp title 'cold leg' " :-
@gp :- "set xlabel 'Z coordinate [in]'" :-
@gp :- "set ylabel 'Vert displ [in]'"
# A reasonable single number to report for the deflection at the center is the average of the displacements at the nodes at the center of the plate (-0.136348):
cdis = mean(u.values[lcenter, 3])/phun("in");
println("Center node displacements $(cdis) [in]; NAFEMS-R0031-3 reference: –0.123 [in]")
# The reference displacement at the center of -0.123 [in] reported for the benchmark is evaluated from an analytical formulation that neglects transverse (pinching) deformation. Due to the soft core, significant pinching is observed. The solution to the benchmark obtained in Abaqus with incompatible hexahedral elements (with the same number of elements as in the stacked continuum shell solution) is -0.131 [in], which is close to our own solution. Hence, our own solution is probably more accurate than the reference solution because it includes an effect neglected in the benchmark solution.
# The deformed shape can be investigated visually in `paraview` (uncomment the line at the bottom if you have `paraview` in your PATH):
File = "NAFEMS-R0031-3-plate.vtk"
vtkexportmesh(File, connasarray(fes), geom.values, FinEtools.MeshExportModule.VTK.H20;
scalars = [("Layer", fes.label)], vectors = [("displacement", u.values)])
# @async run(`"paraview.exe" $File`);
# Note that the VTK file will contain element labels (which can help us distinguish between the layers) as scalar field, and the displacements as a vector field.
| FinEtoolsDeforLinear | https://github.com/PetrKryslUCSD/FinEtoolsDeforLinear.jl.git |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.