﻿ Sample Problems > Usage > 3D_domains > 3d_box_in_sphere

# 3d_box_in_sphere

Navigation:  Sample Problems > Usage > 3D_domains >

# 3d_box_in_sphere   { 3D_BOX_IN_SPHERE.PDE

This problem demonstrates the construction of a box inside a sphere.

We use two conical frustums to define an extrusion layer to contain the box.

The flat surfaces define top and bottom of the box and the cones fall

to meet at the diameter of the sphere.

The box is then defined as a square section of the layer between the

flat surfaces of the frustums.

Click "Controls->Domain Review" to watch the domain construction process.

We solve a heat equation for demonstration purposes.

}

title '3D Box in a Sphere'

coordinates

cartesian3

Select

regrid = off       { for quicker completion }

ngrid = 16

variables

u

definitions

R0 = 1         { sphere radius }

hbox = R0/4     { box half-size }

{ Make the box-bounding circle slightly bigger than box, or corner

intersections will confuse the mesh generator. }

Rbox = 1.1*sqrt(2)*hbox

rho = sqrt(x^2+y^2)             { 2d radius - don't use 'R', it's 3D radius! }

zsphere = SPHERE ((0,0,0),R0)   {  hemisphere shape }

zbottom = -zsphere             { bottom of sphere }

ztop = zsphere                 { top of sphere }

zboxbottom = -hbox { default box-bounding surfaces - patched later in outer sphere }

zboxtop = hbox

zcone = hbox*(R0-rho)/(R0-Rbox) { cone shape for bringing box top to sphere diameter }

K = 1               { Define all parameter defaults for non-box volume}

source = 0

equations

U: div(K*grad(u)) + source   = 0

extrusion

surface z = zbottom         { the bottom hemisphere and plane }

surface z = zboxbottom

surface z = zboxtop

surface z = ztop           { the top hemisphere and plane }

boundaries

surface 1 value(u)=0       { for demonstration purposes }

surface 4 value(u)=0

region 1       { The sphere }

zboxbottom = -zcone

zboxtop = zcone

start  (R0,0)

arc(center=0,0) angle=360 to close

limited region 2       { smaller circle overlays sphere }

layer 2             { ... and exists only in layer 2 }

start(Rbox,0)

arc(center=0,0) angle=360 to close

limited region 3       { the box outline }

layer 2             { box exists only in layer 2 }

source = 1

K = 0.1

start(-hbox,-hbox) line to (hbox,-hbox) to (hbox,hbox) to (-hbox,hbox) to close

plots

grid(x,y,z) as "outer sphere"

grid(x,z) on y=0  nolines as "cross-section showing box"

grid(x,z) on y=0 paintregions nolines as "region and layer structure"

grid(x,y) on z=0 paintregions nolines as "region and layer structure"

contour(u) on y=0 as "temperature"

end