Skip to content

Commit

Permalink
Processing review comments AvdG
Browse files Browse the repository at this point in the history
  • Loading branch information
rfaasse committed Dec 21, 2023
1 parent 1937ef0 commit 482748b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -477,22 +477,22 @@ class ResidualBasedBlockBuilderAndSolverWithMassAndDamping
GetDerivativesForVariable(DISPLACEMENT_Y, rNode, rFirstDerivativeVector,
rSecondDerivativeVector);

const std::vector<const Variable<double>*> conditional_variables = {
const std::vector<const Variable<double>*> optional_variables = {
&ROTATION_X, &ROTATION_Y, &ROTATION_Z, &DISPLACEMENT_Z};

for (const auto p_variable : conditional_variables)
for (const auto p_variable : optional_variables)
{
GetDerivativesForConditionalVariable(
*p_variable, rNode, rFirstDerivativeVector, rSecondDerivativeVector);
GetDerivativesForOptionalVariable(*p_variable, rNode, rFirstDerivativeVector,
rSecondDerivativeVector);
}
}
});
}

void GetDerivativesForConditionalVariable(const Variable<double>& rVariable,
const Node& rNode,
TSystemVectorType& rFirstDerivativeVector,
TSystemVectorType& rSecondDerivativeVector) const
void GetDerivativesForOptionalVariable(const Variable<double>& rVariable,
const Node& rNode,
TSystemVectorType& rFirstDerivativeVector,
TSystemVectorType& rSecondDerivativeVector) const
{
if (rNode.HasDofFor(rVariable))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ def test_rotation_with_moving_load(self):

# run simulation
test_helper.run_kratos(file_path)
res_path = os.path.join(file_path, test_name + result_extension)

reader = test_helper.GiDOutputFileReader()
res_path = os.path.join(file_path, test_name + result_extension)
simulation_output = reader.read_output_from(res_path)
rotations = simulation_output["results"]["ROTATION"]

# Validation for Time = 0.02
values_time_0_02 = reader.get_values_at_time(1.0, rotations)
value_for_node = reader.get_value_at_node(1, values_time_0_02)
# Validation for Time = 1.0
rotations_time_1 = reader.get_values_at_time(1.0, rotations)
rotations_for_node_1 = reader.get_value_at_node(1, rotations_time_1)

# This test is a regression test, if rotation is not added to the
# newmark upw scheme as a variable that needs to be predicted and
# updated, the results will be different.
self.assertAlmostEqual(-0.000177858, value_for_node[2])
self.assertAlmostEqual(-0.000177858, rotations_for_node_1[2])

def test_rotation_with_moving_load_constant_system_matrices(self):
"""
Expand All @@ -43,20 +43,19 @@ def test_rotation_with_moving_load_constant_system_matrices(self):

self.assertTrue(isinstance(simulation._GetSolver().builder_and_solver, KratosGeo.ResidualBasedBlockBuilderAndSolverWithMassAndDamping))

res_path = os.path.join(file_path, test_name + result_extension)

reader = test_helper.GiDOutputFileReader()
res_path = os.path.join(file_path, test_name + result_extension)
simulation_output = reader.read_output_from(res_path)
rotations = simulation_output["results"]["ROTATION"]

# Validation for Time = 0.02
values_time_0_02 = reader.get_values_at_time(1.0, rotations)
value_for_node = reader.get_value_at_node(1, values_time_0_02)
# Validation for Time = 1.0
rotations_time_1 = reader.get_values_at_time(1.0, rotations)
rotations_for_node_1 = reader.get_value_at_node(1, rotations_time_1)

# This test is a regression test, if rotation is not added to the
# newmark upw scheme as a variable that needs to be predicted and
# updated, the results will be different.
self.assertAlmostEqual(-0.000177858, value_for_node[2])
# ResidualBasedBlockBuilderAndSolverWithMassAndDamping as a variable that
# needs to update the first/second time derivatives, the results will be different.
self.assertAlmostEqual(-0.000177858, rotations_for_node_1[2])

if __name__ == '__main__':
KratosUnittest.main()

0 comments on commit 482748b

Please sign in to comment.