Пример #1
0
def getthecoeffs(N=None, Re=None, scheme='CR',
                 inivp='Stokes', inifemp=None):
    femp, stokesmatsc, rhsmomcont \
        = dnsps.get_sysmats(problem='cylinderwake', N=N, Re=Re,
                            scheme=scheme, mergerhs=True)
    fp = rhsmomcont['fp']
    fv = rhsmomcont['fv']
    # stokesmatsc.update(rhsmomcont)

    J, MP = stokesmatsc['J'], stokesmatsc['MP']
    NV, NP = J.T.shape
    # Nv = J.shape[1]
    # Mpfac = spsla.splu(MP)

    if inivp is 'Stokes':
        inivp = lau.solve_sadpnt_smw(amat=stokesmatsc['A'], jmat=J,
                                     jmatT=-J.T, rhsv=fv, rhsp=fp)
        iniv = inivp[:NV]
        inip = snu.get_pfromv(v=iniv, V=femp['V'], M=stokesmatsc['M'],
                              A=stokesmatsc['A'], J=J, fv=fv, fp=fp,
                              diribcs=femp['diribcs'], invinds=femp['invinds'])
    else:
        inv, inp = dts.expand_vp_dolfunc(vp=inivp, **inifemp)
        # interpolate on new mesh and extract the invinds

    getconvvec = getconvvecfun(**femp)
    return dict(A=stokesmatsc['A'], M=stokesmatsc['M'], J=J, JT=J.T, MP=MP,
                fp=fp, fv=fv, getconvvec=getconvvec,
                iniv=iniv, inip=inip,
                V=femp['V'], Q=femp['Q'], invinds=femp['invinds'],
                diribcs=femp['diribcs'], ppin=femp['ppin'], femp=femp)
    def test_pfv(self):
        """check the computation of p from a given v

        """

        femp, stokesmatsc, rhsd = \
            dnsps.get_sysmats(problem='cylinderwake', N=self.N,
                              Re=self.Re, scheme=self.scheme, mergerhs=True)

        Mc, Ac = stokesmatsc['M'], stokesmatsc['A']
        BTc, Bc = stokesmatsc['JT'], stokesmatsc['J']
        print(Bc.shape)

        invinds = femp['invinds']

        fv, fp = rhsd['fv'], rhsd['fp']
        print(np.linalg.norm(fv), np.linalg.norm(fp))
        inivdict = dict(A=Ac, J=Bc, JT=BTc, M=Mc, ppin=self.ppin, fv=fv, fp=fp,
                        return_vp=True, V=femp['V'], clearprvdata=True,
                        invinds=invinds, diribcs=femp['diribcs'])
        vp_init = snu.solve_steadystate_nse(**inivdict)

        NV = Bc.shape[1]

        pfv = snu.get_pfromv(v=vp_init[0], V=femp['V'],
                             M=Mc, A=Ac, J=Bc, fv=fv,
                             invinds=femp['invinds'], diribcs=femp['diribcs'])
        self.assertTrue(np.allclose(pfv, vp_init[1]))
Пример #3
0
    def test_pfv(self):
        """check the computation of p from a given v

        """

        femp, stokesmatsc, rhsd = \
            dnsps.get_sysmats(problem='cylinderwake',
                              meshparams=dict(refinement_level=self.N),
                              Re=self.Re, scheme=self.scheme, mergerhs=True)

        Mc, Ac = stokesmatsc['M'], stokesmatsc['A']
        BTc, Bc = stokesmatsc['JT'], stokesmatsc['J']
        print(Bc.shape)

        invinds = femp['invinds']

        fv, fp = rhsd['fv'], rhsd['fp']
        print(np.linalg.norm(fv), np.linalg.norm(fp))
        inivdict = dict(A=Ac,
                        J=Bc,
                        JT=BTc,
                        M=Mc,
                        ppin=self.ppin,
                        fv=fv,
                        fp=fp,
                        return_vp=True,
                        V=femp['V'],
                        clearprvdata=True,
                        invinds=invinds,
                        diribcs=femp['diribcs'])
        vp_init = snu.solve_steadystate_nse(**inivdict)

        dbcinds, dbcvals = dts.unroll_dlfn_dbcs(femp['diribcs'])
        pfv = snu.get_pfromv(v=vp_init[0][invinds],
                             V=femp['V'],
                             M=Mc,
                             A=Ac,
                             J=Bc,
                             fv=fv,
                             invinds=femp['invinds'],
                             dbcinds=dbcinds,
                             dbcvals=dbcvals)
        self.assertTrue(np.allclose(pfv, vp_init[1]))
Пример #4
0
femp, stokesmatsc, rhsd = \
    dnsps.get_sysmats(problem='cylinderwake', Re=Re,
                      scheme=scheme, mergerhs=True,
                      meshparams=dict(refinement_level=N))

Mc, Ac = stokesmatsc['M'], stokesmatsc['A']
BTc, Bc = stokesmatsc['JT'], stokesmatsc['J']
invinds = femp['invinds']

fv, fp = rhsd['fv'], rhsd['fp']
inivdict = dict(A=Ac, J=Bc, JT=BTc, M=Mc, ppin=ppin, fv=fv, fp=fp,
                return_vp=True, V=femp['V'],
                invinds=invinds, diribcs=femp['diribcs'])

# ## Solve the steady-state NSE
vp_steadystate = snu.solve_steadystate_nse(**inivdict)

NV = Bc.shape[1]

# ## Test: recompute the p from the v
pfv = snu.get_pfromv(v=vp_steadystate[0],
                     V=femp['V'], M=Mc, A=Ac, J=Bc, fv=fv,
                     invinds=femp['invinds'], diribcs=femp['diribcs'])

print('Number of inner velocity nodes: {0}'.format(invinds.shape))
print('Shape of the divergence matrix: ', Bc.shape)

print('error in recomputed pressure: {0}'.
      format(np.linalg.norm(pfv - vp_steadystate[1])))
Пример #5
0
                JT=BTc,
                M=Mc,
                ppin=ppin,
                fv=fv,
                fp=fp,
                return_vp=True,
                V=femp['V'],
                invinds=invinds,
                diribcs=femp['diribcs'])

# ## Solve the steady-state NSE
vp_steadystate = snu.solve_steadystate_nse(**inivdict)

# ## Test: recompute the p from the v
dbcinds, dbcvals = dts.unroll_dlfn_dbcs(femp['diribcs'])
pfv = snu.get_pfromv(v=vp_steadystate[0][femp['invinds'], :],
                     V=femp['V'],
                     M=Mc,
                     A=Ac,
                     J=Bc,
                     fv=fv,
                     invinds=femp['invinds'],
                     dbcinds=dbcinds,
                     dbcvals=dbcvals)

print('Number of inner velocity nodes: {0}'.format(invinds.shape))
print('Shape of the divergence matrix: ', Bc.shape)

print('error in recomputed pressure: {0}'.format(
    np.linalg.norm(pfv - vp_steadystate[1])))
Пример #6
0
N, Re, scheme, ppin = 2, 50, 'TH', None

femp, stokesmatsc, rhsd_vfrc, \
    rhsd_stbc, data_prfx, ddir, proutdir \
    = dnsps.get_sysmats(problem='cylinderwake', N=N, Re=Re,
                        scheme=scheme)

Mc, Ac = stokesmatsc['M'], stokesmatsc['A']
BTc, Bc = stokesmatsc['JT'], stokesmatsc['J']
print Bc.shape

invinds = femp['invinds']

fv, fp = rhsd_stbc['fv'], rhsd_stbc['fp']
inivdict = dict(A=Ac, J=Bc, JT=BTc, M=Mc, ppin=ppin, fv=fv, fp=fp,
                return_vp=True, V=femp['V'],
                invinds=invinds, diribcs=femp['diribcs'])
vp_init = snu.solve_steadystate_nse(**inivdict)[0]

NV = Bc.shape[1]

pfv = snu.get_pfromv(v=vp_init[:NV, :], V=femp['V'], M=Mc, A=Ac, J=Bc, fv=fv,
                     invinds=femp['invinds'], diribcs=femp['diribcs'])
print invinds.shape
print Bc.shape
print pfv.shape
print vp_init.shape

print np.linalg.norm(pfv - vp_init[NV:, :])