コード例 #1
0
ファイル: Case.py プロジェクト: hamdanih/OpenFOAM_test
 def sampleField(self, directory, line, field):
     return SamplePlot(args=[self.path],
                       directoryName=directory,
                       line=[line],
                       field=[field],
                       mode="separate",
                       pandasData=True)["dataFrame"]
コード例 #2
0
def setSampleData(tbl, lineName, dirName="sets"):
    """Read sample data and put it into a vtkTable

    Use in 'Programmable Filter'. Set output type to 'vtkTable'.
    To get (for instance) the data on line 'lineCenter' from the sampled data in
    the directory sets (it will automatically use the current time) in the
    source code write
from PyFoam.Paraview.Data import setSampleData
setSampleData(self.GetOutput(),"lineCenter",dirName="sets")
    """
    actualDir = checkDir(dirName)
    data = SamplePlot(args=[
        case().name, "--directory=" + actualDir, "--time=" +
        str(vTime()), "--line=" + lineName, "--fuzzy-time", "--numpy"
    ]).data

    nExp = re.compile(lineName + "_t=[^ ]+ (.+)")

    for n in data.dtype.names:
        m = nExp.match(n)
        vals = data[n]
        if m:
            n = m.group(1)
        col = vtk.vtkDoubleArray()
        col.SetName(n)
        for v in vals:
            col.InsertNextValue(v)
        tbl.AddColumn(col)

    return tbl
コード例 #3
0
ファイル: Case.py プロジェクト: hamdanih/OpenFOAM_test
 def sampleTime(self, directory, line, time):
     return SamplePlot(args=[self.path],
                       directoryName=directory,
                       line=[line],
                       time=[time],
                       fuzzyTime=True,
                       mode="separate",
                       pandasData=True)["dataFrame"]
コード例 #4
0
    def compareSamples(self,
                       data,
                       reference,
                       fields,
                       time=None,
                       line=None,
                       scaleData=1,
                       offsetData=0,
                       scaleX=1,
                       offsetX=0,
                       useReferenceForComparison=False):
        """Compare sample data and return the statistics
        @param data: the name of the data directory
        @param reference:the name of the directory with the reference data
        @param fields: list of the fields to compare
        @param time: the time to compare for. If empty the latest time is used"""
        timeOpt=["--latest-time"]
        if time:
            timeOpt=["--time="+str(time)]
        if line:
            timeOpt+=["--line=%s" % line]
        addOpt=[]
        if useReferenceForComparison:
            addOpt.append("--use-reference-for-comparison")

        sample=SamplePlot(args=[self.caseDir,
                                "--silent",
                                "--dir="+data,
                                "--reference-dir="+reference,
                                "--tolerant-reference-time",
                                "--compare",
                                "--index-tolerant-compare",
                                "--common-range-compare",
                                "--metrics",
                                "--scale-data=%f" % scaleData,
                                "--scale-x=%f" % scaleX,
                                "--offset-data=%f" % offsetData,
                                "--offset-x=%f" % offsetX
                            ]+
                          timeOpt+
                          addOpt+
                          ["--field="+f for f in fields])
        return Data2DStatistics(metrics=sample["metrics"],
                                compare=sample["compare"],
                                noStrings=True,
                                failureValue=0)
コード例 #5
0
 def postRunTestVelocityProfilesOldSchool(self):
     # Just as an example how to do it detailed
     sample = SamplePlot(args=[
         self.caseDir, "--silent", "--dir=sets",
         "--reference-dir=referenceSet", "--latest-time",
         "--tolerant-reference-time", "--field=U", "--compare", "--metrics"
     ])
     stat = Data2DStatistics(metrics=sample["metrics"],
                             compare=sample["compare"],
                             noStrings=True)
     relError = stat.relativeError()
     for l in relError.columns():
         for com in relError.rows():
             self.isEqual(value=relError[(com, l)],
                          tolerance=self["velocityRelativeTolerance"],
                          message="Match velocty component %s on line %s" %
                          (com, l))
コード例 #6
0
ファイル: pyFoamSamplePlot.py プロジェクト: minhbau/PyFoam
#! /usr/bin/env python

from PyFoam.Applications.SamplePlot import SamplePlot

SamplePlot()
コード例 #7
0
ファイル: Case.py プロジェクト: hamdanih/OpenFOAM_test
 def distributionInfo(self, directory):
     return SamplePlot(args=[self.path],
                       directoryName=directory,
                       isDistribution=True,
                       info=True,
                       silent=True).getData()
コード例 #8
0
ファイル: Case.py プロジェクト: hamdanih/OpenFOAM_test
 def sampleInfo(self, directory):
     return SamplePlot(args=[self.path],
                       directoryName=directory,
                       info=True,
                       silent=True).getData()