Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add spanwise shape variables #75

Merged
merged 16 commits into from
Mar 30, 2021
57 changes: 57 additions & 0 deletions tests/reg_tests/test_Cylinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,60 @@ def scale_circle(val, geo):
print(funcsSens)


def train_spanwise_dvs(self, train=True, refDeriv=True):
self.test_spanwise_dvs(train=train, refDeriv=refDeriv)


def test_spanwise_dvs(self, train=False, refDeriv=False):
refFile = os.path.join(self.base_path,'ref/test_Cylinder_spanwise_dvs.ref')

with BaseRegTest(refFile, train=train) as handler:
handler.root_print("Test 1: Basic FFD, global DVs")
radius = 1.0
height = 10.0

DVCon = DVConstraints()
surf = self.make_cylinder_mesh(radius, height)
DVCon.setSurface(surf)
# DVCon.writeSurfaceTecplot('cylinder_surface.dat')

ffd_name = os.path.join(self.base_path,'../inputFiles/cylinder_ffd.xyz')
self.make_ffd(ffd_name, radius, height)
DVGeo = DVGeometry(ffd_name)

DVGeo.addGeoDVSpanwiseLocal("shape", 'i', lower=-0.5, upper=0.5, axis="y", scale=1.0)

size = DVGeo._getNDVSpanwiseLocal()
DVCon.setDVGeo(DVGeo)


leList = [[0, 0, 0 ], [-radius/2, 0, height]]
xAxis = [-1, 0, 0]
yAxis = [0, 1, 0]
DVCon.addLERadiusConstraints(leList, nSpan=5, axis=yAxis,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this comes from the previous test, but I am not familiar with this script. Why are we using it?

chordDir=xAxis, scaled=False)
# DVCon.writeTecplot('cylinder_constraints.dat')

funcs = {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks we are only testing the DVCon sens here... which I guess it is pretty much the same than testing the DV sens directly? See my comment before the review about an additional test - if needed

DVCon.evalFunctions(funcs)
print(funcs)
handler.root_add_dict('funcs1', funcs, rtol=1e-6, atol=1e-6)

numpy.random.seed(0)
DVGeo.setDesignVars({'shape':(numpy.random.rand(size) - 0.5)})

funcs = {}
DVCon.evalFunctions(funcs)
handler.root_add_dict('funcs2', funcs, rtol=1e-6, atol=1e-6)
print(funcs)

funcsSens = {}
DVCon.evalFunctionsSens(funcsSens)
print(funcsSens)
handler.root_add_dict('funcsSens', funcsSens, rtol=1e-6, atol=1e-6)
print(funcsSens)



if __name__ == '__main__':
unittest.main()