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():
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
parameter.BooleanParameter('left_right_periodicity', value=False, tip="Whether or not the skeleton is periodic in the horizontal direction"), parameter.BooleanParameter("top_bottom_periodicity", value=False, tip="Whether or not the skeleton is periodic in the vertical direction"), parameter.BooleanParameter("front_back_periodicity", value=False, tip="Whether or not the skeleton is periodic in the third direction")) skeletonmenu.addItem(oofmenu.OOFMenuItem( 'Auto', callback=autoskeleton.autoSkeleton, threadable=oofmenu.THREADABLE, no_log=True, # because it calls other menu items params=parameter.ParameterGroup( parameter.AutomaticNameParameter('name', value=automatic.automatic, resolver=skeletonNameResolver, tip="Name of the new skeleton."), whoville.WhoParameter('microstructure', ooflib.common.microstructure.microStructures, tip=parameter.emptyTipString)) + periodicityParams + parameter.ParameterGroup( parameter.FloatParameter('maxscale', value=1.0, tip="Rough size of the largest elements."), parameter.FloatParameter("minscale", value=1.0, tip="Rough size of the smallest elements."), enum.EnumParameter('units', ooflib.common.units.Units, value='Physical', tip="Units for minscale and maxscale."), parameter.FloatRangeParameter('threshold', (0.0, 1.0, 0.01), value=0.90, tip="Minimum acceptable homogeneity")
## OOF.Named_Analysis. def _nameAnalysis(menuitem, name, boundary, analyzer): namedanalysis.NamedBdyAnalysis(name, boundary, analyzer) switchboard.notify("named boundary analyses changed") bdyanalysismenu.addItem( oofmenu.OOFMenuItem( "Create", callback=_nameAnalysis, params=[ parameter.AutomaticNameParameter( 'name', resolver=namedanalysis.bdynameResolver, value=automatic.automatic, tip="The name of the analysis."), bdy_param, analyzer_param ], help="Assign a name to a set of boundary analysis parameters.", discussion=xmlmenudump.loadFile( 'DISCUSSIONS/engine/menu/newnamedbdyanal.xml'))) mainmenu.OOF.LoadData.addItem( oofmenu.OOFMenuItem( 'NamedBdyAnalysis', callback=_nameAnalysis, params=[ parameter.StringParameter('name', tip=parameter.emptyTipString), bdy_param, analyzer_param ],
basename = 'material' 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><x></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>"""))
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 µ.</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 µ. If the given <varname>name</varname> is already being used for another &active; in the same µ, then <userinput><x></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
else: basename = startname msname = param.group['microstructure'].value 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 µs;. 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()
namedanalysismenu = mainmenu.OOF.addItem(oofmenu.OOFMenuItem( 'Named_Analysis', help="Create analysis operations that can be saved and invoked by name", cli_only=1)) def _nameAnalysis(menuitem, name, operation, data, domain, sampling): namedanalysis.NamedAnalysis(name, operation, data, domain, sampling) switchboard.notify("named analyses changed") namedanalysismenu.addItem(oofmenu.OOFMenuItem( "Create", callback=_nameAnalysis, params=[parameter.AutomaticNameParameter( 'name', resolver=namedanalysis.nameResolver, value=automatic.automatic, tip="The name of the analysis."), parameter.RegisteredParameter( 'operation', analyze.DataOperation, tip="How to handle the data."), output_param, domain_param, sample_param], help="Assign a name to a set of analysis parameters.", discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/menu/newnamedanal.xml') )) # The data file command for loading a named analysis uses the same # callback as the command for naming it.
output.setSchedule(schedule, scheduletype) output.setDestination(destination) 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(
def msImageFileNameResolver(param, name): if param.automatic(): basename = os.path.basename(param.group['filename'].value) else: basename = name # Remove colons from the basename, the labeltree uses them as # separators, and it causes confusion if they're in the names. return ooflib.common.microstructure.microStructures.uniqueName( basename.replace(':', '.')) imageparams = parameter.ParameterGroup( filenameparam.ReadFileNameParameter('filename', tip="Name of the file."), parameter.AutomaticNameParameter( 'microstructure_name', msImageFileNameResolver, automatic.automatic, tip='Name of the new Microstructure.')) elif config.dimension() == 3: def createMSFromImageFile(menuitem, filenames, microstructure_name, height, width, depth=0): if ((height != automatic and height <= 0) or (width != automatic and width <= 0) or (depth != automatic and depth <= 0)):
else: 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.'), parameter.RegisteredParameter('reader', orientmapdata.OrientMapReader), 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] if param.automatic(): # The automatic name for an image created from orientation # data is the filename of the data, minus any directory path # or suffix that it might have. msobj = ooflib.common.microstructure.microStructures[msname].getObject()
for g in grouplist: switchboard.notify("new pixel group", g) micromenu.addItem( oofmenu.OOFMenuItem( 'Copy', callback=copyMicrostructure, params=[ parameter.StringParameter('microstructure', '', tip='The source microstructure.'), parameter.AutomaticNameParameter( 'name', resolver=msNameResolver, value=automatic.automatic, tip="Name of the new Microstructure.") ], help="Copy a Microstructure.", discussion="""<para>A copied µ has the same physical size and pixel size as the original µ, and includes <emphasis>copies</emphasis> of all &images; and <link linkend='Section-Concepts-Microstructure-Pixel_Group'>pixel groups</link> contained in the original. It does <emphasis>not</emphasis> include any &skels; or &meshes; from the original.</para>""")) #############################
if param.automatic(): basename = 'boundary' else: basename = startname 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