Esempio n. 1
0
    def matChanged(self, materialname):
        # The given material has changed.  Look through the materials
        # in our Microstructure to see if we care.
        matl = materialmanager.getMaterial(materialname)
        #Interface branch
        ##TODO: Should we look at the material associated with the
        ##edgements instead?
        if config.dimension() == 2 and runtimeflags.surface_mode:
            interfacemsplugin = self.microstructure.getPlugIn("Interfaces")
            interfacemats = interfacemsplugin.getInterfaceMaterials()


#         elif config.dimension() == 3:
        else:
            interfacemats = []

        if matl in material.getMaterials(self.microstructure) or \
               materialname in interfacemats:
            # We *do* care. Really.  Tell all the SubProblems
            # belonging to the microstructure that the material has
            # changed.
            msname = self.microstructure.name()
            subppaths = subproblemcontext.subproblems.keys(base=msname)
            for subppath in subppaths:
                subpctxt = subproblemcontext.subproblems[[msname] + subppath]
                subpctxt.changed("Material properties changed.")
Esempio n. 2
0
    def matChanged(self, materialname):
        # The given material has changed.  Look through the materials
        # in our Microstructure to see if we care.
        matl = materialmanager.getMaterial(materialname)
        #Interface branch
        if config.dimension() == 2 and runtimeflags.surface_mode:
            interfacemsplugin = self.microstructure.getPlugIn("Interfaces")
            interfacemats = interfacemsplugin.getInterfaceMaterials()


#         elif config.dimension() == 3:
        else:
            interfacemats = []

        if matl in material.getMaterials(self.microstructure) or \
               materialname in interfacemats:
            # We *do* care. Really.  Tell all the SubProblems
            # belonging to the microstructure that the material has
            # changed.
            msname = self.microstructure.name()
            subppaths = subproblemcontext.subproblems.keys(base=msname)
            for subppath in subppaths:
                subpctxt = subproblemcontext.subproblems[[msname] + subppath]
                subpctxt.changed("Material properties changed.")
            # Also tell everything that cares whether the mesh data
            # has changed.  This includes PropertyOutputs that may be
            # displayed in a mesh data viewer.
            meshpaths = mesh.meshes.keys(base=msname)
            for meshpath in meshpaths:
                meshctxt = mesh.meshes[[msname] + meshpath]
                switchboard.notify("mesh data changed", meshctxt)
Esempio n. 3
0
    def new_material(self,
                     name,
                     materialtype=material.MATERIALTYPE_BULK,
                     *props):
        # If a Material already exists with the same name, just
        # redefine it by deleting its old Properties and adding the
        # new ones.  *Don't* try deleting the Material entirely and
        # recreating it from scratch, which seems like the easy way to
        # go. Deleting the Material would delete it from any
        # Microstructures and Meshes that use it.
        try:
            matprop = self.materials[name]
        except KeyError:
            matprop = MaterialProps(name, materialtype)
            self.materials[name] = matprop
        else:
            matprop.delete_all_props()

        mat = matprop.actual
        for p in props:
            mat.addProperty(p)
            reg = p.registration()
            path = AllProperties.data.reverse_dict[reg].path()
            matprop.add_prop_ref(path, reg)
            reg.materials[name] = (matprop, p)

        switchboard.notify("new_material", name)
        for ms in microStructures.actualMembers():
            if mat in material.getMaterials(ms.getObject()):
                switchboard.notify("materials changed in microstructure",
                                   ms.getObject())
Esempio n. 4
0
    def new_material(self, name,
                     materialtype=material.MATERIALTYPE_BULK,
                     *props):
        # If a Material already exists with the same name, just
        # redefine it by deleting its old Properties and adding the
        # new ones.  *Don't* try deleting the Material entirely and
        # recreating it from scratch, which seems like the easy way to
        # go. Deleting the Material would delete it from any
        # Microstructures and Meshes that use it.
        try:
            matprop = self.materials[name]
        except KeyError:
            matprop = MaterialProps(name, materialtype)
            self.materials[name] = matprop
        else:
            matprop.delete_all_props()

        mat = matprop.actual
        for p in props:
            mat.addProperty(p)
            reg = p.registration()
            path = AllProperties.data.reverse_dict[reg].path()
            matprop.add_prop_ref(path, reg)
            reg.materials[name]=(matprop, p)

        switchboard.notify("new_material", name)
        for ms in microStructures.actualMembers():
            if mat in material.getMaterials(ms.getObject()):
                switchboard.notify("materials changed in microstructure",
                                   ms.getObject())
Esempio n. 5
0
 def matChangedCB(self, materialname):
     context = self.who()
     if context:
         ms = context.getObject(self.gfxwindow)
         if ms:
             mnames = [m.name() for m in material.getMaterials(ms)]
             if materialname in mnames:
                 self.whoChanged()
Esempio n. 6
0
    def matChanged(self, materialname):
        # The given material has changed.  Look through the materials
        # in our Microstructure to see if we care.
        matl = materialmanager.getMaterial(materialname)
        #Interface branch
        ##TODO: Should we look at the material associated with the
        ##edgements instead?
        if config.dimension() == 2 and runtimeflags.surface_mode:
            interfacemsplugin=self.microstructure.getPlugIn("Interfaces")
            interfacemats=interfacemsplugin.getInterfaceMaterials()
#         elif config.dimension() == 3:
        else:
            interfacemats = []

        if matl in material.getMaterials(self.microstructure) or \
               materialname in interfacemats:
            # We *do* care. Really.  Tell all the SubProblems
            # belonging to the microstructure that the material has
            # changed.
            msname = self.microstructure.name()
            subppaths = subproblemcontext.subproblems.keys(base=msname)
            for subppath in subppaths:
                subpctxt = subproblemcontext.subproblems[[msname]+subppath]
                subpctxt.changed("Material properties changed.")