Пример #1
0
    def process_sref(compound):
        """
        Process a wing reference surface. The compound should contain a single
        face. The underlying surface of this faces will be used to generate a
        new NurbsSurface. Since the OpenVSP surface uses uniform
        parametrization, a chord line is extracted at each unique knot in the
        v-direction. Then a linear surface is lofted through these lines to
        form a bilinear surface where the u-direction is chordwise and the
        v-direction is spanwise.

        :param afem.topology.entities.Compound compound: The compound.

        :return: The reference surface.
        :rtype: afem.geometry.entities.NurbsSurface
        """
        # Get underlying surface
        srf = compound.faces[0].surface

        # Loft new surface
        vknots = srf.vknots
        crvs = []
        for vi in vknots:
            c = srf.v_iso(vi)
            crvs.append(c)
        srf = NurbsSurfaceByInterp(crvs, 1).surface
        return srf
Пример #2
0
def _reloft_wing_surface(srf, tol):
    """
    Attempt to reloft an OpenVSP wing surface which was not split to achieve
    higher continuity.
    """
    logger.info('\tAttempting to reloft the surface...')
    # Gather isocurves at each section, tessellate, and approximate
    crvs = []
    for u in srf.uknots:
        c0 = srf.u_iso(u)
        adp_crv = AdaptorCurve.to_adaptor(c0)
        tool = GCPnts_QuasiUniformDeflection(adp_crv.object, tol)
        if not tool.IsDone():
            logger.info('\tTessellation failed. Using original surface.')
            return srf
        pnts = [c0.eval(tool.Parameter(i)) for i in
                range(1, tool.NbPoints() + 1)]
        c = NurbsCurveByApprox(pnts, tol=tol, continuity=Geometry.C1).curve
        crvs.append(c)
    return NurbsSurfaceByInterp(crvs, 1).surface
Пример #3
0
    def rebuild_wing_sref(srf):
        """
        Attempt to rebuild a wing reference surface using the given OML
        surface. This method is intended to operate on OpenVSP surfaces that
        define the OML of a wing component and/or have similar parametrization.

        :param afem.geometry.entities.NurbsSurface srf: The surface.

        :return: The reference surface.
        :rtype: afem.geometry.entities.NurbsSurface
        """
        # For VSP, wing surfaces are degree=1 in the spanwise direction, so
        # each knot vector usually represents where a wing cross section is
        # located. For each knot vector in spanwise direction, generate a
        # straight line segment between the LE and TE (i.e., the chord line).
        # These chords will serve as the wing reference surface. This assumes
        # that the LE is at v=0.5 in the local parametric domain.
        uknots = srf.uknots
        le_param = srf.local_to_global_param('v', 0.5)
        te_param = srf.local_to_global_param('v', 0.)
        chords = []
        for u in uknots:
            le = srf.eval(u, le_param)
            te = srf.eval(u, te_param)
            c = NurbsCurveByPoints([le, te]).curve
            chords.append(c)

        # VSP wing components wrap around the ends and there may be duplicate
        # chord lines at the root and tip. Retain only unique lines based on LE
        # point.
        unique_chords = [chords[0]]
        for i in range(1, len(chords)):
            c0 = unique_chords[-1]
            ci = chords[i]
            if not ci.eval(0.).is_equal(c0.eval(0.)):
                unique_chords.append(ci)

        # Create degree=1 reference surface by skinning chord lines
        sref = NurbsSurfaceByInterp(unique_chords, 1).surface

        # Set domains to be 0 to 1.
        sref.set_udomain(0., 1.)
        sref.set_vdomain(0., 1.)

        return sref