From: Christian Van Wambeke Date: Wed, 10 Sep 2014 11:26:04 +0000 (+0200) Subject: Merge from tetra_hpc branch X-Git-Tag: V7_5_0a1~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c76ddc0ae514ae0ab3780dc579817b277971c0b1;p=plugins%2Fghs3dprlplugin.git Merge from tetra_hpc branch --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 60b41a1..90fd825 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,7 @@ SET(${PROJECT_NAME_UC}_MINOR_VERSION 4) SET(${PROJECT_NAME_UC}_PATCH_VERSION 1) SET(${PROJECT_NAME_UC}_VERSION ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION}) -SET(${PROJECT_NAME_UC}_VERSION_DEV 1) +SET(${PROJECT_NAME_UC}_VERSION_DEV 2) # Find KERNEL # =========== diff --git a/bin/CMakeLists.txt b/bin/CMakeLists.txt index 39eccde..4e20bf4 100755 --- a/bin/CMakeLists.txt +++ b/bin/CMakeLists.txt @@ -18,3 +18,15 @@ # SALOME_CONFIGURE_FILE(VERSION.in VERSION INSTALL ${SALOME_INSTALL_BINS}) + +# scripts / static / binaries +# temporary standalone project version of mg-tetra_hpc.exe +SET(_bin_SCRIPTS + mg-tetra_hpc.bash + mg-tetra_hpc.exe_Linux_64_avril2014 + meshgems_mpi.c + meshgems_mpi.h +) + +# --- rules --- +SALOME_INSTALL_SCRIPTS("${_bin_SCRIPTS}" ${SALOME_INSTALL_BINS}) diff --git a/bin/meshgems_mpi.c b/bin/meshgems_mpi.c new file mode 100644 index 0000000..5e6075c --- /dev/null +++ b/bin/meshgems_mpi.c @@ -0,0 +1,427 @@ +/* + * Copyright 2009-2013 Distene SAS + * + */ + +#include +#include + +#include "meshgems_mpi.h" + +#include + +static MPI_Datatype *meshgems_mpi_datatype_map = NULL; +static MPI_Op *meshgems_mpi_op_map = NULL; +static int meshgems_mpi_datatype_count = 0; +static int meshgems_mpi_op_count = 0; + +struct meshgems_mpi_handler_ +{ + MPI_Request rq; +}; + +/* note : MPI standard states that a MPI_Datatype is a simple type (pointer or int) */ + +static inline int meshgems_mpi_find_type(meshgems_mpi_datatype datatype, MPI_Datatype *odt) +{ + if(meshgems_mpi_datatype_map && datatype > 0 && datatype <= meshgems_mpi_datatype_count) { + *odt = meshgems_mpi_datatype_map[datatype]; + return MESHGEMS_MPI_SUCCESS; + } + + return MESHGEMS_MPI_ERR; +} + +int meshgems_mpi_type_new(int count, int *array_of_blocklengths, long *array_of_displacements, + meshgems_mpi_datatype *array_of_types, meshgems_mpi_datatype *newtype) +{ + MPI_Datatype nt, *aot; + MPI_Aint *aod; + int ret, r, i; + void *t; + + ret = MESHGEMS_MPI_SUCCESS; + + aot = (MPI_Datatype *) calloc(count, sizeof(MPI_Datatype)); + aod = (MPI_Aint *) calloc(count, sizeof(MPI_Aint)); + if(!aot || !aod) { + ret = MESHGEMS_MPI_ERR; + goto out; + } + + for(i = 0;i < count;i++) { + /* + r = meshgems_mpi_find_type(array_of_types[i], aot+i); + if(r != MESHGEMS_MPI_SUCCESS){ + ret = r; + goto out; + } + */ + aot[i] = meshgems_mpi_datatype_map[array_of_types[i]]; + aod[i] = (MPI_Aint) array_of_displacements[i]; + } + + r = MPI_Type_create_struct(count, array_of_blocklengths, aod, aot, &nt); + /* With MPI1 you can use : + r = MPI_Type_struct(count, array_of_blocklengths, + aod, aot, &nt); + */ + + if(r != MPI_SUCCESS) { + ret = MESHGEMS_MPI_ERR; + goto out; + } + r = MPI_Type_commit(&nt); + if(r != MPI_SUCCESS) { + ret = MESHGEMS_MPI_ERR; + goto out; + } + + meshgems_mpi_datatype_count++; + t = realloc(meshgems_mpi_datatype_map, (meshgems_mpi_datatype_count + 1) * sizeof(MPI_Datatype)); + if(!t) { + ret = MESHGEMS_MPI_ERR; + goto out; + } + meshgems_mpi_datatype_map = (MPI_Datatype *) t; + meshgems_mpi_datatype_map[meshgems_mpi_datatype_count] = nt; + *newtype = meshgems_mpi_datatype_count; + + out: if(aod) + free(aod); + if(aot) + free(aot); + + return ret; +} + +int meshgems_mpi_type_delete(meshgems_mpi_datatype datatype) +{ + /* no op for now */ + return MESHGEMS_MPI_SUCCESS; +} + +int meshgems_mpi_init(int *argc, char ***argv) +{ + int ret; + + ret = MESHGEMS_MPI_SUCCESS; + + meshgems_mpi_datatype_map = calloc(meshgems_mpi_datatype_enum_count, sizeof(MPI_Datatype)); + meshgems_mpi_op_map = calloc(meshgems_mpi_op_enum_count, sizeof(MPI_Op)); + if(!meshgems_mpi_datatype_map || !meshgems_mpi_op_map) { + ret = MESHGEMS_MPI_ERR; + goto out; + } + meshgems_mpi_datatype_count = meshgems_mpi_datatype_enum_count - 1; + meshgems_mpi_op_count = meshgems_mpi_op_enum_count - 1; + + if(sizeof(int) == 4) { + meshgems_mpi_datatype_map[meshgems_mpi_datatype_i4] = MPI_INT; + } else if(sizeof(int) == 4) { + meshgems_mpi_datatype_map[meshgems_mpi_datatype_i4] = MPI_SHORT; + } else { + fprintf(stderr, "Unable to find mpi type for 4 bytes integer\n"); + ret = MESHGEMS_MPI_ERR; + goto out; + } + + if(sizeof(int) == 8) { + meshgems_mpi_datatype_map[meshgems_mpi_datatype_i8] = MPI_INT; + } else if(sizeof(long) == 8) { + meshgems_mpi_datatype_map[meshgems_mpi_datatype_i8] = MPI_LONG; + } else if(sizeof(long long) == 8) { + meshgems_mpi_datatype_map[meshgems_mpi_datatype_i8] = MPI_LONG_LONG; + } else { + fprintf(stderr, "Unable to find mpi type for 8 bytes integer\n"); + ret = MESHGEMS_MPI_ERR; + goto out; + } + + if(sizeof(float) == 4) { + meshgems_mpi_datatype_map[meshgems_mpi_datatype_r4] = MPI_FLOAT; + } else { + fprintf(stderr, "Unable to find mpi type for 4 bytes real\n"); + ret = MESHGEMS_MPI_ERR; + goto out; + } + + if(sizeof(double) == 8) { + meshgems_mpi_datatype_map[meshgems_mpi_datatype_r8] = MPI_DOUBLE; + } else { + fprintf(stderr, "Unable to find mpi type for 8 bytes real\n"); + ret = MESHGEMS_MPI_ERR; + goto out; + } + + meshgems_mpi_op_map[meshgems_mpi_op_max] = MPI_MAX; + meshgems_mpi_op_map[meshgems_mpi_op_sum] = MPI_SUM; + + MPI_Init(argc, argv); + + out: + + if(ret != MESHGEMS_MPI_SUCCESS) { + if(meshgems_mpi_datatype_map) + free(meshgems_mpi_datatype_map); + if(meshgems_mpi_op_map) + free(meshgems_mpi_op_map); + } + + return ret; +} + +int meshgems_mpi_rank(int *r) +{ + MPI_Comm_rank(MPI_COMM_WORLD, r); + + return MESHGEMS_MPI_SUCCESS; +} + +int meshgems_mpi_size(int *n) +{ + MPI_Comm_size(MPI_COMM_WORLD, n); + + return MESHGEMS_MPI_SUCCESS; +} + +int meshgems_mpi_finalize(void) +{ + MPI_Finalize(); + + return MESHGEMS_MPI_SUCCESS; +} + +meshgems_mpi_handler *meshgems_mpi_handler_new(void) +{ + meshgems_mpi_handler *handler; + + handler = calloc(1, sizeof(meshgems_mpi_handler)); + + return handler; +} + +void meshgems_mpi_handler_delete(meshgems_mpi_handler *handler) +{ + if(handler) + free(handler); +} + +int meshgems_mpi_send(void* buffer, int count, meshgems_mpi_datatype datatype, int dest, int tag) +{ + int ret; + int r; + MPI_Datatype dtt; + + dtt = meshgems_mpi_datatype_map[datatype]; + + r = MPI_Send(buffer, count, dtt, dest, tag, MPI_COMM_WORLD); + + if(r != MPI_SUCCESS) { + ret = MESHGEMS_MPI_ERR; + } else { + ret = MESHGEMS_MPI_SUCCESS; + } + + return ret; +} + +int meshgems_mpi_isend(void* buffer, int count, meshgems_mpi_datatype datatype, int dest, int tag, + meshgems_mpi_handler *handler) +{ + int ret; + int r; + MPI_Datatype dtt; + + dtt = meshgems_mpi_datatype_map[datatype]; + + r = MPI_Isend(buffer, count, dtt, dest, tag, MPI_COMM_WORLD, &(handler->rq)); + + if(r != MPI_SUCCESS) { + ret = MESHGEMS_MPI_ERR; + } else { + ret = MESHGEMS_MPI_SUCCESS; + } + + return ret; +} + +int meshgems_mpi_wait(meshgems_mpi_handler *handler) +{ + int ret; + int r; + + r = MPI_Wait(&(handler->rq), MPI_STATUS_IGNORE ); + + if(r != MPI_SUCCESS) { + ret = MESHGEMS_MPI_ERR; + } else { + ret = MESHGEMS_MPI_SUCCESS; + } + + return ret; +} + +int meshgems_mpi_recv(void* buffer, int count, meshgems_mpi_datatype datatype, int src, int tag) +{ + int ret; + int r; + MPI_Datatype dtt; + + dtt = meshgems_mpi_datatype_map[datatype]; + + if(src == MESHGEMS_MPI_ANY_SOURCE) { + src = MPI_ANY_SOURCE; + } + + r = MPI_Recv(buffer, count, dtt, src, tag, MPI_COMM_WORLD, MPI_STATUS_IGNORE ); + + if(r != MPI_SUCCESS) { + ret = MESHGEMS_MPI_ERR; + } else { + ret = MESHGEMS_MPI_SUCCESS; + } + + return ret; +} + +int meshgems_mpi_reduce(void *sendbuf, void *recvbuf, int count, meshgems_mpi_datatype datatype, + meshgems_mpi_op op, int root) +{ + int ret; + int r; + MPI_Datatype dtt; + MPI_Op mop; + + dtt = meshgems_mpi_datatype_map[datatype]; + mop = meshgems_mpi_op_map[op]; + + r = MPI_Reduce(sendbuf, recvbuf, count, dtt, mop, root, MPI_COMM_WORLD); + + if(r != MPI_SUCCESS) { + ret = MESHGEMS_MPI_ERR; + } else { + ret = MESHGEMS_MPI_SUCCESS; + } + + return ret; +} + +int meshgems_mpi_allreduce(void *sendbuf, void *recvbuf, int count, meshgems_mpi_datatype datatype, + meshgems_mpi_op op) +{ + int ret; + int r; + MPI_Datatype dtt; + MPI_Op mop; + + dtt = meshgems_mpi_datatype_map[datatype]; + mop = meshgems_mpi_op_map[op]; + + r = MPI_Allreduce(sendbuf, recvbuf, count, dtt, mop, MPI_COMM_WORLD); + + if(r != MPI_SUCCESS) { + ret = MESHGEMS_MPI_ERR; + } else { + ret = MESHGEMS_MPI_SUCCESS; + } + + return ret; +} + +int meshgems_mpi_gather(void *sendbuf, int sendcount, meshgems_mpi_datatype sendtype, void *recvbuf, + int recvcount, meshgems_mpi_datatype recvtype, int root) +{ + int ret; + int r; + MPI_Datatype sdtt, rdtt; + + sdtt = meshgems_mpi_datatype_map[sendtype]; + rdtt = meshgems_mpi_datatype_map[recvtype]; + + r = MPI_Gather(sendbuf, sendcount, sdtt, recvbuf, recvcount, rdtt, root, MPI_COMM_WORLD); + + if(r != MPI_SUCCESS) { + ret = MESHGEMS_MPI_ERR; + } else { + ret = MESHGEMS_MPI_SUCCESS; + } + + return ret; +} + +int meshgems_mpi_allgather(void *sendbuf, int sendcount, meshgems_mpi_datatype sendtype, + void *recvbuf, int recvcount, meshgems_mpi_datatype recvtype) +{ + int ret; + int r; + MPI_Datatype sdtt, rdtt; + + ret = MESHGEMS_MPI_SUCCESS; + + sdtt = meshgems_mpi_datatype_map[sendtype]; + rdtt = meshgems_mpi_datatype_map[recvtype]; + + r = MPI_Allgather(sendbuf, sendcount, sdtt, recvbuf, recvcount, rdtt, MPI_COMM_WORLD); + if(r != MPI_SUCCESS) { + ret = MESHGEMS_MPI_ERR; + goto out; + } + + out: + + return ret; +} + +int meshgems_mpi_allgatherv(void *sendbuf, int sendcount, meshgems_mpi_datatype sendtype, + void *recvbuf, int *recvcount, int *displs, meshgems_mpi_datatype recvtype) +{ + int ret; + int r; + MPI_Datatype sdtt, rdtt; + + sdtt = meshgems_mpi_datatype_map[sendtype]; + rdtt = meshgems_mpi_datatype_map[recvtype]; + + r = MPI_Allgatherv(sendbuf, sendcount, sdtt, recvbuf, recvcount, displs, rdtt, MPI_COMM_WORLD); + + if(r != MPI_SUCCESS) { + ret = MESHGEMS_MPI_ERR; + } else { + ret = MESHGEMS_MPI_SUCCESS; + } + + return ret; +} + +int meshgems_mpi_barrier(void) +{ + int ret; + int r; + + r = MPI_Barrier(MPI_COMM_WORLD); + + if(r != MPI_SUCCESS) { + ret = MESHGEMS_MPI_ERR; + } else { + ret = MESHGEMS_MPI_SUCCESS; + } + + return ret; +} + +int meshgems_mpi_abort(int errorcode) +{ + int ret; + int r; + + r = MPI_Abort(MPI_COMM_WORLD, errorcode); + + if(r != MPI_SUCCESS) { + ret = MESHGEMS_MPI_ERR; + } else { + ret = MESHGEMS_MPI_SUCCESS; + } + + return ret; +} diff --git a/bin/meshgems_mpi.h b/bin/meshgems_mpi.h new file mode 100644 index 0000000..30f7cc4 --- /dev/null +++ b/bin/meshgems_mpi.h @@ -0,0 +1,72 @@ +/* + * Copyright 2009-2013 Distene SAS + * + */ + +#ifndef __MESHGEMS_MPI_H__ +#define __MESHGEMS_MPI_H__ + +#define MESHGEMS_MPI_SUCCESS 0 +#define MESHGEMS_MPI_ERR 1 + +#define MESHGEMS_MPI_ANY_SOURCE -1 + +/* Declare these as int rather than enum to be able to create dynamic types/operations */ + +typedef int meshgems_mpi_datatype; +typedef int meshgems_mpi_op; + +#define meshgems_mpi_datatype_none 0 +#define meshgems_mpi_datatype_i4 1 +#define meshgems_mpi_datatype_i8 2 +#define meshgems_mpi_datatype_r4 3 +#define meshgems_mpi_datatype_r8 4 +#define meshgems_mpi_datatype_enum_count 5 + +#define meshgems_mpi_op_none 0 +#define meshgems_mpi_op_max 1 +#define meshgems_mpi_op_sum 2 +#define meshgems_mpi_op_enum_count 3 + +int meshgems_mpi_type_new(int count, int *array_of_blocklengths, long *array_of_displacements, + meshgems_mpi_datatype *array_of_types, meshgems_mpi_datatype *newtype); +int meshgems_mpi_type_delete(meshgems_mpi_datatype datatype); + +struct meshgems_mpi_handler_; +typedef struct meshgems_mpi_handler_ meshgems_mpi_handler; + +meshgems_mpi_handler *meshgems_mpi_handler_new(void); +void meshgems_mpi_handler_delete(meshgems_mpi_handler *handler); + +int meshgems_mpi_init(int *argc, char ***argv); +int meshgems_mpi_rank(int *r); +int meshgems_mpi_size(int *n); +int meshgems_mpi_finalize(void); + +int meshgems_mpi_send(void* buffer, int count, meshgems_mpi_datatype datatype, int dest, int tag); +int meshgems_mpi_isend(void* buffer, int count, meshgems_mpi_datatype datatype, int dest, int tag, + meshgems_mpi_handler *handler); +int meshgems_mpi_wait(meshgems_mpi_handler *handler); + +int meshgems_mpi_recv(void* buffer, int count, meshgems_mpi_datatype, int src, int tag); + +int meshgems_mpi_reduce(void *sendbuf, void *recvbuf, int count, meshgems_mpi_datatype datatype, + meshgems_mpi_op op, int root); + +int meshgems_mpi_allreduce(void *sendbuf, void *recvbuf, int count, meshgems_mpi_datatype datatype, + meshgems_mpi_op op); + +int meshgems_mpi_gather(void *sendbuf, int sendcount, meshgems_mpi_datatype sendtype, void *recvbuf, + int recvcount, meshgems_mpi_datatype recvtype, int root); + +int meshgems_mpi_allgather(void *sendbuf, int sendcount, meshgems_mpi_datatype sendtype, + void *recvbuf, int recvcount, meshgems_mpi_datatype recvtype); + +int meshgems_mpi_allgatherv(void *sendbuf, int sendcount, meshgems_mpi_datatype sendtype, + void *recvbuf, int *recvcount, int *displs, meshgems_mpi_datatype recvtype); + +int meshgems_mpi_barrier(void); + +int meshgems_mpi_abort(int errorcode); + +#endif diff --git a/bin/mg-tetra_hpc.bash b/bin/mg-tetra_hpc.bash new file mode 100755 index 0000000..4a2cd6c --- /dev/null +++ b/bin/mg-tetra_hpc.bash @@ -0,0 +1,58 @@ +#!/bin/bash + +#bash script mg-tetra_hpc.bash +#we have renamed binary executable mg-tetra_hpc.exe V1.3.0 as mg-tetra_hpc.exe_Linux_64_avril2014 +#to assume call of other beta-versions of distene mg-tetra_hpc.exe code in standalone plugin GHS3DPRLPLUGIN sources +#and also assume licence file set to overriding licence file of other distene products ( HEXOTIC, GHS3D, etc... ) +#this script is used for only one call of mg-tetra_hpc.bash from salome plugin GHS3DPRLPLUGIN + +#echo "mg-tetra_hpc.bash initial parameters are:" $1 $2 $3 $4 +echo "mg-tetra_hpc.bash initial parameters are:" $* +#$0 is ignored + +CURRENTDIR=`pwd` +COMPILDIR=`dirname $0` +echo "COMPILDIR" $COMPILDIR +echo "CURRENTDIR" $CURRENTDIR +if [[ $HOSTNAME == *hpcspot* ]] + then + HOST="hpcspot" + else + HOST="STANDART_CentOs6" #CentOs6 default +fi +echo "HOST" $HOST + +#we need to compile for mg-tetra_hpc.exe +#DISTENE_LICENSE_FILE is for example, have to be set +if [ $HOST == "hpcspot" ] + then + #env openmpi centos6.5 hpcspot.com + source /apps/mpi/openmpi-1.6-x86_64-gcc48/env.sh + #export DISTENE_LICENSE_FILE="Use global envvar: DLIM8VAR" + #export DLIM8VAR="dlim8 1:1:29030@10.27.51.1/002590c96d98::8fbdc02cde090ca0369ad028e839065b97709e3c33e640eb6a3c2c7e40fe3985" + else + #env openmpi centos6.5 standart lgls is206786 + export WD2=/usr/lib64/openmpi + export PATH=$WD2/bin:${PATH} + export LD_LIBRARY_PATH=$COMPILDIR:$WD2/lib:${LD_LIBRARY_PATH} + #export DISTENE_LICENSE_FILE="Use global envvar: DLIM8VAR" + #export DLIM8VAR="dlim8 1:1:29030@132.166.151.49/84c419b8::87af196ab2a936ab31363624539bff8096fbe1f3c83028c8f6b399b0a904ef85" +fi + +cd $COMPILDIR +if [ ! -f libmeshgems_mpi.so ] +then + echo "libmeshgems_mpi.sols does not exist, I compile it..." + mpicc meshgems_mpi.c -shared -fPIC -o libmeshgems_mpi.so + ls -alt lib* +fi +cd $CURRENTDIR + +echo "mg-tetra_hpc.bash assume licence file set:" +env | grep DLIM + +#mg-tetra_hpc.exe_Linux_64_avril2014 --help +#ldd `which mg-tetra_hpc.exe_Linux_64_avril2014` +mpirun -n $2 mg-tetra_hpc.exe_Linux_64_avril2014 ${@:3:30} + + diff --git a/bin/mg-tetra_hpc.exe_Linux_64_avril2014 b/bin/mg-tetra_hpc.exe_Linux_64_avril2014 new file mode 100755 index 0000000..0205a41 Binary files /dev/null and b/bin/mg-tetra_hpc.exe_Linux_64_avril2014 differ diff --git a/doc/file.mesh.pdf b/doc/file.mesh.pdf new file mode 100644 index 0000000..c0f071e Binary files /dev/null and b/doc/file.mesh.pdf differ diff --git a/doc/salome/gui/GHS3DPRLPLUGIN/images/ghs3dprl_parameters_basic.png b/doc/salome/gui/GHS3DPRLPLUGIN/images/ghs3dprl_parameters_basic.png index 0628058..cdf1c3d 100644 Binary files a/doc/salome/gui/GHS3DPRLPLUGIN/images/ghs3dprl_parameters_basic.png and b/doc/salome/gui/GHS3DPRLPLUGIN/images/ghs3dprl_parameters_basic.png differ diff --git a/doc/salome/gui/GHS3DPRLPLUGIN/input/ghs3dprl_hypo.doc b/doc/salome/gui/GHS3DPRLPLUGIN/input/ghs3dprl_hypo.doc index 4f4dbc1..7b09aea 100644 --- a/doc/salome/gui/GHS3DPRLPLUGIN/input/ghs3dprl_hypo.doc +++ b/doc/salome/gui/GHS3DPRLPLUGIN/input/ghs3dprl_hypo.doc @@ -1,19 +1,18 @@ /*! -\page ghs3dprl_hypo_page MG-Tetra Parallel Parameters hypothesis - -\n MG-Tetra Parallel Parameters hypothesis works only with MG-Tetra Parallel algorithm. -This algorithm is a commercial software, its use requires a licence (http://www.distene.com/fr/build/offer.html). -\n Tepal_V1.4 gives the possibility to generate a partitioned -mesh with 200 million tetrahedrons on a computer with average memory size -(2Go RAM) in about 50 hours on one CPU (Xeon, 2008). -\n New Tepal_V2.0 gives the possibility to generate a partitioned mesh with (for the moment) no more than 100 million -tetrahedrons on computers using MPI, (Total 16 Go RAM) -in about 900 seconds (!yes! : !seconds!) on 2 octo processors (Xeon, 2009). -The launch of this beta-version is described below. +\page ghs3dprl_hypo_page MG-Tetra-hpc (Parallel) Parameters hypothesis + +\n MG-Tetra-hpc Parameters hypothesis works only with MG-Tetra-hpc code (formerly tepal) +which is the parallel implementation of MeshGems-Tetra (formerly TetMesh-GHS3D) algorithm. +This algorithm is a DISTENE commercial software, its use requires a licence. +\n +See http://www.distene.com and http://www.meshgems.com/volume-meshing-meshgems-tetra.html. +\n MG-Tetra-hpc (Tepal V3 in fact) gives the possibility to generate a partitioned +mesh with more than 200 million tetrahedrons on computers using MPI. +The launch of this version is described below. \n This is a serious alternative to MG-Tetra, which requires a much less common configuration with 64Go RAM to only try to make a partition of a mesh with -200 million tetrahedrons, no result guaranteed. +200 million tetrahedrons, no result guaranteed (in 2010). \n \note The Plugin doesn't load in the Memory the supposedly large resulting meshes. The meshes are saved in MED files and can be imported in the user-defined location via menu File-Import-MED Files. @@ -27,286 +26,192 @@ file with 5 million tetrahedrons. Name - allows to define the name of the hypothesis (MG-Tetra Parallel Parameters by default).
  • -MED_Name - allows to define the path and the prefix of the +MED Name - allows to define the path and the prefix of the resulting MED files ("DOMAIN" by default). If the path is not defined, the environment variable $SALOME_TMP_DIR is used. If $SALOME_TMP_DIR is not defined as well, the environment variable $TMP is used.
  • -Nb_Part - allows to define the number of generated MED files. +Nb Partitions - allows to define the number of generated MED files. The initial skin (triangles) will be meshed (tetrahedrons) and partitioned in Nb_Part by the elementary algorithm implemented in Tepal.
  • -Keep_Files - if this box is checked, input files of Tepal +Keep Files - if this box is checked, input files of Tepal (GHS3DPRL.points and GHS3DPRL.faces) are not deleted after use (...if the background mode was not used).
  • -Tepal_in_Background - if this box is checked, Tepal execution +Tetra_hpc in Background - if this box is checked, Tetra_hpc execution and MED file generation are launched in background mode and the user can even exit Salome. Pay attention that in this case Tepal algorithm works independently of "killSalome.py", and sometimes on another host.
  • -To_Mesh_Holes - if this box is checked, the parameter component -of MG-Tetra will mesh holes. +Merge subdomains - if this box is checked, merge the subdomains +into one mesh and write the output .mesh(b). +
  • +
  • +Tag subdomains - if this box is checked, use the parallel subdomain +index as tag into the merged output mesh or not (used in combination with the +merge_subdomains option). +
  • +
  • +Output interfaces - if this box is checked, write the parallel subdomains interface +triangles into the merged output mesh (used in combination with the merge_subdomains option). +
  • +
  • +Discard subdomains - if this box is checked, discard the parallel subdomains +(mesh, global numbering and interfaces).
  • -

    Modifying MG-Tetra Parallel Advanced Parameters


    -GHS3DPRL Plugin launches a standalone binary executable tepal2med.
    -tepal2med launches tepal, waits for the end of computation, and +

    Modifying MG-Tetra-hpc Advanced Parameters


    +GHS3DPRL Plugin launches a standalone binary executable tetrahpc2med.
    +tetrahpc2med launches tetra_hpc, waits for the end of computation, and converts the resulting output tepal files into MED files.
    Some advanced optional parameters are accessible as arguments.
    -If keep_files option is checked, it is possible to re-launch tepal2med -or tepal in the Terminal as a command with custom parameters.
    +If keep_files option is checked, it is possible to re-launch tetrahpc2med +or tetra_hpc in the Terminal as a command with custom parameters.
  • -Advanced tepal2med Parameters - type "tepal2med --help" in the Terminal.

    +Advanced tetrahpc2med Parameters - type tetrahpc2med --help in the Terminal.

    \verbatim -myname@myhost > /export/home/myname/salome_5/GHS3DPRLPLUGIN_5/bin/salome/tepal2med --help -Available options: - --help : produces this help message - --casename : path and name of input tepal2med files which are - - output files of tepal .msg .noboite .faces .points .glo - - output file of GHS3DPRL_Plugin casename_skin.med (optional) - with initial skin and its initial groups - --number : number of partitions - --medname : path and name of output MED files - --limitswap : max size of working cpu memory (Mo) (before swapping on .temp files) - --verbose : trace of execution (0->6) - --test : more tests about joints, before generation of output files - --menu : a GUI menu for option number - --launchtepal : also launch tepal on files casename.faces and casename.points and option number - --meshholes : force parameter component of tetmesh-ghs3d to mesh holes - --background : force background mode from launch tepal and generation of final MED files (big meshes) - --deletegroups : regular expression (see QRegExp) which matches unwanted groups in final MED files - (try --deletegroups="(\bAll_Nodes|\bAll_Faces)" - (try --deletegroups="((\bAll_|\bNew_)(N|F|T))" +myname@myhost > /export/home/myname/salome_7/GHS3DPRLPLUGIN/bin/salome/tetrahpc2med --help +tetrahpc2med V3.0 (MED3+tetra-hpc) Available options: + --help : produces this help message + --casename : path and name of input tetrahpc2med files which are + - output files of GHS3DPRL_Plugin .mesh + - output file of GHS3DPRL_Plugin casename_skin.med (optional) + with initial skin and its initial groups + --number : number of partitions + --medname : path and name of output MED files + --limitswap : max size of working cpu memory (Mo) (before swapping on .temp files) + --verbose : trace of execution (0->6) + --test : more tests about joints, before generation of output files + --menu : a GUI menu for option number + --launchtetra : also launch tetra-hpc on files casename.mesh and option number + --merge_subdomains : merge the subdomains into one mesh and write the output .mesh(b) file + --tag_subdomains : use the parallel subdomain index as tag into the merged output mesh + to identify the parallel subdomains (used in combination with the merge_subdomains option) + --output_interfaces : write the parallel subdomains interface triangles into the merged output mesh + (used in combination with the merge_subdomains option) + --discard_subdomains : discard the parallel subdomains informations output (mesh, global numbering and interfaces) + --background : force background mode from launch tetra-hpc and generation of final MED files (big meshes) + --deletegroups : regular expression (see QRegExp) which matches unwanted groups in final MED files + (try --deletegroups="(\bJOINT)" + (try --deletegroups="(\bAll_Nodes|\bAll_Faces)" + (try --deletegroups="((\bAll_|\bNew_)(N|F|T))" example: - tepal2med --casename=/tmp/GHS3DPRL --number=2 --medname=DOMAIN --limitswap=1000 - --verbose=0 --test=yes --menu=no --launchtepal=no + tetrahpc2med --casename=/tmp/GHS3DPRL --number=2 --medname=DOMAIN --limitswap=1000 --verbose=0 --test=yes --menu=no --launchtetra=no \endverbatim \n

  • -Advanced Tepal_V1.4 Parameters

    +Advanced tetra_hpc parameters (2014)

    \verbatim -USAGE : tepal options - -With options : - --filename name (-f name) : - Prefix of the input case (MANDATORY) - - --ndom n (-n n) : - Number of subdomains to make (MANDATORY) - - --ghs3d ghs3d options (-g ghs3d options) : - Runs temesh ghs3d on a previously generated subdomain. (ghs3d options must be "quoted") - - --memory m (-m m) : - Max amount of memory (megabytes) allowed for ghs in the cutting process. (default is 0 : unlimited) - - --mesh_only (-Z ) : - Only (re)meshes all subdomains and updates communications messages - - --mesh_call command (-c command) : - Calls the user specified command for meshing all the - subomains after their skin has been generated - - --stats_only (-S ) : - Only computes and shows some statistics on subdomains - - --rebuild (-r ) : - Merges final subdomains skins - - --rebuild_tetra (-R ) : - Merges final subdomains skins and tetraedra - - --rebuild_iface (-i ) : - Includes interfaces in final subdomains merge - - --rebuild_retag (-t ) : - Tags vertices, faces (and tetra if selected) with their - subdomain number in the final merge of subdomains (keeps the lowest tag for shared elements) - - --rebuild_ensight_parts (-e ) : - Builds ensight geom file with parts - - --tetmesh_args str (-G str) : - Arguments to pass to Tetmesh during cutting process +Usage: tetra_hpc.exe [options] + +Options: + + Short option (if it exists) + / Long option + | / Description + | | / + v v v + + --help + print this help + + --in + Sets the input file + (MANDATORY) + + --out + Sets the output file + (MANDATORY) + + --merge_subdomains + Describes whether to merge the subdomains into one mesh and write the + output .mesh(b) file or not. + if is + yes : the subdomains will be merged into one mesh and written to + the output .mesh(b), + no : the subdomains will not be merged. + default : no + + --tag_subdomains + Describes whether to use the parallel subdomain index as tag into the + merged output mesh or not (used in combination with the + merge_subdomains option). + if is + yes : the tags of the tetrahedra in the merged output will + identify the parallel subdomains, + no : the tag will keep its standard meaning of volume domain. + default : no + + --output_interfaces + Describes whether to write the parallel subdomains interface + triangles into the merged output mesh or not (used in combination + with the merge_subdomains option). + if is + yes : the parallel subdomains interface triangles will be written + into the merged output mesh, + no : they will not be added to the merged output mesh. + default : no + + --verbose + Set the verbosity level, increasing from 0 to 10. + values are increasing from 0 to 10 : + 0 : no details + 10 : very detailed + default : 3 + + --discard_subdomains + Describes whether to discard the parallel subdomains (mesh, global + numbering and interfaces) or not. + if is + yes : the subdomain informations (mesh, global numbering and + interfaces) will be discarded, + no : they will be written to disk as output. + default : no \endverbatim \n

  • -
  • -Advanced MG-Tertra Parameters (through Tepal_V1.4's --tetmesh_args) - type "ghs3d -h" in a Terminal.

    -\verbatim -myname@myhost > ghs3d -h - -USE - /export/home/myname/ghs3d-4.0/DISTENE/Tools/TetMesh-GHS3D4.0/bin/Linux/ghs3dV4.0 - [-u] [-m memory>] [-M MEMORY] [-f prefix] [-v verbose] - [-c component] [-p0] [-C] [-E count] [-t] [-o level] - [-I filetype] [-a/-b] [-O n m] - -DESCRIPTION - - -u (-h) : prints this message. - - -m memory : launches the software with memory in Megabytes. - The default value of this parameter is 64 Megabytes and its - minimum value is 10 Megabytes. - It is also possible to set this parameter with the - environment variable GHS3D_MEMORY by means of an operation - equivalent to: - setenv GHS3D_MEMORY memory, - the value specified in the command line has the priority on - the environment variable. - - -M MEMORY : provides the automatic memory adjustment feature. - If MEMORY (in Megabytes) is equal to zero, the size of the work space is - calculated from the input. If MEMORY is not equal to - zero, the software starts with MEMORY amount of work space. - The software reallocates memory as necessary. - The start value of MEMORY can range from 0 to 64 Megabytes, - the maximum depends on -m option and the actual memory available. - - -f prefix : defines the generic prefix of the files. - - -v verbose : sets the output level parameter (the verbose parameter - must be in the range 0 to 10). - - -c component : chooses the meshed component. If the parameter is - 0, all components will be meshed, if - 1, only the main (outermost) component will be meshed - - -p0 : disables creation of internal points. - - -C : uses an alternative boundary recovery mechanism. It should be used only - when the standard boundary recovery fails. - - -E count : sets the extended output for error messages. If -E is used, - the error messages will be printed, it is possible - to indicate the maximum number of printed messages between 1 and 100. - - -t : generates an error file prefix.Log - - -o level : sets the required optimisation level. - Valid optimisation levels are: - none, light, standard or strong, - with increase of "quality vs speed" ratio. - - -I filetype : defines the input mesh format as follows: - -IP input files are ascii files, named prefix.points - and prefix.faces - this is the default type of files - -IPb input files are binary files, named prefix.pointsb - and prefix.facesb - -IM input file is ascii file, named prefix.mesh - where prefix is defined with -f option - - -a/-b : selects the output file type: - -a for ascii (the default) and - -b for binary. - - -On : saves a NOPO file in addition. NOPO is the mesh data - structure of the Simail and Modulef software packages. - -Om : saves a mesh file in addition. - -Omn : saves both NOPO and mesh files. - - ============================================================================== - TETMESH-GHS3D SOFTWARE 4.0-3 (December, 2006) - END OF SESSION - COPYRIGHT (C)1989-2006 INRIA ALL RIGHTS RESERVED - ============================================================================== - ( Distene SAS - Phone: +33(0)1-69-26-62-10 Fax: +33(0)1-69-26-90-33 - EMail: support@distene.com ) - -\endverbatim -\n -

  • -

    Saving user's preferred MG-Tetra Parallel Advanced Parameters


    -GHS3DPRL Plugin launches standalone binary executable tepal2med.
    -You may rename file tepal2med as tepal2med.exe for example, and replace -tepal2med by a shell script at your convenience to overriding parameters. -
    ... or else $PATH modification... .
    Idem for file tepal.

    +

    Saving user's preferred GHS3DPRL Advanced Parameters


    +GHS3DPRL Plugin launches standalone binary executable tetrahpc2med.
    +You may rename file tetrahpc2med as tetrahpc2med.exe for example, and replace +tetrahpc2med by a shell script at your convenience to overriding parameters. +
    ... or else $PATH modification... .
  • -Advanced tepal2med Parameters - overriding parameter deletegroups

    -You may rename tepal2med as tepal2med.exe for example. +Advanced tetrahpc2med Parameters - overriding parameter deletegroups

    +You may rename tetrahpc2med as tetrahpc2med.exe for example. \code #!/bin/bash -#script tepal2med overriding parameter deletegroups -#we have renamed binary executable tepal2med as tepal2med.exe -#echo tepal2med initial parameters are $1 $2 $3 $4 ... or $* +#script tetrahpc2med overriding parameter deletegroups +#we have renamed binary executable tetrahpc2med as tetrahpc2med.exe +#echo tetrahpc2med initial parameters are $1 $2 $3 $4 ... or $* #$0 is ignored -tepal2med.exe $* --deletegroups="(\bAll_Nodes|\bAll_Faces)" - -\endcode -\n -

  • -
  • -Advanced Tepal_V1.4 Parameters - overriding parameter component of ghs3d (to mesh holes).

    -You may rename tepal as tepal.exe for example. - -\code -#!/bin/bash -#script tepal overriding parameter component of tetmesh-ghs3d -#we have renamed binary executable tepal as tepal.exe - -#optionnaly we could set licence only for us -DISTENE_LICENSE_FILE="Use global envvar: DLIM8VAR" -DLIM8VAR="dlim8 1:1:29030@is142356/0016175ef08c::a1ba1...etc...e19" -SIMULOGD_LICENSE_FILE=29029@is142356 - -tepal.exe $* --tetmesh_args "-c 0" +tetrahpc2med.exe $* --deletegroups="(\bAll_Nodes|\bAll_Faces)" \endcode \n

  • -
  • -Advanced tepal Parameters - overriding launching tepal on other host.

    -You may rename tepal as tepal.exe for example. - -\code -#!/bin/bash -#script tepal overriding launching tepal on other host (tepal run 64 bits only) -#we have renamed binary executable tepal as tepal.exe -#common file system (same path) otherwise scp... on input or result files -#ssh -keygen -t rsa done and files id_rsa et id-rsa.pub move in ~/.ssh - -#example of typical command -#tepal -f /home/myname/tmp/GHS3DPRL -n 4 > /home/myname/tmp/tepal.log -#echo parameters $1 $2 $3 $4 ... or $* - -#tepal licence ought to be known on otherhost -ssh otherhost "tepal.exe $* > /home/myname/tmp/tepal.log" - -#or more and more -#ssh otherhost "tepal.exe $* --tetmesh_args \"-c 0\"" > /home/myname/tmp/tepal.log - -\endcode -\n -

  • - -

    Tepal_V2.0 and MPI use.


    -This all new beta-version needs MPI, (openmpi-1.3.1 was used). To use it you have to proceed -as done in "overriding parameter component of ghs3d". -Advanced ghs3d Parameters (through Tepal_V1.4's --tetmesh_args) are not assumed yet. -It meshes holes. -\n You may rename tepal as tepal64_v2.exe for example, and replace tepal by a shell script like below. + +

    tetra_hpc and MPI use.


    +This 2014 beta-version needs MPI, (openmpi was used). To use it you have to proceed as below.
  • -example tepal_v2_mpirun.

    +Obsolete example tepal_v2_mpirun.

    \code @@ -444,8 +349,8 @@ algo2d.SetPhySize(5) algo2d.SetGeometricMesh(0) -# 3D mesh with tepal -# ------------------ +# 3D mesh with tetra-hpc (formerly tepal v3 (2014)) +# ---------------------------------------------------- algo3d = m.Tetrahedron(smeshBuilder.MG_Tetra_Parallel) @@ -453,7 +358,10 @@ algo3d.SetMEDName(results) algo3d.SetNbPart(4) algo3d.SetBackground(False) algo3d.SetKeepFiles(False) -algo3d.SetToMeshHoles(True) +algo3d.SetToMergeSubdomains(False) +algo3d.SetToTagSubdomains(False) +algo3d.SetToOutputInterfaces(False) +algo3d.SetToDiscardSubdomains(False) # Launch meshers # -------------- @@ -464,9 +372,9 @@ status = m.Compute() # ---------- if os.access(results+".xml", os.F_OK): - print "Ok: tepal" + print "Ok: tetra_hpc" else: - print "KO: tepal" + print "KO: tetra_hpc" \endcode \n

  • diff --git a/doc/salome/gui/GHS3DPRLPLUGIN/input/index.doc b/doc/salome/gui/GHS3DPRLPLUGIN/input/index.doc index 9746c52..8ae4faf 100644 --- a/doc/salome/gui/GHS3DPRLPLUGIN/input/index.doc +++ b/doc/salome/gui/GHS3DPRLPLUGIN/input/index.doc @@ -6,7 +6,7 @@ - Meshing 3D geometric entities: volumes are split into tetrahedral (pyramidal) elements. - Generating 3D meshes from 2D meshes, working without geometrical objects. -\note GHS3DPRLPLUGIN plugin uses MG-Tetra (former GHS3D) commercial mesher and require a +\note GHS3DPRLPLUGIN plugin uses MG-Tetra-hpc (formerly Tepal) commercial mesher and require a license to be used within the Mesh module. To manage parameters of the GHS3DPRLPLUGIN use \subpage ghs3dprl_hypo_page. diff --git a/idl/GHS3DPRLPlugin_Algorithm.idl b/idl/GHS3DPRLPlugin_Algorithm.idl index 506183d..589b8c5 100755 --- a/idl/GHS3DPRLPlugin_Algorithm.idl +++ b/idl/GHS3DPRLPlugin_Algorithm.idl @@ -56,8 +56,20 @@ module GHS3DPRLPlugin void SetBackground(in boolean value); boolean GetBackground(); - void SetToMeshHoles(in boolean value); - boolean GetToMeshHoles(); + //void SetToMeshHoles(in boolean value); + //boolean GetToMeshHoles(); + + void SetToMergeSubdomains(in boolean value); + boolean GetToMergeSubdomains(); + + void SetToTagSubdomains(in boolean value); + boolean GetToTagSubdomains(); + + void SetToOutputInterfaces(in boolean value); + boolean GetToOutputInterfaces(); + + void SetToDiscardSubdomains(in boolean value); + boolean GetToDiscardSubdomains(); }; }; diff --git a/src/GHS3DPRLPlugin/GHS3DPRLPluginBuilder.py b/src/GHS3DPRLPlugin/GHS3DPRLPluginBuilder.py index 19eefd2..cec63fd 100644 --- a/src/GHS3DPRLPlugin/GHS3DPRLPluginBuilder.py +++ b/src/GHS3DPRLPlugin/GHS3DPRLPluginBuilder.py @@ -111,8 +111,32 @@ class GHS3DPRL_Algorithm(Mesh_Algorithm): ## To mesh "holes" in a solid or not. Default is to mesh. # @param toMesh "mesh holes" flag value - def SetToMeshHoles(self, toMesh): - self.Parameters().SetToMeshHoles(toMesh) + #def SetToMeshHoles(self, toMesh): + # self.Parameters().SetToMeshHoles(toMesh) + # pass + + ## To Merge Subdomains. Default is to no. + # @param toMesh "MergeSubdomains" flag value + def SetToMergeSubdomains(self, toMesh): + self.Parameters().SetToMergeSubdomains(toMesh) + pass + + ## To Tag Subdomains. Default is to no. + # @param toMesh "TagSubdomains" flag value + def SetToTagSubdomains(self, toMesh): + self.Parameters().SetToTagSubdomains(toMesh) + pass + + ## To Output Interfaces. Default is to no. + # @param toMesh "OutputInterfaces" flag value + def SetToOutputInterfaces(self, toMesh): + self.Parameters().SetToOutputInterfaces(toMesh) + pass + + ## To Discard Subdomains. Default is to no. + # @param toMesh "DiscardSubdomains" flag value + def SetToDiscardSubdomains(self, toMesh): + self.Parameters().SetToDiscardSubdomains(toMesh) pass pass # end of GHS3DPRL_Algorithm class diff --git a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_GHS3DPRL.cxx b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_GHS3DPRL.cxx index c6607e8..7b468ce 100755 --- a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_GHS3DPRL.cxx +++ b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_GHS3DPRL.cxx @@ -407,7 +407,10 @@ void GHS3DPRLPlugin_GHS3DPRL::SetParameters(const GHS3DPRLPlugin_Hypothesis* hyp _NbPart = hyp->GetNbPart(); _KeepFiles = hyp->GetKeepFiles(); _Background = hyp->GetBackground(); - _ToMeshHoles = hyp->GetToMeshHoles(); + _ToMergeSubdomains = hyp->GetToMergeSubdomains(); + _ToTagSubdomains = hyp->GetToTagSubdomains(); + _ToOutputInterfaces = hyp->GetToOutputInterfaces(); + _ToDiscardSubdomains = hyp->GetToDiscardSubdomains(); } } @@ -440,9 +443,171 @@ static TCollection_AsciiString getTmpDir() } //============================================================================= -// Here we are going to use the GHS3DPRL mesher +// Here we are going to use the GHS3DPRL mesher for tetra-hpc (formerly tepal in v3 (2014)) bool GHS3DPRLPlugin_GHS3DPRL::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape& theShape) +{ + bool Ok=false; + TCollection_AsciiString pluginerror("ghs3dprl: "); + SMESHDS_Mesh* meshDS = theMesh.GetMeshDS(); + //cout<<"GetMeshDS done\n"; + if (_countSubMesh==0){ + MESSAGE("GHS3DPRLPlugin_GHS3DPRL::Compute for tetra-hpc"); + _countTotal=0; + TopExp_Explorer expf(meshDS->ShapeToMesh(), TopAbs_SOLID); + for ( ; expf.More(); expf.Next() ) _countTotal++; + } + _countSubMesh++; + //cout<<"Compute _countSubMesh "<<_countSubMesh<0) { + path=casenamemed.SubString(1,n); + casenamemed=casenamemed.SubString(n+1,casenamemed.Length()); + } + else + path=tmpDir; + + if (casenamemed.Length()>20){ + casenamemed=casenamemed.SubString(1,20); + cerr<<"MEDName truncated (no more 20 characters) = "< avoid warning message + //med_idt fid=MEDouvrir((const char *)fileskinmed.ToCString(),MED_CREATION); + //med_err ret=MEDfermer(fid); + //fileskinmed=fileskinmed + "cp /home/wambeke/empty.med "+ path + "GHS3DPRL_skin.med"; + //system( fileskinmed.ToCString() ); + fileskinmed=path + "GHS3DPRL_skin.med"; + cout<<"Write file "< 0) { - //Processus père + //Processus pere cout<<"le pere est la\n"; system("echo le pere > lepere.tmp"); system("sleep 10"); @@ -601,7 +768,7 @@ bool GHS3DPRLPlugin_GHS3DPRL::Compute(SMESH_Mesh& theMesh, } else if (pid == 0) { //Processus fils cout<<"le fils est la\n"; - //On rend le fils indépendant de tout terminal + //On rend le fils independant de tout terminal setsid(); system("sleep 20"); system("echo le fils > lefils.tmp"); diff --git a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_GHS3DPRL.hxx b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_GHS3DPRL.hxx index a975b3a..175d4cc 100755 --- a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_GHS3DPRL.hxx +++ b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_GHS3DPRL.hxx @@ -47,10 +47,12 @@ public: void SetParameters(const GHS3DPRLPlugin_Hypothesis* hyp); virtual bool Compute(SMESH_Mesh& aMesh, - const TopoDS_Shape& aShape); + const TopoDS_Shape& aShape); + virtual bool ComputeForTepal(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape); //obsolescent - virtual bool Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape, - MapShapeNbElems& aResMap); + virtual bool Evaluate(SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape, + MapShapeNbElems& aResMap); ostream & SaveTo(ostream & save); istream & LoadFrom(istream & load); @@ -68,7 +70,11 @@ private: int _NbPart; //number of partitions bool _KeepFiles; //tepal file .noboite binary or not bool _Background; //true for big meshes - bool _ToMeshHoles; + //ToMergeSubdomains ToTagSubdomains ToOutputInterfaces ToDiscardSubdomains + bool _ToMergeSubdomains; + bool _ToTagSubdomains; + bool _ToOutputInterfaces; + bool _ToDiscardSubdomains; }; #endif diff --git a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis.cxx b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis.cxx index 7898c98..7b6e6e4 100755 --- a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis.cxx +++ b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis.cxx @@ -30,14 +30,16 @@ * */ //============================================================================= -GHS3DPRLPlugin_Hypothesis::GHS3DPRLPlugin_Hypothesis (int hypId, int studyId, - SMESH_Gen * gen) +GHS3DPRLPlugin_Hypothesis::GHS3DPRLPlugin_Hypothesis (int hypId, int studyId, SMESH_Gen * gen) : SMESH_Hypothesis(hypId, studyId, gen), _MEDName( GetDefaultMEDName() ), _NbPart( GetDefaultNbPart() ), _KeepFiles( GetDefaultKeepFiles() ), _Background( GetDefaultBackground() ), - _ToMeshHoles( GetDefaultToMeshHoles() ) + _ToMergeSubdomains( GetDefaultToMergeSubdomains() ), + _ToTagSubdomains( GetDefaultToTagSubdomains() ), + _ToOutputInterfaces( GetDefaultToOutputInterfaces() ), + _ToDiscardSubdomains( GetDefaultToDiscardSubdomains() ) { MESSAGE("GHS3DPRLPlugin_Hypothesis::GHS3DPRLPlugin_Hypothesis"); _name = GetHypType(); @@ -114,11 +116,39 @@ void GHS3DPRLPlugin_Hypothesis::SetBackground(bool theVal) { } } -void GHS3DPRLPlugin_Hypothesis::SetToMeshHoles(bool theVal) { +/*void GHS3DPRLPlugin_Hypothesis::SetToMeshHoles(bool theVal) { if (theVal != _ToMeshHoles) { _ToMeshHoles = theVal; NotifySubMeshesHypothesisModification(); } +}*/ + +void GHS3DPRLPlugin_Hypothesis::SetToMergeSubdomains(bool theVal) { + if (theVal != _ToMergeSubdomains) { + _ToMergeSubdomains = theVal; + NotifySubMeshesHypothesisModification(); + } +} + +void GHS3DPRLPlugin_Hypothesis::SetToTagSubdomains(bool theVal) { + if (theVal != _ToTagSubdomains) { + _ToTagSubdomains = theVal; + NotifySubMeshesHypothesisModification(); + } +} + +void GHS3DPRLPlugin_Hypothesis::SetToOutputInterfaces(bool theVal) { + if (theVal != _ToOutputInterfaces) { + _ToOutputInterfaces = theVal; + NotifySubMeshesHypothesisModification(); + } +} + +void GHS3DPRLPlugin_Hypothesis::SetToDiscardSubdomains(bool theVal) { + if (theVal != _ToDiscardSubdomains) { + _ToDiscardSubdomains = theVal; + NotifySubMeshesHypothesisModification(); + } } @@ -137,7 +167,11 @@ std::ostream& GHS3DPRLPlugin_Hypothesis::SaveTo(std::ostream& save) //save without any whitespaces! save<<"MEDName="<<_MEDName<<";"; save<<"NbPart="<<_NbPart<<";"; - save<<"ToMeshHoles="<<(int) _ToMeshHoles<<";"; + //save<<"ToMeshHoles="<<(int) _ToMeshHoles<<";"; + save<<"ToMergeSubdomains="<<(int) _ToMergeSubdomains<<";"; + save<<"ToTagSubdomains="<<(int) _ToTagSubdomains<<";"; + save<<"ToOutputInterfaces="<<(int) _ToOutputInterfaces<<";"; + save<<"ToDiscardSubdomains="<<(int) _ToDiscardSubdomains<<";"; save<<"KeepFiles="<<(int) _KeepFiles<<";"; save<<"Background="<<(int) _Background<<";"; return save; @@ -174,7 +208,11 @@ std::istream& GHS3DPRLPlugin_Hypothesis::LoadFrom(std::istream& load) if (str3=="MEDName") _MEDName = str4.c_str(); if (str3=="NbPart") _NbPart = atoi(str4.c_str()); if (str3=="KeepFiles") _KeepFiles = (bool) atoi(str4.c_str()); - if (str3=="ToMeshHoles") _ToMeshHoles = (bool) atoi(str4.c_str()); + //if (str3=="ToMeshHoles") _ToMeshHoles = (bool) atoi(str4.c_str()); + if (str3=="ToMergeSubdomains") _ToMergeSubdomains = (bool) atoi(str4.c_str()); + if (str3=="ToTagSubdomains") _ToTagSubdomains = (bool) atoi(str4.c_str()); + if (str3=="ToOutputInterfaces") _ToOutputInterfaces = (bool) atoi(str4.c_str()); + if (str3=="ToDiscardSubdomains") _ToDiscardSubdomains = (bool) atoi(str4.c_str()); if (str3=="Background") _Background = (bool) atoi(str4.c_str()); } return load; @@ -210,7 +248,7 @@ std::istream& operator >>(std::istream& load, GHS3DPRLPlugin_Hypothesis& hyp) */ //================================================================================ bool GHS3DPRLPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* theMesh, - const TopoDS_Shape& theShape) + const TopoDS_Shape& theShape) { return false; } @@ -252,7 +290,31 @@ bool GHS3DPRLPlugin_Hypothesis::GetDefaultBackground() } //============================================================================= -bool GHS3DPRLPlugin_Hypothesis::GetDefaultToMeshHoles() +//bool GHS3DPRLPlugin_Hypothesis::GetDefaultToMeshHoles() +//{ +// return false; +//} + +//============================================================================= +bool GHS3DPRLPlugin_Hypothesis::GetDefaultToMergeSubdomains() +{ + return false; +} + +//============================================================================= +bool GHS3DPRLPlugin_Hypothesis::GetDefaultToTagSubdomains() +{ + return false; +} + +//============================================================================= +bool GHS3DPRLPlugin_Hypothesis::GetDefaultToOutputInterfaces() +{ + return false; +} + +//============================================================================= +bool GHS3DPRLPlugin_Hypothesis::GetDefaultToDiscardSubdomains() { return false; } diff --git a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis.hxx b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis.hxx index 6c65229..47f2679 100755 --- a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis.hxx +++ b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis.hxx @@ -52,9 +52,19 @@ public: void SetBackground(bool theVal); bool GetBackground() const { return _Background; } - - void SetToMeshHoles(bool theVal); - bool GetToMeshHoles() const { return _ToMeshHoles; } + + //ToMergeSubdomains ToTagSubdomains ToOutputInterfaces ToDiscardSubdomains + void SetToMergeSubdomains(bool theVal); + bool GetToMergeSubdomains() const { return _ToMergeSubdomains; } + + void SetToTagSubdomains(bool theVal); + bool GetToTagSubdomains() const { return _ToTagSubdomains; } + + void SetToOutputInterfaces(bool theVal); + bool GetToOutputInterfaces() const { return _ToOutputInterfaces; } + + void SetToDiscardSubdomains(bool theVal); + bool GetToDiscardSubdomains() const { return _ToDiscardSubdomains; } // the parameters default values @@ -62,7 +72,10 @@ public: static int GetDefaultNbPart(); static bool GetDefaultKeepFiles(); static bool GetDefaultBackground(); - static bool GetDefaultToMeshHoles(); + static bool GetDefaultToMergeSubdomains(); + static bool GetDefaultToTagSubdomains(); + static bool GetDefaultToOutputInterfaces(); + static bool GetDefaultToDiscardSubdomains(); // Persistence virtual std::ostream& SaveTo(std::ostream& save); @@ -92,7 +105,10 @@ private: int _NbPart; // number of partitions bool _KeepFiles; // keep intermediates tepal files or not bool _Background; // tepal in background - bool _ToMeshHoles; -}; + bool _ToMergeSubdomains; + bool _ToTagSubdomains; + bool _ToOutputInterfaces; + bool _ToDiscardSubdomains; + }; #endif diff --git a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis_i.cxx b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis_i.cxx index 06ed854..fad504c 100755 --- a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis_i.cxx +++ b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis_i.cxx @@ -67,7 +67,10 @@ GHS3DPRLPlugin_Hypothesis_i::~GHS3DPRLPlugin_Hypothesis_i() * GHS3DPRLPlugin_Hypothesis_i::SetNbPart * GHS3DPRLPlugin_Hypothesis_i::SetKeepFiles * GHS3DPRLPlugin_Hypothesis_i::SetBackground - * GHS3DPRLPlugin_Hypothesis_i::SetToMeshHoles + * GHS3DPRLPlugin_Hypothesis_i::SetToMergeSubdomains + * GHS3DPRLPlugin_Hypothesis_i::SetToTagSubdomains + * GHS3DPRLPlugin_Hypothesis_i::SetToOutputInterfaces + * GHS3DPRLPlugin_Hypothesis_i::SetToDiscardSubdomains */ //============================================================================= @@ -103,12 +106,36 @@ void GHS3DPRLPlugin_Hypothesis_i::SetBackground (CORBA::Boolean theValue) SMESH::TPythonDump() << _this() << ".SetBackground( " << theValue << " )"; } -void GHS3DPRLPlugin_Hypothesis_i::SetToMeshHoles (CORBA::Boolean theValue) +void GHS3DPRLPlugin_Hypothesis_i::SetToMergeSubdomains (CORBA::Boolean theValue) { - MESSAGE("GHS3DPRLPlugin_Hypothesis_i::SetToMeshHoles"); + MESSAGE("GHS3DPRLPlugin_Hypothesis_i::SetToMergeSubdomains"); ASSERT(myBaseImpl); - this->GetImpl()->SetToMeshHoles(theValue); - SMESH::TPythonDump() << _this() << ".SetToMeshHoles( " << theValue << " )"; + this->GetImpl()->SetToMergeSubdomains(theValue); + SMESH::TPythonDump() << _this() << ".SetToMergeSubdomains( " << theValue << " )"; +} + +void GHS3DPRLPlugin_Hypothesis_i::SetToTagSubdomains (CORBA::Boolean theValue) +{ + MESSAGE("GHS3DPRLPlugin_Hypothesis_i::SetToTagSubdomains"); + ASSERT(myBaseImpl); + this->GetImpl()->SetToTagSubdomains(theValue); + SMESH::TPythonDump() << _this() << ".SetToTagSubdomains( " << theValue << " )"; +} + +void GHS3DPRLPlugin_Hypothesis_i::SetToOutputInterfaces (CORBA::Boolean theValue) +{ + MESSAGE("GHS3DPRLPlugin_Hypothesis_i::SetToOutputInterfaces"); + ASSERT(myBaseImpl); + this->GetImpl()->SetToOutputInterfaces(theValue); + SMESH::TPythonDump() << _this() << ".SetToOutputInterfaces( " << theValue << " )"; +} + +void GHS3DPRLPlugin_Hypothesis_i::SetToDiscardSubdomains (CORBA::Boolean theValue) +{ + MESSAGE("GHS3DPRLPlugin_Hypothesis_i::SetToDiscardSubdomains"); + ASSERT(myBaseImpl); + this->GetImpl()->SetToDiscardSubdomains(theValue); + SMESH::TPythonDump() << _this() << ".SetToDiscardSubdomains( " << theValue << " )"; } //============================================================================= @@ -117,7 +144,10 @@ void GHS3DPRLPlugin_Hypothesis_i::SetToMeshHoles (CORBA::Boolean theValue) * GHS3DPRLPlugin_Hypothesis_i::GetNbPart * GHS3DPRLPlugin_Hypothesis_i::GetKeepFiles * GHS3DPRLPlugin_Hypothesis_i::GetBackground - * GHS3DPRLPlugin_Hypothesis_i::GetToMeshHoles + * GHS3DPRLPlugin_Hypothesis_i::GetToMergeSubdomains + * GHS3DPRLPlugin_Hypothesis_i::GetToTagSubdomains + * GHS3DPRLPlugin_Hypothesis_i::GetToOutputInterfaces + * GHS3DPRLPlugin_Hypothesis_i::GetToDiscardSubdomains */ //============================================================================= @@ -126,7 +156,7 @@ char * GHS3DPRLPlugin_Hypothesis_i::GetMEDName() MESSAGE("GHS3DPRLPlugin_Hypothesis_i::GetMEDName"); ASSERT(myBaseImpl); CORBA::String_var c_s = - CORBA::string_dup(this->GetImpl()->GetMEDName().c_str()); + CORBA::string_dup(this->GetImpl()->GetMEDName().c_str()); return c_s._retn(); } @@ -151,11 +181,32 @@ CORBA::Boolean GHS3DPRLPlugin_Hypothesis_i::GetBackground() return this->GetImpl()->GetBackground(); } -CORBA::Boolean GHS3DPRLPlugin_Hypothesis_i::GetToMeshHoles() +CORBA::Boolean GHS3DPRLPlugin_Hypothesis_i::GetToMergeSubdomains() +{ + MESSAGE("GHS3DPRLPlugin_Hypothesis_i::GetToMergeSubdomains"); + ASSERT(myBaseImpl); + return this->GetImpl()->GetToMergeSubdomains(); +} + +CORBA::Boolean GHS3DPRLPlugin_Hypothesis_i::GetToTagSubdomains() +{ + MESSAGE("GHS3DPRLPlugin_Hypothesis_i::GetToTagSubdomains"); + ASSERT(myBaseImpl); + return this->GetImpl()->GetToTagSubdomains(); +} + +CORBA::Boolean GHS3DPRLPlugin_Hypothesis_i::GetToOutputInterfaces() +{ + MESSAGE("GHS3DPRLPlugin_Hypothesis_i::GetToOutputInterfaces"); + ASSERT(myBaseImpl); + return this->GetImpl()->GetToOutputInterfaces(); +} + +CORBA::Boolean GHS3DPRLPlugin_Hypothesis_i::GetToDiscardSubdomains() { - MESSAGE("GHS3DPRLPlugin_Hypothesis_i::GetToMeshHoles"); + MESSAGE("GHS3DPRLPlugin_Hypothesis_i::GetToDiscardSubdomains"); ASSERT(myBaseImpl); - return this->GetImpl()->GetToMeshHoles(); + return this->GetImpl()->GetToDiscardSubdomains(); } //============================================================================= diff --git a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis_i.hxx b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis_i.hxx index 04d592a..3109336 100755 --- a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis_i.hxx +++ b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis_i.hxx @@ -44,8 +44,8 @@ class GHS3DPRLPLUGIN_EXPORT GHS3DPRLPlugin_Hypothesis_i: public: // Constructor GHS3DPRLPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA, - int theStudyId, - ::SMESH_Gen* theGenImpl); + int theStudyId, + ::SMESH_Gen* theGenImpl); // Destructor virtual ~GHS3DPRLPlugin_Hypothesis_i(); @@ -62,8 +62,17 @@ class GHS3DPRLPLUGIN_EXPORT GHS3DPRLPlugin_Hypothesis_i: void SetBackground(CORBA::Boolean theVal); CORBA::Boolean GetBackground(); - void SetToMeshHoles(CORBA::Boolean theVal); - CORBA::Boolean GetToMeshHoles(); + void SetToMergeSubdomains(CORBA::Boolean theVal); + CORBA::Boolean GetToMergeSubdomains(); + + void SetToTagSubdomains(CORBA::Boolean theVal); + CORBA::Boolean GetToTagSubdomains(); + + void SetToOutputInterfaces(CORBA::Boolean theVal); + CORBA::Boolean GetToOutputInterfaces(); + + void SetToDiscardSubdomains(CORBA::Boolean theVal); + CORBA::Boolean GetToDiscardSubdomains(); // Get implementation ::GHS3DPRLPlugin_Hypothesis* GetImpl(); diff --git a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_i.cxx b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_i.cxx index 7a91fe6..03dcea4 100755 --- a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_i.cxx +++ b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_i.cxx @@ -55,7 +55,7 @@ extern "C" // Algorithms if (strcmp(aHypName, "GHS3DPRL_3D") == 0 || - strcmp(aHypName, "MG-Tetra Parallel") == 0) + strcmp(aHypName, "MG-Tetra Parallel") == 0) aCreator = new GHS3DPRLPlugin_Creator_i; // Hypotheses else if (strcmp(aHypName, "GHS3DPRL_Parameters") == 0 || diff --git a/src/gui/GHS3DPRLPluginGUI_HypothesisCreator.cxx b/src/gui/GHS3DPRLPluginGUI_HypothesisCreator.cxx index 13f3fa5..b37515d 100755 --- a/src/gui/GHS3DPRLPluginGUI_HypothesisCreator.cxx +++ b/src/gui/GHS3DPRLPluginGUI_HypothesisCreator.cxx @@ -46,7 +46,7 @@ GHS3DPRLPluginGUI_HypothesisCreator::GHS3DPRLPluginGUI_HypothesisCreator( const : SMESHGUI_GenericHypothesisCreator( theHypType ), myIs3D( true ) { - printf("Hypo creator !!!!!!!!!!!!!!!!!!!!!!!!!! RNV"); + //printf("Hypo creator GHS3DPRLPlugin !!!!!!!!!!!!!!!!!!!!!!!!!! RNV"); } GHS3DPRLPluginGUI_HypothesisCreator::~GHS3DPRLPluginGUI_HypothesisCreator() @@ -113,9 +113,25 @@ QFrame* GHS3DPRLPluginGUI_HypothesisCreator::buildFrame() myBackground->setWhatsThis( tr( "GHS3DPRL_WhatsThis_Background" ) ); l->addWidget( myBackground, row++, 0, 1, 2 ); - myToMeshHoles = new QCheckBox( tr( "GHS3DPRL_ToMeshHoles" ), GroupC1 ); - myToMeshHoles->setWhatsThis( tr( "GHS3DPRL_WhatsThis_ToMeshHoles" ) ); - l->addWidget( myToMeshHoles, row++, 0, 1, 2 ); + //myToMeshHoles = new QCheckBox( tr( "GHS3DPRL_ToMeshHoles" ), GroupC1 ); + //myToMeshHoles->setWhatsThis( tr( "GHS3DPRL_WhatsThis_ToMeshHoles" ) ); + //l->addWidget( myToMeshHoles, row++, 0, 1, 2 ); + + myToMergeSubdomains = new QCheckBox( tr( "GHS3DPRL_ToMergeSubdomains" ), GroupC1 ); + myToMergeSubdomains->setWhatsThis( tr( "GHS3DPRL_WhatsThis_ToMergeSubdomains" ) ); + l->addWidget( myToMergeSubdomains, row++, 0, 1, 2 ); + + myToTagSubdomains = new QCheckBox( tr( "GHS3DPRL_ToTagSubdomains" ), GroupC1 ); + myToTagSubdomains->setWhatsThis( tr( "GHS3DPRL_WhatsThis_ToTagSubdomains" ) ); + l->addWidget( myToTagSubdomains, row++, 0, 1, 2 ); + + myToOutputInterfaces = new QCheckBox( tr( "GHS3DPRL_ToOutputInterfaces" ), GroupC1 ); + myToOutputInterfaces->setWhatsThis( tr( "GHS3DPRL_WhatsThis_ToOutputInterfaces" ) ); + l->addWidget( myToOutputInterfaces, row++, 0, 1, 2 ); + + myToDiscardSubdomains = new QCheckBox( tr( "GHS3DPRL_ToDiscardSubdomains" ), GroupC1 ); + myToDiscardSubdomains->setWhatsThis( tr( "GHS3DPRL_WhatsThis_ToDiscardSubdomains" ) ); + l->addWidget( myToDiscardSubdomains, row++, 0, 1, 2 ); myIs3D = true; @@ -132,7 +148,11 @@ void GHS3DPRLPluginGUI_HypothesisCreator::retrieveParams() const myNbPart->setValue( data.myNbPart ); myKeepFiles->setChecked( data.myKeepFiles ); myBackground->setChecked( data.myBackground ); - myToMeshHoles->setChecked( data.myToMeshHoles ); + //myToMeshHoles->setChecked( data.myToMeshHoles ); + myToMergeSubdomains->setChecked( data.myToMergeSubdomains ); + myToTagSubdomains->setChecked( data.myToTagSubdomains ); + myToOutputInterfaces->setChecked( data.myToOutputInterfaces ); + myToDiscardSubdomains->setChecked( data.myToDiscardSubdomains ); //myNbPart->setEnabled( true ); } @@ -145,7 +165,11 @@ QString GHS3DPRLPluginGUI_HypothesisCreator::storeParams() const QString valStr; valStr += tr( "GHS3DPRL_MEDName" ) + " = " + data.myMEDName + "; "; valStr += tr( "GHS3DPRL_NbPart" ) + " = " + QString::number( data.myNbPart ) + "; "; - valStr += tr( "GHS3DPRL_ToMeshHoles" ) + " = " + QString::number( data.myToMeshHoles ) + "; "; + //valStr += tr( "GHS3DPRL_ToMeshHoles" ) + " = " + QString::number( data.myToMeshHoles ) + "; "; + valStr += tr( "GHS3DPRL_ToMergeSubdomains" ) + " = " + QString::number( data.myToMergeSubdomains ) + "; "; + valStr += tr( "GHS3DPRL_ToTagSubdomains" ) + " = " + QString::number( data.myToTagSubdomains ) + "; "; + valStr += tr( "GHS3DPRL_ToOutputInterfaces" ) + " = " + QString::number( data.myToOutputInterfaces ) + "; "; + valStr += tr( "GHS3DPRL_ToDiscardSubdomains" ) + " = " + QString::number( data.myToDiscardSubdomains ) + "; "; valStr += tr( "GHS3DPRL_KeepFiles" ) + " = " + QString::number( data.myKeepFiles ) + "; "; valStr += tr( "GHS3DPRL_Background" ) + " = " + QString::number( data.myBackground ) + "; "; @@ -163,7 +187,11 @@ bool GHS3DPRLPluginGUI_HypothesisCreator::readParamsFromHypo( GHS3DPRLHypothesis h_data.myNbPart = h->GetNbPart(); h_data.myKeepFiles = h->GetKeepFiles(); h_data.myBackground = h->GetBackground(); - h_data.myToMeshHoles = h->GetToMeshHoles(); + //h_data.myToMeshHoles = h->GetToMeshHoles(); + h_data.myToMergeSubdomains = h->GetToMergeSubdomains(); + h_data.myToTagSubdomains = h->GetToTagSubdomains(); + h_data.myToOutputInterfaces = h->GetToOutputInterfaces(); + h_data.myToDiscardSubdomains = h->GetToDiscardSubdomains(); return true; } @@ -183,7 +211,11 @@ bool GHS3DPRLPluginGUI_HypothesisCreator::storeParamsToHypo( const GHS3DPRLHypot h->SetNbPart( h_data.myNbPart ); h->SetKeepFiles( h_data.myKeepFiles ); h->SetBackground( h_data.myBackground ); - h->SetToMeshHoles( h_data.myToMeshHoles ); + //h->SetToMeshHoles( h_data.myToMeshHoles ); + h->SetToMergeSubdomains( h_data.myToMergeSubdomains ); + h->SetToTagSubdomains( h_data.myToTagSubdomains ); + h->SetToOutputInterfaces( h_data.myToOutputInterfaces ); + h->SetToDiscardSubdomains( h_data.myToDiscardSubdomains ); } catch ( const SALOME::SALOME_Exception& ex ) { @@ -200,7 +232,11 @@ bool GHS3DPRLPluginGUI_HypothesisCreator::readParamsFromWidgets( GHS3DPRLHypothe h_data.myNbPart = myNbPart->value(); h_data.myKeepFiles = myKeepFiles->isChecked(); h_data.myBackground = myBackground->isChecked(); - h_data.myToMeshHoles = myToMeshHoles->isChecked(); + //h_data.myToMeshHoles = myToMeshHoles->isChecked(); + h_data.myToMergeSubdomains = myToMergeSubdomains->isChecked(); + h_data.myToTagSubdomains = myToTagSubdomains->isChecked(); + h_data.myToOutputInterfaces = myToOutputInterfaces->isChecked(); + h_data.myToDiscardSubdomains = myToDiscardSubdomains->isChecked(); return true; } diff --git a/src/gui/GHS3DPRLPluginGUI_HypothesisCreator.h b/src/gui/GHS3DPRLPluginGUI_HypothesisCreator.h index 2779d9d..3c7e4b5 100755 --- a/src/gui/GHS3DPRLPluginGUI_HypothesisCreator.h +++ b/src/gui/GHS3DPRLPluginGUI_HypothesisCreator.h @@ -49,7 +49,11 @@ typedef struct int myNbPart; bool myKeepFiles; bool myBackground; - bool myToMeshHoles; + //bool myToMeshHoles; + bool myToMergeSubdomains; + bool myToTagSubdomains; + bool myToOutputInterfaces; + bool myToDiscardSubdomains; } GHS3DPRLHypothesisData; /*! @@ -86,7 +90,11 @@ private: QtxIntSpinBox* myNbPart; QCheckBox* myKeepFiles; QCheckBox* myBackground; - QCheckBox* myToMeshHoles; + //QCheckBox* myToMeshHoles; + QCheckBox* myToMergeSubdomains; + QCheckBox* myToTagSubdomains; + QCheckBox* myToOutputInterfaces; + QCheckBox* myToDiscardSubdomains; bool myIs3D; }; diff --git a/src/gui/GHS3DPRLPlugin_msg_en.ts b/src/gui/GHS3DPRLPlugin_msg_en.ts index c5cd05c..2c54997 100644 --- a/src/gui/GHS3DPRLPlugin_msg_en.ts +++ b/src/gui/GHS3DPRLPlugin_msg_en.ts @@ -17,11 +17,27 @@ GHS3DPRL_Background - Tepal in background + Tetra_hpc in background GHS3DPRL_ToMeshHoles - To mesh holes + Mesh holes + + + GHS3DPRL_ToMergeSubdomains + Merge subdomains + + + GHS3DPRL_ToTagSubdomains + Tag subdomains + + + GHS3DPRL_ToOutputInterfaces + Output interfaces + + + GHS3DPRL_ToDiscardSubdomains + Discard subdomains GHS3DPRL_MEDName diff --git a/src/gui/GHS3DPRLPlugin_msg_fr.ts b/src/gui/GHS3DPRLPlugin_msg_fr.ts index 2758ea7..4766a7d 100755 --- a/src/gui/GHS3DPRLPlugin_msg_fr.ts +++ b/src/gui/GHS3DPRLPlugin_msg_fr.ts @@ -5,7 +5,7 @@ @default GHS3DPRL_3D_HYPOTHESIS - GHS3DPRL 3D + Paramètres MG-Tetra-hpc GHS3DPRL_3D_TITLE @@ -13,15 +13,31 @@ GHS3DPRL_KeepFiles - Sauvegarder les fichiers + Garder les fichiers intermédiaires GHS3DPRL_Background - Tepal en arrière plan + Tetra_hpc en arrière plan GHS3DPRL_ToMeshHoles - Mailler les trous + Mailler les trous du maillage + + + GHS3DPRL_ToMergeSubdomains + Fusionner les sous domaines en fin + + + GHS3DPRL_ToTagSubdomains + Marquer les sous domaines + + + GHS3DPRL_ToOutputInterfaces + Gestion des interfaces entre les sous domaines + + + GHS3DPRL_ToDiscardSubdomains + Oublier les sous domaines GHS3DPRL_MEDName @@ -33,15 +49,15 @@ GHS3DPRL_WhatsThis_KeepFiles - Préserver les fichiers Tepal intermédiaires (.faces,.points,.msg,.noboite...) + Préserver les fichiers intermédiaires (.faces,.points,.msg,.noboite...) GHS3DPRL_WhatsThis_Background - Lancer Tepal en arrière-plan (prend du temps pour un maillage de grand volume...) + Lancer MG-Tetra-hpc en arrière-plan (prend du temps pour un maillage de grand volume...) GHS3DPRL_WhatsThis_ToMeshHoles - Tepal maille les trous + MG-Tetra-hp maille les trous (obsolète) GHS3DPRL_WhatsThis_MEDName diff --git a/src/tepal2med/CMakeLists.txt b/src/tepal2med/CMakeLists.txt index 2962e2d..84c623b 100644 --- a/src/tepal2med/CMakeLists.txt +++ b/src/tepal2med/CMakeLists.txt @@ -66,7 +66,6 @@ SET(_other_SOURCES ghs3dprl_mesh_wrap.cxx ghs3dprl_msg_parser.cxx dlg_ghs3dmain.cxx - tepal2med.cxx ) # resource files / to be processed by uic @@ -78,10 +77,13 @@ SET(_uic_files QT4_WRAP_UI(_uic_HEADERS ${_uic_files}) # sources / to compile -SET(tepal2med_SOURCES ${_other_SOURCES} ${_moc_SOURCES} ${_uic_HEADERS}) +SET(tepal2med_SOURCES tepal2med.cxx ${_other_SOURCES} ${_moc_SOURCES} ${_uic_HEADERS}) +SET(tetrahpc2med_SOURCES tetrahpc2med.cxx ${_other_SOURCES} ${_moc_SOURCES} ${_uic_HEADERS}) # --- rules --- ADD_EXECUTABLE(tepal2med ${tepal2med_SOURCES}) +ADD_EXECUTABLE(tetrahpc2med ${tetrahpc2med_SOURCES}) TARGET_LINK_LIBRARIES(tepal2med ${_link_LIBRARIES}) -INSTALL(TARGETS tepal2med EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_BINS}) +TARGET_LINK_LIBRARIES(tetrahpc2med ${_link_LIBRARIES}) +INSTALL(TARGETS tepal2med tetrahpc2med EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_BINS}) diff --git a/src/tepal2med/ghs3dprl_mesh_wrap.cxx b/src/tepal2med/ghs3dprl_mesh_wrap.cxx index 1ed2e55..8f557f4 100755 --- a/src/tepal2med/ghs3dprl_mesh_wrap.cxx +++ b/src/tepal2med/ghs3dprl_mesh_wrap.cxx @@ -448,6 +448,40 @@ bool CVW_FindString(const std::string &str,std::fstream &Ff, long &count) return true; } +//************************************ +bool CVW_FindStringInFirstLines(const std::string &str,std::fstream &Ff, long &maxline) +//find in file maximum maxline first lines with string str in first position of line +//converts count value expected after " " in line found +{ + std::string line; + long nbLine=0; + do + { + if (getline(Ff,line)) + { + nbLine++; + if (line[0]==str[0]) //faster + { + if (line.find(str)==0) + { + return true; + } + } + if (nbLine>=maxline) + { + std::cerr<<"Problem line '"< for speed (and so no test) +{ + QString tmp; + std::fstream Ff(FileName.toLatin1().constData(),std::ios_base::in); + std::string line; + long i,count,meshversion,maxline; + bool ok; + + if (!Ff.is_open()) + { + std::cerr<<"Problem File '"<2) std::cout<<"MeshVersionFormatted_"<nofile<<" ok"<nbfiles++; + return true; +} + ///************************************ bool ghs3dprl_mesh_wrap::ReadFileGLO(const QString FileName) //read file .glo with no parser xml because big file (volume) @@ -645,6 +707,171 @@ bool ghs3dprl_mesh_wrap::ReadFileFACES(const QString FileName) return true; } +//************************************ +bool ghs3dprl_mesh_wrap::ReadFileMESH(const QString FileName) +//read file .mesh from tetra_hpc (with volume) +{ + std::string line(" "); + QString tmp; + std::fstream Ff(FileName.toLatin1().constData(),std::ios_base::in); + long Mversion=0,Mdim=0,Mvert=0,Mtria=0,Mtetra=0; + med_int garbage; + //long ne,np,npfixe,subnumber,reste; + bool ok; + if (verbose>=6)std::cout<<"Read File '"<>tmflo[i]>>tmflo[i+1]>>tmflo[i+2]>>garbage; + if (verbose>4) std::cout<<"Vertices "<nofile); + ok=this->insert_key(tmp,montab); + + getline(Ff,line); + getline(Ff,line); + + if (!(getline(Ff,line) && (line.find("Triangles")==0))) + { + std::cerr<<"Problem on line 'Triangles' of file: not found"<>tmint[i]>>tmint[i+1]>>tmint[i+2]>>garbage; + tmint[i+3]=0; + tmint[i+4]=0; + tmint[i+5]=0; + tmint[i+6]=0; + } + if (verbose>4) std::cout<<"Triangles "<nofile); + ok=this->insert_key(tmp,montab); + + getline(Ff,line); + getline(Ff,line); + + if (!(getline(Ff,line) && (line.find("Tetrahedra")==0))) + { + std::cerr<<"Problem on line 'Tetrahedra' of file: not found"<=2) + { + std::cout<<"MeshVersionFormatted="<nofile); + ok=this->insert_key(tmp,montab); + + //swap on file if too big for memory in one cpu + //default 1GOctet/8(for double)/10(for arrays in memory at the same time) + if (Mvert*3>this->nbelem_limit_swap) + this->SwapOutOfMemory_key_mesh_wrap(QRegExp("NB",Qt::CaseSensitive,QRegExp::RegExp)); + //beware record 6 lenght 1 + //ferme le fichier : + Ff.close(); + this->nbfiles++; + return true; +} + //************************************ bool ghs3dprl_mesh_wrap::ReadFileNOBOITE(const QString FileName) //read file .noboite (volume) @@ -1370,7 +1597,7 @@ bool ghs3dprl_mesh_wrap::Write_masterxmlMEDfile() //Creating child nodes //Version tag med_int majeur,mineur,release; - //Quelle version de MED est utilis� + //Quelle version de MED est utilisee MEDlibraryNumVersion(&majeur,&mineur,&release); if (verbose>0) fprintf(stdout,"Files write with MED V%d.%d.%d\n",majeur,mineur,release); node = xmlNewChild(root_node, 0, BAD_CAST "version",0); @@ -1381,7 +1608,7 @@ bool ghs3dprl_mesh_wrap::Write_masterxmlMEDfile() //Description tag node = xmlNewChild(root_node,0, BAD_CAST "description",0); - xmlNewProp(node, BAD_CAST "what", BAD_CAST "tetrahedral mesh by tepal"); + xmlNewProp(node, BAD_CAST "what", BAD_CAST "tetrahedral mesh by MeshGems-Tetra-hpc (formerly tepal)"); #ifdef WIN32 SYSTEMTIME present; GetLocalTime ( &present ); @@ -1522,7 +1749,8 @@ bool ghs3dprl_mesh_wrap::Write_MEDfiles_v2(bool deletekeys) cmd.toLatin1().constData()<<"> does not exist\n"; } //define family 0 if not existing, no groups - families.add("0",""); + //La famille FAMILLE_ZERO n'a pas été trouvée, elle est obligatoire + families.add("0","FAMILLE_ZERO"); //define family Group_of_New_Nodes (which not exists before tetrahedra) famallnodes=0; if (QString("All_Nodes").contains(deletegroups)==0){ @@ -1647,6 +1875,7 @@ bool ghs3dprl_mesh_wrap::Write_MEDfiles_v2(bool deletekeys) MEDfileClose(fid); //but loop on others domains } + MEDfileClose(fidjoint); //no error if (verbose>0)std::cout<<"\nTotalNumberOftetrahedra="<restore_key(key); //tab1=this->mestab[key1]; if (!tab) { - tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,idom)+".noboite"; - ok=this->ReadFileNOBOITE(tmp); + if (!for_tetrahpc) { + tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,idom)+".noboite"; + ok=this->ReadFileNOBOITE(tmp); + } + if (for_tetrahpc) { + tmp=pathini+casename+tmp.sprintf(format_tetra.toLatin1().constData(),idom)+".mesh"; + ok=this->ReadFileMESH(tmp); + } tab=this->restore_key(key); //tab1=this->mestab[key1]; if (!tab) return false; } @@ -1690,8 +1925,14 @@ bool ghs3dprl_mesh_wrap::idom_nodes() key1=key1.sprintf("GL%d VE",idom); //global numerotation tab1=this->restore_key(key1); //tab1=this->mestab[key1]; if (!tab1) { - tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,idom)+".glo"; - ok=this->ReadFileGLO(tmp); + if (!for_tetrahpc) { + tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,idom)+".glo"; + ok=this->ReadFileGLO(tmp); + } + if (for_tetrahpc) { + tmp=pathini+casename+tmp.sprintf(format_tetra.toLatin1().constData(),idom)+".glo"; + ok=this->ReadFileGLO(tmp); + } if (!ok) {std::cerr<<"Problem file "<restore_key(key1); //tab1=this->mestab[key1]; if (!tab1) return false; @@ -1942,17 +2183,14 @@ bool ghs3dprl_mesh_wrap::idom_joints() //qt3 if (this->nb_key_mesh_wrap(QRegExp(tmp,true,true))<=0) { if (this->nb_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp))<=0) { this->nofile=idom; - /*old version with xml parser too slow - ghs3dprl_msg_parser handler; - handler.mailw=this; - QXmlSimpleReader reader; - reader.setContentHandler(&handler); - tmp=pathini+casename+tmp.sprintf(format,nbfilestot,idom)+".msg"; - QFile File(tmp); - QXmlInputSource source(&File); - reader.parse(source); - File.close();*/ - tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,idom)+".msg"; + + if (!for_tetrahpc) { + tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,idom)+".msg"; + } + if (for_tetrahpc) { + tmp=pathini+casename+tmp.sprintf(format_tetra.toLatin1().constData(),idom)+".msg"; + } + ok=this->ReadFileMSGnew(tmp); if (!ok) { std::cerr<<"Problem in file "<restore_key(key1); //if not yet loaded (first time) try to load necessary file msg of neighbourg if (!tab2) { - tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,ineig)+".msg"; + + if (!for_tetrahpc) { + tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,ineig)+".msg"; + } + if (for_tetrahpc) { + tmp=pathini+casename+tmp.sprintf(format_tetra.toLatin1().constData(),ineig)+".msg"; + } + this->nofile=ineig; //neighbourg file ok=this->ReadFileMSGnew(tmp); this->nofile=idom; //restaure initial domain @@ -2019,14 +2264,14 @@ bool ghs3dprl_mesh_wrap::idom_joints() //two indices for one correspondence arrayi=new med_int[nb*2]; arraynodes=new med_float[nbnodesneig*3]; //for file DOMAIN_join.med - inodes=new med_int[nbnodes]; //for file DOMAIN_join.med + inodes=new med_int[nbnodes]; //for file DOMAIN_join.med med_int * fammore=new med_int[nbnodes]; - for (i=0; i equals tab1->tmint[i]==tab2->tmint[i] - j=tab1->tmint[i]-1; //contents of tab1 1 to nb - inodes[j]=k; k++; //indices 0->n-1 of nodes of joint from nodes of domain + j=tab1->tmint[i]-1; //contents of tab1 1->nb, j 0->nb-1 + inodes[j]=k; k++; //contents of inodes 1->n ,nodes of joint from nodes of domain arraynodes[jj]=tab->tmflo[j*3]; jj++; arraynodes[jj]=tab->tmflo[j*3+1]; jj++; arraynodes[jj]=tab->tmflo[j*3+2]; jj++; @@ -2061,7 +2306,7 @@ bool ghs3dprl_mesh_wrap::idom_joints() key1=key1.sprintf("MS%d NE%d FA SE",ineig,idom); //SE or RE identicals tab2=this->restore_key(key1); if (!tab2) std::cerr<<"Problem existing triangles of joint in domain "<size; nbtria3neig=tab2->size; if (nb!=nbtria3neig) { std::cerr<<"Problem in file "<restore_key(key); //tab1=this->mestab[key1]; med_int nb=tab1->size; nbtria3neig=nb; - if (verbose>4) - std::cout<<"NumberOfTrianglesOfJoint_"<=0) std::cout<<"NumberOfTrianglesOfJoint_"<tmint[i]; ii++; + arrayi[ii]=tab2->tmint[i]; ii++; //correspondance indices triangles in 2 domains + fammore[tab1->tmint[i]-1]=famjoint; //famtria3[tab1->tmint[i]-1]=famjoint; - arrayi[ii]=tab2->tmint[i]; ii++; - //std::cout<tmint[i]-1)*7; //indice of node connectivity - arrayfaces[jj]=inodes[tab->tmint[k]-1]+1; jj++; - arrayfaces[jj]=inodes[tab->tmint[k+1]-1]+1; jj++; - arrayfaces[jj]=inodes[tab->tmint[k+2]-1]+1; jj++; + + k=tab1->tmint[i]-1; //indice of node connectivity + //std::cout<<"k="<tmint[k]-1]; jj++; + arrayfaces[jj]=inodes[tab->tmint[k+1]-1]; jj++; + arrayfaces[jj]=inodes[tab->tmint[k+2]-1]; jj++; + } + int happens=0; + for (i=0; isize ; i++) std::cout<<"triangle i "<tmint[i]<size ; i=i+7) std::cout<<"conn i "<tmint[i]<<" "<tmint[i+1]<<" "<tmint[i+2]<0) { //for (i=0; i5)std::cout<name; + char attdes[MED_COMMENT_SIZE+1]="_NO_DESCRIPTION"; + + char *gro; + med_int i,attide=1,attval=1,natt=1,num=0,ngro=0; + + gro=new char[MED_LNAME_SIZE*ngro+2]; + if (verbose>3)std::cout<<"\ncreate_family_ZERO "<verbose>3){ med_float *coo=new med_float[nnoe*sdim]; /* table des numeros de familles des noeuds profil : (nombre de noeuds) */ med_int *famnodesskin=new med_int[nnoe]; - med_int *pfltab=new med_int[1]; //inutilise car on lit tout + //med_int *pfltab=new med_int[1]; //inutilise car on lit tout //lecture des noeuds : coordonnees ret=MEDmeshNodeCoordinateRd(fid,mymailw->nommaa,MED_NO_DT,MED_NO_IT,MED_FULL_INTERLACE,coo); //mdim,coo,mode_coo,MED_ALL,pfltab,0,&rep,mymailw->nomcoo,mymailw->unicoo); @@ -378,10 +379,10 @@ if (mymailw->verbose>3){ } std::cout<nommaa,MED_NO_DT,MED_NO_IT, - MED_CELL,MED_TRIA3,MED_NODAL,MED_FULL_INTERLACE,pfltab); + MED_CELL,MED_TRIA3,MED_NODAL,MED_FULL_INTERLACE,conn3); //MEDconnLire(fid,mymailw->nommaa,mdim,conn3,mode_coo,pfltab,0,MED_MAILLE,MED_TRIA3,MED_NOD); if (ret < 0){ std::cerr<<"Problem reading MED_TRIA3\n"; @@ -529,7 +530,7 @@ int main(int argc, char *argv[]) QString path,pathini,casename,casenamemed,fileskinmed, tmp,cmd,format, test,menu,launchtepal,background,deletegroups, - version="V2.0 (MED3)"; + version="V3.0 (MED3+tepalv1)"; char *chelp=NULL, *ccasename=NULL, @@ -667,7 +668,7 @@ int main(int argc, char *argv[]) if (menu=="yes") { QApplication a(argc,argv); dlg_ghs3dmain *m = new dlg_ghs3dmain(); - m->setWindowTitle("tepal2med 2.1"); + m->setWindowTitle("tepal2med 3.0"); m->show(); a.exec(); if ( m->result() == QDialog::Accepted ) { @@ -776,6 +777,8 @@ int main(int argc, char *argv[]) int nbf=format.length(); format=format.sprintf(".%%.%dd.%%.%dd",nbf,nbf); mymailw->format=format; + mymailw->format_tetra=format; //here is tepal: not used + mymailw->for_tetrahpc=false; //to know what files to read: .noboite or .mesh //something like "/home/wambeke/tmp/GHS3DPRL_skin.med" fileskinmed=pathini+casename+"_skin.med"; diff --git a/src/tepal2med/tetrahpc2med.cxx b/src/tepal2med/tetrahpc2med.cxx new file mode 100755 index 0000000..098bd1e --- /dev/null +++ b/src/tepal2med/tetrahpc2med.cxx @@ -0,0 +1,835 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// --- +// File : tetrahpc2med.cxx +// Author : Christian VAN WAMBEKE (CEA) +// --- +// +/* +** prog principal de ghs3dprl +*/ + +#include /* printf clrscr fopen fread fwrite fclose */ +#include +#include +#include +#include +#include +#include +#include +#ifndef WIN32 +#include +#endif + +#include + +#include +#include +#include + +#include "ghs3dprl_msg_parser.h" +#include "dlg_ghs3dmain.h" + +#ifdef WIN32 +#include +#include +#define F_OK 0 +#endif + +//#include "MEDMEM_Exception.hxx" +//#include "MEDMEM_define.hxx" + +extern "C" { +#include +//#include +//#include +//#include +} + +//************************************ +med_idt ouvre_fichier_MED(char *fichier,int verbose) +{ + med_idt fid = 0; + med_err ret = 0; + med_int majeur,mineur,release; + + /* on regarde si le fichier existe */ + ret = (int) access(fichier,F_OK); + if (ret < 0) return fid; + + /* on regarde s'il s'agit d'un fichier au format HDF5 */ + med_bool hdfok,medok; + ret = MEDfileCompatibility(fichier,&hdfok,&medok); + if (ret < 0){ + std::cerr<<"File "<0)fprintf(stdout,"\nReading %s with MED V%d.%d.%d", + fichier,majeur,mineur,release); + + /* Ouverture du fichier MED en lecture seule */ + fid = MEDfileOpen(fichier,MED_ACC_RDONLY); + if (ret < 0) return fid; + + MEDfileNumVersionRd(fid, &majeur, &mineur, &release); + if (majeur < 2 || majeur == 2 && mineur < 2) { + fprintf(stderr,"File %s from MED V%d.%d.%d not assumed\n", + fichier,majeur,mineur,release); + //" version est ant�ieure �la version 2.2"; + ret = MEDfileClose(fid); + fid=0; } + else { + if (verbose>0)fprintf(stdout,", file from MED V%d.%d.%d\n",majeur,mineur,release); } + + return fid; +} + +//************************************ +bool ReadFileMED(QString nomfilemed,ghs3dprl_mesh_wrap *mymailw) +{ + med_err ret; + med_idt fid=0; + med_int i,j,sdim,mdim,nmaa,edim,majeur_lu,mineur_lu,release_lu,nprofils,nstep; + med_mesh_type type_maillage; + char dtunit[MED_SNAME_SIZE+1]; + char axisname[MED_SNAME_SIZE+1]; + char axisunit[MED_SNAME_SIZE*3+1]; + med_sorting_type sortingtype; + med_axis_type axistype; + int numero=1; + QString key,tmp; + med_bool chan; + med_bool tran; + + //version qt3 + char* chaine = (char*)malloc((nomfilemed.length()+1)*sizeof(char)); + strncpy(chaine,nomfilemed.toLatin1().constData(),nomfilemed.length()+1); + //std::cout<<"*** ReadFileMED *** "<verbose); + free(chaine); + if (fid == 0) { + std::cerr<<"Problem opening file "< 1) std::cout<<"More than one mesh in "<nommaa,&sdim,&mdim,&type_maillage,mymailw->maillage_description, + dtunit,&sortingtype,&nstep,&axistype,axisname,axisunit); + if (ret < 0){ + std::cerr<<"Problem MEDmeshInfo in "<nommaa,MED_NO_DT,MED_NO_IT, + MED_NODE,MED_NO_GEOTYPE,MED_COORDINATE,MED_NO_CMODE,&chan,&tran); + //(med_geometrie_element)0,(med_connectivite)0); + if (nnoe<1){ + std::cerr<<"Problem number of Vertices < 1\n"; + ret = MEDfileClose(fid); + return false; + } + + //nombre d'objets MED : mailles, faces, aretes , ... + med_int nmailles[MED_N_CELL_GEO],nbtria3; + med_int nfaces[MED_N_FACE_GEO]; + med_int naretes[MED_N_EDGE_FIXED_GEO],nbseg2; + //med_int nmailles[MED_NBR_GEOMETRIE_MAILLE],nbtria3; + //med_int nfaces[MED_NBR_GEOMETRIE_FACE]; + //med_int naretes[MED_NBR_GEOMETRIE_ARETE],nbseg2; + //polygones et polyedres familles equivalences joints + med_int nmpolygones,npolyedres,nfpolygones,nfam,nequ,njnt; + + //Combien de mailles, faces ou aretes pour chaque type geometrique ? + /*for (i=0;inommaa,MED_CONN,MED_MAILLE,typmai[i],typ_con); + //lecture_nombre_mailles_standards(fid,nommaa,typmai[i],typ_con,i); + if (mymailw->verbose>6) std::cout<<"NumberOf"<nommaa,MED_NO_DT,MED_NO_IT, + MED_CELL,MED_TRIA3,MED_CONNECTIVITY,MED_NODAL,&chan,&tran); + nbseg2=MEDmeshnEntity(fid,mymailw->nommaa,MED_NO_DT,MED_NO_IT, + MED_CELL,MED_SEG2,MED_CONNECTIVITY,MED_NODAL,&chan,&tran); + + //combien de familles ? + nfam=MEDnFamily(fid,mymailw->nommaa); + if (mymailw->verbose>2) { + std::cout<<"\nNumberOfFamilies="< famdelete = std::vector(nfam); +{ + med_int ngro; + char *gro; + char nomfam[MED_NAME_SIZE+1]; + med_int numfam; + char str1[MED_COMMENT_SIZE+1]; + char str2[MED_LNAME_SIZE+1]; + med_err ret = 0; + + for (i=0;inommaa,i+1); + if (ngro < 0){ + std::cerr<<"Problem reading number of groups of family\n"; + continue; + } + + //atributs obsolete MED3 + //allocation memoire par exces + gro = (char*) malloc(MED_LNAME_SIZE*(ngro+1)); + + ret = MEDfamilyInfo(fid,mymailw->nommaa,i+1,nomfam,&numfam,gro); + if (ret < 0){ + std::cerr<<"Problem reading informations of family\n"; + continue; + } + + if (mymailw->verbose>8) { + std::cout<<"Family "<deletegroups)>0) { + //std::cout<<"idelete++ "<0) { //only delete family whith all delete groups + //std::cout<<"famdelete++ "<deletegroups)==0){ + if (sgro.contains(qgroup)>0) { + sgro="Skin_"+sgro; //pas sur que ce soit pertinent + } + if (mymailw->verbose>8) std::cout<<"families.add("<families.add(sfam,sgro); + } + else { + //sgro="Skin_"+sgro; //pas sur que ce soit pertinent + //std::cout<<"--deletegroups matches \""<verbose>3) std::cout<<"--deletegroups matches \""<< + sgro.toLatin1().constData()<< + "\" in family "<deletegroups)==0){ + //sgro="Skin_"+sgro; //pas sur que ce soit pertinent + std::cout<<"families.add("<families.add(sfam,sgro); + } + else { + std::cout<<"--deletegroups matches \""<verbose>3){ + std::cout<<"\nFamiliesAndGroupsOf "<families.write(); +} + /* Allocations memoires */ + /* table des coordonnees profil : (space dimension * nombre de noeuds ) */ + med_float *coo=new med_float[nnoe*sdim]; + /* table des numeros de familles des noeuds profil : (nombre de noeuds) */ + med_int *famnodesskin=new med_int[nnoe]; + //med_int *pfltab=new med_int[1]; //inutilise car on lit tout + //lecture des noeuds : coordonnees + ret=MEDmeshNodeCoordinateRd(fid,mymailw->nommaa,MED_NO_DT,MED_NO_IT,MED_FULL_INTERLACE,coo); + //mdim,coo,mode_coo,MED_ALL,pfltab,0,&rep,mymailw->nomcoo,mymailw->unicoo); + if (ret < 0){ + std::cerr<<"Problem reading nodes\n"; + ret = MEDfileClose(fid); + //return false; + } + ret=MEDmeshEntityFamilyNumberRd(fid,mymailw->nommaa,MED_NO_DT,MED_NO_IT,MED_NODE,MED_NONE,famnodesskin); + //famnodesskin,nnoe,MED_NOEUD,(med_geometrie_element) 0); + if (ret < 0){ + std::cerr<<"Problem reading families of nodes\n"; + ret = MEDfileClose(fid); + return false; + } + if (mymailw->verbose>9) { + std::cout<<"\nVertices: no x y z family\n"; + for (i=0;inommaa,MED_NO_DT,MED_NO_IT, + MED_CELL,MED_SEG2,MED_NODAL,MED_FULL_INTERLACE,conn2); + //mdim,conn2,mode_coo,pfltab,0,MED_MAILLE,MED_SEG2,MED_NOD); + if (ret < 0){ + std::cerr<<"Problem reading MED_SEG2\n"; + ret = MEDfileClose(fid); + //return false; + } + med_int *famseg2skin=new med_int[nbseg2]; + ret=MEDmeshEntityFamilyNumberRd(fid,mymailw->nommaa,MED_NO_DT,MED_NO_IT,MED_CELL,MED_SEG2,famseg2skin); + //MEDfamLire(fid,mymailw->nommaa,famseg2skin,nbseg2,MED_MAILLE,MED_SEG2); + if (ret < 0){ + std::cerr<<"Problem reading families of MED_SEG2\n"; + ret = MEDfileClose(fid); + return false; + } + if (mymailw->verbose>9) { + std::cout<<"\nConnectivity MED_SEG2: no node1 node2 family\n"; + for (i=0;inommaa,MED_NO_DT,MED_NO_IT, + MED_CELL,MED_TRIA3,MED_NODAL,MED_FULL_INTERLACE,conn3); + //MEDconnLire(fid,mymailw->nommaa,mdim,conn3,mode_coo,pfltab,0,MED_MAILLE,MED_TRIA3,MED_NOD); + if (ret < 0){ + std::cerr<<"Problem reading MED_TRIA3\n"; + ret = MEDfileClose(fid); + //return false; + } + med_int *famtria3skin=new med_int[nbtria3]; + ret=MEDmeshEntityFamilyNumberRd(fid,mymailw->nommaa,MED_NO_DT,MED_NO_IT,MED_CELL,MED_TRIA3,famtria3skin); + //MEDfamLire(fid,mymailw->nommaa,famtria3skin,nbtria3,MED_MAILLE,MED_TRIA3); + if (ret < 0){ + std::cerr<<"Problem reading families of MED_TRIA3\n"; + ret = MEDfileClose(fid); + return false; + } + if (mymailw->verbose>9) { + std::cout<<"\nConnectivity MED_TRIA3: no node1 node2 node3 family\n"; + for (i=0;i0) { + //std::cout<<"!!!!!!!!nodes "<insert_key(tmp,montab); + + montab=new CVWtab(nnoe,famnodesskin); + tmp="SKIN_VERTICES_FAMILIES"; + ok=mymailw->insert_key(tmp,montab); + + montab=new CVWtab(nbseg2*2,conn2); + tmp="SKIN_SEG2_CONNECTIVITIES"; + ok=mymailw->insert_key(tmp,montab); + + montab=new CVWtab(nbtria3,famseg2skin); + tmp="SKIN_SEG2_FAMILIES"; + ok=mymailw->insert_key(tmp,montab); + + montab=new CVWtab(nbtria3*3,conn3); + tmp="SKIN_TRIA3_CONNECTIVITIES"; + ok=mymailw->insert_key(tmp,montab); + + montab=new CVWtab(nbtria3,famtria3skin); + tmp="SKIN_TRIA3_FAMILIES"; + ok=mymailw->insert_key(tmp,montab); + + //if (mymailw->verbose>6) ok=mymailw->list_keys_mesh_wrap(); + + ret = MEDfileClose(fid); + if (ret < 0){ + std::cerr<<"Problem closing "<6)\n"<< + " --test : more tests about joints, before generation of output files\n"<< + " --menu : a GUI menu for option number\n"<< + " --launchtetra : also launch tetra-hpc on files casename.mesh and option number\n"<< + " --merge_subdomains : merge the subdomains into one mesh and write the output .mesh(b) file\n"<< + " --tag_subdomains : use the parallel subdomain index as tag into the merged output mesh\n"<< + " to identify the parallel subdomains (used in combination with the merge_subdomains option)\n"<< + " --output_interfaces : write the parallel subdomains interface triangles into the merged output mesh\n"<< + " (used in combination with the merge_subdomains option)\n"<< + " --discard_subdomains : discard the parallel subdomains informations output (mesh, global numbering and interfaces)\n"<< + " --background : force background mode from launch tetra-hpc and generation of final MED files (big meshes)\n"<< + " --deletegroups : regular expression (see QRegExp) which matches unwanted groups in final MED files\n"<< + " (try --deletegroups=\"(\\bJOINT)\"\n"<< + " (try --deletegroups=\"(\\bAll_Nodes|\\bAll_Faces)\"\n"<< + " (try --deletegroups=\"((\\bAll_|\\bNew_)(N|F|T))\"\n"; + std::cout<<"example:\n tetrahpcl2med --casename=/tmp/GHS3DPRL --number=2 --medname=DOMAIN "<< + "--limitswap=1000 --verbose=0 --test=yes --menu=no --launchtetra=no\n\n"; + return 1; //no output files + } + + if (!ccasename){ + std::cerr<<"--casename: a path/name is expected\n\n"; + return 1; + } + casename=ccasename; + if (!cnumber){ + std::cerr<<"--number: an integer is expected\n\n"; + return 1; + } + tmp=cnumber; + nbfiles=tmp.toLong(&ok,10); + if (!ok){ + std::cerr<<"--number: an integer is expected\n\n"; + return 1; + } + if (nbfiles<=0){ + std::cerr<<"--number: a positive integer is expected\n\n"; + return 1; + } + if (nbfiles>2048){ //delirium in 2014 + std::cerr<<"--number: a positive integer <= 2048 is expected\n\n"; + return 1; + } + if (!cmedname) cmedname=ccasename; + casenamemed=cmedname; + limit_swap_defaut=1000; //1000Mo + limit_swap=limit_swap_defaut; + if (climitswap){ + tmp=climitswap; + limit_swap=tmp.toLong(&ok,10); + if (!ok){ + std::cerr<<"--limitswap: an integer is expected. try 1000\n\n"; + return 1; + } + if (limit_swap<1 || limit_swap>32000){ + std::cerr<<"--limitswap: [1->32000] expected. try 1000\n\n"; + return 1; + } + } + //default 1GOctet/8(for float) + nbelem_limit_swap=limit_swap*1000000; //100% + CVWtab::memorymax=nbelem_limit_swap; + + verbose=1; //default + if (cverbose){ + tmp=cverbose; + verbose=tmp.toLong(&ok,10); + if (!ok){ + std::cerr<<"--verbose: an integer is expected\n\n"; + return 1; + } + if (verbose<0){ + std::cerr<<"--verbose: a positive integer is expected\n\n"; + return 1; + } + } + + test="no"; //default + if (ctest){ + tmp=ctest; + if (tmp=="yes") test="yes"; + } + + menu="no"; //default + if (cmenu){ + tmp=cmenu; + if (tmp=="yes") menu="yes"; + } + + launchtetra="no"; //default + if (claunchtetra){ + tmp=claunchtetra; + if (tmp=="yes") launchtetra="yes"; + } + + ToMergeSubdomains="no"; //default + if (cToMergeSubdomains){ + tmp=cToMergeSubdomains; + if (tmp=="yes") ToMergeSubdomains="yes"; + } + + ToTagSubdomains="no"; //default + if (cToTagSubdomains){ + tmp=cToTagSubdomains; + if (tmp=="yes") ToTagSubdomains="yes"; + } + + ToOutputInterfaces="no"; //default + if (cToOutputInterfaces){ + tmp=cToOutputInterfaces; + if (tmp=="yes") ToOutputInterfaces="yes"; + } + + ToDiscardSubdomains="no"; //default + if (cToDiscardSubdomains){ + tmp=cToDiscardSubdomains; + if (tmp=="yes") ToDiscardSubdomains="yes"; + } + + background="no"; //default + if (cbackground){ + tmp=cbackground; + if (tmp=="yes") background="yes"; + } + + + // We must always have an application + if (menu=="yes") { + QApplication a(argc,argv); + dlg_ghs3dmain *m = new dlg_ghs3dmain(); + m->setWindowTitle("tetrahpc2med 3.0"); + m->show(); + a.exec(); + if ( m->result() == QDialog::Accepted ) { + std::cout<<"parameters "<KeepFiles()<<" "<NbPart()<NbPart(); + } + else { + return 1; + } + delete m; + } + + int n=casenamemed.count('/'); + if (n>0) + path=casenamemed.section('/',-n-1,-2)+"/"; + else + path="./"; + casenamemed=casenamemed.section('/',-1); + if (casenamemed.length()>20){ + std::cerr<<"--medname truncated (no more 20 characters)"<0) + pathini=casename.section('/',-n-1,-2)+"/"; + else + pathini="./"; + casename=casename.section('/',-1); + if (casename.length()>20){ + std::cerr<<"--casename truncated (no more 20 characters)"<0) + std::cout<<"tetrahpc2med "< 0) { + //Process father + exit(0); //temporary ok for plugin + } + //process children + //On rend le fils independant de tout terminal + //from here everything in background: tetrahpc AND generation of final MED files + setsid(); + system("sleep 10"); //for debug + } +#else + printf("background mode is not supported on win32 platform !\n"); +#endif + + //"tetrahpc -f exemple1 -n 4" + if (launchtetra=="yes"){ + //tetra_hpc.exe --help + //mpirun -n 3 mg-tetra_hpc.exe --in GHS3DPRL.mesh --out TOTO.mesh + + //direct mpirun cause problem: invalid + //cmd="mpirun -n "+cmd.sprintf("%d",nbfiles)+" mg-tetra_hpc.exe --in "+ + + //call tetra_hpc.bash is script which assumes mpirun after compilation openmpi etc... + cmd="mg-tetra_hpc.bash -n "+cmd.sprintf("%d",nbfiles)+" --in "+ + pathini+casename+".mesh --out "+ + pathini+casename+".mesh"+ + " --merge_subdomains "+ToMergeSubdomains+ + " --tag_subdomains "+ToTagSubdomains+ + " --output_interfaces "+ToOutputInterfaces+ + " --discard_subdomains "+ToDiscardSubdomains+ + " > "+path+"tetrahpc.log"; + std::cout<<"\nlaunchtetra command: background="<nbfiles=0; + mymailw->nbfilestot=nbfiles; + //for huge cases big array swap in huge binary files + mymailw->nbelem_limit_swap=nbelem_limit_swap; + mymailw->verbose=verbose; + mymailw->casename=casename; + mymailw->medname=casenamemed; + mymailw->path=path; + mymailw->pathini=pathini; + mymailw->deletegroups=QRegExp(deletegroups,Qt::CaseSensitive,QRegExp::RegExp); + ghs3dprl_msg_parser handler; + //constructor later maybe + //handler.verbose=true; + handler.mailw=mymailw; + mymailw->families.no=1; + //std::cout<<"coucou1 "<families.no<families.add(casename,casenamemed); + format=format.sprintf("%d",nbfiles); + int nbf=format.length(); + format=format.sprintf(".%%0%dd.%%0%dd",nbf,nbf); + format_tetra=".%05d"; + if (verbose>10)std::cout<<"format "<10)std::cout<<"format_tetra "<format=format; + mymailw->format_tetra=format_tetra; + mymailw->for_tetrahpc=true; //to know what files to read: .noboite or .mesh + + //something like "/home/wambeke/tmp/GHS3DPRL_skin.med" + fileskinmed=pathini+casename+"_skin.med"; + //fileskinmed="/home/wambeke/tmp/GHS3DPRL_skin.med"; + /*for debug + { + char ctmp[fileskinmed.length()+1] ; strcpy(ctmp,fileskinmed); + int res=dumpMED(&ctmp[0],1); + }*/ + int ret = access(fileskinmed.toLatin1().constData(),F_OK); //on regarde si le fichier existe + if (ret >= 0) { + ok=ReadFileMED(fileskinmed,mymailw); } + else { + if (verbose>0)std::cout<<"Initial skin file <"< does not exist\n"; } + + +//if test quickly read all files before (or only small files) + if (test=="yes"){ + if (verbose>0) std::cout<<"\nReading output files of tetrahpc as input files of tetrahpc2med...\n"; + //only read beginning of files .xxxxx.mesh + //supposed big files big arrays so only see first lines + mymailw->nbfiles=0; + for (int i=1; i<=nbfiles; i++){ + mymailw->nofile=i; + tmp=pathini+casename+tmp.sprintf(format_tetra.toLatin1().constData(),i)+".mesh"; + if (verbose>0) std::cout<<"FileName="<TestExistingFileMESHnew(tmp); + } + if (verbose>0) + std::cout<<"NumberOfFilesMESHTested="<nbfiles<<": ok\n\n"; + if (mymailw->nbfiles != nbfiles){ + std::cerr<<"NumberOfFiles != NumberOfFilesTested is unexpected\n\n"; + return 1; + } + } //end if test + + ok=mymailw->Write_MEDfiles_v2(true); //deletekeys=true + + nb=mymailw->remove_all_keys_mesh_wrap(); + if (verbose>3)std::cout<<"***remove_all_key_mesh_wrap*** "<0)std::cout<