def run(self): self.pushStatus("Preparing solver input...\n") # get mesh set data # TODO see calculix tasks get mesh set data mesh_obj = membertools.get_mesh_to_solve( self.analysis)[0] # pre check done already meshdatagetter = meshsetsgetter.MeshSetsGetter( self.analysis, self.solver, mesh_obj, membertools.AnalysisMember(self.analysis), ) meshdatagetter.get_mesh_sets() # write solver input w = writer.FemInputWriterZ88(self.analysis, self.solver, mesh_obj, meshdatagetter.member, self.directory) path = w.write_solver_input() # report to user if task succeeded if path is not None: self.pushStatus("Writing solver input completed.") else: self.pushStatus("Writing solver input failed.") self.fail()
def run(self): global _inputFileName self.pushStatus("Preparing input...\n") # get mesh set data # TODO evaluate if it makes sense to add new task # between check and prepare to the solver frame work mesh_obj = membertools.get_mesh_to_solve(self.analysis)[0] # pre check done already meshdatagetter = meshsetsgetter.MeshSetsGetter( self.analysis, self.solver, mesh_obj, membertools.AnalysisMember(self.analysis), ) meshdatagetter.get_mesh_sets() # write solver input w = writer.FemInputWriterCcx( self.analysis, self.solver, mesh_obj, meshdatagetter.member, self.directory, meshdatagetter.mat_geo_sets ) path = w.write_solver_input() # report to user if task succeeded if path != "" and os.path.isfile(path): self.pushStatus("Writing solver input completed.") else: self.pushStatus("Writing solver input failed.") self.fail() _inputFileName = os.path.splitext(os.path.basename(path))[0]
def write_inp_file(self): # get mesh set data # TODO use separate method for getting the mesh set data from femmesh import meshsetsgetter meshdatagetter = meshsetsgetter.MeshSetsGetter( self.analysis, self.solver, self.mesh, membertools.AnalysisMember(self.analysis), ) # save the sets into the member objects of the instanz meshdatagetter meshdatagetter.get_mesh_sets() # write input file import femsolver.calculix.writer as iw self.inp_file_name = "" try: inp_writer = iw.FemInputWriterCcx( self.analysis, self.solver, self.mesh, meshdatagetter.member, self.working_dir, meshdatagetter.mat_geo_sets ) self.inp_file_name = inp_writer.write_solver_input() except Exception: FreeCAD.Console.PrintError( "Unexpected error when writing CalculiX input file: {}\n" .format(sys.exc_info()[1]) ) raise
def __init__(self, analysis_obj, solver_obj, mesh_obj, member, dir_name=None, mat_geo_sets=None): # class attributes from parameter values self.analysis = analysis_obj self.solver_obj = solver_obj self.mesh_object = mesh_obj self.member = member # more attributes self.analysis_type = self.solver_obj.AnalysisType self.document = self.analysis.Document # working dir self.dir_name = dir_name # if dir_name was not given or if it exists but is not empty: create a temporary dir # Purpose: makes sure the analysis can be run even on wired situation if not dir_name: FreeCAD.Console.PrintWarning( "Error: FemInputWriter has no working_dir --> " "we are going to make a temporary one!\n") self.dir_name = self.document.TransientDir.replace( "\\", "/") + "/FemAnl_" + analysis_obj.Uid[-4:] if not os.path.isdir(self.dir_name): os.mkdir(self.dir_name) # new class attributes self.fc_ver = FreeCAD.Version() self.ccx_nall = "Nall" self.ccx_eall = "Eall" self.ccx_evolumes = "Evolumes" self.ccx_efaces = "Efaces" self.ccx_eedges = "Eedges" self.mat_geo_sets = mat_geo_sets if self.mesh_object: self.femmesh = self.mesh_object.FemMesh else: FreeCAD.Console.PrintWarning( "No finite element mesh object was given to the writer class. " "In rare cases this might not be an error. ") # ************************************************* # deprecated, leave for compatibility reasons # if these are calculated here they are calculated twice :-( self.femnodes_mesh = {} self.femelement_table = {} self.constraint_conflict_nodes = [] self.femnodes_ele_table = {} self.femelements_edges_only = [] self.femelements_faces_only = [] self.femelement_volumes_table = {} self.femelement_faces_table = {} self.femelement_edges_table = {} self.femelement_count_test = True # deprecated, leave for compatibility reasons # do not add new objects # only the ones which exists on 0.19 release are kept # materials self.material_objects = member.mats_linear self.material_nonlinear_objects = member.mats_nonlinear # geometries self.beamsection_objects = member.geos_beamsection self.beamrotation_objects = member.geos_beamrotation self.fluidsection_objects = member.geos_fluidsection self.shellthickness_objects = member.geos_shellthickness # constraints self.contact_objects = member.cons_contact self.displacement_objects = member.cons_displacement self.fixed_objects = member.cons_fixed self.force_objects = member.cons_force self.heatflux_objects = member.cons_heatflux self.initialtemperature_objects = member.cons_initialtemperature self.planerotation_objects = member.cons_planerotation self.pressure_objects = member.cons_pressure self.selfweight_objects = member.cons_selfweight self.temperature_objects = member.cons_temperature self.tie_objects = member.cons_tie self.transform_objects = member.cons_transform # meshdatagetter, for compatibility, same with all getter methods self.meshdatagetter = meshsetsgetter.MeshSetsGetter( self.analysis, self.solver_obj, self.mesh_object, self.member, )
def __init__(self, analysis_obj, solver_obj, mesh_obj, member, dir_name=None, mat_geo_sets=None): # class attributes from parameter values self.analysis = analysis_obj self.solver_obj = solver_obj self.mesh_object = mesh_obj self.member = member # more attributes self.analysis_type = self.solver_obj.AnalysisType self.document = self.analysis.Document # working dir # if dir_name was not given or if it exists but is not empty: create a temporary dir # Purpose: makes sure the analysis can be run even on wired situation make_tmp_dir = False if dir_name is None: FreeCAD.Console.PrintWarning( "Error: The working_dir in base input file writer class was not set. " "A temporary directory is used.\n") make_tmp_dir = True elif not os.path.isdir(dir_name): FreeCAD.Console.PrintWarning( "Error: The working_dir: '{}' given to " "base input file writer class does not exist. " "A temporary directory is used.\n".format(dir_name)) make_tmp_dir = True if make_tmp_dir is True: from tempfile import mkdtemp dir_name = mkdtemp(prefix="fcfem_") FreeCAD.Console.PrintWarning( "The working directory '{}' was created and will be used.". format(dir_name)) self.dir_name = dir_name # new class attributes self.fc_ver = FreeCAD.Version() self.ccx_nall = "Nall" self.ccx_eall = "Eall" self.ccx_evolumes = "Evolumes" self.ccx_efaces = "Efaces" self.ccx_eedges = "Eedges" self.mat_geo_sets = mat_geo_sets if self.mesh_object: self.femmesh = self.mesh_object.FemMesh else: FreeCAD.Console.PrintWarning( "No finite element mesh object was given to the writer class. " "In rare cases this might not be an error. ") # ************************************************* # deprecated, leave for compatibility reasons # if these are calculated here they are calculated twice :-( self.femnodes_mesh = {} self.femelement_table = {} self.constraint_conflict_nodes = [] self.femnodes_ele_table = {} self.femelements_edges_only = [] self.femelements_faces_only = [] self.femelement_volumes_table = {} self.femelement_faces_table = {} self.femelement_edges_table = {} self.femelement_count_test = True # deprecated, leave for compatibility reasons # do not add new objects # only the ones which exists on 0.19 release are kept # materials self.material_objects = member.mats_linear self.material_nonlinear_objects = member.mats_nonlinear # geometries self.beamsection_objects = member.geos_beamsection self.beamrotation_objects = member.geos_beamrotation self.fluidsection_objects = member.geos_fluidsection self.shellthickness_objects = member.geos_shellthickness # constraints self.contact_objects = member.cons_contact self.displacement_objects = member.cons_displacement self.fixed_objects = member.cons_fixed self.force_objects = member.cons_force self.heatflux_objects = member.cons_heatflux self.initialtemperature_objects = member.cons_initialtemperature self.planerotation_objects = member.cons_planerotation self.pressure_objects = member.cons_pressure self.selfweight_objects = member.cons_selfweight self.temperature_objects = member.cons_temperature self.tie_objects = member.cons_tie self.transform_objects = member.cons_transform # meshdatagetter, for compatibility, same with all getter methods self.meshdatagetter = meshsetsgetter.MeshSetsGetter( self.analysis, self.solver_obj, self.mesh_object, self.member, )