Ejemplo n.º 1
0
func get_cell_info(ctype string, lbb bool) (ctypeNew string, nverts int) {
	ctypeNew = ctype
	if ctypeNew == "qua9" {
		ctypeNew = "qua8"
	}
	if lbb {
		ctypeNew = shp.GetBasicType(ctypeNew)
	}
	nverts = shp.GetNverts(ctypeNew)
	return
}
Ejemplo n.º 2
0
// register element
func init() {

	// information allocator
	infogetters["up"] = func(cellType string, faceConds []*FaceCond) *Info {

		// new info
		var info Info

		// p-element cell type
		p_cellType := cellType
		lbb := !Global.Sim.Data.NoLBB
		if lbb {
			p_cellType = shp.GetBasicType(cellType)
		}

		// underlying cells info
		u_info := infogetters["u"](cellType, faceConds)
		p_info := infogetters["p"](p_cellType, faceConds)

		// solution variables
		nverts := shp.GetNverts(cellType)
		info.Dofs = make([][]string, nverts)
		for i, dofs := range u_info.Dofs {
			info.Dofs[i] = append(info.Dofs[i], dofs...)
		}
		for i, dofs := range p_info.Dofs {
			info.Dofs[i] = append(info.Dofs[i], dofs...)
		}

		// maps
		info.Y2F = u_info.Y2F
		for key, val := range p_info.Y2F {
			info.Y2F[key] = val
		}

		// t1 and t2 variables
		info.T1vars = p_info.T1vars
		info.T2vars = u_info.T2vars
		return &info
	}

	// element allocator
	eallocators["up"] = func(cellType string, faceConds []*FaceCond, cid int, edat *inp.ElemData, x [][]float64) Elem {

		// basic data
		var o ElemUP
		o.Fconds = faceConds

		// p-element cell type
		p_cellType := cellType
		lbb := !Global.Sim.Data.NoLBB
		if lbb {
			p_cellType = shp.GetBasicType(cellType)
		}

		// cell types
		o.CtypeU = cellType
		o.CtypeP = p_cellType

		// allocate u element
		u_allocator := eallocators["u"]
		u_elem := u_allocator(cellType, faceConds, cid, edat, x)
		if LogErrCond(u_elem == nil, "cannot allocate underlying u-element") {
			return nil
		}
		o.U = u_elem.(*ElemU)

		// make sure p-element uses the same nubmer of integration points than u-element
		edat.Nip = len(o.U.IpsElem)
		//edat.Nipf = len(o.U.IpsFace) // TODO: check if this is necessary

		// allocate p-element
		p_allocator := eallocators["p"]
		p_elem := p_allocator(p_cellType, faceConds, cid, edat, x)
		if LogErrCond(p_elem == nil, "cannot allocate underlying p-element") {
			return nil
		}
		o.P = p_elem.(*ElemP)

		// scratchpad. computed @ each ip
		ndim := Global.Ndim
		o.bs = make([]float64, ndim)
		o.hl = make([]float64, ndim)
		o.Kup = la.MatAlloc(o.U.Nu, o.P.Np)
		o.Kpu = la.MatAlloc(o.P.Np, o.U.Nu)

		// seepage terms
		if o.P.DoExtrap {
			p_nverts := o.P.Shp.Nverts
			u_nverts := o.U.Shp.Nverts
			o.dρldus_ex = la.MatAlloc(p_nverts, u_nverts*ndim)
		}

		// return new element
		return &o
	}
}