mirror of
https://github.com/JuliaFEM/JuliaFEM.jl.git
synced 2026-09-27 12:16:56 +00:00
time properly implemented to .. everything.
This commit is contained in:
@@ -13,11 +13,35 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"WARNING: Base.String is deprecated, use AbstractString instead.\n",
|
||||
"WARNING: Base.String is deprecated, use AbstractString instead.\n",
|
||||
"WARNING: Base.String is deprecated, use AbstractString instead.\n",
|
||||
"WARNING: Base.String is deprecated, use AbstractString instead.\n",
|
||||
"WARNING: Base.String is deprecated, use AbstractString instead.\n",
|
||||
"WARNING: Base.String is deprecated, use AbstractString instead.\n",
|
||||
"WARNING: Base.String is deprecated, use AbstractString instead.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"Logger(root,DEBUG,PipeEndpoint(open, 0 bytes waiting),root)"
|
||||
]
|
||||
},
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"using Logging\n",
|
||||
"using FactCheck\n",
|
||||
@@ -49,7 +73,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -133,7 +157,7 @@
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"get_element_dimension (generic function with 8 methods)"
|
||||
"get_element_dimension (generic function with 7 methods)"
|
||||
]
|
||||
},
|
||||
"execution_count": 5,
|
||||
@@ -164,21 +188,25 @@
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"28-Sep 12:56:52:INFO:root:Testing element MyQuad4\n",
|
||||
"28-Sep 12:56:52:INFO:root:number of basis functions in this element: 4\n",
|
||||
"28-Sep 12:56:53:INFO:root:Initializing element\n",
|
||||
"28-Sep 12:56:53:INFO:root:Element dimension: 2\n",
|
||||
"28-Sep 12:56:53:INFO:root:Setting scalar field JuliaFEM.Field{Int64}(0.0,1,[1,2,3,4]) to element.\n"
|
||||
"29-Sep 00:06:50:INFO:root:Testing element MyQuad4\n",
|
||||
"29-Sep 00:06:50:INFO:root:number of basis functions in this element: 4\n",
|
||||
"29-Sep 00:06:50:INFO:root:Initializing element\n",
|
||||
"29-Sep 00:06:50:INFO:root:Element dimension: 2\n",
|
||||
"29-Sep 00:06:50:INFO:root:Creating new scalar field JuliaFEM.Field{Array{Int64,1}}(0.0,1,[1,2,3,4])\n",
|
||||
"29-Sep 00:06:50:INFO:root:Pushing field to element.\n",
|
||||
"29-Sep 00:06:50:INFO:root:Interpolating scalar field at [0.0,0.0]\n",
|
||||
"29-Sep 00:06:51:INFO:root:Value: 2.5\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"ename": "LoadError",
|
||||
"evalue": "LoadError: MethodError: `convert` has no method matching convert(::Type{Array{JuliaFEM.Field{T},1}}, ::JuliaFEM.Field{Int64})\nThis may have arisen from a call to the constructor Array{JuliaFEM.Field{T},1}(...),\nsince type constructors fall back to convert methods.\nClosest candidates are:\n call{T}(::Type{T}, ::Any)\n convert{T}(::Type{Array{T,1}}, !Matched::Range{T})\n convert{T,S,N}(::Type{Array{T,N}}, !Matched::SubArray{S,N,P<:AbstractArray{T,N},I<:Tuple{Vararg{Union{AbstractArray{T,1},Colon,Int64}}},LD})\n ...\nwhile loading In[6], in expression starting on line 2",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"LoadError: MethodError: `convert` has no method matching convert(::Type{Array{JuliaFEM.Field{T},1}}, ::JuliaFEM.Field{Int64})\nThis may have arisen from a call to the constructor Array{JuliaFEM.Field{T},1}(...),\nsince type constructors fall back to convert methods.\nClosest candidates are:\n call{T}(::Type{T}, ::Any)\n convert{T}(::Type{Array{T,1}}, !Matched::Range{T})\n convert{T,S,N}(::Type{Array{T,N}}, !Matched::SubArray{S,N,P<:AbstractArray{T,N},I<:Tuple{Vararg{Union{AbstractArray{T,1},Colon,Int64}}},LD})\n ...\nwhile loading In[6], in expression starting on line 2",
|
||||
""
|
||||
]
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"PipeEndpoint(open, 0 bytes waiting)"
|
||||
]
|
||||
},
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
@@ -195,31 +223,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"24-Sep 21:04:04:INFO:root:Value: [2.5]\n",
|
||||
"24-Sep 21:04:04:INFO:root:Element MyQuad4 passed tests.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"using JuliaFEM: set_field, interpolate\n",
|
||||
"el1 = MyQuad4([1, 2, 3, 4])\n",
|
||||
"set_field(el1, :temperature, [1, 2, 3, 4])\n",
|
||||
"set_field(el1, :Geometry, Vector[[0.0,0.0,0.0], [10.0,0.0,0.0], [10.0,1.0,0.0], [0.0,1.0,0.0]]);\n",
|
||||
"set_field(el1, :\"heat coefficient\", 1);"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"execution_count": 7,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -227,22 +231,59 @@
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"2.5"
|
||||
"2-element Array{JuliaFEM.Field{T},1}:\n",
|
||||
" JuliaFEM.Field{Int64}(0.0,1,2)\n",
|
||||
" JuliaFEM.Field{Int64}(1.0,1,3)"
|
||||
]
|
||||
},
|
||||
"execution_count": 9,
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"29-Sep 00:06:51:INFO:root:Element MyQuad4 passed tests.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"using JuliaFEM: new_field!, push_field!, interpolate, dinterpolate\n",
|
||||
"el1 = MyQuad4([1, 2, 3, 4])\n",
|
||||
"new_field!(el1, :temperature, Field(0.0, [0.0, 0.0, 0.0, 0.0]))\n",
|
||||
"push_field!(el1, :temperature, Field(1.0, [1.0, 2.0, 3.0, 4.0]))\n",
|
||||
"new_field!(el1, :Geometry, Field(0.0, Vector[[0.0,0.0,0.0], [10.0,0.0,0.0], [10.0,1.0,0.0], [0.0,1.0,0.0]]))\n",
|
||||
"new_field!(el1, \"heat coefficient\", Field(0.0, 2))\n",
|
||||
"push_field!(el1, \"heat coefficient\", Field(1.0, 3))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"1.25"
|
||||
]
|
||||
},
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# temperature at the middle poinf of the element, 1/4*(1+2+3+4)\n",
|
||||
"interpolate(el1, :temperature, [0.0, 0.0])"
|
||||
"# temperature at the middle poinf of the element, 1/4*(1+2+3+4) at t=0.5\n",
|
||||
"interpolate(el1, :temperature, [0.0, 0.0], 0.5)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"execution_count": 9,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -256,14 +297,39 @@
|
||||
" 0.0"
|
||||
]
|
||||
},
|
||||
"execution_count": 10,
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# geometry midpoint of element\n",
|
||||
"interpolate(el1, :Geometry, [0.0, 0.0])"
|
||||
"interpolate(el1, :Geometry, [0.0, 0.0], -Inf)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"3x2 Array{Float64,2}:\n",
|
||||
" 5.0 0.0\n",
|
||||
" 0.0 0.5\n",
|
||||
" 0.0 0.0"
|
||||
]
|
||||
},
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"dinterpolate(el1, :Geometry, [0.0, 0.0], -Inf)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -276,7 +342,7 @@
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"1"
|
||||
"([0.625,0.625,0.625,0.625],[0.75,0.75,0.75,0.75])"
|
||||
]
|
||||
},
|
||||
"execution_count": 11,
|
||||
@@ -286,7 +352,7 @@
|
||||
],
|
||||
"source": [
|
||||
"# interpolating scalar -> scalar.\n",
|
||||
"interpolate(el1, :\"heat coefficient\", [0.0, 0.0])"
|
||||
"interpolate(el1, \"heat coefficient\", [0.0, 0.0], 0.5), interpolate(el1, \"heat coefficient\", [0.0, 0.0], Inf)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -304,10 +370,9 @@
|
||||
"source": [
|
||||
"## Developing own formulation\n",
|
||||
"\n",
|
||||
"Let's consider Poisson equation\n",
|
||||
"Let's consider a Laplace equation\n",
|
||||
"\\begin{align}\n",
|
||||
"\\Delta{u} &= 0 && \\text{on } \\Omega \\\\\n",
|
||||
"u &= u_0 && \\text{on } \\Gamma_{\\mathrm{D}} \\\\\n",
|
||||
"\\frac{\\partial u}{\\partial n} &= g && \\text{on } \\Gamma_{\\mathrm{N}}\n",
|
||||
"\\end{align}\n",
|
||||
"\n",
|
||||
@@ -399,7 +464,7 @@
|
||||
" 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",
|
||||
" set_field(el, :temperature, zeros(2, 4)) # assign new field \"temperature\" to element\n",
|
||||
" new_field!(el, :temperature) # assign new field \"temperature\" to element\n",
|
||||
" DC2D4(el, integration_points, [])\n",
|
||||
"end"
|
||||
]
|
||||
@@ -435,10 +500,11 @@
|
||||
"\"\"\"\n",
|
||||
"Left hand side defined in integration point\n",
|
||||
"\"\"\"\n",
|
||||
"function JuliaFEM.get_lhs(eq::DC2D4, ip)\n",
|
||||
"function JuliaFEM.get_lhs(eq::DC2D4, ip, t)\n",
|
||||
" el = get_element(eq)\n",
|
||||
" dNdX = get_dbasisdX(el, ip.xi)\n",
|
||||
" hc = interpolate(el, :\"temperature thermal conductivity\", ip.xi)\n",
|
||||
" dNdX = get_dbasisdX(el, ip.xi, t)\n",
|
||||
" fld = el[\"temperature thermal conductivity\"](t)\n",
|
||||
" hc = sum(el(ip.xi) * fld)\n",
|
||||
" return dNdX*hc*dNdX'\n",
|
||||
"end\n",
|
||||
"JuliaFEM.has_lhs(eq::DC2D4) = true"
|
||||
@@ -476,17 +542,10 @@
|
||||
"source": [
|
||||
"using JuliaFEM: integrate, integrate_lhs, integrate_rhs\n",
|
||||
"el = Quad4([1, 2, 3, 4])\n",
|
||||
"set_field(el, :Geometry, Vector[[0,0], [1,0], [1,1], [0,1]])\n",
|
||||
"set_field(el, :\"temperature thermal conductivity\", 6)\n",
|
||||
"new_field!(el, :Geometry, Field(0.0, Vector[[0.0,0.0], [1.0,0.0], [1.0,1.0], [0.0,1.0]]))\n",
|
||||
"new_field!(el, \"temperature thermal conductivity\", Field(0.0, 6.0))\n",
|
||||
"eq = DC2D4(el)\n",
|
||||
"integrate_lhs(eq)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"If rhs or lhs is not defined, integration returns nothing."
|
||||
"integrate_lhs(eq, 1.0)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -508,14 +567,14 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"isa(integrate_rhs(eq), Void)"
|
||||
"JuliaFEM.has_lhs(eq)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Next heat flux on boundary:"
|
||||
"If rhs or lhs is not defined, integration returns nothing."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -528,7 +587,7 @@
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"has_rhs (generic function with 2 methods)"
|
||||
"true"
|
||||
]
|
||||
},
|
||||
"execution_count": 18,
|
||||
@@ -536,6 +595,35 @@
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"isa(integrate_rhs(eq, 1.0), Void)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Next heat flux on boundary:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 19,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"has_rhs (generic function with 2 methods)"
|
||||
]
|
||||
},
|
||||
"execution_count": 19,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"using JuliaFEM: get_basis, Seg2\n",
|
||||
"\n",
|
||||
@@ -551,25 +639,25 @@
|
||||
"function DC2D2(el::Seg2)\n",
|
||||
" integration_points = [\n",
|
||||
" IntegrationPoint([0], 2.0)]\n",
|
||||
" set_field(el, :temperature, zeros(2, 1))\n",
|
||||
" new_field!(el, :temperature)\n",
|
||||
" DC2D2(el, integration_points, [])\n",
|
||||
"end\n",
|
||||
"\n",
|
||||
"\"\"\"\n",
|
||||
"Right hand side defined in integration point\n",
|
||||
"\"\"\"\n",
|
||||
"function JuliaFEM.get_rhs(eq::DC2D2, ip)\n",
|
||||
"function JuliaFEM.get_rhs(eq::DC2D2, ip, t)\n",
|
||||
" el = get_element(eq)\n",
|
||||
" N = get_basis(el, ip.xi)\n",
|
||||
" f = interpolate(el, :\"temperature flux\", ip.xi)\n",
|
||||
" return f*N\n",
|
||||
" ϕ = get_basis(el)\n",
|
||||
" f = el[\"temperature flux\"]\n",
|
||||
" return ϕ(ip.xi)*f(t)\n",
|
||||
"end\n",
|
||||
"JuliaFEM.has_rhs(eq::DC2D2) = true"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 19,
|
||||
"execution_count": 20,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -582,17 +670,17 @@
|
||||
" 50.0"
|
||||
]
|
||||
},
|
||||
"execution_count": 19,
|
||||
"execution_count": 20,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"el = Seg2([1, 2])\n",
|
||||
"set_field(el, :Geometry, Vector[[0.0,0.0], [0.0,1.0]])\n",
|
||||
"set_field(el, :\"temperature flux\", 100.0)\n",
|
||||
"new_field!(el, :Geometry, Field(0.0, Vector[[0.0,0.0], [0.0,1.0]]))\n",
|
||||
"new_field!(el, \"temperature flux\", Field(0.0, 100.0))\n",
|
||||
"eq = DC2D2(el)\n",
|
||||
"integrate_rhs(eq)"
|
||||
"integrate_rhs(eq, 1.0)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -607,7 +695,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 20,
|
||||
"execution_count": 21,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -618,7 +706,7 @@
|
||||
"PlaneHeatProblem"
|
||||
]
|
||||
},
|
||||
"execution_count": 20,
|
||||
"execution_count": 21,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -627,14 +715,14 @@
|
||||
"using JuliaFEM: Problem, get_equation, get_dimension\n",
|
||||
"\n",
|
||||
"type PlaneHeatProblem <: Problem\n",
|
||||
" equations :: Array{Any, 1}\n",
|
||||
" equations :: Array{Equation, 1}\n",
|
||||
"end\n",
|
||||
"PlaneHeatProblem() = PlaneHeatProblem([])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 21,
|
||||
"execution_count": 22,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -645,7 +733,7 @@
|
||||
"get_equation (generic function with 3 methods)"
|
||||
]
|
||||
},
|
||||
"execution_count": 21,
|
||||
"execution_count": 22,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -674,7 +762,7 @@
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"24-Sep 21:04:17:DEBUG:root:Problem (matrix) dimension: 4\n"
|
||||
"29-Sep 00:06:53:DEBUG:root:Problem (matrix) dimension: 4\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -687,7 +775,7 @@
|
||||
" -2.0 -1.0 4.0 -1.0\n",
|
||||
" -1.0 -2.0 -1.0 4.0,\n",
|
||||
"\n",
|
||||
"[50.0,50.0,0.0,0.0])"
|
||||
"[300.0,300.0,0.0,0.0])"
|
||||
]
|
||||
},
|
||||
"execution_count": 23,
|
||||
@@ -700,11 +788,11 @@
|
||||
"\n",
|
||||
"# create elements and add necessary properties like connectivity and geometry\n",
|
||||
"el1 = Quad4([1, 2, 3, 4])\n",
|
||||
"set_field(el1, :Geometry, Vector[[0,0], [1,0], [1,1], [0,1]])\n",
|
||||
"set_field(el1, :\"temperature thermal conductivity\", 6)\n",
|
||||
"new_field!(el1, :Geometry, Field(0.0, Vector[[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0]]))\n",
|
||||
"new_field!(el1, \"temperature thermal conductivity\", Field(0.0, 6.0))\n",
|
||||
"el2 = Seg2([1, 2])\n",
|
||||
"set_field(el2, :Geometry, Vector[[0.0,0.0], [0.0,1.0]])\n",
|
||||
"set_field(el2, :\"temperature flux\", 100.0)\n",
|
||||
"new_field!(el2, :Geometry, Field(0.0, Vector[[0.0, 0.0], [0.0, 1.0]]))\n",
|
||||
"new_field!(el2, \"temperature flux\", Field(1.0, 600.0))\n",
|
||||
"\n",
|
||||
"problem = PlaneHeatProblem()\n",
|
||||
"add_element!(problem, el1)\n",
|
||||
@@ -716,20 +804,108 @@
|
||||
"n = get_matrix_dimension(problem)\n",
|
||||
"\n",
|
||||
"# integrate and assembly\n",
|
||||
"t = 1.0\n",
|
||||
"A = zeros(n, n)\n",
|
||||
"b = zeros(n)\n",
|
||||
"for eq in get_equations(problem)\n",
|
||||
" dofs = get_global_dofs(eq)\n",
|
||||
" if has_lhs(eq)\n",
|
||||
" A[dofs, dofs] += integrate_lhs(eq)\n",
|
||||
" A[dofs, dofs] += integrate_lhs(eq, t)\n",
|
||||
" end\n",
|
||||
" if has_rhs(eq)\n",
|
||||
" b[dofs] += integrate_rhs(eq)\n",
|
||||
" b[dofs] += integrate_rhs(eq, t)\n",
|
||||
" end\n",
|
||||
"end\n",
|
||||
"A, b"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 24,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"2-element Array{Float64,1}:\n",
|
||||
" 100.0\n",
|
||||
" 100.0"
|
||||
]
|
||||
},
|
||||
"execution_count": 24,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"fdofs = [1, 2]\n",
|
||||
"A[fdofs, fdofs] \\ b[fdofs]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"We still need to consider Dirichlet boundary conditions:\n",
|
||||
"\\begin{align}\n",
|
||||
"u &= u_0 && \\text{on } \\Gamma_{\\mathrm{D}} \\\\\n",
|
||||
"\\end{align}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 25,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"2x4 Array{Float64,2}:\n",
|
||||
" 0.0 0.0 0.333333 0.166667\n",
|
||||
" 0.0 0.0 0.166667 0.333333"
|
||||
]
|
||||
},
|
||||
"execution_count": 25,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"M = 1/6*[0 0 2 1; 0 0 1 2]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 26,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"6-element Array{Float64,1}:\n",
|
||||
" 100.0 \n",
|
||||
" 100.0 \n",
|
||||
" 1.36187e-14\n",
|
||||
" 1.77636e-15\n",
|
||||
" 600.0 \n",
|
||||
" 600.0 "
|
||||
]
|
||||
},
|
||||
"execution_count": 26,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"[A M'; M zeros(2, 2)] \\ [b; 0; 0]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
@@ -742,13 +918,15 @@
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Julia 0.5.0-dev",
|
||||
"display_name": "Julia 0.4.0-rc2",
|
||||
"language": "julia",
|
||||
"name": "julia-0.5"
|
||||
"name": "julia-0.4"
|
||||
},
|
||||
"language_info": {
|
||||
"file_extension": ".jl",
|
||||
"mimetype": "application/julia",
|
||||
"name": "julia",
|
||||
"version": "0.5.0"
|
||||
"version": "0.4.0"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
Reference in New Issue
Block a user