FEM: move 1DFlow inout nodes file into analysis directory and do not delete it
This commit is contained in:
@@ -63,6 +63,7 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
|
||||
self.main_file_name = self.mesh_object.Name + '.inp'
|
||||
self.file_name = self.dir_name + self.main_file_name
|
||||
self.FluidInletoutlet_ele = []
|
||||
self.fluid_inout_nodes_file = self.dir_name + self.mesh_object.Name + '_inout_nodes.txt'
|
||||
print('FemInputWriterCcx --> self.dir_name --> ' + self.dir_name)
|
||||
print('FemInputWriterCcx --> self.main_file_name --> ' + self.main_file_name)
|
||||
print('FemInputWriterCcx --> self.file_name --> ' + self.file_name)
|
||||
@@ -111,7 +112,7 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
|
||||
if self.fluidsection_objects:
|
||||
if is_fluid_section_inlet_outlet(self.ccx_elsets) is True:
|
||||
inpfile.close()
|
||||
FemMeshTools.use_correct_fluidinout_ele_def(self.FluidInletoutlet_ele, self.file_name)
|
||||
FemMeshTools.use_correct_fluidinout_ele_def(self.FluidInletoutlet_ele, self.file_name, self.fluid_inout_nodes_file)
|
||||
inpfile = open(self.file_name, 'a')
|
||||
|
||||
# constraints independent from steps
|
||||
@@ -262,7 +263,7 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
|
||||
# Fluid section: Inlet and Outlet requires special element definition
|
||||
if self.fluidsection_objects:
|
||||
if is_fluid_section_inlet_outlet(self.ccx_elsets) is True:
|
||||
FemMeshTools.use_correct_fluidinout_ele_def(self.FluidInletoutlet_ele, name + "_Node_Elem_sets.inp")
|
||||
FemMeshTools.use_correct_fluidinout_ele_def(self.FluidInletoutlet_ele, name + "_Node_Elem_sets.inp", self.fluid_inout_nodes_file)
|
||||
|
||||
# constraints independent from steps
|
||||
if self.planerotation_objects:
|
||||
@@ -968,10 +969,12 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
|
||||
f.write('\n***********************************************************\n')
|
||||
f.write('** FluidSection constraints\n')
|
||||
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
|
||||
if os.path.exists("inout_nodes.txt"):
|
||||
inout_nodes_file = open("inout_nodes.txt", "r")
|
||||
if os.path.exists(self.fluid_inout_nodes_file):
|
||||
inout_nodes_file = open(self.fluid_inout_nodes_file, "r")
|
||||
lines = inout_nodes_file.readlines()
|
||||
inout_nodes_file.close()
|
||||
else:
|
||||
print("1DFlow inout nodes file not found: " + self.fluid_inout_nodes_file)
|
||||
# get nodes
|
||||
self.get_constraints_fluidsection_nodes()
|
||||
for femobj in self.fluidsection_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
|
||||
|
||||
@@ -1494,7 +1494,7 @@ def write_D_network_element_to_inputfile(fileName):
|
||||
f.close()
|
||||
|
||||
|
||||
def use_correct_fluidinout_ele_def(FluidInletoutlet_ele, fileName):
|
||||
def use_correct_fluidinout_ele_def(FluidInletoutlet_ele, fileName, fluid_inout_nodes_file):
|
||||
f = open(fileName, 'r')
|
||||
cnt = 0
|
||||
line = f.readline()
|
||||
@@ -1523,7 +1523,8 @@ def use_correct_fluidinout_ele_def(FluidInletoutlet_ele, fileName):
|
||||
f.seek(0)
|
||||
cnt = 0
|
||||
elem_counter = 0
|
||||
inout_nodes_file = open("inout_nodes.txt", "w")
|
||||
print('1DFlow inout nodes file: ' + fluid_inout_nodes_file + '\n')
|
||||
inout_nodes_file = open(fluid_inout_nodes_file, "w")
|
||||
for line in lines:
|
||||
new_line = ''
|
||||
for i in range(len(FluidInletoutlet_ele)):
|
||||
|
||||
@@ -124,15 +124,16 @@ def importFrd(filename, analysis=None, result_name_prefix=None):
|
||||
def readResult(frd_input):
|
||||
print('Read results from: ' + frd_input)
|
||||
inout_nodes = []
|
||||
if os.path.exists("inout_nodes.txt"):
|
||||
print('We have found a inout_nodes.txt file. We gone read it and delete it afterwards')
|
||||
f = pyopen("inout_nodes.txt", "r")
|
||||
inout_nodes_file = frd_input.rsplit('.', 1)[0] + '_inout_nodes.txt'
|
||||
if os.path.exists(inout_nodes_file):
|
||||
print('Read special 1DFlow nodes data form: ' + inout_nodes_file)
|
||||
f = pyopen(inout_nodes_file, "r")
|
||||
lines = f.readlines()
|
||||
for line in lines:
|
||||
a = line.split(',')
|
||||
inout_nodes.append(a)
|
||||
f.close()
|
||||
os.remove("inout_nodes.txt")
|
||||
print(inout_nodes)
|
||||
frd_file = pyopen(frd_input, "r")
|
||||
nodes = {}
|
||||
elements_hexa8 = {}
|
||||
|
||||
Reference in New Issue
Block a user