예제 #1
0
    def readFromStgXML(self, inputFilesList, basePath):
        '''Read in the list of fields that have already been specified to
         be tested from a set of StGermain input files. Useful when e.g.
         working with an Analytic Solution plugin.'''
        self.fromXML = True

        # create a flattened file
        absInputFiles = stgpath.convertLocalXMLFilesToAbsPaths(
            inputFilesList, basePath)
        ffile = stgxml.createFlattenedXML(absInputFiles)
        xmlDoc = etree.parse(ffile)
        stgRoot = xmlDoc.getroot()

        # Go and grab necessary info from XML file
        componentEl = stgxml.getStructNode(stgRoot, self.stgXMLCompListName)
        fieldTestDataEl = stgxml.getStructNode(componentEl,
                                               self.stgXMLCompName)
        fieldTestListEl = stgxml.getListNode(fieldTestDataEl,
                                             self.stgXMLSpecFList)
        fieldTestStructEls = fieldTestListEl.getchildren()
        for fieldStruct in fieldTestStructEls:
            numericField = stgxml.getParamValue(fieldStruct, 'NumericField',
                                                str)
            self.fields[numericField] = FieldComparisonOp(numericField)

        # NB: not reading in all the other specifying stuff currently. Possibly
        # would be useful to do this in future.
        os.remove(ffile)
예제 #2
0
    def readFromStgXML(self, inputFilesList, basePath):
        '''Read in the list of fields that have already been specified to 
         be tested from a set of StGermain input files. Useful when e.g. 
         working with an Analytic Solution plugin.'''
        self.fromXML = True

        # create a flattened file
        absInputFiles = stgpath.convertLocalXMLFilesToAbsPaths(inputFilesList,
            basePath)
        ffile=stgxml.createFlattenedXML(absInputFiles)
        xmlDoc = etree.parse(ffile)
        stgRoot = xmlDoc.getroot()

        # Go and grab necessary info from XML file
        componentEl = stgxml.getStructNode(stgRoot, self.stgXMLCompListName)
        fieldTestDataEl = stgxml.getStructNode(componentEl, self.stgXMLCompName)
        fieldTestListEl = stgxml.getListNode(fieldTestDataEl, self.stgXMLSpecFList)
        fieldTestStructEls = fieldTestListEl.getchildren()
        for fieldStruct in fieldTestStructEls:
            numericField=stgxml.getParamValue(fieldStruct,'NumericField',str)
            self.fields[numericField]=FieldComparisonOp(numericField)

        # NB: not reading in all the other specifying stuff currently. Possibly
        # would be useful to do this in future.
        os.remove(ffile)
예제 #3
0
    def readFromStgXML(self, inputFilesList, basePath):
        '''Read in the list of fields that have already been specified to 
         be tested from a set of StGermain input files. Useful when e.g. 
         working with an Analytic Solution plugin.'''
        self.fromXML = True

        # create a flattened file
        absInputFiles = stgpath.convertLocalXMLFilesToAbsPaths(
            inputFilesList, basePath)
        ffile = stgxml.createFlattenedXML(absInputFiles)
        xmlDoc = etree.parse(ffile)
        stgRoot = xmlDoc.getroot()
        # Go and grab necessary info from XML file
        fieldTestDataEl = stgxml.getStructNode(stgRoot, self.stgXMLSpecName)
        fieldTestListEl = stgxml.getListNode(fieldTestDataEl,
                                             self.stgXMLSpecFList)

        fieldTestEls = fieldTestListEl.getchildren()
        # As per the current spec, the field names are followed by an index
        # of analytic solution
        ii = 0
        while ii < len(fieldTestEls):
            fieldName = fieldTestEls[ii].text
            self.fields[fieldName] = FieldComparisonOp(fieldName)
            # Skip the index
            ii += 1
            ii += 1
        # NB: not reading in all the other specifying stuff currently. Possibly
        # would be useful to do this in future.
        os.remove(ffile)
예제 #4
0
 def test_getStructNode(self):
     structNode = stgxml.getStructNode(self.flatXMLRoot, "velocityICs")
     self.assertEqual(structNode.attrib['name'], "velocityICs")
     self.assertEqual(structNode.text.strip(), "")
     self.assertEqual(len(structNode), 2)
     structNode = stgxml.getStructNode(self.inXMLRoot, "velocityICs")
     self.assertEqual(structNode.attrib['name'], "velocityICs")
     self.assertEqual(structNode.text.strip(), "")
     self.assertEqual(len(structNode), 2)
     structNode = stgxml.getStructNode(self.flatXMLRoot, "voodoo")
     self.assertEqual(structNode, None)
     # Test for the components struct, in both
     structNode = stgxml.getStructNode(self.inXMLRoot, "components")
     self.assertEqual(structNode.attrib['name'], "components")
     self.assertEqual(structNode.text.strip(), "")
     structNode = stgxml.getStructNode(self.flatXMLRoot, "components")
     self.assertEqual(structNode.tag, stgxml.addNsPrefix("components"))
     self.assertEqual(structNode.text.strip(), "")
 def test_getStructNode(self):
     structNode = stgxml.getStructNode(self.flatXMLRoot, "velocityICs")
     self.assertEqual(structNode.attrib['name'], "velocityICs")
     self.assertEqual(structNode.text.strip(), "")
     self.assertEqual(len(structNode), 2)
     structNode = stgxml.getStructNode(self.inXMLRoot, "velocityICs")
     self.assertEqual(structNode.attrib['name'], "velocityICs")
     self.assertEqual(structNode.text.strip(), "")
     self.assertEqual(len(structNode), 2)
     structNode = stgxml.getStructNode(self.flatXMLRoot, "voodoo")
     self.assertEqual(structNode, None)
     # Test for the components struct, in both
     structNode = stgxml.getStructNode(self.inXMLRoot, "components")
     self.assertEqual(structNode.attrib['name'], "components")
     self.assertEqual(structNode.text.strip(), "")
     structNode = stgxml.getStructNode(self.flatXMLRoot, "components")
     self.assertEqual(structNode.tag, stgxml.addNsPrefix("components"))
     self.assertEqual(structNode.text.strip(), "")
예제 #6
0
 def checkStgXMLResultsEnabled(self, inputFilesList, basePath):
     """Checks that the field comparison has the writing of comparison
     info to file enabled (returning Bool)."""
     absInputFiles = stgpath.convertLocalXMLFilesToAbsPaths(
         inputFilesList, basePath)
     ffile = stgxml.createFlattenedXML(absInputFiles)
     xmlDoc = etree.parse(ffile)
     stgRoot = xmlDoc.getroot()
     fieldTestDataEl = stgxml.getStructNode(stgRoot, self.stgXMLSpecName)
     appendNode = stgxml.getParamNode(fieldTestDataEl,
                                      "appendToAnalysisFile")
     appendBool = stgxml.strToBool(appendNode.text)
     os.remove(ffile)
     return appendBool
예제 #7
0
 def checkStgXMLResultsEnabled(self, inputFilesList, basePath):
     """Checks that the field comparison has the writing of comparison
     info to file enabled (returning Bool)."""
     absInputFiles = stgpath.convertLocalXMLFilesToAbsPaths(inputFilesList,
         basePath)
     ffile=stgxml.createFlattenedXML(absInputFiles)
     xmlDoc = etree.parse(ffile)
     stgRoot = xmlDoc.getroot()
     fieldTestDataEl = stgxml.getStructNode(stgRoot, self.stgXMLSpecName)
     appendNode = stgxml.getParamNode(fieldTestDataEl,
         "appendToAnalysisFile")
     appendBool = stgxml.strToBool(appendNode.text)
     os.remove(ffile)
     return appendBool