// GetAndInitPorousModel get porous model from material name // It returns nil on errors, after logging func GetAndInitPorousModel(mdb *inp.MatDb, matname, simfnk string) (mdl *mporous.Model, err error) { // materials cndmat, lrmmat, pormat, err := mdb.GroupGet3(matname, "c", "l", "p") if err != nil { err = chk.Err("materials database failed on getting %q (porous) group:\n%v", matname, err) return } // conductivity models getnew := false cnd := mconduct.GetModel(simfnk, cndmat.Name, cndmat.Model, getnew) if cnd == nil { err = chk.Err("cannot allocate conductivity models with name=%q", cndmat.Model) return } // retention model lrm := mreten.GetModel(simfnk, lrmmat.Name, lrmmat.Model, getnew) if lrm == nil { err = chk.Err("cannot allocate liquid retention model with name=%q", lrmmat.Model) return } // porous model mdl = mporous.GetModel(simfnk, pormat.Name, getnew) if mdl == nil { err = chk.Err("cannot allocate model for porous medium with name=%q", pormat.Name) return } // initialise all models // TODO: initialise just once err = cnd.Init(cndmat.Prms) if err != nil { err = chk.Err("cannot initialise conductivity model:\n%v", err) return } err = lrm.Init(lrmmat.Prms) if err != nil { err = chk.Err("cannot initialise liquid retention model:\n%v", err) return } err = mdl.Init(pormat.Prms, cnd, lrm) if err != nil { err = chk.Err("cannot initialise porous model:\n%v", err) return } return }