diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e8ba7a04d16..4911563593d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -107,6 +107,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; set KRATOS_APPLICATIONS=%KRATOS_APPLICATIONS%%KRATOS_APP_DIR%\ChimeraApplication; set KRATOS_APPLICATIONS=%KRATOS_APPLICATIONS%%KRATOS_APP_DIR%\IgaApplication; set KRATOS_APPLICATIONS=%KRATOS_APPLICATIONS%%KRATOS_APP_DIR%\ParticleMechanicsApplication; @@ -121,7 +122,7 @@ jobs: -G"Visual Studio 16 2019" ^ -H"%KRATOS_SOURCE%" ^ -B"%KRATOS_BUILD%\%KRATOS_BUILD_TYPE%" ^ - -DBOOST_ROOT="%BOOST_ROOT%" ^ + -DBOOST_ROOT="%BOOST_ROOT_1_72_0%" ^ -DINSTALL_RUNKRATOS=OFF ^ -DCMAKE_CXX_FLAGS="/Od" ^ -DUSE_COTIRE=ON || goto :error diff --git a/.github/workflows/nightly_build.yml b/.github/workflows/nightly_build.yml index 4201cf6c6668..3a13e27c1133 100644 --- a/.github/workflows/nightly_build.yml +++ b/.github/workflows/nightly_build.yml @@ -102,7 +102,7 @@ jobs: -G"Visual Studio 16 2019" ^ -H"%KRATOS_SOURCE%" ^ -B"%KRATOS_BUILD%\%KRATOS_BUILD_TYPE%" ^ - -DBOOST_ROOT="%BOOST_ROOT%" ^ + -DBOOST_ROOT="%BOOST_ROOT_1_72_0%" ^ -DINSTALL_RUNKRATOS=OFF ^ -DCMAKE_CXX_FLAGS="/Od" ^ -DUSE_COTIRE=ON || goto :error 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() 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 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..9cbe7bdda332 --- /dev/null +++ b/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/potential_flow_wrapper.py @@ -0,0 +1,56 @@ +from __future__ import print_function, absolute_import, division # makes KratosMultiphysics backward compatible with python 2.6 and 2.7 + +# Importing the Kratos Library +from KratosMultiphysics.kratos_utilities import CheckIfApplicationsAvailable + +if not CheckIfApplicationsAvailable("CompressiblePotentialFlowApplication"): + raise ImportError("The CompressiblePotentialFlowApplication is not available!") + +# 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 Predict(self): + pass + + 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() + + ## 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().Clear() + self._analysis_stage._GetSolver().InitializeSolutionStep() + + super(PotentialFlowWrapper, self).SolveSolutionStep() + + 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..a818e8158cd4 --- /dev/null +++ b/applications/CoSimulationApplication/python_scripts/solver_wrappers/sdof/sdof_static_solver.py @@ -0,0 +1,146 @@ +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 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 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 + elif identifier == "ROOT_POINT_DISPLACEMENT": + self.root_point_displacement = 0.0 + self.root_point_displacement = 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..a384a0de227c --- /dev/null +++ b/applications/CoSimulationApplication/python_scripts/solver_wrappers/sdof/static_sdof_solver_wrapper.py @@ -0,0 +1,47 @@ +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) + + 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 51b01af86512..31980e5c1f88 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", "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") @@ -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_sdof_static/ProjectParametersSDoF.json b/applications/CoSimulationApplication/tests/fsi_sdof_static/ProjectParametersSDoF.json new file mode 100644 index 000000000000..644139fc565f --- /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": false, + "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..b57dfd9c429c --- /dev/null +++ b/applications/CoSimulationApplication/tests/fsi_sdof_static/naca0012_small_parameters_coupling.json @@ -0,0 +1,120 @@ +{ + "problem_data" : { + "problem_name" : "naca0012", + "parallel_type" : "OpenMP", + "echo_level" : 0, + "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", + "reform_dofs_each_step" : false, + "echo_level": 0 + }, + + "fluid_solver_settings" :{ + "solver_type" :"potential_flow", + "domain_size" : 2, + "model_part_name" : "FluidModelPart", + "model_import_settings" : { + "input_type" : "mdpa", + "input_filename" : "fsi_sdof_static/naca0012_small" + }, + "maximum_iterations" : 5, + "echo_level" : 0, + "linear_solver_settings" : { + "solver_type" : "EigenSolversApplication.sparse_lu" + }, + "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": false + } + },{ + "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" : [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" + }, + "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 + } + }] + } +} 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 new file mode 100644 index 000000000000..352c022ad19a --- /dev/null +++ b/applications/CoSimulationApplication/tests/fsi_sdof_static/project_cosim_naca0012_small_fsi_parameters.json @@ -0,0 +1,104 @@ +{ + "problem_data" : + { + "start_time" : 0.0, + "end_time" : 1.0, + "echo_level" : 0, + "print_colors" : true, + "parallel_type" : "OpenMP" + }, + "solver_settings" : + { + "type" : "coupled_solvers.gauss_seidel_strong", + "echo_level" : 0, + "num_coupling_iterations" : 10, + "data_transfer_operators" : { + "transfer_forces" : { + "type" : "sum_distributed_to_single" + }, + "transfer_disp" : { + "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" : [] + }], + "output_data_list" : [ + { + "data" : "disp_y", + "to_solver" : "fluid", + "to_solver_data" : "disp_y", + "data_transfer_operator" : "transfer_disp" + } + ] + } + + ], + "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_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 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 4d4093aed1b4..c48bc860f45c 100644 --- a/applications/CoSimulationApplication/tests/test_CoSimulationApplication.py +++ b/applications/CoSimulationApplication/tests/test_CoSimulationApplication.py @@ -21,6 +21,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 from test_convergence_criteria import TestConvergenceCriteria from test_convergence_criteria import TestConvergenceCriteriaWrapper from test_convergence_accelerators import TestConvergenceAcceleratorWrapper @@ -51,6 +52,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])) smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([TestConvergenceCriteria])) smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([TestConvergenceCriteriaWrapper])) smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([TestCoupledSolverGetSolver])) 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): 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..1a34afeddbb7 --- /dev/null +++ b/applications/CoSimulationApplication/tests/test_sdof_static_solver.py @@ -0,0 +1,73 @@ +from __future__ import print_function, absolute_import, division # makes these scripts backward compatible with python 2.6 and 2.7 + +from KratosMultiphysics import kratos_utilities +import KratosMultiphysics.KratosUnittest as KratosUnittest +from KratosMultiphysics.CoSimulationApplication.solver_wrappers.sdof.sdof_static_solver import SDoFStaticSolver + +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 + + @classmethod + 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) + 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) + + settings["output_parameters"]["write_output_file"] = True + + 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()) + +if __name__ == '__main__': + KratosUnittest.main() 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 44fa96f03f48..90ef3fbc3470 100644 --- a/applications/CompressiblePotentialFlowApplication/compressible_potential_flow_application_variables.cpp +++ b/applications/CompressiblePotentialFlowApplication/compressible_potential_flow_application_variables.cpp @@ -47,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 ab6a66d89cb6..28265f6e4539 100644 --- a/applications/CompressiblePotentialFlowApplication/compressible_potential_flow_application_variables.h +++ b/applications/CompressiblePotentialFlowApplication/compressible_potential_flow_application_variables.h @@ -70,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_elements/embedded_incompressible_potential_flow_element.cpp b/applications/CompressiblePotentialFlowApplication/custom_elements/embedded_incompressible_potential_flow_element.cpp index e4170ca6a8fd..40a7410d8fdd 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); } } @@ -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 penalty_coefficient = rCurrentProcessInfo[PENALTY_COEFFICIENT]; + 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) += penalty_coefficient*penalty_term_potential; - noalias(rRightHandSideVector) += penalty_coefficient*(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 <> 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..10e13133bcbf 100644 --- a/applications/CompressiblePotentialFlowApplication/custom_python/compressible_potential_flow_python_application.cpp +++ b/applications/CompressiblePotentialFlowApplication/custom_python/compressible_potential_flow_python_application.cpp @@ -80,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/custom_utilities/potential_flow_utilities.cpp b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.cpp index 7484b69f1a53..1b69fbf2a45c 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) { @@ -276,7 +354,51 @@ 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 +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) +{ + // 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]; + + // 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 @@ -305,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 @@ -315,12 +437,58 @@ 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; } +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); + + 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 double ComputePerturbationLocalMachNumber(const Element& rElement, const ProcessInfo& rCurrentProcessInfo) { @@ -332,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; @@ -432,13 +600,20 @@ 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); @@ -457,13 +632,20 @@ 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); diff --git a/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h b/applications/CompressiblePotentialFlowApplication/custom_utilities/potential_flow_utilities.h index da81b44e7b07..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,7 +119,6 @@ void CheckIfWakeConditionsAreFulfilled(const ModelPart& rWakeModelPart, const do template bool CheckWakeCondition(const Element& rElement, const double& rTolerance, const int& rEchoLevel); - } // namespace PotentialFlow } // namespace Kratos 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/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/cpp_tests/test_potential_flow_utilities.cpp b/applications/CompressiblePotentialFlowApplication/tests/cpp_tests/test_potential_flow_utilities.cpp index 1dfbb5519c75..939027fa7611 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,6 +82,36 @@ void AssignPerturbationPotentialsToElement(Element& rElement) { potential[i]; } +// checks the function ComputeVelocityMagnitude from utilities +KRATOS_TEST_CASE_IN_SUITE(ComputeVelocityMagnitude, CompressiblePotentialApplicationFastSuite) { + Model this_model; + ModelPart& model_part = this_model.CreateModelPart("Main", 3); + + AssignFreeStreamValues(model_part); + + // velocity corresponding to squared mach number of 3.0 + const double local_velocity_squared = PotentialFlowUtilities::ComputeVelocityMagnitude<2, 3>(3.0, model_part.GetProcessInfo()); + + const double reference_velocity_squared = 232356.0; + + KRATOS_CHECK_RELATIVE_NEAR(local_velocity_squared, reference_velocity_squared, 1e-15); +} + +// 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); + + AssignFreeStreamValues(model_part); + + const double reference_max_velocity_squared = 232356.0; + + // Max local Mach number = sqrt(3.0), from MACH_SQUARED_LIMIT + 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); +} + // Checks the function ComputeLocalSpeedOfSound from the utilities KRATOS_TEST_CASE_IN_SUITE(ComputeLocalSpeedOfSound, CompressiblePotentialApplicationFastSuite) { Model this_model; @@ -84,6 +127,28 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeLocalSpeedOfSound, CompressiblePotentialApplica KRATOS_CHECK_NEAR(local_speed_of_sound, 333.801138, 1e-6); } +// 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); + + AssignFreeStreamValues(model_part); + + const double local_mach_number_squared = 3.0; + + // velocity corresponding to mach number 3.0 + const double local_velocity_squared = PotentialFlowUtilities::ComputeVelocityMagnitude<2, 3>(local_mach_number_squared, model_part.GetProcessInfo()); + + array_1d velocity(2, 0.0); + velocity[0] = std::sqrt(local_velocity_squared); + + const double local_speed_sound_squared = PotentialFlowUtilities::ComputeLocalSpeedofSoundSquared<2,3>(velocity, model_part.GetProcessInfo()); + + const double reference_local_speed_sound_squared = 77452.0; + + KRATOS_CHECK_RELATIVE_NEAR(local_speed_sound_squared, reference_local_speed_sound_squared, 1e-15); +} + // Checks the function ComputeLocalMachNumber from the utilities KRATOS_TEST_CASE_IN_SUITE(ComputeLocalMachNumber, CompressiblePotentialApplicationFastSuite) { Model this_model; @@ -99,6 +164,79 @@ KRATOS_TEST_CASE_IN_SUITE(ComputeLocalMachNumber, CompressiblePotentialApplicati KRATOS_CHECK_NEAR(local_mach_number, 0.748948914, 1e-6); } +// 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); + + AssignFreeStreamValues(model_part); + + const double reference_local_mach_squared = 3.0; + + // velocity corresponding to mach number 3.0 + const double local_velocity_squared = PotentialFlowUtilities::ComputeVelocityMagnitude<2, 3>(reference_local_mach_squared, model_part.GetProcessInfo()); + + array_1d velocity(2, 0.0); + 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()); + + KRATOS_CHECK_RELATIVE_NEAR(local_mach_squared, reference_local_mach_squared, 1e-15); +} + +// 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); + + AssignFreeStreamValues(model_part); + + const double local_mach_number_squared = 1.0; + + // velocity corresponding to mach number 1.0 + const double local_velocity_squared = PotentialFlowUtilities::ComputeVelocityMagnitude<2, 3>(local_mach_number_squared, model_part.GetProcessInfo()); + + array_1d velocity(2, 0.0); + 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()); + + const double mach_derivative = PotentialFlowUtilities::ComputeDerivativeLocalMachSquaredWRTVelocitySquared<2, 3>(velocity, + local_mach_squared, model_part.GetProcessInfo()); + + const double reference_derivative = 1.1620100191086091883e-05; + + KRATOS_CHECK_RELATIVE_NEAR(mach_derivative, reference_derivative, 1e-16); +} + +// 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); + + AssignFreeStreamValues(model_part); + + const double local_mach_number_squared = 3.0; + + // velocity corresponding to mach number 3.0 + const double local_velocity_squared = PotentialFlowUtilities::ComputeVelocityMagnitude<2, 3>(local_mach_number_squared, model_part.GetProcessInfo()); + + array_1d velocity(2, 0.0); + 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()); + + const double mach_derivative = PotentialFlowUtilities::ComputeDerivativeLocalMachSquaredWRTVelocitySquared<2, 3>(velocity, + local_mach_squared, model_part.GetProcessInfo()); + + const double reference_derivative = 2.0657955895264163348e-05; + + KRATOS_CHECK_RELATIVE_NEAR(mach_derivative, reference_derivative, 1e-16); +} + // Checks the function ComputeIncompressiblePerturbationPressureCoefficient from the utilities KRATOS_TEST_CASE_IN_SUITE(ComputePerturbationIncompressiblePressureCoefficient, CompressiblePotentialApplicationFastSuite) { Model this_model; 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, diff --git a/applications/ContactStructuralMechanicsApplication/custom_conditions/ALM_frictional_mortar_contact_condition.cpp b/applications/ContactStructuralMechanicsApplication/custom_conditions/ALM_frictional_mortar_contact_condition.cpp index c5ac54f8c2c1..8926f54dfe52 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_conditions/ALM_frictional_mortar_contact_condition.cpp +++ b/applications/ContactStructuralMechanicsApplication/custom_conditions/ALM_frictional_mortar_contact_condition.cpp @@ -69,11 +69,11 @@ AugmentedLagrangianMethodFrictionalMortarContactCondition -void AugmentedLagrangianMethodFrictionalMortarContactCondition::Initialize( ) +void AugmentedLagrangianMethodFrictionalMortarContactCondition::Initialize(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; - BaseType::Initialize(); + BaseType::Initialize(rCurrentProcessInfo); // We initailize the previous mortar operators mPreviousMortarOperators.Initialize(); @@ -86,7 +86,7 @@ void AugmentedLagrangianMethodFrictionalMortarContactCondition -void AugmentedLagrangianMethodFrictionalMortarContactCondition::InitializeSolutionStep( ProcessInfo& rCurrentProcessInfo ) +void AugmentedLagrangianMethodFrictionalMortarContactCondition::InitializeSolutionStep(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -105,7 +105,7 @@ void AugmentedLagrangianMethodFrictionalMortarContactCondition -void AugmentedLagrangianMethodFrictionalMortarContactCondition::FinalizeSolutionStep( ProcessInfo& rCurrentProcessInfo ) +void AugmentedLagrangianMethodFrictionalMortarContactCondition::FinalizeSolutionStep(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -121,7 +121,7 @@ void AugmentedLagrangianMethodFrictionalMortarContactCondition -void AugmentedLagrangianMethodFrictionalMortarContactCondition::AddExplicitContribution(ProcessInfo& rCurrentProcessInfo) +void AugmentedLagrangianMethodFrictionalMortarContactCondition::AddExplicitContribution(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -135,7 +135,7 @@ void AugmentedLagrangianMethodFrictionalMortarContactCondition -void AugmentedLagrangianMethodFrictionalMortarContactCondition::ComputePreviousMortarOperators( ProcessInfo& rCurrentProcessInfo) +void AugmentedLagrangianMethodFrictionalMortarContactCondition::ComputePreviousMortarOperators(const ProcessInfo& rCurrentProcessInfo) { const IndexType integration_order = this->GetProperties().Has(INTEGRATION_ORDER_CONTACT) ? this->GetProperties().GetValue(INTEGRATION_ORDER_CONTACT) : 2; MortarExplicitContributionUtilities::ComputePreviousMortarOperators(this, rCurrentProcessInfo, mPreviousMortarOperators, integration_order, false); @@ -176017,15 +176017,14 @@ void AugmentedLagrangianMethodFrictionalMortarContactCondition<3,4, true, 3>::Ca } } - /****************************** END AD REPLACEMENT *********************************/ /***********************************************************************************/ template< std::size_t TDim, std::size_t TNumNodes, bool TNormalVariation, std::size_t TNumNodesMaster> void AugmentedLagrangianMethodFrictionalMortarContactCondition::EquationIdVector( EquationIdVectorType& rResult, - ProcessInfo& CurrentProcessInfo - ) + const ProcessInfo& CurrentProcessInfo + ) const { KRATOS_TRY; @@ -176035,30 +176034,31 @@ void AugmentedLagrangianMethodFrictionalMortarContactConditionGetPairedGeometry();; + const GeometryType& r_current_master = this->GetPairedGeometry(); + const GeometryType& r_current_slave = this->GetParentGeometry(); // Master Nodes Displacement Equation IDs for ( IndexType i_master = 0; i_master < TNumNodesMaster; ++i_master ) { // NOTE: Assuming same number of nodes for master and slave - NodeType& master_node = current_master[i_master]; - rResult[index++] = master_node.GetDof( DISPLACEMENT_X ).EquationId( ); - rResult[index++] = master_node.GetDof( DISPLACEMENT_Y ).EquationId( ); - if (TDim == 3) rResult[index++] = master_node.GetDof( DISPLACEMENT_Z ).EquationId( ); + const NodeType& r_master_node = r_current_master[i_master]; + rResult[index++] = r_master_node.GetDof( DISPLACEMENT_X ).EquationId( ); + rResult[index++] = r_master_node.GetDof( DISPLACEMENT_Y ).EquationId( ); + if (TDim == 3) rResult[index++] = r_master_node.GetDof( DISPLACEMENT_Z ).EquationId( ); } // Slave Nodes Displacement Equation IDs for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) { - NodeType& slave_node = this->GetParentGeometry()[ i_slave ]; - rResult[index++] = slave_node.GetDof( DISPLACEMENT_X ).EquationId( ); - rResult[index++] = slave_node.GetDof( DISPLACEMENT_Y ).EquationId( ); - if (TDim == 3) rResult[index++] = slave_node.GetDof( DISPLACEMENT_Z ).EquationId( ); + const NodeType& r_slave_node = r_current_slave[ i_slave ]; + rResult[index++] = r_slave_node.GetDof( DISPLACEMENT_X ).EquationId( ); + rResult[index++] = r_slave_node.GetDof( DISPLACEMENT_Y ).EquationId( ); + if (TDim == 3) rResult[index++] = r_slave_node.GetDof( DISPLACEMENT_Z ).EquationId( ); } // Slave Nodes Lambda Equation IDs for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) { - NodeType& slave_node = this->GetParentGeometry()[ i_slave ]; - rResult[index++] = slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_X ).EquationId( ); - rResult[index++] = slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_Y ).EquationId( ); - if (TDim == 3) rResult[index++] = slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_Z ).EquationId( ); + const NodeType& r_slave_node = r_current_slave[ i_slave ]; + rResult[index++] = r_slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_X ).EquationId( ); + rResult[index++] = r_slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_Y ).EquationId( ); + if (TDim == 3) rResult[index++] = r_slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_Z ).EquationId( ); } KRATOS_CATCH( "" ); @@ -176070,8 +176070,8 @@ void AugmentedLagrangianMethodFrictionalMortarContactCondition void AugmentedLagrangianMethodFrictionalMortarContactCondition::GetDofList( DofsVectorType& rConditionalDofList, - ProcessInfo& rCurrentProcessInfo -) + const ProcessInfo& rCurrentProcessInfo + ) const { KRATOS_TRY; @@ -176081,30 +176081,31 @@ void AugmentedLagrangianMethodFrictionalMortarContactConditionGetPairedGeometry();; + const GeometryType& r_current_master = this->GetPairedGeometry(); + const GeometryType& r_current_slave = this->GetParentGeometry(); // Master Nodes Displacement Equation IDs - for ( IndexType i_master = 0; i_master < TNumNodesMaster; ++i_master ){ // NOTE: Assuming same number of nodes for master and slave - NodeType& master_node = current_master[i_master]; - rConditionalDofList[index++] = master_node.pGetDof( DISPLACEMENT_X ); - rConditionalDofList[index++] = master_node.pGetDof( DISPLACEMENT_Y ); - if (TDim == 3) rConditionalDofList[index++] = master_node.pGetDof( DISPLACEMENT_Z ); + for ( IndexType i_master = 0; i_master < TNumNodesMaster; ++i_master ) { // NOTE: Assuming same number of nodes for master and slave + const NodeType& r_master_node = r_current_master[i_master]; + rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_X ); + rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_Y ); + if (TDim == 3) rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_Z ); } // Slave Nodes Displacement Equation IDs for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) { - NodeType& slave_node = this->GetParentGeometry()[ i_slave ]; - rConditionalDofList[index++] = slave_node.pGetDof( DISPLACEMENT_X ); - rConditionalDofList[index++] = slave_node.pGetDof( DISPLACEMENT_Y ); - if (TDim == 3) rConditionalDofList[index++] = slave_node.pGetDof( DISPLACEMENT_Z ); + const NodeType& r_slave_node = r_current_slave[ i_slave ]; + rConditionalDofList[index++] = r_slave_node.pGetDof( DISPLACEMENT_X ); + rConditionalDofList[index++] = r_slave_node.pGetDof( DISPLACEMENT_Y ); + if (TDim == 3) rConditionalDofList[index++] = r_slave_node.pGetDof( DISPLACEMENT_Z ); } // Slave Nodes Lambda Equation IDs for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) { - NodeType& slave_node = this->GetParentGeometry()[ i_slave ]; - rConditionalDofList[index++] = slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_X ); - rConditionalDofList[index++] = slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_Y ); - if (TDim == 3) rConditionalDofList[index++] = slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_Z ); + const NodeType& r_slave_node = r_current_slave[ i_slave ]; + rConditionalDofList[index++] = r_slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_X ); + rConditionalDofList[index++] = r_slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_Y ); + if (TDim == 3) rConditionalDofList[index++] = r_slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_Z ); } KRATOS_CATCH( "" ); @@ -176114,7 +176115,7 @@ void AugmentedLagrangianMethodFrictionalMortarContactCondition -int AugmentedLagrangianMethodFrictionalMortarContactCondition::Check( const ProcessInfo& rCurrentProcessInfo ) +int AugmentedLagrangianMethodFrictionalMortarContactCondition::Check(const ProcessInfo& rCurrentProcessInfo) const { KRATOS_TRY @@ -176123,19 +176124,19 @@ int AugmentedLagrangianMethodFrictionalMortarContactConditionGetParentGeometry(); for ( IndexType i = 0; i < TNumNodes; ++i ) { - Node<3> &rnode = this->GetParentGeometry()[i]; - KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(NORMAL,rnode) - KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(VECTOR_LAGRANGE_MULTIPLIER,rnode) + const NodeType &r_node = r_current_slave[i]; + KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(VECTOR_LAGRANGE_MULTIPLIER,r_node) + KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(WEIGHTED_SLIP,r_node) - KRATOS_CHECK_DOF_IN_NODE(VECTOR_LAGRANGE_MULTIPLIER_X, rnode) - KRATOS_CHECK_DOF_IN_NODE(VECTOR_LAGRANGE_MULTIPLIER_Y, rnode) - KRATOS_CHECK_DOF_IN_NODE(VECTOR_LAGRANGE_MULTIPLIER_Z, rnode) + KRATOS_CHECK_DOF_IN_NODE(VECTOR_LAGRANGE_MULTIPLIER_X, r_node) + KRATOS_CHECK_DOF_IN_NODE(VECTOR_LAGRANGE_MULTIPLIER_Y, r_node) + KRATOS_CHECK_DOF_IN_NODE(VECTOR_LAGRANGE_MULTIPLIER_Z, r_node) } return ierr; diff --git a/applications/ContactStructuralMechanicsApplication/custom_conditions/ALM_frictional_mortar_contact_condition.h b/applications/ContactStructuralMechanicsApplication/custom_conditions/ALM_frictional_mortar_contact_condition.h index 6c858cd1e436..6b1bd3328b35 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_conditions/ALM_frictional_mortar_contact_condition.h +++ b/applications/ContactStructuralMechanicsApplication/custom_conditions/ALM_frictional_mortar_contact_condition.h @@ -180,19 +180,19 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) AugmentedLagrangianMe /** * @brief Called at the beginning of each solution step */ - void Initialize() override; + void Initialize(const ProcessInfo& rCurrentProcessInfo) override; /** * @brief Called at the begining of each solution step * @param rCurrentProcessInfo the current process info instance */ - void InitializeSolutionStep(ProcessInfo& rCurrentProcessInfo) override; + void InitializeSolutionStep(const ProcessInfo& rCurrentProcessInfo) override; /** * @brief Called at the ending of each solution step * @param rCurrentProcessInfo the current process info instance */ - void FinalizeSolutionStep(ProcessInfo& rCurrentProcessInfo) override; + void FinalizeSolutionStep(const ProcessInfo& rCurrentProcessInfo) override; /** * @brief Creates a new element pointer from an arry of nodes @@ -245,7 +245,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) AugmentedLagrangianMe * SET/UNSETLOCK MUST BE PERFORMED IN THE STRATEGY BEFORE CALLING THIS FUNCTION * @param rCurrentProcessInfo the current process info instance */ - void AddExplicitContribution(ProcessInfo& rCurrentProcessInfo) override; + void AddExplicitContribution(const ProcessInfo& rCurrentProcessInfo) override; /******************************************************************/ /********** AUXILLIARY METHODS FOR GENERAL CALCULATIONS ***********/ @@ -258,8 +258,8 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) AugmentedLagrangianMe */ void EquationIdVector( EquationIdVectorType& rResult, - ProcessInfo& rCurrentProcessInfo - ) override; + const ProcessInfo& rCurrentProcessInfo + ) const override; /** * @brief Sets on ConditionalDofList the degrees of freedom of the considered element geometry @@ -268,8 +268,8 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) AugmentedLagrangianMe */ void GetDofList( DofsVectorType& rConditionalDofList, - ProcessInfo& rCurrentProcessInfo - ) override; + const ProcessInfo& rCurrentProcessInfo + ) const override; /** * @brief This function provides the place to perform checks on the completeness of the input. @@ -278,7 +278,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) AugmentedLagrangianMe * or that no common error is found. * @param rCurrentProcessInfo The current process information */ - int Check( const ProcessInfo& rCurrentProcessInfo ) override; + int Check(const ProcessInfo& rCurrentProcessInfo) const override; ///@} ///@name Access @@ -452,7 +452,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) AugmentedLagrangianMe * @brief It computes the previous mortar operators * @param rCurrentProcessInfo The current process information */ - void ComputePreviousMortarOperators( ProcessInfo& rCurrentProcessInfo); + void ComputePreviousMortarOperators(const ProcessInfo& rCurrentProcessInfo); ///@} ///@name Private Access diff --git a/applications/ContactStructuralMechanicsApplication/custom_conditions/ALM_frictionless_components_mortar_contact_condition.cpp b/applications/ContactStructuralMechanicsApplication/custom_conditions/ALM_frictionless_components_mortar_contact_condition.cpp index 3f13e5c55ef3..2ed692785030 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_conditions/ALM_frictionless_components_mortar_contact_condition.cpp +++ b/applications/ContactStructuralMechanicsApplication/custom_conditions/ALM_frictionless_components_mortar_contact_condition.cpp @@ -66,10 +66,6 @@ AugmentedLagrangianMethodFrictionlessComponentsMortarContactCondition void AugmentedLagrangianMethodFrictionlessComponentsMortarContactCondition<2,2, false, 2>::CalculateLocalLHS( Matrix& rLocalLHS, @@ -27681,10 +27677,6 @@ void AugmentedLagrangianMethodFrictionlessComponentsMortarContactCondition<3,4, /***************************** BEGIN AD REPLACEMENT ********************************/ /***********************************************************************************/ - -/***********************************************************************************/ -/***********************************************************************************/ - template<> void AugmentedLagrangianMethodFrictionlessComponentsMortarContactCondition<2,2, false, 2>::CalculateLocalRHS( Vector& rLocalRHS, @@ -30129,8 +30121,8 @@ void AugmentedLagrangianMethodFrictionlessComponentsMortarContactCondition<3,4, template< SizeType TDim, SizeType TNumNodes, bool TNormalVariation, SizeType TNumNodesMaster > void AugmentedLagrangianMethodFrictionlessComponentsMortarContactCondition::EquationIdVector( EquationIdVectorType& rResult, - ProcessInfo& CurrentProcessInfo - ) + const ProcessInfo& CurrentProcessInfo + ) const { KRATOS_TRY; @@ -30140,33 +30132,31 @@ void AugmentedLagrangianMethodFrictionlessComponentsMortarContactConditionGetPairedGeometry();; + const GeometryType& r_current_master = this->GetPairedGeometry(); + const GeometryType& r_current_slave = this->GetParentGeometry(); // Master Nodes Displacement Equation IDs - for ( IndexType i_master = 0; i_master < TNumNodesMaster; i_master++ ) // NOTE: Assuming same number of nodes for master and slave - { - NodeType& master_node = current_master[i_master]; - rResult[index++] = master_node.GetDof( DISPLACEMENT_X ).EquationId( ); - rResult[index++] = master_node.GetDof( DISPLACEMENT_Y ).EquationId( ); - if (TDim == 3) rResult[index++] = master_node.GetDof( DISPLACEMENT_Z ).EquationId( ); + for ( IndexType i_master = 0; i_master < TNumNodesMaster; ++i_master ) { // NOTE: Assuming same number of nodes for master and slave + const NodeType& r_master_node = r_current_master[i_master]; + rResult[index++] = r_master_node.GetDof( DISPLACEMENT_X ).EquationId( ); + rResult[index++] = r_master_node.GetDof( DISPLACEMENT_Y ).EquationId( ); + if (TDim == 3) rResult[index++] = r_master_node.GetDof( DISPLACEMENT_Z ).EquationId( ); } // Slave Nodes Displacement Equation IDs - for ( IndexType i_slave = 0; i_slave < TNumNodes; i_slave++ ) - { - NodeType& slave_node = this->GetParentGeometry()[ i_slave ]; - rResult[index++] = slave_node.GetDof( DISPLACEMENT_X ).EquationId( ); - rResult[index++] = slave_node.GetDof( DISPLACEMENT_Y ).EquationId( ); - if (TDim == 3) rResult[index++] = slave_node.GetDof( DISPLACEMENT_Z ).EquationId( ); + for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) { + const NodeType& r_slave_node = r_current_slave[ i_slave ]; + rResult[index++] = r_slave_node.GetDof( DISPLACEMENT_X ).EquationId( ); + rResult[index++] = r_slave_node.GetDof( DISPLACEMENT_Y ).EquationId( ); + if (TDim == 3) rResult[index++] = r_slave_node.GetDof( DISPLACEMENT_Z ).EquationId( ); } // Slave Nodes Lambda Equation IDs - for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) - { - NodeType& slave_node = this->GetParentGeometry()[ i_slave ]; - rResult[index++] = slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_X ).EquationId( ); - rResult[index++] = slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_Y ).EquationId( ); - if (TDim == 3) rResult[index++] = slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_Z ).EquationId( ); + for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) { + const NodeType& r_slave_node = r_current_slave[ i_slave ]; + rResult[index++] = r_slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_X ).EquationId( ); + rResult[index++] = r_slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_Y ).EquationId( ); + if (TDim == 3) rResult[index++] = r_slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_Z ).EquationId( ); } KRATOS_CATCH( "" ); @@ -30178,8 +30168,8 @@ void AugmentedLagrangianMethodFrictionlessComponentsMortarContactCondition void AugmentedLagrangianMethodFrictionlessComponentsMortarContactCondition::GetDofList( DofsVectorType& rConditionalDofList, - ProcessInfo& rCurrentProcessInfo - ) + const ProcessInfo& rCurrentProcessInfo + ) const { KRATOS_TRY; @@ -30189,33 +30179,31 @@ void AugmentedLagrangianMethodFrictionlessComponentsMortarContactConditionGetPairedGeometry();; + const GeometryType& r_current_master = this->GetPairedGeometry(); + const GeometryType& r_current_slave = this->GetParentGeometry(); // Master Nodes Displacement Equation IDs - for ( IndexType i_master = 0; i_master < TNumNodesMaster; ++i_master ) // NOTE: Assuming same number of nodes for master and slave - { - NodeType& master_node = current_master[i_master]; - rConditionalDofList[index++] = master_node.pGetDof( DISPLACEMENT_X ); - rConditionalDofList[index++] = master_node.pGetDof( DISPLACEMENT_Y ); - if (TDim == 3) rConditionalDofList[index++] = master_node.pGetDof( DISPLACEMENT_Z ); + for ( IndexType i_master = 0; i_master < TNumNodesMaster; ++i_master ) { // NOTE: Assuming same number of nodes for master and slave + const NodeType& r_master_node = r_current_master[i_master]; + rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_X ); + rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_Y ); + if (TDim == 3) rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_Z ); } // Slave Nodes Displacement Equation IDs - for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) - { - NodeType& slave_node = this->GetParentGeometry()[ i_slave ]; - rConditionalDofList[index++] = slave_node.pGetDof( DISPLACEMENT_X ); - rConditionalDofList[index++] = slave_node.pGetDof( DISPLACEMENT_Y ); - if (TDim == 3) rConditionalDofList[index++] = slave_node.pGetDof( DISPLACEMENT_Z ); + for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) { + const NodeType& r_slave_node = r_current_slave[ i_slave ]; + rConditionalDofList[index++] = r_slave_node.pGetDof( DISPLACEMENT_X ); + rConditionalDofList[index++] = r_slave_node.pGetDof( DISPLACEMENT_Y ); + if (TDim == 3) rConditionalDofList[index++] = r_slave_node.pGetDof( DISPLACEMENT_Z ); } // Slave Nodes Lambda Equation IDs - for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) - { - NodeType& slave_node = this->GetParentGeometry()[ i_slave ]; - rConditionalDofList[index++] = slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_X ); - rConditionalDofList[index++] = slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_Y ); - if (TDim == 3) rConditionalDofList[index++] = slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_Z ); + for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) { + const NodeType& r_slave_node = r_current_slave[ i_slave ]; + rConditionalDofList[index++] = r_slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_X ); + rConditionalDofList[index++] = r_slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_Y ); + if (TDim == 3) rConditionalDofList[index++] = r_slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_Z ); } KRATOS_CATCH( "" ); @@ -30225,7 +30213,7 @@ void AugmentedLagrangianMethodFrictionlessComponentsMortarContactCondition -int AugmentedLagrangianMethodFrictionlessComponentsMortarContactCondition::Check( const ProcessInfo& rCurrentProcessInfo ) +int AugmentedLagrangianMethodFrictionlessComponentsMortarContactCondition::Check(const ProcessInfo& rCurrentProcessInfo) const { KRATOS_TRY @@ -30237,14 +30225,14 @@ int AugmentedLagrangianMethodFrictionlessComponentsMortarContactConditionGetParentGeometry()[i]; - KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(VECTOR_LAGRANGE_MULTIPLIER,rnode) - - KRATOS_CHECK_DOF_IN_NODE(VECTOR_LAGRANGE_MULTIPLIER_X, rnode) - KRATOS_CHECK_DOF_IN_NODE(VECTOR_LAGRANGE_MULTIPLIER_Y, rnode) - KRATOS_CHECK_DOF_IN_NODE(VECTOR_LAGRANGE_MULTIPLIER_Z, rnode) + const GeometryType& r_current_slave = this->GetParentGeometry(); + for ( IndexType i = 0; i < TNumNodes; ++i ) { + const NodeType &r_node = r_current_slave[i]; + KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(VECTOR_LAGRANGE_MULTIPLIER,r_node) + + KRATOS_CHECK_DOF_IN_NODE(VECTOR_LAGRANGE_MULTIPLIER_X, r_node) + KRATOS_CHECK_DOF_IN_NODE(VECTOR_LAGRANGE_MULTIPLIER_Y, r_node) + KRATOS_CHECK_DOF_IN_NODE(VECTOR_LAGRANGE_MULTIPLIER_Z, r_node) } return ierr; diff --git a/applications/ContactStructuralMechanicsApplication/custom_conditions/ALM_frictionless_components_mortar_contact_condition.h b/applications/ContactStructuralMechanicsApplication/custom_conditions/ALM_frictionless_components_mortar_contact_condition.h index bf0d2c1bd98d..5efa9e113c21 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_conditions/ALM_frictionless_components_mortar_contact_condition.h +++ b/applications/ContactStructuralMechanicsApplication/custom_conditions/ALM_frictionless_components_mortar_contact_condition.h @@ -224,8 +224,8 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) AugmentedLagrangianMe */ void EquationIdVector( EquationIdVectorType& rResult, - ProcessInfo& rCurrentProcessInfo - ) override; + const ProcessInfo& rCurrentProcessInfo + ) const override; /** * @brief Sets on ConditionalDofList the degrees of freedom of the considered element geometry @@ -234,8 +234,8 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) AugmentedLagrangianMe */ void GetDofList( DofsVectorType& rConditionalDofList, - ProcessInfo& rCurrentProcessInfo - ) override; + const ProcessInfo& rCurrentProcessInfo + ) const override; /** * @brief This function provides the place to perform checks on the completeness of the input. @@ -244,7 +244,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) AugmentedLagrangianMe * or that no common error is found. * @param rCurrentProcessInfo The current process information */ - int Check( const ProcessInfo& rCurrentProcessInfo ) override; + int Check(const ProcessInfo& rCurrentProcessInfo) const override; ///@} ///@name Access diff --git a/applications/ContactStructuralMechanicsApplication/custom_conditions/ALM_frictionless_mortar_contact_condition.cpp b/applications/ContactStructuralMechanicsApplication/custom_conditions/ALM_frictionless_mortar_contact_condition.cpp index 0c5f8a9bfb0a..f55eee867bdf 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_conditions/ALM_frictionless_mortar_contact_condition.cpp +++ b/applications/ContactStructuralMechanicsApplication/custom_conditions/ALM_frictionless_mortar_contact_condition.cpp @@ -27749,10 +27749,6 @@ void AugmentedLagrangianMethodFrictionlessMortarContactCondition<3, 4, true, 3>: /***************************** BEGIN AD REPLACEMENT ********************************/ /***********************************************************************************/ - -/***********************************************************************************/ -/***********************************************************************************/ - template<> void AugmentedLagrangianMethodFrictionlessMortarContactCondition<2, 2, false, 2>::CalculateLocalRHS( Vector& rLocalRHS, @@ -29587,8 +29583,8 @@ void AugmentedLagrangianMethodFrictionlessMortarContactCondition<3, 4, true, 3>: template< SizeType TDim, SizeType TNumNodes, bool TNormalVariation, SizeType TNumNodesMaster > void AugmentedLagrangianMethodFrictionlessMortarContactCondition::EquationIdVector( EquationIdVectorType& rResult, - ProcessInfo& CurrentProcessInfo - ) + const ProcessInfo& CurrentProcessInfo + ) const { KRATOS_TRY; @@ -29598,28 +29594,29 @@ void AugmentedLagrangianMethodFrictionlessMortarContactConditionGetPairedGeometry();; + const GeometryType& r_current_master = this->GetPairedGeometry(); + const GeometryType& r_current_slave = this->GetParentGeometry(); // Master Nodes Displacement Equation IDs for ( IndexType i_master = 0; i_master < TNumNodesMaster; ++i_master ) { // NOTE: Assuming same number of nodes for master and slave - NodeType& master_node = current_master[i_master]; - rResult[index++] = master_node.GetDof( DISPLACEMENT_X ).EquationId( ); - rResult[index++] = master_node.GetDof( DISPLACEMENT_Y ).EquationId( ); - if (TDim == 3) rResult[index++] = master_node.GetDof( DISPLACEMENT_Z ).EquationId( ); + const NodeType& r_master_node = r_current_master[i_master]; + rResult[index++] = r_master_node.GetDof( DISPLACEMENT_X ).EquationId( ); + rResult[index++] = r_master_node.GetDof( DISPLACEMENT_Y ).EquationId( ); + if (TDim == 3) rResult[index++] = r_master_node.GetDof( DISPLACEMENT_Z ).EquationId( ); } // Slave Nodes Displacement Equation IDs for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) { - NodeType& slave_node = this->GetParentGeometry()[ i_slave ]; - rResult[index++] = slave_node.GetDof( DISPLACEMENT_X ).EquationId( ); - rResult[index++] = slave_node.GetDof( DISPLACEMENT_Y ).EquationId( ); - if (TDim == 3) rResult[index++] = slave_node.GetDof( DISPLACEMENT_Z ).EquationId( ); + const NodeType& r_slave_node = r_current_slave[ i_slave ]; + rResult[index++] = r_slave_node.GetDof( DISPLACEMENT_X ).EquationId( ); + rResult[index++] = r_slave_node.GetDof( DISPLACEMENT_Y ).EquationId( ); + if (TDim == 3) rResult[index++] = r_slave_node.GetDof( DISPLACEMENT_Z ).EquationId( ); } // Slave Nodes Lambda Equation IDs for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) { - NodeType& slave_node = this->GetParentGeometry()[ i_slave ]; - rResult[index++] = slave_node.GetDof( LAGRANGE_MULTIPLIER_CONTACT_PRESSURE ).EquationId( ); + const NodeType& r_slave_node = r_current_slave[ i_slave ]; + rResult[index++] = r_slave_node.GetDof( LAGRANGE_MULTIPLIER_CONTACT_PRESSURE ).EquationId( ); } KRATOS_CATCH( "" ); @@ -29631,8 +29628,8 @@ void AugmentedLagrangianMethodFrictionlessMortarContactCondition void AugmentedLagrangianMethodFrictionlessMortarContactCondition::GetDofList( DofsVectorType& rConditionalDofList, - ProcessInfo& rCurrentProcessInfo - ) + const ProcessInfo& rCurrentProcessInfo + ) const { KRATOS_TRY; @@ -29642,28 +29639,29 @@ void AugmentedLagrangianMethodFrictionlessMortarContactConditionGetPairedGeometry();; + const GeometryType& r_current_master = this->GetPairedGeometry(); + const GeometryType& r_current_slave = this->GetParentGeometry(); // Master Nodes Displacement Equation IDs for ( IndexType i_master = 0; i_master < TNumNodesMaster; ++i_master ) { // NOTE: Assuming same number of nodes for master and slave - NodeType& master_node = current_master[i_master]; - rConditionalDofList[index++] = master_node.pGetDof( DISPLACEMENT_X ); - rConditionalDofList[index++] = master_node.pGetDof( DISPLACEMENT_Y ); - if (TDim == 3) rConditionalDofList[index++] = master_node.pGetDof( DISPLACEMENT_Z ); + const NodeType& r_master_node = r_current_master[i_master]; + rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_X ); + rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_Y ); + if (TDim == 3) rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_Z ); } // Slave Nodes Displacement Equation IDs for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) { - NodeType& slave_node = this->GetParentGeometry()[ i_slave ]; - rConditionalDofList[index++] = slave_node.pGetDof( DISPLACEMENT_X ); - rConditionalDofList[index++] = slave_node.pGetDof( DISPLACEMENT_Y ); - if (TDim == 3) rConditionalDofList[index++] = slave_node.pGetDof( DISPLACEMENT_Z ); + const NodeType& r_slave_node = r_current_slave[ i_slave ]; + rConditionalDofList[index++] = r_slave_node.pGetDof( DISPLACEMENT_X ); + rConditionalDofList[index++] = r_slave_node.pGetDof( DISPLACEMENT_Y ); + if (TDim == 3) rConditionalDofList[index++] = r_slave_node.pGetDof( DISPLACEMENT_Z ); } // Slave Nodes Lambda Equation IDs for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) { - NodeType& slave_node = this->GetParentGeometry()[ i_slave ]; - rConditionalDofList[index++] = slave_node.pGetDof( LAGRANGE_MULTIPLIER_CONTACT_PRESSURE ); + const NodeType& r_slave_node = r_current_slave[ i_slave ]; + rConditionalDofList[index++] = r_slave_node.pGetDof( LAGRANGE_MULTIPLIER_CONTACT_PRESSURE ); } KRATOS_CATCH( "" ); @@ -29673,7 +29671,7 @@ void AugmentedLagrangianMethodFrictionlessMortarContactCondition -int AugmentedLagrangianMethodFrictionlessMortarContactCondition::Check( const ProcessInfo& rCurrentProcessInfo ) +int AugmentedLagrangianMethodFrictionlessMortarContactCondition::Check(const ProcessInfo& rCurrentProcessInfo) const { KRATOS_TRY @@ -29682,16 +29680,15 @@ int AugmentedLagrangianMethodFrictionlessMortarContactConditionGetParentGeometry(); for ( IndexType i = 0; i < TNumNodes; ++i ) { - Node<3> &rnode = this->GetParentGeometry()[i]; - KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(NORMAL,rnode) - KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(LAGRANGE_MULTIPLIER_CONTACT_PRESSURE,rnode) + const NodeType &r_node = r_current_slave[i]; + KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(LAGRANGE_MULTIPLIER_CONTACT_PRESSURE,r_node) - KRATOS_CHECK_DOF_IN_NODE(LAGRANGE_MULTIPLIER_CONTACT_PRESSURE, rnode) + KRATOS_CHECK_DOF_IN_NODE(LAGRANGE_MULTIPLIER_CONTACT_PRESSURE, r_node) } return ierr; diff --git a/applications/ContactStructuralMechanicsApplication/custom_conditions/ALM_frictionless_mortar_contact_condition.h b/applications/ContactStructuralMechanicsApplication/custom_conditions/ALM_frictionless_mortar_contact_condition.h index 57c5beefadfd..8a66b6613ac2 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_conditions/ALM_frictionless_mortar_contact_condition.h +++ b/applications/ContactStructuralMechanicsApplication/custom_conditions/ALM_frictionless_mortar_contact_condition.h @@ -224,8 +224,8 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) AugmentedLagrangianMe */ void EquationIdVector( EquationIdVectorType& rResult, - ProcessInfo& rCurrentProcessInfo - ) override; + const ProcessInfo& rCurrentProcessInfo + ) const override; /** * @brief Sets on ConditionalDofList the degrees of freedom of the considered element geometry @@ -234,8 +234,8 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) AugmentedLagrangianMe */ void GetDofList( DofsVectorType& rConditionalDofList, - ProcessInfo& rCurrentProcessInfo - ) override; + const ProcessInfo& rCurrentProcessInfo + ) const override; /** * @brief This function provides the place to perform checks on the completeness of the input. @@ -244,7 +244,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) AugmentedLagrangianMe * or that no common error is found. * @param rCurrentProcessInfo The current process information */ - int Check( const ProcessInfo& rCurrentProcessInfo ) override; + int Check(const ProcessInfo& rCurrentProcessInfo) const override; ///@} ///@name Access diff --git a/applications/ContactStructuralMechanicsApplication/custom_conditions/mesh_tying_mortar_condition.cpp b/applications/ContactStructuralMechanicsApplication/custom_conditions/mesh_tying_mortar_condition.cpp index 5187d920073e..21020a93cb21 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_conditions/mesh_tying_mortar_condition.cpp +++ b/applications/ContactStructuralMechanicsApplication/custom_conditions/mesh_tying_mortar_condition.cpp @@ -69,18 +69,18 @@ MeshTyingMortarCondition::~MeshTyingMor /***********************************************************************************/ template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> -void MeshTyingMortarCondition::Initialize( ) +void MeshTyingMortarCondition::Initialize(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; - BaseType::Initialize(); + BaseType::Initialize(rCurrentProcessInfo); // We get the unkown variable - const std::string variable_name = GetProperties().Has(TYING_VARIABLE) ? GetProperties().GetValue(TYING_VARIABLE) : "DISPLACEMENT"; - if (KratosComponents>::Has(variable_name)) { - mDoubleVariables.push_back(KratosComponents>::Get(variable_name)); - } else if (KratosComponents>>::Has(variable_name)) { - mArray1DVariables.push_back(KratosComponents>>::Get(variable_name)); + const std::string r_variable_name = GetProperties().Has(TYING_VARIABLE) ? GetProperties().GetValue(TYING_VARIABLE) : "DISPLACEMENT"; + if (KratosComponents>::Has(r_variable_name)) { + mpDoubleVariables.push_back(&KratosComponents>::Get(r_variable_name)); + } else if (KratosComponents>>::Has(r_variable_name)) { + mpArray1DVariables.push_back(&KratosComponents>>::Get(r_variable_name)); } else { KRATOS_ERROR << "Compatible variables are: double or array_1d " << std::endl; } @@ -173,7 +173,7 @@ void MeshTyingMortarCondition::Initiali /***********************************************************************************/ template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> -void MeshTyingMortarCondition::InitializeSolutionStep( ProcessInfo& rCurrentProcessInfo ) +void MeshTyingMortarCondition::InitializeSolutionStep(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -186,7 +186,7 @@ void MeshTyingMortarCondition::Initiali /***********************************************************************************/ template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> -void MeshTyingMortarCondition::InitializeNonLinearIteration( ProcessInfo& rCurrentProcessInfo ) +void MeshTyingMortarCondition::InitializeNonLinearIteration(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -199,7 +199,7 @@ void MeshTyingMortarCondition::Initiali /***********************************************************************************/ template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> -void MeshTyingMortarCondition::FinalizeSolutionStep( ProcessInfo& rCurrentProcessInfo ) +void MeshTyingMortarCondition::FinalizeSolutionStep(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -212,7 +212,7 @@ void MeshTyingMortarCondition::Finalize /***********************************************************************************/ template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> -void MeshTyingMortarCondition::FinalizeNonLinearIteration( ProcessInfo& rCurrentProcessInfo ) +void MeshTyingMortarCondition::FinalizeNonLinearIteration(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -228,13 +228,13 @@ template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> void MeshTyingMortarCondition::CalculateLocalSystem( MatrixType& rLeftHandSideMatrix, VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) { KRATOS_TRY; // Compute the matrix size - const TensorValue tensor_value = (mDoubleVariables.size() == 1) ? ScalarValue : static_cast(TDim); + const TensorValue tensor_value = (mpDoubleVariables.size() == 1) ? ScalarValue : static_cast(TDim); const SizeType matrix_size = tensor_value * (2 * NumNodes + NumNodesMaster); // Resizing as needed the LHS @@ -257,11 +257,11 @@ void MeshTyingMortarCondition::Calculat template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> void MeshTyingMortarCondition::CalculateLeftHandSide( MatrixType& rLeftHandSideMatrix, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) { // Compute the matrix size - const TensorValue tensor_value = (mDoubleVariables.size() == 1) ? ScalarValue : static_cast(TDim); + const TensorValue tensor_value = (mpDoubleVariables.size() == 1) ? ScalarValue : static_cast(TDim); const SizeType matrix_size = tensor_value * (2 * NumNodes + NumNodesMaster); // Resizing as needed the LHS @@ -281,14 +281,14 @@ void MeshTyingMortarCondition::Calculat template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> void MeshTyingMortarCondition::CalculateRightHandSide( VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) { // Creating an auxiliar matrix MatrixType aux_left_hand_side_matrix = Matrix(); // Compute the matrix size - const TensorValue tensor_value = (mDoubleVariables.size() == 1) ? ScalarValue : static_cast(TDim); + const TensorValue tensor_value = (mpDoubleVariables.size() == 1) ? ScalarValue : static_cast(TDim); const SizeType matrix_size = tensor_value * (2 * NumNodes + NumNodesMaster); // Resizing as needed the RHS @@ -305,7 +305,7 @@ void MeshTyingMortarCondition::Calculat template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> void MeshTyingMortarCondition::CalculateMassMatrix( MatrixType& rMassMatrix, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) { KRATOS_TRY; @@ -321,7 +321,7 @@ void MeshTyingMortarCondition::Calculat template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> void MeshTyingMortarCondition::CalculateDampingMatrix( MatrixType& rDampingMatrix, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) { KRATOS_TRY; @@ -346,7 +346,7 @@ void MeshTyingMortarCondition::Calcula KRATOS_TRY; // Create the current DoF data - const TensorValue tensor_value = (mDoubleVariables.size() == 1) ? ScalarValue : static_cast(TDim); + const TensorValue tensor_value = (mpDoubleVariables.size() == 1) ? ScalarValue : static_cast(TDim); if (tensor_value == ScalarValue) { DofData dof_data; @@ -355,7 +355,7 @@ void MeshTyingMortarCondition::Calcula this->InitializeDofData(dof_data); // Update slave element info - dof_data.UpdateMasterPair(this->GetPairedGeometry(), mDoubleVariables, mArray1DVariables); + dof_data.UpdateMasterPair(this->GetPairedGeometry(), mpDoubleVariables, mpArray1DVariables); // Assemble of the matrix is required if ( ComputeLHS ) { @@ -375,7 +375,7 @@ void MeshTyingMortarCondition::Calcula this->InitializeDofData(TDim)>(dof_data); // Update slave element info - dof_data.UpdateMasterPair(this->GetPairedGeometry(), mDoubleVariables, mArray1DVariables); + dof_data.UpdateMasterPair(this->GetPairedGeometry(), mpDoubleVariables, mpArray1DVariables); // Assemble of the matrix is required if ( ComputeLHS ) { @@ -401,8 +401,8 @@ bool MeshTyingMortarCondition::Calculat const array_1d& rNormalMaster, MatrixDualLM& rAe, GeneralVariables& rVariables, - ConditionArrayListType& rConditionsPointsSlave, - IntegrationMethod ThisIntegrationMethod + const ConditionArrayListType& rConditionsPointsSlave, + const IntegrationMethod ThisIntegrationMethod ) { // We initilize the Ae components @@ -470,7 +470,7 @@ void MeshTyingMortarCondition::Calculat const array_1d& rNormalMaster, const PointType& rLocalPointDecomp, const PointType& rLocalPointParent, - GeometryPointType& rGeometryDecomp, + const GeometryPointType& rGeometryDecomp, const bool DualLM ) { @@ -6186,20 +6186,19 @@ void MeshTyingMortarCondition<3,8, 4>::CalculateLocalRHS void MeshTyingMortarCondition::EquationIdVector( EquationIdVectorType& rResult, - ProcessInfo& rCurrentProcessInfo - ) + const ProcessInfo& rCurrentProcessInfo + ) const { KRATOS_TRY; // Compute the matrix size - const TensorValue tensor_value = (mDoubleVariables.size() == 1) ? ScalarValue : static_cast(TDim); + const TensorValue tensor_value = (mpDoubleVariables.size() == 1) ? ScalarValue : static_cast(TDim); const SizeType matrix_size = tensor_value * (2 * NumNodes + NumNodesMaster); if (rResult.size() != matrix_size) { @@ -6210,55 +6209,56 @@ void MeshTyingMortarCondition::Equation /* ORDER - [ MASTER, SLAVE, LM ] */ // Master Nodes DoF Equation IDs - GeometryType& r_current_master = this->GetPairedGeometry(); + const GeometryType& r_current_master = this->GetPairedGeometry(); if (tensor_value == ScalarValue) { for ( IndexType i_master = 0; i_master < NumNodesMaster; ++i_master ) { - rResult[index++] = r_current_master[i_master].GetDof( mDoubleVariables[0] ).EquationId( ); + rResult[index++] = r_current_master[i_master].GetDof( *mpDoubleVariables[0] ).EquationId( ); } } else { - const std::string& variable_name = (mArray1DVariables[0]).Name(); - const Array1DComponentsType& var_x = KratosComponents::Get(variable_name+"_X"); - const Array1DComponentsType& var_y = KratosComponents::Get(variable_name+"_Y"); - const Array1DComponentsType& var_z = KratosComponents::Get(variable_name+"_Z"); + const std::string& r_variable_name = (*mpArray1DVariables[0]).Name(); + const Array1DComponentsType& r_var_x = KratosComponents::Get(r_variable_name+"_X"); + const Array1DComponentsType& r_var_y = KratosComponents::Get(r_variable_name+"_Y"); + const Array1DComponentsType& r_var_z = KratosComponents::Get(r_variable_name+"_Z"); for ( IndexType i_master = 0; i_master < NumNodesMaster; ++i_master ) { - NodeType& r_master_node = r_current_master[i_master]; - rResult[index++] = r_master_node.GetDof( var_x ).EquationId( ); - rResult[index++] = r_master_node.GetDof( var_y ).EquationId( ); - if (TDim == 3) rResult[index++] = r_master_node.GetDof( var_z ).EquationId( ); + const NodeType& r_master_node = r_current_master[i_master]; + rResult[index++] = r_master_node.GetDof( r_var_x ).EquationId( ); + rResult[index++] = r_master_node.GetDof( r_var_y ).EquationId( ); + if (TDim == 3) rResult[index++] = r_master_node.GetDof( r_var_z ).EquationId( ); } } // Slave Nodes DoF Equation IDs + const GeometryType& r_current_slave = this->GetParentGeometry(); if (tensor_value == ScalarValue) { for ( IndexType i_slave = 0; i_slave < NumNodes; ++i_slave ) { - rResult[index++] = this->GetParentGeometry()[i_slave].GetDof( mDoubleVariables[0] ).EquationId( ); + rResult[index++] = r_current_slave[i_slave].GetDof( *mpDoubleVariables[0] ).EquationId( ); } } else { - const std::string& variable_name = (mArray1DVariables[0]).Name(); - const Array1DComponentsType& var_x = KratosComponents::Get(variable_name+"_X"); - const Array1DComponentsType& var_y = KratosComponents::Get(variable_name+"_Y"); - const Array1DComponentsType& var_z = KratosComponents::Get(variable_name+"_Z"); + const std::string& r_variable_name = (*mpArray1DVariables[0]).Name(); + const Array1DComponentsType& r_var_x = KratosComponents::Get(r_variable_name+"_X"); + const Array1DComponentsType& r_var_y = KratosComponents::Get(r_variable_name+"_Y"); + const Array1DComponentsType& r_var_z = KratosComponents::Get(r_variable_name+"_Z"); for ( IndexType i_slave = 0; i_slave < NumNodes; ++i_slave ) { - NodeType& slave_node = this->GetParentGeometry()[i_slave]; - rResult[index++] = slave_node.GetDof( var_x ).EquationId( ); - rResult[index++] = slave_node.GetDof( var_y ).EquationId( ); - if (TDim == 3) rResult[index++] = slave_node.GetDof( var_z ).EquationId( ); + const NodeType& r_slave_node = r_current_slave[i_slave]; + rResult[index++] = r_slave_node.GetDof( r_var_x ).EquationId( ); + rResult[index++] = r_slave_node.GetDof( r_var_y ).EquationId( ); + if (TDim == 3) rResult[index++] = r_slave_node.GetDof( r_var_z ).EquationId( ); } } // Slave Nodes LM Equation IDs if (tensor_value == ScalarValue) { for ( IndexType i_slave = 0; i_slave < NumNodes; ++i_slave ) { - NodeType& slave_node = this->GetParentGeometry()[i_slave]; - rResult[index++] = slave_node.GetDof( SCALAR_LAGRANGE_MULTIPLIER ).EquationId( ); + const NodeType& r_slave_node = r_current_slave[i_slave]; + rResult[index++] = r_slave_node.GetDof( SCALAR_LAGRANGE_MULTIPLIER ).EquationId( ); } } else { for ( IndexType i_slave = 0; i_slave < NumNodes; ++i_slave ) { - NodeType& slave_node = this->GetParentGeometry()[i_slave]; - rResult[index++] = slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_X ).EquationId( ); - rResult[index++] = slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_Y ).EquationId( ); - if (TDim == 3) rResult[index++] = slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_Z ).EquationId( ); + const NodeType& r_slave_node = r_current_slave[i_slave]; + rResult[index++] = r_slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_X ).EquationId( ); + rResult[index++] = r_slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_Y ).EquationId( ); + if (TDim == 3) rResult[index++] = r_slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_Z ).EquationId( ); } } @@ -6271,12 +6271,12 @@ void MeshTyingMortarCondition::Equation template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> void MeshTyingMortarCondition::GetDofList( DofsVectorType& rConditionalDofList, - ProcessInfo& rCurrentProcessInfo - ) + const ProcessInfo& rCurrentProcessInfo + ) const { KRATOS_TRY; - const TensorValue tensor_value = (mDoubleVariables.size() == 1) ? ScalarValue : static_cast(TDim); + const TensorValue tensor_value = (mpDoubleVariables.size() == 1) ? ScalarValue : static_cast(TDim); const SizeType matrix_size = tensor_value * (2 * NumNodes + NumNodesMaster); if (rConditionalDofList.size() != matrix_size) { @@ -6287,101 +6287,62 @@ void MeshTyingMortarCondition::GetDofL /* ORDER - [ MASTER, SLAVE, LM ] */ // Master Nodes DoF Equation IDs - GeometryType& current_master = this->GetPairedGeometry(); + const GeometryType& r_current_master = this->GetPairedGeometry(); if (tensor_value == ScalarValue) { for ( IndexType i_master = 0; i_master < NumNodesMaster; ++i_master ) { - rConditionalDofList[index++] = current_master[i_master].pGetDof( mDoubleVariables[0] ); + rConditionalDofList[index++] = r_current_master[i_master].pGetDof( *mpDoubleVariables[0] ); } } else { - const std::string& variable_name = (mArray1DVariables[0]).Name(); - const Array1DComponentsType& var_x = KratosComponents< Array1DComponentsType>::Get(variable_name+"_X"); - const Array1DComponentsType& var_y = KratosComponents< Array1DComponentsType>::Get(variable_name+"_Y"); - const Array1DComponentsType& var_z = KratosComponents< Array1DComponentsType>::Get(variable_name+"_Z"); + const std::string& r_variable_name = (*mpArray1DVariables[0]).Name(); + const Array1DComponentsType& r_var_x = KratosComponents< Array1DComponentsType>::Get(r_variable_name+"_X"); + const Array1DComponentsType& r_var_y = KratosComponents< Array1DComponentsType>::Get(r_variable_name+"_Y"); + const Array1DComponentsType& r_var_z = KratosComponents< Array1DComponentsType>::Get(r_variable_name+"_Z"); for ( IndexType i_master = 0; i_master < NumNodesMaster; ++i_master ) { - NodeType& master_node = current_master[i_master]; - rConditionalDofList[index++] = master_node.pGetDof( var_x ); - rConditionalDofList[index++] = master_node.pGetDof( var_y ); - if (TDim == 3) rConditionalDofList[index++] = master_node.pGetDof( var_z ); + const NodeType& r_master_node = r_current_master[i_master]; + rConditionalDofList[index++] = r_master_node.pGetDof( r_var_x ); + rConditionalDofList[index++] = r_master_node.pGetDof( r_var_y ); + if (TDim == 3) rConditionalDofList[index++] = r_master_node.pGetDof( r_var_z ); } } // Slave Nodes DoF Equation IDs + const GeometryType& r_current_slave = this->GetParentGeometry(); if (tensor_value == ScalarValue) { for ( IndexType i_slave = 0; i_slave < NumNodes; ++i_slave ) { - rConditionalDofList[index++] = this->GetParentGeometry()[i_slave].pGetDof( mDoubleVariables[0] ); + rConditionalDofList[index++] = r_current_slave[i_slave].pGetDof( *mpDoubleVariables[0] ); } } else { - const std::string& variable_name = (mArray1DVariables[0]).Name(); - const Array1DComponentsType& var_x = KratosComponents< Array1DComponentsType>::Get(variable_name+"_X"); - const Array1DComponentsType& var_y = KratosComponents< Array1DComponentsType>::Get(variable_name+"_Y"); - const Array1DComponentsType& var_z = KratosComponents< Array1DComponentsType>::Get(variable_name+"_Z"); + const std::string& r_variable_name = (*mpArray1DVariables[0]).Name(); + const Array1DComponentsType& r_var_x = KratosComponents< Array1DComponentsType>::Get(r_variable_name+"_X"); + const Array1DComponentsType& r_var_y = KratosComponents< Array1DComponentsType>::Get(r_variable_name+"_Y"); + const Array1DComponentsType& r_var_z = KratosComponents< Array1DComponentsType>::Get(r_variable_name+"_Z"); for ( IndexType i_slave = 0; i_slave < NumNodes; ++i_slave ) { - NodeType& slave_node = this->GetParentGeometry()[i_slave]; - rConditionalDofList[index++] = slave_node.pGetDof( var_x ); - rConditionalDofList[index++] = slave_node.pGetDof( var_y ); - if (TDim == 3) rConditionalDofList[index++] = slave_node.pGetDof( var_z ); + const NodeType& r_slave_node = r_current_slave[i_slave]; + rConditionalDofList[index++] = r_slave_node.pGetDof( r_var_x ); + rConditionalDofList[index++] = r_slave_node.pGetDof( r_var_y ); + if (TDim == 3) rConditionalDofList[index++] = r_slave_node.pGetDof( r_var_z ); } } // Slave Nodes LM Equation IDs if (tensor_value == ScalarValue) { for ( IndexType i_slave = 0; i_slave < NumNodes; ++i_slave ) { - NodeType& slave_node = this->GetParentGeometry()[i_slave]; - rConditionalDofList[index++] = slave_node.pGetDof( SCALAR_LAGRANGE_MULTIPLIER ); + const NodeType& r_slave_node = r_current_slave[i_slave]; + rConditionalDofList[index++] = r_slave_node.pGetDof( SCALAR_LAGRANGE_MULTIPLIER ); } } else { for ( IndexType i_slave = 0; i_slave < NumNodes; ++i_slave ) { - NodeType& slave_node = this->GetParentGeometry()[i_slave]; - rConditionalDofList[index++] = slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_X ); - rConditionalDofList[index++] = slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_Y ); - if (TDim == 3) rConditionalDofList[index++] = slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_Z ); + const NodeType& r_slave_node = r_current_slave[i_slave]; + rConditionalDofList[index++] = r_slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_X ); + rConditionalDofList[index++] = r_slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_Y ); + if (TDim == 3) rConditionalDofList[index++] = r_slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_Z ); } } 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 ); -} - /***********************************************************************************/ /***********************************************************************************/ @@ -6461,7 +6422,7 @@ void MeshTyingMortarCondition::Calculat /***********************************************************************************/ template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> -int MeshTyingMortarCondition::Check( const ProcessInfo& rCurrentProcessInfo ) +int MeshTyingMortarCondition::Check(const ProcessInfo& rCurrentProcessInfo) const { KRATOS_TRY diff --git a/applications/ContactStructuralMechanicsApplication/custom_conditions/mesh_tying_mortar_condition.h b/applications/ContactStructuralMechanicsApplication/custom_conditions/mesh_tying_mortar_condition.h index 5258c34d1a46..69fbcafc1937 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; @@ -189,38 +189,38 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MeshTyingMortarCondit /** * Called at the beginning of each solution step */ - void Initialize() override; + void Initialize(const ProcessInfo& rCurrentProcessInfo) override; /** * Called at the beginning of each solution step * @param rCurrentProcessInfo The current process info instance */ - void InitializeSolutionStep(ProcessInfo& rCurrentProcessInfo) override; + void InitializeSolutionStep(const ProcessInfo& rCurrentProcessInfo) override; /** * Called at the beginning of each iteration * @param rCurrentProcessInfo The current process info instance */ - void InitializeNonLinearIteration(ProcessInfo& rCurrentProcessInfo) override; + void InitializeNonLinearIteration(const ProcessInfo& rCurrentProcessInfo) override; /** * Called at the ending of each solution step * @param rCurrentProcessInfo The current process info instance */ - void FinalizeSolutionStep(ProcessInfo& rCurrentProcessInfo) override; + void FinalizeSolutionStep(const ProcessInfo& rCurrentProcessInfo) override; /** * Called at the end of each iteration * @param rCurrentProcessInfo The current process info instance */ - void FinalizeNonLinearIteration(ProcessInfo& rCurrentProcessInfo) override; + void FinalizeNonLinearIteration(const ProcessInfo& rCurrentProcessInfo) override; /** * Initialize Mass Matrix */ void CalculateMassMatrix( MatrixType& rMassMatrix, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) override; /** @@ -228,7 +228,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MeshTyingMortarCondit */ void CalculateDampingMatrix( MatrixType& rDampingMatrix, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) override; /** @@ -283,8 +283,8 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MeshTyingMortarCondit */ void EquationIdVector( EquationIdVectorType& rResult, - ProcessInfo& rCurrentProcessInfo - ) override; + const ProcessInfo& rCurrentProcessInfo + ) const override; /** * Sets on ConditionalDofList the degrees of freedom of the considered element geometry @@ -293,35 +293,8 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MeshTyingMortarCondit */ void GetDofList( DofsVectorType& rConditionalDofList, - ProcessInfo& rCurrentProcessInfo - ) 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; + ) const override; /** * Calculate a double Variable @@ -355,7 +328,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MeshTyingMortarCondit * @details It is designed to be called only once (or anyway, not often) typically at the beginning of the calculations, so to verify that nothing is missing from the input or that no common error is found. * @param rCurrentProcessInfo The current process information */ - int Check( const ProcessInfo& rCurrentProcessInfo ) override; + int Check(const ProcessInfo& rCurrentProcessInfo) const override; ///@} ///@name Access @@ -440,18 +413,18 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MeshTyingMortarCondit */ void UpdateMasterPair( const GeometryType& rGeometryInput, - std::vector>& rDoubleVariables, - std::vector>>& rArray1DVariables + std::vector*>& rpDoubleVariables, + std::vector>*>& rpArray1DVariables ) { /* DoF */ if (TTensor == 1) { for (IndexType i_node = 0; i_node < NumNodesMaster; ++i_node) { - u2(i_node, 0) = rGeometryInput[i_node].FastGetSolutionStepValue(rDoubleVariables[0]); + u2(i_node, 0) = rGeometryInput[i_node].FastGetSolutionStepValue(*rpDoubleVariables[0]); } } else { for (IndexType i_node = 0; i_node < NumNodesMaster; ++i_node) { - const array_1d& value = rGeometryInput[i_node].FastGetSolutionStepValue(rArray1DVariables[0]); + const array_1d& value = rGeometryInput[i_node].FastGetSolutionStepValue(*rpArray1DVariables[0]); for (IndexType i_dof = 0; i_dof < TTensor; ++i_dof) { u2(i_node, i_dof) = value[i_dof]; } @@ -465,11 +438,11 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MeshTyingMortarCondit ///@name Protected member Variables ///@{ - MortarConditionMatrices mrThisMortarConditionMatrices; /// The mortar operators + MortarConditionMatrices mrThisMortarConditionMatrices; /// The mortar operators - std::vector> mDoubleVariables; /// The list of double variables + std::vector*> mpDoubleVariables; /// The list of double variables - std::vector>> mArray1DVariables; /// The list of components array1d + std::vector>*> mpArray1DVariables; /// The list of components array1d ///@} ///@name Protected Operators @@ -494,7 +467,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MeshTyingMortarCondit void CalculateLocalSystem( MatrixType& rLeftHandSideMatrix, VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) override; /** @@ -505,7 +478,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MeshTyingMortarCondit */ void CalculateRightHandSide( VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) override; /** @@ -516,7 +489,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MeshTyingMortarCondit */ void CalculateLeftHandSide( MatrixType& rLeftHandSideMatrix, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) override; /** @@ -541,14 +514,14 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MeshTyingMortarCondit if (TTensor == ScalarValue) { for (IndexType i_node = 0; i_node < NumNodes; i_node++) { - const double value = GetParentGeometry()[i_node].FastGetSolutionStepValue(mDoubleVariables[0]); + const double value = GetParentGeometry()[i_node].FastGetSolutionStepValue(*mpDoubleVariables[0]); const double lm = GetParentGeometry()[i_node].FastGetSolutionStepValue(SCALAR_LAGRANGE_MULTIPLIER); rDofData.u1(i_node, 0) = value; rDofData.LagrangeMultipliers(i_node, 0) = lm; } } else { for (IndexType i_node = 0; i_node < NumNodes; i_node++) { - const array_1d& value = GetParentGeometry()[i_node].FastGetSolutionStepValue(mArray1DVariables[0]); + const array_1d& value = GetParentGeometry()[i_node].FastGetSolutionStepValue(*mpArray1DVariables[0]); const array_1d& lm = GetParentGeometry()[i_node].FastGetSolutionStepValue(VECTOR_LAGRANGE_MULTIPLIER); for (IndexType i_dof = 0; i_dof < TDim; i_dof++) { rDofData.u1(i_node, i_dof) = value[i_dof]; @@ -565,8 +538,8 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MeshTyingMortarCondit const array_1d& rNormalMaster, MatrixDualLM& rAe, GeneralVariables& rVariables, - ConditionArrayListType& rConditionsPointsSlave, - IntegrationMethod ThisIntegrationMethod + const ConditionArrayListType& rConditionsPointsSlave, + const IntegrationMethod ThisIntegrationMethod ); /** @@ -578,7 +551,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MeshTyingMortarCondit const array_1d& rNormalMaster, const PointType& rLocalPointDecomp, const PointType& rLocalPointParent, - GeometryPointType& rGeometryDecomp, + const GeometryPointType& rGeometryDecomp, const bool DualLM = false ); diff --git a/applications/ContactStructuralMechanicsApplication/custom_conditions/mortar_contact_condition.cpp b/applications/ContactStructuralMechanicsApplication/custom_conditions/mortar_contact_condition.cpp index 79c468d087d5..235c59b6e5e7 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_conditions/mortar_contact_condition.cpp +++ b/applications/ContactStructuralMechanicsApplication/custom_conditions/mortar_contact_condition.cpp @@ -84,11 +84,11 @@ MortarContactCondition -void MortarContactCondition::Initialize( ) +void MortarContactCondition::Initialize(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; - BaseType::Initialize(); + BaseType::Initialize(rCurrentProcessInfo); // We reset the ISOLATED flag this->Set(ISOLATED, false); @@ -100,7 +100,7 @@ void MortarContactCondition -void MortarContactCondition::InitializeSolutionStep( ProcessInfo& rCurrentProcessInfo ) +void MortarContactCondition::InitializeSolutionStep(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -113,7 +113,7 @@ void MortarContactCondition -void MortarContactCondition::InitializeNonLinearIteration( ProcessInfo& rCurrentProcessInfo ) +void MortarContactCondition::InitializeNonLinearIteration(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -126,7 +126,7 @@ void MortarContactCondition -void MortarContactCondition::FinalizeSolutionStep( ProcessInfo& rCurrentProcessInfo ) +void MortarContactCondition::FinalizeSolutionStep(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -139,7 +139,7 @@ void MortarContactCondition -void MortarContactCondition::FinalizeNonLinearIteration( ProcessInfo& rCurrentProcessInfo ) +void MortarContactCondition::FinalizeNonLinearIteration(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -155,7 +155,7 @@ template< SizeType TDim, SizeType TNumNodes, FrictionalCase TFrictional, bool TN void MortarContactCondition::CalculateLocalSystem( MatrixType& rLeftHandSideMatrix, VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) { KRATOS_TRY; @@ -176,7 +176,7 @@ void MortarContactCondition void MortarContactCondition::CalculateLeftHandSide( MatrixType& rLeftHandSideMatrix, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) { // Resizing as needed @@ -195,7 +195,7 @@ void MortarContactCondition void MortarContactCondition::CalculateRightHandSide( VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) { // Creating an auxiliar matrix @@ -214,7 +214,7 @@ void MortarContactCondition void MortarContactCondition::CalculateMassMatrix( MatrixType& rMassMatrix, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) { KRATOS_TRY; @@ -230,7 +230,7 @@ void MortarContactCondition void MortarContactCondition::CalculateDampingMatrix( MatrixType& rDampingMatrix, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) { KRATOS_TRY; @@ -244,7 +244,7 @@ void MortarContactCondition -void MortarContactCondition::AddExplicitContribution(ProcessInfo& rCurrentProcessInfo) +void MortarContactCondition::AddExplicitContribution(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -261,7 +261,7 @@ template< SizeType TDim, SizeType TNumNodes, FrictionalCase TFrictional, bool TN void MortarContactCondition::AddExplicitContribution( const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable& rDestinationVariable, + const Variable& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) { @@ -276,7 +276,7 @@ template< SizeType TDim, SizeType TNumNodes, FrictionalCase TFrictional, bool TN void MortarContactCondition::AddExplicitContribution( const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable >& rDestinationVariable, + const Variable >& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) { @@ -559,8 +559,8 @@ void MortarContactCondition void MortarContactCondition::EquationIdVector( EquationIdVectorType& rResult, - ProcessInfo& CurrentProcessInfo - ) + const ProcessInfo& CurrentProcessInfo + ) const { KRATOS_ERROR << "You are calling to the base class method EquationIdVector, check your condition definition" << std::endl; } @@ -571,49 +571,10 @@ void MortarContactCondition void MortarContactCondition::GetDofList( DofsVectorType& rConditionalDofList, - ProcessInfo& rCurrentProcessInfo - ) -{ - KRATOS_ERROR << "You are calling to the base class method GetDofList, check your condition definition" << std::endl; -} - -//******************************* GET DOUBLE VALUE *********************************/ -/***********************************************************************************/ - -template< SizeType TDim, SizeType TNumNodes, FrictionalCase TFrictional, bool TNormalVariation, SizeType TNumNodesMaster> -void MortarContactCondition::GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, const ProcessInfo& rCurrentProcessInfo - ) + ) const { - 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 ); + KRATOS_ERROR << "You are calling to the base class method GetDofList, check your condition definition" << std::endl; } /***********************************************************************************/ @@ -689,7 +650,7 @@ void MortarContactCondition -int MortarContactCondition::Check( const ProcessInfo& rCurrentProcessInfo ) +int MortarContactCondition::Check(const ProcessInfo& rCurrentProcessInfo) const { KRATOS_TRY @@ -697,7 +658,8 @@ int MortarContactConditionGetParentGeometry().NumberOfGeometryParts() == 0) << "YOU HAVE NOT INITIALIZED THE PAIR GEOMETRY IN THE MeshTyingMortarCondition" << std::endl; + const GeometryType& r_current_slave = this->GetParentGeometry(); + KRATOS_ERROR_IF(r_current_slave.NumberOfGeometryParts() == 0) << "YOU HAVE NOT INITIALIZED THE PAIR GEOMETRY IN THE MortarContactCondition" << std::endl; // Check that all required variables have been registered KRATOS_CHECK_VARIABLE_KEY(DISPLACEMENT) @@ -705,15 +667,15 @@ int MortarContactCondition &rnode = this->GetParentGeometry()[i]; - KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(DISPLACEMENT,rnode) - KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(WEIGHTED_GAP,rnode) - KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(NORMAL,rnode) - - KRATOS_CHECK_DOF_IN_NODE(DISPLACEMENT_X, rnode) - KRATOS_CHECK_DOF_IN_NODE(DISPLACEMENT_Y, rnode) - KRATOS_CHECK_DOF_IN_NODE(DISPLACEMENT_Z, rnode) + for ( IndexType i = 0; i < TNumNodes; ++i ) { + const auto& r_node = r_current_slave[i]; + KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(DISPLACEMENT,r_node) + KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(WEIGHTED_GAP,r_node) + KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(NORMAL,r_node) + + KRATOS_CHECK_DOF_IN_NODE(DISPLACEMENT_X, r_node) + KRATOS_CHECK_DOF_IN_NODE(DISPLACEMENT_Y, r_node) + KRATOS_CHECK_DOF_IN_NODE(DISPLACEMENT_Z, r_node) } return ierr; diff --git a/applications/ContactStructuralMechanicsApplication/custom_conditions/mortar_contact_condition.h b/applications/ContactStructuralMechanicsApplication/custom_conditions/mortar_contact_condition.h index b1119b4b98a1..c6f85f568381 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_conditions/mortar_contact_condition.h +++ b/applications/ContactStructuralMechanicsApplication/custom_conditions/mortar_contact_condition.h @@ -201,32 +201,33 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MortarContactConditio /** * @brief Called at the beginning of each solution step + * @param rCurrentProcessInfo the current process info instance */ - void Initialize() override; + void Initialize(const ProcessInfo& rCurrentProcessInfo) override; /** * @brief Called at the beginning of each solution step * @param rCurrentProcessInfo the current process info instance */ - void InitializeSolutionStep(ProcessInfo& rCurrentProcessInfo) override; + void InitializeSolutionStep(const ProcessInfo& rCurrentProcessInfo) override; /** * @brief Called at the beginning of each iteration * @param rCurrentProcessInfo the current process info instance */ - void InitializeNonLinearIteration(ProcessInfo& rCurrentProcessInfo) override; + void InitializeNonLinearIteration(const ProcessInfo& rCurrentProcessInfo) override; /** * @brief Called at the ending of each solution step * @param rCurrentProcessInfo the current process info instance */ - void FinalizeSolutionStep(ProcessInfo& rCurrentProcessInfo) override; + void FinalizeSolutionStep(const ProcessInfo& rCurrentProcessInfo) override; /** * @brief Called at the end of each iteration * @param rCurrentProcessInfo the current process info instance */ - void FinalizeNonLinearIteration(ProcessInfo& rCurrentProcessInfo) override; + void FinalizeNonLinearIteration(const ProcessInfo& rCurrentProcessInfo) override; /** * @brief This method computes the mass matrix @@ -235,7 +236,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MortarContactConditio */ void CalculateMassMatrix( MatrixType& rMassMatrix, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) override; /** @@ -245,7 +246,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MortarContactConditio */ void CalculateDampingMatrix( MatrixType& rDampingMatrix, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) override; /** @@ -294,7 +295,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MortarContactConditio * @details NodalData is modified Inside the function, so the the "AddEXplicit" FUNCTIONS THE ONLY FUNCTIONS IN WHICH A CONDITION IS ALLOWED TO WRITE ON ITS NODES. The caller is expected to ensure thread safety hence SET/UNSETLOCK MUST BE PERFORMED IN THE STRATEGY BEFORE CALLING THIS FUNCTION * @param rCurrentProcessInfo the current process info instance */ - void AddExplicitContribution(ProcessInfo& rCurrentProcessInfo) override; + void AddExplicitContribution(const ProcessInfo& rCurrentProcessInfo) override; /** * @brief This function is designed to make the element to assemble an rRHS vector identified by a variable rRHSVariable by assembling it to the nodes on the variable rDestinationVariable (double version) @@ -307,7 +308,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MortarContactConditio void AddExplicitContribution( const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable& rDestinationVariable, + const Variable& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) override; @@ -322,7 +323,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MortarContactConditio */ void AddExplicitContribution(const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable >& rDestinationVariable, + const Variable >& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) override; @@ -337,8 +338,8 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MortarContactConditio */ void EquationIdVector( EquationIdVectorType& rResult, - ProcessInfo& rCurrentProcessInfo - ) override; + const ProcessInfo& rCurrentProcessInfo + ) const override; /** * @brief Sets on ConditionalDofList the degrees of freedom of the considered element geometry @@ -347,44 +348,8 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MortarContactConditio */ void GetDofList( DofsVectorType& rConditionalDofList, - ProcessInfo& rCurrentProcessInfo - ) 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; + ) const override; /** * @brief Calculate a double Variable @@ -429,7 +394,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MortarContactConditio * or that no common error is found. * @param rCurrentProcessInfo The current process information */ - int Check( const ProcessInfo& rCurrentProcessInfo ) override; + int Check(const ProcessInfo& rCurrentProcessInfo) const override; ///@} ///@name Access @@ -502,7 +467,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MortarContactConditio void CalculateLocalSystem( MatrixType& rLeftHandSideMatrix, VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) override; /** @@ -513,7 +478,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MortarContactConditio */ void CalculateRightHandSide( VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) override; /** @@ -524,7 +489,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MortarContactConditio */ void CalculateLeftHandSide( MatrixType& rLeftHandSideMatrix, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) override; /** diff --git a/applications/ContactStructuralMechanicsApplication/custom_conditions/mpc_mortar_contact_condition.cpp b/applications/ContactStructuralMechanicsApplication/custom_conditions/mpc_mortar_contact_condition.cpp index 3c7ba21ca149..b77b7eb5ebeb 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_conditions/mpc_mortar_contact_condition.cpp +++ b/applications/ContactStructuralMechanicsApplication/custom_conditions/mpc_mortar_contact_condition.cpp @@ -75,11 +75,11 @@ MPCMortarContactCondition::~MPCMortarContactCond /***********************************************************************************/ template< SizeType TDim, SizeType TNumNodes, SizeType TNumNodesMaster> -void MPCMortarContactCondition::Initialize( ) +void MPCMortarContactCondition::Initialize(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; - BaseType::Initialize(); + BaseType::Initialize(rCurrentProcessInfo); // We initailize the previous mortar operators if (this->Is(SLIP)) { @@ -122,7 +122,7 @@ void MPCMortarContactCondition::Initialize( ) /***********************************************************************************/ template< SizeType TDim, SizeType TNumNodes, SizeType TNumNodesMaster> -void MPCMortarContactCondition::InitializeSolutionStep( ProcessInfo& rCurrentProcessInfo ) +void MPCMortarContactCondition::InitializeSolutionStep(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -175,7 +175,7 @@ void MPCMortarContactCondition::InitializeSoluti /***********************************************************************************/ template< SizeType TDim, SizeType TNumNodes, SizeType TNumNodesMaster> -void MPCMortarContactCondition::InitializeNonLinearIteration(ProcessInfo& rCurrentProcessInfo) +void MPCMortarContactCondition::InitializeNonLinearIteration(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -220,7 +220,7 @@ void MPCMortarContactCondition::InitializeNonLin /***********************************************************************************/ template< SizeType TDim, SizeType TNumNodes, SizeType TNumNodesMaster> -void MPCMortarContactCondition::FinalizeSolutionStep( ProcessInfo& rCurrentProcessInfo ) +void MPCMortarContactCondition::FinalizeSolutionStep(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -238,7 +238,7 @@ void MPCMortarContactCondition::FinalizeSolution /***********************************************************************************/ template< SizeType TDim, SizeType TNumNodes, SizeType TNumNodesMaster> -void MPCMortarContactCondition::FinalizeNonLinearIteration( ProcessInfo& rCurrentProcessInfo ) +void MPCMortarContactCondition::FinalizeNonLinearIteration(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -253,8 +253,8 @@ void MPCMortarContactCondition::FinalizeNonLinea template< SizeType TDim, SizeType TNumNodes, SizeType TNumNodesMaster> void MPCMortarContactCondition::EquationIdVector( EquationIdVectorType& rResult, - ProcessInfo& rCurrentProcessInfo - ) + const ProcessInfo& rCurrentProcessInfo + ) const { KRATOS_TRY @@ -264,12 +264,12 @@ void MPCMortarContactCondition::EquationIdVector IndexType index = 0; /* ORDER - [ MASTER, SLAVE ] */ - GeometryType& r_slave_geometry = this->GetParentGeometry(); - GeometryType& r_master_geometry = this->GetPairedGeometry(); + const GeometryType& r_slave_geometry = this->GetParentGeometry(); + const GeometryType& r_master_geometry = this->GetPairedGeometry(); // Master Nodes Displacement Equation IDs for ( IndexType i_master = 0; i_master < TNumNodesMaster; ++i_master ) { // NOTE: Assuming same number of nodes for master and slave - NodeType& r_master_node = r_master_geometry[i_master]; + const NodeType& r_master_node = r_master_geometry[i_master]; rResult[index++] = r_master_node.GetDof( DISPLACEMENT_X ).EquationId( ); rResult[index++] = r_master_node.GetDof( DISPLACEMENT_Y ).EquationId( ); if (TDim == 3) rResult[index++] = r_master_node.GetDof( DISPLACEMENT_Z ).EquationId( ); @@ -277,7 +277,7 @@ void MPCMortarContactCondition::EquationIdVector // Slave Nodes Displacement Equation IDs for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) { - NodeType& r_slave_node = r_slave_geometry[ i_slave ]; + const NodeType& r_slave_node = r_slave_geometry[ i_slave ]; rResult[index++] = r_slave_node.GetDof( DISPLACEMENT_X ).EquationId( ); rResult[index++] = r_slave_node.GetDof( DISPLACEMENT_Y ).EquationId( ); if (TDim == 3) rResult[index++] = r_slave_node.GetDof( DISPLACEMENT_Z ).EquationId( ); @@ -292,8 +292,8 @@ void MPCMortarContactCondition::EquationIdVector template< SizeType TDim, SizeType TNumNodes, SizeType TNumNodesMaster> void MPCMortarContactCondition::GetDofList( DofsVectorType& rConditionalDofList, - ProcessInfo& rCurrentProcessInfo - ) + const ProcessInfo& rCurrentProcessInfo + ) const { KRATOS_TRY @@ -303,12 +303,12 @@ void MPCMortarContactCondition::GetDofList( IndexType index = 0; /* ORDER - [ MASTER, SLAVE ] */ - GeometryType& r_slave_geometry = this->GetParentGeometry(); - GeometryType& r_master_geometry = this->GetPairedGeometry(); + const GeometryType& r_slave_geometry = this->GetParentGeometry(); + const GeometryType& r_master_geometry = this->GetPairedGeometry(); // Master Nodes Displacement Equation IDs for ( IndexType i_master = 0; i_master < TNumNodesMaster; ++i_master ){ // NOTE: Assuming same number of nodes for master and slave - NodeType& r_master_node = r_master_geometry[i_master]; + const NodeType& r_master_node = r_master_geometry[i_master]; rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_X ); rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_Y ); if (TDim == 3) rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_Z ); @@ -316,7 +316,7 @@ void MPCMortarContactCondition::GetDofList( // Slave Nodes Displacement Equation IDs for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) { - NodeType& r_slave_node = r_slave_geometry[ i_slave ]; + const NodeType& r_slave_node = r_slave_geometry[ i_slave ]; rConditionalDofList[index++] = r_slave_node.pGetDof( DISPLACEMENT_X ); rConditionalDofList[index++] = r_slave_node.pGetDof( DISPLACEMENT_Y ); if (TDim == 3) rConditionalDofList[index++] = r_slave_node.pGetDof( DISPLACEMENT_Z ); @@ -333,7 +333,7 @@ template< SizeType TDim, SizeType TNumNodes, SizeType TNumNodesMaster> void MPCMortarContactCondition::CalculateLocalSystem( MatrixType& rLeftHandSideMatrix, VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) { KRATOS_TRY; @@ -350,12 +350,12 @@ void MPCMortarContactCondition::CalculateLocalSy template< SizeType TDim, SizeType TNumNodes, SizeType TNumNodesMaster> void MPCMortarContactCondition::CalculateLeftHandSide( MatrixType& rLeftHandSideMatrix, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) { // Resizing as needed the LHS if ( rLeftHandSideMatrix.size1() != MatrixSize || rLeftHandSideMatrix.size2() != MatrixSize ) - rLeftHandSideMatrix.resize( MatrixSize, MatrixSize, false ); + rLeftHandSideMatrix.resize( MatrixSize, MatrixSize, false ); noalias(rLeftHandSideMatrix) = ZeroMatrix( MatrixSize, MatrixSize ); } @@ -366,7 +366,7 @@ void MPCMortarContactCondition::CalculateLeftHan template< SizeType TDim, SizeType TNumNodes, SizeType TNumNodesMaster> void MPCMortarContactCondition::CalculateRightHandSide( VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) { // Resizing as needed the RHS @@ -414,7 +414,7 @@ void MPCMortarContactCondition::CalculateRightHa template< SizeType TDim, SizeType TNumNodes, SizeType TNumNodesMaster> void MPCMortarContactCondition::CalculateMassMatrix( MatrixType& rMassMatrix, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) { KRATOS_TRY; @@ -430,7 +430,7 @@ void MPCMortarContactCondition::CalculateMassMat template< SizeType TDim, SizeType TNumNodes, SizeType TNumNodesMaster> void MPCMortarContactCondition::CalculateDampingMatrix( MatrixType& rDampingMatrix, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) { KRATOS_TRY; @@ -444,7 +444,7 @@ void MPCMortarContactCondition::CalculateDamping /***********************************************************************************/ template< SizeType TDim, SizeType TNumNodes, SizeType TNumNodesMaster> -void MPCMortarContactCondition::AddExplicitContribution(ProcessInfo& rCurrentProcessInfo) +void MPCMortarContactCondition::AddExplicitContribution(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -466,7 +466,7 @@ template< SizeType TDim, SizeType TNumNodes, SizeType TNumNodesMaster> void MPCMortarContactCondition::ConstraintDofDatabaseUpdate( Matrix& rRelationMatrix, Vector& rConstantVector, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) { auto p_const = this->GetValue(CONSTRAINT_POINTER); @@ -594,7 +594,7 @@ void MPCMortarContactCondition::UpdateConstraint MortarConditionMatrices& rMortarConditionMatrices, Matrix& rRelationMatrix, Vector& rConstantVector, - ProcessInfo& rCurrentProcessInfo, + const ProcessInfo& rCurrentProcessInfo, const bool DualLM ) { @@ -720,7 +720,7 @@ void MPCMortarContactCondition::UpdateConstraint MortarConditionMatrices& rMortarConditionMatrices, Matrix& rRelationMatrix, Vector& rConstantVector, - ProcessInfo& rCurrentProcessInfo, + const ProcessInfo& rCurrentProcessInfo, const bool DualLM ) { @@ -839,7 +839,7 @@ void MPCMortarContactCondition::UpdateConstraint MortarConditionMatrices& rMortarConditionMatrices, Matrix& rRelationMatrix, Vector& rConstantVector, - ProcessInfo& rCurrentProcessInfo, + const ProcessInfo& rCurrentProcessInfo, const bool DualLM ) { @@ -941,51 +941,12 @@ void MPCMortarContactCondition::UpdateConstraint /***********************************************************************************/ template< SizeType TDim, SizeType TNumNodes, SizeType TNumNodesMaster> -void MPCMortarContactCondition::ComputePreviousMortarOperators( ProcessInfo& rCurrentProcessInfo) +void MPCMortarContactCondition::ComputePreviousMortarOperators(const ProcessInfo& rCurrentProcessInfo) { const IndexType integration_order = this->GetProperties().Has(INTEGRATION_ORDER_CONTACT) ? this->GetProperties().GetValue(INTEGRATION_ORDER_CONTACT) : 2; 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 ); -} - /***********************************************************************************/ /***********************************************************************************/ @@ -1059,7 +1020,7 @@ void MPCMortarContactCondition::CalculateOnInteg /***********************************************************************************/ template< SizeType TDim, SizeType TNumNodes, SizeType TNumNodesMaster> -int MPCMortarContactCondition::Check( const ProcessInfo& rCurrentProcessInfo ) +int MPCMortarContactCondition::Check(const ProcessInfo& rCurrentProcessInfo) const { KRATOS_TRY @@ -1067,7 +1028,7 @@ int MPCMortarContactCondition::Check( const Proc int ierr = Condition::Check(rCurrentProcessInfo); if(ierr != 0) return ierr; - KRATOS_ERROR_IF(this->GetParentGeometry().NumberOfGeometryParts() == 0) << "YOU HAVE NOT INITIALIZED THE PAIR GEOMETRY IN THE MeshTyingMortarCondition" << std::endl; + KRATOS_ERROR_IF(this->GetParentGeometry().NumberOfGeometryParts() == 0) << "YOU HAVE NOT INITIALIZED THE PAIR GEOMETRY IN THE MPCMortarContactCondition" << std::endl; // Check that all required variables have been registered KRATOS_CHECK_VARIABLE_KEY(DISPLACEMENT) @@ -1075,15 +1036,16 @@ int MPCMortarContactCondition::Check( const Proc KRATOS_CHECK_VARIABLE_KEY(NORMAL) // Check that the element's nodes contain all required SolutionStepData and Degrees of freedom - for ( IndexType i = 0; i < TNumNodes; i++ ) { - Node<3> &rnode = this->GetParentGeometry()[i]; - KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(DISPLACEMENT,rnode) - KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(WEIGHTED_GAP,rnode) - KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(NORMAL,rnode) - - KRATOS_CHECK_DOF_IN_NODE(DISPLACEMENT_X, rnode) - KRATOS_CHECK_DOF_IN_NODE(DISPLACEMENT_Y, rnode) - KRATOS_CHECK_DOF_IN_NODE(DISPLACEMENT_Z, rnode) + const GeometryType& r_current_slave = this->GetParentGeometry(); + for ( IndexType i = 0; i < TNumNodes; ++i ) { + const auto& r_node = r_current_slave[i]; + KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(DISPLACEMENT,r_node) + KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(WEIGHTED_GAP,r_node) + KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(NORMAL,r_node) + + KRATOS_CHECK_DOF_IN_NODE(DISPLACEMENT_X, r_node) + KRATOS_CHECK_DOF_IN_NODE(DISPLACEMENT_Y, r_node) + KRATOS_CHECK_DOF_IN_NODE(DISPLACEMENT_Z, r_node) } return ierr; diff --git a/applications/ContactStructuralMechanicsApplication/custom_conditions/mpc_mortar_contact_condition.h b/applications/ContactStructuralMechanicsApplication/custom_conditions/mpc_mortar_contact_condition.h index c30c5771fffb..66f93b914be5 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_conditions/mpc_mortar_contact_condition.h +++ b/applications/ContactStructuralMechanicsApplication/custom_conditions/mpc_mortar_contact_condition.h @@ -226,32 +226,33 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MPCMortarContactCondi /** * @brief Called at the beginning of each solution step + * @param rCurrentProcessInfo the current process info instance */ - void Initialize() override; + void Initialize(const ProcessInfo& rCurrentProcessInfo) override; /** * @brief Called at the beginning of each solution step * @param rCurrentProcessInfo the current process info instance */ - void InitializeSolutionStep(ProcessInfo& rCurrentProcessInfo) override; + void InitializeSolutionStep(const ProcessInfo& rCurrentProcessInfo) override; /** * @brief Called at the beginning of each iteration * @param rCurrentProcessInfo the current process info instance */ - void InitializeNonLinearIteration(ProcessInfo& rCurrentProcessInfo) override; + void InitializeNonLinearIteration(const ProcessInfo& rCurrentProcessInfo) override; /** * @brief Called at the ending of each solution step * @param rCurrentProcessInfo the current process info instance */ - void FinalizeSolutionStep(ProcessInfo& rCurrentProcessInfo) override; + void FinalizeSolutionStep(const ProcessInfo& rCurrentProcessInfo) override; /** * @brief Called at the end of each iteration * @param rCurrentProcessInfo the current process info instance */ - void FinalizeNonLinearIteration(ProcessInfo& rCurrentProcessInfo) override; + void FinalizeNonLinearIteration(const ProcessInfo& rCurrentProcessInfo) override; /** * @brief Sets on rResult the ID's of the element degrees of freedom @@ -260,8 +261,8 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MPCMortarContactCondi */ void EquationIdVector( EquationIdVectorType& rResult, - ProcessInfo& rCurrentProcessInfo - ) override; + const ProcessInfo& rCurrentProcessInfo + ) const override; /** * @brief Sets on ConditionalDofList the degrees of freedom of the considered element geometry @@ -270,8 +271,8 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MPCMortarContactCondi */ void GetDofList( DofsVectorType& rConditionalDofList, - ProcessInfo& rCurrentProcessInfo - ) override; + const ProcessInfo& rCurrentProcessInfo + ) const override; /** @@ -281,7 +282,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MPCMortarContactCondi */ void CalculateMassMatrix( MatrixType& rMassMatrix, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) override; /** @@ -291,7 +292,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MPCMortarContactCondi */ void CalculateDampingMatrix( MatrixType& rDampingMatrix, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) override; /** @@ -299,48 +300,12 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MPCMortarContactCondi * @details The "AddEXplicit" FUNCTIONS THE ONLY FUNCTIONS IN WHICH A CONDITION IS ALLOWED TO WRITE ON ITS NODES. The caller is expected to ensure thread safety hence SET/UNSETLOCK MUST BE PERFORMED IN THE STRATEGY BEFORE CALLING THIS FUNCTION * @param rCurrentProcessInfo the current process info instance */ - void AddExplicitContribution(ProcessInfo& rCurrentProcessInfo) override; + void AddExplicitContribution(const ProcessInfo& rCurrentProcessInfo) override; /******************************************************************/ /********** 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 @@ -384,7 +349,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MPCMortarContactCondi * or that no common error is found. * @param rCurrentProcessInfo The current process information */ - int Check( const ProcessInfo& rCurrentProcessInfo ) override; + int Check(const ProcessInfo& rCurrentProcessInfo) const override; ///@} ///@name Access @@ -461,7 +426,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MPCMortarContactCondi void CalculateLocalSystem( MatrixType& rLeftHandSideMatrix, VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) override; /** @@ -472,7 +437,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MPCMortarContactCondi */ void CalculateRightHandSide( VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) override; /** @@ -483,7 +448,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MPCMortarContactCondi */ void CalculateLeftHandSide( MatrixType& rLeftHandSideMatrix, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) override; /** @@ -541,7 +506,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MPCMortarContactCondi void ConstraintDofDatabaseUpdate( Matrix& rRelationMatrix, Vector& rConstantVector, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ); /** @@ -556,7 +521,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MPCMortarContactCondi MortarConditionMatrices& rMortarConditionMatrices, Matrix& rRelationMatrix, Vector& rConstantVector, - ProcessInfo& rCurrentProcessInfo, + const ProcessInfo& rCurrentProcessInfo, const bool DualLM = true ); @@ -572,7 +537,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MPCMortarContactCondi MortarConditionMatrices& rMortarConditionMatrices, Matrix& rRelationMatrix, Vector& rConstantVector, - ProcessInfo& rCurrentProcessInfo, + const ProcessInfo& rCurrentProcessInfo, const bool DualLM = true ); @@ -588,7 +553,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MPCMortarContactCondi MortarConditionMatrices& rMortarConditionMatrices, Matrix& rRelationMatrix, Vector& rConstantVector, - ProcessInfo& rCurrentProcessInfo, + const ProcessInfo& rCurrentProcessInfo, const bool DualLM = true ); @@ -596,7 +561,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MPCMortarContactCondi * @brief It computes the previous mortar operators * @param rCurrentProcessInfo The current process instance */ - void ComputePreviousMortarOperators(ProcessInfo& rCurrentProcessInfo); + void ComputePreviousMortarOperators(const ProcessInfo& rCurrentProcessInfo); ///@} ///@name Private Access diff --git a/applications/ContactStructuralMechanicsApplication/custom_conditions/paired_condition.cpp b/applications/ContactStructuralMechanicsApplication/custom_conditions/paired_condition.cpp index 64f142b41159..3552610f2d32 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_conditions/paired_condition.cpp +++ b/applications/ContactStructuralMechanicsApplication/custom_conditions/paired_condition.cpp @@ -64,11 +64,11 @@ PairedCondition::~PairedCondition( ) /***********************************************************************************/ /***********************************************************************************/ -void PairedCondition::Initialize( ) +void PairedCondition::Initialize(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; - BaseType::Initialize(); + BaseType::Initialize(rCurrentProcessInfo); // The normal of the paired condition const auto& r_paired_geometry = GetPairedGeometry(); @@ -82,7 +82,7 @@ void PairedCondition::Initialize( ) /***********************************************************************************/ /***********************************************************************************/ -void PairedCondition::InitializeSolutionStep(ProcessInfo& rCurrentProcessInfo) +void PairedCondition::InitializeSolutionStep(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -100,7 +100,7 @@ void PairedCondition::InitializeSolutionStep(ProcessInfo& rCurrentProcessInfo) /***********************************************************************************/ /***********************************************************************************/ -void PairedCondition::InitializeNonLinearIteration(ProcessInfo& rCurrentProcessInfo) +void PairedCondition::InitializeNonLinearIteration(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; diff --git a/applications/ContactStructuralMechanicsApplication/custom_conditions/paired_condition.h b/applications/ContactStructuralMechanicsApplication/custom_conditions/paired_condition.h index da43f12c28b1..07391356417e 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_conditions/paired_condition.h +++ b/applications/ContactStructuralMechanicsApplication/custom_conditions/paired_condition.h @@ -136,20 +136,21 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) PairedCondition /** * @brief Called at the beginning of each solution step + * @param rCurrentProcessInfo the current process info instance */ - void Initialize() override; + void Initialize(const ProcessInfo& rCurrentProcessInfo) override; /** * @brief Called at the beginning of each solution step * @param rCurrentProcessInfo the current process info instance */ - void InitializeSolutionStep(ProcessInfo& rCurrentProcessInfo) override; + void InitializeSolutionStep(const ProcessInfo& rCurrentProcessInfo) override; /** * @brief Called at the beginning of each iteration * @param rCurrentProcessInfo the current process info instance */ - void InitializeNonLinearIteration(ProcessInfo& rCurrentProcessInfo) override; + void InitializeNonLinearIteration(const ProcessInfo& rCurrentProcessInfo) override; /** * @brief Creates a new element pointer from an arry of nodes diff --git a/applications/ContactStructuralMechanicsApplication/custom_conditions/penalty_frictional_mortar_contact_condition.cpp b/applications/ContactStructuralMechanicsApplication/custom_conditions/penalty_frictional_mortar_contact_condition.cpp index 0ca4fe84b84a..6a6ae89e08ed 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_conditions/penalty_frictional_mortar_contact_condition.cpp +++ b/applications/ContactStructuralMechanicsApplication/custom_conditions/penalty_frictional_mortar_contact_condition.cpp @@ -69,11 +69,11 @@ PenaltyMethodFrictionalMortarContactCondition -void PenaltyMethodFrictionalMortarContactCondition::Initialize( ) +void PenaltyMethodFrictionalMortarContactCondition::Initialize(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; - BaseType::Initialize(); + BaseType::Initialize(rCurrentProcessInfo); // We initailize the previous mortar operators mPreviousMortarOperators.Initialize(); @@ -85,7 +85,7 @@ void PenaltyMethodFrictionalMortarContactCondition -void PenaltyMethodFrictionalMortarContactCondition::InitializeSolutionStep( ProcessInfo& rCurrentProcessInfo ) +void PenaltyMethodFrictionalMortarContactCondition::InitializeSolutionStep(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -104,7 +104,7 @@ void PenaltyMethodFrictionalMortarContactCondition -void PenaltyMethodFrictionalMortarContactCondition::FinalizeSolutionStep( ProcessInfo& rCurrentProcessInfo ) +void PenaltyMethodFrictionalMortarContactCondition::FinalizeSolutionStep(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -120,7 +120,7 @@ void PenaltyMethodFrictionalMortarContactCondition -void PenaltyMethodFrictionalMortarContactCondition::AddExplicitContribution(ProcessInfo& rCurrentProcessInfo) +void PenaltyMethodFrictionalMortarContactCondition::AddExplicitContribution(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -136,7 +136,7 @@ template< SizeType TDim, SizeType TNumNodes, bool TNormalVariation, SizeType TNu void PenaltyMethodFrictionalMortarContactCondition::AddExplicitContribution( const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable& rDestinationVariable, + const Variable& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) { @@ -154,7 +154,7 @@ template< SizeType TDim, SizeType TNumNodes, bool TNormalVariation, SizeType TNu void PenaltyMethodFrictionalMortarContactCondition::AddExplicitContribution( const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable>& rDestinationVariable, + const Variable>& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) { @@ -200,7 +200,7 @@ void PenaltyMethodFrictionalMortarContactCondition -void PenaltyMethodFrictionalMortarContactCondition::ComputePreviousMortarOperators( ProcessInfo& rCurrentProcessInfo) +void PenaltyMethodFrictionalMortarContactCondition::ComputePreviousMortarOperators(const ProcessInfo& rCurrentProcessInfo) { const IndexType integration_order = this->GetProperties().Has(INTEGRATION_ORDER_CONTACT) ? this->GetProperties().GetValue(INTEGRATION_ORDER_CONTACT) : 2; MortarExplicitContributionUtilities::ComputePreviousMortarOperators(this, rCurrentProcessInfo, mPreviousMortarOperators, integration_order, false); @@ -209,10 +209,6 @@ void PenaltyMethodFrictionalMortarContactCondition void PenaltyMethodFrictionalMortarContactCondition<2,2, false, 2>::CalculateLocalLHS( Matrix& rLocalLHS, @@ -90293,10 +90289,6 @@ void PenaltyMethodFrictionalMortarContactCondition<3,4, true, 3>::CalculateLocal /***************************** BEGIN AD REPLACEMENT ********************************/ /***********************************************************************************/ - -/***********************************************************************************/ -/***********************************************************************************/ - template<> void PenaltyMethodFrictionalMortarContactCondition<2,2, false, 2>::CalculateLocalRHS( Vector& rLocalRHS, @@ -96824,15 +96816,14 @@ void PenaltyMethodFrictionalMortarContactCondition<3,4, true, 3>::CalculateLocal } } - /****************************** END AD REPLACEMENT *********************************/ /***********************************************************************************/ template< std::size_t TDim, std::size_t TNumNodes, bool TNormalVariation, std::size_t TNumNodesMaster> void PenaltyMethodFrictionalMortarContactCondition::EquationIdVector( EquationIdVectorType& rResult, - ProcessInfo& CurrentProcessInfo - ) + const ProcessInfo& CurrentProcessInfo + ) const { KRATOS_TRY; @@ -96842,12 +96833,12 @@ void PenaltyMethodFrictionalMortarContactConditionGetParentGeometry(); - GeometryType& r_master_geometry = this->GetPairedGeometry(); + const GeometryType& r_slave_geometry = this->GetParentGeometry(); + const GeometryType& r_master_geometry = this->GetPairedGeometry(); // Master Nodes Displacement Equation IDs for ( IndexType i_master = 0; i_master < TNumNodesMaster; ++i_master ) { // NOTE: Assuming same number of nodes for master and slave - NodeType& r_master_node = r_master_geometry[i_master]; + const NodeType& r_master_node = r_master_geometry[i_master]; rResult[index++] = r_master_node.GetDof( DISPLACEMENT_X ).EquationId( ); rResult[index++] = r_master_node.GetDof( DISPLACEMENT_Y ).EquationId( ); if (TDim == 3) rResult[index++] = r_master_node.GetDof( DISPLACEMENT_Z ).EquationId( ); @@ -96855,7 +96846,7 @@ void PenaltyMethodFrictionalMortarContactCondition void PenaltyMethodFrictionalMortarContactCondition::GetDofList( DofsVectorType& rConditionalDofList, - ProcessInfo& rCurrentProcessInfo -) + const ProcessInfo& rCurrentProcessInfo + ) const { KRATOS_TRY; @@ -96881,12 +96872,12 @@ void PenaltyMethodFrictionalMortarContactConditionGetParentGeometry(); - GeometryType& r_master_geometry = this->GetPairedGeometry(); + const GeometryType& r_slave_geometry = this->GetParentGeometry(); + const GeometryType& r_master_geometry = this->GetPairedGeometry(); // Master Nodes Displacement Equation IDs for ( IndexType i_master = 0; i_master < TNumNodesMaster; ++i_master ){ // NOTE: Assuming same number of nodes for master and slave - NodeType& r_master_node = r_master_geometry[i_master]; + const NodeType& r_master_node = r_master_geometry[i_master]; rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_X ); rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_Y ); if (TDim == 3) rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_Z ); @@ -96894,7 +96885,7 @@ void PenaltyMethodFrictionalMortarContactCondition -int PenaltyMethodFrictionalMortarContactCondition::Check( const ProcessInfo& rCurrentProcessInfo ) +int PenaltyMethodFrictionalMortarContactCondition::Check(const ProcessInfo& rCurrentProcessInfo) const { KRATOS_TRY @@ -96916,14 +96907,13 @@ int PenaltyMethodFrictionalMortarContactConditionGetParentGeometry(); + const GeometryType& r_slave_geometry = this->GetParentGeometry(); for ( IndexType i = 0; i < TNumNodes; ++i ) { - NodeType& r_node = r_slave_geometry[i]; - KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(NORMAL, r_node) + const NodeType& r_node = r_slave_geometry[i]; + KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(WEIGHTED_SLIP, r_node) } return ierr; diff --git a/applications/ContactStructuralMechanicsApplication/custom_conditions/penalty_frictional_mortar_contact_condition.h b/applications/ContactStructuralMechanicsApplication/custom_conditions/penalty_frictional_mortar_contact_condition.h index 3597cda00b7a..1c6701f74f85 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_conditions/penalty_frictional_mortar_contact_condition.h +++ b/applications/ContactStructuralMechanicsApplication/custom_conditions/penalty_frictional_mortar_contact_condition.h @@ -181,19 +181,19 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) PenaltyMethodFriction /** * @brief Called at the beginning of each solution step */ - void Initialize() override; + void Initialize(const ProcessInfo& rCurrentProcessInfo) override; /** * @brief Called at the begining of each solution step * @param rCurrentProcessInfo the current process info instance */ - void InitializeSolutionStep(ProcessInfo& rCurrentProcessInfo) override; + void InitializeSolutionStep(const ProcessInfo& rCurrentProcessInfo) override; /** * @brief Called at the ending of each solution step * @param rCurrentProcessInfo the current process info instance */ - void FinalizeSolutionStep(ProcessInfo& rCurrentProcessInfo) override; + void FinalizeSolutionStep(const ProcessInfo& rCurrentProcessInfo) override; /** * @brief Creates a new element pointer from an arry of nodes @@ -246,7 +246,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) PenaltyMethodFriction * SET/UNSETLOCK MUST BE PERFORMED IN THE STRATEGY BEFORE CALLING THIS FUNCTION * @param rCurrentProcessInfo the current process info instance */ - void AddExplicitContribution(ProcessInfo& rCurrentProcessInfo) override; + void AddExplicitContribution(const ProcessInfo& rCurrentProcessInfo) override; /** * @brief This function is designed to make the element to assemble an rRHS vector identified by a variable rRHSVariable by assembling it to the nodes on the variable rDestinationVariable (double version) @@ -260,7 +260,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) PenaltyMethodFriction void AddExplicitContribution( const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable& rDestinationVariable, + const Variable& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) override; @@ -275,7 +275,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) PenaltyMethodFriction */ void AddExplicitContribution(const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable >& rDestinationVariable, + const Variable >& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) override; @@ -290,8 +290,8 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) PenaltyMethodFriction */ void EquationIdVector( EquationIdVectorType& rResult, - ProcessInfo& rCurrentProcessInfo - ) override; + const ProcessInfo& rCurrentProcessInfo + ) const override; /** * @brief Sets on ConditionalDofList the degrees of freedom of the considered element geometry @@ -300,8 +300,8 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) PenaltyMethodFriction */ void GetDofList( DofsVectorType& rConditionalDofList, - ProcessInfo& rCurrentProcessInfo - ) override; + const ProcessInfo& rCurrentProcessInfo + ) const override; /** * @brief This function provides the place to perform checks on the completeness of the input. @@ -310,7 +310,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) PenaltyMethodFriction * or that no common error is found. * @param rCurrentProcessInfo The current process information */ - int Check( const ProcessInfo& rCurrentProcessInfo ) override; + int Check(const ProcessInfo& rCurrentProcessInfo) const override; ///@} ///@name Access @@ -486,7 +486,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) PenaltyMethodFriction * @brief It computes the previous mortar operators * @param rCurrentProcessInfo The current process information */ - void ComputePreviousMortarOperators( ProcessInfo& rCurrentProcessInfo); + void ComputePreviousMortarOperators(const ProcessInfo& rCurrentProcessInfo); /** * @brief It calculates the matrix containing the tangent vector of the r_gt (for frictional contact) diff --git a/applications/ContactStructuralMechanicsApplication/custom_conditions/penalty_frictionless_mortar_contact_condition.cpp b/applications/ContactStructuralMechanicsApplication/custom_conditions/penalty_frictionless_mortar_contact_condition.cpp index ff72c46c5684..a8d560b7ef21 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_conditions/penalty_frictionless_mortar_contact_condition.cpp +++ b/applications/ContactStructuralMechanicsApplication/custom_conditions/penalty_frictionless_mortar_contact_condition.cpp @@ -68,7 +68,7 @@ PenaltyMethodFrictionlessMortarContactCondition -void PenaltyMethodFrictionlessMortarContactCondition::AddExplicitContribution(ProcessInfo& rCurrentProcessInfo) +void PenaltyMethodFrictionlessMortarContactCondition::AddExplicitContribution(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -85,7 +85,7 @@ template< SizeType TDim, SizeType TNumNodes, bool TNormalVariation, SizeType TNu void PenaltyMethodFrictionlessMortarContactCondition::AddExplicitContribution( const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable& rDestinationVariable, + const Variable& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) { @@ -103,7 +103,7 @@ template< SizeType TDim, SizeType TNumNodes, bool TNormalVariation, SizeType TNu void PenaltyMethodFrictionlessMortarContactCondition::AddExplicitContribution( const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable>& rDestinationVariable, + const Variable>& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) { @@ -28118,8 +28118,8 @@ void PenaltyMethodFrictionlessMortarContactCondition<3, 4, true, 3>::CalculateLo template< SizeType TDim, SizeType TNumNodes, bool TNormalVariation, SizeType TNumNodesMaster > void PenaltyMethodFrictionlessMortarContactCondition::EquationIdVector( EquationIdVectorType& rResult, - ProcessInfo& CurrentProcessInfo - ) + const ProcessInfo& CurrentProcessInfo + ) const { KRATOS_TRY; @@ -28129,12 +28129,12 @@ void PenaltyMethodFrictionlessMortarContactConditionGetParentGeometry(); - GeometryType& r_master_geometry = this->GetPairedGeometry(); + const GeometryType& r_slave_geometry = this->GetParentGeometry(); + const GeometryType& r_master_geometry = this->GetPairedGeometry(); // Master Nodes Displacement Equation IDs for ( IndexType i_master = 0; i_master < TNumNodesMaster; ++i_master ) { // NOTE: Assuming same number of nodes for master and slave - NodeType& r_master_node = r_master_geometry[i_master]; + const NodeType& r_master_node = r_master_geometry[i_master]; rResult[index++] = r_master_node.GetDof( DISPLACEMENT_X ).EquationId( ); rResult[index++] = r_master_node.GetDof( DISPLACEMENT_Y ).EquationId( ); if (TDim == 3) rResult[index++] = r_master_node.GetDof( DISPLACEMENT_Z ).EquationId( ); @@ -28142,7 +28142,7 @@ void PenaltyMethodFrictionlessMortarContactCondition void PenaltyMethodFrictionlessMortarContactCondition::GetDofList( DofsVectorType& rConditionalDofList, - ProcessInfo& rCurrentProcessInfo - ) + const ProcessInfo& rCurrentProcessInfo + ) const { KRATOS_TRY; @@ -28168,12 +28168,12 @@ void PenaltyMethodFrictionlessMortarContactConditionGetParentGeometry(); - GeometryType& r_master_geometry = this->GetPairedGeometry(); + const GeometryType& r_slave_geometry = this->GetParentGeometry(); + const GeometryType& r_master_geometry = this->GetPairedGeometry(); // Master Nodes Displacement Equation IDs for ( IndexType i_master = 0; i_master < TNumNodesMaster; ++i_master ) { // NOTE: Assuming same number of nodes for master and slave - NodeType& r_master_node = r_master_geometry[i_master]; + const NodeType& r_master_node = r_master_geometry[i_master]; rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_X ); rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_Y ); if (TDim == 3) rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_Z ); @@ -28181,7 +28181,7 @@ void PenaltyMethodFrictionlessMortarContactCondition -int PenaltyMethodFrictionlessMortarContactCondition::Check( const ProcessInfo& rCurrentProcessInfo ) +int PenaltyMethodFrictionlessMortarContactCondition::Check(const ProcessInfo& rCurrentProcessInfo) const { KRATOS_TRY // Base class checks for positive Jacobian and Id > 0 - int ierr = BaseType::Check(rCurrentProcessInfo); - if(ierr != 0) return ierr; - - // Check that all required variables have been registered - KRATOS_CHECK_VARIABLE_KEY(NORMAL) - - // Check that the element's nodes contain all required SolutionStepData and Degrees of freedom - GeometryType& r_slave_geometry = this->GetParentGeometry(); - for ( IndexType i = 0; i < TNumNodes; ++i ) { - NodeType& r_node = r_slave_geometry[i]; - KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(NORMAL,r_node) - } + const int ierr = BaseType::Check(rCurrentProcessInfo); return ierr; diff --git a/applications/ContactStructuralMechanicsApplication/custom_conditions/penalty_frictionless_mortar_contact_condition.h b/applications/ContactStructuralMechanicsApplication/custom_conditions/penalty_frictionless_mortar_contact_condition.h index c2ecebdecd0f..3d66e06b0ffa 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_conditions/penalty_frictionless_mortar_contact_condition.h +++ b/applications/ContactStructuralMechanicsApplication/custom_conditions/penalty_frictionless_mortar_contact_condition.h @@ -231,7 +231,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) PenaltyMethodFriction * SET/UNSETLOCK MUST BE PERFORMED IN THE STRATEGY BEFORE CALLING THIS FUNCTION * @param rCurrentProcessInfo the current process info instance */ - void AddExplicitContribution(ProcessInfo& rCurrentProcessInfo) override; + void AddExplicitContribution(const ProcessInfo& rCurrentProcessInfo) override; /** * @brief This function is designed to make the element to assemble an rRHS vector identified by a variable rRHSVariable by assembling it to the nodes on the variable rDestinationVariable (double version) @@ -245,7 +245,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) PenaltyMethodFriction void AddExplicitContribution( const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable& rDestinationVariable, + const Variable& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) override; @@ -260,7 +260,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) PenaltyMethodFriction */ void AddExplicitContribution(const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable >& rDestinationVariable, + const Variable >& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) override; @@ -275,8 +275,8 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) PenaltyMethodFriction */ void EquationIdVector( EquationIdVectorType& rResult, - ProcessInfo& rCurrentProcessInfo - ) override; + const ProcessInfo& rCurrentProcessInfo + ) const override; /** * @brief Sets on ConditionalDofList the degrees of freedom of the considered element geometry @@ -285,8 +285,8 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) PenaltyMethodFriction */ void GetDofList( DofsVectorType& rConditionalDofList, - ProcessInfo& rCurrentProcessInfo - ) override; + const ProcessInfo& rCurrentProcessInfo + ) const override; /** * @brief This function provides the place to perform checks on the completeness of the input. @@ -295,7 +295,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) PenaltyMethodFriction * or that no common error is found. * @param rCurrentProcessInfo The current process information */ - int Check( const ProcessInfo& rCurrentProcessInfo ) override; + int Check(const ProcessInfo& rCurrentProcessInfo) const override; ///@} ///@name Access diff --git a/applications/ContactStructuralMechanicsApplication/custom_processes/base_contact_search_process.cpp b/applications/ContactStructuralMechanicsApplication/custom_processes/base_contact_search_process.cpp index 1a54977eadbb..bc7ab39f06d8 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_processes/base_contact_search_process.cpp +++ b/applications/ContactStructuralMechanicsApplication/custom_processes/base_contact_search_process.cpp @@ -815,7 +815,7 @@ Condition::Pointer BaseContactSearchProcess::A p_auxiliar_condition->SetValue(NORMAL, rSlaveNormal); // We activate the condition and initialize it p_auxiliar_condition->Set(ACTIVE, true); - p_auxiliar_condition->Initialize(); + p_auxiliar_condition->Initialize(rComputingModelPart.GetProcessInfo()); return p_auxiliar_condition; } 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_processes/mpc_contact_search_process.cpp b/applications/ContactStructuralMechanicsApplication/custom_processes/mpc_contact_search_process.cpp index a0796d9b4505..7e22e158e55d 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_processes/mpc_contact_search_process.cpp +++ b/applications/ContactStructuralMechanicsApplication/custom_processes/mpc_contact_search_process.cpp @@ -135,12 +135,13 @@ Condition::Pointer MPCContactSearchProcess::Ad if (p_cond.get() != nullptr) { MasterSlaveConstraint::Pointer p_new_const = Kratos::make_shared(GetMaximumConstraintsIds() + 1); p_new_const->Set(ACTIVE); - p_new_const->Initialize(rComputingModelPart.GetProcessInfo()); + const auto& r_process_info = rComputingModelPart.GetProcessInfo(); + p_new_const->Initialize(r_process_info); rComputingModelPart.AddMasterSlaveConstraint(p_new_const); p_cond->SetValue(CONSTRAINT_POINTER, p_new_const); if (is_frictional) p_cond->Set(SLIP); if (is_rigid) p_cond->Set(RIGID); - p_cond->Initialize(); + p_cond->Initialize(r_process_info); } return p_cond; 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]); diff --git a/applications/ContactStructuralMechanicsApplication/custom_utilities/contact_utilities.h b/applications/ContactStructuralMechanicsApplication/custom_utilities/contact_utilities.h index 7647c2a6b499..42dfdc728deb 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_utilities/contact_utilities.h +++ b/applications/ContactStructuralMechanicsApplication/custom_utilities/contact_utilities.h @@ -343,7 +343,7 @@ class ContactUtilities ConditionsArrayType& r_conditions_array = rModelPart.Conditions(); KRATOS_TRACE_IF("Empty model part", r_conditions_array.size() == 0) << "YOUR COMPUTING CONTACT MODEL PART IS EMPTY" << std::endl; const auto it_cond_begin = r_conditions_array.begin(); - ProcessInfo& r_process_info = rModelPart.GetProcessInfo(); + const ProcessInfo& r_process_info = rModelPart.GetProcessInfo(); #pragma omp parallel for for(int i = 0; i < static_cast(r_conditions_array.size()); ++i) { auto it_cond = it_cond_begin + i; diff --git a/applications/ContactStructuralMechanicsApplication/custom_utilities/mortar_explicit_contribution_utilities.cpp b/applications/ContactStructuralMechanicsApplication/custom_utilities/mortar_explicit_contribution_utilities.cpp index 4bde00db54c4..50b74ff8e6ec 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_utilities/mortar_explicit_contribution_utilities.cpp +++ b/applications/ContactStructuralMechanicsApplication/custom_utilities/mortar_explicit_contribution_utilities.cpp @@ -26,7 +26,7 @@ typename MortarExplicitContributionUtilities& rAreaVariable + const Variable& rAreaVariable ) { KRATOS_TRY @@ -172,7 +172,7 @@ typename MortarExplicitContributionUtilities& rAreaVariable, + const Variable& rAreaVariable, const bool ConsiderObjetiveFormulation ) { @@ -197,7 +197,7 @@ typename MortarExplicitContributionUtilitiesGetPairedGeometry(); + const GeometryType& r_master_geometry = pCondition->GetPairedGeometry(); // The normal of the master condition const array_1d& r_normal_master = pCondition->GetPairedNormal(); @@ -227,9 +227,10 @@ typename MortarExplicitContributionUtilities points_array (TDim); // The points are stored as local coordinates, we calculate the global coordinates of pCondition points + PointType global_point; for (IndexType i_geom = 0; i_geom < conditions_points_slave.size(); ++i_geom) { - PointType global_point; for (IndexType i_node = 0; i_node < TDim; ++i_node) { r_slave_geometry.GlobalCoordinates(global_point, conditions_points_slave[i_geom][i_node]); points_array(i_node) = Kratos::make_shared(PointType(global_point)); @@ -349,7 +350,7 @@ template< const SizeType TDim, const SizeType TNumNodes, const FrictionalCase TF void MortarExplicitContributionUtilities::ComputeNodalArea( PairedCondition* pCondition, const ProcessInfo& rCurrentProcessInfo, - Variable& rAreaVariable, + const Variable& rAreaVariable, const IndexType IntegrationOrder, const bool AxisymmetricCase ) @@ -371,7 +372,7 @@ bool MortarExplicitContributionUtilities& rAreaVariable + const Variable& rAreaVariable ) { // We "save" the mortar operator for the next step @@ -391,7 +392,7 @@ bool MortarExplicitContributionUtilitiesGetPairedGeometry(); + const GeometryType& r_master_geometry = pCondition->GetPairedGeometry(); // The normal of the master condition const array_1d& r_normal_master = pCondition->GetPairedNormal(); @@ -421,11 +422,12 @@ bool MortarExplicitContributionUtilities points_array (TDim); // The points are stored as local coordinates, we calculate the global coordinates of this points + array_1d belong_array; + PointType global_point; for (IndexType i_geom = 0; i_geom < conditions_points_slave.size(); ++i_geom) { - PointerVector points_array (TDim); // The points are stored as local coordinates, we calculate the global coordinates of this points - array_1d belong_array; for (IndexType i_node = 0; i_node < TDim; ++i_node) { - PointType global_point; r_slave_geometry.GlobalCoordinates(global_point, conditions_points_slave[i_geom][i_node]); points_array(i_node) = Kratos::make_shared(PointType(global_point)); belong_array[i_node] = conditions_points_slave[i_geom][i_node].GetBelong(); @@ -480,7 +482,7 @@ template< SizeType TDim, SizeType TNumNodes, FrictionalCase TFrictional, bool TN bool MortarExplicitContributionUtilities::ExplicitCalculateAe( const GeometryType& rSlaveGeometry, GeneralVariables& rVariables, - ConditionArrayListType& rConditionsPointsSlave, + const ConditionArrayListType& rConditionsPointsSlave, BoundedMatrix& rAe, const IntegrationMethod& rIntegrationMethod, const double AxiSymCoeff @@ -493,9 +495,10 @@ bool MortarExplicitContributionUtilities points_array (TDim); // The points are stored as local coordinates, we calculate the global coordinates of this points + PointType global_point; for (IndexType i_geom = 0; i_geom < rConditionsPointsSlave.size(); ++i_geom) { - std::vector points_array (TDim); // The points are stored as local coordinates, we calculate the global coordinates of this points - PointType global_point; for (IndexType i_node = 0; i_node < TDim; ++i_node) { rSlaveGeometry.GlobalCoordinates(global_point, rConditionsPointsSlave[i_geom][i_node]); points_array[i_node] = Kratos::make_shared( global_point ); @@ -534,13 +537,13 @@ bool MortarExplicitContributionUtilities void MortarExplicitContributionUtilities::ExplicitCalculateKinematics( - PairedCondition* pCondition, + const PairedCondition* pCondition, GeneralVariables& rVariables, const BoundedMatrix& rAe, const array_1d& rNormalMaster, const PointType& rLocalPointDecomp, const PointType& rLocalPointParent, - GeometryPointType& rGeometryDecomp, + const GeometryPointType& rGeometryDecomp, const bool DualLM ) { @@ -568,13 +571,13 @@ void MortarExplicitContributionUtilities void MortarExplicitContributionUtilities::CalculateKinematics( - PairedCondition* pCondition, + const PairedCondition* pCondition, GeneralVariables& rVariables, const DerivativeDataType& rDerivativeData, const array_1d& rNormalMaster, const PointType& rLocalPointDecomp, const PointType& rLocalPointParent, - GeometryPointType& rGeometryDecomp, + const GeometryPointType& rGeometryDecomp, const bool DualLM ) { @@ -602,14 +605,14 @@ void MortarExplicitContributionUtilities void MortarExplicitContributionUtilities::MasterShapeFunctionValue( - PairedCondition* pCondition, + const PairedCondition* pCondition, GeneralVariables& rVariables, const array_1d& rNormalMaster, const PointType& rLocalPoint ) { - GeometryType& r_slave_geometry = pCondition->GetParentGeometry(); - GeometryType& r_master_geometry = pCondition->GetPairedGeometry(); + const GeometryType& r_slave_geometry = pCondition->GetParentGeometry(); + const GeometryType& r_master_geometry = pCondition->GetPairedGeometry(); PointType projected_gp_global; const array_1d gp_normal = MortarUtilities::GaussPointUnitNormal(rVariables.NSlave, r_slave_geometry); @@ -635,7 +638,7 @@ void MortarExplicitContributionUtilities& rAreaVariable = NODAL_AREA + const Variable& rAreaVariable = NODAL_AREA ); /** * @brief This method computes the explicit contributions of the mortar contact conditions @@ -171,7 +171,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MortarExplicitContrib const bool AxisymmetricCase = false, const bool ComputeNodalArea = false, const bool ComputeDualLM = true, - Variable& rAreaVariable = NODAL_AREA, + const Variable& rAreaVariable = NODAL_AREA, const bool ConsiderObjetiveFormulation = false ); @@ -188,7 +188,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MortarExplicitContrib static bool ExplicitCalculateAe( const GeometryType& rSlaveGeometry, GeneralVariables& rVariables, - ConditionArrayListType& rConditionsPointsSlave, + const ConditionArrayListType& rConditionsPointsSlave, BoundedMatrix& rAe, const IntegrationMethod& rIntegrationMethod, const double AxiSymCoeff = 1.0 @@ -207,13 +207,13 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MortarExplicitContrib * @param DualLM If the dual LM is considered or not */ static void ExplicitCalculateKinematics( - PairedCondition* pCondition, + const PairedCondition* pCondition, GeneralVariables& rVariables, const BoundedMatrix& rAe, const array_1d& rNormalMaster, const PointType& rLocalPointDecomp, const PointType& rLocalPointParent, - GeometryPointType& rGeometryDecomp, + const GeometryPointType& rGeometryDecomp, const bool DualLM = true ); @@ -230,7 +230,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MortarExplicitContrib static void ComputeNodalArea( PairedCondition* pCondition, const ProcessInfo& rCurrentProcessInfo, - Variable& rAreaVariable = NODAL_AREA, + const Variable& rAreaVariable = NODAL_AREA, const IndexType IntegrationOrder = 2, const bool AxisymmetricCase = false ); @@ -256,7 +256,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MortarExplicitContrib const bool AxisymmetricCase = false, const bool ComputeNodalArea = false, const bool ComputeDualLM = true, - Variable& rAreaVariable = NODAL_AREA + const Variable& rAreaVariable = NODAL_AREA ); /** @@ -272,13 +272,13 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MortarExplicitContrib * @param DualLM If the dual LM is considered or not */ static void CalculateKinematics( - PairedCondition* pCondition, + const PairedCondition* pCondition, GeneralVariables& rVariables, const DerivativeDataType& rDerivativeData, const array_1d& rNormalMaster, const PointType& rLocalPointDecomp, const PointType& rLocalPointParent, - GeometryPointType& rGeometryDecomp, + const GeometryPointType& rGeometryDecomp, const bool DualLM = true ); @@ -290,7 +290,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MortarExplicitContrib * @param rLocalPoint The current local point */ static void MasterShapeFunctionValue( - PairedCondition* pCondition, + const PairedCondition* pCondition, GeneralVariables& rVariables, const array_1d& rNormalMaster, const PointType& rLocalPoint @@ -306,7 +306,7 @@ namespace AuxiliarOperationsUtilities * @param rNSlave The shape functions of the slave side */ double KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) GetAxisymmetricCoefficient( - PairedCondition* pCondition, + const PairedCondition* pCondition, const Vector& rNSlave ); @@ -317,7 +317,7 @@ namespace AuxiliarOperationsUtilities * @return Radius: The radius of axisymmetry */ double KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) CalculateRadius( - PairedCondition* pCondition, + const PairedCondition* pCondition, const Vector& rNSlave ); } 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 = {} diff --git a/applications/ContactStructuralMechanicsApplication/symbolic_generation/ALM_frictional_mortar_condition/ALM_frictional_mortar_contact_condition_template.cpp b/applications/ContactStructuralMechanicsApplication/symbolic_generation/ALM_frictional_mortar_condition/ALM_frictional_mortar_contact_condition_template.cpp index 3e59627852d7..3afad20dab10 100644 --- a/applications/ContactStructuralMechanicsApplication/symbolic_generation/ALM_frictional_mortar_condition/ALM_frictional_mortar_contact_condition_template.cpp +++ b/applications/ContactStructuralMechanicsApplication/symbolic_generation/ALM_frictional_mortar_condition/ALM_frictional_mortar_contact_condition_template.cpp @@ -69,11 +69,11 @@ AugmentedLagrangianMethodFrictionalMortarContactCondition -void AugmentedLagrangianMethodFrictionalMortarContactCondition::Initialize( ) +void AugmentedLagrangianMethodFrictionalMortarContactCondition::Initialize(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; - BaseType::Initialize(); + BaseType::Initialize(rCurrentProcessInfo); // We initailize the previous mortar operators mPreviousMortarOperators.Initialize(); @@ -86,7 +86,7 @@ void AugmentedLagrangianMethodFrictionalMortarContactCondition -void AugmentedLagrangianMethodFrictionalMortarContactCondition::InitializeSolutionStep( ProcessInfo& rCurrentProcessInfo ) +void AugmentedLagrangianMethodFrictionalMortarContactCondition::InitializeSolutionStep(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -105,7 +105,7 @@ void AugmentedLagrangianMethodFrictionalMortarContactCondition -void AugmentedLagrangianMethodFrictionalMortarContactCondition::FinalizeSolutionStep( ProcessInfo& rCurrentProcessInfo ) +void AugmentedLagrangianMethodFrictionalMortarContactCondition::FinalizeSolutionStep(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -121,7 +121,7 @@ void AugmentedLagrangianMethodFrictionalMortarContactCondition -void AugmentedLagrangianMethodFrictionalMortarContactCondition::AddExplicitContribution(ProcessInfo& rCurrentProcessInfo) +void AugmentedLagrangianMethodFrictionalMortarContactCondition::AddExplicitContribution(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -135,7 +135,7 @@ void AugmentedLagrangianMethodFrictionalMortarContactCondition -void AugmentedLagrangianMethodFrictionalMortarContactCondition::ComputePreviousMortarOperators( ProcessInfo& rCurrentProcessInfo) +void AugmentedLagrangianMethodFrictionalMortarContactCondition::ComputePreviousMortarOperators(const ProcessInfo& rCurrentProcessInfo) { const IndexType integration_order = this->GetProperties().Has(INTEGRATION_ORDER_CONTACT) ? this->GetProperties().GetValue(INTEGRATION_ORDER_CONTACT) : 2; MortarExplicitContributionUtilities::ComputePreviousMortarOperators(this, rCurrentProcessInfo, mPreviousMortarOperators, integration_order, false); @@ -160,8 +160,8 @@ void AugmentedLagrangianMethodFrictionalMortarContactCondition void AugmentedLagrangianMethodFrictionalMortarContactCondition::EquationIdVector( EquationIdVectorType& rResult, - ProcessInfo& CurrentProcessInfo - ) + const ProcessInfo& CurrentProcessInfo + ) const { KRATOS_TRY; @@ -171,30 +171,31 @@ void AugmentedLagrangianMethodFrictionalMortarContactConditionGetPairedGeometry();; + const GeometryType& r_current_master = this->GetPairedGeometry(); + const GeometryType& r_current_slave = this->GetParentGeometry(); // Master Nodes Displacement Equation IDs for ( IndexType i_master = 0; i_master < TNumNodesMaster; ++i_master ) { // NOTE: Assuming same number of nodes for master and slave - NodeType& master_node = current_master[i_master]; - rResult[index++] = master_node.GetDof( DISPLACEMENT_X ).EquationId( ); - rResult[index++] = master_node.GetDof( DISPLACEMENT_Y ).EquationId( ); - if (TDim == 3) rResult[index++] = master_node.GetDof( DISPLACEMENT_Z ).EquationId( ); + const NodeType& r_master_node = r_current_master[i_master]; + rResult[index++] = r_master_node.GetDof( DISPLACEMENT_X ).EquationId( ); + rResult[index++] = r_master_node.GetDof( DISPLACEMENT_Y ).EquationId( ); + if (TDim == 3) rResult[index++] = r_master_node.GetDof( DISPLACEMENT_Z ).EquationId( ); } // Slave Nodes Displacement Equation IDs for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) { - NodeType& slave_node = this->GetParentGeometry()[ i_slave ]; - rResult[index++] = slave_node.GetDof( DISPLACEMENT_X ).EquationId( ); - rResult[index++] = slave_node.GetDof( DISPLACEMENT_Y ).EquationId( ); - if (TDim == 3) rResult[index++] = slave_node.GetDof( DISPLACEMENT_Z ).EquationId( ); + const NodeType& r_slave_node = r_current_slave[ i_slave ]; + rResult[index++] = r_slave_node.GetDof( DISPLACEMENT_X ).EquationId( ); + rResult[index++] = r_slave_node.GetDof( DISPLACEMENT_Y ).EquationId( ); + if (TDim == 3) rResult[index++] = r_slave_node.GetDof( DISPLACEMENT_Z ).EquationId( ); } // Slave Nodes Lambda Equation IDs for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) { - NodeType& slave_node = this->GetParentGeometry()[ i_slave ]; - rResult[index++] = slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_X ).EquationId( ); - rResult[index++] = slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_Y ).EquationId( ); - if (TDim == 3) rResult[index++] = slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_Z ).EquationId( ); + const NodeType& r_slave_node = r_current_slave[ i_slave ]; + rResult[index++] = r_slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_X ).EquationId( ); + rResult[index++] = r_slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_Y ).EquationId( ); + if (TDim == 3) rResult[index++] = r_slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_Z ).EquationId( ); } KRATOS_CATCH( "" ); @@ -206,8 +207,8 @@ void AugmentedLagrangianMethodFrictionalMortarContactCondition void AugmentedLagrangianMethodFrictionalMortarContactCondition::GetDofList( DofsVectorType& rConditionalDofList, - ProcessInfo& rCurrentProcessInfo -) + const ProcessInfo& rCurrentProcessInfo + ) const { KRATOS_TRY; @@ -217,30 +218,31 @@ void AugmentedLagrangianMethodFrictionalMortarContactConditionGetPairedGeometry();; + const GeometryType& r_current_master = this->GetPairedGeometry(); + const GeometryType& r_current_slave = this->GetParentGeometry(); // Master Nodes Displacement Equation IDs - for ( IndexType i_master = 0; i_master < TNumNodesMaster; ++i_master ){ // NOTE: Assuming same number of nodes for master and slave - NodeType& master_node = current_master[i_master]; - rConditionalDofList[index++] = master_node.pGetDof( DISPLACEMENT_X ); - rConditionalDofList[index++] = master_node.pGetDof( DISPLACEMENT_Y ); - if (TDim == 3) rConditionalDofList[index++] = master_node.pGetDof( DISPLACEMENT_Z ); + for ( IndexType i_master = 0; i_master < TNumNodesMaster; ++i_master ) { // NOTE: Assuming same number of nodes for master and slave + const NodeType& r_master_node = r_current_master[i_master]; + rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_X ); + rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_Y ); + if (TDim == 3) rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_Z ); } // Slave Nodes Displacement Equation IDs for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) { - NodeType& slave_node = this->GetParentGeometry()[ i_slave ]; - rConditionalDofList[index++] = slave_node.pGetDof( DISPLACEMENT_X ); - rConditionalDofList[index++] = slave_node.pGetDof( DISPLACEMENT_Y ); - if (TDim == 3) rConditionalDofList[index++] = slave_node.pGetDof( DISPLACEMENT_Z ); + const NodeType& r_slave_node = r_current_slave[ i_slave ]; + rConditionalDofList[index++] = r_slave_node.pGetDof( DISPLACEMENT_X ); + rConditionalDofList[index++] = r_slave_node.pGetDof( DISPLACEMENT_Y ); + if (TDim == 3) rConditionalDofList[index++] = r_slave_node.pGetDof( DISPLACEMENT_Z ); } // Slave Nodes Lambda Equation IDs for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) { - NodeType& slave_node = this->GetParentGeometry()[ i_slave ]; - rConditionalDofList[index++] = slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_X ); - rConditionalDofList[index++] = slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_Y ); - if (TDim == 3) rConditionalDofList[index++] = slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_Z ); + const NodeType& r_slave_node = r_current_slave[ i_slave ]; + rConditionalDofList[index++] = r_slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_X ); + rConditionalDofList[index++] = r_slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_Y ); + if (TDim == 3) rConditionalDofList[index++] = r_slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_Z ); } KRATOS_CATCH( "" ); @@ -250,7 +252,7 @@ void AugmentedLagrangianMethodFrictionalMortarContactCondition -int AugmentedLagrangianMethodFrictionalMortarContactCondition::Check( const ProcessInfo& rCurrentProcessInfo ) +int AugmentedLagrangianMethodFrictionalMortarContactCondition::Check(const ProcessInfo& rCurrentProcessInfo) const { KRATOS_TRY @@ -259,19 +261,19 @@ int AugmentedLagrangianMethodFrictionalMortarContactConditionGetParentGeometry(); for ( IndexType i = 0; i < TNumNodes; ++i ) { - Node<3> &rnode = this->GetParentGeometry()[i]; - KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(NORMAL,rnode) - KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(VECTOR_LAGRANGE_MULTIPLIER,rnode) + const NodeType &r_node = r_current_slave[i]; + KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(VECTOR_LAGRANGE_MULTIPLIER,r_node) + KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(WEIGHTED_SLIP,r_node) - KRATOS_CHECK_DOF_IN_NODE(VECTOR_LAGRANGE_MULTIPLIER_X, rnode) - KRATOS_CHECK_DOF_IN_NODE(VECTOR_LAGRANGE_MULTIPLIER_Y, rnode) - KRATOS_CHECK_DOF_IN_NODE(VECTOR_LAGRANGE_MULTIPLIER_Z, rnode) + KRATOS_CHECK_DOF_IN_NODE(VECTOR_LAGRANGE_MULTIPLIER_X, r_node) + KRATOS_CHECK_DOF_IN_NODE(VECTOR_LAGRANGE_MULTIPLIER_Y, r_node) + KRATOS_CHECK_DOF_IN_NODE(VECTOR_LAGRANGE_MULTIPLIER_Z, r_node) } return ierr; diff --git a/applications/ContactStructuralMechanicsApplication/symbolic_generation/ALM_frictionless_components_mortar_condition/ALM_frictionless_components_mortar_contact_condition_template.cpp b/applications/ContactStructuralMechanicsApplication/symbolic_generation/ALM_frictionless_components_mortar_condition/ALM_frictionless_components_mortar_contact_condition_template.cpp index 68726c186dee..9e8f27982663 100644 --- a/applications/ContactStructuralMechanicsApplication/symbolic_generation/ALM_frictionless_components_mortar_condition/ALM_frictionless_components_mortar_contact_condition_template.cpp +++ b/applications/ContactStructuralMechanicsApplication/symbolic_generation/ALM_frictionless_components_mortar_condition/ALM_frictionless_components_mortar_contact_condition_template.cpp @@ -40,7 +40,7 @@ Condition::Pointer AugmentedLagrangianMethodFrictionlessComponentsMortarContactC GeometryPointerType pGeom, PropertiesPointerType pProperties) const { - return Kratos::make_intrusive< AugmentedLagrangianMethodFrictionlessComponentsMortarContactCondition >( NewId, pGeom, pProperties ); + return Kratos::make_intrusive< AugmentedLagrangianMethodFrictionlessComponentsMortarContactCondition >( NewId, pGeom, pProperties ); } /***********************************************************************************/ @@ -53,7 +53,7 @@ Condition::Pointer AugmentedLagrangianMethodFrictionlessComponentsMortarContactC PropertiesType::Pointer pProperties, GeometryType::Pointer pMasterGeom) const { - return Kratos::make_intrusive< AugmentedLagrangianMethodFrictionlessComponentsMortarContactCondition >( NewId, pGeom, pProperties, pMasterGeom ); + return Kratos::make_intrusive< AugmentedLagrangianMethodFrictionlessComponentsMortarContactCondition >( NewId, pGeom, pProperties, pMasterGeom ); } /************************************* DESTRUCTOR **********************************/ @@ -82,8 +82,8 @@ AugmentedLagrangianMethodFrictionlessComponentsMortarContactCondition void AugmentedLagrangianMethodFrictionlessComponentsMortarContactCondition::EquationIdVector( EquationIdVectorType& rResult, - ProcessInfo& CurrentProcessInfo - ) + const ProcessInfo& CurrentProcessInfo + ) const { KRATOS_TRY; @@ -93,33 +93,31 @@ void AugmentedLagrangianMethodFrictionlessComponentsMortarContactConditionGetPairedGeometry();; + const GeometryType& r_current_master = this->GetPairedGeometry(); + const GeometryType& r_current_slave = this->GetParentGeometry(); // Master Nodes Displacement Equation IDs - for ( IndexType i_master = 0; i_master < TNumNodesMaster; i_master++ ) // NOTE: Assuming same number of nodes for master and slave - { - NodeType& master_node = current_master[i_master]; - rResult[index++] = master_node.GetDof( DISPLACEMENT_X ).EquationId( ); - rResult[index++] = master_node.GetDof( DISPLACEMENT_Y ).EquationId( ); - if (TDim == 3) rResult[index++] = master_node.GetDof( DISPLACEMENT_Z ).EquationId( ); + for ( IndexType i_master = 0; i_master < TNumNodesMaster; ++i_master ) { // NOTE: Assuming same number of nodes for master and slave + const NodeType& r_master_node = r_current_master[i_master]; + rResult[index++] = r_master_node.GetDof( DISPLACEMENT_X ).EquationId( ); + rResult[index++] = r_master_node.GetDof( DISPLACEMENT_Y ).EquationId( ); + if (TDim == 3) rResult[index++] = r_master_node.GetDof( DISPLACEMENT_Z ).EquationId( ); } // Slave Nodes Displacement Equation IDs - for ( IndexType i_slave = 0; i_slave < TNumNodes; i_slave++ ) - { - NodeType& slave_node = this->GetParentGeometry()[ i_slave ]; - rResult[index++] = slave_node.GetDof( DISPLACEMENT_X ).EquationId( ); - rResult[index++] = slave_node.GetDof( DISPLACEMENT_Y ).EquationId( ); - if (TDim == 3) rResult[index++] = slave_node.GetDof( DISPLACEMENT_Z ).EquationId( ); + for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) { + const NodeType& r_slave_node = r_current_slave[ i_slave ]; + rResult[index++] = r_slave_node.GetDof( DISPLACEMENT_X ).EquationId( ); + rResult[index++] = r_slave_node.GetDof( DISPLACEMENT_Y ).EquationId( ); + if (TDim == 3) rResult[index++] = r_slave_node.GetDof( DISPLACEMENT_Z ).EquationId( ); } // Slave Nodes Lambda Equation IDs - for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) - { - NodeType& slave_node = this->GetParentGeometry()[ i_slave ]; - rResult[index++] = slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_X ).EquationId( ); - rResult[index++] = slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_Y ).EquationId( ); - if (TDim == 3) rResult[index++] = slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_Z ).EquationId( ); + for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) { + const NodeType& r_slave_node = r_current_slave[ i_slave ]; + rResult[index++] = r_slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_X ).EquationId( ); + rResult[index++] = r_slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_Y ).EquationId( ); + if (TDim == 3) rResult[index++] = r_slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_Z ).EquationId( ); } KRATOS_CATCH( "" ); @@ -131,8 +129,8 @@ void AugmentedLagrangianMethodFrictionlessComponentsMortarContactCondition void AugmentedLagrangianMethodFrictionlessComponentsMortarContactCondition::GetDofList( DofsVectorType& rConditionalDofList, - ProcessInfo& rCurrentProcessInfo - ) + const ProcessInfo& rCurrentProcessInfo + ) const { KRATOS_TRY; @@ -142,33 +140,31 @@ void AugmentedLagrangianMethodFrictionlessComponentsMortarContactConditionGetPairedGeometry();; + const GeometryType& r_current_master = this->GetPairedGeometry(); + const GeometryType& r_current_slave = this->GetParentGeometry(); // Master Nodes Displacement Equation IDs - for ( IndexType i_master = 0; i_master < TNumNodesMaster; ++i_master ) // NOTE: Assuming same number of nodes for master and slave - { - NodeType& master_node = current_master[i_master]; - rConditionalDofList[index++] = master_node.pGetDof( DISPLACEMENT_X ); - rConditionalDofList[index++] = master_node.pGetDof( DISPLACEMENT_Y ); - if (TDim == 3) rConditionalDofList[index++] = master_node.pGetDof( DISPLACEMENT_Z ); + for ( IndexType i_master = 0; i_master < TNumNodesMaster; ++i_master ) { // NOTE: Assuming same number of nodes for master and slave + const NodeType& r_master_node = r_current_master[i_master]; + rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_X ); + rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_Y ); + if (TDim == 3) rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_Z ); } // Slave Nodes Displacement Equation IDs - for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) - { - NodeType& slave_node = this->GetParentGeometry()[ i_slave ]; - rConditionalDofList[index++] = slave_node.pGetDof( DISPLACEMENT_X ); - rConditionalDofList[index++] = slave_node.pGetDof( DISPLACEMENT_Y ); - if (TDim == 3) rConditionalDofList[index++] = slave_node.pGetDof( DISPLACEMENT_Z ); + for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) { + const NodeType& r_slave_node = r_current_slave[ i_slave ]; + rConditionalDofList[index++] = r_slave_node.pGetDof( DISPLACEMENT_X ); + rConditionalDofList[index++] = r_slave_node.pGetDof( DISPLACEMENT_Y ); + if (TDim == 3) rConditionalDofList[index++] = r_slave_node.pGetDof( DISPLACEMENT_Z ); } // Slave Nodes Lambda Equation IDs - for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) - { - NodeType& slave_node = this->GetParentGeometry()[ i_slave ]; - rConditionalDofList[index++] = slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_X ); - rConditionalDofList[index++] = slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_Y ); - if (TDim == 3) rConditionalDofList[index++] = slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_Z ); + for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) { + const NodeType& r_slave_node = r_current_slave[ i_slave ]; + rConditionalDofList[index++] = r_slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_X ); + rConditionalDofList[index++] = r_slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_Y ); + if (TDim == 3) rConditionalDofList[index++] = r_slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_Z ); } KRATOS_CATCH( "" ); @@ -178,7 +174,7 @@ void AugmentedLagrangianMethodFrictionlessComponentsMortarContactCondition -int AugmentedLagrangianMethodFrictionlessComponentsMortarContactCondition::Check( const ProcessInfo& rCurrentProcessInfo ) +int AugmentedLagrangianMethodFrictionlessComponentsMortarContactCondition::Check(const ProcessInfo& rCurrentProcessInfo) const { KRATOS_TRY @@ -190,14 +186,14 @@ int AugmentedLagrangianMethodFrictionlessComponentsMortarContactConditionGetParentGeometry()[i]; - KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(VECTOR_LAGRANGE_MULTIPLIER,rnode) - - KRATOS_CHECK_DOF_IN_NODE(VECTOR_LAGRANGE_MULTIPLIER_X, rnode) - KRATOS_CHECK_DOF_IN_NODE(VECTOR_LAGRANGE_MULTIPLIER_Y, rnode) - KRATOS_CHECK_DOF_IN_NODE(VECTOR_LAGRANGE_MULTIPLIER_Z, rnode) + const GeometryType& r_current_slave = this->GetParentGeometry(); + for ( IndexType i = 0; i < TNumNodes; ++i ) { + const NodeType &r_node = r_current_slave[i]; + KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(VECTOR_LAGRANGE_MULTIPLIER,r_node) + + KRATOS_CHECK_DOF_IN_NODE(VECTOR_LAGRANGE_MULTIPLIER_X, r_node) + KRATOS_CHECK_DOF_IN_NODE(VECTOR_LAGRANGE_MULTIPLIER_Y, r_node) + KRATOS_CHECK_DOF_IN_NODE(VECTOR_LAGRANGE_MULTIPLIER_Z, r_node) } return ierr; diff --git a/applications/ContactStructuralMechanicsApplication/symbolic_generation/ALM_frictionless_mortar_condition/ALM_frictionless_mortar_contact_condition_template.cpp b/applications/ContactStructuralMechanicsApplication/symbolic_generation/ALM_frictionless_mortar_condition/ALM_frictionless_mortar_contact_condition_template.cpp index 8a40eefab20d..792acceacd28 100644 --- a/applications/ContactStructuralMechanicsApplication/symbolic_generation/ALM_frictionless_mortar_condition/ALM_frictionless_mortar_contact_condition_template.cpp +++ b/applications/ContactStructuralMechanicsApplication/symbolic_generation/ALM_frictionless_mortar_condition/ALM_frictionless_mortar_contact_condition_template.cpp @@ -40,7 +40,7 @@ Condition::Pointer AugmentedLagrangianMethodFrictionlessMortarContactCondition >( NewId, pGeom, pProperties ); + return Kratos::make_intrusive< AugmentedLagrangianMethodFrictionlessMortarContactCondition >( NewId, pGeom, pProperties ); } /***********************************************************************************/ @@ -53,7 +53,7 @@ Condition::Pointer AugmentedLagrangianMethodFrictionlessMortarContactCondition >( NewId, pGeom, pProperties, pMasterGeom ); + return Kratos::make_intrusive< AugmentedLagrangianMethodFrictionlessMortarContactCondition >( NewId, pGeom, pProperties, pMasterGeom ); } /************************************* DESTRUCTOR **********************************/ @@ -82,8 +82,8 @@ AugmentedLagrangianMethodFrictionlessMortarContactCondition void AugmentedLagrangianMethodFrictionlessMortarContactCondition::EquationIdVector( EquationIdVectorType& rResult, - ProcessInfo& CurrentProcessInfo - ) + const ProcessInfo& CurrentProcessInfo + ) const { KRATOS_TRY; @@ -93,28 +93,29 @@ void AugmentedLagrangianMethodFrictionlessMortarContactConditionGetPairedGeometry();; + const GeometryType& r_current_master = this->GetPairedGeometry(); + const GeometryType& r_current_slave = this->GetParentGeometry(); // Master Nodes Displacement Equation IDs for ( IndexType i_master = 0; i_master < TNumNodesMaster; ++i_master ) { // NOTE: Assuming same number of nodes for master and slave - NodeType& master_node = current_master[i_master]; - rResult[index++] = master_node.GetDof( DISPLACEMENT_X ).EquationId( ); - rResult[index++] = master_node.GetDof( DISPLACEMENT_Y ).EquationId( ); - if (TDim == 3) rResult[index++] = master_node.GetDof( DISPLACEMENT_Z ).EquationId( ); + const NodeType& r_master_node = r_current_master[i_master]; + rResult[index++] = r_master_node.GetDof( DISPLACEMENT_X ).EquationId( ); + rResult[index++] = r_master_node.GetDof( DISPLACEMENT_Y ).EquationId( ); + if (TDim == 3) rResult[index++] = r_master_node.GetDof( DISPLACEMENT_Z ).EquationId( ); } // Slave Nodes Displacement Equation IDs for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) { - NodeType& slave_node = this->GetParentGeometry()[ i_slave ]; - rResult[index++] = slave_node.GetDof( DISPLACEMENT_X ).EquationId( ); - rResult[index++] = slave_node.GetDof( DISPLACEMENT_Y ).EquationId( ); - if (TDim == 3) rResult[index++] = slave_node.GetDof( DISPLACEMENT_Z ).EquationId( ); + const NodeType& r_slave_node = r_current_slave[ i_slave ]; + rResult[index++] = r_slave_node.GetDof( DISPLACEMENT_X ).EquationId( ); + rResult[index++] = r_slave_node.GetDof( DISPLACEMENT_Y ).EquationId( ); + if (TDim == 3) rResult[index++] = r_slave_node.GetDof( DISPLACEMENT_Z ).EquationId( ); } // Slave Nodes Lambda Equation IDs for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) { - NodeType& slave_node = this->GetParentGeometry()[ i_slave ]; - rResult[index++] = slave_node.GetDof( LAGRANGE_MULTIPLIER_CONTACT_PRESSURE ).EquationId( ); + const NodeType& r_slave_node = r_current_slave[ i_slave ]; + rResult[index++] = r_slave_node.GetDof( LAGRANGE_MULTIPLIER_CONTACT_PRESSURE ).EquationId( ); } KRATOS_CATCH( "" ); @@ -126,8 +127,8 @@ void AugmentedLagrangianMethodFrictionlessMortarContactCondition void AugmentedLagrangianMethodFrictionlessMortarContactCondition::GetDofList( DofsVectorType& rConditionalDofList, - ProcessInfo& rCurrentProcessInfo - ) + const ProcessInfo& rCurrentProcessInfo + ) const { KRATOS_TRY; @@ -137,28 +138,29 @@ void AugmentedLagrangianMethodFrictionlessMortarContactConditionGetPairedGeometry();; + const GeometryType& r_current_master = this->GetPairedGeometry(); + const GeometryType& r_current_slave = this->GetParentGeometry(); // Master Nodes Displacement Equation IDs for ( IndexType i_master = 0; i_master < TNumNodesMaster; ++i_master ) { // NOTE: Assuming same number of nodes for master and slave - NodeType& master_node = current_master[i_master]; - rConditionalDofList[index++] = master_node.pGetDof( DISPLACEMENT_X ); - rConditionalDofList[index++] = master_node.pGetDof( DISPLACEMENT_Y ); - if (TDim == 3) rConditionalDofList[index++] = master_node.pGetDof( DISPLACEMENT_Z ); + const NodeType& r_master_node = r_current_master[i_master]; + rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_X ); + rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_Y ); + if (TDim == 3) rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_Z ); } // Slave Nodes Displacement Equation IDs for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) { - NodeType& slave_node = this->GetParentGeometry()[ i_slave ]; - rConditionalDofList[index++] = slave_node.pGetDof( DISPLACEMENT_X ); - rConditionalDofList[index++] = slave_node.pGetDof( DISPLACEMENT_Y ); - if (TDim == 3) rConditionalDofList[index++] = slave_node.pGetDof( DISPLACEMENT_Z ); + const NodeType& r_slave_node = r_current_slave[ i_slave ]; + rConditionalDofList[index++] = r_slave_node.pGetDof( DISPLACEMENT_X ); + rConditionalDofList[index++] = r_slave_node.pGetDof( DISPLACEMENT_Y ); + if (TDim == 3) rConditionalDofList[index++] = r_slave_node.pGetDof( DISPLACEMENT_Z ); } // Slave Nodes Lambda Equation IDs for ( IndexType i_slave = 0; i_slave < TNumNodes; ++i_slave ) { - NodeType& slave_node = this->GetParentGeometry()[ i_slave ]; - rConditionalDofList[index++] = slave_node.pGetDof( LAGRANGE_MULTIPLIER_CONTACT_PRESSURE ); + const NodeType& r_slave_node = r_current_slave[ i_slave ]; + rConditionalDofList[index++] = r_slave_node.pGetDof( LAGRANGE_MULTIPLIER_CONTACT_PRESSURE ); } KRATOS_CATCH( "" ); @@ -168,7 +170,7 @@ void AugmentedLagrangianMethodFrictionlessMortarContactCondition -int AugmentedLagrangianMethodFrictionlessMortarContactCondition::Check( const ProcessInfo& rCurrentProcessInfo ) +int AugmentedLagrangianMethodFrictionlessMortarContactCondition::Check(const ProcessInfo& rCurrentProcessInfo) const { KRATOS_TRY @@ -177,16 +179,15 @@ int AugmentedLagrangianMethodFrictionlessMortarContactConditionGetParentGeometry(); for ( IndexType i = 0; i < TNumNodes; ++i ) { - Node<3> &rnode = this->GetParentGeometry()[i]; - KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(NORMAL,rnode) - KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(LAGRANGE_MULTIPLIER_CONTACT_PRESSURE,rnode) + const NodeType &r_node = r_current_slave[i]; + KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(LAGRANGE_MULTIPLIER_CONTACT_PRESSURE,r_node) - KRATOS_CHECK_DOF_IN_NODE(LAGRANGE_MULTIPLIER_CONTACT_PRESSURE, rnode) + KRATOS_CHECK_DOF_IN_NODE(LAGRANGE_MULTIPLIER_CONTACT_PRESSURE, r_node) } return ierr; diff --git a/applications/ContactStructuralMechanicsApplication/symbolic_generation/DALM_frictionless_mortar_condition/DALM_frictionless_mortar_contact_condition.h b/applications/ContactStructuralMechanicsApplication/symbolic_generation/DALM_frictionless_mortar_condition/DALM_frictionless_mortar_contact_condition.h index 9af5e1f9c4fb..769d1ead2649 100644 --- a/applications/ContactStructuralMechanicsApplication/symbolic_generation/DALM_frictionless_mortar_condition/DALM_frictionless_mortar_contact_condition.h +++ b/applications/ContactStructuralMechanicsApplication/symbolic_generation/DALM_frictionless_mortar_condition/DALM_frictionless_mortar_contact_condition.h @@ -237,7 +237,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) DoubleAugmentedLagran * or that no common error is found. * @param rCurrentProcessInfo The current process information */ - int Check( const ProcessInfo& rCurrentProcessInfo ) override; + int Check(const ProcessInfo& rCurrentProcessInfo) const override; ///@} ///@name Access diff --git a/applications/ContactStructuralMechanicsApplication/symbolic_generation/DALM_frictionless_mortar_condition/DALM_frictionless_mortar_contact_condition_template.cpp b/applications/ContactStructuralMechanicsApplication/symbolic_generation/DALM_frictionless_mortar_condition/DALM_frictionless_mortar_contact_condition_template.cpp index 1ddb28fd59a9..50be4658c697 100644 --- a/applications/ContactStructuralMechanicsApplication/symbolic_generation/DALM_frictionless_mortar_condition/DALM_frictionless_mortar_contact_condition_template.cpp +++ b/applications/ContactStructuralMechanicsApplication/symbolic_generation/DALM_frictionless_mortar_condition/DALM_frictionless_mortar_contact_condition_template.cpp @@ -234,7 +234,7 @@ void DoubleAugmentedLagrangianMethodFrictionlessMortarContactCondition -int DoubleAugmentedLagrangianMethodFrictionlessMortarContactCondition::Check( const ProcessInfo& rCurrentProcessInfo ) +int DoubleAugmentedLagrangianMethodFrictionlessMortarContactCondition::Check(const ProcessInfo& rCurrentProcessInfo) const { KRATOS_TRY 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 3d212ec9d9aa..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 @@ -69,18 +69,18 @@ MeshTyingMortarCondition::~MeshTyingMor /***********************************************************************************/ template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> -void MeshTyingMortarCondition::Initialize( ) +void MeshTyingMortarCondition::Initialize(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; - BaseType::Initialize(); + BaseType::Initialize(rCurrentProcessInfo); // We get the unkown variable - const std::string variable_name = GetProperties().Has(TYING_VARIABLE) ? GetProperties().GetValue(TYING_VARIABLE) : "DISPLACEMENT"; - if (KratosComponents>::Has(variable_name)) { - mDoubleVariables.push_back(KratosComponents>::Get(variable_name)); - } else if (KratosComponents>>::Has(variable_name)) { - mArray1DVariables.push_back(KratosComponents>>::Get(variable_name)); + const std::string r_variable_name = GetProperties().Has(TYING_VARIABLE) ? GetProperties().GetValue(TYING_VARIABLE) : "DISPLACEMENT"; + if (KratosComponents>::Has(r_variable_name)) { + mpDoubleVariables.push_back(&KratosComponents>::Get(r_variable_name)); + } else if (KratosComponents>>::Has(r_variable_name)) { + mpArray1DVariables.push_back(&KratosComponents>>::Get(r_variable_name)); } else { KRATOS_ERROR << "Compatible variables are: double or array_1d " << std::endl; } @@ -173,7 +173,7 @@ void MeshTyingMortarCondition::Initiali /***********************************************************************************/ template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> -void MeshTyingMortarCondition::InitializeSolutionStep( ProcessInfo& rCurrentProcessInfo ) +void MeshTyingMortarCondition::InitializeSolutionStep(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -186,7 +186,7 @@ void MeshTyingMortarCondition::Initiali /***********************************************************************************/ template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> -void MeshTyingMortarCondition::InitializeNonLinearIteration( ProcessInfo& rCurrentProcessInfo ) +void MeshTyingMortarCondition::InitializeNonLinearIteration(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -199,7 +199,7 @@ void MeshTyingMortarCondition::Initiali /***********************************************************************************/ template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> -void MeshTyingMortarCondition::FinalizeSolutionStep( ProcessInfo& rCurrentProcessInfo ) +void MeshTyingMortarCondition::FinalizeSolutionStep(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -212,7 +212,7 @@ void MeshTyingMortarCondition::Finalize /***********************************************************************************/ template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> -void MeshTyingMortarCondition::FinalizeNonLinearIteration( ProcessInfo& rCurrentProcessInfo ) +void MeshTyingMortarCondition::FinalizeNonLinearIteration(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -228,13 +228,13 @@ template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> void MeshTyingMortarCondition::CalculateLocalSystem( MatrixType& rLeftHandSideMatrix, VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) { KRATOS_TRY; // Compute the matrix size - const TensorValue tensor_value = (mDoubleVariables.size() == 1) ? ScalarValue : static_cast(TDim); + const TensorValue tensor_value = (mpDoubleVariables.size() == 1) ? ScalarValue : static_cast(TDim); const SizeType matrix_size = tensor_value * (2 * NumNodes + NumNodesMaster); // Resizing as needed the LHS @@ -257,11 +257,11 @@ void MeshTyingMortarCondition::Calculat template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> void MeshTyingMortarCondition::CalculateLeftHandSide( MatrixType& rLeftHandSideMatrix, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) { // Compute the matrix size - const TensorValue tensor_value = (mDoubleVariables.size() == 1) ? ScalarValue : static_cast(TDim); + const TensorValue tensor_value = (mpDoubleVariables.size() == 1) ? ScalarValue : static_cast(TDim); const SizeType matrix_size = tensor_value * (2 * NumNodes + NumNodesMaster); // Resizing as needed the LHS @@ -281,14 +281,14 @@ void MeshTyingMortarCondition::Calculat template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> void MeshTyingMortarCondition::CalculateRightHandSide( VectorType& rRightHandSideVector, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) { // Creating an auxiliar matrix MatrixType aux_left_hand_side_matrix = Matrix(); // Compute the matrix size - const TensorValue tensor_value = (mDoubleVariables.size() == 1) ? ScalarValue : static_cast(TDim); + const TensorValue tensor_value = (mpDoubleVariables.size() == 1) ? ScalarValue : static_cast(TDim); const SizeType matrix_size = tensor_value * (2 * NumNodes + NumNodesMaster); // Resizing as needed the RHS @@ -305,7 +305,7 @@ void MeshTyingMortarCondition::Calculat template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> void MeshTyingMortarCondition::CalculateMassMatrix( MatrixType& rMassMatrix, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) { KRATOS_TRY; @@ -321,7 +321,7 @@ void MeshTyingMortarCondition::Calculat template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> void MeshTyingMortarCondition::CalculateDampingMatrix( MatrixType& rDampingMatrix, - ProcessInfo& rCurrentProcessInfo + const ProcessInfo& rCurrentProcessInfo ) { KRATOS_TRY; @@ -346,7 +346,7 @@ void MeshTyingMortarCondition::Calcula KRATOS_TRY; // Create the current DoF data - const TensorValue tensor_value = (mDoubleVariables.size() == 1) ? ScalarValue : static_cast(TDim); + const TensorValue tensor_value = (mpDoubleVariables.size() == 1) ? ScalarValue : static_cast(TDim); if (tensor_value == ScalarValue) { DofData dof_data; @@ -355,7 +355,7 @@ void MeshTyingMortarCondition::Calcula this->InitializeDofData(dof_data); // Update slave element info - dof_data.UpdateMasterPair(this->GetPairedGeometry(), mDoubleVariables, mArray1DVariables); + dof_data.UpdateMasterPair(this->GetPairedGeometry(), mpDoubleVariables, mpArray1DVariables); // Assemble of the matrix is required if ( ComputeLHS ) { @@ -375,7 +375,7 @@ void MeshTyingMortarCondition::Calcula this->InitializeDofData(TDim)>(dof_data); // Update slave element info - dof_data.UpdateMasterPair(this->GetPairedGeometry(), mDoubleVariables, mArray1DVariables); + dof_data.UpdateMasterPair(this->GetPairedGeometry(), mpDoubleVariables, mpArray1DVariables); // Assemble of the matrix is required if ( ComputeLHS ) { @@ -401,8 +401,8 @@ bool MeshTyingMortarCondition::Calculat const array_1d& rNormalMaster, MatrixDualLM& rAe, GeneralVariables& rVariables, - ConditionArrayListType& rConditionsPointsSlave, - IntegrationMethod ThisIntegrationMethod + const ConditionArrayListType& rConditionsPointsSlave, + const IntegrationMethod ThisIntegrationMethod ) { // We initilize the Ae components @@ -470,7 +470,7 @@ void MeshTyingMortarCondition::Calculat const array_1d& rNormalMaster, const PointType& rLocalPointDecomp, const PointType& rLocalPointParent, - GeometryPointType& rGeometryDecomp, + const GeometryPointType& rGeometryDecomp, const bool DualLM ) { @@ -535,13 +535,13 @@ void MeshTyingMortarCondition::MasterSh template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> void MeshTyingMortarCondition::EquationIdVector( EquationIdVectorType& rResult, - ProcessInfo& rCurrentProcessInfo - ) + const ProcessInfo& rCurrentProcessInfo + ) const { KRATOS_TRY; // Compute the matrix size - const TensorValue tensor_value = (mDoubleVariables.size() == 1) ? ScalarValue : static_cast(TDim); + const TensorValue tensor_value = (mpDoubleVariables.size() == 1) ? ScalarValue : static_cast(TDim); const SizeType matrix_size = tensor_value * (2 * NumNodes + NumNodesMaster); if (rResult.size() != matrix_size) { @@ -552,55 +552,56 @@ void MeshTyingMortarCondition::Equation /* ORDER - [ MASTER, SLAVE, LM ] */ // Master Nodes DoF Equation IDs - GeometryType& r_current_master = this->GetPairedGeometry(); + const GeometryType& r_current_master = this->GetPairedGeometry(); if (tensor_value == ScalarValue) { for ( IndexType i_master = 0; i_master < NumNodesMaster; ++i_master ) { - rResult[index++] = r_current_master[i_master].GetDof( mDoubleVariables[0] ).EquationId( ); + rResult[index++] = r_current_master[i_master].GetDof( *mpDoubleVariables[0] ).EquationId( ); } } else { - const std::string& variable_name = (mArray1DVariables[0]).Name(); - const Array1DComponentsType& var_x = KratosComponents::Get(variable_name+"_X"); - const Array1DComponentsType& var_y = KratosComponents::Get(variable_name+"_Y"); - const Array1DComponentsType& var_z = KratosComponents::Get(variable_name+"_Z"); + const std::string& r_variable_name = (*mpArray1DVariables[0]).Name(); + const Array1DComponentsType& r_var_x = KratosComponents::Get(r_variable_name+"_X"); + const Array1DComponentsType& r_var_y = KratosComponents::Get(r_variable_name+"_Y"); + const Array1DComponentsType& r_var_z = KratosComponents::Get(r_variable_name+"_Z"); for ( IndexType i_master = 0; i_master < NumNodesMaster; ++i_master ) { - NodeType& r_master_node = r_current_master[i_master]; - rResult[index++] = r_master_node.GetDof( var_x ).EquationId( ); - rResult[index++] = r_master_node.GetDof( var_y ).EquationId( ); - if (TDim == 3) rResult[index++] = r_master_node.GetDof( var_z ).EquationId( ); + const NodeType& r_master_node = r_current_master[i_master]; + rResult[index++] = r_master_node.GetDof( r_var_x ).EquationId( ); + rResult[index++] = r_master_node.GetDof( r_var_y ).EquationId( ); + if (TDim == 3) rResult[index++] = r_master_node.GetDof( r_var_z ).EquationId( ); } } // Slave Nodes DoF Equation IDs + const GeometryType& r_current_slave = this->GetParentGeometry(); if (tensor_value == ScalarValue) { for ( IndexType i_slave = 0; i_slave < NumNodes; ++i_slave ) { - rResult[index++] = this->GetParentGeometry()[i_slave].GetDof( mDoubleVariables[0] ).EquationId( ); + rResult[index++] = r_current_slave[i_slave].GetDof( *mpDoubleVariables[0] ).EquationId( ); } } else { - const std::string& variable_name = (mArray1DVariables[0]).Name(); - const Array1DComponentsType& var_x = KratosComponents::Get(variable_name+"_X"); - const Array1DComponentsType& var_y = KratosComponents::Get(variable_name+"_Y"); - const Array1DComponentsType& var_z = KratosComponents::Get(variable_name+"_Z"); + const std::string& r_variable_name = (*mpArray1DVariables[0]).Name(); + const Array1DComponentsType& r_var_x = KratosComponents::Get(r_variable_name+"_X"); + const Array1DComponentsType& r_var_y = KratosComponents::Get(r_variable_name+"_Y"); + const Array1DComponentsType& r_var_z = KratosComponents::Get(r_variable_name+"_Z"); for ( IndexType i_slave = 0; i_slave < NumNodes; ++i_slave ) { - NodeType& slave_node = this->GetParentGeometry()[i_slave]; - rResult[index++] = slave_node.GetDof( var_x ).EquationId( ); - rResult[index++] = slave_node.GetDof( var_y ).EquationId( ); - if (TDim == 3) rResult[index++] = slave_node.GetDof( var_z ).EquationId( ); + const NodeType& r_slave_node = r_current_slave[i_slave]; + rResult[index++] = r_slave_node.GetDof( r_var_x ).EquationId( ); + rResult[index++] = r_slave_node.GetDof( r_var_y ).EquationId( ); + if (TDim == 3) rResult[index++] = r_slave_node.GetDof( r_var_z ).EquationId( ); } } // Slave Nodes LM Equation IDs if (tensor_value == ScalarValue) { for ( IndexType i_slave = 0; i_slave < NumNodes; ++i_slave ) { - NodeType& slave_node = this->GetParentGeometry()[i_slave]; - rResult[index++] = slave_node.GetDof( SCALAR_LAGRANGE_MULTIPLIER ).EquationId( ); + const NodeType& r_slave_node = r_current_slave[i_slave]; + rResult[index++] = r_slave_node.GetDof( SCALAR_LAGRANGE_MULTIPLIER ).EquationId( ); } } else { for ( IndexType i_slave = 0; i_slave < NumNodes; ++i_slave ) { - NodeType& slave_node = this->GetParentGeometry()[i_slave]; - rResult[index++] = slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_X ).EquationId( ); - rResult[index++] = slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_Y ).EquationId( ); - if (TDim == 3) rResult[index++] = slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_Z ).EquationId( ); + const NodeType& r_slave_node = r_current_slave[i_slave]; + rResult[index++] = r_slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_X ).EquationId( ); + rResult[index++] = r_slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_Y ).EquationId( ); + if (TDim == 3) rResult[index++] = r_slave_node.GetDof( VECTOR_LAGRANGE_MULTIPLIER_Z ).EquationId( ); } } @@ -613,12 +614,12 @@ void MeshTyingMortarCondition::Equation template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> void MeshTyingMortarCondition::GetDofList( DofsVectorType& rConditionalDofList, - ProcessInfo& rCurrentProcessInfo - ) + const ProcessInfo& rCurrentProcessInfo + ) const { KRATOS_TRY; - const TensorValue tensor_value = (mDoubleVariables.size() == 1) ? ScalarValue : static_cast(TDim); + const TensorValue tensor_value = (mpDoubleVariables.size() == 1) ? ScalarValue : static_cast(TDim); const SizeType matrix_size = tensor_value * (2 * NumNodes + NumNodesMaster); if (rConditionalDofList.size() != matrix_size) { @@ -629,101 +630,62 @@ void MeshTyingMortarCondition::GetDofL /* ORDER - [ MASTER, SLAVE, LM ] */ // Master Nodes DoF Equation IDs - GeometryType& current_master = this->GetPairedGeometry(); + const GeometryType& r_current_master = this->GetPairedGeometry(); if (tensor_value == ScalarValue) { for ( IndexType i_master = 0; i_master < NumNodesMaster; ++i_master ) { - rConditionalDofList[index++] = current_master[i_master].pGetDof( mDoubleVariables[0] ); + rConditionalDofList[index++] = r_current_master[i_master].pGetDof( *mpDoubleVariables[0] ); } } else { - const std::string& variable_name = (mArray1DVariables[0]).Name(); - const Array1DComponentsType& var_x = KratosComponents< Array1DComponentsType>::Get(variable_name+"_X"); - const Array1DComponentsType& var_y = KratosComponents< Array1DComponentsType>::Get(variable_name+"_Y"); - const Array1DComponentsType& var_z = KratosComponents< Array1DComponentsType>::Get(variable_name+"_Z"); + const std::string& r_variable_name = (*mpArray1DVariables[0]).Name(); + const Array1DComponentsType& r_var_x = KratosComponents< Array1DComponentsType>::Get(r_variable_name+"_X"); + const Array1DComponentsType& r_var_y = KratosComponents< Array1DComponentsType>::Get(r_variable_name+"_Y"); + const Array1DComponentsType& r_var_z = KratosComponents< Array1DComponentsType>::Get(r_variable_name+"_Z"); for ( IndexType i_master = 0; i_master < NumNodesMaster; ++i_master ) { - NodeType& master_node = current_master[i_master]; - rConditionalDofList[index++] = master_node.pGetDof( var_x ); - rConditionalDofList[index++] = master_node.pGetDof( var_y ); - if (TDim == 3) rConditionalDofList[index++] = master_node.pGetDof( var_z ); + const NodeType& r_master_node = r_current_master[i_master]; + rConditionalDofList[index++] = r_master_node.pGetDof( r_var_x ); + rConditionalDofList[index++] = r_master_node.pGetDof( r_var_y ); + if (TDim == 3) rConditionalDofList[index++] = r_master_node.pGetDof( r_var_z ); } } // Slave Nodes DoF Equation IDs + const GeometryType& r_current_slave = this->GetParentGeometry(); if (tensor_value == ScalarValue) { for ( IndexType i_slave = 0; i_slave < NumNodes; ++i_slave ) { - rConditionalDofList[index++] = this->GetParentGeometry()[i_slave].pGetDof( mDoubleVariables[0] ); + rConditionalDofList[index++] = r_current_slave[i_slave].pGetDof( *mpDoubleVariables[0] ); } } else { - const std::string& variable_name = (mArray1DVariables[0]).Name(); - const Array1DComponentsType& var_x = KratosComponents< Array1DComponentsType>::Get(variable_name+"_X"); - const Array1DComponentsType& var_y = KratosComponents< Array1DComponentsType>::Get(variable_name+"_Y"); - const Array1DComponentsType& var_z = KratosComponents< Array1DComponentsType>::Get(variable_name+"_Z"); + const std::string& r_variable_name = (*mpArray1DVariables[0]).Name(); + const Array1DComponentsType& r_var_x = KratosComponents< Array1DComponentsType>::Get(r_variable_name+"_X"); + const Array1DComponentsType& r_var_y = KratosComponents< Array1DComponentsType>::Get(r_variable_name+"_Y"); + const Array1DComponentsType& r_var_z = KratosComponents< Array1DComponentsType>::Get(r_variable_name+"_Z"); for ( IndexType i_slave = 0; i_slave < NumNodes; ++i_slave ) { - NodeType& slave_node = this->GetParentGeometry()[i_slave]; - rConditionalDofList[index++] = slave_node.pGetDof( var_x ); - rConditionalDofList[index++] = slave_node.pGetDof( var_y ); - if (TDim == 3) rConditionalDofList[index++] = slave_node.pGetDof( var_z ); + const NodeType& r_slave_node = r_current_slave[i_slave]; + rConditionalDofList[index++] = r_slave_node.pGetDof( r_var_x ); + rConditionalDofList[index++] = r_slave_node.pGetDof( r_var_y ); + if (TDim == 3) rConditionalDofList[index++] = r_slave_node.pGetDof( r_var_z ); } } // Slave Nodes LM Equation IDs if (tensor_value == ScalarValue) { for ( IndexType i_slave = 0; i_slave < NumNodes; ++i_slave ) { - NodeType& slave_node = this->GetParentGeometry()[i_slave]; - rConditionalDofList[index++] = slave_node.pGetDof( SCALAR_LAGRANGE_MULTIPLIER ); + const NodeType& r_slave_node = r_current_slave[i_slave]; + rConditionalDofList[index++] = r_slave_node.pGetDof( SCALAR_LAGRANGE_MULTIPLIER ); } } else { for ( IndexType i_slave = 0; i_slave < NumNodes; ++i_slave ) { - NodeType& slave_node = this->GetParentGeometry()[i_slave]; - rConditionalDofList[index++] = slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_X ); - rConditionalDofList[index++] = slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_Y ); - if (TDim == 3) rConditionalDofList[index++] = slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_Z ); + const NodeType& r_slave_node = r_current_slave[i_slave]; + rConditionalDofList[index++] = r_slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_X ); + rConditionalDofList[index++] = r_slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_Y ); + if (TDim == 3) rConditionalDofList[index++] = r_slave_node.pGetDof( VECTOR_LAGRANGE_MULTIPLIER_Z ); } } 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 ); -} - /***********************************************************************************/ /***********************************************************************************/ @@ -803,7 +765,7 @@ void MeshTyingMortarCondition::Calculat /***********************************************************************************/ template< SizeType TDim, SizeType TNumNodesElem, SizeType TNumNodesElemMaster> -int MeshTyingMortarCondition::Check( const ProcessInfo& rCurrentProcessInfo ) +int MeshTyingMortarCondition::Check(const ProcessInfo& rCurrentProcessInfo) const { KRATOS_TRY diff --git a/applications/ContactStructuralMechanicsApplication/symbolic_generation/penalty_frictional_mortar_condition/penalty_frictional_mortar_contact_condition_template.cpp b/applications/ContactStructuralMechanicsApplication/symbolic_generation/penalty_frictional_mortar_condition/penalty_frictional_mortar_contact_condition_template.cpp index 1c4a71348af7..42647335b78e 100644 --- a/applications/ContactStructuralMechanicsApplication/symbolic_generation/penalty_frictional_mortar_condition/penalty_frictional_mortar_contact_condition_template.cpp +++ b/applications/ContactStructuralMechanicsApplication/symbolic_generation/penalty_frictional_mortar_condition/penalty_frictional_mortar_contact_condition_template.cpp @@ -69,11 +69,11 @@ PenaltyMethodFrictionalMortarContactCondition -void PenaltyMethodFrictionalMortarContactCondition::Initialize( ) +void PenaltyMethodFrictionalMortarContactCondition::Initialize(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; - BaseType::Initialize(); + BaseType::Initialize(rCurrentProcessInfo); // We initailize the previous mortar operators mPreviousMortarOperators.Initialize(); @@ -85,7 +85,7 @@ void PenaltyMethodFrictionalMortarContactCondition -void PenaltyMethodFrictionalMortarContactCondition::InitializeSolutionStep( ProcessInfo& rCurrentProcessInfo ) +void PenaltyMethodFrictionalMortarContactCondition::InitializeSolutionStep(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -104,7 +104,7 @@ void PenaltyMethodFrictionalMortarContactCondition -void PenaltyMethodFrictionalMortarContactCondition::FinalizeSolutionStep( ProcessInfo& rCurrentProcessInfo ) +void PenaltyMethodFrictionalMortarContactCondition::FinalizeSolutionStep(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -120,7 +120,7 @@ void PenaltyMethodFrictionalMortarContactCondition -void PenaltyMethodFrictionalMortarContactCondition::AddExplicitContribution(ProcessInfo& rCurrentProcessInfo) +void PenaltyMethodFrictionalMortarContactCondition::AddExplicitContribution(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -136,7 +136,7 @@ template< SizeType TDim, SizeType TNumNodes, bool TNormalVariation, SizeType TNu void PenaltyMethodFrictionalMortarContactCondition::AddExplicitContribution( const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable& rDestinationVariable, + const Variable& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) { @@ -154,7 +154,7 @@ template< SizeType TDim, SizeType TNumNodes, bool TNormalVariation, SizeType TNu void PenaltyMethodFrictionalMortarContactCondition::AddExplicitContribution( const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable>& rDestinationVariable, + const Variable>& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) { @@ -200,7 +200,7 @@ void PenaltyMethodFrictionalMortarContactCondition -void PenaltyMethodFrictionalMortarContactCondition::ComputePreviousMortarOperators( ProcessInfo& rCurrentProcessInfo) +void PenaltyMethodFrictionalMortarContactCondition::ComputePreviousMortarOperators(const ProcessInfo& rCurrentProcessInfo) { const IndexType integration_order = this->GetProperties().Has(INTEGRATION_ORDER_CONTACT) ? this->GetProperties().GetValue(INTEGRATION_ORDER_CONTACT) : 2; MortarExplicitContributionUtilities::ComputePreviousMortarOperators(this, rCurrentProcessInfo, mPreviousMortarOperators, integration_order, false); @@ -225,8 +225,8 @@ void PenaltyMethodFrictionalMortarContactCondition void PenaltyMethodFrictionalMortarContactCondition::EquationIdVector( EquationIdVectorType& rResult, - ProcessInfo& CurrentProcessInfo - ) + const ProcessInfo& CurrentProcessInfo + ) const { KRATOS_TRY; @@ -236,12 +236,12 @@ void PenaltyMethodFrictionalMortarContactConditionGetParentGeometry(); - GeometryType& r_master_geometry = this->GetPairedGeometry(); + const GeometryType& r_slave_geometry = this->GetParentGeometry(); + const GeometryType& r_master_geometry = this->GetPairedGeometry(); // Master Nodes Displacement Equation IDs for ( IndexType i_master = 0; i_master < TNumNodesMaster; ++i_master ) { // NOTE: Assuming same number of nodes for master and slave - NodeType& r_master_node = r_master_geometry[i_master]; + const NodeType& r_master_node = r_master_geometry[i_master]; rResult[index++] = r_master_node.GetDof( DISPLACEMENT_X ).EquationId( ); rResult[index++] = r_master_node.GetDof( DISPLACEMENT_Y ).EquationId( ); if (TDim == 3) rResult[index++] = r_master_node.GetDof( DISPLACEMENT_Z ).EquationId( ); @@ -249,7 +249,7 @@ void PenaltyMethodFrictionalMortarContactCondition void PenaltyMethodFrictionalMortarContactCondition::GetDofList( DofsVectorType& rConditionalDofList, - ProcessInfo& rCurrentProcessInfo -) + const ProcessInfo& rCurrentProcessInfo + ) const { KRATOS_TRY; @@ -275,12 +275,12 @@ void PenaltyMethodFrictionalMortarContactConditionGetParentGeometry(); - GeometryType& r_master_geometry = this->GetPairedGeometry(); + const GeometryType& r_slave_geometry = this->GetParentGeometry(); + const GeometryType& r_master_geometry = this->GetPairedGeometry(); // Master Nodes Displacement Equation IDs for ( IndexType i_master = 0; i_master < TNumNodesMaster; ++i_master ){ // NOTE: Assuming same number of nodes for master and slave - NodeType& r_master_node = r_master_geometry[i_master]; + const NodeType& r_master_node = r_master_geometry[i_master]; rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_X ); rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_Y ); if (TDim == 3) rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_Z ); @@ -288,7 +288,7 @@ void PenaltyMethodFrictionalMortarContactCondition -int PenaltyMethodFrictionalMortarContactCondition::Check( const ProcessInfo& rCurrentProcessInfo ) +int PenaltyMethodFrictionalMortarContactCondition::Check(const ProcessInfo& rCurrentProcessInfo) const { KRATOS_TRY @@ -310,14 +310,13 @@ int PenaltyMethodFrictionalMortarContactConditionGetParentGeometry(); + const GeometryType& r_slave_geometry = this->GetParentGeometry(); for ( IndexType i = 0; i < TNumNodes; ++i ) { - NodeType& r_node = r_slave_geometry[i]; - KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(NORMAL, r_node) + const NodeType& r_node = r_slave_geometry[i]; + KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(WEIGHTED_SLIP, r_node) } return ierr; diff --git a/applications/ContactStructuralMechanicsApplication/symbolic_generation/penalty_frictionless_mortar_condition/penalty_frictionless_mortar_contact_condition_template.cpp b/applications/ContactStructuralMechanicsApplication/symbolic_generation/penalty_frictionless_mortar_condition/penalty_frictionless_mortar_contact_condition_template.cpp index 76711a87d4c3..e152e6c8169c 100644 --- a/applications/ContactStructuralMechanicsApplication/symbolic_generation/penalty_frictionless_mortar_condition/penalty_frictionless_mortar_contact_condition_template.cpp +++ b/applications/ContactStructuralMechanicsApplication/symbolic_generation/penalty_frictionless_mortar_condition/penalty_frictionless_mortar_contact_condition_template.cpp @@ -68,7 +68,7 @@ PenaltyMethodFrictionlessMortarContactCondition -void PenaltyMethodFrictionlessMortarContactCondition::AddExplicitContribution(ProcessInfo& rCurrentProcessInfo) +void PenaltyMethodFrictionlessMortarContactCondition::AddExplicitContribution(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY; @@ -85,13 +85,13 @@ template< SizeType TDim, SizeType TNumNodes, bool TNormalVariation, SizeType TNu void PenaltyMethodFrictionlessMortarContactCondition::AddExplicitContribution( const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable& rDestinationVariable, + const Variable& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) { KRATOS_TRY; - // TODO: Add something if necessary + BaseType::AddExplicitContribution(rRHSVector, rRHSVariable, rDestinationVariable, rCurrentProcessInfo); KRATOS_CATCH("") } @@ -103,7 +103,7 @@ template< SizeType TDim, SizeType TNumNodes, bool TNormalVariation, SizeType TNu void PenaltyMethodFrictionlessMortarContactCondition::AddExplicitContribution( const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable>& rDestinationVariable, + const Variable>& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) { @@ -163,8 +163,8 @@ void PenaltyMethodFrictionlessMortarContactCondition void PenaltyMethodFrictionlessMortarContactCondition::EquationIdVector( EquationIdVectorType& rResult, - ProcessInfo& CurrentProcessInfo - ) + const ProcessInfo& CurrentProcessInfo + ) const { KRATOS_TRY; @@ -174,12 +174,12 @@ void PenaltyMethodFrictionlessMortarContactConditionGetParentGeometry(); - GeometryType& r_master_geometry = this->GetPairedGeometry(); + const GeometryType& r_slave_geometry = this->GetParentGeometry(); + const GeometryType& r_master_geometry = this->GetPairedGeometry(); // Master Nodes Displacement Equation IDs for ( IndexType i_master = 0; i_master < TNumNodesMaster; ++i_master ) { // NOTE: Assuming same number of nodes for master and slave - NodeType& r_master_node = r_master_geometry[i_master]; + const NodeType& r_master_node = r_master_geometry[i_master]; rResult[index++] = r_master_node.GetDof( DISPLACEMENT_X ).EquationId( ); rResult[index++] = r_master_node.GetDof( DISPLACEMENT_Y ).EquationId( ); if (TDim == 3) rResult[index++] = r_master_node.GetDof( DISPLACEMENT_Z ).EquationId( ); @@ -187,7 +187,7 @@ void PenaltyMethodFrictionlessMortarContactCondition void PenaltyMethodFrictionlessMortarContactCondition::GetDofList( DofsVectorType& rConditionalDofList, - ProcessInfo& rCurrentProcessInfo - ) + const ProcessInfo& rCurrentProcessInfo + ) const { KRATOS_TRY; @@ -213,12 +213,12 @@ void PenaltyMethodFrictionlessMortarContactConditionGetParentGeometry(); - GeometryType& r_master_geometry = this->GetPairedGeometry(); + const GeometryType& r_slave_geometry = this->GetParentGeometry(); + const GeometryType& r_master_geometry = this->GetPairedGeometry(); // Master Nodes Displacement Equation IDs for ( IndexType i_master = 0; i_master < TNumNodesMaster; ++i_master ) { // NOTE: Assuming same number of nodes for master and slave - NodeType& r_master_node = r_master_geometry[i_master]; + const NodeType& r_master_node = r_master_geometry[i_master]; rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_X ); rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_Y ); if (TDim == 3) rConditionalDofList[index++] = r_master_node.pGetDof( DISPLACEMENT_Z ); @@ -226,7 +226,7 @@ void PenaltyMethodFrictionlessMortarContactCondition -int PenaltyMethodFrictionlessMortarContactCondition::Check( const ProcessInfo& rCurrentProcessInfo ) +int PenaltyMethodFrictionlessMortarContactCondition::Check(const ProcessInfo& rCurrentProcessInfo) const { KRATOS_TRY // Base class checks for positive Jacobian and Id > 0 - int ierr = BaseType::Check(rCurrentProcessInfo); - if(ierr != 0) return ierr; - - // Check that all required variables have been registered - KRATOS_CHECK_VARIABLE_KEY(NORMAL) - - // Check that the element's nodes contain all required SolutionStepData and Degrees of freedom - GeometryType& r_slave_geometry = this->GetParentGeometry(); - for ( IndexType i = 0; i < TNumNodes; ++i ) { - NodeType& r_node = r_slave_geometry[i]; - KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(NORMAL,r_node) - } + const int ierr = BaseType::Check(rCurrentProcessInfo); return ierr; diff --git a/applications/ContactStructuralMechanicsApplication/tests/cpp_tests/test_weighted_gap.cpp b/applications/ContactStructuralMechanicsApplication/tests/cpp_tests/test_weighted_gap.cpp index b26dbd22f13b..e89f979ddee5 100644 --- a/applications/ContactStructuralMechanicsApplication/tests/cpp_tests/test_weighted_gap.cpp +++ b/applications/ContactStructuralMechanicsApplication/tests/cpp_tests/test_weighted_gap.cpp @@ -56,7 +56,7 @@ namespace Kratos const double MoveMesh = 0.0 ) { - auto& r_process_info = rModelPart.GetProcessInfo(); + const auto& r_process_info = rModelPart.GetProcessInfo(); rModelPart.CreateSubModelPart("SlaveModelPart"); ModelPart& r_slave_model_part = rModelPart.GetSubModelPart("SlaveModelPart"); @@ -179,7 +179,7 @@ namespace Kratos const double MoveMesh = 0.0 ) { - auto& r_process_info = rModelPart.GetProcessInfo(); + const auto& r_process_info = rModelPart.GetProcessInfo(); rModelPart.CreateSubModelPart("SlaveModelPart"); ModelPart& r_slave_model_part = rModelPart.GetSubModelPart("SlaveModelPart"); @@ -334,7 +334,7 @@ namespace Kratos const double MoveMesh = 0.0 ) { - auto& r_process_info = rModelPart.GetProcessInfo(); + const auto& r_process_info = rModelPart.GetProcessInfo(); rModelPart.CreateSubModelPart("SlaveModelPart"); ModelPart& r_slave_model_part = rModelPart.GetSubModelPart("SlaveModelPart"); @@ -704,7 +704,7 @@ namespace Kratos } // We set the database - auto& r_process_info = rModelPart.GetProcessInfo(); + const auto& r_process_info = rModelPart.GetProcessInfo(); ModelPart& r_computing_contact_model_part = rModelPart.GetSubModelPart("ComputingContact"); for (auto p_slave_cond : slave_conds) { for (auto p_master_cond : master_conds) { @@ -910,10 +910,11 @@ namespace Kratos const array_1d zero_vector = ZeroVector(3);; VariableUtils().SetVariable(WEIGHTED_GAP, 0.0, r_model_part.Nodes()); VariableUtils().SetVariable(WEIGHTED_SLIP, zero_vector, r_model_part.Nodes()); + const auto& r_const_process_info = r_model_part.GetProcessInfo(); for (auto& r_cond : r_model_part.GetSubModelPart("ComputingContact").Conditions()) { if (r_cond.Is(SLAVE)) { - r_cond.AddExplicitContribution(r_process_info); - r_cond.FinalizeSolutionStep(r_process_info); + r_cond.AddExplicitContribution(r_const_process_info); + r_cond.FinalizeSolutionStep(r_const_process_info); } } @@ -966,10 +967,11 @@ namespace Kratos const array_1d zero_vector = ZeroVector(3);; VariableUtils().SetVariable(WEIGHTED_GAP, 0.0, r_model_part.Nodes()); VariableUtils().SetVariable(WEIGHTED_SLIP, zero_vector, r_model_part.Nodes()); + const auto& r_const_process_info = r_model_part.GetProcessInfo(); for (auto& r_cond : r_model_part.GetSubModelPart("ComputingContact").Conditions()) { if (r_cond.Is(SLAVE)) { - r_cond.AddExplicitContribution(r_process_info); - r_cond.FinalizeSolutionStep(r_process_info); + r_cond.AddExplicitContribution(r_const_process_info); + r_cond.FinalizeSolutionStep(r_const_process_info); } } @@ -1022,11 +1024,12 @@ namespace Kratos const array_1d zero_vector = ZeroVector(3);; VariableUtils().SetVariable(WEIGHTED_GAP, 0.0, r_model_part.Nodes()); VariableUtils().SetVariable(WEIGHTED_SLIP, zero_vector, r_model_part.Nodes()); + const auto& r_const_process_info = r_model_part.GetProcessInfo(); for (auto& r_cond : r_model_part.GetSubModelPart("ComputingContact").Conditions()) { if (r_cond.Is(SLAVE)) { r_cond.Set(MODIFIED, true); - r_cond.AddExplicitContribution(r_process_info); - r_cond.FinalizeSolutionStep(r_process_info); + r_cond.AddExplicitContribution(r_const_process_info); + r_cond.FinalizeSolutionStep(r_const_process_info); } } @@ -1079,11 +1082,12 @@ namespace Kratos const array_1d zero_vector = ZeroVector(3);; VariableUtils().SetVariable(WEIGHTED_GAP, 0.0, r_model_part.Nodes()); VariableUtils().SetVariable(WEIGHTED_SLIP, zero_vector, r_model_part.Nodes()); + const auto& r_const_process_info = r_model_part.GetProcessInfo(); for (auto& r_cond : r_model_part.GetSubModelPart("ComputingContact").Conditions()) { if (r_cond.Is(SLAVE)) { r_cond.Set(MODIFIED, true); - r_cond.AddExplicitContribution(r_process_info); - r_cond.FinalizeSolutionStep(r_process_info); + r_cond.AddExplicitContribution(r_const_process_info); + r_cond.FinalizeSolutionStep(r_const_process_info); } } @@ -1143,10 +1147,11 @@ namespace Kratos const array_1d zero_vector = ZeroVector(3);; VariableUtils().SetVariable(WEIGHTED_GAP, 0.0, r_model_part.Nodes()); VariableUtils().SetVariable(WEIGHTED_SLIP, zero_vector, r_model_part.Nodes()); + const auto& r_const_process_info = r_model_part.GetProcessInfo(); for (auto& r_cond : r_model_part.GetSubModelPart("ComputingContact").Conditions()) { if (r_cond.Is(SLAVE)) { - r_cond.AddExplicitContribution(r_process_info); - r_cond.FinalizeSolutionStep(r_process_info); + r_cond.AddExplicitContribution(r_const_process_info); + r_cond.FinalizeSolutionStep(r_const_process_info); } } @@ -1206,11 +1211,12 @@ namespace Kratos const array_1d zero_vector = ZeroVector(3);; VariableUtils().SetVariable(WEIGHTED_GAP, 0.0, r_model_part.Nodes()); VariableUtils().SetVariable(WEIGHTED_SLIP, zero_vector, r_model_part.Nodes()); + const auto& r_const_process_info = r_model_part.GetProcessInfo(); for (auto& r_cond : r_model_part.GetSubModelPart("ComputingContact").Conditions()) { if (r_cond.Is(SLAVE)) { r_cond.Set(MODIFIED, true); - r_cond.AddExplicitContribution(r_process_info); - r_cond.FinalizeSolutionStep(r_process_info); + r_cond.AddExplicitContribution(r_const_process_info); + r_cond.FinalizeSolutionStep(r_const_process_info); } } @@ -1274,11 +1280,12 @@ namespace Kratos const array_1d zero_vector = ZeroVector(3);; VariableUtils().SetVariable(WEIGHTED_GAP, 0.0, r_model_part.Nodes()); VariableUtils().SetVariable(WEIGHTED_SLIP, zero_vector, r_model_part.Nodes()); + const auto& r_const_process_info = r_model_part.GetProcessInfo(); for (auto& r_cond : r_model_part.GetSubModelPart("ComputingContact").Conditions()) { if (r_cond.Is(SLAVE)) { r_cond.Set(MODIFIED, true); - r_cond.AddExplicitContribution(r_process_info); - r_cond.FinalizeSolutionStep(r_process_info); + r_cond.AddExplicitContribution(r_const_process_info); + r_cond.FinalizeSolutionStep(r_const_process_info); } } @@ -1335,9 +1342,10 @@ namespace Kratos const array_1d zero_vector = ZeroVector(3); VariableUtils().SetVariable(WEIGHTED_GAP, 0.0, r_model_part.Nodes()); VariableUtils().SetVariable(WEIGHTED_SLIP, zero_vector, r_model_part.Nodes()); + const auto& r_const_process_info = r_model_part.GetProcessInfo(); for (auto& r_cond : r_model_part.GetSubModelPart("ComputingContact").Conditions()) { - r_cond.AddExplicitContribution(r_process_info); - r_cond.FinalizeSolutionStep(r_process_info); + r_cond.AddExplicitContribution(r_const_process_info); + r_cond.FinalizeSolutionStep(r_const_process_info); } // // DEBUG @@ -1390,10 +1398,11 @@ namespace Kratos const array_1d zero_vector = ZeroVector(3); VariableUtils().SetVariable(WEIGHTED_GAP, 0.0, r_model_part.Nodes()); VariableUtils().SetVariable(WEIGHTED_SLIP, zero_vector, r_model_part.Nodes()); + const auto& r_const_process_info = r_model_part.GetProcessInfo(); for (auto& r_cond : r_model_part.GetSubModelPart("ComputingContact").Conditions()) { r_cond.Set(MODIFIED, true); - r_cond.AddExplicitContribution(r_process_info); - r_cond.FinalizeSolutionStep(r_process_info); + r_cond.AddExplicitContribution(r_const_process_info); + r_cond.FinalizeSolutionStep(r_const_process_info); } // // DEBUG 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_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") < ElementConfigureType; typedef RigidFaceGeometricalObjectConfigure<3> RigidFaceGeometricalConfigureType; - typedef Kratos::VariableComponent > > ComponentOf3ComponentsVariableType; + typedef Variable ComponentOf3ComponentsVariableType; /// Pointer definition of ExplicitSolverStrategy KRATOS_CLASS_POINTER_DEFINITION(ExplicitSolverStrategy); diff --git a/applications/DEMApplication/custom_utilities/inlet.cpp b/applications/DEMApplication/custom_utilities/inlet.cpp index a6e5cd5a4252..238d8618d2d5 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" @@ -34,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) @@ -113,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 @@ -171,7 +183,7 @@ namespace Kratos { mBallsModelPartHasSphericity, mBallsModelPartHasRotation, true, - smp_it->Elements()); + mp.Elements()); FixInjectorConditions(p_element); max_Id++; @@ -453,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; @@ -474,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; @@ -540,7 +552,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 +617,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) { @@ -622,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++; @@ -646,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/custom_utilities/pre_utilities.h b/applications/DEMApplication/custom_utilities/pre_utilities.h index 234984ad0252..cabb3a9e025c 100644 --- a/applications/DEMApplication/custom_utilities/pre_utilities.h +++ b/applications/DEMApplication/custom_utilities/pre_utilities.h @@ -83,6 +83,38 @@ class PreUtilities p_properties->SetValue(CLUSTER_INFORMATION, cl_info); } + 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;} + + 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::ptr_const_iterator it = begin + i; + const Element& el = **it; + const SphericContinuumParticle* p_cont_sphere = dynamic_cast(&el); + 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; + } else { + 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; + } + } + 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; + outputfile <= 1.15: print(node_vel) print(node_force) 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; 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]; 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); 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) diff --git a/applications/FluidDynamicsApplication/python_scripts/cfl_output_process.py b/applications/FluidDynamicsApplication/python_scripts/cfl_output_process.py index d761d6848514..2e0041910eab 100755 --- a/applications/FluidDynamicsApplication/python_scripts/cfl_output_process.py +++ b/applications/FluidDynamicsApplication/python_scripts/cfl_output_process.py @@ -1,11 +1,19 @@ # 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 -from statistics import mean, stdev +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 math import sqrt def Factory(settings, model): @@ -37,7 +45,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 +69,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 +88,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 +143,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] + 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 # qunatifying the global max - x_max = max(x) + # 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): - 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] 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/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 - } }] } } 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..3001346683d4 --- /dev/null +++ b/applications/FluidDynamicsApplication/tests/cfl_output_process_test.py @@ -0,0 +1,67 @@ +import KratosMultiphysics as km + +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 + + @UnitTest.skipIfApplicationsNotAvailable("StatisticsApplication") + 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() 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 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) 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); 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); 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< 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_processes/metrics_hessian_process.cpp b/applications/MeshingApplication/custom_processes/metrics_hessian_process.cpp index 9ade501ea58a..8a9c9f9d933e 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) + ) : mrModelPart(rThisModelPart), + mrOriginVariable(&rVariable) { - // 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) -{ - // 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 @@ -232,7 +199,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(); @@ -244,7 +213,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); } @@ -352,9 +321,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 +482,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 +535,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..407d4ab9c635 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 ///@{ @@ -273,8 +278,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 @@ -307,8 +311,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 +326,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/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"); 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/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 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 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); } /** 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.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian.cpp index 943c8aff2d78..11845ccef5c2 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 { @@ -42,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!!! } @@ -50,7 +51,7 @@ UpdatedLagrangian::UpdatedLagrangian( ) //************************************************************************************ UpdatedLagrangian::UpdatedLagrangian( IndexType NewId, GeometryType::Pointer pGeometry ) : Element( NewId, pGeometry ) - , mMP(pGeometry->WorkingSpaceDimension()) + , mMP() { //DO NOT ADD DOFS HERE!!! } @@ -60,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; @@ -292,36 +293,44 @@ 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); // 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 (!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 (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 +344,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 +465,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 +503,31 @@ 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 ); + const bool is_explicit = (rCurrentProcessInfo.Has(IS_EXPLICIT)) + ? rCurrentProcessInfo.GetValue(IS_EXPLICIT) + : false; + if (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, + rVariables.DN_DX, mMP.cauchy_stress_vector, mMP.volume, + mConstitutiveLawVector->GetStrainSize(), rRightHandSideVector); + } + else + { + // Operation performed: rRightHandSideVector -= IntForce*IntToReferenceWeight + this->CalculateAndAddInternalForces(rRightHandSideVector, rVariables, rIntegrationWeight); + } + + } } @@ -537,6 +573,73 @@ 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. + 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; + + // 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); + + // 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 +729,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 ) @@ -813,33 +899,40 @@ 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; - - // Calculating shape function - Variables.N = this->MPMShapeFunctionPointValues(Variables.N, mMP.xg); + const bool is_explicit = (rCurrentProcessInfo.Has(IS_EXPLICIT)) + ? rCurrentProcessInfo.GetValue(IS_EXPLICIT) + : false; mFinalizedStep = false; + // Calculating shape functions + Vector N; + this->MPMShapeFunctionPointValues(N, mMP.xg); + + 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] += N[j] * nodal_velocity[k]; + aux_MP_acceleration[k] += N[j] * nodal_acceleration[k]; + } } } @@ -848,18 +941,28 @@ 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; + + } + // 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 * (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].FastGetSolutionStepValue(NODAL_MASS, 0) += N[i] * mMP.mass; r_geometry[i].UnSetLock(); - } } @@ -870,6 +973,13 @@ void UpdatedLagrangian::FinalizeSolutionStep( ProcessInfo& rCurrentProcessInfo ) { KRATOS_TRY + 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: GeneralVariables Variables; this->InitializeGeneralVariables(Variables,rCurrentProcessInfo); @@ -923,8 +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); - this->UpdateGaussPoint(rVariables, rCurrentProcessInfo); - + const bool is_explicit = (rCurrentProcessInfo.Has(IS_EXPLICIT)) + ? rCurrentProcessInfo.GetValue(IS_EXPLICIT) + : false; + if (!is_explicit) this->UpdateGaussPoint(rVariables, rCurrentProcessInfo); } //************************************************************************************ @@ -1013,6 +1125,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; @@ -1273,39 +1388,68 @@ void UpdatedLagrangian::CalculateDampingMatrix( MatrixType& rDampingMatrix, Proc KRATOS_CATCH( "" ) } +void UpdatedLagrangian::AddExplicitContribution(const VectorType& rRHSVector, const Variable& rRHSVariable, const 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********************************************************* -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_lumped_mass_matrix = (rCurrentProcessInfo.Has(COMPUTE_LUMPED_MASS_MATRIX)) + ? rCurrentProcessInfo.GetValue(COMPUTE_LUMPED_MASS_MATRIX) + : true; - 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.size2() != 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_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) + { + 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; + } } } @@ -1613,6 +1757,41 @@ 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) + { + Vector N; + this->MPMShapeFunctionPointValues(N, mMP.xg); + MPMExplicitUtilities::UpdateGaussPointExplicit(rCurrentProcessInfo, *this, N); + rValues[0] = true; + } + else if (rVariable == CALCULATE_MUSL_VELOCITY_FIELD) + { + Vector N; + this->MPMShapeFunctionPointValues(N, mMP.xg); + MPMExplicitUtilities::CalculateMUSLGridVelocity(*this, N); + 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..699f0317851e 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,15 +132,6 @@ class UpdatedLagrangian // MP_VOLUME volume = 1.0; - SizeType strain_size = (WorkingSpaceDimension == 2) - ? 3 - : 6; - - // MP_CAUCHY_STRESS_VECTOR - cauchy_stress_vector = ZeroVector(strain_size); - // MP_ALMANSI_STRAIN_VECTOR - almansi_strain_vector = ZeroVector(strain_size); - // MP_DELTA_PLASTIC_STRAIN delta_plastic_strain = 1.0; // MP_DELTA_PLASTIC_VOLUMETRIC_STRAIN @@ -482,7 +473,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 @@ -494,6 +485,11 @@ class UpdatedLagrangian ProcessInfo& rCurrentProcessInfo) override; + void AddExplicitContribution(const VectorType& rRHSVector, + const Variable& rRHSVariable, + const Variable >& rDestinationVariable, + const ProcessInfo& rCurrentProcessInfo) override; + //************************************************************************************ //************************************************************************************ /** @@ -540,6 +536,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,7 +607,6 @@ class UpdatedLagrangian */ bool mFinalizedStep; - ///@} ///@name Protected Operators ///@{ @@ -640,7 +639,8 @@ class UpdatedLagrangian virtual void CalculateAndAddRHS(LocalSystemComponents& rLocalSystem, GeneralVariables& rVariables, Vector& rVolumeForce, - const double& rIntegrationWeight); + const double& rIntegrationWeight, + const ProcessInfo& rCurrentProcessInfo); /** @@ -675,6 +675,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 +804,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..6d871402c31f 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(); @@ -1019,35 +1023,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_lumped_mass_matrix = (rCurrentProcessInfo.Has(COMPUTE_LUMPED_MASS_MATRIX)) + ? rCurrentProcessInfo.GetValue(COMPUTE_LUMPED_MASS_MATRIX) + : true; - 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.size2() != 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_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) + { + 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; + } } } @@ -1237,6 +1250,12 @@ int UpdatedLagrangianUP::Check( const ProcessInfo& rCurrentProcessInfo ) { KRATOS_TRY + 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; correct = UpdatedLagrangian::Check(rCurrentProcessInfo); diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.hpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_UP.hpp index c8d6742c0376..d57d19600389 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; //************************************************************************************ @@ -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; /** diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_axisymmetry.cpp index af07fc2a495a..f0207809329c 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,74 @@ 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); + const bool is_explicit = (rCurrentProcessInfo.Has(IS_EXPLICIT)) + ? rCurrentProcessInfo.GetValue(IS_EXPLICIT) + : false; + if (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 + const double current_radius = ParticleMechanicsMathUtilities::CalculateRadius(rVariables.N, GetGeometry()); + MPMExplicitUtilities::CalculateAndAddAxisymmetricExplicitInternalForce(*this, + rVariables.DN_DX, rVariables.N, mMP.cauchy_stress_vector, mMP.volume, + mConstitutiveLawVector->GetStrainSize(), current_radius, rRightHandSideVector); + } + else + { + // Operation performed: rRightHandSideVector -= IntForce*IntToReferenceWeight + this->CalculateAndAddInternalForces(rRightHandSideVector, rVariables, rIntegrationWeight); + } + + + } +} + + //************************************************************************************ //************************************************************************************ @@ -311,6 +380,71 @@ 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. + 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; + + // 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); + + // 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 070ecad0ff8f..1c13901b3ef1 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. + void CalculateExplicitStresses(const ProcessInfo& rCurrentProcessInfo, + GeneralVariables& rVariables) override; + /** * Clear Nodal Forces */ @@ -255,6 +259,11 @@ class UpdatedLagrangianAxisymmetry const double & rCurrentRadius, const double & rReferenceRadius); + /// Calculate and add RHS + void CalculateAndAddRHS(LocalSystemComponents& rLocalSystem, + GeneralVariables& rVariables, Vector& rVolumeForce, const double& rIntegrationWeight, + const ProcessInfo& rCurrentProcessInfo) override; + ///@} ///@name Protected Access ///@{ diff --git a/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp b/applications/ParticleMechanicsApplication/custom_elements/updated_lagrangian_quadrilateral.cpp index 57b6ba0b5928..c388f0570ac8 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 { @@ -42,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!!! } @@ -50,7 +51,7 @@ UpdatedLagrangianQuadrilateral::UpdatedLagrangianQuadrilateral( ) //************************************************************************************ UpdatedLagrangianQuadrilateral::UpdatedLagrangianQuadrilateral( IndexType NewId, GeometryType::Pointer pGeometry ) : Element( NewId, pGeometry ) - , mMP(pGeometry->WorkingSpaceDimension()) + , mMP() { //DO NOT ADD DOFS HERE!!! } @@ -60,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; @@ -293,39 +294,47 @@ 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); // 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 (!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); - - /* 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 if (is_explicit) + { + 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,8 +345,8 @@ 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 ); - 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( "" ) @@ -458,7 +467,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, + const ProcessInfo& rCurrentProcessInfo) { // Contribution of the internal and external forces if( rLocalSystem.CalculationFlags.Is( UpdatedLagrangianQuadrilateral::COMPUTE_RHS_VECTOR_WITH_COMPONENTS ) ) @@ -492,9 +506,31 @@ void UpdatedLagrangianQuadrilateral::CalculateAndAddRHS(LocalSystemComponents& r // Operation performed: rRightHandSideVector += ExtForce*IntToReferenceWeight this->CalculateAndAddExternalForces( rRightHandSideVector, rVariables, rVolumeForce, rIntegrationWeight ); + const bool is_explicit = (rCurrentProcessInfo.Has(IS_EXPLICIT)) + ? rCurrentProcessInfo.GetValue(IS_EXPLICIT) + : false; - // Operation performed: rRightHandSideVector -= IntForce*IntToReferenceWeight - this->CalculateAndAddInternalForces( rRightHandSideVector, rVariables, rIntegrationWeight ); + if (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, + rVariables.DN_DX, mMP.cauchy_stress_vector, mMP.volume, + mConstitutiveLawVector->GetStrainSize(), rRightHandSideVector); + } + else + { + // Operation performed: rRightHandSideVector -= IntForce*IntToReferenceWeight + this->CalculateAndAddInternalForces(rRightHandSideVector, rVariables, rIntegrationWeight); + } } } @@ -541,6 +577,73 @@ void UpdatedLagrangianQuadrilateral::CalculateAndAddInternalForces(VectorType& r //************************************************************************************ //************************************************************************************ + +void UpdatedLagrangianQuadrilateral::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. + 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; + + // 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); + + // 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 @@ -629,22 +732,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( "" ) -} //************************************************************************************ //************************************************************************************ @@ -818,33 +905,40 @@ 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; - - // Calculating shape function - Variables.N = this->MPMShapeFunctionPointValues(Variables.N, mMP.xg); + const bool is_explicit = (rCurrentProcessInfo.Has(IS_EXPLICIT)) + ? rCurrentProcessInfo.GetValue(IS_EXPLICIT) + : false; mFinalizedStep = false; + // Calculating shape functions + Vector N; + this->MPMShapeFunctionPointValues(N, mMP.xg); + 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] += N[j] * nodal_velocity[k]; + aux_MP_acceleration[k] += N[j] * nodal_acceleration[k]; + } } } @@ -853,37 +947,52 @@ 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 + // 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 * (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].FastGetSolutionStepValue(NODAL_MASS, 0) += N[i] * mMP.mass; r_geometry[i].UnSetLock(); - } } - ////************************************************************************************ ////************************************************************************************ -void UpdatedLagrangianQuadrilateral::FinalizeSolutionStep( ProcessInfo& rCurrentProcessInfo ) +void UpdatedLagrangianQuadrilateral::FinalizeSolutionStep(ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY + 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: GeneralVariables Variables; - this->InitializeGeneralVariables(Variables,rCurrentProcessInfo); + this->InitializeGeneralVariables(Variables, rCurrentProcessInfo); // Create constitutive law parameters: - ConstitutiveLaw::Parameters Values(GetGeometry(),GetProperties(),rCurrentProcessInfo); + ConstitutiveLaw::Parameters Values(GetGeometry(), GetProperties(), rCurrentProcessInfo); // Set constitutive law flags: - Flags &ConstitutiveLawOptions=Values.GetOptions(); + Flags& ConstitutiveLawOptions = Values.GetOptions(); ConstitutiveLawOptions.Set(ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN); ConstitutiveLawOptions.Set(ConstitutiveLaw::COMPUTE_STRESS); @@ -892,7 +1001,7 @@ void UpdatedLagrangianQuadrilateral::FinalizeSolutionStep( ProcessInfo& rCurrent this->CalculateKinematics(Variables, rCurrentProcessInfo); // Set general variables to constitutivelaw parameters - this->SetGeneralVariables(Variables,Values); + this->SetGeneralVariables(Variables, Values); // Call the constitutive law to update material variables mConstitutiveLawVector->FinalizeMaterialResponse(Values, Variables.StressMeasure); @@ -901,11 +1010,10 @@ void UpdatedLagrangianQuadrilateral::FinalizeSolutionStep( ProcessInfo& rCurrent this->FinalizeStepVariables(Variables, rCurrentProcessInfo); mFinalizedStep = true; - - KRATOS_CATCH( "" ) + + KRATOS_CATCH("") } -////************************************************************************************ ////************************************************************************************ void UpdatedLagrangianQuadrilateral::FinalizeStepVariables( GeneralVariables & rVariables, const ProcessInfo& rCurrentProcessInfo) @@ -927,8 +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); - this->UpdateGaussPoint(rVariables, rCurrentProcessInfo); - + const bool is_explicit = (rCurrentProcessInfo.Has(IS_EXPLICIT)) + ? rCurrentProcessInfo.GetValue(IS_EXPLICIT) + : false; + if (!is_explicit) this->UpdateGaussPoint(rVariables, rCurrentProcessInfo); } //************************************************************************************ @@ -1014,6 +1124,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; @@ -1274,36 +1387,76 @@ void UpdatedLagrangianQuadrilateral::CalculateDampingMatrix( MatrixType& rDampin KRATOS_CATCH( "" ) } + +void UpdatedLagrangianQuadrilateral::AddExplicitContribution(const VectorType& rRHSVector, + const Variable& rRHSVariable, + const 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********************************************************* -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_lumped_mass_matrix = (rCurrentProcessInfo.Has(COMPUTE_LUMPED_MASS_MATRIX)) + ? rCurrentProcessInfo.GetValue(COMPUTE_LUMPED_MASS_MATRIX) + : true; - 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.size2() != 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_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) + { + 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; + } } } @@ -1695,6 +1848,41 @@ 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) + { + 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) + { + Vector N; + this->MPMShapeFunctionPointValues(N, mMP.xg); + MPMExplicitUtilities::UpdateGaussPointExplicit(rCurrentProcessInfo, *this, N); + rValues[0] = true; + } + else if (rVariable == CALCULATE_MUSL_VELOCITY_FIELD) + { + Vector N; + this->MPMShapeFunctionPointValues(N, mMP.xg); + MPMExplicitUtilities::CalculateMUSLGridVelocity(*this, N); + 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 80d10cbb6a5f..ec192cbdcce8 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,15 +133,6 @@ class UpdatedLagrangianQuadrilateral // MP_VOLUME volume = 1.0; - SizeType strain_size = (WorkingSpaceDimension == 2) - ? 3 - : 6; - - // MP_CAUCHY_STRESS_VECTOR - cauchy_stress_vector = ZeroVector(strain_size); - // MP_ALMANSI_STRAIN_VECTOR - almansi_strain_vector = ZeroVector(strain_size); - // MP_DELTA_PLASTIC_STRAIN delta_plastic_strain = 1.0; // MP_DELTA_PLASTIC_VOLUMETRIC_STRAIN @@ -416,9 +407,7 @@ class UpdatedLagrangianQuadrilateral */ void InitializeSolutionStep(ProcessInfo& rCurrentProcessInfo) override; - /** - * Called at the end of eahc solution step - */ + /// Called at the end of each solution step void FinalizeSolutionStep(ProcessInfo& rCurrentProcessInfo) override; //************* COMPUTING METHODS @@ -488,7 +477,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 @@ -499,6 +488,11 @@ class UpdatedLagrangianQuadrilateral void CalculateDampingMatrix(MatrixType& rDampingMatrix, ProcessInfo& rCurrentProcessInfo) override; + void AddExplicitContribution(const VectorType& rRHSVector, + const Variable& rRHSVariable, + const Variable >& rDestinationVariable, + const ProcessInfo& rCurrentProcessInfo) override; + //************************************************************************************ //************************************************************************************ @@ -546,6 +540,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; @@ -610,7 +608,6 @@ class UpdatedLagrangianQuadrilateral */ bool mFinalizedStep; - ///@} ///@name Protected Operators ///@{ @@ -639,17 +636,16 @@ class UpdatedLagrangianQuadrilateral /** * Calculation and addition of the vectors of the RHS */ - virtual void CalculateAndAddRHS(LocalSystemComponents& rLocalSystem, GeneralVariables& rVariables, Vector& rVolumeForce, - const double& rIntegrationWeight); + const double& rIntegrationWeight, + const ProcessInfo& rCurrentProcessInfo); /** * Calculation of the Material Stiffness Matrix. Kuum = BT * C * B */ - virtual void CalculateAndAddKuum(MatrixType& rLeftHandSideMatrix, GeneralVariables& rVariables, const double& rIntegrationWeight); @@ -678,6 +674,9 @@ class UpdatedLagrangianQuadrilateral 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 @@ -807,11 +806,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_python/add_custom_strategies_to_python.cpp b/applications/ParticleMechanicsApplication/custom_python/add_custom_strategies_to_python.cpp index b67d257db4d7..66d84c8ed368 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,18 +73,21 @@ namespace Python{ .def("Initialize", &MPMResidualBasedBossakSchemeType::Initialize) ; + // MPM Explicit Scheme Type + py::class_< MPMExplicitSchemeType, typename MPMExplicitSchemeType::Pointer, BaseSchemeType >(m, "MPMExplicitScheme") + .def(py::init < ModelPart& >()) + .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 >() ) .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) + ; + + // MPM Explicit Strategy Type + py::class_< MPMExplicitStrategyType, typename MPMExplicitStrategyType::Pointer, BaseSolvingStrategyType >(m, "MPMExplicitStrategy") + .def(py::init< ModelPart&, BaseSchemeType::Pointer, bool, bool, bool >()) ; } diff --git a/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp b/applications/ParticleMechanicsApplication/custom_python/particle_mechanics_python_application.cpp index bf8496c2695f..226ce07947de 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,14 @@ 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_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); + 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_strategies/schemes/mpm_explicit_scheme.hpp b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp new file mode 100644 index 000000000000..3612b171196d --- /dev/null +++ b/applications/ParticleMechanicsApplication/custom_strategies/schemes/mpm_explicit_scheme.hpp @@ -0,0 +1,563 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ ` +// _|\_\_| \__,_|\__|\___/ ____/ +// 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 "solving_strategies/schemes/scheme.h" +#include "custom_utilities/mpm_boundary_rotation_utility.h" +#include "custom_utilities/mpm_explicit_utilities.h" + +namespace Kratos { + /** + * @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(); + + /** + * @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 + */ + explicit MPMExplicitScheme( + ModelPart& grid_model_part + ) + : Scheme(), + mr_grid_model_part(grid_model_part) + { + } + + /// Destructor. + virtual ~MPMExplicitScheme() {} + + /** + * 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 + // Initialize scheme + BaseType::SetSchemeIsInitialized(); + 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 + 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]; + const double delta_time = r_current_process_info[DELTA_TIME]; + + // 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); + + #pragma omp parallel for schedule(guided,512) + 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)) + { + this->UpdateTranslationalDegreesOfFreedom(r_current_process_info, it_node, disppos, delta_time, dim); + } + } // for Node parallel + + KRATOS_CATCH("") + } + + //*************************************************************************** + //*************************************************************************** + + void UpdateTranslationalDegreesOfFreedom( + const ProcessInfo& r_current_process_info, + NodeIterator itCurrentNode, + const IndexType DisplacementPosition, + const double delta_time, + 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); + + 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 + + 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 * delta_time * r_current_residual[j]; + } + } // for DomainSize + } + + //*************************************************************************** + //*************************************************************************** + + /** + * 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 + + 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) + { + 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 before momenta update (USF and 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); + + // 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) + { + NodeIterator i = mr_grid_model_part.NodesBegin() + iter; + + if ((i)->Is(ACTIVE)) + { + 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()); + + for (IndexType j = 0; j < DomainSize; j++) + { + if (fix_displacements[j]) + { + nodal_velocity[j] = 0.0; + } + else if (calculateVelocityFromMomenta && nodal_mass > numerical_limit) + { + 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 */ + void FinalizeSolutionStep( + ModelPart& rModelPart, + TSystemMatrixType& A, + TSystemVectorType& Dx, + TSystemVectorType& b) override + { + KRATOS_TRY + + ElementsArrayType& rElements = rModelPart.Elements(); + const ProcessInfo& rCurrentProcessInfo = rModelPart.GetProcessInfo(); + const auto it_elem_begin = rModelPart.ElementsBegin(); + + + // map grid 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); + } + + //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; + it_cond->FinalizeSolutionStep(rCurrentProcessInfo); + } + + KRATOS_CATCH("") + } + //*************************************************************************** + //*************************************************************************** + + void CalculateUpdatedGridVelocityField(const ProcessInfo& rCurrentProcessInfo, ModelPart& rModelPart) + { + if (rCurrentProcessInfo.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 1) + { + // 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. + + // 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(); + } + + // 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); + } + } + + //*************************************************************************** + //*************************************************************************** + + /** 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 GetDofList( + const Condition& rCurrentCondition, + Element::DofsVectorType& rConditionDofList, + const ProcessInfo& rCurrentProcessInfo) override + { + rCurrentCondition.GetDofList(rConditionDofList, rCurrentProcessInfo); + } + + //*************************************************************************** + //*************************************************************************** + + /** + * 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(const ModelPart& rModelPart) const override + { + KRATOS_TRY + + int err = Scheme::Check(rModelPart); + 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 (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; + KRATOS_ERROR_IF(it->SolutionStepsDataHas(ACCELERATION) == false) << "ACCELERATION variable is not allocated for node " << it->Id() << std::endl; + } + + //check that dofs exist + 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; + 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(rModelPart.GetBufferSize() < 2) << "Insufficient buffer size. Buffer size should be greater than 2. Current size is" << rModelPart.GetBufferSize() << std::endl; + KRATOS_CATCH("") + return 0; + } + + 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); + KRATOS_CATCH("") + } + + protected: + /// @name Member Variables + ModelPart& mr_grid_model_part; + + private: + }; /* 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..3583208ab8b3 --- /dev/null +++ b/applications/ParticleMechanicsApplication/custom_strategies/strategies/mpm_explicit_strategy.hpp @@ -0,0 +1,403 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ \. +// _|\_\_| \__,_|\__|\___/ ____/ +// 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 +{ +/// 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: + 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; + + explicit 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 + + mKeepSystemConstantDuringIterations = false; + mSolutionStepIsInitialized = false; + mInitializeWasPerformed = false; + mFinalizeSolutionStep = true; + // Set EchoLevel to the default value (only time is displayed) + this->SetEchoLevel(1); + // By default the matrices are rebuilt at each solution step + this->SetRebuildLevel(1); + + KRATOS_CATCH("") + } + + /// Destructor. + virtual ~MPMExplicitStrategy() + { + } + + + //Set and Get Scheme ... containing Builder, Update and other + void SetScheme(typename TSchemeType::Pointer pScheme) + { + mpScheme = pScheme; + }; + + typename TSchemeType::Pointer GetScheme() + { + return mpScheme; + }; + + /// 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 + KRATOS_INFO_IF("MPM_Explicit_Strategy", this->GetEchoLevel() == 2) << "CurrentTime = " << BaseType::GetModelPart().GetProcessInfo()[TIME] << std::endl; + + KRATOS_CATCH("") + } + + void InitializeSolutionStep() override + { + KRATOS_TRY + + // Initialize solution step + if (!mSolutionStepIsInitialized) + { + typename TSchemeType::Pointer pScheme = GetScheme(); + 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); + } + + 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(); + + // 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 + if (mCalculateReactionsFlag) CalculateReactions(pScheme, BaseType::GetModelPart(), mA, mDx, mb); + + return true; + } + + //********************************************************************** + //********************************************************************** + + void Clear() override + { + KRATOS_TRY + GetScheme()->Clear(); + + KRATOS_CATCH("") + } + + void SetKeepSystemConstantDuringIterations(bool value) + { + mKeepSystemConstantDuringIterations = value; + } + + bool GetKeepSystemConstantDuringIterations() + { + return mKeepSystemConstantDuringIterations; + } + + private: + + protected: + /*@} */ + /**@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; + + //********************************************************************** + //********************************************************************** + + 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 + + ConditionsArrayType& r_conditions = rModelPart.Conditions(); + ElementsArrayType& r_elements = rModelPart.Elements(); + + LocalSystemVectorType RHS_Contribution = LocalSystemVectorType(0); + Element::EquationIdVectorType equation_id_vector_dummy; // Dummy + + #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, 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, rModelPart.GetProcessInfo()); + } + + 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]; + } + } + } + } + + /// Copy constructor + MPMExplicitStrategy(const MPMExplicitStrategy& Other) + { + }; + }; // Class MPMExplicitStrategy +}; // namespace Kratos + +#endif // KRATOS_MPM_EXPLICIT_STRATEGY defined 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..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 @@ -18,15 +18,7 @@ /* 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" +#include "solving_strategies/strategies/residualbased_newton_raphson_strategy.h" // Application includes #include "particle_mechanics_application_variables.h" @@ -72,7 +64,7 @@ template class MPMResidualBasedNewtonRaphsonStrategy - : public SolvingStrategy + : public ResidualBasedNewtonRaphsonStrategy { public: /**@name Type Definitions */ @@ -114,11 +106,12 @@ class MPMResidualBasedNewtonRaphsonStrategy /** Constructors. */ - MPMResidualBasedNewtonRaphsonStrategy( + + MPMResidualBasedNewtonRaphsonStrategy( ModelPart& rModelPart, bool MoveMeshFlag = false - ) - : SolvingStrategy(rModelPart, MoveMeshFlag) + ) : ResidualBasedNewtonRaphsonStrategy( + rModelPart, MoveMeshFlag) { } @@ -131,55 +124,10 @@ class MPMResidualBasedNewtonRaphsonStrategy bool CalculateReactions = false, 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( @@ -192,51 +140,11 @@ class MPMResidualBasedNewtonRaphsonStrategy bool CalculateReactions = false, 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. @@ -244,205 +152,18 @@ class MPMResidualBasedNewtonRaphsonStrategy 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; + typename TSchemeType::Pointer p_scheme = this->GetScheme(); + typename TBuilderAndSolverType::Pointer p_builder_and_solver = this->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 @@ -451,21 +172,21 @@ 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 + << "\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 +196,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 +210,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 @@ -507,44 +228,41 @@ class MPMResidualBasedNewtonRaphsonStrategy 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); + 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"<GetEchoLevel() >= 3 && !is_converged) << "Starting Nonlinear iteration" << std::endl; // Iteration Loop while (is_converged == false && - iteration_number++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) { - if (BaseType::mRebuildLevel > 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 (this->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 +270,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 +279,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); } } @@ -574,7 +292,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 @@ -583,7 +300,7 @@ class MPMResidualBasedNewtonRaphsonStrategy // If converged if (is_converged == true) { - if (mpConvergenceCriteria->GetActualizeRHSflag() == true) + if (this->mpConvergenceCriteria->GetActualizeRHSflag() == true) { TSparseSpace::SetToZero(rb); @@ -591,378 +308,21 @@ 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 (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) + if (iteration_number >= this->mMaxIterationNumber && BaseType::GetModelPart().GetCommunicator().MyPID() == 0) { - GetBuilderAndSolver()->BuildRHS(GetScheme(), BaseType::GetModelPart(), rb); + if (this->GetEchoLevel() > 1) this->MaxIterationsExceeded(); } - DofsArrayType& r_dof_set = GetBuilderAndSolver()->GetDofSet(); - - return mpConvergenceCriteria->PostCriteria(BaseType::GetModelPart(), r_dof_set, rA, rDx, rb); - KRATOS_CATCH( "" ); - + return is_converged; } - /** - * @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/custom_utilities/mpm_explicit_utilities.cpp b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp new file mode 100644 index 000000000000..8ca422b5705a --- /dev/null +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.cpp @@ -0,0 +1,415 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ \. +// _|\_\_| \__,_|\__|\___/ ____/ +// Multi-Physics +// +// License: BSD License +// Kratos default license: kratos/license.txt +// +// Main authors: Peter Wilson +// + +// Project includes +#include "custom_utilities/mpm_explicit_utilities.h" + +namespace Kratos +{ + void MPMExplicitUtilities::CalculateAndAddExplicitInternalForce( + Element& rElement, + const Matrix& rDN_DX, + const Vector& rMPStress, + const double rMPVolume, + const SizeType StrainSize, + Vector& rRightHandSideVector) + { + 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(); + 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++) + { + 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 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 + } + + KRATOS_CATCH("") + } + + /***********************************************************************************/ + /***********************************************************************************/ + + void MPMExplicitUtilities::CalculateAndAddAxisymmetricExplicitInternalForce( + 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, + const 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(); + + + // 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 + if (isCentralDifference) isUpdateMPPositionFromUpdatedMPVelocity = false; + + + // Advance the material point predictor velocity + for (IndexType i = 0; i < dimension; i++) { + 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]; + } + else if (!isUpdateMPPositionFromUpdatedMPVelocity) + { + delta_xg[j] += rDeltaTime * rN[i] * r_nodal_momenta[j] / nodal_mass; + } + } + } + } + + // Update the MP Acceleration + rElement.SetValuesOnIntegrationPoints(MP_ACCELERATION, { MP_Acceleration }, rProcessInfo); + + // Update the MP Velocity corrector + for (IndexType j = 0; j < dimension; j++) + { + MP_Velocity[j] += gamma * rDeltaTime * MP_Acceleration[j]; + } + rElement.SetValuesOnIntegrationPoints(MP_VELOCITY, { MP_Velocity }, rProcessInfo); + + // Update the MP Position + if (isUpdateMPPositionFromUpdatedMPVelocity) + { + for (IndexType j = 0; j < dimension; j++) + { + 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); + + // Update the MP total 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("") + } + + /***********************************************************************************/ + /***********************************************************************************/ + + void MPMExplicitUtilities::CalculateMUSLGridVelocity( + Element& rElement, + const Vector& rN) + { + KRATOS_TRY + + GeometryType& rGeom = rElement.GetGeometry(); + const SizeType dimension = rGeom.WorkingSpaceDimension(); + const SizeType number_of_nodes = rGeom.PointsNumber(); + 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 (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 (IndexType j = 0; j < dimension; j++) + { + r_current_velocity[j] += rN[i] * MP_Mass[0] * MP_Velocity[0][j] / r_nodal_mass; + } + } + } + + KRATOS_CATCH("") + } + + /***********************************************************************************/ + /***********************************************************************************/ + + void MPMExplicitUtilities::CalculateExplicitKinematics( + const ProcessInfo& rCurrentProcessInfo, + Element& rElement, + const Matrix& rDN_DX, + Vector& rMPStrain, + Matrix& rDeformationGradientIncrement, + const SizeType StrainSize) + { + 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(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 + 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 == 3) + { + rMPStrain(2) += 2.0 * strainIncrement(0, 1); //e_xy + } + else if((dimension == 3 && StrainSize == 6)) + { + 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); + if (rCurrentProcessInfo.GetValue(IS_COMPRESSIBLE)) rDeformationGradientIncrement += strainIncrement; + + 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 + + const 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(2, 2) += 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 new file mode 100644 index 000000000000..e3ff6689e56c --- /dev/null +++ b/applications/ParticleMechanicsApplication/custom_utilities/mpm_explicit_utilities.h @@ -0,0 +1,68 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ \. +// _|\_\_| \__,_|\__|\___/ ____/ +// 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 + +// 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; + + 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) CalculateAndAddAxisymmetricExplicitInternalForce(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); + + 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, + 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); + }; // namespace ExplicitIntegrationUtilities +} // namespace Kratos +#endif /* KRATOS_MPM_EXPLICIT_UTILITIES defined */ \ No newline at end of file diff --git a/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h b/applications/ParticleMechanicsApplication/custom_utilities/mpm_search_element_utility.h index f4c1c3f4ad86..dfe03eecbcce 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) { + 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 + #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,6 @@ namespace MPMSearchElementUtility r_geometry[j].Reset(ACTIVE); } - // Search background grid and make element active Vector N; const int max_result = 1000; @@ -85,6 +87,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 && 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) { + if (std::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 = 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]; + 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,11 +179,9 @@ namespace MPMSearchElementUtility } } } - } // end namespace MPMSearchElementUtility } // end namespace Kratos #endif // KRATOS_MPM_SEARCH_ELEMENT_UTILITY - diff --git a/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp b/applications/ParticleMechanicsApplication/particle_mechanics_application.cpp index 428cda76f187..8e18e3c93502 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,14 @@ namespace Kratos // Solver related variables KRATOS_REGISTER_VARIABLE(IGNORE_GEOMETRIC_STIFFNESS); + + // Explicit time integration variables + 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) + 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 80ccc6f647a6..2da7230552df 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,12 @@ namespace Kratos // Solver related variables KRATOS_CREATE_VARIABLE(bool, IGNORE_GEOMETRIC_STIFFNESS) + + // Explicit time integration variables + 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) + 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 304ae9fbda49..e74a39b1ebf4 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,14 @@ namespace Kratos // Solver related variables KRATOS_DEFINE_APPLICATION_VARIABLE(PARTICLE_MECHANICS_APPLICATION, bool, IGNORE_GEOMETRIC_STIFFNESS) + + // Explicit time integration variables + 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) + 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 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..0f3376c54601 --- /dev/null +++ b/applications/ParticleMechanicsApplication/python_scripts/assign_initial_velocity_to_particle_process.py @@ -0,0 +1,64 @@ +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) + + # 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.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! + 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 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..633410a7bf7e --- /dev/null +++ b/applications/ParticleMechanicsApplication/python_scripts/mpm_explicit_solver.py @@ -0,0 +1,111 @@ +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("""{ + "time_integration_method" : "explicit", + "scheme_type" : "central_difference", + "stress_update" : "usf" + }""") + 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) + + 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 + + # Check whether compressibility is considered + 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": + stress_update_option = 10 + stress_update = self.settings["stress_update"].GetString() #0 = USF, 1 = USL, 2 = MUSL + 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, stress_update_option) + grid_model_part.ProcessInfo.SetValue(KratosParticle.IS_EXPLICIT_CENTRAL_DIFFERENCE, False) + 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: + 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) + + return KratosParticle.MPMExplicitScheme( grid_model_part) + + 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() + reform_dofs_at_each_step = 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..b097d0772db5 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", @@ -58,7 +59,9 @@ def GetDefaultSettings(cls): "residual_absolute_tolerance" : 1.0E-9, "max_iteration" : 20, "pressure_dofs" : false, + "compressible" : true, "axis_symmetric_flag" : false, + "consistent_mass_matrix" : false, "block_builder" : true, "move_mesh_flag" : false, "problem_domain_sub_model_part_list" : [], @@ -150,12 +153,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,15 +382,23 @@ 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 + grid_model_part = self.GetGridModelPart(); + grid_model_part.ProcessInfo.SetValue(KratosParticle.IS_EXPLICIT, False) analysis_type = self.settings["analysis_type"].GetString() + is_consistent_mass_matrix = self.settings["consistent_mass_matrix"].GetBool() + 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': 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/particle_from_json_check_result_process.py b/applications/ParticleMechanicsApplication/python_scripts/particle_from_json_check_result_process.py index 16cc70b9f51d..dea459592cb5 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,8 @@ 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"): for component_index, component in enumerate(["_X", "_Y", "_Z"]): values_json = self.data["PARTICLE_" + str(mp.Id)][variable_name +component] 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 5d96e536441c..8c1a89e00e40 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"] = [] @@ -104,7 +104,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]) 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" 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/explicit_tests/axisymmetric_disk/compressible_explicit_axisym_disk_test_materials.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/compressible_explicit_axisym_disk_test_materials.json new file mode 100644 index 000000000000..2c3ae397134c --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/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/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..bf49eeab633e --- /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","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 + } + }] + }, + "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_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_parameters.json b/applications/ParticleMechanicsApplication/tests/explicit_tests/axisymmetric_disk/tri_compressible_explicit_axisym_disk_test_parameters.json new file mode 100644 index 000000000000..88261051a49e --- /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/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","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 + } + }] + }, + "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/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..7b7413c07cfd --- /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.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/central_difference_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/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..c2cc9f660344 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/central_difference_explicit_oscillating_point_test_results.json @@ -0,0 +1 @@ +{"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_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..76f66d9d9307 --- /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.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","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.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 new file mode 100644 index 000000000000..610e9c56363d --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_Y_compressible_test_results.json @@ -0,0 +1 @@ +{"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 new file mode 100644 index 000000000000..4916466d2808 --- /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.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/explicit_oscillating_point_gravity_test_results.json", + "model_part_name" : "MPM_Material", + "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 new file mode 100644 index 000000000000..ad8352963947 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/explicit_oscillating_point_gravity_test_results.json @@ -0,0 +1 @@ +{"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/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/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..766dc39c854d --- /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.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/musl_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/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..77d8af0c8e49 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/musl_explicit_oscillating_point_test_results.json @@ -0,0 +1 @@ +{"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/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/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..527b31faa423 --- /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.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/usf_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/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..debab71d670c --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usf_explicit_oscillating_point_test_results.json @@ -0,0 +1 @@ +{"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 new file mode 100644 index 000000000000..3089e3890500 --- /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.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/usl_explicit_oscillating_point_test_results.json", + "model_part_name" : "MPM_Material", + "time_frequency" : 0.05 + } + }] +} \ No newline at end of file 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..4056e9b90c13 --- /dev/null +++ b/applications/ParticleMechanicsApplication/tests/explicit_tests/oscillating_point/usl_explicit_oscillating_point_test_results.json @@ -0,0 +1 @@ +{"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 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/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..6e662a66bf0b --- /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 a95a25ed2794..69e65a291edd 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" @@ -90,4 +93,38 @@ 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" + +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" + +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" + +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" + +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" + +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 36bc2c9a65bc..974dd6ae1b38 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 @@ -28,6 +29,19 @@ 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 +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 +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) from test_generate_mpm_particle import TestGenerateMPMParticle as TTestGenerateMPMParticle @@ -80,22 +94,30 @@ 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.addTest(TBeamCantileverDynamicConsistentMassTest('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')) + nightSuite.addTest(TExplicitOscillatingPointGravityTest('test_execution')) + 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 ## For very long tests that should not be in nighly and you can use to validate diff --git a/applications/PoromechanicsApplication/CMakeLists.txt b/applications/PoromechanicsApplication/CMakeLists.txt index 29c203a76590..cfd6fd5c6059 100644 --- a/applications/PoromechanicsApplication/CMakeLists.txt +++ b/applications/PoromechanicsApplication/CMakeLists.txt @@ -27,6 +27,8 @@ 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/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/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_2D_law.cpp b/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_2D_law.cpp new file mode 100644 index 000000000000..1a55191189eb --- /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(fabs(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(fabs(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.YieldStress / (2.0 * (1.0 + rVariables.PoissonCoefficient)); + + double friction_stress = fabs(shear_modulus * 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(); + + 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 new file mode 100644 index 000000000000..d61f5398d33b --- /dev/null +++ b/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_3D_law.cpp @@ -0,0 +1,354 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ ` +// _|\_\_| \__,_|\__|\___/ ____/ +// 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(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; + } else { + 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(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.YoungModulus = MaterialProperties[YOUNG_MODULUS]; + rVariables.PoissonCoefficient = MaterialProperties[POISSON_RATIO]; + rVariables.MaxCompresiveStress = MaterialProperties[MAX_COMPRESSIVE_STRESS]; + rVariables.MaxTensileStress = MaterialProperties[MAX_TENSILE_STRESS]; + rVariables.YieldStress = rVariables.YoungModulus; + 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= rVariables.YoungModulus * 1.0e-7; + } + + 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[1] < 0.0, rStressVector[1] < 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.YieldStress / (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..f5431a23aa3f --- /dev/null +++ b/applications/PoromechanicsApplication/custom_constitutive/simplified_bilinear_3D_law.hpp @@ -0,0 +1,114 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ ` +// _|\_\_| \__,_|\__|\___/ ____/ +// 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: + + // Member Variables + +//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + + 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_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_python/add_custom_constitutive_laws_to_python.cpp b/applications/PoromechanicsApplication/custom_python/add_custom_constitutive_laws_to_python.cpp index 7f2085bf4927..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 @@ -18,6 +18,8 @@ #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/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" @@ -61,6 +63,12 @@ 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_< SimplifiedBilinear2DLaw, SimplifiedBilinear2DLaw::Pointer, ConstitutiveLaw > + (m, "SimplifiedBilinear2DLaw") + .def( py::init<>() ); py::class_< LinearElastic3DLaw, LinearElastic3DLaw::Pointer, ConstitutiveLaw > (m, "LinearElasticSolid3DLaw") 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")); diff --git a/applications/PoromechanicsApplication/poromechanics_application.cpp b/applications/PoromechanicsApplication/poromechanics_application.cpp index fbd899fd93ba..61263d285879 100644 --- a/applications/PoromechanicsApplication/poromechanics_application.cpp +++ b/applications/PoromechanicsApplication/poromechanics_application.cpp @@ -181,6 +181,8 @@ 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("SimplifiedBilinear2DLaw",mSimplifiedBilinear2DLaw); KRATOS_REGISTER_CONSTITUTIVE_LAW("LinearElasticSolid3DLaw", mLinearElastic3DLaw); KRATOS_REGISTER_CONSTITUTIVE_LAW("LinearElasticPlaneStrainSolid2DLaw", mLinearElasticPlaneStrain2DLaw); @@ -266,6 +268,9 @@ void KratosPoromechanicsApplication::Register() KRATOS_REGISTER_VARIABLE( NODAL_JOINT_DAMAGE ) 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.h b/applications/PoromechanicsApplication/poromechanics_application.h index e27cd66137d3..5271e2ebeef3 100644 --- a/applications/PoromechanicsApplication/poromechanics_application.h +++ b/applications/PoromechanicsApplication/poromechanics_application.h @@ -50,6 +50,8 @@ #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/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" @@ -195,6 +197,8 @@ const BilinearCohesive3DLaw mBilinearCohesive3DLaw; const BilinearCohesive2DLaw mBilinearCohesive2DLaw; const ExponentialCohesive3DLaw mExponentialCohesive3DLaw; const ExponentialCohesive2DLaw mExponentialCohesive2DLaw; +const SimplifiedBilinear3DLaw mSimplifiedBilinear3DLaw; +const SimplifiedBilinear2DLaw mSimplifiedBilinear2DLaw; const LocalDamageFlowRule mLocalDamageFlowRule; const NonlocalDamageFlowRule mNonlocalDamageFlowRule; diff --git a/applications/PoromechanicsApplication/poromechanics_application_variables.cpp b/applications/PoromechanicsApplication/poromechanics_application_variables.cpp index 71929f371bc7..acced9ecb452 100644 --- a/applications/PoromechanicsApplication/poromechanics_application_variables.cpp +++ b/applications/PoromechanicsApplication/poromechanics_application_variables.cpp @@ -69,4 +69,7 @@ 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 ) +KRATOS_CREATE_VARIABLE( double, MAX_TENSILE_STRESS ) } diff --git a/applications/PoromechanicsApplication/poromechanics_application_variables.h b/applications/PoromechanicsApplication/poromechanics_application_variables.h index c292dd4c74ef..4583ca8cc03b 100644 --- a/applications/PoromechanicsApplication/poromechanics_application_variables.h +++ b/applications/PoromechanicsApplication/poromechanics_application_variables.h @@ -81,6 +81,9 @@ 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 ) +KRATOS_DEFINE_APPLICATION_VARIABLE( POROMECHANICS_APPLICATION, double, MAX_TENSILE_STRESS ) } #endif /* KRATOS_POROMECHANICS_APPLICATION_VARIABLES_H_INCLUDED */ 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_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); } 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) 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 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) diff --git a/applications/StructuralMechanicsApplication/custom_conditions/base_load_condition.cpp b/applications/StructuralMechanicsApplication/custom_conditions/base_load_condition.cpp index 3aefc4c0f1bc..afc712771571 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(); @@ -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 ffca69a2b136..56210a845a70 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. @@ -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; diff --git a/applications/StructuralMechanicsApplication/custom_conditions/displacement_control_condition.cpp b/applications/StructuralMechanicsApplication/custom_conditions/displacement_control_condition.cpp index 8008314c66fa..8f658f90b5f8 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 @@ -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..36168beaca1b 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. @@ -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_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/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; /** 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 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 c1ac661bcad3..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; @@ -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..4f91c5f08059 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(); @@ -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 ) { @@ -1325,89 +1325,6 @@ 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 ); -} /***********************************************************************************/ /***********************************************************************************/ diff --git a/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.h b/applications/StructuralMechanicsApplication/custom_elements/base_solid_element.h index 098c2822c6f3..0a33f3cd20d0 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. @@ -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; @@ -457,6 +457,7 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) BaseSolidElement const ProcessInfo& rCurrentProcessInfo ) override; + /** * @brief Set a bool Value on the Element Constitutive Law * @param rVariable The variable we want to set @@ -553,95 +554,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 diff --git a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_2D2N.cpp b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_2D2N.cpp index 74fac473e5b6..c73f25476f1b 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) { @@ -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 @@ -834,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 5523f603cf5a..37dbcc5a2aac 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, @@ -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; @@ -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..57ae8289dc53 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) { @@ -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, @@ -1553,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 3f65369958eb..28a57ef3de44 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_3D2N.hpp +++ b/applications/StructuralMechanicsApplication/custom_elements/cr_beam_element_3D2N.hpp @@ -213,20 +213,20 @@ class CrBeamElement3D2N : public Element void AddExplicitContribution(const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable >& rDestinationVariable, + const Variable >& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo) override; 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 @@ -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..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; @@ -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) @@ -2044,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); @@ -2061,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 2c25b54abf06..52353b1423c4 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/isotropic_shell_element.hpp +++ b/applications/StructuralMechanicsApplication/custom_elements/isotropic_shell_element.hpp @@ -115,18 +115,14 @@ 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; 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..0178304af8a7 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; @@ -973,25 +970,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 @@ -1058,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; @@ -1096,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 334e59219bd4..b0f7878311bb 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; @@ -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; @@ -133,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, @@ -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/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/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..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); @@ -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..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 @@ -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/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/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 diff --git a/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.cpp b/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.cpp index b783c55fb1c4..71c4b13451dc 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 @@ -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 @@ -667,7 +640,7 @@ void TrussElement3D2N::WriteTransformationCoordinates( void TrussElement3D2N::AddExplicitContribution( const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable& rDestinationVariable, + const Variable& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) { @@ -693,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 2ab52f880279..d41b822bdb8e 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.hpp +++ b/applications/StructuralMechanicsApplication/custom_elements/truss_element_3D2N.hpp @@ -117,16 +117,16 @@ namespace Kratos std::vector& rOutput, const ProcessInfo& rCurrentProcessInfo) override; - void GetValueOnIntegrationPoints( - const Variable& rVariable, - std::vector& rValues, - const ProcessInfo& rCurrentProcessInfo) override; - - void GetValueOnIntegrationPoints( + 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 * @param rinternalForces The current updated internal forces @@ -139,20 +139,6 @@ namespace Kratos */ void CreateTransformationMatrix(BoundedMatrix& rRotationMatrix); - void CalculateOnIntegrationPoints( - const Variable& rVariable, - 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, @@ -189,7 +175,7 @@ namespace Kratos void AddExplicitContribution( const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable& rDestinationVariable, + const Variable& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) override; @@ -204,22 +190,22 @@ namespace Kratos */ void AddExplicitContribution(const VectorType& rRHSVector, const Variable& rRHSVariable, - Variable >& rDestinationVariable, + const Variable >& rDestinationVariable, const ProcessInfo& rCurrentProcessInfo ) override; 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; 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 ///@{ diff --git a/applications/StructuralMechanicsApplication/custom_processes/impose_rigid_movement_process.cpp b/applications/StructuralMechanicsApplication/custom_processes/impose_rigid_movement_process.cpp index 47edb3ada76f..ee6be7f83f20 100644 --- a/applications/StructuralMechanicsApplication/custom_processes/impose_rigid_movement_process.cpp +++ b/applications/StructuralMechanicsApplication/custom_processes/impose_rigid_movement_process.cpp @@ -62,54 +62,45 @@ 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; + 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); - } 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); + master_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_list_variables.push_back(&r_variable_x); + const Variable& r_variable_y = KratosComponents>::Get(master_variable_name+"_Y"); + master_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_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 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); - } 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); + slave_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_list_variables.push_back(&r_variable_x); + const Variable& r_variable_y = KratosComponents>::Get(slave_variable_name+"_Y"); + slave_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_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); + for (auto& r_var : master_list_variables) + slave_list_variables.push_back(r_var); } // Getting index of the master node @@ -121,8 +112,7 @@ 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_components_list_variables.size(); + const SizeType number_of_variables = master_list_variables.size(); // We get the relation and constant const double relation = mThisParameters["relation"].GetDouble(); @@ -141,12 +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_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); + 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); } } 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) diff --git a/applications/StructuralMechanicsApplication/custom_processes/spr_error_process.cpp b/applications/StructuralMechanicsApplication/custom_processes/spr_error_process.cpp index ecf03a078ca7..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) { @@ -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 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..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_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 6c5771ab3100..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 { @@ -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.cpp b/applications/StructuralMechanicsApplication/custom_response_functions/adjoint_elements/adjoint_finite_difference_base_element.cpp index f87ebfead73c..420d8e1cae42 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 @@ -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 c02cb9e2dcb5..846b1930578c 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 { @@ -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, @@ -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; @@ -466,12 +452,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 0a293a9a2ed3..c68125de2548 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/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; 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 89a6b555c234..e7f1bb6e8960 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 2d908e93c0c8..e39cb1211864 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/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 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 ad4ac46b1a71..7db67ee212cd 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 5bfc134911c3..f14bb9a57c6a 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_strategies/custom_strategies/prebuckling_strategy.hpp b/applications/StructuralMechanicsApplication/custom_strategies/custom_strategies/prebuckling_strategy.hpp index 0fcf4ebb9b45..8582055a0402 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,10 +110,7 @@ class PrebucklingStrategy BuilderAndSolverPointerType pBuilderAndSolver, typename ConvergenceCriteriaType::Pointer pConvergenceCriteria, int MaxIteration, - double InitialLoadIncrement, - double SmallLoadIncrement, - double PathFollowingStep, - double ConvergenceRatio ) + Parameters BucklingSettings ) : SolvingStrategy(rModelPart) { KRATOS_TRY @@ -127,13 +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 = BucklingSettings["make_matrices_symmetric"].GetBool(); // Set Eigensolver flags mpEigenSolver->SetDofSetIsInitializedFlag(false); @@ -552,6 +552,13 @@ class PrebucklingStrategy // between the current and previous step 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) ); + } + this->pGetEigenSolver()->GetLinearSystemSolver()->Solve( rStiffnessMatrixPrevious, rStiffnessMatrix, @@ -745,6 +752,8 @@ class PrebucklingStrategy double mLambda = 0.0; double mLambdaPrev = 1.0; + bool mMakeMatricesSymmetricFlag; + ///@} ///@name Private Operators ///@{ 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(); 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 diff --git a/applications/StructuralMechanicsApplication/python_scripts/structural_mechanics_prebuckling_solver.py b/applications/StructuralMechanicsApplication/python_scripts/structural_mechanics_prebuckling_solver.py index 7fe367696f4b..5967a82d5445 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", @@ -116,7 +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 ) 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") diff --git a/applications/StructuralMechanicsApplication/tests/test_prebuckling_analysis.py b/applications/StructuralMechanicsApplication/tests/test_prebuckling_analysis.py index 4e68f20caef6..94edaca1d695 100644 --- a/applications/StructuralMechanicsApplication/tests/test_prebuckling_analysis.py +++ b/applications/StructuralMechanicsApplication/tests/test_prebuckling_analysis.py @@ -91,9 +91,19 @@ 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 + } + """) + + 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 } """) @@ -111,10 +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 ) + buckling_settings ) eig_strategy.SetEchoLevel(echo) LoadFactor = [] for i in range(iterations): diff --git a/applications/TrilinosApplication/custom_strategies/builder_and_solvers/trilinos_block_builder_and_solver_periodic.h b/applications/TrilinosApplication/custom_strategies/builder_and_solvers/trilinos_block_builder_and_solver_periodic.h index 46d42baf4d79..4a6b537ec761 100644 --- a/applications/TrilinosApplication/custom_strategies/builder_and_solvers/trilinos_block_builder_and_solver_periodic.h +++ b/applications/TrilinosApplication/custom_strategies/builder_and_solvers/trilinos_block_builder_and_solver_periodic.h @@ -144,7 +144,7 @@ class TrilinosBlockBuilderAndSolverPeriodic { KRATOS_TRY; - unsigned int Rank = this->mrComm.MyPID(); + int Rank = this->mrComm.MyPID(); // Count the Dofs on this partition (on periodic node pairs, only the dofs on the node with higher Id are counted) int DofCount = 0; @@ -430,7 +430,7 @@ class TrilinosBlockBuilderAndSolverPeriodic itCond->GetDofList(DofList,rProcessInfo); for(typename Condition::DofsVectorType::iterator iDof = DofList.begin() ; iDof != DofList.end() ; ++iDof) if ( (*iDof)->Id() == FirstNode) - ExtraDofs[ (unsigned int)( (*iDof)->GetSolutionStepValue(PARTITION_INDEX) ) ]++; + ExtraDofs[(*iDof)->GetSolutionStepValue(PARTITION_INDEX)]++; rGeom[0].GetValue(mPeriodicIdVar) = rGeom[0].FastGetSolutionStepValue(mPeriodicIdVar); } diff --git a/applications/TrilinosApplication/custom_strategies/convergencecriterias/trilinos_displacement_criteria.h b/applications/TrilinosApplication/custom_strategies/convergencecriterias/trilinos_displacement_criteria.h index 3fbfbd372364..cf4ab39ee79f 100644 --- a/applications/TrilinosApplication/custom_strategies/convergencecriterias/trilinos_displacement_criteria.h +++ b/applications/TrilinosApplication/custom_strategies/convergencecriterias/trilinos_displacement_criteria.h @@ -278,7 +278,7 @@ class TrilinosDisplacementCriteria : public ConvergenceCriteria< TSparseSpace, T TDataType local_ReferenceDispNorm = TDataType(); TDataType value; - const double rank = rModelPart.GetCommunicator().MyPID(); // double because I want to compare with PARTITION_INDEX + const int rank = rModelPart.GetCommunicator().MyPID(); for(auto it_dof = rDofSet.begin() ; it_dof != rDofSet.end() ; ++it_dof) { diff --git a/applications/TrilinosApplication/custom_strategies/convergencecriterias/trilinos_residual_criteria.h b/applications/TrilinosApplication/custom_strategies/convergencecriterias/trilinos_residual_criteria.h index 657afb44751a..ca9c2775f70f 100644 --- a/applications/TrilinosApplication/custom_strategies/convergencecriterias/trilinos_residual_criteria.h +++ b/applications/TrilinosApplication/custom_strategies/convergencecriterias/trilinos_residual_criteria.h @@ -99,7 +99,7 @@ class TrilinosResidualCriteria : public ResidualCriteria< TSparseSpace, TDenseSp TDataType residual_solution_norm = TDataType(); long int local_dof_num = 0; - const double rank = rB.Comm().MyPID(); // To compare with PARTITION_INDEX, which is a double variable + const int rank = rB.Comm().MyPID(); // Loop over Dofs #pragma omp parallel for reduction(+:residual_solution_norm,local_dof_num) diff --git a/applications/TrilinosApplication/custom_utilities/trilinos_cutting_app.h b/applications/TrilinosApplication/custom_utilities/trilinos_cutting_app.h index b7f64b72e96b..cb07754a2ac0 100644 --- a/applications/TrilinosApplication/custom_utilities/trilinos_cutting_app.h +++ b/applications/TrilinosApplication/custom_utilities/trilinos_cutting_app.h @@ -1063,7 +1063,7 @@ class TrilinosCuttingApplication pnode->X0() = weight * (it_node1->X0()) + (1.0 - weight) * it_node2->X0(); pnode->Y0() = weight * (it_node1->Y0()) + (1.0 - weight) * it_node2->Y0(); pnode->Z0() = weight * (it_node1->Z0()) + (1.0 - weight) * it_node2->Z0(); - pnode->FastGetSolutionStepValue(PARTITION_INDEX) = double(partition_new_nodes[i]) ; + pnode->FastGetSolutionStepValue(PARTITION_INDEX) = partition_new_nodes[i]; new_model_part.Nodes().push_back(pnode); } @@ -1382,7 +1382,7 @@ class TrilinosCuttingApplication double* node1_data = it->GetValue(FATHER_NODES)[1].SolutionStepData().Data(0); double weight = it->GetValue(WEIGHT_FATHER_NODES); double* step_data = (it)->SolutionStepData().Data(0); - double partition_index= it->FastGetSolutionStepValue(PARTITION_INDEX); + int partition_index= it->FastGetSolutionStepValue(PARTITION_INDEX); //now we only have to copy the information from node_data to step_data for (int j = 0; j < step_data_size; j++) //looping all the variables and interpolating using weight diff --git a/applications/TrilinosApplication/custom_utilities/trilinos_cutting_iso_app.h b/applications/TrilinosApplication/custom_utilities/trilinos_cutting_iso_app.h index 1e49806c356a..d475e86c2b10 100644 --- a/applications/TrilinosApplication/custom_utilities/trilinos_cutting_iso_app.h +++ b/applications/TrilinosApplication/custom_utilities/trilinos_cutting_iso_app.h @@ -1284,7 +1284,7 @@ class TrilinosCuttingIsosurfaceApplication double* node1_data = it->GetValue(FATHER_NODES)[1].SolutionStepData().Data(0); double weight = it->GetValue(WEIGHT_FATHER_NODES); double* step_data = (it)->SolutionStepData().Data(0); - double partition_index= it->FastGetSolutionStepValue(PARTITION_INDEX); + int partition_index= it->FastGetSolutionStepValue(PARTITION_INDEX); //now we only have to copy the information from node_data to step_data for (int j = 0; j < step_data_size; j++) //looping all the variables and interpolating using weight 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(); diff --git a/kratos/containers/data_value_container.h b/kratos/containers/data_value_container.h index f7c50750e2fa..a4b207ed00e4 100644 --- a/kratos/containers/data_value_container.h +++ b/kratos/containers/data_value_container.h @@ -211,17 +211,18 @@ 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()) - return *static_cast(i->second); + if ((i = std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.SourceKey()))) != mData.end()) + return *(static_cast(i->second) + rThisVariable.GetComponentIndex()); #ifdef KRATOS_DEBUG if(OpenMPUtils::IsInParallel() != 0) 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); + return *(static_cast(mData.back().second) + rThisVariable.GetComponentIndex()); } //TODO: make the variable of the constant version consistent with the one of the "classical" one @@ -233,8 +234,8 @@ 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); + 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,10 +262,13 @@ 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()) - *static_cast(i->second) = rValue; - else - mData.push_back(ValueType(&rThisVariable,new TDataType(rValue))); //TODO: this shall be insert not push_back + if ((i = std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.SourceKey()))) != mData.end()) { + *(static_cast(i->second) + rThisVariable.GetComponentIndex()) = 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) @@ -276,7 +280,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 +308,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 +401,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; } }; diff --git a/kratos/containers/variable.h b/kratos/containers/variable.h index 6cfd987cfa90..1d728279a69d 100644 --- a/kratos/containers/variable.h +++ b/kratos/containers/variable.h @@ -112,10 +112,53 @@ class Variable : public VariableData } /** + * @brief Constructor for creating a component of other variable + * @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& rNewName, + TSourceVariableType* pSourceVariable, + char ComponentIndex, + const TDataType Zero = TDataType() + ) + : VariableData(rNewName, sizeof(TDataType), pSourceVariable, ComponentIndex), + mZero(Zero) + { + } + + /** + * @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. * @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), + mpTimeDerivativeVariable(rOtherVariable.mpTimeDerivativeVariable) + { + } /// Destructor. ~Variable() override {} @@ -213,7 +256,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) ; + } } /** @@ -263,7 +311,18 @@ class Variable : public VariableData */ static const VariableType& StaticObject() { - return msStaticObject; + const static Variable static_object("NONE"); + return static_object; + } + + TDataType& GetValue(void* pSource) const + { + return GetValueByIndex(static_cast(pSource),GetComponentIndex()); + } + + const TDataType& GetValue(const void* pSource) const + { + return GetValueByIndex(static_cast(pSource),GetComponentIndex()); } ///@} @@ -289,6 +348,10 @@ class Variable : public VariableData return mZero; } + const void* pZero() const override { + return &mZero; + } + ///@} ///@name Inquiry ///@{ @@ -305,6 +368,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(); } @@ -314,7 +383,7 @@ class Variable : public VariableData */ void PrintInfo(std::ostream& rOStream) const override { - rOStream << Name() << " variable"; + rOStream << Info(); } /// Print object's data. @@ -389,6 +458,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 ///@{ @@ -441,9 +525,6 @@ class Variable : public VariableData ///@} -template -const Variable Variable::msStaticObject("NONE"); - ///@name Type Definitions ///@{ diff --git a/kratos/containers/variable_component.h b/kratos/containers/variable_component.h index 0328302c1110..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), true, rNewAdaptor.GetComponentIndex()), - mAdaptor(rNewAdaptor), + : BaseType(rComponentName, sizeof(DataType),&rNewAdaptor.GetSourceVariable(), rNewAdaptor.GetComponentIndex()), mpSourceVariable(&rNewAdaptor.GetSourceVariable()), mpTimeDerivativeVariable(pTimeDerivativeVariable) { SetKey(GenerateKey(rSourceName, sizeof(DataType), true, ComponentIndex)); @@ -110,7 +105,7 @@ class VariableComponent : public VariableData /// Copy constructor. VariableComponent(const VariableComponent& rOther) - : BaseType(rOther), mAdaptor(rOther.mAdaptor) {} + : BaseType(rOther), mpSourceVariable(rOther.mpSourceVariable) {} /// Destructor. ~VariableComponent() override {} @@ -141,32 +136,28 @@ 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() { - 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 { - rOStream << Name() << " component of " << mAdaptor.GetSourceVariable().Name() << " variable : " << *static_cast(pSource) ; + rOStream << Name() << " component of " << GetSourceVariable().Name() << " variable : " << *static_cast(pSource) ; } ///@} @@ -182,14 +173,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. @@ -221,7 +212,7 @@ class VariableComponent : public VariableData VariableComponent& operator=(const VariableComponent& rOther) { BaseType::operator=(rOther); - mAdaptor = rOther.mAdaptor; + mpSourceVariable = rOther.mpSourceVariable; } ///@} @@ -252,12 +243,11 @@ class VariableComponent : public VariableData static const VariableComponent msStaticObject; - ///@} ///@name Member Variables ///@{ - TAdaptorType mAdaptor; + const SourceVariableType* mpSourceVariable; const VariableComponentType* mpTimeDerivativeVariable = nullptr; /// Definition of the pointer to the variable for the time derivative @@ -274,6 +264,21 @@ class VariableComponent : public VariableData ///@name Private Operations ///@{ + /// 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]; + } + + template + const DataType& GetValueByIndex(const TValueType& rValue, std::size_t index) const + { + return rValue[index]; + } + ///@} ///@name Private Access @@ -297,9 +302,6 @@ class VariableComponent : public VariableData ///@} -template -const VariableComponent VariableComponent::msStaticObject("NONE", "NONE", 0, TAdaptorType::StaticObject()); - ///@name Type Definitions ///@{ diff --git a/kratos/containers/variable_data.cpp b/kratos/containers/variable_data.cpp index a8aae1697fbe..2eee261bf6a2 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(this), 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 5bc2ed668186..080d120bbbd1 100644 --- a/kratos/containers/variable_data.h +++ b/kratos/containers/variable_data.h @@ -177,11 +177,23 @@ class KRATOS_API(KRATOS_CORE) VariableData ///@name Access ///@{ + 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); @@ -206,6 +218,27 @@ 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); + } + + const VariableData& GetSourceVariable() const + { + 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 @@ -267,6 +300,7 @@ class KRATOS_API(KRATOS_CORE) VariableData mName = rOtherVariable.mName; mKey = rOtherVariable.mKey; mSize = rOtherVariable.mSize; + mpSourceVariable = rOtherVariable.mpSourceVariable; mIsComponent = rOtherVariable.mIsComponent; return *this; @@ -276,8 +310,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 @@ -298,8 +335,10 @@ class KRATOS_API(KRATOS_CORE) VariableData std::size_t mSize; - bool mIsComponent; + const VariableData* mpSourceVariable; + bool mIsComponent; + ///@} ///@name Private Operations ///@{ diff --git a/kratos/containers/variables_list.h b/kratos/containers/variables_list.h index d57252a34f48..f99ee51cccb5 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,15 +263,21 @@ 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", ""); + if (Has(ThisVariable)) return; + if(ThisVariable.IsComponent()){ + Add(ThisVariable.GetSourceVariable()); + return; + } + 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); } @@ -338,12 +344,12 @@ namespace Kratos 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()); } @@ -368,13 +374,17 @@ namespace Kratos bool Has(const VariableData& rThisVariable) const { + if(rThisVariable.IsComponent()){ + return Has(rThisVariable.GetSourceVariable()); + } + 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 @@ -489,9 +499,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; diff --git a/kratos/containers/variables_list_data_value_container.h b/kratos/containers/variables_list_data_value_container.h index 7472086426ca..fd62c5efbd03 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 @@ -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 diff --git a/kratos/containers/vector_component_adaptor.h b/kratos/containers/vector_component_adaptor.h index 5421464d7a88..219bd75250d5 100644 --- a/kratos/containers/vector_component_adaptor.h +++ b/kratos/containers/vector_component_adaptor.h @@ -114,7 +114,9 @@ class VectorComponentAdaptor static VectorComponentAdaptor const& StaticObject() { - return msStaticObject; + + static VectorComponentAdaptor const static_object = VectorComponentAdaptor(VectorComponentAdaptor::SourceVariableType::StaticObject(), 0); + return static_object; } ///@} @@ -206,8 +208,6 @@ class VectorComponentAdaptor ///@name Static Member Variables ///@{ - static VectorComponentAdaptor const msStaticObject; - ///@} ///@name Member Variables ///@{ @@ -253,9 +253,6 @@ class VectorComponentAdaptor ///@} -template -const VectorComponentAdaptor VectorComponentAdaptor::msStaticObject = VectorComponentAdaptor(VectorComponentAdaptor::SourceVariableType::StaticObject(), 0); - ///@name Type Definitions ///@{ diff --git a/kratos/elements/levelset_convection_element_simplex.h b/kratos/elements/levelset_convection_element_simplex.h index a904ec84fe56..4f04e3df277d 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(TIME_INTEGRATION_THETA) ? rCurrentProcessInfo[TIME_INTEGRATION_THETA] : 0.5; 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/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 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 diff --git a/kratos/includes/communicator.h b/kratos/includes/communicator.h index 448170cafb78..0209da80a6d0 100644 --- a/kratos/includes/communicator.h +++ b/kratos/includes/communicator.h @@ -206,6 +206,12 @@ class KRATOS_API(KRATOS_CORE) Communicator virtual int TotalProcesses() const; + SizeType GlobalNumberOfNodes() const; + + SizeType GlobalNumberOfElements() const; + + SizeType GlobalNumberOfConditions() const; + SizeType GetNumberOfColors() const; void SetNumberOfColors(SizeType NewNumberOfColors); diff --git a/kratos/includes/condition.h b/kratos/includes/condition.h index eded6518b5d7..6717fd207540 100644 --- a/kratos/includes/condition.h +++ b/kratos/includes/condition.h @@ -978,49 +978,55 @@ class Condition : public GeometricalObject * Note, that these functions expect a std::vector of values for the specified variable type that * contains a value for each integration point! * CalculateValueOnIntegrationPoints: calculates the values of given Variable. - * these methods are: OPTIONAL */ virtual void CalculateOnIntegrationPoints(const Variable& rVariable, std::vector& rOutput, const ProcessInfo& rCurrentProcessInfo) { + this->GetValueOnIntegrationPoints(rVariable, rOutput, rCurrentProcessInfo); } virtual void CalculateOnIntegrationPoints(const Variable& rVariable, std::vector& rOutput, const ProcessInfo& rCurrentProcessInfo) { + this->GetValueOnIntegrationPoints(rVariable, rOutput, rCurrentProcessInfo); } virtual void CalculateOnIntegrationPoints(const Variable& rVariable, std::vector& rOutput, const ProcessInfo& rCurrentProcessInfo) { + this->GetValueOnIntegrationPoints(rVariable, rOutput, rCurrentProcessInfo); } virtual void CalculateOnIntegrationPoints(const Variable >& rVariable, - std::vector< array_1d >& Output, + std::vector< array_1d >& rOutput, const ProcessInfo& rCurrentProcessInfo) { + this->GetValueOnIntegrationPoints(rVariable, rOutput, rCurrentProcessInfo); } virtual void CalculateOnIntegrationPoints(const Variable >& rVariable, - std::vector< array_1d >& Output, + std::vector< array_1d >& rOutput, const ProcessInfo& rCurrentProcessInfo) { + this->GetValueOnIntegrationPoints(rVariable, rOutput, rCurrentProcessInfo); } virtual void CalculateOnIntegrationPoints(const Variable& rVariable, - std::vector< Vector >& Output, + std::vector< Vector >& rOutput, const ProcessInfo& rCurrentProcessInfo) { + this->GetValueOnIntegrationPoints(rVariable, rOutput, rCurrentProcessInfo); } virtual void CalculateOnIntegrationPoints(const Variable& rVariable, - std::vector< Matrix >& Output, + std::vector< Matrix >& rOutput, const ProcessInfo& rCurrentProcessInfo) { + this->GetValueOnIntegrationPoints(rVariable, rOutput, rCurrentProcessInfo); } /** @@ -1074,42 +1080,49 @@ class Condition : public GeometricalObject //GET ON INTEGRATION POINTS METHODS + // KRATOS_DEPRECATED_MESSAGE("This is legacy version, please use \"CalculateOnIntegrationPoints\"") virtual void GetValueOnIntegrationPoints(const Variable& rVariable, std::vector& rValues, const ProcessInfo& rCurrentProcessInfo) { } + // KRATOS_DEPRECATED_MESSAGE("This is legacy version, please use \"CalculateOnIntegrationPoints\"") virtual void GetValueOnIntegrationPoints(const Variable& rVariable, std::vector& rValues, const ProcessInfo& rCurrentProcessInfo) { } + // KRATOS_DEPRECATED_MESSAGE("This is legacy version, please use \"CalculateOnIntegrationPoints\"") virtual void GetValueOnIntegrationPoints(const Variable& rVariable, std::vector& rValues, const ProcessInfo& rCurrentProcessInfo) { } + // KRATOS_DEPRECATED_MESSAGE("This is legacy version, please use \"CalculateOnIntegrationPoints\"") virtual void GetValueOnIntegrationPoints(const Variable >& rVariable, std::vector >& rValues, const ProcessInfo& rCurrentProcessInfo) { } + // KRATOS_DEPRECATED_MESSAGE("This is legacy version, please use \"CalculateOnIntegrationPoints\"") virtual void GetValueOnIntegrationPoints(const Variable >& rVariable, std::vector >& rValues, const ProcessInfo& rCurrentProcessInfo) { } + // KRATOS_DEPRECATED_MESSAGE("This is legacy version, please use \"CalculateOnIntegrationPoints\"") virtual void GetValueOnIntegrationPoints(const Variable& rVariable, std::vector& rValues, const ProcessInfo& rCurrentProcessInfo) { } + // KRATOS_DEPRECATED_MESSAGE("This is legacy version, please use \"CalculateOnIntegrationPoints\"") virtual void GetValueOnIntegrationPoints(const Variable& rVariable, std::vector& rValues, const ProcessInfo& rCurrentProcessInfo) diff --git a/kratos/includes/define.h b/kratos/includes/define.h index a6f465048d7f..f20c474fedae 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,21 +179,21 @@ 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 #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,22 +206,22 @@ 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 #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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -797,7 +797,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){ */ diff --git a/kratos/includes/element.h b/kratos/includes/element.h index 8c35f2d359a1..b61647ad49f8 100644 --- a/kratos/includes/element.h +++ b/kratos/includes/element.h @@ -984,49 +984,62 @@ class Element : public GeometricalObject * Note, that these functions expect a std::vector of values for the specified variable type that * contains a value for each integration point! * CalculateValueOnIntegrationPoints: calculates the values of given Variable. - * these methods are: OPTIONAL */ virtual void CalculateOnIntegrationPoints(const Variable& rVariable, std::vector& rOutput, const ProcessInfo& rCurrentProcessInfo) { + this->GetValueOnIntegrationPoints(rVariable, rOutput, rCurrentProcessInfo); } virtual void CalculateOnIntegrationPoints(const Variable& rVariable, std::vector& rOutput, const ProcessInfo& rCurrentProcessInfo) { + this->GetValueOnIntegrationPoints(rVariable, rOutput, rCurrentProcessInfo); } virtual void CalculateOnIntegrationPoints(const Variable& rVariable, std::vector& rOutput, const ProcessInfo& rCurrentProcessInfo) { + this->GetValueOnIntegrationPoints(rVariable, rOutput, rCurrentProcessInfo); } virtual void CalculateOnIntegrationPoints(const Variable >& rVariable, std::vector< array_1d >& rOutput, const ProcessInfo& rCurrentProcessInfo) { + this->GetValueOnIntegrationPoints(rVariable, rOutput, rCurrentProcessInfo); } virtual void CalculateOnIntegrationPoints(const Variable >& rVariable, std::vector< array_1d >& rOutput, const ProcessInfo& rCurrentProcessInfo) { + this->GetValueOnIntegrationPoints(rVariable, rOutput, rCurrentProcessInfo); } virtual void CalculateOnIntegrationPoints(const Variable& rVariable, std::vector< Vector >& rOutput, const ProcessInfo& rCurrentProcessInfo) { + this->GetValueOnIntegrationPoints(rVariable, rOutput, rCurrentProcessInfo); } virtual void CalculateOnIntegrationPoints(const Variable& rVariable, std::vector< Matrix >& rOutput, const ProcessInfo& rCurrentProcessInfo) { + this->GetValueOnIntegrationPoints(rVariable, rOutput, rCurrentProcessInfo); + } + + virtual void CalculateOnIntegrationPoints(const Variable& rVariable, + std::vector& rOutput, + const ProcessInfo& rCurrentProcessInfo) + { + this->GetValueOnIntegrationPoints(rVariable, rOutput, rCurrentProcessInfo); } /** @@ -1090,48 +1103,56 @@ class Element : public GeometricalObject //GET ON INTEGRATION POINTS METHODS + // KRATOS_DEPRECATED_MESSAGE("This is legacy version, please use \"CalculateOnIntegrationPoints\"") virtual void GetValueOnIntegrationPoints(const Variable& rVariable, std::vector& rValues, const ProcessInfo& rCurrentProcessInfo) { } + // KRATOS_DEPRECATED_MESSAGE("This is legacy version, please use \"CalculateOnIntegrationPoints\"") virtual void GetValueOnIntegrationPoints(const Variable& rVariable, std::vector& rValues, const ProcessInfo& rCurrentProcessInfo) { } + // KRATOS_DEPRECATED_MESSAGE("This is legacy version, please use \"CalculateOnIntegrationPoints\"") virtual void GetValueOnIntegrationPoints(const Variable& rVariable, std::vector& rValues, const ProcessInfo& rCurrentProcessInfo) { } + // KRATOS_DEPRECATED_MESSAGE("This is legacy version, please use \"CalculateOnIntegrationPoints\"") virtual void GetValueOnIntegrationPoints(const Variable >& rVariable, std::vector >& rValues, const ProcessInfo& rCurrentProcessInfo) { } + // KRATOS_DEPRECATED_MESSAGE("This is legacy version, please use \"CalculateOnIntegrationPoints\"") virtual void GetValueOnIntegrationPoints(const Variable >& rVariable, std::vector >& rValues, const ProcessInfo& rCurrentProcessInfo) { } + // KRATOS_DEPRECATED_MESSAGE("This is legacy version, please use \"CalculateOnIntegrationPoints\"") virtual void GetValueOnIntegrationPoints(const Variable& rVariable, std::vector& rValues, const ProcessInfo& rCurrentProcessInfo) { } + // KRATOS_DEPRECATED_MESSAGE("This is legacy version, please use \"CalculateOnIntegrationPoints\"") virtual void GetValueOnIntegrationPoints(const Variable& rVariable, std::vector& rValues, const ProcessInfo& rCurrentProcessInfo) { } + // KRATOS_DEPRECATED_MESSAGE("This is legacy version, please use \"CalculateOnIntegrationPoints\"") virtual void GetValueOnIntegrationPoints(const Variable& rVariable, std::vector& rValues, const ProcessInfo& rCurrentProcessInfo) diff --git a/kratos/includes/exception.h b/kratos/includes/exception.h index f31e81a964f2..56f4a8738e3a 100644 --- a/kratos/includes/exception.h +++ b/kratos/includes/exception.h @@ -44,7 +44,7 @@ namespace Kratos In order to have such information it is recommended to use it via KRATOS_ERROR macro. * @author Pooyan Dadvand */ -class KRATOS_API(KRATOS_CORE) Exception +class KRATOS_API(KRATOS_CORE) Exception : public std::exception { public: @@ -148,7 +148,7 @@ class KRATOS_API(KRATOS_CORE) Exception ///@{ void update_what(); - + ///@} }; // Class Exception @@ -158,11 +158,11 @@ class KRATOS_API(KRATOS_CORE) Exception ///@name Kratos Macros ///@{ -#define KRATOS_ERROR throw Exception("Error: ", KRATOS_CODE_LOCATION) +#define KRATOS_ERROR throw Kratos::Exception("Error: ", KRATOS_CODE_LOCATION) -#define KRATOS_ERROR_IF(conditional) if(conditional) throw Exception("Error: ", KRATOS_CODE_LOCATION) +#define KRATOS_ERROR_IF(conditional) if(conditional) throw Kratos::Exception("Error: ", KRATOS_CODE_LOCATION) -#define KRATOS_ERROR_IF_NOT(conditional) if(!(conditional)) throw Exception("Error: ", KRATOS_CODE_LOCATION) +#define KRATOS_ERROR_IF_NOT(conditional) if(!(conditional)) throw Kratos::Exception("Error: ", KRATOS_CODE_LOCATION) #ifdef KRATOS_DEBUG #define KRATOS_DEBUG_ERROR KRATOS_ERROR diff --git a/kratos/includes/gid_gauss_point_container.h b/kratos/includes/gid_gauss_point_container.h index e36e0e3fb90b..dfadbfee1516 100644 --- a/kratos/includes/gid_gauss_point_container.h +++ b/kratos/includes/gid_gauss_point_container.h @@ -138,7 +138,7 @@ class GidGaussPointsContainer if( mMeshElements.size() != 0 ) { for( auto it = mMeshElements.begin(); it != mMeshElements.end(); it++ ) { if( !(it->IsDefined(ACTIVE)) || it->Is(ACTIVE) ) { - it->GetValueOnIntegrationPoints( rVariable, ValuesOnIntPoint, + it->CalculateOnIntegrationPoints( rVariable, ValuesOnIntPoint, rModelPart.GetProcessInfo() ); for(unsigned int i=0; iIsDefined(ACTIVE)) || it->Is(ACTIVE) ) { - it->GetValueOnIntegrationPoints( rVariable, ValuesOnIntPoint, + it->CalculateOnIntegrationPoints( rVariable, ValuesOnIntPoint, rModelPart.GetProcessInfo() ); for(unsigned int i=0; iIsDefined(ACTIVE)) || it->Is(ACTIVE) ) { - it->GetValueOnIntegrationPoints( rVariable, ValuesOnIntPoint, + it->CalculateOnIntegrationPoints( rVariable, ValuesOnIntPoint, rModelPart.GetProcessInfo() ); for(unsigned int i=0; iIsDefined(ACTIVE)) || it->Is(ACTIVE) ) { - it->GetValueOnIntegrationPoints( rVariable, ValuesOnIntPoint, + it->CalculateOnIntegrationPoints( rVariable, ValuesOnIntPoint, rModelPart.GetProcessInfo() ); for(unsigned int i=0; iIsDefined(ACTIVE)) || it->Is(ACTIVE) ) { - it->GetValueOnIntegrationPoints( rVariable, ValuesOnIntPoint, + it->CalculateOnIntegrationPoints( rVariable, ValuesOnIntPoint, rModelPart.GetProcessInfo() ); for(unsigned int i=0; iIsDefined(ACTIVE)) || it->Is(ACTIVE) ) { - it->GetValueOnIntegrationPoints( rVariable, ValuesOnIntPoint, + it->CalculateOnIntegrationPoints( rVariable, ValuesOnIntPoint, rModelPart.GetProcessInfo() ); for(unsigned int i=0; iIsDefined(ACTIVE)) || it->Is(ACTIVE) ) { - it->GetValueOnIntegrationPoints( rVariable, ValuesOnIntPoint, + it->CalculateOnIntegrationPoints( rVariable, ValuesOnIntPoint, rModelPart.GetProcessInfo() ); for(unsigned int i=0; iIsDefined(ACTIVE)) || it->Is(ACTIVE) ) { - it->GetValueOnIntegrationPoints( rVariable, ValuesOnIntPoint, + it->CalculateOnIntegrationPoints( rVariable, ValuesOnIntPoint, rModelPart.GetProcessInfo() ); for(unsigned int i=0; iIsDefined(ACTIVE)) || it->Is(ACTIVE) ) { - it->GetValueOnIntegrationPoints( rVariable, ValuesOnIntPoint, + it->CalculateOnIntegrationPoints( rVariable, ValuesOnIntPoint, rModelPart.GetProcessInfo() ); for(unsigned int i=0; iIsDefined(ACTIVE)) || it->Is(ACTIVE) ) { - it->GetValueOnIntegrationPoints( rVariable, ValuesOnIntPoint, + it->CalculateOnIntegrationPoints( rVariable, ValuesOnIntPoint, rModelPart.GetProcessInfo() ); for(unsigned int i=0; iIsDefined(ACTIVE)) || it->Is(ACTIVE) ) { - it->GetValueOnIntegrationPoints( rVariable, ValuesOnIntPoint, + it->CalculateOnIntegrationPoints( rVariable, ValuesOnIntPoint, rModelPart.GetProcessInfo() ); for(unsigned int i=0; iIsDefined(ACTIVE)) || it->Is(ACTIVE) ) { - it->GetValueOnIntegrationPoints( rVariable, ValuesOnIntPoint, + it->CalculateOnIntegrationPoints( rVariable, ValuesOnIntPoint, rModelPart.GetProcessInfo() ); for(unsigned int i=0; iIsDefined(ACTIVE)) || it->Is(ACTIVE) ) { - it->GetValueOnIntegrationPoints( rVariable, ValuesOnIntPoint, + it->CalculateOnIntegrationPoints( rVariable, ValuesOnIntPoint, rModelPart.GetProcessInfo() ); for(unsigned int i=0; iIsDefined(ACTIVE)) || it->Is(ACTIVE) ) { - it->GetValueOnIntegrationPoints( rVariable, ValuesOnIntPoint, + it->CalculateOnIntegrationPoints( rVariable, ValuesOnIntPoint, rModelPart.GetProcessInfo() ); if (ValuesOnIntPoint[0].size1() == 0 && ValuesOnIntPoint[0].size2() == 0) { diff --git a/kratos/includes/variables.h b/kratos/includes/variables.h index a8149e34f47d..51d1fa3d901c 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, TIME_INTEGRATION_THETA ) + //sheme info :: pass to elements KRATOS_DEFINE_VARIABLE( double, NEWMARK_BETA ) KRATOS_DEFINE_VARIABLE( double, NEWMARK_GAMMA ) @@ -142,7 +144,7 @@ namespace Kratos KRATOS_DEFINE_VARIABLE( double, NORMAL_CONTACT_STRESS ) KRATOS_DEFINE_VARIABLE( double, TANGENTIAL_CONTACT_STRESS ) - KRATOS_DEFINE_VARIABLE( double, PARTITION_INDEX ) + KRATOS_DEFINE_VARIABLE( int, PARTITION_INDEX ) KRATOS_DEFINE_VARIABLE( double, TEMPERATURE_OLD_IT ) KRATOS_DEFINE_VARIABLE( double, VISCOSITY ) KRATOS_DEFINE_VARIABLE( double, ERROR_RATIO ) diff --git a/kratos/input_output/logger.h b/kratos/input_output/logger.h index 58daa158392b..d0b67e7bd9e2 100644 --- a/kratos/input_output/logger.h +++ b/kratos/input_output/logger.h @@ -245,41 +245,41 @@ namespace Kratos #define KRATOS_LOG_OCCURRENCES_LINE(line) kratos_log_loop_counter##line #define KRATOS_LOG_OCCURRENCES KRATOS_LOG_OCCURRENCES_LINE(__LINE__) -#define KRATOS_INFO(label) Logger(label) << KRATOS_CODE_LOCATION << Logger::Severity::INFO -#define KRATOS_INFO_IF(label, conditional) if(conditional) Logger(label) << KRATOS_CODE_LOCATION << Logger::Severity::INFO -#define KRATOS_INFO_ONCE(label) static int KRATOS_LOG_OCCURRENCES = -1; if (++KRATOS_LOG_OCCURRENCES == 0) Logger(label) << KRATOS_CODE_LOCATION << Logger::Severity::INFO -#define KRATOS_INFO_FIRST_N(label, logger_count) static int KRATOS_LOG_OCCURRENCES = -1; if (++KRATOS_LOG_OCCURRENCES < logger_count) Logger(label) << KRATOS_CODE_LOCATION << Logger::Severity::INFO - -#define KRATOS_INFO_ALL_RANKS(label) KRATOS_INFO(label) << Logger::DistributedFilter::FromAllRanks() -#define KRATOS_INFO_IF_ALL_RANKS(label, conditional) KRATOS_INFO_IF(label, conditional) << Logger::DistributedFilter::FromAllRanks() -#define KRATOS_INFO_ONCE_ALL_RANKS(label) KRATOS_INFO_ONCE(label) << Logger::DistributedFilter::FromAllRanks() -#define KRATOS_INFO_FIRST_N_ALL_RANKS(label, logger_count) KRATOS_INFO_FIRST_N(label, logger_count) << Logger::DistributedFilter::FromAllRanks() - -#define KRATOS_WARNING(label) Logger(label) << KRATOS_CODE_LOCATION << Logger::Severity::WARNING -#define KRATOS_WARNING_IF(label, conditional) if(conditional) Logger(label) << KRATOS_CODE_LOCATION << Logger::Severity::WARNING -#define KRATOS_WARNING_ONCE(label) static int KRATOS_LOG_OCCURRENCES = -1; if (++KRATOS_LOG_OCCURRENCES == 0) Logger(label) << KRATOS_CODE_LOCATION << Logger::Severity::WARNING -#define KRATOS_WARNING_FIRST_N(label, logger_count) static int KRATOS_LOG_OCCURRENCES = -1; if (++KRATOS_LOG_OCCURRENCES < logger_count) Logger(label) << KRATOS_CODE_LOCATION << Logger::Severity::WARNING - -#define KRATOS_WARNING_ALL_RANKS(label) KRATOS_WARNING(label) << Logger::DistributedFilter::FromAllRanks() -#define KRATOS_WARNING_IF_ALL_RANKS(label, conditional) KRATOS_WARNING_IF(label, conditional) << Logger::DistributedFilter::FromAllRanks() -#define KRATOS_WARNING_ONCE_ALL_RANKS(label) KRATOS_WARNING_ONCE(label) << Logger::DistributedFilter::FromAllRanks() -#define KRATOS_WARNING_FIRST_N_ALL_RANKS(label, logger_count) KRATOS_WARNING_FIRST_N(label, logger_count) << Logger::DistributedFilter::FromAllRanks() - -#define KRATOS_DETAIL(label) Logger(label) << KRATOS_CODE_LOCATION << Logger::Severity::DETAIL -#define KRATOS_DETAIL_IF(label, conditional) if(conditional) Logger(label) << KRATOS_CODE_LOCATION << Logger::Severity::DETAIL -#define KRATOS_DETAIL_ONCE(label) static int KRATOS_LOG_OCCURRENCES = -1; if (++KRATOS_LOG_OCCURRENCES == 0) Logger(label) << KRATOS_CODE_LOCATION << Logger::Severity::DETAIL -#define KRATOS_DETAIL_FIRST_N(label, logger_count) static int KRATOS_LOG_OCCURRENCES = -1; if (++KRATOS_LOG_OCCURRENCES < logger_count) Logger(label) << KRATOS_CODE_LOCATION << Logger::Severity::DETAIL - -#define KRATOS_DETAIL_ALL_RANKS(label) KRATOS_DETAIL(label) << Logger::DistributedFilter::FromAllRanks() -#define KRATOS_DETAIL_IF_ALL_RANKS(label, conditional) KRATOS_DETAIL_IF(label, conditional) << Logger::DistributedFilter::FromAllRanks() -#define KRATOS_DETAIL_ONCE_ALL_RANKS(label) KRATOS_DETAIL_ONCE(label) << Logger::DistributedFilter::FromAllRanks() -#define KRATOS_DETAIL_FIRST_N_ALL_RANKS(label, logger_count) KRATOS_DETAIL_FIRST_N(label, logger_count) << Logger::DistributedFilter::FromAllRanks() +#define KRATOS_INFO(label) Kratos::Logger(label) << KRATOS_CODE_LOCATION << Kratos::Logger::Severity::INFO +#define KRATOS_INFO_IF(label, conditional) if(conditional) Kratos::Logger(label) << KRATOS_CODE_LOCATION << Kratos::Logger::Severity::INFO +#define KRATOS_INFO_ONCE(label) static int KRATOS_LOG_OCCURRENCES = -1; if (++KRATOS_LOG_OCCURRENCES == 0) Kratos::Logger(label) << KRATOS_CODE_LOCATION << Kratos::Logger::Severity::INFO +#define KRATOS_INFO_FIRST_N(label, logger_count) static int KRATOS_LOG_OCCURRENCES = -1; if (++KRATOS_LOG_OCCURRENCES < logger_count) Kratos::Logger(label) << KRATOS_CODE_LOCATION << Kratos::Logger::Severity::INFO + +#define KRATOS_INFO_ALL_RANKS(label) KRATOS_INFO(label) << Kratos::Logger::DistributedFilter::FromAllRanks() +#define KRATOS_INFO_IF_ALL_RANKS(label, conditional) KRATOS_INFO_IF(label, conditional) << Kratos::Logger::DistributedFilter::FromAllRanks() +#define KRATOS_INFO_ONCE_ALL_RANKS(label) KRATOS_INFO_ONCE(label) << Kratos::Logger::DistributedFilter::FromAllRanks() +#define KRATOS_INFO_FIRST_N_ALL_RANKS(label, logger_count) KRATOS_INFO_FIRST_N(label, logger_count) << Kratos::Logger::DistributedFilter::FromAllRanks() + +#define KRATOS_WARNING(label) Kratos::Logger(label) << KRATOS_CODE_LOCATION << Kratos::Logger::Severity::WARNING +#define KRATOS_WARNING_IF(label, conditional) if(conditional) Kratos::Logger(label) << KRATOS_CODE_LOCATION << Kratos::Logger::Severity::WARNING +#define KRATOS_WARNING_ONCE(label) static int KRATOS_LOG_OCCURRENCES = -1; if (++KRATOS_LOG_OCCURRENCES == 0) Kratos::Logger(label) << KRATOS_CODE_LOCATION << Kratos::Logger::Severity::WARNING +#define KRATOS_WARNING_FIRST_N(label, logger_count) static int KRATOS_LOG_OCCURRENCES = -1; if (++KRATOS_LOG_OCCURRENCES < logger_count) Kratos::Logger(label) << KRATOS_CODE_LOCATION << Kratos::Logger::Severity::WARNING + +#define KRATOS_WARNING_ALL_RANKS(label) KRATOS_WARNING(label) << Kratos::Logger::DistributedFilter::FromAllRanks() +#define KRATOS_WARNING_IF_ALL_RANKS(label, conditional) KRATOS_WARNING_IF(label, conditional) << Kratos::Logger::DistributedFilter::FromAllRanks() +#define KRATOS_WARNING_ONCE_ALL_RANKS(label) KRATOS_WARNING_ONCE(label) << Kratos::Logger::DistributedFilter::FromAllRanks() +#define KRATOS_WARNING_FIRST_N_ALL_RANKS(label, logger_count) KRATOS_WARNING_FIRST_N(label, logger_count) << Kratos::Logger::DistributedFilter::FromAllRanks() + +#define KRATOS_DETAIL(label) Kratos::Logger(label) << KRATOS_CODE_LOCATION << Kratos::Logger::Severity::DETAIL +#define KRATOS_DETAIL_IF(label, conditional) if(conditional) Kratos::Logger(label) << KRATOS_CODE_LOCATION << Kratos::Logger::Severity::DETAIL +#define KRATOS_DETAIL_ONCE(label) static int KRATOS_LOG_OCCURRENCES = -1; if (++KRATOS_LOG_OCCURRENCES == 0) Kratos::Logger(label) << KRATOS_CODE_LOCATION << Kratos::Logger::Severity::DETAIL +#define KRATOS_DETAIL_FIRST_N(label, logger_count) static int KRATOS_LOG_OCCURRENCES = -1; if (++KRATOS_LOG_OCCURRENCES < logger_count) Kratos::Logger(label) << KRATOS_CODE_LOCATION << Kratos::Logger::Severity::DETAIL + +#define KRATOS_DETAIL_ALL_RANKS(label) KRATOS_DETAIL(label) << Kratos::Logger::DistributedFilter::FromAllRanks() +#define KRATOS_DETAIL_IF_ALL_RANKS(label, conditional) KRATOS_DETAIL_IF(label, conditional) << Kratos::Logger::DistributedFilter::FromAllRanks() +#define KRATOS_DETAIL_ONCE_ALL_RANKS(label) KRATOS_DETAIL_ONCE(label) << Kratos::Logger::DistributedFilter::FromAllRanks() +#define KRATOS_DETAIL_FIRST_N_ALL_RANKS(label, logger_count) KRATOS_DETAIL_FIRST_N(label, logger_count) << Kratos::Logger::DistributedFilter::FromAllRanks() #ifdef KRATOS_DEBUG -#define KRATOS_TRACE(label) Logger(label) << KRATOS_CODE_LOCATION << Logger::Severity::TRACE -#define KRATOS_TRACE_IF(label, conditional) if(conditional) Logger(label) << KRATOS_CODE_LOCATION << Logger::Severity::TRACE -#define KRATOS_TRACE_ONCE(label) static int KRATOS_LOG_OCCURRENCES = -1; if (++KRATOS_LOG_OCCURRENCES == 0) Logger(label) << KRATOS_CODE_LOCATION << Logger::Severity::TRACE -#define KRATOS_TRACE_FIRST_N(label, logger_count) static int KRATOS_LOG_OCCURRENCES = -1; if (++KRATOS_LOG_OCCURRENCES < logger_count) Logger(label) << KRATOS_CODE_LOCATION << Logger::Severity::TRACE +#define KRATOS_TRACE(label) Kratos::Logger(label) << KRATOS_CODE_LOCATION << Kratos::Logger::Severity::TRACE +#define KRATOS_TRACE_IF(label, conditional) if(conditional) Kratos::Logger(label) << KRATOS_CODE_LOCATION << Kratos::Logger::Severity::TRACE +#define KRATOS_TRACE_ONCE(label) static int KRATOS_LOG_OCCURRENCES = -1; if (++KRATOS_LOG_OCCURRENCES == 0) Kratos::Logger(label) << KRATOS_CODE_LOCATION << Kratos::Logger::Severity::TRACE +#define KRATOS_TRACE_FIRST_N(label, logger_count) static int KRATOS_LOG_OCCURRENCES = -1; if (++KRATOS_LOG_OCCURRENCES < logger_count) Kratos::Logger(label) << KRATOS_CODE_LOCATION << Kratos::Logger::Severity::TRACE #else #define KRATOS_TRACE(label) if(false) KRATOS_WARNING(label) #define KRATOS_TRACE_IF(label, conditional) if(false) KRATOS_WARNING(label) @@ -287,17 +287,17 @@ namespace Kratos #define KRATOS_TRACE_FIRST_N(label, logger_count) if(false) KRATOS_WARNING(label) #endif -#define KRATOS_TRACE_ALL_RANKS(label) KRATOS_TRACE(label) << Logger::DistributedFilter::FromAllRanks() -#define KRATOS_TRACE_IF_ALL_RANKS(label, conditional) KRATOS_TRACE_IF(label, conditional) << Logger::DistributedFilter::FromAllRanks() -#define KRATOS_TRACE_ONCE_ALL_RANKS(label) KRATOS_TRACE_ONCE(label) << Logger::DistributedFilter::FromAllRanks() -#define KRATOS_TRACE_FIRST_N_ALL_RANKS(label, logger_count) KRATOS_TRACE_FIRST_N(label, logger_count) << Logger::DistributedFilter::FromAllRanks() +#define KRATOS_TRACE_ALL_RANKS(label) KRATOS_TRACE(label) << Kratos::Logger::DistributedFilter::FromAllRanks() +#define KRATOS_TRACE_IF_ALL_RANKS(label, conditional) KRATOS_TRACE_IF(label, conditional) << Kratos::Logger::DistributedFilter::FromAllRanks() +#define KRATOS_TRACE_ONCE_ALL_RANKS(label) KRATOS_TRACE_ONCE(label) << Kratos::Logger::DistributedFilter::FromAllRanks() +#define KRATOS_TRACE_FIRST_N_ALL_RANKS(label, logger_count) KRATOS_TRACE_FIRST_N(label, logger_count) << Kratos::Logger::DistributedFilter::FromAllRanks() #if defined(KRATOS_ENABLE_CHECK_POINT) -#define KRATOS_CHECK_POINT(label) Logger(label) << Logger::Category::CHECKING +#define KRATOS_CHECK_POINT(label) Kratos::Logger(label) << Kratos::Logger::Category::CHECKING #else #define KRATOS_CHECK_POINT(label) \ if (false) \ - Logger(label) << Logger::Category::CHECKING + Kratos::Logger(label) << Kratos::Logger::Category::CHECKING #endif ///@} 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/mpi/tests/sources/test_mpi_communicator.cpp b/kratos/mpi/tests/sources/test_mpi_communicator.cpp index 30d3040249af..f066bc64c07a 100644 --- a/kratos/mpi/tests/sources/test_mpi_communicator.cpp +++ b/kratos/mpi/tests/sources/test_mpi_communicator.cpp @@ -30,8 +30,7 @@ namespace Internals { void ModelPartForMPICommunicatorTests(ModelPart& rModelPart, const DataCommunicator& rComm) { /* NOTE: the modelpart should at least have PARTITION_INDEX in the nodal solution step data */ - constexpr double pi = 3.141592653589793238462643383279502884197169399375105820974944592308; - constexpr double total_angle = pi/2.0; + constexpr double total_angle = Globals::Pi/2.0; constexpr double side_length = 1.0; Properties::Pointer p_properties = rModelPart.CreateNewProperties(0); @@ -40,7 +39,7 @@ void ModelPartForMPICommunicatorTests(ModelPart& rModelPart, const DataCommunica const int size = rComm.Size(); auto p_center = rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - p_center->FastGetSolutionStepValue(PARTITION_INDEX) = 0.0; + p_center->FastGetSolutionStepValue(PARTITION_INDEX) = 0; const double angle_start = rank * (total_angle / size); const double angle_end = rank+1 * (total_angle / size); @@ -56,9 +55,9 @@ void ModelPartForMPICommunicatorTests(ModelPart& rModelPart, const DataCommunica auto p_node_1 = rModelPart.CreateNewNode(local_index, x1, y1, 0.0); auto p_node_2 = rModelPart.CreateNewNode(ghost_index, x2, y2, 0.0); - p_node_1->FastGetSolutionStepValue(PARTITION_INDEX) = 1.0*rank; + p_node_1->FastGetSolutionStepValue(PARTITION_INDEX) = rank; const int remote_rank = (rank != size-1) ? rank + 1 : 0; - p_node_2->FastGetSolutionStepValue(PARTITION_INDEX) = 1.0*remote_rank; + p_node_2->FastGetSolutionStepValue(PARTITION_INDEX) = remote_rank; std::vector element_nodes{1, local_index, ghost_index}; rModelPart.CreateNewElement("Element2D3N", rank+1, element_nodes, p_properties); @@ -763,7 +762,7 @@ KRATOS_DISTRIBUTED_TEST_CASE_IN_SUITE(ParallelFillCommunicatorExecution, KratosM auto neighbor_indices = r_mpi_comm.NeighbourIndices(); int neighbor; - double local_index = comm_world.Rank(); // PARTITION_INDEX is a double + int local_index = comm_world.Rank(); for (unsigned int i = 0; i < number_of_colors; i++) { if ((neighbor = neighbor_indices[i]) > -1) @@ -773,7 +772,7 @@ KRATOS_DISTRIBUTED_TEST_CASE_IN_SUITE(ParallelFillCommunicatorExecution, KratosM std::size_t ghost_size = r_mpi_comm.GhostMeshes()[i].Nodes().size(); KRATOS_CHECK_GREATER(interface_size, 0); KRATOS_CHECK_EQUAL(interface_size, local_size+ghost_size); - double neighbor_index = neighbor; // PARTITION_INDEX is a double + int neighbor_index = neighbor; for (auto& node : r_mpi_comm.LocalMeshes()[i].Nodes()) { KRATOS_CHECK_EQUAL(node.FastGetSolutionStepValue(PARTITION_INDEX,0), local_index); @@ -786,5 +785,23 @@ KRATOS_DISTRIBUTED_TEST_CASE_IN_SUITE(ParallelFillCommunicatorExecution, KratosM } } + +KRATOS_DISTRIBUTED_TEST_CASE_IN_SUITE(CommunicatorGlobalNumMethods, KratosMPICoreFastSuite) +{ + Model model; + ModelPart& r_model_part = model.CreateModelPart("TestModelPart"); + r_model_part.AddNodalSolutionStepVariable(PARTITION_INDEX); + + MPIDataCommunicator comm_world(MPI_COMM_WORLD); + Internals::ModelPartForMPICommunicatorTests(r_model_part, comm_world); + + const auto& r_mpi_comm = r_model_part.GetCommunicator(); + + const unsigned int comm_size = r_mpi_comm.TotalProcesses(); + + KRATOS_CHECK_EQUAL(r_mpi_comm.GlobalNumberOfNodes(), comm_size+1); + KRATOS_CHECK_EQUAL(r_mpi_comm.GlobalNumberOfElements(), comm_size); +} + } } \ No newline at end of file diff --git a/kratos/mpi/tests/test_mpi_communicator.py b/kratos/mpi/tests/test_mpi_communicator.py index 86e221b410ed..91c466f661c0 100644 --- a/kratos/mpi/tests/test_mpi_communicator.py +++ b/kratos/mpi/tests/test_mpi_communicator.py @@ -219,10 +219,24 @@ def testCommunicatorReductionSerial(self): self.assertEqual(comm.ScanSum(1), 1) - #def test_model_part_io_properties_block(self): - # model_part = ModelPart("Main") - # model_part_io = ModelPartIO("test_model_part_io") - # model_part_io.ReadProperties(model_part.Properties) + def test_GlobalNumberOf_Methods(self): + current_model = KratosMultiphysics.Model() + main_model_part = current_model.CreateModelPart("MainModelPart") + main_model_part.ProcessInfo.SetValue(KratosMultiphysics.DOMAIN_SIZE, 2) + + self._read_model_part_mpi(main_model_part) + + main_comm = main_model_part.GetCommunicator() + + self.assertEqual(main_comm.GlobalNumberOfNodes(), 9) + self.assertEqual(main_comm.GlobalNumberOfElements(), 8) + self.assertEqual(main_comm.GlobalNumberOfConditions(), 8) + + sub_comm = main_model_part.GetSubModelPart("Skin").GetCommunicator() + + self.assertEqual(sub_comm.GlobalNumberOfNodes(), 8) + self.assertEqual(sub_comm.GlobalNumberOfElements(), 0) + self.assertEqual(sub_comm.GlobalNumberOfConditions(), 8) if __name__ == '__main__': KratosUnittest.main() diff --git a/kratos/mpi/utilities/parallel_fill_communicator.cpp b/kratos/mpi/utilities/parallel_fill_communicator.cpp index bfc889723b3f..fdfe6de13840 100644 --- a/kratos/mpi/utilities/parallel_fill_communicator.cpp +++ b/kratos/mpi/utilities/parallel_fill_communicator.cpp @@ -227,24 +227,24 @@ void ParallelFillCommunicator::ComputeCommunicationPlan(ModelPart& rModelPart) } // Get rank of current processor. - const unsigned my_rank = r_data_communicator.Rank(); + const int my_rank = r_data_communicator.Rank(); // Get number of processors. - const unsigned num_processors = r_data_communicator.Size(); + const int num_processors = r_data_communicator.Size(); // Find all ghost nodes on this process and mark the corresponding neighbour process for communication. vector receive_from_neighbour(num_processors, false); for (const auto& rNode : rModelPart.Nodes()) { - const unsigned partition_index = rNode.FastGetSolutionStepValue(PARTITION_INDEX); + const int partition_index = rNode.FastGetSolutionStepValue(PARTITION_INDEX); KRATOS_ERROR_IF(partition_index >= num_processors) << "The partition index is out of range. Invalid model part." << std::endl; if(partition_index != my_rank) receive_from_neighbour[partition_index] = true; } // Make a list of my receive process ids. - std::vector my_receive_neighbours; + std::vector my_receive_neighbours; my_receive_neighbours.reserve(30); - for (unsigned p_id = 0; p_id < num_processors; ++p_id) + for (int p_id = 0; p_id < num_processors; ++p_id) { if (receive_from_neighbour[p_id]) my_receive_neighbours.push_back(p_id); @@ -252,7 +252,7 @@ void ParallelFillCommunicator::ComputeCommunicationPlan(ModelPart& rModelPart) // Initialize arrays for all neighbour id lists on root process. std::vector number_of_receive_neighbours; - std::vector> receive_neighbours; + std::vector> receive_neighbours; if (my_rank == root_id) { number_of_receive_neighbours.resize(num_processors); @@ -264,7 +264,7 @@ void ParallelFillCommunicator::ComputeCommunicationPlan(ModelPart& rModelPart) } if (my_rank == root_id) { - for (unsigned p_id = 0; p_id < num_processors; ++p_id) + for (int p_id = 0; p_id < num_processors; ++p_id) receive_neighbours[p_id].resize(number_of_receive_neighbours[p_id]); } @@ -272,7 +272,7 @@ void ParallelFillCommunicator::ComputeCommunicationPlan(ModelPart& rModelPart) if (my_rank == root_id) // On root we directly copy the data without calling MPI. std::copy(my_receive_neighbours.begin(), my_receive_neighbours.end(), receive_neighbours[root_id].begin()); // Gather the remaining id lists to root. - for (unsigned p_id = 1; p_id < num_processors; ++p_id) + for (int p_id = 1; p_id < num_processors; ++p_id) { if (my_rank == root_id) { @@ -291,8 +291,8 @@ void ParallelFillCommunicator::ComputeCommunicationPlan(ModelPart& rModelPart) { ///@TODO for large problems, this should use a compressed matrix. DenseMatrix domains_graph = ZeroMatrix(num_processors, num_processors); - for (unsigned index1 = 0; index1 < num_processors; ++index1) - for (unsigned index2 : receive_neighbours[index1]) + for (int index1 = 0; index1 < num_processors; ++index1) + for (int index2 : receive_neighbours[index1]) { KRATOS_ERROR_IF(index1 == index2) << "Trying to communicate with the node itself." << std::endl; domains_graph(index1, index2) = 1; @@ -304,7 +304,7 @@ void ParallelFillCommunicator::ComputeCommunicationPlan(ModelPart& rModelPart) GraphColoringProcess coloring_process(num_processors, domains_graph, domains_colored_graph, max_color); coloring_process.Execute(); // Count max colors. - for (unsigned p_id = 0; p_id < num_processors; ++p_id) + for (int p_id = 0; p_id < num_processors; ++p_id) for (int j = 0; j < max_color; ++j) if (domains_colored_graph(p_id, j) != -1 && max_color_found < j) max_color_found = j; @@ -323,7 +323,7 @@ void ParallelFillCommunicator::ComputeCommunicationPlan(ModelPart& rModelPart) } // Send the remaining color patterns to processes. std::vector send_colors(max_color_found); - for (unsigned p_id = 1; p_id < num_processors; ++p_id) + for (int p_id = 1; p_id < num_processors; ++p_id) { if (my_rank == root_id) { @@ -347,7 +347,7 @@ void ParallelFillCommunicator::ComputeCommunicationPlan(ModelPart& rModelPart) void ParallelFillCommunicator::InitializeParallelCommunicationMeshes( ModelPart& rModelPart, const std::vector& rColors, - unsigned MyRank) + int MyRank) { KRATOS_TRY; // Allocate space needed in the communicator. @@ -383,7 +383,7 @@ void ParallelFillCommunicator::InitializeParallelCommunicationMeshes( // Fill nodes for LocalMesh and GhostMesh. for (auto it_node = rModelPart.NodesBegin(); it_node != rModelPart.NodesEnd(); ++it_node) { - const unsigned index = it_node->FastGetSolutionStepValue(PARTITION_INDEX); + const int index = it_node->FastGetSolutionStepValue(PARTITION_INDEX); if (index == MyRank) { r_local_nodes.push_back(*(it_node.base())); diff --git a/kratos/mpi/utilities/parallel_fill_communicator.h b/kratos/mpi/utilities/parallel_fill_communicator.h index 7843eaf6c656..a94d75a5b21a 100644 --- a/kratos/mpi/utilities/parallel_fill_communicator.h +++ b/kratos/mpi/utilities/parallel_fill_communicator.h @@ -140,7 +140,7 @@ class KRATOS_API(KRATOS_MPI_CORE) ParallelFillCommunicator /// Initialize the communicator's ghost, local and interface meshes for all communication pairs (colors). void InitializeParallelCommunicationMeshes(ModelPart& rModelPart, const std::vector& rColors, - unsigned MyRank); + int MyRank); /// Generate the ghost, local and interface meshes for processes of a communication pair (color). void GenerateMeshes(int NeighbourPID, int MyPID, unsigned Color, ModelPart& rModelPart); 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")); diff --git a/kratos/processes/assign_scalar_variable_to_entities_process.h b/kratos/processes/assign_scalar_variable_to_entities_process.h index c2cc3f2c75e8..de5a4b127cdd 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; @@ -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 ///@{ 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/processes/integration_values_extrapolation_to_nodes_process.cpp b/kratos/processes/integration_values_extrapolation_to_nodes_process.cpp index afdf78968f5e..4584e9b3b4f2 100755 --- a/kratos/processes/integration_values_extrapolation_to_nodes_process.cpp +++ b/kratos/processes/integration_values_extrapolation_to_nodes_process.cpp @@ -140,7 +140,7 @@ void IntegrationValuesExtrapolationToNodesProcess::ExecuteFinalizeSolutionStep() // We add the doubles values for ( const auto p_var : mDoubleVariable) { std::vector aux_result(integration_points_number); - it_elem->GetValueOnIntegrationPoints(*p_var, aux_result, r_process_info); + it_elem->CalculateOnIntegrationPoints(*p_var, aux_result, r_process_info); for (IndexType i_gauss_point = 0; i_gauss_point < integration_points_number; ++i_gauss_point) { for (IndexType i_node = 0; i_node < number_of_nodes; ++i_node) { double& aux_value = (mExtrapolateNonHistorical) ? r_this_geometry[i_node].GetValue(*p_var) : r_this_geometry[i_node].FastGetSolutionStepValue(*p_var); @@ -153,7 +153,7 @@ void IntegrationValuesExtrapolationToNodesProcess::ExecuteFinalizeSolutionStep() // We add the arrays values for ( const auto p_var : mArrayVariable) { std::vector> aux_result(integration_points_number); - it_elem->GetValueOnIntegrationPoints(*p_var, aux_result, r_process_info); + it_elem->CalculateOnIntegrationPoints(*p_var, aux_result, r_process_info); for (IndexType i_gauss_point = 0; i_gauss_point < integration_points_number; ++i_gauss_point) { for (IndexType i_node = 0; i_node < number_of_nodes; ++i_node) { array_1d& aux_value = (mExtrapolateNonHistorical) ? r_this_geometry[i_node].GetValue(*p_var) : r_this_geometry[i_node].FastGetSolutionStepValue(*p_var); @@ -169,7 +169,7 @@ void IntegrationValuesExtrapolationToNodesProcess::ExecuteFinalizeSolutionStep() // We add the vectors values for ( const auto p_var : mVectorVariable) { std::vector aux_result(integration_points_number); - it_elem->GetValueOnIntegrationPoints(*p_var, aux_result, r_process_info); + it_elem->CalculateOnIntegrationPoints(*p_var, aux_result, r_process_info); for (IndexType i_gauss_point = 0; i_gauss_point < integration_points_number; ++i_gauss_point) { for (IndexType i_node = 0; i_node < number_of_nodes; ++i_node) { Vector& aux_value = (mExtrapolateNonHistorical) ? r_this_geometry[i_node].GetValue(*p_var) : r_this_geometry[i_node].FastGetSolutionStepValue(*p_var); @@ -185,7 +185,7 @@ void IntegrationValuesExtrapolationToNodesProcess::ExecuteFinalizeSolutionStep() // We add the matrix values for ( const auto p_var : mMatrixVariable) { std::vector aux_result(integration_points_number); - it_elem->GetValueOnIntegrationPoints(*p_var, aux_result, r_process_info); + it_elem->CalculateOnIntegrationPoints(*p_var, aux_result, r_process_info); for (IndexType i_gauss_point = 0; i_gauss_point < integration_points_number; ++i_gauss_point) { for (IndexType i_node = 0; i_node < number_of_nodes; ++i_node) { Matrix& aux_value = (mExtrapolateNonHistorical) ? r_this_geometry[i_node].GetValue(*p_var) : r_this_geometry[i_node].FastGetSolutionStepValue(*p_var); @@ -354,14 +354,14 @@ void IntegrationValuesExtrapolationToNodesProcess::InitializeMaps() // We init the vector sizes for ( const auto p_var : mVectorVariable) { std::vector aux_result(integration_points_number); - it_elem_begin->GetValueOnIntegrationPoints(*p_var, aux_result, r_process_info); + it_elem_begin->CalculateOnIntegrationPoints(*p_var, aux_result, r_process_info); mSizeVectors.insert({p_var, aux_result[0].size()}); } // We init the matrix sizes for ( const auto p_var : mMatrixVariable) { std::vector aux_result(integration_points_number); - it_elem_begin->GetValueOnIntegrationPoints(*p_var, aux_result, r_process_info); + it_elem_begin->CalculateOnIntegrationPoints(*p_var, aux_result, r_process_info); std::pair aux_pair(aux_result[0].size1(), aux_result[0].size2()); mSizeMatrixes.insert({p_var, aux_pair}); } diff --git a/kratos/python/add_communicator_to_python.cpp b/kratos/python/add_communicator_to_python.cpp index ef03ebd79c6a..920650cd2145 100644 --- a/kratos/python/add_communicator_to_python.cpp +++ b/kratos/python/add_communicator_to_python.cpp @@ -89,6 +89,9 @@ void AddCommunicatorToPython(pybind11::module &m) .def(py::init<>()) .def("MyPID", &Communicator::MyPID) .def("TotalProcesses", &Communicator::TotalProcesses) + .def("GlobalNumberOfNodes", &Communicator::GlobalNumberOfNodes) + .def("GlobalNumberOfElements", &Communicator::GlobalNumberOfElements) + .def("GlobalNumberOfConditions", &Communicator::GlobalNumberOfConditions) .def("GetNumberOfColors", &Communicator::GetNumberOfColors) .def("NeighbourIndices", NeighbourIndicesConst, py::return_value_policy::reference_internal) .def("SynchronizeNodalSolutionStepsData", &Communicator::SynchronizeNodalSolutionStepsData) diff --git a/kratos/python/add_containers_to_python.cpp b/kratos/python/add_containers_to_python.cpp index c7e4dd02cf96..2b5ae628b7e2 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) ; @@ -328,6 +331,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, 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/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 >()) diff --git a/kratos/python_scripts/KratosUnittest.py b/kratos/python_scripts/KratosUnittest.py index c0591a6b9fa8..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 @@ -105,11 +105,9 @@ 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 + 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) @contextmanager diff --git a/kratos/python_scripts/from_json_check_result_process.py b/kratos/python_scripts/from_json_check_result_process.py index d4e10c2aec75..82a1e9f71002 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) @@ -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)] 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"): 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 8ea738168ac2..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 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())); + const std::string variable_name = ((*(mDoubleVariable.begin() + 2 * i))->GetSourceVariable()).Name(); + const auto& r_var_z = KratosComponents>::Get(variable_name + "_Z"); + 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++; - } } ///@} @@ -629,19 +554,19 @@ class ResidualBasedBDFCustomScheme mSecondDoubleDerivatives.push_back(&((r_var.GetTimeDerivative()).GetTimeDerivative())); } else if (KratosComponents< Variable< array_1d< double, 3> > >::Has(variable_name)) { // Components - const auto& r_var_x = KratosComponents< VariableComponent>::Get(variable_name+"_X"); - const auto& r_var_y = KratosComponents< VariableComponent>::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())); + const auto& r_var_x = KratosComponents>::Get(variable_name+"_X"); + const auto& r_var_y = KratosComponents>::Get(variable_name+"_Y"); + 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< VariableComponent>::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())); + const auto& r_var_z = KratosComponents>::Get(variable_name+"_Z"); + 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." ; 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 cf0856807878..e72c3c0b0f77 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 e786c80bc451..763dd8eb72a6 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) { diff --git a/kratos/sources/communicator.cpp b/kratos/sources/communicator.cpp index ecbe9179e04f..96f30f46142a 100644 --- a/kratos/sources/communicator.cpp +++ b/kratos/sources/communicator.cpp @@ -93,6 +93,21 @@ int Communicator::TotalProcesses() const return mrDataCommunicator.Size(); } +Communicator::SizeType Communicator::GlobalNumberOfNodes() const +{ + return mrDataCommunicator.SumAll(static_cast(mpLocalMesh->NumberOfNodes())); +} + +Communicator::SizeType Communicator::GlobalNumberOfElements() const +{ + return mrDataCommunicator.SumAll(static_cast(mpLocalMesh->NumberOfElements())); +} + +Communicator::SizeType Communicator::GlobalNumberOfConditions() const +{ + return mrDataCommunicator.SumAll(static_cast(mpLocalMesh->NumberOfConditions())); +} + Communicator::SizeType Communicator::GetNumberOfColors() const { return mNumberOfColors; 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; diff --git a/kratos/sources/variables.cpp b/kratos/sources/variables.cpp index 897dc0292727..e0a5800763e1 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, TIME_INTEGRATION_THETA) + //sheme info :: pass to elements KRATOS_CREATE_VARIABLE(double, NEWMARK_BETA) KRATOS_CREATE_VARIABLE(double, NEWMARK_GAMMA) @@ -129,7 +131,7 @@ KRATOS_CREATE_VARIABLE(double, SCALE_FACTOR) KRATOS_CREATE_VARIABLE(double, NORMAL_CONTACT_STRESS) KRATOS_CREATE_VARIABLE(double, TANGENTIAL_CONTACT_STRESS) -KRATOS_CREATE_VARIABLE(double, PARTITION_INDEX) +KRATOS_CREATE_VARIABLE(int, PARTITION_INDEX) KRATOS_CREATE_VARIABLE(double, TEMPERATURE_OLD_IT) KRATOS_CREATE_VARIABLE(double, VISCOSITY) KRATOS_CREATE_VARIABLE(double, ERROR_RATIO) @@ -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(TIME_INTEGRATION_THETA) + //STRAIN MEASURES KRATOS_REGISTER_VARIABLE(VOLUMETRIC_STRAIN) 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 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 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..ebd5e3e93c65 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,42 @@ 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(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); @@ -50,6 +86,31 @@ 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]); + + 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) { DataValueContainer container_origin; DataValueContainer container_target; diff --git a/kratos/tests/cpp_tests/containers/test_variables.cpp b/kratos/tests/cpp_tests/containers/test_variables.cpp index 39e30d5ba1ca..613401159c69 100644 --- a/kratos/tests/cpp_tests/containers/test_variables.cpp +++ b/kratos/tests/cpp_tests/containers/test_variables.cpp @@ -69,8 +69,9 @@ KRATOS_TEST_CASE_IN_SUITE(VariablesKeyOrder, KratosCoreFastSuite) { } } } + } + -} } 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. 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..90f535b8d732 --- /dev/null +++ b/kratos/tests/cpp_tests/containers/test_variables_list_data_value_container.cpp @@ -0,0 +1,100 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ ` +// _|\_\_| \__,_|\__|\___/ ____/ +// 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(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); + 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. 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..1fa7b289c76c --- /dev/null +++ b/kratos/tests/cpp_tests/elements/test_levelset_convection_element_simplex.cpp @@ -0,0 +1,289 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ ` +// _|\_\_| \__,_|\__|\___/ ____/ +// 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); + Vector rhs_reference = ZeroVector(3); + Matrix lhs = ZeroMatrix(4,4); + Matrix lhs_reference = ZeroMatrix(3,3); + + 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); + 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) { + 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); + Vector rhs_reference = ZeroVector(3); + Matrix lhs = ZeroMatrix(4,4); + Matrix lhs_reference = ZeroMatrix(3,3); + + 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); + 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) { + 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); + Vector rhs_reference = ZeroVector(4); + Matrix lhs = ZeroMatrix(5,4); + Matrix lhs_reference = ZeroMatrix(4,4); + + 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); + 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. +} // namespace Kratos. 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. 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__': 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() diff --git a/kratos/tests/test_variable_utils.py b/kratos/tests/test_variable_utils.py index 744e5799f1a8..43cc9d0fbea1 100644 --- a/kratos/tests/test_variable_utils.py +++ b/kratos/tests/test_variable_utils.py @@ -366,8 +366,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 diff --git a/kratos/utilities/quadrature_points_utility.h b/kratos/utilities/quadrature_points_utility.h index 9d97a3682905..5974305af859 100644 --- a/kratos/utilities/quadrature_points_utility.h +++ b/kratos/utilities/quadrature_points_utility.h @@ -91,7 +91,13 @@ namespace Kratos rPoints, rShapeFunctionContainer, pGeometryParent); - if (WorkingSpaceDimension == 2 && LocalSpaceDimension == 2) + else if (WorkingSpaceDimension == 2 && LocalSpaceDimension == 1) + return Kratos::make_shared< + QuadraturePointGeometry>( + rPoints, + rShapeFunctionContainer, + pGeometryParent); + else if (WorkingSpaceDimension == 2 && LocalSpaceDimension == 2) return Kratos::make_shared< QuadraturePointGeometry>( rPoints, @@ -110,8 +116,8 @@ namespace Kratos rShapeFunctionContainer, pGeometryParent); else{ - KRATOS_ERROR << "Working/ Local space dimension combinations are " - << "not provieded for QuadraturePointGeometry. WorkingSpaceDimension: " + KRATOS_ERROR << "Working/Local space dimension combinations are " + << "not provided for QuadraturePointGeometry. WorkingSpaceDimension: " << WorkingSpaceDimension << ", LocalSpaceDimension: " << LocalSpaceDimension << std::endl; } @@ -128,7 +134,12 @@ namespace Kratos QuadraturePointGeometry>( rPoints, rShapeFunctionContainer); - if (WorkingSpaceDimension == 2 && LocalSpaceDimension == 2) + else if (WorkingSpaceDimension == 2 && LocalSpaceDimension == 1) + return Kratos::make_shared< + QuadraturePointGeometry>( + rPoints, + rShapeFunctionContainer); + else if (WorkingSpaceDimension == 2 && LocalSpaceDimension == 2) return Kratos::make_shared< QuadraturePointGeometry>( rPoints, @@ -144,8 +155,8 @@ namespace Kratos rPoints, rShapeFunctionContainer); else { - KRATOS_ERROR << "Working/ Local space dimension combinations are " - << "not provieded for QuadraturePointGeometry. WorkingSpaceDimension: " + KRATOS_ERROR << "Working/Local space dimension combinations are " + << "not provided for QuadraturePointGeometry. WorkingSpaceDimension: " << WorkingSpaceDimension << ", LocalSpaceDimension: " << LocalSpaceDimension << std::endl; } 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