Conversation
308e42b to
dc11ac1
Compare
rokkrpan
left a comment
There was a problem hiding this comment.
If possible, avoid using linAlg4Foam inside loops.
src/python/geimFOAM.py
Outdated
| sensor_field_i = self.list_sensor_to_field[i] | ||
| for j in range(count_basis + 1): | ||
| sensor_basis_j = self.list_sensor_to_basis_paths[j] | ||
| sensoring_results = linAlg4Foam.readFromPoints(self.virtual_openFoam_directory, [sensor_basis_j], [sensor_field_i], [sensor_point_i]) |
There was a problem hiding this comment.
Each time you call linAlg4Foam it will start from scratch (without compiling). Try to avoid using these functionalities in a loop. You can provide a list of snaps, fields and points all at once, and then extract the needed data from the generated dictionary.
| for i in range(n_rows): | ||
| sensor_point = self.list_points[i] | ||
| sensor_field = self.list_sensor_to_field[i] | ||
| sensoring_results = linAlg4Foam.readFromPoints(self.virtual_openFoam_directory, self.list_chosen_snaps, [sensor_field], [sensor_point]) |
There was a problem hiding this comment.
If possible, avoid using in a loop.
| reconstructed_snap = self.list_reconstructed_snaps[i] | ||
| for field in self.all_fields: | ||
| region, field_name = split_on_slash(field) | ||
| linAlg4Foam.linearCombination(self.virtual_openFoam_directory, [self.list_sensor_to_basis_paths], [field], [coeffs_list], [os.path.join("../symlinked_cases", reconstructed_snap, region)]) |
There was a problem hiding this comment.
If possible, avoid using in a loop. If looping cannot be omitted, then some upgrading of the function is needed.
| residual_snap = self.list_residual_snaps[i] | ||
| for field in self.all_fields: | ||
| region, field_name = split_on_slash(field) | ||
| linAlg4Foam.linearCombination(self.virtual_openFoam_directory, [[snap, reconstructed_snap]], [field], [[1, -1]], [os.path.join("../symlinked_cases", residual_snap, region)]) |
There was a problem hiding this comment.
Considering multiple fields at once is needed?
| for i in range(self.rank_reconstruct): | ||
| sensor_point = self.list_points[i] | ||
| sensor_field = self.list_sensor_to_field[i] | ||
| sensoring_results = linAlg4Foam.readFromPoints(self.virtual_openFoam_directory, self.snaps, [sensor_field], [sensor_point]) |
There was a problem hiding this comment.
If possible, avoid using it in a loop.
This pull request adds the
geimFOAMmodule. It should be noted that it's based on #13. Hence, please checksrc/python/geimFOAM.py. ThegeimFOAMmodule has two Python classes - one for the offline phase of the algorithm and another for the online phase. The classes can be imported by:GeimFOAM_offlinetakes a rank, an instance of theSnapshot_manager, a list of observable fields, and a list of non-observable fields as inputs. It should be noted that the user has been given the option for choosing the non-observable fields because some fields might be of lesser interest, e.g., constant fields.Therefore, the instantiation of
GeimFOAM_offlinewould be of the following form:Then, the
GeimFOAM_offline.run_geim()method must be called to start the algorithm. This can be done the following way:After the completion of this method, the instance of the object is matured and can now be used to run the online phase of the algorithm.
To run the online phase of the algorithm, we have to create an instance of the
GeimFOAM_onlineclass. It takes an instance of theGeimFOAM_offlineclass, a list of snapshots that we intend to reconstruct, and the rank of reconstruction. It can be instantiated the following way:After the instantiation of the object, one must run the
GeimFOAM_online.reconstruct_snaps()method to complete the reconstruction process.