@@ -49,6 +49,7 @@ def __init__(self, solver, custom_settings):
4949 # Retrieve list of model parts from settings
5050 self .include_conditions_model_parts_list = settings ["include_conditions_model_parts_list" ].GetStringArray ()
5151 self .include_elements_model_parts_list = settings ["include_elements_model_parts_list" ].GetStringArray ()
52+ self .include_nodal_neighbouring_elements_model_parts_list = settings ["include_nodal_neighbouring_elements_model_parts_list" ].GetStringArray ()
5253
5354 # Check if the model parts exist
5455 for model_part_name in self .include_conditions_model_parts_list :
@@ -132,7 +133,7 @@ def CreateHRomModelParts(self):
132133
133134 # Output the HROM model part in mdpa format
134135 hrom_output_name = "{}HROM" .format (model_part_output_name )
135- model_part_io = KratosMultiphysics .ModelPartIO (hrom_output_name , KratosMultiphysics .IO .WRITE | KratosMultiphysics .IO .MESH_ONLY )
136+ model_part_io = KratosMultiphysics .ModelPartIO (hrom_output_name , KratosMultiphysics .IO .WRITE | KratosMultiphysics .IO .MESH_ONLY | KratosMultiphysics . IO . SCIENTIFIC_PRECISION )
136137 model_part_io .WriteModelPart (hrom_main_model_part )
137138 KratosMultiphysics .kratos_utilities .DeleteFileIfExisting ("{}.time" .format (hrom_output_name ))
138139 if self .echo_level > 0 :
@@ -153,7 +154,7 @@ def CreateHRomModelParts(self):
153154
154155 # Write the HROM visualization mesh
155156 hrom_vis_output_name = "{}HROMVisualization" .format (model_part_output_name )
156- model_part_io = KratosMultiphysics .ModelPartIO (hrom_vis_output_name , KratosMultiphysics .IO .WRITE | KratosMultiphysics .IO .MESH_ONLY )
157+ model_part_io = KratosMultiphysics .ModelPartIO (hrom_vis_output_name , KratosMultiphysics .IO .WRITE | KratosMultiphysics .IO .MESH_ONLY | KratosMultiphysics . IO . SCIENTIFIC_PRECISION )
157158 model_part_io .WriteModelPart (hrom_visualization_model_part )
158159 KratosMultiphysics .kratos_utilities .DeleteFileIfExisting ("{}.time" .format (hrom_vis_output_name ))
159160 if self .echo_level > 0 :
@@ -170,6 +171,7 @@ def __GetHRomTrainingDefaultSettings(cls):
170171 "projection_strategy": "galerkin",
171172 "include_conditions_model_parts_list": [],
172173 "include_elements_model_parts_list": [],
174+ "include_nodal_neighbouring_elements_model_parts_list":[],
173175 "include_minimum_condition": false,
174176 "include_condition_parents": true
175177 }""" )
@@ -247,6 +249,25 @@ def AppendHRomWeightsToRomParameters(self):
247249
248250 # If needed, update your weights and indexes using __AddSelectedElementsWithZeroWeights function with the new_elements
249251 weights , indexes = self .__AddSelectedElementsWithZeroWeights (weights , indexes , new_elements )
252+
253+ # Add nodal neighbouring elements
254+ for model_part_name in self .include_nodal_neighbouring_elements_model_parts_list :
255+ # Check if the sub model part exists
256+ if self .solver .model .HasModelPart (model_part_name ):
257+ nodal_neighbours_model_part = self .solver .model .GetModelPart (model_part_name )
258+
259+ # Call the GetNodalNeighbouringElementIdsNotInHRom function
260+ new_nodal_neighbours = KratosROM .RomAuxiliaryUtilities .GetNodalNeighbouringElementIdsNotInHRom (
261+ root_model_part , # The complete model part
262+ nodal_neighbours_model_part , # The model part containing the nodal neighbouring elements to be included
263+ hrom_weights )
264+
265+ # Add the new nodal neighbouring elements to the elements dict with a null weight
266+ for element_id in new_nodal_neighbours :
267+ hrom_weights ["Elements" ][element_id ] = 0.0
268+
269+ # If needed, update your weights and indexes using __AddSelectedElementsWithZeroWeights function with the new_nodal_neighbours
270+ weights , indexes = self .__AddSelectedElementsWithZeroWeights (weights , indexes , new_nodal_neighbours )
250271
251272 # If required, keep at least one condition per submodelpart
252273 # This might be required by those BCs involving the faces (e.g. slip BCs)
0 commit comments