Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[StructuralMechanicsApplication] bugfix jumping moving load #11699

Merged
merged 2 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) MovingLoadCondition
void load( Serializer& rSerializer ) override
{
KRATOS_SERIALIZE_LOAD_BASE_CLASS( rSerializer, BaseLoadCondition );
rSerializer.save("mIsMovingLoad", mIsMovingLoad);
rSerializer.load("mIsMovingLoad", mIsMovingLoad);
}

///@}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ bool SetMovingLoadProcess::IsConditionReversed(const Condition& rCondition, cons
}



std::vector<Condition> SetMovingLoadProcess::SortConditions(ModelPart::ConditionsContainerType& rUnsortedConditions, Condition& rFirstCondition)
{

Expand All @@ -160,37 +159,36 @@ std::vector<Condition> SetMovingLoadProcess::SortConditions(ModelPart::Condition
std::vector<Condition> sorted_conditions;
std::vector<int> visited_indices;
GeometricalObject::GeometryType& r_geom_first = rFirstCondition.GetGeometry();
std::set<IndexType> node_id_vector{ r_geom_first[0].Id(),r_geom_first[1].Id() };
std::vector<IndexType> node_id_vector{ r_geom_first[0].Id(),r_geom_first[1].Id() };

bool is_cond_reversed = mIsCondReversedVector[0];
while (visited_indices.size() != unsorted_conditions_v.size()){
for (IndexType i =0; i< unsorted_conditions_v.size(); i++){
while (visited_indices.size() != unsorted_conditions_v.size()) {
for (IndexType i = 0; i < unsorted_conditions_v.size(); i++) {
Condition& r_cond = unsorted_conditions_v[i];
GeometricalObject::GeometryType& r_geom = r_cond.GetGeometry();


// check if current index is already added to sorted condition vector
if (!std::count(visited_indices.begin(), visited_indices.end(), i)){
if (!std::count(visited_indices.begin(), visited_indices.end(), i)) {
// check if geom has a shared node with previous geom
if (node_id_vector.find(r_geom.Points()[0].Id()) != node_id_vector.end() || node_id_vector.find(r_geom.Points()[1].Id()) != node_id_vector.end()){
if (sorted_conditions.size() == 0){
if (std::find(node_id_vector.begin(), node_id_vector.end(), r_geom.Points()[0].Id()) != node_id_vector.end() || std::find(node_id_vector.begin(), node_id_vector.end(), r_geom.Points()[1].Id()) != node_id_vector.end()) {
if (sorted_conditions.size() == 0) {
// check if both nodes of geom are equal to nodes in start element, only do this to add the first element in the sorted conditions vector
if (node_id_vector.find(r_geom[0].Id()) != node_id_vector.end() && node_id_vector.find(r_geom.Points()[1].Id()) != node_id_vector.end()){
if (std::find(node_id_vector.begin(), node_id_vector.end(), r_geom.Points()[0].Id()) != node_id_vector.end() && std::find(node_id_vector.begin(), node_id_vector.end(), r_geom.Points()[1].Id()) != node_id_vector.end()) {
node_id_vector = { r_geom[0].Id(),r_geom[1].Id() };
sorted_conditions.push_back(r_cond);
visited_indices.push_back(i);
}
} else {
// sort nodes in condition, such that new node is connected to previous condition
std::set<IndexType>::iterator prev_id;
if (is_cond_reversed){
prev_id = node_id_vector.begin();
IndexType prev_id;
if (is_cond_reversed) {
prev_id = node_id_vector[0];
} else {
prev_id = node_id_vector.end();
--prev_id;
prev_id = node_id_vector[1];
}

if (*prev_id != r_geom.Points()[0].Id()){
if (prev_id != r_geom.Points()[0].Id()) {
is_cond_reversed = true;
mIsCondReversedVector.push_back(is_cond_reversed);
} else {
Expand All @@ -205,14 +203,13 @@ std::vector<Condition> SetMovingLoadProcess::SortConditions(ModelPart::Condition
}
}
}

}
}

return sorted_conditions;
}


std::vector<Condition> SetMovingLoadProcess::FindEndConditions()
{
std::vector<IndexType> node_id_vector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,14 +463,14 @@ def _TestSetMovingLoadMultipleConditions(self):
#create nodes
second_coord = [1.0, 0.0, 0.0]
third_coord = [2.0, 0.0, 0.0]
mp.CreateNewNode(1, 0.0, 0.0, 0.0)
mp.CreateNewNode(4, 0.0, 0.0, 0.0)
mp.CreateNewNode(2, second_coord[0],second_coord[1],second_coord[2])
mp.CreateNewNode(3, third_coord[0], third_coord[1], third_coord[2])

strategy = self.setup_strategy(mp)
# create condition
conditions = []
conditions.append(mp.CreateNewCondition("MovingLoadCondition2D2N", 1, [1, 2], mp.GetProperties()[1]))
conditions.append(mp.CreateNewCondition("MovingLoadCondition2D2N", 1, [4, 2], mp.GetProperties()[1]))
conditions.append(mp.CreateNewCondition("MovingLoadCondition2D2N", 2, [2, 3], mp.GetProperties()[1]))

parameters = KratosMultiphysics.Parameters("""
Expand Down