mirror of
https://github.com/JuliaFEM/JuliaFEM.jl.git
synced 2026-09-10 13:17:42 +00:00
Introduced the concept of element and equation.
This commit is contained in:
@@ -36,48 +36,26 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"execution_count": 8,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
" in depwarn at /Applications/Julia-0.4.0-dev-539c818c4e.app/Contents/Resources/julia/lib/julia/sys.dylib\n",
|
||||
" in int32 at deprecated.jl:49\n",
|
||||
" in recv at /Users/jukka/.julia/v0.4/ZMQ/src/ZMQ.jl:617\n",
|
||||
" in recv_ipython at /Users/jukka/.julia/v0.4/IJulia/src/msg.jl:63\n",
|
||||
" in eventloop at /Users/jukka/.julia/v0.4/IJulia/src/IJulia.jl:120\n",
|
||||
" in anonymous at task.jl:365\n",
|
||||
"while loading /Users/jukka/.julia/v0.4/IJulia/src/kernel.jl, in expression starting on line 35\n",
|
||||
"WARNING: int32(x) is deprecated, use Int32(x) instead.\n",
|
||||
" in depwarn at /Applications/Julia-0.4.0-dev-539c818c4e.app/Contents/Resources/julia/lib/julia/sys.dylib\n",
|
||||
" in int32 at deprecated.jl:49\n",
|
||||
" in recv at /Users/jukka/.julia/v0.4/ZMQ/src/ZMQ.jl:617\n",
|
||||
" in recv_ipython at /Users/jukka/.julia/v0.4/IJulia/src/msg.jl:63\n",
|
||||
" in eventloop at /Users/jukka/.julia/v0.4/IJulia/src/IJulia.jl:120\n",
|
||||
" in anonymous at task.jl:365\n",
|
||||
"while loading /Users/jukka/.julia/v0.4/IJulia/src/kernel.jl, in expression starting on line 35\n",
|
||||
"24-Aug 00:56:48:INFO:root:loading types\n",
|
||||
"24-Aug 00:56:48:INFO:root:loading elements\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"Logger(root,DEBUG,Pipe(open, 0 bytes waiting),root)"
|
||||
]
|
||||
},
|
||||
"execution_count": 1,
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"using JuliaFEM\n",
|
||||
"using JuliaFEM: Assembly, Element, Quad4, get_integration_points, get_jacobian, get_basis, get_dbasisdxi, get_dbasisdX\n",
|
||||
"using JuliaFEM: Assembly, Element, Quad4, get_jacobian, get_basis\n",
|
||||
"using JuliaFEM: get_dbasisdxi, get_dbasisdX, get_field, set_field\n",
|
||||
"using Logging\n",
|
||||
"Logging.configure(level=DEBUG)"
|
||||
]
|
||||
@@ -100,59 +78,6 @@
|
||||
"First we construct some type for our element which contains all relevant data. We don't care a much how every element is actually implemented as long as it follows some general rules how the interface is constructed. First we define our element family and it's basis functions, derivatives of them etc. These needs to be defined for each element type only once."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"get_rhs (generic function with 1 method)"
|
||||
]
|
||||
},
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"\"\"\"\n",
|
||||
"Integrate f over element using Gaussian quadrature rules.\n",
|
||||
"\n",
|
||||
"Parameters\n",
|
||||
"----------\n",
|
||||
"el::Element\n",
|
||||
" well defined element\n",
|
||||
"f::Function\n",
|
||||
" Function to integrate\n",
|
||||
"\"\"\"\n",
|
||||
"function integrate(el::Element, f::Function)\n",
|
||||
" target = []\n",
|
||||
" for ip in get_integration_points(el)\n",
|
||||
" J = get_jacobian(el, ip.xi)\n",
|
||||
" push!(target, ip.weight*f(el, ip)*det(J))\n",
|
||||
" end\n",
|
||||
" return sum(target)\n",
|
||||
"end\n",
|
||||
"\n",
|
||||
"\"\"\"\n",
|
||||
"Return left hand side of the equation Ax = b (i.e. A)\n",
|
||||
"\"\"\"\n",
|
||||
"function get_lhs(el::Element)\n",
|
||||
" return None\n",
|
||||
"end\n",
|
||||
"\n",
|
||||
"\"\"\"\n",
|
||||
"Return right hand side of the equation Ax = b (i.e. b)\n",
|
||||
"\"\"\"\n",
|
||||
"function get_rhs(el::Element)\n",
|
||||
" return None\n",
|
||||
"end"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
@@ -162,60 +87,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#abstract Mechanical <: CG"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"get_field (generic function with 1 method)"
|
||||
]
|
||||
},
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"\"\"\"\n",
|
||||
"(4-node bilinear) plane stress element\n",
|
||||
"\"\"\"\n",
|
||||
"type CPS4 <: Quad4\n",
|
||||
" id :: Int\n",
|
||||
" node_ids :: Array{Int, 1}\n",
|
||||
" coordinates :: Array{Float64, 2}\n",
|
||||
" integration_points :: Array{IntegrationPoint, 1}\n",
|
||||
" attributes :: Dict{ASCIIString, Any}\n",
|
||||
"end\n",
|
||||
"\n",
|
||||
"function get_field(el::Quad4)\n",
|
||||
" el.attributes[\"displacement\"]\n",
|
||||
"end"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Each element must provide a standard way how it's initialized. For constructor we need only unique element id and it's connectivity data."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"execution_count": 9,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -226,21 +98,88 @@
|
||||
"CPS4"
|
||||
]
|
||||
},
|
||||
"execution_count": 5,
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"function CPS4(element_id, node_ids)\n",
|
||||
"abstract Equation\n",
|
||||
"abstract Elasticity <: Equation\n",
|
||||
"\n",
|
||||
"\"\"\"\n",
|
||||
"Plane stress formulation for 4-node bilinear element.\n",
|
||||
"\"\"\"\n",
|
||||
"type CPS4 <: Elasticity\n",
|
||||
" element :: Quad4\n",
|
||||
" integration_points :: Array{IntegrationPoint, 1}\n",
|
||||
"end\n",
|
||||
"function CPS4(el::Quad4)\n",
|
||||
" integration_points = [\n",
|
||||
" IntegrationPoint(1.0/sqrt(3.0)*[-1, -1], 1.0, Dict()),\n",
|
||||
" IntegrationPoint(1.0/sqrt(3.0)*[ 1, -1], 1.0, Dict()),\n",
|
||||
" IntegrationPoint(1.0/sqrt(3.0)*[ 1, 1], 1.0, Dict()),\n",
|
||||
" IntegrationPoint(1.0/sqrt(3.0)*[-1, 1], 1.0, Dict())]\n",
|
||||
" attributes = Dict(\"displacement\" => zeros(2, 4))\n",
|
||||
" coordinates = zeros(2, 4)\n",
|
||||
" CPS4(element_id, node_ids, coordinates, integration_points, attributes)\n",
|
||||
" IntegrationPoint(1.0/sqrt(3.0)*[-1, -1], 1.0),\n",
|
||||
" IntegrationPoint(1.0/sqrt(3.0)*[ 1, -1], 1.0),\n",
|
||||
" IntegrationPoint(1.0/sqrt(3.0)*[ 1, 1], 1.0),\n",
|
||||
" IntegrationPoint(1.0/sqrt(3.0)*[-1, 1], 1.0)]\n",
|
||||
" CPS4(el, integration_points)\n",
|
||||
"end"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"get_rhs (generic function with 2 methods)"
|
||||
]
|
||||
},
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"using ForwardDiff\n",
|
||||
"\n",
|
||||
"get_integration_points(eq::Equation) = eq.integration_points\n",
|
||||
"\n",
|
||||
"\"\"\"\n",
|
||||
"Integrate f over element using Gaussian quadrature rules.\n",
|
||||
"\n",
|
||||
"Parameters\n",
|
||||
"----------\n",
|
||||
"el::Element\n",
|
||||
" well defined element\n",
|
||||
"f::Function\n",
|
||||
" Function to integrate\n",
|
||||
"\"\"\"\n",
|
||||
"function integrate(eq::Equation, f::Function)\n",
|
||||
" target = []\n",
|
||||
" for ip in get_integration_points(eq)\n",
|
||||
" J = get_jacobian(eq.element, ip.xi)\n",
|
||||
" push!(target, ip.weight*f(eq, ip)*det(J))\n",
|
||||
" end\n",
|
||||
" return sum(target)\n",
|
||||
"end\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\"\"\"\n",
|
||||
"Return left hand side of the equation Ax = b (i.e. A)\n",
|
||||
"\"\"\"\n",
|
||||
"function get_lhs(eq::Equation)\n",
|
||||
" return None\n",
|
||||
"end\n",
|
||||
"\n",
|
||||
"\"\"\"\n",
|
||||
"Return right hand side of the equation Ax = b (i.e. b)\n",
|
||||
"\"\"\"\n",
|
||||
"function get_rhs(eq::Equation)\n",
|
||||
" return None\n",
|
||||
"end"
|
||||
]
|
||||
},
|
||||
@@ -250,12 +189,12 @@
|
||||
"source": [
|
||||
"Here's the actual basic implementation for mechanical elements\n",
|
||||
"\n",
|
||||
"Our task is: for given $\\mathbf{u}$ calculate $\\mathbf{R}(\\mathbf{u}) = \\mathbf{T}(\\mathbf{u}) - \\mathbf{F}(\\mathbf{u})$ and it's partial derivative with respect to $\\mathbf{u}$, i.e. $\\partial \\mathbf{R}(\\mathbf{u}) / \\partial \\mathbf{u}$. Here is our $\\mathbf{T}$:"
|
||||
"Our task is: for given $\\mathbf{u}$ calculate $\\mathbf{R}(\\mathbf{u}) = \\mathbf{T}(\\mathbf{u}) - \\mathbf{F}(\\mathbf{u})$ and it's partial derivative with respect to $\\mathbf{u}$, i.e. $\\partial \\mathbf{R}(\\mathbf{u}) / \\partial \\mathbf{u}$. Because of DRY, we apply this implementation for union of several elements because this works for all 2d and 3d continuum elements."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": 15,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -266,17 +205,60 @@
|
||||
"get_lhs (generic function with 2 methods)"
|
||||
]
|
||||
},
|
||||
"execution_count": 6,
|
||||
"execution_count": 15,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"#using JuliaFEM: linearize\n",
|
||||
"\n",
|
||||
"\"\"\"\n",
|
||||
"Evaluate field in point xi using basis functions.\n",
|
||||
"\"\"\"\n",
|
||||
"function interpolate(el::Element, field::ASCIIString, xi::Array{Float64,1})\n",
|
||||
" f = get_field(el, field)\n",
|
||||
" if !isa(f, Array)\n",
|
||||
" # This is scalar, nothing to interpolate\n",
|
||||
" return f\n",
|
||||
" end\n",
|
||||
" basis = get_basis(el, xi)\n",
|
||||
" dim, nnodes = size(f)\n",
|
||||
" result = zeros(dim)\n",
|
||||
" for i=1:nnodes\n",
|
||||
" result += basis[i]*f[:,i]\n",
|
||||
" end\n",
|
||||
" return result\n",
|
||||
"end\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"StressEquation = Union()\n",
|
||||
"\n",
|
||||
"get_element(eq::Equation) = eq.element\n",
|
||||
"\n",
|
||||
"function linearize(f::Function, field::ASCIIString)\n",
|
||||
" function jacobian(eq::Equation, args...)\n",
|
||||
" el = get_element(eq)\n",
|
||||
" fld = get_field(el, field)\n",
|
||||
" dim, nnodes = size(fld)\n",
|
||||
" function helper!(x, y)\n",
|
||||
" orig = copy(fld)\n",
|
||||
" set_field(el, field, reshape(x, dim, nnodes))\n",
|
||||
" y[:] = f(eq, args...)\n",
|
||||
" set_field(el, field, orig)\n",
|
||||
" end\n",
|
||||
" jac = ForwardDiff.forwarddiff_jacobian(helper!, Float64, fadtype=:dual, n=dim*nnodes, m=dim*nnodes)\n",
|
||||
" return jac(fld[:])\n",
|
||||
" end\n",
|
||||
" return jacobian\n",
|
||||
"end\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\"\"\"\n",
|
||||
"Calculate internal nodal forces for continuum element.\n",
|
||||
"\"\"\"\n",
|
||||
"function Wint(el::Quad4)\n",
|
||||
"\n",
|
||||
"function Wint(eq::CPS4)\n",
|
||||
" el = eq.element\n",
|
||||
" dNdX(xi) = get_dbasisdX(el, xi)\n",
|
||||
" # material\n",
|
||||
" lambda(xi) = interpolate(el, \"lambda\", xi)\n",
|
||||
@@ -289,11 +271,11 @@
|
||||
" S(xi, u) = lambda(xi)*trace(E(xi, u))*I + 2*mu(xi)*E(xi, u)\n",
|
||||
" P(xi, u) = F(xi, u)*S(xi, u)\n",
|
||||
" T(xi, u) = P(xi, u)*dNdX(xi)'\n",
|
||||
" integrate(el, (el, ip) -> T(ip.xi, get_field(el)))\n",
|
||||
" integrate(eq, (eq, ip) -> T(ip.xi, get_field(eq.element, \"displacement\")))\n",
|
||||
"end\n",
|
||||
"\n",
|
||||
"get_rhs(el::Quad4) = -Wint(el) # rhs = -R = -(T-F)\n",
|
||||
"get_lhs(el::Quad4) = linearize(Wint, \"displacement\")(el)"
|
||||
"get_rhs(eq::CPS4) = -Wint(eq) # rhs = -R = -(T-F)\n",
|
||||
"get_lhs(eq::CPS4) = linearize(Wint, \"displacement\")(eq)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -301,13 +283,19 @@
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"That was our geometrically nonlinear elasticity solver. Note how we used automatic differentiation to linearize residual vector.\n",
|
||||
"\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"*Design principle 6*: we test our code. We use FactCheck for testing."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"execution_count": 16,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
@@ -318,7 +306,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"execution_count": 28,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -326,20 +314,22 @@
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"get_test_element (generic function with 1 method)"
|
||||
"CPS4(JuliaFEM.Quad4([1,2,3,4],Dict{ASCIIString,Any}(\"coordinates\"=>2x4 Array{Float64,2}:\n",
|
||||
" 0.0 10.0 10.0 0.0\n",
|
||||
" 0.0 0.0 1.0 1.0,\"lambda\"=>24.0,\"mu\"=>36.0)),[JuliaFEM.IntegrationPoint([-0.5773502691896258,-0.5773502691896258],1.0,Dict{ASCIIString,Any}()),JuliaFEM.IntegrationPoint([0.5773502691896258,-0.5773502691896258],1.0,Dict{ASCIIString,Any}()),JuliaFEM.IntegrationPoint([0.5773502691896258,0.5773502691896258],1.0,Dict{ASCIIString,Any}()),JuliaFEM.IntegrationPoint([-0.5773502691896258,0.5773502691896258],1.0,Dict{ASCIIString,Any}())])"
|
||||
]
|
||||
},
|
||||
"execution_count": 8,
|
||||
"execution_count": 28,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"function get_test_element()\n",
|
||||
"function get_test_equation()\n",
|
||||
" # set up one linear quadrangle element\n",
|
||||
" element_id = 1\n",
|
||||
" node_ids = [1, 2, 3, 4]\n",
|
||||
" el = CPS4(element_id, node_ids)\n",
|
||||
" el = Quad4(node_ids)\n",
|
||||
" eq = CPS4(el)\n",
|
||||
"\n",
|
||||
" E = 90.0\n",
|
||||
" nu = 0.25\n",
|
||||
@@ -347,15 +337,66 @@
|
||||
" la = E*nu/((1+nu)*(1-2*nu))\n",
|
||||
" la = 2*la*mu/(la + 2*mu)\n",
|
||||
" X = [0.0 0.0; 10.0 0.0; 10.0 1.0; 0.0 1.0]'\n",
|
||||
" set_coordinates(el, X)\n",
|
||||
" set_material(el, la, mu)\n",
|
||||
" return el\n",
|
||||
"end"
|
||||
" #set_coordinates(el, X)\n",
|
||||
" #set_material(el, la, mu)\n",
|
||||
" set_field(el, \"coordinates\", X)\n",
|
||||
" set_field(el, \"lambda\", la)\n",
|
||||
" set_field(el, \"mu\", mu)\n",
|
||||
" return eq\n",
|
||||
"end\n",
|
||||
"eq = get_test_equation()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"execution_count": 34,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"getindex (generic function with 132 methods)"
|
||||
]
|
||||
},
|
||||
"execution_count": 34,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# get_element(eq::Equation) = eq.element\n",
|
||||
"#get_field(get_element(eq), \"coordinates\") += 1\n",
|
||||
"#get_field(get_element(eq), \"coordinates\")\n",
|
||||
"#getindex(eq::Equation, field) = eq.element.fields[field]\n",
|
||||
"#setindex!(eq::Equation, Any, field) = "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 36,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"ename": "LoadError",
|
||||
"evalue": "LoadError: MethodError: `setindex!` has no method matching setindex!(::CPS4, ::Array{Float64,2}, ::ASCIIString)\nwhile loading In[36], in expression starting on line 1",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"LoadError: MethodError: `setindex!` has no method matching setindex!(::CPS4, ::Array{Float64,2}, ::ASCIIString)\nwhile loading In[36], in expression starting on line 1",
|
||||
""
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"eq[\"coordinates\"] += 1.0"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"scrolled": false
|
||||
@@ -372,64 +413,48 @@
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"24-Aug 00:57:07:DEBUG:root:Iteration 1\n",
|
||||
"24-Aug 00:57:10:DEBUG:root:Solving Ax = b\n",
|
||||
"24-Aug 00:57:13:DEBUG:root:Iteration 2\n",
|
||||
"24-Aug 00:57:13:DEBUG:root:Solving Ax = b\n",
|
||||
"24-Aug 00:57:13:DEBUG:root:Iteration 3\n",
|
||||
"24-Aug 00:57:13:DEBUG:root:Solving Ax = b\n",
|
||||
"24-Aug 00:57:13:DEBUG:root:Iteration 4\n",
|
||||
"24-Aug 00:57:13:DEBUG:root:Solving Ax = b\n",
|
||||
"24-Aug 00:57:13:DEBUG:root:Iteration 5\n",
|
||||
"24-Aug 00:57:13:DEBUG:root:Solving Ax = b\n",
|
||||
"24-Aug 00:57:13:DEBUG:root:Iteration 6\n",
|
||||
"24-Aug 00:57:13:DEBUG:root:Solving Ax = b\n",
|
||||
"24-Aug 00:57:13:DEBUG:root:Converged in 6 iterations.\n",
|
||||
"24-Aug 00:57:14:DEBUG:root:solution vector: \n",
|
||||
"26-Aug 01:36:30:DEBUG:root:Iteration 1\n",
|
||||
"26-Aug 01:36:30:DEBUG:root:Solving Ax = b\n",
|
||||
"26-Aug 01:36:30:DEBUG:root:Iteration 2\n",
|
||||
"26-Aug 01:36:30:DEBUG:root:Solving Ax = b\n",
|
||||
"26-Aug 01:36:30:DEBUG:root:Iteration 3\n",
|
||||
"26-Aug 01:36:30:DEBUG:root:Solving Ax = b\n",
|
||||
"26-Aug 01:36:30:DEBUG:root:Iteration 4\n",
|
||||
"26-Aug 01:36:30:DEBUG:root:Solving Ax = b\n",
|
||||
"26-Aug 01:36:30:DEBUG:root:Iteration 5\n",
|
||||
"26-Aug 01:36:30:DEBUG:root:Solving Ax = b\n",
|
||||
"26-Aug 01:36:30:DEBUG:root:Iteration 6\n",
|
||||
"26-Aug 01:36:30:DEBUG:root:Solving Ax = b\n",
|
||||
"26-Aug 01:36:30:DEBUG:root:Converged in 6 iterations.\n",
|
||||
"26-Aug 01:36:30:DEBUG:root:solution vector: \n",
|
||||
" [0.0 -0.3991450609547433 -0.07228582695592461 0.0\n",
|
||||
" 0.0 -2.1779892317073504 -2.222244754401764 0.0]\n",
|
||||
"24-Aug 00:57:14:DEBUG:root:norm of u: 3.1292483947150047\n",
|
||||
"24-Aug 00:57:14:DEBUG:root:Iteration 1\n",
|
||||
"24-Aug 00:57:14:DEBUG:root:Solving Ax = b\n",
|
||||
"24-Aug 00:57:14:DEBUG:root:Iteration 2\n",
|
||||
"24-Aug 00:57:14:DEBUG:root:Solving Ax = b\n",
|
||||
"24-Aug 00:57:14:DEBUG:root:Iteration 3\n",
|
||||
"24-Aug 00:57:14:DEBUG:root:Solving Ax = b\n",
|
||||
"24-Aug 00:57:14:DEBUG:root:Iteration 4\n",
|
||||
"24-Aug 00:57:14:DEBUG:root:Solving Ax = b\n",
|
||||
"24-Aug 00:57:14:DEBUG:root:Iteration 5\n",
|
||||
"24-Aug 00:57:15:DEBUG:root:Solving Ax = b\n",
|
||||
"24-Aug 00:57:15:DEBUG:root:Iteration 6\n",
|
||||
"24-Aug 00:57:15:DEBUG:root:Solving Ax = b\n",
|
||||
"24-Aug 00:57:15:DEBUG:root:Converged in 6 iterations.\n",
|
||||
"24-Aug 00:57:15:DEBUG:root:solution vector: \n",
|
||||
"26-Aug 01:36:30:DEBUG:root:norm of u: 3.1292483947150047\n",
|
||||
"26-Aug 01:36:30:DEBUG:root:Iteration 1\n",
|
||||
"26-Aug 01:36:30:DEBUG:root:Solving Ax = b\n",
|
||||
"26-Aug 01:36:30:DEBUG:root:Iteration 2\n",
|
||||
"26-Aug 01:36:30:DEBUG:root:Solving Ax = b\n",
|
||||
"26-Aug 01:36:30:DEBUG:root:Iteration 3\n",
|
||||
"26-Aug 01:36:30:DEBUG:root:Solving Ax = b\n",
|
||||
"26-Aug 01:36:30:DEBUG:root:Iteration 4\n",
|
||||
"26-Aug 01:36:30:DEBUG:root:Solving Ax = b\n",
|
||||
"26-Aug 01:36:30:DEBUG:root:Iteration 5\n",
|
||||
"26-Aug 01:36:30:DEBUG:root:Solving Ax = b\n",
|
||||
"26-Aug 01:36:30:DEBUG:root:Iteration 6\n",
|
||||
"26-Aug 01:36:30:DEBUG:root:Solving Ax = b\n",
|
||||
"26-Aug 01:36:30:DEBUG:root:Converged in 6 iterations.\n",
|
||||
"26-Aug 01:36:30:DEBUG:root:solution vector: \n",
|
||||
" [0.0 1.2578327758133292 1.5202505368695098 0.0\n",
|
||||
" 0.0 -1.8223091343697626 -1.6224781337179326 0.0]\n",
|
||||
"24-Aug 00:57:15:DEBUG:root:norm of u: 3.129248394715004\n"
|
||||
" 0.0 -1.8223091343697626 -1.6224781337179326 0.0]\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"2 facts verified.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"delayed_handler (generic function with 4 methods)"
|
||||
]
|
||||
},
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"facts(\"test solve one element model\") do\n",
|
||||
"\n",
|
||||
" e = get_test_element()\n",
|
||||
" eq = get_test_equation()\n",
|
||||
" el = get_element(eq)\n",
|
||||
" set_field(el, \"displacement\", zeros(2, 4))\n",
|
||||
" F = [0.0 0.0; 0.0 0.0; 0.0 -2.0; 0.0 0.0]'\n",
|
||||
"\n",
|
||||
" du = zeros(2, 4)\n",
|
||||
@@ -437,13 +462,13 @@
|
||||
" free_dofs = [3, 4, 5, 6]\n",
|
||||
" for i=1:10\n",
|
||||
" Logging.debug(\"Iteration $i\")\n",
|
||||
" b = get_rhs(e)\n",
|
||||
" #Logging.debug(\"rhs = $b\")\n",
|
||||
" A = get_lhs(e)\n",
|
||||
" b = get_rhs(eq)\n",
|
||||
" A = get_lhs(eq)\n",
|
||||
" Logging.debug(\"Solving Ax = b\")\n",
|
||||
" du[free_dofs] = A[free_dofs, free_dofs] \\ (b + F)[free_dofs]\n",
|
||||
"\n",
|
||||
" e.attributes[\"displacement\"] += du\n",
|
||||
" field = get_field(el, \"displacement\") + du\n",
|
||||
" set_field(el, \"displacement\", field)\n",
|
||||
" if norm(du) < 1.0e-9\n",
|
||||
" Logging.debug(\"Converged in $i iterations.\")\n",
|
||||
" break\n",
|
||||
@@ -451,7 +476,7 @@
|
||||
" end\n",
|
||||
"\n",
|
||||
" # Tested against Elmer solution\n",
|
||||
" u = e.attributes[\"displacement\"]\n",
|
||||
" u = get_field(el, \"displacement\")\n",
|
||||
" Logging.debug(\"solution vector: \\n $u\")\n",
|
||||
" @fact u[2, 3] --> roughly(-2.222244754401764)\n",
|
||||
" norm1 = norm(u)\n",
|
||||
@@ -462,25 +487,26 @@
|
||||
" rmat = [\n",
|
||||
" cos(phi) -sin(phi)\n",
|
||||
" sin(phi) cos(phi)]\n",
|
||||
" set_coordinates(e, rmat*get_coordinates(e))\n",
|
||||
" set_field(el, \"coordinates\", rmat*get_field(el, \"coordinates\"))\n",
|
||||
" F = rmat*F\n",
|
||||
"\n",
|
||||
" e.attributes[\"displacement\"] = [0.0 0.0; 0.0 0.0; 0.0 0.0; 0.0 0.0]'\n",
|
||||
" set_field(el, \"displacement\", [0.0 0.0; 0.0 0.0; 0.0 0.0; 0.0 0.0]')\n",
|
||||
" du = zeros(2, 4)\n",
|
||||
" for i=1:10\n",
|
||||
" Logging.debug(\"Iteration $i\")\n",
|
||||
" A = get_lhs(e)\n",
|
||||
" b = get_rhs(e)\n",
|
||||
" A = get_lhs(eq)\n",
|
||||
" b = get_rhs(eq)\n",
|
||||
" Logging.debug(\"Solving Ax = b\")\n",
|
||||
" du[free_dofs] = A[free_dofs, free_dofs] \\ (b + F)[free_dofs]\n",
|
||||
"\n",
|
||||
" e.attributes[\"displacement\"] += du\n",
|
||||
" field = get_field(el, \"displacement\") + du\n",
|
||||
" set_field(el, \"displacement\", field)\n",
|
||||
" if norm(du) < 1.0e-9\n",
|
||||
" Logging.debug(\"Converged in $i iterations.\")\n",
|
||||
" break\n",
|
||||
" end\n",
|
||||
" end\n",
|
||||
" u = e.attributes[\"displacement\"]\n",
|
||||
" u = get_field(el, \"displacement\")\n",
|
||||
" Logging.debug(\"solution vector: \\n $u\")\n",
|
||||
" Logging.debug(\"norm of u: $(norm(u))\")\n",
|
||||
" @fact norm(u) --> roughly(norm1) \n",
|
||||
@@ -496,7 +522,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"execution_count": 9,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -507,7 +533,7 @@
|
||||
"assemble_rhs! (generic function with 1 method)"
|
||||
]
|
||||
},
|
||||
"execution_count": 10,
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -546,7 +572,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"execution_count": 10,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -557,7 +583,7 @@
|
||||
"get_field (generic function with 2 methods)"
|
||||
]
|
||||
},
|
||||
"execution_count": 11,
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -571,13 +597,6 @@
|
||||
"end"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"We also need to construct our element in somehow \"standard\" way. My proposal is: element id and node ids (connectivity) information. Of course other fields must also be provided. Here's example for CPS4 element:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
@@ -587,7 +606,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"execution_count": 11,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -598,7 +617,7 @@
|
||||
"set_attribute (generic function with 1 method)"
|
||||
]
|
||||
},
|
||||
"execution_count": 12,
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -618,7 +637,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"execution_count": 12,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -638,7 +657,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"execution_count": 13,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -649,7 +668,7 @@
|
||||
"get_lhs (generic function with 3 methods)"
|
||||
]
|
||||
},
|
||||
"execution_count": 14,
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -691,7 +710,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"execution_count": 14,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -707,38 +726,38 @@
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"24-Aug 01:06:39:DEBUG:root:Starting iteration 1\n",
|
||||
"24-Aug 01:06:39:DEBUG:root:Assembling\n",
|
||||
"24-Aug 01:06:39:DEBUG:root:Assembling element 1\n",
|
||||
"24-Aug 01:06:39:DEBUG:root:Assembling element 2\n",
|
||||
"24-Aug 01:06:40:DEBUG:root:Solution norm = 3.0900221367289986\n",
|
||||
"24-Aug 01:06:40:DEBUG:root:Starting iteration 2\n",
|
||||
"24-Aug 01:06:40:DEBUG:root:Assembling\n",
|
||||
"24-Aug 01:06:40:DEBUG:root:Assembling element 1\n",
|
||||
"24-Aug 01:06:40:DEBUG:root:Assembling element 2\n",
|
||||
"24-Aug 01:06:40:DEBUG:root:Solution norm = 0.3212131602153472\n",
|
||||
"24-Aug 01:06:40:DEBUG:root:Starting iteration 3\n",
|
||||
"24-Aug 01:06:40:DEBUG:root:Assembling\n",
|
||||
"24-Aug 01:06:40:DEBUG:root:Assembling element 1\n",
|
||||
"24-Aug 01:06:40:DEBUG:root:Assembling element 2\n",
|
||||
"24-Aug 01:06:40:DEBUG:root:Solution norm = 0.04043178193999703\n",
|
||||
"24-Aug 01:06:40:DEBUG:root:Starting iteration 4\n",
|
||||
"24-Aug 01:06:40:DEBUG:root:Assembling\n",
|
||||
"24-Aug 01:06:40:DEBUG:root:Assembling element 1\n",
|
||||
"24-Aug 01:06:40:DEBUG:root:Assembling element 2\n",
|
||||
"24-Aug 01:06:40:DEBUG:root:Solution norm = 0.0009291101052105739\n",
|
||||
"24-Aug 01:06:40:DEBUG:root:Starting iteration 5\n",
|
||||
"24-Aug 01:06:40:DEBUG:root:Assembling\n",
|
||||
"24-Aug 01:06:40:DEBUG:root:Assembling element 1\n",
|
||||
"24-Aug 01:06:40:DEBUG:root:Assembling element 2\n",
|
||||
"24-Aug 01:06:40:DEBUG:root:Solution norm = 1.5638899027804743e-7\n",
|
||||
"24-Aug 01:06:40:DEBUG:root:Starting iteration 6\n",
|
||||
"24-Aug 01:06:40:DEBUG:root:Assembling\n",
|
||||
"24-Aug 01:06:40:DEBUG:root:Assembling element 1\n",
|
||||
"24-Aug 01:06:40:DEBUG:root:Assembling element 2\n",
|
||||
"24-Aug 01:06:40:DEBUG:root:Solution norm = 1.0464940956129567e-14\n",
|
||||
"24-Aug 01:06:40:DEBUG:root:Converged in 6 iterations.\n",
|
||||
"24-Aug 01:06:40:DEBUG:root:Displacement of element = \n",
|
||||
"24-Aug 18:33:33:DEBUG:root:Starting iteration 1\n",
|
||||
"24-Aug 18:33:33:DEBUG:root:Assembling\n",
|
||||
"24-Aug 18:33:33:DEBUG:root:Assembling element 1\n",
|
||||
"24-Aug 18:33:33:DEBUG:root:Assembling element 2\n",
|
||||
"24-Aug 18:33:34:DEBUG:root:Solution norm = 3.0900221367289986\n",
|
||||
"24-Aug 18:33:34:DEBUG:root:Starting iteration 2\n",
|
||||
"24-Aug 18:33:34:DEBUG:root:Assembling\n",
|
||||
"24-Aug 18:33:34:DEBUG:root:Assembling element 1\n",
|
||||
"24-Aug 18:33:34:DEBUG:root:Assembling element 2\n",
|
||||
"24-Aug 18:33:34:DEBUG:root:Solution norm = 0.3212131602153472\n",
|
||||
"24-Aug 18:33:34:DEBUG:root:Starting iteration 3\n",
|
||||
"24-Aug 18:33:34:DEBUG:root:Assembling\n",
|
||||
"24-Aug 18:33:34:DEBUG:root:Assembling element 1\n",
|
||||
"24-Aug 18:33:34:DEBUG:root:Assembling element 2\n",
|
||||
"24-Aug 18:33:34:DEBUG:root:Solution norm = 0.04043178193999703\n",
|
||||
"24-Aug 18:33:34:DEBUG:root:Starting iteration 4\n",
|
||||
"24-Aug 18:33:34:DEBUG:root:Assembling\n",
|
||||
"24-Aug 18:33:34:DEBUG:root:Assembling element 1\n",
|
||||
"24-Aug 18:33:34:DEBUG:root:Assembling element 2\n",
|
||||
"24-Aug 18:33:34:DEBUG:root:Solution norm = 0.0009291101052105739\n",
|
||||
"24-Aug 18:33:34:DEBUG:root:Starting iteration 5\n",
|
||||
"24-Aug 18:33:34:DEBUG:root:Assembling\n",
|
||||
"24-Aug 18:33:34:DEBUG:root:Assembling element 1\n",
|
||||
"24-Aug 18:33:34:DEBUG:root:Assembling element 2\n",
|
||||
"24-Aug 18:33:34:DEBUG:root:Solution norm = 1.5638899027804743e-7\n",
|
||||
"24-Aug 18:33:34:DEBUG:root:Starting iteration 6\n",
|
||||
"24-Aug 18:33:34:DEBUG:root:Assembling\n",
|
||||
"24-Aug 18:33:34:DEBUG:root:Assembling element 1\n",
|
||||
"24-Aug 18:33:34:DEBUG:root:Assembling element 2\n",
|
||||
"24-Aug 18:33:34:DEBUG:root:Solution norm = 1.0464940956129567e-14\n",
|
||||
"24-Aug 18:33:34:DEBUG:root:Converged in 6 iterations.\n",
|
||||
"24-Aug 18:33:34:DEBUG:root:Displacement of element = \n",
|
||||
"[0.0 -0.39914506095474334 -0.0722858269559246 0.0\n",
|
||||
" 0.0 -2.1779892317073504 -2.222244754401764 0.0]\n"
|
||||
]
|
||||
@@ -756,7 +775,7 @@
|
||||
"delayed_handler (generic function with 4 methods)"
|
||||
]
|
||||
},
|
||||
"execution_count": 17,
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -832,7 +851,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 18,
|
||||
"execution_count": 15,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -852,7 +871,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 19,
|
||||
"execution_count": 16,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -863,7 +882,7 @@
|
||||
"MPC"
|
||||
]
|
||||
},
|
||||
"execution_count": 19,
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -879,7 +898,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 20,
|
||||
"execution_count": 17,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -890,7 +909,7 @@
|
||||
"create_ldof2gdofmap (generic function with 1 method)"
|
||||
]
|
||||
},
|
||||
"execution_count": 20,
|
||||
"execution_count": 17,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -956,7 +975,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 22,
|
||||
"execution_count": 18,
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"scrolled": false
|
||||
@@ -973,53 +992,53 @@
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"24-Aug 01:07:29:DEBUG:root:Dict(4=>[7,8],2=>[3,4],3=>[5,6],1=>[1,2])\n",
|
||||
"24-Aug 01:07:29:INFO:root:solve!: dofs per node: 2\n",
|
||||
"24-Aug 01:07:29:DEBUG:root:Problem size = 8\n",
|
||||
"24-Aug 01:07:29:DEBUG:root:Starting iteration 1\n",
|
||||
"24-Aug 01:07:29:DEBUG:root:Assembling lhs\n",
|
||||
"24-Aug 01:07:29:DEBUG:root:Assembling rhs\n",
|
||||
"24-Aug 01:07:29:DEBUG:root:Adding Dirichlet boundary conditions using Lagrange multipliers\n",
|
||||
"24-Aug 01:07:29:DEBUG:root:Added 4 Lagrange multipliers to model\n",
|
||||
"24-Aug 01:07:29:DEBUG:root:Solving system of equations. Total size = 12\n",
|
||||
"24-Aug 01:07:29:DEBUG:root:Solution norm du = 3.0900221367289444\n",
|
||||
"24-Aug 01:07:29:DEBUG:root:Starting iteration 2\n",
|
||||
"24-Aug 01:07:29:DEBUG:root:Assembling lhs\n",
|
||||
"24-Aug 01:07:29:DEBUG:root:Assembling rhs\n",
|
||||
"24-Aug 01:07:29:DEBUG:root:Adding Dirichlet boundary conditions using Lagrange multipliers\n",
|
||||
"24-Aug 01:07:29:DEBUG:root:Added 4 Lagrange multipliers to model\n",
|
||||
"24-Aug 01:07:29:DEBUG:root:Solving system of equations. Total size = 12\n",
|
||||
"24-Aug 01:07:29:DEBUG:root:Solution norm du = 0.32121316021534796\n",
|
||||
"24-Aug 01:07:29:DEBUG:root:Starting iteration 3\n",
|
||||
"24-Aug 01:07:29:DEBUG:root:Assembling lhs\n",
|
||||
"24-Aug 01:07:29:DEBUG:root:Assembling rhs\n",
|
||||
"24-Aug 01:07:29:DEBUG:root:Adding Dirichlet boundary conditions using Lagrange multipliers\n",
|
||||
"24-Aug 01:07:29:DEBUG:root:Added 4 Lagrange multipliers to model\n",
|
||||
"24-Aug 01:07:29:DEBUG:root:Solving system of equations. Total size = 12\n",
|
||||
"24-Aug 01:07:29:DEBUG:root:Solution norm du = 0.040431781940014504\n",
|
||||
"24-Aug 01:07:29:DEBUG:root:Starting iteration 4\n",
|
||||
"24-Aug 01:07:29:DEBUG:root:Assembling lhs\n",
|
||||
"24-Aug 01:07:29:DEBUG:root:Assembling rhs\n",
|
||||
"24-Aug 01:07:29:DEBUG:root:Adding Dirichlet boundary conditions using Lagrange multipliers\n",
|
||||
"24-Aug 01:07:29:DEBUG:root:Added 4 Lagrange multipliers to model\n",
|
||||
"24-Aug 01:07:29:DEBUG:root:Solving system of equations. Total size = 12\n",
|
||||
"24-Aug 01:07:29:DEBUG:root:Solution norm du = 0.0009291101052065917\n",
|
||||
"24-Aug 01:07:30:DEBUG:root:Starting iteration 5\n",
|
||||
"24-Aug 01:07:30:DEBUG:root:Assembling lhs\n",
|
||||
"24-Aug 01:07:30:DEBUG:root:Assembling rhs\n",
|
||||
"24-Aug 01:07:30:DEBUG:root:Adding Dirichlet boundary conditions using Lagrange multipliers\n",
|
||||
"24-Aug 01:07:30:DEBUG:root:Added 4 Lagrange multipliers to model\n",
|
||||
"24-Aug 01:07:30:DEBUG:root:Solving system of equations. Total size = 12\n",
|
||||
"24-Aug 01:07:30:DEBUG:root:Solution norm du = 1.5638899136781228e-7\n",
|
||||
"24-Aug 01:07:30:DEBUG:root:Starting iteration 6\n",
|
||||
"24-Aug 01:07:30:DEBUG:root:Assembling lhs\n",
|
||||
"24-Aug 01:07:30:DEBUG:root:Assembling rhs\n",
|
||||
"24-Aug 01:07:30:DEBUG:root:Adding Dirichlet boundary conditions using Lagrange multipliers\n",
|
||||
"24-Aug 01:07:30:DEBUG:root:Added 4 Lagrange multipliers to model\n",
|
||||
"24-Aug 01:07:30:DEBUG:root:Solving system of equations. Total size = 12\n",
|
||||
"24-Aug 01:07:30:DEBUG:root:Solution norm du = 1.0913504694802626e-14\n",
|
||||
"24-Aug 01:07:30:DEBUG:root:Converged in 6 iterations.\n",
|
||||
"24-Aug 01:07:30:DEBUG:root:Displacement on upper right = \n",
|
||||
"24-Aug 18:34:38:DEBUG:root:Dict(4=>[7,8],2=>[3,4],3=>[5,6],1=>[1,2])\n",
|
||||
"24-Aug 18:34:38:INFO:root:solve!: dofs per node: 2\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Problem size = 8\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Starting iteration 1\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Assembling lhs\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Assembling rhs\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Adding Dirichlet boundary conditions using Lagrange multipliers\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Added 4 Lagrange multipliers to model\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Solving system of equations. Total size = 12\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Solution norm du = 3.0900221367289444\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Starting iteration 2\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Assembling lhs\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Assembling rhs\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Adding Dirichlet boundary conditions using Lagrange multipliers\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Added 4 Lagrange multipliers to model\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Solving system of equations. Total size = 12\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Solution norm du = 0.32121316021534796\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Starting iteration 3\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Assembling lhs\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Assembling rhs\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Adding Dirichlet boundary conditions using Lagrange multipliers\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Added 4 Lagrange multipliers to model\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Solving system of equations. Total size = 12\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Solution norm du = 0.040431781940014504\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Starting iteration 4\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Assembling lhs\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Assembling rhs\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Adding Dirichlet boundary conditions using Lagrange multipliers\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Added 4 Lagrange multipliers to model\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Solving system of equations. Total size = 12\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Solution norm du = 0.0009291101052065917\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Starting iteration 5\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Assembling lhs\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Assembling rhs\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Adding Dirichlet boundary conditions using Lagrange multipliers\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Added 4 Lagrange multipliers to model\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Solving system of equations. Total size = 12\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Solution norm du = 1.5638899136781228e-7\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Starting iteration 6\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Assembling lhs\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Assembling rhs\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Adding Dirichlet boundary conditions using Lagrange multipliers\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Added 4 Lagrange multipliers to model\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Solving system of equations. Total size = 12\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Solution norm du = 1.0913504694802626e-14\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Converged in 6 iterations.\n",
|
||||
"24-Aug 18:34:39:DEBUG:root:Displacement on upper right = \n",
|
||||
"[-0.07228582695592467\n",
|
||||
" -2.222244754401765]\n"
|
||||
]
|
||||
@@ -1037,7 +1056,7 @@
|
||||
"delayed_handler (generic function with 4 methods)"
|
||||
]
|
||||
},
|
||||
"execution_count": 22,
|
||||
"execution_count": 18,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
|
||||
+6
-5
@@ -99,15 +99,16 @@ This version returns another function which can be then evaluated against field
|
||||
"""
|
||||
function linearize(f::Function, field::ASCIIString)
|
||||
function jacobian(el::Element, args...)
|
||||
dim, nnodes = size(el.attributes[field])
|
||||
fld = get_field(el, field)
|
||||
dim, nnodes = size(fld)
|
||||
function helper!(x, y)
|
||||
orig = copy(el.attributes[field])
|
||||
el.attributes[field] = reshape(x, dim, nnodes)
|
||||
orig = copy(fld)
|
||||
set_field(el, field, reshape(x, dim, nnodes))
|
||||
y[:] = f(el, args...)
|
||||
el.attributes[field] = copy(orig)
|
||||
set_field(el, field, copy(orig))
|
||||
end
|
||||
jac = ForwardDiff.forwarddiff_jacobian(helper!, Float64, fadtype=:dual, n=dim*nnodes, m=dim*nnodes)
|
||||
return jac(el.attributes[field][:])
|
||||
return jac(fld[:])
|
||||
end
|
||||
return jacobian
|
||||
end
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ type IntegrationPoint
|
||||
weight :: Float64
|
||||
attributes :: Dict{ASCIIString, Any}
|
||||
end
|
||||
IntegrationPoint(xi, weight) = IntegrationPoint(xi, weight, Dict{AsciiString, Any}())
|
||||
IntegrationPoint(xi, weight) = IntegrationPoint(xi, weight, Dict{ASCIIString, Any}())
|
||||
|
||||
type Assembly
|
||||
# LHS
|
||||
|
||||
Reference in New Issue
Block a user