예제 #1
0
파일: MWSS.py 프로젝트: fmoabreu/fluxo
    def add_fields(self):
        params = self.params.copy_recursive()
        if not self.params.debug:
            params["save"] = False
            params["plot"] = False
        params.pop("debug")
        params.pop("use_timeaverage")
        params.pop("finalize")
        
        fields = [Magnitude("WSS")]

        T0, T1 = self.params.start_time, self.params.end_time
        assert T0 != Field.default_params().start_time
        assert T1 != Field.default_params().end_time

        if self.params.use_timeaverage:
            fields.append(TimeAverage("Magnitude_WSS", params=params, label="%2g-%2g" %(T0,T1)))

        submesh = create_submesh(self.aneurysm_domain[0].mesh(), self.aneurysm_domain[0], self.aneurysm_domain[1])

        fields.append(Restrict(fields[-1].name, submesh, label="aneurysm"))
        fields.append(Maximum(fields[-1].name))

        if not self.params.use_timeaverage:
            fields.append(TimeAverage(fields[-1].name, params=params, label="%2g-%2g" %(T0,T1)))

        self.valuename = fields[-1].name
        return fields
예제 #2
0
파일: LNWSS.py 프로젝트: fmoabreu/fluxo
    def add_fields(self):
        params = self.params.copy_recursive()
        if not self.params.debug:
            params["save"] = False
            params["plot"] = False
        params.pop("debug")
        params.pop("use_timeaverage")
        params.pop("finalize")

        T0, T1 = self.params.start_time, self.params.end_time
        assert T0 != Field.default_params().start_time
        assert T1 != Field.default_params().end_time

        fields = [Magnitude("WSS", params=params)]

        if self.params.use_timeaverage:
            fields.append(TimeAverage("Magnitude_WSS", params=params, label="%2g-%2g" %(T0,T1)))
        
        fields.append(Logarithm(fields[-1].name, params=params))
        fields.append(DomainAvg(fields[-1].name, cell_domains=self.aneurysm_domain[0], indicator=self.aneurysm_domain[1], params=params, label="aneurysm"))
        
        if not self.params.use_timeaverage:
            fields.append(TimeAverage(fields[-1].name, params=params, label="%2g-%2g" %(T0,T1)))

        self.valuename = fields[-1].name
        for f in fields:
            print f
        return fields
예제 #3
0
    def add_fields(self):
        Field.start_recording()

        params = self.params.copy_recursive()
        if not self.params.debug:
            params["save"] = False
            params["plot"] = False
        params.pop("debug")
        params.pop("use_timeaverage")
        params.pop("finalize")
        T0, T1 = self.params.start_time, self.params.end_time
        assert T0 != Field.default_params().start_time
        assert T1 != Field.default_params().end_time

        u = "Velocity"
        if self.params.use_timeaverage:
            u = TimeAverage(u, params=params).name

        class VD(Field):
            def __init__(self, valuename, nu, subdomain, *args, **kwargs):
                Field.__init__(self, *args, **kwargs)
                self.valuename = valuename
                mf = subdomain[0]
                idx = subdomain[1]
                self.dx = dx(idx, domain=mf.mesh(), subdomain_data=mf)
                self.vol = assemble(Constant(1) * self.dx)

                self.nu = nu

            def compute(self, get):
                u = get(self.valuename)
                if u == None:
                    return None

                return 1.0 / self.vol * assemble(
                    2 * self.nu * inner(epsilon(u), epsilon(u)) * self.dx)

        fa = VD(u, 1.0, self.aneurysm, params=params, label="aneurysm")
        fnv = VD(u, 1.0, self.near_vessel, params=params, label="nv")

        f = fa / fnv

        if not self.params.use_timeaverage:
            f = TimeAverage(f, params=params)

        self.valuename = f.name

        recorded_fields = Field.stop_recording()
        return recorded_fields
예제 #4
0
파일: VDR.py 프로젝트: fmoabreu/fluxo
    def add_fields(self):
        Field.start_recording()

        params = self.params.copy_recursive()
        if not self.params.debug:
            params["save"] = False
            params["plot"] = False
        params.pop("debug")
        params.pop("use_timeaverage")
        params.pop("finalize")
        T0, T1 = self.params.start_time, self.params.end_time
        assert T0 != Field.default_params().start_time
        assert T1 != Field.default_params().end_time

        u = "Velocity"
        if self.params.use_timeaverage:
            u = TimeAverage(u, params=params).name

        class VD(Field):
            def __init__(self, valuename, nu, subdomain,*args, **kwargs):
                Field.__init__(self, *args, **kwargs)
                self.valuename = valuename
                mf = subdomain[0]
                idx = subdomain[1]
                self.dx = dx(idx, domain=mf.mesh(), subdomain_data=mf)
                self.vol = assemble(Constant(1)*self.dx)

                self.nu = nu

            def compute(self, get):
                u = get(self.valuename)
                if u == None:
                    return None

                return 1.0/self.vol*assemble(2*self.nu*inner(epsilon(u), epsilon(u))*self.dx)

        fa = VD(u, 1.0, self.aneurysm, params=params, label="aneurysm")
        fnv = VD(u, 1.0, self.near_vessel, params=params, label="nv")
        
        f = fa/fnv

        if not self.params.use_timeaverage:
            f = TimeAverage(f, params=params)

        self.valuename = f.name

        recorded_fields = Field.stop_recording()
        return recorded_fields
예제 #5
0
 def default_params(cls):
     params = Field.default_params()
     #params.replace(finalize=True)
     params.update(use_timeaverage=True,
                   debug=False,
                   method="Xiang")
     return params
예제 #6
0
파일: SCI.py 프로젝트: fmoabreu/fluxo
    def add_fields(self):
        Field.start_recording()

        params = self.params.copy_recursive()
        if not self.params.debug:
            params["save"] = False
            params["plot"] = False
        params.pop("debug")
        params.pop("use_timeaverage")
        params.pop("finalize")
        T0, T1 = self.params.start_time, self.params.end_time
        assert T0 != Field.default_params().start_time
        assert T1 != Field.default_params().end_time

        tau = Magnitude("WSS")
        if self.params.use_timeaverage:
            tau = TimeAverage(tau, params=params)

        threshold = DomainAvg(tau, cell_domains=self.near_vessel[0], indicator=self.near_vessel[1], label="nv") + \
                    DomainSD(tau, cell_domains=self.aneurysm[0], indicator=self.aneurysm[1], label="aneurysm")
        threshold.name = "threshold_sci_nv"
        mask = Threshold(tau, threshold, dict(threshold_by="above"))

        mf = self.aneurysm[0]
        idx = self.aneurysm[1]

        Aa = ConstantField(assemble(Constant(1)*dx(idx, domain=mf.mesh(), subdomain_data=mf)))
        Aa.name = "AneurysmArea"
        Fh = Aa*DomainAvg(tau*mask, cell_domains=mf, indicator=idx, params=params)
        Fh.name = "HighShear"
        Ah = Aa*DomainAvg(mask, cell_domains=mf, indicator=idx, params=params)+ConstantField(1e-12)
        Ah.name = "HighShearArea"
        Fa = Aa*DomainAvg(tau, cell_domains=mf, indicator=idx, params=params)
        Fa.name = "TotalShear"

        f = (Fh/Fa)/(Ah/Aa)

        if not self.params.use_timeaverage:
            f = TimeAverage(f, params=params)

        self.valuename = f.name

        fields = Field.stop_recording()
        return fields
예제 #7
0
파일: LNWSS.py 프로젝트: fmoabreu/fluxo
    def add_fields(self):
        params = self.params.copy_recursive()
        if not self.params.debug:
            params["save"] = False
            params["plot"] = False
        params.pop("debug")
        params.pop("use_timeaverage")
        params.pop("finalize")

        T0, T1 = self.params.start_time, self.params.end_time
        assert T0 != Field.default_params().start_time
        assert T1 != Field.default_params().end_time

        fields = [Magnitude("WSS", params=params)]

        if self.params.use_timeaverage:
            fields.append(
                TimeAverage("Magnitude_WSS",
                            params=params,
                            label="%2g-%2g" % (T0, T1)))

        fields.append(Logarithm(fields[-1].name, params=params))
        fields.append(
            DomainAvg(fields[-1].name,
                      cell_domains=self.aneurysm_domain[0],
                      indicator=self.aneurysm_domain[1],
                      params=params,
                      label="aneurysm"))

        if not self.params.use_timeaverage:
            fields.append(
                TimeAverage(fields[-1].name,
                            params=params,
                            label="%2g-%2g" % (T0, T1)))

        self.valuename = fields[-1].name
        for f in fields:
            print f
        return fields
예제 #8
0
    def add_fields(self):
        Field.start_recording()

        params = self.params.copy_recursive()
        if not self.params.debug:
            params["save"] = False
            params["plot"] = False
        params.pop("debug")
        params.pop("use_timeaverage")
        params.pop("finalize")
        params.pop("method")

        T0, T1 = self.params.start_time, self.params.end_time
        assert T0 != Field.default_params().start_time
        assert T1 != Field.default_params().end_time

        tau = Magnitude("WSS", params=params)
        if self.params.use_timeaverage:
            tau = TimeAverage(tau, params=params, label="%2g-%2g" %(T0,T1))


        if self.params.method == "Xiang":
            threshold = 0.1*DomainAvg(tau, cell_domains=self.parent_artery[0], indicator=self.parent_artery[1])
        elif self.params.method == "Cebral":
            threshold = DomainAvg(tau, cell_domains=self.parent_artery[0], indicator=self.parent_artery[1]) - \
                        DomainSD(tau, cell_domains=self.aneurysm_domain[0], indicator=self.aneurysm_domain[1])
        else:
            raise RuntimeError("Unknown method: "+str(self.params.method))

        f = DomainAvg(Threshold(tau, threshold, params=params.copy_recursive().update(threshold_by="below")),
                                cell_domains=self.aneurysm_domain[0], indicator=self.aneurysm_domain[1], params=params)

        if not self.params.use_timeaverage:
            f = TimeAverage(f, params=params, label="%2g-%2g" %(T0,T1))

        self.valuename = f.name

        fields = Field.stop_recording()
        return fields
예제 #9
0
def test_store_params(casedir):
    pp = PostProcessor(dict(casedir=casedir))
    params = ParamDict(Field=Field.default_params(),
                       PostProcessor=PostProcessor.default_params())

    pp.store_params(params)

    # Read back params
    params2 = None
    with open(os.path.join(pp.get_casedir(), "params.pickle"), 'r') as f:
        params2 = pickle.load(f)
    assert params2 == params

    str_params2 = open(os.path.join(pp.get_casedir(), "params.txt"),
                       'r').read()
    assert str_params2 == str(params)
예제 #10
0
파일: Q.py 프로젝트: fmoabreu/fluxo
 def default_params(cls):
     params = Field.default_params()
     params.replace(
         expr2function="project",  # "assemble" | "project" | "interpolate"
     )
     return params
예제 #11
0
파일: PLC.py 프로젝트: fmoabreu/fluxo
    def add_fields(self):
        Field.start_recording()
        params = self.params.copy()
        if not self.params.debug:
            params["save"] = False
            params["plot"] = False
        params.pop("debug")
        params.pop("use_timeaverage")
        params.pop("finalize")

        T0, T1 = self.params.start_time, self.params.end_time
        assert T0 != Field.default_params().start_time
        assert T1 != Field.default_params().end_time

        fields = []
        dep_fields = []
        if self.params.use_timeaverage:
            f = TimeAverage("Velocity",
                            params=params,
                            label="%2g-%2g" % (T0, T1))
            velocity = f.name
            fields.append(f)

            f = TimeAverage("Pressure",
                            params=params,
                            label="%2g-%2g" % (T0, T1))
            pressure = f.name
            fields.append(f)
        else:
            velocity = "Velocity"
            pressure = "Pressure"

        upstream_fields = []
        dynamic_upstream = []
        for i, plane in enumerate(self.upstream_planes):
            fu = DomainAvg(Magnitude(SubFunction(velocity,
                                                 plane,
                                                 params=params,
                                                 label="PLC_upstream_" +
                                                 str(i)),
                                     params=params),
                           params=params)
            fp = DomainAvg(SubFunction(pressure,
                                       plane,
                                       params=params,
                                       label="PLC_upstream_" + str(i)),
                           params=params)

            f = 0.5 * self.rho * fu * fu
            f.params.update(params)

            f.name = "PLC_DynamicUpstream_%d" % i
            dynamic_upstream.append(f)

            f += fp
            f.params.update(params)
            f.name = "PLC_Upstream_%d" % i

            upstream_fields.append(f)

        downstream_fields = []
        for i, plane in enumerate(self.downstream_planes):
            fu = DomainAvg(Magnitude(SubFunction(velocity,
                                                 plane,
                                                 params=params,
                                                 label="PLC_downstream_" +
                                                 str(i)),
                                     params=params),
                           params=params)
            fp = DomainAvg(SubFunction(pressure,
                                       plane,
                                       params=params,
                                       label="PLC_downstream_" + str(i)),
                           params=params)

            f = 0.5 * self.rho * fu * fu + fp
            f.params.update(params)
            f.name = "PLC_Downstream%d" % i
            downstream_fields.append(f)

        fu = sum(upstream_fields)
        fu *= 1. / len(upstream_fields)
        fu.params.update(params)
        fu.name = "PLC_Upstream_Avg"

        fd = sum(downstream_fields)
        fd *= 1. / len(downstream_fields)
        fd.params.update(params)
        fd.name = "PLC_Downstream_Avg"

        fdu = sum(dynamic_upstream)
        fdu *= 1. / len(dynamic_upstream)
        fdu.params.update(params)
        fdu.name = "PLC_DynamicUpstream_Avg"
        f = (fu - fd) / fdu
        f.params.update(params)

        if not self.params.use_timeaverage:
            f = TimeAverage(f, params=params)
        self.valuename = f.name

        recorded_fields = Field.stop_recording()

        return recorded_fields
예제 #12
0
파일: PLC.py 프로젝트: fmoabreu/fluxo
    def add_fields(self):
        Field.start_recording()
        params = self.params.copy()
        if not self.params.debug:
            params["save"] = False
            params["plot"] = False
        params.pop("debug")
        params.pop("use_timeaverage")
        params.pop("finalize")
            
        T0, T1 = self.params.start_time, self.params.end_time
        assert T0 != Field.default_params().start_time
        assert T1 != Field.default_params().end_time

        fields = []
        dep_fields = []
        if self.params.use_timeaverage:
            f = TimeAverage("Velocity", params=params, label="%2g-%2g" %(T0,T1))
            velocity = f.name
            fields.append(f)
            
            f = TimeAverage("Pressure", params=params, label="%2g-%2g" %(T0,T1))
            pressure = f.name
            fields.append(f)
        else:
            velocity = "Velocity"
            pressure = "Pressure"

        upstream_fields = []
        dynamic_upstream = []
        for i, plane in enumerate(self.upstream_planes):
            fu = DomainAvg(Magnitude(SubFunction(velocity, plane, params=params, label="PLC_upstream_"+str(i)), params=params), params=params)
            fp = DomainAvg(SubFunction(pressure, plane, params=params, label="PLC_upstream_"+str(i)), params=params)

            f = 0.5*self.rho*fu*fu
            f.params.update(params)

            f.name = "PLC_DynamicUpstream_%d" %i
            dynamic_upstream.append(f)

            f += fp
            f.params.update(params)
            f.name = "PLC_Upstream_%d" %i

            upstream_fields.append(f)

        downstream_fields = []
        for i, plane in enumerate(self.downstream_planes):
            fu = DomainAvg(Magnitude(SubFunction(velocity, plane, params=params, label="PLC_downstream_"+str(i)), params=params), params=params)
            fp = DomainAvg(SubFunction(pressure, plane, params=params, label="PLC_downstream_"+str(i)), params=params)

            f = 0.5*self.rho*fu*fu+fp
            f.params.update(params)
            f.name = "PLC_Downstream%d" %i
            downstream_fields.append(f)

        fu = sum(upstream_fields)
        fu *= 1./len(upstream_fields)
        fu.params.update(params)
        fu.name = "PLC_Upstream_Avg"
        
        fd = sum(downstream_fields)
        fd *= 1./len(downstream_fields)
        fd.params.update(params)
        fd.name = "PLC_Downstream_Avg"
        
        fdu = sum(dynamic_upstream)
        fdu *= 1./len(dynamic_upstream)
        fdu.params.update(params)
        fdu.name = "PLC_DynamicUpstream_Avg"
        f = (fu-fd)/fdu
        f.params.update(params)
        
        if not self.params.use_timeaverage:
            f = TimeAverage(f, params=params)
        self.valuename = f.name

        recorded_fields = Field.stop_recording()

        return recorded_fields
예제 #13
0
 def default_params(cls):
     params = Field.default_params()
     params.update(debug=False)
     return params
예제 #14
0
파일: OSI.py 프로젝트: fmoabreu/fluxo
 def default_params(cls):
     params = Field.default_params()
     params.update(
         finalize=True,
         )
     return params
예제 #15
0
파일: ICI.py 프로젝트: fmoabreu/fluxo
    def add_fields(self):
        Field.start_recording()

        params = self.params.copy_recursive()
        if not self.params.debug:
            params["save"] = False
            params["plot"] = False
        params.pop("debug")
        params.pop("use_timeaverage")
        params.pop("finalize")
        T0, T1 = self.params.start_time, self.params.end_time
        assert T0 != Field.default_params().start_time
        assert T1 != Field.default_params().end_time
        if self.params.use_timeaverage:
            u = TimeAverage("Velocity", params=params)
            velocity = u.name
        else:
            velocity = "Velocity"
        

        uneck = SubFunction(velocity, self.neck, params=params, label="neck")

        A = assemble(Constant(1)*dx(domain=self.neck))
        Qin = Dot(ConstantField(self.necknormal), uneck, params=params)

        t = Threshold(Qin, ConstantField(0), dict(threshold_by="above"))
        t.params.update(params)
        t.name = "threshold_neck"

        Ain = A*DomainAvg(t)
        Ain.name = "Ain"
        Ain.params.update(params)
        Qin = A*DomainAvg(Dot(Qin,t, params=params))
        Qin.name = "Qin"
        Qin.params.update(params)
        
        Qpa = 0
        for i, (plane, n) in enumerate(self.pa_planes):
            upa = SubFunction(velocity, plane, params=params, label="pa_%d" %i)
            
            Ai = assemble(Constant(1)*dx(domain=plane))
            Q = Ai*DomainAvg(Dot(ConstantField(n), upa, params=params))
            Q.name = "Qpa%d" %i
            Q.params.update(params)
            Qpa += Magnitude(Q)
            Qpa.params.update(params)
        Qpa.name = "Sum_Qpa"
        f = (Qin/Qpa)/(Ain/A)

        if not self.params.use_timeaverage:
            f = TimeAverage(f.name, params=params)
        
        self.valuename = f.name
        
        self.Qin = Qin.name
        self.Qpa = Qpa.name
        self.Ain = Ain.name
        self.A = A
        

        fields = Field.stop_recording()

        return fields
예제 #16
0
파일: MWSS.py 프로젝트: fmoabreu/fluxo
 def default_params(cls):
     params = Field.default_params()
     params.update(use_timeaverage=True,
                   debug=False)
     return params
예제 #17
0
    def add_fields(self):
        Field.start_recording()

        params = self.params.copy_recursive()
        if not self.params.debug:
            params["save"] = False
            params["plot"] = False
        params.pop("debug")
        params.pop("use_timeaverage")
        params.pop("finalize")
        T0, T1 = self.params.start_time, self.params.end_time
        assert T0 != Field.default_params().start_time
        assert T1 != Field.default_params().end_time
        if self.params.use_timeaverage:
            u = TimeAverage("Velocity", params=params)
            velocity = u.name
        else:
            velocity = "Velocity"

        uneck = SubFunction(velocity, self.neck, params=params, label="neck")

        A = assemble(Constant(1) * dx(domain=self.neck))
        Qin = Dot(ConstantField(self.necknormal), uneck, params=params)

        t = Threshold(Qin, ConstantField(0), dict(threshold_by="above"))
        t.params.update(params)
        t.name = "threshold_neck"

        Ain = A * DomainAvg(t)
        Ain.name = "Ain"
        Ain.params.update(params)
        Qin = A * DomainAvg(Dot(Qin, t, params=params))
        Qin.name = "Qin"
        Qin.params.update(params)

        Qpa = 0
        for i, (plane, n) in enumerate(self.pa_planes):
            upa = SubFunction(velocity,
                              plane,
                              params=params,
                              label="pa_%d" % i)

            Ai = assemble(Constant(1) * dx(domain=plane))
            Q = Ai * DomainAvg(Dot(ConstantField(n), upa, params=params))
            Q.name = "Qpa%d" % i
            Q.params.update(params)
            Qpa += Magnitude(Q)
            Qpa.params.update(params)
        Qpa.name = "Sum_Qpa"
        f = (Qin / Qpa) / (Ain / A)

        if not self.params.use_timeaverage:
            f = TimeAverage(f.name, params=params)

        self.valuename = f.name

        self.Qin = Qin.name
        self.Qpa = Qpa.name
        self.Ain = Ain.name
        self.A = A

        fields = Field.stop_recording()

        return fields
예제 #18
0
파일: AOSI.py 프로젝트: fmoabreu/fluxo
 def default_params(cls):
     params = Field.default_params()
     params.update(debug=False)
     return params