Commit 67117d83 authored by Nicolas CHEVAUGEON's avatar Nicolas CHEVAUGEON

improving build (FindXXX now support REQUIRED)

parent e40604ab
......@@ -6,14 +6,27 @@ enable_testing()
#set(CMAKE_CXX_COMPILER /usr/bin/mpicxx)
find_package(Trellis)
find_package(ScorecCore)
find_package(Moab)
#find_package(Trellis)
#find_package(ScorecCore)
#find_package(Moab)
#find_package(XfileMeshInterfaces)
#add_subdirectory(src/core)
add_subdirectory(src/test)
add_subdirectory(src/test_scorec)
add_subdirectory(src/test_moab)
find_package(ScorecCore)
if (ScorecCore_FOUND)
add_subdirectory(src/test_scorec)
else()
message("####### Target test_scorec won't be build since it Need ScorecCore")
endif()
find_package(Moab)
if (Moab_FOUND)
add_subdirectory(src/test_moab)
else()
message("####### Target test_moab won't be build since it Need Moab")
endif()
......@@ -4,20 +4,8 @@
set(MOAB_INSTALL "/home/chevaugeon/develop/moab/moab-4.6.3/install")
set(MOAB_LIB ${MOAB_INSTALL}/lib)
find_package(MPI REQUIRED)
set(MOAB_INCLUDE_DIR ${MOAB_INSTALL}/include )
message("###### MOAB_INCLUDE_DIR " ${MOAB_INCLUDE_DIR})
message("###### MPI_CXX_INCLUDE_PATH " ${MPI_CXX_INCLUDE_PATH})
list(APPEND MOAB_INCLUDE_DIR ${MPI_CXX_INCLUDE_PATH})
find_library(MOAB_LIBRARY MOAB PATH ${MOAB_LIB})
list(APPEND MOAB_LIBRARIES
${MOAB_LIBRARY}
)
if ( MOAB_LIBRARIES)
set (Moab_FOUND TRUE)
else()
set (Moab_FOUND FALSE)
endif()
find_package_handle_standard_args(Moab DEFAULT_MSG MOAB_LIBRARY MOAB_INCLUDE_DIR)
set(Moab_LIBRARIES ${MOAB_LIBRARY})
set(Moab_INCLUDE_DIRS ${MOAB_INCLUDE_DIR} ${MPI_CXX_INCLUDE_PATH})
......@@ -2,61 +2,46 @@
#
set(SCOREC_CORE_INSTALL "/home/chevaugeon/develop/scorec_core/install")
set(SCOREC_CORE_LIB ${SCOREC_CORE_INSTALL}/lib)
set(SCOREC_CORE_LIBPATH ${SCOREC_CORE_INSTALL}/lib)
find_package(MPI REQUIRED)
set(SCOREC_CORE_INCLUDE_DIR ${SCOREC_CORE_INSTALL}/include )
message("###### SCOREC_CORE_INCLUDE_DIR " ${SCOREC_CORE_INCLUDE_DIR})
message("###### MPI_CXX_INCLUDE_PATH " ${MPI_CXX_INCLUDE_PATH})
list(APPEND SCOREC_CORE_INCLUDE_DIR ${MPI_CXX_INCLUDE_PATH})
message("###### SCOREC_CORE_INCLUDE_DIR " ${SCOREC_CORE_INCLUDE_DIR})
find_library(PUMI_LIBRARY pumi PATH ${SCOREC_CORE_LIBPATH})
find_package_handle_standard_args(pumi DEFAULT_MSG PUMI_LIBRARY)
find_library(CRV_LIBRARY crv PATH ${SCOREC_CORE_LIBPATH})
find_package_handle_standard_args(crv DEFAULT_MSG CRV_LIBRARY)
find_library(SPR_LIBRARY spr PATH ${SCOREC_CORE_LIBPATH})
find_package_handle_standard_args(spr DEFAULT_MSG SPR_LIBRARY)
find_library(PH_LIBRARY ph PATH ${SCOREC_CORE_LIBPATH})
find_package_handle_standard_args(ph DEFAULT_MSG PH_LIBRARY)
find_library(MA_LIBRARY ma PATH ${SCOREC_CORE_LIBPATH})
find_package_handle_standard_args(ma DEFAULT_MSG MA_LIBRARY)
find_library(MDS_LIBRARY mds PATH ${SCOREC_CORE_LIBPATH})
find_package_handle_standard_args(mds DEFAULT_MSG MDS_LIBRARY)
find_library(APF_ZOLTAN_LIBRARY apf_zoltan PATH ${SCOREC_CORE_LIBPATH})
find_package_handle_standard_args(apf_zoltan DEFAULT_MSG APF_ZOLTAN_LIBRARY)
find_library(SAM_LIBRARY sam PATH ${SCOREC_CORE_LIBPATH})
find_package_handle_standard_args(sam DEFAULT_MSG SAM_LIBRARY)
find_library(APF_LIBRARY apf PATH ${SCOREC_CORE_LIBPATH})
find_package_handle_standard_args(apf DEFAULT_MSG APF_LIBRARY)
find_library(GMI_LIBRARY gmi PATH ${SCOREC_CORE_LIBPATH})
find_package_handle_standard_args(gmi DEFAULT_MSG GMI_LIBRARY)
find_library(LION_LIBRARY lion PATH ${SCOREC_CORE_LIBPATH})
find_package_handle_standard_args(lion DEFAULT_MSG LION_LIBRARY)
find_library(MTH_LIBRARY mth PATH ${SCOREC_CORE_LIBPATH})
find_package_handle_standard_args(mth DEFAULT_MSG MTH_LIBRARY)
find_library(PCU_LIBRARY pcu PATH ${SCOREC_CORE_LIBPATH})
find_package_handle_standard_args(pcu DEFAULT_MSG PCU_LIBRARY)
#pumi.a crv.a spr.a ph.a ma.a mds.a parma.a apf_zoltan.a sam.a apf.a gmi.a lion.a mth.a pcu.a
find_library(PUMI_LIBRARIES pumi PATH ${SCOREC_CORE_LIB})
find_library(CRV_LIBRARIES crv PATH ${SCOREC_CORE_LIB})
find_library(SPR_LIBRARIES spr PATH ${SCOREC_CORE_LIB})
find_library(PH_LIBRARIES ph PATH ${SCOREC_CORE_LIB})
find_library(MA_LIBRARIES ma PATH ${SCOREC_CORE_LIB})
find_library(MDS_LIBRARIES mds PATH ${SCOREC_CORE_LIB})
find_library(APF_ZOLTAN_LIBRARIES apf_zoltan PATH ${SCOREC_CORE_LIB})
find_library(SAM_LIBRARIES sam PATH ${SCOREC_CORE_LIB})
find_library(APF_LIBRARIES apf PATH ${SCOREC_CORE_LIB})
find_library(GMI_LIBRARIES gmi PATH ${SCOREC_CORE_LIB})
find_library(LION_LIBRARIES lion PATH ${SCOREC_CORE_LIB})
find_library(MTH_LIBRARIES mth PATH ${SCOREC_CORE_LIB})
find_library(PCU_LIBRARIES pcu PATH ${SCOREC_CORE_LIB})
find_package_handle_standard_args(ScorecCore REQUIRED_VARS
PUMI_LIBRARY CRV_LIBRARY SPR_LIBRARY PH_LIBRARY MA_LIBRARY MDS_LIBRARY APF_ZOLTAN_LIBRARY SAM_LIBRARY
APF_LIBRARY GMI_LIBRARY LION_LIBRARY MTH_LIBRARY PCU_LIBRARY)
list(APPEND SCOREC_CORE_LIBRARIES
${PUMI_LIBRARIES}
${CRV_LIBRARIES}
${SPR_LIBRARIES}
${PH_LIBRARIES}
${MA_LIBRARIES}
${MDS_LIBRARIES}
${APF_ZOLTAN_LIBRARIES}
${SAM_LIBRARIES}
${APF_LIBRARIES}
${GMI_LIBRARIES}
${LION_LIBRARIES}
${MTH_LIBRARIES}
${PCU_LIBRARIES}
${MPI_CXX_LIBRARIES}
set(ScorecCore_LIBRARIES ${PUMI_LIBRARY} ${CRV_LIBRARY} ${SPR_LIBRARY} ${PH_LIBRARY}
${MA_LIBRARY} ${MDS_LIBRARY} ${APF_ZOLTAN_LIBRARY} ${SAM_LIBRARY}
${APF_LIBRARY} ${GMI_LIBRARY} ${LION_LIBRARY} ${MTH_LIBRARY} ${PCU_LIBRARY} ${MPI_CXX_LIBRARIES}
)
if ( PUMI_LIBRARIES AND CRV_LIBRARIES
AND SPR_LIBRARIES
AND PH_LIBRARIES
AND MA_LIBRARIES
AND MDS_LIBRARIES
AND APF_ZOLTAN_LIBRARIES
AND SAM_LIBRARIES
AND APF_LIBRARIES
AND GMI_LIBRARIES
AND LION_LIBRARIES
AND MTH_LIBRARIES
AND PCU_LIBRARIES)
set (ScorecCore_FOUND TRUE)
else()
set (ScorecCore_FOUND FALSE)
endif()
set(ScorecCore_INCLUDE_DIRS ${SCOREC_CORE_INCLUDE_DIR} ${MPI_CXX_INCLUDE_PATH})
......@@ -2,31 +2,27 @@
#
set(TRELLIS_INSTALL "/home/chevaugeon/develop/GIT_gem/sources/mine/mdb")
find_library(AOMD_LIBRARIES AOMD
PATH
${TRELLIS_INSTALL}/Trellis/lib
)
find_library(Util_LIBRARIES Util
PATH
${TRELLIS_INSTALL}/Trellis/lib
)
find_library(model_LIBRARIES model
PATH
${TRELLIS_INSTALL}/Trellis/lib
)
find_library(AOMD_LIBRARY AOMD PATH ${TRELLIS_INSTALL}/Trellis/lib)
find_package_handle_standard_args(AOMD DEFAULT_MSG AOMD_LIBRARY)
find_library(Util_LIBRARY Util PATH ${TRELLIS_INSTALL}/Trellis/lib)
find_package_handle_standard_args(Util DEFAULT_MSG Util_LIBRARY)
find_library(model_LIBRARY model PATH ${TRELLIS_INSTALL}/Trellis/lib)
find_package_handle_standard_args(model DEFAULT_MSG model_LIBRARY)
find_package_handle_standard_args(Trellis REQUIRED_VARS model_LIBRARY AOMD_LIBRARY Util_LIBRARY)
list(APPEND Trellis_LIBRARIES
${AOMD_LIBRARIES}
${Util_LIBRARIES}
${model_LIBRARIES}
set(Trellis_LIBRARIES
${AOMD_LIBRARY}
${Util_LIBRARY}
${model_LIBRARY}
)
list(APPEND Trellis_INCLUDE_DIR
set(Trellis_INCLUDE_DIRS
${TRELLIS_INSTALL}/Trellis/AOMD/AOMD/include
${TRELLIS_INSTALL}/Trellis/AOMD/AOMD/parallel
${TRELLIS_INSTALL}/Trellis/AOMD/AOMD/cint
......@@ -44,12 +40,4 @@ list(APPEND Trellis_INCLUDE_DIR
${TRELLIS_INSTALL}/Trellis/Util/Util/util
)
#set (AOMD_LIBRARIES "AOMD_LIBRARIES_NOT_FOUND" )
#set (Util_LIBRARIES "Util_LIBRARIES_NOT_FOUND" )
#set (model_LIBRARIES "model_LIBRARIES_NOT_FOUND" )
if ( AOMD_LIBRARIES AND Util_LIBRARIES AND model_LIBRARIES )
set(Trellis_FOUND TRUE)
else()
set(Trellis_FOUND FALSE)
endif()
This diff is collapsed.
......@@ -98,6 +98,10 @@
void copy (const InputRange &source, OutputRange &result){
std::copy(source.begin(), source.end(), result.begin());
}
template <class T, class OutputRange>
void copy (std::initializer_list<T> source, OutputRange &result){
std::copy(source.begin(), source.end(), result.begin());
}
template <class InputRange, class OutputRange, class UnaryOperation>
void transform (const InputRange &source, OutputRange &result, UnaryOperation op){
......
......@@ -59,16 +59,18 @@ add_executable(atomic_structured atomic_structured.cc)
set_target_properties(atomic_structured PROPERTIES CXX_STANDARD 17 CXX_EXTENSIONS OFF)
target_include_directories(atomic_structured PRIVATE ../core ../io)
if (Trellis_FOUND AND ScorecCore_FOUND AND Moab_FOUND)
add_executable(bench_build_large_mesh bench_build_large_mesh.cc ../io/scorec_core_to_gmsh.cc ../io/moab_to_gmsh.cc)
set_target_properties(bench_build_large_mesh PROPERTIES CXX_STANDARD 17 CXX_EXTENSIONS OFF)
target_include_directories(bench_build_large_mesh PRIVATE ../core ../io ${Trellis_INCLUDE_DIR} ${SCOREC_CORE_INCLUDE_DIR} ${MOAB_INCLUDE_DIR})
target_link_libraries(bench_build_large_mesh ${Trellis_LIBRARIES} ${SCOREC_CORE_LIBRARIES} ${MOAB_LIBRARIES})
add_test(bench_build_large_mesh.cc_t bench_build_large_mesh)
find_package(Moab)
find_package(ScorecCore)
find_package(Trellis)
if(Moab_FOUND AND ScorecCore_FOUND AND Trellis_FOUND)
add_subdirectory(bench_build_large_mesh)
else()
message("####### Target bench_build_large_mesh won't be build since it Need Trellis and ScorecCore and Moab")
message("bench_build_large_mesh won't be build since Moab or ScorecCore or Trellis was not found")
endif()
add_custom_target(link_target ALL
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/data ${CMAKE_CURRENT_BINARY_DIR}/data)
......
find_package(Moab REQUIRED)
find_package(ScorecCore REQUIRED)
find_package(Trellis REQUIRED)
#find_package(XfileMeshInterfaces)
if (Trellis_FOUND AND ScorecCore_FOUND AND Moab_FOUND)
add_executable(bench_build_large_mesh bench_build_large_mesh.cc ../../io/scorec_core_to_gmsh.cc ../../io/moab_to_gmsh.cc)
set_target_properties(bench_build_large_mesh PROPERTIES CXX_STANDARD 17 CXX_EXTENSIONS OFF)
target_include_directories(bench_build_large_mesh PRIVATE ../../core ../../io ${Trellis_INCLUDE_DIRS} ${ScorecCore_INCLUDE_DIRS} ${Moab_INCLUDE_DIRS})
target_link_libraries(bench_build_large_mesh ${Trellis_LIBRARIES} ${ScorecCore_LIBRARIES} ${Moab_LIBRARIES})
add_test(bench_build_large_mesh.cc_t bench_build_large_mesh)
else()
message("####### Target bench_build_large_mesh won't be build since it Need Trellis and ScorecCore and Moab")
endif()
#include "bench_build_large_mesh.h"
#include "bench_build_large_mesh_moab.h"
template <typename T>
using allocator_mine_t = allocator_monitor <T>;
......@@ -32,15 +34,16 @@ int main(int argc, char *argv[]){
bool aomd_build_all = true;
bool scorec_core = false;
bool moab = false;
std::string meshbase = "mdb";
bool xfileMeshinterfaceAOMD = true;
std::string meshbase = "moab";
if (argc>1) {
meshbase = argv[1];
}
if (meshbase == "mdb") {
mdb_one_level = false;
mdb_oriented_one_level = false;
mdb_all = false;
mdb_top_to_vertices = true;
mdb_all = true;
mdb_top_to_vertices= false;
}
if (meshbase == "aomd") aomd = true;
if (meshbase == "scorec") scorec_core = true;
......@@ -471,87 +474,16 @@ int main(int argc, char *argv[]){
apf::destroyMesh(m);
PCU_Comm_Free();
}//end scorec
if(moab)
{
if(moab){
std::cout << "Testing moab mesh" << std::endl;
moab::Interface* m = new (std::nothrow) moab::Core;
if (!m) return 1;
using vertex = moab::EntityHandle;
using region = moab::EntityHandle;
std::unordered_map<index, vertex , structured_mesh::index::hash> index_to_v;
index_to_v.reserve(g.vertices_range().size() );
moab::ErrorCode rval;
int idmemoinit = memo_usage.start("moab_init");
int idmemofull = memo_usage.start("moab_full");
my_time_t start = my_clock_t::now();
for (auto ijk : g.vertices_range()) {
vertex v;
rval = m->create_vertex( calc(ijk).data(), v);
index_to_v[ijk] = v;
}
for (auto ijk : g.hexs_range())
for (const auto &tet : g.tets(ijk)){
region r;
std::array<vertex, 4 > vertices = {index_to_v[tet[0]] , index_to_v[tet[1]], index_to_v[tet[2]], index_to_v[tet[3]] } ;
m->create_element(moab::EntityType::MBTET, vertices.data(), 4, r );
}
my_time_t end= my_clock_t::now();
my_duration_t time_build_mesh (end-start);
memo_usage.end(idmemoinit);
std::cout <<" Mesh build in "<< time_build_mesh.count() << "s "<<std::endl;
int nvert, nedge, ntri, ntet;
rval = m->get_number_entities_by_type(0, moab::MBVERTEX, nvert, false);
rval = m->get_number_entities_by_type(0, moab::MBEDGE, nedge, false);
rval = m->get_number_entities_by_type(0, moab::MBTRI, ntri, false);
rval = m->get_number_entities_by_type(0, moab::MBTET, ntet, false);
std::cout <<" "<< nvert << " vertices, "<< nedge << " edges, "<< ntri << " faces, " <<ntet << " regions." << std::endl;
my_duration_t time_export;
if(doexport){
std::ofstream outfile("mesh_moab.msh");
my_time_t start = my_clock_t::now();
exportMOABToGMSH( m, outfile );
my_time_t end = my_clock_t::now();
time_export = (end-start);
std::cout <<" Time export to moab : "<<time_export.count() << std::endl;
}
{
moab::Range tets, faces, edges, vertices;
moab::Range tets_faces, faces_tets;
moab::Range faces_edges, edges_faces;
moab::Range edges_vertices, vertices_edges;
// std::cout << "get "
m->get_entities_by_type(0, moab::MBTET, tets);
m->get_adjacencies(tets , 2, true, tets_faces, moab::Interface::UNION);
m->get_entities_by_type(0, moab::MBTRI, faces);
m->get_adjacencies(faces , 3, true, faces_tets, moab::Interface::UNION);
m->get_adjacencies(faces , 1, true, faces_edges, moab::Interface::UNION);
m->get_entities_by_type(0, moab::MBEDGE, edges);
m->get_adjacencies(edges , 0, true, edges_vertices, moab::Interface::UNION);
m->get_entities_by_type(0, moab::MBVERTEX, vertices);
m->get_adjacencies(vertices, 1, true, vertices_edges, moab::Interface::UNION);
}
end= my_clock_t::now();
my_duration_t time_build_edge_face_mesh = (end-start) - time_export;
std::cout <<" Mesh egde and faces build in "<< time_build_edge_face_mesh.count() << "s "<<std::endl;
memo_usage.end(idmemofull);
rval = m->get_number_entities_by_type(0, moab::MBVERTEX, nvert, false);
rval = m->get_number_entities_by_type(0, moab::MBEDGE, nedge, false);
rval = m->get_number_entities_by_type(0, moab::MBTRI, ntri, false);
rval = m->get_number_entities_by_type(0, moab::MBTET, ntet, false);
std::cout <<" "<< nvert << " vertices, "<< nedge << " edges, "<< ntri << " faces, " <<ntet << " regions." << std::endl;
if (dobench_edge_vertices) compute_dim_cog(m, 1);
if (dobench_tri_vertices) compute_dim_cog(m, 2);
if (dobench_tet_vertices) compute_dim_cog(m, 3);
auto m = create_moab_simplex_mesh_from_structured_mesh(g, calc, memo_usage, doexport);
using entity = moab::EntityHandle;
moab::Range tets;
rval = m->get_entities_by_type(0, moab::MBTET, tets);
m->get_entities_by_type(0, moab::MBTET, tets);
moab::EntityHandle tet0 = tets[0];
if (dobench_tet_face_face_tet)
{
neighbors_moab neib(m);
if (dobench_tet_face_face_tet) {
neighbors_moab neib(m.get());
my_time_t start = my_clock_t::now();
std::function< std::vector< entity > ( entity ) > getneib = [neib]( entity pr){return neib.get_face_neighbor(pr);};
auto ordered_tet = breath_first_search(tet0, getneib );
......@@ -561,7 +493,7 @@ int main(int argc, char *argv[]){
}
if (dobench_tet_edge_edge_tet)
{
neighbors_moab neib(m);
neighbors_moab neib(m.get());
my_time_t start = my_clock_t::now();
std::function< std::vector< entity > ( entity ) > getneib = [neib]( entity pr){return neib.get_edge_neighbor(pr);};
auto ordered_tet = breath_first_search(tet0, getneib );
......@@ -571,7 +503,7 @@ int main(int argc, char *argv[]){
}
if (dobench_tet_vertex_vertex_tet)
{
neighbors_moab neib(m);
neighbors_moab neib(m.get());
my_time_t start = my_clock_t::now();
std::function< std::vector< entity > ( entity ) > getneib = [neib]( entity pr){return neib.get_vertex_neighbor(pr);};
auto ordered_tet = breath_first_search(tet0, getneib );
......@@ -579,7 +511,6 @@ int main(int argc, char *argv[]){
my_duration_t time_visit (end-start);
std::cout << " bfs tet->vertex->tet. nb tet visited : " << ordered_tet.size()<< " in "<< time_visit.count() << " s" << std::endl;
}
delete m;
}//end moab
memo_usage.print();
MPI_Finalize();
......
......@@ -42,12 +42,6 @@
#include "scorec_core_to_gmsh.h"
//moab includes
#include "moab/Core.hpp"
#include "moab_to_gmsh.h"
// timing on laptop for 100*100*100
// 13/10/2019 :
// a 15 s (release, nocheck)
......@@ -209,8 +203,8 @@ void bench_mdb(const structured_mesh &g,
std::function<coord ( const structured_mesh::index & ) > calc,
xMemoryMonitor& memo_usage, const std::string &testname,
bool dobench_edge_vertices, bool dobench_tri_vertices, bool dobench_tet_vertices,
bool dobench_face_tet_tet_face, bool dobench_face_edge_edge_face, bool dobench_face_vertex_vertex_face,
bool dobench_tet_face_face_tet, bool dobench_tet_edge_edge_tet, bool dobench_tet_vertex_vertex_tet,
bool dobench_face_tet_tet_face, bool dobench_face_edge_edge_face, bool dobench_face_vertex_vertex_face,
bool dobench_edge_tet_tet_edge, bool dobench_edge_face_face_edge, bool dobench_edge_vertex_vertex_edge,
bool dobench_vertex_tet_tet_vertex, bool dobench_vertex_face_face_vertex, bool dobench_vertex_edge_edge_vertex,
bool doexport
......@@ -385,34 +379,6 @@ void compute_dim_cog(apf::Mesh2 *m, int dim){
std::cout <<" computing all "<< ent << " cogs in "<< time_cogs.count() << "s "<<std::endl;
}
void compute_dim_cog(const moab::Interface* m, int dim){
assert( ((dim >= 1) && (dim <= 3)) ) ;
my_time_t start = my_clock_t::now();
moab::ErrorCode rval;
int nr;
rval = m->get_number_entities_by_dimension(0, dim, nr, false);
moab::Range entities;
rval = m->get_entities_by_dimension(0, dim, entities, false);
std::vector<coord> cogs( (size_t(nr)) );
for (auto ent : entities){
coord cog(0.,0.,0.);
moab::Range vertices;
m->get_connectivity(&ent, 1, vertices);
size_t npt = size_t(dim+1);
std::vector < double > xi( npt), yi(npt), zi(npt);
m->get_coords(vertices, xi.data(), yi.data(), zi.data());
for (size_t i = 0; i < npt; ++i){
cog[0] += xi[i]/npt;
cog[1] += yi[i]/npt;
cog[2] += zi[i]/npt;
}
cogs.push_back(cog/(1.*(dim+1)));
}
my_time_t end= my_clock_t::now();
my_duration_t time_cogs (end-start);
std::string ent = (dim==1)? "edge" :((dim==2)? "face":"region");
std::cout <<" computing all "<< ent << " cogs in "<< time_cogs.count() << "s "<<std::endl;
}
......@@ -524,46 +490,4 @@ public:
};
class neighbors_moab{
public:
using tet = moab::EntityHandle;
using tri = moab::EntityHandle;
using edge = moab::EntityHandle;
using vertex = moab::EntityHandle;
using mesh = moab::Interface *;
neighbors_moab( mesh _m):m{_m}{}
std::vector< tet > get_face_neighbor( tet pr) const {
moab::Range faces;
moab::Range regions;
m->get_adjacencies(&pr, 1, 2, true, faces);
m->get_adjacencies(faces, 3, true, regions, moab::Interface::UNION);
std::vector< tet > ret;
ret.reserve(4);
for (auto prn : regions ) if (prn!=pr) ret.push_back(prn);
return ret;
}
std::vector< tet > get_edge_neighbor( tet pr) const {
moab::Range edges;
moab::Range regions;
m->get_adjacencies(&pr, 1, 1, true, edges);
m->get_adjacencies(edges, 3, true, regions, moab::Interface::UNION);
std::vector< tet > ret;
ret.reserve(32);
for (auto prn : regions ) if (prn!=pr) ret.push_back(prn);
return ret;
}
std::vector< tet > get_vertex_neighbor( tet pr) const {
moab::Range vertices;
moab::Range regions;
m->get_adjacencies(&pr, 1, 0, true, vertices);
m->get_adjacencies(vertices, 3, true, regions, moab::Interface::UNION);
std::vector< tet > ret;
ret.reserve(32);
for (auto prn : regions ) if (prn!=pr) ret.push_back(prn);
return ret;
}
private :
mesh m;
};
#endif // BENCH_BUILD_LARGE_MESH_H
......@@ -66,13 +66,14 @@ Testing mdb_oriented_one_level
bfs tet->vertex->tet in 45.434400s
Testing mdb_all_level
Mesh build in 13.180600s Memory 4.51009 GB
computing all edge cogs in 0.298848s
computing all face cogs in 0.441007s
computing all region cogs in 0.217542s
bfs face->tet->face in 12.566800s
bfs face->edge->face in 18.168900s
bfs face->vertex->face in 56.658700s
Memory 4.51009 GB
Mesh build in 13.180600s
computing all edge cogs in 0.298848s
computing all face cogs in 0.441007s
computing all region cogs in 0.217542s
bfs tet->face->tet. nb tet visited in 6.7322 s
bfs tet->edge->tet. nb tet visited in 11.4126 s
bfs tet->vertex->tet. nb tet visited in 19.2613 s
Testing mdb top to vertices simplex mesh (noedge, noregion)
Mesh build in 1.595860s Memory 418.543 MB
......
#ifndef BENCH_BUILD_LARGE_MESH_MOAB_H
#define BENCH_BUILD_LARGE_MESH_MOAB_H
#include "moab/Core.hpp"
#include "moab_to_gmsh.h"
#include "bench_build_large_mesh.h"
#include "structured_mesh.h"
std::unique_ptr <moab::Interface > create_moab_simplex_mesh_from_structured_mesh(
const structured_mesh &g,
std::function<coord ( const structured_mesh::index & ) > calc,
xMemoryMonitor &memo_usage, bool doexport){
std::unique_ptr<moab::Interface> m(new moab::Core);
// moab::Interface* m = new (std::nothrow) moab::Core;
//std::unique_ptr<moab::Interface* > m(new (std::nothrow) moab::Core);
if (!m) return nullptr;
using vertex = moab::EntityHandle;
using region = moab::EntityHandle;
std::unordered_map<mdb::structured_mesh::index,
vertex , mdb::structured_mesh::index::hash> index_to_v;
index_to_v.reserve(g.vertices_range().size() );
moab::ErrorCode rval;
int idmemoinit = memo_usage.start("moab_init");
int idmemofull = memo_usage.start("moab_full");
my_time_t start = my_clock_t::now();
for (auto ijk : g.vertices_range()) {
vertex v;
m->create_vertex( calc(ijk).xyz.data(), v);
index_to_v[ijk] = v;
}
for (auto ijk : g.hexs_range())
for (const auto &tet : g.tets(ijk)){
region r;
std::array<vertex, 4 > vertices = {index_to_v[tet[0]] , index_to_v[tet[1]], index_to_v[tet[2]], index_to_v[tet[3]] } ;
m->create_element(moab::EntityType::MBTET, vertices.data(), 4, r );
}
my_time_t end= my_clock_t::now();
my_duration_t time_build_mesh (end-start);
memo_usage.end(idmemoinit);
std::cout <<" Mesh build in "<< time_build_mesh.count() << "s "<<std::endl;
int nvert, nedge, ntri, ntet;
rval = m->get_number_entities_by_type(0, moab::MBVERTEX, nvert, false);
rval = m->get_number_entities_by_type(0, moab::MBEDGE, nedge, false);
rval = m->get_number_entities_by_type(0, moab::MBTRI, ntri, false);
rval = m->get_number_entities_by_type(0, moab::MBTET, ntet, false);
std::cout <<" "<< nvert << " vertices, "<< nedge << " edges, "<< ntri << " faces, " <<ntet << " regions." << std::endl;
my_duration_t time_export;
if(doexport){
std::ofstream outfile("mesh_moab.msh");
my_time_t start = my_clock_t::now();
exportMOABToGMSH( m.get(), outfile );
my_time_t end = my_clock_t::now();
time_export = (end-start);
std::cout <<" Time export to moab : "<<time_export.count() << std::endl;
}
{
moab::Range tets, faces, edges, vertices;
moab::Range tets_faces, faces_tets;
moab::Range faces_edges, edges_faces;
moab::Range edges_vertices, vertices_edges;
// std::cout << "get "
m->get_entities_by_type(0, moab::MBTET, tets);
m->get_adjacencies(tets , 2, true, tets_faces, moab::Interface::UNION);
m->get_entities_by_type(0, moab::MBTRI, faces);
m->get_adjacencies(faces , 3, true, faces_tets, moab::Interface::UNION);
m->get_adjacencies(faces , 1, true, faces_edges, moab::Interface::UNION);
m->get_entities_by_type(0, moab::MBEDGE, edges);
m->get_adjacencies(edges , 0, true, edges_vertices, moab::Interface::UNION);
m->get_entities_by_type(0, moab::MBVERTEX, vertices);
m->get_adjacencies(vertices, 1, true, vertices_edges, moab::Interface::UNION);
}
end= my_clock_t::now();
my_duration_t time_build_edge_face_mesh = (end-start) - time_export;
std::cout <<" Mesh egde and faces build in "<< time_build_edge_face_mesh.count() << "s "<<std::endl;
memo_usage.end(idmemofull);
rval = m->get_number_entities_by_type(0, moab::MBVERTEX, nvert, false);
rval = m->get_number_entities_by_type(0, moab::MBEDGE, nedge, false);
rval = m->get_number_entities_by_type(0, moab::MBTRI, ntri, false);
rval = m->get_number_entities_by_type(0, moab::MBTET, ntet, false);
std::cout <<" "<< nvert << " vertices, "<< nedge << " edges, "<< ntri << " faces, " <<ntet << " regions." << std::endl;
return m;
}
void compute_dim_cog(const moab::Interface* m, int dim){
assert( ((dim >= 1) && (dim <= 3)) ) ;
my_time_t start = my_clock_t::now();
moab::ErrorCode rval;
int nr;
rval = m->get_number_entities_by_dimension(0, dim, nr, false);
moab::Range entities;
rval = m->get_entities_by_dimension(0, dim, entities, false);
std::vector<coord> cogs( (size_t(nr)) );
for (auto ent : entities){
coord cog(0.,0.,0.);
moab::Range vertices;
m->get_connectivity(&ent, 1, vertices);
size_t npt = size_t(dim+1);
std::vector < double > xi( npt), yi(npt), zi(npt);
m->get_coords(vertices, xi.data(), yi.data(), zi.data());
for (size_t i = 0; i < npt; ++i){
cog[0] += xi[i]/npt;
cog[1] += yi[i]/npt;
cog[2] += zi[i]/npt;
}
cogs.push_back(cog/(1.*(dim+1)));
}
my_time_t end= my_clock_t::now();
my_duration_t time_cogs (end-start);
std::string ent = (dim==1)? "edge" :((dim==2)? "face":"region");
std::cout <<" computing all "<< ent << " cogs in "<< time_cogs.count() << "s "<<std::endl;
}
class neighbors_moab{
public:
using tet = moab::EntityHandle;
using tri = moab::EntityHandle;
using edge = moab::EntityHandle;
using vertex = moab::EntityHandle;
using mesh = moab::Interface *;
neighbors_moab( mesh _m):m{_m}{}
std::vector< tet > get_face_neighbor( tet pr) const {
moab::Range faces;
moab::Range regions;
m->get_adjacencies(&pr, 1, 2, true, faces);
m->get_adjacencies(faces, 3, true, regions, moab::Interface::UNION);
std::vector< tet > ret;
ret.reserve(4);
for (auto prn : regions ) if (prn!=pr) ret.push_back(prn);
return ret;
}
std::vector< tet > get_edge_neighbor( tet pr) const {
moab::Range edges;
moab::Range regions;
m->get_adjacencies(&pr, 1, 1, true, edges);
m->get_adjacencies(edges, 3, true, regions, moab::Interface::UNION);
std::vector< tet > ret;
ret.reserve(32);
for (auto prn : regions ) if (prn!=pr) ret.push_back(prn);
return ret;
}
std::vector< tet > get_vertex_neighbor( tet pr) const {
moab::Range vertices;
moab::Range regions;
m->get_adjacencies(&pr, 1, 0, true, vertices);
m->get_adjacencies(vertices, 3, true, regions, moab::Interface::UNION);