# rst getLocalIndex # The control points of the FFD are the same as the coordinates of the points in the input file # but they will be in a jumbled order because of the internal spline representation of the volume. # Let's put them in a sensible order for plotting. # the raw array of FFD control points (size n_control_pts x 3) FFD = DVGeo.FFD.coef # we can use the getLocalIndex method to put the coefs in contiguous order # the FFD block has i,j,k directions # in this problem i is left/right, j is up down, and k is into the page (along the cyl) # Let's extract a ring of the front-face control points in contiguous order. # We'll add these as a pointset as well so we can visualize them. # (Don't worry too much about the details) FFDptset = np.concatenate([ FFD[DVGeo.getLocalIndex(0)[:, 0, 0]], FFD[DVGeo.getLocalIndex(0)[::-1, 1, 0]], FFD[DVGeo.getLocalIndex(0)[0, 0, 0]].reshape((1, 3)), ]).reshape(21, 3) # Add these control points to the FFD volume. This is only for visualization purposes in this demo. # Under normal circumstances you don't need to worry about adding the FFD points as a pointset DVGeo.addPointSet(FFDptset, "ffd") # Print the indices and coordinates of the FFD points for informational purposes print("FFD Indices:") print(DVGeo.getLocalIndex(0)[:, 0, 0]) print("FFD Coordinates:") print(FFD[DVGeo.getLocalIndex(0)[:, 0, 0]]) # Create tecplot output that contains the FFD control points, embedded volume, and pointset
# Add DVGeo object to CFD solver CFDSolver.setDVGeo(DVGeo) # rst dvgeo (end) # ====================================================================== # DVConstraint Setup # ====================================================================== # rst dvcon (beg) DVCon = DVConstraints() # DVCon = DVConstraints_FFD_data() DVCon.setDVGeo(DVGeo) # Only ADflow has the getTriangulatedSurface Function DVCon.setSurface(CFDSolver.getTriangulatedMeshSurface()) # Le/Te constraints lIndex = DVGeo.getLocalIndex(0) indSetA = [] indSetB = [] # print('lIndex.shape[0]',lIndex.shape[0]) for k in range(0, 1): indSetA.append(lIndex[0, 0, k]) # all DV for upper and lower should be same but different sign indSetB.append(lIndex[0, 1, k]) for k in range(0, 1): indSetA.append(lIndex[-1, 0, k]) indSetB.append(lIndex[-1, 1, k]) # print(indSetA) DVCon.addLeTeConstraints(0, indSetA=indSetA, indSetB=indSetB) # DV should be same along spanwise lIndex = DVGeo.getLocalIndex(0) indSetA = []