コード例 #1
0
ファイル: t_mumpssol03_main.go プロジェクト: yunpeng1/gosl
func main() {

	mpi.Start(false)
	defer func() {
		mpi.Stop(false)
	}()

	myrank := mpi.Rank()
	if myrank == 0 {
		chk.PrintTitle("Test MUMPS Sol 03")
	}

	var t la.TripletC
	switch mpi.Size() {
	case 1:
		t.Init(5, 5, 13, true)
		t.Put(0, 0, 1.0, 0)
		t.Put(0, 0, 1.0, 0)
		t.Put(1, 0, 3.0, 0)
		t.Put(0, 1, 3.0, 0)
		t.Put(2, 1, -1.0, 0)
		t.Put(4, 1, 4.0, 0)
		t.Put(1, 2, 4.0, 0)
		t.Put(2, 2, -3.0, 0)
		t.Put(3, 2, 1.0, 0)
		t.Put(4, 2, 2.0, 0)
		t.Put(2, 3, 2.0, 0)
		t.Put(1, 4, 6.0, 0)
		t.Put(4, 4, 1.0, 0)
	case 2:
		if myrank == 0 {
			t.Init(5, 5, 6, true)
			t.Put(0, 0, 1.0, 0)
			t.Put(0, 0, 1.0, 0)
			t.Put(1, 0, 3.0, 0)
			t.Put(0, 1, 3.0, 0)
			t.Put(2, 1, -1.0, 0)
			t.Put(4, 1, 4.0, 0)
		} else {
			t.Init(5, 5, 7, true)
			t.Put(1, 2, 4.0, 0)
			t.Put(2, 2, -3.0, 0)
			t.Put(3, 2, 1.0, 0)
			t.Put(4, 2, 2.0, 0)
			t.Put(2, 3, 2.0, 0)
			t.Put(1, 4, 6.0, 0)
			t.Put(4, 4, 1.0, 0)
		}
	default:
		chk.Panic("this test needs 1 or 2 procs")
	}

	b := []complex128{8.0, 45.0, -3.0, 3.0, 19.0}
	x_correct := []complex128{1, 2, 3, 4, 5}
	sum_b_to_root := false
	la.RunMumpsTestC(&t, 1e-14, b, x_correct, sum_b_to_root)
}
コード例 #2
0
func main() {

	mpi.Start(false)
	defer func() {
		mpi.Stop(false)
	}()

	myrank := mpi.Rank()
	if myrank == 0 {
		chk.PrintTitle("Test MUMPS Sol 05")
	}

	ndim := 10
	id, sz := mpi.Rank(), mpi.Size()
	start, endp1 := (id*ndim)/sz, ((id+1)*ndim)/sz

	if mpi.Size() > ndim {
		chk.Panic("the number of processors must be smaller than or equal to %d", ndim)
	}

	n := 10
	b := make([]complex128, n)
	x_correct := make([]complex128, n)

	// Let exact solution = 1 + 0.5i
	for i := 0; i < ndim; i++ {
		x_correct[i] = complex(float64(i+1), float64(i+1)/10.0)
	}

	var t la.TripletC
	t.Init(ndim, ndim, ndim, true)

	// assemble a and b
	for i := start; i < endp1; i++ {

		// Some very fake diagonals. Should take exactly 20 GMRES steps
		ar := 10.0 + float64(i)/(float64(ndim)/10.0)
		ac := 10.0 - float64(i)/(float64(ndim)/10.0)
		t.Put(i, i, ar, ac)

		// Generate RHS to match exact solution
		b[i] = complex(ar*real(x_correct[i])-ac*imag(x_correct[i]),
			ar*imag(x_correct[i])+ac*real(x_correct[i]))
	}

	sum_b_to_root := true
	la.RunMumpsTestC(&t, 1e-14, b, x_correct, sum_b_to_root)
}
コード例 #3
0
ファイル: t_mumpssol04_main.go プロジェクト: yunpeng1/gosl
func main() {

	mpi.Start(false)
	defer func() {
		mpi.Stop(false)
	}()

	myrank := mpi.Rank()
	if myrank == 0 {
		chk.PrintTitle("Test MUMPS Sol 04")
	}

	ndim := 10
	id, sz := mpi.Rank(), mpi.Size()
	start, endp1 := (id*ndim)/sz, ((id+1)*ndim)/sz

	if mpi.Size() > ndim {
		chk.Panic("the number of processors must be smaller than or equal to %d", ndim)
	}

	b := make([]complex128, ndim)
	var t la.TripletC
	t.Init(ndim, ndim, ndim*ndim, true)

	for i := start; i < endp1; i++ {
		j := i
		if i > 0 {
			j = i - 1
		}
		for ; j < 10; j++ {
			val := 10.0 - float64(j)
			if i > j {
				val -= 1.0
			}
			t.Put(i, j, val, 0)
		}
		b[i] = complex(float64(i+1), 0.0)
	}

	x_correct := []complex128{-1, 8, -65, 454, -2725, 13624, -54497, 163490, -326981, 326991}
	sum_b_to_root := true
	la.RunMumpsTestC(&t, 1e-4, b, x_correct, sum_b_to_root)
}