Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
LoicMarechal committed Feb 22, 2022
2 parents d797b1c + fa40de6 commit b4a9151
Show file tree
Hide file tree
Showing 25 changed files with 1,116 additions and 84 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
sources/libmeshb7.mod
24 changes: 15 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ set (libMeshb_VERSION_MAJOR 7)
set (libMeshb_VERSION_MINOR 54)
project(libMeshb VERSION ${libMeshb_VERSION_MAJOR}.${libMeshb_VERSION_MINOR} LANGUAGES C)

option(WITH_AIO "Use Unix low-level and asynchronous I/O for higher speed" OFF)
option(WITH_CPACK "Enable cpack target to generate a zip file containing binaries" OFF)
option(WITH_GMF_AIO "Use Unix low-level and asynchronous I/O for higher speed" OFF)
option(WITH_GMF_CPACK "Enable cpack target to generate a zip file containing binaries" OFF)
option(WITH_GMF_FORTRAN "Build the Fortran API" ON )

include (CheckLanguage)
check_language (Fortran)
if(CMAKE_Fortran_COMPILER)
if(CMAKE_Fortran_COMPILER AND WITH_GMF_FORTRAN)
enable_language(Fortran)
set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/modules)
if (CMAKE_Fortran_COMPILER_ID STREQUAL GNU)
Expand All @@ -34,14 +35,18 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
if (WIN32)
set(CMAKE_INSTALL_PREFIX "$ENV{HOMEPATH}/cmakebuilds" CACHE PATH "..." FORCE)
else ()
set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/cmakebuilds/$ENV{OSTYPE}-$ENV{MACHTYPE}" CACHE PATH "..." FORCE)
if (DEFINED ENV{OSTYPE} AND DEFINED ENV{MACHTYPE})
set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/cmakebuilds/$ENV{OSTYPE}-$ENV{MACHTYPE}" CACHE PATH "..." FORCE)
else ()
set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/cmakebuilds" CACHE PATH "..." FORCE)
endif ()
endif()
endif ()

list (APPEND CMAKE_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}")

if(WITH_AIO)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWITH_AIO")
if(WITH_GMF_AIO)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWITH_GMF_AIO")
IF(${CMAKE_SYSTEM_NAME} MATCHES Linux)
set(AIO_LIBRARIES rt)
endif()
Expand All @@ -66,7 +71,7 @@ install (DIRECTORY sample_meshes DESTINATION share/libMeshb)
# SET PACKAGE AND DEPLOYMENT VARIABLES
######################################

if (WITH_CPACK)
if (WITH_GMF_CPACK)
include (InstallRequiredSystemLibraries)
set (CPACK_GENERATOR TXZ)
set (CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/copyright.txt)
Expand Down Expand Up @@ -106,6 +111,7 @@ install(FILES
##################################

message("-- Build mode : " ${CMAKE_BUILD_TYPE})
message("-- cpack target enabled : " ${WITH_CPACK})
message("-- Asynchronous IO : " ${WITH_AIO})
message("-- cpack target enabled : " ${WITH_GMF_CPACK})
message("-- Asynchronous IO : " ${WITH_GMF_AIO})
message("-- Fortran API : " ${WITH_GMF_FORTRAN})
message("-- Install directory : " ${CMAKE_INSTALL_PREFIX})
2 changes: 1 addition & 1 deletion Documentation/libMeshb7.tex
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ \subsubsection{Writing mode}
\normalfont

\paragraph{Asynchronous Input Output:}
to get best performance out of flash storage SSD (more than a GB/s), the library needs to access the filesystem through low-level functions and perform the reading and processing tasks in parallel using asynchronous I/O. To do so, you need to compile the library with the {\tt -DWITH\_AIO} option and link the final executable with the {\tt -lrt} library under Linux.
to get best performance out of flash storage SSD (more than a GB/s), the library needs to access the filesystem through low-level functions and perform the reading and processing tasks in parallel using asynchronous I/O. To do so, you need to compile the library with the {\tt -DWITH\_GMF\_AIO} option and link the final executable with the {\tt -lrt} library under Linux.


\subsection{GmfCloseMesh}
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2001-2018 Loïc Maréchal / INRIA
Copyright (c) 2001-2022 Loïc Maréchal / INRIA

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## libMeshb version 7.60
## libMeshb version 7.62
A library to handle the *.meshb file format.

## Overview
Expand Down
2 changes: 1 addition & 1 deletion copyright.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
All libMeshb code is Copyright 2001-2018 - by Loïc Maréchal / INRIA.
All libMeshb code is Copyright 2001-2022 - by Loïc Maréchal / INRIA.
This program is a free software.
You can redistribute it and/or modify it under the terms of the MIT License
as published by the Open Source Initiative.
Expand Down
2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ install (TARGETS mesh2poly DESTINATION share/libMeshb/examples COMPONENT example
########################


if (CMAKE_Fortran_COMPILER)
if (CMAKE_Fortran_COMPILER AND WITH_GMF_FORTRAN)
add_executable(test_libmeshb_f77 test_libmeshb.f)
target_link_libraries(test_libmeshb_f77 Meshbf.7 ${AIO_LIBRARIES})
install (TARGETS test_libmeshb_f77 DESTINATION share/libMeshb/examples COMPONENT examples)
Expand Down
98 changes: 88 additions & 10 deletions examples/mesh2poly.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,38 @@


/*----------------------------------------------------------------------------*/
/* Includes */
/*----------------------------------------------------------------------------*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libmeshb7.h>


/*----------------------------------------------------------------------------*/
/* Topologic tables */
/*----------------------------------------------------------------------------*/

int tettvpe[6][2] = { {0,1}, {1,2}, {2,0}, {3,0}, {3,1}, {3,2} };
int tettvpf[4][3] = { {1,2,3}, {2,0,3}, {3,0,1}, {0,2,1} };
int pyrtvpe[8][2] = { {0,1}, {3,2}, {0,3}, {1,2}, {0,4}, {1,4}, {2,4}, {3,4} };
int pyrtvpf[5][4] = { {0,1,4,-1}, {1,2,4,-1}, {2,3,4,-1}, {3,0,4,-1}, {3,2,1,0} };
int pritvpe[9][2] = { {0,1}, {1,2}, {2,0}, {3,4}, {4,5}, {5,3}, {0,3}, {1,4}, {2,5} };
int pritvpf[5][4] = { {3,5,2,0}, {1,2,5,4}, {0,1,4,3}, {2,1,0,-1}, {3,4,5,-1} };
int hextvpe[12][2] = { {3,2}, {0,1}, {4,5}, {7,6}, {3,7}, {2,6},
{1,5}, {0,4}, {3,0}, {7,4}, {6,5}, {2,1} };
int hextvpf[6][4] = { {3,0,4,7}, {6,5,1,2}, {3,2,1,0},
{4,5,6,7},{3,7,6,2}, {1,5,4,0} };


/*----------------------------------------------------------------------------*/
/* Transform a surface mesh into polygons and a tet mesh into polyhedra */
/*----------------------------------------------------------------------------*/

int main(int ArgCnt, char **ArgVec)
{
int i, j, ver, dim, ref, nod[8], ArgIdx = 1;
int i, j, k, ver, dim, ref, nod[8], ArgIdx = 1;
int NmbVer, NmbTri, NmbQad, NmbTet, NmbPyr, NmbPri, NmbHex;
int64_t InpMsh, OutMsh;
float xf, yf, zf;
Expand All @@ -14,7 +41,7 @@ int main(int ArgCnt, char **ArgVec)

if(ArgCnt != 3)
{
puts("\nMESH2POLY 1.0, may 12 2021, Loic MARECHAL / INRIA\n");
puts("\nMESH2POLY 1.1, september 15 2021, Loic MARECHAL / INRIA\n");
puts(" Usage : mesh2poly source_name destination_name\n");
exit(0);
}
Expand Down Expand Up @@ -62,6 +89,7 @@ int main(int ArgCnt, char **ArgVec)

printf(" InpMsh: idx = %lld, version: %d, dimension: %d\n", InpMsh, ver, dim);

// Copy all the vertices
if(NmbVer)
{
printf(" Copying %d vertices\n", NmbVer);
Expand All @@ -84,32 +112,25 @@ int main(int ArgCnt, char **ArgVec)
}
}

// Transform triangles and quads into boundary polygons
if(NmbTri || NmbQad)
{
GmfSetKwd(OutMsh, GmfBoundaryPolygonHeaders, NmbTri + NmbQad);

if(NmbTri)
{
printf(" Adding %d triangles to the polygons headers\n", NmbTri);
GmfGotoKwd(InpMsh, GmfTriangles);

for(i=1;i<=NmbTri;i++)
{
GmfGetLin(InpMsh, GmfTriangles, &nod[0], &nod[1], &nod[2], &ref);
GmfSetLin(OutMsh, GmfBoundaryPolygonHeaders, (i-1) * 3 + 1, ref);
}
}

if(NmbQad)
{
printf(" Adding %d quads to the polygons headers\n", NmbQad);
GmfGotoKwd(InpMsh, GmfQuadrilaterals);

for(i=1;i<=NmbQad;i++)
{
GmfGetLin(InpMsh, GmfQuadrilaterals, &nod[0], &nod[1], &nod[2], &nod[3], &ref);
GmfSetLin(OutMsh, GmfBoundaryPolygonHeaders, (i-1) * 4 + NmbTri * 3 + 1, ref);
}
}

GmfSetKwd(OutMsh, GmfBoundaryPolygonVertices, NmbTri * 3 + NmbQad * 4);
Expand Down Expand Up @@ -143,6 +164,63 @@ int main(int ArgCnt, char **ArgVec)
}
}

// Transform tets into inner polygons and polyhedra
if(NmbTet)
{
GmfSetKwd(OutMsh, GmfInnerPolygonHeaders, 4 * NmbTet);

if(NmbTet)
{
printf(" Adding %d tet's faces to the polygons headers\n", 4 * NmbTet);

for(i=0;i<NmbTet;i++)
for(j=0;j<4;j++)
GmfSetLin(OutMsh, GmfInnerPolygonHeaders, i * 12 + j * 3 + 1, ref);
}

GmfSetKwd(OutMsh, GmfInnerPolygonVertices, 12 * NmbTet);

if(NmbTet)
{
printf(" Adding %d tet's faces to the polygons faces\n", NmbTet);
GmfGotoKwd(InpMsh, GmfTetrahedra);

for(i=1;i<=NmbTet;i++)
{
GmfGetLin(InpMsh, GmfTetrahedra, &nod[0], &nod[1], &nod[2], &nod[3], &ref);

for(j=0;j<4;j++)
for(k=0;k<3;k++)
GmfSetLin(OutMsh, GmfInnerPolygonVertices, nod[ tettvpf[j][k] ]);
}
}

GmfSetKwd(OutMsh, GmfPolyhedraHeaders, NmbTet);

if(NmbTet)
{
printf(" Adding %d tets to the polyhedra headers\n", NmbTet);
GmfGotoKwd(InpMsh, GmfTetrahedra);

for(i=0;i<NmbTet;i++)
{
GmfGetLin(InpMsh, GmfTetrahedra, &nod[0], &nod[1], &nod[2], &nod[3], &ref);
GmfSetLin(OutMsh, GmfPolyhedraHeaders, i * 4 + 1, ref);
}
}

GmfSetKwd(OutMsh, GmfPolyhedraFaces, NmbTet * 4);

if(NmbTet)
{
printf(" Adding %d tet's face to the polyhedra faces\n", NmbTet * 4);

for(i=0;i<NmbTet;i++)
for(j=0;j<4;j++)
GmfSetLin(OutMsh, GmfPolyhedraFaces, i * 4 + j + 1);
}
}

GmfCloseMesh(InpMsh);
GmfCloseMesh(OutMsh);

Expand Down
9 changes: 5 additions & 4 deletions examples/test_libmeshb_block_pipeline.f
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

c libmeshb example : transform a quadrilateral mesh into a triangular one
c libmeshb example: transform a quadrilateral mesh into a triangular one
c using fast block transfer and pipelined post processing

include 'libmeshb7.ins'
Expand Down Expand Up @@ -39,14 +39,15 @@

c Read the vertices
res = gmfgetblock(InpMsh, GmfVertices, 1_8, NmbVer,
+ movver, 1, VerTab,
+ 0, %val(0), movver, 1, VerTab,
+ GmfDouble, VerTab(1,1), VerTab(1,2),
+ GmfDouble, VerTab(2,1), VerTab(2,2),
+ GmfDouble, VerTab(3,1), VerTab(3,2),
+ GmfInt, RefTab(1), RefTab(2))

c Read the quads
res = gmfgetblock(InpMsh, GmfQuadrilaterals, 1_8, NmbQad,0,
res = gmfgetblock(InpMsh, GmfQuadrilaterals, 1_8, NmbQad,
+ 0, %val(0), %val(0),
+ GmfInt, QadTab(1,1), QadTab(1,2),
+ GmfInt, QadTab(2,1), QadTab(2,2),
+ GmfInt, QadTab(3,1), QadTab(3,2),
Expand Down Expand Up @@ -79,7 +80,7 @@
c Write the triangles
res = gmfsetkwd(OutMsh, GmfTriangles, 2*NmbQad, 0, 0)
res = gmfsetblock(OutMsh, GmfTriangles, 1_8, 2*NmbQad,
+ 0,%val(0),%val(0),
+ 0,%val(0),
+ qad2tri, 2, QadTab, TriTab,
+ GmfInt, TriTab(1,1), TriTab(1,2),
+ GmfInt, TriTab(2,1), TriTab(2,2),
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 6 additions & 4 deletions sources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
# BUILD THE STATIC LIBRARY
##########################

add_library(Meshb.7 libmeshb7.c)
install (FILES libmeshb7.h DESTINATION include COMPONENT headers)
target_include_directories(Meshb.7 PUBLIC $<INSTALL_INTERFACE:include>)
add_library(Meshb.7 libmeshb7.c ../utilities/libmeshb7_helpers.c)
install (FILES libmeshb7.h ../utilities/libmeshb7_helpers.h DESTINATION include COMPONENT headers)
target_include_directories(
Meshb.7 PUBLIC $<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/sources>)
install (TARGETS Meshb.7 EXPORT meshb-target DESTINATION lib COMPONENT libraries)
install (EXPORT meshb-target NAMESPACE ${PROJECT_NAME}::
DESTINATION lib/cmake/${PROJECT_NAME})
Expand All @@ -18,7 +20,7 @@ export (PACKAGE libMeshb)
# BUILD THE LIBRARY WITH FORTRAN API
####################################

if (CMAKE_Fortran_COMPILER)
if (CMAKE_Fortran_COMPILER AND WITH_GMF_FORTRAN)
file(GLOB_RECURSE SOURCES *.[chfF] *.[fF]90)
add_library(Meshbf.7 STATIC ${SOURCES})
set_target_properties(Meshbf.7 PROPERTIES COMPILE_FLAGS "-DF77API")
Expand Down
Loading

0 comments on commit b4a9151

Please sign in to comment.