From c4ba58b41045269b4777219b908b173e9f427bb7 Mon Sep 17 00:00:00 2001 From: BasselSaridar Date: Tue, 10 Dec 2019 18:53:19 +0100 Subject: [PATCH 001/314] Empire Application tot CoSimulation Migration --- .../kratos/potential_flow_wrapper.py | 59 +++++ .../sdof/sdof_static_solver.py | 147 ++++++++++++ .../sdof/static_sdof_solver_wrapper.py | 27 +++ .../ProjectParametersSDoF.json | 19 ++ .../tests/fsi_sdof_static/naca0012_small.mdpa | 210 ++++++++++++++++++ .../naca0012_small_parameters_coupling.json | 159 +++++++++++++ ...ct_paramters_cosim_naca0012_small_fsi.json | 86 +++++++ .../tests/fsi_sdof_static/results.dat | 2 + .../fsi_sdof_static/results_final_sdof.dat | 2 + .../ref_sdof_static_final_displacement.dat | 3 + .../ref_sdof_static_initial_displacement.dat | 2 + .../tests/test_CoSimulationApplication.py | 2 + .../tests/test_sdof_static_solver.py | 94 ++++++++ 13 files changed, 812 insertions(+) create mode 100644 applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/potential_flow_wrapper.py create mode 100644 applications/CoSimulationApplication/python_scripts/solver_wrappers/sdof/sdof_static_solver.py create mode 100644 applications/CoSimulationApplication/python_scripts/solver_wrappers/sdof/static_sdof_solver_wrapper.py create mode 100644 applications/CoSimulationApplication/tests/fsi_sdof_static/ProjectParametersSDoF.json create mode 100644 applications/CoSimulationApplication/tests/fsi_sdof_static/naca0012_small.mdpa create mode 100644 applications/CoSimulationApplication/tests/fsi_sdof_static/naca0012_small_parameters_coupling.json create mode 100644 applications/CoSimulationApplication/tests/fsi_sdof_static/project_paramters_cosim_naca0012_small_fsi.json create mode 100644 applications/CoSimulationApplication/tests/fsi_sdof_static/results.dat create mode 100644 applications/CoSimulationApplication/tests/fsi_sdof_static/results_final_sdof.dat create mode 100644 applications/CoSimulationApplication/tests/reference_files/ref_sdof_static_final_displacement.dat create mode 100644 applications/CoSimulationApplication/tests/reference_files/ref_sdof_static_initial_displacement.dat create mode 100644 applications/CoSimulationApplication/tests/test_sdof_static_solver.py diff --git a/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/potential_flow_wrapper.py b/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/potential_flow_wrapper.py new file mode 100644 index 000000000000..965d0dcfe7af --- /dev/null +++ b/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/potential_flow_wrapper.py @@ -0,0 +1,59 @@ +from __future__ import print_function, absolute_import, division # makes KratosMultiphysics backward compatible with python 2.6 and 2.7 + +# Importing the Kratos Library +import KratosMultiphysics +from KratosMultiphysics.kratos_utilities import CheckIfApplicationsAvailable + +if not CheckIfApplicationsAvailable("CompressiblePotentialFlowApplication"): + raise ImportError("The CompressiblePotentialFlowApplication is not available!") +import KratosMultiphysics.CompressiblePotentialFlowApplication + +# Importing the base class +from KratosMultiphysics.CoSimulationApplication.solver_wrappers.kratos import kratos_base_wrapper + +# Other imports +from KratosMultiphysics.CompressiblePotentialFlowApplication.potential_flow_analysis import PotentialFlowAnalysis +from KratosMultiphysics.CompressiblePotentialFlowApplication.compute_forces_on_nodes_process import ComputeForcesOnNodesProcess +from KratosMultiphysics.CompressiblePotentialFlowApplication.define_wake_process_2d import DefineWakeProcess2D +from KratosMultiphysics.CompressiblePotentialFlowApplication.compute_lift_process import ComputeLiftProcess + +def Create(settings, solver_name): + return PotentialFlowWrapper(settings, solver_name) + +class PotentialFlowWrapper(kratos_base_wrapper.KratosBaseWrapper): + def _CreateAnalysisStage(self): + return PotentialFlowAnalysis(self.model, self.project_parameters) + + def AdvanceInTime(self, current_time): + self.time = 1.0 + return self.time + def Predict(self): + return + + def Initialize(self): + + super(PotentialFlowWrapper, self).Initialize() + + sub_project_parameters = self.project_parameters["processes"]["boundary_conditions_process_list"] + + for i in range(sub_project_parameters.size()): + if sub_project_parameters[i]["python_module"].GetString() == "define_wake_process_2d": + self.wake_process = DefineWakeProcess2D(self.model, sub_project_parameters[i]["Parameters"]) + if not hasattr(self, "wake_process"): + raise Exception("potential flow requires specification of a process for the wake (currently specifically using 'define_wake_process_2d')") + + if sub_project_parameters[i]["python_module"].GetString() == "compute_forces_on_nodes_process": + self.conversion_process = ComputeForcesOnNodesProcess(self.model, sub_project_parameters[i]["Parameters"]) + if sub_project_parameters[i]["python_module"].GetString() == "compute_lift_process": + self.lift_process = ComputeLiftProcess(self.model, sub_project_parameters[i]["Parameters"]) + + def SolveSolutionStep(self): + self.wake_process.ExecuteInitialize() + self._analysis_stage._GetSolver().fluid_solver.solver.Clear() + self._analysis_stage._GetSolver().fluid_solver.solver.InitializeSolutionStep() + super(PotentialFlowWrapper, self).SolveSolutionStep() + self.model["FluidModelPart"].CloneTimeStep(self.time) + self.model["FluidModelPart"].ProcessInfo[KratosMultiphysics.STEP] += 1 + + self.lift_process.ExecuteFinalizeSolutionStep() + self.conversion_process.ExecuteFinalizeSolutionStep() diff --git a/applications/CoSimulationApplication/python_scripts/solver_wrappers/sdof/sdof_static_solver.py b/applications/CoSimulationApplication/python_scripts/solver_wrappers/sdof/sdof_static_solver.py new file mode 100644 index 000000000000..0f0c5161c86b --- /dev/null +++ b/applications/CoSimulationApplication/python_scripts/solver_wrappers/sdof/sdof_static_solver.py @@ -0,0 +1,147 @@ +from __future__ import print_function, absolute_import, division # makes these scripts backward compatible with python 2.6 and 2.7 +# Importing the base class +import KratosMultiphysics +from KratosMultiphysics.CoSimulationApplication.function_callback_utility import GenericCallFunction + +# Other imports +import numpy as np +import json +import os + +class SDoFStaticSolver(object): + def __init__(self, input_name): + + # mimicing two constructors + if isinstance(input_name, dict): + parameters = input_name + + elif isinstance(input_name, str): + if not input_name.endswith(".json"): + input_name += ".json" + + with open(input_name,'r') as ProjectParameters: + parameters = json.load(ProjectParameters) + + else: + raise Exception("The input has to be provided as a dict or a string") + + default_settings = { + "system_parameters":{ + "stiffness" : 4000.0 + }, + "initial_values":{ + "displacement" : 0.0, + }, + "boundary_conditions":{ + "external_load" : 5000.0 + }, + "solver_parameters": { + "buffer_size" : 1 + }, + "output_parameters":{ + "write_output_file": False, + "file_name" : "sdof_static_solver/results_sdof.dat" + }} + + RecursivelyValidateAndAssignDefaults(default_settings, parameters) + + self.stiffness = parameters["system_parameters"]["stiffness"] + + self.initial_displacement = parameters["initial_values"]["displacement"] + + self.force = parameters["boundary_conditions"]["external_load"] + + self.buffer_size = parameters["solver_parameters"]["buffer_size"] + + self.output_file_name = parameters["output_parameters"]["file_name"] + + self.write_output_file = parameters["output_parameters"]["write_output_file"] + + def Initialize(self): + initial_values = self.initial_displacement + self.dx = initial_values + + if self.write_output_file: + if os.path.isfile(self.output_file_name): + os.remove(self.output_file_name) + self.InitializeOutput() + self.time = 0.0 + + def InitializeOutput(self): + with open(self.output_file_name, "w") as results_sdof_static: + results_sdof_static.write("displacement" + "\n") + self.OutputSolutionStep() + + def OutputSolutionStep(self): + if self.write_output_file: + with open(self.output_file_name, "a") as results_sdof_static: + #outputs results + results_sdof_static.write(str(self.dx) + "\n") + + def Predict(self): + return + + def AdvanceInTime(self, current_time): + self.time = 0.0 + return self.time + + def SolveSolutionStep(self): + self.dx = self.force/self.stiffness + KratosMultiphysics.Logger.PrintInfo('SDoFStaticSolver', 'Force Imported = ', self.force) + KratosMultiphysics.Logger.PrintInfo('SDoFStaticSolver', 'Structure Stiffness = ', self.stiffness) + KratosMultiphysics.Logger.PrintInfo('SDoFStaticSolver', 'New Displacement = ', self.dx) + + def CalculateReaction(self, buffer_idx=0): + reaction = self.stiffness * (self.dx) + return reaction + + def GetSolutionStepValue(self, identifier, buffer_idx=0): + if identifier == "DISPLACEMENT": + return self.dx + elif identifier == "REACTION": + return self.CalculateReaction() + else: + raise Exception("Identifier is unknown!") + + def SetSolutionStepValue(self, identifier, value, buffer_idx=0): + if identifier == "DISPLACEMENT": + self.dx= value + elif identifier == "LOAD": + self.force = 0.0 + self.force = value + else: + raise Exception("Identifier is unknown!") + +def ValidateAndAssignDefaults(defaults, settings, recursive=False): + for key, val in settings.items(): + # check if the current entry also exists in the defaults + if not key in defaults.keys(): + err_msg = 'The item with name "' + key + '" is present in this ' + err_msg += 'settings\nbut NOT in the defaults!\n' + err_msg += 'settings are:\n' + err_msg += json.dumps(settings, indent=4) + err_msg += '\ndefaults are:\n' + err_msg += json.dumps(defaults, indent=4) + raise Exception(err_msg) + + # check if the type is the same in the defaults + if type(settings[key]) != type(defaults[key]): + err_msg = 'The type of the item with name "' + key + '" (type: "' + err_msg += str(type(settings[key]).__name__)+'") in this ' + err_msg += 'settings\nis NOT the same as in the defaults (type: "' + err_msg += str(type(defaults[key]).__name__)+'")!\n' + err_msg += 'settings are:\n' + err_msg += json.dumps(settings, indent=4) + err_msg += '\ndefaults are:\n' + err_msg += json.dumps(defaults, indent=4) + raise Exception(err_msg) + + # loop the defaults and add the missing entries + for key_d, val_d in defaults.items(): + if key_d not in settings: # add the default in case the setting is not present + settings[key_d] = val_d + elif recursive and type(val_d) is dict: + RecursivelyValidateAndAssignDefaults(val_d, settings[key_d]) + +def RecursivelyValidateAndAssignDefaults(defaults, settings): + ValidateAndAssignDefaults(defaults, settings, recursive=True) diff --git a/applications/CoSimulationApplication/python_scripts/solver_wrappers/sdof/static_sdof_solver_wrapper.py b/applications/CoSimulationApplication/python_scripts/solver_wrappers/sdof/static_sdof_solver_wrapper.py new file mode 100644 index 000000000000..f590192408eb --- /dev/null +++ b/applications/CoSimulationApplication/python_scripts/solver_wrappers/sdof/static_sdof_solver_wrapper.py @@ -0,0 +1,27 @@ +from __future__ import print_function, absolute_import, division # makes KratosMultiphysics backward compatible with python 2.6 and 2.7 + +# Importing the Kratos Library +import KratosMultiphysics as KM +import KratosMultiphysics.CoSimulationApplication as KMC + +# Importing the base class +from KratosMultiphysics.CoSimulationApplication.base_classes.co_simulation_solver_wrapper import CoSimulationSolverWrapper + +# Other imports +from .sdof_static_solver import SDoFStaticSolver +from .sdof_solver_wrapper import SdofSolverWrapper + +def Create(settings, solver_name): + return SdofStaticSolverWrapper(settings, solver_name) + +class SdofStaticSolverWrapper(SdofSolverWrapper): + """ This class implements a wrapper for an SDof solver to be used in CoSimulation + """ + def __init__(self, settings, solver_name): + CoSimulationSolverWrapper.__init__(self,settings, solver_name) + + input_file_name = self.settings["solver_wrapper_settings"]["input_file"].GetString() + + self.mp = self.model.CreateModelPart("Sdof_Static") + self.mp.ProcessInfo[KM.DOMAIN_SIZE] = 1 + self._sdof_solver = SDoFStaticSolver(input_file_name) diff --git a/applications/CoSimulationApplication/tests/fsi_sdof_static/ProjectParametersSDoF.json b/applications/CoSimulationApplication/tests/fsi_sdof_static/ProjectParametersSDoF.json new file mode 100644 index 000000000000..cdd8b602e4f4 --- /dev/null +++ b/applications/CoSimulationApplication/tests/fsi_sdof_static/ProjectParametersSDoF.json @@ -0,0 +1,19 @@ +{ + "system_parameters":{ + "stiffness" : 50000.00 + }, + "initial_values":{ + "displacement": 0.0 + }, + "boundary_conditions":{ + "external_load": 10000.0 + }, + "solver_parameters": { + "buffer_size": 3 + }, + "output_parameters":{ + "write_output_file": true, + "file_name": "fsi_sdof_static/results_final_sdof.dat" + } + +} \ No newline at end of file diff --git a/applications/CoSimulationApplication/tests/fsi_sdof_static/naca0012_small.mdpa b/applications/CoSimulationApplication/tests/fsi_sdof_static/naca0012_small.mdpa new file mode 100644 index 000000000000..08f240f849d1 --- /dev/null +++ b/applications/CoSimulationApplication/tests/fsi_sdof_static/naca0012_small.mdpa @@ -0,0 +1,210 @@ +Begin ModelPartData +// VARIABLE_NAME value +End ModelPartData + +Begin Properties 0 +End Properties + +Begin Properties 1 + DENSITY 1.22500E+00 +End Properties + +Begin Nodes + 1 -0.50000 -1.00000 0.00000 + 2 -0.50000 -0.42554 0.00000 + 3 0.18073 -1.00000 0.00000 + 4 0.16098 -0.39683 0.00000 + 5 -0.50000 0.04539 0.00000 + 6 0.00381 0.08716 0.00000 + 7 0.69368 -0.47979 0.00000 + 8 0.83003 -1.00000 0.00000 + 9 0.49032 -0.00891 0.00000 + 10 0.49961 0.09728 0.00000 + 11 -0.50000 0.48611 0.00000 + 12 0.32159 0.53024 0.00000 + 13 1.00000 0.00000 0.00000 + 14 1.50000 -1.00000 0.00000 + 15 -0.50000 1.00000 0.00000 + 16 1.50000 -0.47298 0.00000 + 17 0.93936 0.51092 0.00000 + 18 0.16965 1.00000 0.00000 + 19 1.50000 -0.03089 0.00000 + 20 0.81712 1.00000 0.00000 + 21 1.50000 0.43783 0.00000 + 22 1.50000 1.00000 0.00000 +End Nodes + + +Begin Elements Element2D3N// GUI group identifier: Parts Auto1 + 1 1 16 19 13 + 2 1 19 21 13 + 3 1 11 5 6 + 4 1 5 2 6 + 5 1 9 6 4 + 6 1 6 10 12 + 7 1 4 6 2 + 8 1 9 4 7 + 9 1 12 10 17 + 10 1 6 12 11 + 11 1 13 9 7 + 12 1 10 13 17 + 13 1 15 11 18 + 14 1 7 4 3 + 15 1 12 17 20 + 16 1 20 17 22 + 17 1 14 16 8 + 18 1 21 22 17 + 19 1 2 1 3 + 20 1 13 7 16 + 21 1 17 13 21 + 22 1 3 4 2 + 23 1 20 18 12 + 24 1 12 18 11 + 25 1 3 8 7 + 26 1 7 8 16 +End Elements + +Begin Conditions LineCondition2D2N// GUI group identifier: Far field Auto1 +1 0 14 16 +2 0 16 19 +3 0 19 21 +4 0 21 22 +5 0 22 20 +6 0 20 18 +7 0 18 15 +8 0 15 11 +9 0 11 5 +10 0 5 2 +11 0 2 1 +12 0 1 3 +13 0 3 8 +14 0 8 14 +End Conditions + +Begin Conditions LineCondition2D2N// GUI group identifier: Body Auto1Body2D_UpperSurface +15 0 13 10 +16 0 10 6 +End Conditions + +Begin Conditions LineCondition2D2N// GUI group identifier: Body Auto2Body2D_LowerSurface +17 0 6 9 +18 0 9 13 +End Conditions + +Begin SubModelPart Parts_Parts_Auto1 // Group Parts Auto1 // Subtree Parts + Begin SubModelPartNodes + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + End SubModelPartNodes + Begin SubModelPartElements + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + End SubModelPartElements + Begin SubModelPartConditions + End SubModelPartConditions +End SubModelPart +Begin SubModelPart PotentialWallCondition2D_Far_field_Auto1 // Group Far field Auto1 // Subtree PotentialWallCondition2D + Begin SubModelPartNodes + 1 + 2 + 3 + 5 + 8 + 11 + 14 + 15 + 16 + 18 + 19 + 20 + 21 + 22 + End SubModelPartNodes + Begin SubModelPartElements + End SubModelPartElements + Begin SubModelPartConditions + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + End SubModelPartConditions +End SubModelPart +Begin SubModelPart Wake2D_Wake_Auto1 // Group Wake Auto1 // Subtree Wake2D + Begin SubModelPartNodes + 13 + End SubModelPartNodes + Begin SubModelPartElements + End SubModelPartElements + Begin SubModelPartConditions + End SubModelPartConditions +End SubModelPart +Begin SubModelPart Body2D_Body // Group Body Auto1Body2D_UpperSurface // Subtree Body2D + Begin SubModelPartNodes + 6 + 9 + 10 + 13 + End SubModelPartNodes + Begin SubModelPartElements + End SubModelPartElements + Begin SubModelPartConditions + 15 + 16 + 17 + 18 + End SubModelPartConditions +End SubModelPart diff --git a/applications/CoSimulationApplication/tests/fsi_sdof_static/naca0012_small_parameters_coupling.json b/applications/CoSimulationApplication/tests/fsi_sdof_static/naca0012_small_parameters_coupling.json new file mode 100644 index 000000000000..70a342abe3a9 --- /dev/null +++ b/applications/CoSimulationApplication/tests/fsi_sdof_static/naca0012_small_parameters_coupling.json @@ -0,0 +1,159 @@ +{ + "problem_data" : { + "problem_name" : "naca0012", + "parallel_type" : "OpenMP", + "echo_level" : 1, + "start_time" : 0.0, + "end_time" : 1.0 + }, + "solver_settings" : { + "solver_type" : "ale_potential_flow", + "ale_boundary_parts" : ["Body2D_Body"], + "mesh_motion_solver_settings" :{ + "solver_type" : "structural_similarity", + "mesh_motion_linear_solver_settings" : { + "solver_type" : "ExternalSolversApplication.super_lu" + }, + "reform_dofs_each_step" : false, + "echo_level": 1 + }, + + "fluid_solver_settings" :{ + "solver_type" :"potential_flow", + "domain_size" : 2, + "model_part_name" : "FluidModelPart", + "model_import_settings" : { + "input_type" : "mdpa", + "input_filename" : "naca0012_small" + }, + "maximum_iterations" : 5, + "echo_level" : 1, + "linear_solver_settings" : { + "solver_type" : "ExternalSolversApplication.super_lu", + "verbosity" : 0 + }, + "volume_model_part_name" : "Parts_Parts_Auto1", + "skin_parts" : ["PotentialWallCondition2D_Far_field_Auto1","Body2D_Body"], + "no_skin_parts" : [], + "auxiliary_variables_list": ["DISTANCE", "REACTION"] + } + }, + "processes" : { + "initial_conditions_process_list" : [], + "boundary_conditions_process_list" : [{ + "python_module" : "apply_far_field_process", + "kratos_module" : "KratosMultiphysics.CompressiblePotentialFlowApplication", + "process_name" : "FarFieldProcess", + "Parameters" : { + "model_part_name" : "FluidModelPart.PotentialWallCondition2D_Far_field_Auto1", + "inlet_potential" : 1.0, + "free_stream_density": 1.225 + } + },{ + "python_module" : "define_wake_process_2d", + "kratos_module" : "KratosMultiphysics.CompressiblePotentialFlowApplication", + "process_name" : "DefineWakeProcess", + "Parameters" : { + "model_part_name" : "FluidModelPart.Body2D_Body", + "epsilon" : 1e-9 + } + },{ + "python_module" : "compute_lift_process", + "kratos_module" : "KratosMultiphysics.CompressiblePotentialFlowApplication", + "process_name" : "ComputeLiftProcess3D", + "Parameters" : { + "model_part_name" : "FluidModelPart.Body2D_Body", + "far_field_model_part_name" : "FluidModelPart.PotentialWallCondition2D_Far_field_Auto1" + } + },{ + "python_module" : "compute_forces_on_nodes_process", + "kratos_module" : "KratosMultiphysics.CompressiblePotentialFlowApplication", + "process_name" : "ComputeForcesOnNodesProcess", + "Parameters" : { + "model_part_name" : "FluidModelPart.Body2D_Body", + "create_output_file": true + } + },{ + "python_module" : "fix_vector_variable_process", + "kratos_module" : "KratosMultiphysics", + "help" : "This process fixes the selected components of a given vector variable", + "Parameters" : { + "model_part_name" : "FluidModelPart.PotentialWallCondition2D_Far_field_Auto1", + "variable_name" : "MESH_DISPLACEMENT", + "constrained" : [true, true, true] + } + },{ + "python_module" : "fix_vector_variable_process", + "kratos_module" : "KratosMultiphysics", + "help" : "This process fixes the selected components of a given vector variable", + "Parameters" : { + "model_part_name" : "FluidModelPart.Body2D_Body", + "variable_name" : "MESH_DISPLACEMENT", + "constrained" : [true, true, true] + } + }], + "auxiliar_process_list" :[{ + "kratos_module" : "KratosMultiphysics", + "python_module" : "point_output_process", + "help" : "", + "process_name" : "PointOutputProcess", + "Parameters" : { + "position" : [1.0, 0.5, 0.0], + "model_part_name" : "FluidModelPart", + "output_file_settings": { + "file_name" : "naca0012_test_probe1.dat" + }, + "output_variables" : ["VELOCITY_POTENTIAL","REACTION"] + } + },{ + "kratos_module" : "KratosMultiphysics", + "python_module" : "point_output_process", + "help" : "", + "process_name" : "PointOutputProcess", + "Parameters" : { + "position" : [0.49032, -0.00891, 0.0], + "entity_type" : "node", + "model_part_name" : "FluidModelPart", + "output_file_settings": { + "file_name" : "naca0012_mesh_movement_Y.dat" + }, + "output_variables" : [ + "MESH_DISPLACEMENT_Y"] + } + }] + }, + "output_processes" : { + "gid_output" : [{ + "python_module" : "gid_output_process", + "kratos_module" : "KratosMultiphysics", + "process_name" : "GiDOutputProcess", + "help" : "This process writes postprocessing files for GiD", + "Parameters" : { + "model_part_name" : "FluidModelPart", + "output_name" : "naca0012", + "postprocess_parameters" : { + "result_file_configuration" : { + "gidpost_flags" : { + "GiDPostMode" : "GiD_PostBinary", + "WriteDeformedMeshFlag" : "WriteDeformed", + "WriteConditionsFlag" : "WriteConditions", + "MultiFileFlag" : "SingleFile" + }, + "file_label" : "step", + "output_control_type" : "step", + "output_frequency" : 10, + "body_output" : true, + "node_output" : false, + "skin_output" : false, + "plane_output" : [], + "nodal_results" : ["MESH_DISPLACEMENT","REACTION", "VELOCITY_POTENTIAL","AUXILIARY_VELOCITY_POTENTIAL"], + "nodal_nonhistorical_results": ["TRAILING_EDGE","GEOMETRY_DISTANCE"], + "gauss_point_results" : ["PRESSURE_COEFFICIENT","VELOCITY","WAKE","KUTTA"], + "elemental_conditional_flags_results": ["STRUCTURE"] + }, + "point_data_configuration" : [] + } + } + }] + } +} \ No newline at end of file diff --git a/applications/CoSimulationApplication/tests/fsi_sdof_static/project_paramters_cosim_naca0012_small_fsi.json b/applications/CoSimulationApplication/tests/fsi_sdof_static/project_paramters_cosim_naca0012_small_fsi.json new file mode 100644 index 000000000000..f2d187c8e7d8 --- /dev/null +++ b/applications/CoSimulationApplication/tests/fsi_sdof_static/project_paramters_cosim_naca0012_small_fsi.json @@ -0,0 +1,86 @@ +{ + "problem_data" : + { + "start_time" : 0.0, + "end_time" : 1.0, + "echo_level" : 3, + "print_colors" : true + }, + "solver_settings" : + { + "solver_type" : "coupled_solvers.simple_steady_coupling", + "echo_level" : 2, + "data_transfer_operators" : { + "transfer_forces" : { + "type" : "sum_distributed_to_single" + }, + "transfer_disp" : { + "type" : "copy_single_to_distributed" + } + }, + "coupling_sequence": + [ + { + "name": "structure", + "input_data_list" : [{ + "data" : "force_y", + "from_solver" : "fluid", + "from_solver_data" : "force_y", + "data_transfer_operator" : "transfer_forces", + "data_transfer_operator_options" : ["swap_sign"]}], + "output_data_list" : [ + { + "data" : "disp_y", + "to_solver" : "fluid", + "to_solver_data" : "disp_y", + "data_transfer_operator" : "transfer_disp" + } + ] + },{ + "name": "fluid", + "output_data_list": [], + "input_data_list": [] + } + + ], + "solvers" : + { + "fluid": + { + "type" : "solver_wrappers.kratos.potential_flow_wrapper", + "solver_wrapper_settings" : { + "input_file" : "fsi_sdof_static/naca0012_small_parameters_coupling" + }, + "data" : { + "disp_y" : { + "model_part_name" : "FluidModelPart.Body2D_Body", + "variable_name" : "MESH_DISPLACEMENT_Y" + }, + "force_y" : { + "model_part_name" : "FluidModelPart.Body2D_Body", + "variable_name" : "REACTION_Y" + } + } + }, + "structure" : + { + "type" : "solver_wrappers.sdof.static_sdof_solver_wrapper", + "solver_wrapper_settings" : { + "input_file" : "fsi_sdof_static/ProjectParametersSDoF" + }, + "data" : { + "disp_y" : { + "model_part_name" : "Sdof_Static", + "variable_name" : "SCALAR_DISPLACEMENT", + "location" : "model_part" + }, + "force_y" : { + "model_part_name" : "Sdof_Static", + "variable_name" : "SCALAR_FORCE", + "location" : "model_part" + } + } + } + } + } +} \ No newline at end of file diff --git a/applications/CoSimulationApplication/tests/fsi_sdof_static/results.dat b/applications/CoSimulationApplication/tests/fsi_sdof_static/results.dat new file mode 100644 index 000000000000..8b52a9bb333d --- /dev/null +++ b/applications/CoSimulationApplication/tests/fsi_sdof_static/results.dat @@ -0,0 +1,2 @@ +displacement +0.0 diff --git a/applications/CoSimulationApplication/tests/fsi_sdof_static/results_final_sdof.dat b/applications/CoSimulationApplication/tests/fsi_sdof_static/results_final_sdof.dat new file mode 100644 index 000000000000..8b52a9bb333d --- /dev/null +++ b/applications/CoSimulationApplication/tests/fsi_sdof_static/results_final_sdof.dat @@ -0,0 +1,2 @@ +displacement +0.0 diff --git a/applications/CoSimulationApplication/tests/reference_files/ref_sdof_static_final_displacement.dat b/applications/CoSimulationApplication/tests/reference_files/ref_sdof_static_final_displacement.dat new file mode 100644 index 000000000000..42be41821f8a --- /dev/null +++ b/applications/CoSimulationApplication/tests/reference_files/ref_sdof_static_final_displacement.dat @@ -0,0 +1,3 @@ +displacement +0.0 +0.2 diff --git a/applications/CoSimulationApplication/tests/reference_files/ref_sdof_static_initial_displacement.dat b/applications/CoSimulationApplication/tests/reference_files/ref_sdof_static_initial_displacement.dat new file mode 100644 index 000000000000..a8991a181508 --- /dev/null +++ b/applications/CoSimulationApplication/tests/reference_files/ref_sdof_static_initial_displacement.dat @@ -0,0 +1,2 @@ +displacement +1.0 diff --git a/applications/CoSimulationApplication/tests/test_CoSimulationApplication.py b/applications/CoSimulationApplication/tests/test_CoSimulationApplication.py index 61b2bdf84098..e3b13420136e 100644 --- a/applications/CoSimulationApplication/tests/test_CoSimulationApplication.py +++ b/applications/CoSimulationApplication/tests/test_CoSimulationApplication.py @@ -20,6 +20,7 @@ from test_coupling_operations import TestScalingOperation from test_flower_coupling import TestFLOWerCoupling from test_sdof_solver import TestSdofSolver + from test_sdof_static_solver import TestSdofStaticSolver if not using_pykratos: from test_cosim_EMPIRE_API import TestCoSim_EMPIRE_API @@ -45,6 +46,7 @@ def AssembleTestSuites(): smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([TestDataTransferOperators])) smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([TestScalingOperation])) smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([TestSdofSolver])) + smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([TestSdofStaticSolver])) if not using_pykratos: smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([TestCoSim_EMPIRE_API])) smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([TestPingPong])) diff --git a/applications/CoSimulationApplication/tests/test_sdof_static_solver.py b/applications/CoSimulationApplication/tests/test_sdof_static_solver.py new file mode 100644 index 000000000000..7f34d63f23de --- /dev/null +++ b/applications/CoSimulationApplication/tests/test_sdof_static_solver.py @@ -0,0 +1,94 @@ +from __future__ import print_function, absolute_import, division # makes these scripts backward compatible with python 2.6 and 2.7 + +import KratosMultiphysics as KM +from KratosMultiphysics import kratos_utilities +import KratosMultiphysics.KratosUnittest as KratosUnittest +from KratosMultiphysics.CoSimulationApplication.solver_wrappers.sdof.sdof_static_solver import SDoFStaticSolver +from KratosMultiphysics.CoSimulationApplication.solver_wrappers.sdof.static_sdof_solver_wrapper import Create as CreateSDofStaticSolverWrapper + +import os +import numpy as np + +class TestSdofStaticSolver(KratosUnittest.TestCase): + + def setUp(self): + self.system_settings = { + "system_parameters":{ + "stiffness" : 50000.0, + }, + "output_parameters":{ + "write_output_file": True, + "file_name" : "result.dat" + } + } + #result.dat + self.end_time = 1.0 + self.time = 0.0 + + def tearDown(self): + kratos_utilities.DeleteFileIfExisting("result.dat") + + def __CompareResults(self, reference, result): + ref = np.loadtxt(reference, skiprows=1) + res = np.loadtxt(result, skiprows=1) + self.assertEqual(ref.all(), res.all()) + + def __ExecuteTest(self, settings, ref_file_name): + settings.update(self.system_settings) + system = SDoFStaticSolver(settings) + system.Initialize() + + system.SolveSolutionStep() + system.OutputSolutionStep() + self.__CompareResults(os.path.join("reference_files", ref_file_name), "result.dat") + + + def test_initial_displacement(self): + settings = { + "initial_values":{ + "displacement" : 1.0, + } + } + self.__ExecuteTest(settings, "ref_sdof_static_initial_displacement.dat") + + def test_final_displacement(self): + import json + parameter_file_name = "fsi_sdof_static/ProjectParametersSDoF.json" + with open(parameter_file_name, 'r') as parameter_file: + settings = json.load(parameter_file) + + system = SDoFStaticSolver(settings) + system.Initialize() + + system.SolveSolutionStep() + system.OutputSolutionStep() + + results_obtained = np.loadtxt('fsi_sdof_static/results_final_sdof.dat', skiprows=1) + results_reference = np.loadtxt('reference_files/ref_sdof_static_final_displacement.dat', skiprows=1) + self.assertEqual(results_reference.all(), results_obtained.all()) + + def test_wrapper_variables_check(self): + # resusing the sdof fsi parameters + wrapper_settings = KM.Parameters("""{ + "type" : "solver_wrappers.sdof.static_sdof_solver_wrapper", + "solver_wrapper_settings" : { + "input_file" : "fsi_sdof_static/ProjectParametersSDoF" + }, + "data" : { + "disp" : { + "model_part_name" : "Sdof_Static", + "variable_name" : "DISPLACEMENT", + "location" : "model_part", + "dimension" : 1 + } + } + }""") + sdof_static_solver_wrapper = CreateSDofStaticSolverWrapper(wrapper_settings, "custom_sdof_solver_wrapper") + + sdof_static_solver_wrapper.Initialize() + sdof_static_solver_wrapper.InitializeCouplingInterfaceData() + with self.assertRaisesRegex(Exception, 'Variable "DISPLACEMENT" of interface data "disp" of solver "custom_sdof_solver_wrapper" cannot be used for the SDof Solver!'): + sdof_static_solver_wrapper.Check() + +if __name__ == '__main__': + KratosUnittest.main() From 0f2c7f7b5f2468de552ef45fea1138f78593727d Mon Sep 17 00:00:00 2001 From: zidanmahmoud Date: Wed, 11 Dec 2019 16:43:45 +0100 Subject: [PATCH 002/314] removing output process from sdof static sdof --- .../naca0012_small_parameters_coupling.json | 66 +------------------ 1 file changed, 2 insertions(+), 64 deletions(-) diff --git a/applications/CoSimulationApplication/tests/fsi_sdof_static/naca0012_small_parameters_coupling.json b/applications/CoSimulationApplication/tests/fsi_sdof_static/naca0012_small_parameters_coupling.json index 70a342abe3a9..95a88234ce45 100644 --- a/applications/CoSimulationApplication/tests/fsi_sdof_static/naca0012_small_parameters_coupling.json +++ b/applications/CoSimulationApplication/tests/fsi_sdof_static/naca0012_small_parameters_coupling.json @@ -92,68 +92,6 @@ "constrained" : [true, true, true] } }], - "auxiliar_process_list" :[{ - "kratos_module" : "KratosMultiphysics", - "python_module" : "point_output_process", - "help" : "", - "process_name" : "PointOutputProcess", - "Parameters" : { - "position" : [1.0, 0.5, 0.0], - "model_part_name" : "FluidModelPart", - "output_file_settings": { - "file_name" : "naca0012_test_probe1.dat" - }, - "output_variables" : ["VELOCITY_POTENTIAL","REACTION"] - } - },{ - "kratos_module" : "KratosMultiphysics", - "python_module" : "point_output_process", - "help" : "", - "process_name" : "PointOutputProcess", - "Parameters" : { - "position" : [0.49032, -0.00891, 0.0], - "entity_type" : "node", - "model_part_name" : "FluidModelPart", - "output_file_settings": { - "file_name" : "naca0012_mesh_movement_Y.dat" - }, - "output_variables" : [ - "MESH_DISPLACEMENT_Y"] - } - }] - }, - "output_processes" : { - "gid_output" : [{ - "python_module" : "gid_output_process", - "kratos_module" : "KratosMultiphysics", - "process_name" : "GiDOutputProcess", - "help" : "This process writes postprocessing files for GiD", - "Parameters" : { - "model_part_name" : "FluidModelPart", - "output_name" : "naca0012", - "postprocess_parameters" : { - "result_file_configuration" : { - "gidpost_flags" : { - "GiDPostMode" : "GiD_PostBinary", - "WriteDeformedMeshFlag" : "WriteDeformed", - "WriteConditionsFlag" : "WriteConditions", - "MultiFileFlag" : "SingleFile" - }, - "file_label" : "step", - "output_control_type" : "step", - "output_frequency" : 10, - "body_output" : true, - "node_output" : false, - "skin_output" : false, - "plane_output" : [], - "nodal_results" : ["MESH_DISPLACEMENT","REACTION", "VELOCITY_POTENTIAL","AUXILIARY_VELOCITY_POTENTIAL"], - "nodal_nonhistorical_results": ["TRAILING_EDGE","GEOMETRY_DISTANCE"], - "gauss_point_results" : ["PRESSURE_COEFFICIENT","VELOCITY","WAKE","KUTTA"], - "elemental_conditional_flags_results": ["STRUCTURE"] - }, - "point_data_configuration" : [] - } - } - }] + "auxiliar_process_list" :[] } -} \ No newline at end of file +} From b92bda59f33c9255f1b524c7db9e6729f64bf29b Mon Sep 17 00:00:00 2001 From: BasselSaridar Date: Wed, 11 Dec 2019 18:41:50 +0100 Subject: [PATCH 003/314] modifying test JSON file --- .../naca0012_small_parameters_coupling.json | 77 +++++-------------- .../tests/fsi_sdof_static/results.dat | 2 - 2 files changed, 21 insertions(+), 58 deletions(-) delete mode 100644 applications/CoSimulationApplication/tests/fsi_sdof_static/results.dat diff --git a/applications/CoSimulationApplication/tests/fsi_sdof_static/naca0012_small_parameters_coupling.json b/applications/CoSimulationApplication/tests/fsi_sdof_static/naca0012_small_parameters_coupling.json index 70a342abe3a9..e74445221b5d 100644 --- a/applications/CoSimulationApplication/tests/fsi_sdof_static/naca0012_small_parameters_coupling.json +++ b/applications/CoSimulationApplication/tests/fsi_sdof_static/naca0012_small_parameters_coupling.json @@ -24,7 +24,7 @@ "model_part_name" : "FluidModelPart", "model_import_settings" : { "input_type" : "mdpa", - "input_filename" : "naca0012_small" + "input_filename" : "fsi_sdof_static/naca0012_small" }, "maximum_iterations" : 5, "echo_level" : 1, @@ -98,62 +98,27 @@ "help" : "", "process_name" : "PointOutputProcess", "Parameters" : { - "position" : [1.0, 0.5, 0.0], - "model_part_name" : "FluidModelPart", - "output_file_settings": { - "file_name" : "naca0012_test_probe1.dat" - }, - "output_variables" : ["VELOCITY_POTENTIAL","REACTION"] - } - },{ - "kratos_module" : "KratosMultiphysics", - "python_module" : "point_output_process", - "help" : "", - "process_name" : "PointOutputProcess", - "Parameters" : { - "position" : [0.49032, -0.00891, 0.0], - "entity_type" : "node", - "model_part_name" : "FluidModelPart", - "output_file_settings": { - "file_name" : "naca0012_mesh_movement_Y.dat" - }, - "output_variables" : [ - "MESH_DISPLACEMENT_Y"] - } - }] - }, - "output_processes" : { - "gid_output" : [{ - "python_module" : "gid_output_process", - "kratos_module" : "KratosMultiphysics", - "process_name" : "GiDOutputProcess", - "help" : "This process writes postprocessing files for GiD", - "Parameters" : { - "model_part_name" : "FluidModelPart", - "output_name" : "naca0012", - "postprocess_parameters" : { - "result_file_configuration" : { - "gidpost_flags" : { - "GiDPostMode" : "GiD_PostBinary", - "WriteDeformedMeshFlag" : "WriteDeformed", - "WriteConditionsFlag" : "WriteConditions", - "MultiFileFlag" : "SingleFile" - }, - "file_label" : "step", - "output_control_type" : "step", - "output_frequency" : 10, - "body_output" : true, - "node_output" : false, - "skin_output" : false, - "plane_output" : [], - "nodal_results" : ["MESH_DISPLACEMENT","REACTION", "VELOCITY_POTENTIAL","AUXILIARY_VELOCITY_POTENTIAL"], - "nodal_nonhistorical_results": ["TRAILING_EDGE","GEOMETRY_DISTANCE"], - "gauss_point_results" : ["PRESSURE_COEFFICIENT","VELOCITY","WAKE","KUTTA"], - "elemental_conditional_flags_results": ["STRUCTURE"] + "position" : [0.69368 , -0.47979 , 0.00000], + "entity_type" : "element", + "search_tolerance" : 1e-3, + "model_part_name" : "FluidModelPart", + "output_file_settings": { + "file_name" : "results.dat", + "folder_name": "fsi_sdof_static" }, - "point_data_configuration" : [] + "output_variables" : ["MESH_DISPLACEMENT_Y"] } - } - }] + },{ + "python_module" : "compare_two_files_check_process", + "kratos_module" : "KratosMultiphysics", + "help" : "", + "process_name" : "CompareTwoFilesCheckProcess", + "Parameters" :{ + "output_file_name" : "fsi_sdof_static/results.dat", + "reference_file_name" : "fsi_sdof_static/results_ref.dat", + "comparison_type" : "dat_file", + "tolerance" : 1e-3 + } + }] } } \ No newline at end of file diff --git a/applications/CoSimulationApplication/tests/fsi_sdof_static/results.dat b/applications/CoSimulationApplication/tests/fsi_sdof_static/results.dat deleted file mode 100644 index 8b52a9bb333d..000000000000 --- a/applications/CoSimulationApplication/tests/fsi_sdof_static/results.dat +++ /dev/null @@ -1,2 +0,0 @@ -displacement -0.0 From 7b8e1c592e57db3d5949b273d6fb7da6aace32c2 Mon Sep 17 00:00:00 2001 From: BasselSaridar Date: Thu, 12 Dec 2019 12:04:22 +0100 Subject: [PATCH 004/314] adding FSI SFoF Static case --- .../sdof/sdof_static_solver.py | 3 + .../sdof/static_sdof_solver_wrapper.py | 20 ++ .../tests/co_simulation_test_factory.py | 14 + .../tests/fsi_mok/ProjectParametersCFD.json | 303 ++++++++++++++++++ ..._cosim_naca0012_small_fsi_parameters.json} | 36 ++- .../fsi_sdof_static/results_final_sdof.dat | 1 + .../tests/fsi_sdof_static/results_ref.dat | 3 + 7 files changed, 371 insertions(+), 9 deletions(-) create mode 100644 applications/CoSimulationApplication/tests/fsi_mok/ProjectParametersCFD.json rename applications/CoSimulationApplication/tests/fsi_sdof_static/{project_paramters_cosim_naca0012_small_fsi.json => project_cosim_naca0012_small_fsi_parameters.json} (78%) create mode 100644 applications/CoSimulationApplication/tests/fsi_sdof_static/results_ref.dat diff --git a/applications/CoSimulationApplication/python_scripts/solver_wrappers/sdof/sdof_static_solver.py b/applications/CoSimulationApplication/python_scripts/solver_wrappers/sdof/sdof_static_solver.py index 0f0c5161c86b..04d2fbc46057 100644 --- a/applications/CoSimulationApplication/python_scripts/solver_wrappers/sdof/sdof_static_solver.py +++ b/applications/CoSimulationApplication/python_scripts/solver_wrappers/sdof/sdof_static_solver.py @@ -109,6 +109,9 @@ def SetSolutionStepValue(self, identifier, value, buffer_idx=0): elif identifier == "LOAD": self.force = 0.0 self.force = value + elif identifier == "ROOT_POINT_DISPLACEMENT": + self.root_point_displacement = 0.0 + self.root_point_displacement = value else: raise Exception("Identifier is unknown!") diff --git a/applications/CoSimulationApplication/python_scripts/solver_wrappers/sdof/static_sdof_solver_wrapper.py b/applications/CoSimulationApplication/python_scripts/solver_wrappers/sdof/static_sdof_solver_wrapper.py index f590192408eb..a384a0de227c 100644 --- a/applications/CoSimulationApplication/python_scripts/solver_wrappers/sdof/static_sdof_solver_wrapper.py +++ b/applications/CoSimulationApplication/python_scripts/solver_wrappers/sdof/static_sdof_solver_wrapper.py @@ -25,3 +25,23 @@ def __init__(self, settings, solver_name): self.mp = self.model.CreateModelPart("Sdof_Static") self.mp.ProcessInfo[KM.DOMAIN_SIZE] = 1 self._sdof_solver = SDoFStaticSolver(input_file_name) + + def SolveSolutionStep(self): + self._sdof_solver.SetSolutionStepValue("ROOT_POINT_DISPLACEMENT", self.mp[KMC.SCALAR_ROOT_POINT_DISPLACEMENT], 0) + self._sdof_solver.SetSolutionStepValue("LOAD", self.mp[KMC.SCALAR_FORCE], 0) + + self._sdof_solver.SolveSolutionStep() + + self.mp[KMC.SCALAR_DISPLACEMENT] = self._sdof_solver.GetSolutionStepValue("DISPLACEMENT", 0) + self.mp[KMC.SCALAR_REACTION] = self._sdof_solver.GetSolutionStepValue("REACTION", 0) + + def Check(self): + # making sure only a set of vaiables can be used + admissible_variables = [ + "SCALAR_FORCE", + "SCALAR_DISPLACEMENT", + "SCALAR_REACTION", + ] + for data in self.data_dict.values(): + if data.variable.Name() not in admissible_variables: + raise Exception('Variable "{}" of interface data "{}" of solver "{}" cannot be used for the SDof Solver!\nOnly the following variables are allowed: {}'.format(data.variable.Name(), data.name, data.solver_name, admissible_variables)) diff --git a/applications/CoSimulationApplication/tests/co_simulation_test_factory.py b/applications/CoSimulationApplication/tests/co_simulation_test_factory.py index 878fd8cfd813..a2ed1fb4af6d 100644 --- a/applications/CoSimulationApplication/tests/co_simulation_test_factory.py +++ b/applications/CoSimulationApplication/tests/co_simulation_test_factory.py @@ -15,6 +15,7 @@ numpy_available = False have_fsi_dependencies = kratos_utils.CheckIfApplicationsAvailable("FluidDynamicsApplication", "StructuralMechanicsApplication", "MappingApplication", "MeshMovingApplication", "ExternalSolversApplication") +have_potential_fsi_dependencies = kratos_utils.CheckIfApplicationsAvailable("CompressiblePotentialFlowApplication", "StructuralMechanicsApplication", "MappingApplication", "MeshMovingApplication", "ExternalSolversApplication") have_mpm_fem_dependencies = kratos_utils.CheckIfApplicationsAvailable("ParticleMechanicsApplication", "StructuralMechanicsApplication", "MappingApplication", "ExternalSolversApplication") have_dem_fem_dependencies = kratos_utils.CheckIfApplicationsAvailable("DEMApplication", "StructuralMechanicsApplication", "MappingApplication", "ExternalSolversApplication") @@ -159,6 +160,19 @@ def test_sdof_fsi(self): # self.__AddVtkOutputToCFD() # uncomment to get output self._runTest() + def test_sdof_static_fsi(self): + if not numpy_available: + self.skipTest("Numpy not available") + if using_pykratos: + self.skipTest("This test cannot be run with pyKratos!") + if not have_potential_fsi_dependencies: + self.skipTest("FSI dependencies are not available!") + + with KratosUnittest.WorkFolderScope(".", __file__): + self._createTest("fsi_sdof_static", "project_cosim_naca0012_small_fsi") + # self.__AddVtkOutputToCFD() # uncomment to get output + self._runTest() + @classmethod def tearDownClass(cls): super(TestCoSimulationCases,cls).tearDownClass() diff --git a/applications/CoSimulationApplication/tests/fsi_mok/ProjectParametersCFD.json b/applications/CoSimulationApplication/tests/fsi_mok/ProjectParametersCFD.json new file mode 100644 index 000000000000..e104a4ab6640 --- /dev/null +++ b/applications/CoSimulationApplication/tests/fsi_mok/ProjectParametersCFD.json @@ -0,0 +1,303 @@ +{ + "_output_configuration": { + "point_data_configuration": [], + "result_file_configuration": { + "body_output": false, + "file_label": "step", + "gauss_point_results": [], + "gidpost_flags": { + "GiDPostMode": "GiD_PostBinary", + "MultiFileFlag": "SingleFile", + "WriteConditionsFlag": "WriteConditions", + "WriteDeformedMeshFlag": "WriteDeformed" + }, + "nodal_results": [ + "VELOCITY", + "PRESSURE", + "MESH_DISPLACEMENT", + "MESH_VELOCITY" + ], + "node_output": false, + "output_control_type": "step", + "output_frequency": 1.0, + "plane_output": [], + "skin_output": false + } + }, + "output_processes": {}, + "problem_data": { + "echo_level": 0, + "end_time": 1, + "parallel_type": "OpenMP", + "problem_name": "Mok_CFD", + "start_time": 0.0 + }, + "processes": { + "ale_boundary_conditions": [ + { + "Parameters": { + "constrained": [ + true, + true, + true + ], + "model_part_name": "FluidModelPart.NoSlip2D_FSI", + "variable_name": "MESH_DISPLACEMENT" + }, + "help": "This process fixes the selected components of a given vector variable", + "kratos_module": "KratosMultiphysics", + "process_name": "AssignVectorVariableProcess", + "python_module": "fix_vector_variable_process" + }, + { + "Parameters": { + "constrained": [ + true, + true, + true + ], + "model_part_name": "FluidModelPart.AutomaticInlet2D_Inlet", + "variable_name": "MESH_DISPLACEMENT" + }, + "help": "This process fixes the selected components of a given vector variable", + "kratos_module": "KratosMultiphysics", + "process_name": "AssignVectorVariableProcess", + "python_module": "fix_vector_variable_process" + }, + { + "Parameters": { + "constrained": [ + true, + true, + true + ], + "model_part_name": "FluidModelPart.NoSlip2D_Bottom", + "variable_name": "MESH_DISPLACEMENT" + }, + "help": "This process fixes the selected components of a given vector variable", + "kratos_module": "KratosMultiphysics", + "process_name": "AssignVectorVariableProcess", + "python_module": "fix_vector_variable_process" + }, + { + "Parameters": { + "constrained": [ + true, + true, + true + ], + "model_part_name": "FluidModelPart.Outlet2D_Outlet", + "variable_name": "MESH_DISPLACEMENT" + }, + "help": "This process fixes the selected components of a given vector variable", + "kratos_module": "KratosMultiphysics", + "process_name": "AssignVectorVariableProcess", + "python_module": "fix_vector_variable_process" + }, + { + "Parameters": { + "constrained": [ + true, + true, + true + ], + "model_part_name": "FluidModelPart.Slip2D_Top", + "variable_name": "MESH_DISPLACEMENT" + }, + "help": "This process fixes the selected components of a given vector variable", + "kratos_module": "KratosMultiphysics", + "process_name": "AssignVectorVariableProcess", + "python_module": "fix_vector_variable_process" + } + ], + "auxiliar_process_list": [ + { + "Parameters": { + "entity_type": "node", + "model_part_name": "FluidModelPart", + "output_file_settings": { + "file_name": "fsi_mok_cfd_results_disp.dat", + "folder_name": "fsi_mok" + }, + "output_variables": [ + "MESH_DISPLACEMENT_X", + "MESH_DISPLACEMENT_Y", + "MESH_VELOCITY_X", + "MESH_VELOCITY_Y" + ], + "position": [ + 0.5, + 0.25, + 0.0 + ] + }, + "kratos_module": "KratosMultiphysics", + "process_name": "PointOutputProcess", + "python_module": "point_output_process" + }, + { + "Parameters": { + "comparison_type": "dat_file_variables_time_history", + "output_file_name": "fsi_mok/fsi_mok_cfd_results_disp.dat", + "reference_file_name": "fsi_mok/fsi_mok_cfd_results_disp_ref_aitken.dat", + "tolerance": 1e-06 + }, + "kratos_module": "KratosMultiphysics", + "process_name": "CompareTwoFilesCheckProcess", + "python_module": "compare_two_files_check_process" + }, + { + "Parameters": { + "model_part_name": "FluidModelPart", + "output_file_settings": { + "file_name": "fsi_mok_cfd_results_fluid.dat", + "folder_name": "fsi_mok" + }, + "output_variables": [ + "VELOCITY_X", + "VELOCITY_Y", + "MESH_DISPLACEMENT_X", + "MESH_DISPLACEMENT_Y", + "MESH_VELOCITY_X", + "MESH_VELOCITY_Y" + ], + "position": [ + 0.57, + 0.27, + 0.0 + ] + }, + "help": "", + "kratos_module": "KratosMultiphysics", + "process_name": "PointOutputProcess", + "python_module": "point_output_process" + }, + { + "Parameters": { + "comparison_type": "dat_file_variables_time_history", + "output_file_name": "fsi_mok/fsi_mok_cfd_results_fluid.dat", + "reference_file_name": "fsi_mok/fsi_mok_cfd_results_fluid_ref_aitken.dat", + "tolerance": 1e-06 + }, + "kratos_module": "KratosMultiphysics", + "process_name": "CompareTwoFilesCheckProcess", + "python_module": "compare_two_files_check_process" + } + ], + "boundary_conditions_process_list": [ + { + "Parameters": { + "constrained": true, + "direction": "automatic_inwards_normal", + "interval": [ + 0.0, + 10.0 + ], + "mesh_id": 0, + "model_part_name": "FluidModelPart.AutomaticInlet2D_Inlet", + "modulus": "2*0.06067*(1-cos(pi*t/10))*y*(1-y)", + "variable_name": "VELOCITY" + }, + "kratos_module": "KratosMultiphysics", + "process_name": "AssignVectorByDirectionProcess", + "python_module": "assign_vector_by_direction_process" + }, + { + "Parameters": { + "constrained": true, + "direction": "automatic_inwards_normal", + "interval": [ + 10.0, + "End" + ], + "mesh_id": 0, + "model_part_name": "FluidModelPart.AutomaticInlet2D_Inlet", + "modulus": "4*0.06067*y*(1-y)", + "variable_name": "VELOCITY" + }, + "kratos_module": "KratosMultiphysics", + "process_name": "AssignVectorByDirectionProcess", + "python_module": "assign_vector_by_direction_process" + }, + { + "Parameters": { + "constrained": true, + "h_top": 0.0, + "hydrostatic_outlet": false, + "model_part_name": "FluidModelPart.Outlet2D_Outlet", + "value": 0.0, + "variable_name": "PRESSURE" + }, + "kratos_module": "KratosMultiphysics.FluidDynamicsApplication", + "python_module": "apply_outlet_process" + }, + { + "Parameters": { + "model_part_name": "FluidModelPart.NoSlip2D_Bottom" + }, + "kratos_module": "KratosMultiphysics.FluidDynamicsApplication", + "python_module": "apply_noslip_process" + }, + { + "Parameters": { + "model_part_name": "FluidModelPart.NoSlip2D_FSI" + }, + "kratos_module": "KratosMultiphysics.FluidDynamicsApplication", + "python_module": "apply_noslip_process" + }, + { + "Parameters": { + "model_part_name": "FluidModelPart.Slip2D_Top" + }, + "kratos_module": "KratosMultiphysics.FluidDynamicsApplication", + "process_name": "ApplySlipProcess", + "python_module": "apply_slip_process" + } + ], + "gravity": [], + "initial_conditions_process_list": [] + }, + "solver_settings": { + "ale_boundary_parts": [ + "NoSlip2D_FSI" + ], + "fluid_solver_settings": { + "absolute_pressure_tolerance": 1e-06, + "absolute_velocity_tolerance": 1e-06, + "compute_reactions": true, + "domain_size": 2, + "echo_level": 0, + "formulation": { + "dynamic_tau": 1.0, + "element_type": "vms", + "use_orthogonal_subscales": false + }, + "maximum_iterations": 10, + "model_import_settings": { + "input_filename": "fsi_mok/Mok_CFD", + "input_type": "mdpa" + }, + "model_part_name": "FluidModelPart", + "no_skin_parts": [], + "relative_pressure_tolerance": 1e-06, + "relative_velocity_tolerance": 1e-06, + "skin_parts": [ + "AutomaticInlet2D_Inlet", + "Outlet2D_Outlet", + "Slip2D_Top", + "NoSlip2D_Bottom", + "NoSlip2D_FSI" + ], + "solver_type": "Monolithic", + "time_stepping": { + "automatic_time_step": false, + "time_step": 0.1 + }, + "volume_model_part_name": "Parts_Fluid" + }, + "mesh_motion_solver_settings": { + "solver_type": "structural_similarity" + }, + "solver_type": "ale_fluid" + } +} \ No newline at end of file diff --git a/applications/CoSimulationApplication/tests/fsi_sdof_static/project_paramters_cosim_naca0012_small_fsi.json b/applications/CoSimulationApplication/tests/fsi_sdof_static/project_cosim_naca0012_small_fsi_parameters.json similarity index 78% rename from applications/CoSimulationApplication/tests/fsi_sdof_static/project_paramters_cosim_naca0012_small_fsi.json rename to applications/CoSimulationApplication/tests/fsi_sdof_static/project_cosim_naca0012_small_fsi_parameters.json index f2d187c8e7d8..e4e31ca24378 100644 --- a/applications/CoSimulationApplication/tests/fsi_sdof_static/project_paramters_cosim_naca0012_small_fsi.json +++ b/applications/CoSimulationApplication/tests/fsi_sdof_static/project_cosim_naca0012_small_fsi_parameters.json @@ -3,13 +3,15 @@ { "start_time" : 0.0, "end_time" : 1.0, - "echo_level" : 3, - "print_colors" : true + "echo_level" : 1, + "print_colors" : true, + "parallel_type" : "OpenMP" }, "solver_settings" : { - "solver_type" : "coupled_solvers.simple_steady_coupling", - "echo_level" : 2, + "type" : "coupled_solvers.gauss_seidel_strong", + "echo_level" : 1, + "num_coupling_iterations" : 10, "data_transfer_operators" : { "transfer_forces" : { "type" : "sum_distributed_to_single" @@ -18,16 +20,36 @@ "type" : "copy_single_to_distributed" } }, + "convergence_accelerators" : [ + { + "type" : "aitken", + "solver" : "fluid", + "data_name" : "disp_y" + } + ], + "convergence_criteria" :[ + { + "type" : "relative_norm_initial_residual", + "solver" : "fluid", + "data_name" : "disp_y", + "abs_tolerance" : 1e-9, + "rel_tolerance" : 1e-2 + }], "coupling_sequence": [ { + "name": "fluid", + "output_data_list": [], + "input_data_list": [] + },{ "name": "structure", "input_data_list" : [{ "data" : "force_y", "from_solver" : "fluid", "from_solver_data" : "force_y", "data_transfer_operator" : "transfer_forces", - "data_transfer_operator_options" : ["swap_sign"]}], + "data_transfer_operator_options" : [] + }], "output_data_list" : [ { "data" : "disp_y", @@ -36,10 +58,6 @@ "data_transfer_operator" : "transfer_disp" } ] - },{ - "name": "fluid", - "output_data_list": [], - "input_data_list": [] } ], diff --git a/applications/CoSimulationApplication/tests/fsi_sdof_static/results_final_sdof.dat b/applications/CoSimulationApplication/tests/fsi_sdof_static/results_final_sdof.dat index 8b52a9bb333d..51d23d607a22 100644 --- a/applications/CoSimulationApplication/tests/fsi_sdof_static/results_final_sdof.dat +++ b/applications/CoSimulationApplication/tests/fsi_sdof_static/results_final_sdof.dat @@ -1,2 +1,3 @@ displacement 0.0 +0.0004033594026853261 diff --git a/applications/CoSimulationApplication/tests/fsi_sdof_static/results_ref.dat b/applications/CoSimulationApplication/tests/fsi_sdof_static/results_ref.dat new file mode 100644 index 000000000000..e891a0e2995b --- /dev/null +++ b/applications/CoSimulationApplication/tests/fsi_sdof_static/results_ref.dat @@ -0,0 +1,3 @@ +# Results for "element" with Id # 8 at position: x: 0.69368; y: -0.47979; z: 0 +# time MESH_DISPLACEMENT_Y +1.0 0.00026212992038535766 From 055abb039044893d95e664791c2311b6dbacb503 Mon Sep 17 00:00:00 2001 From: BasselSaridar Date: Thu, 12 Dec 2019 12:08:59 +0100 Subject: [PATCH 005/314] removing test_wrapper_variables_check from test_sdof_static_solver as requested --- .../tests/test_sdof_static_solver.py | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/applications/CoSimulationApplication/tests/test_sdof_static_solver.py b/applications/CoSimulationApplication/tests/test_sdof_static_solver.py index 7f34d63f23de..9ed7ad513d50 100644 --- a/applications/CoSimulationApplication/tests/test_sdof_static_solver.py +++ b/applications/CoSimulationApplication/tests/test_sdof_static_solver.py @@ -67,28 +67,5 @@ def test_final_displacement(self): results_reference = np.loadtxt('reference_files/ref_sdof_static_final_displacement.dat', skiprows=1) self.assertEqual(results_reference.all(), results_obtained.all()) - def test_wrapper_variables_check(self): - # resusing the sdof fsi parameters - wrapper_settings = KM.Parameters("""{ - "type" : "solver_wrappers.sdof.static_sdof_solver_wrapper", - "solver_wrapper_settings" : { - "input_file" : "fsi_sdof_static/ProjectParametersSDoF" - }, - "data" : { - "disp" : { - "model_part_name" : "Sdof_Static", - "variable_name" : "DISPLACEMENT", - "location" : "model_part", - "dimension" : 1 - } - } - }""") - sdof_static_solver_wrapper = CreateSDofStaticSolverWrapper(wrapper_settings, "custom_sdof_solver_wrapper") - - sdof_static_solver_wrapper.Initialize() - sdof_static_solver_wrapper.InitializeCouplingInterfaceData() - with self.assertRaisesRegex(Exception, 'Variable "DISPLACEMENT" of interface data "disp" of solver "custom_sdof_solver_wrapper" cannot be used for the SDof Solver!'): - sdof_static_solver_wrapper.Check() - if __name__ == '__main__': KratosUnittest.main() From 9eeb21b0052c3aa3923eb88b4810a72b33b55b3a Mon Sep 17 00:00:00 2001 From: BasselSaridar Date: Thu, 12 Dec 2019 16:10:16 +0100 Subject: [PATCH 006/314] almost done --- .../kratos/potential_flow_wrapper.py | 12 +- .../tests/fsi_mok/ProjectParametersCFD.json | 303 ------------------ 2 files changed, 7 insertions(+), 308 deletions(-) delete mode 100644 applications/CoSimulationApplication/tests/fsi_mok/ProjectParametersCFD.json diff --git a/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/potential_flow_wrapper.py b/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/potential_flow_wrapper.py index 965d0dcfe7af..749bec3da7c1 100644 --- a/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/potential_flow_wrapper.py +++ b/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/potential_flow_wrapper.py @@ -25,10 +25,10 @@ def _CreateAnalysisStage(self): return PotentialFlowAnalysis(self.model, self.project_parameters) def AdvanceInTime(self, current_time): - self.time = 1.0 - return self.time + return 0.0 + def Predict(self): - return + pass def Initialize(self): @@ -49,11 +49,13 @@ def Initialize(self): def SolveSolutionStep(self): self.wake_process.ExecuteInitialize() + + ## the next two lines are needed in order to add Wake DoFs to the new Wake Elements Nodes + ## and delete the ones that are no longer in the Wake Region. self._analysis_stage._GetSolver().fluid_solver.solver.Clear() self._analysis_stage._GetSolver().fluid_solver.solver.InitializeSolutionStep() + super(PotentialFlowWrapper, self).SolveSolutionStep() - self.model["FluidModelPart"].CloneTimeStep(self.time) - self.model["FluidModelPart"].ProcessInfo[KratosMultiphysics.STEP] += 1 self.lift_process.ExecuteFinalizeSolutionStep() self.conversion_process.ExecuteFinalizeSolutionStep() diff --git a/applications/CoSimulationApplication/tests/fsi_mok/ProjectParametersCFD.json b/applications/CoSimulationApplication/tests/fsi_mok/ProjectParametersCFD.json deleted file mode 100644 index e104a4ab6640..000000000000 --- a/applications/CoSimulationApplication/tests/fsi_mok/ProjectParametersCFD.json +++ /dev/null @@ -1,303 +0,0 @@ -{ - "_output_configuration": { - "point_data_configuration": [], - "result_file_configuration": { - "body_output": false, - "file_label": "step", - "gauss_point_results": [], - "gidpost_flags": { - "GiDPostMode": "GiD_PostBinary", - "MultiFileFlag": "SingleFile", - "WriteConditionsFlag": "WriteConditions", - "WriteDeformedMeshFlag": "WriteDeformed" - }, - "nodal_results": [ - "VELOCITY", - "PRESSURE", - "MESH_DISPLACEMENT", - "MESH_VELOCITY" - ], - "node_output": false, - "output_control_type": "step", - "output_frequency": 1.0, - "plane_output": [], - "skin_output": false - } - }, - "output_processes": {}, - "problem_data": { - "echo_level": 0, - "end_time": 1, - "parallel_type": "OpenMP", - "problem_name": "Mok_CFD", - "start_time": 0.0 - }, - "processes": { - "ale_boundary_conditions": [ - { - "Parameters": { - "constrained": [ - true, - true, - true - ], - "model_part_name": "FluidModelPart.NoSlip2D_FSI", - "variable_name": "MESH_DISPLACEMENT" - }, - "help": "This process fixes the selected components of a given vector variable", - "kratos_module": "KratosMultiphysics", - "process_name": "AssignVectorVariableProcess", - "python_module": "fix_vector_variable_process" - }, - { - "Parameters": { - "constrained": [ - true, - true, - true - ], - "model_part_name": "FluidModelPart.AutomaticInlet2D_Inlet", - "variable_name": "MESH_DISPLACEMENT" - }, - "help": "This process fixes the selected components of a given vector variable", - "kratos_module": "KratosMultiphysics", - "process_name": "AssignVectorVariableProcess", - "python_module": "fix_vector_variable_process" - }, - { - "Parameters": { - "constrained": [ - true, - true, - true - ], - "model_part_name": "FluidModelPart.NoSlip2D_Bottom", - "variable_name": "MESH_DISPLACEMENT" - }, - "help": "This process fixes the selected components of a given vector variable", - "kratos_module": "KratosMultiphysics", - "process_name": "AssignVectorVariableProcess", - "python_module": "fix_vector_variable_process" - }, - { - "Parameters": { - "constrained": [ - true, - true, - true - ], - "model_part_name": "FluidModelPart.Outlet2D_Outlet", - "variable_name": "MESH_DISPLACEMENT" - }, - "help": "This process fixes the selected components of a given vector variable", - "kratos_module": "KratosMultiphysics", - "process_name": "AssignVectorVariableProcess", - "python_module": "fix_vector_variable_process" - }, - { - "Parameters": { - "constrained": [ - true, - true, - true - ], - "model_part_name": "FluidModelPart.Slip2D_Top", - "variable_name": "MESH_DISPLACEMENT" - }, - "help": "This process fixes the selected components of a given vector variable", - "kratos_module": "KratosMultiphysics", - "process_name": "AssignVectorVariableProcess", - "python_module": "fix_vector_variable_process" - } - ], - "auxiliar_process_list": [ - { - "Parameters": { - "entity_type": "node", - "model_part_name": "FluidModelPart", - "output_file_settings": { - "file_name": "fsi_mok_cfd_results_disp.dat", - "folder_name": "fsi_mok" - }, - "output_variables": [ - "MESH_DISPLACEMENT_X", - "MESH_DISPLACEMENT_Y", - "MESH_VELOCITY_X", - "MESH_VELOCITY_Y" - ], - "position": [ - 0.5, - 0.25, - 0.0 - ] - }, - "kratos_module": "KratosMultiphysics", - "process_name": "PointOutputProcess", - "python_module": "point_output_process" - }, - { - "Parameters": { - "comparison_type": "dat_file_variables_time_history", - "output_file_name": "fsi_mok/fsi_mok_cfd_results_disp.dat", - "reference_file_name": "fsi_mok/fsi_mok_cfd_results_disp_ref_aitken.dat", - "tolerance": 1e-06 - }, - "kratos_module": "KratosMultiphysics", - "process_name": "CompareTwoFilesCheckProcess", - "python_module": "compare_two_files_check_process" - }, - { - "Parameters": { - "model_part_name": "FluidModelPart", - "output_file_settings": { - "file_name": "fsi_mok_cfd_results_fluid.dat", - "folder_name": "fsi_mok" - }, - "output_variables": [ - "VELOCITY_X", - "VELOCITY_Y", - "MESH_DISPLACEMENT_X", - "MESH_DISPLACEMENT_Y", - "MESH_VELOCITY_X", - "MESH_VELOCITY_Y" - ], - "position": [ - 0.57, - 0.27, - 0.0 - ] - }, - "help": "", - "kratos_module": "KratosMultiphysics", - "process_name": "PointOutputProcess", - "python_module": "point_output_process" - }, - { - "Parameters": { - "comparison_type": "dat_file_variables_time_history", - "output_file_name": "fsi_mok/fsi_mok_cfd_results_fluid.dat", - "reference_file_name": "fsi_mok/fsi_mok_cfd_results_fluid_ref_aitken.dat", - "tolerance": 1e-06 - }, - "kratos_module": "KratosMultiphysics", - "process_name": "CompareTwoFilesCheckProcess", - "python_module": "compare_two_files_check_process" - } - ], - "boundary_conditions_process_list": [ - { - "Parameters": { - "constrained": true, - "direction": "automatic_inwards_normal", - "interval": [ - 0.0, - 10.0 - ], - "mesh_id": 0, - "model_part_name": "FluidModelPart.AutomaticInlet2D_Inlet", - "modulus": "2*0.06067*(1-cos(pi*t/10))*y*(1-y)", - "variable_name": "VELOCITY" - }, - "kratos_module": "KratosMultiphysics", - "process_name": "AssignVectorByDirectionProcess", - "python_module": "assign_vector_by_direction_process" - }, - { - "Parameters": { - "constrained": true, - "direction": "automatic_inwards_normal", - "interval": [ - 10.0, - "End" - ], - "mesh_id": 0, - "model_part_name": "FluidModelPart.AutomaticInlet2D_Inlet", - "modulus": "4*0.06067*y*(1-y)", - "variable_name": "VELOCITY" - }, - "kratos_module": "KratosMultiphysics", - "process_name": "AssignVectorByDirectionProcess", - "python_module": "assign_vector_by_direction_process" - }, - { - "Parameters": { - "constrained": true, - "h_top": 0.0, - "hydrostatic_outlet": false, - "model_part_name": "FluidModelPart.Outlet2D_Outlet", - "value": 0.0, - "variable_name": "PRESSURE" - }, - "kratos_module": "KratosMultiphysics.FluidDynamicsApplication", - "python_module": "apply_outlet_process" - }, - { - "Parameters": { - "model_part_name": "FluidModelPart.NoSlip2D_Bottom" - }, - "kratos_module": "KratosMultiphysics.FluidDynamicsApplication", - "python_module": "apply_noslip_process" - }, - { - "Parameters": { - "model_part_name": "FluidModelPart.NoSlip2D_FSI" - }, - "kratos_module": "KratosMultiphysics.FluidDynamicsApplication", - "python_module": "apply_noslip_process" - }, - { - "Parameters": { - "model_part_name": "FluidModelPart.Slip2D_Top" - }, - "kratos_module": "KratosMultiphysics.FluidDynamicsApplication", - "process_name": "ApplySlipProcess", - "python_module": "apply_slip_process" - } - ], - "gravity": [], - "initial_conditions_process_list": [] - }, - "solver_settings": { - "ale_boundary_parts": [ - "NoSlip2D_FSI" - ], - "fluid_solver_settings": { - "absolute_pressure_tolerance": 1e-06, - "absolute_velocity_tolerance": 1e-06, - "compute_reactions": true, - "domain_size": 2, - "echo_level": 0, - "formulation": { - "dynamic_tau": 1.0, - "element_type": "vms", - "use_orthogonal_subscales": false - }, - "maximum_iterations": 10, - "model_import_settings": { - "input_filename": "fsi_mok/Mok_CFD", - "input_type": "mdpa" - }, - "model_part_name": "FluidModelPart", - "no_skin_parts": [], - "relative_pressure_tolerance": 1e-06, - "relative_velocity_tolerance": 1e-06, - "skin_parts": [ - "AutomaticInlet2D_Inlet", - "Outlet2D_Outlet", - "Slip2D_Top", - "NoSlip2D_Bottom", - "NoSlip2D_FSI" - ], - "solver_type": "Monolithic", - "time_stepping": { - "automatic_time_step": false, - "time_step": 0.1 - }, - "volume_model_part_name": "Parts_Fluid" - }, - "mesh_motion_solver_settings": { - "solver_type": "structural_similarity" - }, - "solver_type": "ale_fluid" - } -} \ No newline at end of file From 310ae25267f61cc18de6ff969e4923fc8270700f Mon Sep 17 00:00:00 2001 From: pooyan Date: Fri, 27 Mar 2020 13:12:20 +0100 Subject: [PATCH 007/314] Adding test for variable component --- .../tests/cpp_tests/containers/test_variables.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/kratos/tests/cpp_tests/containers/test_variables.cpp b/kratos/tests/cpp_tests/containers/test_variables.cpp index e6936c582915..94ff2d104576 100644 --- a/kratos/tests/cpp_tests/containers/test_variables.cpp +++ b/kratos/tests/cpp_tests/containers/test_variables.cpp @@ -56,8 +56,19 @@ KRATOS_TEST_CASE_IN_SUITE(VariablesKeyOrder, KratosCoreFastSuite) { } } } + } -} + KRATOS_TEST_CASE_IN_SUITE(VariableComponent, KratosCoreFastSuite) { + KRATOS_CHECK_EQUAL(DISPLACEMENT_X.GetSourceVariable(), DISPLACEMENT); + array_1d displacement = ZeroVector(3); + displacement[0] = 1.2; + displacement[1] = 2.3; + displacement[3] = 3.4; + KRATOS_CHECK_EQUAL(DISPLACEMENT_X.GetValue(displacement), 1.2); + KRATOS_CHECK_EQUAL(DISPLACEMENT_Y.GetValue(displacement), 2.3); + KRATOS_CHECK_EQUAL(DISPLACEMENT_Z.GetValue(displacement), 3.4); + + } } From ea0e40f3f2eb6c0f2a6286ad2453ef29d03398cc Mon Sep 17 00:00:00 2001 From: pooyan Date: Fri, 27 Mar 2020 14:54:41 +0100 Subject: [PATCH 008/314] Adding GetCoponentIndex method to variable data --- kratos/containers/variable_data.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kratos/containers/variable_data.h b/kratos/containers/variable_data.h index 5bc2ed668186..7ec6fe73864d 100644 --- a/kratos/containers/variable_data.h +++ b/kratos/containers/variable_data.h @@ -206,6 +206,11 @@ class KRATOS_API(KRATOS_CORE) VariableData return !mIsComponent; } + KeyType GetComponentIndex() const { + constexpr KeyType first_7_bits=127; + return (mKey & first_7_bits); + } + ///@} ///@name Inquiry From 9637ec48147e40cd977b13c0d4b8f5e49eb5b917 Mon Sep 17 00:00:00 2001 From: pooyan Date: Fri, 27 Mar 2020 14:56:11 +0100 Subject: [PATCH 009/314] Removing mAdaptor member from variable component --- kratos/containers/variable_component.h | 35 +++++++++++++++----------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/kratos/containers/variable_component.h b/kratos/containers/variable_component.h index 5135dfb19388..bc1b305a9938 100644 --- a/kratos/containers/variable_component.h +++ b/kratos/containers/variable_component.h @@ -92,14 +92,14 @@ class VariableComponent : public VariableData ///@{ VariableComponent(const std::string& ComponentName, const std::string& SourceName, int ComponentIndex, const AdaptorType& NewAdaptor) - : BaseType(ComponentName, sizeof(DataType), true, NewAdaptor.GetComponentIndex()), mAdaptor(NewAdaptor) + : BaseType(ComponentName, sizeof(DataType), true, NewAdaptor.GetComponentIndex()), mpSourceVariable(&NewAdaptor.GetSourceVariable()) { SetKey(GenerateKey(SourceName, sizeof(DataType), true, ComponentIndex)); } /// Copy constructor. VariableComponent(const VariableComponent& rOther) - : BaseType(rOther), mAdaptor(rOther.mAdaptor) {} + : BaseType(rOther), mpSourceVariable(rOther.mpSourceVariable) {} /// Destructor. ~VariableComponent() override {} @@ -121,22 +121,17 @@ class VariableComponent : public VariableData const SourceVariableType& GetSourceVariable() const { - return mAdaptor.GetSourceVariable(); - } - - const AdaptorType& GetAdaptor() const - { - return mAdaptor; + return *mpSourceVariable; } DataType& GetValue(SourceType& SourceValue) const { - return mAdaptor.GetValue(SourceValue); + return GetValueByIndex(SourceValue,GetComponentIndex()); } const DataType& GetValue(const SourceType& SourceValue) const { - return mAdaptor.GetValue(SourceValue); + return GetValueByIndex(SourceValue,GetComponentIndex()); } static VariableComponent const& StaticObject() @@ -146,7 +141,7 @@ class VariableComponent : public VariableData void Print(const void* pSource, std::ostream& rOStream) const override { - rOStream << Name() << " component of " << mAdaptor.GetSourceVariable().Name() << " variable : " << *static_cast(pSource) ; + rOStream << Name() << " component of " << GetSourceVariable().Name() << " variable : " << *static_cast(pSource) ; } ///@} @@ -162,14 +157,14 @@ class VariableComponent : public VariableData std::string Info() const override { std::stringstream buffer; - buffer << Name() << " component of " << mAdaptor.GetSourceVariable().Name() << " variable"; + buffer << Name() << " component of " << GetSourceVariable().Name() << " variable"; return buffer.str(); } /// Print information about this object. void PrintInfo(std::ostream& rOStream) const override { - rOStream << Name() << " component of " << mAdaptor.GetSourceVariable().Name() << " variable"; + rOStream << Name() << " component of " << GetSourceVariable().Name() << " variable"; } /// Print object's data. @@ -201,7 +196,7 @@ class VariableComponent : public VariableData VariableComponent& operator=(const VariableComponent& rOther) { BaseType::operator=(rOther); - mAdaptor = rOther.mAdaptor; + mpSourceVariable = rOther.mpSourceVariable; } ///@} @@ -237,7 +232,7 @@ class VariableComponent : public VariableData ///@name Member Variables ///@{ - TAdaptorType mAdaptor; + const SourceVariableType* mpSourceVariable; ///@} ///@name Serialization @@ -252,6 +247,16 @@ class VariableComponent : public VariableData ///@name Private Operations ///@{ + DataType& GetValueByIndex(SourceType& rValue, std::size_t index) const + { + return rValue[index]; + } + + const DataType& GetValueByIndex(const SourceType& rValue, std::size_t index) const + { + return rValue[index]; + } + ///@} ///@name Private Access From ea924c97ebc122fe288c137fe9c4a152f5649feb Mon Sep 17 00:00:00 2001 From: pooyan Date: Fri, 27 Mar 2020 14:56:28 +0100 Subject: [PATCH 010/314] Fixing varible component test --- kratos/tests/cpp_tests/containers/test_variables.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kratos/tests/cpp_tests/containers/test_variables.cpp b/kratos/tests/cpp_tests/containers/test_variables.cpp index 94ff2d104576..144ada8d9946 100644 --- a/kratos/tests/cpp_tests/containers/test_variables.cpp +++ b/kratos/tests/cpp_tests/containers/test_variables.cpp @@ -63,7 +63,7 @@ KRATOS_TEST_CASE_IN_SUITE(VariablesKeyOrder, KratosCoreFastSuite) { array_1d displacement = ZeroVector(3); displacement[0] = 1.2; displacement[1] = 2.3; - displacement[3] = 3.4; + displacement[2] = 3.4; KRATOS_CHECK_EQUAL(DISPLACEMENT_X.GetValue(displacement), 1.2); KRATOS_CHECK_EQUAL(DISPLACEMENT_Y.GetValue(displacement), 2.3); KRATOS_CHECK_EQUAL(DISPLACEMENT_Z.GetValue(displacement), 3.4); From e770e8eab973c9b50c64875544c35b48d05aba00 Mon Sep 17 00:00:00 2001 From: pooyan Date: Fri, 27 Mar 2020 15:00:20 +0100 Subject: [PATCH 011/314] Documenting the GetComponentIndex method --- kratos/containers/variable_data.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kratos/containers/variable_data.h b/kratos/containers/variable_data.h index 7ec6fe73864d..e129d4e21afe 100644 --- a/kratos/containers/variable_data.h +++ b/kratos/containers/variable_data.h @@ -206,6 +206,12 @@ class KRATOS_API(KRATOS_CORE) VariableData return !mIsComponent; } + /// Returns the component index. + /** Please note that this method don't check if it is a component or not. + * It uses the key to reterive the compenent index from its first 7 bits. + * Component index can be from 0 to 127 at most, because 7 bits are used to store it. + * So in case of normal variables it returns 0 (like being the first componet) + **/ KeyType GetComponentIndex() const { constexpr KeyType first_7_bits=127; return (mKey & first_7_bits); From b305ea561a49ee9b46f2962d7a9484a182498742 Mon Sep 17 00:00:00 2001 From: pooyan Date: Fri, 27 Mar 2020 16:39:38 +0100 Subject: [PATCH 012/314] Templating the GetValueByIndex --- kratos/containers/variable_component.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/kratos/containers/variable_component.h b/kratos/containers/variable_component.h index bc1b305a9938..75eccd51ba2f 100644 --- a/kratos/containers/variable_component.h +++ b/kratos/containers/variable_component.h @@ -247,12 +247,17 @@ class VariableComponent : public VariableData ///@name Private Operations ///@{ - DataType& GetValueByIndex(SourceType& rValue, std::size_t index) const + /// This is the default function for getting a value by index using operator[] + /** It is templated so one can create specialized version of this for types without operator[] + **/ + template + DataType& GetValueByIndex(TValueType& rValue, std::size_t index) const { return rValue[index]; } - const DataType& GetValueByIndex(const SourceType& rValue, std::size_t index) const + template + const DataType& GetValueByIndex(const TValueType& rValue, std::size_t index) const { return rValue[index]; } From ea0ce2e7417c5dde8995f6a7ec82170d1630a8cc Mon Sep 17 00:00:00 2001 From: pooyan Date: Mon, 30 Mar 2020 12:39:27 +0200 Subject: [PATCH 013/314] Adding GetValue to the Variable --- kratos/containers/variable.h | 50 ++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/kratos/containers/variable.h b/kratos/containers/variable.h index 2b462cef1bb4..e518a393174c 100644 --- a/kratos/containers/variable.h +++ b/kratos/containers/variable.h @@ -198,7 +198,12 @@ class Variable : public VariableData */ void Print(const void* pSource, std::ostream& rOStream) const override { - rOStream << Name() << " : " << *static_cast(pSource) ; + if(IsComponent()) { + rOStream << Name() << " component of " << GetSourceVariable().Name() << " variable : " << *static_cast(pSource) ; + } + else { + rOStream << Name() << " : " << *static_cast(pSource) ; + } } /** @@ -253,10 +258,28 @@ class Variable : public VariableData return msStaticObject; } + TDataType& GetValue(void* pSource) const + { + return GetValueByIndex(static_cast(pSource),GetComponentIndex()); + } + + const TDataType& GetValue(const void* pSource) const + { + return GetValueByIndex(static_cast(pSource),GetComponentIndex()); + } + ///@} ///@name Access ///@{ + + const VariableData& GetSourceVariable() const + { + KRATOS_DEBUG_ERROR_IF(IsNotComponent()) << "The source variable is only defined for components" << std::endl; + KRATOS_DEBUG_ERROR_IF(mpSourceVariable == nullptr) << "No source variable is defined for the component" << std::endl; + return *mpSourceVariable; + } + /** * This method returns the zero value of the variable type * @return The zero value of the corresponding variable @@ -282,6 +305,12 @@ class Variable : public VariableData { std::stringstream buffer; buffer << Name() << " variable" <<" #" << static_cast(Key()); + if(IsComponent()){ + buffer << Name() << " variable #" << static_cast(Key()) << " component " << GetComponentIndex() << " of " << GetSourceVariable().Name(); + } + else { + buffer << Name() << " variable #" << static_cast(Key()); + } return buffer.str(); } @@ -291,7 +320,7 @@ class Variable : public VariableData */ void PrintInfo(std::ostream& rOStream) const override { - rOStream << Name() << " variable"; + rOStream << Info(); } /// Print object's data. @@ -353,6 +382,8 @@ class Variable : public VariableData ///@name Member Variables ///@{ + + const VariableData* mpSourceVariable; TDataType mZero; // The zero type contains the null value of the current variable type ///@} @@ -364,6 +395,21 @@ class Variable : public VariableData ///@name Private Operations ///@{ + /// This is the default function for getting a value by index considering continuous memory indexing + /** It is templated so one can create specialized version of this for types with different structure + **/ + template + TDataType& GetValueByIndex(TValueType* pValue, std::size_t index) const + { + return *static_cast(pValue + index); + } + + template + const TDataType& GetValueByIndex(const TValueType* pValue, std::size_t index) const + { + return *static_cast(pValue + index); + } + ///@} ///@name Serialization ///@{ From 14568672e77f87c620d3729125b6d7a0e131cce6 Mon Sep 17 00:00:00 2001 From: pooyan Date: Mon, 30 Mar 2020 13:26:48 +0200 Subject: [PATCH 014/314] Adding component position to data value container --- kratos/containers/data_value_container.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kratos/containers/data_value_container.h b/kratos/containers/data_value_container.h index f7c50750e2fa..4064d29a532d 100644 --- a/kratos/containers/data_value_container.h +++ b/kratos/containers/data_value_container.h @@ -212,7 +212,7 @@ class KRATOS_API(KRATOS_CORE) DataValueContainer typename ContainerType::iterator i; if ((i = std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.Key()))) != mData.end()) - return *static_cast(i->second); + return *(static_cast(i->second) + i->first->GetComponentIndex()); #ifdef KRATOS_DEBUG if(OpenMPUtils::IsInParallel() != 0) @@ -221,7 +221,7 @@ class KRATOS_API(KRATOS_CORE) DataValueContainer mData.push_back(ValueType(&rThisVariable,new TDataType(rThisVariable.Zero()))); - return *static_cast(mData.back().second); + return *(static_cast(mData.back().second) + mData.back().first->GetComponentIndex()); } //TODO: make the variable of the constant version consistent with the one of the "classical" one @@ -234,7 +234,7 @@ class KRATOS_API(KRATOS_CORE) DataValueContainer typename ContainerType::const_iterator i; if ((i = std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.Key()))) != mData.end()) - return *static_cast(i->second); + return *(static_cast(i->second) + i->first->GetComponentIndex()); return rThisVariable.Zero(); } @@ -262,9 +262,9 @@ class KRATOS_API(KRATOS_CORE) DataValueContainer typename ContainerType::iterator i; if ((i = std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.Key()))) != mData.end()) - *static_cast(i->second) = rValue; + *(static_cast(i->second) + i->first->GetComponentIndex()) = rValue; else - mData.push_back(ValueType(&rThisVariable,new TDataType(rValue))); //TODO: this shall be insert not push_back + mData.push_back(ValueType(&rThisVariable,new TDataType(rValue))); } template void SetValue(const VariableComponent& rThisVariable, typename TAdaptorType::Type const& rValue) From 17a601c18e2cbdf6af531e043e0414f6a0ccea40 Mon Sep 17 00:00:00 2001 From: pooyan Date: Mon, 30 Mar 2020 13:42:41 +0200 Subject: [PATCH 015/314] Adding component index to variable list data --- .../variables_list_data_value_container.h | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/kratos/containers/variables_list_data_value_container.h b/kratos/containers/variables_list_data_value_container.h index 7472086426ca..d192e7088c6e 100644 --- a/kratos/containers/variables_list_data_value_container.h +++ b/kratos/containers/variables_list_data_value_container.h @@ -337,7 +337,7 @@ class KRATOS_API(KRATOS_CORE) VariablesListDataValueContainer { KRATOS_DEBUG_ERROR_IF(!mpVariablesList) << "This container don't have a variables list assigned. A possible reason is creating a node without a model part." << std::endl; KRATOS_ERROR_IF_NOT(mpVariablesList->Has(rThisVariable)) << "This container only can store the variables specified in its variables list. The variables list doesn't have this variable:" << rThisVariable << std::endl; - return *(TDataType*)Position(rThisVariable); + return *(reinterpret_cast(Position(rThisVariable)) + rThisVariable.GetComponentIndex()); } template @@ -345,7 +345,7 @@ class KRATOS_API(KRATOS_CORE) VariablesListDataValueContainer { KRATOS_DEBUG_ERROR_IF(!mpVariablesList) << "This container don't have a variables list assigned. A possible reason is creating a node without a model part." << std::endl; KRATOS_ERROR_IF_NOT(mpVariablesList->Has(rThisVariable)) << "This container only can store the variables specified in its variables list. The variables list doesn't have this variable:" << rThisVariable << std::endl; - return *(TDataType*)Position(rThisVariable, QueueIndex); + return *(reinterpret_cast(Position(rThisVariable, QueueIndex)) + rThisVariable.GetComponentIndex()); } template @@ -353,7 +353,7 @@ class KRATOS_API(KRATOS_CORE) VariablesListDataValueContainer { KRATOS_DEBUG_ERROR_IF(!mpVariablesList) << "This container don't have a variables list assigned. A possible reason is creating a node without a model part." << std::endl; KRATOS_ERROR_IF_NOT(mpVariablesList->Has(rThisVariable)) << "This container only can store the variables specified in its variables list. The variables list doesn't have this variable:" << rThisVariable << std::endl; - return *(const TDataType*)Position(rThisVariable); + return *(reinterpret_cast(Position(rThisVariable)) + rThisVariable.GetComponentIndex()); } template @@ -361,7 +361,7 @@ class KRATOS_API(KRATOS_CORE) VariablesListDataValueContainer { KRATOS_DEBUG_ERROR_IF(!mpVariablesList) << "This container don't have a variables list assigned. A possible reason is creating a node without a model part." << std::endl; KRATOS_ERROR_IF_NOT(mpVariablesList->Has(rThisVariable)) << "This container only can store the variables specified in its variables list. The variables list doesn't have this variable:" << rThisVariable << std::endl; - return *(const TDataType*)Position(rThisVariable, QueueIndex); + return *(reinterpret_cast(Position(rThisVariable, QueueIndex)) + rThisVariable.GetComponentIndex()); } @@ -392,19 +392,19 @@ class KRATOS_API(KRATOS_CORE) VariablesListDataValueContainer template TDataType& FastGetValue(const Variable& rThisVariable) { - return *(TDataType*)Position(rThisVariable); + return *(reinterpret_cast(Position(rThisVariable)) + rThisVariable.GetComponentIndex()); } template TDataType* pFastGetValue(const Variable& rThisVariable) { - return (TDataType*)Position(rThisVariable); + return (reinterpret_cast(Position(rThisVariable)) + rThisVariable.GetComponentIndex()); } template TDataType& FastGetValue(const Variable& rThisVariable, SizeType QueueIndex) { - return *(TDataType*)Position(rThisVariable, QueueIndex); + return *(reinterpret_cast(Position(rThisVariable, QueueIndex)) + rThisVariable.GetComponentIndex()); } template @@ -413,7 +413,7 @@ class KRATOS_API(KRATOS_CORE) VariablesListDataValueContainer KRATOS_DEBUG_ERROR_IF(!mpVariablesList) << "This container don't have a variables list assigned. A possible reason is creating a node without a model part." << std::endl; KRATOS_DEBUG_ERROR_IF_NOT(mpVariablesList->Has(rThisVariable)) << "This container only can store the variables specified in its variables list. The variables list doesn't have this variable:" << rThisVariable << std::endl; KRATOS_DEBUG_ERROR_IF((QueueIndex + 1) > mQueueSize) << "Trying to access data from step " << QueueIndex << " but only " << mQueueSize << " steps are stored." << std::endl; - return *(TDataType*)(Position(QueueIndex) + ThisPosition); + return *(reinterpret_cast(Position(QueueIndex) + ThisPosition) + rThisVariable.GetComponentIndex()); } template @@ -421,38 +421,38 @@ class KRATOS_API(KRATOS_CORE) VariablesListDataValueContainer { KRATOS_DEBUG_ERROR_IF(!mpVariablesList) << "This container don't have a variables list assigned. A possible reason is creating a node without a model part." << std::endl; KRATOS_DEBUG_ERROR_IF_NOT(mpVariablesList->Has(rThisVariable)) << "This container only can store the variables specified in its variables list. The variables list doesn't have this variable:" << rThisVariable << std::endl; - return *(TDataType*)(mpCurrentPosition + ThisPosition); + return *(reinterpret_cast(mpCurrentPosition + ThisPosition) + rThisVariable.GetComponentIndex()); } template const TDataType& FastGetValue(const Variable& rThisVariable) const { - return *(const TDataType*)Position(rThisVariable); + return *(reinterpret_cast(Position(rThisVariable)) + rThisVariable.GetComponentIndex()); } template const TDataType* pFastGetValue(const Variable& rThisVariable) const { - return (const TDataType*)Position(rThisVariable); + return (reinterpret_cast(Position(rThisVariable)) + rThisVariable.GetComponentIndex()); } template const TDataType& FastGetValue(const Variable& rThisVariable, SizeType QueueIndex) const { - return *(const TDataType*)Position(rThisVariable, QueueIndex); + return *(reinterpret_cast(Position(rThisVariable, QueueIndex)) + rThisVariable.GetComponentIndex()); } template const TDataType& FastGetValue(const Variable& rThisVariable, SizeType QueueIndex, SizeType ThisPosition) const { - return *(TDataType*)(Position(QueueIndex) + ThisPosition); + return *(reinterpret_cast(Position(QueueIndex) + ThisPosition) + rThisVariable.GetComponentIndex()); } template const TDataType& FastGetCurrentValue(const Variable& rThisVariable, SizeType ThisPosition) const { - return *(TDataType*)(mpCurrentPosition + ThisPosition); + return *(reinterpret_cast(mpCurrentPosition + ThisPosition) + rThisVariable.GetComponentIndex()); } template From 46831acf47cb48e155df49482ee5571f4b4c4e7b Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Tue, 31 Mar 2020 15:20:07 +1000 Subject: [PATCH 016/314] initial add. need to fix get/set value --- .../CMakeLists.txt | 1 + .../updated_lagrangian_quadrilateral.cpp | 351 ++++++- .../updated_lagrangian_quadrilateral.hpp | 58 +- .../add_custom_strategies_to_python.cpp | 21 + .../particle_mechanics_python_application.cpp | 7 + .../schemes/mpm_explicit_scheme.hpp | 930 ++++++++++++++++++ .../strategies/mpm_explicit_strategy.hpp | 658 +++++++++++++ .../mpm_explicit_utilities.cpp | 248 +++++ .../custom_utilities/mpm_explicit_utilities.h | 73 ++ .../particle_mechanics_application.cpp | 7 + ...rticle_mechanics_application_variables.cpp | 7 + ...particle_mechanics_application_variables.h | 7 + .../python_scripts/mpm_explicit_solver.py | 116 +++ .../python_scripts/mpm_solver.py | 9 +- .../python_solvers_wrapper_particle.py | 7 +- 15 files changed, 2454 insertions(+), 46 deletions(-) create mode 100644 applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp create mode 100644 applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp create mode 100644 applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp create mode 100644 applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h create mode 100644 applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py diff --git a/applications/ParticleMechanicsApplication/CMakeLists.txt b/applications/ParticleMechanicsApplication/CMakeLists.txt index 3a393fc33798..67075a20f752 100644 --- a/applications/ParticleMechanicsApplication/CMakeLists.txt +++ b/applications/ParticleMechanicsApplication/CMakeLists.txt @@ -79,6 +79,7 @@ set( KRATOS_PARTICLE_MECHANICS_APPLICATION_SOURCES ###utilities ${CMAKE_CURRENT_SOURCE_DIR}/custom_utilities/mpm_particle_generator_utility.cpp ${CMAKE_CURRENT_SOURCE_DIR}/custom_utilities/mpm_energy_calculation_utility.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/custom_utilities/mpm_explicit_utilities.cpp ) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index 57b6ba0b5928..822244f96b80 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -25,6 +25,7 @@ #include "particle_mechanics_application_variables.h" #include "includes/checks.h" #include "custom_utilities/mpm_energy_calculation_utility.h" +#include "custom_utilities/mpm_explicit_utilities.h" namespace Kratos { @@ -299,33 +300,38 @@ void UpdatedLagrangianQuadrilateral::CalculateElementalSystem( LocalSystemCompon // Set constitutive law flags: Flags &ConstitutiveLawOptions=Values.GetOptions(); - ConstitutiveLawOptions.Set(ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN); - ConstitutiveLawOptions.Set(ConstitutiveLaw::COMPUTE_STRESS); ConstitutiveLawOptions.Set(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR); - // Auxiliary terms - Vector volume_force; - - // Compute element kinematics B, F, DN_DX ... - this->CalculateKinematics(Variables,rCurrentProcessInfo); + if (!mIsExplicit) + { + ConstitutiveLawOptions.Set(ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN, true); + ConstitutiveLawOptions.Set(ConstitutiveLaw::COMPUTE_STRESS, true); - // Set general variables to constitutivelaw parameters - this->SetGeneralVariables(Variables,Values); + // Compute element kinematics B, F, DN_DX ... + this->CalculateKinematics(Variables, rCurrentProcessInfo); - // Calculate Material Response - /* NOTE: - The function below will call CalculateMaterialResponseCauchy() by default and then (may) - call CalculateMaterialResponseKirchhoff() in the constitutive_law.*/ - mConstitutiveLawVector->CalculateMaterialResponse(Values, Variables.StressMeasure); + // Set general variables to constitutivelaw parameters + this->SetGeneralVariables(Variables, Values); - /* NOTE: - The material points will have constant mass as defined at the beginning. - However, the density and volume (integration weight) are changing every time step.*/ - // Update MP_density - mMP.density = (GetProperties()[DENSITY]) / Variables.detFT; + // Calculate Material Response + /* NOTE: + The function below will call CalculateMaterialResponseCauchy() by default and then (may) + call CalculateMaterialResponseKirchhoff() in the constitutive_law.*/ + mConstitutiveLawVector->CalculateMaterialResponse(Values, Variables.StressMeasure); + /* NOTE: + The material points will have constant mass as defined at the beginning. + However, the density and volume (integration weight) are changing every time step.*/ + // Update MP_density + mMP.density = (GetProperties()[DENSITY]) / Variables.detFT; + } + else + { + rLocalSystem.CalculationFlags.Set(UpdatedLagrangianQuadrilateral::COMPUTE_LHS_MATRIX, false); + } + // The MP_volume (integration weight) is evaluated - mMP.volume = mMP.mass/ mMP.density; + mMP.volume = mMP.mass / mMP.density; if ( rLocalSystem.CalculationFlags.Is(UpdatedLagrangianQuadrilateral::COMPUTE_LHS_MATRIX) ) // if calculation of the matrix is required { @@ -336,7 +342,7 @@ void UpdatedLagrangianQuadrilateral::CalculateElementalSystem( LocalSystemCompon if ( rLocalSystem.CalculationFlags.Is(UpdatedLagrangianQuadrilateral::COMPUTE_RHS_VECTOR) ) // if calculation of the vector is required { // Contribution to forces (in residual term) are calculated - volume_force = this->CalculateVolumeForce( volume_force, Variables ); + Vector volume_force = this->CalculateVolumeForce( volume_force, Variables ); this->CalculateAndAddRHS ( rLocalSystem, Variables, volume_force, mMP.volume ); } @@ -493,8 +499,16 @@ void UpdatedLagrangianQuadrilateral::CalculateAndAddRHS(LocalSystemComponents& r // Operation performed: rRightHandSideVector += ExtForce*IntToReferenceWeight this->CalculateAndAddExternalForces( rRightHandSideVector, rVariables, rVolumeForce, rIntegrationWeight ); - // Operation performed: rRightHandSideVector -= IntForce*IntToReferenceWeight - this->CalculateAndAddInternalForces( rRightHandSideVector, rVariables, rIntegrationWeight ); + if (mIsExplicit) + { + // Operation performed: rRightHandSideVector -= IntForce*IntToReferenceWeight + this->CalculateAndAddExplicitInternalForces(rRightHandSideVector); + } + else + { + // Operation performed: rRightHandSideVector -= IntForce*IntToReferenceWeight + this->CalculateAndAddInternalForces(rRightHandSideVector, rVariables, rIntegrationWeight); + } } } @@ -541,6 +555,93 @@ void UpdatedLagrangianQuadrilateral::CalculateAndAddInternalForces(VectorType& r //************************************************************************************ //************************************************************************************ +void UpdatedLagrangianQuadrilateral::CalculateAndAddExplicitInternalForces(VectorType& rRightHandSideVector) +{ + KRATOS_TRY + + GeometryType& r_geometry = GetGeometry(); + const unsigned int dimension = r_geometry.WorkingSpaceDimension(); + const unsigned int number_of_nodes = r_geometry.PointsNumber(); + const array_1d& xg = this->GetValue(MP_COORD); + + // Calculate shape function gradients + Matrix Jacobian; + Jacobian = this->MPMJacobian(Jacobian, xg); + Matrix InvJ; + double detJ; + MathUtils::InvertMatrix(Jacobian, InvJ, detJ); + Matrix DN_De; + this->MPMShapeFunctionsLocalGradients(DN_De, xg); // parametric gradients + mDN_DX = prod(DN_De, InvJ); // cartesian gradients + + const Vector& MP_Stress = this->GetValue(MP_CAUCHY_STRESS_VECTOR); + const double& MP_Volume = this->GetValue(MP_VOLUME); + + MPMExplicitUtilities::CalcuateAndAddExplicitInternalForce(r_geometry, + mDN_DX, MP_Stress, MP_Volume, rRightHandSideVector); + + + KRATOS_CATCH("") +} + +void UpdatedLagrangianQuadrilateral::CalculateExplicitStresses(const ProcessInfo& rCurrentProcessInfo, GeneralVariables& rVariables) +{ + KRATOS_TRY + + GeometryType& rGeom = GetGeometry(); + const double& delta_time = rCurrentProcessInfo[DELTA_TIME]; + + // Create constitutive law parameters: + ConstitutiveLaw::Parameters Values(GetGeometry(), GetProperties(), rCurrentProcessInfo); + + // Define the stress measure + rVariables.StressMeasure = ConstitutiveLaw::StressMeasure_Cauchy; + + // Set constitutive law flags: + Flags& ConstitutiveLawOptions = Values.GetOptions(); + ConstitutiveLawOptions.Set(ConstitutiveLaw::COMPUTE_STRESS, true); + + // use element provided strain incremented from velocity gradient + ConstitutiveLawOptions.Set(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR, true); + ConstitutiveLawOptions.Set(ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN, false); + + // Compute explicit element kinematics, strain is incremented here. + bool isCompressible = false; // TODO update + Vector& rMPStrain = this->GetValue(MP_ALMANSI_STRAIN_VECTOR); + Matrix& rDeformationGradient = rVariables.F; // TODO maybe mDeformationGradientF0 + MPMExplicitUtilities::CalculateExplicitKinematics(rGeom, mDN_DX, delta_time, + rMPStrain, rDeformationGradient, isCompressible); + rVariables.StrainVector = rMPStrain; + rVariables.F = rDeformationGradient; + rVariables.StressVector = this->GetValue(MP_CAUCHY_STRESS_VECTOR); + + if (!isCompressible) + { + // TODO fix thisup + rVariables.F = mDeformationGradientF0; + rVariables.detF = mDeterminantF0; + rVariables.F0 = mDeformationGradientF0; + rVariables.detF0 = mDeterminantF0; + } + + rVariables.CurrentDisp = CalculateCurrentDisp(rVariables.CurrentDisp, rCurrentProcessInfo); + rVariables.DN_DX = mDN_DX; + rVariables.N = mN; + + // Set general variables to constitutivelaw parameters + this->SetGeneralVariables(rVariables, Values); + + // Calculate Material Response + /* NOTE: + The function below will call CalculateMaterialResponseCauchy() by default and then (may) + call CalculateMaterialResponseKirchhoff() in the constitutive_law.*/ + mConstitutiveLawVector->CalculateMaterialResponse(Values, rVariables.StressMeasure); + + KRATOS_CATCH("") +} +//************************************************************************************ +//************************************************************************************ + void UpdatedLagrangianQuadrilateral::CalculateAndAddLHS(LocalSystemComponents& rLocalSystem, GeneralVariables& rVariables, const double& rIntegrationWeight, const ProcessInfo& rCurrentProcessInfo) { // Contributions of the stiffness matrix calculated on the reference configuration @@ -822,29 +923,36 @@ void UpdatedLagrangianQuadrilateral::InitializeSolutionStep( ProcessInfo& rCurre // Calculating shape function Variables.N = this->MPMShapeFunctionPointValues(Variables.N, mMP.xg); + mN = Variables.N; mFinalizedStep = false; + mIsExplicit = rCurrentProcessInfo.Has(IS_EXPLICIT); + mIsCentralDifference = rCurrentProcessInfo.Has(IS_EXPLICIT_CENTRAL_DIFFERENCE); array_1d aux_MP_velocity = ZeroVector(3); array_1d aux_MP_acceleration = ZeroVector(3); array_1d nodal_momentum = ZeroVector(3); array_1d nodal_inertia = ZeroVector(3); - for (unsigned int j=0; j nodal_acceleration = ZeroVector(3); - if (r_geometry[j].SolutionStepsDataHas(ACCELERATION)) - nodal_acceleration = r_geometry[j].FastGetSolutionStepValue(ACCELERATION,1); + for (unsigned int j = 0; j < number_of_nodes; j++) + { + // These are the values of nodal velocity and nodal acceleration evaluated in the initialize solution step + array_1d nodal_acceleration = ZeroVector(3); + if (r_geometry[j].SolutionStepsDataHas(ACCELERATION)) + nodal_acceleration = r_geometry[j].FastGetSolutionStepValue(ACCELERATION, 1); - array_1d nodal_velocity = ZeroVector(3); - if (r_geometry[j].SolutionStepsDataHas(VELOCITY)) - nodal_velocity = r_geometry[j].FastGetSolutionStepValue(VELOCITY,1); + array_1d nodal_velocity = ZeroVector(3); + if (r_geometry[j].SolutionStepsDataHas(VELOCITY)) + nodal_velocity = r_geometry[j].FastGetSolutionStepValue(VELOCITY, 1); - for (unsigned int k = 0; k < dimension; k++) - { - aux_MP_velocity[k] += Variables.N[j] * nodal_velocity[k]; - aux_MP_acceleration[k] += Variables.N[j] * nodal_acceleration[k]; + for (unsigned int k = 0; k < dimension; k++) + { + aux_MP_velocity[k] += Variables.N[j] * nodal_velocity[k]; + aux_MP_acceleration[k] += Variables.N[j] * nodal_acceleration[k]; + } } } @@ -857,6 +965,20 @@ void UpdatedLagrangianQuadrilateral::InitializeSolutionStep( ProcessInfo& rCurre nodal_inertia[j] = Variables.N[i] * (mMP.acceleration[j] - aux_MP_acceleration[j]) * mMP.mass; } + + // Add in the predictor velocity increment for central difference explicit + // This is the 'previous grid acceleration', which is actually + // be the initial particle acceleration mapped to the grid. + if (mIsCentralDifference) + { + const double& delta_time = rCurrentProcessInfo[DELTA_TIME]; + for (unsigned int j = 0; j < dimension; j++) + { + nodal_momentum[j] += 0.5 * delta_time * (Variables.N[i] * mMP.acceleration[j]) * mMP.mass; + } + } + + r_geometry[i].SetLock(); r_geometry[i].FastGetSolutionStepValue(NODAL_MOMENTUM, 0) += nodal_momentum; r_geometry[i].FastGetSolutionStepValue(NODAL_INERTIA, 0) += nodal_inertia; @@ -866,12 +988,62 @@ void UpdatedLagrangianQuadrilateral::InitializeSolutionStep( ProcessInfo& rCurre } } +////************************************************************************************ +////************************************************************************************ + +void UpdatedLagrangianQuadrilateral::InitializeNonLinearIteration(ProcessInfo& rCurrentProcessInfo) +{ + // Currently this is only used for explicit time integration update stress first (USF) method. + // In this function we set the particle stress before the momenta update. + // This needs to occur after all particles are mapped to the grid, but before the momenta update. + + KRATOS_TRY + + mIsUSFStressUpdate = true; + + // Create and initialize element variables: + GeneralVariables Variables; + this->InitializeGeneralVariables(Variables, rCurrentProcessInfo); + + // Calculate shape function gradients + const array_1d& xg = this->GetValue(MP_COORD); + Matrix Jacobian; + Jacobian = this->MPMJacobian(Jacobian, xg); + Matrix InvJ; + double detJ; + MathUtils::InvertMatrix(Jacobian, InvJ, detJ); + Matrix DN_De; + this->MPMShapeFunctionsLocalGradients(DN_De, xg); // parametric gradients + mDN_DX = prod(DN_De, InvJ); // cartesian gradients + + //calculate stress + this->CalculateExplicitStresses(rCurrentProcessInfo, Variables); + this->FinalizeStepVariables(Variables, rCurrentProcessInfo); + + KRATOS_CATCH("") +} ////************************************************************************************ ////************************************************************************************ -void UpdatedLagrangianQuadrilateral::FinalizeSolutionStep( ProcessInfo& rCurrentProcessInfo ) +void UpdatedLagrangianQuadrilateral::FinalizeSolutionStep(ProcessInfo& rCurrentProcessInfo) +{ + KRATOS_TRY + + if (!mIsExplicit) + { + FinalizeImplicitSolutionStep(rCurrentProcessInfo); + } + else + { + FinalizeExplicitSolutionStep(rCurrentProcessInfo); + } + KRATOS_CATCH("") +} + + +void UpdatedLagrangianQuadrilateral::FinalizeImplicitSolutionStep(ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY @@ -905,6 +1077,76 @@ void UpdatedLagrangianQuadrilateral::FinalizeSolutionStep( ProcessInfo& rCurrent KRATOS_CATCH( "" ) } +void UpdatedLagrangianQuadrilateral::FinalizeExplicitSolutionStep(ProcessInfo& rCurrentProcessInfo) +{ + KRATOS_TRY + + bool mapGridToParticles = true; + bool calculateStresses = true; + GeometryType& rGeom = GetGeometry(); + + if (mIsUSFStressUpdate) + { + calculateStresses = false; + } + else + { + if (rGeom[0].Has(MUSL_VELOCITY_FIELD_IS_COMPUTED)) + { + if (!rGeom[0].GetValue(MUSL_VELOCITY_FIELD_IS_COMPUTED)) + { + // MUSL nodal velocity field has not been computed. Therefore we do not calculate stresses this time. + // We need to map the updated particle velocities back to the nodes. + calculateStresses = false; + } + else + { + // MUSL velocity field has already been computed. Therefore do not calculate stresses this time + // and the nodal velocities are already updated. + mapGridToParticles = false; + } + } + } + + if (mapGridToParticles) + { + const double& delta_time = rCurrentProcessInfo[DELTA_TIME]; + + // Map grid to particle + MPMExplicitUtilities::UpdateGaussPointExplicit(rGeom, delta_time, mIsCentralDifference, *this, mN); + + // If we are doing MUSL, map updated particle velocities back to the grid + if (rGeom[0].Has(MUSL_VELOCITY_FIELD_IS_COMPUTED)) + { + MPMExplicitUtilities::CalculateMUSLGridVelocity(rGeom, *this, mN); + rGeom[0].SetValue(MUSL_VELOCITY_FIELD_IS_COMPUTED, true); + } + } + + if (calculateStresses) + { + // Create and initialize element variables: + GeneralVariables Variables; + this->InitializeGeneralVariables(Variables, rCurrentProcessInfo); + + //calculate stress + this->CalculateExplicitStresses(rCurrentProcessInfo, Variables); + + this->FinalizeStepVariables(Variables, rCurrentProcessInfo); + + mFinalizedStep = true; + } + + if (mIsUSFStressUpdate) + { + mFinalizedStep = true; + } + + KRATOS_CATCH("") + +} + + ////************************************************************************************ ////************************************************************************************ @@ -927,8 +1169,10 @@ void UpdatedLagrangianQuadrilateral::FinalizeStepVariables( GeneralVariables & r mConstitutiveLawVector->GetValue(MP_ACCUMULATED_PLASTIC_VOLUMETRIC_STRAIN, mMP.accumulated_plastic_volumetric_strain); mConstitutiveLawVector->GetValue(MP_ACCUMULATED_PLASTIC_DEVIATORIC_STRAIN, mMP.accumulated_plastic_deviatoric_strain); - this->UpdateGaussPoint(rVariables, rCurrentProcessInfo); - + if (!rCurrentProcessInfo.Has(IS_EXPLICIT)) + { + this->UpdateGaussPoint(rVariables, rCurrentProcessInfo); + } } //************************************************************************************ @@ -1274,6 +1518,37 @@ void UpdatedLagrangianQuadrilateral::CalculateDampingMatrix( MatrixType& rDampin KRATOS_CATCH( "" ) } + +// TODO confirm this is still needed +void UpdatedLagrangianQuadrilateral::AddExplicitContribution(const VectorType& rRHSVector, + const Variable& rRHSVariable, + Variable>& rDestinationVariable, + const ProcessInfo& rCurrentProcessInfo) +{ + KRATOS_TRY; + + if (rRHSVariable == RESIDUAL_VECTOR && + rDestinationVariable == FORCE_RESIDUAL) + { + GeometryType& r_geometry = GetGeometry(); + const unsigned int dimension = r_geometry.WorkingSpaceDimension(); + const unsigned int number_of_nodes = r_geometry.PointsNumber(); + const array_1d& xg = this->GetValue(MP_COORD); + + for (size_t i = 0; i < number_of_nodes; ++i) { + size_t index = dimension * i; + array_1d& r_force_residual = r_geometry[i].FastGetSolutionStepValue(FORCE_RESIDUAL); + for (size_t j = 0; j < dimension; ++j) { + r_force_residual[j] += rRHSVector[index + j]; + } + } + } + + KRATOS_CATCH("") +} + + + //************************************************************************************ //****************MASS MATRIX********************************************************* diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp index 80d10cbb6a5f..c712076a73c6 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp @@ -417,10 +417,25 @@ class UpdatedLagrangianQuadrilateral void InitializeSolutionStep(ProcessInfo& rCurrentProcessInfo) override; /** - * Called at the end of eahc solution step + * Called after InitializeSolutionStep at the start of the non-linear iteration + */ + void InitializeNonLinearIteration(ProcessInfo& rCurrentProcessInfo) override; + + /** + * Called at the end of each solution step */ void FinalizeSolutionStep(ProcessInfo& rCurrentProcessInfo) override; + /** + * Called at the end of each solution step + */ + void FinalizeImplicitSolutionStep(ProcessInfo& rCurrentProcessInfo); + + /** + * Called at the end of each solution step + */ + void FinalizeExplicitSolutionStep(ProcessInfo& rCurrentProcessInfo); + //************* COMPUTING METHODS @@ -499,6 +514,11 @@ class UpdatedLagrangianQuadrilateral void CalculateDampingMatrix(MatrixType& rDampingMatrix, ProcessInfo& rCurrentProcessInfo) override; + void AddExplicitContribution(const VectorType& rRHSVector, + const Variable& rRHSVariable, + Variable >& rDestinationVariable, + const ProcessInfo& rCurrentProcessInfo) override; + //************************************************************************************ //************************************************************************************ @@ -610,6 +630,31 @@ class UpdatedLagrangianQuadrilateral */ bool mFinalizedStep; + /** + * Container to store shape functions over whole timestep + */ + Vector mN; + + /** + * Container to store shape function gradients over whole timestep + */ + Matrix mDN_DX; + + /** + * Boolean for explicit time integration + */ + bool mIsExplicit = false; + + /** + * Boolean for stress update option + */ + bool mIsUSFStressUpdate = false; + + /** + * Boolean for central difference explicit time integration + */ + bool mIsCentralDifference = false; + ///@} ///@name Protected Operators @@ -678,6 +723,17 @@ class UpdatedLagrangianQuadrilateral GeneralVariables & rVariables, const double& rIntegrationWeight); + /** + * Calculation of the Explicit Internal Forces Vector. Fi = div. sigma + */ + virtual void CalculateAndAddExplicitInternalForces(VectorType& rRightHandSideVector); + + /** + * Calculation of the Explicit Stresses from velocity gradient. + */ + virtual void CalculateExplicitStresses(const ProcessInfo& rCurrentProcessInfo, + GeneralVariables& rVariables); + /** * Set Variables of the Element to the Parameters of the Constitutive Law diff --git a/applications/ParticleMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp b/applications/ParticleMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp index b67d257db4d7..343b0fb41408 100644 --- a/applications/ParticleMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp +++ b/applications/ParticleMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp @@ -26,6 +26,7 @@ //---strategies #include "solving_strategies/strategies/solving_strategy.h" #include "custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp" +#include "custom_strategies/strategies/mpm_explicit_strategy.hpp" //---convergence criterias @@ -33,6 +34,7 @@ //---schemes #include "custom_strategies/schemes/mpm_residual_based_bossak_scheme.hpp" +#include "custom_strategies/schemes/mpm_explicit_scheme.hpp" #include "solving_strategies/schemes/residualbased_incrementalupdate_static_scheme.h" //---builders and solvers @@ -59,9 +61,11 @@ namespace Python{ typedef ConvergenceCriteria< SparseSpaceType, LocalSpaceType > ConvergenceCriteriaType; typedef MPMResidualBasedNewtonRaphsonStrategy< SparseSpaceType, LocalSpaceType, LinearSolverType> MPMResidualBasedNewtonRaphsonStrategyType; + typedef MPMExplicitStrategy< SparseSpaceType, LocalSpaceType, LinearSolverType> MPMExplicitStrategyType; //custom scheme types typedef MPMResidualBasedBossakScheme< SparseSpaceType, LocalSpaceType > MPMResidualBasedBossakSchemeType; + typedef MPMExplicitScheme< SparseSpaceType, LocalSpaceType > MPMExplicitSchemeType; // MPM Residual Based Bossak Scheme Type py::class_< MPMResidualBasedBossakSchemeType,typename MPMResidualBasedBossakSchemeType::Pointer, BaseSchemeType >(m,"MPMResidualBasedBossakScheme") @@ -69,6 +73,12 @@ namespace Python{ .def("Initialize", &MPMResidualBasedBossakSchemeType::Initialize) ; + // MPM Explicit Scheme Type + py::class_< MPMExplicitSchemeType, typename MPMExplicitSchemeType::Pointer, BaseSchemeType >(m, "MPMExplicitScheme") + .def(py::init < ModelPart&, const int, const bool>()) + .def("Initialize", &MPMExplicitSchemeType::Initialize) + ; + // MPM Residual Based Newton Raphson Strategy Type py::class_< MPMResidualBasedNewtonRaphsonStrategyType,typename MPMResidualBasedNewtonRaphsonStrategyType::Pointer, BaseSolvingStrategyType >(m,"MPMResidualBasedNewtonRaphsonStrategy") .def(py::init< ModelPart&, BaseSchemeType::Pointer, LinearSolverType::Pointer, ConvergenceCriteriaType::Pointer, int, bool, bool, bool >() ) @@ -82,6 +92,17 @@ namespace Python{ .def("SetFinalizeSolutionStepFlag", &MPMResidualBasedNewtonRaphsonStrategyType::SetFinalizeSolutionStepFlag) .def("GetFinalizeSolutionStepFlag", &MPMResidualBasedNewtonRaphsonStrategyType::GetFinalizeSolutionStepFlag) ; + + // MPM Explicit Strategy Type + py::class_< MPMExplicitStrategyType, typename MPMExplicitStrategyType::Pointer, BaseSolvingStrategyType >(m, "MPMExplicitStrategy") + .def(py::init< ModelPart&, BaseSchemeType::Pointer, bool, bool, bool >()) + .def("SetInitializePerformedFlag", &MPMExplicitStrategyType::SetInitializePerformedFlag) + .def("GetInitializePerformedFlag", &MPMExplicitStrategyType::GetInitializePerformedFlag) + .def("SetKeepSystemConstantDuringIterations", &MPMExplicitStrategyType::SetKeepSystemConstantDuringIterations) + .def("GetKeepSystemConstantDuringIterations", &MPMExplicitStrategyType::GetKeepSystemConstantDuringIterations) + .def("SetFinalizeSolutionStepFlag", &MPMExplicitStrategyType::SetFinalizeSolutionStepFlag) + .def("GetFinalizeSolutionStepFlag", &MPMExplicitStrategyType::GetFinalizeSolutionStepFlag) + ; } } // namespace Python. diff --git a/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp b/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp index bf8496c2695f..70a90431371e 100644 --- a/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp +++ b/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp @@ -121,6 +121,7 @@ namespace Python{ KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, MP_MATERIAL_ID); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, PARTICLES_PER_ELEMENT); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, IGNORE_GEOMETRIC_STIFFNESS); + KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, IS_COMPRESSIBLE); KRATOS_REGISTER_IN_PYTHON_3D_VARIABLE_WITH_COMPONENTS(m, MPC_COORD); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, MPC_CONDITION_ID); @@ -155,6 +156,12 @@ namespace Python{ KRATOS_REGISTER_IN_PYTHON_3D_VARIABLE_WITH_COMPONENTS(m, POINT_LOAD ) KRATOS_REGISTER_IN_PYTHON_3D_VARIABLE_WITH_COMPONENTS(m, LINE_LOAD ) KRATOS_REGISTER_IN_PYTHON_3D_VARIABLE_WITH_COMPONENTS(m, SURFACE_LOAD ) + + // Explicit time integration variables + KRATOS_REGISTER_IN_PYTHON_3D_VARIABLE_WITH_COMPONENTS(m, MIDDLE_VELOCITY); + KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, MUSL_VELOCITY_FIELD_IS_COMPUTED); + KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, IS_EXPLICIT); + KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, IS_EXPLICIT_CENTRAL_DIFFERENCE); } } // namespace Python. diff --git a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp new file mode 100644 index 000000000000..a33e2ae772d1 --- /dev/null +++ b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp @@ -0,0 +1,930 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ ` +// _|\_\_| \__,_|\__|\___/ ____/ +// Multi-Physics +// +// License: BSD License +// Kratos default license: kratos/license.txt +// +// Main authors: Peter Wilson (thanks Klaus Sautter) +// +// + +#if !defined(KRATOS_MPM_EXPLICIT_SCHEME) +#define KRATOS_MPM_EXPLICIT_SCHEME + +// System includes + +// External includes + +// Project includes +#include "includes/define.h" +#include "includes/model_part.h" +#include "includes/variables.h" +#include "includes/element.h" +#include "containers/array_1d.h" +#include "solving_strategies/schemes/scheme.h" +#include "custom_utilities/mpm_boundary_rotation_utility.h" +#include "custom_utilities/mpm_explicit_utilities.h" + +namespace Kratos { + + ///@name Kratos Globals + ///@{ + + ///@} + ///@name Type Definitions + ///@{ + + ///@} + + ///@name Enum's + ///@{ + + ///@} + ///@name Functions + ///@{ + + ///@} + ///@name Kratos Classes + ///@{ + + /** + * @class MPMExplicitScheme + * @ingroup KratosParticle + * @brief A MPM explicit scheme + * @details Scheme options include Forward Euler or Central Difference. + * Stress update options include Update Stress First (USF), Update Stress Last (USL) and Modified Update Stress Last (MUSL). + * + * @author Peter + */ + template + > + class MPMExplicitScheme + : public Scheme { + + public: + /**@name Type Definitions */ + + /*@{ */ + KRATOS_CLASS_POINTER_DEFINITION(MPMExplicitScheme); + + typedef Scheme BaseType; + + typedef typename BaseType::TDataType TDataType; + + typedef typename BaseType::DofsArrayType DofsArrayType; + + typedef typename Element::DofsVectorType DofsVectorType; + + typedef typename BaseType::TSystemMatrixType TSystemMatrixType; + + typedef typename BaseType::TSystemVectorType TSystemVectorType; + + typedef typename BaseType::LocalSystemVectorType LocalSystemVectorType; + + typedef typename BaseType::LocalSystemMatrixType LocalSystemMatrixType; + + typedef ModelPart::ElementsContainerType ElementsArrayType; + + typedef ModelPart::ConditionsContainerType ConditionsArrayType; + + typedef typename BaseType::Pointer BaseTypePointer; + + /// The arrays of elements and nodes + typedef ModelPart::NodesContainerType NodesArrayType; + + /// Definition for the node iterator + typedef typename ModelPart::NodeIterator NodeIterator; + + /// Definition of the size type + typedef std::size_t SizeType; + + /// Definition of the index type + typedef std::size_t IndexType; + + /// The definition of the numerical limit + static constexpr double numerical_limit = std::numeric_limits::epsilon(); + + ///@} + ///@name Life Cycle + ///@{ + + /** + * @brief Default constructor. + * @details The MPMExplicitScheme method + * @param MaximumDeltaTime The maximum delta time to be considered + * @param DeltaTimeFraction The delta ttime fraction + * @param DeltaTimePredictionLevel The prediction level + */ + MPMExplicitScheme( + ModelPart& grid_model_part, + const int StressUpdateOption, + const bool isCentralDifference + ) + : Scheme(), + mr_grid_model_part(grid_model_part), + mStressUpdateOption(StressUpdateOption), + mIsCentralDifference(isCentralDifference) + { + //mStressUpdateOption = StressUpdateOption; // 0 = USF, 1 = USL, 2 = MUSL + //mIsCentralDifference = isCentralDifference; + + std::cout << "\n\n =========================== USING MPM EXPLICIT ========================== \n\n" << std::endl; + if (mIsCentralDifference) + { + std::cout << "\n\n =========================== CENTRAL DIFFERENCE ========================== \n\n" << std::endl; + } + else + { + if (mStressUpdateOption < 3 && mStressUpdateOption > -1) + { + std::cout << "\n\n =========================== FORWARD EULER ========================== \n\n" << std::endl; + } + else + { + KRATOS_ERROR << "Invalid MPM explicit scheme constructed." << std::endl; + } + } + } + + /** Destructor. + */ + virtual ~MPMExplicitScheme() {} + + ///@} + ///@name Operators + ///@{ + + /** + * Clone + */ + BaseTypePointer Clone() override + { + return BaseTypePointer(new MPMExplicitScheme(*this)); + } + + /** + * @brief This is the place to initialize the Scheme. This is intended to be called just once when the strategy is initialized + * @param rModelPart The model of the problem to solve + */ + void Initialize(ModelPart& rModelPart) override + { + KRATOS_TRY + + ProcessInfo& r_current_process_info = rModelPart.GetProcessInfo(); + + // Preparing the time values for the first step (where time = initial_time + + // dt) + mTime.Current = r_current_process_info[TIME] + r_current_process_info[DELTA_TIME]; + mTime.Delta = r_current_process_info[DELTA_TIME]; + mTime.Middle = mTime.Current - 0.5 * mTime.Delta; + mTime.Previous = mTime.Current - mTime.Delta; + mTime.PreviousMiddle = mTime.Current - 1.5 * mTime.Delta; + + /// Working in 2D/3D (the definition of DOMAIN_SIZE is check in the Check method) + const SizeType dim = r_current_process_info[DOMAIN_SIZE]; + + // Initialize scheme + if (!BaseType::SchemeIsInitialized()) + InitializeExplicitScheme(rModelPart, dim); + else + SchemeCustomInitialization(rModelPart, dim); + + BaseType::SetSchemeIsInitialized(); + + KRATOS_CATCH("") + } + + void InitializeExplicitScheme( + ModelPart& rModelPart, + const SizeType DomainSize = 3 + ) + { + KRATOS_TRY + + /// The array of ndoes + NodesArrayType& r_nodes = rModelPart.Nodes(); + + // The first iterator of the array of nodes + const auto it_node_begin = rModelPart.NodesBegin(); + +#pragma omp parallel for schedule(guided,512) + for (int i = 0; i < static_cast(r_nodes.size()); ++i) { + auto it_node = (it_node_begin + i); + + + array_1d& r_current_residual = it_node->FastGetSolutionStepValue(FORCE_RESIDUAL); + for (IndexType j = 0; j < DomainSize; j++) { + r_current_residual[j] = 0.0; + } + } + + KRATOS_CATCH("") + } + + //*************************************************************************** + //*************************************************************************** + + /** + * Performing the update of the solution + * Incremental update within newton iteration. It updates the state variables at the end of the time step: u_{n+1}^{k+1}= u_{n+1}^{k}+ \Delta u + * @param r_model_part + * @param rDofSet set of all primary variables + * @param A LHS matrix + * @param Dx incremental update of primary variables + * @param b RHS Vector + */ + void Update( + ModelPart& r_model_part, + DofsArrayType& rDofSet, + TSystemMatrixType& A, + TSystemVectorType& Dx, + TSystemVectorType& b) override + { + KRATOS_TRY + // The current process info + ProcessInfo& r_current_process_info = r_model_part.GetProcessInfo(); + + // The array of nodes + NodesArrayType& r_nodes = r_model_part.Nodes(); + + /// Working in 2D/3D (the definition of DOMAIN_SIZE is check in the Check method) + const SizeType dim = r_current_process_info[DOMAIN_SIZE]; + + // Step Update + // The first step is time = initial_time ( 0.0) + delta time + mTime.Current = r_current_process_info[TIME]; + mTime.Delta = r_current_process_info[DELTA_TIME]; + + mTime.Middle = mTime.Current - 0.50 * mTime.Delta; + mTime.Previous = mTime.Current - 1.00 * mTime.Delta; + mTime.PreviousMiddle = mTime.Middle - 1.00 * mTime.Delta; + + if (mTime.Previous < 0.0) mTime.Previous = 0.00; + if (mTime.PreviousMiddle < 0.0) mTime.PreviousMiddle = 0.00; + // The iterator of the first node + const auto it_node_begin = r_model_part.NodesBegin(); + + // Getting dof position + const IndexType disppos = it_node_begin->GetDofPosition(DISPLACEMENT_X); + + // TODO enable parallel again + //#pragma omp parallel for schedule(guided,512) + for (int i = 0; i < static_cast(r_nodes.size()); ++i) { + // Current step information "N+1" (before step update). + this->UpdateTranslationalDegreesOfFreedom(it_node_begin + i, disppos, dim); + } // for Node parallel + KRATOS_CATCH("") + } + + //*************************************************************************** + //*************************************************************************** + + void UpdateTranslationalDegreesOfFreedom( + NodeIterator itCurrentNode, + const IndexType DisplacementPosition, + const SizeType DomainSize = 3 + ) + { + std::array fix_displacements = { false, false, false }; + fix_displacements[0] = (itCurrentNode->GetDof(DISPLACEMENT_X, DisplacementPosition).IsFixed()); + fix_displacements[1] = (itCurrentNode->GetDof(DISPLACEMENT_Y, DisplacementPosition + 1).IsFixed()); + if (DomainSize == 3) + fix_displacements[2] = (itCurrentNode->GetDof(DISPLACEMENT_Z, DisplacementPosition + 2).IsFixed()); + + array_1d& r_nodal_momenta = itCurrentNode->FastGetSolutionStepValue(NODAL_MOMENTUM); + array_1d& r_current_residual = itCurrentNode->FastGetSolutionStepValue(FORCE_RESIDUAL); + + double alpha = 1.0; + if (mIsCentralDifference) + { + alpha = 0.5; // factor since we are only adding the corrector here + } + + for (IndexType j = 0; j < DomainSize; j++) { + if (fix_displacements[j]) { + r_nodal_momenta[j] = 0.0; + r_current_residual[j] = 0.0; + } + else + { + r_nodal_momenta[j] += alpha * mTime.Delta * r_current_residual[j]; + } + + } // for DomainSize + + // We need to set updated grid velocity here if we are using the USL or USF formulation + if (mStressUpdateOption == 1) + { + array_1d& r_current_velocity = itCurrentNode->FastGetSolutionStepValue(VELOCITY); + r_current_velocity.clear(); + const double nodal_mass = itCurrentNode->FastGetSolutionStepValue(NODAL_MASS); + if (nodal_mass > numerical_limit) + { + for (IndexType j = 0; j < DomainSize; j++) + { + r_current_velocity[j] = r_nodal_momenta[j] / nodal_mass; + } // for DomainSize + } + } + } + + + /** + This is the place to initialize the elements. + This is intended to be called just once when the strategy is initialized + */ + void InitializeElements(ModelPart& rModelPart) override + { + KRATOS_TRY + + int num_threads = OpenMPUtils::GetNumThreads(); + OpenMPUtils::PartitionVector element_partition; + OpenMPUtils::DivideInPartitions(rModelPart.Elements().size(), num_threads, element_partition); + +#pragma omp parallel + { + int k = OpenMPUtils::ThisThread(); + ElementsArrayType::iterator element_begin = rModelPart.Elements().begin() + element_partition[k]; + ElementsArrayType::iterator element_end = rModelPart.Elements().begin() + element_partition[k + 1]; + + for (ElementsArrayType::iterator itElem = element_begin; itElem != element_end; itElem++) + { + itElem->Initialize(); // function to initialize the element + } + } + + this->mElementsAreInitialized = true; + + KRATOS_CATCH("") + } + + //*************************************************************************** + //*************************************************************************** + + /** + This is the place to initialize the conditions. + This is intended to be called just once when the strategy is initialized + */ + void InitializeConditions(ModelPart& rModelPart) override + { + KRATOS_TRY + + KRATOS_ERROR_IF(this->mElementsAreInitialized == false) << "Before initilizing Conditions, initialize Elements FIRST" << std::endl; + + int num_threads = OpenMPUtils::GetNumThreads(); + OpenMPUtils::PartitionVector condition_partition; + OpenMPUtils::DivideInPartitions(rModelPart.Conditions().size(), num_threads, condition_partition); + +#pragma omp parallel + { + int k = OpenMPUtils::ThisThread(); + ConditionsArrayType::iterator condition_begin = rModelPart.Conditions().begin() + condition_partition[k]; + ConditionsArrayType::iterator condition_end = rModelPart.Conditions().begin() + condition_partition[k + 1]; + + for (ConditionsArrayType::iterator itCond = condition_begin; itCond != condition_end; itCond++) + { + itCond->Initialize(); // Function to initialize the condition + } + } + + this->mConditionsAreInitialized = true; + KRATOS_CATCH("") + } + + //*************************************************************************** + //*************************************************************************** + + /** + * initializes time step solution + * only for reasons if the time step solution is restarted + * @param r_model_part + * @param A LHS matrix + * @param Dx incremental update of primary variables + * @param b RHS Vector + */ + void InitializeSolutionStep( + ModelPart& r_model_part, + TSystemMatrixType& A, + TSystemVectorType& Dx, + TSystemVectorType& b) override + { + KRATOS_TRY + + ProcessInfo CurrentProcessInfo = r_model_part.GetProcessInfo(); + BaseType::InitializeSolutionStep(r_model_part, A, Dx, b); + // LOOP OVER THE GRID NODES PERFORMED FOR CLEAR ALL NODAL INFORMATION +#pragma omp parallel for + for (int iter = 0; iter < static_cast(mr_grid_model_part.Nodes().size()); ++iter) + { + auto i = mr_grid_model_part.NodesBegin() + iter; + + // Variables to be cleaned + double& nodal_mass = (i)->FastGetSolutionStepValue(NODAL_MASS); + array_1d& nodal_momentum = (i)->FastGetSolutionStepValue(NODAL_MOMENTUM); + array_1d& nodal_inertia = (i)->FastGetSolutionStepValue(NODAL_INERTIA); + array_1d& nodal_force = (i)->FastGetSolutionStepValue(FORCE_RESIDUAL); + array_1d& nodal_displacement = (i)->FastGetSolutionStepValue(DISPLACEMENT); + array_1d& nodal_velocity = (i)->FastGetSolutionStepValue(VELOCITY); + array_1d& nodal_acceleration = (i)->FastGetSolutionStepValue(ACCELERATION); + + + double& nodal_old_pressure = (i)->FastGetSolutionStepValue(PRESSURE, 1); + double& nodal_pressure = (i)->FastGetSolutionStepValue(PRESSURE); + if (i->SolutionStepsDataHas(NODAL_MPRESSURE)) { + double& nodal_mpressure = (i)->FastGetSolutionStepValue(NODAL_MPRESSURE); + nodal_mpressure = 0.0; + } + + // Clear + nodal_mass = 0.0; + nodal_momentum.clear(); + nodal_inertia.clear(); + nodal_force.clear(); + + nodal_displacement.clear(); + nodal_velocity.clear(); + nodal_acceleration.clear(); + nodal_old_pressure = 0.0; + nodal_pressure = 0.0; + } + + // Extrapolate from Material Point Elements and Conditions + Scheme::InitializeSolutionStep(r_model_part, A, Dx, b); + + // If we are updating stress first (USF), calculate nodal velocities from momenta and apply BCs + if (mStressUpdateOption == 0 || mIsCentralDifference) + { + const IndexType DisplacementPosition = mr_grid_model_part.NodesBegin()->GetDofPosition(DISPLACEMENT_X); + +#pragma omp parallel for + for (int iter = 0; iter < static_cast(mr_grid_model_part.Nodes().size()); ++iter) + { + auto i = mr_grid_model_part.NodesBegin() + iter; + const SizeType DomainSize = CurrentProcessInfo[DOMAIN_SIZE]; + double& nodal_mass = (i)->FastGetSolutionStepValue(NODAL_MASS); + array_1d& nodal_momentum = (i)->FastGetSolutionStepValue(NODAL_MOMENTUM); + array_1d& nodal_velocity = (i)->FastGetSolutionStepValue(VELOCITY); + + std::array fix_displacements = { false, false, false }; + fix_displacements[0] = (i->GetDof(DISPLACEMENT_X, DisplacementPosition).IsFixed()); + fix_displacements[1] = (i->GetDof(DISPLACEMENT_Y, DisplacementPosition + 1).IsFixed()); + if (DomainSize == 3) + fix_displacements[2] = (i->GetDof(DISPLACEMENT_Z, DisplacementPosition + 2).IsFixed()); + + if (nodal_mass > numerical_limit) + { + for (IndexType j = 0; j < DomainSize; j++) + { + if (fix_displacements[j]) + { + nodal_velocity[j] = 0.0; + } + else + { + nodal_velocity[j] = nodal_momentum[j] / nodal_mass; + } + } + } + } + } + KRATOS_CATCH("") + } + + + //*******************************************************FinalizeNonLinIteration******************** + //*************************************************************************** + /** + Function called once at the end of a solution step, after convergence is reached if + an iterative process is needed + */ + void FinalizeSolutionStep( + ModelPart& rModelPart, + TSystemMatrixType& A, + TSystemVectorType& Dx, + TSystemVectorType& b) override + { + KRATOS_TRY + + ElementsArrayType& rElements = rModelPart.Elements(); + const ProcessInfo& rCurrentProcessInfo = rModelPart.GetProcessInfo(); + + if (mStressUpdateOption == 2) + { + // TODO maybe move to strategy so we can use the base scheme function + PerformModifiedUpdateStressLastMapping(rCurrentProcessInfo, rModelPart, rElements); + } + + // Definition of the first element iterator + const auto it_elem_begin = rModelPart.ElementsBegin(); + + // Finalizes solution step for all of the elements +#pragma omp parallel for + for (int i = 0; i < static_cast(rElements.size()); ++i) { + auto it_elem = it_elem_begin + i; + it_elem->FinalizeSolutionStep(rCurrentProcessInfo); + } + + // Definition of the first condition iterator + const auto it_cond_begin = rModelPart.ConditionsBegin(); + + // Finalizes solution step for all of the conditions +#pragma omp parallel for + for (int i = 0; i < static_cast(rModelPart.Conditions().size()); ++i) { + auto it_cond = it_cond_begin + i; + it_cond->FinalizeSolutionStep(rCurrentProcessInfo); + } + + KRATOS_CATCH("") + } + + //*************************************************************************** + //*************************************************************************** + void PerformModifiedUpdateStressLastMapping(const ProcessInfo& rCurrentProcessInfo, ModelPart& rModelPart, ElementsArrayType& rElements) + { + // MUSL stress update. This works by projecting the updated particle + // velocity back to the nodes. The nodal velocity field is then + // used for stress computations. + + // We need to call 'FinalizeSolutionStep' twice. + // First, to update the particles and then aggregate the new particle velocities on the grid. + // Second, to calculate the stresses from the grid velocity + for (int iter = 0; iter < static_cast(mr_grid_model_part.Nodes().size()); ++iter) + { + auto i = mr_grid_model_part.NodesBegin() + iter; + (i)->SetValue(MUSL_VELOCITY_FIELD_IS_COMPUTED, false); + } + + + // Call each particle and aggregate the nodal velocity field + for (ElementsArrayType::iterator it = rElements.begin(); it != rElements.end(); ++it) + { + (it)->FinalizeSolutionStep(rCurrentProcessInfo); + } + + + // Reapply dirichlet BCs to MUSL velocity field + const SizeType DomainSize = rCurrentProcessInfo[DOMAIN_SIZE]; + NodesArrayType& r_nodes = rModelPart.Nodes(); + const auto it_node_begin = rModelPart.NodesBegin(); + const IndexType DisplacementPosition = it_node_begin->GetDofPosition(DISPLACEMENT_X); + + for (int i = 0; i < static_cast(r_nodes.size()); ++i) + { + NodeIterator itCurrentNode = it_node_begin + i; + + std::array fix_displacements = { false, false, false }; + fix_displacements[0] = (itCurrentNode->GetDof(DISPLACEMENT_X, DisplacementPosition).IsFixed()); + fix_displacements[1] = (itCurrentNode->GetDof(DISPLACEMENT_Y, DisplacementPosition + 1).IsFixed()); + if (DomainSize == 3) + fix_displacements[2] = (itCurrentNode->GetDof(DISPLACEMENT_Z, DisplacementPosition + 2).IsFixed()); + + array_1d& r_current_velocity = itCurrentNode->FastGetSolutionStepValue(VELOCITY); + + for (IndexType j = 0; j < DomainSize; j++) + { + if (fix_displacements[j]) + { + r_current_velocity[j] = 0.0; + } + } + } + } + + + + void InitializeNonLinIteration(ModelPart& r_model_part, + TSystemMatrixType& A, + TSystemVectorType& Dx, + TSystemVectorType& b) override + { + KRATOS_TRY + + // This calculates the stresses before momenta update. + // Used for USF and Central Difference method + if (mStressUpdateOption == 0 || mIsCentralDifference) + { + ElementsArrayType& pElements = r_model_part.Elements(); + ProcessInfo& CurrentProcessInfo = r_model_part.GetProcessInfo(); + + for (ElementsArrayType::iterator it = pElements.begin(); it != pElements.end(); ++it) + { + (it)->InitializeNonLinearIteration(CurrentProcessInfo); + } + + ConditionsArrayType& pConditions = r_model_part.Conditions(); + for (ConditionsArrayType::iterator it = pConditions.begin(); it != pConditions.end(); ++it) + { + (it)->InitializeNonLinearIteration(CurrentProcessInfo); + } + } + + KRATOS_CATCH("") + } + + //*************************************************************************** + //*************************************************************************** + + void InitializeNonLinearIteration(Condition::Pointer rCurrentCondition, + ProcessInfo& CurrentProcessInfo) override + { + (rCurrentCondition)->InitializeNonLinearIteration(CurrentProcessInfo); + } + + + //*************************************************************************** + //*************************************************************************** + + void InitializeNonLinearIteration(Element::Pointer rCurrentElement, + ProcessInfo& CurrentProcessInfo) override + { + (rCurrentElement)->InitializeNonLinearIteration(CurrentProcessInfo); + } + + //*************************************************************************** + //*************************************************************************** + + //*************************************************************************** + //*************************************************************************** + + + //*************************************************************************** + //*************************************************************************** + + /** Function that returns the list of Degrees of freedom to be + assembled in the system for a Given Element + */ + void GetElementalDofList( + Element::Pointer rCurrentElement, + Element::DofsVectorType& ElementalDofList, + ProcessInfo& CurrentProcessInfo) override + { + rCurrentElement->GetDofList(ElementalDofList, CurrentProcessInfo); + } + + //*************************************************************************** + //*************************************************************************** + + /** Function that returns the list of Degrees of freedom to be + assembled in the system for a Given Element + */ + void GetConditionDofList( + Condition::Pointer rCurrentCondition, + Element::DofsVectorType& ConditionDofList, + ProcessInfo& CurrentProcessInfo) override + { + rCurrentCondition->GetDofList(ConditionDofList, CurrentProcessInfo); + } + + //*************************************************************************** + //*************************************************************************** + + /** + * This function is designed to be called once to perform all the checks needed + * on the input provided. Checks can be "expensive" as the function is designed + * to catch user's errors. + * @param r_model_part + * @return 0 all ok + */ + int Check(ModelPart& r_model_part) override + { + KRATOS_TRY + + int err = Scheme::Check(r_model_part); + if (err != 0) return err; + + //check that the variables are correctly initialized + KRATOS_ERROR_IF(DISPLACEMENT.Key() == 0) << "DISPLACEMENT has Key zero! (check if the application is correctly registered" << std::endl; + KRATOS_ERROR_IF(VELOCITY.Key() == 0) << "VELOCITY has Key zero! (check if the application is correctly registered" << std::endl; + KRATOS_ERROR_IF(ACCELERATION.Key() == 0) << "ACCELERATION has Key zero! (check if the application is correctly registered" << std::endl; + + //check that variables are correctly allocated + for (ModelPart::NodesContainerType::iterator it = r_model_part.NodesBegin(); + it != r_model_part.NodesEnd(); it++) + { + KRATOS_ERROR_IF(it->SolutionStepsDataHas(DISPLACEMENT) == false) << "DISPLACEMENT variable is not allocated for node " << it->Id() << std::endl; + KRATOS_ERROR_IF(it->SolutionStepsDataHas(VELOCITY) == false) << "VELOCITY variable is not allocated for node " << it->Id() << std::endl; + KRATOS_ERROR_IF(it->SolutionStepsDataHas(ACCELERATION) == false) << "ACCELERATION variable is not allocated for node " << it->Id() << std::endl; + } + + //check that dofs exist + for (ModelPart::NodesContainerType::iterator it = r_model_part.NodesBegin(); + it != r_model_part.NodesEnd(); it++) + { + KRATOS_ERROR_IF(it->HasDofFor(DISPLACEMENT_X) == false) << "Missing DISPLACEMENT_X dof on node " << it->Id() << std::endl; + KRATOS_ERROR_IF(it->HasDofFor(DISPLACEMENT_Y) == false) << "Missing DISPLACEMENT_Y dof on node " << it->Id() << std::endl; + KRATOS_ERROR_IF(it->HasDofFor(DISPLACEMENT_Z) == false) << "Missing DISPLACEMENT_Z dof on node " << it->Id() << std::endl; + } + + //check for minimum value of the buffer index + KRATOS_ERROR_IF(r_model_part.GetBufferSize() < 2) << "Insufficient buffer size. Buffer size should be greater than 2. Current size is" << r_model_part.GetBufferSize() << std::endl; + + return 0; + KRATOS_CATCH("") + } + + virtual void SchemeCustomInitialization( + ModelPart& rModelPart, + const SizeType DomainSize = 3 + ) + { + KRATOS_TRY + + // The array containing the nodes + NodesArrayType& r_nodes = rModelPart.Nodes(); + + // The fisrt node interator + const auto it_node_begin = rModelPart.NodesBegin(); + + // Auxiliar zero array + const array_1d zero_array = ZeroVector(3); + + // Getting dof position + const IndexType disppos = it_node_begin->GetDofPosition(DISPLACEMENT_X); + +#pragma omp parallel for schedule(guided,512) + for (int i = 0; i < static_cast(r_nodes.size()); ++i) { + // Current step information "N+1" (before step update). + auto it_node = it_node_begin + i; + + const double nodal_mass = it_node->GetValue(NODAL_MASS); + + const array_1d& r_current_residual = it_node->FastGetSolutionStepValue(FORCE_RESIDUAL); + + array_1d& r_current_velocity = it_node->FastGetSolutionStepValue(VELOCITY); + // array_1d& r_current_displacement = it_node->FastGetSolutionStepValue(DISPLACEMENT); + array_1d& r_current_acceleration = it_node->FastGetSolutionStepValue(ACCELERATION); + + // Solution of the explicit equation: + if (nodal_mass > numerical_limit) { + r_current_acceleration = r_current_residual / nodal_mass; + } + else { + r_current_acceleration = zero_array; + } + + std::array fix_displacements = { false, false, false }; + + fix_displacements[0] = (it_node->GetDof(DISPLACEMENT_X, disppos).IsFixed()); + fix_displacements[1] = (it_node->GetDof(DISPLACEMENT_Y, disppos + 1).IsFixed()); + if (DomainSize == 3) + fix_displacements[2] = (it_node->GetDof(DISPLACEMENT_Z, disppos + 2).IsFixed()); + + for (IndexType j = 0; j < DomainSize; j++) { + if (fix_displacements[j]) { + r_current_acceleration[j] = 0.0; + } + r_current_velocity[j] += (mTime.Previous - mTime.PreviousMiddle) * r_current_acceleration[j]; + // r_current_displacement[j] = 0.0; + } // for DomainSize + + } // for node parallel + + mTime.Previous = mTime.Current; + mTime.PreviousMiddle = mTime.Middle; + KRATOS_CATCH("") + } + + void Calculate_RHS_Contribution( + Element::Pointer pCurrentElement, + LocalSystemVectorType& RHS_Contribution, + Element::EquationIdVectorType& EquationId, + ProcessInfo& rCurrentProcessInfo + ) override + { + KRATOS_TRY + + this->TCalculate_RHS_Contribution(pCurrentElement, RHS_Contribution, rCurrentProcessInfo); + KRATOS_CATCH("") + } + + /** + * @brief Functions that calculates the RHS of a "condition" object + * @param pCondition The condition to compute + * @param RHS_Contribution The RHS vector contribution + * @param EquationId The ID's of the condition degrees of freedom + * @param rCurrentProcessInfo The current process info instance + */ + void Condition_Calculate_RHS_Contribution( + Condition::Pointer pCurrentCondition, + LocalSystemVectorType& RHS_Contribution, + Element::EquationIdVectorType& EquationId, + ProcessInfo& rCurrentProcessInfo + ) override + { + KRATOS_TRY + + this->TCalculate_RHS_Contribution(pCurrentCondition, RHS_Contribution, rCurrentProcessInfo); + + KRATOS_CATCH("") + } + + template + void TCalculate_RHS_Contribution( + TObjectType pCurrentEntity, + LocalSystemVectorType& RHS_Contribution, + ProcessInfo& rCurrentProcessInfo + ) + { + KRATOS_TRY + + pCurrentEntity->CalculateRightHandSide(RHS_Contribution, rCurrentProcessInfo); + pCurrentEntity->AddExplicitContribution(RHS_Contribution, RESIDUAL_VECTOR, FORCE_RESIDUAL, rCurrentProcessInfo); + //pCurrentEntity->AddExplicitContribution(RHS_Contribution, RESIDUAL_VECTOR, MOMENT_RESIDUAL, rCurrentProcessInfo); + + KRATOS_CATCH("") + } + + + /*@} */ + /**@name Operations */ + /*@{ */ + /*@} */ + /**@name Access */ + /*@{ */ + /*@} */ + /**@name Inquiry */ + /*@{ */ + /*@} */ + /**@name Friends */ + /*@{ */ + + protected: + /**@name Static Member Variables */ + /*@{ */ + /*@} */ + /**@name Member Variables */ + /*@{ */ + + struct DeltaTimeParameters { + double PredictionLevel; // 0, 1, 2 // NOTE: Should be a integer? + double Maximum; // Maximum delta time + double Fraction; // Fraction of the delta time + }; + + /** + * @brief This struct contains the details of the time variables + */ + struct TimeVariables { + double PreviousMiddle; // n-1/2 + double Previous; // n + double Middle; // n+1/2 + double Current; // n+1 + + double Delta; // Time step + }; + + ///@name Protected static Member Variables + ///@{ + + TimeVariables mTime; /// This struct contains the details of the time variables + + ModelPart& mr_grid_model_part; + + const int mStressUpdateOption; // 0 = USF, 1 = USL, 2 = MUSL + const bool mIsCentralDifference; + + /*@} */ + /**@name Protected Operators*/ + /*@{ */ + + /*@} */ + /**@name Protected Operations*/ + /*@{ */ + /*@} */ + /**@name Protected Access */ + /*@{ */ + /*@} */ + /**@name Protected Inquiry */ + /*@{ */ + /*@} */ + /**@name Protected LifeCycle */ + /*@{ */ + private: + /**@name Static Member Variables */ + /*@{ */ + /*@} */ + /**@name Member Variables */ + /*@{ */ + /*@} */ + /**@name Private Operators*/ + /*@{ */ + /*@} */ + /**@name Private Operations*/ + /*@{ */ + /*@} */ + /**@name Private Access */ + /*@{ */ + /*@} */ + /**@name Private Inquiry */ + /*@{ */ + /*@} */ + /**@name Unaccessible methods */ + /*@{ */ + }; /* Class MPMExplicitScheme */ +} /* namespace Kratos.*/ + +#endif /* KRATOS_MPM_EXPLICIT_SCHEME defined */ \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp new file mode 100644 index 000000000000..812b73d85436 --- /dev/null +++ b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp @@ -0,0 +1,658 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ \. +// _|\_\_| \__,_|\__|\___/ ____/ +// Multi-Physics +// +// License: BSD License +// Kratos default license: kratos/license.txt +// +// Main authors: Peter Wilson (thanks Klaus Sautter) +// +// + + +#if !defined(KRATOS_MPM_EXPLICIT_STRATEGY ) +#define KRATOS_MPM_EXPLICIT_STRATEGY + +// System includes + +// External includes + +// Project includes +#include "includes/define.h" +#include "includes/model_part.h" +#include "utilities/variable_utils.h" +#include "includes/kratos_flags.h" + +#include "solving_strategies/strategies/solving_strategy.h" + +// Application includes +#include "particle_mechanics_application_variables.h" + +namespace Kratos +{ + + /**@name Kratos Globals */ + /*@{ */ + + + /*@} */ + /**@name Type Definitions */ + /*@{ */ + + /*@} */ + + + /**@name Enum's */ + /*@{ */ + + + /*@} */ + /**@name Functions */ + /*@{ */ + + + + /*@} */ + /**@name Kratos Classes */ + /*@{ */ + + /// Short class definition. +/** + * @class MPMExplicitStrategy + * @ingroup ParticleMechanicsApplciation + * @brief This strategy is used for the explicit time integration + * @author Peter Wilson (based on the work of Klaus B Sautter) + */ + template + class MPMExplicitStrategy + : public SolvingStrategy + { + public: + /**@name Type Definitions */ + /*@{ */ + /** Counted pointer of ClassName */ + KRATOS_CLASS_POINTER_DEFINITION(MPMExplicitStrategy); + + typedef SolvingStrategy BaseType; + + typedef typename BaseType::TDataType TDataType; + + typedef TSparseSpace SparseSpaceType; + + typedef typename BaseType::TSchemeType TSchemeType; + + typedef typename BaseType::DofsArrayType DofsArrayType; + + typedef typename BaseType::TSystemMatrixType TSystemMatrixType; + + typedef typename BaseType::TSystemVectorType TSystemVectorType; + + typedef typename BaseType::LocalSystemVectorType LocalSystemVectorType; + + typedef typename BaseType::LocalSystemMatrixType LocalSystemMatrixType; + + typedef typename BaseType::TSystemMatrixPointerType TSystemMatrixPointerType; + typedef typename BaseType::TSystemVectorPointerType TSystemVectorPointerType; + + typedef typename BaseType::ElementsArrayType ElementsArrayType; + + typedef typename BaseType::NodesArrayType NodesArrayType; + + typedef typename BaseType::ConditionsArrayType ConditionsArrayType; + + + /*@} */ + /**@name Life Cycle + */ + /*@{ */ + MPMExplicitStrategy( + ModelPart& model_part, + typename TSchemeType::Pointer pScheme, + bool CalculateReactions = false, + bool ReformDofSetAtEachStep = false, + bool MoveMeshFlag = false + ) + : SolvingStrategy(model_part, MoveMeshFlag), + mpScheme(pScheme), + mReformDofSetAtEachStep(ReformDofSetAtEachStep), + mCalculateReactionsFlag(CalculateReactions) + { + KRATOS_TRY + + std::cout << "\n\n MPMExplicitStrategy MADE SS \n\n" << std::endl; + + mKeepSystemConstantDuringIterations = false; + + // Set flags to start correcty the calculations + mSolutionStepIsInitialized = false; + + mInitializeWasPerformed = false; + + mFinalizeSolutionStep = true; + + // Set EchoLevel to the default value (only time is displayed) + SetEchoLevel(1); + + // By default the matrices are rebuilt at each solution step + this->SetRebuildLevel(1); + + KRATOS_CATCH("") + } + + /** Destructor. + */ + virtual ~MPMExplicitStrategy() + { + } + + /** Destructor. + */ + + //Set and Get Scheme ... containing Builder, Update and other + + void SetScheme(typename TSchemeType::Pointer pScheme) + { + mpScheme = pScheme; + }; + + typename TSchemeType::Pointer GetScheme() + { + return mpScheme; + }; + + + void SetInitializePerformedFlag(bool InitializePerformedFlag = true) + { + mInitializeWasPerformed = InitializePerformedFlag; + } + + bool GetInitializePerformedFlag() + { + return mInitializeWasPerformed; + } + + void SetCalculateReactionsFlag(bool CalculateReactionsFlag) + { + mCalculateReactionsFlag = CalculateReactionsFlag; + } + + bool GetCalculateReactionsFlag() + { + return mCalculateReactionsFlag; + } + + bool GetReformDofSetAtEachStepFlag() + { + return mReformDofSetAtEachStep; + } + + void SetFinalizeSolutionStepFlag(bool FinalizeSolutionStepFlag = true) + { + mFinalizeSolutionStep = FinalizeSolutionStepFlag; + } + + bool GetFinalizeSolutionStepFlag() + { + return mFinalizeSolutionStep; + } + + //level of echo for the solving strategy + // 0 -> mute... no echo at all + // 1 -> printing time and basic informations + // 2 -> printing linear solver data + // 3 -> Print of debug informations: + // Echo of stiffness matrix, Dx, b... + + void SetEchoLevel(int Level) override + { + BaseType::mEchoLevel = Level; + } + + //********************************************************************************* + /**OPERATIONS ACCESSIBLE FROM THE INPUT:*/ + //********************************************************************************* + /** + Initialize members + */ + //********************************************************************** + + + void Initialize() override + { + KRATOS_TRY + + typename TSchemeType::Pointer pScheme = GetScheme(); + + // OPERATIONS THAT SHOULD BE DONE ONCE - internal check to avoid repetitions + // if the operations needed were already performed this does nothing + if (mInitializeWasPerformed == false) + { + KRATOS_INFO_IF("MPM_Explicit_Strategy", this->GetEchoLevel() > 1) << "Initializing solving strategy" << std::endl; + KRATOS_ERROR_IF(mInitializeWasPerformed == true) << "Initialization was already performed " << mInitializeWasPerformed << std::endl; + + // Initialize The Scheme - OPERATIONS TO BE DONE ONCE + KRATOS_INFO_IF("MPM_Explicit_Strategy", this->GetEchoLevel() > 1) << "Initializing scheme" << std::endl; + if (pScheme->SchemeIsInitialized() == false) + pScheme->Initialize(BaseType::GetModelPart()); + + // Initialize The Elements - OPERATIONS TO BE DONE ONCE + KRATOS_INFO_IF("MPM_Explicit_Strategy", this->GetEchoLevel() > 1) << "Initializing elements" << std::endl; + if (pScheme->ElementsAreInitialized() == false) + pScheme->InitializeElements(BaseType::GetModelPart()); + + // Initialize The Conditions - OPERATIONS TO BE DONE ONCE + KRATOS_INFO_IF("MPM_Explicit_Strategy", this->GetEchoLevel() > 1) << "Initializing conditions" << std::endl; + if (pScheme->ConditionsAreInitialized() == false) + pScheme->InitializeConditions(BaseType::GetModelPart()); + + mInitializeWasPerformed = true; + } + + // Prints informations about the current time + if (this->GetEchoLevel() == 2 && BaseType::GetModelPart().GetCommunicator().MyPID() == 0) + { + KRATOS_INFO("MPM_Explicit_Strategy") << "CurrentTime = " << BaseType::GetModelPart().GetProcessInfo()[TIME] << std::endl; + } + + KRATOS_CATCH("") + } + + void InitializeSolutionStep() override + { + KRATOS_TRY + + // Initialize solution step + if (mSolutionStepIsInitialized == false) + { + typename TSchemeType::Pointer pScheme = GetScheme(); + + ModelPart& r_model_part = BaseType::GetModelPart(); + + Vector dummy_vector; + TSystemVectorType rDx = TSystemVectorType(); + TSystemVectorType rb = TSystemVectorType(); + + + TSystemMatrixType mA = TSystemMatrixType(); + TSystemVectorType mDx = TSystemVectorType(); + TSystemVectorType mb = TSystemVectorType(); + + // Initial operations ... things that are constant over the Solution Step + pScheme->InitializeSolutionStep(BaseType::GetModelPart(), mA, mDx, mb); + + if (BaseType::mRebuildLevel > 0) + { // TODO: Right now is computed in the Initialize() because is always zero, the option to set the RebuildLevel should be added in the constructor or in some place + ProcessInfo& r_current_process_info = r_model_part.GetProcessInfo(); + ElementsArrayType& r_elements = r_model_part.Elements(); + const auto it_elem_begin = r_elements.begin(); + } + } + + mSolutionStepIsInitialized = true; + + KRATOS_INFO_IF("MPM_Explicit_Strategy", this->GetEchoLevel() >= 3) << "Initialize Solution Step in strategy finished" << std::endl; + + KRATOS_CATCH("") + } + + + //********************************************************************************* + /** + the problem of interest is solved + */ + //********************************************************************** + bool SolveSolutionStep() override + { + typename TSchemeType::Pointer pScheme = GetScheme(); + DofsArrayType dof_set_dummy; + TSystemMatrixType mA = TSystemMatrixType(); + TSystemVectorType mDx = TSystemVectorType(); + TSystemVectorType mb = TSystemVectorType(); + + pScheme->InitializeNonLinIteration(BaseType::GetModelPart(), mA, mDx, mb); + + // Compute residual forces on the model part + this->CalculateAndAddRHS(pScheme, BaseType::GetModelPart()); + + pScheme->Update(BaseType::GetModelPart(), dof_set_dummy, mA, mDx, mb); + + //pScheme->FinalizeNonLinIteration(BaseType::GetModelPart(), mA, mDx, mb); // TODO check if we need this + + // Calculate reactions if required + if (mCalculateReactionsFlag) { + CalculateReactions(pScheme, BaseType::GetModelPart(), mA, mDx, mb); + } + + return true; + } + + //********************************************************************************* + + //********************************************************************** + //********************************************************************** + + void Clear() override + { + KRATOS_TRY + GetScheme()->Clear(); + + KRATOS_CATCH("") + } + + /*@} */ + /**@name Operators + */ + /*@{ */ + + /*@} */ + /**@name Operations */ + /*@{ */ + + + /*@} */ + /**@name Access */ + + /*@{ */ + + void SetKeepSystemConstantDuringIterations(bool value) + { + mKeepSystemConstantDuringIterations = value; + } + + bool GetKeepSystemConstantDuringIterations() + { + return mKeepSystemConstantDuringIterations; + } + + + /*@} */ + /**@name Inquiry */ + /*@{ */ + + + /*@} */ + /**@name Friends */ + /*@{ */ + + + /*@} */ + + private: + /**@name Protected static Member Variables */ + /*@{ */ + + + /*@} */ + /**@name Protected member Variables */ + /*@{ */ + + + /*@} */ + /**@name Protected Operators*/ + /*@{ */ + + + /*@} */ + /**@name Protected Operations*/ + /*@{ */ + + + + /*@} */ + /**@name Protected Access */ + /*@{ */ + + + /*@} */ + /**@name Protected Inquiry */ + /*@{ */ + + + /*@} */ + /**@name Protected LifeCycle */ + /*@{ */ + + + + /*@} */ + + protected: + /**@name Static Member Variables */ + /*@{ */ + + + /*@} */ + /**@name Member Variables */ + /*@{ */ + + typename TSchemeType::Pointer mpScheme; + + + + /** + Flag telling if it is needed to reform the DofSet at each + solution step or if it is possible to form it just once + - true => reforme at each time step + - false => form just one (more efficient) + + Default = false + */ + bool mReformDofSetAtEachStep; + + /** + Flag telling if it is needed or not to compute the reactions + + default = true + */ + bool mCalculateReactionsFlag; + + bool mSolutionStepIsInitialized; + + bool mInitializeWasPerformed; + + //flag to allow keeping system matrix constant during iterations + bool mKeepSystemConstantDuringIterations; + + //flag to allow to not finalize the solution step, so the historical variables are not updated + bool mFinalizeSolutionStep; + + /*@} */ + /**@name Private Operators*/ + /*@{ */ + //********************************************************************** + //********************************************************************** + + + + + //********************************************************************** + //********************************************************************** + void FinalizeSolutionStep() override + { + KRATOS_TRY + typename TSchemeType::Pointer pScheme = GetScheme(); + TSystemMatrixType mA = TSystemMatrixType(); + TSystemVectorType mDx = TSystemVectorType(); + TSystemVectorType mb = TSystemVectorType(); + + + /*Finalization of the solution step, + operations to be done after achieving convergence, for example the + Final Residual Vector (mb) has to be saved in there + to avoid error accumulation*/ + if (mFinalizeSolutionStep) + { + KRATOS_INFO_IF("MPM_Explicit_Strategy", this->GetEchoLevel() >= 3) << "Calling FinalizeSolutionStep" << std::endl; + + pScheme->FinalizeSolutionStep(BaseType::GetModelPart(), mA, mDx, mb); + if (BaseType::MoveMeshFlag()) BaseType::MoveMesh(); + } + + // Cleaning memory after the solution + pScheme->Clean(); + + // Reset flags for next step + mSolutionStepIsInitialized = false; + KRATOS_CATCH("") + } + + /** + * function to perform expensive checks. + * It is designed to be called ONCE to verify that the input is correct. + */ + int Check() override + { + KRATOS_TRY + + BaseType::Check(); + GetScheme()->Check(BaseType::GetModelPart()); + return 0; + + KRATOS_CATCH("") + } + + + void CalculateAndAddRHS( + typename TSchemeType::Pointer pScheme, + ModelPart& rModelPart + ) + { + KRATOS_TRY + + ProcessInfo& r_current_process_info = rModelPart.GetProcessInfo(); + ConditionsArrayType& r_conditions = rModelPart.Conditions(); + ElementsArrayType& r_elements = rModelPart.Elements(); + + LocalSystemVectorType RHS_Contribution = LocalSystemVectorType(0); + Element::EquationIdVectorType equation_id_vector_dummy; // Dummy + // TODO re-enable parallel + //#pragma omp parallel for firstprivate(RHS_Contribution, equation_id_vector_dummy), schedule(guided,512) + for (int i = 0; i < static_cast(r_conditions.size()); ++i) { + auto it_cond = r_conditions.begin() + i; + pScheme->Condition_Calculate_RHS_Contribution((*it_cond.base()), RHS_Contribution, equation_id_vector_dummy, r_current_process_info); + } + + //#pragma omp parallel for firstprivate(RHS_Contribution, equation_id_vector_dummy), schedule(guided,512) + for (int i = 0; i < static_cast(r_elements.size()); ++i) { + auto it_elem = r_elements.begin() + i; + pScheme->Calculate_RHS_Contribution((*it_elem.base()), RHS_Contribution, equation_id_vector_dummy, r_current_process_info); + } + + KRATOS_CATCH("") + } + + + void CalculateReactions( + typename TSchemeType::Pointer pScheme, + ModelPart& rModelPart, + TSystemMatrixType& rA, + TSystemVectorType& rDx, + TSystemVectorType& rb + ) + { + // We iterate over the nodes + auto& r_nodes = rModelPart.Nodes(); + + // If we consider rotation dofs + const bool has_dof_for_rot_z = (r_nodes.begin())->HasDofFor(ROTATION_Z); + + // Auxiliar values + const array_1d zero_array = ZeroVector(3); + array_1d force_residual = ZeroVector(3); + array_1d moment_residual = ZeroVector(3); + + // Getting + const auto it_node_begin = r_nodes.begin(); + const IndexType disppos = it_node_begin->GetDofPosition(DISPLACEMENT_X); + const IndexType rotppos = it_node_begin->GetDofPosition(ROTATION_X); + + // Iterating nodes +#pragma omp parallel for firstprivate(force_residual, moment_residual), schedule(guided,512) + for (int i = 0; i < static_cast(r_nodes.size()); ++i) { + auto it_node = it_node_begin + i; + + noalias(force_residual) = it_node->FastGetSolutionStepValue(FORCE_RESIDUAL); + if (has_dof_for_rot_z) { + noalias(moment_residual) = it_node->FastGetSolutionStepValue(MOMENT_RESIDUAL); + } + else { + noalias(moment_residual) = zero_array; + } + + if (it_node->GetDof(DISPLACEMENT_X, disppos).IsFixed()) { + double& r_reaction = it_node->FastGetSolutionStepValue(REACTION_X); + r_reaction = force_residual[0]; + } + if (it_node->GetDof(DISPLACEMENT_Y, disppos + 1).IsFixed()) { + double& r_reaction = it_node->FastGetSolutionStepValue(REACTION_Y); + r_reaction = force_residual[1]; + } + if (it_node->GetDof(DISPLACEMENT_Z, disppos + 2).IsFixed()) { + double& r_reaction = it_node->FastGetSolutionStepValue(REACTION_Z); + r_reaction = force_residual[2]; + } + if (has_dof_for_rot_z) { + if (it_node->GetDof(ROTATION_X, rotppos).IsFixed()) { + double& r_reaction = it_node->FastGetSolutionStepValue(REACTION_MOMENT_X); + r_reaction = moment_residual[0]; + } + if (it_node->GetDof(ROTATION_Y, rotppos + 1).IsFixed()) { + double& r_reaction = it_node->FastGetSolutionStepValue(REACTION_MOMENT_Y); + r_reaction = moment_residual[1]; + } + if (it_node->GetDof(ROTATION_Z, rotppos + 2).IsFixed()) { + double& r_reaction = it_node->FastGetSolutionStepValue(REACTION_MOMENT_Z); + r_reaction = moment_residual[2]; + } + } + } + } + + + + /*@} */ + /**@name Private Operations*/ + /*@{ */ + + + /*@} */ + /**@name Private Access */ + /*@{ */ + + + /*@} */ + /**@name Private Inquiry */ + /*@{ */ + + + /*@} */ + /**@name Un accessible methods */ + /*@{ */ + + /** Copy constructor. + */ + MPMExplicitStrategy(const MPMExplicitStrategy& Other) + { + }; + + + /*@} */ + + }; /* Class MPMExplicitStrategy */ + + /*@} */ + + /**@name Type Definitions */ + /*@{ */ + + + /*@} */ + +}; /* namespace Kratos.*/ + +#endif /* KRATOS_MPM_EXPLICIT_STRATEGY defined */ diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp new file mode 100644 index 000000000000..f92567cc0e74 --- /dev/null +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp @@ -0,0 +1,248 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ \. +// _|\_\_| \__,_|\__|\___/ ____/ +// Multi-Physics +// +// License: BSD License +// Kratos default license: kratos/license.txt +// +// Main authors: Peter Wilson +// + +// System includes + +// External includes + +// Project includes +#include "custom_utilities/mpm_explicit_utilities.h" + +namespace Kratos +{ + void MPMExplicitUtilities::CalcuateAndAddExplicitInternalForce( + GeometryType& rGeom, + const Matrix& rDN_DX, + const Vector& rMPStress, + const double& rMPVolume, + Vector& rRightHandSideVector) + { + KRATOS_TRY + + const unsigned int dimension = rGeom.WorkingSpaceDimension(); + const unsigned int number_of_nodes = rGeom.PointsNumber(); + array_1d nodal_force_internal_normal = ZeroVector(3); //PJW, needed for explicit force + + // Add in explicit internal force calculation (Fint = Volume*divergence(sigma)) + // TODO extend to 3D + for (unsigned int i = 0; i < number_of_nodes; i++) + { + //f_x = V*(s_xx*dNdX + s_xy*dNdY) + nodal_force_internal_normal[0] = rMPVolume * + (rMPStress[0] * rDN_DX(i, 0) + + rMPStress[2] * rDN_DX(i, 1)); + + //f_x = V*(s_yy*dNdX + s_xy*dNdX) + nodal_force_internal_normal[1] = rMPVolume * + (rMPStress[1] * rDN_DX(i, 1) + + rMPStress[2] * rDN_DX(i, 0)); + + + rRightHandSideVector[dimension * i] -= nodal_force_internal_normal[0]; //minus sign, internal forces + rRightHandSideVector[dimension * i + 1] -= nodal_force_internal_normal[1]; //minus sign, internal forces + + if (dimension > 2) + { + // TODO add in third dimension here + rRightHandSideVector[dimension * i + 2] -= nodal_force_internal_normal[2]; //minus sign, internal forces + } + } + KRATOS_CATCH("") + } + + /***********************************************************************************/ + /***********************************************************************************/ + + void MPMExplicitUtilities::UpdateGaussPointExplicit( + GeometryType& rGeom, + const double& rDeltaTime, + const bool& isCentralDifference, + Element& rElement, + Vector& rN) + { + KRATOS_TRY + + const unsigned int number_of_nodes = rGeom.PointsNumber(); + const unsigned int dimension = rGeom.WorkingSpaceDimension(); + bool isUpdateMPPositionFromUpdatedMPVelocity = true; + + // Update the MP Velocity + const array_1d& MP_PreviousVelocity = rElement.GetValue(MP_VELOCITY); + const array_1d& MP_PreviousAcceleration = rElement.GetValue(MP_ACCELERATION); + array_1d MP_Velocity = ZeroVector(3); + + double alpha = 1.0; + + if (isCentralDifference) + { + alpha = 0.5; + isUpdateMPPositionFromUpdatedMPVelocity = false; + } + + // Advance the predictor velocity + for (unsigned int i = 0; i < dimension; i++) + { + MP_Velocity[i] = MP_PreviousVelocity[i] + (1.0 - alpha) * rDeltaTime * MP_PreviousAcceleration[i]; + } + + + array_1d delta_xg = ZeroVector(3); + array_1d MP_Acceleration = ZeroVector(3); + + for (unsigned int i = 0; i < number_of_nodes; i++) + { + const double nodal_mass = rGeom[i].FastGetSolutionStepValue(NODAL_MASS); + + if (nodal_mass > std::numeric_limits::epsilon()) + { + const array_1d& r_nodal_momenta = rGeom[i].FastGetSolutionStepValue(NODAL_MOMENTUM); + const array_1d& r_current_residual = rGeom[i].FastGetSolutionStepValue(FORCE_RESIDUAL); + const array_1d& r_middle_velocity = rGeom[i].FastGetSolutionStepValue(VELOCITY); + + for (unsigned int j = 0; j < dimension; j++) + { + MP_Acceleration[j] += rN[i] * r_current_residual[j] / nodal_mass; + if (isCentralDifference) + { + delta_xg[j] += rDeltaTime * rN[i] * r_middle_velocity[j]; + } + else if (!isUpdateMPPositionFromUpdatedMPVelocity) + { + delta_xg[j] += rDeltaTime * rN[i] * r_nodal_momenta[j] / nodal_mass; + } + } + } + } + + // Update the MP Velocity corrector + for (unsigned int j = 0; j < dimension; j++) + { + MP_Velocity[j] += alpha * rDeltaTime * MP_Acceleration[j]; + } + rElement.SetValue(MP_VELOCITY, MP_Velocity); + + // Update the MP Position + const array_1d& xg = rElement.GetValue(MP_COORD); + if (isUpdateMPPositionFromUpdatedMPVelocity) + { + for (unsigned int j = 0; j < dimension; j++) + { + delta_xg[j] = rDeltaTime * MP_Velocity[j]; + } + } + const array_1d& new_xg = xg + delta_xg; + rElement.SetValue(MP_COORD, new_xg); + + + // Update the MP Acceleration + rElement.SetValue(MP_ACCELERATION, MP_Acceleration); + + + // Update the MP total displacement + array_1d& MP_Displacement = rElement.GetValue(MP_DISPLACEMENT); + MP_Displacement += delta_xg; + rElement.SetValue(MP_DISPLACEMENT, MP_Displacement); + + KRATOS_CATCH("") + } + + /***********************************************************************************/ + /***********************************************************************************/ + + void MPMExplicitUtilities::CalculateMUSLGridVelocity( + GeometryType& rGeom, + Element& rElement, + Vector& rN) + { + + KRATOS_TRY + const unsigned int dimension = rGeom.WorkingSpaceDimension(); + const unsigned int number_of_nodes = rGeom.PointsNumber(); + const array_1d& MP_Velocity = rElement.GetValue(MP_VELOCITY); + const double& MP_Mass = rElement.GetValue(MP_MASS); + + for (unsigned int i = 0; i < number_of_nodes; i++) + { + array_1d& r_current_velocity = rGeom[i].FastGetSolutionStepValue(VELOCITY); + const double& r_nodal_mass = rGeom[i].FastGetSolutionStepValue(NODAL_MASS); + + for (unsigned int j = 0; j < dimension; j++) + { + // we need to use the original shape functions here (calculated before the momenta update) + r_current_velocity[j] += rN[i] * MP_Mass * MP_Velocity[j] / r_nodal_mass; + } + } + + KRATOS_CATCH("") + } + + /***********************************************************************************/ + /***********************************************************************************/ + + void MPMExplicitUtilities::CalculateExplicitKinematics( + GeometryType& rGeom, + const Matrix& rDN_DX, + const double rDeltaTime, + Vector& rMPStrain, + Matrix& rDeformationGradient, + const bool& isCompressible) + { + KRATOS_TRY + + const SizeType dimension = rGeom.WorkingSpaceDimension(); + const SizeType number_of_nodes = rGeom.PointsNumber(); + + + //Calculate velocity gradients + Matrix velocityGradient = Matrix(dimension, dimension, 0.0); + for (IndexType nodeIndex = 0; nodeIndex < number_of_nodes; nodeIndex++) + { + const array_1d& nodal_velocity = rGeom[nodeIndex].FastGetSolutionStepValue(VELOCITY); + + for (IndexType i = 0; i < dimension; i++) + { + for (IndexType j = 0; j < dimension; j++) + { + velocityGradient(i, j) += nodal_velocity[i] * rDN_DX(nodeIndex, j); + } + } + } + + + //Calculate rate of deformation and spin tensors + Matrix rateOfDeformation = 0.5 * (velocityGradient + trans(velocityGradient)); + Matrix spinTensor = velocityGradient - rateOfDeformation; + + + //Calculate objective Jaumann strain rate + Matrix jaumannRate = rateOfDeformation - + (prod(spinTensor, rateOfDeformation)) * rDeltaTime + + prod((rateOfDeformation * rDeltaTime), spinTensor); + + // TODO extend to 3D + rMPStrain(0) += jaumannRate(0, 0) * rDeltaTime; //e_xx + rMPStrain(1) += jaumannRate(1, 1) * rDeltaTime; //e_yy + rMPStrain(2) += 2.0 * jaumannRate(0, 1) * rDeltaTime; //e_xy + + + // Model compressibility + if (isCompressible) + { + Matrix I = IdentityMatrix(dimension); + Matrix updatedDeformationGradient = prod((I + rDeltaTime * velocityGradient), + rDeformationGradient); + rDeformationGradient = updatedDeformationGradient; + } + + KRATOS_CATCH("") + } +} // namespace Kratos \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h new file mode 100644 index 000000000000..f337ef52cb89 --- /dev/null +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h @@ -0,0 +1,73 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ \. +// _|\_\_| \__,_|\__|\___/ ____/ +// Multi-Physics +// +// License: BSD License +// Kratos default license: kratos/license.txt +// +// Main authors: Peter Wilson +// + +#if !defined(KRATOS_MPM_EXPLICIT_UTILITIES) +#define KRATOS_MPM_EXPLICIT_UTILITIES + +// System includes + +// External includes + +// Project includes +#include "includes/model_part.h" +#include "includes/element.h" +#include "includes/variables.h" + + +#include "particle_mechanics_application_variables.h" + +namespace Kratos +{ + ///@name Kratos Classes + ///@{ + /** + * @namespace MPMExplicitUtilities + * @ingroup ParticleMechanicsApplication + * @brief This namespace includes several utilities necessaries for the computation of the explicit integration + * @author Peter Wilson + */ + namespace MPMExplicitUtilities + { + /// The size type definition + typedef std::size_t SizeType; + + /// The index type definition + typedef std::size_t IndexType; + + /// The arrays of elements and nodes + typedef ModelPart::ElementsContainerType ElementsArrayType; + typedef ModelPart::NodesContainerType NodesArrayType; + typedef Node<3> NodeType; + typedef Geometry GeometryType; + + // Reference https://github.com/KratosMultiphysics/Kratos/blob/MPM/explicit_time_int2/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp + + + void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) CalcuateAndAddExplicitInternalForce(GeometryType& rGeom, + const Matrix& rDN_DX, const Vector& rMPStress, const double& rMPVolume, Vector& rRightHandSideVector); + + + void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) UpdateGaussPointExplicit(GeometryType& rGeom, + const double& rDeltaTime, const bool& isCentralDifference, Element& rElement, Vector& rN); + + + void CalculateMUSLGridVelocity(GeometryType& rGeom, Element& rElement, Vector& rN); + + + void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) CalculateExplicitKinematics(GeometryType& rGeom, + const Matrix& rDN_DX, const double rDeltaTime, Vector& rMPStrain, Matrix& rDeformationGradient, + const bool& isCompressible); + + + }; // namespace ExplicitIntegrationUtilities +} // namespace Kratos +#endif /* KRATOS_MPM_EXPLICIT_UTILITIES defined */ \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp b/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp index 428cda76f187..30c331d43104 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp @@ -156,6 +156,7 @@ namespace Kratos KRATOS_REGISTER_VARIABLE( MP_DELTA_PLASTIC_DEVIATORIC_STRAIN ) KRATOS_REGISTER_VARIABLE( MP_ACCUMULATED_PLASTIC_DEVIATORIC_STRAIN ) KRATOS_REGISTER_VARIABLE( NODAL_MPRESSURE ) + KRATOS_REGISTER_VARIABLE(IS_COMPRESSIBLE) // Registering consitutive law variables KRATOS_REGISTER_VARIABLE( CONSTITUTIVE_LAW_POINTER ) @@ -251,6 +252,12 @@ namespace Kratos // Solver related variables KRATOS_REGISTER_VARIABLE(IGNORE_GEOMETRIC_STIFFNESS); + + // Explicit time integration variables + KRATOS_REGISTER_3D_VARIABLE_WITH_COMPONENTS(MIDDLE_VELOCITY) + KRATOS_REGISTER_VARIABLE(MUSL_VELOCITY_FIELD_IS_COMPUTED) + KRATOS_REGISTER_VARIABLE(IS_EXPLICIT) + KRATOS_REGISTER_VARIABLE(IS_EXPLICIT_CENTRAL_DIFFERENCE) } } // namespace Kratos. diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp index 80ccc6f647a6..25655901b371 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp @@ -38,6 +38,7 @@ namespace Kratos KRATOS_CREATE_VARIABLE( double, MP_ACCUMULATED_PLASTIC_VOLUMETRIC_STRAIN ) KRATOS_CREATE_VARIABLE( double, MP_ACCUMULATED_PLASTIC_DEVIATORIC_STRAIN ) KRATOS_CREATE_VARIABLE( double, NODAL_MPRESSURE ) + KRATOS_CREATE_VARIABLE(bool, IS_COMPRESSIBLE) // Constitutive Law KRATOS_CREATE_VARIABLE( ConstitutiveLaw::Pointer, CONSTITUTIVE_LAW_POINTER ) @@ -92,4 +93,10 @@ namespace Kratos // Solver related variables KRATOS_CREATE_VARIABLE(bool, IGNORE_GEOMETRIC_STIFFNESS) + + // Explicit time integration variables + KRATOS_CREATE_3D_VARIABLE_WITH_COMPONENTS(MIDDLE_VELOCITY) + KRATOS_CREATE_VARIABLE(bool, MUSL_VELOCITY_FIELD_IS_COMPUTED) + KRATOS_CREATE_VARIABLE(bool, IS_EXPLICIT) + KRATOS_CREATE_VARIABLE(bool, IS_EXPLICIT_CENTRAL_DIFFERENCE) } \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h index 304ae9fbda49..eca37099a142 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h @@ -40,6 +40,7 @@ namespace Kratos KRATOS_DEFINE_APPLICATION_VARIABLE( PARTICLE_MECHANICS_APPLICATION, double, MP_MASS ) KRATOS_DEFINE_APPLICATION_VARIABLE( PARTICLE_MECHANICS_APPLICATION, double, MP_DENSITY ) KRATOS_DEFINE_APPLICATION_VARIABLE( PARTICLE_MECHANICS_APPLICATION, double, MP_VOLUME ) + KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, IS_COMPRESSIBLE) // Energy KRATOS_DEFINE_APPLICATION_VARIABLE( PARTICLE_MECHANICS_APPLICATION, double, MP_POTENTIAL_ENERGY ) @@ -118,6 +119,12 @@ namespace Kratos // Solver related variables KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, IGNORE_GEOMETRIC_STIFFNESS) + + // Explicit time integration variables + KRATOS_DEFINE_3D_APPLICATION_VARIABLE_WITH_COMPONENTS(PARTICLE_MECHANICS_APPLICATION, MIDDLE_VELOCITY) + KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, MUSL_VELOCITY_FIELD_IS_COMPUTED) + KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, IS_EXPLICIT) + KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, IS_EXPLICIT_CENTRAL_DIFFERENCE) } #endif // KRATOS_PARTICLE_MECHANICS_APPLICATION_VARIABLES_H_INCLUDED defined \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py b/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py new file mode 100644 index 000000000000..04eeab49f0f5 --- /dev/null +++ b/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py @@ -0,0 +1,116 @@ +from __future__ import print_function, absolute_import, division # makes KratosMultiphysics backward compatible with python 2.6 and 2.7 + +# Importing the Kratos Library +import KratosMultiphysics + +# Import applications and dependencies +import KratosMultiphysics.ParticleMechanicsApplication as KratosParticle + +# Importing the base class +from KratosMultiphysics.ParticleMechanicsApplication.mpm_solver import MPMSolver + +def CreateSolver(model, custom_settings): + return MPMExplicitSolver(model, custom_settings) + +class MPMExplicitSolver(MPMSolver): + + def __init__(self, model, custom_settings): + # Set defaults and validate custom settings in the base class. + # Construct the base solver. + super(MPMExplicitSolver, self).__init__(model, custom_settings) + KratosMultiphysics.Logger.PrintInfo("::[MPMExplicitSolver]:: ", "Construction is finished.") + + @classmethod + def GetDefaultSettings(cls): + this_defaults = KratosMultiphysics.Parameters("""{ + "scheme_type" : "forward_euler", + "stress_update" : "USL" + }""") + this_defaults.AddMissingParameters(super(MPMExplicitSolver, cls).GetDefaultSettings()) + return this_defaults + + + def AddVariables(self): + super(MPMExplicitSolver, self).AddVariables() + self._AddDynamicVariables(self.grid_model_part) + grid_model_part = self.GetGridModelPart() + + # Adding explicit variables + grid_model_part.AddNodalSolutionStepVariable(KratosMultiphysics.FORCE_RESIDUAL) + grid_model_part.AddNodalSolutionStepVariable(KratosMultiphysics.RESIDUAL_VECTOR) + + scheme_type = self.settings["scheme_type"].GetString() + grid_model_part.AddNodalSolutionStepVariable(KratosParticle.MIDDLE_VELOCITY) # we may not need this + #if(scheme_type == "central_differences"): + # grid_model_part.AddNodalSolutionStepVariable(ParticleMechanicsApplication.MIDDLE_VELOCITY) + KratosMultiphysics.Logger.PrintInfo("::[MPMExplicitSolver]:: ", "Variables are all added.") + + ### Protected functions ### + + def _CreateSolutionScheme(self): + grid_model_part = self.GetGridModelPart() + domain_size = self._GetDomainSize() + block_size = domain_size + if (self.settings["pressure_dofs"].GetBool()): + block_size += 1 + + # Setting the time integration schemes + scheme_type = self.settings["scheme_type"].GetString() + isCentralDifference = False + StressUpdateOption = 0 + + if(scheme_type == "forward_euler" or scheme_type == "Forward_Euler"): + stress_update = self.settings["stress_update"].GetString() #0 = USF, 1 = USL, 2 = MUSL + if(stress_update == "USF" or stress_update == "usf"): + StressUpdateOption = 0 + elif(stress_update == "USL" or stress_update == "usl"): + StressUpdateOption = 1 + elif(stress_update == "MUSL" or stress_update == "musl"): + StressUpdateOption = 2 + else: + err_msg = "The requested stress update \"" + stress_update + "\" is not available!\n" + err_msg += "Available options are: \"USF\", \"USL\",\"MUSL\"" + elif(scheme_type == "central_difference" or scheme_type == "Central_Difference"): + isCentralDifference = True + grid_model_part.ProcessInfo.SetValue(KratosParticle.IS_EXPLICIT_CENTRAL_DIFFERENCE, True) + else: + err_msg = "The requested scheme type \"" + scheme_type + "\" is not available!\n" + err_msg += "Available options are: \"forward_euler\", \"central_difference\"" + raise Exception(err_msg) + + is_dynamic = self._IsDynamic() + + return KratosParticle.MPMExplicitScheme( grid_model_part, + StressUpdateOption, + isCentralDifference) + + def _CreateSolutionStrategy(self): + analysis_type = self.settings["analysis_type"].GetString() + if analysis_type == "linear": + grid_model_part = self.GetGridModelPart(); + grid_model_part.ProcessInfo.SetValue(KratosParticle.IS_EXPLICIT, True) + solution_strategy = self._CreateLinearStrategy() + else: + err_msg = "The requested explicit analysis type \"" + analysis_type + "\" is not available!\n" + err_msg += "Available explicit options are: \"linear\"" + raise Exception(err_msg) + return solution_strategy + + + def _CreateLinearStrategy(self): + computing_model_part = self.GetComputingModelPart() + solution_scheme = self._GetSolutionScheme() + linear_solver = self._GetLinearSolver() + reform_dofs_at_each_step = False ## hard-coded, but can be changed upon implementation + calc_norm_dx_flag = False ## hard-coded, but can be changed upon implementation + + move_mesh_flag = self.settings["move_mesh_flag"].GetBool() + move_mesh_flag = False ## hard-coded + return KratosParticle.MPMExplicitStrategy(computing_model_part, + solution_scheme, + self.settings["compute_reactions"].GetBool(), + reform_dofs_at_each_step, + move_mesh_flag) + + def _IsDynamic(self): + return True \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/python_scripts/mpm_solver.py b/applications/ParticleMechanicsApplication/python_scripts/mpm_solver.py index 14093f112743..c586201e16c1 100644 --- a/applications/ParticleMechanicsApplication/python_scripts/mpm_solver.py +++ b/applications/ParticleMechanicsApplication/python_scripts/mpm_solver.py @@ -58,6 +58,7 @@ def GetDefaultSettings(cls): "residual_absolute_tolerance" : 1.0E-9, "max_iteration" : 20, "pressure_dofs" : false, + "compressible" : true, "axis_symmetric_flag" : false, "block_builder" : true, "move_mesh_flag" : false, @@ -150,12 +151,15 @@ def AdvanceInTime(self, current_time): def InitializeSolutionStep(self): self._SearchElement() self._GetSolutionStrategy().Initialize() + + #clean nodal values and map from MPs to nodes self._GetSolutionStrategy().InitializeSolutionStep() def Predict(self): self._GetSolutionStrategy().Predict() def SolveSolutionStep(self): + # Calc residual, update momenta is_converged = self._GetSolutionStrategy().SolveSolutionStep() return is_converged @@ -376,6 +380,7 @@ def _CreateSolutionScheme(self): raise Exception("Solution Scheme creation must be implemented in the derived class.") def _CreateSolutionStrategy(self): + # this is for implicit only. explicit is implemented in derived mpm_explicit_solver analysis_type = self.settings["analysis_type"].GetString() if analysis_type == "non_linear": solution_strategy = self._CreateNewtonRaphsonStrategy() @@ -383,8 +388,8 @@ def _CreateSolutionStrategy(self): self.material_point_model_part.ProcessInfo.SetValue(KratosParticle.IGNORE_GEOMETRIC_STIFFNESS, True) solution_strategy = self._CreateLinearStrategy(); else: - err_msg = "The requested analysis type \"" + analysis_type + "\" is not available!\n" - err_msg += "Available options are: \"linear\", \"non_linear\"" + err_msg = "The requested implicit analysis type \"" + analysis_type + "\" is not available!\n" + err_msg += "Available implicit options are: \"linear\", \"non_linear\"" raise Exception(err_msg) return solution_strategy diff --git a/applications/ParticleMechanicsApplication/python_scripts/python_solvers_wrapper_particle.py b/applications/ParticleMechanicsApplication/python_scripts/python_solvers_wrapper_particle.py index d8f145e704ad..299fe629df66 100644 --- a/applications/ParticleMechanicsApplication/python_scripts/python_solvers_wrapper_particle.py +++ b/applications/ParticleMechanicsApplication/python_scripts/python_solvers_wrapper_particle.py @@ -13,14 +13,11 @@ def CreateSolverByParameters(model, solver_settings, parallelism): time_integration_method = solver_settings["time_integration_method"].GetString() if (time_integration_method == "implicit"): solver_module_name = "mpm_implicit_dynamic_solver" - #TODO: explicit time integration solver is to be implemented elif (time_integration_method == "explicit"): - err_msg = time_integration_method + " time integration method is to be implemented, but not yet available." - err_msg += "Available options are: \"implicit\"" - raise Exception(err_msg) + solver_module_name = "mpm_explicit_solver" else: err_msg = "The requested time integration method \"" + time_integration_method + "\" is not in the python solvers wrapper\n" - err_msg += "Available options are: \"implicit\"" + err_msg += "Available options are: \"implicit\", \"explicit\"" raise Exception(err_msg) elif (solver_type == "Quasi-static" or solver_type == "quasi_static"): solver_module_name = "mpm_quasi_static_solver" From c93630d221bbe041840b870d3b6cad95029bfe01 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Tue, 31 Mar 2020 17:28:45 +1000 Subject: [PATCH 017/314] now runs, but incorrect results --- .../updated_lagrangian_quadrilateral.cpp | 41 ++++---------- .../updated_lagrangian_quadrilateral.hpp | 5 -- .../schemes/mpm_explicit_scheme.hpp | 2 +- .../strategies/mpm_explicit_strategy.hpp | 2 +- .../mpm_explicit_utilities.cpp | 53 ++++++++++--------- 5 files changed, 40 insertions(+), 63 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index 822244f96b80..983f2a47f6b7 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -342,7 +342,7 @@ void UpdatedLagrangianQuadrilateral::CalculateElementalSystem( LocalSystemCompon if ( rLocalSystem.CalculationFlags.Is(UpdatedLagrangianQuadrilateral::COMPUTE_RHS_VECTOR) ) // if calculation of the vector is required { // Contribution to forces (in residual term) are calculated - Vector volume_force = this->CalculateVolumeForce( volume_force, Variables ); + Vector volume_force = mMP.volume_acceleration * mMP.mass; this->CalculateAndAddRHS ( rLocalSystem, Variables, volume_force, mMP.volume ); } @@ -562,23 +562,19 @@ void UpdatedLagrangianQuadrilateral::CalculateAndAddExplicitInternalForces(Vecto GeometryType& r_geometry = GetGeometry(); const unsigned int dimension = r_geometry.WorkingSpaceDimension(); const unsigned int number_of_nodes = r_geometry.PointsNumber(); - const array_1d& xg = this->GetValue(MP_COORD); // Calculate shape function gradients Matrix Jacobian; - Jacobian = this->MPMJacobian(Jacobian, xg); + Jacobian = this->MPMJacobian(Jacobian, mMP.xg); Matrix InvJ; double detJ; MathUtils::InvertMatrix(Jacobian, InvJ, detJ); Matrix DN_De; - this->MPMShapeFunctionsLocalGradients(DN_De, xg); // parametric gradients + this->MPMShapeFunctionsLocalGradients(DN_De, mMP.xg); // parametric gradients mDN_DX = prod(DN_De, InvJ); // cartesian gradients - const Vector& MP_Stress = this->GetValue(MP_CAUCHY_STRESS_VECTOR); - const double& MP_Volume = this->GetValue(MP_VOLUME); - MPMExplicitUtilities::CalcuateAndAddExplicitInternalForce(r_geometry, - mDN_DX, MP_Stress, MP_Volume, rRightHandSideVector); + mDN_DX, mMP.cauchy_stress_vector, mMP.volume, rRightHandSideVector); KRATOS_CATCH("") @@ -607,13 +603,12 @@ void UpdatedLagrangianQuadrilateral::CalculateExplicitStresses(const ProcessInfo // Compute explicit element kinematics, strain is incremented here. bool isCompressible = false; // TODO update - Vector& rMPStrain = this->GetValue(MP_ALMANSI_STRAIN_VECTOR); Matrix& rDeformationGradient = rVariables.F; // TODO maybe mDeformationGradientF0 MPMExplicitUtilities::CalculateExplicitKinematics(rGeom, mDN_DX, delta_time, - rMPStrain, rDeformationGradient, isCompressible); - rVariables.StrainVector = rMPStrain; + mMP.almansi_strain_vector, rDeformationGradient, isCompressible); + rVariables.StrainVector = mMP.almansi_strain_vector; rVariables.F = rDeformationGradient; - rVariables.StressVector = this->GetValue(MP_CAUCHY_STRESS_VECTOR); + rVariables.StressVector = mMP.cauchy_stress_vector; if (!isCompressible) { @@ -730,22 +725,6 @@ double& UpdatedLagrangianQuadrilateral::CalculateVolumeChange( double& rVolumeCh KRATOS_CATCH( "" ) } -//************************************CALCULATE VOLUME ACCELERATION******************* -//************************************************************************************ - -Vector& UpdatedLagrangianQuadrilateral::CalculateVolumeForce( Vector& rVolumeForce, GeneralVariables& rVariables ) -{ - KRATOS_TRY - - const unsigned int dimension = GetGeometry().WorkingSpaceDimension(); - - rVolumeForce = ZeroVector(dimension); - rVolumeForce = mMP.volume_acceleration * mMP.mass; - - return rVolumeForce; - - KRATOS_CATCH( "" ) -} //************************************************************************************ //************************************************************************************ @@ -1006,14 +985,13 @@ void UpdatedLagrangianQuadrilateral::InitializeNonLinearIteration(ProcessInfo& r this->InitializeGeneralVariables(Variables, rCurrentProcessInfo); // Calculate shape function gradients - const array_1d& xg = this->GetValue(MP_COORD); Matrix Jacobian; - Jacobian = this->MPMJacobian(Jacobian, xg); + Jacobian = this->MPMJacobian(Jacobian, mMP.xg); Matrix InvJ; double detJ; MathUtils::InvertMatrix(Jacobian, InvJ, detJ); Matrix DN_De; - this->MPMShapeFunctionsLocalGradients(DN_De, xg); // parametric gradients + this->MPMShapeFunctionsLocalGradients(DN_De, mMP.xg); // parametric gradients mDN_DX = prod(DN_De, InvJ); // cartesian gradients //calculate stress @@ -1533,7 +1511,6 @@ void UpdatedLagrangianQuadrilateral::AddExplicitContribution(const VectorType& r GeometryType& r_geometry = GetGeometry(); const unsigned int dimension = r_geometry.WorkingSpaceDimension(); const unsigned int number_of_nodes = r_geometry.PointsNumber(); - const array_1d& xg = this->GetValue(MP_COORD); for (size_t i = 0; i < number_of_nodes; ++i) { size_t index = dimension * i; diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp index c712076a73c6..70d7afb982b2 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp @@ -863,11 +863,6 @@ class UpdatedLagrangianQuadrilateral */ virtual double& CalculateVolumeChange(double& rVolumeChange, GeneralVariables& rVariables); - /** - * Calculation of the Volume Force of the Element - */ - virtual Vector& CalculateVolumeForce(Vector& rVolumeForce, GeneralVariables& rVariables); - ///@} ///@name Protected Access diff --git a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp index a33e2ae772d1..da00301eaa50 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp @@ -831,7 +831,7 @@ namespace Kratos { { KRATOS_TRY - pCurrentEntity->CalculateRightHandSide(RHS_Contribution, rCurrentProcessInfo); + pCurrentEntity->CalculateRightHandSide(RHS_Contribution, rCurrentProcessInfo); pCurrentEntity->AddExplicitContribution(RHS_Contribution, RESIDUAL_VECTOR, FORCE_RESIDUAL, rCurrentProcessInfo); //pCurrentEntity->AddExplicitContribution(RHS_Contribution, RESIDUAL_VECTOR, MOMENT_RESIDUAL, rCurrentProcessInfo); diff --git a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp index 812b73d85436..f8bee43ab494 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp @@ -524,7 +524,7 @@ namespace Kratos { KRATOS_TRY - ProcessInfo& r_current_process_info = rModelPart.GetProcessInfo(); + ProcessInfo& r_current_process_info = rModelPart.GetProcessInfo(); ConditionsArrayType& r_conditions = rModelPart.Conditions(); ElementsArrayType& r_elements = rModelPart.Elements(); diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp index f92567cc0e74..34ba23eaf060 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp @@ -71,30 +71,31 @@ namespace Kratos { KRATOS_TRY - const unsigned int number_of_nodes = rGeom.PointsNumber(); + const unsigned int number_of_nodes = rGeom.PointsNumber(); const unsigned int dimension = rGeom.WorkingSpaceDimension(); bool isUpdateMPPositionFromUpdatedMPVelocity = true; + const ProcessInfo& rProcessInfo = ProcessInfo(); // Update the MP Velocity - const array_1d& MP_PreviousVelocity = rElement.GetValue(MP_VELOCITY); - const array_1d& MP_PreviousAcceleration = rElement.GetValue(MP_ACCELERATION); + std::vector > MP_PreviousVelocity; + std::vector > MP_PreviousAcceleration; array_1d MP_Velocity = ZeroVector(3); - + rElement.CalculateOnIntegrationPoints(MP_VELOCITY, MP_PreviousVelocity,rProcessInfo); + rElement.CalculateOnIntegrationPoints(MP_ACCELERATION, MP_PreviousAcceleration, rProcessInfo); double alpha = 1.0; if (isCentralDifference) { alpha = 0.5; isUpdateMPPositionFromUpdatedMPVelocity = false; - } - // Advance the predictor velocity - for (unsigned int i = 0; i < dimension; i++) - { - MP_Velocity[i] = MP_PreviousVelocity[i] + (1.0 - alpha) * rDeltaTime * MP_PreviousAcceleration[i]; + // Advance the predictor velocity + for (unsigned int i = 0; i < dimension; i++) + { + MP_Velocity[i] = MP_PreviousVelocity[0][i] + alpha * rDeltaTime * MP_PreviousAcceleration[0][i]; + } } - array_1d delta_xg = ZeroVector(3); array_1d MP_Acceleration = ZeroVector(3); @@ -128,10 +129,11 @@ namespace Kratos { MP_Velocity[j] += alpha * rDeltaTime * MP_Acceleration[j]; } - rElement.SetValue(MP_VELOCITY, MP_Velocity); + rElement.SetValuesOnIntegrationPoints(MP_VELOCITY, { MP_Velocity }, rProcessInfo); // Update the MP Position - const array_1d& xg = rElement.GetValue(MP_COORD); + std::vector > xg; + rElement.CalculateOnIntegrationPoints(MP_COORD, xg,rProcessInfo); if (isUpdateMPPositionFromUpdatedMPVelocity) { for (unsigned int j = 0; j < dimension; j++) @@ -139,18 +141,17 @@ namespace Kratos delta_xg[j] = rDeltaTime * MP_Velocity[j]; } } - const array_1d& new_xg = xg + delta_xg; - rElement.SetValue(MP_COORD, new_xg); - + const array_1d& new_xg = xg[0] + delta_xg; + rElement.SetValuesOnIntegrationPoints(MP_COORD, { new_xg }, rProcessInfo); // Update the MP Acceleration - rElement.SetValue(MP_ACCELERATION, MP_Acceleration); - + rElement.SetValuesOnIntegrationPoints(MP_ACCELERATION, { MP_Acceleration },rProcessInfo); // Update the MP total displacement - array_1d& MP_Displacement = rElement.GetValue(MP_DISPLACEMENT); - MP_Displacement += delta_xg; - rElement.SetValue(MP_DISPLACEMENT, MP_Displacement); + std::vector > MP_Displacement; + rElement.CalculateOnIntegrationPoints(MP_DISPLACEMENT, MP_Displacement,rProcessInfo); + MP_Displacement[0] += delta_xg; + rElement.SetValuesOnIntegrationPoints(MP_DISPLACEMENT,MP_Displacement,rProcessInfo); KRATOS_CATCH("") } @@ -165,10 +166,14 @@ namespace Kratos { KRATOS_TRY - const unsigned int dimension = rGeom.WorkingSpaceDimension(); + const unsigned int dimension = rGeom.WorkingSpaceDimension(); const unsigned int number_of_nodes = rGeom.PointsNumber(); - const array_1d& MP_Velocity = rElement.GetValue(MP_VELOCITY); - const double& MP_Mass = rElement.GetValue(MP_MASS); + const ProcessInfo& rProcessInfo = ProcessInfo(); + + std::vector > MP_Velocity; + std::vector MP_Mass; + rElement.CalculateOnIntegrationPoints(MP_VELOCITY, MP_Velocity,rProcessInfo); + rElement.CalculateOnIntegrationPoints(MP_MASS, MP_Mass, rProcessInfo); for (unsigned int i = 0; i < number_of_nodes; i++) { @@ -178,7 +183,7 @@ namespace Kratos for (unsigned int j = 0; j < dimension; j++) { // we need to use the original shape functions here (calculated before the momenta update) - r_current_velocity[j] += rN[i] * MP_Mass * MP_Velocity[j] / r_nodal_mass; + r_current_velocity[j] += rN[i] * MP_Mass[0] * MP_Velocity[0][j] / r_nodal_mass; } } From 679cb2c4fbaf4440ffd4557f003a288390c48add Mon Sep 17 00:00:00 2001 From: Miguel Angel Date: Tue, 31 Mar 2020 09:42:35 +0200 Subject: [PATCH 018/314] re-activating DEM --- scripts/build/dist/configure_ubuntu_14_04.sh | 1 + scripts/build/dist/configure_ubuntu_16_04.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/scripts/build/dist/configure_ubuntu_14_04.sh b/scripts/build/dist/configure_ubuntu_14_04.sh index 18a9ee8ae692..1ded557e13b2 100644 --- a/scripts/build/dist/configure_ubuntu_14_04.sh +++ b/scripts/build/dist/configure_ubuntu_14_04.sh @@ -29,6 +29,7 @@ export PYTHON_EXECUTABLE="/usr/bin/python3.5" add_app ${KRATOS_APP_DIR}/ExternalSolversApplication add_app ${KRATOS_APP_DIR}/StructuralMechanicsApplication add_app ${KRATOS_APP_DIR}/FluidDynamicsApplication +add_app ${KRATOS_APP_DIR}/DEMApplication # Clean clear diff --git a/scripts/build/dist/configure_ubuntu_16_04.sh b/scripts/build/dist/configure_ubuntu_16_04.sh index 18a9ee8ae692..1ded557e13b2 100644 --- a/scripts/build/dist/configure_ubuntu_16_04.sh +++ b/scripts/build/dist/configure_ubuntu_16_04.sh @@ -29,6 +29,7 @@ export PYTHON_EXECUTABLE="/usr/bin/python3.5" add_app ${KRATOS_APP_DIR}/ExternalSolversApplication add_app ${KRATOS_APP_DIR}/StructuralMechanicsApplication add_app ${KRATOS_APP_DIR}/FluidDynamicsApplication +add_app ${KRATOS_APP_DIR}/DEMApplication # Clean clear From fcb03dfe79f5ea028739325fbd23bebc997aa949 Mon Sep 17 00:00:00 2001 From: Miguel Angel Date: Tue, 31 Mar 2020 09:47:42 +0200 Subject: [PATCH 019/314] Added DEM to WIndows CI --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 16e65a59eb12..8c32f5535f09 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -106,6 +106,7 @@ jobs: set KRATOS_APPLICATIONS=%KRATOS_APPLICATIONS%%KRATOS_APP_DIR%\MeshMovingApplication; set KRATOS_APPLICATIONS=%KRATOS_APPLICATIONS%%KRATOS_APP_DIR%\EigenSolversApplication; set KRATOS_APPLICATIONS=%KRATOS_APPLICATIONS%%KRATOS_APP_DIR%\StructuralMechanicsApplication; + set KRATOS_APPLICATIONS=%KRATOS_APPLICATIONS%%KRATOS_APP_DIR%\DEMApplication; del /F /Q "%KRATOS_BUILD%\%KRATOS_BUILD_TYPE%\cmake_install.cmake" del /F /Q "%KRATOS_BUILD%\%KRATOS_BUILD_TYPE%\CMakeCache.txt" From 77241baab4747f6c37c42a09ce80fb5fcf085883 Mon Sep 17 00:00:00 2001 From: Philipp Bucher Date: Tue, 31 Mar 2020 10:35:08 +0200 Subject: [PATCH 020/314] increased verbosity --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8c32f5535f09..16e4cd273775 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -137,4 +137,4 @@ jobs: run: | set PYTHONPATH=%PYTHONPATH%;%GITHUB_WORKSPACE%/bin/%KRATOS_BUILD_TYPE% set PATH=%PATH%;%GITHUB_WORKSPACE%/bin/%KRATOS_BUILD_TYPE%/libs - python kratos/python_scripts/run_tests.py -l small -c python + python kratos/python_scripts/run_tests.py -l small -c python -v 2 From 6f0bc07bd3399a537d7046a2f082318ef02e715e Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Wed, 1 Apr 2020 10:21:04 +1000 Subject: [PATCH 021/314] fix MP update error --- .../schemes/mpm_explicit_scheme.hpp | 2 +- .../mpm_explicit_utilities.cpp | 29 ++++++++++--------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp index da00301eaa50..46b39f755341 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp @@ -316,7 +316,7 @@ namespace Kratos { } // for DomainSize - // We need to set updated grid velocity here if we are using the USL or USF formulation + // We need to set updated grid velocity here if we are using the USL formulation if (mStressUpdateOption == 1) { array_1d& r_current_velocity = itCurrentNode->FastGetSolutionStepValue(VELOCITY); diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp index 34ba23eaf060..89c741426f5d 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp @@ -28,7 +28,9 @@ namespace Kratos { KRATOS_TRY - const unsigned int dimension = rGeom.WorkingSpaceDimension(); + std::cout << "for fint rMPStress = " << rMPStress << std::endl; + + const unsigned int dimension = rGeom.WorkingSpaceDimension(); const unsigned int number_of_nodes = rGeom.PointsNumber(); array_1d nodal_force_internal_normal = ZeroVector(3); //PJW, needed for explicit force @@ -56,6 +58,7 @@ namespace Kratos rRightHandSideVector[dimension * i + 2] -= nodal_force_internal_normal[2]; //minus sign, internal forces } } + KRATOS_CATCH("") } @@ -73,7 +76,7 @@ namespace Kratos const unsigned int number_of_nodes = rGeom.PointsNumber(); const unsigned int dimension = rGeom.WorkingSpaceDimension(); - bool isUpdateMPPositionFromUpdatedMPVelocity = true; + bool isUpdateMPPositionFromUpdatedMPVelocity = true; // should normally be true. this reduces energy lost from kinematic aliasing const ProcessInfo& rProcessInfo = ProcessInfo(); // Update the MP Velocity @@ -82,18 +85,18 @@ namespace Kratos array_1d MP_Velocity = ZeroVector(3); rElement.CalculateOnIntegrationPoints(MP_VELOCITY, MP_PreviousVelocity,rProcessInfo); rElement.CalculateOnIntegrationPoints(MP_ACCELERATION, MP_PreviousAcceleration, rProcessInfo); - double alpha = 1.0; + double gamma = 1.0; // 0.5 for central difference, 1.0 for forward euler if (isCentralDifference) { - alpha = 0.5; + gamma = 0.5; isUpdateMPPositionFromUpdatedMPVelocity = false; + } - // Advance the predictor velocity - for (unsigned int i = 0; i < dimension; i++) - { - MP_Velocity[i] = MP_PreviousVelocity[0][i] + alpha * rDeltaTime * MP_PreviousAcceleration[0][i]; - } + // Advance the predictor velocity + for (unsigned int i = 0; i < dimension; i++) + { + MP_Velocity[i] = MP_PreviousVelocity[0][i] + (1.0 - gamma) * rDeltaTime * MP_PreviousAcceleration[0][i]; } array_1d delta_xg = ZeroVector(3); @@ -124,10 +127,13 @@ namespace Kratos } } + // Update the MP Acceleration + rElement.SetValuesOnIntegrationPoints(MP_ACCELERATION, { MP_Acceleration }, rProcessInfo); + // Update the MP Velocity corrector for (unsigned int j = 0; j < dimension; j++) { - MP_Velocity[j] += alpha * rDeltaTime * MP_Acceleration[j]; + MP_Velocity[j] += gamma * rDeltaTime * MP_Acceleration[j]; } rElement.SetValuesOnIntegrationPoints(MP_VELOCITY, { MP_Velocity }, rProcessInfo); @@ -144,9 +150,6 @@ namespace Kratos const array_1d& new_xg = xg[0] + delta_xg; rElement.SetValuesOnIntegrationPoints(MP_COORD, { new_xg }, rProcessInfo); - // Update the MP Acceleration - rElement.SetValuesOnIntegrationPoints(MP_ACCELERATION, { MP_Acceleration },rProcessInfo); - // Update the MP total displacement std::vector > MP_Displacement; rElement.CalculateOnIntegrationPoints(MP_DISPLACEMENT, MP_Displacement,rProcessInfo); From 73db4fecfc35004ac36c95a50ebd60146f44b60f Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Wed, 1 Apr 2020 10:38:54 +1000 Subject: [PATCH 022/314] remove debug print --- .../custom_utilities/mpm_explicit_utilities.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp index 89c741426f5d..d64bbd4581a5 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp @@ -28,8 +28,6 @@ namespace Kratos { KRATOS_TRY - std::cout << "for fint rMPStress = " << rMPStress << std::endl; - const unsigned int dimension = rGeom.WorkingSpaceDimension(); const unsigned int number_of_nodes = rGeom.PointsNumber(); array_1d nodal_force_internal_normal = ZeroVector(3); //PJW, needed for explicit force @@ -155,7 +153,7 @@ namespace Kratos rElement.CalculateOnIntegrationPoints(MP_DISPLACEMENT, MP_Displacement,rProcessInfo); MP_Displacement[0] += delta_xg; rElement.SetValuesOnIntegrationPoints(MP_DISPLACEMENT,MP_Displacement,rProcessInfo); - + KRATOS_CATCH("") } From 89ee4d7c1a4392c195ceb12e5024bd72b9d1ae99 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Wed, 1 Apr 2020 10:59:06 +1000 Subject: [PATCH 023/314] Skip inactive grid nodes in explicit analysis --- .../updated_lagrangian_quadrilateral.cpp | 1 + .../particle_mechanics_python_application.cpp | 1 + .../schemes/mpm_explicit_scheme.hpp | 24 ++++++++++++------- .../particle_mechanics_application.cpp | 1 + ...rticle_mechanics_application_variables.cpp | 1 + ...particle_mechanics_application_variables.h | 1 + .../python_scripts/mpm_explicit_solver.py | 1 + 7 files changed, 21 insertions(+), 9 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index 983f2a47f6b7..e4ce3080062e 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -959,6 +959,7 @@ void UpdatedLagrangianQuadrilateral::InitializeSolutionStep( ProcessInfo& rCurre r_geometry[i].SetLock(); + r_geometry[i].FastGetSolutionStepValue(IS_ACTIVE_MPM_EXPLICIT_NODE, 0) = true; r_geometry[i].FastGetSolutionStepValue(NODAL_MOMENTUM, 0) += nodal_momentum; r_geometry[i].FastGetSolutionStepValue(NODAL_INERTIA, 0) += nodal_inertia; diff --git a/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp b/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp index 70a90431371e..52b20ace0e71 100644 --- a/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp +++ b/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp @@ -162,6 +162,7 @@ namespace Python{ KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, MUSL_VELOCITY_FIELD_IS_COMPUTED); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, IS_EXPLICIT); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, IS_EXPLICIT_CENTRAL_DIFFERENCE); + KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, IS_ACTIVE_MPM_EXPLICIT_NODE); } } // namespace Python. diff --git a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp index 46b39f755341..7babbd95d5c8 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp @@ -211,7 +211,7 @@ namespace Kratos { // The first iterator of the array of nodes const auto it_node_begin = rModelPart.NodesBegin(); -#pragma omp parallel for schedule(guided,512) + #pragma omp parallel for schedule(guided,512) for (int i = 0; i < static_cast(r_nodes.size()); ++i) { auto it_node = (it_node_begin + i); @@ -274,9 +274,14 @@ namespace Kratos { // TODO enable parallel again //#pragma omp parallel for schedule(guided,512) for (int i = 0; i < static_cast(r_nodes.size()); ++i) { - // Current step information "N+1" (before step update). - this->UpdateTranslationalDegreesOfFreedom(it_node_begin + i, disppos, dim); + auto it_node = it_node_begin + i; + if ((it_node)->FastGetSolutionStepValue(IS_ACTIVE_MPM_EXPLICIT_NODE, 0)) + { + // Current step information "N+1" (before step update). + this->UpdateTranslationalDegreesOfFreedom(it_node, disppos, dim); + } } // for Node parallel + KRATOS_CATCH("") } @@ -379,7 +384,7 @@ namespace Kratos { OpenMPUtils::PartitionVector condition_partition; OpenMPUtils::DivideInPartitions(rModelPart.Conditions().size(), num_threads, condition_partition); -#pragma omp parallel + #pragma omp parallel { int k = OpenMPUtils::ThisThread(); ConditionsArrayType::iterator condition_begin = rModelPart.Conditions().begin() + condition_partition[k]; @@ -417,10 +422,11 @@ namespace Kratos { ProcessInfo CurrentProcessInfo = r_model_part.GetProcessInfo(); BaseType::InitializeSolutionStep(r_model_part, A, Dx, b); // LOOP OVER THE GRID NODES PERFORMED FOR CLEAR ALL NODAL INFORMATION -#pragma omp parallel for + #pragma omp parallel for for (int iter = 0; iter < static_cast(mr_grid_model_part.Nodes().size()); ++iter) { auto i = mr_grid_model_part.NodesBegin() + iter; + (i)->FastGetSolutionStepValue(IS_ACTIVE_MPM_EXPLICIT_NODE, 0) = false; // Variables to be cleaned double& nodal_mass = (i)->FastGetSolutionStepValue(NODAL_MASS); @@ -460,7 +466,7 @@ namespace Kratos { { const IndexType DisplacementPosition = mr_grid_model_part.NodesBegin()->GetDofPosition(DISPLACEMENT_X); -#pragma omp parallel for + #pragma omp parallel for for (int iter = 0; iter < static_cast(mr_grid_model_part.Nodes().size()); ++iter) { auto i = mr_grid_model_part.NodesBegin() + iter; @@ -522,7 +528,7 @@ namespace Kratos { const auto it_elem_begin = rModelPart.ElementsBegin(); // Finalizes solution step for all of the elements -#pragma omp parallel for + #pragma omp parallel for for (int i = 0; i < static_cast(rElements.size()); ++i) { auto it_elem = it_elem_begin + i; it_elem->FinalizeSolutionStep(rCurrentProcessInfo); @@ -532,7 +538,7 @@ namespace Kratos { const auto it_cond_begin = rModelPart.ConditionsBegin(); // Finalizes solution step for all of the conditions -#pragma omp parallel for + #pragma omp parallel for for (int i = 0; i < static_cast(rModelPart.Conditions().size()); ++i) { auto it_cond = it_cond_begin + i; it_cond->FinalizeSolutionStep(rCurrentProcessInfo); @@ -745,7 +751,7 @@ namespace Kratos { // Getting dof position const IndexType disppos = it_node_begin->GetDofPosition(DISPLACEMENT_X); -#pragma omp parallel for schedule(guided,512) + #pragma omp parallel for schedule(guided,512) for (int i = 0; i < static_cast(r_nodes.size()); ++i) { // Current step information "N+1" (before step update). auto it_node = it_node_begin + i; diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp b/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp index 30c331d43104..897bff1a7d55 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp @@ -258,6 +258,7 @@ namespace Kratos KRATOS_REGISTER_VARIABLE(MUSL_VELOCITY_FIELD_IS_COMPUTED) KRATOS_REGISTER_VARIABLE(IS_EXPLICIT) KRATOS_REGISTER_VARIABLE(IS_EXPLICIT_CENTRAL_DIFFERENCE) + KRATOS_REGISTER_VARIABLE(IS_ACTIVE_MPM_EXPLICIT_NODE) } } // namespace Kratos. diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp index 25655901b371..746dcd98387a 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp @@ -99,4 +99,5 @@ namespace Kratos KRATOS_CREATE_VARIABLE(bool, MUSL_VELOCITY_FIELD_IS_COMPUTED) KRATOS_CREATE_VARIABLE(bool, IS_EXPLICIT) KRATOS_CREATE_VARIABLE(bool, IS_EXPLICIT_CENTRAL_DIFFERENCE) + KRATOS_CREATE_VARIABLE(bool, IS_ACTIVE_MPM_EXPLICIT_NODE) } \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h index eca37099a142..636147c4d92c 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h @@ -125,6 +125,7 @@ namespace Kratos KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, MUSL_VELOCITY_FIELD_IS_COMPUTED) KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, IS_EXPLICIT) KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, IS_EXPLICIT_CENTRAL_DIFFERENCE) + KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, IS_ACTIVE_MPM_EXPLICIT_NODE) } #endif // KRATOS_PARTICLE_MECHANICS_APPLICATION_VARIABLES_H_INCLUDED defined \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py b/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py index 04eeab49f0f5..5f551ff53472 100644 --- a/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py +++ b/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py @@ -38,6 +38,7 @@ def AddVariables(self): # Adding explicit variables grid_model_part.AddNodalSolutionStepVariable(KratosMultiphysics.FORCE_RESIDUAL) grid_model_part.AddNodalSolutionStepVariable(KratosMultiphysics.RESIDUAL_VECTOR) + grid_model_part.AddNodalSolutionStepVariable(KratosParticle.IS_ACTIVE_MPM_EXPLICIT_NODE) scheme_type = self.settings["scheme_type"].GetString() grid_model_part.AddNodalSolutionStepVariable(KratosParticle.MIDDLE_VELOCITY) # we may not need this From 2632dca6dffa551c5879894e0925214f4ff72667 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Wed, 1 Apr 2020 11:02:23 +1000 Subject: [PATCH 024/314] re-enable parallel --- .../custom_strategies/schemes/mpm_explicit_scheme.hpp | 4 +--- .../strategies/mpm_explicit_strategy.hpp | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp index 7babbd95d5c8..304662b314e5 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp @@ -271,8 +271,7 @@ namespace Kratos { // Getting dof position const IndexType disppos = it_node_begin->GetDofPosition(DISPLACEMENT_X); - // TODO enable parallel again - //#pragma omp parallel for schedule(guided,512) + #pragma omp parallel for schedule(guided,512) for (int i = 0; i < static_cast(r_nodes.size()); ++i) { auto it_node = it_node_begin + i; if ((it_node)->FastGetSolutionStepValue(IS_ACTIVE_MPM_EXPLICIT_NODE, 0)) @@ -520,7 +519,6 @@ namespace Kratos { if (mStressUpdateOption == 2) { - // TODO maybe move to strategy so we can use the base scheme function PerformModifiedUpdateStressLastMapping(rCurrentProcessInfo, rModelPart, rElements); } diff --git a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp index f8bee43ab494..5b673096230c 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp @@ -286,7 +286,7 @@ namespace Kratos pScheme->InitializeSolutionStep(BaseType::GetModelPart(), mA, mDx, mb); if (BaseType::mRebuildLevel > 0) - { // TODO: Right now is computed in the Initialize() because is always zero, the option to set the RebuildLevel should be added in the constructor or in some place + { ProcessInfo& r_current_process_info = r_model_part.GetProcessInfo(); ElementsArrayType& r_elements = r_model_part.Elements(); const auto it_elem_begin = r_elements.begin(); @@ -530,14 +530,14 @@ namespace Kratos LocalSystemVectorType RHS_Contribution = LocalSystemVectorType(0); Element::EquationIdVectorType equation_id_vector_dummy; // Dummy - // TODO re-enable parallel - //#pragma omp parallel for firstprivate(RHS_Contribution, equation_id_vector_dummy), schedule(guided,512) + + #pragma omp parallel for firstprivate(RHS_Contribution, equation_id_vector_dummy), schedule(guided,512) for (int i = 0; i < static_cast(r_conditions.size()); ++i) { auto it_cond = r_conditions.begin() + i; pScheme->Condition_Calculate_RHS_Contribution((*it_cond.base()), RHS_Contribution, equation_id_vector_dummy, r_current_process_info); } - //#pragma omp parallel for firstprivate(RHS_Contribution, equation_id_vector_dummy), schedule(guided,512) + #pragma omp parallel for firstprivate(RHS_Contribution, equation_id_vector_dummy), schedule(guided,512) for (int i = 0; i < static_cast(r_elements.size()); ++i) { auto it_elem = r_elements.begin() + i; pScheme->Calculate_RHS_Contribution((*it_elem.base()), RHS_Contribution, equation_id_vector_dummy, r_current_process_info); From 53ab1e8397f03fb61151bf80bf2c425d96a4c65c Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Wed, 1 Apr 2020 11:28:53 +1000 Subject: [PATCH 025/314] remove unused MIDDLE_VELOCITY --- .../particle_mechanics_python_application.cpp | 1 - .../schemes/mpm_explicit_scheme.hpp | 52 ++++++++++--------- .../mpm_explicit_utilities.cpp | 2 +- .../particle_mechanics_application.cpp | 1 - ...rticle_mechanics_application_variables.cpp | 1 - ...particle_mechanics_application_variables.h | 1 - .../python_scripts/mpm_explicit_solver.py | 3 -- 7 files changed, 29 insertions(+), 32 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp b/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp index 52b20ace0e71..10481352892a 100644 --- a/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp +++ b/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp @@ -158,7 +158,6 @@ namespace Python{ KRATOS_REGISTER_IN_PYTHON_3D_VARIABLE_WITH_COMPONENTS(m, SURFACE_LOAD ) // Explicit time integration variables - KRATOS_REGISTER_IN_PYTHON_3D_VARIABLE_WITH_COMPONENTS(m, MIDDLE_VELOCITY); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, MUSL_VELOCITY_FIELD_IS_COMPUTED); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, IS_EXPLICIT); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, IS_EXPLICIT_CENTRAL_DIFFERENCE); diff --git a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp index 304662b314e5..8fc6fd6e9aa7 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp @@ -302,10 +302,10 @@ namespace Kratos { array_1d& r_nodal_momenta = itCurrentNode->FastGetSolutionStepValue(NODAL_MOMENTUM); array_1d& r_current_residual = itCurrentNode->FastGetSolutionStepValue(FORCE_RESIDUAL); - double alpha = 1.0; + double gamma = 1.0; if (mIsCentralDifference) { - alpha = 0.5; // factor since we are only adding the corrector here + gamma = 0.5; // factor since we are only adding the central difference corrector here } for (IndexType j = 0; j < DomainSize; j++) { @@ -315,7 +315,7 @@ namespace Kratos { } else { - r_nodal_momenta[j] += alpha * mTime.Delta * r_current_residual[j]; + r_nodal_momenta[j] += gamma * mTime.Delta * r_current_residual[j]; } } // for DomainSize @@ -349,7 +349,7 @@ namespace Kratos { OpenMPUtils::PartitionVector element_partition; OpenMPUtils::DivideInPartitions(rModelPart.Elements().size(), num_threads, element_partition); -#pragma omp parallel + #pragma omp parallel { int k = OpenMPUtils::ThisThread(); ElementsArrayType::iterator element_begin = rModelPart.Elements().begin() + element_partition[k]; @@ -460,7 +460,7 @@ namespace Kratos { // Extrapolate from Material Point Elements and Conditions Scheme::InitializeSolutionStep(r_model_part, A, Dx, b); - // If we are updating stress first (USF), calculate nodal velocities from momenta and apply BCs + // If we are updating stress first (USF and central difference), calculate nodal velocities from momenta and apply BCs if (mStressUpdateOption == 0 || mIsCentralDifference) { const IndexType DisplacementPosition = mr_grid_model_part.NodesBegin()->GetDofPosition(DISPLACEMENT_X); @@ -469,28 +469,32 @@ namespace Kratos { for (int iter = 0; iter < static_cast(mr_grid_model_part.Nodes().size()); ++iter) { auto i = mr_grid_model_part.NodesBegin() + iter; - const SizeType DomainSize = CurrentProcessInfo[DOMAIN_SIZE]; - double& nodal_mass = (i)->FastGetSolutionStepValue(NODAL_MASS); - array_1d& nodal_momentum = (i)->FastGetSolutionStepValue(NODAL_MOMENTUM); - array_1d& nodal_velocity = (i)->FastGetSolutionStepValue(VELOCITY); - - std::array fix_displacements = { false, false, false }; - fix_displacements[0] = (i->GetDof(DISPLACEMENT_X, DisplacementPosition).IsFixed()); - fix_displacements[1] = (i->GetDof(DISPLACEMENT_Y, DisplacementPosition + 1).IsFixed()); - if (DomainSize == 3) - fix_displacements[2] = (i->GetDof(DISPLACEMENT_Z, DisplacementPosition + 2).IsFixed()); - - if (nodal_mass > numerical_limit) + + if ((i)->FastGetSolutionStepValue(IS_ACTIVE_MPM_EXPLICIT_NODE)) { - for (IndexType j = 0; j < DomainSize; j++) + const SizeType DomainSize = CurrentProcessInfo[DOMAIN_SIZE]; + double& nodal_mass = (i)->FastGetSolutionStepValue(NODAL_MASS); + array_1d& nodal_momentum = (i)->FastGetSolutionStepValue(NODAL_MOMENTUM); + array_1d& nodal_velocity = (i)->FastGetSolutionStepValue(VELOCITY); + + std::array fix_displacements = { false, false, false }; + fix_displacements[0] = (i->GetDof(DISPLACEMENT_X, DisplacementPosition).IsFixed()); + fix_displacements[1] = (i->GetDof(DISPLACEMENT_Y, DisplacementPosition + 1).IsFixed()); + if (DomainSize == 3) + fix_displacements[2] = (i->GetDof(DISPLACEMENT_Z, DisplacementPosition + 2).IsFixed()); + + if (nodal_mass > numerical_limit) { - if (fix_displacements[j]) - { - nodal_velocity[j] = 0.0; - } - else + for (IndexType j = 0; j < DomainSize; j++) { - nodal_velocity[j] = nodal_momentum[j] / nodal_mass; + if (fix_displacements[j]) + { + nodal_velocity[j] = 0.0; + } + else + { + nodal_velocity[j] = nodal_momentum[j] / nodal_mass; + } } } } diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp index d64bbd4581a5..7037a8698756 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp @@ -91,7 +91,7 @@ namespace Kratos isUpdateMPPositionFromUpdatedMPVelocity = false; } - // Advance the predictor velocity + // Advance the material point predictor velocity for (unsigned int i = 0; i < dimension; i++) { MP_Velocity[i] = MP_PreviousVelocity[0][i] + (1.0 - gamma) * rDeltaTime * MP_PreviousAcceleration[0][i]; diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp b/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp index 897bff1a7d55..59432ed22adc 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp @@ -254,7 +254,6 @@ namespace Kratos KRATOS_REGISTER_VARIABLE(IGNORE_GEOMETRIC_STIFFNESS); // Explicit time integration variables - KRATOS_REGISTER_3D_VARIABLE_WITH_COMPONENTS(MIDDLE_VELOCITY) KRATOS_REGISTER_VARIABLE(MUSL_VELOCITY_FIELD_IS_COMPUTED) KRATOS_REGISTER_VARIABLE(IS_EXPLICIT) KRATOS_REGISTER_VARIABLE(IS_EXPLICIT_CENTRAL_DIFFERENCE) diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp index 746dcd98387a..376313de24d5 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp @@ -95,7 +95,6 @@ namespace Kratos KRATOS_CREATE_VARIABLE(bool, IGNORE_GEOMETRIC_STIFFNESS) // Explicit time integration variables - KRATOS_CREATE_3D_VARIABLE_WITH_COMPONENTS(MIDDLE_VELOCITY) KRATOS_CREATE_VARIABLE(bool, MUSL_VELOCITY_FIELD_IS_COMPUTED) KRATOS_CREATE_VARIABLE(bool, IS_EXPLICIT) KRATOS_CREATE_VARIABLE(bool, IS_EXPLICIT_CENTRAL_DIFFERENCE) diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h index 636147c4d92c..ccd60c39d7d5 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h @@ -121,7 +121,6 @@ namespace Kratos KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, IGNORE_GEOMETRIC_STIFFNESS) // Explicit time integration variables - KRATOS_DEFINE_3D_APPLICATION_VARIABLE_WITH_COMPONENTS(PARTICLE_MECHANICS_APPLICATION, MIDDLE_VELOCITY) KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, MUSL_VELOCITY_FIELD_IS_COMPUTED) KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, IS_EXPLICIT) KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, IS_EXPLICIT_CENTRAL_DIFFERENCE) diff --git a/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py b/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py index 5f551ff53472..db27f6364023 100644 --- a/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py +++ b/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py @@ -41,9 +41,6 @@ def AddVariables(self): grid_model_part.AddNodalSolutionStepVariable(KratosParticle.IS_ACTIVE_MPM_EXPLICIT_NODE) scheme_type = self.settings["scheme_type"].GetString() - grid_model_part.AddNodalSolutionStepVariable(KratosParticle.MIDDLE_VELOCITY) # we may not need this - #if(scheme_type == "central_differences"): - # grid_model_part.AddNodalSolutionStepVariable(ParticleMechanicsApplication.MIDDLE_VELOCITY) KratosMultiphysics.Logger.PrintInfo("::[MPMExplicitSolver]:: ", "Variables are all added.") ### Protected functions ### From ad68a1c40575c1d4a66120eeb0987b0028fd0aac Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Wed, 1 Apr 2020 17:03:51 +1000 Subject: [PATCH 026/314] add MUSL small mass check --- .../custom_utilities/mpm_explicit_utilities.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp index 7037a8698756..d8a7e6758ccc 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp @@ -178,13 +178,16 @@ namespace Kratos for (unsigned int i = 0; i < number_of_nodes; i++) { - array_1d& r_current_velocity = rGeom[i].FastGetSolutionStepValue(VELOCITY); const double& r_nodal_mass = rGeom[i].FastGetSolutionStepValue(NODAL_MASS); - for (unsigned int j = 0; j < dimension; j++) + if (r_nodal_mass > std::numeric_limits::epsilon()) { - // we need to use the original shape functions here (calculated before the momenta update) - r_current_velocity[j] += rN[i] * MP_Mass[0] * MP_Velocity[0][j] / r_nodal_mass; + array_1d& r_current_velocity = rGeom[i].FastGetSolutionStepValue(VELOCITY); + for (unsigned int j = 0; j < dimension; j++) + { + // we need to use the original shape functions here (calculated before the momenta update) + r_current_velocity[j] += rN[i] * MP_Mass[0] * MP_Velocity[0][j] / r_nodal_mass; + } } } From 624891839ae36df799e72e697ccebb6bf7c85f68 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Wed, 1 Apr 2020 17:04:00 +1000 Subject: [PATCH 027/314] Create assign_initial_velocity_to_particle_process.py --- ...gn_initial_velocity_to_particle_process.py | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 applications/ParticleMechanicsApplication/python_scripts/assign_initial_velocity_to_particle_process.py diff --git a/applications/ParticleMechanicsApplication/python_scripts/assign_initial_velocity_to_particle_process.py b/applications/ParticleMechanicsApplication/python_scripts/assign_initial_velocity_to_particle_process.py new file mode 100644 index 000000000000..60397244e650 --- /dev/null +++ b/applications/ParticleMechanicsApplication/python_scripts/assign_initial_velocity_to_particle_process.py @@ -0,0 +1,52 @@ +import KratosMultiphysics +import KratosMultiphysics.ParticleMechanicsApplication as KratosParticle + +def Factory(settings, Model): + if(not isinstance(settings, KratosMultiphysics.Parameters)): + raise Exception("expected input shall be a Parameters object, encapsulating a json string") + return AssignInitialVelocityToParticleProcess(Model, settings["Parameters"]) + +## All the processes python should be derived from "Process" +class AssignInitialVelocityToParticleProcess(KratosMultiphysics.Process): + def __init__(self, Model, settings ): + KratosMultiphysics.Process.__init__(self) + + default_settings = KratosMultiphysics.Parameters(""" + { + "mesh_id" : 0, + "model_part_name" : "please_specify_model_part_name", + "variable_name" : "MP_VELOCITY", + "modulus" : 1.0, + "constrained" : true, + "direction" : [0.0, 0.0, 0.0], + "local_axes" : {} + } + """) + + # Trick: allow "modulus" and "direction" to be a double or a string value (otherwise the ValidateAndAssignDefaults might fail) + if(settings.Has("modulus")): + if(settings["modulus"].IsString()): + default_settings["modulus"].SetString("0.0") + + if(settings.Has("direction")): + if(settings["direction"].IsString()): + default_settings["direction"].SetString("Automatic") + + # Detect if variable_name is MP_VELOCITY + if(settings.Has("variable_name")): + if(settings["variable_name"].GetString() != "MP_VELOCITY"): + KratosMultiphysics.Logger.PrintInfo("Warning in apply velocity to particle", "Error in determining variable_name") + raise Exception('The assign_initial_velocity_to_particle_process only accepts \"MP_VELOCITY\" as variable_name.') + + settings.ValidateAndAssignDefaults(default_settings) + + # Default settings + self.model_part = Model[settings["model_part_name"].GetString()] + self.modulus = settings["modulus"].GetDouble() + self.velocity_direction = settings["direction"].GetVector() + self.velocity = self.modulus * self.velocity_direction + + def ExecuteBeforeSolutionLoop(self): + # Assign velocity to MP after solver.Initialize() - only apply once at the beginning! + for element in self.model_part.Elements: + element.SetValuesOnIntegrationPoints(KratosParticle.MP_VELOCITY,[self.velocity],self.model_part.ProcessInfo) \ No newline at end of file From 1411b44fdefb8ce3fb76cf8e103f918fd461e10d Mon Sep 17 00:00:00 2001 From: pooyan Date: Wed, 1 Apr 2020 14:25:24 +0200 Subject: [PATCH 028/314] Using correct component index --- kratos/containers/data_value_container.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kratos/containers/data_value_container.h b/kratos/containers/data_value_container.h index 4064d29a532d..cf7a28f5ad30 100644 --- a/kratos/containers/data_value_container.h +++ b/kratos/containers/data_value_container.h @@ -212,7 +212,7 @@ class KRATOS_API(KRATOS_CORE) DataValueContainer typename ContainerType::iterator i; if ((i = std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.Key()))) != mData.end()) - return *(static_cast(i->second) + i->first->GetComponentIndex()); + return *(static_cast(i->second) + rThisVariable.GetComponentIndex()); #ifdef KRATOS_DEBUG if(OpenMPUtils::IsInParallel() != 0) @@ -221,7 +221,7 @@ class KRATOS_API(KRATOS_CORE) DataValueContainer mData.push_back(ValueType(&rThisVariable,new TDataType(rThisVariable.Zero()))); - return *(static_cast(mData.back().second) + mData.back().first->GetComponentIndex()); + return *(static_cast(mData.back().second) + rThisVariable.GetComponentIndex()); } //TODO: make the variable of the constant version consistent with the one of the "classical" one @@ -234,7 +234,7 @@ class KRATOS_API(KRATOS_CORE) DataValueContainer typename ContainerType::const_iterator i; if ((i = std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.Key()))) != mData.end()) - return *(static_cast(i->second) + i->first->GetComponentIndex()); + return *(static_cast(i->second) + rThisVariable.GetComponentIndex()); return rThisVariable.Zero(); } @@ -262,7 +262,7 @@ class KRATOS_API(KRATOS_CORE) DataValueContainer typename ContainerType::iterator i; if ((i = std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.Key()))) != mData.end()) - *(static_cast(i->second) + i->first->GetComponentIndex()) = rValue; + *(static_cast(i->second) + rThisVariable.GetComponentIndex()) = rValue; else mData.push_back(ValueType(&rThisVariable,new TDataType(rValue))); } From 72fc85469ee87e755a4eee62b58e0f89c08e5ce5 Mon Sep 17 00:00:00 2001 From: pooyan Date: Wed, 1 Apr 2020 14:26:56 +0200 Subject: [PATCH 029/314] Different constructors for variables and componets --- kratos/containers/variable_data.cpp | 11 ++++++++--- kratos/containers/variable_data.h | 23 +++++++++++++++++++---- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/kratos/containers/variable_data.cpp b/kratos/containers/variable_data.cpp index a8aae1697fbe..70d8fee74c0a 100644 --- a/kratos/containers/variable_data.cpp +++ b/kratos/containers/variable_data.cpp @@ -28,14 +28,19 @@ namespace Kratos { + /// Constructor for variables. + VariableData::VariableData(const std::string& NewName, std::size_t NewSize) : mName(NewName), mKey(0), mSize(NewSize), mpSourceVariable(nullptr), mIsComponent(false) { + mKey = GenerateKey(mName, mSize, mIsComponent, 0); + } + /// Constructor. - VariableData::VariableData(const std::string& NewName, std::size_t NewSize, bool Iscomponent, char ComponentIndex) : mName(NewName), mKey(0), mSize(NewSize), mIsComponent(Iscomponent) { - mKey = GenerateKey(mName, mSize, Iscomponent, ComponentIndex); + VariableData::VariableData(const std::string& NewName, std::size_t NewSize, const VariableData* pSourceVariable, char ComponentIndex) : mName(NewName), mKey(0), mSize(NewSize), mpSourceVariable(pSourceVariable), mIsComponent(true) { + mKey = GenerateKey(mpSourceVariable->Name(), mSize, mIsComponent, ComponentIndex); } /// Copy constructor VariableData::VariableData(const VariableData& rOtherVariable) - : mName(rOtherVariable.mName), mKey(rOtherVariable.mKey), mSize(rOtherVariable.mSize), mIsComponent(rOtherVariable.mIsComponent) {} + : mName(rOtherVariable.mName), mKey(rOtherVariable.mKey), mSize(rOtherVariable.mSize),mpSourceVariable(rOtherVariable.mpSourceVariable) , mIsComponent(rOtherVariable.mIsComponent) {} VariableData::KeyType VariableData::GenerateKey(const std::string& Name, std::size_t Size, bool IsComponent, char ComponentIndex) { diff --git a/kratos/containers/variable_data.h b/kratos/containers/variable_data.h index e129d4e21afe..c311a9c867d2 100644 --- a/kratos/containers/variable_data.h +++ b/kratos/containers/variable_data.h @@ -179,7 +179,9 @@ class KRATOS_API(KRATOS_CORE) VariableData KeyType Key() const { - return mKey; + KeyType key = mKey;// >> 8; + key &= 0xFFFFFFFF00; + return key; } /// NOTE: This function is for internal use and not @@ -217,6 +219,13 @@ class KRATOS_API(KRATOS_CORE) VariableData return (mKey & first_7_bits); } + const VariableData& GetSourceVariable() const + { + KRATOS_DEBUG_ERROR_IF(IsNotComponent()) << "The source variable is only defined for components" << std::endl; + KRATOS_DEBUG_ERROR_IF(mpSourceVariable == nullptr) << "No source variable is defined for the component" << std::endl; + return *mpSourceVariable; + } + ///@} ///@name Inquiry @@ -278,6 +287,7 @@ class KRATOS_API(KRATOS_CORE) VariableData mName = rOtherVariable.mName; mKey = rOtherVariable.mKey; mSize = rOtherVariable.mSize; + mpSourceVariable = rOtherVariable.mpSourceVariable; mIsComponent = rOtherVariable.mIsComponent; return *this; @@ -287,8 +297,11 @@ class KRATOS_API(KRATOS_CORE) VariableData ///@name Protected LifeCycle ///@{ - /// Constructor. - VariableData(const std::string& NewName, std::size_t NewSize, bool Iscomponent = false, char ComponentIndex = 0); + /// Constructor for variables. + VariableData(const std::string& NewName, std::size_t NewSize); + + /// Constructor for variables components. + VariableData(const std::string& NewName, std::size_t NewSize, const VariableData* pSourceVariable, char ComponentIndex); /** default constructor is to be used only with serialization due to the fact that @@ -309,8 +322,10 @@ class KRATOS_API(KRATOS_CORE) VariableData std::size_t mSize; - bool mIsComponent; + const VariableData* mpSourceVariable; + bool mIsComponent; + ///@} ///@name Private Operations ///@{ From 921f3134354dfe5865e515de453c54083ae757c5 Mon Sep 17 00:00:00 2001 From: pooyan Date: Wed, 1 Apr 2020 14:27:21 +0200 Subject: [PATCH 030/314] Adapting the constructor and static object --- kratos/containers/variable_component.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/kratos/containers/variable_component.h b/kratos/containers/variable_component.h index 75eccd51ba2f..52efd3ff7d30 100644 --- a/kratos/containers/variable_component.h +++ b/kratos/containers/variable_component.h @@ -91,8 +91,8 @@ class VariableComponent : public VariableData ///@name Life Cycle ///@{ - VariableComponent(const std::string& ComponentName, const std::string& SourceName, int ComponentIndex, const AdaptorType& NewAdaptor) - : BaseType(ComponentName, sizeof(DataType), true, NewAdaptor.GetComponentIndex()), mpSourceVariable(&NewAdaptor.GetSourceVariable()) + VariableComponent(const std::string& ComponentName, const std::string& SourceName, char ComponentIndex, const AdaptorType& NewAdaptor) + : BaseType(ComponentName, sizeof(DataType),&NewAdaptor.GetSourceVariable(), NewAdaptor.GetComponentIndex()), mpSourceVariable(&NewAdaptor.GetSourceVariable()) { SetKey(GenerateKey(SourceName, sizeof(DataType), true, ComponentIndex)); } @@ -136,7 +136,8 @@ class VariableComponent : public VariableData static VariableComponent const& StaticObject() { - return msStaticObject; + static const VariableComponent static_object("NONE", "NONE", 0, TAdaptorType::StaticObject()); + return static_object; } void Print(const void* pSource, std::ostream& rOStream) const override @@ -285,9 +286,6 @@ class VariableComponent : public VariableData ///@} -template -const VariableComponent VariableComponent::msStaticObject("NONE", "NONE", 0, TAdaptorType::StaticObject()); - ///@name Type Definitions ///@{ From 650735d0e0167acf98a0b07c098526721a6385a5 Mon Sep 17 00:00:00 2001 From: pooyan Date: Wed, 1 Apr 2020 14:28:03 +0200 Subject: [PATCH 031/314] Adapting to the new constructor of variable data --- kratos/containers/variable.h | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/kratos/containers/variable.h b/kratos/containers/variable.h index e518a393174c..867d00ac3fed 100644 --- a/kratos/containers/variable.h +++ b/kratos/containers/variable.h @@ -90,11 +90,22 @@ class Variable : public VariableData { } + /** + * Constructor for creating a compenent of other vairable + * @param NewName The name to be assigned to the compoenent + * @param Zero The value to be assigned to the variable as zero. In case of not definition will take the value given by the constructor of the time + */ + template + explicit Variable(const std::string& NewName, TSourceVariableType* pSourceVariable, char ComponentIndex, const TDataType Zero = TDataType()) + : VariableData(NewName, sizeof(TDataType), pSourceVariable, ComponentIndex), mZero(Zero) + { + } + /** * Copy constructor. * @param rOtherVariable The old variable to be copied */ - explicit Variable(const VariableType& rOtherVariable) : VariableData(rOtherVariable), mZero(rOtherVariable.mZero) {} + Variable(const VariableType& rOtherVariable) : VariableData(rOtherVariable), mZero(rOtherVariable.mZero) {} /// Destructor. ~Variable() override {} @@ -255,7 +266,8 @@ class Variable : public VariableData */ static const VariableType& StaticObject() { - return msStaticObject; + const static Variable static_object("NONE"); + return static_object; } TDataType& GetValue(void* pSource) const @@ -272,14 +284,6 @@ class Variable : public VariableData ///@name Access ///@{ - - const VariableData& GetSourceVariable() const - { - KRATOS_DEBUG_ERROR_IF(IsNotComponent()) << "The source variable is only defined for components" << std::endl; - KRATOS_DEBUG_ERROR_IF(mpSourceVariable == nullptr) << "No source variable is defined for the component" << std::endl; - return *mpSourceVariable; - } - /** * This method returns the zero value of the variable type * @return The zero value of the corresponding variable @@ -376,14 +380,10 @@ class Variable : public VariableData ///@name Static Member Variables ///@{ - static const VariableType msStaticObject; - ///@} ///@name Member Variables ///@{ - - const VariableData* mpSourceVariable; TDataType mZero; // The zero type contains the null value of the current variable type ///@} @@ -460,9 +460,6 @@ class Variable : public VariableData ///@} -template -const Variable Variable::msStaticObject("NONE"); - ///@name Type Definitions ///@{ From 416ee2013e1488d1e64e833ebc0da514e1d4ddd7 Mon Sep 17 00:00:00 2001 From: pooyan Date: Wed, 1 Apr 2020 14:28:39 +0200 Subject: [PATCH 032/314] Fixing add and has methods for components --- kratos/containers/variables_list.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kratos/containers/variables_list.h b/kratos/containers/variables_list.h index d57252a34f48..e49e553b978b 100644 --- a/kratos/containers/variables_list.h +++ b/kratos/containers/variables_list.h @@ -266,10 +266,15 @@ namespace Kratos if (ThisVariable.Key() == 0) KRATOS_THROW_ERROR(std::logic_error, "Adding uninitialize variable to this variable list. Check if all variables are registered before kernel initialization", ""); + if (Has(ThisVariable)) return; + if(ThisVariable.IsComponent()){ + Add(ThisVariable.GetSourceVariable()); + } + mVariables.push_back(&ThisVariable); SetPosition(ThisVariable.Key(), mDataSize); const SizeType block_size = sizeof(BlockType); @@ -368,6 +373,10 @@ namespace Kratos bool Has(const VariableData& rThisVariable) const { + if(rThisVariable.IsComponent()){ + return Has(rThisVariable.GetSourceVariable()); + } + if (mPositions.empty()) return false; From cf58c523da4bf7de377a8b0bf124e0ed56c1ed4c Mon Sep 17 00:00:00 2001 From: pooyan Date: Wed, 1 Apr 2020 14:29:01 +0200 Subject: [PATCH 033/314] Fixing static object --- kratos/containers/vector_component_adaptor.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/kratos/containers/vector_component_adaptor.h b/kratos/containers/vector_component_adaptor.h index 7ee0236111ca..6822c1f203fd 100644 --- a/kratos/containers/vector_component_adaptor.h +++ b/kratos/containers/vector_component_adaptor.h @@ -112,7 +112,9 @@ class VectorComponentAdaptor static VectorComponentAdaptor const& StaticObject() { - return msStaticObject; + + static VectorComponentAdaptor const static_object = VectorComponentAdaptor(VectorComponentAdaptor::SourceVariableType::StaticObject(), 0); + return static_object; } ///@} @@ -204,8 +206,6 @@ class VectorComponentAdaptor ///@name Static Member Variables ///@{ - static VectorComponentAdaptor const msStaticObject; - ///@} ///@name Member Variables ///@{ @@ -251,9 +251,6 @@ class VectorComponentAdaptor ///@} -template -const VectorComponentAdaptor VectorComponentAdaptor::msStaticObject = VectorComponentAdaptor(VectorComponentAdaptor::SourceVariableType::StaticObject(), 0); - ///@name Type Definitions ///@{ From 32e2c2c6bda8b5684b12c257c6c367ad1bc8f3a7 Mon Sep 17 00:00:00 2001 From: pooyan Date: Wed, 1 Apr 2020 14:30:17 +0200 Subject: [PATCH 034/314] Changing for array_1d components to variables --- kratos/includes/define.h | 48 ++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/kratos/includes/define.h b/kratos/includes/define.h index 1da8037c5d8b..ae201a1a5d7a 100644 --- a/kratos/includes/define.h +++ b/kratos/includes/define.h @@ -140,9 +140,9 @@ catch(...) { Block KRATOS_THROW_ERROR(std::runtime_error, "Unknown error", MoreI #endif #define KRATOS_DEFINE_3D_VARIABLE_WITH_COMPONENTS_IMPLEMENTATION(module, name) \ KRATOS_EXPORT_MACRO(module) extern Kratos::Variable > name; \ - KRATOS_EXPORT_MACRO(module) extern Kratos::VariableComponent > > name##_X;\ - KRATOS_EXPORT_MACRO(module) extern Kratos::VariableComponent > > name##_Y;\ - KRATOS_EXPORT_MACRO(module) extern Kratos::VariableComponent > > name##_Z; + KRATOS_EXPORT_MACRO(module) extern Kratos::Variable name##_X;\ + KRATOS_EXPORT_MACRO(module) extern Kratos::Variable name##_Y;\ + KRATOS_EXPORT_MACRO(module) extern Kratos::Variable name##_Z; #ifdef KRATOS_DEFINE_3D_VARIABLE_WITH_COMPONENTS #undef KRATOS_DEFINE_3D_VARIABLE_WITH_COMPONENTS @@ -155,18 +155,18 @@ catch(...) { Block KRATOS_THROW_ERROR(std::runtime_error, "Unknown error", MoreI #endif #define KRATOS_DEFINE_3D_APPLICATION_VARIABLE_WITH_COMPONENTS(application, name) \ KRATOS_API(application) extern Kratos::Variable > name; \ - KRATOS_API(application) extern Kratos::VariableComponent > > name##_X;\ - KRATOS_API(application) extern Kratos::VariableComponent > > name##_Y;\ - KRATOS_API(application) extern Kratos::VariableComponent > > name##_Z; + KRATOS_API(application) extern Kratos::Variable name##_X;\ + KRATOS_API(application) extern Kratos::Variable name##_Y;\ + KRATOS_API(application) extern Kratos::Variable name##_Z; #ifdef KRATOS_DEFINE_SYMMETRIC_2D_TENSOR_VARIABLE_WITH_COMPONENTS #undef KRATOS_DEFINE_SYMMETRIC_2D_TENSOR_VARIABLE_WITH_COMPONENTS #endif #define KRATOS_DEFINE_SYMMETRIC_2D_TENSOR_VARIABLE_WITH_COMPONENTS_IMPLEMENTATION(module, name) \ KRATOS_EXPORT_MACRO(module) extern Kratos::Variable > name; \ - KRATOS_EXPORT_MACRO(module) extern Kratos::VariableComponent > > name##_XX;\ - KRATOS_EXPORT_MACRO(module) extern Kratos::VariableComponent > > name##_YY;\ - KRATOS_EXPORT_MACRO(module) extern Kratos::VariableComponent > > name##_XY; + KRATOS_EXPORT_MACRO(module) extern Kratos::Variable name##_XX;\ + KRATOS_EXPORT_MACRO(module) extern Kratos::Variable name##_YY;\ + KRATOS_EXPORT_MACRO(module) extern Kratos::Variable name##_XY; #ifdef KRATOS_DEFINE_SYMMETRIC_2D_TENSOR_VARIABLE_WITH_COMPONENTS #undef KRATOS_DEFINE_SYMMETRIC_2D_TENSOR_VARIABLE_WITH_COMPONENTS @@ -179,9 +179,9 @@ catch(...) { Block KRATOS_THROW_ERROR(std::runtime_error, "Unknown error", MoreI #endif #define KRATOS_DEFINE_SYMMETRIC_2D_TENSOR_APPLICATION_VARIABLE_WITH_COMPONENTS(application, name) \ KRATOS_API(application) extern Kratos::Variable > name; \ - KRATOS_API(application) extern Kratos::VariableComponent > > name##_XX;\ - KRATOS_API(application) extern Kratos::VariableComponent > > name##_YY;\ - KRATOS_API(application) extern Kratos::VariableComponent > > name##_XY; + KRATOS_API(application) extern Kratos::Variable name##_XX;\ + KRATOS_API(application) extern Kratos::Variable name##_YY;\ + KRATOS_API(application) extern Kratos::Variable name##_XY; #ifdef KRATOS_DEFINE_SYMMETRIC_3D_TENSOR_VARIABLE_WITH_COMPONENTS #undef KRATOS_DEFINE_SYMMETRIC_3D_TENSOR_VARIABLE_WITH_COMPONENTS @@ -293,14 +293,14 @@ catch(...) { Block KRATOS_THROW_ERROR(std::runtime_error, "Unknown error", MoreI #define KRATOS_CREATE_3D_VARIABLE_WITH_THIS_COMPONENTS(name, component1, component2, component3) \ /*const*/ Kratos::Variable > name(#name, Kratos::array_1d(Kratos::ZeroVector(3))); \ \ - /*const*/ Kratos::VariableComponent > > \ - component1(#component1, #name, 0, Kratos::VectorComponentAdaptor >(name, 0)); \ + /*const*/ Kratos::Variable \ + component1(#component1, &name, 0); \ \ - /*const*/ Kratos::VariableComponent > > \ - component2(#component2, #name, 1, Kratos::VectorComponentAdaptor >(name, 1)); \ + /*const*/ Kratos::Variable \ + component2(#component2, &name, 1); \ \ - /*const*/ Kratos::VariableComponent > > \ - component3(#component3, #name, 2, Kratos::VectorComponentAdaptor >(name, 2)); + /*const*/ Kratos::Variable \ + component3(#component3, &name, 2); #ifdef KRATOS_CREATE_3D_VARIABLE_WITH_COMPONENTS #undef KRATOS_CREATE_3D_VARIABLE_WITH_COMPONENTS @@ -314,14 +314,14 @@ catch(...) { Block KRATOS_THROW_ERROR(std::runtime_error, "Unknown error", MoreI #define KRATOS_CREATE_SYMMETRIC_2D_TENSOR_VARIABLE_WITH_THIS_COMPONENTS(name, component1, component2, component3) \ /*const*/ Kratos::Variable > name(#name, Kratos::zero_vector(3)); \ \ - /*const*/ Kratos::VariableComponent > > \ - component1(#component1, #name, 0, Kratos::VectorComponentAdaptor >(name, 0)); \ + /*const*/ Kratos::Variable \ + component1(#component1, &name, 0); \ \ - /*const*/ Kratos::VariableComponent > > \ - component2(#component2, #name, 1, Kratos::VectorComponentAdaptor >(name, 1)); \ + /*const*/ Kratos::Variable \ + component2(#component2, &name, 1); \ \ - /*const*/ Kratos::VariableComponent > > \ - component3(#component3, #name, 2, Kratos::VectorComponentAdaptor >(name, 2)); + /*const*/ Kratos::Variable \ + component3(#component3, &name, 2); #ifdef KRATOS_CREATE_SYMMETRIC_2D_TENSOR_VARIABLE_WITH_COMPONENTS #undef KRATOS_CREATE_SYMMETRIC_2D_TENSOR_VARIABLE_WITH_COMPONENTS From 3de240d865f54501a3874b2621c059fe76fb80a6 Mon Sep 17 00:00:00 2001 From: pooyan Date: Wed, 1 Apr 2020 14:30:49 +0200 Subject: [PATCH 035/314] Changing compoent type to variable --- .../residual_based_bdf_displacement_scheme.h | 14 +++++++------- .../residual_based_bossak_displacement_scheme.hpp | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/kratos/solving_strategies/schemes/residual_based_bdf_displacement_scheme.h b/kratos/solving_strategies/schemes/residual_based_bdf_displacement_scheme.h index 510e0b34a4eb..ab0200270d02 100644 --- a/kratos/solving_strategies/schemes/residual_based_bdf_displacement_scheme.h +++ b/kratos/solving_strategies/schemes/residual_based_bdf_displacement_scheme.h @@ -88,7 +88,7 @@ class ResidualBasedBDFDisplacementScheme /// Conditions containers definition typedef ModelPart::ConditionsContainerType ConditionsArrayType; - typedef VectorComponentAdaptor< array_1d< double, 3 > > ComponentType; + typedef double ComponentType; ///@} ///@name Life Cycle @@ -181,9 +181,9 @@ class ResidualBasedBDFDisplacementScheme const int accelpos = it_node_begin->HasDofFor(ACCELERATION_X) ? it_node_begin->GetDofPosition(ACCELERATION_X) : -1; std::array fixed = {false, false, false}; - const std::array, 3> disp_components = {DISPLACEMENT_X, DISPLACEMENT_Y, DISPLACEMENT_Z}; - const std::array, 3> vel_components = {VELOCITY_X, VELOCITY_Y, VELOCITY_Z}; - const std::array, 3> accel_components = {ACCELERATION_X, ACCELERATION_Y, ACCELERATION_Z}; + const std::array, 3> disp_components = {DISPLACEMENT_X, DISPLACEMENT_Y, DISPLACEMENT_Z}; + const std::array, 3> vel_components = {VELOCITY_X, VELOCITY_Y, VELOCITY_Z}; + const std::array, 3> accel_components = {ACCELERATION_X, ACCELERATION_Y, ACCELERATION_Z}; #pragma omp parallel for private(fixed) for(int i = 0; i < num_nodes; ++i) { @@ -251,9 +251,9 @@ class ResidualBasedBDFDisplacementScheme // Auxiliar variables std::array predicted = {false, false, false}; - const std::array, 3> disp_components = {DISPLACEMENT_X, DISPLACEMENT_Y, DISPLACEMENT_Z}; - const std::array, 3> vel_components = {VELOCITY_X, VELOCITY_Y, VELOCITY_Z}; - const std::array, 3> accel_components = {ACCELERATION_X, ACCELERATION_Y, ACCELERATION_Z}; + const std::array, 3> disp_components = {DISPLACEMENT_X, DISPLACEMENT_Y, DISPLACEMENT_Z}; + const std::array, 3> vel_components = {VELOCITY_X, VELOCITY_Y, VELOCITY_Z}; + const std::array, 3> accel_components = {ACCELERATION_X, ACCELERATION_Y, ACCELERATION_Z}; #pragma omp parallel for private(predicted) for(int i = 0; i< num_nodes; ++i) { diff --git a/kratos/solving_strategies/schemes/residual_based_bossak_displacement_scheme.hpp b/kratos/solving_strategies/schemes/residual_based_bossak_displacement_scheme.hpp index 10bc4a5754e3..74394dacbfb8 100644 --- a/kratos/solving_strategies/schemes/residual_based_bossak_displacement_scheme.hpp +++ b/kratos/solving_strategies/schemes/residual_based_bossak_displacement_scheme.hpp @@ -88,7 +88,7 @@ class ResidualBasedBossakDisplacementScheme typedef typename BaseType::Pointer BaseTypePointer; - typedef VectorComponentAdaptor< array_1d< double, 3 > > ComponentType; + typedef double ComponentType; ///@} ///@name Life Cycle @@ -279,9 +279,9 @@ class ResidualBasedBossakDisplacementScheme // Auxiliar variables array_1d delta_displacement; std::array predicted = {false, false, false}; - const std::array, 3> disp_components = {DISPLACEMENT_X, DISPLACEMENT_Y, DISPLACEMENT_Z}; - const std::array, 3> vel_components = {VELOCITY_X, VELOCITY_Y, VELOCITY_Z}; - const std::array, 3> accel_components = {ACCELERATION_X, ACCELERATION_Y, ACCELERATION_Z}; + const std::array, 3> disp_components = {DISPLACEMENT_X, DISPLACEMENT_Y, DISPLACEMENT_Z}; + const std::array, 3> vel_components = {VELOCITY_X, VELOCITY_Y, VELOCITY_Z}; + const std::array, 3> accel_components = {ACCELERATION_X, ACCELERATION_Y, ACCELERATION_Z}; #pragma omp parallel for private(delta_displacement, predicted) for(int i = 0; i < num_nodes; ++i) { @@ -375,9 +375,9 @@ class ResidualBasedBossakDisplacementScheme const int accelpos = it_node_begin->HasDofFor(ACCELERATION_X) ? it_node_begin->GetDofPosition(ACCELERATION_X) : -1; std::array fixed = {false, false, false}; - const std::array, 3> disp_components = {DISPLACEMENT_X, DISPLACEMENT_Y, DISPLACEMENT_Z}; - const std::array, 3> vel_components = {VELOCITY_X, VELOCITY_Y, VELOCITY_Z}; - const std::array, 3> accel_components = {ACCELERATION_X, ACCELERATION_Y, ACCELERATION_Z}; + const std::array, 3> disp_components = {DISPLACEMENT_X, DISPLACEMENT_Y, DISPLACEMENT_Z}; + const std::array, 3> vel_components = {VELOCITY_X, VELOCITY_Y, VELOCITY_Z}; + const std::array, 3> accel_components = {ACCELERATION_X, ACCELERATION_Y, ACCELERATION_Z}; #pragma omp parallel for private(fixed) for(int i = 0; i < num_nodes; ++i) { From 23f09784ce8b38eac196515a36a8f6012a0364a4 Mon Sep 17 00:00:00 2001 From: pooyan Date: Wed, 1 Apr 2020 14:31:10 +0200 Subject: [PATCH 036/314] Adding tests for components --- .../containers/test_data_value_container.cpp | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/kratos/tests/cpp_tests/containers/test_data_value_container.cpp b/kratos/tests/cpp_tests/containers/test_data_value_container.cpp index 946f350f7688..2590b5e51906 100644 --- a/kratos/tests/cpp_tests/containers/test_data_value_container.cpp +++ b/kratos/tests/cpp_tests/containers/test_data_value_container.cpp @@ -36,6 +36,24 @@ KRATOS_TEST_CASE_IN_SUITE(DataValueContainerHas, KratosCoreFastSuite) { KRATOS_CHECK_EQUAL(check_false, false); } +KRATOS_TEST_CASE_IN_SUITE(DataValueContainerHasComponent, KratosCoreFastSuite) { + DataValueContainer container; + array_1d displacement; + displacement[0] = 0.00; + displacement[1] = 0.10; + displacement[2] = 0.20; + + KRATOS_CHECK_IS_FALSE(container.Has(DISPLACEMENT_X)); + KRATOS_CHECK_IS_FALSE(container.Has(DISPLACEMENT_Y)); + KRATOS_CHECK_IS_FALSE(container.Has(DISPLACEMENT_Z)); + + container.SetValue(DISPLACEMENT, displacement); + + KRATOS_CHECK(container.Has(DISPLACEMENT_X)); + KRATOS_CHECK(container.Has(DISPLACEMENT_Y)); + KRATOS_CHECK(container.Has(DISPLACEMENT_Z)); +} + KRATOS_TEST_CASE_IN_SUITE(DataValueContainer, KratosCoreFastSuite) { DataValueContainer container; Vector original_distances(4); @@ -50,6 +68,20 @@ KRATOS_TEST_CASE_IN_SUITE(DataValueContainer, KratosCoreFastSuite) { KRATOS_CHECK_EQUAL(distances[i], original_distances[i]); } +KRATOS_TEST_CASE_IN_SUITE(DataValueContainerComponent, KratosCoreFastSuite) { + DataValueContainer container; + array_1d original_velocity; + original_velocity[0] = 0.00; + original_velocity[1] = 0.10; + original_velocity[2] = 0.20; + + container.SetValue(VELOCITY, original_velocity); + + KRATOS_CHECK_EQUAL(container.GetValue(VELOCITY_X), original_velocity[0]); + KRATOS_CHECK_EQUAL(container.GetValue(VELOCITY_Y), original_velocity[1]); + KRATOS_CHECK_EQUAL(container.GetValue(VELOCITY_Z), original_velocity[2]); +} + KRATOS_TEST_CASE_IN_SUITE(DataValueContainerMerge, KratosCoreFastSuite) { DataValueContainer container_origin; DataValueContainer container_target; From a51ef5ffa072b449bbf0c1487dbf9becdf817704 Mon Sep 17 00:00:00 2001 From: pooyan Date: Wed, 1 Apr 2020 14:31:50 +0200 Subject: [PATCH 037/314] Adding tests for VariablesListDataValueContainer --- ...st_variables_list_data_value_container.cpp | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 kratos/tests/cpp_tests/containers/test_variables_list_data_value_container.cpp diff --git a/kratos/tests/cpp_tests/containers/test_variables_list_data_value_container.cpp b/kratos/tests/cpp_tests/containers/test_variables_list_data_value_container.cpp new file mode 100644 index 000000000000..81ac0cdea598 --- /dev/null +++ b/kratos/tests/cpp_tests/containers/test_variables_list_data_value_container.cpp @@ -0,0 +1,84 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ ` +// _|\_\_| \__,_|\__|\___/ ____/ +// Multi-Physics +// +// License: BSD License +// Kratos default license: +// kratos/license.txt +// +// Main authors: Pooyan Dadvand +// +// + +// System includes +#include + +// External includes + +// Project includes +#include "containers/variables_list_data_value_container.h" +#include "includes/variables.h" +#include "testing/testing.h" + +namespace Kratos { +namespace Testing { + +KRATOS_TEST_CASE_IN_SUITE(VariablesListDataValueContainerHas, KratosCoreFastSuite) { + VariablesList::Pointer p_variables_list=Kratos::make_intrusive(); + p_variables_list->Add(NODAL_AREA); + VariablesListDataValueContainer container(p_variables_list); + + KRATOS_CHECK(container.Has(NODAL_AREA)); + KRATOS_CHECK_IS_FALSE(container.Has(DISPLACEMENT)); +} + +KRATOS_TEST_CASE_IN_SUITE(VariablesListDataValueContainerHasComponent, KratosCoreFastSuite) { + VariablesList::Pointer p_variables_list=Kratos::make_intrusive(); + p_variables_list->Add(DISPLACEMENT); + VariablesListDataValueContainer container(p_variables_list); + + KRATOS_CHECK_IS_FALSE(container.Has(VELOCITY_X)); + KRATOS_CHECK_IS_FALSE(container.Has(VELOCITY_Y)); + KRATOS_CHECK_IS_FALSE(container.Has(VELOCITY_Z)); + + KRATOS_CHECK(container.Has(DISPLACEMENT_X)); + KRATOS_CHECK(container.Has(DISPLACEMENT_Y)); + KRATOS_CHECK(container.Has(DISPLACEMENT_Z)); +} + +KRATOS_TEST_CASE_IN_SUITE(VariablesListDataValueContainerGetValue, KratosCoreFastSuite) { + VariablesList::Pointer p_variables_list=Kratos::make_intrusive(); + p_variables_list->Add(ELEMENTAL_DISTANCES); + VariablesListDataValueContainer container(p_variables_list); + Vector original_distances(4); + original_distances[0] = 0.00; + original_distances[1] = 0.10; + original_distances[2] = 0.20; + original_distances[3] = 0.30; + container.SetValue(ELEMENTAL_DISTANCES, original_distances); + auto& distances = container.GetValue(ELEMENTAL_DISTANCES); + + for (std::size_t i = 0; i < distances.size(); i++) + KRATOS_CHECK_EQUAL(distances[i], original_distances[i]); +} + +KRATOS_TEST_CASE_IN_SUITE(VariablesListDataValueContainerGetComponentValue, KratosCoreFastSuite) { + VariablesList::Pointer p_variables_list=Kratos::make_intrusive(); + p_variables_list->Add(VELOCITY); + VariablesListDataValueContainer container(p_variables_list); + array_1d original_velocity; + original_velocity[0] = 0.00; + original_velocity[1] = 0.10; + original_velocity[2] = 0.20; + + container.SetValue(VELOCITY, original_velocity); + + KRATOS_CHECK_EQUAL(container.GetValue(VELOCITY_X), original_velocity[0]); + KRATOS_CHECK_EQUAL(container.GetValue(VELOCITY_Y), original_velocity[1]); + KRATOS_CHECK_EQUAL(container.GetValue(VELOCITY_Z), original_velocity[2]); +} + +} +} // namespace Kratos. From 0ea89fde5adc287771aaaca75eef5956d9281274 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Thu, 2 Apr 2020 11:25:05 +1000 Subject: [PATCH 038/314] add compressibility flag --- .../custom_elements/updated_lagrangian_quadrilateral.cpp | 2 +- .../python_scripts/mpm_explicit_solver.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index e4ce3080062e..f6b995dc8a49 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -586,6 +586,7 @@ void UpdatedLagrangianQuadrilateral::CalculateExplicitStresses(const ProcessInfo GeometryType& rGeom = GetGeometry(); const double& delta_time = rCurrentProcessInfo[DELTA_TIME]; + bool isCompressible = rCurrentProcessInfo.GetValue(IS_COMPRESSIBLE); // Create constitutive law parameters: ConstitutiveLaw::Parameters Values(GetGeometry(), GetProperties(), rCurrentProcessInfo); @@ -602,7 +603,6 @@ void UpdatedLagrangianQuadrilateral::CalculateExplicitStresses(const ProcessInfo ConstitutiveLawOptions.Set(ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN, false); // Compute explicit element kinematics, strain is incremented here. - bool isCompressible = false; // TODO update Matrix& rDeformationGradient = rVariables.F; // TODO maybe mDeformationGradientF0 MPMExplicitUtilities::CalculateExplicitKinematics(rGeom, mDN_DX, delta_time, mMP.almansi_strain_vector, rDeformationGradient, isCompressible); diff --git a/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py b/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py index db27f6364023..2e076e67d74c 100644 --- a/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py +++ b/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py @@ -52,6 +52,10 @@ def _CreateSolutionScheme(self): if (self.settings["pressure_dofs"].GetBool()): block_size += 1 + # Check whether compressibility is considered + isCompressible = self.settings["compressible"].GetBool() + grid_model_part.ProcessInfo.SetValue(KratosParticle.IS_COMPRESSIBLE, isCompressible) + # Setting the time integration schemes scheme_type = self.settings["scheme_type"].GetString() isCentralDifference = False From faf81ccd461dc9d3c0d1508fce31757c55cd7fab Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Thu, 2 Apr 2020 13:23:33 +1000 Subject: [PATCH 039/314] add compressibility --- .../updated_lagrangian_quadrilateral.cpp | 28 ++++++++----- .../mpm_explicit_utilities.cpp | 41 +++++++++++++++---- 2 files changed, 51 insertions(+), 18 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index f6b995dc8a49..787abde60482 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -602,23 +602,31 @@ void UpdatedLagrangianQuadrilateral::CalculateExplicitStresses(const ProcessInfo ConstitutiveLawOptions.Set(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR, true); ConstitutiveLawOptions.Set(ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN, false); + // Compute explicit element kinematics, strain is incremented here. - Matrix& rDeformationGradient = rVariables.F; // TODO maybe mDeformationGradientF0 MPMExplicitUtilities::CalculateExplicitKinematics(rGeom, mDN_DX, delta_time, - mMP.almansi_strain_vector, rDeformationGradient, isCompressible); - rVariables.StrainVector = mMP.almansi_strain_vector; - rVariables.F = rDeformationGradient; + mMP.almansi_strain_vector, rVariables.F, isCompressible); rVariables.StressVector = mMP.cauchy_stress_vector; + rVariables.StrainVector = mMP.almansi_strain_vector; - if (!isCompressible) + // Update gradient deformation + rVariables.F0 = mDeformationGradientF0; // total member def grad NOT including this increment + rVariables.FT = prod(rVariables.F, rVariables.F0); // total def grad including this increment + rVariables.detF = MathUtils::Det(rVariables.F); // det of current increment + rVariables.detF0 = MathUtils::Det(rVariables.F0); // det of def grad NOT including this increment + rVariables.detFT = MathUtils::Det(rVariables.FT); // det of total def grad including this increment + mDeformationGradientF0 = rVariables.FT; // update member internal total grad def + mDeterminantF0 = rVariables.detFT; // update member internal total grad def det + + // Update MP volume + if (isCompressible) { - // TODO fix thisup - rVariables.F = mDeformationGradientF0; - rVariables.detF = mDeterminantF0; - rVariables.F0 = mDeformationGradientF0; - rVariables.detF0 = mDeterminantF0; + mMP.density = (GetProperties()[DENSITY]) / rVariables.detFT; + mMP.volume = mMP.mass / mMP.density; } + + rVariables.CurrentDisp = CalculateCurrentDisp(rVariables.CurrentDisp, rCurrentProcessInfo); rVariables.DN_DX = mDN_DX; rVariables.N = mN; diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp index d8a7e6758ccc..92e0fb69cdcb 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp @@ -50,9 +50,15 @@ namespace Kratos rRightHandSideVector[dimension * i] -= nodal_force_internal_normal[0]; //minus sign, internal forces rRightHandSideVector[dimension * i + 1] -= nodal_force_internal_normal[1]; //minus sign, internal forces - if (dimension > 2) + if (dimension == 3) { + KRATOS_ERROR << "NOT IMPLEMENTED YET"; // TODO add in third dimension here + //f_x = V*(s_yy*dNdX + s_xy*dNdX) + nodal_force_internal_normal[1] = rMPVolume * + (rMPStress[1] * rDN_DX(i, 1) + + rMPStress[2] * rDN_DX(i, 0)); + rRightHandSideVector[dimension * i + 2] -= nodal_force_internal_normal[2]; //minus sign, internal forces } } @@ -202,12 +208,12 @@ namespace Kratos const Matrix& rDN_DX, const double rDeltaTime, Vector& rMPStrain, - Matrix& rDeformationGradient, + Matrix& rDeformationGradientIncrement, const bool& isCompressible) { KRATOS_TRY - const SizeType dimension = rGeom.WorkingSpaceDimension(); + const SizeType dimension = rGeom.WorkingSpaceDimension(); const SizeType number_of_nodes = rGeom.PointsNumber(); @@ -226,7 +232,6 @@ namespace Kratos } } - //Calculate rate of deformation and spin tensors Matrix rateOfDeformation = 0.5 * (velocityGradient + trans(velocityGradient)); Matrix spinTensor = velocityGradient - rateOfDeformation; @@ -242,14 +247,34 @@ namespace Kratos rMPStrain(1) += jaumannRate(1, 1) * rDeltaTime; //e_yy rMPStrain(2) += 2.0 * jaumannRate(0, 1) * rDeltaTime; //e_xy + if (dimension == 3) + { + KRATOS_ERROR << "NOT IMPLEMENTED YET"; + } // Model compressibility + rDeformationGradientIncrement = IdentityMatrix(dimension, dimension); if (isCompressible) { - Matrix I = IdentityMatrix(dimension); - Matrix updatedDeformationGradient = prod((I + rDeltaTime * velocityGradient), - rDeformationGradient); - rDeformationGradient = updatedDeformationGradient; + Matrix strainIncrement = ZeroMatrix(dimension, dimension); + + strainIncrement(0, 0) = rMPStrain(0); + strainIncrement(1, 1) = rMPStrain(1); + strainIncrement(0, 1) = rMPStrain(2) / 2.0; + strainIncrement(1, 0) = rMPStrain(2) / 2.0; + + if (dimension == 3) + { + strainIncrement(2, 2) = rMPStrain(0); + strainIncrement(0, 0) = rMPStrain(0); + strainIncrement(0, 0) = rMPStrain(0); + strainIncrement(0, 0) = rMPStrain(0); + strainIncrement(0, 0) = rMPStrain(0); + strainIncrement(0, 0) = rMPStrain(0); + KRATOS_ERROR << "NOT IMPLEMENTED YET"; + } + + rDeformationGradientIncrement += strainIncrement; } KRATOS_CATCH("") From 7deb1ca200fe713320ca941e5fb9617353363e53 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Thu, 2 Apr 2020 14:55:59 +1000 Subject: [PATCH 040/314] extend to 3D --- .../mpm_explicit_utilities.cpp | 105 ++++++++++++------ 1 file changed, 68 insertions(+), 37 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp index 92e0fb69cdcb..561c68b85290 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp @@ -30,37 +30,56 @@ namespace Kratos const unsigned int dimension = rGeom.WorkingSpaceDimension(); const unsigned int number_of_nodes = rGeom.PointsNumber(); - array_1d nodal_force_internal_normal = ZeroVector(3); //PJW, needed for explicit force + array_1d nodal_force_internal_normal = ZeroVector(3); // Add in explicit internal force calculation (Fint = Volume*divergence(sigma)) - // TODO extend to 3D + // Refer to link for notation https://github.com/KratosMultiphysics/Kratos/wiki/How-to-use-the-Constitutive-Law-class for (unsigned int i = 0; i < number_of_nodes; i++) { - //f_x = V*(s_xx*dNdX + s_xy*dNdY) - nodal_force_internal_normal[0] = rMPVolume * - (rMPStress[0] * rDN_DX(i, 0) + - rMPStress[2] * rDN_DX(i, 1)); + // f_i = V * Sum_j [s_ij N_,j] + if (dimension == 2) + { + // StressVec = s00 s11 s01 + // Index 0 1 2 - //f_x = V*(s_yy*dNdX + s_xy*dNdX) - nodal_force_internal_normal[1] = rMPVolume * - (rMPStress[1] * rDN_DX(i, 1) + - rMPStress[2] * rDN_DX(i, 0)); + //f_x = V*(s_xx*dNdX + s_xy*dNdY) + nodal_force_internal_normal[0] = rMPVolume * + (rMPStress[0] * rDN_DX(i, 0) + + rMPStress[2] * rDN_DX(i, 1)); + //f_y = V*(s_yy*dNdY + s_yx*dNdX) + nodal_force_internal_normal[1] = rMPVolume * + (rMPStress[1] * rDN_DX(i, 1) + + rMPStress[2] * rDN_DX(i, 0)); + } + else + { + // StressVec = s00 s11 s22 s01 s12 s02 + // Index 0 1 2 3 4 5 - rRightHandSideVector[dimension * i] -= nodal_force_internal_normal[0]; //minus sign, internal forces - rRightHandSideVector[dimension * i + 1] -= nodal_force_internal_normal[1]; //minus sign, internal forces + //f_x = V*(s_xx*dNdX + s_xy*dNdY + s_xz*dNdZ) + nodal_force_internal_normal[0] = rMPVolume * + (rMPStress[0] * rDN_DX(i, 0) + + rMPStress[3] * rDN_DX(i, 1) + + rMPStress[5] * rDN_DX(i, 2)); - if (dimension == 3) - { - KRATOS_ERROR << "NOT IMPLEMENTED YET"; - // TODO add in third dimension here - //f_x = V*(s_yy*dNdX + s_xy*dNdX) + //f_y = V*(s_yy*dNdY + s_yx*dNdX + s_yz*dNdZ) nodal_force_internal_normal[1] = rMPVolume * (rMPStress[1] * rDN_DX(i, 1) + - rMPStress[2] * rDN_DX(i, 0)); + rMPStress[3] * rDN_DX(i, 0) + + rMPStress[4] * rDN_DX(i, 2)); + + //f_z = V*(s_zz*dNdZ + s_zx*dNdX + s_zy*dNdY) + nodal_force_internal_normal[2] = rMPVolume * + (rMPStress[2] * rDN_DX(i, 2) + + rMPStress[5] * rDN_DX(i, 0) + + rMPStress[4] * rDN_DX(i, 1)); rRightHandSideVector[dimension * i + 2] -= nodal_force_internal_normal[2]; //minus sign, internal forces } + + rRightHandSideVector[dimension * i] -= nodal_force_internal_normal[0]; //minus sign, internal forces + rRightHandSideVector[dimension * i + 1] -= nodal_force_internal_normal[1]; //minus sign, internal forces } KRATOS_CATCH("") @@ -242,36 +261,48 @@ namespace Kratos (prod(spinTensor, rateOfDeformation)) * rDeltaTime + prod((rateOfDeformation * rDeltaTime), spinTensor); - // TODO extend to 3D rMPStrain(0) += jaumannRate(0, 0) * rDeltaTime; //e_xx rMPStrain(1) += jaumannRate(1, 1) * rDeltaTime; //e_yy - rMPStrain(2) += 2.0 * jaumannRate(0, 1) * rDeltaTime; //e_xy - if (dimension == 3) + if (dimension == 2) { - KRATOS_ERROR << "NOT IMPLEMENTED YET"; - } + rMPStrain(2) += 2.0 * jaumannRate(0, 1) * rDeltaTime; //e_xy + } + else + { + rMPStrain(2) += jaumannRate(2, 2) * rDeltaTime; //e_zz + + rMPStrain(3) += 2.0 * jaumannRate(0, 1) * rDeltaTime; //e_xy + rMPStrain(4) += 2.0 * jaumannRate(1, 2) * rDeltaTime; //e_yz + rMPStrain(5) += 2.0 * jaumannRate(0, 2) * rDeltaTime; //e_xz + } // Model compressibility - rDeformationGradientIncrement = IdentityMatrix(dimension, dimension); + rDeformationGradientIncrement = IdentityMatrix(dimension); if (isCompressible) { - Matrix strainIncrement = ZeroMatrix(dimension, dimension); + Matrix strainIncrement = ZeroMatrix(dimension); - strainIncrement(0, 0) = rMPStrain(0); - strainIncrement(1, 1) = rMPStrain(1); - strainIncrement(0, 1) = rMPStrain(2) / 2.0; - strainIncrement(1, 0) = rMPStrain(2) / 2.0; + strainIncrement(0, 0) = rMPStrain(0); //e_xx + strainIncrement(1, 1) = rMPStrain(1); //e_yy - if (dimension == 3) + if (dimension == 2) + { + strainIncrement(0, 1) = rMPStrain(2) / 2.0; //e_xy + strainIncrement(1, 0) = rMPStrain(2) / 2.0; //e_yx + } + else { - strainIncrement(2, 2) = rMPStrain(0); - strainIncrement(0, 0) = rMPStrain(0); - strainIncrement(0, 0) = rMPStrain(0); - strainIncrement(0, 0) = rMPStrain(0); - strainIncrement(0, 0) = rMPStrain(0); - strainIncrement(0, 0) = rMPStrain(0); - KRATOS_ERROR << "NOT IMPLEMENTED YET"; + strainIncrement(2, 2) = rMPStrain(2); //e_zz + + strainIncrement(0, 1) = rMPStrain(3) / 2.0; //e_xy + strainIncrement(1, 0) = rMPStrain(3) / 2.0; //e_yx + + strainIncrement(1, 2) = rMPStrain(4) / 2.0; //e_yz + strainIncrement(2, 1) = rMPStrain(4) / 2.0; //e_zy + + strainIncrement(0, 2) = rMPStrain(5) / 2.0; //e_xz + strainIncrement(2, 0) = rMPStrain(5) / 2.0; //e_zx } rDeformationGradientIncrement += strainIncrement; From 2a33ec678c5fe06f8cd684c4ad7e45da6fa24ee6 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Thu, 2 Apr 2020 16:44:58 +1000 Subject: [PATCH 041/314] fix for explicit mp's that lie exactly on element edges --- .../mpm_search_element_utility.h | 44 +++++++++++++++++-- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h b/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h index f4c1c3f4ad86..8ff699eac0ba 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h @@ -47,8 +47,11 @@ namespace MPMSearchElementUtility void SearchElement(ModelPart& rBackgroundGridModelPart, ModelPart& rMPMModelPart, const std::size_t MaxNumberOfResults, const double Tolerance) { + ProcessInfo& rProcessInfo = rBackgroundGridModelPart.GetProcessInfo(); + bool isExplicit = rProcessInfo.GetValue(IS_EXPLICIT); + // Reset elements to inactive -#pragma omp parallel for + #pragma omp parallel for for (int i = 0; i < static_cast(rBackgroundGridModelPart.Elements().size()); ++i) { auto element_itr = rBackgroundGridModelPart.Elements().begin() + i; auto& r_geometry = element_itr->GetGeometry(); @@ -58,7 +61,7 @@ namespace MPMSearchElementUtility r_geometry[j].Reset(ACTIVE); } - + // Search background grid and make element active Vector N; const int max_result = 1000; @@ -85,6 +88,42 @@ namespace MPMSearchElementUtility // FindPointOnMesh find the background element in which a given point falls and the relative shape functions bool is_found = SearchStructure.FindPointOnMesh(xg[0], N, pelem, result_begin, MaxNumberOfResults, Tolerance); + + if (is_found && isExplicit) { + // check if MP is exactly on the edge of the element, this gives spurious strains in explicit + bool isOnEdge = false; + for (SizeType i = 0; i < N.size(); ++i) { + if (abs(N[i]) < std::numeric_limits::epsilon()) { + isOnEdge = true; + break; + } + } + if (isOnEdge) { + // MP is exactly on the edge. Now we give it a little 'nudge' + array_1d xg_nudged = array_1d(xg[0]); + const double& delta_time = rProcessInfo[DELTA_TIME]; + std::vector> mp_vel; + element_itr->CalculateOnIntegrationPoints(MP_VELOCITY, mp_vel, rMPMModelPart.GetProcessInfo()); + array_1d nudge_displacement = delta_time / 1000.0 * mp_vel[0]; + xg_nudged += nudge_displacement; + is_found = SearchStructure.FindPointOnMesh(xg_nudged, N, pelem, result_begin, MaxNumberOfResults, Tolerance); + // check if the nudged point is found... + if (is_found){ + // store the nudged MP position + element_itr->SetValuesOnIntegrationPoints(MP_COORD, { xg_nudged }, rMPMModelPart.GetProcessInfo()); + KRATOS_INFO("MPMSearchElementUtility") << "WARNING: To prevent spurious explicit stresses, Material Point " << element_itr->Id() + << " was nudged by " << nudge_displacement << std::endl; + } + else { + // find the un-nudged MP again + is_found = SearchStructure.FindPointOnMesh(xg[0], N, pelem, result_begin, MaxNumberOfResults, Tolerance); + KRATOS_INFO("MPMSearchElementUtility") << "WARNING: Material Point " << element_itr->Id() + << " lies exactly on an element edge and may give spurious results."<< std::endl; + } + } + } + + if (is_found == true) { pelem->Set(ACTIVE); element_itr->GetGeometry() = pelem->GetGeometry(); @@ -141,7 +180,6 @@ namespace MPMSearchElementUtility } } } - } // end namespace MPMSearchElementUtility } // end namespace Kratos From 388e7322841edff83585ca72714a5ff5d802b839 Mon Sep 17 00:00:00 2001 From: pooyan Date: Thu, 2 Apr 2020 18:49:27 +0200 Subject: [PATCH 042/314] Adding source and hash key methods --- kratos/containers/variable_data.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/kratos/containers/variable_data.h b/kratos/containers/variable_data.h index c311a9c867d2..e82d69f3c3fa 100644 --- a/kratos/containers/variable_data.h +++ b/kratos/containers/variable_data.h @@ -177,13 +177,23 @@ class KRATOS_API(KRATOS_CORE) VariableData ///@name Access ///@{ - KeyType Key() const + KeyType HashKey() const { KeyType key = mKey;// >> 8; key &= 0xFFFFFFFF00; return key; } + KeyType Key() const + { + return mKey; + } + + KeyType SourceKey() const + { + return mpSourceVariable->mKey; + } + /// NOTE: This function is for internal use and not /// to change arbitrary any variable's key void SetKey(KeyType NewKey); From b69de09b0192f10a84ed5eb5992c1648ea2b85ca Mon Sep 17 00:00:00 2001 From: pooyan Date: Thu, 2 Apr 2020 18:50:15 +0200 Subject: [PATCH 043/314] Pointing source variable to this --- kratos/containers/variable_data.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kratos/containers/variable_data.cpp b/kratos/containers/variable_data.cpp index 70d8fee74c0a..2eee261bf6a2 100644 --- a/kratos/containers/variable_data.cpp +++ b/kratos/containers/variable_data.cpp @@ -29,7 +29,7 @@ namespace Kratos { /// Constructor for variables. - VariableData::VariableData(const std::string& NewName, std::size_t NewSize) : mName(NewName), mKey(0), mSize(NewSize), mpSourceVariable(nullptr), mIsComponent(false) { + VariableData::VariableData(const std::string& NewName, std::size_t NewSize) : mName(NewName), mKey(0), mSize(NewSize), mpSourceVariable(this), mIsComponent(false) { mKey = GenerateKey(mName, mSize, mIsComponent, 0); } From 46b47543b5aac2eab461790b873f3f65a17c4bef Mon Sep 17 00:00:00 2001 From: pooyan Date: Thu, 2 Apr 2020 18:51:09 +0200 Subject: [PATCH 044/314] changing components to variables --- .../residual_based_bdf_custom_scheme.h | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/kratos/solving_strategies/schemes/residual_based_bdf_custom_scheme.h b/kratos/solving_strategies/schemes/residual_based_bdf_custom_scheme.h index bea70267d82d..a61abc1caad0 100644 --- a/kratos/solving_strategies/schemes/residual_based_bdf_custom_scheme.h +++ b/kratos/solving_strategies/schemes/residual_based_bdf_custom_scheme.h @@ -203,9 +203,9 @@ class ResidualBasedBDFCustomScheme first_derivative_name.substr(0, first_derivative_name.size() - 2); std::string second_derivative_name = (*(mSecondArrayDerivatives.begin() + 2 * i))->Name(); second_derivative_name.substr(0, second_derivative_name.size() - 2); - mArrayVariable.push_back(&KratosComponents< VariableComponent>::Get(variable_name + "_Z")); - mFirstArrayDerivatives.push_back(&KratosComponents< VariableComponent>::Get(first_derivative_name + "_Z")); - mSecondArrayDerivatives.push_back(&KratosComponents< VariableComponent>::Get(second_derivative_name + "_Z")); + mArrayVariable.push_back(&KratosComponents< Variable>::Get(variable_name + "_Z")); + mFirstArrayDerivatives.push_back(&KratosComponents< Variable>::Get(first_derivative_name + "_Z")); + mSecondArrayDerivatives.push_back(&KratosComponents< Variable>::Get(second_derivative_name + "_Z")); } } else { KRATOS_ERROR << "DOMAIN_SIZE can onbly be 2 or 3. It is: " << domain_size << std::endl; @@ -467,9 +467,9 @@ class ResidualBasedBDFCustomScheme std::vector*> mDoubleVariable; /// The double variables std::vector*> mFirstDoubleDerivatives; /// The first derivative double variable to compute std::vector*> mSecondDoubleDerivatives; /// The second derivative double variable to compute - std::vector*> mArrayVariable; /// The array variables to compute - std::vector*> mFirstArrayDerivatives; /// The first derivative array variable to compute - std::vector*> mSecondArrayDerivatives; /// The second derivative array variable to compute + std::vector*> mArrayVariable; /// The array variables to compute + std::vector*> mFirstArrayDerivatives; /// The first derivative array variable to compute + std::vector*> mSecondArrayDerivatives; /// The second derivative array variable to compute ///@} ///@name Protected Operators @@ -638,20 +638,20 @@ class ResidualBasedBDFCustomScheme mSecondDoubleDerivatives.push_back(&KratosComponents>::Get(second_derivative_name)); } else if (KratosComponents< Variable< array_1d< double, 3> > >::Has(variable_name)) { // Components - mArrayVariable.push_back(&KratosComponents< VariableComponent>::Get(variable_name+"_X")); - mArrayVariable.push_back(&KratosComponents< VariableComponent>::Get(variable_name+"_Y")); + mArrayVariable.push_back(&KratosComponents< Variable>::Get(variable_name+"_X")); + mArrayVariable.push_back(&KratosComponents< Variable>::Get(variable_name+"_Y")); if (mDomainSize == 3) - mArrayVariable.push_back(&KratosComponents< VariableComponent>::Get(variable_name+"_Z")); + mArrayVariable.push_back(&KratosComponents< Variable>::Get(variable_name+"_Z")); - mFirstArrayDerivatives.push_back(&KratosComponents< VariableComponent>::Get(first_derivative_name+"_X")); - mFirstArrayDerivatives.push_back(&KratosComponents< VariableComponent>::Get(first_derivative_name+"_Y")); + mFirstArrayDerivatives.push_back(&KratosComponents< Variable>::Get(first_derivative_name+"_X")); + mFirstArrayDerivatives.push_back(&KratosComponents< Variable>::Get(first_derivative_name+"_Y")); if (mDomainSize == 3) - mFirstArrayDerivatives.push_back(&KratosComponents< VariableComponent>::Get(first_derivative_name+"_Z")); + mFirstArrayDerivatives.push_back(&KratosComponents< Variable>::Get(first_derivative_name+"_Z")); - mSecondArrayDerivatives.push_back(&KratosComponents< VariableComponent>::Get(second_derivative_name+"_X")); - mSecondArrayDerivatives.push_back(&KratosComponents< VariableComponent>::Get(second_derivative_name+"_Y")); + mSecondArrayDerivatives.push_back(&KratosComponents< Variable>::Get(second_derivative_name+"_X")); + mSecondArrayDerivatives.push_back(&KratosComponents< Variable>::Get(second_derivative_name+"_Y")); if (mDomainSize == 3) - mSecondArrayDerivatives.push_back(&KratosComponents< VariableComponent>::Get(second_derivative_name+"_Z")); + mSecondArrayDerivatives.push_back(&KratosComponents< Variable>::Get(second_derivative_name+"_Z")); } else { KRATOS_ERROR << "Only double and vector variables are allowed in the variables list." ; } From 3e8b94e503d51e2a53c4c88411228bc506c0ded2 Mon Sep 17 00:00:00 2001 From: pooyan Date: Thu, 2 Apr 2020 18:51:25 +0200 Subject: [PATCH 045/314] Adding tests for variables list --- .../containers/test_variables_list.cpp | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 kratos/tests/cpp_tests/containers/test_variables_list.cpp diff --git a/kratos/tests/cpp_tests/containers/test_variables_list.cpp b/kratos/tests/cpp_tests/containers/test_variables_list.cpp new file mode 100644 index 000000000000..b726ebd73ae5 --- /dev/null +++ b/kratos/tests/cpp_tests/containers/test_variables_list.cpp @@ -0,0 +1,62 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ ` +// _|\_\_| \__,_|\__|\___/ ____/ +// Multi-Physics +// +// License: BSD License +// Kratos default license: +// kratos/license.txt +// +// Main authors: Pooyan Dadvand +// +// + +// System includes +#include + +// External includes + +// Project includes +#include "containers/variables_list_data_value_container.h" +#include "includes/variables.h" +#include "testing/testing.h" + +namespace Kratos { +namespace Testing { + +KRATOS_TEST_CASE_IN_SUITE(VariablesListHas, KratosCoreFastSuite) { + VariablesList variables_list; + variables_list.Add(NODAL_AREA); + variables_list.Add(VELOCITY); + + + KRATOS_CHECK(variables_list.Has(NODAL_AREA)); + KRATOS_CHECK(variables_list.Has(VELOCITY)); + KRATOS_CHECK_IS_FALSE(variables_list.Has(DISPLACEMENT)); +} + +KRATOS_TEST_CASE_IN_SUITE(VariablesListHasComponent, KratosCoreFastSuite) { + VariablesList variables_list; + variables_list.Add(DISPLACEMENT); + + KRATOS_CHECK_IS_FALSE(variables_list.Has(VELOCITY_X)); + KRATOS_CHECK_IS_FALSE(variables_list.Has(VELOCITY_Y)); + KRATOS_CHECK_IS_FALSE(variables_list.Has(VELOCITY_Z)); + + KRATOS_CHECK(variables_list.Has(DISPLACEMENT_X)); + KRATOS_CHECK(variables_list.Has(DISPLACEMENT_Y)); + KRATOS_CHECK(variables_list.Has(DISPLACEMENT_Z)); +} + + +KRATOS_TEST_CASE_IN_SUITE(VariablesListGetDofInfo, KratosCoreFastSuite) { + VariablesList variables_list; + auto dof_index = variables_list.AddDof(&DISPLACEMENT_Y, &REACTION_Y); + KRATOS_CHECK_EQUAL(variables_list.GetDofVariable(dof_index), DISPLACEMENT_Y); + KRATOS_CHECK_EQUAL(variables_list.pGetDofReaction(dof_index), &REACTION_Y); + +} + +} +} // namespace Kratos. From a54bfc2c600095ca69c37f0cb80b4e52b29e9c7e Mon Sep 17 00:00:00 2001 From: pooyan Date: Thu, 2 Apr 2020 18:51:53 +0200 Subject: [PATCH 046/314] Using source key instead of key --- kratos/containers/variables_list.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/kratos/containers/variables_list.h b/kratos/containers/variables_list.h index e49e553b978b..eae7e42b3bc2 100644 --- a/kratos/containers/variables_list.h +++ b/kratos/containers/variables_list.h @@ -143,7 +143,7 @@ namespace Kratos template IndexType operator()(Variable const& ThisVariable) const { - return GetPosition(ThisVariable.Key()); + return GetPosition(ThisVariable.SourceKey()); } const VariableData* operator[](IndexType Index) const @@ -263,7 +263,7 @@ namespace Kratos void Add(VariableData const& ThisVariable) { - if (ThisVariable.Key() == 0) + if (ThisVariable.SourceKey() == 0) KRATOS_THROW_ERROR(std::logic_error, "Adding uninitialize variable to this variable list. Check if all variables are registered before kernel initialization", ""); @@ -276,7 +276,7 @@ namespace Kratos } mVariables.push_back(&ThisVariable); - SetPosition(ThisVariable.Key(), mDataSize); + SetPosition(ThisVariable.SourceKey(), mDataSize); const SizeType block_size = sizeof(BlockType); mDataSize += static_cast(((block_size - 1) + ThisVariable.Size()) / block_size); } @@ -335,20 +335,20 @@ namespace Kratos mDofReactions[DofIndex] = pThisDofReaction; } - IndexType Index(IndexType VariableKey) const - { - return GetPosition(VariableKey); - } + // IndexType Index(IndexType VariableKey) const + // { + // return GetPosition(VariableKey); + // } template IndexType Index(Variable const& ThisVariable) const { - return GetPosition(ThisVariable.Key()); + return GetPosition(ThisVariable.SourceKey()); } IndexType Index(const VariableData* pThisVariable) const { - return GetPosition(pThisVariable->Key()); + return GetPosition(pThisVariable->SourceKey()); } @@ -380,10 +380,10 @@ namespace Kratos if (mPositions.empty()) return false; - if (rThisVariable.Key() == 0) + if (rThisVariable.SourceKey() == 0) return false; - return mKeys[GetHashIndex(rThisVariable.Key(), mKeys.size(), mHashFunctionIndex)] == rThisVariable.Key(); + return mKeys[GetHashIndex(rThisVariable.SourceKey(), mKeys.size(), mHashFunctionIndex)] == rThisVariable.SourceKey(); } bool IsEmpty() const @@ -498,9 +498,9 @@ namespace Kratos size_is_ok = true; for (auto i_variable = mVariables.begin(); i_variable != mVariables.end(); i_variable++) - if (new_positions[GetHashIndex((*i_variable)->Key(), new_size, new_hash_function_index)] > mDataSize) { - new_positions[GetHashIndex((*i_variable)->Key(), new_size, new_hash_function_index)] = mPositions[GetHashIndex((*i_variable)->Key(), mPositions.size(), mHashFunctionIndex)]; - new_keys[GetHashIndex((*i_variable)->Key(), new_size, new_hash_function_index)] = (*i_variable)->Key(); + if (new_positions[GetHashIndex((*i_variable)->SourceKey(), new_size, new_hash_function_index)] > mDataSize) { + new_positions[GetHashIndex((*i_variable)->SourceKey(), new_size, new_hash_function_index)] = mPositions[GetHashIndex((*i_variable)->SourceKey(), mPositions.size(), mHashFunctionIndex)]; + new_keys[GetHashIndex((*i_variable)->SourceKey(), new_size, new_hash_function_index)] = (*i_variable)->SourceKey(); } else { size_is_ok = false; From 47c17142de47474f5150379a78d218d8b21b36ef Mon Sep 17 00:00:00 2001 From: pooyan Date: Thu, 2 Apr 2020 19:03:45 +0200 Subject: [PATCH 047/314] Using source key in data value container --- kratos/containers/data_value_container.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/kratos/containers/data_value_container.h b/kratos/containers/data_value_container.h index cf7a28f5ad30..512781081510 100644 --- a/kratos/containers/data_value_container.h +++ b/kratos/containers/data_value_container.h @@ -211,7 +211,7 @@ class KRATOS_API(KRATOS_CORE) DataValueContainer #endif typename ContainerType::iterator i; - if ((i = std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.Key()))) != mData.end()) + if ((i = std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.SourceKey()))) != mData.end()) return *(static_cast(i->second) + rThisVariable.GetComponentIndex()); #ifdef KRATOS_DEBUG @@ -233,7 +233,7 @@ class KRATOS_API(KRATOS_CORE) DataValueContainer typename ContainerType::const_iterator i; - if ((i = std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.Key()))) != mData.end()) + if ((i = std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.SourceKey()))) != mData.end()) return *(static_cast(i->second) + rThisVariable.GetComponentIndex()); return rThisVariable.Zero(); @@ -261,7 +261,7 @@ class KRATOS_API(KRATOS_CORE) DataValueContainer #endif typename ContainerType::iterator i; - if ((i = std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.Key()))) != mData.end()) + if ((i = std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.SourceKey()))) != mData.end()) *(static_cast(i->second) + rThisVariable.GetComponentIndex()) = rValue; else mData.push_back(ValueType(&rThisVariable,new TDataType(rValue))); @@ -276,7 +276,7 @@ class KRATOS_API(KRATOS_CORE) DataValueContainer { typename ContainerType::iterator i; - if ((i = std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.Key()))) != mData.end()) + if ((i = std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.SourceKey()))) != mData.end()) { i->first->Delete(i->second); mData.erase(i); @@ -304,12 +304,12 @@ class KRATOS_API(KRATOS_CORE) DataValueContainer template bool Has(const Variable& rThisVariable) const { - return (std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.Key())) != mData.end()); + return (std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.SourceKey())) != mData.end()); } template bool Has(const VariableComponent& rThisVariable) const { - return (std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.GetSourceVariable().Key())) != mData.end()); + return (std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.GetSourceVariable().SourceKey())) != mData.end()); } bool IsEmpty() const @@ -397,7 +397,7 @@ class KRATOS_API(KRATOS_CORE) DataValueContainer explicit IndexCheck(std::size_t I) : mI(I) {} bool operator()(const ValueType& I) { - return I.first->Key() == mI; + return I.first->SourceKey() == mI; } }; From 86611cf9cd981d3cd39792a2092ea6e18d8f6782 Mon Sep 17 00:00:00 2001 From: pooyan Date: Thu, 2 Apr 2020 19:04:27 +0200 Subject: [PATCH 048/314] Using source key in variables list data container --- kratos/containers/variables_list_data_value_container.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kratos/containers/variables_list_data_value_container.h b/kratos/containers/variables_list_data_value_container.h index d192e7088c6e..fd62c5efbd03 100644 --- a/kratos/containers/variables_list_data_value_container.h +++ b/kratos/containers/variables_list_data_value_container.h @@ -1021,14 +1021,14 @@ class KRATOS_API(KRATOS_CORE) VariablesListDataValueContainer inline SizeType LocalOffset(VariableData const & rThisVariable) const { KRATOS_DEBUG_ERROR_IF(!mpVariablesList) << "This container don't have a variables list assigned. A possible reason is creating a node without a model part." << std::endl; - return mpVariablesList->Index(rThisVariable); + return mpVariablesList->Index(rThisVariable.SourceKey()); } inline BlockType* Position(VariableData const & rThisVariable) const { KRATOS_DEBUG_ERROR_IF(!mpVariablesList) << "This container don't have a variables list assigned. A possible reason is creating a node without a model part." << std::endl; KRATOS_DEBUG_ERROR_IF_NOT(mpVariablesList->Has(rThisVariable)) << "This container only can store the variables specified in its variables list. The variables list doesn't have this variable:" << rThisVariable << std::endl; - return mpCurrentPosition + mpVariablesList->Index(rThisVariable); + return mpCurrentPosition + mpVariablesList->Index(rThisVariable.SourceKey()); } inline BlockType* Position(VariableData const & rThisVariable, SizeType ThisIndex) const @@ -1036,7 +1036,7 @@ class KRATOS_API(KRATOS_CORE) VariablesListDataValueContainer KRATOS_DEBUG_ERROR_IF(!mpVariablesList) << "This container don't have a variables list assigned. A possible reason is creating a node without a model part." << std::endl; KRATOS_DEBUG_ERROR_IF_NOT(mpVariablesList->Has(rThisVariable)) << "This container only can store the variables specified in its variables list. The variables list doesn't have this variable:" << rThisVariable << std::endl; KRATOS_DEBUG_ERROR_IF((ThisIndex + 1) > mQueueSize) << "Trying to access data from step " << ThisIndex << " but only " << mQueueSize << " steps are stored." << std::endl; - return Position(ThisIndex) + mpVariablesList->Index(rThisVariable); + return Position(ThisIndex) + mpVariablesList->Index(rThisVariable.SourceKey()); } inline BlockType* Position() const From a85236d7a3ade839c5035ecd7a1c8809e9672885 Mon Sep 17 00:00:00 2001 From: pooyan Date: Thu, 2 Apr 2020 19:04:46 +0200 Subject: [PATCH 049/314] Uncommenting the index method --- kratos/containers/variables_list.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kratos/containers/variables_list.h b/kratos/containers/variables_list.h index eae7e42b3bc2..19286fc5f48c 100644 --- a/kratos/containers/variables_list.h +++ b/kratos/containers/variables_list.h @@ -335,10 +335,10 @@ namespace Kratos mDofReactions[DofIndex] = pThisDofReaction; } - // IndexType Index(IndexType VariableKey) const - // { - // return GetPosition(VariableKey); - // } + IndexType Index(IndexType VariableKey) const + { + return GetPosition(VariableKey); + } template IndexType Index(Variable const& ThisVariable) const From 15d3d63c7bb063a2880e4154ce9ae76ef3c40458 Mon Sep 17 00:00:00 2001 From: pooyan Date: Thu, 2 Apr 2020 19:05:17 +0200 Subject: [PATCH 050/314] Removing get value test --- kratos/tests/cpp_tests/containers/test_variables.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/kratos/tests/cpp_tests/containers/test_variables.cpp b/kratos/tests/cpp_tests/containers/test_variables.cpp index 144ada8d9946..880b9ea9c2a4 100644 --- a/kratos/tests/cpp_tests/containers/test_variables.cpp +++ b/kratos/tests/cpp_tests/containers/test_variables.cpp @@ -58,17 +58,7 @@ KRATOS_TEST_CASE_IN_SUITE(VariablesKeyOrder, KratosCoreFastSuite) { } } - KRATOS_TEST_CASE_IN_SUITE(VariableComponent, KratosCoreFastSuite) { - KRATOS_CHECK_EQUAL(DISPLACEMENT_X.GetSourceVariable(), DISPLACEMENT); - array_1d displacement = ZeroVector(3); - displacement[0] = 1.2; - displacement[1] = 2.3; - displacement[2] = 3.4; - KRATOS_CHECK_EQUAL(DISPLACEMENT_X.GetValue(displacement), 1.2); - KRATOS_CHECK_EQUAL(DISPLACEMENT_Y.GetValue(displacement), 2.3); - KRATOS_CHECK_EQUAL(DISPLACEMENT_Z.GetValue(displacement), 3.4); - } } From 7d8b01d74ca477bd9b20cbdd7e72a0741a8b6766 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Fri, 3 Apr 2020 10:14:50 +1000 Subject: [PATCH 051/314] fix MUSL comments --- .../custom_elements/updated_lagrangian_quadrilateral.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index 787abde60482..112d5135a52f 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -1088,8 +1088,7 @@ void UpdatedLagrangianQuadrilateral::FinalizeExplicitSolutionStep(ProcessInfo& r } else { - // MUSL velocity field has already been computed. Therefore do not calculate stresses this time - // and the nodal velocities are already updated. + // MUSL velocity field has already been computed. Therefore only calculate stresses this time. mapGridToParticles = false; } } From 1196b12c0fce7eb4c9db0567dda3be16fb1ccd8a Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Fri, 3 Apr 2020 12:10:03 +1000 Subject: [PATCH 052/314] print explicit scheme info to console --- .../schemes/mpm_explicit_scheme.hpp | 33 ++++++++++--------- .../strategies/mpm_explicit_strategy.hpp | 2 -- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp index 8fc6fd6e9aa7..bc18d76cb7db 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp @@ -129,25 +129,28 @@ namespace Kratos { mStressUpdateOption(StressUpdateOption), mIsCentralDifference(isCentralDifference) { - //mStressUpdateOption = StressUpdateOption; // 0 = USF, 1 = USL, 2 = MUSL - //mIsCentralDifference = isCentralDifference; - - std::cout << "\n\n =========================== USING MPM EXPLICIT ========================== \n\n" << std::endl; - if (mIsCentralDifference) - { - std::cout << "\n\n =========================== CENTRAL DIFFERENCE ========================== \n\n" << std::endl; + std::cout << "Initializing MPM "; + if (mIsCentralDifference){ + std::cout << "central difference"; } - else - { - if (mStressUpdateOption < 3 && mStressUpdateOption > -1) - { - std::cout << "\n\n =========================== FORWARD EULER ========================== \n\n" << std::endl; - } - else - { + else{ + std::cout << "forward Euler ("; + switch (mStressUpdateOption){ + case 0: + std::cout << "USF)"; + break; + case 1: + std::cout << "USL)"; + break; + case 2: + std::cout << "MUSL)"; + break; + default: KRATOS_ERROR << "Invalid MPM explicit scheme constructed." << std::endl; + break; } } + std::cout << " explicit time integration scheme " << std::endl; } /** Destructor. diff --git a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp index 5b673096230c..67f107645ca9 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp @@ -124,8 +124,6 @@ namespace Kratos { KRATOS_TRY - std::cout << "\n\n MPMExplicitStrategy MADE SS \n\n" << std::endl; - mKeepSystemConstantDuringIterations = false; // Set flags to start correcty the calculations From 7426e17526912b9eab66dafbadaaff40930bd031 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Fri, 3 Apr 2020 14:07:18 +1000 Subject: [PATCH 053/314] use node ACTIVE flag and remove added IS_ACTIVE_MPM_EXPLICIT_NODE --- .../custom_elements/updated_lagrangian_quadrilateral.cpp | 1 - .../custom_python/particle_mechanics_python_application.cpp | 1 - .../custom_strategies/schemes/mpm_explicit_scheme.hpp | 5 ++--- .../custom_utilities/mpm_search_element_utility.h | 2 +- .../particle_mechanics_application.cpp | 1 - .../particle_mechanics_application_variables.cpp | 1 - .../particle_mechanics_application_variables.h | 1 - .../python_scripts/mpm_explicit_solver.py | 1 - 8 files changed, 3 insertions(+), 10 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index 112d5135a52f..ab2b29f958da 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -967,7 +967,6 @@ void UpdatedLagrangianQuadrilateral::InitializeSolutionStep( ProcessInfo& rCurre r_geometry[i].SetLock(); - r_geometry[i].FastGetSolutionStepValue(IS_ACTIVE_MPM_EXPLICIT_NODE, 0) = true; r_geometry[i].FastGetSolutionStepValue(NODAL_MOMENTUM, 0) += nodal_momentum; r_geometry[i].FastGetSolutionStepValue(NODAL_INERTIA, 0) += nodal_inertia; diff --git a/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp b/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp index 10481352892a..38b4922e2c26 100644 --- a/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp +++ b/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp @@ -161,7 +161,6 @@ namespace Python{ KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, MUSL_VELOCITY_FIELD_IS_COMPUTED); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, IS_EXPLICIT); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, IS_EXPLICIT_CENTRAL_DIFFERENCE); - KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, IS_ACTIVE_MPM_EXPLICIT_NODE); } } // namespace Python. diff --git a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp index bc18d76cb7db..3f4f684f2a1b 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp @@ -277,7 +277,7 @@ namespace Kratos { #pragma omp parallel for schedule(guided,512) for (int i = 0; i < static_cast(r_nodes.size()); ++i) { auto it_node = it_node_begin + i; - if ((it_node)->FastGetSolutionStepValue(IS_ACTIVE_MPM_EXPLICIT_NODE, 0)) + if ((it_node)->Is(ACTIVE)) { // Current step information "N+1" (before step update). this->UpdateTranslationalDegreesOfFreedom(it_node, disppos, dim); @@ -428,7 +428,6 @@ namespace Kratos { for (int iter = 0; iter < static_cast(mr_grid_model_part.Nodes().size()); ++iter) { auto i = mr_grid_model_part.NodesBegin() + iter; - (i)->FastGetSolutionStepValue(IS_ACTIVE_MPM_EXPLICIT_NODE, 0) = false; // Variables to be cleaned double& nodal_mass = (i)->FastGetSolutionStepValue(NODAL_MASS); @@ -473,7 +472,7 @@ namespace Kratos { { auto i = mr_grid_model_part.NodesBegin() + iter; - if ((i)->FastGetSolutionStepValue(IS_ACTIVE_MPM_EXPLICIT_NODE)) + if ((i)->Is(ACTIVE)) { const SizeType DomainSize = CurrentProcessInfo[DOMAIN_SIZE]; double& nodal_mass = (i)->FastGetSolutionStepValue(NODAL_MASS); diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h b/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h index 8ff699eac0ba..deeef01de806 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h @@ -48,7 +48,7 @@ namespace MPMSearchElementUtility const double Tolerance) { ProcessInfo& rProcessInfo = rBackgroundGridModelPart.GetProcessInfo(); - bool isExplicit = rProcessInfo.GetValue(IS_EXPLICIT); + bool isExplicit = rProcessInfo.Has(IS_EXPLICIT); // Reset elements to inactive #pragma omp parallel for diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp b/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp index 59432ed22adc..2522848dc65c 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp @@ -257,7 +257,6 @@ namespace Kratos KRATOS_REGISTER_VARIABLE(MUSL_VELOCITY_FIELD_IS_COMPUTED) KRATOS_REGISTER_VARIABLE(IS_EXPLICIT) KRATOS_REGISTER_VARIABLE(IS_EXPLICIT_CENTRAL_DIFFERENCE) - KRATOS_REGISTER_VARIABLE(IS_ACTIVE_MPM_EXPLICIT_NODE) } } // namespace Kratos. diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp index 376313de24d5..65d01ed20a90 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp @@ -98,5 +98,4 @@ namespace Kratos KRATOS_CREATE_VARIABLE(bool, MUSL_VELOCITY_FIELD_IS_COMPUTED) KRATOS_CREATE_VARIABLE(bool, IS_EXPLICIT) KRATOS_CREATE_VARIABLE(bool, IS_EXPLICIT_CENTRAL_DIFFERENCE) - KRATOS_CREATE_VARIABLE(bool, IS_ACTIVE_MPM_EXPLICIT_NODE) } \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h index ccd60c39d7d5..b86b8955c68a 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h @@ -124,7 +124,6 @@ namespace Kratos KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, MUSL_VELOCITY_FIELD_IS_COMPUTED) KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, IS_EXPLICIT) KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, IS_EXPLICIT_CENTRAL_DIFFERENCE) - KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, IS_ACTIVE_MPM_EXPLICIT_NODE) } #endif // KRATOS_PARTICLE_MECHANICS_APPLICATION_VARIABLES_H_INCLUDED defined \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py b/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py index 2e076e67d74c..4bc1c36148ac 100644 --- a/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py +++ b/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py @@ -38,7 +38,6 @@ def AddVariables(self): # Adding explicit variables grid_model_part.AddNodalSolutionStepVariable(KratosMultiphysics.FORCE_RESIDUAL) grid_model_part.AddNodalSolutionStepVariable(KratosMultiphysics.RESIDUAL_VECTOR) - grid_model_part.AddNodalSolutionStepVariable(KratosParticle.IS_ACTIVE_MPM_EXPLICIT_NODE) scheme_type = self.settings["scheme_type"].GetString() KratosMultiphysics.Logger.PrintInfo("::[MPMExplicitSolver]:: ", "Variables are all added.") From deca9534d002354be61dce20449a44964d863167 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Fri, 3 Apr 2020 14:07:41 +1000 Subject: [PATCH 054/314] add in default time integration settings settings --- .../python_scripts/mpm_explicit_solver.py | 1 + .../ParticleMechanicsApplication/python_scripts/mpm_solver.py | 1 + 2 files changed, 2 insertions(+) diff --git a/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py b/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py index 4bc1c36148ac..a064addeadf3 100644 --- a/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py +++ b/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py @@ -23,6 +23,7 @@ def __init__(self, model, custom_settings): @classmethod def GetDefaultSettings(cls): this_defaults = KratosMultiphysics.Parameters("""{ + "time_integration_method" : "explicit", "scheme_type" : "forward_euler", "stress_update" : "USL" }""") diff --git a/applications/ParticleMechanicsApplication/python_scripts/mpm_solver.py b/applications/ParticleMechanicsApplication/python_scripts/mpm_solver.py index c586201e16c1..dfd1420774cd 100644 --- a/applications/ParticleMechanicsApplication/python_scripts/mpm_solver.py +++ b/applications/ParticleMechanicsApplication/python_scripts/mpm_solver.py @@ -38,6 +38,7 @@ def GetDefaultSettings(cls): "domain_size" : -1, "echo_level" : 0, "time_stepping" : { }, + "time_integration_method" : "implicit", "analysis_type" : "non_linear", "grid_model_import_settings" : { "input_type" : "mdpa", From 6a8267d0007139d40d4e0da31bac9313071c5bcc Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Fri, 3 Apr 2020 14:25:34 +1000 Subject: [PATCH 055/314] all tests run again --- .../updated_lagrangian_quadrilateral.cpp | 49 ++++++++++--------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index ab2b29f958da..aaa00cea78d3 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -304,8 +304,8 @@ void UpdatedLagrangianQuadrilateral::CalculateElementalSystem( LocalSystemCompon if (!mIsExplicit) { - ConstitutiveLawOptions.Set(ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN, true); - ConstitutiveLawOptions.Set(ConstitutiveLaw::COMPUTE_STRESS, true); + ConstitutiveLawOptions.Set(ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN); + ConstitutiveLawOptions.Set(ConstitutiveLaw::COMPUTE_STRESS); // Compute element kinematics B, F, DN_DX ... this->CalculateKinematics(Variables, rCurrentProcessInfo); @@ -985,27 +985,30 @@ void UpdatedLagrangianQuadrilateral::InitializeNonLinearIteration(ProcessInfo& r // This needs to occur after all particles are mapped to the grid, but before the momenta update. KRATOS_TRY - - mIsUSFStressUpdate = true; - - // Create and initialize element variables: - GeneralVariables Variables; - this->InitializeGeneralVariables(Variables, rCurrentProcessInfo); - - // Calculate shape function gradients - Matrix Jacobian; - Jacobian = this->MPMJacobian(Jacobian, mMP.xg); - Matrix InvJ; - double detJ; - MathUtils::InvertMatrix(Jacobian, InvJ, detJ); - Matrix DN_De; - this->MPMShapeFunctionsLocalGradients(DN_De, mMP.xg); // parametric gradients - mDN_DX = prod(DN_De, InvJ); // cartesian gradients - - //calculate stress - this->CalculateExplicitStresses(rCurrentProcessInfo, Variables); - - this->FinalizeStepVariables(Variables, rCurrentProcessInfo); + + if (mIsExplicit) + { + mIsUSFStressUpdate = true; + + // Create and initialize element variables: + GeneralVariables Variables; + this->InitializeGeneralVariables(Variables, rCurrentProcessInfo); + + // Calculate shape function gradients + Matrix Jacobian; + Jacobian = this->MPMJacobian(Jacobian, mMP.xg); + Matrix InvJ; + double detJ; + MathUtils::InvertMatrix(Jacobian, InvJ, detJ); + Matrix DN_De; + this->MPMShapeFunctionsLocalGradients(DN_De, mMP.xg); // parametric gradients + mDN_DX = prod(DN_De, InvJ); // cartesian gradients + + //calculate stress + this->CalculateExplicitStresses(rCurrentProcessInfo, Variables); + + this->FinalizeStepVariables(Variables, rCurrentProcessInfo); + } KRATOS_CATCH("") } From d37724e4d4fb7188ae519f6053ba9da1bb564470 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Fri, 3 Apr 2020 15:41:19 +1000 Subject: [PATCH 056/314] remove unused variables --- .../custom_elements/updated_lagrangian_quadrilateral.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index aaa00cea78d3..844c475f65ef 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -560,8 +560,6 @@ void UpdatedLagrangianQuadrilateral::CalculateAndAddExplicitInternalForces(Vecto KRATOS_TRY GeometryType& r_geometry = GetGeometry(); - const unsigned int dimension = r_geometry.WorkingSpaceDimension(); - const unsigned int number_of_nodes = r_geometry.PointsNumber(); // Calculate shape function gradients Matrix Jacobian; From 5f68a8bd138f31fb8b02c4c64fa8f5fe7d317eda Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Fri, 3 Apr 2020 16:47:50 +1000 Subject: [PATCH 057/314] remove unused code --- .../custom_strategies/strategies/mpm_explicit_strategy.hpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp index 67f107645ca9..d62c2a0089fc 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp @@ -282,13 +282,6 @@ namespace Kratos // Initial operations ... things that are constant over the Solution Step pScheme->InitializeSolutionStep(BaseType::GetModelPart(), mA, mDx, mb); - - if (BaseType::mRebuildLevel > 0) - { - ProcessInfo& r_current_process_info = r_model_part.GetProcessInfo(); - ElementsArrayType& r_elements = r_model_part.Elements(); - const auto it_elem_begin = r_elements.begin(); - } } mSolutionStepIsInitialized = true; From 986ce9839a7a937a735a07e1482269ccc5b3e72b Mon Sep 17 00:00:00 2001 From: Inigo Lopez Date: Fri, 3 Apr 2020 10:37:06 +0200 Subject: [PATCH 058/314] removing unnecessary advanceintime --- .../solver_wrappers/kratos/potential_flow_wrapper.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/potential_flow_wrapper.py b/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/potential_flow_wrapper.py index 749bec3da7c1..8d2365f9f445 100644 --- a/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/potential_flow_wrapper.py +++ b/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/potential_flow_wrapper.py @@ -24,9 +24,6 @@ class PotentialFlowWrapper(kratos_base_wrapper.KratosBaseWrapper): def _CreateAnalysisStage(self): return PotentialFlowAnalysis(self.model, self.project_parameters) - def AdvanceInTime(self, current_time): - return 0.0 - def Predict(self): pass @@ -52,8 +49,8 @@ def SolveSolutionStep(self): ## the next two lines are needed in order to add Wake DoFs to the new Wake Elements Nodes ## and delete the ones that are no longer in the Wake Region. - self._analysis_stage._GetSolver().fluid_solver.solver.Clear() - self._analysis_stage._GetSolver().fluid_solver.solver.InitializeSolutionStep() + self._analysis_stage._GetSolver().Clear() + self._analysis_stage._GetSolver().InitializeSolutionStep() super(PotentialFlowWrapper, self).SolveSolutionStep() From e19080d8c342930267f9000aac80008b2c810187 Mon Sep 17 00:00:00 2001 From: Inigo Lopez Date: Fri, 3 Apr 2020 10:37:17 +0200 Subject: [PATCH 059/314] updating parameters --- .../fsi_sdof_static/naca0012_small_parameters_coupling.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/CoSimulationApplication/tests/fsi_sdof_static/naca0012_small_parameters_coupling.json b/applications/CoSimulationApplication/tests/fsi_sdof_static/naca0012_small_parameters_coupling.json index 3c896faec27a..a524aae74484 100644 --- a/applications/CoSimulationApplication/tests/fsi_sdof_static/naca0012_small_parameters_coupling.json +++ b/applications/CoSimulationApplication/tests/fsi_sdof_static/naca0012_small_parameters_coupling.json @@ -11,7 +11,7 @@ "ale_boundary_parts" : ["Body2D_Body"], "mesh_motion_solver_settings" :{ "solver_type" : "structural_similarity", - "mesh_motion_linear_solver_settings" : { + "linear_solver_settings" : { "solver_type" : "ExternalSolversApplication.super_lu" }, "reform_dofs_each_step" : false, From 4e17df23299c85821b26f67ef87d51535e00e662 Mon Sep 17 00:00:00 2001 From: pooyan Date: Fri, 3 Apr 2020 12:28:44 +0200 Subject: [PATCH 060/314] Adding variable data new methods to python --- kratos/python/add_containers_to_python.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kratos/python/add_containers_to_python.cpp b/kratos/python/add_containers_to_python.cpp index 68d38d6b06d4..dcbde4901e03 100644 --- a/kratos/python/add_containers_to_python.cpp +++ b/kratos/python/add_containers_to_python.cpp @@ -97,6 +97,9 @@ void AddContainersToPython(pybind11::module& m) py::class_(m, "VariableData" ) .def("Name", &VariableData::Name, py::return_value_policy::copy) .def("Key", &VariableData::Key) + .def("GetSourceVariable", &VariableData::GetSourceVariable) + .def("GetComponentIndex()", &VariableData::GetComponentIndex) + .def("IsComponent", &VariableData::IsComponent) .def("__str__", PrintObject) ; From 808d49f7b370ac38291086b9a9af6debda3ee15d Mon Sep 17 00:00:00 2001 From: pooyan Date: Fri, 3 Apr 2020 12:29:55 +0200 Subject: [PATCH 061/314] Fixing type check --- kratos/python_scripts/from_json_check_result_process.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kratos/python_scripts/from_json_check_result_process.py b/kratos/python_scripts/from_json_check_result_process.py index d4e10c2aec75..db9192cbcd6f 100644 --- a/kratos/python_scripts/from_json_check_result_process.py +++ b/kratos/python_scripts/from_json_check_result_process.py @@ -134,7 +134,7 @@ def ExecuteFinalizeSolutionStep(self): self.__check_values(node.Id, "Node", value, value_json, variable_name) # Array variable elif variable_type == "Array": - if (KratosMultiphysics.KratosGlobals.GetVariableType(variable_name + "_X") == "Component"): + if (KratosMultiphysics.KratosGlobals.GetVariableType(variable_name + "_X") == "Double"): for component_index, component in enumerate(["_X", "_Y", "_Z"]): values_json = self.data[node_identifier][variable_name+component] value_json = self.__linear_interpolation(time, input_time_list, values_json) From 62e1132759ef961dc3861d092f38dd353a348156 Mon Sep 17 00:00:00 2001 From: pooyan Date: Fri, 3 Apr 2020 12:30:12 +0200 Subject: [PATCH 062/314] Fixing component check --- kratos/python_scripts/from_json_check_result_process.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kratos/python_scripts/from_json_check_result_process.py b/kratos/python_scripts/from_json_check_result_process.py index db9192cbcd6f..82a1e9f71002 100644 --- a/kratos/python_scripts/from_json_check_result_process.py +++ b/kratos/python_scripts/from_json_check_result_process.py @@ -173,7 +173,7 @@ def ExecuteFinalizeSolutionStep(self): self.__check_values(elem.Id, "Element", value[gp], value_json, variable_name) # Array variable elif variable_type == "Array": - if (KratosMultiphysics.KratosGlobals.GetVariableType(variable_name + "_X") == "Component"): + if (KratosMultiphysics.KratosGlobals.GetVariableType(variable_name + "_X") == "Double"): for gp in range(gauss_point_number): for component_index, component in enumerate(["_X", "_Y", "_Z"]): values_json = self.data["ELEMENT_" + str(elem.Id)][variable_name+component][str(gp)] From 0e1d9dc6c3a07293e49241902c044c8e3528ccdb Mon Sep 17 00:00:00 2001 From: pooyan Date: Fri, 3 Apr 2020 12:30:34 +0200 Subject: [PATCH 063/314] Changing component to scalar --- kratos/tests/test_variable_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kratos/tests/test_variable_utils.py b/kratos/tests/test_variable_utils.py index 9cee97b66499..ddc0597e1e7d 100644 --- a/kratos/tests/test_variable_utils.py +++ b/kratos/tests/test_variable_utils.py @@ -345,8 +345,8 @@ def test_copy_var(self): ##save the variable values KratosMultiphysics.VariableUtils().CopyScalarVar(KratosMultiphysics.VISCOSITY, KratosMultiphysics.DENSITY, model_part.Nodes) - KratosMultiphysics.VariableUtils().CopyComponentVar(KratosMultiphysics.FORCE_X, KratosMultiphysics.REACTION_Y, model_part.Nodes) - KratosMultiphysics.VariableUtils().CopyComponentVar(KratosMultiphysics.FORCE_X, KratosMultiphysics.FORCE_Y, model_part.Nodes) + KratosMultiphysics.VariableUtils().CopyScalarVar(KratosMultiphysics.FORCE_X, KratosMultiphysics.REACTION_Y, model_part.Nodes) + KratosMultiphysics.VariableUtils().CopyScalarVar(KratosMultiphysics.FORCE_X, KratosMultiphysics.FORCE_Y, model_part.Nodes) KratosMultiphysics.VariableUtils().CopyVectorVar(KratosMultiphysics.DISPLACEMENT, KratosMultiphysics.VELOCITY, model_part.Nodes) ##verify the result From 5e9e38401e4d3edeaf324136abf0189526f28174 Mon Sep 17 00:00:00 2001 From: pooyan Date: Fri, 3 Apr 2020 12:32:43 +0200 Subject: [PATCH 064/314] Fixing component checks --- .../python_scripts/particle_from_json_check_result_process.py | 2 +- .../python_scripts/particle_json_output_process.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/applications/ParticleMechanicsApplication/python_scripts/particle_from_json_check_result_process.py b/applications/ParticleMechanicsApplication/python_scripts/particle_from_json_check_result_process.py index 49229711e855..28cf422e25f7 100644 --- a/applications/ParticleMechanicsApplication/python_scripts/particle_from_json_check_result_process.py +++ b/applications/ParticleMechanicsApplication/python_scripts/particle_from_json_check_result_process.py @@ -51,7 +51,7 @@ def ExecuteFinalizeSolutionStep(self): self.assertTrue(isclosethis, msg=(str(value) + " != " + str(value_json) + ", rel_tol = " + str(reltol) + ", abs_tol = " + str(tol) + " : Error checking particle " + str(mp.Id) + " " + variable_name + " results.")) # Array variable elif variable_type == "Array": - if (KratosMultiphysics.KratosGlobals.GetVariableType(variable_name + "_X") == "Component"): + if (KratosMultiphysics.KratosGlobals.GetVariableType(variable_name + "_X") == "Double"): # X-component values_json = self.data["PARTICLE_" + str(mp.Id)][variable_name + "_X"] value_json = self.__linear_interpolation(time, input_time_list, values_json) diff --git a/applications/ParticleMechanicsApplication/python_scripts/particle_json_output_process.py b/applications/ParticleMechanicsApplication/python_scripts/particle_json_output_process.py index 210b76859c3a..a7b9d4869e0e 100644 --- a/applications/ParticleMechanicsApplication/python_scripts/particle_json_output_process.py +++ b/applications/ParticleMechanicsApplication/python_scripts/particle_json_output_process.py @@ -43,7 +43,7 @@ def ExecuteBeforeSolutionLoop(self): if (count == 0): data["RESULTANT"][variable_name] = [] elif variable_type == "Array": - if (KratosMultiphysics.KratosGlobals.GetVariableType(variable_name + "_X") == "Component"): + if (KratosMultiphysics.KratosGlobals.GetVariableType(variable_name + "_X") == "Double"): if (self.resultant_solution == False): data["PARTICLE_" + str(mp.Id)][variable_name + "_X"] = [] data["PARTICLE_" + str(mp.Id)][variable_name + "_Y"] = [] @@ -103,7 +103,7 @@ def ExecuteFinalizeSolutionStep(self): else: data["RESULTANT"][variable_name][-1] += value elif variable_type == "Array": - if (KratosMultiphysics.KratosGlobals.GetVariableType(variable_name + "_X") == "Component"): + if (KratosMultiphysics.KratosGlobals.GetVariableType(variable_name + "_X") == "Double"): if (self.resultant_solution == False): data["PARTICLE_" + str(mp.Id)][variable_name + "_X"].append(value[0]) data["PARTICLE_" + str(mp.Id)][variable_name + "_Y"].append(value[1]) From 11530e1eb9870949800f7783c7357eec7ba794fb Mon Sep 17 00:00:00 2001 From: pooyan Date: Fri, 3 Apr 2020 12:44:35 +0200 Subject: [PATCH 065/314] Changing array_1d 6 components to variables --- kratos/includes/define.h | 48 ++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/kratos/includes/define.h b/kratos/includes/define.h index ae201a1a5d7a..6f7a939c6c66 100644 --- a/kratos/includes/define.h +++ b/kratos/includes/define.h @@ -188,12 +188,12 @@ catch(...) { Block KRATOS_THROW_ERROR(std::runtime_error, "Unknown error", MoreI #endif #define KRATOS_DEFINE_SYMMETRIC_3D_TENSOR_VARIABLE_WITH_COMPONENTS_IMPLEMENTATION(module, name) \ KRATOS_EXPORT_MACRO(module) extern Kratos::Variable > name; \ - KRATOS_EXPORT_MACRO(module) extern Kratos::VariableComponent > > name##_XX;\ - KRATOS_EXPORT_MACRO(module) extern Kratos::VariableComponent > > name##_YY;\ - KRATOS_EXPORT_MACRO(module) extern Kratos::VariableComponent > > name##_ZZ;\ - KRATOS_EXPORT_MACRO(module) extern Kratos::VariableComponent > > name##_XY;\ - KRATOS_EXPORT_MACRO(module) extern Kratos::VariableComponent > > name##_YZ;\ - KRATOS_EXPORT_MACRO(module) extern Kratos::VariableComponent > > name##_XZ; + KRATOS_EXPORT_MACRO(module) extern Kratos::Variable name##_XX;\ + KRATOS_EXPORT_MACRO(module) extern Kratos::Variable name##_YY;\ + KRATOS_EXPORT_MACRO(module) extern Kratos::Variable name##_ZZ;\ + KRATOS_EXPORT_MACRO(module) extern Kratos::Variable name##_XY;\ + KRATOS_EXPORT_MACRO(module) extern Kratos::Variable name##_YZ;\ + KRATOS_EXPORT_MACRO(module) extern Kratos::Variable name##_XZ; #ifdef KRATOS_DEFINE_SYMMETRIC_3D_TENSOR_VARIABLE_WITH_COMPONENTS #undef KRATOS_DEFINE_SYMMETRIC_3D_TENSOR_VARIABLE_WITH_COMPONENTS @@ -206,12 +206,12 @@ catch(...) { Block KRATOS_THROW_ERROR(std::runtime_error, "Unknown error", MoreI #endif #define KRATOS_DEFINE_SYMMETRIC_3D_TENSOR_APPLICATION_VARIABLE_WITH_COMPONENTS(application, name) \ KRATOS_API(application) extern Kratos::Variable > name; \ - KRATOS_API(application) extern Kratos::VariableComponent > > name##_XX;\ - KRATOS_API(application) extern Kratos::VariableComponent > > name##_YY;\ - KRATOS_API(application) extern Kratos::VariableComponent > > name##_ZZ;\ - KRATOS_API(application) extern Kratos::VariableComponent > > name##_XY;\ - KRATOS_API(application) extern Kratos::VariableComponent > > name##_YZ;\ - KRATOS_API(application) extern Kratos::VariableComponent > > name##_XZ; + KRATOS_API(application) extern Kratos::Variable name##_XX;\ + KRATOS_API(application) extern Kratos::Variable name##_YY;\ + KRATOS_API(application) extern Kratos::Variable name##_ZZ;\ + KRATOS_API(application) extern Kratos::Variable name##_XY;\ + KRATOS_API(application) extern Kratos::Variable name##_YZ;\ + KRATOS_API(application) extern Kratos::Variable name##_XZ; #ifdef KRATOS_DEFINE_2D_TENSOR_VARIABLE_WITH_COMPONENTS #undef KRATOS_DEFINE_2D_TENSOR_VARIABLE_WITH_COMPONENTS @@ -335,23 +335,23 @@ catch(...) { Block KRATOS_THROW_ERROR(std::runtime_error, "Unknown error", MoreI #define KRATOS_CREATE_SYMMETRIC_3D_TENSOR_VARIABLE_WITH_THIS_COMPONENTS(name, component1, component2, component3, component4, component5, component6) \ /*const*/ Kratos::Variable > name(#name, Kratos::zero_vector(6)); \ \ - /*const*/ Kratos::VariableComponent > > \ - component1(#component1, #name, 0, Kratos::VectorComponentAdaptor >(name, 0)); \ + /*const*/ Kratos::Variable \ + component1(#component1, &name, 0); \ \ - /*const*/ Kratos::VariableComponent > > \ - component2(#component2, #name, 1, Kratos::VectorComponentAdaptor >(name, 1)); \ + /*const*/ Kratos::Variable \ + component2(#component2, &name, 1); \ \ - /*const*/ Kratos::VariableComponent > > \ - component3(#component3, #name, 2, Kratos::VectorComponentAdaptor >(name, 2)); \ + /*const*/ Kratos::Variable \ + component3(#component3, &name, 2); \ \ - /*const*/ Kratos::VariableComponent > > \ - component4(#component4, #name, 3, Kratos::VectorComponentAdaptor >(name, 3)); \ + /*const*/ Kratos::Variable \ + component4(#component4, &name, 3); \ \ - /*const*/ Kratos::VariableComponent > > \ - component5(#component5, #name, 4, Kratos::VectorComponentAdaptor >(name, 4)); \ + /*const*/ Kratos::Variable \ + component5(#component5, &name, 4); \ \ - /*const*/ Kratos::VariableComponent > > \ - component6(#component6, #name, 5, Kratos::VectorComponentAdaptor >(name, 5)); + /*const*/ Kratos::Variable \ + component6(#component6, &name, 5); #ifdef KRATOS_CREATE_SYMMETRIC_3D_TENSOR_VARIABLE_WITH_COMPONENTS #undef KRATOS_CREATE_SYMMETRIC_3D_TENSOR_VARIABLE_WITH_COMPONENTS From 460b3a5b75361fcf89cd9aff438b594837b9958a Mon Sep 17 00:00:00 2001 From: pooyan Date: Fri, 3 Apr 2020 12:54:30 +0200 Subject: [PATCH 066/314] Changing all components to variable --- kratos/includes/define.h | 105 +++++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 53 deletions(-) diff --git a/kratos/includes/define.h b/kratos/includes/define.h index 6f7a939c6c66..c53426e205a6 100644 --- a/kratos/includes/define.h +++ b/kratos/includes/define.h @@ -218,10 +218,10 @@ catch(...) { Block KRATOS_THROW_ERROR(std::runtime_error, "Unknown error", MoreI #endif #define KRATOS_DEFINE_2D_TENSOR_VARIABLE_WITH_COMPONENTS_IMPLEMENTATION(module, name) \ KRATOS_EXPORT_MACRO(module) extern Kratos::Variable > name; \ - KRATOS_EXPORT_MACRO(module) extern Kratos::VariableComponent > > name##_XX;\ - KRATOS_EXPORT_MACRO(module) extern Kratos::VariableComponent > > name##_XY;\ - KRATOS_EXPORT_MACRO(module) extern Kratos::VariableComponent > > name##_YX;\ - KRATOS_EXPORT_MACRO(module) extern Kratos::VariableComponent > > name##_YY; + KRATOS_EXPORT_MACRO(module) extern Kratos::Variable name##_XX;\ + KRATOS_EXPORT_MACRO(module) extern Kratos::Variable name##_XY;\ + KRATOS_EXPORT_MACRO(module) extern Kratos::Variable name##_YX;\ + KRATOS_EXPORT_MACRO(module) extern Kratos::Variable name##_YY; #ifdef KRATOS_DEFINE_2D_TENSOR_VARIABLE_WITH_COMPONENTS #undef KRATOS_DEFINE_2D_TENSOR_VARIABLE_WITH_COMPONENTS @@ -234,25 +234,25 @@ catch(...) { Block KRATOS_THROW_ERROR(std::runtime_error, "Unknown error", MoreI #endif #define KRATOS_DEFINE_2D_TENSOR_APPLICATION_VARIABLE_WITH_COMPONENTS(application, name) \ KRATOS_API(application) extern Kratos::Variable > name; \ - KRATOS_API(application) extern Kratos::VariableComponent > > name##_XX;\ - KRATOS_API(application) extern Kratos::VariableComponent > > name##_XY;\ - KRATOS_API(application) extern Kratos::VariableComponent > > name##_YX;\ - KRATOS_API(application) extern Kratos::VariableComponent > > name##_YY; + KRATOS_API(application) extern Kratos::Variable name##_XX;\ + KRATOS_API(application) extern Kratos::Variable name##_XY;\ + KRATOS_API(application) extern Kratos::Variable name##_YX;\ + KRATOS_API(application) extern Kratos::Variable name##_YY; #ifdef KRATOS_DEFINE_3D_TENSOR_VARIABLE_WITH_COMPONENTS #undef KRATOS_DEFINE_3D_TENSOR_VARIABLE_WITH_COMPONENTS #endif #define KRATOS_DEFINE_3D_TENSOR_VARIABLE_WITH_COMPONENTS_IMPLEMENTATION(module, name) \ KRATOS_EXPORT_MACRO(module) extern Kratos::Variable > name; \ - KRATOS_EXPORT_MACRO(module) extern Kratos::VariableComponent > > name##_XX;\ - KRATOS_EXPORT_MACRO(module) extern Kratos::VariableComponent > > name##_XY;\ - KRATOS_EXPORT_MACRO(module) extern Kratos::VariableComponent > > name##_XZ;\ - KRATOS_EXPORT_MACRO(module) extern Kratos::VariableComponent > > name##_YX;\ - KRATOS_EXPORT_MACRO(module) extern Kratos::VariableComponent > > name##_YY;\ - KRATOS_EXPORT_MACRO(module) extern Kratos::VariableComponent > > name##_YZ;\ - KRATOS_EXPORT_MACRO(module) extern Kratos::VariableComponent > > name##_ZX;\ - KRATOS_EXPORT_MACRO(module) extern Kratos::VariableComponent > > name##_ZY;\ - KRATOS_EXPORT_MACRO(module) extern Kratos::VariableComponent > > name##_ZZ; + KRATOS_EXPORT_MACRO(module) extern Kratos::Variable name##_XX;\ + KRATOS_EXPORT_MACRO(module) extern Kratos::Variable name##_XY;\ + KRATOS_EXPORT_MACRO(module) extern Kratos::Variable name##_XZ;\ + KRATOS_EXPORT_MACRO(module) extern Kratos::Variable name##_YX;\ + KRATOS_EXPORT_MACRO(module) extern Kratos::Variable name##_YY;\ + KRATOS_EXPORT_MACRO(module) extern Kratos::Variable name##_YZ;\ + KRATOS_EXPORT_MACRO(module) extern Kratos::Variable name##_ZX;\ + KRATOS_EXPORT_MACRO(module) extern Kratos::Variable name##_ZY;\ + KRATOS_EXPORT_MACRO(module) extern Kratos::Variable name##_ZZ; #ifdef KRATOS_DEFINE_3D_TENSOR_VARIABLE_WITH_COMPONENTS #undef KRATOS_DEFINE_3D_TENSOR_VARIABLE_WITH_COMPONENTS @@ -265,15 +265,15 @@ catch(...) { Block KRATOS_THROW_ERROR(std::runtime_error, "Unknown error", MoreI #endif #define KRATOS_DEFINE_3D_TENSOR_APPLICATION_VARIABLE_WITH_COMPONENTS(application, name) \ KRATOS_API(application) extern Kratos::Variable > name; \ - KRATOS_API(application) extern Kratos::VariableComponent > > name##_XX;\ - KRATOS_API(application) extern Kratos::VariableComponent > > name##_XY;\ - KRATOS_API(application) extern Kratos::VariableComponent > > name##_XZ;\ - KRATOS_API(application) extern Kratos::VariableComponent > > name##_YX;\ - KRATOS_API(application) extern Kratos::VariableComponent > > name##_YY;\ - KRATOS_API(application) extern Kratos::VariableComponent > > name##_YZ;\ - KRATOS_API(application) extern Kratos::VariableComponent > > name##_ZX;\ - KRATOS_API(application) extern Kratos::VariableComponent > > name##_ZY;\ - KRATOS_API(application) extern Kratos::VariableComponent > > name##_ZZ; + KRATOS_API(application) extern Kratos::Variable name##_XX;\ + KRATOS_API(application) extern Kratos::Variable name##_XY;\ + KRATOS_API(application) extern Kratos::Variable name##_XZ;\ + KRATOS_API(application) extern Kratos::Variable name##_YX;\ + KRATOS_API(application) extern Kratos::Variable name##_YY;\ + KRATOS_API(application) extern Kratos::Variable name##_YZ;\ + KRATOS_API(application) extern Kratos::Variable name##_ZX;\ + KRATOS_API(application) extern Kratos::Variable name##_ZY;\ + KRATOS_API(application) extern Kratos::Variable name##_ZZ; #ifdef KRATOS_CREATE_VARIABLE #undef KRATOS_CREATE_VARIABLE @@ -365,17 +365,17 @@ catch(...) { Block KRATOS_THROW_ERROR(std::runtime_error, "Unknown error", MoreI #define KRATOS_CREATE_2D_TENSOR_VARIABLE_WITH_THIS_COMPONENTS(name, component1, component2, component3, component4) \ /*const*/ Kratos::Variable > name(#name, Kratos::zero_vector(4)); \ \ - /*const*/ Kratos::VariableComponent > > \ - component1(#component1, #name, 0, Kratos::VectorComponentAdaptor >(name, 0)); \ + /*const*/ Kratos::Variable \ + component1(#component1, &name, 0); \ \ - /*const*/ Kratos::VariableComponent > > \ - component2(#component2, #name, 1, Kratos::VectorComponentAdaptor >(name, 1)); \ + /*const*/ Kratos::Variable \ + component2(#component2, &name, 1); \ \ - /*const*/ Kratos::VariableComponent > > \ - component3(#component3, #name, 2, Kratos::VectorComponentAdaptor >(name, 2)); \ + /*const*/ Kratos::Variable \ + component3(#component3, &name, 2); \ \ - /*const*/ Kratos::VariableComponent > > \ - component4(#component4, #name, 3, Kratos::VectorComponentAdaptor >(name, 3)); + /*const*/ Kratos::Variable \ + component4(#component4, &name, 3); #ifdef KRATOS_CREATE_2D_TENSOR_VARIABLE_WITH_COMPONENTS #undef KRATOS_CREATE_2D_TENSOR_VARIABLE_WITH_COMPONENTS @@ -389,32 +389,32 @@ catch(...) { Block KRATOS_THROW_ERROR(std::runtime_error, "Unknown error", MoreI #define KRATOS_CREATE_3D_TENSOR_VARIABLE_WITH_THIS_COMPONENTS(name, component1, component2, component3, component4, component5, component6, component7, component8, component9) \ /*const*/ Kratos::Variable > name(#name, Kratos::zero_vector(9)); \ \ - /*const*/ Kratos::VariableComponent > > \ - component1(#component1, #name, 0, Kratos::VectorComponentAdaptor >(name, 0)); \ + /*const*/ Kratos::Variable \ + component1(#component1, &name, 0); \ \ - /*const*/ Kratos::VariableComponent > > \ - component2(#component2, #name, 1, Kratos::VectorComponentAdaptor >(name, 1)); \ + /*const*/ Kratos::Variable \ + component2(#component2, &name, 1); \ \ - /*const*/ Kratos::VariableComponent > > \ - component3(#component3, #name, 2, Kratos::VectorComponentAdaptor >(name, 2)); \ + /*const*/ Kratos::Variable \ + component3(#component3, &name, 2); \ \ - /*const*/ Kratos::VariableComponent > > \ - component4(#component4, #name, 3, Kratos::VectorComponentAdaptor >(name, 3)); \ + /*const*/ Kratos::Variable \ + component4(#component4, &name, 3); \ \ - /*const*/ Kratos::VariableComponent > > \ - component5(#component5, #name, 4, Kratos::VectorComponentAdaptor >(name, 4)); \ + /*const*/ Kratos::Variable \ + component5(#component5, &name, 4); \ \ - /*const*/ Kratos::VariableComponent > > \ - component6(#component6, #name, 5, Kratos::VectorComponentAdaptor >(name, 5)); \ + /*const*/ Kratos::Variable \ + component6(#component6, &name, 5); \ \ - /*const*/ Kratos::VariableComponent > > \ - component7(#component7, #name, 6, Kratos::VectorComponentAdaptor >(name, 6)); \ + /*const*/ Kratos::Variable \ + component7(#component7, &name, 6); \ \ - /*const*/ Kratos::VariableComponent > > \ - component8(#component8, #name, 7, Kratos::VectorComponentAdaptor >(name, 7)); \ + /*const*/ Kratos::Variable \ + component8(#component8, &name, 7); \ \ - /*const*/ Kratos::VariableComponent > > \ - component9(#component9, #name, 8, Kratos::VectorComponentAdaptor >(name, 8)); + /*const*/ Kratos::Variable \ + component9(#component9, &name, 8); #ifdef KRATOS_CREATE_3D_TENSOR_VARIABLE_WITH_COMPONENTS #undef KRATOS_CREATE_3D_TENSOR_VARIABLE_WITH_COMPONENTS @@ -650,7 +650,6 @@ namespace Kratos // Kratos variable registering /* #define KRATOS_REGISTER_VARIABLE_WITH_ZERO(type, name, zero) const Variable name(#name, __LINE__, zero) */ /* #define KRATOS_REGISTER_VARIABLE(type, name) const Variable name(#name, __LINE__) */ -/* #define KRATOS_REGISTER_VARIABLE_COMPONENT(type, name, source) const VariableComponent name(#name, __LINE__, type source) */ /* #define KRATOS_REGISTER_LINEAR_SOLVER_BEGIN \ */ /* template ApplyToLinearSolver(String Name){ */ From 8cfb308142bb43a3924e2433f5aa75475f197a35 Mon Sep 17 00:00:00 2001 From: pooyan Date: Fri, 3 Apr 2020 17:24:04 +0200 Subject: [PATCH 067/314] Updating structural mechanics --- .../custom_conditions/displacement_control_condition.cpp | 4 ++-- .../custom_conditions/displacement_control_condition.h | 4 ++-- .../adjoint_finite_difference_base_element.cpp | 2 +- .../adjoint_finite_difference_base_element.h | 4 ++-- ...adjoint_finite_difference_small_displacement_element.cpp | 2 +- .../adjoint_local_stress_response_function.h | 2 +- .../adjoint_nodal_displacement_response_function.cpp | 4 ++-- .../response_utilities/finite_difference_utility.h | 2 +- .../custom_schemes/explicit_multi_stage_kim_scheme.hpp | 2 +- .../custom_utilities/rve_periodicity_utility.cpp | 6 +++--- .../custom_utilities/rve_periodicity_utility.h | 2 +- 11 files changed, 17 insertions(+), 17 deletions(-) diff --git a/applications/StructuralMechanicsApplication/custom_conditions/displacement_control_condition.cpp b/applications/StructuralMechanicsApplication/custom_conditions/displacement_control_condition.cpp index 69182f6c701f..c721d46e8781 100644 --- a/applications/StructuralMechanicsApplication/custom_conditions/displacement_control_condition.cpp +++ b/applications/StructuralMechanicsApplication/custom_conditions/displacement_control_condition.cpp @@ -104,7 +104,7 @@ Condition::Pointer DisplacementControlCondition::Clone ( /***********************************************************************************/ /***********************************************************************************/ -DisplacementControlCondition::Array1DComponentType* DisplacementControlCondition::GetDisplacementInDirection() const +Variable* DisplacementControlCondition::GetDisplacementInDirection() const { KRATOS_TRY @@ -132,7 +132,7 @@ DisplacementControlCondition::Array1DComponentType* DisplacementControlCondition /***********************************************************************************/ /***********************************************************************************/ -DisplacementControlCondition::Array1DComponentType* DisplacementControlCondition::GetPointLoadInDirection() const +Variable* DisplacementControlCondition::GetPointLoadInDirection() const { KRATOS_TRY diff --git a/applications/StructuralMechanicsApplication/custom_conditions/displacement_control_condition.h b/applications/StructuralMechanicsApplication/custom_conditions/displacement_control_condition.h index 1c553c099d8f..31b0b01f5ea5 100644 --- a/applications/StructuralMechanicsApplication/custom_conditions/displacement_control_condition.h +++ b/applications/StructuralMechanicsApplication/custom_conditions/displacement_control_condition.h @@ -329,8 +329,8 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) DisplacementControlCondition ///@name Private Operations ///@{ - Array1DComponentType* GetDisplacementInDirection() const; - Array1DComponentType* GetPointLoadInDirection() const; + Variable* GetDisplacementInDirection() const; + Variable* GetPointLoadInDirection() const; ///@} ///@name Private Access diff --git a/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_finite_difference_base_element.cpp b/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_finite_difference_base_element.cpp index ece5c285ba31..90a160e26830 100644 --- a/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_finite_difference_base_element.cpp +++ b/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_finite_difference_base_element.cpp @@ -406,7 +406,7 @@ void AdjointFiniteDifferencingBaseElement::CalculateStressDispla initial_state_variables.resize(num_dofs, false); // Build vector of variables containing the DOF-variables of the primal problem - std::vector>>> primal_solution_variable_list; + std::vector> primal_solution_variable_list; primal_solution_variable_list.reserve(num_dofs_per_node); primal_solution_variable_list.push_back(DISPLACEMENT_X); primal_solution_variable_list.push_back(DISPLACEMENT_Y); diff --git a/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_finite_difference_base_element.h b/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_finite_difference_base_element.h index 5a83b822c4b7..264101368249 100644 --- a/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_finite_difference_base_element.h +++ b/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_finite_difference_base_element.h @@ -467,12 +467,12 @@ class AdjointFiniteDifferencingBaseElement : public Element } // Build vector of variables containing the DOF-variables of the primal problem - std::vector>>*> primal_solution_variable_list; + std::vector*> primal_solution_variable_list; (mHasRotationDofs) ? primal_solution_variable_list = {&DISPLACEMENT_X, &DISPLACEMENT_Y, &DISPLACEMENT_Z, &ROTATION_X, &ROTATION_Y, &ROTATION_Z} : primal_solution_variable_list = {&DISPLACEMENT_X, &DISPLACEMENT_Y, &DISPLACEMENT_Z}; // Build vector of variables containing the DOF-variables of the adjoint problem - std::vector>>*> adjoint_solution_variable_list; + std::vector*> adjoint_solution_variable_list; (mHasRotationDofs) ? adjoint_solution_variable_list = {&ADJOINT_DISPLACEMENT_X, &ADJOINT_DISPLACEMENT_Y, &ADJOINT_DISPLACEMENT_Z, &ADJOINT_ROTATION_X, &ADJOINT_ROTATION_Y, &ADJOINT_ROTATION_Z} : adjoint_solution_variable_list = {&ADJOINT_DISPLACEMENT_X, &ADJOINT_DISPLACEMENT_Y, &ADJOINT_DISPLACEMENT_Z}; diff --git a/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_finite_difference_small_displacement_element.cpp b/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_finite_difference_small_displacement_element.cpp index c40379565742..28a4296993e7 100644 --- a/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_finite_difference_small_displacement_element.cpp +++ b/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_finite_difference_small_displacement_element.cpp @@ -48,7 +48,7 @@ void AdjointFiniteDifferencingSmallDisplacementElement::Calculat << "AdjointFiniteDifferencingSmallDisplacementElement::CalculateStressDisplacementDerivative: Invalid element dimension! Currently only 3D SmallDisplacementElements are supported!" << std::endl; // Build vector of variables containing the DOF-variables of the primal problem - std::vector>>> primal_solution_variable_list {DISPLACEMENT_X, DISPLACEMENT_Y, DISPLACEMENT_Z}; + std::vector> primal_solution_variable_list {DISPLACEMENT_X, DISPLACEMENT_Y, DISPLACEMENT_Z}; std::vector stress_tensor; this->mpPrimalElement->CalculateOnIntegrationPoints(PK2_STRESS_TENSOR, stress_tensor, rCurrentProcessInfo); diff --git a/applications/StructuralMechanicsApplication/custom_response_functions/response_utilities/adjoint_local_stress_response_function.h b/applications/StructuralMechanicsApplication/custom_response_functions/response_utilities/adjoint_local_stress_response_function.h index 05a684719ca9..32a639721ee3 100644 --- a/applications/StructuralMechanicsApplication/custom_response_functions/response_utilities/adjoint_local_stress_response_function.h +++ b/applications/StructuralMechanicsApplication/custom_response_functions/response_utilities/adjoint_local_stress_response_function.h @@ -56,7 +56,7 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) AdjointLocalStressResponseFun ///@{ typedef Element::DofsVectorType DofsVectorType; - typedef VariableComponent > >* Array1DComponentsPointerType; + typedef Variable* Array1DComponentsPointerType; ///@} ///@name Pointer Definitions diff --git a/applications/StructuralMechanicsApplication/custom_response_functions/response_utilities/adjoint_nodal_displacement_response_function.cpp b/applications/StructuralMechanicsApplication/custom_response_functions/response_utilities/adjoint_nodal_displacement_response_function.cpp index 51a5621b4b28..f94d72895824 100644 --- a/applications/StructuralMechanicsApplication/custom_response_functions/response_utilities/adjoint_nodal_displacement_response_function.cpp +++ b/applications/StructuralMechanicsApplication/custom_response_functions/response_utilities/adjoint_nodal_displacement_response_function.cpp @@ -32,7 +32,7 @@ namespace Kratos mpTracedNode = rModelPart.pGetNode(id_traced_node); // Check if variable for traced dof is valid - if( !( KratosComponents< VariableComponent< VectorComponentAdaptor > > >::Has(mTracedDofLabel)) ) + if( !( KratosComponents>::Has(mTracedDofLabel)) ) KRATOS_ERROR << "Specified traced DOF is not available. Specified DOF: " << mTracedDofLabel << std::endl; else { @@ -43,7 +43,7 @@ namespace Kratos } // Check if variable for traced adjoint dof is valid - if( !(KratosComponents< VariableComponent< VectorComponentAdaptor > > >::Has(std::string("ADJOINT_") + mTracedDofLabel)) ) + if( !(KratosComponents>::Has(std::string("ADJOINT_") + mTracedDofLabel)) ) { KRATOS_ERROR << "Specified traced adjoint DOF is not available." << std::endl; } diff --git a/applications/StructuralMechanicsApplication/custom_response_functions/response_utilities/finite_difference_utility.h b/applications/StructuralMechanicsApplication/custom_response_functions/response_utilities/finite_difference_utility.h index 4d72a10ca0b3..267b0c4ebc61 100644 --- a/applications/StructuralMechanicsApplication/custom_response_functions/response_utilities/finite_difference_utility.h +++ b/applications/StructuralMechanicsApplication/custom_response_functions/response_utilities/finite_difference_utility.h @@ -38,7 +38,7 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) FiniteDifferenceUtility { public: - typedef VariableComponent > > array_1d_component_type; + typedef Variable array_1d_component_type; typedef std::size_t IndexType; typedef std::size_t SizeType; diff --git a/applications/StructuralMechanicsApplication/custom_strategies/custom_schemes/explicit_multi_stage_kim_scheme.hpp b/applications/StructuralMechanicsApplication/custom_strategies/custom_schemes/explicit_multi_stage_kim_scheme.hpp index 0c7b870137a8..1acb47c11549 100644 --- a/applications/StructuralMechanicsApplication/custom_strategies/custom_schemes/explicit_multi_stage_kim_scheme.hpp +++ b/applications/StructuralMechanicsApplication/custom_strategies/custom_schemes/explicit_multi_stage_kim_scheme.hpp @@ -92,7 +92,7 @@ class ExplicitMultiStageKimScheme typedef Variable> ArrayVarType; typedef Variable DoubleVarType; - typedef VariableComponent>> VarComponentType; + typedef Variable VarComponentType; typedef array_1d Double3DArray; diff --git a/applications/StructuralMechanicsApplication/custom_utilities/rve_periodicity_utility.cpp b/applications/StructuralMechanicsApplication/custom_utilities/rve_periodicity_utility.cpp index ce03eefe2e73..54299ed267b1 100644 --- a/applications/StructuralMechanicsApplication/custom_utilities/rve_periodicity_utility.cpp +++ b/applications/StructuralMechanicsApplication/custom_utilities/rve_periodicity_utility.cpp @@ -138,9 +138,9 @@ void RVEPeriodicityUtility::Finalize(const Variable>& rVaria { // Get the components const std::string& r_base_variable_name = rVariable.Name(); - auto& r_var_x = KratosComponents>>>::Get(r_base_variable_name + "_X"); - auto& r_var_y = KratosComponents>>>::Get(r_base_variable_name + "_Y"); - auto& r_var_z = KratosComponents>>>::Get(r_base_variable_name + "_Z"); + auto& r_var_x = KratosComponents>::Get(r_base_variable_name + "_X"); + auto& r_var_y = KratosComponents>::Get(r_base_variable_name + "_Y"); + auto& r_var_z = KratosComponents>::Get(r_base_variable_name + "_Z"); for (auto& r_data : mAuxPairings) { auto& r_master_data = r_data.second; diff --git a/applications/StructuralMechanicsApplication/custom_utilities/rve_periodicity_utility.h b/applications/StructuralMechanicsApplication/custom_utilities/rve_periodicity_utility.h index aa6538c881d3..e969033d82e5 100644 --- a/applications/StructuralMechanicsApplication/custom_utilities/rve_periodicity_utility.h +++ b/applications/StructuralMechanicsApplication/custom_utilities/rve_periodicity_utility.h @@ -61,7 +61,7 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) RVEPeriodicityUtility typedef Node<3> NodeType; /// Definition of the component of variable type - typedef VariableComponent>> VariableComponentType; + typedef Variable VariableComponentType; ///@} ///@name Life Cycle From 41508e67d899618472b7415ce1142556aa335638 Mon Sep 17 00:00:00 2001 From: pooyan Date: Fri, 3 Apr 2020 17:24:33 +0200 Subject: [PATCH 068/314] Updating contact structural mechanics --- .../custom_conditions/mesh_tying_mortar_condition.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/ContactStructuralMechanicsApplication/custom_conditions/mesh_tying_mortar_condition.h b/applications/ContactStructuralMechanicsApplication/custom_conditions/mesh_tying_mortar_condition.h index 5258c34d1a46..c7741e6001cb 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_conditions/mesh_tying_mortar_condition.h +++ b/applications/ContactStructuralMechanicsApplication/custom_conditions/mesh_tying_mortar_condition.h @@ -107,7 +107,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MeshTyingMortarCondit typedef GeometryType::IntegrationPointsArrayType IntegrationPointsType; // Type definition of the components of an array_1d - typedef VariableComponent > > Array1DComponentsType; + typedef Variable Array1DComponentsType; typedef typename std::vector> ConditionArrayListType; From 15b9af345aec53927722ec3a1c92bd736549997a Mon Sep 17 00:00:00 2001 From: pooyan Date: Fri, 3 Apr 2020 17:25:04 +0200 Subject: [PATCH 069/314] Updating distance modification process --- .../custom_processes/distance_modification_process.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/FluidDynamicsApplication/custom_processes/distance_modification_process.h b/applications/FluidDynamicsApplication/custom_processes/distance_modification_process.h index 9e19d44a9524..123f9ee37dcd 100644 --- a/applications/FluidDynamicsApplication/custom_processes/distance_modification_process.h +++ b/applications/FluidDynamicsApplication/custom_processes/distance_modification_process.h @@ -59,7 +59,7 @@ class KRATOS_API(FLUID_DYNAMICS_APPLICATION) DistanceModificationProcess : publi public: ///@name Type Definitions ///@{ - typedef VariableComponent< VectorComponentAdaptor> > ComponentType; + typedef Variable ComponentType; /// Pointer definition of DistanceModificationProcess KRATOS_CLASS_POINTER_DEFINITION(DistanceModificationProcess); From 506d015281f97aa06a421f8f622f2cab137ef4d1 Mon Sep 17 00:00:00 2001 From: pooyan Date: Fri, 3 Apr 2020 17:25:27 +0200 Subject: [PATCH 070/314] Updating modelpart io --- kratos/sources/model_part_io.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/kratos/sources/model_part_io.cpp b/kratos/sources/model_part_io.cpp index ab54b6527fb5..2b35ffbd999a 100644 --- a/kratos/sources/model_part_io.cpp +++ b/kratos/sources/model_part_io.cpp @@ -1558,7 +1558,7 @@ void ModelPartIO::ReadNodalDataBlock(ModelPart& rThisModelPart) NodesContainerType& rThisNodes = rThisModelPart.Nodes(); - typedef VariableComponent > > array_1d_component_type; + typedef Variable array_1d_component_type; std::string variable_name; @@ -1662,7 +1662,7 @@ void ModelPartIO::WriteNodalDataBlock(ModelPart& rThisModelPart) VariablesList r_this_variables = rThisModelPart.GetNodalSolutionStepVariablesList(); NodesContainerType& r_this_nodes = rThisModelPart.Nodes(); - typedef VariableComponent > > array_1d_component_type; + typedef Variable array_1d_component_type; std::string variable_name; @@ -1805,7 +1805,7 @@ void ModelPartIO::WriteNodalDataBlock(ModelPart& rThisModelPart) template void ModelPartIO::WriteDataBlock(const TObjectsContainerType& rThisObjectContainer, const std::string& rObjectName){ - typedef VariableComponent > > array_1d_component_type; + typedef Variable array_1d_component_type; std::unordered_set variables; for(auto& object :rThisObjectContainer){ @@ -2000,7 +2000,7 @@ void ModelPartIO::ReadElementalDataBlock(ElementsContainerType& rThisElements) { KRATOS_TRY - typedef VariableComponent > > array_1d_component_type; + typedef Variable array_1d_component_type; std::string variable_name; @@ -2116,7 +2116,7 @@ void ModelPartIO::ReadConditionalDataBlock(ConditionsContainerType& rThisConditi { KRATOS_TRY - typedef VariableComponent > > array_1d_component_type; + typedef Variable array_1d_component_type; std::string variable_name; @@ -3466,7 +3466,7 @@ void ModelPartIO::DivideNodalDataBlock(OutputFilesContainerType& OutputFiles, { KRATOS_TRY - typedef VariableComponent > > array_1d_component_type; + typedef Variable array_1d_component_type; std::string word; @@ -3654,7 +3654,7 @@ void ModelPartIO::DivideElementalDataBlock(OutputFilesContainerType& OutputFiles { KRATOS_TRY - typedef VariableComponent > > array_1d_component_type; + typedef Variable array_1d_component_type; std::string word; @@ -3779,7 +3779,7 @@ void ModelPartIO::DivideConditionalDataBlock(OutputFilesContainerType& OutputFil KRATOS_TRY - typedef VariableComponent > > array_1d_component_type; + typedef Variable array_1d_component_type; std::string word, variable_name; From e5e5e7455aaaeca022c7e797e744b526b7bb9e7e Mon Sep 17 00:00:00 2001 From: pooyan Date: Fri, 3 Apr 2020 17:25:43 +0200 Subject: [PATCH 071/314] updating assign scalar variables --- kratos/processes/assign_scalar_variable_to_entities_process.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kratos/processes/assign_scalar_variable_to_entities_process.h b/kratos/processes/assign_scalar_variable_to_entities_process.h index a94828dc4ef7..36c85a76987c 100644 --- a/kratos/processes/assign_scalar_variable_to_entities_process.h +++ b/kratos/processes/assign_scalar_variable_to_entities_process.h @@ -51,7 +51,7 @@ class KRATOS_API(KRATOS_CORE) AssignScalarVariableToEntitiesProcess typedef Node<3> NodeType; /// Definition of array component - typedef VariableComponent > > array_1d_component_type; + typedef Variable array_1d_component_type; /// The container of the entities typedef PointerVectorSet EntityContainerType; From ae3bc5eb726ed357dddf4be8f4d686876f1345b2 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Mon, 6 Apr 2020 09:18:43 +1000 Subject: [PATCH 072/314] [skip ci] remove unused variables --- .../strategies/mpm_explicit_strategy.hpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp index d62c2a0089fc..2f8ad443da33 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp @@ -268,14 +268,6 @@ namespace Kratos if (mSolutionStepIsInitialized == false) { typename TSchemeType::Pointer pScheme = GetScheme(); - - ModelPart& r_model_part = BaseType::GetModelPart(); - - Vector dummy_vector; - TSystemVectorType rDx = TSystemVectorType(); - TSystemVectorType rb = TSystemVectorType(); - - TSystemMatrixType mA = TSystemMatrixType(); TSystemVectorType mDx = TSystemVectorType(); TSystemVectorType mb = TSystemVectorType(); From 76c382cf43da46843c8ee4903192df1189e739a1 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Mon, 6 Apr 2020 10:50:00 +1000 Subject: [PATCH 073/314] [skip ci] initial velocity works for model_parts, not just mpm_material --- ...gn_initial_velocity_to_particle_process.py | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/applications/ParticleMechanicsApplication/python_scripts/assign_initial_velocity_to_particle_process.py b/applications/ParticleMechanicsApplication/python_scripts/assign_initial_velocity_to_particle_process.py index 60397244e650..68f7ac2db86b 100644 --- a/applications/ParticleMechanicsApplication/python_scripts/assign_initial_velocity_to_particle_process.py +++ b/applications/ParticleMechanicsApplication/python_scripts/assign_initial_velocity_to_particle_process.py @@ -40,13 +40,28 @@ def __init__(self, Model, settings ): settings.ValidateAndAssignDefaults(default_settings) + + + + # Get updated model_part + self.model = Model + model_part_name = settings["model_part_name"].GetString() + if (model_part_name.startswith('Initial_MPM_Material.')): + model_part_name = model_part_name.replace('Initial_MPM_Material.','') + self.mpm_material_model_part_name = "MPM_Material." + model_part_name + # The actual initial velocity application occurs after the submodelpart is + # transferred from the initial MPM material to the MPM material in the particle + # generator utility. Therefore we change the prefix from initial MPM material + # to MPM material. + # Default settings - self.model_part = Model[settings["model_part_name"].GetString()] self.modulus = settings["modulus"].GetDouble() self.velocity_direction = settings["direction"].GetVector() self.velocity = self.modulus * self.velocity_direction def ExecuteBeforeSolutionLoop(self): # Assign velocity to MP after solver.Initialize() - only apply once at the beginning! - for element in self.model_part.Elements: - element.SetValuesOnIntegrationPoints(KratosParticle.MP_VELOCITY,[self.velocity],self.model_part.ProcessInfo) \ No newline at end of file + model_part = self.model[self.mpm_material_model_part_name] + # the model part is identified here, AFTER it has been transferred to the MPM_material part! + for element in model_part.Elements: + element.SetValuesOnIntegrationPoints(KratosParticle.MP_VELOCITY,[self.velocity],model_part.ProcessInfo) \ No newline at end of file From f23a0e1111642fcf9b344d43cd6e843dec8ca5a2 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Mon, 6 Apr 2020 12:03:28 +1000 Subject: [PATCH 074/314] [skip ci] cleanup comments --- .../updated_lagrangian_quadrilateral.hpp | 45 +--- .../schemes/mpm_explicit_scheme.hpp | 134 ++---------- .../strategies/mpm_explicit_strategy.hpp | 193 ++---------------- .../mpm_explicit_utilities.cpp | 17 +- .../custom_utilities/mpm_explicit_utilities.h | 9 - 5 files changed, 42 insertions(+), 356 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp index 70d7afb982b2..5a81ccbf03cc 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp @@ -416,24 +416,16 @@ class UpdatedLagrangianQuadrilateral */ void InitializeSolutionStep(ProcessInfo& rCurrentProcessInfo) override; - /** - * Called after InitializeSolutionStep at the start of the non-linear iteration - */ + /// Called after InitializeSolutionStep at the start of the non-linear iteration void InitializeNonLinearIteration(ProcessInfo& rCurrentProcessInfo) override; - /** - * Called at the end of each solution step - */ + /// Called at the end of each solution step void FinalizeSolutionStep(ProcessInfo& rCurrentProcessInfo) override; - /** - * Called at the end of each solution step - */ + /// Called at the end of each solution step void FinalizeImplicitSolutionStep(ProcessInfo& rCurrentProcessInfo); - /** - * Called at the end of each solution step - */ + /// Called at the end of each solution step void FinalizeExplicitSolutionStep(ProcessInfo& rCurrentProcessInfo); //************* COMPUTING METHODS @@ -630,29 +622,19 @@ class UpdatedLagrangianQuadrilateral */ bool mFinalizedStep; - /** - * Container to store shape functions over whole timestep - */ + /// Container to store shape functions over whole timestep Vector mN; - /** - * Container to store shape function gradients over whole timestep - */ + /// Container to store shape function gradients over whole timestep Matrix mDN_DX; - /** - * Boolean for explicit time integration - */ + /// Boolean for explicit time integration bool mIsExplicit = false; - /** - * Boolean for stress update option - */ + /// Boolean for stress update option bool mIsUSFStressUpdate = false; - /** - * Boolean for central difference explicit time integration - */ + /// Boolean for central difference explicit time integration bool mIsCentralDifference = false; @@ -723,18 +705,13 @@ class UpdatedLagrangianQuadrilateral GeneralVariables & rVariables, const double& rIntegrationWeight); - /** - * Calculation of the Explicit Internal Forces Vector. Fi = div. sigma - */ + /// Calculation of the Explicit Internal Forces Vector. Fi = div. sigma virtual void CalculateAndAddExplicitInternalForces(VectorType& rRightHandSideVector); - /** - * Calculation of the Explicit Stresses from velocity gradient. - */ + /// Calculation of the Explicit Stresses from velocity gradient. virtual void CalculateExplicitStresses(const ProcessInfo& rCurrentProcessInfo, GeneralVariables& rVariables); - /** * Set Variables of the Element to the Parameters of the Constitutive Law */ diff --git a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp index 3f4f684f2a1b..ef3224b5186d 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp @@ -29,27 +29,6 @@ #include "custom_utilities/mpm_explicit_utilities.h" namespace Kratos { - - ///@name Kratos Globals - ///@{ - - ///@} - ///@name Type Definitions - ///@{ - - ///@} - - ///@name Enum's - ///@{ - - ///@} - ///@name Functions - ///@{ - - ///@} - ///@name Kratos Classes - ///@{ - /** * @class MPMExplicitScheme * @ingroup KratosParticle @@ -108,10 +87,6 @@ namespace Kratos { /// The definition of the numerical limit static constexpr double numerical_limit = std::numeric_limits::epsilon(); - ///@} - ///@name Life Cycle - ///@{ - /** * @brief Default constructor. * @details The MPMExplicitScheme method @@ -153,14 +128,9 @@ namespace Kratos { std::cout << " explicit time integration scheme " << std::endl; } - /** Destructor. - */ + /// Destructor. virtual ~MPMExplicitScheme() {} - ///@} - ///@name Operators - ///@{ - /** * Clone */ @@ -178,7 +148,7 @@ namespace Kratos { KRATOS_TRY ProcessInfo& r_current_process_info = rModelPart.GetProcessInfo(); - + // TODO cleanup // Preparing the time values for the first step (where time = initial_time + // dt) mTime.Current = r_current_process_info[TIME] + r_current_process_info[DELTA_TIME]; @@ -306,8 +276,7 @@ namespace Kratos { array_1d& r_current_residual = itCurrentNode->FastGetSolutionStepValue(FORCE_RESIDUAL); double gamma = 1.0; - if (mIsCentralDifference) - { + if (mIsCentralDifference) { gamma = 0.5; // factor since we are only adding the central difference corrector here } @@ -316,8 +285,7 @@ namespace Kratos { r_nodal_momenta[j] = 0.0; r_current_residual[j] = 0.0; } - else - { + else { r_nodal_momenta[j] += gamma * mTime.Delta * r_current_residual[j]; } @@ -340,10 +308,9 @@ namespace Kratos { } - /** - This is the place to initialize the elements. - This is intended to be called just once when the strategy is initialized - */ + + /** This is the place to initialize the elements. + This is intended to be called just once when the strategy is initialized */ void InitializeElements(ModelPart& rModelPart) override { KRATOS_TRY @@ -506,12 +473,9 @@ namespace Kratos { } - //*******************************************************FinalizeNonLinIteration******************** - //*************************************************************************** - /** - Function called once at the end of a solution step, after convergence is reached if - an iterative process is needed - */ + + /** Function called once at the end of a solution step, after convergence is reached if + an iterative process is needed */ void FinalizeSolutionStep( ModelPart& rModelPart, TSystemMatrixType& A, @@ -605,7 +569,6 @@ namespace Kratos { } - void InitializeNonLinIteration(ModelPart& r_model_part, TSystemMatrixType& A, TSystemVectorType& Dx, @@ -654,13 +617,6 @@ namespace Kratos { (rCurrentElement)->InitializeNonLinearIteration(CurrentProcessInfo); } - //*************************************************************************** - //*************************************************************************** - - //*************************************************************************** - //*************************************************************************** - - //*************************************************************************** //*************************************************************************** @@ -843,97 +799,35 @@ namespace Kratos { pCurrentEntity->CalculateRightHandSide(RHS_Contribution, rCurrentProcessInfo); pCurrentEntity->AddExplicitContribution(RHS_Contribution, RESIDUAL_VECTOR, FORCE_RESIDUAL, rCurrentProcessInfo); - //pCurrentEntity->AddExplicitContribution(RHS_Contribution, RESIDUAL_VECTOR, MOMENT_RESIDUAL, rCurrentProcessInfo); KRATOS_CATCH("") } - - /*@} */ - /**@name Operations */ - /*@{ */ - /*@} */ - /**@name Access */ - /*@{ */ - /*@} */ - /**@name Inquiry */ - /*@{ */ - /*@} */ - /**@name Friends */ - /*@{ */ - protected: - /**@name Static Member Variables */ - /*@{ */ - /*@} */ - /**@name Member Variables */ - /*@{ */ - + /// @name Member Variables struct DeltaTimeParameters { double PredictionLevel; // 0, 1, 2 // NOTE: Should be a integer? double Maximum; // Maximum delta time double Fraction; // Fraction of the delta time }; - /** - * @brief This struct contains the details of the time variables - */ + /// @brief This struct contains the details of the time variables struct TimeVariables { double PreviousMiddle; // n-1/2 double Previous; // n double Middle; // n+1/2 double Current; // n+1 - double Delta; // Time step }; - ///@name Protected static Member Variables - ///@{ - + /// Protected static Member Variables + // TODO check if this is needed TimeVariables mTime; /// This struct contains the details of the time variables - ModelPart& mr_grid_model_part; - const int mStressUpdateOption; // 0 = USF, 1 = USL, 2 = MUSL const bool mIsCentralDifference; - /*@} */ - /**@name Protected Operators*/ - /*@{ */ - - /*@} */ - /**@name Protected Operations*/ - /*@{ */ - /*@} */ - /**@name Protected Access */ - /*@{ */ - /*@} */ - /**@name Protected Inquiry */ - /*@{ */ - /*@} */ - /**@name Protected LifeCycle */ - /*@{ */ private: - /**@name Static Member Variables */ - /*@{ */ - /*@} */ - /**@name Member Variables */ - /*@{ */ - /*@} */ - /**@name Private Operators*/ - /*@{ */ - /*@} */ - /**@name Private Operations*/ - /*@{ */ - /*@} */ - /**@name Private Access */ - /*@{ */ - /*@} */ - /**@name Private Inquiry */ - /*@{ */ - /*@} */ - /**@name Unaccessible methods */ - /*@{ */ }; /* Class MPMExplicitScheme */ } /* namespace Kratos.*/ diff --git a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp index 2f8ad443da33..e153ed0ffae5 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp @@ -24,7 +24,6 @@ #include "includes/model_part.h" #include "utilities/variable_utils.h" #include "includes/kratos_flags.h" - #include "solving_strategies/strategies/solving_strategy.h" // Application includes @@ -32,33 +31,7 @@ namespace Kratos { - - /**@name Kratos Globals */ - /*@{ */ - - - /*@} */ - /**@name Type Definitions */ - /*@{ */ - - /*@} */ - - - /**@name Enum's */ - /*@{ */ - - - /*@} */ - /**@name Functions */ - /*@{ */ - - - - /*@} */ - /**@name Kratos Classes */ - /*@{ */ - - /// Short class definition. +/// Short class definition. /** * @class MPMExplicitStrategy * @ingroup ParticleMechanicsApplciation @@ -73,9 +46,6 @@ namespace Kratos : public SolvingStrategy { public: - /**@name Type Definitions */ - /*@{ */ - /** Counted pointer of ClassName */ KRATOS_CLASS_POINTER_DEFINITION(MPMExplicitStrategy); typedef SolvingStrategy BaseType; @@ -105,11 +75,6 @@ namespace Kratos typedef typename BaseType::ConditionsArrayType ConditionsArrayType; - - /*@} */ - /**@name Life Cycle - */ - /*@{ */ MPMExplicitStrategy( ModelPart& model_part, typename TSchemeType::Pointer pScheme, @@ -142,17 +107,13 @@ namespace Kratos KRATOS_CATCH("") } - /** Destructor. - */ + /// Destructor. virtual ~MPMExplicitStrategy() { } - /** Destructor. - */ //Set and Get Scheme ... containing Builder, Update and other - void SetScheme(typename TSchemeType::Pointer pScheme) { mpScheme = pScheme; @@ -211,15 +172,7 @@ namespace Kratos BaseType::mEchoLevel = Level; } - //********************************************************************************* - /**OPERATIONS ACCESSIBLE FROM THE INPUT:*/ - //********************************************************************************* - /** - Initialize members - */ - //********************************************************************** - - + /// Initialize members void Initialize() override { KRATOS_TRY @@ -284,11 +237,7 @@ namespace Kratos } - //********************************************************************************* - /** - the problem of interest is solved - */ - //********************************************************************** + /// the problem of interest is solved bool SolveSolutionStep() override { typename TSchemeType::Pointer pScheme = GetScheme(); @@ -314,8 +263,6 @@ namespace Kratos return true; } - //********************************************************************************* - //********************************************************************** //********************************************************************** @@ -327,21 +274,6 @@ namespace Kratos KRATOS_CATCH("") } - /*@} */ - /**@name Operators - */ - /*@{ */ - - /*@} */ - /**@name Operations */ - /*@{ */ - - - /*@} */ - /**@name Access */ - - /*@{ */ - void SetKeepSystemConstantDuringIterations(bool value) { mKeepSystemConstantDuringIterations = value; @@ -352,63 +284,9 @@ namespace Kratos return mKeepSystemConstantDuringIterations; } - - /*@} */ - /**@name Inquiry */ - /*@{ */ - - - /*@} */ - /**@name Friends */ - /*@{ */ - - - /*@} */ - private: - /**@name Protected static Member Variables */ - /*@{ */ - - - /*@} */ - /**@name Protected member Variables */ - /*@{ */ - - - /*@} */ - /**@name Protected Operators*/ - /*@{ */ - - - /*@} */ - /**@name Protected Operations*/ - /*@{ */ - - - - /*@} */ - /**@name Protected Access */ - /*@{ */ - - - /*@} */ - /**@name Protected Inquiry */ - /*@{ */ - - - /*@} */ - /**@name Protected LifeCycle */ - /*@{ */ - - - - /*@} */ protected: - /**@name Static Member Variables */ - /*@{ */ - - /*@} */ /**@name Member Variables */ /*@{ */ @@ -427,34 +305,22 @@ namespace Kratos */ bool mReformDofSetAtEachStep; - /** - Flag telling if it is needed or not to compute the reactions - - default = true - */ + /// Flag telling if it is needed or not to compute the reactions, default = true bool mCalculateReactionsFlag; bool mSolutionStepIsInitialized; bool mInitializeWasPerformed; - //flag to allow keeping system matrix constant during iterations + /// flag to allow keeping system matrix constant during iterations bool mKeepSystemConstantDuringIterations; - //flag to allow to not finalize the solution step, so the historical variables are not updated + /// flag to allow to not finalize the solution step, so the historical variables are not updated bool mFinalizeSolutionStep; - /*@} */ - /**@name Private Operators*/ - /*@{ */ //********************************************************************** //********************************************************************** - - - - //********************************************************************** - //********************************************************************** void FinalizeSolutionStep() override { KRATOS_TRY @@ -555,7 +421,7 @@ namespace Kratos const IndexType rotppos = it_node_begin->GetDofPosition(ROTATION_X); // Iterating nodes -#pragma omp parallel for firstprivate(force_residual, moment_residual), schedule(guided,512) + #pragma omp parallel for firstprivate(force_residual, moment_residual), schedule(guided,512) for (int i = 0; i < static_cast(r_nodes.size()); ++i) { auto it_node = it_node_begin + i; @@ -596,46 +462,11 @@ namespace Kratos } } - - - /*@} */ - /**@name Private Operations*/ - /*@{ */ - - - /*@} */ - /**@name Private Access */ - /*@{ */ - - - /*@} */ - /**@name Private Inquiry */ - /*@{ */ - - - /*@} */ - /**@name Un accessible methods */ - /*@{ */ - - /** Copy constructor. - */ + /// Copy constructor MPMExplicitStrategy(const MPMExplicitStrategy& Other) { }; + }; // Class MPMExplicitStrategy +}; // namespace Kratos - - /*@} */ - - }; /* Class MPMExplicitStrategy */ - - /*@} */ - - /**@name Type Definitions */ - /*@{ */ - - - /*@} */ - -}; /* namespace Kratos.*/ - -#endif /* KRATOS_MPM_EXPLICIT_STRATEGY defined */ +#endif // KRATOS_MPM_EXPLICIT_STRATEGY defined diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp index 561c68b85290..61c9b629c0d8 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp @@ -10,10 +10,6 @@ // Main authors: Peter Wilson // -// System includes - -// External includes - // Project includes #include "custom_utilities/mpm_explicit_utilities.h" @@ -28,12 +24,12 @@ namespace Kratos { KRATOS_TRY + // Add in explicit internal force calculation (Fint = Volume*divergence(sigma)) + // Refer to link for notation https://github.com/KratosMultiphysics/Kratos/wiki/How-to-use-the-Constitutive-Law-class const unsigned int dimension = rGeom.WorkingSpaceDimension(); const unsigned int number_of_nodes = rGeom.PointsNumber(); array_1d nodal_force_internal_normal = ZeroVector(3); - - // Add in explicit internal force calculation (Fint = Volume*divergence(sigma)) - // Refer to link for notation https://github.com/KratosMultiphysics/Kratos/wiki/How-to-use-the-Constitutive-Law-class + for (unsigned int i = 0; i < number_of_nodes; i++) { // f_i = V * Sum_j [s_ij N_,j] @@ -110,15 +106,13 @@ namespace Kratos rElement.CalculateOnIntegrationPoints(MP_ACCELERATION, MP_PreviousAcceleration, rProcessInfo); double gamma = 1.0; // 0.5 for central difference, 1.0 for forward euler - if (isCentralDifference) - { + if (isCentralDifference) { gamma = 0.5; isUpdateMPPositionFromUpdatedMPVelocity = false; } // Advance the material point predictor velocity - for (unsigned int i = 0; i < dimension; i++) - { + for (unsigned int i = 0; i < dimension; i++) { MP_Velocity[i] = MP_PreviousVelocity[0][i] + (1.0 - gamma) * rDeltaTime * MP_PreviousAcceleration[0][i]; } @@ -190,7 +184,6 @@ namespace Kratos Element& rElement, Vector& rN) { - KRATOS_TRY const unsigned int dimension = rGeom.WorkingSpaceDimension(); const unsigned int number_of_nodes = rGeom.PointsNumber(); diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h index f337ef52cb89..96c4353a90b0 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h @@ -13,16 +13,10 @@ #if !defined(KRATOS_MPM_EXPLICIT_UTILITIES) #define KRATOS_MPM_EXPLICIT_UTILITIES -// System includes - -// External includes - // Project includes #include "includes/model_part.h" #include "includes/element.h" #include "includes/variables.h" - - #include "particle_mechanics_application_variables.h" namespace Kratos @@ -49,9 +43,6 @@ namespace Kratos typedef Node<3> NodeType; typedef Geometry GeometryType; - // Reference https://github.com/KratosMultiphysics/Kratos/blob/MPM/explicit_time_int2/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp - - void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) CalcuateAndAddExplicitInternalForce(GeometryType& rGeom, const Matrix& rDN_DX, const Vector& rMPStress, const double& rMPVolume, Vector& rRightHandSideVector); From 3b358b1d4134e43c807d41547f4bc07744f16985 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Mon, 6 Apr 2020 12:16:12 +1000 Subject: [PATCH 075/314] [skip ci] cleanup --- .../mpm_explicit_utilities.cpp | 41 +++++++++---------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp index 61c9b629c0d8..514260704ddf 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp @@ -26,11 +26,11 @@ namespace Kratos // Add in explicit internal force calculation (Fint = Volume*divergence(sigma)) // Refer to link for notation https://github.com/KratosMultiphysics/Kratos/wiki/How-to-use-the-Constitutive-Law-class - const unsigned int dimension = rGeom.WorkingSpaceDimension(); - const unsigned int number_of_nodes = rGeom.PointsNumber(); + const SizeType dimension = rGeom.WorkingSpaceDimension(); + const SizeType number_of_nodes = rGeom.PointsNumber(); array_1d nodal_force_internal_normal = ZeroVector(3); - for (unsigned int i = 0; i < number_of_nodes; i++) + for (IndexType i = 0; i < number_of_nodes; i++) { // f_i = V * Sum_j [s_ij N_,j] if (dimension == 2) @@ -93,8 +93,8 @@ namespace Kratos { KRATOS_TRY - const unsigned int number_of_nodes = rGeom.PointsNumber(); - const unsigned int dimension = rGeom.WorkingSpaceDimension(); + const SizeType number_of_nodes = rGeom.PointsNumber(); + const SizeType dimension = rGeom.WorkingSpaceDimension(); bool isUpdateMPPositionFromUpdatedMPVelocity = true; // should normally be true. this reduces energy lost from kinematic aliasing const ProcessInfo& rProcessInfo = ProcessInfo(); @@ -104,22 +104,21 @@ namespace Kratos array_1d MP_Velocity = ZeroVector(3); rElement.CalculateOnIntegrationPoints(MP_VELOCITY, MP_PreviousVelocity,rProcessInfo); rElement.CalculateOnIntegrationPoints(MP_ACCELERATION, MP_PreviousAcceleration, rProcessInfo); - double gamma = 1.0; // 0.5 for central difference, 1.0 for forward euler - - if (isCentralDifference) { - gamma = 0.5; - isUpdateMPPositionFromUpdatedMPVelocity = false; - } + const double gamma = (isCentralDifference) + ? 0.5 + : 1.0; // 0.5 for central difference, 1.0 for forward euler + if (isCentralDifference) isUpdateMPPositionFromUpdatedMPVelocity = false; + // Advance the material point predictor velocity - for (unsigned int i = 0; i < dimension; i++) { + for (IndexType i = 0; i < dimension; i++) { MP_Velocity[i] = MP_PreviousVelocity[0][i] + (1.0 - gamma) * rDeltaTime * MP_PreviousAcceleration[0][i]; } array_1d delta_xg = ZeroVector(3); array_1d MP_Acceleration = ZeroVector(3); - for (unsigned int i = 0; i < number_of_nodes; i++) + for (IndexType i = 0; i < number_of_nodes; i++) { const double nodal_mass = rGeom[i].FastGetSolutionStepValue(NODAL_MASS); @@ -129,7 +128,7 @@ namespace Kratos const array_1d& r_current_residual = rGeom[i].FastGetSolutionStepValue(FORCE_RESIDUAL); const array_1d& r_middle_velocity = rGeom[i].FastGetSolutionStepValue(VELOCITY); - for (unsigned int j = 0; j < dimension; j++) + for (IndexType j = 0; j < dimension; j++) { MP_Acceleration[j] += rN[i] * r_current_residual[j] / nodal_mass; if (isCentralDifference) @@ -148,7 +147,7 @@ namespace Kratos rElement.SetValuesOnIntegrationPoints(MP_ACCELERATION, { MP_Acceleration }, rProcessInfo); // Update the MP Velocity corrector - for (unsigned int j = 0; j < dimension; j++) + for (IndexType j = 0; j < dimension; j++) { MP_Velocity[j] += gamma * rDeltaTime * MP_Acceleration[j]; } @@ -159,7 +158,7 @@ namespace Kratos rElement.CalculateOnIntegrationPoints(MP_COORD, xg,rProcessInfo); if (isUpdateMPPositionFromUpdatedMPVelocity) { - for (unsigned int j = 0; j < dimension; j++) + for (IndexType j = 0; j < dimension; j++) { delta_xg[j] = rDeltaTime * MP_Velocity[j]; } @@ -185,8 +184,8 @@ namespace Kratos Vector& rN) { KRATOS_TRY - const unsigned int dimension = rGeom.WorkingSpaceDimension(); - const unsigned int number_of_nodes = rGeom.PointsNumber(); + const SizeType dimension = rGeom.WorkingSpaceDimension(); + const SizeType number_of_nodes = rGeom.PointsNumber(); const ProcessInfo& rProcessInfo = ProcessInfo(); std::vector > MP_Velocity; @@ -194,14 +193,14 @@ namespace Kratos rElement.CalculateOnIntegrationPoints(MP_VELOCITY, MP_Velocity,rProcessInfo); rElement.CalculateOnIntegrationPoints(MP_MASS, MP_Mass, rProcessInfo); - for (unsigned int i = 0; i < number_of_nodes; i++) + for (IndexType i = 0; i < number_of_nodes; i++) { const double& r_nodal_mass = rGeom[i].FastGetSolutionStepValue(NODAL_MASS); if (r_nodal_mass > std::numeric_limits::epsilon()) { array_1d& r_current_velocity = rGeom[i].FastGetSolutionStepValue(VELOCITY); - for (unsigned int j = 0; j < dimension; j++) + for (IndexType j = 0; j < dimension; j++) { // we need to use the original shape functions here (calculated before the momenta update) r_current_velocity[j] += rN[i] * MP_Mass[0] * MP_Velocity[0][j] / r_nodal_mass; @@ -228,7 +227,6 @@ namespace Kratos const SizeType dimension = rGeom.WorkingSpaceDimension(); const SizeType number_of_nodes = rGeom.PointsNumber(); - //Calculate velocity gradients Matrix velocityGradient = Matrix(dimension, dimension, 0.0); for (IndexType nodeIndex = 0; nodeIndex < number_of_nodes; nodeIndex++) @@ -248,7 +246,6 @@ namespace Kratos Matrix rateOfDeformation = 0.5 * (velocityGradient + trans(velocityGradient)); Matrix spinTensor = velocityGradient - rateOfDeformation; - //Calculate objective Jaumann strain rate Matrix jaumannRate = rateOfDeformation - (prod(spinTensor, rateOfDeformation)) * rDeltaTime + From 9ef06e23decd8b937cd95f6769e8b68287aa1693 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Mon, 6 Apr 2020 16:32:19 +1000 Subject: [PATCH 076/314] [skip ci] add explicit usl oscillating point test --- .../explicit_oscillating_point_test_Body.mdpa | 34 +++ .../explicit_oscillating_point_test_Grid.mdpa | 287 ++++++++++++++++++ ...icit_oscillating_point_test_materials.json | 19 ++ ...cit_oscillating_point_test_parameters.json | 91 ++++++ ...plicit_oscillating_point_test_results.json | 1 + .../tests/particle_mechanics_test_factory.py | 6 +- .../test_ParticleMechanicsApplication.py | 5 + 7 files changed, 442 insertions(+), 1 deletion(-) create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_test_Body.mdpa create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_test_Grid.mdpa create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_test_materials.json create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usl_explicit_oscillating_point_test_parameters.json create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usl_explicit_oscillating_point_test_results.json diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_test_Body.mdpa b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_test_Body.mdpa new file mode 100644 index 000000000000..e22d7aa3ccde --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_test_Body.mdpa @@ -0,0 +1,34 @@ +Begin ModelPartData +// VARIABLE_NAME value +End ModelPartData + +Begin Properties 0 +End Properties +Begin Nodes + 43 2.00000 2.00000 0.00000 + 45 2.00000 1.00000 0.00000 + 49 1.00000 2.00000 0.00000 + 50 1.00000 1.00000 0.00000 +End Nodes + + +Begin Elements UpdatedLagrangian2D4N// GUI group identifier: bar + 31 0 45 43 49 50 +End Elements + +Begin SubModelPart Parts_bar // Group bar // Subtree Parts + Begin SubModelPartNodes + 43 + 45 + 49 + 50 + End SubModelPartNodes + Begin SubModelPartElements + 31 + 31 + 31 + 31 + End SubModelPartElements + Begin SubModelPartConditions + End SubModelPartConditions +End SubModelPart diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_test_Grid.mdpa b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_test_Grid.mdpa new file mode 100644 index 000000000000..0f6444817f3d --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_test_Grid.mdpa @@ -0,0 +1,287 @@ +Begin ModelPartData +// VARIABLE_NAME value +End ModelPartData + +Begin Properties 0 +End Properties +Begin Nodes + 1 10.0000000000 3.0000000000 0.0000000000 + 2 10.0000000000 2.0000000000 0.0000000000 + 3 9.0000000000 3.0000000000 0.0000000000 + 4 9.0000000000 2.0000000000 0.0000000000 + 5 10.0000000000 1.0000000000 0.0000000000 + 6 8.0000000000 3.0000000000 0.0000000000 + 7 8.0000000000 2.0000000000 0.0000000000 + 8 9.0000000000 1.0000000000 0.0000000000 + 9 8.0000000000 1.0000000000 0.0000000000 + 10 7.0000000000 3.0000000000 0.0000000000 + 11 10.0000000000 0.0000000000 0.0000000000 + 12 7.0000000000 2.0000000000 0.0000000000 + 13 9.0000000000 0.0000000000 0.0000000000 + 14 8.0000000000 0.0000000000 0.0000000000 + 15 7.0000000000 1.0000000000 0.0000000000 + 16 6.0000000000 3.0000000000 0.0000000000 + 17 6.0000000000 2.0000000000 0.0000000000 + 18 6.0000000000 2.0000000000 0.0000000000 + 19 7.0000000000 0.0000000000 0.0000000000 + 20 6.0000000000 1.0000000000 0.0000000000 + 21 6.0000000000 1.0000000000 0.0000000000 + 22 5.0000000000 3.0000000000 0.0000000000 + 23 6.0000000000 0.0000000000 0.0000000000 + 24 5.0000000000 2.0000000000 0.0000000000 + 25 5.0000000000 2.0000000000 0.0000000000 + 26 5.0000000000 1.0000000000 0.0000000000 + 27 5.0000000000 1.0000000000 0.0000000000 + 28 5.0000000000 0.0000000000 0.0000000000 + 29 4.0000000000 3.0000000000 0.0000000000 + 30 4.0000000000 2.0000000000 0.0000000000 + 31 4.0000000000 2.0000000000 0.0000000000 + 32 4.0000000000 1.0000000000 0.0000000000 + 33 4.0000000000 1.0000000000 0.0000000000 + 34 4.0000000000 0.0000000000 0.0000000000 + 35 3.0000000000 3.0000000000 0.0000000000 + 36 3.0000000000 2.0000000000 0.0000000000 + 37 3.0000000000 2.0000000000 0.0000000000 + 38 3.0000000000 1.0000000000 0.0000000000 + 39 3.0000000000 1.0000000000 0.0000000000 + 40 3.0000000000 0.0000000000 0.0000000000 + 41 2.0000000000 3.0000000000 0.0000000000 + 42 2.0000000000 2.0000000000 0.0000000000 + 43 2.0000000000 2.0000000000 0.0000000000 + 44 2.0000000000 1.0000000000 0.0000000000 + 45 2.0000000000 1.0000000000 0.0000000000 + 46 2.0000000000 0.0000000000 0.0000000000 + 47 1.0000000000 3.0000000000 0.0000000000 + 48 1.0000000000 2.0000000000 0.0000000000 + 49 1.0000000000 2.0000000000 0.0000000000 + 50 1.0000000000 1.0000000000 0.0000000000 + 51 1.0000000000 1.0000000000 0.0000000000 + 52 1.0000000000 0.0000000000 0.0000000000 + 53 0.0000000000 3.0000000000 0.0000000000 + 54 0.0000000000 2.0000000000 0.0000000000 + 55 0.0000000000 1.0000000000 0.0000000000 + 56 0.0000000000 0.0000000000 0.0000000000 +End Nodes + + +Begin Elements Element2D4N// GUI group identifier: grid + 1 0 52 51 55 56 + 2 0 46 44 51 52 + 3 0 40 38 44 46 + 4 0 34 33 38 40 + 5 0 28 27 33 34 + 6 0 23 21 27 28 + 7 0 19 15 21 23 + 8 0 14 9 15 19 + 9 0 13 8 9 14 + 10 0 11 5 8 13 + 11 0 51 48 54 55 + 12 0 44 42 48 51 + 13 0 38 36 42 44 + 14 0 33 31 36 38 + 15 0 27 25 31 33 + 16 0 21 18 25 27 + 17 0 15 12 18 21 + 18 0 9 7 12 15 + 19 0 8 4 7 9 + 20 0 5 2 4 8 + 21 0 48 47 53 54 + 22 0 42 41 47 48 + 23 0 36 35 41 42 + 24 0 31 29 35 36 + 25 0 25 22 29 31 + 26 0 18 16 22 25 + 27 0 12 10 16 18 + 28 0 7 6 10 12 + 29 0 4 3 6 7 + 30 0 2 1 3 4 +End Elements + +Begin SubModelPart Parts_grid // Group grid // Subtree Parts + Begin SubModelPartNodes + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 18 + 19 + 21 + 22 + 23 + 25 + 27 + 28 + 29 + 31 + 33 + 34 + 35 + 36 + 38 + 40 + 41 + 42 + 44 + 46 + 47 + 48 + 51 + 52 + 53 + 54 + 55 + 56 + End SubModelPartNodes + Begin SubModelPartElements + 1 + 1 + 1 + 1 + 2 + 2 + 2 + 2 + 3 + 3 + 3 + 3 + 4 + 4 + 4 + 4 + 5 + 5 + 5 + 5 + 6 + 6 + 6 + 6 + 7 + 7 + 7 + 7 + 8 + 8 + 8 + 8 + 9 + 9 + 9 + 9 + 10 + 10 + 10 + 10 + 11 + 11 + 11 + 11 + 12 + 12 + 12 + 12 + 13 + 13 + 13 + 13 + 14 + 14 + 14 + 14 + 15 + 15 + 15 + 15 + 16 + 16 + 16 + 16 + 17 + 17 + 17 + 17 + 18 + 18 + 18 + 18 + 19 + 19 + 19 + 19 + 20 + 20 + 20 + 20 + 21 + 21 + 21 + 21 + 22 + 22 + 22 + 22 + 23 + 23 + 23 + 23 + 24 + 24 + 24 + 24 + 25 + 25 + 25 + 25 + 26 + 26 + 26 + 26 + 27 + 27 + 27 + 27 + 28 + 28 + 28 + 28 + 29 + 29 + 29 + 29 + 30 + 30 + 30 + 30 + End SubModelPartElements + Begin SubModelPartConditions + End SubModelPartConditions +End SubModelPart +Begin SubModelPart DISPLACEMENT_Displacement_Auto1 // Group Displacement Auto1 // Subtree DISPLACEMENT + Begin SubModelPartNodes + 47 + 48 + 51 + 52 + 53 + 54 + 55 + 56 + End SubModelPartNodes + Begin SubModelPartElements + End SubModelPartElements + Begin SubModelPartConditions + End SubModelPartConditions +End SubModelPart diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_test_materials.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_test_materials.json new file mode 100644 index 000000000000..27571f44941d --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_test_materials.json @@ -0,0 +1,19 @@ +{ + "properties" : [{ + "model_part_name" : "Initial_MPM_Material.Parts_bar", + "properties_id" : 1, + "Material" : { + "constitutive_law" : { + "name" : "LinearElasticIsotropicPlaneStress2DLaw" + }, + "Variables" : { + "THICKNESS" : 1.0, + "PARTICLES_PER_ELEMENT" : 1, + "DENSITY" : 1.0, + "YOUNG_MODULUS" : 39.4784176043574, + "POISSON_RATIO" : 0 + }, + "Tables" : {} + } + }] +} diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usl_explicit_oscillating_point_test_parameters.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usl_explicit_oscillating_point_test_parameters.json new file mode 100644 index 000000000000..c23819a9f872 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usl_explicit_oscillating_point_test_parameters.json @@ -0,0 +1,91 @@ +{ + "problem_data" : { + "problem_name" : "usl_explicit_oscillating_point_test", + "parallel_type" : "OpenMP", + "echo_level" : 0, + "start_time" : 0.0, + "end_time" : 0.5 + }, + "solver_settings" : { + "solver_type" : "Dynamic", + "model_part_name" : "MPM_Material", + "domain_size" : 2, + "echo_level" : 0, + "analysis_type" : "linear", + "time_integration_method" : "explicit", + "scheme_type" : "forward_euler", + "stress_update" : "usl", + "compressible" : false, + "model_import_settings" : { + "input_type" : "mdpa", + "input_filename" : "explicit_tests/oscillating_point/explicit_oscillating_point_test_Body" + }, + "material_import_settings" : { + "materials_filename" : "explicit_tests/oscillating_point/explicit_oscillating_point_test_materials.json" + }, + "time_stepping" : { + "time_step" : 0.05 + }, + "convergence_criterion" : "residual_criterion", + "displacement_relative_tolerance" : 0.0001, + "displacement_absolute_tolerance" : 1e-9, + "residual_relative_tolerance" : 0.0001, + "residual_absolute_tolerance" : 1e-9, + "max_iteration" : 10, + "problem_domain_sub_model_part_list" : ["Parts_bar","Parts_grid"], + "processes_sub_model_part_list" : ["DISPLACEMENT_Displacement_Auto1"], + "grid_model_import_settings" : { + "input_type" : "mdpa", + "input_filename" : "explicit_tests/oscillating_point/explicit_oscillating_point_test_Grid" + }, + "pressure_dofs" : false + }, + "processes" : { + "constraints_process_list" : [{ + "python_module" : "assign_vector_variable_process", + "kratos_module" : "KratosMultiphysics", + "Parameters" : { + "model_part_name" : "Background_Grid.DISPLACEMENT_Displacement_Auto1", + "variable_name" : "DISPLACEMENT", + "constrained" : [true,true,true], + "value" : [0.0,0.0,0.0], + "interval" : [0.0,"End"] + } + }], + "loads_process_list" : [], + "list_other_processes" : [{ + "python_module" : "assign_initial_velocity_to_particle_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "Parameters" : { + "model_part_name" : "Parts_bar", + "variable_name" : "MP_VELOCITY", + "modulus" : 0.1, + "direction" : [1.0,0.0,0.0] + } + }, + { + "python_module" : "particle_from_json_check_result_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "help" : "", + "process_name" : "ParticleFromJsonCheckResultProcess", + "Parameters" : { + "check_variables" : ["MP_VELOCITY","MP_DISPLACEMENT"], + "input_file_name" : "explicit_tests/oscillating_point/usl_explicit_oscillating_point_test_results.json", + "model_part_name" : "MPM_Material", + "time_frequency" : 0.5 + } + }] + }, + "print_output_process" : [{ + "python_module" : "particle_json_output_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "help" : "", + "process_name" : "ParticleJsonOutputProcess", + "Parameters" : { + "gauss_points_output_variables" : ["MP_VELOCITY","MP_DISPLACEMENT"], + "output_file_name" : "explicit_tests/oscillating_point/usl_explicit_oscillating_point_test_results.json", + "model_part_name" : "MPM_Material", + "time_frequency" : 0.5 + } + }] +} diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usl_explicit_oscillating_point_test_results.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usl_explicit_oscillating_point_test_results.json new file mode 100644 index 000000000000..2d0b68e23e0f --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usl_explicit_oscillating_point_test_results.json @@ -0,0 +1 @@ +{"TIME": [0.5499999999999999], "PARTICLE_57": {"MP_VELOCITY_X": [-0.06125222201131185], "MP_VELOCITY_Y": [0.0], "MP_VELOCITY_Z": [0.0], "MP_DISPLACEMENT_X": [0.004083861091415111], "MP_DISPLACEMENT_Y": [0.0], "MP_DISPLACEMENT_Z": [0.0]}} \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py b/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py index a95a25ed2794..bff3184677f9 100644 --- a/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py +++ b/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py @@ -90,4 +90,8 @@ class PenaltyImpositionBeamCantileverStaticHyperelasticSelfWeightLoad2DQuadTest( ### Slip Boundary Tests class SlipBoundaryTest(ParticleMechanicsTestFactory): - file_name = "slip_tests/slip_boundary_test" \ No newline at end of file + file_name = "slip_tests/slip_boundary_test" + +### Explicit time integration tests +class ExplicitOscillatingPointUSLTest(ParticleMechanicsTestFactory): + file_name = "explicit_tests/oscillating_point/usl_explicit_oscillating_point_test" \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py index 36bc2c9a65bc..59cdbe1d2e9d 100644 --- a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py +++ b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py @@ -28,6 +28,9 @@ from particle_mechanics_test_factory import SlipBoundaryTest as TSlipBoundaryTest +from particle_mechanics_test_factory import ExplicitOscillatingPointUSLTest as TExplicitOscillatingPointUSLTest + + # Import from Test Factories (with different analysis flows) from test_generate_mpm_particle import TestGenerateMPMParticle as TTestGenerateMPMParticle @@ -97,6 +100,8 @@ def AssembleTestSuites(): nightSuite.addTest(TBeamCantileverLinearStaticHyperelasticSelfWeightLoad2DQuadTest('test_execution')) + nightSuite.addTest(TExplicitOscillatingPointUSLTest('test_execution')) + ### Adding Validation Tests ## For very long tests that should not be in nighly and you can use to validate validationSuite = suites['validation'] From 775fc90ead627ae39718485a1b42462e64f46bed Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Mon, 6 Apr 2020 16:34:16 +1000 Subject: [PATCH 077/314] [skip ci] remove explicit scheme printout upon creation --- .../schemes/mpm_explicit_scheme.hpp | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp index ef3224b5186d..f667caec22c6 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp @@ -104,28 +104,6 @@ namespace Kratos { mStressUpdateOption(StressUpdateOption), mIsCentralDifference(isCentralDifference) { - std::cout << "Initializing MPM "; - if (mIsCentralDifference){ - std::cout << "central difference"; - } - else{ - std::cout << "forward Euler ("; - switch (mStressUpdateOption){ - case 0: - std::cout << "USF)"; - break; - case 1: - std::cout << "USL)"; - break; - case 2: - std::cout << "MUSL)"; - break; - default: - KRATOS_ERROR << "Invalid MPM explicit scheme constructed." << std::endl; - break; - } - } - std::cout << " explicit time integration scheme " << std::endl; } /// Destructor. From 1b94835015868e58c861a587b965318fbf55c233 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Mon, 6 Apr 2020 16:57:46 +1000 Subject: [PATCH 078/314] [skip ci] add remaining oscillating point explicit tests --- ...cit_oscillating_point_test_parameters.json | 91 +++++++++++++++++++ ...plicit_oscillating_point_test_results.json | 1 + ...cit_oscillating_point_test_parameters.json | 91 +++++++++++++++++++ ...plicit_oscillating_point_test_results.json | 1 + ...cit_oscillating_point_test_parameters.json | 91 +++++++++++++++++++ ...plicit_oscillating_point_test_results.json | 1 + .../tests/particle_mechanics_test_factory.py | 11 ++- .../test_ParticleMechanicsApplication.py | 6 ++ 8 files changed, 292 insertions(+), 1 deletion(-) create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/central_difference_explicit_oscillating_point_test_parameters.json create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/central_difference_explicit_oscillating_point_test_results.json create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/musl_explicit_oscillating_point_test_parameters.json create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/musl_explicit_oscillating_point_test_results.json create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usf_explicit_oscillating_point_test_parameters.json create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usf_explicit_oscillating_point_test_results.json diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/central_difference_explicit_oscillating_point_test_parameters.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/central_difference_explicit_oscillating_point_test_parameters.json new file mode 100644 index 000000000000..2f091746e11d --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/central_difference_explicit_oscillating_point_test_parameters.json @@ -0,0 +1,91 @@ +{ + "problem_data" : { + "problem_name" : "central_difference_explicit_oscillating_point_test", + "parallel_type" : "OpenMP", + "echo_level" : 0, + "start_time" : 0.0, + "end_time" : 0.5 + }, + "solver_settings" : { + "solver_type" : "Dynamic", + "model_part_name" : "MPM_Material", + "domain_size" : 2, + "echo_level" : 0, + "analysis_type" : "linear", + "time_integration_method" : "explicit", + "scheme_type" : "central_difference", + "stress_update" : "usl", + "compressible" : false, + "model_import_settings" : { + "input_type" : "mdpa", + "input_filename" : "explicit_tests/oscillating_point/explicit_oscillating_point_test_Body" + }, + "material_import_settings" : { + "materials_filename" : "explicit_tests/oscillating_point/explicit_oscillating_point_test_materials.json" + }, + "time_stepping" : { + "time_step" : 0.05 + }, + "convergence_criterion" : "residual_criterion", + "displacement_relative_tolerance" : 0.0001, + "displacement_absolute_tolerance" : 1e-9, + "residual_relative_tolerance" : 0.0001, + "residual_absolute_tolerance" : 1e-9, + "max_iteration" : 10, + "problem_domain_sub_model_part_list" : ["Parts_bar","Parts_grid"], + "processes_sub_model_part_list" : ["DISPLACEMENT_Displacement_Auto1"], + "grid_model_import_settings" : { + "input_type" : "mdpa", + "input_filename" : "explicit_tests/oscillating_point/explicit_oscillating_point_test_Grid" + }, + "pressure_dofs" : false + }, + "processes" : { + "constraints_process_list" : [{ + "python_module" : "assign_vector_variable_process", + "kratos_module" : "KratosMultiphysics", + "Parameters" : { + "model_part_name" : "Background_Grid.DISPLACEMENT_Displacement_Auto1", + "variable_name" : "DISPLACEMENT", + "constrained" : [true,true,true], + "value" : [0.0,0.0,0.0], + "interval" : [0.0,"End"] + } + }], + "loads_process_list" : [], + "list_other_processes" : [{ + "python_module" : "assign_initial_velocity_to_particle_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "Parameters" : { + "model_part_name" : "Parts_bar", + "variable_name" : "MP_VELOCITY", + "modulus" : 0.1, + "direction" : [1.0,0.0,0.0] + } + }, + { + "python_module" : "particle_from_json_check_result_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "help" : "", + "process_name" : "ParticleFromJsonCheckResultProcess", + "Parameters" : { + "check_variables" : ["MP_VELOCITY","MP_DISPLACEMENT"], + "input_file_name" : "explicit_tests/oscillating_point/central_difference_explicit_oscillating_point_test_results.json", + "model_part_name" : "MPM_Material", + "time_frequency" : 0.5 + } + }] + }, + "print_output_process" : [{ + "python_module" : "particle_json_output_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "help" : "", + "process_name" : "ParticleJsonOutputProcess", + "Parameters" : { + "gauss_points_output_variables" : ["MP_VELOCITY","MP_DISPLACEMENT"], + "output_file_name" : "explicit_tests/oscillating_point/central_difference_explicit_oscillating_point_test_results.json", + "model_part_name" : "MPM_Material", + "time_frequency" : 0.5 + } + }] +} diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/central_difference_explicit_oscillating_point_test_results.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/central_difference_explicit_oscillating_point_test_results.json new file mode 100644 index 000000000000..c11026dd5585 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/central_difference_explicit_oscillating_point_test_results.json @@ -0,0 +1 @@ +{"TIME": [0.5499999999999999], "PARTICLE_57": {"MP_VELOCITY_X": [-0.09465174631196166], "MP_VELOCITY_Y": [0.0], "MP_VELOCITY_Z": [0.0], "MP_DISPLACEMENT_X": [-0.002631334702967393], "MP_DISPLACEMENT_Y": [0.0], "MP_DISPLACEMENT_Z": [0.0]}} \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/musl_explicit_oscillating_point_test_parameters.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/musl_explicit_oscillating_point_test_parameters.json new file mode 100644 index 000000000000..de355dc56399 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/musl_explicit_oscillating_point_test_parameters.json @@ -0,0 +1,91 @@ +{ + "problem_data" : { + "problem_name" : "musl_explicit_oscillating_point_test", + "parallel_type" : "OpenMP", + "echo_level" : 0, + "start_time" : 0.0, + "end_time" : 0.5 + }, + "solver_settings" : { + "solver_type" : "Dynamic", + "model_part_name" : "MPM_Material", + "domain_size" : 2, + "echo_level" : 0, + "analysis_type" : "linear", + "time_integration_method" : "explicit", + "scheme_type" : "forward_euler", + "stress_update" : "musl", + "compressible" : false, + "model_import_settings" : { + "input_type" : "mdpa", + "input_filename" : "explicit_tests/oscillating_point/explicit_oscillating_point_test_Body" + }, + "material_import_settings" : { + "materials_filename" : "explicit_tests/oscillating_point/explicit_oscillating_point_test_materials.json" + }, + "time_stepping" : { + "time_step" : 0.05 + }, + "convergence_criterion" : "residual_criterion", + "displacement_relative_tolerance" : 0.0001, + "displacement_absolute_tolerance" : 1e-9, + "residual_relative_tolerance" : 0.0001, + "residual_absolute_tolerance" : 1e-9, + "max_iteration" : 10, + "problem_domain_sub_model_part_list" : ["Parts_bar","Parts_grid"], + "processes_sub_model_part_list" : ["DISPLACEMENT_Displacement_Auto1"], + "grid_model_import_settings" : { + "input_type" : "mdpa", + "input_filename" : "explicit_tests/oscillating_point/explicit_oscillating_point_test_Grid" + }, + "pressure_dofs" : false + }, + "processes" : { + "constraints_process_list" : [{ + "python_module" : "assign_vector_variable_process", + "kratos_module" : "KratosMultiphysics", + "Parameters" : { + "model_part_name" : "Background_Grid.DISPLACEMENT_Displacement_Auto1", + "variable_name" : "DISPLACEMENT", + "constrained" : [true,true,true], + "value" : [0.0,0.0,0.0], + "interval" : [0.0,"End"] + } + }], + "loads_process_list" : [], + "list_other_processes" : [{ + "python_module" : "assign_initial_velocity_to_particle_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "Parameters" : { + "model_part_name" : "Parts_bar", + "variable_name" : "MP_VELOCITY", + "modulus" : 0.1, + "direction" : [1.0,0.0,0.0] + } + }, + { + "python_module" : "particle_from_json_check_result_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "help" : "", + "process_name" : "ParticleFromJsonCheckResultProcess", + "Parameters" : { + "check_variables" : ["MP_VELOCITY","MP_DISPLACEMENT"], + "input_file_name" : "explicit_tests/oscillating_point/musl_explicit_oscillating_point_test_results.json", + "model_part_name" : "MPM_Material", + "time_frequency" : 0.5 + } + }] + }, + "print_output_process" : [{ + "python_module" : "particle_json_output_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "help" : "", + "process_name" : "ParticleJsonOutputProcess", + "Parameters" : { + "gauss_points_output_variables" : ["MP_VELOCITY","MP_DISPLACEMENT"], + "output_file_name" : "explicit_tests/oscillating_point/musl_explicit_oscillating_point_test_results.json", + "model_part_name" : "MPM_Material", + "time_frequency" : 0.5 + } + }] +} diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/musl_explicit_oscillating_point_test_results.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/musl_explicit_oscillating_point_test_results.json new file mode 100644 index 000000000000..6023a1aa9154 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/musl_explicit_oscillating_point_test_results.json @@ -0,0 +1 @@ +{"TIME": [0.5499999999999999], "PARTICLE_57": {"MP_VELOCITY_X": [-0.09978366929917684], "MP_VELOCITY_Y": [0.0], "MP_VELOCITY_Z": [0.0], "MP_DISPLACEMENT_X": [-0.005199725114259626], "MP_DISPLACEMENT_Y": [0.0], "MP_DISPLACEMENT_Z": [0.0]}} \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usf_explicit_oscillating_point_test_parameters.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usf_explicit_oscillating_point_test_parameters.json new file mode 100644 index 000000000000..db565f57254c --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usf_explicit_oscillating_point_test_parameters.json @@ -0,0 +1,91 @@ +{ + "problem_data" : { + "problem_name" : "usf_explicit_oscillating_point_test", + "parallel_type" : "OpenMP", + "echo_level" : 0, + "start_time" : 0.0, + "end_time" : 0.5 + }, + "solver_settings" : { + "solver_type" : "Dynamic", + "model_part_name" : "MPM_Material", + "domain_size" : 2, + "echo_level" : 0, + "analysis_type" : "linear", + "time_integration_method" : "explicit", + "scheme_type" : "forward_euler", + "stress_update" : "usf", + "compressible" : false, + "model_import_settings" : { + "input_type" : "mdpa", + "input_filename" : "explicit_tests/oscillating_point/explicit_oscillating_point_test_Body" + }, + "material_import_settings" : { + "materials_filename" : "explicit_tests/oscillating_point/explicit_oscillating_point_test_materials.json" + }, + "time_stepping" : { + "time_step" : 0.05 + }, + "convergence_criterion" : "residual_criterion", + "displacement_relative_tolerance" : 0.0001, + "displacement_absolute_tolerance" : 1e-9, + "residual_relative_tolerance" : 0.0001, + "residual_absolute_tolerance" : 1e-9, + "max_iteration" : 10, + "problem_domain_sub_model_part_list" : ["Parts_bar","Parts_grid"], + "processes_sub_model_part_list" : ["DISPLACEMENT_Displacement_Auto1"], + "grid_model_import_settings" : { + "input_type" : "mdpa", + "input_filename" : "explicit_tests/oscillating_point/explicit_oscillating_point_test_Grid" + }, + "pressure_dofs" : false + }, + "processes" : { + "constraints_process_list" : [{ + "python_module" : "assign_vector_variable_process", + "kratos_module" : "KratosMultiphysics", + "Parameters" : { + "model_part_name" : "Background_Grid.DISPLACEMENT_Displacement_Auto1", + "variable_name" : "DISPLACEMENT", + "constrained" : [true,true,true], + "value" : [0.0,0.0,0.0], + "interval" : [0.0,"End"] + } + }], + "loads_process_list" : [], + "list_other_processes" : [{ + "python_module" : "assign_initial_velocity_to_particle_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "Parameters" : { + "model_part_name" : "Parts_bar", + "variable_name" : "MP_VELOCITY", + "modulus" : 0.1, + "direction" : [1.0,0.0,0.0] + } + }, + { + "python_module" : "particle_from_json_check_result_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "help" : "", + "process_name" : "ParticleFromJsonCheckResultProcess", + "Parameters" : { + "check_variables" : ["MP_VELOCITY","MP_DISPLACEMENT"], + "input_file_name" : "explicit_tests/oscillating_point/usf_explicit_oscillating_point_test_results.json", + "model_part_name" : "MPM_Material", + "time_frequency" : 0.5 + } + }] + }, + "print_output_process" : [{ + "python_module" : "particle_json_output_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "help" : "", + "process_name" : "ParticleJsonOutputProcess", + "Parameters" : { + "gauss_points_output_variables" : ["MP_VELOCITY","MP_DISPLACEMENT"], + "output_file_name" : "explicit_tests/oscillating_point/usf_explicit_oscillating_point_test_results.json", + "model_part_name" : "MPM_Material", + "time_frequency" : 0.5 + } + }] +} diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usf_explicit_oscillating_point_test_results.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usf_explicit_oscillating_point_test_results.json new file mode 100644 index 000000000000..404c3ae48a2a --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usf_explicit_oscillating_point_test_results.json @@ -0,0 +1 @@ +{"TIME": [0.5499999999999999], "PARTICLE_57": {"MP_VELOCITY_X": [-0.08951982332474648], "MP_VELOCITY_Y": [0.0], "MP_VELOCITY_Z": [0.0], "MP_DISPLACEMENT_X": [-0.014675716280496952], "MP_DISPLACEMENT_Y": [0.0], "MP_DISPLACEMENT_Z": [0.0]}} \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py b/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py index bff3184677f9..18e1dccda543 100644 --- a/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py +++ b/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py @@ -94,4 +94,13 @@ class SlipBoundaryTest(ParticleMechanicsTestFactory): ### Explicit time integration tests class ExplicitOscillatingPointUSLTest(ParticleMechanicsTestFactory): - file_name = "explicit_tests/oscillating_point/usl_explicit_oscillating_point_test" \ No newline at end of file + file_name = "explicit_tests/oscillating_point/usl_explicit_oscillating_point_test" + +class ExplicitOscillatingPointUSFTest(ParticleMechanicsTestFactory): + file_name = "explicit_tests/oscillating_point/usf_explicit_oscillating_point_test" + +class ExplicitOscillatingPointMUSLTest(ParticleMechanicsTestFactory): + file_name = "explicit_tests/oscillating_point/musl_explicit_oscillating_point_test" + +class ExplicitOscillatingPointCentralDifferenceTest(ParticleMechanicsTestFactory): + file_name = "explicit_tests/oscillating_point/central_difference_explicit_oscillating_point_test" \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py index 59cdbe1d2e9d..fbb65ae14c3f 100644 --- a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py +++ b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py @@ -29,6 +29,9 @@ from particle_mechanics_test_factory import SlipBoundaryTest as TSlipBoundaryTest from particle_mechanics_test_factory import ExplicitOscillatingPointUSLTest as TExplicitOscillatingPointUSLTest +from particle_mechanics_test_factory import ExplicitOscillatingPointUSFTest as TExplicitOscillatingPointUSFTest +from particle_mechanics_test_factory import ExplicitOscillatingPointMUSLTest as TExplicitOscillatingPointMUSLTest +from particle_mechanics_test_factory import ExplicitOscillatingPointCentralDifferenceTest as TExplicitOscillatingPointCentralDifferenceTest @@ -101,6 +104,9 @@ def AssembleTestSuites(): nightSuite.addTest(TBeamCantileverLinearStaticHyperelasticSelfWeightLoad2DQuadTest('test_execution')) nightSuite.addTest(TExplicitOscillatingPointUSLTest('test_execution')) + nightSuite.addTest(TExplicitOscillatingPointUSFTest('test_execution')) + nightSuite.addTest(TExplicitOscillatingPointMUSLTest('test_execution')) + nightSuite.addTest(TExplicitOscillatingPointCentralDifferenceTest('test_execution')) ### Adding Validation Tests ## For very long tests that should not be in nighly and you can use to validate From 2f670a9cd023383c34299b3ce28ad50d4561e631 Mon Sep 17 00:00:00 2001 From: pooyan Date: Mon, 6 Apr 2020 11:37:29 +0200 Subject: [PATCH 079/314] Fixing fluid dynamic app tests --- kratos/processes/apply_constant_vectorvalue_process.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kratos/processes/apply_constant_vectorvalue_process.h b/kratos/processes/apply_constant_vectorvalue_process.h index a76db37f23b9..48996db723ed 100644 --- a/kratos/processes/apply_constant_vectorvalue_process.h +++ b/kratos/processes/apply_constant_vectorvalue_process.h @@ -148,7 +148,7 @@ class ApplyConstantVectorValueProcess : public Process KRATOS_THROW_ERROR(std::runtime_error,"Direction vector is expected to have size 3. Direction vector currently passed",mdirection); } - typedef VariableComponent< VectorComponentAdaptor > > component_type; + typedef Variable component_type; if(KratosComponents< component_type >::Has(mvariable_name+std::string("_X")) == false) { KRATOS_THROW_ERROR(std::runtime_error,"Not defined the variable ",mvariable_name+std::string("_X")); @@ -207,7 +207,7 @@ class ApplyConstantVectorValueProcess : public Process KRATOS_THROW_ERROR(std::runtime_error,"Direction vector is expected to have size 3. Direction vector currently passed",mdirection); } - typedef VariableComponent< VectorComponentAdaptor > > component_type; + typedef Variable component_type; if(KratosComponents< component_type >::Has(mvariable_name+std::string("_X")) == false) { KRATOS_THROW_ERROR(std::runtime_error,"Not defined the variable ",mvariable_name+std::string("_X")); @@ -255,7 +255,7 @@ class ApplyConstantVectorValueProcess : public Process { //compute the value to be applied array_1d value = mmodulus*mdirection; - typedef VariableComponent< VectorComponentAdaptor > > component_type; + typedef Variable component_type; component_type varx = KratosComponents< component_type >::Get(mvariable_name+std::string("_X")); component_type vary = KratosComponents< component_type >::Get(mvariable_name+std::string("_Y")); From 33c8bc490c69955a1f0992f4a19bc2d6c392d0c7 Mon Sep 17 00:00:00 2001 From: pooyan Date: Mon, 6 Apr 2020 12:35:43 +0200 Subject: [PATCH 080/314] Fixing adjoint tests --- .../adjoint_nodal_displacement_response_function.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/StructuralMechanicsApplication/custom_response_functions/response_utilities/adjoint_nodal_displacement_response_function.h b/applications/StructuralMechanicsApplication/custom_response_functions/response_utilities/adjoint_nodal_displacement_response_function.h index 3b0e0690d35b..29f7be26efce 100644 --- a/applications/StructuralMechanicsApplication/custom_response_functions/response_utilities/adjoint_nodal_displacement_response_function.h +++ b/applications/StructuralMechanicsApplication/custom_response_functions/response_utilities/adjoint_nodal_displacement_response_function.h @@ -56,7 +56,7 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) AdjointNodalDisplacementRespo typedef Element::DofsVectorType DofsVectorType; typedef Node<3>::Pointer PointTypePointer; - typedef VariableComponent>> VariableComponentType; + typedef Variable VariableComponentType; ///@} ///@name Pointer Definitions From 8eae19ce63841cc7ae991201b7e4a44d5124cd5f Mon Sep 17 00:00:00 2001 From: philbucher Date: Mon, 6 Apr 2020 16:33:52 +0200 Subject: [PATCH 081/314] fixing MeshMovingApp --- .../strategies/laplacian_meshmoving_strategy.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/applications/MeshMovingApplication/custom_strategies/strategies/laplacian_meshmoving_strategy.h b/applications/MeshMovingApplication/custom_strategies/strategies/laplacian_meshmoving_strategy.h index 753fa936aa41..3a77c4140450 100644 --- a/applications/MeshMovingApplication/custom_strategies/strategies/laplacian_meshmoving_strategy.h +++ b/applications/MeshMovingApplication/custom_strategies/strategies/laplacian_meshmoving_strategy.h @@ -100,9 +100,7 @@ class LaplacianMeshMovingStrategy mpmesh_model_part = MoveMeshUtilities::GenerateMeshPart( BaseType::GetModelPart(), element_type); - typedef typename Kratos::VariableComponent< - Kratos::VectorComponentAdaptor>> - VarComponent; + typedef Variable VarComponent; mpbuilder_and_solver_x = typename TBuilderAndSolverType::Pointer( new ResidualBasedEliminationBuilderAndSolverComponentwise< From b1ffb58361f65f4e455c6709e5eac0908364f590 Mon Sep 17 00:00:00 2001 From: philbucher Date: Mon, 6 Apr 2020 16:40:28 +0200 Subject: [PATCH 082/314] cleanup and fix MappingApp --- .../custom_mappers/interpolative_mapper_base.h | 2 +- .../interface_vector_container.cpp | 18 ++---------------- .../interface_vector_container.h | 13 ++----------- .../interface_vector_container_mpi.cpp | 18 ++---------------- 4 files changed, 7 insertions(+), 44 deletions(-) diff --git a/applications/MappingApplication/custom_mappers/interpolative_mapper_base.h b/applications/MappingApplication/custom_mappers/interpolative_mapper_base.h index c2a1324bf459..ee6ed3ef2a1f 100644 --- a/applications/MappingApplication/custom_mappers/interpolative_mapper_base.h +++ b/applications/MappingApplication/custom_mappers/interpolative_mapper_base.h @@ -60,7 +60,7 @@ class InterpolativeMapperBase : public Mapper typedef typename BaseType::TMappingMatrixType TMappingMatrixType; typedef Kratos::unique_ptr TMappingMatrixUniquePointerType; - typedef VariableComponent< VectorComponentAdaptor > > ComponentVariableType; + typedef Variable ComponentVariableType; ///@} ///@name Life Cycle diff --git a/applications/MappingApplication/custom_utilities/interface_vector_container.cpp b/applications/MappingApplication/custom_utilities/interface_vector_container.cpp index 69183b336721..63e70cced4f7 100644 --- a/applications/MappingApplication/custom_utilities/interface_vector_container.cpp +++ b/applications/MappingApplication/custom_utilities/interface_vector_container.cpp @@ -33,28 +33,14 @@ typedef InterfaceVectorContainer VectorContaine /* PUBLIC Methods */ /***********************************************************************************/ template<> -void VectorContainerType::UpdateSystemVectorFromModelPart(const DoubleVariableType& rVariable, +void VectorContainerType::UpdateSystemVectorFromModelPart(const Variable& rVariable, const Kratos::Flags& rMappingOptions) { MapperUtilities::UpdateSystemVectorFromModelPart(*mpInterfaceVector, mrModelPart, rVariable, rMappingOptions); } template<> -void VectorContainerType::UpdateSystemVectorFromModelPart(const ComponentVariableType& rVariable, - const Kratos::Flags& rMappingOptions) -{ - MapperUtilities::UpdateSystemVectorFromModelPart(*mpInterfaceVector, mrModelPart, rVariable, rMappingOptions); -} - -template<> -void VectorContainerType::UpdateModelPartFromSystemVector(const DoubleVariableType& rVariable, - const Kratos::Flags& rMappingOptions) -{ - MapperUtilities::UpdateModelPartFromSystemVector(*mpInterfaceVector, mrModelPart, rVariable, rMappingOptions); -} - -template<> -void VectorContainerType::UpdateModelPartFromSystemVector(const ComponentVariableType& rVariable, +void VectorContainerType::UpdateModelPartFromSystemVector(const Variable& rVariable, const Kratos::Flags& rMappingOptions) { MapperUtilities::UpdateModelPartFromSystemVector(*mpInterfaceVector, mrModelPart, rVariable, rMappingOptions); diff --git a/applications/MappingApplication/custom_utilities/interface_vector_container.h b/applications/MappingApplication/custom_utilities/interface_vector_container.h index 40961a757b80..1dcc45b70e0c 100644 --- a/applications/MappingApplication/custom_utilities/interface_vector_container.h +++ b/applications/MappingApplication/custom_utilities/interface_vector_container.h @@ -53,9 +53,6 @@ class InterfaceVectorContainer typedef Kratos::unique_ptr TSystemVectorUniquePointerType; - typedef Variable DoubleVariableType; - typedef VariableComponent< VectorComponentAdaptor > > ComponentVariableType; - ///@} ///@name Life Cycle ///@{ @@ -71,16 +68,10 @@ class InterfaceVectorContainer ///@name Operations ///@{ - void UpdateSystemVectorFromModelPart(const DoubleVariableType& rVariable, - const Kratos::Flags& rMappingOptions); - - void UpdateSystemVectorFromModelPart(const ComponentVariableType& rVariable, - const Kratos::Flags& rMappingOptions); - - void UpdateModelPartFromSystemVector(const DoubleVariableType& rVariable, + void UpdateSystemVectorFromModelPart(const Variable& rVariable, const Kratos::Flags& rMappingOptions); - void UpdateModelPartFromSystemVector(const ComponentVariableType& rVariable, + void UpdateModelPartFromSystemVector(const Variable& rVariable, const Kratos::Flags& rMappingOptions); ///@} diff --git a/applications/MappingApplication/custom_utilities/interface_vector_container_mpi.cpp b/applications/MappingApplication/custom_utilities/interface_vector_container_mpi.cpp index 8834ab315c9f..9a2c6df75ee4 100644 --- a/applications/MappingApplication/custom_utilities/interface_vector_container_mpi.cpp +++ b/applications/MappingApplication/custom_utilities/interface_vector_container_mpi.cpp @@ -33,28 +33,14 @@ typedef InterfaceVectorContainer VectorContaine /* PUBLIC Methods */ /***********************************************************************************/ template<> -void VectorContainerType::UpdateSystemVectorFromModelPart(const DoubleVariableType& rVariable, +void VectorContainerType::UpdateSystemVectorFromModelPart(const Variable& rVariable, const Kratos::Flags& rMappingOptions) { MapperUtilities::UpdateSystemVectorFromModelPart((*mpInterfaceVector)[0], mrModelPart, rVariable, rMappingOptions); } template<> -void VectorContainerType::UpdateSystemVectorFromModelPart(const ComponentVariableType& rVariable, - const Kratos::Flags& rMappingOptions) -{ - MapperUtilities::UpdateSystemVectorFromModelPart((*mpInterfaceVector)[0], mrModelPart, rVariable, rMappingOptions); -} - -template<> -void VectorContainerType::UpdateModelPartFromSystemVector(const DoubleVariableType& rVariable, - const Kratos::Flags& rMappingOptions) -{ - MapperUtilities::UpdateModelPartFromSystemVector((*mpInterfaceVector)[0], mrModelPart, rVariable, rMappingOptions); -} - -template<> -void VectorContainerType::UpdateModelPartFromSystemVector(const ComponentVariableType& rVariable, +void VectorContainerType::UpdateModelPartFromSystemVector(const Variable& rVariable, const Kratos::Flags& rMappingOptions) { MapperUtilities::UpdateModelPartFromSystemVector((*mpInterfaceVector)[0], mrModelPart, rVariable, rMappingOptions); From 9df6186addd8952c22158b5e83c51c7983356a04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Mon, 6 Apr 2020 16:58:09 +0200 Subject: [PATCH 083/314] Fix compilation --- kratos/containers/variable_component.h | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/kratos/containers/variable_component.h b/kratos/containers/variable_component.h index 258237d89f5a..b910fd9ba6b7 100644 --- a/kratos/containers/variable_component.h +++ b/kratos/containers/variable_component.h @@ -16,16 +16,12 @@ #if !defined(KRATOS_VARIABLE_COMPONENT_H_INCLUDED ) #define KRATOS_VARIABLE_COMPONENT_H_INCLUDED - - // System includes #include #include - // External includes - // Project includes #include "includes/define.h" #include "containers/variable_data.h" @@ -101,8 +97,7 @@ class VariableComponent : public VariableData const AdaptorType& rNewAdaptor, const VariableComponentType* pTimeDerivativeVariable = nullptr ) - : BaseType(rComponentName, sizeof(DataType),&rNewAdaptor.GetSourceVariable(), rNewAdaptor.GetComponentIndex()), mpSourceVariable(&NewAdaptor.GetSourceVariable()), - mAdaptor(rNewAdaptor), + : BaseType(rComponentName, sizeof(DataType),&rNewAdaptor.GetSourceVariable(), rNewAdaptor.GetComponentIndex()), mpSourceVariable(&rNewAdaptor.GetSourceVariable()), mpTimeDerivativeVariable(pTimeDerivativeVariable) { SetKey(GenerateKey(rSourceName, sizeof(DataType), true, ComponentIndex)); @@ -248,7 +243,6 @@ class VariableComponent : public VariableData static const VariableComponent msStaticObject; - ///@} ///@name Member Variables ///@{ From c26ddecd5f6e2c3fc62f9ab8c1bbea4f2fba55c9 Mon Sep 17 00:00:00 2001 From: Inigo Lopez Date: Mon, 6 Apr 2020 17:01:51 +0200 Subject: [PATCH 084/314] ommit output file --- .../fsi_sdof_static/naca0012_small_parameters_coupling.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/CoSimulationApplication/tests/fsi_sdof_static/naca0012_small_parameters_coupling.json b/applications/CoSimulationApplication/tests/fsi_sdof_static/naca0012_small_parameters_coupling.json index a524aae74484..8ae659b0fb84 100644 --- a/applications/CoSimulationApplication/tests/fsi_sdof_static/naca0012_small_parameters_coupling.json +++ b/applications/CoSimulationApplication/tests/fsi_sdof_static/naca0012_small_parameters_coupling.json @@ -71,7 +71,7 @@ "process_name" : "ComputeForcesOnNodesProcess", "Parameters" : { "model_part_name" : "FluidModelPart.Body2D_Body", - "create_output_file": true + "create_output_file": false } },{ "python_module" : "fix_vector_variable_process", From b9dbfcb321938ca30d76f57a0e0ce4d67d2edd9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Mon, 6 Apr 2020 17:42:54 +0200 Subject: [PATCH 085/314] Missing --- kratos/containers/variable.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kratos/containers/variable.h b/kratos/containers/variable.h index 91be22d12dd4..5c0afe3e8ef2 100644 --- a/kratos/containers/variable.h +++ b/kratos/containers/variable.h @@ -127,7 +127,12 @@ class Variable : public VariableData * @brief Copy constructor. * @param rOtherVariable The old variable to be copied */ - Variable(const VariableType& rOtherVariable) : VariableData(rOtherVariable), mZero(rOtherVariable.mZero) {} + Variable(const VariableType& rOtherVariable) : + VariableData(rOtherVariable), + mZero(rOtherVariable.mZero), + mpTimeDerivativeVariable(rOtherVariable.mpTimeDerivativeVariable) + { + } /// Destructor. ~Variable() override {} From 1a34edf903d4383abea2be5d3140e8d00e6e6df2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Mon, 6 Apr 2020 17:44:00 +0200 Subject: [PATCH 086/314] Fix macro --- kratos/includes/define.h | 100 +++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/kratos/includes/define.h b/kratos/includes/define.h index 630bf80928e6..689ebf3b0f1d 100644 --- a/kratos/includes/define.h +++ b/kratos/includes/define.h @@ -502,14 +502,14 @@ catch(...) { Block KRATOS_THROW_ERROR(std::runtime_error, "Unknown error", MoreI #define KRATOS_CREATE_3D_VARIABLE_WITH_THIS_COMPONENTS_WITH_TIME_DERIVATIVE(name, component1, component2, component3, variable_derivative) \ /*const*/ Kratos::Variable > name(#name, Kratos::array_1d(Kratos::ZeroVector(3)), &variable_derivative); \ \ - /*const*/ Kratos::VariableComponent > > \ - component1(#component1, #name, 0, Kratos::VectorComponentAdaptor >(name, 0), &variable_derivative##_X); \ + /*const*/ Kratos::Variable \ + component1(#component1, #name, 0, &variable_derivative##_X); \ \ - /*const*/ Kratos::VariableComponent > > \ - component2(#component2, #name, 1, Kratos::VectorComponentAdaptor >(name, 1), &variable_derivative##_Y); \ + /*const*/ Kratos::Variable \ + component2(#component2, #name, 1, &variable_derivative##_Y); \ \ - /*const*/ Kratos::VariableComponent > > \ - component3(#component3, #name, 2, Kratos::VectorComponentAdaptor >(name, 2), &variable_derivative##_Z); + /*const*/ Kratos::Variable \ + component3(#component3, #name, 2, &variable_derivative##_Z); #ifdef KRATOS_CREATE_3D_VARIABLE_WITH_COMPONENTS_WITH_TIME_DERIVATIVE #undef KRATOS_CREATE_3D_VARIABLE_WITH_COMPONENTS_WITH_TIME_DERIVATIVE @@ -523,14 +523,14 @@ catch(...) { Block KRATOS_THROW_ERROR(std::runtime_error, "Unknown error", MoreI #define KRATOS_CREATE_SYMMETRIC_2D_TENSOR_VARIABLE_WITH_THIS_COMPONENTS_WITH_TIME_DERIVATIVE(name, component1, component2, component3, variable_derivative) \ /*const*/ Kratos::Variable > name(#name, Kratos::zero_vector(3), &variable_derivative); \ \ - /*const*/ Kratos::VariableComponent > > \ - component1(#component1, #name, 0, Kratos::VectorComponentAdaptor >(name, 0), &variable_derivative##_XX); \ + /*const*/ Kratos::Variable \ + component1(#component1, #name, 0, &variable_derivative##_XX); \ \ - /*const*/ Kratos::VariableComponent > > \ - component2(#component2, #name, 1, Kratos::VectorComponentAdaptor >(name, 1), &variable_derivative##_YY); \ + /*const*/ Kratos::Variable \ + component2(#component2, #name, 1, &variable_derivative##_YY); \ \ - /*const*/ Kratos::VariableComponent > > \ - component3(#component3, #name, 2, Kratos::VectorComponentAdaptor >(name, 2), &variable_derivative##_XY); + /*const*/ Kratos::Variable \ + component3(#component3, #name, 2, &variable_derivative##_XY); #ifdef KRATOS_CREATE_SYMMETRIC_2D_TENSOR_VARIABLE_WITH_COMPONENTS_WITH_TIME_DERIVATIVE #undef KRATOS_CREATE_SYMMETRIC_2D_TENSOR_VARIABLE_WITH_COMPONENTS_WITH_TIME_DERIVATIVE @@ -544,23 +544,23 @@ catch(...) { Block KRATOS_THROW_ERROR(std::runtime_error, "Unknown error", MoreI #define KRATOS_CREATE_SYMMETRIC_3D_TENSOR_VARIABLE_WITH_THIS_COMPONENTS_WITH_TIME_DERIVATIVE(name, component1, component2, component3, component4, component5, component6, variable_derivative) \ /*const*/ Kratos::Variable > name(#name, Kratos::zero_vector(6), &variable_derivative); \ \ - /*const*/ Kratos::VariableComponent > > \ - component1(#component1, #name, 0, Kratos::VectorComponentAdaptor >(name, 0), &variable_derivative##_XX); \ + /*const*/ Kratos::Variable \ + component1(#component1, #name, 0, &variable_derivative##_XX); \ \ - /*const*/ Kratos::VariableComponent > > \ - component2(#component2, #name, 1, Kratos::VectorComponentAdaptor >(name, 1), &variable_derivative##_YY); \ + /*const*/ Kratos::Variable \ + component2(#component2, #name, 1, &variable_derivative##_YY); \ \ - /*const*/ Kratos::VariableComponent > > \ - component3(#component3, #name, 2, Kratos::VectorComponentAdaptor >(name, 2), &variable_derivative##_ZZ); \ + /*const*/ Kratos::Variable \ + component3(#component3, #name, 2, &variable_derivative##_ZZ); \ \ - /*const*/ Kratos::VariableComponent > > \ - component4(#component4, #name, 3, Kratos::VectorComponentAdaptor >(name, 3), &variable_derivative##_XY); \ + /*const*/ Kratos::Variable \ + component4(#component4, #name, 3, &variable_derivative##_XY); \ \ - /*const*/ Kratos::VariableComponent > > \ - component5(#component5, #name, 4, Kratos::VectorComponentAdaptor >(name, 4), &variable_derivative##_YZ); \ + /*const*/ Kratos::Variable \ + component5(#component5, #name, 4, &variable_derivative##_YZ); \ \ - /*const*/ Kratos::VariableComponent > > \ - component6(#component6, #name, 5, Kratos::VectorComponentAdaptor >(name, 5), &variable_derivative##_XZ); + /*const*/ Kratos::Variable \ + component6(#component6, #name, 5, &variable_derivative##_XZ); #ifdef KRATOS_CREATE_SYMMETRIC_3D_TENSOR_VARIABLE_WITH_COMPONENTS_WITH_TIME_DERIVATIVE #undef KRATOS_CREATE_SYMMETRIC_3D_TENSOR_VARIABLE_WITH_COMPONENTS_WITH_TIME_DERIVATIVE @@ -574,17 +574,17 @@ catch(...) { Block KRATOS_THROW_ERROR(std::runtime_error, "Unknown error", MoreI #define KRATOS_CREATE_2D_TENSOR_VARIABLE_WITH_THIS_COMPONENTS_WITH_TIME_DERIVATIVE(name, component1, component2, component3, component4, variable_derivative) \ /*const*/ Kratos::Variable > name(#name, Kratos::zero_vector(4), &variable_derivative); \ \ - /*const*/ Kratos::VariableComponent > > \ - component1(#component1, #name, 0, Kratos::VectorComponentAdaptor >(name, 0), &variable_derivative##_XX); \ + /*const*/ Kratos::Variable \ + component1(#component1, #name, 0, &variable_derivative##_XX); \ \ - /*const*/ Kratos::VariableComponent > > \ - component2(#component2, #name, 1, Kratos::VectorComponentAdaptor >(name, 1), &variable_derivative##_XY); \ + /*const*/ Kratos::Variable \ + component2(#component2, #name, 1, &variable_derivative##_XY); \ \ - /*const*/ Kratos::VariableComponent > > \ - component3(#component3, #name, 2, Kratos::VectorComponentAdaptor >(name, 2), &variable_derivative##_YX); \ + /*const*/ Kratos::Variable \ + component3(#component3, #name, 2, &variable_derivative##_YX); \ \ - /*const*/ Kratos::VariableComponent > > \ - component4(#component4, #name, 3, Kratos::VectorComponentAdaptor >(name, 3), &variable_derivative##_YY); + /*const*/ Kratos::Variable \ + component4(#component4, #name, 3, &variable_derivative##_YY); #ifdef KRATOS_CREATE_2D_TENSOR_VARIABLE_WITH_COMPONENTS_WITH_TIME_DERIVATIVE #undef KRATOS_CREATE_2D_TENSOR_VARIABLE_WITH_COMPONENTS_WITH_TIME_DERIVATIVE @@ -598,32 +598,32 @@ catch(...) { Block KRATOS_THROW_ERROR(std::runtime_error, "Unknown error", MoreI #define KRATOS_CREATE_3D_TENSOR_VARIABLE_WITH_THIS_COMPONENTS_WITH_TIME_DERIVATIVE(name, component1, component2, component3, component4, component5, component6, component7, component8, component9, variable_derivative) \ /*const*/ Kratos::Variable > name(#name, Kratos::zero_vector(9), &variable_derivative); \ \ - /*const*/ Kratos::VariableComponent > > \ - component1(#component1, #name, 0, Kratos::VectorComponentAdaptor >(name, 0), &variable_derivative##_XX); \ + /*const*/ Kratos::Variable \ + component1(#component1, #name, 0, &variable_derivative##_XX); \ \ - /*const*/ Kratos::VariableComponent > > \ - component2(#component2, #name, 1, Kratos::VectorComponentAdaptor >(name, 1), &variable_derivative##_XY); \ + /*const*/ Kratos::Variable \ + component2(#component2, #name, 1, &variable_derivative##_XY); \ \ - /*const*/ Kratos::VariableComponent > > \ - component3(#component3, #name, 2, Kratos::VectorComponentAdaptor >(name, 2), &variable_derivative##_XZ); \ + /*const*/ Kratos::Variable \ + component3(#component3, #name, 2, &variable_derivative##_XZ); \ \ - /*const*/ Kratos::VariableComponent > > \ - component4(#component4, #name, 3, Kratos::VectorComponentAdaptor >(name, 3), &variable_derivative##_YX); \ + /*const*/ Kratos::Variable \ + component4(#component4, #name, 3, &variable_derivative##_YX); \ \ - /*const*/ Kratos::VariableComponent > > \ - component5(#component5, #name, 4, Kratos::VectorComponentAdaptor >(name, 4), &variable_derivative##_YY); \ + /*const*/ Kratos::Variable \ + component5(#component5, #name, 4, &variable_derivative##_YY); \ \ - /*const*/ Kratos::VariableComponent > > \ - component6(#component6, #name, 5, Kratos::VectorComponentAdaptor >(name, 5), &variable_derivative##_YZ); \ + /*const*/ Kratos::Variable \ + component6(#component6, #name, 5, &variable_derivative##_YZ); \ \ - /*const*/ Kratos::VariableComponent > > \ - component7(#component7, #name, 6, Kratos::VectorComponentAdaptor >(name, 6), &variable_derivative##_ZX); \ + /*const*/ Kratos::Variable \ + component7(#component7, #name, 6, &variable_derivative##_ZX); \ \ - /*const*/ Kratos::VariableComponent > > \ - component8(#component8, #name, 7, Kratos::VectorComponentAdaptor >(name, 7), &variable_derivative##_ZY); \ + /*const*/ Kratos::Variable \ + component8(#component8, #name, 7, &variable_derivative##_ZY); \ \ - /*const*/ Kratos::VariableComponent > > \ - component9(#component9, #name, 8, Kratos::VectorComponentAdaptor >(name, 8), &variable_derivative##_ZZ); + /*const*/ Kratos::Variable \ + component9(#component9, #name, 8, &variable_derivative##_ZZ); #ifdef KRATOS_CREATE_3D_TENSOR_VARIABLE_WITH_COMPONENTS_WITH_TIME_DERIVATIVE #undef KRATOS_CREATE_3D_TENSOR_VARIABLE_WITH_COMPONENTS_WITH_TIME_DERIVATIVE From e2fc665aafeffc2ace666cf80b39bab92284f3a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Mon, 6 Apr 2020 17:55:15 +0200 Subject: [PATCH 087/314] Minor --- kratos/containers/variable.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/kratos/containers/variable.h b/kratos/containers/variable.h index 5c0afe3e8ef2..13775d6c25e3 100644 --- a/kratos/containers/variable.h +++ b/kratos/containers/variable.h @@ -113,12 +113,18 @@ class Variable : public VariableData /** * @brief Constructor for creating a component of other variable - * @param NewName The name to be assigned to the compoenent + * @param rNewName The name to be assigned to the compoenent * @param Zero The value to be assigned to the variable as zero. In case of not definition will take the value given by the constructor of the time */ template - explicit Variable(const std::string& NewName, TSourceVariableType* pSourceVariable, char ComponentIndex, const TDataType Zero = TDataType()) - : VariableData(NewName, sizeof(TDataType), pSourceVariable, ComponentIndex), mZero(Zero) + explicit Variable( + const std::string& rNewName, + TSourceVariableType* pSourceVariable, + char ComponentIndex, + const TDataType Zero = TDataType() + ) + : VariableData(rNewName, sizeof(TDataType), pSourceVariable, ComponentIndex), + mZero(Zero) { } From e19a2c632c017f4405c68409e53bb69673385749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Mon, 6 Apr 2020 18:22:11 +0200 Subject: [PATCH 088/314] Typo --- kratos/includes/define.h | 50 ++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/kratos/includes/define.h b/kratos/includes/define.h index 689ebf3b0f1d..f20c474fedae 100644 --- a/kratos/includes/define.h +++ b/kratos/includes/define.h @@ -503,13 +503,13 @@ catch(...) { Block KRATOS_THROW_ERROR(std::runtime_error, "Unknown error", MoreI /*const*/ Kratos::Variable > name(#name, Kratos::array_1d(Kratos::ZeroVector(3)), &variable_derivative); \ \ /*const*/ Kratos::Variable \ - component1(#component1, #name, 0, &variable_derivative##_X); \ + component1(#component1, &name, 0, &variable_derivative##_X); \ \ /*const*/ Kratos::Variable \ - component2(#component2, #name, 1, &variable_derivative##_Y); \ + component2(#component2, &name, 1, &variable_derivative##_Y); \ \ /*const*/ Kratos::Variable \ - component3(#component3, #name, 2, &variable_derivative##_Z); + component3(#component3, &name, 2, &variable_derivative##_Z); #ifdef KRATOS_CREATE_3D_VARIABLE_WITH_COMPONENTS_WITH_TIME_DERIVATIVE #undef KRATOS_CREATE_3D_VARIABLE_WITH_COMPONENTS_WITH_TIME_DERIVATIVE @@ -524,13 +524,13 @@ catch(...) { Block KRATOS_THROW_ERROR(std::runtime_error, "Unknown error", MoreI /*const*/ Kratos::Variable > name(#name, Kratos::zero_vector(3), &variable_derivative); \ \ /*const*/ Kratos::Variable \ - component1(#component1, #name, 0, &variable_derivative##_XX); \ + component1(#component1, &name, 0, &variable_derivative##_XX); \ \ /*const*/ Kratos::Variable \ - component2(#component2, #name, 1, &variable_derivative##_YY); \ + component2(#component2, &name, 1, &variable_derivative##_YY); \ \ /*const*/ Kratos::Variable \ - component3(#component3, #name, 2, &variable_derivative##_XY); + component3(#component3, &name, 2, &variable_derivative##_XY); #ifdef KRATOS_CREATE_SYMMETRIC_2D_TENSOR_VARIABLE_WITH_COMPONENTS_WITH_TIME_DERIVATIVE #undef KRATOS_CREATE_SYMMETRIC_2D_TENSOR_VARIABLE_WITH_COMPONENTS_WITH_TIME_DERIVATIVE @@ -545,22 +545,22 @@ catch(...) { Block KRATOS_THROW_ERROR(std::runtime_error, "Unknown error", MoreI /*const*/ Kratos::Variable > name(#name, Kratos::zero_vector(6), &variable_derivative); \ \ /*const*/ Kratos::Variable \ - component1(#component1, #name, 0, &variable_derivative##_XX); \ + component1(#component1, &name, 0, &variable_derivative##_XX); \ \ /*const*/ Kratos::Variable \ - component2(#component2, #name, 1, &variable_derivative##_YY); \ + component2(#component2, &name, 1, &variable_derivative##_YY); \ \ /*const*/ Kratos::Variable \ - component3(#component3, #name, 2, &variable_derivative##_ZZ); \ + component3(#component3, &name, 2, &variable_derivative##_ZZ); \ \ /*const*/ Kratos::Variable \ - component4(#component4, #name, 3, &variable_derivative##_XY); \ + component4(#component4, &name, 3, &variable_derivative##_XY); \ \ /*const*/ Kratos::Variable \ - component5(#component5, #name, 4, &variable_derivative##_YZ); \ + component5(#component5, &name, 4, &variable_derivative##_YZ); \ \ /*const*/ Kratos::Variable \ - component6(#component6, #name, 5, &variable_derivative##_XZ); + component6(#component6, &name, 5, &variable_derivative##_XZ); #ifdef KRATOS_CREATE_SYMMETRIC_3D_TENSOR_VARIABLE_WITH_COMPONENTS_WITH_TIME_DERIVATIVE #undef KRATOS_CREATE_SYMMETRIC_3D_TENSOR_VARIABLE_WITH_COMPONENTS_WITH_TIME_DERIVATIVE @@ -575,16 +575,16 @@ catch(...) { Block KRATOS_THROW_ERROR(std::runtime_error, "Unknown error", MoreI /*const*/ Kratos::Variable > name(#name, Kratos::zero_vector(4), &variable_derivative); \ \ /*const*/ Kratos::Variable \ - component1(#component1, #name, 0, &variable_derivative##_XX); \ + component1(#component1, &name, 0, &variable_derivative##_XX); \ \ /*const*/ Kratos::Variable \ - component2(#component2, #name, 1, &variable_derivative##_XY); \ + component2(#component2, &name, 1, &variable_derivative##_XY); \ \ /*const*/ Kratos::Variable \ - component3(#component3, #name, 2, &variable_derivative##_YX); \ + component3(#component3, &name, 2, &variable_derivative##_YX); \ \ /*const*/ Kratos::Variable \ - component4(#component4, #name, 3, &variable_derivative##_YY); + component4(#component4, &name, 3, &variable_derivative##_YY); #ifdef KRATOS_CREATE_2D_TENSOR_VARIABLE_WITH_COMPONENTS_WITH_TIME_DERIVATIVE #undef KRATOS_CREATE_2D_TENSOR_VARIABLE_WITH_COMPONENTS_WITH_TIME_DERIVATIVE @@ -599,31 +599,31 @@ catch(...) { Block KRATOS_THROW_ERROR(std::runtime_error, "Unknown error", MoreI /*const*/ Kratos::Variable > name(#name, Kratos::zero_vector(9), &variable_derivative); \ \ /*const*/ Kratos::Variable \ - component1(#component1, #name, 0, &variable_derivative##_XX); \ + component1(#component1, &name, 0, &variable_derivative##_XX); \ \ /*const*/ Kratos::Variable \ - component2(#component2, #name, 1, &variable_derivative##_XY); \ + component2(#component2, &name, 1, &variable_derivative##_XY); \ \ /*const*/ Kratos::Variable \ - component3(#component3, #name, 2, &variable_derivative##_XZ); \ + component3(#component3, &name, 2, &variable_derivative##_XZ); \ \ /*const*/ Kratos::Variable \ - component4(#component4, #name, 3, &variable_derivative##_YX); \ + component4(#component4, &name, 3, &variable_derivative##_YX); \ \ /*const*/ Kratos::Variable \ - component5(#component5, #name, 4, &variable_derivative##_YY); \ + component5(#component5, &name, 4, &variable_derivative##_YY); \ \ /*const*/ Kratos::Variable \ - component6(#component6, #name, 5, &variable_derivative##_YZ); \ + component6(#component6, &name, 5, &variable_derivative##_YZ); \ \ /*const*/ Kratos::Variable \ - component7(#component7, #name, 6, &variable_derivative##_ZX); \ + component7(#component7, &name, 6, &variable_derivative##_ZX); \ \ /*const*/ Kratos::Variable \ - component8(#component8, #name, 7, &variable_derivative##_ZY); \ + component8(#component8, &name, 7, &variable_derivative##_ZY); \ \ /*const*/ Kratos::Variable \ - component9(#component9, #name, 8, &variable_derivative##_ZZ); + component9(#component9, &name, 8, &variable_derivative##_ZZ); #ifdef KRATOS_CREATE_3D_TENSOR_VARIABLE_WITH_COMPONENTS_WITH_TIME_DERIVATIVE #undef KRATOS_CREATE_3D_TENSOR_VARIABLE_WITH_COMPONENTS_WITH_TIME_DERIVATIVE From b0ad8ce0194e1e267aade6408e15ef59897273e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Mon, 6 Apr 2020 18:27:39 +0200 Subject: [PATCH 089/314] Missing constructor --- kratos/containers/variable.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/kratos/containers/variable.h b/kratos/containers/variable.h index 13775d6c25e3..cf765bfed396 100644 --- a/kratos/containers/variable.h +++ b/kratos/containers/variable.h @@ -128,6 +128,26 @@ class Variable : public VariableData { } + /** + * @brief Constructor for creating a component of other variable + * @param rNewName The name to be assigned to the compoenent + * @param pTimeDerivativeVariable Pointer to the time derivative variable + * @param Zero The value to be assigned to the variable as zero. In case of not definition will take the value given by the constructor of the time + */ + template + explicit Variable( + const std::string& rNewName, + TSourceVariableType* pSourceVariable, + char ComponentIndex, + const VariableType* pTimeDerivativeVariable, + const TDataType Zero = TDataType() + ) + : VariableData(rNewName, sizeof(TDataType), pSourceVariable, ComponentIndex), + mZero(Zero), + mpTimeDerivativeVariable(pTimeDerivativeVariable) + { + } + /** * Copy constructor. * @brief Copy constructor. From 1fc35359339b528ea299aa42b6f2df475f8dc0b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Mon, 6 Apr 2020 18:56:46 +0200 Subject: [PATCH 090/314] Simplify code --- .../residual_based_bdf_custom_scheme.h | 115 +++--------------- 1 file changed, 20 insertions(+), 95 deletions(-) diff --git a/kratos/solving_strategies/schemes/residual_based_bdf_custom_scheme.h b/kratos/solving_strategies/schemes/residual_based_bdf_custom_scheme.h index e3a21cfd964a..e76e73fb3a55 100644 --- a/kratos/solving_strategies/schemes/residual_based_bdf_custom_scheme.h +++ b/kratos/solving_strategies/schemes/residual_based_bdf_custom_scheme.h @@ -139,9 +139,6 @@ class ResidualBasedBDFCustomScheme ,mDoubleVariable(rOther.mDoubleVariable) ,mFirstDoubleDerivatives(rOther.mFirstDoubleDerivatives) ,mSecondDoubleDerivatives(rOther.mSecondDoubleDerivatives) - ,mArrayVariable(rOther.mArrayVariable) - ,mFirstArrayDerivatives(rOther.mFirstArrayDerivatives) - ,mSecondArrayDerivatives(rOther.mSecondArrayDerivatives) { } @@ -184,24 +181,24 @@ class ResidualBasedBDFCustomScheme KRATOS_WARNING_IF("ResidualBasedBDFCustomScheme", !r_current_process_info.Has(DOMAIN_SIZE)) << "DOMAIN_SIZE not defined. Please define DOMAIN_SIZE. 3D case will be assumed" << std::endl; const std::size_t domain_size = r_current_process_info.Has(DOMAIN_SIZE) ? r_current_process_info.GetValue(DOMAIN_SIZE) : 3; if (domain_size != mDomainSize) { - const std::size_t total_number_of_variables = mArrayVariable.size(); + const std::size_t total_number_of_variables = mDoubleVariable.size(); // We remove the third component if (domain_size == 2) { const std::size_t number_variables_added = total_number_of_variables/3; for (std::size_t i = 0; i < number_variables_added; ++i) { - mArrayVariable.erase(mArrayVariable.begin() + (2 + 2 * i)); - mFirstArrayDerivatives.erase(mArrayVariable.begin() + (2 + 2 * i)); - mSecondArrayDerivatives.erase(mArrayVariable.begin() + (2 + 2 * i)); + mDoubleVariable.erase(mDoubleVariable.begin() + (2 + 2 * i)); + mFirstDoubleDerivatives.erase(mDoubleVariable.begin() + (2 + 2 * i)); + mSecondDoubleDerivatives.erase(mDoubleVariable.begin() + (2 + 2 * i)); } } else if (domain_size == 3) { // We need to add the third component const std::size_t number_variables_added = total_number_of_variables/2; for (std::size_t i = 0; i < number_variables_added; ++i) { - const std::string variable_name = ((*(mArrayVariable.begin() + 2 * i))->GetSourceVariable()).Name(); + const std::string variable_name = ((*(mDoubleVariable.begin() + 2 * i))->GetSourceVariable()).Name(); const auto& r_var_z = KratosComponents>::Get(variable_name + "_Z"); - mArrayVariable.push_back(&r_var_z); - mFirstArrayDerivatives.push_back(&(r_var_z.GetTimeDerivative())); - mSecondArrayDerivatives.push_back(&((r_var_z.GetTimeDerivative()).GetTimeDerivative())); + mDoubleVariable.push_back(&r_var_z); + mFirstDoubleDerivatives.push_back(&(r_var_z.GetTimeDerivative())); + mSecondDoubleDerivatives.push_back(&((r_var_z.GetTimeDerivative()).GetTimeDerivative())); } } else { KRATOS_ERROR << "DOMAIN_SIZE can onbly be 2 or 3. It is: " << domain_size << std::endl; @@ -266,30 +263,6 @@ class ResidualBasedBDFCustomScheme counter++; } - - counter = 0; - for (auto p_var : mArrayVariable) { - - fixed = false; - - // Derivatives - const auto& dvar = *mFirstArrayDerivatives[counter]; - const auto& d2var = *mSecondArrayDerivatives[counter]; - - if (it_node->HasDofFor(d2var)) { - if (it_node->IsFixed(d2var)) { - it_node->Fix(*p_var); - fixed = true; - } - } - - if (it_node->HasDofFor(dvar)) { - if (it_node->IsFixed(dvar) && !fixed) { - it_node->Fix(*p_var); - } - } - counter++; - } } KRATOS_CATCH("ResidualBasedBDFCustomScheme.InitializeSolutionStep"); @@ -340,15 +313,6 @@ class ResidualBasedBDFCustomScheme counter++; } - counter = 0; - for (auto p_var : mArrayVariable) { - // Derivatives - const auto& dvar = *mFirstArrayDerivatives[counter]; - const auto& d2var = *mSecondArrayDerivatives[counter]; - - ComputePredictComponent(it_node, *p_var, dvar, d2var, delta_time); - counter++; - } // Updating time derivatives UpdateFirstDerivative(it_node); @@ -382,12 +346,6 @@ class ResidualBasedBDFCustomScheme KRATOS_CHECK_VARIABLE_KEY((*p_var)) for ( auto p_var : mSecondDoubleDerivatives) KRATOS_CHECK_VARIABLE_KEY((*p_var)) - for ( auto p_var : mArrayVariable) - KRATOS_CHECK_VARIABLE_KEY((*p_var)) - for ( auto p_var : mFirstArrayDerivatives) - KRATOS_CHECK_VARIABLE_KEY((*p_var)) - for ( auto p_var : mSecondArrayDerivatives) - KRATOS_CHECK_VARIABLE_KEY((*p_var)) // Check that variables are correctly allocated for(auto& r_node : rModelPart.Nodes()) { @@ -397,19 +355,9 @@ class ResidualBasedBDFCustomScheme KRATOS_CHECK_VARIABLE_IN_NODAL_DATA((*p_var), r_node) for ( auto p_var : mSecondDoubleDerivatives) KRATOS_CHECK_VARIABLE_IN_NODAL_DATA((*p_var), r_node) - for ( auto p_var : mArrayVariable) - KRATOS_CHECK_VARIABLE_IN_NODAL_DATA((*p_var), r_node) - for ( auto p_var : mFirstArrayDerivatives) - KRATOS_CHECK_VARIABLE_IN_NODAL_DATA((*p_var), r_node) - for ( auto p_var : mSecondArrayDerivatives) - KRATOS_CHECK_VARIABLE_IN_NODAL_DATA((*p_var), r_node) for ( auto p_var : mDoubleVariable) KRATOS_CHECK_DOF_IN_NODE((*p_var), r_node) - - for ( auto p_var : mArrayVariable) { - KRATOS_CHECK_DOF_IN_NODE((*p_var), r_node) - } } KRATOS_CATCH( "" ); @@ -460,12 +408,9 @@ class ResidualBasedBDFCustomScheme ///@name Protected member Variables ///@{ - std::vector*> mDoubleVariable; /// The double variables - std::vector*> mFirstDoubleDerivatives; /// The first derivative double variable to compute - std::vector*> mSecondDoubleDerivatives; /// The second derivative double variable to compute - std::vector*> mArrayVariable; /// The array variables to compute - std::vector*> mFirstArrayDerivatives; /// The first derivative array variable to compute - std::vector*> mSecondArrayDerivatives; /// The second derivative array variable to compute + std::vector*> mDoubleVariable; /// The double variables + std::vector*> mFirstDoubleDerivatives; /// The first derivative double variable to compute + std::vector*> mSecondDoubleDerivatives; /// The second derivative double variable to compute ///@} ///@name Protected Operators @@ -490,16 +435,6 @@ class ResidualBasedBDFCustomScheme dotun0 += BDFBaseType::mBDF[i_order] * itNode->FastGetSolutionStepValue(*p_var, i_order); counter++; } - - // ARRAYS - counter = 0; - for (auto p_var : mArrayVariable) { - double& dotun0 = itNode->FastGetSolutionStepValue(*mFirstArrayDerivatives[counter]); - dotun0 = BDFBaseType::mBDF[0] * itNode->FastGetSolutionStepValue(*p_var); - for (std::size_t i_order = 1; i_order < BDFBaseType::mOrder + 1; ++i_order) - dotun0 += BDFBaseType::mBDF[i_order] * itNode->FastGetSolutionStepValue(*p_var, i_order); - counter++; - } } /** @@ -517,16 +452,6 @@ class ResidualBasedBDFCustomScheme dot2un0 += BDFBaseType::mBDF[i_order] * itNode->FastGetSolutionStepValue(*p_var, i_order); counter++; } - - // ARRAYS - counter = 0; - for (auto p_var : mFirstArrayDerivatives) { - double& dot2un0 = itNode->FastGetSolutionStepValue(*mSecondArrayDerivatives[counter]); - dot2un0 = BDFBaseType::mBDF[0] * itNode->FastGetSolutionStepValue(*p_var); - for (std::size_t i_order = 1; i_order < BDFBaseType::mOrder + 1; ++i_order) - dot2un0 += BDFBaseType::mBDF[i_order] * itNode->FastGetSolutionStepValue(*p_var, i_order); - counter++; - } } ///@} @@ -631,17 +556,17 @@ class ResidualBasedBDFCustomScheme // Components const auto& r_var_x = KratosComponents>::Get(variable_name+"_X"); const auto& r_var_y = KratosComponents>::Get(variable_name+"_Y"); - mArrayVariable.push_back(&r_var_x); - mArrayVariable.push_back(&r_var_y); - mFirstArrayDerivatives.push_back(&(r_var_x.GetTimeDerivative())); - mFirstArrayDerivatives.push_back(&(r_var_y.GetTimeDerivative())); - mSecondArrayDerivatives.push_back(&((r_var_x.GetTimeDerivative()).GetTimeDerivative())); - mSecondArrayDerivatives.push_back(&((r_var_y.GetTimeDerivative()).GetTimeDerivative())); + mDoubleVariable.push_back(&r_var_x); + mDoubleVariable.push_back(&r_var_y); + mFirstDoubleDerivatives.push_back(&(r_var_x.GetTimeDerivative())); + mFirstDoubleDerivatives.push_back(&(r_var_y.GetTimeDerivative())); + mSecondDoubleDerivatives.push_back(&((r_var_x.GetTimeDerivative()).GetTimeDerivative())); + mSecondDoubleDerivatives.push_back(&((r_var_y.GetTimeDerivative()).GetTimeDerivative())); if (mDomainSize == 3) { const auto& r_var_z = KratosComponents>::Get(variable_name+"_Z"); - mArrayVariable.push_back(&r_var_z); - mFirstArrayDerivatives.push_back(&(r_var_z.GetTimeDerivative())); - mSecondArrayDerivatives.push_back(&((r_var_z.GetTimeDerivative()).GetTimeDerivative())); + mDoubleVariable.push_back(&r_var_z); + mFirstDoubleDerivatives.push_back(&(r_var_z.GetTimeDerivative())); + mSecondDoubleDerivatives.push_back(&((r_var_z.GetTimeDerivative()).GetTimeDerivative())); } } else { KRATOS_ERROR << "Only double and vector variables are allowed in the variables list." ; From 53dea5fabe1e67cf80380824a3b91461c6a23c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Mon, 6 Apr 2020 19:20:15 +0200 Subject: [PATCH 091/314] Simplify code (II) --- .../compute_nodal_gradient_process.cpp | 137 ++---------------- .../compute_nodal_gradient_process.h | 14 +- kratos/python/add_processes_to_python.cpp | 6 - 3 files changed, 16 insertions(+), 141 deletions(-) diff --git a/kratos/processes/compute_nodal_gradient_process.cpp b/kratos/processes/compute_nodal_gradient_process.cpp index 3e3eca58014d..eda5faa459e0 100644 --- a/kratos/processes/compute_nodal_gradient_process.cpp +++ b/kratos/processes/compute_nodal_gradient_process.cpp @@ -66,21 +66,11 @@ void ComputeNodalGradientProcess::Execute() Vector values(number_of_nodes); if (!mNonHistoricalVariable) { - if (mpOriginVariableDoubleList.size() > 0) { - for(std::size_t i_node=0; i_node 0) { - for(std::size_t i_node=0; i_node>::Has(r_origin_variable_name)) { - mpOriginVariableDoubleList.push_back(&KratosComponents>::Get(r_origin_variable_name)); - } else if (KratosComponents::Has(r_origin_variable_name)) { - mpOriginVariableComponentsList.push_back(&KratosComponents::Get(r_origin_variable_name)); + mpOriginVariable = &KratosComponents>::Get(r_origin_variable_name); } else { - KRATOS_ERROR << "Only components and doubles are allowed as variables" << std::endl; + KRATOS_ERROR << "Only doubles are allowed as variables" << std::endl; } // Setting the non-historical flag @@ -154,17 +142,9 @@ ComputeNodalGradientProcess 0) { - VariableUtils().CheckVariableExists(*mpOriginVariableDoubleList[0], mrModelPart.Nodes()); - } else { - VariableUtils().CheckVariableExists(*mpOriginVariableComponentsList[0], mrModelPart.Nodes()); - } + VariableUtils().CheckVariableExists(*mpOriginVariable, mrModelPart.Nodes()); } else { - if (mpOriginVariableDoubleList.size() > 0) { - KRATOS_ERROR_IF_NOT(mrModelPart.Nodes().begin()->Has(*mpOriginVariableDoubleList[0])) << "Variable " << r_origin_variable_name << " not defined on non-historial database" << std::endl; - } else { - KRATOS_ERROR_IF_NOT(mrModelPart.Nodes().begin()->Has(*mpOriginVariableComponentsList[0])) << "Variable " << r_origin_variable_name << " not defined on non-historial database" << std::endl; - } + KRATOS_ERROR_IF_NOT(mrModelPart.Nodes().begin()->Has(*mpOriginVariable)) << "Variable " << r_origin_variable_name << " not defined on non-historial database" << std::endl; } VariableUtils().CheckVariableExists(*mpGradientVariable, mrModelPart.Nodes()); // In case the area or gradient variable is not initialized we initialize it @@ -196,11 +176,9 @@ ComputeNodalGradientProcess>::Has(r_origin_variable_name)) { - mpOriginVariableDoubleList.push_back(&KratosComponents>::Get(r_origin_variable_name)); - } else if (KratosComponents::Has(r_origin_variable_name)) { - mpOriginVariableComponentsList.push_back(&KratosComponents::Get(r_origin_variable_name)); + mpOriginVariable = &KratosComponents>::Get(r_origin_variable_name); } else { - KRATOS_ERROR << "Only components and doubles are allowed as variables" << std::endl; + KRATOS_ERROR << "Only doubles are allowed as variables" << std::endl; } // Setting the non-historical flag @@ -208,17 +186,9 @@ ComputeNodalGradientProcess 0) { - VariableUtils().CheckVariableExists(*mpOriginVariableDoubleList[0], mrModelPart.Nodes()); - } else { - VariableUtils().CheckVariableExists(*mpOriginVariableComponentsList[0], mrModelPart.Nodes()); - } + VariableUtils().CheckVariableExists(*mpOriginVariable, mrModelPart.Nodes()); } else { - if (mpOriginVariableDoubleList.size() > 0) { - KRATOS_ERROR_IF_NOT(mrModelPart.Nodes().begin()->Has(*mpOriginVariableDoubleList[0])) << "Variable " << r_origin_variable_name << " not defined on non-historial database" << std::endl; - } else { - KRATOS_ERROR_IF_NOT(mrModelPart.Nodes().begin()->Has(*mpOriginVariableComponentsList[0])) << "Variable " << r_origin_variable_name << " not defined on non-historial database" << std::endl; - } + KRATOS_ERROR_IF_NOT(mrModelPart.Nodes().begin()->Has(*mpOriginVariable)) << "Variable " << r_origin_variable_name << " not defined on non-historial database" << std::endl; } // In case the area or gradient variable is not initialized we initialize it auto& r_nodes = rModelPart.Nodes(); @@ -244,15 +214,13 @@ ComputeNodalGradientProcess& rAreaVariable, const bool NonHistoricalVariable ) : mrModelPart(rModelPart), + mpOriginVariable(&rOriginVariable), mpGradientVariable(&rGradientVariable), mpAreaVariable(&rAreaVariable), mNonHistoricalVariable(NonHistoricalVariable) { KRATOS_TRY - // We push the list of double variables - mpOriginVariableDoubleList.push_back(&rOriginVariable); - // Doing several checks if (!mNonHistoricalVariable) { VariableUtils().CheckVariableExists(rOriginVariable, mrModelPart.Nodes()); @@ -280,90 +248,13 @@ ComputeNodalGradientProcess& rAreaVariable, const bool NonHistoricalVariable ) : mrModelPart(rModelPart), + mpOriginVariable(&rOriginVariable), mpGradientVariable(&rGradientVariable), mpAreaVariable(&rAreaVariable), mNonHistoricalVariable(NonHistoricalVariable) { KRATOS_TRY - // We push the list of double variables - mpOriginVariableDoubleList.push_back(&rOriginVariable); - - // Doing several checks - if (!mNonHistoricalVariable) { - VariableUtils().CheckVariableExists(rOriginVariable, mrModelPart.Nodes()); - } else { - KRATOS_ERROR_IF_NOT(mrModelPart.Nodes().begin()->Has(rOriginVariable)) << "Variable " << rOriginVariable.Name() << " not defined on non-historial database" << std::endl; - } - // In case the area or gradient variable is not initialized we initialize it - auto& r_nodes = rModelPart.Nodes(); - if (!r_nodes.begin()->Has( rGradientVariable )) { - const array_1d zero_vector = ZeroVector(3); - VariableUtils().SetNonHistoricalVariable(rGradientVariable, zero_vector, r_nodes); - } - if (!r_nodes.begin()->Has( rAreaVariable )) { - VariableUtils().SetNonHistoricalVariable(rAreaVariable, 0.0, r_nodes); - } - - KRATOS_CATCH("") -} - -/***********************************************************************************/ -/***********************************************************************************/ - -template<> -ComputeNodalGradientProcess::ComputeNodalGradientProcess( - ModelPart& rModelPart, - const ComponentType& rOriginVariable, - const Variable >& rGradientVariable, - const Variable& rAreaVariable, - const bool NonHistoricalVariable - ) : mrModelPart(rModelPart), - mpGradientVariable(&rGradientVariable), - mpAreaVariable(&rAreaVariable), - mNonHistoricalVariable(NonHistoricalVariable) -{ - KRATOS_TRY - - // We push the components list - mpOriginVariableComponentsList.push_back(&rOriginVariable); - - // Doing several checks - if (!mNonHistoricalVariable) { - VariableUtils().CheckVariableExists(rOriginVariable, mrModelPart.Nodes()); - } else { - KRATOS_ERROR_IF_NOT(mrModelPart.Nodes().begin()->Has(rOriginVariable)) << "Variable " << rOriginVariable.Name() << " not defined on non-historial database" << std::endl; - } - VariableUtils().CheckVariableExists(rGradientVariable, mrModelPart.Nodes()); - // In case the area or gradient variable is not initialized we initialize it - auto& r_nodes = rModelPart.Nodes(); - if (!r_nodes.begin()->Has( rAreaVariable )) { - VariableUtils().SetNonHistoricalVariable(rAreaVariable, 0.0, r_nodes); - } - - KRATOS_CATCH("") -} - -/***********************************************************************************/ -/***********************************************************************************/ - -template<> -ComputeNodalGradientProcess::ComputeNodalGradientProcess( - ModelPart& rModelPart, - const ComponentType& rOriginVariable, - const Variable >& rGradientVariable, - const Variable& rAreaVariable, - const bool NonHistoricalVariable - ) : mrModelPart(rModelPart), - mpGradientVariable(&rGradientVariable), - mpAreaVariable(&rAreaVariable), - mNonHistoricalVariable(NonHistoricalVariable) -{ - KRATOS_TRY - - // We push the components list - mpOriginVariableComponentsList.push_back(&rOriginVariable); - // Doing several checks if (!mNonHistoricalVariable) { VariableUtils().CheckVariableExists(rOriginVariable, mrModelPart.Nodes()); diff --git a/kratos/processes/compute_nodal_gradient_process.h b/kratos/processes/compute_nodal_gradient_process.h index 6e1c5d0f04fd..2dbef0248093 100644 --- a/kratos/processes/compute_nodal_gradient_process.h +++ b/kratos/processes/compute_nodal_gradient_process.h @@ -97,15 +97,6 @@ class KRATOS_API(KRATOS_CORE) ComputeNodalGradientProcess const bool NonHistoricalVariable = false ); - /// Default constructor. (component) - ComputeNodalGradientProcess( - ModelPart& rModelPart, - const ComponentType& rOriginVariable, - const Variable >& rGradientVariable, - const Variable& rAreaVariable = NODAL_AREA, - const bool NonHistoricalVariable = false - ); - /// Destructor. ~ComputeNodalGradientProcess() override { @@ -224,10 +215,9 @@ class KRATOS_API(KRATOS_CORE) ComputeNodalGradientProcess ///@{ ModelPart& mrModelPart; /// The main model part - std::vector*> mpOriginVariableDoubleList; /// The scalar variable list to compute - std::vector mpOriginVariableComponentsList; /// The scalar variable list to compute (components) + const Variable* mpOriginVariable = nullptr; /// The scalar variable list to compute const Variable>* mpGradientVariable; /// The resultant gradient variable - const Variable* mpAreaVariable; /// The auxiliar area variable + const Variable* mpAreaVariable = nullptr; /// The auxiliar area variable bool mNonHistoricalVariable = false; /// If the variable is non-historical ///@} diff --git a/kratos/python/add_processes_to_python.cpp b/kratos/python/add_processes_to_python.cpp index 05d67ef464c1..21c5a6cf932e 100644 --- a/kratos/python/add_processes_to_python.cpp +++ b/kratos/python/add_processes_to_python.cpp @@ -307,9 +307,6 @@ void AddProcessesToPython(pybind11::module& m) /* Historical */ py::class_, ComputeNodalGradientProcess::Pointer, Process>(m,"ComputeNodalGradientProcess") .def(py::init()) - .def(py::init >&>()) - .def(py::init >& , Variable& >()) - .def(py::init >& , Variable&, const bool >()) .def(py::init&, Variable >&>()) .def(py::init&, Variable >& , Variable& >()) .def(py::init&, Variable >& , Variable&, const bool >()) @@ -323,9 +320,6 @@ void AddProcessesToPython(pybind11::module& m) /* Non-Historical */ py::class_, ComputeNodalGradientProcess::Pointer, Process>(m,"ComputeNonHistoricalNodalGradientProcess") .def(py::init()) - .def(py::init >&>()) - .def(py::init >& , Variable& >()) - .def(py::init >& , Variable&, const bool >()) .def(py::init&, Variable >&>()) .def(py::init&, Variable >& , Variable& >()) .def(py::init&, Variable >& , Variable&, const bool >()) From a731aa10a5bde7cb78dca1573fd99b0faa1dbe65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Mon, 6 Apr 2020 19:52:34 +0200 Subject: [PATCH 092/314] [MeshingApplication] Adapt processes to 6686 Just that --- .../metrics_hessian_process.cpp | 45 +++---------------- .../metrics_hessian_process.h | 3 +- .../custom_python/add_processes_to_python.cpp | 4 -- 3 files changed, 7 insertions(+), 45 deletions(-) diff --git a/applications/MeshingApplication/custom_processes/metrics_hessian_process.cpp b/applications/MeshingApplication/custom_processes/metrics_hessian_process.cpp index 9ade501ea58a..3cb7e5e47da2 100755 --- a/applications/MeshingApplication/custom_processes/metrics_hessian_process.cpp +++ b/applications/MeshingApplication/custom_processes/metrics_hessian_process.cpp @@ -37,9 +37,7 @@ ComputeHessianSolMetricProcess::ComputeHessianSolMetricProcess( // We push the list of double variables if (KratosComponents>::Has(r_metric_variable_name)) { - mrOriginVariableDoubleList.push_back(&KratosComponents>::Get(r_metric_variable_name)); - } else if (KratosComponents::Has(r_metric_variable_name)) { - mrOriginVariableComponentsList.push_back(&KratosComponents::Get(r_metric_variable_name)); + mrOriginVariable = &KratosComponents>::Get(r_metric_variable_name); } else { KRATOS_ERROR << "Only components and doubles are allowed as variables" << std::endl; } @@ -52,32 +50,9 @@ ComputeHessianSolMetricProcess::ComputeHessianSolMetricProcess( ModelPart& rThisModelPart, Variable& rVariable, Parameters ThisParameters - ) : mrModelPart(rThisModelPart) -{ - // We push the list of double variables - mrOriginVariableDoubleList.push_back(&rVariable); - - // TODO: Remove this warning in the future - KRATOS_WARNING_IF("ComputeHessianSolMetricProcess", !ThisParameters.Has("enforce_anisotropy_relative_variable")) << "enforce_anisotropy_relative_variable not defined. By default is considered false" << std::endl; - - // We check the parameters - const Parameters default_parameters = GetDefaultParameters(); - ThisParameters.RecursivelyValidateAndAssignDefaults(default_parameters); - InitializeVariables(ThisParameters); -} - -/***********************************************************************************/ -/***********************************************************************************/ - -ComputeHessianSolMetricProcess::ComputeHessianSolMetricProcess( - ModelPart& rThisModelPart, - ComponentType& rVariable, - Parameters ThisParameters - ):mrModelPart(rThisModelPart) + ) : mrModelPart(rThisModelPart), + mrOriginVariable(&rVariable) { - // We push the components list - mrOriginVariableComponentsList.push_back(&rVariable); - // TODO: Remove this warning in the future KRATOS_WARNING_IF("ComputeHessianSolMetricProcess", !ThisParameters.Has("enforce_anisotropy_relative_variable")) << "enforce_anisotropy_relative_variable not defined. By default is considered false" << std::endl; @@ -98,17 +73,9 @@ void ComputeHessianSolMetricProcess::Execute() // Some checks NodesArrayType& r_nodes_array = mrModelPart.Nodes(); if (!mNonHistoricalVariable) { - if (mrOriginVariableDoubleList.size() > 0) { - VariableUtils().CheckVariableExists(*mrOriginVariableDoubleList[0], r_nodes_array); - } else { - VariableUtils().CheckVariableExists(*mrOriginVariableComponentsList[0], r_nodes_array); - } + VariableUtils().CheckVariableExists(*mrOriginVariable, r_nodes_array); } else { - if (mrOriginVariableDoubleList.size() > 0) { - KRATOS_ERROR_IF_NOT(r_nodes_array.begin()->Has(*mrOriginVariableDoubleList[0])) << "Variable " << mrOriginVariableDoubleList[0]->Name() << " not defined on non-historial database" << std::endl; - } else { - KRATOS_ERROR_IF_NOT(r_nodes_array.begin()->Has(*mrOriginVariableComponentsList[0])) << "Variable " << mrOriginVariableComponentsList[0]->Name() << " not defined on non-historial database" << std::endl; - } + KRATOS_ERROR_IF_NOT(r_nodes_array.begin()->Has(*mrOriginVariable)) << "Variable " << mrOriginVariable->Name() << " not defined on non-historial database" << std::endl; } // Checking NODAL_H @@ -244,7 +211,7 @@ void ComputeHessianSolMetricProcess::CalculateAuxiliarHessian() it_node->SetValue(AUXILIAR_GRADIENT, aux_zero_vector); // Saving auxiliar value - const double value = mNonHistoricalVariable ? (mrOriginVariableDoubleList.size() > 0 ? it_node->GetValue(*mrOriginVariableDoubleList[0]) : it_node->GetValue(*mrOriginVariableComponentsList[0])) : (mrOriginVariableDoubleList.size() > 0 ? it_node->FastGetSolutionStepValue(*mrOriginVariableDoubleList[0]) : it_node->FastGetSolutionStepValue(*mrOriginVariableComponentsList[0])); + const double value = mNonHistoricalVariable ? it_node->GetValue(*mrOriginVariable) : it_node->FastGetSolutionStepValue(*mrOriginVariable); it_node->SetValue(NODAL_MAUX, value * normalization_factor); } diff --git a/applications/MeshingApplication/custom_processes/metrics_hessian_process.h b/applications/MeshingApplication/custom_processes/metrics_hessian_process.h index 6b406d9ae9c4..e94eece34f69 100755 --- a/applications/MeshingApplication/custom_processes/metrics_hessian_process.h +++ b/applications/MeshingApplication/custom_processes/metrics_hessian_process.h @@ -273,8 +273,7 @@ class KRATOS_API(MESHING_APPLICATION) ComputeHessianSolMetricProcess ModelPart& mrModelPart; /// The model part to compute bool mNonHistoricalVariable = false; /// If the variable is non-historical - std::vector*> mrOriginVariableDoubleList; /// The scalar variable list to compute - std::vector mrOriginVariableComponentsList; /// The scalar variable list to compute (components) + const Variable* mrOriginVariable; /// The scalar variable list to compute const Variable* mpRatioReferenceVariable; /// Variable used to compute the anisotropic ratio Parameters mThisParameters; /// Here configurations are stored diff --git a/applications/MeshingApplication/custom_python/add_processes_to_python.cpp b/applications/MeshingApplication/custom_python/add_processes_to_python.cpp index 9965d65cc6ed..b89e8edc5400 100644 --- a/applications/MeshingApplication/custom_python/add_processes_to_python.cpp +++ b/applications/MeshingApplication/custom_python/add_processes_to_python.cpp @@ -39,8 +39,6 @@ namespace Python { namespace py = pybind11; -typedef VariableComponent< VectorComponentAdaptor > > ComponentType; - void AddProcessesToPython(pybind11::module& m) { // The process to interpolate nodal values @@ -87,8 +85,6 @@ void AddProcessesToPython(pybind11::module& m) .def(py::init()) .def(py::init&>()) .def(py::init&, Parameters>()) - .def(py::init()) - .def(py::init()) ; m.attr("ComputeHessianSolMetricProcess2D") = m.attr("ComputeHessianSolMetricProcess"); From 4d96f65ae1439522dcbcb4002f1cbc4de8e77fa9 Mon Sep 17 00:00:00 2001 From: Inigo Lopez Date: Mon, 6 Apr 2020 20:02:23 +0200 Subject: [PATCH 093/314] codacy --- .../solver_wrappers/kratos/potential_flow_wrapper.py | 2 -- .../solver_wrappers/sdof/sdof_static_solver.py | 6 +----- .../tests/test_sdof_static_solver.py | 3 +-- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/potential_flow_wrapper.py b/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/potential_flow_wrapper.py index 8d2365f9f445..9cbe7bdda332 100644 --- a/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/potential_flow_wrapper.py +++ b/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/potential_flow_wrapper.py @@ -1,12 +1,10 @@ from __future__ import print_function, absolute_import, division # makes KratosMultiphysics backward compatible with python 2.6 and 2.7 # Importing the Kratos Library -import KratosMultiphysics from KratosMultiphysics.kratos_utilities import CheckIfApplicationsAvailable if not CheckIfApplicationsAvailable("CompressiblePotentialFlowApplication"): raise ImportError("The CompressiblePotentialFlowApplication is not available!") -import KratosMultiphysics.CompressiblePotentialFlowApplication # Importing the base class from KratosMultiphysics.CoSimulationApplication.solver_wrappers.kratos import kratos_base_wrapper diff --git a/applications/CoSimulationApplication/python_scripts/solver_wrappers/sdof/sdof_static_solver.py b/applications/CoSimulationApplication/python_scripts/solver_wrappers/sdof/sdof_static_solver.py index 04d2fbc46057..0df9306d951a 100644 --- a/applications/CoSimulationApplication/python_scripts/solver_wrappers/sdof/sdof_static_solver.py +++ b/applications/CoSimulationApplication/python_scripts/solver_wrappers/sdof/sdof_static_solver.py @@ -4,7 +4,6 @@ from KratosMultiphysics.CoSimulationApplication.function_callback_utility import GenericCallFunction # Other imports -import numpy as np import json import os @@ -78,9 +77,6 @@ def OutputSolutionStep(self): #outputs results results_sdof_static.write(str(self.dx) + "\n") - def Predict(self): - return - def AdvanceInTime(self, current_time): self.time = 0.0 return self.time @@ -116,7 +112,7 @@ def SetSolutionStepValue(self, identifier, value, buffer_idx=0): raise Exception("Identifier is unknown!") def ValidateAndAssignDefaults(defaults, settings, recursive=False): - for key, val in settings.items(): + for key in settings.items(): # check if the current entry also exists in the defaults if not key in defaults.keys(): err_msg = 'The item with name "' + key + '" is present in this ' diff --git a/applications/CoSimulationApplication/tests/test_sdof_static_solver.py b/applications/CoSimulationApplication/tests/test_sdof_static_solver.py index 9ed7ad513d50..d9e8f02efe8d 100644 --- a/applications/CoSimulationApplication/tests/test_sdof_static_solver.py +++ b/applications/CoSimulationApplication/tests/test_sdof_static_solver.py @@ -1,10 +1,8 @@ from __future__ import print_function, absolute_import, division # makes these scripts backward compatible with python 2.6 and 2.7 -import KratosMultiphysics as KM from KratosMultiphysics import kratos_utilities import KratosMultiphysics.KratosUnittest as KratosUnittest from KratosMultiphysics.CoSimulationApplication.solver_wrappers.sdof.sdof_static_solver import SDoFStaticSolver -from KratosMultiphysics.CoSimulationApplication.solver_wrappers.sdof.static_sdof_solver_wrapper import Create as CreateSDofStaticSolverWrapper import os import numpy as np @@ -25,6 +23,7 @@ def setUp(self): self.end_time = 1.0 self.time = 0.0 + @classmethod def tearDown(self): kratos_utilities.DeleteFileIfExisting("result.dat") From da8a4c3e60dbccb693b93005bfae5b8c575a5518 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Tue, 7 Apr 2020 09:11:27 +1000 Subject: [PATCH 094/314] [skip ci] fix error in explicit compressibility --- .../mpm_explicit_utilities.cpp | 46 ++++--------------- 1 file changed, 10 insertions(+), 36 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp index 514260704ddf..0d6f4bd89498 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp @@ -250,53 +250,27 @@ namespace Kratos Matrix jaumannRate = rateOfDeformation - (prod(spinTensor, rateOfDeformation)) * rDeltaTime + prod((rateOfDeformation * rDeltaTime), spinTensor); + Matrix strainIncrement = rDeltaTime * jaumannRate; - rMPStrain(0) += jaumannRate(0, 0) * rDeltaTime; //e_xx - rMPStrain(1) += jaumannRate(1, 1) * rDeltaTime; //e_yy - + // Apply strain increment to strain vector + rMPStrain(0) += strainIncrement(0, 0); //e_xx + rMPStrain(1) += strainIncrement(1, 1); //e_yy if (dimension == 2) { - rMPStrain(2) += 2.0 * jaumannRate(0, 1) * rDeltaTime; //e_xy + rMPStrain(2) += 2.0 * strainIncrement(0, 1); //e_xy } else { - rMPStrain(2) += jaumannRate(2, 2) * rDeltaTime; //e_zz + rMPStrain(2) += strainIncrement(2, 2) * rDeltaTime; //e_zz - rMPStrain(3) += 2.0 * jaumannRate(0, 1) * rDeltaTime; //e_xy - rMPStrain(4) += 2.0 * jaumannRate(1, 2) * rDeltaTime; //e_yz - rMPStrain(5) += 2.0 * jaumannRate(0, 2) * rDeltaTime; //e_xz + rMPStrain(3) += 2.0 * strainIncrement(0, 1); //e_xy + rMPStrain(4) += 2.0 * strainIncrement(1, 2); //e_yz + rMPStrain(5) += 2.0 * strainIncrement(0, 2); //e_xz } // Model compressibility rDeformationGradientIncrement = IdentityMatrix(dimension); - if (isCompressible) - { - Matrix strainIncrement = ZeroMatrix(dimension); - - strainIncrement(0, 0) = rMPStrain(0); //e_xx - strainIncrement(1, 1) = rMPStrain(1); //e_yy - - if (dimension == 2) - { - strainIncrement(0, 1) = rMPStrain(2) / 2.0; //e_xy - strainIncrement(1, 0) = rMPStrain(2) / 2.0; //e_yx - } - else - { - strainIncrement(2, 2) = rMPStrain(2); //e_zz - - strainIncrement(0, 1) = rMPStrain(3) / 2.0; //e_xy - strainIncrement(1, 0) = rMPStrain(3) / 2.0; //e_yx - - strainIncrement(1, 2) = rMPStrain(4) / 2.0; //e_yz - strainIncrement(2, 1) = rMPStrain(4) / 2.0; //e_zy - - strainIncrement(0, 2) = rMPStrain(5) / 2.0; //e_xz - strainIncrement(2, 0) = rMPStrain(5) / 2.0; //e_zx - } - - rDeformationGradientIncrement += strainIncrement; - } + if (isCompressible) rDeformationGradientIncrement += strainIncrement; KRATOS_CATCH("") } From 6107cad25096cec5c9358353f119297d1ac1bc03 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Tue, 7 Apr 2020 09:50:24 +1000 Subject: [PATCH 095/314] [skip ci] add test for 2D Y orientation compressible oscillating point --- ...lating_point_Y_compressible_test_Grid.mdpa | 283 ++++++++++++++++++ ..._point_Y_compressible_test_parameters.json | 91 ++++++ ...ing_point_Y_compressible_test_results.json | 1 + .../tests/particle_mechanics_test_factory.py | 5 +- .../test_ParticleMechanicsApplication.py | 13 +- 5 files changed, 386 insertions(+), 7 deletions(-) create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test_Grid.mdpa create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test_parameters.json create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test_results.json diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test_Grid.mdpa b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test_Grid.mdpa new file mode 100644 index 000000000000..f94c5da3d66d --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test_Grid.mdpa @@ -0,0 +1,283 @@ +Begin ModelPartData +// VARIABLE_NAME value +End ModelPartData + +Begin Properties 0 +End Properties +Begin Nodes + 1 10.0000000000 3.0000000000 0.0000000000 + 2 10.0000000000 2.0000000000 0.0000000000 + 3 9.0000000000 3.0000000000 0.0000000000 + 4 9.0000000000 2.0000000000 0.0000000000 + 5 10.0000000000 1.0000000000 0.0000000000 + 6 8.0000000000 3.0000000000 0.0000000000 + 7 8.0000000000 2.0000000000 0.0000000000 + 8 9.0000000000 1.0000000000 0.0000000000 + 9 8.0000000000 1.0000000000 0.0000000000 + 10 7.0000000000 3.0000000000 0.0000000000 + 11 10.0000000000 0.0000000000 0.0000000000 + 12 7.0000000000 2.0000000000 0.0000000000 + 13 9.0000000000 0.0000000000 0.0000000000 + 14 8.0000000000 0.0000000000 0.0000000000 + 15 7.0000000000 1.0000000000 0.0000000000 + 16 6.0000000000 3.0000000000 0.0000000000 + 17 6.0000000000 2.0000000000 0.0000000000 + 18 6.0000000000 2.0000000000 0.0000000000 + 19 7.0000000000 0.0000000000 0.0000000000 + 20 6.0000000000 1.0000000000 0.0000000000 + 21 6.0000000000 1.0000000000 0.0000000000 + 22 5.0000000000 3.0000000000 0.0000000000 + 23 6.0000000000 0.0000000000 0.0000000000 + 24 5.0000000000 2.0000000000 0.0000000000 + 25 5.0000000000 2.0000000000 0.0000000000 + 26 5.0000000000 1.0000000000 0.0000000000 + 27 5.0000000000 1.0000000000 0.0000000000 + 28 5.0000000000 0.0000000000 0.0000000000 + 29 4.0000000000 3.0000000000 0.0000000000 + 30 4.0000000000 2.0000000000 0.0000000000 + 31 4.0000000000 2.0000000000 0.0000000000 + 32 4.0000000000 1.0000000000 0.0000000000 + 33 4.0000000000 1.0000000000 0.0000000000 + 34 4.0000000000 0.0000000000 0.0000000000 + 35 3.0000000000 3.0000000000 0.0000000000 + 36 3.0000000000 2.0000000000 0.0000000000 + 37 3.0000000000 2.0000000000 0.0000000000 + 38 3.0000000000 1.0000000000 0.0000000000 + 39 3.0000000000 1.0000000000 0.0000000000 + 40 3.0000000000 0.0000000000 0.0000000000 + 41 2.0000000000 3.0000000000 0.0000000000 + 42 2.0000000000 2.0000000000 0.0000000000 + 43 2.0000000000 2.0000000000 0.0000000000 + 44 2.0000000000 1.0000000000 0.0000000000 + 45 2.0000000000 1.0000000000 0.0000000000 + 46 2.0000000000 0.0000000000 0.0000000000 + 47 1.0000000000 3.0000000000 0.0000000000 + 48 1.0000000000 2.0000000000 0.0000000000 + 49 1.0000000000 2.0000000000 0.0000000000 + 50 1.0000000000 1.0000000000 0.0000000000 + 51 1.0000000000 1.0000000000 0.0000000000 + 52 1.0000000000 0.0000000000 0.0000000000 + 53 0.0000000000 3.0000000000 0.0000000000 + 54 0.0000000000 2.0000000000 0.0000000000 + 55 0.0000000000 1.0000000000 0.0000000000 + 56 0.0000000000 0.0000000000 0.0000000000 +End Nodes + + +Begin Elements Element2D4N// GUI group identifier: grid + 1 0 52 51 55 56 + 2 0 46 44 51 52 + 3 0 40 38 44 46 + 4 0 34 33 38 40 + 5 0 28 27 33 34 + 6 0 23 21 27 28 + 7 0 19 15 21 23 + 8 0 14 9 15 19 + 9 0 13 8 9 14 + 10 0 11 5 8 13 + 11 0 51 48 54 55 + 12 0 44 42 48 51 + 13 0 38 36 42 44 + 14 0 33 31 36 38 + 15 0 27 25 31 33 + 16 0 21 18 25 27 + 17 0 15 12 18 21 + 18 0 9 7 12 15 + 19 0 8 4 7 9 + 20 0 5 2 4 8 + 21 0 48 47 53 54 + 22 0 42 41 47 48 + 23 0 36 35 41 42 + 24 0 31 29 35 36 + 25 0 25 22 29 31 + 26 0 18 16 22 25 + 27 0 12 10 16 18 + 28 0 7 6 10 12 + 29 0 4 3 6 7 + 30 0 2 1 3 4 +End Elements + +Begin SubModelPart Parts_grid // Group grid // Subtree Parts + Begin SubModelPartNodes + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 18 + 19 + 21 + 22 + 23 + 25 + 27 + 28 + 29 + 31 + 33 + 34 + 35 + 36 + 38 + 40 + 41 + 42 + 44 + 46 + 47 + 48 + 51 + 52 + 53 + 54 + 55 + 56 + End SubModelPartNodes + Begin SubModelPartElements + 1 + 1 + 1 + 1 + 2 + 2 + 2 + 2 + 3 + 3 + 3 + 3 + 4 + 4 + 4 + 4 + 5 + 5 + 5 + 5 + 6 + 6 + 6 + 6 + 7 + 7 + 7 + 7 + 8 + 8 + 8 + 8 + 9 + 9 + 9 + 9 + 10 + 10 + 10 + 10 + 11 + 11 + 11 + 11 + 12 + 12 + 12 + 12 + 13 + 13 + 13 + 13 + 14 + 14 + 14 + 14 + 15 + 15 + 15 + 15 + 16 + 16 + 16 + 16 + 17 + 17 + 17 + 17 + 18 + 18 + 18 + 18 + 19 + 19 + 19 + 19 + 20 + 20 + 20 + 20 + 21 + 21 + 21 + 21 + 22 + 22 + 22 + 22 + 23 + 23 + 23 + 23 + 24 + 24 + 24 + 24 + 25 + 25 + 25 + 25 + 26 + 26 + 26 + 26 + 27 + 27 + 27 + 27 + 28 + 28 + 28 + 28 + 29 + 29 + 29 + 29 + 30 + 30 + 30 + 30 + End SubModelPartElements + Begin SubModelPartConditions + End SubModelPartConditions +End SubModelPart +Begin SubModelPart DISPLACEMENT_Displacement_Auto1 // Group Displacement Auto1 // Subtree DISPLACEMENT + Begin SubModelPartNodes + 44 + 45 + 50 + 51 + End SubModelPartNodes + Begin SubModelPartElements + End SubModelPartElements + Begin SubModelPartConditions + End SubModelPartConditions +End SubModelPart diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test_parameters.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test_parameters.json new file mode 100644 index 000000000000..00c5e0c5aeb0 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test_parameters.json @@ -0,0 +1,91 @@ +{ + "problem_data" : { + "problem_name" : "explicit_oscillating_point_Y_compressible_test", + "parallel_type" : "OpenMP", + "echo_level" : 0, + "start_time" : 0.0, + "end_time" : 0.3 + }, + "solver_settings" : { + "solver_type" : "Dynamic", + "model_part_name" : "MPM_Material", + "domain_size" : 2, + "echo_level" : 0, + "analysis_type" : "linear", + "time_integration_method" : "explicit", + "scheme_type" : "forward_euler", + "stress_update" : "usf", + "compressible" : true, + "model_import_settings" : { + "input_type" : "mdpa", + "input_filename" : "explicit_tests/oscillating_point/explicit_oscillating_point_test_Body" + }, + "material_import_settings" : { + "materials_filename" : "explicit_tests/oscillating_point/explicit_oscillating_point_test_materials.json" + }, + "time_stepping" : { + "time_step" : 0.05 + }, + "convergence_criterion" : "residual_criterion", + "displacement_relative_tolerance" : 0.0001, + "displacement_absolute_tolerance" : 1e-9, + "residual_relative_tolerance" : 0.0001, + "residual_absolute_tolerance" : 1e-9, + "max_iteration" : 10, + "problem_domain_sub_model_part_list" : ["Parts_bar","Parts_grid"], + "processes_sub_model_part_list" : ["DISPLACEMENT_Displacement_Auto1"], + "grid_model_import_settings" : { + "input_type" : "mdpa", + "input_filename" : "explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test_Grid" + }, + "pressure_dofs" : false + }, + "processes" : { + "constraints_process_list" : [{ + "python_module" : "assign_vector_variable_process", + "kratos_module" : "KratosMultiphysics", + "Parameters" : { + "model_part_name" : "Background_Grid.DISPLACEMENT_Displacement_Auto1", + "variable_name" : "DISPLACEMENT", + "constrained" : [true,true,true], + "value" : [0.0,0.0,0.0], + "interval" : [0.0,"End"] + } + }], + "loads_process_list" : [], + "list_other_processes" : [{ + "python_module" : "assign_initial_velocity_to_particle_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "Parameters" : { + "model_part_name" : "Parts_bar", + "variable_name" : "MP_VELOCITY", + "modulus" : 0.1, + "direction" : [0.0,1.0,0.0] + } + }, + { + "python_module" : "particle_from_json_check_result_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "help" : "", + "process_name" : "ParticleFromJsonCheckResultProcess", + "Parameters" : { + "check_variables" : ["MP_VELOCITY","MP_DISPLACEMENT","MP_VOLUME"], + "input_file_name" : "explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test_results.json", + "model_part_name" : "MPM_Material", + "time_frequency" : 0.25 + } + }] + }, + "print_output_process" : [{ + "python_module" : "particle_json_output_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "help" : "", + "process_name" : "ParticleJsonOutputProcess", + "Parameters" : { + "gauss_points_output_variables" : ["MP_VELOCITY","MP_DISPLACEMENT","MP_VOLUME"], + "output_file_name" : "explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test_results.json", + "model_part_name" : "MPM_Material", + "time_frequency" : 0.25 + } + }] +} diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test_results.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test_results.json new file mode 100644 index 000000000000..b219ca99bc1d --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test_results.json @@ -0,0 +1 @@ +{"TIME": [0.3], "PARTICLE_57": {"MP_VELOCITY_X": [0.0], "MP_VELOCITY_Y": [-0.04673422288768836], "MP_VELOCITY_Z": [0.0], "MP_DISPLACEMENT_X": [0.0], "MP_DISPLACEMENT_Y": [0.007950583089302025], "MP_DISPLACEMENT_Z": [0.0], "MP_VOLUME": [1.0153720903266241]}} \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py b/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py index 18e1dccda543..18a2b14d629c 100644 --- a/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py +++ b/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py @@ -103,4 +103,7 @@ class ExplicitOscillatingPointMUSLTest(ParticleMechanicsTestFactory): file_name = "explicit_tests/oscillating_point/musl_explicit_oscillating_point_test" class ExplicitOscillatingPointCentralDifferenceTest(ParticleMechanicsTestFactory): - file_name = "explicit_tests/oscillating_point/central_difference_explicit_oscillating_point_test" \ No newline at end of file + file_name = "explicit_tests/oscillating_point/central_difference_explicit_oscillating_point_test" + +class ExplicitOscillatingPointYCompressibleTest(ParticleMechanicsTestFactory): + file_name = "explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test" \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py index fbb65ae14c3f..9bcd5e922527 100644 --- a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py +++ b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py @@ -32,7 +32,7 @@ from particle_mechanics_test_factory import ExplicitOscillatingPointUSFTest as TExplicitOscillatingPointUSFTest from particle_mechanics_test_factory import ExplicitOscillatingPointMUSLTest as TExplicitOscillatingPointMUSLTest from particle_mechanics_test_factory import ExplicitOscillatingPointCentralDifferenceTest as TExplicitOscillatingPointCentralDifferenceTest - +from particle_mechanics_test_factory import ExplicitOscillatingPointYCompressibleTest as TExplicitOscillatingPointYCompressibleTest # Import from Test Factories (with different analysis flows) @@ -88,25 +88,26 @@ def AssembleTestSuites(): nightSuite.addTests(smallSuite) nightSuite.addTest(TAxisSymmetricCircularPlate2DTriTest('test_execution')) - + nightSuite.addTest(TBeamCantileverStaticLinearElasticPointLoad2DTriTest('test_execution')) nightSuite.addTest(TBeamCantileverStaticLinearElasticParticlePointLoad2DTriTest('test_execution')) nightSuite.addTest(TBeamCantileverStaticLinearElasticLineLoad2DQuadTest('test_execution')) nightSuite.addTest(TBeamCantileverStaticLinearElasticSurfaceLoad3DHexaTest('test_execution')) nightSuite.addTest(TBeamCantileverStaticHyperelasticSelfWeightLoad2DQuadTest('test_execution')) - + nightSuite.addTest(TCooksMembraneCompressibleTest('test_execution')) nightSuite.addTest(TCooksMembraneUPCompressibleTest('test_execution')) nightSuite.addTest(TCooksMembraneUPIncompressibleTest('test_execution')) - + nightSuite.addTest(TPenaltyImpositionBeamCantileverStaticHyperelasticSelfWeightLoad2DQuadTest('test_execution')) - + nightSuite.addTest(TBeamCantileverLinearStaticHyperelasticSelfWeightLoad2DQuadTest('test_execution')) - + nightSuite.addTest(TExplicitOscillatingPointUSLTest('test_execution')) nightSuite.addTest(TExplicitOscillatingPointUSFTest('test_execution')) nightSuite.addTest(TExplicitOscillatingPointMUSLTest('test_execution')) nightSuite.addTest(TExplicitOscillatingPointCentralDifferenceTest('test_execution')) + nightSuite.addTest(TExplicitOscillatingPointYCompressibleTest('test_execution')) ### Adding Validation Tests ## For very long tests that should not be in nighly and you can use to validate From b655cc8927b888e81afd144010a42315844e5baf Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Tue, 7 Apr 2020 10:04:58 +1000 Subject: [PATCH 096/314] [skip ci] remove central difference bools --- .../updated_lagrangian_quadrilateral.cpp | 6 ++-- .../updated_lagrangian_quadrilateral.hpp | 3 -- .../schemes/mpm_explicit_scheme.hpp | 30 ++++++++++--------- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index 844c475f65ef..10ba0e0664e8 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -912,7 +912,6 @@ void UpdatedLagrangianQuadrilateral::InitializeSolutionStep( ProcessInfo& rCurre mFinalizedStep = false; mIsExplicit = rCurrentProcessInfo.Has(IS_EXPLICIT); - mIsCentralDifference = rCurrentProcessInfo.Has(IS_EXPLICIT_CENTRAL_DIFFERENCE); array_1d aux_MP_velocity = ZeroVector(3); array_1d aux_MP_acceleration = ZeroVector(3); @@ -954,7 +953,7 @@ void UpdatedLagrangianQuadrilateral::InitializeSolutionStep( ProcessInfo& rCurre // Add in the predictor velocity increment for central difference explicit // This is the 'previous grid acceleration', which is actually // be the initial particle acceleration mapped to the grid. - if (mIsCentralDifference) + if (rCurrentProcessInfo.Has(IS_EXPLICIT_CENTRAL_DIFFERENCE)) { const double& delta_time = rCurrentProcessInfo[DELTA_TIME]; for (unsigned int j = 0; j < dimension; j++) @@ -1099,7 +1098,8 @@ void UpdatedLagrangianQuadrilateral::FinalizeExplicitSolutionStep(ProcessInfo& r const double& delta_time = rCurrentProcessInfo[DELTA_TIME]; // Map grid to particle - MPMExplicitUtilities::UpdateGaussPointExplicit(rGeom, delta_time, mIsCentralDifference, *this, mN); + bool isCentralDifference = rCurrentProcessInfo.Has(IS_EXPLICIT_CENTRAL_DIFFERENCE); + MPMExplicitUtilities::UpdateGaussPointExplicit(rGeom, delta_time, isCentralDifference, *this, mN); // If we are doing MUSL, map updated particle velocities back to the grid if (rGeom[0].Has(MUSL_VELOCITY_FIELD_IS_COMPUTED)) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp index 5a81ccbf03cc..e159b136b8a3 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp @@ -634,9 +634,6 @@ class UpdatedLagrangianQuadrilateral /// Boolean for stress update option bool mIsUSFStressUpdate = false; - /// Boolean for central difference explicit time integration - bool mIsCentralDifference = false; - ///@} ///@name Protected Operators diff --git a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp index f667caec22c6..508b5a6fb358 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp @@ -101,8 +101,7 @@ namespace Kratos { ) : Scheme(), mr_grid_model_part(grid_model_part), - mStressUpdateOption(StressUpdateOption), - mIsCentralDifference(isCentralDifference) + mStressUpdateOption(StressUpdateOption) { } @@ -196,8 +195,8 @@ namespace Kratos { TSystemVectorType& b) override { KRATOS_TRY - // The current process info - ProcessInfo& r_current_process_info = r_model_part.GetProcessInfo(); + // The current process info + ProcessInfo& r_current_process_info = r_model_part.GetProcessInfo(); // The array of nodes NodesArrayType& r_nodes = r_model_part.Nodes(); @@ -228,7 +227,7 @@ namespace Kratos { if ((it_node)->Is(ACTIVE)) { // Current step information "N+1" (before step update). - this->UpdateTranslationalDegreesOfFreedom(it_node, disppos, dim); + this->UpdateTranslationalDegreesOfFreedom(r_current_process_info, it_node, disppos, dim); } } // for Node parallel @@ -239,6 +238,7 @@ namespace Kratos { //*************************************************************************** void UpdateTranslationalDegreesOfFreedom( + ProcessInfo& r_current_process_info, NodeIterator itCurrentNode, const IndexType DisplacementPosition, const SizeType DomainSize = 3 @@ -253,10 +253,11 @@ namespace Kratos { array_1d& r_nodal_momenta = itCurrentNode->FastGetSolutionStepValue(NODAL_MOMENTUM); array_1d& r_current_residual = itCurrentNode->FastGetSolutionStepValue(FORCE_RESIDUAL); - double gamma = 1.0; - if (mIsCentralDifference) { - gamma = 0.5; // factor since we are only adding the central difference corrector here - } + const double gamma = (r_current_process_info.Has(IS_EXPLICIT_CENTRAL_DIFFERENCE)) + ? 0.5 + : 1.0; + // we are only adding the central difference corrector here + for (IndexType j = 0; j < DomainSize; j++) { if (fix_displacements[j]) { @@ -366,7 +367,7 @@ namespace Kratos { { KRATOS_TRY - ProcessInfo CurrentProcessInfo = r_model_part.GetProcessInfo(); + ProcessInfo& rCurrentProcessInfo = r_model_part.GetProcessInfo(); BaseType::InitializeSolutionStep(r_model_part, A, Dx, b); // LOOP OVER THE GRID NODES PERFORMED FOR CLEAR ALL NODAL INFORMATION #pragma omp parallel for @@ -408,7 +409,7 @@ namespace Kratos { Scheme::InitializeSolutionStep(r_model_part, A, Dx, b); // If we are updating stress first (USF and central difference), calculate nodal velocities from momenta and apply BCs - if (mStressUpdateOption == 0 || mIsCentralDifference) + if (mStressUpdateOption == 0 || rCurrentProcessInfo.Has(IS_EXPLICIT_CENTRAL_DIFFERENCE)) { const IndexType DisplacementPosition = mr_grid_model_part.NodesBegin()->GetDofPosition(DISPLACEMENT_X); @@ -419,7 +420,7 @@ namespace Kratos { if ((i)->Is(ACTIVE)) { - const SizeType DomainSize = CurrentProcessInfo[DOMAIN_SIZE]; + const SizeType DomainSize = rCurrentProcessInfo[DOMAIN_SIZE]; double& nodal_mass = (i)->FastGetSolutionStepValue(NODAL_MASS); array_1d& nodal_momentum = (i)->FastGetSolutionStepValue(NODAL_MOMENTUM); array_1d& nodal_velocity = (i)->FastGetSolutionStepValue(VELOCITY); @@ -554,9 +555,11 @@ namespace Kratos { { KRATOS_TRY + ProcessInfo& rCurrentProcessInfo = r_model_part.GetProcessInfo(); + // This calculates the stresses before momenta update. // Used for USF and Central Difference method - if (mStressUpdateOption == 0 || mIsCentralDifference) + if (mStressUpdateOption == 0 || rCurrentProcessInfo.Has(IS_EXPLICIT_CENTRAL_DIFFERENCE)) { ElementsArrayType& pElements = r_model_part.Elements(); ProcessInfo& CurrentProcessInfo = r_model_part.GetProcessInfo(); @@ -803,7 +806,6 @@ namespace Kratos { TimeVariables mTime; /// This struct contains the details of the time variables ModelPart& mr_grid_model_part; const int mStressUpdateOption; // 0 = USF, 1 = USL, 2 = MUSL - const bool mIsCentralDifference; private: }; /* Class MPMExplicitScheme */ From b5f7c2c2b6ebff8a1483e756f169791077e8fb1e Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Tue, 7 Apr 2020 10:27:55 +1000 Subject: [PATCH 097/314] [skip ci] remove element explicit and stress update bools --- .../updated_lagrangian_quadrilateral.cpp | 28 ++++++++++--------- .../updated_lagrangian_quadrilateral.hpp | 10 ++----- .../add_custom_strategies_to_python.cpp | 2 +- .../particle_mechanics_python_application.cpp | 1 + .../schemes/mpm_explicit_scheme.hpp | 16 ++++------- .../particle_mechanics_application.cpp | 1 + ...rticle_mechanics_application_variables.cpp | 1 + ...particle_mechanics_application_variables.h | 1 + .../python_scripts/mpm_explicit_solver.py | 5 ++-- 9 files changed, 30 insertions(+), 35 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index 10ba0e0664e8..0805a7b528da 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -302,7 +302,7 @@ void UpdatedLagrangianQuadrilateral::CalculateElementalSystem( LocalSystemCompon Flags &ConstitutiveLawOptions=Values.GetOptions(); ConstitutiveLawOptions.Set(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR); - if (!mIsExplicit) + if (!rCurrentProcessInfo.Has(IS_EXPLICIT)) { ConstitutiveLawOptions.Set(ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN); ConstitutiveLawOptions.Set(ConstitutiveLaw::COMPUTE_STRESS); @@ -343,7 +343,7 @@ void UpdatedLagrangianQuadrilateral::CalculateElementalSystem( LocalSystemCompon { // Contribution to forces (in residual term) are calculated Vector volume_force = mMP.volume_acceleration * mMP.mass; - this->CalculateAndAddRHS ( rLocalSystem, Variables, volume_force, mMP.volume ); + this->CalculateAndAddRHS ( rLocalSystem, Variables, volume_force, mMP.volume, rCurrentProcessInfo); } KRATOS_CATCH( "" ) @@ -464,7 +464,12 @@ void UpdatedLagrangianQuadrilateral::CalculateDeformationMatrix(Matrix& rB, //************************************************************************************ //************************************************************************************ -void UpdatedLagrangianQuadrilateral::CalculateAndAddRHS(LocalSystemComponents& rLocalSystem, GeneralVariables& rVariables, Vector& rVolumeForce, const double& rIntegrationWeight) +void UpdatedLagrangianQuadrilateral::CalculateAndAddRHS( + LocalSystemComponents& rLocalSystem, + GeneralVariables& rVariables, + Vector& rVolumeForce, + const double& rIntegrationWeight, + ProcessInfo& rCurrentProcessInfo) { // Contribution of the internal and external forces if( rLocalSystem.CalculationFlags.Is( UpdatedLagrangianQuadrilateral::COMPUTE_RHS_VECTOR_WITH_COMPONENTS ) ) @@ -499,7 +504,7 @@ void UpdatedLagrangianQuadrilateral::CalculateAndAddRHS(LocalSystemComponents& r // Operation performed: rRightHandSideVector += ExtForce*IntToReferenceWeight this->CalculateAndAddExternalForces( rRightHandSideVector, rVariables, rVolumeForce, rIntegrationWeight ); - if (mIsExplicit) + if (rCurrentProcessInfo.Has(IS_EXPLICIT)) { // Operation performed: rRightHandSideVector -= IntForce*IntToReferenceWeight this->CalculateAndAddExplicitInternalForces(rRightHandSideVector); @@ -909,9 +914,7 @@ void UpdatedLagrangianQuadrilateral::InitializeSolutionStep( ProcessInfo& rCurre // Calculating shape function Variables.N = this->MPMShapeFunctionPointValues(Variables.N, mMP.xg); mN = Variables.N; - mFinalizedStep = false; - mIsExplicit = rCurrentProcessInfo.Has(IS_EXPLICIT); array_1d aux_MP_velocity = ZeroVector(3); array_1d aux_MP_acceleration = ZeroVector(3); @@ -919,7 +922,7 @@ void UpdatedLagrangianQuadrilateral::InitializeSolutionStep( ProcessInfo& rCurre array_1d nodal_inertia = ZeroVector(3); // TODO, We should never retrieve previous nodal values in MPM. The below should be mapping particle accelerations to the grid. - if (!mIsExplicit) + if (!rCurrentProcessInfo.Has(IS_EXPLICIT)) { for (unsigned int j = 0; j < number_of_nodes; j++) { @@ -983,10 +986,8 @@ void UpdatedLagrangianQuadrilateral::InitializeNonLinearIteration(ProcessInfo& r KRATOS_TRY - if (mIsExplicit) + if (rCurrentProcessInfo.Has(IS_EXPLICIT) && rCurrentProcessInfo.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 0) { - mIsUSFStressUpdate = true; - // Create and initialize element variables: GeneralVariables Variables; this->InitializeGeneralVariables(Variables, rCurrentProcessInfo); @@ -1017,7 +1018,7 @@ void UpdatedLagrangianQuadrilateral::FinalizeSolutionStep(ProcessInfo& rCurrentP { KRATOS_TRY - if (!mIsExplicit) + if (!rCurrentProcessInfo.Has(IS_EXPLICIT)) { FinalizeImplicitSolutionStep(rCurrentProcessInfo); } @@ -1071,8 +1072,9 @@ void UpdatedLagrangianQuadrilateral::FinalizeExplicitSolutionStep(ProcessInfo& r bool calculateStresses = true; GeometryType& rGeom = GetGeometry(); - if (mIsUSFStressUpdate) + if (rCurrentProcessInfo.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 0) { + // USF stresses already calculated calculateStresses = false; } else @@ -1123,7 +1125,7 @@ void UpdatedLagrangianQuadrilateral::FinalizeExplicitSolutionStep(ProcessInfo& r mFinalizedStep = true; } - if (mIsUSFStressUpdate) + if (rCurrentProcessInfo.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 0) { mFinalizedStep = true; } diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp index e159b136b8a3..b60392f449eb 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp @@ -628,13 +628,6 @@ class UpdatedLagrangianQuadrilateral /// Container to store shape function gradients over whole timestep Matrix mDN_DX; - /// Boolean for explicit time integration - bool mIsExplicit = false; - - /// Boolean for stress update option - bool mIsUSFStressUpdate = false; - - ///@} ///@name Protected Operators ///@{ @@ -667,7 +660,8 @@ class UpdatedLagrangianQuadrilateral virtual void CalculateAndAddRHS(LocalSystemComponents& rLocalSystem, GeneralVariables& rVariables, Vector& rVolumeForce, - const double& rIntegrationWeight); + const double& rIntegrationWeight, + ProcessInfo& rCurrentProcessInfo); /** diff --git a/applications/ParticleMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp b/applications/ParticleMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp index 343b0fb41408..4f27af2186ef 100644 --- a/applications/ParticleMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp +++ b/applications/ParticleMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp @@ -75,7 +75,7 @@ namespace Python{ // MPM Explicit Scheme Type py::class_< MPMExplicitSchemeType, typename MPMExplicitSchemeType::Pointer, BaseSchemeType >(m, "MPMExplicitScheme") - .def(py::init < ModelPart&, const int, const bool>()) + .def(py::init < ModelPart& >()) .def("Initialize", &MPMExplicitSchemeType::Initialize) ; diff --git a/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp b/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp index 38b4922e2c26..2c4c4fa9fc93 100644 --- a/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp +++ b/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp @@ -161,6 +161,7 @@ namespace Python{ KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, MUSL_VELOCITY_FIELD_IS_COMPUTED); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, IS_EXPLICIT); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, IS_EXPLICIT_CENTRAL_DIFFERENCE); + KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, EXPLICIT_STRESS_UPDATE_OPTION); } } // namespace Python. diff --git a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp index 508b5a6fb358..48e3c87878b2 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp @@ -95,13 +95,10 @@ namespace Kratos { * @param DeltaTimePredictionLevel The prediction level */ MPMExplicitScheme( - ModelPart& grid_model_part, - const int StressUpdateOption, - const bool isCentralDifference + ModelPart& grid_model_part ) : Scheme(), - mr_grid_model_part(grid_model_part), - mStressUpdateOption(StressUpdateOption) + mr_grid_model_part(grid_model_part) { } @@ -271,7 +268,7 @@ namespace Kratos { } // for DomainSize // We need to set updated grid velocity here if we are using the USL formulation - if (mStressUpdateOption == 1) + if (r_current_process_info.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 1) { array_1d& r_current_velocity = itCurrentNode->FastGetSolutionStepValue(VELOCITY); r_current_velocity.clear(); @@ -409,7 +406,7 @@ namespace Kratos { Scheme::InitializeSolutionStep(r_model_part, A, Dx, b); // If we are updating stress first (USF and central difference), calculate nodal velocities from momenta and apply BCs - if (mStressUpdateOption == 0 || rCurrentProcessInfo.Has(IS_EXPLICIT_CENTRAL_DIFFERENCE)) + if (rCurrentProcessInfo.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 0 || rCurrentProcessInfo.Has(IS_EXPLICIT_CENTRAL_DIFFERENCE)) { const IndexType DisplacementPosition = mr_grid_model_part.NodesBegin()->GetDofPosition(DISPLACEMENT_X); @@ -466,7 +463,7 @@ namespace Kratos { ElementsArrayType& rElements = rModelPart.Elements(); const ProcessInfo& rCurrentProcessInfo = rModelPart.GetProcessInfo(); - if (mStressUpdateOption == 2) + if (rCurrentProcessInfo.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 2) { PerformModifiedUpdateStressLastMapping(rCurrentProcessInfo, rModelPart, rElements); } @@ -559,7 +556,7 @@ namespace Kratos { // This calculates the stresses before momenta update. // Used for USF and Central Difference method - if (mStressUpdateOption == 0 || rCurrentProcessInfo.Has(IS_EXPLICIT_CENTRAL_DIFFERENCE)) + if (rCurrentProcessInfo.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 0 || rCurrentProcessInfo.Has(IS_EXPLICIT_CENTRAL_DIFFERENCE)) { ElementsArrayType& pElements = r_model_part.Elements(); ProcessInfo& CurrentProcessInfo = r_model_part.GetProcessInfo(); @@ -805,7 +802,6 @@ namespace Kratos { // TODO check if this is needed TimeVariables mTime; /// This struct contains the details of the time variables ModelPart& mr_grid_model_part; - const int mStressUpdateOption; // 0 = USF, 1 = USL, 2 = MUSL private: }; /* Class MPMExplicitScheme */ diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp b/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp index 2522848dc65c..bc0c4a95a5f5 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp @@ -257,6 +257,7 @@ namespace Kratos KRATOS_REGISTER_VARIABLE(MUSL_VELOCITY_FIELD_IS_COMPUTED) KRATOS_REGISTER_VARIABLE(IS_EXPLICIT) KRATOS_REGISTER_VARIABLE(IS_EXPLICIT_CENTRAL_DIFFERENCE) + KRATOS_REGISTER_VARIABLE(EXPLICIT_STRESS_UPDATE_OPTION) } } // namespace Kratos. diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp index 65d01ed20a90..242e05d21d7f 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp @@ -98,4 +98,5 @@ namespace Kratos KRATOS_CREATE_VARIABLE(bool, MUSL_VELOCITY_FIELD_IS_COMPUTED) KRATOS_CREATE_VARIABLE(bool, IS_EXPLICIT) KRATOS_CREATE_VARIABLE(bool, IS_EXPLICIT_CENTRAL_DIFFERENCE) + KRATOS_CREATE_VARIABLE(int, EXPLICIT_STRESS_UPDATE_OPTION) } \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h index b86b8955c68a..09cdb45556e2 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h @@ -124,6 +124,7 @@ namespace Kratos KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, MUSL_VELOCITY_FIELD_IS_COMPUTED) KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, IS_EXPLICIT) KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, IS_EXPLICIT_CENTRAL_DIFFERENCE) + KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, int, EXPLICIT_STRESS_UPDATE_OPTION) } #endif // KRATOS_PARTICLE_MECHANICS_APPLICATION_VARIABLES_H_INCLUDED defined \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py b/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py index a064addeadf3..380cffceb26d 100644 --- a/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py +++ b/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py @@ -72,6 +72,7 @@ def _CreateSolutionScheme(self): else: err_msg = "The requested stress update \"" + stress_update + "\" is not available!\n" err_msg += "Available options are: \"USF\", \"USL\",\"MUSL\"" + grid_model_part.ProcessInfo.SetValue(KratosParticle.EXPLICIT_STRESS_UPDATE_OPTION, StressUpdateOption) elif(scheme_type == "central_difference" or scheme_type == "Central_Difference"): isCentralDifference = True grid_model_part.ProcessInfo.SetValue(KratosParticle.IS_EXPLICIT_CENTRAL_DIFFERENCE, True) @@ -82,9 +83,7 @@ def _CreateSolutionScheme(self): is_dynamic = self._IsDynamic() - return KratosParticle.MPMExplicitScheme( grid_model_part, - StressUpdateOption, - isCentralDifference) + return KratosParticle.MPMExplicitScheme( grid_model_part) def _CreateSolutionStrategy(self): analysis_type = self.settings["analysis_type"].GetString() From c15315b3945d450ffea9f6239f953a833f0995c3 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Tue, 7 Apr 2020 11:11:00 +1000 Subject: [PATCH 098/314] [skip ci] add explicit gravity test --- ...llating_point_gravity_test_parameters.json | 91 +++++++++++++++++++ ...scillating_point_gravity_test_results.json | 1 + .../tests/particle_mechanics_test_factory.py | 5 +- .../test_ParticleMechanicsApplication.py | 2 +- 4 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_gravity_test_parameters.json create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_gravity_test_results.json diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_gravity_test_parameters.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_gravity_test_parameters.json new file mode 100644 index 000000000000..aa913a3c9778 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_gravity_test_parameters.json @@ -0,0 +1,91 @@ +{ + "problem_data" : { + "problem_name" : "explicit_oscillating_point_gravity_test", + "parallel_type" : "OpenMP", + "echo_level" : 0, + "start_time" : 0.0, + "end_time" : 0.5 + }, + "solver_settings" : { + "solver_type" : "Dynamic", + "model_part_name" : "MPM_Material", + "domain_size" : 2, + "echo_level" : 0, + "analysis_type" : "linear", + "time_integration_method" : "explicit", + "scheme_type" : "forward_euler", + "stress_update" : "musl", + "compressible" : false, + "model_import_settings" : { + "input_type" : "mdpa", + "input_filename" : "explicit_tests/oscillating_point/explicit_oscillating_point_test_Body" + }, + "material_import_settings" : { + "materials_filename" : "explicit_tests/oscillating_point/explicit_oscillating_point_test_materials.json" + }, + "time_stepping" : { + "time_step" : 0.05 + }, + "convergence_criterion" : "residual_criterion", + "displacement_relative_tolerance" : 0.0001, + "displacement_absolute_tolerance" : 1e-9, + "residual_relative_tolerance" : 0.0001, + "residual_absolute_tolerance" : 1e-9, + "max_iteration" : 10, + "problem_domain_sub_model_part_list" : ["Parts_bar","Parts_grid"], + "processes_sub_model_part_list" : ["DISPLACEMENT_Displacement_Auto1"], + "grid_model_import_settings" : { + "input_type" : "mdpa", + "input_filename" : "explicit_tests/oscillating_point/explicit_oscillating_point_test_Grid" + }, + "pressure_dofs" : false + }, + "processes" : { + "constraints_process_list" : [{ + "python_module" : "assign_vector_variable_process", + "kratos_module" : "KratosMultiphysics", + "Parameters" : { + "model_part_name" : "Background_Grid.DISPLACEMENT_Displacement_Auto1", + "variable_name" : "DISPLACEMENT", + "constrained" : [true,true,true], + "value" : [0.0,0.0,0.0], + "interval" : [0.0,"End"] + } + }], + "gravity" : [{ + "python_module" : "assign_gravity_to_particle_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "process_name" : "AssignGravityToParticleProcess", + "Parameters" : { + "model_part_name" : "MPM_Material", + "variable_name" : "MP_VOLUME_ACCELERATION", + "modulus" : 1.0, + "direction" : [1.0,0.0,0.0] + } + }], + "list_other_processes" : [{ + "python_module" : "particle_from_json_check_result_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "help" : "", + "process_name" : "ParticleFromJsonCheckResultProcess", + "Parameters" : { + "check_variables" : ["MP_VELOCITY","MP_DISPLACEMENT"], + "input_file_name" : "explicit_tests/oscillating_point/explicit_oscillating_point_gravity_test_results.json", + "model_part_name" : "MPM_Material", + "time_frequency" : 0.5 + } + }] + }, + "print_output_process" : [{ + "python_module" : "particle_json_output_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "help" : "", + "process_name" : "ParticleJsonOutputProcess", + "Parameters" : { + "gauss_points_output_variables" : ["MP_VELOCITY","MP_DISPLACEMENT"], + "output_file_name" : "explicit_tests/oscillating_point/explicit_oscillating_point_gravity_test_results.json", + "model_part_name" : "MPM_Material", + "time_frequency" : 0.5 + } + }] +} diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_gravity_test_results.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_gravity_test_results.json new file mode 100644 index 000000000000..01c8fce5e4a1 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_gravity_test_results.json @@ -0,0 +1 @@ +{"TIME": [0.5499999999999999], "PARTICLE_57": {"MP_VELOCITY_X": [-0.022856844929611164], "MP_VELOCITY_Y": [0.0], "MP_VELOCITY_Z": [0.0], "MP_DISPLACEMENT_X": [0.024896886207813072], "MP_DISPLACEMENT_Y": [0.0], "MP_DISPLACEMENT_Z": [0.0]}} \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py b/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py index 18a2b14d629c..caa4cd90c677 100644 --- a/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py +++ b/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py @@ -106,4 +106,7 @@ class ExplicitOscillatingPointCentralDifferenceTest(ParticleMechanicsTestFactory file_name = "explicit_tests/oscillating_point/central_difference_explicit_oscillating_point_test" class ExplicitOscillatingPointYCompressibleTest(ParticleMechanicsTestFactory): - file_name = "explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test" \ No newline at end of file + file_name = "explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test" + +class ExplicitOscillatingPointGravityTest(ParticleMechanicsTestFactory): + file_name = "explicit_tests/oscillating_point/explicit_oscillating_point_gravity_test" \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py index 9bcd5e922527..54bde80a6944 100644 --- a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py +++ b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py @@ -86,7 +86,7 @@ def AssembleTestSuites(): ## These tests are executed in the nightly build nightSuite = suites['nightly'] nightSuite.addTests(smallSuite) - + nightSuite.addTest(TAxisSymmetricCircularPlate2DTriTest('test_execution')) nightSuite.addTest(TBeamCantileverStaticLinearElasticPointLoad2DTriTest('test_execution')) From 4c33babec020b16f52f949f2c33b06a799784486 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Tue, 7 Apr 2020 11:11:39 +1000 Subject: [PATCH 099/314] [skip ci] add explicit gravity test 2 --- .../tests/test_ParticleMechanicsApplication.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py index 54bde80a6944..e369126d7859 100644 --- a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py +++ b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py @@ -33,6 +33,8 @@ from particle_mechanics_test_factory import ExplicitOscillatingPointMUSLTest as TExplicitOscillatingPointMUSLTest from particle_mechanics_test_factory import ExplicitOscillatingPointCentralDifferenceTest as TExplicitOscillatingPointCentralDifferenceTest from particle_mechanics_test_factory import ExplicitOscillatingPointYCompressibleTest as TExplicitOscillatingPointYCompressibleTest +from particle_mechanics_test_factory import ExplicitOscillatingPointGravityTest as TExplicitOscillatingPointGravityTest + # Import from Test Factories (with different analysis flows) @@ -108,6 +110,7 @@ def AssembleTestSuites(): nightSuite.addTest(TExplicitOscillatingPointMUSLTest('test_execution')) nightSuite.addTest(TExplicitOscillatingPointCentralDifferenceTest('test_execution')) nightSuite.addTest(TExplicitOscillatingPointYCompressibleTest('test_execution')) + nightSuite.addTest(TExplicitOscillatingPointGravityTest('test_execution')) ### Adding Validation Tests ## For very long tests that should not be in nighly and you can use to validate From 6b82d4e79b73a453968bfa27b4c674e5a095412c Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Tue, 7 Apr 2020 15:27:41 +1000 Subject: [PATCH 100/314] [skip ci] fix MUSL formulation --- .../updated_lagrangian_quadrilateral.cpp | 7 +++---- .../schemes/mpm_explicit_scheme.hpp | 12 ++++-------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index 0805a7b528da..caa163745a48 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -1079,9 +1079,9 @@ void UpdatedLagrangianQuadrilateral::FinalizeExplicitSolutionStep(ProcessInfo& r } else { - if (rGeom[0].Has(MUSL_VELOCITY_FIELD_IS_COMPUTED)) + if (rCurrentProcessInfo.Has(MUSL_VELOCITY_FIELD_IS_COMPUTED)) { - if (!rGeom[0].GetValue(MUSL_VELOCITY_FIELD_IS_COMPUTED)) + if (!rCurrentProcessInfo.GetValue(MUSL_VELOCITY_FIELD_IS_COMPUTED)) { // MUSL nodal velocity field has not been computed. Therefore we do not calculate stresses this time. // We need to map the updated particle velocities back to the nodes. @@ -1104,10 +1104,9 @@ void UpdatedLagrangianQuadrilateral::FinalizeExplicitSolutionStep(ProcessInfo& r MPMExplicitUtilities::UpdateGaussPointExplicit(rGeom, delta_time, isCentralDifference, *this, mN); // If we are doing MUSL, map updated particle velocities back to the grid - if (rGeom[0].Has(MUSL_VELOCITY_FIELD_IS_COMPUTED)) + if (rCurrentProcessInfo.Has(MUSL_VELOCITY_FIELD_IS_COMPUTED)) { MPMExplicitUtilities::CalculateMUSLGridVelocity(rGeom, *this, mN); - rGeom[0].SetValue(MUSL_VELOCITY_FIELD_IS_COMPUTED, true); } } diff --git a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp index 48e3c87878b2..7ff4ed97ec38 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp @@ -461,7 +461,7 @@ namespace Kratos { KRATOS_TRY ElementsArrayType& rElements = rModelPart.Elements(); - const ProcessInfo& rCurrentProcessInfo = rModelPart.GetProcessInfo(); + ProcessInfo& rCurrentProcessInfo = rModelPart.GetProcessInfo(); if (rCurrentProcessInfo.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 2) { @@ -493,7 +493,7 @@ namespace Kratos { //*************************************************************************** //*************************************************************************** - void PerformModifiedUpdateStressLastMapping(const ProcessInfo& rCurrentProcessInfo, ModelPart& rModelPart, ElementsArrayType& rElements) + void PerformModifiedUpdateStressLastMapping(ProcessInfo& rCurrentProcessInfo, ModelPart& rModelPart, ElementsArrayType& rElements) { // MUSL stress update. This works by projecting the updated particle // velocity back to the nodes. The nodal velocity field is then @@ -502,18 +502,14 @@ namespace Kratos { // We need to call 'FinalizeSolutionStep' twice. // First, to update the particles and then aggregate the new particle velocities on the grid. // Second, to calculate the stresses from the grid velocity - for (int iter = 0; iter < static_cast(mr_grid_model_part.Nodes().size()); ++iter) - { - auto i = mr_grid_model_part.NodesBegin() + iter; - (i)->SetValue(MUSL_VELOCITY_FIELD_IS_COMPUTED, false); - } - + rCurrentProcessInfo.SetValue(MUSL_VELOCITY_FIELD_IS_COMPUTED, false); // Call each particle and aggregate the nodal velocity field for (ElementsArrayType::iterator it = rElements.begin(); it != rElements.end(); ++it) { (it)->FinalizeSolutionStep(rCurrentProcessInfo); } + rCurrentProcessInfo.SetValue(MUSL_VELOCITY_FIELD_IS_COMPUTED, true); // Reapply dirichlet BCs to MUSL velocity field From 87b4e9d0e87333c7e01cf3d45adce316facd0c0c Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Tue, 7 Apr 2020 16:54:02 +1000 Subject: [PATCH 101/314] [skip ci] cleanup. dont use initializeNLiteration and use scheme instead --- .../updated_lagrangian_quadrilateral.cpp | 69 ++++---- .../updated_lagrangian_quadrilateral.hpp | 7 +- .../particle_mechanics_python_application.cpp | 1 + .../schemes/mpm_explicit_scheme.hpp | 158 ++++++------------ .../strategies/mpm_explicit_strategy.hpp | 8 +- .../particle_mechanics_application.cpp | 1 + ...rticle_mechanics_application_variables.cpp | 3 +- ...particle_mechanics_application_variables.h | 1 + 8 files changed, 94 insertions(+), 154 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index caa163745a48..15094ab801e6 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -975,41 +975,6 @@ void UpdatedLagrangianQuadrilateral::InitializeSolutionStep( ProcessInfo& rCurre } } -////************************************************************************************ -////************************************************************************************ - -void UpdatedLagrangianQuadrilateral::InitializeNonLinearIteration(ProcessInfo& rCurrentProcessInfo) -{ - // Currently this is only used for explicit time integration update stress first (USF) method. - // In this function we set the particle stress before the momenta update. - // This needs to occur after all particles are mapped to the grid, but before the momenta update. - - KRATOS_TRY - - if (rCurrentProcessInfo.Has(IS_EXPLICIT) && rCurrentProcessInfo.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 0) - { - // Create and initialize element variables: - GeneralVariables Variables; - this->InitializeGeneralVariables(Variables, rCurrentProcessInfo); - - // Calculate shape function gradients - Matrix Jacobian; - Jacobian = this->MPMJacobian(Jacobian, mMP.xg); - Matrix InvJ; - double detJ; - MathUtils::InvertMatrix(Jacobian, InvJ, detJ); - Matrix DN_De; - this->MPMShapeFunctionsLocalGradients(DN_De, mMP.xg); // parametric gradients - mDN_DX = prod(DN_De, InvJ); // cartesian gradients - - //calculate stress - this->CalculateExplicitStresses(rCurrentProcessInfo, Variables); - - this->FinalizeStepVariables(Variables, rCurrentProcessInfo); - } - - KRATOS_CATCH("") -} ////************************************************************************************ ////************************************************************************************ @@ -1956,6 +1921,40 @@ void UpdatedLagrangianQuadrilateral::DecimalCorrection(Vector& rVector) ///@name Access Get Values ///@{ +void UpdatedLagrangianQuadrilateral::CalculateOnIntegrationPoints(const Variable& rVariable, + std::vector& rValues, + const ProcessInfo& rCurrentProcessInfo) +{ + if (rValues.size() != 1) + rValues.resize(1); + + if (rVariable == CALCULATE_EXPLICIT_MP_STRESS) { + // Create and initialize element variables: + GeneralVariables Variables; + this->InitializeGeneralVariables(Variables, rCurrentProcessInfo); + + // Calculate shape function gradients + Matrix Jacobian; + Jacobian = this->MPMJacobian(Jacobian, mMP.xg); + Matrix InvJ; + double detJ; + MathUtils::InvertMatrix(Jacobian, InvJ, detJ); + Matrix DN_De; + this->MPMShapeFunctionsLocalGradients(DN_De, mMP.xg); // parametric gradients + mDN_DX = prod(DN_De, InvJ); // cartesian gradients + + //calculate stress + this->CalculateExplicitStresses(rCurrentProcessInfo, Variables); + this->FinalizeStepVariables(Variables, rCurrentProcessInfo); + + rValues[0] = true; + } + else + { + KRATOS_ERROR << "Variable " << rVariable << " is called in CalculateOnIntegrationPoints, but is not implemented." << std::endl; + } +} + void UpdatedLagrangianQuadrilateral::CalculateOnIntegrationPoints(const Variable& rVariable, std::vector& rValues, const ProcessInfo& rCurrentProcessInfo) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp index b60392f449eb..9c406a612ffb 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp @@ -416,9 +416,6 @@ class UpdatedLagrangianQuadrilateral */ void InitializeSolutionStep(ProcessInfo& rCurrentProcessInfo) override; - /// Called after InitializeSolutionStep at the start of the non-linear iteration - void InitializeNonLinearIteration(ProcessInfo& rCurrentProcessInfo) override; - /// Called at the end of each solution step void FinalizeSolutionStep(ProcessInfo& rCurrentProcessInfo) override; @@ -558,6 +555,10 @@ class UpdatedLagrangianQuadrilateral ///@name Access Get Values ///@{ + void CalculateOnIntegrationPoints(const Variable& rVariable, + std::vector& rValues, + const ProcessInfo& rCurrentProcessInfo) override; + void CalculateOnIntegrationPoints(const Variable& rVariable, std::vector& rValues, const ProcessInfo& rCurrentProcessInfo) override; diff --git a/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp b/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp index 2c4c4fa9fc93..80ac9b12e504 100644 --- a/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp +++ b/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp @@ -162,6 +162,7 @@ namespace Python{ KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, IS_EXPLICIT); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, IS_EXPLICIT_CENTRAL_DIFFERENCE); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, EXPLICIT_STRESS_UPDATE_OPTION); + KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, CALCULATE_EXPLICIT_MP_STRESS); } } // namespace Python. diff --git a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp index 7ff4ed97ec38..e282184f9847 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp @@ -405,50 +405,68 @@ namespace Kratos { // Extrapolate from Material Point Elements and Conditions Scheme::InitializeSolutionStep(r_model_part, A, Dx, b); - // If we are updating stress first (USF and central difference), calculate nodal velocities from momenta and apply BCs - if (rCurrentProcessInfo.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 0 || rCurrentProcessInfo.Has(IS_EXPLICIT_CENTRAL_DIFFERENCE)) + // If we are updating stress before momenta update (USF and central difference), + if (rCurrentProcessInfo.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 0 || rCurrentProcessInfo.Has(IS_EXPLICIT_CENTRAL_DIFFERENCE)) { + // calculate nodal velocities from momenta and apply BCs + calculateGridVelocityAndApplyDirichletBC(rCurrentProcessInfo,true); + + // calculate stresses + const auto it_elem_begin = r_model_part.ElementsBegin(); + #pragma omp parallel for + for (int i = 0; i < static_cast(r_model_part.Elements().size()); ++i) { + auto it_elem = it_elem_begin + i; + std::vector dummy; + it_elem->CalculateOnIntegrationPoints(CALCULATE_EXPLICIT_MP_STRESS, dummy, rCurrentProcessInfo); + } + } + + KRATOS_CATCH("") + } + + /// Apply Dirichlet BCs to nodal velocity field + void calculateGridVelocityAndApplyDirichletBC( + ProcessInfo rCurrentProcessInfo, + bool calculateVelocityFromMomenta = false) + { + KRATOS_TRY + + const IndexType DisplacementPosition = mr_grid_model_part.NodesBegin()->GetDofPosition(DISPLACEMENT_X); + const SizeType DomainSize = rCurrentProcessInfo[DOMAIN_SIZE]; + + #pragma omp parallel for + for (int iter = 0; iter < static_cast(mr_grid_model_part.Nodes().size()); ++iter) { - const IndexType DisplacementPosition = mr_grid_model_part.NodesBegin()->GetDofPosition(DISPLACEMENT_X); + NodeIterator i = mr_grid_model_part.NodesBegin() + iter; - #pragma omp parallel for - for (int iter = 0; iter < static_cast(mr_grid_model_part.Nodes().size()); ++iter) + if ((i)->Is(ACTIVE)) { - auto i = mr_grid_model_part.NodesBegin() + iter; + double& nodal_mass = (i)->FastGetSolutionStepValue(NODAL_MASS); + array_1d& nodal_momentum = (i)->FastGetSolutionStepValue(NODAL_MOMENTUM); + array_1d& nodal_velocity = (i)->FastGetSolutionStepValue(VELOCITY); + + std::array fix_displacements = { false, false, false }; + fix_displacements[0] = (i->GetDof(DISPLACEMENT_X, DisplacementPosition).IsFixed()); + fix_displacements[1] = (i->GetDof(DISPLACEMENT_Y, DisplacementPosition + 1).IsFixed()); + if (DomainSize == 3) + fix_displacements[2] = (i->GetDof(DISPLACEMENT_Z, DisplacementPosition + 2).IsFixed()); - if ((i)->Is(ACTIVE)) + for (IndexType j = 0; j < DomainSize; j++) { - const SizeType DomainSize = rCurrentProcessInfo[DOMAIN_SIZE]; - double& nodal_mass = (i)->FastGetSolutionStepValue(NODAL_MASS); - array_1d& nodal_momentum = (i)->FastGetSolutionStepValue(NODAL_MOMENTUM); - array_1d& nodal_velocity = (i)->FastGetSolutionStepValue(VELOCITY); - - std::array fix_displacements = { false, false, false }; - fix_displacements[0] = (i->GetDof(DISPLACEMENT_X, DisplacementPosition).IsFixed()); - fix_displacements[1] = (i->GetDof(DISPLACEMENT_Y, DisplacementPosition + 1).IsFixed()); - if (DomainSize == 3) - fix_displacements[2] = (i->GetDof(DISPLACEMENT_Z, DisplacementPosition + 2).IsFixed()); - - if (nodal_mass > numerical_limit) + if (fix_displacements[j]) + { + nodal_velocity[j] = 0.0; + } + else if (calculateVelocityFromMomenta && nodal_mass > numerical_limit) { - for (IndexType j = 0; j < DomainSize; j++) - { - if (fix_displacements[j]) - { - nodal_velocity[j] = 0.0; - } - else - { - nodal_velocity[j] = nodal_momentum[j] / nodal_mass; - } - } + nodal_velocity[j] = nodal_momentum[j] / nodal_mass; } } } } + KRATOS_CATCH("") } - /** Function called once at the end of a solution step, after convergence is reached if an iterative process is needed */ @@ -511,84 +529,8 @@ namespace Kratos { } rCurrentProcessInfo.SetValue(MUSL_VELOCITY_FIELD_IS_COMPUTED, true); - // Reapply dirichlet BCs to MUSL velocity field - const SizeType DomainSize = rCurrentProcessInfo[DOMAIN_SIZE]; - NodesArrayType& r_nodes = rModelPart.Nodes(); - const auto it_node_begin = rModelPart.NodesBegin(); - const IndexType DisplacementPosition = it_node_begin->GetDofPosition(DISPLACEMENT_X); - - for (int i = 0; i < static_cast(r_nodes.size()); ++i) - { - NodeIterator itCurrentNode = it_node_begin + i; - - std::array fix_displacements = { false, false, false }; - fix_displacements[0] = (itCurrentNode->GetDof(DISPLACEMENT_X, DisplacementPosition).IsFixed()); - fix_displacements[1] = (itCurrentNode->GetDof(DISPLACEMENT_Y, DisplacementPosition + 1).IsFixed()); - if (DomainSize == 3) - fix_displacements[2] = (itCurrentNode->GetDof(DISPLACEMENT_Z, DisplacementPosition + 2).IsFixed()); - - array_1d& r_current_velocity = itCurrentNode->FastGetSolutionStepValue(VELOCITY); - - for (IndexType j = 0; j < DomainSize; j++) - { - if (fix_displacements[j]) - { - r_current_velocity[j] = 0.0; - } - } - } - } - - - void InitializeNonLinIteration(ModelPart& r_model_part, - TSystemMatrixType& A, - TSystemVectorType& Dx, - TSystemVectorType& b) override - { - KRATOS_TRY - - ProcessInfo& rCurrentProcessInfo = r_model_part.GetProcessInfo(); - - // This calculates the stresses before momenta update. - // Used for USF and Central Difference method - if (rCurrentProcessInfo.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 0 || rCurrentProcessInfo.Has(IS_EXPLICIT_CENTRAL_DIFFERENCE)) - { - ElementsArrayType& pElements = r_model_part.Elements(); - ProcessInfo& CurrentProcessInfo = r_model_part.GetProcessInfo(); - - for (ElementsArrayType::iterator it = pElements.begin(); it != pElements.end(); ++it) - { - (it)->InitializeNonLinearIteration(CurrentProcessInfo); - } - - ConditionsArrayType& pConditions = r_model_part.Conditions(); - for (ConditionsArrayType::iterator it = pConditions.begin(); it != pConditions.end(); ++it) - { - (it)->InitializeNonLinearIteration(CurrentProcessInfo); - } - } - - KRATOS_CATCH("") - } - - //*************************************************************************** - //*************************************************************************** - - void InitializeNonLinearIteration(Condition::Pointer rCurrentCondition, - ProcessInfo& CurrentProcessInfo) override - { - (rCurrentCondition)->InitializeNonLinearIteration(CurrentProcessInfo); - } - - - //*************************************************************************** - //*************************************************************************** - - void InitializeNonLinearIteration(Element::Pointer rCurrentElement, - ProcessInfo& CurrentProcessInfo) override - { - (rCurrentElement)->InitializeNonLinearIteration(CurrentProcessInfo); + calculateGridVelocityAndApplyDirichletBC(rCurrentProcessInfo); } //*************************************************************************** diff --git a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp index e153ed0ffae5..7d0d84667e3e 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp @@ -246,19 +246,13 @@ namespace Kratos TSystemVectorType mDx = TSystemVectorType(); TSystemVectorType mb = TSystemVectorType(); - pScheme->InitializeNonLinIteration(BaseType::GetModelPart(), mA, mDx, mb); - // Compute residual forces on the model part this->CalculateAndAddRHS(pScheme, BaseType::GetModelPart()); pScheme->Update(BaseType::GetModelPart(), dof_set_dummy, mA, mDx, mb); - //pScheme->FinalizeNonLinIteration(BaseType::GetModelPart(), mA, mDx, mb); // TODO check if we need this - // Calculate reactions if required - if (mCalculateReactionsFlag) { - CalculateReactions(pScheme, BaseType::GetModelPart(), mA, mDx, mb); - } + if (mCalculateReactionsFlag) CalculateReactions(pScheme, BaseType::GetModelPart(), mA, mDx, mb); return true; } diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp b/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp index bc0c4a95a5f5..ecf8da877270 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp @@ -258,6 +258,7 @@ namespace Kratos KRATOS_REGISTER_VARIABLE(IS_EXPLICIT) KRATOS_REGISTER_VARIABLE(IS_EXPLICIT_CENTRAL_DIFFERENCE) KRATOS_REGISTER_VARIABLE(EXPLICIT_STRESS_UPDATE_OPTION) + KRATOS_REGISTER_VARIABLE(CALCULATE_EXPLICIT_MP_STRESS) } } // namespace Kratos. diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp index 242e05d21d7f..3d33368ee391 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp @@ -98,5 +98,6 @@ namespace Kratos KRATOS_CREATE_VARIABLE(bool, MUSL_VELOCITY_FIELD_IS_COMPUTED) KRATOS_CREATE_VARIABLE(bool, IS_EXPLICIT) KRATOS_CREATE_VARIABLE(bool, IS_EXPLICIT_CENTRAL_DIFFERENCE) - KRATOS_CREATE_VARIABLE(int, EXPLICIT_STRESS_UPDATE_OPTION) + KRATOS_CREATE_VARIABLE(int, EXPLICIT_STRESS_UPDATE_OPTION) + KRATOS_CREATE_VARIABLE(bool, CALCULATE_EXPLICIT_MP_STRESS) } \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h index 09cdb45556e2..8cb763abc6d6 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h @@ -125,6 +125,7 @@ namespace Kratos KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, IS_EXPLICIT) KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, IS_EXPLICIT_CENTRAL_DIFFERENCE) KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, int, EXPLICIT_STRESS_UPDATE_OPTION) + KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, CALCULATE_EXPLICIT_MP_STRESS) } #endif // KRATOS_PARTICLE_MECHANICS_APPLICATION_VARIABLES_H_INCLUDED defined \ No newline at end of file From d38c24cad3a3cf948ebfbcd2b73ed152074a09ba Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Tue, 7 Apr 2020 17:11:56 +1000 Subject: [PATCH 102/314] [skip ci] transition to scheme based implementation --- .../updated_lagrangian_quadrilateral.cpp | 40 ++++++++++--------- .../particle_mechanics_python_application.cpp | 1 + .../mpm_explicit_utilities.cpp | 5 ++- .../custom_utilities/mpm_explicit_utilities.h | 6 +-- .../particle_mechanics_application.cpp | 1 + ...rticle_mechanics_application_variables.cpp | 1 + ...particle_mechanics_application_variables.h | 1 + 7 files changed, 31 insertions(+), 24 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index 15094ab801e6..f71e8f05fda0 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -1062,29 +1062,14 @@ void UpdatedLagrangianQuadrilateral::FinalizeExplicitSolutionStep(ProcessInfo& r if (mapGridToParticles) { - const double& delta_time = rCurrentProcessInfo[DELTA_TIME]; - - // Map grid to particle - bool isCentralDifference = rCurrentProcessInfo.Has(IS_EXPLICIT_CENTRAL_DIFFERENCE); - MPMExplicitUtilities::UpdateGaussPointExplicit(rGeom, delta_time, isCentralDifference, *this, mN); - - // If we are doing MUSL, map updated particle velocities back to the grid - if (rCurrentProcessInfo.Has(MUSL_VELOCITY_FIELD_IS_COMPUTED)) - { - MPMExplicitUtilities::CalculateMUSLGridVelocity(rGeom, *this, mN); - } + std::vector dummy; + this->CalculateOnIntegrationPoints(EXPLICIT_MAP_GRID_TO_MP, dummy, rCurrentProcessInfo); } if (calculateStresses) { - // Create and initialize element variables: - GeneralVariables Variables; - this->InitializeGeneralVariables(Variables, rCurrentProcessInfo); - - //calculate stress - this->CalculateExplicitStresses(rCurrentProcessInfo, Variables); - - this->FinalizeStepVariables(Variables, rCurrentProcessInfo); + std::vector dummy; + this->CalculateOnIntegrationPoints(CALCULATE_EXPLICIT_MP_STRESS, dummy, rCurrentProcessInfo); mFinalizedStep = true; } @@ -1929,6 +1914,7 @@ void UpdatedLagrangianQuadrilateral::CalculateOnIntegrationPoints(const Variable rValues.resize(1); if (rVariable == CALCULATE_EXPLICIT_MP_STRESS) { + // Create and initialize element variables: GeneralVariables Variables; this->InitializeGeneralVariables(Variables, rCurrentProcessInfo); @@ -1949,6 +1935,22 @@ void UpdatedLagrangianQuadrilateral::CalculateOnIntegrationPoints(const Variable rValues[0] = true; } + else if (rVariable == EXPLICIT_MAP_GRID_TO_MP) { + + const double& delta_time = rCurrentProcessInfo[DELTA_TIME]; + + // Map grid to particle + bool isCentralDifference = rCurrentProcessInfo.Has(IS_EXPLICIT_CENTRAL_DIFFERENCE); + MPMExplicitUtilities::UpdateGaussPointExplicit(delta_time, isCentralDifference, *this, mN); + + // If we are doing MUSL, map updated particle velocities back to the grid + if (rCurrentProcessInfo.Has(MUSL_VELOCITY_FIELD_IS_COMPUTED)) + { + MPMExplicitUtilities::CalculateMUSLGridVelocity(*this, mN); + } + + rValues[0] = true; + } else { KRATOS_ERROR << "Variable " << rVariable << " is called in CalculateOnIntegrationPoints, but is not implemented." << std::endl; diff --git a/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp b/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp index 80ac9b12e504..d21ca05cf706 100644 --- a/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp +++ b/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp @@ -163,6 +163,7 @@ namespace Python{ KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, IS_EXPLICIT_CENTRAL_DIFFERENCE); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, EXPLICIT_STRESS_UPDATE_OPTION); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, CALCULATE_EXPLICIT_MP_STRESS); + KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, EXPLICIT_MAP_GRID_TO_MP); } } // namespace Python. diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp index 0d6f4bd89498..a4062241070e 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp @@ -85,7 +85,6 @@ namespace Kratos /***********************************************************************************/ void MPMExplicitUtilities::UpdateGaussPointExplicit( - GeometryType& rGeom, const double& rDeltaTime, const bool& isCentralDifference, Element& rElement, @@ -93,6 +92,7 @@ namespace Kratos { KRATOS_TRY + GeometryType& rGeom = rElement.GetGeometry(); const SizeType number_of_nodes = rGeom.PointsNumber(); const SizeType dimension = rGeom.WorkingSpaceDimension(); bool isUpdateMPPositionFromUpdatedMPVelocity = true; // should normally be true. this reduces energy lost from kinematic aliasing @@ -179,11 +179,12 @@ namespace Kratos /***********************************************************************************/ void MPMExplicitUtilities::CalculateMUSLGridVelocity( - GeometryType& rGeom, Element& rElement, Vector& rN) { KRATOS_TRY + + GeometryType& rGeom = rElement.GetGeometry(); const SizeType dimension = rGeom.WorkingSpaceDimension(); const SizeType number_of_nodes = rGeom.PointsNumber(); const ProcessInfo& rProcessInfo = ProcessInfo(); diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h index 96c4353a90b0..40304c786579 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h @@ -47,11 +47,11 @@ namespace Kratos const Matrix& rDN_DX, const Vector& rMPStress, const double& rMPVolume, Vector& rRightHandSideVector); - void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) UpdateGaussPointExplicit(GeometryType& rGeom, - const double& rDeltaTime, const bool& isCentralDifference, Element& rElement, Vector& rN); + void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) UpdateGaussPointExplicit(const double& rDeltaTime, + const bool& isCentralDifference, Element& rElement, Vector& rN); - void CalculateMUSLGridVelocity(GeometryType& rGeom, Element& rElement, Vector& rN); + void CalculateMUSLGridVelocity(Element& rElement, Vector& rN); void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) CalculateExplicitKinematics(GeometryType& rGeom, diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp b/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp index ecf8da877270..a93941311678 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp @@ -259,6 +259,7 @@ namespace Kratos KRATOS_REGISTER_VARIABLE(IS_EXPLICIT_CENTRAL_DIFFERENCE) KRATOS_REGISTER_VARIABLE(EXPLICIT_STRESS_UPDATE_OPTION) KRATOS_REGISTER_VARIABLE(CALCULATE_EXPLICIT_MP_STRESS) + KRATOS_REGISTER_VARIABLE(EXPLICIT_MAP_GRID_TO_MP) } } // namespace Kratos. diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp index 3d33368ee391..8588c8a5927b 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp @@ -100,4 +100,5 @@ namespace Kratos KRATOS_CREATE_VARIABLE(bool, IS_EXPLICIT_CENTRAL_DIFFERENCE) KRATOS_CREATE_VARIABLE(int, EXPLICIT_STRESS_UPDATE_OPTION) KRATOS_CREATE_VARIABLE(bool, CALCULATE_EXPLICIT_MP_STRESS) + KRATOS_CREATE_VARIABLE(bool, EXPLICIT_MAP_GRID_TO_MP) } \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h index 8cb763abc6d6..9818aebdb1ee 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h @@ -126,6 +126,7 @@ namespace Kratos KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, IS_EXPLICIT_CENTRAL_DIFFERENCE) KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, int, EXPLICIT_STRESS_UPDATE_OPTION) KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, CALCULATE_EXPLICIT_MP_STRESS) + KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, EXPLICIT_MAP_GRID_TO_MP) } #endif // KRATOS_PARTICLE_MECHANICS_APPLICATION_VARIABLES_H_INCLUDED defined \ No newline at end of file From ee420d01b6d35e1d90be1444cda0a2f1bedfbffc Mon Sep 17 00:00:00 2001 From: Inigo Lopez Date: Tue, 7 Apr 2020 11:09:43 +0200 Subject: [PATCH 103/314] fixing sdof static test --- .../python_scripts/solver_wrappers/sdof/sdof_static_solver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/CoSimulationApplication/python_scripts/solver_wrappers/sdof/sdof_static_solver.py b/applications/CoSimulationApplication/python_scripts/solver_wrappers/sdof/sdof_static_solver.py index 0df9306d951a..a818e8158cd4 100644 --- a/applications/CoSimulationApplication/python_scripts/solver_wrappers/sdof/sdof_static_solver.py +++ b/applications/CoSimulationApplication/python_scripts/solver_wrappers/sdof/sdof_static_solver.py @@ -112,7 +112,7 @@ def SetSolutionStepValue(self, identifier, value, buffer_idx=0): raise Exception("Identifier is unknown!") def ValidateAndAssignDefaults(defaults, settings, recursive=False): - for key in settings.items(): + for key, val in settings.items(): # check if the current entry also exists in the defaults if not key in defaults.keys(): err_msg = 'The item with name "' + key + '" is present in this ' From 04a067b85e5368faff4a5243972b7ab459328744 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20Irazabal?= Date: Tue, 7 Apr 2020 11:13:35 +0200 Subject: [PATCH 104/314] fixing DamApp --- .../custom_processes/apply_component_table_process.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/DamApplication/custom_processes/apply_component_table_process.hpp b/applications/DamApplication/custom_processes/apply_component_table_process.hpp index 79cbcbc2602d..6ab433c43e4a 100644 --- a/applications/DamApplication/custom_processes/apply_component_table_process.hpp +++ b/applications/DamApplication/custom_processes/apply_component_table_process.hpp @@ -91,7 +91,7 @@ class ApplyComponentTableProcessDam : public Process { KRATOS_TRY; - typedef VariableComponent< VectorComponentAdaptor > > component_type; + typedef Variable component_type; component_type var_component = KratosComponents< component_type >::Get(mvariable_name); const int nnodes = static_cast(mr_model_part.Nodes().size()); @@ -122,7 +122,7 @@ class ApplyComponentTableProcessDam : public Process { KRATOS_TRY; - typedef VariableComponent< VectorComponentAdaptor > > component_type; + typedef Variable component_type; component_type var_component = KratosComponents< component_type >::Get(mvariable_name); const double Time = mr_model_part.GetProcessInfo()[TIME]/mTimeUnitConverter; From 6e4ef58a57d16ac75d7195ff3d6004ab064dc7fd Mon Sep 17 00:00:00 2001 From: Ignasi de Pouplana Date: Tue, 7 Apr 2020 11:20:31 +0200 Subject: [PATCH 105/314] Fixing DemStructuresCouplingApp --- .../custom_processes/control_module_process.hpp | 6 +++--- .../custom_utilities/control_module_fem_dem_utilities.hpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/applications/DemStructuresCouplingApplication/custom_processes/control_module_process.hpp b/applications/DemStructuresCouplingApplication/custom_processes/control_module_process.hpp index f7c8f1f0edcf..c28ca4a7d0b9 100644 --- a/applications/DemStructuresCouplingApplication/custom_processes/control_module_process.hpp +++ b/applications/DemStructuresCouplingApplication/custom_processes/control_module_process.hpp @@ -120,7 +120,7 @@ class ControlModuleProcess : public Process const int NNodes = static_cast(mrModelPart.Nodes().size()); ModelPart::NodesContainerType::iterator it_begin = mrModelPart.NodesBegin(); - typedef VariableComponent< VectorComponentAdaptor > > ComponentType; + typedef Variable ComponentType; if(mRadialDisplacement == true) { ComponentType VarComponentX = KratosComponents< ComponentType >::Get(mVariableNameX); @@ -172,7 +172,7 @@ class ControlModuleProcess : public Process FaceArea += itCond->GetGeometry().Area(); } - typedef VariableComponent< VectorComponentAdaptor > > ComponentType; + typedef Variable ComponentType; const int NNodes = static_cast(mrModelPart.Nodes().size()); ModelPart::NodesContainerType::iterator it_begin = mrModelPart.NodesBegin(); double FaceReaction = 0.0; @@ -295,7 +295,7 @@ class ControlModuleProcess : public Process const int NNodes = static_cast(mrModelPart.Nodes().size()); ModelPart::NodesContainerType::iterator it_begin = mrModelPart.NodesBegin(); - typedef VariableComponent< VectorComponentAdaptor > > ComponentType; + typedef Variable ComponentType; const double DeltaTime = mrModelPart.GetProcessInfo()[DELTA_TIME]; if(mRadialDisplacement == true) { diff --git a/applications/DemStructuresCouplingApplication/custom_utilities/control_module_fem_dem_utilities.hpp b/applications/DemStructuresCouplingApplication/custom_utilities/control_module_fem_dem_utilities.hpp index 7c485bd4e7e0..1e89ce4fa1dc 100644 --- a/applications/DemStructuresCouplingApplication/custom_utilities/control_module_fem_dem_utilities.hpp +++ b/applications/DemStructuresCouplingApplication/custom_utilities/control_module_fem_dem_utilities.hpp @@ -150,7 +150,7 @@ void ExecuteInitialize() const int NNodes = static_cast(mrFemModelPart.Nodes().size()); ModelPart::NodesContainerType::iterator it_begin = mrFemModelPart.NodesBegin(); - typedef VariableComponent< VectorComponentAdaptor > > ComponentType; + typedef Variable ComponentType; ComponentType VarComponent = KratosComponents< ComponentType >::Get(mVariableName); #pragma omp parallel for @@ -173,7 +173,7 @@ void ExecuteInitializeSolutionStep() if(CurrentTime >= mStartTime && mTargetStressTableId > 0) { // Calculate ReactionStress - typedef VariableComponent< VectorComponentAdaptor > > ComponentType; + typedef Variable ComponentType; ComponentType ReactionVarComponent = KratosComponents< ComponentType >::Get(mReactionVariableName); const int NNodes = static_cast(mrFemModelPart.Nodes().size()); ModelPart::NodesContainerType::iterator it_begin = mrFemModelPart.NodesBegin(); @@ -266,7 +266,7 @@ void ExecuteInitializeSolutionStep() const int NNodes = static_cast(mrFemModelPart.Nodes().size()); ModelPart::NodesContainerType::iterator it_begin = mrFemModelPart.NodesBegin(); - typedef VariableComponent< VectorComponentAdaptor > > ComponentType; + typedef Variable ComponentType; ComponentType VarComponent = KratosComponents< ComponentType >::Get(mVariableName); const double DeltaTime = mrFemModelPart.GetProcessInfo()[DELTA_TIME]; From 2ad2186d00f6c7bc38269c6f3745b0e9ad27de4b Mon Sep 17 00:00:00 2001 From: Ignasi de Pouplana Date: Tue, 7 Apr 2020 11:21:13 +0200 Subject: [PATCH 106/314] Fixing PoromechanicsApp. --- .../custom_processes/apply_component_table_process.hpp | 4 ++-- .../strategies/poromechanics_newton_raphson_strategy.hpp | 4 ++-- .../strategies/poromechanics_ramm_arc_length_strategy.hpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/applications/PoromechanicsApplication/custom_processes/apply_component_table_process.hpp b/applications/PoromechanicsApplication/custom_processes/apply_component_table_process.hpp index f23571c33ebc..11864f430b25 100644 --- a/applications/PoromechanicsApplication/custom_processes/apply_component_table_process.hpp +++ b/applications/PoromechanicsApplication/custom_processes/apply_component_table_process.hpp @@ -85,7 +85,7 @@ class ApplyComponentTableProcess : public Process { KRATOS_TRY; - typedef VariableComponent< VectorComponentAdaptor > > component_type; + typedef Variable component_type; component_type var_component = KratosComponents< component_type >::Get(mvariable_name); const int nnodes = static_cast(mr_model_part.Nodes().size()); @@ -116,7 +116,7 @@ class ApplyComponentTableProcess : public Process { KRATOS_TRY; - typedef VariableComponent< VectorComponentAdaptor > > component_type; + typedef Variable component_type; component_type var_component = KratosComponents< component_type >::Get(mvariable_name); const double Time = mr_model_part.GetProcessInfo()[TIME]/mTimeUnitConverter; diff --git a/applications/PoromechanicsApplication/custom_strategies/strategies/poromechanics_newton_raphson_strategy.hpp b/applications/PoromechanicsApplication/custom_strategies/strategies/poromechanics_newton_raphson_strategy.hpp index ab44fdefb295..6740891ad7cf 100644 --- a/applications/PoromechanicsApplication/custom_strategies/strategies/poromechanics_newton_raphson_strategy.hpp +++ b/applications/PoromechanicsApplication/custom_strategies/strategies/poromechanics_newton_raphson_strategy.hpp @@ -312,7 +312,7 @@ class PoromechanicsNewtonRaphsonStrategy : public ResidualBasedNewtonRaphsonStra } else if( KratosComponents< Variable > >::Has(VariableName) ) { - typedef VariableComponent< VectorComponentAdaptor > > component_type; + typedef Variable component_type; component_type varx = KratosComponents< component_type >::Get(VariableName+std::string("_X")); component_type vary = KratosComponents< component_type >::Get(VariableName+std::string("_Y")); component_type varz = KratosComponents< component_type >::Get(VariableName+std::string("_Z")); @@ -373,7 +373,7 @@ class PoromechanicsNewtonRaphsonStrategy : public ResidualBasedNewtonRaphsonStra } else if( KratosComponents< Variable > >::Has(VariableName) ) { - typedef VariableComponent< VectorComponentAdaptor > > component_type; + typedef Variable component_type; component_type varx = KratosComponents< component_type >::Get(VariableName+std::string("_X")); component_type vary = KratosComponents< component_type >::Get(VariableName+std::string("_Y")); component_type varz = KratosComponents< component_type >::Get(VariableName+std::string("_Z")); diff --git a/applications/PoromechanicsApplication/custom_strategies/strategies/poromechanics_ramm_arc_length_strategy.hpp b/applications/PoromechanicsApplication/custom_strategies/strategies/poromechanics_ramm_arc_length_strategy.hpp index 4dd4ca121da7..faff8b17b353 100644 --- a/applications/PoromechanicsApplication/custom_strategies/strategies/poromechanics_ramm_arc_length_strategy.hpp +++ b/applications/PoromechanicsApplication/custom_strategies/strategies/poromechanics_ramm_arc_length_strategy.hpp @@ -594,7 +594,7 @@ class PoromechanicsRammArcLengthStrategy : public PoromechanicsNewtonRaphsonStra } else if( KratosComponents< Variable > >::Has(VariableName) ) { - typedef VariableComponent< VectorComponentAdaptor > > component_type; + typedef Variable component_type; component_type varx = KratosComponents< component_type >::Get(VariableName+std::string("_X")); component_type vary = KratosComponents< component_type >::Get(VariableName+std::string("_Y")); component_type varz = KratosComponents< component_type >::Get(VariableName+std::string("_Z")); From 0a00b199965aafcf498d450c8af40cf3c95ab6ba Mon Sep 17 00:00:00 2001 From: pooyan Date: Tue, 7 Apr 2020 16:28:21 +0200 Subject: [PATCH 107/314] Fixing DEM app compilation --- .../custom_strategies/strategies/explicit_solver_strategy.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/DEMApplication/custom_strategies/strategies/explicit_solver_strategy.h b/applications/DEMApplication/custom_strategies/strategies/explicit_solver_strategy.h index 5de821c2d59a..707da7d6866f 100644 --- a/applications/DEMApplication/custom_strategies/strategies/explicit_solver_strategy.h +++ b/applications/DEMApplication/custom_strategies/strategies/explicit_solver_strategy.h @@ -98,7 +98,7 @@ namespace Kratos { typedef PropertiesContainerType::iterator PropertiesIterator; typedef DiscreteParticleConfigure<3> ElementConfigureType; typedef RigidFaceGeometricalObjectConfigure<3> RigidFaceGeometricalConfigureType; - typedef Kratos::VariableComponent > > ComponentOf3ComponentsVariableType; + typedef Variable ComponentOf3ComponentsVariableType; /// Pointer definition of ExplicitSolverStrategy KRATOS_CLASS_POINTER_DEFINITION(ExplicitSolverStrategy); From 416c68a4aaa37d9e6a9f2bc61b85020b5aab0e19 Mon Sep 17 00:00:00 2001 From: pooyan Date: Tue, 7 Apr 2020 16:28:54 +0200 Subject: [PATCH 108/314] Fixing mesh moving app compilation --- .../strategies/laplacian_meshmoving_strategy.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/applications/MeshMovingApplication/custom_strategies/strategies/laplacian_meshmoving_strategy.h b/applications/MeshMovingApplication/custom_strategies/strategies/laplacian_meshmoving_strategy.h index 753fa936aa41..3a77c4140450 100644 --- a/applications/MeshMovingApplication/custom_strategies/strategies/laplacian_meshmoving_strategy.h +++ b/applications/MeshMovingApplication/custom_strategies/strategies/laplacian_meshmoving_strategy.h @@ -100,9 +100,7 @@ class LaplacianMeshMovingStrategy mpmesh_model_part = MoveMeshUtilities::GenerateMeshPart( BaseType::GetModelPart(), element_type); - typedef typename Kratos::VariableComponent< - Kratos::VectorComponentAdaptor>> - VarComponent; + typedef Variable VarComponent; mpbuilder_and_solver_x = typename TBuilderAndSolverType::Pointer( new ResidualBasedEliminationBuilderAndSolverComponentwise< From 0f6f78b0df790dc8f905a07bd96420a891ae3fc5 Mon Sep 17 00:00:00 2001 From: pooyan Date: Tue, 7 Apr 2020 16:29:11 +0200 Subject: [PATCH 109/314] Fixing RANS app compilation --- .../cpp/evm_k_epsilon/test_k_epsilon_utilities.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/applications/RANSApplication/tests/cpp/evm_k_epsilon/test_k_epsilon_utilities.cpp b/applications/RANSApplication/tests/cpp/evm_k_epsilon/test_k_epsilon_utilities.cpp index bad4eff238db..6cad2a393476 100644 --- a/applications/RANSApplication/tests/cpp/evm_k_epsilon/test_k_epsilon_utilities.cpp +++ b/applications/RANSApplication/tests/cpp/evm_k_epsilon/test_k_epsilon_utilities.cpp @@ -127,19 +127,19 @@ void CreateModelPartNodes(ModelPart& rModelPart) VariableUtils().AddDof>(RANS_SCALAR_2_ADJOINT_1, rModelPart); VariableUtils().AddDof>(PRESSURE, rModelPart); - VariableUtils().AddDof>>>( + VariableUtils().AddDof>( VELOCITY_X, rModelPart); - VariableUtils().AddDof>>>( + VariableUtils().AddDof>( VELOCITY_Y, rModelPart); - VariableUtils().AddDof>>>( + VariableUtils().AddDof>( VELOCITY_Z, rModelPart); VariableUtils().AddDof>(ADJOINT_FLUID_SCALAR_1, rModelPart); - VariableUtils().AddDof>>>( + VariableUtils().AddDof>( ADJOINT_FLUID_VECTOR_1_X, rModelPart); - VariableUtils().AddDof>>>( + VariableUtils().AddDof>( ADJOINT_FLUID_VECTOR_1_Y, rModelPart); - VariableUtils().AddDof>>>( + VariableUtils().AddDof>( ADJOINT_FLUID_VECTOR_1_Z, rModelPart); } From 8c76dd5831c422883f2d6fc2bc46c5ab5ae383f4 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Wed, 8 Apr 2020 08:10:13 +1000 Subject: [PATCH 110/314] [skip ci] precalculated dndx, move towards scheme implementation --- .../updated_lagrangian_quadrilateral.cpp | 65 ++++++------------- 1 file changed, 20 insertions(+), 45 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index f71e8f05fda0..6638a74b0ab5 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -566,20 +566,9 @@ void UpdatedLagrangianQuadrilateral::CalculateAndAddExplicitInternalForces(Vecto GeometryType& r_geometry = GetGeometry(); - // Calculate shape function gradients - Matrix Jacobian; - Jacobian = this->MPMJacobian(Jacobian, mMP.xg); - Matrix InvJ; - double detJ; - MathUtils::InvertMatrix(Jacobian, InvJ, detJ); - Matrix DN_De; - this->MPMShapeFunctionsLocalGradients(DN_De, mMP.xg); // parametric gradients - mDN_DX = prod(DN_De, InvJ); // cartesian gradients - MPMExplicitUtilities::CalcuateAndAddExplicitInternalForce(r_geometry, mDN_DX, mMP.cauchy_stress_vector, mMP.volume, rRightHandSideVector); - KRATOS_CATCH("") } @@ -628,8 +617,6 @@ void UpdatedLagrangianQuadrilateral::CalculateExplicitStresses(const ProcessInfo mMP.volume = mMP.mass / mMP.density; } - - rVariables.CurrentDisp = CalculateCurrentDisp(rVariables.CurrentDisp, rCurrentProcessInfo); rVariables.DN_DX = mDN_DX; rVariables.N = mN; @@ -911,10 +898,20 @@ void UpdatedLagrangianQuadrilateral::InitializeSolutionStep( ProcessInfo& rCurre const unsigned int number_of_nodes = r_geometry.PointsNumber(); GeneralVariables Variables; - // Calculating shape function + mFinalizedStep = false; + + // Calculating shape function and gradients Variables.N = this->MPMShapeFunctionPointValues(Variables.N, mMP.xg); mN = Variables.N; - mFinalizedStep = false; + Matrix Jacobian; + Jacobian = this->MPMJacobian(Jacobian, mMP.xg); + Matrix InvJ; + double detJ; + MathUtils::InvertMatrix(Jacobian, InvJ, detJ); + Matrix DN_De; + this->MPMShapeFunctionsLocalGradients(DN_De, mMP.xg); // parametric gradients + mDN_DX = prod(DN_De, InvJ); // cartesian gradients + array_1d aux_MP_velocity = ZeroVector(3); array_1d aux_MP_acceleration = ZeroVector(3); @@ -1106,10 +1103,7 @@ void UpdatedLagrangianQuadrilateral::FinalizeStepVariables( GeneralVariables & r mConstitutiveLawVector->GetValue(MP_ACCUMULATED_PLASTIC_VOLUMETRIC_STRAIN, mMP.accumulated_plastic_volumetric_strain); mConstitutiveLawVector->GetValue(MP_ACCUMULATED_PLASTIC_DEVIATORIC_STRAIN, mMP.accumulated_plastic_deviatoric_strain); - if (!rCurrentProcessInfo.Has(IS_EXPLICIT)) - { - this->UpdateGaussPoint(rVariables, rCurrentProcessInfo); - } + if (!rCurrentProcessInfo.Has(IS_EXPLICIT)) this->UpdateGaussPoint(rVariables, rCurrentProcessInfo); } //************************************************************************************ @@ -1913,41 +1907,22 @@ void UpdatedLagrangianQuadrilateral::CalculateOnIntegrationPoints(const Variable if (rValues.size() != 1) rValues.resize(1); - if (rVariable == CALCULATE_EXPLICIT_MP_STRESS) { - - // Create and initialize element variables: + if (rVariable == CALCULATE_EXPLICIT_MP_STRESS) + { GeneralVariables Variables; this->InitializeGeneralVariables(Variables, rCurrentProcessInfo); - - // Calculate shape function gradients - Matrix Jacobian; - Jacobian = this->MPMJacobian(Jacobian, mMP.xg); - Matrix InvJ; - double detJ; - MathUtils::InvertMatrix(Jacobian, InvJ, detJ); - Matrix DN_De; - this->MPMShapeFunctionsLocalGradients(DN_De, mMP.xg); // parametric gradients - mDN_DX = prod(DN_De, InvJ); // cartesian gradients - - //calculate stress this->CalculateExplicitStresses(rCurrentProcessInfo, Variables); this->FinalizeStepVariables(Variables, rCurrentProcessInfo); rValues[0] = true; } - else if (rVariable == EXPLICIT_MAP_GRID_TO_MP) { - - const double& delta_time = rCurrentProcessInfo[DELTA_TIME]; - - // Map grid to particle - bool isCentralDifference = rCurrentProcessInfo.Has(IS_EXPLICIT_CENTRAL_DIFFERENCE); - MPMExplicitUtilities::UpdateGaussPointExplicit(delta_time, isCentralDifference, *this, mN); - + else if (rVariable == EXPLICIT_MAP_GRID_TO_MP) + { + MPMExplicitUtilities::UpdateGaussPointExplicit(rCurrentProcessInfo[DELTA_TIME], + rCurrentProcessInfo.Has(IS_EXPLICIT_CENTRAL_DIFFERENCE), *this, mN); // If we are doing MUSL, map updated particle velocities back to the grid - if (rCurrentProcessInfo.Has(MUSL_VELOCITY_FIELD_IS_COMPUTED)) - { + if (rCurrentProcessInfo.Has(MUSL_VELOCITY_FIELD_IS_COMPUTED)) MPMExplicitUtilities::CalculateMUSLGridVelocity(*this, mN); - } rValues[0] = true; } From 60a9443d4f436a8c84ac6c50d4473cd0aae70c88 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Wed, 8 Apr 2020 09:38:37 +1000 Subject: [PATCH 111/314] [skip ci] moved explicit to scheme --- .../updated_lagrangian_quadrilateral.cpp | 133 +++++------------- .../updated_lagrangian_quadrilateral.hpp | 6 - .../particle_mechanics_python_application.cpp | 2 +- .../schemes/mpm_explicit_scheme.hpp | 62 ++++++-- .../mpm_explicit_utilities.cpp | 8 +- .../custom_utilities/mpm_explicit_utilities.h | 4 +- .../particle_mechanics_application.cpp | 2 +- ...rticle_mechanics_application_variables.cpp | 2 +- ...particle_mechanics_application_variables.h | 2 +- .../python_scripts/mpm_explicit_solver.py | 2 + 10 files changed, 96 insertions(+), 127 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index 6638a74b0ab5..54432632f8cf 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -325,7 +325,7 @@ void UpdatedLagrangianQuadrilateral::CalculateElementalSystem( LocalSystemCompon // Update MP_density mMP.density = (GetProperties()[DENSITY]) / Variables.detFT; } - else + else if (rCurrentProcessInfo.GetValue(IS_EXPLICIT)) { rLocalSystem.CalculationFlags.Set(UpdatedLagrangianQuadrilateral::COMPUTE_LHS_MATRIX, false); } @@ -506,8 +506,7 @@ void UpdatedLagrangianQuadrilateral::CalculateAndAddRHS( if (rCurrentProcessInfo.Has(IS_EXPLICIT)) { - // Operation performed: rRightHandSideVector -= IntForce*IntToReferenceWeight - this->CalculateAndAddExplicitInternalForces(rRightHandSideVector); + if (rCurrentProcessInfo.GetValue(IS_EXPLICIT)) this->CalculateAndAddExplicitInternalForces(rRightHandSideVector); } else { @@ -918,7 +917,7 @@ void UpdatedLagrangianQuadrilateral::InitializeSolutionStep( ProcessInfo& rCurre array_1d nodal_momentum = ZeroVector(3); array_1d nodal_inertia = ZeroVector(3); - // TODO, We should never retrieve previous nodal values in MPM. The below should be mapping particle accelerations to the grid. + if (!rCurrentProcessInfo.Has(IS_EXPLICIT)) { for (unsigned int j = 0; j < number_of_nodes; j++) @@ -953,7 +952,7 @@ void UpdatedLagrangianQuadrilateral::InitializeSolutionStep( ProcessInfo& rCurre // Add in the predictor velocity increment for central difference explicit // This is the 'previous grid acceleration', which is actually // be the initial particle acceleration mapped to the grid. - if (rCurrentProcessInfo.Has(IS_EXPLICIT_CENTRAL_DIFFERENCE)) + if (rCurrentProcessInfo.GetValue(IS_EXPLICIT_CENTRAL_DIFFERENCE)) { const double& delta_time = rCurrentProcessInfo[DELTA_TIME]; for (unsigned int j = 0; j < dimension; j++) @@ -980,108 +979,40 @@ void UpdatedLagrangianQuadrilateral::FinalizeSolutionStep(ProcessInfo& rCurrentP { KRATOS_TRY - if (!rCurrentProcessInfo.Has(IS_EXPLICIT)) - { - FinalizeImplicitSolutionStep(rCurrentProcessInfo); - } - else + // FinalizeSolutionStep for explicit time integration is done in the scheme + if (!rCurrentProcessInfo.Has(IS_EXPLICIT)) { - FinalizeExplicitSolutionStep(rCurrentProcessInfo); - } - KRATOS_CATCH("") -} + // Create and initialize element variables: + GeneralVariables Variables; + this->InitializeGeneralVariables(Variables, rCurrentProcessInfo); + // Create constitutive law parameters: + ConstitutiveLaw::Parameters Values(GetGeometry(), GetProperties(), rCurrentProcessInfo); -void UpdatedLagrangianQuadrilateral::FinalizeImplicitSolutionStep(ProcessInfo& rCurrentProcessInfo) -{ - KRATOS_TRY + // Set constitutive law flags: + Flags& ConstitutiveLawOptions = Values.GetOptions(); - // Create and initialize element variables: - GeneralVariables Variables; - this->InitializeGeneralVariables(Variables,rCurrentProcessInfo); + ConstitutiveLawOptions.Set(ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN); + ConstitutiveLawOptions.Set(ConstitutiveLaw::COMPUTE_STRESS); - // Create constitutive law parameters: - ConstitutiveLaw::Parameters Values(GetGeometry(),GetProperties(),rCurrentProcessInfo); + // Compute element kinematics B, F, DN_DX ... + this->CalculateKinematics(Variables, rCurrentProcessInfo); - // Set constitutive law flags: - Flags &ConstitutiveLawOptions=Values.GetOptions(); - - ConstitutiveLawOptions.Set(ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN); - ConstitutiveLawOptions.Set(ConstitutiveLaw::COMPUTE_STRESS); - - // Compute element kinematics B, F, DN_DX ... - this->CalculateKinematics(Variables, rCurrentProcessInfo); - - // Set general variables to constitutivelaw parameters - this->SetGeneralVariables(Variables,Values); - - // Call the constitutive law to update material variables - mConstitutiveLawVector->FinalizeMaterialResponse(Values, Variables.StressMeasure); - - // Call the element internal variables update - this->FinalizeStepVariables(Variables, rCurrentProcessInfo); + // Set general variables to constitutivelaw parameters + this->SetGeneralVariables(Variables, Values); - mFinalizedStep = true; - - KRATOS_CATCH( "" ) -} - -void UpdatedLagrangianQuadrilateral::FinalizeExplicitSolutionStep(ProcessInfo& rCurrentProcessInfo) -{ - KRATOS_TRY + // Call the constitutive law to update material variables + mConstitutiveLawVector->FinalizeMaterialResponse(Values, Variables.StressMeasure); - bool mapGridToParticles = true; - bool calculateStresses = true; - GeometryType& rGeom = GetGeometry(); + // Call the element internal variables update + this->FinalizeStepVariables(Variables, rCurrentProcessInfo); - if (rCurrentProcessInfo.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 0) - { - // USF stresses already calculated - calculateStresses = false; - } - else - { - if (rCurrentProcessInfo.Has(MUSL_VELOCITY_FIELD_IS_COMPUTED)) - { - if (!rCurrentProcessInfo.GetValue(MUSL_VELOCITY_FIELD_IS_COMPUTED)) - { - // MUSL nodal velocity field has not been computed. Therefore we do not calculate stresses this time. - // We need to map the updated particle velocities back to the nodes. - calculateStresses = false; - } - else - { - // MUSL velocity field has already been computed. Therefore only calculate stresses this time. - mapGridToParticles = false; - } + mFinalizedStep = true; } - } - - if (mapGridToParticles) - { - std::vector dummy; - this->CalculateOnIntegrationPoints(EXPLICIT_MAP_GRID_TO_MP, dummy, rCurrentProcessInfo); - } - - if (calculateStresses) - { - std::vector dummy; - this->CalculateOnIntegrationPoints(CALCULATE_EXPLICIT_MP_STRESS, dummy, rCurrentProcessInfo); - - mFinalizedStep = true; - } - - if (rCurrentProcessInfo.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 0) - { - mFinalizedStep = true; - } - + KRATOS_CATCH("") - } - -////************************************************************************************ ////************************************************************************************ void UpdatedLagrangianQuadrilateral::FinalizeStepVariables( GeneralVariables & rVariables, const ProcessInfo& rCurrentProcessInfo) @@ -1909,21 +1840,21 @@ void UpdatedLagrangianQuadrilateral::CalculateOnIntegrationPoints(const Variable if (rVariable == CALCULATE_EXPLICIT_MP_STRESS) { + // TODO collapse these GeneralVariables Variables; this->InitializeGeneralVariables(Variables, rCurrentProcessInfo); this->CalculateExplicitStresses(rCurrentProcessInfo, Variables); this->FinalizeStepVariables(Variables, rCurrentProcessInfo); - rValues[0] = true; } else if (rVariable == EXPLICIT_MAP_GRID_TO_MP) { - MPMExplicitUtilities::UpdateGaussPointExplicit(rCurrentProcessInfo[DELTA_TIME], - rCurrentProcessInfo.Has(IS_EXPLICIT_CENTRAL_DIFFERENCE), *this, mN); - // If we are doing MUSL, map updated particle velocities back to the grid - if (rCurrentProcessInfo.Has(MUSL_VELOCITY_FIELD_IS_COMPUTED)) - MPMExplicitUtilities::CalculateMUSLGridVelocity(*this, mN); - + MPMExplicitUtilities::UpdateGaussPointExplicit(rCurrentProcessInfo, *this, mN); + rValues[0] = true; + } + else if (rVariable == CALCULATE_MUSL_VELOCITY_FIELD) + { + MPMExplicitUtilities::CalculateMUSLGridVelocity(*this, mN); rValues[0] = true; } else diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp index 9c406a612ffb..5395ad82dd1e 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp @@ -419,12 +419,6 @@ class UpdatedLagrangianQuadrilateral /// Called at the end of each solution step void FinalizeSolutionStep(ProcessInfo& rCurrentProcessInfo) override; - /// Called at the end of each solution step - void FinalizeImplicitSolutionStep(ProcessInfo& rCurrentProcessInfo); - - /// Called at the end of each solution step - void FinalizeExplicitSolutionStep(ProcessInfo& rCurrentProcessInfo); - //************* COMPUTING METHODS diff --git a/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp b/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp index d21ca05cf706..226ce07947de 100644 --- a/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp +++ b/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp @@ -158,7 +158,7 @@ namespace Python{ KRATOS_REGISTER_IN_PYTHON_3D_VARIABLE_WITH_COMPONENTS(m, SURFACE_LOAD ) // Explicit time integration variables - KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, MUSL_VELOCITY_FIELD_IS_COMPUTED); + KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, CALCULATE_MUSL_VELOCITY_FIELD); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, IS_EXPLICIT); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, IS_EXPLICIT_CENTRAL_DIFFERENCE); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, EXPLICIT_STRESS_UPDATE_OPTION); diff --git a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp index e282184f9847..81cc9b18b354 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp @@ -250,7 +250,7 @@ namespace Kratos { array_1d& r_nodal_momenta = itCurrentNode->FastGetSolutionStepValue(NODAL_MOMENTUM); array_1d& r_current_residual = itCurrentNode->FastGetSolutionStepValue(FORCE_RESIDUAL); - const double gamma = (r_current_process_info.Has(IS_EXPLICIT_CENTRAL_DIFFERENCE)) + const double gamma = (r_current_process_info.GetValue(IS_EXPLICIT_CENTRAL_DIFFERENCE)) ? 0.5 : 1.0; // we are only adding the central difference corrector here @@ -406,7 +406,9 @@ namespace Kratos { Scheme::InitializeSolutionStep(r_model_part, A, Dx, b); // If we are updating stress before momenta update (USF and central difference), - if (rCurrentProcessInfo.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 0 || rCurrentProcessInfo.Has(IS_EXPLICIT_CENTRAL_DIFFERENCE)) { + if (rCurrentProcessInfo.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 0 || + rCurrentProcessInfo.GetValue(IS_EXPLICIT_CENTRAL_DIFFERENCE)) + { // calculate nodal velocities from momenta and apply BCs calculateGridVelocityAndApplyDirichletBC(rCurrentProcessInfo,true); @@ -478,13 +480,26 @@ namespace Kratos { { KRATOS_TRY - ElementsArrayType& rElements = rModelPart.Elements(); + ElementsArrayType& rElements = rModelPart.Elements(); ProcessInfo& rCurrentProcessInfo = rModelPart.GetProcessInfo(); - if (rCurrentProcessInfo.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 2) + const bool isMUSL = (rCurrentProcessInfo.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 2) + ? true + : false; + if (isMUSL) PerformModifiedUpdateStressLastMapping(rCurrentProcessInfo, rModelPart, rElements); + + + bool calculateMPStresses; + if (rCurrentProcessInfo.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 0 || + rCurrentProcessInfo.GetValue(IS_EXPLICIT_CENTRAL_DIFFERENCE)) { - PerformModifiedUpdateStressLastMapping(rCurrentProcessInfo, rModelPart, rElements); + calculateMPStresses = false; } + else + { + calculateMPStresses = true; + } + // Definition of the first element iterator const auto it_elem_begin = rModelPart.ElementsBegin(); @@ -493,7 +508,12 @@ namespace Kratos { #pragma omp parallel for for (int i = 0; i < static_cast(rElements.size()); ++i) { auto it_elem = it_elem_begin + i; - it_elem->FinalizeSolutionStep(rCurrentProcessInfo); + std::vector dummy; + + if (!isMUSL) it_elem->CalculateOnIntegrationPoints(EXPLICIT_MAP_GRID_TO_MP, dummy, rCurrentProcessInfo); + if (calculateMPStresses) it_elem->CalculateOnIntegrationPoints(CALCULATE_EXPLICIT_MP_STRESS, dummy, rCurrentProcessInfo); + + //it_elem->FinalizeSolutionStep(rCurrentProcessInfo); } // Definition of the first condition iterator @@ -520,14 +540,34 @@ namespace Kratos { // We need to call 'FinalizeSolutionStep' twice. // First, to update the particles and then aggregate the new particle velocities on the grid. // Second, to calculate the stresses from the grid velocity - rCurrentProcessInfo.SetValue(MUSL_VELOCITY_FIELD_IS_COMPUTED, false); - // Call each particle and aggregate the nodal velocity field - for (ElementsArrayType::iterator it = rElements.begin(); it != rElements.end(); ++it) + // Definition of the first element iterator + const auto it_elem_begin = rModelPart.ElementsBegin(); + + // Map grid results to MPs + #pragma omp parallel for + for (int i = 0; i < static_cast(rElements.size()); ++i) { + auto it_elem = it_elem_begin + i; + std::vector dummy; + it_elem->CalculateOnIntegrationPoints(EXPLICIT_MAP_GRID_TO_MP, dummy, rCurrentProcessInfo); + } + + // Reset grid velocities + #pragma omp parallel for + for (int iter = 0; iter < static_cast(mr_grid_model_part.Nodes().size()); ++iter) { - (it)->FinalizeSolutionStep(rCurrentProcessInfo); + auto i = mr_grid_model_part.NodesBegin() + iter; + array_1d& nodal_velocity = (i)->FastGetSolutionStepValue(VELOCITY); + nodal_velocity.clear(); + } + + // Map updated MP velocities back to grid + #pragma omp parallel for + for (int i = 0; i < static_cast(rElements.size()); ++i) { + auto it_elem = it_elem_begin + i; + std::vector dummy; + it_elem->CalculateOnIntegrationPoints(CALCULATE_MUSL_VELOCITY_FIELD, dummy, rCurrentProcessInfo); } - rCurrentProcessInfo.SetValue(MUSL_VELOCITY_FIELD_IS_COMPUTED, true); // Reapply dirichlet BCs to MUSL velocity field calculateGridVelocityAndApplyDirichletBC(rCurrentProcessInfo); diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp index a4062241070e..3f354e42bc74 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp @@ -85,13 +85,15 @@ namespace Kratos /***********************************************************************************/ void MPMExplicitUtilities::UpdateGaussPointExplicit( - const double& rDeltaTime, - const bool& isCentralDifference, + const ProcessInfo& rCurrentProcessInfo, Element& rElement, Vector& rN) { KRATOS_TRY + + const double& rDeltaTime = rCurrentProcessInfo[DELTA_TIME]; + const bool& isCentralDifference = rCurrentProcessInfo.GetValue(IS_EXPLICIT_CENTRAL_DIFFERENCE); GeometryType& rGeom = rElement.GetGeometry(); const SizeType number_of_nodes = rGeom.PointsNumber(); const SizeType dimension = rGeom.WorkingSpaceDimension(); @@ -171,7 +173,7 @@ namespace Kratos rElement.CalculateOnIntegrationPoints(MP_DISPLACEMENT, MP_Displacement,rProcessInfo); MP_Displacement[0] += delta_xg; rElement.SetValuesOnIntegrationPoints(MP_DISPLACEMENT,MP_Displacement,rProcessInfo); - + KRATOS_CATCH("") } diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h index 40304c786579..719cfca47628 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h @@ -47,8 +47,8 @@ namespace Kratos const Matrix& rDN_DX, const Vector& rMPStress, const double& rMPVolume, Vector& rRightHandSideVector); - void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) UpdateGaussPointExplicit(const double& rDeltaTime, - const bool& isCentralDifference, Element& rElement, Vector& rN); + void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) UpdateGaussPointExplicit(const ProcessInfo& rCurrentProcessInfo, + Element& rElement, Vector& rN); void CalculateMUSLGridVelocity(Element& rElement, Vector& rN); diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp b/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp index a93941311678..8e18e3c93502 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp @@ -254,7 +254,7 @@ namespace Kratos KRATOS_REGISTER_VARIABLE(IGNORE_GEOMETRIC_STIFFNESS); // Explicit time integration variables - KRATOS_REGISTER_VARIABLE(MUSL_VELOCITY_FIELD_IS_COMPUTED) + KRATOS_REGISTER_VARIABLE(CALCULATE_MUSL_VELOCITY_FIELD) KRATOS_REGISTER_VARIABLE(IS_EXPLICIT) KRATOS_REGISTER_VARIABLE(IS_EXPLICIT_CENTRAL_DIFFERENCE) KRATOS_REGISTER_VARIABLE(EXPLICIT_STRESS_UPDATE_OPTION) diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp index 8588c8a5927b..2da7230552df 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp @@ -95,7 +95,7 @@ namespace Kratos KRATOS_CREATE_VARIABLE(bool, IGNORE_GEOMETRIC_STIFFNESS) // Explicit time integration variables - KRATOS_CREATE_VARIABLE(bool, MUSL_VELOCITY_FIELD_IS_COMPUTED) + KRATOS_CREATE_VARIABLE(bool, CALCULATE_MUSL_VELOCITY_FIELD) KRATOS_CREATE_VARIABLE(bool, IS_EXPLICIT) KRATOS_CREATE_VARIABLE(bool, IS_EXPLICIT_CENTRAL_DIFFERENCE) KRATOS_CREATE_VARIABLE(int, EXPLICIT_STRESS_UPDATE_OPTION) diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h index 9818aebdb1ee..e74a39b1ebf4 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h @@ -121,7 +121,7 @@ namespace Kratos KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, IGNORE_GEOMETRIC_STIFFNESS) // Explicit time integration variables - KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, MUSL_VELOCITY_FIELD_IS_COMPUTED) + KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, CALCULATE_MUSL_VELOCITY_FIELD) KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, IS_EXPLICIT) KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, IS_EXPLICIT_CENTRAL_DIFFERENCE) KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, int, EXPLICIT_STRESS_UPDATE_OPTION) diff --git a/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py b/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py index 380cffceb26d..9244d3e6fd5d 100644 --- a/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py +++ b/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py @@ -73,8 +73,10 @@ def _CreateSolutionScheme(self): err_msg = "The requested stress update \"" + stress_update + "\" is not available!\n" err_msg += "Available options are: \"USF\", \"USL\",\"MUSL\"" grid_model_part.ProcessInfo.SetValue(KratosParticle.EXPLICIT_STRESS_UPDATE_OPTION, StressUpdateOption) + grid_model_part.ProcessInfo.SetValue(KratosParticle.IS_EXPLICIT_CENTRAL_DIFFERENCE, False) elif(scheme_type == "central_difference" or scheme_type == "Central_Difference"): isCentralDifference = True + grid_model_part.ProcessInfo.SetValue(KratosParticle.EXPLICIT_STRESS_UPDATE_OPTION, 0) grid_model_part.ProcessInfo.SetValue(KratosParticle.IS_EXPLICIT_CENTRAL_DIFFERENCE, True) else: err_msg = "The requested scheme type \"" + scheme_type + "\" is not available!\n" From fa20e966a81798f2518a5dc1edebe5a12ae68439 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Wed, 8 Apr 2020 09:49:39 +1000 Subject: [PATCH 112/314] [skip ci] change Has to GetValue, tidy element explicit --- .../updated_lagrangian_quadrilateral.cpp | 25 ++++++------------- .../updated_lagrangian_quadrilateral.hpp | 3 --- .../mpm_search_element_utility.h | 4 +-- .../python_scripts/mpm_solver.py | 2 ++ 4 files changed, 12 insertions(+), 22 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index 54432632f8cf..5180e850b05c 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -302,7 +302,7 @@ void UpdatedLagrangianQuadrilateral::CalculateElementalSystem( LocalSystemCompon Flags &ConstitutiveLawOptions=Values.GetOptions(); ConstitutiveLawOptions.Set(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR); - if (!rCurrentProcessInfo.Has(IS_EXPLICIT)) + if (!rCurrentProcessInfo.GetValue(IS_EXPLICIT)) { ConstitutiveLawOptions.Set(ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN); ConstitutiveLawOptions.Set(ConstitutiveLaw::COMPUTE_STRESS); @@ -504,9 +504,11 @@ void UpdatedLagrangianQuadrilateral::CalculateAndAddRHS( // Operation performed: rRightHandSideVector += ExtForce*IntToReferenceWeight this->CalculateAndAddExternalForces( rRightHandSideVector, rVariables, rVolumeForce, rIntegrationWeight ); - if (rCurrentProcessInfo.Has(IS_EXPLICIT)) + if (rCurrentProcessInfo.GetValue(IS_EXPLICIT)) { - if (rCurrentProcessInfo.GetValue(IS_EXPLICIT)) this->CalculateAndAddExplicitInternalForces(rRightHandSideVector); + GeometryType& r_geometry = GetGeometry(); + MPMExplicitUtilities::CalcuateAndAddExplicitInternalForce(r_geometry, + mDN_DX, mMP.cauchy_stress_vector, mMP.volume, rRightHandSideVector); } else { @@ -559,17 +561,6 @@ void UpdatedLagrangianQuadrilateral::CalculateAndAddInternalForces(VectorType& r //************************************************************************************ //************************************************************************************ -void UpdatedLagrangianQuadrilateral::CalculateAndAddExplicitInternalForces(VectorType& rRightHandSideVector) -{ - KRATOS_TRY - - GeometryType& r_geometry = GetGeometry(); - - MPMExplicitUtilities::CalcuateAndAddExplicitInternalForce(r_geometry, - mDN_DX, mMP.cauchy_stress_vector, mMP.volume, rRightHandSideVector); - - KRATOS_CATCH("") -} void UpdatedLagrangianQuadrilateral::CalculateExplicitStresses(const ProcessInfo& rCurrentProcessInfo, GeneralVariables& rVariables) { @@ -918,7 +909,7 @@ void UpdatedLagrangianQuadrilateral::InitializeSolutionStep( ProcessInfo& rCurre array_1d nodal_inertia = ZeroVector(3); - if (!rCurrentProcessInfo.Has(IS_EXPLICIT)) + if (!rCurrentProcessInfo.GetValue(IS_EXPLICIT)) { for (unsigned int j = 0; j < number_of_nodes; j++) { @@ -980,7 +971,7 @@ void UpdatedLagrangianQuadrilateral::FinalizeSolutionStep(ProcessInfo& rCurrentP KRATOS_TRY // FinalizeSolutionStep for explicit time integration is done in the scheme - if (!rCurrentProcessInfo.Has(IS_EXPLICIT)) + if (!rCurrentProcessInfo.GetValue(IS_EXPLICIT)) { // Create and initialize element variables: GeneralVariables Variables; @@ -1034,7 +1025,7 @@ void UpdatedLagrangianQuadrilateral::FinalizeStepVariables( GeneralVariables & r mConstitutiveLawVector->GetValue(MP_ACCUMULATED_PLASTIC_VOLUMETRIC_STRAIN, mMP.accumulated_plastic_volumetric_strain); mConstitutiveLawVector->GetValue(MP_ACCUMULATED_PLASTIC_DEVIATORIC_STRAIN, mMP.accumulated_plastic_deviatoric_strain); - if (!rCurrentProcessInfo.Has(IS_EXPLICIT)) this->UpdateGaussPoint(rVariables, rCurrentProcessInfo); + if (!rCurrentProcessInfo.GetValue(IS_EXPLICIT)) this->UpdateGaussPoint(rVariables, rCurrentProcessInfo); } //************************************************************************************ diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp index 5395ad82dd1e..fe5af6c7c2f0 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp @@ -691,9 +691,6 @@ class UpdatedLagrangianQuadrilateral GeneralVariables & rVariables, const double& rIntegrationWeight); - /// Calculation of the Explicit Internal Forces Vector. Fi = div. sigma - virtual void CalculateAndAddExplicitInternalForces(VectorType& rRightHandSideVector); - /// Calculation of the Explicit Stresses from velocity gradient. virtual void CalculateExplicitStresses(const ProcessInfo& rCurrentProcessInfo, GeneralVariables& rVariables); diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h b/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h index deeef01de806..c86af2eb1f81 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h @@ -47,8 +47,8 @@ namespace MPMSearchElementUtility void SearchElement(ModelPart& rBackgroundGridModelPart, ModelPart& rMPMModelPart, const std::size_t MaxNumberOfResults, const double Tolerance) { - ProcessInfo& rProcessInfo = rBackgroundGridModelPart.GetProcessInfo(); - bool isExplicit = rProcessInfo.Has(IS_EXPLICIT); + const ProcessInfo& rProcessInfo = rBackgroundGridModelPart.GetProcessInfo(); + const bool isExplicit = rProcessInfo.GetValue(IS_EXPLICIT); // Reset elements to inactive #pragma omp parallel for diff --git a/applications/ParticleMechanicsApplication/python_scripts/mpm_solver.py b/applications/ParticleMechanicsApplication/python_scripts/mpm_solver.py index dfd1420774cd..93816856404a 100644 --- a/applications/ParticleMechanicsApplication/python_scripts/mpm_solver.py +++ b/applications/ParticleMechanicsApplication/python_scripts/mpm_solver.py @@ -382,6 +382,8 @@ def _CreateSolutionScheme(self): def _CreateSolutionStrategy(self): # this is for implicit only. explicit is implemented in derived mpm_explicit_solver + grid_model_part = self.GetGridModelPart(); + grid_model_part.ProcessInfo.SetValue(KratosParticle.IS_EXPLICIT, False) analysis_type = self.settings["analysis_type"].GetString() if analysis_type == "non_linear": solution_strategy = self._CreateNewtonRaphsonStrategy() From a995337a64e6001844658bfd70ef6b480c9c8ca6 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Wed, 8 Apr 2020 09:56:30 +1000 Subject: [PATCH 113/314] [skip ci] clean explicit function --- .../custom_elements/updated_lagrangian_quadrilateral.cpp | 4 +--- .../custom_utilities/mpm_explicit_utilities.cpp | 7 ++++--- .../custom_utilities/mpm_explicit_utilities.h | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index 5180e850b05c..d18b915cfce9 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -506,8 +506,7 @@ void UpdatedLagrangianQuadrilateral::CalculateAndAddRHS( if (rCurrentProcessInfo.GetValue(IS_EXPLICIT)) { - GeometryType& r_geometry = GetGeometry(); - MPMExplicitUtilities::CalcuateAndAddExplicitInternalForce(r_geometry, + MPMExplicitUtilities::CalcuateAndAddExplicitInternalForce(*this, mDN_DX, mMP.cauchy_stress_vector, mMP.volume, rRightHandSideVector); } else @@ -1831,7 +1830,6 @@ void UpdatedLagrangianQuadrilateral::CalculateOnIntegrationPoints(const Variable if (rVariable == CALCULATE_EXPLICIT_MP_STRESS) { - // TODO collapse these GeneralVariables Variables; this->InitializeGeneralVariables(Variables, rCurrentProcessInfo); this->CalculateExplicitStresses(rCurrentProcessInfo, Variables); diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp index 3f354e42bc74..d046d0ecfaca 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp @@ -16,7 +16,7 @@ namespace Kratos { void MPMExplicitUtilities::CalcuateAndAddExplicitInternalForce( - GeometryType& rGeom, + Element& rElement, const Matrix& rDN_DX, const Vector& rMPStress, const double& rMPVolume, @@ -24,8 +24,9 @@ namespace Kratos { KRATOS_TRY - // Add in explicit internal force calculation (Fint = Volume*divergence(sigma)) - // Refer to link for notation https://github.com/KratosMultiphysics/Kratos/wiki/How-to-use-the-Constitutive-Law-class + // Add in explicit internal force calculation (Fint = Volume*divergence(sigma)) + // Refer to link for notation https://github.com/KratosMultiphysics/Kratos/wiki/How-to-use-the-Constitutive-Law-class + GeometryType& rGeom = rElement.GetGeometry(); const SizeType dimension = rGeom.WorkingSpaceDimension(); const SizeType number_of_nodes = rGeom.PointsNumber(); array_1d nodal_force_internal_normal = ZeroVector(3); diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h index 719cfca47628..1be6faf2476d 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h @@ -43,7 +43,7 @@ namespace Kratos typedef Node<3> NodeType; typedef Geometry GeometryType; - void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) CalcuateAndAddExplicitInternalForce(GeometryType& rGeom, + void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) CalcuateAndAddExplicitInternalForce(Element& rElement, const Matrix& rDN_DX, const Vector& rMPStress, const double& rMPVolume, Vector& rRightHandSideVector); From 53a60ee947dac8a88d6279505ae146e2969ec629 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Wed, 8 Apr 2020 10:55:27 +1000 Subject: [PATCH 114/314] [skip ci] fix explicit check --- .../updated_lagrangian_quadrilateral.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index d18b915cfce9..e3239556044d 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -942,12 +942,15 @@ void UpdatedLagrangianQuadrilateral::InitializeSolutionStep( ProcessInfo& rCurre // Add in the predictor velocity increment for central difference explicit // This is the 'previous grid acceleration', which is actually // be the initial particle acceleration mapped to the grid. - if (rCurrentProcessInfo.GetValue(IS_EXPLICIT_CENTRAL_DIFFERENCE)) + if (rCurrentProcessInfo.Has(IS_EXPLICIT_CENTRAL_DIFFERENCE)) { - const double& delta_time = rCurrentProcessInfo[DELTA_TIME]; - for (unsigned int j = 0; j < dimension; j++) + if (rCurrentProcessInfo.GetValue(IS_EXPLICIT_CENTRAL_DIFFERENCE)) { - nodal_momentum[j] += 0.5 * delta_time * (Variables.N[i] * mMP.acceleration[j]) * mMP.mass; + const double& delta_time = rCurrentProcessInfo[DELTA_TIME]; + for (unsigned int j = 0; j < dimension; j++) + { + nodal_momentum[j] += 0.5 * delta_time * (Variables.N[i] * mMP.acceleration[j]) * mMP.mass; + } } } From ff246b5fb702b070e4fc6367feba82365285a489 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Wed, 8 Apr 2020 11:00:35 +1000 Subject: [PATCH 115/314] [skip ci] clean up FinalizeSolutionStep --- .../updated_lagrangian_quadrilateral.cpp | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index e3239556044d..e658df3d5415 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -972,36 +972,35 @@ void UpdatedLagrangianQuadrilateral::FinalizeSolutionStep(ProcessInfo& rCurrentP { KRATOS_TRY - // FinalizeSolutionStep for explicit time integration is done in the scheme - if (!rCurrentProcessInfo.GetValue(IS_EXPLICIT)) - { - // Create and initialize element variables: - GeneralVariables Variables; - this->InitializeGeneralVariables(Variables, rCurrentProcessInfo); + KRATOS_ERROR_IF(rCurrentProcessInfo.GetValue(IS_EXPLICIT)) + << "FinalizeSolutionStep for explicit time integration is done in the scheme"; - // Create constitutive law parameters: - ConstitutiveLaw::Parameters Values(GetGeometry(), GetProperties(), rCurrentProcessInfo); + // Create and initialize element variables: + GeneralVariables Variables; + this->InitializeGeneralVariables(Variables, rCurrentProcessInfo); - // Set constitutive law flags: - Flags& ConstitutiveLawOptions = Values.GetOptions(); + // Create constitutive law parameters: + ConstitutiveLaw::Parameters Values(GetGeometry(), GetProperties(), rCurrentProcessInfo); - ConstitutiveLawOptions.Set(ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN); - ConstitutiveLawOptions.Set(ConstitutiveLaw::COMPUTE_STRESS); + // Set constitutive law flags: + Flags& ConstitutiveLawOptions = Values.GetOptions(); - // Compute element kinematics B, F, DN_DX ... - this->CalculateKinematics(Variables, rCurrentProcessInfo); + ConstitutiveLawOptions.Set(ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN); + ConstitutiveLawOptions.Set(ConstitutiveLaw::COMPUTE_STRESS); - // Set general variables to constitutivelaw parameters - this->SetGeneralVariables(Variables, Values); + // Compute element kinematics B, F, DN_DX ... + this->CalculateKinematics(Variables, rCurrentProcessInfo); - // Call the constitutive law to update material variables - mConstitutiveLawVector->FinalizeMaterialResponse(Values, Variables.StressMeasure); + // Set general variables to constitutivelaw parameters + this->SetGeneralVariables(Variables, Values); - // Call the element internal variables update - this->FinalizeStepVariables(Variables, rCurrentProcessInfo); + // Call the constitutive law to update material variables + mConstitutiveLawVector->FinalizeMaterialResponse(Values, Variables.StressMeasure); - mFinalizedStep = true; - } + // Call the element internal variables update + this->FinalizeStepVariables(Variables, rCurrentProcessInfo); + + mFinalizedStep = true; KRATOS_CATCH("") } From d6e61c2f51d35c68bdbbcc04d1f2f29d99379ae5 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Wed, 8 Apr 2020 11:51:42 +1000 Subject: [PATCH 116/314] [skip ci] more cleanup --- .../updated_lagrangian_quadrilateral.cpp | 5 +- .../schemes/mpm_explicit_scheme.hpp | 188 ++---------------- .../strategies/mpm_explicit_strategy.hpp | 13 -- .../mpm_explicit_utilities.cpp | 29 +-- .../custom_utilities/mpm_explicit_utilities.h | 14 +- 5 files changed, 36 insertions(+), 213 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index e658df3d5415..d30aa93f9228 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -585,8 +585,8 @@ void UpdatedLagrangianQuadrilateral::CalculateExplicitStresses(const ProcessInfo // Compute explicit element kinematics, strain is incremented here. - MPMExplicitUtilities::CalculateExplicitKinematics(rGeom, mDN_DX, delta_time, - mMP.almansi_strain_vector, rVariables.F, isCompressible); + MPMExplicitUtilities::CalculateExplicitKinematics(rCurrentProcessInfo, *this, mDN_DX, + mMP.almansi_strain_vector, rVariables.F); rVariables.StressVector = mMP.cauchy_stress_vector; rVariables.StrainVector = mMP.almansi_strain_vector; @@ -1373,7 +1373,6 @@ void UpdatedLagrangianQuadrilateral::CalculateDampingMatrix( MatrixType& rDampin KRATOS_CATCH( "" ) } -// TODO confirm this is still needed void UpdatedLagrangianQuadrilateral::AddExplicitContribution(const VectorType& rRHSVector, const Variable& rRHSVariable, Variable>& rDestinationVariable, diff --git a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp index 81cc9b18b354..e8c99974923d 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp @@ -120,55 +120,8 @@ namespace Kratos { void Initialize(ModelPart& rModelPart) override { KRATOS_TRY - - ProcessInfo& r_current_process_info = rModelPart.GetProcessInfo(); - // TODO cleanup - // Preparing the time values for the first step (where time = initial_time + - // dt) - mTime.Current = r_current_process_info[TIME] + r_current_process_info[DELTA_TIME]; - mTime.Delta = r_current_process_info[DELTA_TIME]; - mTime.Middle = mTime.Current - 0.5 * mTime.Delta; - mTime.Previous = mTime.Current - mTime.Delta; - mTime.PreviousMiddle = mTime.Current - 1.5 * mTime.Delta; - - /// Working in 2D/3D (the definition of DOMAIN_SIZE is check in the Check method) - const SizeType dim = r_current_process_info[DOMAIN_SIZE]; - // Initialize scheme - if (!BaseType::SchemeIsInitialized()) - InitializeExplicitScheme(rModelPart, dim); - else - SchemeCustomInitialization(rModelPart, dim); - BaseType::SetSchemeIsInitialized(); - - KRATOS_CATCH("") - } - - void InitializeExplicitScheme( - ModelPart& rModelPart, - const SizeType DomainSize = 3 - ) - { - KRATOS_TRY - - /// The array of ndoes - NodesArrayType& r_nodes = rModelPart.Nodes(); - - // The first iterator of the array of nodes - const auto it_node_begin = rModelPart.NodesBegin(); - - #pragma omp parallel for schedule(guided,512) - for (int i = 0; i < static_cast(r_nodes.size()); ++i) { - auto it_node = (it_node_begin + i); - - - array_1d& r_current_residual = it_node->FastGetSolutionStepValue(FORCE_RESIDUAL); - for (IndexType j = 0; j < DomainSize; j++) { - r_current_residual[j] = 0.0; - } - } - KRATOS_CATCH("") } @@ -195,23 +148,10 @@ namespace Kratos { // The current process info ProcessInfo& r_current_process_info = r_model_part.GetProcessInfo(); - // The array of nodes - NodesArrayType& r_nodes = r_model_part.Nodes(); - /// Working in 2D/3D (the definition of DOMAIN_SIZE is check in the Check method) const SizeType dim = r_current_process_info[DOMAIN_SIZE]; + const double delta_time = r_current_process_info[DELTA_TIME]; - // Step Update - // The first step is time = initial_time ( 0.0) + delta time - mTime.Current = r_current_process_info[TIME]; - mTime.Delta = r_current_process_info[DELTA_TIME]; - - mTime.Middle = mTime.Current - 0.50 * mTime.Delta; - mTime.Previous = mTime.Current - 1.00 * mTime.Delta; - mTime.PreviousMiddle = mTime.Middle - 1.00 * mTime.Delta; - - if (mTime.Previous < 0.0) mTime.Previous = 0.00; - if (mTime.PreviousMiddle < 0.0) mTime.PreviousMiddle = 0.00; // The iterator of the first node const auto it_node_begin = r_model_part.NodesBegin(); @@ -219,12 +159,11 @@ namespace Kratos { const IndexType disppos = it_node_begin->GetDofPosition(DISPLACEMENT_X); #pragma omp parallel for schedule(guided,512) - for (int i = 0; i < static_cast(r_nodes.size()); ++i) { + for (int i = 0; i < static_cast(r_model_part.Nodes().size()); ++i) { auto it_node = it_node_begin + i; if ((it_node)->Is(ACTIVE)) { - // Current step information "N+1" (before step update). - this->UpdateTranslationalDegreesOfFreedom(r_current_process_info, it_node, disppos, dim); + this->UpdateTranslationalDegreesOfFreedom(r_current_process_info, it_node, disppos, delta_time, dim); } } // for Node parallel @@ -238,6 +177,7 @@ namespace Kratos { ProcessInfo& r_current_process_info, NodeIterator itCurrentNode, const IndexType DisplacementPosition, + const double delta_time, const SizeType DomainSize = 3 ) { @@ -255,16 +195,16 @@ namespace Kratos { : 1.0; // we are only adding the central difference corrector here - - for (IndexType j = 0; j < DomainSize; j++) { - if (fix_displacements[j]) { + for (IndexType j = 0; j < DomainSize; j++) + { + if (fix_displacements[j]) + { r_nodal_momenta[j] = 0.0; r_current_residual[j] = 0.0; } else { - r_nodal_momenta[j] += gamma * mTime.Delta * r_current_residual[j]; + r_nodal_momenta[j] += gamma * delta_time * r_current_residual[j]; } - } // for DomainSize // We need to set updated grid velocity here if we are using the USL formulation @@ -283,7 +223,6 @@ namespace Kratos { } } - /** This is the place to initialize the elements. This is intended to be called just once when the strategy is initialized */ @@ -291,7 +230,7 @@ namespace Kratos { { KRATOS_TRY - int num_threads = OpenMPUtils::GetNumThreads(); + int num_threads = OpenMPUtils::GetNumThreads(); OpenMPUtils::PartitionVector element_partition; OpenMPUtils::DivideInPartitions(rModelPart.Elements().size(), num_threads, element_partition); @@ -323,7 +262,7 @@ namespace Kratos { { KRATOS_TRY - KRATOS_ERROR_IF(this->mElementsAreInitialized == false) << "Before initilizing Conditions, initialize Elements FIRST" << std::endl; + KRATOS_ERROR_IF(this->mElementsAreInitialized == false) << "Before initilizing Conditions, initialize Elements FIRST" << std::endl; int num_threads = OpenMPUtils::GetNumThreads(); OpenMPUtils::PartitionVector condition_partition; @@ -366,7 +305,6 @@ namespace Kratos { ProcessInfo& rCurrentProcessInfo = r_model_part.GetProcessInfo(); BaseType::InitializeSolutionStep(r_model_part, A, Dx, b); - // LOOP OVER THE GRID NODES PERFORMED FOR CLEAR ALL NODAL INFORMATION #pragma omp parallel for for (int iter = 0; iter < static_cast(mr_grid_model_part.Nodes().size()); ++iter) { @@ -381,7 +319,6 @@ namespace Kratos { array_1d& nodal_velocity = (i)->FastGetSolutionStepValue(VELOCITY); array_1d& nodal_acceleration = (i)->FastGetSolutionStepValue(ACCELERATION); - double& nodal_old_pressure = (i)->FastGetSolutionStepValue(PRESSURE, 1); double& nodal_pressure = (i)->FastGetSolutionStepValue(PRESSURE); if (i->SolutionStepsDataHas(NODAL_MPRESSURE)) { @@ -421,7 +358,6 @@ namespace Kratos { it_elem->CalculateOnIntegrationPoints(CALCULATE_EXPLICIT_MP_STRESS, dummy, rCurrentProcessInfo); } } - KRATOS_CATCH("") } @@ -488,18 +424,11 @@ namespace Kratos { : false; if (isMUSL) PerformModifiedUpdateStressLastMapping(rCurrentProcessInfo, rModelPart, rElements); - - bool calculateMPStresses; - if (rCurrentProcessInfo.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 0 || + const bool calculateMPStresses = ( + rCurrentProcessInfo.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 0 || rCurrentProcessInfo.GetValue(IS_EXPLICIT_CENTRAL_DIFFERENCE)) - { - calculateMPStresses = false; - } - else - { - calculateMPStresses = true; - } - + ? false + : true; // Definition of the first element iterator const auto it_elem_begin = rModelPart.ElementsBegin(); @@ -512,8 +441,6 @@ namespace Kratos { if (!isMUSL) it_elem->CalculateOnIntegrationPoints(EXPLICIT_MAP_GRID_TO_MP, dummy, rCurrentProcessInfo); if (calculateMPStresses) it_elem->CalculateOnIntegrationPoints(CALCULATE_EXPLICIT_MP_STRESS, dummy, rCurrentProcessInfo); - - //it_elem->FinalizeSolutionStep(rCurrentProcessInfo); } // Definition of the first condition iterator @@ -648,68 +575,6 @@ namespace Kratos { KRATOS_CATCH("") } - virtual void SchemeCustomInitialization( - ModelPart& rModelPart, - const SizeType DomainSize = 3 - ) - { - KRATOS_TRY - - // The array containing the nodes - NodesArrayType& r_nodes = rModelPart.Nodes(); - - // The fisrt node interator - const auto it_node_begin = rModelPart.NodesBegin(); - - // Auxiliar zero array - const array_1d zero_array = ZeroVector(3); - - // Getting dof position - const IndexType disppos = it_node_begin->GetDofPosition(DISPLACEMENT_X); - - #pragma omp parallel for schedule(guided,512) - for (int i = 0; i < static_cast(r_nodes.size()); ++i) { - // Current step information "N+1" (before step update). - auto it_node = it_node_begin + i; - - const double nodal_mass = it_node->GetValue(NODAL_MASS); - - const array_1d& r_current_residual = it_node->FastGetSolutionStepValue(FORCE_RESIDUAL); - - array_1d& r_current_velocity = it_node->FastGetSolutionStepValue(VELOCITY); - // array_1d& r_current_displacement = it_node->FastGetSolutionStepValue(DISPLACEMENT); - array_1d& r_current_acceleration = it_node->FastGetSolutionStepValue(ACCELERATION); - - // Solution of the explicit equation: - if (nodal_mass > numerical_limit) { - r_current_acceleration = r_current_residual / nodal_mass; - } - else { - r_current_acceleration = zero_array; - } - - std::array fix_displacements = { false, false, false }; - - fix_displacements[0] = (it_node->GetDof(DISPLACEMENT_X, disppos).IsFixed()); - fix_displacements[1] = (it_node->GetDof(DISPLACEMENT_Y, disppos + 1).IsFixed()); - if (DomainSize == 3) - fix_displacements[2] = (it_node->GetDof(DISPLACEMENT_Z, disppos + 2).IsFixed()); - - for (IndexType j = 0; j < DomainSize; j++) { - if (fix_displacements[j]) { - r_current_acceleration[j] = 0.0; - } - r_current_velocity[j] += (mTime.Previous - mTime.PreviousMiddle) * r_current_acceleration[j]; - // r_current_displacement[j] = 0.0; - } // for DomainSize - - } // for node parallel - - mTime.Previous = mTime.Current; - mTime.PreviousMiddle = mTime.Middle; - KRATOS_CATCH("") - } - void Calculate_RHS_Contribution( Element::Pointer pCurrentElement, LocalSystemVectorType& RHS_Contribution, @@ -718,7 +583,6 @@ namespace Kratos { ) override { KRATOS_TRY - this->TCalculate_RHS_Contribution(pCurrentElement, RHS_Contribution, rCurrentProcessInfo); KRATOS_CATCH("") } @@ -738,9 +602,7 @@ namespace Kratos { ) override { KRATOS_TRY - this->TCalculate_RHS_Contribution(pCurrentCondition, RHS_Contribution, rCurrentProcessInfo); - KRATOS_CATCH("") } @@ -752,33 +614,13 @@ namespace Kratos { ) { KRATOS_TRY - pCurrentEntity->CalculateRightHandSide(RHS_Contribution, rCurrentProcessInfo); pCurrentEntity->AddExplicitContribution(RHS_Contribution, RESIDUAL_VECTOR, FORCE_RESIDUAL, rCurrentProcessInfo); - KRATOS_CATCH("") } protected: /// @name Member Variables - struct DeltaTimeParameters { - double PredictionLevel; // 0, 1, 2 // NOTE: Should be a integer? - double Maximum; // Maximum delta time - double Fraction; // Fraction of the delta time - }; - - /// @brief This struct contains the details of the time variables - struct TimeVariables { - double PreviousMiddle; // n-1/2 - double Previous; // n - double Middle; // n+1/2 - double Current; // n+1 - double Delta; // Time step - }; - - /// Protected static Member Variables - // TODO check if this is needed - TimeVariables mTime; /// This struct contains the details of the time variables ModelPart& mr_grid_model_part; private: diff --git a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp index 7d0d84667e3e..4e316c4a7201 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp @@ -90,17 +90,11 @@ namespace Kratos KRATOS_TRY mKeepSystemConstantDuringIterations = false; - - // Set flags to start correcty the calculations mSolutionStepIsInitialized = false; - mInitializeWasPerformed = false; - mFinalizeSolutionStep = true; - // Set EchoLevel to the default value (only time is displayed) SetEchoLevel(1); - // By default the matrices are rebuilt at each solution step this->SetRebuildLevel(1); @@ -124,7 +118,6 @@ namespace Kratos return mpScheme; }; - void SetInitializePerformedFlag(bool InitializePerformedFlag = true) { mInitializeWasPerformed = InitializePerformedFlag; @@ -166,7 +159,6 @@ namespace Kratos // 2 -> printing linear solver data // 3 -> Print of debug informations: // Echo of stiffness matrix, Dx, b... - void SetEchoLevel(int Level) override { BaseType::mEchoLevel = Level; @@ -248,7 +240,6 @@ namespace Kratos // Compute residual forces on the model part this->CalculateAndAddRHS(pScheme, BaseType::GetModelPart()); - pScheme->Update(BaseType::GetModelPart(), dof_set_dummy, mA, mDx, mb); // Calculate reactions if required @@ -284,11 +275,8 @@ namespace Kratos /*@} */ /**@name Member Variables */ /*@{ */ - typename TSchemeType::Pointer mpScheme; - - /** Flag telling if it is needed to reform the DofSet at each solution step or if it is possible to form it just once @@ -323,7 +311,6 @@ namespace Kratos TSystemVectorType mDx = TSystemVectorType(); TSystemVectorType mb = TSystemVectorType(); - /*Finalization of the solution step, operations to be done after achieving convergence, for example the Final Residual Vector (mb) has to be saved in there diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp index d046d0ecfaca..a2fdc6827a0d 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp @@ -88,7 +88,7 @@ namespace Kratos void MPMExplicitUtilities::UpdateGaussPointExplicit( const ProcessInfo& rCurrentProcessInfo, Element& rElement, - Vector& rN) + const Vector& rN) { KRATOS_TRY @@ -183,7 +183,7 @@ namespace Kratos void MPMExplicitUtilities::CalculateMUSLGridVelocity( Element& rElement, - Vector& rN) + const Vector& rN) { KRATOS_TRY @@ -219,15 +219,16 @@ namespace Kratos /***********************************************************************************/ void MPMExplicitUtilities::CalculateExplicitKinematics( - GeometryType& rGeom, + const ProcessInfo& rCurrentProcessInfo, + Element& rElement, const Matrix& rDN_DX, - const double rDeltaTime, Vector& rMPStrain, - Matrix& rDeformationGradientIncrement, - const bool& isCompressible) + Matrix& rDeformationGradientIncrement) { KRATOS_TRY + GeometryType rGeom = rElement.GetGeometry(); + const double deltaTime = rCurrentProcessInfo[DELTA_TIME]; const SizeType dimension = rGeom.WorkingSpaceDimension(); const SizeType number_of_nodes = rGeom.PointsNumber(); @@ -247,14 +248,14 @@ namespace Kratos } //Calculate rate of deformation and spin tensors - Matrix rateOfDeformation = 0.5 * (velocityGradient + trans(velocityGradient)); - Matrix spinTensor = velocityGradient - rateOfDeformation; + const Matrix rateOfDeformation = 0.5 * (velocityGradient + trans(velocityGradient)); + const Matrix spinTensor = velocityGradient - rateOfDeformation; //Calculate objective Jaumann strain rate - Matrix jaumannRate = rateOfDeformation - - (prod(spinTensor, rateOfDeformation)) * rDeltaTime + - prod((rateOfDeformation * rDeltaTime), spinTensor); - Matrix strainIncrement = rDeltaTime * jaumannRate; + const Matrix jaumannRate = rateOfDeformation - + (prod(spinTensor, rateOfDeformation)) * deltaTime + + prod((rateOfDeformation * deltaTime), spinTensor); + const Matrix strainIncrement = deltaTime * jaumannRate; // Apply strain increment to strain vector rMPStrain(0) += strainIncrement(0, 0); //e_xx @@ -265,7 +266,7 @@ namespace Kratos } else { - rMPStrain(2) += strainIncrement(2, 2) * rDeltaTime; //e_zz + rMPStrain(2) += strainIncrement(2, 2) * deltaTime; //e_zz rMPStrain(3) += 2.0 * strainIncrement(0, 1); //e_xy rMPStrain(4) += 2.0 * strainIncrement(1, 2); //e_yz @@ -274,7 +275,7 @@ namespace Kratos // Model compressibility rDeformationGradientIncrement = IdentityMatrix(dimension); - if (isCompressible) rDeformationGradientIncrement += strainIncrement; + if (rCurrentProcessInfo.GetValue(IS_COMPRESSIBLE)) rDeformationGradientIncrement += strainIncrement; KRATOS_CATCH("") } diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h index 1be6faf2476d..f84af727cb85 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h @@ -46,19 +46,13 @@ namespace Kratos void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) CalcuateAndAddExplicitInternalForce(Element& rElement, const Matrix& rDN_DX, const Vector& rMPStress, const double& rMPVolume, Vector& rRightHandSideVector); - void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) UpdateGaussPointExplicit(const ProcessInfo& rCurrentProcessInfo, - Element& rElement, Vector& rN); - - - void CalculateMUSLGridVelocity(Element& rElement, Vector& rN); - - - void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) CalculateExplicitKinematics(GeometryType& rGeom, - const Matrix& rDN_DX, const double rDeltaTime, Vector& rMPStrain, Matrix& rDeformationGradient, - const bool& isCompressible); + Element& rElement, const Vector& rN); + void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) CalculateMUSLGridVelocity(Element& rElement, const Vector& rN); + void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) CalculateExplicitKinematics(const ProcessInfo& rCurrentProcessInfo, + Element& rElement, const Matrix& rDN_DX, Vector& rMPStrain, Matrix& rDeformationGradient); }; // namespace ExplicitIntegrationUtilities } // namespace Kratos #endif /* KRATOS_MPM_EXPLICIT_UTILITIES defined */ \ No newline at end of file From 20afab30f327fbd00969c793d33dde10ab1febea Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Wed, 8 Apr 2020 11:59:41 +1000 Subject: [PATCH 117/314] [skip ci] processinfo cleanup --- .../custom_strategies/schemes/mpm_explicit_scheme.hpp | 10 +++++----- .../strategies/mpm_explicit_strategy.hpp | 5 ++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp index e8c99974923d..ac8975e82ac4 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp @@ -146,7 +146,7 @@ namespace Kratos { { KRATOS_TRY // The current process info - ProcessInfo& r_current_process_info = r_model_part.GetProcessInfo(); + const ProcessInfo& r_current_process_info = r_model_part.GetProcessInfo(); /// Working in 2D/3D (the definition of DOMAIN_SIZE is check in the Check method) const SizeType dim = r_current_process_info[DOMAIN_SIZE]; @@ -174,7 +174,7 @@ namespace Kratos { //*************************************************************************** void UpdateTranslationalDegreesOfFreedom( - ProcessInfo& r_current_process_info, + const ProcessInfo& r_current_process_info, NodeIterator itCurrentNode, const IndexType DisplacementPosition, const double delta_time, @@ -303,7 +303,7 @@ namespace Kratos { { KRATOS_TRY - ProcessInfo& rCurrentProcessInfo = r_model_part.GetProcessInfo(); + const ProcessInfo& rCurrentProcessInfo = r_model_part.GetProcessInfo(); BaseType::InitializeSolutionStep(r_model_part, A, Dx, b); #pragma omp parallel for for (int iter = 0; iter < static_cast(mr_grid_model_part.Nodes().size()); ++iter) @@ -417,7 +417,7 @@ namespace Kratos { KRATOS_TRY ElementsArrayType& rElements = rModelPart.Elements(); - ProcessInfo& rCurrentProcessInfo = rModelPart.GetProcessInfo(); + const ProcessInfo& rCurrentProcessInfo = rModelPart.GetProcessInfo(); const bool isMUSL = (rCurrentProcessInfo.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 2) ? true @@ -458,7 +458,7 @@ namespace Kratos { //*************************************************************************** //*************************************************************************** - void PerformModifiedUpdateStressLastMapping(ProcessInfo& rCurrentProcessInfo, ModelPart& rModelPart, ElementsArrayType& rElements) + void PerformModifiedUpdateStressLastMapping(const ProcessInfo& rCurrentProcessInfo, ModelPart& rModelPart, ElementsArrayType& rElements) { // MUSL stress update. This works by projecting the updated particle // velocity back to the nodes. The nodal velocity field is then diff --git a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp index 4e316c4a7201..929800f0772a 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp @@ -354,7 +354,6 @@ namespace Kratos { KRATOS_TRY - ProcessInfo& r_current_process_info = rModelPart.GetProcessInfo(); ConditionsArrayType& r_conditions = rModelPart.Conditions(); ElementsArrayType& r_elements = rModelPart.Elements(); @@ -364,13 +363,13 @@ namespace Kratos #pragma omp parallel for firstprivate(RHS_Contribution, equation_id_vector_dummy), schedule(guided,512) for (int i = 0; i < static_cast(r_conditions.size()); ++i) { auto it_cond = r_conditions.begin() + i; - pScheme->Condition_Calculate_RHS_Contribution((*it_cond.base()), RHS_Contribution, equation_id_vector_dummy, r_current_process_info); + pScheme->Condition_Calculate_RHS_Contribution((*it_cond.base()), RHS_Contribution, equation_id_vector_dummy, rModelPart.GetProcessInfo()); } #pragma omp parallel for firstprivate(RHS_Contribution, equation_id_vector_dummy), schedule(guided,512) for (int i = 0; i < static_cast(r_elements.size()); ++i) { auto it_elem = r_elements.begin() + i; - pScheme->Calculate_RHS_Contribution((*it_elem.base()), RHS_Contribution, equation_id_vector_dummy, r_current_process_info); + pScheme->Calculate_RHS_Contribution((*it_elem.base()), RHS_Contribution, equation_id_vector_dummy, rModelPart.GetProcessInfo()); } KRATOS_CATCH("") From 77eadb542385ca7c60dfaf0d17d7fbe9744824b4 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Wed, 8 Apr 2020 12:38:04 +1000 Subject: [PATCH 118/314] test CI, fix unused variables --- .../custom_elements/updated_lagrangian_quadrilateral.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index d30aa93f9228..4a6a27d2baae 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -565,10 +565,6 @@ void UpdatedLagrangianQuadrilateral::CalculateExplicitStresses(const ProcessInfo { KRATOS_TRY - GeometryType& rGeom = GetGeometry(); - const double& delta_time = rCurrentProcessInfo[DELTA_TIME]; - bool isCompressible = rCurrentProcessInfo.GetValue(IS_COMPRESSIBLE); - // Create constitutive law parameters: ConstitutiveLaw::Parameters Values(GetGeometry(), GetProperties(), rCurrentProcessInfo); @@ -600,7 +596,7 @@ void UpdatedLagrangianQuadrilateral::CalculateExplicitStresses(const ProcessInfo mDeterminantF0 = rVariables.detFT; // update member internal total grad def det // Update MP volume - if (isCompressible) + if (rCurrentProcessInfo.GetValue(IS_COMPRESSIBLE)) { mMP.density = (GetProperties()[DENSITY]) / rVariables.detFT; mMP.volume = mMP.mass / mMP.density; From 7908e0ab24eb573bc9660a18ec313590087350c4 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Wed, 8 Apr 2020 16:08:01 +1000 Subject: [PATCH 119/314] [skip ci] remove outdated comment --- .../custom_strategies/schemes/mpm_explicit_scheme.hpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp index ac8975e82ac4..d79e52f4367c 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp @@ -464,10 +464,6 @@ namespace Kratos { // velocity back to the nodes. The nodal velocity field is then // used for stress computations. - // We need to call 'FinalizeSolutionStep' twice. - // First, to update the particles and then aggregate the new particle velocities on the grid. - // Second, to calculate the stresses from the grid velocity - // Definition of the first element iterator const auto it_elem_begin = rModelPart.ElementsBegin(); From bc2172dac8ebe6090e23bf1a9936a398964db009 Mon Sep 17 00:00:00 2001 From: Miguel Date: Wed, 8 Apr 2020 14:19:11 +0200 Subject: [PATCH 120/314] updating component variables --- .../apply_perturbation_function_process.cpp | 3 +-- .../apply_sinusoidal_function_process.cpp | 3 +-- .../add_custom_processes_to_python.cpp | 15 --------------- .../add_custom_utilities_to_python.cpp | 8 -------- .../bfecc_convection_utility.cpp | 5 ++--- .../move_shallow_water_particle_utility.h | 2 +- .../convergence_output_process.py | 2 +- ...test_apply_perturbation_function_process.cpp | 17 +---------------- 8 files changed, 7 insertions(+), 48 deletions(-) diff --git a/applications/ShallowWaterApplication/custom_processes/apply_perturbation_function_process.cpp b/applications/ShallowWaterApplication/custom_processes/apply_perturbation_function_process.cpp index fc3a3ebe8017..8d6e66073717 100644 --- a/applications/ShallowWaterApplication/custom_processes/apply_perturbation_function_process.cpp +++ b/applications/ShallowWaterApplication/custom_processes/apply_perturbation_function_process.cpp @@ -80,7 +80,7 @@ void ApplyPerturbationFunctionProcess::ExecuteBeforeSolutionLoop() double distance = ComputeDistance(*i_node.base()); double& r_value = i_node->FastGetSolutionStepValue(mrVariable); r_value = ComputeInitialValue(distance); - } + } } @@ -136,6 +136,5 @@ void ApplyPerturbationFunctionProcess::ValidateParameters(Parameters& } template class ApplyPerturbationFunctionProcess>; -template class ApplyPerturbationFunctionProcess>>>; } // namespace Kratos. diff --git a/applications/ShallowWaterApplication/custom_processes/apply_sinusoidal_function_process.cpp b/applications/ShallowWaterApplication/custom_processes/apply_sinusoidal_function_process.cpp index 1d88d9b14037..3f2e318d943a 100644 --- a/applications/ShallowWaterApplication/custom_processes/apply_sinusoidal_function_process.cpp +++ b/applications/ShallowWaterApplication/custom_processes/apply_sinusoidal_function_process.cpp @@ -126,7 +126,6 @@ void ApplySinusoidalFunctionProcess::ValidateParameters(Parameters& rP template class ApplySinusoidalFunctionProcess< Variable >; -template class ApplySinusoidalFunctionProcess< VariableComponent< VectorComponentAdaptor< array_1d > > >; template class ApplySinusoidalFunctionProcess< Variable< array_1d > >; -} // namespace Kratos. \ No newline at end of file +} // namespace Kratos. diff --git a/applications/ShallowWaterApplication/custom_python/add_custom_processes_to_python.cpp b/applications/ShallowWaterApplication/custom_python/add_custom_processes_to_python.cpp index a77ce0b97771..975fafe3883b 100644 --- a/applications/ShallowWaterApplication/custom_python/add_custom_processes_to_python.cpp +++ b/applications/ShallowWaterApplication/custom_python/add_custom_processes_to_python.cpp @@ -40,8 +40,6 @@ namespace Python { namespace py = pybind11; - typedef VariableComponent>> VariableComponentType; - py::class_ (m, "ElementalRefiningCriteriaProcess") .def(py::init()) @@ -56,25 +54,12 @@ namespace Python .def(py::init&, Parameters&>()) ; - typedef ApplyPerturbationFunctionProcess ApplyPerturbationComponentFunctionProcess; - py::class_ - (m, "ApplyPerturbationFunctionToComponent") - .def(py::init::Pointer, VariableComponentType&, Parameters&>()) - .def(py::init()) - ; - typedef ApplySinusoidalFunctionProcess> ApplySinusoidalScalarFunctionProcess; py::class_ (m, "ApplySinusoidalFunctionToScalar") .def(py::init&, Parameters&>()) ; - typedef ApplySinusoidalFunctionProcess ApplySinusoidalComponentFunctionProcess; - py::class_ - (m, "ApplySinusoidalFunctionToComponent") - .def(py::init()) - ; - typedef ApplySinusoidalFunctionProcess>> ApplySinusoidalVectorFunctionProcess; py::class_ (m, "ApplySinusoidalFunctionToVector") diff --git a/applications/ShallowWaterApplication/custom_python/add_custom_utilities_to_python.cpp b/applications/ShallowWaterApplication/custom_python/add_custom_utilities_to_python.cpp index 03cf878fdd50..f1718ddbc021 100644 --- a/applications/ShallowWaterApplication/custom_python/add_custom_utilities_to_python.cpp +++ b/applications/ShallowWaterApplication/custom_python/add_custom_utilities_to_python.cpp @@ -56,8 +56,6 @@ namespace Python { namespace py = pybind11; - typedef VariableComponent>> ComponentVariableType; - py::class_< MoveShallowWaterParticleUtility<2> > (m, "MoveShallowWaterParticleUtility") .def(py::init()) .def("MountBin", &MoveShallowWaterParticleUtility<2>::MountBin) @@ -97,9 +95,6 @@ namespace Python .def("RootMeanSquareNonHistorical", &ShallowWaterUtilities::RootMeanSquareNonHistorical, ModelPart::NodesContainerType>) .def("RootMeanSquareNonHistorical", &ShallowWaterUtilities::RootMeanSquareNonHistorical, ModelPart::ElementsContainerType>) .def("RootMeanSquareNonHistorical", &ShallowWaterUtilities::RootMeanSquareNonHistorical, ModelPart::ConditionsContainerType>) - .def("RootMeanSquareNonHistorical", &ShallowWaterUtilities::RootMeanSquareNonHistorical) - .def("RootMeanSquareNonHistorical", &ShallowWaterUtilities::RootMeanSquareNonHistorical) - .def("RootMeanSquareNonHistorical", &ShallowWaterUtilities::RootMeanSquareNonHistorical) ; py::class_< EstimateDtShallow > (m, "EstimateDtShallow") @@ -113,10 +108,8 @@ namespace Python .def("Replicate", &ReplicateModelPartUtility::Replicate) .def("TransferVariable", &ReplicateModelPartUtility::TransferVariable>) .def("TransferVariable", &ReplicateModelPartUtility::TransferVariable>>) - .def("TransferVariable", &ReplicateModelPartUtility::TransferVariable>>>) .def("TransferNonHistoricalVariable", &ReplicateModelPartUtility::TransferNonHistoricalVariable>) .def("TransferNonHistoricalVariable", &ReplicateModelPartUtility::TransferNonHistoricalVariable>>) - .def("TransferNonHistoricalVariable", &ReplicateModelPartUtility::TransferNonHistoricalVariable>>>) .def("SetOriginMeshZCoordinate", SetOriginMeshZCoordinate1) .def("SetOriginMeshZCoordinate", SetOriginMeshZCoordinate2) .def("SetDestinationMeshZCoordinate", SetDestinationMeshZCoordinate1) @@ -137,7 +130,6 @@ namespace Python .def("Convect", &BFECCConvectionUtility<2>::Convect>,array_1d>) .def("UpdateSearchDatabase", &BFECCConvectionUtility<2>::UpdateSearchDatabase) .def("ResetBoundaryConditions", &BFECCConvectionUtility<2>::ResetBoundaryConditions>) - .def("ResetBoundaryConditions", &BFECCConvectionUtility<2>::ResetBoundaryConditions>>>) .def("CopyVariableToPreviousTimeStep", &BFECCConvectionUtility<2>::CopyVariableToPreviousTimeStep>) .def("CopyVariableToPreviousTimeStep", &BFECCConvectionUtility<2>::CopyVariableToPreviousTimeStep>>) ; diff --git a/applications/ShallowWaterApplication/custom_utilities/bfecc_convection_utility.cpp b/applications/ShallowWaterApplication/custom_utilities/bfecc_convection_utility.cpp index 9c71a14a77e8..151397a95a6c 100644 --- a/applications/ShallowWaterApplication/custom_utilities/bfecc_convection_utility.cpp +++ b/applications/ShallowWaterApplication/custom_utilities/bfecc_convection_utility.cpp @@ -36,7 +36,7 @@ BFECCConvectionUtility::BFECCConvectionUtility(ModelPart& rThisModelPart, ThisParameters.ValidateAndAssignDefaults(default_parameters); mMaxResults = ThisParameters["maximum_results"].GetDouble(); - + mSearchStructure.UpdateSearchDatabase(); } @@ -211,9 +211,8 @@ template void BFECCConvectionUtility<2>::Convect>, a template void BFECCConvectionUtility<3>::Convect>, array_1d>(const Variable>&, const Variable>&); template void BFECCConvectionUtility<2>::ResetBoundaryConditions(const Variable&); -template void BFECCConvectionUtility<2>::ResetBoundaryConditions(const VariableComponent>>&); template void BFECCConvectionUtility<2>::CopyVariableToPreviousTimeStep(const Variable&); template void BFECCConvectionUtility<2>::CopyVariableToPreviousTimeStep(const Variable>&); -} // namespace Kratos \ No newline at end of file +} // namespace Kratos diff --git a/applications/ShallowWaterApplication/custom_utilities/move_shallow_water_particle_utility.h b/applications/ShallowWaterApplication/custom_utilities/move_shallow_water_particle_utility.h index 06cf0246ba21..f5e00fb7bd45 100644 --- a/applications/ShallowWaterApplication/custom_utilities/move_shallow_water_particle_utility.h +++ b/applications/ShallowWaterApplication/custom_utilities/move_shallow_water_particle_utility.h @@ -361,7 +361,7 @@ class MoveShallowWaterParticleUtility { KRATOS_TRY - typedef VariableComponent > > component_type; + typedef Variable component_type; component_type vector_var_x = KratosComponents< component_type >::Get(m_vector_var1_name+std::string("_X")); component_type vector_var_y = KratosComponents< component_type >::Get(m_vector_var1_name+std::string("_Y")); component_type vector_var_z = KratosComponents< component_type >::Get(m_vector_var1_name+std::string("_Z")); diff --git a/applications/ShallowWaterApplication/python_scripts/convergence_output_process.py b/applications/ShallowWaterApplication/python_scripts/convergence_output_process.py index b6b373a97196..82a3ab5d19b0 100644 --- a/applications/ShallowWaterApplication/python_scripts/convergence_output_process.py +++ b/applications/ShallowWaterApplication/python_scripts/convergence_output_process.py @@ -59,7 +59,7 @@ def ExecuteFinalize(self): def Check(self): for variable in self.variables: - if not isinstance(variable, KM.DoubleVariable) and not isinstance(variable, KM.Array1DComponentVariable): + if not isinstance(variable, KM.DoubleVariable): raise Exception("This process is expecting only double or component variables") if not isinstance(self.weight_variable, KM.DoubleVariable): diff --git a/applications/ShallowWaterApplication/tests/cpp_tests/test_apply_perturbation_function_process.cpp b/applications/ShallowWaterApplication/tests/cpp_tests/test_apply_perturbation_function_process.cpp index d0a78a249c13..7926a6120f7c 100644 --- a/applications/ShallowWaterApplication/tests/cpp_tests/test_apply_perturbation_function_process.cpp +++ b/applications/ShallowWaterApplication/tests/cpp_tests/test_apply_perturbation_function_process.cpp @@ -86,23 +86,8 @@ KRATOS_TEST_CASE_IN_SUITE(ApplyPerturbationFunctionProcess, ShallowWaterApplicat double value = node.FastGetSolutionStepValue(FREE_SURFACE_ELEVATION); KRATOS_CHECK_NEAR(value, exact_value, tolerance); } - - // Creation and execution of the process for component - ApplyPerturbationFunctionProcess>>>( - model_part, - sub_model_part.Nodes(), - WATER_SURFACE_Z, - parameters)(); - - for (auto& node : model_part.Nodes()) - { - double x = node.X(); - double exact_value = ((x < 1.0) ? (0.0) : (periodic_function(x))); - double value = node.FastGetSolutionStepValue(WATER_SURFACE_Z); - KRATOS_CHECK_NEAR(value, exact_value, tolerance); - } } } // namespace Testing -} // namespace Kratos \ No newline at end of file +} // namespace Kratos From 781b1399e88ddc5b30779a888fa8808c1cf08e55 Mon Sep 17 00:00:00 2001 From: Miguel Date: Wed, 8 Apr 2020 14:28:15 +0200 Subject: [PATCH 121/314] Revert "updating component variables" This reverts commit bc2172dac8ebe6090e23bf1a9936a398964db009. --- .../apply_perturbation_function_process.cpp | 3 ++- .../apply_sinusoidal_function_process.cpp | 3 ++- .../add_custom_processes_to_python.cpp | 15 +++++++++++++++ .../add_custom_utilities_to_python.cpp | 8 ++++++++ .../bfecc_convection_utility.cpp | 5 +++-- .../move_shallow_water_particle_utility.h | 2 +- .../convergence_output_process.py | 2 +- ...test_apply_perturbation_function_process.cpp | 17 ++++++++++++++++- 8 files changed, 48 insertions(+), 7 deletions(-) diff --git a/applications/ShallowWaterApplication/custom_processes/apply_perturbation_function_process.cpp b/applications/ShallowWaterApplication/custom_processes/apply_perturbation_function_process.cpp index 8d6e66073717..fc3a3ebe8017 100644 --- a/applications/ShallowWaterApplication/custom_processes/apply_perturbation_function_process.cpp +++ b/applications/ShallowWaterApplication/custom_processes/apply_perturbation_function_process.cpp @@ -80,7 +80,7 @@ void ApplyPerturbationFunctionProcess::ExecuteBeforeSolutionLoop() double distance = ComputeDistance(*i_node.base()); double& r_value = i_node->FastGetSolutionStepValue(mrVariable); r_value = ComputeInitialValue(distance); - } + } } @@ -136,5 +136,6 @@ void ApplyPerturbationFunctionProcess::ValidateParameters(Parameters& } template class ApplyPerturbationFunctionProcess>; +template class ApplyPerturbationFunctionProcess>>>; } // namespace Kratos. diff --git a/applications/ShallowWaterApplication/custom_processes/apply_sinusoidal_function_process.cpp b/applications/ShallowWaterApplication/custom_processes/apply_sinusoidal_function_process.cpp index 3f2e318d943a..1d88d9b14037 100644 --- a/applications/ShallowWaterApplication/custom_processes/apply_sinusoidal_function_process.cpp +++ b/applications/ShallowWaterApplication/custom_processes/apply_sinusoidal_function_process.cpp @@ -126,6 +126,7 @@ void ApplySinusoidalFunctionProcess::ValidateParameters(Parameters& rP template class ApplySinusoidalFunctionProcess< Variable >; +template class ApplySinusoidalFunctionProcess< VariableComponent< VectorComponentAdaptor< array_1d > > >; template class ApplySinusoidalFunctionProcess< Variable< array_1d > >; -} // namespace Kratos. +} // namespace Kratos. \ No newline at end of file diff --git a/applications/ShallowWaterApplication/custom_python/add_custom_processes_to_python.cpp b/applications/ShallowWaterApplication/custom_python/add_custom_processes_to_python.cpp index 975fafe3883b..a77ce0b97771 100644 --- a/applications/ShallowWaterApplication/custom_python/add_custom_processes_to_python.cpp +++ b/applications/ShallowWaterApplication/custom_python/add_custom_processes_to_python.cpp @@ -40,6 +40,8 @@ namespace Python { namespace py = pybind11; + typedef VariableComponent>> VariableComponentType; + py::class_ (m, "ElementalRefiningCriteriaProcess") .def(py::init()) @@ -54,12 +56,25 @@ namespace Python .def(py::init&, Parameters&>()) ; + typedef ApplyPerturbationFunctionProcess ApplyPerturbationComponentFunctionProcess; + py::class_ + (m, "ApplyPerturbationFunctionToComponent") + .def(py::init::Pointer, VariableComponentType&, Parameters&>()) + .def(py::init()) + ; + typedef ApplySinusoidalFunctionProcess> ApplySinusoidalScalarFunctionProcess; py::class_ (m, "ApplySinusoidalFunctionToScalar") .def(py::init&, Parameters&>()) ; + typedef ApplySinusoidalFunctionProcess ApplySinusoidalComponentFunctionProcess; + py::class_ + (m, "ApplySinusoidalFunctionToComponent") + .def(py::init()) + ; + typedef ApplySinusoidalFunctionProcess>> ApplySinusoidalVectorFunctionProcess; py::class_ (m, "ApplySinusoidalFunctionToVector") diff --git a/applications/ShallowWaterApplication/custom_python/add_custom_utilities_to_python.cpp b/applications/ShallowWaterApplication/custom_python/add_custom_utilities_to_python.cpp index f1718ddbc021..03cf878fdd50 100644 --- a/applications/ShallowWaterApplication/custom_python/add_custom_utilities_to_python.cpp +++ b/applications/ShallowWaterApplication/custom_python/add_custom_utilities_to_python.cpp @@ -56,6 +56,8 @@ namespace Python { namespace py = pybind11; + typedef VariableComponent>> ComponentVariableType; + py::class_< MoveShallowWaterParticleUtility<2> > (m, "MoveShallowWaterParticleUtility") .def(py::init()) .def("MountBin", &MoveShallowWaterParticleUtility<2>::MountBin) @@ -95,6 +97,9 @@ namespace Python .def("RootMeanSquareNonHistorical", &ShallowWaterUtilities::RootMeanSquareNonHistorical, ModelPart::NodesContainerType>) .def("RootMeanSquareNonHistorical", &ShallowWaterUtilities::RootMeanSquareNonHistorical, ModelPart::ElementsContainerType>) .def("RootMeanSquareNonHistorical", &ShallowWaterUtilities::RootMeanSquareNonHistorical, ModelPart::ConditionsContainerType>) + .def("RootMeanSquareNonHistorical", &ShallowWaterUtilities::RootMeanSquareNonHistorical) + .def("RootMeanSquareNonHistorical", &ShallowWaterUtilities::RootMeanSquareNonHistorical) + .def("RootMeanSquareNonHistorical", &ShallowWaterUtilities::RootMeanSquareNonHistorical) ; py::class_< EstimateDtShallow > (m, "EstimateDtShallow") @@ -108,8 +113,10 @@ namespace Python .def("Replicate", &ReplicateModelPartUtility::Replicate) .def("TransferVariable", &ReplicateModelPartUtility::TransferVariable>) .def("TransferVariable", &ReplicateModelPartUtility::TransferVariable>>) + .def("TransferVariable", &ReplicateModelPartUtility::TransferVariable>>>) .def("TransferNonHistoricalVariable", &ReplicateModelPartUtility::TransferNonHistoricalVariable>) .def("TransferNonHistoricalVariable", &ReplicateModelPartUtility::TransferNonHistoricalVariable>>) + .def("TransferNonHistoricalVariable", &ReplicateModelPartUtility::TransferNonHistoricalVariable>>>) .def("SetOriginMeshZCoordinate", SetOriginMeshZCoordinate1) .def("SetOriginMeshZCoordinate", SetOriginMeshZCoordinate2) .def("SetDestinationMeshZCoordinate", SetDestinationMeshZCoordinate1) @@ -130,6 +137,7 @@ namespace Python .def("Convect", &BFECCConvectionUtility<2>::Convect>,array_1d>) .def("UpdateSearchDatabase", &BFECCConvectionUtility<2>::UpdateSearchDatabase) .def("ResetBoundaryConditions", &BFECCConvectionUtility<2>::ResetBoundaryConditions>) + .def("ResetBoundaryConditions", &BFECCConvectionUtility<2>::ResetBoundaryConditions>>>) .def("CopyVariableToPreviousTimeStep", &BFECCConvectionUtility<2>::CopyVariableToPreviousTimeStep>) .def("CopyVariableToPreviousTimeStep", &BFECCConvectionUtility<2>::CopyVariableToPreviousTimeStep>>) ; diff --git a/applications/ShallowWaterApplication/custom_utilities/bfecc_convection_utility.cpp b/applications/ShallowWaterApplication/custom_utilities/bfecc_convection_utility.cpp index 151397a95a6c..9c71a14a77e8 100644 --- a/applications/ShallowWaterApplication/custom_utilities/bfecc_convection_utility.cpp +++ b/applications/ShallowWaterApplication/custom_utilities/bfecc_convection_utility.cpp @@ -36,7 +36,7 @@ BFECCConvectionUtility::BFECCConvectionUtility(ModelPart& rThisModelPart, ThisParameters.ValidateAndAssignDefaults(default_parameters); mMaxResults = ThisParameters["maximum_results"].GetDouble(); - + mSearchStructure.UpdateSearchDatabase(); } @@ -211,8 +211,9 @@ template void BFECCConvectionUtility<2>::Convect>, a template void BFECCConvectionUtility<3>::Convect>, array_1d>(const Variable>&, const Variable>&); template void BFECCConvectionUtility<2>::ResetBoundaryConditions(const Variable&); +template void BFECCConvectionUtility<2>::ResetBoundaryConditions(const VariableComponent>>&); template void BFECCConvectionUtility<2>::CopyVariableToPreviousTimeStep(const Variable&); template void BFECCConvectionUtility<2>::CopyVariableToPreviousTimeStep(const Variable>&); -} // namespace Kratos +} // namespace Kratos \ No newline at end of file diff --git a/applications/ShallowWaterApplication/custom_utilities/move_shallow_water_particle_utility.h b/applications/ShallowWaterApplication/custom_utilities/move_shallow_water_particle_utility.h index f5e00fb7bd45..06cf0246ba21 100644 --- a/applications/ShallowWaterApplication/custom_utilities/move_shallow_water_particle_utility.h +++ b/applications/ShallowWaterApplication/custom_utilities/move_shallow_water_particle_utility.h @@ -361,7 +361,7 @@ class MoveShallowWaterParticleUtility { KRATOS_TRY - typedef Variable component_type; + typedef VariableComponent > > component_type; component_type vector_var_x = KratosComponents< component_type >::Get(m_vector_var1_name+std::string("_X")); component_type vector_var_y = KratosComponents< component_type >::Get(m_vector_var1_name+std::string("_Y")); component_type vector_var_z = KratosComponents< component_type >::Get(m_vector_var1_name+std::string("_Z")); diff --git a/applications/ShallowWaterApplication/python_scripts/convergence_output_process.py b/applications/ShallowWaterApplication/python_scripts/convergence_output_process.py index 82a3ab5d19b0..b6b373a97196 100644 --- a/applications/ShallowWaterApplication/python_scripts/convergence_output_process.py +++ b/applications/ShallowWaterApplication/python_scripts/convergence_output_process.py @@ -59,7 +59,7 @@ def ExecuteFinalize(self): def Check(self): for variable in self.variables: - if not isinstance(variable, KM.DoubleVariable): + if not isinstance(variable, KM.DoubleVariable) and not isinstance(variable, KM.Array1DComponentVariable): raise Exception("This process is expecting only double or component variables") if not isinstance(self.weight_variable, KM.DoubleVariable): diff --git a/applications/ShallowWaterApplication/tests/cpp_tests/test_apply_perturbation_function_process.cpp b/applications/ShallowWaterApplication/tests/cpp_tests/test_apply_perturbation_function_process.cpp index 7926a6120f7c..d0a78a249c13 100644 --- a/applications/ShallowWaterApplication/tests/cpp_tests/test_apply_perturbation_function_process.cpp +++ b/applications/ShallowWaterApplication/tests/cpp_tests/test_apply_perturbation_function_process.cpp @@ -86,8 +86,23 @@ KRATOS_TEST_CASE_IN_SUITE(ApplyPerturbationFunctionProcess, ShallowWaterApplicat double value = node.FastGetSolutionStepValue(FREE_SURFACE_ELEVATION); KRATOS_CHECK_NEAR(value, exact_value, tolerance); } + + // Creation and execution of the process for component + ApplyPerturbationFunctionProcess>>>( + model_part, + sub_model_part.Nodes(), + WATER_SURFACE_Z, + parameters)(); + + for (auto& node : model_part.Nodes()) + { + double x = node.X(); + double exact_value = ((x < 1.0) ? (0.0) : (periodic_function(x))); + double value = node.FastGetSolutionStepValue(WATER_SURFACE_Z); + KRATOS_CHECK_NEAR(value, exact_value, tolerance); + } } } // namespace Testing -} // namespace Kratos +} // namespace Kratos \ No newline at end of file From cdc91429b86424abae9619a23112d7bfca9540b8 Mon Sep 17 00:00:00 2001 From: Miguel Angel Date: Wed, 8 Apr 2020 17:11:16 +0200 Subject: [PATCH 122/314] Attempt to use a different random generator --- applications/DEMApplication/custom_utilities/inlet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/DEMApplication/custom_utilities/inlet.cpp b/applications/DEMApplication/custom_utilities/inlet.cpp index a6e5cd5a4252..7db387f7bdfe 100644 --- a/applications/DEMApplication/custom_utilities/inlet.cpp +++ b/applications/DEMApplication/custom_utilities/inlet.cpp @@ -540,7 +540,7 @@ namespace Kratos { if (number_of_particles_to_insert) { //randomizing mesh - srand(/*time(NULL)* */r_modelpart.GetProcessInfo()[TIME_STEPS]); + std::mt19937 random_generator(r_modelpart.GetProcessInfo()[TIME_STEPS]); ModelPart::ElementsContainerType::ContainerType valid_elements(mesh_size_elements); //This is a new vector we are going to work on int valid_elements_length = 0; @@ -605,7 +605,7 @@ namespace Kratos { } } - int random_pos = rand() % valid_elements_length; + int random_pos = random_generator() % valid_elements_length; Element* p_injector_element = valid_elements[random_pos].get(); if (mp[CONTAINS_CLUSTERS] == false) { From 0475a98802089b8432046aabc76f69aa50e802a6 Mon Sep 17 00:00:00 2001 From: Miguel Angel Date: Wed, 8 Apr 2020 17:22:21 +0200 Subject: [PATCH 123/314] I forgot the include, which was not needed in my pc btw --- applications/DEMApplication/custom_utilities/inlet.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/applications/DEMApplication/custom_utilities/inlet.cpp b/applications/DEMApplication/custom_utilities/inlet.cpp index 7db387f7bdfe..3b151d683b2c 100644 --- a/applications/DEMApplication/custom_utilities/inlet.cpp +++ b/applications/DEMApplication/custom_utilities/inlet.cpp @@ -5,6 +5,7 @@ #include #include +#include #include "inlet.h" #include "create_and_destroy.h" From 7a7688d76337ca33ebb0a58ca7f3723e2dfb3bda Mon Sep 17 00:00:00 2001 From: Miguel Angel Date: Wed, 8 Apr 2020 21:05:20 +0200 Subject: [PATCH 124/314] The inlet has an ordered list of submodelparts now --- .../DEMApplication/custom_utilities/inlet.cpp | 41 ++++++++++++------- .../DEMApplication/custom_utilities/inlet.h | 1 + .../DEMApplication/tests/test_DEM_2D_inlet.py | 2 +- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/applications/DEMApplication/custom_utilities/inlet.cpp b/applications/DEMApplication/custom_utilities/inlet.cpp index 3b151d683b2c..238d8618d2d5 100644 --- a/applications/DEMApplication/custom_utilities/inlet.cpp +++ b/applications/DEMApplication/custom_utilities/inlet.cpp @@ -35,6 +35,10 @@ namespace Kratos { return indentation; } + bool SortSubModelPartsByName(ModelPart* A, ModelPart* B) { + return (A->Name() < B->Name()); + } + /// Constructor DEM_Inlet::DEM_Inlet(ModelPart& inlet_modelpart): mInletModelPart(inlet_modelpart) @@ -114,15 +118,22 @@ namespace Kratos { int smp_number = 0; for (ModelPart::SubModelPartsContainerType::iterator smp_it = mInletModelPart.SubModelPartsBegin(); smp_it != mInletModelPart.SubModelPartsEnd(); ++smp_it) { - ModelPart& mp = *smp_it; + ModelPart* mp = &*smp_it; + mListOfSubModelParts.push_back(mp); + } + std::sort(mListOfSubModelParts.begin(), mListOfSubModelParts.end(), SortSubModelPartsByName); + + for(int i=0; i<(int)mListOfSubModelParts.size(); i++) { + ModelPart& mp = *mListOfSubModelParts[i]; + CheckSubModelPart(mp); mp[MAXIMUM_RADIUS] = 1.5 * mp[RADIUS]; mp[MINIMUM_RADIUS] = 0.5 * mp[RADIUS]; - int mesh_size = smp_it->NumberOfNodes(); + int mesh_size = mp.NumberOfNodes(); if (!mesh_size) continue; - ModelPart::NodesContainerType::ContainerType& all_nodes = smp_it->NodesArray(); + ModelPart::NodesContainerType::ContainerType& all_nodes = mp.NodesArray(); std::string& identifier = mp[IDENTIFIER]; mp[INLET_INITIAL_VELOCITY] = mp[LINEAR_VELOCITY]; //This is the velocity of the moving injector of particles mp[INLET_INITIAL_PARTICLES_VELOCITY] = mp[VELOCITY]; //This is the initial velocity vector of the injected particles @@ -172,7 +183,7 @@ namespace Kratos { mBallsModelPartHasSphericity, mBallsModelPartHasRotation, true, - smp_it->Elements()); + mp.Elements()); FixInjectorConditions(p_element); max_Id++; @@ -454,8 +465,8 @@ namespace Kratos { void DEM_Inlet::InitializeStep(ModelPart& r_modelpart) { bool is_there_any_dense_inlet = false; - for (ModelPart::SubModelPartsContainerType::iterator smp_it = mInletModelPart.SubModelPartsBegin(); smp_it != mInletModelPart.SubModelPartsEnd(); ++smp_it) { - ModelPart& mp = *smp_it; + for(int i=0; i<(int)mListOfSubModelParts.size(); i++) { + ModelPart& mp = *mListOfSubModelParts[i]; if (mp[DENSE_INLET]) { is_there_any_dense_inlet = true; break; @@ -475,15 +486,15 @@ namespace Kratos { int smp_number = 0; int inter_smp_number = 0; - for (ModelPart::SubModelPartsContainerType::iterator smp_it = mInletModelPart.SubModelPartsBegin(); smp_it != mInletModelPart.SubModelPartsEnd(); ++smp_it) { - ModelPart& mp = *smp_it; + for(int i=0; i<(int)mListOfSubModelParts.size(); i++) { + ModelPart& mp = *mListOfSubModelParts[i]; const double inlet_start_time = mp[INLET_START_TIME]; if (current_time < inlet_start_time) continue; - const int mesh_size_elements = smp_it->NumberOfElements(); + const int mesh_size_elements = mp.NumberOfElements(); - ModelPart::ElementsContainerType::ContainerType& all_elements = smp_it->ElementsArray(); + ModelPart::ElementsContainerType::ContainerType& all_elements = mp.ElementsArray(); if (current_time > mp[INLET_STOP_TIME]) { if (mLayerRemoved[inter_smp_number]) continue; @@ -623,9 +634,9 @@ namespace Kratos { mBallsModelPartHasSphericity, mBallsModelPartHasRotation, false, - smp_it->Elements()); + mp.Elements()); - mOriginInletSubmodelPartIndexes[p_spheric_particle->Id()] = smp_it->Name(); + mOriginInletSubmodelPartIndexes[p_spheric_particle->Id()] = mp.Name(); FixInjectionConditions(p_spheric_particle, p_injector_element); UpdatePartialThroughput(*p_spheric_particle, smp_number); max_Id++; @@ -647,20 +658,20 @@ namespace Kratos { p_fast_properties, mBallsModelPartHasSphericity, mBallsModelPartHasRotation, - smp_it->Elements(), + mp.Elements(), number_of_added_spheres, mStrategyForContinuum, new_component_spheres); max_Id += number_of_added_spheres; if (p_cluster) { - mOriginInletSubmodelPartIndexes[p_cluster->Id()] = smp_it->Name(); + mOriginInletSubmodelPartIndexes[p_cluster->Id()] = mp.Name(); UpdateInjectedParticleVelocity(*p_cluster, *p_injector_element); } else { for (unsigned int i = 0; i < new_component_spheres.size(); ++i) { - mOriginInletSubmodelPartIndexes[new_component_spheres[i]->Id()] = smp_it->Name(); + mOriginInletSubmodelPartIndexes[new_component_spheres[i]->Id()] = mp.Name(); UpdateInjectedParticleVelocity(*new_component_spheres[i], *p_injector_element); } diff --git a/applications/DEMApplication/custom_utilities/inlet.h b/applications/DEMApplication/custom_utilities/inlet.h index db596680f96d..3e23af95177b 100644 --- a/applications/DEMApplication/custom_utilities/inlet.h +++ b/applications/DEMApplication/custom_utilities/inlet.h @@ -112,6 +112,7 @@ namespace Kratos { bool mWarningTooSmallInletForMassFlow; void ThrowWarningTooSmallInlet(const ModelPart& mp); void ThrowWarningTooSmallInletForMassFlow(const ModelPart& mp); + std::vector mListOfSubModelParts; }; }// namespace Kratos. diff --git a/applications/DEMApplication/tests/test_DEM_2D_inlet.py b/applications/DEMApplication/tests/test_DEM_2D_inlet.py index ac64715fdb2f..2efca84610ce 100644 --- a/applications/DEMApplication/tests/test_DEM_2D_inlet.py +++ b/applications/DEMApplication/tests/test_DEM_2D_inlet.py @@ -48,7 +48,7 @@ def FinalizeSolutionStep(self): for node in self.spheres_model_part.Nodes: node_vel = node.GetSolutionStepValue(KratosMultiphysics.VELOCITY_Y) node_force = node.GetSolutionStepValue(KratosMultiphysics.TOTAL_FORCES_Y) - if node.Id == 7: + if node.Id == 6: if self.time >= 1.15: print(node_vel) print(node_force) From 111d0ce882a17e60f5a6987c7b7dd1e0ef8e8c52 Mon Sep 17 00:00:00 2001 From: Miguel Angel Date: Wed, 8 Apr 2020 23:09:17 +0200 Subject: [PATCH 125/314] leaving out the restart tests (tests taking too long) --- applications/DEMApplication/tests/test_DEMApplication.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/DEMApplication/tests/test_DEMApplication.py b/applications/DEMApplication/tests/test_DEMApplication.py index 0675def36456..2822eec4da38 100644 --- a/applications/DEMApplication/tests/test_DEMApplication.py +++ b/applications/DEMApplication/tests/test_DEMApplication.py @@ -57,8 +57,8 @@ def AssembleTestSuites(): smallSuite.addTest(test_DEM_3D_continuum.TestDEM3DContinuum("test_DEM3D_continuum")) - smallSuite.addTest(test_restart.TestRestartOneBall("test_execution")) - smallSuite.addTest(test_restart.TestRestartTwoBalls("test_execution")) + #smallSuite.addTest(test_restart.TestRestartOneBall("test_execution")) + #smallSuite.addTest(test_restart.TestRestartTwoBalls("test_execution")) # Create a test suit with the selected tests plus all small tests nightSuite = suites['nightly'] From 354ae3d7cb2e75845535a6e46619967d00bf49f8 Mon Sep 17 00:00:00 2001 From: Philipp Bucher Date: Thu, 9 Apr 2020 00:52:44 +0200 Subject: [PATCH 126/314] revert increasing of verbosity --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e9317d8853b..7d4cc2fcd95b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -142,4 +142,4 @@ jobs: run: | set PYTHONPATH=%PYTHONPATH%;%GITHUB_WORKSPACE%/bin/%KRATOS_BUILD_TYPE% set PATH=%PATH%;%GITHUB_WORKSPACE%/bin/%KRATOS_BUILD_TYPE%/libs - python kratos/python_scripts/run_tests.py -l small -c python -v 2 + python kratos/python_scripts/run_tests.py -l small -c python From 32b1ced294fa62ed27fc96d8c4aade31d35e5a6a Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Thu, 9 Apr 2020 09:05:20 +1000 Subject: [PATCH 127/314] [skip ci] change abs() to std::abs() --- .../custom_utilities/mpm_search_element_utility.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h b/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h index c86af2eb1f81..77aee2b7eb64 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h @@ -93,7 +93,7 @@ namespace MPMSearchElementUtility // check if MP is exactly on the edge of the element, this gives spurious strains in explicit bool isOnEdge = false; for (SizeType i = 0; i < N.size(); ++i) { - if (abs(N[i]) < std::numeric_limits::epsilon()) { + if (std::abs(N[i]) < std::numeric_limits::epsilon()) { isOnEdge = true; break; } From 083058c18a964b0ed31bf598d308bed499b61cf0 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Thu, 9 Apr 2020 09:10:37 +1000 Subject: [PATCH 128/314] [skip ci] remove scheme functions duplicate to baseclass --- .../schemes/mpm_explicit_scheme.hpp | 61 ------------------- 1 file changed, 61 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp index d79e52f4367c..952025147a3f 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp @@ -223,67 +223,6 @@ namespace Kratos { } } - - /** This is the place to initialize the elements. - This is intended to be called just once when the strategy is initialized */ - void InitializeElements(ModelPart& rModelPart) override - { - KRATOS_TRY - - int num_threads = OpenMPUtils::GetNumThreads(); - OpenMPUtils::PartitionVector element_partition; - OpenMPUtils::DivideInPartitions(rModelPart.Elements().size(), num_threads, element_partition); - - #pragma omp parallel - { - int k = OpenMPUtils::ThisThread(); - ElementsArrayType::iterator element_begin = rModelPart.Elements().begin() + element_partition[k]; - ElementsArrayType::iterator element_end = rModelPart.Elements().begin() + element_partition[k + 1]; - - for (ElementsArrayType::iterator itElem = element_begin; itElem != element_end; itElem++) - { - itElem->Initialize(); // function to initialize the element - } - } - - this->mElementsAreInitialized = true; - - KRATOS_CATCH("") - } - - //*************************************************************************** - //*************************************************************************** - - /** - This is the place to initialize the conditions. - This is intended to be called just once when the strategy is initialized - */ - void InitializeConditions(ModelPart& rModelPart) override - { - KRATOS_TRY - - KRATOS_ERROR_IF(this->mElementsAreInitialized == false) << "Before initilizing Conditions, initialize Elements FIRST" << std::endl; - - int num_threads = OpenMPUtils::GetNumThreads(); - OpenMPUtils::PartitionVector condition_partition; - OpenMPUtils::DivideInPartitions(rModelPart.Conditions().size(), num_threads, condition_partition); - - #pragma omp parallel - { - int k = OpenMPUtils::ThisThread(); - ConditionsArrayType::iterator condition_begin = rModelPart.Conditions().begin() + condition_partition[k]; - ConditionsArrayType::iterator condition_end = rModelPart.Conditions().begin() + condition_partition[k + 1]; - - for (ConditionsArrayType::iterator itCond = condition_begin; itCond != condition_end; itCond++) - { - itCond->Initialize(); // Function to initialize the condition - } - } - - this->mConditionsAreInitialized = true; - KRATOS_CATCH("") - } - //*************************************************************************** //*************************************************************************** From 2d6f6e027b2662347ce4dd9e592ac612325adffa Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Thu, 9 Apr 2020 13:29:51 +1000 Subject: [PATCH 129/314] [skip ci] update MP position from grid vel. update test results --- .../mpm_explicit_utilities.cpp | 26 ++++++++++++------- ...cit_oscillating_point_test_parameters.json | 4 +-- ...plicit_oscillating_point_test_results.json | 2 +- ..._point_Y_compressible_test_parameters.json | 4 +-- ...ing_point_Y_compressible_test_results.json | 2 +- ...llating_point_gravity_test_parameters.json | 4 +-- ...scillating_point_gravity_test_results.json | 2 +- ...cit_oscillating_point_test_parameters.json | 4 +-- ...plicit_oscillating_point_test_results.json | 2 +- ...cit_oscillating_point_test_parameters.json | 4 +-- ...plicit_oscillating_point_test_results.json | 2 +- ...cit_oscillating_point_test_parameters.json | 8 +++--- ...plicit_oscillating_point_test_results.json | 2 +- 13 files changed, 37 insertions(+), 29 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp index a2fdc6827a0d..319f0d563c50 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp @@ -92,21 +92,25 @@ namespace Kratos { KRATOS_TRY - const double& rDeltaTime = rCurrentProcessInfo[DELTA_TIME]; const bool& isCentralDifference = rCurrentProcessInfo.GetValue(IS_EXPLICIT_CENTRAL_DIFFERENCE); GeometryType& rGeom = rElement.GetGeometry(); const SizeType number_of_nodes = rGeom.PointsNumber(); const SizeType dimension = rGeom.WorkingSpaceDimension(); - bool isUpdateMPPositionFromUpdatedMPVelocity = true; // should normally be true. this reduces energy lost from kinematic aliasing - const ProcessInfo& rProcessInfo = ProcessInfo(); - // Update the MP Velocity + + // False for stability (typical across research papers). + // One may set to true to reduces energy lost from kinematic aliasing + bool isUpdateMPPositionFromUpdatedMPVelocity = false; + + + const ProcessInfo& rProcessInfo = ProcessInfo(); std::vector > MP_PreviousVelocity; std::vector > MP_PreviousAcceleration; array_1d MP_Velocity = ZeroVector(3); rElement.CalculateOnIntegrationPoints(MP_VELOCITY, MP_PreviousVelocity,rProcessInfo); rElement.CalculateOnIntegrationPoints(MP_ACCELERATION, MP_PreviousAcceleration, rProcessInfo); + const double gamma = (isCentralDifference) ? 0.5 : 1.0; // 0.5 for central difference, 1.0 for forward euler @@ -118,22 +122,27 @@ namespace Kratos MP_Velocity[i] = MP_PreviousVelocity[0][i] + (1.0 - gamma) * rDeltaTime * MP_PreviousAcceleration[0][i]; } + + // Calculate the MP displacement and acceleration for this timestep array_1d delta_xg = ZeroVector(3); array_1d MP_Acceleration = ZeroVector(3); - for (IndexType i = 0; i < number_of_nodes; i++) { const double nodal_mass = rGeom[i].FastGetSolutionStepValue(NODAL_MASS); - if (nodal_mass > std::numeric_limits::epsilon()) { const array_1d& r_nodal_momenta = rGeom[i].FastGetSolutionStepValue(NODAL_MOMENTUM); const array_1d& r_current_residual = rGeom[i].FastGetSolutionStepValue(FORCE_RESIDUAL); + + // Applicable to central difference only, the value in VELOCITY at the moment is actually the + // predicted (middle) grid velocity const array_1d& r_middle_velocity = rGeom[i].FastGetSolutionStepValue(VELOCITY); for (IndexType j = 0; j < dimension; j++) { + // Update MP acceleration regardless of explicit method MP_Acceleration[j] += rN[i] * r_current_residual[j] / nodal_mass; + if (isCentralDifference) { delta_xg[j] += rDeltaTime * rN[i] * r_middle_velocity[j]; @@ -157,8 +166,6 @@ namespace Kratos rElement.SetValuesOnIntegrationPoints(MP_VELOCITY, { MP_Velocity }, rProcessInfo); // Update the MP Position - std::vector > xg; - rElement.CalculateOnIntegrationPoints(MP_COORD, xg,rProcessInfo); if (isUpdateMPPositionFromUpdatedMPVelocity) { for (IndexType j = 0; j < dimension; j++) @@ -166,6 +173,8 @@ namespace Kratos delta_xg[j] = rDeltaTime * MP_Velocity[j]; } } + std::vector > xg; + rElement.CalculateOnIntegrationPoints(MP_COORD, xg, rProcessInfo); const array_1d& new_xg = xg[0] + delta_xg; rElement.SetValuesOnIntegrationPoints(MP_COORD, { new_xg }, rProcessInfo); @@ -206,7 +215,6 @@ namespace Kratos array_1d& r_current_velocity = rGeom[i].FastGetSolutionStepValue(VELOCITY); for (IndexType j = 0; j < dimension; j++) { - // we need to use the original shape functions here (calculated before the momenta update) r_current_velocity[j] += rN[i] * MP_Mass[0] * MP_Velocity[0][j] / r_nodal_mass; } } diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/central_difference_explicit_oscillating_point_test_parameters.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/central_difference_explicit_oscillating_point_test_parameters.json index 2f091746e11d..7b7413c07cfd 100644 --- a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/central_difference_explicit_oscillating_point_test_parameters.json +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/central_difference_explicit_oscillating_point_test_parameters.json @@ -72,7 +72,7 @@ "check_variables" : ["MP_VELOCITY","MP_DISPLACEMENT"], "input_file_name" : "explicit_tests/oscillating_point/central_difference_explicit_oscillating_point_test_results.json", "model_part_name" : "MPM_Material", - "time_frequency" : 0.5 + "time_frequency" : 0.05 } }] }, @@ -85,7 +85,7 @@ "gauss_points_output_variables" : ["MP_VELOCITY","MP_DISPLACEMENT"], "output_file_name" : "explicit_tests/oscillating_point/central_difference_explicit_oscillating_point_test_results.json", "model_part_name" : "MPM_Material", - "time_frequency" : 0.5 + "time_frequency" : 0.05 } }] } diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/central_difference_explicit_oscillating_point_test_results.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/central_difference_explicit_oscillating_point_test_results.json index c11026dd5585..c2cc9f660344 100644 --- a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/central_difference_explicit_oscillating_point_test_results.json +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/central_difference_explicit_oscillating_point_test_results.json @@ -1 +1 @@ -{"TIME": [0.5499999999999999], "PARTICLE_57": {"MP_VELOCITY_X": [-0.09465174631196166], "MP_VELOCITY_Y": [0.0], "MP_VELOCITY_Z": [0.0], "MP_DISPLACEMENT_X": [-0.002631334702967393], "MP_DISPLACEMENT_Y": [0.0], "MP_DISPLACEMENT_Z": [0.0]}} \ No newline at end of file +{"TIME": [0.1, 0.15000000000000002, 0.25, 0.35, 0.44999999999999996, 0.5499999999999999], "PARTICLE_57": {"MP_VELOCITY_X": [0.0807478366529913, 0.058460983466439215, -0.0006532389290301224, -0.05951593607317321, -0.09546242275669915, -0.09465174631196166], "MP_VELOCITY_Y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [0.00476452618942263, 0.006565659218831968, 0.008106714679452356, 0.0064997295237307785, 0.0023794739962015115, -0.002631334702967393], "MP_DISPLACEMENT_Y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}} \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test_parameters.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test_parameters.json index 00c5e0c5aeb0..76f66d9d9307 100644 --- a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test_parameters.json +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test_parameters.json @@ -72,7 +72,7 @@ "check_variables" : ["MP_VELOCITY","MP_DISPLACEMENT","MP_VOLUME"], "input_file_name" : "explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test_results.json", "model_part_name" : "MPM_Material", - "time_frequency" : 0.25 + "time_frequency" : 0.05 } }] }, @@ -85,7 +85,7 @@ "gauss_points_output_variables" : ["MP_VELOCITY","MP_DISPLACEMENT","MP_VOLUME"], "output_file_name" : "explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test_results.json", "model_part_name" : "MPM_Material", - "time_frequency" : 0.25 + "time_frequency" : 0.05 } }] } diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test_results.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test_results.json index b219ca99bc1d..610e9c56363d 100644 --- a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test_results.json +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test_results.json @@ -1 +1 @@ -{"TIME": [0.3], "PARTICLE_57": {"MP_VELOCITY_X": [0.0], "MP_VELOCITY_Y": [-0.04673422288768836], "MP_VELOCITY_Z": [0.0], "MP_DISPLACEMENT_X": [0.0], "MP_DISPLACEMENT_Y": [0.007950583089302025], "MP_DISPLACEMENT_Z": [0.0], "MP_VOLUME": [1.0153720903266241]}} \ No newline at end of file +{"TIME": [0.1, 0.15000000000000002, 0.25], "PARTICLE_57": {"MP_VELOCITY_X": [0.0, 0.0, 0.0], "MP_VELOCITY_Y": [0.07136527770707196, 0.04555668922580646, -0.01655831359778045], "MP_VELOCITY_Z": [0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [0.0, 0.0, 0.0], "MP_DISPLACEMENT_Y": [0.003330566196403541, 0.0038361530540934716, 0.002261999258417581], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0], "MP_VOLUME": [1.009529052378845, 1.0131313184376634, 1.0162134293589045]}} \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_gravity_test_parameters.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_gravity_test_parameters.json index aa913a3c9778..4916466d2808 100644 --- a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_gravity_test_parameters.json +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_gravity_test_parameters.json @@ -72,7 +72,7 @@ "check_variables" : ["MP_VELOCITY","MP_DISPLACEMENT"], "input_file_name" : "explicit_tests/oscillating_point/explicit_oscillating_point_gravity_test_results.json", "model_part_name" : "MPM_Material", - "time_frequency" : 0.5 + "time_frequency" : 0.05 } }] }, @@ -85,7 +85,7 @@ "gauss_points_output_variables" : ["MP_VELOCITY","MP_DISPLACEMENT"], "output_file_name" : "explicit_tests/oscillating_point/explicit_oscillating_point_gravity_test_results.json", "model_part_name" : "MPM_Material", - "time_frequency" : 0.5 + "time_frequency" : 0.05 } }] } diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_gravity_test_results.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_gravity_test_results.json index 01c8fce5e4a1..ad8352963947 100644 --- a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_gravity_test_results.json +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_gravity_test_results.json @@ -1 +1 @@ -{"TIME": [0.5499999999999999], "PARTICLE_57": {"MP_VELOCITY_X": [-0.022856844929611164], "MP_VELOCITY_Y": [0.0], "MP_VELOCITY_Z": [0.0], "MP_DISPLACEMENT_X": [0.024896886207813072], "MP_DISPLACEMENT_Y": [0.0], "MP_DISPLACEMENT_Z": [0.0]}} \ No newline at end of file +{"TIME": [0.1, 0.15000000000000002, 0.25, 0.35, 0.44999999999999996, 0.5499999999999999], "PARTICLE_57": {"MP_VELOCITY_X": [0.047595098899727656, 0.0655805656959943, 0.08130873429934196, 0.066141134020889, 0.025775019014031512, -0.024494164076803847], "MP_VELOCITY_Y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [0.0030063174449863825, 0.005102622556098812, 0.00950356523973283, 0.01279821909120219, 0.013716697500976314, 0.011882974685673741], "MP_DISPLACEMENT_Y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}} \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/musl_explicit_oscillating_point_test_parameters.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/musl_explicit_oscillating_point_test_parameters.json index de355dc56399..766dc39c854d 100644 --- a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/musl_explicit_oscillating_point_test_parameters.json +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/musl_explicit_oscillating_point_test_parameters.json @@ -72,7 +72,7 @@ "check_variables" : ["MP_VELOCITY","MP_DISPLACEMENT"], "input_file_name" : "explicit_tests/oscillating_point/musl_explicit_oscillating_point_test_results.json", "model_part_name" : "MPM_Material", - "time_frequency" : 0.5 + "time_frequency" : 0.05 } }] }, @@ -85,7 +85,7 @@ "gauss_points_output_variables" : ["MP_VELOCITY","MP_DISPLACEMENT"], "output_file_name" : "explicit_tests/oscillating_point/musl_explicit_oscillating_point_test_results.json", "model_part_name" : "MPM_Material", - "time_frequency" : 0.5 + "time_frequency" : 0.05 } }] } diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/musl_explicit_oscillating_point_test_results.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/musl_explicit_oscillating_point_test_results.json index 6023a1aa9154..77d8af0c8e49 100644 --- a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/musl_explicit_oscillating_point_test_results.json +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/musl_explicit_oscillating_point_test_results.json @@ -1 +1 @@ -{"TIME": [0.5499999999999999], "PARTICLE_57": {"MP_VELOCITY_X": [-0.09978366929917684], "MP_VELOCITY_Y": [0.0], "MP_VELOCITY_Z": [0.0], "MP_DISPLACEMENT_X": [-0.005199725114259626], "MP_DISPLACEMENT_Y": [0.0], "MP_DISPLACEMENT_Z": [0.0]}} \ No newline at end of file +{"TIME": [0.1, 0.15000000000000002, 0.25, 0.35, 0.44999999999999996, 0.5499999999999999], "PARTICLE_57": {"MP_VELOCITY_X": [0.09013039559891065, 0.07136527770707196, 0.015251835739720197, -0.046734222887688345, -0.09072558365651112, -0.09978366929917684], "MP_VELOCITY_Y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [0.004519019779945533, 0.0058543888273506536, 0.006007163391731251, 0.002875803435140294, -0.0023078088214195953, -0.0074981193533312195], "MP_DISPLACEMENT_Y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}} \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usf_explicit_oscillating_point_test_parameters.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usf_explicit_oscillating_point_test_parameters.json index db565f57254c..527b31faa423 100644 --- a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usf_explicit_oscillating_point_test_parameters.json +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usf_explicit_oscillating_point_test_parameters.json @@ -72,7 +72,7 @@ "check_variables" : ["MP_VELOCITY","MP_DISPLACEMENT"], "input_file_name" : "explicit_tests/oscillating_point/usf_explicit_oscillating_point_test_results.json", "model_part_name" : "MPM_Material", - "time_frequency" : 0.5 + "time_frequency" : 0.05 } }] }, @@ -85,7 +85,7 @@ "gauss_points_output_variables" : ["MP_VELOCITY","MP_DISPLACEMENT"], "output_file_name" : "explicit_tests/oscillating_point/usf_explicit_oscillating_point_test_results.json", "model_part_name" : "MPM_Material", - "time_frequency" : 0.5 + "time_frequency" : 0.05 } }] } diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usf_explicit_oscillating_point_test_results.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usf_explicit_oscillating_point_test_results.json index 404c3ae48a2a..debab71d670c 100644 --- a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usf_explicit_oscillating_point_test_results.json +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usf_explicit_oscillating_point_test_results.json @@ -1 +1 @@ -{"TIME": [0.5499999999999999], "PARTICLE_57": {"MP_VELOCITY_X": [-0.08951982332474648], "MP_VELOCITY_Y": [0.0], "MP_VELOCITY_Z": [0.0], "MP_DISPLACEMENT_X": [-0.014675716280496952], "MP_DISPLACEMENT_Y": [0.0], "MP_DISPLACEMENT_Z": [0.0]}} \ No newline at end of file +{"TIME": [0.1, 0.15000000000000002, 0.25, 0.35, 0.44999999999999996, 0.5499999999999999], "PARTICLE_57": {"MP_VELOCITY_X": [0.07136527770707196, 0.04555668922580646, -0.016558313597780438, -0.07229764925865806, -0.10019926185688716, -0.0895198233247465], "MP_VELOCITY_Y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [0.003330566196403541, 0.0038361530540934716, 0.0022619992584175823, -0.002109942025155003, -0.007551060827717633, -0.011928952620478358], "MP_DISPLACEMENT_Y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}} \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usl_explicit_oscillating_point_test_parameters.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usl_explicit_oscillating_point_test_parameters.json index c23819a9f872..466fae1eaaa6 100644 --- a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usl_explicit_oscillating_point_test_parameters.json +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usl_explicit_oscillating_point_test_parameters.json @@ -72,10 +72,9 @@ "check_variables" : ["MP_VELOCITY","MP_DISPLACEMENT"], "input_file_name" : "explicit_tests/oscillating_point/usl_explicit_oscillating_point_test_results.json", "model_part_name" : "MPM_Material", - "time_frequency" : 0.5 + "time_frequency" : 0.05 } - }] - }, + }], "print_output_process" : [{ "python_module" : "particle_json_output_process", "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", @@ -85,7 +84,8 @@ "gauss_points_output_variables" : ["MP_VELOCITY","MP_DISPLACEMENT"], "output_file_name" : "explicit_tests/oscillating_point/usl_explicit_oscillating_point_test_results.json", "model_part_name" : "MPM_Material", - "time_frequency" : 0.5 + "time_frequency" : 0.05 } }] + } } diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usl_explicit_oscillating_point_test_results.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usl_explicit_oscillating_point_test_results.json index 2d0b68e23e0f..4056e9b90c13 100644 --- a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usl_explicit_oscillating_point_test_results.json +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usl_explicit_oscillating_point_test_results.json @@ -1 +1 @@ -{"TIME": [0.5499999999999999], "PARTICLE_57": {"MP_VELOCITY_X": [-0.06125222201131185], "MP_VELOCITY_Y": [0.0], "MP_VELOCITY_Z": [0.0], "MP_DISPLACEMENT_X": [0.004083861091415111], "MP_DISPLACEMENT_Y": [0.0], "MP_DISPLACEMENT_Z": [0.0]}} \ No newline at end of file +{"TIME": [0.1, 0.15000000000000002, 0.25, 0.35, 0.44999999999999996, 0.5499999999999999], "PARTICLE_57": {"MP_VELOCITY_X": [0.09013039559891065, 0.07232967617054292, 0.02329184785168604, -0.025291152991195175, -0.05569790200616022, -0.06009696642306896], "MP_VELOCITY_Y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [0.004519019779945533, 0.005902608750524202, 0.006524336404820801, 0.004625690374115824, 0.0013723861258407599, -0.0017725791779102337], "MP_DISPLACEMENT_Y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}} \ No newline at end of file From 0090447ff541b370ef52be1d3406b1da26d57326 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Thu, 9 Apr 2020 13:52:58 +1000 Subject: [PATCH 130/314] restructure scheme finalizeSolutionStep --- .../schemes/mpm_explicit_scheme.hpp | 135 +++++++++--------- 1 file changed, 68 insertions(+), 67 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp index 952025147a3f..386f4dd2390b 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp @@ -206,21 +206,6 @@ namespace Kratos { r_nodal_momenta[j] += gamma * delta_time * r_current_residual[j]; } } // for DomainSize - - // We need to set updated grid velocity here if we are using the USL formulation - if (r_current_process_info.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 1) - { - array_1d& r_current_velocity = itCurrentNode->FastGetSolutionStepValue(VELOCITY); - r_current_velocity.clear(); - const double nodal_mass = itCurrentNode->FastGetSolutionStepValue(NODAL_MASS); - if (nodal_mass > numerical_limit) - { - for (IndexType j = 0; j < DomainSize; j++) - { - r_current_velocity[j] = r_nodal_momenta[j] / nodal_mass; - } // for DomainSize - } - } } //*************************************************************************** @@ -357,35 +342,34 @@ namespace Kratos { ElementsArrayType& rElements = rModelPart.Elements(); const ProcessInfo& rCurrentProcessInfo = rModelPart.GetProcessInfo(); - - const bool isMUSL = (rCurrentProcessInfo.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 2) - ? true - : false; - if (isMUSL) PerformModifiedUpdateStressLastMapping(rCurrentProcessInfo, rModelPart, rElements); - - const bool calculateMPStresses = ( - rCurrentProcessInfo.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 0 || - rCurrentProcessInfo.GetValue(IS_EXPLICIT_CENTRAL_DIFFERENCE)) - ? false - : true; - - // Definition of the first element iterator const auto it_elem_begin = rModelPart.ElementsBegin(); - // Finalizes solution step for all of the elements + + // map grid to MPs #pragma omp parallel for - for (int i = 0; i < static_cast(rElements.size()); ++i) { + for (int i = 0; i < static_cast(rElements.size()); ++i) + { auto it_elem = it_elem_begin + i; std::vector dummy; - - if (!isMUSL) it_elem->CalculateOnIntegrationPoints(EXPLICIT_MAP_GRID_TO_MP, dummy, rCurrentProcessInfo); - if (calculateMPStresses) it_elem->CalculateOnIntegrationPoints(CALCULATE_EXPLICIT_MP_STRESS, dummy, rCurrentProcessInfo); + it_elem->CalculateOnIntegrationPoints(EXPLICIT_MAP_GRID_TO_MP, dummy, rCurrentProcessInfo); } - // Definition of the first condition iterator - const auto it_cond_begin = rModelPart.ConditionsBegin(); + //update stress after momenta update for USL(1) and MUSL(2) + if (rCurrentProcessInfo.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) > 0) + { + this->CalculateUpdatedGridVelocityField(rCurrentProcessInfo, rModelPart); + + #pragma omp parallel for + for (int i = 0; i < static_cast(rElements.size()); ++i) + { + auto it_elem = it_elem_begin + i; + std::vector dummy; + it_elem->CalculateOnIntegrationPoints(CALCULATE_EXPLICIT_MP_STRESS, dummy, rCurrentProcessInfo); + } + } // Finalizes solution step for all of the conditions + const auto it_cond_begin = rModelPart.ConditionsBegin(); #pragma omp parallel for for (int i = 0; i < static_cast(rModelPart.Conditions().size()); ++i) { auto it_cond = it_cond_begin + i; @@ -394,45 +378,62 @@ namespace Kratos { KRATOS_CATCH("") } - //*************************************************************************** //*************************************************************************** - void PerformModifiedUpdateStressLastMapping(const ProcessInfo& rCurrentProcessInfo, ModelPart& rModelPart, ElementsArrayType& rElements) - { - // MUSL stress update. This works by projecting the updated particle - // velocity back to the nodes. The nodal velocity field is then - // used for stress computations. - - // Definition of the first element iterator - const auto it_elem_begin = rModelPart.ElementsBegin(); - - // Map grid results to MPs - #pragma omp parallel for - for (int i = 0; i < static_cast(rElements.size()); ++i) { - auto it_elem = it_elem_begin + i; - std::vector dummy; - it_elem->CalculateOnIntegrationPoints(EXPLICIT_MAP_GRID_TO_MP, dummy, rCurrentProcessInfo); - } - // Reset grid velocities - #pragma omp parallel for - for (int iter = 0; iter < static_cast(mr_grid_model_part.Nodes().size()); ++iter) + void CalculateUpdatedGridVelocityField(const ProcessInfo& rCurrentProcessInfo, ModelPart& rModelPart) + { + if (rCurrentProcessInfo.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 1) { - auto i = mr_grid_model_part.NodesBegin() + iter; - array_1d& nodal_velocity = (i)->FastGetSolutionStepValue(VELOCITY); - nodal_velocity.clear(); + // USL + const SizeType DomainSize = rCurrentProcessInfo[DOMAIN_SIZE]; + #pragma omp parallel for + for (int iter = 0; iter < static_cast(rModelPart.Nodes().size()); ++iter) + { + NodeIterator i = rModelPart.NodesBegin() + iter; + if ((i)->Is(ACTIVE)) + { + array_1d& r_nodal_momenta = (i)->FastGetSolutionStepValue(NODAL_MOMENTUM); + array_1d& r_current_velocity = i->FastGetSolutionStepValue(VELOCITY); + r_current_velocity.clear(); + const double nodal_mass = i->FastGetSolutionStepValue(NODAL_MASS); + if (nodal_mass > numerical_limit) + { + for (IndexType j = 0; j < DomainSize; j++) + { + r_current_velocity[j] = r_nodal_momenta[j] / nodal_mass; + } // for DomainSize + } + } + } } + else if (rCurrentProcessInfo.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 2) + { + // MUSL stress update. This works by projecting the updated particle + // velocity back to the nodes. The nodal velocity field is then + // used for stress computations. - // Map updated MP velocities back to grid - #pragma omp parallel for - for (int i = 0; i < static_cast(rElements.size()); ++i) { - auto it_elem = it_elem_begin + i; - std::vector dummy; - it_elem->CalculateOnIntegrationPoints(CALCULATE_MUSL_VELOCITY_FIELD, dummy, rCurrentProcessInfo); - } + // Reset grid velocities + #pragma omp parallel for + for (int iter = 0; iter < static_cast(rModelPart.Nodes().size()); ++iter) + { + auto i = rModelPart.NodesBegin() + iter; + array_1d& nodal_velocity = (i)->FastGetSolutionStepValue(VELOCITY); + nodal_velocity.clear(); + } - // Reapply dirichlet BCs to MUSL velocity field - calculateGridVelocityAndApplyDirichletBC(rCurrentProcessInfo); + // Map updated MP velocities back to grid + const auto it_elem_begin = rModelPart.ElementsBegin(); + #pragma omp parallel for + for (int i = 0; i < static_cast(rModelPart.Elements().size()); ++i) { + auto it_elem = it_elem_begin + i; + std::vector dummy; + it_elem->CalculateOnIntegrationPoints(CALCULATE_MUSL_VELOCITY_FIELD, dummy, rCurrentProcessInfo); + } + + // Reapply dirichlet BCs to MUSL velocity field + calculateGridVelocityAndApplyDirichletBC(rCurrentProcessInfo); + } } //*************************************************************************** From dd11c7ce4a87dace51fd2fe4bfe077015f613990 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Thu, 9 Apr 2020 09:21:49 +0200 Subject: [PATCH 131/314] fixing RANS --- ...exact_nodal_periodic_condition_process.cpp | 17 ------------ .../residual_based_bossak_velocity_scheme.h | 16 +++++------ .../test_rans_evm_k_epsilon_conditions.cpp | 27 +++++++++---------- 3 files changed, 20 insertions(+), 40 deletions(-) diff --git a/applications/RANSApplication/custom_processes/auxiliary_processes/rans_apply_exact_nodal_periodic_condition_process.cpp b/applications/RANSApplication/custom_processes/auxiliary_processes/rans_apply_exact_nodal_periodic_condition_process.cpp index c29f214eead2..cb4aff857452 100644 --- a/applications/RANSApplication/custom_processes/auxiliary_processes/rans_apply_exact_nodal_periodic_condition_process.cpp +++ b/applications/RANSApplication/custom_processes/auxiliary_processes/rans_apply_exact_nodal_periodic_condition_process.cpp @@ -126,15 +126,6 @@ int RansApplyExactNodalPeriodicConditionProcess::Check() RansCheckUtilities::CheckIfVariableExistsInModelPart( r_base_model_part_nodes, variable); } - else if (KratosComponents>>>::Has( - variable_name)) - { - const VariableComponent>>& variable = - KratosComponents>>>::Get( - variable_name); - RansCheckUtilities::CheckIfVariableExistsInModelPart( - r_base_model_part_nodes, variable.GetSourceVariable()); - } else { KRATOS_ERROR << "Variable " << variable_name << " not found.\n"; @@ -189,14 +180,6 @@ void RansApplyExactNodalPeriodicConditionProcess::CreatePeriodicConditions() KratosComponents>::Get(variable_name); p_properties->GetValue(PERIODIC_VARIABLES).Add(variable); } - else if (KratosComponents>>>::Has( - variable_name)) - { - const VariableComponent>>& variable = - KratosComponents>>>::Get( - variable_name); - p_properties->GetValue(PERIODIC_VARIABLES).Add(variable); - } else { KRATOS_ERROR << "Variable " << variable_name << " not found.\n"; diff --git a/applications/RANSApplication/custom_strategies/residual_based_bossak_velocity_scheme.h b/applications/RANSApplication/custom_strategies/residual_based_bossak_velocity_scheme.h index 251a9dbe69d8..a117f4c09dfd 100644 --- a/applications/RANSApplication/custom_strategies/residual_based_bossak_velocity_scheme.h +++ b/applications/RANSApplication/custom_strategies/residual_based_bossak_velocity_scheme.h @@ -76,9 +76,9 @@ class ResidualBasedBossakVelocityScheme : public Scheme const*> rDisplacementVariables, const std::vector const*> rVelocityVariables, const std::vector const*> rAccelerationVariables, - const std::vector>> const*> rDisplacementComponentVariables, - const std::vector>> const*> rVelocityComponentVariables, - const std::vector>> const*> rAccelerationComponentVariables) + const std::vector const*> rDisplacementComponentVariables, + const std::vector const*> rVelocityComponentVariables, + const std::vector const*> rAccelerationComponentVariables) : mAlphaBossak(AlphaBossak), mUpdateAcceleration(rAccelerationVariables.size() > 0 || rAccelerationComponentVariables.size() > 0), @@ -440,11 +440,11 @@ class ResidualBasedBossakVelocityScheme : public Scheme>(rModelPart, mVelocityVariables, mAccelerationVariables); - UpdateAcceleration>>>( + UpdateAcceleration>( rModelPart, mVelocityComponentVariables, mAccelerationComponentVariables); UpdateDisplacement>(rModelPart, mDisplacementVariables, mVelocityVariables, mAccelerationVariables); - UpdateDisplacement>>>( + UpdateDisplacement>( rModelPart, mDisplacementComponentVariables, mVelocityComponentVariables, mAccelerationComponentVariables); @@ -524,9 +524,9 @@ class ResidualBasedBossakVelocityScheme : public Scheme const*> mVelocityVariables; const std::vector const*> mAccelerationVariables; - const std::vector>> const*> mDisplacementComponentVariables; - const std::vector>> const*> mVelocityComponentVariables; - const std::vector>> const*> mAccelerationComponentVariables; + const std::vector const*> mDisplacementComponentVariables; + const std::vector const*> mVelocityComponentVariables; + const std::vector const*> mAccelerationComponentVariables; BossakConstants mBossak; diff --git a/applications/RANSApplication/tests/cpp/evm_k_epsilon/test_rans_evm_k_epsilon_conditions.cpp b/applications/RANSApplication/tests/cpp/evm_k_epsilon/test_rans_evm_k_epsilon_conditions.cpp index 05e521f19fe2..91692943f6c8 100644 --- a/applications/RANSApplication/tests/cpp/evm_k_epsilon/test_rans_evm_k_epsilon_conditions.cpp +++ b/applications/RANSApplication/tests/cpp/evm_k_epsilon/test_rans_evm_k_epsilon_conditions.cpp @@ -36,8 +36,8 @@ namespace Testing namespace { void CreateRansEvmKEpsilonUnitTestModelPart(const std::string& rConditionName, - const std::vector& rDofVariableNamesList, - ModelPart& rModelPart) + const std::vector& rDofVariableNamesList, + ModelPart& rModelPart) { const auto& r_proto = KratosComponents::Get(rConditionName); auto node_ids = std::vector{}; @@ -65,20 +65,17 @@ void CreateRansEvmKEpsilonUnitTestModelPart(const std::string& rConditionName, } else if (KratosComponents>>::Has(dof_variable_name)) { - const auto& r_variable_x = - KratosComponents>>>::Get( - dof_variable_name + "_X"); - const auto& r_variable_y = - KratosComponents>>>::Get( - dof_variable_name + "_Y"); + const auto& r_variable_x = KratosComponents>::Get( + dof_variable_name + "_X"); + const auto& r_variable_y = KratosComponents>::Get( + dof_variable_name + "_Y"); r_node.AddDof(r_variable_x).SetEquationId(r_node.Id() * 5); r_node.AddDof(r_variable_y).SetEquationId(r_node.Id() * 5); if (coords.size2() != 2) { - const auto& r_variable_z = - KratosComponents>>>::Get( - dof_variable_name + "_Z"); + const auto& r_variable_z = KratosComponents>::Get( + dof_variable_name + "_Z"); r_node.AddDof(r_variable_z).SetEquationId(r_node.Id() * 10); } } @@ -105,8 +102,8 @@ void RansEvmKEpsilonEpsilonWall2D2N_SetUp(ModelPart& rModelPart) rModelPart.AddNodalSolutionStepVariable(TURBULENT_KINETIC_ENERGY); rModelPart.AddNodalSolutionStepVariable(TURBULENT_ENERGY_DISSIPATION_RATE); rModelPart.AddNodalSolutionStepVariable(RANS_Y_PLUS); - CreateRansEvmKEpsilonUnitTestModelPart("RansEvmKEpsilonEpsilonWall2D2N", - {"TURBULENT_ENERGY_DISSIPATION_RATE"}, rModelPart); + CreateRansEvmKEpsilonUnitTestModelPart( + "RansEvmKEpsilonEpsilonWall2D2N", {"TURBULENT_ENERGY_DISSIPATION_RATE"}, rModelPart); } void RansEvmKEpsilonVmsMonolithicWall2D2N_SetUp(ModelPart& rModelPart) @@ -124,8 +121,8 @@ void RansEvmKEpsilonVmsMonolithicWall2D2N_SetUp(ModelPart& rModelPart) rModelPart.AddNodalSolutionStepVariable(TURBULENT_VISCOSITY); rModelPart.AddNodalSolutionStepVariable(TURBULENT_ENERGY_DISSIPATION_RATE); rModelPart.AddNodalSolutionStepVariable(VISCOSITY); - CreateRansEvmKEpsilonUnitTestModelPart("RansEvmKEpsilonVmsMonolithicWall2D2N", - {"VELOCITY", "PRESSURE"}, rModelPart); + CreateRansEvmKEpsilonUnitTestModelPart( + "RansEvmKEpsilonVmsMonolithicWall2D2N", {"VELOCITY", "PRESSURE"}, rModelPart); } void RansEvmKEpsilonEpsilonWall2D2N_AssignTestData(ModelPart& rModelPart) From 5d758917309d5a70972e0613a6664c3f2e35b6ba Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Thu, 9 Apr 2020 09:25:40 +0200 Subject: [PATCH 132/314] fixing HDF5 --- .../custom_io/hdf5_nodal_solution_step_bossak_io.cpp | 1 - .../custom_io/hdf5_nodal_solution_step_data_io.cpp | 2 -- 2 files changed, 3 deletions(-) diff --git a/applications/HDF5Application/custom_io/hdf5_nodal_solution_step_bossak_io.cpp b/applications/HDF5Application/custom_io/hdf5_nodal_solution_step_bossak_io.cpp index ceefb878d91b..f3078b77d6dd 100644 --- a/applications/HDF5Application/custom_io/hdf5_nodal_solution_step_bossak_io.cpp +++ b/applications/HDF5Application/custom_io/hdf5_nodal_solution_step_bossak_io.cpp @@ -37,7 +37,6 @@ void NodalSolutionStepBossakIO::WriteNodalResults(NodesContainerType const& rNod WriteInfo info; for (const std::string& r_name : VariableNames()) RegisteredComponentLookup>, - VariableComponent>>, Variable, Variable>(r_name) .Execute(local_nodes, GetFile(), prefix, mAlphaBossak, info); diff --git a/applications/HDF5Application/custom_io/hdf5_nodal_solution_step_data_io.cpp b/applications/HDF5Application/custom_io/hdf5_nodal_solution_step_data_io.cpp index 3759512f8f65..b5349a45961f 100644 --- a/applications/HDF5Application/custom_io/hdf5_nodal_solution_step_data_io.cpp +++ b/applications/HDF5Application/custom_io/hdf5_nodal_solution_step_data_io.cpp @@ -98,7 +98,6 @@ void NodalSolutionStepDataIO::WriteNodalResults(NodesContainerType const& rNodes // Write each variable. for (const std::string& r_variable_name : mVariableNames) RegisteredComponentLookup>, - VariableComponent>>, Variable, Variable>(r_variable_name) .Execute(local_nodes, Step, *mpFile, mPrefix, info); @@ -123,7 +122,6 @@ void NodalSolutionStepDataIO::ReadNodalResults(NodesContainerType& rNodes, Commu // Read local data for each variable. for (const std::string& r_variable_name : mVariableNames) RegisteredComponentLookup>, - VariableComponent>>, Variable, Variable>(r_variable_name) .Execute(local_nodes, Step, *mpFile, mPrefix, start_index, block_size); From 7292582911283f432522bd08ab5b668edacf8810 Mon Sep 17 00:00:00 2001 From: philbucher Date: Thu, 9 Apr 2020 11:32:28 +0200 Subject: [PATCH 133/314] adapt to changes --- .../python_scripts/coupling_interface_data.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/applications/CoSimulationApplication/python_scripts/coupling_interface_data.py b/applications/CoSimulationApplication/python_scripts/coupling_interface_data.py index 7850962520c3..474bfaf9dabf 100644 --- a/applications/CoSimulationApplication/python_scripts/coupling_interface_data.py +++ b/applications/CoSimulationApplication/python_scripts/coupling_interface_data.py @@ -47,7 +47,7 @@ def __init__(self, custom_settings, model, name="default", solver_name="default_ self.variable_type = KM.KratosGlobals.GetVariableType(variable_name) - admissible_scalar_variable_types = ["Bool", "Integer", "Unsigned Integer", "Double", "Component"] + admissible_scalar_variable_types = ["Bool", "Integer", "Unsigned Integer", "Double"] admissible_vector_variable_types = ["Array"] if not self.variable_type in admissible_scalar_variable_types and not self.variable_type in admissible_vector_variable_types: @@ -91,13 +91,8 @@ def Initialize(self): if domain_size != self.dimension: cs_tools.cs_print_warning('CouplingInterfaceData', '"DOMAIN_SIZE" ({}) of ModelPart "{}" does not match dimension ({})'.format(domain_size, self.model_part_name, self.dimension)) - if self.location == "node_historical": - if self.variable_type == "Component": - var_to_check = self.variable.GetSourceVariable() - else: - var_to_check = self.variable - if not self.model_part.HasNodalSolutionStepVariable(var_to_check): - self.__RaiseException('"{}" is missing as SolutionStepVariable in ModelPart "{}"'.format(var_to_check.Name(), self.model_part_name)) + if self.location == "node_historical" and not self.model_part.HasNodalSolutionStepVariable(self.variable): + self.__RaiseException('"{}" is missing as SolutionStepVariable in ModelPart "{}"'.format(self.variable.Name(), self.model_part_name)) self.is_initialized = True From 82cb88c95df2461c542ed11da232896f07012606 Mon Sep 17 00:00:00 2001 From: philbucher Date: Thu, 9 Apr 2020 11:32:32 +0200 Subject: [PATCH 134/314] add test --- .../tests/test_coupling_interface_data.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/applications/CoSimulationApplication/tests/test_coupling_interface_data.py b/applications/CoSimulationApplication/tests/test_coupling_interface_data.py index 4f38c43a977d..12aca37d9ca5 100644 --- a/applications/CoSimulationApplication/tests/test_coupling_interface_data.py +++ b/applications/CoSimulationApplication/tests/test_coupling_interface_data.py @@ -198,7 +198,7 @@ def test_wrong_input_variable_type(self): "variable_name" : "EXTERNAL_FORCES_VECTOR" }""") - exp_error = 'The input for "variable" "EXTERNAL_FORCES_VECTOR" is of variable type "Vector" which is not allowed, only the following variable types are allowed:\nBool, Integer, Unsigned Integer, Double, Component, Array' + exp_error = 'The input for "variable" "EXTERNAL_FORCES_VECTOR" is of variable type "Vector" which is not allowed, only the following variable types are allowed:\nBool, Integer, Unsigned Integer, Double, Array' with self.assertRaisesRegex(Exception, exp_error): CouplingInterfaceData(settings, self.model) @@ -276,7 +276,19 @@ def test_wrong_input_missing_solutionstepvar_component(self): "variable_name" : "FORCE_X" }""") - exp_error = '"FORCE" is missing as SolutionStepVariable in ModelPart "mp_4_test"' + exp_error = '"FORCE_X" is missing as SolutionStepVariable in ModelPart "mp_4_test"' + + coupling_data = CouplingInterfaceData(settings, self.model) + with self.assertRaisesRegex(Exception, exp_error): + coupling_data.Initialize() + + def test_wrong_input_missing_solutionstepvar_double(self): + settings = KM.Parameters("""{ + "model_part_name" : "mp_4_test", + "variable_name" : "TEMPERATURE" + }""") + + exp_error = '"TEMPERATURE" is missing as SolutionStepVariable in ModelPart "mp_4_test"' coupling_data = CouplingInterfaceData(settings, self.model) with self.assertRaisesRegex(Exception, exp_error): From 3d6196db1ab2de9452890b189583d6eba06a1886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Thu, 9 Apr 2020 13:14:51 +0200 Subject: [PATCH 135/314] Full initialize --- .../cpp_tests/sources/test_condition.cpp | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/kratos/tests/cpp_tests/sources/test_condition.cpp b/kratos/tests/cpp_tests/sources/test_condition.cpp index 321faaa4c8de..b59c71fdf2a6 100644 --- a/kratos/tests/cpp_tests/sources/test_condition.cpp +++ b/kratos/tests/cpp_tests/sources/test_condition.cpp @@ -16,12 +16,8 @@ #include "includes/model_part.h" #include "containers/model.h" - namespace Kratos { namespace Testing { - typedef Node<3> NodeType; - typedef std::size_t IndexType; - /** * Here the clone operator is test */ @@ -38,25 +34,20 @@ namespace Kratos { // Definition of properties auto p_prop = model_part.CreateNewProperties(1); - // List onf nodes - std::vector list_nodes(3); - list_nodes[0] = p_node1; - list_nodes[1] = p_node2; - list_nodes[2] = p_node3; - - auto p_cond = model_part.CreateNewCondition("SurfaceCondition3D3N", 1, PointerVector{list_nodes}, p_prop); + auto p_cond = model_part.CreateNewCondition("SurfaceCondition3D3N", 1, {{1, 2, 3}}, p_prop); p_cond->SetValue(DISTANCE, 12.1); + p_cond->SetValue(VELOCITY, ZeroVector(3)); p_cond->SetValue(VELOCITY_X, 32.4); p_cond->Set(ACTIVE, true); - Condition::Pointer p_clone_of_cond = p_cond->Clone(2, PointerVector{list_nodes}); + Condition::Pointer p_clone_of_cond = p_cond->Clone(2, p_cond->GetGeometry()); KRATOS_CHECK_EQUAL(p_clone_of_cond->Id(), 2); KRATOS_CHECK_DOUBLE_EQUAL(p_clone_of_cond->GetValue(DISTANCE), 12.1); KRATOS_CHECK_DOUBLE_EQUAL(p_clone_of_cond->GetValue(VELOCITY_X), 32.4); - KRATOS_CHECK_DOUBLE_EQUAL(p_clone_of_cond->GetValue(VELOCITY_Y), 0.00); - KRATOS_CHECK_DOUBLE_EQUAL(p_clone_of_cond->GetValue(VELOCITY_Z), 0.00); + KRATOS_CHECK_DOUBLE_EQUAL(p_clone_of_cond->GetValue(VELOCITY_Y), 0.0); + KRATOS_CHECK_DOUBLE_EQUAL(p_clone_of_cond->GetValue(VELOCITY_Z), 0.0); KRATOS_CHECK(p_clone_of_cond->Is(ACTIVE)); } } // namespace Testing. From 4485f09263b83e256c8e2aabb0b87a2359ea079c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Thu, 9 Apr 2020 16:03:23 +0200 Subject: [PATCH 136/314] Proposal to solve issue @pooyan-dadvand check this --- kratos/containers/data_value_container.h | 32 +++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/kratos/containers/data_value_container.h b/kratos/containers/data_value_container.h index 512781081510..418197ce51ff 100644 --- a/kratos/containers/data_value_container.h +++ b/kratos/containers/data_value_container.h @@ -261,10 +261,36 @@ class KRATOS_API(KRATOS_CORE) DataValueContainer #endif typename ContainerType::iterator i; - if ((i = std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.SourceKey()))) != mData.end()) + if ((i = std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.SourceKey()))) != mData.end()) { *(static_cast(i->second) + rThisVariable.GetComponentIndex()) = rValue; - else - mData.push_back(ValueType(&rThisVariable,new TDataType(rValue))); + } else { + if (rThisVariable.IsComponent()) { + const auto& r_source_variable_data = rThisVariable.GetSourceVariable(); + const auto& r_source_variable_data_name = r_source_variable_data.Name(); + if (KratosComponents >>::Has(r_source_variable_data_name)) { + const auto& r_source_variable = KratosComponents>>::Get(r_source_variable_data_name); + this->SetValue(r_source_variable, r_source_variable.Zero()); + } else if (KratosComponents >>::Has(r_source_variable_data_name)) { + const auto& r_source_variable = KratosComponents>>::Get(r_source_variable_data_name); + this->SetValue(r_source_variable, r_source_variable.Zero()); + } else if (KratosComponents >>::Has(r_source_variable_data_name)) { + const auto& r_source_variable = KratosComponents>>::Get(r_source_variable_data_name); + this->SetValue(r_source_variable, r_source_variable.Zero()); + } else if (KratosComponents >>::Has(r_source_variable_data_name)) { + const auto& r_source_variable = KratosComponents>>::Get(r_source_variable_data_name); + this->SetValue(r_source_variable, r_source_variable.Zero()); + } else { + KRATOS_ERROR << "Variable for component" << rThisVariable.Name() << " not found" << std::endl; + } + if ((i = std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.SourceKey()))) != mData.end()) { + *(static_cast(i->second) + rThisVariable.GetComponentIndex()) = rValue; + } else { + KRATOS_ERROR << "All components of " << r_source_variable_data.Name() << " should have been initialized, something went wrong" << std::endl; + } + } else { + mData.push_back(ValueType(&rThisVariable,new TDataType(rValue))); + } + } } template void SetValue(const VariableComponent& rThisVariable, typename TAdaptorType::Type const& rValue) From 5d7ffbfef420cfa3788bbcf1553a6aabeaf573aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Thu, 9 Apr 2020 16:03:31 +0200 Subject: [PATCH 137/314] Test --- .../containers/test_data_value_container.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/kratos/tests/cpp_tests/containers/test_data_value_container.cpp b/kratos/tests/cpp_tests/containers/test_data_value_container.cpp index 2590b5e51906..624f44259248 100644 --- a/kratos/tests/cpp_tests/containers/test_data_value_container.cpp +++ b/kratos/tests/cpp_tests/containers/test_data_value_container.cpp @@ -54,6 +54,24 @@ KRATOS_TEST_CASE_IN_SUITE(DataValueContainerHasComponent, KratosCoreFastSuite) { KRATOS_CHECK(container.Has(DISPLACEMENT_Z)); } +KRATOS_TEST_CASE_IN_SUITE(DataValueContainerSetComponentCheck, KratosCoreFastSuite) { + DataValueContainer container; + + KRATOS_CHECK_IS_FALSE(container.Has(DISPLACEMENT_X)); + KRATOS_CHECK_IS_FALSE(container.Has(DISPLACEMENT_Y)); + KRATOS_CHECK_IS_FALSE(container.Has(DISPLACEMENT_Z)); + + container.SetValue(DISPLACEMENT_X, 10.0); + + KRATOS_CHECK(container.Has(DISPLACEMENT_X)); + KRATOS_CHECK(container.Has(DISPLACEMENT_Y)); + KRATOS_CHECK(container.Has(DISPLACEMENT_Z)); + + KRATOS_CHECK_EQUAL(container.GetValue(DISPLACEMENT_X), 10.0); + KRATOS_CHECK_EQUAL(container.GetValue(DISPLACEMENT_Y), 0.0); + KRATOS_CHECK_EQUAL(container.GetValue(DISPLACEMENT_Z), 0.0); +} + KRATOS_TEST_CASE_IN_SUITE(DataValueContainer, KratosCoreFastSuite) { DataValueContainer container; Vector original_distances(4); From 09b7dafb4d69c8330aa104bc54fb16af46da9c30 Mon Sep 17 00:00:00 2001 From: pooyan Date: Thu, 9 Apr 2020 16:32:51 +0200 Subject: [PATCH 138/314] Fixing data value container component initializing --- kratos/containers/data_value_container.h | 10 +++++++--- kratos/containers/variable.h | 4 ++++ kratos/containers/variable_data.h | 5 ++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/kratos/containers/data_value_container.h b/kratos/containers/data_value_container.h index 512781081510..88211a2aadfd 100644 --- a/kratos/containers/data_value_container.h +++ b/kratos/containers/data_value_container.h @@ -219,7 +219,8 @@ class KRATOS_API(KRATOS_CORE) DataValueContainer KRATOS_ERROR << "attempting to do a GetValue for: " << rThisVariable << " unfortunately the variable is not in the database and the operations is not threadsafe (this function is being called from within a parallel region)" << std::endl; #endif - mData.push_back(ValueType(&rThisVariable,new TDataType(rThisVariable.Zero()))); + auto p_source_variable = &rThisVariable.GetSourceVariable(); + mData.push_back(ValueType(p_source_variable,p_source_variable->Clone(p_source_variable->pZero()))); return *(static_cast(mData.back().second) + rThisVariable.GetComponentIndex()); } @@ -263,8 +264,11 @@ class KRATOS_API(KRATOS_CORE) DataValueContainer if ((i = std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.SourceKey()))) != mData.end()) *(static_cast(i->second) + rThisVariable.GetComponentIndex()) = rValue; - else - mData.push_back(ValueType(&rThisVariable,new TDataType(rValue))); + else{ + auto p_source_variable = &rThisVariable.GetSourceVariable(); + mData.push_back(ValueType(p_source_variable,p_source_variable->Clone(p_source_variable->pZero()))); + *(static_cast(mData.back().second) + rThisVariable.GetComponentIndex()) = rValue; + } } template void SetValue(const VariableComponent& rThisVariable, typename TAdaptorType::Type const& rValue) diff --git a/kratos/containers/variable.h b/kratos/containers/variable.h index cf765bfed396..1d728279a69d 100644 --- a/kratos/containers/variable.h +++ b/kratos/containers/variable.h @@ -348,6 +348,10 @@ class Variable : public VariableData return mZero; } + const void* pZero() const override { + return &mZero; + } + ///@} ///@name Inquiry ///@{ diff --git a/kratos/containers/variable_data.h b/kratos/containers/variable_data.h index e82d69f3c3fa..080d120bbbd1 100644 --- a/kratos/containers/variable_data.h +++ b/kratos/containers/variable_data.h @@ -231,11 +231,14 @@ class KRATOS_API(KRATOS_CORE) VariableData const VariableData& GetSourceVariable() const { - KRATOS_DEBUG_ERROR_IF(IsNotComponent()) << "The source variable is only defined for components" << std::endl; KRATOS_DEBUG_ERROR_IF(mpSourceVariable == nullptr) << "No source variable is defined for the component" << std::endl; return *mpSourceVariable; } + virtual const void* pZero() const { + KRATOS_ERROR << "Calling base class method." << std::endl; + } + ///@} ///@name Inquiry From 85bc20d1af4239fb32500283b138a86799f45439 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Thu, 9 Apr 2020 16:42:13 +0200 Subject: [PATCH 139/314] Update data_value_container.h --- kratos/containers/data_value_container.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kratos/containers/data_value_container.h b/kratos/containers/data_value_container.h index 1a5ec11fadff..a4b207ed00e4 100644 --- a/kratos/containers/data_value_container.h +++ b/kratos/containers/data_value_container.h @@ -264,7 +264,7 @@ class KRATOS_API(KRATOS_CORE) DataValueContainer if ((i = std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.SourceKey()))) != mData.end()) { *(static_cast(i->second) + rThisVariable.GetComponentIndex()) = rValue; - else{ + } else { auto p_source_variable = &rThisVariable.GetSourceVariable(); mData.push_back(ValueType(p_source_variable,p_source_variable->Clone(p_source_variable->pZero()))); *(static_cast(mData.back().second) + rThisVariable.GetComponentIndex()) = rValue; From 65367989bf453b9828cda01466edc06274171854 Mon Sep 17 00:00:00 2001 From: pooyan Date: Thu, 9 Apr 2020 17:00:45 +0200 Subject: [PATCH 140/314] Fixing variables list add --- kratos/containers/variables_list.h | 1 + 1 file changed, 1 insertion(+) diff --git a/kratos/containers/variables_list.h b/kratos/containers/variables_list.h index 19286fc5f48c..f99ee51cccb5 100644 --- a/kratos/containers/variables_list.h +++ b/kratos/containers/variables_list.h @@ -273,6 +273,7 @@ namespace Kratos if(ThisVariable.IsComponent()){ Add(ThisVariable.GetSourceVariable()); + return; } mVariables.push_back(&ThisVariable); From c6ff757c34f13f8908aeaa752a7038b422683002 Mon Sep 17 00:00:00 2001 From: pooyan Date: Thu, 9 Apr 2020 17:01:14 +0200 Subject: [PATCH 141/314] Adding test for data value container component add --- .../containers/test_data_value_container.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kratos/tests/cpp_tests/containers/test_data_value_container.cpp b/kratos/tests/cpp_tests/containers/test_data_value_container.cpp index 2590b5e51906..190262ccc7cd 100644 --- a/kratos/tests/cpp_tests/containers/test_data_value_container.cpp +++ b/kratos/tests/cpp_tests/containers/test_data_value_container.cpp @@ -80,6 +80,17 @@ KRATOS_TEST_CASE_IN_SUITE(DataValueContainerComponent, KratosCoreFastSuite) { KRATOS_CHECK_EQUAL(container.GetValue(VELOCITY_X), original_velocity[0]); KRATOS_CHECK_EQUAL(container.GetValue(VELOCITY_Y), original_velocity[1]); KRATOS_CHECK_EQUAL(container.GetValue(VELOCITY_Z), original_velocity[2]); + + container.SetValue(DISPLACEMENT_Y, 1.23); + + KRATOS_CHECK_EQUAL(container.GetValue(VELOCITY_X), original_velocity[0]); + KRATOS_CHECK_EQUAL(container.GetValue(VELOCITY_Y), original_velocity[1]); + KRATOS_CHECK_EQUAL(container.GetValue(VELOCITY_Z), original_velocity[2]); + + KRATOS_CHECK_EQUAL(container.GetValue(DISPLACEMENT_X), 0.00); + KRATOS_CHECK_EQUAL(container.GetValue(DISPLACEMENT_Y), 1.23); + KRATOS_CHECK_EQUAL(container.GetValue(DISPLACEMENT_Z), 0.00); + } KRATOS_TEST_CASE_IN_SUITE(DataValueContainerMerge, KratosCoreFastSuite) { From 9223a3229c0cda2866dbbb3dfccf7d124a0625e6 Mon Sep 17 00:00:00 2001 From: pooyan Date: Thu, 9 Apr 2020 17:02:41 +0200 Subject: [PATCH 142/314] Adding test for add component to variable list container --- .../test_variables_list_data_value_container.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/kratos/tests/cpp_tests/containers/test_variables_list_data_value_container.cpp b/kratos/tests/cpp_tests/containers/test_variables_list_data_value_container.cpp index 81ac0cdea598..90f535b8d732 100644 --- a/kratos/tests/cpp_tests/containers/test_variables_list_data_value_container.cpp +++ b/kratos/tests/cpp_tests/containers/test_variables_list_data_value_container.cpp @@ -64,6 +64,22 @@ KRATOS_TEST_CASE_IN_SUITE(VariablesListDataValueContainerGetValue, KratosCoreFas KRATOS_CHECK_EQUAL(distances[i], original_distances[i]); } +KRATOS_TEST_CASE_IN_SUITE(VariablesListDataValueContainerAddComponent, KratosCoreFastSuite) { + VariablesList::Pointer p_variables_list=Kratos::make_intrusive(); + p_variables_list->Add(VELOCITY_Y); + VariablesListDataValueContainer container(p_variables_list); + array_1d original_velocity; + original_velocity[0] = 0.00; + original_velocity[1] = 0.10; + original_velocity[2] = 0.20; + + container.SetValue(VELOCITY, original_velocity); + + KRATOS_CHECK_EQUAL(container.GetValue(VELOCITY_X), original_velocity[0]); + KRATOS_CHECK_EQUAL(container.GetValue(VELOCITY_Y), original_velocity[1]); + KRATOS_CHECK_EQUAL(container.GetValue(VELOCITY_Z), original_velocity[2]); +} + KRATOS_TEST_CASE_IN_SUITE(VariablesListDataValueContainerGetComponentValue, KratosCoreFastSuite) { VariablesList::Pointer p_variables_list=Kratos::make_intrusive(); p_variables_list->Add(VELOCITY); From fbe63a476d5d0100296c355059f7cdac99e29aab Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Thu, 9 Apr 2020 17:36:45 +0200 Subject: [PATCH 143/314] add cfl_output_process test --- .../tests/Cavity/cfl_output_process_ref.dat | 7 ++ .../Cavity/cfl_output_test_parameters.json | 112 ++++++++++++++++++ .../tests/cfl_output_process_test.py | 67 +++++++++++ 3 files changed, 186 insertions(+) create mode 100644 applications/FluidDynamicsApplication/tests/Cavity/cfl_output_process_ref.dat create mode 100644 applications/FluidDynamicsApplication/tests/Cavity/cfl_output_test_parameters.json create mode 100644 applications/FluidDynamicsApplication/tests/cfl_output_process_test.py diff --git a/applications/FluidDynamicsApplication/tests/Cavity/cfl_output_process_ref.dat b/applications/FluidDynamicsApplication/tests/Cavity/cfl_output_process_ref.dat new file mode 100644 index 000000000000..30a9c2a15315 --- /dev/null +++ b/applications/FluidDynamicsApplication/tests/Cavity/cfl_output_process_ref.dat @@ -0,0 +1,7 @@ +# CFL for model part MainModelPart.Parts_Fluid| CFL_threshold: 2.5 +# Time Mean Std Max HowMany>2.5 [%] HowMany>1.0 [%] +0.2 0.41451852 0.43025031 2.68266667 10.00000000 20.00000000 +0.4 0.51840000 0.43905635 5.69066667 20.00000000 32.00000000 +0.6 0.61621053 0.59766605 9.02400000 24.00000000 36.00000000 +0.7999999999999999 0.54400000 0.54527187 12.16000000 30.00000000 46.00000000 +0.9999999999999999 0.60380952 0.68235326 15.20000000 30.00000000 48.00000000 diff --git a/applications/FluidDynamicsApplication/tests/Cavity/cfl_output_test_parameters.json b/applications/FluidDynamicsApplication/tests/Cavity/cfl_output_test_parameters.json new file mode 100644 index 000000000000..788fe21de021 --- /dev/null +++ b/applications/FluidDynamicsApplication/tests/Cavity/cfl_output_test_parameters.json @@ -0,0 +1,112 @@ +{ + "problem_data" : { + "problem_name" : "cavity5", + "parallel_type" : "OpenMP", + "echo_level" : 0, + "start_time" : 0.0, + "end_time" : 1.0 + }, + "restart_options" : { + "SaveRestart" : "False", + "RestartFrequency" : 0, + "LoadRestart" : "False", + "Restart_Step" : 0 + }, + "solver_settings" : { + "solver_type": "Monolithic", + "model_part_name": "MainModelPart", + "domain_size": 2, + "model_import_settings" : { + "input_type" : "mdpa", + "input_filename" : "square5" + }, + "material_import_settings": { + "materials_filename": "cavity_test_materials.json" + }, + "echo_level" : 0, + "compute_reactions" : false, + "maximum_iterations" : 1000, + "formulation" : { + "element_type" : "qsvms", + "use_orthogonal_subscales": false, + "dynamic_tau" : 0.0 + }, + "relative_velocity_tolerance" : 1e-6, + "absolute_velocity_tolerance" : 1e-6, + "relative_pressure_tolerance" : 1e-6, + "absolute_pressure_tolerance" : 1e-6, + "linear_solver_settings" : { + "solver_type" : "amgcl", + "max_iteration" : 200, + "tolerance" : 1e-9, + "provide_coordinates" : false, + "smoother_type" : "ilu0", + "krylov_type" : "gmres", + "coarsening_type" : "aggregation", + "scaling" : false + }, + "volume_model_part_name" : "Parts_Fluid", + "skin_parts" : ["NoSlip2D_left_wall","NoSlip2D_right_wall","NoSlip2D_bottom_wall","NoSlip2D_top_wall"], + "no_skin_parts" : ["Pressure_lower_left_corner"], + "time_stepping" : { + "automatic_time_step" : false, + "time_step" : 0.1 + } + }, + "processes": { + "initial_conditions_process_list" : [], + "boundary_conditions_process_list" : [{ + "python_module" : "assign_vector_variable_process", + "kratos_module" : "KratosMultiphysics", + "help" : "This process fixes the selected components of a given vector variable", + "process_name" : "AssignVectorVariableProcess", + "Parameters" : { + "model_part_name" : "MainModelPart.Parts_Fluid", + "variable_name" : "VELOCITY", + "constrained" : [false,false,false], + "value" : ["5*t*t*x*y-3*t*x","-20*t*x*x", "t*y*30*y"], + "interval" : [0.0,"End"] + } + },{ + "python_module" : "assign_scalar_variable_process", + "kratos_module" : "KratosMultiphysics", + "process_name" : "AssignScalarVariableProcess", + "Parameters" : { + "model_part_name" : "MainModelPart.Parts_Fluid", + "variable_name" : "PRESSURE", + "value" : "t*t+2", + "constrained" : false + } + }], + "gravity" : [], + "auxiliar_process_list" : [{ + "kratos_module" : "KratosMultiphysics.FluidDynamicsApplication", + "python_module" : "cfl_output_process", + "help" : "", + "Parameters" : { + "model_part_name" : "MainModelPart.Parts_Fluid", + "interval" : [0.0, 1e30], + "cfl_output_limit" : 2.5, + "print_to_screen" : false, + "print_format" : ".8f", + "write_output_file" : true, + "output_step" : 2, + "output_file_settings": { + "file_name": "cfl_output_process.dat" + } + } + },{ + "python_module" : "compare_two_files_check_process", + "kratos_module" : "KratosMultiphysics", + "help" : "", + "process_name" : "CompareTwoFilesCheckProcess", + "Parameters" :{ + "output_file_name" : "cfl_output_process.dat", + "reference_file_name" : "cfl_output_process_ref.dat", + "comparison_type" : "deterministic", + "remove_output_file" : true, + "tolerance" : 1e-5 + } + }] + } +} diff --git a/applications/FluidDynamicsApplication/tests/cfl_output_process_test.py b/applications/FluidDynamicsApplication/tests/cfl_output_process_test.py new file mode 100644 index 000000000000..cf33765d980c --- /dev/null +++ b/applications/FluidDynamicsApplication/tests/cfl_output_process_test.py @@ -0,0 +1,67 @@ +import KratosMultiphysics as km +import KratosMultiphysics.FluidDynamicsApplication as kfd + +from fluid_analysis_without_solution import FluidAnalysisWithoutSolution + +import KratosMultiphysics.KratosUnittest as UnitTest +import KratosMultiphysics.kratos_utilities as kratos_utilities + +class CFLOutputProcessTest(UnitTest.TestCase): + + def setUp(self): + # Set to true to get post-process files for the test + self.print_output = True + + def testCFLOutput(self): + work_folder = "Cavity" + settings_file_name = "cfl_output_test_parameters.json" + + with UnitTest.WorkFolderScope(work_folder, __file__): + self._runTest(settings_file_name) + + kratos_utilities.DeleteFileIfExisting("square5.time") + + def _runTest(self,settings_file_name): + model = km.Model() + with open(settings_file_name,'r') as settings_file: + settings = km.Parameters(settings_file.read()) + + # to check the results: add output settings block if needed + if self.print_output: + settings.AddValue("output_processes", km.Parameters(r'''{ + "gid_output" : [{ + "python_module" : "gid_output_process", + "kratos_module" : "KratosMultiphysics", + "process_name" : "GiDOutputProcess", + "Parameters" : { + "model_part_name" : "MainModelPart.fluid_computational_model_part", + "output_name" : "cavity", + "postprocess_parameters" : { + "result_file_configuration" : { + "gidpost_flags" : { + "GiDPostMode" : "GiD_PostBinary", + "WriteDeformedMeshFlag" : "WriteDeformed", + "WriteConditionsFlag" : "WriteConditions", + "MultiFileFlag" : "SingleFile" + }, + "file_label" : "time", + "output_control_type" : "step", + "output_frequency" : 1, + "body_output" : true, + "node_output" : false, + "skin_output" : false, + "plane_output" : [], + "nodal_results" : ["VELOCITY","PRESSURE"], + "gauss_point_results" : [] + }, + "point_data_configuration" : [] + } + } + }] + }''')) + + analysis = FluidAnalysisWithoutSolution(model,settings) + analysis.Run() + +if __name__ == '__main__': + UnitTest.main() From e9865ad880f9a2e8ac76e0a2fb8b6753300a07ea Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Thu, 9 Apr 2020 17:40:42 +0200 Subject: [PATCH 144/314] minor fix --- .../python_scripts/cfl_output_process.py | 74 +++++++++++-------- 1 file changed, 43 insertions(+), 31 deletions(-) diff --git a/applications/FluidDynamicsApplication/python_scripts/cfl_output_process.py b/applications/FluidDynamicsApplication/python_scripts/cfl_output_process.py index d761d6848514..d7e7e4f4f8fb 100755 --- a/applications/FluidDynamicsApplication/python_scripts/cfl_output_process.py +++ b/applications/FluidDynamicsApplication/python_scripts/cfl_output_process.py @@ -1,11 +1,20 @@ # Importing the Kratos Library import KratosMultiphysics import KratosMultiphysics.FluidDynamicsApplication as KratosCFD +from KratosMultiphysics.kratos_utilities import CheckIfApplicationsAvailable # other imports from KratosMultiphysics.time_based_ascii_file_writer_utility import TimeBasedAsciiFileWriterUtility +if CheckIfApplicationsAvailable("StatisticsApplication"): + from KratosMultiphysics.StatisticsApplication import SpatialMethods as spatial_methods +else: + msg = "CFLOutputProcess requires StatisticsApplication which is not found." + msg += " Please install/compile it and try again." + raise Exception(msg) + from statistics import mean, stdev +import math def Factory(settings, model): @@ -37,7 +46,7 @@ def __init__(self, model, params): } """) - + # Detect "End" as a tag and replace it by a large number if(params.Has("interval")): if(params["interval"][1].IsString()): @@ -61,6 +70,11 @@ def __init__(self, model, params): # getting output limit for summarization self.cfl_output_limit = params["cfl_output_limit"].GetDouble() + # TODO: Is it ok to do this check? If not, distribution calculation is going to be messy with if conditions for + # case with cfl_output_limit <= 1.0 + if (self.cfl_output_limit <= 1.0): + raise Exception("Please provide cfl_output_limit greater than 1.0") + self.format = params["print_format"].GetString() self.output_step = params["output_step"].GetInt() self.print_to_screen = params["print_to_screen"].GetBool() @@ -75,16 +89,24 @@ def __init__(self, model, params): self.output_file = TimeBasedAsciiFileWriterUtility(self.model_part, file_handler_params, file_header).file + self.distribution_params = KratosMultiphysics.Parameters('''{ + "number_of_value_groups" : 1, + "min_value" : "min", + "max_value" : "max" + }''') + self.distribution_params["min_value"].SetDouble(min(self.cfl_output_limit, 1.0)) + self.distribution_params["max_value"].SetDouble(max(self.cfl_output_limit, 1.0)) + def ExecuteFinalizeSolutionStep(self): current_time = self.model_part.ProcessInfo[KratosMultiphysics.TIME] current_step = self.model_part.ProcessInfo[KratosMultiphysics.STEP] if((current_time >= self.interval[0]) and (current_time < self.interval[1])) and (current_step % self.output_step == 0): - cfl_value = self._EvaluateCFL() + self._EvaluateCFL() + output = self._CalculateWithRespectToThreshold() if (self.model_part.GetCommunicator().MyPID() == 0): - output = self._SummarizeCFL(cfl_value) output_vals = [format(val, self.format) for val in output] # not formatting time in order to not lead to problems with time recognition @@ -122,45 +144,35 @@ def _PrintToScreen(self, result_msg): KratosMultiphysics.Logger.PrintInfo( "CFLOutputProcess", "Current time: " + result_msg) - def _CalculateWithRespectToThreshold(self, x): + def _CalculateWithRespectToThreshold(self): + current_container = spatial_methods.NonHistorical.Elements.NormMethods + + _, _, _, group_histogram, group_percentage_distribution, group_means, group_variances = current_container.Distribution( + self.model_part, KratosMultiphysics.CFL_NUMBER, "value", self.distribution_params) - y = [val for val in x if val < self.cfl_output_limit] - y1 = [val for val in x if val < 1.0] # % of element with cfl above threshold - how_many = ((len(x)-len(y))/len(x))*100 + how_many = group_percentage_distribution[-1]*100.0 # % of element with cfl above 1 - how_many1 = ((len(x)-len(y1))/len(x))*100 + how_many1 = (1.0 - group_percentage_distribution[0])*100.0 # quantifying the mean and std for values below the threshold - y_mean = mean(y) - y_std = stdev(y) + total_elements_in_threshold_range = group_histogram[0] + group_histogram[1] + if (total_elements_in_threshold_range > 0): + y_mean = (group_means[0] * group_histogram[0] + group_means[1] * group_histogram[1]) / total_elements_in_threshold_range + + threshold_sum_squared = (group_variances[0] + math.pow(group_means[0], 2)) * group_histogram[0] + (group_variances[1] + math.pow(group_means[1], 2)) * group_histogram[1] + y_std = math.sqrt((threshold_sum_squared - total_elements_in_threshold_range * math.pow(y_mean, 2)) / (total_elements_in_threshold_range - 1.0)) + else: + y_mean = 0.0 + y_std = 0.0 # qunatifying the global max - x_max = max(x) + # TODO: @Mate, where should we put the id of the element, where max is? + x_max, max_id = current_container.Max(self.model_part, KratosMultiphysics.CFL_NUMBER, "value") return [y_mean, y_std, x_max, how_many, how_many1] def _EvaluateCFL(self): - if (self.model_part.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE] == 2): KratosCFD.EstimateDtUtility2D.CalculateLocalCFL(self.model_part) else: KratosCFD.EstimateDtUtility3D.CalculateLocalCFL(self.model_part) - - local_cfl = [] - for elem in self.model_part.Elements: - local_cfl.append(elem.GetValue(KratosMultiphysics.CFL_NUMBER)) - - local_cfl = self.model_part.GetCommunicator().GetDataCommunicator().GathervDoubles(local_cfl, 0) - - return local_cfl - - def _SummarizeCFL(self, local_cfl): - - global_cfl = [] - for k in local_cfl: - global_cfl.extend(k) - - cfl_mean, cfl_std, cfl_max, cfl_how_many, cfl_how_many1 = self._CalculateWithRespectToThreshold( - global_cfl) - - return [cfl_mean, cfl_std, cfl_max, cfl_how_many, cfl_how_many1] From 62bc0a124b00a881ccded1d4b7401e6c1ceb0d56 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Thu, 9 Apr 2020 17:44:29 +0200 Subject: [PATCH 145/314] import fix --- .../python_scripts/cfl_output_process.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/applications/FluidDynamicsApplication/python_scripts/cfl_output_process.py b/applications/FluidDynamicsApplication/python_scripts/cfl_output_process.py index d7e7e4f4f8fb..1558b5adb3cd 100755 --- a/applications/FluidDynamicsApplication/python_scripts/cfl_output_process.py +++ b/applications/FluidDynamicsApplication/python_scripts/cfl_output_process.py @@ -13,8 +13,7 @@ msg += " Please install/compile it and try again." raise Exception(msg) -from statistics import mean, stdev -import math +from math import pow, sqrt def Factory(settings, model): @@ -160,8 +159,8 @@ def _CalculateWithRespectToThreshold(self): if (total_elements_in_threshold_range > 0): y_mean = (group_means[0] * group_histogram[0] + group_means[1] * group_histogram[1]) / total_elements_in_threshold_range - threshold_sum_squared = (group_variances[0] + math.pow(group_means[0], 2)) * group_histogram[0] + (group_variances[1] + math.pow(group_means[1], 2)) * group_histogram[1] - y_std = math.sqrt((threshold_sum_squared - total_elements_in_threshold_range * math.pow(y_mean, 2)) / (total_elements_in_threshold_range - 1.0)) + threshold_sum_squared = (group_variances[0] + pow(group_means[0], 2)) * group_histogram[0] + (group_variances[1] + pow(group_means[1], 2)) * group_histogram[1] + y_std = sqrt((threshold_sum_squared - total_elements_in_threshold_range * pow(y_mean, 2)) / (total_elements_in_threshold_range - 1.0)) else: y_mean = 0.0 y_std = 0.0 From 1af5776fab14b6a3e54ecc989bf37b3566d8833a Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Thu, 9 Apr 2020 18:23:40 +0200 Subject: [PATCH 146/314] extending distribution method with tests --- .../custom_methods/spatial_methods.h | 54 +++++++++++++++---- ..._historical_magnitude_distribution.ref.dat | 10 ++-- ..._historical_magnitude_distribution.ref.dat | 10 ++-- ..._historical_magnitude_distribution.ref.dat | 10 ++-- ..._historical_magnitude_distribution.ref.dat | 10 ++-- .../tests/test_spatial_methods.py | 14 +++-- 6 files changed, 75 insertions(+), 33 deletions(-) diff --git a/applications/StatisticsApplication/custom_methods/spatial_methods.h b/applications/StatisticsApplication/custom_methods/spatial_methods.h index 16dc6e734429..1a591b0cb8e2 100644 --- a/applications/StatisticsApplication/custom_methods/spatial_methods.h +++ b/applications/StatisticsApplication/custom_methods/spatial_methods.h @@ -568,7 +568,7 @@ class ContainerSpatialMethods } template - std::tuple, std::vector, std::vector> static GetNormDistribution( + std::tuple, std::vector, std::vector, std::vector, std::vector> static GetNormDistribution( const ModelPart& rModelPart, const Variable& rVariable, @@ -647,27 +647,41 @@ class ContainerSpatialMethods min_value + (max_value - min_value) * static_cast(i) / static_cast(number_of_groups)); } - group_limits[group_limits.size() - 1] += 1.0; + + // final group limit is extended by a small amount. epsilon in numeric limits cannot be used + // since testing also need to have the same extending value in python. Therefore hard coded value + // is used + group_limits[group_limits.size() - 1] += 1e-16; group_limits.push_back(std::numeric_limits::max()); group_limits.shrink_to_fit(); const int number_of_limits = group_limits.size(); std::vector distribution; + std::vector group_means, group_variances; for (int i = 0; i < number_of_limits; ++i) { distribution.push_back(0); + group_means.push_back(0.0); + group_variances.push_back(0.0); } distribution.shrink_to_fit(); + group_means.shrink_to_fit(); + group_variances.shrink_to_fit(); #pragma omp parallel { std::vector local_distribution; + std::vector local_means, local_variances; for (int i = 0; i < number_of_limits; ++i) { local_distribution.push_back(0); + local_means.push_back(0.0); + local_variances.push_back(0.0); } local_distribution.shrink_to_fit(); + local_means.shrink_to_fit(); + local_variances.shrink_to_fit(); #pragma omp for for (int i = 0; i < static_cast(r_container.size()); ++i) @@ -681,6 +695,8 @@ class ContainerSpatialMethods if (value_norm < group_limits[i]) { ++local_distribution[i]; + local_means[i] += value_norm; + local_variances[i] += std::pow(value_norm, 2); break; } } @@ -690,30 +706,48 @@ class ContainerSpatialMethods for (int i = 0; i < number_of_limits; ++i) { distribution[i] += local_distribution[i]; + group_means[i] += local_means[i]; + group_variances[i] += local_variances[i]; } } } std::vector global_distribution = rModelPart.GetCommunicator().GetDataCommunicator().SumAll(distribution); + std::vector global_mean_distribution = + rModelPart.GetCommunicator().GetDataCommunicator().SumAll(group_means); + std::vector global_variance_distribution = + rModelPart.GetCommunicator().GetDataCommunicator().SumAll(group_variances); - const int number_of_items = std::max( - std::accumulate(global_distribution.begin(), global_distribution.end(), 0), 1); + const double number_of_items = static_cast(std::max( + std::accumulate(global_distribution.begin(), global_distribution.end(), 0), 1)); std::vector global_percentage_distributions; for (int i = 0; i < number_of_limits; ++i) { - global_percentage_distributions.push_back( - static_cast(global_distribution[i]) / - static_cast(number_of_items)); + const double number_of_values_in_group = + static_cast(global_distribution[i]); + global_percentage_distributions.push_back(number_of_values_in_group / number_of_items); + if (number_of_values_in_group > 0.0) + { + global_mean_distribution[i] /= number_of_values_in_group; + global_variance_distribution[i] /= number_of_values_in_group; + global_variance_distribution[i] -= + std::pow(global_mean_distribution[i], 2); + } } - group_limits[group_limits.size() - 2] -= 1.0; + + // reversing group limit is extention + group_limits[group_limits.size() - 2] -= 1e-16; group_limits[group_limits.size() - 1] = max_value; - return std::make_tuple, std::vector, std::vector>( + return std::make_tuple, std::vector, + std::vector, std::vector, std::vector>( std::forward(min_value), std::forward(max_value), std::forward>(group_limits), std::forward>(global_distribution), - std::forward>(global_percentage_distributions)); + std::forward>(global_percentage_distributions), + std::forward>(global_mean_distribution), + std::forward>(global_variance_distribution)); KRATOS_CATCH(""); } diff --git a/applications/StatisticsApplication/tests/spatial_statistics_process/test_model_part_condition_non_historical_magnitude_distribution.ref.dat b/applications/StatisticsApplication/tests/spatial_statistics_process/test_model_part_condition_non_historical_magnitude_distribution.ref.dat index 21a1b3ae9b31..b3e1d04ef7de 100644 --- a/applications/StatisticsApplication/tests/spatial_statistics_process/test_model_part_condition_non_historical_magnitude_distribution.ref.dat +++ b/applications/StatisticsApplication/tests/spatial_statistics_process/test_model_part_condition_non_historical_magnitude_distribution.ref.dat @@ -9,9 +9,9 @@ # ---------------------------------------------------------------------- # Headers: # OutputControlVariableValue PRESSURE_Min PRESSURE_Max VELOCITY_Min VELOCITY_Max LOAD_MESHES_Min LOAD_MESHES_Max GREEN_LAGRANGE_STRAIN_TENSOR_Min GREEN_LAGRANGE_STRAIN_TENSOR_Max -2 6.0 27.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 20.784609690826528 93.53074360871938 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 20.12461179749811 67.08203932499369 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 120.0 330.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 -4 10.0 45.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 34.64101615137755 155.88457268119896 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 33.54101966249684 111.80339887498948 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 200.0 550.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 -6 14.0 63.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 48.49742261192856 218.23840175367854 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 46.95742752749558 156.52475842498527 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 280.0 770.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 -8 18.0 81.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 62.353829072479584 280.59223082615813 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 60.37383539249432 201.24611797498108 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 360.0 990.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 -10 22.0 99.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 76.2102355330306 342.9460598986377 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 73.79024325749306 245.96747752497686 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 440.0 1210.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 +2 6.0 27.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 20.784609690826528 93.53074360871938 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 20.12461179749811 67.08203932499369 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 120.0 330.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 +4 10.0 45.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 34.64101615137755 155.88457268119896 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 33.54101966249684 111.80339887498948 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 200.0 550.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 +6 14.0 63.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 48.49742261192856 218.23840175367854 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 46.95742752749558 156.52475842498527 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 280.0 770.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 +8 18.0 81.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 62.353829072479584 280.59223082615813 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 60.37383539249432 201.24611797498108 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 360.0 990.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 +10 22.0 99.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 76.2102355330306 342.9460598986377 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 73.79024325749306 245.96747752497686 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 440.0 1210.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 # End of file diff --git a/applications/StatisticsApplication/tests/spatial_statistics_process/test_model_part_element_non_historical_magnitude_distribution.ref.dat b/applications/StatisticsApplication/tests/spatial_statistics_process/test_model_part_element_non_historical_magnitude_distribution.ref.dat index 5e5ddcbf250d..942d6e4c8888 100644 --- a/applications/StatisticsApplication/tests/spatial_statistics_process/test_model_part_element_non_historical_magnitude_distribution.ref.dat +++ b/applications/StatisticsApplication/tests/spatial_statistics_process/test_model_part_element_non_historical_magnitude_distribution.ref.dat @@ -9,9 +9,9 @@ # ---------------------------------------------------------------------- # Headers: # OutputControlVariableValue PRESSURE_Min PRESSURE_Max VELOCITY_Min VELOCITY_Max LOAD_MESHES_Min LOAD_MESHES_Max GREEN_LAGRANGE_STRAIN_TENSOR_Min GREEN_LAGRANGE_STRAIN_TENSOR_Max -2 6.0 27.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 20.784609690826528 93.53074360871938 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 20.12461179749811 67.08203932499369 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 120.0 330.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 -4 10.0 45.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 34.64101615137755 155.88457268119896 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 33.54101966249684 111.80339887498948 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 200.0 550.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 -6 14.0 63.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 48.49742261192856 218.23840175367854 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 46.95742752749558 156.52475842498527 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 280.0 770.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 -8 18.0 81.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 62.353829072479584 280.59223082615813 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 60.37383539249432 201.24611797498108 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 360.0 990.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 -10 22.0 99.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 76.2102355330306 342.9460598986377 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 73.79024325749306 245.96747752497686 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 440.0 1210.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.125 0.0 +2 6.0 27.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 20.784609690826528 93.53074360871938 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 20.12461179749811 67.08203932499369 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 120.0 330.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 +4 10.0 45.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 34.64101615137755 155.88457268119896 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 33.54101966249684 111.80339887498948 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 200.0 550.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 +6 14.0 63.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 48.49742261192856 218.23840175367854 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 46.95742752749558 156.52475842498527 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 280.0 770.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 +8 18.0 81.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 62.353829072479584 280.59223082615813 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 60.37383539249432 201.24611797498108 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 360.0 990.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 +10 22.0 99.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 76.2102355330306 342.9460598986377 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 73.79024325749306 245.96747752497686 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 440.0 1210.0 0.0 0.125 0.125 0.125 0.0 0.125 0.125 0.0 0.125 0.125 0.0 0.125 # End of file diff --git a/applications/StatisticsApplication/tests/spatial_statistics_process/test_model_part_nodal_historical_magnitude_distribution.ref.dat b/applications/StatisticsApplication/tests/spatial_statistics_process/test_model_part_nodal_historical_magnitude_distribution.ref.dat index 998c8412b717..8e4d9a9bfede 100644 --- a/applications/StatisticsApplication/tests/spatial_statistics_process/test_model_part_nodal_historical_magnitude_distribution.ref.dat +++ b/applications/StatisticsApplication/tests/spatial_statistics_process/test_model_part_nodal_historical_magnitude_distribution.ref.dat @@ -9,9 +9,9 @@ # ---------------------------------------------------------------------- # Headers: # OutputControlVariableValue PRESSURE_Min PRESSURE_Max VELOCITY_Min VELOCITY_Max LOAD_MESHES_Min LOAD_MESHES_Max GREEN_LAGRANGE_STRAIN_TENSOR_Min GREEN_LAGRANGE_STRAIN_TENSOR_Max -2 6.0 30.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 20.784609690826528 103.92304845413264 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 20.12461179749811 73.79024325749306 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 120.0 360.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 -4 10.0 50.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 34.64101615137755 173.20508075688772 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 33.54101966249684 122.98373876248843 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 200.0 600.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 -6 14.0 70.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 48.49742261192856 242.4871130596428 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 46.95742752749558 172.1772342674838 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 280.0 840.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 -8 18.0 90.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 62.353829072479584 311.7691453623979 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 60.37383539249432 221.37072977247917 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 360.0 1080.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 -10 22.0 110.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 76.2102355330306 381.051177665153 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 73.79024325749306 270.5642252774746 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 440.0 1320.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 +2 6.0 30.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 20.784609690826528 103.92304845413264 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 20.12461179749811 73.79024325749306 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 120.0 360.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 +4 10.0 50.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 34.64101615137755 173.20508075688772 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 33.54101966249684 122.98373876248843 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 200.0 600.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 +6 14.0 70.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 48.49742261192856 242.4871130596428 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 46.95742752749558 172.1772342674838 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 280.0 840.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 +8 18.0 90.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 62.353829072479584 311.7691453623979 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 60.37383539249432 221.37072977247917 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 360.0 1080.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 +10 22.0 110.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 76.2102355330306 381.051177665153 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 73.79024325749306 270.5642252774746 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 440.0 1320.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 # End of file diff --git a/applications/StatisticsApplication/tests/spatial_statistics_process/test_model_part_nodal_non_historical_magnitude_distribution.ref.dat b/applications/StatisticsApplication/tests/spatial_statistics_process/test_model_part_nodal_non_historical_magnitude_distribution.ref.dat index 78cefa06ae6a..dc558ab9df0d 100644 --- a/applications/StatisticsApplication/tests/spatial_statistics_process/test_model_part_nodal_non_historical_magnitude_distribution.ref.dat +++ b/applications/StatisticsApplication/tests/spatial_statistics_process/test_model_part_nodal_non_historical_magnitude_distribution.ref.dat @@ -9,9 +9,9 @@ # ---------------------------------------------------------------------- # Headers: # OutputControlVariableValue PRESSURE_Min PRESSURE_Max VELOCITY_Min VELOCITY_Max LOAD_MESHES_Min LOAD_MESHES_Max GREEN_LAGRANGE_STRAIN_TENSOR_Min GREEN_LAGRANGE_STRAIN_TENSOR_Max -2 6.0 30.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 20.784609690826528 103.92304845413264 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 20.12461179749811 73.79024325749306 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 120.0 360.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 -4 10.0 50.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 34.64101615137755 173.20508075688772 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 33.54101966249684 122.98373876248843 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 200.0 600.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 -6 14.0 70.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 48.49742261192856 242.4871130596428 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 46.95742752749558 172.1772342674838 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 280.0 840.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 -8 18.0 90.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 62.353829072479584 311.7691453623979 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 60.37383539249432 221.37072977247917 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 360.0 1080.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 -10 22.0 110.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 76.2102355330306 381.051177665153 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 73.79024325749306 270.5642252774746 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 440.0 1320.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 +2 6.0 30.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 20.784609690826528 103.92304845413264 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 20.12461179749811 73.79024325749306 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 120.0 360.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 +4 10.0 50.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 34.64101615137755 173.20508075688772 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 33.54101966249684 122.98373876248843 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 200.0 600.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 +6 14.0 70.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 48.49742261192856 242.4871130596428 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 46.95742752749558 172.1772342674838 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 280.0 840.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 +8 18.0 90.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 62.353829072479584 311.7691453623979 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 60.37383539249432 221.37072977247917 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 360.0 1080.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 +10 22.0 110.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 76.2102355330306 381.051177665153 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 73.79024325749306 270.5642252774746 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 440.0 1320.0 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.1111111111111111 0.0 0.1111111111111111 # End of file diff --git a/applications/StatisticsApplication/tests/test_spatial_methods.py b/applications/StatisticsApplication/tests/test_spatial_methods.py index 4e70ed52089e..8779ceb6dd5b 100644 --- a/applications/StatisticsApplication/tests/test_spatial_methods.py +++ b/applications/StatisticsApplication/tests/test_spatial_methods.py @@ -179,23 +179,31 @@ def analytical_method(container, container_type, norm_type, variable): group_limits = [ min_value + (max_value - min_value) * i / 10 for i in range(11) ] - group_limits[-1] += 1.0 + group_limits[-1] += 1e-16 group_limits.append(1e+100) data_distribution = [0 for i in range(len(group_limits))] + mean_distribution = [0.0 for i in range(len(group_limits))] + variance_distribution = [0.0 for i in range(len(group_limits))] for value in item_values: for i, v in enumerate(group_limits): if (value < v): data_distribution[i] += 1 + mean_distribution[i] += value + variance_distribution[i] += value**2.0 break percentage_data_distribution = [] for i, _ in enumerate(group_limits): percentage_data_distribution.append(data_distribution[i] / len(item_values)) + if (data_distribution[i] > 0): + mean_distribution[i] /= data_distribution[i] + variance_distribution[i] /= data_distribution[i] + variance_distribution[i] -= mean_distribution[i]**2.0 - group_limits[-2] -= 1.0 + group_limits[-2] -= 1e-16 group_limits[-1] = max_value - return min_value, max_value, group_limits, data_distribution, percentage_data_distribution + return min_value, max_value, group_limits, data_distribution, percentage_data_distribution, mean_distribution, variance_distribution self.__TestMethod("distribution", analytical_method, default_parameters) From 7a1bc7d039c7448d75b7ff48ccb14a62c614b123 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Thu, 9 Apr 2020 18:25:36 +0200 Subject: [PATCH 147/314] update readme --- applications/StatisticsApplication/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/applications/StatisticsApplication/README.md b/applications/StatisticsApplication/README.md index c9af436df081..82cf89d84a43 100644 --- a/applications/StatisticsApplication/README.md +++ b/applications/StatisticsApplication/README.md @@ -262,6 +262,8 @@ Distribution methods calculates distribution of a given variable with respect to 3. group limits of the distribution (only upper limit) (double array) 4. number of occurences of items within each group (int array) 5. percentage distribution of number of occurences of items within each group (double array) +6. Each group's seperate means +7. Eash group's seperate variances This method requires followings as the parameters as a object of Kratos.Parameters, if nothing is provided, then followings are assumed as defaults. @@ -282,7 +284,7 @@ import KratosMultiphysics as Kratos import KratosMultiphysics.StatisticsApplication as KratosStats model = Kratos.Model() model_part = model.CreateModelPart("test_model_part") -min_value, max_value, group_upper_values, group_histogram, group_percentage_distribution = KratosStats.SpatialMethods.NonHistorical.Nodes.NormMethods.Distribution(model_part, Kratos.VELOCITY, "magnitude") +min_value, max_value, group_upper_values, group_histogram, group_percentage_distribution, group_means, group_variances = KratosStats.SpatialMethods.NonHistorical.Nodes.NormMethods.Distribution(model_part, Kratos.VELOCITY, "magnitude") ``` ### Norm methods From bdf63493565e69aa199c683338248101a188c3f3 Mon Sep 17 00:00:00 2001 From: eloisabaez Date: Fri, 10 Apr 2020 14:40:41 +0200 Subject: [PATCH 148/314] initial draft of mach derivative function --- ...ic_perturbation_potential_flow_element.cpp | 26 +++++++++++++++++++ ...onic_perturbation_potential_flow_element.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/applications/CompressiblePotentialFlowApplication/custom_elements/transonic_perturbation_potential_flow_element.cpp b/applications/CompressiblePotentialFlowApplication/custom_elements/transonic_perturbation_potential_flow_element.cpp index 4905f0921390..78d5b4855ef7 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_elements/transonic_perturbation_potential_flow_element.cpp +++ b/applications/CompressiblePotentialFlowApplication/custom_elements/transonic_perturbation_potential_flow_element.cpp @@ -972,6 +972,32 @@ double TransonicPerturbationPotentialFlowElement::ComputeDensit pow(rho, 2 - heat_capacity_ratio) / (2 * a_inf * a_inf); } +template +double TransonicPerturbationPotentialFlowElement::ComputeLocalMachSquaredDerivative( + const ProcessInfo& rCurrentProcessInfo) const +{ + // read free stream values + const double heat_capacity_ratio = rCurrentProcessInfo[HEAT_CAPACITY_RATIO]; + const double free_stream_mach = rCurrentProcessInfo[FREE_STREAM_MACH]; + const array_1d free_stream_velocity = rCurrentProcessInfo[FREE_STREAM_VELOCITY]; + + // calculate local values + array_1d velocity = PotentialFlowUtilities::ComputeVelocity(*this); + double local_mach_number = PotentialFlowUtilities::ComputePerturbationLocalMachNumber(*this, rCurrentProcessInfo); + + // make squares of values + double sq_local_mach_number = pow(local_mach_number, 2); + double sq_free_stream_mach = pow(free_stream_mach, 2); + double sq_local_velocity = inner_prod(velocity, velocity); + double sq_free_stream_velocity = inner_prod(free_stream_velocity, free_stream_velocity); + + // square bracket term + double square_bracket_term = 1.0 + 0.5*(heat_capacity_ratio - 1)*sq_free_stream_mach*(1 - (sq_local_velocity/sq_free_stream_velocity)); + + // calculate mach derivative + return sq_local_mach_number * ((1/sq_local_velocity) + 0.5*(heat_capacity_ratio - 1)*(1/sq_free_stream_velocity)*sq_free_stream_mach*(1/square_bracket_term)); +} + // serializer template diff --git a/applications/CompressiblePotentialFlowApplication/custom_elements/transonic_perturbation_potential_flow_element.h b/applications/CompressiblePotentialFlowApplication/custom_elements/transonic_perturbation_potential_flow_element.h index a0f17241cdeb..72d76cd3ca31 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_elements/transonic_perturbation_potential_flow_element.h +++ b/applications/CompressiblePotentialFlowApplication/custom_elements/transonic_perturbation_potential_flow_element.h @@ -276,6 +276,8 @@ class TransonicPerturbationPotentialFlowElement : public Element void ComputePotentialJump(const ProcessInfo& rCurrentProcessInfo); + double ComputeLocalMachSquaredDerivative(const ProcessInfo& rCurrentProcessInfo) const; + ///@} ///@name Private Operations ///@{ From eb86d8831420efbffbc63d98b36eda1a7b4b759d Mon Sep 17 00:00:00 2001 From: eloisabaez Date: Mon, 13 Apr 2020 14:20:25 +0200 Subject: [PATCH 149/314] edit mach derivative function --- .../transonic_perturbation_potential_flow_element.cpp | 6 ++---- .../transonic_perturbation_potential_flow_element.h | 4 +++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/applications/CompressiblePotentialFlowApplication/custom_elements/transonic_perturbation_potential_flow_element.cpp b/applications/CompressiblePotentialFlowApplication/custom_elements/transonic_perturbation_potential_flow_element.cpp index 78d5b4855ef7..5181e2f51501 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_elements/transonic_perturbation_potential_flow_element.cpp +++ b/applications/CompressiblePotentialFlowApplication/custom_elements/transonic_perturbation_potential_flow_element.cpp @@ -974,6 +974,8 @@ double TransonicPerturbationPotentialFlowElement::ComputeDensit template double TransonicPerturbationPotentialFlowElement::ComputeLocalMachSquaredDerivative( + array_1d velocity, + double local_mach_number, const ProcessInfo& rCurrentProcessInfo) const { // read free stream values @@ -981,10 +983,6 @@ double TransonicPerturbationPotentialFlowElement::ComputeLocalM const double free_stream_mach = rCurrentProcessInfo[FREE_STREAM_MACH]; const array_1d free_stream_velocity = rCurrentProcessInfo[FREE_STREAM_VELOCITY]; - // calculate local values - array_1d velocity = PotentialFlowUtilities::ComputeVelocity(*this); - double local_mach_number = PotentialFlowUtilities::ComputePerturbationLocalMachNumber(*this, rCurrentProcessInfo); - // make squares of values double sq_local_mach_number = pow(local_mach_number, 2); double sq_free_stream_mach = pow(free_stream_mach, 2); diff --git a/applications/CompressiblePotentialFlowApplication/custom_elements/transonic_perturbation_potential_flow_element.h b/applications/CompressiblePotentialFlowApplication/custom_elements/transonic_perturbation_potential_flow_element.h index 72d76cd3ca31..daa3c3d75254 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_elements/transonic_perturbation_potential_flow_element.h +++ b/applications/CompressiblePotentialFlowApplication/custom_elements/transonic_perturbation_potential_flow_element.h @@ -276,7 +276,9 @@ class TransonicPerturbationPotentialFlowElement : public Element void ComputePotentialJump(const ProcessInfo& rCurrentProcessInfo); - double ComputeLocalMachSquaredDerivative(const ProcessInfo& rCurrentProcessInfo) const; + double ComputeLocalMachSquaredDerivative(array_1d velocity, + double local_mach_number, + const ProcessInfo& rCurrentProcessInfo) const; ///@} ///@name Private Operations From 0eb481d079e2f0d7a177e70198d9d4393bbdf1b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Tue, 14 Apr 2020 12:12:00 +0200 Subject: [PATCH 150/314] Fix FluidApp --- .../shock_detection_process.cpp | 14 +---- .../shock_detection_process.h | 56 ------------------- .../add_custom_processes_to_python.cpp | 4 -- 3 files changed, 1 insertion(+), 73 deletions(-) diff --git a/applications/FluidDynamicsApplication/custom_processes/shock_detection_process.cpp b/applications/FluidDynamicsApplication/custom_processes/shock_detection_process.cpp index ab1afa31e12a..388af3d07645 100644 --- a/applications/FluidDynamicsApplication/custom_processes/shock_detection_process.cpp +++ b/applications/FluidDynamicsApplication/custom_processes/shock_detection_process.cpp @@ -53,11 +53,7 @@ void ShockDetectionProcess::ExecuteInitializeSolutionStep() } // Perform the edge based shock detection - if (mShockVariableIsDouble) { - EdgeBasedShockDetectionSpecialization<>(*mpShockDoubleVariable, *mpShockGradientVariable); - } else { - EdgeBasedShockDetectionSpecialization<>(*mpShockComponentVariable, *mpShockGradientVariable); - } + EdgeBasedShockDetectionSpecialization<>(*mpShockDoubleVariable, *mpShockGradientVariable); } void ShockDetectionProcess::Execute() @@ -77,14 +73,6 @@ void ShockDetectionProcess::EdgeBasedShockDetection( EdgeBasedShockDetectionSpecialization<>(rShockVariable, rShockGradientVariable); } -void ShockDetectionProcess::EdgeBasedShockDetection( - const VariableComponentType& rShockVariable, - const Variable>& rShockGradientVariable) -{ - // Specialize the edge based shock detection - EdgeBasedShockDetectionSpecialization<>(rShockVariable, rShockGradientVariable); -} - std::string ShockDetectionProcess::Info() const { std::stringstream buffer; diff --git a/applications/FluidDynamicsApplication/custom_processes/shock_detection_process.h b/applications/FluidDynamicsApplication/custom_processes/shock_detection_process.h index 23e3d81af3dc..1c5ae05a174f 100644 --- a/applications/FluidDynamicsApplication/custom_processes/shock_detection_process.h +++ b/applications/FluidDynamicsApplication/custom_processes/shock_detection_process.h @@ -127,9 +127,6 @@ class KRATOS_API(FLUID_DYNAMICS_APPLICATION) ShockDetectionProcess : public Proc /// Pointer definition of ShockDetectionProcess KRATOS_CLASS_POINTER_DEFINITION(ShockDetectionProcess); - /// Variable component type - typedef VariableComponent< VectorComponentAdaptor > > VariableComponentType; - /// Node pointer type typedef typename Node<3>::Pointer NodePointerType; @@ -148,29 +145,11 @@ class KRATOS_API(FLUID_DYNAMICS_APPLICATION) ShockDetectionProcess : public Proc , mrModelPart(rModelPart) , mUpdateNodalAreaAtEachStep(UpdateNodalAreaAtEachStep) , mUpdateNodalNeighboursAtEachStep(UpdateNodalNeighboursAtEachStep) - , mShockVariableIsDouble(true) , mpShockDoubleVariable(&rShockDoubleVariable) , mpShockGradientVariable(&rShockGradientVariable) , mpShockSensorVariable(&SHOCK_SENSOR) {} - /// Constructor with default shock sensor variable for component shock variable - ShockDetectionProcess( - ModelPart& rModelPart, - const VariableComponentType& rShockComponentVariable, - const Variable>& rShockGradientVariable, - const bool UpdateNodalAreaAtEachStep = false, - const bool UpdateNodalNeighboursAtEachStep = false) - : Process() - , mrModelPart(rModelPart) - , mUpdateNodalAreaAtEachStep(UpdateNodalAreaAtEachStep) - , mUpdateNodalNeighboursAtEachStep(UpdateNodalNeighboursAtEachStep) - , mShockVariableIsDouble(false) - , mpShockComponentVariable(&rShockComponentVariable) - , mpShockGradientVariable(&rShockGradientVariable) - , mpShockSensorVariable(&SHOCK_SENSOR) - {} - /// Constructor with custom shock sensor variable for double shock variable ShockDetectionProcess( ModelPart& rModelPart, @@ -183,30 +162,11 @@ class KRATOS_API(FLUID_DYNAMICS_APPLICATION) ShockDetectionProcess : public Proc , mrModelPart(rModelPart) , mUpdateNodalAreaAtEachStep(UpdateNodalAreaAtEachStep) , mUpdateNodalNeighboursAtEachStep(UpdateNodalNeighboursAtEachStep) - , mShockVariableIsDouble(true) , mpShockDoubleVariable(&rShockDoubleVariable) , mpShockGradientVariable(&rShockGradientVariable) , mpShockSensorVariable(&rShockSensorVariable) {} - /// Constructor with custom shock sensor variable for component shock variable - ShockDetectionProcess( - ModelPart& rModelPart, - const VariableComponentType& rShockComponentVariable, - const Variable>& rShockGradientVariable, - const Variable& rShockSensorVariable, - const bool UpdateNodalAreaAtEachStep = false, - const bool UpdateNodalNeighboursAtEachStep = false) - : Process() - , mrModelPart(rModelPart) - , mUpdateNodalAreaAtEachStep(UpdateNodalAreaAtEachStep) - , mUpdateNodalNeighboursAtEachStep(UpdateNodalNeighboursAtEachStep) - , mShockVariableIsDouble(false) - , mpShockComponentVariable(&rShockComponentVariable) - , mpShockGradientVariable(&rShockGradientVariable) - , mpShockSensorVariable(&rShockSensorVariable) - {} - /// Destructor. virtual ~ShockDetectionProcess() = default; @@ -250,16 +210,6 @@ class KRATOS_API(FLUID_DYNAMICS_APPLICATION) ShockDetectionProcess : public Proc const Variable& rShockVariable, const Variable>& rShockGradientVariable); - /** - * @brief Perform edge based shock detection - * This method performs the edge based shock detection - * @param rShockVariable Component variable to perform the shock detection - * @param rShockGradientVariable Vector variable to calculate the shock variable gradients - */ - void EdgeBasedShockDetection( - const VariableComponentType& rShockVariable, - const Variable>& rShockGradientVariable); - /** * @brief Template specialization of the edge based shock detection function * Auxiliary method to specialize the variable types for the edge based shock detection @@ -394,15 +344,9 @@ class KRATOS_API(FLUID_DYNAMICS_APPLICATION) ShockDetectionProcess : public Proc /// Flag to indicate if the nodal neighbours have been already computed bool mNodalNeighboursAlreadyComputed = false; - /// Flag to indicate if the shock variable type is double or component one - const bool mShockVariableIsDouble; - /// Pointer to the shock detection double variable const Variable* mpShockDoubleVariable = nullptr; - /// Pointer to the shock detection component variable - const VariableComponentType* mpShockComponentVariable = nullptr; - /// Name of the shock detection gradient variable const Variable>* mpShockGradientVariable = nullptr; diff --git a/applications/FluidDynamicsApplication/custom_python/add_custom_processes_to_python.cpp b/applications/FluidDynamicsApplication/custom_python/add_custom_processes_to_python.cpp index d98d5bf958c7..d29c18931476 100644 --- a/applications/FluidDynamicsApplication/custom_python/add_custom_processes_to_python.cpp +++ b/applications/FluidDynamicsApplication/custom_python/add_custom_processes_to_python.cpp @@ -60,8 +60,6 @@ void AddCustomProcessesToPython(pybind11::module& m) typedef LinearSolver LinearSolverType; - typedef VariableComponent< VectorComponentAdaptor > > VariableComponentType; - py::class_, SpalartAllmarasTurbulenceModel< SparseSpaceType, LocalSpaceType, LinearSolverType >::Pointer, Process> (m,"SpalartAllmarasTurbulenceModel") .def(py::init < ModelPart&, LinearSolverType::Pointer, unsigned int, double, unsigned int, bool, unsigned int>()) @@ -136,8 +134,6 @@ void AddCustomProcessesToPython(pybind11::module& m) (m, "ShockDetectionProcess") .def(py::init < ModelPart&, const Variable&, const Variable>&, const bool, const bool >()) .def(py::init < ModelPart&, const Variable&, const Variable>&, const Variable&, const bool, const bool >()) - .def(py::init < ModelPart&, const VariableComponentType&, const Variable>&, const bool, const bool >()) - .def(py::init < ModelPart&, const VariableComponentType&, const Variable>&, const Variable&, const bool, const bool >()) .def("ExecuteInitialize", &ShockDetectionProcess::ExecuteInitialize) .def("ExecuteInitializeSolutionStep", &ShockDetectionProcess::ExecuteInitialize) .def("Execute", &ShockDetectionProcess::Execute) From 4db38506f063d3e694a1fef6e942caa858dce122 Mon Sep 17 00:00:00 2001 From: eloisabaez Date: Tue, 14 Apr 2020 14:00:08 +0200 Subject: [PATCH 151/314] moving calculation to utilities and adding test --- ...ic_perturbation_potential_flow_element.cpp | 24 ---------- ...onic_perturbation_potential_flow_element.h | 4 -- .../potential_flow_utilities.cpp | 29 ++++++++++++ .../potential_flow_utilities.h | 3 ++ .../test_potential_flow_utilities.cpp | 44 +++++++++++++++++++ 5 files changed, 76 insertions(+), 28 deletions(-) diff --git a/applications/CompressiblePotentialFlowApplication/custom_elements/transonic_perturbation_potential_flow_element.cpp b/applications/CompressiblePotentialFlowApplication/custom_elements/transonic_perturbation_potential_flow_element.cpp index 5181e2f51501..4905f0921390 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_elements/transonic_perturbation_potential_flow_element.cpp +++ b/applications/CompressiblePotentialFlowApplication/custom_elements/transonic_perturbation_potential_flow_element.cpp @@ -972,30 +972,6 @@ double TransonicPerturbationPotentialFlowElement::ComputeDensit pow(rho, 2 - heat_capacity_ratio) / (2 * a_inf * a_inf); } -template -double TransonicPerturbationPotentialFlowElement::ComputeLocalMachSquaredDerivative( - array_1d velocity, - double local_mach_number, - const ProcessInfo& rCurrentProcessInfo) const -{ - // read free stream values - const double heat_capacity_ratio = rCurrentProcessInfo[HEAT_CAPACITY_RATIO]; - const double free_stream_mach = rCurrentProcessInfo[FREE_STREAM_MACH]; - const array_1d free_stream_velocity = rCurrentProcessInfo[FREE_STREAM_VELOCITY]; - - // make squares of values - double sq_local_mach_number = pow(local_mach_number, 2); - double sq_free_stream_mach = pow(free_stream_mach, 2); - double sq_local_velocity = inner_prod(velocity, velocity); - double sq_free_stream_velocity = inner_prod(free_stream_velocity, free_stream_velocity); - - // square bracket term - double square_bracket_term = 1.0 + 0.5*(heat_capacity_ratio - 1)*sq_free_stream_mach*(1 - (sq_local_velocity/sq_free_stream_velocity)); - - // calculate mach derivative - return sq_local_mach_number * ((1/sq_local_velocity) + 0.5*(heat_capacity_ratio - 1)*(1/sq_free_stream_velocity)*sq_free_stream_mach*(1/square_bracket_term)); -} - // serializer template diff --git a/applications/CompressiblePotentialFlowApplication/custom_elements/transonic_perturbation_potential_flow_element.h b/applications/CompressiblePotentialFlowApplication/custom_elements/transonic_perturbation_potential_flow_element.h index daa3c3d75254..a0f17241cdeb 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_elements/transonic_perturbation_potential_flow_element.h +++ b/applications/CompressiblePotentialFlowApplication/custom_elements/transonic_perturbation_potential_flow_element.h @@ -276,10 +276,6 @@ class TransonicPerturbationPotentialFlowElement : public Element void ComputePotentialJump(const ProcessInfo& rCurrentProcessInfo); - double ComputeLocalMachSquaredDerivative(array_1d velocity, - double local_mach_number, - const ProcessInfo& rCurrentProcessInfo) const; - ///@} ///@name Private Operations ///@{ diff --git a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp index 7484b69f1a53..9c4fc8ff2e66 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp +++ b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp @@ -416,6 +416,32 @@ bool CheckWakeCondition(const Element& rElement, const double& rTolerance, const return wake_condition_is_fulfilled; } +template +double ComputeLocalMachSquaredDerivative( + array_1d velocity, + double local_mach_number, + const ProcessInfo& rCurrentProcessInfo) +{ + // read free stream values + const double heat_capacity_ratio = rCurrentProcessInfo[HEAT_CAPACITY_RATIO]; + const double free_stream_mach = rCurrentProcessInfo[FREE_STREAM_MACH]; + const array_1d free_stream_velocity = rCurrentProcessInfo[FREE_STREAM_VELOCITY]; + + // make squares of values + double sq_local_mach_number = pow(local_mach_number, 2); + double sq_free_stream_mach = pow(free_stream_mach, 2); + double sq_local_velocity = inner_prod(velocity, velocity); + double sq_free_stream_velocity = inner_prod(free_stream_velocity, free_stream_velocity); + + // square bracket term + double square_bracket_term = 1.0 + 0.5*(heat_capacity_ratio - 1)* + sq_free_stream_mach*(1 - (sq_local_velocity/sq_free_stream_velocity)); + + // calculate mach derivative + return sq_local_mach_number * ((1/sq_local_velocity) + + 0.5*(heat_capacity_ratio - 1)*(1/sq_free_stream_velocity)*sq_free_stream_mach*(1/square_bracket_term)); +} + /////////////////////////////////////////////////////////////////////////////////////////////////// // Template instantiation @@ -443,6 +469,7 @@ template double ComputePerturbationLocalMachNumber<2, 3>(const Element& rElement template bool CheckIfElementIsCutByDistance<2, 3>(const BoundedVector& rNodalDistances); template void KRATOS_API(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION) CheckIfWakeConditionsAreFulfilled<2>(const ModelPart&, const double& rTolerance, const int& rEchoLevel); template bool CheckWakeCondition<2, 3>(const Element& rElement, const double& rTolerance, const int& rEchoLevel); +template double ComputeLocalMachSquaredDerivative<2, 3>(array_1d velocity, double local_mach_number, const ProcessInfo& rCurrentProcessInfo); // 3D template array_1d GetWakeDistances<3, 4>(const Element& rElement); @@ -468,5 +495,7 @@ template double ComputePerturbationLocalMachNumber<3, 4>(const Element& rElement template bool CheckIfElementIsCutByDistance<3, 4>(const BoundedVector& rNodalDistances); template void KRATOS_API(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION) CheckIfWakeConditionsAreFulfilled<3>(const ModelPart&, const double& rTolerance, const int& rEchoLevel); template bool CheckWakeCondition<3, 4>(const Element& rElement, const double& rTolerance, const int& rEchoLevel); +template double ComputeLocalMachSquaredDerivative<3, 4>(array_1d velocity, double local_mach_number, const ProcessInfo& rCurrentProcessInfo); + } // namespace PotentialFlow } // namespace Kratos diff --git a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h index da81b44e7b07..34357a8f3558 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h +++ b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h @@ -99,6 +99,9 @@ void CheckIfWakeConditionsAreFulfilled(const ModelPart& rWakeModelPart, const do template bool CheckWakeCondition(const Element& rElement, const double& rTolerance, const int& rEchoLevel); +template +double ComputeLocalMachSquaredDerivative(array_1d velocity, double local_mach_number,const ProcessInfo& rCurrentProcessInfo); + } // namespace PotentialFlow } // namespace Kratos diff --git a/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp b/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp index 1dfbb5519c75..69824d66007d 100644 --- a/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp +++ b/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp @@ -163,5 +163,49 @@ KRATOS_TEST_CASE_IN_SUITE(ComputePerturbationLocalMachNumber, CompressiblePotent KRATOS_CHECK_NEAR(local_mach_number, 0.9474471158469713, 1e-16); } +// Checks the function ComputeLocalMachSquaredDerivative from the utilities, transonic local Mach number +KRATOS_TEST_CASE_IN_SUITE(ComputeLocalMachSquaredDerivativeTransonicMach, CompressiblePotentialApplicationFastSuite) { + Model this_model; + ModelPart& model_part = this_model.CreateModelPart("Main", 3); + + GenerateTestingElement(model_part); + + auto rCurrentProcessInfo = model_part.GetProcessInfo(); + + array_1d velocity(2, 0.0); + velocity[0] = 68.0 * sqrt(67.0/3.0); + + double local_mach_number = 1.0; + + auto mach_derivative = PotentialFlowUtilities::ComputeLocalMachSquaredDerivative<2, 3>(velocity, + local_mach_number, model_part.GetProcessInfo()); + + double reference_derivative = 1.16201001910861e-05; + + KRATOS_CHECK_NEAR(mach_derivative, reference_derivative, 1e-16); +} + +// Checks the function ComputeLocalMachSquaredDerivative from the utilities, supersonic local Mach number +KRATOS_TEST_CASE_IN_SUITE(ComputeLocalMachSquaredDerivativeSuperSonicMach, CompressiblePotentialApplicationFastSuite) { + Model this_model; + ModelPart& model_part = this_model.CreateModelPart("Main", 3); + + GenerateTestingElement(model_part); + + auto rCurrentProcessInfo = model_part.GetProcessInfo(); + + array_1d velocity(2, 0.0); + velocity[0] = 272.0 * sqrt(134.0/21.0); + + double local_mach_number = 4.0; + + double mach_derivative = PotentialFlowUtilities::ComputeLocalMachSquaredDerivative<2, 3>(velocity, + local_mach_number, model_part.GetProcessInfo()); + + double reference_derivative = 0.000142346227340804; + + KRATOS_CHECK_NEAR(mach_derivative, reference_derivative, 1e-16); +} + } // namespace Testing } // namespace Kratos. From 9c194e2cf9038ebd05f6c650b1607fc2caf13264 Mon Sep 17 00:00:00 2001 From: eloisabaez Date: Tue, 14 Apr 2020 18:13:50 +0200 Subject: [PATCH 152/314] change input to constant references --- .../potential_flow_utilities.cpp | 8 +++---- .../potential_flow_utilities.h | 2 +- .../test_potential_flow_utilities.cpp | 24 ++++++++++++++----- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp index 9c4fc8ff2e66..bfdd281d8ba7 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp +++ b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp @@ -418,8 +418,8 @@ bool CheckWakeCondition(const Element& rElement, const double& rTolerance, const template double ComputeLocalMachSquaredDerivative( - array_1d velocity, - double local_mach_number, + const array_1d& velocity, + const double& local_mach_number, const ProcessInfo& rCurrentProcessInfo) { // read free stream values @@ -469,7 +469,7 @@ template double ComputePerturbationLocalMachNumber<2, 3>(const Element& rElement template bool CheckIfElementIsCutByDistance<2, 3>(const BoundedVector& rNodalDistances); template void KRATOS_API(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION) CheckIfWakeConditionsAreFulfilled<2>(const ModelPart&, const double& rTolerance, const int& rEchoLevel); template bool CheckWakeCondition<2, 3>(const Element& rElement, const double& rTolerance, const int& rEchoLevel); -template double ComputeLocalMachSquaredDerivative<2, 3>(array_1d velocity, double local_mach_number, const ProcessInfo& rCurrentProcessInfo); +template double ComputeLocalMachSquaredDerivative<2, 3>(const array_1d& velocity, const double& local_mach_number, const ProcessInfo& rCurrentProcessInfo); // 3D template array_1d GetWakeDistances<3, 4>(const Element& rElement); @@ -495,7 +495,7 @@ template double ComputePerturbationLocalMachNumber<3, 4>(const Element& rElement template bool CheckIfElementIsCutByDistance<3, 4>(const BoundedVector& rNodalDistances); template void KRATOS_API(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION) CheckIfWakeConditionsAreFulfilled<3>(const ModelPart&, const double& rTolerance, const int& rEchoLevel); template bool CheckWakeCondition<3, 4>(const Element& rElement, const double& rTolerance, const int& rEchoLevel); -template double ComputeLocalMachSquaredDerivative<3, 4>(array_1d velocity, double local_mach_number, const ProcessInfo& rCurrentProcessInfo); +template double ComputeLocalMachSquaredDerivative<3, 4>(const array_1d& velocity, const double& local_mach_number, const ProcessInfo& rCurrentProcessInfo); } // namespace PotentialFlow } // namespace Kratos diff --git a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h index 34357a8f3558..228f4fa5b855 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h +++ b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h @@ -100,7 +100,7 @@ template bool CheckWakeCondition(const Element& rElement, const double& rTolerance, const int& rEchoLevel); template -double ComputeLocalMachSquaredDerivative(array_1d velocity, double local_mach_number,const ProcessInfo& rCurrentProcessInfo); +double ComputeLocalMachSquaredDerivative(const array_1d& velocity, const double& local_mach_number,const ProcessInfo& rCurrentProcessInfo); } // namespace PotentialFlow } // namespace Kratos diff --git a/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp b/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp index 69824d66007d..c63b8528f3e8 100644 --- a/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp +++ b/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp @@ -168,9 +168,15 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeLocalMachSquaredDerivativeTransonicMach, Compre Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); - GenerateTestingElement(model_part); + model_part.GetProcessInfo()[FREE_STREAM_DENSITY] = 1.225; + model_part.GetProcessInfo()[FREE_STREAM_MACH] = 0.6; + model_part.GetProcessInfo()[HEAT_CAPACITY_RATIO] = 1.4; + model_part.GetProcessInfo()[SOUND_VELOCITY] = 340.0; - auto rCurrentProcessInfo = model_part.GetProcessInfo(); + BoundedVector free_stream_velocity = ZeroVector(3); + free_stream_velocity(0) = model_part.GetProcessInfo().GetValue(FREE_STREAM_MACH) * + model_part.GetProcessInfo().GetValue(SOUND_VELOCITY); + model_part.GetProcessInfo()[FREE_STREAM_VELOCITY] = free_stream_velocity; array_1d velocity(2, 0.0); velocity[0] = 68.0 * sqrt(67.0/3.0); @@ -186,18 +192,24 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeLocalMachSquaredDerivativeTransonicMach, Compre } // Checks the function ComputeLocalMachSquaredDerivative from the utilities, supersonic local Mach number -KRATOS_TEST_CASE_IN_SUITE(ComputeLocalMachSquaredDerivativeSuperSonicMach, CompressiblePotentialApplicationFastSuite) { +KRATOS_TEST_CASE_IN_SUITE(ComputeLocalMachSquaredDerivativeSupersonicMach, CompressiblePotentialApplicationFastSuite) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); - GenerateTestingElement(model_part); + model_part.GetProcessInfo()[FREE_STREAM_DENSITY] = 1.225; + model_part.GetProcessInfo()[FREE_STREAM_MACH] = 0.6; + model_part.GetProcessInfo()[HEAT_CAPACITY_RATIO] = 1.4; + model_part.GetProcessInfo()[SOUND_VELOCITY] = 340.0; - auto rCurrentProcessInfo = model_part.GetProcessInfo(); + BoundedVector free_stream_velocity = ZeroVector(3); + free_stream_velocity(0) = model_part.GetProcessInfo().GetValue(FREE_STREAM_MACH) * + model_part.GetProcessInfo().GetValue(SOUND_VELOCITY); + model_part.GetProcessInfo()[FREE_STREAM_VELOCITY] = free_stream_velocity; array_1d velocity(2, 0.0); velocity[0] = 272.0 * sqrt(134.0/21.0); - double local_mach_number = 4.0; + const double local_mach_number = 4.0; double mach_derivative = PotentialFlowUtilities::ComputeLocalMachSquaredDerivative<2, 3>(velocity, local_mach_number, model_part.GetProcessInfo()); From 8f9168c9545b1869445837f5477bf9d0a539e957 Mon Sep 17 00:00:00 2001 From: eloisabaez Date: Wed, 15 Apr 2020 11:12:08 +0200 Subject: [PATCH 153/314] adding derivative equation reference --- .../custom_utilities/potential_flow_utilities.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp index bfdd281d8ba7..7cda22fd920b 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp +++ b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp @@ -422,6 +422,10 @@ double ComputeLocalMachSquaredDerivative( const double& local_mach_number, const ProcessInfo& rCurrentProcessInfo) { + // Following Fully Simulataneous Coupling of the Full Potential Equation + // and the Integral Boundary Layer Equations in Three Dimensions + // by Brian Nishida (1996), Section A.2 + // read free stream values const double heat_capacity_ratio = rCurrentProcessInfo[HEAT_CAPACITY_RATIO]; const double free_stream_mach = rCurrentProcessInfo[FREE_STREAM_MACH]; From 8f1f1eb749dcb4012556825b1b79e1872dac84ab Mon Sep 17 00:00:00 2001 From: eloisabaez Date: Wed, 15 Apr 2020 15:29:28 +0200 Subject: [PATCH 154/314] local speed of sound with clamping calc and test --- .../potential_flow_utilities.cpp | 72 +++++++++++++++++++ .../potential_flow_utilities.h | 6 ++ .../test_potential_flow_utilities.cpp | 49 +++++++++++++ 3 files changed, 127 insertions(+) diff --git a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp index 7cda22fd920b..fb3f166bcf2e 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp +++ b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp @@ -446,6 +446,74 @@ double ComputeLocalMachSquaredDerivative( 0.5*(heat_capacity_ratio - 1)*(1/sq_free_stream_velocity)*sq_free_stream_mach*(1/square_bracket_term)); } +template +double ComputeMaximumVelocitySquared(const ProcessInfo& rCurrentProcessInfo) +{ + + // Following Fully Simulataneous Coupling of the Full Potential Equation + // and the Integral Boundary Layer Equations in Three Dimensions + // by Brian Nishida (1996), Section A.2 and Section 2.5 + + // make square of maximum local mach number + double sq_max_local_mach_number = 3.0; + + // read free stream values + const double heat_capacity_ratio = rCurrentProcessInfo[HEAT_CAPACITY_RATIO]; + const double free_stream_mach = rCurrentProcessInfo[FREE_STREAM_MACH]; + const array_1d free_stream_velocity = rCurrentProcessInfo[FREE_STREAM_VELOCITY]; + + // make squares of values + double sq_free_stream_mach = pow(free_stream_mach, 2); + double sq_free_stream_velocity = inner_prod(free_stream_velocity, free_stream_velocity); + + return sq_max_local_mach_number * sq_free_stream_velocity * + ((sq_free_stream_mach * heat_capacity_ratio - sq_free_stream_mach + 2) / + (sq_free_stream_mach * heat_capacity_ratio * sq_max_local_mach_number + - sq_max_local_mach_number * sq_free_stream_mach + 2 * sq_free_stream_mach)); +} + +template +double ComputeLocalSpeedofSoundSquared( + const array_1d& rVelocity, + const ProcessInfo& rCurrentProcessInfo) +{ + // Implemented according to Equation 8.7 of Drela, M. (2014) Flight Vehicle + // Aerodynamics, The MIT Press, London and + + // read free stream values + const double heat_capacity_ratio = rCurrentProcessInfo[HEAT_CAPACITY_RATIO]; + const double free_stream_mach = rCurrentProcessInfo[FREE_STREAM_MACH]; + const array_1d free_stream_velocity = rCurrentProcessInfo[FREE_STREAM_VELOCITY]; + const double free_stream_speed_sound = rCurrentProcessInfo[SOUND_VELOCITY]; + + // make squares of values + double sq_free_stream_mach = pow(free_stream_mach, 2); + double sq_free_stream_speed_sound = pow(free_stream_speed_sound,2); + double sq_local_velocity = inner_prod(rVelocity, rVelocity); + double sq_free_stream_velocity = inner_prod(free_stream_velocity, free_stream_velocity); + + // check if velocity is over max allowed velocity + double sq_max_velocity = ComputeMaximumVelocitySquared(rCurrentProcessInfo); + + if (sq_local_velocity > sq_max_velocity) + { + KRATOS_WARNING("Clamped local velocity") << + "SQUARE OF LOCAL VELOCITY ABOVE ALLOWED SQUARE OF VELOCITY" + << " sq_local_velocity = " << sq_max_velocity + << " sq_max_velocity = " << sq_max_velocity << std::endl; + + sq_local_velocity = sq_max_velocity; + } + + // square bracket term + double square_bracket_term = 1.0 + 0.5*(heat_capacity_ratio - 1)* + sq_free_stream_mach*(1 - (sq_local_velocity/sq_free_stream_velocity)); + + return sq_free_stream_speed_sound * square_bracket_term; + +} + + /////////////////////////////////////////////////////////////////////////////////////////////////// // Template instantiation @@ -474,6 +542,8 @@ template bool CheckIfElementIsCutByDistance<2, 3>(const BoundedVector template void KRATOS_API(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION) CheckIfWakeConditionsAreFulfilled<2>(const ModelPart&, const double& rTolerance, const int& rEchoLevel); template bool CheckWakeCondition<2, 3>(const Element& rElement, const double& rTolerance, const int& rEchoLevel); template double ComputeLocalMachSquaredDerivative<2, 3>(const array_1d& velocity, const double& local_mach_number, const ProcessInfo& rCurrentProcessInfo); +template double ComputeMaximumVelocitySquared<2, 3>(const ProcessInfo& rCurrentProcessInfo); +template double ComputeLocalSpeedofSoundSquared<2, 3>(const array_1d& rVelocity,const ProcessInfo& rCurrentProcessInfo); // 3D template array_1d GetWakeDistances<3, 4>(const Element& rElement); @@ -500,6 +570,8 @@ template bool CheckIfElementIsCutByDistance<3, 4>(const BoundedVector template void KRATOS_API(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION) CheckIfWakeConditionsAreFulfilled<3>(const ModelPart&, const double& rTolerance, const int& rEchoLevel); template bool CheckWakeCondition<3, 4>(const Element& rElement, const double& rTolerance, const int& rEchoLevel); template double ComputeLocalMachSquaredDerivative<3, 4>(const array_1d& velocity, const double& local_mach_number, const ProcessInfo& rCurrentProcessInfo); +template double ComputeMaximumVelocitySquared<3, 4>(const ProcessInfo& rCurrentProcessInfo); +template double ComputeLocalSpeedofSoundSquared<3, 4>(const array_1d& rVelocity,const ProcessInfo& rCurrentProcessInfo); } // namespace PotentialFlow } // namespace Kratos diff --git a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h index 228f4fa5b855..e57fa08eb330 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h +++ b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h @@ -102,6 +102,12 @@ bool CheckWakeCondition(const Element& rElement, const double& rTolerance, const template double ComputeLocalMachSquaredDerivative(const array_1d& velocity, const double& local_mach_number,const ProcessInfo& rCurrentProcessInfo); +template +double ComputeMaximumVelocitySquared(const ProcessInfo& rCurrentProcessInfo); + +template +double ComputeLocalSpeedofSoundSquared(const array_1d& rVelocity,const ProcessInfo& rCurrentProcessInfo); + } // namespace PotentialFlow } // namespace Kratos diff --git a/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp b/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp index c63b8528f3e8..972c66595f16 100644 --- a/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp +++ b/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp @@ -219,5 +219,54 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeLocalMachSquaredDerivativeSupersonicMach, Compr KRATOS_CHECK_NEAR(mach_derivative, reference_derivative, 1e-16); } +// Checks the function ComputeMaximumVelocitySquared from the utilities +KRATOS_TEST_CASE_IN_SUITE(ComputeMaximumVelocitySquared, CompressiblePotentialApplicationFastSuite) { + Model this_model; + ModelPart& model_part = this_model.CreateModelPart("Main", 3); + + model_part.GetProcessInfo()[FREE_STREAM_DENSITY] = 1.225; + model_part.GetProcessInfo()[FREE_STREAM_MACH] = 0.6; + model_part.GetProcessInfo()[HEAT_CAPACITY_RATIO] = 1.4; + model_part.GetProcessInfo()[SOUND_VELOCITY] = 340.0; + + BoundedVector free_stream_velocity = ZeroVector(3); + free_stream_velocity(0) = model_part.GetProcessInfo().GetValue(FREE_STREAM_MACH) * + model_part.GetProcessInfo().GetValue(SOUND_VELOCITY); + model_part.GetProcessInfo()[FREE_STREAM_VELOCITY] = free_stream_velocity; + + // Max local Mach number = sqrt(3.0), hard coded in ComputeMaximumVelocitySquared + + double reference_sq_max_velocity = 232356.0000000000000000; + + double sq_max_velocity = PotentialFlowUtilities::ComputeMaximumVelocitySquared<2, 3>(model_part.GetProcessInfo()); + + KRATOS_CHECK_NEAR(sq_max_velocity, reference_sq_max_velocity, 1e-10); +} + +// Checks ComputeLocalSpeedofSoundSquared in utilities, local velocity that should be clamped +KRATOS_TEST_CASE_IN_SUITE(ComputeLocalSpeedofSoundSquared, CompressiblePotentialApplicationFastSuite) { + Model this_model; + ModelPart& model_part = this_model.CreateModelPart("Main", 3); + + model_part.GetProcessInfo()[FREE_STREAM_DENSITY] = 1.225; + model_part.GetProcessInfo()[FREE_STREAM_MACH] = 0.6; + model_part.GetProcessInfo()[HEAT_CAPACITY_RATIO] = 1.4; + model_part.GetProcessInfo()[SOUND_VELOCITY] = 340.0; + + BoundedVector free_stream_velocity = ZeroVector(3); + free_stream_velocity(0) = model_part.GetProcessInfo().GetValue(FREE_STREAM_MACH) * + model_part.GetProcessInfo().GetValue(SOUND_VELOCITY); + model_part.GetProcessInfo()[FREE_STREAM_VELOCITY] = free_stream_velocity; + + array_1d velocity(2, 0.0); + velocity[0] = 350000.0; + + double sq_local_speed_sound = PotentialFlowUtilities::ComputeLocalSpeedofSoundSquared<2,3>(velocity, model_part.GetProcessInfo()); + + double reference_sq_local_speed_sound = 77452.0000000000; + + KRATOS_CHECK_NEAR(sq_local_speed_sound, reference_sq_local_speed_sound, 1e-16); +} + } // namespace Testing } // namespace Kratos. From a164d1232d7f40ed5b406570761f087dd3114245 Mon Sep 17 00:00:00 2001 From: eloisabaez Date: Wed, 15 Apr 2020 17:20:16 +0200 Subject: [PATCH 155/314] local mach number squared and test --- .../potential_flow_utilities.cpp | 45 ++++++++++++++++++- .../potential_flow_utilities.h | 3 ++ .../test_potential_flow_utilities.cpp | 35 +++++++++++++-- 3 files changed, 78 insertions(+), 5 deletions(-) diff --git a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp index fb3f166bcf2e..fd7f9e19c580 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp +++ b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp @@ -437,6 +437,19 @@ double ComputeLocalMachSquaredDerivative( double sq_local_velocity = inner_prod(velocity, velocity); double sq_free_stream_velocity = inner_prod(free_stream_velocity, free_stream_velocity); + // check if velocity is over max allowed velocity + double sq_max_velocity = ComputeMaximumVelocitySquared(rCurrentProcessInfo); + + if (sq_local_velocity > sq_max_velocity) + { + KRATOS_WARNING("Clamped local velocity") << + "SQUARE OF LOCAL VELOCITY ABOVE ALLOWED SQUARE OF VELOCITY" + << " sq_local_velocity = " << sq_max_velocity + << " sq_max_velocity = " << sq_max_velocity << std::endl; + + sq_local_velocity = sq_max_velocity; + } + // square bracket term double square_bracket_term = 1.0 + 0.5*(heat_capacity_ratio - 1)* sq_free_stream_mach*(1 - (sq_local_velocity/sq_free_stream_velocity)); @@ -478,7 +491,7 @@ double ComputeLocalSpeedofSoundSquared( const ProcessInfo& rCurrentProcessInfo) { // Implemented according to Equation 8.7 of Drela, M. (2014) Flight Vehicle - // Aerodynamics, The MIT Press, London and + // Aerodynamics, The MIT Press, London // read free stream values const double heat_capacity_ratio = rCurrentProcessInfo[HEAT_CAPACITY_RATIO]; @@ -510,10 +523,38 @@ double ComputeLocalSpeedofSoundSquared( sq_free_stream_mach*(1 - (sq_local_velocity/sq_free_stream_velocity)); return sq_free_stream_speed_sound * square_bracket_term; +} +template +double ComputeLocalMachNumberSquared( + const array_1d& rVelocity, + const ProcessInfo& rCurrentProcessInfo) +{ + // Implemented according to Equation 8.8 of Drela, M. (2014) Flight Vehicle + // Aerodynamics, The MIT Press, London + + double sq_local_speed_of_sound = ComputeLocalSpeedofSoundSquared(rVelocity, rCurrentProcessInfo); + + double sq_local_velocity = inner_prod(rVelocity, rVelocity); + + // check if velocity is over max allowed velocity + double sq_max_velocity = ComputeMaximumVelocitySquared(rCurrentProcessInfo); + + if (sq_local_velocity > sq_max_velocity) + { + KRATOS_WARNING("ComputeLocalMachNumberSquared: Clamped local velocity") << + "SQUARE OF LOCAL VELOCITY ABOVE ALLOWED SQUARE OF VELOCITY" + << " sq_local_velocity = " << sq_max_velocity + << " sq_max_velocity = " << sq_max_velocity << std::endl; + + sq_local_velocity = sq_max_velocity; + } + + return sq_local_velocity / sq_local_speed_of_sound; } + /////////////////////////////////////////////////////////////////////////////////////////////////// // Template instantiation @@ -544,6 +585,7 @@ template bool CheckWakeCondition<2, 3>(const Element& rElement, const double& rT template double ComputeLocalMachSquaredDerivative<2, 3>(const array_1d& velocity, const double& local_mach_number, const ProcessInfo& rCurrentProcessInfo); template double ComputeMaximumVelocitySquared<2, 3>(const ProcessInfo& rCurrentProcessInfo); template double ComputeLocalSpeedofSoundSquared<2, 3>(const array_1d& rVelocity,const ProcessInfo& rCurrentProcessInfo); +template double ComputeLocalMachNumberSquared<2, 3>(const array_1d& rVelocity, const ProcessInfo& rCurrentProcessInfo); // 3D template array_1d GetWakeDistances<3, 4>(const Element& rElement); @@ -572,6 +614,7 @@ template bool CheckWakeCondition<3, 4>(const Element& rElement, const double& rT template double ComputeLocalMachSquaredDerivative<3, 4>(const array_1d& velocity, const double& local_mach_number, const ProcessInfo& rCurrentProcessInfo); template double ComputeMaximumVelocitySquared<3, 4>(const ProcessInfo& rCurrentProcessInfo); template double ComputeLocalSpeedofSoundSquared<3, 4>(const array_1d& rVelocity,const ProcessInfo& rCurrentProcessInfo); +template double ComputeLocalMachNumberSquared<3, 4>(const array_1d& rVelocity, const ProcessInfo& rCurrentProcessInfo); } // namespace PotentialFlow } // namespace Kratos diff --git a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h index e57fa08eb330..13afa733ab82 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h +++ b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h @@ -108,6 +108,9 @@ double ComputeMaximumVelocitySquared(const ProcessInfo& rCurrentProcessInfo); template double ComputeLocalSpeedofSoundSquared(const array_1d& rVelocity,const ProcessInfo& rCurrentProcessInfo); +template +double ComputeLocalMachNumberSquared(const array_1d& rVelocity, const ProcessInfo& rCurrentProcessInfo); + } // namespace PotentialFlow } // namespace Kratos diff --git a/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp b/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp index 972c66595f16..ae62bfdcef85 100644 --- a/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp +++ b/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp @@ -181,7 +181,8 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeLocalMachSquaredDerivativeTransonicMach, Compre array_1d velocity(2, 0.0); velocity[0] = 68.0 * sqrt(67.0/3.0); - double local_mach_number = 1.0; + double sq_local_mach_number = PotentialFlowUtilities::ComputeLocalMachNumberSquared<2, 3>(velocity, model_part.GetProcessInfo()); + double local_mach_number = sqrt(sq_local_mach_number); auto mach_derivative = PotentialFlowUtilities::ComputeLocalMachSquaredDerivative<2, 3>(velocity, local_mach_number, model_part.GetProcessInfo()); @@ -209,12 +210,13 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeLocalMachSquaredDerivativeSupersonicMach, Compr array_1d velocity(2, 0.0); velocity[0] = 272.0 * sqrt(134.0/21.0); - const double local_mach_number = 4.0; + double sq_local_mach_number = PotentialFlowUtilities::ComputeLocalMachNumberSquared<2, 3>(velocity, model_part.GetProcessInfo()); + double local_mach_number = sqrt(sq_local_mach_number); double mach_derivative = PotentialFlowUtilities::ComputeLocalMachSquaredDerivative<2, 3>(velocity, local_mach_number, model_part.GetProcessInfo()); - - double reference_derivative = 0.000142346227340804; + + double reference_derivative = 2.06579558952642e-05; KRATOS_CHECK_NEAR(mach_derivative, reference_derivative, 1e-16); } @@ -268,5 +270,30 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeLocalSpeedofSoundSquared, CompressiblePotential KRATOS_CHECK_NEAR(sq_local_speed_sound, reference_sq_local_speed_sound, 1e-16); } +// Checks ComputeLocalMachNumberSquared in utilities, local velocity that should be clamped +KRATOS_TEST_CASE_IN_SUITE(ComputeLocalMachNumberSquared, CompressiblePotentialApplicationFastSuite) { + Model this_model; + ModelPart& model_part = this_model.CreateModelPart("Main", 3); + + model_part.GetProcessInfo()[FREE_STREAM_DENSITY] = 1.225; + model_part.GetProcessInfo()[FREE_STREAM_MACH] = 0.6; + model_part.GetProcessInfo()[HEAT_CAPACITY_RATIO] = 1.4; + model_part.GetProcessInfo()[SOUND_VELOCITY] = 340.0; + + BoundedVector free_stream_velocity = ZeroVector(3); + free_stream_velocity(0) = model_part.GetProcessInfo().GetValue(FREE_STREAM_MACH) * + model_part.GetProcessInfo().GetValue(SOUND_VELOCITY); + model_part.GetProcessInfo()[FREE_STREAM_VELOCITY] = free_stream_velocity; + + array_1d velocity(2, 0.0); + velocity[0] = 350000.0; + + double sq_local_mach_number = PotentialFlowUtilities::ComputeLocalMachNumberSquared<2, 3>(velocity, model_part.GetProcessInfo()); + + double reference_sq_local_mach_number = 3.0; + + KRATOS_CHECK_NEAR(sq_local_mach_number, reference_sq_local_mach_number, 1e-10); +} + } // namespace Testing } // namespace Kratos. From 7e3a4cdba8a1a66454c17fc0dd9af4e6c42aa27e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Wed, 15 Apr 2020 19:53:43 +0200 Subject: [PATCH 156/314] [Core] Transition changes for #5939 This is a transition PR in order to adapt TestLinearMultipointConstraints in transition for #5939 --- kratos/tests/test_linear_constraints.py | 415 ++++++++++++++---------- 1 file changed, 236 insertions(+), 179 deletions(-) diff --git a/kratos/tests/test_linear_constraints.py b/kratos/tests/test_linear_constraints.py index 1da2f61a5b4a..b5f22d774b1d 100644 --- a/kratos/tests/test_linear_constraints.py +++ b/kratos/tests/test_linear_constraints.py @@ -1,11 +1,13 @@ from __future__ import print_function, absolute_import, division -import KratosMultiphysics + +# Importing the Kratos Library +import KratosMultiphysics as KM import KratosMultiphysics.KratosUnittest as KratosUnittest import KratosMultiphysics.kratos_utilities as KratosUtils import math if KratosUtils.CheckIfApplicationsAvailable("StructuralMechanicsApplication"): - import KratosMultiphysics.StructuralMechanicsApplication as StructuralMechanicsApplication + import KratosMultiphysics.StructuralMechanicsApplication as SMA def inner_prod(a,b): tmp = 0 @@ -18,98 +20,76 @@ def setUp(self): pass def _add_variables(self): - self.mp.AddNodalSolutionStepVariable(KratosMultiphysics.DISPLACEMENT) - self.mp.AddNodalSolutionStepVariable(KratosMultiphysics.REACTION) - self.mp.AddNodalSolutionStepVariable(KratosMultiphysics.VELOCITY) - self.mp.AddNodalSolutionStepVariable(KratosMultiphysics.ACCELERATION) - self.mp.AddNodalSolutionStepVariable(KratosMultiphysics.VOLUME_ACCELERATION) + self.mp.AddNodalSolutionStepVariable(KM.DISPLACEMENT) + self.mp.AddNodalSolutionStepVariable(KM.REACTION) + self.mp.AddNodalSolutionStepVariable(KM.VELOCITY) + self.mp.AddNodalSolutionStepVariable(KM.ACCELERATION) + self.mp.AddNodalSolutionStepVariable(KM.VOLUME_ACCELERATION) def _add_dofs(self): - KratosMultiphysics.VariableUtils().AddDof( - KratosMultiphysics.DISPLACEMENT_X, KratosMultiphysics.REACTION_X, - self.mp) - KratosMultiphysics.VariableUtils().AddDof( - KratosMultiphysics.DISPLACEMENT_Y, KratosMultiphysics.REACTION_Y, - self.mp) - KratosMultiphysics.VariableUtils().AddDof( - KratosMultiphysics.DISPLACEMENT_Z, KratosMultiphysics.REACTION_Z, - self.mp) - - KratosMultiphysics.VariableUtils().AddDof( - KratosMultiphysics.VELOCITY_X, self.mp) - KratosMultiphysics.VariableUtils().AddDof( - KratosMultiphysics.VELOCITY_Y, self.mp) - KratosMultiphysics.VariableUtils().AddDof( - KratosMultiphysics.VELOCITY_Z, self.mp) - - KratosMultiphysics.VariableUtils().AddDof( - KratosMultiphysics.ACCELERATION_X, self.mp) - KratosMultiphysics.VariableUtils().AddDof( - KratosMultiphysics.ACCELERATION_Y, self.mp) - KratosMultiphysics.VariableUtils().AddDof( - KratosMultiphysics.ACCELERATION_Z, self.mp) + KM.VariableUtils().AddDof(KM.DISPLACEMENT_X, KM.REACTION_X, self.mp) + KM.VariableUtils().AddDof(KM.DISPLACEMENT_Y, KM.REACTION_Y, self.mp) + KM.VariableUtils().AddDof(KM.DISPLACEMENT_Z, KM.REACTION_Z, self.mp) + + KM.VariableUtils().AddDof(KM.VELOCITY_X, self.mp) + KM.VariableUtils().AddDof(KM.VELOCITY_Y, self.mp) + KM.VariableUtils().AddDof(KM.VELOCITY_Z, self.mp) + + KM.VariableUtils().AddDof(KM.ACCELERATION_X, self.mp) + KM.VariableUtils().AddDof(KM.ACCELERATION_Y, self.mp) + KM.VariableUtils().AddDof(KM.ACCELERATION_Z, self.mp) def _apply_material_properties(self, dim): #define properties - self.mp.GetProperties()[1].SetValue(KratosMultiphysics.YOUNG_MODULUS, 210e9) - self.mp.GetProperties()[1].SetValue(KratosMultiphysics.POISSON_RATIO, 0.3) - self.mp.GetProperties()[1].SetValue(KratosMultiphysics.THICKNESS, 1.0) - self.mp.GetProperties()[1].SetValue(KratosMultiphysics.DENSITY, 1.0) + self.mp.GetProperties()[1].SetValue(KM.YOUNG_MODULUS, 210e9) + self.mp.GetProperties()[1].SetValue(KM.POISSON_RATIO, 0.3) + self.mp.GetProperties()[1].SetValue(KM.THICKNESS, 1.0) + self.mp.GetProperties()[1].SetValue(KM.DENSITY, 1.0) g = [0, 0, 0] - self.mp.GetProperties()[1].SetValue(KratosMultiphysics.VOLUME_ACCELERATION, - g) + self.mp.GetProperties()[1].SetValue(KM.VOLUME_ACCELERATION, g) + self.mp.ProcessInfo[KM.DOMAIN_SIZE] = dim if dim == 2: - cl = KratosMultiphysics.StructuralMechanicsApplication.LinearElasticPlaneStrain2DLaw( - ) + cl = SMA.LinearElasticPlaneStrain2DLaw() else: - cl = KratosMultiphysics.StructuralMechanicsApplication.LinearElastic3DLaw( - ) - self.mp.GetProperties()[1].SetValue(KratosMultiphysics.CONSTITUTIVE_LAW, cl) + cl = SMA.LinearElastic3DLaw() + self.mp.GetProperties()[1].SetValue(KM.CONSTITUTIVE_LAW, cl) def _apply_BCs(self): bcs = self.mp.GetSubModelPart("FixedEdgeNodes") - KratosMultiphysics.VariableUtils().SetVariable( - KratosMultiphysics.DISPLACEMENT_X, 0.0, bcs.Nodes) - KratosMultiphysics.VariableUtils().SetVariable( - KratosMultiphysics.DISPLACEMENT_Y, 0.0, bcs.Nodes) + KM.VariableUtils().SetVariable(KM.DISPLACEMENT_X, 0.0, bcs.Nodes) + KM.VariableUtils().SetVariable(KM.DISPLACEMENT_Y, 0.0, bcs.Nodes) - KratosMultiphysics.VariableUtils().ApplyFixity( - KratosMultiphysics.DISPLACEMENT_X, True, bcs.Nodes) - KratosMultiphysics.VariableUtils().ApplyFixity( - KratosMultiphysics.DISPLACEMENT_Y, True, bcs.Nodes) + KM.VariableUtils().ApplyFixity(KM.DISPLACEMENT_X, True, bcs.Nodes) + KM.VariableUtils().ApplyFixity(KM.DISPLACEMENT_Y, True, bcs.Nodes) bcmn = self.mp.GetSubModelPart("MovingNodes") - KratosMultiphysics.VariableUtils().SetVariable( - KratosMultiphysics.DISPLACEMENT_X, 0.01, bcmn.Nodes) - KratosMultiphysics.VariableUtils().SetVariable( - KratosMultiphysics.DISPLACEMENT_Y, 0.0, bcmn.Nodes) - KratosMultiphysics.VariableUtils().ApplyFixity( - KratosMultiphysics.DISPLACEMENT_X, True, bcmn.Nodes) - KratosMultiphysics.VariableUtils().ApplyFixity( - KratosMultiphysics.DISPLACEMENT_Y, True, bcmn.Nodes) + KM.VariableUtils().SetVariable(KM.DISPLACEMENT_X, 0.01, bcmn.Nodes) + KM.VariableUtils().SetVariable(KM.DISPLACEMENT_Y, 0.0, bcmn.Nodes) + KM.VariableUtils().ApplyFixity(KM.DISPLACEMENT_X, True, bcmn.Nodes) + KM.VariableUtils().ApplyFixity(KM.DISPLACEMENT_Y, True, bcmn.Nodes) - def _setup_solver(self): + def _setup_solver(self, solving_with = "Block", linear_solver = "AMGCL"): #define a minimal newton raphson solver - self.linear_solver = KratosMultiphysics.SkylineLUFactorizationSolver() - self.builder_and_solver = KratosMultiphysics.ResidualBasedBlockBuilderAndSolver( - self.linear_solver) - self.scheme = KratosMultiphysics.ResidualBasedBossakDisplacementScheme( - -0.01) - self.convergence_criterion = KratosMultiphysics.ResidualCriteria( - 1e-10, 1e-12) + if linear_solver == "AMGCL": + self.linear_solver = KM.AMGCLSolver() + else: + self.linear_solver = KM.SkylineLUFactorizationSolver() + if solving_with == "Block": + self.builder_and_solver = KM.ResidualBasedBlockBuilderAndSolver(self.linear_solver) + else: # Block default + self.builder_and_solver = KM.ResidualBasedBlockBuilderAndSolver(self.linear_solver) + self.scheme = KM.ResidualBasedBossakDisplacementScheme(-0.01) + self.convergence_criterion = KM.ResidualCriteria(1e-6, 1e-9) self.convergence_criterion.SetEchoLevel(0) - max_iters = 100 - compute_reactions = False + max_iters = 10 + compute_reactions = True reform_step_dofs = True move_mesh_flag = False - self.strategy = KratosMultiphysics.ResidualBasedNewtonRaphsonStrategy( - self.mp, self.scheme, self.linear_solver, self.convergence_criterion, - self.builder_and_solver, max_iters, compute_reactions, - reform_step_dofs, move_mesh_flag) + self.strategy = KM.ResidualBasedNewtonRaphsonStrategy(self.mp, self.scheme, self.linear_solver, self.convergence_criterion, self.builder_and_solver, max_iters, compute_reactions, reform_step_dofs, move_mesh_flag) self.strategy.SetEchoLevel(0) self.strategy.Initialize() @@ -125,74 +105,117 @@ def _reset(self): def _solve(self): self.strategy.Solve() - def _check_results(self): - dispx13 = self.mp.Nodes[13].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) + def _basic_check_results(self): + reactionx1 = self.mp.Nodes[1].GetSolutionStepValue(KM.REACTION_X, 0) + self.assertLessEqual(abs((reactionx1 - -1413464323.8223937)/(-1413464323.8223937)), 1.0e-2) + reactiony1 = self.mp.Nodes[1].GetSolutionStepValue(KM.REACTION_Y, 0) + self.assertLessEqual(abs((reactiony1 - -605769230.7692306)/(-605769230.7692306)), 1.0e-2) + + reactionx4 = self.mp.Nodes[4].GetSolutionStepValue(KM.REACTION_X, 0) + self.assertLessEqual(abs((reactionx4 - -1413467109.1832492)/(-1413467109.1832492)), 1.0e-2) + reactiony4 = self.mp.Nodes[4].GetSolutionStepValue(KM.REACTION_Y, 0) + self.assertLessEqual(abs((reactiony4 - 605769230.7692306)/(605769230.7692306)), 1.0e-2) + + dispx3 = self.mp.Nodes[3].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) + self.assertAlmostEqual(dispx3, 0.01, 4) + dispy3 = self.mp.Nodes[3].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) + self.assertAlmostEqual(dispy3, 0.0, 4) + + dispx2 = self.mp.Nodes[2].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) + self.assertAlmostEqual(dispx2, 0.01, 4) + dispy2 = self.mp.Nodes[2].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) + self.assertAlmostEqual(dispy2, 0.0, 4) + + dispx3 = self.mp.Nodes[3].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) + self.assertAlmostEqual(dispx3, 0.01, 4) + dispy3 = self.mp.Nodes[3].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) + self.assertAlmostEqual(dispy3, 0.0, 4) + + def _advanced_check_results(self): + dispx13 = self.mp.Nodes[13].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) self.assertAlmostEqual(dispx13, 0.01, 4) - dispy13 = self.mp.Nodes[13].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) + dispy13 = self.mp.Nodes[13].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) self.assertAlmostEqual(dispy13, 0.0, 4) - dispx14 = self.mp.Nodes[14].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) + dispx14 = self.mp.Nodes[14].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) self.assertAlmostEqual(dispx14, 0.01, 4) - dispy14 = self.mp.Nodes[14].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) + dispy14 = self.mp.Nodes[14].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) self.assertAlmostEqual(dispy14, 0.0, 4) - dispx15 = self.mp.Nodes[15].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) + dispx15 = self.mp.Nodes[15].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) self.assertAlmostEqual(dispx15, 0.01, 4) - dispy15 = self.mp.Nodes[15].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) + dispy15 = self.mp.Nodes[15].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) self.assertAlmostEqual(dispy15, 0.0, 4) - dispx11 = self.mp.Nodes[11].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) + dispx11 = self.mp.Nodes[11].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) self.assertAlmostEqual(dispx11, 0.0077238, 4) - dispy11 = self.mp.Nodes[11].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) + dispy11 = self.mp.Nodes[11].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) self.assertAlmostEqual(dispy11, 0.0, 4) - dispx4 = self.mp.Nodes[4].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) + dispx4 = self.mp.Nodes[4].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) self.assertAlmostEqual(dispx4, 0.0022754, 4) - dispy4 = self.mp.Nodes[4].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) + dispy4 = self.mp.Nodes[4].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) self.assertAlmostEqual(dispy4, 0.0, 4) - disp1 = self.mp.Nodes[16].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) - disp2 = self.mp.Nodes[6].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) + disp1 = self.mp.Nodes[16].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) + disp2 = self.mp.Nodes[6].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) self.assertAlmostEqual(disp1, disp2, 4) self.assertAlmostEqual(disp1, 0.0049994, 4) self.assertAlmostEqual(disp2, 0.0049994, 4) #print("Test 1 :: ", disp1," == ",disp2) - disp1 = self.mp.Nodes[16].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) - disp2 = self.mp.Nodes[6].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) + disp1 = self.mp.Nodes[16].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) + disp2 = self.mp.Nodes[6].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) self.assertAlmostEqual(disp1, disp2, 5) self.assertAlmostEqual(disp1, -0.0011584, 4) self.assertAlmostEqual(disp1, -0.0011584, 4) #print("Test 2 :: ", disp1," == ",disp2) - disp1 = self.mp.Nodes[7].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) - disp2 = self.mp.Nodes[17].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) + disp1 = self.mp.Nodes[7].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) + disp2 = self.mp.Nodes[17].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) self.assertAlmostEqual(disp1, disp2, 4) self.assertAlmostEqual(disp1, 0.0049994, 4) self.assertAlmostEqual(disp2, 0.0049994, 4) #print("Test 3 :: ", disp1," == ",disp2) - disp1 = self.mp.Nodes[7].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) - disp2 = self.mp.Nodes[17].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) + disp1 = self.mp.Nodes[7].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) + disp2 = self.mp.Nodes[17].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) self.assertAlmostEqual(disp1, disp2, 4) #print("Test 4 :: ", disp1," == ",disp2) - disp1 = self.mp.Nodes[18].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) - disp2 = self.mp.Nodes[9].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) + disp1 = self.mp.Nodes[18].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) + disp2 = self.mp.Nodes[9].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) self.assertAlmostEqual(disp1, disp2, 4) self.assertAlmostEqual(disp1, 0.0049994, 4) self.assertAlmostEqual(disp1, 0.0049994, 4) #print("Test 5 :: ", disp1," == ",disp2) - disp1 = self.mp.Nodes[18].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) - disp2 = self.mp.Nodes[9].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) + disp1 = self.mp.Nodes[18].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) + disp2 = self.mp.Nodes[9].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) self.assertAlmostEqual(disp1, disp2, 4) self.assertAlmostEqual(disp1, 0.0011584, 4) self.assertAlmostEqual(disp1, 0.0011584, 4) #print("Test 6 :: ", disp1," == ",disp2) - def _setup_model_part(self): + def _basic_setup_model_part(self): + #create nodes + self.mp.CreateNewNode(1, 0.00000, 0.00000, 0.00000) + self.mp.CreateNewNode(2, 1.00000, 0.00000, 0.00000) + self.mp.CreateNewNode(3, 1.00000, 1.00000, 0.00000) + self.mp.CreateNewNode(4, 0.00000, 1.00000, 0.00000) + + #create a submodelpart for boundary conditions + bcs = self.mp.CreateSubModelPart("FixedEdgeNodes") + bcs.AddNodes([1, 4]) + + bcmn = self.mp.CreateSubModelPart("MovingNodes") + bcmn.AddNodes([2]) + + #create Element + self.mp.CreateNewElement("SmallDisplacementElement2D4N", 1, [1, 2, 3, 4], self.mp.GetProperties()[1]) + + def _advanced_setup_model_part(self): #create nodes self.mp.CreateNewNode(1, 0.00000, 1.00000, 0.00000) self.mp.CreateNewNode(2, 0.00000, 0.50000, 0.00000) @@ -221,59 +244,86 @@ def _setup_model_part(self): bcmn.AddNodes([13, 14, 15]) #create Element - self.mp.CreateNewElement("SmallDisplacementElement2D4N", 1, - [14, 11, 12, 15], self.mp.GetProperties()[1]) - self.mp.CreateNewElement("SmallDisplacementElement2D4N", 2, - [13, 10, 11, 14], self.mp.GetProperties()[1]) - self.mp.CreateNewElement("SmallDisplacementElement2D4N", 3, - [11, 17, 18, 12], self.mp.GetProperties()[1]) - self.mp.CreateNewElement("SmallDisplacementElement2D4N", 4, - [10, 16, 17, 11], self.mp.GetProperties()[1]) - self.mp.CreateNewElement("SmallDisplacementElement2D4N", 5, - [2, 4, 3, 1], self.mp.GetProperties()[1]) - self.mp.CreateNewElement("SmallDisplacementElement2D4N", 6, [5, 8, 4, 2], - self.mp.GetProperties()[1]) - self.mp.CreateNewElement("SmallDisplacementElement2D4N", 7, [4, 7, 6, 3], - self.mp.GetProperties()[1]) - self.mp.CreateNewElement("SmallDisplacementElement2D4N", 8, [8, 9, 7, 4], - self.mp.GetProperties()[1]) - - def _apply_mpc_constraints(self): - - self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 2, self.mp.Nodes[16], KratosMultiphysics.DISPLACEMENT_X, self.mp.Nodes[6], KratosMultiphysics.DISPLACEMENT_X, 1.0, 0) - self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 1, self.mp.Nodes[16], KratosMultiphysics.DISPLACEMENT_Y, self.mp.Nodes[6], KratosMultiphysics.DISPLACEMENT_Y, 1.0, 0) - - - self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 3, self.mp.Nodes[17], KratosMultiphysics.DISPLACEMENT_X, self.mp.Nodes[7], KratosMultiphysics.DISPLACEMENT_X, 1.0, 0) - self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 4, self.mp.Nodes[17], KratosMultiphysics.DISPLACEMENT_Y, self.mp.Nodes[7], KratosMultiphysics.DISPLACEMENT_Y, 1.0, 0) - - self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 5, self.mp.Nodes[18], KratosMultiphysics.DISPLACEMENT_X, self.mp.Nodes[9], KratosMultiphysics.DISPLACEMENT_X, 1.0, 0) - self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 6, self.mp.Nodes[18], KratosMultiphysics.DISPLACEMENT_Y, self.mp.Nodes[9], KratosMultiphysics.DISPLACEMENT_Y, 1.0, 0) + self.mp.CreateNewElement("SmallDisplacementElement2D4N", 1, [14, 11, 12, 15], self.mp.GetProperties()[1]) + self.mp.CreateNewElement("SmallDisplacementElement2D4N", 2, [13, 10, 11, 14], self.mp.GetProperties()[1]) + self.mp.CreateNewElement("SmallDisplacementElement2D4N", 3, [11, 17, 18, 12], self.mp.GetProperties()[1]) + self.mp.CreateNewElement("SmallDisplacementElement2D4N", 4, [10, 16, 17, 11], self.mp.GetProperties()[1]) + self.mp.CreateNewElement("SmallDisplacementElement2D4N", 5, [2, 4, 3, 1], self.mp.GetProperties()[1]) + self.mp.CreateNewElement("SmallDisplacementElement2D4N", 6, [5, 8, 4, 2], self.mp.GetProperties()[1]) + self.mp.CreateNewElement("SmallDisplacementElement2D4N", 7, [4, 7, 6, 3], self.mp.GetProperties()[1]) + self.mp.CreateNewElement("SmallDisplacementElement2D4N", 8, [8, 9, 7, 4], self.mp.GetProperties()[1]) + + def _basic_apply_mpc_constraints(self): + self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 1, self.mp.Nodes[2], KM.DISPLACEMENT_X, self.mp.Nodes[3], KM.DISPLACEMENT_X, 1.0, 0) + self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 2, self.mp.Nodes[2], KM.DISPLACEMENT_Y, self.mp.Nodes[3], KM.DISPLACEMENT_Y, 1.0, 0) + + def _advanced_apply_mpc_constraints(self): + + self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 2, self.mp.Nodes[16], KM.DISPLACEMENT_X, self.mp.Nodes[6], KM.DISPLACEMENT_X, 1.0, 0) + self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 1, self.mp.Nodes[16], KM.DISPLACEMENT_Y, self.mp.Nodes[6], KM.DISPLACEMENT_Y, 1.0, 0) + + + self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 3, self.mp.Nodes[17], KM.DISPLACEMENT_X, self.mp.Nodes[7], KM.DISPLACEMENT_X, 1.0, 0) + self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 4, self.mp.Nodes[17], KM.DISPLACEMENT_Y, self.mp.Nodes[7], KM.DISPLACEMENT_Y, 1.0, 0) + + self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 5, self.mp.Nodes[18], KM.DISPLACEMENT_X, self.mp.Nodes[9], KM.DISPLACEMENT_X, 1.0, 0) + self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 6, self.mp.Nodes[18], KM.DISPLACEMENT_Y, self.mp.Nodes[9], KM.DISPLACEMENT_Y, 1.0, 0) def _set_and_fill_buffer(self, buffer_size, delta_time): # Set buffer size self.mp.SetBufferSize(buffer_size) # Fill buffer - time = self.mp.ProcessInfo[KratosMultiphysics.TIME] + time = self.mp.ProcessInfo[KM.TIME] time = time - delta_time * (buffer_size) - self.mp.ProcessInfo.SetValue(KratosMultiphysics.TIME, time) + self.mp.ProcessInfo.SetValue(KM.TIME, time) for size in range(0, buffer_size): step = size - (buffer_size - 1) - self.mp.ProcessInfo.SetValue(KratosMultiphysics.STEP, step) + self.mp.ProcessInfo.SetValue(KM.STEP, step) time = time + delta_time #delta_time is computed from previous time in process_info self.mp.CloneTimeStep(time) - self.mp.ProcessInfo[KratosMultiphysics.IS_RESTARTED] = False + self.mp.ProcessInfo[KM.IS_RESTARTED] = False - @KratosUnittest.skipIfApplicationsNotAvailable("StructuralMechanicsApplication") - def test_MPC_Constraints(self): + def _basic_setup_test(self, solving_with = "Block", linear_solver = "AMGCL"): + dim = 2 + current_model = KM.Model() + self.mp= current_model.CreateModelPart("MainModelPart") + self.mp.ProcessInfo[KM.DOMAIN_SIZE] = dim + self._add_variables() + self._basic_setup_model_part() + self._add_dofs() + self._apply_material_properties(dim) + + #time integration parameters + dt = 0.002 + time = 0.0 + end_time = 0.01 + step = 0 + + self._set_and_fill_buffer(2, dt) + # Applying boundary conditions + self._apply_BCs() + # Applying constraints + self._basic_apply_mpc_constraints() + # Solving the system of equations + self._setup_solver(solving_with, linear_solver) + + while (time <= end_time): + time = time + dt + step = step + 1 + self.mp.CloneTimeStep(time) + self._solve() + # Checking the results + self._basic_check_results() + self._reset() + + def _advanced_setup_test(self, solving_with = "Block", linear_solver = "AMGCL"): dim = 2 - current_model = KratosMultiphysics.Model() + current_model = KM.Model() self.mp= current_model.CreateModelPart("MainModelPart") - self.mp.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE] = dim self._add_variables() - self._setup_model_part() + self._advanced_setup_model_part() self._add_dofs() self._apply_material_properties(dim) @@ -287,9 +337,9 @@ def test_MPC_Constraints(self): # Applying boundary conditions self._apply_BCs() # Applying constraints - self._apply_mpc_constraints() + self._advanced_apply_mpc_constraints() # Solving the system of equations - self._setup_solver() + self._setup_solver(solving_with, linear_solver) while (time <= end_time): time = time + dt @@ -297,47 +347,54 @@ def test_MPC_Constraints(self): self.mp.CloneTimeStep(time) self._solve() # Checking the results - self._check_results() + self._advanced_check_results() self._reset() + @KratosUnittest.skipIfApplicationsNotAvailable("StructuralMechanicsApplication") + def test_basic_MPC_Constraints(self): + self._basic_setup_test("Block") + + @KratosUnittest.skipIfApplicationsNotAvailable("StructuralMechanicsApplication") + def test_advanced_MPC_Constraints(self): + self._advanced_setup_test("Block", "LU") class TestLinearConstraints(KratosUnittest.TestCase): def setUp(self): pass def _add_variables(self,mp): - mp.AddNodalSolutionStepVariable(KratosMultiphysics.DISPLACEMENT) - mp.AddNodalSolutionStepVariable(KratosMultiphysics.REACTION) - mp.AddNodalSolutionStepVariable(KratosMultiphysics.VOLUME_ACCELERATION) + mp.AddNodalSolutionStepVariable(KM.DISPLACEMENT) + mp.AddNodalSolutionStepVariable(KM.REACTION) + mp.AddNodalSolutionStepVariable(KM.VOLUME_ACCELERATION) def _apply_material_properties(self, mp, dim, small_strain = True): #define properties - mp.GetProperties()[1].SetValue(KratosMultiphysics.YOUNG_MODULUS,210) - mp.GetProperties()[1].SetValue(KratosMultiphysics.POISSON_RATIO,0.3) - mp.GetProperties()[1].SetValue(KratosMultiphysics.THICKNESS,1.0) - mp.GetProperties()[1].SetValue(KratosMultiphysics.DENSITY,1.0) + mp.GetProperties()[1].SetValue(KM.YOUNG_MODULUS,210) + mp.GetProperties()[1].SetValue(KM.POISSON_RATIO,0.3) + mp.GetProperties()[1].SetValue(KM.THICKNESS,1.0) + mp.GetProperties()[1].SetValue(KM.DENSITY,1.0) g = [0,-10.0,0] - mp.GetProperties()[1].SetValue(KratosMultiphysics.VOLUME_ACCELERATION,g) + mp.GetProperties()[1].SetValue(KM.VOLUME_ACCELERATION,g) - cl = StructuralMechanicsApplication.LinearElasticPlaneStrain2DLaw() - mp.GetProperties()[1].SetValue(KratosMultiphysics.CONSTITUTIVE_LAW,cl) + cl = SMA.LinearElasticPlaneStrain2DLaw() + mp.GetProperties()[1].SetValue(KM.CONSTITUTIVE_LAW,cl) def _set_buffer(self,mp): buffer_size = 3 mp.SetBufferSize(buffer_size) # Cycle the buffer. This sets all historical nodal solution step data to # the current value and initializes the time stepping in the process info. - mp.ProcessInfo[KratosMultiphysics.DELTA_TIME] = 1.0 - delta_time = mp.ProcessInfo[KratosMultiphysics.DELTA_TIME] - time = mp.ProcessInfo[KratosMultiphysics.TIME] + mp.ProcessInfo[KM.DELTA_TIME] = 1.0 + delta_time = mp.ProcessInfo[KM.DELTA_TIME] + time = mp.ProcessInfo[KM.TIME] step =-buffer_size time = time - delta_time * buffer_size - mp.ProcessInfo.SetValue(KratosMultiphysics.TIME, time) + mp.ProcessInfo.SetValue(KM.TIME, time) for i in range(0, buffer_size): step = step + 1 time = time + delta_time - mp.ProcessInfo.SetValue(KratosMultiphysics.STEP, step) + mp.ProcessInfo.SetValue(KM.STEP, step) mp.CloneTimeStep(time) def _apply_BCs(self,mp,A,b): @@ -345,10 +402,10 @@ def _apply_BCs(self,mp,A,b): def _create_strategy(self, mp): #define a minimal newton raphson solver - linear_solver = KratosMultiphysics.SkylineLUFactorizationSolver() - builder_and_solver = KratosMultiphysics.ResidualBasedBlockBuilderAndSolver(linear_solver) - scheme = KratosMultiphysics.ResidualBasedIncrementalUpdateStaticScheme() - convergence_criterion = KratosMultiphysics.DisplacementCriteria(1e-13,1e-14) + linear_solver = KM.SkylineLUFactorizationSolver() + builder_and_solver = KM.ResidualBasedBlockBuilderAndSolver(linear_solver) + scheme = KM.ResidualBasedIncrementalUpdateStaticScheme() + convergence_criterion = KM.DisplacementCriteria(1e-13,1e-14) convergence_criterion.SetEchoLevel(0) #max_iters = 1 @@ -356,7 +413,7 @@ def _create_strategy(self, mp): compute_reactions = True reform_step_dofs = True move_mesh_flag = True - strategy = KratosMultiphysics.ResidualBasedNewtonRaphsonStrategy(mp, + strategy = KM.ResidualBasedNewtonRaphsonStrategy(mp, scheme, linear_solver, convergence_criterion, @@ -381,7 +438,7 @@ def _solve_with_strategy(self, strategy, step): def test_constraints(self): dim = 2 - current_model = KratosMultiphysics.Model() + current_model = KM.Model() mp = current_model.CreateModelPart("tl_solid_part") self._add_variables(mp) @@ -397,29 +454,29 @@ def test_constraints(self): n3 = mp.CreateNewNode(3, 0.0, 2.0, 0.0) n4 = mp.CreateNewNode(4, -2.0, 1.0, 0.0) - KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.DISPLACEMENT_X, KratosMultiphysics.REACTION_X,mp) - KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.DISPLACEMENT_Y, KratosMultiphysics.REACTION_Y,mp) - KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.DISPLACEMENT_Z, KratosMultiphysics.REACTION_Z,mp) + KM.VariableUtils().AddDof(KM.DISPLACEMENT_X, KM.REACTION_X,mp) + KM.VariableUtils().AddDof(KM.DISPLACEMENT_Y, KM.REACTION_Y,mp) + KM.VariableUtils().AddDof(KM.DISPLACEMENT_Z, KM.REACTION_Z,mp) mp.CreateNewElement("TotalLagrangianElement2D4N", 1, [1,2,3,4], mp.GetProperties()[1]) #node 1 is completely fixed - n1.Fix(KratosMultiphysics.DISPLACEMENT_X) - n1.Fix(KratosMultiphysics.DISPLACEMENT_Y) + n1.Fix(KM.DISPLACEMENT_X) + n1.Fix(KM.DISPLACEMENT_Y) ################# apply a constraint on node 2 #node2 is at allowed to slide normally to normal2 (taken as normal to the side 1-2) dx = n2.X - n1.X dy = n2.Y - n1.Y - normal_2 = KratosMultiphysics.Array3([dy,-dx,0])/math.sqrt(dx**2+dy**2) + normal_2 = KM.Array3([dy,-dx,0])/math.sqrt(dx**2+dy**2) inner_prod(normal_2,normal_2) - master_dofs_2 = [n2.GetDof(KratosMultiphysics.DISPLACEMENT_Y)] - slave_dofs_2 = [n2.GetDof(KratosMultiphysics.DISPLACEMENT_X)] - RelationMatrix2 = KratosMultiphysics.Matrix(1,1) + master_dofs_2 = [n2.GetDof(KM.DISPLACEMENT_Y)] + slave_dofs_2 = [n2.GetDof(KM.DISPLACEMENT_X)] + RelationMatrix2 = KM.Matrix(1,1) RelationMatrix2[0,0] = -normal_2[1]/normal_2[0] - ConstantVector = KratosMultiphysics.Vector([0.0]) + ConstantVector = KM.Vector([0.0]) - constraint_2 = KratosMultiphysics.LinearMasterSlaveConstraint(2, + constraint_2 = KM.LinearMasterSlaveConstraint(2, master_dofs_2, slave_dofs_2, @@ -432,13 +489,13 @@ def test_constraints(self): #node4 is at allowed to slide normally to normal4 dx = n1.X - n4.X dy = n1.Y - n4.Y - normal_4 = KratosMultiphysics.Array3([dy,-dx,0])/math.sqrt(dx**2+dy**2) - n4.SetValue(KratosMultiphysics.NORMAL, normal_4) #artificially set the normal + normal_4 = KM.Array3([dy,-dx,0])/math.sqrt(dx**2+dy**2) + n4.SetValue(KM.NORMAL, normal_4) #artificially set the normal - constraint_4 = KratosMultiphysics.SlipConstraint(4, - n4.GetDof(KratosMultiphysics.DISPLACEMENT_X), - n4.GetDof(KratosMultiphysics.DISPLACEMENT_Y), - n4.GetValue(KratosMultiphysics.NORMAL) + constraint_4 = KM.SlipConstraint(4, + n4.GetDof(KM.DISPLACEMENT_X), + n4.GetDof(KM.DISPLACEMENT_Y), + n4.GetValue(KM.NORMAL) ) mp.AddMasterSlaveConstraint(constraint_4) @@ -447,17 +504,17 @@ def test_constraints(self): self._solve_with_strategy(strategy,0) ##verify the results - d2 = n2.GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT) - d3 = n3.GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT) - d4 = n4.GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT) + d2 = n2.GetSolutionStepValue(KM.DISPLACEMENT) + d3 = n3.GetSolutionStepValue(KM.DISPLACEMENT) + d4 = n4.GetSolutionStepValue(KM.DISPLACEMENT) self.assertAlmostEqual(d2[0]*normal_2[0] + d2[1]*normal_2[1],0.0, 15) self.assertAlmostEqual(d4[0]*normal_4[0] + d4[1]*normal_4[1],0.0, 15) self.assertAlmostEqual(d3[0], 0.0, 15) #symmetry condition self.assertAlmostEqual(d3[1], 2.0*d2[1], 15) - R2 = n2.GetSolutionStepValue(KratosMultiphysics.REACTION) - R4 = n4.GetSolutionStepValue(KratosMultiphysics.REACTION) + R2 = n2.GetSolutionStepValue(KM.REACTION) + R4 = n4.GetSolutionStepValue(KM.REACTION) nR2 = inner_prod(normal_2, R2) nR4 = inner_prod(normal_4, R4) @@ -473,7 +530,7 @@ def test_constraints(self): self.assertTrue(tang_2.norm_2() < 1e-12) self.assertTrue(tang_4.norm_2() < 1e-12) - self.assertEqual(mp.ProcessInfo[KratosMultiphysics.NL_ITERATION_NUMBER], 5) #4 if using Residual Criteria + self.assertEqual(mp.ProcessInfo[KM.NL_ITERATION_NUMBER], 5) #4 if using Residual Criteria if __name__ == '__main__': KratosUnittest.main() From b3603a1fec8b7a5d44ab2847524b15e6b58e38b0 Mon Sep 17 00:00:00 2001 From: eloisabaez <60355972+eloisabaez@users.noreply.github.com> Date: Thu, 16 Apr 2020 12:27:04 +0200 Subject: [PATCH 157/314] Update applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp Co-Authored-By: Philipp Bucher --- .../custom_utilities/potential_flow_utilities.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp index 7cda22fd920b..8b2383429f10 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp +++ b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp @@ -438,12 +438,12 @@ double ComputeLocalMachSquaredDerivative( double sq_free_stream_velocity = inner_prod(free_stream_velocity, free_stream_velocity); // square bracket term - double square_bracket_term = 1.0 + 0.5*(heat_capacity_ratio - 1)* - sq_free_stream_mach*(1 - (sq_local_velocity/sq_free_stream_velocity)); + double square_bracket_term = 1.0 + 0.5*(heat_capacity_ratio - 1.0)* + sq_free_stream_mach*(1.0 - (sq_local_velocity/sq_free_stream_velocity)); // calculate mach derivative - return sq_local_mach_number * ((1/sq_local_velocity) + - 0.5*(heat_capacity_ratio - 1)*(1/sq_free_stream_velocity)*sq_free_stream_mach*(1/square_bracket_term)); + return sq_local_mach_number * ((1.0/sq_local_velocity) + + 0.5*(heat_capacity_ratio - 1.0)*(1.0/sq_free_stream_velocity)*sq_free_stream_mach*(1.0/square_bracket_term)); } /////////////////////////////////////////////////////////////////////////////////////////////////// From b5a5238b1d95dc0e8addcf369d0fea4cf638ea5f Mon Sep 17 00:00:00 2001 From: eloisabaez Date: Thu, 16 Apr 2020 12:40:42 +0200 Subject: [PATCH 158/314] std::pow and doubles everywhere --- .../custom_utilities/potential_flow_utilities.cpp | 14 +++++++------- .../cpp_tests/test_potential_flow_utilities.cpp | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp index fb3f075ab5c0..3e85cfbce233 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp +++ b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp @@ -432,8 +432,8 @@ double ComputeLocalMachSquaredDerivative( const array_1d free_stream_velocity = rCurrentProcessInfo[FREE_STREAM_VELOCITY]; // make squares of values - double sq_local_mach_number = pow(local_mach_number, 2); - double sq_free_stream_mach = pow(free_stream_mach, 2); + double sq_local_mach_number = std::pow(local_mach_number, 2); + double sq_free_stream_mach = std::pow(free_stream_mach, 2); double sq_local_velocity = inner_prod(velocity, velocity); double sq_free_stream_velocity = inner_prod(free_stream_velocity, free_stream_velocity); @@ -476,7 +476,7 @@ double ComputeMaximumVelocitySquared(const ProcessInfo& rCurrentProcessInfo) const array_1d free_stream_velocity = rCurrentProcessInfo[FREE_STREAM_VELOCITY]; // make squares of values - double sq_free_stream_mach = pow(free_stream_mach, 2); + double sq_free_stream_mach = std::pow(free_stream_mach, 2); double sq_free_stream_velocity = inner_prod(free_stream_velocity, free_stream_velocity); return sq_max_local_mach_number * sq_free_stream_velocity * @@ -500,8 +500,8 @@ double ComputeLocalSpeedofSoundSquared( const double free_stream_speed_sound = rCurrentProcessInfo[SOUND_VELOCITY]; // make squares of values - double sq_free_stream_mach = pow(free_stream_mach, 2); - double sq_free_stream_speed_sound = pow(free_stream_speed_sound,2); + double sq_free_stream_mach = std::pow(free_stream_mach, 2); + double sq_free_stream_speed_sound = std::pow(free_stream_speed_sound,2); double sq_local_velocity = inner_prod(rVelocity, rVelocity); double sq_free_stream_velocity = inner_prod(free_stream_velocity, free_stream_velocity); @@ -519,8 +519,8 @@ double ComputeLocalSpeedofSoundSquared( } // square bracket term - double square_bracket_term = 1.0 + 0.5*(heat_capacity_ratio - 1)* - sq_free_stream_mach*(1 - (sq_local_velocity/sq_free_stream_velocity)); + double square_bracket_term = 1.0 + 0.5*(heat_capacity_ratio - 1.0)* + sq_free_stream_mach*(1.0 - (sq_local_velocity/sq_free_stream_velocity)); return sq_free_stream_speed_sound * square_bracket_term; } diff --git a/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp b/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp index ae62bfdcef85..74113717801a 100644 --- a/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp +++ b/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp @@ -184,7 +184,7 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeLocalMachSquaredDerivativeTransonicMach, Compre double sq_local_mach_number = PotentialFlowUtilities::ComputeLocalMachNumberSquared<2, 3>(velocity, model_part.GetProcessInfo()); double local_mach_number = sqrt(sq_local_mach_number); - auto mach_derivative = PotentialFlowUtilities::ComputeLocalMachSquaredDerivative<2, 3>(velocity, + double mach_derivative = PotentialFlowUtilities::ComputeLocalMachSquaredDerivative<2, 3>(velocity, local_mach_number, model_part.GetProcessInfo()); double reference_derivative = 1.16201001910861e-05; From 80041b5403c5d3aa664a9539cb3f1fee58f9ded9 Mon Sep 17 00:00:00 2001 From: eloisabaez <60355972+eloisabaez@users.noreply.github.com> Date: Thu, 16 Apr 2020 13:18:47 +0200 Subject: [PATCH 159/314] Update applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp Co-Authored-By: Philipp Bucher --- .../custom_utilities/potential_flow_utilities.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp index 8b2383429f10..a952b011282f 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp +++ b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp @@ -418,8 +418,8 @@ bool CheckWakeCondition(const Element& rElement, const double& rTolerance, const template double ComputeLocalMachSquaredDerivative( - const array_1d& velocity, - const double& local_mach_number, + const array_1d& rVelocity, + const double rLocalMachNumber, const ProcessInfo& rCurrentProcessInfo) { // Following Fully Simulataneous Coupling of the Full Potential Equation From 48c609beab3aaaa6c8d9d4d3a36b64cfa621ce12 Mon Sep 17 00:00:00 2001 From: eloisabaez Date: Thu, 16 Apr 2020 13:22:02 +0200 Subject: [PATCH 160/314] appropriate variable names --- .../custom_utilities/potential_flow_utilities.cpp | 10 +++++----- .../custom_utilities/potential_flow_utilities.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp index a952b011282f..ff640f8be5e0 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp +++ b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp @@ -432,9 +432,9 @@ double ComputeLocalMachSquaredDerivative( const array_1d free_stream_velocity = rCurrentProcessInfo[FREE_STREAM_VELOCITY]; // make squares of values - double sq_local_mach_number = pow(local_mach_number, 2); - double sq_free_stream_mach = pow(free_stream_mach, 2); - double sq_local_velocity = inner_prod(velocity, velocity); + double sq_local_mach_number = std::pow(rLocalMachNumber, 2); + double sq_free_stream_mach = std::pow(free_stream_mach, 2); + double sq_local_velocity = inner_prod(rVelocity, rVelocity); double sq_free_stream_velocity = inner_prod(free_stream_velocity, free_stream_velocity); // square bracket term @@ -473,7 +473,7 @@ template double ComputePerturbationLocalMachNumber<2, 3>(const Element& rElement template bool CheckIfElementIsCutByDistance<2, 3>(const BoundedVector& rNodalDistances); template void KRATOS_API(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION) CheckIfWakeConditionsAreFulfilled<2>(const ModelPart&, const double& rTolerance, const int& rEchoLevel); template bool CheckWakeCondition<2, 3>(const Element& rElement, const double& rTolerance, const int& rEchoLevel); -template double ComputeLocalMachSquaredDerivative<2, 3>(const array_1d& velocity, const double& local_mach_number, const ProcessInfo& rCurrentProcessInfo); +template double ComputeLocalMachSquaredDerivative<2, 3>(const array_1d& rVelocity, const double& rLocalMachNumber, const ProcessInfo& rCurrentProcessInfo); // 3D template array_1d GetWakeDistances<3, 4>(const Element& rElement); @@ -499,7 +499,7 @@ template double ComputePerturbationLocalMachNumber<3, 4>(const Element& rElement template bool CheckIfElementIsCutByDistance<3, 4>(const BoundedVector& rNodalDistances); template void KRATOS_API(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION) CheckIfWakeConditionsAreFulfilled<3>(const ModelPart&, const double& rTolerance, const int& rEchoLevel); template bool CheckWakeCondition<3, 4>(const Element& rElement, const double& rTolerance, const int& rEchoLevel); -template double ComputeLocalMachSquaredDerivative<3, 4>(const array_1d& velocity, const double& local_mach_number, const ProcessInfo& rCurrentProcessInfo); +template double ComputeLocalMachSquaredDerivative<3, 4>(const array_1d& rVelocity, const double& rLocalMachNumber, const ProcessInfo& rCurrentProcessInfo); } // namespace PotentialFlow } // namespace Kratos diff --git a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h index 228f4fa5b855..4134c158d2c4 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h +++ b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h @@ -100,7 +100,7 @@ template bool CheckWakeCondition(const Element& rElement, const double& rTolerance, const int& rEchoLevel); template -double ComputeLocalMachSquaredDerivative(const array_1d& velocity, const double& local_mach_number,const ProcessInfo& rCurrentProcessInfo); +double ComputeLocalMachSquaredDerivative(const array_1d& rVelocity, const double& local_mach_number,const ProcessInfo& rCurrentProcessInfo); } // namespace PotentialFlow } // namespace Kratos From 17ff92647505e43aeb9d6203e22a78a144dee554 Mon Sep 17 00:00:00 2001 From: eloisabaez Date: Thu, 16 Apr 2020 13:52:02 +0200 Subject: [PATCH 161/314] fixing issues with variable name --- .../custom_utilities/potential_flow_utilities.cpp | 4 ++-- .../custom_utilities/potential_flow_utilities.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp index 680c702d26cb..41262e5f1b0b 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp +++ b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp @@ -582,7 +582,7 @@ template double ComputePerturbationLocalMachNumber<2, 3>(const Element& rElement template bool CheckIfElementIsCutByDistance<2, 3>(const BoundedVector& rNodalDistances); template void KRATOS_API(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION) CheckIfWakeConditionsAreFulfilled<2>(const ModelPart&, const double& rTolerance, const int& rEchoLevel); template bool CheckWakeCondition<2, 3>(const Element& rElement, const double& rTolerance, const int& rEchoLevel); -template double ComputeLocalMachSquaredDerivative<2, 3>(const array_1d& rVelocity, const double& rLocalMachNumber, const ProcessInfo& rCurrentProcessInfo); +template double ComputeLocalMachSquaredDerivative<2, 3>(const array_1d& rVelocity, const double rLocalMachNumber, const ProcessInfo& rCurrentProcessInfo); template double ComputeMaximumVelocitySquared<2, 3>(const ProcessInfo& rCurrentProcessInfo); template double ComputeLocalSpeedofSoundSquared<2, 3>(const array_1d& rVelocity,const ProcessInfo& rCurrentProcessInfo); template double ComputeLocalMachNumberSquared<2, 3>(const array_1d& rVelocity, const ProcessInfo& rCurrentProcessInfo); @@ -611,7 +611,7 @@ template double ComputePerturbationLocalMachNumber<3, 4>(const Element& rElement template bool CheckIfElementIsCutByDistance<3, 4>(const BoundedVector& rNodalDistances); template void KRATOS_API(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION) CheckIfWakeConditionsAreFulfilled<3>(const ModelPart&, const double& rTolerance, const int& rEchoLevel); template bool CheckWakeCondition<3, 4>(const Element& rElement, const double& rTolerance, const int& rEchoLevel); -template double ComputeLocalMachSquaredDerivative<3, 4>(const array_1d& rVelocity, const double& rLocalMachNumber, const ProcessInfo& rCurrentProcessInfo); +template double ComputeLocalMachSquaredDerivative<3, 4>(const array_1d& rVelocity, const double rLocalMachNumber, const ProcessInfo& rCurrentProcessInfo); template double ComputeMaximumVelocitySquared<3, 4>(const ProcessInfo& rCurrentProcessInfo); template double ComputeLocalSpeedofSoundSquared<3, 4>(const array_1d& rVelocity,const ProcessInfo& rCurrentProcessInfo); template double ComputeLocalMachNumberSquared<3, 4>(const array_1d& rVelocity, const ProcessInfo& rCurrentProcessInfo); diff --git a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h index 85d834b94a3a..adf4a17b792a 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h +++ b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h @@ -100,7 +100,7 @@ template bool CheckWakeCondition(const Element& rElement, const double& rTolerance, const int& rEchoLevel); template -double ComputeLocalMachSquaredDerivative(const array_1d& rVelocity, const double& local_mach_number,const ProcessInfo& rCurrentProcessInfo); +double ComputeLocalMachSquaredDerivative(const array_1d& rVelocity, const double local_mach_number,const ProcessInfo& rCurrentProcessInfo); template double ComputeMaximumVelocitySquared(const ProcessInfo& rCurrentProcessInfo); From f138c4710568114e9b8607b64223ffbaeaef8727 Mon Sep 17 00:00:00 2001 From: eloisabaez Date: Thu, 16 Apr 2020 15:33:19 +0200 Subject: [PATCH 162/314] fixing bug, const variables --- .../custom_utilities/potential_flow_utilities.cpp | 10 +++++----- .../custom_utilities/potential_flow_utilities.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp index ff640f8be5e0..aff7470533b7 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp +++ b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp @@ -432,10 +432,10 @@ double ComputeLocalMachSquaredDerivative( const array_1d free_stream_velocity = rCurrentProcessInfo[FREE_STREAM_VELOCITY]; // make squares of values - double sq_local_mach_number = std::pow(rLocalMachNumber, 2); - double sq_free_stream_mach = std::pow(free_stream_mach, 2); + const double sq_local_mach_number = std::pow(rLocalMachNumber, 2); + const double sq_free_stream_mach = std::pow(free_stream_mach, 2); double sq_local_velocity = inner_prod(rVelocity, rVelocity); - double sq_free_stream_velocity = inner_prod(free_stream_velocity, free_stream_velocity); + const double sq_free_stream_velocity = inner_prod(free_stream_velocity, free_stream_velocity); // square bracket term double square_bracket_term = 1.0 + 0.5*(heat_capacity_ratio - 1.0)* @@ -473,7 +473,7 @@ template double ComputePerturbationLocalMachNumber<2, 3>(const Element& rElement template bool CheckIfElementIsCutByDistance<2, 3>(const BoundedVector& rNodalDistances); template void KRATOS_API(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION) CheckIfWakeConditionsAreFulfilled<2>(const ModelPart&, const double& rTolerance, const int& rEchoLevel); template bool CheckWakeCondition<2, 3>(const Element& rElement, const double& rTolerance, const int& rEchoLevel); -template double ComputeLocalMachSquaredDerivative<2, 3>(const array_1d& rVelocity, const double& rLocalMachNumber, const ProcessInfo& rCurrentProcessInfo); +template double ComputeLocalMachSquaredDerivative<2, 3>(const array_1d& rVelocity, const double rLocalMachNumber, const ProcessInfo& rCurrentProcessInfo); // 3D template array_1d GetWakeDistances<3, 4>(const Element& rElement); @@ -499,7 +499,7 @@ template double ComputePerturbationLocalMachNumber<3, 4>(const Element& rElement template bool CheckIfElementIsCutByDistance<3, 4>(const BoundedVector& rNodalDistances); template void KRATOS_API(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION) CheckIfWakeConditionsAreFulfilled<3>(const ModelPart&, const double& rTolerance, const int& rEchoLevel); template bool CheckWakeCondition<3, 4>(const Element& rElement, const double& rTolerance, const int& rEchoLevel); -template double ComputeLocalMachSquaredDerivative<3, 4>(const array_1d& rVelocity, const double& rLocalMachNumber, const ProcessInfo& rCurrentProcessInfo); +template double ComputeLocalMachSquaredDerivative<3, 4>(const array_1d& rVelocity, const double rLocalMachNumber, const ProcessInfo& rCurrentProcessInfo); } // namespace PotentialFlow } // namespace Kratos diff --git a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h index 4134c158d2c4..af445807e772 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h +++ b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h @@ -100,7 +100,7 @@ template bool CheckWakeCondition(const Element& rElement, const double& rTolerance, const int& rEchoLevel); template -double ComputeLocalMachSquaredDerivative(const array_1d& rVelocity, const double& local_mach_number,const ProcessInfo& rCurrentProcessInfo); +double ComputeLocalMachSquaredDerivative(const array_1d& rVelocity, const double rLocalMachNumber,const ProcessInfo& rCurrentProcessInfo); } // namespace PotentialFlow } // namespace Kratos From b18f4d229c9c8a01e505bbc9ba199738efba62bc Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Fri, 17 Apr 2020 12:10:57 +1000 Subject: [PATCH 163/314] [skip ci] clean up quad element --- .../updated_lagrangian_quadrilateral.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index 4a6a27d2baae..060e4071709a 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -934,30 +934,23 @@ void UpdatedLagrangianQuadrilateral::InitializeSolutionStep( ProcessInfo& rCurre nodal_inertia[j] = Variables.N[i] * (mMP.acceleration[j] - aux_MP_acceleration[j]) * mMP.mass; } - // Add in the predictor velocity increment for central difference explicit // This is the 'previous grid acceleration', which is actually // be the initial particle acceleration mapped to the grid. - if (rCurrentProcessInfo.Has(IS_EXPLICIT_CENTRAL_DIFFERENCE)) - { - if (rCurrentProcessInfo.GetValue(IS_EXPLICIT_CENTRAL_DIFFERENCE)) - { + if (rCurrentProcessInfo.Has(IS_EXPLICIT_CENTRAL_DIFFERENCE)) { + if (rCurrentProcessInfo.GetValue(IS_EXPLICIT_CENTRAL_DIFFERENCE)) { const double& delta_time = rCurrentProcessInfo[DELTA_TIME]; - for (unsigned int j = 0; j < dimension; j++) - { + for (unsigned int j = 0; j < dimension; j++) { nodal_momentum[j] += 0.5 * delta_time * (Variables.N[i] * mMP.acceleration[j]) * mMP.mass; } } } - r_geometry[i].SetLock(); r_geometry[i].FastGetSolutionStepValue(NODAL_MOMENTUM, 0) += nodal_momentum; r_geometry[i].FastGetSolutionStepValue(NODAL_INERTIA, 0) += nodal_inertia; - r_geometry[i].FastGetSolutionStepValue(NODAL_MASS, 0) += Variables.N[i] * mMP.mass; r_geometry[i].UnSetLock(); - } } From 1f08634d7bbf3a72d70ca1010d0a589156cbfcc2 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Fri, 17 Apr 2020 12:11:35 +1000 Subject: [PATCH 164/314] [skip ci] initial add of explicit to updated lagrangian element --- .../custom_elements/updated_lagrangian.cpp | 258 ++++++++++++++---- .../custom_elements/updated_lagrangian.hpp | 27 +- .../custom_elements/updated_lagrangian_UP.cpp | 6 +- .../custom_elements/updated_lagrangian_UP.hpp | 3 +- 4 files changed, 227 insertions(+), 67 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp index 943c8aff2d78..142536958286 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp @@ -25,6 +25,7 @@ #include "particle_mechanics_application_variables.h" #include "includes/checks.h" #include "custom_utilities/mpm_energy_calculation_utility.h" +#include "custom_utilities/mpm_explicit_utilities.h" namespace Kratos { @@ -298,30 +299,35 @@ void UpdatedLagrangian::CalculateElementalSystem( LocalSystemComponents& rLocalS // Set constitutive law flags: Flags &ConstitutiveLawOptions=Values.GetOptions(); - ConstitutiveLawOptions.Set(ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN); - ConstitutiveLawOptions.Set(ConstitutiveLaw::COMPUTE_STRESS); ConstitutiveLawOptions.Set(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR); - // Auxiliary terms - Vector volume_force; + if (!rCurrentProcessInfo.GetValue(IS_EXPLICIT)) + { + ConstitutiveLawOptions.Set(ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN); + ConstitutiveLawOptions.Set(ConstitutiveLaw::COMPUTE_STRESS); - // Compute element kinematics B, F, DN_DX ... - this->CalculateKinematics(Variables,rCurrentProcessInfo); + // Compute element kinematics B, F, DN_DX ... + this->CalculateKinematics(Variables, rCurrentProcessInfo); - // Set general variables to constitutivelaw parameters - this->SetGeneralVariables(Variables,Values); + // Set general variables to constitutivelaw parameters + this->SetGeneralVariables(Variables, Values); - // Calculate Material Response - /* NOTE: - The function below will call CalculateMaterialResponseCauchy() by default and then (may) - call CalculateMaterialResponseKirchhoff() in the constitutive_law.*/ - mConstitutiveLawVector->CalculateMaterialResponse(Values, Variables.StressMeasure); + // Calculate Material Response + /* NOTE: + The function below will call CalculateMaterialResponseCauchy() by default and then (may) + call CalculateMaterialResponseKirchhoff() in the constitutive_law.*/ + mConstitutiveLawVector->CalculateMaterialResponse(Values, Variables.StressMeasure); - /* NOTE: - The material points will have constant mass as defined at the beginning. - However, the density and volume (integration weight) are changing every time step.*/ - // Update MP_Density - mMP.density = (GetProperties()[DENSITY]) / Variables.detFT; + /* NOTE: + The material points will have constant mass as defined at the beginning. + However, the density and volume (integration weight) are changing every time step.*/ + // Update MP_Density + mMP.density = (GetProperties()[DENSITY]) / Variables.detFT; + } + else if (rCurrentProcessInfo.GetValue(IS_EXPLICIT)) + { + rLocalSystem.CalculationFlags.Set(UpdatedLagrangian::COMPUTE_LHS_MATRIX, false); + } // The MP_Volume (integration weight) is evaluated mMP.volume = mMP.mass / mMP.density; @@ -335,8 +341,8 @@ void UpdatedLagrangian::CalculateElementalSystem( LocalSystemComponents& rLocalS if ( rLocalSystem.CalculationFlags.Is(UpdatedLagrangian::COMPUTE_RHS_VECTOR) ) // if calculation of the vector is required { // Contribution to forces (in residual term) are calculated - volume_force = this->CalculateVolumeForce( volume_force, Variables ); - this->CalculateAndAddRHS ( rLocalSystem, Variables, volume_force, mMP.volume); + Vector volume_force = mMP.volume_acceleration * mMP.mass; + this->CalculateAndAddRHS ( rLocalSystem, Variables, volume_force, mMP.volume,rCurrentProcessInfo); } KRATOS_CATCH( "" ) @@ -456,7 +462,11 @@ void UpdatedLagrangian::CalculateDeformationMatrix(Matrix& rB, //************************************************************************************ //************************************************************************************ -void UpdatedLagrangian::CalculateAndAddRHS(LocalSystemComponents& rLocalSystem, GeneralVariables& rVariables, Vector& rVolumeForce, const double& rIntegrationWeight) +void UpdatedLagrangian::CalculateAndAddRHS(LocalSystemComponents& rLocalSystem, + GeneralVariables& rVariables, + Vector& rVolumeForce, + const double& rIntegrationWeight, + const ProcessInfo& rCurrentProcessInfo) { // Contribution of the internal and external forces if( rLocalSystem.CalculationFlags.Is( UpdatedLagrangian::COMPUTE_RHS_VECTOR_WITH_COMPONENTS ) ) @@ -490,8 +500,18 @@ void UpdatedLagrangian::CalculateAndAddRHS(LocalSystemComponents& rLocalSystem, // Operation performed: rRightHandSideVector += ExtForce*IntToReferenceWeight this->CalculateAndAddExternalForces( rRightHandSideVector, rVariables, rVolumeForce, rIntegrationWeight ); - // Operation performed: rRightHandSideVector -= IntForce*IntToReferenceWeight - this->CalculateAndAddInternalForces( rRightHandSideVector, rVariables, rIntegrationWeight ); + if (rCurrentProcessInfo.GetValue(IS_EXPLICIT)) + { + MPMExplicitUtilities::CalcuateAndAddExplicitInternalForce(*this, + mDN_DX, mMP.cauchy_stress_vector, mMP.volume, rRightHandSideVector); + } + else + { + // Operation performed: rRightHandSideVector -= IntForce*IntToReferenceWeight + this->CalculateAndAddInternalForces(rRightHandSideVector, rVariables, rIntegrationWeight); + } + + } } @@ -537,6 +557,66 @@ void UpdatedLagrangian::CalculateAndAddInternalForces(VectorType& rRightHandSide //************************************************************************************ //************************************************************************************ +void UpdatedLagrangian::CalculateExplicitStresses(const ProcessInfo& rCurrentProcessInfo, + GeneralVariables& rVariables) +{ + KRATOS_TRY + + // Create constitutive law parameters: + ConstitutiveLaw::Parameters Values(GetGeometry(), GetProperties(), rCurrentProcessInfo); + + // Define the stress measure + rVariables.StressMeasure = ConstitutiveLaw::StressMeasure_Cauchy; + + // Set constitutive law flags: + Flags& ConstitutiveLawOptions = Values.GetOptions(); + ConstitutiveLawOptions.Set(ConstitutiveLaw::COMPUTE_STRESS, true); + + // use element provided strain incremented from velocity gradient + ConstitutiveLawOptions.Set(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR, true); + ConstitutiveLawOptions.Set(ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN, false); + + + // Compute explicit element kinematics, strain is incremented here. + MPMExplicitUtilities::CalculateExplicitKinematics(rCurrentProcessInfo, *this, mDN_DX, + mMP.almansi_strain_vector, rVariables.F); + rVariables.StressVector = mMP.cauchy_stress_vector; + rVariables.StrainVector = mMP.almansi_strain_vector; + + // Update gradient deformation + rVariables.F0 = mDeformationGradientF0; // total member def grad NOT including this increment + rVariables.FT = prod(rVariables.F, rVariables.F0); // total def grad including this increment + rVariables.detF = MathUtils::Det(rVariables.F); // det of current increment + rVariables.detF0 = MathUtils::Det(rVariables.F0); // det of def grad NOT including this increment + rVariables.detFT = MathUtils::Det(rVariables.FT); // det of total def grad including this increment + mDeformationGradientF0 = rVariables.FT; // update member internal total grad def + mDeterminantF0 = rVariables.detFT; // update member internal total grad def det + + // Update MP volume + if (rCurrentProcessInfo.GetValue(IS_COMPRESSIBLE)) + { + mMP.density = (GetProperties()[DENSITY]) / rVariables.detFT; + mMP.volume = mMP.mass / mMP.density; + } + + rVariables.CurrentDisp = CalculateCurrentDisp(rVariables.CurrentDisp, rCurrentProcessInfo); + rVariables.DN_DX = mDN_DX; + rVariables.N = mN; + + // Set general variables to constitutivelaw parameters + this->SetGeneralVariables(rVariables, Values); + + // Calculate Material Response + /* NOTE: + The function below will call CalculateMaterialResponseCauchy() by default and then (may) + call CalculateMaterialResponseKirchhoff() in the constitutive_law.*/ + mConstitutiveLawVector->CalculateMaterialResponse(Values, rVariables.StressMeasure); + + KRATOS_CATCH("") +} +//************************************************************************************ +//************************************************************************************ + void UpdatedLagrangian::CalculateAndAddLHS(LocalSystemComponents& rLocalSystem, GeneralVariables& rVariables, const double& rIntegrationWeight, const ProcessInfo& rCurrentProcessInfo) { @@ -626,23 +706,6 @@ double& UpdatedLagrangian::CalculateVolumeChange( double& rVolumeChange, General KRATOS_CATCH( "" ) } -//************************************CALCULATE VOLUME ACCELERATION******************* -//************************************************************************************ - -Vector& UpdatedLagrangian::CalculateVolumeForce( Vector& rVolumeForce, GeneralVariables& rVariables ) -{ - KRATOS_TRY - - const unsigned int dimension = GetGeometry().WorkingSpaceDimension(); - - rVolumeForce = ZeroVector(dimension); - rVolumeForce = mMP.volume_acceleration * mMP.mass; - - return rVolumeForce; - - KRATOS_CATCH( "" ) -} - //************************************************************************************ //************************************************************************************ void UpdatedLagrangian::CalculateRightHandSide( VectorType& rRightHandSideVector, ProcessInfo& rCurrentProcessInfo ) @@ -815,31 +878,44 @@ void UpdatedLagrangian::InitializeSolutionStep( ProcessInfo& rCurrentProcessInfo const unsigned int number_of_nodes = r_geometry.PointsNumber(); GeneralVariables Variables; - // Calculating shape function - Variables.N = this->MPMShapeFunctionPointValues(Variables.N, mMP.xg); - mFinalizedStep = false; + // Calculating shape function and gradients + Variables.N = this->MPMShapeFunctionPointValues(Variables.N, mMP.xg); + mN = Variables.N; + Matrix Jacobian; + Jacobian = this->MPMJacobian(Jacobian, mMP.xg); + Matrix InvJ; + double detJ; + MathUtils::InvertMatrix(Jacobian, InvJ, detJ); + Matrix DN_De; + this->MPMShapeFunctionsLocalGradients(DN_De); // parametric gradients + mDN_DX = prod(DN_De, InvJ); // cartesian gradients + + array_1d aux_MP_velocity = ZeroVector(3); array_1d aux_MP_acceleration = ZeroVector(3); array_1d nodal_momentum = ZeroVector(3); array_1d nodal_inertia = ZeroVector(3); - for (unsigned int j=0; j nodal_acceleration = ZeroVector(3); - if (r_geometry[j].SolutionStepsDataHas(ACCELERATION)) - nodal_acceleration = r_geometry[j].FastGetSolutionStepValue(ACCELERATION,1); + for (unsigned int j = 0; j < number_of_nodes; j++) + { + // These are the values of nodal velocity and nodal acceleration evaluated in the initialize solution step + array_1d nodal_acceleration = ZeroVector(3); + if (r_geometry[j].SolutionStepsDataHas(ACCELERATION)) + nodal_acceleration = r_geometry[j].FastGetSolutionStepValue(ACCELERATION, 1); - array_1d nodal_velocity = ZeroVector(3); - if (r_geometry[j].SolutionStepsDataHas(VELOCITY)) - nodal_velocity = r_geometry[j].FastGetSolutionStepValue(VELOCITY,1); + array_1d nodal_velocity = ZeroVector(3); + if (r_geometry[j].SolutionStepsDataHas(VELOCITY)) + nodal_velocity = r_geometry[j].FastGetSolutionStepValue(VELOCITY, 1); - for (unsigned int k = 0; k < dimension; k++) - { - aux_MP_velocity[k] += Variables.N[j] * nodal_velocity[k]; - aux_MP_acceleration[k] += Variables.N[j] * nodal_acceleration[k]; + for (unsigned int k = 0; k < dimension; k++) + { + aux_MP_velocity[k] += Variables.N[j] * nodal_velocity[k]; + aux_MP_acceleration[k] += Variables.N[j] * nodal_acceleration[k]; + } } } @@ -853,13 +929,23 @@ void UpdatedLagrangian::InitializeSolutionStep( ProcessInfo& rCurrentProcessInfo } + // Add in the predictor velocity increment for central difference explicit + // This is the 'previous grid acceleration', which is actually + // be the initial particle acceleration mapped to the grid. + if (rCurrentProcessInfo.Has(IS_EXPLICIT_CENTRAL_DIFFERENCE)) { + if (rCurrentProcessInfo.GetValue(IS_EXPLICIT_CENTRAL_DIFFERENCE)) { + const double& delta_time = rCurrentProcessInfo[DELTA_TIME]; + for (unsigned int j = 0; j < dimension; j++) { + nodal_momentum[j] += 0.5 * delta_time * (Variables.N[i] * mMP.acceleration[j]) * mMP.mass; + } + } + } + r_geometry[i].SetLock(); r_geometry[i].FastGetSolutionStepValue(NODAL_MOMENTUM, 0) += nodal_momentum; r_geometry[i].FastGetSolutionStepValue(NODAL_INERTIA, 0) += nodal_inertia; - r_geometry[i].FastGetSolutionStepValue(NODAL_MASS, 0) += Variables.N[i] * mMP.mass; r_geometry[i].UnSetLock(); - } } @@ -870,6 +956,9 @@ void UpdatedLagrangian::FinalizeSolutionStep( ProcessInfo& rCurrentProcessInfo ) { KRATOS_TRY + KRATOS_ERROR_IF(rCurrentProcessInfo.GetValue(IS_EXPLICIT)) + << "FinalizeSolutionStep for explicit time integration is done in the scheme"; + // Create and initialize element variables: GeneralVariables Variables; this->InitializeGeneralVariables(Variables,rCurrentProcessInfo); @@ -923,8 +1012,7 @@ void UpdatedLagrangian::FinalizeStepVariables( GeneralVariables & rVariables, co mConstitutiveLawVector->GetValue(MP_ACCUMULATED_PLASTIC_VOLUMETRIC_STRAIN, mMP.accumulated_plastic_volumetric_strain); mConstitutiveLawVector->GetValue(MP_ACCUMULATED_PLASTIC_DEVIATORIC_STRAIN, mMP.accumulated_plastic_deviatoric_strain); - this->UpdateGaussPoint(rVariables, rCurrentProcessInfo); - + if (!rCurrentProcessInfo.GetValue(IS_EXPLICIT)) this->UpdateGaussPoint(rVariables, rCurrentProcessInfo); } //************************************************************************************ @@ -1273,6 +1361,27 @@ void UpdatedLagrangian::CalculateDampingMatrix( MatrixType& rDampingMatrix, Proc KRATOS_CATCH( "" ) } +void UpdatedLagrangian::AddExplicitContribution(const VectorType& rRHSVector, const Variable& rRHSVariable, Variable>& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo) +{ + KRATOS_TRY; + + if (rRHSVariable == RESIDUAL_VECTOR && + rDestinationVariable == FORCE_RESIDUAL) { + GeometryType& r_geometry = GetGeometry(); + const unsigned int dimension = r_geometry.WorkingSpaceDimension(); + const unsigned int number_of_nodes = r_geometry.PointsNumber(); + + for (size_t i = 0; i < number_of_nodes; ++i) { + size_t index = dimension * i; + array_1d& r_force_residual = r_geometry[i].FastGetSolutionStepValue(FORCE_RESIDUAL); + for (size_t j = 0; j < dimension; ++j) { + r_force_residual[j] += rRHSVector[index + j]; + } + } + } + + KRATOS_CATCH("") +} //************************************************************************************ //****************MASS MATRIX********************************************************* @@ -1613,6 +1722,37 @@ void UpdatedLagrangian::DecimalCorrection(Vector& rVector) ///@name Access Get Values ///@{ +void UpdatedLagrangian::CalculateOnIntegrationPoints(const Variable& rVariable, + std::vector& rValues, + const ProcessInfo& rCurrentProcessInfo) +{ + if (rValues.size() != 1) + rValues.resize(1); + + if (rVariable == CALCULATE_EXPLICIT_MP_STRESS) + { + GeneralVariables Variables; + this->InitializeGeneralVariables(Variables, rCurrentProcessInfo); + this->CalculateExplicitStresses(rCurrentProcessInfo, Variables); + this->FinalizeStepVariables(Variables, rCurrentProcessInfo); + rValues[0] = true; + } + else if (rVariable == EXPLICIT_MAP_GRID_TO_MP) + { + MPMExplicitUtilities::UpdateGaussPointExplicit(rCurrentProcessInfo, *this, mN); + rValues[0] = true; + } + else if (rVariable == CALCULATE_MUSL_VELOCITY_FIELD) + { + MPMExplicitUtilities::CalculateMUSLGridVelocity(*this, mN); + rValues[0] = true; + } + else + { + KRATOS_ERROR << "Variable " << rVariable << " is called in CalculateOnIntegrationPoints, but is not implemented." << std::endl; + } +} + void UpdatedLagrangian::CalculateOnIntegrationPoints(const Variable& rVariable, std::vector& rValues, const ProcessInfo& rCurrentProcessInfo) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.hpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.hpp index 69d3f5d7881f..1e0f28dcee66 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.hpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.hpp @@ -494,6 +494,11 @@ class UpdatedLagrangian ProcessInfo& rCurrentProcessInfo) override; + void AddExplicitContribution(const VectorType& rRHSVector, + const Variable& rRHSVariable, + Variable >& rDestinationVariable, + const ProcessInfo& rCurrentProcessInfo) override; + //************************************************************************************ //************************************************************************************ /** @@ -540,6 +545,10 @@ class UpdatedLagrangian ///@name Access Get Values ///@{ + void CalculateOnIntegrationPoints(const Variable& rVariable, + std::vector& rValues, + const ProcessInfo& rCurrentProcessInfo) override; + void CalculateOnIntegrationPoints(const Variable& rVariable, std::vector& rValues, const ProcessInfo& rCurrentProcessInfo) override; @@ -607,6 +616,12 @@ class UpdatedLagrangian */ bool mFinalizedStep; + /// Container to store shape functions over whole timestep + Vector mN; + + /// Container to store shape function gradients over whole timestep + Matrix mDN_DX; + ///@} ///@name Protected Operators @@ -640,7 +655,8 @@ class UpdatedLagrangian virtual void CalculateAndAddRHS(LocalSystemComponents& rLocalSystem, GeneralVariables& rVariables, Vector& rVolumeForce, - const double& rIntegrationWeight); + const double& rIntegrationWeight, + const ProcessInfo& rCurrentProcessInfo); /** @@ -675,6 +691,10 @@ class UpdatedLagrangian GeneralVariables & rVariables, const double& rIntegrationWeight); + /// Calculation of the Explicit Stresses from velocity gradient. + virtual void CalculateExplicitStresses(const ProcessInfo& rCurrentProcessInfo, + GeneralVariables& rVariables); + /** * Set Variables of the Element to the Parameters of the Constitutive Law @@ -800,11 +820,6 @@ class UpdatedLagrangian */ virtual double& CalculateVolumeChange(double& rVolumeChange, GeneralVariables& rVariables); - /** - * Calculation of the Volume Force of the Element - */ - virtual Vector& CalculateVolumeForce(Vector& rVolumeForce, GeneralVariables& rVariables); - ///@name Protected LifeCycle ///@{ ///@} diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.cpp index ce6eafff3106..0c9c031226c9 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.cpp @@ -431,7 +431,11 @@ void UpdatedLagrangianUP::InitializeSolutionStep( ProcessInfo& rCurrentProcessIn //************************************************************************************ //************************************************************************************ -void UpdatedLagrangianUP::CalculateAndAddRHS(LocalSystemComponents& rLocalSystem, GeneralVariables& rVariables, Vector& rVolumeForce, const double& rIntegrationWeight) +void UpdatedLagrangianUP::CalculateAndAddRHS(LocalSystemComponents& rLocalSystem, + GeneralVariables& rVariables, + Vector& rVolumeForce, + const double& rIntegrationWeight, + const ProcessInfo& rCurrentProcessInfo) { // Contribution of the internal and external forces VectorType& rRightHandSideVector = rLocalSystem.GetRightHandSideVector(); diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.hpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.hpp index c8d6742c0376..618285b7e4a5 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.hpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.hpp @@ -265,7 +265,8 @@ class UpdatedLagrangianUP void CalculateAndAddRHS(LocalSystemComponents& rLocalSystem, GeneralVariables& rVariables, Vector& rVolumeForce, - const double& rIntegrationWeight) override; + const double& rIntegrationWeight, + const ProcessInfo& rCurrentProcessInfo) override; /** From e6f04e7c5dc73c42ecadd1a6780af022a8730783 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Fri, 17 Apr 2020 17:33:27 +1000 Subject: [PATCH 165/314] [skip ci] add error to prevent explicit time int for UP element --- .../custom_elements/updated_lagrangian_UP.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.cpp index 0c9c031226c9..0aa6485c0c39 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.cpp @@ -1241,6 +1241,9 @@ int UpdatedLagrangianUP::Check( const ProcessInfo& rCurrentProcessInfo ) { KRATOS_TRY + KRATOS_ERROR_IF(rCurrentProcessInfo.GetValue(IS_EXPLICIT)) + << "Explicit time integration not implemented for Updated Lagrangian UP MPM Element"; + int correct = 0; correct = UpdatedLagrangian::Check(rCurrentProcessInfo); From 8116336fef6681f39bba1f698c58e7c36fbd5404 Mon Sep 17 00:00:00 2001 From: eloisabaez Date: Fri, 17 Apr 2020 11:44:59 +0200 Subject: [PATCH 166/314] fixing ref variable names --- .../custom_utilities/potential_flow_utilities.cpp | 8 ++++---- .../custom_utilities/potential_flow_utilities.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp index aff7470533b7..861ca2529040 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp +++ b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp @@ -419,7 +419,7 @@ bool CheckWakeCondition(const Element& rElement, const double& rTolerance, const template double ComputeLocalMachSquaredDerivative( const array_1d& rVelocity, - const double rLocalMachNumber, + const double localMachNumber, const ProcessInfo& rCurrentProcessInfo) { // Following Fully Simulataneous Coupling of the Full Potential Equation @@ -432,7 +432,7 @@ double ComputeLocalMachSquaredDerivative( const array_1d free_stream_velocity = rCurrentProcessInfo[FREE_STREAM_VELOCITY]; // make squares of values - const double sq_local_mach_number = std::pow(rLocalMachNumber, 2); + const double sq_local_mach_number = std::pow(localMachNumber, 2); const double sq_free_stream_mach = std::pow(free_stream_mach, 2); double sq_local_velocity = inner_prod(rVelocity, rVelocity); const double sq_free_stream_velocity = inner_prod(free_stream_velocity, free_stream_velocity); @@ -473,7 +473,7 @@ template double ComputePerturbationLocalMachNumber<2, 3>(const Element& rElement template bool CheckIfElementIsCutByDistance<2, 3>(const BoundedVector& rNodalDistances); template void KRATOS_API(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION) CheckIfWakeConditionsAreFulfilled<2>(const ModelPart&, const double& rTolerance, const int& rEchoLevel); template bool CheckWakeCondition<2, 3>(const Element& rElement, const double& rTolerance, const int& rEchoLevel); -template double ComputeLocalMachSquaredDerivative<2, 3>(const array_1d& rVelocity, const double rLocalMachNumber, const ProcessInfo& rCurrentProcessInfo); +template double ComputeLocalMachSquaredDerivative<2, 3>(const array_1d& rVelocity, const double localMachNumber, const ProcessInfo& rCurrentProcessInfo); // 3D template array_1d GetWakeDistances<3, 4>(const Element& rElement); @@ -499,7 +499,7 @@ template double ComputePerturbationLocalMachNumber<3, 4>(const Element& rElement template bool CheckIfElementIsCutByDistance<3, 4>(const BoundedVector& rNodalDistances); template void KRATOS_API(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION) CheckIfWakeConditionsAreFulfilled<3>(const ModelPart&, const double& rTolerance, const int& rEchoLevel); template bool CheckWakeCondition<3, 4>(const Element& rElement, const double& rTolerance, const int& rEchoLevel); -template double ComputeLocalMachSquaredDerivative<3, 4>(const array_1d& rVelocity, const double rLocalMachNumber, const ProcessInfo& rCurrentProcessInfo); +template double ComputeLocalMachSquaredDerivative<3, 4>(const array_1d& rVelocity, const double localMachNumber, const ProcessInfo& rCurrentProcessInfo); } // namespace PotentialFlow } // namespace Kratos diff --git a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h index af445807e772..52ef454d834f 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h +++ b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h @@ -100,7 +100,7 @@ template bool CheckWakeCondition(const Element& rElement, const double& rTolerance, const int& rEchoLevel); template -double ComputeLocalMachSquaredDerivative(const array_1d& rVelocity, const double rLocalMachNumber,const ProcessInfo& rCurrentProcessInfo); +double ComputeLocalMachSquaredDerivative(const array_1d& rVelocity, const double localMachNumber,const ProcessInfo& rCurrentProcessInfo); } // namespace PotentialFlow } // namespace Kratos From 955b7aa40140bc47395b1836849f433c243cc040 Mon Sep 17 00:00:00 2001 From: eloisabaez Date: Fri, 17 Apr 2020 15:11:05 +0200 Subject: [PATCH 167/314] function to for clamped velocity sq --- ...e_potential_flow_application_variables.cpp | 1 + ...ble_potential_flow_application_variables.h | 1 + ...ible_potential_flow_python_application.cpp | 1 + .../potential_flow_utilities.cpp | 75 ++++++++----------- .../potential_flow_utilities.h | 3 + .../python_scripts/apply_far_field_process.py | 4 + .../test_potential_flow_utilities.cpp | 5 ++ 7 files changed, 48 insertions(+), 42 deletions(-) diff --git a/applications/CompressiblePotentialFlowApplication/compressible_potential_flow_application_variables.cpp b/applications/CompressiblePotentialFlowApplication/compressible_potential_flow_application_variables.cpp index 44fa96f03f48..1dad0e56e9ca 100644 --- a/applications/CompressiblePotentialFlowApplication/compressible_potential_flow_application_variables.cpp +++ b/applications/CompressiblePotentialFlowApplication/compressible_potential_flow_application_variables.cpp @@ -26,6 +26,7 @@ KRATOS_CREATE_VARIABLE(double, PRESSURE_LOWER) KRATOS_CREATE_VARIABLE(double, POTENTIAL_JUMP) KRATOS_CREATE_VARIABLE(double, ENERGY_NORM_REFERENCE) KRATOS_CREATE_VARIABLE(double, POTENTIAL_ENERGY_REFERENCE) +KRATOS_CREATE_VARIABLE(double, MACH_SQUARED_LIMIT) // Free stream magnitudes KRATOS_CREATE_3D_VARIABLE_WITH_COMPONENTS(FREE_STREAM_VELOCITY) diff --git a/applications/CompressiblePotentialFlowApplication/compressible_potential_flow_application_variables.h b/applications/CompressiblePotentialFlowApplication/compressible_potential_flow_application_variables.h index ab6a66d89cb6..49e20183fe46 100644 --- a/applications/CompressiblePotentialFlowApplication/compressible_potential_flow_application_variables.h +++ b/applications/CompressiblePotentialFlowApplication/compressible_potential_flow_application_variables.h @@ -49,6 +49,7 @@ KRATOS_DEFINE_APPLICATION_VARIABLE(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION, doub KRATOS_DEFINE_APPLICATION_VARIABLE(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION, double, POTENTIAL_JUMP) KRATOS_DEFINE_APPLICATION_VARIABLE(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION, double, ENERGY_NORM_REFERENCE) KRATOS_DEFINE_APPLICATION_VARIABLE(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION, double, POTENTIAL_ENERGY_REFERENCE) +KRATOS_DEFINE_APPLICATION_VARIABLE(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION, double, MACH_SQUARED_LIMIT) // Free stream magnitudes KRATOS_DEFINE_3D_APPLICATION_VARIABLE_WITH_COMPONENTS(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION, FREE_STREAM_VELOCITY) diff --git a/applications/CompressiblePotentialFlowApplication/custom_python/compressible_potential_flow_python_application.cpp b/applications/CompressiblePotentialFlowApplication/custom_python/compressible_potential_flow_python_application.cpp index 1f89c388a516..10dea0f3070e 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_python/compressible_potential_flow_python_application.cpp +++ b/applications/CompressiblePotentialFlowApplication/custom_python/compressible_potential_flow_python_application.cpp @@ -67,6 +67,7 @@ PYBIND11_MODULE(KratosCompressiblePotentialFlowApplication, m) KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, POTENTIAL_JUMP); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, ENERGY_NORM_REFERENCE); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, POTENTIAL_ENERGY_REFERENCE); + KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, MACH_SQUARED_LIMIT); // Free stream magnitudes KRATOS_REGISTER_IN_PYTHON_3D_VARIABLE_WITH_COMPONENTS(m, FREE_STREAM_VELOCITY); diff --git a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp index 41262e5f1b0b..ee346a5261f1 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp +++ b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp @@ -434,21 +434,10 @@ double ComputeLocalMachSquaredDerivative( // make squares of values double sq_local_mach_number = std::pow(rLocalMachNumber, 2); double sq_free_stream_mach = std::pow(free_stream_mach, 2); - double sq_local_velocity = inner_prod(rVelocity, rVelocity); double sq_free_stream_velocity = inner_prod(free_stream_velocity, free_stream_velocity); - // check if velocity is over max allowed velocity - double sq_max_velocity = ComputeMaximumVelocitySquared(rCurrentProcessInfo); - - if (sq_local_velocity > sq_max_velocity) - { - KRATOS_WARNING("Clamped local velocity") << - "SQUARE OF LOCAL VELOCITY ABOVE ALLOWED SQUARE OF VELOCITY" - << " sq_local_velocity = " << sq_max_velocity - << " sq_max_velocity = " << sq_max_velocity << std::endl; - - sq_local_velocity = sq_max_velocity; - } + // computes square of velocity including clamping according to MACH_SQUARED_LIMIT + double sq_local_velocity = ComputeClampedVelocitySquared(rVelocity, rCurrentProcessInfo); // square bracket term double square_bracket_term = 1.0 + 0.5*(heat_capacity_ratio - 1.0)* @@ -467,8 +456,8 @@ double ComputeMaximumVelocitySquared(const ProcessInfo& rCurrentProcessInfo) // and the Integral Boundary Layer Equations in Three Dimensions // by Brian Nishida (1996), Section A.2 and Section 2.5 - // make square of maximum local mach number - double sq_max_local_mach_number = 3.0; + // maximum local squared mach number + const double sq_max_local_mach_number = rCurrentProcessInfo[MACH_SQUARED_LIMIT]; // read free stream values const double heat_capacity_ratio = rCurrentProcessInfo[HEAT_CAPACITY_RATIO]; @@ -485,6 +474,29 @@ double ComputeMaximumVelocitySquared(const ProcessInfo& rCurrentProcessInfo) - sq_max_local_mach_number * sq_free_stream_mach + 2 * sq_free_stream_mach)); } +template +double ComputeClampedVelocitySquared( + const array_1d& rVelocity, + const ProcessInfo& rCurrentProcessInfo) +{ + // check if velocity is over max allowed velocity + double sq_max_velocity = ComputeMaximumVelocitySquared(rCurrentProcessInfo); + + double sq_local_velocity = inner_prod(rVelocity, rVelocity); + + if (sq_local_velocity > sq_max_velocity) + { + KRATOS_WARNING("Clamped local velocity") << + "SQUARE OF LOCAL VELOCITY ABOVE ALLOWED SQUARE OF VELOCITY" + << " sq_local_velocity = " << sq_max_velocity + << " sq_max_velocity = " << sq_max_velocity << std::endl; + + sq_local_velocity = sq_max_velocity; + } + + return sq_local_velocity; +} + template double ComputeLocalSpeedofSoundSquared( const array_1d& rVelocity, @@ -502,21 +514,10 @@ double ComputeLocalSpeedofSoundSquared( // make squares of values double sq_free_stream_mach = std::pow(free_stream_mach, 2); double sq_free_stream_speed_sound = std::pow(free_stream_speed_sound,2); - double sq_local_velocity = inner_prod(rVelocity, rVelocity); double sq_free_stream_velocity = inner_prod(free_stream_velocity, free_stream_velocity); - // check if velocity is over max allowed velocity - double sq_max_velocity = ComputeMaximumVelocitySquared(rCurrentProcessInfo); - - if (sq_local_velocity > sq_max_velocity) - { - KRATOS_WARNING("Clamped local velocity") << - "SQUARE OF LOCAL VELOCITY ABOVE ALLOWED SQUARE OF VELOCITY" - << " sq_local_velocity = " << sq_max_velocity - << " sq_max_velocity = " << sq_max_velocity << std::endl; - - sq_local_velocity = sq_max_velocity; - } + // computes square of velocity including clamping according to MACH_SQUARED_LIMIT + double sq_local_velocity = ComputeClampedVelocitySquared(rVelocity, rCurrentProcessInfo); // square bracket term double square_bracket_term = 1.0 + 0.5*(heat_capacity_ratio - 1.0)* @@ -535,20 +536,8 @@ double ComputeLocalMachNumberSquared( double sq_local_speed_of_sound = ComputeLocalSpeedofSoundSquared(rVelocity, rCurrentProcessInfo); - double sq_local_velocity = inner_prod(rVelocity, rVelocity); - - // check if velocity is over max allowed velocity - double sq_max_velocity = ComputeMaximumVelocitySquared(rCurrentProcessInfo); - - if (sq_local_velocity > sq_max_velocity) - { - KRATOS_WARNING("ComputeLocalMachNumberSquared: Clamped local velocity") << - "SQUARE OF LOCAL VELOCITY ABOVE ALLOWED SQUARE OF VELOCITY" - << " sq_local_velocity = " << sq_max_velocity - << " sq_max_velocity = " << sq_max_velocity << std::endl; - - sq_local_velocity = sq_max_velocity; - } + // computes square of velocity including clamping according to MACH_SQUARED_LIMIT + double sq_local_velocity = ComputeClampedVelocitySquared(rVelocity, rCurrentProcessInfo); return sq_local_velocity / sq_local_speed_of_sound; } @@ -584,6 +573,7 @@ template void KRATOS_API(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION) CheckIfWakeCon template bool CheckWakeCondition<2, 3>(const Element& rElement, const double& rTolerance, const int& rEchoLevel); template double ComputeLocalMachSquaredDerivative<2, 3>(const array_1d& rVelocity, const double rLocalMachNumber, const ProcessInfo& rCurrentProcessInfo); template double ComputeMaximumVelocitySquared<2, 3>(const ProcessInfo& rCurrentProcessInfo); +template double ComputeClampedVelocitySquared<2, 3>(const array_1d& rVelocity, const ProcessInfo& rCurrentProcessInfo); template double ComputeLocalSpeedofSoundSquared<2, 3>(const array_1d& rVelocity,const ProcessInfo& rCurrentProcessInfo); template double ComputeLocalMachNumberSquared<2, 3>(const array_1d& rVelocity, const ProcessInfo& rCurrentProcessInfo); @@ -613,6 +603,7 @@ template void KRATOS_API(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION) CheckIfWakeCo template bool CheckWakeCondition<3, 4>(const Element& rElement, const double& rTolerance, const int& rEchoLevel); template double ComputeLocalMachSquaredDerivative<3, 4>(const array_1d& rVelocity, const double rLocalMachNumber, const ProcessInfo& rCurrentProcessInfo); template double ComputeMaximumVelocitySquared<3, 4>(const ProcessInfo& rCurrentProcessInfo); +template double ComputeClampedVelocitySquared<3, 4>(const array_1d& rVelocity, const ProcessInfo& rCurrentProcessInfo); template double ComputeLocalSpeedofSoundSquared<3, 4>(const array_1d& rVelocity,const ProcessInfo& rCurrentProcessInfo); template double ComputeLocalMachNumberSquared<3, 4>(const array_1d& rVelocity, const ProcessInfo& rCurrentProcessInfo); diff --git a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h index adf4a17b792a..81d8b46c941d 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h +++ b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h @@ -105,6 +105,9 @@ double ComputeLocalMachSquaredDerivative(const array_1d& rVelocity, template double ComputeMaximumVelocitySquared(const ProcessInfo& rCurrentProcessInfo); +template +double ComputeClampedVelocitySquared(const array_1d& rVelocity, const ProcessInfo& rCurrentProcessInfo); + template double ComputeLocalSpeedofSoundSquared(const array_1d& rVelocity,const ProcessInfo& rCurrentProcessInfo); diff --git a/applications/CompressiblePotentialFlowApplication/python_scripts/apply_far_field_process.py b/applications/CompressiblePotentialFlowApplication/python_scripts/apply_far_field_process.py index 4b5671ef52e5..8a87676368fa 100644 --- a/applications/CompressiblePotentialFlowApplication/python_scripts/apply_far_field_process.py +++ b/applications/CompressiblePotentialFlowApplication/python_scripts/apply_far_field_process.py @@ -29,6 +29,7 @@ def __init__(self, Model, settings ): "heat_capacity_ratio": 1.4, "inlet_potential": 1.0, "mach_number_limit": 0.94, + "mach_number_squared_limit": 3.0, "initialize_flow_field": true, "perturbation_field": false } """ ) @@ -45,6 +46,7 @@ def __init__(self, Model, settings ): self.heat_capacity_ratio = settings["heat_capacity_ratio"].GetDouble() self.inlet_potential_0 = settings["inlet_potential"].GetDouble() self.mach_number_limit = settings["mach_number_limit"].GetDouble() + self.mach_number_squared_limit = settings["mach_number_squared_limit"].GetDouble() self.initialize_flow_field = settings["initialize_flow_field"].GetBool() self.perturbation_field = settings["perturbation_field"].GetBool() if(self.perturbation_field): @@ -63,6 +65,8 @@ def __init__(self, Model, settings ): self.fluid_model_part.ProcessInfo.SetValue(KratosMultiphysics.SOUND_VELOCITY,self.free_stream_speed_of_sound) self.fluid_model_part.ProcessInfo.SetValue(KratosCFD.HEAT_CAPACITY_RATIO,self.heat_capacity_ratio) self.fluid_model_part.ProcessInfo.SetValue(CPFApp.MACH_LIMIT,self.mach_number_limit) + self.fluid_model_part.ProcessInfo.SetValue(CPFApp.MACH_SQUARED_LIMIT,self.mach_number_squared_limit) + def ExecuteInitializeSolutionStep(self): far_field_process=CPFApp.ApplyFarFieldProcess(self.far_field_model_part, self.inlet_potential_0, self.initialize_flow_field, self.perturbation_field) diff --git a/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp b/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp index 74113717801a..d43472f5575c 100644 --- a/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp +++ b/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp @@ -172,6 +172,7 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeLocalMachSquaredDerivativeTransonicMach, Compre model_part.GetProcessInfo()[FREE_STREAM_MACH] = 0.6; model_part.GetProcessInfo()[HEAT_CAPACITY_RATIO] = 1.4; model_part.GetProcessInfo()[SOUND_VELOCITY] = 340.0; + model_part.GetProcessInfo()[MACH_SQUARED_LIMIT] = 3.0; BoundedVector free_stream_velocity = ZeroVector(3); free_stream_velocity(0) = model_part.GetProcessInfo().GetValue(FREE_STREAM_MACH) * @@ -201,6 +202,7 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeLocalMachSquaredDerivativeSupersonicMach, Compr model_part.GetProcessInfo()[FREE_STREAM_MACH] = 0.6; model_part.GetProcessInfo()[HEAT_CAPACITY_RATIO] = 1.4; model_part.GetProcessInfo()[SOUND_VELOCITY] = 340.0; + model_part.GetProcessInfo()[MACH_SQUARED_LIMIT] = 3.0; BoundedVector free_stream_velocity = ZeroVector(3); free_stream_velocity(0) = model_part.GetProcessInfo().GetValue(FREE_STREAM_MACH) * @@ -230,6 +232,7 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeMaximumVelocitySquared, CompressiblePotentialAp model_part.GetProcessInfo()[FREE_STREAM_MACH] = 0.6; model_part.GetProcessInfo()[HEAT_CAPACITY_RATIO] = 1.4; model_part.GetProcessInfo()[SOUND_VELOCITY] = 340.0; + model_part.GetProcessInfo()[MACH_SQUARED_LIMIT] = 3.0; BoundedVector free_stream_velocity = ZeroVector(3); free_stream_velocity(0) = model_part.GetProcessInfo().GetValue(FREE_STREAM_MACH) * @@ -254,6 +257,7 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeLocalSpeedofSoundSquared, CompressiblePotential model_part.GetProcessInfo()[FREE_STREAM_MACH] = 0.6; model_part.GetProcessInfo()[HEAT_CAPACITY_RATIO] = 1.4; model_part.GetProcessInfo()[SOUND_VELOCITY] = 340.0; + model_part.GetProcessInfo()[MACH_SQUARED_LIMIT] = 3.0; BoundedVector free_stream_velocity = ZeroVector(3); free_stream_velocity(0) = model_part.GetProcessInfo().GetValue(FREE_STREAM_MACH) * @@ -279,6 +283,7 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeLocalMachNumberSquared, CompressiblePotentialAp model_part.GetProcessInfo()[FREE_STREAM_MACH] = 0.6; model_part.GetProcessInfo()[HEAT_CAPACITY_RATIO] = 1.4; model_part.GetProcessInfo()[SOUND_VELOCITY] = 340.0; + model_part.GetProcessInfo()[MACH_SQUARED_LIMIT] = 3.0; BoundedVector free_stream_velocity = ZeroVector(3); free_stream_velocity(0) = model_part.GetProcessInfo().GetValue(FREE_STREAM_MACH) * From 6b53f9454b66e232db95d843c0d75963362de5e2 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Mon, 20 Apr 2020 17:25:10 +1000 Subject: [PATCH 168/314] fix up usl explicit test --- .../usl_explicit_oscillating_point_test_parameters.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usl_explicit_oscillating_point_test_parameters.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usl_explicit_oscillating_point_test_parameters.json index 466fae1eaaa6..3089e3890500 100644 --- a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usl_explicit_oscillating_point_test_parameters.json +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usl_explicit_oscillating_point_test_parameters.json @@ -74,8 +74,9 @@ "model_part_name" : "MPM_Material", "time_frequency" : 0.05 } - }], - "print_output_process" : [{ + }] + }, + "print_output_process" : [{ "python_module" : "particle_json_output_process", "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", "help" : "", @@ -87,5 +88,4 @@ "time_frequency" : 0.05 } }] - } -} +} \ No newline at end of file From ee18c86945e22cc66f53d5e332fc09c3582c49e3 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Mon, 20 Apr 2020 17:28:36 +1000 Subject: [PATCH 169/314] set element strain size from constitutive law --- .../custom_elements/updated_lagrangian.cpp | 9 ++++++--- .../custom_elements/updated_lagrangian.hpp | 10 +++------- .../updated_lagrangian_quadrilateral.cpp | 9 ++++++--- .../updated_lagrangian_quadrilateral.hpp | 10 +++------- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp index 142536958286..ce3992187543 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp @@ -43,7 +43,7 @@ KRATOS_CREATE_LOCAL_FLAG( UpdatedLagrangian, COMPUTE_LHS_MATRIX_WITH_COMPONENTS, UpdatedLagrangian::UpdatedLagrangian( ) : Element( ) - , mMP(0) + , mMP() { //DO NOT CALL IT: only needed for Register and Serialization!!! } @@ -51,7 +51,7 @@ UpdatedLagrangian::UpdatedLagrangian( ) //************************************************************************************ UpdatedLagrangian::UpdatedLagrangian( IndexType NewId, GeometryType::Pointer pGeometry ) : Element( NewId, pGeometry ) - , mMP(pGeometry->WorkingSpaceDimension()) + , mMP() { //DO NOT ADD DOFS HERE!!! } @@ -61,7 +61,7 @@ UpdatedLagrangian::UpdatedLagrangian( IndexType NewId, GeometryType::Pointer pGe UpdatedLagrangian::UpdatedLagrangian( IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties ) : Element( NewId, pGeometry, pProperties ) - , mMP(pGeometry->WorkingSpaceDimension()) + , mMP() { mFinalizedStep = true; @@ -1101,6 +1101,9 @@ void UpdatedLagrangian::InitializeMaterial() mConstitutiveLawVector->InitializeMaterial( GetProperties(), GetGeometry(), Variables.N ); + + mMP.almansi_strain_vector = ZeroVector(mConstitutiveLawVector->GetStrainSize()); + mMP.cauchy_stress_vector = ZeroVector(mConstitutiveLawVector->GetStrainSize()); } else KRATOS_ERROR << "A constitutive law needs to be specified for the element with ID: " << this->Id() << std::endl; diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.hpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.hpp index 1e0f28dcee66..8353ecc597e3 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.hpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.hpp @@ -123,7 +123,7 @@ class UpdatedLagrangian // MP_ACCUMULATED_PLASTIC_DEVIATORIC_STRAIN double accumulated_plastic_deviatoric_strain; - explicit MaterialPointVariables(SizeType WorkingSpaceDimension) + explicit MaterialPointVariables() { // MP_MASS mass = 1.0; @@ -132,14 +132,10 @@ class UpdatedLagrangian // MP_VOLUME volume = 1.0; - SizeType strain_size = (WorkingSpaceDimension == 2) - ? 3 - : 6; - // MP_CAUCHY_STRESS_VECTOR - cauchy_stress_vector = ZeroVector(strain_size); + cauchy_stress_vector = ZeroVector(0); // MP_ALMANSI_STRAIN_VECTOR - almansi_strain_vector = ZeroVector(strain_size); + almansi_strain_vector = ZeroVector(0); // MP_DELTA_PLASTIC_STRAIN delta_plastic_strain = 1.0; diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index 060e4071709a..d8be4ebeedc9 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -43,7 +43,7 @@ KRATOS_CREATE_LOCAL_FLAG( UpdatedLagrangianQuadrilateral, COMPUTE_LHS_MATRIX_WIT UpdatedLagrangianQuadrilateral::UpdatedLagrangianQuadrilateral( ) : Element( ) - , mMP(0) + , mMP() { //DO NOT CALL IT: only needed for Register and Serialization!!! } @@ -51,7 +51,7 @@ UpdatedLagrangianQuadrilateral::UpdatedLagrangianQuadrilateral( ) //************************************************************************************ UpdatedLagrangianQuadrilateral::UpdatedLagrangianQuadrilateral( IndexType NewId, GeometryType::Pointer pGeometry ) : Element( NewId, pGeometry ) - , mMP(pGeometry->WorkingSpaceDimension()) + , mMP() { //DO NOT ADD DOFS HERE!!! } @@ -61,7 +61,7 @@ UpdatedLagrangianQuadrilateral::UpdatedLagrangianQuadrilateral( IndexType NewId, UpdatedLagrangianQuadrilateral::UpdatedLagrangianQuadrilateral( IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties ) : Element( NewId, pGeometry, pProperties ) - , mMP(pGeometry->WorkingSpaceDimension()) + , mMP() { mFinalizedStep = true; @@ -1101,6 +1101,9 @@ void UpdatedLagrangianQuadrilateral::InitializeMaterial() mConstitutiveLawVector->InitializeMaterial( GetProperties(), GetGeometry(), Variables.N ); + + mMP.almansi_strain_vector = ZeroVector(mConstitutiveLawVector->GetStrainSize()); + mMP.cauchy_stress_vector = ZeroVector(mConstitutiveLawVector->GetStrainSize()); } else KRATOS_ERROR << "A constitutive law needs to be specified for the element with ID: " << this->Id() << std::endl; diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp index fe5af6c7c2f0..a9695dbf3f3a 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp @@ -124,7 +124,7 @@ class UpdatedLagrangianQuadrilateral // MP_ACCUMULATED_PLASTIC_DEVIATORIC_STRAIN double accumulated_plastic_deviatoric_strain; - explicit MaterialPointVariables(SizeType WorkingSpaceDimension) + explicit MaterialPointVariables() { // MP_MASS mass = 1.0; @@ -133,14 +133,10 @@ class UpdatedLagrangianQuadrilateral // MP_VOLUME volume = 1.0; - SizeType strain_size = (WorkingSpaceDimension == 2) - ? 3 - : 6; - // MP_CAUCHY_STRESS_VECTOR - cauchy_stress_vector = ZeroVector(strain_size); + cauchy_stress_vector = ZeroVector(0); // MP_ALMANSI_STRAIN_VECTOR - almansi_strain_vector = ZeroVector(strain_size); + almansi_strain_vector = ZeroVector(0); // MP_DELTA_PLASTIC_STRAIN delta_plastic_strain = 1.0; From 7b318737345fadee08f96969bedf910eae3076ff Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Mon, 20 Apr 2020 17:29:48 +1000 Subject: [PATCH 170/314] add strain size to explicit internal force calc --- .../custom_elements/updated_lagrangian.cpp | 3 +- .../updated_lagrangian_quadrilateral.cpp | 3 +- .../mpm_explicit_utilities.cpp | 33 ++++++++++--------- .../custom_utilities/mpm_explicit_utilities.h | 4 +++ 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp index ce3992187543..7c5b6df7c13e 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp @@ -503,7 +503,8 @@ void UpdatedLagrangian::CalculateAndAddRHS(LocalSystemComponents& rLocalSystem, if (rCurrentProcessInfo.GetValue(IS_EXPLICIT)) { MPMExplicitUtilities::CalcuateAndAddExplicitInternalForce(*this, - mDN_DX, mMP.cauchy_stress_vector, mMP.volume, rRightHandSideVector); + mDN_DX, mMP.cauchy_stress_vector, mMP.volume, + mConstitutiveLawVector->GetStrainSize(), rRightHandSideVector); } else { diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index d8be4ebeedc9..4dd161e38f66 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -507,7 +507,8 @@ void UpdatedLagrangianQuadrilateral::CalculateAndAddRHS( if (rCurrentProcessInfo.GetValue(IS_EXPLICIT)) { MPMExplicitUtilities::CalcuateAndAddExplicitInternalForce(*this, - mDN_DX, mMP.cauchy_stress_vector, mMP.volume, rRightHandSideVector); + mDN_DX, mMP.cauchy_stress_vector, mMP.volume, + mConstitutiveLawVector->GetStrainSize(), rRightHandSideVector); } else { diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp index 319f0d563c50..c96cc907524b 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp @@ -20,61 +20,64 @@ namespace Kratos const Matrix& rDN_DX, const Vector& rMPStress, const double& rMPVolume, + const std::size_t StrainSize, Vector& rRightHandSideVector) { KRATOS_TRY - // Add in explicit internal force calculation (Fint = Volume*divergence(sigma)) - // Refer to link for notation https://github.com/KratosMultiphysics/Kratos/wiki/How-to-use-the-Constitutive-Law-class + // Add in explicit internal force calculation (f_i = V * Sum_j [s_ij N_,j]) + // Refer to link for notation https://github.com/KratosMultiphysics/Kratos/wiki/How-to-use-the-Constitutive-Law-class GeometryType& rGeom = rElement.GetGeometry(); const SizeType dimension = rGeom.WorkingSpaceDimension(); const SizeType number_of_nodes = rGeom.PointsNumber(); array_1d nodal_force_internal_normal = ZeroVector(3); - - for (IndexType i = 0; i < number_of_nodes; i++) + for (IndexType i = 0; i < number_of_nodes; i++) { - // f_i = V * Sum_j [s_ij N_,j] - if (dimension == 2) + if (dimension == 2 && StrainSize == 3) { // StressVec = s00 s11 s01 // Index 0 1 2 - //f_x = V*(s_xx*dNdX + s_xy*dNdY) nodal_force_internal_normal[0] = rMPVolume * (rMPStress[0] * rDN_DX(i, 0) + rMPStress[2] * rDN_DX(i, 1)); - //f_y = V*(s_yy*dNdY + s_yx*dNdX) nodal_force_internal_normal[1] = rMPVolume * (rMPStress[1] * rDN_DX(i, 1) + rMPStress[2] * rDN_DX(i, 0)); - } - else + } + else if (dimension == 2 && StrainSize == 4) + { + KRATOS_ERROR + << "Call CalcuateAndAddAxisymmetricExplicitInternalForce instead of CalcuateAndAddExplicitInternalForce" + << std::endl; + } + else if (dimension == 3 && StrainSize == 6) { // StressVec = s00 s11 s22 s01 s12 s02 // Index 0 1 2 3 4 5 - //f_x = V*(s_xx*dNdX + s_xy*dNdY + s_xz*dNdZ) nodal_force_internal_normal[0] = rMPVolume * (rMPStress[0] * rDN_DX(i, 0) + rMPStress[3] * rDN_DX(i, 1) + rMPStress[5] * rDN_DX(i, 2)); - //f_y = V*(s_yy*dNdY + s_yx*dNdX + s_yz*dNdZ) nodal_force_internal_normal[1] = rMPVolume * (rMPStress[1] * rDN_DX(i, 1) + rMPStress[3] * rDN_DX(i, 0) + rMPStress[4] * rDN_DX(i, 2)); - //f_z = V*(s_zz*dNdZ + s_zx*dNdX + s_zy*dNdY) nodal_force_internal_normal[2] = rMPVolume * (rMPStress[2] * rDN_DX(i, 2) + rMPStress[5] * rDN_DX(i, 0) + rMPStress[4] * rDN_DX(i, 1)); - rRightHandSideVector[dimension * i + 2] -= nodal_force_internal_normal[2]; //minus sign, internal forces + } + else + { + KRATOS_ERROR << "Dimension = " << dimension << " and strain size = " << StrainSize + << " are invalid for MPM explicit internal force calculation." << std::endl; } - rRightHandSideVector[dimension * i] -= nodal_force_internal_normal[0]; //minus sign, internal forces rRightHandSideVector[dimension * i + 1] -= nodal_force_internal_normal[1]; //minus sign, internal forces } diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h index f84af727cb85..d35f2eb170a4 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h @@ -46,6 +46,10 @@ namespace Kratos void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) CalcuateAndAddExplicitInternalForce(Element& rElement, const Matrix& rDN_DX, const Vector& rMPStress, const double& rMPVolume, Vector& rRightHandSideVector); + void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) CalcuateAndAddAxisymmetricExplicitInternalForce(Element& rElement, + const Matrix& rDN_DX, const Vector& rN, const Vector& rMPStress, const double& rMPVolume, + const SizeType StrainSize, const double AxisymmetricRadius, Vector& rRightHandSideVector); + void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) UpdateGaussPointExplicit(const ProcessInfo& rCurrentProcessInfo, Element& rElement, const Vector& rN); From 3e98f55458864e9ed1117bc07a558aae543983fe Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Mon, 20 Apr 2020 17:30:23 +1000 Subject: [PATCH 171/314] add new explicit internal force calc for axisymmetric element --- .../updated_lagrangian_axisymmetry.cpp | 58 +++++++++++++++++++ .../updated_lagrangian_axisymmetry.hpp | 5 ++ .../mpm_explicit_utilities.cpp | 42 ++++++++++++++ .../custom_utilities/mpm_explicit_utilities.h | 3 +- 4 files changed, 107 insertions(+), 1 deletion(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp index af07fc2a495a..02d453478c79 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp @@ -24,6 +24,7 @@ #include "includes/constitutive_law.h" #include "custom_utilities/particle_mechanics_math_utilities.h" #include "particle_mechanics_application_variables.h" +#include "custom_utilities/mpm_explicit_utilities.h" namespace Kratos { @@ -269,6 +270,63 @@ void UpdatedLagrangianAxisymmetry::CalculateDeformationGradient(const Matrix& rD KRATOS_CATCH( "" ) } +//************************************************************************************ +void UpdatedLagrangianAxisymmetry::CalculateAndAddRHS(LocalSystemComponents& rLocalSystem, + GeneralVariables& rVariables, + Vector& rVolumeForce, + const double& rIntegrationWeight, + const ProcessInfo& rCurrentProcessInfo) +{ + // Contribution of the internal and external forces + if (rLocalSystem.CalculationFlags.Is(UpdatedLagrangian::COMPUTE_RHS_VECTOR_WITH_COMPONENTS)) + { + std::vector& rRightHandSideVectors = rLocalSystem.GetRightHandSideVectors(); + const std::vector< Variable< VectorType > >& rRightHandSideVariables = rLocalSystem.GetRightHandSideVariables(); + for (unsigned int i = 0; i < rRightHandSideVariables.size(); i++) + { + bool calculated = false; + if (rRightHandSideVariables[i] == EXTERNAL_FORCES_VECTOR) + { + // Operation performed: rRightHandSideVector += ExtForce*IntToReferenceWeight + this->CalculateAndAddExternalForces(rRightHandSideVectors[i], rVariables, rVolumeForce, rIntegrationWeight); + calculated = true; + } + + if (rRightHandSideVariables[i] == INTERNAL_FORCES_VECTOR) + { + // Operation performed: rRightHandSideVector -= IntForce*IntToReferenceWeight + this->CalculateAndAddInternalForces(rRightHandSideVectors[i], rVariables, rIntegrationWeight); + calculated = true; + } + + KRATOS_ERROR_IF(calculated == false) << " ELEMENT can not supply the required local system variable: " << rRightHandSideVariables[i] << std::endl; + } + } + else + { + VectorType& rRightHandSideVector = rLocalSystem.GetRightHandSideVector(); + + // Operation performed: rRightHandSideVector += ExtForce*IntToReferenceWeight + this->CalculateAndAddExternalForces(rRightHandSideVector, rVariables, rVolumeForce, rIntegrationWeight); + + if (rCurrentProcessInfo.GetValue(IS_EXPLICIT)) + { + const double current_radius = ParticleMechanicsMathUtilities::CalculateRadius(mN, GetGeometry()); + MPMExplicitUtilities::CalcuateAndAddAxisymmetricExplicitInternalForce(*this, + mDN_DX, mN, mMP.cauchy_stress_vector, mMP.volume, + mConstitutiveLawVector->GetStrainSize(), current_radius, rRightHandSideVector); + } + else + { + // Operation performed: rRightHandSideVector -= IntForce*IntToReferenceWeight + this->CalculateAndAddInternalForces(rRightHandSideVector, rVariables, rIntegrationWeight); + } + + + } +} + + //************************************************************************************ //************************************************************************************ diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.hpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.hpp index 070ecad0ff8f..8c064449fa70 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.hpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.hpp @@ -255,6 +255,11 @@ class UpdatedLagrangianAxisymmetry const double & rCurrentRadius, const double & rReferenceRadius); + /// Calculate and add RHS + void UpdatedLagrangianAxisymmetry::CalculateAndAddRHS(LocalSystemComponents& rLocalSystem, + GeneralVariables& rVariables, Vector& rVolumeForce, const double& rIntegrationWeight, + const ProcessInfo& rCurrentProcessInfo) override; + ///@} ///@name Protected Access ///@{ diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp index c96cc907524b..26eeea0f73f4 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp @@ -88,6 +88,48 @@ namespace Kratos /***********************************************************************************/ /***********************************************************************************/ + void MPMExplicitUtilities::CalcuateAndAddAxisymmetricExplicitInternalForce( + Element& rElement, + const Matrix& rDN_DX, + const Vector& rN, + const Vector& rMPStress, + const double& rMPVolume, + const SizeType StrainSize, + const double AxisymmetricRadius, + Vector& rRightHandSideVector) + { + KRATOS_TRY + + // Add in explicit internal force calculation (Fint = Volume*divergence(sigma)) + // Refer to link for notation https://github.com/KratosMultiphysics/Kratos/wiki/How-to-use-the-Constitutive-Law-class + GeometryType& rGeom = rElement.GetGeometry(); + const SizeType dimension = rGeom.WorkingSpaceDimension(); + const SizeType number_of_nodes = rGeom.PointsNumber(); + array_1d nodal_force_internal_normal = ZeroVector(3); + + KRATOS_ERROR_IF_NOT(dimension == 2 && StrainSize == 4) + << "Call CalcuateAndAddExplicitInternalForce instead of CalcuateAndAddAxisymmetricExplicitInternalForce" + << std::endl; + + for (IndexType i = 0; i < number_of_nodes; i++) { + // StressVec = srr szz sthetatheta srz + // Index 0 1 2 3 + + nodal_force_internal_normal[0] = rMPVolume * + (rMPStress[0] * rDN_DX(i, 0) + + rMPStress[2] * rN[i] / AxisymmetricRadius + + rMPStress[3] * rDN_DX(i, 1)); + + nodal_force_internal_normal[1] = rMPVolume * + (rMPStress[1] * rDN_DX(i, 1) + + rMPStress[3] * rDN_DX(i, 0)); + + rRightHandSideVector[dimension * i] -= nodal_force_internal_normal[0]; //minus sign, internal forces + rRightHandSideVector[dimension * i + 1] -= nodal_force_internal_normal[1]; //minus sign, internal forces + } + KRATOS_CATCH("") + } + void MPMExplicitUtilities::UpdateGaussPointExplicit( const ProcessInfo& rCurrentProcessInfo, Element& rElement, diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h index d35f2eb170a4..56da18114d96 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h @@ -44,7 +44,8 @@ namespace Kratos typedef Geometry GeometryType; void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) CalcuateAndAddExplicitInternalForce(Element& rElement, - const Matrix& rDN_DX, const Vector& rMPStress, const double& rMPVolume, Vector& rRightHandSideVector); + const Matrix& rDN_DX, const Vector& rMPStress, const double& rMPVolume, + const SizeType StrainSize, Vector& rRightHandSideVector); void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) CalcuateAndAddAxisymmetricExplicitInternalForce(Element& rElement, const Matrix& rDN_DX, const Vector& rN, const Vector& rMPStress, const double& rMPVolume, From f576e152c0fca4948404d1050477855780b9b7e6 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Mon, 20 Apr 2020 19:26:44 +1000 Subject: [PATCH 172/314] [skip ci] add explicit kinematics for axisymmetric --- .../updated_lagrangian_axisymmetry.cpp | 57 ++++++++++++ .../updated_lagrangian_axisymmetry.hpp | 4 + .../mpm_explicit_utilities.cpp | 89 +++++++++++++++++-- .../custom_utilities/mpm_explicit_utilities.h | 7 +- 4 files changed, 151 insertions(+), 6 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp index 02d453478c79..388c75c97c93 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp @@ -369,6 +369,63 @@ void UpdatedLagrangianAxisymmetry::CalculateAndAddKuug(MatrixType& rLeftHandSide KRATOS_CATCH( "" ) } +void UpdatedLagrangianAxisymmetry::CalculateExplicitStresses(const ProcessInfo& rCurrentProcessInfo, GeneralVariables& rVariables) +{ + KRATOS_TRY + + // Create constitutive law parameters: + ConstitutiveLaw::Parameters Values(GetGeometry(), GetProperties(), rCurrentProcessInfo); + + // Define the stress measure + rVariables.StressMeasure = ConstitutiveLaw::StressMeasure_Cauchy; + + // Set constitutive law flags: + Flags& ConstitutiveLawOptions = Values.GetOptions(); + ConstitutiveLawOptions.Set(ConstitutiveLaw::COMPUTE_STRESS, true); + + // use element provided strain incremented from velocity gradient + ConstitutiveLawOptions.Set(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR, true); + ConstitutiveLawOptions.Set(ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN, false); + + + // Compute explicit element kinematics, strain is incremented here. + MPMExplicitUtilities::CalculateExplicitKinematics(rCurrentProcessInfo, *this, mDN_DX, + mMP.almansi_strain_vector, rVariables.F); + rVariables.StressVector = mMP.cauchy_stress_vector; + rVariables.StrainVector = mMP.almansi_strain_vector; + + // Update gradient deformation + rVariables.F0 = mDeformationGradientF0; // total member def grad NOT including this increment + rVariables.FT = prod(rVariables.F, rVariables.F0); // total def grad including this increment + rVariables.detF = MathUtils::Det(rVariables.F); // det of current increment + rVariables.detF0 = MathUtils::Det(rVariables.F0); // det of def grad NOT including this increment + rVariables.detFT = MathUtils::Det(rVariables.FT); // det of total def grad including this increment + mDeformationGradientF0 = rVariables.FT; // update member internal total grad def + mDeterminantF0 = rVariables.detFT; // update member internal total grad def det + + // Update MP volume + if (rCurrentProcessInfo.GetValue(IS_COMPRESSIBLE)) + { + mMP.density = (GetProperties()[DENSITY]) / rVariables.detFT; + mMP.volume = mMP.mass / mMP.density; + } + + rVariables.CurrentDisp = CalculateCurrentDisp(rVariables.CurrentDisp, rCurrentProcessInfo); + rVariables.DN_DX = mDN_DX; + rVariables.N = mN; + + // Set general variables to constitutivelaw parameters + this->SetGeneralVariables(rVariables, Values); + + // Calculate Material Response + /* NOTE: + The function below will call CalculateMaterialResponseCauchy() by default and then (may) + call CalculateMaterialResponseKirchhoff() in the constitutive_law.*/ + mConstitutiveLawVector->CalculateMaterialResponse(Values, rVariables.StressMeasure); + + KRATOS_CATCH("") +} + //*************************COMPUTE ALMANSI STRAIN************************************* //************************************************************************************ void UpdatedLagrangianAxisymmetry::CalculateAlmansiStrain(const Matrix& rF, diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.hpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.hpp index 8c064449fa70..0ecb49f0ee84 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.hpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.hpp @@ -182,6 +182,10 @@ class UpdatedLagrangianAxisymmetry GeneralVariables& rVariables, const double& rIntegrationWeight) override; + /// Calculation of the Explicit Stresses from velocity gradient. + virtual void CalculateExplicitStresses(const ProcessInfo& rCurrentProcessInfo, + GeneralVariables& rVariables); + /** * Clear Nodal Forces */ diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp index 26eeea0f73f4..18af87d8db1a 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp @@ -20,7 +20,7 @@ namespace Kratos const Matrix& rDN_DX, const Vector& rMPStress, const double& rMPVolume, - const std::size_t StrainSize, + const SizeType StrainSize, Vector& rRightHandSideVector) { KRATOS_TRY @@ -276,7 +276,8 @@ namespace Kratos Element& rElement, const Matrix& rDN_DX, Vector& rMPStrain, - Matrix& rDeformationGradientIncrement) + Matrix& rDeformationGradientIncrement, + const SizeType StrainSize) { KRATOS_TRY @@ -287,6 +288,7 @@ namespace Kratos //Calculate velocity gradients Matrix velocityGradient = Matrix(dimension, dimension, 0.0); + for (IndexType nodeIndex = 0; nodeIndex < number_of_nodes; nodeIndex++) { const array_1d& nodal_velocity = rGeom[nodeIndex].FastGetSolutionStepValue(VELOCITY); @@ -313,18 +315,23 @@ namespace Kratos // Apply strain increment to strain vector rMPStrain(0) += strainIncrement(0, 0); //e_xx rMPStrain(1) += strainIncrement(1, 1); //e_yy - if (dimension == 2) + if (dimension == 2 && StrainSize == 3) { rMPStrain(2) += 2.0 * strainIncrement(0, 1); //e_xy } - else + else if((dimension == 3 && StrainSize == 6)) { - rMPStrain(2) += strainIncrement(2, 2) * deltaTime; //e_zz + rMPStrain(2) += strainIncrement(2, 2); //e_zz rMPStrain(3) += 2.0 * strainIncrement(0, 1); //e_xy rMPStrain(4) += 2.0 * strainIncrement(1, 2); //e_yz rMPStrain(5) += 2.0 * strainIncrement(0, 2); //e_xz } + else + { + KRATOS_ERROR << "Dimension = " << dimension << " and strain size = " << StrainSize + << " are invalid for MPM explicit kinematic calculation." << std::endl; + } // Model compressibility rDeformationGradientIncrement = IdentityMatrix(dimension); @@ -332,4 +339,76 @@ namespace Kratos KRATOS_CATCH("") } + + void MPMExplicitUtilities::CalculateExplicitAsymmetricKinematics( + const ProcessInfo& rCurrentProcessInfo, + Element& rElement, + const Matrix& rDN_DX, + const Vector& rN, + Vector& rMPStrain, + Matrix& rDeformationGradientIncrement, + const SizeType StrainSize, + const double AxisymmetricRadius) + { + KRATOS_TRY + + GeometryType rGeom = rElement.GetGeometry(); + const double deltaTime = rCurrentProcessInfo[DELTA_TIME]; + const SizeType dimension = rGeom.WorkingSpaceDimension(); + const SizeType number_of_nodes = rGeom.PointsNumber(); + + //Calculate velocity gradients + Matrix velocityGradient = Matrix(3, 3, 0.0); // for axisymmetric case + + for (IndexType nodeIndex = 0; nodeIndex < number_of_nodes; nodeIndex++) + { + const array_1d& nodal_velocity = rGeom[nodeIndex].FastGetSolutionStepValue(VELOCITY); + + for (IndexType i = 0; i < dimension; i++) + { + for (IndexType j = 0; j < dimension; j++) + { + velocityGradient(i, j) += nodal_velocity[i] * rDN_DX(nodeIndex, j); + } + } + } + if (dimension == 2 && StrainSize == 4) // axisymmetric case + { + for (IndexType nodeIndex = 0; nodeIndex < number_of_nodes; nodeIndex++) + { + const array_1d& nodal_velocity = rGeom[nodeIndex].FastGetSolutionStepValue(VELOCITY); + velocityGradient(3, 3) += nodal_velocity[0] * rN[nodeIndex] / AxisymmetricRadius;; + } + } + + //Calculate rate of deformation and spin tensors + const Matrix rateOfDeformation = 0.5 * (velocityGradient + trans(velocityGradient)); + const Matrix spinTensor = velocityGradient - rateOfDeformation; + + //Calculate objective Jaumann strain rate + const Matrix jaumannRate = rateOfDeformation - + (prod(spinTensor, rateOfDeformation)) * deltaTime + + prod((rateOfDeformation * deltaTime), spinTensor); + const Matrix strainIncrement = deltaTime * jaumannRate; + + // Apply strain increment to strain vector + rMPStrain(0) += strainIncrement(0, 0); //e_xx + rMPStrain(1) += strainIncrement(1, 1); //e_yy + if (dimension == 2 && StrainSize == 4) + { + rMPStrain(2) += strainIncrement(2, 2); //e_theta theta + rMPStrain(3) += 2.0 * strainIncrement(0, 1); //e_xy + } + else + { + KRATOS_ERROR << "Dimension = " << dimension << " and strain size = " << StrainSize + << " are invalid for MPM explicit asymmetric kinematic calculation." << std::endl; + } + + // Model compressibility + rDeformationGradientIncrement = IdentityMatrix(3); + if (rCurrentProcessInfo.GetValue(IS_COMPRESSIBLE)) rDeformationGradientIncrement += strainIncrement; + + KRATOS_CATCH("") + } } // namespace Kratos \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h index 56da18114d96..190fa333d3a4 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h @@ -57,7 +57,12 @@ namespace Kratos void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) CalculateMUSLGridVelocity(Element& rElement, const Vector& rN); void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) CalculateExplicitKinematics(const ProcessInfo& rCurrentProcessInfo, - Element& rElement, const Matrix& rDN_DX, Vector& rMPStrain, Matrix& rDeformationGradient); + Element& rElement, const Matrix& rDN_DX, Vector& rMPStrain, Matrix& rDeformationGradient, + const SizeType StrainSize); + + void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) CalculateExplicitAsymmetricKinematics(const ProcessInfo& rCurrentProcessInfo, + Element& rElement, const Matrix& rDN_DX, const Vector& rN, Vector& rMPStrain, Matrix& rDeformationGradient, + const SizeType StrainSize, const double AxisymmetricRadius = 1.0); }; // namespace ExplicitIntegrationUtilities } // namespace Kratos #endif /* KRATOS_MPM_EXPLICIT_UTILITIES defined */ \ No newline at end of file From 2f5d901e7602c06c07ab6b31e1cce20736c265e3 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Tue, 21 Apr 2020 09:21:08 +1000 Subject: [PATCH 173/314] fixed up calls to explicit kinematics --- .../custom_elements/updated_lagrangian.cpp | 2 +- .../custom_elements/updated_lagrangian_axisymmetry.cpp | 5 +++-- .../custom_elements/updated_lagrangian_quadrilateral.cpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp index 7c5b6df7c13e..066bf564deeb 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp @@ -580,7 +580,7 @@ void UpdatedLagrangian::CalculateExplicitStresses(const ProcessInfo& rCurrentPro // Compute explicit element kinematics, strain is incremented here. MPMExplicitUtilities::CalculateExplicitKinematics(rCurrentProcessInfo, *this, mDN_DX, - mMP.almansi_strain_vector, rVariables.F); + mMP.almansi_strain_vector, rVariables.F, mConstitutiveLawVector->GetStrainSize()); rVariables.StressVector = mMP.cauchy_stress_vector; rVariables.StrainVector = mMP.almansi_strain_vector; diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp index 388c75c97c93..1dcaf1de7a8a 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp @@ -389,8 +389,9 @@ void UpdatedLagrangianAxisymmetry::CalculateExplicitStresses(const ProcessInfo& // Compute explicit element kinematics, strain is incremented here. - MPMExplicitUtilities::CalculateExplicitKinematics(rCurrentProcessInfo, *this, mDN_DX, - mMP.almansi_strain_vector, rVariables.F); + const double current_radius = ParticleMechanicsMathUtilities::CalculateRadius(mN, GetGeometry()); + MPMExplicitUtilities::CalculateExplicitAsymmetricKinematics(rCurrentProcessInfo, *this, mDN_DX, + mN, mMP.almansi_strain_vector, rVariables.F, mConstitutiveLawVector->GetStrainSize(), current_radius); rVariables.StressVector = mMP.cauchy_stress_vector; rVariables.StrainVector = mMP.almansi_strain_vector; diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index 4dd161e38f66..a5e8f6f0c007 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -583,7 +583,7 @@ void UpdatedLagrangianQuadrilateral::CalculateExplicitStresses(const ProcessInfo // Compute explicit element kinematics, strain is incremented here. MPMExplicitUtilities::CalculateExplicitKinematics(rCurrentProcessInfo, *this, mDN_DX, - mMP.almansi_strain_vector, rVariables.F); + mMP.almansi_strain_vector, rVariables.F, mConstitutiveLawVector->GetStrainSize()); rVariables.StressVector = mMP.cauchy_stress_vector; rVariables.StrainVector = mMP.almansi_strain_vector; From 3c627b2c1c5942fbc086a99236504e1bc2d28deb Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Tue, 21 Apr 2020 09:22:29 +1000 Subject: [PATCH 174/314] add explicit tri test --- ..._explicit_oscillating_point_test_Body.mdpa | 33 ++++++ ..._explicit_oscillating_point_test_Grid.mdpa | 75 +++++++++++++ ...cit_oscillating_point_test_parameters.json | 103 ++++++++++++++++++ ...plicit_oscillating_point_test_results.json | 1 + .../tests/particle_mechanics_test_factory.py | 5 +- .../test_ParticleMechanicsApplication.py | 40 +++---- 6 files changed, 236 insertions(+), 21 deletions(-) create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/tri_explicit_oscillating_point_test_Body.mdpa create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/tri_explicit_oscillating_point_test_Grid.mdpa create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/tri_explicit_oscillating_point_test_parameters.json create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/tri_explicit_oscillating_point_test_results.json diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/tri_explicit_oscillating_point_test_Body.mdpa b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/tri_explicit_oscillating_point_test_Body.mdpa new file mode 100644 index 000000000000..4f9ce67fa744 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/tri_explicit_oscillating_point_test_Body.mdpa @@ -0,0 +1,33 @@ +Begin ModelPartData +// VARIABLE_NAME value +End ModelPartData + +Begin Properties 0 +End Properties +Begin Nodes + 3 1.00000 1.00000 0.00000 + 6 1.00000 0.00000 0.00000 + 7 0.00000 1.00000 0.00000 + 10 0.00000 0.00000 0.00000 +End Nodes + + +Begin Elements UpdatedLagrangian2D3N// GUI group identifier: bar + 5 0 6 3 10 + 6 0 3 7 10 +End Elements + +Begin SubModelPart Parts_bar // Group bar // Subtree Parts + Begin SubModelPartNodes + 3 + 6 + 7 + 10 + End SubModelPartNodes + Begin SubModelPartElements + 5 + 6 + End SubModelPartElements + Begin SubModelPartConditions + End SubModelPartConditions +End SubModelPart diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/tri_explicit_oscillating_point_test_Grid.mdpa b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/tri_explicit_oscillating_point_test_Grid.mdpa new file mode 100644 index 000000000000..2b35a62088ad --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/tri_explicit_oscillating_point_test_Grid.mdpa @@ -0,0 +1,75 @@ +Begin ModelPartData +// VARIABLE_NAME value +End ModelPartData + +Begin Properties 0 +End Properties +Begin Nodes + 1 2.0000000000 1.0000000000 0.0000000000 + 2 2.0000000000 0.0000000000 0.0000000000 + 3 1.0000000000 1.0000000000 0.0000000000 + 4 1.0000000000 1.0000000000 0.0000000000 + 5 1.0000000000 0.0000000000 0.0000000000 + 6 1.0000000000 0.0000000000 0.0000000000 + 7 0.0000000000 1.0000000000 0.0000000000 + 8 0.0000000000 1.0000000000 0.0000000000 + 9 0.0000000000 0.0000000000 0.0000000000 + 10 0.0000000000 0.0000000000 0.0000000000 +End Nodes + + +Begin Elements Element2D3N// GUI group identifier: grid + 1 0 5 4 9 + 2 0 4 8 9 + 3 0 2 1 5 + 4 0 1 4 5 +End Elements + +Begin SubModelPart Parts_grid // Group grid // Subtree Parts + Begin SubModelPartNodes + 1 + 2 + 4 + 5 + 8 + 9 + End SubModelPartNodes + Begin SubModelPartElements + 1 + 2 + 3 + 4 + End SubModelPartElements + Begin SubModelPartConditions + End SubModelPartConditions +End SubModelPart +Begin SubModelPart DISPLACEMENT_bc // Group bc // Subtree DISPLACEMENT + Begin SubModelPartNodes + 7 + 8 + 9 + 10 + End SubModelPartNodes + Begin SubModelPartElements + End SubModelPartElements + Begin SubModelPartConditions + End SubModelPartConditions +End SubModelPart +Begin SubModelPart DISPLACEMENT_bcy // Group bc // Subtree DISPLACEMENT + Begin SubModelPartNodes + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + End SubModelPartNodes + Begin SubModelPartElements + End SubModelPartElements + Begin SubModelPartConditions + End SubModelPartConditions +End SubModelPart diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/tri_explicit_oscillating_point_test_parameters.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/tri_explicit_oscillating_point_test_parameters.json new file mode 100644 index 000000000000..1cdd912ddbe7 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/tri_explicit_oscillating_point_test_parameters.json @@ -0,0 +1,103 @@ +{ + "problem_data" : { + "problem_name" : "tri_explicit_oscillating_point_test", + "parallel_type" : "OpenMP", + "echo_level" : 0, + "start_time" : 0.0, + "end_time" : 0.5 + }, + "solver_settings" : { + "solver_type" : "Dynamic", + "model_part_name" : "MPM_Material", + "domain_size" : 2, + "echo_level" : 0, + "analysis_type" : "linear", + "time_integration_method" : "explicit", + "scheme_type" : "central_difference", + "stress_update" : "usf", + "compressible" : true, + "model_import_settings" : { + "input_type" : "mdpa", + "input_filename" : "explicit_tests/oscillating_point/tri_explicit_oscillating_point_test_Body" + }, + "material_import_settings" : { + "materials_filename" : "explicit_tests/oscillating_point/explicit_oscillating_point_test_materials.json" + }, + "time_stepping" : { + "time_step" : 0.025 + }, + "convergence_criterion" : "residual_criterion", + "displacement_relative_tolerance" : 0.0001, + "displacement_absolute_tolerance" : 1e-9, + "residual_relative_tolerance" : 0.0001, + "residual_absolute_tolerance" : 1e-9, + "max_iteration" : 10, + "problem_domain_sub_model_part_list" : ["Parts_bar","Parts_grid"], + "processes_sub_model_part_list" : ["DISPLACEMENT_bc","DISPLACEMENT_bcy"], + "grid_model_import_settings" : { + "input_type" : "mdpa", + "input_filename" : "explicit_tests/oscillating_point/tri_explicit_oscillating_point_test_Grid" + }, + "pressure_dofs" : false + }, + "processes" : { + "constraints_process_list" : [{ + "python_module" : "assign_vector_variable_process", + "kratos_module" : "KratosMultiphysics", + "Parameters" : { + "model_part_name" : "Background_Grid.DISPLACEMENT_bc", + "variable_name" : "DISPLACEMENT", + "constrained" : [true,true,true], + "value" : [0.0,0.0,0.0], + "interval" : [0.0,"End"] + } + }, + { + "python_module" : "assign_vector_variable_process", + "kratos_module" : "KratosMultiphysics", + "Parameters" : { + "model_part_name" : "Background_Grid.DISPLACEMENT_bcy", + "variable_name" : "DISPLACEMENT", + "constrained" : [false,true,true], + "value" : [0.0,0.0,0.0], + "interval" : [0.0,"End"] + } + }], + "loads_process_list" : [], + "gravity" : [], + "list_other_processes" : [{ + "python_module" : "assign_initial_velocity_to_particle_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "Parameters" : { + "model_part_name" : "Parts_bar", + "variable_name" : "MP_VELOCITY", + "modulus" : 0.1, + "direction" : [1.0,0.0,0.0] + } + }, + { + "python_module" : "particle_from_json_check_result_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "help" : "", + "process_name" : "ParticleFromJsonCheckResultProcess", + "Parameters" : { + "check_variables" : ["MP_VELOCITY","MP_DISPLACEMENT"], + "input_file_name" : "explicit_tests/oscillating_point/tri_explicit_oscillating_point_test_results.json", + "model_part_name" : "MPM_Material", + "time_frequency" : 0.05 + } + }] + }, + "print_output_process" : [{ + "python_module" : "particle_json_output_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "help" : "", + "process_name" : "ParticleJsonOutputProcess", + "Parameters" : { + "gauss_points_output_variables" : ["MP_VELOCITY","MP_DISPLACEMENT"], + "output_file_name" : "explicit_tests/oscillating_point/tri_explicit_oscillating_point_test_results.json", + "model_part_name" : "MPM_Material", + "time_frequency" : 0.05 + } + }] +} diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/tri_explicit_oscillating_point_test_results.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/tri_explicit_oscillating_point_test_results.json new file mode 100644 index 000000000000..8cc6f06a65d9 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/tri_explicit_oscillating_point_test_results.json @@ -0,0 +1 @@ +{"TIME": [0.07500000000000001, 0.15, 0.22499999999999998, 0.3, 0.35000000000000003, 0.4000000000000001, 0.4500000000000001], "PARTICLE_11": {"MP_VELOCITY_X": [0.08373839747464354, 0.039997256955703483, -0.0177227099023543, -0.07160449500235735, -0.0969151371774592, -0.10932747666167487, -0.1069617608896657], "MP_VELOCITY_Y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [0.0048075346990736146, 0.008336792462972526, 0.009635188437521515, 0.008412515524615543, 0.006397450979945896, 0.003750588935755303, 0.0008432716256892474], "MP_DISPLACEMENT_Y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}, "PARTICLE_12": {"MP_VELOCITY_X": [0.09450886015883068, 0.07887942773345037, 0.055536168809088356, 0.027971653556186443, 0.00913199226805543, -0.00886627792615979, -0.025189951277991528], "MP_VELOCITY_Y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [0.0024243258949907067, 0.004339876169446722, 0.005352812692416251, 0.005311106543676654, 0.00474943998988654, 0.0038691759105836197, 0.002800993465474124], "MP_DISPLACEMENT_Y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}} \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py b/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py index caa4cd90c677..4674fef081d1 100644 --- a/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py +++ b/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py @@ -109,4 +109,7 @@ class ExplicitOscillatingPointYCompressibleTest(ParticleMechanicsTestFactory): file_name = "explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test" class ExplicitOscillatingPointGravityTest(ParticleMechanicsTestFactory): - file_name = "explicit_tests/oscillating_point/explicit_oscillating_point_gravity_test" \ No newline at end of file + file_name = "explicit_tests/oscillating_point/explicit_oscillating_point_gravity_test" + +class ExplicitOscillatingPointTriTest(ParticleMechanicsTestFactory): + file_name = "explicit_tests/oscillating_point/tri_explicit_oscillating_point_test" \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py index e369126d7859..9c8b4a26515f 100644 --- a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py +++ b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py @@ -87,23 +87,23 @@ def AssembleTestSuites(): ## These tests are executed in the nightly build nightSuite = suites['nightly'] - nightSuite.addTests(smallSuite) - - nightSuite.addTest(TAxisSymmetricCircularPlate2DTriTest('test_execution')) - - nightSuite.addTest(TBeamCantileverStaticLinearElasticPointLoad2DTriTest('test_execution')) - nightSuite.addTest(TBeamCantileverStaticLinearElasticParticlePointLoad2DTriTest('test_execution')) - nightSuite.addTest(TBeamCantileverStaticLinearElasticLineLoad2DQuadTest('test_execution')) - nightSuite.addTest(TBeamCantileverStaticLinearElasticSurfaceLoad3DHexaTest('test_execution')) - nightSuite.addTest(TBeamCantileverStaticHyperelasticSelfWeightLoad2DQuadTest('test_execution')) - - nightSuite.addTest(TCooksMembraneCompressibleTest('test_execution')) - nightSuite.addTest(TCooksMembraneUPCompressibleTest('test_execution')) - nightSuite.addTest(TCooksMembraneUPIncompressibleTest('test_execution')) - - nightSuite.addTest(TPenaltyImpositionBeamCantileverStaticHyperelasticSelfWeightLoad2DQuadTest('test_execution')) - - nightSuite.addTest(TBeamCantileverLinearStaticHyperelasticSelfWeightLoad2DQuadTest('test_execution')) + #nightSuite.addTests(smallSuite) + # + #nightSuite.addTest(TAxisSymmetricCircularPlate2DTriTest('test_execution')) + # + #nightSuite.addTest(TBeamCantileverStaticLinearElasticPointLoad2DTriTest('test_execution')) + #nightSuite.addTest(TBeamCantileverStaticLinearElasticParticlePointLoad2DTriTest('test_execution')) + #nightSuite.addTest(TBeamCantileverStaticLinearElasticLineLoad2DQuadTest('test_execution')) + #nightSuite.addTest(TBeamCantileverStaticLinearElasticSurfaceLoad3DHexaTest('test_execution')) + #nightSuite.addTest(TBeamCantileverStaticHyperelasticSelfWeightLoad2DQuadTest('test_execution')) + # + #nightSuite.addTest(TCooksMembraneCompressibleTest('test_execution')) + #nightSuite.addTest(TCooksMembraneUPCompressibleTest('test_execution')) + #nightSuite.addTest(TCooksMembraneUPIncompressibleTest('test_execution')) + # + #nightSuite.addTest(TPenaltyImpositionBeamCantileverStaticHyperelasticSelfWeightLoad2DQuadTest('test_execution')) + # + #nightSuite.addTest(TBeamCantileverLinearStaticHyperelasticSelfWeightLoad2DQuadTest('test_execution')) nightSuite.addTest(TExplicitOscillatingPointUSLTest('test_execution')) nightSuite.addTest(TExplicitOscillatingPointUSFTest('test_execution')) @@ -124,9 +124,9 @@ def AssembleTestSuites(): return suites if __name__ == '__main__': - KratosMultiphysics.Logger.PrintInfo("Unittests", "\nRunning cpp unit tests ...") - run_cpp_unit_tests.run() - KratosMultiphysics.Logger.PrintInfo("Unittests", "Finished running cpp unit tests!") + #KratosMultiphysics.Logger.PrintInfo("Unittests", "\nRunning cpp unit tests ...") + #run_cpp_unit_tests.run() + #KratosMultiphysics.Logger.PrintInfo("Unittests", "Finished running cpp unit tests!") KratosMultiphysics.Logger.PrintInfo("Unittests", "\nRunning python tests ...") KratosUnittest.runTests(AssembleTestSuites()) From a2cd7e2c460ca373aa34b950d2f323cd915fbcd9 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Tue, 21 Apr 2020 11:41:22 +1000 Subject: [PATCH 175/314] add explicit tri test --- .../tests/test_ParticleMechanicsApplication.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py index 9c8b4a26515f..fbbcb40defe2 100644 --- a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py +++ b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py @@ -34,7 +34,7 @@ from particle_mechanics_test_factory import ExplicitOscillatingPointCentralDifferenceTest as TExplicitOscillatingPointCentralDifferenceTest from particle_mechanics_test_factory import ExplicitOscillatingPointYCompressibleTest as TExplicitOscillatingPointYCompressibleTest from particle_mechanics_test_factory import ExplicitOscillatingPointGravityTest as TExplicitOscillatingPointGravityTest - +from particle_mechanics_test_factory import ExplicitOscillatingPointTriTest as TExplicitOscillatingPointTriTest # Import from Test Factories (with different analysis flows) @@ -111,6 +111,7 @@ def AssembleTestSuites(): nightSuite.addTest(TExplicitOscillatingPointCentralDifferenceTest('test_execution')) nightSuite.addTest(TExplicitOscillatingPointYCompressibleTest('test_execution')) nightSuite.addTest(TExplicitOscillatingPointGravityTest('test_execution')) + nightSuite.addTest(TExplicitOscillatingPointTriTest('test_execution')) ### Adding Validation Tests ## For very long tests that should not be in nighly and you can use to validate From 8ceaac9bf1cfbbad7ddacb52a23675473016df99 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Tue, 21 Apr 2020 11:41:53 +1000 Subject: [PATCH 176/314] fix up axisymmetric explicit stress calculation error --- .../custom_utilities/mpm_explicit_utilities.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp index 18af87d8db1a..00b3960a4581 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp @@ -25,6 +25,7 @@ namespace Kratos { KRATOS_TRY + // Add in explicit internal force calculation (f_i = V * Sum_j [s_ij N_,j]) // Refer to link for notation https://github.com/KratosMultiphysics/Kratos/wiki/How-to-use-the-Constitutive-Law-class GeometryType& rGeom = rElement.GetGeometry(); @@ -352,7 +353,7 @@ namespace Kratos { KRATOS_TRY - GeometryType rGeom = rElement.GetGeometry(); + const GeometryType rGeom = rElement.GetGeometry(); const double deltaTime = rCurrentProcessInfo[DELTA_TIME]; const SizeType dimension = rGeom.WorkingSpaceDimension(); const SizeType number_of_nodes = rGeom.PointsNumber(); @@ -377,7 +378,7 @@ namespace Kratos for (IndexType nodeIndex = 0; nodeIndex < number_of_nodes; nodeIndex++) { const array_1d& nodal_velocity = rGeom[nodeIndex].FastGetSolutionStepValue(VELOCITY); - velocityGradient(3, 3) += nodal_velocity[0] * rN[nodeIndex] / AxisymmetricRadius;; + velocityGradient(2, 2) += nodal_velocity[0] * rN[nodeIndex] / AxisymmetricRadius; } } From 9f649eaa63ec7f09b49be6e653d294e57065e62e Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Tue, 21 Apr 2020 11:42:03 +1000 Subject: [PATCH 177/314] clean up --- .../custom_elements/updated_lagrangian_axisymmetry.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp index 1dcaf1de7a8a..683c9185f75c 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp @@ -373,8 +373,8 @@ void UpdatedLagrangianAxisymmetry::CalculateExplicitStresses(const ProcessInfo& { KRATOS_TRY - // Create constitutive law parameters: - ConstitutiveLaw::Parameters Values(GetGeometry(), GetProperties(), rCurrentProcessInfo); + // Create constitutive law parameters: + ConstitutiveLaw::Parameters Values(GetGeometry(), GetProperties(), rCurrentProcessInfo); // Define the stress measure rVariables.StressMeasure = ConstitutiveLaw::StressMeasure_Cauchy; From fd4bb883039672bd9ec4475b0d5450ecdbcb4ad7 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Tue, 21 Apr 2020 11:58:12 +1000 Subject: [PATCH 178/314] add explicit tri axisymmetric test --- ...ressible_explicit_axisym_disk_results.json | 1 + ...ssible_explicit_axisym_disk_test_Body.mdpa | 97 ++++++++ ...ssible_explicit_axisym_disk_test_Grid.mdpa | 226 ++++++++++++++++++ ...e_explicit_axisym_disk_test_materials.json | 19 ++ ..._explicit_axisym_disk_test_parameters.json | 93 +++++++ .../tests/particle_mechanics_test_factory.py | 5 +- .../test_ParticleMechanicsApplication.py | 3 + 7 files changed, 443 insertions(+), 1 deletion(-) create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_results.json create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_Body.mdpa create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_Grid.mdpa create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_materials.json create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_parameters.json diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_results.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_results.json new file mode 100644 index 000000000000..cf37dd5ce9a2 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_results.json @@ -0,0 +1 @@ +{"TIME": [0.05, 0.07500000000000001, 0.125, 0.175, 0.22499999999999998, 0.27499999999999997], "PARTICLE_69": {"MP_VELOCITY_X": [2.832243457783042e-21, -1.9818722997558727e-08, 3.7515130444149435e-06, 4.06924880104624e-05, 0.0001445279949806306, 0.0002593394264058129], "MP_VELOCITY_Y": [-0.0005, -0.0007499948886138046, -0.0012517163363202533, -0.0017678169566162788, -0.0023106561405308867, -0.0028477064485990643], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [4.088038953932378e-23, -3.8534786614608084e-09, -9.844815712490649e-08, -1.8367575069067858e-07, 1.2506676940801912e-06, 6.594795536643608e-06], "MP_DISPLACEMENT_Y": [-1.2499999999999999e-05, -2.812273208307649e-05, -7.80545594228358e-05, -0.00015279586676725829, -0.00025255215509206356, -0.0003776281087448352], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [2.0943951023931957, 2.094395086912602, 2.0943950418029798, 2.0943963131003454, 2.0944037851400528, 2.094425032581101]}, "PARTICLE_70": {"MP_VELOCITY_X": [6.236203016660749e-22, -5.9042480554658794e-08, 1.6207526160731473e-06, 2.1407256109410494e-05, 6.927300901384693e-05, 0.00010096487867226642], "MP_VELOCITY_Y": [-0.0005, -0.0007499745173423769, -0.001251142433281356, -0.0017665969536307337, -0.002323965303926242, -0.002936334989865063], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [3.7351156262867443e-23, -2.7187875871050388e-09, -1.0473723153766492e-07, -4.069679894994647e-07, -1.530137762021757e-07, 1.7175155873844983e-06], "MP_DISPLACEMENT_Y": [-1.25e-05, -2.8123567191931878e-05, -7.804987243613642e-05, -0.00015266396714092964, -0.00025202925124299664, -0.000377073372177098], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [1.047197551196598, 1.0471975341139519, 1.047197019180197, 1.0471957057050647, 1.0471979687810884, 1.0472095649077204]}, "PARTICLE_71": {"MP_VELOCITY_X": [-2.42349101211651e-08, 2.536889361786062e-07, 8.241717676011553e-06, 4.684129750810757e-05, 0.00014165937327136817, 0.00030253634852185916], "MP_VELOCITY_Y": [-0.00049994632086449, -0.0007499033350114617, -0.0012502129451034628, -0.0017384905785787694, -0.0021675320551784167, -0.002485564976727565], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-3.1448354839789807e-23, -1.3423789252159201e-08, -5.346492994294962e-08, 5.519397090891214e-07, 3.6545696317100196e-06, 1.1388293053904677e-05], "MP_DISPLACEMENT_Y": [-1.2499999999999999e-05, -2.80849757710518e-05, -7.759363626794167e-05, -0.00015087743366568434, -0.00024637108950060913, -0.0003606565732534922], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [5.235987755982989, 5.2359876118080475, 5.235989820314393, 5.236010928928237, 5.2360663047071325, 5.236139906547655]}, "PARTICLE_72": {"MP_VELOCITY_X": [-1.5693813544965357e-07, -1.1563958631457532e-06, -8.128938273974813e-06, -2.8493419124437178e-06, 7.708074229222041e-05, 0.0002691303105692414], "MP_VELOCITY_Y": [-0.0004999293020927264, -0.0007494648527685238, -0.0012459702142524438, -0.001746070716439549, -0.002273740974459533, -0.002837764531683424], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [1.1720735401857953e-23, -1.5702988084103987e-08, -2.861357206165403e-07, -1.1873950474637084e-06, -2.11062910714805e-06, -1.0873886512301092e-06], "MP_DISPLACEMENT_Y": [-1.25e-05, -2.8106731917618078e-05, -7.779225091735984e-05, -0.00015143017556224153, -0.0002480120056573815, -0.00036623842265010563], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [4.188790204786391, 4.188790048224593, 4.188788871510655, 4.188787831883633, 4.188787838923024, 4.188784822222494]}, "PARTICLE_73": {"MP_VELOCITY_X": [3.113629509143368e-07, 3.523806646125343e-06, 4.7296893384735265e-05, 0.00018958949689675285, 0.0004150316249993746, 0.0006267725685369234], "MP_VELOCITY_Y": [-0.0004974880893680493, -0.0007385065021093053, -0.0011943428989015395, -0.001600918444554646, -0.0019065589471285917, -0.002052817645017008], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-1.910262010025975e-09, -1.3010268080210925e-08, 2.1533287247736432e-07, 2.3859569087775263e-06, 9.248960181976194e-06, 2.2236998596832563e-05], "MP_DISPLACEMENT_Y": [-1.2428756483159267e-05, -2.7673752208868717e-05, -7.4475956436146e-05, -0.0001399057348042319, -0.00021932483866003778, -0.0003066904444758808], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [8.377580436537833, 8.3775822605465, 8.377600044562426, 8.377636182391266, 8.377666904622, 8.377675587654439]}, "PARTICLE_74": {"MP_VELOCITY_X": [-4.13939520597562e-07, -5.605283324634609e-07, 1.7553247524947675e-05, 9.30863314185262e-05, 0.0002139062786208778, 0.00032036842328715513], "MP_VELOCITY_Y": [-0.0004989338499484874, -0.000745847015996473, -0.0012402941256945863, -0.0017393113656478066, -0.0021831073214442593, -0.002462018912230718], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-1.5008534588023592e-08, -1.123649279395903e-07, -7.446645287773881e-07, -1.3803268835448319e-06, -2.3863903535052126e-07, 4.071879119543203e-06], "MP_DISPLACEMENT_Y": [-1.2470271456998599e-05, -2.7878113987246684e-05, -7.585356457782453e-05, -0.00014471114596689233, -0.00023143489720963282, -0.00033118464558166847], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [7.330382481170555, 7.330380407088393, 7.330369141518004, 7.330363308995223, 7.330388865746994, 7.330439080010935]}, "PARTICLE_75": {"MP_VELOCITY_X": [1.3353733304931958e-05, 4.1581470482210307e-05, 0.00015126880654628514, 0.0002907605734375881, 0.00041181462140001845, 0.0005136843537794175], "MP_VELOCITY_Y": [-0.00047952447249978577, -0.0006958397081912248, -0.001035324498205896, -0.0011782557092552173, -0.0011106224689035654, -0.0009384931062382643], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [4.627536430838688e-08, 2.966838633778459e-07, 2.352336683360801e-06, 7.892639389737928e-06, 1.7585359604736493e-05, 3.0980402432681293e-05], "MP_DISPLACEMENT_Y": [-1.106417812230998e-05, -2.350889999880596e-05, -5.993129056555898e-05, -0.00010689020785664624, -0.00015724664637827338, -0.0002046401021422092], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [11.519166124853369, 11.519157399025113, 11.519160064998374, 11.519201881226259, 11.519241673129468, 11.519227673174926]}, "PARTICLE_76": {"MP_VELOCITY_X": [2.869802331363579e-07, 2.323776769339492e-06, 2.5765293911208476e-05, 0.00010184466971209189, 0.00023643943329282015, 0.00039219565819626715], "MP_VELOCITY_Y": [-0.000486189371846396, -0.0007068092541464175, -0.001070245107969513, -0.001310621130918384, -0.0014310217740934274, -0.0014570575068327144], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-3.2644078744388895e-09, -1.855857745900708e-08, 5.4683539495167716e-08, 1.1644158977442732e-06, 4.9037962405963505e-06, 1.2193466712423753e-05], "MP_DISPLACEMENT_Y": [-1.1844811667717696e-05, -2.5803036108191527e-05, -6.716486018254388e-05, -0.00012169240410993341, -0.00018315502738641768, -0.0002455667350961349], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [10.471975560391101, 10.471978011605252, 10.472000432363565, 10.472039160344098, 10.47205244275776, 10.472014133965455]}, "PARTICLE_77": {"MP_VELOCITY_X": [1.2676978459306195e-05, 3.8472267045885364e-05, 0.000137109985085581, 0.0002578414694570373, 0.0003423126128212761, 0.00037352502667952], "MP_VELOCITY_Y": [-0.00024232259196950814, -0.00031831345283564043, -0.0004553319030713213, -0.0005360054216666495, -0.0005312013076987223, -0.00046472323610250365], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [3.4531164668862815e-08, 2.1516595931501885e-07, 1.599191344703102e-06, 4.938360280483921e-06, 9.983044174696964e-06, 1.5893454600134966e-05], "MP_DISPLACEMENT_Y": [-3.356306590403867e-06, -6.873181468165323e-06, -1.70574673488533e-05, -3.0033331947234567e-05, -4.336056247448114e-05, -5.4849625594194526e-05], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [14.660764306262742, 14.660756928602051, 14.660700402281167, 14.660564025283765, 14.660357993199792, 14.660116604248966]}, "PARTICLE_78": {"MP_VELOCITY_X": [1.2785348907394821e-05, 3.8613508632511276e-05, 0.0001318874150479678, 0.00022738976370122025, 0.0002618586911757566, 0.00022962648148120568], "MP_VELOCITY_Y": [-0.0003560409144259803, -0.0004953591883437401, -0.0007109579391635395, -0.0007891858150620265, -0.0006998932686511026, -0.0004869102541078784], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [3.317724308764071e-08, 2.0918207265544145e-07, 1.5750632139877866e-06, 4.915805734412683e-06, 1.006101180860291e-05, 1.6279044867021595e-05], "MP_DISPLACEMENT_Y": [-6.939027026533577e-06, -1.4354267312642536e-05, -3.552684754087018e-05, -6.191216752630613e-05, -8.87945365106767e-05, -0.00011213054033589214], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [13.613559077905089, 13.61354423902419, 13.613516435812477, 13.613509177123012, 13.61351198028586, 13.613504418853985]}, "PARTICLE_79": {"MP_VELOCITY_X": [-1.196652830456386e-21, -2.0284999877534591e-07, -3.5980842894230273e-06, -1.4728218259435399e-05, -4.0512013795643665e-05, -8.771139133654631e-05], "MP_VELOCITY_Y": [-0.0005, -0.0007498411186180141, -0.0012458128051748727, -0.0017278099158305053, -0.0022019041082761157, -0.0027206898181199018], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [2.673159489183155e-23, -4.331355987024832e-09, -1.9108887609749487e-07, -1.1964038286140036e-06, -3.5285425487774813e-06, -7.278757206832621e-06], "MP_DISPLACEMENT_Y": [-1.25e-05, -2.81226030013239e-05, -7.79819756334017e-05, -0.00015201296301803016, -0.00024924135668218225, -0.00036976307063359576], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [2.0943951023931957, 2.094395068758673, 2.0943939990762495, 2.0943893775316016, 2.0943827472441927, 2.094380500634335]}, "PARTICLE_80": {"MP_VELOCITY_X": [-3.6456595951720825e-21, -1.392473282899171e-07, -3.208277497120756e-06, -1.5373749269679e-05, -2.9857547435442086e-05, -4.0578520769831104e-06], "MP_VELOCITY_Y": [-0.0005, -0.0007498386500778008, -0.001243116474231054, -0.0017010798756907893, -0.0021099419105763293, -0.002545009013445198], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-4.913416809948948e-24, -1.6125269151446448e-09, -1.1016362910115662e-07, -8.03254479474763e-07, -2.7353390105279443e-06, -6.2095548051468e-06], "MP_DISPLACEMENT_Y": [-1.25e-05, -2.8124035826965842e-05, -7.801954872192132e-05, -0.0001520323992222436, -0.00024848053705217864, -0.0003668768790658636], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [1.047197551196598, 1.0471975410647927, 1.0471970279143061, 1.0471943300397866, 1.0471882352444517, 1.0471773820929862]}, "PARTICLE_81": {"MP_VELOCITY_X": [-3.2625425257557087e-07, -2.7133312171057664e-06, -2.8010749386928096e-05, -8.92723508301158e-05, -0.0001439172233165075, -0.0001454170732093036], "MP_VELOCITY_Y": [-0.0004998280636680914, -0.000748385233504772, -0.0012321356171618753, -0.0016936280992242898, -0.002162637770112756, -0.0026503937952244393], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [2.4891381181037805e-23, -2.5992177766201945e-08, -5.713998973309434e-07, -3.0713141525600313e-06, -8.740738790678297e-06, -1.7203668326276724e-05], "MP_DISPLACEMENT_Y": [-1.25e-05, -2.8097306810573243e-05, -7.753639261201221e-05, -0.00014985148787132046, -0.00024298650143534252, -0.0003553182089249976], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [5.235987755982989, 5.235987440734816, 5.235984712170829, 5.23597986417689, 5.235972246825738, 5.235953405254702]}, "PARTICLE_82": {"MP_VELOCITY_X": [-1.6931623317058257e-07, -1.7205751919622523e-06, -2.134976397771332e-05, -8.187123747969539e-05, -0.0001862884886142444, -0.0003440739895974058], "MP_VELOCITY_Y": [-0.0004998987612890451, -0.000748781852497475, -0.0012325513107813084, -0.0016765808312237684, -0.0020774559565855367, -0.0024445090628222557], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [4.34319038846221e-23, -1.5755220781805023e-08, -4.7007662914992127e-07, -2.857209578783464e-06, -8.755756914361494e-06, -1.8519842024798655e-05], "MP_DISPLACEMENT_Y": [-1.25e-05, -2.8112343000679852e-05, -7.773080474073483e-05, -0.00015056614961027348, -0.000244738817177094, -0.00035939853365561707], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [4.188790204786391, 4.188790026107958, 4.1887861069388075, 4.188768412657667, 4.188730931152087, 4.188681609661408]}, "PARTICLE_83": {"MP_VELOCITY_X": [-1.4573051907676378e-06, -7.015515722412912e-06, -3.6924912565443304e-05, -9.547809448483418e-05, -0.0001826823806212247, -0.00028509349268598233], "MP_VELOCITY_Y": [-0.0004978623334917864, -0.0007392217552475387, -0.001186056220117881, -0.0015644044493891085, -0.0018545159486410868, -0.0020310283274242317], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-3.044581830438905e-08, -2.2904146518607253e-07, -1.920538801768828e-06, -6.295103791368562e-06, -1.3450916306534257e-05, -2.2782284274663776e-05], "MP_DISPLACEMENT_Y": [-1.2454833938799709e-05, -2.776428162584996e-05, -7.47390322569671e-05, -0.00014025811962389484, -0.00022020597670584338, -0.00030995543223000005], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [8.377579577542818, 8.37757569631906, 8.377551985252483, 8.377515274431689, 8.377491854137864, 8.377487999194226]}, "PARTICLE_84": {"MP_VELOCITY_X": [-1.2369215814426438e-06, -7.758362764682942e-06, -6.612312539385604e-05, -0.00022818443545069222, -0.0004760553888786023, -0.0007176990819593539], "MP_VELOCITY_Y": [-0.0004987735655891494, -0.0007421983777333463, -0.0011821360812550303, -0.0015111015437795066, -0.001727685167799755, -0.0018668601179025709], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-1.5437287735926253e-08, -1.4039008170873081e-07, -1.5146344982466516e-06, -6.247072699707055e-06, -1.6189307823695912e-05, -3.1586357268906834e-05], "MP_DISPLACEMENT_Y": [-1.2484562615780725e-05, -2.7961720564425278e-05, -7.622329167058778e-05, -0.00014484596602586255, -0.00023011732132587976, -0.0003285081370928198], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [7.330382470394825, 7.330379966788238, 7.330361826710588, 7.330327732412029, 7.330288610625344, 7.33023832906837]}, "PARTICLE_85": {"MP_VELOCITY_X": [-1.45168684053716e-05, -4.3789242099385715e-05, -0.00014493745476248034, -0.0002368027631306781, -0.00025741825917764043, -0.00022265876519053608], "MP_VELOCITY_Y": [-0.0004717884645224017, -0.0006630102963261668, -0.0009182483857422657, -0.0010356089695764074, -0.0010579380762835607, -0.0009756718668483098], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-5.495556848868461e-08, -3.505167059028372e-07, -2.5485209641659537e-06, -7.442482718168522e-06, -1.4017323475732289e-05, -2.077072133598971e-05], "MP_DISPLACEMENT_Y": [-1.155548957473803e-05, -2.481320766432668e-05, -6.286541640218414e-05, -0.00011090809739798985, -0.0001631251192798824, -0.00021432322069077516], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [11.519164615511324, 11.519151585347895, 11.51913183060157, 11.519130736528368, 11.519121677594553, 11.519083421766261]}, "PARTICLE_86": {"MP_VELOCITY_X": [-1.553593969875546e-05, -4.904497581065901e-05, -0.00017789073478911876, -0.00033763456553852103, -0.00047542633283863153, -0.0005936091056290491], "MP_VELOCITY_Y": [-0.0004820156237850174, -0.0006880818454074319, -0.0009881037001956846, -0.001150985554730587, -0.0012048363856772288, -0.0011402472862334706], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-6.903905545711803e-08, -4.6165209684614604e-07, -3.5638940506170043e-06, -1.1136365072148632e-05, -2.2885617615124095e-05, -3.758232233316327e-05], "MP_DISPLACEMENT_Y": [-1.2123999244888103e-05, -2.6570108466214073e-05, -6.906209506858508e-05, -0.00012466877926506543, -0.00018806713750607834, -0.0002542200866609729], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [10.471974118635508, 10.471967840607041, 10.47192782115951, 10.471855131069297, 10.471786953582715, 10.471755830862115]}, "PARTICLE_87": {"MP_VELOCITY_X": [1.0831779218820795e-07, 1.4077355445911056e-07, -5.228213996997846e-06, -3.0473951577009265e-05, -8.050279632506388e-05, -0.00014397496305932651], "MP_VELOCITY_Y": [-0.00023871830042777393, -0.00030204550025514354, -0.0003806228662360533, -0.0003781677818024093, -0.0002936634387130705, -0.0001471346632624776], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-1.3541458644129615e-09, -5.987986887998129e-09, -2.422144083702721e-08, -2.3101528992026888e-08, 7.630300302563011e-08, 3.8213590034539463e-07], "MP_DISPLACEMENT_Y": [-3.5827218512250903e-06, -7.481095240773486e-06, -1.846943616126387e-05, -3.187894690546058e-05, -4.54341366816636e-05, -5.728119242157272e-05], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [14.660765771807853, 14.660765960555874, 14.660766703218355, 14.660766654512996, 14.660762591730442, 14.660750098977292]}, "PARTICLE_88": {"MP_VELOCITY_X": [-1.41271941470132e-05, -4.3004771294579715e-05, -0.00015655655829308613, -0.00030578042259574926, -0.0004244615442767658, -0.00047480175856227437], "MP_VELOCITY_Y": [-0.0003478009212301798, -0.00045872664846407157, -0.0005529845244201996, -0.0004921805219795987, -0.00033118938044316966, -0.0001171586377817274], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-3.9947150272821294e-08, -2.5044343970898055e-07, -1.850128334587823e-06, -5.653001890403242e-06, -1.1319805064995035e-05, -1.7878663423864063e-05], "MP_DISPLACEMENT_Y": [-7.418552242041887e-06, -1.5645911054826165e-05, -3.857453156705669e-05, -6.607288983392116e-05, -9.385627218799762e-05, -0.00011854589654561032], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [13.613559278770248, 13.61354943782975, 13.613570122803209, 13.613685808438168, 13.613876070514163, 13.61409525708454]}} \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_Body.mdpa b/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_Body.mdpa new file mode 100644 index 000000000000..5f1cc6a0e8e7 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_Body.mdpa @@ -0,0 +1,97 @@ +Begin ModelPartData +// VARIABLE_NAME value +End ModelPartData + +Begin Properties 0 +End Properties +Begin Nodes + 5 5.00000 2.00000 0.00000 + 10 5.00000 1.00000 0.00000 + 11 4.00000 2.00000 0.00000 + 12 4.00000 1.00000 0.00000 + 17 5.00000 0.00000 0.00000 + 18 3.00000 2.00000 0.00000 + 20 4.00000 0.00000 0.00000 + 22 3.00000 1.00000 0.00000 + 26 2.00000 2.00000 0.00000 + 29 3.00000 0.00000 0.00000 + 33 2.00000 1.00000 0.00000 + 36 2.00000 0.00000 0.00000 + 38 1.00000 2.00000 0.00000 + 41 1.00000 1.00000 0.00000 + 44 1.00000 0.00000 0.00000 + 47 0.00000 2.00000 0.00000 + 49 0.00000 1.00000 0.00000 + 52 0.00000 0.00000 0.00000 +End Nodes + + +Begin Elements UpdatedLagrangianAxisymmetry2D3N// GUI group identifier: disk + 1 0 44 41 52 + 2 0 41 49 52 + 3 0 36 33 44 + 4 0 33 41 44 + 5 0 29 22 36 + 6 0 22 33 36 + 7 0 20 12 29 + 8 0 12 22 29 + 9 0 17 10 20 + 10 0 10 12 20 + 11 0 41 38 49 + 12 0 38 47 49 + 13 0 33 26 41 + 14 0 26 38 41 + 15 0 22 18 33 + 16 0 18 26 33 + 17 0 12 11 22 + 18 0 11 18 22 + 19 0 10 5 12 + 20 0 5 11 12 +End Elements + +Begin SubModelPart Parts_disk // Group disk // Subtree Parts + Begin SubModelPartNodes + 5 + 10 + 11 + 12 + 17 + 18 + 20 + 22 + 26 + 29 + 33 + 36 + 38 + 41 + 44 + 47 + 49 + 52 + End SubModelPartNodes + Begin SubModelPartElements + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + End SubModelPartElements + Begin SubModelPartConditions + End SubModelPartConditions +End SubModelPart diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_Grid.mdpa b/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_Grid.mdpa new file mode 100644 index 000000000000..c50125ac06b6 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_Grid.mdpa @@ -0,0 +1,226 @@ +Begin ModelPartData +// VARIABLE_NAME value +End ModelPartData + +Begin Properties 0 +End Properties +Begin Nodes + 1 6.0000000000 3.0000000000 0.0000000000 + 2 6.0000000000 2.0000000000 0.0000000000 + 3 5.0000000000 3.0000000000 0.0000000000 + 4 5.0000000000 2.0000000000 0.0000000000 + 5 5.0000000000 2.0000000000 0.0000000000 + 6 4.0000000000 3.0000000000 0.0000000000 + 7 6.0000000000 1.0000000000 0.0000000000 + 8 5.0000000000 1.0000000000 0.0000000000 + 9 4.0000000000 2.0000000000 0.0000000000 + 10 5.0000000000 1.0000000000 0.0000000000 + 11 4.0000000000 2.0000000000 0.0000000000 + 12 4.0000000000 1.0000000000 0.0000000000 + 13 4.0000000000 1.0000000000 0.0000000000 + 14 6.0000000000 0.0000000000 0.0000000000 + 15 3.0000000000 3.0000000000 0.0000000000 + 16 5.0000000000 0.0000000000 0.0000000000 + 17 5.0000000000 0.0000000000 0.0000000000 + 18 3.0000000000 2.0000000000 0.0000000000 + 19 3.0000000000 2.0000000000 0.0000000000 + 20 4.0000000000 0.0000000000 0.0000000000 + 21 4.0000000000 0.0000000000 0.0000000000 + 22 3.0000000000 1.0000000000 0.0000000000 + 23 3.0000000000 1.0000000000 0.0000000000 + 24 6.0000000000 -1.0000000000 0.0000000000 + 25 2.0000000000 3.0000000000 0.0000000000 + 26 2.0000000000 2.0000000000 0.0000000000 + 27 2.0000000000 2.0000000000 0.0000000000 + 28 5.0000000000 -1.0000000000 0.0000000000 + 29 3.0000000000 0.0000000000 0.0000000000 + 30 3.0000000000 0.0000000000 0.0000000000 + 31 4.0000000000 -1.0000000000 0.0000000000 + 32 2.0000000000 1.0000000000 0.0000000000 + 33 2.0000000000 1.0000000000 0.0000000000 + 34 1.0000000000 3.0000000000 0.0000000000 + 35 3.0000000000 -1.0000000000 0.0000000000 + 36 2.0000000000 0.0000000000 0.0000000000 + 37 2.0000000000 0.0000000000 0.0000000000 + 38 1.0000000000 2.0000000000 0.0000000000 + 39 1.0000000000 2.0000000000 0.0000000000 + 40 1.0000000000 1.0000000000 0.0000000000 + 41 1.0000000000 1.0000000000 0.0000000000 + 42 2.0000000000 -1.0000000000 0.0000000000 + 43 1.0000000000 0.0000000000 0.0000000000 + 44 1.0000000000 0.0000000000 0.0000000000 + 45 0.0000000000 3.0000000000 0.0000000000 + 46 0.0000000000 2.0000000000 0.0000000000 + 47 0.0000000000 2.0000000000 0.0000000000 + 48 0.0000000000 1.0000000000 0.0000000000 + 49 0.0000000000 1.0000000000 0.0000000000 + 50 1.0000000000 -1.0000000000 0.0000000000 + 51 0.0000000000 0.0000000000 0.0000000000 + 52 0.0000000000 0.0000000000 0.0000000000 + 53 0.0000000000 -1.0000000000 0.0000000000 +End Nodes + + +Begin Elements Element2D3N// GUI group identifier: grid + 21 0 50 43 53 + 22 0 43 51 53 + 23 0 42 37 50 + 24 0 37 43 50 + 25 0 35 30 42 + 26 0 30 37 42 + 27 0 31 21 35 + 28 0 21 30 35 + 29 0 28 16 31 + 30 0 16 21 31 + 31 0 24 14 28 + 32 0 14 16 28 + 33 0 43 40 51 + 34 0 40 48 51 + 35 0 37 32 43 + 36 0 32 40 43 + 37 0 30 23 37 + 38 0 23 32 37 + 39 0 21 13 30 + 40 0 13 23 30 + 41 0 16 8 21 + 42 0 8 13 21 + 43 0 14 7 16 + 44 0 7 8 16 + 45 0 40 39 48 + 46 0 39 46 48 + 47 0 32 27 40 + 48 0 27 39 40 + 49 0 23 19 32 + 50 0 19 27 32 + 51 0 13 9 23 + 52 0 9 19 23 + 53 0 8 4 13 + 54 0 4 9 13 + 55 0 7 2 8 + 56 0 2 4 8 + 57 0 39 34 46 + 58 0 34 45 46 + 59 0 27 25 39 + 60 0 25 34 39 + 61 0 19 15 27 + 62 0 15 25 27 + 63 0 9 6 19 + 64 0 6 15 19 + 65 0 4 3 9 + 66 0 3 6 9 + 67 0 2 1 4 + 68 0 1 3 4 +End Elements + +Begin SubModelPart Parts_grid // Group grid // Subtree Parts + Begin SubModelPartNodes + 1 + 2 + 3 + 4 + 6 + 7 + 8 + 9 + 13 + 14 + 15 + 16 + 19 + 21 + 23 + 24 + 25 + 27 + 28 + 30 + 31 + 32 + 34 + 35 + 37 + 39 + 40 + 42 + 43 + 45 + 46 + 48 + 50 + 51 + 53 + End SubModelPartNodes + Begin SubModelPartElements + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + End SubModelPartElements + Begin SubModelPartConditions + End SubModelPartConditions +End SubModelPart +Begin SubModelPart DISPLACEMENT_bc // Group bc // Subtree DISPLACEMENT + Begin SubModelPartNodes + 1 + 2 + 3 + 4 + 5 + 7 + 8 + 10 + 14 + 16 + 17 + 24 + 28 + End SubModelPartNodes + Begin SubModelPartElements + End SubModelPartElements + Begin SubModelPartConditions + End SubModelPartConditions +End SubModelPart diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_materials.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_materials.json new file mode 100644 index 000000000000..2c3ae397134c --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_materials.json @@ -0,0 +1,19 @@ +{ + "properties" : [{ + "model_part_name" : "Initial_MPM_Material.Parts_disk", + "properties_id" : 1, + "Material" : { + "constitutive_law" : { + "name" : "LinearElasticIsotropicAxisym2DLaw" + }, + "Variables" : { + "THICKNESS" : 1.0, + "PARTICLES_PER_ELEMENT" : 1, + "DENSITY" : 10.0, + "YOUNG_MODULUS" : 4000.0, + "POISSON_RATIO" : 0.29 + }, + "Tables" : {} + } + }] +} diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_parameters.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_parameters.json new file mode 100644 index 000000000000..6bf0ffc43111 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_parameters.json @@ -0,0 +1,93 @@ +{ + "problem_data" : { + "problem_name" : "tri_compressible_explicit_axisym_disk_test", + "parallel_type" : "OpenMP", + "echo_level" : 0, + "start_time" : 0.0, + "end_time" : 0.25 + }, + "solver_settings" : { + "solver_type" : "Dynamic", + "model_part_name" : "MPM_Material", + "domain_size" : 2, + "echo_level" : 0, + "analysis_type" : "linear", + "time_integration_method" : "explicit", + "scheme_type" : "central_difference", + "stress_update" : "musl", + "compressible" : true, + "model_import_settings" : { + "input_type" : "mdpa", + "input_filename" : "explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_Body" + }, + "material_import_settings" : { + "materials_filename" : "explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_materials.json" + }, + "time_stepping" : { + "time_step" : 0.025 + }, + "convergence_criterion" : "residual_criterion", + "displacement_relative_tolerance" : 0.0001, + "displacement_absolute_tolerance" : 1e-9, + "residual_relative_tolerance" : 0.0001, + "residual_absolute_tolerance" : 1e-9, + "max_iteration" : 10, + "problem_domain_sub_model_part_list" : ["Parts_disk","Parts_grid"], + "processes_sub_model_part_list" : ["DISPLACEMENT_bc"], + "grid_model_import_settings" : { + "input_type" : "mdpa", + "input_filename" : "explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_Grid" + }, + "axis_symmetric_flag" : true, + "pressure_dofs" : false + }, + "processes" : { + "constraints_process_list" : [{ + "python_module" : "assign_vector_variable_process", + "kratos_module" : "KratosMultiphysics", + "Parameters" : { + "model_part_name" : "Background_Grid.DISPLACEMENT_bc", + "variable_name" : "DISPLACEMENT", + "constrained" : [true,true,true], + "value" : [0.0,0.0,0.0], + "interval" : [0.0,"End"] + } + }], + "loads_process_list" : [], + "gravity" : [{ + "python_module" : "assign_gravity_to_particle_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "process_name" : "AssignGravityToParticleProcess", + "Parameters" : { + "model_part_name" : "MPM_Material", + "variable_name" : "MP_VOLUME_ACCELERATION", + "modulus" : 0.01, + "direction" : [0.0,-1.0,0.0] + } + }], + "list_other_processes" : [{ + "python_module" : "particle_from_json_check_result_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "help" : "", + "process_name" : "ParticleFromJsonCheckResultProcess", + "Parameters" : { + "check_variables" : ["MP_VELOCITY","MP_DISPLACEMENT"], + "input_file_name" : "explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_results.json", + "model_part_name" : "MPM_Material", + "time_frequency" : 0.025 + } + }] + }, + "print_output_process" : [{ + "python_module" : "particle_json_output_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "help" : "", + "process_name" : "ParticleJsonOutputProcess", + "Parameters" : { + "gauss_points_output_variables" : ["MP_VELOCITY","MP_DISPLACEMENT","MP_VOLUME"], + "output_file_name" : "explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_results.json", + "model_part_name" : "MPM_Material", + "time_frequency" : 0.025 + } + }] +} diff --git a/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py b/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py index 4674fef081d1..92f75a558d4f 100644 --- a/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py +++ b/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py @@ -112,4 +112,7 @@ class ExplicitOscillatingPointGravityTest(ParticleMechanicsTestFactory): file_name = "explicit_tests/oscillating_point/explicit_oscillating_point_gravity_test" class ExplicitOscillatingPointTriTest(ParticleMechanicsTestFactory): - file_name = "explicit_tests/oscillating_point/tri_explicit_oscillating_point_test" \ No newline at end of file + file_name = "explicit_tests/oscillating_point/tri_explicit_oscillating_point_test" + +class ExplicitAxisymDiskTriCompressibleTest(ParticleMechanicsTestFactory): + file_name = "explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test" \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py index fbbcb40defe2..7ea376e90161 100644 --- a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py +++ b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py @@ -35,6 +35,8 @@ from particle_mechanics_test_factory import ExplicitOscillatingPointYCompressibleTest as TExplicitOscillatingPointYCompressibleTest from particle_mechanics_test_factory import ExplicitOscillatingPointGravityTest as TExplicitOscillatingPointGravityTest from particle_mechanics_test_factory import ExplicitOscillatingPointTriTest as TExplicitOscillatingPointTriTest +from particle_mechanics_test_factory import ExplicitAxisymDiskTriCompressibleTest as TExplicitAxisymDiskTriCompressibleTest + # Import from Test Factories (with different analysis flows) @@ -112,6 +114,7 @@ def AssembleTestSuites(): nightSuite.addTest(TExplicitOscillatingPointYCompressibleTest('test_execution')) nightSuite.addTest(TExplicitOscillatingPointGravityTest('test_execution')) nightSuite.addTest(TExplicitOscillatingPointTriTest('test_execution')) + nightSuite.addTest(TExplicitAxisymDiskTriCompressibleTest('test_execution')) ### Adding Validation Tests ## For very long tests that should not be in nighly and you can use to validate From 18ffc5e47e84fc2564e67f97c6d2750d67a61ab4 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Tue, 21 Apr 2020 12:13:48 +1000 Subject: [PATCH 179/314] add quad explicit axisymmetric test --- ..._explicit_axisym_disk_test_materials.json} | 0 ...ressible_explicit_axisym_disk_results.json | 1 + ...ssible_explicit_axisym_disk_test_Body.mdpa | 77 ++++++++ ...ssible_explicit_axisym_disk_test_Grid.mdpa | 178 ++++++++++++++++++ ..._explicit_axisym_disk_test_parameters.json | 93 +++++++++ ..._explicit_axisym_disk_test_parameters.json | 2 +- .../tests/particle_mechanics_test_factory.py | 5 +- .../test_ParticleMechanicsApplication.py | 3 +- 8 files changed, 356 insertions(+), 3 deletions(-) rename applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/{tri_compressible_explicit_axisym_disk_test_materials.json => compressible_explicit_axisym_disk_test_materials.json} (100%) create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/quad_compressible_explicit_axisym_disk_results.json create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/quad_compressible_explicit_axisym_disk_test_Body.mdpa create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/quad_compressible_explicit_axisym_disk_test_Grid.mdpa create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/quad_compressible_explicit_axisym_disk_test_parameters.json diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_materials.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/compressible_explicit_axisym_disk_test_materials.json similarity index 100% rename from applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_materials.json rename to applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/compressible_explicit_axisym_disk_test_materials.json diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/quad_compressible_explicit_axisym_disk_results.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/quad_compressible_explicit_axisym_disk_results.json new file mode 100644 index 000000000000..84c294fe578c --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/quad_compressible_explicit_axisym_disk_results.json @@ -0,0 +1 @@ +{"TIME": [0.05, 0.07500000000000001, 0.125, 0.175, 0.22499999999999998, 0.27499999999999997], "PARTICLE_54": {"MP_VELOCITY_X": [1.1887059094010329e-21, 6.435414309468191e-08, 1.415867502850197e-06, 6.8373912809986795e-06, 1.6311211589912776e-05, 2.2467359242926456e-05], "MP_VELOCITY_Y": [-0.0005, -0.0007499374684180468, -0.0012485765740926607, -0.00174263242524855, -0.0022299276219619048, -0.0027135190427205226], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [2.1252037887020895e-24, 8.808778954155197e-10, 3.582325736760653e-08, 2.8357324447907173e-07, 1.1469275246652193e-06, 3.1362258024141355e-06], "MP_DISPLACEMENT_Y": [-1.25e-05, -2.8123307597547817e-05, -7.806747719166728e-05, -0.00015269057753533702, -0.00025137489182127786, -0.0003732289895630642], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [3.141592653589793, 3.141592664659203, 3.141593038919138, 3.141595605752406, 3.1416046725633477, 3.1416264431097463]}, "PARTICLE_55": {"MP_VELOCITY_X": [9.395897302754166e-08, 7.398010660881141e-07, 8.8409083387604e-06, 4.119599201803964e-05, 0.00011851359564662441, 0.0002507190632479003], "MP_VELOCITY_Y": [-0.0004999097382969533, -0.0007493832243078351, -0.001243716526070033, -0.0017224256173251672, -0.0021708279428872277, -0.0025754088368869004], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [3.462616517799095e-24, 1.0037522953497107e-08, 1.8128748158305563e-07, 9.973044321653507e-07, 3.3794736934045363e-06, 8.556030915973162e-06], "MP_DISPLACEMENT_Y": [-1.25e-05, -2.809087873313603e-05, -7.759740739758237e-05, -0.00015060983252357268, -0.0002454991289829718, -0.0003601559999919463], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [9.42477796076938, 9.424778179831215, 9.424781360980294, 9.424794168403025, 9.424826832992864, 9.424891600772332]}, "PARTICLE_56": {"MP_VELOCITY_X": [1.1156672752490264e-06, 5.695360480456211e-06, 3.5512426345311656e-05, 0.00010974320722590466, 0.00024343664630887649, 0.00043897526985769015], "MP_VELOCITY_Y": [-0.0004979787088410854, -0.0007400386624075336, -0.0011932426722055028, -0.0015906156993861099, -0.0019243744180447446, -0.00219197039612103], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [1.2420099835548292e-08, 9.377182680390247e-08, 8.920288285064319e-07, 3.5579460998766604e-06, 9.493870207786705e-06, 1.9912210580987643e-05], "MP_DISPLACEMENT_Y": [-1.2450320260469304e-05, -2.7798385415566385e-05, -7.529347873269734e-05, -0.00014227171567751667, -0.0002247199426510779, -0.00031872334394953273], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [15.707963736176893, 15.70796622774787, 15.707987432877095, 15.708049498867478, 15.708168938915515, 15.708345310381292]}, "PARTICLE_57": {"MP_VELOCITY_X": [1.0807343521720433e-05, 3.458458453193833e-05, 0.0001451831758839824, 0.0003434826320926078, 0.0005936577218961342, 0.000829124180769531], "MP_VELOCITY_Y": [-0.00048127106364503875, -0.0006945031132284983, -0.0010273856904156398, -0.0012105399413729681, -0.0012494370979541508, -0.0011824167139150902], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [3.371173697956945e-08, 2.1252470955141345e-07, 1.7538220699336956e-06, 6.396090922136736e-06, 1.5726631899664814e-05, 3.0358812644630736e-05], "MP_DISPLACEMENT_Y": [-1.1486249343518389e-05, -2.4753031806376934e-05, -6.386106519529978e-05, -0.00011509259131175103, -0.00017243750808366076, -0.00023065232393561512], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [21.991149177150245, 21.9911518148598, 21.99117151788408, 21.991224185292225, 21.991317159036516, 21.99143924722726]}, "PARTICLE_58": {"MP_VELOCITY_X": [9.785615285453428e-06, 2.956604216121511e-05, 0.000117055700836478, 0.00026720528121910607, 0.0004469872166756318, 0.0006002956587141111], "MP_VELOCITY_Y": [-0.00029570209302287717, -0.0003914070568805765, -0.0005167521764500597, -0.0005374599666136481, -0.0004558037972730677, -0.000297985302329637], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [2.1291570608304855e-08, 1.2790827214719851e-07, 1.0123853093734841e-06, 3.600301548577188e-06, 8.654952042703879e-06, 1.6311513785084536e-05], "MP_DISPLACEMENT_Y": [-5.285929083047e-06, -1.098471740441969e-05, -2.7149849978887618e-05, -4.720244785337976e-05, -6.798115100871936e-05, -8.678994212777769e-05], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [28.274332811658248, 28.2743274519337, 28.27428299330829, 28.274152917835735, 28.273898864561776, 28.273514038254774]}, "PARTICLE_59": {"MP_VELOCITY_X": [-2.0954595258785044e-21, -6.435291873540076e-08, -1.415814102620114e-06, -6.837008324967555e-06, -1.6310050875891775e-05, -2.2464711020448536e-05], "MP_VELOCITY_Y": [-0.0005, -0.0007499374698090893, -0.0012485766925559747, -0.0017426341906137152, -0.002229939893218213, -0.0027135731857849898], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-2.12520378870209e-24, -8.808278044884598e-10, -3.58192566965467e-08, -2.8352025455657975e-07, -1.1466087486797178e-06, -3.135007629427241e-06], "MP_DISPLACEMENT_Y": [-1.25e-05, -2.8123307606507684e-05, -7.806747857845034e-05, -0.0001526906049575477, -0.0002513751178663407, -0.00037323012195539706], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [3.1415926535897927, 3.141592642520956, 3.141592268298417, 3.141589701867237, 3.1415806369518795, 3.1415588716969842]}, "PARTICLE_60": {"MP_VELOCITY_X": [-9.395630151143028e-08, -7.397687543779026e-07, -8.840147676245517e-06, -4.11901097265332e-05, -0.00011848848930251708, -0.0002506454693818696], "MP_VELOCITY_Y": [-0.0004999097392526725, -0.000749383240046966, -0.0012437170758600182, -0.0017224310127963536, -0.00217085515669602, -0.0025754994198737024], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-3.462616517799095e-24, -1.0037226304366113e-08, -1.812714057843179e-07, -9.971270865660335e-07, -3.378488073057264e-06, -8.552402796265904e-06], "MP_DISPLACEMENT_Y": [-1.25e-05, -2.8090878766109986e-05, -7.759741166928983e-05, -0.00015060990186101974, -0.00024549962062696333, -0.0003601581517624038], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [9.424777960769378, 9.424777741712477, 9.42477456074377, 9.42476175452765, 9.424729093727615, 9.424664333204717]}, "PARTICLE_61": {"MP_VELOCITY_X": [-1.115653133986686e-06, -5.695225367681801e-06, -3.5510211848708285e-05, -0.00010972963567699443, -0.00024338666979504788, -0.00043884325927145333], "MP_VELOCITY_Y": [-0.0004979787115213319, -0.0007400387130384589, -0.0011932442428058813, -0.0015906294893758396, -0.001924438371079328, -0.0021921675571911223], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-1.241978933693365e-08, -9.376825828367277e-08, -8.919540798416012e-07, -3.5574078451451586e-06, -9.491612000318574e-06, -1.9905440363424e-05], "MP_DISPLACEMENT_Y": [-1.245032018284465e-05, -2.7798384570182876e-05, -7.529346887294263e-05, -0.00014227171630413132, -0.00022472027482729284, -0.00031872534151757687], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [15.70796279973513, 15.70796030829569, 15.70793910544904, 15.707877050745868, 15.707757640304699, 15.707581317847737]}, "PARTICLE_62": {"MP_VELOCITY_X": [-1.0807136155770147e-05, -3.458360505584089e-05, -0.00014517537437678176, -0.0003434529739225141, -0.0005935847960519392, -0.0008289927042614902], "MP_VELOCITY_Y": [-0.0004812709634486271, -0.0006945026844231563, -0.0010273833535980265, -0.0012105370674278272, -0.0012494507535823732, -0.001182492091004292], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-3.371081934527082e-08, -2.1251563567304523e-07, -1.7536808531912771e-06, -6.3952949368245805e-06, -1.5723958255196843e-05, -3.0352332544518483e-05], "MP_DISPLACEMENT_Y": [-1.1486247931193262e-05, -2.4753019240789197e-05, -6.386093334712732e-05, -0.00011509210213953738, -0.0001724365365719806, -0.00023065150388717624], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [21.991147973153705, 21.991145335989852, 21.991125640889862, 21.99107300717032, 21.990980118102225, 21.9908581792017]}, "PARTICLE_63": {"MP_VELOCITY_X": [-9.785459257523745e-06, -2.956556986655703e-05, -0.00011705527236273078, -0.00026721208598761575, -0.0004470184952408469, -0.0006003718279336749], "MP_VELOCITY_Y": [-0.0002957019912577462, -0.0003914066004013113, -0.000516749052198721, -0.0005374506187918037, -0.0004557897428006654, -0.00029798496027952744], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-2.1291096543455706e-08, -1.279050315084858e-07, -1.0123695410227278e-06, -3.600345585757138e-06, -8.655424223046917e-06, -1.631325102522805e-05], "MP_DISPLACEMENT_Y": [-5.285927748346526e-06, -1.0984705952050413e-05, -2.7149737815483508e-05, -4.7202040031242135e-05, -6.798023224218675e-05, -8.678843454107345e-05], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [28.274334952096552, 28.274340310512827, 28.27438476858795, 28.274514861839734, 28.274768978984266, 28.27515393782595]}} \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/quad_compressible_explicit_axisym_disk_test_Body.mdpa b/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/quad_compressible_explicit_axisym_disk_test_Body.mdpa new file mode 100644 index 000000000000..b06b9e70d156 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/quad_compressible_explicit_axisym_disk_test_Body.mdpa @@ -0,0 +1,77 @@ +Begin ModelPartData +// VARIABLE_NAME value +End ModelPartData + +Begin Properties 0 +End Properties +Begin Nodes + 5 5.00000 2.00000 0.00000 + 10 5.00000 1.00000 0.00000 + 11 4.00000 2.00000 0.00000 + 12 4.00000 1.00000 0.00000 + 17 5.00000 0.00000 0.00000 + 18 3.00000 2.00000 0.00000 + 20 4.00000 0.00000 0.00000 + 22 3.00000 1.00000 0.00000 + 26 2.00000 2.00000 0.00000 + 29 3.00000 0.00000 0.00000 + 33 2.00000 1.00000 0.00000 + 36 2.00000 0.00000 0.00000 + 38 1.00000 2.00000 0.00000 + 41 1.00000 1.00000 0.00000 + 44 1.00000 0.00000 0.00000 + 47 0.00000 2.00000 0.00000 + 49 0.00000 1.00000 0.00000 + 52 0.00000 0.00000 0.00000 +End Nodes + + +Begin Elements UpdatedLagrangianAxisymmetry2D4N// GUI group identifier: disk + 1 0 44 41 49 52 + 2 0 36 33 41 44 + 3 0 29 22 33 36 + 4 0 20 12 22 29 + 5 0 17 10 12 20 + 6 0 41 38 47 49 + 7 0 33 26 38 41 + 8 0 22 18 26 33 + 9 0 12 11 18 22 + 10 0 10 5 11 12 +End Elements + +Begin SubModelPart Parts_disk // Group disk // Subtree Parts + Begin SubModelPartNodes + 5 + 10 + 11 + 12 + 17 + 18 + 20 + 22 + 26 + 29 + 33 + 36 + 38 + 41 + 44 + 47 + 49 + 52 + End SubModelPartNodes + Begin SubModelPartElements + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + End SubModelPartElements + Begin SubModelPartConditions + End SubModelPartConditions +End SubModelPart diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/quad_compressible_explicit_axisym_disk_test_Grid.mdpa b/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/quad_compressible_explicit_axisym_disk_test_Grid.mdpa new file mode 100644 index 000000000000..61fa166b6c86 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/quad_compressible_explicit_axisym_disk_test_Grid.mdpa @@ -0,0 +1,178 @@ +Begin ModelPartData +// VARIABLE_NAME value +End ModelPartData + +Begin Properties 0 +End Properties +Begin Nodes + 1 6.0000000000 3.0000000000 0.0000000000 + 2 6.0000000000 2.0000000000 0.0000000000 + 3 5.0000000000 3.0000000000 0.0000000000 + 4 5.0000000000 2.0000000000 0.0000000000 + 5 5.0000000000 2.0000000000 0.0000000000 + 6 4.0000000000 3.0000000000 0.0000000000 + 7 6.0000000000 1.0000000000 0.0000000000 + 8 5.0000000000 1.0000000000 0.0000000000 + 9 4.0000000000 2.0000000000 0.0000000000 + 10 5.0000000000 1.0000000000 0.0000000000 + 11 4.0000000000 2.0000000000 0.0000000000 + 12 4.0000000000 1.0000000000 0.0000000000 + 13 4.0000000000 1.0000000000 0.0000000000 + 14 6.0000000000 0.0000000000 0.0000000000 + 15 3.0000000000 3.0000000000 0.0000000000 + 16 5.0000000000 0.0000000000 0.0000000000 + 17 5.0000000000 0.0000000000 0.0000000000 + 18 3.0000000000 2.0000000000 0.0000000000 + 19 3.0000000000 2.0000000000 0.0000000000 + 20 4.0000000000 0.0000000000 0.0000000000 + 21 4.0000000000 0.0000000000 0.0000000000 + 22 3.0000000000 1.0000000000 0.0000000000 + 23 3.0000000000 1.0000000000 0.0000000000 + 24 6.0000000000 -1.0000000000 0.0000000000 + 25 2.0000000000 3.0000000000 0.0000000000 + 26 2.0000000000 2.0000000000 0.0000000000 + 27 2.0000000000 2.0000000000 0.0000000000 + 28 5.0000000000 -1.0000000000 0.0000000000 + 29 3.0000000000 0.0000000000 0.0000000000 + 30 3.0000000000 0.0000000000 0.0000000000 + 31 4.0000000000 -1.0000000000 0.0000000000 + 32 2.0000000000 1.0000000000 0.0000000000 + 33 2.0000000000 1.0000000000 0.0000000000 + 34 1.0000000000 3.0000000000 0.0000000000 + 35 3.0000000000 -1.0000000000 0.0000000000 + 36 2.0000000000 0.0000000000 0.0000000000 + 37 2.0000000000 0.0000000000 0.0000000000 + 38 1.0000000000 2.0000000000 0.0000000000 + 39 1.0000000000 2.0000000000 0.0000000000 + 40 1.0000000000 1.0000000000 0.0000000000 + 41 1.0000000000 1.0000000000 0.0000000000 + 42 2.0000000000 -1.0000000000 0.0000000000 + 43 1.0000000000 0.0000000000 0.0000000000 + 44 1.0000000000 0.0000000000 0.0000000000 + 45 0.0000000000 3.0000000000 0.0000000000 + 46 0.0000000000 2.0000000000 0.0000000000 + 47 0.0000000000 2.0000000000 0.0000000000 + 48 0.0000000000 1.0000000000 0.0000000000 + 49 0.0000000000 1.0000000000 0.0000000000 + 50 1.0000000000 -1.0000000000 0.0000000000 + 51 0.0000000000 0.0000000000 0.0000000000 + 52 0.0000000000 0.0000000000 0.0000000000 + 53 0.0000000000 -1.0000000000 0.0000000000 +End Nodes + + +Begin Elements Element2D4N// GUI group identifier: grid + 11 0 50 43 51 53 + 12 0 42 37 43 50 + 13 0 35 30 37 42 + 14 0 31 21 30 35 + 15 0 28 16 21 31 + 16 0 24 14 16 28 + 17 0 43 40 48 51 + 18 0 37 32 40 43 + 19 0 30 23 32 37 + 20 0 21 13 23 30 + 21 0 16 8 13 21 + 22 0 14 7 8 16 + 23 0 40 39 46 48 + 24 0 32 27 39 40 + 25 0 23 19 27 32 + 26 0 13 9 19 23 + 27 0 8 4 9 13 + 28 0 7 2 4 8 + 29 0 39 34 45 46 + 30 0 27 25 34 39 + 31 0 19 15 25 27 + 32 0 9 6 15 19 + 33 0 4 3 6 9 + 34 0 2 1 3 4 +End Elements + +Begin SubModelPart Parts_grid // Group grid // Subtree Parts + Begin SubModelPartNodes + 1 + 2 + 3 + 4 + 6 + 7 + 8 + 9 + 13 + 14 + 15 + 16 + 19 + 21 + 23 + 24 + 25 + 27 + 28 + 30 + 31 + 32 + 34 + 35 + 37 + 39 + 40 + 42 + 43 + 45 + 46 + 48 + 50 + 51 + 53 + End SubModelPartNodes + Begin SubModelPartElements + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + End SubModelPartElements + Begin SubModelPartConditions + End SubModelPartConditions +End SubModelPart +Begin SubModelPart DISPLACEMENT_bc // Group bc // Subtree DISPLACEMENT + Begin SubModelPartNodes + 1 + 2 + 3 + 4 + 5 + 7 + 8 + 10 + 14 + 16 + 17 + 24 + 28 + End SubModelPartNodes + Begin SubModelPartElements + End SubModelPartElements + Begin SubModelPartConditions + End SubModelPartConditions +End SubModelPart diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/quad_compressible_explicit_axisym_disk_test_parameters.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/quad_compressible_explicit_axisym_disk_test_parameters.json new file mode 100644 index 000000000000..40d7c7952573 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/quad_compressible_explicit_axisym_disk_test_parameters.json @@ -0,0 +1,93 @@ +{ + "problem_data" : { + "problem_name" : "quad_compressible_explicit_axisym_disk_test", + "parallel_type" : "OpenMP", + "echo_level" : 0, + "start_time" : 0.0, + "end_time" : 0.25 + }, + "solver_settings" : { + "solver_type" : "Dynamic", + "model_part_name" : "MPM_Material", + "domain_size" : 2, + "echo_level" : 0, + "analysis_type" : "linear", + "time_integration_method" : "explicit", + "scheme_type" : "central_difference", + "stress_update" : "musl", + "compressible" : true, + "model_import_settings" : { + "input_type" : "mdpa", + "input_filename" : "explicit_tests/axisymmetric_disk/quad_compressible_explicit_axisym_disk_test_Body" + }, + "material_import_settings" : { + "materials_filename" : "explicit_tests/axisymmetric_disk/compressible_explicit_axisym_disk_test_materials.json" + }, + "time_stepping" : { + "time_step" : 0.025 + }, + "convergence_criterion" : "residual_criterion", + "displacement_relative_tolerance" : 0.0001, + "displacement_absolute_tolerance" : 1e-9, + "residual_relative_tolerance" : 0.0001, + "residual_absolute_tolerance" : 1e-9, + "max_iteration" : 10, + "problem_domain_sub_model_part_list" : ["Parts_disk","Parts_grid"], + "processes_sub_model_part_list" : ["DISPLACEMENT_bc"], + "grid_model_import_settings" : { + "input_type" : "mdpa", + "input_filename" : "explicit_tests/axisymmetric_disk/quad_compressible_explicit_axisym_disk_test_Grid" + }, + "axis_symmetric_flag" : true, + "pressure_dofs" : false + }, + "processes" : { + "constraints_process_list" : [{ + "python_module" : "assign_vector_variable_process", + "kratos_module" : "KratosMultiphysics", + "Parameters" : { + "model_part_name" : "Background_Grid.DISPLACEMENT_bc", + "variable_name" : "DISPLACEMENT", + "constrained" : [true,true,true], + "value" : [0.0,0.0,0.0], + "interval" : [0.0,"End"] + } + }], + "loads_process_list" : [], + "gravity" : [{ + "python_module" : "assign_gravity_to_particle_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "process_name" : "AssignGravityToParticleProcess", + "Parameters" : { + "model_part_name" : "MPM_Material", + "variable_name" : "MP_VOLUME_ACCELERATION", + "modulus" : 0.01, + "direction" : [0.0,-1.0,0.0] + } + }], + "list_other_processes" : [{ + "python_module" : "particle_from_json_check_result_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "help" : "", + "process_name" : "ParticleFromJsonCheckResultProcess", + "Parameters" : { + "check_variables" : ["MP_VELOCITY","MP_DISPLACEMENT"], + "input_file_name" : "explicit_tests/axisymmetric_disk/quad_compressible_explicit_axisym_disk_results.json", + "model_part_name" : "MPM_Material", + "time_frequency" : 0.025 + } + }] + }, + "print_output_process" : [{ + "python_module" : "particle_json_output_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "help" : "", + "process_name" : "ParticleJsonOutputProcess", + "Parameters" : { + "gauss_points_output_variables" : ["MP_VELOCITY","MP_DISPLACEMENT","MP_VOLUME"], + "output_file_name" : "explicit_tests/axisymmetric_disk/quad_compressible_explicit_axisym_disk_results.json", + "model_part_name" : "MPM_Material", + "time_frequency" : 0.025 + } + }] +} diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_parameters.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_parameters.json index 6bf0ffc43111..84a1126bca12 100644 --- a/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_parameters.json +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_parameters.json @@ -21,7 +21,7 @@ "input_filename" : "explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_Body" }, "material_import_settings" : { - "materials_filename" : "explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_materials.json" + "materials_filename" : "explicit_tests/axisymmetric_disk/compressible_explicit_axisym_disk_test_materials.json" }, "time_stepping" : { "time_step" : 0.025 diff --git a/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py b/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py index 92f75a558d4f..e541b4a687bd 100644 --- a/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py +++ b/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py @@ -115,4 +115,7 @@ class ExplicitOscillatingPointTriTest(ParticleMechanicsTestFactory): file_name = "explicit_tests/oscillating_point/tri_explicit_oscillating_point_test" class ExplicitAxisymDiskTriCompressibleTest(ParticleMechanicsTestFactory): - file_name = "explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test" \ No newline at end of file + file_name = "explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test" + +class ExplicitAxisymDiskQuadCompressibleTest(ParticleMechanicsTestFactory): + file_name = "explicit_tests/axisymmetric_disk/quad_compressible_explicit_axisym_disk_test" \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py index 7ea376e90161..8fc07a2cfa73 100644 --- a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py +++ b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py @@ -36,7 +36,7 @@ from particle_mechanics_test_factory import ExplicitOscillatingPointGravityTest as TExplicitOscillatingPointGravityTest from particle_mechanics_test_factory import ExplicitOscillatingPointTriTest as TExplicitOscillatingPointTriTest from particle_mechanics_test_factory import ExplicitAxisymDiskTriCompressibleTest as TExplicitAxisymDiskTriCompressibleTest - +from particle_mechanics_test_factory import ExplicitAxisymDiskQuadCompressibleTest as TExplicitAxisymDiskQuadCompressibleTest # Import from Test Factories (with different analysis flows) @@ -115,6 +115,7 @@ def AssembleTestSuites(): nightSuite.addTest(TExplicitOscillatingPointGravityTest('test_execution')) nightSuite.addTest(TExplicitOscillatingPointTriTest('test_execution')) nightSuite.addTest(TExplicitAxisymDiskTriCompressibleTest('test_execution')) + nightSuite.addTest(TExplicitAxisymDiskQuadCompressibleTest('test_execution')) ### Adding Validation Tests ## For very long tests that should not be in nighly and you can use to validate From 11a9cd74082eae8e8991b2474e0df82bea1f7667 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Tue, 21 Apr 2020 12:15:17 +1000 Subject: [PATCH 180/314] restore all tests --- .../test_ParticleMechanicsApplication.py | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py index 8fc07a2cfa73..920c33814b25 100644 --- a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py +++ b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py @@ -89,23 +89,23 @@ def AssembleTestSuites(): ## These tests are executed in the nightly build nightSuite = suites['nightly'] - #nightSuite.addTests(smallSuite) - # - #nightSuite.addTest(TAxisSymmetricCircularPlate2DTriTest('test_execution')) - # - #nightSuite.addTest(TBeamCantileverStaticLinearElasticPointLoad2DTriTest('test_execution')) - #nightSuite.addTest(TBeamCantileverStaticLinearElasticParticlePointLoad2DTriTest('test_execution')) - #nightSuite.addTest(TBeamCantileverStaticLinearElasticLineLoad2DQuadTest('test_execution')) - #nightSuite.addTest(TBeamCantileverStaticLinearElasticSurfaceLoad3DHexaTest('test_execution')) - #nightSuite.addTest(TBeamCantileverStaticHyperelasticSelfWeightLoad2DQuadTest('test_execution')) - # - #nightSuite.addTest(TCooksMembraneCompressibleTest('test_execution')) - #nightSuite.addTest(TCooksMembraneUPCompressibleTest('test_execution')) - #nightSuite.addTest(TCooksMembraneUPIncompressibleTest('test_execution')) - # - #nightSuite.addTest(TPenaltyImpositionBeamCantileverStaticHyperelasticSelfWeightLoad2DQuadTest('test_execution')) - # - #nightSuite.addTest(TBeamCantileverLinearStaticHyperelasticSelfWeightLoad2DQuadTest('test_execution')) + nightSuite.addTests(smallSuite) + + nightSuite.addTest(TAxisSymmetricCircularPlate2DTriTest('test_execution')) + + nightSuite.addTest(TBeamCantileverStaticLinearElasticPointLoad2DTriTest('test_execution')) + nightSuite.addTest(TBeamCantileverStaticLinearElasticParticlePointLoad2DTriTest('test_execution')) + nightSuite.addTest(TBeamCantileverStaticLinearElasticLineLoad2DQuadTest('test_execution')) + nightSuite.addTest(TBeamCantileverStaticLinearElasticSurfaceLoad3DHexaTest('test_execution')) + nightSuite.addTest(TBeamCantileverStaticHyperelasticSelfWeightLoad2DQuadTest('test_execution')) + + nightSuite.addTest(TCooksMembraneCompressibleTest('test_execution')) + nightSuite.addTest(TCooksMembraneUPCompressibleTest('test_execution')) + nightSuite.addTest(TCooksMembraneUPIncompressibleTest('test_execution')) + + nightSuite.addTest(TPenaltyImpositionBeamCantileverStaticHyperelasticSelfWeightLoad2DQuadTest('test_execution')) + + nightSuite.addTest(TBeamCantileverLinearStaticHyperelasticSelfWeightLoad2DQuadTest('test_execution')) nightSuite.addTest(TExplicitOscillatingPointUSLTest('test_execution')) nightSuite.addTest(TExplicitOscillatingPointUSFTest('test_execution')) @@ -129,9 +129,9 @@ def AssembleTestSuites(): return suites if __name__ == '__main__': - #KratosMultiphysics.Logger.PrintInfo("Unittests", "\nRunning cpp unit tests ...") - #run_cpp_unit_tests.run() - #KratosMultiphysics.Logger.PrintInfo("Unittests", "Finished running cpp unit tests!") + KratosMultiphysics.Logger.PrintInfo("Unittests", "\nRunning cpp unit tests ...") + run_cpp_unit_tests.run() + KratosMultiphysics.Logger.PrintInfo("Unittests", "Finished running cpp unit tests!") KratosMultiphysics.Logger.PrintInfo("Unittests", "\nRunning python tests ...") KratosUnittest.runTests(AssembleTestSuites()) From d8b07273a79c9f8df82560a37fb94955e9ebbbe4 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Tue, 21 Apr 2020 13:27:19 +1000 Subject: [PATCH 181/314] update axisymmetry element for linux compilation --- .../custom_elements/updated_lagrangian_axisymmetry.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.hpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.hpp index 0ecb49f0ee84..1c13901b3ef1 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.hpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.hpp @@ -183,8 +183,8 @@ class UpdatedLagrangianAxisymmetry const double& rIntegrationWeight) override; /// Calculation of the Explicit Stresses from velocity gradient. - virtual void CalculateExplicitStresses(const ProcessInfo& rCurrentProcessInfo, - GeneralVariables& rVariables); + void CalculateExplicitStresses(const ProcessInfo& rCurrentProcessInfo, + GeneralVariables& rVariables) override; /** * Clear Nodal Forces @@ -260,7 +260,7 @@ class UpdatedLagrangianAxisymmetry const double & rReferenceRadius); /// Calculate and add RHS - void UpdatedLagrangianAxisymmetry::CalculateAndAddRHS(LocalSystemComponents& rLocalSystem, + void CalculateAndAddRHS(LocalSystemComponents& rLocalSystem, GeneralVariables& rVariables, Vector& rVolumeForce, const double& rIntegrationWeight, const ProcessInfo& rCurrentProcessInfo) override; From 584fa5bac8eebd160206dfc669196b000a1b7318 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Tue, 21 Apr 2020 14:14:38 +1000 Subject: [PATCH 182/314] add 3d hex explicit test --- ...icit_oscillating_point_test_materials.json | 19 ++++ ..._explicit_oscillating_point_test_Body.mdpa | 39 ++++++++ ..._explicit_oscillating_point_test_Grid.mdpa | 69 ++++++++++++++ ...cit_oscillating_point_test_parameters.json | 92 +++++++++++++++++++ ...plicit_oscillating_point_test_results.json | 1 + .../tests/particle_mechanics_test_factory.py | 5 +- .../test_ParticleMechanicsApplication.py | 2 + 7 files changed, 226 insertions(+), 1 deletion(-) create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3d_explicit_oscillating_point_test_materials.json create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dhex_compressible_explicit_oscillating_point_test_Body.mdpa create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dhex_compressible_explicit_oscillating_point_test_Grid.mdpa create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dhex_compressible_explicit_oscillating_point_test_parameters.json create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dhex_compressible_explicit_oscillating_point_test_results.json diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3d_explicit_oscillating_point_test_materials.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3d_explicit_oscillating_point_test_materials.json new file mode 100644 index 000000000000..a393765d0307 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3d_explicit_oscillating_point_test_materials.json @@ -0,0 +1,19 @@ +{ + "properties" : [{ + "model_part_name" : "Initial_MPM_Material.Parts_bar", + "properties_id" : 1, + "Material" : { + "constitutive_law" : { + "name" : "LinearElasticIsotropic3DLaw" + }, + "Variables" : { + "PARTICLES_PER_ELEMENT" : 1, + "DENSITY" : 1.0, + "YOUNG_MODULUS" : 39.4784176043574, + "POISSON_RATIO" : 0.0, + "THICKNESS" : 1.0 + }, + "Tables" : {} + } + }] +} diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dhex_compressible_explicit_oscillating_point_test_Body.mdpa b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dhex_compressible_explicit_oscillating_point_test_Body.mdpa new file mode 100644 index 000000000000..49f30dcccad8 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dhex_compressible_explicit_oscillating_point_test_Body.mdpa @@ -0,0 +1,39 @@ +Begin ModelPartData +// VARIABLE_NAME value +End ModelPartData + +Begin Properties 0 +End Properties +Begin Nodes + 3 0.00000 1.00000 1.00000 + 9 0.00000 0.00000 1.00000 + 10 1.00000 1.00000 1.00000 + 12 1.00000 0.00000 1.00000 + 14 0.00000 1.00000 0.00000 + 16 0.00000 0.00000 0.00000 + 18 1.00000 1.00000 0.00000 + 20 1.00000 0.00000 0.00000 +End Nodes + + +Begin Elements UpdatedLagrangian3D8N// GUI group identifier: bar + 3 0 14 18 10 3 16 20 12 9 +End Elements + +Begin SubModelPart Parts_bar // Group bar // Subtree Parts + Begin SubModelPartNodes + 3 + 9 + 10 + 12 + 14 + 16 + 18 + 20 + End SubModelPartNodes + Begin SubModelPartElements + 3 + End SubModelPartElements + Begin SubModelPartConditions + End SubModelPartConditions +End SubModelPart diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dhex_compressible_explicit_oscillating_point_test_Grid.mdpa b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dhex_compressible_explicit_oscillating_point_test_Grid.mdpa new file mode 100644 index 000000000000..bec7aeb09f8e --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dhex_compressible_explicit_oscillating_point_test_Grid.mdpa @@ -0,0 +1,69 @@ +Begin ModelPartData +// VARIABLE_NAME value +End ModelPartData + +Begin Properties 0 +End Properties +Begin Nodes + 1 0.0000000000 1.0000000000 2.0000000000 + 2 1.0000000000 1.0000000000 2.0000000000 + 3 0.0000000000 1.0000000000 1.0000000000 + 4 0.0000000000 0.0000000000 2.0000000000 + 5 0.0000000000 1.0000000000 1.0000000000 + 6 1.0000000000 0.0000000000 2.0000000000 + 7 0.0000000000 0.0000000000 1.0000000000 + 8 1.0000000000 1.0000000000 1.0000000000 + 9 0.0000000000 0.0000000000 1.0000000000 + 10 1.0000000000 1.0000000000 1.0000000000 + 11 1.0000000000 0.0000000000 1.0000000000 + 12 1.0000000000 0.0000000000 1.0000000000 + 13 0.0000000000 1.0000000000 0.0000000000 + 14 0.0000000000 1.0000000000 0.0000000000 + 15 0.0000000000 0.0000000000 0.0000000000 + 16 0.0000000000 0.0000000000 0.0000000000 + 17 1.0000000000 1.0000000000 0.0000000000 + 18 1.0000000000 1.0000000000 0.0000000000 + 19 1.0000000000 0.0000000000 0.0000000000 + 20 1.0000000000 0.0000000000 0.0000000000 +End Nodes + + +Begin Elements Element3D8N// GUI group identifier: grid + 1 0 8 5 13 17 11 7 15 19 + 2 0 2 1 5 8 6 4 7 11 +End Elements + +Begin SubModelPart Parts_grid // Group grid // Subtree Parts + Begin SubModelPartNodes + 1 + 2 + 4 + 5 + 6 + 7 + 8 + 11 + 13 + 15 + 17 + 19 + End SubModelPartNodes + Begin SubModelPartElements + 1 + 2 + End SubModelPartElements + Begin SubModelPartConditions + End SubModelPartConditions +End SubModelPart +Begin SubModelPart DISPLACEMENT_bc // Group bc // Subtree DISPLACEMENT + Begin SubModelPartNodes + 13 + 15 + 17 + 19 + End SubModelPartNodes + Begin SubModelPartElements + End SubModelPartElements + Begin SubModelPartConditions + End SubModelPartConditions +End SubModelPart diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dhex_compressible_explicit_oscillating_point_test_parameters.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dhex_compressible_explicit_oscillating_point_test_parameters.json new file mode 100644 index 000000000000..e1907119ee27 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dhex_compressible_explicit_oscillating_point_test_parameters.json @@ -0,0 +1,92 @@ +{ + "problem_data" : { + "problem_name" : "3dhex_compressible_explicit_oscillating_point_test", + "parallel_type" : "OpenMP", + "echo_level" : 0, + "start_time" : 0.0, + "end_time" : 0.25 + }, + "solver_settings" : { + "solver_type" : "Dynamic", + "model_part_name" : "MPM_Material", + "domain_size" : 3, + "echo_level" : 0, + "analysis_type" : "linear", + "time_integration_method" : "explicit", + "scheme_type" : "forward_euler", + "stress_update" : "usf", + "compressible" : true, + "model_import_settings" : { + "input_type" : "mdpa", + "input_filename" : "explicit_tests/oscillating_point_3d/3dhex_compressible_explicit_oscillating_point_test_Body" + }, + "material_import_settings" : { + "materials_filename" : "explicit_tests/oscillating_point_3d/3d_explicit_oscillating_point_test_materials.json" + }, + "time_stepping" : { + "time_step" : 0.025 + }, + "convergence_criterion" : "residual_criterion", + "displacement_relative_tolerance" : 0.0001, + "displacement_absolute_tolerance" : 1e-9, + "residual_relative_tolerance" : 0.0001, + "residual_absolute_tolerance" : 1e-9, + "max_iteration" : 10, + "problem_domain_sub_model_part_list" : ["Parts_bar","Parts_grid"], + "processes_sub_model_part_list" : ["DISPLACEMENT_bc"], + "grid_model_import_settings" : { + "input_type" : "mdpa", + "input_filename" : "explicit_tests/oscillating_point_3d/3dhex_compressible_explicit_oscillating_point_test_Grid" + }, + "pressure_dofs" : false + }, + "processes" : { + "constraints_process_list" : [{ + "python_module" : "assign_vector_variable_process", + "kratos_module" : "KratosMultiphysics", + "Parameters" : { + "model_part_name" : "Background_Grid.DISPLACEMENT_bc", + "variable_name" : "DISPLACEMENT", + "constrained" : [true,true,true], + "value" : [0.0,0.0,0.0], + "interval" : [0.0,"End"] + } + }], + "loads_process_list" : [], + "list_other_processes" : [{ + "python_module" : "particle_from_json_check_result_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "help" : "", + "process_name" : "ParticleFromJsonCheckResultProcess", + "Parameters" : { + "check_variables" : ["MP_VELOCITY","MP_DISPLACEMENT","MP_VOLUME"], + "input_file_name" : "explicit_tests/oscillating_point_3d/3dhex_compressible_explicit_oscillating_point_test_results.json", + "model_part_name" : "MPM_Material", + "time_frequency" : 0.025 + } + }], + "gravity" : [{ + "python_module" : "assign_gravity_to_particle_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "process_name" : "AssignGravityToParticleProcess", + "Parameters" : { + "model_part_name" : "MPM_Material", + "variable_name" : "MP_VOLUME_ACCELERATION", + "modulus" : 0.1, + "direction" : [0.0,0.0,1.0] + } + }] + }, + "print_output_process" : [{ + "python_module" : "particle_json_output_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "help" : "", + "process_name" : "ParticleJsonOutputProcess", + "Parameters" : { + "gauss_points_output_variables" : ["MP_VELOCITY","MP_DISPLACEMENT","MP_VOLUME"], + "output_file_name" : "explicit_tests/oscillating_point_3d/3dhex_compressible_explicit_oscillating_point_test_results.json", + "model_part_name" : "MPM_Material", + "time_frequency" : 0.025 + } + }] +} diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dhex_compressible_explicit_oscillating_point_test_results.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dhex_compressible_explicit_oscillating_point_test_results.json new file mode 100644 index 000000000000..ca117efee230 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dhex_compressible_explicit_oscillating_point_test_results.json @@ -0,0 +1 @@ +{"TIME": [0.05, 0.07500000000000001, 0.125, 0.175, 0.22499999999999998, 0.27499999999999997], "PARTICLE_21": {"MP_VELOCITY_X": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VELOCITY_Y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VELOCITY_Z": [0.002469235611246596, 0.003627660543020087, 0.0056500848287184035, 0.007119123413548287, 0.007890827244213038, 0.007889552998751173], "MP_DISPLACEMENT_X": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_Y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_Z": [7.735686684366492e-05, 0.0001371877105868443, 0.0002918401651211401, 0.00048009828214555934, 0.000683558178474316, 0.0008823109807566546], "MP_VOLUME": [1.00003125, 1.0000929828193714, 1.0003011224862841, 1.0006040946310906, 1.0009722936408783, 1.001369705226477]}} \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py b/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py index e541b4a687bd..ec680bf7cfd6 100644 --- a/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py +++ b/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py @@ -118,4 +118,7 @@ class ExplicitAxisymDiskTriCompressibleTest(ParticleMechanicsTestFactory): file_name = "explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test" class ExplicitAxisymDiskQuadCompressibleTest(ParticleMechanicsTestFactory): - file_name = "explicit_tests/axisymmetric_disk/quad_compressible_explicit_axisym_disk_test" \ No newline at end of file + file_name = "explicit_tests/axisymmetric_disk/quad_compressible_explicit_axisym_disk_test" + +class Explicit3dHexCompressibleOscillatingPointTest(ParticleMechanicsTestFactory): + file_name = "explicit_tests/oscillating_point_3d/3dhex_compressible_explicit_oscillating_point_test" \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py index 920c33814b25..700ffeeb2bb9 100644 --- a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py +++ b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py @@ -37,6 +37,7 @@ from particle_mechanics_test_factory import ExplicitOscillatingPointTriTest as TExplicitOscillatingPointTriTest from particle_mechanics_test_factory import ExplicitAxisymDiskTriCompressibleTest as TExplicitAxisymDiskTriCompressibleTest from particle_mechanics_test_factory import ExplicitAxisymDiskQuadCompressibleTest as TExplicitAxisymDiskQuadCompressibleTest +from particle_mechanics_test_factory import Explicit3dHexCompressibleOscillatingPointTest as TExplicit3dHexCompressibleOscillatingPointTest # Import from Test Factories (with different analysis flows) @@ -92,6 +93,7 @@ def AssembleTestSuites(): nightSuite.addTests(smallSuite) nightSuite.addTest(TAxisSymmetricCircularPlate2DTriTest('test_execution')) + nightSuite.addTest(TExplicit3dHexCompressibleOscillatingPointTest('test_execution')) nightSuite.addTest(TBeamCantileverStaticLinearElasticPointLoad2DTriTest('test_execution')) nightSuite.addTest(TBeamCantileverStaticLinearElasticParticlePointLoad2DTriTest('test_execution')) From f7136abddee1703dc400735961c4f57d0bd6583a Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Tue, 21 Apr 2020 14:15:13 +1000 Subject: [PATCH 183/314] add mpvolume to compressible axisymmetric tests --- .../quad_compressible_explicit_axisym_disk_test_parameters.json | 2 +- .../tri_compressible_explicit_axisym_disk_test_parameters.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/quad_compressible_explicit_axisym_disk_test_parameters.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/quad_compressible_explicit_axisym_disk_test_parameters.json index 40d7c7952573..bf49eeab633e 100644 --- a/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/quad_compressible_explicit_axisym_disk_test_parameters.json +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/quad_compressible_explicit_axisym_disk_test_parameters.json @@ -71,7 +71,7 @@ "help" : "", "process_name" : "ParticleFromJsonCheckResultProcess", "Parameters" : { - "check_variables" : ["MP_VELOCITY","MP_DISPLACEMENT"], + "check_variables" : ["MP_VELOCITY","MP_DISPLACEMENT","MP_VOLUME"], "input_file_name" : "explicit_tests/axisymmetric_disk/quad_compressible_explicit_axisym_disk_results.json", "model_part_name" : "MPM_Material", "time_frequency" : 0.025 diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_parameters.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_parameters.json index 84a1126bca12..88261051a49e 100644 --- a/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_parameters.json +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_parameters.json @@ -71,7 +71,7 @@ "help" : "", "process_name" : "ParticleFromJsonCheckResultProcess", "Parameters" : { - "check_variables" : ["MP_VELOCITY","MP_DISPLACEMENT"], + "check_variables" : ["MP_VELOCITY","MP_DISPLACEMENT","MP_VOLUME"], "input_file_name" : "explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_results.json", "model_part_name" : "MPM_Material", "time_frequency" : 0.025 From f784ddd074406d0d91a55aac1b1186238067e71b Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Tue, 21 Apr 2020 14:40:07 +1000 Subject: [PATCH 184/314] add 3d tet explicit test --- ..._explicit_oscillating_point_test_Body.mdpa | 49 ++++++++ ..._explicit_oscillating_point_test_Grid.mdpa | 109 ++++++++++++++++++ ...cit_oscillating_point_test_parameters.json | 102 ++++++++++++++++ ...plicit_oscillating_point_test_results.json | 1 + .../tests/particle_mechanics_test_factory.py | 5 +- .../test_ParticleMechanicsApplication.py | 3 + 6 files changed, 268 insertions(+), 1 deletion(-) create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dtet_compressible_explicit_oscillating_point_test_Body.mdpa create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dtet_compressible_explicit_oscillating_point_test_Grid.mdpa create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dtet_compressible_explicit_oscillating_point_test_parameters.json create mode 100644 applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dtet_compressible_explicit_oscillating_point_test_results.json diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dtet_compressible_explicit_oscillating_point_test_Body.mdpa b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dtet_compressible_explicit_oscillating_point_test_Body.mdpa new file mode 100644 index 000000000000..7a805dc6345c --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dtet_compressible_explicit_oscillating_point_test_Body.mdpa @@ -0,0 +1,49 @@ +Begin ModelPartData +// VARIABLE_NAME value +End ModelPartData + +Begin Properties 0 +End Properties +Begin Nodes + 3 0.00000 1.00000 1.00000 + 9 0.00000 0.00000 1.00000 + 10 1.00000 1.00000 1.00000 + 12 1.00000 0.00000 1.00000 + 14 0.00000 1.00000 0.00000 + 17 0.00000 0.00000 0.00000 + 18 1.00000 1.00000 0.00000 + 20 1.00000 0.00000 0.00000 +End Nodes + + +Begin Elements UpdatedLagrangian3D4N// GUI group identifier: bar + 13 0 9 3 10 14 + 14 0 14 18 10 9 + 15 0 12 10 18 9 + 16 0 9 12 20 18 + 17 0 9 17 14 18 + 18 0 17 20 18 9 +End Elements + +Begin SubModelPart Parts_bar // Group bar // Subtree Parts + Begin SubModelPartNodes + 3 + 9 + 10 + 12 + 14 + 17 + 18 + 20 + End SubModelPartNodes + Begin SubModelPartElements + 13 + 14 + 15 + 16 + 17 + 18 + End SubModelPartElements + Begin SubModelPartConditions + End SubModelPartConditions +End SubModelPart diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dtet_compressible_explicit_oscillating_point_test_Grid.mdpa b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dtet_compressible_explicit_oscillating_point_test_Grid.mdpa new file mode 100644 index 000000000000..9952f2f12a9c --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dtet_compressible_explicit_oscillating_point_test_Grid.mdpa @@ -0,0 +1,109 @@ +Begin ModelPartData +// VARIABLE_NAME value +End ModelPartData + +Begin Properties 0 +End Properties +Begin Nodes + 1 0.0000000000 1.0000000000 2.0000000000 + 2 1.0000000000 1.0000000000 2.0000000000 + 3 0.0000000000 1.0000000000 1.0000000000 + 4 0.0000000000 0.0000000000 2.0000000000 + 5 0.0000000000 1.0000000000 1.0000000000 + 6 1.0000000000 0.0000000000 2.0000000000 + 7 0.0000000000 0.0000000000 1.0000000000 + 8 1.0000000000 1.0000000000 1.0000000000 + 9 0.0000000000 0.0000000000 1.0000000000 + 10 1.0000000000 1.0000000000 1.0000000000 + 11 1.0000000000 0.0000000000 1.0000000000 + 12 1.0000000000 0.0000000000 1.0000000000 + 13 0.0000000000 1.0000000000 0.0000000000 + 14 0.0000000000 1.0000000000 0.0000000000 + 15 0.0000000000 0.0000000000 0.0000000000 + 16 1.0000000000 1.0000000000 0.0000000000 + 17 0.0000000000 0.0000000000 0.0000000000 + 18 1.0000000000 1.0000000000 0.0000000000 + 19 1.0000000000 0.0000000000 0.0000000000 + 20 1.0000000000 0.0000000000 0.0000000000 +End Nodes + + +Begin Elements Element3D4N// GUI group identifier: grid + 1 0 15 13 5 16 + 2 0 16 8 5 15 + 3 0 7 5 8 15 + 4 0 15 7 11 8 + 5 0 15 19 16 8 + 6 0 19 11 8 15 + 7 0 4 1 2 5 + 8 0 5 8 2 4 + 9 0 6 2 8 4 + 10 0 4 6 11 8 + 11 0 4 7 5 8 + 12 0 7 11 8 4 +End Elements + +Begin SubModelPart Parts_grid // Group grid // Subtree Parts + Begin SubModelPartNodes + 1 + 2 + 4 + 5 + 6 + 7 + 8 + 11 + 13 + 15 + 16 + 19 + End SubModelPartNodes + Begin SubModelPartElements + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + End SubModelPartElements + Begin SubModelPartConditions + End SubModelPartConditions +End SubModelPart +Begin SubModelPart DISPLACEMENT_bc // Group bc // Subtree DISPLACEMENT + Begin SubModelPartNodes + 13 + 15 + 16 + 19 + End SubModelPartNodes + Begin SubModelPartElements + End SubModelPartElements + Begin SubModelPartConditions + End SubModelPartConditions +End SubModelPart +Begin SubModelPart DISPLACEMENT_bclat // Group bclat // Subtree DISPLACEMENT + Begin SubModelPartNodes + 1 + 2 + 4 + 5 + 6 + 7 + 8 + 11 + 13 + 15 + 16 + 19 + End SubModelPartNodes + Begin SubModelPartElements + End SubModelPartElements + Begin SubModelPartConditions + End SubModelPartConditions +End SubModelPart diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dtet_compressible_explicit_oscillating_point_test_parameters.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dtet_compressible_explicit_oscillating_point_test_parameters.json new file mode 100644 index 000000000000..26437cc30b23 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dtet_compressible_explicit_oscillating_point_test_parameters.json @@ -0,0 +1,102 @@ +{ + "problem_data" : { + "problem_name" : "3dtet_compressible_explicit_oscillating_point_test", + "parallel_type" : "OpenMP", + "echo_level" : 0, + "start_time" : 0.0, + "end_time" : 0.25 + }, + "solver_settings" : { + "solver_type" : "Dynamic", + "model_part_name" : "MPM_Material", + "domain_size" : 3, + "echo_level" : 0, + "analysis_type" : "linear", + "time_integration_method" : "explicit", + "scheme_type" : "forward_euler", + "stress_update" : "usf", + "compressible" : true, + "model_import_settings" : { + "input_type" : "mdpa", + "input_filename" : "explicit_tests/oscillating_point_3d/3dtet_compressible_explicit_oscillating_point_test_Body" + }, + "material_import_settings" : { + "materials_filename" : "explicit_tests/oscillating_point_3d/3d_explicit_oscillating_point_test_materials.json" + }, + "time_stepping" : { + "time_step" : 0.025 + }, + "convergence_criterion" : "residual_criterion", + "displacement_relative_tolerance" : 0.0001, + "displacement_absolute_tolerance" : 1e-9, + "residual_relative_tolerance" : 0.0001, + "residual_absolute_tolerance" : 1e-9, + "max_iteration" : 10, + "problem_domain_sub_model_part_list" : ["Parts_bar","Parts_grid"], + "processes_sub_model_part_list" : ["DISPLACEMENT_bc","DISPLACEMENT_bclat"], + "grid_model_import_settings" : { + "input_type" : "mdpa", + "input_filename" : "explicit_tests/oscillating_point_3d/3dtet_compressible_explicit_oscillating_point_test_Grid" + }, + "pressure_dofs" : false + }, + "processes" : { + "constraints_process_list" : [{ + "python_module" : "assign_vector_variable_process", + "kratos_module" : "KratosMultiphysics", + "Parameters" : { + "model_part_name" : "Background_Grid.DISPLACEMENT_bc", + "variable_name" : "DISPLACEMENT", + "constrained" : [true,true,true], + "value" : [0.0,0.0,0.0], + "interval" : [0.0,"End"] + } + },{ + "python_module" : "assign_vector_variable_process", + "kratos_module" : "KratosMultiphysics", + "Parameters" : { + "model_part_name" : "Background_Grid.DISPLACEMENT_bclat", + "variable_name" : "DISPLACEMENT", + "constrained" : [true,true,false], + "value" : [0.0,0.0,0.0], + "interval" : [0.0,"End"] + } + }], + "loads_process_list" : [], + "list_other_processes" : [{ + "python_module" : "particle_from_json_check_result_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "help" : "", + "process_name" : "ParticleFromJsonCheckResultProcess", + "Parameters" : { + "check_variables" : ["MP_VELOCITY","MP_DISPLACEMENT","MP_VOLUME"], + "input_file_name" : "explicit_tests/oscillating_point_3d/3dtet_compressible_explicit_oscillating_point_test_results.json", + "model_part_name" : "MPM_Material", + "time_frequency" : 0.025 + } + }], + "gravity" : [{ + "python_module" : "assign_gravity_to_particle_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "process_name" : "AssignGravityToParticleProcess", + "Parameters" : { + "model_part_name" : "MPM_Material", + "variable_name" : "MP_VOLUME_ACCELERATION", + "modulus" : 0.1, + "direction" : [0.0,0.0,1.0] + } + }] + }, + "print_output_process" : [{ + "python_module" : "particle_json_output_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "help" : "", + "process_name" : "ParticleJsonOutputProcess", + "Parameters" : { + "gauss_points_output_variables" : ["MP_VELOCITY","MP_DISPLACEMENT","MP_VOLUME"], + "output_file_name" : "explicit_tests/oscillating_point_3d/3dtet_compressible_explicit_oscillating_point_test_results.json", + "model_part_name" : "MPM_Material", + "time_frequency" : 0.025 + } + }] +} diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dtet_compressible_explicit_oscillating_point_test_results.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dtet_compressible_explicit_oscillating_point_test_results.json new file mode 100644 index 000000000000..5051d1b990e1 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dtet_compressible_explicit_oscillating_point_test_results.json @@ -0,0 +1 @@ +{"TIME": [0.05, 0.07500000000000001, 0.125, 0.175, 0.22499999999999998, 0.27499999999999997], "PARTICLE_21": {"MP_VELOCITY_X": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VELOCITY_Y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VELOCITY_Z": [0.0036916446399043487, 0.005393386629286181, 0.008239788001612342, 0.010035836694180043, 0.010508625352701011, 0.009532113188585645], "MP_DISPLACEMENT_X": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_Y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_Z": [0.00011898594021890179, 0.00021416639809219035, 0.0004618192065606581, 0.0007608012548798167, 0.0010765760579289274, 0.0013738113154414876], "MP_VOLUME": [0.16667447916087405, 0.1666897473018923, 0.1667395700476368, 0.16680728418863677, 0.16688109293614095, 0.16694841678563865]}, "PARTICLE_22": {"MP_VELOCITY_X": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VELOCITY_Y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VELOCITY_Z": [0.002490438649775342, 0.0037117507966339786, 0.006059145373935651, 0.008218433695025387, 0.010121913316539728, 0.011713461273328693], "MP_DISPLACEMENT_X": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_Y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_Z": [8.016567001279607e-05, 0.00014594580973280378, 0.0003222444889786742, 0.0005439010201351152, 0.0007892317085773285, 0.0010342888736958808], "MP_VOLUME": [0.16667274300116255, 0.1666846482424528, 0.16672380684567398, 0.16677799002487023, 0.16683901024614578, 0.16689824235491096]}, "PARTICLE_23": {"MP_VELOCITY_X": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VELOCITY_Y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VELOCITY_Z": [0.0036367128103154756, 0.005178042802005714, 0.007242925884724294, 0.00756713121694627, 0.006043665246278154, 0.002969201334559986], "MP_DISPLACEMENT_X": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_Y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_Z": [0.00011891434128767432, 0.00021219125857215233, 0.00044274429621585785, 0.0006950383009372413, 0.0009256832493479382, 0.0011000668031761948], "MP_VOLUME": [0.16667447916384037, 0.1666897473143486, 0.1667395700819765, 0.1668072841756392, 0.16688109278466098, 0.16694841664690513]}, "PARTICLE_24": {"MP_VELOCITY_X": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VELOCITY_Y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VELOCITY_Z": [0.0024496391394342575, 0.0035515769989360947, 0.00530506451069898, 0.006290840959730308, 0.0064690076607701475, 0.005983718110082301], "MP_DISPLACEMENT_X": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_Y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_Z": [8.01220209593324e-05, 0.00014455212564042942, 0.0003085564310753708, 0.0004960590417139565, 0.000677634922519104, 0.0008278165552405325], "MP_VOLUME": [0.1666731768796195, 0.16668585627510424, 0.1667267920742603, 0.16678115047655884, 0.16683817799688994, 0.16688713498712981]}, "PARTICLE_25": {"MP_VELOCITY_X": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VELOCITY_Y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VELOCITY_Z": [0.0012522871507944376, 0.0018835199811832657, 0.0031581144260456858, 0.004431268734345605, 0.005653358838400391, 0.006746723054744563], "MP_DISPLACEMENT_X": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_Y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_Z": [4.009681092623318e-05, 7.326489431795302e-05, 0.00016399309681070155, 0.0002821959038623033, 0.00041892495517728394, 0.0005626377420763924], "MP_VOLUME": [0.16667274300116255, 0.1666846482424528, 0.16672380684567398, 0.16677799002487023, 0.16683901024614578, 0.16689824235491096]}, "PARTICLE_26": {"MP_VELOCITY_X": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VELOCITY_Y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VELOCITY_Z": [0.0012381498326980316, 0.0018282166163198035, 0.002900864521579894, 0.003786412027051445, 0.004466425654019698, 0.004962261434459546], "MP_DISPLACEMENT_X": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_Y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_Z": [4.006885810560965e-05, 7.268078721489824e-05, 0.0001582484340678183, 0.0002616875763787497, 0.00037024766947777756, 0.0004715086392897974], "MP_VOLUME": [0.1666731768796195, 0.16668585627510424, 0.1667267920742603, 0.16678115047655884, 0.16683817799688994, 0.16688713498712981]}} \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py b/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py index ec680bf7cfd6..a70fbcf4e598 100644 --- a/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py +++ b/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py @@ -121,4 +121,7 @@ class ExplicitAxisymDiskQuadCompressibleTest(ParticleMechanicsTestFactory): file_name = "explicit_tests/axisymmetric_disk/quad_compressible_explicit_axisym_disk_test" class Explicit3dHexCompressibleOscillatingPointTest(ParticleMechanicsTestFactory): - file_name = "explicit_tests/oscillating_point_3d/3dhex_compressible_explicit_oscillating_point_test" \ No newline at end of file + file_name = "explicit_tests/oscillating_point_3d/3dhex_compressible_explicit_oscillating_point_test" + +class Explicit3dTetCompressibleOscillatingPointTest(ParticleMechanicsTestFactory): + file_name = "explicit_tests/oscillating_point_3d/3dtet_compressible_explicit_oscillating_point_test" \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py index 700ffeeb2bb9..d9cc98eac06f 100644 --- a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py +++ b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py @@ -38,6 +38,8 @@ from particle_mechanics_test_factory import ExplicitAxisymDiskTriCompressibleTest as TExplicitAxisymDiskTriCompressibleTest from particle_mechanics_test_factory import ExplicitAxisymDiskQuadCompressibleTest as TExplicitAxisymDiskQuadCompressibleTest from particle_mechanics_test_factory import Explicit3dHexCompressibleOscillatingPointTest as TExplicit3dHexCompressibleOscillatingPointTest +from particle_mechanics_test_factory import Explicit3dTetCompressibleOscillatingPointTest as TExplicit3dTetCompressibleOscillatingPointTest + # Import from Test Factories (with different analysis flows) @@ -118,6 +120,7 @@ def AssembleTestSuites(): nightSuite.addTest(TExplicitOscillatingPointTriTest('test_execution')) nightSuite.addTest(TExplicitAxisymDiskTriCompressibleTest('test_execution')) nightSuite.addTest(TExplicitAxisymDiskQuadCompressibleTest('test_execution')) + nightSuite.addTest(TExplicit3dTetCompressibleOscillatingPointTest('test_execution')) ### Adding Validation Tests ## For very long tests that should not be in nighly and you can use to validate From 201004f338c13285528758bd994e5fc3e2228518 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Tue, 21 Apr 2020 16:58:43 +1000 Subject: [PATCH 185/314] clean up test order --- .../tests/test_ParticleMechanicsApplication.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py index d9cc98eac06f..6514b560b51a 100644 --- a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py +++ b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py @@ -95,7 +95,6 @@ def AssembleTestSuites(): nightSuite.addTests(smallSuite) nightSuite.addTest(TAxisSymmetricCircularPlate2DTriTest('test_execution')) - nightSuite.addTest(TExplicit3dHexCompressibleOscillatingPointTest('test_execution')) nightSuite.addTest(TBeamCantileverStaticLinearElasticPointLoad2DTriTest('test_execution')) nightSuite.addTest(TBeamCantileverStaticLinearElasticParticlePointLoad2DTriTest('test_execution')) @@ -120,6 +119,7 @@ def AssembleTestSuites(): nightSuite.addTest(TExplicitOscillatingPointTriTest('test_execution')) nightSuite.addTest(TExplicitAxisymDiskTriCompressibleTest('test_execution')) nightSuite.addTest(TExplicitAxisymDiskQuadCompressibleTest('test_execution')) + nightSuite.addTest(TExplicit3dHexCompressibleOscillatingPointTest('test_execution')) nightSuite.addTest(TExplicit3dTetCompressibleOscillatingPointTest('test_execution')) ### Adding Validation Tests From 91404d9aaa08b426ae478d39ebdc4c4cbf2ba6c0 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Tue, 21 Apr 2020 16:59:01 +1000 Subject: [PATCH 186/314] clean up as per codacy --- .../custom_elements/updated_lagrangian.hpp | 4 ++-- .../updated_lagrangian_quadrilateral.hpp | 4 ++-- .../custom_strategies/schemes/mpm_explicit_scheme.hpp | 9 ++++----- .../strategies/mpm_explicit_strategy.hpp | 2 +- .../assign_initial_velocity_to_particle_process.py | 5 +---- .../python_scripts/mpm_explicit_solver.py | 10 +--------- .../tests/test_ParticleMechanicsApplication.py | 2 +- 7 files changed, 12 insertions(+), 24 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.hpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.hpp index 8353ecc597e3..6f1a13146053 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.hpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.hpp @@ -133,9 +133,9 @@ class UpdatedLagrangian volume = 1.0; // MP_CAUCHY_STRESS_VECTOR - cauchy_stress_vector = ZeroVector(0); + cauchy_stress_vector; // MP_ALMANSI_STRAIN_VECTOR - almansi_strain_vector = ZeroVector(0); + almansi_strain_vector; // MP_DELTA_PLASTIC_STRAIN delta_plastic_strain = 1.0; diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp index a9695dbf3f3a..037957d5f9f6 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp @@ -134,9 +134,9 @@ class UpdatedLagrangianQuadrilateral volume = 1.0; // MP_CAUCHY_STRESS_VECTOR - cauchy_stress_vector = ZeroVector(0); + cauchy_stress_vector; // MP_ALMANSI_STRAIN_VECTOR - almansi_strain_vector = ZeroVector(0); + almansi_strain_vector; // MP_DELTA_PLASTIC_STRAIN delta_plastic_strain = 1.0; diff --git a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp index 386f4dd2390b..1b209465c3bf 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp @@ -94,7 +94,7 @@ namespace Kratos { * @param DeltaTimeFraction The delta ttime fraction * @param DeltaTimePredictionLevel The prediction level */ - MPMExplicitScheme( + explicit MPMExplicitScheme( ModelPart& grid_model_part ) : Scheme(), @@ -488,7 +488,7 @@ namespace Kratos { //check that variables are correctly allocated for (ModelPart::NodesContainerType::iterator it = r_model_part.NodesBegin(); - it != r_model_part.NodesEnd(); it++) + it != r_model_part.NodesEnd(); ++it) { KRATOS_ERROR_IF(it->SolutionStepsDataHas(DISPLACEMENT) == false) << "DISPLACEMENT variable is not allocated for node " << it->Id() << std::endl; KRATOS_ERROR_IF(it->SolutionStepsDataHas(VELOCITY) == false) << "VELOCITY variable is not allocated for node " << it->Id() << std::endl; @@ -497,7 +497,7 @@ namespace Kratos { //check that dofs exist for (ModelPart::NodesContainerType::iterator it = r_model_part.NodesBegin(); - it != r_model_part.NodesEnd(); it++) + it != r_model_part.NodesEnd(); ++it) { KRATOS_ERROR_IF(it->HasDofFor(DISPLACEMENT_X) == false) << "Missing DISPLACEMENT_X dof on node " << it->Id() << std::endl; KRATOS_ERROR_IF(it->HasDofFor(DISPLACEMENT_Y) == false) << "Missing DISPLACEMENT_Y dof on node " << it->Id() << std::endl; @@ -506,9 +506,8 @@ namespace Kratos { //check for minimum value of the buffer index KRATOS_ERROR_IF(r_model_part.GetBufferSize() < 2) << "Insufficient buffer size. Buffer size should be greater than 2. Current size is" << r_model_part.GetBufferSize() << std::endl; - - return 0; KRATOS_CATCH("") + return 0; } void Calculate_RHS_Contribution( diff --git a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp index 929800f0772a..5f99056b7354 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp @@ -75,7 +75,7 @@ namespace Kratos typedef typename BaseType::ConditionsArrayType ConditionsArrayType; - MPMExplicitStrategy( + explicit MPMExplicitStrategy( ModelPart& model_part, typename TSchemeType::Pointer pScheme, bool CalculateReactions = false, diff --git a/applications/ParticleMechanicsApplication/python_scripts/assign_initial_velocity_to_particle_process.py b/applications/ParticleMechanicsApplication/python_scripts/assign_initial_velocity_to_particle_process.py index 68f7ac2db86b..0f3376c54601 100644 --- a/applications/ParticleMechanicsApplication/python_scripts/assign_initial_velocity_to_particle_process.py +++ b/applications/ParticleMechanicsApplication/python_scripts/assign_initial_velocity_to_particle_process.py @@ -40,9 +40,6 @@ def __init__(self, Model, settings ): settings.ValidateAndAssignDefaults(default_settings) - - - # Get updated model_part self.model = Model model_part_name = settings["model_part_name"].GetString() @@ -52,7 +49,7 @@ def __init__(self, Model, settings ): # The actual initial velocity application occurs after the submodelpart is # transferred from the initial MPM material to the MPM material in the particle # generator utility. Therefore we change the prefix from initial MPM material - # to MPM material. + # to MPM material. # Default settings self.modulus = settings["modulus"].GetDouble() diff --git a/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py b/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py index 9244d3e6fd5d..5144e2c4587a 100644 --- a/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py +++ b/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py @@ -40,7 +40,6 @@ def AddVariables(self): grid_model_part.AddNodalSolutionStepVariable(KratosMultiphysics.FORCE_RESIDUAL) grid_model_part.AddNodalSolutionStepVariable(KratosMultiphysics.RESIDUAL_VECTOR) - scheme_type = self.settings["scheme_type"].GetString() KratosMultiphysics.Logger.PrintInfo("::[MPMExplicitSolver]:: ", "Variables are all added.") ### Protected functions ### @@ -58,10 +57,9 @@ def _CreateSolutionScheme(self): # Setting the time integration schemes scheme_type = self.settings["scheme_type"].GetString() - isCentralDifference = False - StressUpdateOption = 0 if(scheme_type == "forward_euler" or scheme_type == "Forward_Euler"): + StressUpdateOption = 10 stress_update = self.settings["stress_update"].GetString() #0 = USF, 1 = USL, 2 = MUSL if(stress_update == "USF" or stress_update == "usf"): StressUpdateOption = 0 @@ -75,7 +73,6 @@ def _CreateSolutionScheme(self): grid_model_part.ProcessInfo.SetValue(KratosParticle.EXPLICIT_STRESS_UPDATE_OPTION, StressUpdateOption) grid_model_part.ProcessInfo.SetValue(KratosParticle.IS_EXPLICIT_CENTRAL_DIFFERENCE, False) elif(scheme_type == "central_difference" or scheme_type == "Central_Difference"): - isCentralDifference = True grid_model_part.ProcessInfo.SetValue(KratosParticle.EXPLICIT_STRESS_UPDATE_OPTION, 0) grid_model_part.ProcessInfo.SetValue(KratosParticle.IS_EXPLICIT_CENTRAL_DIFFERENCE, True) else: @@ -83,8 +80,6 @@ def _CreateSolutionScheme(self): err_msg += "Available options are: \"forward_euler\", \"central_difference\"" raise Exception(err_msg) - is_dynamic = self._IsDynamic() - return KratosParticle.MPMExplicitScheme( grid_model_part) def _CreateSolutionStrategy(self): @@ -103,10 +98,7 @@ def _CreateSolutionStrategy(self): def _CreateLinearStrategy(self): computing_model_part = self.GetComputingModelPart() solution_scheme = self._GetSolutionScheme() - linear_solver = self._GetLinearSolver() reform_dofs_at_each_step = False ## hard-coded, but can be changed upon implementation - calc_norm_dx_flag = False ## hard-coded, but can be changed upon implementation - move_mesh_flag = self.settings["move_mesh_flag"].GetBool() move_mesh_flag = False ## hard-coded return KratosParticle.MPMExplicitStrategy(computing_model_part, diff --git a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py index 6514b560b51a..94934810bbe1 100644 --- a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py +++ b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py @@ -121,7 +121,7 @@ def AssembleTestSuites(): nightSuite.addTest(TExplicitAxisymDiskQuadCompressibleTest('test_execution')) nightSuite.addTest(TExplicit3dHexCompressibleOscillatingPointTest('test_execution')) nightSuite.addTest(TExplicit3dTetCompressibleOscillatingPointTest('test_execution')) - + ### Adding Validation Tests ## For very long tests that should not be in nighly and you can use to validate validationSuite = suites['validation'] From 85d9c3c30de447a6a3b031f023d08ffe4d8c6ca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Tue, 21 Apr 2020 16:47:21 +0200 Subject: [PATCH 187/314] [Core] Fix documentation in Hexahedra3D20 According to https://www.gidhome.com/documents/referencemanual/PREPROCESSING/Mesh%20Menu/Element%20type Partially fixes #5546 --- kratos/geometries/hexahedra_3d_20.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kratos/geometries/hexahedra_3d_20.h b/kratos/geometries/hexahedra_3d_20.h index 4aa0408f9bf7..28f61fd82c13 100644 --- a/kratos/geometries/hexahedra_3d_20.h +++ b/kratos/geometries/hexahedra_3d_20.h @@ -35,11 +35,11 @@ namespace Kratos * 3----10----2 * |\ |\ * | 15 | 14 - * 9 \ 11 \ + * 11 \ 9 \ * | 7----18+---6 * | | | | * 0---+-8----1 | - * \ 17 \ 19 + * \ 19 \ 17 * 12 | 13| * \| \| * 4----16----5 From 924d01980a8f144dcefa4302d49968c90f3dd23c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Tue, 21 Apr 2020 16:50:19 +0200 Subject: [PATCH 188/314] [Core] Fix documentation in Hexahedra3D27 According to https://www.gidhome.com/documents/referencemanual/PREPROCESSING/Mesh%20Menu/Element%20type Fixes #5546 --- kratos/geometries/hexahedra_3d_27.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kratos/geometries/hexahedra_3d_27.h b/kratos/geometries/hexahedra_3d_27.h index c75b8e14ebfd..ac82b4e6e97b 100644 --- a/kratos/geometries/hexahedra_3d_27.h +++ b/kratos/geometries/hexahedra_3d_27.h @@ -36,11 +36,11 @@ namespace Kratos * 3----10----2 * |\ |\ * |15 23 | 14 - * 9 \ 20 11 \ + * 11 \ 20 9 \ * | 7----18+---6 - * |22 | 26 | 24| + * |24 | 26 | 22| * 0---+-8----1 | - * \ 17 25 \ 19 + * \ 19 25 \ 17 * 12 | 21 13| * \| \| * 4----16----5 From 406266fe58fd6db660bcfdc7762aa25003ba32a7 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Wed, 22 Apr 2020 09:11:51 +1000 Subject: [PATCH 189/314] use core newton raphson strategy instead of custom --- .../add_custom_strategies_to_python.cpp | 19 +- ...residual_based_newton_raphson_strategy.hpp | 969 ------------------ .../python_scripts/mpm_solver.py | 2 +- 3 files changed, 2 insertions(+), 988 deletions(-) delete mode 100644 applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp diff --git a/applications/ParticleMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp b/applications/ParticleMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp index b67d257db4d7..29f943c1845b 100644 --- a/applications/ParticleMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp +++ b/applications/ParticleMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp @@ -22,11 +22,10 @@ #include "containers/flags.h" #include "spaces/ublas_space.h" #include "boost/numeric/ublas/matrix.hpp" +#include "particle_mechanics_application_variables.h" //---strategies #include "solving_strategies/strategies/solving_strategy.h" -#include "custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp" - //---convergence criterias #include "solving_strategies/convergencecriterias/convergence_criteria.h" @@ -58,8 +57,6 @@ namespace Python{ typedef Scheme< SparseSpaceType, LocalSpaceType > BaseSchemeType; typedef ConvergenceCriteria< SparseSpaceType, LocalSpaceType > ConvergenceCriteriaType; - typedef MPMResidualBasedNewtonRaphsonStrategy< SparseSpaceType, LocalSpaceType, LinearSolverType> MPMResidualBasedNewtonRaphsonStrategyType; - //custom scheme types typedef MPMResidualBasedBossakScheme< SparseSpaceType, LocalSpaceType > MPMResidualBasedBossakSchemeType; @@ -68,20 +65,6 @@ namespace Python{ .def(py::init < ModelPart&, unsigned int, unsigned int, double, double, bool>()) .def("Initialize", &MPMResidualBasedBossakSchemeType::Initialize) ; - - // MPM Residual Based Newton Raphson Strategy Type - py::class_< MPMResidualBasedNewtonRaphsonStrategyType,typename MPMResidualBasedNewtonRaphsonStrategyType::Pointer, BaseSolvingStrategyType >(m,"MPMResidualBasedNewtonRaphsonStrategy") - .def(py::init< ModelPart&, BaseSchemeType::Pointer, LinearSolverType::Pointer, ConvergenceCriteriaType::Pointer, int, bool, bool, bool >() ) - .def(py::init< ModelPart&, BaseSchemeType::Pointer, LinearSolverType::Pointer, ConvergenceCriteriaType::Pointer, BuilderAndSolverType::Pointer, int, bool, bool, bool >() ) - .def("SetMaxIterationNumber", &MPMResidualBasedNewtonRaphsonStrategyType::SetMaxIterationNumber) - .def("GetMaxIterationNumber", &MPMResidualBasedNewtonRaphsonStrategyType::GetMaxIterationNumber) - .def("SetInitializePerformedFlag", &MPMResidualBasedNewtonRaphsonStrategyType::SetInitializePerformedFlag) - .def("GetInitializePerformedFlag", &MPMResidualBasedNewtonRaphsonStrategyType::GetInitializePerformedFlag) - .def("SetKeepSystemConstantDuringIterations", &MPMResidualBasedNewtonRaphsonStrategyType::SetKeepSystemConstantDuringIterations) - .def("GetKeepSystemConstantDuringIterations", &MPMResidualBasedNewtonRaphsonStrategyType::GetKeepSystemConstantDuringIterations) - .def("SetFinalizeSolutionStepFlag", &MPMResidualBasedNewtonRaphsonStrategyType::SetFinalizeSolutionStepFlag) - .def("GetFinalizeSolutionStepFlag", &MPMResidualBasedNewtonRaphsonStrategyType::GetFinalizeSolutionStepFlag) - ; } } // namespace Python. diff --git a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp deleted file mode 100644 index 87487ac93f91..000000000000 --- a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp +++ /dev/null @@ -1,969 +0,0 @@ -// | / | -// ' / __| _` | __| _ \ __| -// . \ | ( | | ( |\__ \. -// _|\_\_| \__,_|\__|\___/ ____/ -// Multi-Physics -// -// License: BSD License -// Kratos default license: kratos/license.txt -// -// Main authors: Ilaria Iaconeta, Bodhinanda Chandra -// -// - - -#if !defined(KRATOS_MPM_RESIDUAL_BASED_NEWTON_RAPHSON_STRATEGY ) -#define KRATOS_MPM_RESIDUAL_BASED_NEWTON_RAPHSON_STRATEGY - -/* System includes */ - -/* External includes */ - -/* Project includes */ -#include "includes/define.h" -#include "includes/model_part.h" -#include "includes/kratos_flags.h" - -#include "solving_strategies/strategies/solving_strategy.h" -#include "solving_strategies/convergencecriterias/convergence_criteria.h" -#include "solving_strategies/builder_and_solvers/residualbased_elimination_builder_and_solver.h" - -// Application includes -#include "particle_mechanics_application_variables.h" - -namespace Kratos -{ - -/**@name Kratos Globals */ -/*@{ */ - - -/*@} */ -/**@name Type Definitions */ -/*@{ */ - -/*@} */ - - -/**@name Enum's */ -/*@{ */ - - -/*@} */ -/**@name Functions */ -/*@{ */ - - - -/*@} */ -/**@name Kratos Classes */ -/*@{ */ - -/// Short class definition. - -/** - * @class MPMResidualBasedNewtonRaphsonStrategy - * @ingroup KratosParticle - * @brief Newton Raphson strategy suited for MPM simulations - * @details This strategy iterates until the convergence is achieved (or the maximum number of iterations is achieved) using a Newton Raphson algorithm - */ -template -class MPMResidualBasedNewtonRaphsonStrategy - : public SolvingStrategy -{ -public: - /**@name Type Definitions */ - /*@{ */ - typedef ConvergenceCriteria TConvergenceCriteriaType; - - /** Counted pointer of ClassName */ - KRATOS_CLASS_POINTER_DEFINITION(MPMResidualBasedNewtonRaphsonStrategy); - - typedef SolvingStrategy BaseType; - - typedef typename BaseType::TBuilderAndSolverType TBuilderAndSolverType; - - typedef typename BaseType::TDataType TDataType; - - typedef TSparseSpace SparseSpaceType; - - typedef typename BaseType::TSchemeType TSchemeType; - - typedef typename BaseType::DofsArrayType DofsArrayType; - - typedef typename BaseType::TSystemMatrixType TSystemMatrixType; - - typedef typename BaseType::TSystemVectorType TSystemVectorType; - - typedef typename BaseType::LocalSystemVectorType LocalSystemVectorType; - - typedef typename BaseType::LocalSystemMatrixType LocalSystemMatrixType; - - typedef typename BaseType::TSystemMatrixPointerType TSystemMatrixPointerType; - - typedef typename BaseType::TSystemVectorPointerType TSystemVectorPointerType; - - - /*@} */ - /**@name Life Cycle - */ - /*@{ */ - - /** Constructors. - */ - MPMResidualBasedNewtonRaphsonStrategy( - ModelPart& rModelPart, - bool MoveMeshFlag = false - ) - : SolvingStrategy(rModelPart, MoveMeshFlag) - { - } - - MPMResidualBasedNewtonRaphsonStrategy( - ModelPart& rModelPart, - typename TSchemeType::Pointer pScheme, - typename TLinearSolver::Pointer pNewLinearSolver, - typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria, - int MaxIterations = 30, - bool CalculateReactions = false, - bool ReformDofSetAtEachStep = false, - bool MoveMeshFlag = false - ) - : SolvingStrategy(rModelPart, MoveMeshFlag) - { - KRATOS_TRY; - - mKeepSystemConstantDuringIterations = false; - - // Set flags to default values - SetMaxIterationNumber(MaxIterations); - - mCalculateReactionsFlag = CalculateReactions; - - mReformDofSetAtEachStep = ReformDofSetAtEachStep; - - // Saving the convergence criteria to be used - mpConvergenceCriteria = pNewConvergenceCriteria; - - // Saving the scheme - mpScheme = pScheme; - - // Saving the linear solver - mpLinearSolver = pNewLinearSolver; - - // Setting up the default builder and solver - mpBuilderAndSolver = typename TBuilderAndSolverType::Pointer - ( - new ResidualBasedEliminationBuilderAndSolver (mpLinearSolver) - ); - - // Set flags to start correcty the calculations - mSolutionStepIsInitialized = false; - - mInitializeWasPerformed = false; - - mFinalizeSolutionStep = true; - - // Tells to the Builder And Solver if the reactions have to be Calculated or not - GetBuilderAndSolver()->SetCalculateReactionsFlag(mCalculateReactionsFlag); - - // Tells to the Builder And Solver if the system matrix and vectors need to be reshaped at each step or not - GetBuilderAndSolver()->SetReshapeMatrixFlag(mReformDofSetAtEachStep); - - // Set EchoLevel to the default value (only time is displayed) - SetEchoLevel(1); - - // By default the matrices are rebuilt at each iteration - this->SetRebuildLevel(2); - - KRATOS_CATCH( "" ); - } - - MPMResidualBasedNewtonRaphsonStrategy( - ModelPart& rModelPart, - typename TSchemeType::Pointer pScheme, - typename TLinearSolver::Pointer pNewLinearSolver, - typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria, - typename TBuilderAndSolverType::Pointer pNewBuilderAndSolver, - int MaxIterations = 30, - bool CalculateReactions = false, - bool ReformDofSetAtEachStep = false, - bool MoveMeshFlag = false - ) - : SolvingStrategy(rModelPart, MoveMeshFlag) - { - KRATOS_TRY; - - mKeepSystemConstantDuringIterations = false; - - // Set flags to default values - SetMaxIterationNumber(MaxIterations); - mCalculateReactionsFlag = CalculateReactions; - - mReformDofSetAtEachStep = ReformDofSetAtEachStep; - - // Saving the convergence criteria to be used - mpConvergenceCriteria = pNewConvergenceCriteria; - - // Saving the scheme - mpScheme = pScheme; - - // Saving the linear solver - mpLinearSolver = pNewLinearSolver; - - // Setting up the default builder and solver - mpBuilderAndSolver = pNewBuilderAndSolver; - - // Set flags to start correcty the calculations - mSolutionStepIsInitialized = false; - - mInitializeWasPerformed = false; - - mFinalizeSolutionStep = true; - - // Tells to the Builder And Solver if the reactions have to be Calculated or not - GetBuilderAndSolver()->SetCalculateReactionsFlag(mCalculateReactionsFlag); - - // Tells to the Builder And Solver if the system matrix and vectors need to be reshaped at each step or not - GetBuilderAndSolver()->SetReshapeMatrixFlag(mReformDofSetAtEachStep); - - // Set EchoLevel to the default value (only time is displayed) - SetEchoLevel(1); - - // By default the matrices are rebuilt at each iteration - this->SetRebuildLevel(2); - - KRATOS_CATCH( "" ); - } - - /** Destructor. - */ - virtual ~MPMResidualBasedNewtonRaphsonStrategy() - { - } - - /** Destructor. - */ - - // Set and Get Scheme ... containing Builder, Update and other - - void SetScheme(typename TSchemeType::Pointer pScheme) - { - mpScheme = pScheme; - }; - - typename TSchemeType::Pointer GetScheme() - { - return mpScheme; - }; - - void SetBuilderAndSolver(typename TBuilderAndSolverType::Pointer pNewBuilderAndSolver) - { - mpBuilderAndSolver = pNewBuilderAndSolver; - }; - - typename TBuilderAndSolverType::Pointer GetBuilderAndSolver() - { - return mpBuilderAndSolver; - }; - - void SetInitializePerformedFlag(bool InitializePerformedFlag = true) - { - mInitializeWasPerformed = InitializePerformedFlag; - } - - bool GetInitializePerformedFlag() - { - return mInitializeWasPerformed; - } - - void SetCalculateReactionsFlag(bool CalculateReactionsFlag) - { - mCalculateReactionsFlag = CalculateReactionsFlag; - } - - bool GetCalculateReactionsFlag() - { - return mCalculateReactionsFlag; - } - - void SetReformDofSetAtEachStepFlag(bool flag) - { - mReformDofSetAtEachStep = flag; - GetBuilderAndSolver()->SetReshapeMatrixFlag(mReformDofSetAtEachStep); - } - - bool GetReformDofSetAtEachStepFlag() - { - return mReformDofSetAtEachStep; - } - - void SetMaxIterationNumber(unsigned int MaxIterationNumber) - { - mMaxIterationNumber = MaxIterationNumber; - } - - unsigned int GetMaxIterationNumber() - { - return mMaxIterationNumber; - } - - void SetFinalizeSolutionStepFlag(bool FinalizeSolutionStepFlag = true) - { - mFinalizeSolutionStep = FinalizeSolutionStepFlag; - } - - bool GetFinalizeSolutionStepFlag() - { - return mFinalizeSolutionStep; - } - - /** - * @brief It sets the level of echo for the solving strategy - * @param Level The level to set - * @details The different levels of echo are: - * - 0: Mute... no echo at all - * - 1: Printing time and basic informations - * - 2: Printing linear solver data - * - 3: Print of debug informations: Echo of stiffness matrix, Dx, b... - */ - void SetEchoLevel(int Level) override - { - BaseType::mEchoLevel = Level; - GetBuilderAndSolver()->SetEchoLevel(Level); - mpConvergenceCriteria->SetEchoLevel(Level); - } - - //********************************************************************************* - /**OPERATIONS ACCESSIBLE FROM THE INPUT:*/ - - /** - * @brief Operation to predict the solution ... if it is not called a trivial predictor is used in which the - values of the solution step of interest are assumed equal to the old values - */ - void Predict() override - { - KRATOS_TRY; - // OPERATIONS THAT SHOULD BE DONE ONCE - internal check to avoid repetitions - // If the operations needed were already performed this does nothing - if (mInitializeWasPerformed == false) - Initialize(); - - // Initialize solution step - if (mSolutionStepIsInitialized == false) - InitializeSolutionStep(); - - DofsArrayType& r_dof_set = GetBuilderAndSolver()->GetDofSet(); - - TSystemMatrixType& rA = *mpA; - TSystemVectorType& rDx = *mpDx; - TSystemVectorType& rb = *mpb; - - GetScheme()->Predict(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); - - // Move the mesh if needed - if (this->MoveMeshFlag() == true) BaseType::MoveMesh(); - - KRATOS_CATCH( "" ); - } - - /** - * @brief Initialization of member variables and prior operations - */ - void Initialize() override - { - KRATOS_TRY; - - typename TSchemeType::Pointer p_scheme = GetScheme(); - typename TBuilderAndSolverType::Pointer p_builder_and_solver = GetBuilderAndSolver(); - - // OPERATIONS THAT SHOULD BE DONE ONCE - internal check to avoid repetitions - // if the operations needed were already performed this does nothing - if (mInitializeWasPerformed == false) - { - KRATOS_INFO_IF("MPMNewtonRaphsonStrategy",this->GetEchoLevel() >1) << "Initializing solving strategy" << std::endl; - KRATOS_ERROR_IF(mInitializeWasPerformed == true) << "Initialization was already performed " << mInitializeWasPerformed << std::endl; - - // Initialize The Scheme - OPERATIONS TO BE DONE ONCE - KRATOS_INFO_IF("MPMNewtonRaphsonStrategy",this->GetEchoLevel() >1) << "Initializing scheme" << std::endl; - if (p_scheme->SchemeIsInitialized() == false) - p_scheme->Initialize(BaseType::GetModelPart()); - - // Initialize The Elements - OPERATIONS TO BE DONE ONCE - KRATOS_INFO_IF("MPMNewtonRaphsonStrategy",this->GetEchoLevel() >1) << "Initializing elements" << std::endl; - if (p_scheme->ElementsAreInitialized() == false) - p_scheme->InitializeElements(BaseType::GetModelPart()); - - // Initialize The Conditions - OPERATIONS TO BE DONE ONCE - KRATOS_INFO_IF("MPMNewtonRaphsonStrategy",this->GetEchoLevel() >1) << "Initializing conditions" << std::endl; - if (p_scheme->ConditionsAreInitialized() == false) - p_scheme->InitializeConditions(BaseType::GetModelPart()); - - // Initialisation of the convergence criteria - typename TConvergenceCriteriaType::Pointer p_convergence_criteria = mpConvergenceCriteria; - KRATOS_INFO_IF("MPMNewtonRaphsonStrategy",this->GetEchoLevel() >1) << "Initializing convergence criteria"<IsInitialized() == false) - p_convergence_criteria->Initialize(BaseType::GetModelPart()); - - mInitializeWasPerformed = true; - } - - // Set up the system, operation performed just once unless it is required to reform the dof set at each iteration - if (p_builder_and_solver->GetDofSetIsInitializedFlag() == false || - mReformDofSetAtEachStep == true) - { - // Setting up the list of the DOFs to be solved - p_builder_and_solver->SetUpDofSet(p_scheme, BaseType::GetModelPart()); - - // Shaping correctly the system - p_builder_and_solver->SetUpSystem(BaseType::GetModelPart()); - - } - - // Prints informations about the current time - if (this->GetEchoLevel() == 2 && BaseType::GetModelPart().GetCommunicator().MyPID() == 0 ) - { - KRATOS_INFO("MPMNewtonRaphsonStrategy") << "CurrentTime = " << BaseType::GetModelPart().GetProcessInfo()[TIME] << std::endl; - } - - KRATOS_CATCH( "" ); - } - - /** - * @brief Solves the current step. This function returns true if a solution has been found, false otherwise. - */ - bool SolveSolutionStep() override - { - typename TSchemeType::Pointer p_scheme = GetScheme(); - typename TBuilderAndSolverType::Pointer p_builder_and_solver = GetBuilderAndSolver(); - - TSystemMatrixType& rA = *mpA; - TSystemVectorType& rDx = *mpDx; - TSystemVectorType& rb = *mpb; - DofsArrayType& r_dof_set = p_builder_and_solver->GetDofSet(); - - // Initializing the parameters of the Newton-Raphson cycle - unsigned int iteration_number = 1; - BaseType::GetModelPart().GetProcessInfo()[NL_ITERATION_NUMBER] = iteration_number; - bool is_converged = false; - - p_scheme->InitializeNonLinIteration(BaseType::GetModelPart(), rA, rDx, rb); - is_converged = mpConvergenceCriteria->PreCriteria(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); - - KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3) << "PreCriteria:" - << "\tIs_converged: " << is_converged << "\tmRebuildLevel: " << BaseType::mRebuildLevel - << "\tmStiffnessMatrixIsBuilt: " << BaseType::mStiffnessMatrixIsBuilt << std::endl; - - if (BaseType::mRebuildLevel > 1 || BaseType::mStiffnessMatrixIsBuilt == false) - { - KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3) << "SetToZero the matrix and vectors of the system"<GetEchoLevel() >= 3) << "Build and Solve"<BuildAndSolve(p_scheme, BaseType::GetModelPart(), rA, rDx, rb); - } - else - { - TSparseSpace::SetToZero(rDx); // rDx=0.00; - TSparseSpace::SetToZero(rb); - - p_builder_and_solver->BuildRHSAndSolve(p_scheme, BaseType::GetModelPart(), rA, rDx, rb); - KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3) << "BuildRHSAndSolve"<GetEchoLevel() == 3) // If it is needed to print the debug info - { - KRATOS_INFO("MPMNewtonRaphsonStrategy") << "SystemMatrix = " << rA << std::endl; - KRATOS_INFO("MPMNewtonRaphsonStrategy") << "solution obtained = " << rDx << std::endl; - KRATOS_INFO("MPMNewtonRaphsonStrategy") << "RHS = " << rb << std::endl; - } - else if (this->GetEchoLevel() == 4) // Print to matrix market file - { - std::stringstream matrix_market_name; - matrix_market_name << "A_" << BaseType::GetModelPart().GetProcessInfo()[TIME] << "_" << iteration_number << ".mm"; - TSparseSpace::WriteMatrixMarketMatrix((char*) (matrix_market_name.str()).c_str(), rA, false); - - std::stringstream matrix_market_vectname; - matrix_market_vectname << "b_" << BaseType::GetModelPart().GetProcessInfo()[TIME] << "_" << iteration_number << ".mm.rhs"; - TSparseSpace::WriteMatrixMarketVector((char*) (matrix_market_vectname.str()).c_str(), rb); - } - - // Update results - r_dof_set = p_builder_and_solver->GetDofSet(); - p_scheme->Update(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); - p_scheme->FinalizeNonLinIteration(BaseType::GetModelPart(), rA, rDx, rb); - - // Move the mesh if needed - if (BaseType::MoveMeshFlag() == true) BaseType::MoveMesh(); - - if (is_converged == true) - { - // Initialisation of the convergence criteria - r_dof_set = p_builder_and_solver->GetDofSet(); - mpConvergenceCriteria->InitializeSolutionStep(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); - - if (mpConvergenceCriteria->GetActualizeRHSflag() == true) - { - TSparseSpace::SetToZero(rb); - p_builder_and_solver->BuildRHS(p_scheme, BaseType::GetModelPart(), rb); - } - - is_converged = mpConvergenceCriteria->PostCriteria(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); - } - KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3 && !is_converged) << "Starting Nonlinear iteration"<InitializeNonLinIteration(BaseType::GetModelPart(), rA, rDx, rb); - - is_converged = mpConvergenceCriteria->PreCriteria(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); - - // Call the linear system solver to find the correction rDx. It is not called if there is no system to solve - if (SparseSpaceType::Size(rDx) != 0) - { - if (BaseType::mRebuildLevel > 1 || BaseType::mStiffnessMatrixIsBuilt == false ) - { - KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3) << "Iteration Number: " << iteration_number <GetEchoLevel() >= 3) << "Build and Solve"<BuildAndSolve(p_scheme, BaseType::GetModelPart(), rA, rDx, rb); - } - else - { - TSparseSpace::SetToZero(rDx); - TSparseSpace::SetToZero(rb); - - KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3) << "Build RHS and Solve" <BuildRHSAndSolve(p_scheme, BaseType::GetModelPart(), rA, rDx, rb); - } - } - else - { - TSparseSpace::SetToZero(rDx); - TSparseSpace::SetToZero(rb); - - KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3) << "Build RHS and Solve" <BuildRHSAndSolve(p_scheme, BaseType::GetModelPart(), rA, rDx, rb); - } - } - else - { - KRATOS_WARNING("MPMNewtonRaphsonStrategy") << "ATTENTION: no free DOFs!! " << std::endl; - } - - // Updating the results stored in the database - r_dof_set = p_builder_and_solver->GetDofSet(); - - p_scheme->Update(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); - - p_scheme->FinalizeNonLinIteration(BaseType::GetModelPart(), rA, rDx, rb); - - // Move the mesh if needed - if (BaseType::MoveMeshFlag() == true) BaseType::MoveMesh(); - - // If converged - if (is_converged == true) - { - if (mpConvergenceCriteria->GetActualizeRHSflag() == true) - { - TSparseSpace::SetToZero(rb); - - p_builder_and_solver->BuildRHS(p_scheme, BaseType::GetModelPart(), rb); - - } - - is_converged = mpConvergenceCriteria->PostCriteria(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); - } - } - - - // Plot a warning if the maximum number of iterations is exceeded - if (iteration_number >= mMaxIterationNumber && BaseType::GetModelPart().GetCommunicator().MyPID() == 0) - { - if (this->GetEchoLevel() > 1) - MaxIterationsExceeded(); - } - - return true; - } - - /** - * @brief This should be considered as a "post solution" convergence check which is useful for coupled analysis - the convergence criteria used is the one used inside the "solve" step - */ - bool IsConverged() override - { - KRATOS_TRY; - - TSystemMatrixType& rA = *mpA; - TSystemVectorType& rDx = *mpDx; - TSystemVectorType& rb = *mpb; - - if (mpConvergenceCriteria->GetActualizeRHSflag() == true) - { - GetBuilderAndSolver()->BuildRHS(GetScheme(), BaseType::GetModelPart(), rb); - } - - DofsArrayType& r_dof_set = GetBuilderAndSolver()->GetDofSet(); - - return mpConvergenceCriteria->PostCriteria(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); - KRATOS_CATCH( "" ); - - } - - /** - * @brief This operations should be called before printing the results when non trivial results - * (e.g. stresses) - * Need to be calculated given the solution of the step - * @details This operations should be called only when needed, before printing as it can involve a non - * negligible cost - */ - void CalculateOutputData() override - { - TSystemMatrixType& rA = *mpA; - TSystemVectorType& rDx = *mpDx; - TSystemVectorType& rb = *mpb; - - DofsArrayType& r_dof_set = GetBuilderAndSolver()->GetDofSet(); - GetScheme()->CalculateOutputData(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); - } - - /** - * @brief Clears the internal storage - */ - void Clear() override - { - KRATOS_TRY; - - SparseSpaceType::Clear(mpA); - TSystemMatrixType& rA = *mpA; - SparseSpaceType::Resize(rA, 0, 0); - - SparseSpaceType::Clear(mpDx); - TSystemVectorType& rDx = *mpDx; - SparseSpaceType::Resize(rDx, 0); - - SparseSpaceType::Clear(mpb); - TSystemVectorType& rb = *mpb; - SparseSpaceType::Resize(rb, 0); - - // Setting to zero the internal flag to ensure that the dof sets are recalculated - GetBuilderAndSolver()->SetDofSetIsInitializedFlag(false); - GetBuilderAndSolver()->Clear(); - GetScheme()->Clear(); - - KRATOS_CATCH( "" ); - } - - /*@} */ - /**@name Operators - */ - /*@{ */ - - /*@} */ - /**@name Operations */ - /*@{ */ - - - /*@} */ - /**@name Access */ - /*@{ */ - - /** - * @brief This method returns the LHS matrix - * @return The LHS matrix - */ - TSystemMatrixType& GetSystemMatrix() - { - TSystemMatrixType& rA = *mpA; - return rA; - } - - /** - * @brief Set method for the flag mKeepSystemConstantDuringIterations - * @param Value If we consider constant the system of equations during the iterations - */ - void SetKeepSystemConstantDuringIterations(bool value) - { - mKeepSystemConstantDuringIterations = value; - } - - /** - * @brief Get method for the flag mKeepSystemConstantDuringIterations - * @return True if we consider constant the system of equations during the iterations, false otherwise - */ - bool GetKeepSystemConstantDuringIterations() - { - return mKeepSystemConstantDuringIterations; - } - - /*@} */ - /**@name Inquiry */ - /*@{ */ - - - /*@} */ - /**@name Friends */ - /*@{ */ - - /*@} */ - -private: - - /**@name Protected static Member Variables */ - /*@{ */ - - /*@} */ - /**@name Protected member Variables */ - /*@{ */ - - /*@} */ - /**@name Protected Operators*/ - /*@{ */ - - - /*@} */ - /**@name Protected Operations*/ - /*@{ */ - - /*@} */ - /**@name Protected Access */ - /*@{ */ - - /*@} */ - /**@name Protected Inquiry */ - /*@{ */ - - /*@} */ - /**@name Protected LifeCycle */ - /*@{ */ - - /*@} */ - -protected: - /**@name Static Member Variables */ - /*@{ */ - - /*@} */ - /**@name Member Variables */ - /*@{ */ - - typename TLinearSolver::Pointer mpLinearSolver; /// The pointer to the linear solver considered - typename TSchemeType::Pointer mpScheme; /// The pointer to the time scheme employed - typename TBuilderAndSolverType::Pointer mpBuilderAndSolver; /// The pointer to the builder and solver employed - typename TConvergenceCriteriaType::Pointer mpConvergenceCriteria; /// The pointer to the convergence criteria employed - - TSystemVectorPointerType mpDx; /// The incremement in the solution - TSystemVectorPointerType mpb; /// The RHS vector of the system of equations - TSystemMatrixPointerType mpA; /// The LHS matrix of the system of equations - - /** - * @brief Flag telling if it is needed to reform the DofSet at each - solution step or if it is possible to form it just once - * @details Default = false - - true : Reform at each time step - - false : Form just one (more efficient) - */ - bool mReformDofSetAtEachStep; - - // Flag telling if it is needed or not to compute the reactions - bool mCalculateReactionsFlag; - - // Flag to set as initialized the solution step - bool mSolutionStepIsInitialized; - - // The maximum number of iterations, 30 by default - unsigned int mMaxIterationNumber; - - // Flag to set as initialized the strategy - bool mInitializeWasPerformed; - - // Flag to allow keeping system matrix constant during iterations - bool mKeepSystemConstantDuringIterations; - - // Flag to allow to not finalize the solution step, so the historical variables are not updated - bool mFinalizeSolutionStep; - - /*@} */ - /**@name Private Operators*/ - /*@{ */ - - /** - * @brief Performs all the required operations that should be done (for each step) before solving the solution step. - * @details A member variable should be used as a flag to make sure this function is called only once per step. - */ - void InitializeSolutionStep() override - { - KRATOS_TRY; - - // Initialize solution step - if (mSolutionStepIsInitialized == false) - { - typename TBuilderAndSolverType::Pointer p_builder_and_solver = GetBuilderAndSolver(); - typename TSchemeType::Pointer p_scheme = GetScheme(); - - // Setting up the Vectors involved to the correct size - p_builder_and_solver->ResizeAndInitializeVectors(p_scheme, mpA, mpDx, mpb, BaseType::GetModelPart()); - - TSystemMatrixType& rA = *mpA; - TSystemVectorType& rDx = *mpDx; - TSystemVectorType& rb = *mpb; - - // Initial operations ... things that are constant over the Solution Step - p_builder_and_solver->InitializeSolutionStep(BaseType::GetModelPart(), rA, rDx, rb); - - // Initial operations ... things that are constant over the Solution Step - p_scheme->InitializeSolutionStep(BaseType::GetModelPart(), rA, rDx, rb); - - mSolutionStepIsInitialized = true; - } - - KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3) << "Initialize Solution Step in strategy finished" <CalculateReactions(p_scheme, BaseType::GetModelPart(), rA, rDx, rb); - } - - // Calling r_dof_set - DofsArrayType& r_dof_set = p_builder_and_solver->GetDofSet(); - - /* Finalization of the solution step, - * operations to be done after achieving convergence, for example the - * Final Residual Vector (rb) has to be saved in there to avoid error accumulation - */ - if( mFinalizeSolutionStep ) - { - KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3) << "Calling FinalizeSolutionStep" <FinalizeSolutionStep(BaseType::GetModelPart(), rA, rDx, rb); - p_builder_and_solver->FinalizeSolutionStep(BaseType::GetModelPart(), rA, rDx, rb); - mpConvergenceCriteria->FinalizeSolutionStep(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); - } - - // Cleaning memory after the solution - p_scheme->Clean(); - - // Reset flags for next step - mSolutionStepIsInitialized = false; - - if (mReformDofSetAtEachStep == true) //deallocate the systemvectors - { - SparseSpaceType::Clear(mpA); - SparseSpaceType::Clear(mpDx); - SparseSpaceType::Clear(mpb); - - this->Clear(); - } - - KRATOS_CATCH( "" ); - } - - /** - * @brief This method prints information after reach the max number of iterations - */ - void MaxIterationsExceeded() - { - KRATOS_WARNING("MPMNewtonRaphsonStrategy") << "***************************************************" << std::endl; - KRATOS_WARNING("MPMNewtonRaphsonStrategy") << "******* ATTENTION: max iterations exceeded ********" << std::endl; - KRATOS_WARNING("MPMNewtonRaphsonStrategy") << "***************************************************" << std::endl; - - } - - /** - * @brief Function to perform expensive checks. - * @details It is designed to be called ONCE to verify that the input is correct. - */ - int Check() override - { - KRATOS_TRY; - - BaseType::Check(); - GetBuilderAndSolver()->Check(BaseType::GetModelPart()); - GetScheme()->Check(BaseType::GetModelPart()); - mpConvergenceCriteria->Check(BaseType::GetModelPart()); - - return 0; - - KRATOS_CATCH( "" ); - } - - - /*@} */ - /**@name Private Operations*/ - /*@{ */ - - - /*@} */ - /**@name Private Access */ - /*@{ */ - - - /*@} */ - /**@name Private Inquiry */ - /*@{ */ - - - /*@} */ - /**@name Un accessible methods */ - /*@{ */ - - /** Copy constructor. - */ - MPMResidualBasedNewtonRaphsonStrategy(const MPMResidualBasedNewtonRaphsonStrategy& Other) - { - }; - - - /*@} */ - -}; /* Class MPMResidualBasedNewtonRaphsonStrategy */ - -/*@} */ - -/**@name Type Definitions */ -/*@{ */ - - -/*@} */ - -} /* namespace Kratos.*/ - -#endif /* KRATOS_MPM_RESIDUAL_BASED_NEWTON_RAPHSON_STRATEGY defined */ - diff --git a/applications/ParticleMechanicsApplication/python_scripts/mpm_solver.py b/applications/ParticleMechanicsApplication/python_scripts/mpm_solver.py index 14093f112743..55f35a0dab54 100644 --- a/applications/ParticleMechanicsApplication/python_scripts/mpm_solver.py +++ b/applications/ParticleMechanicsApplication/python_scripts/mpm_solver.py @@ -395,7 +395,7 @@ def _CreateNewtonRaphsonStrategy(self): convergence_criterion = self._GetConvergenceCriteria() builder_and_solver = self._GetBuilderAndSolver() reform_dofs_at_each_step = False ## hard-coded, but can be changed upon implementation - return KratosParticle.MPMResidualBasedNewtonRaphsonStrategy(computing_model_part, + return KratosMultiphysics.ResidualBasedNewtonRaphsonStrategy(computing_model_part, solution_scheme, linear_solver, convergence_criterion, From b03b04c53cb47337488508a020c6cf59b8162b0c Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Wed, 22 Apr 2020 10:31:23 +1000 Subject: [PATCH 190/314] Revert "use core newton raphson strategy instead of custom" This reverts commit 406266fe58fd6db660bcfdc7762aa25003ba32a7. --- .../add_custom_strategies_to_python.cpp | 19 +- ...residual_based_newton_raphson_strategy.hpp | 969 ++++++++++++++++++ .../python_scripts/mpm_solver.py | 2 +- 3 files changed, 988 insertions(+), 2 deletions(-) create mode 100644 applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp diff --git a/applications/ParticleMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp b/applications/ParticleMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp index 29f943c1845b..b67d257db4d7 100644 --- a/applications/ParticleMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp +++ b/applications/ParticleMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp @@ -22,10 +22,11 @@ #include "containers/flags.h" #include "spaces/ublas_space.h" #include "boost/numeric/ublas/matrix.hpp" -#include "particle_mechanics_application_variables.h" //---strategies #include "solving_strategies/strategies/solving_strategy.h" +#include "custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp" + //---convergence criterias #include "solving_strategies/convergencecriterias/convergence_criteria.h" @@ -57,6 +58,8 @@ namespace Python{ typedef Scheme< SparseSpaceType, LocalSpaceType > BaseSchemeType; typedef ConvergenceCriteria< SparseSpaceType, LocalSpaceType > ConvergenceCriteriaType; + typedef MPMResidualBasedNewtonRaphsonStrategy< SparseSpaceType, LocalSpaceType, LinearSolverType> MPMResidualBasedNewtonRaphsonStrategyType; + //custom scheme types typedef MPMResidualBasedBossakScheme< SparseSpaceType, LocalSpaceType > MPMResidualBasedBossakSchemeType; @@ -65,6 +68,20 @@ namespace Python{ .def(py::init < ModelPart&, unsigned int, unsigned int, double, double, bool>()) .def("Initialize", &MPMResidualBasedBossakSchemeType::Initialize) ; + + // MPM Residual Based Newton Raphson Strategy Type + py::class_< MPMResidualBasedNewtonRaphsonStrategyType,typename MPMResidualBasedNewtonRaphsonStrategyType::Pointer, BaseSolvingStrategyType >(m,"MPMResidualBasedNewtonRaphsonStrategy") + .def(py::init< ModelPart&, BaseSchemeType::Pointer, LinearSolverType::Pointer, ConvergenceCriteriaType::Pointer, int, bool, bool, bool >() ) + .def(py::init< ModelPart&, BaseSchemeType::Pointer, LinearSolverType::Pointer, ConvergenceCriteriaType::Pointer, BuilderAndSolverType::Pointer, int, bool, bool, bool >() ) + .def("SetMaxIterationNumber", &MPMResidualBasedNewtonRaphsonStrategyType::SetMaxIterationNumber) + .def("GetMaxIterationNumber", &MPMResidualBasedNewtonRaphsonStrategyType::GetMaxIterationNumber) + .def("SetInitializePerformedFlag", &MPMResidualBasedNewtonRaphsonStrategyType::SetInitializePerformedFlag) + .def("GetInitializePerformedFlag", &MPMResidualBasedNewtonRaphsonStrategyType::GetInitializePerformedFlag) + .def("SetKeepSystemConstantDuringIterations", &MPMResidualBasedNewtonRaphsonStrategyType::SetKeepSystemConstantDuringIterations) + .def("GetKeepSystemConstantDuringIterations", &MPMResidualBasedNewtonRaphsonStrategyType::GetKeepSystemConstantDuringIterations) + .def("SetFinalizeSolutionStepFlag", &MPMResidualBasedNewtonRaphsonStrategyType::SetFinalizeSolutionStepFlag) + .def("GetFinalizeSolutionStepFlag", &MPMResidualBasedNewtonRaphsonStrategyType::GetFinalizeSolutionStepFlag) + ; } } // namespace Python. diff --git a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp new file mode 100644 index 000000000000..87487ac93f91 --- /dev/null +++ b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp @@ -0,0 +1,969 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ \. +// _|\_\_| \__,_|\__|\___/ ____/ +// Multi-Physics +// +// License: BSD License +// Kratos default license: kratos/license.txt +// +// Main authors: Ilaria Iaconeta, Bodhinanda Chandra +// +// + + +#if !defined(KRATOS_MPM_RESIDUAL_BASED_NEWTON_RAPHSON_STRATEGY ) +#define KRATOS_MPM_RESIDUAL_BASED_NEWTON_RAPHSON_STRATEGY + +/* System includes */ + +/* External includes */ + +/* Project includes */ +#include "includes/define.h" +#include "includes/model_part.h" +#include "includes/kratos_flags.h" + +#include "solving_strategies/strategies/solving_strategy.h" +#include "solving_strategies/convergencecriterias/convergence_criteria.h" +#include "solving_strategies/builder_and_solvers/residualbased_elimination_builder_and_solver.h" + +// Application includes +#include "particle_mechanics_application_variables.h" + +namespace Kratos +{ + +/**@name Kratos Globals */ +/*@{ */ + + +/*@} */ +/**@name Type Definitions */ +/*@{ */ + +/*@} */ + + +/**@name Enum's */ +/*@{ */ + + +/*@} */ +/**@name Functions */ +/*@{ */ + + + +/*@} */ +/**@name Kratos Classes */ +/*@{ */ + +/// Short class definition. + +/** + * @class MPMResidualBasedNewtonRaphsonStrategy + * @ingroup KratosParticle + * @brief Newton Raphson strategy suited for MPM simulations + * @details This strategy iterates until the convergence is achieved (or the maximum number of iterations is achieved) using a Newton Raphson algorithm + */ +template +class MPMResidualBasedNewtonRaphsonStrategy + : public SolvingStrategy +{ +public: + /**@name Type Definitions */ + /*@{ */ + typedef ConvergenceCriteria TConvergenceCriteriaType; + + /** Counted pointer of ClassName */ + KRATOS_CLASS_POINTER_DEFINITION(MPMResidualBasedNewtonRaphsonStrategy); + + typedef SolvingStrategy BaseType; + + typedef typename BaseType::TBuilderAndSolverType TBuilderAndSolverType; + + typedef typename BaseType::TDataType TDataType; + + typedef TSparseSpace SparseSpaceType; + + typedef typename BaseType::TSchemeType TSchemeType; + + typedef typename BaseType::DofsArrayType DofsArrayType; + + typedef typename BaseType::TSystemMatrixType TSystemMatrixType; + + typedef typename BaseType::TSystemVectorType TSystemVectorType; + + typedef typename BaseType::LocalSystemVectorType LocalSystemVectorType; + + typedef typename BaseType::LocalSystemMatrixType LocalSystemMatrixType; + + typedef typename BaseType::TSystemMatrixPointerType TSystemMatrixPointerType; + + typedef typename BaseType::TSystemVectorPointerType TSystemVectorPointerType; + + + /*@} */ + /**@name Life Cycle + */ + /*@{ */ + + /** Constructors. + */ + MPMResidualBasedNewtonRaphsonStrategy( + ModelPart& rModelPart, + bool MoveMeshFlag = false + ) + : SolvingStrategy(rModelPart, MoveMeshFlag) + { + } + + MPMResidualBasedNewtonRaphsonStrategy( + ModelPart& rModelPart, + typename TSchemeType::Pointer pScheme, + typename TLinearSolver::Pointer pNewLinearSolver, + typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria, + int MaxIterations = 30, + bool CalculateReactions = false, + bool ReformDofSetAtEachStep = false, + bool MoveMeshFlag = false + ) + : SolvingStrategy(rModelPart, MoveMeshFlag) + { + KRATOS_TRY; + + mKeepSystemConstantDuringIterations = false; + + // Set flags to default values + SetMaxIterationNumber(MaxIterations); + + mCalculateReactionsFlag = CalculateReactions; + + mReformDofSetAtEachStep = ReformDofSetAtEachStep; + + // Saving the convergence criteria to be used + mpConvergenceCriteria = pNewConvergenceCriteria; + + // Saving the scheme + mpScheme = pScheme; + + // Saving the linear solver + mpLinearSolver = pNewLinearSolver; + + // Setting up the default builder and solver + mpBuilderAndSolver = typename TBuilderAndSolverType::Pointer + ( + new ResidualBasedEliminationBuilderAndSolver (mpLinearSolver) + ); + + // Set flags to start correcty the calculations + mSolutionStepIsInitialized = false; + + mInitializeWasPerformed = false; + + mFinalizeSolutionStep = true; + + // Tells to the Builder And Solver if the reactions have to be Calculated or not + GetBuilderAndSolver()->SetCalculateReactionsFlag(mCalculateReactionsFlag); + + // Tells to the Builder And Solver if the system matrix and vectors need to be reshaped at each step or not + GetBuilderAndSolver()->SetReshapeMatrixFlag(mReformDofSetAtEachStep); + + // Set EchoLevel to the default value (only time is displayed) + SetEchoLevel(1); + + // By default the matrices are rebuilt at each iteration + this->SetRebuildLevel(2); + + KRATOS_CATCH( "" ); + } + + MPMResidualBasedNewtonRaphsonStrategy( + ModelPart& rModelPart, + typename TSchemeType::Pointer pScheme, + typename TLinearSolver::Pointer pNewLinearSolver, + typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria, + typename TBuilderAndSolverType::Pointer pNewBuilderAndSolver, + int MaxIterations = 30, + bool CalculateReactions = false, + bool ReformDofSetAtEachStep = false, + bool MoveMeshFlag = false + ) + : SolvingStrategy(rModelPart, MoveMeshFlag) + { + KRATOS_TRY; + + mKeepSystemConstantDuringIterations = false; + + // Set flags to default values + SetMaxIterationNumber(MaxIterations); + mCalculateReactionsFlag = CalculateReactions; + + mReformDofSetAtEachStep = ReformDofSetAtEachStep; + + // Saving the convergence criteria to be used + mpConvergenceCriteria = pNewConvergenceCriteria; + + // Saving the scheme + mpScheme = pScheme; + + // Saving the linear solver + mpLinearSolver = pNewLinearSolver; + + // Setting up the default builder and solver + mpBuilderAndSolver = pNewBuilderAndSolver; + + // Set flags to start correcty the calculations + mSolutionStepIsInitialized = false; + + mInitializeWasPerformed = false; + + mFinalizeSolutionStep = true; + + // Tells to the Builder And Solver if the reactions have to be Calculated or not + GetBuilderAndSolver()->SetCalculateReactionsFlag(mCalculateReactionsFlag); + + // Tells to the Builder And Solver if the system matrix and vectors need to be reshaped at each step or not + GetBuilderAndSolver()->SetReshapeMatrixFlag(mReformDofSetAtEachStep); + + // Set EchoLevel to the default value (only time is displayed) + SetEchoLevel(1); + + // By default the matrices are rebuilt at each iteration + this->SetRebuildLevel(2); + + KRATOS_CATCH( "" ); + } + + /** Destructor. + */ + virtual ~MPMResidualBasedNewtonRaphsonStrategy() + { + } + + /** Destructor. + */ + + // Set and Get Scheme ... containing Builder, Update and other + + void SetScheme(typename TSchemeType::Pointer pScheme) + { + mpScheme = pScheme; + }; + + typename TSchemeType::Pointer GetScheme() + { + return mpScheme; + }; + + void SetBuilderAndSolver(typename TBuilderAndSolverType::Pointer pNewBuilderAndSolver) + { + mpBuilderAndSolver = pNewBuilderAndSolver; + }; + + typename TBuilderAndSolverType::Pointer GetBuilderAndSolver() + { + return mpBuilderAndSolver; + }; + + void SetInitializePerformedFlag(bool InitializePerformedFlag = true) + { + mInitializeWasPerformed = InitializePerformedFlag; + } + + bool GetInitializePerformedFlag() + { + return mInitializeWasPerformed; + } + + void SetCalculateReactionsFlag(bool CalculateReactionsFlag) + { + mCalculateReactionsFlag = CalculateReactionsFlag; + } + + bool GetCalculateReactionsFlag() + { + return mCalculateReactionsFlag; + } + + void SetReformDofSetAtEachStepFlag(bool flag) + { + mReformDofSetAtEachStep = flag; + GetBuilderAndSolver()->SetReshapeMatrixFlag(mReformDofSetAtEachStep); + } + + bool GetReformDofSetAtEachStepFlag() + { + return mReformDofSetAtEachStep; + } + + void SetMaxIterationNumber(unsigned int MaxIterationNumber) + { + mMaxIterationNumber = MaxIterationNumber; + } + + unsigned int GetMaxIterationNumber() + { + return mMaxIterationNumber; + } + + void SetFinalizeSolutionStepFlag(bool FinalizeSolutionStepFlag = true) + { + mFinalizeSolutionStep = FinalizeSolutionStepFlag; + } + + bool GetFinalizeSolutionStepFlag() + { + return mFinalizeSolutionStep; + } + + /** + * @brief It sets the level of echo for the solving strategy + * @param Level The level to set + * @details The different levels of echo are: + * - 0: Mute... no echo at all + * - 1: Printing time and basic informations + * - 2: Printing linear solver data + * - 3: Print of debug informations: Echo of stiffness matrix, Dx, b... + */ + void SetEchoLevel(int Level) override + { + BaseType::mEchoLevel = Level; + GetBuilderAndSolver()->SetEchoLevel(Level); + mpConvergenceCriteria->SetEchoLevel(Level); + } + + //********************************************************************************* + /**OPERATIONS ACCESSIBLE FROM THE INPUT:*/ + + /** + * @brief Operation to predict the solution ... if it is not called a trivial predictor is used in which the + values of the solution step of interest are assumed equal to the old values + */ + void Predict() override + { + KRATOS_TRY; + // OPERATIONS THAT SHOULD BE DONE ONCE - internal check to avoid repetitions + // If the operations needed were already performed this does nothing + if (mInitializeWasPerformed == false) + Initialize(); + + // Initialize solution step + if (mSolutionStepIsInitialized == false) + InitializeSolutionStep(); + + DofsArrayType& r_dof_set = GetBuilderAndSolver()->GetDofSet(); + + TSystemMatrixType& rA = *mpA; + TSystemVectorType& rDx = *mpDx; + TSystemVectorType& rb = *mpb; + + GetScheme()->Predict(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); + + // Move the mesh if needed + if (this->MoveMeshFlag() == true) BaseType::MoveMesh(); + + KRATOS_CATCH( "" ); + } + + /** + * @brief Initialization of member variables and prior operations + */ + void Initialize() override + { + KRATOS_TRY; + + typename TSchemeType::Pointer p_scheme = GetScheme(); + typename TBuilderAndSolverType::Pointer p_builder_and_solver = GetBuilderAndSolver(); + + // OPERATIONS THAT SHOULD BE DONE ONCE - internal check to avoid repetitions + // if the operations needed were already performed this does nothing + if (mInitializeWasPerformed == false) + { + KRATOS_INFO_IF("MPMNewtonRaphsonStrategy",this->GetEchoLevel() >1) << "Initializing solving strategy" << std::endl; + KRATOS_ERROR_IF(mInitializeWasPerformed == true) << "Initialization was already performed " << mInitializeWasPerformed << std::endl; + + // Initialize The Scheme - OPERATIONS TO BE DONE ONCE + KRATOS_INFO_IF("MPMNewtonRaphsonStrategy",this->GetEchoLevel() >1) << "Initializing scheme" << std::endl; + if (p_scheme->SchemeIsInitialized() == false) + p_scheme->Initialize(BaseType::GetModelPart()); + + // Initialize The Elements - OPERATIONS TO BE DONE ONCE + KRATOS_INFO_IF("MPMNewtonRaphsonStrategy",this->GetEchoLevel() >1) << "Initializing elements" << std::endl; + if (p_scheme->ElementsAreInitialized() == false) + p_scheme->InitializeElements(BaseType::GetModelPart()); + + // Initialize The Conditions - OPERATIONS TO BE DONE ONCE + KRATOS_INFO_IF("MPMNewtonRaphsonStrategy",this->GetEchoLevel() >1) << "Initializing conditions" << std::endl; + if (p_scheme->ConditionsAreInitialized() == false) + p_scheme->InitializeConditions(BaseType::GetModelPart()); + + // Initialisation of the convergence criteria + typename TConvergenceCriteriaType::Pointer p_convergence_criteria = mpConvergenceCriteria; + KRATOS_INFO_IF("MPMNewtonRaphsonStrategy",this->GetEchoLevel() >1) << "Initializing convergence criteria"<IsInitialized() == false) + p_convergence_criteria->Initialize(BaseType::GetModelPart()); + + mInitializeWasPerformed = true; + } + + // Set up the system, operation performed just once unless it is required to reform the dof set at each iteration + if (p_builder_and_solver->GetDofSetIsInitializedFlag() == false || + mReformDofSetAtEachStep == true) + { + // Setting up the list of the DOFs to be solved + p_builder_and_solver->SetUpDofSet(p_scheme, BaseType::GetModelPart()); + + // Shaping correctly the system + p_builder_and_solver->SetUpSystem(BaseType::GetModelPart()); + + } + + // Prints informations about the current time + if (this->GetEchoLevel() == 2 && BaseType::GetModelPart().GetCommunicator().MyPID() == 0 ) + { + KRATOS_INFO("MPMNewtonRaphsonStrategy") << "CurrentTime = " << BaseType::GetModelPart().GetProcessInfo()[TIME] << std::endl; + } + + KRATOS_CATCH( "" ); + } + + /** + * @brief Solves the current step. This function returns true if a solution has been found, false otherwise. + */ + bool SolveSolutionStep() override + { + typename TSchemeType::Pointer p_scheme = GetScheme(); + typename TBuilderAndSolverType::Pointer p_builder_and_solver = GetBuilderAndSolver(); + + TSystemMatrixType& rA = *mpA; + TSystemVectorType& rDx = *mpDx; + TSystemVectorType& rb = *mpb; + DofsArrayType& r_dof_set = p_builder_and_solver->GetDofSet(); + + // Initializing the parameters of the Newton-Raphson cycle + unsigned int iteration_number = 1; + BaseType::GetModelPart().GetProcessInfo()[NL_ITERATION_NUMBER] = iteration_number; + bool is_converged = false; + + p_scheme->InitializeNonLinIteration(BaseType::GetModelPart(), rA, rDx, rb); + is_converged = mpConvergenceCriteria->PreCriteria(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); + + KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3) << "PreCriteria:" + << "\tIs_converged: " << is_converged << "\tmRebuildLevel: " << BaseType::mRebuildLevel + << "\tmStiffnessMatrixIsBuilt: " << BaseType::mStiffnessMatrixIsBuilt << std::endl; + + if (BaseType::mRebuildLevel > 1 || BaseType::mStiffnessMatrixIsBuilt == false) + { + KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3) << "SetToZero the matrix and vectors of the system"<GetEchoLevel() >= 3) << "Build and Solve"<BuildAndSolve(p_scheme, BaseType::GetModelPart(), rA, rDx, rb); + } + else + { + TSparseSpace::SetToZero(rDx); // rDx=0.00; + TSparseSpace::SetToZero(rb); + + p_builder_and_solver->BuildRHSAndSolve(p_scheme, BaseType::GetModelPart(), rA, rDx, rb); + KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3) << "BuildRHSAndSolve"<GetEchoLevel() == 3) // If it is needed to print the debug info + { + KRATOS_INFO("MPMNewtonRaphsonStrategy") << "SystemMatrix = " << rA << std::endl; + KRATOS_INFO("MPMNewtonRaphsonStrategy") << "solution obtained = " << rDx << std::endl; + KRATOS_INFO("MPMNewtonRaphsonStrategy") << "RHS = " << rb << std::endl; + } + else if (this->GetEchoLevel() == 4) // Print to matrix market file + { + std::stringstream matrix_market_name; + matrix_market_name << "A_" << BaseType::GetModelPart().GetProcessInfo()[TIME] << "_" << iteration_number << ".mm"; + TSparseSpace::WriteMatrixMarketMatrix((char*) (matrix_market_name.str()).c_str(), rA, false); + + std::stringstream matrix_market_vectname; + matrix_market_vectname << "b_" << BaseType::GetModelPart().GetProcessInfo()[TIME] << "_" << iteration_number << ".mm.rhs"; + TSparseSpace::WriteMatrixMarketVector((char*) (matrix_market_vectname.str()).c_str(), rb); + } + + // Update results + r_dof_set = p_builder_and_solver->GetDofSet(); + p_scheme->Update(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); + p_scheme->FinalizeNonLinIteration(BaseType::GetModelPart(), rA, rDx, rb); + + // Move the mesh if needed + if (BaseType::MoveMeshFlag() == true) BaseType::MoveMesh(); + + if (is_converged == true) + { + // Initialisation of the convergence criteria + r_dof_set = p_builder_and_solver->GetDofSet(); + mpConvergenceCriteria->InitializeSolutionStep(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); + + if (mpConvergenceCriteria->GetActualizeRHSflag() == true) + { + TSparseSpace::SetToZero(rb); + p_builder_and_solver->BuildRHS(p_scheme, BaseType::GetModelPart(), rb); + } + + is_converged = mpConvergenceCriteria->PostCriteria(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); + } + KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3 && !is_converged) << "Starting Nonlinear iteration"<InitializeNonLinIteration(BaseType::GetModelPart(), rA, rDx, rb); + + is_converged = mpConvergenceCriteria->PreCriteria(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); + + // Call the linear system solver to find the correction rDx. It is not called if there is no system to solve + if (SparseSpaceType::Size(rDx) != 0) + { + if (BaseType::mRebuildLevel > 1 || BaseType::mStiffnessMatrixIsBuilt == false ) + { + KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3) << "Iteration Number: " << iteration_number <GetEchoLevel() >= 3) << "Build and Solve"<BuildAndSolve(p_scheme, BaseType::GetModelPart(), rA, rDx, rb); + } + else + { + TSparseSpace::SetToZero(rDx); + TSparseSpace::SetToZero(rb); + + KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3) << "Build RHS and Solve" <BuildRHSAndSolve(p_scheme, BaseType::GetModelPart(), rA, rDx, rb); + } + } + else + { + TSparseSpace::SetToZero(rDx); + TSparseSpace::SetToZero(rb); + + KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3) << "Build RHS and Solve" <BuildRHSAndSolve(p_scheme, BaseType::GetModelPart(), rA, rDx, rb); + } + } + else + { + KRATOS_WARNING("MPMNewtonRaphsonStrategy") << "ATTENTION: no free DOFs!! " << std::endl; + } + + // Updating the results stored in the database + r_dof_set = p_builder_and_solver->GetDofSet(); + + p_scheme->Update(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); + + p_scheme->FinalizeNonLinIteration(BaseType::GetModelPart(), rA, rDx, rb); + + // Move the mesh if needed + if (BaseType::MoveMeshFlag() == true) BaseType::MoveMesh(); + + // If converged + if (is_converged == true) + { + if (mpConvergenceCriteria->GetActualizeRHSflag() == true) + { + TSparseSpace::SetToZero(rb); + + p_builder_and_solver->BuildRHS(p_scheme, BaseType::GetModelPart(), rb); + + } + + is_converged = mpConvergenceCriteria->PostCriteria(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); + } + } + + + // Plot a warning if the maximum number of iterations is exceeded + if (iteration_number >= mMaxIterationNumber && BaseType::GetModelPart().GetCommunicator().MyPID() == 0) + { + if (this->GetEchoLevel() > 1) + MaxIterationsExceeded(); + } + + return true; + } + + /** + * @brief This should be considered as a "post solution" convergence check which is useful for coupled analysis - the convergence criteria used is the one used inside the "solve" step + */ + bool IsConverged() override + { + KRATOS_TRY; + + TSystemMatrixType& rA = *mpA; + TSystemVectorType& rDx = *mpDx; + TSystemVectorType& rb = *mpb; + + if (mpConvergenceCriteria->GetActualizeRHSflag() == true) + { + GetBuilderAndSolver()->BuildRHS(GetScheme(), BaseType::GetModelPart(), rb); + } + + DofsArrayType& r_dof_set = GetBuilderAndSolver()->GetDofSet(); + + return mpConvergenceCriteria->PostCriteria(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); + KRATOS_CATCH( "" ); + + } + + /** + * @brief This operations should be called before printing the results when non trivial results + * (e.g. stresses) + * Need to be calculated given the solution of the step + * @details This operations should be called only when needed, before printing as it can involve a non + * negligible cost + */ + void CalculateOutputData() override + { + TSystemMatrixType& rA = *mpA; + TSystemVectorType& rDx = *mpDx; + TSystemVectorType& rb = *mpb; + + DofsArrayType& r_dof_set = GetBuilderAndSolver()->GetDofSet(); + GetScheme()->CalculateOutputData(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); + } + + /** + * @brief Clears the internal storage + */ + void Clear() override + { + KRATOS_TRY; + + SparseSpaceType::Clear(mpA); + TSystemMatrixType& rA = *mpA; + SparseSpaceType::Resize(rA, 0, 0); + + SparseSpaceType::Clear(mpDx); + TSystemVectorType& rDx = *mpDx; + SparseSpaceType::Resize(rDx, 0); + + SparseSpaceType::Clear(mpb); + TSystemVectorType& rb = *mpb; + SparseSpaceType::Resize(rb, 0); + + // Setting to zero the internal flag to ensure that the dof sets are recalculated + GetBuilderAndSolver()->SetDofSetIsInitializedFlag(false); + GetBuilderAndSolver()->Clear(); + GetScheme()->Clear(); + + KRATOS_CATCH( "" ); + } + + /*@} */ + /**@name Operators + */ + /*@{ */ + + /*@} */ + /**@name Operations */ + /*@{ */ + + + /*@} */ + /**@name Access */ + /*@{ */ + + /** + * @brief This method returns the LHS matrix + * @return The LHS matrix + */ + TSystemMatrixType& GetSystemMatrix() + { + TSystemMatrixType& rA = *mpA; + return rA; + } + + /** + * @brief Set method for the flag mKeepSystemConstantDuringIterations + * @param Value If we consider constant the system of equations during the iterations + */ + void SetKeepSystemConstantDuringIterations(bool value) + { + mKeepSystemConstantDuringIterations = value; + } + + /** + * @brief Get method for the flag mKeepSystemConstantDuringIterations + * @return True if we consider constant the system of equations during the iterations, false otherwise + */ + bool GetKeepSystemConstantDuringIterations() + { + return mKeepSystemConstantDuringIterations; + } + + /*@} */ + /**@name Inquiry */ + /*@{ */ + + + /*@} */ + /**@name Friends */ + /*@{ */ + + /*@} */ + +private: + + /**@name Protected static Member Variables */ + /*@{ */ + + /*@} */ + /**@name Protected member Variables */ + /*@{ */ + + /*@} */ + /**@name Protected Operators*/ + /*@{ */ + + + /*@} */ + /**@name Protected Operations*/ + /*@{ */ + + /*@} */ + /**@name Protected Access */ + /*@{ */ + + /*@} */ + /**@name Protected Inquiry */ + /*@{ */ + + /*@} */ + /**@name Protected LifeCycle */ + /*@{ */ + + /*@} */ + +protected: + /**@name Static Member Variables */ + /*@{ */ + + /*@} */ + /**@name Member Variables */ + /*@{ */ + + typename TLinearSolver::Pointer mpLinearSolver; /// The pointer to the linear solver considered + typename TSchemeType::Pointer mpScheme; /// The pointer to the time scheme employed + typename TBuilderAndSolverType::Pointer mpBuilderAndSolver; /// The pointer to the builder and solver employed + typename TConvergenceCriteriaType::Pointer mpConvergenceCriteria; /// The pointer to the convergence criteria employed + + TSystemVectorPointerType mpDx; /// The incremement in the solution + TSystemVectorPointerType mpb; /// The RHS vector of the system of equations + TSystemMatrixPointerType mpA; /// The LHS matrix of the system of equations + + /** + * @brief Flag telling if it is needed to reform the DofSet at each + solution step or if it is possible to form it just once + * @details Default = false + - true : Reform at each time step + - false : Form just one (more efficient) + */ + bool mReformDofSetAtEachStep; + + // Flag telling if it is needed or not to compute the reactions + bool mCalculateReactionsFlag; + + // Flag to set as initialized the solution step + bool mSolutionStepIsInitialized; + + // The maximum number of iterations, 30 by default + unsigned int mMaxIterationNumber; + + // Flag to set as initialized the strategy + bool mInitializeWasPerformed; + + // Flag to allow keeping system matrix constant during iterations + bool mKeepSystemConstantDuringIterations; + + // Flag to allow to not finalize the solution step, so the historical variables are not updated + bool mFinalizeSolutionStep; + + /*@} */ + /**@name Private Operators*/ + /*@{ */ + + /** + * @brief Performs all the required operations that should be done (for each step) before solving the solution step. + * @details A member variable should be used as a flag to make sure this function is called only once per step. + */ + void InitializeSolutionStep() override + { + KRATOS_TRY; + + // Initialize solution step + if (mSolutionStepIsInitialized == false) + { + typename TBuilderAndSolverType::Pointer p_builder_and_solver = GetBuilderAndSolver(); + typename TSchemeType::Pointer p_scheme = GetScheme(); + + // Setting up the Vectors involved to the correct size + p_builder_and_solver->ResizeAndInitializeVectors(p_scheme, mpA, mpDx, mpb, BaseType::GetModelPart()); + + TSystemMatrixType& rA = *mpA; + TSystemVectorType& rDx = *mpDx; + TSystemVectorType& rb = *mpb; + + // Initial operations ... things that are constant over the Solution Step + p_builder_and_solver->InitializeSolutionStep(BaseType::GetModelPart(), rA, rDx, rb); + + // Initial operations ... things that are constant over the Solution Step + p_scheme->InitializeSolutionStep(BaseType::GetModelPart(), rA, rDx, rb); + + mSolutionStepIsInitialized = true; + } + + KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3) << "Initialize Solution Step in strategy finished" <CalculateReactions(p_scheme, BaseType::GetModelPart(), rA, rDx, rb); + } + + // Calling r_dof_set + DofsArrayType& r_dof_set = p_builder_and_solver->GetDofSet(); + + /* Finalization of the solution step, + * operations to be done after achieving convergence, for example the + * Final Residual Vector (rb) has to be saved in there to avoid error accumulation + */ + if( mFinalizeSolutionStep ) + { + KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3) << "Calling FinalizeSolutionStep" <FinalizeSolutionStep(BaseType::GetModelPart(), rA, rDx, rb); + p_builder_and_solver->FinalizeSolutionStep(BaseType::GetModelPart(), rA, rDx, rb); + mpConvergenceCriteria->FinalizeSolutionStep(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); + } + + // Cleaning memory after the solution + p_scheme->Clean(); + + // Reset flags for next step + mSolutionStepIsInitialized = false; + + if (mReformDofSetAtEachStep == true) //deallocate the systemvectors + { + SparseSpaceType::Clear(mpA); + SparseSpaceType::Clear(mpDx); + SparseSpaceType::Clear(mpb); + + this->Clear(); + } + + KRATOS_CATCH( "" ); + } + + /** + * @brief This method prints information after reach the max number of iterations + */ + void MaxIterationsExceeded() + { + KRATOS_WARNING("MPMNewtonRaphsonStrategy") << "***************************************************" << std::endl; + KRATOS_WARNING("MPMNewtonRaphsonStrategy") << "******* ATTENTION: max iterations exceeded ********" << std::endl; + KRATOS_WARNING("MPMNewtonRaphsonStrategy") << "***************************************************" << std::endl; + + } + + /** + * @brief Function to perform expensive checks. + * @details It is designed to be called ONCE to verify that the input is correct. + */ + int Check() override + { + KRATOS_TRY; + + BaseType::Check(); + GetBuilderAndSolver()->Check(BaseType::GetModelPart()); + GetScheme()->Check(BaseType::GetModelPart()); + mpConvergenceCriteria->Check(BaseType::GetModelPart()); + + return 0; + + KRATOS_CATCH( "" ); + } + + + /*@} */ + /**@name Private Operations*/ + /*@{ */ + + + /*@} */ + /**@name Private Access */ + /*@{ */ + + + /*@} */ + /**@name Private Inquiry */ + /*@{ */ + + + /*@} */ + /**@name Un accessible methods */ + /*@{ */ + + /** Copy constructor. + */ + MPMResidualBasedNewtonRaphsonStrategy(const MPMResidualBasedNewtonRaphsonStrategy& Other) + { + }; + + + /*@} */ + +}; /* Class MPMResidualBasedNewtonRaphsonStrategy */ + +/*@} */ + +/**@name Type Definitions */ +/*@{ */ + + +/*@} */ + +} /* namespace Kratos.*/ + +#endif /* KRATOS_MPM_RESIDUAL_BASED_NEWTON_RAPHSON_STRATEGY defined */ + diff --git a/applications/ParticleMechanicsApplication/python_scripts/mpm_solver.py b/applications/ParticleMechanicsApplication/python_scripts/mpm_solver.py index 55f35a0dab54..14093f112743 100644 --- a/applications/ParticleMechanicsApplication/python_scripts/mpm_solver.py +++ b/applications/ParticleMechanicsApplication/python_scripts/mpm_solver.py @@ -395,7 +395,7 @@ def _CreateNewtonRaphsonStrategy(self): convergence_criterion = self._GetConvergenceCriteria() builder_and_solver = self._GetBuilderAndSolver() reform_dofs_at_each_step = False ## hard-coded, but can be changed upon implementation - return KratosMultiphysics.ResidualBasedNewtonRaphsonStrategy(computing_model_part, + return KratosParticle.MPMResidualBasedNewtonRaphsonStrategy(computing_model_part, solution_scheme, linear_solver, convergence_criterion, From ca310c0ac61a1363fcbcee009355c9ca6fb91e2a Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Wed, 22 Apr 2020 11:08:44 +1000 Subject: [PATCH 191/314] derive from core NR and only override solvesolutionstep --- .../add_custom_strategies_to_python.cpp | 8 - ...residual_based_newton_raphson_strategy.hpp | 695 +----------------- 2 files changed, 37 insertions(+), 666 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp b/applications/ParticleMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp index b67d257db4d7..19aaa24b2fae 100644 --- a/applications/ParticleMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp +++ b/applications/ParticleMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp @@ -73,14 +73,6 @@ namespace Python{ py::class_< MPMResidualBasedNewtonRaphsonStrategyType,typename MPMResidualBasedNewtonRaphsonStrategyType::Pointer, BaseSolvingStrategyType >(m,"MPMResidualBasedNewtonRaphsonStrategy") .def(py::init< ModelPart&, BaseSchemeType::Pointer, LinearSolverType::Pointer, ConvergenceCriteriaType::Pointer, int, bool, bool, bool >() ) .def(py::init< ModelPart&, BaseSchemeType::Pointer, LinearSolverType::Pointer, ConvergenceCriteriaType::Pointer, BuilderAndSolverType::Pointer, int, bool, bool, bool >() ) - .def("SetMaxIterationNumber", &MPMResidualBasedNewtonRaphsonStrategyType::SetMaxIterationNumber) - .def("GetMaxIterationNumber", &MPMResidualBasedNewtonRaphsonStrategyType::GetMaxIterationNumber) - .def("SetInitializePerformedFlag", &MPMResidualBasedNewtonRaphsonStrategyType::SetInitializePerformedFlag) - .def("GetInitializePerformedFlag", &MPMResidualBasedNewtonRaphsonStrategyType::GetInitializePerformedFlag) - .def("SetKeepSystemConstantDuringIterations", &MPMResidualBasedNewtonRaphsonStrategyType::SetKeepSystemConstantDuringIterations) - .def("GetKeepSystemConstantDuringIterations", &MPMResidualBasedNewtonRaphsonStrategyType::GetKeepSystemConstantDuringIterations) - .def("SetFinalizeSolutionStepFlag", &MPMResidualBasedNewtonRaphsonStrategyType::SetFinalizeSolutionStepFlag) - .def("GetFinalizeSolutionStepFlag", &MPMResidualBasedNewtonRaphsonStrategyType::GetFinalizeSolutionStepFlag) ; } diff --git a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp index 87487ac93f91..f60db15b565c 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp @@ -18,15 +18,16 @@ /* System includes */ /* External includes */ +#include "solving_strategies/strategies/residualbased_newton_raphson_strategy.h" /* Project includes */ -#include "includes/define.h" -#include "includes/model_part.h" -#include "includes/kratos_flags.h" - -#include "solving_strategies/strategies/solving_strategy.h" -#include "solving_strategies/convergencecriterias/convergence_criteria.h" -#include "solving_strategies/builder_and_solvers/residualbased_elimination_builder_and_solver.h" +//#include "includes/define.h" +//#include "includes/model_part.h" +//#include "includes/kratos_flags.h" +// +// +//#include "solving_strategies/convergencecriterias/convergence_criteria.h" +//#include "solving_strategies/builder_and_solvers/residualbased_elimination_builder_and_solver.h" // Application includes #include "particle_mechanics_application_variables.h" @@ -72,7 +73,7 @@ template class MPMResidualBasedNewtonRaphsonStrategy - : public SolvingStrategy + : public ResidualBasedNewtonRaphsonStrategy { public: /**@name Type Definitions */ @@ -114,13 +115,15 @@ class MPMResidualBasedNewtonRaphsonStrategy /** Constructors. */ - MPMResidualBasedNewtonRaphsonStrategy( + + /*MPMResidualBasedNewtonRaphsonStrategy( ModelPart& rModelPart, bool MoveMeshFlag = false ) - : SolvingStrategy(rModelPart, MoveMeshFlag) + : ResidualBasedNewtonRaphsonStrategy( + rModelPart, MoveMeshFlag) { - } + }*/ MPMResidualBasedNewtonRaphsonStrategy( ModelPart& rModelPart, @@ -132,54 +135,10 @@ class MPMResidualBasedNewtonRaphsonStrategy bool ReformDofSetAtEachStep = false, bool MoveMeshFlag = false ) - : SolvingStrategy(rModelPart, MoveMeshFlag) + : ResidualBasedNewtonRaphsonStrategy( + rModelPart, pScheme, pNewLinearSolver, pNewConvergenceCriteria, + MaxIterations, CalculateReactions, ReformDofSetAtEachStep, MoveMeshFlag) { - KRATOS_TRY; - - mKeepSystemConstantDuringIterations = false; - - // Set flags to default values - SetMaxIterationNumber(MaxIterations); - - mCalculateReactionsFlag = CalculateReactions; - - mReformDofSetAtEachStep = ReformDofSetAtEachStep; - - // Saving the convergence criteria to be used - mpConvergenceCriteria = pNewConvergenceCriteria; - - // Saving the scheme - mpScheme = pScheme; - - // Saving the linear solver - mpLinearSolver = pNewLinearSolver; - - // Setting up the default builder and solver - mpBuilderAndSolver = typename TBuilderAndSolverType::Pointer - ( - new ResidualBasedEliminationBuilderAndSolver (mpLinearSolver) - ); - - // Set flags to start correcty the calculations - mSolutionStepIsInitialized = false; - - mInitializeWasPerformed = false; - - mFinalizeSolutionStep = true; - - // Tells to the Builder And Solver if the reactions have to be Calculated or not - GetBuilderAndSolver()->SetCalculateReactionsFlag(mCalculateReactionsFlag); - - // Tells to the Builder And Solver if the system matrix and vectors need to be reshaped at each step or not - GetBuilderAndSolver()->SetReshapeMatrixFlag(mReformDofSetAtEachStep); - - // Set EchoLevel to the default value (only time is displayed) - SetEchoLevel(1); - - // By default the matrices are rebuilt at each iteration - this->SetRebuildLevel(2); - - KRATOS_CATCH( "" ); } MPMResidualBasedNewtonRaphsonStrategy( @@ -193,50 +152,12 @@ class MPMResidualBasedNewtonRaphsonStrategy bool ReformDofSetAtEachStep = false, bool MoveMeshFlag = false ) - : SolvingStrategy(rModelPart, MoveMeshFlag) + : ResidualBasedNewtonRaphsonStrategy( + rModelPart, pScheme, pNewLinearSolver, + pNewConvergenceCriteria, pNewBuilderAndSolver, MaxIterations, + CalculateReactions, ReformDofSetAtEachStep, MoveMeshFlag) { - KRATOS_TRY; - - mKeepSystemConstantDuringIterations = false; - - // Set flags to default values - SetMaxIterationNumber(MaxIterations); - mCalculateReactionsFlag = CalculateReactions; - - mReformDofSetAtEachStep = ReformDofSetAtEachStep; - - // Saving the convergence criteria to be used - mpConvergenceCriteria = pNewConvergenceCriteria; - - // Saving the scheme - mpScheme = pScheme; - - // Saving the linear solver - mpLinearSolver = pNewLinearSolver; - - // Setting up the default builder and solver - mpBuilderAndSolver = pNewBuilderAndSolver; - - // Set flags to start correcty the calculations - mSolutionStepIsInitialized = false; - - mInitializeWasPerformed = false; - - mFinalizeSolutionStep = true; - - // Tells to the Builder And Solver if the reactions have to be Calculated or not - GetBuilderAndSolver()->SetCalculateReactionsFlag(mCalculateReactionsFlag); - - // Tells to the Builder And Solver if the system matrix and vectors need to be reshaped at each step or not - GetBuilderAndSolver()->SetReshapeMatrixFlag(mReformDofSetAtEachStep); - - // Set EchoLevel to the default value (only time is displayed) - SetEchoLevel(1); - - // By default the matrices are rebuilt at each iteration - this->SetRebuildLevel(2); - - KRATOS_CATCH( "" ); + } /** Destructor. @@ -245,193 +166,7 @@ class MPMResidualBasedNewtonRaphsonStrategy { } - /** Destructor. - */ - - // Set and Get Scheme ... containing Builder, Update and other - - void SetScheme(typename TSchemeType::Pointer pScheme) - { - mpScheme = pScheme; - }; - - typename TSchemeType::Pointer GetScheme() - { - return mpScheme; - }; - - void SetBuilderAndSolver(typename TBuilderAndSolverType::Pointer pNewBuilderAndSolver) - { - mpBuilderAndSolver = pNewBuilderAndSolver; - }; - - typename TBuilderAndSolverType::Pointer GetBuilderAndSolver() - { - return mpBuilderAndSolver; - }; - - void SetInitializePerformedFlag(bool InitializePerformedFlag = true) - { - mInitializeWasPerformed = InitializePerformedFlag; - } - - bool GetInitializePerformedFlag() - { - return mInitializeWasPerformed; - } - - void SetCalculateReactionsFlag(bool CalculateReactionsFlag) - { - mCalculateReactionsFlag = CalculateReactionsFlag; - } - - bool GetCalculateReactionsFlag() - { - return mCalculateReactionsFlag; - } - - void SetReformDofSetAtEachStepFlag(bool flag) - { - mReformDofSetAtEachStep = flag; - GetBuilderAndSolver()->SetReshapeMatrixFlag(mReformDofSetAtEachStep); - } - - bool GetReformDofSetAtEachStepFlag() - { - return mReformDofSetAtEachStep; - } - - void SetMaxIterationNumber(unsigned int MaxIterationNumber) - { - mMaxIterationNumber = MaxIterationNumber; - } - - unsigned int GetMaxIterationNumber() - { - return mMaxIterationNumber; - } - - void SetFinalizeSolutionStepFlag(bool FinalizeSolutionStepFlag = true) - { - mFinalizeSolutionStep = FinalizeSolutionStepFlag; - } - - bool GetFinalizeSolutionStepFlag() - { - return mFinalizeSolutionStep; - } - - /** - * @brief It sets the level of echo for the solving strategy - * @param Level The level to set - * @details The different levels of echo are: - * - 0: Mute... no echo at all - * - 1: Printing time and basic informations - * - 2: Printing linear solver data - * - 3: Print of debug informations: Echo of stiffness matrix, Dx, b... - */ - void SetEchoLevel(int Level) override - { - BaseType::mEchoLevel = Level; - GetBuilderAndSolver()->SetEchoLevel(Level); - mpConvergenceCriteria->SetEchoLevel(Level); - } - - //********************************************************************************* - /**OPERATIONS ACCESSIBLE FROM THE INPUT:*/ - - /** - * @brief Operation to predict the solution ... if it is not called a trivial predictor is used in which the - values of the solution step of interest are assumed equal to the old values - */ - void Predict() override - { - KRATOS_TRY; - // OPERATIONS THAT SHOULD BE DONE ONCE - internal check to avoid repetitions - // If the operations needed were already performed this does nothing - if (mInitializeWasPerformed == false) - Initialize(); - - // Initialize solution step - if (mSolutionStepIsInitialized == false) - InitializeSolutionStep(); - - DofsArrayType& r_dof_set = GetBuilderAndSolver()->GetDofSet(); - - TSystemMatrixType& rA = *mpA; - TSystemVectorType& rDx = *mpDx; - TSystemVectorType& rb = *mpb; - - GetScheme()->Predict(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); - - // Move the mesh if needed - if (this->MoveMeshFlag() == true) BaseType::MoveMesh(); - - KRATOS_CATCH( "" ); - } - - /** - * @brief Initialization of member variables and prior operations - */ - void Initialize() override - { - KRATOS_TRY; - - typename TSchemeType::Pointer p_scheme = GetScheme(); - typename TBuilderAndSolverType::Pointer p_builder_and_solver = GetBuilderAndSolver(); - - // OPERATIONS THAT SHOULD BE DONE ONCE - internal check to avoid repetitions - // if the operations needed were already performed this does nothing - if (mInitializeWasPerformed == false) - { - KRATOS_INFO_IF("MPMNewtonRaphsonStrategy",this->GetEchoLevel() >1) << "Initializing solving strategy" << std::endl; - KRATOS_ERROR_IF(mInitializeWasPerformed == true) << "Initialization was already performed " << mInitializeWasPerformed << std::endl; - - // Initialize The Scheme - OPERATIONS TO BE DONE ONCE - KRATOS_INFO_IF("MPMNewtonRaphsonStrategy",this->GetEchoLevel() >1) << "Initializing scheme" << std::endl; - if (p_scheme->SchemeIsInitialized() == false) - p_scheme->Initialize(BaseType::GetModelPart()); - - // Initialize The Elements - OPERATIONS TO BE DONE ONCE - KRATOS_INFO_IF("MPMNewtonRaphsonStrategy",this->GetEchoLevel() >1) << "Initializing elements" << std::endl; - if (p_scheme->ElementsAreInitialized() == false) - p_scheme->InitializeElements(BaseType::GetModelPart()); - - // Initialize The Conditions - OPERATIONS TO BE DONE ONCE - KRATOS_INFO_IF("MPMNewtonRaphsonStrategy",this->GetEchoLevel() >1) << "Initializing conditions" << std::endl; - if (p_scheme->ConditionsAreInitialized() == false) - p_scheme->InitializeConditions(BaseType::GetModelPart()); - - // Initialisation of the convergence criteria - typename TConvergenceCriteriaType::Pointer p_convergence_criteria = mpConvergenceCriteria; - KRATOS_INFO_IF("MPMNewtonRaphsonStrategy",this->GetEchoLevel() >1) << "Initializing convergence criteria"<IsInitialized() == false) - p_convergence_criteria->Initialize(BaseType::GetModelPart()); - - mInitializeWasPerformed = true; - } - - // Set up the system, operation performed just once unless it is required to reform the dof set at each iteration - if (p_builder_and_solver->GetDofSetIsInitializedFlag() == false || - mReformDofSetAtEachStep == true) - { - // Setting up the list of the DOFs to be solved - p_builder_and_solver->SetUpDofSet(p_scheme, BaseType::GetModelPart()); - - // Shaping correctly the system - p_builder_and_solver->SetUpSystem(BaseType::GetModelPart()); - - } - - // Prints informations about the current time - if (this->GetEchoLevel() == 2 && BaseType::GetModelPart().GetCommunicator().MyPID() == 0 ) - { - KRATOS_INFO("MPMNewtonRaphsonStrategy") << "CurrentTime = " << BaseType::GetModelPart().GetProcessInfo()[TIME] << std::endl; - } - - KRATOS_CATCH( "" ); - } - + /** * @brief Solves the current step. This function returns true if a solution has been found, false otherwise. */ @@ -454,18 +189,18 @@ class MPMResidualBasedNewtonRaphsonStrategy is_converged = mpConvergenceCriteria->PreCriteria(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3) << "PreCriteria:" - << "\tIs_converged: " << is_converged << "\tmRebuildLevel: " << BaseType::mRebuildLevel + << "\tIs_converged: " << is_converged << "\tmRebuildLevel: " << BaseType::mRebuildLevel << "\tmStiffnessMatrixIsBuilt: " << BaseType::mStiffnessMatrixIsBuilt << std::endl; if (BaseType::mRebuildLevel > 1 || BaseType::mStiffnessMatrixIsBuilt == false) { - KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3) << "SetToZero the matrix and vectors of the system"<GetEchoLevel() >= 3) << "SetToZero the matrix and vectors of the system" << std::endl; TSparseSpace::SetToZero(rA); TSparseSpace::SetToZero(rDx); TSparseSpace::SetToZero(rb); - KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3) << "Build and Solve"<GetEchoLevel() >= 3) << "Build and Solve" << std::endl; p_builder_and_solver->BuildAndSolve(p_scheme, BaseType::GetModelPart(), rA, rDx, rb); } @@ -475,7 +210,7 @@ class MPMResidualBasedNewtonRaphsonStrategy TSparseSpace::SetToZero(rb); p_builder_and_solver->BuildRHSAndSolve(p_scheme, BaseType::GetModelPart(), rA, rDx, rb); - KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3) << "BuildRHSAndSolve"<GetEchoLevel() >= 3) << "BuildRHSAndSolve" << std::endl; } @@ -489,11 +224,11 @@ class MPMResidualBasedNewtonRaphsonStrategy { std::stringstream matrix_market_name; matrix_market_name << "A_" << BaseType::GetModelPart().GetProcessInfo()[TIME] << "_" << iteration_number << ".mm"; - TSparseSpace::WriteMatrixMarketMatrix((char*) (matrix_market_name.str()).c_str(), rA, false); + TSparseSpace::WriteMatrixMarketMatrix((char*)(matrix_market_name.str()).c_str(), rA, false); std::stringstream matrix_market_vectname; matrix_market_vectname << "b_" << BaseType::GetModelPart().GetProcessInfo()[TIME] << "_" << iteration_number << ".mm.rhs"; - TSparseSpace::WriteMatrixMarketVector((char*) (matrix_market_vectname.str()).c_str(), rb); + TSparseSpace::WriteMatrixMarketVector((char*)(matrix_market_vectname.str()).c_str(), rb); } // Update results @@ -518,11 +253,11 @@ class MPMResidualBasedNewtonRaphsonStrategy is_converged = mpConvergenceCriteria->PostCriteria(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); } - KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3 && !is_converged) << "Starting Nonlinear iteration"<GetEchoLevel() >= 3 && !is_converged) << "Starting Nonlinear iteration" << std::endl; // Iteration Loop while (is_converged == false && - iteration_number++ 1 || BaseType::mStiffnessMatrixIsBuilt == false ) + if (BaseType::mRebuildLevel > 1 || BaseType::mStiffnessMatrixIsBuilt == false) { - KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3) << "Iteration Number: " << iteration_number <GetEchoLevel() >= 3) << "Iteration Number: " << iteration_number << std::endl; - if( GetKeepSystemConstantDuringIterations() == false) + if (GetKeepSystemConstantDuringIterations() == false) { TSparseSpace::SetToZero(rA); TSparseSpace::SetToZero(rDx); TSparseSpace::SetToZero(rb); - KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3) << "Build and Solve"<GetEchoLevel() >= 3) << "Build and Solve" << std::endl; p_builder_and_solver->BuildAndSolve(p_scheme, BaseType::GetModelPart(), rA, rDx, rb); } else @@ -552,7 +287,7 @@ class MPMResidualBasedNewtonRaphsonStrategy TSparseSpace::SetToZero(rDx); TSparseSpace::SetToZero(rb); - KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3) << "Build RHS and Solve" <GetEchoLevel() >= 3) << "Build RHS and Solve" << std::endl; p_builder_and_solver->BuildRHSAndSolve(p_scheme, BaseType::GetModelPart(), rA, rDx, rb); } } @@ -561,7 +296,7 @@ class MPMResidualBasedNewtonRaphsonStrategy TSparseSpace::SetToZero(rDx); TSparseSpace::SetToZero(rb); - KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3) << "Build RHS and Solve" <GetEchoLevel() >= 3) << "Build RHS and Solve" << std::endl; p_builder_and_solver->BuildRHSAndSolve(p_scheme, BaseType::GetModelPart(), rA, rDx, rb); } } @@ -595,7 +330,6 @@ class MPMResidualBasedNewtonRaphsonStrategy } } - // Plot a warning if the maximum number of iterations is exceeded if (iteration_number >= mMaxIterationNumber && BaseType::GetModelPart().GetCommunicator().MyPID() == 0) { @@ -606,363 +340,8 @@ class MPMResidualBasedNewtonRaphsonStrategy return true; } - /** - * @brief This should be considered as a "post solution" convergence check which is useful for coupled analysis - the convergence criteria used is the one used inside the "solve" step - */ - bool IsConverged() override - { - KRATOS_TRY; - - TSystemMatrixType& rA = *mpA; - TSystemVectorType& rDx = *mpDx; - TSystemVectorType& rb = *mpb; - - if (mpConvergenceCriteria->GetActualizeRHSflag() == true) - { - GetBuilderAndSolver()->BuildRHS(GetScheme(), BaseType::GetModelPart(), rb); - } - - DofsArrayType& r_dof_set = GetBuilderAndSolver()->GetDofSet(); - - return mpConvergenceCriteria->PostCriteria(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); - KRATOS_CATCH( "" ); - - } - - /** - * @brief This operations should be called before printing the results when non trivial results - * (e.g. stresses) - * Need to be calculated given the solution of the step - * @details This operations should be called only when needed, before printing as it can involve a non - * negligible cost - */ - void CalculateOutputData() override - { - TSystemMatrixType& rA = *mpA; - TSystemVectorType& rDx = *mpDx; - TSystemVectorType& rb = *mpb; - - DofsArrayType& r_dof_set = GetBuilderAndSolver()->GetDofSet(); - GetScheme()->CalculateOutputData(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); - } - - /** - * @brief Clears the internal storage - */ - void Clear() override - { - KRATOS_TRY; - - SparseSpaceType::Clear(mpA); - TSystemMatrixType& rA = *mpA; - SparseSpaceType::Resize(rA, 0, 0); - - SparseSpaceType::Clear(mpDx); - TSystemVectorType& rDx = *mpDx; - SparseSpaceType::Resize(rDx, 0); - - SparseSpaceType::Clear(mpb); - TSystemVectorType& rb = *mpb; - SparseSpaceType::Resize(rb, 0); - - // Setting to zero the internal flag to ensure that the dof sets are recalculated - GetBuilderAndSolver()->SetDofSetIsInitializedFlag(false); - GetBuilderAndSolver()->Clear(); - GetScheme()->Clear(); - - KRATOS_CATCH( "" ); - } - - /*@} */ - /**@name Operators - */ - /*@{ */ - - /*@} */ - /**@name Operations */ - /*@{ */ - - - /*@} */ - /**@name Access */ - /*@{ */ - - /** - * @brief This method returns the LHS matrix - * @return The LHS matrix - */ - TSystemMatrixType& GetSystemMatrix() - { - TSystemMatrixType& rA = *mpA; - return rA; - } - - /** - * @brief Set method for the flag mKeepSystemConstantDuringIterations - * @param Value If we consider constant the system of equations during the iterations - */ - void SetKeepSystemConstantDuringIterations(bool value) - { - mKeepSystemConstantDuringIterations = value; - } - - /** - * @brief Get method for the flag mKeepSystemConstantDuringIterations - * @return True if we consider constant the system of equations during the iterations, false otherwise - */ - bool GetKeepSystemConstantDuringIterations() - { - return mKeepSystemConstantDuringIterations; - } - - /*@} */ - /**@name Inquiry */ - /*@{ */ - - - /*@} */ - /**@name Friends */ - /*@{ */ - - /*@} */ - -private: - - /**@name Protected static Member Variables */ - /*@{ */ - - /*@} */ - /**@name Protected member Variables */ - /*@{ */ - - /*@} */ - /**@name Protected Operators*/ - /*@{ */ - - - /*@} */ - /**@name Protected Operations*/ - /*@{ */ - - /*@} */ - /**@name Protected Access */ - /*@{ */ - - /*@} */ - /**@name Protected Inquiry */ - /*@{ */ - - /*@} */ - /**@name Protected LifeCycle */ - /*@{ */ - - /*@} */ - -protected: - /**@name Static Member Variables */ - /*@{ */ - - /*@} */ - /**@name Member Variables */ - /*@{ */ - - typename TLinearSolver::Pointer mpLinearSolver; /// The pointer to the linear solver considered - typename TSchemeType::Pointer mpScheme; /// The pointer to the time scheme employed - typename TBuilderAndSolverType::Pointer mpBuilderAndSolver; /// The pointer to the builder and solver employed - typename TConvergenceCriteriaType::Pointer mpConvergenceCriteria; /// The pointer to the convergence criteria employed - - TSystemVectorPointerType mpDx; /// The incremement in the solution - TSystemVectorPointerType mpb; /// The RHS vector of the system of equations - TSystemMatrixPointerType mpA; /// The LHS matrix of the system of equations - - /** - * @brief Flag telling if it is needed to reform the DofSet at each - solution step or if it is possible to form it just once - * @details Default = false - - true : Reform at each time step - - false : Form just one (more efficient) - */ - bool mReformDofSetAtEachStep; - - // Flag telling if it is needed or not to compute the reactions - bool mCalculateReactionsFlag; - - // Flag to set as initialized the solution step - bool mSolutionStepIsInitialized; - - // The maximum number of iterations, 30 by default - unsigned int mMaxIterationNumber; - - // Flag to set as initialized the strategy - bool mInitializeWasPerformed; - - // Flag to allow keeping system matrix constant during iterations - bool mKeepSystemConstantDuringIterations; - - // Flag to allow to not finalize the solution step, so the historical variables are not updated - bool mFinalizeSolutionStep; - - /*@} */ - /**@name Private Operators*/ - /*@{ */ - - /** - * @brief Performs all the required operations that should be done (for each step) before solving the solution step. - * @details A member variable should be used as a flag to make sure this function is called only once per step. - */ - void InitializeSolutionStep() override - { - KRATOS_TRY; - - // Initialize solution step - if (mSolutionStepIsInitialized == false) - { - typename TBuilderAndSolverType::Pointer p_builder_and_solver = GetBuilderAndSolver(); - typename TSchemeType::Pointer p_scheme = GetScheme(); - - // Setting up the Vectors involved to the correct size - p_builder_and_solver->ResizeAndInitializeVectors(p_scheme, mpA, mpDx, mpb, BaseType::GetModelPart()); - - TSystemMatrixType& rA = *mpA; - TSystemVectorType& rDx = *mpDx; - TSystemVectorType& rb = *mpb; - - // Initial operations ... things that are constant over the Solution Step - p_builder_and_solver->InitializeSolutionStep(BaseType::GetModelPart(), rA, rDx, rb); - - // Initial operations ... things that are constant over the Solution Step - p_scheme->InitializeSolutionStep(BaseType::GetModelPart(), rA, rDx, rb); - - mSolutionStepIsInitialized = true; - } - - KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3) << "Initialize Solution Step in strategy finished" <CalculateReactions(p_scheme, BaseType::GetModelPart(), rA, rDx, rb); - } - - // Calling r_dof_set - DofsArrayType& r_dof_set = p_builder_and_solver->GetDofSet(); - - /* Finalization of the solution step, - * operations to be done after achieving convergence, for example the - * Final Residual Vector (rb) has to be saved in there to avoid error accumulation - */ - if( mFinalizeSolutionStep ) - { - KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3) << "Calling FinalizeSolutionStep" <FinalizeSolutionStep(BaseType::GetModelPart(), rA, rDx, rb); - p_builder_and_solver->FinalizeSolutionStep(BaseType::GetModelPart(), rA, rDx, rb); - mpConvergenceCriteria->FinalizeSolutionStep(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); - } - - // Cleaning memory after the solution - p_scheme->Clean(); - - // Reset flags for next step - mSolutionStepIsInitialized = false; - - if (mReformDofSetAtEachStep == true) //deallocate the systemvectors - { - SparseSpaceType::Clear(mpA); - SparseSpaceType::Clear(mpDx); - SparseSpaceType::Clear(mpb); - - this->Clear(); - } - - KRATOS_CATCH( "" ); - } - - /** - * @brief This method prints information after reach the max number of iterations - */ - void MaxIterationsExceeded() - { - KRATOS_WARNING("MPMNewtonRaphsonStrategy") << "***************************************************" << std::endl; - KRATOS_WARNING("MPMNewtonRaphsonStrategy") << "******* ATTENTION: max iterations exceeded ********" << std::endl; - KRATOS_WARNING("MPMNewtonRaphsonStrategy") << "***************************************************" << std::endl; - - } - - /** - * @brief Function to perform expensive checks. - * @details It is designed to be called ONCE to verify that the input is correct. - */ - int Check() override - { - KRATOS_TRY; - - BaseType::Check(); - GetBuilderAndSolver()->Check(BaseType::GetModelPart()); - GetScheme()->Check(BaseType::GetModelPart()); - mpConvergenceCriteria->Check(BaseType::GetModelPart()); - - return 0; - - KRATOS_CATCH( "" ); - } - - - /*@} */ - /**@name Private Operations*/ - /*@{ */ - - - /*@} */ - /**@name Private Access */ - /*@{ */ - - - /*@} */ - /**@name Private Inquiry */ - /*@{ */ - - - /*@} */ - /**@name Un accessible methods */ - /*@{ */ - - /** Copy constructor. - */ - MPMResidualBasedNewtonRaphsonStrategy(const MPMResidualBasedNewtonRaphsonStrategy& Other) - { - }; - - - /*@} */ - }; /* Class MPMResidualBasedNewtonRaphsonStrategy */ -/*@} */ - -/**@name Type Definitions */ -/*@{ */ - - -/*@} */ - } /* namespace Kratos.*/ #endif /* KRATOS_MPM_RESIDUAL_BASED_NEWTON_RAPHSON_STRATEGY defined */ From d46cca51daed1d07c7508893bdb340c8f2e0e604 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Wed, 22 Apr 2020 11:26:02 +1000 Subject: [PATCH 192/314] cleanup --- .../mpm_residual_based_newton_raphson_strategy.hpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp index f60db15b565c..a2be3be4abfa 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp @@ -116,14 +116,14 @@ class MPMResidualBasedNewtonRaphsonStrategy /** Constructors. */ - /*MPMResidualBasedNewtonRaphsonStrategy( + MPMResidualBasedNewtonRaphsonStrategy( ModelPart& rModelPart, bool MoveMeshFlag = false ) : ResidualBasedNewtonRaphsonStrategy( rModelPart, MoveMeshFlag) { - }*/ + } MPMResidualBasedNewtonRaphsonStrategy( ModelPart& rModelPart, @@ -165,7 +165,6 @@ class MPMResidualBasedNewtonRaphsonStrategy virtual ~MPMResidualBasedNewtonRaphsonStrategy() { } - /** * @brief Solves the current step. This function returns true if a solution has been found, false otherwise. @@ -261,9 +260,7 @@ class MPMResidualBasedNewtonRaphsonStrategy { // Setting the number of iteration BaseType::GetModelPart().GetProcessInfo()[NL_ITERATION_NUMBER] = iteration_number; - p_scheme->InitializeNonLinIteration(BaseType::GetModelPart(), rA, rDx, rb); - is_converged = mpConvergenceCriteria->PreCriteria(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); // Call the linear system solver to find the correction rDx. It is not called if there is no system to solve @@ -309,7 +306,6 @@ class MPMResidualBasedNewtonRaphsonStrategy r_dof_set = p_builder_and_solver->GetDofSet(); p_scheme->Update(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); - p_scheme->FinalizeNonLinIteration(BaseType::GetModelPart(), rA, rDx, rb); // Move the mesh if needed From 5ec4859eaec1f10bb52d3b0988c388ee1d6b1781 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Wed, 22 Apr 2020 11:29:50 +1000 Subject: [PATCH 193/314] more cleanup --- ...residual_based_newton_raphson_strategy.hpp | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp index a2be3be4abfa..307baf0eb884 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp @@ -20,15 +20,6 @@ /* External includes */ #include "solving_strategies/strategies/residualbased_newton_raphson_strategy.h" -/* Project includes */ -//#include "includes/define.h" -//#include "includes/model_part.h" -//#include "includes/kratos_flags.h" -// -// -//#include "solving_strategies/convergencecriterias/convergence_criteria.h" -//#include "solving_strategies/builder_and_solvers/residualbased_elimination_builder_and_solver.h" - // Application includes #include "particle_mechanics_application_variables.h" @@ -119,8 +110,7 @@ class MPMResidualBasedNewtonRaphsonStrategy MPMResidualBasedNewtonRaphsonStrategy( ModelPart& rModelPart, bool MoveMeshFlag = false - ) - : ResidualBasedNewtonRaphsonStrategy( + ) : ResidualBasedNewtonRaphsonStrategy( rModelPart, MoveMeshFlag) { } @@ -134,8 +124,7 @@ class MPMResidualBasedNewtonRaphsonStrategy bool CalculateReactions = false, bool ReformDofSetAtEachStep = false, bool MoveMeshFlag = false - ) - : ResidualBasedNewtonRaphsonStrategy( + ) : ResidualBasedNewtonRaphsonStrategy( rModelPart, pScheme, pNewLinearSolver, pNewConvergenceCriteria, MaxIterations, CalculateReactions, ReformDofSetAtEachStep, MoveMeshFlag) { @@ -151,13 +140,11 @@ class MPMResidualBasedNewtonRaphsonStrategy bool CalculateReactions = false, bool ReformDofSetAtEachStep = false, bool MoveMeshFlag = false - ) - : ResidualBasedNewtonRaphsonStrategy( + ) : ResidualBasedNewtonRaphsonStrategy( rModelPart, pScheme, pNewLinearSolver, pNewConvergenceCriteria, pNewBuilderAndSolver, MaxIterations, CalculateReactions, ReformDofSetAtEachStep, MoveMeshFlag) { - } /** Destructor. From d5deda95ba430f1cb8443399e9c9fd1dbbdb9c73 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Wed, 22 Apr 2020 12:40:08 +1000 Subject: [PATCH 194/314] fix up linux compilation --- ...residual_based_newton_raphson_strategy.hpp | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp index 307baf0eb884..0d58fbc89317 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp @@ -158,12 +158,12 @@ class MPMResidualBasedNewtonRaphsonStrategy */ bool SolveSolutionStep() override { - typename TSchemeType::Pointer p_scheme = GetScheme(); - typename TBuilderAndSolverType::Pointer p_builder_and_solver = GetBuilderAndSolver(); - - TSystemMatrixType& rA = *mpA; - TSystemVectorType& rDx = *mpDx; - TSystemVectorType& rb = *mpb; + typename TSchemeType::Pointer p_scheme = ResidualBasedNewtonRaphsonStrategy::GetScheme(); + typename TBuilderAndSolverType::Pointer p_builder_and_solver = ResidualBasedNewtonRaphsonStrategy::GetBuilderAndSolver(); + + TSystemMatrixType& rA = *(this->mpA); + TSystemVectorType& rDx = *(this->mpDx); + TSystemVectorType& rb = *(this->mpb); DofsArrayType& r_dof_set = p_builder_and_solver->GetDofSet(); // Initializing the parameters of the Newton-Raphson cycle @@ -172,7 +172,7 @@ class MPMResidualBasedNewtonRaphsonStrategy bool is_converged = false; p_scheme->InitializeNonLinIteration(BaseType::GetModelPart(), rA, rDx, rb); - is_converged = mpConvergenceCriteria->PreCriteria(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); + is_converged = this->mpConvergenceCriteria->PreCriteria(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3) << "PreCriteria:" << "\tIs_converged: " << is_converged << "\tmRebuildLevel: " << BaseType::mRebuildLevel @@ -229,26 +229,26 @@ class MPMResidualBasedNewtonRaphsonStrategy { // Initialisation of the convergence criteria r_dof_set = p_builder_and_solver->GetDofSet(); - mpConvergenceCriteria->InitializeSolutionStep(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); + this->mpConvergenceCriteria->InitializeSolutionStep(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); - if (mpConvergenceCriteria->GetActualizeRHSflag() == true) + if (this->mpConvergenceCriteria->GetActualizeRHSflag() == true) { TSparseSpace::SetToZero(rb); p_builder_and_solver->BuildRHS(p_scheme, BaseType::GetModelPart(), rb); } - is_converged = mpConvergenceCriteria->PostCriteria(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); + is_converged = this->mpConvergenceCriteria->PostCriteria(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); } KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3 && !is_converged) << "Starting Nonlinear iteration" << std::endl; // Iteration Loop while (is_converged == false && - iteration_number++ < mMaxIterationNumber) + iteration_number++ < this->mMaxIterationNumber) { // Setting the number of iteration BaseType::GetModelPart().GetProcessInfo()[NL_ITERATION_NUMBER] = iteration_number; p_scheme->InitializeNonLinIteration(BaseType::GetModelPart(), rA, rDx, rb); - is_converged = mpConvergenceCriteria->PreCriteria(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); + is_converged = this->mpConvergenceCriteria->PreCriteria(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); // Call the linear system solver to find the correction rDx. It is not called if there is no system to solve if (SparseSpaceType::Size(rDx) != 0) @@ -257,7 +257,7 @@ class MPMResidualBasedNewtonRaphsonStrategy { KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3) << "Iteration Number: " << iteration_number << std::endl; - if (GetKeepSystemConstantDuringIterations() == false) + if (ResidualBasedNewtonRaphsonStrategy::GetKeepSystemConstantDuringIterations() == false) { TSparseSpace::SetToZero(rA); TSparseSpace::SetToZero(rDx); @@ -301,7 +301,7 @@ class MPMResidualBasedNewtonRaphsonStrategy // If converged if (is_converged == true) { - if (mpConvergenceCriteria->GetActualizeRHSflag() == true) + if (this->mpConvergenceCriteria->GetActualizeRHSflag() == true) { TSparseSpace::SetToZero(rb); @@ -309,15 +309,15 @@ class MPMResidualBasedNewtonRaphsonStrategy } - is_converged = mpConvergenceCriteria->PostCriteria(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); + is_converged = this->mpConvergenceCriteria->PostCriteria(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); } } // Plot a warning if the maximum number of iterations is exceeded - if (iteration_number >= mMaxIterationNumber && BaseType::GetModelPart().GetCommunicator().MyPID() == 0) + if (iteration_number >= this->mMaxIterationNumber && BaseType::GetModelPart().GetCommunicator().MyPID() == 0) { if (this->GetEchoLevel() > 1) - MaxIterationsExceeded(); + ResidualBasedNewtonRaphsonStrategy::MaxIterationsExceeded(); } return true; From 2485faa898ff044938e3da210d3e93fb8044a94d Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Wed, 22 Apr 2020 13:22:15 +1000 Subject: [PATCH 195/314] more linux fixes --- .../mpm_residual_based_newton_raphson_strategy.hpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp index 0d58fbc89317..0f264ccf0b2b 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp @@ -158,8 +158,8 @@ class MPMResidualBasedNewtonRaphsonStrategy */ bool SolveSolutionStep() override { - typename TSchemeType::Pointer p_scheme = ResidualBasedNewtonRaphsonStrategy::GetScheme(); - typename TBuilderAndSolverType::Pointer p_builder_and_solver = ResidualBasedNewtonRaphsonStrategy::GetBuilderAndSolver(); + typename TSchemeType::Pointer p_scheme = this->GetScheme(); + typename TBuilderAndSolverType::Pointer p_builder_and_solver = this->GetBuilderAndSolver(); TSystemMatrixType& rA = *(this->mpA); TSystemVectorType& rDx = *(this->mpDx); @@ -257,7 +257,7 @@ class MPMResidualBasedNewtonRaphsonStrategy { KRATOS_INFO_IF("MPMNewtonRaphsonStrategy", this->GetEchoLevel() >= 3) << "Iteration Number: " << iteration_number << std::endl; - if (ResidualBasedNewtonRaphsonStrategy::GetKeepSystemConstantDuringIterations() == false) + if (this->GetKeepSystemConstantDuringIterations() == false) { TSparseSpace::SetToZero(rA); TSparseSpace::SetToZero(rDx); @@ -316,8 +316,7 @@ class MPMResidualBasedNewtonRaphsonStrategy // Plot a warning if the maximum number of iterations is exceeded if (iteration_number >= this->mMaxIterationNumber && BaseType::GetModelPart().GetCommunicator().MyPID() == 0) { - if (this->GetEchoLevel() > 1) - ResidualBasedNewtonRaphsonStrategy::MaxIterationsExceeded(); + if (this->GetEchoLevel() > 1) this->MaxIterationsExceeded(); } return true; From 68f646e673f6a6a1ffd48d28ddb768c86e8d7918 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Thu, 23 Apr 2020 10:09:25 +1000 Subject: [PATCH 196/314] return actual convergence bool --- .../strategies/mpm_residual_based_newton_raphson_strategy.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp index 0f264ccf0b2b..39a13c0e0be3 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_residual_based_newton_raphson_strategy.hpp @@ -228,7 +228,6 @@ class MPMResidualBasedNewtonRaphsonStrategy if (is_converged == true) { // Initialisation of the convergence criteria - r_dof_set = p_builder_and_solver->GetDofSet(); this->mpConvergenceCriteria->InitializeSolutionStep(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); if (this->mpConvergenceCriteria->GetActualizeRHSflag() == true) @@ -319,7 +318,7 @@ class MPMResidualBasedNewtonRaphsonStrategy if (this->GetEchoLevel() > 1) this->MaxIterationsExceeded(); } - return true; + return is_converged; } }; /* Class MPMResidualBasedNewtonRaphsonStrategy */ From e57e2fbaa3eae3f788bb3296db857dccbd1deb92 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Thu, 23 Apr 2020 11:13:10 +1000 Subject: [PATCH 197/314] change explicit solver py to lowercase --- .../python_scripts/mpm_explicit_solver.py | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py b/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py index 5144e2c4587a..f2b9fb83f34c 100644 --- a/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py +++ b/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py @@ -24,8 +24,8 @@ def __init__(self, model, custom_settings): def GetDefaultSettings(cls): this_defaults = KratosMultiphysics.Parameters("""{ "time_integration_method" : "explicit", - "scheme_type" : "forward_euler", - "stress_update" : "USL" + "scheme_type" : "central_difference", + "stress_update" : "usf" }""") this_defaults.AddMissingParameters(super(MPMExplicitSolver, cls).GetDefaultSettings()) return this_defaults @@ -52,27 +52,27 @@ def _CreateSolutionScheme(self): block_size += 1 # Check whether compressibility is considered - isCompressible = self.settings["compressible"].GetBool() - grid_model_part.ProcessInfo.SetValue(KratosParticle.IS_COMPRESSIBLE, isCompressible) + is_compressible = self.settings["compressible"].GetBool() + grid_model_part.ProcessInfo.SetValue(KratosParticle.IS_COMPRESSIBLE, is_compressible) # Setting the time integration schemes scheme_type = self.settings["scheme_type"].GetString() - if(scheme_type == "forward_euler" or scheme_type == "Forward_Euler"): - StressUpdateOption = 10 + if(scheme_type == "forward_euler"): + stress_update_option = 10 stress_update = self.settings["stress_update"].GetString() #0 = USF, 1 = USL, 2 = MUSL - if(stress_update == "USF" or stress_update == "usf"): - StressUpdateOption = 0 - elif(stress_update == "USL" or stress_update == "usl"): - StressUpdateOption = 1 - elif(stress_update == "MUSL" or stress_update == "musl"): - StressUpdateOption = 2 + if(stress_update == "usf"): + stress_update_option = 0 + elif(stress_update == "usl"): + stress_update_option = 1 + elif(stress_update == "musl"): + stress_update_option = 2 else: err_msg = "The requested stress update \"" + stress_update + "\" is not available!\n" - err_msg += "Available options are: \"USF\", \"USL\",\"MUSL\"" - grid_model_part.ProcessInfo.SetValue(KratosParticle.EXPLICIT_STRESS_UPDATE_OPTION, StressUpdateOption) + err_msg += "Available options are: \"usf\", \"usl\",\"musl\"" + grid_model_part.ProcessInfo.SetValue(KratosParticle.EXPLICIT_STRESS_UPDATE_OPTION, stress_update_option) grid_model_part.ProcessInfo.SetValue(KratosParticle.IS_EXPLICIT_CENTRAL_DIFFERENCE, False) - elif(scheme_type == "central_difference" or scheme_type == "Central_Difference"): + elif(scheme_type == "central_difference"): grid_model_part.ProcessInfo.SetValue(KratosParticle.EXPLICIT_STRESS_UPDATE_OPTION, 0) grid_model_part.ProcessInfo.SetValue(KratosParticle.IS_EXPLICIT_CENTRAL_DIFFERENCE, True) else: From c1967425bdd61b8950295d7f6f154ebdc11ca3f8 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Thu, 23 Apr 2020 11:16:01 +1000 Subject: [PATCH 198/314] formatting explicit solver py --- .../python_scripts/mpm_explicit_solver.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py b/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py index f2b9fb83f34c..633410a7bf7e 100644 --- a/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py +++ b/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py @@ -58,21 +58,21 @@ def _CreateSolutionScheme(self): # Setting the time integration schemes scheme_type = self.settings["scheme_type"].GetString() - if(scheme_type == "forward_euler"): + if scheme_type == "forward_euler": stress_update_option = 10 stress_update = self.settings["stress_update"].GetString() #0 = USF, 1 = USL, 2 = MUSL - if(stress_update == "usf"): + if stress_update == "usf": stress_update_option = 0 - elif(stress_update == "usl"): + elif stress_update == "usl": stress_update_option = 1 - elif(stress_update == "musl"): + elif stress_update == "musl": stress_update_option = 2 else: err_msg = "The requested stress update \"" + stress_update + "\" is not available!\n" err_msg += "Available options are: \"usf\", \"usl\",\"musl\"" grid_model_part.ProcessInfo.SetValue(KratosParticle.EXPLICIT_STRESS_UPDATE_OPTION, stress_update_option) grid_model_part.ProcessInfo.SetValue(KratosParticle.IS_EXPLICIT_CENTRAL_DIFFERENCE, False) - elif(scheme_type == "central_difference"): + elif scheme_type == "central_difference": grid_model_part.ProcessInfo.SetValue(KratosParticle.EXPLICIT_STRESS_UPDATE_OPTION, 0) grid_model_part.ProcessInfo.SetValue(KratosParticle.IS_EXPLICIT_CENTRAL_DIFFERENCE, True) else: From 5a1975b27c0bd085d5b5c8926ea54af128fd1cdb Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Thu, 23 Apr 2020 11:19:52 +1000 Subject: [PATCH 199/314] fix explicit utilities function typo --- .../custom_elements/updated_lagrangian.cpp | 2 +- .../custom_elements/updated_lagrangian_axisymmetry.cpp | 2 +- .../custom_elements/updated_lagrangian_quadrilateral.cpp | 2 +- .../custom_utilities/mpm_explicit_utilities.cpp | 4 ++-- .../custom_utilities/mpm_explicit_utilities.h | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp index 066bf564deeb..4a61eed7c789 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp @@ -502,7 +502,7 @@ void UpdatedLagrangian::CalculateAndAddRHS(LocalSystemComponents& rLocalSystem, if (rCurrentProcessInfo.GetValue(IS_EXPLICIT)) { - MPMExplicitUtilities::CalcuateAndAddExplicitInternalForce(*this, + MPMExplicitUtilities::CalculateAndAddExplicitInternalForce(*this, mDN_DX, mMP.cauchy_stress_vector, mMP.volume, mConstitutiveLawVector->GetStrainSize(), rRightHandSideVector); } diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp index 683c9185f75c..f06797be71cf 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp @@ -312,7 +312,7 @@ void UpdatedLagrangianAxisymmetry::CalculateAndAddRHS(LocalSystemComponents& rLo if (rCurrentProcessInfo.GetValue(IS_EXPLICIT)) { const double current_radius = ParticleMechanicsMathUtilities::CalculateRadius(mN, GetGeometry()); - MPMExplicitUtilities::CalcuateAndAddAxisymmetricExplicitInternalForce(*this, + MPMExplicitUtilities::CalculateAndAddAxisymmetricExplicitInternalForce(*this, mDN_DX, mN, mMP.cauchy_stress_vector, mMP.volume, mConstitutiveLawVector->GetStrainSize(), current_radius, rRightHandSideVector); } diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index a5e8f6f0c007..eed622db2f72 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -506,7 +506,7 @@ void UpdatedLagrangianQuadrilateral::CalculateAndAddRHS( if (rCurrentProcessInfo.GetValue(IS_EXPLICIT)) { - MPMExplicitUtilities::CalcuateAndAddExplicitInternalForce(*this, + MPMExplicitUtilities::CalculateAndAddExplicitInternalForce(*this, mDN_DX, mMP.cauchy_stress_vector, mMP.volume, mConstitutiveLawVector->GetStrainSize(), rRightHandSideVector); } diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp index 00b3960a4581..f2a12d1e4362 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp @@ -15,7 +15,7 @@ namespace Kratos { - void MPMExplicitUtilities::CalcuateAndAddExplicitInternalForce( + void MPMExplicitUtilities::CalculateAndAddExplicitInternalForce( Element& rElement, const Matrix& rDN_DX, const Vector& rMPStress, @@ -89,7 +89,7 @@ namespace Kratos /***********************************************************************************/ /***********************************************************************************/ - void MPMExplicitUtilities::CalcuateAndAddAxisymmetricExplicitInternalForce( + void MPMExplicitUtilities::CalculateAndAddAxisymmetricExplicitInternalForce( Element& rElement, const Matrix& rDN_DX, const Vector& rN, diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h index 190fa333d3a4..446c0c2ed2f3 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h @@ -43,11 +43,11 @@ namespace Kratos typedef Node<3> NodeType; typedef Geometry GeometryType; - void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) CalcuateAndAddExplicitInternalForce(Element& rElement, + void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) CalculateAndAddExplicitInternalForce(Element& rElement, const Matrix& rDN_DX, const Vector& rMPStress, const double& rMPVolume, const SizeType StrainSize, Vector& rRightHandSideVector); - void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) CalcuateAndAddAxisymmetricExplicitInternalForce(Element& rElement, + void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) CalculateAndAddAxisymmetricExplicitInternalForce(Element& rElement, const Matrix& rDN_DX, const Vector& rN, const Vector& rMPStress, const double& rMPVolume, const SizeType StrainSize, const double AxisymmetricRadius, Vector& rRightHandSideVector); From 258dca95101f21f7572d64b05e9e31191550d13c Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Thu, 23 Apr 2020 11:21:49 +1000 Subject: [PATCH 200/314] pass POD type by value --- .../custom_utilities/mpm_explicit_utilities.cpp | 4 ++-- .../custom_utilities/mpm_explicit_utilities.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp index f2a12d1e4362..8ca422b5705a 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp @@ -19,7 +19,7 @@ namespace Kratos Element& rElement, const Matrix& rDN_DX, const Vector& rMPStress, - const double& rMPVolume, + const double rMPVolume, const SizeType StrainSize, Vector& rRightHandSideVector) { @@ -94,7 +94,7 @@ namespace Kratos const Matrix& rDN_DX, const Vector& rN, const Vector& rMPStress, - const double& rMPVolume, + const double rMPVolume, const SizeType StrainSize, const double AxisymmetricRadius, Vector& rRightHandSideVector) diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h index 446c0c2ed2f3..9e1977550a9c 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h @@ -44,11 +44,11 @@ namespace Kratos typedef Geometry GeometryType; void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) CalculateAndAddExplicitInternalForce(Element& rElement, - const Matrix& rDN_DX, const Vector& rMPStress, const double& rMPVolume, + const Matrix& rDN_DX, const Vector& rMPStress, const double rMPVolume, const SizeType StrainSize, Vector& rRightHandSideVector); void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) CalculateAndAddAxisymmetricExplicitInternalForce(Element& rElement, - const Matrix& rDN_DX, const Vector& rN, const Vector& rMPStress, const double& rMPVolume, + const Matrix& rDN_DX, const Vector& rN, const Vector& rMPStress, const double rMPVolume, const SizeType StrainSize, const double AxisymmetricRadius, Vector& rRightHandSideVector); void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) UpdateGaussPointExplicit(const ProcessInfo& rCurrentProcessInfo, From 769d9c83af489a6fb6ceaa1e3fc955d2ff30d2bc Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Thu, 23 Apr 2020 11:22:25 +1000 Subject: [PATCH 201/314] remove default arg of axisym explicit utilities --- .../custom_utilities/mpm_explicit_utilities.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h index 9e1977550a9c..e3ff6689e56c 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h @@ -62,7 +62,7 @@ namespace Kratos void KRATOS_API(PARTICLE_MECHANICS_APPLICATION) CalculateExplicitAsymmetricKinematics(const ProcessInfo& rCurrentProcessInfo, Element& rElement, const Matrix& rDN_DX, const Vector& rN, Vector& rMPStrain, Matrix& rDeformationGradient, - const SizeType StrainSize, const double AxisymmetricRadius = 1.0); + const SizeType StrainSize, const double AxisymmetricRadius); }; // namespace ExplicitIntegrationUtilities } // namespace Kratos #endif /* KRATOS_MPM_EXPLICIT_UTILITIES defined */ \ No newline at end of file From 9b7b9ba056f41e463c7fb706e9b64204f293ffc1 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Thu, 23 Apr 2020 11:24:31 +1000 Subject: [PATCH 202/314] Update mpm_search_element_utility.h --- .../custom_utilities/mpm_search_element_utility.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h b/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h index 77aee2b7eb64..625cc10ad04d 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h @@ -48,7 +48,7 @@ namespace MPMSearchElementUtility const double Tolerance) { const ProcessInfo& rProcessInfo = rBackgroundGridModelPart.GetProcessInfo(); - const bool isExplicit = rProcessInfo.GetValue(IS_EXPLICIT); + const bool is_explicit = rProcessInfo.GetValue(IS_EXPLICIT); // Reset elements to inactive #pragma omp parallel for @@ -89,7 +89,7 @@ namespace MPMSearchElementUtility bool is_found = SearchStructure.FindPointOnMesh(xg[0], N, pelem, result_begin, MaxNumberOfResults, Tolerance); - if (is_found && isExplicit) { + if (is_found && is_explicit) { // check if MP is exactly on the edge of the element, this gives spurious strains in explicit bool isOnEdge = false; for (SizeType i = 0; i < N.size(); ++i) { From 289aac8abe3b2463da95b55abb03a23b1499847f Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Thu, 23 Apr 2020 11:36:25 +1000 Subject: [PATCH 203/314] removed superfluous strategy access functions --- .../add_custom_strategies_to_python.cpp | 6 --- .../strategies/mpm_explicit_strategy.hpp | 46 ------------------- 2 files changed, 52 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp b/applications/ParticleMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp index 4f27af2186ef..69129ae302ca 100644 --- a/applications/ParticleMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp +++ b/applications/ParticleMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp @@ -96,12 +96,6 @@ namespace Python{ // MPM Explicit Strategy Type py::class_< MPMExplicitStrategyType, typename MPMExplicitStrategyType::Pointer, BaseSolvingStrategyType >(m, "MPMExplicitStrategy") .def(py::init< ModelPart&, BaseSchemeType::Pointer, bool, bool, bool >()) - .def("SetInitializePerformedFlag", &MPMExplicitStrategyType::SetInitializePerformedFlag) - .def("GetInitializePerformedFlag", &MPMExplicitStrategyType::GetInitializePerformedFlag) - .def("SetKeepSystemConstantDuringIterations", &MPMExplicitStrategyType::SetKeepSystemConstantDuringIterations) - .def("GetKeepSystemConstantDuringIterations", &MPMExplicitStrategyType::GetKeepSystemConstantDuringIterations) - .def("SetFinalizeSolutionStepFlag", &MPMExplicitStrategyType::SetFinalizeSolutionStepFlag) - .def("GetFinalizeSolutionStepFlag", &MPMExplicitStrategyType::GetFinalizeSolutionStepFlag) ; } diff --git a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp index 5f99056b7354..af3a0b5af5ac 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp @@ -118,52 +118,6 @@ namespace Kratos return mpScheme; }; - void SetInitializePerformedFlag(bool InitializePerformedFlag = true) - { - mInitializeWasPerformed = InitializePerformedFlag; - } - - bool GetInitializePerformedFlag() - { - return mInitializeWasPerformed; - } - - void SetCalculateReactionsFlag(bool CalculateReactionsFlag) - { - mCalculateReactionsFlag = CalculateReactionsFlag; - } - - bool GetCalculateReactionsFlag() - { - return mCalculateReactionsFlag; - } - - bool GetReformDofSetAtEachStepFlag() - { - return mReformDofSetAtEachStep; - } - - void SetFinalizeSolutionStepFlag(bool FinalizeSolutionStepFlag = true) - { - mFinalizeSolutionStep = FinalizeSolutionStepFlag; - } - - bool GetFinalizeSolutionStepFlag() - { - return mFinalizeSolutionStep; - } - - //level of echo for the solving strategy - // 0 -> mute... no echo at all - // 1 -> printing time and basic informations - // 2 -> printing linear solver data - // 3 -> Print of debug informations: - // Echo of stiffness matrix, Dx, b... - void SetEchoLevel(int Level) override - { - BaseType::mEchoLevel = Level; - } - /// Initialize members void Initialize() override { From 76a98ea0328ca2761de6c80d553072b12b440444 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Thu, 23 Apr 2020 11:39:39 +1000 Subject: [PATCH 204/314] Update mpm_explicit_strategy.hpp --- .../custom_strategies/strategies/mpm_explicit_strategy.hpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp index af3a0b5af5ac..88c7450049d8 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp @@ -151,10 +151,7 @@ namespace Kratos } // Prints informations about the current time - if (this->GetEchoLevel() == 2 && BaseType::GetModelPart().GetCommunicator().MyPID() == 0) - { - KRATOS_INFO("MPM_Explicit_Strategy") << "CurrentTime = " << BaseType::GetModelPart().GetProcessInfo()[TIME] << std::endl; - } + KRATOS_INFO_IF("MPM_Explicit_Strategy", this->GetEchoLevel() == 2) << "CurrentTime = " << BaseType::GetModelPart().GetProcessInfo()[TIME] << std::endl; KRATOS_CATCH("") } @@ -164,7 +161,7 @@ namespace Kratos KRATOS_TRY // Initialize solution step - if (mSolutionStepIsInitialized == false) + if (!mSolutionStepIsInitialized) { typename TSchemeType::Pointer pScheme = GetScheme(); TSystemMatrixType mA = TSystemMatrixType(); From 6a899c1b5a4ae3c6a2387873b92e4563e285ca2e Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Thu, 23 Apr 2020 11:49:17 +1000 Subject: [PATCH 205/314] update scheme - use new getdoflist interface --- .../schemes/mpm_explicit_scheme.hpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp index 1b209465c3bf..cb1351c318c6 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp @@ -22,8 +22,6 @@ #include "includes/define.h" #include "includes/model_part.h" #include "includes/variables.h" -#include "includes/element.h" -#include "containers/array_1d.h" #include "solving_strategies/schemes/scheme.h" #include "custom_utilities/mpm_boundary_rotation_utility.h" #include "custom_utilities/mpm_explicit_utilities.h" @@ -456,12 +454,12 @@ namespace Kratos { /** Function that returns the list of Degrees of freedom to be assembled in the system for a Given Element */ - void GetConditionDofList( - Condition::Pointer rCurrentCondition, - Element::DofsVectorType& ConditionDofList, - ProcessInfo& CurrentProcessInfo) override + void GetDofList( + const Condition& rCurrentCondition, + Element::DofsVectorType& rConditionDofList, + const ProcessInfo& rCurrentProcessInfo) override { - rCurrentCondition->GetDofList(ConditionDofList, CurrentProcessInfo); + rCurrentCondition.GetDofList(rConditionDofList, rCurrentProcessInfo); } //*************************************************************************** From 98a4da572541422265b941351adfed0dc6eae4fc Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Thu, 23 Apr 2020 11:57:22 +1000 Subject: [PATCH 206/314] Update mpm_explicit_scheme.hpp --- .../schemes/mpm_explicit_scheme.hpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp index cb1351c318c6..3612b171196d 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp @@ -472,11 +472,11 @@ namespace Kratos { * @param r_model_part * @return 0 all ok */ - int Check(ModelPart& r_model_part) override + int Check(const ModelPart& rModelPart) const override { KRATOS_TRY - int err = Scheme::Check(r_model_part); + int err = Scheme::Check(rModelPart); if (err != 0) return err; //check that the variables are correctly initialized @@ -485,8 +485,8 @@ namespace Kratos { KRATOS_ERROR_IF(ACCELERATION.Key() == 0) << "ACCELERATION has Key zero! (check if the application is correctly registered" << std::endl; //check that variables are correctly allocated - for (ModelPart::NodesContainerType::iterator it = r_model_part.NodesBegin(); - it != r_model_part.NodesEnd(); ++it) + for (auto it = rModelPart.NodesBegin(); + it != rModelPart.NodesEnd(); ++it) { KRATOS_ERROR_IF(it->SolutionStepsDataHas(DISPLACEMENT) == false) << "DISPLACEMENT variable is not allocated for node " << it->Id() << std::endl; KRATOS_ERROR_IF(it->SolutionStepsDataHas(VELOCITY) == false) << "VELOCITY variable is not allocated for node " << it->Id() << std::endl; @@ -494,8 +494,8 @@ namespace Kratos { } //check that dofs exist - for (ModelPart::NodesContainerType::iterator it = r_model_part.NodesBegin(); - it != r_model_part.NodesEnd(); ++it) + for (auto it = rModelPart.NodesBegin(); + it != rModelPart.NodesEnd(); ++it) { KRATOS_ERROR_IF(it->HasDofFor(DISPLACEMENT_X) == false) << "Missing DISPLACEMENT_X dof on node " << it->Id() << std::endl; KRATOS_ERROR_IF(it->HasDofFor(DISPLACEMENT_Y) == false) << "Missing DISPLACEMENT_Y dof on node " << it->Id() << std::endl; @@ -503,7 +503,7 @@ namespace Kratos { } //check for minimum value of the buffer index - KRATOS_ERROR_IF(r_model_part.GetBufferSize() < 2) << "Insufficient buffer size. Buffer size should be greater than 2. Current size is" << r_model_part.GetBufferSize() << std::endl; + KRATOS_ERROR_IF(rModelPart.GetBufferSize() < 2) << "Insufficient buffer size. Buffer size should be greater than 2. Current size is" << rModelPart.GetBufferSize() << std::endl; KRATOS_CATCH("") return 0; } From 7c00464e91fe39ebdcb07f9992f423e138ad5f35 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Thu, 23 Apr 2020 12:03:02 +1000 Subject: [PATCH 207/314] add const to quad addexplicitcontribution --- .../custom_elements/updated_lagrangian_quadrilateral.cpp | 2 +- .../custom_elements/updated_lagrangian_quadrilateral.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index eed622db2f72..e1b765d908ba 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -1368,7 +1368,7 @@ void UpdatedLagrangianQuadrilateral::CalculateDampingMatrix( MatrixType& rDampin void UpdatedLagrangianQuadrilateral::AddExplicitContribution(const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable>& rDestinationVariable, + const Variable>& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp index 037957d5f9f6..e2ddba5429aa 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp @@ -495,7 +495,7 @@ class UpdatedLagrangianQuadrilateral void AddExplicitContribution(const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable >& rDestinationVariable, + const Variable >& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo) override; From 974b80ce4b2cac3fb03be1d4cf40da660ac23e2e Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Thu, 23 Apr 2020 12:12:57 +1000 Subject: [PATCH 208/314] quad - dont store shape functions --- .../updated_lagrangian_quadrilateral.cpp | 61 +++++++++++-------- .../updated_lagrangian_quadrilateral.hpp | 6 -- 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index e1b765d908ba..e601160b5da8 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -506,8 +506,18 @@ void UpdatedLagrangianQuadrilateral::CalculateAndAddRHS( if (rCurrentProcessInfo.GetValue(IS_EXPLICIT)) { + this->MPMShapeFunctionPointValues(rVariables.N, mMP.xg); + Matrix Jacobian; + Jacobian = this->MPMJacobian(Jacobian, mMP.xg); + Matrix InvJ; + double detJ; + MathUtils::InvertMatrix(Jacobian, InvJ, detJ); + Matrix DN_De; + this->MPMShapeFunctionsLocalGradients(DN_De, mMP.xg); // parametric gradients + rVariables.DN_DX = prod(DN_De, InvJ); // cartesian gradients + MPMExplicitUtilities::CalculateAndAddExplicitInternalForce(*this, - mDN_DX, mMP.cauchy_stress_vector, mMP.volume, + rVariables.DN_DX, mMP.cauchy_stress_vector, mMP.volume, mConstitutiveLawVector->GetStrainSize(), rRightHandSideVector); } else @@ -582,7 +592,16 @@ void UpdatedLagrangianQuadrilateral::CalculateExplicitStresses(const ProcessInfo // Compute explicit element kinematics, strain is incremented here. - MPMExplicitUtilities::CalculateExplicitKinematics(rCurrentProcessInfo, *this, mDN_DX, + this->MPMShapeFunctionPointValues(rVariables.N, mMP.xg); + Matrix Jacobian; + Jacobian = this->MPMJacobian(Jacobian, mMP.xg); + Matrix InvJ; + double detJ; + MathUtils::InvertMatrix(Jacobian, InvJ, detJ); + Matrix DN_De; + this->MPMShapeFunctionsLocalGradients(DN_De, mMP.xg); // parametric gradients + rVariables.DN_DX = prod(DN_De, InvJ); // cartesian gradients + MPMExplicitUtilities::CalculateExplicitKinematics(rCurrentProcessInfo, *this, rVariables.DN_DX, mMP.almansi_strain_vector, rVariables.F, mConstitutiveLawVector->GetStrainSize()); rVariables.StressVector = mMP.cauchy_stress_vector; rVariables.StrainVector = mMP.almansi_strain_vector; @@ -604,8 +623,6 @@ void UpdatedLagrangianQuadrilateral::CalculateExplicitStresses(const ProcessInfo } rVariables.CurrentDisp = CalculateCurrentDisp(rVariables.CurrentDisp, rCurrentProcessInfo); - rVariables.DN_DX = mDN_DX; - rVariables.N = mN; // Set general variables to constitutivelaw parameters this->SetGeneralVariables(rVariables, Values); @@ -882,22 +899,12 @@ void UpdatedLagrangianQuadrilateral::InitializeSolutionStep( ProcessInfo& rCurre GeometryType& r_geometry = GetGeometry(); const unsigned int dimension = r_geometry.WorkingSpaceDimension(); const unsigned int number_of_nodes = r_geometry.PointsNumber(); - GeneralVariables Variables; mFinalizedStep = false; - // Calculating shape function and gradients - Variables.N = this->MPMShapeFunctionPointValues(Variables.N, mMP.xg); - mN = Variables.N; - Matrix Jacobian; - Jacobian = this->MPMJacobian(Jacobian, mMP.xg); - Matrix InvJ; - double detJ; - MathUtils::InvertMatrix(Jacobian, InvJ, detJ); - Matrix DN_De; - this->MPMShapeFunctionsLocalGradients(DN_De, mMP.xg); // parametric gradients - mDN_DX = prod(DN_De, InvJ); // cartesian gradients - + // Calculating shape functions + Vector N; + this->MPMShapeFunctionPointValues(N, mMP.xg); array_1d aux_MP_velocity = ZeroVector(3); array_1d aux_MP_acceleration = ZeroVector(3); @@ -920,8 +927,8 @@ void UpdatedLagrangianQuadrilateral::InitializeSolutionStep( ProcessInfo& rCurre for (unsigned int k = 0; k < dimension; k++) { - aux_MP_velocity[k] += Variables.N[j] * nodal_velocity[k]; - aux_MP_acceleration[k] += Variables.N[j] * nodal_acceleration[k]; + aux_MP_velocity[k] += N[j] * nodal_velocity[k]; + aux_MP_acceleration[k] += N[j] * nodal_acceleration[k]; } } } @@ -931,8 +938,8 @@ void UpdatedLagrangianQuadrilateral::InitializeSolutionStep( ProcessInfo& rCurre { for (unsigned int j = 0; j < dimension; j++) { - nodal_momentum[j] = Variables.N[i] * (mMP.velocity[j] - aux_MP_velocity[j]) * mMP.mass; - nodal_inertia[j] = Variables.N[i] * (mMP.acceleration[j] - aux_MP_acceleration[j]) * mMP.mass; + nodal_momentum[j] = N[i] * (mMP.velocity[j] - aux_MP_velocity[j]) * mMP.mass; + nodal_inertia[j] = N[i] * (mMP.acceleration[j] - aux_MP_acceleration[j]) * mMP.mass; } // Add in the predictor velocity increment for central difference explicit @@ -942,7 +949,7 @@ void UpdatedLagrangianQuadrilateral::InitializeSolutionStep( ProcessInfo& rCurre if (rCurrentProcessInfo.GetValue(IS_EXPLICIT_CENTRAL_DIFFERENCE)) { const double& delta_time = rCurrentProcessInfo[DELTA_TIME]; for (unsigned int j = 0; j < dimension; j++) { - nodal_momentum[j] += 0.5 * delta_time * (Variables.N[i] * mMP.acceleration[j]) * mMP.mass; + nodal_momentum[j] += 0.5 * delta_time * (N[i] * mMP.acceleration[j]) * mMP.mass; } } } @@ -950,7 +957,7 @@ void UpdatedLagrangianQuadrilateral::InitializeSolutionStep( ProcessInfo& rCurre r_geometry[i].SetLock(); r_geometry[i].FastGetSolutionStepValue(NODAL_MOMENTUM, 0) += nodal_momentum; r_geometry[i].FastGetSolutionStepValue(NODAL_INERTIA, 0) += nodal_inertia; - r_geometry[i].FastGetSolutionStepValue(NODAL_MASS, 0) += Variables.N[i] * mMP.mass; + r_geometry[i].FastGetSolutionStepValue(NODAL_MASS, 0) += N[i] * mMP.mass; r_geometry[i].UnSetLock(); } } @@ -1832,12 +1839,16 @@ void UpdatedLagrangianQuadrilateral::CalculateOnIntegrationPoints(const Variable } else if (rVariable == EXPLICIT_MAP_GRID_TO_MP) { - MPMExplicitUtilities::UpdateGaussPointExplicit(rCurrentProcessInfo, *this, mN); + Vector N; + this->MPMShapeFunctionPointValues(N, mMP.xg); + MPMExplicitUtilities::UpdateGaussPointExplicit(rCurrentProcessInfo, *this, N); rValues[0] = true; } else if (rVariable == CALCULATE_MUSL_VELOCITY_FIELD) { - MPMExplicitUtilities::CalculateMUSLGridVelocity(*this, mN); + Vector N; + this->MPMShapeFunctionPointValues(N, mMP.xg); + MPMExplicitUtilities::CalculateMUSLGridVelocity(*this, N); rValues[0] = true; } else diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp index e2ddba5429aa..793a136c5617 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp @@ -613,12 +613,6 @@ class UpdatedLagrangianQuadrilateral */ bool mFinalizedStep; - /// Container to store shape functions over whole timestep - Vector mN; - - /// Container to store shape function gradients over whole timestep - Matrix mDN_DX; - ///@} ///@name Protected Operators ///@{ From 9963b88798df8e39308e99b682cac1f4b62d50aa Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Thu, 23 Apr 2020 12:19:36 +1000 Subject: [PATCH 209/314] dont store shape functions in other elements too --- .../custom_elements/updated_lagrangian.cpp | 59 +++++++++++-------- .../custom_elements/updated_lagrangian.hpp | 7 --- .../updated_lagrangian_axisymmetry.cpp | 30 +++++++--- 3 files changed, 58 insertions(+), 38 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp index 4a61eed7c789..1791c3800f6e 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp @@ -502,8 +502,17 @@ void UpdatedLagrangian::CalculateAndAddRHS(LocalSystemComponents& rLocalSystem, if (rCurrentProcessInfo.GetValue(IS_EXPLICIT)) { + this->MPMShapeFunctionPointValues(rVariables.N, mMP.xg); + Matrix Jacobian; + Jacobian = this->MPMJacobian(Jacobian, mMP.xg); + Matrix InvJ; + double detJ; + MathUtils::InvertMatrix(Jacobian, InvJ, detJ); + Matrix DN_De; + this->MPMShapeFunctionsLocalGradients(DN_De); // parametric gradients + rVariables.DN_DX = prod(DN_De, InvJ); // cartesian gradients MPMExplicitUtilities::CalculateAndAddExplicitInternalForce(*this, - mDN_DX, mMP.cauchy_stress_vector, mMP.volume, + rVariables.DN_DX, mMP.cauchy_stress_vector, mMP.volume, mConstitutiveLawVector->GetStrainSize(), rRightHandSideVector); } else @@ -579,7 +588,16 @@ void UpdatedLagrangian::CalculateExplicitStresses(const ProcessInfo& rCurrentPro // Compute explicit element kinematics, strain is incremented here. - MPMExplicitUtilities::CalculateExplicitKinematics(rCurrentProcessInfo, *this, mDN_DX, + this->MPMShapeFunctionPointValues(rVariables.N, mMP.xg); + Matrix Jacobian; + Jacobian = this->MPMJacobian(Jacobian, mMP.xg); + Matrix InvJ; + double detJ; + MathUtils::InvertMatrix(Jacobian, InvJ, detJ); + Matrix DN_De; + this->MPMShapeFunctionsLocalGradients(DN_De); // parametric gradients + rVariables.DN_DX = prod(DN_De, InvJ); // cartesian gradients + MPMExplicitUtilities::CalculateExplicitKinematics(rCurrentProcessInfo, *this, rVariables.DN_DX, mMP.almansi_strain_vector, rVariables.F, mConstitutiveLawVector->GetStrainSize()); rVariables.StressVector = mMP.cauchy_stress_vector; rVariables.StrainVector = mMP.almansi_strain_vector; @@ -601,8 +619,6 @@ void UpdatedLagrangian::CalculateExplicitStresses(const ProcessInfo& rCurrentPro } rVariables.CurrentDisp = CalculateCurrentDisp(rVariables.CurrentDisp, rCurrentProcessInfo); - rVariables.DN_DX = mDN_DX; - rVariables.N = mN; // Set general variables to constitutivelaw parameters this->SetGeneralVariables(rVariables, Values); @@ -877,21 +893,12 @@ void UpdatedLagrangian::InitializeSolutionStep( ProcessInfo& rCurrentProcessInfo GeometryType& r_geometry = GetGeometry(); const unsigned int dimension = r_geometry.WorkingSpaceDimension(); const unsigned int number_of_nodes = r_geometry.PointsNumber(); - GeneralVariables Variables; mFinalizedStep = false; - // Calculating shape function and gradients - Variables.N = this->MPMShapeFunctionPointValues(Variables.N, mMP.xg); - mN = Variables.N; - Matrix Jacobian; - Jacobian = this->MPMJacobian(Jacobian, mMP.xg); - Matrix InvJ; - double detJ; - MathUtils::InvertMatrix(Jacobian, InvJ, detJ); - Matrix DN_De; - this->MPMShapeFunctionsLocalGradients(DN_De); // parametric gradients - mDN_DX = prod(DN_De, InvJ); // cartesian gradients + // Calculating shape functions + Vector N; + this->MPMShapeFunctionPointValues(N, mMP.xg); array_1d aux_MP_velocity = ZeroVector(3); @@ -914,8 +921,8 @@ void UpdatedLagrangian::InitializeSolutionStep( ProcessInfo& rCurrentProcessInfo for (unsigned int k = 0; k < dimension; k++) { - aux_MP_velocity[k] += Variables.N[j] * nodal_velocity[k]; - aux_MP_acceleration[k] += Variables.N[j] * nodal_acceleration[k]; + aux_MP_velocity[k] += N[j] * nodal_velocity[k]; + aux_MP_acceleration[k] += N[j] * nodal_acceleration[k]; } } } @@ -925,8 +932,8 @@ void UpdatedLagrangian::InitializeSolutionStep( ProcessInfo& rCurrentProcessInfo { for (unsigned int j = 0; j < dimension; j++) { - nodal_momentum[j] = Variables.N[i] * (mMP.velocity[j] - aux_MP_velocity[j]) * mMP.mass; - nodal_inertia[j] = Variables.N[i] * (mMP.acceleration[j] - aux_MP_acceleration[j]) * mMP.mass; + nodal_momentum[j] = N[i] * (mMP.velocity[j] - aux_MP_velocity[j]) * mMP.mass; + nodal_inertia[j] = N[i] * (mMP.acceleration[j] - aux_MP_acceleration[j]) * mMP.mass; } @@ -937,7 +944,7 @@ void UpdatedLagrangian::InitializeSolutionStep( ProcessInfo& rCurrentProcessInfo if (rCurrentProcessInfo.GetValue(IS_EXPLICIT_CENTRAL_DIFFERENCE)) { const double& delta_time = rCurrentProcessInfo[DELTA_TIME]; for (unsigned int j = 0; j < dimension; j++) { - nodal_momentum[j] += 0.5 * delta_time * (Variables.N[i] * mMP.acceleration[j]) * mMP.mass; + nodal_momentum[j] += 0.5 * delta_time * (N[i] * mMP.acceleration[j]) * mMP.mass; } } } @@ -945,7 +952,7 @@ void UpdatedLagrangian::InitializeSolutionStep( ProcessInfo& rCurrentProcessInfo r_geometry[i].SetLock(); r_geometry[i].FastGetSolutionStepValue(NODAL_MOMENTUM, 0) += nodal_momentum; r_geometry[i].FastGetSolutionStepValue(NODAL_INERTIA, 0) += nodal_inertia; - r_geometry[i].FastGetSolutionStepValue(NODAL_MASS, 0) += Variables.N[i] * mMP.mass; + r_geometry[i].FastGetSolutionStepValue(NODAL_MASS, 0) += N[i] * mMP.mass; r_geometry[i].UnSetLock(); } } @@ -1743,12 +1750,16 @@ void UpdatedLagrangian::CalculateOnIntegrationPoints(const Variable& rVari } else if (rVariable == EXPLICIT_MAP_GRID_TO_MP) { - MPMExplicitUtilities::UpdateGaussPointExplicit(rCurrentProcessInfo, *this, mN); + Vector N; + this->MPMShapeFunctionPointValues(N, mMP.xg); + MPMExplicitUtilities::UpdateGaussPointExplicit(rCurrentProcessInfo, *this, N); rValues[0] = true; } else if (rVariable == CALCULATE_MUSL_VELOCITY_FIELD) { - MPMExplicitUtilities::CalculateMUSLGridVelocity(*this, mN); + Vector N; + this->MPMShapeFunctionPointValues(N, mMP.xg); + MPMExplicitUtilities::CalculateMUSLGridVelocity(*this, N); rValues[0] = true; } else diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.hpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.hpp index 6f1a13146053..b4e1ca4f519b 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.hpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.hpp @@ -612,13 +612,6 @@ class UpdatedLagrangian */ bool mFinalizedStep; - /// Container to store shape functions over whole timestep - Vector mN; - - /// Container to store shape function gradients over whole timestep - Matrix mDN_DX; - - ///@} ///@name Protected Operators ///@{ diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp index f06797be71cf..5e81edcc2dd9 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp @@ -311,9 +311,18 @@ void UpdatedLagrangianAxisymmetry::CalculateAndAddRHS(LocalSystemComponents& rLo if (rCurrentProcessInfo.GetValue(IS_EXPLICIT)) { - const double current_radius = ParticleMechanicsMathUtilities::CalculateRadius(mN, GetGeometry()); + this->MPMShapeFunctionPointValues(rVariables.N, mMP.xg); + Matrix Jacobian; + Jacobian = this->MPMJacobian(Jacobian, mMP.xg); + Matrix InvJ; + double detJ; + MathUtils::InvertMatrix(Jacobian, InvJ, detJ); + Matrix DN_De; + this->MPMShapeFunctionsLocalGradients(DN_De); // parametric gradients + rVariables.DN_DX = prod(DN_De, InvJ); // cartesian gradients + const double current_radius = ParticleMechanicsMathUtilities::CalculateRadius(rVariables.N, GetGeometry()); MPMExplicitUtilities::CalculateAndAddAxisymmetricExplicitInternalForce(*this, - mDN_DX, mN, mMP.cauchy_stress_vector, mMP.volume, + rVariables.DN_DX, rVariables.N, mMP.cauchy_stress_vector, mMP.volume, mConstitutiveLawVector->GetStrainSize(), current_radius, rRightHandSideVector); } else @@ -389,9 +398,18 @@ void UpdatedLagrangianAxisymmetry::CalculateExplicitStresses(const ProcessInfo& // Compute explicit element kinematics, strain is incremented here. - const double current_radius = ParticleMechanicsMathUtilities::CalculateRadius(mN, GetGeometry()); - MPMExplicitUtilities::CalculateExplicitAsymmetricKinematics(rCurrentProcessInfo, *this, mDN_DX, - mN, mMP.almansi_strain_vector, rVariables.F, mConstitutiveLawVector->GetStrainSize(), current_radius); + this->MPMShapeFunctionPointValues(rVariables.N, mMP.xg); + Matrix Jacobian; + Jacobian = this->MPMJacobian(Jacobian, mMP.xg); + Matrix InvJ; + double detJ; + MathUtils::InvertMatrix(Jacobian, InvJ, detJ); + Matrix DN_De; + this->MPMShapeFunctionsLocalGradients(DN_De); // parametric gradients + rVariables.DN_DX = prod(DN_De, InvJ); // cartesian gradients + const double current_radius = ParticleMechanicsMathUtilities::CalculateRadius(rVariables.N, GetGeometry()); + MPMExplicitUtilities::CalculateExplicitAsymmetricKinematics(rCurrentProcessInfo, *this, rVariables.DN_DX, + rVariables.N, mMP.almansi_strain_vector, rVariables.F, mConstitutiveLawVector->GetStrainSize(), current_radius); rVariables.StressVector = mMP.cauchy_stress_vector; rVariables.StrainVector = mMP.almansi_strain_vector; @@ -412,8 +430,6 @@ void UpdatedLagrangianAxisymmetry::CalculateExplicitStresses(const ProcessInfo& } rVariables.CurrentDisp = CalculateCurrentDisp(rVariables.CurrentDisp, rCurrentProcessInfo); - rVariables.DN_DX = mDN_DX; - rVariables.N = mN; // Set general variables to constitutivelaw parameters this->SetGeneralVariables(rVariables, Values); From b1da9215e89200c6d978dc2eb0ef39ead67cf636 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Thu, 23 Apr 2020 12:20:56 +1000 Subject: [PATCH 210/314] add const to updated lagrange add explicit contribution --- .../custom_elements/updated_lagrangian.cpp | 2 +- .../custom_elements/updated_lagrangian.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp index 1791c3800f6e..42cdc3323f4e 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp @@ -1372,7 +1372,7 @@ void UpdatedLagrangian::CalculateDampingMatrix( MatrixType& rDampingMatrix, Proc KRATOS_CATCH( "" ) } -void UpdatedLagrangian::AddExplicitContribution(const VectorType& rRHSVector, const Variable& rRHSVariable, Variable>& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo) +void UpdatedLagrangian::AddExplicitContribution(const VectorType& rRHSVector, const Variable& rRHSVariable, const Variable>& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.hpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.hpp index b4e1ca4f519b..51d57265b159 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.hpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.hpp @@ -492,7 +492,7 @@ class UpdatedLagrangian void AddExplicitContribution(const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable >& rDestinationVariable, + const Variable >& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo) override; //************************************************************************************ From f25b329111759af69949ef41b8c884218ff18497 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Thu, 23 Apr 2020 14:19:09 +1000 Subject: [PATCH 211/314] add safe checks for explicit time integration --- .../custom_elements/updated_lagrangian.cpp | 28 +++++++++++++++---- .../custom_elements/updated_lagrangian_UP.cpp | 5 +++- .../updated_lagrangian_axisymmetry.cpp | 6 ++-- .../updated_lagrangian_quadrilateral.cpp | 27 ++++++++++++++---- 4 files changed, 51 insertions(+), 15 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp index 42cdc3323f4e..d1a6454fb005 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp @@ -293,6 +293,9 @@ void UpdatedLagrangian::CalculateElementalSystem( LocalSystemComponents& rLocalS // Create and initialize element variables: GeneralVariables Variables; this->InitializeGeneralVariables(Variables,rCurrentProcessInfo); + const bool is_explicit = (rCurrentProcessInfo.Has(IS_EXPLICIT)) + ? rCurrentProcessInfo.GetValue(IS_EXPLICIT) + : false; // Create constitutive law parameters: ConstitutiveLaw::Parameters Values(GetGeometry(),GetProperties(),rCurrentProcessInfo); @@ -301,7 +304,7 @@ void UpdatedLagrangian::CalculateElementalSystem( LocalSystemComponents& rLocalS Flags &ConstitutiveLawOptions=Values.GetOptions(); ConstitutiveLawOptions.Set(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR); - if (!rCurrentProcessInfo.GetValue(IS_EXPLICIT)) + if (!is_explicit) { ConstitutiveLawOptions.Set(ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN); ConstitutiveLawOptions.Set(ConstitutiveLaw::COMPUTE_STRESS); @@ -324,7 +327,7 @@ void UpdatedLagrangian::CalculateElementalSystem( LocalSystemComponents& rLocalS // Update MP_Density mMP.density = (GetProperties()[DENSITY]) / Variables.detFT; } - else if (rCurrentProcessInfo.GetValue(IS_EXPLICIT)) + else if (is_explicit) { rLocalSystem.CalculationFlags.Set(UpdatedLagrangian::COMPUTE_LHS_MATRIX, false); } @@ -500,7 +503,10 @@ void UpdatedLagrangian::CalculateAndAddRHS(LocalSystemComponents& rLocalSystem, // Operation performed: rRightHandSideVector += ExtForce*IntToReferenceWeight this->CalculateAndAddExternalForces( rRightHandSideVector, rVariables, rVolumeForce, rIntegrationWeight ); - if (rCurrentProcessInfo.GetValue(IS_EXPLICIT)) + const bool is_explicit = (rCurrentProcessInfo.Has(IS_EXPLICIT)) + ? rCurrentProcessInfo.GetValue(IS_EXPLICIT) + : false; + if (is_explicit) { this->MPMShapeFunctionPointValues(rVariables.N, mMP.xg); Matrix Jacobian; @@ -893,6 +899,9 @@ void UpdatedLagrangian::InitializeSolutionStep( ProcessInfo& rCurrentProcessInfo GeometryType& r_geometry = GetGeometry(); const unsigned int dimension = r_geometry.WorkingSpaceDimension(); const unsigned int number_of_nodes = r_geometry.PointsNumber(); + const bool is_explicit = (rCurrentProcessInfo.Has(IS_EXPLICIT)) + ? rCurrentProcessInfo.GetValue(IS_EXPLICIT) + : false; mFinalizedStep = false; @@ -906,7 +915,7 @@ void UpdatedLagrangian::InitializeSolutionStep( ProcessInfo& rCurrentProcessInfo array_1d nodal_momentum = ZeroVector(3); array_1d nodal_inertia = ZeroVector(3); - if (!rCurrentProcessInfo.GetValue(IS_EXPLICIT)) + if (!is_explicit) { for (unsigned int j = 0; j < number_of_nodes; j++) { @@ -964,7 +973,11 @@ void UpdatedLagrangian::FinalizeSolutionStep( ProcessInfo& rCurrentProcessInfo ) { KRATOS_TRY - KRATOS_ERROR_IF(rCurrentProcessInfo.GetValue(IS_EXPLICIT)) + const bool is_explicit = (rCurrentProcessInfo.Has(IS_EXPLICIT)) + ? rCurrentProcessInfo.GetValue(IS_EXPLICIT) + : false; + + KRATOS_ERROR_IF(is_explicit) << "FinalizeSolutionStep for explicit time integration is done in the scheme"; // Create and initialize element variables: @@ -1020,7 +1033,10 @@ void UpdatedLagrangian::FinalizeStepVariables( GeneralVariables & rVariables, co mConstitutiveLawVector->GetValue(MP_ACCUMULATED_PLASTIC_VOLUMETRIC_STRAIN, mMP.accumulated_plastic_volumetric_strain); mConstitutiveLawVector->GetValue(MP_ACCUMULATED_PLASTIC_DEVIATORIC_STRAIN, mMP.accumulated_plastic_deviatoric_strain); - if (!rCurrentProcessInfo.GetValue(IS_EXPLICIT)) this->UpdateGaussPoint(rVariables, rCurrentProcessInfo); + const bool is_explicit = (rCurrentProcessInfo.Has(IS_EXPLICIT)) + ? rCurrentProcessInfo.GetValue(IS_EXPLICIT) + : false; + if (!is_explicit) this->UpdateGaussPoint(rVariables, rCurrentProcessInfo); } //************************************************************************************ diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.cpp index 0aa6485c0c39..58a23c66ac87 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.cpp @@ -1241,7 +1241,10 @@ int UpdatedLagrangianUP::Check( const ProcessInfo& rCurrentProcessInfo ) { KRATOS_TRY - KRATOS_ERROR_IF(rCurrentProcessInfo.GetValue(IS_EXPLICIT)) + const bool is_explicit = (rCurrentProcessInfo.Has(IS_EXPLICIT)) + ? rCurrentProcessInfo.GetValue(IS_EXPLICIT) + : false; + KRATOS_ERROR_IF(is_explicit) << "Explicit time integration not implemented for Updated Lagrangian UP MPM Element"; int correct = 0; diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp index 5e81edcc2dd9..f0207809329c 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp @@ -308,8 +308,10 @@ void UpdatedLagrangianAxisymmetry::CalculateAndAddRHS(LocalSystemComponents& rLo // Operation performed: rRightHandSideVector += ExtForce*IntToReferenceWeight this->CalculateAndAddExternalForces(rRightHandSideVector, rVariables, rVolumeForce, rIntegrationWeight); - - if (rCurrentProcessInfo.GetValue(IS_EXPLICIT)) + const bool is_explicit = (rCurrentProcessInfo.Has(IS_EXPLICIT)) + ? rCurrentProcessInfo.GetValue(IS_EXPLICIT) + : false; + if (is_explicit) { this->MPMShapeFunctionPointValues(rVariables.N, mMP.xg); Matrix Jacobian; diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index e601160b5da8..582077a835cb 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -294,6 +294,9 @@ void UpdatedLagrangianQuadrilateral::CalculateElementalSystem( LocalSystemCompon // Create and initialize element variables: GeneralVariables Variables; this->InitializeGeneralVariables(Variables,rCurrentProcessInfo); + const bool is_explicit = (rCurrentProcessInfo.Has(IS_EXPLICIT)) + ? rCurrentProcessInfo.GetValue(IS_EXPLICIT) + : false; // Create constitutive law parameters: ConstitutiveLaw::Parameters Values(GetGeometry(),GetProperties(),rCurrentProcessInfo); @@ -302,7 +305,7 @@ void UpdatedLagrangianQuadrilateral::CalculateElementalSystem( LocalSystemCompon Flags &ConstitutiveLawOptions=Values.GetOptions(); ConstitutiveLawOptions.Set(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR); - if (!rCurrentProcessInfo.GetValue(IS_EXPLICIT)) + if (!is_explicit) { ConstitutiveLawOptions.Set(ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN); ConstitutiveLawOptions.Set(ConstitutiveLaw::COMPUTE_STRESS); @@ -325,7 +328,7 @@ void UpdatedLagrangianQuadrilateral::CalculateElementalSystem( LocalSystemCompon // Update MP_density mMP.density = (GetProperties()[DENSITY]) / Variables.detFT; } - else if (rCurrentProcessInfo.GetValue(IS_EXPLICIT)) + else if (is_explicit) { rLocalSystem.CalculationFlags.Set(UpdatedLagrangianQuadrilateral::COMPUTE_LHS_MATRIX, false); } @@ -503,8 +506,11 @@ void UpdatedLagrangianQuadrilateral::CalculateAndAddRHS( // Operation performed: rRightHandSideVector += ExtForce*IntToReferenceWeight this->CalculateAndAddExternalForces( rRightHandSideVector, rVariables, rVolumeForce, rIntegrationWeight ); + const bool is_explicit = (rCurrentProcessInfo.Has(IS_EXPLICIT)) + ? rCurrentProcessInfo.GetValue(IS_EXPLICIT) + : false; - if (rCurrentProcessInfo.GetValue(IS_EXPLICIT)) + if (is_explicit) { this->MPMShapeFunctionPointValues(rVariables.N, mMP.xg); Matrix Jacobian; @@ -899,6 +905,9 @@ void UpdatedLagrangianQuadrilateral::InitializeSolutionStep( ProcessInfo& rCurre GeometryType& r_geometry = GetGeometry(); const unsigned int dimension = r_geometry.WorkingSpaceDimension(); const unsigned int number_of_nodes = r_geometry.PointsNumber(); + const bool is_explicit = (rCurrentProcessInfo.Has(IS_EXPLICIT)) + ? rCurrentProcessInfo.GetValue(IS_EXPLICIT) + : false; mFinalizedStep = false; @@ -912,7 +921,7 @@ void UpdatedLagrangianQuadrilateral::InitializeSolutionStep( ProcessInfo& rCurre array_1d nodal_inertia = ZeroVector(3); - if (!rCurrentProcessInfo.GetValue(IS_EXPLICIT)) + if (!is_explicit) { for (unsigned int j = 0; j < number_of_nodes; j++) { @@ -969,7 +978,10 @@ void UpdatedLagrangianQuadrilateral::FinalizeSolutionStep(ProcessInfo& rCurrentP { KRATOS_TRY - KRATOS_ERROR_IF(rCurrentProcessInfo.GetValue(IS_EXPLICIT)) + const bool is_explicit = (rCurrentProcessInfo.Has(IS_EXPLICIT)) + ? rCurrentProcessInfo.GetValue(IS_EXPLICIT) + : false; + KRATOS_ERROR_IF(is_explicit) << "FinalizeSolutionStep for explicit time integration is done in the scheme"; // Create and initialize element variables: @@ -1023,7 +1035,10 @@ void UpdatedLagrangianQuadrilateral::FinalizeStepVariables( GeneralVariables & r mConstitutiveLawVector->GetValue(MP_ACCUMULATED_PLASTIC_VOLUMETRIC_STRAIN, mMP.accumulated_plastic_volumetric_strain); mConstitutiveLawVector->GetValue(MP_ACCUMULATED_PLASTIC_DEVIATORIC_STRAIN, mMP.accumulated_plastic_deviatoric_strain); - if (!rCurrentProcessInfo.GetValue(IS_EXPLICIT)) this->UpdateGaussPoint(rVariables, rCurrentProcessInfo); + const bool is_explicit = (rCurrentProcessInfo.Has(IS_EXPLICIT)) + ? rCurrentProcessInfo.GetValue(IS_EXPLICIT) + : false; + if (!is_explicit) this->UpdateGaussPoint(rVariables, rCurrentProcessInfo); } //************************************************************************************ From f314900f81449ba900c3ce4a213179a79ccbbbf5 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Thu, 23 Apr 2020 15:12:57 +1000 Subject: [PATCH 212/314] fix strategy setEchoLevel --- .../custom_strategies/strategies/mpm_explicit_strategy.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp index 88c7450049d8..3583208ab8b3 100644 --- a/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp +++ b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp @@ -94,7 +94,7 @@ namespace Kratos mInitializeWasPerformed = false; mFinalizeSolutionStep = true; // Set EchoLevel to the default value (only time is displayed) - SetEchoLevel(1); + this->SetEchoLevel(1); // By default the matrices are rebuilt at each solution step this->SetRebuildLevel(1); From 11ff581592ff56417d82693a301b5272e20baeab Mon Sep 17 00:00:00 2001 From: DanielDiez Date: Thu, 23 Apr 2020 09:37:13 +0200 Subject: [PATCH 213/314] make element implicit by default --- .../levelset_convection_element_simplex.h | 20 +++++++------------ kratos/includes/variables.h | 2 ++ kratos/python/add_containers_to_python.cpp | 1 + kratos/sources/variables.cpp | 4 ++++ 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/kratos/elements/levelset_convection_element_simplex.h b/kratos/elements/levelset_convection_element_simplex.h index a904ec84fe56..c5bb9e2d3681 100644 --- a/kratos/elements/levelset_convection_element_simplex.h +++ b/kratos/elements/levelset_convection_element_simplex.h @@ -111,15 +111,9 @@ class LevelSetConvectionElementSimplex if (rRightHandSideVector.size() != TNumNodes) rRightHandSideVector.resize(TNumNodes, false); //false says not to preserve existing storage!! - -// noalias(rLeftHandSideMatrix) = ZeroMatrix(TNumNodes, TNumNodes); -// noalias(rRightHandSideVector) = ZeroVector(TNumNodes); - -// //Crank-Nicholson factor -// const double cr_nk = 0.5; - const double delta_t = rCurrentProcessInfo[DELTA_TIME]; const double dt_inv = 1.0 / delta_t; + const double theta = rCurrentProcessInfo.Has(THETA) ? rCurrentProcessInfo[THETA] : 1.0; ConvectionDiffusionSettings::Pointer my_settings = rCurrentProcessInfo.GetValue(CONVECTION_DIFFUSION_SETTINGS); const Variable& rUnknownVar = my_settings->GetUnknownVariable(); @@ -216,12 +210,12 @@ class LevelSetConvectionElementSimplex } //adding the second and third term in the formulation - noalias(rLeftHandSideMatrix) = (dt_inv + 0.5*beta*div_v)*aux1; //the 0.5 comes from the use of Crank Nichlson - noalias(rRightHandSideVector) = (dt_inv - 0.5*beta*div_v)*prod(aux1,phi_old); //the 0.5 comes from the use of Crank Nichlson + noalias(rLeftHandSideMatrix) = (dt_inv + theta*beta*div_v)*aux1; + noalias(rRightHandSideVector) = (dt_inv - (1.0 - theta)*beta*div_v)*prod(aux1,phi_old); //terms in aux2 - noalias(rLeftHandSideMatrix) += 0.5*aux2; //the 0.5 comes from the use of Crank Nichlson - noalias(rRightHandSideVector) -= 0.5*prod(aux2,phi_old); //the 0.5 comes from the use of Crank Nichlson + noalias(rLeftHandSideMatrix) += theta*aux2; + noalias(rRightHandSideVector) -= (1.0 - theta)*prod(aux2,phi_old); //take out the dirichlet part to finish computing the residual noalias(rRightHandSideVector) -= prod(rLeftHandSideMatrix, phi); @@ -351,9 +345,9 @@ class LevelSetConvectionElementSimplex { h_inv += DN_DX(i,k)*DN_DX(i,k); } - h += 1.0/h_inv; + h = std::max(h, 1.0 / h_inv); } - h = sqrt(h)/static_cast(TNumNodes); + h = std::sqrt(h); return h; } diff --git a/kratos/includes/variables.h b/kratos/includes/variables.h index c4e7506edcbf..626e98861120 100644 --- a/kratos/includes/variables.h +++ b/kratos/includes/variables.h @@ -124,6 +124,8 @@ namespace Kratos KRATOS_DEFINE_VARIABLE( double, GRADIENT_PENALTY_COEFFICIENT ) + KRATOS_DEFINE_VARIABLE( double, THETA ) + //sheme info :: pass to elements KRATOS_DEFINE_VARIABLE( double, NEWMARK_BETA ) KRATOS_DEFINE_VARIABLE( double, NEWMARK_GAMMA ) diff --git a/kratos/python/add_containers_to_python.cpp b/kratos/python/add_containers_to_python.cpp index c7e4dd02cf96..9b36b4c2b963 100644 --- a/kratos/python/add_containers_to_python.cpp +++ b/kratos/python/add_containers_to_python.cpp @@ -328,6 +328,7 @@ void AddContainersToPython(pybind11::module& m) KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, ERROR_RATIO ) KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, TIME_STEPS ) KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, SCALAR_LAGRANGE_MULTIPLIER ) + KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, THETA ) KRATOS_REGISTER_IN_PYTHON_3D_VARIABLE_WITH_COMPONENTS(m, VECTOR_LAGRANGE_MULTIPLIER ) KRATOS_REGISTER_IN_PYTHON_3D_VARIABLE_WITH_COMPONENTS(m, ANGULAR_ACCELERATION ) diff --git a/kratos/sources/variables.cpp b/kratos/sources/variables.cpp index 2f7611dcbbca..b4284674139d 100644 --- a/kratos/sources/variables.cpp +++ b/kratos/sources/variables.cpp @@ -111,6 +111,8 @@ KRATOS_CREATE_VARIABLE(double, DETERMINANT_F) KRATOS_CREATE_VARIABLE(double, GRADIENT_PENALTY_COEFFICIENT) +KRATOS_CREATE_VARIABLE(double, THETA) + //sheme info :: pass to elements KRATOS_CREATE_VARIABLE(double, NEWMARK_BETA) KRATOS_CREATE_VARIABLE(double, NEWMARK_GAMMA) @@ -598,6 +600,8 @@ void KratosApplication::RegisterVariables() { KRATOS_REGISTER_VARIABLE(GEOMETRIC_STIFFNESS_MATRIX) KRATOS_REGISTER_VARIABLE(DETERMINANT_F) KRATOS_REGISTER_VARIABLE(GRADIENT_PENALTY_COEFFICIENT) + KRATOS_REGISTER_VARIABLE(THETA) + //STRAIN MEASURES KRATOS_REGISTER_VARIABLE(VOLUMETRIC_STRAIN) From fc0371c5a4b6476624709e07f38e008ae2938cac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20Irazabal?= Date: Thu, 23 Apr 2020 12:56:23 +0200 Subject: [PATCH 214/314] Adding simplified_bilinear_3D_law --- .../PoromechanicsApplication/CMakeLists.txt | 1 + .../simplified_bilinear_3D_law.cpp | 348 ++++++++++++++++++ .../simplified_bilinear_3D_law.hpp | 134 +++++++ ...add_custom_constitutive_laws_to_python.cpp | 4 + .../poromechanics_application.cpp | 3 + .../poromechanics_application.h | 2 + .../poromechanics_application_variables.cpp | 2 + .../poromechanics_application_variables.h | 2 + 8 files changed, 496 insertions(+) create mode 100644 applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_3D_law.cpp create mode 100644 applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_3D_law.hpp diff --git a/applications/PoromechanicsApplication/CMakeLists.txt b/applications/PoromechanicsApplication/CMakeLists.txt index 29c203a76590..1519b69bcb3e 100644 --- a/applications/PoromechanicsApplication/CMakeLists.txt +++ b/applications/PoromechanicsApplication/CMakeLists.txt @@ -27,6 +27,7 @@ set( KRATOS_POROMECHANICS_APPLICATION_CORE_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/custom_constitutive/bilinear_cohesive_2D_law.cpp ${CMAKE_CURRENT_SOURCE_DIR}/custom_constitutive/exponential_cohesive_3D_law.cpp ${CMAKE_CURRENT_SOURCE_DIR}/custom_constitutive/exponential_cohesive_2D_law.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/custom_constitutive/simplified_bilinear_3D_law.cpp ${CMAKE_CURRENT_SOURCE_DIR}/custom_constitutive/local_damage_3D_law.cpp ${CMAKE_CURRENT_SOURCE_DIR}/custom_constitutive/local_damage_plane_strain_2D_law.cpp ${CMAKE_CURRENT_SOURCE_DIR}/custom_constitutive/local_damage_plane_stress_2D_law.cpp diff --git a/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_3D_law.cpp b/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_3D_law.cpp new file mode 100644 index 000000000000..576688909933 --- /dev/null +++ b/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_3D_law.cpp @@ -0,0 +1,348 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ ` +// _|\_\_| \__,_|\__|\___/ ____/ +// Multi-Physics +// +// License: BSD License +// Kratos default license: kratos/license.txt +// +// Main authors: Javier San Mauro Saiz +// Joaquin Irazabal Gonzalez +// + +// Application includes +#include "custom_constitutive/simplified_bilinear_3D_law.hpp" + +namespace Kratos +{ + +int SimplifiedBilinear3DLaw::Check(const Properties& rMaterialProperties,const GeometryType& rElementGeometry,const ProcessInfo& rCurrentProcessInfo) +{ + // Verify ProcessInfo variables + KRATOS_CHECK_VARIABLE_KEY(IS_CONVERGED); + + // Verify Properties variables + KRATOS_CHECK_VARIABLE_KEY(MAX_COMPRESSIVE_STRESS); + if(rMaterialProperties.Has(MAX_COMPRESSIVE_STRESS)) { + KRATOS_ERROR_IF(rMaterialProperties[MAX_COMPRESSIVE_STRESS] < 0.0) << "MAX_COMPRESSIVE_STRESS has an invalid value " << std::endl; + } else { + KRATOS_ERROR << "MAX_COMPRESSIVE_STRESS not defined" << std::endl; + } + + KRATOS_CHECK_VARIABLE_KEY(POISSON_RATIO); + if(rMaterialProperties.Has(POISSON_RATIO)) { + KRATOS_ERROR_IF(rMaterialProperties[POISSON_RATIO] < -1.0) << "POISSON_RATIO has an invalid value lower ahn -1.0" << std::endl; + KRATOS_ERROR_IF(rMaterialProperties[POISSON_RATIO] >= 0.5) << "POISSON_RATIO has an invalid value greater or equal to 0.5 " << std::endl; + } else { + KRATOS_ERROR << "POISSON_RATIO not defined" << std::endl; + } + + KRATOS_CHECK_VARIABLE_KEY(FRICTION_COEFFICIENT); + if(rMaterialProperties.Has(FRICTION_COEFFICIENT)) { + KRATOS_ERROR_IF(rMaterialProperties[FRICTION_COEFFICIENT] < 0.0) << "FRICTION_COEFFICIENT has an invalid value " << std::endl; + } else { + KRATOS_ERROR << "FRICTION_COEFFICIENT not defined" << std::endl; + } + + return 0; +} + +//---------------------------------------------------------------------------------------- + +void SimplifiedBilinear3DLaw::InitializeMaterial( const Properties& rMaterialProperties,const GeometryType& rElementGeometry,const Vector& rShapeFunctionsValues ) +{ + mStateVariable = 1.0; +} + +//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +void SimplifiedBilinear3DLaw::CalculateMaterialResponseCauchy (Parameters& rValues) +{ + //Check + rValues.CheckAllParameters(); + + //Initialize main variables + Flags& Options = rValues.GetOptions(); + ConstitutiveLawVariables Variables; + this->InitializeConstitutiveLawVariables(Variables,rValues); + + this->ComputeEquivalentStrain(Variables,rValues); + this->CheckLoadingFunction(Variables,rValues); + + if(Options.Is(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR)) + { + if(Options.IsNot(ConstitutiveLaw::COMPUTE_STRESS)) + { + // COMPUTE_CONSTITUTIVE_TENSOR + Matrix& rConstitutiveMatrix = rValues.GetConstitutiveMatrix(); + + this->ComputeConstitutiveMatrix(rConstitutiveMatrix,Variables,rValues); + } + else + { + // COMPUTE_CONSTITUTIVE_TENSOR && COMPUTE_STRESS + Matrix& rConstitutiveMatrix = rValues.GetConstitutiveMatrix(); + Vector& rStressVector = rValues.GetStressVector(); + + this->ComputeConstitutiveMatrix(rConstitutiveMatrix,Variables,rValues); + this->ComputeStressVector(rStressVector,Variables,rValues); + } + } + else if(Options.Is(ConstitutiveLaw::COMPUTE_STRESS)) + { + // COMPUTE_STRESS + Vector& rStressVector = rValues.GetStressVector(); + + this->ComputeStressVector(rStressVector,Variables,rValues); + } +} + +//---------------------------------------------------------------------------------------- + +void SimplifiedBilinear3DLaw::FinalizeMaterialResponseCauchy (Parameters& rValues) +{ + if(rValues.GetProcessInfo()[IS_CONVERGED]==true) //Convergence is achieved. Save equilibrium state variable + { + rValues.CheckAllParameters(); + + ConstitutiveLawVariables Variables; + this->InitializeConstitutiveLawVariables(Variables,rValues); + + this->ComputeEquivalentStrain(Variables,rValues); + this->CheckLoadingFunction(Variables,rValues); + + if(Variables.LoadingFlag) + { + mStateVariable = Variables.EquivalentStrain; + } + } +} + +//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +void SimplifiedBilinear3DLaw::InitializeConstitutiveLawVariables(ConstitutiveLawVariables& rVariables, + Parameters& rValues) + +{ + const Properties& MaterialProperties = rValues.GetMaterialProperties(); + rVariables.MaxCompresiveStress = MaterialProperties[MAX_COMPRESSIVE_STRESS]; + rVariables.MaxTensileStress = 30.0 * pow(rVariables.MaxCompresiveStress, 1.5); + rVariables.YoungModulus = 85.0e6 * pow(rVariables.MaxCompresiveStress + 8.0e6, 0.33333333333333333333333333333); + rVariables.YieldStress = rVariables.YoungModulus; + rVariables.PoissonCoefficient = MaterialProperties[POISSON_RATIO]; + rVariables.FrictionCoefficient = MaterialProperties[FRICTION_COEFFICIENT]; +} + +//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +void SimplifiedBilinear3DLaw::ComputeEquivalentStrain(ConstitutiveLawVariables& rVariables, + Parameters& rValues) +{ + const Vector& StrainVector = rValues.GetStrainVector(); + + if( rValues.GetOptions().Is(ConstitutiveLaw::COMPUTE_STRAIN_ENERGY) ) // No contact between interfaces + { + rVariables.EquivalentStrain = 1.0; + if (mStateVariable == 1.0) + { + if((sqrt(StrainVector[0] * StrainVector[0] + StrainVector[1] * StrainVector[1]) * rVariables.YieldStress) > rVariables.MaxTensileStress) + { + rVariables.EquivalentStrain = 0.0; + } + if(fabs(rVariables.YieldStress * StrainVector[2]) > rVariables.MaxTensileStress) + { + rVariables.EquivalentStrain = 0.0; + } + } + } + else // Contact between interfaces + { + rVariables.EquivalentStrain = 1.0; + if (mStateVariable == 1.0) + { + if((sqrt(StrainVector[0] * StrainVector[0] + StrainVector[1] * StrainVector[1]) * rVariables.YieldStress) > rVariables.MaxTensileStress) + { + rVariables.EquivalentStrain = 0.0; + } + if(fabs(rVariables.YoungModulus * StrainVector[2]) > rVariables.MaxCompresiveStress) + { + rVariables.EquivalentStrain = 0.0; + } + } + } +} + +//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +void SimplifiedBilinear3DLaw::CheckLoadingFunction(ConstitutiveLawVariables& rVariables, + Parameters& rValues) +{ + rVariables.LoadingFlag = false; + rVariables.LoadingFunction = 0.0; + + if(rVariables.EquivalentStrain < mStateVariable) + { + rVariables.LoadingFlag = true; + rVariables.LoadingFunction = 1.0; + } +} + +//---------------------------------------------------------------------------------------- + +void SimplifiedBilinear3DLaw::ComputeConstitutiveMatrix(Matrix& rConstitutiveMatrix, + ConstitutiveLawVariables& rVariables, + Parameters& rValues) +{ + const Vector& StrainVector = rValues.GetStrainVector(); + + if( rValues.GetOptions().Is(ConstitutiveLaw::COMPUTE_STRAIN_ENERGY) ) // No contact between interfaces + { + + // Unloading + + // Tensile constitutive matrix + if (mStateVariable == 0.0) + { + rVariables.YieldStress= rVariables.YoungModulus * 1.0e-7; + } + + rConstitutiveMatrix(0,0) = rVariables.YieldStress; + rConstitutiveMatrix(1,1) = rConstitutiveMatrix(0,0); + rConstitutiveMatrix(2,2) = rConstitutiveMatrix(0,0); + + rConstitutiveMatrix(0,1) = 0.0; + rConstitutiveMatrix(0,2) = 0.0; + rConstitutiveMatrix(1,2) = 0.0; + rConstitutiveMatrix(1,0) = 0.0; + rConstitutiveMatrix(2,0) = 0.0; + rConstitutiveMatrix(2,1) = 0.0; + + } + else // Contact between interfaces + { + + // Unloading + + // Compresive constitutive matrix + if (mStateVariable==0.0) + { + rVariables.YieldStress=2.0e3; + } + + rConstitutiveMatrix(0,0) = rVariables.YieldStress; + rConstitutiveMatrix(1,1) = rVariables.YieldStress; + rConstitutiveMatrix(2,2) = rVariables.YoungModulus; + + rConstitutiveMatrix(0,1) = 0.0; + + const double eps = std::numeric_limits::epsilon(); + + if(StrainVector[0] > eps) + { + rConstitutiveMatrix(0,2) =-rVariables.YoungModulus * rVariables.FrictionCoefficient; + } + else if(StrainVector[0] < -eps) + { + rConstitutiveMatrix(0,2) = rVariables.YoungModulus * rVariables.FrictionCoefficient; + } + else + { + rConstitutiveMatrix(0,2) = 0.0; + } + + if(StrainVector[1] > eps) + { + rConstitutiveMatrix(1,2) =-rVariables.YoungModulus * rVariables.FrictionCoefficient; + } + else if(StrainVector[1] < -eps) + { + rConstitutiveMatrix(1,2) = rVariables.YoungModulus * rVariables.FrictionCoefficient; + } + else + { + rConstitutiveMatrix(1,2) = 0.0; + } + + rConstitutiveMatrix(1,0) = 0.0; + rConstitutiveMatrix(2,0) = 0.0; + rConstitutiveMatrix(2,1) = 0.0; + + } +} + +//---------------------------------------------------------------------------------------- + +void SimplifiedBilinear3DLaw::ComputeStressVector(Vector& rStressVector, + ConstitutiveLawVariables& rVariables, + Parameters& rValues) +{ + const Vector& StrainVector = rValues.GetStrainVector(); + + if( rValues.GetOptions().Is(ConstitutiveLaw::COMPUTE_STRAIN_ENERGY) ) // No contact between interfaces + { + // Tensile stress + if (mStateVariable==0.0) + { + rVariables.YieldStress = rVariables.YoungModulus * 1.0e-7; + } + + rStressVector[0] = rVariables.YieldStress * StrainVector[0]; + rStressVector[1] = rVariables.YieldStress * StrainVector[1]; + rStressVector[2] = rVariables.YieldStress * StrainVector[2]; + } + else // Contact between interfaces + { + // Note: StrainVector[2] < 0.0 + // Note: rStressVector[2] < 0.0 + // Compresive stress + if (mStateVariable==0.0) + { + rVariables.YieldStress = rVariables.YoungModulus * 1.0e-7; + } + + rStressVector[2] = rVariables.YoungModulus * StrainVector[2]; + + const double shear_modulus = rVariables.YoungModulus / (2.0 * (1.0 + rVariables.PoissonCoefficient)); + + double tangential_strain_vector_modulus = sqrt(StrainVector[0] * StrainVector[0] + StrainVector[1] * StrainVector[1]); + + double friction_stress0 = fabs(shear_modulus * StrainVector[0]); + double max_friction_stress0 = fabs(rVariables.FrictionCoefficient * rStressVector[2] * StrainVector[0] / tangential_strain_vector_modulus); + if (friction_stress0 > max_friction_stress0) friction_stress0 = max_friction_stress0; + + double friction_stress1 = fabs(shear_modulus * StrainVector[1]); + double max_friction_stress1 = fabs(rVariables.FrictionCoefficient * rStressVector[2] * StrainVector[1] / tangential_strain_vector_modulus); + if (friction_stress1 > max_friction_stress1) friction_stress1 = max_friction_stress1; + + const double eps = std::numeric_limits::epsilon(); + + if(StrainVector[0] > eps) + { + rStressVector[0] = rVariables.YieldStress * StrainVector[0] + friction_stress0; + } + else if(StrainVector[0] < -eps) + { + rStressVector[0] = rVariables.YieldStress * StrainVector[0] - friction_stress0; + } + else + { + rStressVector[0] = 0.0; + } + + if(StrainVector[1] > eps) + { + rStressVector[1] = rVariables.YieldStress * StrainVector[1] + friction_stress1; + } + else if(StrainVector[1] < -eps) + { + rStressVector[1] = rVariables.YieldStress * StrainVector[1] - friction_stress1; + } + else + { + rStressVector[1] = 0.0; + } + } +} + +} // Namespace Kratos diff --git a/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_3D_law.hpp b/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_3D_law.hpp new file mode 100644 index 000000000000..8eb3def8351b --- /dev/null +++ b/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_3D_law.hpp @@ -0,0 +1,134 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ ` +// _|\_\_| \__,_|\__|\___/ ____/ +// Multi-Physics +// +// License: BSD License +// Kratos default license: kratos/license.txt +// +// Main authors: Javier San Mauro Saiz +// Joaquin Irazabal Gonzalez +// + +#if !defined (KRATOS_SIMPLIFIED_BILINEAR_3D_LAW_H_INCLUDED) +#define KRATOS_SIMPLIFIED_BILINEAR_3D_LAW_H_INCLUDED + +// System includes + +// Project includes +#include "includes/serializer.h" + +// Application includes +#include "custom_constitutive/bilinear_cohesive_3D_law.hpp" +#include "poromechanics_application_variables.h" + +namespace Kratos +{ + +class KRATOS_API(POROMECHANICS_APPLICATION) SimplifiedBilinear3DLaw : public BilinearCohesive3DLaw +{ + +public: + + /// Definition of the base class + typedef BilinearCohesive3DLaw BaseType; + + KRATOS_CLASS_POINTER_DEFINITION(SimplifiedBilinear3DLaw); + +//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + + // Default Constructor + SimplifiedBilinear3DLaw() + { + } + + ConstitutiveLaw::Pointer Clone() const override + { + return Kratos::make_shared(SimplifiedBilinear3DLaw(*this)); + } + + // Copy Constructor + SimplifiedBilinear3DLaw (const SimplifiedBilinear3DLaw& rOther) : BilinearCohesive3DLaw(rOther) + { + } + + // Destructor + ~SimplifiedBilinear3DLaw() override + { + } + +//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + + int Check(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, const ProcessInfo& rCurrentProcessInfo) override; + + void InitializeMaterial( const Properties& rMaterialProperties,const GeometryType& rElementGeometry,const Vector& rShapeFunctionsValues ) override; + +//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + + void CalculateMaterialResponseCauchy (Parameters & rValues) override; + + void FinalizeMaterialResponseCauchy (Parameters & rValues) override; + +//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +protected: + +protected: + + struct ConstitutiveLawVariables + { + double YieldStress; + double YoungModulus; + double MaxTensileStress; + double MaxCompresiveStress; + double PoissonCoefficient; + double FrictionCoefficient; + + Matrix CompressionMatrix; + Matrix WeightMatrix; + + double EquivalentStrain; + bool LoadingFlag; + double LoadingFunction; + }; + + // Member Variables + double mStateVariable; + +//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + + virtual void InitializeConstitutiveLawVariables(ConstitutiveLawVariables& rVariables, Parameters& rValues); + + virtual void ComputeEquivalentStrain(ConstitutiveLawVariables& rVariables, Parameters& rValues); + + virtual void CheckLoadingFunction(ConstitutiveLawVariables& rVariables, Parameters& rValues); + + virtual void ComputeConstitutiveMatrix(Matrix& rConstitutiveMatrix, + ConstitutiveLawVariables& rVariables, + Parameters& rValues); + + virtual void ComputeStressVector(Vector& rStressVector, + ConstitutiveLawVariables& rVariables, + Parameters& rValues); +//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +private: + + // Serialization + + friend class Serializer; + + void save(Serializer& rSerializer) const override + { + KRATOS_SERIALIZE_SAVE_BASE_CLASS( rSerializer, ConstitutiveLaw ) + } + + void load(Serializer& rSerializer) override + { + KRATOS_SERIALIZE_LOAD_BASE_CLASS( rSerializer, ConstitutiveLaw ) + } + +}; // Class SimplifiedBilinear3DLaw +} // namespace Kratos. +#endif // KRATOS_SIMPLIFIED_BILINEAR_3D_LAW_H_INCLUDED defined diff --git a/applications/PoromechanicsApplication/custom_python/add_custom_constitutive_laws_to_python.cpp b/applications/PoromechanicsApplication/custom_python/add_custom_constitutive_laws_to_python.cpp index 7f2085bf4927..b4d97842bb70 100644 --- a/applications/PoromechanicsApplication/custom_python/add_custom_constitutive_laws_to_python.cpp +++ b/applications/PoromechanicsApplication/custom_python/add_custom_constitutive_laws_to_python.cpp @@ -18,6 +18,7 @@ #include "custom_constitutive/bilinear_cohesive_2D_law.hpp" #include "custom_constitutive/exponential_cohesive_3D_law.hpp" #include "custom_constitutive/exponential_cohesive_2D_law.hpp" +#include "custom_constitutive/simplified_bilinear_3D_law.hpp" #include "custom_constitutive/simo_ju_local_damage_3D_law.hpp" #include "custom_constitutive/simo_ju_local_damage_plane_strain_2D_law.hpp" @@ -61,6 +62,9 @@ void AddCustomConstitutiveLawsToPython(pybind11::module& m) py::class_< ExponentialCohesive2DLaw, ExponentialCohesive2DLaw::Pointer, ConstitutiveLaw > (m, "ExponentialCohesive2DLaw") .def( py::init<>() ); + py::class_< SimplifiedBilinear3DLaw, SimplifiedBilinear3DLaw::Pointer, ConstitutiveLaw > + (m, "SimplifiedBilinear3DLaw") + .def( py::init<>() ); py::class_< LinearElastic3DLaw, LinearElastic3DLaw::Pointer, ConstitutiveLaw > (m, "LinearElasticSolid3DLaw") diff --git a/applications/PoromechanicsApplication/poromechanics_application.cpp b/applications/PoromechanicsApplication/poromechanics_application.cpp index fbd899fd93ba..9f7df1362523 100644 --- a/applications/PoromechanicsApplication/poromechanics_application.cpp +++ b/applications/PoromechanicsApplication/poromechanics_application.cpp @@ -181,6 +181,7 @@ void KratosPoromechanicsApplication::Register() KRATOS_REGISTER_CONSTITUTIVE_LAW("BilinearCohesive2DLaw",mBilinearCohesive2DLaw); KRATOS_REGISTER_CONSTITUTIVE_LAW("ExponentialCohesive3DLaw",mExponentialCohesive3DLaw); KRATOS_REGISTER_CONSTITUTIVE_LAW("ExponentialCohesive2DLaw",mExponentialCohesive2DLaw); + KRATOS_REGISTER_CONSTITUTIVE_LAW("SimplifiedBilinear3DLaw",mSimplifiedBilinear3DLaw); KRATOS_REGISTER_CONSTITUTIVE_LAW("LinearElasticSolid3DLaw", mLinearElastic3DLaw); KRATOS_REGISTER_CONSTITUTIVE_LAW("LinearElasticPlaneStrainSolid2DLaw", mLinearElasticPlaneStrain2DLaw); @@ -266,6 +267,8 @@ void KratosPoromechanicsApplication::Register() KRATOS_REGISTER_VARIABLE( NODAL_JOINT_DAMAGE ) KRATOS_REGISTER_VARIABLE( SHEAR_FRACTURE_ENERGY ) + + KRATOS_REGISTER_VARIABLE( MAX_COMPRESSIVE_STRESS ) } }// namespace Kratos. diff --git a/applications/PoromechanicsApplication/poromechanics_application.h b/applications/PoromechanicsApplication/poromechanics_application.h index e27cd66137d3..866fcac5e20d 100644 --- a/applications/PoromechanicsApplication/poromechanics_application.h +++ b/applications/PoromechanicsApplication/poromechanics_application.h @@ -50,6 +50,7 @@ #include "custom_constitutive/bilinear_cohesive_2D_law.hpp" #include "custom_constitutive/exponential_cohesive_3D_law.hpp" #include "custom_constitutive/exponential_cohesive_2D_law.hpp" +#include "custom_constitutive/simplified_bilinear_3D_law.hpp" #include "custom_constitutive/custom_flow_rules/local_damage_flow_rule.hpp" #include "custom_constitutive/custom_flow_rules/nonlocal_damage_flow_rule.hpp" @@ -195,6 +196,7 @@ const BilinearCohesive3DLaw mBilinearCohesive3DLaw; const BilinearCohesive2DLaw mBilinearCohesive2DLaw; const ExponentialCohesive3DLaw mExponentialCohesive3DLaw; const ExponentialCohesive2DLaw mExponentialCohesive2DLaw; +const SimplifiedBilinear3DLaw mSimplifiedBilinear3DLaw; const LocalDamageFlowRule mLocalDamageFlowRule; const NonlocalDamageFlowRule mNonlocalDamageFlowRule; diff --git a/applications/PoromechanicsApplication/poromechanics_application_variables.cpp b/applications/PoromechanicsApplication/poromechanics_application_variables.cpp index 71929f371bc7..35dae8732029 100644 --- a/applications/PoromechanicsApplication/poromechanics_application_variables.cpp +++ b/applications/PoromechanicsApplication/poromechanics_application_variables.cpp @@ -69,4 +69,6 @@ KRATOS_CREATE_VARIABLE( double, NODAL_JOINT_WIDTH ) KRATOS_CREATE_VARIABLE( double, NODAL_JOINT_DAMAGE ) KRATOS_CREATE_VARIABLE( double, SHEAR_FRACTURE_ENERGY ) + +KRATOS_CREATE_VARIABLE( double, MAX_COMPRESSIVE_STRESS ) } diff --git a/applications/PoromechanicsApplication/poromechanics_application_variables.h b/applications/PoromechanicsApplication/poromechanics_application_variables.h index c292dd4c74ef..940a98fc1c20 100644 --- a/applications/PoromechanicsApplication/poromechanics_application_variables.h +++ b/applications/PoromechanicsApplication/poromechanics_application_variables.h @@ -81,6 +81,8 @@ KRATOS_DEFINE_APPLICATION_VARIABLE( POROMECHANICS_APPLICATION, double, NODAL_JOI KRATOS_DEFINE_APPLICATION_VARIABLE( POROMECHANICS_APPLICATION, double, NODAL_JOINT_DAMAGE ) KRATOS_DEFINE_APPLICATION_VARIABLE( POROMECHANICS_APPLICATION, double, SHEAR_FRACTURE_ENERGY ) + +KRATOS_DEFINE_APPLICATION_VARIABLE( POROMECHANICS_APPLICATION, double, MAX_COMPRESSIVE_STRESS ) } #endif /* KRATOS_POROMECHANICS_APPLICATION_VARIABLES_H_INCLUDED */ From 5524541ed8f47008d26ebedc59811b2d81ae92fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20Irazabal?= Date: Thu, 23 Apr 2020 13:57:40 +0200 Subject: [PATCH 215/314] Adding simplified_bilinear_2D_law --- .../PoromechanicsApplication/CMakeLists.txt | 1 + .../simplified_bilinear_2D_law.cpp | 164 ++++++++++++++++++ .../simplified_bilinear_2D_law.hpp | 93 ++++++++++ .../simplified_bilinear_3D_law.cpp | 50 +++--- ...add_custom_constitutive_laws_to_python.cpp | 4 + .../poromechanics_application.cpp | 1 + .../poromechanics_application.h | 2 + 7 files changed, 286 insertions(+), 29 deletions(-) create mode 100644 applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_2D_law.cpp create mode 100644 applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_2D_law.hpp diff --git a/applications/PoromechanicsApplication/CMakeLists.txt b/applications/PoromechanicsApplication/CMakeLists.txt index 1519b69bcb3e..cfd6fd5c6059 100644 --- a/applications/PoromechanicsApplication/CMakeLists.txt +++ b/applications/PoromechanicsApplication/CMakeLists.txt @@ -28,6 +28,7 @@ set( KRATOS_POROMECHANICS_APPLICATION_CORE_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/custom_constitutive/exponential_cohesive_3D_law.cpp ${CMAKE_CURRENT_SOURCE_DIR}/custom_constitutive/exponential_cohesive_2D_law.cpp ${CMAKE_CURRENT_SOURCE_DIR}/custom_constitutive/simplified_bilinear_3D_law.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/custom_constitutive/simplified_bilinear_2D_law.cpp ${CMAKE_CURRENT_SOURCE_DIR}/custom_constitutive/local_damage_3D_law.cpp ${CMAKE_CURRENT_SOURCE_DIR}/custom_constitutive/local_damage_plane_strain_2D_law.cpp ${CMAKE_CURRENT_SOURCE_DIR}/custom_constitutive/local_damage_plane_stress_2D_law.cpp diff --git a/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_2D_law.cpp b/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_2D_law.cpp new file mode 100644 index 000000000000..3e581159b38b --- /dev/null +++ b/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_2D_law.cpp @@ -0,0 +1,164 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ ` +// _|\_\_| \__,_|\__|\___/ ____/ +// Multi-Physics +// +// License: BSD License +// Kratos default license: kratos/license.txt +// +// Main authors: Javier San Mauro Saiz +// Joaquin Irazabal Gonzalez +// + +// Application includes +#include "custom_constitutive/simplified_bilinear_2D_law.hpp" + +namespace Kratos +{ + +void SimplifiedBilinear2DLaw::ComputeEquivalentStrain(ConstitutiveLawVariables& rVariables, + Parameters& rValues) +{ + const Vector& StrainVector = rValues.GetStrainVector(); + + if( rValues.GetOptions().Is(ConstitutiveLaw::COMPUTE_STRAIN_ENERGY) ) // No contact between interfaces + { + rVariables.EquivalentStrain = 1.0; + if (mStateVariable == 1.0) + { + if((StrainVector[0] * rVariables.YieldStress) > rVariables.MaxTensileStress) + { + rVariables.EquivalentStrain = 0.0; + } + if(fabs(rVariables.YieldStress * StrainVector[1]) > rVariables.MaxTensileStress) + { + rVariables.EquivalentStrain = 0.0; + } + } + } + + else // Contact between interfaces + { + rVariables.EquivalentStrain = 1.0; + if (mStateVariable == 1.0) + { + if((StrainVector[0] * rVariables.YieldStress) > rVariables.MaxTensileStress) + { + rVariables.EquivalentStrain = 0.0; + } + if(fabs(rVariables.YoungModulus * StrainVector[1]) > rVariables.MaxCompresiveStress) + { + rVariables.EquivalentStrain = 0.0; + } + } + } +} + +//---------------------------------------------------------------------------------------- + +void SimplifiedBilinear2DLaw::ComputeConstitutiveMatrix(Matrix& rConstitutiveMatrix, + ConstitutiveLawVariables& rVariables, + Parameters& rValues) +{ + const Vector& StrainVector = rValues.GetStrainVector(); + + if( rValues.GetOptions().Is(ConstitutiveLaw::COMPUTE_STRAIN_ENERGY) ) // No contact between interfaces + { + // Unloading -> Tensile constitutive matrix + if (mStateVariable == 0.0) + { + rVariables.YieldStress = rVariables.YoungModulus * 1.0e-7; + } + + rConstitutiveMatrix(0,0) = rVariables.YieldStress; + rConstitutiveMatrix(1,1) = rConstitutiveMatrix(0,0); + + rConstitutiveMatrix(0,1) = 0.0; + rConstitutiveMatrix(1,0) = 0.0; + } + + else // Contact between interfaces + { + // Unloading- > Compresive constitutive matrix + if (mStateVariable == 0.0) + { + rVariables.YieldStress = rVariables.YoungModulus * 1.0e-7; + } + + rConstitutiveMatrix(0,0) = rVariables.YieldStress; + rConstitutiveMatrix(1,1) = rVariables.YoungModulus; + + const double eps = std::numeric_limits::epsilon(); + + if(StrainVector[0] > eps) + { + rConstitutiveMatrix(0,1) =-rVariables.YoungModulus * rVariables.FrictionCoefficient; + } + else if(StrainVector[0] < -eps) + { + rConstitutiveMatrix(0,1) = rVariables.YoungModulus * rVariables.FrictionCoefficient; + } + else + { + rConstitutiveMatrix(0,1) = 0.0; + } + + rConstitutiveMatrix(1,0) = 0.0; + } +} + +//---------------------------------------------------------------------------------------- + +void SimplifiedBilinear2DLaw::ComputeStressVector(Vector& rStressVector, + ConstitutiveLawVariables& rVariables, + Parameters& rValues) +{ +const Vector& StrainVector = rValues.GetStrainVector(); + + if( rValues.GetOptions().Is(ConstitutiveLaw::COMPUTE_STRAIN_ENERGY) ) // No contact between interfaces + { + // Tensile stress + if (mStateVariable == 0.0) + { + rVariables.YieldStress = rVariables.YoungModulus * 1.0e-7; + } + + rStressVector[0] = rVariables.YieldStress * StrainVector[0]; + rStressVector[1] = rVariables.YieldStress * StrainVector[1]; + } + + else // Contact between interfaces + { + // Note: StrainVector[1] < 0.0, rStressVector[1] < 0.0 -> Compresive stress + if (mStateVariable==0.0) + { + rVariables.YieldStress = rVariables.YoungModulus * 1.0e-7; + } + + rStressVector[1] = rVariables.YoungModulus * StrainVector[1]; + + const double shear_modulus = rVariables.YoungModulus / (2.0 * (1.0 + rVariables.PoissonCoefficient)); + + double friction_stress = fabs(shear_modulus * StrainVector[0]); + double max_friction_stress = fabs(rVariables.FrictionCoefficient * rStressVector[2] * StrainVector[0]); + if (friction_stress > max_friction_stress) friction_stress = max_friction_stress; + + const double eps = std::numeric_limits::epsilon(); + + if(StrainVector[0] > eps) + { + rStressVector[0] = rVariables.YieldStress * StrainVector[0] + friction_stress; + } + else if(StrainVector[0] < -eps) + { + rStressVector[0] = rVariables.YieldStress * StrainVector[0] - friction_stress; + } + else + { + rStressVector[0] = 0.0; + } + } +} + +} // Namespace Kratos diff --git a/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_2D_law.hpp b/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_2D_law.hpp new file mode 100644 index 000000000000..6f5eda1977de --- /dev/null +++ b/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_2D_law.hpp @@ -0,0 +1,93 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ ` +// _|\_\_| \__,_|\__|\___/ ____/ +// Multi-Physics +// +// License: BSD License +// Kratos default license: kratos/license.txt +// +// Main authors: Ignasi de Pouplana +// + +#if !defined (KRATOS_SIMPLIFIED_BILINEAR_2D_LAW_H_INCLUDED) +#define KRATOS_SIMPLIFIED_BILINEAR_2D_LAW_H_INCLUDED + +// Project includes +#include "includes/serializer.h" + +// Application includes +#include "custom_constitutive/simplified_bilinear_3D_law.hpp" +#include "poromechanics_application_variables.h" + +namespace Kratos +{ + +class KRATOS_API(POROMECHANICS_APPLICATION) SimplifiedBilinear2DLaw : public SimplifiedBilinear3DLaw +{ + +public: + + KRATOS_CLASS_POINTER_DEFINITION(SimplifiedBilinear2DLaw); + +//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + + // Default Constructor + SimplifiedBilinear2DLaw() + { + } + + ConstitutiveLaw::Pointer Clone() const override + { + return Kratos::make_shared(SimplifiedBilinear2DLaw(*this)); + } + + // Copy Constructor + SimplifiedBilinear2DLaw (const SimplifiedBilinear2DLaw& rOther) : SimplifiedBilinear3DLaw(rOther) + { + } + + // Destructor + ~SimplifiedBilinear2DLaw() override + { + } + +//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +protected: + + // Member Variables + +//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + + void ComputeEquivalentStrain(ConstitutiveLawVariables& rVariables, Parameters& rValues) override; + + void ComputeConstitutiveMatrix(Matrix& rConstitutiveMatrix, + ConstitutiveLawVariables& rVariables, + Parameters& rValues) override; + + void ComputeStressVector(Vector& rStressVector, + ConstitutiveLawVariables& rVariables, + Parameters& rValues) override; + +//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +private: + + // Serialization + + friend class Serializer; + + void save(Serializer& rSerializer) const override + { + KRATOS_SERIALIZE_SAVE_BASE_CLASS( rSerializer, ConstitutiveLaw ) + } + + void load(Serializer& rSerializer) override + { + KRATOS_SERIALIZE_LOAD_BASE_CLASS( rSerializer, ConstitutiveLaw ) + } + +}; // Class SimplifiedBilinear2DLaw +} // namespace Kratos. +#endif // KRATOS_SIMPLIFIED_BILINEAR_2D_LAW_H_INCLUDED defined diff --git a/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_3D_law.cpp b/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_3D_law.cpp index 576688909933..6325a6952cb2 100644 --- a/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_3D_law.cpp +++ b/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_3D_law.cpp @@ -155,7 +155,7 @@ void SimplifiedBilinear3DLaw::ComputeEquivalentStrain(ConstitutiveLawVariables& rVariables.EquivalentStrain = 0.0; } } - } + } else // Contact between interfaces { rVariables.EquivalentStrain = 1.0; @@ -198,36 +198,31 @@ void SimplifiedBilinear3DLaw::ComputeConstitutiveMatrix(Matrix& rConstitutiveMat if( rValues.GetOptions().Is(ConstitutiveLaw::COMPUTE_STRAIN_ENERGY) ) // No contact between interfaces { + // Unloading -> Tensile constitutive matrix + if (mStateVariable == 0.0) + { + rVariables.YieldStress= rVariables.YoungModulus * 1.0e-7; + } - // Unloading - - // Tensile constitutive matrix - if (mStateVariable == 0.0) - { - rVariables.YieldStress= rVariables.YoungModulus * 1.0e-7; - } - - rConstitutiveMatrix(0,0) = rVariables.YieldStress; - rConstitutiveMatrix(1,1) = rConstitutiveMatrix(0,0); - rConstitutiveMatrix(2,2) = rConstitutiveMatrix(0,0); + rConstitutiveMatrix(0,0) = rVariables.YieldStress; + rConstitutiveMatrix(1,1) = rConstitutiveMatrix(0,0); + rConstitutiveMatrix(2,2) = rConstitutiveMatrix(0,0); - rConstitutiveMatrix(0,1) = 0.0; - rConstitutiveMatrix(0,2) = 0.0; - rConstitutiveMatrix(1,2) = 0.0; - rConstitutiveMatrix(1,0) = 0.0; - rConstitutiveMatrix(2,0) = 0.0; - rConstitutiveMatrix(2,1) = 0.0; + rConstitutiveMatrix(0,1) = 0.0; + rConstitutiveMatrix(0,2) = 0.0; + rConstitutiveMatrix(1,2) = 0.0; + rConstitutiveMatrix(1,0) = 0.0; + rConstitutiveMatrix(2,0) = 0.0; + rConstitutiveMatrix(2,1) = 0.0; } + else // Contact between interfaces { - - // Unloading - - // Compresive constitutive matrix - if (mStateVariable==0.0) + // Unloading -> Compresive constitutive matrix + if (mStateVariable == 0.0) { - rVariables.YieldStress=2.0e3; + rVariables.YieldStress= rVariables.YoungModulus * 1.0e-7; } rConstitutiveMatrix(0,0) = rVariables.YieldStress; @@ -267,7 +262,6 @@ void SimplifiedBilinear3DLaw::ComputeConstitutiveMatrix(Matrix& rConstitutiveMat rConstitutiveMatrix(1,0) = 0.0; rConstitutiveMatrix(2,0) = 0.0; rConstitutiveMatrix(2,1) = 0.0; - } } @@ -284,7 +278,7 @@ void SimplifiedBilinear3DLaw::ComputeStressVector(Vector& rStressVector, // Tensile stress if (mStateVariable==0.0) { - rVariables.YieldStress = rVariables.YoungModulus * 1.0e-7; + rVariables.YieldStress = rVariables.YoungModulus * 1.0e-7; } rStressVector[0] = rVariables.YieldStress * StrainVector[0]; @@ -293,9 +287,7 @@ void SimplifiedBilinear3DLaw::ComputeStressVector(Vector& rStressVector, } else // Contact between interfaces { - // Note: StrainVector[2] < 0.0 - // Note: rStressVector[2] < 0.0 - // Compresive stress + // Note: StrainVector[1] < 0.0, rStressVector[1] < 0.0 -> Compresive stress if (mStateVariable==0.0) { rVariables.YieldStress = rVariables.YoungModulus * 1.0e-7; diff --git a/applications/PoromechanicsApplication/custom_python/add_custom_constitutive_laws_to_python.cpp b/applications/PoromechanicsApplication/custom_python/add_custom_constitutive_laws_to_python.cpp index b4d97842bb70..f52c7f7d2894 100644 --- a/applications/PoromechanicsApplication/custom_python/add_custom_constitutive_laws_to_python.cpp +++ b/applications/PoromechanicsApplication/custom_python/add_custom_constitutive_laws_to_python.cpp @@ -19,6 +19,7 @@ #include "custom_constitutive/exponential_cohesive_3D_law.hpp" #include "custom_constitutive/exponential_cohesive_2D_law.hpp" #include "custom_constitutive/simplified_bilinear_3D_law.hpp" +#include "custom_constitutive/simplified_bilinear_2D_law.hpp" #include "custom_constitutive/simo_ju_local_damage_3D_law.hpp" #include "custom_constitutive/simo_ju_local_damage_plane_strain_2D_law.hpp" @@ -65,6 +66,9 @@ void AddCustomConstitutiveLawsToPython(pybind11::module& m) py::class_< SimplifiedBilinear3DLaw, SimplifiedBilinear3DLaw::Pointer, ConstitutiveLaw > (m, "SimplifiedBilinear3DLaw") .def( py::init<>() ); + py::class_< SimplifiedBilinear2DLaw, SimplifiedBilinear2DLaw::Pointer, ConstitutiveLaw > + (m, "SimplifiedBilinear2DLaw") + .def( py::init<>() ); py::class_< LinearElastic3DLaw, LinearElastic3DLaw::Pointer, ConstitutiveLaw > (m, "LinearElasticSolid3DLaw") diff --git a/applications/PoromechanicsApplication/poromechanics_application.cpp b/applications/PoromechanicsApplication/poromechanics_application.cpp index 9f7df1362523..1ca8fce0f60a 100644 --- a/applications/PoromechanicsApplication/poromechanics_application.cpp +++ b/applications/PoromechanicsApplication/poromechanics_application.cpp @@ -182,6 +182,7 @@ void KratosPoromechanicsApplication::Register() KRATOS_REGISTER_CONSTITUTIVE_LAW("ExponentialCohesive3DLaw",mExponentialCohesive3DLaw); KRATOS_REGISTER_CONSTITUTIVE_LAW("ExponentialCohesive2DLaw",mExponentialCohesive2DLaw); KRATOS_REGISTER_CONSTITUTIVE_LAW("SimplifiedBilinear3DLaw",mSimplifiedBilinear3DLaw); + KRATOS_REGISTER_CONSTITUTIVE_LAW("SimplifiedBilinear2DLaw",mSimplifiedBilinear2DLaw); KRATOS_REGISTER_CONSTITUTIVE_LAW("LinearElasticSolid3DLaw", mLinearElastic3DLaw); KRATOS_REGISTER_CONSTITUTIVE_LAW("LinearElasticPlaneStrainSolid2DLaw", mLinearElasticPlaneStrain2DLaw); diff --git a/applications/PoromechanicsApplication/poromechanics_application.h b/applications/PoromechanicsApplication/poromechanics_application.h index 866fcac5e20d..5271e2ebeef3 100644 --- a/applications/PoromechanicsApplication/poromechanics_application.h +++ b/applications/PoromechanicsApplication/poromechanics_application.h @@ -51,6 +51,7 @@ #include "custom_constitutive/exponential_cohesive_3D_law.hpp" #include "custom_constitutive/exponential_cohesive_2D_law.hpp" #include "custom_constitutive/simplified_bilinear_3D_law.hpp" +#include "custom_constitutive/simplified_bilinear_2D_law.hpp" #include "custom_constitutive/custom_flow_rules/local_damage_flow_rule.hpp" #include "custom_constitutive/custom_flow_rules/nonlocal_damage_flow_rule.hpp" @@ -197,6 +198,7 @@ const BilinearCohesive2DLaw mBilinearCohesive2DLaw; const ExponentialCohesive3DLaw mExponentialCohesive3DLaw; const ExponentialCohesive2DLaw mExponentialCohesive2DLaw; const SimplifiedBilinear3DLaw mSimplifiedBilinear3DLaw; +const SimplifiedBilinear2DLaw mSimplifiedBilinear2DLaw; const LocalDamageFlowRule mLocalDamageFlowRule; const NonlocalDamageFlowRule mNonlocalDamageFlowRule; From c846988d6c260450f7572b0073f01c84b58cb5ef Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Thu, 23 Apr 2020 23:33:05 +1000 Subject: [PATCH 216/314] add const to quad calculateandaddRHS --- .../custom_elements/updated_lagrangian_quadrilateral.cpp | 2 +- .../custom_elements/updated_lagrangian_quadrilateral.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index 582077a835cb..5097b48e1f3c 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -472,7 +472,7 @@ void UpdatedLagrangianQuadrilateral::CalculateAndAddRHS( GeneralVariables& rVariables, Vector& rVolumeForce, const double& rIntegrationWeight, - ProcessInfo& rCurrentProcessInfo) + const ProcessInfo& rCurrentProcessInfo) { // Contribution of the internal and external forces if( rLocalSystem.CalculationFlags.Is( UpdatedLagrangianQuadrilateral::COMPUTE_RHS_VECTOR_WITH_COMPONENTS ) ) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp index 793a136c5617..5ec6783165bd 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp @@ -646,7 +646,7 @@ class UpdatedLagrangianQuadrilateral GeneralVariables& rVariables, Vector& rVolumeForce, const double& rIntegrationWeight, - ProcessInfo& rCurrentProcessInfo); + const ProcessInfo& rCurrentProcessInfo); /** From 23fbf08c5b2a19c07cbfdc23cd251867be0ad3b6 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Thu, 23 Apr 2020 23:35:41 +1000 Subject: [PATCH 217/314] lower case r_process_info in search utility --- .../custom_utilities/mpm_search_element_utility.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h b/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h index 625cc10ad04d..d79959fbe5aa 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h @@ -47,8 +47,8 @@ namespace MPMSearchElementUtility void SearchElement(ModelPart& rBackgroundGridModelPart, ModelPart& rMPMModelPart, const std::size_t MaxNumberOfResults, const double Tolerance) { - const ProcessInfo& rProcessInfo = rBackgroundGridModelPart.GetProcessInfo(); - const bool is_explicit = rProcessInfo.GetValue(IS_EXPLICIT); + const ProcessInfo& r_process_info = rBackgroundGridModelPart.GetProcessInfo(); + const bool is_explicit = r_process_info.GetValue(IS_EXPLICIT); // Reset elements to inactive #pragma omp parallel for From 4715dedb1860e6d993b153c57cd06f5e222ab3ee Mon Sep 17 00:00:00 2001 From: Miguel Angel Celigueta Date: Thu, 23 Apr 2020 17:40:22 +0200 Subject: [PATCH 218/314] Add restart tests to nightly tests Co-Authored-By: Philipp Bucher --- applications/DEMApplication/tests/test_DEMApplication.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/applications/DEMApplication/tests/test_DEMApplication.py b/applications/DEMApplication/tests/test_DEMApplication.py index 2822eec4da38..a99cf5269cbb 100644 --- a/applications/DEMApplication/tests/test_DEMApplication.py +++ b/applications/DEMApplication/tests/test_DEMApplication.py @@ -57,11 +57,11 @@ def AssembleTestSuites(): smallSuite.addTest(test_DEM_3D_continuum.TestDEM3DContinuum("test_DEM3D_continuum")) - #smallSuite.addTest(test_restart.TestRestartOneBall("test_execution")) - #smallSuite.addTest(test_restart.TestRestartTwoBalls("test_execution")) - # Create a test suit with the selected tests plus all small tests nightSuite = suites['nightly'] + + nightSuite.addTest(test_restart.TestRestartOneBall("test_execution")) + nightSuite.addTest(test_restart.TestRestartTwoBalls("test_execution")) nightSuite.addTests(smallSuite) # For very long tests that should not be in nightly and you can use to validate From 42c8d03302cb6e334bc598b5a078283000166ee5 Mon Sep 17 00:00:00 2001 From: eloisabaez Date: Thu, 23 Apr 2020 18:44:10 +0200 Subject: [PATCH 219/314] addressing pull request comments --- ...ompressible_potential_flow_application.cpp | 1 + ...e_potential_flow_application_variables.cpp | 2 +- ...ble_potential_flow_application_variables.h | 2 +- .../potential_flow_utilities.cpp | 318 ++++++++++-------- .../potential_flow_utilities.h | 37 +- .../test_potential_flow_utilities.cpp | 269 ++++++++------- 6 files changed, 337 insertions(+), 292 deletions(-) diff --git a/applications/CompressiblePotentialFlowApplication/compressible_potential_flow_application.cpp b/applications/CompressiblePotentialFlowApplication/compressible_potential_flow_application.cpp index c7ef4c82015c..263f1f785108 100644 --- a/applications/CompressiblePotentialFlowApplication/compressible_potential_flow_application.cpp +++ b/applications/CompressiblePotentialFlowApplication/compressible_potential_flow_application.cpp @@ -101,6 +101,7 @@ void KratosCompressiblePotentialFlowApplication::Register() // Solver parameters KRATOS_REGISTER_VARIABLE(MACH_LIMIT) + KRATOS_REGISTER_VARIABLE(MACH_SQUARED_LIMIT) // Markers KRATOS_REGISTER_VARIABLE(WAKE); diff --git a/applications/CompressiblePotentialFlowApplication/compressible_potential_flow_application_variables.cpp b/applications/CompressiblePotentialFlowApplication/compressible_potential_flow_application_variables.cpp index 1dad0e56e9ca..90ef3fbc3470 100644 --- a/applications/CompressiblePotentialFlowApplication/compressible_potential_flow_application_variables.cpp +++ b/applications/CompressiblePotentialFlowApplication/compressible_potential_flow_application_variables.cpp @@ -26,7 +26,6 @@ KRATOS_CREATE_VARIABLE(double, PRESSURE_LOWER) KRATOS_CREATE_VARIABLE(double, POTENTIAL_JUMP) KRATOS_CREATE_VARIABLE(double, ENERGY_NORM_REFERENCE) KRATOS_CREATE_VARIABLE(double, POTENTIAL_ENERGY_REFERENCE) -KRATOS_CREATE_VARIABLE(double, MACH_SQUARED_LIMIT) // Free stream magnitudes KRATOS_CREATE_3D_VARIABLE_WITH_COMPONENTS(FREE_STREAM_VELOCITY) @@ -48,6 +47,7 @@ KRATOS_CREATE_3D_VARIABLE_WITH_COMPONENTS(WING_SPAN_DIRECTION) // Solver parameters KRATOS_CREATE_VARIABLE(double, MACH_LIMIT) +KRATOS_CREATE_VARIABLE(double, MACH_SQUARED_LIMIT) // Markers KRATOS_CREATE_VARIABLE(int, WAKE) diff --git a/applications/CompressiblePotentialFlowApplication/compressible_potential_flow_application_variables.h b/applications/CompressiblePotentialFlowApplication/compressible_potential_flow_application_variables.h index 49e20183fe46..28265f6e4539 100644 --- a/applications/CompressiblePotentialFlowApplication/compressible_potential_flow_application_variables.h +++ b/applications/CompressiblePotentialFlowApplication/compressible_potential_flow_application_variables.h @@ -49,7 +49,6 @@ KRATOS_DEFINE_APPLICATION_VARIABLE(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION, doub KRATOS_DEFINE_APPLICATION_VARIABLE(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION, double, POTENTIAL_JUMP) KRATOS_DEFINE_APPLICATION_VARIABLE(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION, double, ENERGY_NORM_REFERENCE) KRATOS_DEFINE_APPLICATION_VARIABLE(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION, double, POTENTIAL_ENERGY_REFERENCE) -KRATOS_DEFINE_APPLICATION_VARIABLE(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION, double, MACH_SQUARED_LIMIT) // Free stream magnitudes KRATOS_DEFINE_3D_APPLICATION_VARIABLE_WITH_COMPONENTS(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION, FREE_STREAM_VELOCITY) @@ -71,6 +70,7 @@ KRATOS_DEFINE_3D_APPLICATION_VARIABLE_WITH_COMPONENTS(COMPRESSIBLE_POTENTIAL_FLO // Solver parameters KRATOS_DEFINE_APPLICATION_VARIABLE(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION, double, MACH_LIMIT) +KRATOS_DEFINE_APPLICATION_VARIABLE(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION, double, MACH_SQUARED_LIMIT) // Markers KRATOS_DEFINE_APPLICATION_VARIABLE(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION, int, WAKE) diff --git a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp index 2c7f405fc476..2e409a736b68 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp +++ b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp @@ -117,6 +117,84 @@ array_1d ComputeVelocity(const Element& rElement) return ComputeVelocityUpperWakeElement(rElement); } +template +double ComputeMaximumVelocitySquared(const ProcessInfo& rCurrentProcessInfo) +{ + // Following Fully Simulataneous Coupling of the Full Potential Equation + // and the Integral Boundary Layer Equations in Three Dimensions + // by Brian Nishida (1996), Section A.2 and Section 2.5 + + // maximum local squared mach number (user defined, 3.0 used as default) + const double max_local_mach_squared = rCurrentProcessInfo[MACH_SQUARED_LIMIT]; + + // read free stream values + const double heat_capacity_ratio = rCurrentProcessInfo[HEAT_CAPACITY_RATIO]; + const double free_stream_mach = rCurrentProcessInfo[FREE_STREAM_MACH]; + const array_1d free_stream_velocity = rCurrentProcessInfo[FREE_STREAM_VELOCITY]; + + // make squares of values + const double free_stream_mach_squared = std::pow(free_stream_mach, 2); + const double free_stream_velocity_squared = inner_prod(free_stream_velocity, free_stream_velocity); + + // calculate velocity + const double numerator = (2.0 + (heat_capacity_ratio - 1) * free_stream_mach_squared ); + const double denominator = (2.0 + (heat_capacity_ratio - 1) * max_local_mach_squared ); + const double factor = free_stream_velocity_squared * max_local_mach_squared / free_stream_mach_squared; + + return factor * numerator / denominator; +} + +// This function returns the square of the magnitude of the velocity, +// clamping it if it is over the maximum allowed +template +double ComputeClampedVelocitySquared( + const array_1d& rVelocity, + const ProcessInfo& rCurrentProcessInfo) +{ + // compute max velocity allowed by limit Mach number + const double max_velocity_squared = ComputeMaximumVelocitySquared(rCurrentProcessInfo); + double local_velocity_squared = inner_prod(rVelocity, rVelocity); + + // check if local velocity should be changed + if (local_velocity_squared > max_velocity_squared) + { + KRATOS_WARNING("Clamped local velocity") << + "SQUARE OF LOCAL VELOCITY ABOVE ALLOWED SQUARE OF VELOCITY" + << " local_velocity_squared = " << local_velocity_squared + << " max_velocity_squared = " << max_velocity_squared << std::endl; + + local_velocity_squared = max_velocity_squared; + } + + return local_velocity_squared; +} + +template +double ComputeVelocityMagnitude( + const double localMachNumberSquared, + const ProcessInfo& rCurrentProcessInfo) +{ + // Following Fully Simulataneous Coupling of the Full Potential Equation + // and the Integral Boundary Layer Equations in Three Dimensions + // by Brian Nishida (1996), Section A.2 and Section 2.5 + + // read free stream values + const double heat_capacity_ratio = rCurrentProcessInfo[HEAT_CAPACITY_RATIO]; + const double free_stream_mach = rCurrentProcessInfo[FREE_STREAM_MACH]; + const array_1d free_stream_velocity = rCurrentProcessInfo[FREE_STREAM_VELOCITY]; + + // make squares of values + const double free_stream_mach_squared = std::pow(free_stream_mach, 2); + const double free_stream_velocity_squared = inner_prod(free_stream_velocity, free_stream_velocity); + + // calculate velocity + const double numerator = (2.0 + (heat_capacity_ratio - 1) * free_stream_mach_squared ); + const double denominator = (2.0 + (heat_capacity_ratio - 1) * localMachNumberSquared ); + const double factor = free_stream_velocity_squared * localMachNumberSquared / free_stream_mach_squared; + + return factor * numerator / denominator; +} + template array_1d ComputeVelocityNormalElement(const Element& rElement) { @@ -279,6 +357,47 @@ double ComputeLocalSpeedOfSound(const Element& rElement, const ProcessInfo& rCur return a_inf * sqrt(1 + (heat_capacity_ratio - 1) * M_inf_2 * (1 - v_2 / v_inf_2) / 2); } +template +double ComputeLocalSpeedofSoundSquared( + const array_1d& rVelocity, + const ProcessInfo& rCurrentProcessInfo) +{ + // Implemented according to Equation 8.7 of Drela, M. (2014) Flight Vehicle + // Aerodynamics, The MIT Press, London + + // read free stream values + const double free_stream_speed_sound = rCurrentProcessInfo[SOUND_VELOCITY]; + + // make squares of value + const double free_stream_speed_sound_squared = std::pow(free_stream_speed_sound,2); + + // computes square of velocity including clamping according to MACH_SQUARED_LIMIT + const double local_velocity_squared = ComputeClampedVelocitySquared(rVelocity, rCurrentProcessInfo); + + // computes square bracket term with clamped velocity squared + const double speed_of_sound_factor = ComputeSquaredSpeedofSoundFactor(local_velocity_squared, rCurrentProcessInfo); + + return free_stream_speed_sound_squared * speed_of_sound_factor; +} + +template +double ComputeSquaredSpeedofSoundFactor( + const double localVelocitySquared, + const ProcessInfo& rCurrentProcessInfo) +{ + // read free stream values + const double heat_capacity_ratio = rCurrentProcessInfo[HEAT_CAPACITY_RATIO]; + const double free_stream_mach = rCurrentProcessInfo[FREE_STREAM_MACH]; + const array_1d free_stream_velocity = rCurrentProcessInfo[FREE_STREAM_VELOCITY]; + + // make squares of values + const double free_stream_mach_squared = std::pow(free_stream_mach, 2); + const double free_stream_velocity_squared = inner_prod(free_stream_velocity, free_stream_velocity); + + return 1.0 + 0.5*(heat_capacity_ratio - 1.0)* + free_stream_mach_squared*(1.0 - (localVelocitySquared/free_stream_velocity_squared)); +} + template double ComputePerturbationLocalSpeedOfSound(const Element& rElement, const ProcessInfo& rCurrentProcessInfo) { @@ -321,6 +440,52 @@ double ComputeLocalMachNumber(const Element& rElement, const ProcessInfo& rCurre return velocity_module / local_speed_of_sound; } +template +double ComputeLocalMachNumberSquared( + const array_1d& rVelocity, + const ProcessInfo& rCurrentProcessInfo) +{ + // Implemented according to Equation 8.8 of + // Drela, M. (2014) Flight VehicleAerodynamics, The MIT Press, London + + const double local_speed_of_sound_squared = ComputeLocalSpeedofSoundSquared(rVelocity, rCurrentProcessInfo); + + // computes square of velocity including clamping according to MACH_SQUARED_LIMIT + const double local_velocity_squared = ComputeClampedVelocitySquared(rVelocity, rCurrentProcessInfo); + + return local_velocity_squared / local_speed_of_sound_squared; +} + +template +double ComputeDerivativeLocalMachSquaredWRTVelocitySquared( + const array_1d& rVelocity, + const double localMachNumberSquared, + const ProcessInfo& rCurrentProcessInfo) +{ + // Following Fully Simulataneous Coupling of the Full Potential Equation + // and the Integral Boundary Layer Equations in Three Dimensions + // by Brian Nishida (1996), Section A.2.3 + + // read free stream values + const double heat_capacity_ratio = rCurrentProcessInfo[HEAT_CAPACITY_RATIO]; + const double free_stream_mach = rCurrentProcessInfo[FREE_STREAM_MACH]; + const array_1d free_stream_velocity = rCurrentProcessInfo[FREE_STREAM_VELOCITY]; + + // make squares of values + const double free_stream_mach_squared = std::pow(free_stream_mach, 2); + const double free_stream_velocity_squared = inner_prod(free_stream_velocity, free_stream_velocity); + + // computes square of velocity including clamping according to MACH_SQUARED_LIMIT + const double local_velocity_squared = ComputeClampedVelocitySquared(rVelocity, rCurrentProcessInfo); + + // square bracket term + const double speed_of_sound_factor = ComputeSquaredSpeedofSoundFactor(local_velocity_squared, rCurrentProcessInfo); + + // calculate mach derivative + return localMachNumberSquared * ((1.0/local_velocity_squared) + + 0.5*(heat_capacity_ratio - 1.0)*(1.0/free_stream_velocity_squared)*free_stream_mach_squared*(1.0/speed_of_sound_factor)); +} + template double ComputePerturbationLocalMachNumber(const Element& rElement, const ProcessInfo& rCurrentProcessInfo) { @@ -416,134 +581,6 @@ bool CheckWakeCondition(const Element& rElement, const double& rTolerance, const return wake_condition_is_fulfilled; } -template -double ComputeLocalMachSquaredDerivative( - const array_1d& rVelocity, - const double localMachNumber, - const ProcessInfo& rCurrentProcessInfo) -{ - // Following Fully Simulataneous Coupling of the Full Potential Equation - // and the Integral Boundary Layer Equations in Three Dimensions - // by Brian Nishida (1996), Section A.2 - - // read free stream values - const double heat_capacity_ratio = rCurrentProcessInfo[HEAT_CAPACITY_RATIO]; - const double free_stream_mach = rCurrentProcessInfo[FREE_STREAM_MACH]; - const array_1d free_stream_velocity = rCurrentProcessInfo[FREE_STREAM_VELOCITY]; - - // make squares of values - const double sq_local_mach_number = std::pow(localMachNumber, 2); - const double sq_free_stream_mach = std::pow(free_stream_mach, 2); - const double sq_free_stream_velocity = inner_prod(free_stream_velocity, free_stream_velocity); - - // computes square of velocity including clamping according to MACH_SQUARED_LIMIT - const double sq_local_velocity = ComputeClampedVelocitySquared(rVelocity, rCurrentProcessInfo); - - // square bracket term - double square_bracket_term = 1.0 + 0.5*(heat_capacity_ratio - 1.0)* - sq_free_stream_mach*(1.0 - (sq_local_velocity/sq_free_stream_velocity)); - - // calculate mach derivative - return sq_local_mach_number * ((1.0/sq_local_velocity) + - 0.5*(heat_capacity_ratio - 1.0)*(1.0/sq_free_stream_velocity)*sq_free_stream_mach*(1.0/square_bracket_term)); -} - -template -double ComputeMaximumVelocitySquared(const ProcessInfo& rCurrentProcessInfo) -{ - - // Following Fully Simulataneous Coupling of the Full Potential Equation - // and the Integral Boundary Layer Equations in Three Dimensions - // by Brian Nishida (1996), Section A.2 and Section 2.5 - - // maximum local squared mach number - const double sq_max_local_mach_number = rCurrentProcessInfo[MACH_SQUARED_LIMIT]; - - // read free stream values - const double heat_capacity_ratio = rCurrentProcessInfo[HEAT_CAPACITY_RATIO]; - const double free_stream_mach = rCurrentProcessInfo[FREE_STREAM_MACH]; - const array_1d free_stream_velocity = rCurrentProcessInfo[FREE_STREAM_VELOCITY]; - - // make squares of values - double sq_free_stream_mach = std::pow(free_stream_mach, 2); - double sq_free_stream_velocity = inner_prod(free_stream_velocity, free_stream_velocity); - - return sq_max_local_mach_number * sq_free_stream_velocity * - ((sq_free_stream_mach * heat_capacity_ratio - sq_free_stream_mach + 2) / - (sq_free_stream_mach * heat_capacity_ratio * sq_max_local_mach_number - - sq_max_local_mach_number * sq_free_stream_mach + 2 * sq_free_stream_mach)); -} - -template -double ComputeClampedVelocitySquared( - const array_1d& rVelocity, - const ProcessInfo& rCurrentProcessInfo) -{ - // check if velocity is over max allowed velocity - double sq_max_velocity = ComputeMaximumVelocitySquared(rCurrentProcessInfo); - - double sq_local_velocity = inner_prod(rVelocity, rVelocity); - - if (sq_local_velocity > sq_max_velocity) - { - KRATOS_WARNING("Clamped local velocity") << - "SQUARE OF LOCAL VELOCITY ABOVE ALLOWED SQUARE OF VELOCITY" - << " sq_local_velocity = " << sq_max_velocity - << " sq_max_velocity = " << sq_max_velocity << std::endl; - - sq_local_velocity = sq_max_velocity; - } - - return sq_local_velocity; -} - -template -double ComputeLocalSpeedofSoundSquared( - const array_1d& rVelocity, - const ProcessInfo& rCurrentProcessInfo) -{ - // Implemented according to Equation 8.7 of Drela, M. (2014) Flight Vehicle - // Aerodynamics, The MIT Press, London - - // read free stream values - const double heat_capacity_ratio = rCurrentProcessInfo[HEAT_CAPACITY_RATIO]; - const double free_stream_mach = rCurrentProcessInfo[FREE_STREAM_MACH]; - const array_1d free_stream_velocity = rCurrentProcessInfo[FREE_STREAM_VELOCITY]; - const double free_stream_speed_sound = rCurrentProcessInfo[SOUND_VELOCITY]; - - // make squares of values - double sq_free_stream_mach = std::pow(free_stream_mach, 2); - double sq_free_stream_speed_sound = std::pow(free_stream_speed_sound,2); - double sq_free_stream_velocity = inner_prod(free_stream_velocity, free_stream_velocity); - - // computes square of velocity including clamping according to MACH_SQUARED_LIMIT - double sq_local_velocity = ComputeClampedVelocitySquared(rVelocity, rCurrentProcessInfo); - - // square bracket term - double square_bracket_term = 1.0 + 0.5*(heat_capacity_ratio - 1.0)* - sq_free_stream_mach*(1.0 - (sq_local_velocity/sq_free_stream_velocity)); - - return sq_free_stream_speed_sound * square_bracket_term; -} - -template -double ComputeLocalMachNumberSquared( - const array_1d& rVelocity, - const ProcessInfo& rCurrentProcessInfo) -{ - // Implemented according to Equation 8.8 of Drela, M. (2014) Flight Vehicle - // Aerodynamics, The MIT Press, London - - double sq_local_speed_of_sound = ComputeLocalSpeedofSoundSquared(rVelocity, rCurrentProcessInfo); - - // computes square of velocity including clamping according to MACH_SQUARED_LIMIT - double sq_local_velocity = ComputeClampedVelocitySquared(rVelocity, rCurrentProcessInfo); - - return sq_local_velocity / sq_local_speed_of_sound; -} - - - /////////////////////////////////////////////////////////////////////////////////////////////////// // Template instantiation @@ -560,22 +597,24 @@ template array_1d ComputeVelocityNormalElement<2, 3>(const Element& r template array_1d ComputeVelocityUpperWakeElement<2, 3>(const Element& rElement); template array_1d ComputeVelocityLowerWakeElement<2, 3>(const Element& rElement); template array_1d ComputeVelocity<2, 3>(const Element& rElement); +template double ComputeMaximumVelocitySquared<2, 3>(const ProcessInfo& rCurrentProcessInfo); +template double ComputeClampedVelocitySquared<2, 3>(const array_1d& rVelocity, const ProcessInfo& rCurrentProcessInfo); +template double ComputeVelocityMagnitude<2, 3>(const double localMachNumberSquared, const ProcessInfo& rCurrentProcessInfo); template double ComputeIncompressiblePressureCoefficient<2, 3>(const Element& rElement, const ProcessInfo& rCurrentProcessInfo); template double ComputePerturbationIncompressiblePressureCoefficient<2, 3>(const Element& rElement, const ProcessInfo& rCurrentProcessInfo); template double ComputeCompressiblePressureCoefficient<2, 3>(const Element& rElement, const ProcessInfo& rCurrentProcessInfo); template double ComputePerturbationCompressiblePressureCoefficient<2, 3>(const Element& rElement, const ProcessInfo& rCurrentProcessInfo); template double ComputeLocalSpeedOfSound<2, 3>(const Element& rElement, const ProcessInfo& rCurrentProcessInfo); +template double ComputeLocalSpeedofSoundSquared<2, 3>(const array_1d& rVelocity,const ProcessInfo& rCurrentProcessInfo); +template double ComputeSquaredSpeedofSoundFactor<2, 3>(const double localVelocitySquared, const ProcessInfo& rCurrentProcessInfo); template double ComputePerturbationLocalSpeedOfSound<2, 3>(const Element& rElement, const ProcessInfo& rCurrentProcessInfo); template double ComputeLocalMachNumber<2, 3>(const Element& rElement, const ProcessInfo& rCurrentProcessInfo); +template double ComputeLocalMachNumberSquared<2, 3>(const array_1d& rVelocity, const ProcessInfo& rCurrentProcessInfo); +template double ComputeDerivativeLocalMachSquaredWRTVelocitySquared<2, 3>(const array_1d& rVelocity, const double localMachNumberSquared, const ProcessInfo& rCurrentProcessInfo); template double ComputePerturbationLocalMachNumber<2, 3>(const Element& rElement, const ProcessInfo& rCurrentProcessInfo); template bool CheckIfElementIsCutByDistance<2, 3>(const BoundedVector& rNodalDistances); template void KRATOS_API(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION) CheckIfWakeConditionsAreFulfilled<2>(const ModelPart&, const double& rTolerance, const int& rEchoLevel); template bool CheckWakeCondition<2, 3>(const Element& rElement, const double& rTolerance, const int& rEchoLevel); -template double ComputeLocalMachSquaredDerivative<2, 3>(const array_1d& rVelocity, const double localMachNumber, const ProcessInfo& rCurrentProcessInfo); -template double ComputeMaximumVelocitySquared<2, 3>(const ProcessInfo& rCurrentProcessInfo); -template double ComputeClampedVelocitySquared<2, 3>(const array_1d& rVelocity, const ProcessInfo& rCurrentProcessInfo); -template double ComputeLocalSpeedofSoundSquared<2, 3>(const array_1d& rVelocity,const ProcessInfo& rCurrentProcessInfo); -template double ComputeLocalMachNumberSquared<2, 3>(const array_1d& rVelocity, const ProcessInfo& rCurrentProcessInfo); // 3D template array_1d GetWakeDistances<3, 4>(const Element& rElement); @@ -590,22 +629,23 @@ template array_1d ComputeVelocityNormalElement<3, 4>(const Element& r template array_1d ComputeVelocityUpperWakeElement<3, 4>(const Element& rElement); template array_1d ComputeVelocityLowerWakeElement<3, 4>(const Element& rElement); template array_1d ComputeVelocity<3, 4>(const Element& rElement); +template double ComputeMaximumVelocitySquared<3, 4>(const ProcessInfo& rCurrentProcessInfo); +template double ComputeClampedVelocitySquared<3, 4>(const array_1d& rVelocity, const ProcessInfo& rCurrentProcessInfo); +template double ComputeVelocityMagnitude<3, 4>(const double localMachNumberSquared, const ProcessInfo& rCurrentProcessInfo); template double ComputeIncompressiblePressureCoefficient<3, 4>(const Element& rElement, const ProcessInfo& rCurrentProcessInfo); template double ComputePerturbationIncompressiblePressureCoefficient<3, 4>(const Element& rElement, const ProcessInfo& rCurrentProcessInfo); template double ComputeCompressiblePressureCoefficient<3, 4>(const Element& rElement, const ProcessInfo& rCurrentProcessInfo); template double ComputePerturbationCompressiblePressureCoefficient<3, 4>(const Element& rElement, const ProcessInfo& rCurrentProcessInfo); template double ComputeLocalSpeedOfSound<3, 4>(const Element& rElement, const ProcessInfo& rCurrentProcessInfo); +template double ComputeLocalSpeedofSoundSquared<3, 4>(const array_1d& rVelocity,const ProcessInfo& rCurrentProcessInfo); +template double ComputeSquaredSpeedofSoundFactor<3, 4>(const double localVelocitySquared, const ProcessInfo& rCurrentProcessInfo); template double ComputePerturbationLocalSpeedOfSound<3, 4>(const Element& rElement, const ProcessInfo& rCurrentProcessInfo); template double ComputeLocalMachNumber<3, 4>(const Element& rElement, const ProcessInfo& rCurrentProcessInfo); +template double ComputeLocalMachNumberSquared<3, 4>(const array_1d& rVelocity, const ProcessInfo& rCurrentProcessInfo); +template double ComputeDerivativeLocalMachSquaredWRTVelocitySquared<3, 4>(const array_1d& rVelocity, const double localMachNumberSquared, const ProcessInfo& rCurrentProcessInfo); template double ComputePerturbationLocalMachNumber<3, 4>(const Element& rElement, const ProcessInfo& rCurrentProcessInfo); template bool CheckIfElementIsCutByDistance<3, 4>(const BoundedVector& rNodalDistances); template void KRATOS_API(COMPRESSIBLE_POTENTIAL_FLOW_APPLICATION) CheckIfWakeConditionsAreFulfilled<3>(const ModelPart&, const double& rTolerance, const int& rEchoLevel); template bool CheckWakeCondition<3, 4>(const Element& rElement, const double& rTolerance, const int& rEchoLevel); -template double ComputeLocalMachSquaredDerivative<3, 4>(const array_1d& rVelocity, const double localMachNumber, const ProcessInfo& rCurrentProcessInfo); -template double ComputeMaximumVelocitySquared<3, 4>(const ProcessInfo& rCurrentProcessInfo); -template double ComputeClampedVelocitySquared<3, 4>(const array_1d& rVelocity, const ProcessInfo& rCurrentProcessInfo); -template double ComputeLocalSpeedofSoundSquared<3, 4>(const array_1d& rVelocity,const ProcessInfo& rCurrentProcessInfo); -template double ComputeLocalMachNumberSquared<3, 4>(const array_1d& rVelocity, const ProcessInfo& rCurrentProcessInfo); - } // namespace PotentialFlow } // namespace Kratos diff --git a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h index 7ac5f2f026a8..982b35a9c232 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h +++ b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h @@ -64,6 +64,15 @@ array_1d ComputeVelocityLowerWakeElement(const Element& rElement); template array_1d ComputeVelocity(const Element& rElement); +template +double ComputeMaximumVelocitySquared(const ProcessInfo& rCurrentProcessInfo); + +template +double ComputeClampedVelocitySquared(const array_1d& rVelocity, const ProcessInfo& rCurrentProcessInfo); + +template +double ComputeVelocityMagnitude(const double localMachNumberSquared, const ProcessInfo& rCurrentProcessInfo); + template double ComputeIncompressiblePressureCoefficient(const Element& rElement, const ProcessInfo& rCurrentProcessInfo); @@ -79,12 +88,24 @@ double ComputePerturbationCompressiblePressureCoefficient(const Element& rElemen template double ComputeLocalSpeedOfSound(const Element& rElement, const ProcessInfo& rCurrentProcessInfo); +template +double ComputeLocalSpeedofSoundSquared(const array_1d& rVelocity,const ProcessInfo& rCurrentProcessInfo); + +template +double ComputeSquaredSpeedofSoundFactor(const double localVelocitySquared, const ProcessInfo& rCurrentProcessInfo); + template double ComputePerturbationLocalSpeedOfSound(const Element& rElement, const ProcessInfo& rCurrentProcessInfo); template double ComputeLocalMachNumber(const Element& rElement, const ProcessInfo& rCurrentProcessInfo); +template +double ComputeLocalMachNumberSquared(const array_1d& rVelocity, const ProcessInfo& rCurrentProcessInfo); + +template +double ComputeDerivativeLocalMachSquaredWRTVelocitySquared(const array_1d& rVelocity, const double localMachNumberSquared,const ProcessInfo& rCurrentProcessInfo); + template double ComputePerturbationLocalMachNumber(const Element& rElement, const ProcessInfo& rCurrentProcessInfo); @@ -98,22 +119,6 @@ void CheckIfWakeConditionsAreFulfilled(const ModelPart& rWakeModelPart, const do template bool CheckWakeCondition(const Element& rElement, const double& rTolerance, const int& rEchoLevel); - -template -double ComputeLocalMachSquaredDerivative(const array_1d& rVelocity, const double localMachNumber,const ProcessInfo& rCurrentProcessInfo); - -template -double ComputeMaximumVelocitySquared(const ProcessInfo& rCurrentProcessInfo); - -template -double ComputeClampedVelocitySquared(const array_1d& rVelocity, const ProcessInfo& rCurrentProcessInfo); - -template -double ComputeLocalSpeedofSoundSquared(const array_1d& rVelocity,const ProcessInfo& rCurrentProcessInfo); - -template -double ComputeLocalMachNumberSquared(const array_1d& rVelocity, const ProcessInfo& rCurrentProcessInfo); - } // namespace PotentialFlow } // namespace Kratos diff --git a/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp b/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp index d43472f5575c..b46ae854593b 100644 --- a/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp +++ b/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp @@ -51,6 +51,19 @@ void GenerateTestingElement(ModelPart& rModelPart) { rModelPart.CreateNewElement("CompressiblePotentialFlowElement2D3N", 1, elemNodes, pElemProp); } +void AssignFreeStreamValues(ModelPart& rModelPart) { + rModelPart.GetProcessInfo()[FREE_STREAM_DENSITY] = 1.225; + rModelPart.GetProcessInfo()[FREE_STREAM_MACH] = 0.6; + rModelPart.GetProcessInfo()[HEAT_CAPACITY_RATIO] = 1.4; + rModelPart.GetProcessInfo()[SOUND_VELOCITY] = 340.0; + rModelPart.GetProcessInfo()[MACH_SQUARED_LIMIT] = 3.0; + + BoundedVector free_stream_velocity = ZeroVector(3); + free_stream_velocity(0) = rModelPart.GetProcessInfo().GetValue(FREE_STREAM_MACH) * + rModelPart.GetProcessInfo().GetValue(SOUND_VELOCITY); + rModelPart.GetProcessInfo()[FREE_STREAM_VELOCITY] = free_stream_velocity; +} + void AssignPotentialsToElement(Element& rElement) { // Define the nodal values std::array potential{0.0, 150.0, 350.0}; @@ -69,235 +82,221 @@ void AssignPerturbationPotentialsToElement(Element& rElement) { potential[i]; } -// Checks the function ComputeLocalSpeedOfSound from the utilities -KRATOS_TEST_CASE_IN_SUITE(ComputeLocalSpeedOfSound, CompressiblePotentialApplicationFastSuite) { +// checks the function ComputeVelocityMagnitude from utilities +KRATOS_TEST_CASE_IN_SUITE(ComputeVelocityMagnitude, CompressiblePotentialApplicationFastSuite) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); - GenerateTestingElement(model_part); - Element::Pointer pElement = model_part.pGetElement(1); + AssignFreeStreamValues(model_part); - AssignPotentialsToElement(*pElement); - const double local_speed_of_sound = - PotentialFlowUtilities::ComputeLocalSpeedOfSound<2, 3>( - *pElement, model_part.GetProcessInfo()); - KRATOS_CHECK_NEAR(local_speed_of_sound, 333.801138, 1e-6); + // velocity corresponding to squared mach number of 3.0 + double local_velocity_squared = PotentialFlowUtilities::ComputeVelocityMagnitude<2, 3>(3.0, model_part.GetProcessInfo()); + + KRATOS_CHECK_NEAR(local_velocity_squared, 232356.0000000000000000, 1e-10); } -// Checks the function ComputeLocalMachNumber from the utilities -KRATOS_TEST_CASE_IN_SUITE(ComputeLocalMachNumber, CompressiblePotentialApplicationFastSuite) { +// Checks the function ComputeMaximumVelocitySquared from the utilities +KRATOS_TEST_CASE_IN_SUITE(ComputeMaximumVelocitySquared, CompressiblePotentialApplicationFastSuite) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); - GenerateTestingElement(model_part); - Element::Pointer pElement = model_part.pGetElement(1); + AssignFreeStreamValues(model_part); - AssignPotentialsToElement(*pElement); - const double local_mach_number = - PotentialFlowUtilities::ComputeLocalMachNumber<2, 3>( - *pElement, model_part.GetProcessInfo()); - KRATOS_CHECK_NEAR(local_mach_number, 0.748948914, 1e-6); + double reference_max_velocity_squared = 232356.0000000000000000; + + // Max local Mach number = sqrt(3.0), from MACH_SQUARED_LIMIT + double max_velocity_squared = PotentialFlowUtilities::ComputeMaximumVelocitySquared<2, 3>(model_part.GetProcessInfo()); + + KRATOS_CHECK_NEAR(max_velocity_squared, reference_max_velocity_squared, 1e-10); } -// Checks the function ComputeIncompressiblePerturbationPressureCoefficient from the utilities -KRATOS_TEST_CASE_IN_SUITE(ComputePerturbationIncompressiblePressureCoefficient, CompressiblePotentialApplicationFastSuite) { +// Checks the function ComputeLocalSpeedOfSound from the utilities +KRATOS_TEST_CASE_IN_SUITE(ComputeLocalSpeedOfSound, CompressiblePotentialApplicationFastSuite) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); GenerateTestingElement(model_part); Element::Pointer pElement = model_part.pGetElement(1); - AssignPerturbationPotentialsToElement(*pElement); - const double pressure_coefficient = - PotentialFlowUtilities::ComputePerturbationIncompressiblePressureCoefficient<2, 3>( + AssignPotentialsToElement(*pElement); + const double local_speed_of_sound = + PotentialFlowUtilities::ComputeLocalSpeedOfSound<2, 3>( *pElement, model_part.GetProcessInfo()); - - KRATOS_CHECK_NEAR(pressure_coefficient, -1.266171664744329, 1e-15); + KRATOS_CHECK_NEAR(local_speed_of_sound, 333.801138, 1e-6); } -// Checks the function ComputePerturbationCompressiblePressureCoefficient from the utilities -KRATOS_TEST_CASE_IN_SUITE(ComputePerturbationCompressiblePressureCoefficient, CompressiblePotentialApplicationFastSuite) { +// Checks ComputeLocalSpeedofSoundSquared in utilities, local velocity that should be clamped +KRATOS_TEST_CASE_IN_SUITE(ComputeLocalSpeedofSoundSquared, CompressiblePotentialApplicationFastSuite) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); - GenerateTestingElement(model_part); - Element::Pointer pElement = model_part.pGetElement(1); + AssignFreeStreamValues(model_part); - AssignPerturbationPotentialsToElement(*pElement); - const double pressure_coefficient = - PotentialFlowUtilities::ComputePerturbationCompressiblePressureCoefficient<2, 3>( - *pElement, model_part.GetProcessInfo()); + double local_mach_number = 3.0; - KRATOS_CHECK_NEAR(pressure_coefficient, -1.128385779511008, 1e-15); + // velocity corresponding to mach number 3.0 + double local_velocity_squared = PotentialFlowUtilities::ComputeVelocityMagnitude<2, 3>(std::pow(local_mach_number, 2), model_part.GetProcessInfo()); + + array_1d velocity(2, 0.0); + velocity[0] = local_velocity_squared; + + double local_speed_sound_squared = PotentialFlowUtilities::ComputeLocalSpeedofSoundSquared<2,3>(velocity, model_part.GetProcessInfo()); + + double reference_local_speed_sound_squared = 77452.0000000000; + + KRATOS_CHECK_NEAR(local_speed_sound_squared, reference_local_speed_sound_squared, 1e-16); } -// Checks the function ComputePerturbationLocalSpeedOfSound from the utilities -KRATOS_TEST_CASE_IN_SUITE(ComputePerturbationLocalSpeedOfSound, CompressiblePotentialApplicationFastSuite) { +// Checks the function ComputeLocalMachNumber from the utilities +KRATOS_TEST_CASE_IN_SUITE(ComputeLocalMachNumber, CompressiblePotentialApplicationFastSuite) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); GenerateTestingElement(model_part); Element::Pointer pElement = model_part.pGetElement(1); - AssignPerturbationPotentialsToElement(*pElement); - const double local_speed_of_sound = - PotentialFlowUtilities::ComputePerturbationLocalSpeedOfSound<2, 3>( + AssignPotentialsToElement(*pElement); + const double local_mach_number = + PotentialFlowUtilities::ComputeLocalMachNumber<2, 3>( *pElement, model_part.GetProcessInfo()); - - KRATOS_CHECK_NEAR(local_speed_of_sound, 324.1317633309022, 1e-13); + KRATOS_CHECK_NEAR(local_mach_number, 0.748948914, 1e-6); } -// Checks the function ComputePerturbationLocalMachNumber from the utilities -KRATOS_TEST_CASE_IN_SUITE(ComputePerturbationLocalMachNumber, CompressiblePotentialApplicationFastSuite) { +// Checks ComputeLocalMachNumberSquared in utilities, local velocity that should be clamped +KRATOS_TEST_CASE_IN_SUITE(ComputeLocalMachNumberSquared, CompressiblePotentialApplicationFastSuite) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); - GenerateTestingElement(model_part); - Element::Pointer pElement = model_part.pGetElement(1); + AssignFreeStreamValues(model_part); - AssignPerturbationPotentialsToElement(*pElement); - const double local_mach_number = - PotentialFlowUtilities::ComputePerturbationLocalMachNumber<2, 3>( - *pElement, model_part.GetProcessInfo()); + double reference_local_mach_squared = 3.0; - KRATOS_CHECK_NEAR(local_mach_number, 0.9474471158469713, 1e-16); + // velocity corresponding to mach number 3.0 + double local_velocity_squared = PotentialFlowUtilities::ComputeVelocityMagnitude<2, 3>(reference_local_mach_squared, model_part.GetProcessInfo()); + + array_1d velocity(2, 0.0); + velocity[0] = local_velocity_squared; + + // computes mach number with clamping + double local_mach_squared = PotentialFlowUtilities::ComputeLocalMachNumberSquared<2, 3>(velocity, model_part.GetProcessInfo()); + + KRATOS_CHECK_NEAR(local_mach_squared, reference_local_mach_squared, 1e-10); } -// Checks the function ComputeLocalMachSquaredDerivative from the utilities, transonic local Mach number -KRATOS_TEST_CASE_IN_SUITE(ComputeLocalMachSquaredDerivativeTransonicMach, CompressiblePotentialApplicationFastSuite) { +// Checks the function ComputeDLocalMachSquaredWRTVelocitySquared from the utilities, transonic local Mach number +KRATOS_TEST_CASE_IN_SUITE(ComputeDLocalMachSquaredWRTVelocitySquaredTransonicMach, CompressiblePotentialApplicationFastSuite) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); - model_part.GetProcessInfo()[FREE_STREAM_DENSITY] = 1.225; - model_part.GetProcessInfo()[FREE_STREAM_MACH] = 0.6; - model_part.GetProcessInfo()[HEAT_CAPACITY_RATIO] = 1.4; - model_part.GetProcessInfo()[SOUND_VELOCITY] = 340.0; - model_part.GetProcessInfo()[MACH_SQUARED_LIMIT] = 3.0; + AssignFreeStreamValues(model_part); - BoundedVector free_stream_velocity = ZeroVector(3); - free_stream_velocity(0) = model_part.GetProcessInfo().GetValue(FREE_STREAM_MACH) * - model_part.GetProcessInfo().GetValue(SOUND_VELOCITY); - model_part.GetProcessInfo()[FREE_STREAM_VELOCITY] = free_stream_velocity; + double local_mach_number = 1.0; + + // velocity corresponding to mach number 1.0 + double local_velocity_squared = PotentialFlowUtilities::ComputeVelocityMagnitude<2, 3>(std::pow(local_mach_number, 2), model_part.GetProcessInfo()); array_1d velocity(2, 0.0); - velocity[0] = 68.0 * sqrt(67.0/3.0); + velocity[0] = sqrt(local_velocity_squared); - double sq_local_mach_number = PotentialFlowUtilities::ComputeLocalMachNumberSquared<2, 3>(velocity, model_part.GetProcessInfo()); - double local_mach_number = sqrt(sq_local_mach_number); + // performs clamping on mach number + double local_mach_squared = PotentialFlowUtilities::ComputeLocalMachNumberSquared<2, 3>(velocity, model_part.GetProcessInfo()); - double mach_derivative = PotentialFlowUtilities::ComputeLocalMachSquaredDerivative<2, 3>(velocity, - local_mach_number, model_part.GetProcessInfo()); + double mach_derivative = PotentialFlowUtilities::ComputeDerivativeLocalMachSquaredWRTVelocitySquared<2, 3>(velocity, + local_mach_squared, model_part.GetProcessInfo()); double reference_derivative = 1.16201001910861e-05; KRATOS_CHECK_NEAR(mach_derivative, reference_derivative, 1e-16); } -// Checks the function ComputeLocalMachSquaredDerivative from the utilities, supersonic local Mach number -KRATOS_TEST_CASE_IN_SUITE(ComputeLocalMachSquaredDerivativeSupersonicMach, CompressiblePotentialApplicationFastSuite) { +// Checks the function ComputeDLocalMachSquaredWRTVelocitySquared from the utilities, supersonic local Mach number +KRATOS_TEST_CASE_IN_SUITE(ComputeDLocalMachSquaredWRTVelocitySquaredSupersonicMach, CompressiblePotentialApplicationFastSuite) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); - model_part.GetProcessInfo()[FREE_STREAM_DENSITY] = 1.225; - model_part.GetProcessInfo()[FREE_STREAM_MACH] = 0.6; - model_part.GetProcessInfo()[HEAT_CAPACITY_RATIO] = 1.4; - model_part.GetProcessInfo()[SOUND_VELOCITY] = 340.0; - model_part.GetProcessInfo()[MACH_SQUARED_LIMIT] = 3.0; + AssignFreeStreamValues(model_part); - BoundedVector free_stream_velocity = ZeroVector(3); - free_stream_velocity(0) = model_part.GetProcessInfo().GetValue(FREE_STREAM_MACH) * - model_part.GetProcessInfo().GetValue(SOUND_VELOCITY); - model_part.GetProcessInfo()[FREE_STREAM_VELOCITY] = free_stream_velocity; + double local_mach_number = 3.0; + + // velocity corresponding to mach number 3.0 + double local_velocity_squared = PotentialFlowUtilities::ComputeVelocityMagnitude<2, 3>(std::pow(local_mach_number, 2), model_part.GetProcessInfo()); array_1d velocity(2, 0.0); - velocity[0] = 272.0 * sqrt(134.0/21.0); + velocity[0] = local_velocity_squared; - double sq_local_mach_number = PotentialFlowUtilities::ComputeLocalMachNumberSquared<2, 3>(velocity, model_part.GetProcessInfo()); - double local_mach_number = sqrt(sq_local_mach_number); + // performs clamping on mach number + double local_mach_squared = PotentialFlowUtilities::ComputeLocalMachNumberSquared<2, 3>(velocity, model_part.GetProcessInfo()); - double mach_derivative = PotentialFlowUtilities::ComputeLocalMachSquaredDerivative<2, 3>(velocity, - local_mach_number, model_part.GetProcessInfo()); + double mach_derivative = PotentialFlowUtilities::ComputeDerivativeLocalMachSquaredWRTVelocitySquared<2, 3>(velocity, + local_mach_squared, model_part.GetProcessInfo()); double reference_derivative = 2.06579558952642e-05; KRATOS_CHECK_NEAR(mach_derivative, reference_derivative, 1e-16); } -// Checks the function ComputeMaximumVelocitySquared from the utilities -KRATOS_TEST_CASE_IN_SUITE(ComputeMaximumVelocitySquared, CompressiblePotentialApplicationFastSuite) { +// Checks the function ComputeIncompressiblePerturbationPressureCoefficient from the utilities +KRATOS_TEST_CASE_IN_SUITE(ComputePerturbationIncompressiblePressureCoefficient, CompressiblePotentialApplicationFastSuite) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); - model_part.GetProcessInfo()[FREE_STREAM_DENSITY] = 1.225; - model_part.GetProcessInfo()[FREE_STREAM_MACH] = 0.6; - model_part.GetProcessInfo()[HEAT_CAPACITY_RATIO] = 1.4; - model_part.GetProcessInfo()[SOUND_VELOCITY] = 340.0; - model_part.GetProcessInfo()[MACH_SQUARED_LIMIT] = 3.0; - - BoundedVector free_stream_velocity = ZeroVector(3); - free_stream_velocity(0) = model_part.GetProcessInfo().GetValue(FREE_STREAM_MACH) * - model_part.GetProcessInfo().GetValue(SOUND_VELOCITY); - model_part.GetProcessInfo()[FREE_STREAM_VELOCITY] = free_stream_velocity; - - // Max local Mach number = sqrt(3.0), hard coded in ComputeMaximumVelocitySquared - - double reference_sq_max_velocity = 232356.0000000000000000; + GenerateTestingElement(model_part); + Element::Pointer pElement = model_part.pGetElement(1); - double sq_max_velocity = PotentialFlowUtilities::ComputeMaximumVelocitySquared<2, 3>(model_part.GetProcessInfo()); + AssignPerturbationPotentialsToElement(*pElement); + const double pressure_coefficient = + PotentialFlowUtilities::ComputePerturbationIncompressiblePressureCoefficient<2, 3>( + *pElement, model_part.GetProcessInfo()); - KRATOS_CHECK_NEAR(sq_max_velocity, reference_sq_max_velocity, 1e-10); + KRATOS_CHECK_NEAR(pressure_coefficient, -1.266171664744329, 1e-15); } -// Checks ComputeLocalSpeedofSoundSquared in utilities, local velocity that should be clamped -KRATOS_TEST_CASE_IN_SUITE(ComputeLocalSpeedofSoundSquared, CompressiblePotentialApplicationFastSuite) { +// Checks the function ComputePerturbationCompressiblePressureCoefficient from the utilities +KRATOS_TEST_CASE_IN_SUITE(ComputePerturbationCompressiblePressureCoefficient, CompressiblePotentialApplicationFastSuite) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); - model_part.GetProcessInfo()[FREE_STREAM_DENSITY] = 1.225; - model_part.GetProcessInfo()[FREE_STREAM_MACH] = 0.6; - model_part.GetProcessInfo()[HEAT_CAPACITY_RATIO] = 1.4; - model_part.GetProcessInfo()[SOUND_VELOCITY] = 340.0; - model_part.GetProcessInfo()[MACH_SQUARED_LIMIT] = 3.0; - - BoundedVector free_stream_velocity = ZeroVector(3); - free_stream_velocity(0) = model_part.GetProcessInfo().GetValue(FREE_STREAM_MACH) * - model_part.GetProcessInfo().GetValue(SOUND_VELOCITY); - model_part.GetProcessInfo()[FREE_STREAM_VELOCITY] = free_stream_velocity; - - array_1d velocity(2, 0.0); - velocity[0] = 350000.0; - - double sq_local_speed_sound = PotentialFlowUtilities::ComputeLocalSpeedofSoundSquared<2,3>(velocity, model_part.GetProcessInfo()); + GenerateTestingElement(model_part); + Element::Pointer pElement = model_part.pGetElement(1); - double reference_sq_local_speed_sound = 77452.0000000000; + AssignPerturbationPotentialsToElement(*pElement); + const double pressure_coefficient = + PotentialFlowUtilities::ComputePerturbationCompressiblePressureCoefficient<2, 3>( + *pElement, model_part.GetProcessInfo()); - KRATOS_CHECK_NEAR(sq_local_speed_sound, reference_sq_local_speed_sound, 1e-16); + KRATOS_CHECK_NEAR(pressure_coefficient, -1.128385779511008, 1e-15); } -// Checks ComputeLocalMachNumberSquared in utilities, local velocity that should be clamped -KRATOS_TEST_CASE_IN_SUITE(ComputeLocalMachNumberSquared, CompressiblePotentialApplicationFastSuite) { +// Checks the function ComputePerturbationLocalSpeedOfSound from the utilities +KRATOS_TEST_CASE_IN_SUITE(ComputePerturbationLocalSpeedOfSound, CompressiblePotentialApplicationFastSuite) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); - model_part.GetProcessInfo()[FREE_STREAM_DENSITY] = 1.225; - model_part.GetProcessInfo()[FREE_STREAM_MACH] = 0.6; - model_part.GetProcessInfo()[HEAT_CAPACITY_RATIO] = 1.4; - model_part.GetProcessInfo()[SOUND_VELOCITY] = 340.0; - model_part.GetProcessInfo()[MACH_SQUARED_LIMIT] = 3.0; + GenerateTestingElement(model_part); + Element::Pointer pElement = model_part.pGetElement(1); - BoundedVector free_stream_velocity = ZeroVector(3); - free_stream_velocity(0) = model_part.GetProcessInfo().GetValue(FREE_STREAM_MACH) * - model_part.GetProcessInfo().GetValue(SOUND_VELOCITY); - model_part.GetProcessInfo()[FREE_STREAM_VELOCITY] = free_stream_velocity; + AssignPerturbationPotentialsToElement(*pElement); + const double local_speed_of_sound = + PotentialFlowUtilities::ComputePerturbationLocalSpeedOfSound<2, 3>( + *pElement, model_part.GetProcessInfo()); - array_1d velocity(2, 0.0); - velocity[0] = 350000.0; + KRATOS_CHECK_NEAR(local_speed_of_sound, 324.1317633309022, 1e-13); +} - double sq_local_mach_number = PotentialFlowUtilities::ComputeLocalMachNumberSquared<2, 3>(velocity, model_part.GetProcessInfo()); +// Checks the function ComputePerturbationLocalMachNumber from the utilities +KRATOS_TEST_CASE_IN_SUITE(ComputePerturbationLocalMachNumber, CompressiblePotentialApplicationFastSuite) { + Model this_model; + ModelPart& model_part = this_model.CreateModelPart("Main", 3); - double reference_sq_local_mach_number = 3.0; + GenerateTestingElement(model_part); + Element::Pointer pElement = model_part.pGetElement(1); - KRATOS_CHECK_NEAR(sq_local_mach_number, reference_sq_local_mach_number, 1e-10); + AssignPerturbationPotentialsToElement(*pElement); + const double local_mach_number = + PotentialFlowUtilities::ComputePerturbationLocalMachNumber<2, 3>( + *pElement, model_part.GetProcessInfo()); + + KRATOS_CHECK_NEAR(local_mach_number, 0.9474471158469713, 1e-16); } } // namespace Testing From 9a3a957a1cc9d508b92378457c8e6c7e963579cc Mon Sep 17 00:00:00 2001 From: eloisabaez Date: Thu, 23 Apr 2020 18:56:21 +0200 Subject: [PATCH 220/314] addressing final pull request comment --- .../custom_utilities/potential_flow_utilities.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp index 2e409a736b68..4dbfd8cce21b 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp +++ b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp @@ -481,9 +481,9 @@ double ComputeDerivativeLocalMachSquaredWRTVelocitySquared( // square bracket term const double speed_of_sound_factor = ComputeSquaredSpeedofSoundFactor(local_velocity_squared, rCurrentProcessInfo); - // calculate mach derivative - return localMachNumberSquared * ((1.0/local_velocity_squared) + - 0.5*(heat_capacity_ratio - 1.0)*(1.0/free_stream_velocity_squared)*free_stream_mach_squared*(1.0/speed_of_sound_factor)); + const double second_term_factor = 0.5 * (heat_capacity_ratio - 1.0) / free_stream_velocity_squared * free_stream_mach_squared; + + return localMachNumberSquared * ((1.0 / local_velocity_squared) + second_term_factor / speed_of_sound_factor); } template From 397a3e2569629b9c6b146a9b13746e27fa9d5b68 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Fri, 24 Apr 2020 07:38:38 +1000 Subject: [PATCH 221/314] cleanup to rerun checks --- .../custom_elements/updated_lagrangian_quadrilateral.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp index 5ec6783165bd..fcc980f585e1 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp @@ -641,7 +641,6 @@ class UpdatedLagrangianQuadrilateral /** * Calculation and addition of the vectors of the RHS */ - virtual void CalculateAndAddRHS(LocalSystemComponents& rLocalSystem, GeneralVariables& rVariables, Vector& rVolumeForce, @@ -652,7 +651,6 @@ class UpdatedLagrangianQuadrilateral /** * Calculation of the Material Stiffness Matrix. Kuum = BT * C * B */ - virtual void CalculateAndAddKuum(MatrixType& rLeftHandSideMatrix, GeneralVariables& rVariables, const double& rIntegrationWeight); From 64b1f50264b5b615dd17fcb01e0c1619cbd13cb5 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Fri, 24 Apr 2020 07:47:22 +1000 Subject: [PATCH 222/314] update variable in search utility --- .../custom_utilities/mpm_search_element_utility.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h b/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h index d79959fbe5aa..58ea446b2451 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h @@ -101,7 +101,7 @@ namespace MPMSearchElementUtility if (isOnEdge) { // MP is exactly on the edge. Now we give it a little 'nudge' array_1d xg_nudged = array_1d(xg[0]); - const double& delta_time = rProcessInfo[DELTA_TIME]; + const double& delta_time = r_process_info[DELTA_TIME]; std::vector> mp_vel; element_itr->CalculateOnIntegrationPoints(MP_VELOCITY, mp_vel, rMPMModelPart.GetProcessInfo()); array_1d nudge_displacement = delta_time / 1000.0 * mp_vel[0]; From f7ed98c7bbc0d78b0d4862f03daa71dcd7a19101 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Fri, 24 Apr 2020 09:18:29 +1000 Subject: [PATCH 223/314] add consistent mass matrix option for all elements --- .../custom_elements/updated_lagrangian.cpp | 50 +++++++++++-------- .../custom_elements/updated_lagrangian.hpp | 2 +- .../custom_elements/updated_lagrangian_UP.cpp | 49 ++++++++++-------- .../custom_elements/updated_lagrangian_UP.hpp | 2 +- .../updated_lagrangian_quadrilateral.cpp | 49 +++++++++++------- .../updated_lagrangian_quadrilateral.hpp | 2 +- .../particle_mechanics_python_application.cpp | 1 + .../particle_mechanics_application.cpp | 1 + ...rticle_mechanics_application_variables.cpp | 1 + ...particle_mechanics_application_variables.h | 1 + .../python_scripts/mpm_solver.py | 3 ++ 11 files changed, 98 insertions(+), 63 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp index 943c8aff2d78..2573a97565b5 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp @@ -1276,36 +1276,44 @@ void UpdatedLagrangian::CalculateDampingMatrix( MatrixType& rDampingMatrix, Proc //************************************************************************************ //****************MASS MATRIX********************************************************* -void UpdatedLagrangian::CalculateMassMatrix( MatrixType& rMassMatrix, ProcessInfo& rCurrentProcessInfo ) +void UpdatedLagrangian::CalculateMassMatrix( MatrixType& rMassMatrix, const ProcessInfo& rCurrentProcessInfo ) { KRATOS_TRY // Call the values of the shape function for the single element - GeneralVariables Variables; - this->InitializeGeneralVariables(Variables,rCurrentProcessInfo); + Vector N; + this->MPMShapeFunctionPointValues(N, mMP.xg); - // Lumped - const unsigned int dimension = GetGeometry().WorkingSpaceDimension(); - const unsigned int number_of_nodes = GetGeometry().PointsNumber(); - unsigned int matrix_size = dimension * number_of_nodes; + const bool is_consistent_mass_matrix = (rCurrentProcessInfo.Has(USE_CONSISTENT_MASS_MATRIX)) + ? rCurrentProcessInfo.GetValue(USE_CONSISTENT_MASS_MATRIX) + : false; + + const SizeType dimension = GetGeometry().WorkingSpaceDimension(); + const SizeType number_of_nodes = GetGeometry().PointsNumber(); + const SizeType matrix_size = dimension * number_of_nodes; if ( rMassMatrix.size1() != matrix_size ) rMassMatrix.resize( matrix_size, matrix_size, false ); - rMassMatrix = ZeroMatrix(matrix_size, matrix_size); - - // TOTAL MASS OF ONE MP ELEMENT - const double & r_total_mass = mMP.mass; - - // LUMPED MATRIX - for ( unsigned int i = 0; i < number_of_nodes; i++ ) - { - double temp = Variables.N[i] * r_total_mass; - - for ( unsigned int j = 0; j < dimension; j++ ) - { - unsigned int index = i * dimension + j; - rMassMatrix( index, index ) = temp; + + if (is_consistent_mass_matrix) { + for (IndexType i = 0; i < number_of_nodes; ++i) { + for (IndexType j = 0; j < number_of_nodes; ++j) { + for (IndexType k = 0; k < dimension; ++k) + { + const IndexType index_i = i * dimension + k; + const IndexType index_j = j * dimension + k; + rMassMatrix(index_i, index_j) = N[i] * N[j] * mMP.mass; + } + } + } + } else { + for (IndexType i = 0; i < number_of_nodes; ++i) { + for (IndexType k = 0; k < dimension; ++k) + { + const IndexType index = i * dimension + k; + rMassMatrix(index, index) = N[i] * mMP.mass; + } } } diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.hpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.hpp index 69d3f5d7881f..08017f8282cd 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.hpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.hpp @@ -482,7 +482,7 @@ class UpdatedLagrangian * @param rCurrentProcessInfo: the current process info instance */ void CalculateMassMatrix(MatrixType& rMassMatrix, - ProcessInfo& rCurrentProcessInfo) override; + const ProcessInfo& rCurrentProcessInfo) override; /** * this is called during the assembling process in order diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.cpp index ce6eafff3106..f811eab21969 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.cpp @@ -1019,35 +1019,44 @@ void UpdatedLagrangianUP::GetDofList( DofsVectorType& rElementalDofList, Process //************************************************************************************ //****************MASS MATRIX********************************************************* -void UpdatedLagrangianUP::CalculateMassMatrix( MatrixType& rMassMatrix, ProcessInfo& rCurrentProcessInfo ) +void UpdatedLagrangianUP::CalculateMassMatrix( MatrixType& rMassMatrix, const ProcessInfo& rCurrentProcessInfo ) { KRATOS_TRY // Call the values of the shape function for the single element - GeneralVariables Variables; - this->InitializeGeneralVariables(Variables,rCurrentProcessInfo); + Vector N; + this->MPMShapeFunctionPointValues(N, mMP.xg); - // Lumped - unsigned int dimension = GetGeometry().WorkingSpaceDimension(); - const unsigned int number_of_nodes = GetGeometry().PointsNumber(); - unsigned int matrix_size = number_of_nodes * dimension + number_of_nodes; + const bool is_consistent_mass_matrix = (rCurrentProcessInfo.Has(USE_CONSISTENT_MASS_MATRIX)) + ? rCurrentProcessInfo.GetValue(USE_CONSISTENT_MASS_MATRIX) + : false; - if ( rMassMatrix.size1() != matrix_size ) - rMassMatrix.resize( matrix_size, matrix_size, false ); + const SizeType dimension = GetGeometry().WorkingSpaceDimension(); + const SizeType number_of_nodes = GetGeometry().PointsNumber(); + const SizeType matrix_size = dimension * number_of_nodes; + if (rMassMatrix.size1() != matrix_size) + rMassMatrix.resize(matrix_size, matrix_size, false); rMassMatrix = ZeroMatrix(matrix_size, matrix_size); - // TOTAL MASS OF ONE MP ELEMENT - const double & r_total_mass = mMP.mass; - - // LUMPED MATRIX - for ( unsigned int i = 0; i < number_of_nodes; i++ ) - { - double temp = Variables.N[i] * r_total_mass; - unsigned int index_up = i * dimension + i; - for ( unsigned int j = 0; j < dimension; j++ ) - { - rMassMatrix( index_up+j, index_up+j ) = temp; + if (is_consistent_mass_matrix) { + for (IndexType i = 0; i < number_of_nodes; ++i) { + for (IndexType j = 0; j < number_of_nodes; ++j) { + for (IndexType k = 0; k < dimension; ++k) + { + const IndexType index_i = i * dimension + k; + const IndexType index_j = j * dimension + k; + rMassMatrix(index_i, index_j) = N[i] * N[j] * mMP.mass; + } + } + } + } else { + for (IndexType i = 0; i < number_of_nodes; ++i) { + for (IndexType k = 0; k < dimension; ++k) + { + const IndexType index = i * dimension + k; + rMassMatrix(index, index) = N[i] * mMP.mass; + } } } diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.hpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.hpp index c8d6742c0376..a05828a0d60b 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.hpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.hpp @@ -169,7 +169,7 @@ class UpdatedLagrangianUP * @param rCurrentProcessInfo: the current process info instance */ void CalculateMassMatrix(MatrixType& rMassMatrix, - ProcessInfo& rCurrentProcessInfo) override; + const ProcessInfo& rCurrentProcessInfo) override; //************************************************************************************ diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index 57b6ba0b5928..5c82a9cb1882 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -1277,33 +1277,44 @@ void UpdatedLagrangianQuadrilateral::CalculateDampingMatrix( MatrixType& rDampin //************************************************************************************ //****************MASS MATRIX********************************************************* -void UpdatedLagrangianQuadrilateral::CalculateMassMatrix( MatrixType& rMassMatrix, ProcessInfo& rCurrentProcessInfo ) +void UpdatedLagrangianQuadrilateral::CalculateMassMatrix( MatrixType& rMassMatrix, const ProcessInfo& rCurrentProcessInfo ) { KRATOS_TRY - //I need to call the values of the shape function for the single element - GeneralVariables Variables; - this->InitializeGeneralVariables(Variables,rCurrentProcessInfo); + // Call the values of the shape function for the single element + Vector N; + this->MPMShapeFunctionPointValues(N, mMP.xg); - //lumped - const unsigned int dimension = GetGeometry().WorkingSpaceDimension(); - const unsigned int number_of_nodes = GetGeometry().PointsNumber(); - unsigned int matrix_size = dimension * number_of_nodes; + const bool is_consistent_mass_matrix = (rCurrentProcessInfo.Has(USE_CONSISTENT_MASS_MATRIX)) + ? rCurrentProcessInfo.GetValue(USE_CONSISTENT_MASS_MATRIX) + : false; - if ( rMassMatrix.size1() != matrix_size ) - rMassMatrix.resize( matrix_size, matrix_size, false ); + const SizeType dimension = GetGeometry().WorkingSpaceDimension(); + const SizeType number_of_nodes = GetGeometry().PointsNumber(); + const SizeType matrix_size = dimension * number_of_nodes; + if (rMassMatrix.size1() != matrix_size) + rMassMatrix.resize(matrix_size, matrix_size, false); rMassMatrix = ZeroMatrix(matrix_size, matrix_size); - //LUMPED MATRIX - for ( unsigned int i = 0; i < number_of_nodes; i++ ) - { - double temp = Variables.N[i] * mMP.mass; - - for ( unsigned int j = 0; j < dimension; j++ ) - { - unsigned int index = i * dimension + j; - rMassMatrix( index, index ) = temp; + if (is_consistent_mass_matrix) { + for (IndexType i = 0; i < number_of_nodes; ++i) { + for (IndexType j = 0; j < number_of_nodes; ++j) { + for (IndexType k = 0; k < dimension; ++k) + { + const IndexType index_i = i * dimension + k; + const IndexType index_j = j * dimension + k; + rMassMatrix(index_i, index_j) = N[i] * N[j] * mMP.mass; + } + } + } + } else { + for (IndexType i = 0; i < number_of_nodes; ++i) { + for (IndexType k = 0; k < dimension; ++k) + { + const IndexType index = i * dimension + k; + rMassMatrix(index, index) = N[i] * mMP.mass; + } } } diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp index 80d10cbb6a5f..b306b2f59fa4 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp @@ -488,7 +488,7 @@ class UpdatedLagrangianQuadrilateral * @param rCurrentProcessInfo: the current process info instance */ void CalculateMassMatrix(MatrixType& rMassMatrix, - ProcessInfo& rCurrentProcessInfo) override; + const ProcessInfo& rCurrentProcessInfo) override; /** * this is called during the assembling process in order diff --git a/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp b/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp index bf8496c2695f..53d598346960 100644 --- a/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp +++ b/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp @@ -121,6 +121,7 @@ namespace Python{ KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, MP_MATERIAL_ID); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, PARTICLES_PER_ELEMENT); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, IGNORE_GEOMETRIC_STIFFNESS); + KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, USE_CONSISTENT_MASS_MATRIX); KRATOS_REGISTER_IN_PYTHON_3D_VARIABLE_WITH_COMPONENTS(m, MPC_COORD); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, MPC_CONDITION_ID); diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp b/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp index 428cda76f187..df1a76a45bf7 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp @@ -208,6 +208,7 @@ namespace Kratos KRATOS_REGISTER_3D_VARIABLE_WITH_COMPONENTS( NODAL_MOMENTUM ) KRATOS_REGISTER_3D_VARIABLE_WITH_COMPONENTS( NODAL_INERTIA ) KRATOS_REGISTER_3D_VARIABLE_WITH_COMPONENTS( NODAL_INTERNAL_FORCE ) + KRATOS_REGISTER_VARIABLE(USE_CONSISTENT_MASS_MATRIX) // Registering Constitutive Laws // CL: Linear Elastic laws diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp index 80ccc6f647a6..40a6b739effd 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp @@ -89,6 +89,7 @@ namespace Kratos // Grid node variable KRATOS_CREATE_3D_VARIABLE_WITH_COMPONENTS( NODAL_MOMENTUM) KRATOS_CREATE_3D_VARIABLE_WITH_COMPONENTS( NODAL_INERTIA) + KRATOS_CREATE_VARIABLE(bool, USE_CONSISTENT_MASS_MATRIX) // Solver related variables KRATOS_CREATE_VARIABLE(bool, IGNORE_GEOMETRIC_STIFFNESS) diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h index 304ae9fbda49..d1216dd10963 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h @@ -115,6 +115,7 @@ namespace Kratos KRATOS_DEFINE_3D_APPLICATION_VARIABLE_WITH_COMPONENTS(PARTICLE_MECHANICS_APPLICATION, NODAL_MOMENTUM ) KRATOS_DEFINE_3D_APPLICATION_VARIABLE_WITH_COMPONENTS(PARTICLE_MECHANICS_APPLICATION, NODAL_INERTIA ) KRATOS_DEFINE_3D_APPLICATION_VARIABLE_WITH_COMPONENTS(PARTICLE_MECHANICS_APPLICATION, NODAL_INTERNAL_FORCE ) + KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, USE_CONSISTENT_MASS_MATRIX) // Solver related variables KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, IGNORE_GEOMETRIC_STIFFNESS) diff --git a/applications/ParticleMechanicsApplication/python_scripts/mpm_solver.py b/applications/ParticleMechanicsApplication/python_scripts/mpm_solver.py index 14093f112743..3b3df9062f7e 100644 --- a/applications/ParticleMechanicsApplication/python_scripts/mpm_solver.py +++ b/applications/ParticleMechanicsApplication/python_scripts/mpm_solver.py @@ -59,6 +59,7 @@ def GetDefaultSettings(cls): "max_iteration" : 20, "pressure_dofs" : false, "axis_symmetric_flag" : false, + "consistent_mass_matrix" : false, "block_builder" : true, "move_mesh_flag" : false, "problem_domain_sub_model_part_list" : [], @@ -377,6 +378,8 @@ def _CreateSolutionScheme(self): def _CreateSolutionStrategy(self): analysis_type = self.settings["analysis_type"].GetString() + is_consistent_mass_matrix = self.settings["consistent_mass_matrix"].GetBool() + self.grid_model_part.ProcessInfo.SetValue(KratosParticle.USE_CONSISTENT_MASS_MATRIX, is_consistent_mass_matrix) if analysis_type == "non_linear": solution_strategy = self._CreateNewtonRaphsonStrategy() elif analysis_type == 'linear': From 7802c85de0566de2b21974635f9cca01cd7408d6 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Fri, 24 Apr 2020 10:03:54 +1000 Subject: [PATCH 224/314] add test for consistent mass matrix --- ..._cantilever_consistent_mass_test_Body.mdpa | 85 +++++ ..._cantilever_consistent_mass_test_Grid.mdpa | 295 ++++++++++++++++++ ...ilever_consistent_mass_test_materials.json | 19 ++ ...lever_consistent_mass_test_parameters.json | 91 ++++++ ...ntilever_consistent_mass_test_results.json | 1 + .../tests/particle_mechanics_test_factory.py | 3 + .../test_ParticleMechanicsApplication.py | 2 + 7 files changed, 496 insertions(+) create mode 100644 applications/ParticleMechanicsApplication/tests/beam_tests/dynamic_cantilever/dynamic_cantilever_consistent_mass_test_Body.mdpa create mode 100644 applications/ParticleMechanicsApplication/tests/beam_tests/dynamic_cantilever/dynamic_cantilever_consistent_mass_test_Grid.mdpa create mode 100644 applications/ParticleMechanicsApplication/tests/beam_tests/dynamic_cantilever/dynamic_cantilever_consistent_mass_test_materials.json create mode 100644 applications/ParticleMechanicsApplication/tests/beam_tests/dynamic_cantilever/dynamic_cantilever_consistent_mass_test_parameters.json create mode 100644 applications/ParticleMechanicsApplication/tests/beam_tests/dynamic_cantilever/dynamic_cantilever_consistent_mass_test_results.json diff --git a/applications/ParticleMechanicsApplication/tests/beam_tests/dynamic_cantilever/dynamic_cantilever_consistent_mass_test_Body.mdpa b/applications/ParticleMechanicsApplication/tests/beam_tests/dynamic_cantilever/dynamic_cantilever_consistent_mass_test_Body.mdpa new file mode 100644 index 000000000000..ee50176cdca9 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/beam_tests/dynamic_cantilever/dynamic_cantilever_consistent_mass_test_Body.mdpa @@ -0,0 +1,85 @@ +Begin ModelPartData +// VARIABLE_NAME value +End ModelPartData + +Begin Properties 0 +End Properties +Begin Nodes + 5 0.00000 1.00000 0.00000 + 10 0.00000 0.00000 0.00000 + 11 1.00000 1.00000 0.00000 + 13 1.00000 0.00000 0.00000 + 16 2.00000 1.00000 0.00000 + 21 2.00000 0.00000 0.00000 + 23 3.00000 1.00000 0.00000 + 26 3.00000 0.00000 0.00000 + 30 4.00000 1.00000 0.00000 + 32 4.00000 0.00000 0.00000 + 37 5.00000 1.00000 0.00000 + 38 5.00000 0.00000 0.00000 + 42 6.00000 1.00000 0.00000 + 44 6.00000 0.00000 0.00000 + 48 7.00000 1.00000 0.00000 + 50 7.00000 0.00000 0.00000 + 55 8.00000 1.00000 0.00000 + 56 8.00000 0.00000 0.00000 + 60 9.00000 1.00000 0.00000 + 62 9.00000 0.00000 0.00000 + 67 10.00000 1.00000 0.00000 + 69 10.00000 0.00000 0.00000 +End Nodes + + +Begin Elements UpdatedLagrangian2D4N// GUI group identifier: beam + 1 0 13 11 5 10 + 2 0 21 16 11 13 + 3 0 26 23 16 21 + 4 0 32 30 23 26 + 5 0 38 37 30 32 + 6 0 44 42 37 38 + 7 0 50 48 42 44 + 8 0 56 55 48 50 + 9 0 62 60 55 56 + 10 0 69 67 60 62 +End Elements + +Begin SubModelPart Parts_beam // Group beam // Subtree Parts + Begin SubModelPartNodes + 5 + 10 + 11 + 13 + 16 + 21 + 23 + 26 + 30 + 32 + 37 + 38 + 42 + 44 + 48 + 50 + 55 + 56 + 60 + 62 + 67 + 69 + End SubModelPartNodes + Begin SubModelPartElements + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + End SubModelPartElements + Begin SubModelPartConditions + End SubModelPartConditions +End SubModelPart diff --git a/applications/ParticleMechanicsApplication/tests/beam_tests/dynamic_cantilever/dynamic_cantilever_consistent_mass_test_Grid.mdpa b/applications/ParticleMechanicsApplication/tests/beam_tests/dynamic_cantilever/dynamic_cantilever_consistent_mass_test_Grid.mdpa new file mode 100644 index 000000000000..6f606e544c0c --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/beam_tests/dynamic_cantilever/dynamic_cantilever_consistent_mass_test_Grid.mdpa @@ -0,0 +1,295 @@ +Begin ModelPartData +// VARIABLE_NAME value +End ModelPartData + +Begin Properties 0 +End Properties +Begin Nodes + 1 -1.0000000000 2.0000000000 0.0000000000 + 2 -1.0000000000 1.0000000000 0.0000000000 + 3 0.0000000000 2.0000000000 0.0000000000 + 4 -0.0000000000 1.0000000000 0.0000000000 + 5 0.0000000000 1.0000000000 0.0000000000 + 6 -1.0000000000 -0.0000000000 0.0000000000 + 7 1.0000000000 2.0000000000 0.0000000000 + 8 1.0000000000 1.0000000000 0.0000000000 + 9 -0.0000000000 0.0000000000 0.0000000000 + 10 0.0000000000 0.0000000000 0.0000000000 + 11 1.0000000000 1.0000000000 0.0000000000 + 12 1.0000000000 0.0000000000 0.0000000000 + 13 1.0000000000 0.0000000000 0.0000000000 + 14 -1.0000000000 -1.0000000000 0.0000000000 + 15 2.0000000000 2.0000000000 0.0000000000 + 16 2.0000000000 1.0000000000 0.0000000000 + 17 0.0000000000 -1.0000000000 0.0000000000 + 18 2.0000000000 1.0000000000 0.0000000000 + 19 2.0000000000 0.0000000000 0.0000000000 + 20 1.0000000000 -1.0000000000 0.0000000000 + 21 2.0000000000 0.0000000000 0.0000000000 + 22 3.0000000000 2.0000000000 0.0000000000 + 23 3.0000000000 1.0000000000 0.0000000000 + 24 3.0000000000 1.0000000000 0.0000000000 + 25 2.0000000000 -1.0000000000 0.0000000000 + 26 3.0000000000 0.0000000000 0.0000000000 + 27 3.0000000000 -0.0000000000 0.0000000000 + 28 3.0000000000 -1.0000000000 0.0000000000 + 29 4.0000000000 2.0000000000 0.0000000000 + 30 4.0000000000 1.0000000000 0.0000000000 + 31 4.0000000000 1.0000000000 0.0000000000 + 32 4.0000000000 0.0000000000 0.0000000000 + 33 4.0000000000 0.0000000000 0.0000000000 + 34 4.0000000000 -1.0000000000 0.0000000000 + 35 5.0000000000 2.0000000000 0.0000000000 + 36 5.0000000000 1.0000000000 0.0000000000 + 37 5.0000000000 1.0000000000 0.0000000000 + 38 5.0000000000 0.0000000000 0.0000000000 + 39 5.0000000000 -0.0000000000 0.0000000000 + 40 5.0000000000 -1.0000000000 0.0000000000 + 41 6.0000000000 2.0000000000 0.0000000000 + 42 6.0000000000 1.0000000000 0.0000000000 + 43 6.0000000000 1.0000000000 0.0000000000 + 44 6.0000000000 0.0000000000 0.0000000000 + 45 6.0000000000 -0.0000000000 0.0000000000 + 46 6.0000000000 -1.0000000000 0.0000000000 + 47 7.0000000000 2.0000000000 0.0000000000 + 48 7.0000000000 1.0000000000 0.0000000000 + 49 7.0000000000 1.0000000000 0.0000000000 + 50 7.0000000000 0.0000000000 0.0000000000 + 51 7.0000000000 -0.0000000000 0.0000000000 + 52 7.0000000000 -1.0000000000 0.0000000000 + 53 8.0000000000 2.0000000000 0.0000000000 + 54 8.0000000000 1.0000000000 0.0000000000 + 55 8.0000000000 1.0000000000 0.0000000000 + 56 8.0000000000 0.0000000000 0.0000000000 + 57 8.0000000000 -0.0000000000 0.0000000000 + 58 8.0000000000 -1.0000000000 0.0000000000 + 59 9.0000000000 2.0000000000 0.0000000000 + 60 9.0000000000 1.0000000000 0.0000000000 + 61 9.0000000000 1.0000000000 0.0000000000 + 62 9.0000000000 0.0000000000 0.0000000000 + 63 9.0000000000 -0.0000000000 0.0000000000 + 64 9.0000000000 -1.0000000000 0.0000000000 + 65 10.0000000000 2.0000000000 0.0000000000 + 66 10.0000000000 1.0000000000 0.0000000000 + 67 10.0000000000 1.0000000000 0.0000000000 + 68 10.0000000000 -0.0000000000 0.0000000000 + 69 10.0000000000 0.0000000000 0.0000000000 + 70 10.0000000000 -1.0000000000 0.0000000000 + 71 11.0000000000 2.0000000000 0.0000000000 + 72 11.0000000000 1.0000000000 0.0000000000 + 73 11.0000000000 -0.0000000000 0.0000000000 + 74 11.0000000000 -1.0000000000 0.0000000000 +End Nodes + + +Begin Elements Element2D4N// GUI group identifier: grid + 11 0 17 9 6 14 + 12 0 20 12 9 17 + 13 0 25 19 12 20 + 14 0 28 27 19 25 + 15 0 34 33 27 28 + 16 0 40 39 33 34 + 17 0 46 45 39 40 + 18 0 52 51 45 46 + 19 0 58 57 51 52 + 20 0 64 63 57 58 + 21 0 70 68 63 64 + 22 0 74 73 68 70 + 23 0 9 4 2 6 + 24 0 12 8 4 9 + 25 0 19 18 8 12 + 26 0 27 24 18 19 + 27 0 33 31 24 27 + 28 0 39 36 31 33 + 29 0 45 43 36 39 + 30 0 51 49 43 45 + 31 0 57 54 49 51 + 32 0 63 61 54 57 + 33 0 68 66 61 63 + 34 0 73 72 66 68 + 35 0 4 3 1 2 + 36 0 8 7 3 4 + 37 0 18 15 7 8 + 38 0 24 22 15 18 + 39 0 31 29 22 24 + 40 0 36 35 29 31 + 41 0 43 41 35 36 + 42 0 49 47 41 43 + 43 0 54 53 47 49 + 44 0 61 59 53 54 + 45 0 66 65 59 61 + 46 0 72 71 65 66 + 48 0 14 17 65 66 + 49 0 17 20 65 66 + 50 0 20 25 65 66 + 51 0 25 28 65 66 + 52 0 28 34 65 66 + 53 0 34 40 65 66 + 54 0 40 46 65 66 + 55 0 46 52 65 66 + 56 0 52 58 65 66 + 57 0 58 64 65 66 + 58 0 64 70 65 66 + 59 0 70 74 65 66 + 60 0 74 73 65 66 + 61 0 73 72 65 66 + 62 0 72 71 65 66 + 63 0 1 3 65 66 + 64 0 3 7 65 66 + 65 0 7 15 65 66 + 66 0 15 22 65 66 + 67 0 22 29 65 66 + 68 0 29 35 65 66 + 69 0 35 41 65 66 + 70 0 41 47 65 66 + 71 0 47 53 65 66 + 72 0 53 59 65 66 + 73 0 59 65 65 66 + 74 0 65 71 65 66 + 75 0 14 6 65 66 + 76 0 6 2 65 66 + 77 0 2 1 65 66 +End Elements + +Begin SubModelPart Parts_grid // Group grid // Subtree Parts + Begin SubModelPartNodes + 1 + 2 + 3 + 4 + 6 + 7 + 8 + 9 + 12 + 14 + 15 + 17 + 18 + 19 + 20 + 22 + 24 + 25 + 27 + 28 + 29 + 31 + 33 + 34 + 35 + 36 + 39 + 40 + 41 + 43 + 45 + 46 + 47 + 49 + 51 + 52 + 53 + 54 + 57 + 58 + 59 + 61 + 63 + 64 + 65 + 66 + 68 + 70 + 71 + 72 + 73 + 74 + End SubModelPartNodes + Begin SubModelPartElements + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + End SubModelPartElements + Begin SubModelPartConditions + End SubModelPartConditions +End SubModelPart +Begin SubModelPart DISPLACEMENT_restraint // Group restraint // Subtree DISPLACEMENT + Begin SubModelPartNodes + 1 + 2 + 3 + 4 + 6 + 9 + 14 + 17 + End SubModelPartNodes + Begin SubModelPartElements + End SubModelPartElements + Begin SubModelPartConditions + End SubModelPartConditions +End SubModelPart diff --git a/applications/ParticleMechanicsApplication/tests/beam_tests/dynamic_cantilever/dynamic_cantilever_consistent_mass_test_materials.json b/applications/ParticleMechanicsApplication/tests/beam_tests/dynamic_cantilever/dynamic_cantilever_consistent_mass_test_materials.json new file mode 100644 index 000000000000..34e99ec26ffd --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/beam_tests/dynamic_cantilever/dynamic_cantilever_consistent_mass_test_materials.json @@ -0,0 +1,19 @@ +{ + "properties" : [{ + "model_part_name" : "Initial_MPM_Material.Parts_beam", + "properties_id" : 1, + "Material" : { + "constitutive_law" : { + "name" : "LinearElasticIsotropicPlaneStress2DLaw" + }, + "Variables" : { + "THICKNESS" : 0.1, + "PARTICLES_PER_ELEMENT" : 4, + "DENSITY" : 7850.0, + "YOUNG_MODULUS" : 210000000000.0, + "POISSON_RATIO" : 0.3 + }, + "Tables" : {} + } + }] +} diff --git a/applications/ParticleMechanicsApplication/tests/beam_tests/dynamic_cantilever/dynamic_cantilever_consistent_mass_test_parameters.json b/applications/ParticleMechanicsApplication/tests/beam_tests/dynamic_cantilever/dynamic_cantilever_consistent_mass_test_parameters.json new file mode 100644 index 000000000000..17dad50fb207 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/beam_tests/dynamic_cantilever/dynamic_cantilever_consistent_mass_test_parameters.json @@ -0,0 +1,91 @@ +{ + "problem_data" : { + "problem_name" : "dynamic_cantilever_consistent_mass_test", + "parallel_type" : "OpenMP", + "echo_level" : 0, + "start_time" : 0.0, + "end_time" : 1.0 + }, + "solver_settings" : { + "solver_type" : "Dynamic", + "model_part_name" : "MPM_Material", + "domain_size" : 2, + "echo_level" : 0, + "analysis_type" : "non_linear", + "time_integration_method" : "implicit", + "scheme_type" : "newmark", + "model_import_settings" : { + "input_type" : "mdpa", + "input_filename" : "beam_tests/dynamic_cantilever/dynamic_cantilever_consistent_mass_test_Body" + }, + "material_import_settings" : { + "materials_filename" : "beam_tests/dynamic_cantilever/dynamic_cantilever_consistent_mass_test_materials.json" + }, + "time_stepping" : { + "time_step" : 0.1 + }, + "convergence_criterion" : "residual_criterion", + "consistent_mass_matrix" : true, + "displacement_relative_tolerance" : 0.0001, + "displacement_absolute_tolerance" : 1e-9, + "residual_relative_tolerance" : 0.0001, + "residual_absolute_tolerance" : 1e-9, + "max_iteration" : 10, + "problem_domain_sub_model_part_list" : ["Parts_beam","Parts_grid"], + "processes_sub_model_part_list" : ["DISPLACEMENT_restraint"], + "grid_model_import_settings" : { + "input_type" : "mdpa", + "input_filename" : "beam_tests/dynamic_cantilever/dynamic_cantilever_consistent_mass_test_Grid" + }, + "pressure_dofs" : false + }, + "processes" : { + "constraints_process_list" : [{ + "python_module" : "assign_vector_variable_process", + "kratos_module" : "KratosMultiphysics", + "Parameters" : { + "model_part_name" : "Background_Grid.DISPLACEMENT_restraint", + "variable_name" : "DISPLACEMENT", + "constrained" : [true,true,true], + "value" : [0.0,0.0,0.0], + "interval" : [0.0,"End"] + } + }], + "loads_process_list" : [], + "list_other_processes" : [{ + "python_module" : "particle_from_json_check_result_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "help" : "", + "process_name" : "ParticleFromJsonCheckResultProcess", + "Parameters" : { + "check_variables" : ["MP_VELOCITY","MP_DISPLACEMENT","MP_VOLUME"], + "input_file_name" : "beam_tests/dynamic_cantilever/dynamic_cantilever_consistent_mass_test_results.json", + "model_part_name" : "MPM_Material", + "time_frequency" : 0.1 + } + }], + "gravity" : [{ + "python_module" : "assign_gravity_to_particle_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "process_name" : "AssignGravityToParticleProcess", + "Parameters" : { + "model_part_name" : "MPM_Material", + "variable_name" : "MP_VOLUME_ACCELERATION", + "modulus" : 9.81, + "direction" : [0.0,-1.0,0.0] + } + }] + }, + "print_output_process" : [{ + "python_module" : "particle_json_output_process", + "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", + "help" : "", + "process_name" : "ParticleJsonOutputProcess", + "Parameters" : { + "gauss_points_output_variables" : ["MP_VELOCITY","MP_DISPLACEMENT","MP_VOLUME"], + "output_file_name" : "beam_tests/dynamic_cantilever/dynamic_cantilever_consistent_mass_test_results.json", + "model_part_name" : "MPM_Material", + "time_frequency" : 0.1 + } + }] +} diff --git a/applications/ParticleMechanicsApplication/tests/beam_tests/dynamic_cantilever/dynamic_cantilever_consistent_mass_test_results.json b/applications/ParticleMechanicsApplication/tests/beam_tests/dynamic_cantilever/dynamic_cantilever_consistent_mass_test_results.json new file mode 100644 index 000000000000..404877adedf0 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/beam_tests/dynamic_cantilever/dynamic_cantilever_consistent_mass_test_results.json @@ -0,0 +1 @@ +{"TIME": [0.2, 0.30000000000000004, 0.5, 0.7, 0.8999999999999999, 1.0999999999999999], "PARTICLE_77": {"MP_VELOCITY_X": [-0.0003048329721276926, 0.0009803739538722413, 4.008276132500433e-05, -0.00036255051545320855, -0.0005172192125249307, 8.319187134761245e-05], "MP_VELOCITY_Y": [0.0060394746046257275, -0.011743287864699165, -0.02603533463618879, -0.0367684308657993, -0.03984215692616004, -0.03990990941837948], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-1.845905765330371e-05, -2.6084187150489767e-05, -6.283362640149166e-06, -2.1950672185746607e-05, -5.014803769348392e-05, -5.161210601192819e-05], "MP_DISPLACEMENT_Y": [-3.4998117513839e-05, -5.351290386352202e-05, -1.5520569171197668e-05, -4.450016605505197e-05, -9.720824666961271e-05, -9.937147636588113e-05], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.02499941528384283, 0.02499917355795493, 0.024999801335281742, 0.024999304862979462, 0.02499841105342348, 0.024998364911502237]}, "PARTICLE_78": {"MP_VELOCITY_X": [0.00030871355243933143, -0.0009883594456127414, -6.41153420582964e-05, 0.00031609623709457756, 0.0004480377124464101, -0.00017189464396280665], "MP_VELOCITY_Y": [0.0060378564432101095, -0.01174366012958937, -0.02603533982559823, -0.03676614803035222, -0.03984071302182504, -0.03990730108511631], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [1.8425675367213415e-05, 2.6054572706313463e-05, 6.250577537939364e-06, 2.189857228769474e-05, 5.007689416053581e-05, 5.1522609648309916e-05], "MP_DISPLACEMENT_Y": [-3.504229565558154e-05, -5.3559406321249426e-05, -1.558712398708183e-05, -4.4594582004221916e-05, -9.731502904282149e-05, -9.951773961297277e-05], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.02500058448339142, 0.02500082629078424, 0.025000198645746124, 0.025000694829091775, 0.02500158805731728, 0.02500163415209235]}, "PARTICLE_79": {"MP_VELOCITY_X": [-0.00026360407738248954, -0.0006237651975027317, 3.406484471237594e-05, 8.668092160353668e-05, 0.000185484939788861, -9.856962034153962e-05], "MP_VELOCITY_Y": [0.003668664811236067, -0.00956924032410234, -0.02625029131562045, -0.0391291144538819, -0.04141573907414632, -0.03911818155187019], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [4.934323362686253e-06, 6.978661827287327e-06, 1.670336903568009e-06, 5.861741020976341e-06, 1.3412995752952911e-05, 1.3797828390356203e-05], "MP_DISPLACEMENT_Y": [-9.389555407737533e-06, -1.4351200207880782e-05, -4.17655864122621e-06, -1.1949083843260141e-05, -2.6075484804231526e-05, -2.6665699816799043e-05], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.025000583713523435, 0.02500082555456539, 0.02500019753562842, 0.02500069334335776, 0.02500158664900033, 0.025001632125989968]}, "PARTICLE_80": {"MP_VELOCITY_X": [0.0002653046965201541, 0.0006177164740899604, -5.665316588208621e-05, -0.00013353320893368619, -0.0002562805497996181, 7.88389875826099e-06], "MP_VELOCITY_Y": [0.0036690629467315723, -0.009569672460561222, -0.02625109813976545, -0.03912963886489651, -0.041414490356691605, -0.03911801248630935], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-4.948909659239577e-06, -6.991875549627568e-06, -1.68811991513039e-06, -5.887626049975334e-06, -1.3442192651818995e-05, -1.3837033947500659e-05], "MP_DISPLACEMENT_Y": [-9.377717910042969e-06, -1.4338739911610592e-05, -4.158725331274186e-06, -1.19237851646343e-05, -2.6046872552204424e-05, -2.6626508695282162e-05], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.024999414514298476, 0.024999172822047108, 0.02499980022567248, 0.02499930337789085, 0.024998409645670842, 0.024998362886213245]}, "PARTICLE_81": {"MP_VELOCITY_X": [-0.0008194725942123142, 0.001985468007549857, 0.00016598551197615679, -0.0007545380935841666, -0.0009901154872525172, 0.0002057459778606159], "MP_VELOCITY_Y": [0.015985842014553244, -0.021416921357747584, -0.025552634054992623, -0.026572016012369342, -0.03268067214816536, -0.04293264032790249], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-3.92395299349015e-05, -5.241383952621684e-05, -1.0821500106710584e-05, -4.467774838000069e-05, -0.00010507931588490675, -0.00010871628276095732], "MP_DISPLACEMENT_Y": [-0.00013844116693103323, -0.00019828470327360644, -4.92614892840776e-05, -0.00016633033760853934, -0.0003775014668422589, -0.0003879981528785524], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.024999502898109698, 0.024999391925445317, 0.02499991676932468, 0.024999476516121118, 0.024998696684473642, 0.024998644634638804]}, "PARTICLE_82": {"MP_VELOCITY_X": [0.0008308295113635773, -0.0020035081888411985, -0.00019929753202831894, 0.000706777647924668, 0.0009228680761197822, -0.00029336250446329603], "MP_VELOCITY_Y": [0.01598186746844448, -0.02141720778361541, -0.025553983935433122, -0.026569256570595244, -0.0326770652241097, -0.042929387136813844], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [3.8905171119647336e-05, 5.207734586301606e-05, 1.0352535738573172e-05, 4.3984300457562656e-05, 0.00010424959172115996, 0.00010760078712313936], "MP_DISPLACEMENT_Y": [-0.00013859263571568912, -0.00019844224474127063, -4.949696000161954e-05, -0.0001666743992608147, -0.0003778970399410483, -0.0003885387611389765], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.02500049750208155, 0.025000608584035983, 0.02500008419106391, 0.025000524587198276, 0.02500130387072808, 0.025001356386960993]}, "PARTICLE_83": {"MP_VELOCITY_X": [0.0006017909306625128, -0.0013583947089978073, -0.00012698885354458004, 0.0004816797245431534, 0.0006449926398019181, -0.0002249357562773983], "MP_VELOCITY_Y": [0.009338009415900395, -0.014917164050393169, -0.025848214272227218, -0.03340327601469979, -0.037502581393665815, -0.04093249523381709], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [2.7525951444106828e-05, 3.813649683756877e-05, 8.572197311968737e-06, 3.210646610645309e-05, 7.441047674879578e-05, 7.664802877145632e-05], "MP_DISPLACEMENT_Y": [-6.965466581445608e-05, -0.00010287934923610258, -2.771786072949952e-05, -8.603554673241399e-05, -0.00019157032341408003, -0.00019645885844716854], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.02500049682829572, 0.0250006079256933, 0.025000083011868658, 0.025000522965159498, 0.025001302463946468, 0.025001354282884986]}, "PARTICLE_84": {"MP_VELOCITY_X": [-0.0005956737423932362, 0.00134652739053319, 9.93952368303681e-05, -0.0005295128505886434, -0.0007144675826178698, 0.00013536752597628779], "MP_VELOCITY_Y": [0.009338904203461153, -0.014918898955361831, -0.02584873124804328, -0.03340108807710065, -0.03749854025448105, -0.040928041914432854], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-2.7649373739931594e-05, -3.8257185156100504e-05, -8.735384680640847e-06, -3.235143448201139e-05, -7.470811185977705e-05, -7.70438918106342e-05], "MP_DISPLACEMENT_Y": [-6.958806951355676e-05, -0.00010280819331052683, -2.7618680310437683e-05, -8.589087858458809e-05, -0.0001913952646952082, -0.0001962232404845321], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.024999502224855426, 0.024999391267607814, 0.024999915590995566, 0.024999474895190988, 0.02499869527839945, 0.024998642531420697]}, "PARTICLE_85": {"MP_VELOCITY_X": [-0.0011497413245219164, 0.0028640824100510023, 0.0002065243741930236, -0.0010912719869182155, -0.0014205316096890632, 0.00030924299646155616], "MP_VELOCITY_Y": [0.03197863226464506, -0.03742444937029844, -0.025521200821935944, -0.009881801756996694, -0.020160745037634747, -0.04591411289587273], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-5.67762042621674e-05, -7.150554473438342e-05, -1.2243346321029605e-05, -6.206762711817812e-05, -0.0001500286003934874, -0.0001560951679951026], "MP_DISPLACEMENT_Y": [-0.00030728477144669505, -0.0004190481084761122, -9.038096841055155e-05, -0.00035423173475531496, -0.0008272398476543972, -0.0008534680297348838], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.02499958915991287, 0.024999569967300902, 0.024999995862597633, 0.02499961655134755, 0.024998956147366358, 0.024998904755376326]}, "PARTICLE_86": {"MP_VELOCITY_X": [0.001176310005349661, -0.0028986180341037666, -0.0002543810117752571, 0.0010439215103864028, 0.001354502836145299, -0.0003952909117814196], "MP_VELOCITY_Y": [0.03197200369821101, -0.03742403103254192, -0.025524643236520025, -0.009880369773305451, -0.020156741825913052, -0.04591260013113023], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [5.571983667969848e-05, 7.042896872710562e-05, 1.0655563964230227e-05, 5.971132979811686e-05, 0.00014724872898549726, 0.0001523223465243631], "MP_DISPLACEMENT_Y": [-0.00030756844509731624, -0.00041934056529115355, -9.08397140393577e-05, -0.0003549149186302755, -0.0008280292351488462, -0.0008545490126691893], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.025000411553268705, 0.025000430873590333, 0.025000005679408525, 0.025000385490151367, 0.02500104541658365, 0.025001097623438297]}, "PARTICLE_87": {"MP_VELOCITY_X": [0.0009847761524117335, -0.0024162006318463676, -0.00023346586838353064, 0.0008572747026030498, 0.0011128036449482913, -0.00033925676849477993], "MP_VELOCITY_Y": [0.022047799363093555, -0.027446326881363545, -0.02546686276318743, -0.0202709256084333, -0.028035302706253214, -0.044270864672170875], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [4.645997727633497e-05, 6.073008496846283e-05, 1.0909595754613068e-05, 5.137867245291069e-05, 0.0001237645243073591, 0.00012787456325423293], "MP_DISPLACEMENT_Y": [-0.00020233126365803408, -0.00028322782706815153, -6.639101948593691e-05, -0.00023869291518238922, -0.0005484120981192706, -0.0005648381371024057], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.025000410754386877, 0.02500043007973352, 0.02500000414345544, 0.025000383300963352, 0.025001043505620733, 0.02500109477110431]}, "PARTICLE_88": {"MP_VELOCITY_X": [-0.0009679307381383693, 0.002392104168348683, 0.0001946586502539337, -0.0009052045163198607, -0.0011794665980901613, 0.00025209920827393807], "MP_VELOCITY_Y": [0.02205096317042976, -0.027448844241351918, -0.025465289968833522, -0.020265419019719302, -0.028028968963756347, -0.04426157407152429], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-4.704373339233657e-05, -6.13226852649721e-05, -1.1762558781924039e-05, -5.264241472259324e-05, -0.00012526331872178233, -0.00012990099397906023], "MP_DISPLACEMENT_Y": [-0.0002021420220866861, -0.00028303091461856934, -6.60980757824431e-05, -0.00023825964987905427, -0.0005478991405821353, -0.0005641417500000729], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.02499958836150411, 0.024999569173912023, 0.02499999432751233, 0.024999614363318063, 0.024998954237144443, 0.024998901903953315]}, "PARTICLE_89": {"MP_VELOCITY_X": [-0.0014084609509011862, 0.003534615807228198, 0.0002454421039570381, -0.0013628365720766708, -0.001778106136694818, 0.00039407547489568535], "MP_VELOCITY_Y": [0.05253850826533553, -0.05814702605706329, -0.026007562590030286, 0.011451747460301523, -0.0024061245581502317, -0.04473270053686376], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-7.11770095186322e-05, -8.489699040303382e-05, -1.1925361632540108e-05, -7.539324576324237e-05, -0.00018614372342473095, -0.0001947001456174503], "MP_DISPLACEMENT_Y": [-0.0005296680913077908, -0.0006927655987229987, -0.00012941119795387753, -0.0005901455968122505, -0.001411620139550096, -0.0014606597035514703], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.024999672716889278, 0.024999710321548477, 0.02500004257871912, 0.024999727471675167, 0.02499918949205962, 0.024999144605451863]}, "PARTICLE_90": {"MP_VELOCITY_X": [0.0014589166190027967, -0.003593090192914716, -0.00031151736074393286, 0.0013200426180774078, 0.0017144890626727355, -0.00047518957886792207], "MP_VELOCITY_Y": [0.0525294779801536, -0.058145588307999874, -0.026013519070732558, 0.011450582350058818, -0.002403511967911, -0.044732416307369106], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [6.894444376382119e-05, 8.262020416040071e-05, 8.424865621630025e-06, 7.015746556324242e-05, 0.0001799970718554736, 0.00018631917294483402], "MP_DISPLACEMENT_Y": [-0.0005300777849786716, -0.0006931848173486414, -0.00013009999253736507, -0.0005911861640398976, -0.0014128255802984635, -0.001462315180438004], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.025000328051497784, 0.025000290584734953, 0.024999959159479033, 0.025000274976000762, 0.02500081257147448, 0.025000858431155532]}, "PARTICLE_91": {"MP_VELOCITY_X": [0.001303429489505359, -0.0032138295787047183, -0.00027518201325190967, 0.0011680322847352766, 0.0015158403233814916, -0.00043156952800050814], "MP_VELOCITY_Y": [0.04014073265087985, -0.04564828247919735, -0.025670871224699646, -0.0013857182435438372, -0.013295290480630065, -0.04604489243454735], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [6.174612825093886e-05, 7.629570022765562e-05, 9.991207796400468e-06, 6.47445773420045e-05, 0.00016231746024826315, 0.00016798424004567752], "MP_DISPLACEMENT_Y": [-0.00039537789022570514, -0.0005291781216724849, -0.00010788922917935378, -0.0004493341609298171, -0.0010596213789897673, -0.0010949870407240643], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.02500032735218744, 0.025000289866972152, 0.02499995764691829, 0.025000272760396607, 0.025000810641552094, 0.025000855534800637]}, "PARTICLE_92": {"MP_VELOCITY_X": [-0.001267708318840237, 0.0031703518026572008, 0.00022024743612840468, -0.001213765290460633, -0.0015807995566857293, 0.0003474502935167542], "MP_VELOCITY_Y": [0.04014654876626889, -0.045651594745056666, -0.025666745185451305, -0.001378098765634812, -0.013288545037504432, -0.04603171773417862], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-6.324105696513239e-05, -7.782092969780196e-05, -1.2285428155590797e-05, -6.816206258849862e-05, -0.0001663400684235646, -0.0001734561732232102], "MP_DISPLACEMENT_Y": [-0.0003950551613784844, -0.000528846350409465, -0.00010736710398992879, -0.0004485505194847826, -0.0010586999646012352, -0.0010937295050302712], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.024999672017902902, 0.024999709604119492, 0.02500004106683224, 0.02499972525699901, 0.024999187562714235, 0.024999141709801304]}, "PARTICLE_93": {"MP_VELOCITY_X": [-0.0015990979178201986, 0.00403242949632482, 0.0002749650940434608, -0.0015808662111965657, -0.002052659623500263, 0.0004632111409791127], "MP_VELOCITY_Y": [0.07642749679549993, -0.08220322842414063, -0.02660928923245104, 0.03641362648630932, 0.022681460497541966, -0.037610398065022144], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-8.258032599675131e-05, -9.395189847587975e-05, -1.0971054130468852e-05, -8.568891218821927e-05, -0.00021444671015128196, -0.00022536361325076345], "MP_DISPLACEMENT_Y": [-0.0007941414294499003, -0.0010014778514767198, -0.00016115701166560803, -0.0008598853702469901, -0.002099406101860603, -0.002177222339096713], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.02499975176048977, 0.024999816585381106, 0.02500006241800746, 0.024999812894807176, 0.024999396882026348, 0.024999362944755008]}, "PARTICLE_94": {"MP_VELOCITY_X": [0.0016816713506534577, -0.004122225859027756, -0.00036300082629226946, 0.0015493101738355088, 0.0020011002977815026, -0.0005348808780149681], "MP_VELOCITY_Y": [0.07641655780980235, -0.08220073519629793, -0.026617704738316747, 0.03640930781856426, 0.022681446186126372, -0.03760847819880397], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [7.876463908536435e-05, 9.006847155063623e-05, 4.788509403455272e-06, 7.637204304615999e-05, 0.00020353497266968338, 0.00021043587196119205], "MP_DISPLACEMENT_Y": [-0.000794655471344444, -0.001002000530480872, -0.00016205158290545987, -0.000861250943908858, -0.002100991015139333, -0.002179405529510037], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.025000248926449375, 0.025000184237941453, 0.024999939253263746, 0.02500018955246221, 0.02500060528361635, 0.025000640207836572]}, "PARTICLE_95": {"MP_VELOCITY_X": [0.0015603712206542397, -0.0038362967888829016, -0.0003348436043282164, 0.001422496190433106, 0.0018448238173112232, -0.0005024685973768568], "MP_VELOCITY_Y": [0.062250579865922265, -0.06793842368460833, -0.026267068608010508, 0.021573499743368984, 0.00723136054100719, -0.04248330171191847], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [7.350665464610551e-05, 8.631251423674007e-05, 7.033960375354585e-06, 7.327733954965278e-05, 0.00019104499259461481, 0.00019769936642185842], "MP_DISPLACEMENT_Y": [-0.0006370556189059435, -0.0008198684952128748, -0.000144592979493662, -0.0007015293948829924, -0.001691834172840444, -0.001752845507359324], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.025000248375748765, 0.025000183651713283, 0.024999937925279644, 0.02500018756981556, 0.025000603555010235, 0.02500063759454673]}, "PARTICLE_96": {"MP_VELOCITY_X": [-0.0014971526344198876, 0.0037658059079190057, 0.0002603126875817515, -0.001460890875130514, -0.0019042072837189995, 0.0004255311464353432], "MP_VELOCITY_Y": [0.06225892249183445, -0.0679423735580113, -0.026260263965524902, 0.021582248584391228, 0.007237064844322783, -0.04246479759581903], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-7.635679010349573e-05, -8.921731965208267e-05, -1.156988096921702e-05, -8.008506941462875e-05, -0.000199029998077499, -0.00020860319981280426], "MP_DISPLACEMENT_Y": [-0.0006366113064239227, -0.0008194156481715824, -0.00014384420493402912, -0.0007003922508956374, -0.0016905020586541878, -0.0017510193897050644], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.024999751209973595, 0.024999815999351294, 0.02500006109046109, 0.024999810912775953, 0.024999395153796206, 0.02499936033192511]}, "PARTICLE_97": {"MP_VELOCITY_X": [-0.0017273352888345622, 0.004377385625413968, 0.0002889333470923435, -0.001737242129929451, -0.0022421512175446485, 0.0005149346727300071], "MP_VELOCITY_Y": [0.10262345548324125, -0.10851242813646564, -0.027038313017371016, 0.06727544668003571, 0.05793905050403361, -0.03191080960653203], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-9.119114066718446e-05, -9.985255729214214e-05, -1.0187419635525346e-05, -9.374926136811588e-05, -0.0002358780127560566, -0.0002488929389216677], "MP_DISPLACEMENT_Y": [-0.0010899461115693142, -0.0013317826672237234, -0.00018388963071406215, -0.001152606464925987, -0.0028629121110520135, -0.002973791028485908], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.024999824097676676, 0.02499989302035356, 0.025000061938016658, 0.02499987713949233, 0.024999578185614643, 0.024999557170777783]}, "PARTICLE_98": {"MP_VELOCITY_X": [0.001848822567984328, -0.004504897050233512, -0.00040309836145676747, 0.0017296939934582523, 0.002218886377455315, -0.000580575427947402], "MP_VELOCITY_Y": [0.10261117384480303, -0.10850900784931766, -0.027048794947768573, 0.06726613571349749, 0.05793350587307344, -0.03191300186903851], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [8.54717190365841e-05, 9.404621695774983e-05, 6.680950901002101e-07, 7.931479575778571e-05, 0.00021899377450781293, 0.00022573251174755072], "MP_DISPLACEMENT_Y": [-0.001090536875021677, -0.001332380351268042, -0.000184946885491082, -0.0011542317572022472, -0.002864801702180982, -0.0029764009286410925], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.02500017644384388, 0.025000107644494104, 0.024999939489440036, 0.025000125005866913, 0.025000423777611105, 0.025000445680610023]}, "PARTICLE_99": {"MP_VELOCITY_X": [0.0017590714050353842, -0.00430116650558523, -0.000381053517742533, 0.0016320075817872711, 0.0021017502874633594, -0.0005552573415396042], "MP_VELOCITY_Y": [0.08723192655901385, -0.09307055405156969, -0.02682708127587838, 0.048650561080525026, 0.0362655028160203, -0.03479142347000919], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [8.197277776920514e-05, 9.214275792903227e-05, 3.0868551538152636e-06, 7.79957567485423e-05, 0.00021102902291012362, 0.0002179549047066819], "MP_DISPLACEMENT_Y": [-0.0009161593698890863, -0.0011393210321406558, -0.00017284820711806464, -0.0009825276488529709, -0.0024152654229932635, -0.002507223543799579], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.02500017605600258, 0.025000107214598232, 0.024999938452012104, 0.025000123438685233, 0.02500042240956821, 0.025000443591151285]}, "PARTICLE_100": {"MP_VELOCITY_X": [-0.0016606661492016062, 0.004196512265331853, 0.00028287517477868125, -0.001654512302239778, -0.002142770964404994, 0.0004877639397451838], "MP_VELOCITY_Y": [0.08724234626388411, -0.09307498049570936, -0.026817847103980164, 0.04865909839773828, 0.03626848468423929, -0.03476714646688216], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-8.655302544100977e-05, -9.67995121082868e-05, -1.0596403477236923e-05, -8.934405765255332e-05, -0.00022431477885810695, -0.0002361514689478972], "MP_DISPLACEMENT_Y": [-0.0009156182707420097, -0.0011387729563570163, -0.00017190365006272083, -0.000981080650825544, -0.002413573674689002, -0.002504895547625541], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.024999823709922472, 0.024999892590555604, 0.025000060900825176, 0.02499987557264592, 0.02499957681777468, 0.024999555081569473]}, "PARTICLE_101": {"MP_VELOCITY_X": [-0.0018009937536476329, 0.004592541564304685, 0.00029215377649587787, -0.0018296054381199004, -0.002359313157135487, 0.0005441432825746093], "MP_VELOCITY_Y": [0.13031007788904841, -0.13625794366745814, -0.025490920276826534, 0.10979243703475083, 0.0976876103471265, -0.041657261810814444], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-9.730669597744852e-05, -0.0001035934291213818, -1.0074107216064096e-05, -0.00010014801081510065, -0.0002513697231149352, -0.000266191599339233], "MP_DISPLACEMENT_Y": [-0.001407337996894355, -0.001674226381046204, -0.0001984058190127552, -0.0014601879935981512, -0.003678039854364521, -0.003824420355381764], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.024999887268233375, 0.024999944361686458, 0.025000048417075083, 0.02499992476263947, 0.024999732195712613, 0.024999722740165434]}, "PARTICLE_102": {"MP_VELOCITY_X": [0.001966372993316385, -0.004762685275407039, -0.0004317021875530889, 0.0018673842375822093, 0.002371924929181352, -0.0006210677267378967], "MP_VELOCITY_Y": [0.13029697733968387, -0.13625380918615704, -0.025504400706363936, 0.10977247033807254, 0.09766906777578083, -0.04168377314265607], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [8.945921842611003e-05, 9.564515944849742e-05, -3.274181837038966e-06, 7.981058245711529e-05, 0.000227595854446848, 0.00023350933730655358], "MP_DISPLACEMENT_Y": [-0.0014079784412352374, -0.0016748719386848064, -0.0001995752999337354, -0.0014619934077206918, -0.0036801422286582655, -0.003827330012995874], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.02500011311418205, 0.025000056121444892, 0.024999952672085813, 0.025000076901403167, 0.025000269372258726, 0.025000279538932874]}, "PARTICLE_103": {"MP_VELOCITY_X": [0.001904466604211866, -0.004628370133636903, -0.00041643992270297544, 0.0017931737332063118, 0.00229173474895235, -0.0005976046121040554], "MP_VELOCITY_Y": [0.11415094510874617, -0.12007923037568032, -0.026693979434456533, 0.08364765063670684, 0.07439357837352584, -0.033767427846685155], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [8.747950356767758e-05, 9.498655288750802e-05, -1.0320910181554552e-06, 7.980752595641697e-05, 0.00022343845254010688, 0.00022990868359383], "MP_DISPLACEMENT_Y": [-0.0012223155261637153, -0.001475876324004363, -0.00019209681526939333, -0.0012826865454717775, -0.0032037090381138154, -0.003330098394316644], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.025000112869683084, 0.025000055839066365, 0.024999951955417123, 0.025000075812892132, 0.025000268418865355, 0.025000278066171694]}, "PARTICLE_104": {"MP_VELOCITY_X": [-0.0017648384595575334, 0.004483692671302924, 0.000291653260296744, -0.0017837424773846297, -0.002299716346784571, 0.000530676003687922], "MP_VELOCITY_Y": [0.11416288037088655, -0.12008396623181712, -0.02668317903551856, 0.08365190884354691, 0.07438909385859681, -0.0337491445912613], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-9.407074294992063e-05, -0.00010167107317265886, -1.0043088005919093e-05, -9.663756163390331e-05, -0.000243121654355192, -0.0002569336645229704], "MP_DISPLACEMENT_Y": [-0.0012217059826200184, -0.0014752615775468396, -0.0001910027583842326, -0.0012810008671576842, -0.003201740107558821, -0.003327380464370834], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.024999887023766994, 0.024999944079346224, 0.025000047700507736, 0.024999923674271556, 0.024999731242406627, 0.024999721267513875]}, "PARTICLE_105": {"MP_VELOCITY_X": [-0.0018299686467887297, 0.004704161809756412, 0.0002954790855235136, -0.0018696557830412183, -0.002424600177223914, 0.0005487128966709234], "MP_VELOCITY_Y": [0.1588659151661848, -0.16485580511709846, -0.014106201065514579, 0.16179595953475834, 0.1252837517885454, -0.07254572654697922], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-0.00010133329704341938, -0.00010597578290774531, -1.0824861520120966e-05, -0.00010528799400031944, -0.0002619556836709813, -0.0002783749942587338], "MP_DISPLACEMENT_Y": [-0.00173794228951676, -0.002022635523699875, -0.00020699933330666116, -0.0017766028985971762, -0.004524509641257685, -0.004707318044580565], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.024999938630349924, 0.02499997565609849, 0.025000029482825852, 0.024999959661468646, 0.02499985562452676, 0.024999853495529994]}, "PARTICLE_106": {"MP_VELOCITY_X": [0.002042444987725238, -0.004920333272317716, -0.00044323593415103576, 0.0019635991707977513, 0.00246189015550461, -0.0006611270176529192], "MP_VELOCITY_Y": [0.15885241069044798, -0.16485119055215192, -0.01412583778355174, 0.16175927398158163, 0.1252465946914883, -0.0726116267807218], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [9.122120321790238e-05, 9.575319624991816e-05, -6.671610057538426e-06, 7.853689712153785e-05, 0.0002306939615944421, 0.00023532566243412338], "MP_DISPLACEMENT_Y": [-0.0017386099011086663, -0.002023306828379797, -0.0002082332333276848, -0.001778511826172989, -0.004526735476432719, -0.0047104021972729495], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.02500006160785301, 0.025000024654416204, 0.024999971243741814, 0.025000041457733612, 0.025000145462001612, 0.025000148082987995]}, "PARTICLE_107": {"MP_VELOCITY_X": [0.0020034205496442235, -0.004840765163359646, -0.00043868575149432843, 0.001913428078845844, 0.002417941090817134, -0.0006375159077514746], "MP_VELOCITY_Y": [0.1422750025166325, -0.14825002114646335, -0.02213378015077211, 0.13072015542460752, 0.11131975743882816, -0.05206751799880219], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [9.046314779394729e-05, 9.585207958022212e-05, -4.781520395911022e-06, 7.947589588283495e-05, 0.00022954498103768992, 0.00023496851925437125], "MP_DISPLACEMENT_Y": [-0.0015463169982515954, -0.00182155295374506, -0.00020389207661171936, -0.0015948387680258208, -0.00403463683141699, -0.0041971665777016266], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.025000061473172398, 0.025000024492845812, 0.02499997081868672, 0.025000040811475843, 0.025000144890337278, 0.025000147191882843]}, "PARTICLE_108": {"MP_VELOCITY_X": [-0.0018183688204539985, 0.004651768693578653, 0.00029337261085538675, -0.0018522719669770257, -0.0023923883554392354, 0.0005495261671295839], "MP_VELOCITY_Y": [0.14228790634286714, -0.1482549217800433, -0.022124059399834084, 0.13071286187644943, 0.11130001320899774, -0.05207717132004833], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-9.925132052975621e-05, -0.00010474534190821996, -1.027970875728607e-05, -0.00010245998575960228, -0.00025641120743839666, -0.00027192900552882264], "MP_DISPLACEMENT_Y": [-0.0015456652698232097, -0.001820897442811902, -0.00020269930136391535, -0.0015929950052047037, -0.0040324840611358015, -0.004194188089425927], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.024999938495677894, 0.024999975494538636, 0.02500002905780163, 0.024999959015253884, 0.024999855052889822, 0.024999852604460023]}, "PARTICLE_109": {"MP_VELOCITY_X": [-0.0018261861294201404, 0.004751607707933541, 0.0003024437252381958, -0.0018761325407988267, -0.0024618216625737965, 0.0005401173642967885], "MP_VELOCITY_Y": [0.1878527616174283, -0.186826057075915, 0.011114032458713785, 0.20439038258941414, 0.12935956491114917, -0.11090788290473537], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-0.00010379639825801155, -0.00010760462517855437, -1.2352348611045067e-05, -0.00010949503052930628, -0.0002688890741175333, -0.00028682501842144513], "MP_DISPLACEMENT_Y": [-0.0020751284924476663, -0.0023734091317109776, -0.0002123951044554302, -0.002097424474618106, -0.00538643032799267, -0.005605774205396218], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.024999975434928646, 0.02499999211073316, 0.025000012390298663, 0.024999983820256352, 0.02499994303191098, 0.02499994344644646]}, "PARTICLE_110": {"MP_VELOCITY_X": [0.0020875106790191585, -0.004996777124551975, -0.00044045415782287874, 0.002020182976340181, 0.0024953805374372633, -0.0006922550586046898], "MP_VELOCITY_Y": [0.1878391311968641, -0.18682235162579539, 0.01109543750306266, 0.20435852641814203, 0.12933495975870693, -0.11096838654259836], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [9.135162888506014e-05, 9.504170427759741e-05, -9.460145941465545e-06, 7.6062241357167e-05, 0.0002298251627406956, 0.00023296321212610367], "MP_DISPLACEMENT_Y": [-0.0020758072279887714, -0.0023740907247636316, -0.00021365607171415328, -0.002099376874270737, -0.005388708783336478, -0.005608932706051833], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.025000024695803705, 0.025000008061824265, 0.02499998802398419, 0.025000016820667922, 0.02500005761266947, 0.025000057483711764]}, "PARTICLE_111": {"MP_VELOCITY_X": [0.0020650278092412336, -0.004962033134344446, -0.0004435648783811365, 0.001992499982191218, 0.0024829703853615328, -0.0006753367815901377], "MP_VELOCITY_Y": [0.1710614197551673, -0.17518583778339403, -0.005213789970610214, 0.18152354816864302, 0.13011401521424137, -0.08833287639718503], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [9.146012656891355e-05, 9.553707980978931e-05, -7.922479969158435e-06, 7.762643057760468e-05, 0.0002307726925862563, 0.00023479411734967848], "MP_DISPLACEMENT_Y": [-0.0018804855108071382, -0.0021713577703676846, -0.0002108463356735946, -0.0019136976307524466, -0.004889553793263378, -0.0050886770399915186], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.025000024629278424, 0.025000007981018004, 0.024999987807654292, 0.025000016490528076, 0.025000057309696674, 0.025000057014522792]}, "PARTICLE_112": {"MP_VELOCITY_X": [-0.0018320119931347222, 0.004731016526835703, 0.0002980415649330259, -0.0018758086901793872, -0.002442941885467226, 0.0005465703850133608], "MP_VELOCITY_Y": [0.17107483807797344, -0.17519175799469475, -0.005208747835297581, 0.1815045090537774, 0.1300824079113359, -0.08837114408756926], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-0.00010255027404469332, -0.00010674087873737941, -1.1377385417871307e-05, -0.00010716872945996968, -0.0002652954378019303, -0.00028236056624682623], "MP_DISPLACEMENT_Y": [-0.001879812436721365, -0.002170681754189692, -0.0002096006069772947, -0.0019117692576142093, -0.004887302556631827, -0.005085558059153145], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.02499997536840454, 0.024999992029928392, 0.02500001217397403, 0.024999983490123764, 0.0249999427289435, 0.02499994297726447]}, "PARTICLE_113": {"MP_VELOCITY_X": [-0.0018247191906934817, 0.004771436263146937, 0.0002974974322482722, -0.001878132975038478, -0.0024817141006772655, 0.0005230431057691886], "MP_VELOCITY_Y": [0.20281099428135732, -0.18885235857296714, 0.03066002133024734, 0.21996978906366485, 0.12037093261243162, -0.13166181921178782], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-0.00010534355091444095, -0.00010889779786402288, -1.435903483357388e-05, -0.0001131332769897635, -0.00027369853937242255, -0.00029315279291246445], "MP_DISPLACEMENT_Y": [-0.0024143975723360635, -0.0027247903662780347, -0.00021676966714087066, -0.0024196641610225696, -0.006253157362150728, -0.006508970085237907], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.024999994915730222, 0.024999998635833593, 0.025000002564693133, 0.024999996624079514, 0.024999988441100403, 0.024999988743203527]}, "PARTICLE_114": {"MP_VELOCITY_X": [0.00209737875818871, -0.005015133436646572, -0.0004455929786582498, 0.0020368191378048366, 0.002496597638771715, -0.0007165516472812151], "MP_VELOCITY_Y": [0.20280274603789814, -0.1888419795768286, 0.030646532947937427, 0.21996103418391613, 0.12036643802699001, -0.131688811115873], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [9.054248374975246e-05, 9.397085276737317e-05, -1.1831062016802842e-05, 7.292110623859704e-05, 0.00022671884221571359, 0.00022831748401111406], "MP_DISPLACEMENT_Y": [-0.0024150792597213023, -0.0027254745096785445, -0.00021803754206140002, -0.0024216278205829375, -0.006255449560272557, -0.006512147870839914], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.025000005110658242, 0.025000001409690414, 0.024999997549426264, 0.025000003541120606, 0.025000011727437543, 0.025000011506525987]}, "PARTICLE_115": {"MP_VELOCITY_X": [0.002096201036118653, -0.005010956557195959, -0.000440923061634943, 0.002032223815729011, 0.002499216568732172, -0.0007030384031445388], "MP_VELOCITY_Y": [0.19634090851267932, -0.19048415553347842, 0.020708837965098495, 0.2146784370915047, 0.1267433172597784, -0.12253896638816679], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [9.110614786224453e-05, 9.462254413335281e-05, -1.0506009797275158e-05, 7.480362323534107e-05, 0.00022874081244912768, 0.0002312308336790497], "MP_DISPLACEMENT_Y": [-0.0022190510126937095, -0.0025225656175477977, -0.00021558224550317917, -0.002235475303241233, -0.005754698528093325, -0.005990349046016225], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.025000005093380878, 0.0250000013839884, 0.0249999974773092, 0.025000003436888348, 0.025000011628179313, 0.025000011349361025]}, "PARTICLE_116": {"MP_VELOCITY_X": [-0.0018242005457322769, 0.004762496834662088, 0.00030237186175779583, -0.0018766273763988807, -0.0024720724591661067, 0.0005340142951342512], "MP_VELOCITY_Y": [0.19635990790994567, -0.19048394441980726, 0.020720124526661207, 0.2146768629239239, 0.12673703902666927, -0.12255552753155427], "MP_VELOCITY_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_DISPLACEMENT_X": [-0.00010454444561133861, -0.0001081820474373978, -1.314980408217677e-05, -0.00011109101925792139, -0.0002711387998525672, -0.00028971375450484926], "MP_DISPLACEMENT_Y": [-0.0022183703346105813, -0.0025218823437588088, -0.00021431678670976416, -0.0022335155847773742, -0.005752410920100085, -0.00598717779576507], "MP_DISPLACEMENT_Z": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "MP_VOLUME": [0.02499999489845289, 0.024999998610131628, 0.025000002492576372, 0.02499999651984766, 0.02499998834184255, 0.024999988586039096]}} \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py b/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py index a95a25ed2794..a8b09a1c86bd 100644 --- a/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py +++ b/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py @@ -66,6 +66,9 @@ class BeamCantileverStaticHyperelasticSelfWeightLoad2DQuadTest(ParticleMechanics class BeamCantileverLinearStaticHyperelasticSelfWeightLoad2DQuadTest(ParticleMechanicsTestFactory): file_name = "beam_tests/hyperelastic_cantilever_beam/linear_self_weight_load_2D_quad_test" +class BeamCantileverDynamicConsistentMassTest(ParticleMechanicsTestFactory): + file_name = "beam_tests/dynamic_cantilever/dynamic_cantilever_consistent_mass_test" + ### Cook's Membrane Tests class CooksMembraneCompressibleTest(ParticleMechanicsTestFactory): file_name = "cooks_membrane_tests/compressible_cook_membrane_2D_test" diff --git a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py index 36bc2c9a65bc..f8fcecd76d13 100644 --- a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py +++ b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py @@ -15,6 +15,7 @@ from particle_mechanics_test_factory import BeamCantileverStaticLinearElasticSurfaceLoad3DHexaTest as TBeamCantileverStaticLinearElasticSurfaceLoad3DHexaTest from particle_mechanics_test_factory import BeamCantileverStaticHyperelasticSelfWeightLoad2DQuadTest as TBeamCantileverStaticHyperelasticSelfWeightLoad2DQuadTest from particle_mechanics_test_factory import BeamCantileverLinearStaticHyperelasticSelfWeightLoad2DQuadTest as TBeamCantileverLinearStaticHyperelasticSelfWeightLoad2DQuadTest +from particle_mechanics_test_factory import BeamCantileverDynamicConsistentMassTest as TBeamCantileverDynamicConsistentMassTest from particle_mechanics_test_factory import CooksMembraneCompressibleTest as TCooksMembraneCompressibleTest from particle_mechanics_test_factory import CooksMembraneUPCompressibleTest as TCooksMembraneUPCompressibleTest @@ -96,6 +97,7 @@ def AssembleTestSuites(): nightSuite.addTest(TPenaltyImpositionBeamCantileverStaticHyperelasticSelfWeightLoad2DQuadTest('test_execution')) nightSuite.addTest(TBeamCantileverLinearStaticHyperelasticSelfWeightLoad2DQuadTest('test_execution')) + nightSuite.addTest(TBeamCantileverDynamicConsistentMassTest('test_execution')) ### Adding Validation Tests ## For very long tests that should not be in nighly and you can use to validate From 0cda020c3dabe8b717c90332003ec1145431f9fd Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Fri, 24 Apr 2020 13:50:43 +1000 Subject: [PATCH 225/314] added check for size2 --- .../custom_elements/updated_lagrangian.cpp | 2 +- .../custom_elements/updated_lagrangian_UP.cpp | 2 +- .../custom_elements/updated_lagrangian_quadrilateral.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp index 2573a97565b5..b43c671d9394 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp @@ -1292,7 +1292,7 @@ void UpdatedLagrangian::CalculateMassMatrix( MatrixType& rMassMatrix, const Proc const SizeType number_of_nodes = GetGeometry().PointsNumber(); const SizeType matrix_size = dimension * number_of_nodes; - if ( rMassMatrix.size1() != matrix_size ) + if ( rMassMatrix.size1() != matrix_size || rMassMatrix.size2() != matrix_size) rMassMatrix.resize( matrix_size, matrix_size, false ); rMassMatrix = ZeroMatrix(matrix_size, matrix_size); diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.cpp index f811eab21969..32489f02d898 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.cpp @@ -1035,7 +1035,7 @@ void UpdatedLagrangianUP::CalculateMassMatrix( MatrixType& rMassMatrix, const Pr const SizeType number_of_nodes = GetGeometry().PointsNumber(); const SizeType matrix_size = dimension * number_of_nodes; - if (rMassMatrix.size1() != matrix_size) + if (rMassMatrix.size1() != matrix_size || rMassMatrix.size2() != matrix_size) rMassMatrix.resize(matrix_size, matrix_size, false); rMassMatrix = ZeroMatrix(matrix_size, matrix_size); diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index 5c82a9cb1882..72ac4fb56966 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -1293,7 +1293,7 @@ void UpdatedLagrangianQuadrilateral::CalculateMassMatrix( MatrixType& rMassMatri const SizeType number_of_nodes = GetGeometry().PointsNumber(); const SizeType matrix_size = dimension * number_of_nodes; - if (rMassMatrix.size1() != matrix_size) + if (rMassMatrix.size1() != matrix_size || rMassMatrix.size2() != matrix_size) rMassMatrix.resize(matrix_size, matrix_size, false); rMassMatrix = ZeroMatrix(matrix_size, matrix_size); From 05c5bfa0b2c74c244855d039999a2c63ed7179ae Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Fri, 24 Apr 2020 14:36:55 +1000 Subject: [PATCH 226/314] Update applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h Co-Authored-By: tteschemacher --- .../custom_utilities/mpm_search_element_utility.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h b/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h index 58ea446b2451..dfe03eecbcce 100644 --- a/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h @@ -61,7 +61,6 @@ namespace MPMSearchElementUtility r_geometry[j].Reset(ACTIVE); } - // Search background grid and make element active Vector N; const int max_result = 1000; @@ -186,4 +185,3 @@ namespace MPMSearchElementUtility #endif // KRATOS_MPM_SEARCH_ELEMENT_UTILITY - From dda32d7e1aa9f865f555f036d549d365558e70b2 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Fri, 24 Apr 2020 14:37:06 +1000 Subject: [PATCH 227/314] Update applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py Co-Authored-By: tteschemacher --- .../tests/test_ParticleMechanicsApplication.py | 1 - 1 file changed, 1 deletion(-) diff --git a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py index 94934810bbe1..69760012ba1a 100644 --- a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py +++ b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py @@ -93,7 +93,6 @@ def AssembleTestSuites(): ## These tests are executed in the nightly build nightSuite = suites['nightly'] nightSuite.addTests(smallSuite) - nightSuite.addTest(TAxisSymmetricCircularPlate2DTriTest('test_execution')) nightSuite.addTest(TBeamCantileverStaticLinearElasticPointLoad2DTriTest('test_execution')) From d0f0fe78d5783e9c26709632d499a675ae1c4da0 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Fri, 24 Apr 2020 14:37:18 +1000 Subject: [PATCH 228/314] Update applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py Co-Authored-By: tteschemacher --- .../tests/test_ParticleMechanicsApplication.py | 1 - 1 file changed, 1 deletion(-) diff --git a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py index 69760012ba1a..ba10dce846af 100644 --- a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py +++ b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py @@ -106,7 +106,6 @@ def AssembleTestSuites(): nightSuite.addTest(TCooksMembraneUPIncompressibleTest('test_execution')) nightSuite.addTest(TPenaltyImpositionBeamCantileverStaticHyperelasticSelfWeightLoad2DQuadTest('test_execution')) - nightSuite.addTest(TBeamCantileverLinearStaticHyperelasticSelfWeightLoad2DQuadTest('test_execution')) nightSuite.addTest(TExplicitOscillatingPointUSLTest('test_execution')) From fe140aaa9147b3c341ea0275cca5e9884d045cb3 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Fri, 24 Apr 2020 14:37:28 +1000 Subject: [PATCH 229/314] Update applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dtet_compressible_explicit_oscillating_point_test_parameters.json Co-Authored-By: tteschemacher --- ...compressible_explicit_oscillating_point_test_parameters.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dtet_compressible_explicit_oscillating_point_test_parameters.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dtet_compressible_explicit_oscillating_point_test_parameters.json index 26437cc30b23..6e662a66bf0b 100644 --- a/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dtet_compressible_explicit_oscillating_point_test_parameters.json +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point_3d/3dtet_compressible_explicit_oscillating_point_test_parameters.json @@ -87,7 +87,7 @@ } }] }, - "print_output_process" : [{ + "print_output_process" : [{ "python_module" : "particle_json_output_process", "kratos_module" : "KratosMultiphysics.ParticleMechanicsApplication", "help" : "", From 47169dd3117d2afc511318120fce87490e4d044f Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Fri, 24 Apr 2020 14:37:38 +1000 Subject: [PATCH 230/314] Update applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py Co-Authored-By: tteschemacher --- .../tests/test_ParticleMechanicsApplication.py | 1 - 1 file changed, 1 deletion(-) diff --git a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py index ba10dce846af..5017fec3df4e 100644 --- a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py +++ b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py @@ -104,7 +104,6 @@ def AssembleTestSuites(): nightSuite.addTest(TCooksMembraneCompressibleTest('test_execution')) nightSuite.addTest(TCooksMembraneUPCompressibleTest('test_execution')) nightSuite.addTest(TCooksMembraneUPIncompressibleTest('test_execution')) - nightSuite.addTest(TPenaltyImpositionBeamCantileverStaticHyperelasticSelfWeightLoad2DQuadTest('test_execution')) nightSuite.addTest(TBeamCantileverLinearStaticHyperelasticSelfWeightLoad2DQuadTest('test_execution')) From b8f60d2215ab9aced1394e9e18c5f2b76778906f Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Fri, 24 Apr 2020 14:37:49 +1000 Subject: [PATCH 231/314] Update applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py Co-Authored-By: tteschemacher --- .../tests/test_ParticleMechanicsApplication.py | 1 - 1 file changed, 1 deletion(-) diff --git a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py index 5017fec3df4e..c05efcc666bb 100644 --- a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py +++ b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py @@ -100,7 +100,6 @@ def AssembleTestSuites(): nightSuite.addTest(TBeamCantileverStaticLinearElasticLineLoad2DQuadTest('test_execution')) nightSuite.addTest(TBeamCantileverStaticLinearElasticSurfaceLoad3DHexaTest('test_execution')) nightSuite.addTest(TBeamCantileverStaticHyperelasticSelfWeightLoad2DQuadTest('test_execution')) - nightSuite.addTest(TCooksMembraneCompressibleTest('test_execution')) nightSuite.addTest(TCooksMembraneUPCompressibleTest('test_execution')) nightSuite.addTest(TCooksMembraneUPIncompressibleTest('test_execution')) From d5dd11414cc4880187c2d894acbe77703f78ca16 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Fri, 24 Apr 2020 14:38:02 +1000 Subject: [PATCH 232/314] Update applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py Co-Authored-By: tteschemacher --- .../tests/test_ParticleMechanicsApplication.py | 1 - 1 file changed, 1 deletion(-) diff --git a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py index c05efcc666bb..085f0c350695 100644 --- a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py +++ b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py @@ -94,7 +94,6 @@ def AssembleTestSuites(): nightSuite = suites['nightly'] nightSuite.addTests(smallSuite) nightSuite.addTest(TAxisSymmetricCircularPlate2DTriTest('test_execution')) - nightSuite.addTest(TBeamCantileverStaticLinearElasticPointLoad2DTriTest('test_execution')) nightSuite.addTest(TBeamCantileverStaticLinearElasticParticlePointLoad2DTriTest('test_execution')) nightSuite.addTest(TBeamCantileverStaticLinearElasticLineLoad2DQuadTest('test_execution')) From 9261f97ea23313434687a01e6764af7ffe980f86 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Fri, 24 Apr 2020 14:41:23 +1000 Subject: [PATCH 233/314] remove unused cauchy_stress_vector --- .../custom_elements/updated_lagrangian.hpp | 5 ----- .../custom_elements/updated_lagrangian_quadrilateral.hpp | 5 ----- 2 files changed, 10 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.hpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.hpp index 51d57265b159..4ea1cc25091c 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.hpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.hpp @@ -132,11 +132,6 @@ class UpdatedLagrangian // MP_VOLUME volume = 1.0; - // MP_CAUCHY_STRESS_VECTOR - cauchy_stress_vector; - // MP_ALMANSI_STRAIN_VECTOR - almansi_strain_vector; - // MP_DELTA_PLASTIC_STRAIN delta_plastic_strain = 1.0; // MP_DELTA_PLASTIC_VOLUMETRIC_STRAIN diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp index fcc980f585e1..5fa26c91f433 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.hpp @@ -133,11 +133,6 @@ class UpdatedLagrangianQuadrilateral // MP_VOLUME volume = 1.0; - // MP_CAUCHY_STRESS_VECTOR - cauchy_stress_vector; - // MP_ALMANSI_STRAIN_VECTOR - almansi_strain_vector; - // MP_DELTA_PLASTIC_STRAIN delta_plastic_strain = 1.0; // MP_DELTA_PLASTIC_VOLUMETRIC_STRAIN From 57122894dbbe45e0708f4c56fc7081239335f391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20Irazabal?= Date: Fri, 24 Apr 2020 09:25:43 +0200 Subject: [PATCH 234/314] Add MaxTensileStress to joint properties --- .../simplified_bilinear_3D_law.cpp | 15 +++++++++++---- .../poromechanics_application.cpp | 1 + .../poromechanics_application_variables.cpp | 1 + .../poromechanics_application_variables.h | 1 + 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_3D_law.cpp b/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_3D_law.cpp index 6325a6952cb2..fcc5b45f854a 100644 --- a/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_3D_law.cpp +++ b/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_3D_law.cpp @@ -30,9 +30,16 @@ int SimplifiedBilinear3DLaw::Check(const Properties& rMaterialProperties,const G KRATOS_ERROR << "MAX_COMPRESSIVE_STRESS not defined" << std::endl; } + KRATOS_CHECK_VARIABLE_KEY(MAX_TENSILE_STRESS); + if(rMaterialProperties.Has(MAX_TENSILE_STRESS)) { + KRATOS_ERROR_IF(rMaterialProperties[MAX_TENSILE_STRESS] < 0.0) << "MAX_TENSILE_STRESS has an invalid value " << std::endl; + } else { + KRATOS_ERROR << "MAX_TENSILE_STRESS not defined" << std::endl; + } + KRATOS_CHECK_VARIABLE_KEY(POISSON_RATIO); if(rMaterialProperties.Has(POISSON_RATIO)) { - KRATOS_ERROR_IF(rMaterialProperties[POISSON_RATIO] < -1.0) << "POISSON_RATIO has an invalid value lower ahn -1.0" << std::endl; + KRATOS_ERROR_IF(rMaterialProperties[POISSON_RATIO] < -1.0) << "POISSON_RATIO has an invalid value lower than -1.0" << std::endl; KRATOS_ERROR_IF(rMaterialProperties[POISSON_RATIO] >= 0.5) << "POISSON_RATIO has an invalid value greater or equal to 0.5 " << std::endl; } else { KRATOS_ERROR << "POISSON_RATIO not defined" << std::endl; @@ -127,8 +134,8 @@ void SimplifiedBilinear3DLaw::InitializeConstitutiveLawVariables(ConstitutiveLaw { const Properties& MaterialProperties = rValues.GetMaterialProperties(); rVariables.MaxCompresiveStress = MaterialProperties[MAX_COMPRESSIVE_STRESS]; - rVariables.MaxTensileStress = 30.0 * pow(rVariables.MaxCompresiveStress, 1.5); - rVariables.YoungModulus = 85.0e6 * pow(rVariables.MaxCompresiveStress + 8.0e6, 0.33333333333333333333333333333); + rVariables.MaxTensileStress = MaterialProperties[MAX_TENSILE_STRESS]; + rVariables.YoungModulus = 85.0e6 * pow(MaterialProperties[MAX_COMPRESSIVE_STRESS] + 8.0e6, 0.33333333333333333333333333333); rVariables.YieldStress = rVariables.YoungModulus; rVariables.PoissonCoefficient = MaterialProperties[POISSON_RATIO]; rVariables.FrictionCoefficient = MaterialProperties[FRICTION_COEFFICIENT]; @@ -295,7 +302,7 @@ void SimplifiedBilinear3DLaw::ComputeStressVector(Vector& rStressVector, rStressVector[2] = rVariables.YoungModulus * StrainVector[2]; - const double shear_modulus = rVariables.YoungModulus / (2.0 * (1.0 + rVariables.PoissonCoefficient)); + const double shear_modulus = rVariables.YieldStress / (2.0 * (1.0 + rVariables.PoissonCoefficient)); double tangential_strain_vector_modulus = sqrt(StrainVector[0] * StrainVector[0] + StrainVector[1] * StrainVector[1]); diff --git a/applications/PoromechanicsApplication/poromechanics_application.cpp b/applications/PoromechanicsApplication/poromechanics_application.cpp index 1ca8fce0f60a..61263d285879 100644 --- a/applications/PoromechanicsApplication/poromechanics_application.cpp +++ b/applications/PoromechanicsApplication/poromechanics_application.cpp @@ -270,6 +270,7 @@ void KratosPoromechanicsApplication::Register() KRATOS_REGISTER_VARIABLE( SHEAR_FRACTURE_ENERGY ) KRATOS_REGISTER_VARIABLE( MAX_COMPRESSIVE_STRESS ) + KRATOS_REGISTER_VARIABLE( MAX_TENSILE_STRESS ) } }// namespace Kratos. diff --git a/applications/PoromechanicsApplication/poromechanics_application_variables.cpp b/applications/PoromechanicsApplication/poromechanics_application_variables.cpp index 35dae8732029..acced9ecb452 100644 --- a/applications/PoromechanicsApplication/poromechanics_application_variables.cpp +++ b/applications/PoromechanicsApplication/poromechanics_application_variables.cpp @@ -71,4 +71,5 @@ KRATOS_CREATE_VARIABLE( double, NODAL_JOINT_DAMAGE ) KRATOS_CREATE_VARIABLE( double, SHEAR_FRACTURE_ENERGY ) KRATOS_CREATE_VARIABLE( double, MAX_COMPRESSIVE_STRESS ) +KRATOS_CREATE_VARIABLE( double, MAX_TENSILE_STRESS ) } diff --git a/applications/PoromechanicsApplication/poromechanics_application_variables.h b/applications/PoromechanicsApplication/poromechanics_application_variables.h index 940a98fc1c20..4583ca8cc03b 100644 --- a/applications/PoromechanicsApplication/poromechanics_application_variables.h +++ b/applications/PoromechanicsApplication/poromechanics_application_variables.h @@ -83,6 +83,7 @@ KRATOS_DEFINE_APPLICATION_VARIABLE( POROMECHANICS_APPLICATION, double, NODAL_JOI KRATOS_DEFINE_APPLICATION_VARIABLE( POROMECHANICS_APPLICATION, double, SHEAR_FRACTURE_ENERGY ) KRATOS_DEFINE_APPLICATION_VARIABLE( POROMECHANICS_APPLICATION, double, MAX_COMPRESSIVE_STRESS ) +KRATOS_DEFINE_APPLICATION_VARIABLE( POROMECHANICS_APPLICATION, double, MAX_TENSILE_STRESS ) } #endif /* KRATOS_POROMECHANICS_APPLICATION_VARIABLES_H_INCLUDED */ From c45727dd90e987e1ab449d67d29c19215961d3a7 Mon Sep 17 00:00:00 2001 From: Miguel Angel Date: Fri, 24 Apr 2020 10:27:37 +0200 Subject: [PATCH 235/314] Histogram of number of bonds is printed at the beginning of the comp --- .../add_custom_utilities_to_python.cpp | 1 + .../custom_utilities/pre_utilities.h | 20 +++++++++++++++++++ .../python_scripts/DEM_analysis_stage.py | 2 ++ 3 files changed, 23 insertions(+) diff --git a/applications/DEMApplication/custom_python/add_custom_utilities_to_python.cpp b/applications/DEMApplication/custom_python/add_custom_utilities_to_python.cpp index 89a097ecb35e..2f3702e1a50f 100755 --- a/applications/DEMApplication/custom_python/add_custom_utilities_to_python.cpp +++ b/applications/DEMApplication/custom_python/add_custom_utilities_to_python.cpp @@ -295,6 +295,7 @@ void AddCustomUtilitiesToPython(pybind11::module& m) { .def("ResetSkinParticles", &PreUtilities::ResetSkinParticles) .def("SetSkinParticlesInnerBoundary", &PreUtilities::SetSkinParticlesInnerBoundary) .def("SetSkinParticlesOuterBoundary", &PreUtilities::SetSkinParticlesOuterBoundary) + .def("PrintNumberOfNeighboursHistogram", &PreUtilities::PrintNumberOfNeighboursHistogram) ; py::class_(m, "PostUtilities") diff --git a/applications/DEMApplication/custom_utilities/pre_utilities.h b/applications/DEMApplication/custom_utilities/pre_utilities.h index 234984ad0252..6e6e6d86fc76 100644 --- a/applications/DEMApplication/custom_utilities/pre_utilities.h +++ b/applications/DEMApplication/custom_utilities/pre_utilities.h @@ -83,6 +83,26 @@ class PreUtilities p_properties->SetValue(CLUSTER_INFORMATION, cl_info); } + void PrintNumberOfNeighboursHistogram(ModelPart& rSpheresModelPart, std::string const& filename) { + std::vector number_of_spheres_with_i_neighbours; + number_of_spheres_with_i_neighbours.resize(20); + for(int i=0; i<(int)number_of_spheres_with_i_neighbours.size(); i++) {number_of_spheres_with_i_neighbours[i] = 0;} + + ElementsArrayType& pElements = rSpheresModelPart.GetCommunicator().LocalMesh().Elements(); + for(int i=0; i<(int)pElements.size(); i++) { + ElementsArrayType::iterator it = pElements.ptr_begin() + i; + SphericContinuumParticle* p_cont_sphere = dynamic_cast(&*it); + number_of_spheres_with_i_neighbours[p_cont_sphere->mNeighbourElements.size()] += 1; + } + std::ofstream outputfile(filename, std::ios_base::out | std::ios_base::app); + outputfile << "number_of_neighbours percentage_of_spheres_with_that_number_of_neighbours number_of_spheres_with_that_number_of_neighbours\n"; + for(int i=0; i<(int)number_of_spheres_with_i_neighbours.size(); i++) { + const double percentage = (double)(number_of_spheres_with_i_neighbours[i]) / rSpheresModelPart.NumberOfElements(0) * 100; + outputfile < Date: Fri, 24 Apr 2020 12:39:45 +0200 Subject: [PATCH 236/314] fix adjoint tests (#6753) * fix adjoint tests * modifications due to review * use fill method to get a zeromatrix --- ...joint_sensitivity_analysis_test_factory.py | 10 +-- .../tests/test_adjoint_loading_conditions.py | 64 +++++++++++-------- 2 files changed, 41 insertions(+), 33 deletions(-) diff --git a/applications/StructuralMechanicsApplication/tests/adjoint_sensitivity_analysis_test_factory.py b/applications/StructuralMechanicsApplication/tests/adjoint_sensitivity_analysis_test_factory.py index c08abbfb1c4b..13b4516ede34 100644 --- a/applications/StructuralMechanicsApplication/tests/adjoint_sensitivity_analysis_test_factory.py +++ b/applications/StructuralMechanicsApplication/tests/adjoint_sensitivity_analysis_test_factory.py @@ -129,13 +129,9 @@ class TestAdjointSensitivityAnalysisBeamStructureNodalReaction(AdjointSensitivit def perform_additional_checks(self): adjoint_model_part = self.adjoint_analysis.model.GetModelPart(self.model_part_name) - reference_values = [-0.31249774999397384, -1.249] - sensitivities_to_check = [] - sensitivities_to_check.append(adjoint_model_part.Conditions[1].GetValue(StructuralMechanicsApplication.POINT_LOAD_SENSITIVITY)[2]) - sensitivities_to_check.append(adjoint_model_part.Elements[10].GetValue(StructuralMechanicsApplication.I22_SENSITIVITY)) - - self.assertAlmostEqual(sensitivities_to_check[0], reference_values[0], 4) - self.assertAlmostEqual(sensitivities_to_check[1], reference_values[1], 2) + reference_value = -0.31249774999397384 + sensitivity_to_check = adjoint_model_part.Conditions[1].GetValue(StructuralMechanicsApplication.POINT_LOAD_SENSITIVITY)[2] + self.assertAlmostEqual(sensitivity_to_check, reference_value) @KratosUnittest.skipUnless(has_hdf5_application,"Missing required application: HDF5Application") diff --git a/applications/StructuralMechanicsApplication/tests/test_adjoint_loading_conditions.py b/applications/StructuralMechanicsApplication/tests/test_adjoint_loading_conditions.py index f6afe244c90d..97cca9b2d454 100644 --- a/applications/StructuralMechanicsApplication/tests/test_adjoint_loading_conditions.py +++ b/applications/StructuralMechanicsApplication/tests/test_adjoint_loading_conditions.py @@ -6,13 +6,6 @@ class TestAdjointLoadingConditions(KratosUnittest.TestCase): - def __CheckSensitivityMatrix(self, sen_matrix, reference_sen_matrix, digits_to_check=5): - if ((sen_matrix.Size1() != len(reference_sen_matrix)) or (sen_matrix.Size2() != len(reference_sen_matrix[0]))): - raise Exception('Matrix sizes does not fit!') - for i in range(sen_matrix.Size1()): - for j in range(sen_matrix.Size2()): - self.assertAlmostEqual(sen_matrix[i,j], reference_sen_matrix[i][j], digits_to_check) - def _SurfaceLoadCondition3D4N(self, prefix = ""): current_model = KratosMultiphysics.Model() mp = current_model.CreateModelPart("solid_part") @@ -47,18 +40,31 @@ def _SurfaceLoadCondition3D4N(self, prefix = ""): mp.ProcessInfo[StructuralMechanicsApplication.PERTURBATION_SIZE] = 1e-5 # check w.r.t. to design variable SURFACE_LOAD - reference_res_1 = [[0.25,0,0,0.25,0,0,0.25,0,0,0.25,0,0],[0,0.25,0,0,0.25,0,0,0.25,0,0,0.25,0],[0,0,0.25,0,0,0.25,0,0,0.25,0,0,0.25]] + reference_res_1 = KratosMultiphysics.Matrix(3, 12) + reference_res_1.fill(0.0) + reference_res_1[0,0] = reference_res_1[0,3] = reference_res_1[0,6] = reference_res_1[0,9] = 0.25 + reference_res_1[1,1] = reference_res_1[1,4] = reference_res_1[1,7] = reference_res_1[1,10] = 0.25 + reference_res_1[2,2] = reference_res_1[2,5] = reference_res_1[2,8] = reference_res_1[2,11] = 0.25 cond.CalculateSensitivityMatrix(StructuralMechanicsApplication.SURFACE_LOAD, sen_matrix, mp.ProcessInfo) - self.__CheckSensitivityMatrix(sen_matrix, reference_res_1) + self.assertMatrixAlmostEqual(reference_res_1, sen_matrix) # check w.r.t. to design variable SHAPE_SENSITIVITY - reference_res_2 = ((0,0,-0.166667,0,0,-0.166667,0,0,-0.0833333,0,0,-0.0833333),(0,0,-0.166667,0,0,-0.0833333,0,0,-0.0833333,0,0,-0.166667), - (0,0,1.25e-06,0,0,8.33328e-07,0,0,4.16669e-07,0,0,8.33336e-07),(0,0,0.166667,0,0,0.166667,0,0,0.0833333,0,0,0.0833333), - (0,0,-0.0833333,0,0,-0.166667,0,0,-0.166667,0,0,-0.0833333),(0,0,8.33336e-07,0,0,1.25e-06,0,0,8.33336e-07,0,0,4.16664e-07), - (0,0,0.0833333,0,0,0.0833333,0,0,0.166667,0,0,0.166667),(0,0,0.0833333,0,0,0.166667,0,0,0.166667,0,0,0.0833333),(0,0,4.16664e-07,0,0,8.33333e-07,0,0,1.25e-06,0,0,8.33336e-07), - (0,0,-0.0833333,0,0,-0.0833333,0,0,-0.166667,0,0,-0.166667),(0,0,0.166667,0,0,0.0833333,0,0,0.0833333,0,0,0.166667),(0,0,8.33336e-07,0,0,4.16667e-07,0,0,8.33336e-07,0,0,1.25e-06)) + reference_res_2 = KratosMultiphysics.Matrix(12, 12) + reference_res_2.fill(0.0) + reference_res_2[0,2] = reference_res_2[0,5] = reference_res_2[1,2] = reference_res_2[1,11] = -0.166667 + reference_res_2[0,8] = reference_res_2[0,11] = reference_res_2[1,5] = reference_res_2[1,8] = -0.0833333 + reference_res_2[3,2] = reference_res_2[3,5] = reference_res_2[10,2] = reference_res_2[10,11] = 0.166667 + reference_res_2[3,8] = reference_res_2[3,11] = reference_res_2[10,5] = reference_res_2[10,8] = 0.0833333 + reference_res_2[6,8] = reference_res_2[6,11] = reference_res_2[7,5] = reference_res_2[7,8] = 0.166667 + reference_res_2[6,2] = reference_res_2[6,5] = reference_res_2[7,2] = reference_res_2[7,11] = 0.0833333 + reference_res_2[4,5] = reference_res_2[4,8] = reference_res_2[9,8] = reference_res_2[9,11] = -0.166667 + reference_res_2[4,2] = reference_res_2[4,11] = reference_res_2[9,2] = reference_res_2[9,5] = -0.0833333 + reference_res_2[2,2] = reference_res_2[5,5] = reference_res_2[8,8] = reference_res_2[11,11] = 1.25e-06 + reference_res_2[2,8] = reference_res_2[5,11] = reference_res_2[8,2] = reference_res_2[11,5] = 4.1667e-07 + reference_res_2[2,5] = reference_res_2[2,11] = reference_res_2[5,2] = reference_res_2[5,8] = 4.1667e-07 + reference_res_2[8,5] = reference_res_2[8,11] = reference_res_2[11,2] = reference_res_2[11,8] = 8.333e-07 cond.CalculateSensitivityMatrix(KratosMultiphysics.SHAPE_SENSITIVITY, sen_matrix, mp.ProcessInfo) - self.__CheckSensitivityMatrix(sen_matrix, reference_res_2) + self.assertMatrixAlmostEqual(reference_res_2, sen_matrix, 6) # change loading load_on_cond[2] = 0.0 @@ -66,12 +72,11 @@ def _SurfaceLoadCondition3D4N(self, prefix = ""): cond.SetValue(KratosMultiphysics.PRESSURE, 1.0) # check w.r.t. to design variable PRESSURE - reference_res_3 = [0,0,0.25,0,0,0.25,0,0,0.25,0,0,0.25] + reference_res_3 = KratosMultiphysics.Matrix(1, 12) + reference_res_3.fill(0.0) + reference_res_3[0,2] = reference_res_3[0,5] = reference_res_3[0,8] = reference_res_3[0,11] = 0.25 cond.CalculateSensitivityMatrix(KratosMultiphysics.PRESSURE, sen_matrix, mp.ProcessInfo) - if ((sen_matrix.Size2() != len(reference_res_3)) or sen_matrix.Size1() != 1): - raise Exception('Matrix sizes does not fit!') - for i in range(sen_matrix.Size2()): - self.assertAlmostEqual(sen_matrix[0,i], reference_res_3[i], 5) + self.assertMatrixAlmostEqual(reference_res_3, sen_matrix) def _LineLoadCondition3D2N(self, prefix = ""): @@ -111,16 +116,23 @@ def _LineLoadCondition3D2N(self, prefix = ""): mp.ProcessInfo[StructuralMechanicsApplication.PERTURBATION_SIZE] = 1e-6 # check w.r.t. to design variable SURFACE_LOAD - reference_res_1 = ((0.707107,0,0,0.707107,0,0),(0,0.707107,0,0,0.707107,0),(0,0,0.707107,0,0,0.707107)) + reference_res_1 = KratosMultiphysics.Matrix(3, 6) + reference_res_1.fill(0.0) + reference_res_1[0,0] = reference_res_1[0,3] = reference_res_1[1,1] = reference_res_1[1,4] = reference_res_1[2,2] = reference_res_1[2,5] = 0.70710678 cond.CalculateSensitivityMatrix(StructuralMechanicsApplication.LINE_LOAD, sen_matrix, mp.ProcessInfo) - self.__CheckSensitivityMatrix(sen_matrix, reference_res_1) + self.assertMatrixAlmostEqual(reference_res_1, sen_matrix, 6) # check w.r.t. to design variable SHAPE_SENSITIVITY - reference_res_2 = ((0,2499.999376,2499.999376,0,2499.999376,2499.999376),(0,2499.999376,2499.999376,0,2499.999376,2499.999376), - (0,-0.001250,-0.001250,0,-0.0012450,-0.001250),(0,-2500.000624,-2500.000624,0,-2500.000624,-2500.000624), - (0,-2500.000624,-2500.000624,0,-2500.000624,-2500.000624),(0,-0.001250,-0.001250,0,-0.001250,-0.001250)) + reference_res_2 = KratosMultiphysics.Matrix(6, 6) + reference_res_2.fill(0.0) + reference_res_2[0,1] = reference_res_2[0,2] = reference_res_2[0,4] = reference_res_2[0,5] = 2499.999376 + reference_res_2[1,1] = reference_res_2[1,2] = reference_res_2[1,4] = reference_res_2[1,5] = 2499.999376 + reference_res_2[2,1] = reference_res_2[2,2] = reference_res_2[2,4] = reference_res_2[2,5] = -0.001250 + reference_res_2[3,1] = reference_res_2[3,2] = reference_res_2[3,4] = reference_res_2[3,5] = -2500.000624 + reference_res_2[4,1] = reference_res_2[4,2] = reference_res_2[4,4] = reference_res_2[4,5] = -2500.000624 + reference_res_2[5,1] = reference_res_2[5,2] = reference_res_2[5,4] = reference_res_2[5,5] = -0.001250 cond.CalculateSensitivityMatrix(KratosMultiphysics.SHAPE_SENSITIVITY, sen_matrix, mp.ProcessInfo) - self.__CheckSensitivityMatrix(sen_matrix, reference_res_2) + self.assertMatrixAlmostEqual(reference_res_2, sen_matrix, 6) def test_SDSurfaceLoadCondition3D4N(self): self._SurfaceLoadCondition3D4N(prefix = "SmallDisplacement") From 8482edf861b6ff042db631a34ac705ee1aba0908 Mon Sep 17 00:00:00 2001 From: Miguel Angel Celigueta Date: Fri, 24 Apr 2020 12:56:01 +0200 Subject: [PATCH 237/314] Update applications/DEMApplication/custom_utilities/pre_utilities.h Co-Authored-By: Philipp Bucher --- applications/DEMApplication/custom_utilities/pre_utilities.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/DEMApplication/custom_utilities/pre_utilities.h b/applications/DEMApplication/custom_utilities/pre_utilities.h index 6e6e6d86fc76..3a022560fb14 100644 --- a/applications/DEMApplication/custom_utilities/pre_utilities.h +++ b/applications/DEMApplication/custom_utilities/pre_utilities.h @@ -83,7 +83,7 @@ class PreUtilities p_properties->SetValue(CLUSTER_INFORMATION, cl_info); } - void PrintNumberOfNeighboursHistogram(ModelPart& rSpheresModelPart, std::string const& filename) { + void PrintNumberOfNeighboursHistogram(const ModelPart& rSpheresModelPart, std::string const& filename) { std::vector number_of_spheres_with_i_neighbours; number_of_spheres_with_i_neighbours.resize(20); for(int i=0; i<(int)number_of_spheres_with_i_neighbours.size(); i++) {number_of_spheres_with_i_neighbours[i] = 0;} From 55ec354d077c271f2fe10c69ef5a8b3d37a01153 Mon Sep 17 00:00:00 2001 From: eloisabaez Date: Fri, 24 Apr 2020 13:02:19 +0200 Subject: [PATCH 238/314] making relative near check --- .../potential_flow_utilities.cpp | 3 + .../test_potential_flow_utilities.cpp | 55 +++++++++++++------ 2 files changed, 42 insertions(+), 16 deletions(-) diff --git a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp index 4dbfd8cce21b..441616d2cf0d 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp +++ b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp @@ -385,6 +385,9 @@ double ComputeSquaredSpeedofSoundFactor( const double localVelocitySquared, const ProcessInfo& rCurrentProcessInfo) { + // Implemented according to Equation 8.7 of Drela, M. (2014) Flight Vehicle + // Aerodynamics, The MIT Press, London + // read free stream values const double heat_capacity_ratio = rCurrentProcessInfo[HEAT_CAPACITY_RATIO]; const double free_stream_mach = rCurrentProcessInfo[FREE_STREAM_MACH]; diff --git a/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp b/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp index b46ae854593b..967e2748866d 100644 --- a/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp +++ b/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp @@ -92,7 +92,12 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeVelocityMagnitude, CompressiblePotentialApplica // velocity corresponding to squared mach number of 3.0 double local_velocity_squared = PotentialFlowUtilities::ComputeVelocityMagnitude<2, 3>(3.0, model_part.GetProcessInfo()); - KRATOS_CHECK_NEAR(local_velocity_squared, 232356.0000000000000000, 1e-10); + double reference_velocity_squared = 232356.00000000000000000000; + + std::cout.precision(16); + KRATOS_WATCH(local_velocity_squared) + + KRATOS_CHECK_RELATIVE_NEAR(local_velocity_squared, reference_velocity_squared, 1e-15); } // Checks the function ComputeMaximumVelocitySquared from the utilities @@ -102,12 +107,15 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeMaximumVelocitySquared, CompressiblePotentialAp AssignFreeStreamValues(model_part); - double reference_max_velocity_squared = 232356.0000000000000000; + double reference_max_velocity_squared = 232356.00000000000000000000; // Max local Mach number = sqrt(3.0), from MACH_SQUARED_LIMIT double max_velocity_squared = PotentialFlowUtilities::ComputeMaximumVelocitySquared<2, 3>(model_part.GetProcessInfo()); - KRATOS_CHECK_NEAR(max_velocity_squared, reference_max_velocity_squared, 1e-10); + std::cout.precision(16); + KRATOS_WATCH(max_velocity_squared) + + KRATOS_CHECK_RELATIVE_NEAR(max_velocity_squared, reference_max_velocity_squared, 1e-15); } // Checks the function ComputeLocalSpeedOfSound from the utilities @@ -142,9 +150,12 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeLocalSpeedofSoundSquared, CompressiblePotential double local_speed_sound_squared = PotentialFlowUtilities::ComputeLocalSpeedofSoundSquared<2,3>(velocity, model_part.GetProcessInfo()); - double reference_local_speed_sound_squared = 77452.0000000000; + double reference_local_speed_sound_squared = 77452.00000000000000000000; - KRATOS_CHECK_NEAR(local_speed_sound_squared, reference_local_speed_sound_squared, 1e-16); + std::cout.precision(16); + KRATOS_WATCH(local_speed_sound_squared) + + KRATOS_CHECK_RELATIVE_NEAR(local_speed_sound_squared, reference_local_speed_sound_squared, 1e-15); } // Checks the function ComputeLocalMachNumber from the utilities @@ -169,7 +180,7 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeLocalMachNumberSquared, CompressiblePotentialAp AssignFreeStreamValues(model_part); - double reference_local_mach_squared = 3.0; + double reference_local_mach_squared = 3.00000000000000000000; // velocity corresponding to mach number 3.0 double local_velocity_squared = PotentialFlowUtilities::ComputeVelocityMagnitude<2, 3>(reference_local_mach_squared, model_part.GetProcessInfo()); @@ -180,11 +191,14 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeLocalMachNumberSquared, CompressiblePotentialAp // computes mach number with clamping double local_mach_squared = PotentialFlowUtilities::ComputeLocalMachNumberSquared<2, 3>(velocity, model_part.GetProcessInfo()); - KRATOS_CHECK_NEAR(local_mach_squared, reference_local_mach_squared, 1e-10); + std::cout.precision(20); + KRATOS_WATCH(local_mach_squared) + + KRATOS_CHECK_RELATIVE_NEAR(local_mach_squared, reference_local_mach_squared, 1e-15); } -// Checks the function ComputeDLocalMachSquaredWRTVelocitySquared from the utilities, transonic local Mach number -KRATOS_TEST_CASE_IN_SUITE(ComputeDLocalMachSquaredWRTVelocitySquaredTransonicMach, CompressiblePotentialApplicationFastSuite) { +// Checks the function ComputeDerivativeLocalMachSquaredWRTVelocitySquared from the utilities, transonic local Mach number +KRATOS_TEST_CASE_IN_SUITE(ComputeDerivativeLocalMachSquaredWRTVelocitySquaredTransonicMach, CompressiblePotentialApplicationFastSuite) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); @@ -198,19 +212,25 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeDLocalMachSquaredWRTVelocitySquaredTransonicMac array_1d velocity(2, 0.0); velocity[0] = sqrt(local_velocity_squared); + std::cout.precision(20); + KRATOS_WATCH(velocity[0]) + // performs clamping on mach number double local_mach_squared = PotentialFlowUtilities::ComputeLocalMachNumberSquared<2, 3>(velocity, model_part.GetProcessInfo()); double mach_derivative = PotentialFlowUtilities::ComputeDerivativeLocalMachSquaredWRTVelocitySquared<2, 3>(velocity, local_mach_squared, model_part.GetProcessInfo()); - double reference_derivative = 1.16201001910861e-05; + double reference_derivative = 1.1620100191086091883e-05; - KRATOS_CHECK_NEAR(mach_derivative, reference_derivative, 1e-16); + std::cout.precision(20); + KRATOS_WATCH(mach_derivative) + + KRATOS_CHECK_RELATIVE_NEAR(mach_derivative, reference_derivative, 1e-16); } -// Checks the function ComputeDLocalMachSquaredWRTVelocitySquared from the utilities, supersonic local Mach number -KRATOS_TEST_CASE_IN_SUITE(ComputeDLocalMachSquaredWRTVelocitySquaredSupersonicMach, CompressiblePotentialApplicationFastSuite) { +// Checks the function ComputeDerivativeLocalMachSquaredWRTVelocitySquared from the utilities, supersonic local Mach number +KRATOS_TEST_CASE_IN_SUITE(ComputeDerivativeLocalMachSquaredWRTVelocitySquaredSupersonicMach, CompressiblePotentialApplicationFastSuite) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); @@ -222,7 +242,7 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeDLocalMachSquaredWRTVelocitySquaredSupersonicMa double local_velocity_squared = PotentialFlowUtilities::ComputeVelocityMagnitude<2, 3>(std::pow(local_mach_number, 2), model_part.GetProcessInfo()); array_1d velocity(2, 0.0); - velocity[0] = local_velocity_squared; + velocity[0] = sqrt(local_velocity_squared); // performs clamping on mach number double local_mach_squared = PotentialFlowUtilities::ComputeLocalMachNumberSquared<2, 3>(velocity, model_part.GetProcessInfo()); @@ -230,9 +250,12 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeDLocalMachSquaredWRTVelocitySquaredSupersonicMa double mach_derivative = PotentialFlowUtilities::ComputeDerivativeLocalMachSquaredWRTVelocitySquared<2, 3>(velocity, local_mach_squared, model_part.GetProcessInfo()); - double reference_derivative = 2.06579558952642e-05; + double reference_derivative = 2.0657955895264163348e-05; + + std::cout.precision(20); + KRATOS_WATCH(mach_derivative) - KRATOS_CHECK_NEAR(mach_derivative, reference_derivative, 1e-16); + KRATOS_CHECK_RELATIVE_NEAR(mach_derivative, reference_derivative, 1e-16); } // Checks the function ComputeIncompressiblePerturbationPressureCoefficient from the utilities From 421ece194c67c0235ea3456a53c0824a4123e5a9 Mon Sep 17 00:00:00 2001 From: Manuel Messmer Date: Fri, 24 Apr 2020 15:46:33 +0200 Subject: [PATCH 239/314] Add option do make matrices symmetric! --- .../add_custom_strategies_to_python.cpp | 2 +- .../custom_strategies/prebuckling_strategy.hpp | 13 ++++++++++++- .../structural_mechanics_prebuckling_solver.py | 6 ++++-- .../tests/test_prebuckling_analysis.py | 7 ++++--- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/applications/StructuralMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp b/applications/StructuralMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp index bf0a1a9b7884..c846bed369ff 100755 --- a/applications/StructuralMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp +++ b/applications/StructuralMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp @@ -109,7 +109,7 @@ void AddCustomStrategiesToPython(pybind11::module& m) // Prebuckling Strategy py::class_< PrebucklingStrategyType, typename PrebucklingStrategyType::Pointer,BaseSolvingStrategyType >(m,"PrebucklingStrategy") - .def(py::init()) + .def(py::init()) .def("GetSolutionFoundFlag", &PrebucklingStrategyType::GetSolutionFoundFlag) ; py::class_< FormfindingStrategyType,typename FormfindingStrategyType::Pointer, ResidualBasedNewtonRaphsonStrategyType >(m,"FormfindingStrategy") diff --git a/applications/StructuralMechanicsApplication/custom_strategies/custom_strategies/prebuckling_strategy.hpp b/applications/StructuralMechanicsApplication/custom_strategies/custom_strategies/prebuckling_strategy.hpp index 0fcf4ebb9b45..a6759389c589 100644 --- a/applications/StructuralMechanicsApplication/custom_strategies/custom_strategies/prebuckling_strategy.hpp +++ b/applications/StructuralMechanicsApplication/custom_strategies/custom_strategies/prebuckling_strategy.hpp @@ -112,7 +112,8 @@ class PrebucklingStrategy double InitialLoadIncrement, double SmallLoadIncrement, double PathFollowingStep, - double ConvergenceRatio ) + double ConvergenceRatio, + bool MakeMatricesSymmetricFlag ) : SolvingStrategy(rModelPart) { KRATOS_TRY @@ -135,6 +136,8 @@ class PrebucklingStrategy mConvergenceRatio = ConvergenceRatio; + mMakeMatricesSymmetricFlag = MakeMatricesSymmetricFlag; + // Set Eigensolver flags mpEigenSolver->SetDofSetIsInitializedFlag(false); mpEigenSolver->SetReshapeMatrixFlag(false); @@ -552,6 +555,12 @@ class PrebucklingStrategy // between the current and previous step rStiffnessMatrix = rStiffnessMatrixPrevious - rStiffnessMatrix; + // Symmetrice matrices if enabled + if( mMakeMatricesSymmetricFlag ){ + rStiffnessMatrix = 0.5 * ( rStiffnessMatrix + boost::numeric::ublas::trans(rStiffnessMatrix) ); + rStiffnessMatrixPrevious = 0.5 * ( rStiffnessMatrixPrevious + boost::numeric::ublas::trans(rStiffnessMatrixPrevious) ); + } + this->pGetEigenSolver()->GetLinearSystemSolver()->Solve( rStiffnessMatrixPrevious, rStiffnessMatrix, @@ -745,6 +754,8 @@ class PrebucklingStrategy double mLambda = 0.0; double mLambdaPrev = 1.0; + bool mMakeMatricesSymmetricFlag; + ///@} ///@name Private Operators ///@{ diff --git a/applications/StructuralMechanicsApplication/python_scripts/structural_mechanics_prebuckling_solver.py b/applications/StructuralMechanicsApplication/python_scripts/structural_mechanics_prebuckling_solver.py index 7fe367696f4b..114860865c47 100644 --- a/applications/StructuralMechanicsApplication/python_scripts/structural_mechanics_prebuckling_solver.py +++ b/applications/StructuralMechanicsApplication/python_scripts/structural_mechanics_prebuckling_solver.py @@ -34,7 +34,8 @@ def GetDefaultSettings(cls): "initial_load_increment" : 1.0, "small_load_increment" : 0.0005, "path_following_step" : 0.5, - "convergence_ratio" : 0.05 + "convergence_ratio" : 0.05, + "make_matrices_symmetric" : True }, "eigensolver_settings" : { "solver_type" : "eigen_eigensystem", @@ -119,4 +120,5 @@ def _create_mechanical_solution_strategy(self): buckling_settings["initial_load_increment"].GetDouble(), buckling_settings["small_load_increment"].GetDouble(), buckling_settings["path_following_step"].GetDouble(), - buckling_settings["convergence_ratio"].GetDouble() ) + buckling_settings["convergence_ratio"].GetDouble(), + buckling_settings["make_matrices_symmetric"].GetBoolean() ) diff --git a/applications/StructuralMechanicsApplication/tests/test_prebuckling_analysis.py b/applications/StructuralMechanicsApplication/tests/test_prebuckling_analysis.py index 4e68f20caef6..d44fbc3358fd 100644 --- a/applications/StructuralMechanicsApplication/tests/test_prebuckling_analysis.py +++ b/applications/StructuralMechanicsApplication/tests/test_prebuckling_analysis.py @@ -91,9 +91,9 @@ def _solve_prebuckling_problem(self,mp,NumOfNodes,iterations,echo=0): { "max_iteration" : 1000, "tolerance" : 1e-6, - "number_of_eigenvalues" : 2, + "number_of_eigenvalues" : 1, "echo_level" : 0, - "normalize_eigenvectors": true + "normalize_eigenvectors": false } """) @@ -114,7 +114,8 @@ def _solve_prebuckling_problem(self,mp,NumOfNodes,iterations,echo=0): 1.0, 0.0005, 0.5, - 0.005 ) + 0.005, + True ) eig_strategy.SetEchoLevel(echo) LoadFactor = [] for i in range(iterations): From 0887b461702e12f718220c62205d8a057bf1f57a Mon Sep 17 00:00:00 2001 From: Manuel Messmer Date: Fri, 24 Apr 2020 15:47:06 +0200 Subject: [PATCH 240/314] Push test temporarily to small test_suite. --- .../tests/test_StructuralMechanicsApplication.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/applications/StructuralMechanicsApplication/tests/test_StructuralMechanicsApplication.py b/applications/StructuralMechanicsApplication/tests/test_StructuralMechanicsApplication.py index a6ff959633cd..03ad1e2b110c 100644 --- a/applications/StructuralMechanicsApplication/tests/test_StructuralMechanicsApplication.py +++ b/applications/StructuralMechanicsApplication/tests/test_StructuralMechanicsApplication.py @@ -312,7 +312,8 @@ def AssembleTestSuites(): # Dynamic Eigenvalue Analysis smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([TTestDynamicEigenvalueAnalysis])) # Buckling analysis test - nightSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([TTestPrebucklingAnalysis])) + #Change again!!! + smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([TTestPrebucklingAnalysis])) # Nodal Damping nightSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([TNodalDampingTests])) # TODO should be in smallSuite but is too slow # Dynamic basic tests From 9e346478e8e63fa327defbc30685f4f4d4213a14 Mon Sep 17 00:00:00 2001 From: eloisabaez Date: Fri, 24 Apr 2020 16:56:59 +0200 Subject: [PATCH 241/314] addressing comments on pr --- ...ible_potential_flow_python_application.cpp | 2 +- .../test_potential_flow_utilities.cpp | 65 +++++++------------ 2 files changed, 23 insertions(+), 44 deletions(-) diff --git a/applications/CompressiblePotentialFlowApplication/custom_python/compressible_potential_flow_python_application.cpp b/applications/CompressiblePotentialFlowApplication/custom_python/compressible_potential_flow_python_application.cpp index 10dea0f3070e..10e13133bcbf 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_python/compressible_potential_flow_python_application.cpp +++ b/applications/CompressiblePotentialFlowApplication/custom_python/compressible_potential_flow_python_application.cpp @@ -67,7 +67,6 @@ PYBIND11_MODULE(KratosCompressiblePotentialFlowApplication, m) KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, POTENTIAL_JUMP); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, ENERGY_NORM_REFERENCE); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, POTENTIAL_ENERGY_REFERENCE); - KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, MACH_SQUARED_LIMIT); // Free stream magnitudes KRATOS_REGISTER_IN_PYTHON_3D_VARIABLE_WITH_COMPONENTS(m, FREE_STREAM_VELOCITY); @@ -81,6 +80,7 @@ PYBIND11_MODULE(KratosCompressiblePotentialFlowApplication, m) // Solver parameters KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, MACH_LIMIT); + KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, MACH_SQUARED_LIMIT); // Integral magnitudes KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, LIFT_COEFFICIENT); diff --git a/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp b/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp index 967e2748866d..ea64c358c1d9 100644 --- a/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp +++ b/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp @@ -90,12 +90,9 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeVelocityMagnitude, CompressiblePotentialApplica AssignFreeStreamValues(model_part); // velocity corresponding to squared mach number of 3.0 - double local_velocity_squared = PotentialFlowUtilities::ComputeVelocityMagnitude<2, 3>(3.0, model_part.GetProcessInfo()); + const double local_velocity_squared = PotentialFlowUtilities::ComputeVelocityMagnitude<2, 3>(3.0, model_part.GetProcessInfo()); - double reference_velocity_squared = 232356.00000000000000000000; - - std::cout.precision(16); - KRATOS_WATCH(local_velocity_squared) + const double reference_velocity_squared = 232356.0; KRATOS_CHECK_RELATIVE_NEAR(local_velocity_squared, reference_velocity_squared, 1e-15); } @@ -107,13 +104,10 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeMaximumVelocitySquared, CompressiblePotentialAp AssignFreeStreamValues(model_part); - double reference_max_velocity_squared = 232356.00000000000000000000; + const double reference_max_velocity_squared = 232356.0; // Max local Mach number = sqrt(3.0), from MACH_SQUARED_LIMIT - double max_velocity_squared = PotentialFlowUtilities::ComputeMaximumVelocitySquared<2, 3>(model_part.GetProcessInfo()); - - std::cout.precision(16); - KRATOS_WATCH(max_velocity_squared) + const double max_velocity_squared = PotentialFlowUtilities::ComputeMaximumVelocitySquared<2, 3>(model_part.GetProcessInfo()); KRATOS_CHECK_RELATIVE_NEAR(max_velocity_squared, reference_max_velocity_squared, 1e-15); } @@ -140,20 +134,17 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeLocalSpeedofSoundSquared, CompressiblePotential AssignFreeStreamValues(model_part); - double local_mach_number = 3.0; + const double local_mach_number_squared = 3.0; // velocity corresponding to mach number 3.0 - double local_velocity_squared = PotentialFlowUtilities::ComputeVelocityMagnitude<2, 3>(std::pow(local_mach_number, 2), model_part.GetProcessInfo()); + const double local_velocity_squared = PotentialFlowUtilities::ComputeVelocityMagnitude<2, 3>(local_mach_number_squared, model_part.GetProcessInfo()); array_1d velocity(2, 0.0); velocity[0] = local_velocity_squared; - double local_speed_sound_squared = PotentialFlowUtilities::ComputeLocalSpeedofSoundSquared<2,3>(velocity, model_part.GetProcessInfo()); - - double reference_local_speed_sound_squared = 77452.00000000000000000000; + const double local_speed_sound_squared = PotentialFlowUtilities::ComputeLocalSpeedofSoundSquared<2,3>(velocity, model_part.GetProcessInfo()); - std::cout.precision(16); - KRATOS_WATCH(local_speed_sound_squared) + const double reference_local_speed_sound_squared = 77452.0; KRATOS_CHECK_RELATIVE_NEAR(local_speed_sound_squared, reference_local_speed_sound_squared, 1e-15); } @@ -180,19 +171,16 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeLocalMachNumberSquared, CompressiblePotentialAp AssignFreeStreamValues(model_part); - double reference_local_mach_squared = 3.00000000000000000000; + const double reference_local_mach_squared = 3.0; // velocity corresponding to mach number 3.0 - double local_velocity_squared = PotentialFlowUtilities::ComputeVelocityMagnitude<2, 3>(reference_local_mach_squared, model_part.GetProcessInfo()); + const double local_velocity_squared = PotentialFlowUtilities::ComputeVelocityMagnitude<2, 3>(reference_local_mach_squared, model_part.GetProcessInfo()); array_1d velocity(2, 0.0); - velocity[0] = local_velocity_squared; + velocity[0] = sqrt(local_velocity_squared); // computes mach number with clamping - double local_mach_squared = PotentialFlowUtilities::ComputeLocalMachNumberSquared<2, 3>(velocity, model_part.GetProcessInfo()); - - std::cout.precision(20); - KRATOS_WATCH(local_mach_squared) + const double local_mach_squared = PotentialFlowUtilities::ComputeLocalMachNumberSquared<2, 3>(velocity, model_part.GetProcessInfo()); KRATOS_CHECK_RELATIVE_NEAR(local_mach_squared, reference_local_mach_squared, 1e-15); } @@ -204,27 +192,21 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeDerivativeLocalMachSquaredWRTVelocitySquaredTra AssignFreeStreamValues(model_part); - double local_mach_number = 1.0; + const double local_mach_number_squared = 1.0; // velocity corresponding to mach number 1.0 - double local_velocity_squared = PotentialFlowUtilities::ComputeVelocityMagnitude<2, 3>(std::pow(local_mach_number, 2), model_part.GetProcessInfo()); + const double local_velocity_squared = PotentialFlowUtilities::ComputeVelocityMagnitude<2, 3>(local_mach_number_squared, model_part.GetProcessInfo()); array_1d velocity(2, 0.0); velocity[0] = sqrt(local_velocity_squared); - std::cout.precision(20); - KRATOS_WATCH(velocity[0]) - // performs clamping on mach number - double local_mach_squared = PotentialFlowUtilities::ComputeLocalMachNumberSquared<2, 3>(velocity, model_part.GetProcessInfo()); + const double local_mach_squared = PotentialFlowUtilities::ComputeLocalMachNumberSquared<2, 3>(velocity, model_part.GetProcessInfo()); - double mach_derivative = PotentialFlowUtilities::ComputeDerivativeLocalMachSquaredWRTVelocitySquared<2, 3>(velocity, + const double mach_derivative = PotentialFlowUtilities::ComputeDerivativeLocalMachSquaredWRTVelocitySquared<2, 3>(velocity, local_mach_squared, model_part.GetProcessInfo()); - double reference_derivative = 1.1620100191086091883e-05; - - std::cout.precision(20); - KRATOS_WATCH(mach_derivative) + const double reference_derivative = 1.1620100191086091883e-05; KRATOS_CHECK_RELATIVE_NEAR(mach_derivative, reference_derivative, 1e-16); } @@ -236,24 +218,21 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeDerivativeLocalMachSquaredWRTVelocitySquaredSup AssignFreeStreamValues(model_part); - double local_mach_number = 3.0; + const double local_mach_number_squared = 3.0; // velocity corresponding to mach number 3.0 - double local_velocity_squared = PotentialFlowUtilities::ComputeVelocityMagnitude<2, 3>(std::pow(local_mach_number, 2), model_part.GetProcessInfo()); + const double local_velocity_squared = PotentialFlowUtilities::ComputeVelocityMagnitude<2, 3>(local_mach_number_squared, model_part.GetProcessInfo()); array_1d velocity(2, 0.0); velocity[0] = sqrt(local_velocity_squared); // performs clamping on mach number - double local_mach_squared = PotentialFlowUtilities::ComputeLocalMachNumberSquared<2, 3>(velocity, model_part.GetProcessInfo()); + const double local_mach_squared = PotentialFlowUtilities::ComputeLocalMachNumberSquared<2, 3>(velocity, model_part.GetProcessInfo()); - double mach_derivative = PotentialFlowUtilities::ComputeDerivativeLocalMachSquaredWRTVelocitySquared<2, 3>(velocity, + const double mach_derivative = PotentialFlowUtilities::ComputeDerivativeLocalMachSquaredWRTVelocitySquared<2, 3>(velocity, local_mach_squared, model_part.GetProcessInfo()); - double reference_derivative = 2.0657955895264163348e-05; - - std::cout.precision(20); - KRATOS_WATCH(mach_derivative) + const double reference_derivative = 2.0657955895264163348e-05; KRATOS_CHECK_RELATIVE_NEAR(mach_derivative, reference_derivative, 1e-16); } From 2c418f0d259fb3a21b092391e8916ca408e29ccf Mon Sep 17 00:00:00 2001 From: Miguel Angel Date: Fri, 24 Apr 2020 20:48:09 +0200 Subject: [PATCH 242/314] Considers that the case can be continuum or not --- .../DEMApplication/custom_utilities/pre_utilities.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/applications/DEMApplication/custom_utilities/pre_utilities.h b/applications/DEMApplication/custom_utilities/pre_utilities.h index 3a022560fb14..fb792790c384 100644 --- a/applications/DEMApplication/custom_utilities/pre_utilities.h +++ b/applications/DEMApplication/custom_utilities/pre_utilities.h @@ -92,7 +92,16 @@ class PreUtilities for(int i=0; i<(int)pElements.size(); i++) { ElementsArrayType::iterator it = pElements.ptr_begin() + i; SphericContinuumParticle* p_cont_sphere = dynamic_cast(&*it); - number_of_spheres_with_i_neighbours[p_cont_sphere->mNeighbourElements.size()] += 1; + if(p_cont_sphere != NULL) { + unsigned int size = p_cont_sphere->mContinuumInitialNeighborsSize; + if(size > number_of_spheres_with_i_neighbours.size() - 1) size = number_of_spheres_with_i_neighbours.size() - 1; + number_of_spheres_with_i_neighbours[size] += 1; + } else { + SphericParticle* p_sphere = dynamic_cast(&*it); + unsigned int size = p_sphere->mNeighbourElements.size(); + if(size > number_of_spheres_with_i_neighbours.size() - 1) size = number_of_spheres_with_i_neighbours.size() - 1; + number_of_spheres_with_i_neighbours[size] += 1; + } } std::ofstream outputfile(filename, std::ios_base::out | std::ios_base::app); outputfile << "number_of_neighbours percentage_of_spheres_with_that_number_of_neighbours number_of_spheres_with_that_number_of_neighbours\n"; From 3d549567ebcd45182eef52023aa22a3d076bb092 Mon Sep 17 00:00:00 2001 From: Miguel Angel Date: Fri, 24 Apr 2020 21:35:55 +0200 Subject: [PATCH 243/314] const problems solved --- .../DEMApplication/custom_utilities/pre_utilities.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/applications/DEMApplication/custom_utilities/pre_utilities.h b/applications/DEMApplication/custom_utilities/pre_utilities.h index fb792790c384..153735479cd6 100644 --- a/applications/DEMApplication/custom_utilities/pre_utilities.h +++ b/applications/DEMApplication/custom_utilities/pre_utilities.h @@ -88,16 +88,19 @@ class PreUtilities number_of_spheres_with_i_neighbours.resize(20); for(int i=0; i<(int)number_of_spheres_with_i_neighbours.size(); i++) {number_of_spheres_with_i_neighbours[i] = 0;} - ElementsArrayType& pElements = rSpheresModelPart.GetCommunicator().LocalMesh().Elements(); + const ElementsArrayType& pElements = rSpheresModelPart.GetCommunicator().LocalMesh().Elements(); + ElementsArrayType::ptr_const_iterator begin = pElements.ptr_begin(); + for(int i=0; i<(int)pElements.size(); i++) { - ElementsArrayType::iterator it = pElements.ptr_begin() + i; - SphericContinuumParticle* p_cont_sphere = dynamic_cast(&*it); + ElementsArrayType::ptr_const_iterator it = begin + i; + const Element& el = **it; + const SphericContinuumParticle* p_cont_sphere = dynamic_cast(&el); if(p_cont_sphere != NULL) { unsigned int size = p_cont_sphere->mContinuumInitialNeighborsSize; if(size > number_of_spheres_with_i_neighbours.size() - 1) size = number_of_spheres_with_i_neighbours.size() - 1; number_of_spheres_with_i_neighbours[size] += 1; } else { - SphericParticle* p_sphere = dynamic_cast(&*it); + const SphericParticle* p_sphere = dynamic_cast(&el); unsigned int size = p_sphere->mNeighbourElements.size(); if(size > number_of_spheres_with_i_neighbours.size() - 1) size = number_of_spheres_with_i_neighbours.size() - 1; number_of_spheres_with_i_neighbours[size] += 1; From 23dd684186e21ef04d8afd6123304f4aae490778 Mon Sep 17 00:00:00 2001 From: Miguel Angel Celigueta Date: Fri, 24 Apr 2020 21:38:23 +0200 Subject: [PATCH 244/314] simpler check for null pointer Co-Authored-By: Philipp Bucher --- applications/DEMApplication/custom_utilities/pre_utilities.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/DEMApplication/custom_utilities/pre_utilities.h b/applications/DEMApplication/custom_utilities/pre_utilities.h index 153735479cd6..2f18cb3f564b 100644 --- a/applications/DEMApplication/custom_utilities/pre_utilities.h +++ b/applications/DEMApplication/custom_utilities/pre_utilities.h @@ -95,7 +95,7 @@ class PreUtilities ElementsArrayType::ptr_const_iterator it = begin + i; const Element& el = **it; const SphericContinuumParticle* p_cont_sphere = dynamic_cast(&el); - if(p_cont_sphere != NULL) { + if(p_cont_sphere) { unsigned int size = p_cont_sphere->mContinuumInitialNeighborsSize; if(size > number_of_spheres_with_i_neighbours.size() - 1) size = number_of_spheres_with_i_neighbours.size() - 1; number_of_spheres_with_i_neighbours[size] += 1; From ddae04299dd6a629a07a19063b56b078d44b5ba8 Mon Sep 17 00:00:00 2001 From: Miguel Angel Celigueta Date: Fri, 24 Apr 2020 21:38:56 +0200 Subject: [PATCH 245/314] double operation corrected Co-Authored-By: Philipp Bucher --- applications/DEMApplication/custom_utilities/pre_utilities.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/DEMApplication/custom_utilities/pre_utilities.h b/applications/DEMApplication/custom_utilities/pre_utilities.h index 2f18cb3f564b..ad1177ad18cd 100644 --- a/applications/DEMApplication/custom_utilities/pre_utilities.h +++ b/applications/DEMApplication/custom_utilities/pre_utilities.h @@ -109,7 +109,7 @@ class PreUtilities std::ofstream outputfile(filename, std::ios_base::out | std::ios_base::app); outputfile << "number_of_neighbours percentage_of_spheres_with_that_number_of_neighbours number_of_spheres_with_that_number_of_neighbours\n"; for(int i=0; i<(int)number_of_spheres_with_i_neighbours.size(); i++) { - const double percentage = (double)(number_of_spheres_with_i_neighbours[i]) / rSpheresModelPart.NumberOfElements(0) * 100; + const double percentage = (double)(number_of_spheres_with_i_neighbours[i]) / double(rSpheresModelPart.NumberOfElements(0)) * 100.0; outputfile < Date: Fri, 24 Apr 2020 21:40:54 +0200 Subject: [PATCH 246/314] cast Co-Authored-By: Philipp Bucher --- applications/DEMApplication/custom_utilities/pre_utilities.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/DEMApplication/custom_utilities/pre_utilities.h b/applications/DEMApplication/custom_utilities/pre_utilities.h index ad1177ad18cd..cabb3a9e025c 100644 --- a/applications/DEMApplication/custom_utilities/pre_utilities.h +++ b/applications/DEMApplication/custom_utilities/pre_utilities.h @@ -109,7 +109,7 @@ class PreUtilities std::ofstream outputfile(filename, std::ios_base::out | std::ios_base::app); outputfile << "number_of_neighbours percentage_of_spheres_with_that_number_of_neighbours number_of_spheres_with_that_number_of_neighbours\n"; for(int i=0; i<(int)number_of_spheres_with_i_neighbours.size(); i++) { - const double percentage = (double)(number_of_spheres_with_i_neighbours[i]) / double(rSpheresModelPart.NumberOfElements(0)) * 100.0; + const double percentage = (double)(number_of_spheres_with_i_neighbours[i]) / (double)(rSpheresModelPart.NumberOfElements(0)) * 100.0; outputfile < Date: Sat, 25 Apr 2020 11:40:34 +1000 Subject: [PATCH 247/314] change USE_CONSISTENT_MASS_MATRIX to COMPUTE_LUMPED_MASS_MATRIX --- .../custom_elements/updated_lagrangian.cpp | 8 ++++---- .../custom_elements/updated_lagrangian_UP.cpp | 8 ++++---- .../custom_elements/updated_lagrangian_quadrilateral.cpp | 8 ++++---- .../particle_mechanics_python_application.cpp | 1 - .../particle_mechanics_application.cpp | 1 - .../particle_mechanics_application_variables.cpp | 1 - .../particle_mechanics_application_variables.h | 1 - .../python_scripts/mpm_solver.py | 5 ++++- 8 files changed, 16 insertions(+), 17 deletions(-) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp index b43c671d9394..1b7922cab8fd 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp @@ -1284,9 +1284,9 @@ void UpdatedLagrangian::CalculateMassMatrix( MatrixType& rMassMatrix, const Proc Vector N; this->MPMShapeFunctionPointValues(N, mMP.xg); - const bool is_consistent_mass_matrix = (rCurrentProcessInfo.Has(USE_CONSISTENT_MASS_MATRIX)) - ? rCurrentProcessInfo.GetValue(USE_CONSISTENT_MASS_MATRIX) - : false; + const bool is_lumped_mass_matrix = (rCurrentProcessInfo.Has(COMPUTE_LUMPED_MASS_MATRIX)) + ? rCurrentProcessInfo.GetValue(COMPUTE_LUMPED_MASS_MATRIX) + : true; const SizeType dimension = GetGeometry().WorkingSpaceDimension(); const SizeType number_of_nodes = GetGeometry().PointsNumber(); @@ -1296,7 +1296,7 @@ void UpdatedLagrangian::CalculateMassMatrix( MatrixType& rMassMatrix, const Proc rMassMatrix.resize( matrix_size, matrix_size, false ); rMassMatrix = ZeroMatrix(matrix_size, matrix_size); - if (is_consistent_mass_matrix) { + if (!is_lumped_mass_matrix) { for (IndexType i = 0; i < number_of_nodes; ++i) { for (IndexType j = 0; j < number_of_nodes; ++j) { for (IndexType k = 0; k < dimension; ++k) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.cpp index 32489f02d898..0603a1710485 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.cpp @@ -1027,9 +1027,9 @@ void UpdatedLagrangianUP::CalculateMassMatrix( MatrixType& rMassMatrix, const Pr Vector N; this->MPMShapeFunctionPointValues(N, mMP.xg); - const bool is_consistent_mass_matrix = (rCurrentProcessInfo.Has(USE_CONSISTENT_MASS_MATRIX)) - ? rCurrentProcessInfo.GetValue(USE_CONSISTENT_MASS_MATRIX) - : false; + const bool is_lumped_mass_matrix = (rCurrentProcessInfo.Has(COMPUTE_LUMPED_MASS_MATRIX)) + ? rCurrentProcessInfo.GetValue(COMPUTE_LUMPED_MASS_MATRIX) + : true; const SizeType dimension = GetGeometry().WorkingSpaceDimension(); const SizeType number_of_nodes = GetGeometry().PointsNumber(); @@ -1039,7 +1039,7 @@ void UpdatedLagrangianUP::CalculateMassMatrix( MatrixType& rMassMatrix, const Pr rMassMatrix.resize(matrix_size, matrix_size, false); rMassMatrix = ZeroMatrix(matrix_size, matrix_size); - if (is_consistent_mass_matrix) { + if (!is_lumped_mass_matrix) { for (IndexType i = 0; i < number_of_nodes; ++i) { for (IndexType j = 0; j < number_of_nodes; ++j) { for (IndexType k = 0; k < dimension; ++k) diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index 72ac4fb56966..615cbc655e07 100644 --- a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp +++ b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp @@ -1285,9 +1285,9 @@ void UpdatedLagrangianQuadrilateral::CalculateMassMatrix( MatrixType& rMassMatri Vector N; this->MPMShapeFunctionPointValues(N, mMP.xg); - const bool is_consistent_mass_matrix = (rCurrentProcessInfo.Has(USE_CONSISTENT_MASS_MATRIX)) - ? rCurrentProcessInfo.GetValue(USE_CONSISTENT_MASS_MATRIX) - : false; + const bool is_lumped_mass_matrix = (rCurrentProcessInfo.Has(COMPUTE_LUMPED_MASS_MATRIX)) + ? rCurrentProcessInfo.GetValue(COMPUTE_LUMPED_MASS_MATRIX) + : true; const SizeType dimension = GetGeometry().WorkingSpaceDimension(); const SizeType number_of_nodes = GetGeometry().PointsNumber(); @@ -1297,7 +1297,7 @@ void UpdatedLagrangianQuadrilateral::CalculateMassMatrix( MatrixType& rMassMatri rMassMatrix.resize(matrix_size, matrix_size, false); rMassMatrix = ZeroMatrix(matrix_size, matrix_size); - if (is_consistent_mass_matrix) { + if (!is_lumped_mass_matrix) { for (IndexType i = 0; i < number_of_nodes; ++i) { for (IndexType j = 0; j < number_of_nodes; ++j) { for (IndexType k = 0; k < dimension; ++k) diff --git a/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp b/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp index 53d598346960..bf8496c2695f 100644 --- a/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp +++ b/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp @@ -121,7 +121,6 @@ namespace Python{ KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, MP_MATERIAL_ID); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, PARTICLES_PER_ELEMENT); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, IGNORE_GEOMETRIC_STIFFNESS); - KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, USE_CONSISTENT_MASS_MATRIX); KRATOS_REGISTER_IN_PYTHON_3D_VARIABLE_WITH_COMPONENTS(m, MPC_COORD); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, MPC_CONDITION_ID); diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp b/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp index df1a76a45bf7..428cda76f187 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp @@ -208,7 +208,6 @@ namespace Kratos KRATOS_REGISTER_3D_VARIABLE_WITH_COMPONENTS( NODAL_MOMENTUM ) KRATOS_REGISTER_3D_VARIABLE_WITH_COMPONENTS( NODAL_INERTIA ) KRATOS_REGISTER_3D_VARIABLE_WITH_COMPONENTS( NODAL_INTERNAL_FORCE ) - KRATOS_REGISTER_VARIABLE(USE_CONSISTENT_MASS_MATRIX) // Registering Constitutive Laws // CL: Linear Elastic laws diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp index 40a6b739effd..80ccc6f647a6 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.cpp @@ -89,7 +89,6 @@ namespace Kratos // Grid node variable KRATOS_CREATE_3D_VARIABLE_WITH_COMPONENTS( NODAL_MOMENTUM) KRATOS_CREATE_3D_VARIABLE_WITH_COMPONENTS( NODAL_INERTIA) - KRATOS_CREATE_VARIABLE(bool, USE_CONSISTENT_MASS_MATRIX) // Solver related variables KRATOS_CREATE_VARIABLE(bool, IGNORE_GEOMETRIC_STIFFNESS) diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h index d1216dd10963..304ae9fbda49 100644 --- a/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h +++ b/applications/ParticleMechanicsApplication/particle_mechanics_application_variables.h @@ -115,7 +115,6 @@ namespace Kratos KRATOS_DEFINE_3D_APPLICATION_VARIABLE_WITH_COMPONENTS(PARTICLE_MECHANICS_APPLICATION, NODAL_MOMENTUM ) KRATOS_DEFINE_3D_APPLICATION_VARIABLE_WITH_COMPONENTS(PARTICLE_MECHANICS_APPLICATION, NODAL_INERTIA ) KRATOS_DEFINE_3D_APPLICATION_VARIABLE_WITH_COMPONENTS(PARTICLE_MECHANICS_APPLICATION, NODAL_INTERNAL_FORCE ) - KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, USE_CONSISTENT_MASS_MATRIX) // Solver related variables KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, IGNORE_GEOMETRIC_STIFFNESS) diff --git a/applications/ParticleMechanicsApplication/python_scripts/mpm_solver.py b/applications/ParticleMechanicsApplication/python_scripts/mpm_solver.py index 3b3df9062f7e..89e556daec4a 100644 --- a/applications/ParticleMechanicsApplication/python_scripts/mpm_solver.py +++ b/applications/ParticleMechanicsApplication/python_scripts/mpm_solver.py @@ -379,7 +379,10 @@ def _CreateSolutionScheme(self): def _CreateSolutionStrategy(self): analysis_type = self.settings["analysis_type"].GetString() is_consistent_mass_matrix = self.settings["consistent_mass_matrix"].GetBool() - self.grid_model_part.ProcessInfo.SetValue(KratosParticle.USE_CONSISTENT_MASS_MATRIX, is_consistent_mass_matrix) + if is_consistent_mass_matrix: + self.grid_model_part.ProcessInfo.SetValue(KratosMultiphysics.COMPUTE_LUMPED_MASS_MATRIX, False) + else: + self.grid_model_part.ProcessInfo.SetValue(KratosMultiphysics.COMPUTE_LUMPED_MASS_MATRIX, True) if analysis_type == "non_linear": solution_strategy = self._CreateNewtonRaphsonStrategy() elif analysis_type == 'linear': From c466e8bbaa4fdff1484959f79ce510b2094a2500 Mon Sep 17 00:00:00 2001 From: Manuel Messmer Date: Sat, 25 Apr 2020 11:12:42 +0200 Subject: [PATCH 248/314] Change Test back to nightsSuite --- .../tests/test_StructuralMechanicsApplication.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/applications/StructuralMechanicsApplication/tests/test_StructuralMechanicsApplication.py b/applications/StructuralMechanicsApplication/tests/test_StructuralMechanicsApplication.py index 03ad1e2b110c..a6ff959633cd 100644 --- a/applications/StructuralMechanicsApplication/tests/test_StructuralMechanicsApplication.py +++ b/applications/StructuralMechanicsApplication/tests/test_StructuralMechanicsApplication.py @@ -312,8 +312,7 @@ def AssembleTestSuites(): # Dynamic Eigenvalue Analysis smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([TTestDynamicEigenvalueAnalysis])) # Buckling analysis test - #Change again!!! - smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([TTestPrebucklingAnalysis])) + nightSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([TTestPrebucklingAnalysis])) # Nodal Damping nightSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([TNodalDampingTests])) # TODO should be in smallSuite but is too slow # Dynamic basic tests From 4339845147e8788917ba088e162bd512b6f87869 Mon Sep 17 00:00:00 2001 From: Manuel Messmer Date: Sat, 25 Apr 2020 11:46:49 +0200 Subject: [PATCH 249/314] Pass buckling settings by parameter object. --- .../add_custom_strategies_to_python.cpp | 2 +- .../custom_strategies/prebuckling_strategy.hpp | 17 +++++++---------- .../structural_mechanics_prebuckling_solver.py | 8 ++------ .../tests/test_prebuckling_analysis.py | 16 +++++++++++----- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/applications/StructuralMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp b/applications/StructuralMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp index c846bed369ff..7b4846cba3fb 100755 --- a/applications/StructuralMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp +++ b/applications/StructuralMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp @@ -109,7 +109,7 @@ void AddCustomStrategiesToPython(pybind11::module& m) // Prebuckling Strategy py::class_< PrebucklingStrategyType, typename PrebucklingStrategyType::Pointer,BaseSolvingStrategyType >(m,"PrebucklingStrategy") - .def(py::init()) + .def(py::init()) .def("GetSolutionFoundFlag", &PrebucklingStrategyType::GetSolutionFoundFlag) ; py::class_< FormfindingStrategyType,typename FormfindingStrategyType::Pointer, ResidualBasedNewtonRaphsonStrategyType >(m,"FormfindingStrategy") diff --git a/applications/StructuralMechanicsApplication/custom_strategies/custom_strategies/prebuckling_strategy.hpp b/applications/StructuralMechanicsApplication/custom_strategies/custom_strategies/prebuckling_strategy.hpp index a6759389c589..452d061a2ba3 100644 --- a/applications/StructuralMechanicsApplication/custom_strategies/custom_strategies/prebuckling_strategy.hpp +++ b/applications/StructuralMechanicsApplication/custom_strategies/custom_strategies/prebuckling_strategy.hpp @@ -101,6 +101,7 @@ class PrebucklingStrategy * @param SmallLoadIncrement Load increment of the small load step * @param PathFollowingStep Load increment of the big load step * @param ConvergenceRatio Convergence ratio for the computed eigenvalues + * @param MakeMatricesSymmetricFlag Flag to ensures that matrices are symmetric before eigenvalue problem is evaluated */ PrebucklingStrategy( ModelPart &rModelPart, @@ -109,11 +110,7 @@ class PrebucklingStrategy BuilderAndSolverPointerType pBuilderAndSolver, typename ConvergenceCriteriaType::Pointer pConvergenceCriteria, int MaxIteration, - double InitialLoadIncrement, - double SmallLoadIncrement, - double PathFollowingStep, - double ConvergenceRatio, - bool MakeMatricesSymmetricFlag ) + Parameters BucklingSettings ) : SolvingStrategy(rModelPart) { KRATOS_TRY @@ -128,15 +125,15 @@ class PrebucklingStrategy mMaxIteration = MaxIteration; - mInitialLoadIncrement = InitialLoadIncrement; + mInitialLoadIncrement = BucklingSettings["initial_load_increment"].GetDouble(); - mSmallLoadIncrement = SmallLoadIncrement; + mSmallLoadIncrement = BucklingSettings["small_load_increment"].GetDouble(); - mPathFollowingStep = PathFollowingStep; + mPathFollowingStep = BucklingSettings["path_following_step"].GetDouble(); - mConvergenceRatio = ConvergenceRatio; + mConvergenceRatio = BucklingSettings["convergence_ratio"].GetDouble(); - mMakeMatricesSymmetricFlag = MakeMatricesSymmetricFlag; + mMakeMatricesSymmetricFlag = BucklingSettings["make_matrices_symmetric"].GetBool(); // Set Eigensolver flags mpEigenSolver->SetDofSetIsInitializedFlag(false); diff --git a/applications/StructuralMechanicsApplication/python_scripts/structural_mechanics_prebuckling_solver.py b/applications/StructuralMechanicsApplication/python_scripts/structural_mechanics_prebuckling_solver.py index 114860865c47..5967a82d5445 100644 --- a/applications/StructuralMechanicsApplication/python_scripts/structural_mechanics_prebuckling_solver.py +++ b/applications/StructuralMechanicsApplication/python_scripts/structural_mechanics_prebuckling_solver.py @@ -35,7 +35,7 @@ def GetDefaultSettings(cls): "small_load_increment" : 0.0005, "path_following_step" : 0.5, "convergence_ratio" : 0.05, - "make_matrices_symmetric" : True + "make_matrices_symmetric" : true }, "eigensolver_settings" : { "solver_type" : "eigen_eigensystem", @@ -117,8 +117,4 @@ def _create_mechanical_solution_strategy(self): builder_and_solver, convergence_criteria, self.settings["max_iteration"].GetInt(), - buckling_settings["initial_load_increment"].GetDouble(), - buckling_settings["small_load_increment"].GetDouble(), - buckling_settings["path_following_step"].GetDouble(), - buckling_settings["convergence_ratio"].GetDouble(), - buckling_settings["make_matrices_symmetric"].GetBoolean() ) + buckling_settings ) diff --git a/applications/StructuralMechanicsApplication/tests/test_prebuckling_analysis.py b/applications/StructuralMechanicsApplication/tests/test_prebuckling_analysis.py index d44fbc3358fd..94edaca1d695 100644 --- a/applications/StructuralMechanicsApplication/tests/test_prebuckling_analysis.py +++ b/applications/StructuralMechanicsApplication/tests/test_prebuckling_analysis.py @@ -97,6 +97,16 @@ def _solve_prebuckling_problem(self,mp,NumOfNodes,iterations,echo=0): } """) + buckling_settings = KratosMultiphysics.Parameters(""" + { + "initial_load_increment" : 1.0, + "small_load_increment" : 0.0005, + "path_following_step" : 0.5, + "convergence_ratio" : 0.005, + "make_matrices_symmetric" : true + } + """) + eigen_solver = EigenSolversApplication.EigensystemSolver(eigensolver_settings) eigen_solver_ = KratosMultiphysics.ResidualBasedEliminationBuilderAndSolver(eigen_solver) convergence_criterion = KratosMultiphysics.DisplacementCriteria(1e-4,1e-9) @@ -111,11 +121,7 @@ def _solve_prebuckling_problem(self,mp,NumOfNodes,iterations,echo=0): builder_and_solver, convergence_criterion, 10, - 1.0, - 0.0005, - 0.5, - 0.005, - True ) + buckling_settings ) eig_strategy.SetEchoLevel(echo) LoadFactor = [] for i in range(iterations): From 61eb9f2313e23c6729653437c1562d9a8eaf9210 Mon Sep 17 00:00:00 2001 From: Philipp Bucher Date: Sun, 26 Apr 2020 16:14:06 +0200 Subject: [PATCH 250/314] Improve import settings (#6802) * unify settings in PythonSolver * unify settings in DistributedImportModelPartUtility * fixing some syntex errors * minor to trigger build --- .../distributed_import_model_part_utility.py | 36 +++++++++---------- kratos/python_scripts/python_solver.py | 30 +++++++++++----- 2 files changed, 39 insertions(+), 27 deletions(-) diff --git a/kratos/mpi/python_scripts/distributed_import_model_part_utility.py b/kratos/mpi/python_scripts/distributed_import_model_part_utility.py index 43d9a57f7afb..4a4147e4600c 100644 --- a/kratos/mpi/python_scripts/distributed_import_model_part_utility.py +++ b/kratos/mpi/python_scripts/distributed_import_model_part_utility.py @@ -26,32 +26,32 @@ def ImportModelPart(self): is_single_process_run = (self.comm.Size() == 1) if input_type == "mdpa": - input_filename = model_part_import_settings["input_filename"].GetString() + default_settings = KratosMultiphysics.Parameters("""{ + "input_filename" : "", + "skip_timer" : true, + "ignore_variables_not_in_solution_step_data" : false, + "perform_partitioning" : true, + "partition_in_memory" : false + }""") + + # cannot validate as this might contain other settings too + model_part_import_settings.AddMissingParameters(default_settings) - # Unless otherwise stated, always perform the Metis partitioning - if not model_part_import_settings.Has("perform_partitioning"): - model_part_import_settings.AddEmptyValue("perform_partitioning") - model_part_import_settings["perform_partitioning"].SetBool(True) + input_filename = model_part_import_settings["input_filename"].GetString() perform_partitioning = model_part_import_settings["perform_partitioning"].GetBool() + partition_in_memory = model_part_import_settings["partition_in_memory"].GetBool() # Setting some mdpa-import-related flags import_flags = KratosMultiphysics.ModelPartIO.READ - if model_part_import_settings.Has("ignore_variables_not_in_solution_step_data"): - if model_part_import_settings["ignore_variables_not_in_solution_step_data"].GetBool(): - import_flags = KratosMultiphysics.ModelPartIO.IGNORE_VARIABLES_ERROR|import_flags - skip_timer = True - if model_part_import_settings.Has("skip_timer"): - skip_timer = model_part_import_settings["skip_timer"].GetBool() - if skip_timer: + + if model_part_import_settings["skip_timer"].GetBool(): import_flags = KratosMultiphysics.ModelPartIO.SKIP_TIMER|import_flags - # Select the partitioning method (File by default) - partition_in_memory = False - if model_part_import_settings.Has("partition_in_memory"): - partition_in_memory = model_part_import_settings["partition_in_memory"].GetBool() + if model_part_import_settings["ignore_variables_not_in_solution_step_data"].GetBool(): + import_flags = KratosMultiphysics.ModelPartIO.IGNORE_VARIABLES_ERROR|import_flags - if not is_single_process_run and perform_partitioning == True: + if not is_single_process_run and perform_partitioning: import KratosMultiphysics.MetisApplication as KratosMetis # Partition of the original .mdpa file @@ -123,4 +123,4 @@ def CreateCommunicators(self): ParallelFillCommunicator = KratosMPI.ParallelFillCommunicator(self.main_model_part.GetRootModelPart()) ParallelFillCommunicator.Execute() - KratosMultiphysics.Logger.PrintInfo("::[DistributedImportModelPartUtility]::", "MPI communicators constructed.") \ No newline at end of file + KratosMultiphysics.Logger.PrintInfo("::[DistributedImportModelPartUtility]::", "MPI communicators constructed.") diff --git a/kratos/python_scripts/python_solver.py b/kratos/python_scripts/python_solver.py index 7b8f0f8e14d4..432a09725d2c 100644 --- a/kratos/python_scripts/python_solver.py +++ b/kratos/python_scripts/python_solver.py @@ -162,29 +162,41 @@ def _ImportModelPart(self, model_part, model_part_import_settings): if (input_type == "mdpa"): problem_path = os.getcwd() + + default_settings = KratosMultiphysics.Parameters("""{ + "input_filename" : "", + "skip_timer" : true, + "ignore_variables_not_in_solution_step_data" : false, + "reorder" : false, + "reorder_consecutive" : false + }""") + + # cannot validate as this might contain other settings too + model_part_import_settings.AddMissingParameters(default_settings) + input_filename = model_part_import_settings["input_filename"].GetString() # Setting some mdpa-import-related flags import_flags = KratosMultiphysics.ModelPartIO.READ - if model_part_import_settings.Has("ignore_variables_not_in_solution_step_data"): - if model_part_import_settings["ignore_variables_not_in_solution_step_data"].GetBool(): - import_flags = KratosMultiphysics.ModelPartIO.IGNORE_VARIABLES_ERROR|import_flags - skip_timer = True - if model_part_import_settings.Has("skip_timer"): - skip_timer = model_part_import_settings["skip_timer"].GetBool() - if skip_timer: + + if model_part_import_settings["skip_timer"].GetBool(): import_flags = KratosMultiphysics.ModelPartIO.SKIP_TIMER|import_flags + if model_part_import_settings["ignore_variables_not_in_solution_step_data"].GetBool(): + import_flags = KratosMultiphysics.ModelPartIO.IGNORE_VARIABLES_ERROR|import_flags + # Import model part from mdpa file. KratosMultiphysics.Logger.PrintInfo("::[PythonSolver]::", "Reading model part from file: " + os.path.join(problem_path, input_filename) + ".mdpa") - if (model_part_import_settings.Has("reorder_consecutive") and model_part_import_settings["reorder_consecutive"].GetBool()): + + if model_part_import_settings["reorder_consecutive"].GetBool(): KratosMultiphysics.ReorderConsecutiveModelPartIO(input_filename, import_flags).ReadModelPart(model_part) else: KratosMultiphysics.ModelPartIO(input_filename, import_flags).ReadModelPart(model_part) - if (model_part_import_settings.Has("reorder") and model_part_import_settings["reorder"].GetBool()): + if model_part_import_settings["reorder"].GetBool(): tmp = KratosMultiphysics.Parameters("{}") KratosMultiphysics.ReorderAndOptimizeModelPartProcess(model_part, tmp).Execute() + KratosMultiphysics.Logger.PrintInfo("::[PythonSolver]::", "Finished reading model part from mdpa file.") elif (input_type == "rest"): From 153775b680676158e1d8c085a6988443bcf672c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Sun, 26 Apr 2020 21:26:26 +0200 Subject: [PATCH 251/314] [MeshingApplication] Extending normalization methods in ComputeHessianSolMetricProcess MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adding value and gradient norm normalization methods as detailed in P.J. Frey, F. Alauzet; Anisotropic mesh adaptation for CFD computations; Comput. Methods Appl. Mech. Engrg. 194 (2005) 5068–5082 --- .../metrics_hessian_process.cpp | 32 +++++++++++++++- .../metrics_hessian_process.h | 28 ++++++++++++-- .../tests/cpp_tests/test_metric_process.cpp | 38 ++++++++++++++++++- 3 files changed, 91 insertions(+), 7 deletions(-) diff --git a/applications/MeshingApplication/custom_processes/metrics_hessian_process.cpp b/applications/MeshingApplication/custom_processes/metrics_hessian_process.cpp index 9ade501ea58a..3d4ba88a5880 100755 --- a/applications/MeshingApplication/custom_processes/metrics_hessian_process.cpp +++ b/applications/MeshingApplication/custom_processes/metrics_hessian_process.cpp @@ -232,7 +232,9 @@ void ComputeHessianSolMetricProcess::CalculateAuxiliarHessian() const int num_nodes = static_cast(r_nodes_array.size()); // We get the normalization factor - const double normalization_factor = mThisParameters["normalization_factor"].GetDouble(); + const Normalization normalization_method = ConvertNormalization(mThisParameters["normalization_method"].GetString()); + const double normalization_factor = normalization_method == Normalization::CONSTANT ? mThisParameters["normalization_factor"].GetDouble() : 1.0; + const double normalization_alpha = mThisParameters["normalization_alpha"].GetDouble(); // Initialize auxiliar variables const auto& it_nodes_begin = r_nodes_array.begin(); @@ -352,9 +354,31 @@ void ComputeHessianSolMetricProcess::CalculateAuxiliarHessian() } } + // We normalize the value of the NODAL_AREA + if (normalization_method == Normalization::VALUE) { + #pragma omp parallel for + for(int i_node = 0; i_node < num_nodes; ++i_node) { + auto it_node = it_nodes_begin + i_node; + const double factor = it_node->GetValue(NODAL_MAUX); + if (factor > std::numeric_limits::epsilon()) { + it_node->GetValue(NODAL_AREA) *= factor; + } + } + } else if (normalization_method == Normalization::NORM_GRADIENT) { + #pragma omp parallel for + for(int i_node = 0; i_node < num_nodes; ++i_node) { + auto it_node = it_nodes_begin + i_node; + const double factor = norm_2(it_node->GetValue(AUXILIAR_GRADIENT)) * it_node->GetValue(NODAL_H) + normalization_alpha * it_node->GetValue(NODAL_MAUX); + if (factor > std::numeric_limits::epsilon()) { + it_node->GetValue(NODAL_AREA) *= factor; + } + } + } + + // We average considering the NODAL_AREA #pragma omp parallel for for(int i_node = 0; i_node < num_nodes; ++i_node) { - auto it_node = r_nodes_array.begin() + i_node; + auto it_node = it_nodes_begin + i_node; const double nodal_area = it_node->GetValue(NODAL_AREA); if (nodal_area > std::numeric_limits::epsilon()) { it_node->GetValue(AUXILIAR_HESSIAN) /= nodal_area; @@ -491,6 +515,8 @@ const Parameters ComputeHessianSolMetricProcess::GetDefaultParameters() const "metric_variable" : "DISTANCE", "non_historical_metric_variable" : false, "normalization_factor" : 1.0, + "normalization_alpha" : 0.0, + "normalization_method" : "constant", "estimate_interpolation_error" : false, "interpolation_error" : 1.0e-6, "mesh_dependent_constant" : 0.28125 @@ -542,6 +568,8 @@ void ComputeHessianSolMetricProcess::InitializeVariables(Parameters ThisParamete mThisParameters.AddValue("metric_variable", ThisParameters["hessian_strategy_parameters"]["metric_variable"]); mThisParameters.AddValue("non_historical_metric_variable", ThisParameters["hessian_strategy_parameters"]["non_historical_metric_variable"]); mThisParameters.AddValue("normalization_factor", ThisParameters["hessian_strategy_parameters"]["normalization_factor"]); + mThisParameters.AddValue("normalization_alpha", ThisParameters["hessian_strategy_parameters"]["normalization_alpha"]); + mThisParameters.AddValue("normalization_method", ThisParameters["hessian_strategy_parameters"]["normalization_method"]); mThisParameters.AddValue("estimate_interpolation_error", considered_parameters["hessian_strategy_parameters"]["estimate_interpolation_error"]); mThisParameters.AddValue("mesh_dependent_constant", considered_parameters["hessian_strategy_parameters"]["mesh_dependent_constant"]); mThisParameters.AddValue("hmin_over_hmax_anisotropic_ratio", considered_parameters["enforced_anisotropy_parameters"]["hmin_over_hmax_anisotropic_ratio"]); diff --git a/applications/MeshingApplication/custom_processes/metrics_hessian_process.h b/applications/MeshingApplication/custom_processes/metrics_hessian_process.h index 6b406d9ae9c4..d9b23a844d2e 100755 --- a/applications/MeshingApplication/custom_processes/metrics_hessian_process.h +++ b/applications/MeshingApplication/custom_processes/metrics_hessian_process.h @@ -94,7 +94,7 @@ namespace Kratos * @ingroup MeshingApplication * @brief This class is can be used to compute the metrics of the model part with an Hessian approach * @details References: - * [1] F. Alauzet, Metric-based anisotropic mesh adaptation, CEA-EDF-INRIA schools: Numerical Analysis Summer School. CEA, Cadarache, France + * [1] P.J. Frey, F. Alauzet; Anisotropic mesh adaptation for CFD computations; Comput. Methods Appl. Mech. Engrg. 194 (2005) 5068–5082 * @author Vicente Mataix Ferrandiz */ class KRATOS_API(MESHING_APPLICATION) ComputeHessianSolMetricProcess @@ -128,6 +128,11 @@ class KRATOS_API(MESHING_APPLICATION) ComputeHessianSolMetricProcess */ enum class Interpolation {CONSTANT = 0, LINEAR = 1, EXPONENTIAL = 2}; + /** + * @brief This enums allows to differentiate the normalization types + */ + enum class Normalization {CONSTANT = 0, VALUE = 1, NORM_GRADIENT = 2}; + ///@} ///@name Life Cycle ///@{ @@ -307,8 +312,8 @@ class KRATOS_API(MESHING_APPLICATION) ComputeHessianSolMetricProcess /** * @brief This converts the interpolation string to an enum - * @param Str The string that you want to comvert in the equivalent enum - * @return Interpolation: The equivalent enum (this requires less memmory than a std::string) + * @param Str The string that you want to convert in the equivalent enum + * @return Interpolation: The equivalent enum (this requires less memmory and is eassier to compare than a std::string) */ Interpolation ConvertInter(const std::string& Str) { @@ -322,6 +327,23 @@ class KRATOS_API(MESHING_APPLICATION) ComputeHessianSolMetricProcess return Interpolation::LINEAR; } + /** + * @brief This converts the normalization string to an enum + * @param Str The string that you want to convert in the equivalent enum + * @return Normalization: The equivalent enum (this requires less memmory and is eassier to compare than a std::string) + */ + Normalization ConvertNormalization(const std::string& Str) + { + if(Str == "Constant" || Str == "CONSTANT" || Str == "constant") + return Normalization::CONSTANT; + else if(Str == "Value" || Str == "VALUE" || Str == "value") + return Normalization::VALUE; + else if(Str == "Norm_Gradient" || Str == "NORM_GRADIENT" || Str == "norm_gradient") + return Normalization::NORM_GRADIENT; + else + return Normalization::CONSTANT; + } + /** * @brief This calculates the anisotropic ratio * @param Distance Distance parameter diff --git a/applications/MeshingApplication/tests/cpp_tests/test_metric_process.cpp b/applications/MeshingApplication/tests/cpp_tests/test_metric_process.cpp index 78945e82e22f..0d289c25d4cd 100644 --- a/applications/MeshingApplication/tests/cpp_tests/test_metric_process.cpp +++ b/applications/MeshingApplication/tests/cpp_tests/test_metric_process.cpp @@ -205,8 +205,8 @@ namespace Kratos // Compute metric Parameters parameters = Parameters(R"({"enforce_anisotropy_relative_variable" : true})"); - auto hessian_process = ComputeHessianSolMetricProcess(r_model_part, DISTANCE, parameters); - hessian_process.Execute(); + auto hessian_process_constant = ComputeHessianSolMetricProcess(r_model_part, DISTANCE, parameters); + hessian_process_constant.Execute(); // // DEBUG // GiDIODebugMetric(r_model_part); @@ -220,6 +220,40 @@ namespace Kratos KRATOS_CHECK_LESS_EQUAL(norm_2(r_model_part.pGetNode(2)->GetValue(METRIC_TENSOR_2D) - ref_metric), tolerance); KRATOS_CHECK_LESS_EQUAL(norm_2(r_model_part.pGetNode(5)->GetValue(METRIC_TENSOR_2D) - ref_metric), tolerance); KRATOS_CHECK_LESS_EQUAL(norm_2(r_model_part.pGetNode(6)->GetValue(METRIC_TENSOR_2D) - ref_metric), tolerance); + + // Compute metric + parameters = Parameters(R"({ + "enforce_anisotropy_relative_variable" : true, + "hessian_strategy_parameters": { + "normalization_method" : "value" + }})"); + auto hessian_process_value = ComputeHessianSolMetricProcess(r_model_part, DISTANCE, parameters); + hessian_process_value.Execute(); + +// // DEBUG +// GiDIODebugMetric(r_model_part); + + KRATOS_CHECK_VECTOR_RELATIVE_NEAR(r_model_part.pGetNode(1)->GetValue(METRIC_TENSOR_2D), ref_metric, tolerance); + KRATOS_CHECK_VECTOR_RELATIVE_NEAR(r_model_part.pGetNode(2)->GetValue(METRIC_TENSOR_2D), ref_metric, tolerance); + KRATOS_CHECK_VECTOR_RELATIVE_NEAR(r_model_part.pGetNode(5)->GetValue(METRIC_TENSOR_2D), ref_metric, tolerance); + KRATOS_CHECK_VECTOR_RELATIVE_NEAR(r_model_part.pGetNode(6)->GetValue(METRIC_TENSOR_2D), ref_metric, tolerance); + + // Compute metric + parameters = Parameters(R"({ + "enforce_anisotropy_relative_variable" : true, + "hessian_strategy_parameters": { + "normalization_method" : "norm_gradient" + }})"); + auto hessian_process_norm_gradient = ComputeHessianSolMetricProcess(r_model_part, DISTANCE, parameters); + hessian_process_norm_gradient.Execute(); + +// // DEBUG +// GiDIODebugMetric(r_model_part); + + KRATOS_CHECK_VECTOR_RELATIVE_NEAR(r_model_part.pGetNode(1)->GetValue(METRIC_TENSOR_2D), ref_metric, tolerance); + KRATOS_CHECK_VECTOR_RELATIVE_NEAR(r_model_part.pGetNode(2)->GetValue(METRIC_TENSOR_2D), ref_metric, tolerance); + KRATOS_CHECK_VECTOR_RELATIVE_NEAR(r_model_part.pGetNode(5)->GetValue(METRIC_TENSOR_2D), ref_metric, tolerance); + KRATOS_CHECK_VECTOR_RELATIVE_NEAR(r_model_part.pGetNode(6)->GetValue(METRIC_TENSOR_2D), ref_metric, tolerance); } /** From 05eba014d43bb75061cd90bdf93e620d8bb091a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Sun, 26 Apr 2020 21:42:38 +0200 Subject: [PATCH 252/314] Update base script --- .../python_scripts/mmg_process.py | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/applications/MeshingApplication/python_scripts/mmg_process.py b/applications/MeshingApplication/python_scripts/mmg_process.py index 528fef0e83e1..2b534e088e2f 100644 --- a/applications/MeshingApplication/python_scripts/mmg_process.py +++ b/applications/MeshingApplication/python_scripts/mmg_process.py @@ -96,6 +96,8 @@ def __init__(self, Model, settings ): "metric_variable" : ["DISTANCE"], "non_historical_metric_variable" : [false], "normalization_factor" : [1.0], + "normalization_alpha" : [0.0], + "normalization_method" : ["constant"], "estimate_interpolation_error" : false, "interpolation_error" : 0.04, "mesh_dependent_constant" : 0.28125 @@ -282,6 +284,10 @@ def ExecuteInitialize(self): self.non_historical_metric_variable = self.__list_extender(self.non_historical_metric_variable, variable_types) self.normalization_factor = self.__generate_double_list_from_input(self.settings["hessian_strategy_parameters"]["normalization_factor"]) self.normalization_factor = self.__list_extender(self.normalization_factor, variable_types) + self.normalization_alpha = self.__generate_double_list_from_input(self.settings["hessian_strategy_parameters"]["normalization_alpha"]) + self.normalization_alpha = self.__list_extender(self.normalization_alpha, variable_types) + self.normalization_method = self.__generate_string_list_from_input(self.settings["hessian_strategy_parameters"]["normalization_method"]) + self.normalization_method = self.__list_extender(self.normalization_method, variable_types) len_metric_variables = len(self.metric_variables) len_non_historical_metric_variable = len(self.non_historical_metric_variable) if len_metric_variables > len_non_historical_metric_variable: @@ -291,6 +297,14 @@ def ExecuteInitialize(self): if len_metric_variables > len_normalization_factor: for i in range(len_normalization_factor, len_metric_variables): self.normalization_factor.append(1.0) + len_normalization_alpha = len(self.normalization_alpha) + if len_metric_variables > len_normalization_alpha: + for i in range(len_normalization_alpha, len_metric_variables): + self.normalization_alpha.append(0.0) + len_normalization_method = len(self.normalization_method) + if len_metric_variables > len_normalization_method: + for i in range(len_normalization_method, len_metric_variables): + self.normalization_method.append("constant") mesh_dependent_constant = self.settings["hessian_strategy_parameters"]["mesh_dependent_constant"].GetDouble() if mesh_dependent_constant == 0.0: self.settings["hessian_strategy_parameters"]["mesh_dependent_constant"].SetDouble(0.5 * (self.domain_size/(self.domain_size + 1))**2.0) @@ -475,13 +489,19 @@ def _CreateMetricsProcess(self): hessian_parameters["hessian_strategy_parameters"].AddEmptyValue("non_historical_metric_variable") hessian_parameters["hessian_strategy_parameters"].RemoveValue("normalization_factor") hessian_parameters["hessian_strategy_parameters"].AddEmptyValue("normalization_factor") + hessian_parameters["hessian_strategy_parameters"].RemoveValue("normalization_alpha") + hessian_parameters["hessian_strategy_parameters"].AddEmptyValue("normalization_alpha") + hessian_parameters["hessian_strategy_parameters"].RemoveValue("normalization_method") + hessian_parameters["hessian_strategy_parameters"].AddEmptyValue("normalization_method") hessian_parameters.AddValue("anisotropy_remeshing",self.settings["anisotropy_remeshing"]) hessian_parameters.AddValue("enforce_anisotropy_relative_variable",self.settings["enforce_anisotropy_relative_variable"]) hessian_parameters.AddValue("enforced_anisotropy_parameters",self.settings["anisotropy_parameters"]) hessian_parameters["enforced_anisotropy_parameters"].RemoveValue("boundary_layer_min_size_ratio") - for current_metric_variable, non_historical_metric_variable, normalization_factor in zip(self.metric_variables, self.non_historical_metric_variable, self.normalization_factor): + for current_metric_variable, non_historical_metric_variable, normalization_factor, normalization_alpha, normalization_method in zip(self.metric_variables, self.non_historical_metric_variable, self.normalization_factor, self.normalization_alpha, self.normalization_method): hessian_parameters["hessian_strategy_parameters"]["non_historical_metric_variable"].SetBool(non_historical_metric_variable) hessian_parameters["hessian_strategy_parameters"]["normalization_factor"].SetDouble(normalization_factor) + hessian_parameters["hessian_strategy_parameters"]["normalization_alpha"].SetDouble(normalization_alpha) + hessian_parameters["hessian_strategy_parameters"]["normalization_method"].SetString(normalization_method) self.metric_processes.append(MeshingApplication.ComputeHessianSolMetricProcess(self.main_model_part, current_metric_variable, hessian_parameters)) elif self.strategy == "superconvergent_patch_recovery" or self.strategy == "SPR": # Generate SPR process @@ -706,6 +726,20 @@ def __generate_double_list_from_input(self,param): return double_list + def __generate_string_list_from_input(self,param): + '''Parse a list of strings from input.''' + # At least verify that the input is an array + if not param.IsArray(): + raise Exception("{0} Error: Variable list is unreadable".format(self.__class__.__name__)) + + # Retrieve the boolean from the arrays + string_list = [] + + for i in range( 0,param.size()): + string_list.append(param[i].GetString()) + + return string_list + def __generate_submodelparts_list_from_input(self,param): '''Parse a list of variables from input.''' # At least verify that the input is a string From 8f2453f8dcef049a0f63e18060ec585c2c9fe47f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Sun, 26 Apr 2020 21:42:54 +0200 Subject: [PATCH 253/314] Update another script --- .../contact_remesh_mmg_process.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/applications/ContactStructuralMechanicsApplication/python_scripts/contact_remesh_mmg_process.py b/applications/ContactStructuralMechanicsApplication/python_scripts/contact_remesh_mmg_process.py index 86a4ff999cd3..4eec4e8cdf5f 100644 --- a/applications/ContactStructuralMechanicsApplication/python_scripts/contact_remesh_mmg_process.py +++ b/applications/ContactStructuralMechanicsApplication/python_scripts/contact_remesh_mmg_process.py @@ -64,6 +64,8 @@ def __init__(self, Model, settings ): "metric_variable" : ["VON_MISES_STRESS","AUGMENTED_NORMAL_CONTACT_PRESSURE","STRAIN_ENERGY"], "non_historical_metric_variable" : [true, true, true], "normalization_factor" : [1.0, 1.0, 1.0], + "normalization_alpha" : [0.0, 0.0, 0.0], + "normalization_method" : ["constant", "constant", "constant"], "estimate_interpolation_error" : false, "interpolation_error" : 0.04, "mesh_dependent_constant" : 0.28125 @@ -164,12 +166,20 @@ def __init__(self, Model, settings ): number_of_metric_variable = settings["hessian_strategy_parameters"]["metric_variable"].size() number_of_non_historical_metric_variable = settings["hessian_strategy_parameters"]["non_historical_metric_variable"].size() number_of_normalization_factor = settings["hessian_strategy_parameters"]["normalization_factor"].size() + number_of_normalization_alpha = settings["hessian_strategy_parameters"]["normalization_alpha"].size() + number_of_normalization_method = settings["hessian_strategy_parameters"]["normalization_method"].size() if number_of_non_historical_metric_variable < number_of_metric_variable: for i in range(number_of_non_historical_metric_variable, number_of_metric_variable): settings["hessian_strategy_parameters"]["non_historical_metric_variable"].Append(True) if number_of_normalization_factor < number_of_metric_variable: for i in range(number_of_normalization_factor, number_of_metric_variable): settings["hessian_strategy_parameters"]["normalization_factor"].Append(1.0) + if number_of_normalization_alpha < number_of_metric_variable: + for i in range(number_of_normalization_alpha, number_of_metric_variable): + settings["hessian_strategy_parameters"]["normalization_alpha"].Append(0.0) + if number_of_normalization_method < number_of_metric_variable: + for i in range(number_of_normalization_method, number_of_metric_variable): + settings["hessian_strategy_parameters"]["normalization_method"].Append("constant") # Remove unused if not self.consider_strain_energy: @@ -180,22 +190,28 @@ def __init__(self, Model, settings ): index_to_remove = i # Copying - auxiliar_parameters = KratosMultiphysics.Parameters("""{"metric_variable" : [], "non_historical_metric_variable" : [], "normalization_factor" : []}""") + auxiliar_parameters = KratosMultiphysics.Parameters("""{"metric_variable" : [], "non_historical_metric_variable" : [], "normalization_factor" : [], "normalization_alpha" : [], "normalization_method" : []}""") for i in range(number_of_metric_variable): if not i == index_to_remove: auxiliar_parameters["metric_variable"].Append(settings["hessian_strategy_parameters"]["metric_variable"][i]) auxiliar_parameters["non_historical_metric_variable"].Append(settings["hessian_strategy_parameters"]["non_historical_metric_variable"][i]) auxiliar_parameters["normalization_factor"].Append(settings["hessian_strategy_parameters"]["normalization_factor"][i]) + auxiliar_parameters["normalization_alpha"].Append(settings["hessian_strategy_parameters"]["normalization_alpha"][i]) + auxiliar_parameters["normalization_method"].Append(settings["hessian_strategy_parameters"]["normalization_method"][i]) # Removing old settings["hessian_strategy_parameters"].RemoveValue("metric_variable") settings["hessian_strategy_parameters"].RemoveValue("non_historical_metric_variable") settings["hessian_strategy_parameters"].RemoveValue("normalization_factor") + settings["hessian_strategy_parameters"].RemoveValue("normalization_alpha") + settings["hessian_strategy_parameters"].RemoveValue("normalization_method") # Adding new settings["hessian_strategy_parameters"].AddValue("metric_variable", auxiliar_parameters["metric_variable"]) settings["hessian_strategy_parameters"].AddValue("non_historical_metric_variable", auxiliar_parameters["non_historical_metric_variable"]) settings["hessian_strategy_parameters"].AddValue("normalization_factor", auxiliar_parameters["normalization_factor"]) + settings["hessian_strategy_parameters"].AddValue("normalization_alpha", auxiliar_parameters["normalization_alpha"]) + settings["hessian_strategy_parameters"].AddValue("normalization_method", auxiliar_parameters["normalization_method"]) # Auxiliar dictionary with the variables and index self.variables_dict = {} From a77e8706697b2b90ff791f73d05d2f7846f4d9f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20Irazabal?= Date: Mon, 27 Apr 2020 08:59:44 +0200 Subject: [PATCH 254/314] Add Young Modulus to properties --- .../simplified_bilinear_3D_law.cpp | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_3D_law.cpp b/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_3D_law.cpp index fcc5b45f854a..d61f5398d33b 100644 --- a/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_3D_law.cpp +++ b/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_3D_law.cpp @@ -23,6 +23,21 @@ int SimplifiedBilinear3DLaw::Check(const Properties& rMaterialProperties,const G KRATOS_CHECK_VARIABLE_KEY(IS_CONVERGED); // Verify Properties variables + KRATOS_CHECK_VARIABLE_KEY(YOUNG_MODULUS); + if(rMaterialProperties.Has(YOUNG_MODULUS)) { + KRATOS_ERROR_IF(rMaterialProperties[YOUNG_MODULUS] <= 0.0) << "YOUNG_MODULUS has an invalid value " << std::endl; + } else { + KRATOS_ERROR << "YOUNG_MODULUS not defined" << std::endl; + } + + KRATOS_CHECK_VARIABLE_KEY(POISSON_RATIO); + if(rMaterialProperties.Has(POISSON_RATIO)) { + KRATOS_ERROR_IF(rMaterialProperties[POISSON_RATIO] < -1.0) << "POISSON_RATIO has an invalid value lower than -1.0" << std::endl; + KRATOS_ERROR_IF(rMaterialProperties[POISSON_RATIO] >= 0.5) << "POISSON_RATIO has an invalid value greater or equal to 0.5 " << std::endl; + } else { + KRATOS_ERROR << "POISSON_RATIO not defined" << std::endl; + } + KRATOS_CHECK_VARIABLE_KEY(MAX_COMPRESSIVE_STRESS); if(rMaterialProperties.Has(MAX_COMPRESSIVE_STRESS)) { KRATOS_ERROR_IF(rMaterialProperties[MAX_COMPRESSIVE_STRESS] < 0.0) << "MAX_COMPRESSIVE_STRESS has an invalid value " << std::endl; @@ -37,14 +52,6 @@ int SimplifiedBilinear3DLaw::Check(const Properties& rMaterialProperties,const G KRATOS_ERROR << "MAX_TENSILE_STRESS not defined" << std::endl; } - KRATOS_CHECK_VARIABLE_KEY(POISSON_RATIO); - if(rMaterialProperties.Has(POISSON_RATIO)) { - KRATOS_ERROR_IF(rMaterialProperties[POISSON_RATIO] < -1.0) << "POISSON_RATIO has an invalid value lower than -1.0" << std::endl; - KRATOS_ERROR_IF(rMaterialProperties[POISSON_RATIO] >= 0.5) << "POISSON_RATIO has an invalid value greater or equal to 0.5 " << std::endl; - } else { - KRATOS_ERROR << "POISSON_RATIO not defined" << std::endl; - } - KRATOS_CHECK_VARIABLE_KEY(FRICTION_COEFFICIENT); if(rMaterialProperties.Has(FRICTION_COEFFICIENT)) { KRATOS_ERROR_IF(rMaterialProperties[FRICTION_COEFFICIENT] < 0.0) << "FRICTION_COEFFICIENT has an invalid value " << std::endl; @@ -133,11 +140,11 @@ void SimplifiedBilinear3DLaw::InitializeConstitutiveLawVariables(ConstitutiveLaw { const Properties& MaterialProperties = rValues.GetMaterialProperties(); + rVariables.YoungModulus = MaterialProperties[YOUNG_MODULUS]; + rVariables.PoissonCoefficient = MaterialProperties[POISSON_RATIO]; rVariables.MaxCompresiveStress = MaterialProperties[MAX_COMPRESSIVE_STRESS]; rVariables.MaxTensileStress = MaterialProperties[MAX_TENSILE_STRESS]; - rVariables.YoungModulus = 85.0e6 * pow(MaterialProperties[MAX_COMPRESSIVE_STRESS] + 8.0e6, 0.33333333333333333333333333333); rVariables.YieldStress = rVariables.YoungModulus; - rVariables.PoissonCoefficient = MaterialProperties[POISSON_RATIO]; rVariables.FrictionCoefficient = MaterialProperties[FRICTION_COEFFICIENT]; } From d255b58625ce12c66de6c94898120b1edda04275 Mon Sep 17 00:00:00 2001 From: DanielDiez Date: Mon, 27 Apr 2020 11:36:29 +0200 Subject: [PATCH 255/314] change default value, rename theta, fix test --- kratos/elements/levelset_convection_element_simplex.h | 2 +- kratos/includes/variables.h | 2 +- kratos/python/add_containers_to_python.cpp | 2 +- kratos/sources/variables.cpp | 4 ++-- kratos/tests/test_levelset_convection.py | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/kratos/elements/levelset_convection_element_simplex.h b/kratos/elements/levelset_convection_element_simplex.h index c5bb9e2d3681..4f04e3df277d 100644 --- a/kratos/elements/levelset_convection_element_simplex.h +++ b/kratos/elements/levelset_convection_element_simplex.h @@ -113,7 +113,7 @@ class LevelSetConvectionElementSimplex const double delta_t = rCurrentProcessInfo[DELTA_TIME]; const double dt_inv = 1.0 / delta_t; - const double theta = rCurrentProcessInfo.Has(THETA) ? rCurrentProcessInfo[THETA] : 1.0; + const double theta = rCurrentProcessInfo.Has(TIME_INTEGRATION_THETA) ? rCurrentProcessInfo[TIME_INTEGRATION_THETA] : 0.5; ConvectionDiffusionSettings::Pointer my_settings = rCurrentProcessInfo.GetValue(CONVECTION_DIFFUSION_SETTINGS); const Variable& rUnknownVar = my_settings->GetUnknownVariable(); diff --git a/kratos/includes/variables.h b/kratos/includes/variables.h index 626e98861120..51d1fa3d901c 100644 --- a/kratos/includes/variables.h +++ b/kratos/includes/variables.h @@ -124,7 +124,7 @@ namespace Kratos KRATOS_DEFINE_VARIABLE( double, GRADIENT_PENALTY_COEFFICIENT ) - KRATOS_DEFINE_VARIABLE( double, THETA ) + KRATOS_DEFINE_VARIABLE( double, TIME_INTEGRATION_THETA ) //sheme info :: pass to elements KRATOS_DEFINE_VARIABLE( double, NEWMARK_BETA ) diff --git a/kratos/python/add_containers_to_python.cpp b/kratos/python/add_containers_to_python.cpp index 9b36b4c2b963..4a0b244bdb03 100644 --- a/kratos/python/add_containers_to_python.cpp +++ b/kratos/python/add_containers_to_python.cpp @@ -328,7 +328,7 @@ void AddContainersToPython(pybind11::module& m) KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, ERROR_RATIO ) KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, TIME_STEPS ) KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, SCALAR_LAGRANGE_MULTIPLIER ) - KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, THETA ) + KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, TIME_INTEGRATION_THETA ) KRATOS_REGISTER_IN_PYTHON_3D_VARIABLE_WITH_COMPONENTS(m, VECTOR_LAGRANGE_MULTIPLIER ) KRATOS_REGISTER_IN_PYTHON_3D_VARIABLE_WITH_COMPONENTS(m, ANGULAR_ACCELERATION ) diff --git a/kratos/sources/variables.cpp b/kratos/sources/variables.cpp index b4284674139d..e0a5800763e1 100644 --- a/kratos/sources/variables.cpp +++ b/kratos/sources/variables.cpp @@ -111,7 +111,7 @@ KRATOS_CREATE_VARIABLE(double, DETERMINANT_F) KRATOS_CREATE_VARIABLE(double, GRADIENT_PENALTY_COEFFICIENT) -KRATOS_CREATE_VARIABLE(double, THETA) +KRATOS_CREATE_VARIABLE(double, TIME_INTEGRATION_THETA) //sheme info :: pass to elements KRATOS_CREATE_VARIABLE(double, NEWMARK_BETA) @@ -600,7 +600,7 @@ void KratosApplication::RegisterVariables() { KRATOS_REGISTER_VARIABLE(GEOMETRIC_STIFFNESS_MATRIX) KRATOS_REGISTER_VARIABLE(DETERMINANT_F) KRATOS_REGISTER_VARIABLE(GRADIENT_PENALTY_COEFFICIENT) - KRATOS_REGISTER_VARIABLE(THETA) + KRATOS_REGISTER_VARIABLE(TIME_INTEGRATION_THETA) //STRAIN MEASURES diff --git a/kratos/tests/test_levelset_convection.py b/kratos/tests/test_levelset_convection.py index adae0f50eea3..704434524870 100644 --- a/kratos/tests/test_levelset_convection.py +++ b/kratos/tests/test_levelset_convection.py @@ -61,8 +61,8 @@ def test_levelset_convection(self): max_distance = max(max_distance, d) min_distance = min(min_distance, d) - self.assertAlmostEqual(max_distance, 0.7904255118014996) - self.assertAlmostEqual(min_distance,-0.11710292469993094) + self.assertAlmostEqual(max_distance, 0.733304104543163) + self.assertAlmostEqual(min_distance,-0.06371359024393097) if __name__ == '__main__': From 269753b27e5ba79a29ec519ba9bb66ab27fc4458 Mon Sep 17 00:00:00 2001 From: Klaus Bernd Sautter Date: Mon, 27 Apr 2020 11:44:56 +0200 Subject: [PATCH 256/314] remove functions --- .../custom_elements/base_shell_element.h | 52 -------- .../custom_elements/base_solid_element.cpp | 85 +------------ .../custom_elements/base_solid_element.h | 115 ++---------------- .../custom_elements/cr_beam_element_2D2N.cpp | 9 -- .../custom_elements/cr_beam_element_2D2N.hpp | 5 - .../custom_elements/cr_beam_element_3D2N.cpp | 10 -- .../custom_elements/cr_beam_element_3D2N.hpp | 5 - .../cr_beam_element_linear_2D2N.cpp | 10 -- .../cr_beam_element_linear_2D2N.hpp | 5 - .../isotropic_shell_element.cpp | 11 -- .../isotropic_shell_element.hpp | 4 - .../custom_elements/membrane_element.cpp | 19 --- .../custom_elements/membrane_element.hpp | 7 -- ...cement_mixed_volumetric_strain_element.cpp | 23 ---- ...lacement_mixed_volumetric_strain_element.h | 21 ---- .../solid_shell_element_sprism_3D6N.cpp | 72 ----------- .../solid_shell_element_sprism_3D6N.h | 79 ------------ .../custom_elements/truss_element_3D2N.cpp | 27 ---- .../custom_elements/truss_element_3D2N.hpp | 19 --- .../custom_elements/updated_lagrangian.cpp | 23 ---- .../custom_elements/updated_lagrangian.h | 29 ----- 21 files changed, 14 insertions(+), 616 deletions(-) diff --git a/applications/StructuralMechanicsApplication/custom_elements/base_shell_element.h b/applications/StructuralMechanicsApplication/custom_elements/base_shell_element.h index c1ac661bcad3..d7e961d167a3 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/base_shell_element.h +++ b/applications/StructuralMechanicsApplication/custom_elements/base_shell_element.h @@ -144,58 +144,6 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) BaseShellElement void CalculateRightHandSide(VectorType& rRightHandSideVector, ProcessInfo& rCurrentProcessInfo) override; - // GetValueOnIntegrationPoints are TEMPORARY until they are removed!!! - // They will be removed from the derived elements; i.e. the implementation - // should be in CalculateOnIntegrationPoints! - // Adding these functions here is bcs GiD calls GetValueOnIntegrationPoints - void GetValueOnIntegrationPoints(const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo) override - { - CalculateOnIntegrationPoints(rVariable, rValues, rCurrentProcessInfo); - } - - void GetValueOnIntegrationPoints(const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo) override - { - CalculateOnIntegrationPoints(rVariable, rValues, rCurrentProcessInfo); - } - - void GetValueOnIntegrationPoints(const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo) override - { - CalculateOnIntegrationPoints(rVariable, rValues, rCurrentProcessInfo); - } - - void GetValueOnIntegrationPoints(const Variable >& rVariable, - std::vector >& rValues, - const ProcessInfo& rCurrentProcessInfo) override - { - CalculateOnIntegrationPoints(rVariable, rValues, rCurrentProcessInfo); - } - - void GetValueOnIntegrationPoints(const Variable >& rVariable, - std::vector >& rValues, - const ProcessInfo& rCurrentProcessInfo) override - { - CalculateOnIntegrationPoints(rVariable, rValues, rCurrentProcessInfo); - } - - void GetValueOnIntegrationPoints(const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo) override - { - CalculateOnIntegrationPoints(rVariable, rValues, rCurrentProcessInfo); - } - - void GetValueOnIntegrationPoints(const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo) override - { - CalculateOnIntegrationPoints(rVariable, rValues, rCurrentProcessInfo); - } /** * This method provides the place to perform checks on the completeness of the input diff --git a/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.cpp b/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.cpp index 67ba734d9c69..67f3f0f5a767 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.cpp +++ b/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.cpp @@ -1325,94 +1325,11 @@ void BaseSolidElement::SetValuesOnIntegrationPoints( } } -/***********************************************************************************/ -/***********************************************************************************/ - -void BaseSolidElement::GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) -{ - CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo ); -} - -/***********************************************************************************/ -/***********************************************************************************/ - -void BaseSolidElement::GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) -{ - CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo ); -} - -/***********************************************************************************/ -/***********************************************************************************/ - -void BaseSolidElement::GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) -{ - CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo ); -} - -/***********************************************************************************/ -/***********************************************************************************/ - -void BaseSolidElement::GetValueOnIntegrationPoints( - const Variable>& rVariable, - std::vector>& rValues, - const ProcessInfo& rCurrentProcessInfo - ) -{ - CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo ); -} - -/***********************************************************************************/ -/***********************************************************************************/ - -void BaseSolidElement::GetValueOnIntegrationPoints( - const Variable>& rVariable, - std::vector>& rValues, - const ProcessInfo& rCurrentProcessInfo - ) -{ - CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo ); -} - -/***********************************************************************************/ -/***********************************************************************************/ - -void BaseSolidElement::GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) -{ - CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo ); -} /***********************************************************************************/ /***********************************************************************************/ -void BaseSolidElement::GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) -{ - CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo ); -} - -/***********************************************************************************/ -/***********************************************************************************/ - -void BaseSolidElement::GetValueOnIntegrationPoints( +void BaseSolidElement::CalculateOnIntegrationPoints( const Variable& rVariable, std::vector& rValues, const ProcessInfo& rCurrentProcessInfo diff --git a/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.h b/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.h index 098c2822c6f3..6b80e98a0729 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.h +++ b/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.h @@ -457,6 +457,19 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) BaseSolidElement const ProcessInfo& rCurrentProcessInfo ) override; + + /** + * @brief Calculate a Constitutive Law from the element + * @param rVariable The variable we want to get + * @param rOutput The values obtained int the integration points + * @param rCurrentProcessInfo the current process info instance + */ + void CalculateOnIntegrationPoints( + const Variable& rVariable, + std::vector& rValues, + const ProcessInfo& rCurrentProcessInfo + ) override; + /** * @brief Set a bool Value on the Element Constitutive Law * @param rVariable The variable we want to set @@ -553,108 +566,6 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) BaseSolidElement const ProcessInfo& rCurrentProcessInfo ) override; - // GetValueOnIntegrationPoints are TEMPORARY until they are removed!!! - // They will be removed from the derived elements; i.e. the implementation - // should be in CalculateOnIntegrationPoints! - // Adding these functions here is bcs GiD calls GetValueOnIntegrationPoints - - /** - * @brief Get on rVariable a bool Value from the Element Constitutive Law - * @param rVariable The variable we want to get - * @param rValues The results in the integration points - * @param rCurrentProcessInfo the current process info instance - */ - void GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) override; - - /** - * @brief Get on rVariable a int Value from the Element Constitutive Law - * @param rVariable The variable we want to get - * @param rValues The results in the integration points - * @param rCurrentProcessInfo the current process info instance - */ - void GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) override; - - /** - * @brief Get on rVariable a double Value from the Element Constitutive Law - * @param rVariable The variable we want to get - * @param rValues The results in the integration points - * @param rCurrentProcessInfo the current process info instance - */ - void GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) override; - - /** - * @brief Get on rVariable a 3 components array_1d Value from the Element Constitutive Law - * @param rVariable The variable we want to get - * @param rValues The results in the integration points - * @param rCurrentProcessInfo the current process info instance - */ - void GetValueOnIntegrationPoints( - const Variable>& rVariable, - std::vector>& rValues, - const ProcessInfo& rCurrentProcessInfo - ) override; - - /** - * @brief Get on rVariable a 6 components array_1d Value from the Element Constitutive Law - * @param rVariable The variable we want to get - * @param rValues The results in the integration points - * @param rCurrentProcessInfo the current process info instance - */ - void GetValueOnIntegrationPoints( - const Variable>& rVariable, - std::vector>& rValues, - const ProcessInfo& rCurrentProcessInfo - ) override; - - /** - * @brief Get on rVariable a Vector Value from the Element Constitutive Law - * @param rVariable The variable we want to get - * @param rValues The results in the integration points - * @param rCurrentProcessInfo the current process info instance - */ - void GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) override; - - /** - * @brief Get on rVariable a Matrix Value from the Element Constitutive Law - * @param rVariable The variable we want to get - * @param rValues The results in the integration points - * @param rCurrentProcessInfo the current process info instance - */ - void GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) override; - - /** - * @todo To be renamed to CalculateOnIntegrationPoints!!! - * @brief Get on rVariable Constitutive Law from the element - * @param rVariable The variable we want to get - * @param rValues The results in the integration points - * @param rCurrentProcessInfo the current process info instance - */ - void GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) override; - /** * @brief This function provides the place to perform checks on the completeness of the input. * @details It is designed to be called only once (or anyway, not often) typically at the beginning diff --git a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_2D2N.cpp b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_2D2N.cpp index 74fac473e5b6..eb94d5533f10 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_2D2N.cpp +++ b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_2D2N.cpp @@ -790,15 +790,6 @@ void CrBeamElement2D2N::CalculateOnIntegrationPoints( KRATOS_CATCH("") } -void CrBeamElement2D2N::GetValueOnIntegrationPoints( - const Variable>& rVariable, - std::vector>& rOutput, - const ProcessInfo& rCurrentProcessInfo) -{ - KRATOS_TRY; - CalculateOnIntegrationPoints(rVariable, rOutput, rCurrentProcessInfo); - KRATOS_CATCH("") -} CrBeamElement2D2N::IntegrationMethod CrBeamElement2D2N::GetIntegrationMethod() const diff --git a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_2D2N.hpp b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_2D2N.hpp index 5523f603cf5a..36d09c22aa26 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_2D2N.hpp +++ b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_2D2N.hpp @@ -261,11 +261,6 @@ class CrBeamElement2D2N : public Element * @brief This function calculates the element contributions to an explicit time integration */ - void GetValueOnIntegrationPoints( - const Variable >& rVariable, - std::vector< array_1d >& rOutput, - const ProcessInfo& rCurrentProcessInfo) override; - void CalculateOnIntegrationPoints( const Variable >& rVariable, std::vector< array_1d >& rOutput, diff --git a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_3D2N.cpp b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_3D2N.cpp index 951b59b5789e..4a9cabab342a 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_3D2N.cpp +++ b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_3D2N.cpp @@ -1272,16 +1272,6 @@ void CrBeamElement3D2N::CalculateOnIntegrationPoints( KRATOS_CATCH("") } -void CrBeamElement3D2N::GetValueOnIntegrationPoints( - const Variable>& rVariable, - std::vector>& rOutput, - const ProcessInfo& rCurrentProcessInfo) -{ - KRATOS_TRY; - CalculateOnIntegrationPoints(rVariable, rOutput, rCurrentProcessInfo); - KRATOS_CATCH("") -} - void CrBeamElement3D2N::AssembleSmallInBigMatrix( Matrix SmallMatrix, diff --git a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_3D2N.hpp b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_3D2N.hpp index 3f65369958eb..228186d188ef 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_3D2N.hpp +++ b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_3D2N.hpp @@ -263,11 +263,6 @@ class CrBeamElement3D2N : public Element std::vector< array_1d >& rOutput, const ProcessInfo& rCurrentProcessInfo) override; - void GetValueOnIntegrationPoints( - const Variable >& rVariable, - std::vector< array_1d >& rOutput, - const ProcessInfo& rCurrentProcessInfo) override; - IntegrationMethod GetIntegrationMethod() const override; diff --git a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_linear_2D2N.cpp b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_linear_2D2N.cpp index b66061b8e2b6..0dd02580e274 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_linear_2D2N.cpp +++ b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_linear_2D2N.cpp @@ -210,16 +210,6 @@ void CrBeamElementLinear2D2N::CalculateOnIntegrationPoints( KRATOS_CATCH("") } -void CrBeamElementLinear2D2N::GetValueOnIntegrationPoints( - const Variable>& rVariable, - std::vector>& rOutput, - const ProcessInfo& rCurrentProcessInfo) -{ - KRATOS_TRY; - CalculateOnIntegrationPoints(rVariable, rOutput, rCurrentProcessInfo); - KRATOS_CATCH("") -} - double CrBeamElementLinear2D2N::CalculateLength() const { KRATOS_TRY; diff --git a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_linear_2D2N.hpp b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_linear_2D2N.hpp index 9d0949816c1a..c0a093c3d073 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_linear_2D2N.hpp +++ b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_linear_2D2N.hpp @@ -103,11 +103,6 @@ class CrBeamElementLinear2D2N : public CrBeamElement2D2N double CalculateLength() const override; - void GetValueOnIntegrationPoints( - const Variable >& rVariable, - std::vector< array_1d >& rOutput, - const ProcessInfo& rCurrentProcessInfo) override; - void CalculateOnIntegrationPoints( const Variable >& rVariable, std::vector< array_1d >& rOutput, diff --git a/applications/StructuralMechanicsApplication/custom_elements/isotropic_shell_element.cpp b/applications/StructuralMechanicsApplication/custom_elements/isotropic_shell_element.cpp index 9858116623d6..9226843bac9e 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/isotropic_shell_element.cpp +++ b/applications/StructuralMechanicsApplication/custom_elements/isotropic_shell_element.cpp @@ -939,17 +939,6 @@ void IsotropicShellElement::NicePrint(const Matrix& A) } -//************************************************************************************ -//************************************************************************************ -void IsotropicShellElement::GetValueOnIntegrationPoints( const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo) -{ - CalculateOnIntegrationPoints(rVariable, rValues, rCurrentProcessInfo); -} - - - //************************************************************************************ //************************************************************************************ void IsotropicShellElement::CalculateOnIntegrationPoints(const Variable& rVariable, std::vector< Matrix >& Output, const ProcessInfo& rCurrentProcessInfo) diff --git a/applications/StructuralMechanicsApplication/custom_elements/isotropic_shell_element.hpp b/applications/StructuralMechanicsApplication/custom_elements/isotropic_shell_element.hpp index 2c25b54abf06..af6920e12b49 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/isotropic_shell_element.hpp +++ b/applications/StructuralMechanicsApplication/custom_elements/isotropic_shell_element.hpp @@ -123,10 +123,6 @@ class IsotropicShellElement void CalculateOnIntegrationPoints(const Variable& rVariable, std::vector& Output, const ProcessInfo& rCurrentProcessInfo) override; - void GetValueOnIntegrationPoints( const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo) override; - void Calculate(const Variable& rVariable, Matrix& Output, const ProcessInfo& rCurrentProcessInfo) override; void Initialize(const ProcessInfo& rCurrentProcessInfo) override; diff --git a/applications/StructuralMechanicsApplication/custom_elements/membrane_element.cpp b/applications/StructuralMechanicsApplication/custom_elements/membrane_element.cpp index 6ab8899ec851..e62af665741b 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/membrane_element.cpp +++ b/applications/StructuralMechanicsApplication/custom_elements/membrane_element.cpp @@ -973,25 +973,6 @@ void MembraneElement::Calculate(const Variable& rVariable, Matrix& rOutp } } -void MembraneElement::GetValueOnIntegrationPoints( - const Variable>& rVariable, - std::vector>& rOutput, - const ProcessInfo& rCurrentProcessInfo) -{ - KRATOS_TRY; - CalculateOnIntegrationPoints(rVariable, rOutput, rCurrentProcessInfo); - KRATOS_CATCH("") -} - -void MembraneElement::GetValueOnIntegrationPoints(const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo) -{ - KRATOS_TRY; - CalculateOnIntegrationPoints(rVariable, rValues, rCurrentProcessInfo); - KRATOS_CATCH("") -} - void MembraneElement::CalculateMassMatrix(MatrixType& rMassMatrix, ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY diff --git a/applications/StructuralMechanicsApplication/custom_elements/membrane_element.hpp b/applications/StructuralMechanicsApplication/custom_elements/membrane_element.hpp index 334e59219bd4..1533de7c5363 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/membrane_element.hpp +++ b/applications/StructuralMechanicsApplication/custom_elements/membrane_element.hpp @@ -122,10 +122,6 @@ namespace Kratos std::vector>& rOutput, const ProcessInfo& rCurrentProcessInfo) override; - void GetValueOnIntegrationPoints( - const Variable>& rVariable, - std::vector>& rOutput, - const ProcessInfo& rCurrentProcessInfo) override; void CalculateMassMatrix(MatrixType& rMassMatrix,ProcessInfo& rCurrentProcessInfo) override; @@ -367,9 +363,6 @@ namespace Kratos void PrincipalVector(Vector& rPrincipalVector, const Vector& rNonPrincipalVector); - void GetValueOnIntegrationPoints(const Variable& rVariable, - std::vector& rValues, const ProcessInfo& rCurrentProcessInfo) override; - void CalculateOnIntegrationPoints(const Variable& rVariable, std::vector< Vector >& rOutput, const ProcessInfo& rCurrentProcessInfo) override; diff --git a/applications/StructuralMechanicsApplication/custom_elements/small_displacement_mixed_volumetric_strain_element.cpp b/applications/StructuralMechanicsApplication/custom_elements/small_displacement_mixed_volumetric_strain_element.cpp index 48a0934a317e..7efe94fd751b 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/small_displacement_mixed_volumetric_strain_element.cpp +++ b/applications/StructuralMechanicsApplication/custom_elements/small_displacement_mixed_volumetric_strain_element.cpp @@ -1140,29 +1140,6 @@ void SmallDisplacementMixedVolumetricStrainElement::CalculateOnIntegrationPoints } } -/***********************************************************************************/ -/***********************************************************************************/ - -void SmallDisplacementMixedVolumetricStrainElement::GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) -{ - CalculateOnIntegrationPoints(rVariable, rValues, rCurrentProcessInfo); -} - -/***********************************************************************************/ -/***********************************************************************************/ - -void SmallDisplacementMixedVolumetricStrainElement::GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) -{ - CalculateOnIntegrationPoints(rVariable, rValues, rCurrentProcessInfo); -} /***********************************************************************************/ /***********************************************************************************/ diff --git a/applications/StructuralMechanicsApplication/custom_elements/small_displacement_mixed_volumetric_strain_element.h b/applications/StructuralMechanicsApplication/custom_elements/small_displacement_mixed_volumetric_strain_element.h index 781067604a76..2ce65bb61e88 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/small_displacement_mixed_volumetric_strain_element.h +++ b/applications/StructuralMechanicsApplication/custom_elements/small_displacement_mixed_volumetric_strain_element.h @@ -345,27 +345,6 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) SmallDisplacementMixedVolumet std::vector& rOutput, const ProcessInfo& rCurrentProcessInfo) override; - /** - * @brief Get on rVariable a double Value from the Element Constitutive Law - * @param rVariable The variable we want to get - * @param rValues The results in the integration points - * @param rCurrentProcessInfo the current process info instance - */ - void GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo) override; - - /** - * @brief Get on rVariable a Vector Value from the Element Constitutive Law - * @param rVariable The variable we want to get - * @param rValues The results in the integration points - * @param rCurrentProcessInfo the current process info instance - */ - void GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo) override; ///@} ///@name Access diff --git a/applications/StructuralMechanicsApplication/custom_elements/solid_shell_element_sprism_3D6N.cpp b/applications/StructuralMechanicsApplication/custom_elements/solid_shell_element_sprism_3D6N.cpp index 292c677683ab..5ba8952dfc51 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/solid_shell_element_sprism_3D6N.cpp +++ b/applications/StructuralMechanicsApplication/custom_elements/solid_shell_element_sprism_3D6N.cpp @@ -1341,78 +1341,6 @@ void SolidShellElementSprism3D6N::SetValuesOnIntegrationPoints( BaseType::SetValuesOnIntegrationPoints(rVariable, rValues, rCurrentProcessInfo); } -/******************************** GET DOUBLE VALUE *********************************/ -/***********************************************************************************/ - -void SolidShellElementSprism3D6N::GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) -{ - CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo ); -} - -/********************************** GET VECTOR VALUE *******************************/ -/***********************************************************************************/ - -void SolidShellElementSprism3D6N::GetValueOnIntegrationPoints( - const Variable>& rVariable, - std::vector>& rValues, - const ProcessInfo& rCurrentProcessInfo - ) -{ - CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo ); -} - -/*********************************** GET MATRIX VALUE ******************************/ -/***********************************************************************************/ - -void SolidShellElementSprism3D6N::GetValueOnIntegrationPoints( - const Variable>& rVariable, - std::vector>& rValues, - const ProcessInfo& rCurrentProcessInfo - ) -{ - CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo ); -} - -/********************************** GET VECTOR VALUE *******************************/ -/***********************************************************************************/ - -void SolidShellElementSprism3D6N::GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) -{ - CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo ); -} - -/*********************************** GET MATRIX VALUE ******************************/ -/***********************************************************************************/ - -void SolidShellElementSprism3D6N::GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) -{ - CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo ); -} - -/******************************** GET CONSTITUTIVE VALUE ***************************/ -/***********************************************************************************/ - -void SolidShellElementSprism3D6N::GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) -{ - BaseType::GetValueOnIntegrationPoints(rVariable, rValues, rCurrentProcessInfo); -} - //********************************* CHECK VALUES **********************************// /***********************************************************************************/ /***********************************************************************************/ diff --git a/applications/StructuralMechanicsApplication/custom_elements/solid_shell_element_sprism_3D6N.h b/applications/StructuralMechanicsApplication/custom_elements/solid_shell_element_sprism_3D6N.h index 6989d45832bc..8ef4a421d2a6 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/solid_shell_element_sprism_3D6N.h +++ b/applications/StructuralMechanicsApplication/custom_elements/solid_shell_element_sprism_3D6N.h @@ -425,7 +425,6 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) SolidShellElementSprism3D6N * Note, that these functions expect a std::vector of values for the * specified variable type that contains a value for each integration point! * SetValuesOnIntegrationPoints: Set the values for given Variable. - * GetValueOnIntegrationPoints: Get the values for given Variable. */ /** @@ -476,84 +475,6 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) SolidShellElementSprism3D6N const ProcessInfo& rCurrentProcessInfo ) override; - // GetValueOnIntegrationPoints are TEMPORARY until they are removed!!! - // They will be removed from the derived elements; i.e. the implementation - // should be in CalculateOnIntegrationPoints! - // Adding these functions here is bcs GiD calls GetValueOnIntegrationPoints - - /** - * @brief Get on rVariable a double Value from the Element Constitutive Law - * @param rVariable The internal variables in the element - * @param rValues Values of the ContstitutiveLaw - * @param rCurrentProcessInfo The current process info instance - */ - void GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) override; - - /** - * @brief Get on rVariable a array_1d Value from the Element Constitutive Law - * @param rVariable The internal variables in the element - * @param rValues Values of the ContstitutiveLaw - * @param rCurrentProcessInfo The current process info instance - */ - void GetValueOnIntegrationPoints( - const Variable>& rVariable, - std::vector>& rValues, - const ProcessInfo& rCurrentProcessInfo - ) override; - - /** - * @brief Get on rVariable a array_1d Value from the Element Constitutive Law - * @param rVariable The internal variables in the element - * @param rValues Values of the ContstitutiveLaw - * @param rCurrentProcessInfo The current process info instance - */ - void GetValueOnIntegrationPoints( - const Variable>& rVariable, - std::vector>& rValues, - const ProcessInfo& rCurrentProcessInfo - ) override; - - /** - * @brief Get on rVariable a Vector Value from the Element Constitutive Law - * @param rVariable The internal variables in the element - * @param rValues Values of the ContstitutiveLaw - * @param rCurrentProcessInfo The current process info instance - */ - void GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) override; - - /** - * @brief Get on rVariable a Matrix Value from the Element Constitutive Law - * @param rVariable The internal variables in the element - * @param rValues Values of the ContstitutiveLaw - * @param rCurrentProcessInfo The current process info instance - */ - void GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) override; - - /** - * @todo To be renamed to CalculateOnIntegrationPoints!!! - * @brief Get a Constitutive Law Value - * @param rVariable The internal variables in the element - * @param rValues Values of the ContstitutiveLaw - * @param rCurrentProcessInfo The current process info instance - */ - void GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) override; - //****************** CHECK VALUES *****************// /** * @brief This function provides the place to perform checks on the completeness of the input. diff --git a/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.cpp b/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.cpp index b783c55fb1c4..8e948c6f44f2 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.cpp +++ b/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.cpp @@ -435,33 +435,6 @@ void TrussElement3D2N::CalculateOnIntegrationPoints( } } -void TrussElement3D2N::GetValueOnIntegrationPoints( - const Variable& rVariable, std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo) -{ - KRATOS_TRY - CalculateOnIntegrationPoints(rVariable, rValues, rCurrentProcessInfo); - KRATOS_CATCH("") -} -void TrussElement3D2N::GetValueOnIntegrationPoints( - const Variable& rVariable, std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo) -{ - KRATOS_TRY - CalculateOnIntegrationPoints(rVariable, rValues, rCurrentProcessInfo); - KRATOS_CATCH("") -} - -void TrussElement3D2N::GetValueOnIntegrationPoints( - const Variable>& rVariable, - std::vector>& rOutput, - const ProcessInfo& rCurrentProcessInfo) -{ - KRATOS_TRY; - CalculateOnIntegrationPoints(rVariable, rOutput, rCurrentProcessInfo); - KRATOS_CATCH("") -} - int TrussElement3D2N::Check(const ProcessInfo& rCurrentProcessInfo) const { KRATOS_TRY diff --git a/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.hpp b/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.hpp index 2ab52f880279..16a8904572d0 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.hpp +++ b/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.hpp @@ -117,15 +117,6 @@ namespace Kratos std::vector& rOutput, const ProcessInfo& rCurrentProcessInfo) override; - void GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo) override; - - void GetValueOnIntegrationPoints( - const Variable >& rVariable, - std::vector< array_1d >& rOutput, - const ProcessInfo& rCurrentProcessInfo) override; /** * @brief This function updates the internal normal force w.r.t. the current deformations @@ -144,16 +135,6 @@ namespace Kratos std::vector& rOutput, const ProcessInfo& rCurrentProcessInfo) override; - void GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo) override; - - void CalculateOnIntegrationPoints( - const Variable >& rVariable, - std::vector< array_1d >& rOutput, - const ProcessInfo& rCurrentProcessInfo) override; - void CalculateLocalSystem( MatrixType& rLeftHandSideMatrix, VectorType& rRightHandSideVector, diff --git a/applications/StructuralMechanicsApplication/custom_elements/updated_lagrangian.cpp b/applications/StructuralMechanicsApplication/custom_elements/updated_lagrangian.cpp index eea805033f34..b4add7f941a8 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/updated_lagrangian.cpp +++ b/applications/StructuralMechanicsApplication/custom_elements/updated_lagrangian.cpp @@ -527,29 +527,6 @@ void UpdatedLagrangian::SetValuesOnIntegrationPoints( } } -/***********************************************************************************/ -/***********************************************************************************/ - -void UpdatedLagrangian::GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) -{ - this->CalculateOnIntegrationPoints(rVariable, rValues, rCurrentProcessInfo); -} - -/***********************************************************************************/ -/***********************************************************************************/ - -void UpdatedLagrangian::GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) -{ - this->CalculateOnIntegrationPoints(rVariable, rValues, rCurrentProcessInfo); -} /***********************************************************************************/ /***********************************************************************************/ diff --git a/applications/StructuralMechanicsApplication/custom_elements/updated_lagrangian.h b/applications/StructuralMechanicsApplication/custom_elements/updated_lagrangian.h index 4c1572628023..4b0d9e37da32 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/updated_lagrangian.h +++ b/applications/StructuralMechanicsApplication/custom_elements/updated_lagrangian.h @@ -211,35 +211,6 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) UpdatedLagrangian const ProcessInfo& rCurrentProcessInfo ) override; - // GetValueOnIntegrationPoints are TEMPORARY until they are removed!!! - // They will be removed from the derived elements; i.e. the implementation - // should be in CalculateOnIntegrationPoints! - // Adding these functions here is bcs GiD calls GetValueOnIntegrationPoints - - /** - * @brief Get on rVariable a double Value from the Element Constitutive Law - * @param rVariable The variable we want to get - * @param rValues The results in the integration points - * @param rCurrentProcessInfo the current process info instance - */ - void GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) override; - - /** - * @brief Get on rVariable a Matrix Value from the Element Constitutive Law - * @param rVariable The variable we want to get - * @param rValues The results in the integration points - * @param rCurrentProcessInfo the current process info instance - */ - void GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) override; - ///@} ///@name Access ///@{ From c1d7011d9258fdf6d9e49413158bf79f298d30b8 Mon Sep 17 00:00:00 2001 From: Carlos Roig Date: Mon, 27 Apr 2020 11:05:27 +0000 Subject: [PATCH 257/314] Adding compatibility with hdf5 1.12 --- applications/HDF5Application/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/applications/HDF5Application/CMakeLists.txt b/applications/HDF5Application/CMakeLists.txt index e90b5014d07b..c682b199fce3 100644 --- a/applications/HDF5Application/CMakeLists.txt +++ b/applications/HDF5Application/CMakeLists.txt @@ -41,6 +41,8 @@ set( KRATOS_HDF5_APPLICATION_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_hdf5_condition_flag_value_io.cpp ) +add_definitions(-DH5_USE_110_API) + set(HDF5_USE_STATIC_LIBRARIES OFF) if(USE_MPI) message(STATUS "Searching for parallel HDF5 libraries.") @@ -135,4 +137,4 @@ if(${INSTALL_TESTING_FILES} MATCHES ON ) endif(${INSTALL_TESTING_FILES} MATCHES ON) # Install targets -install(TARGETS KratosHDF5Application DESTINATION libs) \ No newline at end of file +install(TARGETS KratosHDF5Application DESTINATION libs) From 1c13409d953ff3174489929fdd15c55b11712f5d Mon Sep 17 00:00:00 2001 From: Klaus Bernd Sautter Date: Mon, 27 Apr 2020 13:55:58 +0200 Subject: [PATCH 258/314] small fixes --- .../custom_elements/base_solid_element.cpp | 2 +- .../custom_elements/base_solid_element.h | 25 ++++++++++--------- .../custom_elements/truss_element_3D2N.hpp | 13 +++++++--- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.cpp b/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.cpp index 67f3f0f5a767..0849ccebeecd 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.cpp +++ b/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.cpp @@ -1329,7 +1329,7 @@ void BaseSolidElement::SetValuesOnIntegrationPoints( /***********************************************************************************/ /***********************************************************************************/ -void BaseSolidElement::CalculateOnIntegrationPoints( +void BaseSolidElement::GetValueOnIntegrationPoints( const Variable& rVariable, std::vector& rValues, const ProcessInfo& rCurrentProcessInfo diff --git a/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.h b/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.h index 6b80e98a0729..f93260fc2f15 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.h +++ b/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.h @@ -458,18 +458,6 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) BaseSolidElement ) override; - /** - * @brief Calculate a Constitutive Law from the element - * @param rVariable The variable we want to get - * @param rOutput The values obtained int the integration points - * @param rCurrentProcessInfo the current process info instance - */ - void CalculateOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) override; - /** * @brief Set a bool Value on the Element Constitutive Law * @param rVariable The variable we want to set @@ -566,6 +554,19 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) BaseSolidElement const ProcessInfo& rCurrentProcessInfo ) override; + /** + * @todo To be renamed to CalculateOnIntegrationPoints!!! + * @brief Get on rVariable Constitutive Law from the element + * @param rVariable The variable we want to get + * @param rValues The results in the integration points + * @param rCurrentProcessInfo the current process info instance + */ + void GetValueOnIntegrationPoints( + const Variable& rVariable, + std::vector& rValues, + const ProcessInfo& rCurrentProcessInfo + ) override; + /** * @brief This function provides the place to perform checks on the completeness of the input. * @details It is designed to be called only once (or anyway, not often) typically at the beginning diff --git a/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.hpp b/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.hpp index 16a8904572d0..daa51b89d770 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.hpp +++ b/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.hpp @@ -117,6 +117,15 @@ namespace Kratos std::vector& rOutput, const ProcessInfo& rCurrentProcessInfo) override; + void CalculateOnIntegrationPoints( + const Variable >& rVariable, + std::vector< array_1d >& rOutput, + const ProcessInfo& rCurrentProcessInfo) override; + + void CalculateOnIntegrationPoints( + const Variable& rVariable, + std::vector& rOutput, + const ProcessInfo& rCurrentProcessInfo) override; /** * @brief This function updates the internal normal force w.r.t. the current deformations @@ -130,10 +139,6 @@ namespace Kratos */ void CreateTransformationMatrix(BoundedMatrix& rRotationMatrix); - void CalculateOnIntegrationPoints( - const Variable& rVariable, - std::vector& rOutput, - const ProcessInfo& rCurrentProcessInfo) override; void CalculateLocalSystem( MatrixType& rLeftHandSideMatrix, From 57f341c6399797849b3f8868063a64d1b2fe8dda Mon Sep 17 00:00:00 2001 From: KlausBSautter Date: Mon, 27 Apr 2020 14:03:54 +0200 Subject: [PATCH 259/314] fixing segfault in spr_error_process --- .../custom_processes/spr_error_process.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/StructuralMechanicsApplication/custom_processes/spr_error_process.cpp b/applications/StructuralMechanicsApplication/custom_processes/spr_error_process.cpp index ecf03a078ca7..5ccd8130dc5d 100644 --- a/applications/StructuralMechanicsApplication/custom_processes/spr_error_process.cpp +++ b/applications/StructuralMechanicsApplication/custom_processes/spr_error_process.cpp @@ -215,8 +215,8 @@ void SPRErrorProcess::CalculatePatch( auto& neigh_elements = itPatchNode->GetValue(NEIGHBOUR_ELEMENTS); for( WeakElementItType it_elem = neigh_elements.begin(); it_elem != neigh_elements.end(); ++it_elem) { - it_elem->GetValueOnIntegrationPoints(*mpStressVariable,stress_vector,mThisModelPart.GetProcessInfo()); - it_elem->GetValueOnIntegrationPoints(INTEGRATION_COORDINATES,coordinates_vector,mThisModelPart.GetProcessInfo()); + it_elem->CalculateOnIntegrationPoints(*mpStressVariable,stress_vector,mThisModelPart.GetProcessInfo()); + it_elem->CalculateOnIntegrationPoints(INTEGRATION_COORDINATES,coordinates_vector,mThisModelPart.GetProcessInfo()); KRATOS_INFO_IF("SPRErrorProcess", mEchoLevel > 3) << "\tStress: " << stress_vector[0] << std::endl From 8de8fda6b90f3de1919094cb51ef58c4c99bb159 Mon Sep 17 00:00:00 2001 From: KlausBSautter Date: Mon, 27 Apr 2020 14:09:04 +0200 Subject: [PATCH 260/314] more fixes on spr_error_process --- .../custom_processes/spr_error_process.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/StructuralMechanicsApplication/custom_processes/spr_error_process.cpp b/applications/StructuralMechanicsApplication/custom_processes/spr_error_process.cpp index 5ccd8130dc5d..602342a2c33c 100644 --- a/applications/StructuralMechanicsApplication/custom_processes/spr_error_process.cpp +++ b/applications/StructuralMechanicsApplication/custom_processes/spr_error_process.cpp @@ -151,7 +151,7 @@ void SPRErrorProcess::CalculateErrorEstimation( for(int i_elem = 0; i_elem < num_elem; ++i_elem){ auto it_elem = it_elem_begin + i_elem; - it_elem->GetValueOnIntegrationPoints(ERROR_INTEGRATION_POINT, error_integration_point, r_process_info); + it_elem->CalculateOnIntegrationPoints(ERROR_INTEGRATION_POINT, error_integration_point, r_process_info); // The error_integration_point is printed if (mEchoLevel > 2) { @@ -170,7 +170,7 @@ void SPRErrorProcess::CalculateErrorEstimation( it_elem->SetValue(ELEMENT_ERROR, error_energy_norm); // We compute now the energy norm - it_elem->GetValueOnIntegrationPoints(STRAIN_ENERGY, strain_energy, r_process_info); + it_elem->CalculateOnIntegrationPoints(STRAIN_ENERGY, strain_energy, r_process_info); double energy_norm = 0.0; for(IndexType i = 0;i < strain_energy.size(); ++i) { From 7bff34d820e036f0f1690122c92a043772640405 Mon Sep 17 00:00:00 2001 From: philbucher Date: Mon, 27 Apr 2020 14:20:01 +0200 Subject: [PATCH 261/314] update also conditions --- .../custom_conditions/line_load_condition.cpp | 17 ----------------- .../custom_conditions/line_load_condition.h | 12 ------------ .../surface_load_condition_3d.cpp | 16 ---------------- .../surface_load_condition_3d.h | 12 ------------ 4 files changed, 57 deletions(-) diff --git a/applications/StructuralMechanicsApplication/custom_conditions/line_load_condition.cpp b/applications/StructuralMechanicsApplication/custom_conditions/line_load_condition.cpp index c661edbe484d..65c21180c552 100644 --- a/applications/StructuralMechanicsApplication/custom_conditions/line_load_condition.cpp +++ b/applications/StructuralMechanicsApplication/custom_conditions/line_load_condition.cpp @@ -99,23 +99,6 @@ LineLoadCondition::~LineLoadCondition() /***********************************************************************************/ /***********************************************************************************/ -template -void LineLoadCondition::GetValueOnIntegrationPoints( - const Variable>& rVariable, - std::vector< array_1d>& rOutput, - const ProcessInfo& rCurrentProcessInfo - ) -{ - KRATOS_TRY; - - this->CalculateOnIntegrationPoints( rVariable, rOutput, rCurrentProcessInfo ); - - KRATOS_CATCH( "" ); -} - -/***********************************************************************************/ -/***********************************************************************************/ - template void LineLoadCondition::CalculateOnIntegrationPoints( const Variable>& rVariable, diff --git a/applications/StructuralMechanicsApplication/custom_conditions/line_load_condition.h b/applications/StructuralMechanicsApplication/custom_conditions/line_load_condition.h index 12752f0c4781..5a10291e9c24 100644 --- a/applications/StructuralMechanicsApplication/custom_conditions/line_load_condition.h +++ b/applications/StructuralMechanicsApplication/custom_conditions/line_load_condition.h @@ -148,18 +148,6 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) LineLoadCondition NodesArrayType const& ThisNodes ) const override; - /** - * @brief Get on rVariable a array_1d Value - * @param rVariable Internal values - * @param rCurrentProcessInfo The current process information - * @param rOutput The values of interest (array_1d) - */ - void GetValueOnIntegrationPoints( - const Variable>& rVariable, - std::vector>& rOutput, - const ProcessInfo& rCurrentProcessInfo - ) override; - /** * @brief Calculate a array_1d Variable * @param rVariable Internal values diff --git a/applications/StructuralMechanicsApplication/custom_conditions/surface_load_condition_3d.cpp b/applications/StructuralMechanicsApplication/custom_conditions/surface_load_condition_3d.cpp index 595c03758041..25e1fafdf640 100644 --- a/applications/StructuralMechanicsApplication/custom_conditions/surface_load_condition_3d.cpp +++ b/applications/StructuralMechanicsApplication/custom_conditions/surface_load_condition_3d.cpp @@ -105,22 +105,6 @@ SurfaceLoadCondition3D::~SurfaceLoadCondition3D() /***********************************************************************************/ /***********************************************************************************/ -void SurfaceLoadCondition3D::GetValueOnIntegrationPoints( - const Variable >& rVariable, - std::vector< array_1d >& rOutput, - const ProcessInfo& rCurrentProcessInfo - ) -{ - KRATOS_TRY; - - this->CalculateOnIntegrationPoints( rVariable, rOutput, rCurrentProcessInfo ); - - KRATOS_CATCH( "" ); -} - -/***********************************************************************************/ -/***********************************************************************************/ - void SurfaceLoadCondition3D::CalculateOnIntegrationPoints( const Variable >& rVariable, std::vector< array_1d >& rOutput, diff --git a/applications/StructuralMechanicsApplication/custom_conditions/surface_load_condition_3d.h b/applications/StructuralMechanicsApplication/custom_conditions/surface_load_condition_3d.h index 40f3d9eae1b6..e6c30789ab59 100644 --- a/applications/StructuralMechanicsApplication/custom_conditions/surface_load_condition_3d.h +++ b/applications/StructuralMechanicsApplication/custom_conditions/surface_load_condition_3d.h @@ -129,18 +129,6 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) SurfaceLoadCondition3D NodesArrayType const& ThisNodes ) const override; - /** - * @brief Get on rVariable a array_1d Value - * @param rVariable Internal values - * @param rCurrentProcessInfo The current process information - * @param rOutput The values of interest (array_1d) - */ - void GetValueOnIntegrationPoints( - const Variable >& rVariable, - std::vector >& rOutput, - const ProcessInfo& rCurrentProcessInfo - ) override; - /** * @brief Calculate a array_1d Variable * @param rVariable Internal values From 25b9fe1c0501959877692c4b611da327902ac1ca Mon Sep 17 00:00:00 2001 From: philbucher Date: Mon, 27 Apr 2020 14:20:14 +0200 Subject: [PATCH 262/314] update adjoint stuff --- .../adjoint_semi_analytic_base_condition.h | 14 -------------- .../adjoint_finite_difference_base_element.h | 14 -------------- 2 files changed, 28 deletions(-) diff --git a/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_conditions/adjoint_semi_analytic_base_condition.h b/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_conditions/adjoint_semi_analytic_base_condition.h index 6c5771ab3100..518a2aa54a7f 100644 --- a/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_conditions/adjoint_semi_analytic_base_condition.h +++ b/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_conditions/adjoint_semi_analytic_base_condition.h @@ -305,20 +305,6 @@ class AdjointSemiAnalyticBaseCondition KRATOS_ERROR << "CalculateOnIntegrationPoints of the adjoint base condition is called!" << std::endl; } - void GetValueOnIntegrationPoints(const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo) override - { - this->CalculateOnIntegrationPoints(rVariable, rValues, rCurrentProcessInfo); - } - - void GetValueOnIntegrationPoints(const Variable >& rVariable, - std::vector< array_1d >& rValues, - const ProcessInfo& rCurrentProcessInfo) override - { - this->CalculateOnIntegrationPoints(rVariable, rValues, rCurrentProcessInfo); - } - int Check( const ProcessInfo& rCurrentProcessInfo ) const override; /** diff --git a/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_finite_difference_base_element.h b/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_finite_difference_base_element.h index c02cb9e2dcb5..751356a4353f 100644 --- a/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_finite_difference_base_element.h +++ b/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_finite_difference_base_element.h @@ -364,20 +364,6 @@ class AdjointFiniteDifferencingBaseElement : public Element KRATOS_ERROR << "CalculateOnIntegrationPoints of the adjoint base element is called!" << std::endl; } - void GetValueOnIntegrationPoints(const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo) override - { - this->CalculateOnIntegrationPoints(rVariable, rValues, rCurrentProcessInfo); - } - - void GetValueOnIntegrationPoints(const Variable >& rVariable, - std::vector< array_1d >& rValues, - const ProcessInfo& rCurrentProcessInfo) override - { - this->CalculateOnIntegrationPoints(rVariable, rValues, rCurrentProcessInfo); - } - int Check(const ProcessInfo& rCurrentProcessInfo) const override; From 346d387b26ce86ca6d69ae04e593cd785f20f6f2 Mon Sep 17 00:00:00 2001 From: philbucher Date: Mon, 27 Apr 2020 14:23:54 +0200 Subject: [PATCH 263/314] first updates in Contact --- .../custom_processes/contact_spr_error_process.cpp | 4 ++-- .../residualbased_newton_raphson_contact_strategy.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/applications/ContactStructuralMechanicsApplication/custom_processes/contact_spr_error_process.cpp b/applications/ContactStructuralMechanicsApplication/custom_processes/contact_spr_error_process.cpp index 21269ec5db3d..555f895909bf 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_processes/contact_spr_error_process.cpp +++ b/applications/ContactStructuralMechanicsApplication/custom_processes/contact_spr_error_process.cpp @@ -75,8 +75,8 @@ void ContactSPRErrorProcess::CalculatePatch( for( WeakElementItType it_elem = r_neigh_elements.begin(); it_elem != r_neigh_elements.end(); ++it_elem) { auto& r_process_info = BaseType::mThisModelPart.GetProcessInfo(); - it_elem->GetValueOnIntegrationPoints(*BaseType::mpStressVariable,stress_vector, r_process_info); - it_elem->GetValueOnIntegrationPoints(INTEGRATION_COORDINATES, coordinates_vector, r_process_info); + it_elem->CalculateOnIntegrationPoints(*BaseType::mpStressVariable,stress_vector, r_process_info); + it_elem->CalculateOnIntegrationPoints(INTEGRATION_COORDINATES, coordinates_vector, r_process_info); KRATOS_INFO_IF("ContactSPRErrorProcess", BaseType::mEchoLevel > 3) << "\tElement: " << it_elem->Id() << std::endl diff --git a/applications/ContactStructuralMechanicsApplication/custom_strategies/custom_strategies/residualbased_newton_raphson_contact_strategy.h b/applications/ContactStructuralMechanicsApplication/custom_strategies/custom_strategies/residualbased_newton_raphson_contact_strategy.h index 652e408fdea6..4c8496306867 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_strategies/custom_strategies/residualbased_newton_raphson_contact_strategy.h +++ b/applications/ContactStructuralMechanicsApplication/custom_strategies/custom_strategies/residualbased_newton_raphson_contact_strategy.h @@ -818,7 +818,7 @@ class ResidualBasedNewtonRaphsonContactStrategy : // We check now the deformation gradient std::vector deformation_gradient_matrices; - it_elem->GetValueOnIntegrationPoints( DEFORMATION_GRADIENT, deformation_gradient_matrices, r_process_info); + it_elem->CalculateOnIntegrationPoints( DEFORMATION_GRADIENT, deformation_gradient_matrices, r_process_info); for (IndexType i_gp = 0; i_gp < deformation_gradient_matrices.size(); ++i_gp) { const double det_f = MathUtils::DetMat(deformation_gradient_matrices[i_gp]); From 7c64331f74a2401b201f079af525273051f4adb0 Mon Sep 17 00:00:00 2001 From: philbucher Date: Mon, 27 Apr 2020 14:26:42 +0200 Subject: [PATCH 264/314] updated Contact --- .../mesh_tying_mortar_condition.cpp | 40 ------------------- .../mesh_tying_mortar_condition.h | 27 ------------- .../mortar_contact_condition.cpp | 39 ------------------ .../mortar_contact_condition.h | 36 ----------------- .../mpc_mortar_contact_condition.cpp | 39 ------------------ .../mpc_mortar_contact_condition.h | 36 ----------------- .../mesh_tying_mortar_condition_template.cpp | 40 ------------------- 7 files changed, 257 deletions(-) diff --git a/applications/ContactStructuralMechanicsApplication/custom_conditions/mesh_tying_mortar_condition.cpp b/applications/ContactStructuralMechanicsApplication/custom_conditions/mesh_tying_mortar_condition.cpp index 6fd0599d182a..21020a93cb21 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_conditions/mesh_tying_mortar_condition.cpp +++ b/applications/ContactStructuralMechanicsApplication/custom_conditions/mesh_tying_mortar_condition.cpp @@ -6343,46 +6343,6 @@ void MeshTyingMortarCondition::GetDofL KRATOS_CATCH( "" ); } - -//******************************* GET DOUBLE VALUE *********************************/ -/***********************************************************************************/ - -template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> -void MeshTyingMortarCondition::GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) -{ - this->CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo ); -} - -//******************************* GET ARRAY_1D VALUE *******************************/ -/***********************************************************************************/ - -template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> -void MeshTyingMortarCondition::GetValueOnIntegrationPoints( - const Variable >& rVariable, - std::vector >& rValues, - const ProcessInfo& rCurrentProcessInfo - ) -{ - this->CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo ); -} - -//******************************* GET VECTOR VALUE *********************************/ -/***********************************************************************************/ - -template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> -void MeshTyingMortarCondition::GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) -{ - this->CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo ); -} - /***********************************************************************************/ /***********************************************************************************/ diff --git a/applications/ContactStructuralMechanicsApplication/custom_conditions/mesh_tying_mortar_condition.h b/applications/ContactStructuralMechanicsApplication/custom_conditions/mesh_tying_mortar_condition.h index 33c969b21f9e..64414c8e07d0 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_conditions/mesh_tying_mortar_condition.h +++ b/applications/ContactStructuralMechanicsApplication/custom_conditions/mesh_tying_mortar_condition.h @@ -296,33 +296,6 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MeshTyingMortarCondit const ProcessInfo& rCurrentProcessInfo ) const override; - /** - * Get on rVariable a double Value - */ - void GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) override; - - /** - * Get on rVariable a array_1d Value - */ - void GetValueOnIntegrationPoints( - const Variable >& rVariable, - std::vector >& rValues, - const ProcessInfo& rCurrentProcessInfo - ) override; - - /** - * Get on rVariable a Vector Value - */ - void GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) override; - /** * Calculate a double Variable */ diff --git a/applications/ContactStructuralMechanicsApplication/custom_conditions/mortar_contact_condition.cpp b/applications/ContactStructuralMechanicsApplication/custom_conditions/mortar_contact_condition.cpp index d8f7d94dd8f5..235c59b6e5e7 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_conditions/mortar_contact_condition.cpp +++ b/applications/ContactStructuralMechanicsApplication/custom_conditions/mortar_contact_condition.cpp @@ -577,45 +577,6 @@ void MortarContactCondition -void MortarContactCondition::GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) -{ - this->CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo ); -} - -//******************************* GET ARRAY_1D VALUE *******************************/ -/***********************************************************************************/ - -template< SizeType TDim, SizeType TNumNodes, FrictionalCase TFrictional, bool TNormalVariation, SizeType TNumNodesMaster> -void MortarContactCondition::GetValueOnIntegrationPoints( - const Variable >& rVariable, - std::vector >& rValues, - const ProcessInfo& rCurrentProcessInfo - ) -{ - this->CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo ); -} - -//******************************* GET VECTOR VALUE *********************************/ -/***********************************************************************************/ - -template< SizeType TDim, SizeType TNumNodes, FrictionalCase TFrictional, bool TNormalVariation, SizeType TNumNodesMaster> -void MortarContactCondition::GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) -{ - this->CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo ); -} - /***********************************************************************************/ /***********************************************************************************/ diff --git a/applications/ContactStructuralMechanicsApplication/custom_conditions/mortar_contact_condition.h b/applications/ContactStructuralMechanicsApplication/custom_conditions/mortar_contact_condition.h index 91a63dfd2bed..c6f85f568381 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_conditions/mortar_contact_condition.h +++ b/applications/ContactStructuralMechanicsApplication/custom_conditions/mortar_contact_condition.h @@ -351,42 +351,6 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MortarContactConditio const ProcessInfo& rCurrentProcessInfo ) const override; - /** - * @brief Get on rVariable a double Value - * @param rVariable Internal values - * @param rCurrentProcessInfo The current process information - * @param rValues The values of interest (doubles) - */ - void GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) override; - - /** - * @brief Get on rVariable a array_1d Value - * @param rVariable Internal values - * @param rCurrentProcessInfo The current process information - * @param rValues The values of interest (array_1d) - */ - void GetValueOnIntegrationPoints( - const Variable >& rVariable, - std::vector >& rValues, - const ProcessInfo& rCurrentProcessInfo - ) override; - - /** - * @brief Get on rVariable a Vector Value - * @param rVariable Internal values - * @param rCurrentProcessInfo The current process information - * @param rValues The values of interest (vector) - */ - void GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) override; - /** * @brief Calculate a double Variable * @param rVariable Internal values diff --git a/applications/ContactStructuralMechanicsApplication/custom_conditions/mpc_mortar_contact_condition.cpp b/applications/ContactStructuralMechanicsApplication/custom_conditions/mpc_mortar_contact_condition.cpp index b6df3ce1ebf1..b77b7eb5ebeb 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_conditions/mpc_mortar_contact_condition.cpp +++ b/applications/ContactStructuralMechanicsApplication/custom_conditions/mpc_mortar_contact_condition.cpp @@ -947,45 +947,6 @@ void MPCMortarContactCondition::ComputePreviousM MortarExplicitContributionUtilities::ComputePreviousMortarOperators(this, rCurrentProcessInfo, mPreviousMortarOperators, integration_order, false); } -//******************************* GET DOUBLE VALUE *********************************/ -/***********************************************************************************/ - -template< SizeType TDim, SizeType TNumNodes, SizeType TNumNodesMaster> -void MPCMortarContactCondition::GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) -{ - this->CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo ); -} - -//******************************* GET ARRAY_1D VALUE *******************************/ -/***********************************************************************************/ - -template< SizeType TDim, SizeType TNumNodes, SizeType TNumNodesMaster> -void MPCMortarContactCondition::GetValueOnIntegrationPoints( - const Variable >& rVariable, - std::vector >& rValues, - const ProcessInfo& rCurrentProcessInfo - ) -{ - this->CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo ); -} - -//******************************* GET VECTOR VALUE *********************************/ -/***********************************************************************************/ - -template< SizeType TDim, SizeType TNumNodes, SizeType TNumNodesMaster> -void MPCMortarContactCondition::GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) -{ - this->CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo ); -} - /***********************************************************************************/ /***********************************************************************************/ diff --git a/applications/ContactStructuralMechanicsApplication/custom_conditions/mpc_mortar_contact_condition.h b/applications/ContactStructuralMechanicsApplication/custom_conditions/mpc_mortar_contact_condition.h index 885d91c56c2a..66f93b914be5 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_conditions/mpc_mortar_contact_condition.h +++ b/applications/ContactStructuralMechanicsApplication/custom_conditions/mpc_mortar_contact_condition.h @@ -306,42 +306,6 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MPCMortarContactCondi /********** AUXILLIARY METHODS FOR GENERAL CALCULATIONS ***********/ /******************************************************************/ - /** - * @brief Get on rVariable a double Value - * @param rVariable Internal values - * @param rCurrentProcessInfo The current process information - * @param rValues The values of interest (doubles) - */ - void GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) override; - - /** - * @brief Get on rVariable a array_1d Value - * @param rVariable Internal values - * @param rCurrentProcessInfo The current process information - * @param rValues The values of interest (array_1d) - */ - void GetValueOnIntegrationPoints( - const Variable >& rVariable, - std::vector >& rValues, - const ProcessInfo& rCurrentProcessInfo - ) override; - - /** - * @brief Get on rVariable a Vector Value - * @param rVariable Internal values - * @param rCurrentProcessInfo The current process information - * @param rValues The values of interest (vector) - */ - void GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) override; - /** * @brief Calculate a double Variable * @param rVariable Internal values diff --git a/applications/ContactStructuralMechanicsApplication/symbolic_generation/mesh_tying_mortar_condition/mesh_tying_mortar_condition_template.cpp b/applications/ContactStructuralMechanicsApplication/symbolic_generation/mesh_tying_mortar_condition/mesh_tying_mortar_condition_template.cpp index 3a912dc366c7..286edd3e215c 100644 --- a/applications/ContactStructuralMechanicsApplication/symbolic_generation/mesh_tying_mortar_condition/mesh_tying_mortar_condition_template.cpp +++ b/applications/ContactStructuralMechanicsApplication/symbolic_generation/mesh_tying_mortar_condition/mesh_tying_mortar_condition_template.cpp @@ -686,46 +686,6 @@ void MeshTyingMortarCondition::GetDofL KRATOS_CATCH( "" ); } - -//******************************* GET DOUBLE VALUE *********************************/ -/***********************************************************************************/ - -template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> -void MeshTyingMortarCondition::GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) -{ - this->CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo ); -} - -//******************************* GET ARRAY_1D VALUE *******************************/ -/***********************************************************************************/ - -template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> -void MeshTyingMortarCondition::GetValueOnIntegrationPoints( - const Variable >& rVariable, - std::vector >& rValues, - const ProcessInfo& rCurrentProcessInfo - ) -{ - this->CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo ); -} - -//******************************* GET VECTOR VALUE *********************************/ -/***********************************************************************************/ - -template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> -void MeshTyingMortarCondition::GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo - ) -{ - this->CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo ); -} - /***********************************************************************************/ /***********************************************************************************/ From 35d24796390c5810eb7e63e6ea67412ddb28c982 Mon Sep 17 00:00:00 2001 From: philbucher Date: Mon, 27 Apr 2020 14:29:56 +0200 Subject: [PATCH 265/314] updates also Trilinos --- .../TrilinosApplication/custom_utilities/trilinos_refine_mesh.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/TrilinosApplication/custom_utilities/trilinos_refine_mesh.h b/applications/TrilinosApplication/custom_utilities/trilinos_refine_mesh.h index 3d63175c9c97..cf9fff280a07 100644 --- a/applications/TrilinosApplication/custom_utilities/trilinos_refine_mesh.h +++ b/applications/TrilinosApplication/custom_utilities/trilinos_refine_mesh.h @@ -988,7 +988,7 @@ class TrilinosRefineMesh const ProcessInfo& rCurrentProcessInfo) { std::vector values; - father_elem->GetValueOnIntegrationPoints(INTERNAL_VARIABLES, values, rCurrentProcessInfo); + father_elem->CalculateOnIntegrationPoints(INTERNAL_VARIABLES, values, rCurrentProcessInfo); /* /// WARNING = Calculando la longitud ponderada de fractura del elemento. Solo valido para isotropic_damage Element::GeometryType& geom_father = father_elem->GetGeometry(); Element::GeometryType& geom_child = child_elem->GetGeometry(); From cf5869f898611b52e4b5c6e69bafc366bc685e92 Mon Sep 17 00:00:00 2001 From: Manuel Messmer Date: Mon, 27 Apr 2020 14:33:58 +0200 Subject: [PATCH 266/314] Add some comment! --- .../custom_strategies/custom_strategies/prebuckling_strategy.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/applications/StructuralMechanicsApplication/custom_strategies/custom_strategies/prebuckling_strategy.hpp b/applications/StructuralMechanicsApplication/custom_strategies/custom_strategies/prebuckling_strategy.hpp index 452d061a2ba3..8582055a0402 100644 --- a/applications/StructuralMechanicsApplication/custom_strategies/custom_strategies/prebuckling_strategy.hpp +++ b/applications/StructuralMechanicsApplication/custom_strategies/custom_strategies/prebuckling_strategy.hpp @@ -553,6 +553,7 @@ class PrebucklingStrategy rStiffnessMatrix = rStiffnessMatrixPrevious - rStiffnessMatrix; // Symmetrice matrices if enabled + // The ublas transpose function is called manually, because it is missing in the corresponding space if( mMakeMatricesSymmetricFlag ){ rStiffnessMatrix = 0.5 * ( rStiffnessMatrix + boost::numeric::ublas::trans(rStiffnessMatrix) ); rStiffnessMatrixPrevious = 0.5 * ( rStiffnessMatrixPrevious + boost::numeric::ublas::trans(rStiffnessMatrixPrevious) ); From aec2437504138c5b19c3133c9acc9419436bf0ef Mon Sep 17 00:00:00 2001 From: philbucher Date: Mon, 27 Apr 2020 17:01:22 +0200 Subject: [PATCH 267/314] updates in MeshinApp --- .../MeshingApplication/custom_io/pfem_gid_io.h | 14 +++++++------- .../internal_variables_interpolation_process.h | 10 +++++----- .../local_refine_geometry_mesh.cpp | 2 +- .../test_internal_interpolation_process.cpp | 8 ++++---- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/applications/MeshingApplication/custom_io/pfem_gid_io.h b/applications/MeshingApplication/custom_io/pfem_gid_io.h index cc6b24f991a7..c18d095e8a8c 100644 --- a/applications/MeshingApplication/custom_io/pfem_gid_io.h +++ b/applications/MeshingApplication/custom_io/pfem_gid_io.h @@ -128,7 +128,7 @@ class PfemGidGaussPointsContainer for( ModelPart::ElementsContainerType::iterator it = mMeshElements.begin(); it != mMeshElements.end(); it++ ) { - it->GetValueOnIntegrationPoints( rVariable, ValuesOnIntPoint, + it->CalculateOnIntegrationPoints( rVariable, ValuesOnIntPoint, r_model_part.GetProcessInfo() ); for(unsigned int i=0; iGetValueOnIntegrationPoints( rVariable, ValuesOnIntPoint, + it->CalculateOnIntegrationPoints( rVariable, ValuesOnIntPoint, r_model_part.GetProcessInfo() ); for(unsigned int i=0; iGetValueOnIntegrationPoints( rVariable, ValuesOnIntPoint, + it->CalculateOnIntegrationPoints( rVariable, ValuesOnIntPoint, r_model_part.GetProcessInfo() ); for(unsigned int i=0; iGetValueOnIntegrationPoints( rVariable, ValuesOnIntPoint, + it->CalculateOnIntegrationPoints( rVariable, ValuesOnIntPoint, r_model_part.GetProcessInfo() ); for(unsigned int i=0; iGetValueOnIntegrationPoints( rVariable, ValuesOnIntPoint, + it->CalculateOnIntegrationPoints( rVariable, ValuesOnIntPoint, r_model_part.GetProcessInfo() ); for(unsigned int i=0; iGetValueOnIntegrationPoints( rVariable, ValuesOnIntPoint, + it->CalculateOnIntegrationPoints( rVariable, ValuesOnIntPoint, r_model_part.GetProcessInfo() ); for(unsigned int i=0; i values; - itElemOrigin->GetValueOnIntegrationPoints(rThisVar, values, rCurrentProcessInfo); + itElemOrigin->CalculateOnIntegrationPoints(rThisVar, values, rCurrentProcessInfo); pPointOrigin->SetValue(rThisVar, values[GaussPointId]); } @@ -353,7 +353,7 @@ class KRATOS_API(MESHING_APPLICATION) InternalVariablesInterpolationProcess ) { std::vector values; - itElemDestination->GetValueOnIntegrationPoints(rThisVar, values, rCurrentProcessInfo); + itElemDestination->CalculateOnIntegrationPoints(rThisVar, values, rCurrentProcessInfo); TVarType aux_value; values[GaussPointId] = pPointOrigin->GetValue(rThisVar, aux_value); itElemDestination->SetValuesOnIntegrationPoints(rThisVar, values, rCurrentProcessInfo); @@ -445,7 +445,7 @@ class KRATOS_API(MESHING_APPLICATION) InternalVariablesInterpolationProcess const TVarType destination_value = weighting_function_numerator/weighting_function_denominator; std::vector values; - itElemDestination->GetValueOnIntegrationPoints(rThisVar, values, rCurrentProcessInfo); + itElemDestination->CalculateOnIntegrationPoints(rThisVar, values, rCurrentProcessInfo); values[GaussPointId] = destination_value; itElemDestination->SetValuesOnIntegrationPoints(rThisVar, values, rCurrentProcessInfo); } @@ -499,7 +499,7 @@ class KRATOS_API(MESHING_APPLICATION) InternalVariablesInterpolationProcess ) { std::vector origin_values; - itElemOrigin->GetValueOnIntegrationPoints(rThisVar, origin_values, rCurrentProcessInfo); + itElemOrigin->CalculateOnIntegrationPoints(rThisVar, origin_values, rCurrentProcessInfo); // We sum all the contributions for (unsigned int i_node = 0; i_node < rThisGeometry.size(); ++i_node) { @@ -609,7 +609,7 @@ class KRATOS_API(MESHING_APPLICATION) InternalVariablesInterpolationProcess destination_value += N[i_node] * rThisGeometry[i_node].GetValue(rThisVar); std::vector values; - itElemDestination->GetValueOnIntegrationPoints(rThisVar, values, rCurrentProcessInfo); + itElemDestination->CalculateOnIntegrationPoints(rThisVar, values, rCurrentProcessInfo); values[GaussPointId] = destination_value; itElemDestination->SetValuesOnIntegrationPoints(rThisVar, values, rCurrentProcessInfo); } diff --git a/applications/MeshingApplication/custom_utilities/local_refine_geometry_mesh.cpp b/applications/MeshingApplication/custom_utilities/local_refine_geometry_mesh.cpp index eb72dc547dcd..6526f476f1e8 100644 --- a/applications/MeshingApplication/custom_utilities/local_refine_geometry_mesh.cpp +++ b/applications/MeshingApplication/custom_utilities/local_refine_geometry_mesh.cpp @@ -470,7 +470,7 @@ namespace Kratos { // NOTE: Right now there is not an interpolation at all, it just copying the values std::vector values; - father_elem->GetValueOnIntegrationPoints(INTERNAL_VARIABLES, values, rCurrentProcessInfo); + father_elem->CalculateOnIntegrationPoints(INTERNAL_VARIABLES, values, rCurrentProcessInfo); child_elem->SetValuesOnIntegrationPoints(INTERNAL_VARIABLES, values, rCurrentProcessInfo); } diff --git a/applications/MeshingApplication/tests/cpp_tests/test_internal_interpolation_process.cpp b/applications/MeshingApplication/tests/cpp_tests/test_internal_interpolation_process.cpp index a342793a427c..10d28a6feaa2 100644 --- a/applications/MeshingApplication/tests/cpp_tests/test_internal_interpolation_process.cpp +++ b/applications/MeshingApplication/tests/cpp_tests/test_internal_interpolation_process.cpp @@ -522,7 +522,7 @@ namespace Kratos // Getting the this_var std::vector detF0_vector(integration_points_number); const auto& this_var = KratosComponents>::Get("REFERENCE_DEFORMATION_GRADIENT_DETERMINANT"); - elem.GetValueOnIntegrationPoints(this_var,detF0_vector,current_process_info); + elem.CalculateOnIntegrationPoints(this_var,detF0_vector,current_process_info); for (std::size_t i = 0; i detF0_vector(integration_points_number); const auto& this_var = KratosComponents>::Get("REFERENCE_DEFORMATION_GRADIENT_DETERMINANT"); - elem.GetValueOnIntegrationPoints(this_var,detF0_vector,current_process_info); + elem.CalculateOnIntegrationPoints(this_var,detF0_vector,current_process_info); for (std::size_t i = 0; i detF0_vector(integration_points_number); const auto& this_var = KratosComponents>::Get("REFERENCE_DEFORMATION_GRADIENT_DETERMINANT"); - elem.GetValueOnIntegrationPoints(this_var,detF0_vector,current_process_info); + elem.CalculateOnIntegrationPoints(this_var,detF0_vector,current_process_info); for (std::size_t i = 0; i detF0_vector(integration_points_number); const auto& this_var = KratosComponents>::Get("REFERENCE_DEFORMATION_GRADIENT_DETERMINANT"); - elem.GetValueOnIntegrationPoints(this_var,detF0_vector,current_process_info); + elem.CalculateOnIntegrationPoints(this_var,detF0_vector,current_process_info); for (std::size_t i = 0; i Date: Tue, 28 Apr 2020 07:31:11 +0200 Subject: [PATCH 268/314] applying codacy changes --- .../python_scripts/cfl_output_process.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/applications/FluidDynamicsApplication/python_scripts/cfl_output_process.py b/applications/FluidDynamicsApplication/python_scripts/cfl_output_process.py index 1558b5adb3cd..2e0041910eab 100755 --- a/applications/FluidDynamicsApplication/python_scripts/cfl_output_process.py +++ b/applications/FluidDynamicsApplication/python_scripts/cfl_output_process.py @@ -13,7 +13,7 @@ msg += " Please install/compile it and try again." raise Exception(msg) -from math import pow, sqrt +from math import sqrt def Factory(settings, model): @@ -166,8 +166,8 @@ def _CalculateWithRespectToThreshold(self): y_std = 0.0 # qunatifying the global max - # TODO: @Mate, where should we put the id of the element, where max is? - x_max, max_id = current_container.Max(self.model_part, KratosMultiphysics.CFL_NUMBER, "value") + # TODO: @Mate, where should we put the id of the element, where max is (second bland output argument is max_id)? + x_max, _ = current_container.Max(self.model_part, KratosMultiphysics.CFL_NUMBER, "value") return [y_mean, y_std, x_max, how_many, how_many1] def _EvaluateCFL(self): From 6f27eac7b48dd0d5026ee4d1f42c026117e49237 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Tue, 28 Apr 2020 07:31:20 +0200 Subject: [PATCH 269/314] adding skip test --- .../FluidDynamicsApplication/tests/cfl_output_process_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/FluidDynamicsApplication/tests/cfl_output_process_test.py b/applications/FluidDynamicsApplication/tests/cfl_output_process_test.py index cf33765d980c..3001346683d4 100644 --- a/applications/FluidDynamicsApplication/tests/cfl_output_process_test.py +++ b/applications/FluidDynamicsApplication/tests/cfl_output_process_test.py @@ -1,5 +1,4 @@ import KratosMultiphysics as km -import KratosMultiphysics.FluidDynamicsApplication as kfd from fluid_analysis_without_solution import FluidAnalysisWithoutSolution @@ -12,6 +11,7 @@ def setUp(self): # Set to true to get post-process files for the test self.print_output = True + @UnitTest.skipIfApplicationsNotAvailable("StatisticsApplication") def testCFLOutput(self): work_folder = "Cavity" settings_file_name = "cfl_output_test_parameters.json" From 07e7851be3930c63f874048b0c71d7b43ed0696e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20Irazabal?= Date: Tue, 28 Apr 2020 09:01:49 +0200 Subject: [PATCH 270/314] Changes suggested by jsanmauro --- .../custom_constitutive/simplified_bilinear_2D_law.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_2D_law.cpp b/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_2D_law.cpp index 3e581159b38b..1a55191189eb 100644 --- a/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_2D_law.cpp +++ b/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_2D_law.cpp @@ -27,7 +27,7 @@ void SimplifiedBilinear2DLaw::ComputeEquivalentStrain(ConstitutiveLawVariables& rVariables.EquivalentStrain = 1.0; if (mStateVariable == 1.0) { - if((StrainVector[0] * rVariables.YieldStress) > rVariables.MaxTensileStress) + if(fabs(StrainVector[0] * rVariables.YieldStress) > rVariables.MaxTensileStress) { rVariables.EquivalentStrain = 0.0; } @@ -43,7 +43,7 @@ void SimplifiedBilinear2DLaw::ComputeEquivalentStrain(ConstitutiveLawVariables& rVariables.EquivalentStrain = 1.0; if (mStateVariable == 1.0) { - if((StrainVector[0] * rVariables.YieldStress) > rVariables.MaxTensileStress) + if(fabs(StrainVector[0] * rVariables.YieldStress) > rVariables.MaxTensileStress) { rVariables.EquivalentStrain = 0.0; } @@ -138,10 +138,10 @@ const Vector& StrainVector = rValues.GetStrainVector(); rStressVector[1] = rVariables.YoungModulus * StrainVector[1]; - const double shear_modulus = rVariables.YoungModulus / (2.0 * (1.0 + rVariables.PoissonCoefficient)); + const double shear_modulus = rVariables.YieldStress / (2.0 * (1.0 + rVariables.PoissonCoefficient)); double friction_stress = fabs(shear_modulus * StrainVector[0]); - double max_friction_stress = fabs(rVariables.FrictionCoefficient * rStressVector[2] * StrainVector[0]); + double max_friction_stress = fabs(rVariables.FrictionCoefficient * rStressVector[1]); if (friction_stress > max_friction_stress) friction_stress = max_friction_stress; const double eps = std::numeric_limits::epsilon(); From 55ab651eea8184e23033ab4d787ee4054fd04612 Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Tue, 28 Apr 2020 10:03:31 +0200 Subject: [PATCH 271/314] fix 1 --- kratos/python_scripts/kratos_utilities.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kratos/python_scripts/kratos_utilities.py b/kratos/python_scripts/kratos_utilities.py index 2f17cae954f8..a0e16faad993 100644 --- a/kratos/python_scripts/kratos_utilities.py +++ b/kratos/python_scripts/kratos_utilities.py @@ -61,7 +61,7 @@ def CheckIfApplicationsAvailable(*application_names): available_apps = GetListOfAvailableApplications() return all(app_name in available_apps for app_name in application_names) -def GetNotAvailableApplications(*application_names): +def GetNotAvailableApplications(application_names): """Returns a list of applications that are not available out of a provided list of applications """ available_apps = GetListOfAvailableApplications() From 5836fb787e93136e69223d4cc9f47a6ec9862bcd Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Tue, 28 Apr 2020 10:10:29 +0200 Subject: [PATCH 272/314] update skip test method --- kratos/python_scripts/KratosUnittest.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kratos/python_scripts/KratosUnittest.py b/kratos/python_scripts/KratosUnittest.py index c0591a6b9fa8..f11c70b2662a 100644 --- a/kratos/python_scripts/KratosUnittest.py +++ b/kratos/python_scripts/KratosUnittest.py @@ -106,10 +106,8 @@ def GetValErrMsg(idx_1, idx_2): def skipIfApplicationsNotAvailable(*application_names): '''Skips the test if required applications are not available''' required_but_not_available_apps = GetNotAvailableApplications(application_names) - if len(required_but_not_available_apps) > 0: - reason_for_skip = 'Required Applications are missing: {}'.format('", "'.join(*required_but_not_available_apps)) - return skip(reason_for_skip) - return _id + reason_for_skip = 'Required Applications are missing: {}'.format('", "'.join(required_but_not_available_apps)) + return skipIf(len(required_but_not_available_apps) > 0, reason_for_skip) @contextmanager From ed17abd6cc13791f2b04c40f53b76b5885849f79 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Tue, 28 Apr 2020 10:21:38 +0200 Subject: [PATCH 273/314] remove cfl test from existing tests --- .../CylinderTest/cylinder_cfl_results_ref.dat | 13 --------- .../cylinder_fluid_parameters.json | 28 +------------------ 2 files changed, 1 insertion(+), 40 deletions(-) delete mode 100644 applications/FluidDynamicsApplication/tests/CylinderTest/cylinder_cfl_results_ref.dat diff --git a/applications/FluidDynamicsApplication/tests/CylinderTest/cylinder_cfl_results_ref.dat b/applications/FluidDynamicsApplication/tests/CylinderTest/cylinder_cfl_results_ref.dat deleted file mode 100644 index ce21203819b1..000000000000 --- a/applications/FluidDynamicsApplication/tests/CylinderTest/cylinder_cfl_results_ref.dat +++ /dev/null @@ -1,13 +0,0 @@ -# CFL for model part MainModelPart| CFL_threshold: 2.5 -# Time Mean Std Max HowMany>2.5 [%] HowMany>1.0 [%] -0.1 0.29588124 0.35689410 2.75039835 0.19333011 3.96326728 -0.2 0.29686301 0.36170507 2.81354315 0.24166264 4.20492992 -0.30000000000000004 0.29571495 0.35894916 2.64283904 0.14499758 4.01159981 -0.4 0.29490276 0.35790661 2.56049176 0.09666506 3.76993717 -0.5 0.29400445 0.35716871 2.51102848 0.04833253 3.76993717 -0.6 0.29323587 0.35691373 2.47139126 0.00000000 3.67327211 -0.7 0.29152600 0.35400192 2.43810179 0.00000000 3.52827453 -0.7999999999999999 0.29002522 0.35148712 2.40913406 0.00000000 3.52827453 -0.8999999999999999 0.28875351 0.34923909 2.38321330 0.00000000 3.52827453 -0.9999999999999999 0.28768492 0.34722511 2.35954195 0.00000000 3.57660706 -1.0999999999999999 0.28686749 0.34536798 2.33763994 0.00000000 3.47994200 diff --git a/applications/FluidDynamicsApplication/tests/CylinderTest/cylinder_fluid_parameters.json b/applications/FluidDynamicsApplication/tests/CylinderTest/cylinder_fluid_parameters.json index 53aee7d5e69d..13adafdc22ef 100644 --- a/applications/FluidDynamicsApplication/tests/CylinderTest/cylinder_fluid_parameters.json +++ b/applications/FluidDynamicsApplication/tests/CylinderTest/cylinder_fluid_parameters.json @@ -141,21 +141,7 @@ "print_drag_to_screen" : true, "interval" : [0.0,"End"] } - },{ - "python_module" : "cfl_output_process", - "kratos_module" : "KratosMultiphysics.FluidDynamicsApplication", - "process_name" : "CFLOutputProcess", - "Parameters" : { - "model_part_name" : "MainModelPart", - "write_output_file" : true, - "print_to_screen" : true, - "cfl_output_limit" : 2.5, - "interval" : [0.0,"End"], - "output_step" : 1, - "output_file_settings" : { - "file_name": "cylinder_cfl_results" - }} - }, + }, { "python_module" : "compare_two_files_check_process", "kratos_module" : "KratosMultiphysics", @@ -192,18 +178,6 @@ "remove_output_file" : true, "tolerance" : 1e-5 } - },{ - "python_module" : "compare_two_files_check_process", - "kratos_module" : "KratosMultiphysics", - "help" : "", - "process_name" : "CompareTwoFilesCheckProcess", - "Parameters" :{ - "output_file_name" : "cylinder_cfl_results.dat", - "reference_file_name" : "cylinder_cfl_results_ref.dat", - "comparison_type" : "dat_file", - "remove_output_file" : true, - "tolerance" : 1e-5 - } }] } } From 328fe2edc8033e4768123f79ae0f71548adef7a0 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Tue, 28 Apr 2020 10:21:56 +0200 Subject: [PATCH 274/314] adding additional cfl output test --- .../tests/test_FluidDynamicsApplication.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/applications/FluidDynamicsApplication/tests/test_FluidDynamicsApplication.py b/applications/FluidDynamicsApplication/tests/test_FluidDynamicsApplication.py index a54e42e2b54a..4c28a471b853 100644 --- a/applications/FluidDynamicsApplication/tests/test_FluidDynamicsApplication.py +++ b/applications/FluidDynamicsApplication/tests/test_FluidDynamicsApplication.py @@ -28,6 +28,7 @@ from adjoint_vms_sensitivity_2d import AdjointVMSSensitivity2D from hdf5_io_test import HDF5IOTest from test_statistics_process import IntegrationPointStatisticsTest +from cfl_output_process_test import CFLOutputProcessTest def AssembleTestSuites(): ''' Populates the test suites to run. @@ -99,6 +100,7 @@ def AssembleTestSuites(): nightSuite.addTest(FluidAnalysisTest('testSteadyCavity')) nightSuite.addTest(FluidAnalysisTest('testSteadyCylinder')) nightSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([IntegrationPointStatisticsTest])) + nightSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([CFLOutputProcessTest])) # For very long tests that should not be in nighly and you can use to validate From 2ab871b7e922f3a07e1a0f5d64046100108e0e0d Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Tue, 28 Apr 2020 10:29:49 +0200 Subject: [PATCH 275/314] Update kratos/python_scripts/KratosUnittest.py Co-Authored-By: Philipp Bucher --- kratos/python_scripts/KratosUnittest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kratos/python_scripts/KratosUnittest.py b/kratos/python_scripts/KratosUnittest.py index f11c70b2662a..dbaf6bc475d6 100644 --- a/kratos/python_scripts/KratosUnittest.py +++ b/kratos/python_scripts/KratosUnittest.py @@ -105,7 +105,7 @@ def GetValErrMsg(idx_1, idx_2): def skipIfApplicationsNotAvailable(*application_names): '''Skips the test if required applications are not available''' - required_but_not_available_apps = GetNotAvailableApplications(application_names) + required_but_not_available_apps = GetNotAvailableApplications(*application_names) reason_for_skip = 'Required Applications are missing: {}'.format('", "'.join(required_but_not_available_apps)) return skipIf(len(required_but_not_available_apps) > 0, reason_for_skip) From 8518679f249d687cffc7bdda16bf17689bc63d0e Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Tue, 28 Apr 2020 10:31:17 +0200 Subject: [PATCH 276/314] revert change --- kratos/python_scripts/kratos_utilities.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kratos/python_scripts/kratos_utilities.py b/kratos/python_scripts/kratos_utilities.py index a0e16faad993..2f17cae954f8 100644 --- a/kratos/python_scripts/kratos_utilities.py +++ b/kratos/python_scripts/kratos_utilities.py @@ -61,7 +61,7 @@ def CheckIfApplicationsAvailable(*application_names): available_apps = GetListOfAvailableApplications() return all(app_name in available_apps for app_name in application_names) -def GetNotAvailableApplications(application_names): +def GetNotAvailableApplications(*application_names): """Returns a list of applications that are not available out of a provided list of applications """ available_apps = GetListOfAvailableApplications() From 9279696c83f6f59a607f07414400c064692afc28 Mon Sep 17 00:00:00 2001 From: Philipp Bucher Date: Tue, 28 Apr 2020 10:32:33 +0200 Subject: [PATCH 277/314] adding ProcessInfo --- .../python_scripts/base_classes/co_simulation_coupled_solver.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/applications/CoSimulationApplication/python_scripts/base_classes/co_simulation_coupled_solver.py b/applications/CoSimulationApplication/python_scripts/base_classes/co_simulation_coupled_solver.py index 503a632efbc3..fbf6127f38f4 100644 --- a/applications/CoSimulationApplication/python_scripts/base_classes/co_simulation_coupled_solver.py +++ b/applications/CoSimulationApplication/python_scripts/base_classes/co_simulation_coupled_solver.py @@ -49,6 +49,8 @@ def __init__(self, settings, solver_name): super(CoSimulationCoupledSolver, self).__init__(settings, solver_name) + self.process_info = KM.ProcessInfo() + self.solver_wrappers = self.__CreateSolverWrappers() self.coupling_sequence = self.__GetSolverCoSimulationDetails() From 6e576039ec9498543066fd651a45a46ed9fc9206 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20Irazabal?= Date: Tue, 28 Apr 2020 13:20:54 +0200 Subject: [PATCH 278/314] Avoid the creation additional ConstitutiveLawVariables struct --- .../bilinear_cohesive_3D_law.hpp | 3 +++ .../simplified_bilinear_3D_law.hpp | 20 ------------------- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/applications/PoromechanicsApplication/custom_constitutive/bilinear_cohesive_3D_law.hpp b/applications/PoromechanicsApplication/custom_constitutive/bilinear_cohesive_3D_law.hpp index ffd420b7b14d..938abf04be9c 100644 --- a/applications/PoromechanicsApplication/custom_constitutive/bilinear_cohesive_3D_law.hpp +++ b/applications/PoromechanicsApplication/custom_constitutive/bilinear_cohesive_3D_law.hpp @@ -86,8 +86,11 @@ class KRATOS_API(POROMECHANICS_APPLICATION) BilinearCohesive3DLaw : public Const double DamageThreshold; double YieldStress; double YoungModulus; + double PoissonCoefficient; double FrictionCoefficient; double PenaltyStiffness; + double MaxTensileStress; + double MaxCompresiveStress; Matrix CompressionMatrix; Matrix WeightMatrix; diff --git a/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_3D_law.hpp b/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_3D_law.hpp index 8eb3def8351b..f5431a23aa3f 100644 --- a/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_3D_law.hpp +++ b/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_3D_law.hpp @@ -74,27 +74,7 @@ class KRATOS_API(POROMECHANICS_APPLICATION) SimplifiedBilinear3DLaw : public Bil protected: -protected: - - struct ConstitutiveLawVariables - { - double YieldStress; - double YoungModulus; - double MaxTensileStress; - double MaxCompresiveStress; - double PoissonCoefficient; - double FrictionCoefficient; - - Matrix CompressionMatrix; - Matrix WeightMatrix; - - double EquivalentStrain; - bool LoadingFlag; - double LoadingFunction; - }; - // Member Variables - double mStateVariable; //---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- From c65b324d9c0dbbf527779bad4d6a6d6f4e49e84f Mon Sep 17 00:00:00 2001 From: philbucher Date: Tue, 28 Apr 2020 13:46:47 +0200 Subject: [PATCH 279/314] minor corrections --- kratos/python_scripts/KratosUnittest.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kratos/python_scripts/KratosUnittest.py b/kratos/python_scripts/KratosUnittest.py index dbaf6bc475d6..7258dff1890a 100644 --- a/kratos/python_scripts/KratosUnittest.py +++ b/kratos/python_scripts/KratosUnittest.py @@ -37,9 +37,9 @@ def run(self, result=None): def skipTestIfApplicationsNotAvailable(self, *application_names): '''Skips the test if required applications are not available''' - required_but_not_available_apps = GetNotAvailableApplications(application_names) + required_but_not_available_apps = GetNotAvailableApplications(*application_names) if len(required_but_not_available_apps) > 0: - self.skipTest('Required Applications are missing: {}'.format('", "'.join(*required_but_not_available_apps))) + self.skipTest('Required Applications are missing: "{}"'.format('", "'.join(required_but_not_available_apps))) def assertEqualTolerance(self, first, second, tolerance, msg=None): ''' Fails if first and second have a difference greater than @@ -106,7 +106,7 @@ def GetValErrMsg(idx_1, idx_2): def skipIfApplicationsNotAvailable(*application_names): '''Skips the test if required applications are not available''' required_but_not_available_apps = GetNotAvailableApplications(*application_names) - reason_for_skip = 'Required Applications are missing: {}'.format('", "'.join(required_but_not_available_apps)) + reason_for_skip = 'Required Applications are missing: "{}"'.format('", "'.join(required_but_not_available_apps)) return skipIf(len(required_but_not_available_apps) > 0, reason_for_skip) From eb545945025823c093e5b2c1fb65676c2e72da74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Tue, 28 Apr 2020 14:31:59 +0200 Subject: [PATCH 280/314] Revert KM. --- kratos/tests/test_linear_constraints.py | 254 ++++++++++++------------ 1 file changed, 127 insertions(+), 127 deletions(-) diff --git a/kratos/tests/test_linear_constraints.py b/kratos/tests/test_linear_constraints.py index b5f22d774b1d..317473ad3404 100644 --- a/kratos/tests/test_linear_constraints.py +++ b/kratos/tests/test_linear_constraints.py @@ -1,7 +1,7 @@ from __future__ import print_function, absolute_import, division # Importing the Kratos Library -import KratosMultiphysics as KM +import KratosMultiphysics import KratosMultiphysics.KratosUnittest as KratosUnittest import KratosMultiphysics.kratos_utilities as KratosUtils import math @@ -20,76 +20,76 @@ def setUp(self): pass def _add_variables(self): - self.mp.AddNodalSolutionStepVariable(KM.DISPLACEMENT) - self.mp.AddNodalSolutionStepVariable(KM.REACTION) - self.mp.AddNodalSolutionStepVariable(KM.VELOCITY) - self.mp.AddNodalSolutionStepVariable(KM.ACCELERATION) - self.mp.AddNodalSolutionStepVariable(KM.VOLUME_ACCELERATION) + self.mp.AddNodalSolutionStepVariable(KratosMultiphysics.DISPLACEMENT) + self.mp.AddNodalSolutionStepVariable(KratosMultiphysics.REACTION) + self.mp.AddNodalSolutionStepVariable(KratosMultiphysics.VELOCITY) + self.mp.AddNodalSolutionStepVariable(KratosMultiphysics.ACCELERATION) + self.mp.AddNodalSolutionStepVariable(KratosMultiphysics.VOLUME_ACCELERATION) def _add_dofs(self): - KM.VariableUtils().AddDof(KM.DISPLACEMENT_X, KM.REACTION_X, self.mp) - KM.VariableUtils().AddDof(KM.DISPLACEMENT_Y, KM.REACTION_Y, self.mp) - KM.VariableUtils().AddDof(KM.DISPLACEMENT_Z, KM.REACTION_Z, self.mp) + KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.DISPLACEMENT_X, KratosMultiphysics.REACTION_X, self.mp) + KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.DISPLACEMENT_Y, KratosMultiphysics.REACTION_Y, self.mp) + KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.DISPLACEMENT_Z, KratosMultiphysics.REACTION_Z, self.mp) - KM.VariableUtils().AddDof(KM.VELOCITY_X, self.mp) - KM.VariableUtils().AddDof(KM.VELOCITY_Y, self.mp) - KM.VariableUtils().AddDof(KM.VELOCITY_Z, self.mp) + KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.VELOCITY_X, self.mp) + KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.VELOCITY_Y, self.mp) + KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.VELOCITY_Z, self.mp) - KM.VariableUtils().AddDof(KM.ACCELERATION_X, self.mp) - KM.VariableUtils().AddDof(KM.ACCELERATION_Y, self.mp) - KM.VariableUtils().AddDof(KM.ACCELERATION_Z, self.mp) + KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.ACCELERATION_X, self.mp) + KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.ACCELERATION_Y, self.mp) + KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.ACCELERATION_Z, self.mp) def _apply_material_properties(self, dim): #define properties - self.mp.GetProperties()[1].SetValue(KM.YOUNG_MODULUS, 210e9) - self.mp.GetProperties()[1].SetValue(KM.POISSON_RATIO, 0.3) - self.mp.GetProperties()[1].SetValue(KM.THICKNESS, 1.0) - self.mp.GetProperties()[1].SetValue(KM.DENSITY, 1.0) + self.mp.GetProperties()[1].SetValue(KratosMultiphysics.YOUNG_MODULUS, 210e9) + self.mp.GetProperties()[1].SetValue(KratosMultiphysics.POISSON_RATIO, 0.3) + self.mp.GetProperties()[1].SetValue(KratosMultiphysics.THICKNESS, 1.0) + self.mp.GetProperties()[1].SetValue(KratosMultiphysics.DENSITY, 1.0) g = [0, 0, 0] - self.mp.GetProperties()[1].SetValue(KM.VOLUME_ACCELERATION, g) + self.mp.GetProperties()[1].SetValue(KratosMultiphysics.VOLUME_ACCELERATION, g) - self.mp.ProcessInfo[KM.DOMAIN_SIZE] = dim + self.mp.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE] = dim if dim == 2: cl = SMA.LinearElasticPlaneStrain2DLaw() else: cl = SMA.LinearElastic3DLaw() - self.mp.GetProperties()[1].SetValue(KM.CONSTITUTIVE_LAW, cl) + self.mp.GetProperties()[1].SetValue(KratosMultiphysics.CONSTITUTIVE_LAW, cl) def _apply_BCs(self): bcs = self.mp.GetSubModelPart("FixedEdgeNodes") - KM.VariableUtils().SetVariable(KM.DISPLACEMENT_X, 0.0, bcs.Nodes) - KM.VariableUtils().SetVariable(KM.DISPLACEMENT_Y, 0.0, bcs.Nodes) + KratosMultiphysics.VariableUtils().SetVariable(KratosMultiphysics.DISPLACEMENT_X, 0.0, bcs.Nodes) + KratosMultiphysics.VariableUtils().SetVariable(KratosMultiphysics.DISPLACEMENT_Y, 0.0, bcs.Nodes) - KM.VariableUtils().ApplyFixity(KM.DISPLACEMENT_X, True, bcs.Nodes) - KM.VariableUtils().ApplyFixity(KM.DISPLACEMENT_Y, True, bcs.Nodes) + KratosMultiphysics.VariableUtils().ApplyFixity(KratosMultiphysics.DISPLACEMENT_X, True, bcs.Nodes) + KratosMultiphysics.VariableUtils().ApplyFixity(KratosMultiphysics.DISPLACEMENT_Y, True, bcs.Nodes) bcmn = self.mp.GetSubModelPart("MovingNodes") - KM.VariableUtils().SetVariable(KM.DISPLACEMENT_X, 0.01, bcmn.Nodes) - KM.VariableUtils().SetVariable(KM.DISPLACEMENT_Y, 0.0, bcmn.Nodes) - KM.VariableUtils().ApplyFixity(KM.DISPLACEMENT_X, True, bcmn.Nodes) - KM.VariableUtils().ApplyFixity(KM.DISPLACEMENT_Y, True, bcmn.Nodes) + KratosMultiphysics.VariableUtils().SetVariable(KratosMultiphysics.DISPLACEMENT_X, 0.01, bcmn.Nodes) + KratosMultiphysics.VariableUtils().SetVariable(KratosMultiphysics.DISPLACEMENT_Y, 0.0, bcmn.Nodes) + KratosMultiphysics.VariableUtils().ApplyFixity(KratosMultiphysics.DISPLACEMENT_X, True, bcmn.Nodes) + KratosMultiphysics.VariableUtils().ApplyFixity(KratosMultiphysics.DISPLACEMENT_Y, True, bcmn.Nodes) def _setup_solver(self, solving_with = "Block", linear_solver = "AMGCL"): #define a minimal newton raphson solver if linear_solver == "AMGCL": - self.linear_solver = KM.AMGCLSolver() + self.linear_solver = KratosMultiphysics.AMGCLSolver() else: - self.linear_solver = KM.SkylineLUFactorizationSolver() + self.linear_solver = KratosMultiphysics.SkylineLUFactorizationSolver() if solving_with == "Block": - self.builder_and_solver = KM.ResidualBasedBlockBuilderAndSolver(self.linear_solver) + self.builder_and_solver = KratosMultiphysics.ResidualBasedBlockBuilderAndSolver(self.linear_solver) else: # Block default - self.builder_and_solver = KM.ResidualBasedBlockBuilderAndSolver(self.linear_solver) - self.scheme = KM.ResidualBasedBossakDisplacementScheme(-0.01) - self.convergence_criterion = KM.ResidualCriteria(1e-6, 1e-9) + self.builder_and_solver = KratosMultiphysics.ResidualBasedBlockBuilderAndSolver(self.linear_solver) + self.scheme = KratosMultiphysics.ResidualBasedBossakDisplacementScheme(-0.01) + self.convergence_criterion = KratosMultiphysics.ResidualCriteria(1e-6, 1e-9) self.convergence_criterion.SetEchoLevel(0) max_iters = 10 compute_reactions = True reform_step_dofs = True move_mesh_flag = False - self.strategy = KM.ResidualBasedNewtonRaphsonStrategy(self.mp, self.scheme, self.linear_solver, self.convergence_criterion, self.builder_and_solver, max_iters, compute_reactions, reform_step_dofs, move_mesh_flag) + self.strategy = KratosMultiphysics.ResidualBasedNewtonRaphsonStrategy(self.mp, self.scheme, self.linear_solver, self.convergence_criterion, self.builder_and_solver, max_iters, compute_reactions, reform_step_dofs, move_mesh_flag) self.strategy.SetEchoLevel(0) self.strategy.Initialize() @@ -106,93 +106,93 @@ def _solve(self): self.strategy.Solve() def _basic_check_results(self): - reactionx1 = self.mp.Nodes[1].GetSolutionStepValue(KM.REACTION_X, 0) + reactionx1 = self.mp.Nodes[1].GetSolutionStepValue(KratosMultiphysics.REACTION_X, 0) self.assertLessEqual(abs((reactionx1 - -1413464323.8223937)/(-1413464323.8223937)), 1.0e-2) - reactiony1 = self.mp.Nodes[1].GetSolutionStepValue(KM.REACTION_Y, 0) + reactiony1 = self.mp.Nodes[1].GetSolutionStepValue(KratosMultiphysics.REACTION_Y, 0) self.assertLessEqual(abs((reactiony1 - -605769230.7692306)/(-605769230.7692306)), 1.0e-2) - reactionx4 = self.mp.Nodes[4].GetSolutionStepValue(KM.REACTION_X, 0) + reactionx4 = self.mp.Nodes[4].GetSolutionStepValue(KratosMultiphysics.REACTION_X, 0) self.assertLessEqual(abs((reactionx4 - -1413467109.1832492)/(-1413467109.1832492)), 1.0e-2) - reactiony4 = self.mp.Nodes[4].GetSolutionStepValue(KM.REACTION_Y, 0) + reactiony4 = self.mp.Nodes[4].GetSolutionStepValue(KratosMultiphysics.REACTION_Y, 0) self.assertLessEqual(abs((reactiony4 - 605769230.7692306)/(605769230.7692306)), 1.0e-2) - dispx3 = self.mp.Nodes[3].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) + dispx3 = self.mp.Nodes[3].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) self.assertAlmostEqual(dispx3, 0.01, 4) - dispy3 = self.mp.Nodes[3].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) + dispy3 = self.mp.Nodes[3].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) self.assertAlmostEqual(dispy3, 0.0, 4) - dispx2 = self.mp.Nodes[2].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) + dispx2 = self.mp.Nodes[2].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) self.assertAlmostEqual(dispx2, 0.01, 4) - dispy2 = self.mp.Nodes[2].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) + dispy2 = self.mp.Nodes[2].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) self.assertAlmostEqual(dispy2, 0.0, 4) - dispx3 = self.mp.Nodes[3].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) + dispx3 = self.mp.Nodes[3].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) self.assertAlmostEqual(dispx3, 0.01, 4) - dispy3 = self.mp.Nodes[3].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) + dispy3 = self.mp.Nodes[3].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) self.assertAlmostEqual(dispy3, 0.0, 4) def _advanced_check_results(self): - dispx13 = self.mp.Nodes[13].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) + dispx13 = self.mp.Nodes[13].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) self.assertAlmostEqual(dispx13, 0.01, 4) - dispy13 = self.mp.Nodes[13].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) + dispy13 = self.mp.Nodes[13].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) self.assertAlmostEqual(dispy13, 0.0, 4) - dispx14 = self.mp.Nodes[14].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) + dispx14 = self.mp.Nodes[14].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) self.assertAlmostEqual(dispx14, 0.01, 4) - dispy14 = self.mp.Nodes[14].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) + dispy14 = self.mp.Nodes[14].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) self.assertAlmostEqual(dispy14, 0.0, 4) - dispx15 = self.mp.Nodes[15].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) + dispx15 = self.mp.Nodes[15].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) self.assertAlmostEqual(dispx15, 0.01, 4) - dispy15 = self.mp.Nodes[15].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) + dispy15 = self.mp.Nodes[15].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) self.assertAlmostEqual(dispy15, 0.0, 4) - dispx11 = self.mp.Nodes[11].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) + dispx11 = self.mp.Nodes[11].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) self.assertAlmostEqual(dispx11, 0.0077238, 4) - dispy11 = self.mp.Nodes[11].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) + dispy11 = self.mp.Nodes[11].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) self.assertAlmostEqual(dispy11, 0.0, 4) - dispx4 = self.mp.Nodes[4].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) + dispx4 = self.mp.Nodes[4].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) self.assertAlmostEqual(dispx4, 0.0022754, 4) - dispy4 = self.mp.Nodes[4].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) + dispy4 = self.mp.Nodes[4].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) self.assertAlmostEqual(dispy4, 0.0, 4) - disp1 = self.mp.Nodes[16].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) - disp2 = self.mp.Nodes[6].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) + disp1 = self.mp.Nodes[16].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) + disp2 = self.mp.Nodes[6].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) self.assertAlmostEqual(disp1, disp2, 4) self.assertAlmostEqual(disp1, 0.0049994, 4) self.assertAlmostEqual(disp2, 0.0049994, 4) #print("Test 1 :: ", disp1," == ",disp2) - disp1 = self.mp.Nodes[16].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) - disp2 = self.mp.Nodes[6].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) + disp1 = self.mp.Nodes[16].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) + disp2 = self.mp.Nodes[6].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) self.assertAlmostEqual(disp1, disp2, 5) self.assertAlmostEqual(disp1, -0.0011584, 4) self.assertAlmostEqual(disp1, -0.0011584, 4) #print("Test 2 :: ", disp1," == ",disp2) - disp1 = self.mp.Nodes[7].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) - disp2 = self.mp.Nodes[17].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) + disp1 = self.mp.Nodes[7].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) + disp2 = self.mp.Nodes[17].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) self.assertAlmostEqual(disp1, disp2, 4) self.assertAlmostEqual(disp1, 0.0049994, 4) self.assertAlmostEqual(disp2, 0.0049994, 4) #print("Test 3 :: ", disp1," == ",disp2) - disp1 = self.mp.Nodes[7].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) - disp2 = self.mp.Nodes[17].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) + disp1 = self.mp.Nodes[7].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) + disp2 = self.mp.Nodes[17].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) self.assertAlmostEqual(disp1, disp2, 4) #print("Test 4 :: ", disp1," == ",disp2) - disp1 = self.mp.Nodes[18].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) - disp2 = self.mp.Nodes[9].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) + disp1 = self.mp.Nodes[18].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) + disp2 = self.mp.Nodes[9].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) self.assertAlmostEqual(disp1, disp2, 4) self.assertAlmostEqual(disp1, 0.0049994, 4) self.assertAlmostEqual(disp1, 0.0049994, 4) #print("Test 5 :: ", disp1," == ",disp2) - disp1 = self.mp.Nodes[18].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) - disp2 = self.mp.Nodes[9].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) + disp1 = self.mp.Nodes[18].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) + disp2 = self.mp.Nodes[9].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) self.assertAlmostEqual(disp1, disp2, 4) self.assertAlmostEqual(disp1, 0.0011584, 4) self.assertAlmostEqual(disp1, 0.0011584, 4) @@ -254,42 +254,42 @@ def _advanced_setup_model_part(self): self.mp.CreateNewElement("SmallDisplacementElement2D4N", 8, [8, 9, 7, 4], self.mp.GetProperties()[1]) def _basic_apply_mpc_constraints(self): - self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 1, self.mp.Nodes[2], KM.DISPLACEMENT_X, self.mp.Nodes[3], KM.DISPLACEMENT_X, 1.0, 0) - self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 2, self.mp.Nodes[2], KM.DISPLACEMENT_Y, self.mp.Nodes[3], KM.DISPLACEMENT_Y, 1.0, 0) + self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 1, self.mp.Nodes[2], KratosMultiphysics.DISPLACEMENT_X, self.mp.Nodes[3], KratosMultiphysics.DISPLACEMENT_X, 1.0, 0) + self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 2, self.mp.Nodes[2], KratosMultiphysics.DISPLACEMENT_Y, self.mp.Nodes[3], KratosMultiphysics.DISPLACEMENT_Y, 1.0, 0) def _advanced_apply_mpc_constraints(self): - self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 2, self.mp.Nodes[16], KM.DISPLACEMENT_X, self.mp.Nodes[6], KM.DISPLACEMENT_X, 1.0, 0) - self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 1, self.mp.Nodes[16], KM.DISPLACEMENT_Y, self.mp.Nodes[6], KM.DISPLACEMENT_Y, 1.0, 0) + self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 2, self.mp.Nodes[16], KratosMultiphysics.DISPLACEMENT_X, self.mp.Nodes[6], KratosMultiphysics.DISPLACEMENT_X, 1.0, 0) + self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 1, self.mp.Nodes[16], KratosMultiphysics.DISPLACEMENT_Y, self.mp.Nodes[6], KratosMultiphysics.DISPLACEMENT_Y, 1.0, 0) - self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 3, self.mp.Nodes[17], KM.DISPLACEMENT_X, self.mp.Nodes[7], KM.DISPLACEMENT_X, 1.0, 0) - self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 4, self.mp.Nodes[17], KM.DISPLACEMENT_Y, self.mp.Nodes[7], KM.DISPLACEMENT_Y, 1.0, 0) + self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 3, self.mp.Nodes[17], KratosMultiphysics.DISPLACEMENT_X, self.mp.Nodes[7], KratosMultiphysics.DISPLACEMENT_X, 1.0, 0) + self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 4, self.mp.Nodes[17], KratosMultiphysics.DISPLACEMENT_Y, self.mp.Nodes[7], KratosMultiphysics.DISPLACEMENT_Y, 1.0, 0) - self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 5, self.mp.Nodes[18], KM.DISPLACEMENT_X, self.mp.Nodes[9], KM.DISPLACEMENT_X, 1.0, 0) - self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 6, self.mp.Nodes[18], KM.DISPLACEMENT_Y, self.mp.Nodes[9], KM.DISPLACEMENT_Y, 1.0, 0) + self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 5, self.mp.Nodes[18], KratosMultiphysics.DISPLACEMENT_X, self.mp.Nodes[9], KratosMultiphysics.DISPLACEMENT_X, 1.0, 0) + self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 6, self.mp.Nodes[18], KratosMultiphysics.DISPLACEMENT_Y, self.mp.Nodes[9], KratosMultiphysics.DISPLACEMENT_Y, 1.0, 0) def _set_and_fill_buffer(self, buffer_size, delta_time): # Set buffer size self.mp.SetBufferSize(buffer_size) # Fill buffer - time = self.mp.ProcessInfo[KM.TIME] + time = self.mp.ProcessInfo[KratosMultiphysics.TIME] time = time - delta_time * (buffer_size) - self.mp.ProcessInfo.SetValue(KM.TIME, time) + self.mp.ProcessInfo.SetValue(KratosMultiphysics.TIME, time) for size in range(0, buffer_size): step = size - (buffer_size - 1) - self.mp.ProcessInfo.SetValue(KM.STEP, step) + self.mp.ProcessInfo.SetValue(KratosMultiphysics.STEP, step) time = time + delta_time #delta_time is computed from previous time in process_info self.mp.CloneTimeStep(time) - self.mp.ProcessInfo[KM.IS_RESTARTED] = False + self.mp.ProcessInfo[KratosMultiphysics.IS_RESTARTED] = False def _basic_setup_test(self, solving_with = "Block", linear_solver = "AMGCL"): dim = 2 - current_model = KM.Model() + current_model = KratosMultiphysics.Model() self.mp= current_model.CreateModelPart("MainModelPart") - self.mp.ProcessInfo[KM.DOMAIN_SIZE] = dim + self.mp.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE] = dim self._add_variables() self._basic_setup_model_part() self._add_dofs() @@ -320,7 +320,7 @@ def _basic_setup_test(self, solving_with = "Block", linear_solver = "AMGCL"): def _advanced_setup_test(self, solving_with = "Block", linear_solver = "AMGCL"): dim = 2 - current_model = KM.Model() + current_model = KratosMultiphysics.Model() self.mp= current_model.CreateModelPart("MainModelPart") self._add_variables() self._advanced_setup_model_part() @@ -363,38 +363,38 @@ def setUp(self): pass def _add_variables(self,mp): - mp.AddNodalSolutionStepVariable(KM.DISPLACEMENT) - mp.AddNodalSolutionStepVariable(KM.REACTION) - mp.AddNodalSolutionStepVariable(KM.VOLUME_ACCELERATION) + mp.AddNodalSolutionStepVariable(KratosMultiphysics.DISPLACEMENT) + mp.AddNodalSolutionStepVariable(KratosMultiphysics.REACTION) + mp.AddNodalSolutionStepVariable(KratosMultiphysics.VOLUME_ACCELERATION) def _apply_material_properties(self, mp, dim, small_strain = True): #define properties - mp.GetProperties()[1].SetValue(KM.YOUNG_MODULUS,210) - mp.GetProperties()[1].SetValue(KM.POISSON_RATIO,0.3) - mp.GetProperties()[1].SetValue(KM.THICKNESS,1.0) - mp.GetProperties()[1].SetValue(KM.DENSITY,1.0) + mp.GetProperties()[1].SetValue(KratosMultiphysics.YOUNG_MODULUS,210) + mp.GetProperties()[1].SetValue(KratosMultiphysics.POISSON_RATIO,0.3) + mp.GetProperties()[1].SetValue(KratosMultiphysics.THICKNESS,1.0) + mp.GetProperties()[1].SetValue(KratosMultiphysics.DENSITY,1.0) g = [0,-10.0,0] - mp.GetProperties()[1].SetValue(KM.VOLUME_ACCELERATION,g) + mp.GetProperties()[1].SetValue(KratosMultiphysics.VOLUME_ACCELERATION,g) cl = SMA.LinearElasticPlaneStrain2DLaw() - mp.GetProperties()[1].SetValue(KM.CONSTITUTIVE_LAW,cl) + mp.GetProperties()[1].SetValue(KratosMultiphysics.CONSTITUTIVE_LAW,cl) def _set_buffer(self,mp): buffer_size = 3 mp.SetBufferSize(buffer_size) # Cycle the buffer. This sets all historical nodal solution step data to # the current value and initializes the time stepping in the process info. - mp.ProcessInfo[KM.DELTA_TIME] = 1.0 - delta_time = mp.ProcessInfo[KM.DELTA_TIME] - time = mp.ProcessInfo[KM.TIME] + mp.ProcessInfo[KratosMultiphysics.DELTA_TIME] = 1.0 + delta_time = mp.ProcessInfo[KratosMultiphysics.DELTA_TIME] + time = mp.ProcessInfo[KratosMultiphysics.TIME] step =-buffer_size time = time - delta_time * buffer_size - mp.ProcessInfo.SetValue(KM.TIME, time) + mp.ProcessInfo.SetValue(KratosMultiphysics.TIME, time) for i in range(0, buffer_size): step = step + 1 time = time + delta_time - mp.ProcessInfo.SetValue(KM.STEP, step) + mp.ProcessInfo.SetValue(KratosMultiphysics.STEP, step) mp.CloneTimeStep(time) def _apply_BCs(self,mp,A,b): @@ -402,10 +402,10 @@ def _apply_BCs(self,mp,A,b): def _create_strategy(self, mp): #define a minimal newton raphson solver - linear_solver = KM.SkylineLUFactorizationSolver() - builder_and_solver = KM.ResidualBasedBlockBuilderAndSolver(linear_solver) - scheme = KM.ResidualBasedIncrementalUpdateStaticScheme() - convergence_criterion = KM.DisplacementCriteria(1e-13,1e-14) + linear_solver = KratosMultiphysics.SkylineLUFactorizationSolver() + builder_and_solver = KratosMultiphysics.ResidualBasedBlockBuilderAndSolver(linear_solver) + scheme = KratosMultiphysics.ResidualBasedIncrementalUpdateStaticScheme() + convergence_criterion = KratosMultiphysics.DisplacementCriteria(1e-13,1e-14) convergence_criterion.SetEchoLevel(0) #max_iters = 1 @@ -413,7 +413,7 @@ def _create_strategy(self, mp): compute_reactions = True reform_step_dofs = True move_mesh_flag = True - strategy = KM.ResidualBasedNewtonRaphsonStrategy(mp, + strategy = KratosMultiphysics.ResidualBasedNewtonRaphsonStrategy(mp, scheme, linear_solver, convergence_criterion, @@ -438,7 +438,7 @@ def _solve_with_strategy(self, strategy, step): def test_constraints(self): dim = 2 - current_model = KM.Model() + current_model = KratosMultiphysics.Model() mp = current_model.CreateModelPart("tl_solid_part") self._add_variables(mp) @@ -454,29 +454,29 @@ def test_constraints(self): n3 = mp.CreateNewNode(3, 0.0, 2.0, 0.0) n4 = mp.CreateNewNode(4, -2.0, 1.0, 0.0) - KM.VariableUtils().AddDof(KM.DISPLACEMENT_X, KM.REACTION_X,mp) - KM.VariableUtils().AddDof(KM.DISPLACEMENT_Y, KM.REACTION_Y,mp) - KM.VariableUtils().AddDof(KM.DISPLACEMENT_Z, KM.REACTION_Z,mp) + KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.DISPLACEMENT_X, KratosMultiphysics.REACTION_X,mp) + KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.DISPLACEMENT_Y, KratosMultiphysics.REACTION_Y,mp) + KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.DISPLACEMENT_Z, KratosMultiphysics.REACTION_Z,mp) mp.CreateNewElement("TotalLagrangianElement2D4N", 1, [1,2,3,4], mp.GetProperties()[1]) #node 1 is completely fixed - n1.Fix(KM.DISPLACEMENT_X) - n1.Fix(KM.DISPLACEMENT_Y) + n1.Fix(KratosMultiphysics.DISPLACEMENT_X) + n1.Fix(KratosMultiphysics.DISPLACEMENT_Y) ################# apply a constraint on node 2 #node2 is at allowed to slide normally to normal2 (taken as normal to the side 1-2) dx = n2.X - n1.X dy = n2.Y - n1.Y - normal_2 = KM.Array3([dy,-dx,0])/math.sqrt(dx**2+dy**2) + normal_2 = KratosMultiphysics.Array3([dy,-dx,0])/math.sqrt(dx**2+dy**2) inner_prod(normal_2,normal_2) - master_dofs_2 = [n2.GetDof(KM.DISPLACEMENT_Y)] - slave_dofs_2 = [n2.GetDof(KM.DISPLACEMENT_X)] - RelationMatrix2 = KM.Matrix(1,1) + master_dofs_2 = [n2.GetDof(KratosMultiphysics.DISPLACEMENT_Y)] + slave_dofs_2 = [n2.GetDof(KratosMultiphysics.DISPLACEMENT_X)] + RelationMatrix2 = KratosMultiphysics.Matrix(1,1) RelationMatrix2[0,0] = -normal_2[1]/normal_2[0] - ConstantVector = KM.Vector([0.0]) + ConstantVector = KratosMultiphysics.Vector([0.0]) - constraint_2 = KM.LinearMasterSlaveConstraint(2, + constraint_2 = KratosMultiphysics.LinearMasterSlaveConstraint(2, master_dofs_2, slave_dofs_2, @@ -489,13 +489,13 @@ def test_constraints(self): #node4 is at allowed to slide normally to normal4 dx = n1.X - n4.X dy = n1.Y - n4.Y - normal_4 = KM.Array3([dy,-dx,0])/math.sqrt(dx**2+dy**2) - n4.SetValue(KM.NORMAL, normal_4) #artificially set the normal + normal_4 = KratosMultiphysics.Array3([dy,-dx,0])/math.sqrt(dx**2+dy**2) + n4.SetValue(KratosMultiphysics.NORMAL, normal_4) #artificially set the normal - constraint_4 = KM.SlipConstraint(4, - n4.GetDof(KM.DISPLACEMENT_X), - n4.GetDof(KM.DISPLACEMENT_Y), - n4.GetValue(KM.NORMAL) + constraint_4 = KratosMultiphysics.SlipConstraint(4, + n4.GetDof(KratosMultiphysics.DISPLACEMENT_X), + n4.GetDof(KratosMultiphysics.DISPLACEMENT_Y), + n4.GetValue(KratosMultiphysics.NORMAL) ) mp.AddMasterSlaveConstraint(constraint_4) @@ -504,17 +504,17 @@ def test_constraints(self): self._solve_with_strategy(strategy,0) ##verify the results - d2 = n2.GetSolutionStepValue(KM.DISPLACEMENT) - d3 = n3.GetSolutionStepValue(KM.DISPLACEMENT) - d4 = n4.GetSolutionStepValue(KM.DISPLACEMENT) + d2 = n2.GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT) + d3 = n3.GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT) + d4 = n4.GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT) self.assertAlmostEqual(d2[0]*normal_2[0] + d2[1]*normal_2[1],0.0, 15) self.assertAlmostEqual(d4[0]*normal_4[0] + d4[1]*normal_4[1],0.0, 15) self.assertAlmostEqual(d3[0], 0.0, 15) #symmetry condition self.assertAlmostEqual(d3[1], 2.0*d2[1], 15) - R2 = n2.GetSolutionStepValue(KM.REACTION) - R4 = n4.GetSolutionStepValue(KM.REACTION) + R2 = n2.GetSolutionStepValue(KratosMultiphysics.REACTION) + R4 = n4.GetSolutionStepValue(KratosMultiphysics.REACTION) nR2 = inner_prod(normal_2, R2) nR4 = inner_prod(normal_4, R4) @@ -530,7 +530,7 @@ def test_constraints(self): self.assertTrue(tang_2.norm_2() < 1e-12) self.assertTrue(tang_4.norm_2() < 1e-12) - self.assertEqual(mp.ProcessInfo[KM.NL_ITERATION_NUMBER], 5) #4 if using Residual Criteria + self.assertEqual(mp.ProcessInfo[KratosMultiphysics.NL_ITERATION_NUMBER], 5) #4 if using Residual Criteria if __name__ == '__main__': KratosUnittest.main() From ed655d9c53ead7d3c33812f51ca5b34975dccd10 Mon Sep 17 00:00:00 2001 From: philbucher Date: Tue, 28 Apr 2020 14:52:47 +0200 Subject: [PATCH 281/314] not writing output file --- .../tests/fsi_sdof_static/ProjectParametersSDoF.json | 2 +- .../tests/fsi_sdof_static/results_final_sdof.dat | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) delete mode 100644 applications/CoSimulationApplication/tests/fsi_sdof_static/results_final_sdof.dat diff --git a/applications/CoSimulationApplication/tests/fsi_sdof_static/ProjectParametersSDoF.json b/applications/CoSimulationApplication/tests/fsi_sdof_static/ProjectParametersSDoF.json index cdd8b602e4f4..644139fc565f 100644 --- a/applications/CoSimulationApplication/tests/fsi_sdof_static/ProjectParametersSDoF.json +++ b/applications/CoSimulationApplication/tests/fsi_sdof_static/ProjectParametersSDoF.json @@ -12,7 +12,7 @@ "buffer_size": 3 }, "output_parameters":{ - "write_output_file": true, + "write_output_file": false, "file_name": "fsi_sdof_static/results_final_sdof.dat" } diff --git a/applications/CoSimulationApplication/tests/fsi_sdof_static/results_final_sdof.dat b/applications/CoSimulationApplication/tests/fsi_sdof_static/results_final_sdof.dat deleted file mode 100644 index 51d23d607a22..000000000000 --- a/applications/CoSimulationApplication/tests/fsi_sdof_static/results_final_sdof.dat +++ /dev/null @@ -1,3 +0,0 @@ -displacement -0.0 -0.0004033594026853261 From abd78e6696a3b2b75a85d85991e183461be3ffc2 Mon Sep 17 00:00:00 2001 From: philbucher Date: Tue, 28 Apr 2020 14:55:04 +0200 Subject: [PATCH 282/314] cleanup --- .../naca0012_small_parameters_coupling.json | 12 ++++-------- .../project_cosim_naca0012_small_fsi_parameters.json | 4 ++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/applications/CoSimulationApplication/tests/fsi_sdof_static/naca0012_small_parameters_coupling.json b/applications/CoSimulationApplication/tests/fsi_sdof_static/naca0012_small_parameters_coupling.json index 8ae659b0fb84..b57dfd9c429c 100644 --- a/applications/CoSimulationApplication/tests/fsi_sdof_static/naca0012_small_parameters_coupling.json +++ b/applications/CoSimulationApplication/tests/fsi_sdof_static/naca0012_small_parameters_coupling.json @@ -2,7 +2,7 @@ "problem_data" : { "problem_name" : "naca0012", "parallel_type" : "OpenMP", - "echo_level" : 1, + "echo_level" : 0, "start_time" : 0.0, "end_time" : 1.0 }, @@ -11,11 +11,8 @@ "ale_boundary_parts" : ["Body2D_Body"], "mesh_motion_solver_settings" :{ "solver_type" : "structural_similarity", - "linear_solver_settings" : { - "solver_type" : "ExternalSolversApplication.super_lu" - }, "reform_dofs_each_step" : false, - "echo_level": 1 + "echo_level": 0 }, "fluid_solver_settings" :{ @@ -27,10 +24,9 @@ "input_filename" : "fsi_sdof_static/naca0012_small" }, "maximum_iterations" : 5, - "echo_level" : 1, + "echo_level" : 0, "linear_solver_settings" : { - "solver_type" : "ExternalSolversApplication.super_lu", - "verbosity" : 0 + "solver_type" : "EigenSolversApplication.sparse_lu" }, "volume_model_part_name" : "Parts_Parts_Auto1", "skin_parts" : ["PotentialWallCondition2D_Far_field_Auto1","Body2D_Body"], diff --git a/applications/CoSimulationApplication/tests/fsi_sdof_static/project_cosim_naca0012_small_fsi_parameters.json b/applications/CoSimulationApplication/tests/fsi_sdof_static/project_cosim_naca0012_small_fsi_parameters.json index e4e31ca24378..352c022ad19a 100644 --- a/applications/CoSimulationApplication/tests/fsi_sdof_static/project_cosim_naca0012_small_fsi_parameters.json +++ b/applications/CoSimulationApplication/tests/fsi_sdof_static/project_cosim_naca0012_small_fsi_parameters.json @@ -3,14 +3,14 @@ { "start_time" : 0.0, "end_time" : 1.0, - "echo_level" : 1, + "echo_level" : 0, "print_colors" : true, "parallel_type" : "OpenMP" }, "solver_settings" : { "type" : "coupled_solvers.gauss_seidel_strong", - "echo_level" : 1, + "echo_level" : 0, "num_coupling_iterations" : 10, "data_transfer_operators" : { "transfer_forces" : { From 04052ce536e5d923506b206a03184efc3c03c20d Mon Sep 17 00:00:00 2001 From: philbucher Date: Tue, 28 Apr 2020 14:57:20 +0200 Subject: [PATCH 283/314] correct dependencies --- .../tests/co_simulation_test_factory.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/applications/CoSimulationApplication/tests/co_simulation_test_factory.py b/applications/CoSimulationApplication/tests/co_simulation_test_factory.py index a2ed1fb4af6d..31980e5c1f88 100644 --- a/applications/CoSimulationApplication/tests/co_simulation_test_factory.py +++ b/applications/CoSimulationApplication/tests/co_simulation_test_factory.py @@ -14,10 +14,10 @@ except ImportError: numpy_available = False -have_fsi_dependencies = kratos_utils.CheckIfApplicationsAvailable("FluidDynamicsApplication", "StructuralMechanicsApplication", "MappingApplication", "MeshMovingApplication", "ExternalSolversApplication") -have_potential_fsi_dependencies = kratos_utils.CheckIfApplicationsAvailable("CompressiblePotentialFlowApplication", "StructuralMechanicsApplication", "MappingApplication", "MeshMovingApplication", "ExternalSolversApplication") -have_mpm_fem_dependencies = kratos_utils.CheckIfApplicationsAvailable("ParticleMechanicsApplication", "StructuralMechanicsApplication", "MappingApplication", "ExternalSolversApplication") -have_dem_fem_dependencies = kratos_utils.CheckIfApplicationsAvailable("DEMApplication", "StructuralMechanicsApplication", "MappingApplication", "ExternalSolversApplication") +have_fsi_dependencies = kratos_utils.CheckIfApplicationsAvailable("FluidDynamicsApplication", "StructuralMechanicsApplication", "MappingApplication", "MeshMovingApplication", "EigenSolversApplication") +have_potential_fsi_dependencies = kratos_utils.CheckIfApplicationsAvailable("CompressiblePotentialFlowApplication", "StructuralMechanicsApplication", "MappingApplication", "MeshMovingApplication", "EigenSolversApplication") +have_mpm_fem_dependencies = kratos_utils.CheckIfApplicationsAvailable("ParticleMechanicsApplication", "StructuralMechanicsApplication", "MappingApplication", "EigenSolversApplication") +have_dem_fem_dependencies = kratos_utils.CheckIfApplicationsAvailable("DEMApplication", "StructuralMechanicsApplication", "MappingApplication", "EigenSolversApplication") using_pykratos = UsingPyKratos() From 7c0d4130d04e8e06b115aef0619995914e5f2016 Mon Sep 17 00:00:00 2001 From: philbucher Date: Tue, 28 Apr 2020 15:02:34 +0200 Subject: [PATCH 284/314] improving file handling --- .../CoSimulationApplication/tests/test_sdof_static_solver.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/applications/CoSimulationApplication/tests/test_sdof_static_solver.py b/applications/CoSimulationApplication/tests/test_sdof_static_solver.py index d9e8f02efe8d..1a34afeddbb7 100644 --- a/applications/CoSimulationApplication/tests/test_sdof_static_solver.py +++ b/applications/CoSimulationApplication/tests/test_sdof_static_solver.py @@ -24,8 +24,9 @@ def setUp(self): self.time = 0.0 @classmethod - def tearDown(self): + def tearDownClass(self): kratos_utilities.DeleteFileIfExisting("result.dat") + kratos_utilities.DeleteFileIfExisting('fsi_sdof_static/results_final_sdof.dat') def __CompareResults(self, reference, result): ref = np.loadtxt(reference, skiprows=1) @@ -56,6 +57,8 @@ def test_final_displacement(self): with open(parameter_file_name, 'r') as parameter_file: settings = json.load(parameter_file) + settings["output_parameters"]["write_output_file"] = True + system = SDoFStaticSolver(settings) system.Initialize() From 751c78ce06a467a6cd8ea79dfccb55b730ece4a9 Mon Sep 17 00:00:00 2001 From: Philipp Bucher Date: Tue, 28 Apr 2020 15:24:24 +0200 Subject: [PATCH 285/314] adding missing version of CalculateOnIntegrationPoints --- kratos/includes/element.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kratos/includes/element.h b/kratos/includes/element.h index 94546fa02f1b..b61647ad49f8 100644 --- a/kratos/includes/element.h +++ b/kratos/includes/element.h @@ -1035,6 +1035,13 @@ class Element : public GeometricalObject this->GetValueOnIntegrationPoints(rVariable, rOutput, rCurrentProcessInfo); } + virtual void CalculateOnIntegrationPoints(const Variable& rVariable, + std::vector& rOutput, + const ProcessInfo& rCurrentProcessInfo) + { + this->GetValueOnIntegrationPoints(rVariable, rOutput, rCurrentProcessInfo); + } + /** * Access for variables on Integration points. * This gives access to variables stored in the constitutive law on each integration point. From 2fbf729950245fdc1db3c4305bbfc05662be742d Mon Sep 17 00:00:00 2001 From: philbucher Date: Tue, 28 Apr 2020 15:39:15 +0200 Subject: [PATCH 286/314] update Element template --- kratos/templates/classes/element_template.cpp | 28 +++++++++---------- kratos/templates/classes/element_template.h | 28 +++++++++---------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/kratos/templates/classes/element_template.cpp b/kratos/templates/classes/element_template.cpp index 6a33cc851e3d..ec0cdd889621 100644 --- a/kratos/templates/classes/element_template.cpp +++ b/kratos/templates/classes/element_template.cpp @@ -165,7 +165,7 @@ Element::Pointer @{KRATOS_NAME_CAMEL}::Clone(IndexType NewId, NodesArrayType con * @param rResult: the elemental equation ID vector * @param rCurrentProcessInfo: the current process info instance */ -void @{KRATOS_NAME_CAMEL}::EquationIdVector(EquationIdVectorType& rResult, ProcessInfo& CurrentProcessInfo) +void @{KRATOS_NAME_CAMEL}::EquationIdVector(EquationIdVectorType& rResult, const ProcessInfo& CurrentProcessInfo) const { unsigned int number_of_nodes = GetGeometry().PointsNumber(); if (rResult.size() != number_of_nodes) @@ -179,7 +179,7 @@ void @{KRATOS_NAME_CAMEL}::EquationIdVector(EquationIdVectorType& rResult, Proce * @param ElementalDofList: the list of DOFs * @param rCurrentProcessInfo: the current process info instance */ -void @{KRATOS_NAME_CAMEL}::GetDofList(DofsVectorType& rElementalDofList, ProcessInfo& CurrentProcessInfo) +void @{KRATOS_NAME_CAMEL}::GetDofList(DofsVectorType& rElementalDofList, const ProcessInfo& CurrentProcessInfo) const { unsigned int number_of_nodes = GetGeometry().PointsNumber(); if (rElementalDofList.size() != number_of_nodes) @@ -206,7 +206,7 @@ void @{KRATOS_NAME_CAMEL}::GetDofList(DofsVectorType& rElementalDofList, Process void @{KRATOS_NAME_CAMEL}::CalculateLocalSystem( MatrixType& rLeftHandSideMatrix, VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo) + const ProcessInfo& rCurrentProcessInfo) { } @@ -216,7 +216,7 @@ void @{KRATOS_NAME_CAMEL}::CalculateLocalSystem( * @param rLeftHandSideMatrix: the elemental left hand side matrix * @param rCurrentProcessInfo: the current process info instance */ -void @{KRATOS_NAME_CAMEL}::CalculateLeftHandSide(MatrixType& rLeftHandSideMatrix, ProcessInfo& rCurrentProcessInfo) +void @{KRATOS_NAME_CAMEL}::CalculateLeftHandSide(MatrixType& rLeftHandSideMatrix, const ProcessInfo& rCurrentProcessInfo) { } @@ -226,7 +226,7 @@ void @{KRATOS_NAME_CAMEL}::CalculateLeftHandSide(MatrixType& rLeftHandSideMatrix * @param rRightHandSideVector: the elemental right hand side vector * @param rCurrentProcessInfo: the current process info instance */ -void @{KRATOS_NAME_CAMEL}::CalculateRightHandSide(VectorType& rRightHandSideVector, ProcessInfo& rCurrentProcessInfo) +void @{KRATOS_NAME_CAMEL}::CalculateRightHandSide(VectorType& rRightHandSideVector, const ProcessInfo& rCurrentProcessInfo) { } @@ -240,7 +240,7 @@ void @{KRATOS_NAME_CAMEL}::CalculateRightHandSide(VectorType& rRightHandSideVect void @{KRATOS_NAME_CAMEL}::CalculateFirstDerivativesContributions( MatrixType& rLeftHandSideMatrix, VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo) + const ProcessInfo& rCurrentProcessInfo) { if (rLeftHandSideMatrix.size1() != 0) rLeftHandSideMatrix.resize(0, 0, false); @@ -254,7 +254,7 @@ void @{KRATOS_NAME_CAMEL}::CalculateFirstDerivativesContributions( * @param rLeftHandSideMatrix: the elemental left hand side matrix * @param rCurrentProcessInfo: the current process info instance */ -void @{KRATOS_NAME_CAMEL}::CalculateFirstDerivativesLHS(MatrixType& rLeftHandSideMatrix, ProcessInfo& rCurrentProcessInfo) +void @{KRATOS_NAME_CAMEL}::CalculateFirstDerivativesLHS(MatrixType& rLeftHandSideMatrix, const ProcessInfo& rCurrentProcessInfo) { if (rLeftHandSideMatrix.size1() != 0) rLeftHandSideMatrix.resize(0, 0, false); @@ -266,7 +266,7 @@ void @{KRATOS_NAME_CAMEL}::CalculateFirstDerivativesLHS(MatrixType& rLeftHandSid * @param rRightHandSideVector: the elemental right hand side vector * @param rCurrentProcessInfo: the current process info instance */ -void @{KRATOS_NAME_CAMEL}::CalculateFirstDerivativesRHS(VectorType& rRightHandSideVector, ProcessInfo& rCurrentProcessInfo) +void @{KRATOS_NAME_CAMEL}::CalculateFirstDerivativesRHS(VectorType& rRightHandSideVector, const ProcessInfo& rCurrentProcessInfo) { if (rRightHandSideVector.size() != 0) rRightHandSideVector.resize(0, false); @@ -292,7 +292,7 @@ void @{KRATOS_NAME_CAMEL}::CalculateFirstDerivativesRHS(VectorType& rRightHandSi void @{KRATOS_NAME_CAMEL}::CalculateSecondDerivativesContributions( MatrixType& rLeftHandSideMatrix, VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo) + const ProcessInfo& rCurrentProcessInfo) { if (rLeftHandSideMatrix.size1() != 0) rLeftHandSideMatrix.resize(0, 0, false); @@ -308,7 +308,7 @@ void @{KRATOS_NAME_CAMEL}::CalculateSecondDerivativesContributions( */ void @{KRATOS_NAME_CAMEL}::CalculateSecondDerivativesLHS( MatrixType& rLeftHandSideMatrix, - ProcessInfo& rCurrentProcessInfo) + const ProcessInfo& rCurrentProcessInfo) { if (rLeftHandSideMatrix.size1() != 0) rLeftHandSideMatrix.resize(0, 0, false); @@ -322,7 +322,7 @@ void @{KRATOS_NAME_CAMEL}::CalculateSecondDerivativesLHS( */ void @{KRATOS_NAME_CAMEL}::CalculateSecondDerivativesRHS( VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo) + const ProcessInfo& rCurrentProcessInfo) { if (rRightHandSideVector.size() != 0) rRightHandSideVector.resize(0, false); @@ -334,7 +334,7 @@ void @{KRATOS_NAME_CAMEL}::CalculateSecondDerivativesRHS( * @param rMassMatrix: the elemental mass matrix * @param rCurrentProcessInfo: the current process info instance */ -void @{KRATOS_NAME_CAMEL}::CalculateMassMatrix(MatrixType& rMassMatrix, ProcessInfo& rCurrentProcessInfo) +void @{KRATOS_NAME_CAMEL}::CalculateMassMatrix(MatrixType& rMassMatrix, const ProcessInfo& rCurrentProcessInfo) { if (rMassMatrix.size1() != 0) rMassMatrix.resize(0, 0, false); @@ -346,7 +346,7 @@ void @{KRATOS_NAME_CAMEL}::CalculateMassMatrix(MatrixType& rMassMatrix, ProcessI * @param rDampingMatrix: the elemental damping matrix * @param rCurrentProcessInfo: the current process info instance */ -void @{KRATOS_NAME_CAMEL}::CalculateDampingMatrix(MatrixType& rDampingMatrix, ProcessInfo& rCurrentProcessInfo) +void @{KRATOS_NAME_CAMEL}::CalculateDampingMatrix(MatrixType& rDampingMatrix, const ProcessInfo& rCurrentProcessInfo) { if (rDampingMatrix.size1() != 0) rDampingMatrix.resize(0, 0, false); @@ -361,7 +361,7 @@ void @{KRATOS_NAME_CAMEL}::CalculateDampingMatrix(MatrixType& rDampingMatrix, Pr * @param rCurrentProcessInfo * this method is: MANDATORY */ -int @{KRATOS_NAME_CAMEL}::Check(const ProcessInfo& rCurrentProcessInfo) +int @{KRATOS_NAME_CAMEL}::Check(const ProcessInfo& rCurrentProcessInfo) const { KRATOS_TRY diff --git a/kratos/templates/classes/element_template.h b/kratos/templates/classes/element_template.h index 2023e0f7b67c..625e0d2f160b 100644 --- a/kratos/templates/classes/element_template.h +++ b/kratos/templates/classes/element_template.h @@ -147,14 +147,14 @@ class @{KRATOS_NAME_CAMEL} @{KRATOS_CLASS_BASE_HEADER} * @param rResult: the elemental equation ID vector * @param rCurrentProcessInfo: the current process info instance */ - void EquationIdVector(EquationIdVectorType& rResult, ProcessInfo& CurrentProcessInfo) override; + void EquationIdVector(EquationIdVectorType& rResult, const ProcessInfo& CurrentProcessInfo) const override; /** * determines the elemental list of DOFs * @param ElementalDofList: the list of DOFs * @param rCurrentProcessInfo: the current process info instance */ - void GetDofList(DofsVectorType& rElementalDofList, ProcessInfo& CurrentProcessInfo) override; + void GetDofList(DofsVectorType& rElementalDofList, const ProcessInfo& CurrentProcessInfo) const override; /** * ELEMENTS inherited from this class have to implement next @@ -174,7 +174,7 @@ class @{KRATOS_NAME_CAMEL} @{KRATOS_CLASS_BASE_HEADER} void CalculateLocalSystem( MatrixType& rLeftHandSideMatrix, VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo) override; + const ProcessInfo& rCurrentProcessInfo) override; /** * this is called during the assembling process in order @@ -182,7 +182,7 @@ class @{KRATOS_NAME_CAMEL} @{KRATOS_CLASS_BASE_HEADER} * @param rLeftHandSideMatrix: the elemental left hand side matrix * @param rCurrentProcessInfo: the current process info instance */ - void CalculateLeftHandSide(MatrixType& rLeftHandSideMatrix, ProcessInfo& rCurrentProcessInfo) override; + void CalculateLeftHandSide(MatrixType& rLeftHandSideMatrix, const ProcessInfo& rCurrentProcessInfo) override; /** * this is called during the assembling process in order @@ -190,7 +190,7 @@ class @{KRATOS_NAME_CAMEL} @{KRATOS_CLASS_BASE_HEADER} * @param rRightHandSideVector: the elemental right hand side vector * @param rCurrentProcessInfo: the current process info instance */ - void CalculateRightHandSide(VectorType& rRightHandSideVector, ProcessInfo& rCurrentProcessInfo) override; + void CalculateRightHandSide(VectorType& rRightHandSideVector, const ProcessInfo& rCurrentProcessInfo) override; /** * this is called during the assembling process in order @@ -202,7 +202,7 @@ class @{KRATOS_NAME_CAMEL} @{KRATOS_CLASS_BASE_HEADER} void CalculateFirstDerivativesContributions( MatrixType& rLeftHandSideMatrix, VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo) override; + const ProcessInfo& rCurrentProcessInfo) override; /** * this is called during the assembling process in order @@ -210,7 +210,7 @@ class @{KRATOS_NAME_CAMEL} @{KRATOS_CLASS_BASE_HEADER} * @param rLeftHandSideMatrix: the elemental left hand side matrix * @param rCurrentProcessInfo: the current process info instance */ - void CalculateFirstDerivativesLHS(MatrixType& rLeftHandSideMatrix, ProcessInfo& rCurrentProcessInfo) override; + void CalculateFirstDerivativesLHS(MatrixType& rLeftHandSideMatrix, const ProcessInfo& rCurrentProcessInfo) override; /** * this is called during the assembling process in order @@ -218,7 +218,7 @@ class @{KRATOS_NAME_CAMEL} @{KRATOS_CLASS_BASE_HEADER} * @param rRightHandSideVector: the elemental right hand side vector * @param rCurrentProcessInfo: the current process info instance */ - void CalculateFirstDerivativesRHS(VectorType& rRightHandSideVector, ProcessInfo& rCurrentProcessInfo) override; + void CalculateFirstDerivativesRHS(VectorType& rRightHandSideVector, const ProcessInfo& rCurrentProcessInfo) override; /** * ELEMENTS inherited from this class must implement this methods @@ -240,7 +240,7 @@ class @{KRATOS_NAME_CAMEL} @{KRATOS_CLASS_BASE_HEADER} void CalculateSecondDerivativesContributions( MatrixType& rLeftHandSideMatrix, VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo) override; + const ProcessInfo& rCurrentProcessInfo) override; /** * this is called during the assembling process in order @@ -250,7 +250,7 @@ class @{KRATOS_NAME_CAMEL} @{KRATOS_CLASS_BASE_HEADER} */ void CalculateSecondDerivativesLHS( MatrixType& rLeftHandSideMatrix, - ProcessInfo& rCurrentProcessInfo) override; + const ProcessInfo& rCurrentProcessInfo) override; /** * this is called during the assembling process in order @@ -260,7 +260,7 @@ class @{KRATOS_NAME_CAMEL} @{KRATOS_CLASS_BASE_HEADER} */ void CalculateSecondDerivativesRHS( VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo) override; + const ProcessInfo& rCurrentProcessInfo) override; /** * this is called during the assembling process in order @@ -268,7 +268,7 @@ class @{KRATOS_NAME_CAMEL} @{KRATOS_CLASS_BASE_HEADER} * @param rMassMatrix: the elemental mass matrix * @param rCurrentProcessInfo: the current process info instance */ - void CalculateMassMatrix(MatrixType& rMassMatrix, ProcessInfo& rCurrentProcessInfo) override; + void CalculateMassMatrix(MatrixType& rMassMatrix, const ProcessInfo& rCurrentProcessInfo) override; /** * this is called during the assembling process in order @@ -276,7 +276,7 @@ class @{KRATOS_NAME_CAMEL} @{KRATOS_CLASS_BASE_HEADER} * @param rDampingMatrix: the elemental damping matrix * @param rCurrentProcessInfo: the current process info instance */ - void CalculateDampingMatrix(MatrixType& rDampingMatrix, ProcessInfo& rCurrentProcessInfo) override; + void CalculateDampingMatrix(MatrixType& rDampingMatrix, const ProcessInfo& rCurrentProcessInfo) override; /** * This method provides the place to perform checks on the completeness of the input @@ -287,7 +287,7 @@ class @{KRATOS_NAME_CAMEL} @{KRATOS_CLASS_BASE_HEADER} * @param rCurrentProcessInfo * this method is: MANDATORY */ - int Check(const ProcessInfo& rCurrentProcessInfo) override; + int Check(const ProcessInfo& rCurrentProcessInfo) const override; ///@} ///@name Access From c768d300ca269e9f82dc8eb2c40f82513b9ffa89 Mon Sep 17 00:00:00 2001 From: philbucher Date: Tue, 28 Apr 2020 15:39:24 +0200 Subject: [PATCH 287/314] update Condition template --- .../templates/classes/condition_template.cpp | 28 +++++++++---------- kratos/templates/classes/condition_template.h | 28 +++++++++---------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/kratos/templates/classes/condition_template.cpp b/kratos/templates/classes/condition_template.cpp index 9d393ce36176..0beb5b5d527f 100644 --- a/kratos/templates/classes/condition_template.cpp +++ b/kratos/templates/classes/condition_template.cpp @@ -165,7 +165,7 @@ Condition::Pointer @{KRATOS_NAME_CAMEL}::Clone(IndexType NewId, NodesArrayType c * @param rResult: the condition equation ID vector * @param rCurrentProcessInfo: the current process info instance */ -void @{KRATOS_NAME_CAMEL}::EquationIdVector(EquationIdVectorType& rResult, ProcessInfo& CurrentProcessInfo) +void @{KRATOS_NAME_CAMEL}::EquationIdVector(EquationIdVectorType& rResult, const ProcessInfo& CurrentProcessInfo) const { unsigned int number_of_nodes = GetGeometry().PointsNumber(); if (rResult.size() != number_of_nodes) @@ -179,7 +179,7 @@ void @{KRATOS_NAME_CAMEL}::EquationIdVector(EquationIdVectorType& rResult, Proce * @param ConditionDofList: the list of DOFs * @param rCurrentProcessInfo: the current process info instance */ -void @{KRATOS_NAME_CAMEL}::GetDofList(DofsVectorType& rConditionDofList, ProcessInfo& CurrentProcessInfo) +void @{KRATOS_NAME_CAMEL}::GetDofList(DofsVectorType& rConditionDofList, const ProcessInfo& CurrentProcessInfo) const { unsigned int number_of_nodes = GetGeometry().PointsNumber(); if (rConditionDofList.size() != number_of_nodes) @@ -206,7 +206,7 @@ void @{KRATOS_NAME_CAMEL}::GetDofList(DofsVectorType& rConditionDofList, Process void @{KRATOS_NAME_CAMEL}::CalculateLocalSystem( MatrixType& rLeftHandSideMatrix, VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo) + const ProcessInfo& rCurrentProcessInfo) { } @@ -216,7 +216,7 @@ void @{KRATOS_NAME_CAMEL}::CalculateLocalSystem( * @param rLeftHandSideMatrix: the condition left hand side matrix * @param rCurrentProcessInfo: the current process info instance */ -void @{KRATOS_NAME_CAMEL}::CalculateLeftHandSide(MatrixType& rLeftHandSideMatrix, ProcessInfo& rCurrentProcessInfo) +void @{KRATOS_NAME_CAMEL}::CalculateLeftHandSide(MatrixType& rLeftHandSideMatrix, const ProcessInfo& rCurrentProcessInfo) { } @@ -226,7 +226,7 @@ void @{KRATOS_NAME_CAMEL}::CalculateLeftHandSide(MatrixType& rLeftHandSideMatrix * @param rRightHandSideVector: the condition right hand side vector * @param rCurrentProcessInfo: the current process info instance */ -void @{KRATOS_NAME_CAMEL}::CalculateRightHandSide(VectorType& rRightHandSideVector, ProcessInfo& rCurrentProcessInfo) +void @{KRATOS_NAME_CAMEL}::CalculateRightHandSide(VectorType& rRightHandSideVector, const ProcessInfo& rCurrentProcessInfo) { } @@ -240,7 +240,7 @@ void @{KRATOS_NAME_CAMEL}::CalculateRightHandSide(VectorType& rRightHandSideVect void @{KRATOS_NAME_CAMEL}::CalculateFirstDerivativesContributions( MatrixType& rLeftHandSideMatrix, VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo) + const ProcessInfo& rCurrentProcessInfo) { if (rLeftHandSideMatrix.size1() != 0) rLeftHandSideMatrix.resize(0, 0, false); @@ -254,7 +254,7 @@ void @{KRATOS_NAME_CAMEL}::CalculateFirstDerivativesContributions( * @param rLeftHandSideMatrix: the condition left hand side matrix * @param rCurrentProcessInfo: the current process info instance */ -void @{KRATOS_NAME_CAMEL}::CalculateFirstDerivativesLHS(MatrixType& rLeftHandSideMatrix, ProcessInfo& rCurrentProcessInfo) +void @{KRATOS_NAME_CAMEL}::CalculateFirstDerivativesLHS(MatrixType& rLeftHandSideMatrix, const ProcessInfo& rCurrentProcessInfo) { if (rLeftHandSideMatrix.size1() != 0) rLeftHandSideMatrix.resize(0, 0, false); @@ -266,7 +266,7 @@ void @{KRATOS_NAME_CAMEL}::CalculateFirstDerivativesLHS(MatrixType& rLeftHandSid * @param rRightHandSideVector: the condition right hand side vector * @param rCurrentProcessInfo: the current process info instance */ -void @{KRATOS_NAME_CAMEL}::CalculateFirstDerivativesRHS(VectorType& rRightHandSideVector, ProcessInfo& rCurrentProcessInfo) +void @{KRATOS_NAME_CAMEL}::CalculateFirstDerivativesRHS(VectorType& rRightHandSideVector, const ProcessInfo& rCurrentProcessInfo) { if (rRightHandSideVector.size() != 0) rRightHandSideVector.resize(0, false); @@ -292,7 +292,7 @@ void @{KRATOS_NAME_CAMEL}::CalculateFirstDerivativesRHS(VectorType& rRightHandSi void @{KRATOS_NAME_CAMEL}::CalculateSecondDerivativesContributions( MatrixType& rLeftHandSideMatrix, VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo) + const ProcessInfo& rCurrentProcessInfo) { if (rLeftHandSideMatrix.size1() != 0) rLeftHandSideMatrix.resize(0, 0, false); @@ -308,7 +308,7 @@ void @{KRATOS_NAME_CAMEL}::CalculateSecondDerivativesContributions( */ void @{KRATOS_NAME_CAMEL}::CalculateSecondDerivativesLHS( MatrixType& rLeftHandSideMatrix, - ProcessInfo& rCurrentProcessInfo) + const ProcessInfo& rCurrentProcessInfo) { if (rLeftHandSideMatrix.size1() != 0) rLeftHandSideMatrix.resize(0, 0, false); @@ -322,7 +322,7 @@ void @{KRATOS_NAME_CAMEL}::CalculateSecondDerivativesLHS( */ void @{KRATOS_NAME_CAMEL}::CalculateSecondDerivativesRHS( VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo) + const ProcessInfo& rCurrentProcessInfo) { if (rRightHandSideVector.size() != 0) rRightHandSideVector.resize(0, false); @@ -334,7 +334,7 @@ void @{KRATOS_NAME_CAMEL}::CalculateSecondDerivativesRHS( * @param rMassMatrix: the condition mass matrix * @param rCurrentProcessInfo: the current process info instance */ -void @{KRATOS_NAME_CAMEL}::CalculateMassMatrix(MatrixType& rMassMatrix, ProcessInfo& rCurrentProcessInfo) +void @{KRATOS_NAME_CAMEL}::CalculateMassMatrix(MatrixType& rMassMatrix, const ProcessInfo& rCurrentProcessInfo) { if (rMassMatrix.size1() != 0) rMassMatrix.resize(0, 0, false); @@ -346,7 +346,7 @@ void @{KRATOS_NAME_CAMEL}::CalculateMassMatrix(MatrixType& rMassMatrix, ProcessI * @param rDampingMatrix: the condition damping matrix * @param rCurrentProcessInfo: the current process info instance */ -void @{KRATOS_NAME_CAMEL}::CalculateDampingMatrix(MatrixType& rDampingMatrix, ProcessInfo& rCurrentProcessInfo) +void @{KRATOS_NAME_CAMEL}::CalculateDampingMatrix(MatrixType& rDampingMatrix, const ProcessInfo& rCurrentProcessInfo) { if (rDampingMatrix.size1() != 0) rDampingMatrix.resize(0, 0, false); @@ -361,7 +361,7 @@ void @{KRATOS_NAME_CAMEL}::CalculateDampingMatrix(MatrixType& rDampingMatrix, Pr * @param rCurrentProcessInfo * this method is: MANDATORY */ -int @{KRATOS_NAME_CAMEL}::Check(const ProcessInfo& rCurrentProcessInfo) +int @{KRATOS_NAME_CAMEL}::Check(const ProcessInfo& rCurrentProcessInfo) const { KRATOS_TRY diff --git a/kratos/templates/classes/condition_template.h b/kratos/templates/classes/condition_template.h index 6695c63cc7b9..d16a576b0b91 100644 --- a/kratos/templates/classes/condition_template.h +++ b/kratos/templates/classes/condition_template.h @@ -147,14 +147,14 @@ class @{KRATOS_NAME_CAMEL} @{KRATOS_CLASS_BASE_HEADER} * @param rResult: the condition equation ID vector * @param rCurrentProcessInfo: the current process info instance */ - void EquationIdVector(EquationIdVectorType& rResult, ProcessInfo& CurrentProcessInfo) override; + void EquationIdVector(EquationIdVectorType& rResult, const ProcessInfo& CurrentProcessInfo) const override; /** * determines the condition list of DOFs * @param rConditionDofList: the list of DOFs * @param rCurrentProcessInfo: the current process info instance */ - void GetDofList(DofsVectorType& rConditionDofList, ProcessInfo& CurrentProcessInfo) override; + void GetDofList(DofsVectorType& rConditionDofList, const ProcessInfo& CurrentProcessInfo) const override; /** * CONDITIONS inherited from this class have to implement next @@ -174,7 +174,7 @@ class @{KRATOS_NAME_CAMEL} @{KRATOS_CLASS_BASE_HEADER} void CalculateLocalSystem( MatrixType& rLeftHandSideMatrix, VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo) override; + const ProcessInfo& rCurrentProcessInfo) override; /** * this is called during the assembling process in order @@ -182,7 +182,7 @@ class @{KRATOS_NAME_CAMEL} @{KRATOS_CLASS_BASE_HEADER} * @param rLeftHandSideMatrix: the condition left hand side matrix * @param rCurrentProcessInfo: the current process info instance */ - void CalculateLeftHandSide(MatrixType& rLeftHandSideMatrix, ProcessInfo& rCurrentProcessInfo) override; + void CalculateLeftHandSide(MatrixType& rLeftHandSideMatrix, const ProcessInfo& rCurrentProcessInfo) override; /** * this is called during the assembling process in order @@ -190,7 +190,7 @@ class @{KRATOS_NAME_CAMEL} @{KRATOS_CLASS_BASE_HEADER} * @param rRightHandSideVector: the condition right hand side vector * @param rCurrentProcessInfo: the current process info instance */ - void CalculateRightHandSide(VectorType& rRightHandSideVector, ProcessInfo& rCurrentProcessInfo) override; + void CalculateRightHandSide(VectorType& rRightHandSideVector, const ProcessInfo& rCurrentProcessInfo) override; /** * this is called during the assembling process in order @@ -202,7 +202,7 @@ class @{KRATOS_NAME_CAMEL} @{KRATOS_CLASS_BASE_HEADER} void CalculateFirstDerivativesContributions( MatrixType& rLeftHandSideMatrix, VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo) override; + const ProcessInfo& rCurrentProcessInfo) override; /** * this is called during the assembling process in order @@ -210,7 +210,7 @@ class @{KRATOS_NAME_CAMEL} @{KRATOS_CLASS_BASE_HEADER} * @param rLeftHandSideMatrix: the condition left hand side matrix * @param rCurrentProcessInfo: the current process info instance */ - void CalculateFirstDerivativesLHS(MatrixType& rLeftHandSideMatrix, ProcessInfo& rCurrentProcessInfo) override; + void CalculateFirstDerivativesLHS(MatrixType& rLeftHandSideMatrix, const ProcessInfo& rCurrentProcessInfo) override; /** * this is called during the assembling process in order @@ -218,7 +218,7 @@ class @{KRATOS_NAME_CAMEL} @{KRATOS_CLASS_BASE_HEADER} * @param rRightHandSideVector: the condition right hand side vector * @param rCurrentProcessInfo: the current process info instance */ - void CalculateFirstDerivativesRHS(VectorType& rRightHandSideVector, ProcessInfo& rCurrentProcessInfo) override; + void CalculateFirstDerivativesRHS(VectorType& rRightHandSideVector, const ProcessInfo& rCurrentProcessInfo) override; /** * CONDITIONS inherited from this class must implement this methods @@ -240,7 +240,7 @@ class @{KRATOS_NAME_CAMEL} @{KRATOS_CLASS_BASE_HEADER} void CalculateSecondDerivativesContributions( MatrixType& rLeftHandSideMatrix, VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo) override; + const ProcessInfo& rCurrentProcessInfo) override; /** * this is called during the assembling process in order @@ -250,7 +250,7 @@ class @{KRATOS_NAME_CAMEL} @{KRATOS_CLASS_BASE_HEADER} */ void CalculateSecondDerivativesLHS( MatrixType& rLeftHandSideMatrix, - ProcessInfo& rCurrentProcessInfo) override; + const ProcessInfo& rCurrentProcessInfo) override; /** * this is called during the assembling process in order @@ -260,7 +260,7 @@ class @{KRATOS_NAME_CAMEL} @{KRATOS_CLASS_BASE_HEADER} */ void CalculateSecondDerivativesRHS( VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo) override; + const ProcessInfo& rCurrentProcessInfo) override; /** * this is called during the assembling process in order @@ -268,7 +268,7 @@ class @{KRATOS_NAME_CAMEL} @{KRATOS_CLASS_BASE_HEADER} * @param rMassMatrix: the condition mass matrix * @param rCurrentProcessInfo: the current process info instance */ - void CalculateMassMatrix(MatrixType& rMassMatrix, ProcessInfo& rCurrentProcessInfo) override; + void CalculateMassMatrix(MatrixType& rMassMatrix, const ProcessInfo& rCurrentProcessInfo) override; /** * this is called during the assembling process in order @@ -276,7 +276,7 @@ class @{KRATOS_NAME_CAMEL} @{KRATOS_CLASS_BASE_HEADER} * @param rDampingMatrix: the condition damping matrix * @param rCurrentProcessInfo: the current process info instance */ - void CalculateDampingMatrix(MatrixType& rDampingMatrix, ProcessInfo& rCurrentProcessInfo) override; + void CalculateDampingMatrix(MatrixType& rDampingMatrix, const ProcessInfo& rCurrentProcessInfo) override; /** * This method provides the place to perform checks on the completeness of the input @@ -287,7 +287,7 @@ class @{KRATOS_NAME_CAMEL} @{KRATOS_CLASS_BASE_HEADER} * @param rCurrentProcessInfo * this method is: MANDATORY */ - int Check(const ProcessInfo& rCurrentProcessInfo) override; + int Check(const ProcessInfo& rCurrentProcessInfo) const override; ///@} ///@name Access From e3ac31a9c543c21d16e8cce62f907995dfd51020 Mon Sep 17 00:00:00 2001 From: philbucher Date: Tue, 28 Apr 2020 15:45:13 +0200 Subject: [PATCH 288/314] updated conditions --- .../custom_conditions/base_load_condition.cpp | 6 +++--- .../custom_conditions/base_load_condition.h | 6 +++--- .../custom_conditions/displacement_control_condition.cpp | 2 +- .../custom_conditions/displacement_control_condition.h | 2 +- .../custom_conditions/point_moment_condition_3d.cpp | 6 +++--- .../custom_conditions/point_moment_condition_3d.h | 6 +++--- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/applications/StructuralMechanicsApplication/custom_conditions/base_load_condition.cpp b/applications/StructuralMechanicsApplication/custom_conditions/base_load_condition.cpp index 3aefc4c0f1bc..57f020dffa90 100644 --- a/applications/StructuralMechanicsApplication/custom_conditions/base_load_condition.cpp +++ b/applications/StructuralMechanicsApplication/custom_conditions/base_load_condition.cpp @@ -159,7 +159,7 @@ void BaseLoadCondition::GetDofList( void BaseLoadCondition::GetValuesVector( Vector& rValues, int Step - ) + ) const { const SizeType number_of_nodes = GetGeometry().size(); const SizeType dim = GetGeometry().WorkingSpaceDimension(); @@ -184,7 +184,7 @@ void BaseLoadCondition::GetValuesVector( void BaseLoadCondition::GetFirstDerivativesVector( Vector& rValues, int Step - ) + ) const { const SizeType number_of_nodes = GetGeometry().size(); const SizeType dim = GetGeometry().WorkingSpaceDimension(); @@ -209,7 +209,7 @@ void BaseLoadCondition::GetFirstDerivativesVector( void BaseLoadCondition::GetSecondDerivativesVector( Vector& rValues, int Step - ) + ) const { const SizeType number_of_nodes = GetGeometry().size(); const SizeType dim = GetGeometry().WorkingSpaceDimension(); diff --git a/applications/StructuralMechanicsApplication/custom_conditions/base_load_condition.h b/applications/StructuralMechanicsApplication/custom_conditions/base_load_condition.h index ffca69a2b136..99735b0ede6b 100644 --- a/applications/StructuralMechanicsApplication/custom_conditions/base_load_condition.h +++ b/applications/StructuralMechanicsApplication/custom_conditions/base_load_condition.h @@ -181,7 +181,7 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) BaseLoadCondition void GetValuesVector( Vector& rValues, int Step = 0 - ) override; + ) const override; /** * @brief Sets on rValues the nodal velocities @@ -191,7 +191,7 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) BaseLoadCondition void GetFirstDerivativesVector( Vector& rValues, int Step = 0 - ) override; + ) const override; /** * @brief Sets on rValues the nodal accelerations @@ -201,7 +201,7 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) BaseLoadCondition void GetSecondDerivativesVector( Vector& rValues, int Step = 0 - ) override; + ) const override; /** * @brief This function provides a more general interface to the element. diff --git a/applications/StructuralMechanicsApplication/custom_conditions/displacement_control_condition.cpp b/applications/StructuralMechanicsApplication/custom_conditions/displacement_control_condition.cpp index 8008314c66fa..ec2293b38fe5 100644 --- a/applications/StructuralMechanicsApplication/custom_conditions/displacement_control_condition.cpp +++ b/applications/StructuralMechanicsApplication/custom_conditions/displacement_control_condition.cpp @@ -217,7 +217,7 @@ void DisplacementControlCondition::GetDofList( void DisplacementControlCondition::GetValuesVector( Vector& rValues, int Step - ) + ) const { const SizeType number_of_nodes = GetGeometry().size(); const SizeType mat_size = number_of_nodes * GetBlockSize(); diff --git a/applications/StructuralMechanicsApplication/custom_conditions/displacement_control_condition.h b/applications/StructuralMechanicsApplication/custom_conditions/displacement_control_condition.h index 24689e1e7c34..d0c4b40023f9 100644 --- a/applications/StructuralMechanicsApplication/custom_conditions/displacement_control_condition.h +++ b/applications/StructuralMechanicsApplication/custom_conditions/displacement_control_condition.h @@ -169,7 +169,7 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) DisplacementControlCondition void GetValuesVector( Vector& rValues, int Step = 0 - ) override; + ) const override; /** * @brief This function provides a more general interface to the element. diff --git a/applications/StructuralMechanicsApplication/custom_conditions/point_moment_condition_3d.cpp b/applications/StructuralMechanicsApplication/custom_conditions/point_moment_condition_3d.cpp index 414f32fe6aa6..a50f94f04774 100644 --- a/applications/StructuralMechanicsApplication/custom_conditions/point_moment_condition_3d.cpp +++ b/applications/StructuralMechanicsApplication/custom_conditions/point_moment_condition_3d.cpp @@ -122,7 +122,7 @@ void PointMomentCondition3D::GetDofList( void PointMomentCondition3D::GetValuesVector( Vector& rValues, int Step - ) + ) const { const array_1d & r_rotation = GetGeometry()[0].FastGetSolutionStepValue(ROTATION, Step); @@ -138,7 +138,7 @@ void PointMomentCondition3D::GetValuesVector( void PointMomentCondition3D::GetFirstDerivativesVector( Vector& rValues, int Step - ) + ) const { const array_1d & r_angular_vel = GetGeometry()[0].FastGetSolutionStepValue(ANGULAR_VELOCITY, Step); @@ -154,7 +154,7 @@ void PointMomentCondition3D::GetFirstDerivativesVector( void PointMomentCondition3D::GetSecondDerivativesVector( Vector& rValues, int Step - ) + ) const { const array_1d & r_angular_acc = GetGeometry()[0].FastGetSolutionStepValue(ANGULAR_ACCELERATION, Step); diff --git a/applications/StructuralMechanicsApplication/custom_conditions/point_moment_condition_3d.h b/applications/StructuralMechanicsApplication/custom_conditions/point_moment_condition_3d.h index 8826df346c20..ddebd406b44b 100644 --- a/applications/StructuralMechanicsApplication/custom_conditions/point_moment_condition_3d.h +++ b/applications/StructuralMechanicsApplication/custom_conditions/point_moment_condition_3d.h @@ -144,7 +144,7 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) PointMomentCondition3D void GetValuesVector( Vector& rValues, int Step = 0 - ) override; + ) const override; /** * Sets on rValues the nodal velocities @@ -154,7 +154,7 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) PointMomentCondition3D void GetFirstDerivativesVector( Vector& rValues, int Step = 0 - ) override; + ) const override; /** * Sets on rValues the nodal accelerations @@ -164,7 +164,7 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) PointMomentCondition3D void GetSecondDerivativesVector( Vector& rValues, int Step = 0 - ) override; + ) const override; /** From b9ec14f3286153def13e272ed7dff8f5891ef835 Mon Sep 17 00:00:00 2001 From: philbucher Date: Tue, 28 Apr 2020 15:47:00 +0200 Subject: [PATCH 289/314] updated Adjoint Elements --- .../adjoint_elements/adjoint_finite_difference_base_element.cpp | 2 +- .../adjoint_elements/adjoint_finite_difference_base_element.h | 2 +- .../adjoint_elements/adjoint_solid_element.cpp | 2 +- .../adjoint_elements/adjoint_solid_element.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_finite_difference_base_element.cpp b/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_finite_difference_base_element.cpp index f87ebfead73c..8e98b102360a 100644 --- a/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_finite_difference_base_element.cpp +++ b/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_finite_difference_base_element.cpp @@ -97,7 +97,7 @@ void AdjointFiniteDifferencingBaseElement::GetDofList(DofsVector } template -void AdjointFiniteDifferencingBaseElement::GetValuesVector(Vector& rValues, int Step) +void AdjointFiniteDifferencingBaseElement::GetValuesVector(Vector& rValues, int Step) const { KRATOS_TRY diff --git a/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_finite_difference_base_element.h b/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_finite_difference_base_element.h index 751356a4353f..ef999640d38b 100644 --- a/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_finite_difference_base_element.h +++ b/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_finite_difference_base_element.h @@ -130,7 +130,7 @@ class AdjointFiniteDifferencingBaseElement : public Element return mpPrimalElement->GetIntegrationMethod(); } - void GetValuesVector(Vector& values, int Step = 0) override; + void GetValuesVector(Vector& values, int Step = 0) const override; void Initialize(const ProcessInfo& rCurrentProcessInfo) override { diff --git a/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_solid_element.cpp b/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_solid_element.cpp index 22185b883e44..02c3807509e6 100644 --- a/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_solid_element.cpp +++ b/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_solid_element.cpp @@ -219,7 +219,7 @@ void AdjointSolidElement::CalculateSecondDerivativesLHS( } template -void AdjointSolidElement::GetValuesVector(Vector& rValues, int Step) +void AdjointSolidElement::GetValuesVector(Vector& rValues, int Step) const { KRATOS_TRY; const auto& r_geom = mPrimalElement.GetGeometry(); diff --git a/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_solid_element.h b/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_solid_element.h index 9804e0fcc392..6ccbb61cc579 100644 --- a/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_solid_element.h +++ b/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_solid_element.h @@ -111,7 +111,7 @@ class AdjointSolidElement void CalculateSecondDerivativesLHS(MatrixType& rLeftHandSideMatrix, ProcessInfo& rCurrentProcessInfo) override; - void GetValuesVector(Vector& rValues, int Step = 0) override; + void GetValuesVector(Vector& rValues, int Step = 0) const override; void EquationIdVector(EquationIdVectorType& rResult, const ProcessInfo& rCurrentProcessInfo) const override; From 50a5c1aea81b35ae05818bee7c686799c49ae0a6 Mon Sep 17 00:00:00 2001 From: philbucher Date: Tue, 28 Apr 2020 15:47:08 +0200 Subject: [PATCH 290/314] updated Adjoint Conditions --- .../adjoint_conditions/adjoint_semi_analytic_base_condition.cpp | 2 +- .../adjoint_conditions/adjoint_semi_analytic_base_condition.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_conditions/adjoint_semi_analytic_base_condition.cpp b/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_conditions/adjoint_semi_analytic_base_condition.cpp index 440117c80f48..86e8c20ed7e9 100644 --- a/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_conditions/adjoint_semi_analytic_base_condition.cpp +++ b/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_conditions/adjoint_semi_analytic_base_condition.cpp @@ -93,7 +93,7 @@ namespace Kratos } template - void AdjointSemiAnalyticBaseCondition::GetValuesVector(Vector& rValues, int Step) + void AdjointSemiAnalyticBaseCondition::GetValuesVector(Vector& rValues, int Step) const { const SizeType number_of_nodes = this->GetGeometry().size(); const SizeType dimension = this->GetGeometry().WorkingSpaceDimension(); diff --git a/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_conditions/adjoint_semi_analytic_base_condition.h b/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_conditions/adjoint_semi_analytic_base_condition.h index 518a2aa54a7f..d2e258deceea 100644 --- a/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_conditions/adjoint_semi_analytic_base_condition.h +++ b/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_conditions/adjoint_semi_analytic_base_condition.h @@ -120,7 +120,7 @@ class AdjointSemiAnalyticBaseCondition return mpPrimalCondition->GetIntegrationMethod(); } - void GetValuesVector(Vector& rValues, int Step = 0 ) override; + void GetValuesVector(Vector& rValues, int Step = 0 ) const override; void Initialize(const ProcessInfo& rCurrentProcessInfo) override { From 8d979b7ebec334a732c56b27c85b164e8065f131 Mon Sep 17 00:00:00 2001 From: philbucher Date: Tue, 28 Apr 2020 15:52:20 +0200 Subject: [PATCH 291/314] Updated Elements --- .../custom_elements/base_shell_element.cpp | 6 +++--- .../custom_elements/base_shell_element.h | 6 +++--- .../custom_elements/base_solid_element.cpp | 6 +++--- .../custom_elements/base_solid_element.h | 6 +++--- .../custom_elements/cr_beam_element_2D2N.cpp | 6 +++--- .../custom_elements/cr_beam_element_2D2N.hpp | 6 +++--- .../custom_elements/cr_beam_element_3D2N.cpp | 6 +++--- .../custom_elements/cr_beam_element_3D2N.hpp | 6 +++--- .../custom_elements/isotropic_shell_element.cpp | 6 +++--- .../custom_elements/isotropic_shell_element.hpp | 6 +++--- .../custom_elements/membrane_element.cpp | 9 +++------ .../custom_elements/membrane_element.hpp | 6 +++--- .../custom_elements/nodal_concentrated_element.cpp | 6 +++--- .../custom_elements/nodal_concentrated_element.hpp | 6 +++--- .../custom_elements/solid_shell_element_sprism_3D6N.cpp | 6 +++--- .../custom_elements/solid_shell_element_sprism_3D6N.h | 6 +++--- .../custom_elements/spring_damper_element_3D2N.cpp | 6 +++--- .../custom_elements/truss_element_3D2N.cpp | 6 +++--- .../custom_elements/truss_element_3D2N.hpp | 6 +++--- 19 files changed, 57 insertions(+), 60 deletions(-) diff --git a/applications/StructuralMechanicsApplication/custom_elements/base_shell_element.cpp b/applications/StructuralMechanicsApplication/custom_elements/base_shell_element.cpp index 3bdff0bac64d..3b82ee2b72af 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/base_shell_element.cpp +++ b/applications/StructuralMechanicsApplication/custom_elements/base_shell_element.cpp @@ -92,7 +92,7 @@ void BaseShellElement::GetDofList(DofsVectorType& rElementalDofList, } } -void BaseShellElement::GetValuesVector(Vector& rValues, int Step) +void BaseShellElement::GetValuesVector(Vector& rValues, int Step) const { const SizeType num_dofs = GetNumberOfDofs(); @@ -118,7 +118,7 @@ void BaseShellElement::GetValuesVector(Vector& rValues, int Step) } } -void BaseShellElement::GetFirstDerivativesVector(Vector& rValues, int Step) +void BaseShellElement::GetFirstDerivativesVector(Vector& rValues, int Step) const { const SizeType num_dofs = GetNumberOfDofs(); @@ -144,7 +144,7 @@ void BaseShellElement::GetFirstDerivativesVector(Vector& rValues, int Step) } } -void BaseShellElement::GetSecondDerivativesVector(Vector& rValues, int Step) +void BaseShellElement::GetSecondDerivativesVector(Vector& rValues, int Step) const { const SizeType num_dofs = GetNumberOfDofs(); diff --git a/applications/StructuralMechanicsApplication/custom_elements/base_shell_element.h b/applications/StructuralMechanicsApplication/custom_elements/base_shell_element.h index d7e961d167a3..12148f5f975d 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/base_shell_element.h +++ b/applications/StructuralMechanicsApplication/custom_elements/base_shell_element.h @@ -120,11 +120,11 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) BaseShellElement void GetDofList(DofsVectorType& rElementalDofList, const ProcessInfo& rCurrentProcessInfo) const override; - void GetValuesVector(Vector& rValues, int Step = 0) override; + void GetValuesVector(Vector& rValues, int Step = 0) const override; - void GetFirstDerivativesVector(Vector& rValues, int Step = 0) override; + void GetFirstDerivativesVector(Vector& rValues, int Step = 0) const override; - void GetSecondDerivativesVector(Vector& rValues, int Step = 0) override; + void GetSecondDerivativesVector(Vector& rValues, int Step = 0) const override; void ResetConstitutiveLaw() override; diff --git a/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.cpp b/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.cpp index 0849ccebeecd..d2ea09ef6e43 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.cpp +++ b/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.cpp @@ -370,7 +370,7 @@ void BaseSolidElement::GetDofList( void BaseSolidElement::GetValuesVector( Vector& rValues, int Step - ) + ) const { const SizeType number_of_nodes = GetGeometry().size(); const SizeType dimension = GetGeometry().WorkingSpaceDimension(); @@ -394,7 +394,7 @@ void BaseSolidElement::GetValuesVector( void BaseSolidElement::GetFirstDerivativesVector( Vector& rValues, int Step - ) + ) const { const SizeType number_of_nodes = GetGeometry().size(); const SizeType dimension = GetGeometry().WorkingSpaceDimension(); @@ -415,7 +415,7 @@ void BaseSolidElement::GetFirstDerivativesVector( void BaseSolidElement::GetSecondDerivativesVector( Vector& rValues, int Step - ) + ) const { const SizeType number_of_nodes = GetGeometry().size(); const SizeType dimension = GetGeometry().WorkingSpaceDimension(); diff --git a/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.h b/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.h index f93260fc2f15..df7b0457e438 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.h +++ b/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.h @@ -267,7 +267,7 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) BaseSolidElement void GetValuesVector( Vector& rValues, int Step = 0 - ) override; + ) const override; /** * @brief Sets on rValues the nodal velocities @@ -277,7 +277,7 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) BaseSolidElement void GetFirstDerivativesVector( Vector& rValues, int Step = 0 - ) override; + ) const override; /** * @brief Sets on rValues the nodal accelerations @@ -287,7 +287,7 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) BaseSolidElement void GetSecondDerivativesVector( Vector& rValues, int Step = 0 - ) override; + ) const override; /** * @brief This function provides a more general interface to the element. diff --git a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_2D2N.cpp b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_2D2N.cpp index eb94d5533f10..b72a499c6a59 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_2D2N.cpp +++ b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_2D2N.cpp @@ -85,7 +85,7 @@ void CrBeamElement2D2N::GetDofList(DofsVectorType& rElementalDofList, } } -void CrBeamElement2D2N::GetValuesVector(Vector& rValues, int Step) +void CrBeamElement2D2N::GetValuesVector(Vector& rValues, int Step) const { KRATOS_TRY @@ -105,7 +105,7 @@ void CrBeamElement2D2N::GetValuesVector(Vector& rValues, int Step) KRATOS_CATCH("") } -void CrBeamElement2D2N::GetFirstDerivativesVector(Vector& rValues, int Step) +void CrBeamElement2D2N::GetFirstDerivativesVector(Vector& rValues, int Step) const { KRATOS_TRY @@ -126,7 +126,7 @@ void CrBeamElement2D2N::GetFirstDerivativesVector(Vector& rValues, int Step) KRATOS_CATCH("") } -void CrBeamElement2D2N::GetSecondDerivativesVector(Vector& rValues, int Step) +void CrBeamElement2D2N::GetSecondDerivativesVector(Vector& rValues, int Step) const { KRATOS_TRY if (rValues.size() != msElementSize) { diff --git a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_2D2N.hpp b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_2D2N.hpp index 36d09c22aa26..b04367bfd245 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_2D2N.hpp +++ b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_2D2N.hpp @@ -103,15 +103,15 @@ class CrBeamElement2D2N : public Element void GetValuesVector( Vector& rValues, - int Step = 0) override; + int Step = 0) const override; void GetSecondDerivativesVector( Vector& rValues, - int Step = 0) override; + int Step = 0) const override; void GetFirstDerivativesVector( Vector& rValues, - int Step = 0) override; + int Step = 0) const override; void CalculateMassMatrix( MatrixType& rMassMatrix, diff --git a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_3D2N.cpp b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_3D2N.cpp index 4a9cabab342a..5ee83acfc159 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_3D2N.cpp +++ b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_3D2N.cpp @@ -93,7 +93,7 @@ void CrBeamElement3D2N::GetDofList(DofsVectorType& rElementalDofList, } } -void CrBeamElement3D2N::GetSecondDerivativesVector(Vector& rValues, int Step) +void CrBeamElement3D2N::GetSecondDerivativesVector(Vector& rValues, int Step) const { KRATOS_TRY @@ -127,7 +127,7 @@ void CrBeamElement3D2N::InitializeNonLinearIteration(ProcessInfo& rCurrentProces KRATOS_CATCH("") } -void CrBeamElement3D2N::GetFirstDerivativesVector(Vector& rValues, int Step) +void CrBeamElement3D2N::GetFirstDerivativesVector(Vector& rValues, int Step) const { KRATOS_TRY @@ -153,7 +153,7 @@ void CrBeamElement3D2N::GetFirstDerivativesVector(Vector& rValues, int Step) KRATOS_CATCH("") } -void CrBeamElement3D2N::GetValuesVector(Vector& rValues, int Step) +void CrBeamElement3D2N::GetValuesVector(Vector& rValues, int Step) const { KRATOS_TRY if (rValues.size() != msElementSize) { diff --git a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_3D2N.hpp b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_3D2N.hpp index 228186d188ef..4875b2d875cf 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_3D2N.hpp +++ b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_3D2N.hpp @@ -218,15 +218,15 @@ class CrBeamElement3D2N : public Element void GetValuesVector( Vector& rValues, - int Step = 0) override; + int Step = 0) const override; void GetSecondDerivativesVector( Vector& rValues, - int Step = 0) override; + int Step = 0) const override; void GetFirstDerivativesVector( Vector& rValues, - int Step = 0) override; + int Step = 0) const override; /** * @brief This function is used to assemble single transformation matrix in the big global rotation matrix diff --git a/applications/StructuralMechanicsApplication/custom_elements/isotropic_shell_element.cpp b/applications/StructuralMechanicsApplication/custom_elements/isotropic_shell_element.cpp index 9226843bac9e..3f5f258a3298 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/isotropic_shell_element.cpp +++ b/applications/StructuralMechanicsApplication/custom_elements/isotropic_shell_element.cpp @@ -741,7 +741,7 @@ void IsotropicShellElement::GetDofList(DofsVectorType& ElementalDofList, const P //************************************************************************************ //************************************************************************************ -void IsotropicShellElement::GetValuesVector(Vector& values, int Step) +void IsotropicShellElement::GetValuesVector(Vector& values, int Step) const { const unsigned int number_of_nodes = 3; //const unsigned int dim = 3; @@ -2033,7 +2033,7 @@ void IsotropicShellElement::CalculateMassMatrix(MatrixType& rMassMatrix, Process //************************************************************************************ //************************************************************************************ -void IsotropicShellElement::GetFirstDerivativesVector(Vector& values, int Step) +void IsotropicShellElement::GetFirstDerivativesVector(Vector& values, int Step) const { unsigned int MatSize = 18; if(values.size() != MatSize) values.resize(MatSize,false); @@ -2050,7 +2050,7 @@ void IsotropicShellElement::GetFirstDerivativesVector(Vector& values, int Step) } //************************************************************************************ //************************************************************************************ -void IsotropicShellElement::GetSecondDerivativesVector(Vector& values, int Step) +void IsotropicShellElement::GetSecondDerivativesVector(Vector& values, int Step) const { unsigned int MatSize = 18; if(values.size() != MatSize) values.resize(MatSize,false); diff --git a/applications/StructuralMechanicsApplication/custom_elements/isotropic_shell_element.hpp b/applications/StructuralMechanicsApplication/custom_elements/isotropic_shell_element.hpp index af6920e12b49..52353b1423c4 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/isotropic_shell_element.hpp +++ b/applications/StructuralMechanicsApplication/custom_elements/isotropic_shell_element.hpp @@ -115,9 +115,9 @@ class IsotropicShellElement void InitializeSolutionStep(ProcessInfo& CurrentProcessInfo) override; - void GetValuesVector(Vector& values, int Step) override; - void GetFirstDerivativesVector(Vector& values, int Step = 0) override; - void GetSecondDerivativesVector(Vector& values, int Step = 0) override; + void GetValuesVector(Vector& values, int Step) const override; + void GetFirstDerivativesVector(Vector& values, int Step = 0) const override; + void GetSecondDerivativesVector(Vector& values, int Step = 0) const override; void CalculateOnIntegrationPoints(const Variable& rVariable, std::vector< Matrix >& Output, const ProcessInfo& rCurrentProcessInfo) override; diff --git a/applications/StructuralMechanicsApplication/custom_elements/membrane_element.cpp b/applications/StructuralMechanicsApplication/custom_elements/membrane_element.cpp index e62af665741b..2ff2fd007883 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/membrane_element.cpp +++ b/applications/StructuralMechanicsApplication/custom_elements/membrane_element.cpp @@ -199,8 +199,7 @@ void MembraneElement::CalculateLocalSystem( void MembraneElement::GetValuesVector( Vector& rValues, - int Step) - + int Step) const { const SizeType number_of_nodes = GetGeometry().size(); const SizeType dimension = GetGeometry().WorkingSpaceDimension(); @@ -224,8 +223,7 @@ void MembraneElement::GetValuesVector( void MembraneElement::GetFirstDerivativesVector( Vector& rValues, - int Step) - + int Step) const { const SizeType number_of_nodes = GetGeometry().size(); const SizeType mat_size = number_of_nodes * 3; @@ -249,8 +247,7 @@ void MembraneElement::GetFirstDerivativesVector( void MembraneElement::GetSecondDerivativesVector( Vector& rValues, - int Step) - + int Step) const { const SizeType number_of_nodes = GetGeometry().size(); const SizeType mat_size = number_of_nodes * 3; diff --git a/applications/StructuralMechanicsApplication/custom_elements/membrane_element.hpp b/applications/StructuralMechanicsApplication/custom_elements/membrane_element.hpp index 1533de7c5363..ee3843e07c7c 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/membrane_element.hpp +++ b/applications/StructuralMechanicsApplication/custom_elements/membrane_element.hpp @@ -105,15 +105,15 @@ namespace Kratos void GetValuesVector( Vector& rValues, - int Step = 0) override; + int Step = 0) const override; void GetFirstDerivativesVector( Vector& rValues, - int Step = 0) override; + int Step = 0) const override; void GetSecondDerivativesVector( Vector& rValues, - int Step = 0) override; + int Step = 0) const override; int Check(const ProcessInfo& rCurrentProcessInfo) const override; diff --git a/applications/StructuralMechanicsApplication/custom_elements/nodal_concentrated_element.cpp b/applications/StructuralMechanicsApplication/custom_elements/nodal_concentrated_element.cpp index b13330ee0e68..0acc0d4c0274 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/nodal_concentrated_element.cpp +++ b/applications/StructuralMechanicsApplication/custom_elements/nodal_concentrated_element.cpp @@ -167,7 +167,7 @@ void NodalConcentratedElement::EquationIdVector( //*********************************DISPLACEMENT*************************************** //************************************************************************************ -void NodalConcentratedElement::GetValuesVector( Vector& rValues, int Step ) +void NodalConcentratedElement::GetValuesVector( Vector& rValues, int Step ) const { //GIVES THE VECTOR WITH THE DOFS VARIABLES OF THE ELEMENT (i.e. ELEMENT DISPLACEMENTS) const unsigned int dimension = GetGeometry().WorkingSpaceDimension(); @@ -186,7 +186,7 @@ void NodalConcentratedElement::GetValuesVector( Vector& rValues, int Step ) //************************************VELOCITY**************************************** //************************************************************************************ -void NodalConcentratedElement::GetFirstDerivativesVector( Vector& rValues, int Step ) +void NodalConcentratedElement::GetFirstDerivativesVector( Vector& rValues, int Step ) const { //GIVES THE VECTOR WITH THE TIME DERIVATIVE OF THE DOFS VARIABLES OF THE ELEMENT (i.e. ELEMENT VELOCITIES) const unsigned int dimension = GetGeometry().WorkingSpaceDimension(); @@ -204,7 +204,7 @@ void NodalConcentratedElement::GetFirstDerivativesVector( Vector& rValues, int S //*********************************ACCELERATION*************************************** //************************************************************************************ -void NodalConcentratedElement::GetSecondDerivativesVector( Vector& rValues, int Step ) +void NodalConcentratedElement::GetSecondDerivativesVector( Vector& rValues, int Step ) const { //GIVES THE VECTOR WITH THE TIME SECOND DERIVATIVE OF THE DOFS VARIABLES OF THE ELEMENT (i.e. ELEMENT ACCELERATIONS) const unsigned int dimension = GetGeometry().WorkingSpaceDimension(); diff --git a/applications/StructuralMechanicsApplication/custom_elements/nodal_concentrated_element.hpp b/applications/StructuralMechanicsApplication/custom_elements/nodal_concentrated_element.hpp index ad38abb54931..a0e4336dfe39 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/nodal_concentrated_element.hpp +++ b/applications/StructuralMechanicsApplication/custom_elements/nodal_concentrated_element.hpp @@ -133,17 +133,17 @@ class NodalConcentratedElement /** * Sets on rValues the nodal displacements */ - void GetValuesVector(Vector& rValues, int Step = 0) override; + void GetValuesVector(Vector& rValues, int Step = 0) const override; /** * Sets on rValues the nodal velocities */ - void GetFirstDerivativesVector(Vector& rValues, int Step = 0) override; + void GetFirstDerivativesVector(Vector& rValues, int Step = 0) const override; /** * Sets on rValues the nodal accelerations */ - void GetSecondDerivativesVector(Vector& rValues, int Step = 0) override; + void GetSecondDerivativesVector(Vector& rValues, int Step = 0) const override; //************* COMPUTING METHODS diff --git a/applications/StructuralMechanicsApplication/custom_elements/solid_shell_element_sprism_3D6N.cpp b/applications/StructuralMechanicsApplication/custom_elements/solid_shell_element_sprism_3D6N.cpp index 5ba8952dfc51..6cbc89a78842 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/solid_shell_element_sprism_3D6N.cpp +++ b/applications/StructuralMechanicsApplication/custom_elements/solid_shell_element_sprism_3D6N.cpp @@ -234,7 +234,7 @@ void SolidShellElementSprism3D6N::GetDofList( void SolidShellElementSprism3D6N::GetValuesVector( Vector& rValues, int Step - ) + ) const { const WeakPointerVectorNodesType& p_neighbour_nodes = this->GetValue(NEIGHBOUR_NODES); const SizeType number_of_nodes = GetGeometry().size() + NumberOfActiveNeighbours(p_neighbour_nodes); @@ -270,7 +270,7 @@ void SolidShellElementSprism3D6N::GetValuesVector( void SolidShellElementSprism3D6N::GetFirstDerivativesVector( Vector& rValues, int Step - ) + ) const { const WeakPointerVectorNodesType& p_neighbour_nodes = this->GetValue(NEIGHBOUR_NODES); const SizeType number_of_nodes = GetGeometry().size() + NumberOfActiveNeighbours(p_neighbour_nodes); @@ -306,7 +306,7 @@ void SolidShellElementSprism3D6N::GetFirstDerivativesVector( void SolidShellElementSprism3D6N::GetSecondDerivativesVector( Vector& rValues, int Step - ) + ) const { const WeakPointerVectorNodesType& p_neighbour_nodes = this->GetValue(NEIGHBOUR_NODES); const SizeType number_of_nodes = GetGeometry().size() + NumberOfActiveNeighbours(p_neighbour_nodes); diff --git a/applications/StructuralMechanicsApplication/custom_elements/solid_shell_element_sprism_3D6N.h b/applications/StructuralMechanicsApplication/custom_elements/solid_shell_element_sprism_3D6N.h index 8ef4a421d2a6..c1c0bdab118b 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/solid_shell_element_sprism_3D6N.h +++ b/applications/StructuralMechanicsApplication/custom_elements/solid_shell_element_sprism_3D6N.h @@ -222,7 +222,7 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) SolidShellElementSprism3D6N void GetValuesVector( Vector& rValues, int Step = 0 - ) override; + ) const override; /** * @brief Sets on rValues the nodal velocities @@ -232,7 +232,7 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) SolidShellElementSprism3D6N void GetFirstDerivativesVector( Vector& rValues, int Step = 0 - ) override; + ) const override; /** * @brief Sets on rValues the nodal accelerations @@ -242,7 +242,7 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) SolidShellElementSprism3D6N void GetSecondDerivativesVector( Vector& rValues, int Step = 0 - ) override; + ) const override; /** * @brief This is called during the assembling process in order diff --git a/applications/StructuralMechanicsApplication/custom_elements/spring_damper_element_3D2N.cpp b/applications/StructuralMechanicsApplication/custom_elements/spring_damper_element_3D2N.cpp index 700a7ba293b0..1478f1795d91 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/spring_damper_element_3D2N.cpp +++ b/applications/StructuralMechanicsApplication/custom_elements/spring_damper_element_3D2N.cpp @@ -150,7 +150,7 @@ void SpringDamperElement3D2N::EquationIdVector( EquationIdVectorType& rResult, c //*********************************DISPLACEMENT*************************************** //************************************************************************************ -void SpringDamperElement3D2N::GetValuesVector( Vector& rValues, int Step ) +void SpringDamperElement3D2N::GetValuesVector( Vector& rValues, int Step ) const { //GIVES THE VECTOR WITH THE DOFS VARIABLES OF THE ELEMENT (i.e. ELEMENT DISPLACEMENTS) if ( rValues.size() != msElementSize ) @@ -177,7 +177,7 @@ void SpringDamperElement3D2N::GetValuesVector( Vector& rValues, int Step ) //************************************VELOCITY**************************************** //************************************************************************************ -void SpringDamperElement3D2N::GetFirstDerivativesVector( Vector& rValues, int Step ) +void SpringDamperElement3D2N::GetFirstDerivativesVector( Vector& rValues, int Step ) const { //GIVES THE VECTOR WITH THE TIME DERIVATIVE OF THE DOFS VARIABLES OF THE ELEMENT (i.e. ELEMENT VELOCITIES) if ( rValues.size() != msElementSize ) @@ -202,7 +202,7 @@ void SpringDamperElement3D2N::GetFirstDerivativesVector( Vector& rValues, int St //*********************************ACCELERATION*************************************** //************************************************************************************ -void SpringDamperElement3D2N::GetSecondDerivativesVector( Vector& rValues, int Step ) +void SpringDamperElement3D2N::GetSecondDerivativesVector( Vector& rValues, int Step ) const { //GIVES THE VECTOR WITH THE TIME SECOND DERIVATIVE OF THE DOFS VARIABLES OF THE ELEMENT (i.e. ELEMENT ACCELERATIONS) if ( rValues.size() != msElementSize ) diff --git a/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.cpp b/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.cpp index 8e948c6f44f2..cf59e21b5e98 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.cpp +++ b/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.cpp @@ -191,7 +191,7 @@ TrussElement3D2N::CalculateBodyForces() KRATOS_CATCH("") } -void TrussElement3D2N::GetValuesVector(Vector& rValues, int Step) +void TrussElement3D2N::GetValuesVector(Vector& rValues, int Step) const { KRATOS_TRY @@ -211,7 +211,7 @@ void TrussElement3D2N::GetValuesVector(Vector& rValues, int Step) KRATOS_CATCH("") } -void TrussElement3D2N::GetFirstDerivativesVector(Vector& rValues, int Step) +void TrussElement3D2N::GetFirstDerivativesVector(Vector& rValues, int Step) const { KRATOS_TRY @@ -231,7 +231,7 @@ void TrussElement3D2N::GetFirstDerivativesVector(Vector& rValues, int Step) KRATOS_CATCH("") } -void TrussElement3D2N::GetSecondDerivativesVector(Vector& rValues, int Step) +void TrussElement3D2N::GetSecondDerivativesVector(Vector& rValues, int Step) const { KRATOS_TRY diff --git a/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.hpp b/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.hpp index daa51b89d770..285b6a35690c 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.hpp +++ b/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.hpp @@ -197,15 +197,15 @@ namespace Kratos void GetValuesVector( Vector& rValues, - int Step = 0) override; + int Step = 0) const override; void GetSecondDerivativesVector( Vector& rValues, - int Step = 0) override; + int Step = 0) const override; void GetFirstDerivativesVector( Vector& rValues, - int Step = 0) override; + int Step = 0) const override; int Check( const ProcessInfo& rCurrentProcessInfo) const override; From 33f4473abdce502b4cfbdb0ddb03410df64775b4 Mon Sep 17 00:00:00 2001 From: philbucher Date: Tue, 28 Apr 2020 15:53:44 +0200 Subject: [PATCH 292/314] missing updates --- .../custom_elements/spring_damper_element_3D2N.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/applications/StructuralMechanicsApplication/custom_elements/spring_damper_element_3D2N.hpp b/applications/StructuralMechanicsApplication/custom_elements/spring_damper_element_3D2N.hpp index 41313b359ab5..1ddb7be6ef00 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/spring_damper_element_3D2N.hpp +++ b/applications/StructuralMechanicsApplication/custom_elements/spring_damper_element_3D2N.hpp @@ -122,17 +122,17 @@ class SpringDamperElement3D2N /** * Sets on rValues the nodal displacements */ - void GetValuesVector(Vector& rValues, int Step = 0) override; + void GetValuesVector(Vector& rValues, int Step = 0) const override; /** * Sets on rValues the nodal velocities */ - void GetFirstDerivativesVector(Vector& rValues, int Step = 0) override; + void GetFirstDerivativesVector(Vector& rValues, int Step = 0) const override; /** * Sets on rValues the nodal accelerations */ - void GetSecondDerivativesVector(Vector& rValues, int Step = 0) override; + void GetSecondDerivativesVector(Vector& rValues, int Step = 0) const override; //************* COMPUTING METHODS From 51a6e57c645b6f0663ad337d8394451e313bade7 Mon Sep 17 00:00:00 2001 From: philbucher Date: Tue, 28 Apr 2020 15:57:19 +0200 Subject: [PATCH 293/314] one more const --- .../custom_conditions/base_load_condition.cpp | 2 +- .../custom_conditions/base_load_condition.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/StructuralMechanicsApplication/custom_conditions/base_load_condition.cpp b/applications/StructuralMechanicsApplication/custom_conditions/base_load_condition.cpp index 57f020dffa90..afc712771571 100644 --- a/applications/StructuralMechanicsApplication/custom_conditions/base_load_condition.cpp +++ b/applications/StructuralMechanicsApplication/custom_conditions/base_load_condition.cpp @@ -339,7 +339,7 @@ double BaseLoadCondition::GetIntegrationWeight( void BaseLoadCondition::AddExplicitContribution( const VectorType& rRHS, const Variable& rRHSVariable, - Variable >& rDestinationVariable, + const Variable >& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) { diff --git a/applications/StructuralMechanicsApplication/custom_conditions/base_load_condition.h b/applications/StructuralMechanicsApplication/custom_conditions/base_load_condition.h index 99735b0ede6b..56210a845a70 100644 --- a/applications/StructuralMechanicsApplication/custom_conditions/base_load_condition.h +++ b/applications/StructuralMechanicsApplication/custom_conditions/base_load_condition.h @@ -256,7 +256,7 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) BaseLoadCondition */ void AddExplicitContribution(const VectorType& rRHS, const Variable& rRHSVariable, - Variable >& rDestinationVariable, + const Variable >& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) override; From 87704e246040217115cd86ae9920332afe7de533 Mon Sep 17 00:00:00 2001 From: philbucher Date: Tue, 28 Apr 2020 16:01:02 +0200 Subject: [PATCH 294/314] updated also AddExplicitContribution --- .../custom_elements/base_solid_element.cpp | 4 ++-- .../custom_elements/base_solid_element.h | 4 ++-- .../custom_elements/cr_beam_element_2D2N.cpp | 2 +- .../custom_elements/cr_beam_element_2D2N.hpp | 2 +- .../custom_elements/cr_beam_element_3D2N.cpp | 2 +- .../custom_elements/cr_beam_element_3D2N.hpp | 2 +- .../custom_elements/membrane_element.cpp | 4 ++-- .../custom_elements/membrane_element.hpp | 4 ++-- .../custom_elements/truss_element_3D2N.cpp | 4 ++-- .../custom_elements/truss_element_3D2N.hpp | 4 ++-- .../adjoint_finite_difference_base_element.h | 20 +++++++++---------- 11 files changed, 26 insertions(+), 26 deletions(-) diff --git a/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.cpp b/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.cpp index d2ea09ef6e43..4f91c5f08059 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.cpp +++ b/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.cpp @@ -436,7 +436,7 @@ void BaseSolidElement::GetSecondDerivativesVector( void BaseSolidElement::AddExplicitContribution( const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable& rDestinationVariable, + const Variable& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) { @@ -469,7 +469,7 @@ void BaseSolidElement::AddExplicitContribution( void BaseSolidElement::AddExplicitContribution( const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable>& rDestinationVariable, + const Variable>& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) { diff --git a/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.h b/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.h index df7b0457e438..0a33f3cd20d0 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.h +++ b/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.h @@ -334,7 +334,7 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) BaseSolidElement void AddExplicitContribution( const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable& rDestinationVariable, + const Variable& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) override; @@ -349,7 +349,7 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) BaseSolidElement */ void AddExplicitContribution(const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable >& rDestinationVariable, + const Variable >& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) override; diff --git a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_2D2N.cpp b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_2D2N.cpp index b72a499c6a59..c73f25476f1b 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_2D2N.cpp +++ b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_2D2N.cpp @@ -825,7 +825,7 @@ double CrBeamElement2D2N::Modulus2Pi(double A) const void CrBeamElement2D2N::AddExplicitContribution( const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable>& rDestinationVariable, + const Variable>& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo) { // FORCE- & Moment- Residual is 3D vector diff --git a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_2D2N.hpp b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_2D2N.hpp index b04367bfd245..37dbcc5a2aac 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_2D2N.hpp +++ b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_2D2N.hpp @@ -136,7 +136,7 @@ class CrBeamElement2D2N : public Element void AddExplicitContribution(const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable >& rDestinationVariable, + const Variable >& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo) override; int Check(const ProcessInfo& rCurrentProcessInfo) const override; diff --git a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_3D2N.cpp b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_3D2N.cpp index 5ee83acfc159..57ae8289dc53 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_3D2N.cpp +++ b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_3D2N.cpp @@ -1543,7 +1543,7 @@ CrBeamElement3D2N::GetIntegrationMethod() const void CrBeamElement3D2N::AddExplicitContribution( const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable>& rDestinationVariable, + const Variable>& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) { diff --git a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_3D2N.hpp b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_3D2N.hpp index 4875b2d875cf..28a57ef3de44 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_3D2N.hpp +++ b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_3D2N.hpp @@ -213,7 +213,7 @@ class CrBeamElement3D2N : public Element void AddExplicitContribution(const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable >& rDestinationVariable, + const Variable >& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo) override; void GetValuesVector( diff --git a/applications/StructuralMechanicsApplication/custom_elements/membrane_element.cpp b/applications/StructuralMechanicsApplication/custom_elements/membrane_element.cpp index 2ff2fd007883..0178304af8a7 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/membrane_element.cpp +++ b/applications/StructuralMechanicsApplication/custom_elements/membrane_element.cpp @@ -1036,7 +1036,7 @@ void MembraneElement::CalculateLumpedMassVector(VectorType& rMassVector) void MembraneElement::AddExplicitContribution( const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable& rDestinationVariable, + const Variable& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -1074,7 +1074,7 @@ void MembraneElement::CalculateDampingMatrix( void MembraneElement::AddExplicitContribution( const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable>& rDestinationVariable, + const Variable>& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; diff --git a/applications/StructuralMechanicsApplication/custom_elements/membrane_element.hpp b/applications/StructuralMechanicsApplication/custom_elements/membrane_element.hpp index ee3843e07c7c..b0f7878311bb 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/membrane_element.hpp +++ b/applications/StructuralMechanicsApplication/custom_elements/membrane_element.hpp @@ -129,13 +129,13 @@ namespace Kratos void AddExplicitContribution( const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable>& rDestinationVariable, + const Variable>& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo) override; void AddExplicitContribution( const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable& rDestinationVariable, + const Variable& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo) override; void Calculate(const Variable& rVariable, diff --git a/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.cpp b/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.cpp index cf59e21b5e98..71c4b13451dc 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.cpp +++ b/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.cpp @@ -640,7 +640,7 @@ void TrussElement3D2N::WriteTransformationCoordinates( void TrussElement3D2N::AddExplicitContribution( const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable& rDestinationVariable, + const Variable& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) { @@ -666,7 +666,7 @@ void TrussElement3D2N::AddExplicitContribution( void TrussElement3D2N::AddExplicitContribution( const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable>& rDestinationVariable, + const Variable>& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) { diff --git a/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.hpp b/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.hpp index 285b6a35690c..d41b822bdb8e 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.hpp +++ b/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.hpp @@ -175,7 +175,7 @@ namespace Kratos void AddExplicitContribution( const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable& rDestinationVariable, + const Variable& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) override; @@ -190,7 +190,7 @@ namespace Kratos */ void AddExplicitContribution(const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable >& rDestinationVariable, + const Variable >& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) override; diff --git a/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_finite_difference_base_element.h b/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_finite_difference_base_element.h index ef999640d38b..301df4801cfb 100644 --- a/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_finite_difference_base_element.h +++ b/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_finite_difference_base_element.h @@ -264,15 +264,15 @@ class AdjointFiniteDifferencingBaseElement : public Element mpPrimalElement->CalculateDampingMatrix(rDampingMatrix, rCurrentProcessInfo); } - void AddExplicitContribution(ProcessInfo& rCurrentProcessInfo) override + void AddExplicitContribution(const ProcessInfo& rCurrentProcessInfo) override { mpPrimalElement->AddExplicitContribution(rCurrentProcessInfo); } void AddExplicitContribution(const VectorType& rRHSVector, - const Variable& rRHSVariable, - Variable& rDestinationVariable, - const ProcessInfo& rCurrentProcessInfo) override + const Variable& rRHSVariable, + const Variable& rDestinationVariable, + const ProcessInfo& rCurrentProcessInfo) override { mpPrimalElement->AddExplicitContribution(rRHSVector, rRHSVariable, @@ -281,9 +281,9 @@ class AdjointFiniteDifferencingBaseElement : public Element } void AddExplicitContribution(const VectorType& rRHSVector, - const Variable& rRHSVariable, - Variable >& rDestinationVariable, - const ProcessInfo& rCurrentProcessInfo) override + const Variable& rRHSVariable, + const Variable >& rDestinationVariable, + const ProcessInfo& rCurrentProcessInfo) override { mpPrimalElement->AddExplicitContribution(rRHSVector, rRHSVariable, @@ -292,9 +292,9 @@ class AdjointFiniteDifferencingBaseElement : public Element } void AddExplicitContribution(const MatrixType& rLHSMatrix, - const Variable& rLHSVariable, - Variable& rDestinationVariable, - const ProcessInfo& rCurrentProcessInfo) override + const Variable& rLHSVariable, + const Variable& rDestinationVariable, + const ProcessInfo& rCurrentProcessInfo) override { mpPrimalElement->AddExplicitContribution(rLHSMatrix, rLHSVariable, From 1257a0e557a554541310410eb95648e1fe51efda Mon Sep 17 00:00:00 2001 From: DanielDiez Date: Tue, 28 Apr 2020 17:41:26 +0200 Subject: [PATCH 295/314] add cpp test --- ...st_levelset_convection_element_simplex.cpp | 277 ++++++++++++++++++ 1 file changed, 277 insertions(+) create mode 100644 kratos/tests/cpp_tests/elements/test_levelset_convection_element_simplex.cpp diff --git a/kratos/tests/cpp_tests/elements/test_levelset_convection_element_simplex.cpp b/kratos/tests/cpp_tests/elements/test_levelset_convection_element_simplex.cpp new file mode 100644 index 000000000000..f8aab2dfc8ed --- /dev/null +++ b/kratos/tests/cpp_tests/elements/test_levelset_convection_element_simplex.cpp @@ -0,0 +1,277 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ ` +// _|\_\_| \__,_|\__|\___/ ____/ +// Multi-Physics +// +// License: BSD License +// Kratos default license: kratos/license.txt +// +// Main authors: Daniel Diez +// + +// System includes +#include + +// External includes + +// Project includes +#include "containers/model.h" +#include "testing/testing.h" +#include "elements/levelset_convection_element_simplex.h" + +// Utility includes +#include "utilities/geometry_utilities.h" + +namespace Kratos +{ +namespace Testing +{ + KRATOS_TEST_CASE_IN_SUITE(LevelSetConvectionElement2D, KratosCoreFastSuite) { + Model current_model; + ModelPart& model_part = current_model.CreateModelPart("Main"); + model_part.SetBufferSize(3); + + // Variables addition + model_part.AddNodalSolutionStepVariable(VELOCITY); + model_part.AddNodalSolutionStepVariable(DISTANCE); + + // Process info creation + double delta_time = 0.1; + double cross_wind_diff = 0.5; + model_part.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); + model_part.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + + ConvectionDiffusionSettings::Pointer p_conv_diff_settings = Kratos::make_unique(); + model_part.GetProcessInfo().SetValue(CONVECTION_DIFFUSION_SETTINGS, p_conv_diff_settings); + model_part.GetProcessInfo().SetValue(CROSS_WIND_STABILIZATION_FACTOR, cross_wind_diff); + p_conv_diff_settings->SetUnknownVariable(DISTANCE); + p_conv_diff_settings->SetConvectionVariable(VELOCITY); + + // Set the element properties + Properties::Pointer pElemProp = model_part.CreateNewProperties(0); + + // Geometry creation + model_part.CreateNewNode(1, 0.0, 0.0, 0.0); + model_part.CreateNewNode(2, 1.0, 0.0, 0.0); + model_part.CreateNewNode(3, 0.0, 1.0, 0.0); + std::vector elemNodes {1, 2, 3}; + auto p_element = model_part.CreateNewElement("LevelSetConvectionElementSimplex2D3N", 1, elemNodes, pElemProp); + + // Define the nodal values + Matrix vel_original(3,2); + vel_original(0,0) = 0.0; vel_original(0,1) = 0.1; + vel_original(1,0) = 0.1; vel_original(1,1) = 0.2; + vel_original(2,0) = 0.2; vel_original(2,1) = 0.3; + + for(unsigned int i=0; i<3; i++){ + for(unsigned int k=0; k<2; k++){ + p_element->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i,k); + p_element->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9*vel_original(i,k); + p_element->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75*vel_original(i,k); + } + } + p_element->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; + p_element->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = -1.0; + p_element->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = 0.5; + + p_element->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE,1) = -0.8; + p_element->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE,1) = -0.8; + p_element->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE,1) = 0.7; + + // Compute RHS and LHS + Vector rhs = ZeroVector(4); + Matrix lhs = ZeroMatrix(4,4); + + p_element->Initialize(); + const ProcessInfo& const_process_info = model_part.GetProcessInfo(); + p_element->CalculateLocalSystem(lhs, rhs, const_process_info); + + KRATOS_CHECK_EQUAL(rhs.size(), 3); + KRATOS_CHECK_EQUAL(lhs.size1(), 3); + KRATOS_CHECK_EQUAL(lhs.size2(), 3); + KRATOS_CHECK_NEAR(rhs(0), 0.1186006876 , 1e-7); + KRATOS_CHECK_NEAR(rhs(1), 0.4123679368 , 1e-7); + KRATOS_CHECK_NEAR(rhs(2), 0.3265313756 , 1e-7); + KRATOS_CHECK_NEAR(lhs(0,0), 0.367583692212 , 1e-7); + KRATOS_CHECK_NEAR(lhs(0,1), -0.301736964939 , 1e-7); + KRATOS_CHECK_NEAR(lhs(0,2), -0.336905789443 , 1e-7); + KRATOS_CHECK_NEAR(lhs(1,0), 0.493383924505 , 1e-7); + KRATOS_CHECK_NEAR(lhs(1,1), 1.1281300063 , 1e-7); + KRATOS_CHECK_NEAR(lhs(1,2), 0.677825753415 , 1e-7); + KRATOS_CHECK_NEAR(lhs(2,0), 0.73444904995 , 1e-7); + KRATOS_CHECK_NEAR(lhs(2,1), 0.864023625302 , 1e-7); + KRATOS_CHECK_NEAR(lhs(2,2), 1.37324670269 , 1e-7); + } + + KRATOS_TEST_CASE_IN_SUITE(LevelSetConvectionElement2DImplicit, KratosCoreFastSuite) { + Model current_model; + ModelPart& model_part = current_model.CreateModelPart("Main"); + model_part.SetBufferSize(3); + + // Variables addition + model_part.AddNodalSolutionStepVariable(VELOCITY); + model_part.AddNodalSolutionStepVariable(DISTANCE); + + // Process info creation + double delta_time = 0.1; + double cross_wind_diff = 0.5; + model_part.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); + model_part.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + + ConvectionDiffusionSettings::Pointer p_conv_diff_settings = Kratos::make_unique(); + model_part.GetProcessInfo().SetValue(CONVECTION_DIFFUSION_SETTINGS, p_conv_diff_settings); + model_part.GetProcessInfo().SetValue(CROSS_WIND_STABILIZATION_FACTOR, cross_wind_diff); + model_part.GetProcessInfo().SetValue(TIME_INTEGRATION_THETA, 1.0); + p_conv_diff_settings->SetUnknownVariable(DISTANCE); + p_conv_diff_settings->SetConvectionVariable(VELOCITY); + + // Set the element properties + Properties::Pointer pElemProp = model_part.CreateNewProperties(0); + + // Geometry creation + model_part.CreateNewNode(1, 0.0, 0.0, 0.0); + model_part.CreateNewNode(2, 1.0, 0.0, 0.0); + model_part.CreateNewNode(3, 0.0, 1.0, 0.0); + std::vector elemNodes {1, 2, 3}; + auto p_element = model_part.CreateNewElement("LevelSetConvectionElementSimplex2D3N", 1, elemNodes, pElemProp); + + // Define the nodal values + Matrix vel_original(3,2); + vel_original(0,0) = 0.0; vel_original(0,1) = 0.1; + vel_original(1,0) = 0.1; vel_original(1,1) = 0.2; + vel_original(2,0) = 0.2; vel_original(2,1) = 0.3; + + for(unsigned int i=0; i<3; i++){ + for(unsigned int k=0; k<2; k++){ + p_element->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i,k); + p_element->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9*vel_original(i,k); + p_element->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75*vel_original(i,k); + } + } + p_element->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; + p_element->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = -1.0; + p_element->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = 0.5; + + p_element->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE,1) = -0.8; + p_element->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE,1) = -0.8; + p_element->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE,1) = 0.7; + + // Compute RHS and LHS + Vector rhs = ZeroVector(4); + Matrix lhs = ZeroMatrix(4,4); + + p_element->Initialize(); + const ProcessInfo& const_process_info = model_part.GetProcessInfo(); + p_element->CalculateLocalSystem(lhs, rhs, const_process_info); + + KRATOS_CHECK_EQUAL(rhs.size(), 3); + KRATOS_CHECK_EQUAL(lhs.size1(), 3); + KRATOS_CHECK_EQUAL(lhs.size2(), 3); + KRATOS_CHECK_NEAR(rhs(0), 0.1186006876 , 1e-7); + KRATOS_CHECK_NEAR(rhs(1), 0.4123679368 , 1e-7); + KRATOS_CHECK_NEAR(rhs(2), 0.3265313756 , 1e-7); + KRATOS_CHECK_NEAR(lhs(0,0), 0.490708692212 , 1e-7); + KRATOS_CHECK_NEAR(lhs(0,1), -0.367257798272 , 1e-7); + KRATOS_CHECK_NEAR(lhs(0,2), -0.39450995611 , 1e-7); + KRATOS_CHECK_NEAR(lhs(1,0), 0.398175591172 , 1e-7); + KRATOS_CHECK_NEAR(lhs(1,1), 1.2075050063 , 1e-7); + KRATOS_CHECK_NEAR(lhs(1,2), 0.693659086748 , 1e-7); + KRATOS_CHECK_NEAR(lhs(2,0), 0.635282383283 , 1e-7); + KRATOS_CHECK_NEAR(lhs(2,1), 0.873919458635 , 1e-7); + KRATOS_CHECK_NEAR(lhs(2,2), 1.46251753603 , 1e-7); + } + + KRATOS_TEST_CASE_IN_SUITE(LevelSetConvectionElement3D, KratosCoreFastSuite) { + Model current_model; + ModelPart& model_part = current_model.CreateModelPart("Main"); + model_part.SetBufferSize(3); + + // Variables addition + model_part.AddNodalSolutionStepVariable(VELOCITY); + model_part.AddNodalSolutionStepVariable(DISTANCE); + + // Process info creation + double delta_time = 0.1; + double cross_wind_diff = 0.5; + model_part.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); + model_part.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + + ConvectionDiffusionSettings::Pointer p_conv_diff_settings = Kratos::make_unique(); + model_part.GetProcessInfo().SetValue(CONVECTION_DIFFUSION_SETTINGS, p_conv_diff_settings); + model_part.GetProcessInfo().SetValue(CROSS_WIND_STABILIZATION_FACTOR, cross_wind_diff); + p_conv_diff_settings->SetUnknownVariable(DISTANCE); + p_conv_diff_settings->SetConvectionVariable(VELOCITY); + + // Set the element properties + Properties::Pointer pElemProp = model_part.CreateNewProperties(0); + + // Geometry creation + model_part.CreateNewNode(1, 0.0, 0.0, 0.0); + model_part.CreateNewNode(2, 1.0, 0.0, 0.0); + model_part.CreateNewNode(3, 0.0, 1.0, 0.0); + model_part.CreateNewNode(4, 0.0, 0.0, 1.0); + std::vector elemNodes {1, 2, 3, 4}; + auto p_element = model_part.CreateNewElement("LevelSetConvectionElementSimplex3D4N", 1, elemNodes, pElemProp); + + // Define the nodal values + Matrix vel_original(4,3); + vel_original(0,0) = 0.0; vel_original(0,1) = 0.1; vel_original(0,2) = 0.1; + vel_original(1,0) = 0.1; vel_original(1,1) = 0.2; vel_original(1,2) = 0.2; + vel_original(2,0) = 0.2; vel_original(2,1) = 0.3; vel_original(2,2) = 0.3; + vel_original(3,0) = 0.2; vel_original(3,1) = 0.3; vel_original(3,2) = 0.3; + + for(unsigned int i=0; i<4; i++){ + for(unsigned int k=0; k<3; k++){ + p_element->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i,k); + p_element->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9*vel_original(i,k); + p_element->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75*vel_original(i,k); + } + } + p_element->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; + p_element->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = -1.0; + p_element->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = 0.5; + p_element->GetGeometry()[3].FastGetSolutionStepValue(DISTANCE) = 0.5; + + p_element->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE,1) = -0.8; + p_element->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE,1) = -0.8; + p_element->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE,1) = 0.7; + p_element->GetGeometry()[3].FastGetSolutionStepValue(DISTANCE,1) = 0.7; + + // Compute RHS and LHS + Vector rhs = ZeroVector(5); + Matrix lhs = ZeroMatrix(5,4); + + p_element->Initialize(); + const ProcessInfo& const_process_info = model_part.GetProcessInfo(); + p_element->CalculateLocalSystem(lhs, rhs, const_process_info); + + KRATOS_CHECK_EQUAL(rhs.size(), 4); + KRATOS_CHECK_EQUAL(lhs.size1(), 4); + KRATOS_CHECK_EQUAL(lhs.size2(), 4); + KRATOS_CHECK_NEAR(rhs(0), -0.0191355037271 , 1e-7); + KRATOS_CHECK_NEAR(rhs(1), 0.0913265708816 , 1e-7); + KRATOS_CHECK_NEAR(rhs(2), 0.0771336330894 , 1e-7); + KRATOS_CHECK_NEAR(rhs(3), 0.0771336330894 , 1e-7); + KRATOS_CHECK_NEAR(lhs(0,0), 0.0118217128739 , 1e-7); + KRATOS_CHECK_NEAR(lhs(0,1), -0.124973472054 , 1e-7); + KRATOS_CHECK_NEAR(lhs(0,2), -0.132050658822 , 1e-7); + KRATOS_CHECK_NEAR(lhs(0,3), -0.132050658822 , 1e-7); + KRATOS_CHECK_NEAR(lhs(1,0), 0.0952497205202 , 1e-7); + KRATOS_CHECK_NEAR(lhs(1,1), 0.224296426094 , 1e-7); + KRATOS_CHECK_NEAR(lhs(1,2), 0.133855853867 , 1e-7); + KRATOS_CHECK_NEAR(lhs(1,3), 0.133855853867 , 1e-7); + KRATOS_CHECK_NEAR(lhs(2,0), 0.13203719997 , 1e-7); + KRATOS_CHECK_NEAR(lhs(2,1), 0.16361977298 , 1e-7); + KRATOS_CHECK_NEAR(lhs(2,2), 0.264675745948 , 1e-7); + KRATOS_CHECK_NEAR(lhs(2,3), 0.167998225674 , 1e-7); + KRATOS_CHECK_NEAR(lhs(3,0), 0.13203719997 , 1e-7); + KRATOS_CHECK_NEAR(lhs(3,1), 0.16361977298 , 1e-7); + KRATOS_CHECK_NEAR(lhs(3,2), 0.167998225674 , 1e-7); + KRATOS_CHECK_NEAR(lhs(3,3), 0.264675745948 , 1e-7); + } + + + +} // namespace Testing. +} // namespace Kratos. From 85aebe4d9f22667e0a5d016d40cf9ade657d679a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Tue, 28 Apr 2020 14:31:59 +0200 Subject: [PATCH 296/314] Revert "Revert KM." This reverts commit eb545945025823c093e5b2c1fb65676c2e72da74. --- kratos/tests/test_linear_constraints.py | 254 ++++++++++++------------ 1 file changed, 127 insertions(+), 127 deletions(-) diff --git a/kratos/tests/test_linear_constraints.py b/kratos/tests/test_linear_constraints.py index 317473ad3404..b5f22d774b1d 100644 --- a/kratos/tests/test_linear_constraints.py +++ b/kratos/tests/test_linear_constraints.py @@ -1,7 +1,7 @@ from __future__ import print_function, absolute_import, division # Importing the Kratos Library -import KratosMultiphysics +import KratosMultiphysics as KM import KratosMultiphysics.KratosUnittest as KratosUnittest import KratosMultiphysics.kratos_utilities as KratosUtils import math @@ -20,76 +20,76 @@ def setUp(self): pass def _add_variables(self): - self.mp.AddNodalSolutionStepVariable(KratosMultiphysics.DISPLACEMENT) - self.mp.AddNodalSolutionStepVariable(KratosMultiphysics.REACTION) - self.mp.AddNodalSolutionStepVariable(KratosMultiphysics.VELOCITY) - self.mp.AddNodalSolutionStepVariable(KratosMultiphysics.ACCELERATION) - self.mp.AddNodalSolutionStepVariable(KratosMultiphysics.VOLUME_ACCELERATION) + self.mp.AddNodalSolutionStepVariable(KM.DISPLACEMENT) + self.mp.AddNodalSolutionStepVariable(KM.REACTION) + self.mp.AddNodalSolutionStepVariable(KM.VELOCITY) + self.mp.AddNodalSolutionStepVariable(KM.ACCELERATION) + self.mp.AddNodalSolutionStepVariable(KM.VOLUME_ACCELERATION) def _add_dofs(self): - KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.DISPLACEMENT_X, KratosMultiphysics.REACTION_X, self.mp) - KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.DISPLACEMENT_Y, KratosMultiphysics.REACTION_Y, self.mp) - KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.DISPLACEMENT_Z, KratosMultiphysics.REACTION_Z, self.mp) + KM.VariableUtils().AddDof(KM.DISPLACEMENT_X, KM.REACTION_X, self.mp) + KM.VariableUtils().AddDof(KM.DISPLACEMENT_Y, KM.REACTION_Y, self.mp) + KM.VariableUtils().AddDof(KM.DISPLACEMENT_Z, KM.REACTION_Z, self.mp) - KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.VELOCITY_X, self.mp) - KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.VELOCITY_Y, self.mp) - KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.VELOCITY_Z, self.mp) + KM.VariableUtils().AddDof(KM.VELOCITY_X, self.mp) + KM.VariableUtils().AddDof(KM.VELOCITY_Y, self.mp) + KM.VariableUtils().AddDof(KM.VELOCITY_Z, self.mp) - KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.ACCELERATION_X, self.mp) - KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.ACCELERATION_Y, self.mp) - KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.ACCELERATION_Z, self.mp) + KM.VariableUtils().AddDof(KM.ACCELERATION_X, self.mp) + KM.VariableUtils().AddDof(KM.ACCELERATION_Y, self.mp) + KM.VariableUtils().AddDof(KM.ACCELERATION_Z, self.mp) def _apply_material_properties(self, dim): #define properties - self.mp.GetProperties()[1].SetValue(KratosMultiphysics.YOUNG_MODULUS, 210e9) - self.mp.GetProperties()[1].SetValue(KratosMultiphysics.POISSON_RATIO, 0.3) - self.mp.GetProperties()[1].SetValue(KratosMultiphysics.THICKNESS, 1.0) - self.mp.GetProperties()[1].SetValue(KratosMultiphysics.DENSITY, 1.0) + self.mp.GetProperties()[1].SetValue(KM.YOUNG_MODULUS, 210e9) + self.mp.GetProperties()[1].SetValue(KM.POISSON_RATIO, 0.3) + self.mp.GetProperties()[1].SetValue(KM.THICKNESS, 1.0) + self.mp.GetProperties()[1].SetValue(KM.DENSITY, 1.0) g = [0, 0, 0] - self.mp.GetProperties()[1].SetValue(KratosMultiphysics.VOLUME_ACCELERATION, g) + self.mp.GetProperties()[1].SetValue(KM.VOLUME_ACCELERATION, g) - self.mp.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE] = dim + self.mp.ProcessInfo[KM.DOMAIN_SIZE] = dim if dim == 2: cl = SMA.LinearElasticPlaneStrain2DLaw() else: cl = SMA.LinearElastic3DLaw() - self.mp.GetProperties()[1].SetValue(KratosMultiphysics.CONSTITUTIVE_LAW, cl) + self.mp.GetProperties()[1].SetValue(KM.CONSTITUTIVE_LAW, cl) def _apply_BCs(self): bcs = self.mp.GetSubModelPart("FixedEdgeNodes") - KratosMultiphysics.VariableUtils().SetVariable(KratosMultiphysics.DISPLACEMENT_X, 0.0, bcs.Nodes) - KratosMultiphysics.VariableUtils().SetVariable(KratosMultiphysics.DISPLACEMENT_Y, 0.0, bcs.Nodes) + KM.VariableUtils().SetVariable(KM.DISPLACEMENT_X, 0.0, bcs.Nodes) + KM.VariableUtils().SetVariable(KM.DISPLACEMENT_Y, 0.0, bcs.Nodes) - KratosMultiphysics.VariableUtils().ApplyFixity(KratosMultiphysics.DISPLACEMENT_X, True, bcs.Nodes) - KratosMultiphysics.VariableUtils().ApplyFixity(KratosMultiphysics.DISPLACEMENT_Y, True, bcs.Nodes) + KM.VariableUtils().ApplyFixity(KM.DISPLACEMENT_X, True, bcs.Nodes) + KM.VariableUtils().ApplyFixity(KM.DISPLACEMENT_Y, True, bcs.Nodes) bcmn = self.mp.GetSubModelPart("MovingNodes") - KratosMultiphysics.VariableUtils().SetVariable(KratosMultiphysics.DISPLACEMENT_X, 0.01, bcmn.Nodes) - KratosMultiphysics.VariableUtils().SetVariable(KratosMultiphysics.DISPLACEMENT_Y, 0.0, bcmn.Nodes) - KratosMultiphysics.VariableUtils().ApplyFixity(KratosMultiphysics.DISPLACEMENT_X, True, bcmn.Nodes) - KratosMultiphysics.VariableUtils().ApplyFixity(KratosMultiphysics.DISPLACEMENT_Y, True, bcmn.Nodes) + KM.VariableUtils().SetVariable(KM.DISPLACEMENT_X, 0.01, bcmn.Nodes) + KM.VariableUtils().SetVariable(KM.DISPLACEMENT_Y, 0.0, bcmn.Nodes) + KM.VariableUtils().ApplyFixity(KM.DISPLACEMENT_X, True, bcmn.Nodes) + KM.VariableUtils().ApplyFixity(KM.DISPLACEMENT_Y, True, bcmn.Nodes) def _setup_solver(self, solving_with = "Block", linear_solver = "AMGCL"): #define a minimal newton raphson solver if linear_solver == "AMGCL": - self.linear_solver = KratosMultiphysics.AMGCLSolver() + self.linear_solver = KM.AMGCLSolver() else: - self.linear_solver = KratosMultiphysics.SkylineLUFactorizationSolver() + self.linear_solver = KM.SkylineLUFactorizationSolver() if solving_with == "Block": - self.builder_and_solver = KratosMultiphysics.ResidualBasedBlockBuilderAndSolver(self.linear_solver) + self.builder_and_solver = KM.ResidualBasedBlockBuilderAndSolver(self.linear_solver) else: # Block default - self.builder_and_solver = KratosMultiphysics.ResidualBasedBlockBuilderAndSolver(self.linear_solver) - self.scheme = KratosMultiphysics.ResidualBasedBossakDisplacementScheme(-0.01) - self.convergence_criterion = KratosMultiphysics.ResidualCriteria(1e-6, 1e-9) + self.builder_and_solver = KM.ResidualBasedBlockBuilderAndSolver(self.linear_solver) + self.scheme = KM.ResidualBasedBossakDisplacementScheme(-0.01) + self.convergence_criterion = KM.ResidualCriteria(1e-6, 1e-9) self.convergence_criterion.SetEchoLevel(0) max_iters = 10 compute_reactions = True reform_step_dofs = True move_mesh_flag = False - self.strategy = KratosMultiphysics.ResidualBasedNewtonRaphsonStrategy(self.mp, self.scheme, self.linear_solver, self.convergence_criterion, self.builder_and_solver, max_iters, compute_reactions, reform_step_dofs, move_mesh_flag) + self.strategy = KM.ResidualBasedNewtonRaphsonStrategy(self.mp, self.scheme, self.linear_solver, self.convergence_criterion, self.builder_and_solver, max_iters, compute_reactions, reform_step_dofs, move_mesh_flag) self.strategy.SetEchoLevel(0) self.strategy.Initialize() @@ -106,93 +106,93 @@ def _solve(self): self.strategy.Solve() def _basic_check_results(self): - reactionx1 = self.mp.Nodes[1].GetSolutionStepValue(KratosMultiphysics.REACTION_X, 0) + reactionx1 = self.mp.Nodes[1].GetSolutionStepValue(KM.REACTION_X, 0) self.assertLessEqual(abs((reactionx1 - -1413464323.8223937)/(-1413464323.8223937)), 1.0e-2) - reactiony1 = self.mp.Nodes[1].GetSolutionStepValue(KratosMultiphysics.REACTION_Y, 0) + reactiony1 = self.mp.Nodes[1].GetSolutionStepValue(KM.REACTION_Y, 0) self.assertLessEqual(abs((reactiony1 - -605769230.7692306)/(-605769230.7692306)), 1.0e-2) - reactionx4 = self.mp.Nodes[4].GetSolutionStepValue(KratosMultiphysics.REACTION_X, 0) + reactionx4 = self.mp.Nodes[4].GetSolutionStepValue(KM.REACTION_X, 0) self.assertLessEqual(abs((reactionx4 - -1413467109.1832492)/(-1413467109.1832492)), 1.0e-2) - reactiony4 = self.mp.Nodes[4].GetSolutionStepValue(KratosMultiphysics.REACTION_Y, 0) + reactiony4 = self.mp.Nodes[4].GetSolutionStepValue(KM.REACTION_Y, 0) self.assertLessEqual(abs((reactiony4 - 605769230.7692306)/(605769230.7692306)), 1.0e-2) - dispx3 = self.mp.Nodes[3].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) + dispx3 = self.mp.Nodes[3].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) self.assertAlmostEqual(dispx3, 0.01, 4) - dispy3 = self.mp.Nodes[3].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) + dispy3 = self.mp.Nodes[3].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) self.assertAlmostEqual(dispy3, 0.0, 4) - dispx2 = self.mp.Nodes[2].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) + dispx2 = self.mp.Nodes[2].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) self.assertAlmostEqual(dispx2, 0.01, 4) - dispy2 = self.mp.Nodes[2].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) + dispy2 = self.mp.Nodes[2].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) self.assertAlmostEqual(dispy2, 0.0, 4) - dispx3 = self.mp.Nodes[3].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) + dispx3 = self.mp.Nodes[3].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) self.assertAlmostEqual(dispx3, 0.01, 4) - dispy3 = self.mp.Nodes[3].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) + dispy3 = self.mp.Nodes[3].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) self.assertAlmostEqual(dispy3, 0.0, 4) def _advanced_check_results(self): - dispx13 = self.mp.Nodes[13].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) + dispx13 = self.mp.Nodes[13].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) self.assertAlmostEqual(dispx13, 0.01, 4) - dispy13 = self.mp.Nodes[13].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) + dispy13 = self.mp.Nodes[13].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) self.assertAlmostEqual(dispy13, 0.0, 4) - dispx14 = self.mp.Nodes[14].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) + dispx14 = self.mp.Nodes[14].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) self.assertAlmostEqual(dispx14, 0.01, 4) - dispy14 = self.mp.Nodes[14].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) + dispy14 = self.mp.Nodes[14].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) self.assertAlmostEqual(dispy14, 0.0, 4) - dispx15 = self.mp.Nodes[15].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) + dispx15 = self.mp.Nodes[15].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) self.assertAlmostEqual(dispx15, 0.01, 4) - dispy15 = self.mp.Nodes[15].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) + dispy15 = self.mp.Nodes[15].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) self.assertAlmostEqual(dispy15, 0.0, 4) - dispx11 = self.mp.Nodes[11].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) + dispx11 = self.mp.Nodes[11].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) self.assertAlmostEqual(dispx11, 0.0077238, 4) - dispy11 = self.mp.Nodes[11].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) + dispy11 = self.mp.Nodes[11].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) self.assertAlmostEqual(dispy11, 0.0, 4) - dispx4 = self.mp.Nodes[4].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) + dispx4 = self.mp.Nodes[4].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) self.assertAlmostEqual(dispx4, 0.0022754, 4) - dispy4 = self.mp.Nodes[4].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) + dispy4 = self.mp.Nodes[4].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) self.assertAlmostEqual(dispy4, 0.0, 4) - disp1 = self.mp.Nodes[16].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) - disp2 = self.mp.Nodes[6].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) + disp1 = self.mp.Nodes[16].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) + disp2 = self.mp.Nodes[6].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) self.assertAlmostEqual(disp1, disp2, 4) self.assertAlmostEqual(disp1, 0.0049994, 4) self.assertAlmostEqual(disp2, 0.0049994, 4) #print("Test 1 :: ", disp1," == ",disp2) - disp1 = self.mp.Nodes[16].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) - disp2 = self.mp.Nodes[6].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) + disp1 = self.mp.Nodes[16].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) + disp2 = self.mp.Nodes[6].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) self.assertAlmostEqual(disp1, disp2, 5) self.assertAlmostEqual(disp1, -0.0011584, 4) self.assertAlmostEqual(disp1, -0.0011584, 4) #print("Test 2 :: ", disp1," == ",disp2) - disp1 = self.mp.Nodes[7].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) - disp2 = self.mp.Nodes[17].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) + disp1 = self.mp.Nodes[7].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) + disp2 = self.mp.Nodes[17].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) self.assertAlmostEqual(disp1, disp2, 4) self.assertAlmostEqual(disp1, 0.0049994, 4) self.assertAlmostEqual(disp2, 0.0049994, 4) #print("Test 3 :: ", disp1," == ",disp2) - disp1 = self.mp.Nodes[7].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) - disp2 = self.mp.Nodes[17].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) + disp1 = self.mp.Nodes[7].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) + disp2 = self.mp.Nodes[17].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) self.assertAlmostEqual(disp1, disp2, 4) #print("Test 4 :: ", disp1," == ",disp2) - disp1 = self.mp.Nodes[18].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) - disp2 = self.mp.Nodes[9].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_X, 0) + disp1 = self.mp.Nodes[18].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) + disp2 = self.mp.Nodes[9].GetSolutionStepValue(KM.DISPLACEMENT_X, 0) self.assertAlmostEqual(disp1, disp2, 4) self.assertAlmostEqual(disp1, 0.0049994, 4) self.assertAlmostEqual(disp1, 0.0049994, 4) #print("Test 5 :: ", disp1," == ",disp2) - disp1 = self.mp.Nodes[18].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) - disp2 = self.mp.Nodes[9].GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT_Y, 0) + disp1 = self.mp.Nodes[18].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) + disp2 = self.mp.Nodes[9].GetSolutionStepValue(KM.DISPLACEMENT_Y, 0) self.assertAlmostEqual(disp1, disp2, 4) self.assertAlmostEqual(disp1, 0.0011584, 4) self.assertAlmostEqual(disp1, 0.0011584, 4) @@ -254,42 +254,42 @@ def _advanced_setup_model_part(self): self.mp.CreateNewElement("SmallDisplacementElement2D4N", 8, [8, 9, 7, 4], self.mp.GetProperties()[1]) def _basic_apply_mpc_constraints(self): - self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 1, self.mp.Nodes[2], KratosMultiphysics.DISPLACEMENT_X, self.mp.Nodes[3], KratosMultiphysics.DISPLACEMENT_X, 1.0, 0) - self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 2, self.mp.Nodes[2], KratosMultiphysics.DISPLACEMENT_Y, self.mp.Nodes[3], KratosMultiphysics.DISPLACEMENT_Y, 1.0, 0) + self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 1, self.mp.Nodes[2], KM.DISPLACEMENT_X, self.mp.Nodes[3], KM.DISPLACEMENT_X, 1.0, 0) + self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 2, self.mp.Nodes[2], KM.DISPLACEMENT_Y, self.mp.Nodes[3], KM.DISPLACEMENT_Y, 1.0, 0) def _advanced_apply_mpc_constraints(self): - self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 2, self.mp.Nodes[16], KratosMultiphysics.DISPLACEMENT_X, self.mp.Nodes[6], KratosMultiphysics.DISPLACEMENT_X, 1.0, 0) - self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 1, self.mp.Nodes[16], KratosMultiphysics.DISPLACEMENT_Y, self.mp.Nodes[6], KratosMultiphysics.DISPLACEMENT_Y, 1.0, 0) + self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 2, self.mp.Nodes[16], KM.DISPLACEMENT_X, self.mp.Nodes[6], KM.DISPLACEMENT_X, 1.0, 0) + self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 1, self.mp.Nodes[16], KM.DISPLACEMENT_Y, self.mp.Nodes[6], KM.DISPLACEMENT_Y, 1.0, 0) - self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 3, self.mp.Nodes[17], KratosMultiphysics.DISPLACEMENT_X, self.mp.Nodes[7], KratosMultiphysics.DISPLACEMENT_X, 1.0, 0) - self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 4, self.mp.Nodes[17], KratosMultiphysics.DISPLACEMENT_Y, self.mp.Nodes[7], KratosMultiphysics.DISPLACEMENT_Y, 1.0, 0) + self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 3, self.mp.Nodes[17], KM.DISPLACEMENT_X, self.mp.Nodes[7], KM.DISPLACEMENT_X, 1.0, 0) + self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 4, self.mp.Nodes[17], KM.DISPLACEMENT_Y, self.mp.Nodes[7], KM.DISPLACEMENT_Y, 1.0, 0) - self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 5, self.mp.Nodes[18], KratosMultiphysics.DISPLACEMENT_X, self.mp.Nodes[9], KratosMultiphysics.DISPLACEMENT_X, 1.0, 0) - self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 6, self.mp.Nodes[18], KratosMultiphysics.DISPLACEMENT_Y, self.mp.Nodes[9], KratosMultiphysics.DISPLACEMENT_Y, 1.0, 0) + self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 5, self.mp.Nodes[18], KM.DISPLACEMENT_X, self.mp.Nodes[9], KM.DISPLACEMENT_X, 1.0, 0) + self.mp.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 6, self.mp.Nodes[18], KM.DISPLACEMENT_Y, self.mp.Nodes[9], KM.DISPLACEMENT_Y, 1.0, 0) def _set_and_fill_buffer(self, buffer_size, delta_time): # Set buffer size self.mp.SetBufferSize(buffer_size) # Fill buffer - time = self.mp.ProcessInfo[KratosMultiphysics.TIME] + time = self.mp.ProcessInfo[KM.TIME] time = time - delta_time * (buffer_size) - self.mp.ProcessInfo.SetValue(KratosMultiphysics.TIME, time) + self.mp.ProcessInfo.SetValue(KM.TIME, time) for size in range(0, buffer_size): step = size - (buffer_size - 1) - self.mp.ProcessInfo.SetValue(KratosMultiphysics.STEP, step) + self.mp.ProcessInfo.SetValue(KM.STEP, step) time = time + delta_time #delta_time is computed from previous time in process_info self.mp.CloneTimeStep(time) - self.mp.ProcessInfo[KratosMultiphysics.IS_RESTARTED] = False + self.mp.ProcessInfo[KM.IS_RESTARTED] = False def _basic_setup_test(self, solving_with = "Block", linear_solver = "AMGCL"): dim = 2 - current_model = KratosMultiphysics.Model() + current_model = KM.Model() self.mp= current_model.CreateModelPart("MainModelPart") - self.mp.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE] = dim + self.mp.ProcessInfo[KM.DOMAIN_SIZE] = dim self._add_variables() self._basic_setup_model_part() self._add_dofs() @@ -320,7 +320,7 @@ def _basic_setup_test(self, solving_with = "Block", linear_solver = "AMGCL"): def _advanced_setup_test(self, solving_with = "Block", linear_solver = "AMGCL"): dim = 2 - current_model = KratosMultiphysics.Model() + current_model = KM.Model() self.mp= current_model.CreateModelPart("MainModelPart") self._add_variables() self._advanced_setup_model_part() @@ -363,38 +363,38 @@ def setUp(self): pass def _add_variables(self,mp): - mp.AddNodalSolutionStepVariable(KratosMultiphysics.DISPLACEMENT) - mp.AddNodalSolutionStepVariable(KratosMultiphysics.REACTION) - mp.AddNodalSolutionStepVariable(KratosMultiphysics.VOLUME_ACCELERATION) + mp.AddNodalSolutionStepVariable(KM.DISPLACEMENT) + mp.AddNodalSolutionStepVariable(KM.REACTION) + mp.AddNodalSolutionStepVariable(KM.VOLUME_ACCELERATION) def _apply_material_properties(self, mp, dim, small_strain = True): #define properties - mp.GetProperties()[1].SetValue(KratosMultiphysics.YOUNG_MODULUS,210) - mp.GetProperties()[1].SetValue(KratosMultiphysics.POISSON_RATIO,0.3) - mp.GetProperties()[1].SetValue(KratosMultiphysics.THICKNESS,1.0) - mp.GetProperties()[1].SetValue(KratosMultiphysics.DENSITY,1.0) + mp.GetProperties()[1].SetValue(KM.YOUNG_MODULUS,210) + mp.GetProperties()[1].SetValue(KM.POISSON_RATIO,0.3) + mp.GetProperties()[1].SetValue(KM.THICKNESS,1.0) + mp.GetProperties()[1].SetValue(KM.DENSITY,1.0) g = [0,-10.0,0] - mp.GetProperties()[1].SetValue(KratosMultiphysics.VOLUME_ACCELERATION,g) + mp.GetProperties()[1].SetValue(KM.VOLUME_ACCELERATION,g) cl = SMA.LinearElasticPlaneStrain2DLaw() - mp.GetProperties()[1].SetValue(KratosMultiphysics.CONSTITUTIVE_LAW,cl) + mp.GetProperties()[1].SetValue(KM.CONSTITUTIVE_LAW,cl) def _set_buffer(self,mp): buffer_size = 3 mp.SetBufferSize(buffer_size) # Cycle the buffer. This sets all historical nodal solution step data to # the current value and initializes the time stepping in the process info. - mp.ProcessInfo[KratosMultiphysics.DELTA_TIME] = 1.0 - delta_time = mp.ProcessInfo[KratosMultiphysics.DELTA_TIME] - time = mp.ProcessInfo[KratosMultiphysics.TIME] + mp.ProcessInfo[KM.DELTA_TIME] = 1.0 + delta_time = mp.ProcessInfo[KM.DELTA_TIME] + time = mp.ProcessInfo[KM.TIME] step =-buffer_size time = time - delta_time * buffer_size - mp.ProcessInfo.SetValue(KratosMultiphysics.TIME, time) + mp.ProcessInfo.SetValue(KM.TIME, time) for i in range(0, buffer_size): step = step + 1 time = time + delta_time - mp.ProcessInfo.SetValue(KratosMultiphysics.STEP, step) + mp.ProcessInfo.SetValue(KM.STEP, step) mp.CloneTimeStep(time) def _apply_BCs(self,mp,A,b): @@ -402,10 +402,10 @@ def _apply_BCs(self,mp,A,b): def _create_strategy(self, mp): #define a minimal newton raphson solver - linear_solver = KratosMultiphysics.SkylineLUFactorizationSolver() - builder_and_solver = KratosMultiphysics.ResidualBasedBlockBuilderAndSolver(linear_solver) - scheme = KratosMultiphysics.ResidualBasedIncrementalUpdateStaticScheme() - convergence_criterion = KratosMultiphysics.DisplacementCriteria(1e-13,1e-14) + linear_solver = KM.SkylineLUFactorizationSolver() + builder_and_solver = KM.ResidualBasedBlockBuilderAndSolver(linear_solver) + scheme = KM.ResidualBasedIncrementalUpdateStaticScheme() + convergence_criterion = KM.DisplacementCriteria(1e-13,1e-14) convergence_criterion.SetEchoLevel(0) #max_iters = 1 @@ -413,7 +413,7 @@ def _create_strategy(self, mp): compute_reactions = True reform_step_dofs = True move_mesh_flag = True - strategy = KratosMultiphysics.ResidualBasedNewtonRaphsonStrategy(mp, + strategy = KM.ResidualBasedNewtonRaphsonStrategy(mp, scheme, linear_solver, convergence_criterion, @@ -438,7 +438,7 @@ def _solve_with_strategy(self, strategy, step): def test_constraints(self): dim = 2 - current_model = KratosMultiphysics.Model() + current_model = KM.Model() mp = current_model.CreateModelPart("tl_solid_part") self._add_variables(mp) @@ -454,29 +454,29 @@ def test_constraints(self): n3 = mp.CreateNewNode(3, 0.0, 2.0, 0.0) n4 = mp.CreateNewNode(4, -2.0, 1.0, 0.0) - KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.DISPLACEMENT_X, KratosMultiphysics.REACTION_X,mp) - KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.DISPLACEMENT_Y, KratosMultiphysics.REACTION_Y,mp) - KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.DISPLACEMENT_Z, KratosMultiphysics.REACTION_Z,mp) + KM.VariableUtils().AddDof(KM.DISPLACEMENT_X, KM.REACTION_X,mp) + KM.VariableUtils().AddDof(KM.DISPLACEMENT_Y, KM.REACTION_Y,mp) + KM.VariableUtils().AddDof(KM.DISPLACEMENT_Z, KM.REACTION_Z,mp) mp.CreateNewElement("TotalLagrangianElement2D4N", 1, [1,2,3,4], mp.GetProperties()[1]) #node 1 is completely fixed - n1.Fix(KratosMultiphysics.DISPLACEMENT_X) - n1.Fix(KratosMultiphysics.DISPLACEMENT_Y) + n1.Fix(KM.DISPLACEMENT_X) + n1.Fix(KM.DISPLACEMENT_Y) ################# apply a constraint on node 2 #node2 is at allowed to slide normally to normal2 (taken as normal to the side 1-2) dx = n2.X - n1.X dy = n2.Y - n1.Y - normal_2 = KratosMultiphysics.Array3([dy,-dx,0])/math.sqrt(dx**2+dy**2) + normal_2 = KM.Array3([dy,-dx,0])/math.sqrt(dx**2+dy**2) inner_prod(normal_2,normal_2) - master_dofs_2 = [n2.GetDof(KratosMultiphysics.DISPLACEMENT_Y)] - slave_dofs_2 = [n2.GetDof(KratosMultiphysics.DISPLACEMENT_X)] - RelationMatrix2 = KratosMultiphysics.Matrix(1,1) + master_dofs_2 = [n2.GetDof(KM.DISPLACEMENT_Y)] + slave_dofs_2 = [n2.GetDof(KM.DISPLACEMENT_X)] + RelationMatrix2 = KM.Matrix(1,1) RelationMatrix2[0,0] = -normal_2[1]/normal_2[0] - ConstantVector = KratosMultiphysics.Vector([0.0]) + ConstantVector = KM.Vector([0.0]) - constraint_2 = KratosMultiphysics.LinearMasterSlaveConstraint(2, + constraint_2 = KM.LinearMasterSlaveConstraint(2, master_dofs_2, slave_dofs_2, @@ -489,13 +489,13 @@ def test_constraints(self): #node4 is at allowed to slide normally to normal4 dx = n1.X - n4.X dy = n1.Y - n4.Y - normal_4 = KratosMultiphysics.Array3([dy,-dx,0])/math.sqrt(dx**2+dy**2) - n4.SetValue(KratosMultiphysics.NORMAL, normal_4) #artificially set the normal + normal_4 = KM.Array3([dy,-dx,0])/math.sqrt(dx**2+dy**2) + n4.SetValue(KM.NORMAL, normal_4) #artificially set the normal - constraint_4 = KratosMultiphysics.SlipConstraint(4, - n4.GetDof(KratosMultiphysics.DISPLACEMENT_X), - n4.GetDof(KratosMultiphysics.DISPLACEMENT_Y), - n4.GetValue(KratosMultiphysics.NORMAL) + constraint_4 = KM.SlipConstraint(4, + n4.GetDof(KM.DISPLACEMENT_X), + n4.GetDof(KM.DISPLACEMENT_Y), + n4.GetValue(KM.NORMAL) ) mp.AddMasterSlaveConstraint(constraint_4) @@ -504,17 +504,17 @@ def test_constraints(self): self._solve_with_strategy(strategy,0) ##verify the results - d2 = n2.GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT) - d3 = n3.GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT) - d4 = n4.GetSolutionStepValue(KratosMultiphysics.DISPLACEMENT) + d2 = n2.GetSolutionStepValue(KM.DISPLACEMENT) + d3 = n3.GetSolutionStepValue(KM.DISPLACEMENT) + d4 = n4.GetSolutionStepValue(KM.DISPLACEMENT) self.assertAlmostEqual(d2[0]*normal_2[0] + d2[1]*normal_2[1],0.0, 15) self.assertAlmostEqual(d4[0]*normal_4[0] + d4[1]*normal_4[1],0.0, 15) self.assertAlmostEqual(d3[0], 0.0, 15) #symmetry condition self.assertAlmostEqual(d3[1], 2.0*d2[1], 15) - R2 = n2.GetSolutionStepValue(KratosMultiphysics.REACTION) - R4 = n4.GetSolutionStepValue(KratosMultiphysics.REACTION) + R2 = n2.GetSolutionStepValue(KM.REACTION) + R4 = n4.GetSolutionStepValue(KM.REACTION) nR2 = inner_prod(normal_2, R2) nR4 = inner_prod(normal_4, R4) @@ -530,7 +530,7 @@ def test_constraints(self): self.assertTrue(tang_2.norm_2() < 1e-12) self.assertTrue(tang_4.norm_2() < 1e-12) - self.assertEqual(mp.ProcessInfo[KratosMultiphysics.NL_ITERATION_NUMBER], 5) #4 if using Residual Criteria + self.assertEqual(mp.ProcessInfo[KM.NL_ITERATION_NUMBER], 5) #4 if using Residual Criteria if __name__ == '__main__': KratosUnittest.main() From f5e3f04315ec8ddb1a62e6920fa3d28328305c23 Mon Sep 17 00:00:00 2001 From: DanielDiez Date: Wed, 29 Apr 2020 09:59:47 +0200 Subject: [PATCH 297/314] use vector-matrix check macros --- ...st_levelset_convection_element_simplex.cpp | 108 ++++++++++-------- 1 file changed, 60 insertions(+), 48 deletions(-) diff --git a/kratos/tests/cpp_tests/elements/test_levelset_convection_element_simplex.cpp b/kratos/tests/cpp_tests/elements/test_levelset_convection_element_simplex.cpp index f8aab2dfc8ed..1fa7b289c76c 100644 --- a/kratos/tests/cpp_tests/elements/test_levelset_convection_element_simplex.cpp +++ b/kratos/tests/cpp_tests/elements/test_levelset_convection_element_simplex.cpp @@ -81,27 +81,32 @@ namespace Testing // Compute RHS and LHS Vector rhs = ZeroVector(4); + Vector rhs_reference = ZeroVector(3); Matrix lhs = ZeroMatrix(4,4); + Matrix lhs_reference = ZeroMatrix(3,3); - p_element->Initialize(); const ProcessInfo& const_process_info = model_part.GetProcessInfo(); + p_element->Initialize(const_process_info); p_element->CalculateLocalSystem(lhs, rhs, const_process_info); + KRATOS_CHECK_EQUAL(rhs.size(), 3); KRATOS_CHECK_EQUAL(lhs.size1(), 3); KRATOS_CHECK_EQUAL(lhs.size2(), 3); - KRATOS_CHECK_NEAR(rhs(0), 0.1186006876 , 1e-7); - KRATOS_CHECK_NEAR(rhs(1), 0.4123679368 , 1e-7); - KRATOS_CHECK_NEAR(rhs(2), 0.3265313756 , 1e-7); - KRATOS_CHECK_NEAR(lhs(0,0), 0.367583692212 , 1e-7); - KRATOS_CHECK_NEAR(lhs(0,1), -0.301736964939 , 1e-7); - KRATOS_CHECK_NEAR(lhs(0,2), -0.336905789443 , 1e-7); - KRATOS_CHECK_NEAR(lhs(1,0), 0.493383924505 , 1e-7); - KRATOS_CHECK_NEAR(lhs(1,1), 1.1281300063 , 1e-7); - KRATOS_CHECK_NEAR(lhs(1,2), 0.677825753415 , 1e-7); - KRATOS_CHECK_NEAR(lhs(2,0), 0.73444904995 , 1e-7); - KRATOS_CHECK_NEAR(lhs(2,1), 0.864023625302 , 1e-7); - KRATOS_CHECK_NEAR(lhs(2,2), 1.37324670269 , 1e-7); + rhs_reference[0] = 0.1186006876; + rhs_reference[1] = 0.4123679368; + rhs_reference[2] = 0.3265313756; + lhs_reference(0,0) = 0.367583692212; + lhs_reference(0,1) = -0.301736964939; + lhs_reference(0,2) = -0.336905789443; + lhs_reference(1,0) = 0.493383924505; + lhs_reference(1,1) = 1.1281300063; + lhs_reference(1,2) = 0.677825753415; + lhs_reference(2,0) = 0.73444904995; + lhs_reference(2,1) = 0.864023625302; + lhs_reference(2,2) = 1.37324670269; + KRATOS_CHECK_VECTOR_NEAR(rhs,rhs_reference, 1e-7); + KRATOS_CHECK_MATRIX_NEAR(lhs,lhs_reference, 1e-7); } KRATOS_TEST_CASE_IN_SUITE(LevelSetConvectionElement2DImplicit, KratosCoreFastSuite) { @@ -159,27 +164,31 @@ namespace Testing // Compute RHS and LHS Vector rhs = ZeroVector(4); + Vector rhs_reference = ZeroVector(3); Matrix lhs = ZeroMatrix(4,4); + Matrix lhs_reference = ZeroMatrix(3,3); - p_element->Initialize(); const ProcessInfo& const_process_info = model_part.GetProcessInfo(); + p_element->Initialize(const_process_info); p_element->CalculateLocalSystem(lhs, rhs, const_process_info); KRATOS_CHECK_EQUAL(rhs.size(), 3); KRATOS_CHECK_EQUAL(lhs.size1(), 3); KRATOS_CHECK_EQUAL(lhs.size2(), 3); - KRATOS_CHECK_NEAR(rhs(0), 0.1186006876 , 1e-7); - KRATOS_CHECK_NEAR(rhs(1), 0.4123679368 , 1e-7); - KRATOS_CHECK_NEAR(rhs(2), 0.3265313756 , 1e-7); - KRATOS_CHECK_NEAR(lhs(0,0), 0.490708692212 , 1e-7); - KRATOS_CHECK_NEAR(lhs(0,1), -0.367257798272 , 1e-7); - KRATOS_CHECK_NEAR(lhs(0,2), -0.39450995611 , 1e-7); - KRATOS_CHECK_NEAR(lhs(1,0), 0.398175591172 , 1e-7); - KRATOS_CHECK_NEAR(lhs(1,1), 1.2075050063 , 1e-7); - KRATOS_CHECK_NEAR(lhs(1,2), 0.693659086748 , 1e-7); - KRATOS_CHECK_NEAR(lhs(2,0), 0.635282383283 , 1e-7); - KRATOS_CHECK_NEAR(lhs(2,1), 0.873919458635 , 1e-7); - KRATOS_CHECK_NEAR(lhs(2,2), 1.46251753603 , 1e-7); + rhs_reference[0] = 0.1186006876; + rhs_reference[1] = 0.4123679368; + rhs_reference[2] = 0.3265313756; + lhs_reference(0,0) = 0.490708692212; + lhs_reference(0,1) = -0.367257798272; + lhs_reference(0,2) = -0.39450995611; + lhs_reference(1,0) = 0.398175591172; + lhs_reference(1,1) = 1.2075050063; + lhs_reference(1,2) = 0.693659086748; + lhs_reference(2,0) = 0.635282383283; + lhs_reference(2,1) = 0.873919458635; + lhs_reference(2,2) = 1.46251753603; + KRATOS_CHECK_VECTOR_NEAR(rhs,rhs_reference, 1e-7); + KRATOS_CHECK_MATRIX_NEAR(lhs,lhs_reference, 1e-7); } KRATOS_TEST_CASE_IN_SUITE(LevelSetConvectionElement3D, KratosCoreFastSuite) { @@ -240,37 +249,40 @@ namespace Testing // Compute RHS and LHS Vector rhs = ZeroVector(5); + Vector rhs_reference = ZeroVector(4); Matrix lhs = ZeroMatrix(5,4); + Matrix lhs_reference = ZeroMatrix(4,4); - p_element->Initialize(); const ProcessInfo& const_process_info = model_part.GetProcessInfo(); + p_element->Initialize(const_process_info); p_element->CalculateLocalSystem(lhs, rhs, const_process_info); KRATOS_CHECK_EQUAL(rhs.size(), 4); KRATOS_CHECK_EQUAL(lhs.size1(), 4); KRATOS_CHECK_EQUAL(lhs.size2(), 4); - KRATOS_CHECK_NEAR(rhs(0), -0.0191355037271 , 1e-7); - KRATOS_CHECK_NEAR(rhs(1), 0.0913265708816 , 1e-7); - KRATOS_CHECK_NEAR(rhs(2), 0.0771336330894 , 1e-7); - KRATOS_CHECK_NEAR(rhs(3), 0.0771336330894 , 1e-7); - KRATOS_CHECK_NEAR(lhs(0,0), 0.0118217128739 , 1e-7); - KRATOS_CHECK_NEAR(lhs(0,1), -0.124973472054 , 1e-7); - KRATOS_CHECK_NEAR(lhs(0,2), -0.132050658822 , 1e-7); - KRATOS_CHECK_NEAR(lhs(0,3), -0.132050658822 , 1e-7); - KRATOS_CHECK_NEAR(lhs(1,0), 0.0952497205202 , 1e-7); - KRATOS_CHECK_NEAR(lhs(1,1), 0.224296426094 , 1e-7); - KRATOS_CHECK_NEAR(lhs(1,2), 0.133855853867 , 1e-7); - KRATOS_CHECK_NEAR(lhs(1,3), 0.133855853867 , 1e-7); - KRATOS_CHECK_NEAR(lhs(2,0), 0.13203719997 , 1e-7); - KRATOS_CHECK_NEAR(lhs(2,1), 0.16361977298 , 1e-7); - KRATOS_CHECK_NEAR(lhs(2,2), 0.264675745948 , 1e-7); - KRATOS_CHECK_NEAR(lhs(2,3), 0.167998225674 , 1e-7); - KRATOS_CHECK_NEAR(lhs(3,0), 0.13203719997 , 1e-7); - KRATOS_CHECK_NEAR(lhs(3,1), 0.16361977298 , 1e-7); - KRATOS_CHECK_NEAR(lhs(3,2), 0.167998225674 , 1e-7); - KRATOS_CHECK_NEAR(lhs(3,3), 0.264675745948 , 1e-7); + rhs_reference[0] = -0.0191355037271; + rhs_reference[1] = 0.0913265708816; + rhs_reference[2] = 0.0771336330894; + rhs_reference[3] = 0.0771336330894; + lhs_reference(0,0) = 0.0118217128739; + lhs_reference(0,1) = -0.124973472054; + lhs_reference(0,2) = -0.132050658822; + lhs_reference(0,3) = -0.132050658822; + lhs_reference(1,0) = 0.0952497205202; + lhs_reference(1,1) = 0.224296426094; + lhs_reference(1,2) = 0.133855853867; + lhs_reference(1,3) = 0.133855853867; + lhs_reference(2,0) = 0.13203719997; + lhs_reference(2,1) = 0.16361977298; + lhs_reference(2,2) = 0.264675745948; + lhs_reference(2,3) = 0.167998225674; + lhs_reference(3,0) = 0.13203719997; + lhs_reference(3,1) = 0.16361977298; + lhs_reference(3,2) = 0.167998225674; + lhs_reference(3,3) = 0.264675745948; + KRATOS_CHECK_VECTOR_NEAR(rhs,rhs_reference, 1e-7); + KRATOS_CHECK_MATRIX_NEAR(lhs,lhs_reference, 1e-7); } - } // namespace Testing. From c00776f7e76cf0de559cd82bc54049463ba02d73 Mon Sep 17 00:00:00 2001 From: eloisabaez Date: Wed, 29 Apr 2020 10:45:38 +0200 Subject: [PATCH 298/314] std::sqrt added --- .../custom_utilities/potential_flow_utilities.cpp | 8 ++++---- .../tests/cpp_tests/test_potential_flow_utilities.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp index 441616d2cf0d..1b69fbf2a45c 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp +++ b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp @@ -354,7 +354,7 @@ double ComputeLocalSpeedOfSound(const Element& rElement, const ProcessInfo& rCur << "Error on element -> " << rElement.Id() << "\n" << "v_inf_2 must be larger than zero." << std::endl; - return a_inf * sqrt(1 + (heat_capacity_ratio - 1) * M_inf_2 * (1 - v_2 / v_inf_2) / 2); + return a_inf * std::sqrt(1 + (heat_capacity_ratio - 1) * M_inf_2 * (1 - v_2 / v_inf_2) / 2); } template @@ -427,7 +427,7 @@ double ComputePerturbationLocalSpeedOfSound(const Element& rElement, const Proce << "Error on element -> " << rElement.Id() << "\n" << "v_inf_2 must be larger than zero." << std::endl; - return a_inf * sqrt(1 + (heat_capacity_ratio - 1) * M_inf_2 * (1 - v_2 / v_inf_2) / 2); + return a_inf * std::sqrt(1 + (heat_capacity_ratio - 1) * M_inf_2 * (1 - v_2 / v_inf_2) / 2); } template @@ -437,7 +437,7 @@ double ComputeLocalMachNumber(const Element& rElement, const ProcessInfo& rCurre // Aerodynamics, The MIT Press, London array_1d velocity = ComputeVelocity(rElement); - const double velocity_module = sqrt(inner_prod(velocity, velocity)); + const double velocity_module = std::sqrt(inner_prod(velocity, velocity)); const double local_speed_of_sound = ComputeLocalSpeedOfSound(rElement, rCurrentProcessInfo); return velocity_module / local_speed_of_sound; @@ -500,7 +500,7 @@ double ComputePerturbationLocalMachNumber(const Element& rElement, const Process for (unsigned int i = 0; i < Dim; i++){ velocity[i] += free_stream_velocity[i]; } - const double velocity_module = sqrt(inner_prod(velocity, velocity)); + const double velocity_module = std::sqrt(inner_prod(velocity, velocity)); const double local_speed_of_sound = ComputePerturbationLocalSpeedOfSound(rElement, rCurrentProcessInfo); return velocity_module / local_speed_of_sound; diff --git a/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp b/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp index ea64c358c1d9..939027fa7611 100644 --- a/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp +++ b/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp @@ -140,7 +140,7 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeLocalSpeedofSoundSquared, CompressiblePotential const double local_velocity_squared = PotentialFlowUtilities::ComputeVelocityMagnitude<2, 3>(local_mach_number_squared, model_part.GetProcessInfo()); array_1d velocity(2, 0.0); - velocity[0] = local_velocity_squared; + velocity[0] = std::sqrt(local_velocity_squared); const double local_speed_sound_squared = PotentialFlowUtilities::ComputeLocalSpeedofSoundSquared<2,3>(velocity, model_part.GetProcessInfo()); @@ -177,7 +177,7 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeLocalMachNumberSquared, CompressiblePotentialAp const double local_velocity_squared = PotentialFlowUtilities::ComputeVelocityMagnitude<2, 3>(reference_local_mach_squared, model_part.GetProcessInfo()); array_1d velocity(2, 0.0); - velocity[0] = sqrt(local_velocity_squared); + velocity[0] = std::sqrt(local_velocity_squared); // computes mach number with clamping const double local_mach_squared = PotentialFlowUtilities::ComputeLocalMachNumberSquared<2, 3>(velocity, model_part.GetProcessInfo()); @@ -198,7 +198,7 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeDerivativeLocalMachSquaredWRTVelocitySquaredTra const double local_velocity_squared = PotentialFlowUtilities::ComputeVelocityMagnitude<2, 3>(local_mach_number_squared, model_part.GetProcessInfo()); array_1d velocity(2, 0.0); - velocity[0] = sqrt(local_velocity_squared); + velocity[0] = std::sqrt(local_velocity_squared); // performs clamping on mach number const double local_mach_squared = PotentialFlowUtilities::ComputeLocalMachNumberSquared<2, 3>(velocity, model_part.GetProcessInfo()); @@ -224,7 +224,7 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeDerivativeLocalMachSquaredWRTVelocitySquaredSup const double local_velocity_squared = PotentialFlowUtilities::ComputeVelocityMagnitude<2, 3>(local_mach_number_squared, model_part.GetProcessInfo()); array_1d velocity(2, 0.0); - velocity[0] = sqrt(local_velocity_squared); + velocity[0] = std::sqrt(local_velocity_squared); // performs clamping on mach number const double local_mach_squared = PotentialFlowUtilities::ComputeLocalMachNumberSquared<2, 3>(velocity, model_part.GetProcessInfo()); From 6576a320ee453c01a33cc75fcc4813616353f150 Mon Sep 17 00:00:00 2001 From: marcnunezc Date: Wed, 29 Apr 2020 11:42:09 +0200 Subject: [PATCH 299/314] Use stabilization factor instead of penalty coeff --- .../embedded_incompressible_potential_flow_element.cpp | 8 ++++---- .../python_scripts/potential_flow_adjoint_solver.py | 2 +- .../python_scripts/potential_flow_solver.py | 10 +++++----- .../embedded_circle_penalty_parameters.json | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/applications/CompressiblePotentialFlowApplication/custom_elements/embedded_incompressible_potential_flow_element.cpp b/applications/CompressiblePotentialFlowApplication/custom_elements/embedded_incompressible_potential_flow_element.cpp index e4170ca6a8fd..5a69346703ed 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_elements/embedded_incompressible_potential_flow_element.cpp +++ b/applications/CompressiblePotentialFlowApplication/custom_elements/embedded_incompressible_potential_flow_element.cpp @@ -65,7 +65,7 @@ void EmbeddedIncompressiblePotentialFlowElement::CalculateLocalSy if (is_embedded && wake == 0 && kutta == 0) { CalculateEmbeddedLocalSystem(rLeftHandSideMatrix,rRightHandSideVector,rCurrentProcessInfo); - if (std::abs(rCurrentProcessInfo[PENALTY_COEFFICIENT]) > std::numeric_limits::epsilon()) { + if (std::abs(rCurrentProcessInfo[STABILIZATION_FACTOR]) > std::numeric_limits::epsilon()) { AddPotentialGradientStabilizationTerm(rLeftHandSideMatrix,rRightHandSideVector,rCurrentProcessInfo); } } @@ -198,10 +198,10 @@ void EmbeddedIncompressiblePotentialFlowElement::AddPotentialGrad auto penalty_term_nodal_gradient = data.vol*prod(data.DN_DX, averaged_nodal_gradient); auto penalty_term_potential = data.vol*prod(data.DN_DX,trans(data.DN_DX)); - auto penalty_coefficient = rCurrentProcessInfo[PENALTY_COEFFICIENT]; + auto stabilization_factor = rCurrentProcessInfo[STABILIZATION_FACTOR]; - noalias(rLeftHandSideMatrix) += penalty_coefficient*penalty_term_potential; - noalias(rRightHandSideVector) += penalty_coefficient*(penalty_term_nodal_gradient-prod(penalty_term_potential, potential)); + noalias(rLeftHandSideMatrix) += stabilization_factor*penalty_term_potential; + noalias(rRightHandSideVector) += stabilization_factor*(penalty_term_nodal_gradient-prod(penalty_term_potential, potential)); } template <> diff --git a/applications/CompressiblePotentialFlowApplication/python_scripts/potential_flow_adjoint_solver.py b/applications/CompressiblePotentialFlowApplication/python_scripts/potential_flow_adjoint_solver.py index 9accf30a2034..860855afa448 100644 --- a/applications/CompressiblePotentialFlowApplication/python_scripts/potential_flow_adjoint_solver.py +++ b/applications/CompressiblePotentialFlowApplication/python_scripts/potential_flow_adjoint_solver.py @@ -37,7 +37,7 @@ def _SetUpEmbeddedIncompressibleElement(self, formulation_settings): default_settings = KratosMultiphysics.Parameters(r"""{ "element_type": "", "gradient_mode": "", - "penalty_coefficient": 0.0 + "stabilization_factor": 0.0 }""") formulation_settings.ValidateAndAssignDefaults(default_settings) diff --git a/applications/CompressiblePotentialFlowApplication/python_scripts/potential_flow_solver.py b/applications/CompressiblePotentialFlowApplication/python_scripts/potential_flow_solver.py index 74448b4285cc..39cecd1ea9f3 100644 --- a/applications/CompressiblePotentialFlowApplication/python_scripts/potential_flow_solver.py +++ b/applications/CompressiblePotentialFlowApplication/python_scripts/potential_flow_solver.py @@ -82,14 +82,14 @@ def _SetUpTransonicPerturbationElement(self, formulation_settings): def _SetUpEmbeddedIncompressibleElement(self, formulation_settings): default_settings = KratosMultiphysics.Parameters(r"""{ "element_type": "embedded_incompressible", - "penalty_coefficient": 0.0 + "stabilization_factor": 0.0 }""") formulation_settings.ValidateAndAssignDefaults(default_settings) self.element_name = "EmbeddedIncompressiblePotentialFlowElement" self.condition_name = "PotentialWallCondition" - self.process_info_data[KratosMultiphysics.FluidDynamicsApplication.PENALTY_COEFFICIENT] = formulation_settings["penalty_coefficient"].GetDouble() + self.process_info_data[KratosMultiphysics.STABILIZATION_FACTOR] = formulation_settings["stabilization_factor"].GetDouble() def _SetUpEmbeddedCompressibleElement(self, formulation_settings): default_settings = KratosMultiphysics.Parameters(r"""{ @@ -203,9 +203,9 @@ def _ComputeNodalElementalNeighbours(self): def _GetStrategyType(self): element_type = self.settings["formulation"]["element_type"].GetString() if "incompressible" in element_type: - if not self.settings["formulation"].Has("penalty_coefficient"): + if not self.settings["formulation"].Has("stabilization_factor"): strategy_type = "linear" - elif self.settings["formulation"]["penalty_coefficient"].GetDouble() == 0.0: + elif self.settings["formulation"]["stabilization_factor"].GetDouble() == 0.0: strategy_type = "linear" else: strategy_type = "non_linear" @@ -255,4 +255,4 @@ def _CreateSolutionStrategy(self): else: err_msg = "Unknown strategy type: \'" + strategy_type + "\'. Valid options are \'linear\' and \'non_linear\'." raise Exception(err_msg) - return solution_strategy \ No newline at end of file + return solution_strategy diff --git a/applications/CompressiblePotentialFlowApplication/tests/embedded_test/embedded_circle_penalty_parameters.json b/applications/CompressiblePotentialFlowApplication/tests/embedded_test/embedded_circle_penalty_parameters.json index d8277d43c91f..19c9cd4ff084 100644 --- a/applications/CompressiblePotentialFlowApplication/tests/embedded_test/embedded_circle_penalty_parameters.json +++ b/applications/CompressiblePotentialFlowApplication/tests/embedded_test/embedded_circle_penalty_parameters.json @@ -15,7 +15,7 @@ }, "formulation": { "element_type":"embedded_incompressible", - "penalty_coefficient": 1.0 + "stabilization_factor": 1.0 }, "maximum_iterations" : 10, "echo_level" : 0, From 63f4144b0322f160bff7554a30fa43259f0c12d2 Mon Sep 17 00:00:00 2001 From: marcnunezc Date: Wed, 29 Apr 2020 11:46:11 +0200 Subject: [PATCH 300/314] Renaming local variables --- .../embedded_incompressible_potential_flow_element.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/applications/CompressiblePotentialFlowApplication/custom_elements/embedded_incompressible_potential_flow_element.cpp b/applications/CompressiblePotentialFlowApplication/custom_elements/embedded_incompressible_potential_flow_element.cpp index 5a69346703ed..40a7410d8fdd 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_elements/embedded_incompressible_potential_flow_element.cpp +++ b/applications/CompressiblePotentialFlowApplication/custom_elements/embedded_incompressible_potential_flow_element.cpp @@ -196,12 +196,12 @@ void EmbeddedIncompressiblePotentialFlowElement::AddPotentialGrad PotentialFlowUtilities::ElementalData data; GeometryUtils::CalculateGeometryData(this->GetGeometry(), data.DN_DX, data.N, data.vol); - auto penalty_term_nodal_gradient = data.vol*prod(data.DN_DX, averaged_nodal_gradient); - auto penalty_term_potential = data.vol*prod(data.DN_DX,trans(data.DN_DX)); + auto stabilization_term_nodal_gradient = data.vol*prod(data.DN_DX, averaged_nodal_gradient); + auto stabilization_term_potential = data.vol*prod(data.DN_DX,trans(data.DN_DX)); auto stabilization_factor = rCurrentProcessInfo[STABILIZATION_FACTOR]; - noalias(rLeftHandSideMatrix) += stabilization_factor*penalty_term_potential; - noalias(rRightHandSideVector) += stabilization_factor*(penalty_term_nodal_gradient-prod(penalty_term_potential, potential)); + noalias(rLeftHandSideMatrix) += stabilization_factor*stabilization_term_potential; + noalias(rRightHandSideVector) += stabilization_factor*(stabilization_term_nodal_gradient-prod(stabilization_term_potential, potential)); } template <> From c3549a31eeda47a463023f357bf5130b03c96547 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Wed, 29 Apr 2020 13:56:03 +0200 Subject: [PATCH 301/314] [StructuralMechanicsApplication] Fixes #6839 Fixes #6839 --- .../impose_rigid_movement_process.cpp | 43 +++++++------------ .../impose_rigid_movement_process.h | 25 +++++------ 2 files changed, 26 insertions(+), 42 deletions(-) diff --git a/applications/StructuralMechanicsApplication/custom_processes/impose_rigid_movement_process.cpp b/applications/StructuralMechanicsApplication/custom_processes/impose_rigid_movement_process.cpp index 47edb3ada76f..85e1b81f2c09 100644 --- a/applications/StructuralMechanicsApplication/custom_processes/impose_rigid_movement_process.cpp +++ b/applications/StructuralMechanicsApplication/custom_processes/impose_rigid_movement_process.cpp @@ -63,26 +63,22 @@ void ImposeRigidMovementProcess::ExecuteInitialize() // Getting list of variables std::vector*> master_double_list_variables, slave_double_list_variables; - std::vector*> master_components_list_variables, slave_components_list_variables; const std::string& master_variable_name = mThisParameters["master_variable_name"].GetString(); // The master variable if(KratosComponents>::Has(master_variable_name)){ const Variable& r_variable = KratosComponents>::Get(master_variable_name); master_double_list_variables.push_back(&r_variable); - } else if (KratosComponents< VariableComponent>::Has(master_variable_name)) { - const VariableComponent& r_variable = KratosComponents>::Get(master_variable_name); - master_components_list_variables.push_back(&r_variable); } else if (KratosComponents< Variable< array_1d< double, 3> > >::Has(master_variable_name)) { - const VariableComponent& r_variable_x = KratosComponents>::Get(master_variable_name+"_X"); - master_components_list_variables.push_back(&r_variable_x); - const VariableComponent& r_variable_y = KratosComponents>::Get(master_variable_name+"_Y"); - master_components_list_variables.push_back(&r_variable_y); + const Variable& r_variable_x = KratosComponents>::Get(master_variable_name+"_X"); + master_double_list_variables.push_back(&r_variable_x); + const Variable& r_variable_y = KratosComponents>::Get(master_variable_name+"_Y"); + master_double_list_variables.push_back(&r_variable_y); if (r_root_model_part.GetProcessInfo()[DOMAIN_SIZE] == 3) { - const VariableComponent& r_variable_z = KratosComponents>::Get(master_variable_name+"_Z"); - master_components_list_variables.push_back(&r_variable_z); + const Variable& r_variable_z = KratosComponents>::Get(master_variable_name+"_Z"); + master_double_list_variables.push_back(&r_variable_z); } } else { - KRATOS_ERROR << "Only double, components and vector variables are allowed in the variables list." ; + KRATOS_ERROR << "Only double and vector variables are allowed in the variables list." ; } const std::string& slave_variable_name = mThisParameters["slave_variable_name"].GetString(); // We get the slave variable list @@ -90,26 +86,21 @@ void ImposeRigidMovementProcess::ExecuteInitialize() if(KratosComponents>::Has(slave_variable_name)){ const Variable& r_variable = KratosComponents>::Get(slave_variable_name); slave_double_list_variables.push_back(&r_variable); - } else if (KratosComponents< VariableComponent>::Has(slave_variable_name)) { - const VariableComponent& r_variable = KratosComponents>::Get(slave_variable_name); - slave_components_list_variables.push_back(&r_variable); } else if (KratosComponents< Variable< array_1d< double, 3> > >::Has(slave_variable_name)) { - const VariableComponent& r_variable_x = KratosComponents>::Get(slave_variable_name+"_X"); - slave_components_list_variables.push_back(&r_variable_x); - const VariableComponent& r_variable_y = KratosComponents>::Get(slave_variable_name+"_Y"); - slave_components_list_variables.push_back(&r_variable_y); + const Variable& r_variable_x = KratosComponents>::Get(slave_variable_name+"_X"); + slave_double_list_variables.push_back(&r_variable_x); + const Variable& r_variable_y = KratosComponents>::Get(slave_variable_name+"_Y"); + slave_double_list_variables.push_back(&r_variable_y); if (r_root_model_part.GetProcessInfo()[DOMAIN_SIZE] == 3) { - const VariableComponent& r_variable_z = KratosComponents>::Get(slave_variable_name+"_Z"); - slave_components_list_variables.push_back(&r_variable_z); + const Variable& r_variable_z = KratosComponents>::Get(slave_variable_name+"_Z"); + slave_double_list_variables.push_back(&r_variable_z); } } else { - KRATOS_ERROR << "Only double, components and vector variables are allowed in the variables list." ; + KRATOS_ERROR << "Only double and vector variables are allowed in the variables list." ; } } else { // Else we consider exactly the same list of variables for (auto& r_var : master_double_list_variables) slave_double_list_variables.push_back(r_var); - for (auto& r_var : master_components_list_variables) - slave_components_list_variables.push_back(r_var); } // Getting index of the master node @@ -122,7 +113,7 @@ void ImposeRigidMovementProcess::ExecuteInitialize() // List of variables const SizeType number_of_double_variables = master_double_list_variables.size(); - const SizeType number_of_components_variables = master_components_list_variables.size(); + const SizeType number_of_components_variables = master_double_list_variables.size(); // We get the relation and constant const double relation = mThisParameters["relation"].GetDouble(); @@ -145,10 +136,6 @@ void ImposeRigidMovementProcess::ExecuteInitialize() auto p_constraint = r_clone_constraint.Create(constraint_id + (i * number_of_double_variables + i_var) + 1, *p_master_node, *master_double_list_variables[i_var], *it_node, *slave_double_list_variables[i_var], relation, constant); (constraints_buffer).insert((constraints_buffer).begin(), p_constraint); } - for (IndexType i_var = 0; i_var < number_of_components_variables; ++i_var) { - auto p_constraint = r_clone_constraint.Create(constraint_id + (i * number_of_components_variables + i_var) + 1, *p_master_node, *master_components_list_variables[i_var], *it_node, *slave_components_list_variables[i_var], relation, constant); - (constraints_buffer).insert((constraints_buffer).begin(), p_constraint); - } } } diff --git a/applications/StructuralMechanicsApplication/custom_processes/impose_rigid_movement_process.h b/applications/StructuralMechanicsApplication/custom_processes/impose_rigid_movement_process.h index 6bdeadb3fe4c..563e90ab83ad 100644 --- a/applications/StructuralMechanicsApplication/custom_processes/impose_rigid_movement_process.h +++ b/applications/StructuralMechanicsApplication/custom_processes/impose_rigid_movement_process.h @@ -28,16 +28,16 @@ namespace Kratos ///@} ///@name Type Definitions ///@{ - + ///@} ///@name Enum's ///@{ - + ///@} ///@name Functions ///@{ - -/** + +/** * @class ImposeRigidMovementProcess * @ingroup StructuralMechanicsApplication * @brief This method assign linear kinematic constrains to a certain submodelpart @@ -53,16 +53,13 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) ImposeRigidMovementProcess /// Pointer definition of ImposeRigidMovementProcess KRATOS_CLASS_POINTER_DEFINITION(ImposeRigidMovementProcess); - + /// General type definitions typedef Node<3> NodeType; /// General containers type definitions typedef ModelPart::MasterSlaveConstraintContainerType ConstraintContainerType; - /// Component definition - typedef VectorComponentAdaptor< array_1d< double, 3 > > ComponentType; - /// Definitions of the integers typedef std::size_t IndexType; typedef std::size_t SizeType; @@ -100,7 +97,7 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) ImposeRigidMovementProcess ///@} ///@name Friends ///@{ - + ///@} ///@name Operators ///@{ @@ -109,11 +106,11 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) ImposeRigidMovementProcess { Execute(); } - + ///@} ///@name Operations ///@{ - + /** * @brief Execute method is used to execute the Process algorithms. */ @@ -123,7 +120,7 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) ImposeRigidMovementProcess * @brief This function is designed for being called at the beginning of the computations right after reading the model and the groups */ void ExecuteInitialize() override; - + /** * @brief This method provides the defaults parameters to avoid conflicts between the different constructors */ @@ -185,7 +182,7 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) ImposeRigidMovementProcess ///@} ///@name Protected Operations ///@{ - + ///@} ///@name Protected Access ///@{ @@ -211,7 +208,7 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) ImposeRigidMovementProcess ///@} ///@name Member Variables ///@{ - + ModelPart& mrThisModelPart; /// The model part to compute Parameters mThisParameters; /// The parameters (can be used for general pourposes) From 18fd042047a0c5a6ddd94441e616ddf4655b7d3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Wed, 29 Apr 2020 16:10:22 +0200 Subject: [PATCH 302/314] Change name --- .../impose_rigid_movement_process.cpp | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/applications/StructuralMechanicsApplication/custom_processes/impose_rigid_movement_process.cpp b/applications/StructuralMechanicsApplication/custom_processes/impose_rigid_movement_process.cpp index 85e1b81f2c09..77d078e7a6c3 100644 --- a/applications/StructuralMechanicsApplication/custom_processes/impose_rigid_movement_process.cpp +++ b/applications/StructuralMechanicsApplication/custom_processes/impose_rigid_movement_process.cpp @@ -62,20 +62,20 @@ void ImposeRigidMovementProcess::ExecuteInitialize() } // Getting list of variables - std::vector*> master_double_list_variables, slave_double_list_variables; + std::vector*> master_list_variables, slave_list_variables; const std::string& master_variable_name = mThisParameters["master_variable_name"].GetString(); // The master variable if(KratosComponents>::Has(master_variable_name)){ const Variable& r_variable = KratosComponents>::Get(master_variable_name); - master_double_list_variables.push_back(&r_variable); + master_list_variables.push_back(&r_variable); } else if (KratosComponents< Variable< array_1d< double, 3> > >::Has(master_variable_name)) { const Variable& r_variable_x = KratosComponents>::Get(master_variable_name+"_X"); - master_double_list_variables.push_back(&r_variable_x); + master_list_variables.push_back(&r_variable_x); const Variable& r_variable_y = KratosComponents>::Get(master_variable_name+"_Y"); - master_double_list_variables.push_back(&r_variable_y); + master_list_variables.push_back(&r_variable_y); if (r_root_model_part.GetProcessInfo()[DOMAIN_SIZE] == 3) { const Variable& r_variable_z = KratosComponents>::Get(master_variable_name+"_Z"); - master_double_list_variables.push_back(&r_variable_z); + master_list_variables.push_back(&r_variable_z); } } else { KRATOS_ERROR << "Only double and vector variables are allowed in the variables list." ; @@ -85,22 +85,22 @@ void ImposeRigidMovementProcess::ExecuteInitialize() if (slave_variable_name != "") { if(KratosComponents>::Has(slave_variable_name)){ const Variable& r_variable = KratosComponents>::Get(slave_variable_name); - slave_double_list_variables.push_back(&r_variable); + slave_list_variables.push_back(&r_variable); } else if (KratosComponents< Variable< array_1d< double, 3> > >::Has(slave_variable_name)) { const Variable& r_variable_x = KratosComponents>::Get(slave_variable_name+"_X"); - slave_double_list_variables.push_back(&r_variable_x); + slave_list_variables.push_back(&r_variable_x); const Variable& r_variable_y = KratosComponents>::Get(slave_variable_name+"_Y"); - slave_double_list_variables.push_back(&r_variable_y); + slave_list_variables.push_back(&r_variable_y); if (r_root_model_part.GetProcessInfo()[DOMAIN_SIZE] == 3) { const Variable& r_variable_z = KratosComponents>::Get(slave_variable_name+"_Z"); - slave_double_list_variables.push_back(&r_variable_z); + slave_list_variables.push_back(&r_variable_z); } } else { KRATOS_ERROR << "Only double and vector variables are allowed in the variables list." ; } } else { // Else we consider exactly the same list of variables - for (auto& r_var : master_double_list_variables) - slave_double_list_variables.push_back(r_var); + for (auto& r_var : master_list_variables) + slave_list_variables.push_back(r_var); } // Getting index of the master node @@ -112,8 +112,8 @@ void ImposeRigidMovementProcess::ExecuteInitialize() const auto it_node_begin = r_nodes_array.begin(); // List of variables - const SizeType number_of_double_variables = master_double_list_variables.size(); - const SizeType number_of_components_variables = master_double_list_variables.size(); + const SizeType number_of_double_variables = master_list_variables.size(); + const SizeType number_of_components_variables = master_list_variables.size(); // We get the relation and constant const double relation = mThisParameters["relation"].GetDouble(); @@ -133,7 +133,7 @@ void ImposeRigidMovementProcess::ExecuteInitialize() auto it_node = it_node_begin + i; if (it_node->Id() != p_master_node->Id()) { for (IndexType i_var = 0; i_var < number_of_double_variables; ++i_var) { - auto p_constraint = r_clone_constraint.Create(constraint_id + (i * number_of_double_variables + i_var) + 1, *p_master_node, *master_double_list_variables[i_var], *it_node, *slave_double_list_variables[i_var], relation, constant); + auto p_constraint = r_clone_constraint.Create(constraint_id + (i * number_of_double_variables + i_var) + 1, *p_master_node, *master_list_variables[i_var], *it_node, *slave_list_variables[i_var], relation, constant); (constraints_buffer).insert((constraints_buffer).begin(), p_constraint); } } From cac1cf55b2b645bca869bdba0d705b841229699a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Wed, 29 Apr 2020 16:14:00 +0200 Subject: [PATCH 303/314] Typo --- .../custom_processes/impose_rigid_movement_process.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/applications/StructuralMechanicsApplication/custom_processes/impose_rigid_movement_process.cpp b/applications/StructuralMechanicsApplication/custom_processes/impose_rigid_movement_process.cpp index 77d078e7a6c3..b1720711c47a 100644 --- a/applications/StructuralMechanicsApplication/custom_processes/impose_rigid_movement_process.cpp +++ b/applications/StructuralMechanicsApplication/custom_processes/impose_rigid_movement_process.cpp @@ -113,7 +113,6 @@ void ImposeRigidMovementProcess::ExecuteInitialize() // List of variables const SizeType number_of_double_variables = master_list_variables.size(); - const SizeType number_of_components_variables = master_list_variables.size(); // We get the relation and constant const double relation = mThisParameters["relation"].GetDouble(); From 2d9f0d78f1f96f7e918a5449d05edf0e08270ac3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Wed, 29 Apr 2020 16:14:38 +0200 Subject: [PATCH 304/314] Suggestion --- .../custom_processes/impose_rigid_movement_process.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/applications/StructuralMechanicsApplication/custom_processes/impose_rigid_movement_process.cpp b/applications/StructuralMechanicsApplication/custom_processes/impose_rigid_movement_process.cpp index b1720711c47a..ee6be7f83f20 100644 --- a/applications/StructuralMechanicsApplication/custom_processes/impose_rigid_movement_process.cpp +++ b/applications/StructuralMechanicsApplication/custom_processes/impose_rigid_movement_process.cpp @@ -112,7 +112,7 @@ void ImposeRigidMovementProcess::ExecuteInitialize() const auto it_node_begin = r_nodes_array.begin(); // List of variables - const SizeType number_of_double_variables = master_list_variables.size(); + const SizeType number_of_variables = master_list_variables.size(); // We get the relation and constant const double relation = mThisParameters["relation"].GetDouble(); @@ -131,8 +131,8 @@ void ImposeRigidMovementProcess::ExecuteInitialize() for (int i = 0; i < number_of_nodes; ++i) { auto it_node = it_node_begin + i; if (it_node->Id() != p_master_node->Id()) { - for (IndexType i_var = 0; i_var < number_of_double_variables; ++i_var) { - auto p_constraint = r_clone_constraint.Create(constraint_id + (i * number_of_double_variables + i_var) + 1, *p_master_node, *master_list_variables[i_var], *it_node, *slave_list_variables[i_var], relation, constant); + for (IndexType i_var = 0; i_var < number_of_variables; ++i_var) { + auto p_constraint = r_clone_constraint.Create(constraint_id + (i * number_of_variables + i_var) + 1, *p_master_node, *master_list_variables[i_var], *it_node, *slave_list_variables[i_var], relation, constant); (constraints_buffer).insert((constraints_buffer).begin(), p_constraint); } } From 0fc5450e106f7264b0fa824d78a811440acd16b6 Mon Sep 17 00:00:00 2001 From: peterjwilson Date: Thu, 30 Apr 2020 17:13:49 +1000 Subject: [PATCH 305/314] Update particle_mechanics_python_application.cpp --- .../custom_python/particle_mechanics_python_application.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp b/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp index a508a0936644..226ce07947de 100644 --- a/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp +++ b/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp @@ -122,7 +122,6 @@ namespace Python{ KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, PARTICLES_PER_ELEMENT); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, IGNORE_GEOMETRIC_STIFFNESS); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, IS_COMPRESSIBLE); - KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, USE_CONSISTENT_MASS_MATRIX); KRATOS_REGISTER_IN_PYTHON_3D_VARIABLE_WITH_COMPONENTS(m, MPC_COORD); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, MPC_CONDITION_ID); From 0f20027f61e82af0adf0a0d13c8185eb84374991 Mon Sep 17 00:00:00 2001 From: marandra Date: Thu, 30 Apr 2020 10:11:41 +0200 Subject: [PATCH 306/314] Add case where CMAKE_BUILD_TYPE is passed directly to cmake request-checks: true --- CMakeLists.txt | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ddac158aec59..6cfb9ef896c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,18 +86,20 @@ SET( CMAKE_MODULE_LINKER_FLAGS_FULLDEBUG "${CMAKE_MODULE_LINKER_FLAGS}") SET( CMAKE_MODULE_LINKER_FLAGS_CUSTOM "${CMAKE_MODULE_LINKER_FLAGS}") # If build mode is not defined, assume Release -if(DEFINED ENV{KRATOS_BUILD_TYPE}) - list(FIND CMAKE_CONFIGURATION_TYPES $ENV{KRATOS_BUILD_TYPE} FOUND_MODE) - if(FOUND_MODE EQUAL -1) - message("Unknown CMAKE_BUILD_TYPE '${CMAKE_BUILD_TYPE}', using 'Release'.") - set(CMAKE_BUILD_TYPE Release) - else(FOUND_MODE EQUAL -1) - set(CMAKE_BUILD_TYPE $ENV{KRATOS_BUILD_TYPE}) - endif(FOUND_MODE EQUAL -1) -else(DEFINED ENV{KRATOS_BUILD_TYPE}) - message("--No CMAKE_BUILD_TYPE is defined, building in 'Release' mode.") - set(CMAKE_BUILD_TYPE Release) -endif(DEFINED ENV{KRATOS_BUILD_TYPE}) +if(NOT DEFINED CMAKE_BUILD_TYPE) + if(DEFINED ENV{KRATOS_BUILD_TYPE}) + list(FIND CMAKE_CONFIGURATION_TYPES $ENV{KRATOS_BUILD_TYPE} FOUND_MODE) + if(FOUND_MODE EQUAL -1) + message("Unknown CMAKE_BUILD_TYPE '${CMAKE_BUILD_TYPE}', using 'Release'.") + set(CMAKE_BUILD_TYPE Release) + else(FOUND_MODE EQUAL -1) + set(CMAKE_BUILD_TYPE $ENV{KRATOS_BUILD_TYPE}) + endif(FOUND_MODE EQUAL -1) + else(DEFINED ENV{KRATOS_BUILD_TYPE}) + message("--No CMAKE_BUILD_TYPE is defined, building in 'Release' mode.") + set(CMAKE_BUILD_TYPE Release) + endif(DEFINED ENV{KRATOS_BUILD_TYPE}) +endif(NOT DEFINED CMAKE_BUILD_TYPE) set (KratosMultiphysics_BUILD_TYPE ${CMAKE_BUILD_TYPE}) if(USE_COTIRE MATCHES ON) From 60920eac917267be008df03f60c1eba5e3ec800c Mon Sep 17 00:00:00 2001 From: Miguel Angel Date: Thu, 30 Apr 2020 11:53:17 +0200 Subject: [PATCH 307/314] removing bold, only works in Linux --- .../custom_strategies/strategies/explicit_solver_continuum.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/DEMApplication/custom_strategies/strategies/explicit_solver_continuum.cpp b/applications/DEMApplication/custom_strategies/strategies/explicit_solver_continuum.cpp index 23dbeb8480a2..0e39733eadd7 100644 --- a/applications/DEMApplication/custom_strategies/strategies/explicit_solver_continuum.cpp +++ b/applications/DEMApplication/custom_strategies/strategies/explicit_solver_continuum.cpp @@ -510,7 +510,7 @@ namespace Kratos { KRATOS_INFO("DEM") < Date: Thu, 30 Apr 2020 11:57:36 +0200 Subject: [PATCH 308/314] removed unused constructors --- kratos/processes/assign_scalar_variable_to_entities_process.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/kratos/processes/assign_scalar_variable_to_entities_process.h b/kratos/processes/assign_scalar_variable_to_entities_process.h index 9e30f7225273..de5a4b127cdd 100644 --- a/kratos/processes/assign_scalar_variable_to_entities_process.h +++ b/kratos/processes/assign_scalar_variable_to_entities_process.h @@ -156,8 +156,6 @@ class KRATOS_API(KRATOS_CORE) AssignScalarVariableToEntitiesProcess ///@{ /// Copy constructor. - AssignScalarVariableToEntitiesProcess(AssignScalarVariableToEntitiesProcess const& rOther); - ///@} ///@name Protected Operations ///@{ @@ -250,8 +248,6 @@ class KRATOS_API(KRATOS_CORE) AssignScalarVariableToEntitiesProcess ///@{ /// Assignment operator. - AssignScalarVariableToEntitiesProcess& operator=(AssignScalarVariableToEntitiesProcess const& rOther); - ///@} ///@name Serialization ///@{ From d580bd1003d7b51081d041576daf72f5d88b11cb Mon Sep 17 00:00:00 2001 From: marandra Date: Thu, 30 Apr 2020 12:00:34 +0200 Subject: [PATCH 309/314] Dummy change to trigger CI --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6cfb9ef896c8..0178df5577f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,6 +102,7 @@ if(NOT DEFINED CMAKE_BUILD_TYPE) endif(NOT DEFINED CMAKE_BUILD_TYPE) set (KratosMultiphysics_BUILD_TYPE ${CMAKE_BUILD_TYPE}) + if(USE_COTIRE MATCHES ON) include(cotire) set(CMAKE_SKIP_RPATH ON) From b5d7a747427f660c17ac49ca79fe176a4d0e6b96 Mon Sep 17 00:00:00 2001 From: Miguel Angel Date: Thu, 30 Apr 2020 12:07:08 +0200 Subject: [PATCH 310/314] not bool, but int --- .../custom_utilities/explicit_integration_utilities.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/StructuralMechanicsApplication/custom_utilities/explicit_integration_utilities.cpp b/applications/StructuralMechanicsApplication/custom_utilities/explicit_integration_utilities.cpp index 914933047c8f..10960c225974 100644 --- a/applications/StructuralMechanicsApplication/custom_utilities/explicit_integration_utilities.cpp +++ b/applications/StructuralMechanicsApplication/custom_utilities/explicit_integration_utilities.cpp @@ -49,7 +49,7 @@ double CalculateDeltaTime( double mass_factor = ThisParameters["mass_factor"].GetDouble(); // How the density of the solid is going to be multiplied (1.0 by default) const double desired_delta_time = ThisParameters["desired_delta_time"].GetDouble(); // The minimum delta time we want, if the value is negative not mass factor will be computed const bool compute_mass_factor = desired_delta_time < 0.0 ? false : true; - const bool max_number_of_iterations = ThisParameters["max_number_of_iterations"].GetInt(); + const int max_number_of_iterations = ThisParameters["max_number_of_iterations"].GetInt(); // Getting process info ProcessInfo& r_current_process_info = rModelPart.GetProcessInfo(); From 972f930f5b74c1f73fd1663c7fa575f982d21513 Mon Sep 17 00:00:00 2001 From: Carlos Roig Date: Thu, 30 Apr 2020 21:42:07 +0200 Subject: [PATCH 311/314] Checking content instead of variable existance. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0178df5577f6..6920911b4351 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,7 +86,7 @@ SET( CMAKE_MODULE_LINKER_FLAGS_FULLDEBUG "${CMAKE_MODULE_LINKER_FLAGS}") SET( CMAKE_MODULE_LINKER_FLAGS_CUSTOM "${CMAKE_MODULE_LINKER_FLAGS}") # If build mode is not defined, assume Release -if(NOT DEFINED CMAKE_BUILD_TYPE) +if(NOT CMAKE_BUILD_TYPE) if(DEFINED ENV{KRATOS_BUILD_TYPE}) list(FIND CMAKE_CONFIGURATION_TYPES $ENV{KRATOS_BUILD_TYPE} FOUND_MODE) if(FOUND_MODE EQUAL -1) @@ -99,7 +99,7 @@ if(NOT DEFINED CMAKE_BUILD_TYPE) message("--No CMAKE_BUILD_TYPE is defined, building in 'Release' mode.") set(CMAKE_BUILD_TYPE Release) endif(DEFINED ENV{KRATOS_BUILD_TYPE}) -endif(NOT DEFINED CMAKE_BUILD_TYPE) +endif(NOT CMAKE_BUILD_TYPE) set (KratosMultiphysics_BUILD_TYPE ${CMAKE_BUILD_TYPE}) From 192059d54d12678608145d6833c12586a50bbc3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Fri, 1 May 2020 12:37:09 +0200 Subject: [PATCH 312/314] [Core] This fixes constraint utilities after unifying components Basically that --- .../mechanical_explicit_strategy.hpp | 2 +- kratos/utilities/constraint_utilities.cpp | 51 ++++++++----------- 2 files changed, 21 insertions(+), 32 deletions(-) diff --git a/applications/StructuralMechanicsApplication/custom_strategies/custom_strategies/mechanical_explicit_strategy.hpp b/applications/StructuralMechanicsApplication/custom_strategies/custom_strategies/mechanical_explicit_strategy.hpp index 2a08608f7410..f82b4b9c4dd1 100644 --- a/applications/StructuralMechanicsApplication/custom_strategies/custom_strategies/mechanical_explicit_strategy.hpp +++ b/applications/StructuralMechanicsApplication/custom_strategies/custom_strategies/mechanical_explicit_strategy.hpp @@ -68,7 +68,7 @@ class MechanicalExplicitStrategy typedef typename BaseType::ElementsArrayType ElementsArrayType; typedef typename BaseType::ConditionsArrayType ConditionsArrayType; typedef typename BaseType::LocalSystemVectorType LocalSystemVectorType; - typedef ModelPart::VariableComponentType VariableComponentType; + /// DoF types definition typedef typename Node<3>::DofType DofType; typedef typename DofType::Pointer DofPointerType; diff --git a/kratos/utilities/constraint_utilities.cpp b/kratos/utilities/constraint_utilities.cpp index 1a864b6adedc..09a8f2a0d9d3 100644 --- a/kratos/utilities/constraint_utilities.cpp +++ b/kratos/utilities/constraint_utilities.cpp @@ -145,9 +145,7 @@ void PreComputeExplicitConstraintConstribution( KRATOS_ERROR_IF_NOT(rDofVariableNames.size() == rResidualDofVariableNames.size()) << "PreComputeExplicitConstraintConstribution not properly defined variables" << std::endl; // Defining variable maps - std::unordered_map*> double_variable_map; - typedef ModelPart::VariableComponentType VariableComponentType; - std::unordered_map components_variable_map; + std::unordered_map*> variable_map; std::size_t counter = 0; for (auto& r_dof_variable_name : rDofVariableNames) { @@ -156,21 +154,21 @@ void PreComputeExplicitConstraintConstribution( if (KratosComponents>::Has(r_dof_variable_name)) { const auto& r_check_dof = KratosComponents>::Get(r_dof_variable_name); const auto& r_residual_dof = KratosComponents>::Get(r_reaction_variable_name); - double_variable_map.insert({r_check_dof.Key(),&r_residual_dof}); + variable_map.insert({r_check_dof.Key(),&r_residual_dof}); } else if (KratosComponents>>::Has(r_dof_variable_name)) { // Getting the dof to check - const VariableComponentType& r_check_dof_x = KratosComponents::Get(r_dof_variable_name + "_X"); - const VariableComponentType& r_check_dof_y = KratosComponents::Get(r_dof_variable_name + "_Y"); - const VariableComponentType& r_check_dof_z = KratosComponents::Get(r_dof_variable_name + "_Z"); + const Variable& r_check_dof_x = KratosComponents>::Get(r_dof_variable_name + "_X"); + const Variable& r_check_dof_y = KratosComponents>::Get(r_dof_variable_name + "_Y"); + const Variable& r_check_dof_z = KratosComponents>::Get(r_dof_variable_name + "_Z"); // Getting the residual dofs - const VariableComponentType& r_residual_dof_x = KratosComponents::Get(r_reaction_variable_name + "_X"); - const VariableComponentType& r_residual_dof_y = KratosComponents::Get(r_reaction_variable_name + "_Y"); - const VariableComponentType& r_residual_dof_z = KratosComponents::Get(r_reaction_variable_name + "_Z"); + const Variable& r_residual_dof_x = KratosComponents>::Get(r_reaction_variable_name + "_X"); + const Variable& r_residual_dof_y = KratosComponents>::Get(r_reaction_variable_name + "_Y"); + const Variable& r_residual_dof_z = KratosComponents>::Get(r_reaction_variable_name + "_Z"); - components_variable_map.insert({r_check_dof_x.Key(), &r_residual_dof_x}); - components_variable_map.insert({r_check_dof_y.Key(), &r_residual_dof_y}); - components_variable_map.insert({r_check_dof_z.Key(), &r_residual_dof_z}); + variable_map.insert({r_check_dof_x.Key(), &r_residual_dof_x}); + variable_map.insert({r_check_dof_y.Key(), &r_residual_dof_y}); + variable_map.insert({r_check_dof_z.Key(), &r_residual_dof_z}); } else { KRATOS_ERROR << "Variable is not an array or a double" << std::endl; } @@ -212,11 +210,8 @@ void PreComputeExplicitConstraintConstribution( if (r_dof_slave->Id() != p_slave_node->Id()) p_slave_node = rModelPart.pGetNode(r_dof_slave->Id()); - if (double_variable_map.find(slave_variable_key) != double_variable_map.end()) { - const auto& r_aux_var = *(double_variable_map.find(slave_variable_key)->second); - slave_solution_vector[counter] = p_slave_node->FastGetSolutionStepValue(r_aux_var); - } else if (components_variable_map.find(slave_variable_key) != components_variable_map.end()) { - const auto& r_aux_var = *(components_variable_map.find(slave_variable_key)->second); + if (variable_map.find(slave_variable_key) != variable_map.end()) { + const auto& r_aux_var = *(variable_map.find(slave_variable_key)->second); slave_solution_vector[counter] = p_slave_node->FastGetSolutionStepValue(r_aux_var); } else { slave_solution_vector[counter] = 0.0; @@ -236,13 +231,8 @@ void PreComputeExplicitConstraintConstribution( if (r_dof_master->Id() != p_master_node->Id()) p_master_node = rModelPart.pGetNode(r_dof_master->Id()); - if (double_variable_map.find(master_variable_key) != double_variable_map.end()) { - const auto& r_aux_var = *(double_variable_map.find(master_variable_key)->second); - double& aux_value = p_master_node->FastGetSolutionStepValue(r_aux_var); - #pragma omp atomic - aux_value += master_solution_vector[counter]; - } else if (components_variable_map.find(master_variable_key) != components_variable_map.end()) { - const auto& r_aux_var = *(components_variable_map.find(master_variable_key)->second); + if (variable_map.find(master_variable_key) != variable_map.end()) { + const auto& r_aux_var = *(variable_map.find(master_variable_key)->second); double& aux_value = p_master_node->FastGetSolutionStepValue(r_aux_var); #pragma omp atomic aux_value += master_solution_vector[counter]; @@ -270,15 +260,14 @@ void PreComputeExplicitConstraintMassAndInertia( KRATOS_TRY // Defining variable maps - typedef ModelPart::VariableComponentType VariableComponentType; std::unordered_map*> displacement_variable_map; -// std::unordered_map displacement_variable_map; // NOTE: Mass should be components for consistency -// std::unordered_map rotation_variable_map; // TODO: Add in the future +// std::unordered_map*> displacement_variable_map; // NOTE: Mass should be components for consistency +// std::unordered_map*> rotation_variable_map; // TODO: Add in the future // Getting the displacement dof to check - const VariableComponentType& r_check_dof_x = KratosComponents::Get(DofDisplacementVariableName + "_X"); - const VariableComponentType& r_check_dof_y = KratosComponents::Get(DofDisplacementVariableName + "_Y"); - const VariableComponentType& r_check_dof_z = KratosComponents::Get(DofDisplacementVariableName + "_Z"); + const Variable& r_check_dof_x = KratosComponents>::Get(DofDisplacementVariableName + "_X"); + const Variable& r_check_dof_y = KratosComponents>::Get(DofDisplacementVariableName + "_Y"); + const Variable& r_check_dof_z = KratosComponents>::Get(DofDisplacementVariableName + "_Z"); // Getting the residual dofs const Variable& r_mass_dof_x = KratosComponents>::Get(MassVariableName); From dcda66368b5c33f6c74dd6bc492963b75843b55c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Sat, 2 May 2020 20:32:23 +0200 Subject: [PATCH 313/314] [ContactStructuralMechanicsApplication] Get rid of ExternalSolversApplication It is deprecated, so I remove the dependency --- ...tact_simplest_patch_matching_slope_test_parameters.json | 5 +---- .../3D_contact_patch_test_large_disp_hexa_parameters.json | 6 +----- .../tests/test_ContactStructuralMechanicsApplication.py | 7 ------- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/applications/ContactStructuralMechanicsApplication/tests/ALM_frictionless_contact_test_3D/3D_contact_simplest_patch_matching_slope_test_parameters.json b/applications/ContactStructuralMechanicsApplication/tests/ALM_frictionless_contact_test_3D/3D_contact_simplest_patch_matching_slope_test_parameters.json index 2c3fc1bda353..55a4c3c1ae99 100755 --- a/applications/ContactStructuralMechanicsApplication/tests/ALM_frictionless_contact_test_3D/3D_contact_simplest_patch_matching_slope_test_parameters.json +++ b/applications/ContactStructuralMechanicsApplication/tests/ALM_frictionless_contact_test_3D/3D_contact_simplest_patch_matching_slope_test_parameters.json @@ -35,10 +35,7 @@ "displacement_absolute_tolerance" : 1e-9, "residual_relative_tolerance" : 0.0001, "residual_absolute_tolerance" : 1e-9, - "max_iteration" : 10, - "linear_solver_settings" : { - "solver_type" : "ExternalSolversApplication.super_lu" - } + "max_iteration" : 10 }, "processes" : { "constraints_process_list" : [{ diff --git a/applications/ContactStructuralMechanicsApplication/tests/mesh_tying_test/3D_contact_patch_test_large_disp_hexa_parameters.json b/applications/ContactStructuralMechanicsApplication/tests/mesh_tying_test/3D_contact_patch_test_large_disp_hexa_parameters.json index 760bb89fe5a0..d04d7b575d9a 100644 --- a/applications/ContactStructuralMechanicsApplication/tests/mesh_tying_test/3D_contact_patch_test_large_disp_hexa_parameters.json +++ b/applications/ContactStructuralMechanicsApplication/tests/mesh_tying_test/3D_contact_patch_test_large_disp_hexa_parameters.json @@ -32,11 +32,7 @@ "displacement_absolute_tolerance" : 1e-9, "residual_relative_tolerance" : 0.0001, "residual_absolute_tolerance" : 1e-9, - "max_iteration" : 30, - "linear_solver_settings" : { - "solver_type" : "ExternalSolversApplication.super_lu", - "scaling" : false - } + "max_iteration" : 30 }, "processes" : { "constraints_process_list" : [{ diff --git a/applications/ContactStructuralMechanicsApplication/tests/test_ContactStructuralMechanicsApplication.py b/applications/ContactStructuralMechanicsApplication/tests/test_ContactStructuralMechanicsApplication.py index 9d155f00cbdc..213b335a8eb9 100755 --- a/applications/ContactStructuralMechanicsApplication/tests/test_ContactStructuralMechanicsApplication.py +++ b/applications/ContactStructuralMechanicsApplication/tests/test_ContactStructuralMechanicsApplication.py @@ -5,13 +5,6 @@ # Import Kratos "wrapper" for unittests import KratosMultiphysics.KratosUnittest as KratosUnittest -# Using kratos_utilities -import KratosMultiphysics.kratos_utilities as kratos_utilities -if kratos_utilities.CheckIfApplicationsAvailable("ExternalSolversApplication"): - has_external_solvers_application = True -else: - has_external_solvers_application = False - import os import sys def GetFilePath(fileName): From 06008a1386bc78168ee4ac61e58510c271b46c0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Sat, 2 May 2020 20:37:44 +0200 Subject: [PATCH 314/314] Update test --- .../friction_block_test_results.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/ContactStructuralMechanicsApplication/tests/ALM_frictional_contact_test_3D/friction_block_test_results.json b/applications/ContactStructuralMechanicsApplication/tests/ALM_frictional_contact_test_3D/friction_block_test_results.json index 51ae3e0f6aa5..181cc52860f8 100644 --- a/applications/ContactStructuralMechanicsApplication/tests/ALM_frictional_contact_test_3D/friction_block_test_results.json +++ b/applications/ContactStructuralMechanicsApplication/tests/ALM_frictional_contact_test_3D/friction_block_test_results.json @@ -1 +1 @@ -{"TIME": [0.10000000000000002, 0.2000000000000001, 0.30000000000000016, 0.40000000000000024, 0.5000000000000003, 0.6000000000000004, 0.7000000000000005, 0.8000000000000006, 0.9000000000000007, 1.0050000000000006, 1.1099999999999983, 1.214999999999996, 1.3199999999999938], "NODE_1": {"REACTION_X": [-38.94039630855634, -58.87138044956092, -73.97901319572595, -401.4325166294225, -5239.571080527782, -10927.997435289957, -11889.34355727601, -14382.446642922197, -28407.594442071346, -72523.90935734897, -172418.8002985872, -323808.57998998236, -477283.9742063641], "REACTION_Y": [65.2469592615672, 98.78687605502193, 125.00645597660127, 710.2699401159655, 9161.953883881753, 19615.550720227173, 21068.4904255639, 18484.005019952627, 14414.511564241262, 34459.65379604734, 143875.53238570265, 466075.262336763, 1069403.6367059771], "REACTION_Z": [-15.268576157168159, -23.13551964197925, -29.363965775499913, -169.4911498365983, -2173.300918459568, -4675.269755390553, -4939.915560510324, -3572.994924953581, -321.24793060873014, -877.2524657102726, -22307.797716040273, -107997.7165505581, -293379.66152758827]}, "NODE_3": {"REACTION_X": [-77.880779494807, -117.74269687669613, -147.9581413746197, -802.871927458385, -10478.5688033145, -21864.645712288962, -23760.258784909493, -28828.761049496636, -56797.2583539629, -144785.1176406739, -344488.70400180924, -646920.2576248792, -953377.9268349903], "REACTION_Y": [130.49390012395818, 197.57365784193263, 250.01308694101644, 1420.5430584091496, 18323.58749604773, 39236.41195677225, 42125.34271469817, 37004.989627745395, 28842.10187455495, 68684.53653769044, 286902.3663273426, 930124.3130704497, 2134881.498144828], "REACTION_Z": [7.787722427821109e-06, 4.0959646174343334e-05, -7.73813933534484e-05, 0.00021031057028153555, 0.0006253785545595747, -0.018703570317484264, -0.014071102197704022, -0.02881649847222434, 0.03338975791905341, 0.8860784578839684, 1.6493297062406782, 2.8857392542558955, 5.886494210688397]}, "NODE_4": {"REACTION_X": [-65.28086126689972, -98.14068722905962, -121.0246843187534, -599.030614016901, -8216.54954388014, -17194.94091096661, -21582.30312780505, -48631.35013764508, -123687.17642635967, -257848.47154873697, -428171.6761757516, -506729.6328622018, -393934.02863973466], "REACTION_Y": [45.7308246882566, 69.5875193116018, 87.91677933506178, 436.69381742713745, 5384.135982775803, 8865.42769647074, 2331.344367625566, -562.1243662132692, 40337.4859785768, 192205.563289281, 546351.7496928808, 1153136.9651339226, 1935186.8320858257], "REACTION_Z": [-14.650716509277306, -22.320266058600676, -28.27921905999902, -141.35990893277014, -1725.4983569141352, -2779.5684536115027, -465.4417687642051, 1334.20202747197, -10535.193560714157, -59681.40913903018, -179909.89143110893, -392278.5749308546, -664299.7598086185]}, "NODE_7": {"REACTION_X": [-130.56167248036544, -196.28108966777046, -242.0499428532134, -1198.034064133898, -16435.914852099402, -34355.7755435916, -43223.975271081814, -97146.7182271881, -247081.46621658903, -515209.91725461645, -855304.354732932, -1012382.950327177, -787445.0100701943], "REACTION_Y": [91.46158456563994, 139.1746866076508, 175.834248228695, 873.3752944616037, 10770.060895125338, 17709.492390216303, 4697.29642922251, -1141.8141941962913, 80239.16576484204, 383017.07743504265, 1089793.0207686317, 2301281.225898213, 3862990.4765315], "REACTION_Z": [2.751323938454675e-05, 0.00014479396691768898, -0.0002749708864868694, 0.0007137326801824884, 0.0016610114973900636, 0.012120210200919246, -0.07545946338632348, -0.10583664678438254, 0.615028742996401, 2.902306790500006, 3.038740010029869, 3.8573582813551184, 1.3411575588979758]}, "NODE_12": {"REACTION_X": [-38.9403836810645, -58.87131397964394, -73.97913926304392, -401.4321729896657, -5239.569829642673, -10928.052101421661, -11889.37934663121, -14382.568822897196, -28407.315955337614, -72522.24802742006, -172417.2961018317, -323806.97411089233, -477286.2912811655], "REACTION_Y": [65.24694114934871, 98.78678044046853, 125.00663674461379, 710.269448311889, 9161.952349846319, 19615.602196571683, 21068.52668063561, 18484.093703252154, 14414.376567830885, 34457.513904196676, 143871.9442122702, 466069.2269650125, 1069392.8041113194], "REACTION_Z": [15.268576785017679, 23.135523052897902, 29.363959371863775, 169.4911663740346, 2173.3009457810845, 4675.271830044341, 4939.91485450783, 3572.9991033545402, 321.22943712413166, 877.4822969432075, 22307.950216191028, 107997.74014767303, 293377.6793935702]}, "NODE_15": {"REACTION_X": [-65.28080952914951, -98.14041315819897, -121.02520543407906, -599.0292980772471, -8216.547900406567, -17194.779473067058, -21582.416782636163, -48631.32467853813, -123685.76362364751, -257845.99109313174, -428171.8937972677, -506733.42009522545, -393943.06676872657], "REACTION_Y": [45.730758982556154, 69.58717303786531, 87.91743718118782, 436.69212187333926, 5384.132454334953, 8865.35384272602, 2331.5201817288184, -561.9319698684267, 40335.930304209214, 192199.55522726872, 546345.9512354097, 1153130.1640023165, 1935182.4343080423], "REACTION_Z": [14.650711042288792, 22.320237147429314, 28.279273998819235, 141.35976620377903, 1725.4980247250537, 2779.566030503296, 465.4568578119604, -1334.1808919651485, 10535.0711244737, 59680.8325096739, 179909.2877340772, 392277.80952695466, 664299.4929703381]}, "NODE_17": {"REACTION_X": [-99.68818569171314, -147.6361268104157, -176.1628980276726, -848.6101077860243, -13291.574899996438, -33121.09003710689, -67696.9240941994, -163060.97172350305, -300488.1842161741, -418114.92023835605, -412662.8717840274, -271215.0558432308, -26302.25618258372], "REACTION_Y": [44.21203900133935, 65.45273745188281, 73.6926220108661, 80.31575443677576, 2099.9685654657474, -1026.9243742699364, 1079.977825444057, 78282.10028256057, 327824.9207913387, 802719.1346742131, 1443674.7953923855, 1963382.1208802206, 2203414.449045273], "REACTION_Z": [-14.470007263776509, -21.4945735415017, -24.371240204954912, -26.403128604150275, -634.3201588915323, 644.0520416908055, 1013.2497118740225, -22409.39218548098, -104959.97011816093, -268411.8500640785, -496241.52364911925, -679071.0896751478, -760620.0897470014]}, "NODE_22": {"REACTION_X": [-199.376161842518, -295.27122967182146, -352.3275390588549, -1697.3180939076074, -26568.150242233663, -66372.26767153712, -135257.63232267645, -325882.0013856775, -600384.4976326033, -835080.9553447401, -824187.338738577, -541749.742780222, -52532.45982483911], "REACTION_Y": [88.42380106423258, 130.9040517262156, 147.3878117753238, 160.65155912113244, 4189.791815572066, -1976.2174417259575, 2114.685303372091, 155969.2163111157, 653806.493847988, 1601494.4054057049, 2880646.5521098976, 3918402.7292800765, 4398111.277214357], "REACTION_Z": [0.00011473338657275178, 0.000609177601411659, -0.0011577494472465588, 0.003101662642471581, 0.006338768460011579, -0.2345202791493648, 0.004872664211234223, 0.06730793265523971, 2.59785480589926, 4.823205692766351, 0.5000268067524303, -4.701862166286446, -2.686485089128837]}, "NODE_30": {"REACTION_X": [-99.68798354035488, -147.63505246713459, -176.1649255233381, -848.6042843753847, -13291.562554078722, -33122.37643311093, -67696.37800249428, -163060.30515884273, -300486.1980192686, -418117.89414649876, -412665.8316695294, -271218.7614144783, -26303.704912355315], "REACTION_Y": [44.21176603056719, 65.45128799445133, 73.69537401705782, 80.30828737100362, 2099.9529781498472, -1026.1364881753088, 1079.8196448181516, 78281.78451679484, 327819.3952700854, 802710.371973156, 1443673.9380603828, 1963390.847576186, 2203419.365212526], "REACTION_Z": [14.469984258980414, 21.49445168360254, 24.371471762984513, 26.402508241810665, 634.3188912863384, -644.0051178176382, -1013.2506671957922, 22409.379019873704, 104959.45508621885, 268410.89228488476, 496241.4224495447, 679072.0046775979, 760620.613395829]}, "NODE_36": {"REACTION_X": [-141.83640453771307, -205.77492858593624, -241.70095568803123, -1605.663524705211, -26970.12747570225, -92440.50700562425, -204263.4213035776, -361479.71138450317, -438029.6254957343, -346671.92425349355, -117825.81147893297, 145709.85060932772, 359271.3039893671], "REACTION_Y": [68.74652404035584, 92.04421115352932, 75.38877802797373, -261.43527785180413, 5034.804830165656, 27836.31843178094, 134537.5495989924, 469750.52360755514, 1037550.0704765592, 1692371.2970147533, 2106828.1437004874, 2213620.63360334, 1952858.9015204082], "REACTION_Z": [-22.687582283749535, -30.473632903903987, -24.93459376439956, 105.69057285772868, -1361.3429275998658, -7481.227014685459, -40567.377175785856, -152723.05421313707, -350677.2432493046, -583377.5405960134, -727269.163209044, -763741.6598993081, -673402.1146505775]}, "NODE_38": {"REACTION_X": [-283.6720965228219, -411.54574233173895, -483.4104531661018, -3210.787289877204, -54013.3533335002, -184514.0231333941, -408183.6359922402, -722143.5225535072, -874869.6088229017, -692363.131588313, -235534.46138572748, 291113.48245537846, 717941.4060479689], "REACTION_Y": [137.49202268508836, 184.08281183015987, 150.78891219359974, -523.0546073903276, 10124.742697410526, 55483.12477566759, 268285.13669076073, 937289.9970297465, 2070361.6222297326, 3377055.156741867, 4204897.260531586, 4418480.509062609, 3897999.303673723], "REACTION_Z": [0.00044118464524345313, 0.0023283921652712536, -0.0043236664820511805, 0.012819563998220929, 0.002534599717449737, -1.7765933315490656, 0.6405877335541845, 1.1329594826383982, 4.721153303835308, -3.0420395213295706, -3.090587919286918, -4.074698139273096, -1.6935306142549962]}, "NODE_43": {"REACTION_X": [-141.83566090470055, -205.7710520722828, -241.7079923216807, -1605.6413811449384, -26970.127366006178, -92442.696795634, -204263.1463562806, -361478.6409537485, -438031.38795228093, -346676.506036496, -117827.1118889983, 145711.16696433086, 359272.2920065063], "REACTION_Y": [68.74548290818998, 92.0387273975602, 75.39891973712608, -261.4656867090335, 5034.803255619678, 27840.352928914912, 134536.24990778315, 469748.1156371496, 1037541.2185460192, 1692376.7585574863, 2106834.0280479835, 2213629.066652361, 1952862.7441544798], "REACTION_Z": [22.687494040274558, 30.473167259560213, 24.93545849709652, -105.69313672177795, 1361.3424179599665, 7481.581319960462, 40567.24980259527, 152722.83017652866, 350676.30961999355, 583378.1317309366, 727269.7649046651, 763742.4536029068, 673402.4447627484]}, "NODE_49": {"REACTION_X": [-205.09548314794708, -303.93958111208565, -409.3344496496051, -4912.6603712167225, -69327.22921558097, -224719.5365926931, -387849.2132654837, -433370.4990497039, -294631.5988621484, -5323.86231792433, 271559.1206897078, 484037.59028289013, 525141.4941037149], "REACTION_Y": [91.43219305694244, 100.0703871645344, 41.73078931114618, 930.8722631725786, 40925.41964175481, 211060.1924019685, 616043.8370091206, 1282256.2229031944, 1897293.8525517364, 2197276.3730668095, 2153026.3014575783, 1802305.943839445, 1202601.9310138898], "REACTION_Z": [-30.18926167472881, -32.64337047135605, -11.066165572200642, -214.7495976851019, -12424.757311296718, -66717.17227055402, -203469.8272540088, -438047.26855169865, -654982.0030390922, -758192.0899333179, -742492.2425677476, -620728.704946407, -409110.3836597684]}, "NODE_51": {"REACTION_X": [-410.1877483334936, -607.8644833957168, -818.6900002865938, -9828.694737543048, -138341.88891395766, -449244.79039480916, -774984.935338072, -865866.8865954129, -588621.8995230178, -10785.598896567099, 542781.5586697863, 967279.0305180227, 1049103.2919132817], "REACTION_Y": [182.8602108325394, 200.12010194768408, 83.49163290284004, 1863.1808570530202, 81580.29927905994, 420977.539409495, 1229629.510435631, 2559356.2282513594, 3786651.3260791907, 4385593.824889421, 4297686.939667363, 3597571.4725240413, 2400502.339764903], "REACTION_Z": [0.001730857280952236, 0.00894772531151844, -0.016191322194084368, 0.0514409189078151, 0.30465610237092733, -4.877593410370537, 1.843598207255127, 3.07305205395096, -2.1170572508708574, -4.142769359285012, -2.1382564148516394, -2.154279080510605, -1.296274541033199]}, "NODE_55": {"REACTION_X": [-205.09238583109249, -303.9237340024031, -409.363497644562, -4912.576539630178, -69326.20884627577, -224721.2135252767, -387849.0715351761, -433371.0912665528, -294638.639702947, -5323.691082924459, 271560.19180196535, 484038.9991573122, 525142.2903325082], "REACTION_Y": [91.42805927106528, 100.04906157810959, 41.7694326978481, 930.7509476390669, 40924.55914927608, 211069.96667834817, 616040.2539337005, 1282250.4069136914, 1897298.4118672877, 2197284.7972574015, 2153030.837786506, 1802310.772505893, 1202604.6408109192], "REACTION_Z": [30.188915522992872, 32.6415809370342, 11.069403849489314, 214.7393107967203, 12424.696562466346, 66718.14348538162, 203469.46105968498, 438046.6629270525, 654982.4115205703, 758192.896922325, 742492.658893337, 620729.1248611887, 409110.6380100343]}, "NODE_61": {"REACTION_X": [-325.79325528041505, -562.7958622736128, -1034.7394921385549, -15106.035355410724, -129087.70056759559, -305328.08090532746, -313490.51375984494, -144553.46444097644, 114197.59150816538, 380626.699710137, 543932.9953546671, 549817.7873102069, 407458.7682377744], "REACTION_Y": [90.00406555102705, 97.89637751292113, 209.29030820909054, 12535.654153544792, 173242.34707472945, 671642.4324651456, 1396306.522469246, 1986588.3737861973, 2227399.6873595295, 2051349.8910255614, 1587720.8158751642, 966394.9517598738, 462463.4765324753], "REACTION_Z": [-28.738678847470283, -28.009731026359987, -53.99236290364515, -3863.140061740548, -56618.47216951468, -227508.46131137726, -484461.2801994028, -690101.6482008013, -770570.9888355826, -707714.190259417, -545139.9062773273, -324752.25048126065, -150546.03330958114]}, "NODE_63": {"REACTION_X": [-651.5750511990544, -1125.5226452178024, -2069.6678446815868, -30133.778459229645, -257594.00926487258, -609710.5532180008, -626309.8520459576, -288575.87404042186, 227896.12483787, 760689.2776721562, 1086863.37619292, 1098512.43056678, 814325.3220484194], "REACTION_Y": [179.99276406260532, 195.70941445621466, 418.828221495512, 24965.53388043347, 344913.1741408891, 1340309.8629180035, 2787614.037566955, 3965761.1521207555, 4446698.5902918205, 4094784.1333783967, 3169299.2348674852, 1929132.932508709, 923147.4006180877], "REACTION_Z": [0.006874447737390099, 0.03517403258303098, -0.06757830915084462, 0.1377835917022594, 1.3335330829540908, -5.587823124151328, -0.4946604933356866, -1.4785727125126868, -7.044733304239344, -2.67790673696436, -0.9978407932794653, -1.4480619600217324, -0.37038835618295707]}, "NODE_67": {"REACTION_X": [-325.780717790324, -562.7300183966519, -1034.8765104276038, -15105.87359632151, -129087.11697460427, -305320.81634871423, -313494.54760691675, -144557.7784000339, 114195.94871576567, 380627.91644083086, 543933.7843576607, 549818.7508802426, 407459.23468090256], "REACTION_Y": [89.98762974998067, 97.81198536924856, 209.45483861325675, 12535.349475586238, 173239.60457077794, 671652.1784065727, 1396307.8039189328, 1986591.2893952918, 2227413.877965481, 2051355.726040644, 1587723.1039974913, 966398.0104297694, 462464.3084764277], "REACTION_Z": [28.737303959640546, 28.002696216945655, 54.00587833533472, 3863.112520057023, 56618.206297717305, 227509.57419192337, 484461.3750586936, 690101.9352297606, 770572.3609811009, 707714.7117984692, 545140.1010310748, 324752.5351587537, 150546.10638097458]}, "NODE_73": {"REACTION_X": [-394.4585697997636, -813.28865339871, -1743.8730318228668, -18130.906970438988, -90118.92719107219, -121650.86375153797, 14122.375919265527, 185859.26479275862, 331798.1387094433, 422112.833605275, 413903.09511498595, 296979.60678847536, 168514.64153205702], "REACTION_Y": [28.556650105326923, 102.70817074243877, 728.4877902329026, 29819.51761242831, 269437.1053234534, 810556.4801164619, 1238626.6632700865, 1437683.8893786576, 1390807.9815823843, 1056024.8926727138, 618688.8435887464, 289196.8965044873, 101804.65474963844], "REACTION_Z": [-6.495959450337988, -23.187652598185423, -207.2405217698372, -9621.955754861263, -92704.7556905302, -285258.5771768878, -433790.07624377974, -499209.7466567996, -480311.99054102605, -360359.2052054806, -205878.44715827104, -92980.7851283949, -30973.551885853016]}, "NODE_75": {"REACTION_X": [-788.884916733655, -1626.487669846373, -3488.131168091655, -36202.75170244208, -179879.50101385816, -242614.89283301082, 28176.187960167736, 371278.0516182522, 663688.5298235143, 843489.9636843456, 826880.6310203447, 593693.2999545838, 336821.3214872993], "REACTION_Y": [57.08264527480193, 205.31487850530425, 1457.410056593957, 59383.56890034658, 536427.1571606919, 1617188.5040100962, 2473066.02310404, 2869708.590063705, 2776606.745683171, 2107929.3590569114, 1235036.0348888207, 577281.0268226117, 203162.43011028372], "REACTION_Z": [0.011276584249894528, 0.05609631872566334, -0.11427130676720765, 0.18071981665525527, 1.4472031788609456, 5.30860186056816, -2.3180499227019027, -2.2320994632900693, -6.2210497508058324, -1.5779006565571763, -0.5731390673317946, -0.3952801538835047, -0.03281454749230761]}, "NODE_79": {"REACTION_X": [-394.4330250316438, -813.144629449818, -1744.206706710654, -18130.171215171787, -90120.8517010032, -121644.51506285532, 14119.507384970435, 185855.4375447712, 331802.3470978844, 422113.64465676807, 413903.34136900876, 296980.06022844044, 168514.86775284132], "REACTION_Y": [28.528915834788393, 102.56868283065376, 728.7791297224386, 29818.984933530475, 269435.43715839967, 810547.4803677531, 1238633.107906834, 1437690.8602918517, 1390817.5935956633, 1056028.1784108644, 618690.0392160778, 289197.7578232647, 101804.7846692366], "REACTION_Z": [6.493704132211821, 23.17643355934394, 207.26337408554076, 9621.91966413958, 92704.46755381921, 285257.5321853071, 433790.531226723, 499210.1846241527, 480313.2036281723, 360359.5140817829, 205878.56013469206, 92980.86322925593, 30973.558383636828]}, "NODE_84": {"REACTION_X": [-413.70102996337687, -974.9050454423322, -2185.5176663068346, -11338.435948440656, -18390.757382883134, 57857.550517077936, 167436.3095383326, 245728.70082248872, 287855.3109216191, 262733.79510504333, 189010.82644199528, 109625.07705946744, 51868.42655590513], "REACTION_Y": [48.95918463705095, 351.4281333501234, 1701.4625108562473, 31906.41690030823, 198710.50447313377, 504233.9967536565, 671540.904176758, 702898.087929497, 619626.1319617507, 407607.0897061883, 178675.5561214018, 61375.48299965239, 13651.582175940715], "REACTION_Z": [-10.543115113030597, -92.64360430862622, -485.820146837437, -10458.800215812462, -66297.48507281949, -168192.50696843304, -221834.51098447014, -229735.49163367535, -200881.3238711709, -130064.00180597515, -54610.052396723906, -17693.92560249324, -3551.883027911816]}, "NODE_86": {"REACTION_X": [-827.4172115351367, -1949.265295499432, -4375.455941087457, -22522.64035829222, -36022.79232186929, 115266.26743583282, 334724.41966099653, 491129.3841448021, 574586.6120739621, 524825.4431198903, 378003.44784030225, 218961.60129039054, 103633.40921024198], "REACTION_Y": [97.91500579354198, 702.4185087884265, 3406.8937108031887, 63488.76814409907, 394999.05573225656, 1005705.3827940088, 1340544.978147007, 1402883.8991786456, 1236638.105841921, 813655.0784951686, 356650.8500494538, 122441.33806099868, 27275.786532862858], "REACTION_Z": [0.015480915041263033, 0.08198064607984534, -0.19815799751495433, 0.4878323537095639, -0.8513288758404087, 4.070649711065926, -3.542587260468281, -4.3367221054650145, 0.8821081999049056, -0.5641825892671477, -0.24217637473338982, -0.05452384400268784, 0.024131891269462358]}, "NODE_91": {"REACTION_X": [-413.6657655469672, -974.6866254652739, -2186.084310187958, -11337.395362370256, -18392.61372095451, 57859.35359866914, 167434.66204130222, 245725.92442500126, 287862.53815094935, 262734.48340544786, 189010.96827712923, 109625.31880619614, 51868.41488896323], "REACTION_Y": [48.919608831217374, 351.2132928733354, 1702.0012334149021, 31905.028872381736, 198712.04044132266, 504224.54368584976, 671546.8039284579, 702906.0017117746, 619625.6007888387, 407608.32542063214, 178676.07310992133, 61375.66612207023, 13651.526977854817], "REACTION_Z": [10.540018975506777, 92.62720908149822, 485.8597709730674, 10458.702774928055, 66297.65453991029, 168191.70164070767, 221835.2091951818, 229736.34526459308, 200881.14456141455, 130064.11261423159, 54610.10035082157, 17693.93643102951, 3551.8782127235518]}, "NODE_96": {"REACTION_X": [-687.2141234288738, -1703.2243116880402, -3261.954789623878, -6596.155254061231, 15804.197307854254, 114175.86469327135, 211423.54216987203, 260619.16622991662, 270511.09534295416, 218077.37376035814, 134680.0586156042, 70803.85891768387, 33567.85068715361], "REACTION_Y": [156.8472866689873, 1014.464941144671, 3717.9088520670334, 39929.35336329257, 185120.96855230513, 403912.6259109641, 495531.56214644446, 491192.486821105, 408191.8249490476, 249698.14095109634, 92520.4445803859, 29268.90837725649, 8339.3877828261], "REACTION_Z": [-35.77175510206847, -264.51613908033465, -1051.9870525987276, -12371.625168196744, -57227.027831915344, -123815.99789769684, -150520.71247306914, -147834.9053200812, -121773.6132486863, -73050.31493427356, -25878.747443502125, -7934.021394825857, -2236.5692676210224]}, "NODE_99": {"REACTION_X": [-1374.0164238977536, -3408.44031490683, -6525.095219402646, -13046.807817492088, 31559.466960540492, 228895.36461074237, 422756.1773306808, 521131.4337942045, 540753.5526039769, 436009.42463569104, 268959.6344117627, 141574.59551308953, 67181.31196945293], "REACTION_Y": [313.3808333267835, 2030.153458486568, 7442.773410479897, 79284.22748545809, 367143.6505551003, 804794.038315498, 988530.0084183199, 979432.8791607257, 814820.931821616, 498332.4427959429, 184611.6391124326, 58506.93624739893, 16713.387527776016], "REACTION_Z": [0.025649740038257818, 0.15524059808109314, -0.4250198929020712, 1.0200040799672934, -1.8881118812387285, 3.890449134676601, -3.25976473679475, -4.818144829652738, 3.7002522227267036, -0.263341487145226, -0.1378824595703918, 0.004641513639398909, 0.010853025411506678]}, "NODE_103": {"REACTION_X": [-687.1472434892542, -1702.7388039637576, -3263.1733914615907, -6594.962377671684, 15802.423614465617, 114175.35815749769, 211422.92877927853, 260617.58137032686, 270516.27778069506, 218077.78329477832, 134680.25048854234, 70803.93300033192, 33567.83161609618], "REACTION_Y": [156.77672510815393, 1014.0157981899931, 3719.1356197494133, 39926.86403201623, 185125.02386701282, 403902.882093225, 495539.4425730221, 491203.7161205216, 408183.41322673776, 249698.84742620314, 92520.7980839978, 29268.91497723382, 8339.357896228456], "REACTION_Z": [35.76662530757226, 264.48509497116873, 1052.0720309400915, 12371.42140745678, 57227.403951363915, 123815.22783836005, 150521.35520753643, 147835.85496309533, 121772.88000708628, 73050.36678285105, 25878.774824583947, 7934.020470368909, 2236.5670994808215]}, "NODE_109": {"REACTION_X": [-1541.8058875107986, -3316.1997870361174, -4976.112266301513, 509.5773157480253, 37559.49693634103, 143241.18997249112, 224539.15908693726, 253202.54614101644, 244426.30718889443, 182451.078781906, 100724.25418498626, 54316.03053925204, 28008.176288024806], "REACTION_Y": [785.8531333402498, 3246.386679379409, 8523.673810749828, 48391.185202259876, 168693.76566037853, 311180.4936452306, 346840.49328889995, 327504.8212814965, 258003.39722363523, 150326.5345277849, 50889.676863469154, 19537.97006930187, 9647.5898096842], "REACTION_Z": [-193.86283706510093, -867.9347210304371, -2405.632624898392, -14020.899114930118, -47579.40218972511, -87100.7024969307, -96546.79356361722, -90367.62674056445, -70408.82863010744, -40525.45470759549, -13381.976792938682, -5131.844680996972, -2629.8719040809074]}, "NODE_111": {"REACTION_X": [-3085.022080142366, -6633.352259010597, -9962.381851089722, 1180.7760304324274, 75287.49397219202, 285815.4297589293, 448590.3176770665, 505370.6464470228, 488332.66663525556, 364409.26083160844, 201419.14216706844, 108634.04299087667, 56012.647428236145], "REACTION_Y": [1572.6916013796383, 6497.252706039448, 17064.745386123333, 95821.96342971816, 333524.78675185813, 618822.9563545391, 691171.8505706646, 652594.5058325263, 514783.77292611566, 299989.8975625179, 101711.03453869224, 39075.51476663598, 19294.131754496866], "REACTION_Z": [0.06234736412807962, 0.4719234496976128, -1.3243819137276205, 1.9061946142919624, -2.042067923775903, 4.479937175055966, -2.3948400743320235, -4.299983726610662, 5.10624917014502, -0.06617341998935444, -0.05995883493324072, 0.011312169823668228, 0.0046214865487854695]}, "NODE_115": {"REACTION_X": [-1541.6239283162433, -3314.8239093118555, -4979.40628590168, 511.46398528085774, 37561.61028086429, 143241.7570546614, 224543.1103329255, 253206.94121009833, 244424.885812557, 182451.51341234372, 100724.40534789691, 54316.0387856912, 28008.16711626722], "REACTION_Y": [785.6688640322647, 3244.9703906481272, 8527.571664675152, 48386.25634104569, 168698.3676864791, 311169.100357792, 346846.6109662861, 327515.45294872567, 257991.5015046284, 150326.80311889763, 50889.8560460165, 19537.94265512711, 9647.576667078602], "REACTION_Z": [193.8503686644488, 867.840359964649, 2405.8973889710323, 14020.518296216293, 47579.80879350542, 87099.81391543905, 96547.2663334021, 90368.47604930354, 70407.81685822373, 40525.46776754005, 13381.988736395193, 5131.842423396323, 2629.8709803495667]}, "NODE_121": {"REACTION_X": [-3271.2036756388115, -5424.839390792329, -5682.763739344871, 5042.613262601281, 41501.36199353094, 123826.172262999, 182303.57115547988, 198194.83153311806, 184427.6523493364, 134632.73466275405, 74345.73149124731, 42658.367755123385, 23986.16682814288], "REACTION_Y": [2922.3502313554013, 8485.752578278198, 16449.07379402768, 48054.32099099409, 128367.10158621022, 192978.90674766354, 184164.50145695542, 166971.03674609918, 129814.39729721707, 79651.31020149708, 31779.5092244918, 17477.09923978858, 11410.467046317739], "REACTION_Z": [-769.6105804964383, -2363.242987666499, -4744.603255738922, -13316.394463375997, -34588.88713821266, -52036.75785773354, -48808.10961717952, -43864.64307745201, -34009.80446999706, -20924.892366665146, -8340.95200968905, -4711.655172025464, -3157.2161439029314]}, "NODE_123": {"REACTION_X": [-6545.2931916690195, -10848.188158099858, -11383.397036153883, 10169.518563380461, 82745.02378804651, 247487.52427022654, 364326.87948652287, 396081.1206097406, 368491.18671513355, 269167.04146900016, 148672.01524191254, 85315.72177962186, 47973.390363723796], "REACTION_Y": [5850.241841472442, 16978.54270277735, 32941.80498181, 94749.76417182133, 252351.99736148585, 382675.5427954489, 366185.66587234556, 332467.6453721742, 259146.5920148544, 159131.25175894436, 63530.95890503434, 34952.89777397279, 22822.11802140756], "REACTION_Z": [0.18093039495988705, 1.544032635886424, -4.0028745753897965, 3.144055163568737, -0.3274941789240984, 4.729486432966951, -1.1972685992950574, -2.2724492188681324, 3.6871141767660447, -0.019508947551003075, -0.02116112679050275, 0.0058977191811209195, 0.0021858473753582075]}, "NODE_127": {"REACTION_X": [-3270.6417711001523, -5420.867380805774, -5690.54585400586, 5044.9161802295785, 41503.870482067185, 123824.12711057389, 182304.5507587871, 198197.4871080608, 184425.1397086765, 134632.79749217676, 74345.79976444747, 42658.363839642734, 23986.161646749675], "REACTION_Y": [2921.8029861573414, 8481.18176603877, 16460.489028303728, 48045.88065760696, 128368.10504370026, 192966.9297569935, 184167.7622772475, 166977.20727083346, 129804.91916751736, 79651.36189472458, 31779.57459433777, 17477.08328129487, 11410.460676145114], "REACTION_Z": [769.5744026685459, 2362.9343057780384, 4745.403434103557, 13315.76630358087, 34588.95205149006, 52035.81756068671, 48808.346637031485, 43865.09318144783, 34009.07237455072, 20924.896246145916, 8340.9562330346, 4711.653994079204, 3157.215706934321]}, "NODE_133": {"REACTION_X": [-5084.436050215614, -5817.411765481297, -3774.3029644679455, 5997.341591183188, 29318.725980557843, 77449.94812199441, 104647.29489462539, 112350.08448047114, 105989.286148485, 81732.26600554431, 48137.82982249987, 30101.603754435175, 18190.35906911919], "REACTION_Y": [7614.657289457819, 15623.768560501438, 22536.101845024255, 40010.68600391268, 85038.5878293378, 94345.34054076404, 65513.99402773466, 58254.51813705825, 49758.684340512926, 36880.87209474832, 20394.43575388426, 14336.839458755076, 9960.396470969075], "REACTION_Z": [-2111.046944592426, -4493.49910782771, -6547.402985395189, -10993.19917818622, -23193.23830786694, -25357.86280506024, -16599.490488376538, -14773.727855819767, -12834.989595911193, -9670.90552039082, -5471.510107071283, -3923.9137100353646, -2751.076583801827]}, "NODE_135": {"REACTION_X": [-10166.242867246021, -11642.524311726802, -7570.06713665445, 11940.847457728276, 57859.1157230365, 154244.8407934545, 208819.59088101104, 224188.91325193516, 211935.74177376146, 163437.6027326325, 96273.01380367207, 60203.16764274798, 36380.70564035379], "REACTION_Y": [15236.50195172174, 31265.531734546857, 45149.88687108241, 78631.87040657325, 166765.93637256246, 186259.49341594498, 129682.65989828098, 115888.97857403097, 99444.41307925223, 73721.3354062262, 40783.64388448041, 28673.507244233162, 19920.94995803301], "REACTION_Z": [0.5703630503760451, 4.5339847203904355, -9.603195165689158, 4.7919565624233655, 1.09312167081589, 3.206697239253117, -0.3579042205619771, -0.5016544233294553, 1.2739935120898735, -0.016688893047103193, -0.0060268225006439025, 0.0019486864962345862, 0.0008480959247663122]}, "NODE_139": {"REACTION_X": [-5082.875730840342, -5808.436200324011, -3787.0826537394705, 5999.958832427189, 29320.340271312925, 77447.55729713291, 104649.295032054, 112353.00092240812, 105985.4647565283, 81732.30228843512, 48137.851695353704, 30101.59989078689, 18190.356932878873], "REACTION_Y": [7612.956410206045, 15610.808600601931, 22562.25892083742, 39998.163308059186, 85036.2857032821, 94337.03694882928, 65515.34300757387, 58256.46322325595, 49754.630198007086, 36880.91873635079, 20394.454397043548, 14336.833721552492, 9960.394000098953], "REACTION_Z": [2110.932916742287, 4492.592752112896, 6549.322626232197, 10992.241658450293, 23193.020032928493, 25357.223997816513, 16599.561685496752, 14773.827627853934, 12834.735801349096, 9670.908850021988, 5471.51131128558, 3923.9133205971093, 2751.0764142586604]}, "NODE_145": {"REACTION_X": [-5653.793188545706, -4133.519562256547, -670.6388713749548, 6683.083319249479, 24195.491801269014, 47973.273307512914, 56234.69353101257, 62513.03266631452, 63452.917714405005, 52525.60271781685, 33667.089431514665, 22269.045072797187, 13843.734083533087], "REACTION_Y": [14569.111642381016, 22058.338482777974, 25264.4655132266, 33053.8540947076, 57915.09376473776, 44477.30147273351, 21519.672501094785, 21495.06928348913, 23586.52020797121, 21696.145786022353, 15352.871615837676, 11366.111349124847, 7655.035856788714], "REACTION_Z": [-4180.25070324011, -6401.13684446176, -7338.525729222731, -9235.95824200668, -16099.6966357342, -11841.160883693112, -5256.938160207884, -5432.713005241722, -6149.566858742387, -5789.678195242706, -4179.479386234299, -3117.571868010692, -2102.9088333393524]}, "NODE_147": {"REACTION_X": [-11324.819561153447, -8253.602342793329, -1357.6231542317005, 13142.224792165256, 47956.01072710473, 95587.16018857903, 112275.18981821873, 124983.43994547895, 126894.18128282127, 105046.58879625535, 67333.20761003357, 44538.03380884763, 27687.539355907218], "REACTION_Y": [29162.00736621495, 44136.29101083049, 50639.38392885285, 65006.80451259463, 113761.29664578792, 87568.69855812017, 42381.06777715583, 42924.91751982558, 47156.85283927218, 43384.42955049897, 30704.364437678556, 22732.15924286336, 15310.154973737088], "REACTION_Z": [1.7480332386996906, 10.96452714395491, -17.868606859909505, 6.236530689742722, 1.1525518864127662, 1.52172421483192, -0.12350174308448914, 0.0010478710441930161, 0.22216871933096627, -0.009515866352558078, -0.002272706936309987, 0.00046251151252363343, 0.0003506069829199987]}, "NODE_152": {"REACTION_X": [-5649.982183754785, -4118.824402326205, -683.9564843123435, 6683.762531377895, 24195.13641093523, 47970.535446904396, 56234.56766591752, 62513.159599697006, 63452.024984160744, 52525.62116803314, 33667.09639452577, 22269.043575296506, 13843.733195147594], "REACTION_Y": [14564.045773016085, 22028.435198325864, 25310.972145016873, 33038.033472414754, 57912.20843330449, 44472.9921629756, 21519.893115459723, 21495.047223181056, 23585.813862820534, 21696.17225607622, 15352.878304437327, 11366.109895724514, 7655.034838220176], "REACTION_Z": [4179.901265746231, 6398.945074023853, 7342.097642454863, 9234.711882031612, 16099.466491385929, 11840.857247360535, 5256.962817375, 5432.712807268106, 6149.52248834756, 5789.68009590064, 4179.479840475189, 3117.5717755566666, 2102.9087632473506]}, "NODE_157": {"REACTION_X": [-4154.746697194609, -1077.3207081337382, 2573.9966373972406, 8263.780636890551, 21833.00112524061, 30346.233434744274, 32703.97387769074, 38518.93027688471, 41830.56331015559, 36554.44858512326, 24773.661075609147, 16728.825026467784, 10426.15056089982], "REACTION_Y": [21234.205256273635, 25313.79978764321, 24015.61385655526, 24451.499653119274, 33821.776931383625, 18866.669424000243, 9133.555319140643, 11875.244802077837, 15410.771728720387, 15386.69557186652, 11680.365182441812, 8438.434315473438, 5447.7183487526945], "REACTION_Z": [-6163.903732882589, -7344.654149985739, -6982.027681720393, -6878.267852750774, -9250.851848169248, -4841.612819810382, -2274.9860646656753, -3111.2307980509527, -4130.730414973517, -4172.105852691387, -3195.5949922765135, -2312.0430383813764, -1491.2287527072594]}, "NODE_159": {"REACTION_X": [-8301.189695578882, -2153.495138826931, 5144.51893395572, 16348.25864301244, 43150.56495772412, 60335.610165336606, 65181.23656782711, 77032.07837452108, 83659.35964195727, 73107.71539109433, 49547.18773745361, 33457.648314228776, 20852.30363878423], "REACTION_Y": [42504.988541207786, 50640.05252367467, 48158.61657419088, 48216.52357016204, 66559.21742664267, 37086.318683365855, 18041.073381135124, 23738.97090857227, 30818.55067694895, 30771.62533179803, 23360.487793015887, 16876.862457718667, 10895.446196584502], "REACTION_Z": [4.519908572064196, 20.50790590908764, -24.57180583398258, 5.949550389302658, 0.5920630831160452, 0.5143885830011641, -0.09349374348107631, -0.010270039338138304, 0.04811206285558001, -0.004756790897772589, -0.0010971687993333035, 8.874431114236359e-05, 0.0001529306131260455]}, "NODE_165": {"REACTION_X": [-4147.923279322051, -1061.9592116384642, 2568.700049058089, 8261.57568272113, 21832.132748266737, 30345.030899695746, 32704.23948040347, 38519.038021236884, 41830.30231823328, 36554.45882821226, 24773.66383704254, 16728.824615615024, 10426.150186858098], "REACTION_Y": [21221.71380876194, 25260.449970443042, 24077.62853414595, 24436.51330722832, 33820.137517268595, 18865.166651637788, 9133.84705437143, 11875.290307358962, 15410.60865210743, 15386.709125095776, 11680.36832731289, 8438.43402324278, 5447.7179078972285], "REACTION_Z": [6163.000216477573, 7340.554657584361, 6986.93974175748, 6877.078664311548, 9250.733583414263, 4841.510079768819, 2275.0047475338793, 3111.232852698615, 4130.720796795274, 4172.106803258778, 3195.595211590411, 2312.043020641644, 1491.2287221239155]}, "NODE_188": {"REACTION_X": [-1124.1704627138688, 2263.361058281739, 5143.429958112064, 8298.55724609612, 15954.599825131485, 18483.72318622472, 21483.40244507751, 26850.469953121297, 30237.950056076457, 27035.247915437925, 18739.572831353245, 12676.511563201293, 7856.38340333665], "REACTION_Y": [24985.162559481232, 24552.45146383738, 19085.95673716743, 14311.284641780107, 15037.318924640844, 7120.75325068311, 6131.465372598388, 9047.206071955105, 11652.748214615269, 11373.21669375039, 8501.086925220994, 5932.254545849033, 3712.2911823942577], "REACTION_Z": [-7256.408831430324, -7125.26148343127, -5540.15778971659, -3949.5218405597107, -3956.517620484829, -1784.5146744449632, -1627.2719099630283, -2443.281148751583, -3167.9109034860385, -3100.6751406643884, -2323.124788334746, -1619.9973715184058, -1012.3162330982277]}, "NODE_192": {"REACTION_X": [-2260.798002628184, 4540.800077567552, 10315.216472309367, 16429.171103377554, 31730.44749639304, 36833.60222627031, 42973.79210497588, 53698.801919519334, 60475.33647925291, 54070.29736816347, 37479.106498648725, 25353.021220404175, 15712.769476269732], "REACTION_Y": [50015.598041347155, 49105.896963132014, 38273.691977894974, 28291.993561583688, 29694.559915897575, 14089.261373352701, 12256.057479243667, 18091.397838840887, 23304.747894674598, 22746.10082425298, 17002.117543359, 11864.506886710467, 7424.585577629623], "REACTION_Z": [9.130655249968186, 28.183001707996937, -23.776192086947503, 3.778979222950511, 0.19381027644431015, 0.1467231304395682, -0.030342173245003323, -0.0039252045605735475, 0.014722254732305373, -0.002156230842729201, -0.0005450267055948643, 1.9760682675951102e-05, 6.908652983383945e-05]}, "NODE_200": {"REACTION_X": [-1115.9607781186164, 2269.1357506655263, 5151.061066917058, 8294.685376173382, 15954.134420993512, 18483.21070408587, 21483.46820073247, 26850.479934658033, 30237.889085690636, 27035.252780455863, 18739.574084200984, 12676.51145947705, 7856.383238515693], "REACTION_Y": [24961.14403771148, 24481.452387911544, 19145.80129795841, 14301.331306501444, 15036.744062152511, 7120.290582049299, 6131.549890408868, 9047.214983538903, 11652.704041785217, 11373.222863856687, 8501.088476738958, 5932.254481340751, 3712.290983956851], "REACTION_Z": [7254.5836235985535, 7119.62756230507, 5544.911065362185, 3948.7663999285014, 3956.4788934185226, 1784.485348185956, 1627.2779761733268, 2443.281933694339, 3167.9079600860837, 3100.675571659145, 2323.124897293461, 1619.9973675716028, 1012.3162192903687]}, "NODE_225": {"REACTION_X": [2340.346757754415, 5074.357815145106, 5972.024072595743, 6074.497275422748, 9578.5522399313, 11550.114945490117, 15800.302276707424, 20238.883667537084, 22988.060889807988, 20617.219964112097, 14337.302138389403, 9655.920694305472, 5949.456410385665], "REACTION_Y": [24848.439223835776, 19988.030217201293, 11948.111735938628, 6208.644782991412, 4977.7521056473815, 3200.038494467013, 5223.743802080484, 7430.334316223375, 9015.746644750183, 8423.588045459706, 6078.197881798209, 4129.690326170226, 2538.3187873982965], "REACTION_Z": [-7216.65369112812, -5793.768044386518, -3400.5454873037243, -1646.7214726109232, -1240.3553655754183, -817.6522580208948, -1411.3565449413375, -2017.574880265297, -2449.212352192631, -2287.6761655715686, -1650.4453459677059, -1120.132806064947, -687.7053383095827]}, "NODE_228": {"REACTION_X": [4692.677638988518, 10156.463093758433, 11961.425521383117, 12093.562005733074, 19068.02158417282, 23096.746457661622, 31595.05630130438, 40477.48530017588, 45976.03207382568, 41234.39303284963, 28674.5990370326, 19311.841282160494, 11898.912887216775], "REACTION_Y": [49745.09291699856, 39954.48144229915, 23953.99220469185, 12311.557593775058, 9849.756748384294, 6387.130521676234, 10441.810252726507, 14860.151079149025, 18031.348037244836, 16847.104869023307, 12156.386188961322, 8259.380370286222, 5076.637909244769], "REACTION_Z": [13.678057406666085, 26.834485402168866, -15.268805309982554, 1.6150763218720385, 0.04392505006899228, 0.03939109060104329, -0.013833636289177775, -0.004311673259280724, 0.008339338871564905, -0.0009541206297853932, -0.0002604955641345441, 8.062514893936168e-06, 3.1277409959784563e-05]}, "NODE_236": {"REACTION_X": [2344.8052969185233, 5065.22176057367, 5986.845620842116, 6071.471213263754, 9578.374929823798, 11549.972233031276, 15800.338828993823, 20238.893571386277, 22988.037772397452, 20617.222224972847, 14337.302736319423, 9655.92066480029, 5949.456335915129], "REACTION_Y": [24813.813032657905, 19920.405866063084, 11988.154538191846, 6204.051258227983, 4977.608106866912, 3199.9184727927204, 5223.7845623757175, 7430.346547385195, 9015.722761619134, 8423.590789406859, 6078.19862504634, 4129.690302336665, 2538.3186976668603], "REACTION_Z": [7213.9193636386535, 5788.403412242296, 3403.598211930889, 1646.3985656026023, 1240.3465849913875, 817.6443813016557, 1411.3593109818962, 2017.5757422894849, 2449.210684960078, 2287.6763563104996, 1650.445398039513, 1120.1328044459779, 687.7053320413504]}, "NODE_262": {"REACTION_X": [5603.606669909505, 6452.04542487146, 4924.342072310513, 3556.574729535965, 5326.092722473405, 8070.844236079114, 12253.434126614258, 15765.009518245166, 17850.049703697532, 15947.783143929664, 11052.677359660625, 7411.1309211461785, 4549.59615430548], "REACTION_Y": [20933.730506163407, 12828.033495825055, 5568.600819261106, 1943.7525459234084, 1551.8127233981215, 2706.422058411578, 5159.146536571654, 6889.3887608730365, 7934.824758468486, 7152.524588929883, 4999.848400408986, 3345.115982631357, 2042.5941987848043], "REACTION_Z": [-6085.250668830902, -3666.616939289408, -1522.7276656517643, -485.0338281305093, -375.46835005309583, -717.9735351885786, -1401.789902159221, -1872.0047215422528, -2153.959328116618, -1939.8181278450147, -1354.8944559715978, -905.7678067062539, -552.7469740889749]}, "NODE_265": {"REACTION_X": [11223.57846918024, 12892.621163011469, 9872.229258088388, 7090.664724177976, 10647.076586595449, 16138.03754539639, 24507.025900506582, 31529.934815250497, 35700.06820764919, 31895.558708813485, 22105.353347429, 14822.26175752864, 9099.192386691344], "REACTION_Y": [41886.41544065926, 25633.48369543597, 11158.998196915505, 3860.1799143786807, 3093.0027512781035, 5408.389039557629, 10317.92244779077, 13778.657793185415, 15869.607857266077, 14305.036159420353, 9999.694740951974, 6690.2318643363105, 4085.188496708721], "REACTION_Z": [14.248721013916565, 16.9604496797906, -6.509249057051875, 0.47252697525669873, 0.006948029744421547, 0.015197922589891277, -0.005651248316553392, -0.0023246280701414435, 0.004503809177549556, -0.0004104031340830261, -0.00011739598812710028, 4.4745430045622925e-06, 1.3834699473136425e-05]}, "NODE_273": {"REACTION_X": [5599.859406010465, 6434.487790438803, 4936.502637171674, 3555.0653797203895, 5326.0497390568635, 8070.793864999344, 12253.448584217447, 15765.014355120253, 17850.038968071043, 15947.784183800144, 11052.677648294828, 7411.130909091556, 4549.596119624073], "REACTION_Y": [20898.139075785228, 12783.65708873073, 5587.00290267625, 1942.2841716542966, 1551.7887845861856, 2706.377099772828, 5159.162705681791, 6889.395191740243, 7934.812102543388, 7152.525769452601, 4999.848736433243, 3345.115969977257, 2042.5941591195146], "REACTION_Z": [6082.402107321275, 3663.2260478218955, 1524.0291719354911, 484.9393402813297, 375.46696060792885, 717.9704958470991, 1401.7910322119983, 1872.005186344615, 2153.958427613825, 1939.8182098996358, 1354.8944794475033, 905.7678058074068, 552.7469713192181]}, "NODE_297": {"REACTION_X": [6878.475172695537, 5634.707135392681, 3129.5220855560624, 1802.1249736473337, 2993.8037095584696, 5407.402932422224, 8589.653865933175, 11033.39425530683, 12444.986771882774, 11081.950249743122, 7657.134519861956, 5122.007062018261, 3139.2639237039766], "REACTION_Y": [15464.72693500419, 6305.232947958501, 1972.4414317415676, 760.4836830969682, 1984.0565030051707, 5130.579163966417, 8644.942453179092, 11060.39852482185, 12395.623202402236, 10978.595673411173, 7547.563000265057, 5030.715726642508, 3076.4616183803096], "REACTION_Z": [-4363.590658143185, -1708.1555580396282, -496.9555850047393, -178.37574350011016, -502.1159596116568, -1347.7994109896918, -2282.1079740186756, -2918.9930674224975, -3269.799840662625, -2894.7809677301684, -1989.2922464888027, -1325.5424766748943, -810.4638431301546]}, "NODE_300": {"REACTION_X": [13756.918685819732, 11266.614143095681, 6261.764132910088, 3602.165880958585, 5985.631215466573, 10814.55894389303, 17179.08834210981, 22066.77852080967, 24889.965039752766, 22163.898909813895, 15314.268919448397, 10244.014113759851, 6278.527838718566], "REACTION_Y": [30927.21089609892, 12594.580534478157, 3946.311627920667, 1517.7424721900534, 3965.4793051978504, 10260.573868501744, 17289.655226255607, 22120.77881768231, 24791.23495363671, 21957.18886064773, 15095.125727526603, 10061.431435530452, 6152.923236976555], "REACTION_Z": [10.215807838472301, 6.6818281368448424, -1.703154051417755, 0.10054478688377344, 0.0016618917091193453, 0.006979754947622041, -0.002473861518524245, -0.0011401279059555236, 0.002242193830625183, -0.00017471377850597491, -5.097245343677059e-05, 2.385157756634726e-06, 5.982204584142892e-06]}, "NODE_309": {"REACTION_X": [6869.7567794493925, 5619.612682743726, 3135.9832153347515, 1801.6486703670935, 2993.7928759842, 5407.382875179436, 8589.660729266567, 11033.397055560124, 12444.981213427418, 11081.950728224607, 7657.134656534113, 5122.007056062433, 3139.26390752293], "REACTION_Y": [15438.037288391486, 6286.2615936322, 1977.8174627620078, 760.159167351282, 1984.0509500174346, 5130.558731250269, 8644.949731560602, 11060.401835552746, 12395.616712022906, 10978.59618587501, 7547.563149406078, 5030.715719738748, 3076.4616008687685], "REACTION_Z": [4361.5481424777645, 1706.819564210236, 497.2961569510237, 178.3556353638323, 502.11562718977046, 1347.798014986284, 2282.108468800211, 2918.993295442151, 3269.7993922357073, 2894.781002677263, 1989.2922566891225, 1325.5424761974573, 810.4638419369178]}, "NODE_334": {"REACTION_X": [5627.472362396803, 2951.164041073911, 1314.2679159785869, 855.1456142041301, 1965.707673711728, 4156.236760146773, 6651.536164246723, 8484.843678411547, 9513.45525976023, 8434.845672904987, 5804.254692217189, 3875.6230355612443, 2373.978100469463], "REACTION_Y": [10099.31606499457, 3833.398411773961, 1518.6177439507053, 1212.8671435993638, 3472.1075996967747, 7817.338733815319, 12506.0925256523, 15902.620887738321, 17785.28409565376, 15739.501910371297, 10811.0138614064, 7213.504847607858, 4417.753274233692], "REACTION_Z": [-1954.0389616469047, -563.8634369883259, -182.73185068308072, -174.35635884303815, -603.5583511929832, -1430.134384471246, -2294.7033522358224, -2912.99657399935, -3252.8630610451787, -2875.456118428713, -1972.975967063982, -1315.7980662529526, -805.6913044637738]}, "NODE_338": {"REACTION_X": [11261.758960740888, 5891.780832840325, 2630.474279633552, 1709.6578105469302, 3931.1699311168873, 8312.315199225464, 13303.0771025404, 16969.68500962128, 19026.907032636984, 16869.691187672244, 11608.509376440854, 7751.246065290636, 4747.956198334261], "REACTION_Y": [20188.3760108228, 7654.079488620397, 3038.345768445175, 2424.8677882879415, 6943.75494117657, 15634.477086645747, 25012.17133271406, 31805.23868587838, 35570.56267615399, 31479.00355386716, 21622.0277187681, 14427.009686743411, 8835.506542972242], "REACTION_Z": [5.768445010682626, 2.565112354621192, -0.5658511730192686, 0.05529526145522823, 0.0018065870889358848, 0.0053917477439426875, -0.0016984231237984204, -0.0007696704656154907, 0.00158628269628025, -0.00011890486848642468, -3.46488275226875e-05, 1.8045072920358507e-06, 4.0743998397374526e-06]}, "NODE_344": {"REACTION_X": [5619.315777916384, 2944.5706657829583, 1316.0225975640433, 855.0134957469083, 1965.704334242874, 4156.227710223763, 6651.539109555216, 8484.844977462257, 9513.452612588615, 8434.845881086101, 5804.254752607274, 3875.6230326142268, 2373.9780933736333], "REACTION_Y": [10083.501810370244, 3825.616863954043, 1520.3433664631236, 1212.7110492984327, 3472.102787986724, 7817.324125137555, 12506.097163634908, 15902.622989496323, 17785.279776017334, 15739.502235822501, 10811.013956246457, 7213.504842717715, 4417.753263083516], "REACTION_Z": [1954.8369459157827, 564.7263456975807, 182.46047396439565, 174.37944869562077, 603.5589931377411, 1430.1357685267242, 2294.702908532835, 2912.996385419708, 3252.8634469945155, 2875.4560874095346, 1972.975958125874, 1315.798066683537, 805.691305525104]}} \ No newline at end of file +{"TIME": [0.10000000000000002, 0.2000000000000001, 0.30000000000000016, 0.40000000000000024, 0.5000000000000003, 0.6000000000000004, 0.7000000000000005, 0.8000000000000006, 0.9000000000000007, 1.0050000000000006, 1.1099999999999983, 1.214999999999996, 1.3199999999999938], "NODE_1": {"REACTION_X": [-38.94039630894229, -58.8713805157162, -73.97901325480632, -401.4325162709548, -5239.495227479389, -10927.945008480128, -11888.969478122075, -14385.71679065437, -28407.59250243486, -72524.74091748428, -172418.7889476644, -323806.66065539635, -477283.8703437895], "REACTION_Y": [65.24695922360183, 98.7868761629438, 125.00645593718102, 710.2699395638513, 9161.826842285822, 19615.46542480831, 21067.866055531285, 18489.717384358857, 14414.908323450014, 34461.18928871809, 143875.4304491828, 466069.85218497325, 1069404.034742347], "REACTION_Z": [-15.268576146169249, -23.1355196458183, -29.36396578359951, -169.49114970699532, -2173.271267171928, -4675.2501039793415, -4939.774482118555, -3574.355204906526, -321.3573237936734, -877.5783450051761, -22307.864908585365, -107997.34733004365, -293379.6547434538]}, "NODE_3": {"REACTION_X": [-77.88077949046495, -117.7426972850418, -147.95814135893073, -802.8719268643547, -10478.417364887984, -21864.542003713672, -23759.552790636, -28835.247645433272, -56797.823904956895, -144786.465587302, -344488.38965341926, -646918.5284551607, -953377.3983650325], "REACTION_Y": [130.493900047667, 197.57365814730906, 250.013086733282, 1420.5430574175712, 18323.333797193227, 39236.24250236827, 42124.137773214636, 37016.37547162152, 28843.159867880786, 68687.22603421187, 286902.25243227184, 930120.858655096, 2134881.177529191], "REACTION_Z": [7.763601304944245e-06, 4.0987674935877294e-05, -7.733709282931045e-05, 0.00021027990308652988, 0.00046021438038224005, -0.019067848808845156, -0.028047555264492985, -0.020597386799636297, -0.031041788282266225, 1.044740793699475, 1.685456783947302, -0.589138948416803, 6.400799597497098]}, "NODE_4": {"REACTION_X": [-65.28086128638581, -98.14068725550547, -121.02468423551082, -599.0306133012052, -8216.421660223545, -17194.850674158795, -21581.72589913139, -48635.945534057806, -123686.2686569807, -257849.49764881848, -428171.49493894173, -506730.6615672736, -393933.0894187525], "REACTION_Y": [45.730824670273115, 69.58751926552812, 87.91677932540095, 436.693817104184, 5384.048125077061, 8865.362204042814, 2330.8882890429704, -558.2150846261266, 40336.34115922333, 192206.74905752135, 546351.9500025945, 1153131.6114942634, 1935188.3727159444], "REACTION_Z": [-14.65071649587518, -22.320266090442672, -28.2792190472978, -141.35990885618332, -1725.4704169485804, -2779.5475001199484, -465.2952493699231, 1332.9177814968843, -10535.172828809544, -59681.67274380797, -179910.0232644605, -392277.80474122043, -664300.122103934]}, "NODE_7": {"REACTION_X": [-130.56167253136113, -196.28108983969412, -242.0499428564919, -1198.034062831061, -16435.660058907342, -34355.59417628864, -43222.80371448393, -97156.00807183188, -247082.22677850092, -515211.2697239992, -855303.6594681585, -1012380.5246957287, -787443.2037183762], "REACTION_Y": [91.4615844393924, 139.17468665877755, 175.8342479709861, 873.3752939743068, 10769.886450993692, 17709.362064618475, 4696.415957657617, -1133.9893193136686, 80239.79034103967, 383018.26061762555, 1089792.9146865872, 2301279.2995891417, 3862992.094305875], "REACTION_Z": [2.7580556503536968e-05, 0.00014470423338153182, -0.000274878894064301, 0.0007137041759506246, 0.0011275677902631287, 0.011400643570596003, -0.10946328314480525, -0.08650695160167743, -0.5661182638050377, 3.463213647485645, 3.483706853003241, -1.1013104669109453, 2.0444753082701936]}, "NODE_12": {"REACTION_X": [-38.940383628172434, -58.87131412955241, -73.97913923632154, -401.43217272698604, -5239.494247883969, -10928.000454334007, -11889.032553563307, -14385.809812795107, -28407.90267630853, -72522.72200858037, -172417.02777760022, -323807.1595273262, -477285.8574397978], "REACTION_Y": [65.24694108694011, 98.78678060659288, 125.00663658775825, 710.2694479029585, 9161.825695172378, 19615.51781154029, 21067.936411785086, 18489.782244984966, 14415.048382048693, 34458.65020852818, 143871.7049740134, 466071.1315834289, 1069392.1157064263], "REACTION_Z": [15.268576743650781, 23.13552310674395, 29.36395933368017, 169.49116629843564, 2173.2712814794704, 4675.252176090209, 4939.773369174608, 3574.3586827489335, 321.37950680472443, 877.816354012705, 22308.052520959234, 107997.27663520916, 293377.68064429326]}, "NODE_15": {"REACTION_X": [-65.28080950556743, -98.14041327489373, -121.02520547135337, -599.029297586442, -8216.420975639816, -17194.689597442994, -21581.883929196207, -48635.95033166006, -123687.42370424098, -257846.3499355584, -428171.1761382479, -506729.9469269647, -393942.2228791812], "REACTION_Y": [45.7307588759053, 69.58717315469063, 87.91743708573483, 436.69212162614264, 5384.045855365128, 8865.289743428577, 2331.13796846091, -558.0505972748215, 40337.732774768876, 192199.50308376754, 546345.2127061188, 1153133.5086961964, 1935182.5724436836], "REACTION_Z": [14.650711028213756, 22.320237177269654, 28.279273995257686, 141.35976613042462, 1725.4701914097718, 2779.5452208427996, 465.31714177111326, -1332.900505343995, 10535.285536465202, 59680.98487918671, 179909.33173127825, 392278.0229844076, 664299.7174655591]}, "NODE_17": {"REACTION_X": [-99.68818567482674, -147.63612702595105, -176.16289796975337, -848.6101068427724, -13291.373155385929, -33120.94439223445, -67695.75081014099, -163066.54408597044, -300487.0523093652, -418116.08825635177, -412662.28408541693, -271215.9434629211, -26300.91213983638], "REACTION_Y": [44.21203900340931, 65.45273736399682, 73.69262191964364, 80.31575414167742, 2099.8790501682215, -1027.014352869277, 1079.245381934601, 78283.11308603358, 327819.86652848026, 802719.4987074266, 1443675.0487267445, 1963386.5951151599, 2203414.650725733], "REACTION_Z": [-14.470007251613273, -21.494573539570865, -24.371240189456078, -26.40312846441162, -634.291752235577, 644.0796469285492, 1013.3797583896194, -22409.79976994708, -104959.46079807455, -268411.68715175445, -496241.6596012979, -679071.3955921119, -760620.0921730732]}, "NODE_22": {"REACTION_X": [-199.37616181788442, -295.2712300999867, -352.3275388167114, -1697.3180924628418, -26567.751249225228, -66371.99614888924, -135256.2194660953, -325893.2346722598, -600385.4559305762, -835082.8005080405, -824186.2244589915, -541746.8063495968, -52529.989233329106], "REACTION_Y": [88.4238009593886, 130.90405170778845, 147.38781161632042, 160.65155845939663, 4189.618384040849, -1976.3811607292755, 2114.063171576465, 155971.43499930057, 653806.3536989936, 1601492.6648258811, 2880645.822990854, 3918401.0657473356, 4398111.212589804], "REACTION_Z": [0.00011479656871937749, 0.000609162245282846, -0.0011577931173754052, 0.0031016716983138792, 0.004008008952894215, -0.23994039462991168, -0.260794870873724, 0.011642556313290697, -2.168307769821695, 6.068225096911192, 1.5159182195784524, 1.1120565186138265, -2.488543748797383]}, "NODE_30": {"REACTION_X": [-99.68798348406071, -147.63505251374306, -176.16492549020134, -848.6042836636, -13291.365366224083, -33122.246982569384, -67695.91072502526, -163066.06562491984, -300488.31902369275, -418118.49090752803, -412665.47392862977, -271214.9500352205, -26302.519602811895], "REACTION_Y": [44.21176589180253, 65.451287947806, 73.69537393596438, 80.30828704129027, 2099.8691197967, -1026.211800284611, 1079.7854717220398, 78282.95673458956, 327824.37018621754, 802708.1811712272, 1443672.2585230067, 1963384.575165105, 2203419.087315358], "REACTION_Z": [14.46998421533298, 21.494451669227743, 24.371471732519183, 26.40250810178771, 634.2909507266746, -644.0316390237977, -1013.3276563235436, 22409.797631032103, 104959.891074803, 268410.4837205383, 496241.35864373227, 679071.1792818407, 760620.577186388]}, "NODE_36": {"REACTION_X": [-141.8364045220744, -205.7749286796208, -241.7009556226808, -1605.6635234907735, -26969.82871489562, -92440.3451877122, -204262.23200301843, -361486.7569682469, -438032.8587739227, -346673.3826263616, -117825.19530744251, 145711.812101757, 359271.95198320656], "REACTION_Y": [68.74652396866252, 92.04421122838345, 75.38877800174694, -261.43527846548744, 5034.639261875658, 27836.168028500644, 134536.2387923183, 469745.5299379576, 1037542.6418772272, 1692370.8385971584, 2106827.661002381, 2213624.6787512074, 1952858.1605786746], "REACTION_Z": [-22.687582260625284, -30.473632925235883, -24.934593776075843, 105.69057303477967, -1361.2912723518452, -7481.1839995767195, -40567.263870930365, -152721.4576033812, -350676.3051116678, -583377.086441972, -727268.8182747018, -763741.731413134, -673401.8045994572]}, "NODE_38": {"REACTION_X": [-283.67209655337297, -411.5457425317064, -483.41045286200773, -3210.78728772838, -54012.77297278461, -184513.72972340515, -408181.84463920596, -722158.1166197263, -874871.2857049748, -692366.4254916195, -235533.45493676828, 291115.64958662423, 717942.7712592466], "REACTION_Y": [137.49202261959746, 184.08281197942864, 150.7889121708269, -523.0546085384151, 10124.43472705656, 55482.88605077438, 268284.84885459155, 937281.0208547175, 2070360.8718509802, 3377051.867728263, 4204895.763263606, 4418478.233655167, 3897997.431824333], "REACTION_Z": [0.000441125325467695, 0.002328414098055731, -0.004323743879998787, 0.012819487382763839, -0.007166592770005309, -1.8025522852806262, -0.41169988280216785, 0.7255030313099269, -3.0857415724312887, -1.7876498130499385, -3.062818078091368, 0.9285566717735492, -1.4789359755814075]}, "NODE_43": {"REACTION_X": [-141.83566106644503, -205.77105234717277, -241.70799227807385, -1605.6413800721307, -26969.845643823828, -92442.56869414652, -204262.92343295325, -361485.9776454305, -438029.80808522704, -346678.4491472975, -117827.02650708417, 145711.30035545747, 359272.9984243652], "REACTION_Y": [68.74548295632185, 92.03872747622762, 75.39891978519461, -261.4656871944774, 5034.660723073558, 27840.261602651593, 134537.23132688852, 469743.978286734, 1037547.9857596135, 1692373.820606751, 2106833.3358344263, 2213622.8026126027, 1952861.5427096188], "REACTION_Z": [22.687494053832268, 30.473167285033867, 24.93545851870041, -105.69313691905893, 1361.292702154401, 7481.543483241282, 40567.34561734905, 152721.31428509593, 350676.9170006097, 583377.4317527517, 727269.4142498554, 763741.5505598832, 673402.0927809989]}, "NODE_49": {"REACTION_X": [-205.09548314910404, -303.9395813399595, -409.3344496107321, -4912.6603694357, -69326.77621724264, -224719.4472548527, -387847.5503998141, -433383.37438310747, -294635.97097159165, -5325.72366014446, 271559.29021944513, 484039.22576910496, 525141.5864016735], "REACTION_Y": [91.43219306187058, 100.07038726237658, 41.730789289341914, 930.8722624576174, 40925.11026446006, 211060.13690786224, 616042.3329388086, 1282242.1447335193, 1897298.4536325189, 2197276.8381299516, 2153026.014326452, 1802307.320667129, 1202601.321284511], "REACTION_Z": [-30.18926167296256, -32.64337048556718, -11.066165552668483, -214.74959746865838, -12424.667495666963, -66717.16101576103, -203469.8949527833, -438042.60272531386, -654982.5612639806, -758192.1261986031, -742492.0157521372, -620728.4860732702, -409110.13632122753]}, "NODE_51": {"REACTION_X": [-410.18774833807066, -607.8644838661833, -818.6899998062144, -9828.694734201377, -138341.05427073137, -449244.6678570822, -774982.9134691696, -865891.8706151037, -588624.4400309663, -10789.55452618, 542782.123386997, 967279.9290964825, 1049103.4211138242], "REACTION_Y": [182.8602108870802, 200.12010216079017, 83.49163284162583, 1863.1808556744124, 81579.78025468992, 420977.5659580793, 1229630.8718362541, 2559330.02608293, 3786651.730342755, 4385594.166469008, 4297685.986034865, 3597569.014108808, 2400500.682359471], "REACTION_Z": [0.0017308001740126144, 0.008947705358448133, -0.016191327403807687, 0.05144090140152002, 0.26372558702746574, -4.9534353062663286, -0.20300062565365806, 2.3388740750961006, 2.971055755915586, -4.057623011409305, -2.1642244530376047, 0.16933943721232936, -1.0371832151722629]}, "NODE_55": {"REACTION_X": [-205.0923856624787, -303.9237342600085, -409.36349736831954, -4912.576537927855, -69325.82556348354, -224721.1998971568, -387848.13778440974, -433383.0260764346, -294636.7795211175, -5325.804767142021, 271560.8006948885, 484038.3220571815, 525142.3310491648], "REACTION_Y": [91.42805939852136, 100.04906173274003, 41.76943268748617, 930.750946891081, 40924.34700501865, 211070.07675357774, 616042.8834072938, 1282237.5358794788, 1897294.1992793353, 2197284.8744059075, 2153030.4678160883, 1802306.975069212, 1202603.5152445373], "REACTION_Z": [30.18891553823588, 32.641580932406725, 11.06940381941775, 214.73931057515503, 12424.614914889378, 66718.14729955082, 203469.93387375103, 438042.14253656415, 654981.9812359031, 758192.916432388, 742492.4369573551, 620728.4537442965, 409110.3397192083]}, "NODE_61": {"REACTION_X": [-325.7932552312988, -562.7958626749229, -1034.7394919269084, -15106.03535251132, -129087.16258661092, -305327.9752996076, -313488.60853615485, -144572.9487697194, 114197.40298671962, 380625.8960457559, 543933.0950645407, 549818.3750258108, 407458.7097652462], "REACTION_Y": [90.0040654960996, 97.89637768602876, 209.2903081377288, 12535.654152696945, 173241.92539162992, 671642.8539752716, 1396305.7178405973, 1986571.4067764124, 2227405.701060823, 2051352.2443436077, 1587721.4914442394, 966394.9308044122, 462463.24592658394], "REACTION_Z": [-28.738678840018217, -28.0097310796764, -53.99236284505748, -3863.1400614210265, -56618.36099343306, -227508.64107867546, -484461.42488321476, -690095.8879922342, -770571.8840290976, -707714.8943896536, -545139.8770062879, -324752.01710078423, -150545.94421575966]}, "NODE_63": {"REACTION_X": [-651.5750511796384, -1125.5226460309602, -2069.6678443685228, -30133.778453333634, -257593.0335612794, -609710.4831986366, -626304.4279374143, -288613.6748941714, 227893.8738461975, 760687.9232754603, 1086863.9653836265, 1098512.396245513, 814325.1126855076], "REACTION_Y": [179.99276401931766, 195.70941480556337, 418.8282211922261, 24965.53387841866, 344912.5803011388, 1340311.0273034347, 2787615.3484052294, 3965725.6022800594, 4446701.103742694, 4094787.8596090954, 3169298.8262306517, 1929131.2307318477, 923146.769054197], "REACTION_Z": [0.0068744645222995615, 0.03517400374856816, -0.06757825951128105, 0.1377837331798446, 1.22133366241178, -5.728877233195817, -1.974351443350315, -0.12564480415312573, -2.4004063886241056, -2.276484551082831, -0.16825476568192244, -0.7698297077731695, -0.27619681078067515]}, "NODE_67": {"REACTION_X": [-325.7807178218425, -562.7300188823539, -1034.8765102766788, -15105.873593355827, -129086.6772386096, -305320.7925338183, -313491.7954153712, -144576.12489678717, 114193.8625864856, 380627.3862260278, 543934.1865545545, 549818.09664857, 407459.06694828835], "REACTION_Y": [89.98762971333326, 97.81198558964164, 209.45483848680271, 12535.349474451721, 173239.42659108047, 671652.9013582594, 1396309.9968924916, 1986571.7380027662, 2227410.3776819864, 2051357.2394860256, 1587722.1956092783, 966396.3447699877, 462463.86773542553], "REACTION_Z": [28.73730394942883, 28.002696286494192, 54.00587826988036, 3863.112519727002, 56618.117469909106, 227509.7818538982, 484461.8108451641, 690095.9113537668, 770572.3517297267, 707715.3374998181, 545139.9090034519, 324752.16931403626, 150545.99869326703]}, "NODE_73": {"REACTION_X": [-394.4585696935577, -813.288653941124, -1743.8730315685902, -18130.90696660956, -90118.65985288458, -121650.66865006313, 14125.20284137837, 185842.54582948567, 331798.6183490895, 422113.09650571324, 413903.38594014075, 296979.55719635496, 168514.63045904224], "REACTION_Y": [28.556649998593315, 102.70817096847372, 728.4877901576035, 29819.517611577714, 269436.98191450164, 810557.2050138589, 1238624.8825946718, 1437668.3832310094, 1390811.045733569, 1056026.2603713816, 618689.2929014022, 289196.68793939403, 101804.63677055112], "REACTION_Z": [-6.495959415368528, -23.187652668597355, -207.24052176820334, -9621.955754573324, -92704.72094076622, -285258.8723122452, -433789.4614779956, -499204.44022625213, -480312.58888285543, -360359.54881856404, -205878.47734605163, -92980.67884111388, -30973.544577428656]}, "NODE_75": {"REACTION_X": [-788.8849163567644, -1626.4876707161247, -3488.131167814563, -36202.751695331746, -179878.89950345337, -242614.37315957775, 28180.5882038555, 371243.2380524415, 663687.706846054, 843490.5283228944, 826880.859493519, 593693.0192164341, 336821.2536553021], "REACTION_Y": [57.08264502786258, 205.31487885619288, 1457.410056469269, 59383.56889800854, 536427.0645350544, 1617190.165615166, 2473062.515327594, 2869676.7522162325, 2776609.170833652, 2107931.1566215726, 1235035.9476166647, 577280.3137303405, 203162.36162800246], "REACTION_Z": [0.01127658944310106, 0.056096331821590795, -0.11427132222071634, 0.18072010430387309, 1.3445765182113973, 5.215635850094259, -2.331898420525249, -1.0979769216501154, -4.555978902906645, -1.1139640348264948, -0.13474802282871678, -0.2642039729107637, -0.01883705265208846]}, "NODE_79": {"REACTION_X": [-394.4330248280985, -813.1446299639673, -1744.2067064341823, -18130.171211600013, -90120.56831679436, -121644.33173236827, 14121.936975173216, 185838.76131757078, 331801.0657457019, 422113.9753946005, 413903.4127604276, 296979.8663414729, 168514.80551288594], "REACTION_Y": [28.52891572381671, 102.56868303754544, 728.7791296312366, 29818.984932106272, 269435.50263815577, 810548.4031067311, 1238631.7300580607, 1437672.9767310931, 1390816.9616667496, 1056028.6692744445, 618689.5878597716, 289197.26486842387, 101804.72504196834], "REACTION_Z": [6.4937040751259705, 23.17643362140362, 207.26337408853357, 9621.91966376924, 92704.45321493394, 285257.845646684, 433789.91926269524, 499204.6563970382, 480313.47822931025, 360359.7665297102, 205878.50394339027, 92980.73106216168, 30973.54830146269]}, "NODE_84": {"REACTION_X": [-413.70102994264687, -974.9050457357464, -2185.5176662185204, -11338.435944462122, -18390.58481111834, 57858.025560377486, 167437.30037741718, 245715.14179858784, 287855.90075731336, 262734.1325173676, 189010.9696186373, 109625.03428087, 51868.43245295521], "REACTION_Y": [48.95918463221861, 351.42813358879454, 1701.4625108138403, 31906.416898492505, 198710.74092431442, 504234.39576975506, 671538.6457936785, 702889.7560279554, 619627.2366244985, 407607.61278685567, 178675.7309313467, 61375.39692119482, 13651.597453730388], "REACTION_Z": [-10.543115105891188, -92.64360435642239, -485.8201468170891, -10458.800215330935, -66297.55329488651, -168192.67040558904, -221833.79762972315, -229732.9380866505, -200881.55643969798, -130064.10919174139, -54610.072247599026, -17693.889538337964, -3551.8887146353322]}, "NODE_86": {"REACTION_X": [-827.4172118041648, -1949.2652962252084, -4375.455940363579, -22522.64035071389, -36022.51530206258, 115266.91065475316, 334726.94998410775, 491103.8105677005, 574586.6368155666, 524825.9358680879, 378003.6021304868, 218961.44097543805, 103633.42002128487], "REACTION_Y": [97.91500571367274, 702.4185091104541, 3406.893710629374, 63488.76814039431, 394999.53977542074, 1005706.3156130887, 1340541.231725598, 1402866.8563490543, 1236639.3252786512, 813655.6523195966, 356650.87677043607, 122441.09175643502, 27275.821747752943], "REACTION_Z": [0.0154809508245346, 0.08198067718195645, -0.19815792349785966, 0.48783248524705414, -0.858301234911778, 4.015002876200015, -3.710355635092128, -3.6429774638527306, 1.1972527016623644, -0.3579953014559578, -0.08829542145394953, -0.024819507756546955, 0.02143045946559141]}, "NODE_91": {"REACTION_X": [-413.6657656808309, -974.6866258183607, -2186.0843097543793, -11337.395358924781, -18392.43236601907, 57859.70012800084, 167435.53229835088, 245712.21576276148, 287861.95864900504, 262734.6425653572, 189010.935653295, 109625.18140031927, 51868.41850430366], "REACTION_Y": [48.91960876547526, 351.21329308875926, 1702.001233223269, 31905.028870467504, 198712.29092640214, 504225.08552244806, 671545.1137459131, 702896.1480929188, 619625.7080357922, 407608.3881177337, 178675.88444724958, 61375.49133422213, 13651.547611758], "REACTION_Z": [10.540018952243287, 92.62720910428905, 485.85977098873894, 10458.702774399328, 66297.7241501551, 168191.87610585015, 221834.5291843974, 229733.65582824865, 200881.316098164, 130064.17943774126, 54610.08977108554, 17693.894461729506, 3551.884438362439]}, "NODE_96": {"REACTION_X": [-687.2141232633523, -1703.2243121937706, -3261.954789382632, -6596.155248166968, 15804.344239737726, 114176.2325257669, 211424.7246658364, 260607.9764915543, 270511.2628004458, 218077.64776011053, 134680.1835762135, 70803.79923910864, 33567.862985645304], "REACTION_Y": [156.84728667144952, 1014.4649414006017, 3717.9088520506516, 39929.35335934191, 185121.49958531786, 403912.7829575388, 495528.90616558737, 491187.1094626185, 408192.32334075466, 249698.3941459019, 92520.55584821914, 29268.84618849911, 8339.407015352026], "REACTION_Z": [-35.771755102465, -264.5161391613175, -1051.9870525558313, -12371.625167186206, -57227.17586299483, -123816.083468467, -150519.93973497796, -147833.45204969417, -121773.73384944987, -73050.36195672982, -25878.7561200407, -7934.000512028041, -2236.5754537465523]}, "NODE_99": {"REACTION_X": [-1374.0164234939386, -3408.4403162485905, -6525.095218767634, -13046.80780780477, 31559.901520076142, 228896.176224944, 422757.28494286817, 521107.87262072717, 540753.6980917633, 436009.78727652703, 268959.7357923718, 141574.44963408384, 67181.33718259407], "REACTION_Y": [313.38083330037256, 2030.1534590957813, 7442.773410002065, 79284.22747856933, 367144.5893278505, 804794.628287799, 988525.5063616754, 979421.1264241787, 814821.6655492593, 498332.710745196, 184611.6574039257, 58506.78571414514, 16713.42865821922], "REACTION_Z": [0.025649741635363377, 0.15524062774615288, -0.42501979021182024, 1.02000384099847, -1.841749507944769, 3.816967638602364, -3.786403023987077, -4.2415959808422485, 3.806204717286164, -0.1733265045331791, -0.06446137557941256, 0.01379767907292262, 0.00953967951636514]}, "NODE_103": {"REACTION_X": [-687.1472433609406, -1702.7388046012986, -3263.173390967844, -6594.962373768274, 15802.628407894357, 114175.72594976009, 211423.1148695078, 260606.04372976342, 270516.25680200144, 218077.8862843961, 134680.22123074095, 70803.84897063574, 33567.84581766339], "REACTION_Y": [156.77672512742777, 1014.0157983824699, 3719.1356193865968, 39926.864029001736, 185125.45407147688, 403903.2189955334, 495537.8515557273, 491196.96457270987, 408183.6558311289, 249698.85741247924, 92520.70664112867, 29268.827811035335, 8339.380772873246], "REACTION_Z": [35.76662532079603, 264.4850950634135, 1052.0720308326659, 12371.421406498397, 57227.54275528336, 123815.32798683342, 150520.68691318983, 147834.28843231476, 121772.97996226029, 73050.39605761293, 25878.768926912526, 7933.997761416394, 2236.5735479218924]}, "NODE_109": {"REACTION_X": [-1541.8058873621699, -3316.199787896976, -4976.112266236659, 509.57732508270055, 37560.04538722505, 143241.65546651647, 224539.4092101336, 253191.58969337927, 244426.44952100154, 182451.25078674982, 100724.33957335434, 54315.98053558936, 28008.19261021512], "REACTION_Y": [785.8531332370687, 3246.3866798820823, 8523.673810961993, 48391.18519261388, 168694.50635966007, 311180.3990944311, 346837.11482824275, 327500.69701380574, 258003.66563072833, 150326.63204054284, 50889.74674122237, 19537.934006431024, 9647.609543667075], "REACTION_Z": [-193.8628370296308, -867.934721175775, -2405.632624846318, -14020.899112916144, -47579.60584502591, -87100.71765273827, -96546.04486622204, -90366.64441378065, -70408.87967587111, -40525.474878552726, -13381.984456312508, -5131.833466224385, -2629.8777200637733]}, "NODE_111": {"REACTION_X": [-3085.022079821578, -6633.3522605931685, -9962.381850094744, 1180.776043708067, 75288.40964581643, 285816.2273386837, 448590.58759971976, 505348.8804826753, 488332.77837486967, 364409.51030149916, 201419.23185013782, 108633.92902067844, 56012.68093123454], "REACTION_Y": [1572.6916011326766, 6497.252707046303, 17064.745385586793, 95821.9634164138, 333526.0738753371, 618823.0964286864, 691167.1742215231, 652585.8757900563, 514784.09727944364, 299990.0291354302, 101711.06888701263, 39075.42793167642, 19294.17259909726], "REACTION_Z": [0.06234738852474564, 0.4719234323041235, -1.3243815909174828, 1.9061927977982123, -1.9653075955138775, 4.366740316399955, -3.205958863167325, -3.8419996423617704, 5.182578901949455, -0.045642486849828856, -0.025184747441926447, 0.016501975111623324, 0.0041501546086237795]}, "NODE_115": {"REACTION_X": [-1541.6239280845882, -3314.8239101933596, -4979.40628500453, 511.4639895420605, 37562.05806800616, 143242.11065879738, 224543.2243970768, 253195.53609998035, 244424.86319355993, 182451.58058316162, 100724.4122432934, 54315.97444154522, 28008.18418423484], "REACTION_Y": [785.6688639051399, 3244.9703911435504, 8527.571663931625, 48386.256336780054, 168698.9337432335, 311169.2825802987, 346845.2360343766, 327510.1421841625, 257991.5563981401, 150326.82583829926, 50889.826768985775, 19537.891604315355, 9647.597736239843], "REACTION_Z": [193.8503686096654, 867.8403601136808, 2405.897388871377, 14020.51829456081, 47579.99717543502, 87099.85155444781, 96546.67836902868, 90367.40339637567, 70407.85287705847, 40525.483883348395, 13381.989472572053, 5131.83017207309, 2629.8768905500174]}, "NODE_121": {"REACTION_X": [-3271.20367537869, -5424.839392304458, -5682.763739760732, 5042.613273954771, 41502.129190181, 123826.45307645114, 182303.19509902486, 198185.94489192232, 184427.69735654918, 134632.84066737525, 74345.79672328969, 42658.32902058667, 23986.18386220099], "REACTION_Y": [2922.350231251063, 8485.752579258491, 16449.073794906228, 48054.320972740985, 128367.57329078381, 192978.55298580875, 184161.5710712372, 166967.1510212377, 129814.45675170465, 79651.34924544215, 31779.561212911743, 17477.079524707384, 11410.482964251441], "REACTION_Z": [-769.6105804753162, -2363.242987926773, -4744.603255677169, -13316.394459977288, -34589.02707333219, -52036.711798083554, -48807.494656582116, -43863.530625728614, -34009.806908808445, -20924.903145417036, -8340.960293900236, -4711.6490895137595, -3157.220625660334]}, "NODE_123": {"REACTION_X": [-6545.293191292611, -10848.188161223392, -11383.397034501626, 10169.518577097615, 82746.44925330224, 247488.1078223497, 364326.50005038327, 396063.07419483806, 368491.1790427911, 269167.2256625291, 148672.10025394175, 85315.63676109005, 47973.42483824026], "REACTION_Y": [5850.241841165447, 16978.54270475276, 32941.80498062461, 94749.76415199148, 252352.89691123442, 382675.28955025855, 366181.839488882, 332459.2645034287, 259146.5946967768, 159131.3349754175, 63531.00667768916, 34952.849354422826, 22822.150363244487], "REACTION_Z": [0.18093044318030138, 1.5440326125866477, -4.002873549369724, 3.144049318222642, -0.29914845526218414, 4.585640293029428, -1.9608615392280626, -2.0025839220907073, 3.7294450101726397, -0.023226076642458793, -0.0027252625477558468, 0.009049139393937367, 0.00200593223667056]}, "NODE_127": {"REACTION_X": [-3270.6417708925405, -5420.8673823929375, -5690.545851798201, 5044.916181973681, 41504.51197001415, 123824.42810467897, 182304.49062485536, 198188.1558094034, 184425.0842769532, 134632.8747007767, 74345.8210885918, 42658.31758290755, 23986.179114490307], "REACTION_Y": [2921.8029859281023, 8481.181767086975, 16460.489026145573, 48045.88065561822, 128368.49986264671, 192966.9473666321, 184166.74656426162, 166972.56835511382, 129804.85634355576, 79651.40418744362, 31779.57333521676, 17477.054590917178, 11410.477131434876], "REACTION_Z": [769.5744026086601, 2362.9343060408128, 4745.403433857784, 13315.766301354488, 34589.08635780276, 52035.80011599166, 48807.88336391316, 43863.927271121516, 34009.06642207679, 20924.907767121254, 8340.960837898678, 4711.647281855026, 3157.2202246641477]}, "NODE_133": {"REACTION_X": [-5084.436049726544, -5817.411767601189, -3774.3029658332925, 5997.341602311475, 29319.427677846776, 77450.04707465706, 104646.74403752803, 112343.34523944718, 105989.25487120944, 81732.3257940072, 48137.87399425524, 30101.57910033653, 18190.372360105448], "REACTION_Y": [7614.657289206558, 15623.768562544587, 22536.101847911035, 40010.68597907096, 85038.44416713103, 94344.98599928412, 65512.46704498198, 58250.75042751442, 49758.65073154503, 36880.891681819965, 20394.468761726726, 14336.829456935096, 9960.406167836685], "REACTION_Z": [-2111.0469445492663, -4493.499108373271, -6547.402985413533, -10993.19917457586, -23193.206030533278, -25357.799625821222, -16599.177532647547, -14772.643390933903, -12834.974326888416, -9670.912216849014, -5471.516679734777, -3923.9106336314344, -2751.079249716193]}, "NODE_135": {"REACTION_X": [-10166.242866305969, -11642.524316297902, -7570.0671345006585, 11940.847467048614, 57860.3932177231, 154245.11882389715, 208819.00163817254, 224175.16363972108, 211935.63711763918, 163437.72405382394, 96273.08260384246, 60203.11487714161, 36380.73237626554], "REACTION_Y": [15236.501951282968, 31265.53173870322, 45149.886868902264, 78631.87039056345, 166765.75860610354, 186259.13708760752, 129680.65723675127, 115881.12998419307, 99444.29591911391, 73721.38895871461, 40783.686035316445, 28673.48284570776, 19920.969501914442], "REACTION_Z": [0.5703630531581894, 4.5339846442909675, -9.603192274531466, 4.791943968171836, 1.0580965332701453, 3.084680160285643, -0.7269737213773624, -0.3973162956572196, 1.2920435479172738, -0.02209904163828469, 0.0019591353670875833, 0.0034947901431223727, 0.000796973729165984]}, "NODE_139": {"REACTION_X": [-5082.875730436725, -5808.436202894918, -3787.0826502627942, 5999.958831312566, 29320.942131843683, 77447.70356074118, 104649.24074400026, 112346.0142462631, 105985.390175988, 81732.36345923699, 48137.87684234408, 30101.571771879975, 18190.370377452124], "REACTION_Y": [7612.956409988433, 15610.808602906622, 22562.2589156335, 39998.16331646385, 85036.20790473597, 94336.9881496665, 65514.82068344491, 58252.389018951086, 49754.54451021297, 36880.952249769725, 20394.464412205478, 14336.819323927004, 9960.403851982828], "REACTION_Z": [2110.932916681573, 4492.592752682302, 6549.322625655085, 10992.24165736507, 23192.99475438531, 25357.18513599567, 16599.322224432985, 14772.722394574263, 12834.71693594978, 9670.916625575257, 5471.516288588341, 3923.909935191616, 2751.079090381098]}, "NODE_145": {"REACTION_X": [-5653.793187993014, -4133.519564309492, -670.6388731826937, 6683.08332595232, 24195.81482360109, 47973.27516127746, 56234.37724127091, 62507.640698810006, 63452.86736943461, 52525.64344309685, 33667.12041599346, 22269.028534589183, 13843.743616380087], "REACTION_Y": [14569.111641950469, 22058.338486045148, 25264.465519462778, 33053.85406829192, 57914.6311838704, 44477.08441842146, 21519.187739485045, 21491.94870297917, 23586.478511960628, 21696.1619160555, 15352.892440105745, 11366.104767596493, 7655.041493615299], "REACTION_Z": [-4180.250703120616, -6401.136845430011, -7338.525729356329, -9235.95823947786, -16099.579825234898, -11841.121368560718, -5256.843199361914, -5431.843479149043, -6149.552880013159, -5789.683311134919, -4179.484017478599, -3117.5698919631195, -2102.9103638172624]}, "NODE_147": {"REACTION_X": [-11324.81956006148, -8253.602348255225, -1357.6231519255252, 13142.224800306642, 47956.66189179349, 95587.25023859066, 112274.85888766387, 124972.56127151399, 126894.06190665896, 105046.67449525627, 67333.26096311319, 44537.999079411915, 27687.558470452135], "REACTION_Y": [29162.007365366335, 44136.29101838505, 50639.383925453556, 65006.804508536065, 113760.5469210595, 87568.4663281632, 42380.40643840372, 42918.578408782545, 47156.74725295996, 43384.4689344023, 30704.395699220295, 22732.143996276143, 15310.16629349359], "REACTION_Z": [1.7480332127520342, 10.964526692227992, -17.868600760780737, 6.2365112618062994, 1.1040089146645187, 1.4506196214242664, -0.2147826089640148, 0.03724849604213887, 0.2300350578857433, -0.011985660967638978, 0.0012607975286300643, 0.001190058285374107, 0.00033442614108025737]}, "NODE_152": {"REACTION_X": [-5649.982183219825, -4118.82440576976, -683.956480182349, 6683.762531264801, 24195.453206024522, 47970.62100466155, 56234.53908107373, 62507.667720957106, 63451.95557477542, 52525.66612018165, 33667.11889929114, 22269.025387040503, 13843.742779064978], "REACTION_Y": [14564.04577263541, 22028.435202982262, 25310.97213518404, 33038.03349519454, 57911.86345851245, 44472.96538435034, 21519.700556675918, 21491.819092400136, 23585.74944570522, 21696.195447551778, 15352.888943420381, 11366.101233618276, 7655.04052377462], "REACTION_Z": [4179.901265623419, 6398.945075087119, 7342.097641382601, 9234.71188338766, 16099.359375358188, 11840.831922392908, 5256.886072813272, 5431.836054066904, 6149.50693892735, 5789.6857050262115, 4179.48376556295, 3117.5696540828894, 2102.9102969515966]}, "NODE_157": {"REACTION_X": [-4154.746696328182, -1077.3207096194228, 2573.996636221372, 8263.780640760213, 21833.068845549522, 30346.227496949756, 32703.917788259118, 38514.78614490948, 41830.51768262239, 36554.47918003436, 24773.683016263698, 16728.81317880963, 10426.157272972992], "REACTION_Y": [21234.20525549502, 25313.799791530517, 24015.61386646366, 24451.499630075294, 33821.422911919784, 18866.590630870556, 9133.533937742319, 11873.011421009844, 15410.741826394262, 15386.708988212968, 11680.378187011487, 8438.42934744908, 5447.721720946942], "REACTION_Z": [-6163.903732683679, -7344.654151324415, -6982.027682135695, -6878.267851362188, -9250.764774282827, -4841.60084841825, -2274.9859868271583, -3110.6152991114436, -4130.721180667579, -4172.109778916977, -3195.5980764370497, -2312.0415917198047, -1491.2296663277202]}, "NODE_159": {"REACTION_X": [-8301.18969402827, -2153.495143494513, 5144.518935386209, 16348.258653304663, 43150.74530527857, 60335.65903662011, 65181.20761003934, 77023.75480883532, 83659.26012237748, 73107.77862987878, 49547.22784741267, 33457.62385682785, 20852.317080359422], "REACTION_Y": [42504.98853978668, 50640.05253455628, 48158.616570530045, 48216.52357533318, 66558.62120817682, 37086.24577773454, 18041.042179275642, 23734.466585912778, 30818.48092891114, 30771.654681554384, 23360.509228755298, 16876.851572933945, 10895.452958932696], "REACTION_Z": [4.519908546388706, 20.507904461834187, -24.571796492574776, 5.949529574893859, 0.5625295714862659, 0.4871275001496542, -0.09065987092685646, 0.0034263900010955695, 0.05159947772335727, -0.005604763132851076, 0.0004805479293281678, 0.0004196396239422029, 0.00014665919240997027]}, "NODE_165": {"REACTION_X": [-4147.923278565334, -1061.9592153353365, 2568.700051646936, 8261.575690130532, 21832.232482427156, 30345.08259534626, 32704.264856573474, 38514.85651888873, 41830.24837537823, 36554.491455894895, 24773.682029532214, 16728.812005740583, 10426.156916441247], "REACTION_Y": [21221.71380807993, 25260.44997833988, 24077.62852035308, 24436.513336354896, 33819.86257344607, 18865.16716274652, 9133.836958255935, 11873.016789950341, 15410.568718767576, 15386.725037662794, 11680.376796185485, 8438.4281066202, 5447.7212984057605], "REACTION_Z": [6163.00021628538, 7340.554659213881, 6986.939740303544, 6877.078667084161, 9250.652409385502, 4841.50355347227, 2275.004104468584, 3110.614616522759, 4130.7108656208775, 4172.110898950839, 3195.597980396566, 2312.04150782812, 1491.2296369978546]}, "NODE_188": {"REACTION_X": [-1124.1704618285717, 2263.361058727208, 5143.429959307095, 8298.557245802971, 15954.611145631628, 18483.739777954102, 21483.47701932191, 26847.331648887208, 30237.914400888345, 27035.271472415006, 18739.588688542695, 12676.502679112236, 7856.388240499556], "REACTION_Y": [24985.16255824136, 24552.451466706876, 19085.956748394423, 14311.284626500492, 15037.179818498946, 7120.747375380849, 6131.5480708771, 9045.701234660468, 11652.729575209829, 11373.226843093038, 8501.095069005489, 5932.250797044637, 3712.2933144822036], "REACTION_Z": [-7256.408831120285, -7125.261484797339, -5540.157790401969, -3949.521840011281, -3956.486436207182, -1784.5162206818209, -1627.2929346045717, -2442.869246252121, -3167.9053827984444, -3100.677999165433, -2323.1267967465064, -1619.996305575731, -1012.3168109398583]}, "NODE_192": {"REACTION_X": [-2260.7980009418247, 4540.8000759294555, 10315.21647306246, 16429.171115588553, 31730.499507373614, 36833.66173362677, 42973.93441246162, 53692.51035434742, 60475.261462517854, 54070.34528122198, 37479.136523359375, 25353.00310472512, 15712.779157511028], "REACTION_Y": [50015.59803917004, 49105.8969752641, 38273.69197569614, 28291.993568953694, 29694.327860644255, 14089.273682328523, 12256.191655337185, 18088.371504090042, 23304.70612101386, 22746.121978520187, 17002.131778790164, 11864.498962370402, 7424.589849871991], "REACTION_Z": [9.130655158612626, 28.18299878613516, -23.776182172070094, 3.778964362883471, 0.18210943003350621, 0.13956663331964592, -0.01881148250129172, 0.0019425460516231396, 0.01629372739489554, -0.002442834379735359, 0.00016654997807563632, 0.00016836910538131633, 6.62241096733851e-05]}, "NODE_200": {"REACTION_X": [-1115.9607773621178, 2269.1357488991052, 5151.061066507116, 8294.685387975042, 15954.168156916257, 18483.252606857208, 21483.53684689459, 26847.326534094973, 30237.849710811333, 27035.27713508736, 18739.588256897754, 12676.502227973568, 7856.388082673957], "REACTION_Y": [24961.144036713336, 24481.452398261852, 19145.801284349152, 14301.3313296962, 15036.63850979755, 7120.307548553612, 6131.602005106965, 9045.693149971601, 11652.680887839848, 11373.233865625483, 8501.094576387259, 5932.250305865657, 3712.2931242530785], "REACTION_Z": [7254.583623306153, 7119.627564258323, 5544.911064074826, 3948.7664023436055, 3956.450047334315, 1784.488324820031, 1627.2966960170236, 2442.8688581772158, 3167.9021252954235, 3100.6784874542836, 2323.1267634543815, 1619.9962719203286, 1012.3167976977247]}, "NODE_225": {"REACTION_X": [2340.346758479039, 5074.357816020726, 5972.024075693624, 6074.497275765836, 9578.593033106306, 11550.145173872064, 15800.392766216799, 20236.50761348253, 22988.03415433817, 20617.238190332642, 14337.31382836953, 9655.913890004318, 5949.459997801681], "REACTION_Y": [24848.439222427805, 19988.030218232667, 11948.11174472056, 6208.644776453912, 4977.742522028842, 3200.0533568244837, 5223.8118110809455, 7429.317412210557, 9015.735037588158, 8423.595456745985, 6078.203143349365, 4129.68753906969, 2538.3202311897903], "REACTION_Z": [-7216.653690779232, -5793.768045359018, -3400.5454879730405, -1646.7214726723964, -1240.3554711748852, -817.6570628768815, -1411.3740305759588, -2017.2988001691156, -2449.2090211394034, -2287.678207617061, -1650.4466772050798, -1120.1320299174151, -687.7057285175724]}, "NODE_228": {"REACTION_X": [4692.677640344236, 10156.463095662783, 11961.425522180154, 12093.562016876533, 19068.116920580134, 23096.81356205176, 31595.229038095138, 40472.72675919693, 45975.97692234673, 41234.42978426785, 28674.62165247318, 19311.827516048743, 11898.920065173188], "REACTION_Y": [49745.09291466665, 39954.48145237317, 23953.992204393624, 12311.557599590666, 9849.750851800596, 6387.165250379908, 10441.931311259157, 14858.10973470788, 18031.32279800496, 16847.120004323904, 12156.3957916879, 8259.374605995756, 5076.6408006190195], "REACTION_Z": [13.678057257700857, 26.834481704509017, -15.268798373375603, 1.615069299656625, 0.040545167781260716, 0.037853869284731445, -0.008451547730601305, -0.0016531959749954694, 0.009045975160006492, -0.0010600968562357593, 5.948335456196219e-05, 7.420986298711796e-05, 2.9942543164906965e-05]}, "NODE_236": {"REACTION_X": [2344.8052975906458, 5065.221761303702, 5986.845618491401, 6071.471224698402, 9578.426655737509, 11550.009052218671, 15800.420922597656, 20236.511008065965, 22988.009354234335, 20617.24074950912, 14337.313662750155, 9655.913702981114, 5949.459926448273], "REACTION_Y": [24813.81303164864, 19920.40587626659, 11988.154529027626, 6204.0512711860365, 4977.609113725113, 3199.9382122739826, 5223.837519912922, 7429.322008546195, 9015.709125855738, 8423.598512492328, 6078.2029678133995, 4129.687325201257, 2538.3201452710096], "REACTION_Z": [7213.919363321938, 5788.403413947153, 3403.5982112114443, 1646.398567052954, 1240.3473662453307, 817.6494935572408, 1411.3757205299357, 2017.2991306760364, 2449.2072126429657, 2287.678419544889, 1650.446665294212, 1120.1320150766196, 687.7057225201274]}, "NODE_262": {"REACTION_X": [5603.606670272823, 6452.045425910061, 4924.342075506553, 3556.5747308098644, 5326.154480062356, 8070.8738007904885, 12253.51252255735, 15763.194959519707, 17850.029612035833, 15947.797295416563, 11052.68615912634, 7411.1256566001175, 4549.5988816296185], "REACTION_Y": [20933.730505335603, 12828.033496057244, 5568.600824054844, 1943.7525447942116, 1551.847532145334, 2706.438599808019, 5159.194314681346, 6888.57605385858, 7934.81596759484, 7152.53084523299, 4999.852453046634, 3345.1136232527956, 2042.5953895539785], "REACTION_Z": [-6085.250668640825, -3666.616939821469, -1522.7276660933308, -485.0338285256851, -375.47858659484916, -717.9782704777051, -1401.8023401223193, -1871.7845629189605, -2153.9568695539147, -1939.8198349256616, -1354.8955114491157, -905.7671585254664, -552.7472962873824]}, "NODE_265": {"REACTION_X": [11223.578469948861, 12892.621166470017, 9872.2292592556, 7090.664733050336, 10647.203046502882, 16138.098699011194, 24507.177753112315, 31526.302686673087, 35700.02724322572, 31895.58713327798, 22105.370591152525, 14822.251155681726, 9099.197842772563], "REACTION_Y": [41886.41543943782, 25633.483702076548, 11158.998197764478, 3860.1799188958166, 3093.0748477113298, 5408.423652318916, 10318.012002025036, 13777.028960574538, 15869.589384633182, 14305.048798568343, 9999.702441889931, 6690.227062766494, 4085.1908799733264], "REACTION_Z": [14.248720876760217, 16.96044683890841, -6.509245928796759, 0.47252475819749407, 0.006130431493090782, 0.01470845796256981, -0.0036005334025048796, -0.0011265325501881307, 0.0048143923856969195, -0.00045396714585876907, 2.3300331463360635e-05, 3.329676917473989e-05, 1.322889642096925e-05]}, "NODE_273": {"REACTION_X": [5599.859406407209, 6434.487793290475, 4936.502635112454, 3555.06538731558, 5326.1145752978555, 8070.82542861667, 12253.522071027415, 15763.196778741896, 17850.018094710955, 15947.798456645274, 11052.686092797609, 7411.125571814253, 4549.598848397882], "REACTION_Y": [20898.139075314266, 12783.657096141598, 5587.00289875596, 1942.2841773124528, 1551.8261068349675, 2706.3951370152145, 5159.20450118472, 6888.5790516499, 7934.8024199510055, 7152.5321521477035, 4999.852385065085, 3345.113527793139, 2042.5953515995275], "REACTION_Z": [6082.402107163876, 3663.2260489297882, 1524.0291717493901, 484.9393411192955, 375.47736064652827, 717.9753290265963, 1401.8030601100122, 1871.7847881671132, 2153.9559069566276, 1939.8199256938788, 1354.8955067958627, 905.7671518710933, 552.7472936433935]}, "NODE_297": {"REACTION_X": [6878.47517280335, 5634.70713571584, 3129.522087670258, 1802.1249756379768, 2993.8564204228996, 5407.425122143297, 8589.709315071632, 11032.14334564071, 12444.9730613234, 11081.960095239105, 7657.140544399754, 5122.003406376794, 3139.265804734826], "REACTION_Y": [15464.726935559378, 6305.232949790684, 1972.4414338576776, 760.4836854894952, 1984.122115460768, 5130.602814115315, 8644.998847392322, 11059.174608415364, 12395.61010706719, 10978.605414512107, 7547.568904995649, 5030.712121835702, 3076.4634628558742], "REACTION_Z": [-4363.590658330138, -1708.1555587069838, -496.9555853177227, -178.37574427142712, -502.1336214672069, -1347.8057473980546, -2282.1226491255106, -2918.670508323844, -3269.7963574252813, -2894.7835405950277, -1989.293784557134, -1325.5415227394346, -810.4643291438838]}, "NODE_300": {"REACTION_X": [13756.918686116594, 11266.61414614792, 6261.7641341004255, 3602.1658871817717, 5985.737729874647, 10814.604032574654, 17179.19713923529, 22064.2752878135, 24889.937255709225, 22163.918654039837, 15314.280803491552, 10244.006768871146, 6278.531601475208], "REACTION_Y": [30927.210897522637, 12594.580540696817, 3946.311629642715, 1517.7424783935685, 3965.611384867766, 10260.621833271642, 17289.76593112752, 22118.3294425246, 24791.208370584885, 21957.208398655755, 15095.137358820652, 10061.424189668804, 6152.926926721272], "REACTION_Z": [10.2158077301915, 6.681827015803719, -1.7031532403311758, 0.10054434264095846, 0.0013957069919854348, 0.006756285139317697, -0.0017742620516401075, -0.0006111976920237794, 0.0023762173946124676, -0.00019373568125047314, 9.83368022389186e-06, 1.4761162447030074e-05, 5.7208087014259945e-06]}, "NODE_309": {"REACTION_X": [6869.756779627373, 5619.612685486177, 3135.983214441162, 1801.6486746023975, 2993.846643860379, 5407.405771214735, 8589.714071767592, 11032.144729065274, 12444.967139856923, 11081.960626962607, 7657.140516059566, 5122.003366808456, 3139.2657892388006], "REACTION_Y": [15438.03728922734, 6286.261598560887, 1977.8174623396496, 760.1591711930859, 1984.1173852337215, 5130.583040461382, 8645.004038755766, 11059.17637278009, 12395.603224170045, 10978.605982787343, 7547.56887603115, 5030.712078695988, 3076.4634461058727], "REACTION_Z": [4361.548142691307, 1706.8195651024837, 497.2961571046587, 178.35563622288504, 502.13334229092374, 1347.8043960884356, 2282.1230039841075, 2918.670630555163, 3269.795882194171, 2894.7835793455442, 1989.2937825870595, 1325.541519790243, 810.4643280066939]}, "NODE_334": {"REACTION_X": [5627.472362818564, 2951.1640421235415, 1314.2679169345042, 855.1456162816021, 1965.7528873704566, 4156.253946792265, 6651.577230280564, 8483.898130273445, 9513.44500706011, 8434.853190371061, 5804.25922172376, 3875.6202608972335, 2373.9795286406707], "REACTION_Y": [10099.31606626421, 3833.3984145600793, 1518.6177453507573, 1212.8671476404193, 3472.19523515225, 7817.370845140165, 12506.167954380917, 15900.86089729841, 17785.26510128286, 15739.5159535494, 10811.022282798662, 7213.4996773101575, 4417.755937482288], "REACTION_Z": [-1954.0389619563866, -563.8634376306862, -182.73185082349949, -174.35635967960732, -603.5749027183655, -1430.140346425485, -2294.7168837837544, -2912.6755746324425, -3252.859576352167, -2875.4586888111016, -1972.9774869419014, -1315.7971193435558, -805.691790698474]}, "NODE_338": {"REACTION_X": [11261.75896169872, 5891.780835759758, 2630.474280729516, 1709.6578152113377, 3931.260719199103, 8312.349885285392, 13303.158422635875, 16967.793282198836, 19026.886367751176, 16869.706245982146, 11608.518362852032, 7751.2405012536365, 4747.959054972569], "REACTION_Y": [20188.376013565303, 7654.0794947847235, 3038.3457705732926, 2424.8677969271866, 6943.93074502958, 15634.541816927234, 25012.3210266074, 31801.717707654025, 35570.524437109445, 31479.03167717363, 21622.04444759545, 14426.99932309668, 8835.511869916838], "REACTION_Z": [5.768444947776288, 2.56511208271786, -0.5658509667185285, 0.055295062965143416, 0.0016108020839737947, 0.0052038363958217815, -0.001280248184230004, -0.00040456679244016414, 0.0016777776545495726, -0.00013244602087070234, 7.000382765909308e-06, 1.0227181746813585e-05, 3.907754489773652e-06]}, "NODE_344": {"REACTION_X": [5619.315778435654, 2944.5706678606707, 1316.022597694115, 855.0134983489866, 1965.7499115045032, 4156.2452085663335, 6651.579364714136, 8483.898797877606, 9513.442200391994, 8434.853421929272, 5804.259209534717, 3875.6202432491177, 2373.9795218370878], "REACTION_Y": [10083.501811819106, 3825.6168676808325, 1520.3433671691214, 1212.711053910637, 3472.1909557852487, 7817.356742645088, 12506.171429511376, 15900.862001072373, 17785.260531314536, 15739.516315943865, 10811.02226369839, 7213.499649370396, 4417.755926792057], "REACTION_Z": [1954.8369462162495, 564.726346196827, 182.46047422594296, 174.37944943316757, 603.5754832303595, 1430.1416811735362, 2294.7165621043814, 2912.675479727969, 3252.859985985422, 2875.458654268735, 1972.9774887917458, 1315.797121964223, 805.6917917161068]}} \ No newline at end of file