Skip to content

Contain write operations within with statements#195

Merged
kccwing merged 4 commits intodevelopfrom
fix_dynmb_outfiles
Jun 8, 2022
Merged

Contain write operations within with statements#195
kccwing merged 4 commits intodevelopfrom
fix_dynmb_outfiles

Conversation

@ngoiz
Copy link
Contributor

@ngoiz ngoiz commented May 6, 2022

Fixes open files issue. Probably not the most efficient implementation as the files are opened/closed at each FSI iteration but solves the issue of files being left open.

Also fixes a hardcoded directory

@ngoiz ngoiz requested a review from kccwing May 6, 2022 09:56
self.fid_cond_num = open(dire + 'cond_num.dat', "w")

self.out_files = {'lambda': dire + 'lambda.dat',
'lambda_dot': dire + 'lambda.dat',
Copy link
Collaborator

Choose a reason for hiding this comment

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

... dire + 'lambda_dot.dat'

for out_var, data in out_data.items():
file_name = self.out_files[out_var]
with open(file_name, 'a') as fid:
fid.write(f'{self.data.ts:g} {iteration:g}')
Copy link
Collaborator

Choose a reason for hiding this comment

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

fid.write(f'{self.data.ts:g} {iteration:g} ')

fid.write(f'{self.data.ts:g} {iteration:g}')
for ilm in range(self.num_LM_eq):
fid.write(f'{data[ilm]} ')

Copy link
Collaborator

Choose a reason for hiding this comment

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

fid.write(f'\n')

Copy link
Collaborator

@kccwing kccwing left a comment

Choose a reason for hiding this comment

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

Thanks @ngoiz for fixing this! I've verified the output files with an existing multibody case and can confirm it works.

@kccwing kccwing merged commit ca2c136 into develop Jun 8, 2022
@kccwing kccwing deleted the fix_dynmb_outfiles branch June 8, 2022 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants