-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'reset_ip_data' into 'master'
Reset integration point data by materialIDs See merge request ogs/ogs!4668
- Loading branch information
Showing
17 changed files
with
406 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
ogs_add_executable( | ||
pvtu2vtu | ||
PVTU2VTU.cpp | ||
${PROJECT_SOURCE_DIR}/Applications/Utils/ModelPreparation/PartitionMesh/IntegrationPointDataTools.cpp | ||
) | ||
target_link_libraries(pvtu2vtu GitInfoLib tclap MeshToolsLib NumLib) | ||
install(TARGETS pvtu2vtu RUNTIME DESTINATION bin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
Documentation/ProjectFile/prj/t_zero_mesh_field_data_by_material_ids.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
It specifies material IDs for resetting the integration point data. For the | ||
elements with the specified material IDs, their double-type integration point | ||
data are set to zero. | ||
|
||
It can be used for a restarted simulation with reactivated elements, e.g. | ||
a back-filling simulation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/** | ||
* \file | ||
* \copyright | ||
* Copyright (c) 2012-2023, OpenGeoSys Community (http://www.opengeosys.org) | ||
* Distributed under a Modified BSD License. | ||
* See accompanying file LICENSE.txt or | ||
* http://www.opengeosys.org/project/license | ||
* | ||
* Created on July 6, 2023, 4:21 PM | ||
*/ | ||
|
||
#include "ZeroMeshFieldDataByMaterialIDs.h" | ||
|
||
#include <algorithm> | ||
#include <functional> | ||
|
||
#include "IntegrationPointDataTools.h" | ||
#include "MeshLib/Elements/Element.h" | ||
#include "MeshLib/Mesh.h" | ||
#include "MeshLib/Utils/IntegrationPointWriter.h" | ||
|
||
namespace MeshToolsLib | ||
{ | ||
void zeroMeshFieldDataByMaterialIDs( | ||
MeshLib::Mesh& mesh, std::vector<int> const& selected_material_ids) | ||
{ | ||
auto const materialIds = materialIDs(mesh); | ||
if (!materialIds) | ||
{ | ||
OGS_FATAL( | ||
"Mesh contains no int-property vector named 'MaterialIDs' needed " | ||
"by the 'zero_mesh_field_data_by_materialIDs'"); | ||
} | ||
|
||
std::vector<std::size_t> element_ids_for_selected_materials; | ||
for (std::size_t i = 0; i < materialIds->size(); ++i) | ||
{ | ||
if (std::find(selected_material_ids.begin(), | ||
selected_material_ids.end(), | ||
(*materialIds)[i]) != selected_material_ids.end()) | ||
{ | ||
element_ids_for_selected_materials.push_back(i); | ||
} | ||
} | ||
|
||
MeshLib::Properties& properties = mesh.getProperties(); | ||
|
||
std::vector<std::size_t> element_ip_data_offsets; | ||
|
||
for (auto const& [name, property] : properties) | ||
{ | ||
if (auto const item_type = property->getMeshItemType(); | ||
item_type != MeshLib::MeshItemType::IntegrationPoint) | ||
{ | ||
continue; | ||
} | ||
|
||
// For special field data such as OGS_VERSION, | ||
// IntegrationPointMetaData, | ||
// etc., which are not "real" integration points: | ||
if (!property->getPropertyName().ends_with("_ip")) | ||
{ | ||
continue; | ||
} | ||
|
||
if (properties.template hasPropertyVector<double>( | ||
name, MeshLib::MeshItemType::IntegrationPoint)) | ||
{ | ||
auto& pv = *properties.template getPropertyVector<double>(name); | ||
const int n_components = pv.getNumberOfGlobalComponents(); | ||
|
||
if (element_ip_data_offsets.empty()) | ||
{ | ||
// The returned values has already been multiplied with | ||
// pv.getNumberOfGlobalComponents() | ||
element_ip_data_offsets = | ||
MeshToolsLib::getIntegrationPointDataOffsetsOfMeshElements( | ||
mesh.getElements(), pv, properties); | ||
|
||
// element_ip_data_offsets / pv.getNumberOfGlobalComponents() | ||
std::transform(element_ip_data_offsets.begin(), | ||
element_ip_data_offsets.end(), | ||
element_ip_data_offsets.begin(), | ||
[n = n_components](double const v) | ||
{ return v / n; }); | ||
} | ||
|
||
for (auto const element_id : element_ids_for_selected_materials) | ||
{ | ||
std::fill( | ||
pv.begin() + | ||
n_components * element_ip_data_offsets[element_id], | ||
pv.begin() + | ||
n_components * element_ip_data_offsets[element_id + 1], | ||
0.0); | ||
} | ||
} | ||
} | ||
} | ||
} // namespace MeshToolsLib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* \file | ||
* \copyright | ||
* Copyright (c) 2012-2023, OpenGeoSys Community (http://www.opengeosys.org) | ||
* Distributed under a Modified BSD License. | ||
* See accompanying file LICENSE.txt or | ||
* http://www.opengeosys.org/project/license | ||
* | ||
* Created on July 6, 2023, 4:21 PM | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <vector> | ||
|
||
namespace MeshLib | ||
{ | ||
class Mesh; | ||
|
||
} | ||
|
||
namespace MeshToolsLib | ||
{ | ||
|
||
void zeroMeshFieldDataByMaterialIDs( | ||
MeshLib::Mesh& mesh, std::vector<int> const& selected_material_ids); | ||
} // namespace MeshToolsLib |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.