Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
23624f5
Add mesh output to OM reader
sabakhshi Aug 8, 2025
3b99ca4
Initial commit of direct mesh setting
sabakhshi Oct 24, 2025
bd25ced
Implemented python interface and setting basic meshes works
sabakhshi Oct 27, 2025
4462a65
minor fixes for adjust_mesh_spacing
sabakhshi Oct 28, 2025
85135d3
Fixes for the automatic section slicing routines
sabakhshi Oct 28, 2025
26820d2
Fixes for using nspans to define sections
sabakhshi Oct 28, 2025
83512c4
Fix direct spec of iploc and fix numerous issues with controls
sabakhshi Oct 28, 2025
b443660
tweak f2py interface to pass size explicitly
joanibal Oct 28, 2025
419d72e
Fix broken ainc interp and fix broken camber slope interp
sabakhshi Oct 28, 2025
ca41ba4
Fixed multiple surfaces not being handled correct with custom meshes.…
sabakhshi Oct 29, 2025
dc03dec
fix tecplot file writing
sabakhshi Oct 30, 2025
3728fd3
start figuring out an update routine
sabakhshi Oct 30, 2025
10ac86b
hacked in a way to update surfaces without store or allocating anythi…
sabakhshi Oct 31, 2025
455fe81
WIP rework
sabakhshi Nov 4, 2025
27d8289
Wip stuff
sabakhshi Nov 4, 2025
0514f65
Wip
sabakhshi Nov 5, 2025
488a312
Finally finished the flat index rework for direct mesh
sabakhshi Nov 17, 2025
b283efc
Implement flat mesh setting in python layer initialization. fix some …
sabakhshi Nov 19, 2025
0967bce
Implement new normal calcs for custom meshes
sabakhshi Nov 21, 2025
4c5e34b
Implemented mesh flattening
sabakhshi Dec 16, 2025
e264a5f
start cleaning up for PR
sabakhshi Jan 12, 2026
cc67879
integrated encalc routine for custom meshes into the main one
sabakhshi Jan 13, 2026
426e43f
Added plotting features
sabakhshi Jan 16, 2026
3637270
New control definition implemention. section free
sabakhshi Feb 2, 2026
469a667
removing section loop from amake.wip
sabakhshi Feb 2, 2026
8aa02da
Complete rework of fortran subroutines for custom meshes
sabakhshi Feb 3, 2026
b7b5020
Reworked Mesh implementation. Ready for initial review
sabakhshi Feb 3, 2026
48da6af
Remove contractions from fortran comments
sabakhshi Feb 3, 2026
5c360f3
merge AVL 3.52 into branch
sabakhshi Feb 3, 2026
14d1afd
Manually clean up some things to complete the merge
sabakhshi Feb 3, 2026
5672f7e
Cleaned up some utility functions in the python class
sabakhshi Feb 3, 2026
889b00d
Some things missed from last commit
sabakhshi Feb 3, 2026
9f384d2
fix naca specification for meshes
sabakhshi Feb 3, 2026
0578fb4
Fix tecplot writing from input dict for now
sabakhshi Feb 3, 2026
4a17e21
Fixed multiple mesh surfaces not working correctly
sabakhshi Feb 5, 2026
5acbab9
formatting of fortran code and removed one batch of commented prints
joanibal Feb 6, 2026
191b0d2
fixed EC_G for custom meshes
sabakhshi Feb 8, 2026
c00f256
Added a unit test
sabakhshi Feb 9, 2026
29d89c9
clean up a few things
sabakhshi Feb 9, 2026
e295a2b
Updated array maximums in python class and added the new NSECMAX param
sabakhshi Feb 9, 2026
f7d02cd
added unit test for global constants
joanibal Feb 10, 2026
889d9e4
Initial AD complete
sabakhshi Feb 10, 2026
df7b9c3
started implementing AD seed routines for meshes in python
sabakhshi Feb 10, 2026
86a1b37
Implemented adjoint. reverse still seg faulting for now with unmodfie…
sabakhshi Feb 17, 2026
c63cdde
redo tapenade
sabakhshi Feb 23, 2026
c0f7b49
wip
sabakhshi Feb 23, 2026
c2d82d8
wip stuff
sabakhshi Feb 23, 2026
6304e73
fixed borken tests
sabakhshi Feb 23, 2026
ad64e43
Working on test for mesh derivatives
sabakhshi Feb 24, 2026
ad2310c
Implemented most of the mesh derivative tests
sabakhshi Feb 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions _temp/scratch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import numpy as np

from optvl import OVLSolver
import pickle
import os



mesh = np.load("wing_mesh.npy")


with open("wing_mesh.pkl", 'wb') as f:
pickle.dump(mesh, f)



test_mesh = np.zeros((2,2,3))
test_mesh[1,:,0] = 1.0
test_mesh[:,1,1] = 1.0
test_mesh[:,:,2] = 1.0


base_dir = os.path.dirname(os.path.abspath(__file__)) # Path to current folder
geom_dir = os.path.join(base_dir, '..', 'geom_files')

rect_file = os.path.join(geom_dir, 'rect_with_body.avl')


surf = {
"Wing": {
# General
"component": np.int32(1), # logical surface component index (for grouping interacting surfaces, see AVL manual)
# "yduplicate": np.float64(0.0), # surface is duplicated over the ysymm plane
# Geometry
"scale": np.array(
[1.0, 1.0, 1.0], dtype=np.float64
), # scaling factors applied to all x,y,z coordinates (chords arealso scaled by Xscale)
"translate": np.array(
[0.0, 0.0, 0.0], dtype=np.float64
), # offset added on to all X,Y,Z values in this surface
# Geometry: Mesh
"mesh": np.float64(test_mesh), # (nx,ny,3) numpy array containing mesh coordinates
# Control Surface Specification
"control_assignments": {
"Elevator" : {"assignment":np.arange(0,test_mesh.shape[1]),
"xhinged": 0.5, # x/c location of hinge
"vhinged": np.array([0,1,0]), # vector giving hinge axis about which surface rotates
"gaind": -1.0, # control surface gain
"refld": 1.0 # control surface reflection, sign of deflection for duplicated surface
}
},

}
}

fuselage = {"Fuse pod": {
# General
# 'yduplicate': np.float64(0), # body is duplicated over the ysymm plane
# Geometry
"scale": np.array(
[1.0, 1.0, 1.0]
), # scaling factors applied to all x,y,z coordinates (chords areal so scaled by Xscale)
"translate": np.array([0.0, 0.0, 0.0]), # offset added on to all X,Y,Z values in this surface
# Discretization
"nvb": np.int32(4), # number of source-line nodes
"bspace": np.float64(2.0), # lengthwise node spacing parameter
"bfile": "../geom_files/fuseSimple.dat", # body oml file name
}
}

input_dict = {
"title": "MACH MDAO AVL",
"mach": np.float64(0.0),
"iysym": np.int32(0),
"izsym": np.int32(0),
"zsym": np.float64(0.0),
"Sref": np.float64(1.123),
"Cref": np.float64(0.25),
"Bref": np.float64(6.01),
"XYZref": np.array([0.0, 0, 0],dtype=np.float64),
"CDp": np.float64(0.0),
"surfaces": surf,
"bodies": fuselage,
# Global Control and DV info
"dname": ["Elevator"], # Name of control input for each corresonding index
}


solver = OVLSolver(input_dict=input_dict,debug=True)
# solver = OVLSolver(geo_file=rect_file,debug=True)

solver.set_variable("alpha", 25.0)
solver.set_variable("beta", 5.0)
solver.execute_run()

# solver.plot_geom()
with open("rect_with_body.pkl", 'wb') as f:
pickle.dump(input_dict, f)




6 changes: 2 additions & 4 deletions config/defaults/config.MACOS_GFORTRAN.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ FF90 = gfortran



FF90_FLAGS = -fdefault-real-8 -fdefault-double-8 -O2 -fPIC -Wno-align-commons -std=legacy -C -mmacosx-version-min=13.6
# FF90_FLAGS = -fdefault-real-8 -fdefault -double-8 -O0 -fPIC -Wno-align-commons -Werror=line-truncation -std=legacy -C -mmacosx-version-min=13.6 -g -fcheck=bounds -finit-real=snan -finit-integer=-999999 -ftrapping-math -ftrapv
# FF90_FLAGS = -fdefault-real-8 -fdefault-double-8 -O2 -fPIC -Wno-align-commons -std=legacy -C -mmacosx-version-min=13.6
FF90_FLAGS = -fdefault-real-8 -fdefault -double-8 -O0 -fPIC -Wno-align-commons -Werror=line-truncation -std=legacy -C -mmacosx-version-min=13.6 -g -fcheck=bounds -finit-real=snan -finit-integer=-999999 -ftrapping-math -ftrapv


C_FLAGS = -O2 -fPIC -mmacosx-version-min=13.6

F2PY = f2py
F2PY_FF90 = gfortran

PYTHON = python
Expand Down
41 changes: 41 additions & 0 deletions geom_files/rect_out.avl
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# generated using OptVL v1.4.2.dev0
#===============================================================================
#------------------------------------ Header -----------------------------------
#===============================================================================
MACH MDAO AVL
#Mach
0.12341234
#IYsym IZsym Zsym
0 0 0.0
#Sref Cref Bref
1.0 2.0 3.0
#Xref Yref Zref
4.0 5.0 6.0
#CD0
0.0
#===============================================================================
#------------------------------------- Wing ------------------------------------
#===============================================================================
SURFACE
Wing
#Nchordwise Cspace [Nspanwise Sspace]
1 1.0 1 -2.0
SCALE
1.0 1.0 1.0
TRANSLATE
0.0 0.0 0.0
ANGLE
0.0
#---------------------------------------
SECTION
#Xle Yle Zle | Chord Ainc Nspan Sspace
0.000000 0.000000 0.000000 1.000000 0.000000
CONTROL
#surface gain xhinge hvec SgnDup
Elevator -1.0 0.5 0.000000 1.000000 0.000000 1.0
SECTION
#Xle Yle Zle | Chord Ainc Nspan Sspace
0.000000 1.000000 0.000000 1.000000 0.000000
CONTROL
#surface gain xhinge hvec SgnDup
Elevator -1.0 0.5 0.000000 1.000000 0.000000 1.0
Binary file added geom_files/rect_with_body.pkl
Binary file not shown.
Binary file added geom_files/wing_mesh.pkl
Binary file not shown.
17 changes: 15 additions & 2 deletions optvl/om_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,16 @@ def add_ovl_geom_vars(self, ovl, add_as="inputs", include_airfoil_geom=False):
elif add_as == "outputs":
self.add_output(geom_key, val=surf_data[surf][key], tags="geom")

def add_ovl_mesh_out_as_output(self, ovl):
surf_data = ovl.get_surface_params()

meshes,_ = ovl.get_cp_data()

for surf in surf_data:
idx_surf = ovl.surface_names.index(surf)
out_name = f"{surf}:mesh"
self.add_output(out_name, val=meshes[idx_surf], tags="geom_mesh")

def add_ovl_conditions_as_inputs(sys, ovl):
# TODO: add all the condition constraints

Expand Down Expand Up @@ -331,7 +340,7 @@ def apply_linear(self, inputs, outputs, d_inputs, d_outputs, d_residuals, mode):
res_d_seeds = d_residuals["gamma_d"]
res_u_seeds = d_residuals["gamma_u"]

con_seeds, geom_seeds, gamma_seeds, gamma_d_seeds, gamma_u_seeds, param_seeds, ref_seeds = (
con_seeds, geom_seeds, mesh_seeds, gamma_seeds, gamma_d_seeds, gamma_u_seeds, param_seeds, ref_seeds = (
self.ovl._execute_jac_vec_prod_rev(
res_seeds=res_seeds, res_d_seeds=res_d_seeds, res_u_seeds=res_u_seeds
)
Expand Down Expand Up @@ -601,7 +610,7 @@ def compute_jacvec_product(self, inputs, d_inputs, d_outputs, mode):
# print(var_name, body_axis_seeds[func_key])
print(f" running rev mode derivs for {func_key}")

con_seeds, geom_seeds, gamma_seeds, gamma_d_seeds, gamma_u_seeds, param_seeds, ref_seeds = (
con_seeds, geom_seeds, mesh_seeds, gamma_seeds, gamma_d_seeds, gamma_u_seeds, param_seeds, ref_seeds = (
self.ovl._execute_jac_vec_prod_rev(
func_seeds=func_seeds,
consurf_derivs_seeds=csd_seeds,
Expand Down Expand Up @@ -713,14 +722,18 @@ class OVLMeshReader(om.ExplicitComponent):
def initialize(self):
self.options.declare("geom_file", types=str)
self.options.declare("mass_file", default=None)
self.options.declare("mesh_output",default=False)

def setup(self):
geom_file = self.options["geom_file"]
mass_file = self.options["mass_file"]
mesh_output = self.options["mesh_output"]

avl = OVLSolver(geo_file=geom_file, mass_file=mass_file, debug=False)
add_ovl_geom_vars(self, avl, add_as="outputs", include_airfoil_geom=True)

if mesh_output:
add_ovl_mesh_out_as_output(self,avl)

class Differencer(om.ExplicitComponent):
def setup(self):
Expand Down
Loading
Loading