Example #1
0
import ooflib.common.microstructure
from types import *

if parallel_enable.enabled():
    from ooflib.common.IO import microstructureIPC

micromenu = mainmenu.OOF.addItem(oofmenu.OOFMenuItem(
    'Microstructure',
    help="Create and manipulate µ objects.",
    cli_only=1))
#######################

if config.dimension() == 2:
    sizeparams = parameter.ParameterGroup(
        parameter.FloatParameter('width', 1., tip='Width in physical units.'),
        parameter.FloatParameter('height', 1.,tip='Height in physical units.'),
        parameter.IntParameter('width_in_pixels', 10, tip='Width in pixels.'),
        parameter.IntParameter('height_in_pixels', 10, tip='Height in pixels.'))
    
    
    def newMicrostructure(menuitem, name,
                          width, height,
                          width_in_pixels, height_in_pixels):
        if width<=0 or height<=0 or width_in_pixels<=0 or height_in_pixels<=0:
            raise ooferror.ErrUserError("Negative size values are not allowed.")

        if parallel_enable.enabled():
            # For the rear-end guys
            microstructureIPC.msmenu.New_Parallel(name=name,
                                                 width=width, height=height,
                                                 width_in_pixels=width_in_pixels,
Example #2
0
    skelname = param.group['skeleton'].value
    skelcontext = skeletoncontext.skeletonContexts[skelname]
    return skelcontext.uniqueBoundaryName(basename)


skeletonparam = whoville.WhoParameter(
    'skeleton',
    skeletoncontext.skeletonContexts,
    tip="The Skeleton containing the  boundary.")

nameparam = parameter.AutomaticNameParameter('name',
                                             bdynameresolver,
                                             value=automatic.automatic,
                                             tip="Name for this boundary.")

paramgroup = parameter.ParameterGroup(skeletonparam, nameparam)

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


class BoundaryConstructor(registeredclass.RegisteredClass):
    registry = []
    tip = "Tools to build Skeleton boundaries."
    discussion = """<para>
    <classname>BoundaryConstructor</classname> objects are used by the
    <xref linkend='MenuItem-OOF.Skeleton.Boundary.Construct'/> command
    to build <link
    linkend='Section-Concepts-Skeleton-Boundary'>boundaries</link> in
    a &skel;.
    </para>"""
Example #3
0
                                help=help,
                                discussion=registration.discussion))
        menuitem.data = registration


switchboard.requestCallback(imagemodifier.ImageModifier, buildImageModMenu)
buildImageModMenu()

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

# Size params are reused several times
sizeparams = parameter.ParameterGroup(
    parameter.AutoNumericParameter('height',
                                   automatic.automatic,
                                   tip= \
                                   "Physical height of image, or 'automatic'."),
    parameter.AutoNumericParameter('width',
                                   automatic.automatic,
                                   tip= \
                                   "Physical width of image, or 'automatic'."))

if config.dimension() == 3:
    sizeparams.append(parameter.AutoNumericParameter(
        'depth',
        automatic.automatic,
        tip= \
        "Physical depth of image, or 'automatic'."))

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

if config.dimension() == 2:
Example #4
0
                                                      skeleton_geometry)
        else:
            ms = microStructures[microstructure].getObject()
            skel = cskeleton2.initialSkeleton(name, ms, x_elements, y_elements,
                                              skeleton_geometry)
        switchboard.notify("redraw")

    skelparams = parameter.ParameterGroup(
        AutoWhoNameParameter('name',
                             value=automatic.automatic,
                             resolver=skeletonNameResolver,
                             tip="Name of the new skeleton."),
        WhoParameter('microstructure',
                     microStructures,
                     tip=parameter.emptyTipString),
        IntParameter('x_elements',
                     4,
                     tip="No. of elements in the x-direction."),
        IntParameter('y_elements',
                     4,
                     tip="No. of elements in the y-direction."),
        RegisteredParameter('skeleton_geometry',
                            skeleton.SkeletonGeometry,
                            skeleton.QuadSkeleton(),
                            tip="The shape of the elements."))

elif config.dimension() == 3:

    def _skeleton_from_mstructure(menuitem, name, microstructure, x_elements,
                                  y_elements, z_elements, skeleton_geometry):
        if parallel_enable.enabled():  # PARALLEL
            skel = cskeleton2.initialSkeletonParallel(name, microstructure,
Example #5
0
    else:
        basename = name
    meshname = param.group['mesh'].value
    if meshname is not None:
        meshpath = labeltree.makePath(meshname)
        meshcontext = ooflib.engine.mesh.meshes[meshpath]
        return meshcontext.uniqueBCName(basename)

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)
Example #6
0
    finally:
        meshctxt.end_writing()
    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(
Example #7
0
    if parallel_enable.enabled():
        from ooflib.engine.IO import propertymenuIPC
        propertymenuIPC.ipcpropmenu.Copy(property=property,new_name=new_name)
    else:
        try:
            AllProperties.new_prop(property, new_name)
        except ooferror.ErrUserError, e:
            print e

OOF.Property.addItem(oofmenu.OOFMenuItem(
    'Copy',
    callback=_copywrapper,
    params=parameter.ParameterGroup(
    parameter.StringParameter('property', tip="Name of the source Property."),
    parameter.RestrictedAutomaticNameParameter('new_name',
                                               exclude=':',
                                               resolver=propertyNameResolver,
                                               value=automatic.automatic,
                                               tip="Name for the new Property.")
    ),
    help="Copy a Property.",
    discussion="""<para>

    Make a copy of an existing &property;, with the same parameters.
    The source &property; can be a named &property; or one of the
    predefined unnamed &properties;.

    </para>"""))


def _deletewrapper(menuitem, property):
    if parallel_enable.enabled():
Example #8
0
        basename = name
    # Remove colons from the basename.
    return ooflib.common.microstructure.microStructures.uniqueName(
        basename.replace(':', '.'))


microstructuremenu.micromenu.addItem(
    oofmenu.OOFMenuItem(
        'Create_From_OrientationMap_File',
        callback=_createMSFromOrientationMapFile,
        params=parameter.ParameterGroup(
            filenameparam.ReadFileNameParameter(
                'filename', tip='Name of the Orientation Map file.'),
            enum.EnumParameter('format',
                               orientmapdata.OrientMapType,
                               tip='Type of orientation map file.'),
            parameter.AutomaticNameParameter(
                'microstructure',
                msOrientMapFileNameResolver,
                automatic.automatic,
                tip='Name of the new Microstructure.')),
        help=
        "Load an Orientation Map file and create a Microstructure from it.",
        discussion=xmlmenudump.loadFile(
            'DISCUSSIONS/orientationmap/menu/create.xml')))

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


def _imageNameResolver(param, startname):
    msname = labeltree.makePath(param.group['microstructure'].value)[0]
Example #9
0
def parallel_buildbc(menuitem, name, mesh, condition):
    condition.add_to_mesh(name, mesh)
    switchboard.notify("mesh changed", ooflib.engine.mesh.meshes[mesh])


## OOF.LoadData.IPC.Boundary_Conditions.buildbc
ipcbcmenu.addItem(
    oofmenu.OOFMenuItem(
        'buildbc',
        callback=parallel_buildbc,
        threadable=oofmenu.PARALLEL_THREADABLE,
        params=parameter.ParameterGroup(
            parameter.StringParameter('name'),
            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."))))


def parallel_bcrename(menuitem, mesh, bc, name):
    meshcontext = ooflib.engine.mesh.meshes[mesh]
    meshcontext.renameBdyCondition(bc, name)


ipcbcmenu.addItem(
    oofmenu.OOFMenuItem(
        "Rename",
        callback=parallel_bcrename,
Example #10
0
        else:
            basename = 'material'
    else:
        basename = startname
    return utils.uniqueName(basename, materialmanager.getMaterialNames())


#Interface branch
_materialmenu.addItem(
    OOFMenuItem('New',
                callback=_newmaterial,
                params=parameter.ParameterGroup(
                    parameter.AutomaticNameParameter(
                        'name',
                        resolver=materialNameResolver,
                        value=automatic.automatic,
                        tip="Name of the material."),
                    enum.EnumParameter('material_type',
                                       MaterialType,
                                       value=MATERIALTYPE_BULK,
                                       tip="Type of the material.")),
                help="Create a new Material.",
                discussion="""<para>
    Create a new &material; containing no &properties;.  If another
    &material; with the same <varname>name</varname> already exists,
    <userinput>&lt;x&gt;</userinput> will be appended to the new
    <varname>name</varname>, where <userinput>x</userinput> is an
    integer chosen to make the new name unique.
    </para>"""))


# Rename an existing material.
Example #11
0
    # 'subproblem' is a SubProblemType instance
    subpobj = subproblem.create()
    meshcontext.newSubProblem(subpobj, subproblem,
                              labeltree.makePath(mesh) + [name])


subproblemMenu.addItem(
    oofmenu.OOFMenuItem(
        'New',
        callback=_new_subproblem,
        threadable=oofmenu.THREADABLE,
        params=parameter.ParameterGroup(
            whoville.AutoWhoNameParameter('name',
                                          value=automatic.automatic,
                                          resolver=subproblemNameResolver,
                                          tip="Name of the new SubProblem"),
            SyncMeshParameter('mesh', tip=parameter.emptyTipString),
            parameter.RegisteredParameter('subproblem',
                                          subproblemtype.SubProblemType,
                                          tip=parameter.emptyTipString)),
        help="Define a new subproblem",
        discussion="""<para>

    Create a new &subproblem; in the given &mesh;.  If the given name
    is not unique in the &mesh;, <userinput>&lt;x&gt;</userinput> will
    be appended to it, where <userinput>x</userinput> is an integer
    chosen to make the name unique.  </para>
    """))

#############
Example #12
0
def buildActiveAreaModMenu():
    aamodmenu.clearMenu()
                                                                                
    aamodmenu.addItem(oofmenu.OOFMenuItem(
        'Undo',
        callback=_undo,
        params=[whoville.WhoParameter(
                    'microstructure',
                    ooflib.common.microstructure.microStructures,
                    tip=parameter.emptyTipString)
                ],
        help="Undo the latest active area modification.",
        discussion="""<para>
        Revert to the previous &active; in the given
        &micro;.</para>"""
        ))
                                                                                
    aamodmenu.addItem(oofmenu.OOFMenuItem(
        'Redo',
        callback=_redo,
        params=[whoville.WhoParameter(
                    'microstructure',
                    ooflib.common.microstructure.microStructures,
                    tip=parameter.emptyTipString)
                ],
        help="Redo the latest undone active area modification.",
        discussion="""<para>
        Undo the latest <xref linkend='MenuItem:OOF.ActiveArea.Undo'/>.
        </para>"""))

    aamodmenu.addItem(oofmenu.OOFMenuItem(
        'Override',
        params=[parameter.BooleanParameter(
                    'override', 0,
                    tip="Whether to override or not."),
                whoville.WhoParameter(
                    'microstructure',
                    ooflib.common.microstructure.microStructures,
                    tip=parameter.emptyTipString)
                ],
        callback=_override,
        help="Temporarily activate the entire Microstructure.",
        discussion=xmlmenudump.loadFile(
                'DISCUSSIONS/common/menu/activearea_override.xml')))

    aamodmenu.addItem(oofmenu.OOFMenuItem(
        'Store',
        callback=_store,
        params=parameter.ParameterGroup(
        whoville.WhoParameter('microstructure',
                              ooflib.common.microstructure.microStructures,
                              tip=parameter.emptyTipString),
        parameter.AutomaticNameParameter(
                    'name', value=automatic.automatic,
                    resolver=activeAreaNameResolver,
                    tip = "The name of the active are to be stored")),
        help="Store the current active area.",
        discussion="""<para>

        Give the current &active; a <varname>name</varname>, and store
        it for future use.  This makes it easy to switch between
        different active regions of a &micro;.  If the given
        <varname>name</varname> is already being used for another
        &active; in the same &micro;, then
        <userinput>&lt;x&gt;</userinput> will be appended to it, where
        <userinput>x</userinput> is an integer chosen to make the name
        unique.

        </para>"""))

    aamodmenu.addItem(oofmenu.OOFMenuItem(
        'Restore',
        callback=_restore,
        params=[whoville.WhoParameter(
                    'microstructure',
                    ooflib.common.microstructure.microStructures,
                    tip=parameter.emptyTipString),
                parameter.StringParameter(
                    'name', tip="The name of the active area to be restored.")],
        help="Restore a named active area.",
        discussion="""<para>
        Set the current &active; to the given <link
        linkend='MenuItem:OOF.ActiveArea.Store'>stored</link>
        &active;.
        </para>"""))
    
    aamodmenu.addItem(oofmenu.OOFMenuItem(
        'Rename',
        callback=_rename,
        params=[
        whoville.WhoParameter('microstructure',
                              ooflib.common.microstructure.microStructures,
                              tip=parameter.emptyTipString),
        parameter.StringParameter('oldname',
                                  tip="The name of a stored active area."),
        parameter.StringParameter('newname', '',
                                  tip='A new name for the active area.')
        ],
        help="Rename the stored active area.",
        discussion="<para>Assign a new name to a stored active area.</para>"))
    
    aamodmenu.addItem(oofmenu.OOFMenuItem(
        'Delete',
        callback=_delete,
        params=[
        whoville.WhoParameter('microstructure',
                              ooflib.common.microstructure.microStructures,
                              tip=parameter.emptyTipString),
        parameter.StringParameter(
                    'name',
                    tip="The name of the active area to be deleted.")],
        help="Delete a stored active area.",
        discussion="""<para>
        Delete a <link
        linkend='MenuItem:OOF.ActiveArea.Store'>stored</link> active
        area.  This only deletes the stored copy of the active area.
        It does not affect the activity of any pixels.
        </para>"""))
    
                           
                                                                                
    for registration in activeareamod.ActiveAreaModifier.registry:
        # registration tip string => menuitem help string
        try:
            help = registration.tip
        except AttributeError:
            help = None
        # registration discussion => menuitem discussion
        try:
            discussion = registration.discussion
        except AttributeError:
            discussion = None
        menuitem = aamodmenu.addItem(
            oofmenu.OOFMenuItem(utils.space2underscore(registration.name()),
                                callback=activeareamod.modify,
                                params=[
            whoville.WhoParameter('microstructure',
                                  ooflib.common.microstructure.microStructures,
                                  tip=parameter.emptyTipString)
            ] + registration.params,
                                help=help,
                                discussion=discussion))
        menuitem.data = registration
Example #13
0
    msobj = ooflib.common.microstructure.microStructures[msname].getObject()
    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[
Example #14
0
                                                   immidge.sizeInPixels(),
                                                   immidge.size())
    newimagecontext = oofimage.imageContexts.add([msname, immidge.name()],
                                                 immidge,
                                                 parent=ooflib.common.microstructure.microStructures[msname])
    ms.addImage(newimagecontext)

imenu.addItem(oofmenu.OOFMenuItem(
    'Create_From_Image_Parallel',
    callback = createMSFromImage_Parallel,
    secret = 1,
    no_log = 1,
    threadable = oofmenu.PARALLEL_THREADABLE,
    params = parameter.ParameterGroup(
    parameter.AutomaticNameParameter('msname', imagemenu.msImageNameResolver,
                                     automatic.automatic,
                                     tip="Name of the new Microstructure."),
    parameter.StringParameter('image'))
    ))

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

def createImage(msname, imagename, origin=0):
    if _rank == origin:
        image = oofimage.getImage([msname, imagename])
        destinations = range(1,_size)
        oofimage.Send_Image(image, destinations)
    else:
        image = oofimage.Recv_Image(origin)
    return image
Example #15
0
    for n in notifications:
        switchboard.notify(*n)


ipcmeshmenu.addItem(
    oofmenu.OOFMenuItem(
        'Copy',
        callback=copyMesh_parallel,
        threadable=oofmenu.PARALLEL_THREADABLE,
        params=parameter.ParameterGroup(
            whoville.WhoParameter('mesh',
                                  ooflib.engine.mesh.meshes,
                                  tip=parameter.emptyTipString),
            parameter.StringParameter('name'),
            parameter.BooleanParameter('copy_field',
                                       value=1,
                                       tip='Copy fields?'),
            parameter.BooleanParameter('copy_equation',
                                       value=1,
                                       tip='Copy equation?'),
            parameter.BooleanParameter('copy_bc',
                                       value=1,
                                       tip='Copy boundary conditions?'))))

########################################################################
# Field (Define/Undefine, Activate/Deactivate, In_Plane/Out_of_Plane)
########################################################################

## OOF.LoadData.IPC.Field
ipcfieldmenu = parallelmainmenu.ipcmenu.addItem(
    oofmenu.OOFMenuItem('Field', secret=1, no_log=1))
Example #16
0
    finally:
        meshctxt.end_writing()
    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.")),
        help=
        "Create an output operation to be performed during a time evolution.",
        discussion=xmlmenudump.loadFile(
            'DISCUSSIONS/engine/menu/newschedout.xml')))

outputIOmenu.addItem(
    outputmenu.New.clone(
        discussion="<para>Used internally in data files.</para>"))
Example #17
0
    else:
        basename = startname
    msname = param.group['microstructure'].value
    ms = ooflib.common.microstructure.getMicrostructure(msname)
    return ms.uniqueGroupName(basename)


pixgrpmenu.addItem(
    OOFMenuItem(
        'New',
        callback=newPixelGroup,
        params=parameter.ParameterGroup(
            AutomaticNameParameter('name',
                                   value=automatic.automatic,
                                   resolver=pixelGroupNameResolver,
                                   tip="Group name."),
            whoville.WhoParameter(
                'microstructure',
                whoville.getClass('Microstructure'),
                tip="Microstructure in which to create this PixelGroup.")),
        help='Create a new PixelGroup in the given Microstructure.',
        discussion="""<para>

    Create a new &pixelgroup;.  The <varname>name</varname> of the
    group must be unique within the &micro;.  If it is not unique, a
    suffix of the form <userinput>&lt;x&gt;</userinput> will be
    appended, for some integer <userinput>x</userinput>.

    </para>"""))

##########################
Example #18
0
        if newness:
            switchboard.notify("new pixel group", grp)
        return grp

    reporter.report("Failed to create group", name, "in microstructure",
                    microstructure)


ipcpixgrpmenu.addItem(
    OOFMenuItem(
        'New',
        callback=newPixelGroup_parallel,
        threadable=oofmenu.PARALLEL_THREADABLE,
        params=parameter.ParameterGroup(
            StringParameter('name', tip="Group name."),
            whoville.WhoParameter(
                'microstructure',
                whoville.getClass('Microstructure'),
                tip="Microstructure in which to create this PixelGroup.")),
        help='Create a new PixelGroup in the given Microstructure.',
        discussion="""<para>

    Create a new &pixelgroup;.  The <varname>name</varname> of the
    group must be unique within the &micro;.  If it is not unique, a
    suffix of the form <userinput>&lt;x&gt;</userinput> will be
    appended, for some integer <userinput>x</userinput>.

    </para>"""))

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

Example #19
0
        return startname


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

# Node-specific menu items:

new = oofmenu.OOFMenuItem(
    "New_Group",
    cli_only=1,
    callback=_new_group,
    params=parameter.ParameterGroup(
        whoville.WhoParameter("skeleton",
                              whoville.getClass('Skeleton'),
                              tip=parameter.emptyTipString),
        AutomaticNameParameter("name",
                               value=automatic.automatic,
                               resolver=NewGroupNameResolver(
                                   "nodegroup", "nodegroups"),
                               tip="Name of the group to be created.")),
    help="Create a new node group.",
    discussion=xmlmenudump.loadFile(
        'DISCUSSIONS/engine/menu/newnodegroup.xml'))
new.data = "nodegroups"
nodegroupmenu.addItem(new)

auto = oofmenu.OOFMenuItem(
    "Auto_Group",
    cli_only=1,
    callback=_auto_group,
    params=[