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 83b7b9c64860..7f1d3c4da084 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 @@ -175,6 +175,7 @@ class AdjointFiniteDifferencingBaseElement : public Element { mpPrimalElement->CalculateLeftHandSide(rLeftHandSideMatrix, rCurrentProcessInfo); + noalias(rLeftHandSideMatrix) = -1.0 * rLeftHandSideMatrix; } void CalculateRightHandSide(VectorType& rRightHandSideVector, diff --git a/applications/StructuralMechanicsApplication/custom_response_functions/response_utilities/adjoint_local_stress_response_function.cpp b/applications/StructuralMechanicsApplication/custom_response_functions/response_utilities/adjoint_local_stress_response_function.cpp index f7f70ce2e61c..ce4429b458a5 100644 --- a/applications/StructuralMechanicsApplication/custom_response_functions/response_utilities/adjoint_local_stress_response_function.cpp +++ b/applications/StructuralMechanicsApplication/custom_response_functions/response_utilities/adjoint_local_stress_response_function.cpp @@ -87,7 +87,6 @@ namespace Kratos KRATOS_ERROR_IF(rResponseGradient.size() != rResidualGradient.size1()) << "Size of stress displacement derivative does not fit!" << std::endl; - rResponseGradient *= (-1); } else { diff --git a/applications/StructuralMechanicsApplication/custom_response_functions/response_utilities/adjoint_max_stress_response_function.cpp b/applications/StructuralMechanicsApplication/custom_response_functions/response_utilities/adjoint_max_stress_response_function.cpp index 1ab7f7076d61..bc69998e7b72 100644 --- a/applications/StructuralMechanicsApplication/custom_response_functions/response_utilities/adjoint_max_stress_response_function.cpp +++ b/applications/StructuralMechanicsApplication/custom_response_functions/response_utilities/adjoint_max_stress_response_function.cpp @@ -101,7 +101,6 @@ namespace Kratos KRATOS_ERROR_IF(rResponseGradient.size() != rResidualGradient.size1()) << "AdjointMaxStressResponseFunction::CalculateGradient: Size of stress displacement derivative does not fit!" << std::endl; - rResponseGradient *= (-1); } else { 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 6f39afba242d..3b1c4ed23afd 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 @@ -73,9 +73,9 @@ namespace Kratos for(IndexType i = 0; i < dofs_of_element.size(); ++i) { if (dofs_of_element[i]->Id() == node_id && dofs_of_element[i]->GetVariable() == *adjoint_solution_variable) { - rResponseGradient[i] = -1 * mResponseDirection[0]; - rResponseGradient[i+1] = -1 * mResponseDirection[1]; - rResponseGradient[i+2] = -1 * mResponseDirection[2]; + rResponseGradient[i] = mResponseDirection[0]; + rResponseGradient[i+1] = mResponseDirection[1]; + rResponseGradient[i+2] = mResponseDirection[2]; break; } } diff --git a/applications/SystemIdentificationApplication/python_scripts/responses/damage_detection_response.py b/applications/SystemIdentificationApplication/python_scripts/responses/damage_detection_response.py index 08cdc92b257a..39612981587c 100644 --- a/applications/SystemIdentificationApplication/python_scripts/responses/damage_detection_response.py +++ b/applications/SystemIdentificationApplication/python_scripts/responses/damage_detection_response.py @@ -134,7 +134,7 @@ def CalculateGradient(self, physical_variable_collective_expressions: 'dict[Supp sensitivity_variable = Kratos.KratosGlobals.GetVariable(f"{physical_variable.Name()}_SENSITIVITY") for container_expression in collective_expression.GetContainerExpressions(): sensitivities = self.adjoint_analysis.GetSensitivities(container_expression.GetModelPart()) - container_expression.SetExpression((container_expression.GetExpression() - sensitivities[sensitivity_variable].GetExpression() * test_case_weight)) + container_expression.SetExpression((container_expression.GetExpression() + sensitivities[sensitivity_variable].GetExpression() * test_case_weight)) container_expression.SetExpression(Kratos.Expression.Utils.Collapse(container_expression).GetExpression()) def __GetSensor(self, sensor_name: str) -> KratosDT.Sensors.Sensor: