cubeND.rb
# Divide a domain to two Subdomains and one Separator
Divide a domain to two Subdomains and one Separator
Divide a domain to two Subdomains and one Separator
def bipart(domain)
  if (domain.is_a? Domain) && !(domain.is_a? Separator)
    o = domain.origin
    areas = { x: domain.y_size*domain.z_size, y: domain.x_size*domain.z_size, z: domain.x_size*domain.y_size }
    case areas.min_by(&:last)[0]
    when :x
      lx = (domain.x_size - 1) / 2
      sx = 1
      rx = (domain.x_size - 1) - lx
      ld = Subdomain.new(lx, domain.y_size, domain.z_size, o.x         , o.y, o.z)
      sp = Separator.new( 1, domain.y_size, domain.z_size, o.x + lx    , o.y, o.z)
      rd = Subdomain.new(rx, domain.y_size, domain.z_size, o.x + lx + 1, o.y, o.z)
      return ld, rd, sp
    when :y
      ly = (domain.y_size - 1) / 2
      sy = 1
      ry = (domain.y_size - 1) - ly
      ld = Subdomain.new(domain.x_size, ly, domain.z_size, o.x, o.y         , o.z)
      sp = Separator.new(domain.x_size,  1, domain.z_size, o.x, o.y + ly    , o.z)
      rd = Subdomain.new(domain.x_size, ry, domain.z_size, o.x, o.y + ly + 1, o.z)
      return ld, rd, sp
    when :z
      lz = (domain.z_size - 1) / 2
      sz = 1
      rz = (domain.z_size - 1) - lz
      ld = Subdomain.new(domain.x_size, domain.y_size, lz, o.x, o.y, o.z         )
      sp = Separator.new(domain.x_size, domain.y_size, 1 , o.x, o.y, o.z + lz    )
      rd = Subdomain.new(domain.x_size, domain.y_size, rz, o.x, o.y, o.z + lz + 1)
      return ld ,rd, sp
    else
      return nil, nil, domain
    end
  end
  return nil, nil, domain
end
def bipart ( domain ) if ( domain . is_a? Domain ) && ! ( domain . is_a? Separator ) o = domain . origin areas = { x : domain . y_size * domain . z_size , y : domain . x_size * domain . z_size , z : domain . x_size * domain . y_size } case areas . min_by ( & :last ) [ 0 ] when :x lx = ( domain . x_size - 1 ) / 2 sx = 1 rx = ( domain . x_size - 1 ) - lx ld = Subdomain . new ( lx , domain . y_size , domain . z_size , o . x , o . y , o . z ) sp = Separator . new ( 1 , domain . y_size , domain . z_size , o . x + lx , o . y , o . z ) rd = Subdomain . new ( rx , domain . y_size , domain . z_size , o . x + lx + 1 , o . y , o . z ) return ld , rd , sp when :y ly = ( domain . y_size - 1 ) / 2 sy = 1 ry = ( domain . y_size - 1 ) - ly ld = Subdomain . new ( domain . x_size , ly , domain . z_size , o . x , o . y , o . z ) sp = Separator . new ( domain . x_size , 1 , domain . z_size , o . x , o . y + ly , o . z ) rd = Subdomain . new ( domain . x_size , ry , domain . z_size , o . x , o . y + ly + 1 , o . z ) return ld , rd , sp when :z lz = ( domain . z_size - 1 ) / 2 sz = 1 rz = ( domain . z_size - 1 ) - lz ld = Subdomain . new ( domain . x_size , domain . y_size , lz , o . x , o . y , o . z ) sp = Separator . new ( domain . x_size , domain . y_size , 1 , o . x , o . y , o . z + lz ) rd = Subdomain . new ( domain . x_size , domain . y_size , rz , o . x , o . y , o . z + lz + 1 ) return ld , rd , sp else return nil , nil , domain end end return nil , nil , domain end
Divide a domain to two Subdomains and one Separator
Divide a domain to two Subdomains and one Separator
# domain must be a Domain and not a Separator
domain
<not_specific>