def __init__(self, problem_name, path, read_model_part=True): #setting the domain size for the problem to be solved self.domain_size = 3 ################################################################## ## DEFINE MODELPART ############################################## ################################################################## self.model_part = ModelPart("ekate_simulation") self.path = path self.problem_name = problem_name ################################################################## ## DEFINE SOLVER ################################################# ################################################################## # reading simulation parameters number_of_time_steps = 1 self.analysis_parameters = {} # content of analysis_parameters: # perform_contact_analysis_flag # penalty value for normal contact # maximum number of uzawa iterations # friction coefficient # penalty value for frictional contact # contact_double_check_flag # contact_ramp_penalties_flag # maximum penalty value for normal contact # ramp criterion for normal contact # ramp factor for normal contact # maximum penalty value for frictional contact # ramp criterion for frictional contact # ramp factor for frictional contact # analysis type: static (0), quasi-static (1) or dynamic (2) perform_contact_analysis_flag = False penalty = 0.0 maxuzawa = 0.0 friction = 0.0 frictionpenalty = 0.0 contact_double_check_flag = False contact_ramp_penalties_flag = False maxpenalty = 0.0 rampcriterion = 0.0 rampfactor = 0.0 fricmaxpenalty = 0.0 fricrampcriterion = 0.0 fricrampfactor = 0.0 self.analysis_parameters[ 'perform_contact_analysis_flag'] = perform_contact_analysis_flag self.analysis_parameters['penalty'] = penalty self.analysis_parameters['maxuzawa'] = maxuzawa self.analysis_parameters['friction'] = friction self.analysis_parameters['frictionpenalty'] = frictionpenalty self.analysis_parameters[ 'contact_double_check_flag'] = contact_double_check_flag self.analysis_parameters[ 'contact_ramp_penalties_flag'] = contact_ramp_penalties_flag self.analysis_parameters['maxpenalty'] = maxpenalty self.analysis_parameters['rampcriterion'] = rampcriterion self.analysis_parameters['rampfactor'] = rampfactor self.analysis_parameters['fricmaxpenalty'] = fricmaxpenalty self.analysis_parameters['fricrampcriterion'] = fricrampcriterion self.analysis_parameters['fricrampfactor'] = fricrampfactor self.analysis_parameters['print_sparsity_info_flag'] = False self.analysis_parameters['analysis_type'] = 0 self.analysis_parameters['dissipation_radius'] = 0.1 self.analysis_parameters['decouple_build_and_solve'] = False self.analysis_parameters['solving_scheme'] = 'monolithic' self.analysis_parameters['stop_Newton_Raphson_if_not_converge'] = True self.abs_tol = 1e-6 self.rel_tol = 1e-10 #self.rel_tol = 1e-10 ## generating solver import structural_solver_advanced self.solver = structural_solver_advanced.SolverAdvanced( self.model_part, self.domain_size, number_of_time_steps, self.analysis_parameters, self.abs_tol, self.rel_tol) #import ekate_solver_parallel #self.solver = ekate_solver_parallel.EkateSolver( self.model_part, self.domain_size, number_of_time_steps, self.analysis_parameters, self.abs_tol, self.rel_tol ) structural_solver_advanced.AddVariables(self.model_part) #ekate_solver_parallel.AddVariables( self.model_part ) ################################################################## ## READ MODELPART ################################################ ################################################################## #reading a model write_deformed_flag = WriteDeformedMeshFlag.WriteUndeformed write_elements = WriteConditionsFlag.WriteConditions #write_elements = WriteConditionsFlag.WriteElementsOnly post_mode = GiDPostMode.GiD_PostBinary multi_file_flag = MultiFileFlag.MultipleFiles self.gid_io = StructuralGidIO(self.path + self.problem_name, post_mode, multi_file_flag, write_deformed_flag, write_elements) if read_model_part: self.model_part_io = ModelPartIO(self.path + self.problem_name) self.model_part_io.ReadModelPart(self.model_part) self.meshWritten = False (self.solver).CalculateReactionFlag = False ## READ DEACTIVATION FILE ######################################## if read_model_part: self.cond_file = open(self.path + self.problem_name + ".mdpa", 'r') self.cond_activation_flags = [] self.element_assignments = {} for line in self.cond_file: if "//ElementAssignment" in line: val_set = line.split(' ') self.model_part.Conditions[int(val_set[1])].SetValue( ACTIVATION_LEVEL, self.model_part.Elements[int( val_set[2])].GetValue(ACTIVATION_LEVEL)) #print( "assigning ACTIVATION_LEVEL of element: " +str(int(val_set[2])) + " to Condition: " + str(int(val_set[1])) + " as " + str(self.model_part.Elements[int(val_set[2])].GetValue(ACTIVATION_LEVEL)) ) self.element_assignments[int(val_set[1])] = int(val_set[2]) print "input data read OK" #print "+++++++++++++++++++++++++++++++++++++++" #for node in self.model_part.Nodes: # print node #print "+++++++++++++++++++++++++++++++++++++++" #the buffer size should be set up here after the mesh is read for the first time self.model_part.SetBufferSize(2) ################################################################## ## ADD DOFS ###################################################### ################################################################## structural_solver_advanced.AddDofs(self.model_part) #ekate_solver_parallel.AddDofs( self.model_part ) ################################################################## ## INITIALISE SOLVER FOR PARTICULAR SOLUTION ##################### ################################################################## #defining linear solver plinear_solver = DiagonalFitSolver(MKLPardisoSolver()) self.solver.structure_linear_solver = plinear_solver self.solver.Initialize() (self.solver.solver).SetEchoLevel(2) ( self.solver.solver ).max_iter = 10 #control the maximum iterations of Newton Raphson loop (self.solver.solver).MoveMeshFlag = False
def __init__(self, problem_name, path): #setting the domain size for the problem to be solved self.domain_size = 3 ################################################################## ## DEFINE MODELPART ############################################## ################################################################## self.model_part = ModelPart("isogeometric_simulation") self.model_part_post = ModelPart("isogeometric_mesh") self.path = path self.problem_name = problem_name ################################################################## ## DEFINE SOLVER ################################################# ################################################################## # reading simulation parameters number_of_time_steps = 1 self.analysis_parameters = [] # content of analysis_parameters: # perform_contact_analysis_flag # penalty value for normal contact # maximum number of uzawa iterations # friction coefficient # penalty value for frictional contact # contact_double_check_flag # contact_ramp_penalties_flag # maximum penalty value for normal contact # ramp criterion for normal contact # ramp factor for normal contact # maximum penalty value for frictional contact # ramp criterion for frictional contact # ramp factor for frictional contact # analysis type: static (0), quasi-static (1) or dynamic (2) perform_contact_analysis_flag = False penalty = 0.0 maxuzawa = 0.0 friction = 0.0 frictionpenalty = 0.0 contact_double_check_flag = False contact_ramp_penalties_flag = False maxpenalty = 0.0 rampcriterion = 0.0 rampfactor = 0.0 fricmaxpenalty = 0.0 fricrampcriterion = 0.0 fricrampfactor = 0.0 self.analysis_parameters.append(perform_contact_analysis_flag) self.analysis_parameters.append(penalty) self.analysis_parameters.append(maxuzawa) self.analysis_parameters.append(friction) self.analysis_parameters.append(frictionpenalty) self.analysis_parameters.append(contact_double_check_flag) self.analysis_parameters.append(contact_ramp_penalties_flag) self.analysis_parameters.append(maxpenalty) self.analysis_parameters.append(rampcriterion) self.analysis_parameters.append(rampfactor) self.analysis_parameters.append(fricmaxpenalty) self.analysis_parameters.append(fricrampcriterion) self.analysis_parameters.append(fricrampfactor) #PrintSparsityInfoFlag self.analysis_parameters.append(False) self.analysis_parameters.append(0) abs_tol = 1.0e-10 rel_tol = 1e-6 ## generating solver import structural_solver_advanced self.solver = structural_solver_advanced.SolverAdvanced( self.model_part, self.domain_size, number_of_time_steps, self.analysis_parameters, abs_tol, rel_tol) structural_solver_advanced.AddVariables(self.model_part) self.model_part.AddNodalSolutionStepVariable(STRESSES) self.model_part_post.AddNodalSolutionStepVariable(DISPLACEMENT) self.model_part_post.AddNodalSolutionStepVariable(REACTION) self.model_part_post.AddNodalSolutionStepVariable(STRESSES) ################################################################## ## READ MODELPART ################################################ ################################################################## #reading a model write_deformed_flag = WriteDeformedMeshFlag.WriteUndeformed write_elements = WriteConditionsFlag.WriteConditions #write_elements = WriteConditionsFlag.WriteElementsOnly post_mode = GiDPostMode.GiD_PostAscii multi_file_flag = MultiFileFlag.MultipleFiles self.gid_io = StructuralGidIO(self.path + self.problem_name, post_mode, multi_file_flag, write_deformed_flag, write_elements) self.model_part_io = BezierModelPartIO(self.path + self.problem_name) self.model_part_io.ReadModelPart(self.model_part) self.isogeometric_post_utility = IsogeometricClassicalPostUtility( self.model_part) self.generate_post_model_part = False self.meshWritten = True self.solver.CalculateReactionFlag = True ## READ DEACTIVATION FILE ######################################## self.cond_file = open(self.path + self.problem_name + ".mdpa", 'r') self.cond_activation_flags = [] for line in self.cond_file: if "//ElementAssignment" in line: val_set = line.split(' ') self.model_part.Conditions[int(val_set[1])].SetValue( ACTIVATION_LEVEL, self.model_part.Elements[int( val_set[2])].GetValue(ACTIVATION_LEVEL)) print("assigning ACTIVATION_LEVEL of element: " + str(int(val_set[2])) + " to Condition: " + str(int(val_set[1])) + " as " + str(self.model_part.Elements[int(val_set[2])].GetValue( ACTIVATION_LEVEL))) print("input data read OK") #print "+++++++++++++++++++++++++++++++++++++++" #for node in self.model_part.Nodes: #print node #print "+++++++++++++++++++++++++++++++++++++++" #the buffer size should be set up here after the mesh is read for the first time self.model_part.SetBufferSize(2) ################################################################## ## ADD DOFS ###################################################### ################################################################## structural_solver_advanced.AddDofs(self.model_part) structural_solver_advanced.AddDofs(self.model_part_post) #ekate_solver_parallel.AddDofs( self.model_part ) ################################################################## ## INITIALISE SOLVER FOR PARTICULAR SOLUTION ##################### ################################################################## #defining linear solver plinear_solver = SkylineLUFactorizationSolver() self.solver.structure_linear_solver = plinear_solver self.solver.Initialize() (self.solver.solver).SetEchoLevel(2) #defined linear solver for post-processing # self.solver_post = SkylineLUFactorizationSolver() self.solver_post = SkylineLUFactorizationSolver()
def __init__(self, problem_name, path): # setting the domain size for the problem to be solved self.domain_size = 3 # # DEFINE MODELPART ############################################## # self.model_part = ModelPart("ekate_simulation") self.path = path self.problem_name = problem_name # # DEFINE SOLVER ################################################# # # reading simulation parameters number_of_time_steps = 1 self.analysis_parameters = [] # content of analysis_parameters: # perform_contact_analysis_flag # penalty value for normal contact # maximum number of uzawa iterations # friction coefficient # penalty value for frictional contact # contact_double_check_flag # contact_ramp_penalties_flag # maximum penalty value for normal contact # ramp criterion for normal contact # ramp factor for normal contact # maximum penalty value for frictional contact # ramp criterion for frictional contact # ramp factor for frictional contact perform_contact_analysis_flag = True # performing contact analysis: reading contact parameters penalty = 1e+10 maxuzawa = 25 friction = 0 frictionpenalty = 1e+05 contact_double_check_flag = False contact_ramp_penalties_flag = False maxpenalty = penalty rampcriterion = 0.0 rampfactor = 0.0 fricmaxpenalty = penalty fricrampcriterion = 0.0 fricrampfactor = 0.0 self.analysis_parameters.append(perform_contact_analysis_flag) self.analysis_parameters.append(penalty) self.analysis_parameters.append(maxuzawa) self.analysis_parameters.append(friction) self.analysis_parameters.append(frictionpenalty) self.analysis_parameters.append(contact_double_check_flag) self.analysis_parameters.append(contact_ramp_penalties_flag) self.analysis_parameters.append(maxpenalty) self.analysis_parameters.append(rampcriterion) self.analysis_parameters.append(rampfactor) self.analysis_parameters.append(fricmaxpenalty) self.analysis_parameters.append(fricrampcriterion) self.analysis_parameters.append(fricrampfactor) self.analysis_parameters.append(False) abs_tol = 1e-06 rel_tol = 0.0001 # generating solver import structural_solver_advanced self.solver = structural_solver_advanced.SolverAdvanced( self.model_part, self.domain_size, number_of_time_steps, self.analysis_parameters, abs_tol, rel_tol, kratos_applications_path) structural_solver_advanced.AddVariables(self.model_part) # # READ MODELPART ################################################ # # reading a model write_deformed_flag = WriteDeformedMeshFlag.WriteUndeformed write_elements = WriteConditionsFlag.WriteElementsOnly post_mode = GiDPostMode.GiD_PostBinary multi_file_flag = MultiFileFlag.SingleFile self.gid_io = StructuralGidIO(self.path + self.problem_name, post_mode, multi_file_flag, write_deformed_flag, write_elements) # Reading and partitioning number_of_partitions = mpi.size # we set it equal to the number of processors contact_indices = IndicesVector() contact_indices[:] = [1, 2, 3, 6, 7, 11, 12] metis_partitioning_process = MetisContactPartitioningProcess( model_part, gid_io, number_of_partitions, contact_indices) self.gid_io.ReadModelPart(self.model_part) self.meshWritten = False # READ DEACTIVATION FILE ######################################## self.deac_file = open(self.path + self.problem_name + ".deac", 'r') self.activation_flags = [0] for line in self.deac_file: val_set = line.split(' ') elem_num = int(val_set[0]) act_level = int(val_set[1]) self.activation_flags.append(act_level) print("input data read OK") # print "+++++++++++++++++++++++++++++++++++++++" # for node in self.model_part.Nodes: # print node # print "+++++++++++++++++++++++++++++++++++++++" # the buffer size should be set up here after the mesh is read for the first time self.model_part.SetBufferSize(2) # # ADD DOFS ###################################################### # structural_solver_advanced.AddDofs(self.model_part) # # INITIALISE SOLVER FOR PARTICULAR SOLUTION ##################### # # defining linear solver plinear_solver = SkylineLUFactorizationSolver() self.solver.structure_linear_solver = plinear_solver self.solver.Initialize() (self.solver.solver).SetEchoLevel(2)
def __init__(self, problem_name, path): # setting the domain size for the problem to be solved self.domain_size = 3 # # DEFINE MODELPART ############################################## # self.model_part = ModelPart("ekate_simulation") self.path = path self.problem_name = problem_name # # DEFINE SOLVER ################################################# # # reading simulation parameters number_of_time_steps = 10 self.analysis_parameters = [] # content of analysis_parameters: # perform_contact_analysis_flag # penalty value for normal contact # maximum number of uzawa iterations # friction coefficient # penalty value for frictional contact # contact_double_check_flag # contact_ramp_penalties_flag # maximum penalty value for normal contact # ramp criterion for normal contact # ramp factor for normal contact # maximum penalty value for frictional contact # ramp criterion for frictional contact # ramp factor for frictional contact perform_contact_analysis_flag = False penalty = 0.0 maxuzawa = 0.0 friction = 0.0 frictionpenalty = 0.0 contact_double_check_flag = False contact_ramp_penalties_flag = False maxpenalty = 0.0 rampcriterion = 0.0 rampfactor = 0.0 fricmaxpenalty = 0.0 fricrampcriterion = 0.0 fricrampfactor = 0.0 self.analysis_parameters.append(perform_contact_analysis_flag) self.analysis_parameters.append(penalty) self.analysis_parameters.append(maxuzawa) self.analysis_parameters.append(friction) self.analysis_parameters.append(frictionpenalty) self.analysis_parameters.append(contact_double_check_flag) self.analysis_parameters.append(contact_ramp_penalties_flag) self.analysis_parameters.append(maxpenalty) self.analysis_parameters.append(rampcriterion) self.analysis_parameters.append(rampfactor) self.analysis_parameters.append(fricmaxpenalty) self.analysis_parameters.append(fricrampcriterion) self.analysis_parameters.append(fricrampfactor) # PrintSparsityInfoFlag self.analysis_parameters.append(False) abs_tol = 1e-06 # rel_tol = 0.0001 rel_tol = 1e-10 # generating solver import structural_solver_advanced self.solver = structural_solver_advanced.SolverAdvanced(self.model_part, self.domain_size, number_of_time_steps, self.analysis_parameters, abs_tol, rel_tol) # import ekate_solver_parallel # self.solver = ekate_solver_parallel.EkateSolver( self.model_part, self.domain_size, number_of_time_steps, self.analysis_parameters, abs_tol, rel_tol ) structural_solver_advanced.AddVariables(self.model_part) # ekate_solver_parallel.AddVariables( self.model_part ) # # READ MODELPART ################################################ # # reading a model write_deformed_flag = WriteDeformedMeshFlag.WriteUndeformed write_elements = WriteConditionsFlag.WriteConditions # write_elements = WriteConditionsFlag.WriteElementsOnly post_mode = GiDPostMode.GiD_PostBinary multi_file_flag = MultiFileFlag.MultipleFiles self.gid_io = StructuralGidIO(self.path + self.problem_name, post_mode, multi_file_flag, write_deformed_flag, write_elements) self.model_part_io = ModelPartIO(self.path + self.problem_name) self.model_part_io.ReadModelPart(self.model_part) self.meshWritten = False # READ DEACTIVATION FILE ######################################## self.cond_file = open(self.path + self.problem_name + ".mdpa", 'r') self.cond_activation_flags = [] for line in self.cond_file: if "//ElementAssignment" in line: val_set = line.split(' ') self.model_part.Conditions[int(val_set[1])].SetValue(ACTIVATION_LEVEL, self.model_part.Elements[int(val_set[2])].GetValue(ACTIVATION_LEVEL)) # print( "assigning ACTIVATION_LEVEL of element: " +str(int(val_set[2])) + " to Condition: " + str(int(val_set[1])) + " as " + str(self.model_part.Elements[int(val_set[2])].GetValue(ACTIVATION_LEVEL)) ) print("input data read OK") # print "+++++++++++++++++++++++++++++++++++++++" # for node in self.model_part.Nodes: # print node # print "+++++++++++++++++++++++++++++++++++++++" # the buffer size should be set up here after the mesh is read for the first time self.model_part.SetBufferSize(2) # # ADD DOFS ###################################################### # for node in self.model_part.Nodes: node.AddDof(WATER_PRESSURE) structural_solver_advanced.AddDofs(self.model_part) # ekate_solver_parallel.AddDofs( self.model_part ) # # INITIALISE SOLVER FOR PARTICULAR SOLUTION ##################### # # defining linear solver plinear_solver = MKLPardisoSolver() # plinear_solver = ParallelMKLPardisoSolver() self.solver.structure_linear_solver = plinear_solver self.solver.Initialize() (self.solver.solver).SetEchoLevel(2);