def _loadDiscussion(menuitem): reg = menuitem.data if reg: name = reg.name() return """ <para> Create an instance of the material &property; <classname>%s</classname>. This command is only used in data files. Data files containing &properties; are created by the <link linkend='MenuItem-OOF.File.Save.Materials'><command>Materials</command></link>, <link linkend='MenuItem-OOF.File.Save.Microstructure'><command>Microstructure</command></link>, <link linkend='MenuItem-OOF.File.Save.Skeleton'><command>Skeleton</command></link> and <link linkend='MenuItem-OOF.File.Save.Mesh'><command>Mesh</command></link> commands in the <xref linkend='MenuItem-OOF.File.Save'/> menu. </para> <para> The <varname>name</varname> argument should be set to the name of a named &property; or to an empty string (<userinput>''</userinput>) when setting parameters in an unnamed &property;. </para> <para> See <xref linkend="Property-%s"/> for a complete description of the parameters for this &property;. </para> """ % (reg.name(), reg.name().replace(':', '-')) return intro + xmlmenudump.getDiscussion(reg) # No discussion section for intermediate nodes in the Property # tree, except for the root. if reg.path() == 'OOF.LoadData.Property': return """<para> The <command>OOF.LoadData.Property</command> menu contains an entry for each <emphasis>unnamed</emphasis> &property;. The menu hierarchy echoes the hierarchical arrangement of the &properties; themselves. The commands are used only in data files, where each command sets the parameters of a &property;. Unlike the <xref linkend='MenuItem-OOF.Property.Parametrize'/> menu, which is also based on the &property; hierarchy, the <command>OOF.LoadData.Property</command> menu does not include named properties. Instead, each command has a <varname>name</varname> argument, which is set to an empty string (<userinput>''</userinput>) when assigning parameters to unnamed &properties;.</para>""" return ""
def _loadDiscussion(menuitem): reg = menuitem.data if reg: name = reg.name() return """ <para> Create an instance of the material &property; <classname>%s</classname>. This command is only used in data files. Data files containing &properties; are created by the <link linkend='MenuItem-OOF.File.Save.Materials'><command>Materials</command></link>, <link linkend='MenuItem-OOF.File.Save.Microstructure'><command>Microstructure</command></link>, <link linkend='MenuItem-OOF.File.Save.Skeleton'><command>Skeleton</command></link> and <link linkend='MenuItem-OOF.File.Save.Mesh'><command>Mesh</command></link> commands in the <xref linkend='MenuItem-OOF.File.Save'/> menu. </para> <para> The <varname>name</varname> argument should be set to the name of a named &property; or to an empty string (<userinput>''</userinput>) when setting parameters in an unnamed &property;. </para> <para> See <xref linkend="Property-%s"/> for a complete description of the parameters for this &property;. </para> """ % (reg.name(), reg.name().replace(':','-')) return intro + xmlmenudump.getDiscussion(reg) # No discussion section for intermediate nodes in the Property # tree, except for the root. if reg.path() == 'OOF.LoadData.Property': return """<para> The <command>OOF.LoadData.Property</command> menu contains an entry for each <emphasis>unnamed</emphasis> &property;. The menu hierarchy echoes the hierarchical arrangement of the &properties; themselves. The commands are used only in data files, where each command sets the parameters of a &property;. Unlike the <xref linkend='MenuItem-OOF.Property.Parametrize'/> menu, which is also based on the &property; hierarchy, the <command>OOF.LoadData.Property</command> menu does not include named properties. Instead, each command has a <varname>name</varname> argument, which is set to an empty string (<userinput>''</userinput>) when assigning parameters to unnamed &properties;.</para>""" return ""
def xmldocs(phile): # Called by xmldump in problem.py. # First, do some bookkeeping ptypedict = {} # lists of Properties of each PropertyType. propdict = {} # lists of Properties for each equation, field, or flux for reg in AllProperties.data.getObjects(): if reg.secret(): continue ptype = reg.propertyType() try: ptypedict[ptype].append(reg) except KeyError: ptypedict[ptype] = [reg] # propdict is returned to problem.xmldump so that equations # and fluxes can list their relevant properties. for eqn in reg.equations(): try: propdict[eqn].append(reg) except KeyError: propdict[eqn] = [reg] for flux in reg.fluxes(): try: propdict[flux].append(reg) except KeyError: propdict[flux] = [reg] for field in reg.fields(): try: propdict[field].append(reg) except KeyError: propdict[field] = [reg] print >> phile, "<section id='Section-Properties'>" print >> phile, "<title>Material Properties</title>" print >> phile, """ <para> This is a listing of &properties; by category. Each &material; may have at most one &property; from each category. Follow the links for more detail about each &property;, including which &fields; it requires and which &fluxes; and/or &equations; it contributes to. </para>""" print >> phile, "<itemizedlist>" ptypes = ptypedict.keys() ptypes.sort() for ptype in ptypes: print >> phile, '<listitem id="PropertyType-%s">' % ptype print >> phile, '<para>', ptype print >> phile, '<itemizedlist>' for reg in ptypedict[ptype]: print >> phile, '<listitem><simpara><link linkend="Property-%s">%s</link></simpara></listitem>' % ( reg.name().replace(':', '-'), reg.name()) print >> phile, '</itemizedlist>' print >> phile, '</para>' print >> phile, '</listitem>' print >> phile, '</itemizedlist>' # Create a refentry page for each Property for reg in AllProperties.data.getObjects(): if reg.secret(): continue name = reg.name() idname = name.replace(':', '-') ptype = reg.propertyType() xmlmenudump.xmlIndexEntry(name, ptype + " Property", "Property-" + idname) print >> phile, '<refentry xreflabel="%s" id="Property-%s" role="Property">' \ % (name, idname) print >> phile, '<refnamediv>' print >> phile, '<refname>%s</refname>' % name if reg.tip is not parameter.emptyTipString: tip = reg.tip or "MISSING PROPERTY TIP STRING for %s" % name else: tip = "" print >> phile, '<refpurpose>%s</refpurpose>' % tip print >> phile, '</refnamediv>' print >> phile, '<refsect1>' print >> phile, '<title>Details</title>' print >> phile, '<itemizedlist>' # Category print >> phile, '<listitem><simpara>' print >> phile, 'Property Category: <link linkend="PropertyType-%(t)s">%(t)s</link>' % dict( t=ptype) print >> phile, '</simpara></listitem>' # Parameters print >> phile, '<listitem>' print >> phile, '<para>Parameters:' print >> phile, '<variablelist>' for param in reg.params: print >> phile, '<varlistentry>' print >> phile, '<term><varname>%s</varname></term>' % param.name print >> phile, '<listitem>' if param.tip is not parameter.emptyTipString: tip = param.tip or "MISSING PROPERTY PARAMETER TIP for %s" % name else: tip = "" print >> phile, '<simpara>%s <emphasis>Type</emphasis>: %s </simpara>'\ % (tip, param.valueDesc()) print >> phile, '</listitem>' print >> phile, '</varlistentry>' print >> phile, '</variablelist>' print >> phile, '</para></listitem> <!-- Parameters -->' for classname, plural, objlist in [('Field', 'Fields', reg.fields()), ('Flux', 'Fluxes', reg.fluxes()), ('Equation', 'Equations', reg.equations())]: if objlist: print >> phile, '<listitem><simpara>' text = [ "<link linkend='%s-%s'><varname>%s</varname></link>" % (classname, obj.name(), obj.name()) for obj in objlist ] print >> phile, "%s: %s" % (plural, ", ".join(text)) print >> phile, '</simpara></listitem>' print >> phile, '</itemizedlist>' print >> phile, '</refsect1> <!-- Details -->' print >> phile, '<refsect1>' print >> phile, '<title>Discussion</title>' try: print >> phile, xmlmenudump.getDiscussion(reg) except AttributeError: print >> phile, "<para>MISSING PROPERTY DISCUSSION: %s</para>" % name print >> phile, '</refsect1> <!-- Discussion -->' print >> phile, '</refentry>' print >> phile, "</section> <!-- Properties -->" return propdict
def outputDump(file): scalars = output.scalarOutputs.getObjects() positions = output.positionOutputs.getObjects() aggregates = output.aggregateOutputs.getObjects() allOutputs = scalars + positions + aggregates # # allOutputs contains duplicates... # allOutputs.sort(lambda x, y: cmp(x.getPath(), y.getPath())) xmlids = {} _catalogPaths(scalars, xmlids, 'Output-Scalar-') _catalogPaths(positions, xmlids, 'Output-Position-') _catalogPaths(aggregates, xmlids, 'Output-Aggregates-') print >> file, "<section id='Section-Output'>" print >> file, " <title>Outputs</title>" print >> file, "<!--this section produced by SRC/engine/IO/xmloutputs.py-->" print >> file, """ <para> The <classname>Output</classname> classes provide ways of extracting data from <link linkend='Section-Concepts-Mesh'>Meshes</link>. Different kinds of <classname>Outputs</classname> produce different kinds of data. <link linkend='RegisteredClass-FilledContourDisplay'>Contour plots</link>, for example, display the results of a <link linkend='Section-Output-Scalar'>Scalar Output</link> at locations determined by a <link linkend='Section-Output-Position'>Position Output</link>. </para> <para> <classname>Outputs</classname> are used for graphical output by some <xref linkend="RegisteredClass-DisplayMethod"/> classes, for post-processing on the <link linkend="Section-Tasks-Analysis">Analysis</link> and <link linkend="Section-Tasks-BdyAnalysis">Boundary Analysis</link> pages, and as data for <link linkend="MenuItem-OOF.Mesh.Scheduled_Output">scheduled outputs</link>. </para> <para> The three categories of outputs are <itemizedlist> <listitem><para id='Section-Output-Scalar'> <classname>ScalarOutputs</classname>: These are Outputs whose result is a single number at each evaluation point. They are used as the <varname>what</varname> argument in the contour plotting commands, for example. <itemizedlist spacing='compact'> """ paths = [(o.getPath(), o) for o in scalars] paths.sort() for path, o in paths: xmlmenudump.xmlIndexEntry(path, "Scalar Output", xmlids[o]) print >> file, " <listitem><simpara><link linkend='%s'>" % xmlids[o] print >> file, " <classname>%s</classname>" % path print >> file, " </link></simpara></listitem>" print >> file, """ </itemizedlist> </para></listitem> <listitem><para id='Section-Output-Position'> <classname>PositionOutputs</classname>: These are Outputs whose result is a position. They are used as the <varname>where</varname> argument in plotting commands. <itemizedlist spacing='compact'>""" paths = [(o.getPath(), o) for o in positions] paths.sort() for path, o in paths: xmlmenudump.xmlIndexEntry(path, "Position Output", xmlids[o]) print >> file, " <listitem><simpara><link linkend='%s'>" % xmlids[o] print >> file, " <classname>%s</classname>" % path print >> file, " </link></simpara></listitem>" print >> file, """ </itemizedlist> </para></listitem> <listitem><para id='Section-Output-Aggregate'> <classname>AggregateOutputs</classname>: These are Outputs whose result is a (possibly) multidimensional object, such as a &field; or &flux;. They are used when interactively querying &mesh; data with the <link linkend='Section-Graphics-MeshInfo-DataViewer'>Data Viewer</link>. Many of the <link linkend='Section-Output-Scalar'><classname>ScalarOutputs</classname></link> are also <classname>AggregateOutputs</classname>. <itemizedlist spacing='compact'> """ paths = [(o.getPath(), o) for o in aggregates] paths.sort() for path, o in paths: xmlmenudump.xmlIndexEntry(path, "Aggregate Output", xmlids[o]) print >> file, "<listitem><simpara><link linkend='%s'>" % xmlids[o] print >> file, " <classname>%s</classname>" % path print >> file, " </link></simpara></listitem>" print >> file, """ </itemizedlist> </para></listitem> </itemizedlist> </para> """ # for i in range(len(allOutputs)): # if i==0 or (allOutputs[i] is not allOutputs[i-1]): # o = allOutputs[i] for o, xmlid in xmlids.items(): path = o.getPath() # xmlid = xmlids[path] print >> file, "<refentry id='%s' role='Output'>" % xmlid print >> file, " <refnamediv>" print >> file, " <refname>%s</refname>" % path try: print >> file, " <refpurpose>%s</refpurpose>" % xmlmenudump.getHelp( o) except AttributeError: print >> file, " <refpurpose>MISSING TIP STRING: %s</refpurpose>" % xmlid print >> file, " </refnamediv>" print >> file, " <refsynopsisdiv>" print >> file, " <title>Output Categories</title>" print >> file, " <itemizedlist spacing='compact'>" if o in scalars: print >> file, "<listitem><simpara><link linkend='Section-Output-Scalar'><classname>ScalarOutput</classname></link></simpara></listitem>" if o in positions: print >> file, "<listitem><simpara><link linkend='Section-Output-Position'><classname>PositionOutput</classname></link></simpara></listitem>" if o in aggregates: print >> file, "<listitem><simpara><link linkend='Section-Output-Aggregate'><classname>AggregateOutput</classname></link></simpara></listitem>" print >> file, " </itemizedlist>" print >> file, " </refsynopsisdiv>" params = o.getSettableParams().values() if params: print >> file, " <refsect1>" print >> file, " <title>Parameters</title>" print >> file, " <variablelist>" for param in params: xmlmenudump.process_param(param) print >> file, " <varlistentry>" print >> file, " <term><varname>%s</varname></term>" \ % param.name print >> file, " <listitem>" try: tip = xmlmenudump.getHelp(param) except AttributeError: tip = "MISSING TIP STRING: %s" % param.name print >> file, " <simpara>%s <emphasis>Type</emphasis>: %s</simpara>" \ % (tip, param.valueDesc()) print >> file, " </listitem>" print >> file, " </varlistentry>" print >> file, " </variablelist>" print >> file, " </refsect1>" print >> file, " <refsect1>" print >> file, " <title>Description</title>" try: print >> file, xmlmenudump.getDiscussion(o) except AttributeError: print >> file, \ "<simpara>MISSING DISCUSSION: Output %s</simpara>" % path print >> file, " </refsect1>" print >> file, "</refentry>" print >> file, "</section>" # End of Outputs
def xmldocs(phile): # Called by xmldump in problem.py. # First, do some bookkeeping ptypedict = {} # lists of Properties of each PropertyType. propdict = {} # lists of Properties for each equation, field, or flux for reg in AllProperties.data.getObjects(): if reg.secret(): continue ptype = reg.propertyType() try: ptypedict[ptype].append(reg) except KeyError: ptypedict[ptype] = [reg] # propdict is returned to problem.xmldump so that equations # and fluxes can list their relevant properties. for eqn in reg.equations(): try: propdict[eqn].append(reg) except KeyError: propdict[eqn] = [reg] for flux in reg.fluxes(): try: propdict[flux].append(reg) except KeyError: propdict[flux] = [reg] for field in reg.fields(): try: propdict[field].append(reg) except KeyError: propdict[field] = [reg] print >> phile, "<section id='Section-Properties'>" print >> phile, "<title>Material Properties</title>" print >> phile, """ <para> This is a listing of &properties; by category. Each &material; may have at most one &property; from each category. Follow the links for more detail about each &property;, including which &fields; it requires and which &fluxes; and/or &equations; it contributes to. </para>""" print >> phile, "<itemizedlist>" ptypes = ptypedict.keys() ptypes.sort() for ptype in ptypes: print >> phile, '<listitem id="PropertyType-%s">' % ptype print >> phile, '<para>', ptype print >> phile, '<itemizedlist>' for reg in ptypedict[ptype]: print >> phile, '<listitem><simpara><link linkend="Property-%s">%s</link></simpara></listitem>' % (reg.name().replace(':', '-'), reg.name()) print >> phile, '</itemizedlist>' print >> phile, '</para>' print >> phile, '</listitem>' print >> phile, '</itemizedlist>' # Create a refentry page for each Property for reg in AllProperties.data.getObjects(): if reg.secret(): continue name = reg.name() idname = name.replace(':', '-') ptype = reg.propertyType() xmlmenudump.xmlIndexEntry(name, ptype+" Property", "Property-"+idname) print >> phile, '<refentry xreflabel="%s" id="Property-%s" role="Property">' \ % (name, idname) print >> phile, '<refnamediv>' print >> phile, '<refname>%s</refname>' % name if reg.tip is not parameter.emptyTipString: tip = reg.tip or "MISSING PROPERTY TIP STRING for %s" % name else: tip = "" print >> phile, '<refpurpose>%s</refpurpose>' % tip print >> phile, '</refnamediv>' print >> phile, '<refsect1>' print >> phile, '<title>Details</title>' print >> phile, '<itemizedlist>' # Category print >> phile, '<listitem><simpara>' print >> phile, 'Property Category: <link linkend="PropertyType-%(t)s">%(t)s</link>' % dict(t=ptype) print >> phile, '</simpara></listitem>' # Parameters print >> phile, '<listitem>' print >> phile, '<para>Parameters:' print >> phile, '<variablelist>' for param in reg.params: print >> phile, '<varlistentry>' print >> phile, '<term><varname>%s</varname></term>' % param.name print >> phile, '<listitem>' if param.tip is not parameter.emptyTipString: tip = param.tip or "MISSING PROPERTY PARAMETER TIP for %s"%name else: tip = "" print >> phile, '<simpara>%s <emphasis>Type</emphasis>: %s </simpara>'\ % (tip, param.valueDesc()) print >> phile, '</listitem>' print >> phile, '</varlistentry>' print >> phile, '</variablelist>' print >> phile, '</para></listitem> <!-- Parameters -->' for classname, plural, objlist in [('Field', 'Fields', reg.fields()), ('Flux', 'Fluxes', reg.fluxes()), ('Equation', 'Equations', reg.equations())]: if objlist: print >> phile, '<listitem><simpara>' text = ["<link linkend='%s-%s'><varname>%s</varname></link>" % (classname, obj.name(), obj.name()) for obj in objlist] print >> phile, "%s: %s" % (plural, ", ".join(text)) print >> phile, '</simpara></listitem>' print >> phile, '</itemizedlist>' print >> phile, '</refsect1> <!-- Details -->' print >> phile, '<refsect1>' print >> phile, '<title>Discussion</title>' try: print >> phile, xmlmenudump.getDiscussion(reg) except AttributeError: print >> phile, "<para>MISSING PROPERTY DISCUSSION: %s</para>" % name print >> phile, '</refsect1> <!-- Discussion -->' print >> phile, '</refentry>' print >> phile, "</section> <!-- Properties -->" return propdict
def outputDump(file): scalars = output.scalarOutputs.getObjects() positions = output.positionOutputs.getObjects() aggregates = output.aggregateOutputs.getObjects() allOutputs = scalars + positions + aggregates # # allOutputs contains duplicates... # allOutputs.sort(lambda x, y: cmp(x.getPath(), y.getPath())) xmlids = {} _catalogPaths(scalars, xmlids, 'Output-Scalar-') _catalogPaths(positions, xmlids, 'Output-Position-') _catalogPaths(aggregates, xmlids, 'Output-Aggregates-') print >> file, "<section id='Section-Output'>" print >> file, " <title>Outputs</title>" print >> file, "<!--this section produced by SRC/engine/IO/xmloutputs.py-->" print >> file, """ <para> The <classname>Output</classname> classes provide ways of extracting data from <link linkend='Section-Concepts-Mesh'>Meshes</link>. Different kinds of <classname>Outputs</classname> produce different kinds of data. <link linkend='RegisteredClass-FilledContourDisplay'>Contour plots</link>, for example, display the results of a <link linkend='Section-Output-Scalar'>Scalar Output</link> at locations determined by a <link linkend='Section-Output-Position'>Position Output</link>. </para> <para> <classname>Outputs</classname> are used for graphical output by some <xref linkend="RegisteredClass-DisplayMethod"/> classes, for post-processing on the <link linkend="Section-Tasks-Analysis">Analysis</link> and <link linkend="Section-Tasks-BdyAnalysis">Boundary Analysis</link> pages, and as data for <link linkend="MenuItem-OOF.Mesh.Scheduled_Output">scheduled outputs</link>. </para> <para> The three categories of outputs are <itemizedlist> <listitem><para id='Section-Output-Scalar'> <classname>ScalarOutputs</classname>: These are Outputs whose result is a single number at each evaluation point. They are used as the <varname>what</varname> argument in the contour plotting commands, for example. <itemizedlist spacing='compact'> """ paths = [(o.getPath(),o) for o in scalars] paths.sort() for path,o in paths: xmlmenudump.xmlIndexEntry(path, "Scalar Output", xmlids[o]) print >> file, " <listitem><simpara><link linkend='%s'>" % xmlids[o] print >> file, " <classname>%s</classname>" % path print >> file, " </link></simpara></listitem>" print >> file, """ </itemizedlist> </para></listitem> <listitem><para id='Section-Output-Position'> <classname>PositionOutputs</classname>: These are Outputs whose result is a position. They are used as the <varname>where</varname> argument in plotting commands. <itemizedlist spacing='compact'>""" paths = [(o.getPath(),o) for o in positions] paths.sort() for path,o in paths: xmlmenudump.xmlIndexEntry(path, "Position Output", xmlids[o]) print >> file, " <listitem><simpara><link linkend='%s'>" % xmlids[o] print >> file, " <classname>%s</classname>" % path print >> file, " </link></simpara></listitem>" print >> file, """ </itemizedlist> </para></listitem> <listitem><para id='Section-Output-Aggregate'> <classname>AggregateOutputs</classname>: These are Outputs whose result is a (possibly) multidimensional object, such as a &field; or &flux;. They are used when interactively querying &mesh; data with the <link linkend='Section-Graphics-MeshInfo-DataViewer'>Data Viewer</link>. Many of the <link linkend='Section-Output-Scalar'><classname>ScalarOutputs</classname></link> are also <classname>AggregateOutputs</classname>. <itemizedlist spacing='compact'> """ paths = [(o.getPath(),o) for o in aggregates] paths.sort() for path,o in paths: xmlmenudump.xmlIndexEntry(path, "Aggregate Output", xmlids[o]) print >> file, "<listitem><simpara><link linkend='%s'>" % xmlids[o] print >> file, " <classname>%s</classname>" % path print >> file, " </link></simpara></listitem>" print >> file, """ </itemizedlist> </para></listitem> </itemizedlist> </para> """ # for i in range(len(allOutputs)): # if i==0 or (allOutputs[i] is not allOutputs[i-1]): # o = allOutputs[i] for o,xmlid in xmlids.items(): path = o.getPath() # xmlid = xmlids[path] print >> file, "<refentry id='%s' role='Output'>" % xmlid print >> file, " <refnamediv>" print >> file, " <refname>%s</refname>" % path try: print >> file, " <refpurpose>%s</refpurpose>" % xmlmenudump.getHelp(o) except AttributeError: print >> file, " <refpurpose>MISSING TIP STRING: %s</refpurpose>" % xmlid print >> file, " </refnamediv>" print >> file, " <refsynopsisdiv>" print >> file, " <title>Output Categories</title>" print >> file, " <itemizedlist spacing='compact'>" if o in scalars: print >> file, "<listitem><simpara><link linkend='Section-Output-Scalar'><classname>ScalarOutput</classname></link></simpara></listitem>" if o in positions: print >> file, "<listitem><simpara><link linkend='Section-Output-Position'><classname>PositionOutput</classname></link></simpara></listitem>" if o in aggregates: print >> file, "<listitem><simpara><link linkend='Section-Output-Aggregate'><classname>AggregateOutput</classname></link></simpara></listitem>" print >> file, " </itemizedlist>" print >> file, " </refsynopsisdiv>" params = o.getSettableParams().values() if params: print >> file, " <refsect1>" print >> file, " <title>Parameters</title>" print >> file, " <variablelist>" for param in params: xmlmenudump.process_param(param) print >> file, " <varlistentry>" print >> file, " <term><varname>%s</varname></term>" \ % param.name print >> file, " <listitem>" try: tip = xmlmenudump.getHelp(param) except AttributeError: tip = "MISSING TIP STRING: %s" % param.name print >> file, " <simpara>%s <emphasis>Type</emphasis>: %s</simpara>" \ % (tip, param.valueDesc()) print >> file, " </listitem>" print >> file, " </varlistentry>" print >> file, " </variablelist>" print >> file, " </refsect1>" print >> file, " <refsect1>" print >> file, " <title>Description</title>" try: print >> file, xmlmenudump.getDiscussion(o) except AttributeError: print >> file, \ "<simpara>MISSING DISCUSSION: Output %s</simpara>" % path print >> file, " </refsect1>" print >> file, "</refentry>" print >> file, "</section>" # End of Outputs