Skip to content

Commit

Permalink
Merge pull request #11577 from KratosMultiphysics/RomApp_ECM_candidat…
Browse files Browse the repository at this point in the history
…eElements

[RomApp] Adding candidate elements (and/or conditions) to HROM
  • Loading branch information
Rbravo555 authored Sep 22, 2023
2 parents 272ff81 + 057ce8a commit 76c698f
Show file tree
Hide file tree
Showing 7 changed files with 245 additions and 81 deletions.
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;
}

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

0 comments on commit 76c698f

Please sign in to comment.