예제 #1
0
func (o *Solver) init_mpi() {
	if mpi.IsOn() {
		o.root = (mpi.Rank() == 0)
		if mpi.Size() > 1 {
			o.Distr = true
		}
	}
}
예제 #2
0
파일: sim.go 프로젝트: PatrickSchm/gofem
// PostProcess performs a post-processing of the just read json file
func (o *LinSolData) PostProcess() {
	if mpi.IsOn() {
		if mpi.Size() > 1 {
			o.Name = "mumps"
		}
	} else {
		o.Name = "umfpack"
	}
}
예제 #3
0
파일: solver.go 프로젝트: PatrickSchm/gofem
// Start initialises 'global' and starts logging
func Start(simfilepath string, erasefiles, verbose bool) (startisok bool) {

	// multiprocessing data
	Global.Rank = 0
	Global.Nproc = 1
	Global.Root = true
	Global.Distr = false
	if mpi.IsOn() {
		Global.Rank = mpi.Rank()
		Global.Nproc = mpi.Size()
		Global.Root = Global.Rank == 0
		Global.Distr = Global.Nproc > 1
	}
	Global.Verbose = verbose
	if !Global.Root {
		Global.Verbose = false
	}
	Global.WspcStop = make([]int, Global.Nproc)
	Global.WspcInum = make([]int, Global.Nproc)

	// simulation and convenience variables
	dir := filepath.Dir(simfilepath)
	fn := filepath.Base(simfilepath)
	Global.Sim = inp.ReadSim(dir, fn, Global.LogPrefix, erasefiles)
	LogErrCond(Global.Sim == nil, "ReadSim failed\n")
	if Stop() {
		return
	}
	Global.Ndim = Global.Sim.Ndim
	Global.Dirout = Global.Sim.Data.DirOut
	Global.Fnkey = Global.Sim.Data.FnameKey
	Global.Enc = Global.Sim.Data.Encoder
	Global.Stat = Global.Sim.Data.Stat
	Global.LogBcs = Global.Sim.Data.LogBcs
	Global.Debug = Global.Sim.Data.Debug

	// fix show residual flag
	if !Global.Root {
		Global.Sim.Data.ShowR = false
	}

	// auxiliar structures
	Global.DynCoefs = new(DynCoefs)
	if !Global.DynCoefs.Init(&Global.Sim.Solver) {
		return
	}
	Global.HydroSt = new(HydroStatic)
	Global.HydroSt.Init()

	// success
	return true
}
예제 #4
0
// InitLogFile initialises logger
func InitLogFile(dirout, fnamekey string) (err error) {

	// create log file
	var rank int
	if mpi.IsOn() {
		rank = mpi.Rank()
	}
	LogFile, err = os.Create(io.Sf("%s/%s_p%d.log", dirout, fnamekey, rank))
	if err != nil {
		return
	}

	// connect logger to output file
	log.SetOutput(LogFile)
	return
}
예제 #5
0
파일: ode.go 프로젝트: PaddySchmidt/gosl
// Init initialises ODE structure with default values and allocate slices
func (o *ODE) Init(method string, ndim int, fcn Cb_fcn, jac Cb_jac, M *la.Triplet, out Cb_out, silent bool) {

	// primary variables
	o.method = method
	o.ndim = ndim
	o.fcn = fcn
	o.jac = jac
	o.out = out
	o.silent = silent
	o.ZeroTrial = false
	o.Atol = 1.0e-4
	o.Rtol = 1.0e-4
	o.IniH = 1.0e-4
	o.NmaxIt = 7
	o.NmaxSS = 1000
	o.Mmin = 0.125
	o.Mmax = 5.0
	o.Mfac = 0.9
	o.PredCtrl = true
	o.ϵ = 1.0e-16
	o.θmax = 1.0e-3
	o.C1h = 1.0
	o.C2h = 1.2
	o.LerrStrat = 3
	o.Pll = true
	o.UseRmsNorm = true
	o.SetTol(o.Atol, o.Rtol)

	// derived variables
	o.root = true
	if mpi.IsOn() {
		o.root = (mpi.Rank() == 0)
		if mpi.Size() > 1 {
			o.Distr = true
		}
	}

	// M matrix
	if M != nil {
		o.mTri = M
		o.mMat = o.mTri.ToMatrix(nil)
		o.hasM = true
	} else {
		if o.method == "BwEuler" {
			M = new(la.Triplet)
			la.SpTriSetDiag(M, o.ndim, 1)
			o.mTri = M
			o.mMat = o.mTri.ToMatrix(nil)
			o.hasM = true
		}
	}

	// method
	switch method {
	case "FwEuler":
		o.step = fweuler_step
		o.accept = fweuler_accept
		o.nstg = 1
	case "BwEuler":
		o.step = bweuler_step
		o.accept = bweuler_accept
		o.nstg = 1
	case "MoEuler":
		o.step = erk_step
		o.accept = erk_accept
		o.nstg = 2
		o.erkdat = ERKdat{true, ME2_a, ME2_b, ME2_be, ME2_c}
	case "Dopri5":
		o.step = erk_step
		o.accept = erk_accept
		o.nstg = 7
		o.erkdat = ERKdat{true, DP5_a, DP5_b, DP5_be, DP5_c}
	case "Radau5":
		o.step = radau5_step
		o.accept = radau5_accept
		o.nstg = 3
	default:
		chk.Panic(_ode_err1, method)
	}

	// allocate step variables
	o.f0 = make([]float64, o.ndim)
	o.scal = make([]float64, o.ndim)

	// allocate rk variables
	o.u = make([]float64, o.nstg)
	o.v = make([][]float64, o.nstg)
	o.w = make([][]float64, o.nstg)
	o.δw = make([][]float64, o.nstg)
	o.f = make([][]float64, o.nstg)
	if method == "Radau5" {
		o.z = make([][]float64, o.nstg)
		o.ycol = make([][]float64, o.nstg)
		o.ez = make([]float64, o.ndim)
		o.lerr = make([]float64, o.ndim)
		o.rhs = make([]float64, o.ndim)
	}
	for i := 0; i < o.nstg; i++ {
		o.v[i] = make([]float64, o.ndim)
		o.w[i] = make([]float64, o.ndim)
		o.δw[i] = make([]float64, o.ndim)
		o.f[i] = make([]float64, o.ndim)
		if method == "Radau5" {
			o.z[i] = make([]float64, o.ndim)
			o.ycol[i] = make([]float64, o.ndim)
		}
	}
}