Skip to content
Snippets Groups Projects
Commit 49aa8b36 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

Merge branch 'mpi_geo_msh' into 'master'

Enable node search function work under MPI

See merge request ogs/ogs!3919
parents 2c517172 8cd81bb5
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,10 @@ ...@@ -9,6 +9,10 @@
#include "BoundaryElementsAtPoint.h" #include "BoundaryElementsAtPoint.h"
#ifdef USE_PETSC
#include <mpi.h>
#endif
#include "GeoLib/Point.h" #include "GeoLib/Point.h"
#include "MathLib/Point3d.h" #include "MathLib/Point3d.h"
#include "MeshGeoToolsLib/MeshNodeSearcher.h" #include "MeshGeoToolsLib/MeshNodeSearcher.h"
...@@ -25,6 +29,27 @@ BoundaryElementsAtPoint::BoundaryElementsAtPoint( ...@@ -25,6 +29,27 @@ BoundaryElementsAtPoint::BoundaryElementsAtPoint(
: _mesh(mesh), _point(point) : _mesh(mesh), _point(point)
{ {
auto const node_ids = mshNodeSearcher.getMeshNodeIDs(_point); auto const node_ids = mshNodeSearcher.getMeshNodeIDs(_point);
#ifdef USE_PETSC
std::size_t const number_of_found_nodes_at_rank = node_ids.size();
std::size_t number_of_total_found_nodes = 0;
MPI_Allreduce(&number_of_found_nodes_at_rank, &number_of_total_found_nodes,
1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD);
if (number_of_total_found_nodes == 0)
{
OGS_FATAL(
"BoundaryElementsAtPoint: the mesh node searcher was unable to "
"locate the point ({:f}, {:f}, {:f}) in the mesh.",
_point[0], _point[1], _point[2]);
}
if (number_of_found_nodes_at_rank == 0)
{
return;
}
#else
if (node_ids.empty()) if (node_ids.empty())
{ {
OGS_FATAL( OGS_FATAL(
...@@ -32,10 +57,13 @@ BoundaryElementsAtPoint::BoundaryElementsAtPoint( ...@@ -32,10 +57,13 @@ BoundaryElementsAtPoint::BoundaryElementsAtPoint(
"locate the point ({:f}, {:f}, {:f}) in the mesh.", "locate the point ({:f}, {:f}, {:f}) in the mesh.",
_point[0], _point[1], _point[2]); _point[0], _point[1], _point[2]);
} }
#endif
if (node_ids.size() == 1) if (node_ids.size() == 1)
{ {
std::array<MeshLib::Node*, 1> const nodes = { std::array<MeshLib::Node*, 1> const nodes = {
{const_cast<MeshLib::Node*>(_mesh.getNode(node_ids[0]))}}; {const_cast<MeshLib::Node*>(_mesh.getNode(node_ids[0]))}};
_boundary_elements.push_back(new MeshLib::Point{nodes, node_ids[0]}); _boundary_elements.push_back(new MeshLib::Point{nodes, node_ids[0]});
return; return;
} }
......
...@@ -9,6 +9,10 @@ ...@@ -9,6 +9,10 @@
#include "ConstructMeshesFromGeometries.h" #include "ConstructMeshesFromGeometries.h"
#ifdef USE_PETSC
#include <mpi.h>
#endif
#include "BaseLib/Logging.h" #include "BaseLib/Logging.h"
#include "BoundaryElementsSearcher.h" #include "BoundaryElementsSearcher.h"
#include "GeoLib/GEOObjects.h" #include "GeoLib/GEOObjects.h"
...@@ -65,6 +69,10 @@ constructAdditionalMeshesFromGeometries( ...@@ -65,6 +69,10 @@ constructAdditionalMeshesFromGeometries(
MeshLib::cloneElements( MeshLib::cloneElements(
boundary_element_searcher.getBoundaryElements( boundary_element_searcher.getBoundaryElements(
geometry, multiple_nodes_allowed)))); geometry, multiple_nodes_allowed))));
#ifdef USE_PETSC
MPI_Barrier(MPI_COMM_WORLD);
#endif
} }
} }
return additional_meshes; return additional_meshes;
......
...@@ -17,6 +17,11 @@ ...@@ -17,6 +17,11 @@
#include "MeshGeoToolsLib/ConstructMeshesFromGeometries.h" #include "MeshGeoToolsLib/ConstructMeshesFromGeometries.h"
#include "MeshGeoToolsLib/SearchLength.h" #include "MeshGeoToolsLib/SearchLength.h"
#include "MeshLib/Mesh.h" #include "MeshLib/Mesh.h"
#ifdef USE_PETSC
#include "MeshLib/NodePartitionedMesh.h"
#endif
#include "MeshLib/MeshGenerators/MeshGenerator.h" #include "MeshLib/MeshGenerators/MeshGenerator.h"
#include "Tests/GeoLib/CreateTestPoints.h" #include "Tests/GeoLib/CreateTestPoints.h"
...@@ -25,8 +30,16 @@ TEST(ConstructAdditionalMeshesFromGeoObjects, PointMesh) ...@@ -25,8 +30,16 @@ TEST(ConstructAdditionalMeshesFromGeoObjects, PointMesh)
// create 10x10x10 mesh using 1000 hexahedra // create 10x10x10 mesh using 1000 hexahedra
const double length = 10.0; const double length = 10.0;
const std::size_t n_subdivisions = 10; const std::size_t n_subdivisions = 10;
#ifdef USE_PETSC
std::unique_ptr<MeshLib::NodePartitionedMesh> mesh =
std::make_unique<MeshLib::NodePartitionedMesh>(
*MeshLib::MeshGenerator::generateRegularHexMesh(length,
n_subdivisions));
#else
std::unique_ptr<MeshLib::Mesh> mesh( std::unique_ptr<MeshLib::Mesh> mesh(
MeshLib::MeshGenerator::generateRegularHexMesh(length, n_subdivisions)); MeshLib::MeshGenerator::generateRegularHexMesh(length, n_subdivisions));
#endif
// create geometry: for every mesh node exactly one point // create geometry: for every mesh node exactly one point
GeoLib::GEOObjects geometries; GeoLib::GEOObjects geometries;
...@@ -55,8 +68,16 @@ TEST(ConstructAdditionalMeshesFromGeoObjects, PointMeshLargeSearchRadius) ...@@ -55,8 +68,16 @@ TEST(ConstructAdditionalMeshesFromGeoObjects, PointMeshLargeSearchRadius)
// create 10x10x10 mesh using 1000 hexahedra // create 10x10x10 mesh using 1000 hexahedra
const double length = 10.0; const double length = 10.0;
const std::size_t n_subdivisions = 10; const std::size_t n_subdivisions = 10;
#ifdef USE_PETSC
std::unique_ptr<MeshLib::NodePartitionedMesh> mesh =
std::make_unique<MeshLib::NodePartitionedMesh>(
*MeshLib::MeshGenerator::generateRegularHexMesh(length,
n_subdivisions));
#else
std::unique_ptr<MeshLib::Mesh> mesh( std::unique_ptr<MeshLib::Mesh> mesh(
MeshLib::MeshGenerator::generateRegularHexMesh(length, n_subdivisions)); MeshLib::MeshGenerator::generateRegularHexMesh(length, n_subdivisions));
#endif
// create geometry: for every mesh node exactly one point // create geometry: for every mesh node exactly one point
GeoLib::GEOObjects geometries; GeoLib::GEOObjects geometries;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment