예제 #1
0
파일: post.py 프로젝트: zCFD/zCFD-driver
def calc_force(surface_data, ignore_zone, half_model=False,
               filter=None, **kwargs):

    alpha = 0.0
    if 'alpha' in kwargs:
        alpha = kwargs['alpha']
    beta = 0.0
    if 'beta' in kwargs:
        beta = kwargs['beta']

    sum_client = servermanager.Fetch(surface_data)

    pforce = sum_and_zone_filter(sum_client, "pressureforce",
                                 ignore_zone, filter)
    fforce = sum_and_zone_filter(sum_client, "frictionforce",
                                 ignore_zone, filter)

    pforce = rotate_vector(pforce, alpha, beta)
    fforce = rotate_vector(fforce, alpha, beta)

    if half_model:
        for i in range(0, 3):
            pforce[i] *= 2.0
            fforce[i] *= 2.0

    del sum_client

    return pforce, fforce
예제 #2
0
파일: post.py 프로젝트: sherxman/zPost
def calc_force(surface_data, ignore_zone, half_model=False,
               filter=None, **kwargs):

    alpha = 0.0
    if 'alpha' in kwargs:
        alpha = kwargs['alpha']
    beta = 0.0
    if 'beta' in kwargs:
        beta = kwargs['beta']

    sum_client = servermanager.Fetch(surface_data)

    pforce = sum_and_zone_filter(sum_client, "pressureforce",
                                 ignore_zone, filter)
    fforce = sum_and_zone_filter(sum_client, "frictionforce",
                                 ignore_zone, filter)

    pforce = rotate_vector(pforce, alpha, beta)
    fforce = rotate_vector(fforce, alpha, beta)

    if half_model:
        for i in range(0, 3):
            pforce[i] *= 2.0
            fforce[i] *= 2.0

    return pforce, fforce
예제 #3
0
파일: post.py 프로젝트: zCFD/zCFD-driver
def calc_moment(surface_data, ignore_zone, half_model=False,
                filter=None, **kwargs):

    alpha = 0.0
    if 'alpha' in kwargs:
        alpha = kwargs['alpha']
    beta = 0.0
    if 'beta' in kwargs:
        beta = kwargs['beta']

    if 'ref_pt' in kwargs:
        sum_client = servermanager.Fetch(surface_data)
        if sum_client.GetCellData().GetArray("pressuremomentx"):
            pmoment = sum_and_zone_filter(
                sum_client, "pressuremomentx", ignore_zone, filter)
            fmoment = sum_and_zone_filter(
                sum_client, "frictionmomentx", ignore_zone, filter)

            pmoment = rotate_vector(pmoment, alpha, beta)
            fmoment = rotate_vector(fmoment, alpha, beta)
            #fforce = rotate_vector(fforce,alpha,beta)

            if half_model:
                # This is only valid for X-Z plane reflection
                pmoment[0] += -pmoment[0]
                pmoment[1] += pmoment[1]
                pmoment[2] += -pmoment[2]

                fmoment[0] += -fmoment[0]
                fmoment[1] += fmoment[1]
                fmoment[2] += -fmoment[2]

            return pmoment, fmoment

    else:
        sum_client = servermanager.Fetch(surface_data)
        pmoment = sum_and_zone_filter(
            sum_client, "pressuremoment", ignore_zone, filter)
        fmoment = sum_and_zone_filter(
            sum_client, "frictionmoment", ignore_zone, filter)

        pmoment = rotate_vector(pmoment, alpha, beta)
        fmoment = rotate_vector(fmoment, alpha, beta)
        #fforce = rotate_vector(fforce,alpha,beta)

        if half_model:
            # This is only valid for X-Z plane reflection
            pmoment[0] += -pmoment[0]
            pmoment[1] += pmoment[1]
            pmoment[2] += -pmoment[2]

            fmoment[0] += -fmoment[0]
            fmoment[1] += fmoment[1]
            fmoment[2] += -fmoment[2]

        return pmoment, fmoment
예제 #4
0
파일: post.py 프로젝트: sherxman/zPost
def cf_profile(surface, slice_normal, slice_origin, **kwargs):

    alpha = 0.0
    if 'alpha' in kwargs:
        alpha = kwargs['alpha']
    beta = 0.0
    if 'beta' in kwargs:
        beta = kwargs['beta']

    point_data = CellDatatoPointData(Input=surface)
    point_data.PassCellData = 1

    slice = Slice(Input=point_data, SliceType="Plane")

    slice.SliceType.Normal = slice_normal
    slice.SliceType.Origin = slice_origin

    slice.UpdatePipeline()

    offset = get_chord(slice)

    chord_calc = Calculator(Input=slice)

    chord_calc.AttributeMode = 'Point Data'
    chord_calc.Function = ('(coords.iHat - ' + str(offset[0]) + ')/' +
                           str(offset[1]-offset[0]))
    chord_calc.ResultArrayName = 'chord'

    cf_calc = Calculator(Input=chord_calc)

    cf_calc.AttributeMode = 'Point Data'
    cf_calc.Function = 'mag(cf)'
    cf_calc.ResultArrayName = 'cfmag'

    sum = MinMax(Input=slice)
    sum.Operation = "SUM"
    sum.UpdatePipeline()

    sum_client = servermanager.Fetch(sum)
    pforce = sum_client.GetCellData().GetArray("pressureforce").GetTuple(0)
    fforce = sum_client.GetCellData().GetArray("frictionforce").GetTuple(0)

    pforce = rotate_vector(pforce, alpha, beta)
    fforce = rotate_vector(fforce, alpha, beta)

    if 'func' in kwargs:
        sorted_line = PlotOnSortedLines(Input=cf_calc)
        sorted_line.UpdatePipeline()
        extract_client = servermanager.Fetch(sorted_line)
        for_each(extract_client, **kwargs)

    return {'pressure force': pforce,
            'friction force': fforce}
예제 #5
0
파일: post.py 프로젝트: zCFD/zCFD-driver
def cf_profile(surface, slice_normal, slice_origin, **kwargs):

    alpha = 0.0
    if 'alpha' in kwargs:
        alpha = kwargs['alpha']
    beta = 0.0
    if 'beta' in kwargs:
        beta = kwargs['beta']

    point_data = CellDatatoPointData(Input=surface)
    point_data.PassCellData = 1

    slice = Slice(Input=point_data, SliceType="Plane")

    slice.SliceType.Normal = slice_normal
    slice.SliceType.Origin = slice_origin

    slice.UpdatePipeline()

    offset = get_chord(slice)

    chord_calc = Calculator(Input=slice)

    chord_calc.AttributeMode = 'Point Data'
    chord_calc.Function = ('(coords.iHat - ' + str(offset[0]) + ')/' +
                           str(offset[1] - offset[0]))
    chord_calc.ResultArrayName = 'chord'

    cf_calc = Calculator(Input=chord_calc)

    cf_calc.AttributeMode = 'Point Data'
    cf_calc.Function = 'mag(cf)'
    cf_calc.ResultArrayName = 'cfmag'

    sum = MinMax(Input=slice)
    sum.Operation = "SUM"
    sum.UpdatePipeline()

    sum_client = servermanager.Fetch(sum)
    pforce = sum_client.GetCellData().GetArray("pressureforce").GetTuple(0)
    fforce = sum_client.GetCellData().GetArray("frictionforce").GetTuple(0)

    pforce = rotate_vector(pforce, alpha, beta)
    fforce = rotate_vector(fforce, alpha, beta)

    if 'func' in kwargs:
        sorted_line = PlotOnSortedLines(Input=cf_calc)
        sorted_line.UpdatePipeline()
        extract_client = servermanager.Fetch(sorted_line)
        for_each(extract_client, **kwargs)

    return {'pressure force': pforce,
            'friction force': fforce}
예제 #6
0
파일: post.py 프로젝트: zCFD/zutil
def cp_profile_span(surface, slice_normal, slice_origin, **kwargs):

    alpha = 0.0
    if "alpha" in kwargs:
        alpha = kwargs["alpha"]
    beta = 0.0
    if "beta" in kwargs:
        beta = kwargs["beta"]

    point_data = CellDatatoPointData(Input=surface)
    point_data.PassCellData = 1
    clip = Clip(Input=point_data, ClipType="Plane")
    clip.ClipType.Normal = [0.0, 1.0, 0.0]
    clip.ClipType.Origin = [0.0, 0.0, 0.0]
    clip.UpdatePipeline()

    slice = Slice(Input=clip, SliceType="Plane")

    slice.SliceType.Normal = slice_normal
    slice.SliceType.Origin = slice_origin

    slice.UpdatePipeline()

    offset = get_chord_spanwise(slice)
    # define the cuts and make sure the is the one one you want
    # make the
    chord_calc = Calculator(Input=slice)

    chord_calc.AttributeType = "Point Data"
    chord_calc.Function = (
        "(coords.jHat - " + str(offset[0]) + ")/" + str(offset[1] - offset[0])
    )
    chord_calc.ResultArrayName = "chord"

    sum = MinMax(Input=slice)
    sum.Operation = "SUM"
    sum.UpdatePipeline()

    sum_client = servermanager.Fetch(sum)
    pforce = sum_client.GetCellData().GetArray("pressureforce").GetTuple(0)
    fforce = sum_client.GetCellData().GetArray("frictionforce").GetTuple(0)

    pforce = rotate_vector(pforce, alpha, beta)
    fforce = rotate_vector(fforce, alpha, beta)

    if "func" in kwargs:
        sorted_line = PlotOnSortedLines(Input=chord_calc)
        sorted_line.UpdatePipeline()
        extract_client = servermanager.Fetch(sorted_line)
        for_each(extract_client, **kwargs)

    return {"pressure force": pforce, "friction force": fforce}
예제 #7
0
def calc_drag(file_root):

    wall = PVDReader(FileName=file_root + '_wall.pvd')

    CellDatatoPointData1 = CellDatatoPointData(Input=wall)
    CellDatatoPointData1.PassCellData = 1

    sum = MinMax(Input=CellDatatoPointData1)
    sum.Operation = "SUM"
    sum.UpdatePipeline()

    sum_client = servermanager.Fetch(sum)
    pforce = sum_client.GetCellData().GetArray("pressureforce").GetTuple(0)
    #fforce = sum_client.GetCellData().GetArray("frictionforce").GetTuple(0)
    #yplus = wall_slice_client.GetCellData().GetArray("yplus").GetValue(0)

    pforce = rotate_vector(pforce, alpha, beta)
    #fforce = rotate_vector(fforce,alpha,beta)

    return pforce
예제 #8
0
def my_transform(x, y, z):
    v = [x, y, z]
    v = zutil.rotate_vector(v, alpha, 0.0)
    return {"v1": v[0], "v2": v[1], "v3": v[2]}
예제 #9
0
def plot_cp_profile(label, colour, file_root):

    wall = PVDReader(FileName=file_root + '_WALL.pvd')

    CellDatatoPointData1 = CellDatatoPointData(Input=wall)
    CellDatatoPointData1.PassCellData = 1

    wall_slice = Slice(Input=CellDatatoPointData1, SliceType="Plane")

    wall_slice.SliceType.Normal = [0.0, 1.0, 0.0]
    wall_slice.SliceType.Origin = [0.0, -0.5, 0.0]

    wall_slice.UpdatePipeline()

    offset = get_chord(wall_slice)

    Calculator1 = Calculator(Input=wall_slice)

    Calculator1.AttributeMode = 'point_data'
    Calculator1.Function = '(coords.iHat - ' + \
        str(offset[0]) + ')/' + str(offset[1] - offset[0])
    Calculator1.ResultArrayName = 'chord'

    sum = MinMax(Input=wall_slice)
    sum.UpdatePipeline()
    sum.Operation = "SUM"

    sum_client = servermanager.Fetch(sum)
    pforce = sum_client.GetCellData().GetArray("pressureforce").GetTuple(0)
    fforce = sum_client.GetCellData().GetArray("frictionforce").GetTuple(0)
    #yplus = wall_slice_client.GetCellData().GetArray("yplus").GetValue(0)

    pforce = rotate_vector(pforce, alpha, beta)
    fforce = rotate_vector(fforce, alpha, beta)

    PlotOnSortedLines1 = PlotOnSortedLines(Input=Calculator1)
    PlotOnSortedLines1.UpdatePipeline()

    SetActiveSource(PlotOnSortedLines1)

    DataRepresentation3 = Show()
    DataRepresentation3.XArrayName = 'chord'
    #DataRepresentation3.CompositeDataSetIndex = 3
    DataRepresentation3.UseIndexForXAxis = 0
    DataRepresentation3.SeriesLabel = ['cp', label + ' Re=6m fully turbulent']
    DataRepresentation3.SeriesColor = ['cp', colour[0], colour[1], colour[2]]
    DataRepresentation3.SeriesVisibility = [
        'chord', '0', 'cp', '0', 'V (0)', '0', 'V (1)', '0', 'V (2)', '0',
        'V (Magnitude)', '0', 'p', '0', 'T', '0', 'rho', '0', 'mach', '0',
        'pressureforce (0)', '0', 'pressureforce (1)', '0',
        'pressureforce (2)', '0', 'pressureforce (Magnitude)', '0',
        'pressuremoment (0)', '0', 'pressuremoment (1)', '0',
        'pressuremoment (2)', '0', 'pressuremoment (Magnitude)', '0',
        'frictionforce (0)', '0', 'frictionforce (1)', '0',
        'frictionforce (2)', '0', 'frictionforce (Magnitude)', '0',
        'frictionmoment (0)', '0', 'frictionmoment (1)', '0',
        'frictionmoment (2)', '0', 'frictionmoment (Magnitude)', '0', 'eddy',
        '0', 'yplus', '0', 'var_6', '0', 'var_7', '0', 'arc_length', '0',
        'Points (0)', '0', 'Points (1)', '0', 'Points (2)', '0',
        'Points (Magnitude)', '0', 'vtkOriginalIndices', '0'
    ]
    DataRepresentation3.SeriesVisibility = ['cp', '1']

    #my_representation0 = GetDisplayProperties(PlotOnSortedLines1)
    #my_representation0.SeriesLabel = ['cp', label]
    #my_representation0.SeriesColor = ['cp', colour[0], colour[1], colour[2]]
    #my_representation0.SeriesVisibility = ['cp', '0', 'V (0)', '0', 'V (1)', '0', 'V (2)', '0', 'V (Magnitude)', '0', 'p', '0', 'T', '0', 'rho', '0', 'mach', '0', 'pressureforce (0)', '0', 'pressureforce (1)', '0', 'pressureforce (2)', '0', 'pressureforce (Magnitude)', '0', 'pressuremoment (0)', '0', 'pressuremoment (1)', '0', 'pressuremoment (2)', '0', 'pressuremoment (Magnitude)', '0', 'frictionforce (0)', '0', 'frictionforce (1)', '0', 'frictionforce (2)', '0', 'frictionforce (Magnitude)', '0', 'frictionmoment (0)', '0', 'frictionmoment (1)', '0', 'frictionmoment (2)', '0', 'frictionmoment (Magnitude)', '0', 'eddy', '0', 'yplus', '0', 'var_6', '0', 'var_7', '0', 'arc_length', '0', 'Points (0)', '0', 'Points (1)', '0', 'Points (2)', '0', 'Points (Magnitude)', '0', 'vtkOriginalIndices', '0']
    #i = 0
    # for s in my_representation0.GetProperty('SeriesVisibilityInfo'):
    #    if i%2 == 0:
    #        my_representation0.SeriesVisibility = [ s, '0' ]
    #        print s
    #    i+=1
    #my_representation0.SeriesVisibility = ['cp', '1']

    # my_representation0.UpdatePipeline()

    my_view0 = GetRenderView()
    my_view0.ChartTitle = 'NACA0012 alpha=' + \
        ('%.1f ' % alpha) + ('Cd=%.4f Cl=%.4f' %
                             (pforce[0] + fforce[0], pforce[2] + fforce[2]))
    my_view0.ChartTitleFont = ['Arial', '24', '1', '0']
    my_view0.AxisTitle = ['cp', 'x/c', '', '']
    my_view0.AxisBehavior = [0, 1, 0, 0]
    my_view0.AxisRange = [2.0, -6.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0]
예제 #10
0
파일: post.py 프로젝트: sherxman/zPost
def cp_profile(surface, slice_normal, slice_origin, **kwargs):

    alpha = 0.0
    if 'alpha' in kwargs:
        alpha = kwargs['alpha']
    beta = 0.0
    if 'beta' in kwargs:
        beta = kwargs['beta']

    time_average = False
    if 'time_average' in kwargs:
        time_average = kwargs['time_average']

    rotate_geometry = [0.0, 0.0, 0.0]
    if 'rotate_geometry' in kwargs:
        rotate_geometry = kwargs['rotate_geometry']

    point_data = CellDatatoPointData(Input=surface)
    point_data.PassCellData = 1

    slice = Slice(Input=point_data, SliceType="Plane")

    slice.SliceType.Normal = slice_normal
    slice.SliceType.Origin = slice_origin

    slice.UpdatePipeline()

    if time_average:
        temporal = TemporalStatistics(Input=slice)
        temporal.ComputeMaximum = 0
        temporal.ComputeStandardDeviation = 0
        temporal.ComputeMinimum = 0
        temporal.UpdatePipeline()
        slice = temporal

    offset = get_chord(slice, rotate_geometry)

    transform = Transform(Input=slice, Transform="Transform")
    transform.Transform.Scale = [1.0, 1.0, 1.0]
    transform.Transform.Translate = [0.0, 0.0, 0.0]
    transform.Transform.Rotate = rotate_geometry
    transform.UpdatePipeline()

    chord_calc = Calculator(Input=transform)
    chord_calc.AttributeMode = 'Point Data'
    chord_calc.Function = ('(coords.iHat - ' + str(offset[0]) + ')/' +
                           str(offset[1]-offset[0]))
    chord_calc.ResultArrayName = 'chord'

    # Attempt to calculate forces
    pforce = [0.0, 0.0, 0.0]
    fforce = [0.0, 0.0, 0.0]

    sum = MinMax(Input=slice)
    sum.Operation = "SUM"
    sum.UpdatePipeline()

    sum_client = servermanager.Fetch(sum)
    if (sum_client.GetCellData().GetArray("pressureforce") and
            sum_client.GetCellData().GetArray("frictionforce")):

        pforce = sum_client.GetCellData().GetArray("pressureforce").GetTuple(0)
        fforce = sum_client.GetCellData().GetArray("frictionforce").GetTuple(0)

        pforce = rotate_vector(pforce, alpha, beta)
        fforce = rotate_vector(fforce, alpha, beta)
        """
        # Add sectional force integration
        sorted_line = PlotOnSortedLines(Input=chord_calc)
        sorted_line.UpdatePipeline()
        sorted_line = servermanager.Fetch(sorted_line)
        cp_array = sorted_line.GetCellData().GetArray("cp")

        for i in range(0,len(cp_array)):
            sorted_line.GetPointData().GetArray("X")
            pass
        """

    if 'func' in kwargs:
        sorted_line = PlotOnSortedLines(Input=chord_calc)
        sorted_line.UpdatePipeline()
        extract_client = servermanager.Fetch(sorted_line)
        for_each(extract_client, **kwargs)

    return {'pressure force': pforce,
            'friction force': fforce}
예제 #11
0
파일: post.py 프로젝트: zCFD/zCFD-driver
def cp_profile(surface, slice_normal, slice_origin, **kwargs):

    alpha = 0.0
    if 'alpha' in kwargs:
        alpha = kwargs['alpha']
    beta = 0.0
    if 'beta' in kwargs:
        beta = kwargs['beta']

    time_average = False
    if 'time_average' in kwargs:
        time_average = kwargs['time_average']

    rotate_geometry = [0.0, 0.0, 0.0]
    if 'rotate_geometry' in kwargs:
        rotate_geometry = kwargs['rotate_geometry']

    clean = CleantoGrid(Input=surface)
    clean.UpdatePipeline()

    point_data = CellDatatoPointData(Input=clean)
    point_data.PassCellData = 1
    Delete(clean)
    del clean

    if 'filter' in kwargs:
        filter_zones = kwargs['filter']
        calc_str = ''.join('(zone={:d})|'.format(i) for i in filter_zones)
        filter_data = Calculator(Input=point_data)
        filter_data.AttributeMode = 'Cell Data'
        filter_data.Function = ('if (' + calc_str[:-1] + ', 1, 0)')
        filter_data.ResultArrayName = 'zonefilter'
        filter_data.UpdatePipeline()
        Delete(point_data)
        del point_data
        point_data = Threshold(Input=filter_data)
        point_data.Scalars = ['CELLS', 'zonefilter']
        point_data.ThresholdRange = [1.0, 1.0]
        point_data.UpdatePipeline()
        Delete(filter_data)
        del filter_data

    slice = Slice(Input=point_data, SliceType="Plane")

    slice.SliceType.Normal = slice_normal
    slice.SliceType.Origin = slice_origin

    slice.UpdatePipeline()
    Delete(point_data)
    del point_data

    if time_average:
        temporal = TemporalStatistics(Input=slice)
        temporal.ComputeMaximum = 0
        temporal.ComputeStandardDeviation = 0
        temporal.ComputeMinimum = 0
        temporal.UpdatePipeline()
        Delete(slice)
        del slice
        slice = temporal

    offset = get_chord(slice, rotate_geometry)

    transform = Transform(Input=slice, Transform="Transform")
    transform.Transform.Scale = [1.0, 1.0, 1.0]
    transform.Transform.Translate = [0.0, 0.0, 0.0]
    transform.Transform.Rotate = rotate_geometry
    transform.UpdatePipeline()

    if 'chord_func' in kwargs:
        pass
    else:
        chord_calc = Calculator(Input=transform)
        chord_calc.AttributeMode = 'Point Data'
        chord_calc.Function = ('(coords.iHat - ' + str(offset[0]) + ')/' +
                               str(offset[1] - offset[0]))
        chord_calc.ResultArrayName = 'chord'

    # Attempt to calculate forces
    pforce = [0.0, 0.0, 0.0]
    fforce = [0.0, 0.0, 0.0]
    pmoment = [0.0, 0.0, 0.0]
    fmoment = [0.0, 0.0, 0.0]
    pmomentx = [0.0, 0.0, 0.0]
    fmomentx = [0.0, 0.0, 0.0]
    pmomenty = [0.0, 0.0, 0.0]
    fmomenty = [0.0, 0.0, 0.0]
    pmomentz = [0.0, 0.0, 0.0]
    fmomentz = [0.0, 0.0, 0.0]

    sum = MinMax(Input=slice)
    sum.Operation = "SUM"
    sum.UpdatePipeline()

    sum_client = servermanager.Fetch(sum)
    if sum_client.GetCellData().GetArray("pressureforce"):
        pforce = sum_client.GetCellData().GetArray("pressureforce").GetTuple(0)
        pforce = rotate_vector(pforce, alpha, beta)

    if sum_client.GetCellData().GetArray("frictionforce"):
        fforce = sum_client.GetCellData().GetArray("frictionforce").GetTuple(0)
        fforce = rotate_vector(fforce, alpha, beta)
        """
        # Add sectional force integration
        sorted_line = PlotOnSortedLines(Input=chord_calc)
        sorted_line.UpdatePipeline()
        sorted_line = servermanager.Fetch(sorted_line)
        cp_array = sorted_line.GetCellData().GetArray("cp")

        for i in range(0,len(cp_array)):
            sorted_line.GetPointData().GetArray("X")
            pass
        """
    if sum_client.GetCellData().GetArray("pressuremoment"):
        pmoment = sum_client.GetCellData().GetArray("pressuremoment").GetTuple(0)
        pmoment = rotate_vector(pmoment, alpha, beta)

    if sum_client.GetCellData().GetArray("frictionmoment"):
        fmoment = sum_client.GetCellData().GetArray("frictionmoment").GetTuple(0)
        fmoment = rotate_vector(fmoment, alpha, beta)

    if sum_client.GetCellData().GetArray("pressuremomentx"):
        pmomentx = sum_client.GetCellData().GetArray("pressuremomentx").GetTuple(0)
        pmomentx = rotate_vector(pmomentx, alpha, beta)

    if sum_client.GetCellData().GetArray("frictionmomentx"):
        fmomentx = sum_client.GetCellData().GetArray("frictionmomentx").GetTuple(0)
        fmomentx = rotate_vector(fmomentx, alpha, beta)

    if 'func' in kwargs:
        sorted_line = PlotOnSortedLines(Input=chord_calc)
        sorted_line.UpdatePipeline()
        extract_client = servermanager.Fetch(sorted_line)
        for_each(extract_client, **kwargs)

    Delete(chord_calc)
    del chord_calc
    Delete(sum)
    del sum
    del sum_client
    Delete(slice)
    del slice
    Delete(sorted_line)
    del sorted_line
    del extract_client

    return {'pressure force': pforce,
            'friction force': fforce,
            'pressure moment': pmoment,
            'friction moment': fmoment}
예제 #12
0
파일: post.py 프로젝트: zCFD/zutil
def cp_profile(surface, slice_normal, slice_origin, **kwargs):

    alpha = 0.0
    if "alpha" in kwargs:
        alpha = kwargs["alpha"]
    beta = 0.0
    if "beta" in kwargs:
        beta = kwargs["beta"]

    time_average = False
    if "time_average" in kwargs:
        time_average = kwargs["time_average"]

    rotate_geometry = [0.0, 0.0, 0.0]
    if "rotate_geometry" in kwargs:
        rotate_geometry = kwargs["rotate_geometry"]

    clean = CleantoGrid(Input=surface)
    clean.UpdatePipeline()

    point_data = CellDatatoPointData(Input=clean)
    point_data.PassCellData = 1
    Delete(clean)
    del clean

    if "filter" in kwargs:
        filter_zones = kwargs["filter"]
        calc_str = "".join("(zone={:d})|".format(i) for i in filter_zones)
        filter_data = Calculator(Input=point_data)
        filter_data.AttributeType = "Cell Data"
        filter_data.Function = "if (" + calc_str[:-1] + ", 1, 0)"
        filter_data.ResultArrayName = "zonefilter"
        filter_data.UpdatePipeline()
        Delete(point_data)
        del point_data
        point_data = Threshold(Input=filter_data)
        point_data.Scalars = ["CELLS", "zonefilter"]
        point_data.ThresholdRange = [1.0, 1.0]
        point_data.UpdatePipeline()
        Delete(filter_data)
        del filter_data

    surf = ExtractSurface(Input=point_data)
    surf_normals = GenerateSurfaceNormals(Input=surf)
    surf_normals.UpdatePipeline()

    Delete(surf)
    del surf
    Delete(point_data)
    del point_data

    point_data = surf_normals

    slice = Slice(Input=point_data, SliceType="Plane")

    slice.SliceType.Normal = slice_normal
    slice.SliceType.Origin = slice_origin

    slice.UpdatePipeline()
    Delete(point_data)
    del point_data

    if time_average:
        temporal = TemporalStatistics(Input=slice)
        temporal.ComputeMaximum = 0
        temporal.ComputeStandardDeviation = 0
        temporal.ComputeMinimum = 0
        temporal.UpdatePipeline()
        Delete(slice)
        del slice
        slice = temporal

    offset = get_chord(slice, rotate_geometry)

    transform = Transform(Input=slice, Transform="Transform")
    transform.Transform.Scale = [1.0, 1.0, 1.0]
    transform.Transform.Translate = [0.0, 0.0, 0.0]
    transform.Transform.Rotate = rotate_geometry
    transform.UpdatePipeline()

    if "chord_func" in kwargs:
        pass
    else:
        chord_calc = Calculator(Input=transform)
        chord_calc.AttributeType = "Point Data"
        chord_calc.Function = (
            "(coords.iHat - " + str(offset[0]) + ")/" + str(offset[1] - offset[0])
        )
        chord_calc.ResultArrayName = "chord"

    # Attempt to calculate forces
    pforce = [0.0, 0.0, 0.0]
    fforce = [0.0, 0.0, 0.0]
    pmoment = [0.0, 0.0, 0.0]
    fmoment = [0.0, 0.0, 0.0]
    pmomentx = [0.0, 0.0, 0.0]
    fmomentx = [0.0, 0.0, 0.0]
    pmomenty = [0.0, 0.0, 0.0]
    fmomenty = [0.0, 0.0, 0.0]
    pmomentz = [0.0, 0.0, 0.0]
    fmomentz = [0.0, 0.0, 0.0]

    sum = MinMax(Input=slice)
    sum.Operation = "SUM"
    sum.UpdatePipeline()

    sum_client = servermanager.Fetch(sum)
    if sum_client.GetCellData().GetArray("pressureforce"):
        pforce = sum_client.GetCellData().GetArray("pressureforce").GetTuple(0)
        pforce = rotate_vector(pforce, alpha, beta)

    if sum_client.GetCellData().GetArray("frictionforce"):
        fforce = sum_client.GetCellData().GetArray("frictionforce").GetTuple(0)
        fforce = rotate_vector(fforce, alpha, beta)
        """
        # Add sectional force integration
        sorted_line = PlotOnSortedLines(Input=chord_calc)
        sorted_line.UpdatePipeline()
        sorted_line = servermanager.Fetch(sorted_line)
        cp_array = sorted_line.GetCellData().GetArray("cp")

        for i in range(0,len(cp_array)):
            sorted_line.GetPointData().GetArray("X")
            pass
        """
    if sum_client.GetCellData().GetArray("pressuremoment"):
        pmoment = sum_client.GetCellData().GetArray("pressuremoment").GetTuple(0)
        pmoment = rotate_vector(pmoment, alpha, beta)

    if sum_client.GetCellData().GetArray("frictionmoment"):
        fmoment = sum_client.GetCellData().GetArray("frictionmoment").GetTuple(0)
        fmoment = rotate_vector(fmoment, alpha, beta)

    if sum_client.GetCellData().GetArray("pressuremomentx"):
        pmomentx = sum_client.GetCellData().GetArray("pressuremomentx").GetTuple(0)
        pmomentx = rotate_vector(pmomentx, alpha, beta)

    if sum_client.GetCellData().GetArray("frictionmomentx"):
        fmomentx = sum_client.GetCellData().GetArray("frictionmomentx").GetTuple(0)
        fmomentx = rotate_vector(fmomentx, alpha, beta)

    if "func" in kwargs:
        sorted_line = PlotOnSortedLines(Input=chord_calc)
        sorted_line.UpdatePipeline()
        extract_client = servermanager.Fetch(sorted_line)
        for_each(extract_client, **kwargs)

    Delete(chord_calc)
    del chord_calc
    Delete(sum)
    del sum
    del sum_client
    Delete(slice)
    del slice
    Delete(sorted_line)
    del sorted_line
    del extract_client

    return {
        "pressure force": pforce,
        "friction force": fforce,
        "pressure moment": pmoment,
        "friction moment": fmoment,
    }
예제 #13
0
def my_transform(x, y, z):
    v = [x, y, z]
    v = zutil.rotate_vector(v, alpha, 0.0)
    return {'v1': v[0], 'v2': v[1], 'v3': v[2]}