Skip to content

Commit

Permalink
Y coordinate output
Browse files Browse the repository at this point in the history
Changes to allow  for  the get_cp subroutine to return y-coords
  • Loading branch information
gduthe committed May 14, 2021
1 parent 1f807ba commit 21952d5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/api.f90
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ function get_n_cp() bind(c, name='get_n_cp')
get_n_cp = N
end function get_n_cp

subroutine get_cp(x_out, cp_out, n_points) bind(c, name='get_cp')
subroutine get_cp(x_out, y_out, cp_out, n_points) bind(c, name='get_cp')
use s_xfoil, only: comset
use m_xoper
use i_xfoil
Expand All @@ -508,6 +508,7 @@ subroutine get_cp(x_out, cp_out, n_points) bind(c, name='get_cp')
den = beta + bfac * cpinc
cp_out(i) = cpinc / den
x_out(i) = X(i)
y_out(i) = Y(i)
enddo
end subroutine get_cp

Expand Down
7 changes: 5 additions & 2 deletions xfoil/xfoil.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,15 @@ def get_cp_distribution(self):
-------
x : np.array
X-coordinates
y : np.array
Y-coordinates
cp : np.ndarray
Pressure coefficients at the corresponding x-coordinates
"""
n = self._lib.get_n_cp()
x = np.zeros(n, dtype=c_float)
y = np.zeros(n, dtype=c_float)
cp = np.zeros(n, dtype=c_float)

self._lib.get_cp(x.ctypes.data_as(fptr), cp.ctypes.data_as(fptr), byref(c_int(n)))
return x.astype(float), cp.astype(float)
self._lib.get_cp(x.ctypes.data_as(fptr), y.ctypes.data_as(fptr), cp.ctypes.data_as(fptr), byref(c_int(n)))
return x.astype(float), y.astype(float), cp.astype(float)

0 comments on commit 21952d5

Please sign in to comment.