コード例 #1
0
def gettheref(problem='cylinderwake', N=None, nu=None, Re=None, Nts=None,
              paraout=False, trange=None, scheme=None, data_prefix='',
              debug=False):
    refmeshdict = rtu.get_curmeshdict(problem=problem, N=N, nu=nu,
                                      Re=Re, scheme=scheme)

    refvdict, refpdict = snu.\
        solve_nse(trange=trange, clearprvdata=debug, data_prfx=data_prefix,
                  vfileprfx=proutdir, pfileprfx=proutdir,
                  output_includes_bcs=True,
                  return_dictofvelstrs=True, return_dictofpstrs=True,
                  dictkeysstr=True,
                  start_ssstokes=True, **refmeshdict)

    return refvdict, refpdict
コード例 #2
0
def compvperr(problem=None, scheme=None, trange=None,
              rvd=None, rpd=None, Nref=None,
              cvd=None, cpd=None, Nll=None):
    verrl, perrl = [], []

    rmd = rtu.get_curmeshdict(problem=problem, N=Nref,
                              scheme=scheme, onlymesh=True)
    for tk, t in enumerate(trange):
        vref = dou.load_npa(rvd['{0}'.format(t)])
        pref = dou.load_npa(rpd['{0}'.format(t)])
        # vreff, preff = dts.\
        #     expand_vp_dolfunc(vc=vref, V=rmd['V'], pc=pref, Q=rmd['Q'])

        cmd = rtu.get_curmeshdict(problem=problem, N=Nll[tk],
                                  scheme=scheme, onlymesh=True)
        try:
            vcur = dou.load_npa(cvd[t])
            pcur = dou.load_npa(cpd[t])
        except KeyError:
            vcur = dou.load_npa(cvd['{0}'.format(t)])
            pcur = dou.load_npa(cpd['{0}'.format(t)])

        logger = logging.getLogger("rothemain.compvperr")
        logger.debug("len v={0}, dim V={1}".format(vcur.size, cmd['V'].dim()))
        vcurf, pcurf = dts.\
            expand_vp_dolfunc(vc=vcur, V=cmd['V'], pc=pcur, Q=cmd['Q'])

        # # # This would be the FEniCS way to compute the diff
        #
        # verrl.append(dolfin.errornorm(vreff, vcurf, degree_rise=2))
        #
        # # # however this gave strange results (due to rounding errs?)

        # # # instead we interpolate and substract manually
        Vref = rmd['V']
        vcfinvref = dolfin.interpolate(vcurf, Vref)
        vcinvrefvec = vcfinvref.vector().array()
        difffunc = dolfin.Function(Vref)
        difffunc.vector().set_local(vref.flatten()-vcinvrefvec)

        Qref = rmd['Q']
        pcfinvref = dolfin.interpolate(pcurf, Qref)
        pcinvrefvec = pcfinvref.vector().array()
        difffuncp = dolfin.Function(Qref)
        difffuncp.vector().set_local(pref.flatten()-pcinvrefvec)

        verrl.append(dolfin.norm(difffunc))
        perrl.append(dolfin.norm(difffuncp))

    pverr, pperr, pt = verrl[0], perrl[0], trange[0]
    verrint, perrint = 0, 0
    for k in range(len(trange)-1):
        cverr, cperr, ct = verrl[k+1], perrl[k+1], trange[k+1]
        cts = ct - pt
        logger.debug('t={0}, cts={3}, cverr={1}, verrint={2}'.
                     format(ct, cverr, verrint, cts))
        verrint += 0.5*cts*(pverr + cverr)
        perrint += 0.5*cts*(pperr + cperr)
        pverr, pperr, pt = cverr, cperr, ct

    return dict(verrl=verrl, perrl=perrl, trange=trange,
                perrint=perrint, verrint=verrint,
                Nll=Nll, Nref=Nref)