Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 2 additions & 69 deletions kratos.gid/apps/Dam/python/MainKratos.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ def __init__(self, model):
self.DefineParallelType()
self.DefineVariables()

if self.consider_selfweight:
self.model_selfweight = KratosMultiphysics.Model()
self.PreviousSelfweightProblem()

self.CreateModelPart()

if self.add_previous_results:
Expand Down Expand Up @@ -64,7 +60,6 @@ def DefineVariables(self):
self.problem_path = os.getcwd()
self.echo_level = self.ProjectParameters["solver_settings"]["echo_level"].GetInt()
self.buffer_size = self.ProjectParameters["solver_settings"]["buffer_size"].GetInt()
self.consider_selfweight = self.ProjectParameters["problem_data"]["consider_selfweight"].GetBool()
self.consider_construction = self.ProjectParameters["problem_data"]["consider_construction"].GetBool()
self.use_streamline_utility = self.ProjectParameters["problem_data"]["streamlines_utility"].GetBool()
self.delta_time = self.ProjectParameters["problem_data"]["time_step"].GetDouble()
Expand Down Expand Up @@ -131,64 +126,6 @@ def SetSolver(self):
solver_module = import_module(full_module_name)
self.solver = solver_module.CreateSolver(self.main_model_part, self.ProjectParameters["solver_settings"])

def PreviousSelfweightProblem(self):
# Parsing parmeters of Selfweight Problem
self_parameter_file = open("ProjectParametersSelfWeight.json",'r')
SelfWeightProjectParameters = KratosMultiphysics.Parameters( self_parameter_file.read())

## Creating Selfweight model part --------------------------------------------------------------
self.self_weight_model_part = self.model_selfweight.CreateModelPart("SelfWeight")
self.self_weight_model_part.ProcessInfo.SetValue(KratosMultiphysics.DOMAIN_SIZE, self.domain_size)
self.self_weight_model_part.ProcessInfo.SetValue(KratosMultiphysics.TIME, self.time)
self.self_weight_model_part.ProcessInfo.SetValue(KratosMultiphysics.DELTA_TIME, self.delta_time)
self.self_weight_model_part.ProcessInfo.SetValue(KratosDam.TIME_UNIT_CONVERTER, self.time_unit_converter)

## Construct the solver for selfweight problem -------------------------------------------------
selfweight_solver_module = __import__(SelfWeightProjectParameters["solver_settings"]["solver_type"].GetString())
selfweight_solver = selfweight_solver_module.CreateSolver(self.self_weight_model_part, SelfWeightProjectParameters["solver_settings"])
selfweight_solver.AddVariables()
selfweight_solver.ImportModelPart()
selfweight_solver.AddDofs()

## Kratos Selfweight Model ---------------------------------------------------------------------
#DamSelfWeightModel = KratosMultiphysics.Model()
#DamSelfWeightModel.AddModelPart(self.self_weight_model_part)

## Initialize ----------------------------------------------------------------------------------

# Construct processes to be applied
import KratosMultiphysics.process_factory
self_list_of_processes = process_factory.KratosProcessFactory(DamSelfWeightModel).ConstructListOfProcesses( SelfWeightProjectParameters["constraints_process_list"] )
self_list_of_processes += process_factory.KratosProcessFactory(DamSelfWeightModel).ConstructListOfProcesses( SelfWeightProjectParameters["loads_process_list"] )

# Initialize processes
for process in self_list_of_processes:
process.ExecuteInitialize()

# Set TIME and DELTA_TIME and fill the previous steps of the buffer with the initial conditions
self_time = self.time - (self.buffer_size-1) * self.delta_time
self.self_weight_model_part.ProcessInfo.SetValue(KratosMultiphysics.TIME, self.time)
for step in range(self.buffer_size-1):
self_time = self_time + self.delta_time
self.self_weight_model_part.CloneTimeStep(self_time)

# Initialize the solver
selfweight_solver.Initialize()

# ExecuteBeforeSolutionLoop
for process in self_list_of_processes:
process.ExecuteBeforeSolutionLoop()

# Solving selfweight problem
selfweight_solver.Solve()

# Cleaning selfweight solver
selfweight_solver.Clear()

# Initialize transfer_selfweight_stress_utility
from KratosMultiphysics.DamApplication import transfer_selfweight_stress_utility
self.transfer_utility = transfer_selfweight_stress_utility.TransferSelfweightStressToMainModelPartUtility()

def Run(self):
self.Initialize()

Expand Down Expand Up @@ -360,15 +297,11 @@ def RunMainTemporalLoop(self):
for self.process in self.list_of_processes:
self.process.ExecuteBeforeOutputStep()

# selfweight utility
if self.consider_selfweight:
self.transfer_utility.Transfer(self.self_weight_model_part, self.main_model_part, self.domain_size)

# add previous results utility
if self.add_previous_results and self.add_stress:
if self.type_of_results == "Mechanical" or self.type_of_results == "Thermo-Mechanical":
from KratosMultiphysics.DamApplication import transfer_selfweight_stress_utility
self.transfer_utility = transfer_selfweight_stress_utility.TransferSelfweightStressToMainModelPartUtility()
from KratosMultiphysics.DamApplication import transfer_initial_stress_utility
self.transfer_utility = transfer_initial_stress_utility.TransferInitialStressToMainModelPartUtility()
self.transfer_utility.TransferInitialStress(self.main_model_part, self.domain_size)

# Write GiD results
Expand Down
Loading