Skip to content
Snippets Groups Projects
Commit e5d2f728 authored by Riccardo Riva's avatar Riccardo Riva Committed by Mads M. Pedersen
Browse files

Fix #126

parent 91f6a4b1
No related branches found
No related tags found
1 merge request!272Fix #126
Pipeline #61124 passed
......@@ -218,6 +218,23 @@ class HTCFile(HTCContents, HTCDefaults, HTCExtensions):
with self.open(filename, 'w', encoding='cp1252') as fid:
fid.write(str(self))
def copy(self):
"""
Copy this htc file.
Returns
-------
new_htc : HTCFile
Copy of this htc file.
"""
new_htc = HTCFile()
for key in self.keys():
new_htc[key] = self[key].copy()
new_htc.modelpath = self.modelpath
new_htc.filename = self.filename[:-4] + "_copy.htc"
return new_htc
def set_name(self, name, subfolder=''):
"""Sets the base filename of the simulation files.
......
......@@ -395,6 +395,15 @@ end turb_export;"""
assert tower2.timoschenko_input.set.values == [1, 2]
assert tower2.timoschenko_input__2.set.values == [3, 3]
def test_htc_copy2(self):
htc1 = HTCFile(self.testfilepath + "test.htc")
htc2 = htc1.copy()
test1 = len(htc2.compare(htc1)) == 0
test2 = id(htc1) != id(htc2)
assert test1 and test2
assert htc1.modelpath==htc2.modelpath
assert htc2.filename==self.testfilepath + "test_copy.htc"
def test_location(self):
htc = HTCFile(self.testfilepath + "test.htc")
assert htc.new_htc_structure.main_body__3.location() == 'test.htc/new_htc_structure/main_body__3'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment