From 73275ade5a04ca3a7a7a98d56f979746cab2a82c Mon Sep 17 00:00:00 2001 From: eap Date: Tue, 14 Jun 2016 14:35:16 +0300 Subject: [PATCH] 23288: [CEA 1626] Meshgems v2.3 --- bin/CMakeLists.txt | 7 +- bin/mg-tetra_hpc.bash | 96 ++- bin/mg-tetra_hpc.py | 320 +++++++ .../GHS3DPRLPLUGIN/input/ghs3dprl_hypo.doc | 13 +- idl/GHS3DPRLPlugin_Algorithm.idl | 26 +- src/GHS3DPRLPlugin/GHS3DPRLPluginBuilder.py | 42 +- .../GHS3DPRLPlugin_GHS3DPRL.cxx | 636 ++++---------- .../GHS3DPRLPlugin_GHS3DPRL.hxx | 9 +- .../GHS3DPRLPlugin_Hypothesis.cxx | 101 ++- .../GHS3DPRLPlugin_Hypothesis.hxx | 44 +- .../GHS3DPRLPlugin_Hypothesis_i.cxx | 91 +- .../GHS3DPRLPlugin_Hypothesis_i.hxx | 19 +- .../GHS3DPRLPluginGUI_HypothesisCreator.cxx | 95 +- src/gui/GHS3DPRLPluginGUI_HypothesisCreator.h | 31 +- src/gui/GHS3DPRLPlugin_msg_en.ts | 28 +- src/gui/GHS3DPRLPlugin_msg_fr.ts | 28 +- src/gui/GHS3DPRLPlugin_msg_ja.ts | 28 +- src/tepal2med/ghs3dprl_mesh_wrap.cxx | 437 +++++++--- src/tepal2med/ghs3dprl_mesh_wrap.h | 15 +- src/tepal2med/tepal2med.cxx | 2 +- src/tepal2med/tetrahpc2med.cxx | 299 ++++--- src/tools/CMakeLists.txt | 4 +- src/tools/testMesh.py | 816 ++++++++++++++++++ src/tools/testMeshTest.py | 76 ++ 24 files changed, 2243 insertions(+), 1020 deletions(-) create mode 100644 bin/mg-tetra_hpc.py create mode 100644 src/tools/testMesh.py create mode 100644 src/tools/testMeshTest.py diff --git a/bin/CMakeLists.txt b/bin/CMakeLists.txt index 9519422..7908501 100755 --- a/bin/CMakeLists.txt +++ b/bin/CMakeLists.txt @@ -22,10 +22,11 @@ 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.bash + mg-tetra_hpc.py mg-tetra_hpc.exe_Linux_64_avril2014 - meshgems_mpi.c - meshgems_mpi.h + #meshgems_mpi.c + #meshgems_mpi.h ) # --- rules --- diff --git a/bin/mg-tetra_hpc.bash b/bin/mg-tetra_hpc.bash index 786a422..d48e9de 100755 --- a/bin/mg-tetra_hpc.bash +++ b/bin/mg-tetra_hpc.bash @@ -1,59 +1,67 @@ #!/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... ) +#could assume overriding set licence file of user/other new version distene products #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 +#$0 have to be ignored: name of script +echo "mg-tetra_hpc.bash initial parameters are:\n "$@"\n" + +#example mg-tetra_hpc_mpi v2.1.11 +#mpirun -n 6 mg-tetra_hpc_mpi.exe --gradation 1.05 --max_size 0 --min_size 0 --verbose 3 --in /tmp/GHS3DPRL.mesh --out /tmp/GHS3DPRL_out.mesh -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 +#this is for example, sometimes DISTENE_LICENSE_FILE have to be overriden #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" +# then +# export DISTENE_LICENSE_FILE="Use global envvar: DLIM8VAR" +# export DLIM8VAR="dlim8 1:1:29030@10.27.51.1/002590c96d98::8fbdc02cde090ca0369ad028e839065b97709e3c33e640eb6a3c2c7e40fe3985" +# else +# export DISTENE_LICENSE_FILE="Use global envvar: DLIM8VAR" +# export DLIM8VAR="dlim8 1:1:29030@132.166.151.49/84c419b8::87af196ab2a936ab31363624539bff8096fbe1f3c83028c8f6b399b0a904ef85" +#fi + + +#this is for example, sometimes need to compile stubs/libmeshgems_mpi.so for mg-tetra_hpc.exe, depends of openmpi system or not#CURRENTDIR=`pwd` +CURRENTDIR=`pwd` +COMPILDIR=$MESHGEMSHOME/stubs #/export/home/prerequisites_SALOME_780/MeshGems-2.1-11/FROM_nothing/stubs +MPI_EXE=`which mg-tetra_hpc_mpi.exe` +TARGETDIR=$MESHGEMSHOME/lib/Linux_64 #/export/home/prerequisites_SALOME_780/MeshGems-2.1-11/FROM_nothing/lib/Linux_64 +echo "CURRENTDIR=" $CURRENTDIR +#rm $TARGETDIR/libmeshgems_mpi.so #compile every times +#if [ ! -f $TARGETDIR/libmeshgems_mpi.so ] +#then + echo "Compile libmeshgems_mpi.so with current openmpi:" + echo `which mpicc` + echo "COMPILDIR=" $COMPILDIR + echo "TARGETDIR=" $TARGETDIR + cd $COMPILDIR + mpicc meshgems_mpi.c -DMESHGEMS_LINUX_BUILD -I../include -shared -fPIC -o $TARGETDIR/libmeshgems_mpi.so + find $MESHGEMSHOME -name "libmeshgems_mpi.so" + cd $CURRENTDIR #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 +#example version mpi a mano +#cd /export/home/prerequisites_SALOME_780/MeshGems-2.1-11/FROM_nothing/stubs +#mpicc meshgems_mpi.c -DMESHGEMS_LINUX_BUILD -I../include -shared -fPIC -o libmeshgems_mpi.so +#cp -f libmeshgems_mpi.so /export/home/prerequisites_SALOME_780/MeshGems-2.1-11/FROM_nothing/lib/Linux_64/. echo "mg-tetra_hpc.bash assume licence file set:" -env | grep DLIM +echo DLIM8VAR=$DLIM8VAR +echo DISTENE_LICENSE_FILE=$DISTENE_LICENSE_FILE + +#version multithread: why not use plugin/hypothesis mg-tetra.exe instead? +#which mg-tetra_hpc.exe +#echo mg-tetra_hpc.exe --max_number_of_threads $2 --number_of_subdomains $2 --in ... --out /tmp/GHS3DPRL_out.mesh --verbose 3 +#for multithread only one /tmp/GHS3DPRL_out.mesh created... +#TODO create one med file from /tmp/GHS3DPRL_out.mesh if utile later + + +which mg-tetra_hpc_mpi.exe +#echo mpirun -n $2 mg-tetra_hpc_mpi.exe ${@:3:30} +echo mpirun -n $2 mg-tetra_hpc_mpi.exe --in /tmp/GHS3DPRL.mesh --out /tmp/GHS3DPRL_out.mesh +mpirun -n $2 mg-tetra_hpc_mpi.exe --in /tmp/GHS3DPRL.mesh --out /tmp/GHS3DPRL_out.mesh -#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} -mpirun -n $2 $MESHGEMS_ROOT_DIR/bin/run_mg-tetra_hpc.sh ${@:3:30} +#typically write files /tmp/GHS3DPRL_out.00000?.mesh & /tmp/GHS3DPRL_out.00000?.global diff --git a/bin/mg-tetra_hpc.py b/bin/mg-tetra_hpc.py new file mode 100644 index 0000000..ca6f4ed --- /dev/null +++ b/bin/mg-tetra_hpc.py @@ -0,0 +1,320 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# %% LICENSE_SALOME_CEA_BEGIN +# Copyright (C) 2008-2016 CEA/DEN +# +# 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, or (at your option) any later version. +# +# 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 +# %% LICENSE_END + + +""" +run mg_tetra_hpc.exe or mg_tetra_hpc_mpi.exe + +example linux usage: +- simple run: + ./mg-tetra_hpc.py --help + ./mg-tetra_hpc.py -n 3 --in /tmp/GHS3DPRL.mesh --out /tmp/GHS3DPRL_out.mesh --gradation 1.05 --min_size 0.001 --max_size 1.1 --multithread no > /tmp/tetrahpc.log +""" + +import os +import sys +import time +import platform +import argparse as AP +import pprint as PP #pretty print +import subprocess as SP #Popen +import multiprocessing as MP #cpu_count + +verbose = False + +OK = "ok" +KO = "KO" +OKSYS = 0 #for linux +KOSYS = 1 #for linux + +NB_PROCS = MP.cpu_count() #current cpu number of proc +NAME_OS = platform.system() #'Linux' or 'Windows' + + +########################################################################## +# utilities +########################################################################## + +def okToSys(aResult, verbose=False): + """to get windows or linux result of script""" + + def extendList(alist): + """utility extend list of lists of string results with ok or KO""" + #bad: list(itertools.chain.from_list(alist)) iterate on str + res = [] + if type(alist) != list: + return [alist] + else: + for i in alist: + if type(i) == str: + res.append(i) + else: + res.extend(extendList(i)) + return res + + resList = extendList(aResult) + if resList == []: + if verbose: print("WARNING: result no clear: []") + return KOSYS + + rr = OK + for ri in resList: + if ri[0:2] != OK: + if verbose: print ri + rr = KO + + if verbose: print("INFO: result: %s" % rr) + if rr == OK: + return OKSYS + else: + return KOSYS + +########################################################################## +def getDirAndName(datafile): + path, namefile = os.path.split(os.path.realpath(datafile)) + rootpath = os.getcwd() + return (path, rootpath, namefile) + + +########################################################################## +class ArgRange(object): + """ + ArgumentParser utility for range float or in in arguments + """ + def __init__(self, start, end): + self.start = start + self.end = end + + def __eq__(self, other): + return self.start <= other <= self.end + + def __repr__(self): + return "[%s,%s]" % (self.start, self.end) + + +########################################################################## +def exec_command(cmd, verbose=False): + """Exec ONE command with popen""" + + time.sleep(3) #wait for (MPI) flush files + if verbose: print("launch process:\n %s" % cmd) + try: + pipe = SP.Popen(cmd, shell=True, stdout=SP.PIPE, stderr=SP.PIPE ) + except Exception as e: + result = KO + " ERROR: we have a problem popen on: %s" % PP.pformat(cmd) + return result + + (out, error) = pipe.communicate() + pipe.wait() + + print(out) + print(error) + + result = OK + " INFO: seems final ok for: %s" % PP.pformat(cmd) + time.sleep(3) #wait for (MPI) flush files + return result + + + +########################################################################## +def force_DISTENE_LICENSE_FILE(): + """ + conditionaly overriding/set environ variable DISTENE_LICENSE_FILE, + from/if existing FORCE_DISTENE_LICENSE_FILE environ variable + (for test new version MeshGems etc...) + """ + """ + #example: + DISTENE_LICENSE_FILE=Use global envvar: DLIM8VAR + DLIM8VAR=dlim8 1:1:29030@132.166.151.49/84c419b8::87af196ab2a936ab31363624539bff8096fbe1f3c83028c8f6b399b0a904ef85 + overriden by + FORCE_DISTENE_LICENSE_FILE=/export/home/wambeke/essai_meshgems2.3/dlim8.key + """ + force = os.getenv("FORCE_DISTENE_LICENSE_FILE") + if force != None: + os.environ["DISTENE_LICENSE_FILE"] = force + os.environ["DLIM8VAR"] = "NOTHING" + """ + #export PATH=/export/home/prerequisites_SALOME_780_LAURENT/openmpi-1.8.4/FROM_nothing/bin:$PATH + #do not work prefer set before salome launch + OPENMPI_INSTALL_DIR = "/export/home/prerequisites_SALOME_780_LAURENT/openmpi-1.8.4/FROM_nothing/bin" + sys.path.insert(0, OPENMPI_INSTALL_DIR) + #INSTALL_DIR = /export/home/prerequisites_SALOME_780_LAURENT/openmpi-1.8.4/FROM_nothing + for i in sys.path[0:10]: print "PATH",i + """ + + + + +########################################################################## +def launchMultithread(args): + if verbose: print("INFO: launchMultithread for %s" % NAME_OS) + + if NAME_OS == 'Linux': + #--out is ONE file: basename_tetra_hpc.mesh + outputMulti = os.path.splitext(args.inputFile)[0] + "_tetra_hpc.mesh" #only one file if Multithread + outputs = os.path.splitext(args.outputFiles)[0] + outputMultiAsMpi = os.path.splitext(args.outputFiles)[0] + ".000001.mesh" #create one output file named as only one from mpi + cmd = "mg-tetra_hpc.exe --max_number_of_threads %i --in %s --gradation %s --max_size %s --min_size %s; cp %s %s; ls -alt %s*; " % \ + (args.number, args.inputFile, args.gradation, args.max_size, args.min_size, outputMulti, outputMultiAsMpi, outputs) + else: + return KO + " ERROR: unknown operating system: %s" % NAME_OS + + result = exec_command(cmd, verbose=True) + return result + + + +########################################################################## +def launchMpi(args): + if verbose: print("INFO: launchMpi for %s" % NAME_OS) + + if NAME_OS == 'Linux': + cmd = "" + + """ compile libmeshgems_mpi.so: no needs + COMPILDIR=os.getenv("MESHGEMSHOME") + "/stubs" + TARGETDIR=os.getenv("MESHGEMSHOME") + "/lib/Linux_64" + cmd = "which mg-tetra_hpc_mpi.exe; which mpicc; rm /tmp/GHS3DPRL_out*; " + cmd += "cd %s; mpicc meshgems_mpi.c -DMESHGEMS_LINUX_BUILD -I../include -shared -fPIC -o %s/libmeshgems_mpi.so; " % (COMPILDIR, TARGETDIR) + """ + + outputs = os.path.splitext(args.outputFiles)[0] + cmd += "mpirun -n %i mg-tetra_hpc_mpi.exe --in %s --out %s --gradation %s --max_size %s --min_size %s; ls -alt %s*; " % \ + (args.number, args.inputFile, args.outputFiles, args.gradation, args.max_size, args.min_size, outputs) + else: + return KO + " ERROR: unknown operating system: %s" % NAME_OS + + result = exec_command(cmd, verbose=True) + return result + + +########################################################################## +# main +########################################################################## + +if __name__ == '__main__': + parser = AP.ArgumentParser(description='launch tetra_hpc.exe or tetra_hpc_mpi.exe mesh computation', argument_default=None) + #./mg-tetra_hpc.py -n 3 --in=/tmp/GHS3DPRL.mesh --out=/tmp/GHS3DPRL_out.mesh --gradation=1.05 --min_size=0.001 --max_size=1.1 --multithread no > /tmp/tetrahpc.log + + parser.add_argument( + '-v', '--verbose', + help='set verbose, for debug', + action='store_true', + ) + parser.add_argument( + '-n', '--number', + help='if multithread: number of threads, else distributed: number of processes MPI', + choices=[ArgRange(1, 999999)], + type=int, + metavar='integer >= 0', + default=1, + ) + parser.add_argument( + '-m', '--multithread', + help='launch tetra_hpc multithread instead tetra_hpc distributed (MPI)', + choices=["no", "yes"], + default='no', + ) + parser.add_argument( + '-g', '--gradation', + help='size ratio adjacent cell, default 0 is 1.05', + type=float, + choices=[ArgRange(0.0, 3.0)], + metavar='float in [0.,3]', + default='0' + ) + parser.add_argument( + '-si', '--min_size', + help='min size cell, default 0 is no constraint', + type=float, + choices=[ArgRange(0.0, 9e99)], + metavar='float >= 0', + default='0' + ) + parser.add_argument( + '-sa', '--max_size', + help='max size cell, default 0 is no constraint', + type=float, + choices=[ArgRange(0.0, 9e99)], + metavar='float >= 0', + default='0' + ) + parser.add_argument( + '-i', '--inputFile', + help='input file name', + #nargs='?', + metavar='.../inputFile.mesh' + ) + parser.add_argument( + '-o', '--outputFiles', + help='output basename file(s) name', + #nargs='?', + metavar='.../outputFile.mesh' + ) + """ + parser.add_argument( + '-x', '--xoneargument', + nargs='?', + metavar='0|1', + choices=['0', '1'], + help='one argument, for example', + default='0' + ) + """ + + + """ + args is Namespace, may use it as global to store + parameters, data, used arrays and results and other... + """ + args = parser.parse_args() + + verbose = args.verbose + if verbose: print("INFO: args:\n%s" % PP.pformat(args.__dict__)) + + if len(sys.argv) == 1: #no args as --help + parser.print_help() + sys.exit(KOSYS) + + if args.inputFile == None: + print("\nERROR: Nothing to do: no input files\n\n%s\n" % PP.pformat(args)) + parser.print_help() + sys.exit(KOSYS) + + if args.outputFiles == None: + tmp, _ = os.path.splitext(args.inputFile) + args.outputFiles = tmp + "_out.mesh" + print("\nWARNING: Default ouput files: %s" % args.outputFiles) + + force_DISTENE_LICENSE_FILE() + + print("INFO: mg-tetra_hpc.py assume licence file set:\n DLIM8VAR=%s\n DISTENE_LICENSE_FILE=%s" % \ + (os.getenv("DLIM8VAR"), os.getenv("DISTENE_LICENSE_FILE"))) + + if args.multithread == "yes": + result = launchMultithread(args) + else: + result = launchMpi(args) + sys.exit(okToSys(result, verbose=True)) + diff --git a/doc/salome/gui/GHS3DPRLPLUGIN/input/ghs3dprl_hypo.doc b/doc/salome/gui/GHS3DPRLPLUGIN/input/ghs3dprl_hypo.doc index 867f796..1d14049 100644 --- a/doc/salome/gui/GHS3DPRLPLUGIN/input/ghs3dprl_hypo.doc +++ b/doc/salome/gui/GHS3DPRLPLUGIN/input/ghs3dprl_hypo.doc @@ -50,6 +50,10 @@ can even exit Salome. Pay attention that in this case MG-Tetra-hpc algorithm wor independently of "killSalome.py", and sometimes on another host.
  • +Tetra_hpc Multithread - if this box is checked, MG-Tetra-hpc execution +is with mg_tetra_hpc.exe (multithread version), else mg_tetra_hpc_mpi.exe (MPI distributed version). +
  • +
  • Merge subdomains - if this box is checked, merge the sub-domains into one mesh and write the output .mesh(b).
  • @@ -361,11 +365,12 @@ algo3d = m.Tetrahedron(smeshBuilder.MG_Tetra_Parallel) algo3d.SetMEDName(results) algo3d.SetNbPart(4) algo3d.SetBackground(False) +algo3d.SetMultithread(False) algo3d.SetKeepFiles(False) -algo3d.SetToMergeSubdomains(False) -algo3d.SetToTagSubdomains(False) -algo3d.SetToOutputInterfaces(False) -algo3d.SetToDiscardSubdomains(False) +algo3d.SetGradation(1.05) +algo3d.SetMinSize(0) +algo3d.SetMaxSize(0) + # Launch meshers # -------------- diff --git a/idl/GHS3DPRLPlugin_Algorithm.idl b/idl/GHS3DPRLPlugin_Algorithm.idl index 5110f86..adefb3a 100755 --- a/idl/GHS3DPRLPlugin_Algorithm.idl +++ b/idl/GHS3DPRLPlugin_Algorithm.idl @@ -56,20 +56,24 @@ module GHS3DPRLPlugin void SetBackground(in boolean value); boolean GetBackground(); + void SetMultithread(in boolean value); + boolean GetMultithread(); + //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(); + //void SetToMergeSubdomains(in boolean value); + //boolean GetToMergeSubdomains(); + + void SetGradation(in float value); + float GetGradation(); + + void SetMinSize(in float value); + float GetMinSize(); + + void SetMaxSize(in float value); + float GetMaxSize(); + }; }; diff --git a/src/GHS3DPRLPlugin/GHS3DPRLPluginBuilder.py b/src/GHS3DPRLPlugin/GHS3DPRLPluginBuilder.py index da66572..b6747cc 100644 --- a/src/GHS3DPRLPlugin/GHS3DPRLPluginBuilder.py +++ b/src/GHS3DPRLPlugin/GHS3DPRLPluginBuilder.py @@ -103,40 +103,40 @@ class GHS3DPRL_Algorithm(Mesh_Algorithm): self.Parameters().SetNbPart(value) pass - ## When big mesh, start tepal in background + ## When big mesh, start tetra_hpc in background # @param value "background mode" flag value def SetBackground(self, value): self.Parameters().SetBackground(value) pass + ## use multithread version + # @param value "multithread mode" flag value + def SetMultithread(self, value): + self.Parameters().SetMultithread(value) + pass + ## 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) # 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) + ## Sets the neigbour cell gradation of the initial mesh + # @param value number of partition value + def SetGradation(self, value): + self.Parameters().SetGradation(value) pass - - ## To Output Interfaces. Default is to no. - # @param toMesh "OutputInterfaces" flag value - def SetToOutputInterfaces(self, toMesh): - self.Parameters().SetToOutputInterfaces(toMesh) + + ## Sets the cell min size of the initial mesh + # @param value number of partition value + def SetMinSize(self, value): + self.Parameters().SetMinSize(value) pass - - ## To Discard Subdomains. Default is to no. - # @param toMesh "DiscardSubdomains" flag value - def SetToDiscardSubdomains(self, toMesh): - self.Parameters().SetToDiscardSubdomains(toMesh) + + ## Sets the cell max size of the initial mesh + # @param value number of partition value + def SetMaxSize(self, value): + self.Parameters().SetMaxSize(value) pass pass # end of GHS3DPRL_Algorithm class diff --git a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_GHS3DPRL.cxx b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_GHS3DPRL.cxx index d08bc1f..1932836 100755 --- a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_GHS3DPRL.cxx +++ b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_GHS3DPRL.cxx @@ -59,14 +59,6 @@ using namespace std; -/* -#include -//#include -#include -//#include -#include -using namespace med_2_2;*/ - static void removeFile( const TCollection_AsciiString& fileName ) { try { @@ -132,142 +124,115 @@ bool GHS3DPRLPlugin_GHS3DPRL::CheckHypothesis } //======================================================================= -static bool writeGHS3DPRLFiles (const TCollection_AsciiString & GHS3DPRL_In, - SMESHDS_Mesh * theMesh, - map & theSmdsToGHS3DPRLIdMap, - map & theGHS3DPRLIdToNodeMap) -{ - bool Ok; - int ifam=0; - TCollection_AsciiString namefile(GHS3DPRL_In); - namefile+=".points"; - removeFile(namefile); - ofstream theFile; - theFile.open(namefile.ToCString(),ios::out); -#ifdef WIN32 - Ok = theFile.is_open(); -#else - Ok=theFile.rdbuf()->is_open(); -#endif - if (!Ok) - { - INFOS("Can't write into "<NbNodes(); - int nbFaces=theMesh->NbFaces(); //triangles or quadrangles - const char* space=" "; - //const int dummyint=1; //nrs,nsd,refnum=1 (for wrap) - - // Writing SMESH points into GHS3DPRL File.points - theFile<nodesIterator(); - //int ifam=100;//test famille - theFile.precision(15); theFile.setf(ios::scientific,ios::floatfield); - //cout<<"set precision 15 on float\n"; - while (itOnNode->more()) - { - node_2 = itOnNode->next(); - theSmdsToGHS3DPRLIdMap.insert(map ::value_type(node_2->GetID(),aSmdsNodeID)); - theGHS3DPRLIdToNodeMap.insert(map ::value_type(aSmdsNodeID,node_2)); - theFile<X()<Y()<Z()<is_open(); -#endif - if (!Ok) - { - INFOS("Can't write into "<::const_iterator itOnSmdsNode; - SMDS_ElemIteratorPtr itOnFaceNode; - SMDS_FaceIteratorPtr itOnSmdsFace = theMesh->facesIterator(); - long nbNoTriangles=0; - int ifaces=0; - //ifam=300; - while (itOnSmdsFace->more()) - { - aFace=itOnSmdsFace->next(); - itOnFaceNode=aFace->nodesIterator(); - const int nbNodes=aFace->NbNodes(); - if (nbNodes!=3) nbNoTriangles++; - ifaces++; - theFile<more()) - { - aSmdsNodeID=itOnFaceNode->next()->GetID(); - itOnSmdsNode=theSmdsToGHS3DPRLIdMap.find(aSmdsNodeID); - ASSERT(itOnSmdsNode!=theSmdsToGHS3DPRLIdMap.end()); - theFile< & theSmdsToGHS3DPRLIdMap, +// map & theGHS3DPRLIdToNodeMap) // { -// char *ptr; -// theValue = strtol( theLine, &ptr, 10 ); -// if ( ptr == theLine || -// // there must not be neither '.' nor ',' nor 'E' ... -// (*ptr != ' ' && *ptr != '\n' && *ptr != '\0')) -// return false; - -// DUMP( " " << theValue ); -// theLine = ptr; -// return true; +// bool Ok; +// int ifam=0; +// TCollection_AsciiString namefile(GHS3DPRL_In); +// namefile+=".points"; +// removeFile(namefile); +// ofstream theFile; +// theFile.open(namefile.ToCString(),ios::out); +// #ifdef WIN32 +// Ok = theFile.is_open(); +// #else +// Ok=theFile.rdbuf()->is_open(); +// #endif +// if (!Ok) +// { +// INFOS("Can't write into "<NbNodes(); +// int nbFaces=theMesh->NbFaces(); //triangles or quadrangles +// const char* space=" "; +// //const int dummyint=1; //nrs,nsd,refnum=1 (for wrap) + +// // Writing SMESH points into GHS3DPRL File.points +// theFile<nodesIterator(); +// //int ifam=100;//test famille +// theFile.precision(15); theFile.setf(ios::scientific,ios::floatfield); +// //cout<<"set precision 15 on float\n"; +// while (itOnNode->more()) +// { +// node_2 = itOnNode->next(); +// theSmdsToGHS3DPRLIdMap.insert(map ::value_type(node_2->GetID(),aSmdsNodeID)); +// theGHS3DPRLIdToNodeMap.insert(map ::value_type(aSmdsNodeID,node_2)); +// theFile<X()<Y()<Z()<is_open(); +// #endif +// if (!Ok) +// { +// INFOS("Can't write into "<::const_iterator itOnSmdsNode; +// SMDS_ElemIteratorPtr itOnFaceNode; +// SMDS_FaceIteratorPtr itOnSmdsFace = theMesh->facesIterator(); +// long nbNoTriangles=0; +// int ifaces=0; +// //ifam=300; +// while (itOnSmdsFace->more()) +// { +// aFace=itOnSmdsFace->next(); +// itOnFaceNode=aFace->nodesIterator(); +// const int nbNodes=aFace->NbNodes(); +// if (nbNodes!=3) nbNoTriangles++; +// ifaces++; +// theFile<more()) +// { +// aSmdsNodeID=itOnFaceNode->next()->GetID(); +// itOnSmdsNode=theSmdsToGHS3DPRLIdMap.find(aSmdsNodeID); +// ASSERT(itOnSmdsNode!=theSmdsToGHS3DPRLIdMap.end()); +// theFile< & theGHS3DPRLIdToNodeMap, -// const TCollection_AsciiString & GHS3DPRL_Out, -// int & nodeRefNumber) -// { -// // --------------------------------- -// // Read generated elements and nodes -// // --------------------------------- - -// cout << "Reading GHS3DPRL output file : " << GHS3DPRL_Out << endl; -// cout << endl; - -// char aBuffer[ GHS3DPRLPlugin_BUFLENGTH ]; -// char * aPtr; -// int aLineNb = 0; -// int shapeID = theMesh->ShapeToIndex( theShape ); - -// int line = 1, EndOfFile = 0, nbElem = 0, nField = 10, nbRef = 0, aGHS3DPRLNodeID = 0; -// const char * theField; - -// vector tabField = vector(nField); -// vector tabRef = vector(nField); - -// tabField[0] = "MeshVersionFormatted"; tabRef[0] = 0; -// tabField[1] = "Dimension"; tabRef[1] = 0; -// tabField[2] = "Vertices"; tabRef[2] = 3; -// tabField[3] = "Edges"; tabRef[3] = 2; -// tabField[4] = "Triangles"; tabRef[4] = 3; -// tabField[5] = "Quadrilaterals"; tabRef[5] = 4; -// tabField[6] = "Hexahedra"; tabRef[6] = 8; -// tabField[7] = "Corners"; tabRef[7] = 1; -// tabField[8] = "Ridges"; tabRef[0] = 1; -// tabField[9] = "End"; tabRef[0] = 0; - -// nodeRefNumber += theMesh->NbNodes(); - -// SMDS_NodeIteratorPtr itOnGHS3DPRLInputNode = theMesh->nodesIterator(); -// while ( itOnGHS3DPRLInputNode->more() ) -// theMesh->RemoveNode( itOnGHS3DPRLInputNode->next() ); - -// while ( EndOfFile == 0 ) { -// GHS3DPRLPlugin_ReadLine( aPtr, aBuffer, theFile, aLineNb ); -// for ( int iField = 0; iField < nField; iField++ ) { -// stringstream theMessage; -// theField = tabField[iField]; -// if ( strncmp(aPtr, theField, strlen(theField)) == 0 ) { -// if ( strcmp(theField, "End") == 0 ) { -// EndOfFile = 1; -// theMessage << "End of GHS3DPRL output file has been reached"; -// } -// else { -// GHS3DPRLPlugin_ReadLine( aPtr, aBuffer, theFile, aLineNb ); -// line++; -// getInt( nbElem, aPtr ); - -// if ( strcmp(theField, "MeshVersionFormatted") == 0 ) -// theMessage << "GHS3DPRL mesh descriptor : " << theField << " " << nbElem; -// else if ( strcmp(theField, "Dimension") == 0 ) -// theMessage << "GHS3DPRL mesh of " << nbElem << "D dimension"; -// else if ( strcmp(theField, "Vertices") == 0 || -// strcmp(theField, "Edges") == 0 || -// strcmp(theField, "Quadrilaterals") == 0 || -// strcmp(theField, "Hexahedra") == 0 ) { -// nbRef = tabRef[iField]; -// GHS3DPRLPlugin_ReadLine( aPtr, aBuffer, theFile, aLineNb ); // read blank line - -// if ( strcmp(theField, "Vertices") == 0 ) { -// int aGHS3DPRLID; -// vector coord = vector(nbRef); -// SMDS_MeshNode * aGHS3DPRLNode; - -// for ( int iElem = 0; iElem < nbElem; iElem++ ) { -// aGHS3DPRLID = iElem + 1 + nodeRefNumber; -// GHS3DPRLPlugin_ReadLine( aPtr, aBuffer, theFile, aLineNb ); // read file lines -// for ( int iCoord = 0; iCoord < 3; iCoord++ ) -// getDouble ( coord[ iCoord ], aPtr ); -// aGHS3DPRLNode = theMesh->AddNode(coord[0], coord[1], coord[2]); -// theMesh->SetNodeInVolume( aGHS3DPRLNode, shapeID ); -// theGHS3DPRLIdToNodeMap[ aGHS3DPRLID ] = aGHS3DPRLNode; -// } -// } -// else { -// vector node = vector(nbRef); -// SMDS_MeshElement* aGHS3DPRLElement; -// map ::iterator itOnGHS3DPRLNode; - -// for ( int iElem = 0; iElem < nbElem; iElem++ ) { -// GHS3DPRLPlugin_ReadLine( aPtr, aBuffer, theFile, aLineNb ); // read file lines -// for ( int iRef = 0; iRef < nbRef; iRef++ ) { -// getInt ( aGHS3DPRLNodeID, aPtr ); // read nbRef aGHS3DPRLNodeID -// aGHS3DPRLNodeID += nodeRefNumber; -// itOnGHS3DPRLNode = theGHS3DPRLIdToNodeMap.find( aGHS3DPRLNodeID ); -// node[ iRef ] = itOnGHS3DPRLNode->second; -// } - -// if ( strcmp(theField, "Edges") == 0 ) // create an element -// aGHS3DPRLElement = theMesh->AddEdge( node[0], node[1] ); -// else if ( strcmp(theField, "Quadrilaterals") == 0 ) -// aGHS3DPRLElement = theMesh->AddFace( node[0], node[1], node[2], node[3] ); -// else if ( strcmp(theField, "Hexahedra") == 0 ) -// aGHS3DPRLElement = theMesh->AddVolume( node[0], node[1], node[2], node[3], node[4], node[5], node[6], node[7] ); - -// theMesh->SetMeshElementOnShape( aGHS3DPRLElement, shapeID ); -// } -// } -// theMessage << nbElem << " " << theField << " created"; -// } -// } -// if ( theMessage.str().size() != 0 ) { -// cout << theMessage.str() << endl; -// break; -// } -// } -// } -// } -// cout << endl; -// return true; -// } //============================================================================= // Pass parameters to GHS3DPRL @@ -407,10 +251,11 @@ void GHS3DPRLPlugin_GHS3DPRL::SetParameters(const GHS3DPRLPlugin_Hypothesis* hyp _NbPart = hyp->GetNbPart(); _KeepFiles = hyp->GetKeepFiles(); _Background = hyp->GetBackground(); - _ToMergeSubdomains = hyp->GetToMergeSubdomains(); - _ToTagSubdomains = hyp->GetToTagSubdomains(); - _ToOutputInterfaces = hyp->GetToOutputInterfaces(); - _ToDiscardSubdomains = hyp->GetToDiscardSubdomains(); + _Multithread = hyp->GetMultithread(); + //_ToMergeSubdomains = hyp->GetToMergeSubdomains(); + _Gradation = hyp->GetGradation(); + _MinSize = hyp->GetMinSize(); + _MaxSize = hyp->GetMaxSize(); } } @@ -471,22 +316,33 @@ bool GHS3DPRLPlugin_GHS3DPRL::Compute(SMESH_Mesh& theMesh, return false; } SetParameters(_hypothesis); - cout << "\n" << _name << " parameters :\n" << endl; - cout << " generic path/name of MED Files = " << _MEDName << endl; - cout << " number of partitions = " << _NbPart << endl; - cout << " merge subdomains = " << _ToMergeSubdomains << endl; - cout << " tag subdomains = " << _ToTagSubdomains << endl; - cout << " output interfaces = " << _ToOutputInterfaces << endl; - cout << " discard dubdomains = " << _ToDiscardSubdomains << endl; - cout << " keep intermediates files (from tetra-hpc) = " << _KeepFiles << endl; - cout << " background (from tetra-hpc) = " << _Background << "\n\n"; + cout << "\n" << _name << " parameters:" << endl; + cout << " generic path/name of MED Files = " << _MEDName << endl; + cout << " number of partitions = " << _NbPart << endl; + cout << " gradation = " << _Gradation << endl; + cout << " min_size = " << _MinSize << endl; + cout << " max_size = " << _MaxSize << endl; + cout << " keep intermediates files (from tetra-hpc) = " << _KeepFiles << endl; + cout << " background (from tetra-hpc) = " << _Background << "\n"; + cout << " multithread = " << _Multithread << "\n\n"; //string tmpDir=getTmpDir_new(); TCollection_AsciiString tmpDir=getTmpDir(), - GHS3DPRL_In,GHS3DPRL_Out,GHS3DPRL_Outxml, - run_GHS3DPRL("tetrahpc2med "),rm("rm -f "),run_nokeep_files, - NbPart,fileskinmed(""),fileskinmesh(""),path,casenamemed; //_MEDName.c_str()); + GHS3DPRL_In, + GHS3DPRL_Out, + GHS3DPRL_Outxml, + run_GHS3DPRL("tetrahpc2med "), + rm("rm -f "), + run_nokeep_files, + NbPart, + Gradation, + MinSize, + MaxSize, + fileskinmed(""), + fileskinmesh(""), + path, + casenamemed; //_MEDName.c_str()); casenamemed += (char *)_MEDName.c_str(); int n=casenamemed.SearchFromEnd('/'); @@ -501,8 +357,8 @@ bool GHS3DPRLPlugin_GHS3DPRL::Compute(SMESH_Mesh& theMesh, casenamemed=casenamemed.SubString(1,20); cerr<<"MEDName truncated (no more 20 characters) = "<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 pere - cout<<"le pere est la\n"; - system("echo le pere > lepere.tmp"); - system("sleep 10"); - system("ps -edf |grep wambeke > pslepere.tmp"); - cout<<"le pere return 0\n"; - return 0; //ok - //exit(0); - } else if (pid == 0) { - //Processus fils - cout<<"le fils est la\n"; - //On rend le fils independant de tout terminal - setsid(); - system("sleep 20"); - system("echo le fils > lefils.tmp"); - system("sleep 20"); - system("ps -edf |grep wambeke > pslefils.tmp"); - cout<<"le fils return 0\n"; - return 0; //ok - } else { - //Traitement d'erreur - cout<<"ya probleme sur fork()\n"; - return 1; //ko - }*/ -} //============================================================================= /*! diff --git a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_GHS3DPRL.hxx b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_GHS3DPRL.hxx index e002f3a..f1d1125 100755 --- a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_GHS3DPRL.hxx +++ b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_GHS3DPRL.hxx @@ -48,7 +48,6 @@ public: virtual bool Compute(SMESH_Mesh& aMesh, 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, @@ -65,11 +64,11 @@ private: int _NbPart; //number of partitions bool _KeepFiles; //tepal file .noboite binary or not bool _Background; //true for big meshes + bool _Multithread; //true for mg_tetra_hpc false for mg_tetra_hpc_mpi //ToMergeSubdomains ToTagSubdomains ToOutputInterfaces ToDiscardSubdomains - bool _ToMergeSubdomains; - bool _ToTagSubdomains; - bool _ToOutputInterfaces; - bool _ToDiscardSubdomains; + float _Gradation; + float _MinSize; + float _MaxSize; }; #endif diff --git a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis.cxx b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis.cxx index cb38453..d436fb3 100755 --- a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis.cxx +++ b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis.cxx @@ -36,10 +36,11 @@ GHS3DPRLPlugin_Hypothesis::GHS3DPRLPlugin_Hypothesis (int hypId, int studyId, SM _NbPart( GetDefaultNbPart() ), _KeepFiles( GetDefaultKeepFiles() ), _Background( GetDefaultBackground() ), - _ToMergeSubdomains( GetDefaultToMergeSubdomains() ), - _ToTagSubdomains( GetDefaultToTagSubdomains() ), - _ToOutputInterfaces( GetDefaultToOutputInterfaces() ), - _ToDiscardSubdomains( GetDefaultToDiscardSubdomains() ) + _Multithread( GetDefaultMultithread() ), + //_ToMergeSubdomains( GetDefaultToMergeSubdomains() ), + _Gradation( GetDefaultGradation() ), + _MinSize( GetDefaultMinSize() ), + _MaxSize( GetDefaultMaxSize() ) { MESSAGE("GHS3DPRLPlugin_Hypothesis::GHS3DPRLPlugin_Hypothesis"); _name = GetHypType(); @@ -116,42 +117,46 @@ void GHS3DPRLPlugin_Hypothesis::SetBackground(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; +void GHS3DPRLPlugin_Hypothesis::SetMultithread(bool theVal) { + if (theVal != _Multithread) { + _Multithread = theVal; NotifySubMeshesHypothesisModification(); } } -void GHS3DPRLPlugin_Hypothesis::SetToTagSubdomains(bool theVal) { - if (theVal != _ToTagSubdomains) { - _ToTagSubdomains = theVal; +//void GHS3DPRLPlugin_Hypothesis::SetToMergeSubdomains(bool theVal) { +// if (theVal != _ToMergeSubdomains) { +// _ToMergeSubdomains = theVal; +// NotifySubMeshesHypothesisModification(); +// } +//} + +void GHS3DPRLPlugin_Hypothesis::SetGradation(float theVal) { + if (theVal != _Gradation) { + _Gradation = theVal; NotifySubMeshesHypothesisModification(); } } -void GHS3DPRLPlugin_Hypothesis::SetToOutputInterfaces(bool theVal) { - if (theVal != _ToOutputInterfaces) { - _ToOutputInterfaces = theVal; +void GHS3DPRLPlugin_Hypothesis::SetMinSize(float theVal) { + if (theVal != _MinSize) { + _MinSize = theVal; NotifySubMeshesHypothesisModification(); } } -void GHS3DPRLPlugin_Hypothesis::SetToDiscardSubdomains(bool theVal) { - if (theVal != _ToDiscardSubdomains) { - _ToDiscardSubdomains = theVal; +void GHS3DPRLPlugin_Hypothesis::SetMaxSize(float theVal) { + if (theVal != _MaxSize) { + _MaxSize = theVal; NotifySubMeshesHypothesisModification(); } } + + + + //============================================================================= /*! * @@ -159,21 +164,18 @@ void GHS3DPRLPlugin_Hypothesis::SetToDiscardSubdomains(bool theVal) { //============================================================================= std::ostream& GHS3DPRLPlugin_Hypothesis::SaveTo(std::ostream& save) { - /*save << _MEDName ; //without whitespaces! - save << " " << _NbPart; - save << " " << (int)_KeepFiles;*/ - //explicit outputs for future code compatibility of saved .hdf //save without any whitespaces! save<<"MEDName="<<_MEDName<<";"; save<<"NbPart="<<_NbPart<<";"; //save<<"ToMeshHoles="<<(int) _ToMeshHoles<<";"; - save<<"ToMergeSubdomains="<<(int) _ToMergeSubdomains<<";"; - save<<"ToTagSubdomains="<<(int) _ToTagSubdomains<<";"; - save<<"ToOutputInterfaces="<<(int) _ToOutputInterfaces<<";"; - save<<"ToDiscardSubdomains="<<(int) _ToDiscardSubdomains<<";"; + //save<<"ToMergeSubdomains="<<(int) _ToMergeSubdomains<<";"; + save<<"Gradation="<<(float) _Gradation<<";"; + save<<"MinSize="<<(float) _MinSize<<";"; + save<<"MaxSize="<<(float) _MaxSize<<";"; save<<"KeepFiles="<<(int) _KeepFiles<<";"; save<<"Background="<<(int) _Background<<";"; + save<<"Multithread="<<(int) _Multithread<<";"; return save; } @@ -209,11 +211,11 @@ std::istream& GHS3DPRLPlugin_Hypothesis::LoadFrom(std::istream& load) 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=="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=="Gradation") _Gradation = (float) atof(str4.c_str()); + if (str3=="MinSize") _MinSize = (float) atof(str4.c_str()); + if (str3=="MaxSize") _MaxSize = (float) atof(str4.c_str()); if (str3=="Background") _Background = (bool) atoi(str4.c_str()); + if (str3=="Multithread") _Multithread = (bool) atoi(str4.c_str()); } return load; } @@ -289,6 +291,12 @@ bool GHS3DPRLPlugin_Hypothesis::GetDefaultBackground() return false; } +//============================================================================= +bool GHS3DPRLPlugin_Hypothesis::GetDefaultMultithread() +{ + return false; +} + //============================================================================= //bool GHS3DPRLPlugin_Hypothesis::GetDefaultToMeshHoles() //{ @@ -296,25 +304,24 @@ bool GHS3DPRLPlugin_Hypothesis::GetDefaultBackground() //} //============================================================================= -bool GHS3DPRLPlugin_Hypothesis::GetDefaultToMergeSubdomains() -{ - return false; -} +//bool GHS3DPRLPlugin_Hypothesis::GetDefaultToMergeSubdomains() +//{ +// return false; +//} //============================================================================= -bool GHS3DPRLPlugin_Hypothesis::GetDefaultToTagSubdomains() +float GHS3DPRLPlugin_Hypothesis::GetDefaultGradation() { - return false; + return 1.05; } - //============================================================================= -bool GHS3DPRLPlugin_Hypothesis::GetDefaultToOutputInterfaces() +float GHS3DPRLPlugin_Hypothesis::GetDefaultMinSize() { - return false; + return 0.; } - //============================================================================= -bool GHS3DPRLPlugin_Hypothesis::GetDefaultToDiscardSubdomains() +float GHS3DPRLPlugin_Hypothesis::GetDefaultMaxSize() { - return false; + return 0.; } + diff --git a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis.hxx b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis.hxx index 5d19102..877bf70 100755 --- a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis.hxx +++ b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis.hxx @@ -52,19 +52,20 @@ public: void SetBackground(bool theVal); bool GetBackground() const { return _Background; } - + + void SetMultithread(bool theVal); + bool GetMultithread() const { return _Multithread; } + //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; } + void SetGradation(float theVal); + float GetGradation() const { return _Gradation; } + + void SetMinSize(float theVal); + float GetMinSize() const { return _MinSize; } + + void SetMaxSize(float theVal); + float GetMaxSize() const { return _MaxSize; } + // the parameters default values @@ -72,10 +73,10 @@ public: static int GetDefaultNbPart(); static bool GetDefaultKeepFiles(); static bool GetDefaultBackground(); - static bool GetDefaultToMergeSubdomains(); - static bool GetDefaultToTagSubdomains(); - static bool GetDefaultToOutputInterfaces(); - static bool GetDefaultToDiscardSubdomains(); + static bool GetDefaultMultithread(); + static float GetDefaultGradation(); + static float GetDefaultMinSize(); + static float GetDefaultMaxSize(); // Persistence virtual std::ostream& SaveTo(std::ostream& save); @@ -104,11 +105,12 @@ private: std::string _MEDName; // generic path/name of med files int _NbPart; // number of partitions bool _KeepFiles; // keep intermediates tepal files or not - bool _Background; // tepal in background - bool _ToMergeSubdomains; - bool _ToTagSubdomains; - bool _ToOutputInterfaces; - bool _ToDiscardSubdomains; + bool _Background; // mg-tetra_hpc in background + bool _Multithread; // launch mg-tetra_hpc multithread version, else mpi version +// bool _ToMergeSubdomains; + float _Gradation; + float _MinSize; + float _MaxSize; }; #endif diff --git a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis_i.cxx b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis_i.cxx index 816d7e0..5378d6e 100755 --- a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis_i.cxx +++ b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis_i.cxx @@ -67,10 +67,10 @@ GHS3DPRLPlugin_Hypothesis_i::~GHS3DPRLPlugin_Hypothesis_i() * GHS3DPRLPlugin_Hypothesis_i::SetNbPart * GHS3DPRLPlugin_Hypothesis_i::SetKeepFiles * GHS3DPRLPlugin_Hypothesis_i::SetBackground - * GHS3DPRLPlugin_Hypothesis_i::SetToMergeSubdomains - * GHS3DPRLPlugin_Hypothesis_i::SetToTagSubdomains - * GHS3DPRLPlugin_Hypothesis_i::SetToOutputInterfaces - * GHS3DPRLPlugin_Hypothesis_i::SetToDiscardSubdomains + * GHS3DPRLPlugin_Hypothesis_i::SetMultithread + * GHS3DPRLPlugin_Hypothesis_i::SetGradation + * GHS3DPRLPlugin_Hypothesis_i::SetMinSize + * GHS3DPRLPlugin_Hypothesis_i::SetMaxSize */ //============================================================================= @@ -106,48 +106,60 @@ void GHS3DPRLPlugin_Hypothesis_i::SetBackground (CORBA::Boolean theValue) SMESH::TPythonDump() << _this() << ".SetBackground( " << theValue << " )"; } -void GHS3DPRLPlugin_Hypothesis_i::SetToMergeSubdomains (CORBA::Boolean theValue) +void GHS3DPRLPlugin_Hypothesis_i::SetMultithread (CORBA::Boolean theValue) { - MESSAGE("GHS3DPRLPlugin_Hypothesis_i::SetToMergeSubdomains"); + MESSAGE("GHS3DPRLPlugin_Hypothesis_i::SetMultithread"); ASSERT(myBaseImpl); - this->GetImpl()->SetToMergeSubdomains(theValue); - SMESH::TPythonDump() << _this() << ".SetToMergeSubdomains( " << theValue << " )"; + this->GetImpl()->SetMultithread(theValue); + SMESH::TPythonDump() << _this() << ".SetMultithread( " << theValue << " )"; } -void GHS3DPRLPlugin_Hypothesis_i::SetToTagSubdomains (CORBA::Boolean theValue) +//void GHS3DPRLPlugin_Hypothesis_i::SetToMergeSubdomains (CORBA::Boolean theValue) +//{ +// MESSAGE("GHS3DPRLPlugin_Hypothesis_i::SetToMergeSubdomains"); +// ASSERT(myBaseImpl); +// this->GetImpl()->SetToMergeSubdomains(theValue); +// SMESH::TPythonDump() << _this() << ".SetToMergeSubdomains( " << theValue << " )"; +//} + +void GHS3DPRLPlugin_Hypothesis_i::SetGradation (CORBA::Float theValue) { - MESSAGE("GHS3DPRLPlugin_Hypothesis_i::SetToTagSubdomains"); + MESSAGE("GHS3DPRLPlugin_Hypothesis_i::SetGradation"); ASSERT(myBaseImpl); - this->GetImpl()->SetToTagSubdomains(theValue); - SMESH::TPythonDump() << _this() << ".SetToTagSubdomains( " << theValue << " )"; + this->GetImpl()->SetGradation(theValue); + SMESH::TPythonDump() << _this() << ".SetGradation( " << theValue << " )"; } -void GHS3DPRLPlugin_Hypothesis_i::SetToOutputInterfaces (CORBA::Boolean theValue) +void GHS3DPRLPlugin_Hypothesis_i::SetMinSize (CORBA::Float theValue) { - MESSAGE("GHS3DPRLPlugin_Hypothesis_i::SetToOutputInterfaces"); + MESSAGE("GHS3DPRLPlugin_Hypothesis_i::SetMinSize"); ASSERT(myBaseImpl); - this->GetImpl()->SetToOutputInterfaces(theValue); - SMESH::TPythonDump() << _this() << ".SetToOutputInterfaces( " << theValue << " )"; + this->GetImpl()->SetMinSize(theValue); + SMESH::TPythonDump() << _this() << ".SetMinSize( " << theValue << " )"; } -void GHS3DPRLPlugin_Hypothesis_i::SetToDiscardSubdomains (CORBA::Boolean theValue) +void GHS3DPRLPlugin_Hypothesis_i::SetMaxSize (CORBA::Float theValue) { - MESSAGE("GHS3DPRLPlugin_Hypothesis_i::SetToDiscardSubdomains"); + MESSAGE("GHS3DPRLPlugin_Hypothesis_i::SetMaxSize"); ASSERT(myBaseImpl); - this->GetImpl()->SetToDiscardSubdomains(theValue); - SMESH::TPythonDump() << _this() << ".SetToDiscardSubdomains( " << theValue << " )"; + this->GetImpl()->SetMaxSize(theValue); + SMESH::TPythonDump() << _this() << ".SetMaxSize( " << theValue << " )"; } + + + + //============================================================================= /*! * GHS3DPRLPlugin_Hypothesis_i::GetMEDName * GHS3DPRLPlugin_Hypothesis_i::GetNbPart * GHS3DPRLPlugin_Hypothesis_i::GetKeepFiles * GHS3DPRLPlugin_Hypothesis_i::GetBackground - * GHS3DPRLPlugin_Hypothesis_i::GetToMergeSubdomains - * GHS3DPRLPlugin_Hypothesis_i::GetToTagSubdomains - * GHS3DPRLPlugin_Hypothesis_i::GetToOutputInterfaces - * GHS3DPRLPlugin_Hypothesis_i::GetToDiscardSubdomains + * GHS3DPRLPlugin_Hypothesis_i::GetMultithread + * GHS3DPRLPlugin_Hypothesis_i::GetGradation + * GHS3DPRLPlugin_Hypothesis_i::GetMinSize + * GHS3DPRLPlugin_Hypothesis_i::GetMaxSize */ //============================================================================= @@ -181,32 +193,39 @@ CORBA::Boolean GHS3DPRLPlugin_Hypothesis_i::GetBackground() return this->GetImpl()->GetBackground(); } -CORBA::Boolean GHS3DPRLPlugin_Hypothesis_i::GetToMergeSubdomains() +CORBA::Boolean GHS3DPRLPlugin_Hypothesis_i::GetMultithread() { - MESSAGE("GHS3DPRLPlugin_Hypothesis_i::GetToMergeSubdomains"); + MESSAGE("GHS3DPRLPlugin_Hypothesis_i::GetMultithread"); ASSERT(myBaseImpl); - return this->GetImpl()->GetToMergeSubdomains(); + return this->GetImpl()->GetMultithread(); } -CORBA::Boolean GHS3DPRLPlugin_Hypothesis_i::GetToTagSubdomains() +//CORBA::Boolean GHS3DPRLPlugin_Hypothesis_i::GetToMergeSubdomains() +//{ +// MESSAGE("GHS3DPRLPlugin_Hypothesis_i::GetToMergeSubdomains"); +// ASSERT(myBaseImpl); +// return this->GetImpl()->GetToMergeSubdomains(); +//} + +CORBA::Float GHS3DPRLPlugin_Hypothesis_i::GetGradation() { - MESSAGE("GHS3DPRLPlugin_Hypothesis_i::GetToTagSubdomains"); + MESSAGE("GHS3DPRLPlugin_Hypothesis_i::GetGradation"); ASSERT(myBaseImpl); - return this->GetImpl()->GetToTagSubdomains(); + return this->GetImpl()->GetGradation(); } -CORBA::Boolean GHS3DPRLPlugin_Hypothesis_i::GetToOutputInterfaces() +CORBA::Float GHS3DPRLPlugin_Hypothesis_i::GetMinSize() { - MESSAGE("GHS3DPRLPlugin_Hypothesis_i::GetToOutputInterfaces"); + MESSAGE("GHS3DPRLPlugin_Hypothesis_i::GetMinSize"); ASSERT(myBaseImpl); - return this->GetImpl()->GetToOutputInterfaces(); + return this->GetImpl()->GetMinSize(); } -CORBA::Boolean GHS3DPRLPlugin_Hypothesis_i::GetToDiscardSubdomains() +CORBA::Float GHS3DPRLPlugin_Hypothesis_i::GetMaxSize() { - MESSAGE("GHS3DPRLPlugin_Hypothesis_i::GetToDiscardSubdomains"); + MESSAGE("GHS3DPRLPlugin_Hypothesis_i::GetMaxSize"); ASSERT(myBaseImpl); - return this->GetImpl()->GetToDiscardSubdomains(); + return this->GetImpl()->GetMaxSize(); } //============================================================================= diff --git a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis_i.hxx b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis_i.hxx index 5b23579..ab8d888 100755 --- a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis_i.hxx +++ b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis_i.hxx @@ -62,17 +62,20 @@ class GHS3DPRLPLUGIN_EXPORT GHS3DPRLPlugin_Hypothesis_i: void SetBackground(CORBA::Boolean theVal); CORBA::Boolean GetBackground(); - void SetToMergeSubdomains(CORBA::Boolean theVal); - CORBA::Boolean GetToMergeSubdomains(); + void SetMultithread(CORBA::Boolean theVal); + CORBA::Boolean GetMultithread(); - void SetToTagSubdomains(CORBA::Boolean theVal); - CORBA::Boolean GetToTagSubdomains(); +// void SetToMergeSubdomains(CORBA::Boolean theVal); +// CORBA::Boolean GetToMergeSubdomains(); - void SetToOutputInterfaces(CORBA::Boolean theVal); - CORBA::Boolean GetToOutputInterfaces(); + void SetGradation(CORBA::Float theVal); + CORBA::Float GetGradation(); - void SetToDiscardSubdomains(CORBA::Boolean theVal); - CORBA::Boolean GetToDiscardSubdomains(); + void SetMinSize(CORBA::Float theVal); + CORBA::Float GetMinSize(); + + void SetMaxSize(CORBA::Float theVal); + CORBA::Float GetMaxSize(); // Get implementation ::GHS3DPRLPlugin_Hypothesis* GetImpl(); diff --git a/src/gui/GHS3DPRLPluginGUI_HypothesisCreator.cxx b/src/gui/GHS3DPRLPluginGUI_HypothesisCreator.cxx index 01dfd1b..a573172 100755 --- a/src/gui/GHS3DPRLPluginGUI_HypothesisCreator.cxx +++ b/src/gui/GHS3DPRLPluginGUI_HypothesisCreator.cxx @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -113,25 +114,44 @@ QFrame* GHS3DPRLPluginGUI_HypothesisCreator::buildFrame() myBackground->setWhatsThis( tr( "GHS3DPRL_WhatsThis_Background" ) ); l->addWidget( myBackground, row++, 0, 1, 2 ); + myMultithread = new QCheckBox( tr( "GHS3DPRL_Multithread" ), GroupC1 ); + myMultithread->setWhatsThis( tr( "GHS3DPRL_WhatsThis_Multithread" ) ); + l->addWidget( myMultithread, 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 ); + //myToMergeSubdomains = new QCheckBox( tr( "GHS3DPRL_ToMergeSubdomains" ), GroupC1 ); + //myToMergeSubdomains->setWhatsThis( tr( "GHS3DPRL_WhatsThis_ToMergeSubdomains" ) ); + //l->addWidget( myToMergeSubdomains, row++, 0, 1, 2 ); + + QLabel* aGradationText = new QLabel( tr( "GHS3DPRL_Gradation" ), GroupC1 ); + aGradationText->setWhatsThis( tr( "GHS3DPRL_WhatsThis_Gradation" ) ); + l->addWidget( aGradationText, row, 0, 1, 1 ); + myGradation = new QtxDoubleSpinBox( GroupC1 ); + l->addWidget( myGradation, row++, 1, 1, 1 ); + myGradation->setMinimum( 0 ); + myGradation->setMaximum( 3 ); + myGradation->setSingleStep( 0.01 ); + + QLabel* aMinSizeText = new QLabel( tr( "GHS3DPRL_MinSize" ), GroupC1 ); + aMinSizeText->setWhatsThis( tr( "GHS3DPRL_WhatsThis_MinSize" ) ); + l->addWidget( aMinSizeText, row, 0, 1, 1 ); + myMinSize = new QtxDoubleSpinBox( GroupC1 ); + l->addWidget( myMinSize, row++, 1, 1, 1 ); + myMinSize->setMinimum( 0 ); + //myMinSize->setMaximum( 999999 ); + //myMinSize->setSingleStep( 1 ); + + QLabel* aMaxSizeText = new QLabel( tr( "GHS3DPRL_MaxSize" ), GroupC1 ); + aMaxSizeText->setWhatsThis( tr( "GHS3DPRL_WhatsThis_MaxSize" ) ); + l->addWidget( aMaxSizeText, row, 0, 1, 1 ); + myMaxSize = new QtxDoubleSpinBox( GroupC1 ); + l->addWidget( myMaxSize, row++, 1, 1, 1 ); + myMaxSize->setMinimum( 0 ); + //myMaxSize->setMaximum( 999999 ); + //myMaxSize->setSingleStep( 1 ); myIs3D = true; @@ -148,12 +168,12 @@ void GHS3DPRLPluginGUI_HypothesisCreator::retrieveParams() const myNbPart->setValue( data.myNbPart ); myKeepFiles->setChecked( data.myKeepFiles ); myBackground->setChecked( data.myBackground ); + myMultithread->setChecked( data.myMultithread ); //myToMeshHoles->setChecked( data.myToMeshHoles ); - myToMergeSubdomains->setChecked( data.myToMergeSubdomains ); - myToTagSubdomains->setChecked( data.myToTagSubdomains ); - myToOutputInterfaces->setChecked( data.myToOutputInterfaces ); - myToDiscardSubdomains->setChecked( data.myToDiscardSubdomains ); - //myNbPart->setEnabled( true ); + //myToMergeSubdomains->setChecked( data.myToMergeSubdomains ); + myGradation->setValue( data.myGradation ); + myMinSize->setValue( data.myMinSize ); + myMaxSize->setValue( data.myMaxSize ); } QString GHS3DPRLPluginGUI_HypothesisCreator::storeParams() const @@ -166,12 +186,13 @@ QString GHS3DPRLPluginGUI_HypothesisCreator::storeParams() const 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_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_ToMergeSubdomains" ) + " = " + QString::number( data.myToMergeSubdomains ) + "; "; + valStr += tr( "GHS3DPRL_Gradation" ) + " = " + QString::number( data.myGradation ) + "; "; + valStr += tr( "GHS3DPRL_MinSize" ) + " = " + QString::number( data.myMinSize ) + "; "; + valStr += tr( "GHS3DPRL_MaxSize" ) + " = " + QString::number( data.myMaxSize ) + "; "; valStr += tr( "GHS3DPRL_KeepFiles" ) + " = " + QString::number( data.myKeepFiles ) + "; "; valStr += tr( "GHS3DPRL_Background" ) + " = " + QString::number( data.myBackground ) + "; "; + valStr += tr( "GHS3DPRL_Multithread" ) + " = " + QString::number( data.myMultithread ) + "; "; return valStr; } @@ -187,11 +208,12 @@ bool GHS3DPRLPluginGUI_HypothesisCreator::readParamsFromHypo( GHS3DPRLHypothesis h_data.myNbPart = h->GetNbPart(); h_data.myKeepFiles = h->GetKeepFiles(); h_data.myBackground = h->GetBackground(); + h_data.myMultithread = h->GetMultithread(); //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(); + //h_data.myToMergeSubdomains = h->GetToMergeSubdomains(); + h_data.myGradation = h->GetGradation(); + h_data.myMinSize = h->GetMinSize(); + h_data.myMaxSize = h->GetMaxSize(); return true; } @@ -211,11 +233,12 @@ bool GHS3DPRLPluginGUI_HypothesisCreator::storeParamsToHypo( const GHS3DPRLHypot h->SetNbPart( h_data.myNbPart ); h->SetKeepFiles( h_data.myKeepFiles ); h->SetBackground( h_data.myBackground ); + h->SetMultithread( h_data.myMultithread ); //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 ); + //h->SetToMergeSubdomains( h_data.myToMergeSubdomains ); + h->SetGradation( h_data.myGradation ); + h->SetMinSize( h_data.myMinSize ); + h->SetMaxSize( h_data.myMaxSize ); } catch ( const SALOME::SALOME_Exception& ex ) { @@ -233,10 +256,10 @@ bool GHS3DPRLPluginGUI_HypothesisCreator::readParamsFromWidgets( GHS3DPRLHypothe h_data.myKeepFiles = myKeepFiles->isChecked(); h_data.myBackground = myBackground->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(); + //h_data.myToMergeSubdomains = myToMergeSubdomains->isChecked(); + h_data.myGradation = myGradation->value(); + h_data.myMinSize = myMinSize->value(); + h_data.myMaxSize = myMaxSize->value(); return true; } diff --git a/src/gui/GHS3DPRLPluginGUI_HypothesisCreator.h b/src/gui/GHS3DPRLPluginGUI_HypothesisCreator.h index e0ac60a..9ecef8a 100755 --- a/src/gui/GHS3DPRLPluginGUI_HypothesisCreator.h +++ b/src/gui/GHS3DPRLPluginGUI_HypothesisCreator.h @@ -39,6 +39,7 @@ #include class QtxIntSpinBox; +class QtxDoubleSpinBox; class QCheckBox; class QLineEdit; @@ -49,11 +50,12 @@ typedef struct int myNbPart; bool myKeepFiles; bool myBackground; + bool myMultithread; //bool myToMeshHoles; - bool myToMergeSubdomains; - bool myToTagSubdomains; - bool myToOutputInterfaces; - bool myToDiscardSubdomains; + //bool myToMergeSubdomains; + float myGradation; + float myMinSize; + float myMaxSize; } GHS3DPRLHypothesisData; /*! @@ -85,17 +87,18 @@ private: bool storeParamsToHypo( const GHS3DPRLHypothesisData& ) const; private: - QLineEdit* myName; - QLineEdit* myMEDName; - QtxIntSpinBox* myNbPart; - QCheckBox* myKeepFiles; - QCheckBox* myBackground; + QLineEdit* myName; + QLineEdit* myMEDName; + QtxIntSpinBox* myNbPart; + QCheckBox* myKeepFiles; + QCheckBox* myBackground; + QCheckBox* myMultithread; //QCheckBox* myToMeshHoles; - QCheckBox* myToMergeSubdomains; - QCheckBox* myToTagSubdomains; - QCheckBox* myToOutputInterfaces; - QCheckBox* myToDiscardSubdomains; - bool myIs3D; + //QCheckBox* myToMergeSubdomains; + QtxDoubleSpinBox* myGradation; + QtxDoubleSpinBox* myMinSize; + QtxDoubleSpinBox* myMaxSize; + bool myIs3D; }; #endif // GHS3DPRLPLUGINGUI_HypothesisCreator_H diff --git a/src/gui/GHS3DPRLPlugin_msg_en.ts b/src/gui/GHS3DPRLPlugin_msg_en.ts index 2c54997..2671b82 100644 --- a/src/gui/GHS3DPRLPlugin_msg_en.ts +++ b/src/gui/GHS3DPRLPlugin_msg_en.ts @@ -20,24 +20,24 @@ Tetra_hpc in background - GHS3DPRL_ToMeshHoles - Mesh holes + GHS3DPRL_Multithread + Launch mg_tetra_hpc multithread - GHS3DPRL_ToMergeSubdomains - Merge subdomains + GHS3DPRL_ToMeshHoles + Mesh holes - GHS3DPRL_ToTagSubdomains - Tag subdomains + GHS3DPRL_Gradation + Max ratio adjacent cells - GHS3DPRL_ToOutputInterfaces - Output interfaces + GHS3DPRL_MinSize + Desired minimum cells size - GHS3DPRL_ToDiscardSubdomains - Discard subdomains + GHS3DPRL_MaxSize + Desired maximum cells size GHS3DPRL_MEDName @@ -49,15 +49,15 @@ GHS3DPRL_WhatsThis_KeepFiles - Keep intemediates Tepal Files (.faces,.points,.msg,.noboite...) + Keep intermediates mg_tetra_hpc files GHS3DPRL_WhatsThis_Background - Lanch Tepal in background (for a big mesh, a long time...) + Lanch mg_tetra_hpc in background (for a big mesh, a long time...) - GHS3DPRL_WhatsThis_ToMeshHoles - Tepal meshes holes + GHS3DPRL_WhatsThis_Multithread + Launch mg_tetra_hpc multithread GHS3DPRL_WhatsThis_MEDName diff --git a/src/gui/GHS3DPRLPlugin_msg_fr.ts b/src/gui/GHS3DPRLPlugin_msg_fr.ts index 4766a7d..a9df8dc 100755 --- a/src/gui/GHS3DPRLPlugin_msg_fr.ts +++ b/src/gui/GHS3DPRLPlugin_msg_fr.ts @@ -17,27 +17,23 @@ GHS3DPRL_Background - Tetra_hpc en arrière plan + mg_tetra_hpc en arrière plan - GHS3DPRL_ToMeshHoles - Mailler les trous du maillage + GHS3DPRL_Multithread + Lance mg_tetra_hpc multithread - GHS3DPRL_ToMergeSubdomains - Fusionner les sous domaines en fin + GHS3DPRL_Gradation + Max ratio mailles adjacentes - GHS3DPRL_ToTagSubdomains - Marquer les sous domaines + GHS3DPRL_MinSize + Min taille mailles - GHS3DPRL_ToOutputInterfaces - Gestion des interfaces entre les sous domaines - - - GHS3DPRL_ToDiscardSubdomains - Oublier les sous domaines + GHS3DPRL_MaxSize + Max taille mailles GHS3DPRL_MEDName @@ -53,11 +49,11 @@ GHS3DPRL_WhatsThis_Background - Lancer MG-Tetra-hpc 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 - MG-Tetra-hp maille les trous (obsolète) + GHS3DPRL_WhatsThis_Multithread + Lancer mg_Tetra_hpc multithread GHS3DPRL_WhatsThis_MEDName diff --git a/src/gui/GHS3DPRLPlugin_msg_ja.ts b/src/gui/GHS3DPRLPlugin_msg_ja.ts index 443c76d..61b29d7 100644 --- a/src/gui/GHS3DPRLPlugin_msg_ja.ts +++ b/src/gui/GHS3DPRLPlugin_msg_ja.ts @@ -17,7 +17,11 @@ GHS3DPRL_Background - MG-Tetra HPC in background + Launch mg_tetra_hpc in background + + + GHS3DPRL_Multithread + Launch mg_tetra_hpc multithread GHS3DPRL_ToMeshHoles @@ -38,6 +42,18 @@ GHS3DPRL_ToDiscardSubdomains サブドメインの削除 + + + GHS3DPRL_Gradation + Max ratio adjacent cells + + + GHS3DPRL_MinSize + Desired minimum cells size + + + GHS3DPRL_MaxSize + Desired maximum cells size GHS3DPRL_MEDName @@ -49,15 +65,19 @@ GHS3DPRL_WhatsThis_KeepFiles - 中間のMG-Tetra HPCファイルを保持 + 中間のmg_tetra_hpcファイルを保持 GHS3DPRL_WhatsThis_Background - Launch MG-Tetra HPC in background (for a big mesh, a long time...) + Launch mg_tetra_hpc in background (for a big mesh, a long time...) + + + GHS3DPRL_WhatsThis_Multithread + Launch mg_tetra_hpc multithread GHS3DPRL_WhatsThis_ToMeshHoles - Tepal meshes holes + mg_tetra_hpc meshes holes GHS3DPRL_WhatsThis_MEDName diff --git a/src/tepal2med/ghs3dprl_mesh_wrap.cxx b/src/tepal2med/ghs3dprl_mesh_wrap.cxx index 51dfbe9..33bc8ef 100755 --- a/src/tepal2med/ghs3dprl_mesh_wrap.cxx +++ b/src/tepal2med/ghs3dprl_mesh_wrap.cxx @@ -344,8 +344,8 @@ bool CVWtab::CVWtab_deallocate() memoryuse=memoryuse-sizeof(med_float)*size; size=-size; //precaution } - if (memoryuse<0) std::cout<<"***WARNING*** memoryuse <0 "<nofile<<"="<2) std::cout<<"MeshVersionFormatted_"<nofile<<" ok"<=6)std::cout<<"Read file '"<>vert>>edge>>tria>>tetr; + std::cout<<"First line "<>tmint[i]; + if (verbose>4) std::cout<<"Vertices ("<nofile); + ok=this->insert_key(tmp,montab); + + count=edge; + tmint=new med_int[count]; + for (int i=0; i>tmint[i]; + if (verbose>4) std::cout<<"Edges ("<nofile); + ok=this->insert_key(tmp,montab); + + count=tria; + tmint=new med_int[count]; + for (int i=0; i>tmint[i]; + if (verbose>4) std::cout<<"Triangles ("<nofile); + ok=this->insert_key(tmp,montab); + + count=tetr; + tmint=new med_int[count]; + for (int i=0; i>tmint[i]; + if (verbose>4) std::cout<<"Tetrahedra ("<nofile); + ok=this->insert_key(tmp,montab); + + //Ferme le fichier : + Ff.close(); + this->nbfiles++; + return true; +} + //************************************ bool ghs3dprl_mesh_wrap::ReadFileFACES(const QString FileName) //read file .faces (wrap) @@ -669,8 +758,8 @@ bool ghs3dprl_mesh_wrap::ReadFileFACES(const QString FileName) return false; } - //Lit les donn�s : - //Replace le pointeur de fichier au d�ut :f.seekg(0); + //Lit les donnees : + //Replace le pointeur de fichier au debut :f.seekg(0); if (getline(Ff,line)) { tmp=line.c_str(); @@ -712,13 +801,14 @@ bool ghs3dprl_mesh_wrap::ReadFileMESH(const QString FileName) 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; + long Mversion=0,Mdim=0,Mvert=0,Mtria=0,Medge=0,Mtetra=0,count=0; med_int garbage; - //long ne,np,npfixe,subnumber,reste; + med_int *tmint; bool ok; - if (verbose>=6)std::cout<<"Read File '"<=6)std::cout<<"Read file '"<>tmflo[i]>>tmflo[i+1]>>tmflo[i+2]>>garbage; - if (verbose>4) std::cout<<"Vertices "<>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("Edges")==0))) + { + std::cerr<<"Problem on line 'Edges' of file '"<>tmint[i]>>tmint[i+1]>>garbage; + } + if (verbose>4) std::cout<<"Edges ("<nofile); //TODO see if it could serve + 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 "<4) std::cout<<"Triangles ("<nofile); ok=this->insert_key(tmp,montab); @@ -847,15 +969,17 @@ bool ghs3dprl_mesh_wrap::ReadFileMESH(const QString FileName) std::cout<<"MeshVersionFormatted="<>tmint[i]>>tmint[i+1]>>tmint[i+2]>>tmint[i+3]>>garbage; + if (verbose>4) std::cout<<"Tetrahedra ("<nofile); ok=this->insert_key(tmp,montab); @@ -886,7 +1010,7 @@ bool ghs3dprl_mesh_wrap::ReadFileNOBOITE(const QString FileName) return false; } - //lit les donn�s : + //lit les donnees : Ff>>ne>>np>>npfixe; if (verbose>3){ std::cout<<"NoboiteNumberOfElements="<nbelem_limit_swap +//insertion conditionnee par limite this->nbelem_limit_swap //si tableaux contenus on dimension superieure //alors swap disque dans getenv(tmp) fichier temporaire binaire { @@ -1269,7 +1393,7 @@ bool ghs3dprl_mesh_wrap::insert_key(const QString &key,CVWtab *tab) } //************************************ CVWtab* ghs3dprl_mesh_wrap::restore_key(const QString &key) -//retauration conditionn� par limite nbelem +//retauration conditionnee par limite nbelem //si tableaux contenus on dimension superieure a nbelem //alors swap disque dans getenv(tmp) fichier temporaire //alors lecture du fichier (et reallocate memory) @@ -1793,13 +1917,18 @@ bool ghs3dprl_mesh_wrap::Write_MEDfiles_v2(bool deletekeys) else if (verbose>3) std::cout<<"--deletegroups matches \"New_Tetrahedra\"\n"; if (verbose>6){std::cout<<"\nIntermediatesFamilies\n"; families.write();} - if (verbose>6) std::cout<<"\nNumber0fFiles="<6) std::cout<<"\nNumber0fFiles="<4) std::cout<<"\nEnd of Nodes ***\n"<4) std::cout<<"\nEnd of Edges ***\n"<4) std::cout<<"\nEnd of Faces ***\n"<6){std::cout<<"\nFinalsFamilies\n"; families.write();} - //for nodes families - nb=create_families(fid,1); - if (verbose>5)std::cout<<"NumberOfFamiliesNodes="<8) - std::cout<<"MEDmeshEntityFamilyNumberWr nodes "<5)std::cout<<"NumberOfFamiliesFacesAndEdgesEtc="<8) - std::cout<<"MEDmeshEntityFamilyNumberWr tria3 "<8) - std::cout<<"MEDmeshEntityFamilyNumberWr tetra4 "<4) std::cout<<"\nEnd of Tetrahedra ***\n"<6){std::cout<<"\nFinalsFamilies\n"; families.write();} + //for nodes families + nb=create_families(fid,1); + if (verbose>5)std::cout<<"NumberOfFamiliesNodes="<8) + std::cout<<"MEDmeshEntityFamilyNumberWr nodes "<5)std::cout<<"NumberOfFamiliesFacesAndEdgesEtc="<8) + std::cout<<"MEDmeshEntityFamilyNumberWr tria3 "<8) + std::cout<<"MEDmeshEntityFamilyNumberWr tetra4 "<0)std::cout<<"\nTotalNumberOftetrahedra="<ReadFileNOBOITE(tmp); } if (for_tetrahpc) { - tmp=pathini+casename+tmp.sprintf(format_tetra.toLatin1().constData(),idom)+".mesh"; + tmp=pathini+casename+"_out"+tmp.sprintf(format_tetra.toLatin1().constData(),idom)+".mesh"; ok=this->ReadFileMESH(tmp); } tab=this->restore_key(key); //tab1=this->mestab[key1]; @@ -1911,7 +2048,7 @@ bool ghs3dprl_mesh_wrap::idom_nodes() nbnodes=tab->size/3; err=MEDmeshNodeCoordinateWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,0.,MED_FULL_INTERLACE,nbnodes,tab->tmflo); if (err<0) {std::cerr<<"Problem MEDmeshNodeCoordinateWr"<4)std::cout<<"NumberOfNodes="<4) std::cout<<"NumberOfNodes="<restore_key(key1); //tab1=this->mestab[key1]; if (!tab1) { @@ -1928,8 +2066,8 @@ bool ghs3dprl_mesh_wrap::idom_nodes() ok=this->ReadFileGLO(tmp); } if (for_tetrahpc) { - tmp=pathini+casename+tmp.sprintf(format_tetra.toLatin1().constData(),idom)+".glo"; - ok=this->ReadFileGLO(tmp); + tmp=pathini+casename+"_out"+tmp.sprintf(format_tetra.toLatin1().constData(),idom)+".global"; + ok=this->ReadFileGLOBAL(tmp); } if (!ok) {std::cerr<<"Problem file "<restore_key(key1); //tab1=this->mestab[key1]; @@ -1967,7 +2105,8 @@ bool ghs3dprl_mesh_wrap::idom_nodes() //writing nodes(vertices) global numbering err=MEDmeshGlobalNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_NODE,MED_UNDEF_GEOMETRY_TYPE,nbnodes,tab1->tmint); if (err<0){std::cerr<<"Problem MEDmeshGlobalNumberWr nodes"<restore_key(key1); if (!tab1) return false; } - nbtria3=tab1->size/7; + nbtria3=tab1->size/3; if (verbose>4) std::cout<<"NumberOfTriangles="<tmint[i]; ii++; - arrayi[ii]=tab1->tmint[i+1]; ii++; - arrayi[ii]=tab1->tmint[i+2]; ii++; - i=i+7; - } - err=MEDmeshElementConnectivityWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,0.,MED_CELL,MED_TRIA3,MED_NODAL,MED_FULL_INTERLACE,nbtria3,arrayi); - delete[] arrayi; //need immediately more little array + //arrayi=new med_int[nbtria3*3]; + //ii=0,i=0 ; + //for (j=0; jtmint[i]; ii++; + // arrayi[ii]=tab1->tmint[i+1]; ii++; + // arrayi[ii]=tab1->tmint[i+2]; ii++; + // i=i+7; + //} + //err=MEDmeshElementConnectivityWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,0.,MED_CELL,MED_TRIA3,MED_NODAL,MED_FULL_INTERLACE,nbtria3,arrayi); + err=MEDmeshElementConnectivityWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,0.,MED_CELL,MED_TRIA3,MED_NODAL,MED_FULL_INTERLACE,nbtria3,tab1->tmint); + //delete[] arrayi; //need immediately more little array if (err<0){std::cerr<<"Problem MEDmeshElementConnectivityWr for triangles connectivity"<restore_key(key1); //tab1=this->mestab[key1]; - if (nbtria3!=tab1->size){std::cerr<<"Problem size GLi FA!=nbtria3!"<restore_key(key2); //tab1=this->mestab[key1]; - med_int nbskin=0; - if (tab2) nbskin=tab2->size; + if (!for_multithread) { + key1=key1.sprintf("GL%d FA",idom); + tab1=this->restore_key(key1); //tab1=this->mestab[key1]; + if (nbtria3!=tab1->size){std::cerr<<"Problem size GLi FA!=nbtria3!"<tmint[i]-1; // - if (jtmint[j]; - } - } - ok=set_one_more_family(famtria3,fammore,nb); - delete[] fammore; - //writing faces(triangles) global numbering - if (verbose>2) - std::cout<<"CreateMEDglobalNumerotation_Faces "<size<size,tab1->tmint); - if (err<0){std::cerr<<"Problem MEDmeshGlobalNumberWr faces"<remove_key_mesh_wrap(QRegExp("FC*",true,true)); - tmp=tmp.sprintf("GL%d FA",idom); - //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true)); - xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp)); - tmp=tmp.sprintf("GL%d VE",idom); - //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true)); - xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp)); + key2=key2.sprintf("SKIN_TRIA3_FAMILIES",idom); //on global numerotation + tab2=this->restore_key(key2); //tab1=this->mestab[key1]; + med_int nbskin=0; + if (tab2) nbskin=tab2->size; + + //set families of faces existing in GHS3DPRL_skin.med + med_int nb=nbtria3; + famtria3=new med_int[nb]; + for (i=0; itmint[i]-1; // + if (jtmint[j]; + } + } + ok=set_one_more_family(famtria3,fammore,nb); + delete[] fammore; + + //writing faces(triangles) global numbering + if (verbose>2) + std::cout<<"CreateMEDglobalNumerotation_Faces "<size<size,tab1->tmint); + if (err<0){std::cerr<<"Problem MEDmeshGlobalNumberWr faces"<remove_key_mesh_wrap(QRegExp("FC*",true,true)); + tmp=tmp.sprintf("GL%d FA",idom); + //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true)); + xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp)); + tmp=tmp.sprintf("GL%d VE",idom); + //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true)); + xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp)); + } return ok; } @@ -2471,23 +2614,37 @@ bool ghs3dprl_mesh_wrap::idom_tetras() famtetra4=new med_int[nbtetra4]; for (i=0; irestore_key(key1); //tab1=this->mestab[key1]; - if (!tab1) { - tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,idom)+".glo"; - ok=this->ReadFileGLO(tmp); - tab1=this->restore_key(key1); - if (!tab1) return false; - } + if (!for_multithread) { + //writing tetrahedra global numbering + //GLx EL=files.GLo ELements + key1=key1.sprintf("GL%d EL",idom); + 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); + //tab1=this->restore_key(key1); + //if (!tab1) return false; + + if (!for_tetrahpc) { + tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,idom)+".glo"; + ok=this->ReadFileGLO(tmp); + } + if (for_tetrahpc) { + tmp=pathini+casename+"_out"+tmp.sprintf(format_tetra.toLatin1().constData(),idom)+".global"; + ok=this->ReadFileGLOBAL(tmp); + } + tab1=this->restore_key(key1); + if (!tab1) return false; - if (tab1->size!=nbtetra4){ - std::cerr<<"Problem incorrect size of tetrahedra global numbering"<2) - std::cout<<"CreateMEDglobalNumerotation_tetrahedra "<size<size,tab1->tmint); - if (err<0){std::cerr<<"Problem MEDmeshGlobalNumberWr tetrahedra"<size!=nbtetra4){ + std::cerr<<"Problem incorrect size of tetrahedra global numbering"<2) + std::cout<<"CreateMEDglobalNumerotation_tetrahedra "<size<size,tab1->tmint); + if (err<0){std::cerr<<"Problem MEDmeshGlobalNumberWr tetrahedra"<remove_key_mesh_wrap(QRegExp(tmp,true,true)); diff --git a/src/tepal2med/ghs3dprl_mesh_wrap.h b/src/tepal2med/ghs3dprl_mesh_wrap.h index ec85929..27f3bf2 100755 --- a/src/tepal2med/ghs3dprl_mesh_wrap.h +++ b/src/tepal2med/ghs3dprl_mesh_wrap.h @@ -83,9 +83,17 @@ class familles{ class ghs3dprl_mesh_wrap { public: - QString medname,casename,path,pathini,filemed,format,format_tetra; - bool for_tetrahpc; //to know what files to read: .noboite or .mesh - QRegExp deletegroups; //regular expression + QString + medname, + casename, + path, + pathini, + filemed, + format, + format_tetra; + bool for_tetrahpc; //to know what files to read: .noboite or .mesh + bool for_multithread; //to know what files to read: one or more + QRegExp deletegroups; //regular expression long nbtetrastotal, nofile,nbfiles,nbfilestot, @@ -151,6 +159,7 @@ public: bool ReadFileMSGnew(const QString FileName); bool TestExistingFileMESHnew(const QString FileName); bool ReadFileGLO(const QString FileName); + bool ReadFileGLOBAL(const QString FileName); //mg-tetra v2.1.11 bool ReadFileFACES(const QString FileName); bool ReadFileMESH(const QString FileName); bool ReadFileNOBOITE(const QString FileName); diff --git a/src/tepal2med/tepal2med.cxx b/src/tepal2med/tepal2med.cxx index 7d1c9bc..89760d2 100755 --- a/src/tepal2med/tepal2med.cxx +++ b/src/tepal2med/tepal2med.cxx @@ -90,7 +90,7 @@ med_idt ouvre_fichier_MED(char *fichier,int verbose) if (ret < 0) return fid; MEDfileNumVersionRd(fid, &majeur, &mineur, &release); - if (majeur < 2 || majeur == 2 && mineur < 2) { + 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"; diff --git a/src/tepal2med/tetrahpc2med.cxx b/src/tepal2med/tetrahpc2med.cxx index a24b3da..d3ba409 100755 --- a/src/tepal2med/tetrahpc2med.cxx +++ b/src/tepal2med/tetrahpc2med.cxx @@ -45,7 +45,7 @@ #include #include "ghs3dprl_msg_parser.h" -#include "dlg_ghs3dmain.h" +//#include "dlg_ghs3dmain.h" #ifdef WIN32 #include @@ -90,7 +90,7 @@ med_idt ouvre_fichier_MED(char *fichier,int verbose) if (ret < 0) return fid; MEDfileNumVersionRd(fid, &majeur, &mineur, &release); - if (majeur < 2 || majeur == 2 && mineur < 2) { + 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"; @@ -468,17 +468,99 @@ if (mymailw->verbose>3){ return true; } +/* +mg-tetra_hpc_mpi.exe --help + + ================================================= + MG-Tetra_HPC -- MeshGems 2.1-11 (September, 2015) + ================================================= + + Distene SAS + Campus Teratec + 2, rue de la Piquetterie + 91680 Bruyeres le Chatel + FRANCE + Phone: +33(0)970-650-219 Fax: +33(0)169-269-033 + EMail: + + Running MG-Tetra_HPC (Copyright 2014 by Distene SAS) + date of run: 31-May-2016 AT 09:05:29 + running on : Linux 2.6.32-431.11.2.el6.centos.plus.x86_64 x86_64 + using modules: + MeshGems-Core 2.1-11 + + MeshGems is a Registered Trademark of Distene SAS + + + +Usage: tetra_hpc_mpi.exe [options] + +Options: + + Short option (if it exists) + / Long option + | / Description + | | / + v v v + + --gradation + Sets the size gradation value. + is the desired maximum ratio between 2 adjacent + tetrahedron edges. The closer it is to 1.0, the more uniform the mesh + will be. + Default: 1.05 + + --help + Prints this help. + + --in + Sets the input file. + (MANDATORY) + + --max_size + Sets the desired maximum cell size value. + Default: 0 (no maximum size). + + --min_size + Default: 0 (no minimum size). + Sets the desired minimum cell size value. + + --out + Sets the output file. + If unset, _tetra_hpc is appended to the input file basename. + Using an existing file is forbidden. + Using the same file as --in is forbidden. + + --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 + + +================================================================================ + MG-Tetra_HPC -- MeshGems 2.1-11 (September, 2015) + END OF SESSION - MG-Tetra_HPC (Copyright 2014 by Distene SAS) + compiled Sep 3 2015 12:50:47 on Linux_64 + MeshGems is a Registered Trademark of Distene SAS +================================================================================ + ( Distene SAS + Phone: +33(0)970-650-219 Fax: +33(0)169-269-033 + EMail: ) +*/ + //************************************ int main(int argc, char *argv[]) { bool ok; int i,nb,nbfiles,limit_swap,nbelem_limit_swap,limit_swap_defaut,verbose; + float gradation,min_size,max_size; QString path,pathini,casename,casenamemed,fileskinmed, tmp,cmd,format,format_tetra, - test,menu,launchtetra,background,deletegroups, - ToMergeSubdomains,ToTagSubdomains,ToOutputInterfaces,ToDiscardSubdomains, - version="V3.0 (MED3+tetra-hpc)"; + test,launchtetra,background,multithread,deletegroups, + version="V4.0 (MED3 + tetra-hpc v2.3 Sept 2016)"; char *chelp=NULL, *ccasename=NULL, @@ -486,31 +568,27 @@ int main(int argc, char *argv[]) *cmedname=NULL, *climitswap=NULL, *cverbose=NULL, - *ctest=NULL, - *cmenu=NULL, *claunchtetra=NULL, - *cToMergeSubdomains=NULL, - *cToTagSubdomains=NULL, - *cToOutputInterfaces=NULL, - *cToDiscardSubdomains=NULL, + *cgradation=NULL, + *cmin_size=NULL, + *cmax_size=NULL, *cbackground=NULL, + *cmultithread=NULL, *cdeletegroups=NULL; for (i = 0; i < argc; i++){ if (!strncmp (argv[i], "--help", sizeof ("--help"))) chelp = &(argv[i][0]); else if (!strncmp (argv[i], "--casename=", sizeof ("--casename"))) ccasename = &(argv[i][sizeof ("--casename")]); else if (!strncmp (argv[i], "--number=", sizeof ("--number"))) cnumber = &(argv[i][sizeof ("--number")]); - else if (!strncmp (argv[i], "--medname=", sizeof ("--medname"))) cmedname = &(argv[i][sizeof ("--medname")]); else if (!strncmp (argv[i], "--limitswap=", sizeof ("--limitswap"))) climitswap = &(argv[i][sizeof ("--limitswap")]); + else if (!strncmp (argv[i], "--medname=", sizeof ("--medname"))) cmedname = &(argv[i][sizeof ("--medname")]); else if (!strncmp (argv[i], "--verbose=", sizeof ("--verbose"))) cverbose = &(argv[i][sizeof ("--verbose")]); - else if (!strncmp (argv[i], "--test=", sizeof ("--test"))) ctest = &(argv[i][sizeof ("--test")]); - else if (!strncmp (argv[i], "--menu=", sizeof ("--menu"))) cmenu = &(argv[i][sizeof ("--menu")]); else if (!strncmp (argv[i], "--launchtetra=", sizeof ("--launchtetra"))) claunchtetra = &(argv[i][sizeof ("--launchtetra")]); - else if (!strncmp (argv[i], "--merge_subdomains=", sizeof ("--merge_subdomains"))) cToMergeSubdomains = &(argv[i][sizeof ("--")]); - else if (!strncmp (argv[i], "--tag_subdomains=", sizeof ("--tag_subdomains"))) cToTagSubdomains = &(argv[i][sizeof ("--")]); - else if (!strncmp (argv[i], "--output_interfaces=", sizeof ("--output_interfaces"))) cToOutputInterfaces = &(argv[i][sizeof ("--")]); - else if (!strncmp (argv[i], "--discard_subdomains=", sizeof ("--discard_subdomains"))) cToDiscardSubdomains = &(argv[i][sizeof ("--")]); + else if (!strncmp (argv[i], "--gradation=", sizeof ("--gradation"))) cgradation = &(argv[i][sizeof ("--gradation")]); + else if (!strncmp (argv[i], "--min_size=", sizeof ("--min_size"))) cmin_size = &(argv[i][sizeof ("--min_size")]); + else if (!strncmp (argv[i], "--max_size=", sizeof ("--max_size"))) cmax_size = &(argv[i][sizeof ("--max_size")]); else if (!strncmp (argv[i], "--background=", sizeof ("--background"))) cbackground = &(argv[i][sizeof ("--background")]); + else if (!strncmp (argv[i], "--multithread=", sizeof ("--multithread"))) cmultithread = &(argv[i][sizeof ("--multithread")]); else if (!strncmp (argv[i], "--deletegroups=", sizeof ("--deletegroups"))) cdeletegroups = &(argv[i][sizeof ("--deletegroups")]); } @@ -525,22 +603,19 @@ int main(int argc, char *argv[]) " --medname : path and name of output MED files\n"<< " --limitswap : max size of working cpu memory (Mo) (before swapping on .temp files)\n"<< " --verbose : trace of execution (0->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"<< + " --launchtetra : launch mg_tetra_hpc on files casename.mesh and option number,\n"<< + " else only use existing input/output files\n"<< + " --gradation : the desired maximum ratio between 2 adjacent tetrahedron edges (Default 1.05). The closer it is to 1.0\n"<< + " --min_size : the desired maximum cell size value (Default: 0 no maximum size)\n"<< + " --max_size : the desired minimum cell size value (Default: 0 no minimum size)\n"<< " --background : force background mode from launch tetra-hpc and generation of final MED files (big meshes)\n"<< + " --multithread : launch mg_tetra_hpc multithread version, else mpi version\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"; + std::cout<<"example:\n tetrahpc2med --casename=/tmp/GHS3DPRL --number=2 --medname=DOMAIN "<< + "--verbose=0 --launchtetra=no\n\n"; return 1; //no output files } @@ -563,12 +638,13 @@ int main(int argc, char *argv[]) std::cerr<<"--number: a positive integer is expected\n\n"; return 1; } - if (nbfiles>2048){ //delirium in 2014 + if (nbfiles>2048){ //delirium in 2016 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){ @@ -583,10 +659,7 @@ int main(int argc, char *argv[]) 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; @@ -601,46 +674,54 @@ int main(int argc, char *argv[]) } } - 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"; + gradation=1.05; //default + if (cgradation){ + tmp=cgradation; + gradation=tmp.toFloat(&ok); + if (!ok){ + std::cerr<<"--gradation: a float { 0; ]1,3] } is expected\n\n"; + return 1; + } + if (gradation>3.){ + std::cerr<<"--gradation: a float <= 3. is expected\n\n"; + return 1; + } + if (gradation<0.){ + std::cerr<<"--gradation: a float >= 0. is expected\n\n"; + return 1; + } } - ToOutputInterfaces="no"; //default - if (cToOutputInterfaces){ - tmp=cToOutputInterfaces; - if (tmp=="yes") ToOutputInterfaces="yes"; + if (cmin_size){ + tmp=cmin_size; + min_size=tmp.toFloat(&ok); + if (!ok){ + std::cerr<<"--min_size: a float >= 0. is expected\n\n"; + return 1; + } + if (gradation<0.){ + std::cerr<<"--min_size: a float >= 0. is expected\n\n"; + return 1; + } } - ToDiscardSubdomains="no"; //default - if (cToDiscardSubdomains){ - tmp=cToDiscardSubdomains; - if (tmp=="yes") ToDiscardSubdomains="yes"; + if (cmax_size){ + tmp=cmax_size; + max_size=tmp.toFloat(&ok); + if (!ok){ + std::cerr<<"--max_size: a float >= 0. is expected\n\n"; + return 1; + } + if (gradation<0.){ + std::cerr<<"--max_size: a float >= 0. is expected\n\n"; + return 1; + } } background="no"; //default @@ -649,24 +730,13 @@ int main(int argc, char *argv[]) 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; + multithread="no"; //default + if (cmultithread){ + tmp=cmultithread; + if (tmp=="yes") multithread="yes"; } + int n=casenamemed.count('/'); if (n>0) path=casenamemed.section('/',-n-1,-2)+"/"; @@ -689,8 +759,8 @@ int main(int argc, char *argv[]) casename.truncate(20); } - /*std::cout<<"CaseNameMed="<0) - std::cout<<"tetrahpc2med "< " + path + "tetrahpc.log"; + std::cout<<"\nlaunch tetra_hpc command:"<< + "\n "< "+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); + mymailw->for_multithread=false; + if (multithread=="yes") mymailw->for_multithread=true; ghs3dprl_msg_parser handler; //constructor later maybe //handler.verbose=true; @@ -778,13 +847,19 @@ int main(int argc, char *argv[]) format=format.sprintf("%d",nbfiles); int nbf=format.length(); format=format.sprintf(".%%0%dd.%%0%dd",nbf,nbf); - format_tetra=".%05d"; + format_tetra=".%06d"; 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 + //default 1GOctet/8(for float) + nbelem_limit_swap=limit_swap*1000000; //100% + CVWtab::memorymax=nbelem_limit_swap; + mymailw->nbelem_limit_swap=nbelem_limit_swap; + + //something like "/home/wambeke/tmp/GHS3DPRL_skin.med" fileskinmed=pathini+casename+"_skin.med"; //fileskinmed="/home/wambeke/tmp/GHS3DPRL_skin.med"; diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt index 913648c..930ba7d 100644 --- a/src/tools/CMakeLists.txt +++ b/src/tools/CMakeLists.txt @@ -23,7 +23,9 @@ SET(_bin_SCRIPTS facespoints2mesh.py mesh2facespoints.py + testMesh.py + testMeshTest.py ) # --- rules --- -SALOME_INSTALL_SCRIPTS("${_bin_SCRIPTS}" ${SALOME_INSTALL_SCRIPT_PYTHON}) \ No newline at end of file +SALOME_INSTALL_SCRIPTS("${_bin_SCRIPTS}" ${SALOME_INSTALL_SCRIPT_PYTHON}) diff --git a/src/tools/testMesh.py b/src/tools/testMesh.py new file mode 100644 index 0000000..cf3a206 --- /dev/null +++ b/src/tools/testMesh.py @@ -0,0 +1,816 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# %% LICENSE_SALOME_CEA_BEGIN +# Copyright (C) 2008-2016 CEA/DEN +# +# 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, or (at your option) any later version. +# +# 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 +# %% LICENSE_END + + +""" +run coherency tests on one and some mesh. +initially used for test output(s) mg_tetra_hpc_mpi.exe + +WARNING: is for small meshes, obviously no optimisation. +WARNING: printing and .mesh indices are 1 to n when stored list python 0 to n-1 + +example linux usage: +- simple run: + ./testMesh.py --verbose --testall --files ./GHS3DPRL_out.000001.mesh ./GHS3DPRL_out.000002.mesh + ./testMesh.py -a -f /tmp/GHS3DPRL_out.00000?.mesh +""" + +import os +import sys +import platform +import argparse as AP +import pprint as PP #pretty print + +verbose = False + +OK = "ok" +KO = "KO" +OKSYS = 0 #for linux +KOSYS = 1 #for linux + + +######################################### +# utilities + +def okToSys(aResult, verbose=False): + """to get windows or linux result of script""" + + def extendList(alist): + """utility extend list of lists of string results with ok or KO""" + #bad: list(itertools.chain.from_list(alist)) iterate on str + res = [] + if type(alist) != list: + return [alist] + else: + for i in alist: + if type(i) == str: + res.append(i) + else: + res.extend(extendList(i)) + return res + + resList = extendList(aResult) + if resList == []: + if verbose: print("WARNING: result no clear: []") + return KOSYS + + rr = OK + for ri in resList: + if ri[0:2] != OK: + if verbose: print ri + rr = KO + + if verbose: print("INFO: result: %s" % rr) + if rr == OK: + return OKSYS + else: + return KOSYS + +def getDirAndName(datafile): + path, namefile = os.path.split(os.path.realpath(datafile)) + rootpath = os.getcwd() + return (path, rootpath, namefile) + +def resumeList(aList): + if len(aList) == 0: + return [] + if len(aList) < 3: + return aList + res = [aList[0], "...", aList[-1]] + return res + +def resumeLines(aList, ilines): + if verbose: print("INFO: resumeLines", ilines) + if len(aList) == 0: + return [] + if len(aList) < 3: + return aList + res = [] + for i in ilines: + if i != None: # if not existing tetrahedra for example + resi = [ii.strip("\n") for ii in aList[i:i+4]] + resi.append("...") + res.append(resi) + return res + + +######################################### +class XXVert(object): + """Vertices, Nodes""" + def __init__(self, x, y, z, color=0, indexglobal=0): + self.x = x + self.y = y + self.z = z + self.color = color + self.indexglobal = indexglobal + + def compare(self, vb, args, withAll=True): + if self.x != vb.x: return False + if self.y != vb.y: return False + if self.z != vb.z: return False + if withAll: + if args.withColor: + if self.color != vb.color: return False + if args.withIndex: + if self.indexglobal != vb.indexglobal: return False + return True + + def __eq__(self, vb): + """equality test without color or indexglobal""" + #print "vertice equality" + if self.x != vb.x: return False + if self.y != vb.y: return False + if self.z != vb.z: return False + return True + + def __ne__(self, vb): + """inequality test without color or indexglobal""" + #print "vertice inequality" + if self.x == vb.x and self.y == vb.y and self.z != vb.z: + return True + return False + + def __repr__(self): + return "XXVert(%.4f %.4f %.4f (%i %i))" % \ + (self.x, self.y, self.z, self.color, self.indexglobal) + + def __str__(self): + return "(%s %s %s (%i %i))" % \ + (self.x, self.y, self.z, self.color, self.indexglobal) + + def dist(self, vb): + res = (self.x - vb.x)**2 + (self.y - vb.y)**2 + (self.z -vb.z)**2 + return res**.5 + + + +######################################### +class XXEdge(object): + """Edges, 2 Nodes""" + def __init__(self, a, b, color=0, indexglobal=0): + self.a = a + self.b = b + self.color = color + self.indexglobal = indexglobal + + def compare(self, eb, args): + res = self.a.compare(eb.a, args) and \ + self.b.compare(eb.b, args) + if res: + if args.withColor: + if self.color != eb.color: return False + if args.withIndex: + if self.indexglobal != eb.indexglobal: return False + return res + + def __repr__(self): + return "XXEdge(%i %i (%i %i))" % \ + (self.a, self.b, self.color, self.indexglobal) + + def __str__(self): + return "(%i %i (%i %i))" % \ + (self.a, self.b, self.color, self.indexglobal) + + def inTria(self, tria, args): + t = [tria.a, tria.b, tria.c] + if not self.a in t: return False + if not self.b in t: return False + return True + + def getVertices(self, mesh): + v1 = mesh.verts[self.a - 1] + v2 = mesh.verts[self.b - 1] + return [v1, v2] + + +######################################### +class XXTria(object): + """Triangles, Faces, 3 nodes""" + def __init__(self, a, b, c, color=0, indexglobal=0): + self.a = a + self.b = b + self.c = c + self.color = color + self.indexglobal = indexglobal + + def compare(self, trb, args): + res = self.a.compare(trb.a, args) and \ + self.b.compare(trb.b, args) and \ + self.c.compare(trb.c, args) + if res: + if args.withColor: + if self.color != trb.color: return False + if args.withIndex: + if self.indexglobal != trb.indexglobal: return False + return res + + def __repr__(self): + return "XXTria(%i %i %i (%i %i))" % \ + (self.a, self.b, self.c, self.color, self.indexglobal) + + def __str__(self): + return "(%i %i %i (%i %i))" % \ + (self.a, self.b, self.c, self.color, self.indexglobal) + + def inTetra(self, tetra, args): + t = [tetra.a, tetra.b, tetra.c, tetra.d] + if not self.a in t: return False + if not self.b in t: return False + if not self.c in t: return False + return True + + def getVertices(self, mesh): + v1 = mesh.verts[self.a - 1] + v2 = mesh.verts[self.b - 1] + v3 = mesh.verts[self.c - 1] + return [v1, v2, v3] + + + +######################################### +class XXTetra(object): + """Tetra, 4 nodes""" + def __init__(self, a, b, c, d, color=0, indexglobal=0): + self.a = a + self.b = b + self.c = c + self.d = d + self.color = color + self.indexglobal = indexglobal + + def compare(self, teb, args): + res = self.a.compare(teb.a, args) and \ + self.b.compare(teb.b, args) and \ + self.c.compare(teb.c, args) and \ + self.d.compare(teb.d, args) + if res: + if args.withColor: + if self.color != teb.color: return False + if args.withIndex: + if self.indexglobal != teb.indexglobal: return False + return res + + def __repr__(self): + return "XXTetra(%i %i %i %i (%i %i))" % \ + (self.a, self.b, self.c, self.d, self.color, self.indexglobal) + + def __str__(self): + return "(%i %i %i %i (%i %i))" % \ + (self.a, self.b, self.c, self.d, self.color, self.indexglobal) + + def getVertices(self, mesh): + v1 = mesh.verts[self.a - 1] + v2 = mesh.verts[self.b - 1] + v3 = mesh.verts[self.c - 1] + v4 = mesh.verts[self.d - 1] + return [v1, v2, v3, v4] + + +######################################### +class XXMesh(object): + """Mesh: vertices, edges, triangles, tetrahedra""" + def __init__(self): + self.nameFile = "" + self.verts = [] + self.edges = [] + self.trias = [] + self.tetras = [] + + def initFromFileMesh(self, fileName, args, withGlobal=True): + if not os.path.isfile(fileName): + raise Exception("ERROR: inexisting file '%s'" % fileName) + with open(fileName, "r") as f: + lines = f.readlines() + iverts, iedges, itrias, itetras = self.getIndexInMeshFile(lines) + self.verts = self.getMeshVerts(lines, iverts) + self.edges = self.getMeshEdges(lines, iedges) + self.trias = self.getMeshTrias(lines, itrias) + self.tetras = self.getMeshTetras(lines, itetras) + self.nameFile = fileName + if args.globalNumerotation == True and withGlobal==True: + self.initFromFileGlobal(fileName, args) + if verbose: + print("\nINFO: initFromFileMesh: read file: %s" % str(self)) + print(self.strResume()) + print(PP.pformat(resumeLines(lines, [iverts, iedges, itrias, itetras]))) + + def initFromFileGlobal(self, fileNameMeshOrGlobal, args): + shortname, extension = os.path.splitext(fileNameMeshOrGlobal) + if extension == ".mesh": + fileName = shortname + ".global" + elif extension == "global": + fileName = fileNameMeshOrGlobal + else: + raise Exception("ERROR: initFromFileGlobal: unexpected file '%s'" % fileName) + if not os.path.isfile(fileName): + raise Exception("ERROR: initFromFileGlobal: inexisting file '%s'" % fileName) + + with open(fileName, "r") as f: + lines = f.readlines() + nbverts, nbedges, nbtrias, nbtetras = [int(i) for i in lines[0].split()] + if verbose: + print("\nINFO: initFromFileGlobal: read file: %s" % str(self)) + print(" nbverts %i\n nbedges %i\n nbtrias %i\n nbtetras %i" % (nbverts, nbedges, nbtrias, nbtetras)) + if nbverts != len(self.verts): + raise Exception("ERROR: in file '%s' unexpected number of Vertices %i<>%i" % (fileName, nbverts, len(self.verts))) + if nbedges != len(self.edges): + raise Exception("ERROR: in file '%s' unexpected number of Edges %i<>%i" % (fileName, nbedges, len(self.edges))) + if nbtrias != len(self.trias): + raise Exception("ERROR: in file '%s' unexpected number of Triangles %i<>%i" % (fileName, nbtrias, len(self.trias))) + if nbtetras != len(self.tetras): + raise Exception("ERROR: in file '%s' unexpected number of Tetrahedra %i<>%i" % (fileName, nbtetras, len(self.tetras))) + i = 1 #begin index line 1 + for ii in range(nbverts): + self.verts[ii].indexglobal = long(lines[i]) + i +=1 + for ii in range(nbedges): + self.edges[ii].indexglobal = long(lines[i]) + i +=1 + for ii in range(nbtrias): + self.trias[ii].indexglobal = long(lines[i]) + i +=1 + for ii in range(nbtetras): + self.tetras[ii].indexglobal = long(lines[i]) + i +=1 + + + def __repr__(self): + return "XXMesh(nameFile='%s', nbverts=%i, nbedges=%i, nbtrias=%i, nbtetras=%i)" % \ + (self.nameFile, len(self.verts), len(self.edges), len(self.trias), len(self.tetras)) + + def strResume(self): + res = str(self) + contents = { + "Vertices": resumeList(self.verts), + "Edges": resumeList(self.edges), + "Triangles": resumeList(self.trias), + "Tetrahedra": resumeList(self.tetras), + } + res = res + "\n" + PP.pformat(contents) + return res + + def getIndexInMeshFile(self, lines): + res = [] + for s in ["Vertices", "Edges", "Triangles", "Tetrahedra"]: + try: + i = lines.index(s+"\n") + except: + i = None + res.append(i) + return res + + def getMeshVerts(self, lines, i): + res=[] + try: + idep = i+2 + ilen = int(lines[i+1]) + ifin = idep+ilen + for line in lines[idep:ifin]: + li = line.split(" ") + x, y, z, color = float(li[0]), float(li[1]), float(li[2]), int(li[3]) + res.append(XXVert(x, y, z, color)) + return res + except: + return res + + def getMeshEdges(self, lines, i): + res=[] + try: + idep = i+2 + ilen = int(lines[i+1]) + ifin = idep+ilen + for line in lines[idep:ifin]: + li = line.split(" ") + a, b, color = int(li[0]), int(li[1]), int(li[2]) + res.append(XXEdge(a, b, color)) + return res + except: + return res + + def getMeshTrias(self, lines, i): + res=[] + try: + idep = i+2 + ilen = int(lines[i+1]) + ifin = idep+ilen + for line in lines[idep:ifin]: + li = line.split(" ") + a, b, c, color = int(li[0]), int(li[1]), int(li[2]), int(li[3]) + res.append(XXTria(a, b, c, color)) + return res + except: + return res + + def getMeshTetras(self, lines, i): + res=[] + try: + idep = i+2 + ilen = int(lines[i+1]) + ifin = idep+ilen + for line in lines[idep:ifin]: + li = line.split(" ") + a, b, c, d, color = int(li[0]), int(li[1]), int(li[2]), int(li[3]), int(li[4]) + res.append(XXTetra(a, b, c, d, color)) + return res + except: + return res + + def haveVertsDistinct(self, args): + """stop a first KO""" + i = 0 + verts = self.verts + for v1 in verts[:-1]: + i += 1 + j = i + for v2 in verts[i:]: + j += 1 + if v1.compare(v2, args): + #printing indices 1 to n + print("ERROR: %s vert[%i] equal vert[%i]: v1=%s v2=%s" % (self.nameFile, i, j, v1, v2)) + return KO + " ERROR: %s some equal vertices" % self.nameFile #stop a first KO + return OK + " INFO: no equal vertices" + + def getVertices(self, elem): + """functionnal raccourci to XXElem.getVertices(XXMesh)""" + return elem.getVertices(self) + + def compareListOfVertices(self, v1s, v2s, ordered=False): + """not ordered for now""" + if ordered: + res = [i for i, j in zip(v1s, v2s) if i == j] + return len(res)==len(v1s) + else: + res = 0 + for i in v1s: + for j in v2s: + if i == j: + res += 1 + break + return res==len(v1s) + + + def getCommonVerts(self, mesh, args): + res = [] + for v1 in self.verts: + for v2 in mesh.verts: + if v1.compare(v2, args, withAll=False): + res.append((v1, v2)) + return res + + def getVertices(self, elem): + return elem.getVertices(self) + + def getCommonEdges(self, mesh, args): + res = [] + for e1 in self.edges: + v1s = self.getVertices(e1) + for e2 in mesh.edges: + v2s = mesh.getVertices(e2) + if self.compareListOfVertices(v1s, v2s): + res.append((e1, e2)) + return res + + def getCommonTriangles(self, mesh, args): + res = [] + for e1 in self.trias: + v1s = self.getVertices(e1) + for e2 in mesh.trias: + v2s = mesh.getVertices(e2) + if self.compareListOfVertices(v1s, v2s): + res.append((e1, e2)) + return res + + def getCommonTetras(self, mesh, args): + res = [] + for e1 in self.tetras: + v1s = self.getVertices(e1) + for e2 in mesh.tetras: + v2s = mesh.getVertices(e2) + if self.compareListOfVertices(v1s, v2s): + res.append((e1, e2)) + return res + + def areEdgesInTrias(self, args): + """stop a first KO""" + done = False + i = 0 + edges = self.edges + trias = self.trias + res = OK + " INFO: %s all edges in trias" % self.nameFile + for e in edges: + i += 1 + j = 0 + found = False + for t in trias: + j += 1 + if e.inTria(t, args): + #if verbose: print("INFO: %s edges[%i] in trias[%i]: edge=%s tria=%s" % (self.nameFile, i, j, e, t)) + found = True + break + if not found: + print("ERROR: %s edges[%i] not in trias: edge=%s" % (self.nameFile, i, e)) + if verbose and not done: + print("Triangles:\n%s" % PP.pformat(self.trias)) + done = True + res = KO+" ERROR: %s some edges not in trias" % (self.nameFile) + return res + + + def areTriasInTetras(self, args): + """no stop a first KO""" + done = False + i = 0 + trias = self.trias + tetras = self.tetras + if tetras == []: #supposed skin without tetrahedra + res = OK +" WARNING: %s no tetrahedra in mesh" % (self.nameFile) + return res + res = OK + " INFO: %s all trias in tetras" % self.nameFile + for t in trias: + i += 1 + j = 0 + found = False + for h in tetras: + j += 1 + if t.inTetra(h, args): + #if verbose: print("INFO: %s trias[%i] in tetras[%i]: tria=%s tetra=%s" % (self.nameFile, i, j, t, h)) + found = True + break + if not found: + if verbose: print("ERROR: %s trias[%i] not in tetras: tria=%s" % (self.nameFile, i, t)) + if verbose and not done: + print("INFO: Tetrahedra:\n%s" % PP.pformat(self.tetras)) + done = True + res = KO+" ERROR: %s some trias not in tetras" % (self.nameFile) + return res + + def testIntersection(self, mesh, args): + """intersection coherency between self and mesh""" + + def storeAndInfoIntersection(): + """used as macro: avoid duplicate code""" + #store info in args to use later... + args.intersections[title+name] = commons + if commons == []: + res.append(OK + " INFO: no %s" % title+name) + else: + res.append(OK + " INFO: existing %s" % title+name) + return + + res=[] + name = "%s<->%s" % (self.nameFile, mesh.nameFile) + + title = "Vertices intersection: " + commons = self.getCommonVerts(mesh, args) + storeAndInfoIntersection() + + title = "Edges intersection: " + commons = self.getCommonEdges(mesh, args) + storeAndInfoIntersection() + + title = "Triangles intersection: " + commons = self.getCommonTriangles(mesh, args) + storeAndInfoIntersection() + + title = "Tetrahedra intersection: " + commons = self.getCommonTetras(mesh, args) + storeAndInfoIntersection() + + return res + + def testIndexGlobal(self, mesh, args): + """global index coherency between self and mesh""" + + def storeAndInfoIndexGlobal(): + """used as macro: avoid duplicate code""" + #store info in args to use later... + args.indexglobal[title+name] = problems + if verbose: print("\nINFO: %s\n%s" % (title+name, PP.pformat(problems))) + if problems == []: + res.append(OK + " INFO: coherent %s" % title+name) + else: + res.append(KO + " ERROR: some problems %s" % title+name) + return + + def testIndexGlobal(): + """used as macro: avoid duplicate code""" + nameElem = title.split(' ')[0] + #something like 'Vertices intersection: /tmp/GHS3DPRL_out.000002.mesh<->/tmp/GHS3DPRL_out.000003.mesh' + commonsTitle = nameElem + " intersection: "+ name + #if verbose: print "testIndexGlobal",title,commonsTitle + try: + intersection = args.intersections[commonsTitle] + except: + intersection = [] + problems = [] + for ii, jj in intersection: + if ii.indexglobal != jj.indexglobal: + problems.append((ii, jj)) + return problems + + res=[] + name = "%s<->%s" % (self.nameFile, mesh.nameFile) + + title = "Vertices indexglobal: " + problems = testIndexGlobal() + storeAndInfoIndexGlobal() + + title = "Edges indexglobal: " + problems = testIndexGlobal() + storeAndInfoIndexGlobal() + + title = "Triangles indexglobal: " + problems = testIndexGlobal() + storeAndInfoIndexGlobal() + + title = "Tetrahedra indexglobal: " + problems = testIndexGlobal() + storeAndInfoIndexGlobal() + + return res + + +######################################### +# tests + +def testAll(args): + """test all on meshes from tetra_hpc_mpi""" + res = [] + if verbose: print("\n*****testAll*****\n") + args.skinMesh = None + if args.skinInputFile != None: + args.skinMesh = XXMesh() + #a priori no global numerotation file.global for input tetra_hpc_mpi mesh + args.skinMesh.initFromFileMesh(args.skinInputFile, args, withGlobal=False) + res.append(testStandaloneMesh(args.skinMesh, args)) + print("\nINFO: testAll skin input file:\n%s" % (PP.pformat(args.skinMesh))) + + meshes = [] + for fileName in args.files: + xxmesh = XXMesh() + xxmesh.initFromFileMesh(fileName, args) + meshes.append(xxmesh) + print("\nINFO: testAll ouput files:\n%s\n" % (PP.pformat(meshes))) + #test coherence of one by one meshes + for mesh in meshes: + res.append(testStandaloneMesh(mesh, args)) + #test coherence of intersections an global numerotation of tetra_hpc_mpi output meshes + res.append(testParallelMesh(meshes, args)) + res.append(testParallelMeshAndSkin(meshes, args)) + res.append(testParallelMeshAndSkinColor(meshes, args)) + return res + + +def testStandaloneMesh(mesh, args): + """test coherence of one mesh alone""" + if verbose: print("\nINFO: testStandaloneMesh:\n%s" % PP.pformat(mesh)) + res = [] + res.append(mesh.haveVertsDistinct(args)) + res.append(mesh.areEdgesInTrias(args)) + res.append(mesh.areTriasInTetras(args)) + return res + + +def testParallelMesh(meshes, args): + """test intersection and overriding in tetra_hpc_mpi outputs GHS3DPRL_out.00000?.mesh""" + i = 0 + res = [] + args.intersections = {} + args.indexglobal = {} + for m1 in meshes[:-1]: + i += 1 + for m2 in meshes[i:]: + res.append(m1.testIntersection(m2, args)) + res.append(m1.testIndexGlobal(m2, args)) + if verbose: + print("\nINFO: intersections\n%s" % PP.pformat(args.intersections)) + print("\nINFO: indexglobal\n%s" % PP.pformat(args.indexglobal)) + return res + +def testParallelMeshAndSkin(meshes, args): + """test coherency between input skin and tetra_hpc_mpi outputs GHS3DPRL_out.00000?.mesh""" + res = [] + if args.skinMesh == None: + print("INFO: no skin Mesh for testing intersectionsSkin\n") + res = OK + "INFO: no skin Mesh for testing intersectionsSkin" + return res + nbtriasskin = len(args.skinMesh.trias) + for m1 in meshes: + res.append(args.skinMesh.testIntersection(m1, args)) + res.append(args.skinMesh.testIndexGlobal(m1, args)) + + #test total Triangles in output parallel meshes vs input skin mesh + if True: + kk = {} + nbtriaspara = 0 + for k in args.intersections.keys(): + if args.skinMesh.nameFile in k: + ll = len(args.intersections[k]) + if "Triangles intersection" in k: + nbtriaspara += ll + kk[k] = len(args.intersections[k]) + print("INFO: skin intersections\n%s\n" % PP.pformat(kk)) + if nbtriaspara < nbtriasskin: + res.append(KO + " ERROR: problem all skin triangles not in parallel meshes: %i<->%i" % (nbtriasskin, nbtriaspara)) + return res + +def testParallelMeshAndSkinColor(meshes, args): + """test coherency between color input skin and tetra_hpc_mpi outputs GHS3DPRL_out.00000?.mesh""" + res = [] + if args.color == True: + res.append(KO + " ERROR: test color TODO!!!") + else: + res.append(OK + " WARNING: test color not done") + return res + +if __name__ == '__main__': + parser = AP.ArgumentParser(description='launch test(s) on tetra_hpc_mpi mesh(es)', argument_default=None) + parser.add_argument( + '-a', '--testAll', + help='test all on all meshes', + action='store_true', + ) + parser.add_argument( + '-v', '--verbose', + help='set verbose, for deep debug', + action='store_true', + ) + parser.add_argument( + '-g', '--globalNumerotation', + help='read and set files .global, if associated', + action='store_true', + ) + parser.add_argument( + '-c', '--color', + help='read and test with color', + action='store_true', + ) + parser.add_argument( + '-f', '--files', + help='launch test(s) on file(s)', + nargs='*', + metavar='.../file.mesh' + ) + parser.add_argument( + '-s', '--skinInputFile', + help='launch test(s) on tetra_hpc_mpi input file', + nargs='?', + metavar='.../skinInputFile.mesh' + ) + """ + parser.add_argument( + '-x', '--xoneargument', + nargs='?', + metavar='0|1', + choices=['0', '1'], + help='one argument, for example', + default='0' + ) + """ + + + """ + args is Namespace, use it as global to store + parameters, data, used arrays and results and other... + """ + args = parser.parse_args() + + verbose = args.verbose + if verbose: print("INFO: args:\n%s" % PP.pformat(args)) + + if len(sys.argv) == 1: #no args as --help + parser.print_help() + sys.exit(KOSYS) + + if args.files == None: + print("\nERROR: Nothing to do: no files\n%s" % PP.pformat(args)) + parser.print_help() + sys.exit(KOSYS) + + if args.testAll: + result = testAll(args) + else: + result = KO + print("\nERROR: Nothing to do:\n%s" % PP.pformat(args)) + sys.exit(okToSys(result, verbose=True)) + diff --git a/src/tools/testMeshTest.py b/src/tools/testMeshTest.py new file mode 100644 index 0000000..4930a55 --- /dev/null +++ b/src/tools/testMeshTest.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# %% LICENSE_SALOME_CEA_BEGIN +# Copyright (C) 2008-2016 CEA/DEN +# +# 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, or (at your option) any later version. +# +# 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 +# %% LICENSE_END + + +import unittest +import testMesh as TM +from argparse import Namespace + +verbose = False + +class TestCase(unittest.TestCase): + + def test_010(self): + self.failUnlessEqual(TM.okToSys([]), TM.KOSYS) + self.failUnlessEqual(TM.okToSys([[]]), TM.KOSYS) + + res = TM.OK + " blah blah 0" + self.failUnlessEqual(TM.okToSys([[res]]), TM.OKSYS) + self.failUnlessEqual(TM.okToSys(res), TM.OKSYS) + res = [res] + self.failUnlessEqual(TM.okToSys(res), TM.OKSYS) + res.append(TM.OK + " blah blah 1") + self.failUnlessEqual(TM.okToSys(res), TM.OKSYS) + res.append([TM.OK + " blah blah 2"]) + self.failUnlessEqual(TM.okToSys(res), TM.OKSYS) + res.append([TM.KO + " blah blah 3"]) + self.failUnlessEqual(TM.okToSys(res), TM.KOSYS) + self.failUnlessEqual(TM.okToSys([]), TM.KOSYS) + res = [[[res]],[TM.OK + " blah blah 4"],[]] + self.failUnlessEqual(TM.okToSys(res), TM.KOSYS) + + def test_030(self): + a = TM.XXVert(1, 1, 1) + b = TM.XXVert(2, 2, 2) + c = TM.XXVert(1., 1., 1., 3, 4) + self.failUnlessEqual(a==c, True) + + from argparse import Namespace + args = Namespace(withColor=True, withIndex=True) + self.failUnlessEqual(a.compare(c, args, withAll=True), False) + self.failUnlessEqual(a.compare(c, args, withAll=False), True) + + args = Namespace(withColor=False, withIndex=False) + self.failUnlessEqual(a.compare(c, args, withAll=True), True) + + self.failUnlessEqual(a==b, False) + self.failUnlessEqual(a.dist(b), 3**.5) + + self.failUnlessEqual(str(c), '(1.0 1.0 1.0 (3 4))') + self.failUnlessEqual(c.__repr__(), 'XXVert(1.0000 1.0000 1.0000 (3 4))') + + +if __name__ == '__main__': + verbose = False + unittest.main() + pass -- 2.39.2