示例#1
0
def DirectSampleSetRegistration(name,
                                subclass,
                                ordering,
                                params=[],
                                secret=0,
                                tip=None,
                                discussion=None,
                                **kwargs):
    class NonDirectSubclass(subclass):
        def get_col_names(self):
            return []

    NonDirectSubclass.__name__ = "Stat" + subclass.__name__

    non_direct_params = params[:]

    ## TODO: Do we still need the Stat sample sets?

    registeredclass.Registration(name,
                                 SampleSet,
                                 NonDirectSubclass,
                                 ordering,
                                 params=non_direct_params,
                                 secret=secret,
                                 tip=tip,
                                 direct=False,
                                 discussion="""<para>
        <classname>%(statname)s</classname> is a version of <xref
        linkend='RegisteredClass-%(name)s'/> that is used when the
        <link linkend='MenuItem-OOF.Mesh.Analyze'>analysis
        operation</link> is one of the statistics functions.  It is
        identical, except that it does not have the
        <varname>show_*</varname> parameters, which would be
        meaningless in this context.
        </para>""" % {
                                     'name': subclass.__name__,
                                     'statname': NonDirectSubclass.__name__
                                 },
                                 **kwargs)

    # Now pile on the extra parameters.
    for c_name in subclass.containedClass.columnNames:
        params.append(
            parameter.BooleanParameter(
                _attr_from_colname(c_name),
                1,
                default=1,
                tip="Include or exclude this data from the output."))

    return registeredclass.Registration(name,
                                        SampleSet,
                                        subclass,
                                        ordering,
                                        params,
                                        secret,
                                        tip,
                                        discussion,
                                        direct=True,
                                        **kwargs)
示例#2
0
文件: refine.py 项目: song2001/OOF2
    def __init__(self, rule_set):
        self.rule_set = rule_set

    def markExtras(self, skeleton, markedEdges):
        if self.rule_set.name == "conservative":
            refinequadbisection.markExtras(skeleton, markedEdges)


registeredclass.Registration(
    'Bisection',
    RefinementDegree,
    Bisection,
    1,
    params=[
        enum.EnumParameter('rule_set',
                           refinemethod.RuleSet,
                           refinemethod.conservativeRuleSetEnum(),
                           tip='How to subdivide elements.')
    ],
    tip="Divide element edges into two.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/reg/bisection.xml'))

if config.dimension() == 2:

    class Trisection(RefinementDegree):
        divisions = 2

        def __init__(self, rule_set):
            self.rule_set = rule_set
示例#3
0
## estimator.  The classes need to rearranged so that the norm classes
## are independent of the estimator classes.  After all, we may
## someday have more than one estimator.  If it's not possible to
## refactor the classes like that, then the ErrorNorm classes must at
## least be renamed so that it's clear that they are only meant to be
## used with the ZZ estimator.
    
class L2ErrorNorm(ErrorNorm):
    #AMR subproblem, pass subproblem
    def __call__(self, element, subproblem, flux):
        return subproblem.zz_L2_estimate(element, flux)
    
registeredclass.Registration(
    'L2 Error Norm',
    ErrorNorm,
    L2ErrorNorm,
    ordering=0,
    tip="Use the root mean square of the components of the error.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/reg/l2errornorm.xml'))

class WeightedL2ErrorNorm(ErrorNorm):
    def __init__(self):
        self.weights = None
    #AMR subproblem, pass subproblem
    def preprocess(self, subproblem, flux):
        bottom = 0.0  # [bottom, top] : the range normalized values
        top = 0.3     # to be weighted.
        self.weights = subproblem.zz_L2_weights(flux, bottom, top)
    #AMR subproblem, pass subproblem
    def __call__(self, element, subproblem, flux):
        index = element.get_index()
示例#4
0
                        discussion="""<para>

    Set default parameters for
    <link linkend="RegisteredClass-MeshInfoDisplay"><classname>MeshInfoDisplays</classname></link>.
    See <xref linkend="RegisteredClass-MeshInfoDisplay"/> for the details.
    This command may be placed in the &oof2rc; file to set a default value
    for all &oof2; sessions.
    
    </para>"""))

meshInfoDisplay = registeredclass.Registration(
    'Info',
    display.DisplayMethod,
    MeshInfoDisplay,
    params=meshinfoparams,
    ordering=4.0,
    layerordering=display.PointLike(100),
    whoclasses=('Mesh', ),
    tip=
    "Set display parameters for the decorations used by the Mesh Info toolbox.",
    discussion=xmlmenudump.loadFile(
        'DISCUSSIONS/engine/reg/meshinfodisplay.xml'))


def defaultMeshInfoDisplay():
    return meshInfoDisplay(query_color=defaultQueryColor,
                           peek_color=defaultPeekColor,
                           node_size=defaultNodeSize,
                           line_width=defaultLineWidth)


ghostgfxwindow.PredefinedLayer('Mesh', '<topmost>', defaultMeshInfoDisplay)
示例#5
0
from ooflib.SWIG.common import config
from ooflib.common import registeredclass
##import weakref


class BitmapDisplayMethod(display.DisplayMethod):
    def __init__(self):
        self.bitmapobject = None
        display.DisplayMethod.__init__(self)

    def draw(self, gfxwindow, device):
        bitmapobj = self.who().getObject(gfxwindow)
        if config.dimension() == 2:
            device.draw_image(bitmapobj, coord.Coord(0, 0), bitmapobj.size())
        if config.dimension() == 3:
            device.draw_image(bitmapobj, coord.Coord(0, 0, 0),
                              bitmapobj.size())


bitmapDisplay = registeredclass.Registration(
    'Bitmap',
    display.DisplayMethod,
    BitmapDisplayMethod,
    ordering=-100,
    layerordering=display.Planar,
    params=[],
    whoclasses=('Image', ),
    tip="Display an Image as a bitmap.",
    discussion=xmlmenudump.loadFile(
        'DISCUSSIONS/common/reg/bitmapdisplay.xml'))
示例#6
0
                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')
    )
示例#7
0
if config.dimension() == 2:
    bitoverlayparams = [
        color.ColorParameter('color', tip="Bitmap color."),
        parameter.FloatRangeParameter('tintOpacity', (0., 1., 0.01),
                                      0.6,
                                      tip="Opacity of the overlay.")
    ]
elif config.dimension() == 3:
    bitoverlayparams = [
        color.ColorParameter('color', tip="Bitmap color."),
        parameter.FloatRangeParameter('tintOpacity', (0., 1., 0.01),
                                      0.0,
                                      tip="Opacity of the tint."),
        parameter.FloatRangeParameter('voxelOpacity', (0., 1., 0.01),
                                      0.2,
                                      tip="Opacity of the given region.")
    ]

bitmapOverlay = registeredclass.Registration(
    'BitmapOverlay',
    display.DisplayMethod,
    BitmapOverlayDisplayMethod,
    params=bitoverlayparams,
    ordering=0,
    layerordering=display.SemiPlanar,
    whoclasses=('Pixel Selection', 'Active Area'),
    tip="Special bitmap display method for overlays.",
    discussion=xmlmenudump.loadFile(
        'DISCUSSIONS/common/reg/bitoverlaydisplay.xml'))
示例#8
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'))
示例#9
0
文件: imageIO.py 项目: song2001/OOF2
    pixels in &oof2; data files, as the <varname>pixels</varname>
    parameter in the <xref linkend='MenuItem-OOF.LoadData.Image.New'/>
    command.
    </para>"""

class RGBData8(ImageData):
    def __init__(self, rgbvalues):
        self.rgbvalues = rgbvalues
    def values(self):
        return self.rgbvalues

registeredclass.Registration(
    'RGBData8',
    ImageData,
    RGBData8,
    ordering=0,
    params=[
    parameter.ListOfUnsignedShortsParameter('rgbvalues', tip="RGB values.")],
    tip="RGB image data.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/image/reg/rgbdata8.xml'))



class GrayData8(ImageData):
    def __init__(self, grayvalues):
        self.grayvalues = grayvalues
    def values(self):
        return self.grayvalues

registeredclass.Registration(
    'GrayData8',
示例#10
0
                                primitives.Point(width, r_lvl)
                            ]))
            finally:
                self.lock.release()

    defaultLineWidth = 0
    widthRange = (0, 10)

    registeredclass.Registration(
        'Contour Line',
        display.DisplayMethod,
        PlainContourDisplay,
        ordering=3.0,
        layerordering=display.Linear(1),
        whoclasses=('Mesh', ),
        params=contourparams + [
            IntRangeParameter(
                'width', widthRange, defaultLineWidth, tip="line width"),
            color.ColorParameter('color', color.black, tip="line color")
        ],
        tip="Draw contour lines for the given output data.",
        discussion=xmlmenudump.loadFile(
            'DISCUSSIONS/engine/reg/plaincontour.xml'))

#=*=#=*=#=*=#=*=#=*=#=*=#=*=#=*=#=*=#=*=#=*=#=*=#=*=#=*=#=*=#=*=#=*=#=*=#


class FilledContourDisplay(ContourDisplay):
    def __init__(self,
                 when,
                 what,
示例#11
0
    def defaultName(self):
        return self.analysis

    def printHeaders(self, destination):
        self.analysisObj.printHeaders(destination)

    def save(self, datafile, meshctxt):
        # Before saving the ScheduledOutput, make sure the named
        # analysis is in the data file.
        from ooflib.engine.IO import analyzemenu
        analyzemenu.saveAnalysisDef(datafile, self.analysis)
        scheduledoutput.ScheduledOutput.save(self, datafile, meshctxt)


registeredclass.Registration(
    "Named Analysis",
    scheduledoutput.ScheduledOutput,
    NamedAnalysisOutput,
    ordering=3,
    destinationClass=outputdestination.TextOutputDestination,
    params=[
        AnalysisNameParameter(
            "analysis",
            tip=
            "Name of the analysis operation to perform.  Named analyses can be created on the Analysis and Boundary Analysis Pages."
        )
    ],
    tip="Use a predefined bulk or boundary Analysis method.",
    discussion=xmlmenudump.loadFile(
        'DISCUSSIONS/engine/reg/namedanalysis.xml'))
示例#12
0

class InputSeparator(registeredclass.RegisteredClass):
    registry = []

    def split(self, line):
        return line.split(self.character)


class WhiteSpaceSeparator(InputSeparator):
    character = None


registeredclass.Registration('White Space',
                             InputSeparator,
                             WhiteSpaceSeparator,
                             ordering=0,
                             tip="Any combination of blanks and tabs.")


class CommaSeparator(InputSeparator):
    character = ','


registeredclass.Registration("Comma",
                             InputSeparator,
                             CommaSeparator,
                             ordering=1,
                             tip="A comma.")

示例#13
0
        pass
    def require_timederiv_field(self, subproblemcontext):
        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):
示例#14
0
class NodeFromSelectedSegments(NodeSelectionModifier):
    def __call__(self, skeleton, selection):
        nodes = {}
        for segment in skeleton.segmentselection.retrieve():
            nodes[segment.nodes()[0]] = None
            nodes[segment.nodes()[1]] = None
        selection.start()
        selection.clear()
        selection.select(nodes.keys())


registeredclass.Registration(
    'Select from Selected Segments',
    NodeSelectionModifier,
    NodeFromSelectedSegments,
    ordering=0.1,
    tip="Select nodes from selected segments.",
    discussion=xmlmenudump.loadFile(
        'DISCUSSIONS/engine/menu/nodes_from_segments.xml'))

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


class NodeFromSelectedElements(NodeSelectionModifier):
    def __init__(self, internal=0, boundary=1):
        self.internal = internal
        self.boundary = boundary

    def getAllNodes(self, context):
        nodes = set()
        for element in context.elementselection.retrieve():
示例#15
0
    def computeStaticFields(self, subprobctxt, linsys, unknowns):
        # Called by SubProblemContext.initializeStaticFields.
        return subprobctxt.computeStaticFieldsL(linsys, unknowns)

    def shortrepr(self):
        return "None"

    def __repr__(self):
        return registeredclass.RegisteredClass.__repr__(self)


registeredclass.Registration(
    'None',
    NonlinearSolverBase,
    NoNonlinearSolver,
    ordering=0,
    tip="Use linear equation solvers.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/reg/nononlinear.xml'))

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


class NonlinearSolver(NonlinearSolverBase):
    def step(self, subprob, *args, **kwargs):
        return subprob.time_stepper.nonlinearstep(subprob,
                                                  nonlinearMethod=self,
                                                  *args,
                                                  **kwargs)

    def computeStaticFields(self, subprobctxt, linsys, unknowns):
示例#16
0
文件: profile.py 项目: santiama/OOF3D

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

if config.dimension() == 2:
    tipstr = "A function of x, y, nx, ny, i, s, and/or alpha."
else:
    tipstr = "A function of x, y, z, nx, ny, nz, and/or i."

registeredclass.Registration(
    "Continuum Profile",
    ProfileX,
    ContinuumProfile,
    ordering=2,
    params=[
        profilefunction.ProfileFunctionXParameter(
            "function",
            value=profilefunction.ProfileFunctionX("0.0"),
            tip=tipstr)
    ],
    tip="Boundary condition is an arbitrary function of position.",
    discussion=xmlmenudump.loadFile(
        'DISCUSSIONS/engine/reg/continuumprofilex.xml'))

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


class ContinuumProfileXT(ProfileXT, _ContinuumProfileXT):
    pass


if config.dimension() == 2:
示例#17
0
# work with more than one ScheduleType.

class ScheduleType(registeredclass.RegisteredClass):
    registry = []
    tip="How output Schedules are interpreted."
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/reg/scheduletype.xml')

class AbsoluteOutputSchedule(ScheduleType):
    conditional = False
    def setOffset(self, schedule, time0):
        schedule.setOffset(0.0)

registeredclass.Registration(
    'Absolute',
    ScheduleType,
    AbsoluteOutputSchedule,
    ordering=0,
    tip="Output schedule times are absolute.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/reg/absolutesched.xml')
)

class RelativeOutputSchedule(ScheduleType):
    conditional = False
    def setOffset(self, schedule, time0):
        schedule.setOffset(time0)

registeredclass.Registration(
    'Relative',
    ScheduleType,
    RelativeOutputSchedule,
    ordering=1,
    tip="Output schedule times are relative to the start time.",
示例#18
0
    Set default parameters for the
    <xref linkend="RegisteredClass-SkeletonNodeSelectionDisplay"/>,
    which displays the currently selected &skel; &nodes; in the graphics
    window.  See
    <xref linkend="RegisteredClass-SkeletonNodeSelectionDisplay"/>
    for a discussion of the parameters. This command may be put in the
    &oof2rc; file to set defaults for all &oof2; sessions.
    
    </para>"""))

nodeSelectDisplay = registeredclass.Registration(
    'Selected Nodes',
    display.DisplayMethod,
    SkeletonNodeSelectionDisplay,
    params=nodeselparams,
    ordering=2.2,
    layerordering=display.PointLike(3),
    whoclasses=('Skeleton', ),
    tip="Display the currently selected nodes.",
    discussion=xmlmenudump.loadFile(
        'DISCUSSIONS/engine/reg/nodeselectdisplay.xml'))


def defaultNodeSelectDisplay():
    return nodeSelectDisplay(color=defaultNodeSelColor,
                             size=defaultNodeSelSize)


ghostgfxwindow.PredefinedLayer('Skeleton', '<topmost>',
                               defaultNodeSelectDisplay)
示例#19
0
            x.integrate(domain, output, order, power) for x in self.sample_list
        ]
        return zip(self.sample_list, vals)

    def get_col_names(self):  # see comment in SampleSet.
        return []


registeredclass.Registration(
    "Element Set",
    SampleSet,
    ElementSampleSet,
    10,
    params=[
        parameter.AutoIntParameter(
            "order",
            automatic.automatic,
            tip="Set the order of integration to use during this computation.")
    ],
    sample_type=ELEMENT,
    direct=False,
    tip='Data will be integrated over Element areas.',
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/reg/elementset.xml'))

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

# Trick function which creates the registrations for SampleSet
# objects.  Makes both a "direct" and an "indirect" version of each
# sample set, the former used for point-wise data output, and the
# latter used for statistical or composite data output.  The
# non-direct subclass is created locally and registered in this
示例#20
0
        selection.start()
        selection.clearAndSelect(
            pixelselectioncourieri.ColorSelection(ms, imageobj, self.reference,
                                                  self.range))


registeredclass.Registration(
    'Color Range',
    pixelselectionmod.SelectionModifier,
    ColorRange,
    ordering=3.14,
    params=[
        whoville.WhoParameter('image',
                              whoville.getClass('Image'),
                              tip=parameter.emptyTipString),
        color.NewColorParameter('reference', tip='Reference color.'),
        colordiffparameter.ColorDifferenceParameter(
            'range', tip='Deviation from the reference color.')
    ],
    tip="Select all pixels similar to a reference color.",
    discussion="""<para>

    Select all pixels in an &image; within a given
    <varname>range</varname> of a given <varname>refererence</varname>
    color.  This command basically does the same thing that <xref
    linkend='MenuItem:OOF.Graphics_n.Toolbox.Pixel_Select.Color'/>
    does except the latter takes its <varname>reference</varname>
    input from a mouse click in the Graphics window.

    </para>""")
示例#21
0
    # using C_eff, which is symmetric if M and C are both symmetric
    # and if C21 is zero.

    # If the problem has no second order time derivatives, we'll just
    # be using C.  M's symstate will be INCONSISTENT and C21 will be
    # empty.

    return (subproblem.matrix_symmetry_M == symstate.ASYMMETRIC
            or subproblem.matrix_symmetry_C == symstate.ASYMMETRIC
            or linsys.C21_nonempty())


registeredclass.Registration(
    'Forward Euler',
    timestepper.TimeStepper,
    ForwardEuler,
    ordering=0,
    explicit=True,
    tip="Fully explicit first order time stepping.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/reg/euler.xml'))

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

# Generalized Euler: everything between Forward Euler and Backward
# Euler.  self.theta is defined in subclasses.


class NLDataGE(timestepper.NLData):
    def __init__(self, subproblem, linsys0, endtime, dt, unknowns, theta):
        self.dt = dt
        self.C = linsys0.C_MCKa()
        # resid0 is the part of the residual that can be computed at
示例#22
0
        self.value = value

    def func(self, position, time, component):
        return self.value

    def shortrepr(self):
        return str(self.value)


registeredclass.Registration(
    "Constant",
    ScalarFieldInit,
    ConstScalarFieldInit,
    0,
    params=[
        parameter.FloatParameter('value',
                                 0.0,
                                 tip='Value to assign to the Field.')
    ],
    tip="Initialize a scalar field with a constant value.",
    discussion=xmlmenudump.loadFile(
        'DISCUSSIONS/engine/reg/const_scalar_field_init.xml'))

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


class ConstTwoVectorFieldInit(TwoVectorFieldInit):
    def __init__(self, cx, cy):
        self.cx = cx
        self.cy = cy
示例#23
0
#=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=#


class PinNodeSelection(PinNodesModifier):
    def __call__(self, skelcontext):
        skelcontext.pinnednodes.start()
        skelcontext.pinnednodes.pinSelection(
            skelcontext.nodeselection.currentSelectionTracker())


registeredclass.Registration('Pin Node Selection',
                             PinNodesModifier,
                             PinNodeSelection,
                             ordering=0,
                             tip="Pin selected nodes.",
                             discussion="""<para>
    <link linkend='MenuItem-OOF.Skeleton.PinNodes'>Pin</link> the
    currently <link
    linkend='MenuItem-OOF.NodeSelection'>selected</link> &nodes;.
    </para>""")

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


class UnPinNodeSelection(PinNodesModifier):
    def __call__(self, skelcontext):
        skelcontext.pinnednodes.start()
        skelcontext.pinnednodes.unpinSelection(
            skelcontext.nodeselection.currentSelectionTracker())

示例#24
0
        return self.details

# Subclasses have to have two data members.  "tag" is a string that
# appears in the Status box on the Solver page.  "solvable" is a bool
# that says whether or not the mesh can be solved in its current
# state.  It's used to sensitize the "Solve" button on the Solver
# page.

class Unsolved(MeshStatus):
    tag = "Unsolved"
    solvable = True

registeredclass.Registration(
    "Unsolved",
    MeshStatus,
    Unsolved,
    params=[parameter.StringParameter("details")],
    ordering=0,
    tip=parameter.emptyTipString)

class Unsolvable(MeshStatus):
    tag = "Unsolvable"
    solvable = False

registeredclass.Registration(
    "Unsolvable",
    MeshStatus,
    Unsolvable,
    params=[parameter.StringParameter("details")],
    ordering=1,
    tip=parameter.emptyTipString)
示例#25
0

class ILUTPreconditioner(PreconditionerBase):
    name = "ILUT"


# ILU preconditioner actually points to ILUT preconditioner
class ILUPreconditioner(PreconditionerBase):
    name = "ILU"


registeredclass.Registration(
    "Null",
    PreconditionerBase,
    UnPreconditioner,
    ordering=2000,
    params=[],
    tip=
    "Be bold (or foolhardy) and attempt to solve the mesh without a preconditioner"
)

registeredclass.Registration(
    "Jacobi",
    PreconditionerBase,
    JacobiPreconditioner,
    ordering=500,
    params=[],
    tip=
    "A light-weight preconditioner, that simply inverts the diagonal part of the matrix."
)
示例#26
0
            if indxdiff == 2 or indxdiff == -2:
                changes.extend(self.fix2(skel, element, edgeLengths[0][1]))
            return changes
        return []

    def fix(self, skel, element, which):
        node0 = element.nodes[which]
        node1 = element.nodes[(which+1)%4]
        return [skel.mergeNodePairs((node0, node1)),
                skel.mergeNodePairs((node1, node0))]

    def fix2(self, skel, element, which):
        nodes = [element.nodes[(which+i)%4] for i in range(4)]
        return [skel.mergeNodePairs((nodes[0], nodes[1]), (nodes[2], nodes[3])),
            skel.mergeNodePairs((nodes[1], nodes[0]), (nodes[2], nodes[3])),
            skel.mergeNodePairs((nodes[1], nodes[0]), (nodes[3], nodes[2])),
            skel.mergeNodePairs((nodes[0], nodes[1]), (nodes[3], nodes[2]))]

registeredclass.Registration(
    'Remove Short Sides',
    rationalize.Rationalizer,
    RemoveShortSide,
    gerund = 'removing short sides',
    ordering=0,
    params=[
    parameter.FloatParameter('ratio', value = 5.0,
                             tip = 'Maximum acceptable ratio of the lengths of the second shortest and the shortest sides.')
    ],
    tip = "Eliminate the shortest side of a quadrilateral.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/reg/ration_short.xml'))
示例#27
0
    Set default parameters for
    <link linkend="RegisteredClass-MeshCrossSectionDisplay"><classname>MeshCrossSectionDisplays</classname></link>.
    See <xref linkend="RegisteredClass-MeshCrossSectionDisplay"/> for the
    details.  This command may be put into your &oof2rc; file to set
    defaults for all &oof2; sessions.
    
    </para>"""))

meshCrossSectionDisplay = registeredclass.Registration(
    'Cross Section',
    display.DisplayMethod,
    MeshCrossSectionDisplay,
    params=[
        meshcsparams.MeshCrossSectionSetParameter(
            'cross_sections',
            placeholder.selection,
            tip="Which cross-section to display?")
    ] + meshcsdispparams,
    ordering=5.0,
    layerordering=display.SemiLinear,
    whoclasses=('Mesh', ),
    tip="Determine which cross sections are displayed, and how.",
    discussion=xmlmenudump.loadFile(
        'DISCUSSIONS/engine/reg/meshcsdisplay.xml', ))


def defaultMeshCrossSectionDisplay():
    return meshCrossSectionDisplay(color=defaultMeshCSColor,
                                   linewidth=defaultMeshCSLineWidth)


ghostgfxwindow.PredefinedLayer('Mesh', '<contourable>',
示例#28
0
    callback=_setDefaultVoxelRegionSelectionParams,
    ordering=1,
    params=voxelregionselectionparams,
    help="Set default parameters for voxel region selection tools.",
    discussion="""<para>

    Set default parameters for <link linkend="RegisteredClass:VoxelRegionSelectionDisplay"><classname>VoxelRegionSelectionDisplays</classname></link>.
    See <xref linkend="RegisteredClass:VoxelRegionSelectionDisplay"/> for the details.

    </para>"""))

voxelRegionSelectionDisplay = registeredclass.Registration(
    'Voxel Region Click-and-Drag Editor',
    display.DisplayMethod,
    VoxelRegionSelectionDisplay,
    params=voxelregionselectionparams,
    ordering=3.1,
    layerordering=display.Celestial(0.5),
    whoclasses=('Microstructure'),
    tip="Display the widget for editing a region containing all the voxels to be selected."
    )

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

from ooflib.common.IO import whoville

def predefinedVoxelRegionSelectionLayer():
    # When a new graphics window is opened, a
    # VoxelRegionSelectionDisplay will be automatically created with
    # the default sizing and coloring options.
    return VoxelRegionSelectionDisplay(
        point_size=defaultVoxelRegionSelectionPointSize,
示例#29
0
class SkeletonEdgeDisplay(EdgeDisplay, SkeletonDisplayMethod):
    def __init__(self, width=defaultSkeletonWidth, color=defaultSkeletonColor):
        self.width = width
        self.color = color
        SkeletonDisplayMethod.__init__(self)


registeredclass.Registration(
    'Element Edges',
    display.DisplayMethod,
    MeshEdgeDisplay,
    ordering=0.0,
    layerordering=display.Linear,
    params=meshdispparams + [
        color.ColorParameter(
            'color', defaultMeshColor, tip="Color of the displayed edges."),
        IntRangeParameter('width',
                          widthRange,
                          defaultMeshWidth,
                          tip="Line thickness, in pixels.")
    ],
    whoclasses=('Mesh', ),
    tip="Draw the edges of Mesh Elements.",
    discussion=xmlmenudump.loadFile(
        'DISCUSSIONS/engine/reg/meshedgedisplay.xml'))

registeredclass.Registration(
    'Element Edges',
    display.DisplayMethod,
    SkeletonEdgeDisplay,
    ordering=0.0,
    layerordering=display.Linear,
示例#30
0
        discussion="""<para>

    Set default parameters governing how the
    <link linkend="Section-Graphics-MoveNodes">Move Nodes Toolbox</link>
    displays the moving node in the graphics window.  See
    <xref linkend="RegisteredClass-MoveNodeDisplay"/> for details.
    This command can be put in the &oof2rc; file to set the defaults for
    all &oof2; sessions.

    </para>"""))

moveNodeDisplay = registeredclass.Registration(
    'Moving Nodes',
    display.DisplayMethod,
    MoveNodeDisplay,
    params=movenodeparams,
    ordering=3.0,
    layerordering=display.PointLike(1),
    whoclasses=('Skeleton', ),
    tip="Display the node being moved by the Move Node toolbox.",
    discussion=xmlmenudump.loadFile(
        'DISCUSSIONS/engine/reg/movenodedisplay.xml'))


def defaultMoveNodeDisplay():
    return moveNodeDisplay(color=defaultMoveNodeColor,
                           size=defaultMoveNodeSize)


ghostgfxwindow.PredefinedLayer('Skeleton', '<topmost>', defaultMoveNodeDisplay)