예제 #1
0
파일: geost.go 프로젝트: PaddySchmidt/gofem
// get_porous_parameters extracts parameters based on region data
func get_porous_parameters(mdb *inp.MatDb, reg *inp.Region, ctag int) (RhoS0, nf0 float64, err error) {
	edat := reg.Etag2data(ctag)
	mat := mdb.Get(edat.Mat)
	if mat.Model != "group" {
		err = chk.Err("geost: material type describing layer must be 'group' with porous data")
		return
	}
	if matname, found := io.Keycode(mat.Extra, "p"); found {
		m := mdb.Get(matname)
		for _, p := range m.Prms {
			switch p.N {
			case "RhoS0":
				RhoS0 = p.V
			case "nf0":
				nf0 = p.V
			}
		}
	}
	if RhoS0 < 1e-7 {
		err = chk.Err("geost: initial density of solids RhoS0=%g is incorrect", RhoS0)
		return
	}
	if nf0 < 1e-7 {
		err = chk.Err("geost: initial porosity nf0=%g is incorrect", nf0)
	}
	return
}
예제 #2
0
func GetAndInitSolidModel(mdb *inp.MatDb, matname, simfnk string, ndim int, pstress bool) (mdl msolid.Model, prms fun.Prms, err error) {

	// material name
	matdata := mdb.Get(matname)
	if matdata == nil {
		err = chk.Err("materials database failed on getting %q (solid) material\n", matname)
		return
	}
	mdlname := matdata.Model

	// handle groups
	if mdlname == "group" {
		if s_matname, found := io.Keycode(matdata.Extra, "s"); found {
			matname = s_matname
			matdata = mdb.Get(matname)
			if matdata == nil {
				err = chk.Err("materials database failed on getting %q (solid/sub) material\n", matname)
				return
			}
			mdlname = matdata.Model
		} else {
			err = chk.Err("cannot find solid model in grouped material data. 's' subkey needed in Extra field")
			return
		}
	}

	// initialise model
	mdl, existent := msolid.GetModel(simfnk, matname, mdlname, false)
	if mdl == nil {
		err = chk.Err("cannot find solid model named %q", mdlname)
		return
	}
	if !existent {
		err = mdl.Init(ndim, pstress, matdata.Prms)
		if err != nil {
			err = chk.Err("solid model initialisation failed:\n%v", err)
			return
		}
	}

	// results
	prms = matdata.Prms
	return
}