コード例 #1
0
ファイル: solverPage.py プロジェクト: santiama/OOF3D
    def fieldinitbuttonCB(self, *args): # gtk callback, initialize field
        fld, bc = self.selectedFieldOrBC()
        if fld is not None:
            menuitem = meshmenu.Set_Field_Initializer
            # We can't simply use
            # parameter.getParameters(menuitem.get_arg('initializer'))
            # here, because the menu item's parameter accepts members
            # of the FieldInit base class, but we need to create a
            # widget for the appropriate derived class
            # (ScalarFieldInit, et al).  It's the derived classes that
            # are the registered classes.
            param = parameter.RegisteredParameter(
                'initializer', fieldinit.fieldInitDict[fld.classname()])

            # Set the parameter value to the current initializer of
            # the appropriate field in the current mesh (context) --
            # this is the value that the initializer widget will start
            # with.  If it doesn't get set here, it will just have the
            # most recently-set one, which may be for a different
            # mesh.
            param.value = self.currentMeshContext().get_initializer(fld)

            init = parameterwidgets.getParameterValues(
                param, title = 'Initialize field ' + fld.name(), scope=self)

            if init is not None:
                menuitem.callWithDefaults(mesh=self.currentFullMeshName(),
                                          field=fld,
                                          initializer=init[0])
        if bc is not None:
            menuitem = meshmenu.Boundary_Conditions.Set_BC_Initializer
            iparam = menuitem.get_arg('initializer')
            iparam.set(bc.get_initializer())
            bcparam = menuitem.get_arg('bc')
            bcparam.set(bc.name())
            # Make a bc parameter widget and put it in the local
            # widgetscope so that the initializer RCF can find it.
            bcwidget = bcparam.makeWidget()
            self.addWidget(bcwidget)
            if parameterwidgets.getParameters(
                iparam,
                scope=self,
                title='Initialize BC ' + bc.name()):
                menuitem.callWithDefaults(mesh=self.currentFullMeshName())
            self.removeWidget(bcwidget)
            bcwidget.destroy()
コード例 #2
0
ファイル: orientmapmenu.py プロジェクト: santiama/OOF3D
orientmapmenu.addItem(
    oofmenu.OOFMenuItem(
        'Convert_to_Image',
        callback=_imageFromOrientationMap,
        ordering=3,
        params=parameter.ParameterGroup(
            MicrostructureWithOrientMapParameter(
                'microstructure',
                tip='Convert the Orientation Map in this Microstructure'),
            whoville.AutoWhoNameParameter(
                'imagename',
                resolver=_imageNameResolver,
                value=automatic.automatic,
                tip="Name to give to the new Image."),
            parameter.RegisteredParameter(
                'colorscheme',
                angle2color.Angle2Color,
                tip="How to convert angles to colors.")),
        help=
        "Convert an Orientation Map into an Image, so that pixel selection tools will work on it.",
        discussion=xmlmenudump.loadFile(
            'DISCUSSIONS/orientationmap/menu/image.xml')))

################

# Sensitize the OrientationMap menus when Microstructures are added or deleted.


def _sensitize(path):
    msclass = whoville.getClass('Microstructure')
    # If this module was somehow loaded first, the Microstructure
    # class might not be defined.
コード例 #3
0
                    device.fill_polygon(rectangle)
        finally:
            self.lock.release()


registeredclass.Registration(
    'SkeletonQuality',
    display.DisplayMethod,
    SkeletonQualityDisplay,
    ordering=100,
    layerordering=display.Planar(1.1),
    whoclasses=('Skeleton', ),
    params=[
        skeletonmodifier.alphaParameter,
        parameter.RegisteredParameter('colormap',
                                      colormap.ColorMap,
                                      colormap.ThermalMap(),
                                      tip="color scheme"),
        AutoNumericParameter('min',
                             automatic.automatic,
                             tip="lowest energy to display, or 'automatic'"),
        AutoNumericParameter('max',
                             automatic.automatic,
                             tip="highest energy to display, or 'automatic'")
    ],
    tip="Color each element according to its effective energy.",
    discussion=xmlmenudump.loadFile(
        'DISCUSSIONS/engine/reg/skelqualdisplay.xml'))

###########################################

コード例 #4
0
ファイル: mergetriangles.py プロジェクト: santiama/OOF3D
                sister in processed or
                element.dominantPixel(skel.MS)!=sister.dominantPixel(skel.MS)):
                continue
            j = sister.nodes.index(node0)
            nodeA = sister.nodes[(j+1)%3]
            nodeB = element.nodes[(i+2)%3]
            nlist = [node0, nodeA, node1, nodeB]
            parents = element.getParents() + sister.getParents()
            change = skeleton.ProvisionalChanges(skel)
            change.removeElements(element, sister)
            change.insertElements(ProvisionalQuad(nlist, parents=parents))
            changes.append(change)
        return changes

###################################################
    
registeredclass.Registration(
    'Merge Triangles',
    skeletonmodifier.SkeletonModifier,
    MergeTriangles, ordering = 5,
    params=[parameter.RegisteredParameter('targets',
                                          skeletonmodifier.SkelModTargets,
                                          tip = 'Which elements to modify.'),
            parameter.RegisteredParameter('criterion',
                                          skeletonmodifier.SkelModCriterion,
                                          tip='Acceptance criterion.')
    ],
    tip="Merge neighboring homogeneous triangles to form quadrilaterals.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/reg/merge.xml')
    )
コード例 #5
0
    def draw(self, gfxwindow, device):
        msobj = self.who().getObject(gfxwindow)
        data = orientmapdata.getOrientationMap(msobj)
        if data is not None:
            orientimage = orientmapdata.OrientMapImage(data, self.colorscheme)
            device.draw_image(orientimage, coord.Coord(0, 0), msobj.size())

    def getTimeStamp(self, gfxwindow):
        msobj = self.who().getObject(gfxwindow)
        return max(display.DisplayMethod.getTimeStamp(self, gfxwindow),
                   orientmapdata.getOrientationMapTimestamp(msobj))


registeredclass.Registration(
    'Orientation Map',
    display.DisplayMethod,
    OrientationMapDisplay,
    ordering=2,
    params=[
        parameter.RegisteredParameter(
            'colorscheme',
            angle2color.Angle2Color,
            tip='Method for converting angles to colors.')
    ],
    layerordering=display.Planar(0.5),
    whoclasses=('Microstructure', ),
    tip=
    "Display a Microstructure's Orientation Map, whether or not it's used by Material Properties.",
    discussion=xmlmenudump.loadFile(
        'DISCUSSIONS/orientationmap/reg/orientationmapdisplay.xml'))
コード例 #6
0
        'Boundary_Analysis',
        help="Compute properties of the solution on boundaries."))

mesh_param = whoville.WhoParameter(
    'mesh',
    ooflib.engine.mesh.meshes,
    tip="The mesh on which to perform the analysis.")

time_param = placeholder.TimeParameter(
    'time', tip='Time at which to perform the analysis.')

bdy_param = meshparameters.MeshEdgeBdyParameter('boundary',
                                                tip="The boundary to analyze.")

analyzer_param = parameter.RegisteredParameter(
    'analyzer',
    meshbdyanalysis.MeshBdyAnalyzer,
    tip="Operation to perform on the boundary.")

destination_param = outputdestination.OutputDestinationParameter(
    'destination',
    value=outputdestination.msgWindowOutputDestination,
    tip="Where the data should be written.")


def _meshBdyAnalyze(menuitem, mesh, time, boundary, analyzer, destination):
    meshctxt = ooflib.engine.mesh.meshes[mesh]
    meshctxt.begin_reading()
    try:
        meshctxt.precompute_all_subproblems()
        t = meshctxt.getTime(time)
        meshctxt.restoreCachedData(t)
コード例 #7
0
    def __call__(self, skeleton, selection):
        selected = self.criterion.expand(skeleton, self.ignorePBC)
        selection.start()
        selection.clear()
        selection.select(selected)


registeredclass.Registration(
    'Expand Node Selection',
    NodeSelectionModifier,
    ExpandNodeSelection,
    ordering=2.6,
    params=[
        parameter.RegisteredParameter("criterion",
                                      ExpandCriterion,
                                      tip="How to select new nodes."),
        pbcparams.PBCBooleanParameter("ignorePBC",
                                      False,
                                      tip='Ignore periodicity?')
    ],
    tip="Expand node selection by either neighboring elements or segments.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/menu/expand_node.xml'))

#######################

# Select the indicated group.


class NodeSelectGroup(NodeSelectionModifier):
    def __init__(self, group):
コード例 #8
0
        subpobj = subproblem.create()
        meshcontext.newSubProblem(subpobj, subproblem,
                                  labeltree.makePath(mesh) + [name])
    finally:
        meshcontext.end_writing()
        meshcontext.cancel_reservation()


subpmenu.addItem(
    OOFMenuItem(
        'New',
        callback=_newSubProblem,
        params=[
            parameter.StringParameter('name', tip='Name for the SubProblem'),
            parameter.RegisteredParameter('subproblem',
                                          subproblemtype.SubProblemType,
                                          tip=parameter.emptyTipString),
            whoville.WhoParameter('mesh',
                                  ooflib.engine.mesh.meshes,
                                  tip=parameter.emptyTipString)
        ],
        help="Define a Subproblem.  Used internally in Mesh data files.",
        discussion="<para>Create a &subproblem; in a datafile.</para>"))

getFieldObj = ooflib.SWIG.engine.field.getField
getEquationObj = ooflib.SWIG.engine.equation.getEquation


def _subpFields(menuitem, subproblem, defined, active, inplane):
    subpctxt = ooflib.engine.subproblemcontext.subproblems[subproblem]
    meshctxt = subpctxt.getParent()
コード例 #9
0
ファイル: splitquads.py プロジェクト: pk-organics/OOF3D
                    return None
                prog.setFraction(1.0 * (i + 1) / nel)
                prog.setMessage("%d/%d elements" % (i + 1, nel))
            reporter.report("%d quadrilateral%s split." % (done, 's' *
                                                           (done != 1)))
            skel.cleanUp()
            return skel
        finally:
            prog.finish()


registeredclass.Registration(
    'Split Quads',
    skeletonmodifier.SkeletonModifier,
    SplitQuads,
    ordering=2,
    params=[
        parameter.RegisteredParameter('targets',
                                      skeletonmodifier.SkelModTargets,
                                      tip='Which elements to modify.'),
        parameter.RegisteredParameter('criterion',
                                      skeletonmodifier.SkelModCriterion,
                                      tip='Acceptance criterion'),
        parameter.RegisteredParameter('split_how',
                                      SplitQuadMethod,
                                      GeographicQ2T(),
                                      tip='How to choose the split direction.')
    ],
    tip="Split quadrilateral elements into two triangles.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/reg/splitquads.xml'))
コード例 #10
0
#         debug.fmsg("matrix=\n%s" % matrix)
#         debug.fmsg("rhs=", rhs)
        pc = self.preconditioner.create_preconditioner(matrix)
        return cmatrixmethods.solveCG(matrix, rhs, pc, self.max_iterations,
                                      self.tolerance, solution)

registeredclass.Registration(
    "CG",
    MatrixMethod,
    ConjugateGradient,
    ordering=1,
    symmetricOnly=True,
    params=[
        parameter.RegisteredParameter(
            "preconditioner",
            preconditioner.PreconditionerPtr,
            tip="Black magic for making the matrix more easily solvable."),
        parameter.FloatParameter(
            "tolerance",
            1.e-13,
            tip="Largest acceptable relative error in the matrix solution."),
        parameter.IntParameter("max_iterations",
                               1000,
                               tip="Maximum number of iterations to perform.")
    ],
    tip="Conjugate Gradient method for iteratively solving symmetric matrices.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/reg/cg.xml'))


def check_symmetry(menuitem, state):
    global _check_symmetry
コード例 #11
0
        # this registration doesn't actually duplicate the data.
        orientmapplugin = mscontext.getObject().getPlugIn("OrientationMap")
        orientmapplugin.set_data(data, filename)
        orientmapplugin.timestamp.increment()
    finally:
        mscontext.end_writing()
        mscontext.cancel_reservation()
    reader.postProcess(mscontext)
    orientmapdata.orientationmapNotify(mscontext.getObject())


loadparams = [
    filenameparam.ReadFileNameParameter(
        'filename',
        tip="Name of the file containing the orientation map data."),
    parameter.RegisteredParameter('reader', orientmapdata.OrientMapReader),
    MicrostructureWithoutOrientMapParameter(
        'microstructure', tip='Add the orientation map to this Microstructure.')
    ]

mainmenu.OOF.File.Load.addItem(oofmenu.OOFMenuItem(
    'OrientationMap',
    callback=_loadOrientationMap,
    ordering=10,
    params=loadparams,
    help = "Load an orientation map into a Microstructure",
    discussion =xmlmenudump.loadFile('DISCUSSIONS/orientationmap/menu/load.xml')))

# OOF.OrientationMap.Load is the same as OOF.File.Load.OrientationMap
orientmapmenu.addItem(oofmenu.OOFMenuItem(
    'Load',
コード例 #12
0
ファイル: scheduledoutput.py プロジェクト: song2001/OOF2
                                     self.domain, self.sampling)


registeredclass.Registration(
    'Bulk Analysis',
    ScheduledOutput,
    BulkAnalysis,
    ordering=0.5,
    destinationClass=outputdestination.TextOutputDestination,
    params=[
        enum.EnumParameter('output_type',
                           output.OutputType,
                           tip='The kind of output to produce.'),
        output.ValueOutputParameter('data', tip="The output data source."),
        parameter.RegisteredParameter('operation',
                                      analyze.DataOperation,
                                      tip='What to do to the data.'),
        parameter.RegisteredParameter(
            'domain',
            analysisdomain.Domain,
            tip="Where on the mesh to compute the data."),
        analysissample.SamplingParameter('sampling',
                                         tip="How to sample the domain.")
    ],
    tip="Compute Fields, Fluxes, etc. on the Mesh.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/reg/bulkanalysis.xml'))


class BoundaryAnalysis(ScheduledOutput):
    def __init__(self, operation, boundary):
        self.operation = operation  # a MeshBdyAnalyzer object
コード例 #13
0
    def __init__(self):
        oofGUI.MainPage.__init__(
            self,
            name="Scheduled Output",
            ordering=235,
            tip="Set output quantities to be computed during time evolution.")
        mainbox = gtk.VBox(spacing=2)
        self.gtk.add(mainbox)

        align = gtk.Alignment(xalign=0.5)
        mainbox.pack_start(align, expand=0, fill=0)
        centerbox = gtk.HBox(spacing=3)
        align.add(centerbox)
        self.meshwidget = whowidget.WhoWidget(ooflib.engine.mesh.meshes,
                                              scope=self)
        switchboard.requestCallbackMain(self.meshwidget, self.meshCB)
        label = gtk.Label("Microstructure=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.meshwidget.gtk[0], expand=0, fill=0)

        label = gtk.Label("Skeleton=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.meshwidget.gtk[1], expand=0, fill=0)

        label = gtk.Label("Mesh=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.meshwidget.gtk[2], expand=0, fill=0)

        align = gtk.Alignment(xalign=0.5)
        mainbox.pack_start(align, expand=0, fill=0, padding=3)
        align.add(
            gtk.Label(
                "Skip this page if you're only solving static problems."))

        # The four columns (enable, output, schedule, and destination)
        # are each displayed in their own gtk.TreeView, each of which
        # is in a pane of a gtk.HPaned.  It would have been better to
        # put each column in a different gtk.TreeViewColumn in the
        # same gtk.TreeView, but that would have made it hard to put
        # buttons at the bottom of each column.

        hpane0 = gtk.HPaned()
        gtklogger.setWidgetName(hpane0, 'HPane0')
        gtklogger.connect_passive(hpane0, 'notify::position')
        mainbox.pack_start(hpane0, expand=1, fill=1)

        hpaneL = gtk.HPaned()
        gtklogger.setWidgetName(hpaneL, 'HPaneL')
        gtklogger.connect_passive(hpaneL, 'notify::position')
        hpane0.pack1(hpaneL, resize=True, shrink=False)

        hpaneR = gtk.HPaned()
        gtklogger.setWidgetName(hpaneR, 'HPane2')
        gtklogger.connect_passive(hpaneR, 'notify::position')
        hpane0.pack2(hpaneR, resize=True, shrink=False)

        self.outputList = gtk.ListStore(gobject.TYPE_PYOBJECT)

        # The "Enable" column has a check box for each output
        self.enableFrame = gtk.Frame()
        self.enableFrame.set_shadow_type(gtk.SHADOW_IN)
        hpaneL.pack1(self.enableFrame, resize=False, shrink=False)
        vbox = gtk.VBox()
        self.enableFrame.add(vbox)
        self.enableView = gtk.TreeView(self.outputList)
        gtklogger.setWidgetName(self.enableView, "enable")
        vbox.pack_start(self.enableView, expand=True, fill=True)
        self.enablecell = gtk.CellRendererToggle()
        enablecol = gtk.TreeViewColumn("")
        enablecol.set_resizable(False)
        enablecol.pack_start(self.enablecell, expand=False)
        enablecol.set_cell_data_func(self.enablecell, self.renderEnableCell)
        self.enableView.append_column(enablecol)
        gtklogger.adoptGObject(self.enablecell,
                               self.enableView,
                               access_function=gtklogger.findCellRenderer,
                               access_kwargs={
                                   'col': 0,
                                   'rend': 0
                               })
        gtklogger.connect(self.enablecell, 'toggled', self.enableCellCB)
        # Extra space at the bottom of the column.  The other columns
        # have button boxes at the bottom, so this one needs a strut
        # to keep its rows aligned with the others.
        self.enableStrut = gtk.VBox()
        vbox.pack_start(self.enableStrut, expand=False, fill=False)

        # The "Output" pane lists the name of each output
        self.outputFrame = gtk.Frame()
        self.outputFrame.set_shadow_type(gtk.SHADOW_IN)
        gtklogger.setWidgetName(self.outputFrame, "Output")
        hpaneL.pack2(self.outputFrame, resize=True, shrink=False)
        outputVBox = gtk.VBox()
        self.outputFrame.add(outputVBox)
        self.outputView = gtk.TreeView(self.outputList)
        gtklogger.setWidgetName(self.outputView, "list")
        outputVBox.pack_start(self.outputView, expand=True, fill=True)
        self.outputHScroll = gtk.HScrollbar()
        outputVBox.pack_start(self.outputHScroll, expand=False, fill=False)
        self.outputView.set_hadjustment(self.outputHScroll.get_adjustment())
        self.outputcell = gtk.CellRendererText()
        outputcol = gtk.TreeViewColumn("Output")
        outputcol.pack_start(self.outputcell, expand=True)
        outputcol.set_cell_data_func(self.outputcell, self.renderOutputCell)
        self.outputView.append_column(outputcol)
        gtklogger.connect(self.outputView, 'row-activated',
                          self.outputDoubleClickCB)
        # Buttons for the Output pane.  The extra VBox is used so that
        # the sizes of the button boxes can be synchronized.
        self.outputBBox = gtk.VBox(homogeneous=True)
        outputVBox.pack_start(self.outputBBox, expand=False, fill=False)
        bbox = gtk.HBox(homogeneous=False)
        self.outputBBox.pack_start(bbox, expand=True, fill=True)
        # New Output
        self.newOutputButton = gtkutils.StockButton(gtk.STOCK_NEW, "New")
        gtklogger.setWidgetName(self.newOutputButton, "New")
        gtklogger.connect(self.newOutputButton, 'clicked', self.newOutputCB)
        bbox.pack_start(self.newOutputButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.newOutputButton,
                                  "Define a new output operation.")
        # Edit Output
        self.editOutputButton = gtkutils.StockButton(gtk.STOCK_EDIT, "Edit")
        gtklogger.setWidgetName(self.editOutputButton, "Edit")
        gtklogger.connect(self.editOutputButton, 'clicked', self.editOutputCB)
        bbox.pack_start(self.editOutputButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.editOutputButton,
                                  "Redefine the selected output operation.")
        # Copy Output
        self.copyOutputButton = gtkutils.StockButton(gtk.STOCK_COPY, "Copy")
        gtklogger.setWidgetName(self.copyOutputButton, "Copy")
        gtklogger.connect(self.copyOutputButton, 'clicked', self.copyOutputCB)
        bbox.pack_start(self.copyOutputButton, expand=True, fill=True)
        tooltips.set_tooltip_text(
            self.copyOutputButton,
            "Copy the selected output and its schedule and destination.")
        # Second row of buttons
        bbox = gtk.HBox(homogeneous=False)
        self.outputBBox.pack_start(bbox, expand=True, fill=True)
        # Rename Output
        self.renameOutputButton = gtkutils.StockButton(gtk.STOCK_EDIT,
                                                       "Rename")
        gtklogger.setWidgetName(self.renameOutputButton, "Rename")
        gtklogger.connect(self.renameOutputButton, 'clicked', self.renameCB)
        bbox.pack_start(self.renameOutputButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.renameOutputButton,
                                  "Rename the selected output operation.")
        # Delete Output
        self.deleteOutputButton = gtkutils.StockButton(gtk.STOCK_DELETE,
                                                       "Delete")
        gtklogger.setWidgetName(self.deleteOutputButton, "Delete")
        gtklogger.connect(self.deleteOutputButton, 'clicked',
                          self.deleteOutputCB)
        tooltips.set_tooltip_text(self.deleteOutputButton,
                                  "Delete the selected output operation.")
        bbox.pack_start(self.deleteOutputButton, expand=True, fill=True)
        # Delete all outputs
        self.deleteAllButton = gtkutils.StockButton(gtk.STOCK_DELETE,
                                                    "Delete All")
        gtklogger.setWidgetName(self.deleteAllButton, "DeleteAll")
        gtklogger.connect(self.deleteAllButton, 'clicked', self.deleteAllCB)
        bbox.pack_start(self.deleteAllButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.deleteAllButton,
                                  "Delete all output operations")

        # Schedule pane
        self.schedFrame = gtk.Frame()
        self.schedFrame.set_shadow_type(gtk.SHADOW_IN)
        gtklogger.setWidgetName(self.schedFrame, "Schedule")
        hpaneR.pack1(self.schedFrame, resize=True, shrink=False)
        scheduleVBox = gtk.VBox()
        self.schedFrame.add(scheduleVBox)
        self.schedView = gtk.TreeView(self.outputList)
        gtklogger.setWidgetName(self.schedView, "list")
        scheduleVBox.pack_start(self.schedView, expand=True, fill=True)
        schedHScroll = gtk.HScrollbar()
        scheduleVBox.pack_start(schedHScroll, expand=False, fill=False)
        self.schedView.set_hadjustment(schedHScroll.get_adjustment())
        self.schedcell = gtk.CellRendererText()
        schedcol = gtk.TreeViewColumn("Schedule")
        schedcol.pack_start(self.schedcell, expand=True)
        schedcol.set_cell_data_func(self.schedcell, self.renderScheduleCB)
        self.schedView.append_column(schedcol)
        gtklogger.connect(self.schedView, 'row-activated',
                          self.schedDoubleClickCB)
        # Buttons for the Schedule pane.
        self.schedBBox = gtk.VBox(homogeneous=True)
        scheduleVBox.pack_start(self.schedBBox, expand=False, fill=False)
        bbox = gtk.HBox(homogeneous=False)
        self.schedBBox.pack_start(bbox, expand=True, fill=True)
        # Set Schedule
        self.setScheduleButton = gtkutils.StockButton(gtk.STOCK_NEW, "Set")
        gtklogger.setWidgetName(self.setScheduleButton, "New")
        gtklogger.connect(self.setScheduleButton, 'clicked', self.setSchedCB)
        bbox.pack_start(self.setScheduleButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.setScheduleButton,
                                  "Add a Schedule to the selected Output")
        # Copy Schedule
        self.copyScheduleButton = gtkutils.StockButton(gtk.STOCK_COPY, "Copy")
        gtklogger.setWidgetName(self.copyScheduleButton, "Copy")
        gtklogger.connect(self.copyScheduleButton, 'clicked', self.copySchedCB)
        bbox.pack_start(self.copyScheduleButton, expand=True, fill=True)
        tooltips.set_tooltip_text(
            self.copyScheduleButton,
            "Copy the selected Schedule to another Output")
        # Second row of buttons in the Schedule pane
        bbox = gtk.HBox(homogeneous=False)
        self.schedBBox.pack_start(bbox, expand=True, fill=True)
        # Delete Schedule
        self.deleteScheduleButton = gtkutils.StockButton(
            gtk.STOCK_DELETE, "Delete")
        gtklogger.setWidgetName(self.deleteScheduleButton, "Delete")
        gtklogger.connect(self.deleteScheduleButton, 'clicked',
                          self.deleteSchedCB)
        bbox.pack_start(self.deleteScheduleButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.deleteScheduleButton,
                                  "Delete the selected Schedule.")

        # Destination pane
        self.destFrame = gtk.Frame()
        self.destFrame.set_shadow_type(gtk.SHADOW_IN)
        gtklogger.setWidgetName(self.destFrame, "Destination")
        hpaneR.pack2(self.destFrame, resize=True, shrink=False)
        destVBox = gtk.VBox()
        self.destFrame.add(destVBox)
        destScroll = gtk.ScrolledWindow()
        destScroll.set_shadow_type(gtk.SHADOW_NONE)
        destScroll.set_policy(gtk.POLICY_ALWAYS, gtk.POLICY_ALWAYS)
        destVBox.pack_start(destScroll, expand=True, fill=True)
        self.destView = gtk.TreeView(self.outputList)
        gtklogger.setWidgetName(self.destView, "list")
        destScroll.add(self.destView)
        self.destcell = gtk.CellRendererText()
        destcol = gtk.TreeViewColumn("Destination")
        destcol.pack_start(self.destcell, expand=True)
        destcol.set_cell_data_func(self.destcell, self.renderDestinationCB)
        self.destView.append_column(destcol)
        gtklogger.connect(self.destView, 'row-activated',
                          self.destDoubleClickCB)
        # Buttons for the Destination pane
        self.destBBox = gtk.VBox(homogeneous=True)
        destVBox.pack_start(self.destBBox, expand=False, fill=True)
        bbox = gtk.HBox(homogeneous=False)
        self.destBBox.pack_start(bbox, expand=True, fill=True)
        # Set Destination
        self.setDestinationButton = gtkutils.StockButton(gtk.STOCK_NEW, "Set")
        gtklogger.setWidgetName(self.setDestinationButton, "Set")
        gtklogger.connect(self.setDestinationButton, 'clicked',
                          self.setDestinationCB)
        bbox.pack_start(self.setDestinationButton, expand=True, fill=True)
        tooltips.set_tooltip_text(
            self.setDestinationButton,
            "Assign a destination to the selected Output")
        # Delete Dest
        self.deleteDestButton = gtkutils.StockButton(gtk.STOCK_DELETE,
                                                     "Delete")
        gtklogger.setWidgetName(self.deleteDestButton, "Delete")
        gtklogger.connect(self.deleteDestButton, 'clicked', self.deleteDestCB)
        bbox.pack_start(self.deleteDestButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.deleteDestButton,
                                  "Delete the selected Destination.")
        # Second row of buttons in the Dest pane
        bbox = gtk.HBox(homogeneous=False)
        self.destBBox.pack_start(bbox, expand=True, fill=True)
        # Rewind
        self.rewindDestButton = gtkutils.StockButton(gtk.STOCK_MEDIA_REWIND,
                                                     "Rewind")
        gtklogger.setWidgetName(self.rewindDestButton, "Rewind")
        gtklogger.connect(self.rewindDestButton, 'clicked',
                          self.rewindDestinationCB)
        bbox.pack_start(self.rewindDestButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.rewindDestButton,
                                  "Go back to the start of the output file.")
        # Rewind All
        self.rewindAllDestsButton = gtkutils.StockButton(
            gtk.STOCK_MEDIA_REWIND, "Rewind All")
        gtklogger.setWidgetName(self.rewindAllDestsButton, "RewindAll")
        gtklogger.connect(self.rewindAllDestsButton, 'clicked',
                          self.rewindAllDestinationsCB)
        bbox.pack_start(self.rewindAllDestsButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.rewindAllDestsButton,
                                  "Go back to the start of all output files.")

        # Synchronize the vertical scrolling of all the panes.
        self.schedView.set_vadjustment(destScroll.get_vadjustment())
        self.outputView.set_vadjustment(destScroll.get_vadjustment())
        self.enableView.set_vadjustment(destScroll.get_vadjustment())

        self.allViews = (self.enableView, self.outputView, self.schedView,
                         self.destView)

        # This is a hack.  Some of the dialogs use widgets that need
        # to find out what the current Output is, using the
        # WidgetScope mechanism.  The TreeView isn't a
        # ParameterWidget, so it doesn't use WidgetScopes.  So here we
        # construct a ParameterWidget just so that it can be found.
        # It's kept up to date with the selected Output.  It's not
        # actually placed in the GUI.
        self.dummyOutputParam = parameter.RegisteredParameter(
            'output', scheduledoutput.ScheduledOutput)
        self.dummyOutputWidget = self.dummyOutputParam.makeWidget(scope=self)

        # Catch selection changes in the lists
        self.selectionsignals = {}
        for view in self.allViews:
            gtklogger.adoptGObject(view.get_selection(),
                                   view,
                                   access_method=view.get_selection)
            self.selectionsignals[view] = gtklogger.connect(
                view.get_selection(), 'changed', self.selectionCB)

        switchboard.requestCallbackMain("scheduled outputs changed",
                                        self.outputsChangedCB)
        switchboard.requestCallbackMain("new scheduled output",
                                        self.newOutputSBCB)

        switchboard.requestCallbackMain("gtk font changed", self.setSizes)
コード例 #14
0
    layerordering=display.Planar(0.4),
    params=[
        color.ColorParameter(
            'no_material',
            color.black,
            tip="Color to use if no material has been assigned to a pixel"),
        color.ColorParameter(
            'no_color',
            color.blue,
            tip="Color to use if the assigned material has no assigned color"),
        parameter.FloatRangeParameter("opacity",
                                      bitmapdisplay.opacityRange,
                                      bitmapdisplay.defaultImageOpacity,
                                      tip="Opacity of material colors."),
        parameter.RegisteredParameter("filter",
                                      voxelfilter.VoxelFilterPtr,
                                      voxelfilter.AllVoxels(),
                                      tip="Voxels to include in the display.")
    ],
    whoclasses=('Microstructure', ),
    tip="Display the color of the Material assigned to each pixel.",
    discussion=xmlmenudump.loadFile(
        'DISCUSSIONS/engine/reg/microstructuredisplay.xml'))

############################

if config.dimension() == 2:
    ## TODO MER: Update for new display layer methods and 3D.

    class OrientationDisplay(MSMaterialDisplay):
        def __init__(self,
                     colorscheme,
コード例 #15
0
    interfacemsplugin=msobj.getPlugIn("Interfaces")
    return utils.uniqueName(basename, interfacemsplugin.getCurrentReservedNames())

_interfacemenu.addItem(oofmenu.OOFMenuItem(
    'New',
    callback=_newInterfaceCB,
    params=parameter.ParameterGroup(
    whoville.WhoParameter('microstructure',
                          ooflib.common.microstructure.microStructures,
                          tip=parameter.emptyTipString),
    parameter.AutomaticNameParameter('name',
                                     resolver=interfaceNameResolver,
                                     value=automatic.automatic,
                                     tip="Name of the interface."),
    parameter.RegisteredParameter('interface_type',
                                  interfaceplugin.InterfaceDef,
                                  tip=parameter.emptyTipString)
    ),
    help="Create a named interface in a Microstructure.",
    discussion="""<para>
    Create an interface definition with the given name in the &micros;.
    This action should trigger a rebuild of the &mesh;,
    if it exists.
    </para>"""
    ))

def _renameCB(menuitem, microstructure, interface, name):
    msobj = ooflib.common.microstructure.microStructures[microstructure].getObject()
    interfacemsplugin=msobj.getPlugIn("Interfaces")
    interfacemsplugin.renameInterface(interface,name)
コード例 #16
0
registeredclass.Registration(
    'Adaptive',
    StepDriver,
    AdaptiveDriver,
    ordering=1,
    params=[
        parameter.FloatParameter('tolerance',
                                 1.e-4,
                                 tip="Maximum permissable error."),
        parameter.FloatParameter("initialstep", 0.1, tip="Initial step size."),
        parameter.FloatParameter('minstep',
                                 1.e-5,
                                 tip="Minimum time step size."),
        parameter.RegisteredParameter(
            'errorscaling',
            steperrorscaling.StepErrorScaling,
            value=steperrorscaling.AbsoluteErrorScaling(),
            tip="How to compute the error for each degree of freedom."),
        parameter.RegisteredParameter('stepper',
                                      QCTimeStepper,
                                      tip="Time stepping method.")
    ],
    tip="Take variable sized timesteps.",
    discussion=xmlmenudump.loadFile(
        'DISCUSSIONS/engine/reg/adaptivedriver.xml'))

############


class UniformDriver(StepDriver):
    def __init__(self, stepper, stepsize):
コード例 #17
0
        )

# Parameters to all the menu items.

mesh_param =  whoville.WhoParameter(
    'mesh', ooflib.engine.mesh.meshes,
    tip="The mesh on which to compute the output")

time_param = placeholder.TimeParameter(
    'time', tip='Time at which to perform the analysis.')

output_param = output.ValueOutputParameter(
    'data', tip="The output data source.")

domain_param = parameter.RegisteredParameter(
    'domain', analysisdomain.Domain,
    tip="Where on the mesh to compute the data.")

sample_param = parameter.RegisteredParameter(
    'sampling', analysissample.SampleSet,
    tip="How to sample the domain.")

destination_param = outputdestination.OutputDestinationParameter(
    'destination',
    value=outputdestination.msgWindowOutputDestination,
    tip='Where the data should be written.')

common_analysis_params = [mesh_param,
                          time_param,
                          output_param, 
                          domain_param,
コード例 #18
0
ファイル: imagemenu.py プロジェクト: santiama/OOF3D
                                            tip="Name of the image file."),
        whoville.WhoParameter('microstructure',
                              whoville.getClass('Microstructure'),
                              tip=parameter.emptyTipString))

elif config.dimension() == 3:

    def loadImage(menuitem, filenames, microstructure, height, width, depth):
        if filenames:
            # Read file and create an OOFImage3D object
            image = autoReadImage(filenames, height, width, depth)
            loadImageIntoMS(image, microstructure)
            switchboard.notify("redraw")

    imageparams = parameter.ParameterGroup(
        parameter.RegisteredParameter("filenames",
                                      oofimage.ThreeDImageSpecification),
        whoville.WhoParameter('microstructure',
                              whoville.getClass('Microstructure'),
                              tip=parameter.emptyTipString))

## TODO 3.1: Using the same OOFMenuItem for 2D and 3D, when they have
## different parameters, will cause problems in the documentation.
## Will we have to have two completely separate manuals for the two
## versions?  Better to use different names for the menu items.

mainmenu.OOF.File.Load.addItem(
    oofmenu.OOFMenuItem('Image',
                        callback=loadImage,
                        ellipsis=1,
                        params=imageparams + sizeparams,
                        help="Load an Image into an existing Microstructure.",
コード例 #19
0
ファイル: refine.py プロジェクト: song2001/OOF2
    elif config.dimension() == 3:
        sig = []
        for i in range(len(marks)):
            if marks[i]:
                sig.append(i)
        return tuple(sig)


####################

registeredclass.Registration(
    'Refine',
    skeletonmodifier.SkeletonModifier,
    Refine,
    ordering=0,
    params=[
        parameter.RegisteredParameter('targets',
                                      refinementtarget.RefinementTarget,
                                      tip='Target elements to be refined.'),
        parameter.RegisteredParameter('criterion',
                                      RefinementCriterion,
                                      tip='Exclude certain elements.'),
        parameter.RegisteredParameter(
            'degree',
            RefinementDegree,
            tip='Preferred way of subdividing a side.'),
        skeletonmodifier.alphaParameter
    ],
    tip="Subdivide elements.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/reg/refine.xml'))
コード例 #20
0
        self.criterion = criterion  # unconditional or conditional
        self.method = method  # automatic or specified

    def apply(self, oldskeleton, context):
        skel = oldskeleton.properCopy(skeletonpath=context.path())
        self.method.rationalize(skel, context, self.targets, self.criterion)
        skel.cleanUp()
        return skel


#########################

registeredclass.Registration(
    'Rationalize',
    skeletonmodifier.SkeletonModifier,
    Rationalize,
    ordering=5,
    params=[
        parameter.RegisteredParameter('targets',
                                      skeletonmodifier.SkelModTargets,
                                      tip='Which elements to modify.'),
        parameter.RegisteredParameter('criterion',
                                      skeletonmodifier.SkelModCriterion,
                                      tip='Acceptance criterion'),
        parameter.RegisteredParameter('method',
                                      RationalizeMethod,
                                      tip='Methods for rationalization.')
    ],
    tip='Fix badly shaped elements in a Skeleton.',
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/reg/rationalize.xml'))
コード例 #21
0
ファイル: solvermode.py プロジェクト: santiama/OOF3D
        pass
    def shortrepr(self):
        return '%s | %s' % (self.time_stepper.shortrepr(), 
                            self.matrix_method.shortrepr())

registeredclass.Registration(
    "Basic",
    SolverMode,
    BasicSolverMode,
    ordering=0,
    params=[
        timestepper.BasicStepDriverParameter(
            'time_stepper',
            tip='How to take time steps.'),
        parameter.RegisteredParameter(
            'matrix_method',
            matrixmethod.BasicMatrixMethod,
            tip='How to solve matrix equations.')
        ],
    tip="Let OOF2 choose many solution parameters.",
    discussion=xmlmenudump.loadFile(
        'DISCUSSIONS/engine/reg/basicsolvermode.xml')
    )

def _rep(obj):
    if obj is None:
        return '---'
    return obj.shortrepr()

class AdvancedSolverMode(SolverMode):
    def __init__(self, time_stepper, nonlinear_solver, 
                 symmetric_solver, asymmetric_solver):
コード例 #22
0
##############################################################################


class CompleteDetection(imagemodifier.ImageModifier):
    def __init__(self, filter, threshold):
        self.filter = filter
        self.threshold = threshold

    def __call__(self, image):
        self.filter.__call__(image)
        self.threshold.__call__(image)


registeredclass.Registration(
    'CompleteDetection',
    imagemodifier.ImageModifier,
    CompleteDetection,
    ordering=100000,
    params=[
        parameter.RegisteredParameter('filter',
                                      imagefilter.ImageFilter,
                                      tip='Choose the image filter to use'),
        parameter.RegisteredParameter('threshold',
                                      ImageThreshold,
                                      tip='Thresh')
        ##    parameter.RegisteredParameter('
    ],
    tip='Apply full edge detection process.',
)
コード例 #23
0
bcmenu.addItem(
    oofmenu.OOFMenuItem(
        'New',
        callback=_buildbc,
        params=parameter.ParameterGroup(
            parameter.AutomaticNameParameter(
                'name',
                value=automatic.automatic,
                tip="Name of the new boundary condition",
                resolver=bcnameResolver),
            whoville.WhoParameter(
                'mesh',
                ooflib.engine.mesh.meshes,
                tip='Mesh to which to apply the boundary condition.'),
            parameter.RegisteredParameter("condition",
                                          bdycondition.BC,
                                          tip="The new boundary condition.")),
        help='Create a new boundary condition.',
        discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/menu/new_bc.xml')))


def _bcrename(menuitem, mesh, bc, name):
    if parallel_enable.enabled():
        boundaryconditionIPC.ipcbcmenu.Rename(mesh=mesh, bc=bc, name=name)
    else:
        meshcontext = ooflib.engine.mesh.meshes[mesh]
        meshcontext.renameBdyCondition(bc, name)


bcmenu.addItem(
    oofmenu.OOFMenuItem(
コード例 #24
0
ファイル: scheduledoutputmenu.py プロジェクト: santiama/OOF3D
    switchboard.notify("new scheduled output", meshctxt, name)
    

outputmenu.addItem(oofmenu.OOFMenuItem(
    'New',
    callback=_newOutput,
    params=parameter.ParameterGroup(
            whoville.WhoParameter(
                'mesh', ooflib.engine.mesh.meshes,
                tip='Define an output operation on this mesh.'),
            parameter.AutomaticNameParameter(
                'name', resolver=outputNameResolver,
                value=automatic.automatic,
                tip="A name for the new output operation."),
            parameter.RegisteredParameter(
                'output',
                scheduledoutput.ScheduledOutput,
                tip="The output operation."))
    + parameter.ParameterGroup(
        parameter.RegisteredParameter(
            'scheduletype',
            outputschedule.ScheduleType,
            tip='How to interpret the schedule.'),
        outputschedule.OutputScheduleParameter(
            'schedule',
            tip="When to produce the output."))
    + parameter.ParameterGroup(
        outputdestination.OutputDestinationParameter(
            'destination',
            tip="Where the output should go.")),
    help="Create an output operation to be performed during a time evolution.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/menu/newschedout.xml')
コード例 #25
0
ファイル: imageIO.py プロジェクト: song2001/OOF2

def _newImage(menuitem, name, microstructure, pixels):
    ms = ooflib.common.microstructure.microStructures[microstructure].getObject()
    image = oofimage.newImageFromData(name, ms.sizeInPixels(), pixels.values())
    image.setSize(ms.size())
    imagemenu.loadImageIntoMS(image, microstructure)
    
imgmenu.addItem(oofmenu.OOFMenuItem(
    'New',
    callback=_newImage,
    params=[
    parameter.StringParameter('name', tip="Name for the Image."),
    whoville.WhoParameter('microstructure',whoville.getClass('Microstructure'),
                          tip=parameter.emptyTipString),
    parameter.RegisteredParameter('pixels', ImageData,
                                  tip=parameter.emptyTipString)],
    help="Load an Image.",
    discussion="<para>Load an &image; from a saved &micro;.</para>"
    ))



def writeImage(datafile, imagecontext):
    datafile.startCmd(mainmenu.OOF.LoadData.Image.New)
    datafile.argument('name', imagecontext.name())
    datafile.argument('microstructure', imagecontext.getMicrostructure().name())
    datafile.argument('pixels', RGBData8(imagecontext.getObject().getPixels()))
    datafile.endCmd()

# TODO LATER: Allow different image depths, and find a way to store
# only gray values if the image is gray.
コード例 #26
0

#=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=#

orientmapdata.OrientMapRegistration(
    'Generic',
    GenericReader,
    ordering=0,
    params=[
        parameter.StringParameter(
            "comment_character",
            '#',
            tip="Skip input lines beginning with this character."),
        parameter.RegisteredParameter(
            "separator",
            formatchars.InputSeparator,
            formatchars.WhiteSpaceSeparator(),
            tip="How columns are divided in the input file."),
        parameter.PositiveIntParameter('angle_column',
                                       1,
                                       tip='First column of angle data.'),
        parameter.MetaRegisteredParameter(
            'angle_type',
            orientationmatrix.Orientation,
            orientationmatrix.Bunge,
            tip="The way in which orientations are specified in the input file."
        ),
        enum.EnumParameter('angle_units',
                           AngleUnits,
                           'Radians',
                           tip="The units used for angles in the input file."),
コード例 #27
0
ファイル: errorestimator.py プロジェクト: song2001/OOF2
#                        self.norm(element, subproblem, self.flux)*100)
#         return result
        return self.threshold < self.norm(element, subproblem, self.flux)*100.

# Dummy parameter for smart widget
class ZZFluxParameter(meshparameters.FluxParameter):
    pass

registeredclass.Registration(
    'Z-Z Estimator',
    ErrorEstimator,
    ZZ_Estimator,
    ordering=0.,
    params=[
    parameter.RegisteredParameter('norm',
                                  ErrorNorm,
                                  tip="How to measure the size of an error."),
    ZZFluxParameter('flux', tip=parameter.emptyTipString),
    parameter.FloatRangeParameter('threshold', (0.0, 100.0, 0.5),
                                  value=10.,
                                  tip='Maximum allowable percentage error.')
    ],
    tip="Error estimation by Zienkiewicz and Zhu's superconvergent patch recovery.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/reg/zzspr.xml'))

################################

# RefinementTarget for AdaptiveMeshRefinement.  Marks all elements
# that fail the error estimator test.
class AdaptiveMeshRefine(refinementtarget.RefinementTarget):
    def __init__(self, subproblem, estimator):
コード例 #28
0
            timedriver.apply(solver, subpcontext)
        except ooferror.ErrProcessAborted:
            pass
        ## solved flag is set even if solution did NOT
        ## converge in order to show how far the solution
        ## went.
        subpcontext.solved()

    finally:
        subpcontext.cancel_reservation()


## OOF.LoadData.IPC.Solver.Solve
ipcsolvermenu.addItem(
    oofmenu.OOFMenuItem(
        'Solve',
        callback=parallel_solve,
        threadable=oofmenu.PARALLEL_THREADABLE,
        params=[
            ##    whoville.WhoParameter('subproblem',
            ##                          ooflib.engine.subproblemcontext.subproblems,
            ##                          tip=parameter.emptyTipString),
            parameter.StringParameter('subproblem'),
            ##    whoville.WhoParameter('mesh',
            ##                          ooflib.engine.mesh.meshes,
            ##                          tip="Deprecated.  Use subproblem instead."),
            parameter.RegisteredParameter('solver',
                                          solverdriver.Driver,
                                          tip=parameter.emptyTipString)
        ]))
コード例 #29
0
def _constructCB(menuitem, skeleton, name, constructor):
    skelctxt = skeletoncontext.skeletonContexts[skeleton]
    constructor(skelctxt, name)


#Uniqueness of boundary names is built into boundarybuilder.nameparam
boundarymenu.addItem(
    oofmenu.OOFMenuItem(
        "Construct",
        callback=_constructCB,
        help=
        "Construct a new boundary in a skeleton and in the associated meshes.",
        params=[
            boundarybuilder.skeletonparam, boundarybuilder.nameparam,
            parameter.RegisteredParameter("constructor",
                                          boundarybuilder.BoundaryConstructor,
                                          tip="Which method to use.")
        ],
        discussion=xmlmenudump.loadFile(
            'DISCUSSIONS/engine/menu/boundary_construct.xml')))

### Boundary modification.


def _modifyCB(self, skeleton, boundary, modifier):
    skelctxt = skeletoncontext.skeletonContexts[skeleton]
    modifier(skelctxt, boundary)
    switchboard.notify("redraw")


boundarymenu.addItem(
コード例 #30
0
if config.dimension() == 2:
    registeredclass.Registration(
        'Solid Fill',
        display.DisplayMethod,
        MeshCenterFillDisplay,
        ordering=2.0,
        layerordering=display.Planar,
        params=contourdisplay.zdisplayparams + [
            parameter.AutomaticValueSetParameter(
                'levels',
                automatic.automatic,
                tip="Number of levels or list of levels (in []), or automatic"
            ),
            parameter.RegisteredParameter('colormap',
                                          colormap.ColorMap,
                                          colormap.ThermalMap(),
                                          tip="Fill color.")
        ],
        whoclasses=('Mesh', ),
        tip="Quick and dirty contour plot.",
        discussion=xmlmenudump.loadFile(
            'DISCUSSIONS/engine/reg/centerfilldisplay.xml'))

# SkeletonCenterFillDisplay isn't useful unless there are Outputs that
# can be evaluated on a Skeleton.

##class SkeletonCenterFillDisplay(CenterFillDisplay, SkeletonDisplayMethod):
##    def __init__(self, what, colormap=colormap.ThermalMap()):
##        self.what = what
##        self.colormap = colormap