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

[RomApp] Adding candidate elements (and/or conditions) to HROM #11577

Merged
merged 21 commits into from
Sep 22, 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 @@ -54,6 +54,8 @@ void AddCustomUtilitiesToPython(pybind11::module& m)
.def_static("GetElementIdsNotInHRomModelPart", &RomAuxiliaryUtilities::GetElementIdsNotInHRomModelPart)
.def_static("GetHRomMinimumConditionsIds", &RomAuxiliaryUtilities::GetHRomMinimumConditionsIds)
.def_static("ProjectRomSolutionIncrementToNodes", &RomAuxiliaryUtilities::ProjectRomSolutionIncrementToNodes)
.def_static("GetElementIdsInModelPart", &RomAuxiliaryUtilities::GetElementIdsInModelPart)
.def_static("GetConditionIdsInModelPart", &RomAuxiliaryUtilities::GetConditionIdsInModelPart)
;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ std::vector<IndexType> RomAuxiliaryUtilities::GetNodalNeighbouringElementIdsNotI
{
std::vector<IndexType> new_element_ids;
const auto& r_elem_weights = rHRomWeights.at("Elements");

FindGlobalNodalEntityNeighboursProcess<ModelPart::ElementsContainerType> find_nodal_elements_neighbours_process(rModelPart);
find_nodal_elements_neighbours_process.Execute();

Expand Down Expand Up @@ -373,7 +373,7 @@ std::vector<IndexType> RomAuxiliaryUtilities::GetElementIdsNotInHRomModelPart(

for (const auto& r_elem : rModelPartWithElementsToInclude.Elements()) {
IndexType element_id = r_elem.Id();

// Check if the element is already added
if (r_elem_weights.find(element_id - 1) == r_elem_weights.end()) {
new_element_ids.push_back(element_id - 1);
Expand All @@ -383,6 +383,7 @@ std::vector<IndexType> RomAuxiliaryUtilities::GetElementIdsNotInHRomModelPart(
return new_element_ids;
}


std::vector<IndexType> RomAuxiliaryUtilities::GetConditionIdsNotInHRomModelPart(
const ModelPart& rModelPart,
const ModelPart& rModelPartWithConditionsToInclude,
Expand All @@ -393,7 +394,7 @@ std::vector<IndexType> RomAuxiliaryUtilities::GetConditionIdsNotInHRomModelPart(

for (const auto& r_cond : rModelPartWithConditionsToInclude.Conditions()) {
IndexType condition_id = r_cond.Id();

// Check if the condition is already added
if (r_cond_weights.find(condition_id - 1) == r_cond_weights.end()) {
new_condition_ids.push_back(condition_id - 1);
Expand All @@ -403,6 +404,28 @@ std::vector<IndexType> RomAuxiliaryUtilities::GetConditionIdsNotInHRomModelPart(
return new_condition_ids;
}

std::vector<IndexType> RomAuxiliaryUtilities::GetElementIdsInModelPart(
const ModelPart& rModelPart)
{
std::vector<IndexType> element_ids;

for (const auto& r_elem : rModelPart.Elements()) {
element_ids.push_back(r_elem.Id());
}
return element_ids;
}

std::vector<IndexType> RomAuxiliaryUtilities::GetConditionIdsInModelPart(
const ModelPart& rModelPart)
{
std::vector<IndexType> condition_ids;

for (const auto& r_cond : rModelPart.Conditions()) {
condition_ids.push_back(r_cond.Id());
}
return condition_ids;
}
Comment on lines +407 to +427
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just pointing that these two can be easily done in parallel with an index partition.


std::vector<IndexType> RomAuxiliaryUtilities::GetHRomMinimumConditionsIds(
const ModelPart& rModelPart,
const std::map<IndexType, double>& rHRomConditionWeights)
Expand Down Expand Up @@ -567,6 +590,6 @@ void RomAuxiliaryUtilities::GetPsiElemental(
noalias(row(rPsiElemental, i)) = row(r_nodal_rom_basis, row_id);
}
}
}
}

} // namespace Kratos
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ class KRATOS_API(ROM_APPLICATION) RomAuxiliaryUtilities
static std::vector<IndexType> GetHRomConditionParentsIds(
const ModelPart& rModelPart,
const std::map<std::string, std::map<IndexType, double>>& rHRomWeights);

/**
* @brief Retrieve the IDs of elements neighboring nodes in a given sub-model part but not present in HRom weights.
*
* This function iterates over all the nodes in the provided sub-model part (`rGivenModelPart`) and collects
* the IDs of the elements neighboring each node. The neighboring elements are determined using the
* 'NEIGHBOUR_ELEMENTS' value attached to each node. The function then checks if these elements are already
* present in `rHRomWeights`. If not, their IDs are added to the return vector. It's important to note that
* This function iterates over all the nodes in the provided sub-model part (`rGivenModelPart`) and collects
* the IDs of the elements neighboring each node. The neighboring elements are determined using the
* 'NEIGHBOUR_ELEMENTS' value attached to each node. The function then checks if these elements are already
* present in `rHRomWeights`. If not, their IDs are added to the return vector. It's important to note that
* this function assumes that the 'NEIGHBOUR_ELEMENTS' values are already computed for the nodes in the model part.
*
* @param rModelPart The complete model part which houses all the elements.
Expand Down Expand Up @@ -168,6 +168,15 @@ class KRATOS_API(ROM_APPLICATION) RomAuxiliaryUtilities
const ModelPart& rModelPart,
const std::map<IndexType, double>& rHRomConditionWeights);


static std::vector<IndexType> GetElementIdsInModelPart(
const ModelPart& rModelPart
);

static std::vector<IndexType> GetConditionIdsInModelPart(
const ModelPart& rModelPart
);

/**
* @brief Project the ROM solution increment onto the nodal basis
* For a given model part this function takes the ROM_SOLUTION_INCREMENT, which is assumed to be
Expand Down
Loading