From 51b7f08bdb9757517575bf964ce4c89785e2b2f1 Mon Sep 17 00:00:00 2001 From: ageay Date: Thu, 4 Apr 2013 08:47:30 +0000 Subject: [PATCH] MEDMEM suppression --- idl/CMakeLists.txt | 2 - idl/Compo1Py.idl | 36 - idl/MED_Gen.idl | 84 - idl/Makefile.am | 2 +- src/MEDMEM/CMakeLists.txt | 81 - src/MEDMEM/DataTest/Data/elle_2D_QT_2x2.sauve | 98 - src/MEDMEM/DataTest/Data/elle_2D_QT_4x4.sauve | 175 - .../DataTest/Data/elle_3D_HPr_4x4x4.sauve | 1292 ----- src/MEDMEM/DataTest/Data/maill.0.med | Bin 100351 -> 0 bytes src/MEDMEM/DataTest/Data/mesh.med | Bin 57535 -> 0 bytes src/MEDMEM/DataTest/Data/pointe.med | Bin 80010 -> 0 bytes src/MEDMEM/DataTest/Data/zzzz121b.med | Bin 172158 -> 0 bytes src/MEDMEM/DataTest/Maillages.txt | 5 - src/MEDMEM/DataTest/README | 54 - src/MEDMEM/DataTest/Ref/RtestUCellModel | 244 - .../DataTest/Ref/RtestUGeoNameMeshEntities | 53 - src/MEDMEM/DataTest/constituedump.sh | 80 - src/MEDMEM/DataTest/testreadCoordinate.sh | 86 - src/MEDMEM/DataTest/testreadEntete.sh | 85 - src/MEDMEM/DataTest/tous.sh | 55 - src/MEDMEM/Doxyfile_med_devel.in | 196 - src/MEDMEM/Doxyfile_med_user.in | 210 - src/MEDMEM/MEDMEM.hxx | 53 - src/MEDMEM/MEDMEM_Array.hxx | 801 --- src/MEDMEM/MEDMEM_ArrayConvert.hxx | 315 -- src/MEDMEM/MEDMEM_ArrayInterface.hxx | 108 - src/MEDMEM/MEDMEM_AsciiFieldDriver.hxx | 499 -- src/MEDMEM/MEDMEM_CellModel.cxx | 1546 ------ src/MEDMEM/MEDMEM_CellModel.hxx | 273 - src/MEDMEM/MEDMEM_ConnectZone.cxx | 280 -- src/MEDMEM/MEDMEM_ConnectZone.hxx | 105 - src/MEDMEM/MEDMEM_Connectivity.cxx | 2072 -------- src/MEDMEM/MEDMEM_Connectivity.hxx | 544 -- src/MEDMEM/MEDMEM_Coordinate.cxx | 315 -- src/MEDMEM/MEDMEM_Coordinate.hxx | 122 - src/MEDMEM/MEDMEM_DriverFactory.cxx | 283 -- src/MEDMEM/MEDMEM_DriverFactory.hxx | 86 - src/MEDMEM/MEDMEM_DriverFactory.ixx | 219 - src/MEDMEM/MEDMEM_DriverTools.cxx | 1469 ------ src/MEDMEM/MEDMEM_DriverTools.hxx | 579 --- src/MEDMEM/MEDMEM_DriversDef.cxx | 178 - src/MEDMEM/MEDMEM_DriversDef.hxx | 118 - src/MEDMEM/MEDMEM_EnsightFieldDriver.cxx | 1676 ------ src/MEDMEM/MEDMEM_EnsightFieldDriver.hxx | 161 - src/MEDMEM/MEDMEM_EnsightMedDriver.cxx | 314 -- src/MEDMEM/MEDMEM_EnsightMedDriver.hxx | 113 - src/MEDMEM/MEDMEM_EnsightMeshDriver.cxx | 3320 ------------ src/MEDMEM/MEDMEM_EnsightMeshDriver.hxx | 152 - src/MEDMEM/MEDMEM_EnsightUtils.cxx | 2926 ----------- src/MEDMEM/MEDMEM_EnsightUtils.hxx | 941 ---- src/MEDMEM/MEDMEM_Exception.cxx | 184 - src/MEDMEM/MEDMEM_Exception.hxx | 86 - src/MEDMEM/MEDMEM_Extractor.cxx | 1590 ------ src/MEDMEM/MEDMEM_Extractor.hxx | 107 - src/MEDMEM/MEDMEM_Family.cxx | 407 -- src/MEDMEM/MEDMEM_Family.hxx | 340 -- src/MEDMEM/MEDMEM_Field.cxx | 479 -- src/MEDMEM/MEDMEM_Field.hxx | 4479 ----------------- src/MEDMEM/MEDMEM_FieldConvert.hxx | 106 - src/MEDMEM/MEDMEM_FieldForward.hxx | 32 - src/MEDMEM/MEDMEM_GMesh.cxx | 1403 ------ src/MEDMEM/MEDMEM_GMesh.hxx | 277 - src/MEDMEM/MEDMEM_GaussLocalization.cxx | 1249 ----- src/MEDMEM/MEDMEM_GaussLocalization.hxx | 216 - src/MEDMEM/MEDMEM_GenDriver.cxx | 197 - src/MEDMEM/MEDMEM_GenDriver.hxx | 155 - src/MEDMEM/MEDMEM_GibiMeshDriver.cxx | 4246 ---------------- src/MEDMEM/MEDMEM_GibiMeshDriver.hxx | 494 -- src/MEDMEM/MEDMEM_Grid.cxx | 1213 ----- src/MEDMEM/MEDMEM_Grid.hxx | 253 - src/MEDMEM/MEDMEM_Group.cxx | 159 - src/MEDMEM/MEDMEM_Group.hxx | 138 - src/MEDMEM/MEDMEM_IndexCheckingPolicy.hxx | 66 - src/MEDMEM/MEDMEM_Init.cxx | 62 - src/MEDMEM/MEDMEM_InterlacingPolicy.hxx | 606 --- src/MEDMEM/MEDMEM_InterlacingTraits.hxx | 76 - src/MEDMEM/MEDMEM_MEDMEMchampLire.cxx | 285 -- src/MEDMEM/MEDMEM_MEDMEMchampLire.hxx | 52 - src/MEDMEM/MEDMEM_MEDMEMgaussEcr.cxx | 199 - src/MEDMEM/MEDMEM_MEDMEMgaussEcr.hxx | 49 - src/MEDMEM/MEDMEM_MEDMEMprofilEcr.cxx | 152 - src/MEDMEM/MEDMEM_MEDMEMprofilEcr.hxx | 48 - src/MEDMEM/MEDMEM_MedFieldDriver.hxx | 236 - src/MEDMEM/MEDMEM_MedFieldDriver.txx | 2248 --------- src/MEDMEM/MEDMEM_MedFileBrowser.cxx | 436 -- src/MEDMEM/MEDMEM_MedFileBrowser.hxx | 93 - src/MEDMEM/MEDMEM_MedMeshDriver.cxx | 3028 ----------- src/MEDMEM/MEDMEM_MedMeshDriver.hxx | 281 -- src/MEDMEM/MEDMEM_MedVersion.cxx | 100 - src/MEDMEM/MEDMEM_MedVersion.hxx | 40 - src/MEDMEM/MEDMEM_Mesh.cxx | 1950 ------- src/MEDMEM/MEDMEM_Mesh.hxx | 640 --- src/MEDMEM/MEDMEM_MeshFuse.cxx | 1060 ---- src/MEDMEM/MEDMEM_MeshFuse.hxx | 129 - src/MEDMEM/MEDMEM_Meshing.cxx | 406 -- src/MEDMEM/MEDMEM_Meshing.hxx | 75 - src/MEDMEM/MEDMEM_ModulusArray.hxx | 157 - src/MEDMEM/MEDMEM_OptionManager.hxx | 123 - src/MEDMEM/MEDMEM_PointerOf.hxx | 267 - src/MEDMEM/MEDMEM_PorflowMeshDriver.cxx | 797 --- src/MEDMEM/MEDMEM_PorflowMeshDriver.hxx | 267 - src/MEDMEM/MEDMEM_RCBase.cxx | 65 - src/MEDMEM/MEDMEM_RCBase.hxx | 60 - src/MEDMEM/MEDMEM_Remapper.cxx | 374 -- src/MEDMEM/MEDMEM_Remapper.hxx | 63 - src/MEDMEM/MEDMEM_STRING.hxx | 96 - src/MEDMEM/MEDMEM_SetInterlacingType.hxx | 41 - src/MEDMEM/MEDMEM_SkyLineArray.cxx | 146 - src/MEDMEM/MEDMEM_SkyLineArray.hxx | 191 - src/MEDMEM/MEDMEM_Support.cxx | 1726 ------- src/MEDMEM/MEDMEM_Support.hxx | 365 -- src/MEDMEM/MEDMEM_Tags.hxx | 38 - src/MEDMEM/MEDMEM_TopLevel.cxx | 46 - src/MEDMEM/MEDMEM_TopLevel.hxx | 73 - src/MEDMEM/MEDMEM_TypeMeshDriver.cxx | 244 - src/MEDMEM/MEDMEM_TypeMeshDriver.hxx | 234 - src/MEDMEM/MEDMEM_Unit.cxx | 57 - src/MEDMEM/MEDMEM_Unit.hxx | 127 - src/MEDMEM/MEDMEM_Utilities.hxx | 171 - src/MEDMEM/MEDMEM_VtkFieldDriver.hxx | 510 -- src/MEDMEM/MEDMEM_VtkMedDriver.cxx | 245 - src/MEDMEM/MEDMEM_VtkMedDriver.hxx | 83 - src/MEDMEM/MEDMEM_VtkMeshDriver.cxx | 549 -- src/MEDMEM/MEDMEM_VtkMeshDriver.hxx | 167 - src/MEDMEM/MEDMEM_define.hxx | 353 -- src/MEDMEM/MEDMEM_nArray.hxx | 404 -- src/MEDMEM/MEDNormalizedUnstructuredMesh.hxx | 61 - src/MEDMEM/MEDNormalizedUnstructuredMesh.txx | 131 - src/MEDMEM/Makefile.am | 166 - src/MEDMEM/PointLocator.cxx | 79 - src/MEDMEM/PointLocator.hxx | 60 - src/MEDMEM/checkScript | 96 - 132 files changed, 1 insertion(+), 61164 deletions(-) delete mode 100644 idl/Compo1Py.idl delete mode 100644 idl/MED_Gen.idl delete mode 100644 src/MEDMEM/CMakeLists.txt delete mode 100644 src/MEDMEM/DataTest/Data/elle_2D_QT_2x2.sauve delete mode 100644 src/MEDMEM/DataTest/Data/elle_2D_QT_4x4.sauve delete mode 100644 src/MEDMEM/DataTest/Data/elle_3D_HPr_4x4x4.sauve delete mode 100644 src/MEDMEM/DataTest/Data/maill.0.med delete mode 100755 src/MEDMEM/DataTest/Data/mesh.med delete mode 100644 src/MEDMEM/DataTest/Data/pointe.med delete mode 100644 src/MEDMEM/DataTest/Data/zzzz121b.med delete mode 100644 src/MEDMEM/DataTest/Maillages.txt delete mode 100644 src/MEDMEM/DataTest/README delete mode 100644 src/MEDMEM/DataTest/Ref/RtestUCellModel delete mode 100644 src/MEDMEM/DataTest/Ref/RtestUGeoNameMeshEntities delete mode 100644 src/MEDMEM/DataTest/constituedump.sh delete mode 100755 src/MEDMEM/DataTest/testreadCoordinate.sh delete mode 100755 src/MEDMEM/DataTest/testreadEntete.sh delete mode 100755 src/MEDMEM/DataTest/tous.sh delete mode 100644 src/MEDMEM/Doxyfile_med_devel.in delete mode 100644 src/MEDMEM/Doxyfile_med_user.in delete mode 100755 src/MEDMEM/MEDMEM.hxx delete mode 100644 src/MEDMEM/MEDMEM_Array.hxx delete mode 100644 src/MEDMEM/MEDMEM_ArrayConvert.hxx delete mode 100644 src/MEDMEM/MEDMEM_ArrayInterface.hxx delete mode 100644 src/MEDMEM/MEDMEM_AsciiFieldDriver.hxx delete mode 100644 src/MEDMEM/MEDMEM_CellModel.cxx delete mode 100644 src/MEDMEM/MEDMEM_CellModel.hxx delete mode 100644 src/MEDMEM/MEDMEM_ConnectZone.cxx delete mode 100644 src/MEDMEM/MEDMEM_ConnectZone.hxx delete mode 100644 src/MEDMEM/MEDMEM_Connectivity.cxx delete mode 100644 src/MEDMEM/MEDMEM_Connectivity.hxx delete mode 100644 src/MEDMEM/MEDMEM_Coordinate.cxx delete mode 100644 src/MEDMEM/MEDMEM_Coordinate.hxx delete mode 100644 src/MEDMEM/MEDMEM_DriverFactory.cxx delete mode 100644 src/MEDMEM/MEDMEM_DriverFactory.hxx delete mode 100644 src/MEDMEM/MEDMEM_DriverFactory.ixx delete mode 100644 src/MEDMEM/MEDMEM_DriverTools.cxx delete mode 100644 src/MEDMEM/MEDMEM_DriverTools.hxx delete mode 100644 src/MEDMEM/MEDMEM_DriversDef.cxx delete mode 100644 src/MEDMEM/MEDMEM_DriversDef.hxx delete mode 100644 src/MEDMEM/MEDMEM_EnsightFieldDriver.cxx delete mode 100644 src/MEDMEM/MEDMEM_EnsightFieldDriver.hxx delete mode 100644 src/MEDMEM/MEDMEM_EnsightMedDriver.cxx delete mode 100644 src/MEDMEM/MEDMEM_EnsightMedDriver.hxx delete mode 100644 src/MEDMEM/MEDMEM_EnsightMeshDriver.cxx delete mode 100644 src/MEDMEM/MEDMEM_EnsightMeshDriver.hxx delete mode 100644 src/MEDMEM/MEDMEM_EnsightUtils.cxx delete mode 100644 src/MEDMEM/MEDMEM_EnsightUtils.hxx delete mode 100644 src/MEDMEM/MEDMEM_Exception.cxx delete mode 100644 src/MEDMEM/MEDMEM_Exception.hxx delete mode 100644 src/MEDMEM/MEDMEM_Extractor.cxx delete mode 100644 src/MEDMEM/MEDMEM_Extractor.hxx delete mode 100644 src/MEDMEM/MEDMEM_Family.cxx delete mode 100644 src/MEDMEM/MEDMEM_Family.hxx delete mode 100644 src/MEDMEM/MEDMEM_Field.cxx delete mode 100644 src/MEDMEM/MEDMEM_Field.hxx delete mode 100644 src/MEDMEM/MEDMEM_FieldConvert.hxx delete mode 100644 src/MEDMEM/MEDMEM_FieldForward.hxx delete mode 100644 src/MEDMEM/MEDMEM_GMesh.cxx delete mode 100644 src/MEDMEM/MEDMEM_GMesh.hxx delete mode 100644 src/MEDMEM/MEDMEM_GaussLocalization.cxx delete mode 100644 src/MEDMEM/MEDMEM_GaussLocalization.hxx delete mode 100644 src/MEDMEM/MEDMEM_GenDriver.cxx delete mode 100644 src/MEDMEM/MEDMEM_GenDriver.hxx delete mode 100644 src/MEDMEM/MEDMEM_GibiMeshDriver.cxx delete mode 100644 src/MEDMEM/MEDMEM_GibiMeshDriver.hxx delete mode 100644 src/MEDMEM/MEDMEM_Grid.cxx delete mode 100644 src/MEDMEM/MEDMEM_Grid.hxx delete mode 100644 src/MEDMEM/MEDMEM_Group.cxx delete mode 100644 src/MEDMEM/MEDMEM_Group.hxx delete mode 100644 src/MEDMEM/MEDMEM_IndexCheckingPolicy.hxx delete mode 100644 src/MEDMEM/MEDMEM_Init.cxx delete mode 100644 src/MEDMEM/MEDMEM_InterlacingPolicy.hxx delete mode 100644 src/MEDMEM/MEDMEM_InterlacingTraits.hxx delete mode 100644 src/MEDMEM/MEDMEM_MEDMEMchampLire.cxx delete mode 100644 src/MEDMEM/MEDMEM_MEDMEMchampLire.hxx delete mode 100644 src/MEDMEM/MEDMEM_MEDMEMgaussEcr.cxx delete mode 100644 src/MEDMEM/MEDMEM_MEDMEMgaussEcr.hxx delete mode 100644 src/MEDMEM/MEDMEM_MEDMEMprofilEcr.cxx delete mode 100644 src/MEDMEM/MEDMEM_MEDMEMprofilEcr.hxx delete mode 100644 src/MEDMEM/MEDMEM_MedFieldDriver.hxx delete mode 100644 src/MEDMEM/MEDMEM_MedFieldDriver.txx delete mode 100644 src/MEDMEM/MEDMEM_MedFileBrowser.cxx delete mode 100644 src/MEDMEM/MEDMEM_MedFileBrowser.hxx delete mode 100644 src/MEDMEM/MEDMEM_MedMeshDriver.cxx delete mode 100644 src/MEDMEM/MEDMEM_MedMeshDriver.hxx delete mode 100644 src/MEDMEM/MEDMEM_MedVersion.cxx delete mode 100644 src/MEDMEM/MEDMEM_MedVersion.hxx delete mode 100644 src/MEDMEM/MEDMEM_Mesh.cxx delete mode 100644 src/MEDMEM/MEDMEM_Mesh.hxx delete mode 100644 src/MEDMEM/MEDMEM_MeshFuse.cxx delete mode 100644 src/MEDMEM/MEDMEM_MeshFuse.hxx delete mode 100644 src/MEDMEM/MEDMEM_Meshing.cxx delete mode 100644 src/MEDMEM/MEDMEM_Meshing.hxx delete mode 100644 src/MEDMEM/MEDMEM_ModulusArray.hxx delete mode 100644 src/MEDMEM/MEDMEM_OptionManager.hxx delete mode 100644 src/MEDMEM/MEDMEM_PointerOf.hxx delete mode 100644 src/MEDMEM/MEDMEM_PorflowMeshDriver.cxx delete mode 100644 src/MEDMEM/MEDMEM_PorflowMeshDriver.hxx delete mode 100644 src/MEDMEM/MEDMEM_RCBase.cxx delete mode 100644 src/MEDMEM/MEDMEM_RCBase.hxx delete mode 100644 src/MEDMEM/MEDMEM_Remapper.cxx delete mode 100644 src/MEDMEM/MEDMEM_Remapper.hxx delete mode 100644 src/MEDMEM/MEDMEM_STRING.hxx delete mode 100644 src/MEDMEM/MEDMEM_SetInterlacingType.hxx delete mode 100644 src/MEDMEM/MEDMEM_SkyLineArray.cxx delete mode 100644 src/MEDMEM/MEDMEM_SkyLineArray.hxx delete mode 100644 src/MEDMEM/MEDMEM_Support.cxx delete mode 100644 src/MEDMEM/MEDMEM_Support.hxx delete mode 100644 src/MEDMEM/MEDMEM_Tags.hxx delete mode 100644 src/MEDMEM/MEDMEM_TopLevel.cxx delete mode 100644 src/MEDMEM/MEDMEM_TopLevel.hxx delete mode 100644 src/MEDMEM/MEDMEM_TypeMeshDriver.cxx delete mode 100644 src/MEDMEM/MEDMEM_TypeMeshDriver.hxx delete mode 100644 src/MEDMEM/MEDMEM_Unit.cxx delete mode 100644 src/MEDMEM/MEDMEM_Unit.hxx delete mode 100644 src/MEDMEM/MEDMEM_Utilities.hxx delete mode 100644 src/MEDMEM/MEDMEM_VtkFieldDriver.hxx delete mode 100644 src/MEDMEM/MEDMEM_VtkMedDriver.cxx delete mode 100644 src/MEDMEM/MEDMEM_VtkMedDriver.hxx delete mode 100644 src/MEDMEM/MEDMEM_VtkMeshDriver.cxx delete mode 100644 src/MEDMEM/MEDMEM_VtkMeshDriver.hxx delete mode 100644 src/MEDMEM/MEDMEM_define.hxx delete mode 100644 src/MEDMEM/MEDMEM_nArray.hxx delete mode 100644 src/MEDMEM/MEDNormalizedUnstructuredMesh.hxx delete mode 100644 src/MEDMEM/MEDNormalizedUnstructuredMesh.txx delete mode 100644 src/MEDMEM/Makefile.am delete mode 100644 src/MEDMEM/PointLocator.cxx delete mode 100644 src/MEDMEM/PointLocator.hxx delete mode 100755 src/MEDMEM/checkScript diff --git a/idl/CMakeLists.txt b/idl/CMakeLists.txt index de987362b..570125d74 100644 --- a/idl/CMakeLists.txt +++ b/idl/CMakeLists.txt @@ -28,8 +28,6 @@ INCLUDE_DIRECTORIES( SET(SalomeIDLMED_IDLSOURCES MED.idl - MED_Gen.idl - Compo1Py.idl MEDCouplingCorbaServant.idl ParaMEDCouplingCorbaServant.idl MEDDataManager.idl diff --git a/idl/Compo1Py.idl b/idl/Compo1Py.idl deleted file mode 100644 index 9b3dceb93..000000000 --- a/idl/Compo1Py.idl +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "SALOME_Component.idl" -#include "MED.idl" - -module Compo1Py_ORB -{ - - interface Compo1Py : Engines::EngineComponent - { - void Initialise(in string medFile); - SALOME_MED::MESH Calcul1(); - SALOME_MED::SUPPORT Calcul2(); - }; - -}; diff --git a/idl/MED_Gen.idl b/idl/MED_Gen.idl deleted file mode 100644 index 6fa309695..000000000 --- a/idl/MED_Gen.idl +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -//============================================================================= -// File : Med_Gen.idl -// Project : SALOME -//============================================================================= - -#ifndef _Med_GEN_IDL_ -#define _Med_GEN_IDL_ - - -#include "SALOME_Exception.idl" -#include "SALOME_Component.idl" -#include "SALOMEDS.idl" -#include "MED.idl" - -module SALOME_MED -{ - interface MED_Gen_Driver : SALOMEDS::Driver - { - }; - - interface MED_Gen : Engines::EngineComponent, MED_Gen_Driver - { - /*! - it returns a Corba pointer %MESH on the mesh stored in the .med file - fileName with the name meshName. - */ - SALOME_MED::GMESH readMeshInFile(in string fileName, in string studyName, - in string meshName) - raises(SALOME::SALOME_Exception); - - /*! - it returns a Corba pointer %FIELD on the field instance with the order - ordre at the iteration iter, stored in the .med - file fileName with the name fieldName. - */ - SALOME_MED::FIELD readFieldInFile(in string fileName, in string studyName, - in string fieldName, in long iter, - in long ordre) - raises (SALOME::SALOME_Exception); - - /*! - it returns a Corba pointer on the %MED object regrouping all objects - (%MESH and %FIELD) stored in the file fileName. All instances - of the fields are stored without their type. - */ - SALOME_MED::MED readStructFile(in string fileName, - in string studyName) - raises (SALOME::SALOME_Exception); - - /*! - It pushes all Corba pointers (%MED, %MESH, %FIELD) in the study named - studyName. The %MED object regroups all objects - (%MESH and %FIELD) stored in the file fileName and all - instances of the fields are stored with their own type. - */ - void readStructFileWithFieldType(in string fileName, - in string studyName) - raises (SALOME::SALOME_Exception); - }; -}; - -#endif diff --git a/idl/Makefile.am b/idl/Makefile.am index 51177cc65..109f76019 100644 --- a/idl/Makefile.am +++ b/idl/Makefile.am @@ -25,7 +25,7 @@ include $(top_srcdir)/adm_local/unix/make_common_starter.am BASEIDL_FILES = \ - MED.idl MED_Gen.idl Compo1Py.idl \ + MED.idl \ MEDCouplingCorbaServant.idl \ MEDCouplingCorbaServantTest.idl \ ParaMEDCouplingCorbaServant.idl diff --git a/src/MEDMEM/CMakeLists.txt b/src/MEDMEM/CMakeLists.txt deleted file mode 100644 index 9369071a8..000000000 --- a/src/MEDMEM/CMakeLists.txt +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright (C) 2012-2013 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -INCLUDE_DIRECTORIES( - ${MED3_INCLUDE_DIRS} - ${HDF5_INCLUDE_DIRS} - ${XDR_INCLUDE_DIRS} - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/Bases - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/Geometric2D - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/ExprEval - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/GaussPoints - ) - -SET(medmem_SOURCES - MEDMEM_Init.cxx - MEDMEM_RCBase.cxx - MEDMEM_CellModel.cxx - MEDMEM_Connectivity.cxx - MEDMEM_Coordinate.cxx - MEDMEM_DriversDef.cxx - MEDMEM_DriverFactory.cxx - MEDMEM_Family.cxx - MEDMEM_Field.cxx - MEDMEM_GenDriver.cxx - MEDMEM_Group.cxx - MEDMEM_Exception.cxx - MEDMEM_MedMeshDriver.cxx - MEDMEM_GibiMeshDriver.cxx - MEDMEM_PorflowMeshDriver.cxx - MEDMEM_SkyLineArray.cxx - MEDMEM_Mesh.cxx - MEDMEM_Meshing.cxx - MEDMEM_Support.cxx - MEDMEM_Unit.cxx - MEDMEM_VtkMedDriver.cxx - MEDMEM_VtkMeshDriver.cxx - MEDMEM_Grid.cxx - MEDMEM_MedVersion.cxx - MEDMEM_TopLevel.cxx - MEDMEM_ConnectZone.cxx - MEDMEM_EnsightMedDriver.cxx - MEDMEM_EnsightFieldDriver.cxx - MEDMEM_EnsightUtils.cxx - MEDMEM_EnsightMeshDriver.cxx - MEDMEM_DriverTools.cxx - MEDMEM_GaussLocalization.cxx - MEDMEM_Extractor.cxx - PointLocator.cxx - MEDMEM_Remapper.cxx - MEDMEM_GMesh.cxx - MEDMEM_MeshFuse.cxx - MEDMEM_MedFileBrowser.cxx - ) - -ADD_LIBRARY(medmem SHARED ${medmem_SOURCES}) -SET_TARGET_PROPERTIES(medmem PROPERTIES COMPILE_FLAGS "${HDF5_DEFINITIONS} ${MED3_DEFINITIONS} ${XDR_DEFINITIONS} ${PLATFORM_DEFINITIONS}") -TARGET_LINK_LIBRARIES(medmem interpkernel ${MED3_LIBS_C_ONLY} ${HDF5_LIBS} ${XDR_LIBS} ${PLATFORM_LIBS}) -INSTALL(TARGETS medmem DESTINATION ${MED_salomelib_LIBS}) - -FILE(GLOB medmem_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx") -INSTALL(FILES ${medmem_HEADERS_HXX} MEDMEM_DriverFactory.ixx DESTINATION ${MED_salomeinclude_HEADERS}) -FILE(GLOB medmem_HEADERS_TXX "${CMAKE_CURRENT_SOURCE_DIR}/*.txx") -INSTALL(FILES ${medmem_HEADERS_TXX} DESTINATION ${MED_salomeinclude_HEADERS}) diff --git a/src/MEDMEM/DataTest/Data/elle_2D_QT_2x2.sauve b/src/MEDMEM/DataTest/Data/elle_2D_QT_2x2.sauve deleted file mode 100644 index 4ef4a6dbe..000000000 --- a/src/MEDMEM/DataTest/Data/elle_2D_QT_2x2.sauve +++ /dev/null @@ -1,98 +0,0 @@ - ENREGISTREMENT DE TYPE 4 - NIVEAU 13 NIVEAU ERREUR 0 DIMENSION 2 - DENSITE 0.00000E+00 - ENREGISTREMENT DE TYPE 7 - NOMBRE INFO CASTEM2000 8 - IFOUR -1 NIFOUR 0 IFOMOD -1 IECHO 1 IIMPI 0 IOSPI 0 ISOTYP 1 - NSDPGE 0 - ENREGISTREMENT DE TYPE 2 - PILE NUMERO 1NBRE OBJETS NOMMES 11NBRE OBJETS 14 - A0B0 B1A1 A1A0 B0C0 C0C1 C1C2 C2B2 B2B1 - BOX1 BOX2 BOX3 - 4 6 7 13 14 10 11 12 1 2 - 3 - 8 0 4 4 4 - 4 5 6 7 - 0 0 0 0 - 1 2 3 4 2 5 6 3 4 3 - 7 8 3 6 9 7 - 4 0 1 3 8 - 8 - 0 0 0 0 0 0 0 0 - 6 5 10 10 11 12 12 13 14 14 - 9 6 12 14 15 14 6 15 10 12 - 15 6 10 15 - 8 0 4 4 4 - 9 10 11 12 - 0 0 0 0 - 9 14 16 17 14 13 18 16 17 16 - 19 20 16 18 21 19 - 2 0 0 2 2 - 0 0 - 1 2 2 5 - 2 0 0 2 2 - 0 0 - 5 6 6 9 - 2 0 0 2 2 - 0 0 - 9 7 7 8 - 2 0 0 2 2 - 0 0 - 8 4 4 1 - 2 0 0 2 8 - 0 0 0 0 0 0 0 0 - 5 10 10 11 11 12 12 13 13 14 - 14 9 9 6 6 5 - 2 0 0 2 2 - 0 0 - 9 14 14 13 - 2 0 0 2 2 - 0 0 - 13 18 18 21 - 2 0 0 2 2 - 0 0 - 21 19 19 20 - 2 0 0 2 2 - 0 0 - 20 17 17 9 - 2 0 0 2 2 - 0 0 - 5 10 10 11 - 2 0 0 2 2 - 0 0 - 11 12 12 13 - ENREGISTREMENT DE TYPE 2 - PILE NUMERO 32NBRE OBJETS NOMMES 8NBRE OBJETS 21 - A0 B0 C0 A1 B1 C1 B2 C2 - 1 5 11 8 9 13 20 21 - 21 - 17 18 22 21 5 1 19 20 8 2 - 6 3 7 4 9 12 11 13 14 16 - 15 - ENREGISTREMENT DE TYPE 2 - PILE NUMERO 33NBRE OBJETS NOMMES 0NBRE OBJETS 1 - 66 - 1.00000000000000E+00 5.00000000000000E-01 5.00000000000000E-01 - 1.50000000000000E+00 0.00000000000000E+00 5.00000000000000E-01 - 2.00000000000000E+00 5.00000000000000E-01 5.00000000000000E-01 - 1.50000000000000E+00 1.00000000000000E+00 5.00000000000000E-01 - 1.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 2.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 2.00000000000000E+00 1.00000000000000E+00 0.00000000000000E+00 - 1.00000000000000E+00 1.00000000000000E+00 0.00000000000000E+00 - 1.50000000000000E+00 5.00000000000000E-01 5.00000000000000E-01 - 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 1.00000000000000E+00 1.50000000000000E+00 5.00000000000000E-01 - 1.50000000000000E+00 1.50000000000000E+00 1.25000000000000E-01 - 2.00000000000000E+00 1.50000000000000E+00 5.00000000000000E-01 - 1.50000000000000E+00 2.00000000000000E+00 5.00000000000000E-01 - 2.00000000000000E+00 2.00000000000000E+00 0.00000000000000E+00 - 1.00000000000000E+00 2.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 5.00000000000000E-01 0.00000000000000E+00 5.00000000000000E-01 - 5.00000000000000E-01 1.00000000000000E+00 5.00000000000000E-01 - 0.00000000000000E+00 1.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 5.00000000000000E-01 5.00000000000000E-01 - 5.00000000000000E-01 5.00000000000000E-01 1.25000000000000E-01 - ENREGISTREMENT DE TYPE 5 -LABEL AUTOMATIQUE : 1 diff --git a/src/MEDMEM/DataTest/Data/elle_2D_QT_4x4.sauve b/src/MEDMEM/DataTest/Data/elle_2D_QT_4x4.sauve deleted file mode 100644 index 5b208d1cf..000000000 --- a/src/MEDMEM/DataTest/Data/elle_2D_QT_4x4.sauve +++ /dev/null @@ -1,175 +0,0 @@ - ENREGISTREMENT DE TYPE 4 - NIVEAU 13 NIVEAU ERREUR 0 DIMENSION 2 - DENSITE 0.00000E+00 - ENREGISTREMENT DE TYPE 7 - NOMBRE INFO CASTEM2000 8 - IFOUR -1 NIFOUR 0 IFOMOD -1 IECHO 1 IIMPI 0 IOSPI 0 ISOTYP 1 - NSDPGE 0 - ENREGISTREMENT DE TYPE 2 - PILE NUMERO 1NBRE OBJETS NOMMES 11NBRE OBJETS 14 - A0B0 B1A1 A1A0 B0C0 C0C1 C1C2 C2B2 B2B1 - BOX1 BOX2 BOX3 - 4 6 7 13 14 10 11 12 1 2 - 3 - 8 0 4 4 16 - 4 5 6 7 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 - 1 2 3 4 2 5 6 3 5 7 - 8 6 7 9 10 8 4 3 11 12 - 3 6 13 11 6 8 14 13 8 10 - 15 14 12 11 16 17 11 13 18 16 - 13 14 19 18 14 15 20 19 17 16 - 21 22 16 18 23 21 18 19 24 23 - 19 20 25 24 - 4 0 1 3 34 - 8 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 - 10 9 26 27 28 29 30 31 32 33 - 25 20 34 26 35 36 34 35 36 35 - 27 37 36 27 37 27 29 37 29 38 - 39 37 38 39 38 30 40 39 30 40 - 30 32 40 32 41 42 40 41 42 41 - 33 43 42 33 43 33 20 43 20 15 - 44 43 15 44 15 10 34 44 10 34 - 10 26 34 36 45 34 45 44 43 44 - 45 45 36 37 45 37 39 42 43 45 - 45 39 46 39 40 46 42 45 46 40 - 42 46 - 8 0 4 4 16 - 9 10 11 12 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 - 25 33 47 48 33 41 49 47 41 32 - 50 49 32 31 51 50 48 47 52 53 - 47 49 54 52 49 50 55 54 50 51 - 56 55 53 52 57 58 52 54 59 57 - 54 55 60 59 55 56 61 60 58 57 - 62 63 57 59 64 62 59 60 65 64 - 60 61 66 65 - 2 0 0 2 4 - 0 0 0 0 - 1 2 2 5 5 7 7 9 - 2 0 0 2 4 - 0 0 0 0 - 9 10 10 15 15 20 20 25 - 2 0 0 2 4 - 0 0 0 0 - 25 24 24 23 23 21 21 22 - 2 0 0 2 4 - 0 0 0 0 - 22 17 17 12 12 4 4 1 - 2 0 0 2 16 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 - 9 26 26 35 35 27 27 28 28 29 - 29 38 38 30 30 31 31 32 32 41 - 41 33 33 25 25 20 20 15 15 10 - 10 9 - 2 0 0 2 4 - 0 0 0 0 - 25 33 33 41 41 32 32 31 - 2 0 0 2 4 - 0 0 0 0 - 31 51 51 56 56 61 61 66 - 2 0 0 2 4 - 0 0 0 0 - 66 65 65 64 64 62 62 63 - 2 0 0 2 4 - 0 0 0 0 - 63 58 58 53 53 48 48 25 - 2 0 0 2 4 - 0 0 0 0 - 9 26 26 35 35 27 27 28 - 2 0 0 2 4 - 0 0 0 0 - 28 29 29 38 38 30 30 31 - ENREGISTREMENT DE TYPE 2 - PILE NUMERO 32NBRE OBJETS NOMMES 8NBRE OBJETS 66 - A0 B0 C0 A1 B1 C1 B2 C2 - 1 9 28 22 25 31 63 66 - 66 - 50 51 61 60 52 62 53 63 14 1 - 64 59 65 66 25 67 58 68 69 24 - 56 57 55 54 17 18 2 15 20 3 - 16 22 4 5 19 6 7 21 8 9 - 23 10 11 12 13 26 31 30 32 33 - 42 35 34 36 37 43 39 38 40 41 - 44 45 49 46 47 48 - ENREGISTREMENT DE TYPE 2 - PILE NUMERO 33NBRE OBJETS NOMMES 0NBRE OBJETS 1 - 207 - 1.00000000000000E+00 2.50000000000000E-01 2.50000000000000E-01 - 1.75000000000000E+00 0.00000000000000E+00 2.50000000000000E-01 - 2.00000000000000E+00 7.50000000000000E-01 2.50000000000000E-01 - 1.25000000000000E+00 1.00000000000000E+00 2.50000000000000E-01 - 1.32713397223596E+00 2.00510665587990E-01 2.50000000000000E-01 - 1.58171915768599E+00 2.04663521459000E-01 2.50000000000000E-01 - 1.79975007305965E+00 3.27394710883601E-01 2.50000000000000E-01 - 1.79495960350997E+00 5.77789090564371E-01 2.50000000000000E-01 - 1.67489393228352E+00 7.97461429892528E-01 2.50000000000000E-01 - 1.42452256547730E+00 7.94737926521907E-01 2.50000000000000E-01 - 1.20389122059610E+00 6.76246582772151E-01 2.50000000000000E-01 - 1.20539375184324E+00 4.25895712464750E-01 2.50000000000000E-01 - 1.46870992982599E+00 4.44185259205497E-01 2.50000000000000E-01 - 1.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 2.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 2.00000000000000E+00 1.00000000000000E+00 0.00000000000000E+00 - 1.00000000000000E+00 1.00000000000000E+00 0.00000000000000E+00 - 1.25000000000000E+00 0.00000000000000E+00 2.50000000000000E-01 - 1.50000000000000E+00 0.00000000000000E+00 2.50000000000000E-01 - 2.00000000000000E+00 2.50000000000000E-01 2.50000000000000E-01 - 2.00000000000000E+00 5.00000000000000E-01 2.50000000000000E-01 - 1.75000000000000E+00 1.00000000000000E+00 2.50000000000000E-01 - 1.50000000000000E+00 1.00000000000000E+00 2.50000000000000E-01 - 1.00000000000000E+00 7.50000000000000E-01 2.50000000000000E-01 - 1.00000000000000E+00 5.00000000000000E-01 2.50000000000000E-01 - 1.57180193105475E+00 6.20823344549013E-01 2.50000000000000E-01 - 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 1.00000000000000E+00 1.25000000000000E+00 2.50000000000000E-01 - 1.25000000000000E+00 1.25000000000000E+00 -7.81250000000000E-02 - 1.50000000000000E+00 1.25000000000000E+00 -2.18750000000000E-01 - 1.75000000000000E+00 1.25000000000000E+00 -3.59375000000000E-01 - 1.00000000000000E+00 1.50000000000000E+00 2.50000000000000E-01 - 1.25000000000000E+00 1.50000000000000E+00 -2.18750000000000E-01 - 1.50000000000000E+00 1.50000000000000E+00 -3.12500000000000E-01 - 1.75000000000000E+00 1.50000000000000E+00 -4.06250000000000E-01 - 1.00000000000000E+00 1.75000000000000E+00 2.50000000000000E-01 - 1.25000000000000E+00 1.75000000000000E+00 -3.59375000000000E-01 - 1.50000000000000E+00 1.75000000000000E+00 -4.06250000000000E-01 - 1.75000000000000E+00 1.75000000000000E+00 -4.53125000000000E-01 - 2.00000000000000E+00 1.25000000000000E+00 2.50000000000000E-01 - 2.00000000000000E+00 1.50000000000000E+00 2.50000000000000E-01 - 2.00000000000000E+00 1.75000000000000E+00 2.50000000000000E-01 - 1.25000000000000E+00 2.00000000000000E+00 2.50000000000000E-01 - 1.50000000000000E+00 2.00000000000000E+00 2.50000000000000E-01 - 1.75000000000000E+00 2.00000000000000E+00 2.50000000000000E-01 - 2.00000000000000E+00 2.00000000000000E+00 0.00000000000000E+00 - 1.00000000000000E+00 2.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 2.50000000000000E-01 0.00000000000000E+00 2.50000000000000E-01 - 5.00000000000000E-01 0.00000000000000E+00 2.50000000000000E-01 - 7.50000000000000E-01 0.00000000000000E+00 2.50000000000000E-01 - 7.50000000000000E-01 1.00000000000000E+00 2.50000000000000E-01 - 5.00000000000000E-01 1.00000000000000E+00 2.50000000000000E-01 - 2.50000000000000E-01 1.00000000000000E+00 2.50000000000000E-01 - 0.00000000000000E+00 1.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 7.50000000000000E-01 2.50000000000000E-01 - 0.00000000000000E+00 5.00000000000000E-01 2.50000000000000E-01 - 0.00000000000000E+00 2.50000000000000E-01 2.50000000000000E-01 - 2.50000000000000E-01 2.50000000000000E-01 -7.81250000000000E-02 - 5.00000000000000E-01 2.50000000000000E-01 -2.18750000000000E-01 - 7.50000000000000E-01 2.50000000000000E-01 -3.59375000000000E-01 - 2.50000000000000E-01 5.00000000000000E-01 -2.18750000000000E-01 - 5.00000000000000E-01 5.00000000000000E-01 -3.12500000000000E-01 - 7.50000000000000E-01 5.00000000000000E-01 -4.06250000000000E-01 - 2.50000000000000E-01 7.50000000000000E-01 -3.59375000000000E-01 - 5.00000000000000E-01 7.50000000000000E-01 -4.06250000000000E-01 - 7.50000000000000E-01 7.50000000000000E-01 -4.53125000000000E-01 - ENREGISTREMENT DE TYPE 5 -LABEL AUTOMATIQUE : 1 diff --git a/src/MEDMEM/DataTest/Data/elle_3D_HPr_4x4x4.sauve b/src/MEDMEM/DataTest/Data/elle_3D_HPr_4x4x4.sauve deleted file mode 100644 index a494195fb..000000000 --- a/src/MEDMEM/DataTest/Data/elle_3D_HPr_4x4x4.sauve +++ /dev/null @@ -1,1292 +0,0 @@ - ENREGISTREMENT DE TYPE 4 - NIVEAU 13 NIVEAU ERREUR 0 DIMENSION 3 - DENSITE 0.00000E+00 - ENREGISTREMENT DE TYPE 7 - NOMBRE INFO CASTEM2000 8 - IFOUR 2 NIFOUR 0 IFOMOD 2 IECHO 1 IIMPI 0 IOSPI 0 ISOTYP 1 - NSDPGE 0 - ENREGISTREMENT DE TYPE 2 - PILE NUMERO 1NBRE OBJETS NOMMES 22NBRE OBJETS 41 - A0B0 B0B1 B1A1 A1A0 B0C0 C0C1 C1B1 B1B0 - B1C1 C1C2 C2B2 B2B1 BOX1 CONT2 BOX2 SURF - BOX3 VOL1 VOL2 VOL3 DOM FRONT - 1 2 3 4 5 6 7 8 9 10 - 11 12 13 14 15 16 17 18 19 20 - 21 22 - 2 0 0 2 4 - 0 0 0 0 - 1 10 10 11 11 12 12 2 - 2 0 0 2 4 - 0 0 0 0 - 2 13 13 14 14 15 15 5 - 2 0 0 2 4 - 0 0 0 0 - 5 16 16 17 17 18 18 4 - 2 0 0 2 4 - 0 0 0 0 - 4 19 19 20 20 21 21 1 - 2 0 0 2 4 - 0 0 0 0 - 2 22 22 23 23 24 24 3 - 2 0 0 2 4 - 0 0 0 0 - 3 25 25 26 26 27 27 6 - 2 0 0 2 4 - 0 0 0 0 - 6 28 28 29 29 30 30 5 - 2 0 0 2 4 - 0 0 0 0 - 5 15 15 14 14 13 13 2 - 2 0 0 2 4 - 0 0 0 0 - 5 30 30 29 29 28 28 6 - 2 0 0 2 4 - 0 0 0 0 - 6 31 31 32 32 33 33 8 - 2 0 0 2 4 - 0 0 0 0 - 8 34 34 35 35 36 36 7 - 2 0 0 2 4 - 0 0 0 0 - 7 37 37 38 38 39 39 5 - 8 0 4 4 16 - 1 2 3 4 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 - 1 10 40 21 10 11 41 40 11 12 - 42 41 12 2 13 42 21 40 43 20 - 40 41 44 43 41 42 45 44 42 13 - 14 45 20 43 46 19 43 44 47 46 - 44 45 48 47 45 14 15 48 19 46 - 18 4 46 47 17 18 47 48 16 17 - 48 15 5 16 - 2 0 0 2 16 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 - 2 22 22 23 23 24 24 3 3 25 - 25 26 26 27 27 6 6 28 28 29 - 29 30 30 5 5 15 15 14 14 13 - 13 2 - 4 0 1 3 34 - 14 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 - 13 2 22 24 3 25 27 6 28 30 - 5 15 49 22 23 50 49 23 50 23 - 24 51 50 24 51 24 25 51 25 26 - 52 51 26 52 26 27 53 52 27 53 - 27 28 53 28 29 54 53 29 54 29 - 30 55 54 30 55 30 15 55 15 14 - 56 55 14 56 14 13 49 56 13 49 - 13 22 49 50 57 49 57 56 55 56 - 57 57 50 51 57 51 52 54 55 57 - 57 52 58 52 53 58 54 57 58 53 - 54 58 - 0 2 0 0 0 - 23 15 - 8 0 4 4 16 - 9 10 11 12 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 - 5 30 59 39 30 29 60 59 29 28 - 61 60 28 6 31 61 39 59 62 38 - 59 60 63 62 60 61 64 63 61 31 - 32 64 38 62 65 37 62 63 66 65 - 63 64 67 66 64 32 33 67 37 65 - 36 7 65 66 35 36 66 67 34 35 - 67 33 8 34 - 14 0 3 8 64 - 13 24 25 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 - 1 10 40 21 68 69 70 71 10 11 - 41 40 69 72 73 70 11 12 42 41 - 72 74 75 73 12 2 13 42 74 76 - 77 75 21 40 43 20 71 70 78 79 - 40 41 44 43 70 73 80 78 41 42 - 45 44 73 75 81 80 42 13 14 45 - 75 77 82 81 20 43 46 19 79 78 - 83 84 43 44 47 46 78 80 85 83 - 44 45 48 47 80 81 86 85 45 14 - 15 48 81 82 87 86 19 46 18 4 - 84 83 88 89 46 47 17 18 83 85 - 90 88 47 48 16 17 85 86 91 90 - 48 15 5 16 86 87 92 91 68 69 - 70 71 93 94 95 96 69 72 73 70 - 94 97 98 95 72 74 75 73 97 99 - 100 98 74 76 77 75 99 101 102 100 - 71 70 78 79 96 95 103 104 70 73 - 80 78 95 98 105 103 73 75 81 80 - 98 100 106 105 75 77 82 81 100 102 - 107 106 79 78 83 84 104 103 108 109 - 78 80 85 83 103 105 110 108 80 81 - 86 85 105 106 111 110 81 82 87 86 - 106 107 112 111 84 83 88 89 109 108 - 113 114 83 85 90 88 108 110 115 113 - 85 86 91 90 110 111 116 115 86 87 - 92 91 111 112 117 116 93 94 95 96 - 118 119 120 121 94 97 98 95 119 122 - 123 120 97 99 100 98 122 124 125 123 - 99 101 102 100 124 126 127 125 96 95 - 103 104 121 120 128 129 95 98 105 103 - 120 123 130 128 98 100 106 105 123 125 - 131 130 100 102 107 106 125 127 132 131 - 104 103 108 109 129 128 133 134 103 105 - 110 108 128 130 135 133 105 106 111 110 - 130 131 136 135 106 107 112 111 131 132 - 137 136 109 108 113 114 134 133 138 139 - 108 110 115 113 133 135 140 138 110 111 - 116 115 135 136 141 140 111 112 117 116 - 136 137 142 141 118 119 120 121 143 144 - 145 146 119 122 123 120 144 147 148 145 - 122 124 125 123 147 149 150 148 124 126 - 127 125 149 151 152 150 121 120 128 129 - 146 145 153 154 120 123 130 128 145 148 - 155 153 123 125 131 130 148 150 156 155 - 125 127 132 131 150 152 157 156 129 128 - 133 134 154 153 158 159 128 130 135 133 - 153 155 160 158 130 131 136 135 155 156 - 161 160 131 132 137 136 156 157 162 161 - 134 133 138 139 159 158 163 164 133 135 - 140 138 158 160 165 163 135 136 141 140 - 160 161 166 165 136 137 142 141 161 162 - 167 166 - 16 0 3 6 136 - 15 26 27 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 - 13 2 22 77 76 168 24 3 25 169 - 170 171 27 6 28 172 173 174 30 5 - 15 175 92 87 49 22 23 176 168 177 - 50 49 23 178 176 177 50 23 24 178 - 177 169 51 50 24 179 178 169 51 24 - 25 179 169 171 51 25 26 179 171 180 - 52 51 26 181 179 180 52 26 27 181 - 180 172 53 52 27 182 181 172 53 27 - 28 182 172 174 53 28 29 182 174 183 - 54 53 29 184 182 183 54 29 30 184 - 183 175 55 54 30 185 184 175 55 30 - 15 185 175 87 55 15 14 185 87 82 - 56 55 14 186 185 82 56 14 13 186 - 82 77 49 56 13 176 186 77 49 13 - 22 176 77 168 49 50 57 176 178 187 - 49 57 56 176 187 186 55 56 57 185 - 186 187 57 50 51 187 178 179 57 51 - 52 187 179 181 54 55 57 184 185 187 - 57 52 58 187 181 188 52 53 58 181 - 182 188 54 57 58 184 187 188 53 54 - 58 182 184 188 77 76 168 102 101 189 - 169 170 171 190 191 192 172 173 174 193 - 194 195 175 92 87 196 117 112 176 168 - 177 197 189 198 178 176 177 199 197 198 - 178 177 169 199 198 190 179 178 169 200 - 199 190 179 169 171 200 190 192 179 171 - 180 200 192 201 181 179 180 202 200 201 - 181 180 172 202 201 193 182 181 172 203 - 202 193 182 172 174 203 193 195 182 174 - 183 203 195 204 184 182 183 205 203 204 - 184 183 175 205 204 196 185 184 175 206 - 205 196 185 175 87 206 196 112 185 87 - 82 206 112 107 186 185 82 207 206 107 - 186 82 77 207 107 102 176 186 77 197 - 207 102 176 77 168 197 102 189 176 178 - 187 197 199 208 176 187 186 197 208 207 - 185 186 187 206 207 208 187 178 179 208 - 199 200 187 179 181 208 200 202 184 185 - 187 205 206 208 187 181 188 208 202 209 - 181 182 188 202 203 209 184 187 188 205 - 208 209 182 184 188 203 205 209 102 101 - 189 127 126 210 190 191 192 211 212 213 - 193 194 195 214 215 216 196 117 112 217 - 142 137 197 189 198 218 210 219 199 197 - 198 220 218 219 199 198 190 220 219 211 - 200 199 190 221 220 211 200 190 192 221 - 211 213 200 192 201 221 213 222 202 200 - 201 223 221 222 202 201 193 223 222 214 - 203 202 193 224 223 214 203 193 195 224 - 214 216 203 195 204 224 216 225 205 203 - 204 226 224 225 205 204 196 226 225 217 - 206 205 196 227 226 217 206 196 112 227 - 217 137 206 112 107 227 137 132 207 206 - 107 228 227 132 207 107 102 228 132 127 - 197 207 102 218 228 127 197 102 189 218 - 127 210 197 199 208 218 220 229 197 208 - 207 218 229 228 206 207 208 227 228 229 - 208 199 200 229 220 221 208 200 202 229 - 221 223 205 206 208 226 227 229 208 202 - 209 229 223 230 202 203 209 223 224 230 - 205 208 209 226 229 230 203 205 209 224 - 226 230 127 126 210 152 151 231 211 212 - 213 232 233 234 214 215 216 235 236 237 - 217 142 137 238 167 162 218 210 219 239 - 231 240 220 218 219 241 239 240 220 219 - 211 241 240 232 221 220 211 242 241 232 - 221 211 213 242 232 234 221 213 222 242 - 234 243 223 221 222 244 242 243 223 222 - 214 244 243 235 224 223 214 245 244 235 - 224 214 216 245 235 237 224 216 225 245 - 237 246 226 224 225 247 245 246 226 225 - 217 247 246 238 227 226 217 248 247 238 - 227 217 137 248 238 162 227 137 132 248 - 162 157 228 227 132 249 248 157 228 132 - 127 249 157 152 218 228 127 239 249 152 - 218 127 210 239 152 231 218 220 229 239 - 241 250 218 229 228 239 250 249 227 228 - 229 248 249 250 229 220 221 250 241 242 - 229 221 223 250 242 244 226 227 229 247 - 248 250 229 223 230 250 244 251 223 224 - 230 244 245 251 226 229 230 247 250 251 - 224 226 230 245 247 251 - 14 0 3 8 64 - 17 28 29 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 - 5 30 59 39 92 175 252 253 30 29 - 60 59 175 183 254 252 29 28 61 60 - 183 174 255 254 28 6 31 61 174 173 - 256 255 39 59 62 38 253 252 257 258 - 59 60 63 62 252 254 259 257 60 61 - 64 63 254 255 260 259 61 31 32 64 - 255 256 261 260 38 62 65 37 258 257 - 262 263 62 63 66 65 257 259 264 262 - 63 64 67 66 259 260 265 264 64 32 - 33 67 260 261 266 265 37 65 36 7 - 263 262 267 268 65 66 35 36 262 264 - 269 267 66 67 34 35 264 265 270 269 - 67 33 8 34 265 266 271 270 92 175 - 252 253 117 196 272 273 175 183 254 252 - 196 204 274 272 183 174 255 254 204 195 - 275 274 174 173 256 255 195 194 276 275 - 253 252 257 258 273 272 277 278 252 254 - 259 257 272 274 279 277 254 255 260 259 - 274 275 280 279 255 256 261 260 275 276 - 281 280 258 257 262 263 278 277 282 283 - 257 259 264 262 277 279 284 282 259 260 - 265 264 279 280 285 284 260 261 266 265 - 280 281 286 285 263 262 267 268 283 282 - 287 288 262 264 269 267 282 284 289 287 - 264 265 270 269 284 285 290 289 265 266 - 271 270 285 286 291 290 117 196 272 273 - 142 217 292 293 196 204 274 272 217 225 - 294 292 204 195 275 274 225 216 295 294 - 195 194 276 275 216 215 296 295 273 272 - 277 278 293 292 297 298 272 274 279 277 - 292 294 299 297 274 275 280 279 294 295 - 300 299 275 276 281 280 295 296 301 300 - 278 277 282 283 298 297 302 303 277 279 - 284 282 297 299 304 302 279 280 285 284 - 299 300 305 304 280 281 286 285 300 301 - 306 305 283 282 287 288 303 302 307 308 - 282 284 289 287 302 304 309 307 284 285 - 290 289 304 305 310 309 285 286 291 290 - 305 306 311 310 142 217 292 293 167 238 - 312 313 217 225 294 292 238 246 314 312 - 225 216 295 294 246 237 315 314 216 215 - 296 295 237 236 316 315 293 292 297 298 - 313 312 317 318 292 294 299 297 312 314 - 319 317 294 295 300 299 314 315 320 319 - 295 296 301 300 315 316 321 320 298 297 - 302 303 318 317 322 323 297 299 304 302 - 317 319 324 322 299 300 305 304 319 320 - 325 324 300 301 306 305 320 321 326 325 - 303 302 307 308 323 322 327 328 302 304 - 309 307 322 324 329 327 304 305 310 309 - 324 325 330 329 305 306 311 310 325 326 - 331 330 - 0 2 0 0 0 - 30 19 - 0 2 0 0 0 - 31 32 - 8 0 0 4 32 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 - 5 30 59 39 30 29 60 59 29 28 - 61 60 28 6 31 61 39 59 62 38 - 59 60 63 62 60 61 64 63 61 31 - 32 64 38 62 65 37 62 63 66 65 - 63 64 67 66 64 32 33 67 37 65 - 36 7 65 66 35 36 66 67 34 35 - 67 33 8 34 1 10 40 21 10 11 - 41 40 11 12 42 41 12 2 13 42 - 21 40 43 20 40 41 44 43 41 42 - 45 44 42 13 14 45 20 43 46 19 - 43 44 47 46 44 45 48 47 45 14 - 15 48 19 46 18 4 46 47 17 18 - 47 48 16 17 48 15 5 16 - 8 0 4 4 16 - 33 34 35 36 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 - 143 144 145 146 144 147 148 145 147 149 - 150 148 149 151 152 150 146 145 153 154 - 145 148 155 153 148 150 156 155 150 152 - 157 156 154 153 158 159 153 155 160 158 - 155 156 161 160 156 157 162 161 159 158 - 163 164 158 160 165 163 160 161 166 165 - 161 162 167 166 - 8 0 0 4 64 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 - 1 10 69 68 10 11 72 69 11 12 - 74 72 12 2 76 74 2 13 77 76 - 13 14 82 77 14 15 87 82 15 5 - 92 87 5 16 91 92 16 17 90 91 - 17 18 88 90 18 4 89 88 4 19 - 84 89 19 20 79 84 20 21 71 79 - 21 1 68 71 68 69 94 93 69 72 - 97 94 72 74 99 97 74 76 101 99 - 76 77 102 101 77 82 107 102 82 87 - 112 107 87 92 117 112 92 91 116 117 - 91 90 115 116 90 88 113 115 88 89 - 114 113 89 84 109 114 84 79 104 109 - 79 71 96 104 71 68 93 96 93 94 - 119 118 94 97 122 119 97 99 124 122 - 99 101 126 124 101 102 127 126 102 107 - 132 127 107 112 137 132 112 117 142 137 - 117 116 141 142 116 115 140 141 115 113 - 138 140 113 114 139 138 114 109 134 139 - 109 104 129 134 104 96 121 129 96 93 - 118 121 118 119 144 143 119 122 147 144 - 122 124 149 147 124 126 151 149 126 127 - 152 151 127 132 157 152 132 137 162 157 - 137 142 167 162 142 141 166 167 141 140 - 165 166 140 138 163 165 138 139 164 163 - 139 134 159 164 134 129 154 159 129 121 - 146 154 121 118 143 146 - 4 0 1 3 34 - 37 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 - 152 151 231 232 233 234 235 236 237 238 - 167 162 239 231 240 241 239 240 241 240 - 232 242 241 232 242 232 234 242 234 243 - 244 242 243 244 243 235 245 244 235 245 - 235 237 245 237 246 247 245 246 247 246 - 238 248 247 238 248 238 162 248 162 157 - 249 248 157 249 157 152 239 249 152 239 - 152 231 239 241 250 239 250 249 248 249 - 250 250 241 242 250 242 244 247 248 250 - 250 244 251 244 245 251 247 250 251 245 - 247 251 - 8 0 0 4 64 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 - 2 22 168 76 22 23 177 168 23 24 - 169 177 24 3 170 169 3 25 171 170 - 25 26 180 171 26 27 172 180 27 6 - 173 172 6 28 174 173 28 29 183 174 - 29 30 175 183 30 5 92 175 5 15 - 87 92 15 14 82 87 14 13 77 82 - 13 2 76 77 76 168 189 101 168 177 - 198 189 177 169 190 198 169 170 191 190 - 170 171 192 191 171 180 201 192 180 172 - 193 201 172 173 194 193 173 174 195 194 - 174 183 204 195 183 175 196 204 175 92 - 117 196 92 87 112 117 87 82 107 112 - 82 77 102 107 77 76 101 102 101 189 - 210 126 189 198 219 210 198 190 211 219 - 190 191 212 211 191 192 213 212 192 201 - 222 213 201 193 214 222 193 194 215 214 - 194 195 216 215 195 204 225 216 204 196 - 217 225 196 117 142 217 117 112 137 142 - 112 107 132 137 107 102 127 132 102 101 - 126 127 126 210 231 151 210 219 240 231 - 219 211 232 240 211 212 233 232 212 213 - 234 233 213 222 243 234 222 214 235 243 - 214 215 236 235 215 216 237 236 216 225 - 246 237 225 217 238 246 217 142 167 238 - 142 137 162 167 137 132 157 162 132 127 - 152 157 127 126 151 152 - 8 0 4 4 16 - 38 39 40 41 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 - 167 238 312 313 238 246 314 312 246 237 - 315 314 237 236 316 315 313 312 317 318 - 312 314 319 317 314 315 320 319 315 316 - 321 320 318 317 322 323 317 319 324 322 - 319 320 325 324 320 321 326 325 323 322 - 327 328 322 324 329 327 324 325 330 329 - 325 326 331 330 - 8 0 0 4 64 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 - 5 30 175 92 30 29 183 175 29 28 - 174 183 28 6 173 174 6 31 256 173 - 31 32 261 256 32 33 266 261 33 8 - 271 266 8 34 270 271 34 35 269 270 - 35 36 267 269 36 7 268 267 7 37 - 263 268 37 38 258 263 38 39 253 258 - 39 5 92 253 92 175 196 117 175 183 - 204 196 183 174 195 204 174 173 194 195 - 173 256 276 194 256 261 281 276 261 266 - 286 281 266 271 291 286 271 270 290 291 - 270 269 289 290 269 267 287 289 267 268 - 288 287 268 263 283 288 263 258 278 283 - 258 253 273 278 253 92 117 273 117 196 - 217 142 196 204 225 217 204 195 216 225 - 195 194 215 216 194 276 296 215 276 281 - 301 296 281 286 306 301 286 291 311 306 - 291 290 310 311 290 289 309 310 289 287 - 307 309 287 288 308 307 288 283 303 308 - 283 278 298 303 278 273 293 298 273 117 - 142 293 142 217 238 167 217 225 246 238 - 225 216 237 246 216 215 236 237 215 296 - 316 236 296 301 321 316 301 306 326 321 - 306 311 331 326 311 310 330 331 310 309 - 329 330 309 307 327 329 307 308 328 327 - 308 303 323 328 303 298 318 323 298 293 - 313 318 293 142 167 313 - 14 0 0 8 128 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 5 30 59 39 92 175 252 253 30 29 - 60 59 175 183 254 252 29 28 61 60 - 183 174 255 254 28 6 31 61 174 173 - 256 255 39 59 62 38 253 252 257 258 - 59 60 63 62 252 254 259 257 60 61 - 64 63 254 255 260 259 61 31 32 64 - 255 256 261 260 38 62 65 37 258 257 - 262 263 62 63 66 65 257 259 264 262 - 63 64 67 66 259 260 265 264 64 32 - 33 67 260 261 266 265 37 65 36 7 - 263 262 267 268 65 66 35 36 262 264 - 269 267 66 67 34 35 264 265 270 269 - 67 33 8 34 265 266 271 270 92 175 - 252 253 117 196 272 273 175 183 254 252 - 196 204 274 272 183 174 255 254 204 195 - 275 274 174 173 256 255 195 194 276 275 - 253 252 257 258 273 272 277 278 252 254 - 259 257 272 274 279 277 254 255 260 259 - 274 275 280 279 255 256 261 260 275 276 - 281 280 258 257 262 263 278 277 282 283 - 257 259 264 262 277 279 284 282 259 260 - 265 264 279 280 285 284 260 261 266 265 - 280 281 286 285 263 262 267 268 283 282 - 287 288 262 264 269 267 282 284 289 287 - 264 265 270 269 284 285 290 289 265 266 - 271 270 285 286 291 290 117 196 272 273 - 142 217 292 293 196 204 274 272 217 225 - 294 292 204 195 275 274 225 216 295 294 - 195 194 276 275 216 215 296 295 273 272 - 277 278 293 292 297 298 272 274 279 277 - 292 294 299 297 274 275 280 279 294 295 - 300 299 275 276 281 280 295 296 301 300 - 278 277 282 283 298 297 302 303 277 279 - 284 282 297 299 304 302 279 280 285 284 - 299 300 305 304 280 281 286 285 300 301 - 306 305 283 282 287 288 303 302 307 308 - 282 284 289 287 302 304 309 307 284 285 - 290 289 304 305 310 309 285 286 291 290 - 305 306 311 310 142 217 292 293 167 238 - 312 313 217 225 294 292 238 246 314 312 - 225 216 295 294 246 237 315 314 216 215 - 296 295 237 236 316 315 293 292 297 298 - 313 312 317 318 292 294 299 297 312 314 - 319 317 294 295 300 299 314 315 320 319 - 295 296 301 300 315 316 321 320 298 297 - 302 303 318 317 322 323 297 299 304 302 - 317 319 324 322 299 300 305 304 319 320 - 325 324 300 301 306 305 320 321 326 325 - 303 302 307 308 323 322 327 328 302 304 - 309 307 322 324 329 327 304 305 310 309 - 324 325 330 329 305 306 311 310 325 326 - 331 330 1 10 40 21 68 69 70 71 - 10 11 41 40 69 72 73 70 11 12 - 42 41 72 74 75 73 12 2 13 42 - 74 76 77 75 21 40 43 20 71 70 - 78 79 40 41 44 43 70 73 80 78 - 41 42 45 44 73 75 81 80 42 13 - 14 45 75 77 82 81 20 43 46 19 - 79 78 83 84 43 44 47 46 78 80 - 85 83 44 45 48 47 80 81 86 85 - 45 14 15 48 81 82 87 86 19 46 - 18 4 84 83 88 89 46 47 17 18 - 83 85 90 88 47 48 16 17 85 86 - 91 90 48 15 5 16 86 87 92 91 - 68 69 70 71 93 94 95 96 69 72 - 73 70 94 97 98 95 72 74 75 73 - 97 99 100 98 74 76 77 75 99 101 - 102 100 71 70 78 79 96 95 103 104 - 70 73 80 78 95 98 105 103 73 75 - 81 80 98 100 106 105 75 77 82 81 - 100 102 107 106 79 78 83 84 104 103 - 108 109 78 80 85 83 103 105 110 108 - 80 81 86 85 105 106 111 110 81 82 - 87 86 106 107 112 111 84 83 88 89 - 109 108 113 114 83 85 90 88 108 110 - 115 113 85 86 91 90 110 111 116 115 - 86 87 92 91 111 112 117 116 93 94 - 95 96 118 119 120 121 94 97 98 95 - 119 122 123 120 97 99 100 98 122 124 - 125 123 99 101 102 100 124 126 127 125 - 96 95 103 104 121 120 128 129 95 98 - 105 103 120 123 130 128 98 100 106 105 - 123 125 131 130 100 102 107 106 125 127 - 132 131 104 103 108 109 129 128 133 134 - 103 105 110 108 128 130 135 133 105 106 - 111 110 130 131 136 135 106 107 112 111 - 131 132 137 136 109 108 113 114 134 133 - 138 139 108 110 115 113 133 135 140 138 - 110 111 116 115 135 136 141 140 111 112 - 117 116 136 137 142 141 118 119 120 121 - 143 144 145 146 119 122 123 120 144 147 - 148 145 122 124 125 123 147 149 150 148 - 124 126 127 125 149 151 152 150 121 120 - 128 129 146 145 153 154 120 123 130 128 - 145 148 155 153 123 125 131 130 148 150 - 156 155 125 127 132 131 150 152 157 156 - 129 128 133 134 154 153 158 159 128 130 - 135 133 153 155 160 158 130 131 136 135 - 155 156 161 160 131 132 137 136 156 157 - 162 161 134 133 138 139 159 158 163 164 - 133 135 140 138 158 160 165 163 135 136 - 141 140 160 161 166 165 136 137 142 141 - 161 162 167 166 - 4 0 0 3 68 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 248 162 157 245 237 246 247 250 251 242 - 234 243 249 248 157 250 244 251 238 167 - 162 245 247 251 244 245 251 239 231 240 - 247 245 246 235 236 237 248 238 162 249 - 157 152 247 246 238 232 233 234 248 249 - 250 244 242 243 245 235 237 247 248 250 - 152 151 231 244 243 235 241 239 240 239 - 250 249 242 232 234 250 242 244 241 240 - 232 250 241 242 248 247 238 239 241 250 - 239 152 231 245 244 235 239 249 152 242 - 241 232 55 15 14 53 28 29 51 25 - 26 54 57 58 30 5 15 57 52 58 - 53 54 58 49 22 23 27 6 28 52 - 53 58 24 3 25 13 2 22 56 55 - 14 54 53 29 55 30 15 56 14 13 - 54 29 30 52 51 26 53 27 28 52 - 26 27 50 49 23 51 24 25 50 23 - 24 49 13 22 55 56 57 54 55 57 - 49 57 56 57 51 52 57 50 51 55 - 54 30 49 50 57 53 52 27 49 56 - 13 51 50 24 - 8 0 0 4 192 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 - 0 0 - 160 161 166 165 158 160 165 163 159 158 - 163 164 155 156 161 160 153 155 160 158 - 154 153 158 159 140 141 166 165 148 150 - 156 155 138 140 165 163 139 138 163 164 - 145 148 155 153 146 145 153 154 147 149 - 150 148 134 139 164 159 144 147 148 145 - 143 144 145 146 129 134 159 154 121 129 - 154 146 122 124 149 147 119 122 147 144 - 118 121 146 143 118 119 144 143 115 116 - 141 140 113 115 140 138 114 113 138 139 - 109 114 139 134 104 109 134 129 96 104 - 129 121 97 99 124 122 94 97 122 119 - 93 96 121 118 93 94 119 118 90 91 - 116 115 88 90 115 113 89 88 113 114 - 84 89 114 109 79 84 109 104 71 79 - 104 96 72 74 99 97 69 72 97 94 - 68 71 96 93 68 69 94 93 4 18 - 88 89 17 16 91 90 19 4 89 84 - 18 17 90 88 20 19 84 79 21 20 - 79 71 44 45 48 47 43 44 47 46 - 41 42 45 44 11 12 74 72 1 21 - 71 68 40 41 44 43 10 11 72 69 - 20 43 46 19 46 47 17 18 47 48 - 16 17 21 40 43 20 1 10 69 68 - 19 46 18 4 11 12 42 41 10 11 - 41 40 1 10 40 21 325 326 331 330 - 324 325 330 329 323 322 327 328 322 324 - 329 327 320 321 326 325 315 316 321 320 - 319 320 325 324 317 319 324 322 318 317 - 322 323 161 162 167 166 156 157 162 161 - 308 307 327 328 310 311 331 330 314 315 - 320 319 312 314 319 317 309 310 330 329 - 313 312 317 318 307 309 329 327 306 311 - 331 326 150 152 157 156 303 308 328 323 - 301 306 326 321 149 151 152 150 296 301 - 321 316 141 142 167 166 288 287 307 308 - 290 291 311 310 268 267 287 288 289 290 - 310 309 287 289 309 307 7 36 267 268 - 124 126 151 149 270 271 291 290 269 270 - 290 289 267 269 289 287 286 291 311 306 - 34 8 271 270 298 303 323 318 35 34 - 270 269 36 35 269 267 266 271 291 286 - 293 298 318 313 116 117 142 141 33 8 - 271 266 281 286 306 301 283 288 308 303 - 276 281 301 296 261 266 286 281 256 261 - 281 276 99 101 126 124 32 33 266 261 - 31 32 261 256 263 268 288 283 67 33 - 8 34 91 92 117 116 37 7 268 263 - 237 236 316 315 246 237 315 314 74 76 - 101 99 278 283 303 298 37 65 36 7 - 238 246 314 312 66 67 34 35 65 66 - 35 36 273 278 298 293 167 238 312 313 - 16 5 92 91 64 32 33 67 45 14 - 15 48 215 296 316 236 61 31 32 64 - 12 2 76 74 48 15 5 16 258 263 - 283 278 253 258 278 273 142 293 313 167 - 42 13 14 45 38 37 263 258 12 2 - 13 42 194 276 296 215 39 38 258 253 - 63 64 67 66 62 63 66 65 38 62 - 65 37 60 61 64 63 173 256 276 194 - 59 60 63 62 39 59 62 38 117 273 - 293 142 6 31 256 173 92 253 273 117 - 28 6 31 61 213 222 243 234 210 219 - 240 231 212 213 234 233 126 210 231 151 - 5 39 253 92 29 28 61 60 222 214 - 235 243 219 211 232 240 214 215 236 235 - 192 201 222 213 211 212 233 232 189 198 - 219 210 191 192 213 212 101 189 210 126 - 30 29 60 59 5 30 59 39 171 180 - 201 192 168 177 198 189 170 171 192 191 - 76 168 189 101 25 26 180 171 22 23 - 177 168 201 193 214 222 3 25 171 170 - 198 190 211 219 2 22 168 76 193 194 - 215 214 190 191 212 211 180 172 193 201 - 177 169 190 198 172 173 194 193 169 170 - 191 190 26 27 172 180 23 24 169 177 - 27 6 173 172 24 3 170 169 - 2 0 0 2 4 - 0 0 0 0 - 143 144 144 147 147 149 149 151 - 2 0 0 2 4 - 0 0 0 0 - 151 152 152 157 157 162 162 167 - 2 0 0 2 4 - 0 0 0 0 - 167 166 166 165 165 163 163 164 - 2 0 0 2 4 - 0 0 0 0 - 164 159 159 154 154 146 146 143 - 2 0 0 2 16 - 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 - 151 231 231 240 240 232 232 233 233 234 - 234 243 243 235 235 236 236 237 237 246 - 246 238 238 167 167 162 162 157 157 152 - 152 151 - 2 0 0 2 4 - 0 0 0 0 - 167 238 238 246 246 237 237 236 - 2 0 0 2 4 - 0 0 0 0 - 236 316 316 321 321 326 326 331 - 2 0 0 2 4 - 0 0 0 0 - 331 330 330 329 329 327 327 328 - 2 0 0 2 4 - 0 0 0 0 - 328 323 323 318 318 313 313 167 - ENREGISTREMENT DE TYPE 2 - PILE NUMERO 25NBRE OBJETS NOMMES 1NBRE OBJETS 1 - PI - 1 - 1 - 3.14159265358979E+00 - ENREGISTREMENT DE TYPE 2 - PILE NUMERO 26NBRE OBJETS NOMMES 3NBRE OBJETS 1 - NX NY NZ - 1 1 1 - 1 - 4 - ENREGISTREMENT DE TYPE 2 - PILE NUMERO 27NBRE OBJETS NOMMES 16NBRE OBJETS 15 - #2 #3 #4 D C TITR OPTI DROI - DALL PLAN ET ELIM ENVE OPTION SAUV SAUVE - 1 2 3 4 5 6 7 4 8 9 - 10 11 12 13 14 15 - 55 15 - #2#3#4DROICERCTITROPTIDALLPLANETELIMENVEOPTIONSAUVSAUVE - 2 4 6 10 14 18 22 26 30 32 - 36 40 46 50 55 - ENREGISTREMENT DE TYPE 2 - PILE NUMERO 32NBRE OBJETS NOMMES 9NBRE OBJETS 331 - A0 B0 C0 A1 B1 C1 B2 C2 - VECT - 1 2 3 4 5 6 7 8 9 - 331 - 251 53 54 258 56 55 222 209 351 252 - 253 254 1 64 63 255 256 257 259 260 - 261 57 58 2 59 60 3 61 62 4 - 191 192 193 208 207 206 139 135 131 262 - 263 264 265 266 267 268 269 270 5 6 - 7 8 9 10 11 12 13 101 132 133 - 134 136 137 138 140 141 142 271 272 273 - 274 275 276 277 278 65 14 279 280 281 - 282 76 283 284 285 286 75 287 288 289 - 290 68 291 292 293 294 295 296 297 298 - 77 27 299 300 301 302 88 303 304 305 - 306 87 307 308 309 310 80 311 312 313 - 314 315 316 317 318 89 40 319 320 321 - 322 100 323 324 325 326 99 327 328 329 - 330 92 331 332 333 334 335 336 337 338 - 118 105 339 340 341 342 129 343 344 345 - 346 128 347 348 349 350 121 69 15 66 - 71 16 67 73 17 18 70 19 20 72 - 21 22 74 23 24 25 26 102 81 28 - 78 83 29 79 85 30 31 82 32 33 - 84 34 35 86 36 37 38 39 103 93 - 41 90 95 42 91 97 43 44 94 45 - 46 96 47 48 98 49 50 51 52 104 - 122 106 119 124 107 120 126 108 109 123 - 110 111 125 112 113 127 114 115 116 117 - 130 148 147 149 150 195 152 151 153 154 - 196 156 155 157 158 197 210 223 211 212 - 213 164 163 165 166 199 168 167 169 170 - 200 172 171 173 174 201 214 224 215 216 - 217 180 179 181 182 203 184 183 185 186 - 204 188 187 189 190 205 218 225 219 220 - 221 231 230 232 233 243 235 234 236 237 - 244 239 238 240 241 245 246 250 247 248 - 249 - ENREGISTREMENT DE TYPE 2 - PILE NUMERO 33NBRE OBJETS NOMMES 0NBRE OBJETS 1 - 1404 - 1.00000000000000E+00 2.50000000000000E-01 0.00000000000000E+00 - 2.50000000000000E-01 1.75000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 2.50000000000000E-01 2.00000000000000E+00 - 7.50000000000000E-01 0.00000000000000E+00 2.50000000000000E-01 - 1.25000000000000E+00 1.00000000000000E+00 0.00000000000000E+00 - 2.50000000000000E-01 1.32713397223596E+00 2.00510665587990E-01 - 0.00000000000000E+00 2.50000000000000E-01 1.58171915768599E+00 - 2.04663521459000E-01 0.00000000000000E+00 2.50000000000000E-01 - 1.79975007305965E+00 3.27394710883601E-01 0.00000000000000E+00 - 2.50000000000000E-01 1.79495960350997E+00 5.77789090564371E-01 - 0.00000000000000E+00 2.50000000000000E-01 1.67489393228352E+00 - 7.97461429892528E-01 0.00000000000000E+00 2.50000000000000E-01 - 1.42452256547730E+00 7.94737926521907E-01 0.00000000000000E+00 - 2.50000000000000E-01 1.20389122059610E+00 6.76246582772151E-01 - 0.00000000000000E+00 2.50000000000000E-01 1.20539375184324E+00 - 4.25895712464750E-01 0.00000000000000E+00 2.50000000000000E-01 - 1.46870992982599E+00 4.44185259205497E-01 0.00000000000000E+00 - 2.50000000000000E-01 1.00000000000000E+00 2.50000000000000E-01 - 2.50000000000000E-01 2.50000000000000E-01 1.75000000000000E+00 - 0.00000000000000E+00 2.50000000000000E-01 2.50000000000000E-01 - 2.00000000000000E+00 7.50000000000000E-01 2.50000000000000E-01 - 2.50000000000000E-01 1.25000000000000E+00 1.00000000000000E+00 - 2.50000000000000E-01 2.50000000000000E-01 1.32713397223596E+00 - 2.00510665587990E-01 2.50000000000000E-01 2.50000000000000E-01 - 1.58171915768599E+00 2.04663521459000E-01 2.50000000000000E-01 - 2.50000000000000E-01 1.79975007305965E+00 3.27394710883601E-01 - 2.50000000000000E-01 2.50000000000000E-01 1.79495960350997E+00 - 5.77789090564371E-01 2.50000000000000E-01 2.50000000000000E-01 - 1.67489393228352E+00 7.97461429892528E-01 2.50000000000000E-01 - 2.50000000000000E-01 1.42452256547730E+00 7.94737926521907E-01 - 2.50000000000000E-01 2.50000000000000E-01 1.20389122059610E+00 - 6.76246582772151E-01 2.50000000000000E-01 2.50000000000000E-01 - 1.20539375184324E+00 4.25895712464750E-01 2.50000000000000E-01 - 2.50000000000000E-01 1.46870992982599E+00 4.44185259205497E-01 - 2.50000000000000E-01 2.50000000000000E-01 1.00000000000000E+00 - 2.50000000000000E-01 5.00000000000000E-01 2.50000000000000E-01 - 1.75000000000000E+00 0.00000000000000E+00 5.00000000000000E-01 - 2.50000000000000E-01 2.00000000000000E+00 7.50000000000000E-01 - 5.00000000000000E-01 2.50000000000000E-01 1.25000000000000E+00 - 1.00000000000000E+00 5.00000000000000E-01 2.50000000000000E-01 - 1.32713397223596E+00 2.00510665587990E-01 5.00000000000000E-01 - 2.50000000000000E-01 1.58171915768599E+00 2.04663521459000E-01 - 5.00000000000000E-01 2.50000000000000E-01 1.79975007305965E+00 - 3.27394710883601E-01 5.00000000000000E-01 2.50000000000000E-01 - 1.79495960350997E+00 5.77789090564371E-01 5.00000000000000E-01 - 2.50000000000000E-01 1.67489393228352E+00 7.97461429892528E-01 - 5.00000000000000E-01 2.50000000000000E-01 1.42452256547730E+00 - 7.94737926521907E-01 5.00000000000000E-01 2.50000000000000E-01 - 1.20389122059610E+00 6.76246582772151E-01 5.00000000000000E-01 - 2.50000000000000E-01 1.20539375184324E+00 4.25895712464750E-01 - 5.00000000000000E-01 2.50000000000000E-01 1.46870992982599E+00 - 4.44185259205497E-01 5.00000000000000E-01 2.50000000000000E-01 - 1.00000000000000E+00 2.50000000000000E-01 7.50000000000000E-01 - 2.50000000000000E-01 1.75000000000000E+00 0.00000000000000E+00 - 7.50000000000000E-01 2.50000000000000E-01 2.00000000000000E+00 - 7.50000000000000E-01 7.50000000000000E-01 2.50000000000000E-01 - 1.25000000000000E+00 1.00000000000000E+00 7.50000000000000E-01 - 2.50000000000000E-01 1.32713397223596E+00 2.00510665587990E-01 - 7.50000000000000E-01 2.50000000000000E-01 1.58171915768599E+00 - 2.04663521459000E-01 7.50000000000000E-01 2.50000000000000E-01 - 1.79975007305965E+00 3.27394710883601E-01 7.50000000000000E-01 - 2.50000000000000E-01 1.79495960350997E+00 5.77789090564371E-01 - 7.50000000000000E-01 2.50000000000000E-01 1.67489393228352E+00 - 7.97461429892528E-01 7.50000000000000E-01 2.50000000000000E-01 - 1.42452256547730E+00 7.94737926521907E-01 7.50000000000000E-01 - 2.50000000000000E-01 1.20389122059610E+00 6.76246582772151E-01 - 7.50000000000000E-01 2.50000000000000E-01 1.20539375184324E+00 - 4.25895712464750E-01 7.50000000000000E-01 2.50000000000000E-01 - 1.46870992982599E+00 4.44185259205497E-01 7.50000000000000E-01 - 2.50000000000000E-01 1.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 2.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 2.00000000000000E+00 1.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 1.00000000000000E+00 1.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 1.25000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 2.50000000000000E-01 - 1.50000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 2.50000000000000E-01 2.00000000000000E+00 2.50000000000000E-01 - 0.00000000000000E+00 2.50000000000000E-01 2.00000000000000E+00 - 5.00000000000000E-01 0.00000000000000E+00 2.50000000000000E-01 - 1.75000000000000E+00 1.00000000000000E+00 0.00000000000000E+00 - 2.50000000000000E-01 1.50000000000000E+00 1.00000000000000E+00 - 0.00000000000000E+00 2.50000000000000E-01 1.00000000000000E+00 - 7.50000000000000E-01 0.00000000000000E+00 2.50000000000000E-01 - 1.00000000000000E+00 5.00000000000000E-01 0.00000000000000E+00 - 2.50000000000000E-01 1.00000000000000E+00 0.00000000000000E+00 - 2.50000000000000E-01 2.50000000000000E-01 2.00000000000000E+00 - 0.00000000000000E+00 2.50000000000000E-01 2.50000000000000E-01 - 2.00000000000000E+00 1.00000000000000E+00 2.50000000000000E-01 - 2.50000000000000E-01 1.00000000000000E+00 1.00000000000000E+00 - 2.50000000000000E-01 2.50000000000000E-01 1.25000000000000E+00 - 0.00000000000000E+00 2.50000000000000E-01 2.50000000000000E-01 - 1.50000000000000E+00 0.00000000000000E+00 2.50000000000000E-01 - 2.50000000000000E-01 2.00000000000000E+00 2.50000000000000E-01 - 2.50000000000000E-01 2.50000000000000E-01 2.00000000000000E+00 - 5.00000000000000E-01 2.50000000000000E-01 2.50000000000000E-01 - 1.75000000000000E+00 1.00000000000000E+00 2.50000000000000E-01 - 2.50000000000000E-01 1.50000000000000E+00 1.00000000000000E+00 - 2.50000000000000E-01 2.50000000000000E-01 1.00000000000000E+00 - 7.50000000000000E-01 2.50000000000000E-01 2.50000000000000E-01 - 1.00000000000000E+00 5.00000000000000E-01 2.50000000000000E-01 - 2.50000000000000E-01 1.00000000000000E+00 0.00000000000000E+00 - 5.00000000000000E-01 2.50000000000000E-01 2.00000000000000E+00 - 0.00000000000000E+00 5.00000000000000E-01 2.50000000000000E-01 - 2.00000000000000E+00 1.00000000000000E+00 5.00000000000000E-01 - 2.50000000000000E-01 1.00000000000000E+00 1.00000000000000E+00 - 5.00000000000000E-01 2.50000000000000E-01 1.25000000000000E+00 - 0.00000000000000E+00 5.00000000000000E-01 2.50000000000000E-01 - 1.50000000000000E+00 0.00000000000000E+00 5.00000000000000E-01 - 2.50000000000000E-01 2.00000000000000E+00 2.50000000000000E-01 - 5.00000000000000E-01 2.50000000000000E-01 2.00000000000000E+00 - 5.00000000000000E-01 5.00000000000000E-01 2.50000000000000E-01 - 1.75000000000000E+00 1.00000000000000E+00 5.00000000000000E-01 - 2.50000000000000E-01 1.50000000000000E+00 1.00000000000000E+00 - 5.00000000000000E-01 2.50000000000000E-01 1.00000000000000E+00 - 7.50000000000000E-01 5.00000000000000E-01 2.50000000000000E-01 - 1.00000000000000E+00 5.00000000000000E-01 5.00000000000000E-01 - 2.50000000000000E-01 1.00000000000000E+00 0.00000000000000E+00 - 7.50000000000000E-01 2.50000000000000E-01 2.00000000000000E+00 - 0.00000000000000E+00 7.50000000000000E-01 2.50000000000000E-01 - 2.00000000000000E+00 1.00000000000000E+00 7.50000000000000E-01 - 2.50000000000000E-01 1.00000000000000E+00 1.00000000000000E+00 - 7.50000000000000E-01 2.50000000000000E-01 1.25000000000000E+00 - 0.00000000000000E+00 7.50000000000000E-01 2.50000000000000E-01 - 1.50000000000000E+00 0.00000000000000E+00 7.50000000000000E-01 - 2.50000000000000E-01 2.00000000000000E+00 2.50000000000000E-01 - 7.50000000000000E-01 2.50000000000000E-01 2.00000000000000E+00 - 5.00000000000000E-01 7.50000000000000E-01 2.50000000000000E-01 - 1.75000000000000E+00 1.00000000000000E+00 7.50000000000000E-01 - 2.50000000000000E-01 1.50000000000000E+00 1.00000000000000E+00 - 7.50000000000000E-01 2.50000000000000E-01 1.00000000000000E+00 - 7.50000000000000E-01 7.50000000000000E-01 2.50000000000000E-01 - 1.00000000000000E+00 5.00000000000000E-01 7.50000000000000E-01 - 2.50000000000000E-01 1.57180193105475E+00 6.20823344549013E-01 - 0.00000000000000E+00 2.50000000000000E-01 1.57180193105475E+00 - 6.20823344549013E-01 2.50000000000000E-01 2.50000000000000E-01 - 1.57180193105475E+00 6.20823344549013E-01 5.00000000000000E-01 - 2.50000000000000E-01 1.57180193105475E+00 6.20823344549013E-01 - 7.50000000000000E-01 2.50000000000000E-01 1.00000000000000E+00 - 2.50000000000000E-01 1.00000000000000E+00 2.50000000000000E-01 - 1.75000000000000E+00 0.00000000000000E+00 1.00000000000000E+00 - 2.50000000000000E-01 2.00000000000000E+00 7.50000000000000E-01 - 1.00000000000000E+00 2.50000000000000E-01 1.25000000000000E+00 - 1.00000000000000E+00 1.00000000000000E+00 2.50000000000000E-01 - 1.32713397223596E+00 2.00510665587990E-01 1.00000000000000E+00 - 2.50000000000000E-01 1.58171915768599E+00 2.04663521459000E-01 - 1.00000000000000E+00 2.50000000000000E-01 1.79975007305965E+00 - 3.27394710883601E-01 1.00000000000000E+00 2.50000000000000E-01 - 1.79495960350997E+00 5.77789090564371E-01 1.00000000000000E+00 - 2.50000000000000E-01 1.67489393228352E+00 7.97461429892528E-01 - 1.00000000000000E+00 2.50000000000000E-01 1.42452256547730E+00 - 7.94737926521907E-01 1.00000000000000E+00 2.50000000000000E-01 - 1.20389122059610E+00 6.76246582772151E-01 1.00000000000000E+00 - 2.50000000000000E-01 1.20539375184324E+00 4.25895712464750E-01 - 1.00000000000000E+00 2.50000000000000E-01 1.46870992982599E+00 - 4.44185259205497E-01 1.00000000000000E+00 2.50000000000000E-01 - 1.00000000000000E+00 0.00000000000000E+00 1.00000000000000E+00 - 0.00000000000000E+00 2.00000000000000E+00 0.00000000000000E+00 - 1.00000000000000E+00 0.00000000000000E+00 2.00000000000000E+00 - 1.00000000000000E+00 1.00000000000000E+00 0.00000000000000E+00 - 1.00000000000000E+00 1.00000000000000E+00 1.00000000000000E+00 - 0.00000000000000E+00 1.25000000000000E+00 0.00000000000000E+00 - 1.00000000000000E+00 2.50000000000000E-01 1.50000000000000E+00 - 0.00000000000000E+00 1.00000000000000E+00 2.50000000000000E-01 - 2.00000000000000E+00 2.50000000000000E-01 1.00000000000000E+00 - 2.50000000000000E-01 2.00000000000000E+00 5.00000000000000E-01 - 1.00000000000000E+00 2.50000000000000E-01 1.75000000000000E+00 - 1.00000000000000E+00 1.00000000000000E+00 2.50000000000000E-01 - 1.50000000000000E+00 1.00000000000000E+00 1.00000000000000E+00 - 2.50000000000000E-01 1.00000000000000E+00 7.50000000000000E-01 - 1.00000000000000E+00 2.50000000000000E-01 1.00000000000000E+00 - 5.00000000000000E-01 1.00000000000000E+00 2.50000000000000E-01 - 1.57180193105475E+00 6.20823344549013E-01 1.00000000000000E+00 - 2.50000000000000E-01 1.00000000000000E+00 1.25000000000000E+00 - 0.00000000000000E+00 2.50000000000000E-01 1.25000000000000E+00 - 1.25000000000000E+00 0.00000000000000E+00 -7.81250000000000E-02 - 1.50000000000000E+00 1.25000000000000E+00 0.00000000000000E+00 - -2.18750000000000E-01 1.75000000000000E+00 1.25000000000000E+00 - 0.00000000000000E+00 -3.59375000000000E-01 1.00000000000000E+00 - 1.50000000000000E+00 0.00000000000000E+00 2.50000000000000E-01 - 1.25000000000000E+00 1.50000000000000E+00 0.00000000000000E+00 - -2.18750000000000E-01 1.50000000000000E+00 1.50000000000000E+00 - 0.00000000000000E+00 -3.12500000000000E-01 1.75000000000000E+00 - 1.50000000000000E+00 0.00000000000000E+00 -4.06250000000000E-01 - 1.00000000000000E+00 1.75000000000000E+00 0.00000000000000E+00 - 2.50000000000000E-01 1.25000000000000E+00 1.75000000000000E+00 - 0.00000000000000E+00 -3.59375000000000E-01 1.50000000000000E+00 - 1.75000000000000E+00 0.00000000000000E+00 -4.06250000000000E-01 - 1.75000000000000E+00 1.75000000000000E+00 0.00000000000000E+00 - -4.53125000000000E-01 0.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 1.00000000000000E+00 - 1.25000000000000E+00 2.50000000000000E-01 2.50000000000000E-01 - 1.25000000000000E+00 1.25000000000000E+00 2.50000000000000E-01 - 2.50000000000000E-01 1.50000000000000E+00 1.25000000000000E+00 - 2.50000000000000E-01 2.50000000000000E-01 1.75000000000000E+00 - 1.25000000000000E+00 2.50000000000000E-01 2.50000000000000E-01 - 1.00000000000000E+00 1.50000000000000E+00 2.50000000000000E-01 - 2.50000000000000E-01 1.25000000000000E+00 1.50000000000000E+00 - 2.50000000000000E-01 2.50000000000000E-01 1.50000000000000E+00 - 1.50000000000000E+00 2.50000000000000E-01 2.50000000000000E-01 - 1.75000000000000E+00 1.50000000000000E+00 2.50000000000000E-01 - 2.50000000000000E-01 1.00000000000000E+00 1.75000000000000E+00 - 2.50000000000000E-01 2.50000000000000E-01 1.25000000000000E+00 - 1.75000000000000E+00 2.50000000000000E-01 2.50000000000000E-01 - 1.50000000000000E+00 1.75000000000000E+00 2.50000000000000E-01 - 2.50000000000000E-01 1.75000000000000E+00 1.75000000000000E+00 - 2.50000000000000E-01 2.50000000000000E-01 0.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 1.00000000000000E+00 1.25000000000000E+00 5.00000000000000E-01 - 2.50000000000000E-01 1.25000000000000E+00 1.25000000000000E+00 - 5.00000000000000E-01 2.50000000000000E-01 1.50000000000000E+00 - 1.25000000000000E+00 5.00000000000000E-01 2.50000000000000E-01 - 1.75000000000000E+00 1.25000000000000E+00 5.00000000000000E-01 - 2.50000000000000E-01 1.00000000000000E+00 1.50000000000000E+00 - 5.00000000000000E-01 2.50000000000000E-01 1.25000000000000E+00 - 1.50000000000000E+00 5.00000000000000E-01 2.50000000000000E-01 - 1.50000000000000E+00 1.50000000000000E+00 5.00000000000000E-01 - 2.50000000000000E-01 1.75000000000000E+00 1.50000000000000E+00 - 5.00000000000000E-01 2.50000000000000E-01 1.00000000000000E+00 - 1.75000000000000E+00 5.00000000000000E-01 2.50000000000000E-01 - 1.25000000000000E+00 1.75000000000000E+00 5.00000000000000E-01 - 2.50000000000000E-01 1.50000000000000E+00 1.75000000000000E+00 - 5.00000000000000E-01 2.50000000000000E-01 1.75000000000000E+00 - 1.75000000000000E+00 5.00000000000000E-01 2.50000000000000E-01 - 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 1.00000000000000E+00 1.25000000000000E+00 - 7.50000000000000E-01 2.50000000000000E-01 1.25000000000000E+00 - 1.25000000000000E+00 7.50000000000000E-01 2.50000000000000E-01 - 1.50000000000000E+00 1.25000000000000E+00 7.50000000000000E-01 - 2.50000000000000E-01 1.75000000000000E+00 1.25000000000000E+00 - 7.50000000000000E-01 2.50000000000000E-01 1.00000000000000E+00 - 1.50000000000000E+00 7.50000000000000E-01 2.50000000000000E-01 - 1.25000000000000E+00 1.50000000000000E+00 7.50000000000000E-01 - 2.50000000000000E-01 1.50000000000000E+00 1.50000000000000E+00 - 7.50000000000000E-01 2.50000000000000E-01 1.75000000000000E+00 - 1.50000000000000E+00 7.50000000000000E-01 2.50000000000000E-01 - 1.00000000000000E+00 1.75000000000000E+00 7.50000000000000E-01 - 2.50000000000000E-01 1.25000000000000E+00 1.75000000000000E+00 - 7.50000000000000E-01 2.50000000000000E-01 1.50000000000000E+00 - 1.75000000000000E+00 7.50000000000000E-01 2.50000000000000E-01 - 1.75000000000000E+00 1.75000000000000E+00 7.50000000000000E-01 - 2.50000000000000E-01 2.00000000000000E+00 1.25000000000000E+00 - 0.00000000000000E+00 2.50000000000000E-01 2.00000000000000E+00 - 1.50000000000000E+00 0.00000000000000E+00 2.50000000000000E-01 - 2.00000000000000E+00 1.75000000000000E+00 0.00000000000000E+00 - 2.50000000000000E-01 0.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 2.00000000000000E+00 - 1.25000000000000E+00 2.50000000000000E-01 2.50000000000000E-01 - 2.00000000000000E+00 1.50000000000000E+00 2.50000000000000E-01 - 2.50000000000000E-01 2.00000000000000E+00 1.75000000000000E+00 - 2.50000000000000E-01 2.50000000000000E-01 0.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 2.00000000000000E+00 1.25000000000000E+00 5.00000000000000E-01 - 2.50000000000000E-01 2.00000000000000E+00 1.50000000000000E+00 - 5.00000000000000E-01 2.50000000000000E-01 2.00000000000000E+00 - 1.75000000000000E+00 5.00000000000000E-01 2.50000000000000E-01 - 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 2.00000000000000E+00 1.25000000000000E+00 - 7.50000000000000E-01 2.50000000000000E-01 2.00000000000000E+00 - 1.50000000000000E+00 7.50000000000000E-01 2.50000000000000E-01 - 2.00000000000000E+00 1.75000000000000E+00 7.50000000000000E-01 - 2.50000000000000E-01 1.25000000000000E+00 2.00000000000000E+00 - 0.00000000000000E+00 2.50000000000000E-01 1.50000000000000E+00 - 2.00000000000000E+00 0.00000000000000E+00 2.50000000000000E-01 - 1.75000000000000E+00 2.00000000000000E+00 0.00000000000000E+00 - 2.50000000000000E-01 2.00000000000000E+00 2.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 1.25000000000000E+00 - 2.00000000000000E+00 2.50000000000000E-01 2.50000000000000E-01 - 1.50000000000000E+00 2.00000000000000E+00 2.50000000000000E-01 - 2.50000000000000E-01 1.75000000000000E+00 2.00000000000000E+00 - 2.50000000000000E-01 2.50000000000000E-01 2.00000000000000E+00 - 2.00000000000000E+00 2.50000000000000E-01 2.50000000000000E-01 - 1.25000000000000E+00 2.00000000000000E+00 5.00000000000000E-01 - 2.50000000000000E-01 1.50000000000000E+00 2.00000000000000E+00 - 5.00000000000000E-01 2.50000000000000E-01 1.75000000000000E+00 - 2.00000000000000E+00 5.00000000000000E-01 2.50000000000000E-01 - 2.00000000000000E+00 2.00000000000000E+00 5.00000000000000E-01 - 2.50000000000000E-01 1.25000000000000E+00 2.00000000000000E+00 - 7.50000000000000E-01 2.50000000000000E-01 1.50000000000000E+00 - 2.00000000000000E+00 7.50000000000000E-01 2.50000000000000E-01 - 1.75000000000000E+00 2.00000000000000E+00 7.50000000000000E-01 - 2.50000000000000E-01 2.00000000000000E+00 2.00000000000000E+00 - 7.50000000000000E-01 2.50000000000000E-01 1.00000000000000E+00 - 2.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 1.00000000000000E+00 2.00000000000000E+00 2.50000000000000E-01 - 2.50000000000000E-01 1.00000000000000E+00 2.00000000000000E+00 - 5.00000000000000E-01 2.50000000000000E-01 1.00000000000000E+00 - 2.00000000000000E+00 7.50000000000000E-01 2.50000000000000E-01 - 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 1.00000000000000E+00 1.25000000000000E+00 - 1.00000000000000E+00 2.50000000000000E-01 1.25000000000000E+00 - 1.25000000000000E+00 1.00000000000000E+00 -7.81250000000000E-02 - 1.50000000000000E+00 1.25000000000000E+00 1.00000000000000E+00 - -2.18750000000000E-01 1.75000000000000E+00 1.25000000000000E+00 - 1.00000000000000E+00 -3.59375000000000E-01 1.00000000000000E+00 - 1.50000000000000E+00 1.00000000000000E+00 2.50000000000000E-01 - 1.25000000000000E+00 1.50000000000000E+00 1.00000000000000E+00 - -2.18750000000000E-01 1.50000000000000E+00 1.50000000000000E+00 - 1.00000000000000E+00 -3.12500000000000E-01 1.75000000000000E+00 - 1.50000000000000E+00 1.00000000000000E+00 -4.06250000000000E-01 - 1.00000000000000E+00 1.75000000000000E+00 1.00000000000000E+00 - 2.50000000000000E-01 1.25000000000000E+00 1.75000000000000E+00 - 1.00000000000000E+00 -3.59375000000000E-01 1.50000000000000E+00 - 1.75000000000000E+00 1.00000000000000E+00 -4.06250000000000E-01 - 1.75000000000000E+00 1.75000000000000E+00 1.00000000000000E+00 - -4.53125000000000E-01 0.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 2.00000000000000E+00 - 1.25000000000000E+00 1.00000000000000E+00 2.50000000000000E-01 - 2.00000000000000E+00 1.50000000000000E+00 1.00000000000000E+00 - 2.50000000000000E-01 2.00000000000000E+00 1.75000000000000E+00 - 1.00000000000000E+00 2.50000000000000E-01 1.25000000000000E+00 - 2.00000000000000E+00 1.00000000000000E+00 2.50000000000000E-01 - 1.50000000000000E+00 2.00000000000000E+00 1.00000000000000E+00 - 2.50000000000000E-01 1.75000000000000E+00 2.00000000000000E+00 - 1.00000000000000E+00 2.50000000000000E-01 2.00000000000000E+00 - 2.00000000000000E+00 1.00000000000000E+00 0.00000000000000E+00 - 1.00000000000000E+00 2.00000000000000E+00 1.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 0.00000000000000E+00 2.50000000000000E-01 - 0.00000000000000E+00 0.00000000000000E+00 2.50000000000000E-01 - 5.00000000000000E-01 0.00000000000000E+00 0.00000000000000E+00 - 2.50000000000000E-01 7.50000000000000E-01 0.00000000000000E+00 - 0.00000000000000E+00 2.50000000000000E-01 7.50000000000000E-01 - 1.00000000000000E+00 0.00000000000000E+00 2.50000000000000E-01 - 5.00000000000000E-01 1.00000000000000E+00 0.00000000000000E+00 - 2.50000000000000E-01 2.50000000000000E-01 1.00000000000000E+00 - 0.00000000000000E+00 2.50000000000000E-01 0.00000000000000E+00 - 1.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 - 0.00000000000000E+00 7.50000000000000E-01 0.00000000000000E+00 - 2.50000000000000E-01 0.00000000000000E+00 5.00000000000000E-01 - 0.00000000000000E+00 2.50000000000000E-01 0.00000000000000E+00 - 2.50000000000000E-01 0.00000000000000E+00 2.50000000000000E-01 - 2.50000000000000E-01 2.50000000000000E-01 0.00000000000000E+00 - -7.81250000000000E-02 5.00000000000000E-01 2.50000000000000E-01 - 0.00000000000000E+00 -2.18750000000000E-01 7.50000000000000E-01 - 2.50000000000000E-01 0.00000000000000E+00 -3.59375000000000E-01 - 2.50000000000000E-01 5.00000000000000E-01 0.00000000000000E+00 - -2.18750000000000E-01 5.00000000000000E-01 5.00000000000000E-01 - 0.00000000000000E+00 -3.12500000000000E-01 7.50000000000000E-01 - 5.00000000000000E-01 0.00000000000000E+00 -4.06250000000000E-01 - 2.50000000000000E-01 7.50000000000000E-01 0.00000000000000E+00 - -3.59375000000000E-01 5.00000000000000E-01 7.50000000000000E-01 - 0.00000000000000E+00 -4.06250000000000E-01 7.50000000000000E-01 - 7.50000000000000E-01 0.00000000000000E+00 -4.53125000000000E-01 - 0.00000000000000E+00 0.00000000000000E+00 2.50000000000000E-01 - 2.50000000000000E-01 2.50000000000000E-01 0.00000000000000E+00 - 2.50000000000000E-01 2.50000000000000E-01 2.50000000000000E-01 - 2.50000000000000E-01 2.50000000000000E-01 2.50000000000000E-01 - 0.00000000000000E+00 2.50000000000000E-01 2.50000000000000E-01 - 2.50000000000000E-01 5.00000000000000E-01 0.00000000000000E+00 - 2.50000000000000E-01 2.50000000000000E-01 5.00000000000000E-01 - 2.50000000000000E-01 2.50000000000000E-01 2.50000000000000E-01 - 7.50000000000000E-01 0.00000000000000E+00 2.50000000000000E-01 - 2.50000000000000E-01 7.50000000000000E-01 2.50000000000000E-01 - 2.50000000000000E-01 2.50000000000000E-01 2.50000000000000E-01 - 5.00000000000000E-01 2.50000000000000E-01 2.50000000000000E-01 - 0.00000000000000E+00 5.00000000000000E-01 2.50000000000000E-01 - 2.50000000000000E-01 5.00000000000000E-01 5.00000000000000E-01 - 2.50000000000000E-01 2.50000000000000E-01 7.50000000000000E-01 - 5.00000000000000E-01 2.50000000000000E-01 2.50000000000000E-01 - 2.50000000000000E-01 7.50000000000000E-01 2.50000000000000E-01 - 2.50000000000000E-01 0.00000000000000E+00 7.50000000000000E-01 - 2.50000000000000E-01 2.50000000000000E-01 5.00000000000000E-01 - 7.50000000000000E-01 2.50000000000000E-01 2.50000000000000E-01 - 7.50000000000000E-01 7.50000000000000E-01 2.50000000000000E-01 - 2.50000000000000E-01 2.50000000000000E-01 1.00000000000000E+00 - 2.50000000000000E-01 2.50000000000000E-01 0.00000000000000E+00 - 1.00000000000000E+00 2.50000000000000E-01 2.50000000000000E-01 - 5.00000000000000E-01 1.00000000000000E+00 2.50000000000000E-01 - 2.50000000000000E-01 7.50000000000000E-01 1.00000000000000E+00 - 2.50000000000000E-01 2.50000000000000E-01 0.00000000000000E+00 - 0.00000000000000E+00 5.00000000000000E-01 2.50000000000000E-01 - 2.50000000000000E-01 0.00000000000000E+00 5.00000000000000E-01 - 2.50000000000000E-01 2.50000000000000E-01 2.50000000000000E-01 - 5.00000000000000E-01 2.50000000000000E-01 0.00000000000000E+00 - 2.50000000000000E-01 5.00000000000000E-01 2.50000000000000E-01 - 5.00000000000000E-01 0.00000000000000E+00 5.00000000000000E-01 - 2.50000000000000E-01 5.00000000000000E-01 2.50000000000000E-01 - 5.00000000000000E-01 2.50000000000000E-01 7.50000000000000E-01 - 0.00000000000000E+00 5.00000000000000E-01 2.50000000000000E-01 - 7.50000000000000E-01 2.50000000000000E-01 5.00000000000000E-01 - 2.50000000000000E-01 2.50000000000000E-01 5.00000000000000E-01 - 5.00000000000000E-01 2.50000000000000E-01 0.00000000000000E+00 - 5.00000000000000E-01 5.00000000000000E-01 2.50000000000000E-01 - 5.00000000000000E-01 5.00000000000000E-01 5.00000000000000E-01 - 2.50000000000000E-01 7.50000000000000E-01 5.00000000000000E-01 - 5.00000000000000E-01 2.50000000000000E-01 2.50000000000000E-01 - 7.50000000000000E-01 5.00000000000000E-01 2.50000000000000E-01 - 0.00000000000000E+00 7.50000000000000E-01 5.00000000000000E-01 - 2.50000000000000E-01 5.00000000000000E-01 7.50000000000000E-01 - 5.00000000000000E-01 2.50000000000000E-01 7.50000000000000E-01 - 7.50000000000000E-01 5.00000000000000E-01 2.50000000000000E-01 - 2.50000000000000E-01 1.00000000000000E+00 5.00000000000000E-01 - 2.50000000000000E-01 0.00000000000000E+00 1.00000000000000E+00 - 5.00000000000000E-01 2.50000000000000E-01 5.00000000000000E-01 - 1.00000000000000E+00 5.00000000000000E-01 2.50000000000000E-01 - 7.50000000000000E-01 1.00000000000000E+00 5.00000000000000E-01 - 2.50000000000000E-01 0.00000000000000E+00 0.00000000000000E+00 - 7.50000000000000E-01 2.50000000000000E-01 2.50000000000000E-01 - 0.00000000000000E+00 7.50000000000000E-01 2.50000000000000E-01 - 2.50000000000000E-01 2.50000000000000E-01 7.50000000000000E-01 - 2.50000000000000E-01 0.00000000000000E+00 2.50000000000000E-01 - 7.50000000000000E-01 2.50000000000000E-01 5.00000000000000E-01 - 0.00000000000000E+00 7.50000000000000E-01 2.50000000000000E-01 - 5.00000000000000E-01 2.50000000000000E-01 7.50000000000000E-01 - 2.50000000000000E-01 7.50000000000000E-01 0.00000000000000E+00 - 7.50000000000000E-01 2.50000000000000E-01 7.50000000000000E-01 - 2.50000000000000E-01 7.50000000000000E-01 2.50000000000000E-01 - 2.50000000000000E-01 5.00000000000000E-01 7.50000000000000E-01 - 2.50000000000000E-01 0.00000000000000E+00 5.00000000000000E-01 - 7.50000000000000E-01 2.50000000000000E-01 5.00000000000000E-01 - 5.00000000000000E-01 7.50000000000000E-01 2.50000000000000E-01 - 7.50000000000000E-01 5.00000000000000E-01 7.50000000000000E-01 - 2.50000000000000E-01 2.50000000000000E-01 7.50000000000000E-01 - 7.50000000000000E-01 2.50000000000000E-01 0.00000000000000E+00 - 7.50000000000000E-01 7.50000000000000E-01 2.50000000000000E-01 - 5.00000000000000E-01 7.50000000000000E-01 7.50000000000000E-01 - 2.50000000000000E-01 7.50000000000000E-01 7.50000000000000E-01 - 7.50000000000000E-01 2.50000000000000E-01 2.50000000000000E-01 - 1.00000000000000E+00 7.50000000000000E-01 2.50000000000000E-01 - 0.00000000000000E+00 1.00000000000000E+00 7.50000000000000E-01 - 2.50000000000000E-01 5.00000000000000E-01 1.00000000000000E+00 - 7.50000000000000E-01 2.50000000000000E-01 7.50000000000000E-01 - 1.00000000000000E+00 7.50000000000000E-01 2.50000000000000E-01 - 0.00000000000000E+00 0.00000000000000E+00 1.00000000000000E+00 - 0.00000000000000E+00 2.50000000000000E-01 0.00000000000000E+00 - 1.00000000000000E+00 2.50000000000000E-01 2.50000000000000E-01 - 2.50000000000000E-01 1.00000000000000E+00 -7.81250000000000E-02 - 0.00000000000000E+00 2.50000000000000E-01 1.00000000000000E+00 - 2.50000000000000E-01 5.00000000000000E-01 0.00000000000000E+00 - 1.00000000000000E+00 2.50000000000000E-01 5.00000000000000E-01 - 2.50000000000000E-01 1.00000000000000E+00 -2.18750000000000E-01 - 7.50000000000000E-01 0.00000000000000E+00 1.00000000000000E+00 - 2.50000000000000E-01 7.50000000000000E-01 2.50000000000000E-01 - 1.00000000000000E+00 -3.59375000000000E-01 2.50000000000000E-01 - 5.00000000000000E-01 1.00000000000000E+00 -2.18750000000000E-01 - 0.00000000000000E+00 5.00000000000000E-01 1.00000000000000E+00 - 2.50000000000000E-01 5.00000000000000E-01 5.00000000000000E-01 - 1.00000000000000E+00 -3.12500000000000E-01 7.50000000000000E-01 - 5.00000000000000E-01 1.00000000000000E+00 -4.06250000000000E-01 - 2.50000000000000E-01 7.50000000000000E-01 1.00000000000000E+00 - -3.59375000000000E-01 0.00000000000000E+00 7.50000000000000E-01 - 1.00000000000000E+00 2.50000000000000E-01 5.00000000000000E-01 - 7.50000000000000E-01 1.00000000000000E+00 -4.06250000000000E-01 - 7.50000000000000E-01 7.50000000000000E-01 1.00000000000000E+00 - -4.53125000000000E-01 2.50000000000000E-01 1.00000000000000E+00 - 1.00000000000000E+00 2.50000000000000E-01 0.00000000000000E+00 - 1.00000000000000E+00 1.00000000000000E+00 0.00000000000000E+00 - 5.00000000000000E-01 1.00000000000000E+00 1.00000000000000E+00 - 2.50000000000000E-01 7.50000000000000E-01 1.00000000000000E+00 - 1.00000000000000E+00 2.50000000000000E-01 0.00000000000000E+00 - 0.00000000000000E+00 1.00000000000000E+00 0.00000000000000E+00 - ENREGISTREMENT DE TYPE 5 -LABEL AUTOMATIQUE : 1 diff --git a/src/MEDMEM/DataTest/Data/maill.0.med b/src/MEDMEM/DataTest/Data/maill.0.med deleted file mode 100644 index 4994e63a1f1d82cd4af1c48d226a779faf218634..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 100351 zcmeHQ3w#ts(x2raQ4tnYh$u3mo)HC;03jlpS;&%&CYvP>44@|R2mu5mqC^o`P%+>s z(L;&nAwdsBe?Ee!U*Pc4s9^AMUqn2+XDz}09ED9PvuPQ=H1JdcGdn9uUN|U( z^Dd{uqa8wiJmhyRWFwC<($Pnz~ZM<|4RB-r0#AtMH8 zqkpGX^FUlJjcv>hC7~Sxn?<4&0h@G!W-~JAZwJeH`3{yrARkGNJ1fp}VSII9=Q2x5`McQx@+G6=Kni^AmGJ!; z^&o%;wmZ|2o{^h9E)Ua2ex<5A<3v1B&Z5zQ0PUO9mSj*D`}3^}S%!>;2ItWZ;~^~r zeRvTZ2#Ap#dcgr%b|?VQcwrnvb1h_dGEy8+PTWcY0;2xh zXK`qVjQaE5-b^04b?CyZv!+8pbiWecgQYySnaTvoC0H|A`LrP8g|q-U&Da0 z0Wbis)C1!B#Q6BcgoK2|grs3Z6Njl&Lr|Wr69~WsqjD7M?ozyl9UafRt2yq`*;?AJ z#`7#Rm*Kod=pSvQ;N`NN9*rS{96Jx~91G)Bxt81X2ki>&pte`jxnM_Vf0fq+JKL1U zP?IG2w5B{WAK`splU>DVho`DaQ%kVHbwE3M0Kf>>j;hXJ0#uHc$J;}=b|guKte`gj zEApFln?hG?`6x>FB|!=9w5 z3A!m~0fhpU1V|?{ihmV2Xl?$KMpkgRQ~?dbrhj1ND`8Slv)vGPR)S17cUB_Mp+JWL z9S$@JXo4o7%4q^B)dWZpP#OXuXMVss9Z-hZB~?i2ujUYbwApbAn& zk)O(lcFGf~4E3~lQvm=4hk}AbLBXM*;80L-sHULGKZ2T$N|Pz2CDWjtzbf=f(I|ih zLiCE$t4;H$a`fs`#pxACASf8P(>#A3HQBVOR|*rKP8azyEu#}aZo|f)*(#EyQ zCZ)GZF-?U?S2i8D%8``i@nq$+p2jkwO)c4fqgEDbgS!VGOP4WOc^L(oy|jv=^60GW z)PgieUh9;mT5p>)P<>k6Y7InB9uJ_>{zJDy15YlJD>sm1rQ=_txOC%rj1$}}idi&D z5D>+slFR_8hItr-1Mj=hUWy@p#DT_j3FEW_rLK)`@<2wBk1rp4Me(3OK35z|+kvuF z$N#Ip?`F^a_46VO85;lx-BtD0EZ=Az$I*{rMdhd$Z^8XH%)sZjDd^0ux}aG|vCo9A z4(+Pq+|YbzSB>X~=0kgyE(p!n-p}goD)fBL^`KC=_Vg~;6P2ST*>Za-gqquy=O*Kdc1=4!87|D6L0g=Np zFi%G1=-yuY8Tvo1k!m~b@I=5HmjCM{e1Al~j9pF_H41gBSixumq*==PYgPn={twsn z;Q}-O0PQdy(l}0gUkQznQ5@EI1(Qer5V|z$tl1C{tv9a%yYg@fvw7#P(niRSDP#vY zY&BfV(p5m~fUmkZkguYMr3--`0>0v#0{L7wva}tj3>A_2fqaserI!w16vx$K7+0}< zt}=Gs4wR*i{a;akmi`{PEk^wrUJKTiQG_nZI%`G*MEyA)>?(MFZhC)&fIq^3Wd`H3dGN>8J}f`p>Z_pS&<#a zgIyWLDgvQS(UfGz<&FHEAkUnglWwC36UL2+e0H{ zWQX~an7n0&p>Z_pS&<#agI)1<$j{r?!7?_CSE|M{q)LIB6}L$BYU_CA$qpW`xF$x5 zaCFMIbbTKE5&_-9ecpHo?2F2^aD5(B2?K~$d+YxZ`Au(xev?dQZMFPn>tC~uP@>3h zRtfy3$PT4fLu+dkzr{|o>@YNf<~}R3!+5YOqxh{H#xacFN(vcX$w1AGUdy#>Zv3_m zstVV?DrYkRD#xx($6C)5GqvT|Mzf^IPk1Br6D6}4s#d%boz^At6IB8~A+kg1wb1w( z#VfV5EjtX2pt;YA>@Xhe$|zn@U>w7EMV`U%YA7~0Zjox&*73?`9XwvCz9CYCqf=hw zC%h5*33(pF(~4K3)2>8*qDtT=M0O~>9vVNRc%}4K%ML>$XzsHjJB$arGKyCkZ)W&l zyi#`)OIH9jH+n7CuC3!0sg$*?qt34s-_mkyqghhapS^ceGaHXgRI^1?<*tU}kzoy0g_j_}vBykIQqUw&oRyI)(ke z3iG=<^7!w+scE_&;r3tEG~IvUb}b)&1)2ZVSN^LynT{(p=b-;;vd?F9qDMNpbhb=6 zgq#)t@p9SD45RwGQU+{4|LeBu*I~7CZR(G+#HjzKPP=)^+!-bFrrk1Eo;pn~nlYt# z#+Wg zb@2Iw>bs-M9$HIV(Y&*~BXkW$exmq(CU3Z_pS&^UcfL#TjcaD)tz%dlAV#uJM zP#y$(0$Kql>}vw~8vo4F)j$dGk@bOml~1sAF;KMA#*u-1b;&GU0W_W^rH0f%zS_|& zT@ExK_$t^9gzt`^^eT2j0qO-l7rbwR`o`t56OHT!NW$-?R&HYX$me~YrCms!4h>pt zrya_#jIckGa#j%H1jSk;N)QnB=em&n+3)*k;1AGlWBnY`sELgQ%Gvm!s?0lU(I6F=oe zc32sq9hN*|*`XiIQFkb^!#aT-@_wb^VFnq-E46SxQVulg01Z>&=Ef@rpxkiZEBYMb z6)M*e`gl>ybyi&WC$y@PCXdKOYR^%rZ^bL2aWv~$k)QB@U4R42NH zi$^2;?j@CLAs$d=+v0)oeXORPq`m{dwqjU^14-YyA3J2Q_+IjVLq>h!<>*o5w`g=D zAd0JG`udN$@$o&&m82YJqIQ^@JyfIP@`h;?<14g3S(+sJAK9QBY)AO~ZQK5~#z%d#G(983S)ji0nwMITP{3~pS0G;^ z&sGqeZ)li&!wmVqS1kg(5z_g(5z_g(AM;oF*c^q%iqLgvpm|z~|1R z@aZ>fAKH5(9^eU!ni_#{$47kAoqrESH*W&tcZhkD01FFuyv6z}N3qLM3{+RY@w`ny z{ms>%f4@dozp?(E{0*wP`t!fLtE<0__2=Ik($#OQf54XxnyWwmJAS(Q+gN}8eJEZ1 z#`?p&5VL~j>d*f!kgonV*1zFe*6u2xy7~?D=jWK3tA9x$s~^9sudCl!|A7A2-2Put z#Of~us;l2v|KC{&>~C}R=fBgdtG|u)ciqU^Z3n8W-&p_OBGI4!?w_vyF!e`&B6(SB zmJVQ4SDvvxN2ny0$A3paS6-OyW37>-=Gv#Lj7i#o>gqSv=U1$o(&pMH|300r{x;U1 ze?M1Ozp?(mM4~^xK3`YAvHk)6vANfufA3gVzp?&@BhjB<@29K3jrHf>r`FYPtpA}% z^yk+P=;}AtU-M5mp78Hg>&i3G$6pug*h0WUz(T-6z(U}7BY^7`6lh31(5k(mTV}K_ z+5SG0$8`{)OS8_J4FQ|fNn7h8gJKv*CD%a)Qb?j5qW#$+zcE5PEdG!cWZ5AA8f8Sd ze&!FwKBAey!>!#c1Kun@2iun@2iIF1O=d2afwgN9FC)%^r@r?*Qd zs{2XmezLmLcWip7JN04ImG)Bi-s)~`76KLm76KLm76KLm9S{MWcf}VI>p%xG4eyMD zD`hzU{~eR_1{b$-O^$$Y{=WefM+!-_!+1#Jd`%%v3<~fvvcvjDCTPw73jj2EwoU35 z@Eppn-M&atIoMSUH_Wkl+OEF$x9h)U03jRshNa7ZqP^yy#5j;I84Cuw5pd3*$?+9~ z1kils8_4m=zz5Wed{=UOF5p87e8-w#e|AB|$v`VQLHh&^GV0G&KQck9KMMdfdA7)} zlz-0@&j*Sy@XuYUz#pI$isVq!J35w?x$MTBtAL+EfX&7cck&?9YWiu!7=%La`R%5YRuLkJYY2FF6IURit4j zOT&)BDtH^jO&E@!2jzwRoL(zklBgWJc4b_Pj&G8;t3y8>-}YFwTL@SPSO{1MSO{1M zSO^>|1ZsB1ZS~}@-dgkS6{SUo`**K-?@in62TKpt?0Nm4+b5qn7Td9HG&@RpvTErK zZ+(@Uvi|&SgP#A~k@D9U9ABV%fA->Bh_Fxzn|LUYhM2A{Q3Jx9!Ga-t|lhJAHT2QkHcvyjvkN`-)H$+bCK=ZM~~?0 z&B_k5UN%!hub;L))%bl^Z9PwS$)%N#*IoUNla{8}?HqN->rTJ#l$$*+Pm-m-Xbh6{ z08pFls%I29R_hKd57*uD<%PSR*B=jRm;QD|7c61>Y*UNQvQ2s^uBjay9%&Bkl<4~T z6@^7u)Iz{?2#Dr&WgGUS;3^wEr?H>HzutH2*%e=hIAj`D#j`4n zb?GS23*&mDMTJ7qIwwLvolh7-f2)F0`dbxlXw?Bj%hHUA$t|BvGXA1CO>2ZQ-w^>S)MS_JdKnnmd9HJA@> zs+XJpY{U6rb>4N4S}%P}Af>y&fQ3L5A;8bm zV7y&&2}a<-!7!S4wV%)At@;1p_?bOdH2+U7XLb?CnHSn2KmT7Dp&iykMV1|!-Qt4l zC!GI>_v^}lqBNWT?*yyeC28*vW~gYc)fclPFHp3r`tt($h@gC|$LtjQGe7^|a0Mb6 z904Q0l6(=9N8E##V&$3@0nz-wG@RLm;ru`N1GK{OKd_^Gpk~D_QoSOb|1X3F1bts9 z*!+JyyDn6Y_4P6+p?whkIdR+|w5ayczK+rg^b;;jHkuh@Mk6UHYMG(PtBp52>>4 z;o*m#xSD;O7c(jU%2%G>=KRw9sk;38?ET(OdFNtX{+i8i-$N<~>hjlp zRQTbGy90iUj`ENv>JE0hZNzIj{`+PLT_2o=_rq^@V#oeppzdfm7q&eUq;} zP^`;e{qtvc-|r6iZ7<40?!UKsX0Mmhbo{Hjtm?k{vAcBnYp;DS`P~tZ=<@$~!6QAF zDEe|l?OeN~!82{)+&~t+@N>7XmnM-V|2TN_fJGmYr7usfa^J9sB=tMv z#hQOsDwBJ6B}L!vCkr|a+TVZbCgsix3Z86Cs#g~EtS>yYA(c#dfB$3OpMDV;x&4Zm zABPj=iP)ZxJ-bU*W;wQA*Y~nuK?jp|*|Axh3pOHLgh8#=g4w|rdN&XkgefIw(t=aw*nOa+L^=n^jBXfT_ux#J9T}s)G73uOd zHOe1&q*i~_3|KG@+Z!TSWsw;-9oHnEK^*h#*8T_S~0WTtIFkRa?e+7m-<8tFLOykTTf!e2=>i&^>1}-}60fs+WHr zr}`zWOY!e#sQLW+9(G%PmDiU4NL)fvfT zh39+lr30)vI;c?`T{_B&qoczTf@{g&=PEEC ~Ne25cn5Pe3di3N*I)9=7RAJAb z3}x4a%CURkGAN;a5ZnpbYL~bJt#8xj2Kab2isN6c|6@O~sD*%qfQ5jCfVmOi zpL^i?KksQ6u?5%PXx_k{$>iC+NANPNT=OCzT>n=DcEOn!+98Yjo8JGgiqH=0J(eAs z*UF4F6Fmne@ZJ0}pjeV_{oiC?BX@ig)i@?<7&`3cjT zP*4R$aUUPQp)lGZj#C(~R2$f#$RCwo!|aduM_6Ce;{@N)ae1x)>*umLI*zdQbGafwI+(!vIUR*{UAPX-M`8UL;VG;?BRpm6 z&&I+!G^A;Stv_3)qp<#r1kyhfw*JheqoQ`Mk_)#?>i0fb`RKsj%Vs~O%---P}vbRqs^CrZsxnfyA zQua*u!j;2jl2!XYIpN6QT5|8m!AD|d^;7P>ar(g8lC5NA!;QDB9{nC!y(DFA!|n{F z^y%j|oz?$K^5FAdRVnB8Axp;gNbFhFNEXGtv8ia|8{~o2z3+VB$B)RQl7j6YZH^@~ zkB-fLuUiUP^1<{I7kyhs7M?iz?>X8;JMRt!J-z%}$oSIQ8y<|9Xea zSbNo?Z)f%(k6irHmXRyFk=3Iwch(NtL>7PX>c;2pn?&w>Bm1&ZJqP0RCq52~g6B^W zufL*Wi7o%pn3jBB!8hs%4se|EzYd|kx7%9luh1T(Lh#=({`$8=d!B8+^>~`giR5{t z$?U;;9*Lc>4XIHaT{_i@quUVvc3(7qpR2%l%&bCfJ~vLcdxefu10$V3k)hq;&YyTE zuq#C6I>P)(@f4p$fu;5x<`J! zBb)ic^^^YV9qEVE5EnjN=W%K7`bK`<1E2rb&Bq$~8d%yWZm`d0^49!YaQw`kD}4Tc zH?xaa&b-hL`FY^I%Q!|3I3qi(FR|>9gDk3&qIqC4li5WXPy|Ky{Qp+QhgMiUj~#h| z;`mm7Lm;21e5}Xp6#Fy!ahy+=??EJkBVg2@lW%77h|0>U1bNzc2-`%WKkLmy8nu~8#b}VnmIQ04!)F<5U z3n^RWhbF%Mw~0!1>gJ4Z%YIXyd!g#^!l~nxrxwJVdEwyCl^5p6J4bynQrY^&tp~Rk zd6liU57zgot5&wGekX0(TW2fDYfia-?tuR&!_S;|_vWs*D3{!_S-+P=^k6<)i8~^Uqj#o3bzVr3ruf zB|&-n#8F!hKK-5Y%mssfNs7Bv`5)yK=etvTD7){lKeTf4Eal_H|EL{W(Mj1k;HC1e zKUU)W5AVly^FQW$UZ@RikvuOn+4noN4u|$2d13sAd8{a~2Y7#*c~YE5jN2q diff --git a/src/MEDMEM/DataTest/Data/mesh.med b/src/MEDMEM/DataTest/Data/mesh.med deleted file mode 100755 index 54bdd1b160adeeb6802806a6e12b14da93442f25..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 57535 zcmeI530zgx_Qx;I113&6p@KtBsem{Y>Q=dcihziUGa4v4;#6vyIA)oJX`-p+m_usL zS(%Xy*8fr2vq7J}hxV+fS7tAov;M!|-FwqLCysJ4eYZTv&-bo9uD$kJd!KXe<=*4{ zQQ;BgYL#>FC{w~w!r|vA?#jrQU)7Oy)|h9`Pc`(BRgNhtF<9lJoL%BvNtF8`F-4VY z;f(1stXG#V4tBe!3vU3K5btz4Fl+5wEjjhjlF|WXZU8@c;}m@y#a!z#Kp9sFE0^oj zytcLNdW~~^vt6S5=0Uz!%H-65V29&!G0!e5wb?P3ez@MRRxwXiu@t75_KArN_d&E7 zuM%p%GWI;I`pDWF>s9ZK08E?ynYrc0n*X0+wwF6E<@(AQ@Z4q}*WUv^xEtfX2~b1( zx$dGIjx}l@#hFZUKQFCO*A#tTa-FQuesC#MryDS<&r7(}JEp-wS+5uD1i3fL7I>c) zq&7tW`Zv5s_K!k3>^_-JV)-(ePK5}XDAUs@f@GTU%MO(3tq}WhSIDCV$nM}u>afX- z{hIFqt82D@dD$dSzN5)+FZV`qmp>1w^BO|rI?R3Of8R`5r`x1GD)Z6HrDXW0#Twh3 z=_T{~m6W+Z*Q?$eoFDIRn%rcxpZ;LE+#8Mp_lB{Do%3c7SY2bX{!d!XbCmlb_YrP- zxe(MjP4AK939@CFl4Vfguio_QHtCaOn?xo3P~m&GEYoe$rpkP@>RW>q(~WJCRi7{= zc^=N2VQiDA`UEK{Yp>6%c^{=!GLFkB+55=o6K~5|?G3-bNlVRp!yNPED#jVvF*o|d z8*^4MPby^06RR0#Wyjp;4{yv_#e8=mV;)`II4d1%@T9=M&Y4eq? zKj&*2=cd=C9dn~!yeVfD^SDCB{A6w8Z0wjD{o#!{tC+7VWX!Yc7-wb2+~^N)%vr_! zVj*LmRnIsp9dl#pm2>vB;L1MwU$wAWBjQbIk@@;BKbtA#$UybkP}zp-f=763DgBjv z9ohNn^Jd*9x0`H}rQ}Lv-)$?)ber~VWZqB7b;z#iU~J=PFY_hZNqL-Yx|`ZW$^4lJ zDYrr#3NyCxzg_0@Zj{e zvqP>Q9(n5X<7_1b%I2%jnsl37)hA2IbhMe)3NJWxn=@*C?pKm;{idnUFY?_kJbdbit@*D1jzhW)8`|ywCJzqYpYN;XpNjl8DL*qwMV>9 zTJ56*A^c)aP7!hIY)gC%ji$#oUh{MB*@CTh062 zUwv*VTg&SY&+UK3!@gd5Z&a<;agxP4miKZcT(>}e>U&5$U-6itzKa&EWD?4DsL#W6 z8$b1#Xl_IHzNRSQGtRCvki%L#1^aKXvbutG;h@5^XYi%6_^{p8CE{wvuO2J-?T+O|I&b zrDP(i52^PKT93c_ZcSc&*|!FSzj_a%+oV^Lb%{#K+||FD@A>l7ca5}Wj{jGEU$5tQ zC23y^uH>QrUA@(LA-`J~A4fU)xvjbxD~=V# zWTn8)>fT5=Ld!cse=RN@;-j8H zO(G8VC zhoY_*JelvBM#g;amDI;L9M`Y?HwB|lye(&W9aiTG^Xb4G^Mt;}8QC#6`okM@Rxuav zN^7qa^QivDS?QP?OaJV-0Yc8eN_zYJtnBvw@^Kurw@*Es(iF~ zhS}4-Re4`k?mg|jePwuuecrzg_5N?T?YZ^)2lW(Ve20waIjpl7Fm1`qrIoSnx;dBa zDH|su4}I2qEM(lk`5kw3O%MwjcB^pd*GQ3Z^YS0&F7G6owwZBeZ@b_B$U zj~gyXZhuRhXwdkBmsX#T63ffopZVIt-onwL)ZgA37bV(;>^WQ~rKR}v*o3%U8A6=c zQzGkwFQSC+qT;)QTO^3v-)wQAW6f|eq|N(p#x#!>ZM!5MUcNU<^vhZi^Usm7B7E%d zUxw~=iZ6eDzh>s_PNLJ{d;ax#W~g{4V8wAOWtA}OeIK9@cg7?RrLY8Z3Zl%k${H$8?c)Bl@&S4tI4zqP$`yx;1JrvFM-Uv2$w_L=Ry+Wf1Hb_NZLA0*~fIQ8(lY6C@1 zZtj*X6~o0_dzNgN(>O&O>*Y*|{yJG)@ZBH%$!jsWO*-#oSk$Z=4s=M~ryk>;C5t3=mt^wTYavKS_Ld$NCDzKTZ;vDJQ;3`!ZRa-m-98 z*~xuHofk8{TC!k}xOgu0{9E;hi=*ex)uQAz;}gZ{O3gDjU5F7rp`WFe{P!JV*{iMg2DKa_)+g>y@6fY{_+e`4 zv5|j|6nFV1ZCQLQLQIHn`pJyPB1QK-Z+tdj^f2-Kne%Ua@pfPFQ})l(SFgT9eBR}! z+5HqB}m+yb=)}da<83DNq$M3#FtpDst^{Ua0#clCJgCA-p#M+*>XZLTJBwBQH zHXeG*D6z5b!NZ%Iwi2U5#~u~mwH4*xY8-x~RSU7b)F5_WckpIyir-l6Y*RD5;+LP*~I@_ty#z5+MP z4ZBxPQu!3YyXS^)j8^4oMmr5g7n~`Q{zBO88V&7=q`zQO|F}{Q>@U)w9_X)qY(bsp zI`d_=kOainKJ*^vAzv$5tF8 z!k&nT&s{N2qy(>Pa&~i+=ot9bfBHNUE+(}9 rW_Z8dx@2&U4>_}1l{yOJQFNqUh z?)~Wdt;a@)zz%EgO{$tCzV}}qwQl1;@!qoD<4(*=5#v@p-Tg>Xs>ocsIxpg2f@tu- z@+m`CjS(GE*8H^e!4V>OS?ywTR;P$Yx4d-bu9#us(2Sg&cYc&AcFtV;(Bg>xV)4Aa zOMZE~z4-c-c;5y6+K5S!7uLTL(ptRv-s$}bVQt0ob#r=_&5aPhy=s4#ohsfK=Y0C3K@-HMD`uuFoYzB?dHzt)%OL~A(XU=xIXgUD>?=2ZQT_9s z#5--a_IvU1A!5R%fA~y%Gfq7G)EhZ39T*|*&AjPE>1Wf#xS!hOZeH0;;C~%jx+7wY zSW<5MpclUDBkEmR6?n%76UBmlA8-Bs>xts{`08IAt=v)kW8qU3f;Y4i2m60B#Or1gHiI(e|KTqa$I_N6dTX;2oF2mEUQzvfc~@FxU#lC%qc zHeL{XjC(=&qP!p~qP!p~qr4!hqP!q(MtMQ-r?3T43*`mDpR*Q3U6dCD|IFr1RDeC# z0{*O|u+&CdPvOsh|0n{X>yN_z?hTyjrH9qu0x}Buw}6BR#)!R8y zIStwQEsSk)mEJ5RWv%zTn*TPMHpyrk=W6c_qffjoXSFwi-jkNbnG80^Jb8+-fsVPc z^v25B*MIMgx7B)2FXVbpxZ5~4z25DZ8~x%KGB2IM&9$?$cKF`@ZRWKofpz9 z&I{)Co}l)(o}pgvcFeU$yiZ!iJgbl~kD6nglO1!TKfEz#6?4B2q_yVjzj>dBsq3$v zn;moQ3GbCwF;6OF%!5q#Q#$6J&e*;dcj>8o}jMFdVIa!?U-wic%QV2x!);i>y@r+QA>?;vSV)ahd1V|VxD9X zbN%^$Dub)y%_NUxwdcc>OhZN9BeG7nNmPA;l)T95{>C=R>b^fr$?s9^JHgl{ZJf*p zslKVmu2J73(POzD+Klou>emBl+Ek?xW#(ET+CBfOPzfGYaiF&16DCl&Xl%`?$m=*;BVk-5~QqNv-#UwSP_zguv|9pbcmX+5w&$@HjNrf1Ay82XH$m4*0tn zKBkvzyCdLlX!tl^wr4$m1JfDsHyZr!HoAa{petaXZh*hRsRY6Se*@zLB>{hfLs=C> zf@&ZNbO-#+PIb@&a6R&Vt|zDo^ly6jdl%Zl-)8VPF0`F(`MZ{Sfb9Z6AfPQAs{v>T zXnP~T+f?>x3^*olXPW_jt@&2KuRXT{K_D2=ccDQ0u07J_0R2S2(Lc8V`iy&xb@UtO zPrqq@ac(yQ`b_}(PWz4h=r?~rpK)&5Z}eFNs1N8j&PV%=`sh3QtO?LQyzBMcy8zh8^?vabUJ5uacMlxCS$5!gz&@_O2dwUa zt?pHex(ED9$+;DF52S6E?b)v=dtkng_GO|@TodVjZ#VYI%MZad9=hrBZT_mYMO`;K zj)h$}yN^l_vY$7v8y)9}E`40dm{_Mv_UgjB2;Q^EXR5kxkdPm&_K*2m5Z=9)tNrhv zz3M7<-D}B|{d%2H-}J@a|0Oy?=dzuhF;F#i=` zf2Ot6WfxT0hi;N-ma{+8pSz`5M*DRcZDtwu(Jt08O<1SX9GmsjOY|5_vrd;$uNmz# z%902G_ayKCd3q)~&vPU1-`R%sEa#HvJv;Bsd9Thg-mCL|ocG^lK{3Gh4!pP;m$n1| zj?ec2d|wa<`2K@-unl!+o9ZLYJ`Dl;a4hP+1#mpx*HbrrLfhz<06?9b2koMbw4*8D zdkWgkIo%34Kib;@u%7P=ICs7mpiT4#-(%4ioJVWG_aPjQK43ll!M-dD27Ld(KGene za2(dr9_r!TI38`__)Brv$)q_KyeDPdgcp0KopNr(W9J z5-?tz6Yc2>XaoB)Oa(&Tm`j&Qbj*JCurJb~c&^Fpr z8*u$i0xiHq;1B30mT?`jY%<{bXBpE|0n4YU{9UR{*Rd^angZCaqLTDsd6jMhNgL@S zt|i*Z_V<7pDt!}VD7YJN?QjkHg4Q4ygaEDwmQgo#H31C(ea!XM2rL3zpAA)-F=m_= z1N!1YumsSDv}u_e^xF!s3anE+0ZBH1^XAHx4lN^b38#wUPjC0~G+<)3=N@W77xp z2IW9m!1xaX13?l<1FU-pFxK~hv5E^>p&>xhMU<^12mVpQm z0$PJdz;f_7$OK$F^fi6UHM$zmxAbva&<@a_jAMV$9?&0&paY<<82^zF7kpcc!NU)+Gau!LgnJ9EWReF?ay5J{@olGr(*>JK3IoXZkTf zzs>=v;32>`u#D?~_0vEU;Ft>meRe144mgilAPjT`9YHs6H(-n+0OQmH%m?=Z&Z#G$ zjkK5Jb^`QyXAlk^1`B`yj4S8l1Z>M#Q*vF*16*625ACL1nP4ektR4kiJ6t1c!3wYn zFb?D(VErO+KX?gn-W;F$j{>eo_T@TZY@Yz@!DPU(rhqMgW2A!(fOgR@djMn0dEcX8 z{1}TFfaU36F4zueALq?H_Zj2D7(5H;zb66L!sB2sSO+*3`>>wzc>!!w>CKRvz<$7W z_Y~kd*-bT#L&A?WhZG0knmFtq0bEOb`eL0@~gXP{(L+ zI~WG~fbxJbq#t^NMqo9#4{)C~21%d^V7@814fq1C3Bs7tUk`$cfPUi~Du5@zEU*FG zq|yr^xkk5x8Gt?;19Vv%r0)jw?MCn@pigN-Gq4iO2lK$KpgCX+TYv~K7EA!#C-mWX zFb;5@gubGG>C1;f7#N_^EZYL;w?UvI;F=!{I)S0!Ab1(j|A#>qXbS|Oo@6i*a7_k- zAz%||2RZ|`NdZBCb@W#Vhy<+xV>28~2ee@lXb%q#o3XkNa2-;|OfVWSR_TCkX*=8A3Bo~FFc+|#@u%J00R8L)j4k6seT*6Xo(fg~ z`utwNa|L~>U{r9G^P4 zKjs74LOWQ-F}Zi>hoyivt_7K372vvm97KWcfPQ8BC4gh}0LuW^5c~85?9Z_>z=L1| zcoHyn)OQbf0?_`+U^|!sSic^m1NxADqMvnI$C~k`jy-^WW}0<-0q3_8><9GeI>0$S z2A%_(0sTbX>_h(^0Q5WCZvwl)D_|Sg33h;|zzcvrW!w$}?fVyzJ_6{!Ebua*f1U-5 zFa5-Lv7SCT2wnoTi9V*kjsp6IzNU@q0sXcWaD0~0F8Yc#(GFe5G+{k`!g@;jfHpi2 zICo0Ui?(C|+Rb^;7LLz6(`=KaBvTP()}#Be4a;=7ZqIVsru(p-X+4H}JNL13(8gW2 z?$0uFIrG#@nWH4r99QQl^;k@6n{*ppN2%-FZDg5yIn#QsIV!E^rfp?j!}eOAZm;vS zl`!uv-P5dd*TK3R;NFLMU8d9QqxIP>-79|xgM9&T_4l#WjV;xHZ8S2mg%-E)8*{zZYTS(jFNp= z$F@0u{h8Ogn0MEy^IE#=X1XA9P_A)r&oZ5-)OlT|?Vv5RkL8riyQf*E%XRun(p?AJ z<|rN74y})QU8e1D*Uf&qoRa7=oi~@UUboR{&h>I>*1NaSc4^ym-hIrgNo!lKR_d!_ zM3-LOqobX}f>c37TbYPxr(_2ugM(d(h+x?uB3L$v2$l^ZLR5Vl)xN#%CpAX|hp7It zK}4`@5D}v4LsWf;st-})ged*3RlC+&uS`UQXsPUJt?Xzm%blvdQ`zNIb~%HkKBuzF z8LZj|%Z5&6pHtcARQ5U5cur-fQ`zYZk>fj+y-sDXQ`zHG_V~d3MRE%N(^vf+nf5nH zGyIe^e@7;!Z!cE^tMAC@NoalPm1IexlAh`-r4(v?Q>w^SK6d6wVEstN_wiV ztVy5i!%vjyXIFcwue?cLUQJn$t)!>={7m|CYs-QxB|X)r!idj|<#(#i)RFr3E9t2| z6~=shjsU4|YdtAF)u+Okug|}M)RR}gX!=UZZu$EB8p(p(hDFm?#-z{n;V;Vc?@T?N zZ#k1b^K;QX)#q!{XMR4qr}`?I^qpxT3-&ANslLi4eR1;i?r5T3l1g^yPMw1zAdZs;|09pX)<=l%0u? z6`tx-r}=#Uox^Nl*3hd%x_j^(9Vc4u2z6(o=o> zelYuMedgz8d#aD$F?QEye#W+^`uN>scYWsPaeJzd@1@=KnV;S5sXl%e+g+deIp3b@ z<9E5;^_ibn=&3$_KH#n|{Q>5%Ka})TAHP#BHC+BRe?2Xc?esGcJspqVXQu|OFZp4q zPe0eiQ+@nw#9g2H88Dve%Q5+*k5himkPt6#`1JKgT8-}`$A-I-=Ic>m>vcO@+8(ey PV0*y!fb9Wq^uYfE?kgud diff --git a/src/MEDMEM/DataTest/Data/pointe.med b/src/MEDMEM/DataTest/Data/pointe.med deleted file mode 100644 index 0dbc1e8fb67f318bad69c999cb95129bcf5f1408..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 80010 zcmeHQ4UiSpmA;P|VDL@I;IJ|nvoygdia+zGJBH2DBQrQe<|hmo%!tf5jFDv+hF^c8 z3l{modX}MN*AlT-T&=_`8;XRA(J~cC)`VE5B3aD3?qsuZ(M0mYV$_9AqLX|2ob!He zzx(?2yr1dr*Io7c^u2xV-*?YF=iJlp^}DaFWzjk3pCjO?s1W6%N|ad%JdM&3Yl>JI zoMx7N#Ef@^*iIL{#L(8-++|%-ehuYsC(5L?qkC0*bF*03)@)^QeQz>DKEQ*7Fm?%Sm>$yzu zzU|&7yu<6c?`lk6LX_p|*mB*?~<V(oaNla5A4G=biDArEo_;tJA%t=u zFJqM_IWq;Fi(=t1{d|Amq4RH^pmnL63@88Q;00JRzJ7HTh53O*KA%vdi1TrK8Y)aG zsi75=ucK9TUq`2#;LS{sA8^ya4o;LG2&KU`8+73m`GKuCxc8Ov18z5jc0MRSV1Z#< z2(Ag(QK$<(P*-wT59)^l{W7GG2WgdZc_)2cF$-$MKHyb&E+qtX`ns3=7%?Li4ffC3 z@2;!G`yg*{OuGWetUty~#2 zKTyugauw{^b{-w*(c};K32r{B|DvYBKY{sYe<%4G?y2{|CrZvszJ`0?BPF*1eTV+4 ze91h?epRvLziXcClsvpH|GdBIwR$VWT%u)v!4{S>6yoGJp1l|gupgil50e2$K<78A zejURw)^!PM8;)%4(so*xP;M-C33Lq}#qf8^g+Z;oa2Z`_2>Uy4k{_*Mi-*h2OLQEV z&+GPC!YebkckkNes=~5&iG4JBfE?eZ$FEt-(^G^Glmm_F)_+dOQ?GYH3{cPb`_4M~Y0pmV&`z#GFc)^*A9 zm93t7fz~CI^Rk{&15GopVx-bjcD(v{A*W}HJ6=;7H4I^Ppb&ruIJ`!{k%-DPI1&&L zfPAQQfCn56;2G;Wb?Z+|`D@vjJVJj0+<7@iKEZ?ii6d68 zh1f@QcaHwVOd9_#sxKs^g@DeVP`_BpsIVMz0DLeX(EiXawRD&& zH3Z-bs30>24V=Fy+I=2MQdhtM;V*;mFwsw~u>1wcn=&8o@VYul>+S1Ac|AT$Ux8u1 zJs-z%eMD<9DSkJQrewyem;(PvJD&La_Fg-|=^;IqLGfq#CTv4`-I6VN_ za4i;L{b#En%m_3BI(>CqqpwsstRi&g%-|K19xf+2yhQ$d9ga{A5r*TPTLM(#fhfyWGwD0#n{6WBNwPOeGhs4E1o(%amQy6_Dw8W5u!n~c zKqC}=;0IfulzDJu8?T$W1o@#H&gsLL;n6e7ZQ_TmGg~~`QIB^^wL=E=_lX?s(3DSL zMQqnR4nx?zJR_j9L&r6C$gbbA`+*wUpKSHq-;$n#a`0S2h+Wp%YbW)&#NV}N?jhUd z|0nyc5SrO4pN)hAl*0+}wv(kg2OKP!Q)3e+LIR1?CUyRD zs)|vJo4}Q4V*1DwM;(3tNT(>f|sw6ZM-ahZ(B!<*i5M z7Zp|yZ0g^*W_a_O^+QJA=FJ<|+_Gh}_{HeqLJSDL^pNJT!2YznG4=LU=5JrW+5B1G z&E|^V%rfESG&h}lzd1$H6`$M?cVZqrHOu_dqX#F={oO3{rq@Ofw@G@b8p&$t!KT<$ zRo{r|krhbU_zZQY@^w(?LH0`*dWJDpa z167TAF<+_o*0LqEt%q57zk!{`O+9cwjGH){v>47uf7IJRT@C{fmL7n8nYzR7nX z-%IrCeoU3l*{$RBI6;%`cjLBw5eq;$#N6B8jSJe$<2p(Fs`RmYf;Ph9j7PP51~uD5 z`bpOdC%d=mb6Aq?sIHzcKbQ#U>|RV`_w4$*FaafFC*ln{+fMO!B$RZwOZpODmx%Ksic{JQ+WxMF`5F+cwWVT#(7X6IW%d`|v2 z<|di`z#GCmI}kA;J$Q+{pXR{&8pM$`k+k=divSONp1FC?HT=unfDvXZ*c$ze<*hibs*@qa+LP-=y^cQ>XN6J@!oA$`YuXX*8fM~Idb=pG(yV4k?R zbz~l=Ny#>%_7(-upd1Rdw2)q<|czqGu@yKuV=@G)g@6o3oG731W_OsKjzyF`G3@br<4Pj1@ z5zsjsF^#jKI=yTZM{<2PWd8h6a0{ z!s)=N6k`6DF0DYA)s?Kq6Thb)M$a~@UounA%3U!!u!EO0HowHc?wL# z#c5}D&oelIp~4K7AZI%oox+T16s8)%Tl5`l3Dv6*7kwMk-+vY<%hkKzOy&D2IV|rS z#Qah_yLAZNzIW}X&mp3Ieec@3Z0 zP<(;@y@x&Nj4g*Z1BZalp@_~-zXP)y!oq}lFM1xKhF*9%)T>4yfBxOfBEk;VR&vC2 z+`Jxtd_>0)to&lh)uld>D?1+fjX+*OIQT6B*-K(?673;9MahsT2!Q_FB~K+2A$bWT zS{|%uF%_Om1%Zf|AVBC18t^oM4$2u)c&EOXiiElYW5fHLgJN-Vtgm|s+X>|`74K3> zMa1M3IjoX$2*+LIzRnvjZsx}JaaZ+M@j@aQp2e~D;n=`iJW1nhya>;ll$G_Y*n26E(fM_M@yh()ZiRel7ejEEn3Z^!NomR~HA^OLC>g0ay+V61#^9 zpxqbcCWqCpVMVtE9q@2`X%W!vi$3_D$o>k&k(4PABg(PiKmIC}Z{!V3A9@`r+su*Qrt&@aYfSGTiYfn} z?R%^mOXp6Ty@0SaMPpPnj)KCKM}(ejLKk$9PUJz*bc%OzMq7D=4kfD#};sbjnw04dtu!0@KMZ&Oa%vBeaW%L#ds0 zcJW18N2*;cwmu*E9nOef^!dCuOHG3EGhUrOAA#TGWjLJl+m8Rm!l8c40Ahe|>GWIl za+E7ozXcNt_D9Cg4?$cnFqszHj%@lrY}qe%WYa0^Z+LcxfNDn!D*mA>bF(ASGgwh* zN8HUvP`Gu^Ualv(s!_y?<*a z;9$Q*rQ_$PV0TpG=`#CkDNY)GfbSp3`pYvGY6aPs%3Zys^JyuOZ9{G6K5&iRuqC2E6`NKe5MQ{X5Cw zyoyi`8RJrVF9xq4vVJmcq_IIBpT8fxvGv-|VMEFi69NGGb^Qv%$pqv-| zL~AesI;no|^^&7z*1x)$iSVRc1V$?B0&4SU&W>iZF>DY(nRMsc}p0I?JKz zf1Sut4%bc#<&ZHhMXK|^s;@@5aPq&pNsqBMY^cPmKTQ=*7fz(K?&9qhC}g=&Q^<~y?L=k7d3ZVl*{w;Jbu>~ zZ7Re*_>q@9Dg|0fc-d*CyxFq2-O8_$4p+H#WmspfkABu5dGDb7a#^ZEEbq9%O2hY& z5^w4jV)!%b2Up)>w67mBI{P;pb&W>d)gNoD{a9U{QD0kIZ(P&V)Nr-9-yD8*^l;yQ z2y^wih)G=&556MIoihKLfeEIpws!g(qlf9G>@tbR!p=_XqGLJsdr>n|?k|tOl0uy@ zPUvq(C-OmmXUY%r-(lc!C(*lzVrzhxXjn-w?jreBc zwpNT7bAP!1%-_-3VqH3o*Tzrd)s^EoHJ8hly6umgpT$d-w5~#_6N1yNOIq7oJC?1o zgkLtU=GRk))cgh|U#^GcEwUEo!*sopZcx&V@%cBXK9%tLIY~f$ov6Bg7+>A`QR}^K zDavp2vSrpSp7$Dsk=x(%alFw-)NT8t@<^_l*8#U{B;QQB=Jscsn0bRKQM&twh!i~eYf~;yB*uzx<%8z1OBWJu(XKVZ_YRPhC+G%C*OrP zUb+*hTlt%y)azDnjc&&ZjuLg-K97^T;THel`>B)MZS6bA zzuLZA{O{e3?Jp+kw*6f3KeZRzf10SReFyy6@5Wl(%fI?R zAaa95ZS6bYk9#3T-#z~7zeL&EcfemAzgziN|II4b_HSJ?Ft~bX{px`=Lz@AWczX5v zEw>B~#DTK%`v(RGDWAt-#5vMm@V?fGpY^-?&R*O27NVc6^RKuawcN5ByQ~iC%CVoG zTu$9zPLVZm{r&6L4cE!7A&*)um%N`$F4wN?L%BRJRtkK=#ruDbyTJX~^277Yah%lN+EZ$MU5juZq}HcQs4dAgC*y%}nZ?#E zs4rQbxPo-$toggH*}A2hKOQHSce`HIcX228+iJf+>lNata3r@^i1qpj0vKCMoEi5d znsL1*@$qFnUnFQ^eJAqxDm#6!GttFyy~O?AKpP~r3d>Wr&+po=#1-3qHxNzhAo_m5U6=#D2f?p1hp@0KaR9uJy1!Wuvih#%#H=rnPR8*W7 z_x6i>EAFkhxBi<;f>11nAiuxh6?(5p-+Re>`D8Rr+u5c@CTjK67__OXGRllPQ&twh zKi|nFNhl+Wpkd0AK$w+CgoGS8ld!3=p_S~A#J8e+gi>N=VPa|H)Z5s?*xJzC*oHB- zuyGO_8Zy014ReY!m#9D~p|;k>#tfsxP`^@2&9g6uk5p-dg8o$=P-4n(=wKKTvAP;p zKT%kMez?t9_WR?9);A3jMRAjrvr=>Ch&ZPWZy1M+APxzeg8Zc(P-4o-Fe4)Ns}tlj z9)lwwiKoQI!qP~I>q$f;!hQ!nptv(gCnpG{c>PczH{Yf5IGjKz#d9mtE>eA}%9t;M zhjWrji6yi?YZD8opKcMq3mGP_UrDWmC8rw5d{kshi$B4Qq`&(+4_2obGV zM+|&@!r&NXr zkOD(;NPi_pTc!cE=ask^i=Ni9usS!M$3t@wIWHsVr#|}O%UK&+p=c%_Ieebv^A>5Z zB4n{YekiUe4vtj&aqeeF6n|F3e|Gjq9QGQ+h-&_bE6qpry6*?BRAq-XIHM5~lt?*H z99<^PC@7AC>tO*ThxGCBP*5D@oe3cs`OQSA-<;rgCEZ3=gaf`AdoMrkLHhtDW&mwC_g=_pT^TLr8J(Guk3V+cs^SX zO;3pO(#f`q#uGWJkJ4;Ds+Y%4%fZ4@M}#&DOInp`8iU(MAWH zKAA#}$`o=`rjVmDg&dVB;KHOP+iBH4=Ej>chVuS>$UIf~LmdeJe8|D{cAh>;*R#7GbuVkB^m zmz5kxWhKW^S;=u!R&pGbl^jQ9CC5=&$#GPskfSn%C^M*FXdxhn<#akKAmk`yI5H3! zi}-UE7?MSDl%fL2SqQXX(0R1e^R)12dPoON4;2z}Byt{d9C9|w19CLF2uC|D2$U~c zXov@$Lj{KNigchtM1_oGQ2`)c+C9*MLph^sCqlZ_sfAT^}ArL|daGYeyxlHc*enEehdIdm}p<_P?bL#EH~(2_$3hrFN9 z>ne>$Zf6)POtOFFjZ0ISVOE4L#rF4kKxkabh_ElxQS*>v<6n1+n&6YDMU-tKOsE{i zm8%Ypr+lXEaaf&F9AsSE@c3F0K0*mwi6?olyYYShyz?Tc`Q&;W;yBcMpsk?S-&v&m zkR0k=3UU2SlC($37Tbn#rA%SRq%O=qDb!1%ExswHLciF143pJdhy%w{oH8x*=lj#o z=EYV1^EqgAfVP6-X^3oA505GkBnyuxXOwKQZ+ZPuJoW5D38`m7^9p^*_(7;Z$M8=)VhFFKvnU3ff*xB<&TFD`fwNE~2>Yf7}1TML1QV-|YU6 zjF*J?virYwLL4|gyWVQ$&-bUF&5Nu2`@bQ?pn~FQUjr^?$C3`Im#-{!bUnXV;_r)hW)FG7kv$fAsp6P-=Ez>t#2h zprGxQ4XKw%u8{Q-%_4K#|F-|jSd3E@`pxeD$h?9OUv~eeC&Yo{v+He#{Q3U$vw3lq zfB#3_S5Q3lYJ@$2K0 z2g1ip%gvWL6^9c?Vk#mEQUh}HMM!Yio={W5=STDkF1h(K3~)G}P$Ko)h){i&6tO;&$Ae{e#eZ976^crX2ZZW#YQFVZDH|`4^ar%Q zB#;XzS9&2;Vm$G`&8QN$21e#H;<&P$N6{f#5rQaxU2tELy@Fmxgpu(wlEX>F6AgbR z!TrP!Tp55rGoOEYu7vstW=;M%mpAT9=#AxR|Chfu#o5y40ik|Eo8XE+?i0eHq=-2D zV5Y!fX~Wj9*dv6)Q~@0F`xST6j*)Jcu`sg_GLYv^Kz~hx7;xNS;dsusnGFCYCjzIB(xxT z_#1hOd%WUT!pAG7j(;O6if*&ucx8S5y5)^mQiou9#dsxuKbF?BLj8m`!Bv6BD@DYi zs*3`Lr4?fZu}cVtsRB6Uk5?q59i!tFXD6I$D?$sBhrf}hxW_AuEB0zhonQGd^lwB( z(QPj5^91BE)B-N4Kh+>Oe%tU<_UuR@Ic+&|LhY$Dk>mI4 zy)5m_o$w2ya=b>T@P`ggvX@R3UI9;%5pqPT97j-3avzlWl4JkO9m{rd-qOm-(&qQQ za!G{LqP_^d6a>A!3T+6VbVF~l`fc0qE%1@M$%eb^ zMLBuo%q--|$;NhkIcsBcd2+exn%L3U+LDtH+u`)+fKekmd-#Cb%m467C9)1ziF>J> zD);9yeA2LqqueJC_n0Vh87>+zYMAS&;S=!!;G>)>s=t?|k+GAZjjge@NK+*0sHLr^ z#l0y}Q`FDc+Q!V%LS$sj{r59A=Nckov9X2ikAl?{^)ff>q;G1PGs?!!!qVnPgh-}I zQ>TNbg=IfuP4w1kluR*fJU1~GmUzXL*buMiGcmN0u~56!i2(Jdvl@<|9~|J9r;(Xh z#*hzwXnQK->t%^bli~7#eX0Wv<+F`{y#{Ai&zdetB0wjinK1Xm z*JEda?dIz-v*=}MVPR*?r&JH6R+c)lLtAV71emRkwk%BZL;Xkjx$gh01}5V~6!T=i!PzBHg*<%3 zPf_5b1QzRW%QAmHDuX-+Nt4E&qeAm#nF8}=Leo*&srhG19uC$06gbS^ zgQfed5DuLQuB>?G=jk6vJ4VMHuH^j-+Jy4N6+z;GUmbVQWw!+#ckC|V_rVxn1yl;- z0ik{(wTS(MYY@(jV!TqAQYrZ|Lj6RhKtCabL+y?E`$FD$13BsSeN72}CzXEJw8|*VkK}OKl&pD@ z)R{Q{ir-)JfKWe?TEu?Bc`nX}V!ZNe3+nsCaxgG@H-!Uwi@(Dj|HP$E)FSp1>g2LP(NFwsh{E;?^%I!_ z{e%z>wKwPQKY8O7*9BN!fy4a$SX$2t;n11jO5S)Sa~}2#9j`$0e(_*JORL|CYFBZO zSFA?k9HPrFTs9?Zp2~iHQ9b;3$`|(evNFV71)T@IOxBAbxk5f)Mv|m66vb0sh4lyb zID>2}s6Sqk`iA5R=?{|RpXrZszvz!!1RqGQkp3V^7Oy|(xJrZAmpu+5^Hd}{d;UtD zMBs51lk;&Qw8B5v5`QYIpnsnSgvM2=0^=&`p%U^~2+gj7Dm zdD53}f3C;bf3^Ji?-9?Felgq6UpJ8_efjpI%jWFuSMBG&mo!iM#cV%+JxHGP<=da@ z^%TEqKmR>vdD1T?`)PswYJU08!4@LFx!Q|gZLj#>AI+1#obuwPKE6@g5&c#B`Oo9z zNxzuNi}qLi@2ciWU%vfci()^2eQ%!h<=bDR^5=gqHc$HU?f+5~`}yl!@}ytP_Vd4k zn2NWLoJ3T<}kH}uw$GL!hZ#+Rg zS9g=gIr7$>sPD!i#d~)rPqq{he~1T^I6$Fmc@fDE?Y9ilNd%=NNO7o5!t_4ekuxMh zfXKsPCd7i-_x%L)D56WJ2b7rdxp1h?U}SwDxYD2#PQ-ltUIEqY=O8?vV+P7*{}dmI zC?zK@h2Zv*@}&pku!PVIqTjPzZa#Zu92OD!f$(Yc&CU100*4`?6wjHvumDXL?!e(- zLM23>XA8_h`RtqFBN3sr-q~Ntt}nXJ|bTlB4npiakKeIY5yEdaK*n2;n!yg=?`dqcHW2m*ox4<)2s5W&bvMtKL=k; z#B$HXqYW_n6&d~SfWiX`5BzQqbkkaGe(Q|LQ5xOgl+F5fW!QZczdH2ym$DJM22D36T1ZoO z)}46D?um4@{&%mS-8a}h?cQHW8#q%sy_tbWo$9Tmb6@)gj~J04O&V^#-)@+JG+|}8 zrf;i`X4iGqS37E`!N!etI2yTlGn?Gl7u3}DllppnyJ|OcHM@D>ap}`Wtys9E*O5i< z)7TjevbufQT#wyY=i^o#mq3?G{ads1JKNxnXV1F!>^e>RPRycP?4G&*X2gYGW)~0g>w2~e=RenPK2Z;7HZN&WM`LW)E8p^xE}t7n}U(?P=xfXIRVOE;GBe zcb2YcbuDb<+#qSKv)A5D)?nD3t?Ny*Nr_@p!!K-qp*@b>uqtB5PWy0n`Nx#7C}uHx zl6|+zq3vz<#OB^nKH|aBDQ1H#G9ohAeXZ8Ixh6YC$oDVw>mZlB# zNVVJLC|wb3^5x!{-qK`eICP202zJ}B%N`H4+Do^jZi>B8;V8SUcJ&9!F|8=Bx%HS@ z=u;r{dQL=7@F+b`=OO56`dJowUPzwakKoUj=DCmF3j-*hb$qfbB)*)jgOw~x`N+wh zf8u{ug|4fq!Aa-*Jc|+eK8q3gK8q3gJ`1&*uSe+fEaa;$c?i`*X&wfV=x1Mv(xLp+ z-~93*?vq=dv^@CN?|i>n7}?5_%*U^?tW;tQWPIp3otoSgrxlSCzP_cFV45dg%Yv;Z z%_Ap&U5D&De3cl}?EIq7^w7@=AsjU3cIsdH87D4Eb{VbI-=r03;ws1#kRQH2D-(0s z8NR-slyj~qsxzluD1SNeg%YOuqo4ixnOr4K&Z4)W?3BFnqw)$`ydDsm*9|V>eOLAC zINvgm7Ox2k?SG&LgzmdC_i$$EIun|8ibLEAGNkq9)}!2~96zV>?iXfeVmSp4f9}81 z9xHUe5R&`c!Guyj@aKUuui-Pae-o0U@(PMQK)di)@5-)Q<I~hpY!@X zr~aS#HQy+zpVFT&7ph#SJ_Rja55UPS47@Zl6TrAPPy1>eW59Uu@lDMRey~xm)-{%; zGH~JgO&aSKmx1w5p1)ZYX$9w-JuWje={byOcYBRvWmT}Ukzve=R4ceR;laSLh{G_x z;$)R3o4SFpVV4($o^Xco#ue1g^n)NYYeQta84?gZ=eURw0pPr$#fTHD8DLv`L7V@g z7%;MB^Yh0V`oS^V(_5}xDgnNUFUDNh2*LPt#&X$8U!ZNi`T588ufZJ4&dEbtFfd5n z^W{5T1~@i=Ak0Ds#_-KO+p;Ph&0?I$urxT~i*wkR!)T(lkY&&v)tW(WxI{RNV`) z6@w)(Z0fKn18)E@zuD2L2UjsL&~4WJ!{Y(;8#=0zQBMFOdT(ExR7n*^Pp+qSKiC;e zOnuN_*BSutw&5DyPayD$d5}@b!5PfzbnnD=|4iUNK^%Oi{w!d(`%c~3LpZ-T^;lMB=5!9k+sDQTOjV(zKzw;njAD{UyM2e%r5a{v8X3 z*EDX@>`!KT@@{5F3EL1VlucFg$>S}tg%v3JNt7})ym(25HaKwy?2iICZF8qIi&<7+N^DsF)&D9%qea$H6(4+t6OHCB zFEdC2Mtn?z~6L)TZ#(>%0c4sH}B*3mO1|0uV z{~h%3{HJ1%1AcJw)-v0iZirx0_4qMeAOn25KJhgVWT5fNYGWA4;aO+dl>;;S!H9@a z+druI#(5O9F^)^wRP22nlo+H5%&mh=Bt~RPnl{%mBM`)} z*Bm9_zB5#-kxC|!SBEzM zHgnUAYQ6pp<8IeD)qG7Fm}Ah~NPM*>2-~~OV&)L(kTSVdHk6 zTAAPs{AXNmIILAB^sHnLPHS!l9$j3&Oz?-Gfl)c_q_o9nk|98;oMw@^E4^_bIaW)H$?z1qwuBNTy2?)dA`cyPo#kFg@ zFP2w3#K3?Rwvu>F2F}p5+8pWxpnl8Mmuto_u;+~Ug}Wm^!^pT@hn}W6gY);8OX*Xp zgBx?|FTAsIHn`E>Vcq02>%sXG*3$-mEe|$_J@;M}SQ{icTsRUqXE#{UGJZh(%@lB< z!5xi0cH!W;o|j&Q$H8#1&4l2Yl{3MC3aJN;Lpy`a-F-GEe7*z@EV&dj=;1|>c{^t1 z$Qp*={(p;HzO3*CPwa1aTnWnrFSnn$q&NLP@Mum~ldPmR;DN=>8GeVCfk!pA4~#lf z8=U^86<#47iu}O{~)ODYygn zDyz4-4PK`EygoD44P^N`S@wVa5WK2%DAaS;U~qeC_Xqc0odpjZzbuFim;$b8e(L!# zqZYX2)i*WvkrjBTWmmDw*k<5lj1r9cZv=Si1izjim
Zw~wvW&#e?y?!HU);n+u zo;kEduNt^(eNFZKV>7U){PLjJbK8Tgxcy6KZqEdn3zr@``*|?9qq(X=?M*S@Y`2}& z##tN!7eB3wS@?Q9i0J3^O1#|>TycLsubkIAaM}NHy=SlLg1t=hiG6&0!Sn7X)CQ(K z1S?&8+Eh0_4ANTN-Ez8RA8`A9d1G~5SCHJ-c2UYg3D~e+t;X1KeZeimEAAa-xLC_o(XZA z6&(Ox#`-wi9xxdk@VPxd^2#M}IPT!438Nv%y3o$D+noyFZu`Y=VdeGU?y72oMLH9} zs|$C=hrZDVo67E4)csvOaK~8F*3V-%xU(l=*UkC9;OXM~HrI}A0grq}e`~z619%lS z!nJNwL+~hEMXSjOE*~}nt-tJR23}s)uC1IY0%y*>HEog56}&v;GUU{-6CmsUr|Z{N zjRE(x(?_1^z6-pXpLKSUMGNq%T9sZQ9|nVabyG#lmZyTd<)1KTK5BqhDk1;8UUMFX z_}@u!oOluXtAA>>@J0{}T~KM5cJ*3df_j7JYtzDEqF3`}-79y2^Io>q^O-Oh2A2=D z-BNJ@TC2uFkobJ=k?`LAV06WLN^{mWfGa9*ecs(%0s>>lzZsS&fk`98r%f6k z29fha^hGT?LZ7QG7V6cz#`Q0a$2g5F2V%ws-kCi2EeQOts>hHeJ3!dB51rE^9)bYV z$(^Q|pMirz>e;N5js!7>H8Se<(gd@TZ8yw%`3%fk*4Vazn-P$FKXPnMnLls-oJT@w)BB4b&|m%AWpb@y`Xu2%-`7alLri9Z2?VwA-#d!B}F zL%+|wS_eYStdVus^*#&&+gJ~G7?fUJVje8rZ}BHPpf1NB{;%1#b~&9@IU z9sYD8ketuZs50FT28LHy*KFApI6y7&pXGsL;MmU^Gp;zk0RHNc544_#gCUo8r=Py4 z2|_KRHC*=Nxca z{ojVr<9oo2QDtnOdNv0!4WBeH>+K3c0uOH(IA}R=o8a!P@~sne9ep(A%#oVF$GzvP z+easZs6KwLCQT>Abf2f*XK?fTU{2q9E&6)c!36tb)55lm z27x|Zd#&~V05+O*YaTYc8D;L37o6o=}e7MJ0)uD8Ov?Xd*&_AeNi;8_vQsr<7E4_ zM_{WP-yN|;i%@hJU+58;fmJ8H%m9EGELZNIbP(=IsA(SOvS_a>md_cz@|w>H7V zA=2Fo{xgF!ZB^Ucz3K&*4y@91Ku{PQc&IYdG)W4b#+g5#dC?b)&|iD+*`gQF=0c@o zyX?Ba=~d?_A5DG+`yHt6v)Vru23wBax~HKtboIB0uO|7*jW4>i8~)`x^jmq(NA=iE zICRg8Hsd=@03K#fLK^qk1pO~~snnfw7TQ+ny2kaq1DIfR^2@uA<>C14t!%e`^8#Ky z%Fp-^dI`FXt9eR<{Cr!}$iM76IO})@c)a5iT-Y@%wb7W*aDwfuN{uggfdSSHgRft> z4?@3YWlpcK7)DL(lBp*y3+MQ(TBkAA6?$Kv{{HH#hS22t(EFEMUxDd8+p2h7o&$o) z--@eP&kIDkO$<=cegk4gHU4(H<5G}p7-@G^Ck2k(>Jc!%^DPi|B&Gh6q#hvj{xIkA zAD+OZijS9O^k%`v>Pz%j`&Gj-V90#` zTX7R@pk#Dc8>?p>;1q4+vXzf+g9}boji|1E3j~yFT6^oQve2cuqnY%g8jKn=(V}zM z2QYTo8{3Z6l;N06Yj@YMN-*F~@~e4|Z^MXy0jF;sc>z53*wzowXaj=2j;v~4r2>dN z?H+aeV$#Db`{$+Hhl|XZJ(~Z z^pFLy6`i)P?q~-4KR=<}-%K0$P12prHnj%6d$NX})l>#y3+lP)I7yVanV^4e#$d_!T9-nCgX zHNv_2-!aW=Q4}1qPxDT=`DZwLy7Bj3pPgZVgHx?3A4kF1Q)kv3vW$g`3@i6&@%$>7 z6|!OY%7FI3!+f&;iJ2dvPdAM+gAZ(gGkd!YP8O%bxEPIVCpW)=0rQsko_{hK4viV2 zK4MA_7?^&%gUPT@}SKZ1*@nlW%a&oWqqtCkW#w#rqnan-0e&w+*hbeifYb zdfe)BCqkiHj{|`ZYODcMdOwUr z*^QS$DATl-UHh@nZi%C0Pgi{ymYlkEs^c)=zt%gvQlr6e?)U1}wcgGH-YYuXy{gh2 zPVFA^;I1fu&Yt}0IwbymfjskprEeXQBk~o0-B5woA@%#3GJJx}+p_6;I$z1xSAy0d zRi)TbP=yB+9#D8d;enFp0iks$&Xs8o^>dr#twYID!SeXt^v`uDVoR?Fgw{8T8em)$ zbbX_1!=m93R#4!u^rB3@WkTy46Uh5{TnVL``0G|6X~!rEh2*Hbf?^K{^((1Gtj`*i z6!rOU#+cCh#!P}Mb+V3*`iNhjBS?Qh>$7`#d}Kf810Yb~0rE3I2;OxBU!K(eiFkr*hz)kJ5pjVPf?>!fG!q|Ct${JoB1Q%{K zjb1%k4GdM^+aPvJN3h&smAPx5^Dus8t>aUgq`}#fwcYD%9tLOF9lN=q*;X*4{`lDN z9b(}1sivBFe*j{qZ5gbyq7{fAzcB@V8w3Y`G`?{XroiC2o{cW3dxP-pm0O$moCY%` z4f~vHVhz3B60U4G5(zvlpXjc6+5<%2Z_sE{qh(;)<-6m?9^3`&SJ<}RyTukp&OGME zoa_v3Bb}S8w4DjUcN)FyRP{Cpi<)=wRM$ut@L#5T-+x{L@75Ym<3>+_ea+Z4ZQ20n z@Z^p9$?1V$8Z+jsW}FDjS@GN@AbAIvd9JpbZej%x-@Mm^p%2@_r5%IXY?`48;}$zK zK2e=pw{du-ZI1@_aIA5;dp*WXhBHohy`HZd2&ar#cz$?b5HR&!{&8GC02e%Z(Sq&s z5XPFni*9^W6{fsS`gcBezi6KJ)%}A`z5<)Z9IPC3#|$Q(ta2=NBv<|>seVSDbw z(cTwUHW~T}234u_&ap1HUL~ZjPx6}KAU3)}@5@OkAiBXPFUR4hVR*IvAI_w!11sY_ zeV6Xg08=zn<~y|g1SYh7@WpYHIc#gUxBBVf42ZE;%3Pq_4KC|zTW?3t1PICo@9@0g z4ie)>%>BG65yY$unCH z9MNlGb8oQlMay%WTXE|J9-4l?rez8zt$S0ZvVR7c_vFg_r~lpulLlH>Qg<7~t-sXp z{~Z4Y%wPu1cYQJu1X-N+$~x2#^vxKcVYGfCRCe|8Gr9&r*uEDHvPSyAm}gAu;Sp&d z?%TYBEh{EL9Rt^@F;(4R>_Q`zi|w<3RoJc@6)(DjncKHEd$`jD2I<^7x-9b*j5TUf zXNj{lFzL|s&DWhG7?jz3MJd%?eqe4BkAn z+Raqw)}7s1E}45O1g?HDM#*}*D|orPSGo2lmV;OKJ}o(%@{wkRJAX67cs-Y68Cm9r#*>> zsg=Mzx7Mw|s~yrfWp3TjtrsaA)YA&b2;9fy`_f1t7+NFGAa#jvUaI@TsZ;m`ls6HZwu4G zJEiY&bHzu%o3s5U?RxD3w;Al%?UKAFV{U|30_~`ovPvF1zy){`M~m4IJgzuw|6kNPT_THl^4Bxu7#VKz<%~>U*XKS zfhW>OWWgn^mptnklmSv39K2ZF?=eh1Yx&|uovScr$B0$`4O|Xahdiy8vUUQT+VJ(K zcJ}dLLG+tx@9t}W$Y#4b&Dix61kJC}$1Bno#J_JEzPZ;N7<9SEqvLZQfyF)@>ZHw1 z1(CNd%>PiX1@Nw=s<+_14pdiraL#W51ToES4)$DS02X#>XQOw22?&UYO**xA7l;uh zv}u1U1td(2yYO%4Ixu=bfBk0KJz>PzFje=E17JbG{U^g(KLOKgtj)SR;}S4f)oAaO zb`UtaCRYBmO#~#>5|=lBFd9bHnXshKpcydH*eyia;~t1!UH_nacy~BI;$8Js4@W{t zcbzQ%+xF0BZ@^;ho%P_zg`@QExu(D+l^;brjMjj$wmZu;dp;dZt)sHQsY??Waq)1F z$Jk>q{7bE=jb62YK}z;F+xYASbG84Aj$OGKOiS;tQ{{y}oc(QE+h*I|0GGkfTrb$% z1!{w;bagx=ffJTKx-oCs2sk)qOT93SGGL~OPh1tQznZ(Jbr0itmEla4PwKjnfnaI9 z^s}o)QaH%*=)r-m-e8#f;DIeFRtJG~b{>zo_?27FaDV%VDNTWQ^$e8-6}~~QjW(t? z8pVJ)#+5qRI(7o-tLNLcZvFyHVVixN#N~H`*3DBbFQtQ};)sh4%7lZ}RYI4+fxFO1~+T+`S4>ioV^(gDqcDZH3x$0U6_1518iS73~mo+K_Lv`YO zm+JHb3nTlD@UH6v7wD@pF8_Q7frqw9w!Uxx(_hxMa8OzfmV6i+ZD<97d%w4SMj2`_ z`u?b;m#^6Y<8$|i_|3}%(JC#gjy<&iCJp+W@y2cgNPf}V@4IGIxOi~l*1BIBK>w{7 zQPZy-0AoW2dG_1MfTa_zmfsRH5Ki9oR_r)H879nJ(T`bm19*SG5`AQsGEAK=8LTyH zKMajh^Iy!32j)85Z$D;XH#q6@_3<5twt~x^?Oi{V-3BarTz7N3mIddFW@!hs+6EJM z_UO>~*?kyr_{*Y2o({lc!278gqgz2YmouKDx<|q&EqHp=M0aRo^krZ~pPgXt7fbVT zV^v|$=K-QA3!1LPHg~P%BI-ZZ=4D|ht*qe(_lI58+gurMbh38#jGOYPMPhM&7zT z+ed8;nBy_1?z3~t!Hfsm50}Kggc6(DsmnWBfOMO^pG7_sVd|U9V;c7y4`yyCbE3Pw z1SCwd(f$(4t@ECq#C~~N2`=jXs;QpV90FY|3<>-GdEnwsnr)1+7Z9v>V zHSSh?at=f(Kis%`T{XDO+9avph;TT$@{A*nuRg(cj)5065&#Tbx;*NIs3MF#`@a5= z1JA&;vQ_=WnaRNagkDOu=@~HEEwN=gKP~8z)&E7sZC}7b`|ll750wL>rZsR_xAhtf zxvMjDwb>W2;O_D&^9_qb*Zrk^~iwymc+SlH-v(tv~YKzNM@ z^Sez~1Jmx+-af2{Gq4Sh*=S){1th%QGPU0-uKyT*H}ON4?J#`XQ;n=HyFp}pn+CV) zN5O!*gY9}X84Ty|9sgzAk&V#1Mcsfy6BmMj(8;$ubl3_LE4(;YuUQ&Q9_aRNOxYSR za!-XBC&p9&i_dR;T|Ry`483aa=M)qOmvo(!-q#==c(!-EF=YU^{``>m^`fg?;36C2 z+CA@1hI7|!+3&4+9Qb9_8nIzbI84%f-SbVyOgQ4vxA%4pAAo#vMjZYT9c>&1C3x{>kAfS^6L_I(2`~zK=lg{fLC4T^i8m zt!Gl>V^I-SctGI+g$MHUfY5zT$=&><7)IXu8SU2iegeMtk-sj*+0y3$ zq4hHfIv5xH?=n#wni5wS5Sm&<95R{;9F{(G72G1B^)s2|ds!)jQjPrkq6}%rFp3yP zNRG-YDE0uY&-iUA4EeeU!=&p{PyXCf^7<9~_KN!abI<)9u|n%-QuQ$|#J&IMiqqV%@R$VlE;F8SVKaIjLFA#;;;!5O=nD#I7e1($mC8`xp`ZdxDs{c@iA zQ2OSx$@>NI6)=5IU;*Z{W%Jiusne#Xw9IEydwvbj3T}l56dq7`K;eM`d4NApBO+3w zEBQCS^5$u@4Y54Fb}LX;6ilVa18Dq$5FjEpsgoH%D}pO4o~=SSOei7_gL`2ds`JuQ z1pf{X2+sfaz_>^ulzIct>y%|QNJQoY%!hv&29C!^!Guy=8IT9UDW8T3KFT!4G`k%n z?IPvN6vzk7Pf4Xpj2gZmA%-H4qC?^Dvtdsv5&kvA@Sn~XayJK6i9V$=SU_ZsDUw6J z&U3ve|2u7+QIdQ)Yh&C}y^4^<{`jG|qB!vENeunLlIw`#@5qw; z`EaTXlVOxUUoPb(IH1IoSj`he^J(!$c21 zAN(+zfn(T*Jj#zJVL|y!A}_#4<+9V`@n_pd(-oou`K0>g(QN-@VNQOS%4g>%lg8wx z^nC8vALUHXXH$N9L~nNbG)yUh&i1naKmUAon5IMXLBo`icz${`ELRV& z{IcbUUW!8+PieNFvS>_hD(^hy&MuEk9Fr$Z^k?g%d^DbfvGk8$K|MVA9}@T|+g}3Z zB#)o^i|XO?(=a`soljbxe42?Rk|1#W&t7P$EpS#%)r z9SQA3r~#p!3Dwb-9a!jKg%&zkp@j}sXrY4@TIgVf7CKm=g$`C|p@S7#=wO8wxq^yv|OdPJWd(WgiB=@EVU zM4vvy^&Ul#gApFYv2PxR>%efmUS2coY7(bs|K>p=3?f#k0P(bs|K>wxv4 za&F7*?Zm`^V&XtCaiEwuP)r;sCJq!62a1UU#l(SP;y^KRpqMyNOdKdC4ipmyiirco z#DQYsKrwNkm^e^O94ICZ6cY!Ei32HMd6Yjd0sG+bHvVN8{y0m6$hR7rn@`mlhclco zRi}Idczh0o&mL1=c1mmz`%#$@5er<;rSqr6 z=N-T2KfhCrWW1o`c2zQNM{>whg&(&&laz~>4KT+bNVVBGxa*E2%%4E`zk<6ho; zm+L?*PwP?fma0PgpXLFfc?MO1{;II`GKCmk(Dq8?f^muD3OUa}AZ=f)F6Z}up6Bzg zkF@`@C*uR5%w_j~gYwr$>n$9dKc7%Ke@c8_T;<>Y?Ijs6D4xtnJCEd$rwY;k5m!5t zl#7?-^+&<_KZ=Kf`UQ@_xIuD%ay=93|3uet{)I|IUjHW=`@?=A9g6tU>jA<3k9S>1 zJy6(snMM>8v|frvVq7A*Le@+2=#f3mda+P3o?Z}%@$`a7jHeg4`F1>yBgWGUA~Bv` z5Q*{hf=G;~D@0;ET_F;a`5rNu?-7&v9x<8k5tI2IF`4fXlldMoneP#k`JP`e5)Jv$ zvm>ZWM!O23=zSt+EqO(5M}<&@+biV=SLTkm0 znGVVaO$X^k=V>~K59JMoDIW?Wok$-)9h5gJgVI9!kZvS{!stBJMbkq3G)}XB) zh8%6c?d`};!|k~++L2Aj9;64^fc$}MKsse>W;j}$8}bXvGx8nE1M&~@6S4={fyxEt zALSe66XjRL?a22+K0*FO_M@^x<&ChT#O)L(2pi}a;R9g;;f7L*85GWmM~ZDEi_RfF zq#Ma1d{KS0Uhrv7{GxM+AL*xQBYh|i>8Dsm>7X=dS~O&Nz zgW^$I)DD_I-h-MmmrzYPXRtL{XUH4uugWXqhA2w&r$yvZG@Zr$=^LA5dB-T^dIE5QY$DkSz!| z2=B-qM0L0w#Ut91P*kT-9jL|a)K26ZghMTEM`@z^h|)mED30a}@gsjATab;^AIKKE zBP=6dp!85$C~dSO-=I99bI4!F4(dBpJ}6JrUkJwt6R5lq22k0eGDYQy@PNu5l{LZ= z!UigTRPM+hs9mbY?bR)<&3cGK$v>&p~{0c zPq+N}FxQ{^n|C~%|8;vLF{Pm6VAo;TKS&N872>)bwGZ6pEc-3)pS=Dk*mXO}B-bEe z1nFvP>+0y}bkNb$HPGf-Q2x5#tWnr6NDei2h4+hnvATp-U0KV_r34AwQ{_}$eBEA# z`Oe#DX5%MgMYLX;9>C#vqM!09XzBET&~-ciIR$Dx#UZ~7NxhLjVC2moxq9ZtAx%#~ z{|*lbJ@1uCaAn1F10HvjV=_qmheV7Yio#1v@zKdKn0_F9>6>!%#i!!%rDd3kFkxJG z=H@fqj>GDN(q*F>q`f3!%!j@B2omZ}PN<*42b3@CI6g`zl(xUFq&=p5rW5gzI-xu_ z6genVpS5q&9Q-^9dG#4i!}8RwpKDRXmR1i4)n{jdtDo0rCD{cg@`(ZI4=4&Xrr@JY z4;oWiJy$fl^1f#)|LcgpB)Ni)mkmZ^|06kk6koIq7qc|(Cw|~6)k}e&!njmktxtm2;opWGyi%mZ@l6@LxIDRkEX&~AcR9_f-8CBm4_0H zABw^wzW6AD(8A}ebW0ZZcx848AFntEP(+n(9Q6;YT1hb03s#gj`R96A$R$s4c4lXi@v&~p|(0)!S%u1mhw z;vTPDDdFQ4^-zkal3&*UOACbhiPR$Y6P{6ue&T;wj(=KOLj6RhKtCabL+#u7*K2v> zm5dk#4*xW4{4et(ghOY7D|zD;Q__x66t;@MM_F@e%>UAwl9N_(k5}4~`|Bn3eh`dS z;HNNX7V0Nbi`Y-JT8PU-F~3rnQYrZ|Lj6RhKtCabL+v~H*K2v>70F@+4og0o3U7fB z4xI_Eq8BXo=r?S=yO9k@qc# ze#0iVG_y4`CNFyU4f>ek$slSLO4jp8 zU_H+DpILf;Zm#6DJMLSsUlr}npIe5-nKPkzg;arg1)=L<=3f5wQyvbFY*XN{ILrA@ z*DZuYZGtO#^IL$lV-$s=&G_iyCK~gnd*J^kf5koSNG{>yj`Xbx{1gV6Lj8oKi2a0U z4=xYIc%?9Df9wY>3)Csg3DNCJfVfpS?QMi)$z)&zPH6>1ul`2x=z;>J(LTB<`3|gy!H^CF3boG-uc^;MWWd-7+bV4P>U64EnLirNr z;3HQ;QwX0sS$|3Stm5#I2BCC$X4YjKPx&$~;-h#%iMsze5vtG31DeyHXGz|;&;1yd zSJda9`>(Xe3e{(Af-8CBzK4e~ekcl$9K=TvgqC*y71q9A9rq=YgbI3pY#tf+Avs(k zCF}l}^HH4Z!ut1bl@sbGBt`5ej%48SQ1lajC$fb4iBy4pLI{VLH%)=)HftoNPmzd z|4e`U>i2*;r(k@PlFs`D; zSy&p&4#kFMGHPOIBcpu$RpY+Ph2reH;WHva`QP0#GQ*E`sB>Q%#1E8-a_Qp&==+4( zTQ5sX*)e@Qg#TCw#eXFR$oP<*s@xytM;}nE%k4D3_T)hu2SObQl?ih{d_8s+*lxZa zGmBo978Z8Kd`k6DYGtV-JG8Y%pJHSfTODl~rTL-xmql_vf7;_P#hstt*0_ABKSb0K z0+cI%GjnreCk~f(Mov0T{Edp`=F{b~IsKeZuYi2|1?1}>myfGg$Q(_+CH(wRKE5SF ze0)oU`1qCx@$oI;^I6y-GxBbfkCrc>5rw1$#S3kZ_}^LLw?`J_akG5dBbs$tj%m9> zBSivs(DeD=x5<-!PivWmf~Nng_Ve$*X3G273-ub3x&`S$1P zkAAiM`S0J&lYTMV&%a-qCw=+$<8GSZ{8#Pgzt1mE`o(NN|2}Y@^yS;1>sj|-wV(ff zpgidp(0o2*~8hyNaiJn74~Cs%v&tL+*8yMB4nmv8^KBH7Pd zr=KVNVz!_Ey}~@{%eVh)QS9fh`^%HQeEVtFDa*#MmOuYHjCs#3Bh z`O1@+y!*S_FLCov=QZ;vP(+k!4=6F^Wpi;NVx>AaZ-}-Of-8+&qXUMaI5Z{v286;g zMZ+QUR)Is}%D<8*aj!N*2oMqL>3AgbImSf_q0~A2@69r#9mCuVBP2)V6%>1b)@M8m z&XC&AFsfyXR-f(PND+E5~QqbJ;1rK5{!;ko?d`?_=Zp?K$t0qm0n}(fi{+ldFX8)Au%%osw66R9->8~+3A%(17nUzN@rMm(itJrO|WcQmJ`t0A{ zfL&LpEcsBv}co;uRBn0r;rZB=GBce)xmvsWm)>}bbXheKMi zE7ab%J6lzYo$>kp8-FcTcJIR}otl{JVh>$Dvul2`lnoxdxZS>TE7;xB0#oA>!`YC- zes;Z780l_Fwm82W?Xx;9-|BG}-|IvZYYp+Yg>|I_jtt4T0*L3LZbUBTc-i*?*%}SIm zJ7H^D<530a+V-9|(+Av@u2)yxyxz!Ln&w}<>Va>L(qTz)&R$wK+4UZ)MkbvWOJf|@ zJ()f_iM7}}wD*(yTckc6+CLlFFqB<8vc|bdOE*fRpH!;2eCG)^*{VvT^02COk=F4~ z)eqK^2KVZ*_|5S+cDCP+!0Ge5Nz-A}!M5cOvZ=FLUDe)U%5GU!uHvQ1*V%NH@13?z zJG=7|#!EM2C_7+J%r`l9y~Y9djLVaro!{P;E}PyV?nXiz*2ns$>Iqj>cH7s1%;3GL z>_MG6UayS)k;Wu6y*0e$duhz%%46pEX-ku@IO+Crv1iks8}GS1i92y|2vfedN}3Ou$e!!(;y3ms+;$foA2ZoKyeCrtP{}d-2&1eyp--2CH_H6JZ2XA(}WAi%c4gJ`pCBZ{hF1yI4&A)Hn`gIl?J~QlU zpT-y2c}G6&xL@0sUFAOfxXBI+sbo*wvAJztutz(cicF2qWcLhQe_YdJIJ^1$PP>z7 zi@MdMSHto1@wcL97}deZyl81qvMd(iamP|3@7($q~o;`V+A?_OFm^?KcMadoXV_zv`hcd>sN|nNU=E{Gku==>^c>ArJq z>$O(eA>C{C!N+iBQ|ZpuR~CJ|$Ki8#1w*E;3!9V}#LUTBAw6;=V)@%AOWDO`?k}re zOM^{q*j49^Q8+u}HM6+Sl}_w#=kt5|`z~kCsJ~g%rM(in(c)sc8SG^?W_ZKbTOM|l zuGl#G`eEbN(ltt=%;%G8vI*;U%`=0|*b_JB{AXBYFnhv$Z@FfEE!i0Vx;K?S)MgW& zf2vyDZijS6{~d|<58ai9ZD1Ny^ABXV>or)vWOF-q-`)5rcPcJt*Xed(-y~!#xgH5^IJlVXR zsx+YAJJ^Vh}E`^NlraYkf;oe^1J zXG9j*AsuMr>&ZE8$hl5WXaIt>{P_I|-_PFojThl@V$|R2KUBz$i2Jh7i+Jb%wxG~F zO@cP{;LklGcmBTuz7WUPZa>$dh%LPy5Ssr_sE%=A%7YihA-;NH$W9Ug;1)AKd-}(c8tO`Q$UW&D=78=t=TtQu_9XOg@L^$WEb9Eft?cTe;LmxAYT|N1a(E0G zT$pSZn+(67Fs*{~TWkrIa>drhHg=B2)|N)bR_1x1E^*3!j)(Hum>HWm8JqVubjmG3 z-SmU6x0vIzu$04RY;A3f^;uYQN7-9WeRdX3JT2L5x$=kj3X(s}CqI9PPhS3LdzMZ! zTtaB}yoWNbKO#c;^B3G>cruIR&tKpX2fCkv?mHBG-osv|pWcVbIq!ic6{vr0%Jn6dBvdt|Mr4`eKOB? zP|pN2zIg`Ezs1R2^blJ$V}QvMv+@RK7!cBMYqOqE0{t^=kFU9{55`Q}ESl5H9~$0^ zxmBanXEJS36!jTbKZl}Zh1`tZ!^$co6fQ|ZFLyd<%1e^6zESp6*1J~dcX9st4hGSQRz4NFd z0l|-tRX?H4fRXki4cx2%=+W*_nW=6^K~$sY3oUj;!YJK~ zE$MRF3ie*}ZGp$WS0MQ7!QNTrb->)i%exrQjDRy{SY^byCP1%=cXs(_WP<6wEmo|3 zCjstHEao@1000ENpLY5h1DxRPYE`Cx10%Im$2tz<{HnHe(4aaJFxzC_j!FXn2uSeO z@v?!y`-}7NR+e13gs*sVu?qyj->MARIEw)@J(5lgFlS)zsSS^x-ux8=422#yMgcgY zwbh9SS>K_1bH7NDI|G9p$6T+~Jrzu>F|XMIu{#`pd&JsuNsZZW{u4XRWf+*86dcsP zYD>5xB*iV_<25+{Y|?XSCmWdP5q842zAxA?cfomwNj2f}peA0CpW@+4i9S?+HQhn8V=Ts%Y_1&@4 zFNS^x5zfad#QH^m$dQ98oLXoK=II7UmARS<7Q7m`?~E4%U8Ba$HmYI>J)&(v{}%3G zkyDn+>carccwf~yAPxZkMnU_|x3mJmbGv2iy)6PkTQ}>~oRk24n{|2Nqh<=`dM@aq z(@7gdFZ{1ew>kjC>sWTPmo5TP;FZsf`N6>4Wy;r^hsuKK*LA!4_IUxvSah-UdK3Tx ztJz;r3xObIo&V5|qdq{pC(AQb|B-;{UNkEN<+L%2?bD&@d3L%}N3I>|@%HM=itb?S?T($Fj!^v4A||l_vMDp42)>gbjX~QTt0nAuw^?Yz;U`2?A~6MK(>u@^){0}g2ad#6_WO@ zfXQoDw-_r?1=CyhbgiojVW%^p{w*$Uhm)lB4QDNufcZ!Ijq&c_3Sx(Ae>&4)A&fH* zytVM31h` zj}gmV9}_zCH_#c)*i6H)SF7&3%}XHU=@ZKRB4HR{#dk8Piu8LEh2fY50P~6gwO`}z z7?w8EduoUW3?BBek!6#?wLxVr?Sm93Yu|eKnFj$ZQ>{mL?joYu)(3sf4Kj4>D!+L7 z9e~=rWoFd^IR?^ushpNL3N}5wI3?i*zE{XDT>C{t*Yx%9Hf|zXo4v1U-z4JgI+KuN zY6SFm`j+*KJ`KECYg2aeA}Z`1U3;MZ2XuA1+77P65OU~PS9*I8dONng zY30*E{iTDk-WemH>=)H2!}A#ArJ_vD4-vrbY-}7a=QRjqkXxh}3f= zyYvfcMNq>dTgjWB2t`_*TVuO_UL| zu9r(3<{;s=NZ4DzjD*K$CyJJs5KZSkzp0KUfC29p&(V|aXt27+x4f$XEf0t%#$P0Z z&`-x&o=0lH^*aemA4e$A=4`^ewFJp-vbsNANO;k(z8>(h!3`W;6!*CJ5m4`tw$4l3 z0#Cu5gqBJI=y{ATC4VJ=4MjwfOgaHHci2yt@7_X_(mnU0n+f3B>*PE{NkGlxK97I< zkb|Y|^~B2}TM#Z2uGgG&6p4ZLgs@-$@#_**s!9ZKzq3x2N=`uMy;Nh{T1fFka@DXy z5zs)0Qxd>isqS(U zX}mT@m~^n+0QpvFwmbW-fzr=q=MicOw5oCUkZvNP?d>9Si3TG2oY;GY=^_#D-rv68 z%7cJ+m%3J5w*N+5DZ!h&Lny#A`c2x>&#UOa{53t;l7!o4#$_j7fJdc$COXoH?$p`V zO`3?rrMC6FAp%M#3MQPhA>gg~k||qKz7ZU?Am}>F`@Uz#4+Hv?@7!O)e;Sgf@8*ZweaAxHI0oJH7}U8zD36mq z3EqEB<}%WyVTcKP=JaR*gumr0ny7mX3G^lvzEvZb9vHsc=FTfjXq}YhE8uf_aa$;g|HW46dr-3#t`#N~JrN{4bGyuQWl-8XN8W>0`ZmzmrAEP6A z)r}qqfM~rgw_HviS{_TL>se2O0{-d(s&G0CCUZE@&6bSe&gO6S#x6sIv*wj5i77O{ zZtJ@LGZmy!ooAsa{RGMM#hVX@N&eA$DCG_*e^6=^SBSj<7)rdhW9KLVLMHR9;z@Ri ze6TRsu}cHO+tweb@bf_KChs`&@hOaYLUYD1Py>@gEtSjNxFAzZs>BrTq8`PmgdS2n zA!=%_FOlMD*h-pITE0E_Qs&**&b^4KO}TqZ8~4GZ{&DvsF9_hF9dFV9hLmq`8a~** zt^ppSKAs=LG%#w8q4&zy64dYQvPst)!wjQ0W3{4Ru@h}y`z5e6CJY|CTmJQ&|1?|ACfI>spV z)Rn4;q1m!|F=78POi`L>*XLfx9El8GgZeB?YyQNk-@F$~`-;+z@E^yJiJq&10pB57 z+>88j5*HRbBy7q*lfXCu$!!V#(x_^D3Z+qNE z!bgeq?A!eW@YiT~ez_7LP1j7)f`$rW%&69`DO!M&7CU?D4$vPT|dCN^kSJj z0lX}Hn|3J@AsZ_kzrXPVm$$Rqc%=yt-TC{yR0sjGs@`8ElWs+O(a-VKt)%?rP&ZvT zj|LR6{G;7bFB zRv9FJaNSFZ)(b%XjBudCz)SFGIpe)RPs;!IMLY31lKiA~(EF$I8W8A`TqHB4fi}I| zvV%H+T$-ib;=U_jd$3;WI5&VPg8_S?G7)!(yO$muAwcA>82;(%4{(%!S4LtG0c{WF zefiUe;JX-`-J~ReX;0%;=Pawh_ayB-Rz@PkY3_4-@o5nQ$7C<>2pfSwK_0mz?l6e9 zeti7bEglR~ix6ScC8C4Mx_b}>Ks3Kcj@hshn&z7BIbH|ono)B$uL^OmN|==F;vtke z>_`73nSc)4#&btV>8Q=xF6I4cZs_~v#=toB2zse&kA7H70}baP`aRubXmnnoZGnY| zngNVoSl$ugk%-T_Ts{~2TRD=~mLl4WYbL}gk>YJ=LpFD*2JmcW_I*ttfQ%^F@5)R9 zitQ4+nDvta^{$+o@lYdzacQfFCLbBzJC|wBRY(Dvqq+1*(wsbIfnY{E+20QSs^s0cBm9KD_q)4eqL( zN$fNkpwKdz&L&4d4SG%6MIO?1XzAWOAFl$U1pknIHwj0R7ovCWCE+ESXX>p@DEbGb zy0Go2#~`h$hd)aQ5c}{pn`NaH>JH9(`AZSeq{BMBe3b(t4cC0tTh3wFhrY5)E@33U zeD;`eraL^6H`@2HT>!2KEp+}-Ab=su&ZuTG0w~qS9^BaagBl9_KW@KFZYNGrfNf?2wK2($?bk0Y>pDsRF(unLdV2y`c+KkkMl+f!E>{Ys!I>sV+wRTMNUa)$P}jKgC5(@{>hHJG>@ zT30+6e`J1H-!P3()OIwj@ zSX>|Q>!r$qFINOlg3=jS_Dhg$KK2flnJ#nwSml8)jG@mvThw6U!bfdBa~4>pFj%NR zdmVaDH0RFOa>LmBxK~zotT4X)Ynm$qBUIVXpV9km0!;-?$L!Cq;;Rc6haWU=$EG9u z_X+Gd2n&Px?{}9D!L*NU-9@2L?1<28s&5>G&sFb_ClF6T_gQnYWxXx<%y#t7^j=ly ziow&cE(qTi*8|&A(g2NqHSJY@1g}vgiLS#EUi%9iSJI+_#^*89vX^;LZ;$TamFF@L zmQp?^)0z!Y-j1TyBVmxAR>8ERV+#7YQ@`Jf9!Do#swYR8Od!BWlK;TbL1-WAN#e|( zgizjd!ymT1;61m(TD{;ZeE1ahwQX<&riYyh)>-mk_PpYe@a=bD*5c9fr|mf~!`DtF zbHpAda}=UaO7Otsn7cUrlsrtzM?S4IIStc?r94f}rNClTGjq2c!j~cUJ)>iC@HNWt z#kk@-nDaQwT%FttUqyPa@F&{B+^OIM>ahTrAF;hfbDshlXx=bY%e{gYHwRYzvMOk~ z9ILF9r%m`ybpIyNw7sghv1_?T7Ty5j+K=ynqA_7+1&%Vc2}`!sYlTFrXc z^uRlPrW`A=o6xG6{LU~g7y9(iMX|EAK;LUo4cCT!FoL&)^%-?wgx4`%e4P<$ckG=y zcHk~l<*l6xu9tw()gr1FgJaOGF6nl!CJ4Ivw7&ViX@#yQ9$#IKOhDJ^r29|KaX{hR zgENxmXQ0EjP+~!gE-)HMFn0`ztn%YSpwsgw6t|O z!qE4%bzp$z7krens{ts6h7%`b?t`I}u%kC0alr8X z!@`jt9bqCRUYwAZ1C#uC?|!NQjO7^YAEqIP(H{G4NxbK{CM&8u{ZRje3Sa2>jY!BmCP);YGI5sZ)Nq# zZRpqYi1oZR1Ycd~uF$EO!051^@UNv#Qh(H$%f;dx=PTKIn}@*Q48ZNbC!9R3}Muz(fHBCyBx5uE5Bun~EA~1GBNhI9Qp^ z4`xK%choL8!bn@MS(Ix#G-eiyRdj2>$YtSHKMK-#XZ;SRw+X@Xq#d^kEe+tS+CmV+ zb`}^BD$rvt%!Terec7fXCNM7&82@4qHGC_bej;}%7-mnEDUZF>f*Ik0xWcx@Od;*ER=Z>P+GB=(D)SQd!(ZnHkhF9=;*<7B)?e7dMHF#R}03xnV(wp zWkdO<8q?{#HOQy<9${`k!i9ls`l(8F7&YY7HxYOOxdPT9d-znL(@2q5_QW^|58IqZ zMk2u0eX!&HsbT0BqddA1y^n;0n-v^w*P*^t&i+XN0p@d!wU`SiF@E#f#r(@OQ0sib z;%@pS7;E?7YNyx-mKpY9O>Li`(r@aBmE|N1^IEAjmC3=F_}**HNs{Ql>vt-DYYBYG z&&s$ayAS4sqrN#^d<|n3bPbuZk}%10a{1uBGcelzdg7e{BfR5vF7j<4gSnrAJLvXb zgbC++Zf_n2z=FPE&l}QuYILW*{oB`c(3?NU-S1xsqtjd;8=hZ*X%jZHy05eF&F$lv zsKMJXBQ^f+*#JE(CS3~&r7(bH+iMrn#=Kxrvb&`=nH1+1c^_6h8GuE>UK)x@8kp*# zTs*Z%4@-(;F$ELfVdZ?|o5Y?!u;ikuIn&v|TcsL$ zwi0}<3Ej_Ry@bBi<6}a(PN=|~>*4gR4sYLkE}l8G1n%}tli%WRgSK;d&nbEq2oAI; zVXu<|`2;jVDr@C$KrX(_24n z8D5y$Zx_s)$K*h3mm5qaSeKt{#vAesihX-OhDZ%yU7^-3?!Fl)_L54N-4_Vw z299D%XX}BdLDw*Dnx`Xn<|0NDxdf)4N@CI>0cd06$6W2Z)WX%(n0;_#nR&|)^L{9= z{GPPO4Cj%kTR%j=Gux7VYabWp{cPjD`}+cB>9)43lGk9+<-*G>mj*HCmF7+(msX7E z`x8~Pe?NLY+|2S2aRgUeq2Qw{(?E2bS-EjI9=!MbP8R!k39Jeo==SBE0q28h6zZT1 z_U+`&t`wbcS5^PAPnrq@MTT+sohbzON!xtMFRh?km~}<#jv06tKI1IXeg>{$5)9ew ziQt-hc3Wa&F<3@YwtqeL68v}Xz3iv)1p|H@hW$FUcAqB-$Ydl7_par2mUwxNgQQoD_$FDAA0QL?OB zKlO?odAAjlo|^ zb4(b$<7-S+HZ?}39oyb19+i7waD^i{Y)GnXwe*1xF;vDX&<@-l27Gb$x&b~^dW@{Ecp-3L zJh&}~2>ORK3GDB`fE|B$dJ)qPMw)y1J9|qRJc#B-@nFJ+X*>_0t?BHn# zsqu)R>QW)?e`LlR?syO09EsJL&-OxO=#el^E<+5H<~pQ(;2gN;Ijq@_lS4Q+{Sx&^ z6IyfJ<=y}I5O@pLEPwB$0&#lXWGv!=u)_?z^Y?Ah&fw0e@D?WE-8y)E-QNH_8^d&O zyLDrL($CyAm3g#(==$qEdnT#BUGlCK7;Si{*v+32Qd*DAshI~su#l!@WFoj&xld6TsiKbWwD6f23vhIx4Qg6R0L?%9>u(%UM6-g$y0XIq;P*+Q zfiHpu98^QE&u`m+hd#$29{0>dZ)G>?h*T%^=rA_9L-!n`-rON1GoHko%sFp{f}+qj zO-X`XiHGzWXX5tBRwwYYDBrUdK8b0W1c`$-rbs;hwzJ4m2$X|a1y?^k#RLgXll?~= z(Yx$d*@q&2^x7iRRR}Ku>*w*V&o|OuT z_g+0Y}1Lb2%mG`XW}ISK3C4}nK6_H5AW%`-Rkdvs5QXXo4bIz2U^=LQ4sunUu?V6 z8w+6@i@%s}`9h?w*yE8aBVbajI=z(81@?LJ*2$h?;2L}OAUTsBgz{-`%JGasI76Bn)@TSHFj=n6vK=O|+G-bXeWU@^rBHR2AXAjf;!%00*^Ev~2c1lwy+tEV zg6djFBYJU9gdU6|M-wuZI6cW`@F*(%P%9&VZhPqT>}Q+N^v!WPF5_Qd5y@MxxM_fH zDYLb$fg?x}u~Aag!~zy%_l+r(Z=;2To$kTQ{opt$^{V`Q09uAz%Uju)M&}uU>tq_V z=+pe^V&oJ*CV8TcNx^9}YD=i9rW6N*jLnO`-PFOK?9#A&?HPO9P2LM#ee?F5t+VlwfJ{6TIf9I%QU7;OTrCAHzZc)aR*M&xY)Tm#W+6 zP81O_$?I{TX#6DP%lEyM=RSxPk9a-V$u%+4IL3~s{{lMm1KY&Mq@niN9hF1+&G^jn z2^0IXCr}&8@c55M11SHRo+YriL49?$#?^%fkjzs+S79UqZP|8pId9$2D&>K8L!lfR zD+|A>?;)UZs^@y0gBF^F+WW)mCc0Iqo16@ZM3)b8tC==d=t8V7W7Bp)$FnwXEtO7! z-mW7pD!)sRxUb~{YhNF_9@=Q4;z&pJn|ruuXM)gW_L7VH12$Ciq~7_xZ3Gq63X_kA z$3WB|gJIAv9Y_q{#osz;0Kp^udvDBCKqzb4?_T5G5U;aGzdQXP*w*cy8*t}zMNmI|dnoHK#WZ*h5U) zZSDQ7LGtH1-cKlesKMN*Z6Er{1OAiUVXw^i8uK|(lGhOC8AB-n@bZJtKf*Xx~f$wAr zs^zjcRhDc(szbt>Z?pqyT**24pk^DmTwP}GD9Xb7F?T1AEB1hk&#s!2q~)B?#>XXP zi{s#1(Z%5KJ_`~r9%7?Q&I0FjVYAI#Gt^{@aJ#AAjrwoS+|9K<43P#RzpdjMA<+2B z3tg7S5TIxE{++@wD8Bod#@iGIx25>?-q7Zv^)cGw(^Ll_Q84_oQ_EM#oKMjAZ|#F{ zQ<+0WNdpk`o$|2e6E#T4da2QRxdQF-pJz`WbB5f~R>OIfvyfqVM*hQk5hQtUi#zlB z0Ytg;eA{+42KzK<8+pv=H8}S& z*=a9&{gA8*?TZ3y%1L_v@CCGj=Y6u;iI{3xXI@V~g9TCf}C6qsOy$C(F}q~&o$OOm>Uy&*pC5(}Z+s7I|K@-03c3Q|}# zRif8eBb_(iSD)Am!47JsOM-_W(sYUCjrtFWA7*4q_P+)p-1Bv}KP5rpQnrs(6$QUPB_=s5bjfD~NT=zZgh&1%i*HII8SC3dx>+)AFaifp{>%UgJOq z#F9}?Df0e-Ah!F%i+9d|2EBcio!k;UY)Y@LuUP|!%hctmo7cd`_oAvd^Ef^Vs@{`5 z7z-L+UuE7zokiD49Iwu=K^qZkUXxn|5Yb>_H~W1Q%^wuHZRb`-E$J1*hxJC_msHLO zKf{q2VfTFdT~axR(6Z?XzD#g?)&65+h6#PjO4#%Dj4`5MpRW6S7uxKY=DPHT3?u#d zT&y2{L`}c-PCvs&uo=2Tf7m$@<12G`!+NX0`T2=GN1tBDwB5!s{v+z>x%J-uzPA>5 z-3d&d{&oWc-+z&~rg;e6V;#5l8?9rS>GO>{#q;Q|AJ+a`yb~O6cS!Q)387P-buqc6 zEJO=`F3XZI1v^oi0d3(9uzzy(M0eFE$O!FYJU$A2z>bkx ztSwj%Mb-L&pZz!lXBc1DTh@t+xomOjtySRV<)$9z{syAhLx~sP$YZdvkH;AnMTpt` z(#AUPC|U+@)G(=1g2sh4v-IvchzoosRGbt5#L|!7f>!>3VNl;aa@}AIAk*RrC2?v! zchcl>GPa;2?TcN|L zF|=GGfDDhIdz{V0&7euN=dACMy$$#%)1C*lcc84{<9XsECb%x6B%iSwih*K-=W6bE zqwm$7R%&A59`K(QB$!OUax2F(2H$Q$ew zF3)w9l-?Wo?EgesJ~W*YNXFHp39Js}MxK)~gvgWZpA6q-W0+S^m(%J2i1=g17$;=~ ziE9^c%qG1Cd;K|=j|^7e*SG!BZOwP+F>Jm+_4YNq{EIP_K~4^In?uq^Vy~dp(S)s# z9r560!^m*(>n0L)B2RKqeujV+<%=cN0}#pCv*wU~6odS0-hUHhgG9@%v)_#vFxs4F z)`$HnXp;$NaAs;j;y0Ek!0_MR0b>q7Mv$N7EDix6r>y z9uWD(g$@De$qBizUj%bU#M@I{+{8F8v4A*3@p*Kg}|=O`VN6r3^Xoec}gva z>6IJGo9>S>>~2xkO^IwU5N;ER{QVKVLQF?59b5;+1--r9vI>~U$Chb5B99@zc4gTd z3c;k-ikazy3uwW=ODe+jC)%%B8%D-Wq2H|7tkvpXVnVc)Z5~v2Tf7ft>pdaL1PT$NW8b1J^^kycP?5S=)tgU zpH?_8GsB}nHu_FIE_5wt4mkdf2TE^ia$Vpsf;uS^|DuDJpx)YRokA(z=OTbP9~{n;1GBnpQYPU}Et&Xa~<;rCGcn_&C1<``C@d}mR@YG|A7QV-|)Wc zmDB-YH7|YL53hmctsfmKXOBY3Z**~Xq#-R+rQdKA(_qZGy~UHKjlr%cF8}9|MTjb- zOu4B*D%CIL7=C|T;2mo#`W(2cz8e=Iy4C30>ow9k zrYT|7%;G(ya*4yCpf(8HCMm(|Hv#eWnP2SVNM#VQJG=uNhv2%6Z0+6eT97F*Dh1_A3Sg6N=#{jgf&R>4O8fG1(N%N$29@A* z^vr%$xs7CZ-;k&I+Xq`QYHPN5h>3)|Mz4LsBJVNcS^t?k1_~Gy`*>qsLj@caM9*66 z?8n#(tws7m`WWSUfn2ED2wmH}oRZaA5UE8&&AToO z?(erB&)nmHk4!f0SdFH^dq%->YX2aFd^(W%cr*+gYroj+-kl0z#fLc(`dfhK>l(M~ zz!UKD-U)?VmqAJOV2PRT7DRKW`(+;RhqSodq#~+th`k(~94Q|KG2yq4UZpey+YOtd z(EjIWx0PDLcQ6#f{5qv}+Kxg5&ESjj7j{s%{~`Ie1O`wU())hRDj#&dQs*C$n1%S2 z;fwK)1R%^w?37Ja8vgCVM;M$b1#GA$oD0=c&mKc-3_eyuZfIQt7vXfA)xl z=`1UR{ZillTAdB-Unr*7Ox*-GxKQ7>I};px4^;>`d!lYZ5l^y77DU(aMeIAP4H2|? zzg|5Rty}WHZPH8Nhv0Afq_57|g1^z{JH~9*;GuKRC#!G(oKSdwdXpbS&;Gokoh*&M zTemBlLvNu<-MWcukq;(t{l4)h;5^!Ix!4Ro=EA@(S6?>w2bf+`r&}h)3{i9|J}*wp zV*EDdx*?uCbj|6@Wc@9Rj?ea_HlAg`^y9Ad7Fj}krr2Y=Nam*@N5Y*~qT0j- z2Yw8f4Up;a+=5%n)+I^qzrm~JvQW9+D%#a=KUEXtfW8&_z9-C;!8<^*?Z<)tzKRjKQjg;qX#kAU@)G1ZRD!kSM>mf@9+Y+}tdeUYO)Ww_@LtpUDeo zC!JscyZ^i@JglGrz2UWg3B4pk?a?n*C^DsB`qYoELg39xC;E?gLuB>2fV) zyHIpGP)nfc4tkLd1nk;%7X3TbqlU|b@pe|+=b*+?)E3;;$ZjWudIdqd;s&XK=;nHb zqLCH@r}nK7F1$opjyN4kVh1X|KXodi;2tJ;6JqH27$Fw*4on&e;iJ4!s?CG87#5W@ z*?ZtI1X*ly@10dg(+kaqXcfj$&OYh0Ill)+QW7P?yBfeZn9n%L=6_50|4(H*{!STqt9WC(BWJEyqzo*;(f60h^kpHXw{|a{hj)wWqnExdU{4;qf zBJnR={7>bnTHOCN9H!m>4-WsOiTpQj{Lkd6h_Zjf;opvbzs-M?9ZCC}ANza0{?FR| zz5RcVe_7z4#T7b_f9-i*SN_lQ{C_jX{+T=#{0&!h{{XLle4Z`-77zaZJm0-eDe%Ex^YUNq{>mZ!{=4D*A3yhxxSCS>2jKl5AJM;e zhopV9a|-8q{`bDv(SPsT`OoP8V}XAQ3t+gYs-lZDNj9cs{dx(B9uq$4*IvUR2EqK} zV*zx$=*JhYZzxj(kEWuXQpENFpZAj;&)11~PeAHq1G^xYWxjXUVX}uX_^m-;JO{*0 zx}EZ@u@GHc)qEn_9+P%3TbDCl!Kij&93wjpA!p!S2ZtCMYI>CNQXD`}|8VnNzE)_T zu5WKKQ2`>fX)UDzfN@6o2~xXDv0-+1jjD?-Hn|ouJT_^=HxUW0lAJH0SFDj;)QTS) z`TD2a9x-FH-($%&$(#84N*7C~Yy{M#I0v58-vQOT26#s8QlWfpzD4+DF_^ryQyWc* z#gs@6X@ecSkT5E?*877bzg69wb7MIa12#Ttyz6?1>LEW1i4M6C;utw*bNU0g&FQ+j zs$4`5ez0%aGXs&S^tzYrGr)t4>6o$6Ht-9)J$99wRIlns?)peX52ME>^-o?B1n--? z?jNN)A-FBiJgS=?0{lW~Pc0dsLt{nZS1J><7IK~2FWP~c#-SPSS0pgk({!4`^C70o z8J{#s?!%IsW1`;qRq)&^Ztwz&8)nYT`3uq|VeTSRukc1D7W%~t>@YDP)yKW+(5gs< z^nPs#=e7ulax%TBG9H57pGx+uwbwz0gesTeTU$uUxVfY1WgZ5ff915&^aT7fA4q;W z8w6>sb&TxvU%<0sf$-w~E%f)k)VO*}fTU{G9nn`x55%21k}vy7^;QEfKd*kG#9&tY z9YT*xK>c0y#j0{Hcq&XL<&gKCR5y11g4@1MbkHG;cs}?FmM40mc**@BW2)`a$sIP3 zcrG)VqcRxMOL=(i1~q}UR`k0_p&gjaDzV)s*9U8<@09J1r-h`{i#gWIMi@}CDouaw z20qRE@R>h74ht-Ww-s+)h0xu88k5Qe$n6#DRpd*+%n1+4b4fNBn%^Uzq^$(*HpFw= zybnUmk)s-h!-f#GryzW?H49Bl3Z=Mfogt)8!_MT`8WCipDVO}_5p5x~|KYT%s9Xza6$-SHKRDo#${7{jLRL)Y`a@o9 z@(B{L_@Sa*C&u(VEPPP$1;Y%Tl#42rFo>~|?`f?&sm`g_U#9UkMyAetQt}_h5Stzw z%BVPuuo%=PVXa<~m)(2->nIUpJYm6_yG`M5sw#?m`7}YW^ zpsD!{eOALdr5*tUlB!esL=K}}2c6O3Dj}2>QQ4F6oCnNKDpYtcl%PVFF@JKl1%@5_ z_~Ckp1o+%Oy}j}x7rK|LP1%2Zf{{;cb-(l;g_x}<7uU}1Ag3*8v+6Q|L4lc{*{-dl zB}4sd28RO>zMp|`W=$HLZ?*38YF7mni^baJUM@&>8e;V34#6iAazmBpotGWnjx}8$gCfjdP~An^zT{iDDG*D%T)ByiHU}E^6^kP zW)X-TU?1Vmb423V8KL8ueds`QhnxO5D+(;~b<%u{1GfNmAHm{7=v=Y4qvY8XxW|Rj z8>Oy*ud_DwS2GT@m^U7IcE|^fg5{hq?ze^b7elO)FT~-|zQv6WixCn{t&cy1Z9fKE z>z#_d+6|%P392ud-QaM>x`AO|8hBOezt84t09z_W+FwG?(Q10WsMuErJ?l?ued97m z>rb&Xa=9buS;T1%sW%`ZtULO$ssgyU>^7)fPC}P>i!H;I3b3^CEEQtX2B(Yak7cz4 zL0)32ygSk!<)6FJ`o#`_|00vQN$e(uw>BoHnfO73K$3yb2_d}y>cbs=3l0p=XAxgv zT7**-%h_gyBw4PShuSw$5IrTyG9tSIFucaX>P>?PoG;l%H9Ad_*Ey~%J?XlP4X@eE zj~NBvyEA!)-On?zNkV;sL7E?Wz04*l=Na+!hVGoxzF2G#^2}bPFvZ3la57O<18PNU z)aJ}HplpCo>(UWFs7AN1>%nWNc#c+N-iHh;vT6D#F1~`?bx-rImo*TzEx*D_ryR5X zG&8Kt_G5&6f+%m{JBSnCw>l?BqVc4^sec@#K;l(QoX$>)fpixW-JA9SkVr>2AFXx^ zlO$qR+zfl*vHVP6Rf7+Pjc}eGR=a}N{WKn=eL}E#=`23MZvtti8}8St6v5_Uucry& z0LDZ;pnamf3%r}3%tmmvqYu?`Vpz*IH1Zm{bE9+)A9J_Mye(XSay!npI9!`QL$oN>8{n{p>L30xkFaPXbv7{{3(@Fya&-Qoqx8g%wT#(+0{5{T_`)E zYpb2I1o6o~Ddig8Vs0*{CQl3zqLP@3&Mmn>p3nG?^*fnpE%RxqrjR7>$7ym`$I=P{ z&q^_!m1#uZ(z~@ZM*JjsA7|=WIcqGg?m4ttmxOLnJw}T;v{3bDq$l+HD@+eb2#veN zg6WEaHhD8wkyx;je!lZJWVfAHSn7KOk=JL#xteDnXM3di$R#=S7^LOwYq^Eb_x2tP z2^_`8yJZJlXR0ChUeaXkoHZ7j+HXlV&fwE`xJ{psim?sRS*vQT5SgOPdecz@6WjO7 zXq>(Sk4~Q9TBn>M9g}OTRE}b5*YCEZIz7l_k{il=6$Hg08eGRKGcmwF=7Cx65Li^) z8CDL}ftXsK7~%F0kQV>u+tA2&2$pE@C@C6)Jh?tk-4_Q?^uy%VEBbN_DZO>evpyW6 zG9((rP6GJ7?7C7#9e{4bO3&Sv2SAr2#AfHQA@JH=A8?Z{0qnvX+iUu-;{CP(?sMHN z5Jv3d`M}fwVSE=ys9s;f0=tA&-Tmnh*179QW#ul&xYYf}!uTadsuQWJhCBUa+TYQN6gR$b zYn>g}hew4w)spPzG34ookPh=uG~_-{lT99iYLq$RAJjO|lCImk>%~vB&3+}!n=1%z zHGFi=M}|neDCIOGjay)RWar>x@|UPNn|@$TX99gZ!qSpj2;lsOg{kZ4PY~7X@K+Wt z2g@2ul`|xnp#6K0I)0vr=8ux(3~18P@wfftXU$9C)s*&3TT&c@pHv?ab}fVWOQiTG zOyUuk+zj*HC5@WhJnu`4K7mc+VcwVxS_p4{Kz`do6g)1EZgqa;N8^>#MN2COAuPZ( z+xw~z#$I%+X?+}tQ9sy!?LKP;0k`YO6yC`|#-U&4H3VvmVZ5U{J4G7DwY~G6M_5Sy zk>6I#=@U3^`z0<{y$f93^Im_eW0}oPABWMbYT@Y3#`lK@YAoUXx9_ zU~T&}>?ng77#L`uGu?R^?Z4VRVzHotlSYKQMZ#&|T>SBl^Q8?CA2EB`MMy%8z8r_5 zMR34T7k6H{GOW)3ra}*zpR-Aq^K#QL5MLuMaWD4wWKHdFXLJ5fvjX&P#kOjZ& z;EKYHO&}KSN@F;rjebfCGlNg2(XPPS_E0$=mIjHwZrxLb&nEBg9&0}ct9^+qF(Z@k z-MNe2m{JrgE=d~RH=TwFRsKVt%D2HpNzdY`qq|^Sf#&O<8+tJI$83LLp9ZX+7C1m$ ziGr0pMy}(DDVQ7cxr&c`5mp8y#*55CVcARbLkX#_cWmOJoX(~Xj59^-nQga+m4+wY zGus(qg|X(Bu@xJP*5&_P$PIxNo_i|i`V(MvciFCnH+nd9Zit^EB^L+s+V!V&gr|x`cHo)l93Qa`c z*U+W9@qV|h8g#rU-D{{j2OUAOmBjidFjX`VwTqk=Ca!aP@2TyFFPu^zvl5@da@jkL z@W7uiY41ZFIP3!x<(G?;3rV#0=_tP5_V4g*S9N|&@P3&4sLg)B$N=VVT1x3Clj@AC zUJzmj{V+{sAt_8;4KsJ2W8c(^vIq7sK79CBe-=AT)Y&dne|N*gEkCWi z69nkWGd`_xMGq$K+**Cx+5z4EuUM}HH(xVd{64dc*TZc)ZZobBnqd@-{{5q-xV(l1lOZpY@0EStLvNglZ^s%Z_rV_B26v zX|5~x5^27YP5htPhCuczsQ_&v2YqgZl)k*41}fgQJFIH}v%XkYOy(5Bc!%z!L-={L z+UPz1zEu#T_ulweu(KNz?U}S<1Y@AfUbvt*jt#noavNQwXra@Zrr^-=N*Jqj>ZzoZ zg$c6lDo*i=FrCqGz{@ccQeB&BODHv9TovQu-gm=f$9Oey=Wm!ilky`O9HFb!YFna@ z7j*yH^wVVahtDZhHw}OGqI-H)!}bjgSkg(mK58)lWBpFQcN&M1WP?t(5=?_(^qShb zy3RDrbUqN(JDv%hQLB1n^7+semc_SzFBfL-@}C^d$$)WX`3bMN5SWlVrgvoWIV`r& z4#mzKCh>mEhd+xR$HsWU;}5%eU}ouPc+Q{`jCyRU$JBDe$L4h%)_?(Mzn@)AJFW%; zh8<N6SPsQ^h zFiJmYr;tv<#pQ-Jzu_(D5@7#zdOQc0<7WfjUO*8vpele=vCq*0P#GGzX zKe_@F$AiSUX*$7cpoh+ynhU-^$=#IbH;2e7YiT#X34FRKn3;Y$4JP`uat!NzVd76f zi(_9Tgd87IsHR!Rlse%i&M1Bu4_&qR(^7#62L&FJN3`SHh}^-~tQ_#Y`LS2M<8#Qr z!m)Agj6Jvq-mP=1NQ2QwGKN&o7~xBNRAIo}VJxROlIj>iiPa7(9qq^7!ow=;5yc z5)08{>i&STm*`g%eu|-zNX*(eOAtwBaU$BkfV4j{^vqoI^BRe#v8F6;E)A)-4K0dH zYw?~#ic%9vMn`*LY1eu%fQONp*v?8uh>M}K*paCWL|<0_kIt^>{OA;i#+l0yy!t-y z7_As~*vdTY7pTXiw6WGxkFH}o-226^@%gbs9@zqs9 zp`QLl%8C$2PmIPZ&}w^IGU)HhOrom@QS? zK*Z_gpDx=LP|pivb6-A!N1ms)b6w{GPn%N`$#Xx!wX)(p?dPkY;2vp})7%ffK`)$| z8LA*~lIrlgO=B?5`hG*7gfrKRbyB=EB)$n}r_0IPmgu+ilZ<+R4vXd=Q83+dhMXHO z-TNC)VbmS{m%W3vm_ff$Uj!sIP6GGQkLw8}Ik`%>)4~2BDnfDVWufxh|qX3+}${tyBeU5FMGesqpmza9>tF`lE-$ zXFVup`0D8{bfUNSXqcqIkZ6Y7$t&+6_R?}qc%ca7#0UQJV0n$%oS#;{P_&_%$o=?E z0WnBV6fNR(u!8%-JpLV_Vd%ZL?u?-71Ms#zd+obl3&cFjyIK}Vjj=mwO3I>rvBdAo zr>Ny?_|)>)yC1R%Sfc0YZBIV}kAoftQfJg-$#06zo5vQgWVSQ+S=nVQu`7Q<=^2KB zyFN(^d3s<-K?`#uVG;w}Wwx64{Q1lNVlIEpM}zp^=I0Cezd!SK=Ow$p=HYeOU-Qx@ z_}6?eZUYYqjY*lJez5s}+Pm_2s{OGB+0NexY0o73>BqN64xc%cz1@+`+n+n@BMx5`@Wyg@BaLAp3hqQthM*^ z>}Nk~t!MA=cM1QN&AXxxqSuC*22jW-jon)>KRF9hau~xRNi0C@IPAvR3K-oh>E^w$ z{YY(sJGLQA2jauH_%$mNk-s)&m%J$h3bYoRcu2-W-1a6#4?y1|8Gs80nFccmXN zlEBt&YGM&rF&sXHK5NfVUfl26aFdFTbf|s1)Q0ywA;5C6Ma1_uH;VAtLB}Ev$_j!whKn?v-HnGbP ze>QVjr#(M%KW?jN+4Bl{$;DZ&WX*xdIE|^-A)molIO+}Edjl|X^FHWFGX@65KhX$L zZNa;IN>9uH%U3>{c_!^~7g1$c5BITOhl}CPMk}u0(H`TT77N8jix*tm}rhl>()v=I%AVoe0`Gcg#H-sK%o!BbIOUXoYnzir>A;v z^GOu^azm4Qg3oyEvrR?o(P`(YTHp35 zlw;DcR%hECNDyqfWN-Qj%;h!hOdeo#;4QON{q!0rwrc$OPA3nDv<&6C`PdDDq}{X> zvY#PBVjW&=I0QQ0H_L~PJx65;TzT(XBT$WK_TY;fB2ewGzVjn#9o$#bid!`+g{mu_ z^9~-`3sqFw7zrr?JZmY>$MK9pOv5jxy(xgvzt~P7f*JCQqdwotl#T-4OXP@iDWgE4 zEonVw65ylK)v!;?9pRIM9`;7pqClnsN?3&~!rz{LuvfeqiMt)$zX`*MXsi9ye?CF_kS;rd=c*09)v$*BOyVd~zl{3Z?A>_{IkH#G$3ge#f5x?VxH?{asZ;b@5S*do); zlM5tc_tq%M2uRqsJXvvk6C|D}`Yr6$9ymbjlcHAKjHuFs;l(X2kj)s-eR10ax*%Av ztw(trvdRpt#9!zln{%p;-S(d#aOh~9?n(@g+h@kwc&8to`9P6mE$74VG9Nadq7{I^ zL(4J=9)&FfO)QSRCh^Vh7ZD6__X_&5Df6yI5Db}4-r!zYbwKE7kDswZ=}q{k5l zDF^xJw`bX7_?~)8olF~uaStk2dfpA>tlb5vS1v)utP`85Sv#D&l~L1a5dujsCc-LG z;(?fd%g;)(2*NBYq{C$tAW7EilunuvkagWRyxkRs0*_`p>y;TJ;zP|1!zo9=tj5qq zYLx+`1`IT{u5m#jF&=80g*uR1LWxiBdW?5Mds9Bqo&|yqCngu(R0BWR^O5CYu@IG9 zoN3(51F;jglq$>#-!z0eO{hR~uy=mLES$-f^M{k$ySH!7)?~8E)+! zDM5OWL2!C*oKlLCDe8ywqqrdzFVH!;`3@o^<9FXtwgtX2Eo!|m3~vSh~%y+qr%w_f#PqfH{ux(0sOAA>zkkp2bJ=CxUu|+v{q77^*C~0 z;o8K=bO1%$1T14vi$pHRcbC~<_%%hlkBOHC@W}uE?WCmkKoq{xlt;nT5v)!Lny`Cj zqf(c)dUpn946i=YnEYBD2!ri)HQjr`HJX2m?(@&+n!L5Kg={+t&U9C7JTifD+I&iQ zgsc#CW8Y<^emg`g-pFmPvkv@=Y`Prkq#)^iYYwfqI~ecFLb9$6kUgSuQ|Z13$_S2X z(yLDb;x$~)a`9%k&~&UxnYM{ z@K!#1bT3NUZcXKKm4wurOy#oqlZa9!$Sh2+2LYEEF0VGC)2bsDo9cVYMS##xj+AjhOz|MtL=DGqh1Yh%Swd(U0P5ae&1Bf;SNy#LL)NH%8g=NW2$WLt6AY*osy)*%?5bZq|Y7gT#n8^#oe7;htWm%1`Vd_6r#+Lr`a9H z2&iBU@nu9pBb15I2`b(Y1urFEEyWQRM5WnzSHfclTs-J&J6a!wy`SN3Yz(nS(fab^ zCrb)YV%_oGZ<4a1pmF2W+M@lCS0&obgYlA_KgSX@9_9mCZ+oT(`t!lhXSW>3A#7Wf z-m`L>kLyANyWGw8hy=LQ#Aru2Ck$y(w+IyK1!QLP?or#l21qQi&axv#qjZfHO$#0c z6qPZ3lW@-gVsAyo#T>Fgq{tpYSC_3Qgm>_{#*X_a;mJT8NpTu^ZjW@z zN-G7|dSxM2rhL$s3$AfEYk&yG9L0|(wU&A8IF<|t#UMzY3x2^f7hKUe+*bifeNQFQQaGw-_SFI8!_nAwm49_Z_7g2r!|>+h1)&Hiaii zwQn3ChCi9#-T6FR+$7*@j`1M4ubtpmZrKe)$55qA-d04`s8Jw08$i|xe$nwxGRpN! zI{2J56uHC@r?wq%1Z(0;(hYSpTXNxJ8l6nkJz4FAI116 z*z)o=eNF)CPxQ;JW;6lYlgUAiR|Ju-n7;1qKZPj9f_&U34gsaBm6s4QiX7c~ugzM@ zf#+a+6!VcJaF_5;+Zr^6&IwOY`lMcA>y~{1vzZ;>Xhna;%=raMZr3JoOAo@i&R?GN z6}>@cl(#=$_dpbdRIOT1*eH&Idvs$mABll8pHJnMH9a7;k;sx8D2k%sMus9=3>+Bn z4YpAdg)ERbHlzk;U~k(t|y@SlRG zW%|a2mWoRjShB#91^&AIF3isde$@ES@SE7KgmX=o@S8uf;6JZKf-T9_<~<7$i-g1#pReS#IZ$p{ZYHc z_Dgc!0*lY{+zcD5T3p}6{LSaNG;Zm6{!jL?AK^Deljr^7&+wa~3**7!^UM}K->yAs zUj8TB_K$S`yZBA1h0gyfeiNTGe?Pvqo1a65{?Xtmf&%7nK36jSOEJc48ru8o>c%GU%+Jt1AhaJm zhp+b!aEE;5VKo}8O$C>V)s|jbj1b}EQ5gw&5FpWKVAoXxZrjgrci>ilua^9IF>E`$ zfHBuA&QT2zuEqZ))xZX9U0Z8KV#yF)5avx(UJD6w+sLeMp1}F8!QC_RhH$>ei561$s0=gU?-i0X+WsD;`CY3 zXAf9*gAm--xpR>h#Hr>cgPkU@uDncTWez>C^e5cSq4q%IE_&1^5eDrFcL;z}gA&J% zW4fUQ81MdU9z9$gS?O+5@+O4GxKYX@OFnFY(QxcJOc$nPp2%5>)gx@A`bC8!FW9Ti|Z8 zL!J1tC-;PGp-GEJEBc+^V*LAd-tui6TjY!UgE%%9(wK4cEA6jwj2(+(It%X!R`V$? zjJtr7T#1vMor{+L%{#g1?cbgEklx&(KR@sM%HZpHnZL%*eSg|+&DW0q7xMjce46vo e`uqO=jrcSF$B?vmH ${i}.coor.dump << EOF -1 -1 -1 -EOF -cp ${i}.coor.dump ${i}.ent.dump -done - -for i in `echo zzzz121b.med` -do - echo "constitution de $i : 2nd maillage" - mdump $i > ${i}.2.coor.dump << EOF -1 -1 -2 -EOF -cp ${i}.2.coor.dump ${i}.2.ent.dump -done - -mv *.dump ../Ref -cd ../Ref - -for j in `ls *.ent.dump` -do -echo "Traitement de $j : " -vi ${j} << EOF -:/INFORMATIONS GENERALES -:-2 -:1,.d -:/Nombre de familles -:.,\$d -:wq -EOF -done - -for j in `ls *.coor.dump` -do -echo "Traitement de $j : " -vi ${j} << EOF -:/NOEUDS DU MAILLAGE -:-2 -:1,.d -:/Coordonnees des noeuds -: +2 -:.,\$d -:wq -EOF -done - - diff --git a/src/MEDMEM/DataTest/testreadCoordinate.sh b/src/MEDMEM/DataTest/testreadCoordinate.sh deleted file mode 100755 index 42a065130..000000000 --- a/src/MEDMEM/DataTest/testreadCoordinate.sh +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/sh -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# File : testreadCoordinate.sh -# Module : MED -# -SALOME=${HOME}/V08 -SALOME_LIB=${SALOME}/Build/lib -SALOME_PATH=${SALOME}/Build/MED/src/MEDMEM -LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${SALOME_LIB} -RESULT=PourMail - -rm -rf ${RESULT} -echo " - Comparaison des Coordonnees : " >> ${RESULT} -echo -e " -------------------------------\n">> ${RESULT} - -npb=0; -num=1 -while [ true ] -do - ligne=`sed -n -e"$num,$num p" Maillages.txt` - num=`expr $num + 1 ` - if [ "$ligne" = "" ] - then - break - fi - if [ `echo $ligne | cut -c1 ` = "#" ] - then - echo "COMMENTAIRE" - continue - fi - fich=`echo $ligne | cut -f1 -d":"` - maill=`echo $ligne | cut -f2 -d":"` - nb=`echo $ligne | cut -f3 -d":"` - if [ "$nb" = "" ] - then - Result=Rmem/Rmem.${fich}.coor.dump - Compare=Ref/${fich}.coor.dump - else - Result=Rmem/Rmem.${fich}.${nb}.coor.dump - Compare=Ref/${fich}.${nb}.coor.dump - fi - ${SALOME_PATH}/readCoordinate Data/${fich} "${maill}" > $Result - - echo " Maillage " $maill "lu dans " $fich >> ${RESULT} - diff $Result $Compare >> /dev/null - rc=$? - if [ "$rc" != "0" ] - then - nb=`diff $Result $Compare| grep -v "Type de repere des coordonnees" | wc -l` - nb=`expr $nb + 0 ` - if [ "$nb" != "2" ] - then - echo " Difference entre les resultats des deux methodes de dumps : " >> ${RESULT} - echo " Fichiers compares : $Result et $Compare " >> ${RESULT} - diff $Result $Compare >> ${RESULT} - echo -e "\n">> ${RESULT} - npb=`expr $npb + 1 ` - else - echo " Pas de différence sur les coordonnees == test OK == " >> ${RESULT} - fi - else - echo " Pas de différence sur les coordonnees == test OK == " >> ${RESULT} - fi - echo -e "\n" >> ${RESULT} -done diff --git a/src/MEDMEM/DataTest/testreadEntete.sh b/src/MEDMEM/DataTest/testreadEntete.sh deleted file mode 100755 index 8aa82da64..000000000 --- a/src/MEDMEM/DataTest/testreadEntete.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/sh -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# File : testreadEntete.sh -# Module : MED -# -SALOME=${HOME}/V08 -SALOME_LIB=${SALOME}/Build/lib -SALOME_PATH=${SALOME}/Build/MED/src/MEDMEM -LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${SALOME_LIB} -RESULT=PourMail - -echo " - Comparaison des Entetes : " >> ${RESULT} -echo -e " ------------------------\n">> ${RESULT} - -npb=0; -num=1 -while [ true ] -do - ligne=`sed -n -e"$num,$num p" Maillages.txt` - num=`expr $num + 1 ` - if [ "$ligne" = "" ] - then - break - fi - if [ `echo $ligne | cut -c1 ` = "#" ] - then - echo "COMMENTAIRE" - continue - fi - fich=`echo $ligne | cut -f1 -d":"` - maill=`echo $ligne | cut -f2 -d":"` - nb=`echo $ligne | cut -f3 -d":"` - if [ "$nb" = "" ] - then - Result=Rmem/Rmem.${fich}.ent.dump - Compare=Ref/${fich}.ent.dump - else - Result=Rmem/Rmem.${fich}.${nb}.ent.dump - Compare=Ref/${fich}.${nb}.ent.dump - fi - ${SALOME_PATH}/readEntete Data/${fich} "${maill}" > $Result - - echo " Maillage " $maill "lu dans " $fich >> ${RESULT} - diff $Result $Compare >> /dev/null - rc=$? - if [ "$rc" != "0" ] - then - nb=`diff $Result $Compare| grep -v "Type de repere des coordonnees" | wc -l` - nb=`expr $nb + 0 ` - # if [ "$nb" != "2" ] - # then - echo " Difference entre les resultats des deux methodes de dumps : " >> ${RESULT} - echo " Fichiers compares : $Result et $Compare " >> ${RESULT} - diff $Result $Compare >> ${RESULT} - echo -e "\n">> ${RESULT} - npb=`expr $npb + 1 ` - # else - # echo " Pas de différence sur les coordonnees == test OK == " >> ${RESULT} - # fi - else - echo " Pas de différence sur les informations generales == test OK == " >> ${RESULT} - fi - echo -e "\n" >> ${RESULT} -done diff --git a/src/MEDMEM/DataTest/tous.sh b/src/MEDMEM/DataTest/tous.sh deleted file mode 100755 index c63de94ce..000000000 --- a/src/MEDMEM/DataTest/tous.sh +++ /dev/null @@ -1,55 +0,0 @@ -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# File : tous.sh -# Module : MED -# -SALOME=${HOME}/V08 -SALOME_LIB=${SALOME}/Build/lib -SALOME_PATH=${SALOME}/Build/MED/src/MEDMEM -LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${SALOME_LIB} -RESULT=cptrendu -rm -rf ${RESULT} - -echo " Tests Unitaires " >> $RESULT -echo " --------------- " >> $RESULT -echo " " >> $RESULT - -for prog in testUGeoNameMeshEntities testUCellModel testUUnit testUCoordinate -#for prog in testUCoordinate -do - - echo "Passage du test : " ${prog} - echo "" >> result_test - echo "Passage du test : " ${prog} >> result_test - echo "Passage du test : " ${prog} - ${SALOME_PATH}/${prog} >> result_test - rc=$? - if [ "$rc" = "0" ] - then - echo "Test de " $prog " == Test OK" >> $RESULT - echo " " >> $RESULT - else - echo "Test de " $prog " NOK !!!!!!" >> $RESULT - fi -done -cat $RESULT diff --git a/src/MEDMEM/Doxyfile_med_devel.in b/src/MEDMEM/Doxyfile_med_devel.in deleted file mode 100644 index 8f009c538..000000000 --- a/src/MEDMEM/Doxyfile_med_devel.in +++ /dev/null @@ -1,196 +0,0 @@ -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# Doxyfile 0.1 -#--------------------------------------------------------------------------- -# General configuration options -#--------------------------------------------------------------------------- -# -PROJECT_NAME = "Med Memory Developpers'" -PROJECT_NUMBER = @VERSION@ -OUTPUT_DIRECTORY = doc_ref_devel -OUTPUT_LANGUAGE = English -EXTRACT_ALL = YES -EXTRACT_PRIVATE = YES -EXTRACT_STATIC = NO -HIDE_UNDOC_MEMBERS = NO -HIDE_UNDOC_CLASSES = NO -BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = YES -ALWAYS_DETAILED_SEC = NO -FULL_PATH_NAMES = NO -STRIP_FROM_PATH = -INTERNAL_DOCS = NO -STRIP_CODE_COMMENTS = YES -CASE_SENSE_NAMES = YES -SHORT_NAMES = NO -HIDE_SCOPE_NAMES = NO -VERBATIM_HEADERS = YES -SHOW_INCLUDE_FILES = YES -JAVADOC_AUTOBRIEF = NO -INHERIT_DOCS = YES -INLINE_INFO = YES -SORT_MEMBER_DOCS = YES -DISTRIBUTE_GROUP_DOC = NO -TAB_SIZE = 8 -GENERATE_TODOLIST = YES -GENERATE_TESTLIST = YES -GENERATE_BUGLIST = YES -ALIASES = -ENABLED_SECTIONS = developper -MAX_INITIALIZER_LINES = 30 -OPTIMIZE_OUTPUT_FOR_C = NO -SHOW_USED_FILES = YES -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- -QUIET = NO -WARNINGS = YES -WARN_IF_UNDOCUMENTED = YES -WARN_FORMAT = -WARN_LOGFILE = -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- -INPUT = @srcdir@ -FILE_PATTERNS = MEDMEM*.hxx \ - MEDMEM*.cxx -RECURSIVE = NO -EXCLUDE = CVS -EXCLUDE_PATTERNS = MEDMEM_TypeMeshDriver.* \ - MEDMEM_Utilities.hxx -EXAMPLE_PATH = -EXAMPLE_PATTERNS = -EXAMPLE_RECURSIVE = NO -IMAGE_PATH = -INPUT_FILTER = -FILTER_SOURCE_FILES = NO -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- -SOURCE_BROWSER = NO -INLINE_SOURCES = NO -REFERENCED_BY_RELATION = YES -REFERENCES_RELATION = YES -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- -ALPHABETICAL_INDEX = YES -COLS_IN_ALPHA_INDEX = 5 -IGNORE_PREFIX = -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- -GENERATE_HTML = YES -HTML_OUTPUT = html -HTML_HEADER = -HTML_FOOTER = -HTML_STYLESHEET = -HTML_ALIGN_MEMBERS = YES -GENERATE_HTMLHELP = YES -GENERATE_CHI = YES -BINARY_TOC = NO -TOC_EXPAND = YES -DISABLE_INDEX = NO -ENUM_VALUES_PER_LINE = 4 -GENERATE_TREEVIEW = YES -TREEVIEW_WIDTH = 250 -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- -GENERATE_LATEX = YES -LATEX_OUTPUT = latex -COMPACT_LATEX = NO -PAPER_TYPE = a4wide -EXTRA_PACKAGES = -LATEX_HEADER = -PDF_HYPERLINKS = NO -USE_PDFLATEX = NO -LATEX_BATCHMODE = NO -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- -GENERATE_RTF = NO -RTF_OUTPUT = -COMPACT_RTF = NO -RTF_HYPERLINKS = NO -RTF_STYLESHEET_FILE = -RTF_EXTENSIONS_FILE = -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- -GENERATE_MAN = NO -MAN_OUTPUT = -MAN_EXTENSION = -MAN_LINKS = NO -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- -GENERATE_XML = NO -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- -ENABLE_PREPROCESSING = YES -MACRO_EXPANSION = NO -EXPAND_ONLY_PREDEF = NO -SEARCH_INCLUDES = YES -INCLUDE_PATH = -INCLUDE_FILE_PATTERNS = -PREDEFINED = -EXPAND_AS_DEFINED = -SKIP_FUNCTION_MACROS = YES -#--------------------------------------------------------------------------- -# Configuration::addtions related to external references -#--------------------------------------------------------------------------- -TAGFILES = -GENERATE_TAGFILE = -ALLEXTERNALS = NO -PERL_PATH = -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- -CLASS_DIAGRAMS = YES -HAVE_DOT = YES -CLASS_GRAPH = YES -COLLABORATION_GRAPH = YES -TEMPLATE_RELATIONS = YES -HIDE_UNDOC_RELATIONS = YES -INCLUDE_GRAPH = YES -INCLUDED_BY_GRAPH = YES -GRAPHICAL_HIERARCHY = YES -DOT_FONTNAME = Arial -DOT_PATH = -DOTFILE_DIRS = -MAX_DOT_GRAPH_WIDTH = 1024 -MAX_DOT_GRAPH_HEIGHT = 1024 -GENERATE_LEGEND = YES -DOT_CLEANUP = YES -#--------------------------------------------------------------------------- -# Configuration::addtions related to the search engine -#--------------------------------------------------------------------------- -SEARCHENGINE = NO -CGI_NAME = -CGI_URL = -DOC_URL = -DOC_ABSPATH = -BIN_ABSPATH = -EXT_DOC_PATHS = diff --git a/src/MEDMEM/Doxyfile_med_user.in b/src/MEDMEM/Doxyfile_med_user.in deleted file mode 100644 index 835533e94..000000000 --- a/src/MEDMEM/Doxyfile_med_user.in +++ /dev/null @@ -1,210 +0,0 @@ -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# Doxyfile 0.1 -#--------------------------------------------------------------------------- -# General configuration options -#--------------------------------------------------------------------------- -# -PROJECT_NAME = "Med Memory Users'" -PROJECT_NUMBER = @VERSION@ -OUTPUT_DIRECTORY = doc_ref_user -OUTPUT_LANGUAGE = English -EXTRACT_ALL = YES -EXTRACT_PRIVATE = NO -EXTRACT_STATIC = NO -HIDE_UNDOC_MEMBERS = YES -HIDE_UNDOC_CLASSES = YES -BRIEF_MEMBER_DESC = NO -REPEAT_BRIEF = YES -ALWAYS_DETAILED_SEC = NO -FULL_PATH_NAMES = NO -STRIP_FROM_PATH = -INTERNAL_DOCS = NO -STRIP_CODE_COMMENTS = YES -CASE_SENSE_NAMES = YES -SHORT_NAMES = NO -HIDE_SCOPE_NAMES = NO -VERBATIM_HEADERS = NO -SHOW_INCLUDE_FILES = NO -JAVADOC_AUTOBRIEF = NO -INHERIT_DOCS = YES -INLINE_INFO = NO -SORT_MEMBER_DOCS = NO -DISTRIBUTE_GROUP_DOC = NO -TAB_SIZE = 8 -GENERATE_TODOLIST = YES -GENERATE_TESTLIST = YES -GENERATE_BUGLIST = YES -ALIASES = -ENABLED_SECTIONS = -MAX_INITIALIZER_LINES = 30 -OPTIMIZE_OUTPUT_FOR_C = NO -SHOW_USED_FILES = NO -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- -QUIET = NO -WARNINGS = YES -WARN_IF_UNDOCUMENTED = YES -WARN_FORMAT = "$file:$line: $text" -WARN_LOGFILE = log_user -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- -INPUT = @srcdir@ -FILE_PATTERNS = MEDMEM*.hxx \ - MEDMEM*.cxx -RECURSIVE = NO -EXCLUDE = CVS -EXCLUDE_PATTERNS = MEDMEM_DriversDef.* \ - MEDMEM_DriverTools.* \ - MEDMEM_SkyLineArray.* \ - MEDMEM_TypeMeshDriver.* \ - MEDMEM_CellModel.* \ - MEDMEM_Exception.* \ - MEDMEM_GenDriver.* \ - MEDMEM_Array.hxx \ - MEDMEM_PointerOf.hxx \ - MEDMEM_STRING.hxx \ - MEDMEM_Utilities.hxx \ - MEDMEM_Connectivity.cxx \ - MEDMEM_Connectivity.hxx \ - MEDMEM_Coordinate.cxx \ - MEDMEM_Coordinate.hxx \ - MEDMEM_ModulusArray.hxx -EXAMPLE_PATH = -EXAMPLE_PATTERNS = -EXAMPLE_RECURSIVE = NO -IMAGE_PATH = -INPUT_FILTER = -FILTER_SOURCE_FILES = NO -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- -SOURCE_BROWSER = NO -INLINE_SOURCES = NO -REFERENCED_BY_RELATION = YES -REFERENCES_RELATION = YES -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- -ALPHABETICAL_INDEX = YES -COLS_IN_ALPHA_INDEX = 5 -IGNORE_PREFIX = -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- -GENERATE_HTML = YES -HTML_OUTPUT = html -HTML_HEADER = -HTML_FOOTER = -HTML_STYLESHEET = -HTML_ALIGN_MEMBERS = YES -GENERATE_HTMLHELP = YES -GENERATE_CHI = YES -BINARY_TOC = NO -TOC_EXPAND = YES -DISABLE_INDEX = NO -ENUM_VALUES_PER_LINE = 4 -GENERATE_TREEVIEW = YES -TREEVIEW_WIDTH = 250 -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- -GENERATE_LATEX = YES -LATEX_OUTPUT = latex -COMPACT_LATEX = NO -PAPER_TYPE = a4wide -EXTRA_PACKAGES = -LATEX_HEADER = -PDF_HYPERLINKS = NO -USE_PDFLATEX = NO -LATEX_BATCHMODE = NO -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- -GENERATE_RTF = NO -RTF_OUTPUT = rtf -COMPACT_RTF = NO -RTF_HYPERLINKS = NO -RTF_STYLESHEET_FILE = -RTF_EXTENSIONS_FILE = -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- -GENERATE_MAN = NO -MAN_OUTPUT = man -MAN_EXTENSION = .3 -MAN_LINKS = NO -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- -GENERATE_XML = NO -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- -ENABLE_PREPROCESSING = YES -MACRO_EXPANSION = NO -EXPAND_ONLY_PREDEF = NO -SEARCH_INCLUDES = YES -INCLUDE_PATH = -INCLUDE_FILE_PATTERNS = -PREDEFINED = -EXPAND_AS_DEFINED = -SKIP_FUNCTION_MACROS = YES -#--------------------------------------------------------------------------- -# Configuration::addtions related to external references -#--------------------------------------------------------------------------- -TAGFILES = -GENERATE_TAGFILE = -ALLEXTERNALS = NO -PERL_PATH = /usr/bin/perl -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- -CLASS_DIAGRAMS = YES -HAVE_DOT = YES -CLASS_GRAPH = YES -COLLABORATION_GRAPH = YES -TEMPLATE_RELATIONS = YES -HIDE_UNDOC_RELATIONS = YES -INCLUDE_GRAPH = YES -INCLUDED_BY_GRAPH = YES -GRAPHICAL_HIERARCHY = YES -DOT_FONTNAME = Arial -DOT_PATH = -DOTFILE_DIRS = -MAX_DOT_GRAPH_WIDTH = 1024 -MAX_DOT_GRAPH_HEIGHT = 1024 -GENERATE_LEGEND = YES -DOT_CLEANUP = YES -#--------------------------------------------------------------------------- -# Configuration::addtions related to the search engine -#--------------------------------------------------------------------------- -SEARCHENGINE = NO -CGI_NAME = search.cgi -CGI_URL = -DOC_URL = -DOC_ABSPATH = -BIN_ABSPATH = /usr/local/bin/ -EXT_DOC_PATHS = diff --git a/src/MEDMEM/MEDMEM.hxx b/src/MEDMEM/MEDMEM.hxx deleted file mode 100755 index e2a3eb964..000000000 --- a/src/MEDMEM/MEDMEM.hxx +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : MEDMEM.hxx -// Author : Alexander A. BORODIN -// Module : MED -// -#ifndef _MEDMEM_HXX_ -#define _MEDMEM_HXX_ - -#ifdef WIN32 - #if defined MEDMEM_EXPORTS || defined medmem_EXPORTS - #if defined WIN32 - #define MEDMEM_EXPORT __declspec( dllexport ) - #else - #define MEDMEM_EXPORT - #endif - #else - #if defined WIN32 - #define MEDMEM_EXPORT __declspec( dllimport ) - #else - #define MEDMEM_EXPORT - #endif - #endif -#else - #define MEDMEM_EXPORT -#endif - -#ifdef WIN32 -#pragma warning(disable:4251) // Warning DLL Interface ... -#pragma warning(disable:4290) // Warning Exception ... -#endif - -#endif diff --git a/src/MEDMEM/MEDMEM_Array.hxx b/src/MEDMEM/MEDMEM_Array.hxx deleted file mode 100644 index eed847567..000000000 --- a/src/MEDMEM/MEDMEM_Array.hxx +++ /dev/null @@ -1,801 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __MEDARRAY_H__ -#define __MEDARRAY_H__ - -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_define.hxx" -#include "MEDMEM_PointerOf.hxx" -#include "MEDMEM_Utilities.hxx" - -/*! - A template class to generate an array of any particular type (int, long, - float, double) for our purpose in the MED++ library.\n\n - - Arrays can be stored in MED_FULL_INTERLACE mode (ie : x1,y1,z1,x2,y2,z2...) or - in MED_NO_INTERLACE mode ( x1,x2,..xn, y1, y2 ..,yn,z1,...,zn).\n The alternate - representation mode is calculate ONLY when it is usefull. We assure coherency - for minor data modifications (element, line or column) if you use set methods. - But, if you get a pointer and modify the array, no automatical coherency is possible. - You can use calculateOther to force a recalculation and insure the coherency.\n - No recalculation is done, when the entire array is modified.\n - Theses arrays are "Med like" arrays; lower bound equals 1. (first element is element 1, - first coordinate is coordinate 1). \n - - Available constructors are :\n - - - default constructor (not very usefull)\n - - constructor asking for array dimensions and mode (does memory allocation for you)\n - - constructor asking for array dimensions, mode and values (doesn't do memory allocation - but copies pointers only.)\n - - a copy constructor which copies only pointers.\n - (be aware of coherency) - - a copy constructor which copies data (deepcopy).\n - - assignement operator is also available and only copies pointers (and not data).\n\n - - Attribute "pointers" aren't standard pointers but class PointerOf objects in order to simplify - memory management.\n - - A simple test program (testUArray) allows to test this class. -*/ - -namespace MEDMEM { -template class MEDARRAY -{ -private : - - /*! leading dimension of value (example : space dimension for coordinates) */ - int _ldValues; - /*! length of values (example : number of nodes for coordinates) */ - int _lengthValues; - /*! data access mode. possible values are :\n - - MED_FULL_INTERLACE (default mode) \n - - MED_NO_INTERLACE */ - MED_EN::medModeSwitch _mode; - /*! Pointer to representation in mode MED_FULL_INTERLACE */ - PointerOf _valuesFull; - /*! Pointer to representation in mode MED_NO_INTERLACE */ - PointerOf _valuesNo; - /*! Pointer to representation in mode _mode */ - PointerOf _valuesDefault; - /*! Pointer to representation in the other mode (!=_mode) */ - PointerOf _valuesOther; - -public : - - inline MEDARRAY(); - inline ~MEDARRAY(); - - MEDARRAY (const int ld_values, const int length_values, - const MED_EN::medModeSwitch mode=MED_EN::MED_FULL_INTERLACE); - MEDARRAY (T* values, const int ld_values, - const int length_values, const MED_EN::medModeSwitch mode=MED_EN::MED_FULL_INTERLACE,bool shallowCopy=false, bool ownershipOfValues=false); - MEDARRAY (MEDARRAY const &m); - MEDARRAY (MEDARRAY const &m, bool copyOther); - MEDARRAY & operator = (const MEDARRAY & m); - - MEDARRAY & shallowCopy(const MEDARRAY & m); - - inline int getLeadingValue() const; - inline int getLengthValue() const; - - const T * get (const MED_EN::medModeSwitch mode) ; - const T * getRow (const int i) ; - const T * getColumn (const int j) ; - const T getIJ (const int i, const int j) const; -// T * const get (const MED_EN::medModeSwitch mode) const; -// T * const getRow (const int i) const; -// T * const getColumn (const int j) const; -// T const getIJ (const int i, const int j) const; - - inline MED_EN::medModeSwitch getMode() const; - - void set (const MED_EN::medModeSwitch mode,const T* value); - void setI (const int i, const T* value); - void setJ (const int j, const T* value); - void setIJ (const int i, const int j, const T value); - - void calculateOther(); - bool isOtherCalculated() const {return (const T*)_valuesOther != NULL;} - void clearOtherMode(); -}; - -//-------------------------------------------------// -// // -// IMPLEMENTED CODE // -// // -//-------------------------------------------------// - - -template inline MEDARRAY::MEDARRAY(): - _ldValues(0), _lengthValues(0), _mode(MED_EN::MED_FULL_INTERLACE), - _valuesFull(), _valuesNo(), - _valuesDefault(), _valuesOther() -{ -} - -// ------------------ - -template inline MEDARRAY::~MEDARRAY() -{ -} - -// ------------------ - - /*! This constructor does allocation and does not set values : \n. - It allocates a "T" array of length_values*ld_values length.\n - You don't have to know the T values when calling this construtor - but you have to call "set" method to initialize them later. - You also can get the pointer to the memory zone (with "get" method), - and work with it.\n - The desallocation of T array is not your responsability. \n\n - Throws MEDEXCEPTION if T array length is < 1*/ - -template MEDARRAY::MEDARRAY(const int ld_values, - const int length_values, - const MED_EN::medModeSwitch mode): - - _ldValues(ld_values), - _lengthValues(length_values), - _mode(mode), - _valuesFull(), _valuesNo(), - _valuesDefault(),_valuesOther() -{ - // BEGIN_OF_MED("constructor MEDARRAY::MEDARRAY(const int, const int, const medModeSwitch)"); - - // if ld_values < 1 or length_values < 1 - // throws an exception - // Pointers are setted to NULL - - if ((ld_values<1)|(length_values<1)) - { - throw MEDEXCEPTION(LOCALIZED("MEDARRAY::MEDARRAY(const int, const int, const medModeSwitch) : dimension < 1 !")); - } - - if ( _mode == MED_EN::MED_FULL_INTERLACE) - { - _valuesFull.set(length_values*ld_values); - _valuesDefault.set((T*) _valuesFull); - } - else - { - ASSERT_MED (_mode == MED_EN::MED_NO_INTERLACE); - _valuesNo.set(length_values*ld_values); - _valuesDefault.set((T*)_valuesNo); - } - - ASSERT_MED( (T*)_valuesDefault != NULL); -// SCRUTE_MED((T*)_valuesDefault); -// SCRUTE_MED((T*)_valuesOther); -// SCRUTE_MED((T*)_valuesNo); -// SCRUTE_MED((T*)_valuesFull); - - // END_OF_MED("constructor MEDARRAY::MEDARRAY(const int, const int, const medModeSwitch ()"); -} - -// ------------------ - - /*! This constructor duplicate T*values.\n - - Throws MEDEXCEPTION if the lenght of T is < 1*/ -template MEDARRAY::MEDARRAY( T*values, - const int ld_values, - const int length_values, - const MED_EN::medModeSwitch mode, - bool shallowCopy, - bool ownershipOfValues): - _ldValues(ld_values), - _lengthValues(length_values), - _mode(mode), - _valuesFull(),_valuesNo(), - _valuesDefault(),_valuesOther() -{ - // BEGIN_OF_MED("constructor MEDARRAY::MEDARRAY(T* values, const int, const int, const medModeSwitch)"); - - // if ld_values < 1 or length_values < 1, we could not allocate - // throws an exception - - if ( (ld_values<1) | (length_values<1) ) - { - throw MEDEXCEPTION(LOCALIZED("MEDARRAY::MEDARRAY(T* values, const int, const medModeSwitch) : dimension < 1 !")); - } - if ( _mode == MED_EN::MED_FULL_INTERLACE) - { - if(shallowCopy) - { - if(ownershipOfValues) - { - _valuesFull.setShallowAndOwnership((const T*)values); - } - else - { - _valuesFull.set((const T*)values); - } - } - else - { - _valuesFull.set(_ldValues*length_values,values); - } - _valuesDefault.set((T*)_valuesFull); - } - else - { - ASSERT_MED (_mode == MED_EN::MED_NO_INTERLACE); - if(shallowCopy) - { - if(ownershipOfValues) - { - _valuesNo.setShallowAndOwnership((const T*)values); - } - else - { - _valuesNo.set((const T*)values); - } - } - else - _valuesNo.set(_ldValues*length_values,values); - _valuesDefault.set((T*)_valuesNo); - } - ASSERT_MED( (T*)_valuesDefault != NULL); -// SCRUTE_MED((T*)_valuesDefault); -// SCRUTE_MED((T*)_valuesOther); -// SCRUTE_MED((T*)_valuesNo); -// SCRUTE_MED((T*)_valuesFull); - - // END_OF_MED("constructor MEDARRAY::MEDARRAY(T* values, const int, const int, const medModeSwitch)"); -} - -// ------------------ - - /*! This constructor allocates a new medarray and does a copy of pointers\n - It DOES NOT copy the memory . The two objects will share the same data.\n - (for copying data, use constructor MEDARRAY(MEDARRAY const & m,bool copyOther). */ -template MEDARRAY::MEDARRAY(MEDARRAY const & m ): - _ldValues(m._ldValues), - _lengthValues(m._lengthValues), - _mode(m._mode), - _valuesFull((const T*)m._valuesFull), - _valuesNo((const T*)m._valuesNo), - _valuesDefault((const T*)m._valuesDefault), - _valuesOther((const T*)m._valuesOther) -{ - // BEGIN_OF_MED("constructor MEDARRAY::MEDARRAY(MEDARRAY const & m)"); - ASSERT_MED( (T*)_valuesDefault != NULL); -// SCRUTE_MED((T*)_valuesDefault); -// SCRUTE_MED((T*)_valuesOther); -// SCRUTE_MED((T*)_valuesNo); -// SCRUTE_MED((T*)_valuesFull); - // END_OF_MED("constructor MEDARRAY::MEDARRAY(MEDARRAY const & m)"); -} - - /*! This constructor allocates a new array and does a copy of values - included in the m arrays.\n - If the boolean is setted to true, both representations (in full mode - and no interlace mode) will be copied.\n - Otherwise, only _valuesDefault will be copied.\n - Desallocation of the arrays is not your reponsability.\n\n - Throws MEDEXCEPTION if _valuesOther is null and copyOther equals true*/ -template MEDARRAY::MEDARRAY(MEDARRAY const & p,bool copyOther ): - _ldValues(p._ldValues), - _lengthValues(p._lengthValues), - _mode(p._mode), - _valuesFull(), - _valuesNo(), - _valuesDefault(), - _valuesOther() -{ - // BEGIN_OF_MED("Constructeur deepCopy MEDARRAY::MEDARRAY(MEDARRAY const & m,bool copyOther"); - - // PG : Non, s'il n'y a rien, on test et on ne copie rien, c'est tout ! - -// if ( copyOther==true && ((const T*)p._valuesOther==NULL)) -// { -// throw MEDEXCEPTION("MEDARRAY MEDARRAY const &m,bool copyOther : No Other values defined and bool = true !"); -// } - - if ( _mode == MED_EN::MED_FULL_INTERLACE) - { - _valuesFull.set(p._ldValues*p._lengthValues,(const T*)p._valuesFull); - _valuesDefault.set((T*)_valuesFull); - if (copyOther) - if ((const T*)p._valuesNo != NULL) - { - _valuesNo.set(p._ldValues*p._lengthValues,(const T*)p._valuesNo); - _valuesOther.set((T*)_valuesNo); - } - } - else - { - ASSERT_MED (_mode == MED_EN::MED_NO_INTERLACE); - _valuesNo.set(p._ldValues*p._lengthValues,(const T*)p._valuesNo); - _valuesDefault.set((T*)_valuesNo); - if (copyOther) - if ((const T*)p._valuesFull != NULL) - { - _valuesFull.set(p._ldValues*p._lengthValues,(const T*)p._valuesFull); - _valuesOther.set((T*)_valuesFull); - } - } -} - -// ------------------ - -/*! This operator makes a deep copy of the arrays.\n */ - -template MEDARRAY & MEDARRAY::operator = (const MEDARRAY & m) -{ - - // BEGIN_OF_MED("Operator = MEDARRAY"); - - _ldValues=m._ldValues; - _lengthValues=m._lengthValues; - _mode=m._mode; - - // SCRUTE_MED(_mode); - - if ((const T*) m._valuesFull !=NULL) - _valuesFull.set(_ldValues*_lengthValues,(const T*) m._valuesFull); - - if ((const T*) m._valuesNo !=NULL) - _valuesNo.set(_ldValues*_lengthValues,(const T*) m._valuesNo); - - if (_mode == MED_EN::MED_FULL_INTERLACE) { - //PN : pour enlever les warning compilateur - //_valuesDefault.set((const T*) _valuesFull); - //_valuesOther.set((const T*) _valuesNo); - _valuesDefault.set((T*) _valuesFull); - _valuesOther.set((T*) _valuesNo); - } else { - ASSERT_MED (_mode == MED_EN::MED_NO_INTERLACE); - //PN : pour enlever les warning compilateur - //_valuesDefault.set((const T*) _valuesNo); - //_valuesOther.set((const T*) _valuesFull); - _valuesDefault.set((T*) _valuesNo); - _valuesOther.set((T*) _valuesFull); - } - -// SCRUTE_MED((T*)_valuesDefault); -// SCRUTE_MED((T*)_valuesOther); -// SCRUTE_MED((T*)_valuesNo); -// SCRUTE_MED((T*)_valuesFull); - - // END_OF_MED("Operator = MEDARRAY"); - return *this; -} - -/*! Idem operator= but performs only shallow copy (just copy of pointers) of arrays contains in _valuesFull and _valuesNo \n - WARNING the MEDARRAY returned HAS THE OWNERSHIP OF THE ARRAY !!!! */ - -template MEDARRAY & MEDARRAY::shallowCopy(const MEDARRAY & m) -{ - _ldValues=m._ldValues; - _lengthValues=m._lengthValues; - _mode=m._mode; - if ((const T*) m._valuesFull !=NULL) - _valuesFull.setShallowAndOwnership((const T*) m._valuesFull); - if ((const T*) m._valuesNo !=NULL) - _valuesNo.setShallowAndOwnership((const T*) m._valuesNo); - if (_mode == MED_EN::MED_FULL_INTERLACE) { - _valuesDefault.set((T*) _valuesFull); - _valuesOther.set((T*) _valuesNo); - } else { - _valuesDefault.set((T*) _valuesNo); - _valuesOther.set((T*) _valuesFull); - } - return *this; -} - -// ------------------ - - /*! returns _ldValues. (for example, space dimension for coordinates array)*/ -template inline int MEDARRAY::getLeadingValue() const -{ - return _ldValues; -} - -// ------------------ - - /*! returns _ldValues. (for example, number of nodes for coordinates array)*/ -template inline int MEDARRAY::getLengthValue() const -{ - return _lengthValues; -} - -// ------------------ - - /*! returns a pointer to _valuesDefault or _valuesOther, depending on - mode value : if mode is the same as _mode, _valuesDefault is returned. - else, if _valuesOther is calculated (if necessary) and then returned. - The pointer can be used to set values */ -template const T* MEDARRAY::get(const MED_EN::medModeSwitch mode) -{ - // BEGIN_OF_MED("MEDARRAY::get(const medModeSwitch mode)"); - if ((T*)_valuesDefault == NULL) - { - throw MEDEXCEPTION("MEDARRAY::get(mode) : No values defined !"); - } - if (mode == _mode) - { - //PN : pour enlever les warning compilateurs - //return (const T*)_valuesDefault; - return (T*) _valuesDefault; - } - else - { - if ((T*)_valuesOther == NULL) - { - calculateOther(); - } - //PN : pour enlever les warning compilateurs - //return (const T*)_valuesDefault; - return (T*) _valuesOther; - } -} - -// ------------------ - - /*! returns a pointer to ith element of the array. - (ith line in a MED_FULL_INTERLACE representation )\n - Be aware : if _mode is MED_NO_INTERLACE, the entire - array will be recalculate in MED_FULL_INTERLACE representation.\n*/ - -template const T* MEDARRAY::getRow(const int i) -{ - if ((T*)_valuesDefault == NULL) - { - throw MEDEXCEPTION("MEDARRAY::getRow(i) : No values defined !"); - } - if (i<1) - { - throw MEDEXCEPTION("MEDARRAY::getRow(i) : argument i must be >= 1"); - } - if (i>_lengthValues) - { - throw MEDEXCEPTION("MEDARRAY::getRow(i) : argument i must be <= _lengthValues"); - } - - if ((T*)_valuesFull == NULL) - { - calculateOther(); - } - ASSERT_MED((T*)_valuesFull != NULL); - - // PN pour enlever les warning compilateurs - //const T* ptr = (const T*)_valuesFull + (i-1)*_ldValues; - const T* ptr = (T*) _valuesFull + (i-1)*_ldValues; - - return ptr; -} -// ------------------ - - /*! this method is similar to getRow method.\n - It returns a pointer to jth line of the array in a MED_NO-INTERLACE representation - (for example, 2nd coordinates).\n - Be aware : if _mode is MED_FULL_INTERLACE, the entire - array will be recalculate in MED_NO_INTERLACE representation.\n*/ - -template const T* MEDARRAY::getColumn(const int j) -{ - if ((T*)_valuesDefault == NULL) - { - throw MEDEXCEPTION("MEDARRAY::getColumn(j) : No values defined !"); - } - if (j<1) - { - throw MEDEXCEPTION("MEDARRAY::getColumn(j) : argument j must be >= 1"); - } - if (j>_ldValues) - { - throw MEDEXCEPTION("MEDARRAY::getColumn(j) : argument j must be <= _ldValues"); - } - - if ((T*)_valuesNo == NULL) - { - ASSERT_MED(((T*) _valuesDefault)==((T*) _valuesFull)); - calculateOther(); - } - //PN pour enlever les warning compilateur - //const T* ptr = (const T*)_valuesNo + (j-1)*_lengthValues; - const T* ptr = ( T*)_valuesNo + (j-1)*_lengthValues; - - return ptr; -} - -// ------------------ - - /*! returns Jth value of Ith element .\n - don't forget first element is element 1 (and not element 0). */ -template const T MEDARRAY::getIJ(const int i,const int j) const -{ - - if (i<1) - { - throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : argument i must be >= 1"); - } - if (i>_lengthValues) - { - throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : argument i must be <= _lengthValues"); - } - if (j<1) - { - throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : argument j must be >= 1"); - } - if (j>_ldValues) - { - throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : argument j must be <= _ldValues"); - } - - if ( (const T*)_valuesDefault == NULL) - { - throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : No value in array !"); - } - - if (_mode == MED_EN::MED_FULL_INTERLACE) - { - return _valuesDefault[(i-1)*_ldValues+j-1]; - } - else - { - return _valuesDefault[(j-1)*_lengthValues+i-1]; - } - -} - -// ------------------ - - /*! returns the default mode (_mode)\n - (internal use : needed by write method) */ -template inline MED_EN::medModeSwitch MEDARRAY::getMode() const -{ - return _mode; -} - -// ------------------ - - /*! sets T pointer of _valuesDefault (cf class PointerOf) on value.\n - no copy of value is done. \n - the other representation mode is not recalculate. - the corresponding pointers are setted to null */ -// template void MEDARRAY::set(const medModeSwitch mode, const T* value) -// { - -// BEGIN_OF_MED("MEDARRAY::set(mode,value)"); - -// _mode = mode; -// if ( _mode == MED_FULL_INTERLACE) -// { -// _valuesFull.set(value); -// _valuesDefault.set((T*)_valuesFull); -// _valuesNo.set(0); -// } -// else -// { -// ASSERT_MED (_mode == MED_NO_INTERLACE); -// _valuesNo.set(value); -// _valuesDefault.set((T*)_valuesNo); -// _valuesFull.set(0); -// } -// _valuesOther.set(0); -// END_OF_MED("MEDARRAY::set(mode,i,value)"); -// } - -// set with duplication because we don't know were value come and -// MEDARRAY must have properties on it !!!! -template void MEDARRAY::set(const MED_EN::medModeSwitch mode, const T* value) -{ - // BEGIN_OF_MED("MEDARRAY::set(mode,value)"); - - _mode = mode; - if ( _mode == MED_EN::MED_FULL_INTERLACE) - { - _valuesFull.set(_ldValues*_lengthValues,value); - _valuesDefault.set((T*)_valuesFull); - _valuesNo.set(0); - } - else - { - ASSERT_MED (_mode == MED_EN::MED_NO_INTERLACE); - _valuesNo.set(_ldValues*_lengthValues,value); - _valuesDefault.set((T*)_valuesNo); - _valuesFull.set(0); - } - _valuesOther.set(0); - - // END_OF_MED("MEDARRAY::set(mode,i,value)"); -} - -/*! This function clears the other mode of representation if it exists - * It is usefull for people who needs for optimisation reasons to work directly - * on the inside array without using set-functions - */ -template void MEDARRAY::clearOtherMode() -{ - if(isOtherCalculated()) - { - if ( _mode == MED_EN::MED_FULL_INTERLACE) - _valuesNo.set(0); - else - _valuesFull.set(0); - _valuesOther.set(0); - } -} - - -// ------------------ - - /*! Sets ith element to T* values\n - if they both exist, both _valuesFull and _valuesNo arrays will be updated.\n - Throws exception if i < 1 or i > _lengthValues */ -template void MEDARRAY::setI(const int i, const T* value) -{ - // BEGIN_OF_MED("MEDARRAY::setI(i,value)"); - - if ((T*)_valuesDefault == NULL) - { - throw MEDEXCEPTION("MEDARRAY::setI(i,value) : No values defined !"); - } - if (i<=0) - { - throw MEDEXCEPTION("MEDARRAY::setI(i,value) : argument i must be > 0"); - } - if ( i > _lengthValues) - { - throw MEDEXCEPTION("MEDARRAY::setI(i,value) : argument i must be <= _lenghtValues"); - } - - if ((T*)_valuesFull != NULL) - { - for (int k = 0;k<_ldValues;k++) - { - _valuesFull[k+_ldValues*(i-1)] = value[k]; - } - } - - if ((T*)_valuesNo != NULL) - { - for (int k = 0;k<_ldValues;k++) - { - _valuesNo[k*_lengthValues +(i-1)] = value[k]; - } - } - - // END_OF_MED("MEDARRAY::setI(i,value)"); -} -// ------------------ - - /*! Sets ith element to T* values\n - if they both exist, both _valuesFull and _valuesNo arrays will be updated.\n - Throws exception if i < 1 or i > _lengthValues */ -template void MEDARRAY::setJ(const int j, const T* value) -{ - // BEGIN_OF_MED("MEDARRAY::setJ(j,value)"); - if (( T*)_valuesDefault == NULL) - { - throw MEDEXCEPTION("MEDARRAY::setJ(j) : No values defined !"); - } - if (j<1) - { - throw MEDEXCEPTION("MEDARRAY::setJ(j) : argument j must be >= 1"); - } - if (j>_ldValues) - { - throw MEDEXCEPTION("MEDARRAY::setJ(j) : argument j must be <= _ldValues"); - } - if ((T*)_valuesFull != NULL) - { - for (int k = 0;k<_lengthValues;k++) - { - _valuesFull[k*_ldValues+(j-1)] = value[k]; - } - } - - if ((T*)_valuesNo != NULL) - { - for (int k = 0;k<_lengthValues;k++) - { - _valuesNo[k+_lengthValues*(j-1)] = value[k]; - } - } - // END_OF_MED("MEDARRAY::setJ(j,value)"); -} - -// ------------------ - - /*! Sets value of Jth coordinate of Ith element to T value.\n - Maintains coherency.\n - Throws exception if we don't have - 1<=i<=_lengthValues and 1<=j<=_ldValues */ -template void MEDARRAY::setIJ(const int i, const int j, const T value) -{ - // 1<=i<=_lengthValues and 1<=j<=_ldValues - - if (i<1) - throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : argument i must be >= 1"); - if (i>_lengthValues) - throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : argument i must be <= _lengthValues"); - - if (j<1) - throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : argument j must be >= 1"); - if (j>_ldValues) - throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : argument j must be <= _ldValues"); - - if ((T*)_valuesDefault == NULL) - { - throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : No value in array !"); - } - - if ((T*)_valuesFull != NULL) - { - _valuesFull[j-1+_ldValues*(i-1)] = value; - } - if ((T*)_valuesNo != NULL) - { - _valuesNo[(j-1)*_lengthValues+i-1] = value; - } -} - - /*! Calculates the other mode of representation : MED_FULL_INTERLACE - if __mode = MED_NO_INTERLACE and vice versa.\n - Throws exception if no value are setted */ -template void MEDARRAY::calculateOther() -{ - // BEGIN_OF_MED("MEDARRAY::calculateOther()"); - if ((T*)_valuesDefault == NULL) - { - throw MEDEXCEPTION("MEDARRAY::calculateOther() : No values defined !"); - } - - if ((T*)_valuesOther == NULL) - { - _valuesOther.set(_ldValues*_lengthValues); - } - if (_mode == MED_EN::MED_NO_INTERLACE) - { - _valuesFull.set((T*)_valuesOther); - } - else - { - ASSERT_MED( _mode==MED_EN::MED_FULL_INTERLACE); - _valuesNo.set((T*)_valuesOther); - } - - for (int i=0; i<_lengthValues;i++) - { - for (int j=0; j<_ldValues; j++) - { - if (_mode == MED_EN::MED_NO_INTERLACE) - { - _valuesFull[i*_ldValues+j] = _valuesNo[j*_lengthValues+i]; - } - else - { - _valuesNo[j*_lengthValues+i]=_valuesFull[i*_ldValues+j]; - } - } - } - // END_OF_MED("MEDARRAY::calculateOther()"); -} - -} //End of namespace MEDMEM - -# endif /* # ifndef __MEDARRAY_H__ */ diff --git a/src/MEDMEM/MEDMEM_ArrayConvert.hxx b/src/MEDMEM/MEDMEM_ArrayConvert.hxx deleted file mode 100644 index 6ae394e17..000000000 --- a/src/MEDMEM/MEDMEM_ArrayConvert.hxx +++ /dev/null @@ -1,315 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef MEDMEM_ARRAY_CONVERT_HXX -#define MEDMEM_ARRAY_CONVERT_HXX - -namespace MEDMEM { - -template -MEDMEM_Array * -ArrayConvert( - const MEDMEM_Array< T, NoInterlaceGaussPolicy, CHECKING_POLICY > &array, T* values=0 - ) -{ - MEDMEM_Array * myArray; - if(values) - myArray = new MEDMEM_Array - (values, - array.getDim(), - array.getNbElem(), - array.getNbGeoType(), - array.getNbElemGeoC(), - array.getNbGaussGeo(), - true,false - ); - else - myArray= new MEDMEM_Array - (array.getDim(), - array.getNbElem(), - array.getNbGeoType(), - array.getNbElemGeoC(), - array.getNbGaussGeo() - ); - for (int i=1; i <= array.getNbElem() ; i++ ) - for (int k=1; k<= array.getNbGauss(i); k++ ) - for (int j=1; j<= array.getDim(); j++ ) - myArray->setIJK(i,j,k,array.getIJK(i,j,k)); - - return myArray; - -} - -template -MEDMEM_Array * -ArrayConvert( - const MEDMEM_Array< T, FullInterlaceGaussPolicy, CHECKING_POLICY > &array, T* values=0 - ) -{ - MEDMEM_Array * myArray; - if(values) - myArray = new MEDMEM_Array ( - values, - array.getDim(), - array.getNbElem(), - array.getNbGeoType(), - array.getNbElemGeoC(), - array.getNbGaussGeo(), - true,false - ); - else - myArray = new MEDMEM_Array ( - array.getDim(), - array.getNbElem(), - array.getNbGeoType(), - array.getNbElemGeoC(), - array.getNbGaussGeo() - ); - for (int i=1; i <= array.getNbElem() ; i++ ) - for (int k=1; k<= array.getNbGauss(i); k++ ) - for (int j=1; j<= array.getDim(); j++ ) - myArray->setIJK(i,j,k,array.getIJK(i,j,k)); - - return myArray; - -} - -template -MEDMEM_Array * -ArrayConvert( - const MEDMEM_Array< T, NoInterlaceByTypeGaussPolicy, CHECKING_POLICY > &array, T* values=0 - ) -{ - MEDMEM_Array * myArray; - if(values) - myArray = new MEDMEM_Array ( - values, - array.getDim(), - array.getNbElem(), - array.getNbGeoType(), - array.getNbElemGeoC(), - array.getNbGaussGeo(), - true,false - ); - else - myArray = new MEDMEM_Array ( - array.getDim(), - array.getNbElem(), - array.getNbGeoType(), - array.getNbElemGeoC(), - array.getNbGaussGeo() - ); - for (int i=1; i <= array.getNbElem() ; i++ ) - for (int k=1; k<= array.getNbGauss(i); k++ ) - for (int j=1; j<= array.getDim(); j++ ) - myArray->setIJK(i,j,k,array.getIJK(i,j,k)); - - return myArray; - -} - -template -MEDMEM_Array * -ArrayConvert2No( - const MEDMEM_Array< T, NoInterlaceByTypeGaussPolicy, CHECKING_POLICY > &array, T* values=0 - ) -{ - MEDMEM_Array * myArray; - if(values) - myArray = new MEDMEM_Array ( - values, - array.getDim(), - array.getNbElem(), - array.getNbGeoType(), - array.getNbElemGeoC(), - array.getNbGaussGeo(), - true,false - ); - else - myArray = new MEDMEM_Array ( - array.getDim(), - array.getNbElem(), - array.getNbGeoType(), - array.getNbElemGeoC(), - array.getNbGaussGeo() - ); - for (int i=1; i <= array.getNbElem() ; i++ ) - for (int k=1; k<= array.getNbGauss(i); k++ ) - for (int j=1; j<= array.getDim(); j++ ) - myArray->setIJK(i,j,k,array.getIJK(i,j,k)); - - return myArray; - -} - -template -MEDMEM_Array * -ArrayConvert( - const MEDMEM_Array< T, FullInterlaceNoGaussPolicy, CHECKING_POLICY > &array, T* values=0 - ) -{ - MEDMEM_Array * myArray; - if(values) - myArray=new MEDMEM_Array ( values, - array.getDim(), - array.getNbElem(), - true,false - ); - else - myArray = new MEDMEM_Array ( - array.getDim(), - array.getNbElem() - ); - for (int i=1; i <= array.getNbElem() ; i++ ) - for (int j=1; j<= array.getDim(); j++ ) - myArray->setIJ(i,j,array.getIJ(i,j)); - - return myArray; - -} - -template -MEDMEM_Array * -ArrayConvert( - const MEDMEM_Array< T, NoInterlaceByTypeNoGaussPolicy, CHECKING_POLICY > &array, T* values=0 - ) -{ - MEDMEM_Array * myArray; - if(values) - myArray=new MEDMEM_Array ( values, - array.getDim(), - array.getNbElem(), - true,false - ); - else - myArray = new MEDMEM_Array ( - array.getDim(), - array.getNbElem() - ); - for (int i=1; i <= array.getNbElem() ; i++ ) - for (int j=1; j<= array.getDim(); j++ ) - myArray->setIJ(i,j,array.getIJ(i,j)); - - return myArray; - -} - -template -MEDMEM_Array * -ArrayConvert2No( - const MEDMEM_Array< T, NoInterlaceByTypeNoGaussPolicy, CHECKING_POLICY > &array, T* values=0 - ) -{ - MEDMEM_Array * myArray; - if(values) - myArray=new MEDMEM_Array ( values, - array.getDim(), - array.getNbElem(), - true,false - ); - else - myArray = new MEDMEM_Array ( - array.getDim(), - array.getNbElem() - ); - for (int i=1; i <= array.getNbElem() ; i++ ) - for (int j=1; j<= array.getDim(); j++ ) - myArray->setIJ(i,j,array.getIJ(i,j)); - - return myArray; - -} - -template -MEDMEM_Array * -ArrayConvert( - const MEDMEM_Array< T, NoInterlaceNoGaussPolicy, CHECKING_POLICY > &array, T* values=0 - ) -{ - MEDMEM_Array * myArray; - if(values) - myArray= new MEDMEM_Array (values, - array.getDim(), - array.getNbElem(), - true,false - ); - else - myArray= new MEDMEM_Array ( - array.getDim(), - array.getNbElem() - ); - for (int i=1; i <= array.getNbElem() ; i++ ) - for (int j=1; j<= array.getDim(); j++ ) - myArray->setIJ(i,j,array.getIJ(i,j)); - - return myArray; - -} - - - -// template -// void ArrayConvert( -// const MEDMEM_Array< T, INTERLACING_POLICY, CHECKING_POLICY > & arrayin, -// MEDMEM_Array< T, INTERLACING_POLICY_OTHER, CHECKING_POLICY> * & arrayout -// ) -// { - -// MEDMEM_Array * myArray; -// myArray= new MEDMEM_Array< T, INTERLACING_POLICY_OTHER, CHECKING_POLICY > ( -// arrayin.getDim(), -// arrayin.getNbElem(), -// arrayin.getNbGeoType(), -// arrayin.getNbElemGeoC(), -// arrayin.getNbGaussGeo() -// ); - -// for (int i=1; i <= arrayin.getNbElem() ; i++ ) -// for (int k=1; k<= arrayin.getNbGauss(i); k++ ) -// for (int j=1; j<= arrayin.getDim(); j++ ) -// myArray->setIJK(i,j,k,arrayin.getIJK(i,j,k)); - -// arrayout=myArray; - -// }; - - - - - -// template -// typename MEDMEM_ArrayInterface::Array & -// convertBis(const typename MEDMEM_ArrayInterface< -// ARRAY_ELEMENT_TYPE, -// NoInterlace, -// GAUSS_TAG, -// CHECKING_POLICY>::Array & array ) { -// std::cout << "-------- Convert 3" << std::endl; -// }; - -} //END NAMESPACE -#endif diff --git a/src/MEDMEM/MEDMEM_ArrayInterface.hxx b/src/MEDMEM/MEDMEM_ArrayInterface.hxx deleted file mode 100644 index 9700f4c7a..000000000 --- a/src/MEDMEM/MEDMEM_ArrayInterface.hxx +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef MEDMEM_ARRAYINTERFACE_HXX -#define MEDMEM_ARRAYINTERFACE_HXX - -#include "MEDMEM_nArray.hxx" -#include "MEDMEM_InterlacingTraits.hxx" - -// L'astuce d'une classe d'interface consiste en -// 1) La déclaration d'un type qui est celui de la classe d'implémentation -// 2) D'utiliser ce nouveau nom de type comme paramètres de toutes -// les méthodes de l'interface. -// L'inconvenient est qu'il faut justement passer en argument une instance de -// le classe d'implémentation dans toutes les méthodes et que la classe -// appelante aura aussi à faire ce travail. -// Ne surtout pas oublier inline sinon l'interface couterait cher à l'appel -// des méthodes ! -namespace MEDMEM { - -template < class ARRAY_ELEMENT_TYPE, - class INTERLACE_TAG, - class GAUSS_TAG, - class CHECKING_POLICY=IndexCheckPolicy> - //NoIndexCheckPolicy> -class MEDMEM_EXPORT MEDMEM_ArrayInterface { - -public: - - // Les type ElementType et Array sont a définir aussi dans les classes utilisatrice - // par une déclaration du type : typedef typename ArrayInterface::Array Array; - - typedef ARRAY_ELEMENT_TYPE ElementType; - typedef INTERLACE_TAG Interlacing; - typedef GAUSS_TAG GaussPresence; - typedef typename MEDMEM_InterlacingTraits::Type InterlacingPolicy; - typedef CHECKING_POLICY CheckingPolicy; - typedef MEDMEM_Array Array; - - static inline int getNbGauss(int i, const Array & array) { - return array.getNbGauss(i); - }; - - static inline ElementType * getPtr( Array & array) { - return array.getPtr(); - }; - - static inline void setPtr( ElementType * arrayptr, Array & array, - bool shallowCopy=false, - bool ownershipOfValues=false ) { - array.setPtr(arrayptr,shallowCopy,ownershipOfValues); - }; - - static inline const ElementType * getRow(int i, const Array & array ) { - return array.getRow(i); - } - - static inline void setRow(int i, const ElementType & value, const Array & array ) { - return array.setRow(i,value); - } - - static inline const ElementType * getColumn(int j, const Array & array ) { - return array.getColumn(j); - } - - static inline void setColumn(int j, const ElementType & value, const Array & array ) { - return array.setColumn(j,value); - } - - static inline const ElementType & getIJ(int i, int j, const Array & array) { - return array.getIJ(i,j); - } - - static inline const ElementType & getIJK(int i, int j, int k, const Array & array) { - return array.getIJK(i,j,k); - } - - static inline void setIJ(int i, int j, const ElementType & value, Array & array) { - array.setIJ(i,j,value); - } - - static inline void setIJK(int i, int j, int k, const ElementType & value, Array & array) { - array.setIJK(i,j,k,value); - } - -}; - -} //END NAMESPACE -#endif diff --git a/src/MEDMEM/MEDMEM_AsciiFieldDriver.hxx b/src/MEDMEM/MEDMEM_AsciiFieldDriver.hxx deleted file mode 100644 index fb6c3ea8a..000000000 --- a/src/MEDMEM/MEDMEM_AsciiFieldDriver.hxx +++ /dev/null @@ -1,499 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef ASCII_FIELD_DRIVER_HXX -#define ASCII_FIELD_DRIVER_HXX - -#include "MEDMEM.hxx" -#include "MEDMEM_GenDriver.hxx" -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_Unit.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_ArrayInterface.hxx" -#include "MEDMEM_ArrayConvert.hxx" - -#include -#include -#include -#include -#include -#include -#include - -namespace MEDMEM { - - const int PRECISION_IN_ASCII_FILE = 10; - const double PRECISION_IN_COMPARE = 1e-10; - const int SPACE_BETWEEN_NBS = 19; - - template - void fill(double *a, const double *b) - { - a[N]=b[CODE & 0x3 ]; - fill>2) >(a,b); - } - - template - bool compare(const double* a, const double* b) - { - double sign=b[N]<0 ? -1 : 1; - if(a[N]b[N]*(1+sign*PRECISION_IN_COMPARE)) - return false; - return compare(a,b); - } - - template<> MEDMEM_EXPORT - void fill<-1,0x3>(double *a, const double *b); - - template<> MEDMEM_EXPORT - bool compare<-1>(const double *a, const double *b); - - template - class SDForSorting - { - private: - double _coords[SPACEDIMENSION]; - T *_components; - int _nbComponents; - public: - SDForSorting(const double *coords, const T* comp, int nbComponents); - SDForSorting(const SDForSorting& other); - ~SDForSorting(); - bool operator< (const SDForSorting& other) const; - void writeLine(ofstream& file) const; - }; - - template - class ASCII_FIELD_DRIVER : public GENDRIVER - { - private: - MESH *_mesh; - SUPPORT *_support; - mutable FIELD *_ptrField; - std::string _fileName; - mutable ofstream _file; - unsigned int _code; - MED_EN::med_sort_direc _direc; - int _nbComponents; - int _spaceDimension; - //static int _nbComponentsForCpyInfo; - - public: - template - ASCII_FIELD_DRIVER():GENDRIVER(ASCII_DRIVER), - _ptrField((FIELD)MED_NULL), - _fileName("") {} - - template - ASCII_FIELD_DRIVER(const string & fileName, FIELD * ptrField, - MED_EN::med_sort_direc direction=MED_EN::ASCENDING, - const char *priority=""); - - - ASCII_FIELD_DRIVER(const ASCII_FIELD_DRIVER& other); - void open() throw (MEDEXCEPTION); - void close(); - void read ( void ) throw (MEDEXCEPTION); - void write( void ) const throw (MEDEXCEPTION); - GENDRIVER* copy() const; - private: - void buildIntroduction() const; - template - void sortAndWrite() const; - //template//, std::list< SDForSorting > > - //static void copyInfo(const double *a,T *b); - //static void copyInfo2(const double *,T *); - }; -} - - -namespace MEDMEM { - - template - SDForSorting::SDForSorting(const double *coords, const T* comp, int nbComponents):_nbComponents(nbComponents) - { - fill(_coords,coords); - _components=new T[_nbComponents]; - memcpy(_components,comp,sizeof(T)*_nbComponents); - } - - template - SDForSorting::SDForSorting(const SDForSorting& other):_nbComponents(other._nbComponents) - { - memcpy(_coords,other._coords,sizeof(double)*SPACEDIMENSION); - _components=new T[_nbComponents]; - memcpy(_components,other._components,sizeof(T)*_nbComponents); - } - - template - SDForSorting::~SDForSorting() - { - delete [] _components; - } - - template - bool SDForSorting::operator< (const SDForSorting& other) const - { - return compare(_coords,other._coords); - } - - template - void SDForSorting::writeLine(ofstream& file) const - { - int i; - double temp[SPACEDIMENSION]; - fill(temp,_coords); - for(i=0;i - template - ASCII_FIELD_DRIVER::ASCII_FIELD_DRIVER(const string & fileName, - FIELD * ptrField, - MED_EN::med_sort_direc direction, - const char *priority) - :GENDRIVER(fileName, MED_EN::WRONLY, ASCII_DRIVER), - _ptrField((FIELD*)ptrField), - _fileName(fileName), - _direc(direction) - { - _nbComponents=_ptrField->getNumberOfComponents(); - if(_nbComponents<=0) - throw MEDEXCEPTION("ASCII_FIELD_DRIVER : No components in FIELD"); - _support=(SUPPORT *)_ptrField->getSupport(); - _mesh=(MESH *)_support->getMesh(); - _spaceDimension=_mesh->getSpaceDimension(); - _code=3; - int i; - if(priority[0]=='\0') - for(i=_spaceDimension-1;i>=0;i--) - { - _code<<=2; - _code+=i; - } - else - { - if(_spaceDimension != (int)strlen(priority)) - throw MEDEXCEPTION("ASCII_FIELD_DRIVER : Coordinate priority invalid with spaceDim"); - for(i=_spaceDimension-1;i>=0;i--) - { - char c=toupper(priority[i]); - if(int(c-'X')>(_spaceDimension-1) || int(c-'X')<0) - throw MEDEXCEPTION("ASCII_FIELD_DRIVER : Invalid priority definition"); - _code<<=2; - _code+=c-'X'; - } - } - } - - - template - ASCII_FIELD_DRIVER::ASCII_FIELD_DRIVER(const ASCII_FIELD_DRIVER& other): - GENDRIVER(ASCII_DRIVER), - _mesh(other._mesh), - _support(other._support), - _ptrField(other._ptrField), - _fileName(other._fileName), - _code(other._code), - _direc(other._direc), - _nbComponents(other._nbComponents), - _spaceDimension(other._spaceDimension) - { - } - - template - void ASCII_FIELD_DRIVER::open() throw (MEDEXCEPTION) - { - if (_file.is_open()) - throw MEDEXCEPTION("ASCII_FIELD_DRIVER::open() : file is already open !"); - _file.open(_fileName.c_str(),ofstream::out | ofstream::app); - // for MEDMEMTest_AsciiFieldDriver.cxx:208 : - // must throw because the file is opened - //CPPUNIT_ASSERT_MED_THROW(aDriver1->setFileName("anyfile2"), MEDEXCEPTION); - _status = _file.is_open() ? MED_OPENED : MED_INVALID; - } - - template - void ASCII_FIELD_DRIVER::close() - { - _file.close(); - _status = MED_CLOSED; - } - - template - void ASCII_FIELD_DRIVER::read ( void ) throw (MEDEXCEPTION) - { - throw MEDEXCEPTION("ASCII_FIELD_DRIVER::read : Can't read with a WRONLY driver !"); - } - - template - GENDRIVER* ASCII_FIELD_DRIVER::copy() const - { - return new ASCII_FIELD_DRIVER(*this); - } - - template - void ASCII_FIELD_DRIVER::write( void ) const throw (MEDEXCEPTION) - { - if (!_file.is_open()) - throw MEDEXCEPTION("ASCII_FIELD_DRIVER::write : can't write a file that was not opened !"); - - buildIntroduction(); - switch(_spaceDimension) - { - case 2: - { - switch(_code) - { - case 52: //XY - { - sortAndWrite<2,52>(); - break; - } - case 49: //YX - { - sortAndWrite<2,49>(); - break; - } - default: - MEDEXCEPTION("ASCII_FIELD_DRIVER : Invalid priority definition"); - } - break; - } - case 3: - { - switch(_code) - { - case 228: //XYZ - { - sortAndWrite<3,228>(); - break; - } - case 216: //XZY - { - sortAndWrite<3,216>(); - break; - } - case 225://YXZ - { - sortAndWrite<3,225>(); - break; - } - case 201://YZX - { - sortAndWrite<3,201>(); - break; - } - case 210://ZXY - { - sortAndWrite<3,210>(); - break; - } - case 198://ZYX - { - sortAndWrite<3,198>(); - break; - } - default: - MEDEXCEPTION("ASCII_FIELD_DRIVER : Invalid priority definition"); - } - break; - } - default: - MEDEXCEPTION("ASCII_FIELD_DRIVER : Invalid space dimension must be 2 or 3"); - } - } - - template - void ASCII_FIELD_DRIVER::buildIntroduction() const - { - - int i; - _file << setiosflags(ios::scientific); - _file << "#TITLE: table " << _ptrField->getName() << " TIME: " << _ptrField->getTime() << " IT: " << _ptrField->getIterationNumber() << endl; - _file << "#COLUMN_TITLES: "; - for(i=0;i<_spaceDimension;i++) - _file << char('X'+i) << " | "; - const std::string *compoNames=_ptrField->getComponentsNames(); - for(i=0;i<_nbComponents;i++) - { - if(!compoNames) - _file << compoNames[i]; - else - _file << "None"; - if(i<_nbComponents-1) - _file << " | "; - } - _file << endl; - _file << "#COLUMN_UNITS: "; - compoNames=_mesh->getCoordinateptr()->getCoordinatesUnits(); - for(i=0;i<_spaceDimension;i++) - { - if(!compoNames) - _file << compoNames[i]; - else - _file << "None"; - _file << " | "; - } - const UNIT *compoUnits=_ptrField->getComponentsUnits(); - for(i=0;i<_nbComponents;i++) - { - if(!compoUnits) - _file << compoUnits[i].getName(); - else - _file << "None"; - if(i<_nbComponents-1) - _file << " | "; - } - _file << endl; - } -} - -#include "MEDMEM_Field.hxx" - -namespace MEDMEM -{ - template - template - void ASCII_FIELD_DRIVER::sortAndWrite() const - { - typedef typename MEDMEM_ArrayInterface::Array ArrayDoubleNo; - typedef typename MEDMEM_ArrayInterface::Array ArrayDoubleFull; - typedef typename MEDMEM_ArrayInterface::Array ArrayNo; - typedef typename MEDMEM_ArrayInterface::Array ArrayNoByType; - typedef typename MEDMEM_ArrayInterface::Array ArrayFull; - - int i,j; - int numberOfValues=_ptrField->getNumberOfValues(); - std::list< SDForSorting > li; - const double * coord; - FIELD * barycenterField=0; - ArrayDoubleNo * baryArrayTmp = NULL; - double * xyz[SPACEDIMENSION]; - bool deallocateXyz=false; - - if(_support->getEntity()==MED_EN::MED_NODE) { - if (_support->isOnAllElements()) { - - coord=_mesh->getCoordinates(MED_EN::MED_NO_INTERLACE); - for(i=0; igetCoordinates(MED_EN::MED_FULL_INTERLACE); - const int * nodesNumber=_support->getNumber(MED_EN::MED_ALL_ELEMENTS); - for(i=0; igetBarycenter(_support); - baryArrayTmp = ArrayConvert - ( *( static_cast(barycenterField->getArray()) ) ); - coord = baryArrayTmp->getPtr(); - for(i=0; igetInterlacingType() == MED_EN::MED_FULL_INTERLACE ) - valsToSet= _ptrField->getValue(); - else if ( _ptrField->getInterlacingType() == MED_EN::MED_NO_INTERLACE_BY_TYPE ) { - tmpArray = ArrayConvert - ( *( static_cast(_ptrField->getArray()) ) ); - valsToSet= tmpArray->getPtr(); - } - else { - tmpArray = ArrayConvert - ( *( static_cast(_ptrField->getArray()) ) ); - valsToSet= tmpArray->getPtr(); - } - double temp[SPACEDIMENSION]; - for(i=0;i(temp,valsToSet+i*_nbComponents,_nbComponents)); - } - - if (barycenterField) barycenterField->removeReference(); - if (baryArrayTmp) delete baryArrayTmp; - if (tmpArray) delete tmpArray; - - if(deallocateXyz) - for(j=0;j >::iterator iter; - for(iter=li.begin();iter!=li.end();iter++) - (*iter).writeLine(_file); - _file << endl; - } else if (_direc==MED_EN::DESCENDING) { - - typename std::list< SDForSorting >::reverse_iterator iter; - for(iter=li.rbegin();iter!=li.rend();iter++) - (*iter).writeLine(_file); - _file << endl; - } else - MEDEXCEPTION("ASCII_FIELD_DRIVER : Invalid sort direction"); - } - - //{ - //_nbComponentsForCpyInfo=_nbComponents; - //_ptrField->fillFromAnalytic ::copyInfo3> (); - //_ptrField->fillFromAnalytic< ASCII_FIELD_DRIVER::copyInfo > (); - //li.sort(); - //typename std::list< SDForSorting >::iterator iter; - //_file << setiosflags(ios::scientific) << setprecision(PRECISION_IN_ASCII_FILE); - //for(iter=li.begin();iter!=li.end();iter++) - // { - //(*iter).writeLine(_file); - // } - -// template -// template//, std::list< SDForSorting > lis> -// void ASCII_FIELD_DRIVER::copyInfo(const double *a,T *b) -// { -// //lis.push_back(SDForSorting(a,b,_nbComponentsForCpyInfo)); -// } - -// template -// int ASCII_FIELD_DRIVER::_nbComponentsForCpyInfo=0; -} - -#endif diff --git a/src/MEDMEM/MEDMEM_CellModel.cxx b/src/MEDMEM/MEDMEM_CellModel.cxx deleted file mode 100644 index 4039adb6d..000000000 --- a/src/MEDMEM/MEDMEM_CellModel.cxx +++ /dev/null @@ -1,1546 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -/* - File MEDMEM_CellModel.cxx -*/ - -#include "MEDMEM_CellModel.hxx" - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -CELLMODEL_Map *CELLMODEL_Map::_singleton=0; - -const MEDMEM::CELLMODEL& CELLMODEL_Map::getCellModel(MED_EN::medGeometryElement type) -{ - map::iterator type2model = _cell_models.find(type); - if ( type2model == _cell_models.end() ) - type2model = _cell_models.insert( make_pair( type, CELLMODEL( type ))).first; - - return type2model->second; -} - -const MEDMEM::CELLMODEL& CELLMODEL_Map::retrieveCellModel(MED_EN::medGeometryElement type) -{ - return CELLMODEL_Map::getInstance()->getCellModel(type); -} - -CELLMODEL_Map *CELLMODEL_Map::getInstance() -{ - if(!_singleton) _singleton=new CELLMODEL_Map; - return _singleton; -} - -CELLMODEL::CELLMODEL(medGeometryElement t) -{ - // init first all to nothing - _dimension=0 ; - _numberOfNodes=0 ; - _numberOfVertexes=0 ; - _numberOfConstituentsDimension=0 ; - _numberOfConstituents=(int*)NULL ; - _numberOfNodeOfEachConstituent=(int**)NULL ; - _constituents=(int***)NULL ; - _constituentsType=(medGeometryElement**)NULL ; - - MESSAGE_MED("CELLMODEL : constructeur pour le type " << t); - switch (t) - { - case MED_POINT1 : { - _name="MED_POINT1"; - _type=t; - _dimension=0; - _numberOfVertexes=1; - _numberOfNodes=1; - // nothing else : POINT are none constituent - break; - } - case MED_SEG2 : { - _name="MED_SEG2" ; - _type=t; - _dimension=1; - _numberOfVertexes=2; - _numberOfNodes=2; - // constituent are POINT1 and we have no need to define _constituents vector - _numberOfConstituentsDimension=1 ; - _numberOfConstituents=new int[1] ; - _numberOfConstituents[0]=2 ; - _numberOfNodeOfEachConstituent=new int*[1] ; - _numberOfNodeOfEachConstituent[0]=new int[2] ; - _numberOfNodeOfEachConstituent[0][0]=1 ; - _numberOfNodeOfEachConstituent[0][1]=1 ; - - _constituents = new int**[1] ; - _constituents[0] = new int*[2] ; - _constituents[0][0] = new int[1] ; - _constituents[0][0][0] = 1 ; - _constituents[0][1] = new int[1] ; - _constituents[0][1][0] = 2 ; - - medGeometryElement * tmpConstituentsType1 = new medGeometryElement[2] ; - tmpConstituentsType1[0] = MED_POINT1 ; - tmpConstituentsType1[1] = MED_POINT1 ; - _constituentsType = new medGeometryElement*[1] ; - _constituentsType[0]=tmpConstituentsType1 ; - break; - } - case MED_SEG3 : { - _name="MED_SEG3" ; - _type=t; - _dimension=1; - _numberOfVertexes=2; - _numberOfNodes=3; - // constituent are POINT1 and we have no need to define _constituents vector - _numberOfConstituentsDimension=1 ; - _numberOfConstituents=new int[1] ; - _numberOfConstituents[0]=3 ; - _numberOfNodeOfEachConstituent=new int*[1] ; - _numberOfNodeOfEachConstituent[0]=new int[3] ; - _numberOfNodeOfEachConstituent[0][0]=1 ; - _numberOfNodeOfEachConstituent[0][1]=1 ; - _numberOfNodeOfEachConstituent[0][2]=1 ; - - _constituents = new int**[1] ; - _constituents[0] = new int*[3] ; - _constituents[0][0] = new int[1] ; - _constituents[0][0][0] = 1 ; - _constituents[0][1] = new int[1] ; - _constituents[0][1][0] = 2 ; - _constituents[0][2] = new int[1] ; - _constituents[0][2][0] = 3 ; - - medGeometryElement * tmpConstituentsType1 = new medGeometryElement[3] ; - tmpConstituentsType1[0] = MED_POINT1 ; - tmpConstituentsType1[1] = MED_POINT1 ; - tmpConstituentsType1[2] = MED_POINT1 ; - _constituentsType = new medGeometryElement*[1] ; - _constituentsType[0]=tmpConstituentsType1 ; - break; - } - case MED_TRIA3 : { - _name="MED_TRIA3" ; - _type=t; - _dimension=2; - _numberOfVertexes=3; - _numberOfNodes=3; - - _numberOfConstituentsDimension=1 ; - _numberOfConstituents=new int[1] ; - _numberOfConstituents[0]=3 ; - _numberOfNodeOfEachConstituent=new int*[1] ; - _numberOfNodeOfEachConstituent[0]=new int[3] ; - _numberOfNodeOfEachConstituent[0][0]=2 ; - _numberOfNodeOfEachConstituent[0][1]=2 ; - _numberOfNodeOfEachConstituent[0][2]=2 ; - - int* _edge1=new int[2]; - _edge1[0]=1; - _edge1[1]=2; - int* _edge2=new int[2]; - _edge2[0]=2; - _edge2[1]=3; - int* _edge3=new int[2]; - _edge3[0]=3; - _edge3[1]=1; - int ** tmpConstituents1 = new int*[3]; - tmpConstituents1[0]=_edge1 ; - tmpConstituents1[1]=_edge2 ; - tmpConstituents1[2]=_edge3 ; - _constituents = new int**[1] ; - _constituents[0]=tmpConstituents1 ; - - medGeometryElement * tmpConstituentsType1 = new medGeometryElement[3] ; - tmpConstituentsType1[0] = MED_SEG2 ; - tmpConstituentsType1[1] = MED_SEG2 ; - tmpConstituentsType1[2] = MED_SEG2 ; - _constituentsType = new medGeometryElement*[1] ; - _constituentsType[0]=tmpConstituentsType1 ; - // Well, point are defined, but could not be acces because we have - // only 1 numberOfConstituentsDimension ! - - break; - } - case MED_TRIA6 : { - _name="MED_TRIA6" ; - _type=t; - _dimension=2; - _numberOfVertexes=3; - _numberOfNodes=6; - _numberOfConstituentsDimension=1 ; - _numberOfConstituents=new int[1] ; - _numberOfConstituents[0]=3 ; - _numberOfNodeOfEachConstituent=new int*[1] ; - _numberOfNodeOfEachConstituent[0]=new int[3] ; - _numberOfNodeOfEachConstituent[0][0]=3 ; - _numberOfNodeOfEachConstituent[0][1]=3 ; - _numberOfNodeOfEachConstituent[0][2]=3 ; - - int* _edge1=new int[3]; - _edge1[0]=1; - _edge1[1]=2; - _edge1[2]=4; - int* _edge2=new int[3]; - _edge2[0]=2; - _edge2[1]=3; - _edge2[2]=5; - int* _edge3=new int[3]; - _edge3[0]=3; - _edge3[1]=1; - _edge3[2]=6; - int ** tmpConstituents1 = new int*[3]; - tmpConstituents1[0]=_edge1 ; - tmpConstituents1[1]=_edge2 ; - tmpConstituents1[2]=_edge3 ; - _constituents = new int**[1] ; - _constituents[0]=tmpConstituents1 ; - medGeometryElement * tmpConstituentsType1 = new medGeometryElement[3] ; - tmpConstituentsType1[0] = MED_SEG3 ; - tmpConstituentsType1[1] = MED_SEG3 ; - tmpConstituentsType1[2] = MED_SEG3 ; - _constituentsType = new medGeometryElement*[1] ; - _constituentsType[0]=tmpConstituentsType1 ; - // Well, point are defined, but could not be acces because we have - // only 1 numberOfConstituentsDimension ! - - break; - } - case MED_QUAD4 : { - _name="MED_QUAD4" ; - _type=t; - _dimension=2; - _numberOfVertexes=4; - _numberOfNodes=4; - _numberOfConstituentsDimension=1 ; - _numberOfConstituents=new int[1] ; - _numberOfConstituents[0]=4 ; - _numberOfNodeOfEachConstituent=new int*[1] ; - _numberOfNodeOfEachConstituent[0]=new int[4] ; - _numberOfNodeOfEachConstituent[0][0]=2 ; - _numberOfNodeOfEachConstituent[0][1]=2 ; - _numberOfNodeOfEachConstituent[0][2]=2 ; - _numberOfNodeOfEachConstituent[0][3]=2 ; - - int* _edge1=new int[2]; - _edge1[0]=1; - _edge1[1]=2; - int* _edge2=new int[2]; - _edge2[0]=2; - _edge2[1]=3; - int* _edge3=new int[2]; - _edge3[0]=3; - _edge3[1]=4; - int* _edge4=new int[2]; - _edge4[0]=4; - _edge4[1]=1; - int ** tmpConstituents1 = new int*[4]; - tmpConstituents1[0]=_edge1 ; - tmpConstituents1[1]=_edge2 ; - tmpConstituents1[2]=_edge3 ; - tmpConstituents1[3]=_edge4 ; - _constituents = new int**[1] ; - _constituents[0]=tmpConstituents1 ; - medGeometryElement * tmpConstituentsType1 = new medGeometryElement[4] ; - tmpConstituentsType1[0] = MED_SEG2 ; - tmpConstituentsType1[1] = MED_SEG2 ; - tmpConstituentsType1[2] = MED_SEG2 ; - tmpConstituentsType1[3] = MED_SEG2 ; - _constituentsType = new medGeometryElement*[1] ; - _constituentsType[0]=tmpConstituentsType1 ; - // Well, point are defined, but could not be acces because we have - // only 1 numberOfConstituentsDimension ! - - break; - } - case MED_QUAD8 : { - _name="MED_QUAD8" ; - _type=t; - _dimension=2; - _numberOfVertexes=4; - _numberOfNodes=8; - _numberOfConstituentsDimension=1 ; - _numberOfConstituents=new int[1] ; - _numberOfConstituents[0]=4 ; - _numberOfNodeOfEachConstituent=new int*[1] ; - _numberOfNodeOfEachConstituent[0]=new int[4] ; - _numberOfNodeOfEachConstituent[0][0]=3 ; - _numberOfNodeOfEachConstituent[0][1]=3 ; - _numberOfNodeOfEachConstituent[0][2]=3 ; - _numberOfNodeOfEachConstituent[0][3]=3 ; - - int* _edge1=new int[3]; - _edge1[0]=1; - _edge1[1]=2; - _edge1[2]=5; - int* _edge2=new int[3]; - _edge2[0]=2; - _edge2[1]=3; - _edge2[2]=6; - int* _edge3=new int[3]; - _edge3[0]=3; - _edge3[1]=4; - _edge3[2]=7; - int* _edge4=new int[3]; - _edge4[0]=4; - _edge4[1]=1; - _edge4[2]=8; - int ** tmpConstituents1 = new int*[4]; - tmpConstituents1[0]=_edge1 ; - tmpConstituents1[1]=_edge2 ; - tmpConstituents1[2]=_edge3 ; - tmpConstituents1[3]=_edge4 ; - _constituents = new int**[1] ; - _constituents[0]=tmpConstituents1 ; - medGeometryElement * tmpConstituentsType1 = new medGeometryElement[4] ; - tmpConstituentsType1[0] = MED_SEG3 ; - tmpConstituentsType1[1] = MED_SEG3 ; - tmpConstituentsType1[2] = MED_SEG3 ; - tmpConstituentsType1[3] = MED_SEG3 ; - _constituentsType = new medGeometryElement*[1] ; - _constituentsType[0]=tmpConstituentsType1 ; - // Well, point are defined, but could not be acces because we have - // only 1 numberOfConstituentsDimension ! - - break; - } - case MED_TETRA4 : { - _name="MED_TETRA4" ; - _type=t; - _dimension=3; - _numberOfVertexes=4; - _numberOfNodes=4; - _numberOfConstituentsDimension=2 ; - _numberOfConstituents=new int[2] ; - _numberOfConstituents[0]=4 ; - _numberOfConstituents[1]=6 ; - _numberOfNodeOfEachConstituent=new int*[2] ; - _numberOfNodeOfEachConstituent[0]=new int[4] ; - _numberOfNodeOfEachConstituent[0][0]=3 ; - _numberOfNodeOfEachConstituent[0][1]=3 ; - _numberOfNodeOfEachConstituent[0][2]=3 ; - _numberOfNodeOfEachConstituent[0][3]=3 ; - _numberOfNodeOfEachConstituent[1]=new int[6] ; - _numberOfNodeOfEachConstituent[1][0]=2 ; - _numberOfNodeOfEachConstituent[1][1]=2 ; - _numberOfNodeOfEachConstituent[1][2]=2 ; - _numberOfNodeOfEachConstituent[1][3]=2 ; - _numberOfNodeOfEachConstituent[1][4]=2 ; - _numberOfNodeOfEachConstituent[1][5]=2 ; - - int* _face1=new int[3]; - _face1[0]=1; - _face1[1]=2; - _face1[2]=3; - int* _face2=new int[3]; - _face2[0]=1; - _face2[1]=4; - _face2[2]=2; - int* _face3=new int[3]; - _face3[0]=2; - _face3[1]=4; - _face3[2]=3; - int* _face4=new int[3]; - _face4[0]=3; - _face4[1]=4; - _face4[2]=1; - int* _edge1=new int[2]; - _edge1[0]=1; - _edge1[1]=2; - int* _edge2=new int[2]; - _edge2[0]=2; - _edge2[1]=3; - int* _edge3=new int[2]; - _edge3[0]=3; - _edge3[1]=1; - int* _edge4=new int[2]; - _edge4[0]=1; - _edge4[1]=4; - int* _edge5=new int[2]; - _edge5[0]=2; - _edge5[1]=4; - int* _edge6=new int[2]; - _edge6[0]=3; - _edge6[1]=4; - int ** tmpConstituents1 = new int*[4]; - tmpConstituents1[0]=_face1 ; - tmpConstituents1[1]=_face2 ; - tmpConstituents1[2]=_face3 ; - tmpConstituents1[3]=_face4 ; - int ** tmpConstituents2 = new int*[6]; - tmpConstituents2[0]=_edge1 ; - tmpConstituents2[1]=_edge2 ; - tmpConstituents2[2]=_edge3 ; - tmpConstituents2[3]=_edge4 ; - tmpConstituents2[4]=_edge5 ; - tmpConstituents2[5]=_edge6 ; - _constituents = new int**[2] ; - _constituents[0]=tmpConstituents1 ; - _constituents[1]=tmpConstituents2 ; - medGeometryElement * tmpConstituentsType1 = new medGeometryElement[4] ; - tmpConstituentsType1[0] = MED_TRIA3 ; - tmpConstituentsType1[1] = MED_TRIA3 ; - tmpConstituentsType1[2] = MED_TRIA3 ; - tmpConstituentsType1[3] = MED_TRIA3 ; - medGeometryElement * tmpConstituentsType2 = new medGeometryElement[6] ; - tmpConstituentsType2[0] = MED_SEG2 ; - tmpConstituentsType2[1] = MED_SEG2 ; - tmpConstituentsType2[2] = MED_SEG2 ; - tmpConstituentsType2[3] = MED_SEG2 ; - tmpConstituentsType2[4] = MED_SEG2 ; - tmpConstituentsType2[5] = MED_SEG2 ; - _constituentsType = new medGeometryElement*[2] ; - _constituentsType[0]=tmpConstituentsType1 ; - _constituentsType[1]=tmpConstituentsType2 ; - break; - } - case MED_TETRA10 : { - _name="MED_TETRA10" ; - _type=t; - _dimension=3; - _numberOfVertexes=4; - _numberOfNodes=10; - _numberOfConstituentsDimension=2 ; - _numberOfConstituents=new int[2] ; - _numberOfConstituents[0]=4 ; - _numberOfConstituents[1]=6 ; - _numberOfNodeOfEachConstituent=new int*[2] ; - _numberOfNodeOfEachConstituent[0]=new int[4] ; - _numberOfNodeOfEachConstituent[0][0]=6 ; - _numberOfNodeOfEachConstituent[0][1]=6 ; - _numberOfNodeOfEachConstituent[0][2]=6 ; - _numberOfNodeOfEachConstituent[0][3]=6 ; - _numberOfNodeOfEachConstituent[1]=new int[6] ; - _numberOfNodeOfEachConstituent[1][0]=3 ; - _numberOfNodeOfEachConstituent[1][1]=3 ; - _numberOfNodeOfEachConstituent[1][2]=3 ; - _numberOfNodeOfEachConstituent[1][3]=3 ; - _numberOfNodeOfEachConstituent[1][4]=3 ; - _numberOfNodeOfEachConstituent[1][5]=3 ; - - int* _face1=new int[6]; - _face1[0]=1; - _face1[1]=2; - _face1[2]=3; - _face1[3]=5; - _face1[4]=6; - _face1[5]=7; - int* _face2=new int[6]; - _face2[0]=1; - _face2[1]=4; - _face2[2]=2; - _face2[3]=8; - _face2[4]=9; - _face2[5]=5; - int* _face3=new int[6]; - _face3[0]=2; - _face3[1]=4; - _face3[2]=3; - _face3[3]=9; - _face3[4]=10; - _face3[5]=6; - int* _face4=new int[6]; - _face4[0]=3; - _face4[1]=4; - _face4[2]=1; - _face4[3]=10; - _face4[4]=8; - _face4[5]=7; - int* _edge1=new int[3]; - _edge1[0]=1; - _edge1[1]=2; - _edge1[2]=5; - int* _edge2=new int[3]; - _edge2[0]=2; - _edge2[1]=3; - _edge2[2]=6; - int* _edge3=new int[3]; - _edge3[0]=3; - _edge3[1]=1; - _edge3[2]=7; - int* _edge4=new int[3]; - _edge4[0]=1; - _edge4[1]=4; - _edge4[2]=8; - int* _edge5=new int[3]; - _edge5[0]=2; - _edge5[1]=4; - _edge5[2]=9; - int* _edge6=new int[3]; - _edge6[0]=3; - _edge6[1]=4; - _edge6[2]=10; - int ** tmpConstituents1 = new int*[4]; - tmpConstituents1[0]=_face1 ; - tmpConstituents1[1]=_face2 ; - tmpConstituents1[2]=_face3 ; - tmpConstituents1[3]=_face4 ; - int ** tmpConstituents2 = new int*[6]; - tmpConstituents2[0]=_edge1 ; - tmpConstituents2[1]=_edge2 ; - tmpConstituents2[2]=_edge3 ; - tmpConstituents2[3]=_edge4 ; - tmpConstituents2[4]=_edge5 ; - tmpConstituents2[5]=_edge6 ; - _constituents = new int**[2] ; - _constituents[0]=tmpConstituents1 ; - _constituents[1]=tmpConstituents2 ; - medGeometryElement * tmpConstituentsType1 = new medGeometryElement[4] ; - tmpConstituentsType1[0] = MED_TRIA6 ; - tmpConstituentsType1[1] = MED_TRIA6 ; - tmpConstituentsType1[2] = MED_TRIA6 ; - tmpConstituentsType1[3] = MED_TRIA6 ; - medGeometryElement * tmpConstituentsType2 = new medGeometryElement[6] ; - tmpConstituentsType2[0] = MED_SEG3 ; - tmpConstituentsType2[1] = MED_SEG3 ; - tmpConstituentsType2[2] = MED_SEG3 ; - tmpConstituentsType2[3] = MED_SEG3 ; - tmpConstituentsType2[4] = MED_SEG3 ; - tmpConstituentsType2[5] = MED_SEG3 ; - _constituentsType = new medGeometryElement*[2] ; - _constituentsType[0]=tmpConstituentsType1 ; - _constituentsType[1]=tmpConstituentsType2 ; - break; - } - case MED_HEXA8 : { - _name="MED_HEXA8" ; - _type=t; - _dimension=3; - _numberOfVertexes=8; - _numberOfNodes=8; - _numberOfConstituentsDimension=2 ; - _numberOfConstituents=new int[2] ; - _numberOfConstituents[0]=6 ; - _numberOfConstituents[1]=12 ; - _numberOfNodeOfEachConstituent=new int*[2] ; - _numberOfNodeOfEachConstituent[0]=new int[6] ; - _numberOfNodeOfEachConstituent[0][0]=4 ; - _numberOfNodeOfEachConstituent[0][1]=4 ; - _numberOfNodeOfEachConstituent[0][2]=4 ; - _numberOfNodeOfEachConstituent[0][3]=4 ; - _numberOfNodeOfEachConstituent[0][4]=4 ; - _numberOfNodeOfEachConstituent[0][5]=4 ; - _numberOfNodeOfEachConstituent[1]=new int[12] ; - _numberOfNodeOfEachConstituent[1][0]=2 ; - _numberOfNodeOfEachConstituent[1][1]=2 ; - _numberOfNodeOfEachConstituent[1][2]=2 ; - _numberOfNodeOfEachConstituent[1][3]=2 ; - _numberOfNodeOfEachConstituent[1][4]=2 ; - _numberOfNodeOfEachConstituent[1][5]=2 ; - _numberOfNodeOfEachConstituent[1][6]=2 ; - _numberOfNodeOfEachConstituent[1][7]=2 ; - _numberOfNodeOfEachConstituent[1][8]=2 ; - _numberOfNodeOfEachConstituent[1][9]=2 ; - _numberOfNodeOfEachConstituent[1][10]=2 ; - _numberOfNodeOfEachConstituent[1][11]=2 ; - - int* _edge1=new int[2]; - _edge1[0]=1; - _edge1[1]=2; - int* _edge2=new int[2]; - _edge2[0]=2; - _edge2[1]=3; - int* _edge3=new int[2]; - _edge3[0]=3; - _edge3[1]=4; - int* _edge4=new int[2]; - _edge4[0]=4; - _edge4[1]=1; - int* _edge5=new int[2]; - _edge5[0]=5; - _edge5[1]=6; - int* _edge6=new int[2]; - _edge6[0]=6; - _edge6[1]=7; - int* _edge7=new int[2]; - _edge7[0]=7; - _edge7[1]=8; - int* _edge8=new int[2]; - _edge8[0]=8; - _edge8[1]=5; - int* _edge9=new int[2]; - _edge9[0]=1; - _edge9[1]=5; - int* _edge10=new int[2]; - _edge10[0]=2; - _edge10[1]=6; - int* _edge11=new int[2]; - _edge11[0]=3; - _edge11[1]=7; - int* _edge12=new int[2]; - _edge12[0]=4; - _edge12[1]=8; - int* _face1=new int[4]; - _face1[0]=1; - _face1[1]=2; - _face1[2]=3; - _face1[3]=4; - int* _face2=new int[4]; - _face2[0]=5; - _face2[1]=8; - _face2[2]=7; - _face2[3]=6; - int* _face3=new int[4]; - _face3[0]=1; - _face3[1]=5; - _face3[2]=6; - _face3[3]=2; - int* _face4=new int[4]; - _face4[0]=2; - _face4[1]=6; - _face4[2]=7; - _face4[3]=3; - int* _face5=new int[4]; - _face5[0]=3; - _face5[1]=7; - _face5[2]=8; - _face5[3]=4; - int* _face6=new int[4]; - _face6[0]=4; - _face6[1]=8; - _face6[2]=5; - _face6[3]=1; - int ** tmpConstituents1 = new int*[6]; - tmpConstituents1[0]=_face1 ; - tmpConstituents1[1]=_face2 ; - tmpConstituents1[2]=_face3 ; - tmpConstituents1[3]=_face4 ; - tmpConstituents1[4]=_face5 ; - tmpConstituents1[5]=_face6 ; - int ** tmpConstituents2 = new int*[12]; - tmpConstituents2[0]=_edge1 ; - tmpConstituents2[1]=_edge2 ; - tmpConstituents2[2]=_edge3 ; - tmpConstituents2[3]=_edge4 ; - tmpConstituents2[4]=_edge5 ; - tmpConstituents2[5]=_edge6 ; - tmpConstituents2[6]=_edge7 ; - tmpConstituents2[7]=_edge8 ; - tmpConstituents2[8]=_edge9 ; - tmpConstituents2[9]=_edge10; - tmpConstituents2[10]=_edge11; - tmpConstituents2[11]=_edge12; - _constituents = new int**[2] ; - _constituents[0]=tmpConstituents1 ; - _constituents[1]=tmpConstituents2 ; - medGeometryElement * tmpConstituentsType1 = new medGeometryElement[6] ; - tmpConstituentsType1[0] = MED_QUAD4 ; - tmpConstituentsType1[1] = MED_QUAD4 ; - tmpConstituentsType1[2] = MED_QUAD4 ; - tmpConstituentsType1[3] = MED_QUAD4 ; - tmpConstituentsType1[4] = MED_QUAD4 ; - tmpConstituentsType1[5] = MED_QUAD4 ; - medGeometryElement * tmpConstituentsType2 = new medGeometryElement[12] ; - tmpConstituentsType2[0] = MED_SEG2 ; - tmpConstituentsType2[1] = MED_SEG2 ; - tmpConstituentsType2[2] = MED_SEG2 ; - tmpConstituentsType2[3] = MED_SEG2 ; - tmpConstituentsType2[4] = MED_SEG2 ; - tmpConstituentsType2[5] = MED_SEG2 ; - tmpConstituentsType2[6] = MED_SEG2 ; - tmpConstituentsType2[7] = MED_SEG2 ; - tmpConstituentsType2[8] = MED_SEG2 ; - tmpConstituentsType2[9] = MED_SEG2 ; - tmpConstituentsType2[10] = MED_SEG2 ; - tmpConstituentsType2[11] = MED_SEG2 ; - _constituentsType = new medGeometryElement*[2] ; - _constituentsType[0]=tmpConstituentsType1 ; - _constituentsType[1]=tmpConstituentsType2 ; - break; - } - case MED_HEXA20 : { - _name="MED_HEXA20" ; - _type=t; - _dimension=3; - _numberOfVertexes=8; - _numberOfNodes=20; - _numberOfConstituentsDimension=2 ; - _numberOfConstituents=new int[2] ; - _numberOfConstituents[0]=6 ; - _numberOfConstituents[1]=12 ; - _numberOfNodeOfEachConstituent=new int*[2] ; - _numberOfNodeOfEachConstituent[0]=new int[6] ; - _numberOfNodeOfEachConstituent[0][0]=8 ; - _numberOfNodeOfEachConstituent[0][1]=8 ; - _numberOfNodeOfEachConstituent[0][2]=8 ; - _numberOfNodeOfEachConstituent[0][3]=8 ; - _numberOfNodeOfEachConstituent[0][4]=8 ; - _numberOfNodeOfEachConstituent[0][5]=8 ; - _numberOfNodeOfEachConstituent[1]=new int[12] ; - _numberOfNodeOfEachConstituent[1][0]=3 ; - _numberOfNodeOfEachConstituent[1][1]=3 ; - _numberOfNodeOfEachConstituent[1][2]=3 ; - _numberOfNodeOfEachConstituent[1][3]=3 ; - _numberOfNodeOfEachConstituent[1][4]=3 ; - _numberOfNodeOfEachConstituent[1][5]=3 ; - _numberOfNodeOfEachConstituent[1][6]=3 ; - _numberOfNodeOfEachConstituent[1][7]=3 ; - _numberOfNodeOfEachConstituent[1][8]=3 ; - _numberOfNodeOfEachConstituent[1][9]=3 ; - _numberOfNodeOfEachConstituent[1][10]=3 ; - _numberOfNodeOfEachConstituent[1][11]=3 ; - - int* _edge1=new int[3]; - _edge1[0]=1; - _edge1[1]=2; - _edge1[2]=9; - int* _edge2=new int[3]; - _edge2[0]=2; - _edge2[1]=3; - _edge2[2]=10; - int* _edge3=new int[3]; - _edge3[0]=3; - _edge3[1]=4; - _edge3[2]=11; - int* _edge4=new int[3]; - _edge4[0]=4; - _edge4[1]=1; - _edge4[2]=12; - int* _edge5=new int[3]; - _edge5[0]=5; - _edge5[1]=6; - _edge5[2]=13; - int* _edge6=new int[3]; - _edge6[0]=6; - _edge6[1]=7; - _edge6[2]=14; - int* _edge7=new int[3]; - _edge7[0]=7; - _edge7[1]=8; - _edge7[2]=15; - int* _edge8=new int[3]; - _edge8[0]=8; - _edge8[1]=5; - _edge8[2]=16; - int* _edge9=new int[3]; - _edge9[0]=1; - _edge9[1]=5; - _edge9[2]=17; - int* _edge10=new int[3]; - _edge10[0]=2; - _edge10[1]=6; - _edge10[2]=18; - int* _edge11=new int[3]; - _edge11[0]=3; - _edge11[1]=7; - _edge11[2]=19; - int* _edge12=new int[3]; - _edge12[0]=4; - _edge12[1]=8; - _edge12[2]=20; - int* _face1=new int[8]; - _face1[0]=1; - _face1[1]=2; - _face1[2]=3; - _face1[3]=4; - _face1[4]=9; - _face1[5]=10; - _face1[6]=11; - _face1[7]=12; - int* _face2=new int[8]; - _face2[0]=5; - _face2[1]=8; - _face2[2]=7; - _face2[3]=6; - _face2[4]=16; - _face2[5]=15; - _face2[6]=14; - _face2[7]=13; - int* _face3=new int[8]; - _face3[0]=1; - _face3[1]=5; - _face3[2]=6; - _face3[3]=2; - _face3[4]=17; - _face3[5]=13; - _face3[6]=18; - _face3[7]=9; - int* _face4=new int[8]; - _face4[0]=2; - _face4[1]=6; - _face4[2]=7; - _face4[3]=3; - _face4[4]=18; - _face4[5]=14; - _face4[6]=19; - _face4[7]=10; - int* _face5=new int[8]; - _face5[0]=3; - _face5[1]=7; - _face5[2]=8; - _face5[3]=4; - _face5[4]=19; - _face5[5]=15; - _face5[6]=20; - _face5[7]=11; - int* _face6=new int[8]; - _face6[0]=4; - _face6[1]=8; - _face6[2]=5; - _face6[3]=1; - _face6[4]=20; - _face6[5]=16; - _face6[6]=17; - _face6[7]=12; - int ** tmpConstituents1 = new int*[6]; - tmpConstituents1[0]=_face1 ; - tmpConstituents1[1]=_face2 ; - tmpConstituents1[2]=_face3 ; - tmpConstituents1[3]=_face4 ; - tmpConstituents1[4]=_face5 ; - tmpConstituents1[5]=_face6 ; - int ** tmpConstituents2 = new int*[12]; - tmpConstituents2[0]=_edge1 ; - tmpConstituents2[1]=_edge2 ; - tmpConstituents2[2]=_edge3 ; - tmpConstituents2[3]=_edge4 ; - tmpConstituents2[4]=_edge5 ; - tmpConstituents2[5]=_edge6 ; - tmpConstituents2[6]=_edge7 ; - tmpConstituents2[7]=_edge8 ; - tmpConstituents2[8]=_edge9 ; - tmpConstituents2[9]=_edge10; - tmpConstituents2[10]=_edge11; - tmpConstituents2[11]=_edge12; - _constituents = new int**[2] ; - _constituents[0]=tmpConstituents1 ; - _constituents[1]=tmpConstituents2 ; - medGeometryElement * tmpConstituentsType1 = new medGeometryElement[6] ; - tmpConstituentsType1[0] = MED_QUAD8 ; - tmpConstituentsType1[1] = MED_QUAD8 ; - tmpConstituentsType1[2] = MED_QUAD8 ; - tmpConstituentsType1[3] = MED_QUAD8 ; - tmpConstituentsType1[4] = MED_QUAD8 ; - tmpConstituentsType1[5] = MED_QUAD8 ; - medGeometryElement * tmpConstituentsType2 = new medGeometryElement[12] ; - tmpConstituentsType2[0] = MED_SEG3 ; - tmpConstituentsType2[1] = MED_SEG3 ; - tmpConstituentsType2[2] = MED_SEG3 ; - tmpConstituentsType2[3] = MED_SEG3 ; - tmpConstituentsType2[4] = MED_SEG3 ; - tmpConstituentsType2[5] = MED_SEG3 ; - tmpConstituentsType2[6] = MED_SEG3 ; - tmpConstituentsType2[7] = MED_SEG3 ; - tmpConstituentsType2[8] = MED_SEG3 ; - tmpConstituentsType2[9] = MED_SEG3 ; - tmpConstituentsType2[10] = MED_SEG3 ; - tmpConstituentsType2[11] = MED_SEG3 ; - _constituentsType = new medGeometryElement*[2] ; - _constituentsType[0]=tmpConstituentsType1 ; - _constituentsType[1]=tmpConstituentsType2 ; - break; - } - case MED_PENTA6 : { - _name="MED_PENTA6" ; - _type=t; - _dimension=3; - _numberOfVertexes=6; - _numberOfNodes=6; - - _numberOfConstituentsDimension=2 ; - _numberOfConstituents=new int[2] ; - _numberOfConstituents[0]=5 ; - _numberOfConstituents[1]=9 ; - _numberOfNodeOfEachConstituent=new int*[2] ; - _numberOfNodeOfEachConstituent[0]=new int[5] ; - _numberOfNodeOfEachConstituent[0][0]=3 ; - _numberOfNodeOfEachConstituent[0][1]=3 ; - _numberOfNodeOfEachConstituent[0][2]=4 ; - _numberOfNodeOfEachConstituent[0][3]=4 ; - _numberOfNodeOfEachConstituent[0][4]=4 ; - _numberOfNodeOfEachConstituent[1]=new int[9] ; - _numberOfNodeOfEachConstituent[1][0]=2 ; - _numberOfNodeOfEachConstituent[1][1]=2 ; - _numberOfNodeOfEachConstituent[1][2]=2 ; - _numberOfNodeOfEachConstituent[1][3]=2 ; - _numberOfNodeOfEachConstituent[1][4]=2 ; - _numberOfNodeOfEachConstituent[1][5]=2 ; - _numberOfNodeOfEachConstituent[1][6]=2 ; - _numberOfNodeOfEachConstituent[1][7]=2 ; - _numberOfNodeOfEachConstituent[1][8]=2 ; - - int* _edge1=new int[2]; - _edge1[0]=1; - _edge1[1]=2; - int* _edge2=new int[2]; - _edge2[0]=2; - _edge2[1]=3; - int* _edge3=new int[2]; - _edge3[0]=3; - _edge3[1]=1; - int* _edge4=new int[2]; - _edge4[0]=4; - _edge4[1]=5; - int* _edge5=new int[2]; - _edge5[0]=5; - _edge5[1]=6; - int* _edge6=new int[2]; - _edge6[0]=6; - _edge6[1]=4; - int* _edge7=new int[2]; - _edge7[0]=1; - _edge7[1]=4; - int* _edge8=new int[2]; - _edge8[0]=2; - _edge8[1]=5; - int* _edge9=new int[2]; - _edge9[0]=3; - _edge9[1]=6; - int* _face1=new int[3]; - _face1[0]=1; - _face1[1]=2; - _face1[2]=3; - int* _face2=new int[3]; - _face2[0]=4; - _face2[1]=6; - _face2[2]=5; - int* _face3=new int[4]; - _face3[0]=1; - _face3[1]=4; - _face3[2]=5; - _face3[3]=2; - int* _face4=new int[4]; - _face4[0]=2; - _face4[1]=5; - _face4[2]=6; - _face4[3]=3; - int* _face5=new int[4]; - _face5[0]=3; - _face5[1]=6; - _face5[2]=4; - _face5[3]=1; - int ** tmpConstituents1 = new int*[5]; - tmpConstituents1[0]=_face1 ; - tmpConstituents1[1]=_face2 ; - tmpConstituents1[2]=_face3 ; - tmpConstituents1[3]=_face4 ; - tmpConstituents1[4]=_face5 ; - int ** tmpConstituents2 = new int*[9]; - tmpConstituents2[0]=_edge1 ; - tmpConstituents2[1]=_edge2 ; - tmpConstituents2[2]=_edge3 ; - tmpConstituents2[3]=_edge4 ; - tmpConstituents2[4]=_edge5 ; - tmpConstituents2[5]=_edge6 ; - tmpConstituents2[6]=_edge7 ; - tmpConstituents2[7]=_edge8 ; - tmpConstituents2[8]=_edge9 ; - _constituents = new int**[2] ; - _constituents[0]=tmpConstituents1 ; - _constituents[1]=tmpConstituents2 ; - medGeometryElement * tmpConstituentsType1 = new medGeometryElement[5] ; - tmpConstituentsType1[0] = MED_TRIA3 ; - tmpConstituentsType1[1] = MED_TRIA3 ; - tmpConstituentsType1[2] = MED_QUAD4 ; - tmpConstituentsType1[3] = MED_QUAD4 ; - tmpConstituentsType1[4] = MED_QUAD4 ; - medGeometryElement * tmpConstituentsType2 = new medGeometryElement[9] ; - tmpConstituentsType2[0] = MED_SEG2 ; - tmpConstituentsType2[1] = MED_SEG2 ; - tmpConstituentsType2[2] = MED_SEG2 ; - tmpConstituentsType2[3] = MED_SEG2 ; - tmpConstituentsType2[4] = MED_SEG2 ; - tmpConstituentsType2[5] = MED_SEG2 ; - tmpConstituentsType2[6] = MED_SEG2 ; - tmpConstituentsType2[7] = MED_SEG2 ; - tmpConstituentsType2[8] = MED_SEG2 ; - _constituentsType = new medGeometryElement*[2] ; - _constituentsType[0]=tmpConstituentsType1 ; - _constituentsType[1]=tmpConstituentsType2 ; - break; - } - case MED_PENTA15 : { - _name="MED_PENTA15" ; - _type=t; - _dimension=3; - _numberOfVertexes=6; - _numberOfNodes=15; - _numberOfConstituentsDimension=2 ; - _numberOfConstituents=new int[2] ; - _numberOfConstituents[0]=5 ; - _numberOfConstituents[1]=9 ; - _numberOfNodeOfEachConstituent=new int*[2] ; - _numberOfNodeOfEachConstituent[0]=new int[5] ; - _numberOfNodeOfEachConstituent[0][0]=6 ; - _numberOfNodeOfEachConstituent[0][1]=6 ; - _numberOfNodeOfEachConstituent[0][2]=8 ; - _numberOfNodeOfEachConstituent[0][3]=8 ; - _numberOfNodeOfEachConstituent[0][4]=8 ; - _numberOfNodeOfEachConstituent[1]=new int[9] ; - _numberOfNodeOfEachConstituent[1][0]=3 ; - _numberOfNodeOfEachConstituent[1][1]=3 ; - _numberOfNodeOfEachConstituent[1][2]=3 ; - _numberOfNodeOfEachConstituent[1][3]=3 ; - _numberOfNodeOfEachConstituent[1][4]=3 ; - _numberOfNodeOfEachConstituent[1][5]=3 ; - _numberOfNodeOfEachConstituent[1][6]=3 ; - _numberOfNodeOfEachConstituent[1][7]=3 ; - _numberOfNodeOfEachConstituent[1][8]=3 ; - - int* _edge1=new int[3]; - _edge1[0]=1; - _edge1[1]=2; - _edge1[2]=7; - int* _edge2=new int[3]; - _edge2[0]=2; - _edge2[1]=3; - _edge2[2]=8; - int* _edge3=new int[3]; - _edge3[0]=3; - _edge3[1]=1; - _edge3[2]=9; - int* _edge4=new int[3]; - _edge4[0]=4; - _edge4[1]=5; - _edge4[2]=10; - int* _edge5=new int[3]; - _edge5[0]=5; - _edge5[1]=6; - _edge5[2]=11; - int* _edge6=new int[3]; - _edge6[0]=6; - _edge6[1]=4; - _edge6[2]=12; - int* _edge7=new int[3]; - _edge7[0]=1; - _edge7[1]=4; - _edge7[2]=13; - int* _edge8=new int[3]; - _edge8[0]=2; - _edge8[1]=5; - _edge8[2]=14; - int* _edge9=new int[3]; - _edge9[0]=3; - _edge9[1]=6; - _edge9[2]=15; - int* _face1=new int[6]; - _face1[0]=1; - _face1[1]=2; - _face1[2]=3; - _face1[3]=7; - _face1[4]=8; - _face1[5]=9; - int* _face2=new int[6]; - _face2[0]=4; - _face2[1]=5; - _face2[2]=6; - _face2[3]=12; - _face2[4]=11; - _face2[5]=10; - int* _face3=new int[8]; - _face3[0]=1; - _face3[1]=4; - _face3[2]=5; - _face3[3]=2; - _face3[4]=13; - _face3[5]=10; - _face3[6]=14; - _face3[7]=7; - int* _face4=new int[8]; - _face4[0]=2; - _face4[1]=5; - _face4[2]=6; - _face4[3]=3; - _face4[4]=14; - _face4[5]=11; - _face4[6]=15; - _face4[7]=8; - int* _face5=new int[8]; - _face5[0]=3; - _face5[1]=6; - _face5[2]=4; - _face5[3]=1; - _face5[4]=15; - _face5[5]=12; - _face5[6]=13; - _face5[7]=9; - int ** tmpConstituents1 = new int*[5]; - tmpConstituents1[0]=_face1 ; - tmpConstituents1[1]=_face2 ; - tmpConstituents1[2]=_face3 ; - tmpConstituents1[3]=_face4 ; - tmpConstituents1[4]=_face5 ; - int ** tmpConstituents2 = new int*[9]; - tmpConstituents2[0]=_edge1 ; - tmpConstituents2[1]=_edge2 ; - tmpConstituents2[2]=_edge3 ; - tmpConstituents2[3]=_edge4 ; - tmpConstituents2[4]=_edge5 ; - tmpConstituents2[5]=_edge6 ; - tmpConstituents2[6]=_edge7 ; - tmpConstituents2[7]=_edge8 ; - tmpConstituents2[8]=_edge9 ; - _constituents = new int**[2] ; - _constituents[0]=tmpConstituents1 ; - _constituents[1]=tmpConstituents2 ; - medGeometryElement * tmpConstituentsType1 = new medGeometryElement[5] ; - tmpConstituentsType1[0] = MED_TRIA6 ; - tmpConstituentsType1[1] = MED_TRIA6 ; - tmpConstituentsType1[2] = MED_QUAD8 ; - tmpConstituentsType1[3] = MED_QUAD8 ; - tmpConstituentsType1[4] = MED_QUAD8 ; - medGeometryElement * tmpConstituentsType2 = new medGeometryElement[9] ; - tmpConstituentsType2[0] = MED_SEG3 ; - tmpConstituentsType2[1] = MED_SEG3 ; - tmpConstituentsType2[2] = MED_SEG3 ; - tmpConstituentsType2[3] = MED_SEG3 ; - tmpConstituentsType2[4] = MED_SEG3 ; - tmpConstituentsType2[5] = MED_SEG3 ; - tmpConstituentsType2[6] = MED_SEG3 ; - tmpConstituentsType2[7] = MED_SEG3 ; - tmpConstituentsType2[8] = MED_SEG3 ; - _constituentsType = new medGeometryElement*[2] ; - _constituentsType[0]=tmpConstituentsType1 ; - _constituentsType[1]=tmpConstituentsType2 ; - break ; - } - case MED_PYRA5 : { - _name="MED_PYRA5" ; - _type=t; - _dimension=3; - _numberOfVertexes=5; - _numberOfNodes=5; - _numberOfConstituentsDimension=2 ; - _numberOfConstituents=new int[2] ; - _numberOfConstituents[0]=5 ; - _numberOfConstituents[1]=8 ; - _numberOfNodeOfEachConstituent=new int*[2] ; - _numberOfNodeOfEachConstituent[0]=new int[5] ; - _numberOfNodeOfEachConstituent[0][0]=4 ; - _numberOfNodeOfEachConstituent[0][1]=3 ; - _numberOfNodeOfEachConstituent[0][2]=3 ; - _numberOfNodeOfEachConstituent[0][3]=3 ; - _numberOfNodeOfEachConstituent[0][4]=3 ; - _numberOfNodeOfEachConstituent[1]=new int[8] ; - _numberOfNodeOfEachConstituent[1][0]=2 ; - _numberOfNodeOfEachConstituent[1][1]=2 ; - _numberOfNodeOfEachConstituent[1][2]=2 ; - _numberOfNodeOfEachConstituent[1][3]=2 ; - _numberOfNodeOfEachConstituent[1][4]=2 ; - _numberOfNodeOfEachConstituent[1][5]=2 ; - _numberOfNodeOfEachConstituent[1][6]=2 ; - _numberOfNodeOfEachConstituent[1][7]=2 ; - - int* _edge1=new int[2]; - _edge1[0]=1; - _edge1[1]=2; - int* _edge2=new int[2]; - _edge2[0]=2; - _edge2[1]=3; - int* _edge3=new int[2]; - _edge3[0]=3; - _edge3[1]=4; - int* _edge4=new int[2]; - _edge4[0]=4; - _edge4[1]=1; - int* _edge5=new int[2]; - _edge5[0]=1; - _edge5[1]=5; - int* _edge6=new int[2]; - _edge6[0]=2; - _edge6[1]=5; - int* _edge7=new int[2]; - _edge7[0]=3; - _edge7[1]=5; - int* _edge8=new int[2]; - _edge8[0]=4; - _edge8[1]=5; - int* _face1=new int[4]; - _face1[0]=1; - _face1[1]=2; - _face1[2]=3; - _face1[3]=4; - int* _face2=new int[3]; - _face2[0]=1; - _face2[1]=5; - _face2[2]=2; - int* _face3=new int[3]; - _face3[0]=2; - _face3[1]=5; - _face3[2]=3; - int* _face4=new int[3]; - _face4[0]=3; - _face4[1]=5; - _face4[2]=4; - int* _face5=new int[3]; - _face5[0]=4; - _face5[1]=5; - _face5[2]=1; - int ** tmpConstituents1 = new int*[5]; - tmpConstituents1[0]=_face1 ; - tmpConstituents1[1]=_face2 ; - tmpConstituents1[2]=_face3 ; - tmpConstituents1[3]=_face4 ; - tmpConstituents1[4]=_face5 ; - int ** tmpConstituents2 = new int*[8]; - tmpConstituents2[0]=_edge1 ; - tmpConstituents2[1]=_edge2 ; - tmpConstituents2[2]=_edge3 ; - tmpConstituents2[3]=_edge4 ; - tmpConstituents2[4]=_edge5 ; - tmpConstituents2[5]=_edge6 ; - tmpConstituents2[6]=_edge7 ; - tmpConstituents2[7]=_edge8 ; - _constituents = new int**[2] ; - _constituents[0]=tmpConstituents1 ; - _constituents[1]=tmpConstituents2 ; - medGeometryElement * tmpConstituentsType1 = new medGeometryElement[5] ; - tmpConstituentsType1[0] = MED_QUAD4 ; - tmpConstituentsType1[1] = MED_TRIA3 ; - tmpConstituentsType1[2] = MED_TRIA3 ; - tmpConstituentsType1[3] = MED_TRIA3 ; - tmpConstituentsType1[4] = MED_TRIA3 ; - medGeometryElement * tmpConstituentsType2 = new medGeometryElement[8] ; - tmpConstituentsType2[0] = MED_SEG2 ; - tmpConstituentsType2[1] = MED_SEG2 ; - tmpConstituentsType2[2] = MED_SEG2 ; - tmpConstituentsType2[3] = MED_SEG2 ; - tmpConstituentsType2[4] = MED_SEG2 ; - tmpConstituentsType2[5] = MED_SEG2 ; - tmpConstituentsType2[6] = MED_SEG2 ; - tmpConstituentsType2[7] = MED_SEG2 ; - _constituentsType = new medGeometryElement*[2] ; - _constituentsType[0]=tmpConstituentsType1 ; - _constituentsType[1]=tmpConstituentsType2 ; - break; - } - case MED_PYRA13 : { - _name="MED_PYRA13" ; - _type=t; - _dimension=3; - _numberOfVertexes=5; - _numberOfNodes=13; - _numberOfConstituentsDimension=2 ; - _numberOfConstituents=new int[2] ; - _numberOfConstituents[0]=5 ; - _numberOfConstituents[1]=8 ; - _numberOfNodeOfEachConstituent=new int*[2] ; - _numberOfNodeOfEachConstituent[0]=new int[5] ; - _numberOfNodeOfEachConstituent[0][0]=8 ; - _numberOfNodeOfEachConstituent[0][1]=6 ; - _numberOfNodeOfEachConstituent[0][2]=6 ; - _numberOfNodeOfEachConstituent[0][3]=6 ; - _numberOfNodeOfEachConstituent[0][4]=6 ; - _numberOfNodeOfEachConstituent[1]=new int[8] ; - _numberOfNodeOfEachConstituent[1][0]=3 ; - _numberOfNodeOfEachConstituent[1][1]=3 ; - _numberOfNodeOfEachConstituent[1][2]=3 ; - _numberOfNodeOfEachConstituent[1][3]=3 ; - _numberOfNodeOfEachConstituent[1][4]=3 ; - _numberOfNodeOfEachConstituent[1][5]=3 ; - _numberOfNodeOfEachConstituent[1][6]=3 ; - _numberOfNodeOfEachConstituent[1][7]=3 ; - - int* _edge1=new int[3]; - _edge1[0]=1; - _edge1[1]=2; - _edge1[2]=6; - int* _edge2=new int[3]; - _edge2[0]=2; - _edge2[1]=3; - _edge2[2]=7; - int* _edge3=new int[3]; - _edge3[0]=3; - _edge3[1]=4; - _edge3[2]=8; - int* _edge4=new int[3]; - _edge4[0]=4; - _edge4[1]=1; - _edge4[2]=9; - int* _edge5=new int[3]; - _edge5[0]=1; - _edge5[1]=5; - _edge5[2]=10; - int* _edge6=new int[3]; - _edge6[0]=2; - _edge6[1]=5; - _edge6[2]=11; - int* _edge7=new int[3]; - _edge7[0]=3; - _edge7[1]=5; - _edge7[2]=12; - int* _edge8=new int[3]; - _edge8[0]=4; - _edge8[1]=5; - _edge8[2]=13; - int* _face1=new int[8]; - _face1[0]=1; - _face1[1]=2; - _face1[2]=3; - _face1[3]=4; - _face1[4]=6; - _face1[5]=7; - _face1[6]=8; - _face1[7]=9; - int* _face2=new int[6]; - _face2[0]=1; - _face2[1]=5; - _face2[2]=2; - _face2[3]=10; - _face2[4]=11; - _face2[5]=6; - int* _face3=new int[6]; - _face3[0]=2; - _face3[1]=5; - _face3[2]=3; - _face3[3]=11; - _face3[4]=12; - _face3[5]=7; - int* _face4=new int[6]; - _face4[0]=3; - _face4[1]=5; - _face4[2]=4; - _face4[3]=12; - _face4[4]=13; - _face4[5]=8; - int* _face5=new int[6]; - _face5[0]=4; - _face5[1]=5; - _face5[2]=1; - _face5[3]=13; - _face5[4]=10; - _face5[5]=9; - int ** tmpConstituents1 = new int*[5]; - tmpConstituents1[0]=_face1 ; - tmpConstituents1[1]=_face2 ; - tmpConstituents1[2]=_face3 ; - tmpConstituents1[3]=_face4 ; - tmpConstituents1[4]=_face5 ; - int ** tmpConstituents2 = new int*[8]; - tmpConstituents2[0]=_edge1 ; - tmpConstituents2[1]=_edge2 ; - tmpConstituents2[2]=_edge3 ; - tmpConstituents2[3]=_edge4 ; - tmpConstituents2[4]=_edge5 ; - tmpConstituents2[5]=_edge6 ; - tmpConstituents2[6]=_edge7 ; - tmpConstituents2[7]=_edge8 ; - _constituents = new int**[2] ; - _constituents[0]=tmpConstituents1 ; - _constituents[1]=tmpConstituents2 ; - medGeometryElement * tmpConstituentsType1 = new medGeometryElement[5] ; - tmpConstituentsType1[0] = MED_QUAD8 ; - tmpConstituentsType1[1] = MED_TRIA6 ; - tmpConstituentsType1[2] = MED_TRIA6 ; - tmpConstituentsType1[3] = MED_TRIA6 ; - tmpConstituentsType1[4] = MED_TRIA6 ; - medGeometryElement * tmpConstituentsType2 = new medGeometryElement[8] ; - tmpConstituentsType2[0] = MED_SEG3 ; - tmpConstituentsType2[1] = MED_SEG3 ; - tmpConstituentsType2[2] = MED_SEG3 ; - tmpConstituentsType2[3] = MED_SEG3 ; - tmpConstituentsType2[4] = MED_SEG3 ; - tmpConstituentsType2[5] = MED_SEG3 ; - tmpConstituentsType2[6] = MED_SEG3 ; - tmpConstituentsType2[7] = MED_SEG3 ; - _constituentsType = new medGeometryElement*[2] ; - _constituentsType[0]=tmpConstituentsType1 ; - _constituentsType[1]=tmpConstituentsType2 ; - break; - } - case MED_POLYGON: - _name="MED_POLYGON" ; - _type=t; - _dimension=2; - _numberOfConstituentsDimension=1 ; - _numberOfConstituents=new int[_numberOfConstituentsDimension] ; - _numberOfConstituents[0]=0 ; - _numberOfNodeOfEachConstituent=new int*[_numberOfConstituentsDimension] ; - _numberOfNodeOfEachConstituent[0]=0; - _constituentsType = new medGeometryElement*[_numberOfConstituentsDimension] ; - _constituentsType[0]=0 ; - _constituents = new int**[_numberOfConstituentsDimension] ; - _constituents[0]=0; - break; - case MED_POLYHEDRA: - _name="MED_POLYHEDRA" ; - _type=t; - _dimension=3; - _numberOfConstituentsDimension=2 ; - _numberOfConstituents=new int[_numberOfConstituentsDimension] ; - _numberOfConstituents[0]=_numberOfConstituents[1]=0; - _numberOfNodeOfEachConstituent=new int*[_numberOfConstituentsDimension] ; - _numberOfNodeOfEachConstituent[0]=_numberOfNodeOfEachConstituent[1]=0; - _constituentsType = new medGeometryElement*[_numberOfConstituentsDimension] ; - _constituentsType[0]=_constituentsType[1]=0 ; - _constituents = new int**[_numberOfConstituentsDimension] ; - _constituents[0]=_constituents[1]=0; - break; -// default : -// _type=0; -// break; - } -} - -ostream & MEDMEM::operator<<(ostream &os,const CELLMODEL &my) -{ - os << "Cell Model :" << endl ; - os << " - name : " << my._name << endl; - os << " - type : " << (int)my._type << endl; - os << " - dimension : " << my._dimension << endl; - os << " - number of nodes : " << my._numberOfNodes << endl ; - os << " - number of vertexes : " << my._numberOfVertexes << endl ; - - os << " - number of Constituents Dimension : " << my._numberOfConstituentsDimension << endl ; - - for(int i=0;i constituentsTypes ; -// if (_constituentsType.size() > 0 ) { -// vector constituentsType = _constituentsType[0] ; -// vector::iterator itvec ; -// for(itvec=constituentsType.begin();itvec!=constituentsType.end();itvec++) -// constituentsTypes.insert(*itvec); -// } - return constituentsTypes.size() ; -} - - // Return all types of constituents which dimension is (_dimension-1). -set CELLMODEL::getAllConstituentsType() const -{ - set constituentsTypes ; -// if (_constituentsType.size() > 0 ) { -// vector constituentsType = _constituentsType[0] ; -// vector::iterator itvec ; -// for(itvec=constituentsType.begin();itvec!=constituentsType.end();itvec++) -// constituentsTypes.insert(*itvec); -// } - return constituentsTypes ; -} - - // Return number of constituents foreach type (which dimension is _dimension-1). -map CELLMODEL::getNumberOfConstituentsForeachType() const -{ - map numberOfConstituentsForeachType ; -// map::iterator itmap ; -// if (_constituentsType.size() > 0 ) { -// vector constituentsType = _constituentsType[0] ; -// vector::iterator itvec ; -// for(itvec=constituentsType.begin();itvec!=constituentsType.end();itvec++) { -// itmap = numberOfConstituentsForeachType.find(*itvec); -// if (itmap==numberOfConstituentsForeachType.end()) // new element -// numberOfConstituentsForeachType[*itvec]=1 ; -// else -// numberOfConstituentsForeachType[*itvec]++ ; -// } -// } - return numberOfConstituentsForeachType ; -} - -void CELLMODEL::init(const CELLMODEL &m) -{ - _name=m._name ; - _type= m._type ; - _dimension = m._dimension ; - _numberOfNodes = m._numberOfNodes ; - _numberOfVertexes = m._numberOfVertexes ; - - _numberOfConstituentsDimension = m._numberOfConstituentsDimension ; - - _numberOfConstituents = new int[_numberOfConstituentsDimension] ; - for(int i=0; i<_numberOfConstituentsDimension; i++) - _numberOfConstituents[i]=m._numberOfConstituents[i] ; - - _numberOfNodeOfEachConstituent = new int*[_numberOfConstituentsDimension] ; - for(int i=0; i<_numberOfConstituentsDimension; i++) { - int numberOf = _numberOfConstituents[i] ; - int * newArray = new int[numberOf] ; - int * oldArray = m._numberOfNodeOfEachConstituent[i] ; - for(int j=0; j - -#include -#include -#include - -#include "MEDMEM_Utilities.hxx" -#include "MEDMEM_define.hxx" - -using namespace std ; - -/*! - This class is an internal class and should not be used by the end-user. - This class describes all possible cell models and is used in order - to acces informations about geometric type of the cell : - Each object (if instancied), contains generic informations about - the cell model it describes as cell dimensions, number of nodes... -*/ - - -namespace MEDMEM { - class CELLMODEL; - MEDMEM_EXPORT ostream & operator<<(ostream &os,const CELLMODEL &my); - -class MEDMEM_EXPORT CELLMODEL -{ - -private: - /*! private method : \n - used by constructor and operator= */ - void init(const CELLMODEL &m); - - /*! private method : \n */ - void clean(); - - - //protected: - /*! explicit name (as MED_POINT1) */ - string _name; - /*! type of cell (cf define.h) */ - MED_EN::medGeometryElement _type; - /*! Cell dimension (not space dimension) */ - int _dimension; - /*! number of nodes forming this type of a cell */ - int _numberOfNodes; - /*! number of vertexes forming this type of a cell */ - int _numberOfVertexes; - /*! 2 for a 3D Cell and 1 for a 2DCell */ - int _numberOfConstituentsDimension; - /*! Array of size numberOfConstituentsDimension */ - int* _numberOfConstituents ; - /*! Array of size _numberOfConstituentsDimension - x_numberOfConstituents[i] */ - int** _numberOfNodeOfEachConstituent ; - /*! defines nodal local connectivity for each - constituents of each dimension: - should be seen as a vector> \n - - first vector : for each cell dimension - (first : dim-1, second if any : dim-2)\n - - second vector : for each constituent of - this dimension\n - - third vector : list of local nodes */ - int*** _constituents ; - MED_EN::medGeometryElement** _constituentsType ; - -public : - - /*! Constructor. */ - inline CELLMODEL(); - /*! Constructor. */ - CELLMODEL(MED_EN::medGeometryElement t); - /*! Copy constructor. */ - inline CELLMODEL(const CELLMODEL &m); - /*! Destructor. */ - inline ~CELLMODEL(); - - /*! Operator = : duplicate CELLMODEL. */ - inline CELLMODEL & operator=(const CELLMODEL &m); - - /*! Operator << : print CELLMODEL to the given stream. */ - friend MEDMEM_EXPORT ostream & operator<<(ostream &os,const CELLMODEL &my); - - /*! returns _name attribute (ie: MED_PENTA15).\n - see med.h (in med/include) */ - inline string getName() const; - - /*! returns number of vertexes forming this type of cell */ - inline int getNumberOfVertexes() const; - - /*! returns number of nodes forming this type of cell */ - inline int getNumberOfNodes() const; - - /*! returns the dimension of this type of cell.\n - it can be different from mesh dimension */ - inline int getDimension() const; - - /*! returns the geometric type of the cell. \n - see med.h (in med/include) */ - inline MED_EN::medGeometryElement getType() const; - - /*! returns all constituents which dimension is _dimension-dim.*/ - int** getConstituents(int dim) const; - - /*! returns number of constituents which dimension is _dimension-dim.*/ - int getNumberOfConstituents(int dim) const; - - /*! returns local nodes numbers vector for num-th constituent - which dimension is _dimension-dim.*/ - int* getNodesConstituent(int dim,int num) const; - - /*! returns local node number of nodes_index-th node for - num-th constituent which dimension is _dimension-dim.*/ - int getNodeConstituent(int dim,int num,int nodes_index) const; - - /*! returns types of each constituents which dimension - is _dimension-dim.*/ - MED_EN::medGeometryElement* getConstituentsType(int dim) const; - - /*! returns type of num-th constituent which dimension - is _dimension-dim.*/ - MED_EN::medGeometryElement getConstituentType(int dim,int num) const; - - /*! returns number of constituents type - (which dimension is _dimension-1).*/ - int getNumberOfConstituentsType() const; - - /*! returns all types of constituents which dimension - is (_dimension-1).*/ - set getAllConstituentsType() const; - - /*! returns number of constituents foreach type (which dimension - is _dimension-1).*/ - map getNumberOfConstituentsForeachType() const; - - -}; - -// ------------------------------------------ -// Methodes Inline -// ------------------------------------------ - -inline CELLMODEL::CELLMODEL(): - _type(MED_EN::MED_NONE), - _dimension(0), - _numberOfNodes(0), - _numberOfVertexes(0), - _numberOfConstituentsDimension(0), - _numberOfConstituents((int*)NULL), - _numberOfNodeOfEachConstituent((int**)NULL), - _constituents((int***)NULL), - _constituentsType((MED_EN::medGeometryElement**)NULL) -{ -} -inline CELLMODEL::CELLMODEL(const CELLMODEL &m): - _type(MED_EN::MED_NONE), - _dimension(0), - _numberOfNodes(0), - _numberOfVertexes(0), - _numberOfConstituentsDimension(0), - _numberOfConstituents((int*)NULL), - _numberOfNodeOfEachConstituent((int**)NULL), - _constituents((int***)NULL), - _constituentsType((MED_EN::medGeometryElement**)NULL) -{ - init(m) ; -} -inline CELLMODEL::~CELLMODEL() -{ - // MESSAGE_MED("CELLMODEL::~CELLMODEL() destroying the cell"); - clean() ; -} -inline CELLMODEL & CELLMODEL::operator=(const CELLMODEL &m) -{ - clean() ; - init(m) ; - return *this ; -} -inline string CELLMODEL::getName() const -{ - return _name ; -} -inline int CELLMODEL::getNumberOfVertexes() const -{ - return _numberOfVertexes; -} -inline int CELLMODEL::getNumberOfNodes() const -{ - return _numberOfNodes; -} -inline int CELLMODEL::getDimension() const -{ - return _dimension; -} -inline MED_EN::medGeometryElement CELLMODEL::getType() const -{ - return _type; -} -inline int** CELLMODEL::getConstituents(int dim) const -{ - return _constituents[dim-1] ; -} -inline int CELLMODEL::getNumberOfConstituents(int dim) const -{ - return _numberOfConstituents[dim-1] ; -} -inline int* CELLMODEL::getNodesConstituent(int dim,int num) const -{ - return _constituents[dim-1][num-1]; -} -inline int CELLMODEL::getNodeConstituent(int dim,int num,int nodesNumber) const -{ - return _constituents[dim-1][num-1][nodesNumber-1] ; -} -inline MED_EN::medGeometryElement* CELLMODEL::getConstituentsType(int dim) const -{ - return _constituentsType[dim-1]; -} -inline MED_EN::medGeometryElement CELLMODEL::getConstituentType(int dim,int num) const -{ - return _constituentsType[dim-1][num-1]; -} - -/*!: Utility class for storing cell models. Avoids calling the cellmodel constructor too -often. -*/ -class MEDMEM_EXPORT CELLMODEL_Map -{ -public: - static const MEDMEM::CELLMODEL& retrieveCellModel(MED_EN::medGeometryElement type); -private: - static CELLMODEL_Map *getInstance(); - static CELLMODEL_Map *_singleton; - std::map _cell_models; - - CELLMODEL_Map() {} - ~CELLMODEL_Map(){ if(_singleton) delete _singleton;} - - const MEDMEM::CELLMODEL& getCellModel(MED_EN::medGeometryElement type); - -}; - -}//End of namespace MEDMEM - -#endif /* CELLMODEL_HXX */ diff --git a/src/MEDMEM/MEDMEM_ConnectZone.cxx b/src/MEDMEM/MEDMEM_ConnectZone.cxx deleted file mode 100644 index f3589f691..000000000 --- a/src/MEDMEM/MEDMEM_ConnectZone.cxx +++ /dev/null @@ -1,280 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// few STL include files -// -#include - -// few Med Memory include files -#include "MEDMEM_define.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_SkyLineArray.hxx" -#include "MEDMEM_ConnectZone.hxx" - -using namespace MEDMEM; - - CONNECTZONE::CONNECTZONE(): - _name("") - ,_description("") - ,_localDomainNumber(0) - ,_distantDomainNumber(0) - ,_nodeCorresp(0) - ,_faceCorresp(0) - { - _entityCorresp.clear(); - } - - CONNECTZONE::~CONNECTZONE(){ - if (_nodeCorresp !=0) delete _nodeCorresp; - if (_faceCorresp !=0) delete _faceCorresp; - for (map < pair ,MEDMEM::MEDSKYLINEARRAY * >::iterator - iter = _entityCorresp.begin(); iter != _entityCorresp.end(); iter++) - { - delete iter->second; - } - } - - CONNECTZONE::CONNECTZONE(const CONNECTZONE & myConnectZone): - _name(myConnectZone._name) - ,_description(myConnectZone._description) - ,_localDomainNumber(myConnectZone._localDomainNumber) - ,_distantDomainNumber(myConnectZone._distantDomainNumber) - ,_nodeCorresp(myConnectZone._nodeCorresp) - ,_faceCorresp(myConnectZone._faceCorresp) - ,_entityCorresp(myConnectZone._entityCorresp) - { - } - string CONNECTZONE::getName() const - { - return _name; - } - string CONNECTZONE::getDescription() const - { - return _description; - } - int CONNECTZONE::getDistantDomainNumber() const - { - return _distantDomainNumber; - } - int CONNECTZONE::getLocalDomainNumber() const - { - return _localDomainNumber; - } - - MEDMEM::MESH * CONNECTZONE::getLocalMesh() const - { - return _localMesh; - } - - MEDMEM::MESH * CONNECTZONE::getDistantMesh() const - { - return _distantMesh; - } - - bool CONNECTZONE::isEntityCorrespPresent(MED_EN::medEntityMesh localEntity, - MED_EN::medEntityMesh distantEntity) const -{ - typedef map, MEDMEM::MEDSKYLINEARRAY*>::const_iterator map_iter; - - for (map_iter iter=_entityCorresp.begin(); iter != _entityCorresp.end(); iter++) - { - if ((iter->first).first==localEntity && (iter->first).second==distantEntity) - return true; - } - return false; -} - - const int * CONNECTZONE::getNodeCorrespIndex() const - { - return _nodeCorresp->getIndex(); - } - - const int * CONNECTZONE::getNodeCorrespValue() const - { - return _nodeCorresp->getValue(); - } - int CONNECTZONE::getNodeNumber() const - { - return _nodeCorresp->getNumberOf(); - } - const int * CONNECTZONE::getFaceCorrespIndex() const - { - return _faceCorresp->getIndex(); - } - - const int * CONNECTZONE::getFaceCorrespValue() const - { - return _faceCorresp->getValue(); - } - int CONNECTZONE::getFaceNumber() const - { - return _faceCorresp->getNumberOf(); - } -const int * CONNECTZONE::getEntityCorrespIndex(MED_EN::medEntityMesh localEntity, - MED_EN::medEntityMesh distantEntity) const -{ - typedef map, MEDMEM::MEDSKYLINEARRAY*>::const_iterator map_iter; - - for (map_iter iter=_entityCorresp.begin(); iter != _entityCorresp.end(); iter++) - { - if ((iter->first).first==localEntity && (iter->first).second==distantEntity) - return iter->second->getIndex(); - } - return 0; -} - -const int * CONNECTZONE::getEntityCorrespValue(MED_EN::medEntityMesh localEntity, - MED_EN::medEntityMesh distantEntity) const -{ - typedef map, MEDMEM::MEDSKYLINEARRAY*>::const_iterator map_iter; - - for (map_iter iter=_entityCorresp.begin(); iter != _entityCorresp.end(); iter++) - { - if ((iter->first).first==localEntity && (iter->first).second==distantEntity) - return iter->second->getValue(); - } - return 0; -} - -int CONNECTZONE::getEntityCorrespNumber(MED_EN::medEntityMesh localEntity, - MED_EN::medEntityMesh distantEntity) const -{ - typedef map, MEDMEM::MEDSKYLINEARRAY*>::const_iterator map_iter; - - for (map_iter iter=_entityCorresp.begin(); iter != _entityCorresp.end(); iter++) - { - if ((iter->first).first==localEntity && (iter->first).second==distantEntity) - return iter->second->getNumberOf(); - } - return 0; -} - - -int CONNECTZONE::getEntityCorrespLength(MED_EN::medEntityMesh localEntity, - MED_EN::medEntityMesh distantEntity) const -{ - typedef map, MEDMEM::MEDSKYLINEARRAY*>::const_iterator map_iter; - - for (map_iter iter=_entityCorresp.begin(); iter != _entityCorresp.end(); iter++) - { - if ((iter->first).first==localEntity && (iter->first).second==distantEntity) - return iter->second->getLength(); - } - return 0; -} - - void CONNECTZONE::setName(string name) - { - _name=name; - } - void CONNECTZONE::setDescription(string description) - { - _description=description; - } - void CONNECTZONE::setDistantDomainNumber(int distantDomainNumber) - { - _distantDomainNumber=distantDomainNumber; - } - void CONNECTZONE::setLocalDomainNumber(int localDomainNumber) - { - _localDomainNumber=localDomainNumber; - } - void CONNECTZONE::setLocalMesh(MEDMEM::MESH * localMesh) - { - _localMesh=localMesh; - } - - void CONNECTZONE::setDistantMesh(MEDMEM::MESH * distantMesh) - { - _distantMesh=distantMesh; - } - -/*! transforms an int array containing - * the node-node connections - * to a MEDSKYLINEARRAY - */ - void CONNECTZONE::setNodeCorresp(int * nodeCorresp, int nbnode) - { - int* index= new int[nbnode]; - for (int i=0; i - -// few Med Memory include files -#include "MEDMEM_STRING.hxx" -#include "MEDMEM_define.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_SkyLineArray.hxx" - -namespace MEDMEM { -class MEDMEM_EXPORT CONNECTZONE -{ -private : - string _name; - string _description; - int _localDomainNumber; - int _distantDomainNumber; - - MEDMEM::MESH * _localMesh; - MEDMEM::MESH * _distantMesh; - - MEDMEM::MEDSKYLINEARRAY * _nodeCorresp; - MEDMEM::MEDSKYLINEARRAY * _faceCorresp; - - map < pair , - MEDMEM::MEDSKYLINEARRAY * > - _entityCorresp; - -public : - CONNECTZONE(); - ~CONNECTZONE(); - CONNECTZONE(const CONNECTZONE & myConnectZone); - - string getName() const ; - string getDescription() const ; - int getDistantDomainNumber() const ; - int getLocalDomainNumber() const ; - MEDMEM::MESH * getLocalMesh() const ; - MEDMEM::MESH * getDistantMesh() const ; - - bool isEntityCorrespPresent(MED_EN::medEntityMesh localEntity, - MED_EN::medEntityMesh distantEntity) const; - const int * getNodeCorrespIndex() const; - const int * getNodeCorrespValue() const; - int getNodeNumber() const; - const int * getFaceCorrespIndex() const; - const int * getFaceCorrespValue() const; - int getFaceNumber() const; - const int * getEntityCorrespIndex(MED_EN::medEntityMesh localEntity, - MED_EN::medEntityMesh distantEntity) const; - const int * getEntityCorrespValue(MED_EN::medEntityMesh localEntity, - MED_EN::medEntityMesh distantEntity) const; - int getEntityCorrespNumber(MED_EN::medEntityMesh localEntity, - MED_EN::medEntityMesh distantEntity) const; - int getEntityCorrespLength(MED_EN::medEntityMesh localEntity, - MED_EN::medEntityMesh distantEntity) const; - void setName(string name) ; - void setDescription(string description) ; - void setDistantDomainNumber(int distantDomainNumber) ; - void setLocalDomainNumber(int distantDomainNumber) ; - void setLocalMesh(MEDMEM::MESH * localMesh) ; - void setDistantMesh(MEDMEM::MESH * distantMesh) ; - - void setNodeCorresp(int * nodeCorresp, int nbnode); - void setNodeCorresp(MEDMEM::MEDSKYLINEARRAY* array); - void setFaceCorresp(int * faceCorresp, int nbface); - void setFaceCorresp(MEDMEM::MEDSKYLINEARRAY* array); - void setEntityCorresp(MED_EN::medEntityMesh localEntity, - MED_EN::medEntityMesh distantEntity, - int * entityCorresp, int nbentity); - void setEntityCorresp(MED_EN::medEntityMesh localEntity, - MED_EN::medEntityMesh distantEntity, - MEDMEM::MEDSKYLINEARRAY* array); -}; -} -# endif diff --git a/src/MEDMEM/MEDMEM_Connectivity.cxx b/src/MEDMEM/MEDMEM_Connectivity.cxx deleted file mode 100644 index d7c7ccdcf..000000000 --- a/src/MEDMEM/MEDMEM_Connectivity.cxx +++ /dev/null @@ -1,2072 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_Connectivity.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Group.hxx" -#include "MEDMEM_CellModel.hxx" - -#include "MEDMEM_SkyLineArray.hxx" -#include "MEDMEM_ModulusArray.hxx" - -#include "MEDMEM_STRING.hxx" -#include "MEDMEM_Utilities.hxx" -#include - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -// Enlarge the vector if necessary to insert the element -static inline void insert_vector(vector &Vect, int Indice, int Element) -{ - if (Indice >=(int) Vect.capacity()) - Vect.reserve(Indice + 1000); - - if (Indice >=(int) Vect.size()) - Vect.resize(Indice+1); - - Vect[Indice] = Element; -} - -void mergeOrderedTabs(const int *tab1, int lgth1, const int *tab2, int lgth2, int *result, int& lgth); - -void mergeOrderedTabs(const int *tab1, int lgth1, const int *tab2, int lgth2, int *result, int& lgth) -{ - int cpt[2]={0,0}; - lgth=0; - unsigned char switcher=0; - const int *tabS[2]={tab1,tab2}; - while(cpt[0]tabS[switcher][cpt[switcher]]) - switcher=1-switcher; - else - { - int tmp=tabS[switcher][cpt[switcher]]; - cpt[switcher]++; cpt[1-switcher]++; - result[lgth++]=tmp; - } - } -} - -/*! - Default Constructor. /n - Default for Entity is MED_CELL and type of Connectivity is MED_NODAL */ -//--------------------------------------------------------------// -CONNECTIVITY::CONNECTIVITY(medEntityMesh Entity /* =MED_CELL */) : - //--------------------------------------------------------------// - _entity(Entity), - _typeConnectivity(MED_NODAL), - _numberOfTypes(0), - _geometricTypes((medGeometryElement*)NULL), - _type((CELLMODEL*)NULL), - _entityDimension(0), - _numberOfNodes(0), - _count((int*)NULL), - _nodal((MEDSKYLINEARRAY*)NULL), - _descending((MEDSKYLINEARRAY*)NULL), - _reverseNodalConnectivity((MEDSKYLINEARRAY*)NULL), - _reverseDescendingConnectivity((MEDSKYLINEARRAY*)NULL), - _neighbourhood((MEDSKYLINEARRAY*)NULL), - _constituent((CONNECTIVITY*)NULL), - _isDescendingConnectivityPartial(false) -{ - const char* LOC = "CONNECTIVITY(medEntityMesh Entity=MED_CELL)"; - BEGIN_OF_MED(LOC); - MESSAGE_MED("CONNECTIVITY(medEntityMesh Entity=MED_CELL)"); - _count = new int[1]; - _count[0]=1; - END_OF_MED(LOC); -} - -/*! - Constructor. /n - Default for Entity is MED_CELL */ -//------------------------------------------------------------------------------// -CONNECTIVITY::CONNECTIVITY(int numberOfTypes,medEntityMesh Entity /* =MED_CELL */): - //------------------------------------------------------------------------------// - _entity(Entity), - _typeConnectivity(MED_NODAL), - _numberOfTypes(numberOfTypes), - _entityDimension(0), - _numberOfNodes(0), - _nodal((MEDSKYLINEARRAY*)NULL), - _descending((MEDSKYLINEARRAY*)NULL), - _reverseNodalConnectivity((MEDSKYLINEARRAY*)NULL), - _reverseDescendingConnectivity((MEDSKYLINEARRAY*)NULL), - _neighbourhood((MEDSKYLINEARRAY*)NULL), - _constituent((CONNECTIVITY*)NULL), - _isDescendingConnectivityPartial(false) -{ - MESSAGE_MED("CONNECTIVITY(int numberOfTypes,medEntityMesh Entity=MED_CELL)"); - _geometricTypes = new medGeometryElement[numberOfTypes]; - _type = new CELLMODEL[numberOfTypes]; - _count = new int[numberOfTypes+1]; - _count[0]=1; - if ( numberOfTypes ) - _count[ numberOfTypes-1 ] = 0; // to know whether _count is set or not -} - -/*! - Copy Constructor. -*/ -//------------------------------------------------------// -CONNECTIVITY::CONNECTIVITY (const CONNECTIVITY & m): - //----------------------------------------------------// - _entity (m._entity), - _typeConnectivity (m._typeConnectivity), - _numberOfTypes (m._numberOfTypes), - _entityDimension (m._entityDimension), - _numberOfNodes (m._numberOfNodes), - _isDescendingConnectivityPartial(m._isDescendingConnectivityPartial) -{ - if (m._geometricTypes != NULL) - { - _geometricTypes = new medGeometryElement[_numberOfTypes]; - memcpy(_geometricTypes,m._geometricTypes,_numberOfTypes*sizeof(medGeometryElement)); - } - else - _geometricTypes = (medGeometryElement *) NULL; - - if (m._type != NULL) - { - _type = new CELLMODEL[_numberOfTypes]; - for (int i=0;i<_numberOfTypes;i++) - _type[i] = CELLMODEL(m._type[i]); - } - else - _type = (CELLMODEL *) NULL; - - if (m._count != NULL) - { - _count = new int[_numberOfTypes+1]; - memcpy(_count,m._count,(_numberOfTypes+1)*sizeof(int)); - } - else - _count = (int *) NULL; - - if (m._nodal != NULL) - _nodal = new MEDSKYLINEARRAY(* m._nodal); - else - _nodal = (MEDSKYLINEARRAY *) NULL; - - if (m._descending != NULL) - _descending = new MEDSKYLINEARRAY(* m._descending); - else - _descending = (MEDSKYLINEARRAY *) NULL; - - if (m._reverseNodalConnectivity != NULL) - _reverseNodalConnectivity = new MEDSKYLINEARRAY(* m._reverseNodalConnectivity); - else - _reverseNodalConnectivity = (MEDSKYLINEARRAY *) NULL; - - if (m._reverseDescendingConnectivity != NULL) - _reverseDescendingConnectivity = new MEDSKYLINEARRAY(* m._reverseDescendingConnectivity); - else - _reverseDescendingConnectivity = (MEDSKYLINEARRAY *) NULL; - - if (m._neighbourhood != NULL) - _neighbourhood = new MEDSKYLINEARRAY(* m._neighbourhood); - else - _neighbourhood = (MEDSKYLINEARRAY *) NULL; - - if (m._constituent != NULL) - _constituent = new CONNECTIVITY(* m._constituent); - else - _constituent = (CONNECTIVITY *) NULL; -} - -/*! - Destructor./n - desallocates existing pointers */ -//----------------------------// -CONNECTIVITY::~CONNECTIVITY() -//----------------------------// -{ - MESSAGE_MED("Destructeur de CONNECTIVITY()"); - - if (_geometricTypes != NULL) - delete [] _geometricTypes; - if (_type != NULL) - delete [] _type; - if (_count != NULL) - delete [] _count; - if (_nodal != NULL) - delete _nodal; - if (_descending != NULL) - delete _descending; - if (_reverseNodalConnectivity != NULL) - delete _reverseNodalConnectivity; - if (_reverseDescendingConnectivity != NULL) - delete _reverseDescendingConnectivity; - if (_constituent != NULL) - delete _constituent; -} - -/*! - set _constituent to Constituent - be aware desallocation of _constituent is done by CONNECTIVITY:~CONNECTIVITY - throws an exception if Constituent = MED_CELL - A DOCUMENTER -*/ -//----------------------------------------------------------// -void CONNECTIVITY::setConstituent(CONNECTIVITY * Constituent) - throw (MEDEXCEPTION) -//----------------------------------------------------------// -{ - medEntityMesh Entity = Constituent->getEntity(); - if (Entity == MED_CELL) - throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setConstituent : could not set constituent on MED_CELL !")); - - if ((Entity == MED_EDGE)&(_entityDimension == 3)) - { - if (_constituent == NULL) - throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setConstituent : Entity not found !")); - _constituent->setConstituent(Constituent); - } - else - { - delete _constituent; - _constituent = Constituent; - } -} - -/*! - Return _constituent of given entity -*/ -//----------------------------------------------------------// -const CONNECTIVITY *CONNECTIVITY::getConstituent(MED_EN::medEntityMesh Entity) const throw (MEDEXCEPTION) -//----------------------------------------------------------// -{ - if(Entity==MED_FACE && _entityDimension==3) - return _constituent; - if(Entity==MED_EDGE && _entityDimension==2) - return _constituent; - if(Entity==MED_EDGE && _entityDimension==3) - { - if ( _constituent ) - return _constituent->getConstituent(MED_EDGE); - else - throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::getConstituent : FACE connectivity not defined!")); - } - throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::getConstituent : Invalid request !")); -} - -/*! Duplicated Types array in CONNECTIVITY object. */ -//--------------------------------------------------------------------// -void CONNECTIVITY::setGeometricTypes(const medGeometryElement * Types, - const medEntityMesh Entity) - throw (MEDEXCEPTION) -//--------------------------------------------------------------------// -{ - if (Entity == _entity) - for (int i=0; i<_numberOfTypes; i++) - { - _geometricTypes[i] = Types[i]; - _type[i] = CELLMODEL(_geometricTypes[i]); - if ( _type[i].getDimension() > _entityDimension ) - _entityDimension = _type[i].getDimension(); - } - else - { - if (_constituent == NULL) - throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setGeometricTypes : Entity not found !")); - _constituent->setGeometricTypes(Types,Entity); - } -} - -/*! Set number of elements of each type of given entity */ -//--------------------------------------------------------------------// -void CONNECTIVITY::setCount(const int * Count, - const medEntityMesh Entity) - throw (MEDEXCEPTION) -//--------------------------------------------------------------------// -{ - if (Entity == _entity) - { - // this exception was added at 1.18.2.2.2.4 for NPAL17043: "Correction of - // MEDMEM CPPUNIT tests. Integrated a work of V. Bergeaud and A. Geay." - // and removed for PAL19744: "regression in MEDMEM_Connectivity.cxx" - // Commenting this exception at least looks safe as the case - // _numberOfTypes==0 is previewed here - //if (_numberOfTypes==0) - // throw MEDEXCEPTION("Number of Types was not set before setting counts"); - int * index = new int[Count[_numberOfTypes]]; - index[0]=1; - _count[0]=1; - for (int i=0; i<_numberOfTypes; i++) - { - _count[i+1] = Count[i+1]; - int NumberOfNodesPerElement = _type[i].getNumberOfNodes() ; - if ( _geometricTypes[i] != MED_POLYGON && _geometricTypes[i] != MED_POLYHEDRA ) - for (int j=_count[i]; j<_count[i+1]; j++) - index[j] = index[j-1]+NumberOfNodesPerElement; - else - index[_count[_numberOfTypes]-1] = index[_count[_numberOfTypes-1]-1]; - } - // allocate _nodal - if (_nodal != NULL) delete _nodal; - if (_numberOfTypes != 0) - { - _nodal = new MEDSKYLINEARRAY(_count[_numberOfTypes]-1,index[_count[_numberOfTypes]-1]-1); - _nodal->setIndex(index); - } - else - _nodal=0; - delete [] index; - } - else - { - if (_constituent == NULL) - throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setCount : Entity not found !")); - _constituent->setCount(Count,Entity); - } -} - -//--------------------------------------------------------------------// -void CONNECTIVITY::setNodal(const int * Connectivity, - const medEntityMesh Entity, - const medGeometryElement Type, - const int * PolyConnectivityIndex) - throw (MEDEXCEPTION) -//--------------------------------------------------------------------// -{ - if (_entity == Entity) - { - // find geometric type - bool find = false; - for (int i=0; i<_numberOfTypes; i++) - if (_geometricTypes[i] == Type) - { - if ( _count[i+1] == 0 ) - throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setNodal : " - "number of elements by type must be set before!")); - if ( _count[i+1] < _count[i] ) - throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setNodal : " - "invalid number of elements by type!")); - - find = true; - if ( Type == MED_POLYGON || Type == MED_POLYHEDRA ) - { - if (! PolyConnectivityIndex ) - throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setNodal : PolyConnectivityIndex must be provided for poly- elements !")); - if ( _numberOfTypes == 1 ) - { - delete _nodal; - _nodal = new MEDSKYLINEARRAY(_count[_numberOfTypes]-1, - PolyConnectivityIndex[_count[_numberOfTypes]-1]-1, - PolyConnectivityIndex, Connectivity); - } - else - { - // append poly connectivity to the present one - int nbpoly = getNumberOf( Entity, Type ); - int polyconnlen = PolyConnectivityIndex[nbpoly] - PolyConnectivityIndex[0]; - int newconnlen = _nodal->getLength() + polyconnlen; - // create new MEDSKYLINEARRAY - int * newconn = new int[ newconnlen ]; - int * newindex = new int[ _nodal->getNumberOf() + 1 ]; - MEDSKYLINEARRAY* newnodal = new MEDSKYLINEARRAY(_count[_numberOfTypes]-1, - newconnlen,newindex,newconn, - /*shallowCopy=*/true); - // copy old values - memcpy(newconn, _nodal->getValue(),sizeof(int)*(_nodal->getLength())); - memcpy(newindex,_nodal->getIndex(),sizeof(int)*(_nodal->getNumberOf() - nbpoly + 1)); - // append new ones - memcpy(newconn+_nodal->getLength(),Connectivity, sizeof(int)*polyconnlen); - int* polyindex = newindex + _count[i] - 1; - int delta = polyindex[0] - PolyConnectivityIndex[0]; - for( int j=0;jgetIndex(); - for( int j=_count[i];j<_count[i+1]; j++) - _nodal->setI(j,Connectivity+index[j]-index[_count[i]]); - } - } - if (!find) - throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setNodal : geometric type not found")); - } - else - { - if (_constituent == NULL) - throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setNodal : Entity not found !")); - _constituent->setNodal(Connectivity,Entity,Type,PolyConnectivityIndex); - } -} - -/*! A DOCUMENTER */ -//------------------------------------------------------------------------------------------// -void CONNECTIVITY::calculateConnectivity(medConnectivity ConnectivityType, medEntityMesh Entity) -//------------------------------------------------------------------------------------------// -{ - MESSAGE_MED("CONNECTIVITY::calculateConnectivity"); - - // a temporary limitation due to calculteDescendingConnectivity function !!! - if ((_entityDimension==3) & (Entity==MED_EDGE)) - throw MEDEXCEPTION("CONNECTIVITY::calculateConnectivity : Could not build EDGE !"); - - if (Entity==_entity) - { - if (ConnectivityType==MED_NODAL) - calculateNodalConnectivity(); - else - if (Entity==MED_CELL) - calculateDescendingConnectivity(); - else - throw MEDEXCEPTION("CONNECTIVITY::calculateConnectivity : Could not build DESCENDING !"); - } - if (Entity!=_entity) { - calculateDescendingConnectivity(); - if (_entityDimension == 2 || _entityDimension == 3) - _constituent->calculateConnectivity(ConnectivityType,Entity); - } -} - -//------------------------------------------------------------// -void CONNECTIVITY::updateFamily(const vector& myFamilies) -//------------------------------------------------------------// -{ - const char * LOC = "CONNECTIVITY::updateFamily(vector) "; - int numberOfFamilies = myFamilies.size(); - if (numberOfFamilies == 0 || _constituent == NULL) - return; - // does we do an update ? - if ((_constituent != NULL) && (_descending != NULL)) - return; - if (myFamilies[0]->getEntity() != _constituent->getEntity()) - return; - - CONNECTIVITY * oldConstituent = _constituent; - _constituent = (CONNECTIVITY *)NULL; - if (oldConstituent->_nodal==NULL) - throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"We have no nodal connectivity of sub cell")); - - const int oldNumberOfFace = oldConstituent->_nodal->getNumberOf(); - const int * oldConstituentValue = oldConstituent->_nodal->getValue(); - const int * oldConstituentIndex = oldConstituent->_nodal->getIndex(); - - int * renumberingFromOldToNew = new int [oldNumberOfFace+1]; - - calculateDescendingConnectivity();//perform calculation of descending connectivity to update all connectivities after having taken into account of direction of faces... - _constituent->calculateReverseNodalConnectivity();//getting d-1 nodal connectivity to get new face numbers from nodes numbers... - - const int * reverseFaceNodal = _constituent->getReverseNodalConnectivity(); - const int * reverseFaceNodalIndex = _constituent->getReverseNodalConnectivityIndex(); - - CELLMODEL * aCELLMODEL = &oldConstituent->_type[0]; - //int newNumberOfFaces = _constituent->getNumberOf(_constituent->getEntity(),MED_ALL_ELEMENTS); - for ( int iOldFace = 0; iOldFace < oldNumberOfFace; iOldFace++ ) - { - // Retrieving new number of iOldFace face... - - const int *nodesOfCurrentFaceOld=oldConstituentValue+oldConstituentIndex[iOldFace]-1; - int nbOfNodesOfCurrentFaceOld=oldConstituentIndex[iOldFace+1]-oldConstituentIndex[iOldFace]; - - // get all faces (newFaceNb) around the first node of iOldFace - int sizeOfNewFaceNb=reverseFaceNodalIndex[nodesOfCurrentFaceOld[0]]-reverseFaceNodalIndex[nodesOfCurrentFaceOld[0]-1]; - int *newFaceNb=new int[sizeOfNewFaceNb]; - memcpy(newFaceNb,reverseFaceNodal+reverseFaceNodalIndex[nodesOfCurrentFaceOld[0]-1]-1,sizeOfNewFaceNb*sizeof(int));//all faces candidates are in newFaceNb !!! - - // loop on the rest nodes of iOldFace to find, among newFaceNb, a sole face including all nodes - for(int curNode=1;curNode1;curNode++) - { - const int *newFacesNbForCurNode=reverseFaceNodal+reverseFaceNodalIndex[nodesOfCurrentFaceOld[curNode]-1]-1; - int sizeOfNewFacesNbForCurNode=reverseFaceNodalIndex[nodesOfCurrentFaceOld[curNode]]-reverseFaceNodalIndex[nodesOfCurrentFaceOld[curNode]-1]; - for(int i=0; igetConnectivityOfAnElement(MED_NODAL,_constituent->getEntity(), renumberingFromOldToNew[iOldFace], nbOfNodesOfCurrentFaceNew ); - if ( aCELLMODEL && aCELLMODEL->getNumberOfNodes() != nbOfNodesOfCurrentFaceOld ) - { - // type changed, find a corresponding CELLMODEL - int iType = 2; // 1-st type is already used at loop beginning - while ( iOldFace + 1 >= oldConstituent->_count[ iType ]) // check next type - ++iType; - if ( oldConstituent->_numberOfTypes >= iType && - oldConstituent->_type[ iType-1 ].getNumberOfNodes() > 0 ) - aCELLMODEL = &oldConstituent->_type[ iType-1 ]; - else - aCELLMODEL = 0; - } - int nbOfVertices = aCELLMODEL ? aCELLMODEL->getNumberOfVertexes() : nbOfNodesOfCurrentFaceOld; - MEDMODULUSARRAY modulusArrayOld(nbOfVertices,nbOfNodesOfCurrentFaceOld,nodesOfCurrentFaceOld); - int nbOfVerticesNew = std::min( nbOfVertices, nbOfNodesOfCurrentFaceNew ); - MEDMODULUSARRAY modulusArrayNew(nbOfVerticesNew,nbOfNodesOfCurrentFaceNew,nodesOfCurrentFaceNew); - int retCompareNewOld=modulusArrayNew.compare(modulusArrayOld); - if(retCompareNewOld==0) - throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"Uncompatible given user face with calculated existing faces")); - if(retCompareNewOld==-1) - invertConnectivityForAFace(renumberingFromOldToNew[iOldFace],nodesOfCurrentFaceOld); - } - - // Updating the Family - for(vector::const_iterator iter=myFamilies.begin();iter!=myFamilies.end();iter++) - (*iter)->changeElementsNbs(_constituent->getEntity(), renumberingFromOldToNew); - - // FIX PAL13414: - if ( _constituent && !_constituent->_constituent ) { - _constituent->_constituent = oldConstituent->_constituent; - oldConstituent->_constituent = NULL; - } - // END FIX PAL13414: - - delete oldConstituent; - delete [] renumberingFromOldToNew; - return; -} - -/*! Give descending or nodal connectivity. - - You must give a %medEntityMesh (ie:MED_EDGE) - and a %medGeometryElement (ie:MED_SEG3). */ -//---------------------------------------------------------------------------------// -const int * MEDMEM::CONNECTIVITY::getConnectivity(medConnectivity ConnectivityType, - medEntityMesh Entity, - medGeometryElement Type) const -//----------------------------------------------------------------------------------// -{ - const char * LOC = "CONNECTIVITY::getConnectivity"; - // BEGIN_OF_MED(LOC); - - MEDSKYLINEARRAY * Connectivity; - if (Entity==_entity) { - - if (ConnectivityType==MED_NODAL) - { - calculateNodalConnectivity(); - Connectivity=_nodal; - } - else - { - calculateDescendingConnectivity(); - Connectivity=_descending; - } - - if (Connectivity!=NULL) - if (Type==MED_ALL_ELEMENTS) - return Connectivity->getValue(); - else { - for (int i=0; i<_numberOfTypes; i++) - if (_geometricTypes[i]==Type) - //return Connectivity->getI(i+1); - return Connectivity->getI(_count[i]); - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Type not found !")); - } - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Connectivity not defined !")); - } else - if (_constituent != NULL) - return _constituent->getConnectivity(ConnectivityType,Entity,Type); - - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !")); -} - -//-------------------------------------------------------------------------- -int CONNECTIVITY::getConnectivityLength(medConnectivity ConnectivityType, - medEntityMesh Entity, - medGeometryElement Type) const -//-------------------------------------------------------------------------- -{ - const char * LOC = "CONNECTIVITY::getConnectivity"; - BEGIN_OF_MED(LOC); - - MEDSKYLINEARRAY * Connectivity; - if (Entity == _entity) { - if (ConnectivityType == MED_NODAL) - { - calculateNodalConnectivity(); - Connectivity = _nodal; - } - else - { - calculateDescendingConnectivity(); - Connectivity = _descending; - } - - if (Connectivity != NULL) { - if (Type == MED_ALL_ELEMENTS) { - return Connectivity->getLength(); - } - else { - for (int i=0; i<_numberOfTypes; i++) - if (_geometricTypes[i]==Type) - // issue 19983 - //return (_count[i+1]-_count[i])*getType(Type).getNumberOfNodes(); - { - const int *ind=Connectivity->getIndex(); - return ind[_count[i+1]-1]-ind[_count[i]-1]; - } - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Type not found !")); - } - } - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Connectivity not defined !")); - } - else - if (_constituent != NULL) - return _constituent->getConnectivityLength(ConnectivityType,Entity,Type); - - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !")); -} - -/*! Give morse index array to use with - getConnectivity(mode,entity,MED_ALL_ELEMENTS). - - Each value give start index for corresponding entity in connectivity array. - - Example : i-th element, j-th node of it : - - In C mode : Connectivity[ConnectivityIndex[i]-1+j-1] - - In fortran mode : Connectivity[ConnectivityIndex[i]+j] */ -//-----------------------------------------------------------------------------------------------// -const int * CONNECTIVITY::getConnectivityIndex(medConnectivity ConnectivityType, - medEntityMesh Entity) const -//-----------------------------------------------------------------------------------------------// -{ - const char * LOC = "CONNECTIVITY::getConnectivityIndex"; - - MEDSKYLINEARRAY * Connectivity; - if (Entity==_entity) { - - if (ConnectivityType==MED_NODAL) - Connectivity=_nodal; - else - Connectivity=_descending; - - if (Connectivity!=NULL) - return Connectivity->getIndex(); - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Connectivity not defined !")); - - } else - if (_constituent != NULL) - return _constituent->getConnectivityIndex(ConnectivityType,Entity); - - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !")); -} - - -/*! - * \brief Returns CELLMODEL of a given geometrical type - */ -//--------------------------------------------------------------// -const CELLMODEL & CONNECTIVITY::getType(medGeometryElement Type) const -//--------------------------------------------------------------// -{ - - if ((Type==MED_ALL_ELEMENTS) || (Type==MED_NONE)) - throw MEDEXCEPTION("CONNECTIVITY::getType : medGeometryElement must be different of MED_ALL_ELEMENTS and MED_NONE !"); - for (int i=0; i<_numberOfTypes; i++) - if (_geometricTypes[i]==Type) - return _type[i]; - throw MEDEXCEPTION("CONNECTIVITY::getType : medGeometryElement not found !"); -} - -/*! Returns the number of elements of type %medGeometryElement. - Note : not implemented for MED_ALL_ELEMENTS nor for MED_NONE */ -//------------------------------------------------------------------------// -int CONNECTIVITY::getNumberOfNodesInType(medGeometryElement Type) const -//------------------------------------------------------------------------// -{ - const char * LOC = "CONNECTIVITY::getNumberOfNodesInType"; - BEGIN_OF_MED(LOC); - - if ((Type==MED_ALL_ELEMENTS) || (Type==MED_NONE)) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement must be different of MED_ALL_ELEMENTS and MED_NONE!")); - for (int i=0; i<_numberOfTypes; i++) - if (_geometricTypes[i]==Type) - return _type[i].getNumberOfNodes(); - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement not found !")); -} - -/*! Returns the number of geometric sub cells of %medGeometryElement type. - not implemented for MED_ALL_ELEMENTS nor for MED_NONE */ -//------------------------------------------------------------------------// -int CONNECTIVITY::getNumberOfSubCellInType(medGeometryElement Type) const -//------------------------------------------------------------------------// -{ - if ((Type==MED_ALL_ELEMENTS) || (Type==MED_NONE)) - throw MEDEXCEPTION("CONNECTIVITY::getNumberOfSubCell : medGeometryElement must be different of MED_ALL_ELEMENTS and MED_NONE!"); - for (int i=0; i<_numberOfTypes; i++) - if (_geometricTypes[i]==Type) - return _type[i].getNumberOfConstituents(1); - throw MEDEXCEPTION("CONNECTIVITY::getNumberOfSubCell : medGeometryElement not found !"); -} - -/*! Returns the number of elements of type %medGeometryElement. - - Note : - - Implemented for MED_ALL_ELEMENTS - - Not implemented for MED_ALL_ENTITIES (A VERIFIER) - - Not implemented for MED_NONE */ -//-----------------------------------------------------------------------------------// -int CONNECTIVITY::getNumberOf(medEntityMesh Entity, medGeometryElement Type) const -//-----------------------------------------------------------------------------------// -{ - if(Entity==MED_EN::MED_NODE) - return _numberOfNodes; - if (Entity==_entity) { - if (Type==MED_EN::MED_NONE) - return 0; // not defined ! - //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement must be different of MED_NONE")); - if (!existConnectivity(MED_NODAL,Entity) && !existConnectivity(MED_DESCENDING,Entity)) - return 0; - if (Type==MED_EN::MED_ALL_ELEMENTS) - return _count[_numberOfTypes]-1; - for (int i=0; i<_numberOfTypes; i++) - if (_geometricTypes[i]==Type) - return (_count[i+1] - _count[i]); - //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement not found !")); - } else - if (_constituent != NULL) - return _constituent->getNumberOf(Entity,Type); - - return 0; // valid if they are nothing else ! - //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !")); -} - -/*! A DOCUMENTER */ -//--------------------------------------------------------------// -const int* CONNECTIVITY::getValue(medConnectivity TypeConnectivity, - medGeometryElement Type) const -//--------------------------------------------------------------// -{ - if (TypeConnectivity == MED_NODAL) - { - calculateNodalConnectivity(); - if (Type==MED_ALL_ELEMENTS) - return _nodal->getValue(); - for (int i=0; i<_numberOfTypes; i++) - if (_geometricTypes[i]==Type) - return _nodal->getI(_count[i]); - } - else - { - calculateDescendingConnectivity(); - if (Type==MED_ALL_ELEMENTS) - return _descending->getValue(); - for (int i=0; i<_numberOfTypes; i++) - if (_geometricTypes[i]==Type) - return _descending->getI(_count[i]); - } - throw MEDEXCEPTION("Not found"); -} - -/*! A DOCUMENTER */ -//---------------------------------------------------------------------// -const int* CONNECTIVITY:: getValueIndex(medConnectivity TypeConnectivity) const -//---------------------------------------------------------------------// -{ - if (TypeConnectivity == MED_NODAL) - { - calculateNodalConnectivity(); - return _nodal->getIndex(); - } - else - { - calculateDescendingConnectivity(); - return _descending->getIndex(); - } -} - -/*! Not yet implemented */ -//----------------------------------------------// -const int* CONNECTIVITY:: getNeighbourhood() const -//----------------------------------------------// -{ - throw MEDEXCEPTION("CONNECTIVITY::getNeighbourhood : Not implemented"); -} - -/*! Returns an array which contains, for each node, all cells - arround it. */ -//-------------------------------------------------// -const int* CONNECTIVITY::getReverseNodalConnectivity() const -//-------------------------------------------------// -{ - calculateReverseNodalConnectivity(); - return _reverseNodalConnectivity->getValue(); -} - -/*! Give index array to use with getReverseConnectivity(MED_NODAL). - It is unusefull with MED_DESCENDING mode, because we have allways two cells. */ -//-------------------------------------------------------// -const int* CONNECTIVITY::getReverseNodalConnectivityIndex() const -//-------------------------------------------------------// -{ - calculateReverseNodalConnectivity(); - return _reverseNodalConnectivity->getIndex(); -} - -/*! Returns an array which contains, for each face (or edge), - the 2 cells of each side. First is cell which face normal is outgoing. - arround it. */ -//------------------------------------------------------// -const int* CONNECTIVITY::getReverseDescendingConnectivity() const -//------------------------------------------------------// -{ - // it is in _constituent connectivity only if we are in MED_CELL - // (we could not for instance calculate face-edge connectivity !) - if (_entity!=MED_CELL) - throw MEDEXCEPTION("CONNECTIVITY::getReverseDescendingConnectivity : Error Only in MED_CELL connectivity"); - - // we need descending connectivity - calculateDescendingConnectivity(); - if (_reverseDescendingConnectivity==NULL) - _reverseDescendingConnectivity=_descending->makeReverseArray(); - - return _reverseDescendingConnectivity->getValue(); -} - -/*! calculate the reverse descending Connectivity - and returns the index ( A DOCUMENTER MIEUX)*/ -//-----------------------------------------------------------// -const int* CONNECTIVITY::getReverseDescendingConnectivityIndex() const -//-----------------------------------------------------------// -{ - // it is in _constituent connectivity only if we are in MED_CELL - if (_entity!=MED_CELL) - throw MEDEXCEPTION("CONNECTIVITY::getReverseDescendingConnectivityIndex : Error Only in MED_CELL connectivity"); - - // we need descending connectivity - calculateDescendingConnectivity(); - return _reverseDescendingConnectivity->getIndex(); -} - -/*! A DOCUMENTER (et a finir ???) */ -//--------------------------------------------// -void CONNECTIVITY::calculateNodalConnectivity() const -//--------------------------------------------// -{ - if (_nodal==NULL) - { - if (_descending==NULL) - throw MEDEXCEPTION("CONNECTIVITY::calculateNodalConnectivity : No connectivity found !"); - // calculate _nodal from _descending - } -} - -/*! If not yet done, calculate the nodal Connectivity - and the reverse nodal Connectivity*/ -//---------------------------------------------------// -void CONNECTIVITY::calculateReverseNodalConnectivity() const -//---------------------------------------------------// -{ - const char* LOC = "CONNECTIVITY::calculateReverseNodalConnectivity : "; - BEGIN_OF_MED(LOC); - - SCRUTE_MED(_nodal); - SCRUTE_MED(_reverseNodalConnectivity); - - if (_nodal==NULL) - calculateNodalConnectivity(); - - if(_reverseNodalConnectivity==NULL) - { - vector > reverse_connectivity; - reverse_connectivity.resize(_numberOfNodes+1); - - // Treat all cells types - - const int *index=_nodal->getIndex(); - const int *conn =_nodal->getValue(); - int cell_number=1; - for (int j = 0; j < _numberOfTypes; j++) - { - for (int k = _count[j]; k < _count[j+1]; k++, cell_number++) - { - // node number of the cell - int nb_nodes = index[ cell_number ] - index[ cell_number-1 ]; - if ( _geometricTypes[ j ] == MED_EN::MED_POLYHEDRA ) - { - set nodes( conn, conn + nb_nodes ); - set::iterator n = nodes.begin(); - if ( *n == -1 ) ++n; - for ( ; n != nodes.end(); ++n ) - reverse_connectivity[ *n ].push_back( cell_number ); - conn += nb_nodes; - } - else - { - for (int i = 0; i < nb_nodes; ++i, ++conn) - reverse_connectivity[ *conn ].push_back( cell_number ); - } - } - } - - // Full reverse_nodal_connectivity and reverse_nodal_connectivity_index - - //calculate size of reverse_nodal_connectivity array - int size_reverse_nodal_connectivity = 0; - for (int i = 1; i < _numberOfNodes+1; i++) - size_reverse_nodal_connectivity += reverse_connectivity[i].size(); - - int * reverse_nodal_connectivity_index = new int[_numberOfNodes+1]; - int * reverse_nodal_connectivity = new int[size_reverse_nodal_connectivity]; - - reverse_nodal_connectivity_index[0] = 1; - for (int i = 1; i < _numberOfNodes+1; i++) - { - int size = reverse_connectivity[i].size(); - reverse_nodal_connectivity_index[i] = reverse_nodal_connectivity_index[i-1] + size; - for (int j = 0; j < size; j++) - reverse_nodal_connectivity[reverse_nodal_connectivity_index[i-1]-1+j]= reverse_connectivity[i][j]; - } - - _reverseNodalConnectivity = new MEDSKYLINEARRAY(_numberOfNodes,size_reverse_nodal_connectivity, - reverse_nodal_connectivity_index, - reverse_nodal_connectivity,true); - } - END_OF_MED(LOC); -} - -/*! If not yet done, calculate the Descending Connectivity */ -//-------------------------------------------------// -void CONNECTIVITY::calculateDescendingConnectivity() const -//-------------------------------------------------// -{ - const char * LOC = "CONNECTIVITY::calculateDescendingConnectivity() : "; - BEGIN_OF_MED(LOC); - - if (_descending==NULL) - { - if (_nodal==NULL) - { - MESSAGE_MED(LOC<<"No connectivity found !"); - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"No connectivity found !")); - } - // calcul _descending from _nodal - // we need CONNECTIVITY for constituent - - if (_constituent != NULL && _constituent->_nodal != NULL) - { - const_cast(this)->calculatePartialDescendingConnectivity(); - } - else - { - const_cast(this)->calculateFullDescendingConnectivity(_entity); - } - } -} - -/*! If not yet done, calculate the full Descending Connectivity */ -//-------------------------------------------------// -void CONNECTIVITY::calculateFullDescendingConnectivity(MED_EN::medEntityMesh Entity) -//-------------------------------------------------// -{ - const char * LOC = "CONNECTIVITY::calculateFullDescendingConnectivity() : "; - BEGIN_OF_MED(LOC); - if (_entity != Entity) - { - if (_constituent == NULL) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Entity not found !")); - _constituent->calculateFullDescendingConnectivity(Entity); - } - else - { - if ( _descending==NULL || _isDescendingConnectivityPartial ) - { - if (_nodal==NULL ) - { - MESSAGE_MED(LOC<<"No connectivity found !"); - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"No connectivity found !")); - } - delete _constituent; - _constituent=0; - if (_entityDimension == 3) - _constituent = new CONNECTIVITY(MED_FACE); - else if (_entityDimension == 2) - _constituent = new CONNECTIVITY(MED_EDGE); - else - { - MESSAGE_MED(LOC<<"We are in 1D"); - return; - } - - bool hasPoly = ( _numberOfTypes && _geometricTypes[_numberOfTypes-1] == ( _entityDimension > 2 ? MED_POLYHEDRA : MED_POLYGON )); - int numberOfClassicTypes = _numberOfTypes - hasPoly; - - _constituent->_typeConnectivity = MED_NODAL; - _constituent->_numberOfNodes = _numberOfNodes; - // foreach cells, we built array of constituent - int DescendingSize = 0; - for(int i=0; i0) - descend_connectivity_index[0]=1; - - - map eltsCounter; - medGeometryElement ConstituentsTypes[2] = { MED_NONE, MED_NONE }; - int NumberOfConstituentsForeachType [2] = { 0, 0 }; - map::iterator status; - for(int i=0; isecond++; // increment zero or that there was - } - if(eltsCounter.size()>2) - { - // free memory (issue 0020411: [CEA 342] Sigsegv on gibi writing of MESH coming from MED file without face computation) - delete [] descend_connectivity; - delete [] descend_connectivity_index; - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Descending connectivity does not support more than 2 types.")); - } - status=eltsCounter.begin(); - if(!eltsCounter.empty()) - { - ConstituentsTypes[0]=(*status).first; NumberOfConstituentsForeachType[0]=(*status).second; - if(++status!=eltsCounter.end()) - ConstituentsTypes[1]=(*status).first, NumberOfConstituentsForeachType[1]=(*status).second; - } - int TotalNumberOfConstituents = NumberOfConstituentsForeachType[0]+NumberOfConstituentsForeachType[1]; - int TotalNumberOfNodes = NumberOfConstituentsForeachType[0]*(ConstituentsTypes[0]%100)+NumberOfConstituentsForeachType[1]*(ConstituentsTypes[1]%100); - - int * ConstituentNodalConnectivity = new int[TotalNumberOfNodes]; - int * ConstituentNodalConnectivityIndex = new int[TotalNumberOfConstituents+1]; - ConstituentNodalConnectivityIndex[0]=1; - - _constituent->_entityDimension = _entityDimension-1; - int nbClassicConstituentTypes = eltsCounter.size(); - int nbConstituentTypes = nbClassicConstituentTypes + hasPoly; - _constituent->_numberOfTypes = nbConstituentTypes; - _constituent->_geometricTypes = new medGeometryElement[_constituent->_numberOfTypes]; - _constituent->_type = new CELLMODEL[_constituent->_numberOfTypes]; - if(_constituent->_count) delete [] _constituent->_count; - _constituent->_count = new int[_constituent->_numberOfTypes+1]; - _constituent->_count[0]=1; - med_int* tmp_NumberOfConstituentsForeachType = new med_int[nbClassicConstituentTypes+1]; - tmp_NumberOfConstituentsForeachType[0]=0; // to count constituent of each type - for (int i=0; i_geometricTypes[i]=ConstituentsTypes[i]; - _constituent->_type[i]=CELLMODEL(ConstituentsTypes[i]); - _constituent->_count[i+1]=_constituent->_count[i]+NumberOfConstituentsForeachType[i]; - tmp_NumberOfConstituentsForeachType[i+1]=NumberOfConstituentsForeachType[i]; - for (int j=tmp_NumberOfConstituentsForeachType[i]; jgetIndex(); - const int * ReverseNodalConnectivityValue = _reverseNodalConnectivity->getValue(); - - // array to keep reverse descending connectivity - int * ReverseDescendingConnectivityValue = new int[TotalNumberOfConstituents*2]; - - int TotalNumberOfSubCell = 0; - for (int i=0; i_geometricTypes[0]) - { - tmp_NumberOfConstituentsForeachType[0]++; - TotalNumberOfSubCell=tmp_NumberOfConstituentsForeachType[0]; - } else - { - tmp_NumberOfConstituentsForeachType[1]++; - TotalNumberOfSubCell=tmp_NumberOfConstituentsForeachType[1]; - } - //we have maximum two types - - descend_connectivity[descend_connectivity_index[j-1]+k-2]=TotalNumberOfSubCell; - ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2]=j; - - int NumberOfNodesPerConstituent = Type.getConstituentType(1,k)%100; - int * NodesLists = new int[NumberOfNodesPerConstituent]; - for (int l=0; lgetIJ(j,Type.getNodeConstituent(1,k,l+1)); - ConstituentNodalConnectivity[ConstituentNodalConnectivityIndex[TotalNumberOfSubCell-1]-1+l]=NodesLists[l]; - } - // we use reverse_nodal_connectivity to find the other element which contain this sub cell - - // all elements which contains first node of sub cell : - int ReverseNodalConnectivityIndex_0 = ReverseNodalConnectivityIndex[NodesLists[0]-1]; - int ReverseNodalConnectivityIndex_1 = getIndexOfEndClassicElementInReverseNodal(ReverseNodalConnectivityValue,ReverseNodalConnectivityIndex,NodesLists[0]-1); - //ReverseNodalConnectivityIndex[NodesLists[0]]; - int NumberOfCellsInList = ReverseNodalConnectivityIndex_1-ReverseNodalConnectivityIndex_0; - - if (NumberOfCellsInList > 0) - { // we could have no element ! - int * CellsList = new int[NumberOfCellsInList]; - for (int l=ReverseNodalConnectivityIndex_0; l 0) { // We have found some elements ! - int CellNumber = CellsList[0]; - //delete [] CellsList; - if (NumberOfCellsInList>1) { - // free memory (issue 0020411: [CEA 342] Sigsegv on gibi writing of MESH coming from MED file without face computation) - delete [] CellsList; - delete [] NodesLists; - delete [] ReverseDescendingConnectivityValue; - delete [] tmp_NumberOfConstituentsForeachType; - delete [] descend_connectivity; - delete [] descend_connectivity_index; - delete [] ConstituentNodalConnectivity; - delete [] ConstituentNodalConnectivityIndex; - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"More than one other Cell ("<getIJ(CellNumber,Type2.getNodeConstituent(1,l,m)) == NodesLists[n-1]) - counter++; - } - if (counter==Type.getConstituentType(1,k)%100) - { - descend_connectivity[descend_connectivity_index[CellNumber-1]+l-2]=-1*TotalNumberOfSubCell; // because, see it in other side ! - find2 = true; - } - if (find2) - break; - } - if (!find2) - MESSAGE_MED(LOC<<"ERROR ERROR ERROR ERROR ERROR : we find any subcell !!!"); // exception ? - } - } else { - ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2+1]=0; - } - delete [] CellsList; - } - - delete [] NodesLists; - } - } - } - // we adjust _constituent - int NumberOfConstituent=0; - int SizeOfConstituentNodal=0; - for (int i=0;i_count[i]+1; - SizeOfConstituentNodal += (tmp_NumberOfConstituentsForeachType[i]-_constituent->_count[i]+1)*_constituent->_type[i].getNumberOfNodes(); - } - // we built new _nodal attribute in _constituent - //MEDSKYLINEARRAY *ConstituentNodal = new MEDSKYLINEARRAY(NumberOfConstituent,SizeOfConstituentNodal); - //const int *ConstituentNodalValue = ConstituentNodal->getValue(); - //const int *ConstituentNodalIndex = ConstituentNodal->getIndex(); - int *ConstituentNodalValue = new int[SizeOfConstituentNodal]; - int *ConstituentNodalIndex = new int[NumberOfConstituent+1]; - ConstituentNodalIndex[0]=1; - // we build _reverseDescendingConnectivity - //_reverseDescendingConnectivity = new MEDSKYLINEARRAY(NumberOfConstituent,2*NumberOfConstituent); - //const int *reverseDescendingConnectivityValue = _reverseDescendingConnectivity->getValue(); - //const int *reverseDescendingConnectivityIndex = _reverseDescendingConnectivity->getIndex(); - int *reverseDescendingConnectivityValue = new int[2*NumberOfConstituent]; - int *reverseDescendingConnectivityIndex = new int[NumberOfConstituent+1]; - reverseDescendingConnectivityIndex[0]=1; - - // first constituent type - for(int j=0; j_count[1]-tmp_NumberOfConstituentsForeachType[0]-1; - int offset1=offset*_constituent->_type[0].getNumberOfNodes(); - int offset2=offset*2; - int NumberOfNodesPerConstituent = _constituent->_type[1].getNumberOfNodes(); - for(int j=tmp_NumberOfConstituentsForeachType[0]; j_count[2]=NumberOfConstituent+1; - // we correct _descending to adjust face number - for(int j=0;jtmp_NumberOfConstituentsForeachType[0]) { - if ( descend_connectivity[j] > 0 ) - descend_connectivity[j]-=offset; - else - descend_connectivity[j]+=offset; - } - } - - delete [] ConstituentNodalConnectivityIndex; - delete [] ConstituentNodalConnectivity; - delete [] ReverseDescendingConnectivityValue; - if (_constituent->_numberOfTypes > 0) - _constituent->_count[1]=tmp_NumberOfConstituentsForeachType[0]+1; - delete [] tmp_NumberOfConstituentsForeachType; - - //// - vector Descending( descend_connectivity, descend_connectivity + DescendingSize ); - vector DescendingIndex( descend_connectivity_index, descend_connectivity_index + _count[numberOfClassicTypes] ); - vector Reversedescendingconnectivityvalue(reverseDescendingConnectivityValue,reverseDescendingConnectivityValue + 2*NumberOfConstituent); - vector Reversedescendingconnectivityindex(reverseDescendingConnectivityIndex,reverseDescendingConnectivityIndex + NumberOfConstituent); - delete [] descend_connectivity; - delete [] descend_connectivity_index; - delete [] reverseDescendingConnectivityValue; - delete [] reverseDescendingConnectivityIndex; - - - // polygons (2D mesh) - - vector Constituentnodalvalue(ConstituentNodalValue,ConstituentNodalValue + SizeOfConstituentNodal); - vector Constituentnodalindex(ConstituentNodalIndex,ConstituentNodalIndex + NumberOfConstituent+1); - delete [] ConstituentNodalValue; - delete [] ConstituentNodalIndex; - int NumberOfNewSeg = 0; - - int i = _count[_numberOfTypes - ( hasPoly && _entityDimension == 2 )]; - int NumberOfPolygons = _count[_numberOfTypes] - i; - for (; i < _count[_numberOfTypes]; i++) // for each polygon - { - const int * vector_begin = _nodal->getValue() + _nodal->getIndex()[i-1] - 1; - int vector_size = _nodal->getIndex()[i]-_nodal->getIndex()[i-1]; - vector myPolygon(vector_begin, vector_begin+vector_size); - myPolygon.push_back(myPolygon[0]); - DescendingIndex.push_back( DescendingIndex.back() + vector_size); - for (int j=0; j<(int)myPolygon.size()-1; j++) // for each segment of polygon - { - MEDMODULUSARRAY segment_poly(2,&myPolygon[j]); - int ret_compare = 0; - - // we search it in existing segments - - for (int k=0; k<(int)Constituentnodalindex.size()-1; k++) - { - MEDMODULUSARRAY segment(2,&Constituentnodalvalue[0] + Constituentnodalindex[k]-1); - ret_compare = segment_poly.compare(segment); - if (ret_compare) // segment_poly already exists - { - Descending.push_back(ret_compare*(k+1)); // we had it to the connectivity - insert_vector(Reversedescendingconnectivityvalue, 2*k+1, i); // add polygon i to reverse descending connectivity for segment_poly (in 2nd place) - break; - } - } - - // segment_poly must be created - - if (!ret_compare) - { - NumberOfNewSeg++; - Descending.push_back(NumberOfConstituent+NumberOfNewSeg); // we had it to the connectivity - Constituentnodalvalue.push_back(segment_poly[0]); - Constituentnodalvalue.push_back(segment_poly[1]); - Constituentnodalindex.push_back(Constituentnodalindex[Constituentnodalindex.size()-1] + 2); // we have only segments - insert_vector(Reversedescendingconnectivityvalue, 2*(NumberOfConstituent+NumberOfNewSeg-1), i ); // add polygon i to reverse descending connectivity for segment_poly (in 1st place) - insert_vector(Reversedescendingconnectivityindex, NumberOfConstituent+NumberOfNewSeg-1, 2*(NumberOfConstituent+NumberOfNewSeg-1)+1); // idem with index - } - } - } - - if ( NumberOfPolygons > 0 ) - { - NumberOfConstituent += NumberOfNewSeg; - SizeOfConstituentNodal += 2*NumberOfNewSeg; - } - - // polyhedron (3D mesh) - - vector Constituentpolygonsnodalvalue; - vector Constituentpolygonsnodalindex(1,1); - int NumberOfNewFaces = 0; // by convention new faces are polygons - //offset to switch between all types and classical types. - //int offsetCell = getNumberOf(MED_CELL, MED_ALL_ELEMENTS); - int *tabRes = new int[1000]; //temporay array for intersection calculation - - i = _count[_numberOfTypes - ( hasPoly && _entityDimension == 3 )]; - int NumberOfPolyhedron = _count[_numberOfTypes] - i; - for (; i<_count[_numberOfTypes]; i++) // for each polyhedron - { - const int * nodes = _nodal->getValue() + _nodal->getIndex()[i-1] - 1; - const int * nodesEnd = _nodal->getValue() + _nodal->getIndex()[i ] - 1; - int nbConstituentFaces = 0; - while ( nodes < nodesEnd ) // loop on faces of polyhedron - { - // look for end of face connectivity - const int * faceNodesEnd = nodes; - while ( ++faceNodesEnd < nodesEnd && *faceNodesEnd != -1 ); - int myFaceNumberOfNodes = faceNodesEnd - nodes; - MEDMODULUSARRAY face_poly(myFaceNumberOfNodes,nodes); - // move pointer to next face while continue working with face_poly - if (( nodes = faceNodesEnd ) < nodesEnd ) - nodes++; // skip face separator - - nbConstituentFaces++; - - int ret_compare = 0; - - // we search it in existing faces - - // we search first in TRIA3 and QUAD4 - if (myFaceNumberOfNodes == 3 || myFaceNumberOfNodes == 4) - { - int Begin = -1; // first TRIA3 or QUAD4 - int Number = 0; // number of TRIA3 or QUAD4 - for (int k=0; k<(int)Constituentnodalindex.size()-1; k++) - if (Constituentnodalindex[k+1]-Constituentnodalindex[k] == myFaceNumberOfNodes) - { - if (Begin == -1) - Begin = k; - Number++; - } - - for (int k=0; k 2 should never happend : A face is shared by more than 2 polyhedrons... - { - if (tabRes[0] == i) //as tabRes is ordered by construction tabRes[1] > tabRes[0] so the current - // face is shared with an another cell whose id > current id. So let's create - ret_compare=0; - else - {//tabRes[0] 0) - { - NumberOfConstituent += NumberOfNewFaces; - Constituentnodalvalue.insert( Constituentnodalvalue.end(), - Constituentpolygonsnodalvalue.begin(), - Constituentpolygonsnodalvalue.end()); - Constituentpolygonsnodalvalue.clear(); - Constituentnodalindex.reserve( Constituentnodalindex.size() + NumberOfNewFaces ); - int indexShift = Constituentnodalindex.back() - Constituentpolygonsnodalindex.front(); - for ( unsigned i = 1; i < Constituentpolygonsnodalindex.size(); ++i ) - Constituentnodalindex.push_back( Constituentpolygonsnodalindex[i] + indexShift ); - Constituentpolygonsnodalindex.clear(); - _constituent->_geometricTypes[ _constituent->_numberOfTypes-1 ] = MED_POLYGON; - } - - _constituent->_count[ _constituent->_numberOfTypes ] = NumberOfConstituent+1; - _constituent->_nodal = new MEDSKYLINEARRAY(NumberOfConstituent, - Constituentnodalvalue.size(), - &Constituentnodalindex[0], - &Constituentnodalvalue[0]); - - if(_descending) - delete _descending; - _descending = new MEDSKYLINEARRAY(_count[_numberOfTypes]-1, - Descending.size(), - &DescendingIndex[0], - &Descending[0]); - - Reversedescendingconnectivityindex.push_back(Reversedescendingconnectivityindex[Reversedescendingconnectivityindex.size()-1]+2); // we complete the index - Reversedescendingconnectivityvalue.push_back(0); - _reverseDescendingConnectivity = new MEDSKYLINEARRAY(NumberOfConstituent+1, - 2*NumberOfConstituent, - &Reversedescendingconnectivityindex[0], - &Reversedescendingconnectivityvalue[0]); - _isDescendingConnectivityPartial = false; - } - END_OF_MED(LOC); - } -} - -void CONNECTIVITY::addToDescendingConnectivity(const set& nodes, - multimap& descending, - int iglobal_cell, - const CONNECTIVITY_HashMap & face_map ) const -{ - int dimension = getEntityDimension(); - vector signature (dimension); - set::const_iterator iter=nodes.begin(); - for (int i=0; i< dimension;i++) - { - signature[i]=*iter; - iter++; - } - - - CONNECTIVITY_HashMap::const_iterator itermap=face_map.find(signature); - CONNECTIVITY_HashMap::const_iterator iterend=face_map.end(); - - - if (itermap!=iterend) - descending.insert(make_pair(iglobal_cell,itermap->second)); -} - -/*! This method calculates the descending connectivity without creating missing elements. It only maps the constituent elements that are described in the nodal representation. - For instance, let us consider the following mesh with no MED_EDGE elements on the inner edges. - - +----1----+----2----+ - | | | - 8 1 | 2 3 - | | | - +---------+---------+ - | | | - 7 3 | 4 4 - | | | - +----6----+----5----+ - - - calculatePartialDescendingConnectivity() - will return - 1:1,8 - 2:2,3 - 3:6,7 - 4:4,5 - - whereas calculateDescendingConnectivity() - will create new edges, renumbering existing ones and return - 1:1,2,3,4 - 2:5,6,7,2 - 3:3,8,9,10 - 4:7,11,12,8 - - +----1----+----5----+ - | | | - 4 1 2 2 6 - | | | - +----3----+----7----+ - | | | - 10 3 8 4 11 - | | | - +----9----+----12---+ -*/ - -void CONNECTIVITY::calculatePartialDescendingConnectivity() const -{ - //////////////////////////////////////////////////////////////////////////// - // First stage : creating hash_map referencing faces with the triplet - // of the lowest order nodes as a key and the global face number as a value - - CONNECTIVITY_HashMap face_map; - int iglobal_face=1; - - int dimension = getEntityDimension(); - { - const int* conn =_constituent->getValue (MED_NODAL, MED_ALL_ELEMENTS); - const int* index=_constituent->getValueIndex(MED_NODAL); - int nbfaces=_constituent->getNumberOf(_constituent->getEntity(),MED_ALL_ELEMENTS); - for ( ; iglobal_face <= nbfaces; iglobal_face++ ) - { - const int* face_conn = conn + index[iglobal_face-1] - 1; - const int nbnodes = index[iglobal_face] - index[iglobal_face-1]; - set nodes( face_conn, face_conn + nbnodes ); - vector signature (dimension); - set::iterator iter=nodes.begin(); - for (int i=0; i< dimension;i++) - { - signature[i]=*iter; - iter++; - } - face_map.insert(make_pair(signature,iglobal_face)); - } - } - //////////////////////////////////////////////////////////////////////////// - //Second stage : going through all the faces of the cells and - // connecting them to the hash_map created in the first stage - - multimap descending; //map storing the descending connectivity - - int nbcell_types = getNumberOfTypes(_entity); - const medGeometryElement* cell_types = getGeometricTypes(_entity); - int iglobal_cell = 1; - for (int itype=0; itypegetIndex(); - const int* conn = _nodal->getValue(); - switch ( cell_type ) - { - case MED_POLYGON: - { - for (int icell=0;icell nodes; - if (iface+1!=nbfaces) - { - nodes.insert(conn[index[icell]-1+iface]); - nodes.insert(conn[index[icell]-1+iface+1]); - } - else - { - nodes.insert(conn[index[icell]-1+iface]); - nodes.insert(conn[index[icell]-1]); - } - addToDescendingConnectivity(nodes,descending,iglobal_cell,face_map); - } - iglobal_cell++; - } - } - break; - - case MED_POLYHEDRA: - { - for (int icell = 0; icell < nbcells; icell++) - { - const int* face_conn = conn + index[icell ] - 1; - const int* face_conn_end = conn + index[icell+1] - 1; - while (face_conn < face_conn_end) - { - set nodes; // faces are divided by -1 - for ( ; face_conn < face_conn_end && *face_conn != -1; face_conn++ ) - nodes.insert( *face_conn ); - addToDescendingConnectivity(nodes,descending,iglobal_cell,face_map); - } - iglobal_cell++; - } - } - break; - - default: // classic cells - { - CELLMODEL cellmodel=CELLMODEL_Map::retrieveCellModel(cell_type); - const int* index=_nodal->getIndex(); - const int* conn=_nodal->getValue(); - for (int icell = 0; icell < nbcells; icell++, iglobal_cell++) - { - int nbfaces=cellmodel.getNumberOfConstituents(1); - for (int iface=0; iface nodes; - const int* local_index=cellmodel.getNodesConstituent(1,iface+1); - medGeometryElement face_type = cellmodel.getConstituentType(1,iface+1); - int nbnodes=face_type%100; - for (int inode=0;inode index; - vector value; - index.push_back(1); - - //the number of cells is given by the number - //obtained by browsing all the cell types - int nb_cells = iglobal_cell-1; - - //for (int icell = 0; icell < nb_cells; icell++) - for (int icell = 1; icell <= nb_cells; icell++) - { - multimap::iterator beginning_of_range = descending.lower_bound(icell); - multimap::iterator end_of_range = descending.upper_bound(icell); - int nb=0; - for (multimap::iterator iter2 = beginning_of_range; iter2 != end_of_range; iter2++) - { - value.push_back(iter2->second); - nb++; - } - index.push_back(index.back()+nb); - } - if(_descending) - delete _descending; - _descending = new MEDSKYLINEARRAY(index.size()-1, value.size(), &index[0], &value[0]); - _isDescendingConnectivityPartial = true; -} - - -/*! Not implemented yet */ -//--------------------------------------------------------------------// -void CONNECTIVITY::calculateNeighbourhood(CONNECTIVITY &myConnectivity) -//--------------------------------------------------------------------// -{ - const char* LOC = "CONNECTIVITY::calculateNeighbourhood(CONNECTIVITY &myConnectivity) : "; - BEGIN_OF_MED(LOC); - - MESSAGE_MED(PREFIX_MED<<"method not yet implemented " << myConnectivity._entity); - // Mesh dimension ! - - END_OF_MED(LOC); - return; -} - - -/*! - Returns the geometry of an element given by its entity type & its global number. - - Example : medGeometryElement myType = myConnectivity.getElementType(MED_CELL,35); -*/ -//--------------------------------------------------------------------// -medGeometryElement CONNECTIVITY::getElementType(medEntityMesh Entity,int globalNumber) const -//--------------------------------------------------------------------// -{ - const char * LOC = "medGeometryElement CONNECTIVITY::getElementType(medEntityMesh Entity, int globalNumber) const : "; - BEGIN_OF_MED(LOC); - int globalNumberMin = 1; - int globalNumberMax ; - - if (_entity==Entity) globalNumberMax = _count[_numberOfTypes]; - else if (_constituent!=NULL) globalNumberMax = _constituent->_count[_constituent->_numberOfTypes]; - else - throw MEDEXCEPTION(LOCALIZED("getElementType : Entity not defined !")); - - // The globalNumber must verify : 1 <= globalNumber < _count[_numberOfTypes] (== totalNumberOfElement+1) - - if ( (globalNumber < globalNumberMin) || (globalNumber > globalNumberMax-1 ) ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "globalNumber must be between >= |" - << globalNumberMin <<"| and <= |" << globalNumberMax-1 )); - - if (_entity==Entity) { - for(int i=1; i<=_numberOfTypes;i++) - if (globalNumber<_count[i]) - return _geometricTypes[i-1]; - } - else if (_constituent!=NULL) - return _constituent->getElementType(Entity,globalNumber); - else - throw MEDEXCEPTION(LOCALIZED("getElementType : Entity not defined !")); - throw MEDEXCEPTION(LOCALIZED("getElementType : Wrong Number !")); - - END_OF_MED(LOC); -} - -ostream & MEDMEM::operator<<(ostream &os, CONNECTIVITY &co) -{ - os << endl << "------------- Entity = "; - switch (co._entity) - { - case MED_CELL: - os << "MED_CELL"; - break; - case MED_FACE: - os << "MED_FACE"; - break; - case MED_EDGE: - os << "MED_EDGE"; - break; - case MED_NODE: - os << "MED_NODE"; - break; - case MED_ALL_ENTITIES: - os << "MED_ALL_ENTITIES"; - break; - default: - os << "Unknown"; - break; - } - os << " -------------\n\nMedConnectivity : "; - switch (co._typeConnectivity) - { - case MED_NODAL: - os << "MED_NODAL\n"; - break; - case MED_DESCENDING: - os << "MED_DESCENDING\n"; - break; - default: - break; - } - os << "Entity dimension : " << co._entityDimension << endl; - os << "Number of nodes : " << co._numberOfNodes << endl; - os << "Number of types : " << co._numberOfTypes << endl; - for (int i=0; i!=co._numberOfTypes ; ++i) - os << " -> Type " << co._geometricTypes[i] << " (" << co._type[i].getName() << ") : " - << co._count[i+1]-co._count[i] << " elements" << endl; - - if (co._typeConnectivity == MED_NODAL ) - { - for (int i=0; i 0) - { - const int *connectivity = co.getConnectivity( co._typeConnectivity, co._entity, MED_ALL_ELEMENTS); - const int *connectivity_index = co.getConnectivityIndex( co._typeConnectivity, co._entity ); - - for ( int j=0; j!=numberofelements; j++ ) - { - os << "Element " << j+1 << " : "; - for ( int k=connectivity_index[j]; k!=connectivity_index[j+1]; k++ ) - os << connectivity[k-1] << " "; - os << endl; - } - } - } - - if (co._constituent) - os << endl << *co._constituent << endl; - - return os; -} - -/*! - method that adds to vector 'nodes' all the nodes of polyhedron with id 'polyhedronId'. - WARNING the returned pointer should be deallocated. Returned nodes and polyhedronId are in form [1,...] -*/ -int *CONNECTIVITY::getNodesOfPolyhedron(int polyhedronId, int& lgthOfTab) const -{ - int offsetWithClassicType=_count[ _numberOfTypes-1 ]-1; // hope that polyhedrons is the last type - if (polyhedronId<=offsetWithClassicType || polyhedronId> getNumberOf (MED_CELL, MED_ALL_ELEMENTS)) - throw MEDEXCEPTION("Polyhedron ID does not match a polyhedron in the element range"); - - const int *nodes=getConnectivity(MED_NODAL, MED_CELL, MED_ALL_ELEMENTS); - const int *index=getConnectivityIndex(MED_NODAL,MED_CELL); - const int *cellnodes = nodes + index[polyhedronId-1] - 1; - const int *cellnodesend = nodes + index[polyhedronId ] - 1; - set retInSet( cellnodes, cellnodesend ); - if ( *retInSet.begin() == -1 ) - retInSet.erase( retInSet.begin() ); - lgthOfTab=retInSet.size(); - int *ret=new int[lgthOfTab]; - set::iterator iter=retInSet.begin(); - for(int i=0;iter!=retInSet.end();iter++) - ret[i++]=*iter; - return ret; -} - -/*! - Idem as MESH::getNodesOfPolyhedron except that returned nodes are sorted by face. 'nbOfNodesPerFaces' is an array of size 'nbOfFaces'. - Returned int** has a size of 'nbOfNodesPerFaces' too, and for each element j in int** the size is nbOfNodesPerFaces[j]. - Warning both returned 'nbOfNodesPerFaces' and returned value should be deallocated. Returned nodes and 'polyhedronId' are in form [1,...] -*/ -int **CONNECTIVITY::getNodesPerFaceOfPolyhedron(int polyhedronId, int& nbOfFaces, int* & nbOfNodesPerFaces) const -{ - int offsetWithClassicType=_count[ _numberOfTypes-1 ]-1; // hope that polyhedrons is the last type - if (polyhedronId<=offsetWithClassicType || polyhedronId> getNumberOf(MED_CELL, MED_ALL_ELEMENTS)) - throw MEDEXCEPTION("Polyhedron ID does not match a polyhedron in the element range"); - const int *nodes=getConnectivity(MED_EN::MED_NODAL, MED_CELL, MED_ALL_ELEMENTS); - const int *index=getConnectivityIndex(MED_EN::MED_NODAL, MED_CELL); - - const int *cellnodes = nodes + index[polyhedronId-1] - 1; - const int *cellnodesend = nodes + index[polyhedronId ] - 1; - nbOfFaces=0; - nbOfNodesPerFaces=new int[cellnodesend-cellnodes]; // more than enough - int **ret=new int* [cellnodesend-cellnodes]; - while ( cellnodes < cellnodesend ) - { - ret[nbOfFaces] = (int*)cellnodes; - while ( cellnodes < cellnodesend && *cellnodes != -1 ) ++cellnodes; - nbOfNodesPerFaces[nbOfFaces] = cellnodes - ret[nbOfFaces]; - cellnodes++; - nbOfFaces++; - } - return ret; -} - -/* - Method used in CalculateDescendingConnectivity. So it's typically a private method. - The aim of this method is to hide to CalculateDescendingConnectivity algorithm the fact that in reverse connectivity polygons and polyhedrons - are not in separate data structure, contrary to not reverse connectivities. -*/ -int CONNECTIVITY::getIndexOfEndClassicElementInReverseNodal(const int *reverseNodalValue, const int *reverseNodalIndex, int rk) const -{ - const int lastTypeIsPoly = (_geometricTypes[_numberOfTypes-1]==MED_EN::MED_POLYGON|| - _geometricTypes[_numberOfTypes-1]==MED_EN::MED_POLYHEDRA); - if ( !lastTypeIsPoly ) - return reverseNodalIndex[rk+1]; - int nbOfLastElt=_count[_numberOfTypes-1]-1; - int ret=reverseNodalIndex[rk]; - for(int i=reverseNodalIndex[rk];igetIJ(faceId,1); - int cell2 = _reverseDescendingConnectivity->getIJ(faceId,2); - - if (cell2 != 0) { // we are not on border, update compulsory. If we aren't on border no update necessary so WARNING because user specified a bad oriented face - // Updating _reverseDescendingConnectivity - _reverseDescendingConnectivity->setIJ(faceId,1,cell2); - _reverseDescendingConnectivity->setIJ(faceId,2,cell1); - // Updating _constituent->_nodal because of reversity - const int *descendingNodalIndex=_constituent->_nodal->getIndex(); - MEDSKYLINEARRAY *currentNodal=_constituent->_nodal; - int faceIdRelative=faceId; - for(int iarray=1;iarray<=(descendingNodalIndex[faceIdRelative]-descendingNodalIndex[faceIdRelative-1]);iarray++) - currentNodal->setIJ(faceIdRelative,iarray,nodalConnForFace[iarray-1]); - - // Updating _descending for cell1 and cell2 - const int NB_OF_CELLS_SHARING_A_FACE=2; - int cellsToUpdate[NB_OF_CELLS_SHARING_A_FACE] = { cell1, cell2 }; - for(int curCell=0;curCellgetIndex(); - MEDSKYLINEARRAY *currentDescending=_descending; - for(int iface=newDescendingIndex[cell-1];ifacegetIndexValue(iface); - if (abs(curValue)==faceId) - currentDescending->setIndexValue(iface,-curValue); - } - } - } -} - -/* - Method with 2 output : the connectivity required and its length 'lgth'. - This method gives the connectivity independently it is a polygons/polyhedrons or normal element. -*/ -const int * CONNECTIVITY::getConnectivityOfAnElement(MED_EN::medConnectivity ConnectivityType, MED_EN::medEntityMesh Entity, int Number, int &lgth) const -{ - if(Entity==MED_EN::MED_NODE) - throw MEDEXCEPTION("No connectivity attached to a node entity"); - if(Entity==_entity) - { - if ( Number > getNumberOf( Entity, MED_ALL_ELEMENTS )) - throw MEDEXCEPTION("Unknown number"); - const int * conn = getConnectivity(ConnectivityType,Entity,MED_ALL_ELEMENTS); - const int * index = getConnectivityIndex(ConnectivityType,Entity); - lgth=index[Number]-index[Number-1]; - return conn+index[Number-1]-1; - } - else - { - if(_constituent==NULL) - calculateDescendingConnectivity(); - return _constituent->getConnectivityOfAnElement(ConnectivityType,Entity,Number,lgth); - } -} - -/*! - Perform a deep comparison of the 2 connectivities in NODAL mode and on all elements. -*/ -bool CONNECTIVITY::deepCompare(const CONNECTIVITY& other) const -{ - CONNECTIVITY* temp=(CONNECTIVITY* )this; - const int *conn1=temp->getConnectivity(MED_NODAL,_entity,MED_ALL_ELEMENTS); - int size1=temp->getConnectivityLength(MED_NODAL,_entity,MED_ALL_ELEMENTS); - temp=(CONNECTIVITY* )(&other); - const int *conn2=temp->getConnectivity(MED_NODAL,_entity,MED_ALL_ELEMENTS); - int size2=temp->getConnectivityLength(MED_NODAL,_entity,MED_ALL_ELEMENTS); - if(size1!=size2) - return false; - bool ret=true; - for(int i=0;i -#include -#include - -namespace MEDMEM { - class MEDSKYLINEARRAY; - class FAMILY; - class GROUP; - class CONNECTIVITY; - MEDMEM_EXPORT std::ostream & operator<<(std::ostream &os, CONNECTIVITY &my); - -/*! - This class deals with all types of connectivity.\n - It is a recursive class. -*/ - -/* ------------------------------------------- */ -class MEDMEM_EXPORT CONNECTIVITY -/* ------------------------------------------- */ -{ - - class myHashFn - { - public: - size_t operator()(const std::vector& key) const - { - size_t sum=0; - for (int i=0; i<(int)key.size(); i++) - //sum+=key[i]; -- KO for conn of edges of face [1,6,5,2] since 1+6==2+5 - sum+=key[i]*(i+key.size()); - return sum; - } -// #ifdef WIN32 -// static const size_t bucket_size = 4; -// static const size_t min_buckets = 8; -// bool operator()(const vector& key1, const vector& key2) const -// { -// return ::size_t()(key1) < ::size_t()(key2); -// } -// #endif - }; - - typedef INTERP_KERNEL::HashMap,int, myHashFn > CONNECTIVITY_HashMap; - - /* ---------------------- */ - /* Class Attributs */ - /* ---------------------- */ - -protected: - /*! contains MED_CELL MED_FACE or MED_EDGE */ - MED_EN::medEntityMesh _entity; - /*! contains MED_NODAL or MED_DESCEND */ - MED_EN::medConnectivity _typeConnectivity; - /*! count of differents cells types - used by the mesh */ - int _numberOfTypes; - /*! array of all med_geometric_type used by MESH. */ - MED_EN::medGeometryElement* _geometricTypes; - - /*! map indexed by med_geometric_type - which contains the different - 'CellModel' used by MESH. */ - CELLMODEL * _type; - /*! contains the dimension of the entity */ - int _entityDimension; - - /*! needed by calculateReverseNodalConnectivity */ - int _numberOfNodes; - - /*! array of size _numberOfTypes+1 which - gives for each cell type the first - cell number in _nodal or _descending - array (depends on _typeConnectivity) - To get cells count for one type, we - must minus _count[i+1] and _count[i] - ( 0 <= i < _numberOfTypes ). - Note that _count[_numberOfTypes] returns - total cells count + 1 */ - int * _count; - - /*! pointer to an array which stores the nodal connectivity */ - MEDSKYLINEARRAY* _nodal; - /*! pointer to an array which stores - the descending connectivity */ - mutable MEDSKYLINEARRAY* _descending; - /*! pointer to an array which stores - the reverse nodal connectivity */ - mutable MEDSKYLINEARRAY* _reverseNodalConnectivity; - /*! pointer to an array which stores - the reverse descending connectivity */ - mutable MEDSKYLINEARRAY* _reverseDescendingConnectivity; - /*! if face or edge, list of 2 cells or - 2 faces it belongs to. - If 2nd number equals 0, we have a - boundary entity. We could use - MEDSKYLINEARRAY, but we suppose we have - always only 2 (or 1) entities. */ - MEDSKYLINEARRAY* _neighbourhood; - /*! connectivity of sub cell if - descendant connectivity is calculated */ - CONNECTIVITY * _constituent; - /*! is descending connectivity computed by - calculatePartialDescendingConnectivity() */ - mutable bool _isDescendingConnectivityPartial; - - /* -------------------- */ - /* Class Methods */ - /* -------------------- */ - -private: - /*! private method :\n - does nothing if already exists, else - evaluates _nodal from _descending */ - void calculateNodalConnectivity() const; - /*! private method :\n - does nothing if already exists, else - evaluates from _nodal */ - void calculateReverseNodalConnectivity() const; - /*! private method :\n - does nothing if already exists, else - evaluates _descending from _nodal */ - void calculateDescendingConnectivity() const; - - void calculatePartialDescendingConnectivity() const; - void addToDescendingConnectivity( const std::set& nodes, - std::multimap& descending, - int iglobal_cell , - const CONNECTIVITY_HashMap & ) const; - - /*! private method :\n - does nothing if already exists, else - evaluates from _descending */ - // void calculateReverseDescendingConnectivity(CONNECTIVITY *myConnectivity); - - const int* getReverseNodalConnectivity () const; - const int* getReverseNodalConnectivityIndex () const; - const int* getReverseDescendingConnectivity () const; - const int* getReverseDescendingConnectivityIndex () const; - - /*! private method :\n - does nothing if already exists, else - evaluates _neighbourhood from _descending */ - void calculateNeighbourhood(CONNECTIVITY &myConnectivity); - - int getIndexOfEndClassicElementInReverseNodal(const int *reverseNodalValue, - const int *reverseNodalIndex, int rk) const; - -public: - - friend class MED_MESH_RDONLY_DRIVER; - friend class MED_MESH_WRONLY_DRIVER; - - - friend std::ostream & operator<<(std::ostream &os, CONNECTIVITY &connectivity); - - // in order to fill CONNECTIVITY of MESH - friend class GRID; - - CONNECTIVITY (MED_EN::medEntityMesh Entity=MED_EN::MED_CELL); - CONNECTIVITY (int numberOfTypes, MED_EN::medEntityMesh Entity=MED_EN::MED_CELL); - CONNECTIVITY (const CONNECTIVITY & m); - virtual ~CONNECTIVITY (); - - void setConstituent (CONNECTIVITY * Constituent) - throw (MEDEXCEPTION); - const CONNECTIVITY* getConstituent (const MED_EN::medEntityMesh Entity) const - throw (MEDEXCEPTION); - - void setGeometricTypes (const MED_EN::medGeometryElement * Types, - const MED_EN::medEntityMesh Entity) - throw (MEDEXCEPTION); - - void setCount (const int * Count, - const MED_EN::medEntityMesh Entity) - throw (MEDEXCEPTION); - - void setNodal (const int * Connectivity, - const MED_EN::medEntityMesh Entity, - const MED_EN::medGeometryElement Type, - const int * PolyConnectivityIndex=0) - throw (MEDEXCEPTION); - - inline void setNumberOfNodes(int NumberOfNodes); - inline int getNumberOfNodes() const; - inline int getEntityDimension() const; - - inline void setEntityDimension(int EntityDimension); - - inline bool existConnectivity (MED_EN::medConnectivity connectivityType, - MED_EN::medEntityMesh Entity) const; - - virtual void calculateConnectivity (MED_EN::medConnectivity connectivityType, - MED_EN::medEntityMesh Entity); - - virtual void calculateFullDescendingConnectivity(MED_EN::medEntityMesh Entity); - - virtual void updateFamily (const vector& myFamilies); - - inline MED_EN::medEntityMesh getEntity () const; - - inline int getNumberOfTypes (MED_EN::medEntityMesh Entity) const; - - const int * getConnectivityOfAnElement(MED_EN::medConnectivity ConnectivityType, - MED_EN::medEntityMesh Entity, - int Number, int &lgth) const; - - inline const MED_EN::medGeometryElement * getGeometricTypes (MED_EN::medEntityMesh Entity) const - throw (MEDEXCEPTION); - MED_EN::medGeometryElement getElementType (MED_EN::medEntityMesh Entity, - int Number) const; - inline MED_EN::medGeometryElement getPolyTypeRelativeTo() const; - virtual inline const int * getGlobalNumberingIndex (MED_EN::medEntityMesh Entity) const throw (MEDEXCEPTION); - - virtual const int* getConnectivity (MED_EN::medConnectivity ConnectivityType, - MED_EN::medEntityMesh Entity, - MED_EN::medGeometryElement Type) const; - virtual int getConnectivityLength (MED_EN::medConnectivity ConnectivityType, - MED_EN::medEntityMesh Entity, - MED_EN::medGeometryElement Type) const; - virtual const int* getConnectivityIndex (MED_EN::medConnectivity ConnectivityType, - MED_EN::medEntityMesh Entity) const; - int * getNodesOfPolyhedron(int polyhedronId, int& lgthOfTab) const; - int ** getNodesPerFaceOfPolyhedron(int polyhedronId, int& nbOfFaces, int* & nbOfNodesPerFaces) const; - - const CELLMODEL & getType (MED_EN::medGeometryElement Type) const; - const CELLMODEL * getCellsTypes (MED_EN::medEntityMesh Entity) const - throw (MEDEXCEPTION); - string * getCellTypeNames (MED_EN::medEntityMesh Entity) const - throw (MEDEXCEPTION); - - int getNumberOfNodesInType (MED_EN::medGeometryElement Type) const; - int getNumberOfSubCellInType (MED_EN::medGeometryElement Type) const; - virtual int getNumberOf (MED_EN::medEntityMesh Entity, - MED_EN::medGeometryElement Type) const; - virtual const int* getValue (MED_EN::medConnectivity TypeConnectivity, - MED_EN::medGeometryElement Type) const; - virtual const int* getValueIndex (MED_EN::medConnectivity TypeConnectivity) const; - - virtual inline const int* getReverseConnectivity (MED_EN::medConnectivity ConnectivityType, - MED_EN::medEntityMesh Entity=MED_EN::MED_CELL) const - throw (MEDEXCEPTION); - virtual inline const int* getReverseConnectivityIndex (MED_EN::medConnectivity ConnectivityType, - MED_EN::medEntityMesh Entity=MED_EN::MED_CELL) const - throw (MEDEXCEPTION); - - const int* getNeighbourhood() const; - void invertConnectivityForAFace(int faceId, const int *nodalConnForFace); - bool deepCompare(const CONNECTIVITY& other) const; - - -}; -/*----------------------*/ -/* Methodes Inline */ -/*----------------------*/ - -/*! Returns the medEntityMesh */ -//--------------------------------------------------// -inline MED_EN::medEntityMesh CONNECTIVITY::getEntity() const -//--------------------------------------------------// -{ - return _entity; -} - -/*! Returns the number of different %medGeometryElement types - existing in the specified entity. \n - Note : Not implemented for MED_ALL_ENTITIES. */ -//-----------------------------------------------------------------------// -inline int CONNECTIVITY::getNumberOfTypes(MED_EN::medEntityMesh Entity) const -//-----------------------------------------------------------------------// -{ - MESSAGE_MED("CONNECTIVITY::getNumberOfTypes : Entity = "< (this))->calculateDescendingConnectivity(); - } - catch (MEDEXCEPTION &) - { - return 0 ; - } - - SCRUTE_MED(_entityDimension); - - if (_entityDimension != 2 && _entityDimension != 3) return 0; - - try - { - _constituent->calculateConnectivity(MED_EN::MED_NODAL,Entity); - } - catch (MEDEXCEPTION &) - { - return 0 ; - } - - return _constituent->getNumberOfTypes(Entity); - } - else - return 0; // because it is the right information (no exception needed)! -} - -/*! Returns an array of all %medGeometryElement types existing in the mesh - for the given %medEntityMesh. - Note : Not implemented for MED_ALL_ENTITIES. - Throws an exception if Entity is unknown */ -//------------------------------------------------------------------------------------------// -inline const MED_EN::medGeometryElement* CONNECTIVITY::getGeometricTypes(MED_EN::medEntityMesh Entity) const - throw (MEDEXCEPTION) -//------------------------------------------------------------------------------------------// -{ - if (_entity==Entity) - return _geometricTypes; - else if (_constituent!=NULL) - return _constituent->getGeometricTypes(Entity); - else - //throw MEDEXCEPTION("CONNECTIVITY::getGeometricTypes : Entity not defined !"); - return 0; // idem to supressed getGeometricTypesWithPoly() -} - -/*! Returns an array containing the accumulated number of entities sorted by the geometric type.\n - - Exemple :\n - - In case of a CONNECTIVITY containing 3*MED_TRIA3 et 2*MED_QUAD4 : \n - int * count = getGlobalNumberingIndex(MED_CELL)\n - count[0] is always set to 1\n - count[1] is set to 1+3=4\n - count[2] is set to 4+2=6 = total number of cells + 1\n - - Note : Not implemented for MED_ALL_ENTITIES. \n - Note : The geometric type order is given by the typedef enum medGeometryElement. - -*/ -//----------------------------------------------------------------------------------// -inline const int * CONNECTIVITY::getGlobalNumberingIndex(MED_EN::medEntityMesh Entity) const - throw (MEDEXCEPTION) -//----------------------------------------------------------------------------------// -{ - if (_entity==Entity) - return _count; - else if (_constituent!=NULL) - return _constituent->getGlobalNumberingIndex(Entity); - else - throw MEDEXCEPTION("CONNECTIVITY::getGlobalNumberingIndex : Entity not defined !"); -} - -/*! Returns true if a connectivity exists on elements of type "Entity" */ -//-----------------------------------------------------------------------------// -inline bool CONNECTIVITY::existConnectivity( MED_EN::medConnectivity ConnectivityType, - MED_EN::medEntityMesh Entity) const -//-----------------------------------------------------------------------------// -{ - if (_entity==Entity) { - if ((ConnectivityType == MED_EN::MED_NODAL) && (_nodal != (MEDSKYLINEARRAY*)NULL)) - return true; - if ((ConnectivityType==MED_EN::MED_DESCENDING)&(_descending!=(MEDSKYLINEARRAY*)NULL)) - return true; - } else if (_constituent!=NULL) - return _constituent->existConnectivity(ConnectivityType,Entity); - return false; -} - -/*! -Returns an array containing CELLMODEL foreach element type present -in connectivity for given medEntityMesh (similar as getGeometricTypes).\n -Throw an execption if the given entity is not defined or if the array is not defined. -*/ -//-----------------------------------------------------------------------------// -inline const CELLMODEL * CONNECTIVITY::getCellsTypes(MED_EN::medEntityMesh Entity) const - throw (MEDEXCEPTION) -//-----------------------------------------------------------------------------// -{ - if (Entity == _entity) - if (_type!=NULL) - return _type; - else - throw MEDEXCEPTION("CONNECTIVITY::getCellsTypes(medEntityMesh) :" - " CELLMODEL array is not defined !"); - else - if (_constituent != NULL) - return _constituent->getCellsTypes(Entity); - else - throw MEDEXCEPTION("CONNECTIVITY::getCellsTypes(medEntityMesh) : Not found Entity !"); -} -/*! -Returns an array (it should deleted after use) containing the whole list of -CELLMODEL Name foreach element type present in connectivity for given -medEntityMesh (similar as getGeometricTypes).\n -Throw an execption if the given entity is not defined or if the array is not -defined. - -*/ -//-----------------------------------------------------------------------------// -inline string * CONNECTIVITY::getCellTypeNames(MED_EN::medEntityMesh Entity) const - throw (MEDEXCEPTION) -//-----------------------------------------------------------------------------// -{ - if (Entity == _entity) - if (_type!=NULL) - { - string * stringArray = new string[_numberOfTypes]; - - for (int i=0;i<_numberOfTypes;i++) - stringArray[i] = _type[i].getName(); - - return stringArray; - } - else - throw MEDEXCEPTION("CONNECTIVITY::getCellTypeNames(medEntityMesh) :" - " CELLMODEL array is not defined !"); - else - if (_constituent != NULL) - return _constituent->getCellTypeNames(Entity); - else - throw MEDEXCEPTION("CONNECTIVITY::getCellTypeNames(medEntityMesh) : Not found Entity !"); -} - - - - - - -/*! A DOCUMENTER */ -//------------------------------------------------------------------------------------------// -inline const int* CONNECTIVITY::getReverseConnectivity( MED_EN::medConnectivity ConnectivityType, - MED_EN::medEntityMesh Entity) const - throw (MEDEXCEPTION) -//------------------------------------------------------------------------------------------// -{ - if(_entity==Entity) - { - if (ConnectivityType==MED_EN::MED_NODAL) - return getReverseNodalConnectivity(); - else if (ConnectivityType==MED_EN::MED_DESCENDING) - return getReverseDescendingConnectivity(); - else - throw MEDEXCEPTION("MESH::getReverseConnectivity : connectivity mode not supported !"); - } - // other entity : - if (NULL==_constituent) - calculateDescendingConnectivity(); - return _constituent->getReverseConnectivity(ConnectivityType,Entity); -} - -/*! A DOCUMENTER */ -//-----------------------------------------------------------------------------------------------// -inline const int* CONNECTIVITY::getReverseConnectivityIndex(MED_EN::medConnectivity ConnectivityType, - MED_EN::medEntityMesh Entity) const - throw (MEDEXCEPTION) -//-----------------------------------------------------------------------------------------------// -{ - if(_entity==Entity) - { - if (ConnectivityType==MED_EN::MED_NODAL) - return getReverseNodalConnectivityIndex(); - else if (ConnectivityType==MED_EN::MED_DESCENDING) - return getReverseDescendingConnectivityIndex(); - else - throw MEDEXCEPTION("MESH::getReverseConnectivityIndex : connectivity mode not supported !"); - } - // other entity : - if (NULL==_constituent) - calculateDescendingConnectivity(); - return _constituent->getReverseConnectivityIndex(ConnectivityType,Entity); -} - - -inline void CONNECTIVITY::setNumberOfNodes(int NumberOfNodes) -{ - _numberOfNodes=NumberOfNodes; -} - -inline int CONNECTIVITY::getNumberOfNodes() const -{ - return _numberOfNodes; -} - -inline void CONNECTIVITY::setEntityDimension(int EntityDimension) -{ - _entityDimension=EntityDimension; -} - -int CONNECTIVITY::getEntityDimension() const -{ - return _entityDimension; -} - -MED_EN::medGeometryElement CONNECTIVITY::getPolyTypeRelativeTo() const -{ - if(_entity==MED_EN::MED_CELL && _entityDimension==3) - return MED_EN::MED_POLYHEDRA; - else if((_entity==MED_EN::MED_CELL && _entityDimension==2) || (_entity==MED_EN::MED_FACE && _entityDimension==2)) - return MED_EN::MED_POLYGON; - else - throw MEDEXCEPTION("getPolyTypeRelativeTo : "); -} - - - - -}//End namespace MEDMEM - -#endif /* CONNECTIVITY_HXX */ - - diff --git a/src/MEDMEM/MEDMEM_Coordinate.cxx b/src/MEDMEM/MEDMEM_Coordinate.cxx deleted file mode 100644 index e7aee885a..000000000 --- a/src/MEDMEM/MEDMEM_Coordinate.cxx +++ /dev/null @@ -1,315 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_Coordinate.hxx" -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_STRING.hxx" - -#include "MEDMEM_Utilities.hxx" - -#include - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -/*! Default Constructor : should not be used */ -//----------------------------------------------------------// -COORDINATE::COORDINATE():_coordinateSystem(""), - _coordinate(MEDARRAY()), - _coordinateName(), - _coordinateUnit(), - _nodeNumber() -//----------------------------------------------------------// -{ - const char* LOC = "Default Constructor COORDINATE"; - BEGIN_OF_MED(LOC); -} - -/*! This constructor allocate a MEDARRAY of SpaceDimension * NumberOfNodes.\n - It will create empty array for optional data (nodeNumber..) */ -//------------------------------------------------------------------------------// -COORDINATE::COORDINATE(int SpaceDimension, int NumberOfNodes, medModeSwitch Mode): - _coordinateSystem(""), - _coordinate(SpaceDimension,NumberOfNodes,Mode), - _coordinateName(SpaceDimension), - _coordinateUnit(SpaceDimension), - _nodeNumber() - -//------------------------------------------------------------------------------// -{ - const char* LOC = "Constructor COORDINATE"; - BEGIN_OF_MED(LOC); -} - -/*! This constructor is specialy designed for use in class GRID.\n - * The purpose is to create a COORDINATE without allocating memory for nodes (in the MEDARRAY). - * The allocation (call to setCoordinates) is performed afterward by GRID, if necessary. - * We set _coordinateName & _coordinateUnit in the constructor, because calls to setCoordinateName - * and setCoordinateUnit are not possible before allocation of MEDARRAY. - */ -//------------------------------------------------------------------------------// -COORDINATE::COORDINATE(int SpaceDimension,const string * CoordinateName, const string * CoordinateUnit): - _coordinateSystem(""), _coordinate(MEDARRAY()), _coordinateName(SpaceDimension), - _coordinateUnit(SpaceDimension), _nodeNumber() -{ - for (int i=0; i *Coordinate,bool shallowCopy) -//----------------------------------------------------------// -{ - - const medModeSwitch mode = Coordinate->getMode(); - // const int spaceDimension = (int) Coordinate->getLeadingValue(); - // const int numberOfNodes = (int) Coordinate->getLengthValue(); - if ( Coordinate->get(mode) != NULL) - { - if(shallowCopy) - { - _coordinate.shallowCopy(*Coordinate); - } - else - { - MEDARRAY pourAttribut(*Coordinate,false); - _coordinate = pourAttribut; - //_coordinate.set(mode,Coordinate->get(mode)); - } - } - else - { - throw MED_EXCEPTION ( LOCALIZED(STRING("setCoordinates(MEDARRAY *Coordinate)") << "No Coordinate")); - } -} - -/*! - Sets the value in attribute _coordinate with Coordinate. - _coordinate must be allocated (with - COORDINATE::COORDINATE(int,int,medModeSwitch). -*/ -//----------------------------------------------------------// -void COORDINATE::setCoordinates(const medModeSwitch Mode, - const double *Coordinate) -//----------------------------------------------------------// -{ -// if (_coordinate == NULL) -// throw MEDEXCEPTION("COORDINATE::setCoordinates(double*) : coordinate array not allocated !"); - - _coordinate.set(Mode,Coordinate); -} - -/*! sets the attribute _coordinateName with CoordinateName */ -//----------------------------------------------------------// -void COORDINATE::setCoordinatesNames(const string * CoordinateName) -//----------------------------------------------------------// -{ - int SpaceDimension = getSpaceDimension() ; - //_coordinateName.set(SpaceDimension) ; - _coordinateName.resize(SpaceDimension); - for (int i=0; i - -#include -#include - -#include "MEDMEM_PointerOf.hxx" -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_define.hxx" - - -#include "MEDMEM_Array.hxx" - -/*! - This class contains coordinates of the nodes .\n - It could also store useful optional information about nodes - as node numbers and about axes as names or units. \n - spaceDimension and numberOfNodes can be found in _coordinate object. -*/ - -namespace MEDMEM { -class MEDMEM_EXPORT COORDINATE -{ - -protected: - /*! contains "CARTESIAN", - "CYLINDRICAL" or "SPHERICAL"*/ - string _coordinateSystem; - - - /*! _coordinate is a MEDARRAY object : \n - - spaceDimension \n - - numberOfNodes \n - - default storage mode \n - - Up to 4 "PointerOf" to an array of size spaceDimension*NumberOfNodes\n - - Storing the object (not a pointer to this object) is more convenient for memory - management. - */ - mutable MEDARRAY _coordinate; - - /*! PointerOf to an array of size spaceDimension storing axes names*/ - //PointerOf _coordinateName; - vector _coordinateName; - - /*! PointerOf to an array of size spaceDimension storing units */ - //PointerOf _coordinateUnit; - vector _coordinateUnit; - - /*! PointerOf to an array of size NumberOfNodes : optional nodes numbers */ - PointerOf _nodeNumber; - - -public : - - - friend class MED_MESH_RDONLY_DRIVER; - friend class MED_MESH_WRONLY_DRIVER; - - - COORDINATE(); - COORDINATE(int SpaceDimension, int NumberOfNodes, MED_EN::medModeSwitch Mode); - COORDINATE(int SpaceDimension,const string * CoordinateName, const string * CoordinateUnit); - COORDINATE(const COORDINATE & m); - virtual ~COORDINATE(); - - void setCoordinates(MEDARRAY *Coordinate,bool shallowCopy=false); - void setCoordinates(const MED_EN::medModeSwitch Mode, const double *Coordinate); - void setCoordinatesNames(const string * CoordinateName); - void setCoordinateName(const string CoordinateName, const int i); - void setCoordinatesUnits(const string * CoordinateUnit); - void setCoordinateUnit(const string CoordinateUnit, const int i); - void setCoordinatesSystem(const string CoordinateSystem); - void setNodesNumbers(const int * NodeNumber); - - int getSpaceDimension() const; - int getNumberOfNodes() const; - - virtual const int* getNodesNumbers() const; - //const int* getNodesNumbers() ; - string getCoordinatesSystem() const; - - virtual const double * getCoordinates(MED_EN::medModeSwitch Mode); - virtual double getCoordinate(int Number,int Axis); - virtual const double * getCoordinateAxis(int Axis); - - const string * getCoordinatesNames() const; - string getCoordinateName(int Axis) const; - const string * getCoordinatesUnits() const; - string getCoordinateUnit(int Axis) const; -}; -} - -#endif /* COORDINATE_HXX */ diff --git a/src/MEDMEM/MEDMEM_DriverFactory.cxx b/src/MEDMEM/MEDMEM_DriverFactory.cxx deleted file mode 100644 index 1b81f5f43..000000000 --- a/src/MEDMEM/MEDMEM_DriverFactory.cxx +++ /dev/null @@ -1,283 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_DriverFactory.hxx" -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_GibiMeshDriver.hxx" -#include "MEDMEM_PorflowMeshDriver.hxx" -#include "MEDMEM_VtkMeshDriver.hxx" -#include "MEDMEM_VtkMedDriver.hxx" -#include "MEDMEM_EnsightFieldDriver.hxx" -#include "MEDMEM_EnsightMeshDriver.hxx" - -#include "MEDMEM_Exception.hxx" - -#include "MEDMEM_MedVersion.hxx" -#include "MEDMEM_MedMeshDriver.hxx" - -using namespace MEDMEM; -using namespace MED_EN; - -template<> -void MEDMEM::fill<-1,0x3>(double *a, const double *b) -{ -} - -template<> -bool MEDMEM::compare<-1>(const double *a, const double *b) -{ - return false; -} - -bool DRIVERFACTORY::globalVtkBinaryFormatForWriting = false; - -bool DRIVERFACTORY::getVtkBinaryFormatForWriting() -{ - return globalVtkBinaryFormatForWriting; -} - -void DRIVERFACTORY::setVtkBinaryFormatForWriting(bool isBinary) -{ - globalVtkBinaryFormatForWriting = isBinary; -} - -driverTypes DRIVERFACTORY::deduceDriverTypeFromFileName(const std::string & fileName) -{ - string extension(fileName); - string::size_type pos=extension.rfind('.'); - if(pos==string::npos) - return NO_DRIVER; - extension.erase(0,pos+1); - if(extension=="med") - return MED_DRIVER; - if(extension=="sauve" || extension=="sauv") - return GIBI_DRIVER; - if(extension=="cnc" || extension=="inp" || extension=="xyz") - return PORFLOW_DRIVER; - if(extension=="vtk") - return VTK_DRIVER; - if(extension=="case") - return ENSIGHT_DRIVER; - return NO_DRIVER; -} - -GENDRIVER *DRIVERFACTORY::buildDriverForMesh(driverTypes driverType, - const std::string & fileName, - GMESH *mesh, - const string & driverName, - med_mode_acces access) -{ - GENDRIVER *ret; - switch(driverType) - { - case MED_DRIVER : { - switch(access) - { - case RDONLY : { - ret = new MED_MESH_RDONLY_DRIVER(fileName, mesh); - ret->setMeshName(driverName); - return ret; - } - case WRONLY : { - ret = new MED_MESH_WRONLY_DRIVER(fileName, mesh, access); - ret->setMeshName(driverName); - return ret; - } - case RDWR : { - ret = new MED_MESH_RDWR_DRIVER(fileName, mesh); - ret->setMeshName(driverName); - return ret; - } - default: - throw MED_EXCEPTION ("access type has not been properly specified to the method"); - } - break; - } - - case GIBI_DRIVER : { - if ( mesh->getIsAGrid() ) - throw MED_EXCEPTION("GIBI file can contain unstructured mesh only, not a GRID"); - switch(access) - { - case RDONLY : { - ret=new GIBI_MESH_RDONLY_DRIVER(fileName,(MESH*)mesh); - return ret; - } - case RDWR : - ret=new GIBI_MESH_RDWR_DRIVER(fileName,(MESH*)mesh); - return ret; - - case WRONLY :{ - ret=new GIBI_MESH_WRONLY_DRIVER(fileName,(MESH*)mesh); - return ret; - } - default: - throw MED_EXCEPTION ("access type has not been properly specified to the method"); - } - break; - } - - case PORFLOW_DRIVER : { - if ( mesh->getIsAGrid() ) - throw MED_EXCEPTION("PORFLOW file can contain unstructured mesh only, not a GRID"); - switch(access) - { - case RDONLY : { - ret=new PORFLOW_MESH_RDONLY_DRIVER(fileName,(MESH*)mesh); - return ret; - } - case RDWR : - case WRONLY : { - throw MED_EXCEPTION ("access mode other than MED_LECT has been specified with the PORFLOW_DRIVER type which is not allowed because PORFLOW_DRIVER is only a read access driver"); - } - default: - throw MED_EXCEPTION ("access type has not been properly specified to the method"); - } - break; - } - - case ENSIGHT_DRIVER : { - if ( mesh->getIsAGrid() ) - throw MED_EXCEPTION("EnSight driver reads unstructured mesh, not a GRID"); - switch(access) - { - case RDONLY : { - ret=new ENSIGHT_MESH_RDONLY_DRIVER(fileName,(MESH*)mesh); - return ret; - } - case WRONLY : { - ret=new ENSIGHT_MESH_WRONLY_DRIVER(fileName,(MESH*)mesh); - return ret; - } - case RDWR : { - throw MED_EXCEPTION ("not yet implemented"); - return ret; - } - default: - throw MED_EXCEPTION ("access type has not been properly specified to the method"); - } - break; - } - - case VTK_DRIVER : { - switch(access) - { - case RDONLY : { - throw MED_EXCEPTION ("access mode other than MED_ECRI or MED_REMPT has been specified with the VTK_DRIVER type which is not allowed because VTK_DRIVER is only a write access driver"); - } - case RDWR : - case WRONLY : { - ret=new VTK_MESH_DRIVER(fileName,mesh); - return ret; - } - - default: - throw MED_EXCEPTION ("access type has not been properly specified to the method"); - } - break; - } - - case NO_DRIVER : { - throw MED_EXCEPTION ("NO_DRIVER has been specified to the method 1 which is not allowed"); - } - default: - throw MED_EXCEPTION ("other driver than MED_DRIVER GIBI_DRIVER PORFLOW_DRIVER and VT_DRIVER has been specified to the method which is not allowed"); - } -} - -GENDRIVER * DRIVERFACTORY::buildMeshDriverFromFile(const string & fileName, - GMESH * ptrMesh, - MED_EN::med_mode_acces access) -{ - medFileVersion version = MED_EN::V22; - - try - { - version = getMedFileVersion(fileName); - } - catch (MEDEXCEPTION & ex) - { - } - - MESSAGE_MED("buildMeshDriverFromFile version of the file " << version); - - if (version == MED_EN::V21) - throw MED_EXCEPTION ("med-2.1 files are no more supported"); - - GENDRIVER * driver=0; - - switch(access) - { - case RDONLY : { - driver = new MED_MESH_RDONLY_DRIVER(fileName,ptrMesh); - return driver; - } - case WRONLY : { - driver = new MED_MESH_WRONLY_DRIVER(fileName,ptrMesh,access); - return driver; - } - case RDWR : { - driver = new MED_MESH_RDWR_DRIVER(fileName,ptrMesh); - return driver; - } - default: - throw MED_EXCEPTION ("access type has not been properly specified to the method"); - } - return driver; -} - -GENDRIVER * DRIVERFACTORY::buildConcreteMedDriverForMesh(const std::string & fileName, - GMESH * ptrMesh, - const string & driverName, - MED_EN::med_mode_acces access, - MED_EN::medFileVersion version) -{ - GENDRIVER * driver=0; - - MESSAGE_MED("buildConcreteMedDriverForMesh version of the file " << version); - - if (version == MED_EN::V21) - throw MED_EXCEPTION ("med-2.1 files are no more supported"); - - switch(access) - { - case RDONLY : { - driver = new MED_MESH_RDONLY_DRIVER(fileName,ptrMesh); - driver->setMeshName(driverName); - return driver; - } - case WRONLY : { - driver = new MED_MESH_WRONLY_DRIVER(fileName,ptrMesh); - driver->setMeshName(driverName); - return driver; - } - case RDWR : { - driver = new MED_MESH_RDWR_DRIVER(fileName,ptrMesh); - driver->setMeshName(driverName); - return driver; - } - default: - throw MED_EXCEPTION ("access type has not been properly specified to the method"); - } - return driver; -} diff --git a/src/MEDMEM/MEDMEM_DriverFactory.hxx b/src/MEDMEM/MEDMEM_DriverFactory.hxx deleted file mode 100644 index 5d521fc5e..000000000 --- a/src/MEDMEM/MEDMEM_DriverFactory.hxx +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef DRIVERFACTORY_HXX -#define DRIVERFACTORY_HXX - -#include - -#include "MEDMEM_MedVersion.hxx" -#include "MEDMEM_GenDriver.hxx" -#include "MEDMEM_define.hxx" - -#include "MEDMEM_FieldForward.hxx" - -#include - -namespace MEDMEM { - - class GMESH; - //class MED; - class GENDRIVER; - - namespace DRIVERFACTORY { - - MEDMEM_EXPORT extern bool globalVtkBinaryFormatForWriting; - - MEDMEM_EXPORT bool getVtkBinaryFormatForWriting(); - - MEDMEM_EXPORT void setVtkBinaryFormatForWriting(bool isBinary); - - MEDMEM_EXPORT driverTypes deduceDriverTypeFromFileName(const std::string & fileName); - - driverTypes deduceDriverTypeFromFileName(const std::string & fileName); - - MEDMEM_EXPORT GENDRIVER * buildDriverForMesh(driverTypes driverType, - const std::string & fileName, - GMESH *mesh,const string & driverName, - MED_EN::med_mode_acces access); - - template - GENDRIVER * buildDriverForField(driverTypes driverType, - const std::string & fileName, - FIELD *fielde, - MED_EN::med_mode_acces access); - MEDMEM_EXPORT GENDRIVER * buildMeshDriverFromFile(const string & fileName, - GMESH * ptrMesh, - MED_EN::med_mode_acces access); - template - GENDRIVER * buildFieldDriverFromFile(const string & fileName, - FIELD * ptrField, - MED_EN::med_mode_acces access); - MEDMEM_EXPORT GENDRIVER * buildConcreteMedDriverForMesh(const std::string & fileName, - GMESH *mesh, - const string & driverName, - MED_EN::med_mode_acces access, - MED_EN::medFileVersion version); - template - GENDRIVER * buildConcreteMedDriverForField(const std::string & fileName, - FIELD *fielde, - MED_EN::med_mode_acces access, - MED_EN::medFileVersion version); - } -} - -#include"MEDMEM_DriverFactory.ixx" - -#endif diff --git a/src/MEDMEM/MEDMEM_DriverFactory.ixx b/src/MEDMEM/MEDMEM_DriverFactory.ixx deleted file mode 100644 index 4c83cf9f0..000000000 --- a/src/MEDMEM/MEDMEM_DriverFactory.ixx +++ /dev/null @@ -1,219 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef DRIVERFACTORY_IXX -#define DRIVERFACTORY_IXX - -#include "MEDMEM_VtkFieldDriver.hxx" -#include "MEDMEM_MedFieldDriver.hxx" -#include "MEDMEM_AsciiFieldDriver.hxx" -#include "MEDMEM_EnsightFieldDriver.hxx" - -namespace MEDMEM { - template - GENDRIVER * DRIVERFACTORY::buildDriverForField(driverTypes driverType, - const std::string & fileName, - FIELD *field, - MED_EN::med_mode_acces access) - { - GENDRIVER *ret; - switch(driverType) - { - case MED_DRIVER : { - switch(access) - { - case MED_EN::RDONLY : { - ret = new MED_FIELD_RDONLY_DRIVER(fileName,field); - break; - } - case MED_EN::WRONLY : { - ret= new MED_FIELD_WRONLY_DRIVER(fileName,field); - break; - } - case MED_EN::RDWR : { - ret = new MED_FIELD_RDWR_DRIVER(fileName,field); - break; - } - default: - throw MED_EXCEPTION ("access type has not been properly specified to the method"); - } - break; - } - - case ENSIGHT_DRIVER : { - switch(access) - { - case MED_EN::RDONLY : { - ret = new ENSIGHT_FIELD_RDONLY_DRIVER(fileName,field); - break; - } - case MED_EN::WRONLY : { - ret=new ENSIGHT_FIELD_WRONLY_DRIVER(fileName,field); - break; - } - case MED_EN::RDWR : { - throw MED_EXCEPTION ("not yet implemented"); - break ; - } - default: - throw MED_EXCEPTION ("access type has not been properly specified to the method"); - } - break; - } - - case VTK_DRIVER : { - switch(access) - { - case MED_EN::RDONLY : { - throw MED_EXCEPTION ("access mode other than MED_ECRI and MED_REMP has been specified with the VTK_DRIVER type which is not allowed because VTK_DRIVER is only a write access driver"); - break; - } - case MED_EN::WRONLY : { - ret=new VTK_FIELD_DRIVER(fileName,field); - break; - } - case MED_EN::RDWR : { - ret=new VTK_FIELD_DRIVER(fileName,field); - break ; - } - default: - throw MED_EXCEPTION ("access type has not been properly specified to the method"); - } - break; - } - - case GIBI_DRIVER : { - throw MED_EXCEPTION ("driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD"); - break; - } - - case PORFLOW_DRIVER : { - throw MED_EXCEPTION ("driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD"); - break; - } - - case ASCII_DRIVER : { - switch(access) - { - case MED_EN::WRONLY : { - ret=new ASCII_FIELD_DRIVER(fileName,field); - break; - } - default: - throw MED_EXCEPTION ("driver ASCII_DRIVER on FIELD only in write mod"); - } - break; - } - - case NO_DRIVER : { - throw MED_EXCEPTION ("driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD"); - break; - } - default: - MED_EXCEPTION ("driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD"); - } - return ret; - } - - template - GENDRIVER * DRIVERFACTORY::buildFieldDriverFromFile(const string & fileName, - FIELD * ptrField, - MED_EN::med_mode_acces access) - { - MED_EN::medFileVersion version = MED_EN::V22; - - try - { - version = getMedFileVersion(fileName); - } - catch (MEDEXCEPTION & ) - { - } - - MESSAGE_MED("buildFieldDriverFromFile version of the file " << version); - - GENDRIVER * driver=0; - - switch(access) - { - case MED_EN::RDONLY : { - if (version == MED_EN::V21) - throw MED_EXCEPTION ("med-2.1 files are no more supported"); - else if (version == MED_EN::V22) - driver = new MED_FIELD_RDONLY_DRIVER(fileName,ptrField); - return driver; - } - case MED_EN::WRONLY : { - if (version == MED_EN::V21) - throw MED_EXCEPTION ("med-2.1 files are no more supported"); - else if (version == MED_EN::V22) - driver = new MED_FIELD_WRONLY_DRIVER(fileName,ptrField); - return driver; - } - case MED_EN::RDWR : { - if (version == MED_EN::V21) - throw MED_EXCEPTION ("med-2.1 files are no more supported"); - else if (version == MED_EN::V22) - driver = new MED_FIELD_RDWR_DRIVER(fileName,ptrField); - return driver; - } - default: - throw MED_EXCEPTION ("access type has not been properly specified to the method"); - } - return driver; - } - - template - GENDRIVER * DRIVERFACTORY::buildConcreteMedDriverForField(const std::string & fileName, - FIELD *ptrField, - MED_EN::med_mode_acces access, - MED_EN::medFileVersion version) - { - - MESSAGE_MED("buildConcreteMedDriverForField version of the file " << version); - - if (version == MED_EN::V21) - throw MED_EXCEPTION ("med-2.1 files are no more supported"); - - GENDRIVER * driver=0; - - switch(access) - { - case MED_EN::RDONLY : { - driver = new MED_FIELD_RDONLY_DRIVER(fileName,ptrField); - return driver; - } - case MED_EN::WRONLY : { - driver = new MED_FIELD_WRONLY_DRIVER(fileName,ptrField); - return driver; - } - case MED_EN::RDWR : { - driver = new MED_FIELD_RDWR_DRIVER(fileName,ptrField); - return driver; - } - default: - throw MED_EXCEPTION ("access type has not been properly specified to the method"); - } - return driver; - } -} -#endif diff --git a/src/MEDMEM/MEDMEM_DriverTools.cxx b/src/MEDMEM/MEDMEM_DriverTools.cxx deleted file mode 100644 index 7a0da5dd8..000000000 --- a/src/MEDMEM/MEDMEM_DriverTools.cxx +++ /dev/null @@ -1,1469 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_DriverTools.hxx" -#include "MEDMEM_STRING.hxx" -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Group.hxx" -#include "MEDMEM_Field.hxx" - -#include -#include - -using namespace std; -using namespace MED_EN; - -#define DUMP_LINES_LIMIT 20 - -namespace MEDMEM { - -// avoid coping sortedNodeIDs -_maille::_maille(const _maille& ma) - : sommets(ma.sommets), geometricType(ma.geometricType), - reverse(ma.reverse), sortedNodeIDs(0), _ordre(ma._ordre) -{ -} - -// Cet opérateur permet d'ordonner les mailles dans un set suivant l'ordre requis par MED -bool _maille::operator < (const _maille& ma) const -{ - // si le type géométrique differe, la comparaison est basée dessus - // sinon on se base sur une comparaison des numéros de sommets - // we compare _mailles of only same geometricType due to maillageByType usage - size_t l=sommets.size(); - if ( dimension() > 3 ) { // poly - size_t l2 = ma.sommets.size(); - if ( l != l2 ) - return l < l2; - } - const int* v1 = getSortedNodes(); - const int* v2 = ma.getSortedNodes(); - for ( const int* vEnd = v1 + l; v1 < vEnd; ++v1, ++v2 ) - if(*v1 != *v2) - return *v1 < *v2; - return false; // cas d'égalité - -// if(geometricType==ma.geometricType) -// { -// // construction de deux vecteur temporaire contenant les numeros de sommets -// // pour faire le tri et les comparaisons -// size_t l=sommets.size(); -// if ( dimension() > 3 ) { // poly -// size_t l2 = ma.sommets.size(); -// if ( l != l2 ) -// return l < l2; -// } -// std::vector v1(l); -// std::vector v2(l); -// for (unsigned int i=0; i!=l; ++i) -// { -// v1[i]=nodeNum(i); -// v2[i]=ma.nodeNum(i); -// } -// std::sort(v1.begin(), v1.end()); -// std::sort(v2.begin(), v2.end()); -// for(std::vector::const_iterator i1=v1.begin(), i2=v2.begin(); i1!=v1.end(); ++i1, ++i2) -// if(*i1 != *i2) -// return *i1 < *i2; -// return false; // cas d'égalité -// } -// else -// return geometricType= 0 && i < (int)sommets.size() ); - int i2 = ( i + 1 == (int)sommets.size() ) ? 0 : i + 1; - if ( reverse ) - return make_pair( sommets[i2]->first, sommets[i]->first ); - else - return make_pair( sommets[i]->first, sommets[i2]->first ); -} - -// retourne l'entité d'une maille en fonction de la dimension du maillage. -MED_EN::medEntityMesh _maille::getEntity(const int meshDimension) const throw (MEDEXCEPTION) -{ - const char * LOC = "_maille::getEntity(const int meshDimension)" ; -// BEGIN_OF_MED(LOC); - - int mailleDimension = this->dimensionWithPoly(); - medEntityMesh entity; - if (mailleDimension == meshDimension) - entity = MED_CELL; - else - switch (mailleDimension) - { - case 0 : - entity = MED_NODE; - break; - case 1 : - entity = MED_EDGE; - break; - case 2 : - entity = MED_FACE; - break; - default : - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Impossible de determiner l'entite de la maille.")); - } -return entity; - -//END_OF_MED(LOC); -} - -void _maillageByDimIterator::init(const int dim, const bool convertPoly ) -{ - myIt = myImed->maillageByType.begin(); - myEnd = myImed->maillageByType.end(); - myDim = dim; - myConvertPoly = convertPoly; - nbRemovedByType = & myImed->nbRemovedByType; -} - -std::ostream& operator << (std::ostream& os, const _maille& ma) -{ - os << "maille " << ma.ordre() << " (" << ma.geometricType << ") : < "; - os << ma.nodeNum(0); - for( unsigned i=1; i!=ma.sommets.size(); ++i) - os << ", " << ma.nodeNum( i ); - os << " > sortedNodeIDs: "; - if ( ma.sortedNodeIDs ) { - os << "< "; - for( unsigned i=0; i!=ma.sommets.size(); ++i) - os << ( i ? ", " : "" ) << ma.sortedNodeIDs[ i ]; - os << " >"; - } - else { - os << "NULL"; - } - if ( ma.isMerged() ) - os << " MERGED "; - return os; -} - -std::ostream& operator << (std::ostream& os, const _groupe& gr) -{ - os << "--- Groupe " << gr.nom << " --- " << std::endl ; - os << " -> liste des sous-groupes : "; - for( std::vector::const_iterator i=gr.groupes.begin(); i!=gr.groupes.end(); ++i) - os << *i << " "; - - os << std::endl << " -> liste des "<< gr.mailles.size() << " mailles : " << std::endl; - - _groupe::TMailleIter i1=gr.mailles.begin(); - int l; - for(l = 0; l < DUMP_LINES_LIMIT && i1!=gr.mailles.end(); i1++, l++) - os << setw(3) << l+1 << " " << *(*i1) << std::endl; - - if ( l == DUMP_LINES_LIMIT ) - os << " ... skip " << gr.mailles.size() - l << " mailles" << endl; - - os << " relocMap, size=" << gr.relocMap.size() << endl; - map::const_iterator it = gr.relocMap.begin(); - for ( l = 0; l < DUMP_LINES_LIMIT && it != gr.relocMap.end(); ++it, ++l ) - os << " (" << it->first << "," << it->second << ")"; - if ( gr.relocMap.size() > 0 ) - os << endl; - return os; -} - -std::ostream& operator << (std::ostream& os, const _noeud& no) -{ - os << "noeud " << no.number << " : < "; - std::vector::const_iterator i=no.coord.begin(); - os << *i++ ; - for( ; i!=no.coord.end(); ++i) - os << ", " << *i; - os << " >"; - return os; -} - -void MEDMEM::_fieldBase::dump(std::ostream& os) const -{ - os << "field " << "<" << _name << ">" << endl << - " nb sub: " << _sub.size() << endl << - " group index: " << _group_id << endl << - " type: " << _type << endl; - os << " subcomponents:" << endl; - vector< _sub_data >::const_iterator sub_data = _sub.begin(); - for ( ; sub_data != _sub.end(); ++sub_data ) { - os << " group index: " << sub_data->_supp_id << - ", " << sub_data->nbComponents() << " comp names: "; - for ( int i_comp = 0; i_comp < sub_data->nbComponents(); ++i_comp ) - os << " |" << sub_data->_comp_names[ i_comp ] << "|"; - os << endl; - } -} - -std::ostream& operator << (std::ostream& os, const _fieldBase * f) -{ - f->dump( os ); - return os; -} - -std::ostream& operator << (std::ostream& os, const _intermediateMED& mi) -{ - int l; - _maillageByDimIterator maIt( mi ); - while ( const set<_maille >* maillage = maIt.nextType() ) - { - os << "Set des " << maillage->size() - << " mailles of type " << maIt.type() << ": "<< std::endl; - std::set<_maille>::const_iterator i=maillage->begin(); - for( l = 0; l < DUMP_LINES_LIMIT && i!=maillage->end(); ++i, ++l) - os << setw(3) << l+1 << " " <<*i << std::endl; - if ( l == DUMP_LINES_LIMIT ) - os << " ... skip " << maillage->size() - l << " mailles" << endl; - } - os << std::endl << "Vector des " << mi.groupes.size() << " groupes : " << std::endl; - for (unsigned int k=0; k!=mi.groupes.size(); k++) - os << std::setw(3) << k << " " << mi.groupes[k] << std::endl; - - os << std::endl << "map des " << mi.points.size() << " noeuds : " << std::endl; - std::map::const_iterator j=mi.points.begin(); - for( l = 0; l < DUMP_LINES_LIMIT && j!=mi.points.end(); ++j, ++l) - os << j->second << std::endl; - if ( l == DUMP_LINES_LIMIT ) - os << " ... skip " << mi.points.size() - l << " noeuds" << endl; - - os << endl << mi.fields.size() << " fields:" << endl; - std::list<_fieldBase* >::const_iterator fIt = mi.fields.begin(); - for ( l = 0; fIt != mi.fields.end(); ++fIt, ++l ) - os << " - " << l+1 << " " << *fIt << endl; - - return os; -} - - -//======================================================================= -//function : treatGroupes -//purpose : detect groupes of mixed dimension and erase groupes that -// won't be converted -//======================================================================= - -void _intermediateMED::treatGroupes() -{ - const char * LOC = "_intermediateMED::treatGroupes() : "; - BEGIN_OF_MED(LOC); - - if ( myGroupsTreated ) - return; - myGroupsTreated = true; - - // -------------------- - // erase useless group - // -------------------- - - // decrease hierarchical depth of subgroups - vector::iterator j; - for (unsigned int i=0; i!=this->groupes.size(); ++i) - { - _groupe& grp = groupes[i]; - //INFOS_MED( i << " " << grp.nom ); - j = grp.groupes.begin(); - while( j!=grp.groupes.end() ) { - int grpInd = *j-1; - if ( grpInd < 0 || grpInd >= (int)groupes.size() ) { - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad subgroup index: " << grpInd << - ", in " << i << " groupe.nom=" << grp.nom)); - } - _groupe & sub_grp = groupes[ grpInd ]; - if ( !sub_grp.groupes.empty() ) { - MESSAGE_MED("High hierarchical depth of subgroups in group " << i ); - *j = sub_grp.groupes[0]; // replace j with its 1st subgroup - // push back the rest subs - for ( int k = 1; k < (int)sub_grp.groupes.size(); ++k ) - grp.groupes.push_back( sub_grp.groupes[ k ]); - // vector maybe is reallocated: restart iterator - j = grp.groupes.begin(); - } - else - j++; - } - // remove empty sub-groupes - j = grp.groupes.begin(); - while ( j!=grp.groupes.end() ) { - if ( groupes[*j-1].empty() ) { - grp.groupes.erase( j ); - j = grp.groupes.begin(); - } - else - j++; - } - } - // get indices of groups that are field support - - // do not erase them and their subgroups - std::set groups2convert; - std::list< _fieldBase* >::const_iterator fIt = fields.begin(); - for ( ; fIt != fields.end(); ++fIt ) - (*fIt)->getGroupIds( groups2convert, true ); - - // keep named groups and their subgroups - for (unsigned int i=0; i!=this->groupes.size(); ++i) - { - _groupe& grp = groupes[i]; - if ( grp.empty() || grp.nom.empty() ) - continue; - groups2convert.insert( i ); - for( j = grp.groupes.begin(); j!=grp.groupes.end(); ++j) - groups2convert.insert( *j-1 ); - } - // erase groups that are not in groups2convert - for (unsigned int i=0; i!=this->groupes.size(); ++i) - { - if ( groups2convert.find( i ) == groups2convert.end() ) { - _groupe& grp = groupes[i]; - grp.mailles.clear(); - grp.groupes.clear(); - MESSAGE_MED( "Erase " << i << "-th group " << grp.nom ); - } - } - - // --------------------------------------------------- - // define if there are groups with mixed entity types - // --------------------------------------------------- - - hasMixedCells = false; - for (unsigned int i=0; i!=this->groupes.size(); ++i) - { - _groupe& grp = groupes[i]; - if ( grp.groupes.empty() ) - continue; - - // check if sub-groups have different dimension - j = grp.groupes.begin(); - int dim = groupes[*j-1].mailles[0]->dimension(); - for( j++; j!=grp.groupes.end(); ++j) { - int dim2 = groupes[*j-1].mailles[0]->dimension(); - if ( dim != dim2 ) { - if ( dim == 0 || dim2 == 0 || dim + dim2 == 9 ) { - // cant create a group of nodes plus anything else, - // neither a group of polygones + polyhedrons - grp.mailles.clear(); - grp.groupes.clear(); - MESSAGE_MED( "Erase mixed dim group with nodes:" << i << "-th group " << grp.nom ); - break; - } - int d1 = dim < 4 ? dim : dim - 2; // care of poly - int d2 = dim2 < 4 ? dim2 : dim2 - 2; - if ( d1 != d2 ) { - hasMixedCells = true; - MESSAGE_MED( "Mixed dim group: " << i << "-th " << grp.nom << - " dim1 = " << dim << " dim2 = " << dim2 ); - } - } - } - } - -// if ( hasMixedCells ) -// INFOS_MED( "There will be groups of mixed dimention" ); - END_OF_MED(LOC); -} - -void _intermediateMED::numerotationMaillage() -{ - const char* LOC = "_intermediateMED::numerotationMaillage() : "; - BEGIN_OF_MED(LOC); - if ( myMaillesNumerated ) - return; - myMaillesNumerated = true; - - treatGroupes(); - - set<_maille>::const_iterator i, iEnd; - - // numerotation mailles of type MED_POINT1 by node number - bool hasPointMailles = false; - if ( const set<_maille> * points = _maillageByDimIterator( *this, 0 ).nextType() ) { - hasPointMailles = true; - numerotationPoints(); - for ( i = points->begin(), iEnd = points->end(); i != iEnd; ++i ) - i->setOrdre( i->sommets[0]->second.number ); // is merged if point is merged - } - - // loop on entities - for ( int dim = 1; dim <= 3; ++dim ) - { - int iterDim = hasMixedCells ? -1 : dim; - const bool skipFirstType = ( hasPointMailles && hasMixedCells ); - - // check if any numeration is present - bool hasNumeration = true; - _maillageByDimIterator entityMailles( *this, iterDim, true ); - if ( skipFirstType ) entityMailles.nextType(); - while ( const set<_maille> * typeMailles = entityMailles.nextType() ) { - if ( typeMailles->begin()->ordre() == 0 || typeMailles->rbegin()->ordre() == 0 ) { - hasNumeration = false; - break; - } - } - // check if re-numeration is needed - bool ok = false, renumEntity = false; - if ( hasNumeration ) - { - ok = true; - _maillageByDimIterator entityMailles( *this, iterDim, true ); - if ( skipFirstType ) entityMailles.nextType(); - - int prevNbElems = 0; - while ( const set<_maille> * typeMailles = entityMailles.nextType() ) - { - unsigned minOrdre = INT_MAX, maxOrdre = 0; - for ( i = typeMailles->begin(), iEnd = typeMailles->end(); i!=iEnd; ++i) { - if ( i->ordre() < minOrdre ) minOrdre = i->ordre(); - if ( i->ordre() > maxOrdre ) maxOrdre = i->ordre(); - } - unsigned typeSize = entityMailles.sizeWithoutMerged(); - if ( typeSize != maxOrdre - minOrdre + 1 ) - ok = false; - if ( prevNbElems != 0 ) { - if ( minOrdre == 1 ) - renumEntity = true; - else if ( prevNbElems+1 != (int)minOrdre ) - ok = false; - } - prevNbElems += typeSize; - } - - if ( ok && renumEntity ) // each geom type was numerated separately - { - entityMailles.init( iterDim, true ); - if ( skipFirstType ) entityMailles.nextType(); - prevNbElems = entityMailles.nextType()->size(); // no need to renumber the first type - while ( const set<_maille> * typeMailles = entityMailles.nextType() ) { - for ( i = typeMailles->begin(), iEnd = typeMailles->end(); i!=iEnd; ++i) - i->setOrdre( i->ordre() + prevNbElems ); - prevNbElems += typeMailles->size(); - } - } - } - if ( !ok ) - { - int i_maille=0; - entityMailles.init( iterDim, true ); - if ( skipFirstType ) entityMailles.nextType(); - while ( const set<_maille> * typeMailles = entityMailles.nextType() ) - for ( i = typeMailles->begin(), iEnd = typeMailles->end(); i!=iEnd; ++i) - i->setOrdre( ++i_maille ); - } - } - END_OF_MED(LOC); -} - -bool _intermediateMED::numerotationPoints() -{ - if ( !myNodesNumerated ) // is negative if numerated by merge - { - int i_noeud=0; - for( map::iterator i=points.begin(); i!=points.end(); ++i) - i->second.number = ++i_noeud ; - myNodesNumerated = true; - return true; - } - return false; -} - -int _intermediateMED::nbMerged(int type) const //!< nb nodes removed by merge -{ - TNbByType::const_iterator typeNb = nbRemovedByType.find( type ); - return ( typeNb == nbRemovedByType.end() ? 0 : typeNb->second ); -} - - -/*! - * \if developper - * create a MED COORDINATE from the intermediate structure. - * \endif - */ -COORDINATE * _intermediateMED::getCoordinate(const string & coordinateSystem) -{ - const medModeSwitch mode=MED_FULL_INTERLACE; - int spaceDimension=points.begin()->second.coord.size(); - int numberOfNodes=points.size() - nbMerged( MED_POINT1 ); - - // creation du tableau des coordonnees en mode MED_FULL_INTERLACE - double * coord = new double[spaceDimension*numberOfNodes]; - double * xyz = coord; - for( std::map::const_iterator i=points.begin(); i!=points.end(); ++i ) - if ( i->second.number > 0 ) { - std::copy(i->second.coord.begin(), i->second.coord.end(), xyz ); - xyz += spaceDimension; - } - - // creation de l'objet COORDINATE - COORDINATE * coordinate = new COORDINATE(spaceDimension, numberOfNodes, mode); - coordinate->setCoordinates(mode,coord); - delete [] coord; - coordinate->setCoordinatesSystem(coordinateSystem); - return coordinate; -} - - -/*! - * \if developper - * create a MED CONNECTIVITY from the intermediate structure. - * \endif - */ -CONNECTIVITY * _intermediateMED::getConnectivity() -{ - const char * LOC = "_intermediateMED::getConnectivity() : "; - BEGIN_OF_MED(LOC); - - int numberOfNodes=points.size() - nbMerged( MED_POINT1 ); // number of nodes in the mesh - medEntityMesh entity; - CONNECTIVITY *Connectivity = NULL, *Constituent = NULL; - - set<_maille>::const_iterator i, iEnd; // iterateurs sur les mailles - - // find out mesh dimension - medGeometryElement meshDim; - _maillageByDimIterator allMailles( *this, -1, true ); - while ( allMailles.nextType() ) - meshDim = allMailles.dim(); - - // renumerote les points de 1 a n (pour le cas ou certains points ne sont pas presents dans le maillage d'origine) - numerotationPoints(); - - // loop on entities - for ( int dim = 0; dim <= 3; ++dim ) - { - // skip nodes and elements of or less dimension - // Unfortunately, it is impossible because of MESH::createFamilies() that requires - // presence of connectivity even for nodes! - //int dimension_maillage_moin_2=maillage.rbegin()->dimension() - 2; - - // tableau de travail : nombre d'elements pour chaque type geometrique - vector count; - count.reserve( maillageByType.size() ); - count.push_back( 1 ); - - // tableau de travail : stockage des types geometriques pour UNE entite - vector types; - types.reserve( maillageByType.size() ); - - // iterator returning mailles of each type of an entity, - // but if hasMixedCells, we iterate on all types at every dim, since - // in this case we store POINT1 elems as MED_NODE and - // elems of all the rest types as MED_CELL - int iterDim = hasMixedCells ? -1 : dim; - _maillageByDimIterator entityMailles( *this, iterDim, /*convertPoly=*/true ); - - // count nb of types and nb mailles of each type - int dimension=0; - if ( dim == 0 ) { - if ( entityMailles.nextType() && entityMailles.dim() == 0 ) - { - count.push_back( count.back() + numberOfNodes ); - types.push_back( entityMailles.type() ); - } - } - else { - while ( entityMailles.nextType() ) - { - //if ( entityMailles.dim() > 3 ) break; // ignore poly - - dimension = entityMailles.dim(); - if ( dimension == 0 ) continue; // if hasMixedCells, iterator returns all types - - count.push_back( count.back() + entityMailles.sizeWithoutMerged() ); - types.push_back( entityMailles.type() ); - } - } - int numberOfTypes = types.size(); // nombre de types de l'entite - if ( numberOfTypes == 0 ) - continue; - - if ( dimension == meshDim ) entity=MED_CELL; - else if (dimension==2 ) entity=MED_FACE; - else if (dimension==1 ) entity=MED_EDGE; - else if (dimension==0 ) entity=MED_NODE; - - Connectivity = new CONNECTIVITY ( numberOfTypes, entity ); - Connectivity->setEntityDimension( dimension ); - Connectivity->setNumberOfNodes ( numberOfNodes ); - Connectivity->setGeometricTypes ( &types[0], entity); - Connectivity->setCount ( &count[0], entity ); - - int prevNbElems = 1; // in previous type - for (int k=0; k!=numberOfTypes; ++k ) - { - set<_maille> & typeMailles = maillageByType[ types[k] ]; - i = typeMailles.begin(), iEnd = typeMailles.end(); - int nbMailles = count[k+1]-count[k]; - int* connectivity = 0, *index = 0; - - switch ( types[k] ) - { - case MED_POLYGON: - { - // put polygones in order of increasing number - vector orderedPoly( nbMailles ); - for ( ; i != iEnd; ++i ) - if ( !i->isMerged() ) - orderedPoly[ i->ordre() - prevNbElems ] = &(*i); - - // make index - int* polyIndex = index = new int[ nbMailles + 1 ]; - vector::iterator poly = orderedPoly.begin(), polyEnd = orderedPoly.end(); - for ( *polyIndex++ = 1; polyIndex < index+nbMailles+1; ++poly, ++polyIndex) - *polyIndex = polyIndex[-1] + (*poly)->sommets.size(); - - // make connectivity - int nbNodes = polyIndex[-1]; - int* conn = connectivity = new int[ nbNodes ]; - for ( poly = orderedPoly.begin(); poly != polyEnd; ++poly) { - for ( int j = 0, nbNodes = (*poly)->sommets.size(); j < nbNodes; ++j ) - *conn++ = (*poly)->nodeNum( j ); - } - break; - } - - case MED_POLYHEDRA: - { - if ( typeMailles.size() != polyherdalNbFaceNodes.size() ) - throw MEDEXCEPTION (LOCALIZED(STRING(LOC) << "Missing info on polyhedron faces")); - - typedef TPolyherdalNbFaceNodes::iterator TPolyFaNoIter; - TPolyFaNoIter polyFaNo, polyFaNoEnd = polyherdalNbFaceNodes.end(); - - // put poly's in order of increasing number and count size of connectivity - vector orderedPolyFaNo( nbMailles ); - int connSize = 0; - for ( polyFaNo = polyherdalNbFaceNodes.begin(); polyFaNo != polyFaNoEnd; ++polyFaNo ) - if ( !polyFaNo->first->isMerged() ) - { - orderedPolyFaNo[ polyFaNo->first->ordre() - prevNbElems ] = polyFaNo; - connSize += polyFaNo->first->sommets.size() + polyFaNo->second.size() - 1; - } - vector::iterator pfnIter, pfnEnd = orderedPolyFaNo.end(); - - // make index and connectivity - int* conn = connectivity = new int[ connSize ]; - int* ind = index = new int[ nbMailles+1 ]; - *ind++ = 1; - for ( pfnIter = orderedPolyFaNo.begin(); pfnIter != pfnEnd; ++pfnIter) - { - const _maille * poly = (*pfnIter)->first; - const vector & nbFaceNodes = (*pfnIter)->second; - int nbNodes = 0; - for ( unsigned iFace = 0; iFace < nbFaceNodes.size(); ++iFace ) - { - for ( int j = 0, nbFNodes = nbFaceNodes[iFace]; j < nbFNodes; ++j ) - *conn++ = poly->nodeNum( nbNodes++ ); - *conn++ = -1; - } - conn--; - *ind = ind[-1] + nbNodes; - ++ind; - } - break; - } - - default: // CLASSIC TYPES - - // copie des sommets dans connectivity et set dans Connectivity - int nbSommetsParMaille = i->sommets.size(); - int nbSommets = nbMailles * nbSommetsParMaille; - connectivity = new int[ nbSommets ]; - if ( entity==MED_NODE ) - { - for (int l=0; l!=nbSommets; ++l) - connectivity[l] = l+1; - } - else - { - for ( ; i != iEnd; ++i ) { // loop on elements of geom type - if ( i->isMerged() ) - continue; - int* mailleConn = connectivity + nbSommetsParMaille * ( i->ordre() - prevNbElems ); - if ( i->reverse ) - for ( int n=nbSommetsParMaille-1; n!=-1; --n) - *mailleConn++ = i->nodeNum( n ); - else - for ( int n=0; n != nbSommetsParMaille; ++n) - *mailleConn++ = i->nodeNum( n ); - } - // DO NOT ERASE, maillage will be used while fields construction - //maillage.erase(j); ; // dangereux, mais optimise la memoire consommee! - } - } - - Connectivity->setNodal (connectivity, entity, types[k], index); - delete [] connectivity; - delete [] index; index = 0; - - prevNbElems += nbMailles; - } - - if ( Constituent ) - Connectivity->setConstituent (Constituent); - // stocke Connectivity pour utilisation dans setConstituent lors de la boucle suivante - Constituent = Connectivity; - - if ( entity == MED_CELL ) - break; // necessary if hasMixedCells - } - - END_OF_MED(LOC); - return Connectivity; -} - - -/*! - * \if developper - * fill the arguments vector of groups from the intermediate structure. - * This function must be called before getConnectivity() - * WARNING: new GROUP on all elements are invalid: numbers are not set! - * to make them valid it is necessary to update() them after setting - * connectivity to mesh - * \endif - */ -void _intermediateMED::getGroups(vector & _groupCell, - vector & _groupFace, - vector & _groupEdge, - vector & _groupNode, MESH * _ptrMesh) -{ - const char* LOC = "_intermediateMED::getGroups() : "; - BEGIN_OF_MED(LOC); - - //medGroupes.resize( groupes.size(), 0 ); - if (maillageByType.size() == 0) { - INFOS_MED( "Erreur : il n'y a plus de mailles"); - return; - } - - // get indices of groups that are field support - do not skip them - std::set support_groups; - std::list< _fieldBase* >::const_iterator fIt = fields.begin(); - for ( ; fIt != fields.end(); ++fIt ) - (*fIt)->getGroupIds( support_groups, false ); - - numerotationMaillage(); // Renumerotation des mailles par entite - - int dimension_maillage=getMeshDimension(); - - for (size_t i=0; i!=this->groupes.size(); ++i) - { - _groupe& grp = groupes[i]; - if ( grp.medGroup /*medGroupes[ i ]*/ ) - continue; // grp already converted into a MED group - - bool isFieldSupport = ( support_groups.find( i ) != support_groups.end() ); - // si le groupe est vide, ou si le groupe n'est pas nommé : on passe au suivant - if ( grp.empty() || ( grp.nom.empty() && !isFieldSupport )) { - if ( !grp.nom.empty() ) { - INFOS_MED("Skip group " << i << " " << grp.nom); -// } else { -// MESSAGE_MED("Skip group " << i << " <" << grp.nom << "> " << ( grp.empty() ? ": empty" : "")); - } - continue; - } - - // Build a set of mailles: sort mailles by type and exclude maille doubling - bool isSelfIntersect = false; - typedef set< set<_maille>::iterator, _mailleIteratorCompare > TMailleSet; - TMailleSet mailleSet; - if( grp.groupes.size() ) {// le groupe i contient des sous-maillages - int nb_elem = 0; - for( vector::iterator j=grp.groupes.begin(); j!=grp.groupes.end(); ++j) - { - nb_elem += groupes[*j-1].mailles.size(); - _groupe::TMailleIter maIt=groupes[*j-1].mailles.begin(); - for( ; maIt!=groupes[*j-1].mailles.end(); ++maIt) { -// TMailleSet::const_iterator ma_it = mailleSet.find( *maIt ); -// if ( ma_it != mailleSet.end() ) { -// MESSAGE_MED("EQUAL ELEMS: " << *ma_it << " AND " << *maIt); -// } -// else - mailleSet.insert( *maIt ); - } - } - if ( nb_elem != (int)mailleSet.size() ) { // Self intersecting compound group - isSelfIntersect = true; - INFOS_MED("Self intersecting group: " << i << " <" << grp.nom << ">" - << ", mailleSet.size = " << mailleSet.size() << ", sum nb elems = " << nb_elem); - for( vector::iterator j=grp.groupes.begin(); j!=grp.groupes.end(); ++j) - INFOS_MED(" in sub-group "<< *j << " <" << groupes[*j-1].nom << "> " - << groupes[*j-1].mailles.size() << " mailles of type " - << groupes[*j-1].mailles[0]->geometricType); - // if a group serve as a support to a field, then the _field is to be converted - // into several MEDMEM::FIELDs, one per sub-group; if we already skipped some sub-groups, - // we roll back the loop on groups to create MED groups for skipped ones - if ( isFieldSupport ) { - if ( grp.nom.empty() ) // clear group existing for the sake of field only - grp.groupes.clear(); - std::set sub_grps; - for ( fIt = fields.begin(); fIt != fields.end(); ++fIt ) { - _fieldBase * field = (*fIt); - if ( field->_group_id == (int)i ) { - field->_group_id = -1; // -> a field by support - field->getGroupIds( sub_grps, false ); - } - } - if ( (int)i > *sub_grps.begin() ) { // roll back - support_groups.erase( i ); - support_groups.insert( sub_grps.begin(), sub_grps.end() ); - i = *sub_grps.begin() - 1; - continue; - } - } - } - } - else { - _groupe::TMailleIter maIt=grp.mailles.begin(); - for(; maIt!=grp.mailles.end(); ++maIt) - mailleSet.insert( *maIt ); - if ( grp.mailles.size() != mailleSet.size() ) - INFOS_MED( "Self intersecting group: " << i << " <" << grp.nom << ">" - << ", mailleSet.size = " << mailleSet.size() - << ", nb elems = " << grp.mailles.size()); - } - // MEDMEM does not allow constituents of -2 and less dimension - // but do not skip node group - int group_min_dim = (**mailleSet.begin()).dimensionWithPoly(); - int group_max_dim = (**(--mailleSet.end())).dimensionWithPoly(); - if ( group_max_dim != 0 && group_min_dim <= dimension_maillage - 2 ) { - MESSAGE_MED("Skip group: " << i << " <" << grp.nom << "> - too small dimension: " - << group_min_dim); - continue; - } - - // initialise groupe_entity a l'entite de la premiere maille du groupe - medEntityMesh groupe_entity = (**mailleSet.rbegin()).getEntity(dimension_maillage); - if ( hasMixedCells && group_min_dim > 0 ) - groupe_entity = MED_CELL; - - // total nb of elements in mesh of groupe_entity - int totalNbElements = 0; - if ( groupe_entity == MED_NODE ) - totalNbElements = points.size() - nbMerged( MED_POINT1 ); - else { - int entityDim = hasMixedCells ? -1 : group_min_dim; - _maillageByDimIterator allMailles( *this, entityDim, true ); - while ( allMailles.nextType() ) - if ( allMailles.dim() > 0 ) - totalNbElements += allMailles.sizeWithoutMerged(); - } - const bool isOnAll = ((int) mailleSet.size() == totalNbElements ); - - // if !isOnAll, build a map _maille::ordre() -> index in GROUP.getNumber(MED_ALL_ELEMENTS). - // It is used while fields building. - if ( !isOnAll || isSelfIntersect || isFieldSupport ) { - TMailleSet::iterator maIt = mailleSet.begin(); - for ( int iMa = 0; maIt != mailleSet.end(); maIt++ ) - grp.relocMap.insert( make_pair( (*maIt)->ordre(), ++iMa )); - } - //Parcours des mailles (a partir de la deuxieme) pour compter les types geometriques - int nb_geometric_types=1; - TMailleSet::iterator j=mailleSet.begin(); - medGeometryElement geometrictype=(**j).geometricType; - for ( ++j ; j!=mailleSet.end(); ++j ) - { - //Compte nombre de types geometriques - if ( (**j).geometricType != geometrictype ) // si on change de type geometrique - { - nb_geometric_types++; - geometrictype=(**j).geometricType; - } - } - - MED_EN::medGeometryElement * tab_types_geometriques = new MED_EN::medGeometryElement[nb_geometric_types]; - int * tab_index_types_geometriques = new int[nb_geometric_types+1]; - int * tab_numeros_elements = new int[mailleSet.size()]; - int * tab_nombres_elements = new int[nb_geometric_types]; - - //Remplit tableaux entree des methodes set - int indice_mailles=0/*, maxOrdre = -1*/; - j=mailleSet.begin(); - geometrictype=(**j).geometricType; - tab_index_types_geometriques[0]=1; - int indice_types_geometriques=1; - tab_types_geometriques[0]=geometrictype; - //parcours des mailles du groupe - for ( ; j!=mailleSet.end(); ++j , ++indice_mailles) - { - const _maille& ma = **j; - tab_numeros_elements[indice_mailles]= ma.ordre(); -// if ( maxOrdre < tab_numeros_elements[indice_mailles] ) -// maxOrdre = tab_numeros_elements[indice_mailles]; - if (ma.geometricType != geometrictype) - { - tab_index_types_geometriques[indice_types_geometriques]=indice_mailles+1; - geometrictype=ma.geometricType; - tab_types_geometriques[indice_types_geometriques]=geometrictype; - ++indice_types_geometriques; - } - } - tab_index_types_geometriques[indice_types_geometriques]=indice_mailles+1; - for (int k=0; k != nb_geometric_types; ++k) - { - tab_nombres_elements[k] = tab_index_types_geometriques[k+1]-tab_index_types_geometriques[k]; - } - //INFOS_MED( "MAX ORDRE in grp " << grp.nom << " entity " << groupe_entity << " : " << maxOrdre); - - //Determination type entite du groupe - vector * vect_group; - switch ( groupe_entity ) - { - case MED_CELL : - vect_group= & _groupCell; - break; - case MED_FACE : - vect_group= & _groupFace; - break; - case MED_EDGE : - vect_group= & _groupEdge; - break; - case MED_NODE : - vect_group= & _groupNode; - break; - } - - //Creation nouveau groupe MED - GROUP * new_group = new GROUP(); - grp.medGroup = new_group; - //Appel methodes set - //new_group->setTotalNumberOfElements(mailleSet.size()); - new_group->setName(grp.nom); - new_group->setMesh(_ptrMesh); - if ( _ptrMesh ) - _ptrMesh->removeReference(); - new_group->setNumberOfGeometricType(nb_geometric_types); - new_group->setGeometricType(tab_types_geometriques); - new_group->setNumberOfElements(tab_nombres_elements); - new_group->setNumber(tab_index_types_geometriques,tab_numeros_elements); - new_group->setEntity(groupe_entity); - new_group->setAll( isOnAll ); - - vect_group->push_back(new_group); - - // Issue 0021311. Use case: a gibi group has references (recorded in pile 1) - // and several names (pile 27) refer (pile 10) to this group. - // We create a copy of this group per each named reference - for ( unsigned iRef = 0 ; iRef < grp.refNames.size(); ++iRef ) - if ( !grp.refNames[ iRef ].empty() ) - { - vect_group->push_back( new GROUP( *new_group )); - vect_group->back()->setName( grp.refNames[ iRef ] ); - } - - delete [] tab_types_geometriques; - delete [] tab_index_types_geometriques; - delete [] tab_numeros_elements; - delete [] tab_nombres_elements; - } - - END_OF_MED(LOC); -} - -//======================================================================= -//function : getFamilies -//purpose : create families like MESH::createFamilies() but preserves -// the order of elements in GROUPs defined by constituent families -// order. Call it after getGroups() -//======================================================================= - -// void _intermediateMED::getFamilies(std::vector & _famCell, -// std::vector & _famFace, -// std::vector & _famEdge, -// std::vector & _famNode, MESH * _ptrMesh) -// { -// const char * LOC = "_intermediateMED::getFamilies() : "; -// BEGIN_OF_MED(LOC); - -// int nbElemFam = 0, nbNodeFam = 0; -// std::map< GROUP*, vector< FAMILY * > > grpFamsMap; -// int dimension_maillage=maillage.rbegin()->dimension(); - -// std::set<_maille>::const_iterator i=maillage.begin(); // iterateurs sur les mailles -// std::set<_maille>::const_iterator j=maillage.begin(); - -// do -// { -// // make a family containing mailles shared by the same set of groups -// std::list& grList = i->groupes; // to define the family end -// int dimension = i->dimension(); // to define the entity end -// medGeometryElement type = i->geometricType; -// medEntityMesh entity = i->getEntity( dimension_maillage ); - -// std::vector tab_types_geometriques; -// std::vector tab_index_types_geometriques; -// std::vector tab_nombres_elements; -// std::vector tab_numeros_elements; - -// int iMa = 1, nbtype = 0; -// tab_types_geometriques.push_back( type ); -// tab_index_types_geometriques.push_back( iMa ); - -// // scan family cells and fill the tab that are needed by the create a MED FAMILY -// while (i != maillage.end() && -// i->groupes == grList && -// i->dimension() == dimension) -// { -// if (type != i->geometricType) // si changement de type geometrique -// { -// tab_index_types_geometriques.push_back(iMa); -// tab_nombres_elements.push_back(nbtype); -// nbtype=0; -// type=i->geometricType; -// tab_types_geometriques.push_back(type); // stocke le nouveau type geometrique rencontre -// } -// ++nbtype; -// ++iMa; -// ++i; -// } -// tab_index_types_geometriques.push_back(iMa); -// tab_nombres_elements.push_back(nbtype); // n'a pas été stocké dans la boucle - -// tab_numeros_elements.resize( iMa - 1 ); -// for ( iMa = 0; j != i; j++, iMa++ ) -// tab_numeros_elements[ iMa ] = j->ordre; - -// int id = ( entity == MED_NODE ? ++nbNodeFam : -(++nbElemFam) ); - -// ostringstream name; -// name << "FAM_" << id; - -// // create a empty MED FAMILY and fill it with the tabs we constructed -// FAMILY* newFam = new FAMILY(); -// newFam->setTotalNumberOfElements( iMa ); -// newFam->setName( name.str() ); -// newFam->setMesh( _ptrMesh ); -// newFam->setNumberOfGeometricType( tab_types_geometriques.size() ); -// newFam->setGeometricType( &tab_types_geometriques[0] ); // we know the tab is not empy -// newFam->setNumberOfElements( &tab_nombres_elements[0] ); -// newFam->setNumber( &tab_index_types_geometriques[0], &tab_numeros_elements[0] ); -// newFam->setEntity( entity ); -// newFam->setAll( false ); -// newFam->setIdentifier( id ); -// newFam->setNumberOfGroups( grList.size() ); - -// // Update links between families and groups -// if ( ! grList.empty() ) -// { -// std::string * groupNames = new string[ grList.size() ]; -// std::list::iterator g = grList.begin(); -// for ( int i = 0; g != grList.end(); ++g, ++i ) { -// GROUP * medGROUP = getGroup( *g ); -// groupNames[ i ] = medGROUP->getName(); -// grpFamsMap[ medGROUP ].push_back( newFam ); -// } -// newFam->setGroupsNames(groupNames); -// } -// // store newFam -// std::vector* families = 0; -// switch ( entity ) -// { -// case MED_CELL : -// families = & _famCell; break; -// case MED_FACE : -// families = & _famFace; break; -// case MED_EDGE : -// families = & _famEdge; break; -// case MED_NODE : -// families = & _famNode; break; -// } -// if ( families ) -// families->push_back( newFam ); - -// } while ( i != maillage.end() ); - -// // update references in groups -// std::map< GROUP*, vector< FAMILY * > >::iterator gf = grpFamsMap.begin(); -// for ( ; gf != grpFamsMap.end(); ++gf ) -// { -// gf->first->setNumberOfFamilies( gf->second.size() ); -// gf->first->setFamilies( gf->second ); -// } -//} - -//======================================================================= -//function : getGroup -//purpose : -//======================================================================= - -// GROUP * _intermediateMED::getGroup( int i ) -// { -// if ( i <(int) medGroupes.size() ) -// return medGroupes[ i ]; -// throw MEDEXCEPTION -// (LOCALIZED(STRING("_intermediateMED::getGroup(): WRONG GROUP INDEX: ") -// << medGroupes.size() << " <= " << i )); -// } - -//======================================================================= -//function : getFields -//purpose : -//======================================================================= - -void _intermediateMED::getFields(std::list< FIELD_* >& theFields) -{ - const char * LOC = "_intermediateMED::getFields() : "; - BEGIN_OF_MED(LOC); - - std::list< _fieldBase* >::const_iterator fIt = fields.begin(); - for ( ; fIt != fields.end(); fIt++ ) - { - const _fieldBase* fb = *fIt; - list > ff = fb->getField(groupes); - list >::iterator f_sup = ff.begin(); - for (int j = 1 ; f_sup != ff.end(); f_sup++, ++j ) - { - FIELD_ * f = f_sup->first; - SUPPORT * sup = groupes[ f_sup->second ].medGroup; - if ( !sup ) - throw MEDEXCEPTION - (LOCALIZED(STRING(LOC) <<"_intermediateMED::getFields(), NULL field support: " - << " group index: " << fb->_group_id)); - int nb_elems = sup->getNumberOfElements( MED_ALL_ELEMENTS ); - if ( nb_elems != f->getNumberOfValues() ) - throw MEDEXCEPTION - (LOCALIZED(STRING("_intermediateMED::getFields(), field support size (") - << nb_elems << ") != NumberOfValues (" << f->getNumberOfValues())); - theFields.push_back( f ); - if ( sup->getName().empty() ) { - ostringstream name; - name << "GRP_" << f->getName() << "_" << j; - sup->setName( name.str() ); - } - f->setSupport( sup ); - //f->setIterationNumber( j ); - f->setOrderNumber( j ); - } - } - END_OF_MED(LOC); -} - -//======================================================================= -//function : ~_intermediateMED -//purpose : destructor -//======================================================================= - -_intermediateMED::~_intermediateMED() -{ - MESSAGE_MED( "~_intermediateMED()"); - std::list< _fieldBase* >::const_iterator fIt = fields.begin(); - for ( ; fIt != fields.end(); fIt++ ) - delete *fIt; -} - -//======================================================================= -//function : getGroupIds -//purpose : return ids of main and/or sub- groups -//======================================================================= - -void _fieldBase::getGroupIds( std::set & ids, bool all ) const -{ - if ( hasCommonSupport() ) - ids.insert( _group_id ); - if ( all || !hasCommonSupport() ) { - vector< _sub_data >::const_iterator sub = _sub.begin(); - for ( ; sub != _sub.end(); ++sub ) - ids.insert( sub->_supp_id ); - } -} - -//======================================================================= -//function : hasSameComponentsBySupport -//purpose : -//======================================================================= - -bool _fieldBase::hasSameComponentsBySupport() const -{ - vector< _sub_data >::const_iterator sub_data = _sub.begin(); - const _sub_data& first_sub_data = *sub_data; - for ( ++sub_data ; sub_data != _sub.end(); ++sub_data ) - { - if ( first_sub_data._comp_names != sub_data->_comp_names ) - return false; // diff names of components - - if ( first_sub_data._nb_gauss != sub_data->_nb_gauss ) - return false; // diff nb of gauss points - } - return true; -} - -//======================================================================= -// -//function : mergeNodes -// -//======================================================================= -namespace { - -struct __NOEUD -{ - typedef map::iterator Inoeud; - Inoeud i_noeud; - - __NOEUD() {} - __NOEUD(Inoeud n): i_noeud(n) {} - const double & operator[] (int i) const { return i_noeud->second.coord[i]; } - double operator[] (int i) { return i_noeud->second.coord[i]; } - int dim() const { return i_noeud->second.coord.size(); } - int& num() { return i_noeud->second.number; } - int id() const { return i_noeud->first; } - bool isMerged() const { return i_noeud->second.number < 1; } -}; -//----------------------------------------------------------------------- -double DistanceL2(const __NOEUD &A,const __NOEUD &B) -{ - if ( B.isMerged() ) return DBL_MAX; - const double* cooA = &A[0], *cooB = &B[0], *cooEnd = cooA + A.dim(); - double dist, somme=0; - while ( cooA < cooEnd ) { - dist=((*cooA++) - (*cooB++)); - somme+=dist*dist; - } - return sqrt(somme); -} -//----------------------------------------------------------------------- -struct __NUAGENOEUD -{ - vector< __NOEUD > nodes; - __NUAGENOEUD(_intermediateMED& imed); - __NOEUD & operator [] (int i) { return nodes[i]; } - int size() const { return nodes.size(); } -}; -//----------------------------------------------------------------------- -__NUAGENOEUD::__NUAGENOEUD(_intermediateMED& imed) -{ - nodes.resize( imed.points.size() ); - map::iterator i_noeud = imed.points.begin(); - for( int i = 0; i_noeud!=imed.points.end(); ++i_noeud, ++i ) { - i_noeud->second.number = i+1; - nodes[ i ] = i_noeud; - } -} -//----------------------------------------------------------------------- -// mergeNodes -template int mergeNodes(double tolerance, - _intermediateMED& imed, - vector< int > & /*newNodeIDs*/) -{ - /*typedef dTree<__NOEUD,__NUAGENOEUD,DIM > DTree; - __NUAGENOEUD aNUAGENOEUD( imed ); - DTree tree( &aNUAGENOEUD ); - -// int maxID = imed.points.rbegin()->first; -// newNodeIDs.resize( maxID + 1, 0 ); - - int num = 0, nbRemoved = 0; - int nbNodes = aNUAGENOEUD.size(); - for ( int i = 0; i < nbNodes; ++i ) - { - __NOEUD & node = aNUAGENOEUD[i]; - int & number = node.num(); - if ( number < 0 ) - continue; // already merged - number = ++num; - - list closeNumbers; - int nbCoinsident = tree.get_all_close( node, tolerance, closeNumbers ); - if ( nbCoinsident > 1 ) // not only node it-self found - { - nbRemoved += nbCoinsident-1; // one of coincident nodes remains - int id = node.id(); - list::iterator n = closeNumbers.begin(), nEnd = closeNumbers.end(); - while ( n != nEnd ) { - __NOEUD & coincNode = aNUAGENOEUD[ *n++ ]; - int coincID = coincNode.id(); - if ( coincID != id ) { - coincNode.num() = -number; - //newNodeIDs[ coincID ] = id; - } - } - } - } - return nbRemoved;*/ - return 0; -} -//----------------------------------------------------------------------- -// wrapper of _maille used after merging nodes to find equal mailles -struct _mailleWrap -{ - const _maille* _ma; - - _mailleWrap(const _maille* ma=0): _ma(ma) { if (_ma) _ma->init(); } - ~_mailleWrap() { if (_ma) _ma->init(); } - - bool operator < (const _mailleWrap& mw) const - { - size_t l=_ma->sommets.size(); - const int* v1 = getSortedNodeNums(_ma); - const int* v2 = getSortedNodeNums(mw._ma); - for ( const int* vEnd = v1 + l; v1 < vEnd; ++v1, ++v2 ) - if(*v1 != *v2) - return *v1 < *v2; - return false; // cas d'égalité - } - static const int* getSortedNodeNums(const _maille* ma) - { - if ( !ma->sortedNodeIDs ) { - size_t l=ma->sommets.size(); - ma->sortedNodeIDs = new int[ l ]; - for (size_t i=0; i!=l; ++i) - ma->sortedNodeIDs[i]=ma->nodeNum(i); - std::sort( ma->sortedNodeIDs, ma->sortedNodeIDs + l ); - } - return ma->sortedNodeIDs; - } -}; - -} // namespace - -//======================================================================= -//function : mergeNodesAndElements -//purpose : optionally merge nodes and elements -//======================================================================= - -void _intermediateMED::mergeNodesAndElements(double tolerance) -{ - //const char * LOC = "_intermediateMED::mergeNodesAndElements(): "; - vector< int > newNodeIDs; // for i-th node id, id to replace with - - int nbRemovedNodes = 0; - const int spaceDimension=points.begin()->second.coord.size(); - if ( spaceDimension == 3 ) - nbRemovedNodes = mergeNodes<3>( tolerance, *this, newNodeIDs ); - else if ( spaceDimension == 2 ) - nbRemovedNodes = mergeNodes<2>( tolerance, *this, newNodeIDs ); - - myNodesNumerated = true; - - if ( nbRemovedNodes == 0 ) - return; - - // all commented code here was used to keep initial numeration but it was too slow - //numerotationMaillage(); - treatGroupes(); - - nbRemovedByType[ MED_NONE ] = nbRemovedNodes; - nbRemovedByType[ MED_POINT1 ] = nbRemovedNodes; - - bool hasPointMailles = false; - _maillageByDimIterator entityMailles( *this, 0 ); - if ( const set<_maille> * points = entityMailles.nextType() ) { - hasPointMailles = true; - set<_maille>::const_iterator i, iEnd = points->end(); - for ( i = points->begin(); i != iEnd; ++i ) - i->setOrdre( i->sommets[0]->second.number ); // is merged if point is merged - } - const bool skipFirstType = ( hasPointMailles && hasMixedCells ); - // loop on entities - for ( int dim = 1; dim <= 3; ++dim ) - { - int iterDim = hasMixedCells ? -1 : dim; - //int nbRemovedInEntity = 0; - - // count total nb of mailles in entity -// int nbMailles = 0; -// entityMailles.init( iterDim, true ); -// if ( skipFirstType ) entityMailles.nextType(); // merged POINT1's are same as nodes -// while ( const set<_maille> * typeMailles = entityMailles.nextType() ) -// nbMailles += typeMailles->size(); - - // for each maille number, count shift due to removed mailles with lower numbers - //vector shift( nbMailles+1, 0 ); - - // merge and numerate mailles - int num = 0; - entityMailles.init( iterDim, true ); - if ( skipFirstType ) entityMailles.nextType(); // merged POINT1's are same as nodes - while ( const set<_maille> * typeMailles = entityMailles.nextType() ) - { - int nbRemoved = 0; - set<_mailleWrap> maNodeNumSorted; - pair< set<_mailleWrap>::const_iterator, bool > mw_isunique; - - set<_maille>::const_iterator ma = typeMailles->begin(), maEnd = typeMailles->end(); - while ( ma != maEnd ) - { - const _maille & m = *ma++; - mw_isunique = maNodeNumSorted.insert( &m ); - if ( mw_isunique.second ) { - m.setOrdre( ++num ); - } - else { - const _maille* equalMa = mw_isunique.first->_ma; - //unsigned ordreToRemove = m.ordre(); - m.setMergedOrdre( equalMa->ordre() ); - nbRemoved++; -// while ( ordreToRemove <= nbMailles ) -// shift[ ordreToRemove++ ]++; - } - } - - if ( nbRemoved ) { - nbRemovedByType[ entityMailles.type() ] = nbRemoved; - //nbRemovedInEntity += nbRemoved; - } - - // update maille ordre -// if ( nbRemovedInEntity ) { -// for ( ma = typeMailles->begin(); ma != maEnd; ++ma ) { -// unsigned newOrdre = ma->ordre() - shift[ ma->ordre() ]; -// if ( ma->isMerged() ) -// ma->setMergedOrdre( newOrdre ); -// else -// ma->setOrdre( newOrdre ); -// } -// } - } - } - - myMaillesNumerated = true; - -} - -//======================================================================= -//function : getMeshDimension -//purpose : count mesh dimension -//======================================================================= - -int _intermediateMED::getMeshDimension() const -{ - int dim = 0; - _maillageByDimIterator allMailles( *this, -1, true ); - while ( allMailles.nextType() ) - dim = allMailles.dim(); - return dim; -} - -} - -///// diff --git a/src/MEDMEM/MEDMEM_DriverTools.hxx b/src/MEDMEM/MEDMEM_DriverTools.hxx deleted file mode 100644 index d679b3210..000000000 --- a/src/MEDMEM/MEDMEM_DriverTools.hxx +++ /dev/null @@ -1,579 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef DRIVERTOOLS_HXX -#define DRIVERTOOLS_HXX - -#include - -#include "MEDMEM_define.hxx" -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_FieldForward.hxx" -#include "MEDMEM_ArrayInterface.hxx" -#include "MEDMEM_Group.hxx" -#include "MEDMEM_GaussLocalization.hxx" - -#include -#include -#include -#include -#include -#include -#include -#include - -// Way of storing values with gauss points by CASTEM: full/no interlace. -// Remove code switched by this symbol as soon as the way is found out, -// from here and from gibi driver -#define CASTEM_FULL_INTERLACE - - -namespace MEDMEM { -class MESH; -class CONNECTIVITY; -class COORDINATE; -class GROUP; -class FAMILY; -class FIELD_; -class _intermediateMED; - -// ============================================================================== -struct MEDMEM_EXPORT _noeud -{ - mutable int number; // negative if node is merged - std::vector coord; -}; - -// ============================================================================== -typedef pair _link; // a pair of node numbers - -// ============================================================================== -struct MEDMEM_EXPORT _maille -{ - typedef std::map::iterator TNoeud; //iter; - std::vector< TNoeud > sommets; - MED_EN::medGeometryElement geometricType; - mutable bool reverse; // to reverse sommets of a face - mutable int* sortedNodeIDs; // for comparison and merge - //mutable list groupes; // the GROUPs maille belongs to, used to create families - - _maille(MED_EN::medGeometryElement type=MED_EN::MED_NONE, size_t nelem=0) - : geometricType(type),reverse(false),sortedNodeIDs(0),_ordre(0) { sommets.reserve(nelem); } - - _maille(const _maille& ma); - void init() const { if ( sortedNodeIDs ) delete [] sortedNodeIDs; sortedNodeIDs = 0; } - ~_maille() { init(); } - - int dimension() const // retourne la dimension de la maille - { return geometricType/100; } - - int dimensionWithPoly() const // retourne la dimension de la maille - { return geometricType >= MED_EN::MED_POLYGON ? dimension()-2 : dimension(); } - - const int* getSortedNodes() const; // creates if needed and return sortedNodeIDs - bool operator < (const _maille& ma) const; - MED_EN::medEntityMesh getEntity(const int meshDimension) const throw (MEDEXCEPTION); - _link link(int i) const; - - //bool isMerged(int i) const { return sommets[i]->second.number < 0; } - int nodeNum(int i) const { return abs( sommets[i]->second.number ); } - int nodeID (int i) const { return sommets[i]->first; } // key in points map - - unsigned ordre() const { return abs( _ordre ); } - bool isMerged() const { return _ordre < 0; } - void setMergedOrdre(unsigned o) const { _ordre = -o; } - void setOrdre(int o) const { _ordre = o; } - -private: - mutable int _ordre; // l'ordre est fixé après insertion dans le set, et ne change ni l'état, ni l'ordre -> mutable - _maille& operator=(const _maille& ma); -}; - -// ============================================================================== -struct MEDMEM_EXPORT _mailleIteratorCompare // pour ordonner le set d'iterateurs sur mailles -{ - // this operator is used for ordering mailles thinin a group, which happens when - // right numbers are already given to _maille's, so we can use _maille::ordre - // for comparison instead of a heavy _maille::operator < - bool operator () (std::set<_maille>::iterator i1, std::set<_maille>::iterator i2) - { - //return *i1<*i2; - return i1->ordre() < i2->ordre(); - } -}; - -// ============================================================================== -struct MEDMEM_EXPORT _groupe -{ - typedef std::set<_maille>::iterator TMaille; - typedef std::vector< TMaille >::const_iterator TMailleIter; - std::string nom; - std::vector< TMaille > mailles; // iterateurs sur les mailles composant le groupe - std::vector groupes; // indices des sous-groupes composant le groupe - std::map relocMap; // map _maille::ordre() -> index in GROUP, built by getGroups() - GROUP* medGroup; - - std::vector refNames; /* names of groups referring this one; - refNames is resized according to nb of references - while reading a group (pile 1) and it is filled with - names while reading long names (pile 27); each named - reference is converted into a copy of the medGroup - (issue 0021311) - */ - const _maille& maille(int index) { return *mailles[index]; } - bool empty() const { return mailles.empty() && groupes.empty(); } -#ifdef WIN32 - int size() const { return (mailles.size()>relocMap.size())?mailles.size():relocMap.size(); } -#else - int size() const { return std::max( mailles.size(), relocMap.size() ); } -#endif - _groupe():medGroup(0) {} -}; - -// ============================================================================== -struct MEDMEM_EXPORT _fieldBase { - // a field contains several subcomponents each referring to its own support and - // having several named components - // ---------------------------------------------------------------------------- - struct _sub_data // a subcomponent - // -------------------------------- - { - int _supp_id; // group index within _intermediateMED::groupes - std::vector _comp_names; // component names - std::vector _nb_gauss; // nb values per element in a component - - void setData( int nb_comp, int supp_id ) - { _supp_id = supp_id - 1; _comp_names.resize(nb_comp); _nb_gauss.resize(nb_comp,1); } - int nbComponents() const { return _comp_names.size(); } - std::string & compName( int i_comp ) { return _comp_names[ i_comp ]; } - bool isValidNbGauss() const { return *std::max_element( _nb_gauss.begin(), _nb_gauss.end() ) == - *std::min_element( _nb_gauss.begin(), _nb_gauss.end() ); } -#ifdef WIN32 - int nbGauss() const { return (1>_nb_gauss[0])?1:_nb_gauss[0]; } -#else - int nbGauss() const { return std::max( 1, _nb_gauss[0] ); } -#endif - bool hasGauss() const { return nbGauss() > 1; } - }; - // ---------------------------------------------------------------------------- - std::vector< _sub_data > _sub; - int _group_id; // group index within _intermediateMED::groupes - // if _group_id == -1 then each subcomponent makes a separate MEDMEM::FIELD, else all subcomponents - // are converted into one MEDMEM::FIELD. The latter is possible only if nb of components in all subs - // is the same and supports of subcomponents do not overlap - MED_EN::med_type_champ _type; - std::string _name; - std::string _description;// field description - - _fieldBase( MED_EN::med_type_champ theType, int nb_sub ) - : _group_id(-1),_type(theType) { _sub.resize( nb_sub ); } - virtual std::list > getField(std::vector<_groupe>& groupes) const = 0; - void getGroupIds( std::set & ids, bool all ) const; // return ids of main and/or sub-groups - bool hasCommonSupport() const { return _group_id >= 0; } // true if there is one support for all subs - bool hasSameComponentsBySupport() const; - virtual void dump(std::ostream&) const; - virtual ~_fieldBase() {} -}; - -// ============================================================================== -template< class T > class _field: public _fieldBase -{ - std::vector< std::vector< T > > comp_values; - public: - _field< T > ( MED_EN::med_type_champ theType, int nb_sub, int total_nb_comp ) - : _fieldBase( theType, nb_sub ) { comp_values.reserve( total_nb_comp ); } - std::vector< T >& addComponent( int nb_values ); // return a vector ready to fill in - std::list > getField(std::vector<_groupe>& groupes) const; - virtual void dump(std::ostream&) const; -}; - -// ============================================================================== -/*! - * \if developper - * Iterator on set of _maille's of given dimension - * \endif - */ -class MEDMEM_EXPORT _maillageByDimIterator -{ -public: - // if (convertPoly) then treat poly as 2d and 3d, else as 4d and 5d (=medGeometryElement/100) - _maillageByDimIterator( const _intermediateMED & medi, - const int dim=-1, // dim=-1 - for all dimensions - const bool convertPoly = false ) - { myImed = & medi; init( dim, convertPoly ); } - - // if (convertPoly) then treat poly as 2d and 3d, else as 4d and 5d (=medGeometryElement/100) - void init(const int dim=-1, // dim=-1 - for all dimensions - const bool convertPoly = false ); - - //!< return next set of _maille's of required dimension - const std::set<_maille > * nextType() { - while ( myIt != myEnd ) - if ( !myIt->second.empty() && ( myDim < 0 || dim(false) == myDim )) - return & (myIt++)->second; - else - ++myIt; - return 0; - } - //!< return dimension of mailles returned by the last or further next() - int dim(const bool last=true) const { - iterator it = myIt; - if ( last ) --it; - return myConvertPoly ? - it->second.begin()->dimensionWithPoly() : - it->second.begin()->dimension(); - } - //!< return type of mailles returned by the last next() - MED_EN::medGeometryElement type() const { iterator it = myIt; return (--it)->first; } - - //!< return number of mailles taking into account merged ones - int sizeWithoutMerged() const { - iterator it = myIt; - removed::const_iterator tNb = nbRemovedByType->find( (--it)->first ); - return it->second.size() - ( tNb == nbRemovedByType->end() ? 0 : tNb->second ); - } -private: - typedef std::map removed; - typedef std::map > TMaillageByType; - typedef TMaillageByType::const_iterator iterator; - - const _intermediateMED* myImed; - iterator myIt, myEnd; - int myDim, myConvertPoly; - const removed * nbRemovedByType; -}; - -// ============================================================================== -/*! - * \if developper - * Intermediate structure used by drivers to store data read from the other format file. - * The structure provides functions that transform the stored data to the MED format : - * getCoordinate(), getConnectivity(), getGroups(). - * The elements inserted in maillage and points are automaticaly ordered. - * Renumbering are performed by getConnectivity & getGroups before writing the MED structures. - * Read the conception ducumentation for more details. - * \endif - */ -struct MEDMEM_EXPORT _intermediateMED -{ - typedef std::map > TMaillageByType; - typedef std::map TNbByType; - typedef std::map< const _maille*, std::vector > TPolyherdalNbFaceNodes; - - TNbByType nbRemovedByType; // nb mailles removed by merge - std::vector<_groupe> groupes; - //std::vector medGroupes; - std::map< int, _noeud > points; - std::list< _fieldBase* > fields; - bool hasMixedCells; // true if there are groups with mixed entity types - TPolyherdalNbFaceNodes polyherdalNbFaceNodes; // nb of nodes in faces for each polyhedron - - inline _groupe::TMaille insert(const _maille& ma); - - int getMeshDimension() const; - void mergeNodesAndElements(double tolerance); // optionally merge nodes and elements - CONNECTIVITY * getConnectivity(); // creates MED connectivity from the intermediate structure - COORDINATE * getCoordinate(const string & coordinateSystem="CARTESIAN"); // makes MED coordinate -// void getFamilies(std::vector & _famCell, std::vector & _famFace, -// std::vector & _famEdge, std::vector & _famNode, -// MESH * _ptrMesh); - void getGroups(std::vector & _groupCell, std::vector & _groupFace, - std::vector & _groupEdge, std::vector & _groupNode, - MESH * _ptrMesh); - //GROUP * getGroup( int i ); - - void getFields(std::list< FIELD_* >& fields); - - // used by previous functions to renumber points & mesh. - bool myGroupsTreated; - void treatGroupes(); // detect groupes of mixed dimension - void numerotationMaillage(); - bool numerotationPoints(); // return true if renumeration done - int nbMerged(int geoType) const; //!< nb nodes removed by merge - - _intermediateMED() - { myNodesNumerated = myMaillesNumerated = myGroupsTreated = false; currentTypeMailles = 0; } - ~_intermediateMED(); - -private: - - bool myNodesNumerated, myMaillesNumerated; - // mailles groupped by geom type; use insert() for filling in and - // _maillageByDimIterator for exploring it - //std::set<_maille> maillage; - TMaillageByType maillageByType; - TMaillageByType::value_type* currentTypeMailles; // for fast insertion - friend class _maillageByDimIterator; -}; -//----------------------------------------------------------------------- -_groupe::TMaille _intermediateMED::insert(const _maille& ma) -{ - if ( !currentTypeMailles || currentTypeMailles->first != ma.geometricType ) - currentTypeMailles = & *maillageByType.insert - ( make_pair( ma.geometricType, std::set<_maille >())).first; - - _groupe::TMaille res = currentTypeMailles->second.insert( ma ).first; - - ((_maille&)ma).init(); // this method was added for the sake of this call which is needed to - // remove comparison key (sortedNodeIDs) from a temporary _maille ma - - return res; -} - -// ============================================================================== - -std::ostream& operator << (std::ostream& , const _maille& ); -std::ostream& operator << (std::ostream& , const _groupe& ); -std::ostream& operator << (std::ostream& , const _noeud& ); -std::ostream& operator << (std::ostream& , const _intermediateMED& ); -std::ostream& operator << (std::ostream& , const _fieldBase* ); - -// =========================================================== -// field template implementation // -// =========================================================== - -template - std::vector< T >& _field< T >::addComponent( int nb_values ) -{ - comp_values.push_back( std::vector< T >() ); - std::vector< T >& res = comp_values.back(); - res.resize( nb_values ); - return res; -} - -//======================================================================= -//function : getField -//purpose : return list of pairs< field, supporting_group_id > -//======================================================================= - -template -std::list > _field< T >::getField(std::vector<_groupe> & groupes) const -{ - const char* LOC = "_field< T >::getField()"; - - std::list > res; - - // gauss array data - int nbtypegeo = 0; - vector nbelgeoc(2,0), nbgaussgeo(2,0); - - int i_comp_tot = 0, nb_fields = 0; - std::set supp_id_set; // to create a new field when support repeats if hasCommonSupport() - std::vector< _sub_data >::const_iterator sub_data, sub_end = _sub.end(); - - _groupe* grp = 0; - GROUP* medGrp = 0; - if ( hasCommonSupport() ) // several subs are combined into one field - { - grp = & groupes[ _group_id ]; - medGrp = grp->medGroup; - if ( !grp || grp->empty() || !medGrp || !medGrp->getNumberOfTypes()) - return res; - - // Make gauss array data - nbtypegeo = medGrp->getNumberOfTypes(); - nbelgeoc .resize( nbtypegeo + 1, 0 ); - nbgaussgeo.resize( nbtypegeo + 1, 0 ); - const int * nbElemByType = medGrp->getNumberOfElements(); - const MED_EN::medGeometryElement* types = medGrp->getTypes(); - for (int iType = 0; iType < nbtypegeo; ++iType) { - // nb elem by type - nbelgeoc [ iType+1 ] = nbelgeoc[ iType ] + nbElemByType[ iType ]; - // nb gauss by type; find a sub for a geo type - for ( sub_data = _sub.begin(); sub_data != sub_end; ++sub_data ) { - _groupe & sub_grp = groupes[ sub_data->_supp_id ]; - if ( !sub_grp.empty() && sub_grp.mailles[0]->geometricType == types[ iType ]) - break; - } - ASSERT_MED( sub_data != sub_end ); - nbgaussgeo[ iType+1 ] = sub_data->nbGauss(); - } - } - typedef typename MEDMEM_ArrayInterface::Array TArrayNoGauss; - typedef typename MEDMEM_ArrayInterface::Array TArrayGauss; - FIELD< T, FullInterlace > * f = 0; - TArrayNoGauss * arrayNoGauss = 0; - TArrayGauss * arrayGauss = 0; - - // loop on subs of this field - int i_sub = 1; - for ( sub_data = _sub.begin(); sub_data != sub_end; ++sub_data, ++i_sub ) - { - // nb values in a field - if ( !hasCommonSupport() ) { - grp = & groupes[ sub_data->_supp_id ]; - medGrp = grp->medGroup; - } - int nb_val = grp->size(); - - // check validity of a sub_data - bool validSub = true; - if ( !nb_val ) { - INFOS_MED("Skip field <" << _name << ">: invalid supporting group " - << (hasCommonSupport() ? _group_id : sub_data->_supp_id ) - << " of " << i_sub << "-th subcomponent" ); - validSub = false; - } - if ( !sub_data->isValidNbGauss() ) { - INFOS_MED("Skip field <" << _name << ">: different nb of gauss points in components "); - validSub = false; - } - if ( !validSub ) { - if ( hasCommonSupport() ) { - if ( !res.empty() ) { - if(f) - f->removeReference(); - res.clear(); - } - return res; - } - i_comp_tot += sub_data->nbComponents(); - continue; - } - - // Create a field - - if ( !f || !hasCommonSupport() || !supp_id_set.insert( sub_data->_supp_id ).second ) - { - ++nb_fields; - supp_id_set.clear(); - arrayNoGauss = 0; - arrayGauss = 0; - - f = new FIELD< T, FullInterlace >(); - - f->setNumberOfComponents( sub_data->nbComponents() ); - f->setComponentsNames( & sub_data->_comp_names[ 0 ] ); - f->setNumberOfValues ( nb_val ); - f->setName( _name ); - f->setDescription( _description ); - vector str( sub_data->nbComponents() ); - f->setComponentsDescriptions( &str[0] ); - f->setMEDComponentsUnits( &str[0] ); - if ( !hasCommonSupport() && nb_fields > 1 ) - { - f->setName( MEDMEM::STRING(_name) << "_Sub_" << nb_fields ); - INFOS_MED("Warning: field |" <<_name<<"| is incompatible with MED format (has " - "sub-fields of different nature), so we map its sub-field #"<< nb_fields << - " into a separate field |"<getName() << "|"); - } - res.push_back( make_pair( f , hasCommonSupport() ? _group_id : sub_data->_supp_id )); - MESSAGE_MED(" MAKE " << nb_fields << "-th field <" << _name << "> on group_id " << _group_id ); - - // make an array - if ( !sub_data->hasGauss() ) { - arrayNoGauss = new TArrayNoGauss( sub_data->nbComponents(), nb_val ); - f->setArray( arrayNoGauss ); - } - else { - if ( !hasCommonSupport() ) { - nbtypegeo = 1; - nbelgeoc [1] = nb_val; - nbgaussgeo[1] = sub_data->nbGauss(); - } - arrayGauss = new TArrayGauss(sub_data->nbComponents(), nb_val, - nbtypegeo, & nbelgeoc[0], & nbgaussgeo[0]); - f->setArray( arrayGauss ); - - // PAL11040 "GIBI driver for Castem fields with Gauss point values" - const MED_EN::medGeometryElement* types = medGrp->getTypes(); - for (int iGeom = 0; iGeom < nbtypegeo; ++iGeom) { - ostringstream name; - name << "Gauss_" << nbgaussgeo[iGeom+1] << "points_on" << types[iGeom] << "geom"; - GAUSS_LOCALIZATION_* loc = GAUSS_LOCALIZATION_::makeDefaultLocalization - (name.str(), types[iGeom], nbgaussgeo[iGeom+1]); - f->setGaussLocalization( types[iGeom], loc ); - } - } - } - - // Set values - - // get nb elements in a group - _groupe & sub_grp = groupes[ sub_data->_supp_id ]; - int nb_supp_elems = sub_grp.mailles.size(); - int nb_gauss = sub_data->nbGauss(); - MESSAGE_MED("insert sub data, group_id: " << sub_data->_supp_id << - ", nb values: " << comp_values[ i_comp_tot ].size() << - ", relocMap size: " << sub_grp.relocMap.size() << - ", nb mailles: " << nb_supp_elems); - -#ifdef CASTEM_FULL_INTERLACE - const int gauss_step = 1; - const int elem_step = nb_gauss; -#else - const int gauss_step = nb_supp_elems; - const int elem_step = 1; -#endif - int i; // elem index - // loop on components of a sub - for ( int i_comp = 1; i_comp <= sub_data->nbComponents(); ++i_comp ) - { - // store values - const std::vector< T > & values = comp_values[ i_comp_tot++ ]; - bool oneValue = ( values.size() == 1 ); - ASSERT_MED( oneValue || (int)values.size() == nb_supp_elems * nb_gauss ); - for ( int k = 0; k < nb_supp_elems; ++k ) - { - const T& val = oneValue ? values[ 0 ] : values[ k * elem_step ]; - const _maille& ma = sub_grp.maille( k ); - if ( medGrp->isOnAllElements() ) { - i = ma.ordre(); - } - else { - std::map::const_iterator ordre_i = grp->relocMap.find( ma.ordre() ); - if ( ordre_i == grp->relocMap.end() ) - throw MEDEXCEPTION (LOCALIZED(STRING(LOC) << ", cant find elem index. " - << k << "-th elem: " << ma)); - i = ordre_i->second; - } - if ( arrayNoGauss ) { - arrayNoGauss->setIJ( i, i_comp, val ); - } - else { - const T* pVal = & val; - for ( int iGauss = 1; iGauss <= nb_gauss; ++iGauss, pVal += gauss_step ) - arrayGauss->setIJK( i, i_comp, iGauss, *pVal); - } - } - } - } // loop on subs of the field - - return res; -} - - -// ============================================================================== -template void _field< T >::dump(std::ostream& os) const -// ============================================================================== -{ - _fieldBase::dump(os); - os << endl; - for ( int i = 0 ; i < (int)comp_values.size(); ++i ) - { - os << " " << i+1 << "-th component, nb values: " << comp_values[ i ].size() << endl; - } -} - -} // namespace MEDMEM - -#endif /* DRIVERTOOLS_HXX */ diff --git a/src/MEDMEM/MEDMEM_DriversDef.cxx b/src/MEDMEM/MEDMEM_DriversDef.cxx deleted file mode 100644 index 072d522ad..000000000 --- a/src/MEDMEM/MEDMEM_DriversDef.cxx +++ /dev/null @@ -1,178 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_DriversDef.hxx" - -using namespace std; - -namespace MED_EN { - -// Returns the (string) name of the geometry of -// an element given by a med_geometrie_element value -GEO_NAME::GEO_NAME() : map() -{ - map &table = (map&)*this ; - table[(int)0 ] = "MED_NONE" ; - table[(int)MED_POINT1 ] = "MED_POINT1" ; - table[(int)MED_SEG2 ] = "MED_SEG2" ; - table[(int)MED_SEG3 ] = "MED_SEG3" ; - table[(int)MED_TRIA3 ] = "MED_TRIA3" ; - table[(int)MED_TRIA6 ] = "MED_TRIA6" ; - table[(int)MED_QUAD4 ] = "MED_QUAD4" ; - table[(int)MED_QUAD8 ] = "MED_QUAD8" ; - table[(int)MED_TETRA4 ] = "MED_TETRA4" ; - table[(int)MED_TETRA10] = "MED_TETRA10"; - table[(int)MED_HEXA8 ] = "MED_HEXA8" ; - table[(int)MED_HEXA20 ] = "MED_HEXA20" ; - table[(int)MED_PENTA6 ] = "MED_PENTA6" ; - table[(int)MED_PENTA15] = "MED_PENTA15"; - table[(int)MED_PYRA5 ] = "MED_PYRA5" ; - table[(int)MED_PYRA13 ] = "MED_PYRA13" ; - table[(int)MED_POLYGON] = "MED_POLYGON"; - table[(int)MED_POLYHEDRA] = "MED_POLYHEDRA"; - assert( table.find( (int)MED_POLYHEDRA ) != table.end() ) ; -} - -GEO_NAME::~GEO_NAME() -{ -// MESSAGE_MED(" destructor GEO_NAME::~GEO_NAME() "<< size() ); -// clear(); -// MESSAGE_MED(" end of destructor GEO_NAME::~GEO_NAME() "<< size() ); -} - -string & GEO_NAME::operator[]( const MED_EN::medGeometryElement &c ) const -{ - map &table = (map&)*this ; - assert( table.find( (int)c ) != table.end() ) ; - return table[ (int)c ] ; -} - - -// Returns the (string) name of the type of -// an entity given by a med_entite_maillage value - -ENT_NAME::ENT_NAME() : map() -{ - map &table = (map&)*this ; - table[(int)MED_CELL ] = "MED_MAILLE"; - table[(int)MED_FACE ] = "MED_FACE"; - table[(int)MED_EDGE ] = "MED_ARETE"; - table[(int)MED_NODE ] = "MED_NOEUD"; -} - -ENT_NAME::~ENT_NAME() -{ -// MESSAGE_MED(" destructor ENT_NAME::~ENT_NAME() "<< size() ); -// clear(); -// MESSAGE_MED(" end of destructor ENT_NAME::~ENT_NAME() "<< size() ); -} - -string & ENT_NAME::operator[]( const MED_EN::medEntityMesh &c ) const -{ - map &table = (map&)*this ; - assert( table.find( (int)c ) != table.end() ) ; - return table[ (int)c ] ; -} - -MESH_ENTITIES::MESH_ENTITIES () : map >() -{ - // Override the const declaration in order to used the find method below - // map > &table = (map >&)*this ; unused local variable - - // Initialize the value associated with the ROUGE_ key ( use the private operator = ) - { - const MED_EN::medGeometryElement T[] = { - MED_POINT1, - MED_SEG2, - MED_SEG3, - MED_TRIA3, - MED_QUAD4, - MED_TRIA6, - MED_QUAD8, - MED_TETRA4, - MED_PYRA5, - MED_PENTA6, - MED_HEXA8, - MED_TETRA10, - MED_PYRA13, - MED_PENTA15, - MED_HEXA20, - MED_POLYGON, - MED_POLYHEDRA}; - - list geomList(T,T+sizeof(T)/sizeof(MED_EN::medGeometryElement)); - (*this)[MED_CELL] = geomList; - } - - { - const MED_EN::medGeometryElement T[] = { - MED_TRIA3, - MED_QUAD4, - MED_TRIA6, - MED_QUAD8, - MED_POLYGON}; - - list geomList(T,T+sizeof(T)/sizeof(MED_EN::medGeometryElement)); - (*this)[MED_FACE] = geomList; - } - - { - const MED_EN::medGeometryElement T[] = { - MED_SEG2, - MED_SEG3 }; - - list geomList(T,T+sizeof(T)/sizeof(MED_EN::medGeometryElement)); - (*this)[MED_EDGE] = geomList; - } - - { - // const med_geometrie_element T[] = { MED_NONE }; - const MED_EN::medGeometryElement T[] = { (MED_EN::medGeometryElement)0 }; - list geomList(T,T+sizeof(T)/sizeof(MED_EN::medGeometryElement)); - (*this)[MED_NODE] = geomList; - } - -} - -MESH_ENTITIES::~MESH_ENTITIES() -{ -// MESSAGE_MED(" destructor MESH_ENTITIES::~MESH_ENTITIES() "<< size() ); -// clear(); -// MESSAGE_MED(" end of destructor MESH_ENTITIES::~MESH_ENTITIES() "<< size() ); -} - -const list & MESH_ENTITIES::operator[]( const MED_EN::medEntityMesh &c ) const -{ - map > &table = (map >&)*this ; - // Verify the object already exists in the map - assert( table.find( (int)c ) != table.end() ) ; - return table[ (int)c ] ; -} - -// This operator is used to initialize class objects of type const list -list & MESH_ENTITIES::operator[]( const MED_EN::medEntityMesh &c ) -{ - return (list &) this->map >::operator[]( (int)c) ; -} - -} // End Of NampeSpace MED_EN - diff --git a/src/MEDMEM/MEDMEM_DriversDef.hxx b/src/MEDMEM/MEDMEM_DriversDef.hxx deleted file mode 100644 index 262400aa2..000000000 --- a/src/MEDMEM/MEDMEM_DriversDef.hxx +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -# ifndef DRIVERS_DEF_HXX -# define DRIVERS_DEF_HXX - -#include - -// STL -# include -# include -# include - -using namespace std ; - -#include "MEDMEM_define.hxx" -#include "MEDMEM_Utilities.hxx" - -namespace MED_EN { -/*! This Class inherits from map. \n - It is a constant map association int (which is a med_geometrie_element) and string. \n - Operator [] returns the (string) name of the geometry of an element - given by a med_geometrie_element value. \n - Such a static map is instancied and can be used in any code to have - the name of the geometry of an element : MED_FR:GEO_NAME - A simple test/use case can be found in test/testUGeoNameMeshEntities.cxx */ -//---------------------------------------- -class MEDMEM_EXPORT GEO_NAME : public map -//---------------------------------------- -{ - -public : - - GEO_NAME(); - ~GEO_NAME(); - string & operator[]( const MED_EN::medGeometryElement &c ) const; -} ; - -static const GEO_NAME geoNames ; - -// ____________________________ - -/*! This Class inherits from map. \n - It is a constant map association int (which is a med_entite_maillage) and string. \n - Operator[] returns the (string) name of the type of an entity given by - a med_entite_maillage value. \n - Such a static map is instancied and can be used in any code to have - the name of the geometry of an element : MED_FR:ENT_NAME - A simple test/use case can be found in test/testUGeoNameMeshEntities.cxx */ - -//---------------------------------------- -class MEDMEM_EXPORT ENT_NAME : public map -//---------------------------------------- -{ - -public : - - ENT_NAME (); - ~ENT_NAME(); - string & operator[]( const MED_EN::medEntityMesh &c ) const; -} ; - -static const ENT_NAME entNames ; - -// ____________________________ - -/*! This Class inherits from map. \n - It is a constant map association int (which is a med_entite_maillage) and a list. \n - Operator[] returns the list of all exisiting med_geometrie_element for - a med_entite_maillage value. \n - Such a static map is instancied and can be used in any code to have - the name of the geometry of an element : MED_FR:MESH_ENTITIES - A simple test/use case can be found in test/testUGeoNameMeshEntities.cxx */ - - -//-------------------------------------------------------------------------------- -class MEDMEM_EXPORT MESH_ENTITIES : public map > -//-------------------------------------------------------------------------------- -{ - -public : - - MESH_ENTITIES (); - ~MESH_ENTITIES(); - const list & operator[]( const MED_EN::medEntityMesh &c ) const; - -private: - /*! This operator is used to initialize class objects of - type const list */ - list & operator[]( const MED_EN::medEntityMesh &c ); - -} ; - -static const MESH_ENTITIES meshEntities ; - -} // End Of NameSpace MED_EN - -#endif - diff --git a/src/MEDMEM/MEDMEM_EnsightFieldDriver.cxx b/src/MEDMEM/MEDMEM_EnsightFieldDriver.cxx deleted file mode 100644 index 9b39bc0a8..000000000 --- a/src/MEDMEM/MEDMEM_EnsightFieldDriver.cxx +++ /dev/null @@ -1,1676 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include -#include -#include - -#ifndef WIN32 -#include -#endif - -#include "MEDMEM_Utilities.hxx" - -#include "MEDMEM_Field.hxx" -#include "MEDMEM_EnsightUtils.hxx" - -#define TStrTool _ASCIIFileReader - -using namespace MED_EN; -using namespace MEDMEM_ENSIGHT; - -namespace { - - // ============================================================================== - /*! - * \brief Iterator on specified values of a field component - */ - template class _SelectedValueIterator - { - int myDelta; - const T* myPtr; - int myIndexDelta; - const int* myIndex; - public: - _SelectedValueIterator() // by default next() returns zero - : myDelta( 0 ), myPtr (_ValueIterator::zeroPtr()), - myIndexDelta( 0 ), myIndex(_ValueIterator::zeroPtr()) {} - - _SelectedValueIterator(const T* values, int delta, const int* index) - : myDelta( delta ), myPtr(values), myIndexDelta(1), myIndex(index-1) {} - - const T & next() { myIndex += myIndexDelta; return myPtr[ (*myIndex) * myDelta ]; } - }; - - // ============================================================================== - /*! - * \brief Container of values of any type to read/write from/to EnSight variable. - * It stores values relating to one element type within a part - */ - struct _SubPartValues - { - _SubPart mySubPart; - const char * myValues; - medModeSwitch myInterlace; - bool myOwnValues; // to delete or not myValues - string myConstValue; // if myConstValue is set, other members are meaningless - - // for writing values of a field-on-all-entities for a group - const int * myNumbers; - - string myUndefValue; - set myUndefIndices; - vector myPartialIndices; - - _SubPartValues(const _SubPart& sub=_SubPart()) - : mySubPart(sub), myValues(0), myInterlace(MED_NO_INTERLACE), myOwnValues(true) {}; - - ~_SubPartValues() { clear(); } - void clear() { if ( myOwnValues ) delete [] myValues; myValues = 0; } - - // ------------------------------------------------------------------- - //!< copying removes data from the source object - _SubPartValues(const _SubPartValues& other) - :mySubPart(other.mySubPart), myValues(other.myValues), - myInterlace(other.myInterlace), myOwnValues(true) - { ((_SubPartValues&)other).myValues=0; } - - // ------------------------------------------------------------------- - //!< Return iterator on values of a component counted from 1 - // nbElements is a number of values of a component located one by one in - // not full interlace - template _ValueIterator - getValues( int component, int nbElements, int nbComponents ) const - { - const T* values = (T*) myValues; - if ( myInterlace == MED_FULL_INTERLACE ) { - values += (component - 1); - return _ValueIterator( values, nbComponents ); - } - else { - values += (component - 1) * nbElements; - return _ValueIterator( values, 1 ); - } - } - // ------------------------------------------------------------------- - //!< Return iterator on specified values of a component counted from 1. - // nbElements is a number of values of a component located one by one in - // not full interlace - template _SelectedValueIterator - getSelectedValues( int component, int nbElements, int nbComponents ) const - { - // Values are specified by myNumbers. myValues points to the value - // relating to myNumbers[0] element. - const T* values = (T*) myValues; - if ( myInterlace == MED_FULL_INTERLACE ) { - values -= myNumbers[0] * nbComponents; - values += (component - 1); - return _SelectedValueIterator( values, nbComponents, myNumbers ); - } - else { - values -= myNumbers[0]; - values += (component - 1) * nbElements; - return _SelectedValueIterator( values, 1, myNumbers ); - } - } - // ------------------------------------------------------------------- - //!< Return iterators on all values of all components - template vector< _ValueIterator > - getAllValues( int nbElements, int nbComponents, bool add3dComp ) const - { - // add the 3-d component to a vector in 2D space - int addComp = ( add3dComp && nbComponents == 2 ) ? 1 : 0; - vector< _ValueIterator > compValIt( nbComponents + addComp); - for ( int j = 1; j <= nbComponents; ++j ) - compValIt[ j-1 ] = getValues( j, nbElements, nbComponents ); - return compValIt; - } - // ------------------------------------------------------------------- - //!< Return iterators on specified values for all components - template vector< _SelectedValueIterator > - getAllSelectedValues( int nbElements, int nbComponents, bool add3dComp ) const - { - // add the 3-d component to a vector in 2D space - int addComp = ( add3dComp && nbComponents == 2 ) ? 1 : 0; - vector< _SelectedValueIterator > compValIt( nbComponents + addComp); - for ( int j = 1; j <= nbComponents; ++j ) - compValIt[ j-1 ] = getSelectedValues( j, nbElements, nbComponents ); - return compValIt; - } - }; - - //======================================================================= - /*! - use file reader to get values of a _SubPart - */ - template - void readSubPartValues( FileReader& reader, - const FIELD_* field, - _SubPartValues & subValues) - { - medEntityMesh entity = field->getSupport()->getEntity(); - int nbComponents = field->getNumberOfComponents(); - - int nbElements = 0; - if ( entity == MED_NODE ) - nbElements = subValues.mySubPart.myNbNodes; - else - nbElements = subValues.mySubPart.myNbCells; - - int nbValues = nbElements * nbComponents; - if ( nbValues < 1 ) - return; - - const char* undefValue = 0; - set* undefIndices = &subValues.myUndefIndices; - vector* partial = 0; - if ( !subValues.myUndefValue.empty() ) - undefValue = subValues.myUndefValue.c_str(); - if ( !subValues.myPartialIndices.empty() ) - partial = &subValues.myPartialIndices; - - if ( field->getValueType() == MED_REEL64 ) - subValues.myValues = reader.template convertReals( nbValues, - undefValue, undefIndices, - partial, nbComponents ); - else if ( field->getValueType() == MED_INT32 ) - subValues.myValues = reader.template convertReals ( nbValues, - undefValue, undefIndices, - partial, nbComponents ); - else - subValues.myValues = reader.template convertReals ( nbValues, - undefValue, undefIndices, - partial, nbComponents ); - // convert partial indices into undef indices - if ( !subValues.myPartialIndices.empty() ) - { - // sort partial - set sortedPartial; - vector::iterator p = partial->begin(), pEnd = partial->end(); - while ( p != pEnd ) - sortedPartial.insert( sortedPartial.end(), *p++ ); - partial->clear(); - - // fill undef indices - set & undef = subValues.myUndefIndices; - set::iterator sp = sortedPartial.begin(); - int i = 1; - for ( ; sp != sortedPartial.end() && i <= nbElements; ++i, ++sp ) { - while ( i < *sp ) - undef.insert( undef.end(), i++ ); - } - while ( i <= nbElements ) - undef.insert( undef.end(), i++ ); - } - } - //======================================================================= - /*! - set values to an array - */ - template - void _setValuesToArray( vector< _ValueIterator > & compValIt, - const int nbValues, - TArray* array, - TMailIter& cellIt, - _Support* interSupport, - const set& localUndefIndices, - set & globalUndefIndices) - { - int nbComponents = array->getDim(); - if ( localUndefIndices.empty() ) - { - for ( int c = 0; c < nbValues; ++c, ++cellIt ) - { - int i = interSupport->getIndex( *cellIt ); - for ( int j = 1; j <= nbComponents; ++j ) - array->setIJ( i, j, compValIt[ j ].next() ); - } - } - else - { - // set values from the first till undefined end - set::const_iterator undef = localUndefIndices.begin(); - int c = 1, last = min( nbValues, *localUndefIndices.rbegin() ); - for ( ; c <= last; ++c, ++cellIt ) - { - int i = interSupport->getIndex( *cellIt ); - if ( c == *undef ) { - globalUndefIndices.insert( i ); - ++undef; - } - for ( int j = 1; j <= nbComponents; ++j ) - array->setIJ( i, j, compValIt[ j ].next() ); - } - // set all the rest values - for ( ; c <= nbValues; ++c, ++cellIt ) - { - int i = interSupport->getIndex( *cellIt ); - for ( int j = 1; j <= nbComponents; ++j ) - array->setIJ( i, j, compValIt[ j ].next() ); - } - } - } - - //================================================================================ - /*! - * \brief creates a new support excluding undef indices - */ - //================================================================================ - - SUPPORT* makeShiftedSupport(const SUPPORT* support, - const set undefIndices) - { - int nbElements = support->getNumberOfElements(MED_ALL_ELEMENTS); - int nbTypes = support->getNumberOfTypes(); - - int i, shitf = 1; - set::const_iterator undef; - - // shift support numbers - int * index = new int[ nbTypes + 1 ]; - int * number = new int[ nbElements - undefIndices.size() ]; - if ( support->isOnAllElements() ) { - // make shifted number - int * numberPtr = number; - for ( i = 0, undef = undefIndices.begin(); undef != undefIndices.end(); ++undef ) - while ( ++i < *undef ) - *numberPtr++ = i; - while ( ++i <= nbElements ) - *numberPtr++ = i; - // fill index but without shift - const int * oldNbElemByType = support->getNumberOfElements(); - index[0] = 1; - for ( int t = 0; t < nbTypes; ++t ) - index[ t+1 ] = index[ t ] + oldNbElemByType[ t ]; - } - else { - // shift existing number - shitf = 1; - const int * oldNumber = support->getNumber( MED_ALL_ELEMENTS ); - std::copy( oldNumber, oldNumber + *undefIndices.begin()-1, number ); // copy [0:firstUndef] - for ( undef = undefIndices.begin(); undef != undefIndices.end(); ) { - i = *undef++; - int nextUndef = ( undef != undefIndices.end() ) ? *undef : nbElements + 1; - while ( ++i < nextUndef ) - number[ i-1 - shitf ] = oldNumber[ i-1 ]; // shift number - ++shitf; - } - // copy index - const int * oldIndex = support->getNumberIndex(); - std::copy( oldIndex, oldIndex + nbTypes + 1, index ); - } - // update index - { - set::const_reverse_iterator undef = undefIndices.rbegin(); - for ( ; undef != undefIndices.rend(); ++undef ) { - for ( int t = nbTypes; t ; --t ) - if ( *undef < index[ t ] ) - --index[ t ]; - else - break; - } - } - // count number of elements by type - vector nbElem( nbTypes ); - for ( int t = 0; t < nbTypes; ++t ) - nbElem[ t ] = index[ t+1 ] - index[ t ]; - - SUPPORT* newSup = new SUPPORT; - newSup->setMesh ( support->getMesh() ); - newSup->setNumberOfGeometricType( nbTypes ); - newSup->setGeometricType ( support->getTypes() ); - newSup->setNumberOfElements ( &nbElem[0] ); - newSup->setNumber ( index, number, /*shallowCopy =*/ true ); - newSup->setEntity ( support->getEntity() ); - newSup->setAll ( false ); - - return newSup; - } - - //======================================================================= - /*! - set values to a field - */ - template - void _setValuesToField( FIELD* field, - _Support* interSupport, - list<_SubPartValues> & subPartValues ) - { - medEntityMesh entity = field->getSupport()->getEntity(); - SUPPORT* support = interSupport->medSupport( entity ); - field->setSupport( new SUPPORT( *support )); - field->getSupport()->removeReference(); // support belongs to field only - - int j, nbComponents = field->getNumberOfComponents(); - int nbElements = field->getSupport()->getNumberOfElements(MED_ALL_ELEMENTS); - - typedef typename MEDMEM_ArrayInterface::Array TArray; - - const string& constValue = subPartValues.front().myConstValue; - if ( !constValue.empty() ) - { - vector values(nbComponents * nbElements, (T)atof(constValue.c_str())); - field->setArray( new TArray( &values[0], nbComponents, nbElements )); - field->setNumberOfValues( nbElements ); - return; - } - - field->allocValue( nbComponents, nbElements ); - TArray * array = field->getArrayNoGauss(); - - set undefIndices; // indices of undefined values - - // loop on subParts conatining ensight field values - list<_SubPartValues>::iterator subValue = subPartValues.begin(); - for ( ; subValue != subPartValues.end(); ++subValue ) - { - _SubPart & subPart = subValue->mySubPart; - int nbValues = entity==MED_NODE ? subPart.myNbNodes : subPart.myNbCells; - if ( nbValues == 0 ) - continue; - // value iterator for each component - vector< _ValueIterator > compValIt( nbComponents+1 ); - for ( j = 1; j <= nbComponents; ++j ) - compValIt[ j ] = subValue->template getValues( j, nbValues, nbComponents ); - - // Set values - - if ( entity == MED_NODE ) { - map< int, _noeud >::iterator inode = subPart.myFirstNode; - _setValuesToArray( compValIt, nbValues, array, inode, interSupport, - subValue->myUndefIndices, undefIndices ); - } - else { - _groupe::TMailleIter cell = subPart.myFirstCell; - _setValuesToArray( compValIt, nbValues, array, cell, interSupport, - subValue->myUndefIndices, undefIndices ); - } - } - - if ( !undefIndices.empty() ) - { - // Some values are undefined; it's necessary to compact values in the array - // and create a new support of defined numbers only. - - // shift values - int i, shitf = 1; - set::iterator undef = undefIndices.begin(); - while ( undef != undefIndices.end() ) { - i = *undef++; - int nextUndef = ( undef != undefIndices.end() ) ? *undef : nbElements + 1; - while ( ++i < nextUndef ) { - for ( int j = 1; j <= nbComponents; ++j ) - array->setIJ( i - shitf, j, array->getIJ( i, j )); // shift value - //number[ i-1 - shitf ] = oldNumber[ i-1 ]; // shift number - } - ++shitf; - } - array->_nbelem -= undefIndices.size(); - array->_arraySize = array->_nbelem * nbComponents; - - support = makeShiftedSupport( support, undefIndices ); - support->setName( STRING("Partial for ") << field->getName() ); - field->setSupport( support ); - field->setNumberOfValues( array->_nbelem ); - } - if ( support->getName().empty() ) - support->setName( STRING("Support for ") << field->getName() ); - } - - //======================================================================= - /*! - set values to a field - */ - void setValuesToField( FIELD_* field, - _Support* interSupport, - list<_SubPartValues> & subPartValues ) - { - switch ( field->getInterlacingType() ) { - case MED_FULL_INTERLACE: - if ( field->getValueType() == MED_REEL64 ) - _setValuesToField( static_cast< FIELD* >( field ), - interSupport, subPartValues ); - else - _setValuesToField( static_cast< FIELD* >( field ), - interSupport, subPartValues ); - break; - case MED_NO_INTERLACE: - if ( field->getValueType() == MED_REEL64 ) - _setValuesToField( static_cast< FIELD* >( field ), - interSupport, subPartValues ); - else - _setValuesToField( static_cast< FIELD* >( field ), - interSupport, subPartValues ); - break; - case MED_NO_INTERLACE_BY_TYPE: - if ( field->getValueType() == MED_REEL64 ) - _setValuesToField( static_cast< FIELD* >( field ), - interSupport, subPartValues ); - else - _setValuesToField( static_cast< FIELD* >( field ), - interSupport, subPartValues ); - break; - default:; - } - } - - - //================================================================================ - /*! - * \brief Return node numbers of a non-nodal support - */ - //================================================================================ - - int* getNodeNumbers( const SUPPORT* support, int & nbNodes ) - { - map nodeNumbers; - _CaseFileDriver_User::getSupportNodes( support, nodeNumbers ); - nbNodes = nodeNumbers.size(); - int* nNumbers = new int[ nbNodes ]; - int* nPtr = nNumbers; - map::iterator n = nodeNumbers.begin(), nEnd = nodeNumbers.end(); - while ( n != nEnd ) - *nPtr++ = n->first, n++; - - return nNumbers; - } - -} // namespace - -//======================================================================= -/*! - Constructor. -*/ -ENSIGHT_FIELD_DRIVER::ENSIGHT_FIELD_DRIVER(): - _CaseFileDriver_User(), - _ptrField((FIELD_ *) 0) -{} -//======================================================================= -/*! - Constructor. -*/ -ENSIGHT_FIELD_DRIVER::ENSIGHT_FIELD_DRIVER(const string & fileName, - FIELD_ * ptrField, - med_mode_acces accessMode): - _CaseFileDriver_User(fileName,accessMode), - _ptrField((FIELD_ *) ptrField) -{ -} -//======================================================================= -/*! - Copy constructor. -*/ -ENSIGHT_FIELD_DRIVER::ENSIGHT_FIELD_DRIVER(const ENSIGHT_FIELD_DRIVER & fieldDriver): - _CaseFileDriver_User(fieldDriver), - _ptrField(fieldDriver._ptrField), - _fieldName(fieldDriver._fieldName) -{ -} -//======================================================================= -/*! - Take missing data from other driver. -*/ -void ENSIGHT_FIELD_DRIVER::merge ( const GENDRIVER& driver ) -{ - _CaseFileDriver_User::merge( driver ); - - const ENSIGHT_FIELD_DRIVER* other = dynamic_cast< const ENSIGHT_FIELD_DRIVER* >( &driver ); - if ( other ) { - if ( !_ptrField ) - _ptrField = other->_ptrField; - if ( _constantValue.empty() ) - _constantValue = other->_constantValue; - // _fieldName is copied by GENDRIVER - } -} -//======================================================================= -/*! - Destructor. -*/ -ENSIGHT_FIELD_DRIVER::~ENSIGHT_FIELD_DRIVER() -{ -} -//======================================================================= -/*! - Set the name of the FIELD in EnSight file -*/ -void ENSIGHT_FIELD_DRIVER::setFieldName(const string & fieldName) throw (MEDEXCEPTION) -{ - const char* LOC = "ENSIGHT_FIELD_DRIVER::setFieldName(): "; - if ( (int)fieldName.size() > MAX_FIELD_NAME_LENGTH ) - throw MEDEXCEPTION( compatibilityPb(LOC) << "too long name (> " << - MAX_FIELD_NAME_LENGTH << "): " << fieldName); - - // look for illegal characters - string::size_type pos = fieldName.find_first_of( ILLEGAL_FIELD_NAME_CHARACTERS ); - if ( pos != fieldName.npos ) - throw MEDEXCEPTION( compatibilityPb(LOC) << "Character " << pos << " (" << fieldName[pos] << - ") "<< " in " << fieldName << " is not allowed in field name in EnSight\n" - "The illegal characters are: '" << ILLEGAL_FIELD_NAME_CHARACTERS << "'"); - _fieldName = fieldName; -} -//======================================================================= -/*! - Check possibility to open a case file or a data file -*/ -void ENSIGHT_FIELD_DRIVER::openConst(bool checkDataFile) const throw (MEDEXCEPTION) -{ - const char * LOC ="ENSIGHT_FIELD_DRIVER::open() : "; - BEGIN_OF_MED(LOC); - - if ( checkDataFile ) - { - if ( !getConstantValue().empty() ) - return; // constant value is either stored in case file or is read by _CaseFileDriver - - if ( getDataFileName().empty() ) - throw MED_EXCEPTION - ( LOCALIZED( STRING(LOC) << "Internal error, variable file name is empty")); - - if (!canOpenFile( getDataFileName(), getAccessMode() )) - throw MED_EXCEPTION - ( LOCALIZED( STRING(LOC) << "Can not open Ensight Variable file " << getDataFileName() - << " in access mode " << getAccessMode())); - } - else - { - if ( getCaseFileName().empty() ) - throw MED_EXCEPTION - ( LOCALIZED( STRING(LOC) << "Case file name is empty, " - "please set a correct fileName before calling open()")); - - if ( !canOpenFile( getCaseFileName(), getAccessMode() )) - throw MED_EXCEPTION - ( LOCALIZED( STRING(LOC) << "Can not open Ensight Case file " << getCaseFileName() - << " in access mode " << getAccessMode())); - } - - END_OF_MED(LOC); -} -// ========================================================================================== -//function : ENSIGHT_FIELD_RDONLY_DRIVER - -ENSIGHT_FIELD_RDONLY_DRIVER::ENSIGHT_FIELD_RDONLY_DRIVER() - :ENSIGHT_FIELD_DRIVER(), _fieldStep(1) -{ -} - -//======================================================================= -/*! - Constructor to read a field of index-th time step -*/ -//======================================================================= - -ENSIGHT_FIELD_RDONLY_DRIVER::ENSIGHT_FIELD_RDONLY_DRIVER(const string & fileName, - FIELD_ * ptrField, - int step) - :ENSIGHT_FIELD_DRIVER(fileName,ptrField,MED_EN::RDONLY),_fieldStep(step) -{ -} - -//======================================================================= -//function : ENSIGHT_FIELD_RDONLY_DRIVER -//======================================================================= - -ENSIGHT_FIELD_RDONLY_DRIVER::ENSIGHT_FIELD_RDONLY_DRIVER(const ENSIGHT_FIELD_RDONLY_DRIVER & drv) - :ENSIGHT_FIELD_DRIVER(drv),_fieldStep(drv._fieldStep) -{ -} - -//======================================================================= -//function : ~ENSIGHT_FIELD_RDONLY_DRIVER -//======================================================================= - -ENSIGHT_FIELD_RDONLY_DRIVER::~ENSIGHT_FIELD_RDONLY_DRIVER() -{ - close(); -} - -//======================================================================= -//function : copy -//======================================================================= - -GENDRIVER * ENSIGHT_FIELD_RDONLY_DRIVER::copy(void) const -{ - ENSIGHT_FIELD_RDONLY_DRIVER * myDriver = new ENSIGHT_FIELD_RDONLY_DRIVER(*this); - - return myDriver ; -} -//======================================================================= -// Take missing data from other driver. -//======================================================================= - -void ENSIGHT_FIELD_RDONLY_DRIVER::merge ( const GENDRIVER& driver ) -{ - ENSIGHT_FIELD_DRIVER::merge( driver ); - - const ENSIGHT_FIELD_RDONLY_DRIVER* other = - dynamic_cast< const ENSIGHT_FIELD_RDONLY_DRIVER* >( &driver ); - if ( other ) { - if ( _fieldStep < other->_fieldStep ) - _fieldStep = other->_fieldStep; - } -} - -//======================================================================= -//function : read -//======================================================================= - -void ENSIGHT_FIELD_RDONLY_DRIVER::read (void) - throw (MEDEXCEPTION) -{ - const char * LOC = "ENSIGHT_FIELD_RDONLY_DRIVER::read() : " ; - BEGIN_OF_MED(LOC); - - _CaseFileDriver caseFile( getCaseFileName(), this); - - if ( getDataFileName().empty() ) // find out what to read - { - openConst(false); // check if can read case file - - caseFile.read(); - - // find out index of variable to read - int variableIndex = caseFile.getVariableIndex( _fieldName ); - if ( !variableIndex ) - variableIndex = caseFile.getVariableIndex( _ptrField->getName() ); - if ( !variableIndex ) { - if ( !_fieldName.empty() ) - throw MEDEXCEPTION - (LOCALIZED(STRING(LOC) << "no field found by name |" << _fieldName << "|")); - else - throw MEDEXCEPTION - (LOCALIZED(STRING(LOC) << "no field found by name |" << _ptrField->getName() << "|")); - } - - // here data from Case File is passed: - // * field name - // * number of components - // * etc. - caseFile.setDataFileName( variableIndex, _fieldStep, this ); - } - - openConst(true); // check if can read data file - - getInterData(); // get data on nb of entities by type and on their relocation - - cout << "-> Entering into the field file " << getDataFileName() << endl ; - - if ( !getConstantValue().empty() ) - { - // Create a constant value field - - medEntityMesh entity = MED_CELL; - GROUP* support = new GROUP; - support->setName( string("SupportOnAll_")+entNames[entity]); - support->setMesh( getInterData()->_medMesh ); - support->setAll( true ); - support->setEntity( entity ); - support->update(); - - _groupe interGroup; - interGroup.medGroup = support; - _Support interSupport; - interSupport.setGroup( &interGroup ); - - list<_SubPartValues> subPartValues( 1 ); - subPartValues.back().myConstValue = getConstantValue(); - - setValuesToField( _ptrField, &interSupport, subPartValues ); - } - else - { - // Read values - -#ifndef WIN32 - int curExcept = fedisableexcept( FE_ALL_EXCEPT ); //!< there may be nan values -#endif - - if ( isBinaryDataFile( getDataFileName() ) ) // binary - { - if ( isGoldFormat() ) // Gold - { - readGoldBinary(); - } - else // EnSight6 - { - read6Binary(); - } - } - else // ASCII - { - if ( isGoldFormat() ) // Gold - { - readGoldASCII(); - } - else // EnSight6 - { - read6ASCII(); - } - } - -#ifndef WIN32 - feclearexcept( FE_ALL_EXCEPT ); - if ( curExcept >= 0 ) - feenableexcept( curExcept ); -#endif - } -} - -//======================================================================= -/*! - Read Ensight Gold ASCII -*/ -//======================================================================= - -void ENSIGHT_FIELD_RDONLY_DRIVER::readGoldASCII () -{ - - // data that was set by CaseFile Driver - medEntityMesh entity = _ptrField->getSupport()->getEntity(); - - _SupportDesc supportDescriptor; - list<_SubPartValues> subPartValues; - - _ASCIIFileReader varFile( getDataFileName() ); - - if ( isSingleFileMode() ) { - int curTimeStep = 1; - while ( curTimeStep < getIndexInDataFile() ) { - while ( !varFile.isTimeStepEnd() ) - varFile.getLine(); - curTimeStep++; - } - while ( !varFile.isTimeStepBeginning() ) - varFile.getLine(); - } - string description = varFile.getLine(); // description line - _ptrField->setDescription( description ); - - int partNumber = 0; - _SubPartValues subValuesSample; // to keep interlace - subValuesSample.myInterlace = MED_NO_INTERLACE; - while ( !varFile.isTimeStepEnd() ) - { - string word, restLine, line = varFile.getLine(); - TStrTool::split( line, word, restLine ); - if ( word == "part" ) { - partNumber = varFile.getInt(); // part # - continue; - } - subPartValues.push_back( subValuesSample ); - _SubPartValues & subValues = subPartValues.back(); - - if ( restLine == "undef" ) - subValues.myUndefValue = varFile.getWord(); // undef - - if ( restLine == "partial" ) { - int nbPartial = varFile.getInt(); // ne - subValues.myPartialIndices.reserve( nbPartial ); - while ( nbPartial-- ) - subValues.myPartialIndices.push_back( varFile.getInt() ); // i_ne - } - _SubPartDesc desc( partNumber, word ); - subValues.mySubPart = *getSubPart( desc ); - readSubPartValues( varFile, _ptrField, subValues ); - supportDescriptor.insert( desc ); - } - - _Support* interSupport = getSupport( supportDescriptor, entity ); - setValuesToField( _ptrField, interSupport, subPartValues ); - -} - -//======================================================================= -/*! - Read Ensight GOLD binary -*/ -//======================================================================= - -void ENSIGHT_FIELD_RDONLY_DRIVER::readGoldBinary() -{ - - // data that was set by CaseFile Driver - medEntityMesh entity = _ptrField->getSupport()->getEntity(); - - _SupportDesc supportDescriptor; - list<_SubPartValues> subPartValues; - - _BinaryFileReader varFile( getDataFileName() ); - - // check if swapping bytes needed - try { - skipTimeStamp( varFile ); - } - catch (...) { - varFile.swapBytes(); - varFile.rewind(); - } - if ( getIndexInDataFile() <= 1 ) - varFile.rewind(); - - if ( isSingleFileMode() ) { - // one time step may be skipped by skipTimeStamp() - int curTimeStep = varFile.getPosition() ? 2 : 1 ; - while ( curTimeStep < getIndexInDataFile() ) { - skipTimeStamp( varFile ); - curTimeStep++; - } - varFile.skipTimeStepBeginning(); - } - TStrOwner description( varFile.getLine() ); // description line - _ptrField->setDescription( description.myValues ); - - int partNumber = 0; - _SubPartValues subValuesSample; // to keep interlace - subValuesSample.myInterlace = MED_NO_INTERLACE; - while ( !varFile.eof() ) - { - TStrOwner line( varFile.getLine() ); - if ( isTimeStepEnd( line.myValues )) - break; - string word, restLine; - TStrTool::split( line.myValues, word, restLine ); - if ( word == "part" ) { - partNumber = *TIntOwner( varFile.getInt(1)); // part # - continue; - } - subPartValues.push_back( subValuesSample ); - _SubPartValues & subValues = subPartValues.back(); - - if ( restLine == "undef" ) - subValues.myUndefValue = (STRING( *TFltOwner( varFile.getFlt(1) ))); // undef - - if ( restLine == "partial" ) { - int nbPartial = *TIntOwner( varFile.getInt(1) ); // ne - TIntOwner partial( varFile.getInt( nbPartial )); - subValues.myPartialIndices.assign( partial.myValues, - partial.myValues+nbPartial ); // i_ne - } - _SubPartDesc desc( partNumber, word ); - subValues.mySubPart = *getSubPart( desc ); - readSubPartValues( varFile, _ptrField, subValues ); - supportDescriptor.insert( desc ); - } - - _Support* interSupport = getSupport( supportDescriptor, entity ); - setValuesToField( _ptrField, interSupport, subPartValues ); - -} - -//======================================================================= -/*! - Read Ensight6 ASCII -*/ -//======================================================================= - -void ENSIGHT_FIELD_RDONLY_DRIVER::read6ASCII() -{ - - // data that was set by CaseFile Driver - medEntityMesh entity = _ptrField->getSupport()->getEntity(); - - _SupportDesc supportDescriptor; - list<_SubPartValues> subPartValues; - - _ASCIIFileReader varFile( getDataFileName() ); - - if ( isSingleFileMode() ) { - int curTimeStep = 1; - while ( curTimeStep < getIndexInDataFile() ) { - while ( !varFile.isTimeStepEnd() ) - varFile.getLine(); - curTimeStep++; - } - while ( !varFile.isTimeStepBeginning() ) - varFile.getLine(); - } - string description = varFile.getLine(); // description line - _ptrField->setDescription( description ); - - const _SubPart* subPart = 0; - if ( entity == MED_NODE ) // variable per node - { - _SubPartDesc desc = _SubPartDesc::globalCoordDesc(); - subPart = getSubPart( desc ); - if ( subPart ) { - supportDescriptor.insert( desc ); - _SubPartValues subValues( *subPart ); - subValues.myInterlace = MED_FULL_INTERLACE; - readSubPartValues( varFile, _ptrField, subValues ); - subPartValues.push_back( subValues ); - } - } - int partNumber = 0; - while ( !varFile.isTimeStepEnd() ) - { - string word = varFile.getWord(); - if ( word == "part" ) { - partNumber = varFile.getInt(); - continue; - } - _SubPartDesc desc( partNumber, word ); - supportDescriptor.insert( desc ); - subPart = getSubPart( desc ); - _SubPartValues subValues( *subPart ); - if ( desc.typeName() == "block" ) - subValues.myInterlace = MED_NO_INTERLACE; - else - subValues.myInterlace = MED_FULL_INTERLACE; - readSubPartValues( varFile, _ptrField, subValues ); - subPartValues.push_back( subValues ); - } - - _Support* interSupport = getSupport( supportDescriptor, entity ); - setValuesToField( _ptrField, interSupport, subPartValues ); - -} - -//======================================================================= -/*! - Read Ensight6 binary -*/ -//======================================================================= - -void ENSIGHT_FIELD_RDONLY_DRIVER::read6Binary() -{ - - // data that was set by CaseFile Driver - medEntityMesh entity = _ptrField->getSupport()->getEntity(); - - _SupportDesc supportDescriptor; - list<_SubPartValues> subPartValues; - const _SubPart* subPart = 0; - int partNumber = 0; - - _BinaryFileReader varFile( getDataFileName() ); - - // check if swapping bytes needed - try { - skipTimeStamp( varFile ); - } - catch (...) { - varFile.swapBytes(); - varFile.rewind(); - } - if ( getIndexInDataFile() <= 1 ) - varFile.rewind(); - - if ( isSingleFileMode() ) { - // one time step may be skipped by skipTimeStamp() - int curTimeStep = varFile.getPosition() ? 2 : 1 ; - while ( curTimeStep < getIndexInDataFile() ) { - skipTimeStamp( varFile ); - curTimeStep++; - } - varFile.skipTimeStepBeginning(); - } - - TStrOwner description( varFile.getLine() ); // description line - _ptrField->setDescription( description.myValues ); - - if ( entity == MED_NODE ) // global unstructured node values - { - _SubPartDesc desc = _SubPartDesc::globalCoordDesc(); - subPart = getSubPart( desc ); - if ( subPart ) { - supportDescriptor.insert( desc ); - _SubPartValues subValues( *subPart ); - subValues.myInterlace = MED_FULL_INTERLACE; - readSubPartValues( varFile, _ptrField, subValues ); - subPartValues.push_back( subValues ); - } - } - while ( !varFile.eof() ) - { - TStrOwner line( varFile.getLine() ); - if ( isTimeStepEnd( line )) - break; - string word, restLine; - TStrTool::split( line.myValues, word, restLine ); - if ( word == "part" ) { - partNumber = atoi( restLine.c_str() ); - continue; - } - _SubPartDesc desc( partNumber, word ); - supportDescriptor.insert( desc ); - subPart = getSubPart( desc ); - _SubPartValues subValues( *subPart ); - if ( desc.typeName() == "block" ) - subValues.myInterlace = MED_NO_INTERLACE; - else - subValues.myInterlace = MED_FULL_INTERLACE; - readSubPartValues( varFile, _ptrField, subValues ); - subPartValues.push_back( subValues ); - } - - _Support* interSupport = getSupport( supportDescriptor, entity ); - setValuesToField( _ptrField, interSupport, subPartValues ); - -} - -//================================================================================ -/*! - * \brief Looks for beginning of the next time stamp - */ -//================================================================================ - -void ENSIGHT_FIELD_RDONLY_DRIVER::skipTimeStamp(_BinaryFileReader& varFile) -{ - medEntityMesh entity = _ptrField->getSupport()->getEntity(); - int nbComponents = _ptrField->getNumberOfComponents(); - - if ( isSingleFileMode() ) - varFile.skipTimeStepBeginning(); - - varFile.skip( 80 ); // description - - _SubPart* subPart; - if ( entity == MED_NODE && !isGoldFormat() ) { // skip values on global nodes - subPart = getSubPart( _SubPartDesc::globalCoordDesc() ); - if ( subPart ) - varFile.skip( subPart->myNbNodes * nbComponents * sizeof(float) ); - } - int partNumber; - while ( !varFile.eof() ) - { - TStrOwner line( varFile.getLine() ); - if ( isTimeStepEnd( line )) - break; - - string word, restLine; - TStrTool::split( line.myValues, word, restLine ); - - if ( word == "part" ) { - if ( isGoldFormat() ) - partNumber = *TIntOwner( varFile.getInt(1)); - else - partNumber = atoi( restLine.c_str() ); - continue; - } - if ( restLine == "undef" ) { - varFile.skip( sizeof(int) ); - } - if ( restLine == "partial" ) { - int nbPartial = *TIntOwner( varFile.getInt(1)); // ne - varFile.skip( nbPartial * sizeof(int)); - } - - _SubPartDesc desc( partNumber, word ); - subPart = getSubPart( desc ); - int nbElems = ( entity == MED_NODE ) ? subPart->myNbNodes : subPart->myNbCells; - varFile.skip( nbElems * nbComponents * sizeof(float) ); - } -} - -//======================================================================= -//function : write -//======================================================================= - -void ENSIGHT_FIELD_RDONLY_DRIVER::write(void) const - throw (MEDEXCEPTION) -{ - throw MEDEXCEPTION("ENSIGHT_FIELD_RDONLY_DRIVER::write : Can't write with a RDONLY driver !"); -} - -//======================================================================= -//function : ENSIGHT_FIELD_WRONLY_DRIVER -//======================================================================= - -ENSIGHT_FIELD_WRONLY_DRIVER::ENSIGHT_FIELD_WRONLY_DRIVER() - :ENSIGHT_FIELD_DRIVER() -{ -} - -//======================================================================= -//function : ENSIGHT_FIELD_WRONLY_DRIVER -//======================================================================= - -ENSIGHT_FIELD_WRONLY_DRIVER::ENSIGHT_FIELD_WRONLY_DRIVER(const string & fileName, - const FIELD_ * ptrField) - :ENSIGHT_FIELD_DRIVER(fileName,(FIELD_*)ptrField,MED_EN::WRONLY) -{ -} - -//======================================================================= -//function : ENSIGHT_FIELD_WRONLY_DRIVER -//======================================================================= - - -ENSIGHT_FIELD_WRONLY_DRIVER::ENSIGHT_FIELD_WRONLY_DRIVER(const ENSIGHT_FIELD_WRONLY_DRIVER & drv) - :ENSIGHT_FIELD_DRIVER(drv) -{ -} - -//======================================================================= -//function : ~ENSIGHT_FIELD_WRONLY_DRIVER -//======================================================================= - -ENSIGHT_FIELD_WRONLY_DRIVER::~ENSIGHT_FIELD_WRONLY_DRIVER() -{ - close(); -} - - -//======================================================================= -//function : copy -//======================================================================= - -GENDRIVER * ENSIGHT_FIELD_WRONLY_DRIVER::copy(void) const -{ - ENSIGHT_FIELD_WRONLY_DRIVER * myDriver = new ENSIGHT_FIELD_WRONLY_DRIVER(*this); - - return myDriver ; -} - -//======================================================================= -//function : read -//======================================================================= - -void ENSIGHT_FIELD_WRONLY_DRIVER::read (void) - throw (MEDEXCEPTION) -{ - throw MEDEXCEPTION("ENSIGHT_FIELD_WRONLY_DRIVER::read : Can't read with a write only!"); -} - -//================================================================================ -/*! - * \brief Return pointer to the value of the i-th element - */ -//================================================================================ -const char* getValuePointer( int i, const FIELD_* field ); -const char* getValuePointer( int i, const FIELD_* field ) -{ - switch ( field->getInterlacingType() ) { - case MED_FULL_INTERLACE: - if ( field->getValueType() == MED_REEL64 ) - return (const char*) & static_cast* > - ( field )->getArrayNoGauss()->getIJ( i, 1 ); - else - return (const char*) & static_cast* > - ( field )->getArrayNoGauss()->getIJ( i, 1 ); - case MED_NO_INTERLACE: - if ( field->getValueType() == MED_REEL64 ) - return (const char*) & static_cast* > - ( field )->getArrayNoGauss()->getIJ( i, 1 ); - else - return (const char*) & static_cast* > - ( field )->getArrayNoGauss()->getIJ( i, 1 ); - case MED_NO_INTERLACE_BY_TYPE: - if ( field->getValueType() == MED_REEL64 ) - return (const char*) & static_cast* > - ( field )->getArrayNoGauss()->getIJ( i, 1 ); - else - return (const char*) & static_cast* > - ( field )->getArrayNoGauss()->getIJ( i, 1 ); - default:; - } - return 0; -} - -//======================================================================= -/*! - * \brief Write field values in EnSight6 ASCII format -*/ -//======================================================================= - -template< typename T > -void write6ASCIIValues( const _SubPartValues& subPartValues, - int nbValues, - int nbComponents, - int componentShift, - ofstream & ensightDataFile ) -{ - // add the 3-d component to a vector in 2D space - const bool add3dComp = true; - int mypoint=0; - if ( subPartValues.myNumbers ) - { - vector< _SelectedValueIterator > compValIt = - subPartValues.template getAllSelectedValues( componentShift, nbComponents, add3dComp ); - nbComponents = compValIt.size(); - // in full interlace - for (int i=0; i > compValIt = - subPartValues.template getAllValues( componentShift, nbComponents, add3dComp ); - nbComponents = compValIt.size(); - // in full interlace - for (int i=0; i -void writeGoldASCIIValues( const _SubPartValues& subPartValues, - int nbValues, - int nbComponents, - int componentShift, - ofstream & ensightDataFile ) -{ - // in no-interlace - for(int j=1; j<=nbComponents; j++) { - if ( subPartValues.myNumbers ) - { - _SelectedValueIterator values - = subPartValues.template getSelectedValues( j, componentShift, nbComponents ); - for (int i=0; i values - = subPartValues.template getValues( j, componentShift, nbComponents ); - for (int i=0; i -void write6BinaryValues( const _SubPartValues& subPartValues, - int nbValues, - int nbComponents, - int componentShift, - _BinaryFileWriter & ensightDataFile ) -{ - const bool add3dComp = true; - if ( subPartValues.myNumbers ) - { - vector< _SelectedValueIterator > compValIt = - subPartValues.template getAllSelectedValues( componentShift, nbComponents, add3dComp ); - ensightDataFile.addReal( compValIt, nbValues, MED_FULL_INTERLACE ); - } - else - { - vector< _ValueIterator > compValIt = - subPartValues.template getAllValues( componentShift, nbComponents, add3dComp ); - ensightDataFile.addReal( compValIt, nbValues, MED_FULL_INTERLACE ); - } -} - -//======================================================================= -/*! - * \brief Write field values in EnSight GOLD Binary format -*/ -//======================================================================= - -template< typename T > -void writeGoldBinaryValues( const _SubPartValues& subPartValues, - int nbValues, - int nbComponents, - int componentShift, - _BinaryFileWriter & ensightDataFile ) -{ - const bool add3dComp = false; - if ( subPartValues.myNumbers ) - { - vector< _SelectedValueIterator > compValIt = - subPartValues.template getAllSelectedValues( componentShift, nbComponents, add3dComp ); - ensightDataFile.addReal( compValIt, nbValues, MED_NO_INTERLACE ); - } - else - { - vector< _ValueIterator > compValIt = - subPartValues.template getAllValues( componentShift, nbComponents, add3dComp ); - ensightDataFile.addReal( compValIt, nbValues, MED_NO_INTERLACE ); - } - // add the 3-d component to a vector in 2D space - if ( nbComponents == 2 ) { - vector values( nbValues, 0. ); - ensightDataFile.addReal( & values[0], nbValues ); - } -} - -//======================================================================= -//function : write -//======================================================================= - -void ENSIGHT_FIELD_WRONLY_DRIVER::write(void) const - throw (MEDEXCEPTION) -{ - const char * LOC = "ENSIGHT_FIELD_WRONLY_DRIVER::write(void) const " ; - BEGIN_OF_MED(LOC); - - openConst(false) ; // check if can write to case file - - // Ensight case organization requires a main file (filename.case) which defines organization - - _CaseFileDriver caseFile( getCaseFileName(), this); - caseFile.read(); - caseFile.addField( this ); - caseFile.write(); // all fields of _CaseFileDriver_User are set by this method - - openConst(true) ; // check if can write to data file - - const FIELD_* field = _ptrField; - const SUPPORT * support = field->getSupport(); - const GMESH * mesh = support->getMesh(); - - int dt = field->getIterationNumber(); - int it = field->getOrderNumber(); - int nbComponents = field->getNumberOfComponents(); - med_type_champ type = field->getValueType() ; - - medEntityMesh entity = support->getEntity(); - int totalNbValues = support->getNumberOfElements(MED_ALL_ELEMENTS); - //const int* mainNbValsByType = support->getNumberOfElements(); - - int nbValuesByType = 0; - int& componentShift = (type == MED_NO_INTERLACE_BY_TYPE) ? nbValuesByType : totalNbValues; - - bool isOnAll = support->isOnAllElements(); - if (!isOnAll && !mesh) - throw MED_EXCEPTION(STRING("Can't write field ") << field->getName() << - ", which is not on all elements while mesh is not set to its support"); - if (!isOnAll) - isOnAll = ( mesh->getNumberOfElements(entity,MED_ALL_ELEMENTS) == componentShift ); - if (!isOnAll && entity == MED_NODE && !isGoldFormat() ) { - throw MED_EXCEPTION(compatibilityPb("Can't write field ") << field->getName() << - " which is not on all nodes of the mesh in EnSight6 format," - " use EnSight Gold format instead"); - } - if ( entity == MED_EDGE && mesh && !isToWriteEntity( MED_EDGE, mesh )) - throw MED_EXCEPTION(STRING(LOC) << "Can't write field " << field->getName() - << ", fields on MED_EDGE in volumic mesh are not supported"); - - // part number - int partNum = getPartNumber( support ); - string isPartial = ""; - if ( !partNum ) { - if ( !isGoldFormat() ) - throw MED_EXCEPTION(STRING("Can't write field ") << field->getName() - << " in EnSight6 format, it's support " << support->getName() - << " is not stored in geo file, use EnSight Gold format instead"); - isPartial = " partial"; - SUPPORT *tmpSupport=new SUPPORT; - tmpSupport->setAll(true); - tmpSupport->setEntity( entity ); - partNum = getPartNumber( tmpSupport ); - tmpSupport->removeReference(); - } - - // supports to write the field for - map< int, const SUPPORT* > parts; - map< int, const SUPPORT* >::iterator partNumIt; - parts[ partNum ] = support; - - // In Ensight 6, nodal field is visible on all parts as nodes are global, for - // the rest cases we write field for all groups in order to see values on them - if ( isOnAll && ( isGoldFormat() || entity != MED_NODE ) && mesh ) - { - // In Ensight Gold, to see nodal field on all groups we write them all - int ent = entity, toEntity = entity + 1; - if ( isGoldFormat() && entity == MED_NODE ) - ent = MED_CELL, toEntity = MED_ALL_ENTITIES; - - for ( ; ent < toEntity; ++ent ) { - int nbGroups = mesh->getNumberOfGroups(ent); - for ( int i=1; i<=nbGroups; i++) { - const GROUP* group = mesh->getGroup( ent, i ); - if ( group != support && !group->isOnAllElements() ) { - partNum = getPartNumber( group ); - if ( partNum ) - parts.insert( make_pair( partNum, group )); - } - } - } - } - - // description - string description = field->getDescription(); - if ( description.empty() ) - description = STRING(field->getName()) << " dt=" << dt << " it=" << it; - - cout << "-> Creating the Ensight data file " << getDataFileName() << endl ; - - - _SubPartValues geoTypeValues; - geoTypeValues.myOwnValues = false; - geoTypeValues.myInterlace = field->getInterlacingType(); - int nbWrittenValues = 0; - - if ( isBinaryEnSightFormatForWriting() ) - { - // ====================================================== - // Binary - // ====================================================== - - // function to write values - typedef void (* TWriteValues) (const _SubPartValues& , int, int, int, _BinaryFileWriter &); - TWriteValues writeValues; - if ( isGoldFormat() ) { - if ( type == MED_REEL64 ) writeValues = writeGoldBinaryValues; - else if ( type == MED_INT32 ) writeValues = writeGoldBinaryValues; - else writeValues = writeGoldBinaryValues; - } - else { - if ( type == MED_REEL64 ) writeValues = write6BinaryValues; - else if ( type == MED_INT32 ) writeValues = write6BinaryValues; - else writeValues = write6BinaryValues; - } - _BinaryFileWriter ensightDataFile( getDataFileName() ); - - // description - ensightDataFile.addString( description ); - - for ( partNumIt = parts.begin(); partNumIt != parts.end(); ++partNumIt) - { - const SUPPORT* partSup = partNumIt->second; - partNum = partNumIt->first; - const bool otherEntity = ( entity != partSup->getEntity() ); // Gold, nodal field - nbWrittenValues = 0; - - // part number - if ( isGoldFormat() ) { - ensightDataFile.addString("part"); - ensightDataFile.addInt( partNum ); - } - else if ( entity != MED_NODE ) { - ensightDataFile.addString( STRING("part ") << partNum ); - } - // loop on types - int nbTypes = partSup->getNumberOfTypes(); - const medGeometryElement* geoType = partSup->getTypes(); - for (int i=0; igetNumberOfElements(medType); - - // type name - if ( entity != MED_NODE ) { - const TEnSightElemType& ensightType = getEnSightType(medType); - ensightDataFile.addString( ensightType._name + isPartial ); - } - else if ( isGoldFormat() ) { - ensightDataFile.addString( "coordinates" + isPartial ); - } - - // supporting numbers (Gold only) - if ( !isPartial.empty() ) { - const int *number = partSup->getNumber(medType); - ensightDataFile.addInt( nbValuesByType ); - ensightDataFile.addInt( number, nbValuesByType ); - } - - // get field values - if ( otherEntity ) { // Gold, nodal field, non-nodal group (partSup) - if ( isOnAll && partSup->isOnAllElements() ) { - geoTypeValues.myNumbers = 0; - geoTypeValues.myValues = getValuePointer( 1, field ); - nbValuesByType = totalNbValues; - } - else { - geoTypeValues.myNumbers = getNodeNumbers( partSup, nbValuesByType ); - geoTypeValues.myValues = getValuePointer( geoTypeValues.myNumbers[0], field ); - } - } - else if ( partSup->getNumberOfElements(MED_ALL_ELEMENTS) != totalNbValues ) { - geoTypeValues.myNumbers = partSup->getNumber(medType); - geoTypeValues.myValues = getValuePointer( geoTypeValues.myNumbers[0], field ); - } - else { - geoTypeValues.myNumbers = 0; - geoTypeValues.myValues = getValuePointer( nbWrittenValues + 1, field ); - } - // write values - writeValues(geoTypeValues, nbValuesByType, nbComponents, componentShift, ensightDataFile); - nbWrittenValues += nbValuesByType; - - if ( otherEntity ) { - if ( geoTypeValues.myNumbers ) delete [] geoTypeValues.myNumbers; - break; // all nodal values are written at once - } - } - } - } - else - { - // ====================================================== - // ASCII - // ====================================================== - - // function to write values - typedef void (* TWriteValues) (const _SubPartValues& , int, int, int, ofstream &); - TWriteValues writeValues; - if ( isGoldFormat() ) { - if ( type == MED_REEL64 ) writeValues = writeGoldASCIIValues; - else if ( type == MED_INT32 ) writeValues = writeGoldASCIIValues; - else writeValues = writeGoldASCIIValues; - } - else { - if ( type == MED_REEL64 ) writeValues = write6ASCIIValues; - else if ( type == MED_INT32 ) writeValues = write6ASCIIValues; - else writeValues = write6ASCIIValues; - } - const int iw = isGoldFormat() ? 10 : 8; // width of integer - - ofstream ensightDataFile( getDataFileName().c_str(), ios::out); - ensightDataFile.setf(ios::scientific); - ensightDataFile.precision(5); - - // description - ensightDataFile << description << endl; - - for ( partNumIt = parts.begin(); partNumIt != parts.end(); ++partNumIt) - { - const SUPPORT* partSup = partNumIt->second; - partNum = partNumIt->first; - const bool otherEntity = ( entity != partSup->getEntity() ); // Gold, nodal field - nbWrittenValues = 0; - - // part number - if ( isGoldFormat() ) - ensightDataFile << "part" << endl << setw(iw) << partNum << endl; - else if ( entity != MED_NODE ) { - ensightDataFile << "part " << partNum << endl; - } - // loop on types - int nbTypes = partSup->getNumberOfTypes(); - const medGeometryElement* geoType = partSup->getTypes(); - for (int i=0; igetNumberOfElements(medType); - - // type name - if ( entity != MED_NODE ) { - const TEnSightElemType& ensightType = getEnSightType(medType); - ensightDataFile << ensightType._name << isPartial << endl; - } - else if ( isGoldFormat() ) { - ensightDataFile << "coordinates" << isPartial << endl; - } - - // supporting numbers (Gold only) - if ( !isPartial.empty() ) { - const int *number = partSup->getNumber(medType); - const int *nEnd = number + nbValuesByType; - ensightDataFile << setw(iw) << nbValuesByType << endl; - while ( number < nEnd ) - ensightDataFile << setw(iw) << *number++ << endl; - } - - // get field values - if ( otherEntity ) { // Gold, nodal field, non-nodal group (partSup) - if ( isOnAll && partSup->isOnAllElements() ) { - geoTypeValues.myNumbers = 0; - geoTypeValues.myValues = getValuePointer( 1, field ); - nbValuesByType = totalNbValues; - } - else { - geoTypeValues.myNumbers = getNodeNumbers( partSup, nbValuesByType ); - geoTypeValues.myValues = getValuePointer( geoTypeValues.myNumbers[0], field ); - } - } - else if ( partSup->getNumberOfElements(MED_ALL_ELEMENTS) != totalNbValues ) { - geoTypeValues.myNumbers = partSup->getNumber(medType); - geoTypeValues.myValues = getValuePointer( geoTypeValues.myNumbers[0], field ); - } - else { - geoTypeValues.myNumbers = 0; - geoTypeValues.myValues = getValuePointer( nbWrittenValues + 1, field ); - } - - // write values - writeValues(geoTypeValues, nbValuesByType, nbComponents, componentShift, ensightDataFile); - nbWrittenValues += nbValuesByType; - - if ( otherEntity ) { - if ( geoTypeValues.myNumbers ) delete [] geoTypeValues.myNumbers; - break; // all nodal values are written at once - } - } - } // loop on supports - - ensightDataFile.close(); - } -} diff --git a/src/MEDMEM/MEDMEM_EnsightFieldDriver.hxx b/src/MEDMEM/MEDMEM_EnsightFieldDriver.hxx deleted file mode 100644 index 89b654f61..000000000 --- a/src/MEDMEM/MEDMEM_EnsightFieldDriver.hxx +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef ENSIGHT_FIELD_DRIVER_HXX -#define ENSIGHT_FIELD_DRIVER_HXX - -#include - -#include "MEDMEM_EnsightUtils.hxx" - -// ========================================================================================== -/*! - Driver Ensight for FIELD. -*/ -// ========================================================================================== - -namespace MEDMEM { - -class MEDMEM_EXPORT ENSIGHT_FIELD_DRIVER : public MEDMEM_ENSIGHT::_CaseFileDriver_User -{ -protected: - FIELD_ * _ptrField; - std::string _fieldName; - std::string _constantValue; - - void openConst(bool checkDataFile=false) const throw (MEDEXCEPTION); - -public : - - /*! - Constructor. - */ - ENSIGHT_FIELD_DRIVER(); - ENSIGHT_FIELD_DRIVER(const std::string & fileName, - FIELD_ * ptrField, - MED_EN::med_mode_acces accessMode); - /*! - Copy constructor. - */ - ENSIGHT_FIELD_DRIVER(const ENSIGHT_FIELD_DRIVER & fieldDriver); - virtual void merge ( const GENDRIVER& driver ); - /*! - Destructor. - */ - virtual ~ENSIGHT_FIELD_DRIVER(); - - /*! - Set the name of the FIELD in EnSight file. - - It could be different than the name of the FIELD object. - */ - virtual void setFieldName(const std::string & fieldName) throw (MEDEXCEPTION); - - /*! - Get the name of the FIELD in EnSight file. - */ - virtual std::string getFieldName() const { return _fieldName; } - - virtual void open() throw (MEDEXCEPTION) { openConst(); } - - virtual void close() {} - - FIELD_* getField() { return _ptrField; } - - void setConstantValue(const std::string& value) { _constantValue = value; } - - const std::string& getConstantValue() const { return _constantValue; } - -}; - -// ========================================================================================== - -class MEDMEM_EXPORT ENSIGHT_FIELD_RDONLY_DRIVER : public ENSIGHT_FIELD_DRIVER -{ -public : - - /*! - Constructor to read the field of a specified name and index-th time step. - Append "_Im" to field name to select an imaginary part of a complex field - */ - ENSIGHT_FIELD_RDONLY_DRIVER(const string & fileName, FIELD_ * ptrField, int step=1); - - ENSIGHT_FIELD_RDONLY_DRIVER(); - ENSIGHT_FIELD_RDONLY_DRIVER(const ENSIGHT_FIELD_RDONLY_DRIVER & fieldDriver); - ~ENSIGHT_FIELD_RDONLY_DRIVER(); - virtual GENDRIVER * copy ( void ) const ; - virtual void merge ( const GENDRIVER& driver ); - - /*! - Read a field - */ - void read ( void ) throw (MEDEXCEPTION); - - /*! - Return a MEDEXCEPTION : it is a read-only driver. - */ - void write( void ) const throw (MEDEXCEPTION) ; - -private: - - void readGoldASCII (); - void readGoldBinary(); - void read6ASCII (); - void read6Binary (); - - void skipTimeStamp(MEDMEM_ENSIGHT::_BinaryFileReader& fileReader); - - int _fieldStep; -}; - -// ========================================================================================== - -class MEDMEM_EXPORT ENSIGHT_FIELD_WRONLY_DRIVER : public ENSIGHT_FIELD_DRIVER -{ -public : - - /*! - Constructor to append a field to the file - */ - ENSIGHT_FIELD_WRONLY_DRIVER(const string & fileName, const FIELD_ * ptrField); - - ENSIGHT_FIELD_WRONLY_DRIVER(); - ENSIGHT_FIELD_WRONLY_DRIVER(const ENSIGHT_FIELD_WRONLY_DRIVER & fieldDriver); - ~ENSIGHT_FIELD_WRONLY_DRIVER(); - GENDRIVER * copy ( void ) const ; - - /*! - Return a MEDEXCEPTION : it is the write-only driver. - */ - void read ( void ) throw (MEDEXCEPTION) ; - - /*! - Write FIELD in the specified file, the mesh is supposed to be - written in this file - */ - void write( void ) const throw (MEDEXCEPTION) ; - -}; - -}//End namespace MEDMEM - -#endif /* ENSIGHT_FIELD_DRIVER_HXX */ diff --git a/src/MEDMEM/MEDMEM_EnsightMedDriver.cxx b/src/MEDMEM/MEDMEM_EnsightMedDriver.cxx deleted file mode 100644 index a2347bb26..000000000 --- a/src/MEDMEM/MEDMEM_EnsightMedDriver.cxx +++ /dev/null @@ -1,314 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_define.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Field.hxx" - -#include "MEDMEM_EnsightMedDriver.hxx" -#include "MEDMEM_EnsightFieldDriver.hxx" -#include "MEDMEM_EnsightMeshDriver.hxx" - -using namespace std; -//using namespace MEDMEM; -using namespace MED_EN; -using namespace MEDMEM_ENSIGHT; - -// ================================================================================ -// ENSIGHT_MED_DRIVER -// ================================================================================ -namespace MEDMEM { - -ENSIGHT_MED_DRIVER::ENSIGHT_MED_DRIVER():_CaseFileDriver_User() -{ -} - -ENSIGHT_MED_DRIVER::ENSIGHT_MED_DRIVER(const string & fileName, - med_mode_acces accessMode): - _CaseFileDriver_User(fileName,accessMode) -{ -} - -ENSIGHT_MED_DRIVER::ENSIGHT_MED_DRIVER(const ENSIGHT_MED_DRIVER & driver): - _CaseFileDriver_User(driver) -{ -} - -void ENSIGHT_MED_DRIVER::openConst() const -{ - const char * LOC ="ENSIGHT_MED_DRIVER::open() : "; - BEGIN_OF_MED(LOC); - - if ( _fileName.empty() ) - throw MED_EXCEPTION - ( LOCALIZED( STRING(LOC) << "_fileName is empty, " - "please set a correct fileName before calling open()")); - - if (!canOpenFile( _fileName, getAccessMode() )) - throw MED_EXCEPTION - ( LOCALIZED( STRING(LOC) << "Can not open main Ensight file " << _fileName)); - - END_OF_MED(LOC); -} - -void ENSIGHT_MED_DRIVER::open() -{ - openConst(); -} -void ENSIGHT_MED_DRIVER::close() -{ -} - -ENSIGHT_MED_DRIVER::~ENSIGHT_MED_DRIVER() -{ - MESSAGE_MED("ENSIGHT_MED_DRIVER::~ENSIGHT_MED_DRIVER() has been destroyed"); -} - -// ================================================================================ -// WRONLY -// ================================================================================ - -ENSIGHT_MED_WRONLY_DRIVER::ENSIGHT_MED_WRONLY_DRIVER() : ENSIGHT_MED_DRIVER(), _fields(0) -{ -} - -ENSIGHT_MED_WRONLY_DRIVER::ENSIGHT_MED_WRONLY_DRIVER(const string & fileName, - const vector< const FIELD_* >& fields) - : ENSIGHT_MED_DRIVER(fileName, MED_EN::WRONLY ), _fields( fields ) -{ -} - -ENSIGHT_MED_WRONLY_DRIVER::ENSIGHT_MED_WRONLY_DRIVER(const ENSIGHT_MED_WRONLY_DRIVER & driver) - : ENSIGHT_MED_DRIVER(driver), _fields( driver._fields ) -{ -} - -ENSIGHT_MED_WRONLY_DRIVER::~ENSIGHT_MED_WRONLY_DRIVER() -{ -} - -GENDRIVER * ENSIGHT_MED_WRONLY_DRIVER::copy() const -{ - return new ENSIGHT_MED_WRONLY_DRIVER(*this) ; -} - -void ENSIGHT_MED_WRONLY_DRIVER::read() throw (MEDEXCEPTION) -{ - throw MEDEXCEPTION("ENSIGHT_MED_WRONLY_DRIVER::read : Can't read with a WRONLY driver !"); -} - -void ENSIGHT_MED_WRONLY_DRIVER::write() const throw (MEDEXCEPTION) -{ - const char * LOC = "ENSIGHT_MED_WRONLY_DRIVER::write() : "; - BEGIN_OF_MED(LOC); - - openConst(); // check if can open the case file - - _CaseFileDriver caseFile( getCaseFileName(), this ); - - map< const GMESH*, vector< const FIELD_* > > mesh2fields; - for (unsigned i = 0; i < _fields.size(); ++i ) - mesh2fields[ _fields[i]->getSupport()->getMesh() ].push_back( _fields[i] ); - - // Create drivers for all meshes and fields - // and add them to be written to Case file - - list< GENDRIVER* > drivers; - ENSIGHT_MESH_WRONLY_DRIVER * meshDriver; - ENSIGHT_FIELD_WRONLY_DRIVER * fieldDriver; - - map< const GMESH*, vector< const FIELD_* > >::iterator m_ff = mesh2fields.begin(); - for (; m_ff != mesh2fields.end(); ++m_ff ) - { - const GMESH * mesh = m_ff->first ; - meshDriver = new ENSIGHT_MESH_WRONLY_DRIVER( _fileName, mesh ); - caseFile.addMesh( meshDriver ); - drivers.push_back( meshDriver ); - - // all fields on this mesh - const vector< const FIELD_*> & fields = m_ff->second; - for (unsigned j=0; j::iterator drv = drivers.begin(); - for ( ; drv != drivers.end(); ++drv ) { - GENDRIVER* driver = *drv; - driver->write(); - delete driver; - } - - END_OF_MED(LOC); -} - -// ================================================================================ -// RDONLY -// ================================================================================ - -ENSIGHT_MED_RDONLY_DRIVER::ENSIGHT_MED_RDONLY_DRIVER() : - ENSIGHT_MED_DRIVER(), _fields(0), _isFileStructRead(false) -{ -} - -ENSIGHT_MED_RDONLY_DRIVER::ENSIGHT_MED_RDONLY_DRIVER(const string & fileName, - vector< FIELD_* >& fields) - : ENSIGHT_MED_DRIVER( fileName, MED_EN::RDONLY), _fields( & fields ), _isFileStructRead(false) -{ -} - -ENSIGHT_MED_RDONLY_DRIVER::ENSIGHT_MED_RDONLY_DRIVER(const ENSIGHT_MED_RDONLY_DRIVER & driver) - : ENSIGHT_MED_DRIVER(driver), - _fields( driver._fields ), - _isFileStructRead(driver._isFileStructRead) -{ -} - -ENSIGHT_MED_RDONLY_DRIVER::~ENSIGHT_MED_RDONLY_DRIVER() -{ -} - -GENDRIVER * ENSIGHT_MED_RDONLY_DRIVER::copy() const -{ - return new ENSIGHT_MED_RDONLY_DRIVER(*this) ; -} - -void ENSIGHT_MED_RDONLY_DRIVER::write() const throw (MEDEXCEPTION) -{ - throw MEDEXCEPTION("ENSIGHT_MED_RDONLY_DRIVER::write : Can't write with a RDONLY driver !"); -} - -void ENSIGHT_MED_RDONLY_DRIVER::read() -{ - const char * LOC = "ENSIGHT_MED_RDONLY_DRIVER::read() : " ; - BEGIN_OF_MED(LOC); - - if ( _isFileStructRead ) - { - for ( unsigned i = 0; i < _fields->size(); ++i ) - { - const GMESH* mesh = _fields->at(i)->getSupport()->getMesh(); - if ( mesh->getNumberOfNodes() < 1 ) - const_cast( mesh )->read( getId() ); - _fields->at(i)->read( getId() ); - } - } - else - { - open(); // check if can open the case file - - _CaseFileDriver caseFile( getCaseFileName(), this ); - - caseFile.read(); - - _fields->clear(); - int nbOfFields = caseFile.getNbVariables(); - if ( nbOfFields < 1 ) - return; - - int nbOfMeshes = caseFile.getNbMeshes(); - vector meshes; - for ( int i = 1; i <= nbOfMeshes; ++i ) - { - MESH* mesh = new MESH; - ENSIGHT_MESH_RDONLY_DRIVER meshDriver(_fileName, mesh, i); - caseFile.setDataFileName( i, &meshDriver ); - int drv = mesh->addDriver( meshDriver ); - mesh->read( drv ); - meshes.push_back( mesh ); - } - - for ( int i = 1; i <= nbOfFields; i++ ) - { - int nbSteps = caseFile.getNbVarSteps( i ); - for ( int step = 1; step <= nbSteps; ++step ) - { - FIELD_* field = new FIELD(); - ENSIGHT_FIELD_RDONLY_DRIVER fieldDriver( _fileName, field ); - /*int meshIndex =*/ caseFile.setDataFileName( i, step, &fieldDriver ); - fieldDriver.open(); - fieldDriver.read(); - _fields->push_back( field ); - } - } - } -} - -//================================================================================ -/*! - * \brief Create all meshes and fields but not read them - */ -//================================================================================ - -void ENSIGHT_MED_RDONLY_DRIVER::readFileStruct() -{ - const char * LOC = "ENSIGHT_MED_RDONLY_DRIVER::read() : " ; - BEGIN_OF_MED(LOC); - - open(); // check if can open the case file - - _CaseFileDriver caseFile( getCaseFileName(), this ); - - caseFile.read(); - - int nbOfMeshes = caseFile.getNbMeshes(); - vector meshes( nbOfMeshes+1, (MESH*)0 ); - for ( int i = 1; i <= nbOfMeshes; ++i ) - { - MESH* mesh = meshes[ i ] = new MESH; - ENSIGHT_MESH_RDONLY_DRIVER meshDriver(_fileName, mesh, i); - caseFile.setDataFileName( i, &meshDriver ); // retrieve mesh name - setId( mesh->addDriver( meshDriver )); - } - _isFileStructRead = true; - - _fields->clear(); - int nbOfFields = caseFile.getNbVariables(); - for ( int i = 1; i <= nbOfFields; i++ ) - { - int nbSteps = caseFile.getNbVarSteps( i ); - for ( int step = 1; step <= nbSteps; ++step ) - { - FIELD* field = new FIELD(); - ENSIGHT_FIELD_RDONLY_DRIVER fieldDriver( _fileName, field, step ); - int meshIndex = caseFile.setDataFileName( i, step, &fieldDriver ); // retrieve field name - field->addDriver( fieldDriver ); - if ( const SUPPORT* sup = field->getSupport() ) { - if ( meshIndex > nbOfMeshes || !meshes[ meshIndex ]) - meshIndex = 1; - ((SUPPORT*) sup)->setMesh( meshes[ meshIndex ]); - } - _fields->push_back( field ); - } - } -} -} diff --git a/src/MEDMEM/MEDMEM_EnsightMedDriver.hxx b/src/MEDMEM/MEDMEM_EnsightMedDriver.hxx deleted file mode 100644 index 281c192f8..000000000 --- a/src/MEDMEM/MEDMEM_EnsightMedDriver.hxx +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef ENSIGHT_MED_DRIVER_HXX -#define ENSIGHT_MED_DRIVER_HXX - -#include -#include "MEDMEM_STRING.hxx" -#include "MEDMEM_Utilities.hxx" -#include "MEDMEM_Exception.hxx" - -#include "MEDMEM_EnsightUtils.hxx" - -#include - -using namespace std ; - - -namespace MEDMEM { -class MESH; -class SUPPORT; -class FIELD_; - -// ============================================================================== -/*! - * \brief Base of EnSight drivers - */ -// ============================================================================== - -class MEDMEM_EXPORT ENSIGHT_MED_DRIVER : public MEDMEM_ENSIGHT::_CaseFileDriver_User -{ -protected: - - virtual void openConst() const; - -public : - ENSIGHT_MED_DRIVER(); - ENSIGHT_MED_DRIVER(const string & fileName, MED_EN::med_mode_acces accessMode); - ENSIGHT_MED_DRIVER(const ENSIGHT_MED_DRIVER & driver); - virtual ~ENSIGHT_MED_DRIVER(); - - virtual void open(); - virtual void close(); -}; - -// ============================================================================== -/*! - * \brief Reading EnSight driver - */ -// ============================================================================== - -class MEDMEM_EXPORT ENSIGHT_MED_RDONLY_DRIVER : public virtual ENSIGHT_MED_DRIVER -{ -public : - ENSIGHT_MED_RDONLY_DRIVER(); - ENSIGHT_MED_RDONLY_DRIVER(const string & fileName, std::vector< FIELD_* >& fields); - ENSIGHT_MED_RDONLY_DRIVER(const ENSIGHT_MED_RDONLY_DRIVER & driver); - virtual ~ENSIGHT_MED_RDONLY_DRIVER(); - virtual void write ( void ) const throw (MEDEXCEPTION) ; - virtual void read ( void ) ; - virtual void readFileStruct ( void ) ; - GENDRIVER * copy ( void ) const; -private: - - std::vector< FIELD_* > * _fields; - bool _isFileStructRead; -}; - -// ============================================================================== -/*! - * \brief Writing EnSight driver. - * To set writing format use - * setEnSightFormatForWriting(EnSightFormat) and - * setEnSightBinaryFormatForWriting(bool) - */ -// ============================================================================== - -class MEDMEM_EXPORT ENSIGHT_MED_WRONLY_DRIVER : public virtual ENSIGHT_MED_DRIVER -{ - const std::vector< const FIELD_* > _fields; -public : - ENSIGHT_MED_WRONLY_DRIVER(); - ENSIGHT_MED_WRONLY_DRIVER(const string & fileName, const std::vector< const FIELD_* >& fields); - ENSIGHT_MED_WRONLY_DRIVER(const ENSIGHT_MED_WRONLY_DRIVER & driver); - virtual ~ENSIGHT_MED_WRONLY_DRIVER(); - virtual void write ( void ) const throw (MEDEXCEPTION) ; - virtual void read ( void ) throw (MEDEXCEPTION) ; - GENDRIVER * copy ( void ) const; -}; - -} - - -#endif /* ENSIGTH_MED_DRIVER_HXX */ diff --git a/src/MEDMEM/MEDMEM_EnsightMeshDriver.cxx b/src/MEDMEM/MEDMEM_EnsightMeshDriver.cxx deleted file mode 100644 index 79f81dc23..000000000 --- a/src/MEDMEM/MEDMEM_EnsightMeshDriver.cxx +++ /dev/null @@ -1,3320 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_EnsightMeshDriver.hxx" - -#include -#include -#include - -#include "MEDMEM_define.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Group.hxx" -#include "MEDMEM_Coordinate.hxx" -#include "MEDMEM_Connectivity.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_CellModel.hxx" -#include "MEDMEM_Grid.hxx" - -#include "MEDMEM_MedMeshDriver.hxx" - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; -using namespace MEDMEM_ENSIGHT; - -#define TStrTool _ASCIIFileReader -#define TOLERANCE 1e-15 - -//#define ELEMENT_ID_GIVEN - -namespace { - - // --------------------------------------------------------------------- - /*! - * \brief The beginning of mesh description used to distinguish files - * generated by ENSIGHT_MESH_WRONLY_DRIVER from others - */ - const char* theDescriptionPrefix = "Meshing from MedMemory. "; - - // --------------------------------------------------------------------- - /*! - * \brief Default name of a mesh read from EnSight - */ - const char* theDefaultMeshName = "EnsightMesh"; - - // --------------------------------------------------------------------- - /*! - * \brief Max number of types in EnSight part - */ - const int theMaxNbTypes = 20; - - // --------------------------------------------------------------------- - /*! - * \brief Make array with elements == index[i+1]-index[i] - * \param size - result array size - */ - int* getNumbersByIndex( const int* index, int size, const int* elemNumbers=0) - { - int* numbers = new int[size]; - int* n = numbers; - if ( elemNumbers ) { - const int *elem = elemNumbers-1, *elemEnd = elemNumbers + size; - while ( ++elem < elemEnd ) - *n++ = index[*elem] - index[*elem-1]; - } - else { - const int *ind = index, *indEnd = index + size + 1; - while ( ++ind < indEnd ) - *n++ = ind[0] - ind[-1]; - } - return numbers; - } - // --------------------------------------------------------------------- - /*! - * \brief Type used to delete numbers returned by getNumbersByIndex() - */ - typedef _ValueOwner TNumbers; - -} // namespace - - -ENSIGHT_MESH_DRIVER::ENSIGHT_MESH_DRIVER(): _CaseFileDriver_User(), _ptrMesh((MESH *)NULL) -{ -} - -ENSIGHT_MESH_DRIVER::ENSIGHT_MESH_DRIVER(const string & fileName, - GMESH * ptrMesh) - :_CaseFileDriver_User(fileName,MED_EN::RDWR), _ptrMesh(ptrMesh) -{ - if ( !_ptrMesh ) - throw MEDEXCEPTION("ENSIGHT_MESH_DRIVER(fileName, ptrMesh) : mesh is NULL"); - _meshName = _ptrMesh->getName(); -} - -ENSIGHT_MESH_DRIVER::ENSIGHT_MESH_DRIVER(const string & fileName, - GMESH * ptrMesh, - med_mode_acces accessMode) - :_CaseFileDriver_User(fileName,accessMode), _ptrMesh(ptrMesh) -{ - if ( !_ptrMesh ) - throw MEDEXCEPTION("ENSIGHT_MESH_DRIVER(fileName, ptrMesh) : mesh is NULL"); - _meshName = _ptrMesh->getName(); -} - -ENSIGHT_MESH_DRIVER::ENSIGHT_MESH_DRIVER(const ENSIGHT_MESH_DRIVER & driver) - :_CaseFileDriver_User(driver), _ptrMesh(driver._ptrMesh), _meshName(driver._meshName) -{ -} - -ENSIGHT_MESH_DRIVER::~ENSIGHT_MESH_DRIVER() -{ - MESSAGE_MED("ENSIGHT_MESH_DRIVER::~ENSIGHT_MESH_DRIVER() has been destroyed"); -} - -void ENSIGHT_MESH_DRIVER::setMeshName(const string & meshName) { _meshName = meshName; } - -string ENSIGHT_MESH_DRIVER::getMeshName() const { return _meshName; } - -void ENSIGHT_MESH_DRIVER::openConst(bool checkDataFile) const -{ - const char * LOC ="ENSIGHT_MESH_DRIVER::open() : "; - BEGIN_OF_MED(LOC); - - if ( checkDataFile ) - { - if ( getDataFileName().empty() ) - throw MED_EXCEPTION - ( LOCALIZED( STRING(LOC) << "Internal error, geometry file name is empty")); - - if (!canOpenFile( getDataFileName(), getAccessMode() )) - throw MED_EXCEPTION - ( LOCALIZED( STRING(LOC) << "Can not open Ensight Geometry file " << getDataFileName() - << " in access mode " << getAccessMode())); - } - else - { - if ( getCaseFileName().empty() ) - throw MED_EXCEPTION - ( LOCALIZED( STRING(LOC) << "Case file name is empty, " - "please set a correct fileName before calling open()")); - - if ( !canOpenFile( getCaseFileName(), getAccessMode() )) - throw MED_EXCEPTION - ( LOCALIZED( STRING(LOC) << "Can not open Ensight Case file " << getCaseFileName() - << " in access mode " << getAccessMode())); - } - - END_OF_MED(LOC); -} - -void ENSIGHT_MESH_DRIVER::open() { - openConst() ; -} - -void ENSIGHT_MESH_DRIVER::close() { -} - -// ================================================================================ -// WRONLY -// ================================================================================ - -ENSIGHT_MESH_WRONLY_DRIVER::ENSIGHT_MESH_WRONLY_DRIVER() : - ENSIGHT_MESH_DRIVER(), _append(0) -{ -} - -ENSIGHT_MESH_WRONLY_DRIVER::ENSIGHT_MESH_WRONLY_DRIVER(const string & fileName, - const GMESH * ptrMesh, - bool append) - : ENSIGHT_MESH_DRIVER( fileName, (GMESH*)ptrMesh, WRONLY ), _append(append) -{ -} - -ENSIGHT_MESH_WRONLY_DRIVER::ENSIGHT_MESH_WRONLY_DRIVER(const ENSIGHT_MESH_WRONLY_DRIVER & driver) - : ENSIGHT_MESH_DRIVER(driver),_append(driver._append) -{ -} - -ENSIGHT_MESH_WRONLY_DRIVER::~ENSIGHT_MESH_WRONLY_DRIVER() -{ -} - -GENDRIVER * ENSIGHT_MESH_WRONLY_DRIVER::copy() const -{ - return new ENSIGHT_MESH_WRONLY_DRIVER(*this) ; -} - -void ENSIGHT_MESH_WRONLY_DRIVER::read() throw (MEDEXCEPTION) { - throw MEDEXCEPTION("ENSIGHT_MESH_WRONLY_DRIVER::read : Can't read with a WRONLY driver !"); -} - -//================================================================================ -/*! - * \brief writing - */ -//================================================================================ - -void ENSIGHT_MESH_WRONLY_DRIVER::write() const throw (MEDEXCEPTION) -{ - const char * LOC = "ENSIGHT_MESH_WRONLY_DRIVER::write() : "; - BEGIN_OF_MED(LOC); - - openConst(false) ; // check if can write to case file - - // Ensight case organization requires a main file (filename.case) which defines organization - - _CaseFileDriver caseFile( getCaseFileName(), this); - if ( _append ) - caseFile.read(); - caseFile.addMesh( this ); - caseFile.write(); // all fields of _CaseFileDriver_User are set by this method - - openConst(true) ; // check if can write to data file - - cout << "-> creating the Ensight geometry file " << getDataFileName() << endl ; - - // Store mesh description and a special mark in the first two description lines each - // of 79 chars length maximum, while MED mesh description is up to 200 chars - const char* line1 = theDescriptionPrefix; - string line2 = _ptrMesh->getDescription(); - for ( unsigned i = 0; i < line2.size(); ++i ) { // protect from gabage - if ( !line2[ i ] || !isascii( line2[ i ])) { - line2.resize( i ); - break; - } - } - if ((int) line2.size() >= MAX_LINE_LENGTH ) - line2.resize( MAX_LINE_LENGTH ); - - // EnSight will assign node/element visible numbers it-self - const char* line3 = "node id assign"; -#ifdef ELEMENT_ID_GIVEN - const char* line4 = "element id given"; -#else - const char* line4 = "element id assign"; -#endif - - MESH* mesh = const_cast( _ptrMesh->convertInMESH() ) ; // we write unstructured only - - if ( isBinaryEnSightFormatForWriting() ) - { - // ====================================================== - // Binary - // ====================================================== - - _BinaryFileWriter ensightGeomFile( getDataFileName() ); - - ensightGeomFile.addString("C Binary"); - ensightGeomFile.addString(line1); - ensightGeomFile.addString(line2); - ensightGeomFile.addString(line3); - ensightGeomFile.addString(line4); - - // function to write a support as a part - typedef void (ENSIGHT_MESH_WRONLY_DRIVER::* TWritePart) (_BinaryFileWriter&, const SUPPORT*) const; - TWritePart writePart; - if ( isGoldFormat() ) - { - // GOLD - writePart = & ENSIGHT_MESH_WRONLY_DRIVER::writePartGoldBinary; - } - else - { - // ENSIGHT 6. Write addionally global nodes - writePart = & ENSIGHT_MESH_WRONLY_DRIVER::writePart6Binary; - - // All point are in 3D, so if we are in 1D or 2D, we complete by zero ! - int SpaceDimension = mesh->getSpaceDimension() ; - int NumberOfNodes = mesh->getNumberOfNodes() ; - ensightGeomFile.addString("coordinates"); - ensightGeomFile.addInt( NumberOfNodes ); - const double *coordinate = mesh->getCoordinates(MED_FULL_INTERLACE) ; - if ( SpaceDimension == 3 ) { - ensightGeomFile.addReal(coordinate, NumberOfNodes * SpaceDimension ); - } - else { - typedef _ValueIterator< double > TComponentIt; - vector< TComponentIt > coordCompIt( 3 ); - for (int j=0; j<3; j++, coordinate++) - if ( j < SpaceDimension ) - coordCompIt[ j ] = TComponentIt( coordinate, SpaceDimension ); - else - coordCompIt[ j ] = TComponentIt(); // to iterate on zeros - ensightGeomFile.addReal( coordCompIt, NumberOfNodes, MED_FULL_INTERLACE ); - } - } - - // We put connectivity - - if ( isToWriteEntity( MED_CELL, mesh )) - { - SUPPORT *allCells = const_cast( _ptrMesh->getSupportOnAll( MED_CELL )); - string oldName = allCells->getName(); - allCells->setName( _ptrMesh->getName() ); - try - { - (this->*writePart)( ensightGeomFile, allCells ); - } - catch (MED_EXCEPTION& ex) - { - allCells->setName( oldName ); - throw ex; - } - allCells->setName( oldName ); - } - // And meshdim-1 connectivity - if ( isToWriteEntity( MED_FACE, mesh )) - { - const SUPPORT *allFaces = _ptrMesh->getSupportOnAll( MED_FACE ); - (this->*writePart)( ensightGeomFile, allFaces); - } - else if ( isToWriteEntity(MED_EDGE, mesh)) - { - const SUPPORT *allEdges = _ptrMesh->getSupportOnAll( MED_EDGE ); - (this->*writePart)( ensightGeomFile, allEdges); - } - - // Write all groups as parts - - for ( int ent = MED_CELL; ent < MED_ALL_ENTITIES; ++ent ) - { - medEntityMesh entity = (medEntityMesh) ent; - int nbGroups = mesh->getNumberOfGroups(entity); - for ( int i=1; i<=nbGroups; i++) - { - const GROUP* group = mesh->getGroup( entity, i ); - (this->*writePart)( ensightGeomFile, group ); - } - } - - } - else - { - // ====================================================== - // ASCII - // ====================================================== - ofstream ensightGeomFile( getDataFileName().c_str(), ios::out); - ensightGeomFile.setf(ios::scientific); - ensightGeomFile.precision(5); - - ensightGeomFile << line1 << endl - << line2 << endl - << line3 << endl - << line4 << endl; - - // function to write a support as a part - typedef void (ENSIGHT_MESH_WRONLY_DRIVER::* TWritePart) (ofstream&, const SUPPORT*) const; - TWritePart writePart; - if ( isGoldFormat() ) - { - // GOLD - writePart = & ENSIGHT_MESH_WRONLY_DRIVER::writePartGoldASCII; - } - else - { - // ENSIGHT 6. Write addionally global nodes - writePart = & ENSIGHT_MESH_WRONLY_DRIVER::writePart6ASCII; - - // Put points (all point are in 3D, so if we are in 1D or 2D, we complete by zero ! - int SpaceDimension = mesh->getSpaceDimension() ; - int NumberOfNodes = mesh->getNumberOfNodes() ; - string zeros; - if (SpaceDimension==2) zeros = " 0.00000e+00"; - if (SpaceDimension==1) zeros = " 0.00000e+00 0.00000e+00"; - ensightGeomFile << "coordinates" << endl - << setw(8) << NumberOfNodes << endl ; - const double *coordinate = mesh->getCoordinates(MED_FULL_INTERLACE) ; - for (int i=0; i( _ptrMesh->getSupportOnAll( MED_CELL )); - string oldName = allCells->getName(); - allCells->setName( _ptrMesh->getName() ); - try - { - (this->*writePart)( ensightGeomFile, allCells ); - } - catch (MED_EXCEPTION& ex) - { - allCells->setName( oldName ); - throw ex; - } - allCells->setName( oldName ); - } - // And meshdim-1 connectivity - if ( isToWriteEntity( MED_FACE, mesh )) - { - const SUPPORT *allFaces = _ptrMesh->getSupportOnAll( MED_FACE ); - (this->*writePart)( ensightGeomFile, allFaces); - } - else if ( isToWriteEntity(MED_EDGE, mesh)) - { - const SUPPORT *allEdges = _ptrMesh->getSupportOnAll( MED_EDGE ); - (this->*writePart)( ensightGeomFile, allEdges); - } - - // Write all groups as parts - - for ( int ent = MED_CELL; ent < MED_ALL_ENTITIES; ++ent ) - { - medEntityMesh entity = (medEntityMesh) ent; - int nbGroups = mesh->getNumberOfGroups(entity); - for ( int i=1; i<=nbGroups; i++) - { - const GROUP* group = mesh->getGroup( entity, i ); - (this->*writePart)( ensightGeomFile, group ); - } - } - - ensightGeomFile.close(); - - mesh->removeReference(); - - } // end ASCII format - -} // ENSIGHT_MESH_WRONLY_DRIVER::write() - -//================================================================================ -/*! - * \brief Write support as an EnSight Gold part - */ -//================================================================================ - -void ENSIGHT_MESH_WRONLY_DRIVER::writePartGoldBinary(_BinaryFileWriter& ensightGeomFile, - const SUPPORT* support) const -{ - // part number - int partNum = getPartNumber( support ); - if ( !partNum ) - throw MED_EXCEPTION ( LOCALIZED( STRING("Internal error: invalid part number"))); - ensightGeomFile.addString( "part" ); - ensightGeomFile.addInt( partNum ); - - // group/mesh name - ensightGeomFile.addString( support->getName() ); - - // get geom types - medEntityMesh entity = support->getEntity(); - int nbTypes = support->getNumberOfTypes(); - const medGeometryElement* geoType = support->getTypes(); - - const int * connectivity = 0; - const int * elemConnectivity = 0; - const int * index = 0; - int j; - - const MESH* mesh = support->getMesh()->convertInMESH() ; // we write unstructured only - - // COORDINATES Gold binary - // =================================================================================== - // In Ensight, coordinates of nodes of support elements are in MED_NO_INTERLACE mode. - // We are to write only nodes belonging to elements of the support and - // nodal connectivity should refer to these nodes. - map med2ensIds; - map::iterator medEnsIt; - int SpaceDimension = _ptrMesh->getSpaceDimension() ; - int NumberOfNodes = _ptrMesh->getNumberOfNodes() ; - // ------------------------------------------------- - if ( support->isOnAllElements() ) - { - // nb of nodes - ensightGeomFile.addString( "coordinates" ); - ensightGeomFile.addInt( NumberOfNodes ); - - // coordinates - const double *coordinate = mesh->getCoordinates(MED_FULL_INTERLACE); - typedef _ValueIterator< double > TComponentIt; - vector< TComponentIt > coordCompIt( 1 ); - for (int j=0; j floatCoords( NumberOfNodes ); - for ( j=0; j < SPACE_DIM; j++) { // loop on dimensions - medEnsIt = med2ensIds.begin(); - if ( j < SpaceDimension ) { - const double *coordinate = mesh->getCoordinates(MED_FULL_INTERLACE) + j; - for (int i=0; ifirst-1) * SpaceDimension]; - } - else if ( j-1 < SpaceDimension ) { - for (int i=0; isecond = j; - } - - // CONNECTIVITY Gold binary - // =================================================================================== - // loop on types - for (int i=0; igetNumberOfElements(medType); - int nbCellNodes = ensightType._medIndex.size(); - - // type name and nb cells - ensightGeomFile.addString( ensightType._name ); - ensightGeomFile.addInt( numberOfCell ); - - vector nodeIds; - - // ------------------------------------------------- - if ( support->isOnAllElements() ) - { -#ifdef ELEMENT_ID_GIVEN - // elem numbers - nodeIds.resize( numberOfCell ); - for ( j = 1; j <= numberOfCell; j++) - nodeIds[ j-1 ] = j; - ensightGeomFile.addInt( nodeIds ); - - if ( entity != MED_NODE ) nodeIds.clear(); -#endif - - if ( nbCellNodes > 1 ) // STANDARD ELEMENTS connectivity - { - connectivity = mesh->getConnectivity( MED_NODAL, entity, medType); - nodeIds.reserve( numberOfCell * nbCellNodes); - for (j = 0 ; j < numberOfCell; j++, connectivity += nbCellNodes) - for (int k=0; kgetGlobalNumberingIndex(entity)[i]-1; - connectivity = mesh->getConnectivity( MED_NODAL, entity, medType); - int connLength = mesh->getConnectivityLength( MED_NODAL, entity, medType); - index = mesh->getConnectivityIndex(MED_NODAL, entity); - - // number of nodes in each element - { - TIntOwner nbNodesInPoly( getNumbersByIndex( index+nbStdCells, numberOfCell )); - ensightGeomFile.addInt( nbNodesInPoly.myValues, numberOfCell ); - } // nbNodesInPoly is deleted here - - // connectivity - ensightGeomFile.addInt( connectivity, connLength ); - } - else // POLYHEDRA connectivity - { - connectivity = mesh->getConnectivity( MED_NODAL, entity, medType); - int nbStdCells = mesh->getGlobalNumberingIndex(entity)[i]-1; - index = mesh->getConnectivityIndex(MED_NODAL, entity) + nbStdCells; - - vector nbFacesInPolyhedron, nbNodesInFace, faceConn; - for ( int j = 0; j < numberOfCell; ++j ) - { - int nbFaces = 0, nbNodes = 0; - for ( int k = index[j]; k < index[j+1]; ++k ) - if ( connectivity[k-1] == -1 ) - { - nbNodesInFace.push_back( nbNodes ); - nbNodes = 0; - ++nbFaces; - } - else - { - faceConn.push_back( connectivity[k-1] ); - ++nbNodes; - } - nbNodesInFace.push_back( nbNodes ); - nbFacesInPolyhedron.push_back( nbFaces+1 ); - } - - // nb of faces in each polyhedron - ensightGeomFile.addInt( nbFacesInPolyhedron ); - // number of nodes in each face - ensightGeomFile.addInt( nbNodesInFace ); - // connectivity - ensightGeomFile.addInt( faceConn ); - } - } - // ------------------------------------------------- - else // support is not on all elements - { - const int *number = support->getNumber(medType); - -#ifdef ELEMENT_ID_GIVEN - ensightGeomFile.addInt( number, numberOfCell ); -#endif - if ( nbCellNodes > 1 ) // STANDARD ELEMENTS connectivity - { - connectivity = mesh->getConnectivity( MED_NODAL, entity, MED_ALL_ELEMENTS); - index = mesh->getConnectivityIndex(MED_NODAL, entity); - - nodeIds.reserve( numberOfCell * nbCellNodes); - for (j=0; jgetConnectivity( MED_NODAL, entity, MED_ALL_ELEMENTS); - index = mesh->getConnectivityIndex(MED_NODAL, entity); - - // number of nodes in each element - { - TIntOwner nbNodesInPoly( getNumbersByIndex( index, numberOfCell, number )); - ensightGeomFile.addInt( nbNodesInPoly.myValues, numberOfCell ); - } // nbNodesInPoly is deleted here - - // connectivity - for ( j = 0; j < numberOfCell; ++j ) - { - int elem = number[ j ]; - elemConnectivity = connectivity + index[ elem-1 ]-1; - const int* connEnd = connectivity + index[ elem ]-1; - while ( elemConnectivity < connEnd ) - nodeIds.push_back( med2ensIds[ *elemConnectivity++ ]); - } - ensightGeomFile.addInt( nodeIds ); - } - else // POLYHEDRA connectivity - { - connectivity = mesh->getConnectivity( MED_NODAL, entity, MED_ALL_ELEMENTS); - index = mesh->getConnectivityIndex(MED_NODAL, entity); - vector nbFacesInPolyhedron, nbNodesInFace, faceConn; - for ( int j = 0; j < numberOfCell; ++j ) - { - int elem = number[ j ]; - int nbFaces = 0, nbNodes = 0; - for ( int k = index[elem]; k < index[elem+1]; ++k ) - if ( connectivity[k-1] == -1 ) - { - nbNodesInFace.push_back( nbNodes ); - nbNodes = 0; - ++nbFaces; - } - else - { - faceConn.push_back( connectivity[k-1] ); - ++nbNodes; - } - nbNodesInFace.push_back( nbNodes ); - nbFacesInPolyhedron.push_back( nbFaces+1 ); - } - - // nb of faces in each polyhedron - ensightGeomFile.addInt( nbFacesInPolyhedron ); - // number of nodes in each face - ensightGeomFile.addInt( nbNodesInFace ); - // connectivity - ensightGeomFile.addInt( faceConn ); - } - } - } - - mesh->removeReference(); - -} // writePartGoldBinary() - -//================================================================================ -/*! - * \brief Write support as an EnSight Gold part - */ -//================================================================================ - -void ENSIGHT_MESH_WRONLY_DRIVER::writePartGoldASCII(ofstream& ensightGeomFile, - const SUPPORT* support) const -{ - const int iw = 10; - - // part number - int partNum = getPartNumber( support ); - ensightGeomFile << "part" << endl - << setw(iw) << partNum << endl; - if ( !partNum ) - throw MED_EXCEPTION ( LOCALIZED( STRING("Internal error: invalid part number"))); - - // group/mesh name - ensightGeomFile << support->getName() << endl; - - // get geom types - medEntityMesh entity = support->getEntity(); - int nbTypes = support->getNumberOfTypes(); - const medGeometryElement* geoType = support->getTypes(); - - const int * connectivity = 0; - const int * elemConnectivity = 0; - const int * index = 0; - int j; - - const MESH* mesh = support->getMesh()->convertInMESH() ; // we write unstructured only - - // COORDINATES Gold ASCII - // =================================================================================== - // In Ensight, coordinates of nodes of support elements are in MED_NO_INTERLACE mode. - // We are to write only nodes belonging to elements of the support and - // nodal connectivity should refer to these nodes. - map med2ensIds; - map::iterator medEnsIt; - int SpaceDimension = mesh->getSpaceDimension() ; - int NumberOfNodes = mesh->getNumberOfNodes() ; - string zeroStr = " 0.00000e+00"; - // ----------------------------------- - if ( support->isOnAllElements() ) - { - // nb of nodes - ensightGeomFile << "coordinates" << endl - << setw(iw) << NumberOfNodes << endl ; - - // coordinates - for (j=0; jgetCoordinates(MED_FULL_INTERLACE) + j; - for (int i=0; igetCoordinates(MED_FULL_INTERLACE) + j; - for (int i=0; ifirst-1) * SpaceDimension] << endl; - } - else { - for (int i=0; isecond = j; - } - - // CONNECTIVITY Gold ASCII - // =================================================================================== - // loop on types - for (int i=0; igetNumberOfElements(medType); - int nbCellNodes = ensightType._medIndex.size(); - - // type name and nb cells - ensightGeomFile << ensightType._name << endl - << setw(iw) << numberOfCell << endl; - - // ----------------------------------- - if ( support->isOnAllElements() ) - { -#ifdef ELEMENT_ID_GIVEN - for ( j = 1; j <= numberOfCell; j++) - ensightGeomFile << setw(iw) << j << endl; -#endif - - if ( nbCellNodes > 1 ) // STANDARD ELEMENTS connectivity - { - connectivity = mesh->getConnectivity( MED_NODAL, entity, medType); - for (j = 0 ; j < numberOfCell; j++, connectivity += nbCellNodes) { - for (int k=0; kgetGlobalNumberingIndex(entity)[i]-1; - connectivity = mesh->getConnectivity( MED_NODAL, entity, MED_ALL_ELEMENTS); - index = mesh->getConnectivityIndex(MED_NODAL, entity) + nbStdCells; - // number of nodes in each element - const int* ind = index; - for (j = 0 ; j < numberOfCell; j++, ++ind) - ensightGeomFile << setw(iw) << ( ind[1] - ind[0] ) << endl; - - // connectivity - for (j = 0; j < numberOfCell; j++, ++index) { - nbCellNodes = index[1] - index[0]; - for (int k=0; kgetGlobalNumberingIndex(entity)[i]-1; - connectivity = mesh->getConnectivity( MED_NODAL, entity, medType); - index = mesh->getConnectivityIndex(MED_NODAL, entity) + nbStdCells; - ostringstream nbNodesInFace, faceConn; - for ( j = 0; j < numberOfCell; ++j ) - { - int nbFaces = 0, nbNodes = 0; - for ( int k = index[j]; k < index[j+1]; ++k ) - if ( connectivity[k-1] == -1 ) - { - faceConn << endl; - nbNodesInFace << setw(iw) << nbNodes << endl; - nbNodes = 0; - ++nbFaces; - } - else - { - faceConn << setw(iw) << connectivity[k-1] ; - ++nbNodes; - } - faceConn << endl; - nbNodesInFace << setw(iw) << nbNodes << endl; - ensightGeomFile << setw(iw) << nbFaces+1 << endl ;// nb of faces in each polyhedron - } - ensightGeomFile << nbNodesInFace.str();// number of nodes in each face - ensightGeomFile << faceConn.str();// connectivity of each face - } - } - // ----------------------------------- - else // support is not on all elements - { - const int *number = support->getNumber(medType); - -#ifdef ELEMENT_ID_GIVEN - for ( j = 0; j < numberOfCell; j++) - ensightGeomFile << setw(iw) << number[j] << endl; -#endif - if ( nbCellNodes > 1 ) // STANDARD ELEMENTS connectivity - { - connectivity = mesh->getConnectivity( MED_NODAL, entity, MED_ALL_ELEMENTS); - index = mesh->getConnectivityIndex(MED_NODAL, entity); - - for (j=0; jgetConnectivity( MED_NODAL, entity, MED_ALL_ELEMENTS); - index = mesh->getConnectivityIndex(MED_NODAL, entity); - // number of nodes in each element - for (j = 0 ; j < numberOfCell; j++) { - int elem = number[j]; - ensightGeomFile << setw(iw) << ( index[elem] - index[elem-1] ) << endl; - } - // connectivity - for ( j = 0; j < numberOfCell; ++j ) { - int elem = number[ j ]; - elemConnectivity = connectivity + index[ elem-1 ]-1; - const int* connEnd = connectivity + index[ elem ]-1; - while ( elemConnectivity < connEnd ) - ensightGeomFile << setw(iw) << med2ensIds[ *elemConnectivity++ ]; - ensightGeomFile << endl; - } - } - else // POLYHEDRA connectivity - { - connectivity = mesh->getConnectivity( MED_NODAL, entity, medType); - index = mesh->getConnectivityIndex(MED_NODAL, entity); - ostringstream nbNodesInFace, faceConn; - for ( j = 0; j < numberOfCell; ++j ) - { - int elem = number[j]; - int nbFaces = 0, nbNodes = 0; - for ( int k = index[elem]; k < index[elem+1]; ++k ) - if ( connectivity[k-1] == -1 ) - { - faceConn << endl; - nbNodesInFace << setw(iw) << nbNodes << endl; - nbNodes = 0; - ++nbFaces; - } - else - { - faceConn << setw(iw) << connectivity[k-1] ; - ++nbNodes; - } - faceConn << endl; - nbNodesInFace << setw(iw) << nbNodes << endl; - ensightGeomFile << setw(iw) << nbFaces+1 << endl ;// nb of faces in each polyhedron - } - ensightGeomFile << nbNodesInFace.str();// number of nodes in each face - ensightGeomFile << faceConn.str();// connectivity of each face - } - } - } - - mesh->removeReference(); - -} // writePartGoldASCII() - -//================================================================================ -/*! - * \brief Write support as an Ensight6 part - */ -//================================================================================ - -void ENSIGHT_MESH_WRONLY_DRIVER::writePart6Binary(_BinaryFileWriter& ensightGeomFile, - const SUPPORT* support) const -{ - // part number - int partNum = getPartNumber( support ); - ensightGeomFile.addString( STRING("part ") << partNum ); - if ( !partNum ) - throw MED_EXCEPTION ( LOCALIZED( STRING("Internal error: invalid part number"))); - - // group/mesh name - ensightGeomFile.addString( support->getName() ); - - // get geom types - medEntityMesh entity = support->getEntity(); - int nbTypes = support->getNumberOfTypes(); - const medGeometryElement* geoType = support->getTypes(); - - const MESH* mesh = support->getMesh()->convertInMESH() ; // we write unstructured only - - int j = 1; - const int * connectivity = 0; - if ( entity != MED_NODE ) - connectivity = mesh->getConnectivity( MED_NODAL, entity, MED_ALL_ELEMENTS); - const int * elemConnectivity = connectivity; - - // CONNECTIVITY Ensight 6 binary - // =================================================================================== - // loop on types - for (int i=0; igetNumberOfElements(medType); - ensightGeomFile.addString( ensightType._name ); - ensightGeomFile.addInt( numberOfCell ); - - vector nodeIds; - // ------------------------------------------------- - if ( support->isOnAllElements() ) - { -#ifdef ELEMENT_ID_GIVEN - nodeIds.resize( numberOfCell ); - for ( j = 1; j <= numberOfCell; j++) - nodeIds[ j-1 ] = j; - ensightGeomFile.addInt( nodeIds ); -#endif - if ( entity == MED_NODE ) { -#if !defined(ELEMENT_ID_GIVEN) - nodeIds.resize( numberOfCell * nbCellNodes); - for ( j = 1; j <= numberOfCell; j++) - nodeIds[ j-1 ] = j; -#endif - } - else { - nodeIds.clear(); - nodeIds.reserve( numberOfCell * nbCellNodes ); - for (j = 0 ; j < numberOfCell; j++, elemConnectivity += nbCellNodes) - for (int k=0; kgetNumber(medType); - -#ifdef ELEMENT_ID_GIVEN - ensightGeomFile.addInt( number, numberOfCell ); -#endif - if ( entity == MED_NODE ) { - ensightGeomFile.addInt( number, numberOfCell ); - } - else { - const int* index = mesh->getConnectivityIndex(MED_NODAL, entity); - - nodeIds.reserve( numberOfCell * nbCellNodes); - for (j=0; jremoveReference(); - - -} // writePart6Binary() - -//================================================================================ -/*! - * \brief Write support as an Ensight6 part - */ -//================================================================================ - -void ENSIGHT_MESH_WRONLY_DRIVER::writePart6ASCII(ofstream& ensightGeomFile, - const SUPPORT* support) const -{ - const int iw = 8; - - // part number - int partNum = getPartNumber( support ); - ensightGeomFile << "part " << partNum << endl; - if ( !partNum ) - throw MED_EXCEPTION ( LOCALIZED( STRING("Internal error: invalid part number"))); - - // group/mesh name - ensightGeomFile << support->getName() << endl; - - // get geom types - medEntityMesh entity = support->getEntity(); - int nbTypes = support->getNumberOfTypes(); - const medGeometryElement* geoType = support->getTypes(); - - const MESH* mesh = support->getMesh()->convertInMESH() ; // we write unstructured only - - int j = 1; - const int * connectivity = 0; - if ( entity != MED_NODE ) - connectivity = mesh->getConnectivity( MED_NODAL,entity, MED_ALL_ELEMENTS); - const int * elemConnectivity = connectivity; - - // CONNECTIVITY Ensight 6 ASCII - // =================================================================================== - // loop on types - for (int i=0; igetNumberOfElements(medType); - ensightGeomFile << ensightType._name << endl - << setw(iw) << numberOfCell << endl; - - // ------------------------------------------------- - if ( support->isOnAllElements() ) - { - if ( entity == MED_NODE ) { - for ( j = 1; j <= numberOfCell; j++) { -#ifdef ELEMENT_ID_GIVEN - ensightGeomFile << setw(iw) << j; -#endif - ensightGeomFile << setw(iw) << j << endl; - } - } - else { - for (j = 1 ; j <= numberOfCell; j++, elemConnectivity += nbCellNodes) { -#ifdef ELEMENT_ID_GIVEN - ensightGeomFile << setw(iw) << elem++; -#endif - for (int k=0; kgetNumber(medType); - if ( entity == MED_NODE ) { - for (j=0; jgetConnectivityIndex(MED_NODAL, entity); - - for (j=0; jremoveReference(); - - -} // writePart6ASCII() - -//================================================================================ -/*! - * \brief Return nb of part to write - */ -//================================================================================ - -int ENSIGHT_MESH_WRONLY_DRIVER::nbPartsToWrite() const -{ - int nbParts = 0; - nbParts += (int) isToWriteEntity( MED_CELL, _ptrMesh ); - nbParts += (int) isToWriteEntity( MED_FACE, _ptrMesh ); - nbParts += (int) isToWriteEntity( MED_EDGE, _ptrMesh ); - - // all groups - for ( int ent = MED_CELL; ent < MED_ALL_ENTITIES; ++ent ) { - int nbGroups = _ptrMesh->getNumberOfGroups(medEntityMesh(ent)); - nbParts += nbGroups; - } - return nbParts; -} - -// ================================================================================ -// RDONLY -// ================================================================================ - -ENSIGHT_MESH_RDONLY_DRIVER::ENSIGHT_MESH_RDONLY_DRIVER() - : ENSIGHT_MESH_DRIVER(), _indexInCaseFile(1) -{ -} - -ENSIGHT_MESH_RDONLY_DRIVER::ENSIGHT_MESH_RDONLY_DRIVER(const string & fileName, - MESH * ptrMesh, - int index) - : ENSIGHT_MESH_DRIVER(fileName,ptrMesh,RDONLY), _indexInCaseFile( index ) -{ -} - -ENSIGHT_MESH_RDONLY_DRIVER::ENSIGHT_MESH_RDONLY_DRIVER(const ENSIGHT_MESH_RDONLY_DRIVER & driver) : ENSIGHT_MESH_DRIVER(driver), _indexInCaseFile( driver._indexInCaseFile ) -{ -} - -ENSIGHT_MESH_RDONLY_DRIVER::~ENSIGHT_MESH_RDONLY_DRIVER() -{ -} - -GENDRIVER * ENSIGHT_MESH_RDONLY_DRIVER::copy() const -{ - return new ENSIGHT_MESH_RDONLY_DRIVER(*this) ; -} - -void ENSIGHT_MESH_RDONLY_DRIVER::write() const throw (MEDEXCEPTION) -{ - throw MEDEXCEPTION("ENSIGHT_MESH_RDONLY_DRIVER::write : Can't write with a RDONLY driver !"); -} - -void ENSIGHT_MESH_RDONLY_DRIVER::merge ( const GENDRIVER& driver ) -{ - _CaseFileDriver_User::merge( driver ); - - const ENSIGHT_MESH_RDONLY_DRIVER* other = - dynamic_cast< const ENSIGHT_MESH_RDONLY_DRIVER* >( &driver ); - if ( other ) { - if ( _indexInCaseFile < other->_indexInCaseFile ) - _indexInCaseFile = other->_indexInCaseFile; - } -} - -//================================================================================ -/*! - * \brief Read mesh in all supported formats - */ -//================================================================================ - -void ENSIGHT_MESH_RDONLY_DRIVER::read() throw (MEDEXCEPTION) -{ - const char * LOC = "ENSIGHT_MESH_RDONLY_DRIVER::read() : " ; - BEGIN_OF_MED(LOC); - - openConst(false); // check if can read case file - - _CaseFileDriver caseFile( getCaseFileName(), this); - caseFile.read(); - caseFile.setDataFileName( _indexInCaseFile, this ); // data from Case File is passed here - - openConst(true); // check if can read data file - - cout << "-> Entering into the geometry file " << getDataFileName() << endl ; - - MESH* mesh = (MESH*) getMesh(); - - _InterMed* imed = new _InterMed(); - imed->_medMesh = mesh; - imed->_isOwnMedMesh = false; - imed->_needSubParts = ( caseFile.getNbVariables() > 0 ); - imed->groupes.reserve(1000); - - // to let field drivers know eventual indices of values - if ( imed->_needSubParts ) - setInterData( imed ); - - if ( isBinaryDataFile( getDataFileName() )) // binary - { - if ( isGoldFormat() ) // Gold - { - readGoldBinary( *imed ); - } - else // EnSight6 - { - read6Binary( *imed ); - } - } - else // ASCII - { - if ( isGoldFormat() ) // Gold - { - readGoldASCII( *imed ); - } - else // EnSight6 - { - read6ASCII( *imed ); - } - } - - if ( _isMadeByMed && !imed->groupes.empty() ) { - mesh->_name = imed->groupes[0].nom; - imed->groupes[0].nom = "SupportOnAll_"; - imed->groupes[0].nom += entNames[MED_CELL]; - } - else { - mesh->_name = theDefaultMeshName; - } - mesh->_spaceDimension = SPACE_DIM; - mesh->_numberOfNodes = imed->points.size() - imed->nbMerged( MED_POINT1 ); - mesh->_coordinate = imed->getCoordinate(); - - //Construction des groupes - imed->getGroups(mesh->_groupCell, - mesh->_groupFace, - mesh->_groupEdge, - mesh->_groupNode, mesh); - - mesh->_connectivity = imed->getConnectivity(); - - mesh->createFamilies(); - - // add attributes to families - set famNames; - for (medEntityMesh entity=MED_CELL; entitygetNumberOfFamilies(entity); - for ( i = 1; i <= nb; ++i ) { - FAMILY* f = const_cast( mesh->getFamily( entity, i )); - f->setNumberOfAttributes( 1 ); - int* attIDs = new int[1]; - attIDs[0] = 1; - f->setAttributesIdentifiers( attIDs ); - int* attVals = new int[1]; - attVals[0] = 1; - f->setAttributesValues( attVals ); - string* attDescr = new string[1]; - attDescr[0] = "med_family"; - f->setAttributesDescriptions( attDescr ); - delete [] attDescr; - if ( f->getName().length() > 31 ) // limit a name length - f->setName( STRING("FAM_") << f->getIdentifier()); - // setAll() for groups - nb = mesh->getNumberOfGroups(entity); - for ( i = 1; i <= nb; ++i ) { - GROUP * g = const_cast( mesh->getGroup( entity, i )); - if (mesh->getNumberOfElements( entity, MED_ALL_ELEMENTS ) == - g->getNumberOfElements( MED_ALL_ELEMENTS )) - { - g->setAll( true ); - g->update(); - } - } - } - } - - if ( !imed->_needSubParts ) - delete imed; - - END_OF_MED(LOC); -} - -//================================================================================ -/*! - * \brief Read mesh in Gold ASCII format - */ -//================================================================================ - -void ENSIGHT_MESH_RDONLY_DRIVER::readGoldASCII(_InterMed & imed) -{ - const char * LOC ="ENSIGHT_MESH_RDONLY_DRIVER::readGoldASCII() : "; - BEGIN_OF_MED(LOC); - - _ASCIIFileReader geoFile( getDataFileName() ); - - if ( isSingleFileMode() ) { - int curTimeStep = 1; - while ( curTimeStep++ < getIndexInDataFile() ) { - while ( !geoFile.isTimeStepEnd()) - geoFile.getLine(); - } - while ( !geoFile.isTimeStepBeginning() ) - geoFile.getLine(); - } - // ---------------------- - // Read mesh description - // ---------------------- - { - string descriptionLine1 = geoFile.getLine(); - string descriptionLine2 = geoFile.getLine(); - - // find out if the file was created by MED driver - int prefixSize = strlen( theDescriptionPrefix ); - _isMadeByMed = ( descriptionLine1.substr(0, prefixSize ) == theDescriptionPrefix ); - - if ( _isMadeByMed ) - descriptionLine1 = descriptionLine1.substr( prefixSize ); - _ptrMesh->setDescription( descriptionLine1 + descriptionLine2 ); - } - - // ---------------------------------------- - // Find out presence of node/elem numbers - // ---------------------------------------- - - // EnSight User Manual (for v8) says: - // You do not have to assign node IDs. If you do, the element connectivities are - // based on the node numbers. If you let EnSight assign the node IDs, the nodes - // are considered to be sequential starting at node 1, and element connectivity is - // done accordingly. If node IDs are set to off, they are numbered internally; - // however, you will not be able to display or query on them. If you have node - // IDs in your data, you can have EnSight ignore them by specifying "node id - // ignore." Using this option may reduce some of the memory taken up by the - // Client and Server, but display and query on the nodes will not be available. - - // read "node|element id " - geoFile.getWord(); geoFile.getWord(); - string nodeIds = geoFile.getWord(); - geoFile.getWord(); geoFile.getWord(); - string elemIds = geoFile.getWord(); - - bool haveNodeIds = ( nodeIds == "given" || nodeIds == "ignore" ); - bool haveElemIds = ( elemIds == "given" || elemIds == "ignore" ); - - // extents: xmin xmax ymin ymax zmin zmax - vector extents; - geoFile.toNextLine(); - if ( strncmp( "extents", geoFile.getCurrentPtr(), 7 ) == 0 ) { - geoFile.skip( /*width =*/ 7, /*nbLines =*/ 1 ); - extents.reserve( 6 ); - while ( extents.size() < extents.capacity() ) - extents.push_back( geoFile.getReal() ); - } - - typedef map::iterator INoeud; - map & points = imed.points; - INoeud firstNode; - - _groupe * partGroupe = 0; - int partNum = 0, nbParts = 0; - - while ( !geoFile.isTimeStepEnd() ) - { - string word, restLine, line = geoFile.getLine(); - TStrTool::split( line, word, restLine ); - - const TEnSightElemType & partType = getEnSightType( word ); - if ( partType._medType != MED_ALL_ELEMENTS ) - { - // Unstructured element type encounters - // -------------------------------------- - int nbElemNodes = partType._medType % 100; - int nbElems = geoFile.getInt(); // ne - bool isGhost = isGhostType( word ); - int nodeShift = points.empty() ? 0 : points.rbegin()->first; - - // read element ids - vector elemIds; - if ( haveElemIds ) { - elemIds.reserve( nbElems ); - while ((int) elemIds.size() < nbElems ) - elemIds.push_back( geoFile.getInt() ); // id_e - } - if ( isGhost ) { // do not store ghost elements (?) - int nbNodes = nbElems * nbElemNodes; - if ( partType._name == "nsided" ) // polygons - { - for ( int i = 0; i < nbElems; ++i ) - nbNodes += geoFile.getInt(); - geoFile.skip( nbNodes * INT_WIDTH_GOLD, /*nbLines = */nbElems ); - } - else if ( partType._name == "nfaced" ) // polyhedrons - { - int nbFaces = 0; - for ( int i = 0; i < nbElems; ++i ) - nbFaces += geoFile.getInt(); - for ( int f = 0; f < nbFaces; ++f ) - nbNodes += geoFile.getInt(); - geoFile.skip( nbNodes * INT_WIDTH_GOLD, /*nbLines = */nbFaces ); - } - else // standard types - { - geoFile.skip( nbNodes, nbElemNodes, INT_WIDTH_GOLD ); - } - continue; - } - - // add a group corresponding to subPart (geoType) - imed.groupes.push_back(_groupe()); - _groupe & groupe = imed.groupes.back(); - groupe.mailles.resize( nbElems ); - - // find out if "coordinates" has already been encountered - _SubPartDesc coordDesc( partNum , "coordinates"); - map< _SubPartDesc, _SubPart >::iterator descPart = - imed._subPartDescribed.find( coordDesc ); - bool haveCoords = ( descPart != imed._subPartDescribed.end() ); - if ( haveCoords ) { - firstNode = descPart->second.myFirstNode; - nodeShift -= descPart->second.myNbNodes; - } - - // read poly element data - bool isPoly = ( !nbElemNodes ); - vector nbElemNodesVec( 1, nbElemNodes); - vector nbElemFaces, nbFaceNodes; - if ( partType._name == "nsided" ) // polygons - { - nbElemNodesVec.resize( nbElems ); - for ( int i = 0; i < nbElems; ++i ) - nbElemNodesVec[ i ] = geoFile.getInt(); // npi - } - else if ( partType._name == "nfaced" ) // polyhedrons - { - nbElemFaces.resize( nbElems ); - nbElemNodesVec.resize( nbElems ); - int totalNbFaces = 0; - for ( int i = 0; i < nbElems; ++i ) - totalNbFaces += ( nbElemFaces[ i ] = geoFile.getInt() ); // nf_ei - - nbFaceNodes.resize( totalNbFaces ); - vector::iterator nbFN = nbFaceNodes.begin(); - for ( int i = 0; i < nbElems; ++i ) { - nbElemNodesVec[ i ] = 0; - for ( int nbFaces = nbElemFaces[ i ]; nbFaces; --nbFaces, ++nbFN ) - nbElemNodesVec[ i ] += ( *nbFN = geoFile.getInt() ); // np(f_ei) - } - } - // iterator returning nbElemNodes for standard elems and - // next value from nbElemNodesVec for poly elements - _ValueIterator nbElemNodesIt( & nbElemNodesVec[0], isPoly ? 1 : 0); - - // iterator returning values form partType._medIndex for standard elems - // and node index (n) for poly elements - int n; - _ValueIterator medIndexIt( isPoly ? &n : &partType._medIndex[0], - isPoly ? 0 : 1); - // read connectivity - _maille ma( partType._medType, nbElemNodes ); - ma.sommets.resize( nbElemNodes ); - INoeud node; - for ( int i = 0; i < nbElems; ++i ) { - _ValueIterator medIndex = medIndexIt; - nbElemNodes = nbElemNodesIt.next(); - if ((int) ma.sommets.size() != nbElemNodes ) - ma.sommets.resize( nbElemNodes ); - for ( n = 0; n < nbElemNodes; ++n ) { - int nodeID = geoFile.getInt(); // nn_ei - if ( haveCoords ) - node = points.find( nodeID + nodeShift ); - else - node = points.insert( make_pair( nodeID + nodeShift, _noeud())).first; - ma.sommets[ medIndex.next() ] = node; - } - if ( haveElemIds ) - ma.setOrdre( elemIds[ i ] ); - groupe.mailles[i] = imed.insert(ma); - } - // store nb nodes in polyhedron faces - if ( !nbFaceNodes.empty() ) { - const int* nbFaceNodesPtr = & nbFaceNodes[0]; - for ( int i = 0; i < nbElems; ++i ) { - vector & nbNodesByFace = imed.polyherdalNbFaceNodes[ &groupe.maille( i ) ]; - nbNodesByFace.assign( nbFaceNodesPtr, nbFaceNodesPtr + nbElemFaces[ i ] ); - nbFaceNodesPtr += nbElemFaces[ i ]; - } - } - // create subPart for "coordinates" - if ( !haveCoords ) { - _SubPart & coordSubPart = imed._subPartDescribed[ coordDesc ]; - coordSubPart.myFirstNode = points.insert( make_pair( 1 + nodeShift, _noeud())).first; - } - // add subPart group to part group - int groupeIndex = imed.groupes.size(); - partGroupe->groupes.push_back( groupeIndex ); - - // create subPart - _SubPart subPart( partNum, partType._name ); - subPart.myNbCells = nbElems; - subPart.myCellGroupIndex = groupeIndex; - imed.addSubPart( subPart ); - } - else if ( word == "coordinates" ) - { - // Local node coordinates of a part - // ------------------------------------ - int nbNodes = geoFile.getInt(); // nn - - // read node ids - vector nodeIds; - if ( haveNodeIds ) { - nodeIds.reserve( nbNodes ); - while ((int) nodeIds.size() < nbNodes ) - nodeIds.push_back( geoFile.getInt() ); // id_n - } - - // find out if "coordinates" has already been add at reading connectivity - _SubPartDesc coordDesc( partNum , "coordinates"); - map< _SubPartDesc, _SubPart >::iterator descPart = - imed._subPartDescribed.find( coordDesc ); - bool haveCoords = ( descPart != imed._subPartDescribed.end() ); - - if ( haveCoords ) { - // check that all nodes have been added - firstNode = descPart->second.myFirstNode; - descPart->second.myNbNodes = nbNodes; - INoeud inoeud = firstNode, inoEnd = points.end(); - int id = inoeud->first, idEnd = id + nbNodes; - for ( ; id < idEnd; ++id ) { - if ( inoeud == inoEnd || inoeud->first > id ) { - INoeud in = points.insert( inoeud, make_pair( id, _noeud() )); - in->second.number = id; - in->second.coord.resize( SPACE_DIM ); - } else { - ++inoeud; - } - } - } - else { - // add nodes - int nodeShift = points.empty() ? 0 : points.rbegin()->first; - for ( int iNode = 1; iNode <= nbNodes; ++iNode ) { - INoeud inoeud = points.insert( points.end(), make_pair( iNode + nodeShift, _noeud())); - inoeud->second.number = inoeud->first; - inoeud->second.coord.resize( SPACE_DIM ); - } - firstNode = points.find( 1 + nodeShift ); - // create "coordinates" subPart - _SubPart & subPart = imed._subPartDescribed[ coordDesc ]; - subPart.myNbNodes = nbNodes; - subPart.myFirstNode = firstNode; - } - - // read coordinates in no interlace mode - INoeud endNode = points.end(); - for ( int j = 0; j < SPACE_DIM; ++j ) { - for ( INoeud in = firstNode; in != endNode; ++in ) { - _noeud & node = in->second; - node.coord[ j ] = geoFile.getReal(); - } - } - } - else if ( word == "part" ) - { - // Another part encounters - // ----------------------- - partNum = geoFile.getInt(); - nbParts++; - geoFile.toNextLine(); - - string partName = geoFile.getLine(); - if ( partName.empty() ) - partName = "Part_" + restLine; - - if (int( imed.groupes.capacity() - imed.groupes.size() ) < theMaxNbTypes ) - imed.groupes.reserve( size_t( 1.5 * imed.groupes.size() )); - imed.groupes.push_back(_groupe()); - partGroupe = & imed.groupes.back(); - partGroupe->nom = partName; - partGroupe->groupes.reserve( theMaxNbTypes ); - } - else if ( word == "block" ) - { - // Structured type - // ------------------ - bool rectilinear = ( restLine.find( "rectilinear" ) != restLine.npos ); - bool uniform = ( restLine.find( "uniform" ) != restLine.npos ); - bool curvilinear = ( !rectilinear && !uniform ); - bool iblanked = ( restLine.find( "iblanked" ) != restLine.npos ); - bool with_ghost = ( restLine.find( "with_ghost" ) != restLine.npos ); - bool range = ( restLine.find( "range" ) != restLine.npos ); - - // dimension - int I = geoFile.getInt(); - int J = geoFile.getInt(); - int K = geoFile.getInt(); - int NumberOfNodes = I*J*K; - if ( !NumberOfNodes ) continue; - - // range - if ( range ) { - vector ijkRange; // imin imax jmin jmax kmin kmax - ijkRange.reserve(6); - while ( ijkRange.size() < 6 ) - ijkRange.push_back( geoFile.getInt() ); - I = ijkRange[1]-ijkRange[0]+1; - J = ijkRange[3]-ijkRange[2]+1; - K = ijkRange[5]-ijkRange[4]+1; - NumberOfNodes = I*J*K; - } - // add nodes - int nodeShift = points.empty() ? 0 : points.rbegin()->first; - for ( int iNode = 1; iNode <= NumberOfNodes; ++iNode ) { - INoeud inoeud = points.insert( points.end(), make_pair( iNode + nodeShift, _noeud())); - _noeud & node = inoeud->second; - node.number = inoeud->first; - node.coord.resize( SPACE_DIM ); - } - INoeud firstNode = points.find( nodeShift + 1 ); - INoeud endNode = points.end(); - - GRID grid; // calculator of unstructured data - grid._iArrayLength = I; - grid._jArrayLength = J; - grid._kArrayLength = K; - grid._spaceDimension = SPACE_DIM; - if ( J < 2 ) { grid._spaceDimension--; grid._jArrayLength = 0; } - if ( K < 2 ) { grid._spaceDimension--; grid._kArrayLength = 0; } - int nbElems = grid.getNumberOfElements(MED_CELL, MED_ALL_ELEMENTS); - - if ( curvilinear ) // read coordinates for all nodes - { - for ( int j = 0; j < SPACE_DIM; ++j ) { - for ( INoeud in = firstNode; in != endNode; ++in ) - in->second.coord[ j ] = geoFile.getReal(); - } - grid._gridType = MED_BODY_FITTED; - grid._coordinate = new COORDINATE(3, 1, 0); // to avoid exception in convertInMESH() - } - else if ( rectilinear ) // read delta vectors with non-regular spacing - { - grid._iArray = (double*)geoFile.convertReals( I ); - grid._jArray = (double*)geoFile.convertReals( J ); - grid._kArray = (double*)geoFile.convertReals( K ); - grid._gridType = MED_CARTESIAN; - } - else // uniform: read grid origine and delta vectors for regular spacing grid - { - TDblOwner xyzOrigin( (double*)geoFile.convertReals( 3 )); - TDblOwner xyzDelta ( (double*)geoFile.convertReals( 3 )); - // compute full delta vectors - grid._iArray = new double[ I ]; - grid._jArray = new double[ J ]; - grid._kArray = new double[ K ]; - double* coors[SPACE_DIM] = { grid._iArray, grid._jArray, grid._kArray }; - int size [SPACE_DIM] = { I, J, K }; - for ( int j = 0; j < SPACE_DIM; ++j ) { - double* coo = coors[ j ]; - double* cooEnd = coo + size[ j ]; - coo[0] = xyzOrigin[ j ]; - while ( ++coo < cooEnd ) - *coo = coo[-1] + xyzDelta[ j ]; - } - grid._gridType = MED_CARTESIAN; - } - - // iblanks - if ( iblanked ) - geoFile.skip( NumberOfNodes, /*nbPerLine =*/ 1, INT_WIDTH_GOLD); - // ghosts - if ( with_ghost ) { - geoFile.getWord(); // "ghost_flags" - geoFile.skip( nbElems, /*nbPerLine =*/ 1, INT_WIDTH_GOLD); - } - // node ids - if ( haveNodeIds && geoFile.lookAt( "node_ids" )) { - geoFile.getWord(); // "node_ids" - geoFile.skip( NumberOfNodes, /*nbPerLine =*/ 1, INT_WIDTH_GOLD); - } - // element ids - if ( haveElemIds && geoFile.lookAt( "element_ids" ) ) { - geoFile.getWord(); // "element_ids" - geoFile.skip( nbElems, /*nbPerLine =*/ 1, INT_WIDTH_GOLD); - } - - // let GRID compute all coordinates and connectivity - const MESH* unstruct = grid.convertInMESH(); - if ( !curvilinear ) - { - const double * coo = unstruct->getCoordinates(MED_FULL_INTERLACE); - typedef _ValueIterator< double > TCoordIt; - TCoordIt xCoo( coo+0, grid._spaceDimension); - TCoordIt yCoo( coo+1, grid._spaceDimension); - TCoordIt zCoo( coo+2, grid._spaceDimension); - if ( grid._spaceDimension < 3 ) zCoo = TCoordIt( grid._kArray, 0 ); - if ( grid._spaceDimension < 2 ) yCoo = TCoordIt( grid._jArray, 0 ); - for ( INoeud in = firstNode; in != endNode; ++in ) { - _noeud& node = in->second; - node.coord[ 0 ] = xCoo.next(); - node.coord[ 1 ] = yCoo.next(); - node.coord[ 2 ] = zCoo.next(); - } - } - - // store connectivity - const int * conn = unstruct->getConnectivity( MED_NODAL, MED_CELL, MED_ALL_ELEMENTS ); - medGeometryElement elemType = grid.getElementType( MED_CELL, 1 ); - int nbElemNodes = elemType % 100; - - partGroupe->mailles.resize( nbElems ); - _maille ma( elemType, nbElemNodes ); - ma.sommets.resize( nbElemNodes ); - - for ( int i = 0, nIndex = 0; i < nbElems; ++i ) { - for ( int n = 0; n < nbElemNodes; ++n ) { - int nodeID = conn[ nIndex++ ]; - ma.sommets[n] = points.find( nodeID + nodeShift ); - } - //ma.ordre = ++order; - partGroupe->mailles[i] = imed.insert(ma); - } - _SubPart subPart( partNum, "block" ); - subPart.myNbCells = nbElems; - subPart.myNbNodes = NumberOfNodes; - subPart.myFirstNode = firstNode; - subPart.myCellGroupIndex = imed.groupes.size(); - imed.addSubPart( subPart ); - - unstruct->removeReference(); - } - else - { - throw MEDEXCEPTION - ( LOCALIZED( STRING(LOC) << "Unexpected word: " << word << - " in " << getDataFileName())); - } - } // while ( !geoFile.eof() ) - - if ( nbParts > 1 ) - imed.mergeNodesAndElements(TOLERANCE); - - END_OF_MED(LOC); -} - -//================================================================================ -/*! - * \brief Read mesh in Gold Binary format - */ -//================================================================================ - -void ENSIGHT_MESH_RDONLY_DRIVER::readGoldBinary(_InterMed & imed) -{ - const char * LOC ="ENSIGHT_MESH_RDONLY_DRIVER::readGoldBinary() : "; - BEGIN_OF_MED(LOC); - - _BinaryFileReader geoFile( getDataFileName() ); - - // check if swapping bytes needed - try { - countPartsBinary( geoFile, isSingleFileMode()); - } - catch (...) { - geoFile.swapBytes(); - geoFile.rewind(); - } - if ( getIndexInDataFile() <= 1 ) - geoFile.rewind(); - if ( geoFile.getPosition() == 0 ) { - TStrOwner format( geoFile.getLine() ); // "C|Fortran Binary" - if ( !contains( "C Binary", format )) { - if ( contains( "Fortran Binary", format )) - throw(MEDEXCEPTION(STRING(LOC) << "Fortran Binary format not supported")); - else - throw(MEDEXCEPTION(STRING(LOC) << "unexpected line in " << getDataFileName() - << "\n" << format.myValues)); - } - } - if ( isSingleFileMode() ) { - // one time step may be skipped by countPartsBinary - int curTimeStep = geoFile.getPosition() ? 2 : 1 ; - while ( curTimeStep < getIndexInDataFile() ) { - countPartsBinary( geoFile, true ); // skip time step - curTimeStep++; - } - while (1) { - TStrOwner line( geoFile.getLine() ); - if ( isTimeStepBeginning( line.myValues )) - break; - } - } - // ---------------------- - // Read mesh description - // ---------------------- - { - TStrOwner descriptionLine1 ( geoFile.getLine() ); - TStrOwner descriptionLine2 ( geoFile.getLine() ); - - // find out if the file was created by MED driver - _isMadeByMed = contains( theDescriptionPrefix, descriptionLine1 ); - - if ( _isMadeByMed ) - _ptrMesh->setDescription( descriptionLine2.myValues ); - else - _ptrMesh->setDescription( string(descriptionLine1) + descriptionLine2.myValues ); - } - - // ---------------------------------------- - // Find out presence of node/elem numbers - // ---------------------------------------- - - // EnSight User Manual (for v8) says: - // You do not have to assign node IDs. If you do, the element connectivities are - // based on the node numbers. If you let EnSight assign the node IDs, the nodes - // are considered to be sequential starting at node 1, and element connectivity is - // done accordingly. If node IDs are set to off, they are numbered internally; - // however, you will not be able to display or query on them. If you have node - // IDs in your data, you can have EnSight ignore them by specifying "node id - // ignore." Using this option may reduce some of the memory taken up by the - // Client and Server, but display and query on the nodes will not be available. - - // read "node|element id " - bool haveNodeIds, haveElemIds; - { - TStrOwner nodeIds( geoFile.getLine() ); - TStrOwner elemIds( geoFile.getLine() ); - - haveNodeIds = ( contains( "given", nodeIds ) || contains( "ignore", nodeIds ) ); - haveElemIds = ( contains( "given", elemIds ) || contains( "ignore", elemIds ) ); - } - - typedef map::iterator INoeud; - map & points = imed.points; - INoeud firstNode; - - _groupe * partGroupe = 0; - int partNum = 0, nbParts = 0; - - TFltOwner extents(0); // extents: xmin xmax ymin ymax zmin zmax - - while ( !geoFile.eof() ) - { - TStrOwner line( geoFile.getLine() ); - if ( isSingleFileMode() && isTimeStepEnd( line.myValues )) - break; - string word, restLine; - TStrTool::split( line.myValues, word, restLine ); - - const TEnSightElemType & partType = getEnSightType( word ); - if ( partType._medType != MED_ALL_ELEMENTS ) - { - // Unstructured element type encounters - // -------------------------------------- - int nbElems = *TIntOwner( geoFile.getInt(1) ); // ne - int nbElemNodes = partType._medType % 100; - bool isGhost = isGhostType( word ); - int nodeShift = points.empty() ? 0 : points.rbegin()->first; - - // read element ids - TIntOwner elemIds( haveElemIds ? geoFile.getInt( nbElems ): 0 ); // id_e - - if ( isGhost ) { // do not store ghost elements (?) - int nbNodes = nbElems * nbElemNodes; - if ( partType._name == "nsided" ) // polygons - { - TIntOwner nbNodesInFace( geoFile.getInt( nbElems )); - nbNodes = std::accumulate( nbNodesInFace.myValues, nbNodesInFace.myValues + nbElems, 0 ); - } - else if ( partType._name == "nfaced" ) // polyhedrons - { - TIntOwner nbElemFaces( geoFile.getInt( nbElems )); - int nbFaces = accumulate( nbElemFaces.myValues, nbElemFaces.myValues + nbElems, 0 ); - TIntOwner nbNodesInFace( geoFile.getInt( nbFaces )); - nbNodes = std::accumulate( nbNodesInFace.myValues, nbNodesInFace.myValues + nbElems, 0 ); - } - geoFile.skip( nbNodes * sizeof(int) ); - continue; - } - - // add a group corresponding to subPart (geoType) - imed.groupes.push_back(_groupe()); - _groupe & groupe = imed.groupes.back(); - groupe.mailles.resize( nbElems ); - - // find out if "coordinates" has already been encountered - _SubPartDesc coordDesc( partNum , "coordinates"); - map< _SubPartDesc, _SubPart >::iterator descPart = - imed._subPartDescribed.find( coordDesc ); - bool haveCoords = ( descPart != imed._subPartDescribed.end() ); - if ( haveCoords ) { - firstNode = descPart->second.myFirstNode; - nodeShift -= descPart->second.myNbNodes; - } - - // read poly element data - bool isPoly = ( !nbElemNodes ); - int nbNodes = 0; - TIntOwner nbElemNodesVec(0), nbElemFaces(0), nbFaceNodes(0); - if ( partType._name == "nsided" ) // polygons - { - nbElemNodesVec.myValues = geoFile.getInt( nbElems ); // npi - nbNodes = accumulate( nbElemNodesVec.myValues, nbElemNodesVec.myValues + nbElems, 0 ); - } - else if ( partType._name == "nfaced" ) // polyhedrons - { - nbElemFaces.myValues = geoFile.getInt( nbElems ); // nf_ei - int totalNbFaces = accumulate( nbElemFaces.myValues, nbElemFaces.myValues + nbElems, 0 ); - - nbFaceNodes.myValues = geoFile.getInt( totalNbFaces ); // np(f_ei) - // calculate nb of nodes in each polyhedron - int* nbEN = nbElemNodesVec.myValues = new int[ nbElems ]; - const int *nbFN = nbFaceNodes, *nbEF = nbElemFaces, *nbEND = nbEN + nbElems; - for ( ; nbEN < nbEND; ++nbEN, ++nbEF ) { - nbNodes += *nbEN = accumulate( nbFN, nbFN + *nbEF, 0 ); - nbFN += *nbEF; - } - } - else // standard types - { - nbElemNodesVec.myValues = new int[ 1 ]; - nbElemNodesVec[ 0 ] = nbElemNodes; - nbNodes = nbElems * nbElemNodes; - } - // iterator returning nbElemNodes for standard elems and - // next value from nbElemNodesVec for poly elements - _ValueIterator nbElemNodesIt( nbElemNodesVec, isPoly ? 1 : 0); - - // iterator returning values form partType._medIndex for standard elems - // and node index (n) for poly elements - int n; - _ValueIterator medIndexIt( isPoly ? &n : &partType._medIndex[0], - isPoly ? 0 : 1); - // read connectivity - _maille ma( partType._medType, nbElemNodes ); - ma.sommets.resize( nbElemNodes ); - TIntOwner connectivity( geoFile.getInt( nbNodes )); // nn_ei - int* nodeID = connectivity; - INoeud node; - for ( int i = 0; i < nbElems; ++i ) { - _ValueIterator medIndex = medIndexIt; - nbElemNodes = nbElemNodesIt.next(); - if ((int) ma.sommets.size() != nbElemNodes ) - ma.sommets.resize( nbElemNodes ); - for ( n = 0; n < nbElemNodes; ++n, ++nodeID ) { - if ( haveCoords ) - node = points.find( *nodeID + nodeShift ); - else - node = points.insert( make_pair( *nodeID + nodeShift, _noeud())).first; - ma.sommets[ medIndex.next() ] = node; - } - if ( haveElemIds ) - ma.setOrdre( elemIds[ i ] ); - groupe.mailles[i] = imed.insert(ma); - } - // store nb nodes in polyhedron faces - if ( nbFaceNodes.myValues ) { - const int* nbFaceNodesPtr = nbFaceNodes.myValues; - for ( int i = 0; i < nbElems; ++i ) { - vector & nbNodesByFace = imed.polyherdalNbFaceNodes[ &groupe.maille( i ) ]; - nbNodesByFace.assign( nbFaceNodesPtr, nbFaceNodesPtr + nbElemFaces[ i ] ); - nbFaceNodesPtr += nbElemFaces[ i ]; - } - } - // create subPart for "coordinates" - if ( !haveCoords ) { - _SubPart & coordSubPart = imed._subPartDescribed[ coordDesc ]; - coordSubPart.myFirstNode = points.insert( make_pair( 1 + nodeShift, _noeud())).first; - } - // add subPart group to part group - int groupeIndex = imed.groupes.size(); - partGroupe->groupes.push_back( groupeIndex ); - - // create subPart - _SubPart subPart( partNum, partType._name ); - subPart.myNbCells = nbElems; - subPart.myCellGroupIndex = groupeIndex; - imed.addSubPart( subPart ); - } - else if ( word == "coordinates" ) - { - // Local node coordinates of a part - // ------------------------------------ - int nbNodes = *TIntOwner( geoFile.getInt(1) ); // nn - - // read node ids - TIntOwner nodeIds(0); - if ( haveNodeIds ) - nodeIds.myValues = geoFile.getInt( nbNodes ); // id_n - - // find out if "coordinates" has already been add at reading connectivity - _SubPartDesc coordDesc( partNum , "coordinates"); - map< _SubPartDesc, _SubPart >::iterator descPart = - imed._subPartDescribed.find( coordDesc ); - bool haveCoords = ( descPart != imed._subPartDescribed.end() ); - - if ( haveCoords ) { - // check that all nodes have been added - firstNode = descPart->second.myFirstNode; - descPart->second.myNbNodes = nbNodes; - INoeud inoeud = firstNode, inoEnd = points.end(); - int id = inoeud->first, idEnd = id + nbNodes; - for ( ; id < idEnd; ++id ) { - if ( inoeud == inoEnd || inoeud->first > id ) { - INoeud in = points.insert( inoeud, make_pair( id, _noeud() )); - in->second.number = id; - } else { - ++inoeud; - } - } - } - else { - // add nodes - int nodeShift = points.empty() ? 0 : points.rbegin()->first; - for ( int iNode = 1; iNode <= nbNodes; ++iNode ) { - INoeud inoeud = points.insert( points.end(), make_pair( iNode + nodeShift, _noeud())); - inoeud->second.number = inoeud->first; - } - firstNode = points.find( 1 + nodeShift ); - // create "coordinates" subPart - _SubPart & subPart = imed._subPartDescribed[ coordDesc ]; - subPart.myNbNodes = nbNodes; - subPart.myFirstNode = firstNode; - } - - // read coordinates in no interlace mode - TFltOwner noInterlaceCoords( geoFile.getFlt( nbNodes * SPACE_DIM )); - float* x = noInterlaceCoords; - float* y = x + nbNodes; - float* z = y + nbNodes; - INoeud endNode = points.end(); - for ( INoeud in = firstNode; in != endNode; ++in ) { - _noeud & node = in->second; - node.coord.resize( SPACE_DIM ); - node.coord[ 0 ] = *x++; - node.coord[ 1 ] = *y++; - node.coord[ 2 ] = *z++; - } - } - else if ( word == "part" ) - { - // Another part encounters - // ----------------------- - partNum = *TIntOwner( geoFile.getInt(1) ); - nbParts++; - - string partName( TStrOwner( geoFile.getLine() )); - if ( partName.empty() ) - partName = "Part_" + restLine; - - if (int( imed.groupes.capacity() - imed.groupes.size()) < theMaxNbTypes ) - imed.groupes.reserve( size_t( 1.5 * imed.groupes.size() )); - imed.groupes.push_back(_groupe()); - partGroupe = & imed.groupes.back(); - partGroupe->nom = partName; - partGroupe->groupes.reserve( theMaxNbTypes ); - } - else if ( word == "block" ) - { - // Structured type - // ------------------ - bool rectilinear = ( restLine.find( "rectilinear" ) != restLine.npos ); - bool uniform = ( restLine.find( "uniform" ) != restLine.npos ); - bool curvilinear = ( !rectilinear && !uniform ); - bool iblanked = ( restLine.find( "iblanked" ) != restLine.npos ); - bool with_ghost = ( restLine.find( "with_ghost" ) != restLine.npos ); - bool range = ( restLine.find( "range" ) != restLine.npos ); - - // dimension - TIntOwner ijk( geoFile.getInt(3) ); - int I = ijk[0]; - int J = ijk[1]; - int K = ijk[2]; - int NumberOfNodes = I*J*K; - if ( !NumberOfNodes ) continue; - - // range - if ( range ) { - TIntOwner ijkRange( geoFile.getInt( 6 ));// imin imax jmin jmax kmin kmax - I = ijkRange[1]-ijkRange[0]+1; - J = ijkRange[3]-ijkRange[2]+1; - K = ijkRange[5]-ijkRange[4]+1; - NumberOfNodes = I*J*K; - } - // add nodes - int nodeShift = points.empty() ? 0 : points.rbegin()->first; - for ( int iNode = 1; iNode <= NumberOfNodes; ++iNode ) { - INoeud inoeud = points.insert( points.end(), make_pair( iNode + nodeShift, _noeud())); - _noeud & node = inoeud->second; - node.number = inoeud->first; - node.coord.resize( SPACE_DIM ); - } - INoeud firstNode = points.find( nodeShift + 1 ); - INoeud endNode = points.end(); - - GRID grid; // calculator of unstructured data - grid._iArrayLength = I; - grid._jArrayLength = J; - grid._kArrayLength = K; - grid._spaceDimension = SPACE_DIM; - if ( J < 2 ) { grid._spaceDimension--; grid._jArrayLength = 0; } - if ( K < 2 ) { grid._spaceDimension--; grid._kArrayLength = 0; } - int nbElems = grid.getNumberOfElements(MED_CELL, MED_ALL_ELEMENTS); - - if ( curvilinear ) // read coordinates for all nodes - { - TFltOwner noInterlaceCoords( geoFile.getFlt( NumberOfNodes * SPACE_DIM )); - float* x = noInterlaceCoords; - float* y = x + NumberOfNodes; - float* z = y + NumberOfNodes; - for ( INoeud in = firstNode; in != endNode; ++in ) { - _noeud & node = in->second; - node.coord.resize( SPACE_DIM ); - node.coord[ 0 ] = *x++; - node.coord[ 1 ] = *y++; - node.coord[ 2 ] = *z++; - } - grid._gridType = MED_BODY_FITTED; - grid._coordinate = new COORDINATE(3, 1, 0); // to avoid exception in convertInMESH() - } - else if ( rectilinear ) // read delta vectors with non-regular spacing - { - grid._iArray = (double*)geoFile.convertReals( I ); - grid._jArray = (double*)geoFile.convertReals( J ); - grid._kArray = (double*)geoFile.convertReals( K ); - grid._gridType = MED_CARTESIAN; - } - else // uniform: read grid origine and delta vectors for regular spacing grid - { - TFltOwner xyzOrigin( geoFile.getFlt( 3 )); - TFltOwner xyzDelta ( geoFile.getFlt( 3 )); - // compute full delta vectors - grid._iArray = new double[ I ]; - grid._jArray = new double[ J ]; - grid._kArray = new double[ K ]; - double* coors[SPACE_DIM] = { grid._iArray, grid._jArray, grid._kArray }; - int size [SPACE_DIM] = { I, J, K }; - for ( int j = 0; j < SPACE_DIM; ++j ) { - double* coo = coors[ j ]; - double* cooEnd = coo + size[ j ]; - coo[0] = xyzOrigin[ j ]; - while ( ++coo < cooEnd ) - *coo = coo[-1] + xyzDelta[ j ]; - } - grid._gridType = MED_CARTESIAN; - } - - // iblanks - if ( iblanked ) - geoFile.skip( NumberOfNodes * sizeof(int) ); - // ghosts - if ( with_ghost ) { - TStrOwner( geoFile.getLine() ); // "ghost_flags" - geoFile.skip( nbElems * sizeof(int) ); - } - // node ids - if ( haveNodeIds && !geoFile.eof() ) { - TStrOwner nextLine( geoFile.getLine() ); // "node_ids" - if ( contains( "node_ids", nextLine ) ) - geoFile.skip( NumberOfNodes * sizeof(int) ); - else - geoFile.skip( -MAX_LINE_LENGTH ); - } - // element ids - TIntOwner elemIdOwner(0); - _ValueIterator elemIds; - if ( haveElemIds && !geoFile.eof() ) { - TStrOwner nextLine( geoFile.getLine() ); // "element_ids" - if ( contains( "element_ids", nextLine ) ) { - elemIdOwner.myValues = geoFile.getInt( nbElems ); - elemIds = _ValueIterator( elemIdOwner, 1); - } else { - geoFile.skip( -MAX_LINE_LENGTH ); - } - } - - // let GRID compute all coordinates and connectivity - const MESH* unstruct = grid.convertInMESH(); - if ( !curvilinear ) - { - const double * coo = unstruct->getCoordinates(MED_FULL_INTERLACE); - typedef _ValueIterator< double > TCoordIt; - TCoordIt xCoo( coo+0, grid._spaceDimension); - TCoordIt yCoo( coo+1, grid._spaceDimension); - TCoordIt zCoo( coo+2, grid._spaceDimension); - if ( grid._spaceDimension < 3 ) zCoo = TCoordIt( grid._kArray, 0 ); - if ( grid._spaceDimension < 2 ) yCoo = TCoordIt( grid._jArray, 0 ); - for ( INoeud in = firstNode; in != endNode; ++in ) { - _noeud& node = in->second; - node.coord[ 0 ] = xCoo.next(); - node.coord[ 1 ] = yCoo.next(); - node.coord[ 2 ] = zCoo.next(); - } - } - - // store connectivity - const int * conn = unstruct->getConnectivity( MED_NODAL, MED_CELL, MED_ALL_ELEMENTS ); - medGeometryElement elemType = grid.getElementType( MED_CELL, 1 ); - int nbElemNodes = elemType % 100; - - partGroupe->mailles.resize( nbElems ); - _maille ma( elemType, nbElemNodes ); - ma.sommets.resize( nbElemNodes ); - - for ( int i = 0, nIndex = 0; i < nbElems; ++i ) { - for ( int n = 0; n < nbElemNodes; ++n ) { - int nodeID = conn[ nIndex++ ]; - ma.sommets[n] = points.find( nodeID + nodeShift ); - } - ma.setOrdre( elemIds.next() ); - partGroupe->mailles[i] = imed.insert(ma); - } - - _SubPart subPart( partNum, "block" ); - subPart.myNbCells = nbElems; - subPart.myNbNodes = NumberOfNodes; - subPart.myFirstNode = firstNode; - subPart.myCellGroupIndex = imed.groupes.size(); - imed.addSubPart( subPart ); - - unstruct->removeReference(); - } - else if ( word == "extents" ) - { - extents.myValues = geoFile.getFlt( 6 ); - } - else - { - throw MED_EXCEPTION - ( LOCALIZED( STRING(LOC) << "Unexpected word: " << word << - " in " << getDataFileName())); - } - } // while ( !geoFile.eof() ) - - if ( nbParts > 1 ) - imed.mergeNodesAndElements(TOLERANCE); - - END_OF_MED(LOC); -} - -//================================================================================ -/*! - * \brief Read mesh in Ensight6 ASCII format - */ -//================================================================================ - -void ENSIGHT_MESH_RDONLY_DRIVER::read6ASCII(_InterMed & imed) -{ - const char * LOC ="ENSIGHT_MESH_RDONLY_DRIVER::read6ASCII() : "; - BEGIN_OF_MED(LOC); - - _ASCIIFileReader geoFile( getDataFileName() ); - - if ( isSingleFileMode() ) { - int curTimeStep = 1; - while ( curTimeStep < getIndexInDataFile() ) { - while ( !geoFile.isTimeStepEnd()) - geoFile.getLine(); - curTimeStep++; - } - while ( !geoFile.isTimeStepBeginning() ) - geoFile.getLine(); - } - // ---------------------- - // Read mesh description - // ---------------------- - { - string descriptionLine1 = geoFile.getLine(); - string descriptionLine2 = geoFile.getLine(); - - // find out if the file was created by MED driver - int prefixSize = strlen( theDescriptionPrefix ); - _isMadeByMed = ( descriptionLine1.substr(0, prefixSize ) == theDescriptionPrefix ); - - if ( _isMadeByMed ) - descriptionLine1 = descriptionLine1.substr( prefixSize ); - _ptrMesh->setDescription( descriptionLine1 + descriptionLine2 ); - } - - // ---------------------------------------- - // Find out presence of node/elem numbers - // ---------------------------------------- - - // EnSight User Manual (for v8) says: - // You do not have to assign node IDs. If you do, the element connectivities are - // based on the node numbers. If you let EnSight assign the node IDs, the nodes - // are considered to be sequential starting at node 1, and element connectivity is - // done accordingly. If node IDs are set to off, they are numbered internally; - // however, you will not be able to display or query on them. If you have node - // IDs in your data, you can have EnSight ignore them by specifying "node id - // ignore." Using this option may reduce some of the memory taken up by the - // Client and Server, but display and query on the nodes will not be available. - - // read "node|element id " - geoFile.getWord(); geoFile.getWord(); - string nodeIds = geoFile.getWord(); - geoFile.getWord(); geoFile.getWord(); - string elemIds = geoFile.getWord(); - - bool haveNodeIds = ( nodeIds == "given" || nodeIds == "ignore" ); - bool haveElemIds = ( elemIds == "given" || elemIds == "ignore" ); - - map & points = imed.points; - typedef map::iterator INoeud; - - int haveStructuredParts = 0, haveUnstructuredParts = 0; - - _groupe * partGroupe = 0; - int partNum = 0; - - while ( !geoFile.isTimeStepEnd() ) - { - string word, restLine, line = geoFile.getLine(); - TStrTool::split( line, word, restLine ); - - const TEnSightElemType & partType = getEnSightType( word ); - if ( !partType._medIndex.empty() ) - { - // Unstructured element type encounters - // -------------------------------------- - int nbElemNodes = partType._medType % 100; - int nbElems = geoFile.getInt(); - if ( nbElems > 0 ) - haveUnstructuredParts++; - - imed.groupes.push_back(_groupe()); - _groupe & groupe = imed.groupes.back(); - groupe.mailles.resize( nbElems ); - - // read connectivity - _maille ma( partType._medType, nbElemNodes ); - ma.sommets.resize( nbElemNodes ); - INoeud node; - for ( int i = 0; i < nbElems; ++i ) { - if ( haveElemIds ) - geoFile.getInt(); - for ( int n = 0; n < nbElemNodes; ++n ) { - int nodeID = geoFile.getInt(); - ma.sommets[ partType._medIndex[n] ] = points.find( nodeID ); - } - //ma.ordre = ++order; - groupe.mailles[i] = imed.insert(ma); - } - - int groupeIndex = imed.groupes.size(); - partGroupe->groupes.push_back( groupeIndex ); - - _SubPart subPart( partNum, partType._name ); - subPart.myNbCells = nbElems; - subPart.myCellGroupIndex = groupeIndex; - imed.addSubPart( subPart ); - } - else if ( word == "part" ) - { - // Another part encounters - // ----------------------- - partNum = atoi( restLine.c_str() ); - - string partName = geoFile.getLine(); - if ( partName.empty() ) - partName = "Part_" + restLine; - - if (int( imed.groupes.capacity() - imed.groupes.size()) < theMaxNbTypes ) - imed.groupes.reserve( size_t( 1.5 * imed.groupes.size() )); - imed.groupes.push_back(_groupe()); - partGroupe = & imed.groupes.back(); - partGroupe->nom = partName; - partGroupe->groupes.reserve( theMaxNbTypes ); - } - else if ( word == "block" ) - { - // Structured type - // ------------------ - bool iblanked = ( restLine == "iblanked" ); - - // dimension - int I = geoFile.getInt(); - int J = geoFile.getInt(); - int K = geoFile.getInt(); - int NumberOfNodes = I*J*K; - if ( !NumberOfNodes ) continue; - haveStructuredParts++; - - // add nodes - int nodeShift = points.empty() ? 0 : points.rbegin()->first; - for ( int iNode = 1; iNode <= NumberOfNodes; ++iNode ) { - INoeud inoeud = points.insert( points.end(), make_pair( iNode + nodeShift, _noeud())); - _noeud & node = inoeud->second; - node.number = inoeud->first; - node.coord.resize( SPACE_DIM ); - } - // read coordinates - INoeud firstNode = points.find( nodeShift + 1 ); - INoeud endNode = points.end(); - for ( int j = 0; j < SPACE_DIM; ++j ) { - for ( INoeud in = firstNode; in != endNode; ++in ) { - _noeud & node = in->second; - node.coord[ j ] = geoFile.getReal(); - } - } - // iblanks - if ( iblanked ) - geoFile.skip(NumberOfNodes, /*nbPerLine =*/ 10, INT_WIDTH_6); - - // let GRID calculate connectivity - GRID grid; - grid._iArrayLength = I; - grid._jArrayLength = J; - grid._kArrayLength = K; - grid._gridType = MED_BODY_FITTED; - grid._spaceDimension= SPACE_DIM; - grid._coordinate = new COORDINATE(3, 1, 0); // to avoid exception in convertInMESH() - if ( J < 2 ) { grid._spaceDimension--; grid._jArrayLength = 0; } - if ( K < 2 ) { grid._spaceDimension--; grid._kArrayLength = 0; } - - const MESH* unstruct = grid.convertInMESH(); - const int * conn = unstruct->getConnectivity( MED_NODAL, MED_CELL, MED_ALL_ELEMENTS ); - medGeometryElement elemType = grid.getElementType( MED_CELL, 1 ); - int nbElemNodes = elemType % 100; - int nbElems = grid.getNumberOfElements(MED_CELL, MED_ALL_ELEMENTS); - - partGroupe->mailles.resize( nbElems ); - _maille ma( elemType, nbElemNodes ); - ma.sommets.resize( nbElemNodes ); - - for ( int i = 0, nIndex = 0; i < nbElems; ++i ) { - for ( int n = 0; n < nbElemNodes; ++n ) { - int nodeID = conn[ nIndex++ ]; - ma.sommets[n] = points.find( nodeID + nodeShift ); - } - //ma.ordre = ++order; - partGroupe->mailles[i] = imed.insert(ma); - } - - _SubPart subPart( partNum, "block" ); - subPart.myNbCells = nbElems; - subPart.myNbNodes = NumberOfNodes; - subPart.myFirstNode = firstNode; - subPart.myCellGroupIndex = imed.groupes.size(); - imed.addSubPart( subPart ); - - unstruct->removeReference(); - } - else if ( word == "coordinates" ) - { - // ------------------------------------ - // Unstructured global node coordinates - // ------------------------------------ - int nbNodes = geoFile.getInt(); - - cout << "-> loading coordinates of " << nbNodes << " nodes " << endl ; - - INoeud inoeud; - for ( int i=0 ; i < nbNodes ; i++ ) - { - if ( haveNodeIds ) { - int nodeID = geoFile.getInt(); - inoeud = points.insert( make_pair( nodeID, _noeud() )).first; - inoeud->second.number = nodeID; - } - else { - int nodeID = i + 1; - inoeud = points.insert( points.end(), make_pair( nodeID, _noeud())); - inoeud->second.number = nodeID; - } - _noeud & node = inoeud->second; - node.coord.resize( SPACE_DIM ); - node.coord[ 0 ] = geoFile.getReal(); - node.coord[ 1 ] = geoFile.getReal(); - node.coord[ 2 ] = geoFile.getReal(); - } - - _SubPartDesc cooDesc = _SubPartDesc::globalCoordDesc(); - _SubPart subPart( cooDesc.partNumber(), cooDesc.typeName() ); - subPart.myNbNodes = nbNodes; - subPart.myFirstNode = points.begin(); - imed.addSubPart( subPart ); - } - else - { - throw MED_EXCEPTION - ( LOCALIZED( STRING(LOC) << "Unexpected word: " << word << - " in " << getDataFileName())); - } - } // while ( !geoFile.eof() ) - - if ( ( haveStructuredParts && haveUnstructuredParts ) || haveStructuredParts > 1 ) - imed.mergeNodesAndElements(TOLERANCE); - - END_OF_MED(LOC); -} - -//================================================================================ -/*! - * \brief Read mesh in Ensight6 ASCII format - */ -//================================================================================ - -void ENSIGHT_MESH_RDONLY_DRIVER::read6Binary(_InterMed & imed) -{ - const char * LOC ="ENSIGHT_MESH_RDONLY_DRIVER::read6Binary() : "; - BEGIN_OF_MED(LOC); - - _BinaryFileReader geoFile( getDataFileName() ); - - // check if swapping bytes needed - try { - countPartsBinary( geoFile, isSingleFileMode()); - } - catch (...) { - geoFile.swapBytes(); - geoFile.rewind(); - } - if ( getIndexInDataFile() <= 1 ) - geoFile.rewind(); - if ( geoFile.getPosition() == 0 ) { - TStrOwner format( geoFile.getLine() ); // "C|Fortran Binary" - if ( !contains( "C Binary", format )) { - if ( contains( "Fortran Binary", format )) - throw(MEDEXCEPTION(STRING(LOC) << "Fortran Binary format not supported")); - else - throw(MEDEXCEPTION(STRING(LOC) << "unexpected line in " << getDataFileName() - << "\n" << format.myValues)); - } - } - - if ( isSingleFileMode() ) { - // one time step may be skipped by countPartsBinary - int curTimeStep = geoFile.getPosition() ? 2 : 1 ; - while ( curTimeStep < getIndexInDataFile() ) { - countPartsBinary( geoFile, true ); // skip time step - curTimeStep++; - } - while (1) { - TStrOwner line( geoFile.getLine() ); - if ( isTimeStepBeginning( line.myValues )) - break; - } - } - // ---------------------- - // Read mesh description - // ---------------------- - { - TStrOwner descriptionLine1( geoFile.getLine() ); - TStrOwner descriptionLine2( geoFile.getLine() ); - - // find out if the file was created by MED driver - _isMadeByMed = contains( theDescriptionPrefix, descriptionLine1 ); - - if ( _isMadeByMed ) - _ptrMesh->setDescription( descriptionLine2.myValues ); - else - _ptrMesh->setDescription( string(descriptionLine1) + descriptionLine2.myValues ); - } - - // ---------------------------------------- - // Find out presence of node/elem numbers - // ---------------------------------------- - - // EnSight User Manual (for v8) says: - // You do not have to assign node IDs. If you do, the element connectivities are - // based on the node numbers. If you let EnSight assign the node IDs, the nodes - // are considered to be sequential starting at node 1, and element connectivity is - // done accordingly. If node IDs are set to off, they are numbered internally; - // however, you will not be able to display or query on them. If you have node - // IDs in your data, you can have EnSight ignore them by specifying "node id - // ignore." Using this option may reduce some of the memory taken up by the - // Client and Server, but display and query on the nodes will not be available. - - // read "node|element id " - bool haveNodeIds, haveElemIds; - { - TStrOwner nodeIds( geoFile.getLine() ); - TStrOwner elemIds( geoFile.getLine() ); - - haveNodeIds = ( contains( "given", nodeIds ) || contains( "ignore", nodeIds ) ); - haveElemIds = ( contains( "given", elemIds ) || contains( "ignore", elemIds ) ); - } - map & points = imed.points; - typedef map::iterator INoeud; - - int haveStructuredParts = 0, haveUnstructuredParts = 0; - - _groupe * partGroupe = 0; - int partNum = 0; - - while ( !geoFile.eof() ) - { - TStrOwner line( geoFile.getLine() ); - if ( isSingleFileMode() && isTimeStepEnd( line.myValues )) - break; - string word, restLine; - TStrTool::split( line.myValues, word, restLine ); - - const TEnSightElemType & partType = getEnSightType( word ); - if ( !partType._medIndex.empty() ) - { - // Unstructured element type encounters - // -------------------------------------- - int nbElemNodes = partType._medType % 100; - int nbElems = *TIntOwner( geoFile.getInt(1) ); // ne - if ( nbElems > 0 ) - haveUnstructuredParts++; - - TIntOwner numbers(0); - if ( haveElemIds ) - numbers.myValues = geoFile.getInt( nbElems ); // id_e - - imed.groupes.push_back(_groupe()); - _groupe & groupe = imed.groupes.back(); - groupe.mailles.resize( nbElems ); - - // read connectivity - _maille ma( partType._medType, nbElemNodes ); - ma.sommets.resize( nbElemNodes ); - TIntOwner connectivity( geoFile.getInt( nbElems * nbElemNodes )); - int* nodeID = connectivity; - INoeud node; - for ( int i = 0; i < nbElems; ++i ) { - for ( int n = 0; n < nbElemNodes; ++n, ++nodeID ) - ma.sommets[ partType._medIndex[n] ] = points.find( *nodeID ); - //ma.ordre = ++order; - groupe.mailles[i] = imed.insert(ma); - } - - int groupeIndex = imed.groupes.size(); - partGroupe->groupes.push_back( groupeIndex ); - - _SubPart subPart( partNum, partType._name ); - subPart.myNbCells = nbElems; - subPart.myCellGroupIndex = groupeIndex; - imed.addSubPart( subPart ); - } - else if ( word == "part" ) - { - // Another part encounters - // ----------------------- - partNum = atoi( restLine.c_str() ); - - string partName( TStrOwner( geoFile.getLine() )); - if ( partName.empty() ) - partName = "Part_" + restLine; - - if (int( imed.groupes.capacity() - imed.groupes.size()) < theMaxNbTypes ) - imed.groupes.reserve( size_t( 1.5 * imed.groupes.size() )); - imed.groupes.push_back(_groupe()); - partGroupe = & imed.groupes.back(); - partGroupe->nom = partName; - partGroupe->groupes.reserve( theMaxNbTypes ); - } - else if ( word == "block" ) - { - // Structured type - // ------------------ - bool iblanked = ( restLine == "iblanked" ); - - // dimension - TIntOwner ijk( geoFile.getInt(3) ); - int I = ijk[0]; - int J = ijk[1]; - int K = ijk[2]; - int NumberOfNodes = I*J*K; - if ( !NumberOfNodes ) continue; - haveStructuredParts++; - - // read coordinates - int nodeShift = points.empty() ? 0 : points.rbegin()->first; - { - TFltOwner noInterlaceCoords( geoFile.getFlt( NumberOfNodes * SPACE_DIM )); - float* x = noInterlaceCoords; - float* y = x + NumberOfNodes; - float* z = y + NumberOfNodes; - for ( int iNode = 1; iNode <= NumberOfNodes; ++iNode ) { - INoeud inoeud = points.insert( points.end(), make_pair( iNode + nodeShift, _noeud())); - _noeud & node = inoeud->second; - node.number = inoeud->first; - node.coord.resize( SPACE_DIM ); - node.coord[0] = *x++; - node.coord[1] = *y++; - node.coord[2] = *z++; - } - } - // iblanks - if ( iblanked ) - geoFile.skip(NumberOfNodes * sizeof(int)); - - // let GRID calculate connectivity - GRID grid; - grid._iArrayLength = I; - grid._jArrayLength = J; - grid._kArrayLength = K; - grid._gridType = MED_BODY_FITTED; - grid._spaceDimension= SPACE_DIM; - grid._coordinate = new COORDINATE(3, 1, 0); // to avoid exception in convertInMESH() - if ( J < 2 ) { grid._spaceDimension--; grid._jArrayLength = 0; } - if ( K < 2 ) { grid._spaceDimension--; grid._kArrayLength = 0; } - - const MESH* unstruct = grid.convertInMESH(); - const int * conn = unstruct->getConnectivity( MED_NODAL, MED_CELL, MED_ALL_ELEMENTS ); - medGeometryElement elemType = grid.getElementType( MED_CELL, 1 ); - int nbElemNodes = elemType % 100; - int nbElems = grid.getNumberOfElements(MED_CELL, MED_ALL_ELEMENTS); - - partGroupe->mailles.resize( nbElems ); - _maille ma( elemType, nbElemNodes ); - ma.sommets.resize( nbElemNodes ); - - for ( int i = 0, nIndex = 0; i < nbElems; ++i ) { - for ( int n = 0; n < nbElemNodes; ++n ) { - int nodeID = conn[ nIndex++ ]; - ma.sommets[n] = points.find( nodeID + nodeShift ); - } - //ma.ordre = ++order; - partGroupe->mailles[i] = imed.insert(ma); - } - - _SubPart subPart( partNum, "block" ); - subPart.myNbCells = nbElems; - subPart.myNbNodes = NumberOfNodes; - subPart.myFirstNode = points.find( nodeShift + 1 ); - subPart.myCellGroupIndex = imed.groupes.size(); - imed.addSubPart( subPart ); - - unstruct->removeReference(); - } - else if ( word == "coordinates" ) - { - // ------------------------------ - // Unstructured node coordinates - // ------------------------------ - int nbNodes = *TIntOwner( geoFile.getInt(1) ); - - TIntOwner numbers(0); - if ( haveNodeIds ) - numbers.myValues = geoFile.getInt( nbNodes ); - - TFltOwner fullInterlaceCoords( geoFile.getFlt( nbNodes * SPACE_DIM )); - float* coord = fullInterlaceCoords; - - cout << "-> loading coordinates of " << nbNodes << " nodes " << endl ; - - INoeud inoeud; - for ( int i=0 ; i < nbNodes ; i++ ) - { - if ( haveNodeIds ) { - int nodeID = numbers[ i ]; - inoeud = points.insert( make_pair( nodeID, _noeud() )).first; - inoeud->second.number = nodeID; - } - else { - int nodeID = i + 1; - inoeud = points.insert( points.end(), make_pair( nodeID, _noeud())); - inoeud->second.number = nodeID; - } - _noeud & node = inoeud->second; - node.coord.resize( SPACE_DIM ); - node.coord[ 0 ] = *coord++; - node.coord[ 1 ] = *coord++; - node.coord[ 2 ] = *coord++; - } - - _SubPartDesc cooDesc = _SubPartDesc::globalCoordDesc(); - _SubPart subPart( cooDesc.partNumber(), cooDesc.typeName() ); - subPart.myNbNodes = nbNodes; - subPart.myFirstNode = points.begin(); - imed.addSubPart( subPart ); - } - else - { - throw MED_EXCEPTION - ( LOCALIZED( STRING(LOC) << "Unexpected word: " << word << - " in " << getDataFileName())); - } - } // while ( !geoFile.eof() ) - - if ( ( haveStructuredParts && haveUnstructuredParts ) || haveStructuredParts > 1 ) - imed.mergeNodesAndElements(TOLERANCE); - - END_OF_MED(LOC); -} - -//================================================================================ -/*! - * \brief count number of parts in EnSight geometry file - */ -//================================================================================ - -int ENSIGHT_MESH_RDONLY_DRIVER::countParts(const string& geomFileName, - const bool isSingleFileMode) -{ - const char * LOC ="ENSIGHT_MESH_RDONLY_DRIVER::countParts() : "; - - int nbParts = 0; - if ( isBinaryDataFile( geomFileName )) - { - _BinaryFileReader geoFile(geomFileName); - // check if swapping bytes needed - try { - return countPartsBinary( geoFile, isSingleFileMode ); - } - catch (...) { - } - geoFile.swapBytes(); - geoFile.rewind(); - nbParts = countPartsBinary( geoFile, isSingleFileMode ); - } - else - { - _ASCIIFileReader geoFile(geomFileName); - - if ( isSingleFileMode ) - while ( !isTimeStepBeginning( geoFile.getLine() )); - - geoFile.getLine(); // description line 1 - geoFile.getLine(); // description line 2 - - // read "node|element id " - geoFile.getWord(); geoFile.getWord(); - string nodeIds = geoFile.getWord(); - geoFile.getWord(); geoFile.getWord(); - string elemIds = geoFile.getWord(); - bool haveNodeIds = ( nodeIds == "given" || nodeIds == "ignore" ); - bool haveElemIds = ( elemIds == "given" || elemIds == "ignore" ); - - bool isGold = true; - while ( !geoFile.isTimeStepEnd() ) - { - string word, restLine, line = geoFile.getLine(); - TStrTool::split( line, word, restLine ); - - const TEnSightElemType & partType = getEnSightType( word ); - if ( partType._medType != MED_ALL_ELEMENTS ) - { - // Unstructured element type encounters - // -------------------------------------- - int nbElemNodes = partType._medType % 100; - int nbElems = geoFile.getInt(); // ne - - // element ids - if ( haveElemIds && isGold ) - geoFile.skip( nbElems, /*nbPerLine =*/ 1, INT_WIDTH_GOLD ); // id_e - - // skip connectivity - int nbNodes = nbElems * nbElemNodes; - if ( partType._name == "nsided" ) // polygons - { - for ( int i = 0; i < nbElems; ++i ) - nbNodes += geoFile.getInt(); - geoFile.skip( nbNodes * INT_WIDTH_GOLD, /*nbLines = */nbElems ); - } - else if ( partType._name == "nfaced" ) // polyhedrons - { - int nbFaces = 0; - for ( int i = 0; i < nbElems; ++i ) - nbFaces += geoFile.getInt(); - for ( int f = 0; f < nbFaces; ++f ) - nbNodes += geoFile.getInt(); - geoFile.skip( nbNodes * INT_WIDTH_GOLD, /*nbLines = */nbFaces ); - } - else // standard types - { - if ( isGold ) - geoFile.skip( nbNodes, nbElemNodes, INT_WIDTH_GOLD ); - else if ( haveElemIds ) - geoFile.skip( nbNodes + nbElems, nbElemNodes+1, INT_WIDTH_6 ); - else - geoFile.skip( nbNodes, nbElemNodes, INT_WIDTH_6 ); - } - } - else if ( word == "coordinates" ) - { - isGold = ( nbParts > 0 ); - int nbNodes = geoFile.getInt(); // nn - - if ( isGold ) - { - if ( haveNodeIds ) - geoFile.skip( nbNodes, /*nbPerLine =*/ 1, INT_WIDTH_GOLD ); // node ids - geoFile.skip( nbNodes * SPACE_DIM, /*nbPerLine =*/ 1, FLT_WIDTH ); // coordinates - } - else { - int coordWidth = 3 * FLT_WIDTH; - if ( haveNodeIds ) - coordWidth += INT_WIDTH_6; - geoFile.skip(nbNodes, /*nbPerLine =*/ 1, coordWidth); - } - } - else if ( word == "part" ) - { - nbParts++; - if ( isGold ) - geoFile.skip( 1, /*nbPerLine =*/ 1, INT_WIDTH_GOLD ); //part number - else - geoFile.getWord(); // part number - geoFile.toNextLine(); - geoFile.getLine(); // description line - } - else if ( word == "block" ) - { - // Structured type - // ------------------ - bool rectilinear = ( restLine.find( "rectilinear" ) != restLine.npos ); - bool uniform = ( restLine.find( "uniform" ) != restLine.npos ); - bool curvilinear = ( !rectilinear && !uniform ); - bool iblanked = ( restLine.find( "iblanked" ) != restLine.npos ); - bool with_ghost = ( restLine.find( "with_ghost" ) != restLine.npos ); - bool range = ( restLine.find( "range" ) != restLine.npos ); - - // dimension - int I = geoFile.getInt(); - int J = geoFile.getInt(); - int K = geoFile.getInt(); - int nbNodes = I*J*K; - if ( !nbNodes ) continue; - - // range - if ( range ) { - vector ijkRange; // imin imax jmin jmax kmin kmax - ijkRange.reserve(6); - while ( ijkRange.size() < 6 ) - ijkRange.push_back( geoFile.getInt() ); - I = ijkRange[1]-ijkRange[0]+1; - J = ijkRange[3]-ijkRange[2]+1; - K = ijkRange[5]-ijkRange[4]+1; - nbNodes = I*J*K; - } - int nbElems = (I-1)*(J-1)*(K-1); - - if ( curvilinear ) // read coordinates for all nodes - { - if ( isGold ) - geoFile.skip( nbNodes, /*nbPerLine =*/ 1, FLT_WIDTH ); - else - geoFile.skip( nbNodes * SPACE_DIM, /*nbPerLine =*/ 6, FLT_WIDTH ); - } - else if ( rectilinear ) // read delta vectors with non-regular spacing - { - geoFile.skip( I + J + K, /*nbPerLine =*/ 1, FLT_WIDTH ); - } - else // uniform: read grid origine and delta vectors for regular spacing grid - { - geoFile.skip( 6, /*nbPerLine =*/ 1, FLT_WIDTH ); - } - - // iblanks - if ( iblanked ) { - if ( isGold ) - geoFile.skip( nbNodes, /*nbPerLine =*/ 1, INT_WIDTH_GOLD); - else - geoFile.skip( nbNodes, /*nbPerLine =*/ 10, INT_WIDTH_6 ); - } - // ghosts - if ( with_ghost ) { - geoFile.getWord(); // "ghost_flags" - geoFile.skip( nbElems, /*nbPerLine =*/ 1, INT_WIDTH_GOLD); - } - // node ids - if ( haveNodeIds && geoFile.lookAt( "node_ids" )) { - geoFile.getWord(); // "node_ids" - geoFile.skip( nbNodes, /*nbPerLine =*/ 1, INT_WIDTH_GOLD); - } - // element ids - if ( haveElemIds && geoFile.lookAt( "element_ids" ) ) { - geoFile.getWord(); // "element_ids" - geoFile.skip( nbElems, /*nbPerLine =*/ 1, INT_WIDTH_GOLD); - } - } - else if ( word == "extents" ) { - geoFile.getLine(); geoFile.getLine(); geoFile.getLine();// 3 x 2E12.5 - } - else - { - throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "Unexpected word: " << word)); - } - } - } - return nbParts; -} - -//================================================================================ -/*! - * \brief count number of parts in EnSight geometry file - */ -//================================================================================ - -int ENSIGHT_MESH_RDONLY_DRIVER::countPartsBinary(_BinaryFileReader& geoFile, - const bool isSingleFileMode) -{ - const char * LOC ="ENSIGHT_MESH_RDONLY_DRIVER::countPartsBinary() : "; - - if ( geoFile.getPosition() == 0 ) { - TStrOwner format( geoFile.getLine() ); // "C|Fortran Binary" - if ( !contains( "C Binary", format )) { - if ( contains( "Fortran Binary", format )) - throw(MEDEXCEPTION(STRING(LOC) << "Fortran Binary format not supported")); - else - throw(MEDEXCEPTION(STRING(LOC) << "unexpected line: \n" << format.myValues)); - } - } - - if ( isSingleFileMode ) { - while (1) { - TStrOwner line( geoFile.getLine() ); - if ( isTimeStepBeginning( line.myValues )) - break; - } - } - - // 2 description lines - // ---------------------- - geoFile.skip( 2 * MAX_LINE_LENGTH ); - - // read "node|element id " - bool haveNodeIds, haveElemIds; - { - TStrOwner nodeIds( geoFile.getLine() ); - TStrOwner elemIds( geoFile.getLine() ); - - haveNodeIds = ( contains( "given", nodeIds ) || contains( "ignore", nodeIds ) ); - haveElemIds = ( contains( "given", elemIds ) || contains( "ignore", elemIds ) ); - } - - int nbParts = 0; // the result - bool isGold = true; - - while ( !geoFile.eof() ) - { - TStrOwner line( geoFile.getLine() ); - if ( isSingleFileMode && isTimeStepEnd( line.myValues )) - break; - string word, restLine; - TStrTool::split( line.myValues, word, restLine ); - - const TEnSightElemType & partType = getEnSightType( word ); - if ( partType._medType != MED_ALL_ELEMENTS ) - { - // Unstructured element type encounters - // -------------------------------------- - int nbElems = *TIntOwner( geoFile.getInt(1) ); // ne - int nbElemNodes = partType._medType % 100; - - // read element ids - if ( haveElemIds ) - geoFile.skip( nbElems * sizeof(int) ); // id_e - - int nbNodes = nbElems * nbElemNodes; - if ( partType._name == "nsided" ) // polygons - { - TIntOwner nbNodesInFace( geoFile.getInt( nbElems )); - nbNodes = std::accumulate( nbNodesInFace.myValues, nbNodesInFace.myValues + nbElems, 0 ); - } - else if ( partType._name == "nfaced" ) // polyhedrons - { - TIntOwner nbElemFaces( geoFile.getInt( nbElems )); - int nbFaces = accumulate( nbElemFaces.myValues, nbElemFaces.myValues + nbElems, 0 ); - TIntOwner nbNodesInFace( geoFile.getInt( nbFaces )); - nbNodes = std::accumulate( nbNodesInFace.myValues, nbNodesInFace.myValues + nbFaces, 0 ); - } - geoFile.skip( nbNodes * sizeof(int) ); - } - else if ( word == "coordinates" ) - { - if ( nbParts == 0 ) - isGold = false; - int nbNodes = *TIntOwner( geoFile.getInt(1) ); // nn - - // node ids - if ( haveNodeIds ) - geoFile.skip( nbNodes * sizeof(int) ); // id_n - - // coordinates - geoFile.skip( nbNodes * SPACE_DIM * sizeof(int) ); - } - else if ( word == "part" ) - { - ++nbParts; - if ( isGold ) geoFile.skip(sizeof(int)); // part # - - geoFile.skip(MAX_LINE_LENGTH); // description line - } - else if ( word == "block" ) - { - // Structured type - // ------------------ - bool rectilinear = ( restLine.find( "rectilinear" ) != restLine.npos ); - bool uniform = ( restLine.find( "uniform" ) != restLine.npos ); - bool curvilinear = ( !rectilinear && !uniform ); - bool iblanked = ( restLine.find( "iblanked" ) != restLine.npos ); - bool with_ghost = ( restLine.find( "with_ghost" ) != restLine.npos ); - bool range = ( restLine.find( "range" ) != restLine.npos ); - - // dimension - TIntOwner ijk( geoFile.getInt(3) ); - int I = ijk[0]; - int J = ijk[1]; - int K = ijk[2]; - int NumberOfNodes = I*J*K; - if ( !NumberOfNodes ) { - if ( I != 0 && J != 0 && K != 0 ) - throw MEDEXCEPTION( "Need to swap bytes" ); - continue; - } - - // range - if ( range ) { - TIntOwner ijkRange( geoFile.getInt( 6 ));// imin imax jmin jmax kmin kmax - I = ijkRange[1]-ijkRange[0]+1; - J = ijkRange[3]-ijkRange[2]+1; - K = ijkRange[5]-ijkRange[4]+1; - NumberOfNodes = I*J*K; - } - int nbElems = (I-1)*(J-1)*(K-1); - - if ( curvilinear ) // read coordinates for all nodes - { - geoFile.skip( NumberOfNodes * SPACE_DIM * sizeof(float) ); - } - else if ( rectilinear ) // read delta vectors with non-regular spacing - { - geoFile.skip( (I+J+K) * sizeof(float) ); - } - else // uniform: read grid origine and delta vectors for regular spacing grid - { - geoFile.skip( 6 * sizeof(float) ); - } - - // iblanks - if ( iblanked ) - geoFile.skip( NumberOfNodes * sizeof(int) ); - // ghosts - if ( with_ghost ) { - geoFile.skip( MAX_LINE_LENGTH ); // "ghost_flags" - geoFile.skip( nbElems * sizeof(int) ); - } - // node ids - if ( haveNodeIds && isGold && !geoFile.eof() ) { - TStrOwner nextLine( geoFile.getLine() ); // "node_ids" - if ( contains( "node_ids", nextLine ) ) - geoFile.skip( NumberOfNodes * sizeof(int) ); - else - geoFile.skip( -MAX_LINE_LENGTH ); - } - // element ids - if ( haveElemIds && isGold && !geoFile.eof() ) { - TStrOwner nextLine( geoFile.getLine() ); // "element_ids" - if ( contains( "element_ids", nextLine ) ) - geoFile.skip( nbElems * sizeof(int) ); - else - geoFile.skip( -MAX_LINE_LENGTH ); - } - } - else if ( word == "extents" ) - { - geoFile.skip( 6 * sizeof(float) ); - } - else - { - throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "Unexpected word: " << word )); - } - } // while ( !geoFile.eof() ) - - return nbParts; -} - -GROUP* ENSIGHT_MESH_RDONLY_DRIVER::makeGroup( _groupe& grp, - _InterMed & imed) -{ - //const char* LOC = "ENSIGHT_MESH_RDONLY_DRIVER::makeGroup(): error"; - - // prevent creation of other groups but only this one - for (size_t i=0; i < imed.groupes.size(); ++i) - imed.groupes[i].nom.clear(); - - // let _intermediateMED create a GROUP from grp - grp.medGroup = 0; // the new GROUP should appear in grp.medGroup - grp.nom = "TMP"; - vector tmp; - MESH* mesh = imed._isOwnMedMesh ? (MESH*) 0 : imed._medMesh; - imed.getGroups( tmp, tmp, tmp, tmp, mesh ); - if ( !grp.medGroup ) - throw MEDEXCEPTION(LOCALIZED("Can't create a GROUP from _groupe")); - - grp.medGroup->setName(""); // to let a caller set a proper name - grp.nom = ""; - - // find pre-existing equal _groupe - _groupe * equalGroupe = 0; - for (unsigned int i=0; i < imed.groupes.size() && !equalGroupe; ++i) { - _groupe& g = imed.groupes[i]; - if ( &g != &grp && g.medGroup && g.medGroup->deepCompare( *grp.medGroup )) - equalGroupe = & g; - } - if ( equalGroupe ) { - if ( grp.medGroup->getMesh() ) - grp.medGroup->getMesh()->addReference(); // let the mesh survive - grp.medGroup->removeReference(); - grp.medGroup = equalGroupe->medGroup; - } - else { // new unique group - - if ( grp.medGroup->isOnAllElements() ) // on all elems - grp.medGroup->setName( string("SupportOnAll_")+entNames[ grp.medGroup->getEntity() ] ); - - // add a new group to mesh - if ( !imed._isOwnMedMesh ) { - vector * groups = 0; - switch ( grp.medGroup->getEntity() ) { - case MED_CELL: groups = & imed._medMesh->_groupCell; break; - case MED_FACE: groups = & imed._medMesh->_groupFace; break; - case MED_EDGE: groups = & imed._medMesh->_groupEdge; break; - case MED_NODE: groups = & imed._medMesh->_groupNode; break; - default:; - } - if ( groups ) { - groups->resize( groups->size() + 1 ); - groups->at( groups->size() - 1) = grp.medGroup; - } - } - } - return grp.medGroup; -} diff --git a/src/MEDMEM/MEDMEM_EnsightMeshDriver.hxx b/src/MEDMEM/MEDMEM_EnsightMeshDriver.hxx deleted file mode 100644 index d4cddb76e..000000000 --- a/src/MEDMEM/MEDMEM_EnsightMeshDriver.hxx +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef ENSIGHT_MESH_DRIVER_HXX -#define ENSIGHT_MESH_DRIVER_HXX - -#include "MEDMEM_define.hxx" -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_EnsightUtils.hxx" - -#include - -namespace MEDMEM { - - class GMESH; - class SUPPORT; - -// ============================================================================== -/*! - Driver Ensight for MESH ( writing and reading ). - - Generic part : implement open and close methods. -*/ -// ============================================================================== - -class MEDMEM_EXPORT ENSIGHT_MESH_DRIVER : public MEDMEM_ENSIGHT::_CaseFileDriver_User -{ -protected: - - GMESH * _ptrMesh; - std::string _meshName; - - virtual void openConst(bool checkDataFile=false) const; - -public : - ENSIGHT_MESH_DRIVER() ; - ENSIGHT_MESH_DRIVER(const std::string & fileName, GMESH * ptrMesh) ; - ENSIGHT_MESH_DRIVER(const std::string & fileName, GMESH * ptrMesh, - MED_EN::med_mode_acces accessMode); - ENSIGHT_MESH_DRIVER(const ENSIGHT_MESH_DRIVER & driver) ; - virtual ~ENSIGHT_MESH_DRIVER() ; - - void open(); - void close(); - - virtual void setMeshName(const string & meshName); - virtual std::string getMeshName() const; - - GMESH* getMesh() { return _ptrMesh; } -}; - -// ============================================================================== -/*! - * \brief Reading EnSight driver. - */ -// ============================================================================== - -class MEDMEM_EXPORT ENSIGHT_MESH_RDONLY_DRIVER : public virtual ENSIGHT_MESH_DRIVER -{ -public : - //!< to read mesh of index-th time step - ENSIGHT_MESH_RDONLY_DRIVER(const std::string & fileName, MESH * ptrMesh, int index=1); - - ENSIGHT_MESH_RDONLY_DRIVER(); - ENSIGHT_MESH_RDONLY_DRIVER(const ENSIGHT_MESH_RDONLY_DRIVER & driver); - virtual ~ENSIGHT_MESH_RDONLY_DRIVER(); - virtual GENDRIVER * copy ( void ) const; - virtual void merge ( const GENDRIVER& driver ); - virtual void write ( void ) const throw (MEDEXCEPTION) ; - virtual void read ( void ) throw (MEDEXCEPTION); - - //!< count number of parts in EnSight geometry file - static int countParts(const std::string& geomFileName, - const bool isSingleFileMode); - - static GROUP* makeGroup( MEDMEM::_groupe & interGroup, - MEDMEM_ENSIGHT::_InterMed & imed); - -private: - - void readGoldASCII (MEDMEM_ENSIGHT::_InterMed & imed); - void readGoldBinary(MEDMEM_ENSIGHT::_InterMed & imed); - void read6ASCII (MEDMEM_ENSIGHT::_InterMed & imed); - void read6Binary (MEDMEM_ENSIGHT::_InterMed & imed); - - static int countPartsBinary(MEDMEM_ENSIGHT::_BinaryFileReader& fileReader, - const bool isSingleFileMode); - - bool _isMadeByMed; - int _indexInCaseFile; -}; - -// ============================================================================== -/*! - * \brief Writing EnSight mesh driver. - * To set writing format use - * setEnSightFormatForWriting(EnSightFormat) and - * setEnSightBinaryFormatForWriting(bool) - */ -// ============================================================================== - -class MEDMEM_EXPORT ENSIGHT_MESH_WRONLY_DRIVER : public virtual ENSIGHT_MESH_DRIVER -{ -public : - //!< write a mesh; - // to be appended, a mesh mush have same nb of groups and dimension as already present ones - ENSIGHT_MESH_WRONLY_DRIVER(const std::string & fileName, - const GMESH * ptrMesh, - bool append=false); - - ENSIGHT_MESH_WRONLY_DRIVER(); - ENSIGHT_MESH_WRONLY_DRIVER(const ENSIGHT_MESH_WRONLY_DRIVER & driver); - virtual ~ENSIGHT_MESH_WRONLY_DRIVER(); - GENDRIVER * copy ( void ) const; - void write ( void ) const throw (MEDEXCEPTION) ; - void read ( void ) throw (MEDEXCEPTION) ; - - int nbPartsToWrite() const; - -private: - - void writePart6Binary (MEDMEM_ENSIGHT::_BinaryFileWriter& file, const SUPPORT* support) const; - void writePartGoldBinary(MEDMEM_ENSIGHT::_BinaryFileWriter& file, const SUPPORT* support) const; - void writePart6ASCII (std::ofstream& fileStream, const SUPPORT* support) const; - void writePartGoldASCII (std::ofstream& fileStream, const SUPPORT* support) const; - - bool _append; -}; - -} - -#endif /* ENSIGHT_MESH_DRIVER_HXX */ - diff --git a/src/MEDMEM/MEDMEM_EnsightUtils.cxx b/src/MEDMEM/MEDMEM_EnsightUtils.cxx deleted file mode 100644 index 4fd116c03..000000000 --- a/src/MEDMEM/MEDMEM_EnsightUtils.cxx +++ /dev/null @@ -1,2926 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : MEDMEM_EnsightUtils.cxx -// Created : Fri Jun 6 16:08:32 2008 -// Author : Edward AGAPOV (eap) -// -#include "MEDMEM_Field.hxx" // important to include it before MEDMEM_EnsightUtils.hxx, -// in order not to redefine DBL_MIN - -#include "MEDMEM_EnsightUtils.hxx" - -#include "MEDMEM_EnsightMeshDriver.hxx" -#include "MEDMEM_EnsightFieldDriver.hxx" -#include "MEDMEM_DriverTools.hxx" - -#ifdef WIN32 -#include -#else -#include -#endif -#include -//#include - -using namespace std; -using namespace MEDMEM; - - // TODO: -// -2) in transient model, get time values for meshes form fields on them -// -1) why after reading /data/eap/ENSIGHT/SAMPLES_SRC/EnSight/crash.case only -// geo EnSIght files are written -// -0) test selecting imaginary part to read -// 0) appending fields to write with same names in Case file -// 1) write grid -// 2) if mesh description is longer that maxLen, distribute it among two lines -// 3) care of mesh description at reading -// 4) at writing, cut off " t=..." from mesh name and set to meshDriver->_meshName -// 5) MEDMEM_EXPORT -// 4.5) do something with zzzz121b.med pb -// 6) stripe in getLine() -// 7) care of elem numbers that were read -// 8) read real and imaginary of complex field by MED driver -// 9) read "mesured" and care of variable on it -// 10) clear theInterMedMap and delete _InterMed's there -// 11) not to fill MESH made in getMeshData() -// 12) care of changing nb of '*' in names -// 14) analize _TimeSet to write in shortest form -// 15) add LOCALIZED where no method name specified -// 17) add checks of input mesh and field like in gibi -// 18) check writing interlace in all modes -// 19) define creation by MEDMEM by case file and not by geo -// 21) there maybe '\n' in binary file after string end -// 22) optimize _ASCIIFileReader::eof() at file end -// 23) What if to create CELL entity with 1-3 dim and a CELL group? -// 24) not to write CELL connectivity if a group on all cells is present -// 25) compact imed (sortedNodeIDs etc.) -// 26) no need in converting EnSight variables to eventual types in convertReals -// since a result array is not used directly but occupies more memory -// 27) try to exclude merged nodes in DTree and compare time on ChampsDarcy.med - - -namespace MEDMEM -{ - // ============================================================================== - /*! - Writing format. - */ - // ============================================================================== - - EnSightFormat theEnSightFormatForWriting = ENSIGHT_6; - bool theBinaryFormatForWriting = false; - bool theIgnoreIncompatibility = false; - - void setEnSightFormatForWriting (EnSightFormat format, bool isBinary) - { - theEnSightFormatForWriting = format; - theBinaryFormatForWriting = isBinary; - } - EnSightFormat getEnSightFormatForWriting() - { - return theEnSightFormatForWriting; - } - bool isBinaryEnSightFormatForWriting() - { - return theBinaryFormatForWriting; - } - // ============================================================================== - /*! - To raise or not if MEDMEM-EnSight incompatibility encounters or suspected - */ - // ============================================================================== - - void setIgnoreIncompatibility(bool toIgnore) - { - theIgnoreIncompatibility = toIgnore; - } -} - -#ifdef WIN32 -#define FILE_SEPARATOR '\\' -#else -#define FILE_SEPARATOR '/' -#endif - -#define _ATOI( str ) atoi((str).c_str()) -#define _ATOF( str ) atof((str).c_str()) - -#define BUFFER_SIZE 16184 // for non-stream input - -namespace MEDMEM_ENSIGHT -{ - //-------------------------------------------------------------------------------- - /*! - * \brief Registry of drivers creating _CaseFileDriver - * - * The problem is that if the mesh/field driver is created by the user, it is - * to write Case file, but if it is created by MED driver, it should not, in - * order not to overwrite the Case file written by MED driver. - * To assure this feature, we register all mesh/field drivers added to a case - * file by a MED driver and then ignore thier calls to _CaseFileDriver. - */ - set< const _CaseFileDriver_User* > theCaseUsers; - - //-------------------------------------------------------------------------------- - /*! - * \brief Storage of data read by mesh driver to be used by field drivers - * - * The field driver needs info read by the mesh driver (nb of elements by type in - * each part and what place the element gets in MEDMED support). - * So we store needed data unless it is no more needed (i.e. no driver is alive). - * The map key is ":". - */ - map< string, _InterMed* > theInterMedMap; - - //-------------------------------------------------------------------------------- - /*! - * \brief Add a driver to the registry and return true if was already in - */ - bool isToIgnore(const _CaseFileDriver_User* driver); - bool isToIgnore(const _CaseFileDriver_User* driver) - { - return ! theCaseUsers.insert( driver ).second; - } - - //-------------------------------------------------------------------------------- - /*! - * \brief Remove a driver from the registry - */ - void unregister(const _CaseFileDriver_User* driver); - void unregister(const _CaseFileDriver_User* driver) - { - theCaseUsers.erase( driver ); - if ( theCaseUsers.empty() ) - { - for ( map< string, _InterMed* >::iterator str_imed = theInterMedMap.begin(); - str_imed != theInterMedMap.end(); - str_imed++ ) - delete str_imed->second; - theInterMedMap.clear(); - } - } - - //-------------------------------------------------------------------------------- - /*! - * \brief Return mesh data needed by field driver - */ - _InterMed* getMeshData( const string& key ); - _InterMed* getMeshData( const string& key ) - { - // find existing data - map< string, _InterMed* >::iterator kimed = theInterMedMap.find( key ); - if ( kimed != theInterMedMap.end() ) - return kimed->second; - - // create a new data - MESH * mesh = new MESH; - string caseFile, meshIndex; - _ASCIIFileReader::split( key, caseFile, meshIndex, ':' ); - ENSIGHT_MESH_RDONLY_DRIVER meshDrv(caseFile, mesh, _ATOI( meshIndex )); - meshDrv.read(); - kimed = theInterMedMap.find( key ); - if ( kimed == theInterMedMap.end() ) - return 0; - _InterMed* imed = kimed->second; - imed->_medMesh = mesh; - imed->_isOwnMedMesh = true; - return imed; - } - // --------------------------------------------------------------- - /*! - * \brief Prepend "EnSight-MEDMEM compatibility problem" to the text - * of an exception - */ - STRING compatibilityPb(const string& exceptionText) - { - return STRING("EnSight-MEDMEM compatibility problem:\n") << exceptionText; - } - // --------------------------------------------------------------- - /*! - * \brief To ignore incompatibility or not - */ - bool toIgnoreIncompatibility() - { - return theIgnoreIncompatibility; - } - - //-------------------------------------------------------------------------------- - /*! - * \brief Return true if set index is empty or corresponds to an existing set - */ - template bool isValidIndex(const string& index, const map& aMap) - { - if ( index.empty() ) return true; - return ( aMap.find( _ATOI( index ) ) != aMap.end() ); - } - - //-------------------------------------------------------------------------------- - /*! - * \brief Return EnSight type corresponding to med one - */ - const TEnSightElemType& getEnSightType(medGeometryElement medType) - { - static TEnSightElemType theEnSightType; - - int nbNodes = medType % 100; - theEnSightType._medType = medType; - - switch ( medType ) { - case MED_NONE : - case MED_POINT1 : { - theEnSightType._name = "point"; - theEnSightType._medIndex.resize(1,0); - break ; - } - case MED_SEG2 : { - theEnSightType._name = "bar2"; - int conn [2] = {0,1}; - theEnSightType._medIndex.assign( conn, conn+nbNodes ); - break ; - } - case MED_SEG3 : { - theEnSightType._name = "bar3"; - int conn [3] = {0,2,1}; - theEnSightType._medIndex.assign( conn, conn+nbNodes ); - break ; - } - case MED_TRIA3 : { - theEnSightType._name = "tria3"; - int conn [3] = {0,2,1}; - theEnSightType._medIndex.assign( conn, conn+nbNodes ); - break ; - } - case MED_QUAD4 : { - theEnSightType._name = "quad4"; - int conn [4] = {0,3,2,1}; - theEnSightType._medIndex.assign( conn, conn+nbNodes ); - break ; - } - case MED_TRIA6 : { - theEnSightType._name = "tria6"; - int conn [6] = {0,2,1,5,4,3}; - theEnSightType._medIndex.assign( conn, conn+nbNodes ); - break ; - } - case MED_QUAD8 : { - theEnSightType._name = "quad8"; - int conn [8] = {0,3,2,1,7,6,5,4}; - theEnSightType._medIndex.assign( conn, conn+nbNodes ); - break ; - } - case MED_TETRA4 : { - theEnSightType._name = "tetra4"; - int conn [4] = {0,1,3,2}; - theEnSightType._medIndex.assign( conn, conn+nbNodes ); - break ; - } - case MED_PYRA5 : { - theEnSightType._name = "pyramid5"; - int conn [5] = {0,3,2,1,4}; - theEnSightType._medIndex.assign( conn, conn+nbNodes ); - break ; - } - case MED_PENTA6 : { - theEnSightType._name = "penta6"; - int conn [6] = {0,2,1,3,5,4}; - theEnSightType._medIndex.assign( conn, conn+nbNodes ); - break ; - } - case MED_HEXA8 : { - theEnSightType._name = "hexa8"; - int conn [8] = {0,3,2,1,4,7,6,5}; - theEnSightType._medIndex.assign( conn, conn+nbNodes ); - break ; - } - case MED_TETRA10 : { - theEnSightType._name = "tetra10"; - int conn [10] = {0,2,1,3,6,5,4,7,9,8}; - theEnSightType._medIndex.assign( conn, conn+nbNodes ); - break ; - } - case MED_PYRA13 : { - theEnSightType._name = "pyramid13"; - int conn [13] = {0,3,2,1,4,8,7,6,5,9,12,11,10}; - theEnSightType._medIndex.assign( conn, conn+nbNodes ); - break ; - } - case MED_PENTA15 : { - theEnSightType._name = "penta15"; - int conn [15] = {0,2,1,3,5,4,8,7,6,11,10,12,14,13}; - theEnSightType._medIndex.assign( conn, conn+nbNodes ); - break ; - } - case MED_HEXA20 : { - theEnSightType._name = "hexa20"; - int conn [20] = {0,3,2,1,4,7,6,5,11,10,9,8,15,14,13,12,16,19,18,17}; - theEnSightType._medIndex.assign( conn, conn+nbNodes ); - break ; - } - case MED_POLYGON : { - theEnSightType._name = "nsided"; - theEnSightType._medIndex.clear(); - break ; - } - case MED_POLYHEDRA : { - theEnSightType._name = "nfaced"; - theEnSightType._medIndex.clear(); - break ; - } - default: { - theEnSightType._name = ""; - theEnSightType._medIndex.clear(); - } - } - return theEnSightType; - } - - //-------------------------------------------------------------------------------- - /*! - * \brief Return EnSight type having a given name - */ - const TEnSightElemType& getEnSightType(const string& theTypeName) - { - string typeName = theTypeName; - if ( isGhostType( typeName )) - typeName = string( &typeName[2] ); // ghost type - - static map name2Type; - - map::iterator nameType = name2Type.find( typeName ); - if ( nameType != name2Type.end() ) - return nameType->second; - - const list & allMedTypes = MED_EN::meshEntities[MED_CELL]; - list< medGeometryElement >::const_iterator medType = allMedTypes.begin(); - for ( ; medType != allMedTypes.end(); ++medType ) - { - const TEnSightElemType& enSightType = getEnSightType( *medType ); - if ( enSightType._name == typeName ) - return name2Type[ typeName ] = enSightType; - } - return getEnSightType(MED_ALL_ELEMENTS); - } - -// =============================================================== _CaseFileDriver -/*! - * \brief Case file driver constructor - */ -//================================================================================ - -_CaseFileDriver::_CaseFileDriver(const string & fileName, - const _CaseFileDriver_User* creator) - : _fileName( fileName ), _directory("."), _user( creator ) -{ - // Find out if the driver is blocked - _blocked = isToIgnore( creator ); - if ( creator->getAccessMode() == MED_EN::RDONLY ) - _blocked = false; - if ( !_blocked ) { - // set directory - string::size_type sepPos = _fileName.rfind( FILE_SEPARATOR ); - if ( sepPos != _fileName.npos ) { - _directory = _fileName.substr( 0, sepPos ); - } - _format = getEnSightFormatForWriting(); - } -} - -// =============================================================== _CaseFileDriver -/*! - * \brief Case file driver destructor - */ -//================================================================================ - -_CaseFileDriver::~_CaseFileDriver() -{ - if ( !_blocked ) - { - // to write case file again by same DRIVER - unregister( _user ); - ((_CaseFileDriver_User*)_user)->_imed = 0; - } -} - -#define READ_NEXT_LINE continue -#define RAISE_EXCEPTION break - -//================================================================================ -/*! - * \brief Read Case file - */ -//================================================================================ - -void _CaseFileDriver::read() throw (MEDEXCEPTION) -{ - if ( _blocked ) - return; - - _ASCIIFileReader reader( _fileName ); - - STRING badFile("Invalid Case file "); - badFile << _fileName << "\n"; - - list<_FileSet> fileSets; - list<_TimeSet> timeSets; - - set varNames; // to detect equal variable names - - string section = "_"; - int lineNb = 0; - while ( !reader.eof() ) - { - string line = reader.getLine(); - ++lineNb; - - // cut off comments - string comment; - reader.split( line, line, comment, '#'); - if ( line.empty() ) - READ_NEXT_LINE; - - string key, value; // parts of a line splited by column - reader.split( line, key, value, ':'); - - STRING errorMsg; - - // analyse not empty lines - switch ( section[0] ) { - case 'V': { - // -------------------------------------------------------------------------------- - // VARIABLE - - string type, s, ts, fs; - reader.split(key,type,s); - int newVarIndex = _variables.empty() ? 1 : _variables.rbegin()->first + 1; - - if ( type == "scalar" || type == "vector" || type == "tensor" ) - { - // scalar per node: [ts] [fs] description filename - // vector per node: [ts] [fs] description filename - // tensor symm per node: [ts] [fs] description filename - // tensor asym per node: [ts] [fs] description filename - // scalar per element: [ts] [fs] description filename - // vector per element: [ts] [fs] description filename - // tensor symm per element: [ts] [fs] description filename - // tensor asym per element: [ts] [fs] description filename - // scalar per measured node: [ts] [fs] description filename - // vector per measured node: [ts] [fs] description filename - list parts; - int nbParts = reader.split( value, parts ); - if ( nbParts < 2 ) { - errorMsg << "invalid variable format:\n" << line; - RAISE_EXCEPTION; - } - if ( contains( "per measured node", s.c_str() )) { - //cout << "Skip not supported data type: " << key << endl; - READ_NEXT_LINE; - } - list::reverse_iterator p = parts.rbegin(); - _Variable& var = _variables[newVarIndex]; - var._type = key; - var._fileNameOrData = *p++; - var._name = *p++; - if ( nbParts == 3 ) { - var._timeSetNumber = *p; - } - else if ( nbParts == 4 ) { - var._fileSetNumber = *p++; - var._timeSetNumber = *p; - } - varNames.insert( var._name ); - READ_NEXT_LINE; - } - else if ( type == "constant" ) - { - // constant per case: [ts] description const_value(s) - // constant per case file: [ts] description cvfilename - reader.split(value,s,value); - if ( reader.isDigit( s )) { - ts = s; - reader.split(value,s,value); - } - _Variable& var = _variables[newVarIndex]; - var._type = key; - var._name = s; - var._fileNameOrData = value; - var._timeSetNumber = ts; - if ( var._name.empty() || var._fileNameOrData.empty() ) { - errorMsg << "invalid variable format:\n" << line; - RAISE_EXCEPTION; - } - varNames.insert( var._name ); - READ_NEXT_LINE; - } - else if ( type == "complex" ) - { - // complex scalar per node: [ts] [fs] description Re_fn Im_fn freq - // complex vector per node: [ts] [fs] description Re_fn Im_fn freq - // complex scalar per element: [ts] [fs] description Re_fn Im_fn freq - // complex vector per element: [ts] [fs] description Re_fn Im_fn freq - reader.split(value,s,value); - if ( reader.isDigit( s )) { - ts = s; - reader.split(value,s,value); - if ( reader.isDigit( s )) { - fs = s; - reader.split(value,s,value); - } - } - list parts; - int nbParts = reader.split( value, parts ); - if ( nbParts < 3 ) { - errorMsg << "invalid variable format:\n" << line; - RAISE_EXCEPTION; - } - // a variable contains two fields. We leave one slot in _variables empty - // in order to have last key in _variables equal to number of fields. - // Variable index equal to missing slot key corresponds to real part (Re_fn) - _Variable& var = _variables[++newVarIndex]; - var._type = key; - var._name = s; - var._timeSetNumber = ts; - var._fileSetNumber = fs; - var._fileNameOrData = value; - varNames.insert( var._name ); - READ_NEXT_LINE; - } - break; - } - case 'T': { - // -------------------------------------------------------------------------------- - // TIME - // time set: ts [description] - // number of steps: ns - // filename start number: fs - // filename increment: fi - // time values: time_1 time_2 .... time_ns - // or - // time set: ts [description] - // number of steps: ns - // filename numbers: fn - // time values: time_1 time_2 .... time_ns - // or - // time set: ts [description] - // number of steps: ns - // filename numbers file: fnfilename - // time values file: tvfilename - _TimeSet* timeSet = timeSets.empty() ? 0 : & timeSets.back(); - // --------------------------------------------------------- - if ( key == "time set" ) - { - int nb = _ATOI( value ); - if ( nb < 1 ) { - errorMsg << "Invalid time set number: " << value; - RAISE_EXCEPTION; - } - timeSets.push_back( _TimeSet() ); - timeSets.back()._number = nb; - READ_NEXT_LINE; - } - // --------------------------------------------------------- - if ( key == "number of steps" ) - { - if ( !timeSet || !timeSet->_times.empty() ) { - errorMsg << "Unexpected command: " << key; - RAISE_EXCEPTION; - } - int nbSteps = _ATOI( value ); - if ( nbSteps < 1 ) { - errorMsg << "invalid number of steps: " << value; - RAISE_EXCEPTION; - } - timeSet->_times.resize( nbSteps ); - timeSet->_fileIndex.resize( nbSteps ); - READ_NEXT_LINE; - } - // --------------------------------------------------------- - if ( key == "filename start number" ) - { - if ( !timeSet || timeSet->_fileIndex.empty() ) { - errorMsg << "Unexpected command: " << key; - RAISE_EXCEPTION; - } - if ( !reader.isDigit( value )) { - errorMsg << "invalid " << line; - RAISE_EXCEPTION; - } - timeSet->_fileIndex[0] = value; - READ_NEXT_LINE; - } - // --------------------------------------------------------- - if ( key == "filename increment" ) { - int incr = _ATOI( value ); - if ( incr == 0 ) { - errorMsg << "invalid " << line; - RAISE_EXCEPTION; - } - if ( !timeSet || - timeSet->_fileIndex.empty() || - timeSet->_fileIndex[0].empty() ) { - errorMsg << "Unexpected command: " << key; - RAISE_EXCEPTION; - } - int index = incr + _ATOI( timeSet->_fileIndex[0] ); - int nbSteps = timeSet->_fileIndex.size(); - for ( int i = 1; i < nbSteps; ++i, index += incr ) - timeSet->_fileIndex[i] = STRING( index ); - READ_NEXT_LINE; - } - // --------------------------------------------------------- - if ( key == "time values" ) - { - if ( !timeSet || timeSet->_times.empty() ) { - errorMsg << "Unexpected command: " << key; - RAISE_EXCEPTION; - } - list times; - int i, nbTimes = reader.split( value, times ); - list::iterator t = times.begin(); - for ( i = 0; i < nbTimes; ++i, ++t ) - timeSet->_times[i] = *t; - while ( nbTimes != (int)timeSet->_times.size() ) { - value = reader.getLine(); - ++lineNb; - nbTimes += reader.split( value, times ); - for (t = times.begin(); i < nbTimes; ++i, ++t ) { - if ( ! reader.isDigit( *t, /*real=*/true )) - break; - timeSet->_times[i] = *t; - } - } - if ( nbTimes != (int)timeSet->_times.size() ) { - errorMsg << "incorrect number of times in time set " << timeSet->_number; - RAISE_EXCEPTION; - } - for ( i = 1; i < nbTimes; ++i ) - if ( _ATOF( timeSet->_times[ i ]) <= _ATOF(timeSet->_times[ i-1 ] )) - break; - if ( i < nbTimes ) { // break from the previous loop occured - errorMsg << "time values are not in ascending order in time set " << timeSet->_number; - RAISE_EXCEPTION; - } - READ_NEXT_LINE; - } - // --------------------------------------------------------- - if ( key == "filename numbers" ) - { - if ( !timeSet || timeSet->_fileIndex.empty()) { - errorMsg << "Unexpected command: " << key; - RAISE_EXCEPTION; - } - list numbers; - int i, nb = reader.split( value, numbers ); - int nbFiles = timeSet->_fileIndex.size(); - timeSet->_fileIndex.insert(timeSet->_fileIndex.begin(), numbers.begin(), numbers.end() ); - while ( nb != nbFiles ) { - value = reader.getLine(); - ++lineNb; - i = nb; - nb += reader.split( value, numbers ); - list::iterator n = numbers.begin(); - for ( ; i < nb; ++i, ++n ) { - if ( ! reader.isDigit( *n )) - break; - timeSet->_fileIndex[i] = *n; - } - } - if ( nb != nbFiles ) { - errorMsg << "incorrect number of " << key << " in time set " << timeSet->_number; - RAISE_EXCEPTION; - } - READ_NEXT_LINE; - } - // --------------------------------------------------------- - if ( key == "filename numbers file" || - key == "time values file" ) - { - if ( !timeSet || timeSet->_fileIndex.empty()) { - errorMsg << "Unexpected command: " << key; - RAISE_EXCEPTION; - } - string fileName = _directory + FILE_SEPARATOR + value; - if ( !_user->canOpenFile( fileName, RDONLY )) { - errorMsg << "Can not open file " << fileName; - RAISE_EXCEPTION; - } - _ASCIIFileReader file( fileName ); - list numbers; - while ( !file.eof() ) - numbers.push_back( file.getWord() ); - int nb = numbers.size(); - if ( nb != (int)timeSet->_times.size() ) { - errorMsg << "incorrect number of values in file " << value; - RAISE_EXCEPTION; - } - if ( key[0] == 'f' ) - timeSet->_fileIndex.assign( numbers.begin(), numbers.end() ); - else - timeSet->_times.assign( numbers.begin(), numbers.end() ); - READ_NEXT_LINE; - } - break; - } - case 'F': { - if ( section[1] == 'I' ) { - // -------------------------------------------------------------------------------- - // FILE - // file set: fs - // filename index: fi # Note: only used when data continues in other files - // number of steps: ns - if ( key == "file set" ) { - int nb = _ATOI( value ); - if ( nb < 1 ) { - errorMsg << "Invalid file set number: " << value; - } - else { - fileSets.push_back( _FileSet() ); - fileSets.back()._number = nb; - READ_NEXT_LINE; - } - } - else if ( key == "filename index" ) { - if ( fileSets.empty() ) { - errorMsg << "'filename index' before 'file set'"; - } - else if ( !value.empty() ) { - fileSets.back()._fileIndex.push_back( value ); - READ_NEXT_LINE; - } - } - else if ( key == "number of steps" ) { - if ( fileSets.empty() ) { - errorMsg << "'number of steps' before 'file set'"; - } - else if ( value.empty() ) { - errorMsg << "number of steps omitted: " << line; - } - else if ( !reader.isDigit( value )) { - errorMsg << "invalid number of steps: " << value; - } - else { - int n = _ATOI( value ); - if ( n < 1 ) { - errorMsg << "invalid number of steps: " << value; - RAISE_EXCEPTION; - } - fileSets.back()._nbStepsInFile.push_back( n ); - READ_NEXT_LINE; - } - } - } - else { - // -------------------------------------------------------------------------------- - // FORMAT - // type: ensight - if ( key != "type" ) { - errorMsg << "unexpected info in section " << section << ":\n" << line; - RAISE_EXCEPTION; - } - else { - if ( value == "ensight gold" ) { - _format = ENSIGHT_GOLD; - } - else if ( value == "ensight" ) { - _format = ENSIGHT_6; - } - else { - errorMsg << "Unsupported EnSight format: " << value; - RAISE_EXCEPTION; - } - section = "_"; - READ_NEXT_LINE; - } - } - break; - } - case 'G': { - // -------------------------------------------------------------------------------- - // GEOMETRY - // model: [ts] [fs] filename [change_coords_only] - // measured: [ts] [fs] filename [change_coords_only] - // match: filename - // boundary: filename - // rigid_body: filename - if ( key == "measured" || key == "match" || key == "boundary" || key == "rigid_body") { - //errorMsg << key << " geometry not supported"; - cout << "Warning: " << key << " geomerty not supported" << endl; - READ_NEXT_LINE; - } - else if ( key == "model" ) { - list parts; - reader.split( value, parts ); - list::reverse_iterator s = parts.rbegin(); - for ( ; s != parts.rend(); ++s ) - { - if ( *s == "change_coords_only" ) - _model._change_coords_only = *s; - else if ( _model._fileName.empty() ) - _model._fileName = *s; - else if ( _model._fileSetNumber.empty() ) - _model._fileSetNumber = *s; - else - _model._timeSetNumber = *s; - } - if ( _model._timeSetNumber.empty() && !_model._fileSetNumber.empty() ) - swap( _model._timeSetNumber, _model._fileSetNumber ); - if ( _model._fileName.empty() ) { - errorMsg << "invalid model: " << value; - RAISE_EXCEPTION; - } - READ_NEXT_LINE; - } - break; - } - case 'M': { // MATERIAL - string keyWord1; - reader.split(key,keyWord1,key); - if ( keyWord1 == "material" || keyWord1 == "species" ) - READ_NEXT_LINE; - break; - } - } // end switch (section[0]) - - if ( !errorMsg.empty() ) { - throw MEDEXCEPTION(STRING("Invalid Case file ") << _fileName - << ":" << lineNb << "\n" << errorMsg ); - } - - // we are here if a line was not recognized to belong to a current section - if ( line == "FORMAT" || - line == "GEOMETRY" || - line == "VARIABLE" || - line == "TIME" || - line == "FILE" || - line == "MATERIAL") - section = line; - else - throw MEDEXCEPTION(STRING() << "Invalid format of Case file " << _fileName - << "\nwrong line: " << line ); - } - - if ( _model._fileName.empty() ) - throw MEDEXCEPTION(badFile << "no supported geometry information found" ); - - // store time sets and file sets - list<_FileSet>::iterator fs = fileSets.begin(); - for ( ; fs != fileSets.end(); ++fs ) { - if ( fs->_nbStepsInFile.size() > 1 && fs->_fileIndex.empty() ) - throw MEDEXCEPTION(badFile << "missing file indices in a file set " << fs->_number ); - _fileSets[ fs->_number ] = *fs; - } - list<_TimeSet>::iterator ts = timeSets.begin(); - for ( ; ts != timeSets.end(); ++ts ) - _timeSets[ ts->_number ] = *ts; - - // check validity of ts and fs - - if ( !isValidIndex( _model._timeSetNumber, _timeSets )) - throw MEDEXCEPTION(badFile << "bad time set index:" << _model._timeSetNumber ); - if ( !isValidIndex( _model._fileSetNumber, _fileSets )) - throw MEDEXCEPTION(badFile << "bad file set index:" << _model._timeSetNumber ); - - map< int, _Variable>::iterator ivars = _variables.begin(); - for ( ; ivars != _variables.end(); ++ivars ) { - if ( !isValidIndex( ivars->second._timeSetNumber, _timeSets )) - throw MEDEXCEPTION(badFile << "bad time set index:" << ivars->second._timeSetNumber ); - if ( !isValidIndex( ivars->second._fileSetNumber, _fileSets )) - throw MEDEXCEPTION(badFile << "bad file set index:" << ivars->second._fileSetNumber ); - } - - // check uniqueness of variable names - if ( varNames.size() != _variables.size() ) - cout << badFile << - "Warning: there are different fields with equal names, you may have problems!" << endl; -// throw MEDEXCEPTION(badFile ); - - // As variable does not refer to time set if there is one step (issue 0020113), - // we try to restore the reference - - for ( ivars = _variables.begin(); ivars != _variables.end(); ++ivars ) { - _Variable & var = ivars->second; - if ( var._timeSetNumber.empty() ) - { - // try to find time set with id equal to variable order number - map< int, _TimeSet >::iterator iTs = _timeSets.find( ivars->first ); - if ( iTs != _timeSets.end() && iTs->second._times.size() == 1 ) - var._timeSetNumber = STRING( iTs->second._number ); - else { - // find any time set with 1 time value - for ( iTs = _timeSets.begin(); iTs != _timeSets.end(); ++iTs ) - if ( iTs->second._times.size() == 1 ) - var._timeSetNumber = STRING( iTs->second._number ); - } - } - } -} - -//================================================================================ -/*! - * \brief return number of time steps of a model - */ -//================================================================================ - -int _CaseFileDriver::getNbMeshes() const -{ - if ( _blocked || checkWasRead()) - return 0 ; - if ( _model._timeSetNumber.empty() ) - return 1; - int ts = _ATOI( _model._timeSetNumber ); - map< int, _TimeSet >::const_iterator its = _timeSets.find( ts ); - if ( its == _timeSets.end() ) - throw MEDEXCEPTION(STRING() << "Invalid format of Case file " << _fileName - << "\n Inexistent time set number of a model" ); - return its->second._times.size(); -} - -//================================================================================ -/*! - * \brief Sets all data necessary for meshDriver::read() - * \param meshIndex - time step index - * \param meshDriver - driver - */ -//================================================================================ - -void _CaseFileDriver::setDataFileName(const int meshIndex, - ENSIGHT_MESH_RDONLY_DRIVER* meshDriver) -{ - if ( _blocked || checkWasRead()) - return; - isToIgnore( meshDriver ); // remeber - - meshDriver->_dataFileName = _directory + FILE_SEPARATOR + _model._fileName; - meshDriver->_indexInDataFile = fixWildCardName( meshIndex, - _model._timeSetNumber, - _model._fileSetNumber, - meshDriver->_dataFileName, - meshDriver->_time); - meshDriver->_isGoldFormat = ( _format == ENSIGHT_GOLD ); - meshDriver->_transientMode = ( !_model._timeSetNumber.empty() ); - meshDriver->_singleFileMode = ( !_fileSets.empty() ); - meshDriver->_imedMapKey = STRING(_fileName)<<":"<getMesh(); - ptrMesh->setName(STRING("EnSight mesh ") << meshIndex); -} - -//================================================================================ -/*! - * \brief Return nb of ensight variables - */ -//================================================================================ - -int _CaseFileDriver::getNbVariables() const -{ - return _variables.empty() ? 0 : _variables.rbegin()->first; -} - -//================================================================================ -/*! - * \brief return number of time steps of a variable - */ -//================================================================================ - -int _CaseFileDriver::getNbVarSteps(const int variableIndex) -{ - if ( _blocked || checkWasRead() ) - return 0; - - map< int, _Variable>::const_iterator ivar = _variables.find( variableIndex ); - if ( ivar == _variables.end() ) { - // it can be index of real part of complex variable - ivar = _variables.find( variableIndex+1 ); - if ( ivar == _variables.end() || !contains( "complex", ivar->second._type.c_str() )) { - throw MEDEXCEPTION(STRING( "_CaseFileDriver::getNbVarSteps(): invalid variable index: ") - << variableIndex); - } - } - const _Variable & var = ivar->second; - if ( var._timeSetNumber.empty() ) - return 1; - - const _TimeSet & ts = _timeSets[ _ATOI( var._timeSetNumber)]; - return ts._times.size(); -} - -//================================================================================ -/*! - * \brief return variable index by variable name, return 0 if none found - */ -//================================================================================ - -int _CaseFileDriver::getVariableIndex(const string & varName) const -{ - if ( _blocked || checkWasRead() ) - return 0; - - map< int, _Variable>::const_iterator ivar = _variables.begin(); - for ( ; ivar != _variables.end(); ++ivar ) - { - if ( ivar->second._name == varName ) { - if ( contains( "complex", ivar->second._type.c_str() )) - return ivar->first - 1; // real part of complex variable - return ivar->first; - } - } - // maybe varName is "_Im" - size_t _ImBeg = varName.size() - 3; - if ( varName[ _ImBeg + 0 ] == '_' && - varName[ _ImBeg + 1 ] == 'I' && - varName[ _ImBeg + 2 ] == 'm' ) - { - int i = getVariableIndex( varName.substr( 0, _ImBeg )); - return ( i ? i + 1 : i ); // getVariableIndex() returns index for a real part - } - return 0; -} - -//================================================================================ -/*! - * \brief sets all data necessary for fieldDriver::read() - */ -//================================================================================ - -int _CaseFileDriver::setDataFileName(const int varIndex, - const int stepIndex, - ENSIGHT_FIELD_RDONLY_DRIVER* fieldDriver) -{ - const char* LOC = "_CaseFileDriver::setDataFileName(): "; - if ( _blocked || checkWasRead() ) - return 0; - isToIgnore( fieldDriver ); // remeber - - map< int, _Variable>::iterator ivar = _variables.find( varIndex ); - if ( ivar == _variables.end() ) { - // it can be index of real part of complex variable - ivar = _variables.find( varIndex+1 ); - if ( ivar == _variables.end() || !contains( "complex", ivar->second._type.c_str() )) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "invalid variable index: " << varIndex)); - } - _Variable & var = ivar->second; - - const bool isComplex = contains( "complex", var._type.c_str() ); - const bool isImaginary = ( isComplex && varIndex == ivar->first ); - - // complex scalar per element: [ts] [fs] description Re_fn Im_fn freq - // complex scalar per node: [ts] [fs] description Re_fn Im_fn freq - // complex vector per element: [ts] [fs] description Re_fn Im_fn freq - // complex vector per node: [ts] [fs] description Re_fn Im_fn freq - // constant per case file: [ts] description cvfilename - // constant per case: [ts] description const_value(s) - // scalar per element: [ts] [fs] description filename - // scalar per measured node: [ts] [fs] description filename - // scalar per node: [ts] [fs] description filename - // tensor asym per element: [ts] [fs] description filename - // tensor asym per node: [ts] [fs] description filename - // tensor symm per element: [ts] [fs] description filename - // tensor symm per node: [ts] [fs] description filename - // vector per element: [ts] [fs] description filename - // vector per measured node: [ts] [fs] description filename - // vector per node: [ts] [fs] description filename - - FIELD_* field = fieldDriver->getField(); - - // field name - if ( field->getName().empty() ) { - if ( isImaginary ) - field->setName( var._name + "_Im" ); - else - field->setName( var._name ); - } - // nb of components - list type_parts; - _ASCIIFileReader::split( var._type, type_parts ); - string type1 = type_parts.front(); type_parts.pop_front(); - string type2 = type_parts.front(); type_parts.pop_front(); - int nbComponents = 1; - if ( type1 == "vector" || type2 == "vector" ) - nbComponents = 3; - else if ( type1 == "tensor" ) - nbComponents = ( type2 == "symm" ) ? 6 : 9; - field->setNumberOfComponents( nbComponents ); - - // component names - vector compNames( nbComponents ); - switch ( nbComponents ) { - case 1: - compNames[0] = type1; - break; - case 3: { - const char* xyz[3] = { "X comp","Y comp","Z comp" }; - compNames.assign(xyz, xyz+3); - break; - } - case 6: { - const char* xyz[6] = { "11 comp", "22 comp", "33 comp","12 comp", "13 comp", "23 comp" }; - compNames.assign(xyz, xyz+6); - break; - } - case 9: { - const char* xyz[9] = { "11 comp", "12 comp", "13 comp", "21 comp", "22 comp", "23 comp", - "31 comp", "32 comp", "33 comp" }; - compNames.assign(xyz, xyz+9); - break; - }} - field->setComponentsNames( & compNames[0] ); - - // componet units - vector units( nbComponents ); - vector unitS( nbComponents ), descriptions( nbComponents ); - field->setComponentsUnits(&units[0]); - field->setMEDComponentsUnits(&unitS[0]); - field->setComponentsDescriptions(&descriptions[0]); - - // support type - SUPPORT* sup = const_cast( field->getSupport()); - if ( !sup ) { - field->setSupport( sup = new SUPPORT ); - sup->removeReference(); // sup belongs to field - } - medEntityMesh entity = ( type_parts.back() == "node" ) ? MED_NODE : MED_CELL; - sup->setEntity( entity ); - - // data file name etc. - list fileData_parts; - _ASCIIFileReader::split( var._fileNameOrData, fileData_parts ); - if ( isImaginary ) - fieldDriver->_dataFileName = _directory + FILE_SEPARATOR + *(++fileData_parts.begin()); - else - fieldDriver->_dataFileName = _directory + FILE_SEPARATOR + fileData_parts.front(); - fieldDriver->_indexInDataFile = fixWildCardName( stepIndex, - var._timeSetNumber, - var._fileSetNumber, - fieldDriver->_dataFileName, - fieldDriver->_time); - fieldDriver->_isGoldFormat = ( _format == ENSIGHT_GOLD ); - fieldDriver->_transientMode = ( !var._timeSetNumber.empty() ); - fieldDriver->_singleFileMode = ( !_fileSets.empty() ); - - if ( type1 == "constant" ) { - if ( type_parts.back() == "file" ) { - // append constant values from cvfilename to fileData_parts - string cvfilename = _directory + FILE_SEPARATOR + fileData_parts.back(); - _ASCIIFileReader cvfile( cvfilename ); - fileData_parts.pop_back(); - while ( !cvfile.eof() ) - fileData_parts.push_back( cvfile.getWord() ); - } - if ( (int)fileData_parts.size() < stepIndex ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "can't find value for step " << stepIndex - << " of " << var._type << " " << var._name)); - list::iterator value = fileData_parts.begin(); - advance( value, stepIndex-1 ); - fieldDriver->setConstantValue( *value ); - } - - // mesh data - int meshIndex = 1; - if ( _model._fileName.find('*') != _model._fileName.npos ) { - _TimeSet& ts = _timeSets[ _ATOI( _model._timeSetNumber )]; - vector::iterator t = find( ts._times.begin(), ts._times.end(), fieldDriver->_time ); - if ( t != ts._times.end() ) - meshIndex += distance( ts._times.begin(), t ); - } - fieldDriver->_imedMapKey = STRING(_fileName) << ":" << meshIndex; - - // time - if ( fieldDriver->_transientMode ) { - field->setTime( _ATOF( fieldDriver->_time )); - //field->setOrderNumber( stepIndex ); - field->setIterationNumber( stepIndex ); - } - return meshIndex; -} - -//================================================================================ -/*! - * \brief Throws if case file has not been read else return false - */ -//================================================================================ - -bool _CaseFileDriver::checkWasRead() const throw (MEDEXCEPTION) -{ - if ( _model._fileName.empty() ) - throw MEDEXCEPTION(STRING("Case file ") << _fileName << " has not been successfully read"); - return false; -} - -//================================================================================ -/*! - * \brief replace '*' in file name if any and return index in file - */ -//================================================================================ - -int _CaseFileDriver::fixWildCardName(const int timeStep, - const string & ts, - const string & fs, - string & fileName, - string & time) -{ - int indexInFile = 0; - string fileIndex; - - STRING badFile("Invalid Case file "); - badFile << _fileName << "\n"; - - if ( !fs.empty() ) { // single file mode - const _FileSet & fileSet = _fileSets[ _ATOI( fs ) ]; - if ( fileSet._fileIndex.empty() ) { // no file continuation - indexInFile = timeStep; - } - else { - list::const_iterator nbStepsIt = fileSet._nbStepsInFile.begin(); - list::const_iterator fIndexIt = fileSet._fileIndex.begin(); - int nbSteps = 0; - for ( ; nbStepsIt != fileSet._nbStepsInFile.end(); ++nbStepsIt ) { - if ( nbSteps + *nbStepsIt <= timeStep ) - break; - nbSteps += *nbStepsIt; - } - if ( nbStepsIt == fileSet._nbStepsInFile.end() ) - throw MEDEXCEPTION(LOCALIZED(badFile << "Cant'f find file index for time step " << - timeStep << " in file set " << fs )); - indexInFile = timeStep - nbSteps; - fileIndex = *fIndexIt; - } - } - - string head, queue; - _ASCIIFileReader::split( fileName, head, queue, '*' ); - int indexWidth = fileName.size() - head.size() - queue.size(); - - if ( indexWidth > 0 || !ts.empty() || timeStep > 1 ) { - int tsId = ts.empty() ? 1 : _ATOI( ts ); - const _TimeSet& timeSet = _timeSets[ tsId ]; - if ( timeStep > (int)timeSet._times.size() ) - throw MEDEXCEPTION(LOCALIZED(badFile << "Cant'f find time for time step " << - timeStep << " in time set " << ts )); - time = timeSet._times[ timeStep-1 ]; - if ( timeStep-1 < (int)timeSet._fileIndex.size() ) - fileIndex = timeSet._fileIndex[ timeStep-1 ]; - if ( !indexInFile ) - indexInFile = 1; - } - - if ( indexWidth > 0 ) - { - if ( fileIndex.empty() ) { - throw MEDEXCEPTION(LOCALIZED(badFile << "Can't find file index for time step " << - timeStep << " in time set <" << ts << - "> and file set <" << fs << ">")); - } - if ( indexWidth == (int)fileIndex.size() ) { - fileName = head + fileIndex + queue; - } - else { - fileName = (STRING(head) << setw(indexWidth) << setfill('0') << fileIndex << queue); - } - } - return indexInFile; -} - -//================================================================================ -/*! - * \brief add a mesh to the Case file - */ -//================================================================================ - -void _CaseFileDriver::addMesh(const ENSIGHT_MESH_WRONLY_DRIVER* meshDriver) -{ - if ( _blocked ) - return; - - _meshDrivers.push_back( const_cast( meshDriver )); - - if ( _format == ENSIGHT_6 ) - { - const GMESH* mesh = _meshDrivers.back()->getMesh(); - if ( mesh->getNumberOfElements(MED_CELL, MED_POLYGON) > 0 || - mesh->getNumberOfElements(MED_FACE, MED_POLYGON) > 0 || - mesh->getNumberOfElements(MED_CELL, MED_POLYHEDRA) > 0 ) - throw MEDEXCEPTION - ( compatibilityPb(STRING("Can't write mesh <") << mesh->getName() << - "> since Ensight6 format does not support poly elements," - " use Ensight Gold format instead: call " - "setEnSightFormatForWriting( ENSIGHT_GOLD )")); - } - - isToIgnore( meshDriver ); // remeber -} - -//================================================================================ -/*! - * \brief add a field to the Case file - */ -//================================================================================ - -void _CaseFileDriver::addField(const ENSIGHT_FIELD_WRONLY_DRIVER * theFieldDriver) -{ - if ( _blocked ) - return; - - ENSIGHT_FIELD_WRONLY_DRIVER * fieldDriver = - const_cast( theFieldDriver ); - - FIELD_* field = fieldDriver->getField(); - - STRING problem; - if ( field->getNumberOfValues() == 0 ) - problem << "getNumberOfValues() == 0"; - else if ( field->getGaussPresence() ) - problem << compatibilityPb("Gauss points are not supported by EnSight v8"); - else if ( !field->getSupport() ) - problem << "it has NULL support"; - - switch ( field->getNumberOfComponents() ) { - case 1: - case 3: - case 6: - case 9: break; // ok, supported - case 2: - if ( const GMESH* mesh = field->getSupport()->getMesh() ) - if ( mesh->getSpaceDimension() == 2 ) - break; // we add one component to both mesh and field - default: - problem << - compatibilityPb(STRING("it has ") << field->getNumberOfComponents() - << " components but only 1,3,6 and 9 components are supported by EnSight"); - } - if ( !problem.empty() ) - throw MEDEXCEPTION(STRING("Can't write field <") << field->getName() << - "> to EnSight: " << problem); - - string fieldName = fieldDriver->getFieldName(); - if ( fieldName.empty() ) - fieldName = field->getName(); - if ( fieldName.empty() ) - fieldName = STRING("med_field_")<<_fieldDrivers.size(); - else { // replace illegal characters - string::size_type pos = fieldName.find_first_of( ILLEGAL_FIELD_NAME_CHARACTERS ); - while ( pos != fieldName.npos ) { - fieldName[ pos ] = '_'; - pos = fieldName.find_first_of( ILLEGAL_FIELD_NAME_CHARACTERS ); - } - } - - _fieldDrivers[ fieldName ].push_back( fieldDriver ); - - isToIgnore( fieldDriver ); // remeber -} - -//================================================================================ -/*! - * \brief writing Case file - */ -//================================================================================ - -void _CaseFileDriver::write() throw (MEDEXCEPTION) -{ - if ( _blocked ) - return; - - // Make case file data from added drivers - - bool dataIsRead = !_model._fileName.empty(); - if ( !dataIsRead && _meshDrivers.empty() ) - throw MEDEXCEPTION("no mesh to write into Case file"); - - const int defaultNbDigits = 3; // in file index - - string path, name, ext; - _ASCIIFileReader::split( _fileName, path, name, FILE_SEPARATOR, /*fromBack=*/true); - _ASCIIFileReader::split( name, name, ext, '.', /*fromBack=*/true); - if ( name.empty()) - name = ext; // _fileName: "path/.name" - - list::iterator mDrv = _meshDrivers.begin(); - TFieldDriversByName::iterator fDrv = _fieldDrivers.begin(); - - map< string, string > fileToRenameTo; - - int i, nbOldMeshes = 0, nbNewMeshes = _meshDrivers.size(); - - if ( nbNewMeshes > 0 ) - { - if ( dataIsRead ) - { - // A mesh is going to be added into an existing case file. - // Check that number of parts is same in the existing model - // and in the added ones - string geoFileName = _directory + FILE_SEPARATOR + _model._fileName; - string realGeoFileName = geoFileName, time; - fixWildCardName( 1, - _model._timeSetNumber, - _model._fileSetNumber, - realGeoFileName, - time); - int nbParts = ENSIGHT_MESH_RDONLY_DRIVER::countParts(realGeoFileName, - !_model._fileSetNumber.empty()); - for ( ; mDrv != _meshDrivers.end(); ++mDrv ) - { - int nbNewParts = (*mDrv)->nbPartsToWrite(); - if ( nbParts != nbNewParts ) - throw MEDEXCEPTION(compatibilityPb("Can't add a mesh ") << (*mDrv)->getMesh()->getName() - << "to " << _fileName << " as number of parts in the file " - "differs from number of parts going to be written"); - } - if ( !_model._timeSetNumber.empty() && !_variables.empty() ) { - // Make time set of the model independent of that of variables as - // the number of time steps is apparently becoming different - map< int, _Variable>::iterator ivar = _variables.begin(); - for ( ; ivar != _variables.end(); ++ivar ) { - if ( ivar->second._timeSetNumber == _model._timeSetNumber ) { - int tsNum = _timeSets.rbegin()->first + 1; - _TimeSet& ts = _timeSets[ tsNum ]; - ts._number = tsNum; - ts = _timeSets[ _ATOI( _model._timeSetNumber )]; - _model._timeSetNumber = STRING(tsNum); - break; - } - } - } - string::size_type digitPos = _model._fileName.find('*'); - bool isSeveralFiles = ( digitPos != _model._fileName.npos ); - int nbDigits = defaultNbDigits; - if ( isSeveralFiles ) { - nbDigits = 1; - while ( _model._fileName[ ++digitPos ] == '*' ) - nbDigits++; - } - // Update time set and file set of the model - int nbMeshes; - if ( _model._timeSetNumber.empty() ) { - // old model is static, create a time set - nbMeshes = nbNewMeshes + 1; - int tsNum = _timeSets.empty() ? 1 : _timeSets.rbegin()->first + 1; - _TimeSet& ts = _timeSets[ tsNum ]; - ts._number = tsNum; - _model._timeSetNumber = STRING(tsNum); - // fill the new time set - ts._fileIndex.resize( nbMeshes ); - ts._times.resize ( nbMeshes ); - for ( i = 0; i < nbMeshes; ++i ) { - ts._fileIndex[ i ] = (STRING() << setw(nbDigits) << setfill('0') << i); - ts._times [ i ] = STRING(i); - } - // not to create equal time sets - map< int, _TimeSet >::iterator its, tsEnd = _timeSets.end(); - for ( --tsEnd, its = _timeSets.begin(); its != tsEnd; ++its ) { - if ( ts == its->second ) { - _model._timeSetNumber = STRING( its->first ); - _timeSets.erase( tsEnd ); - break; - } - } - } - else { - // old model is transient, add times and file indices for new meshes - _TimeSet& ts = _timeSets[ _ATOI( _model._timeSetNumber )]; - nbOldMeshes = ts._times.size(); - nbMeshes = nbNewMeshes + nbOldMeshes; - ts._times.resize( nbMeshes ); - double time = 1. + _ATOF( ts._times[ nbOldMeshes-1 ] ); - for ( i = nbOldMeshes; i < nbMeshes; ++i, time+=1. ) - ts._times[ i ] = STRING( time ); - if ( _model._fileSetNumber.empty() ) { // multi-file mode - ts._fileIndex.resize( nbMeshes, string(nbDigits,'0')); - i = nbOldMeshes; - int index = 1 + _ATOI( ts._fileIndex[ i-1 ] ); - for ( ; i < nbMeshes; ++i, ++index ) - ts._fileIndex[ i ] = (STRING() << setw(nbDigits) << setfill('0') << index); - } - else { // single-file mode - _FileSet & fs = _fileSets[ _ATOI( _model._fileSetNumber )]; - for ( i = 0; i < nbNewMeshes; ++i ) - fs._nbStepsInFile.push_back( 1 ); - int index = 1; - if ( fs._fileIndex.empty() ) - fs._fileIndex.push_back(string(nbDigits,'0')); - else - index += _ATOI( fs._fileIndex.back() ); - for ( i = fs._fileIndex.size(); i < nbMeshes; ++i, ++index ) - ts._fileIndex[ i ] = (STRING() << setw(3) << setfill('0') << index); - } - } - // file of the old model is to be renamed - if ( !isSeveralFiles ) { - _model._fileName += string(nbDigits,'*'); - fileToRenameTo[ geoFileName ] = geoFileName + string(nbDigits,'0'); - } - } - else if ( nbNewMeshes > 1 ) - { - // Store meshes into a new case file: create a time set - int tsNum = _timeSets.empty() ? 1 : _timeSets.rbegin()->first + 1; - _TimeSet& ts = _timeSets[ tsNum ]; - ts._number = tsNum; - _model._timeSetNumber = STRING(tsNum); - _model._fileName = name + ".geo" + string(defaultNbDigits, '*'); - // fill the new time set - ts._fileIndex.resize( nbNewMeshes ); - ts._times.resize ( nbNewMeshes ); - for ( i = 0; i < nbNewMeshes; ++i ) { - ts._fileIndex[ i ] = (STRING() << setw(defaultNbDigits) << setfill('0') << i); - ts._times [ i ] = STRING(i); - } - } - else { - // One mesh in a new file - _model._fileName = name + ".geo"; - } - - // Set data to mesh drivers - i = nbOldMeshes + 1; - for ( mDrv = _meshDrivers.begin(); mDrv != _meshDrivers.end(); ++mDrv, ++i ) - { - _CaseFileDriver_User* meshDriver = (*mDrv); - meshDriver->_dataFileName = _directory + FILE_SEPARATOR + _model._fileName; - meshDriver->_indexInDataFile = fixWildCardName( i, - _model._timeSetNumber, - _model._fileSetNumber, - meshDriver->_dataFileName, - meshDriver->_time); - meshDriver->_isGoldFormat = ( _format == ENSIGHT_GOLD ); - meshDriver->_transientMode = ( meshDriver->_indexInDataFile > 0 ); - meshDriver->_singleFileMode = ( !_fileSets.empty() ); - meshDriver->_imedMapKey = STRING(_fileName)<<":"< FDriverByDouble; - - //bool isVarsRead = ( !_variables.empty() ); - for ( ; fDrv != _fieldDrivers.end(); ++fDrv ) - { - const string & fieldName = fDrv->first; - list< ENSIGHT_FIELD_WRONLY_DRIVER* > & drivers = fDrv->second; - - int nbNewSteps = drivers.size(); - - // find out by which parameter fields differ and sort them by the parameter - FDriverByDouble timeMap, iterMap, orderMap; - list< ENSIGHT_FIELD_WRONLY_DRIVER* >::iterator drv; - for ( drv = drivers.begin(); drv != drivers.end(); ++drv ) { - FIELD_* field = (*drv)->getField(); - double time = field->getTime(); - int iter = field->getIterationNumber(); - int ordr = field->getOrderNumber(); - timeMap.insert ( make_pair( time, *drv )); - iterMap.insert ( make_pair( iter, *drv )); - orderMap.insert ( make_pair( ordr, *drv )); - } - FDriverByDouble * sortedDrivers; - FDriverByDouble::iterator tDrv; - if ( (int)timeMap.size() == nbNewSteps ) - sortedDrivers = & timeMap; - else if ( (int)iterMap.size() == nbNewSteps ) - sortedDrivers = & iterMap; - else if ( (int)orderMap.size() == nbNewSteps ) - sortedDrivers = & orderMap; - else { - timeMap.clear(); - sortedDrivers = & timeMap; - for ( drv = drivers.begin(); drv != drivers.end(); ++drv ) { - double time = (*drv)->getField()->getTime(); - if ( ! timeMap.insert( make_pair( time, *drv )).second ) - timeMap.insert( make_pair( timeMap.rbegin()->first + 1., *drv )); - } - } - -// if ( isVarsRead ) { -// int iVar = getVariableIndex( fieldName ); -// if ( iVar > 0 ) { -// // A variable with fieldName already exists, -// // add more time steps to it -// _Variable& var = _variables[ iVar ]; -// _TimeSet& ts = _timeSets[ _ATOI( var._timeSetNumber )]; -// int nbOldSteps = ts._times.size(); -// } -// } - FIELD_* field = drivers.front()->getField(); - int varNum = _variables.size() + 1; - _Variable& var = _variables[ varNum ]; - var._name = fieldName; - switch ( field->getNumberOfComponents() ) { - case 1: var._type = "scalar "; break; - case 2: var._type = "vector "; break;// we add one component to a vector in 2d space - case 3: var._type = "vector "; break; - case 6: var._type = "tensor symm "; break; - case 9: var._type = "tensor asym "; break; - } - if ( field->getSupport()->getEntity() == MED_NODE ) - var._type += "per node"; - else - var._type += "per element"; - var._fileNameOrData = name + "." + fieldName; - - // always create Time set to store time - int nbDigits = defaultNbDigits; - int tsNum = _timeSets.empty() ? 1 : _timeSets.rbegin()->first + 1; - var._timeSetNumber = STRING( tsNum ); - _TimeSet & ts = _timeSets[ tsNum ]; - ts._number = tsNum; - ts._fileIndex.resize( nbNewSteps ); - ts._times.resize ( nbNewSteps ); - tDrv = sortedDrivers->begin(); - for ( i = 0; tDrv != sortedDrivers->end(); ++tDrv, ++i ) { - ts._times [ i ] = (STRING( tDrv->first )); - ts._fileIndex[ i ] = (STRING() << setw(nbDigits) << setfill('0') << i); - } - if ( nbNewSteps > 1 ) - var._fileNameOrData += string( nbDigits, '*' ); - else - ts._fileIndex.clear(); - // not to create equal time sets - map< int, _TimeSet >::iterator its, tsEnd = _timeSets.end(); - for ( --tsEnd, its = _timeSets.begin(); its != tsEnd; ++its ) { - if ( ts == its->second ) { - tsNum = its->first; - var._timeSetNumber = STRING( tsNum ); - _timeSets.erase( tsEnd ); - break; - } - } - tDrv = sortedDrivers->begin(); - for ( i = 1; tDrv != sortedDrivers->end(); ++tDrv, ++i ) { - _CaseFileDriver_User* fieldDriver = tDrv->second; - fieldDriver->_dataFileName = _directory + FILE_SEPARATOR + var._fileNameOrData; - fieldDriver->_indexInDataFile = fixWildCardName( i, - var._timeSetNumber, - var._fileSetNumber, - fieldDriver->_dataFileName, - fieldDriver->_time); - fieldDriver->_isGoldFormat = ( _format == ENSIGHT_GOLD ); - fieldDriver->_transientMode = ( fieldDriver->_indexInDataFile > 0 ); - fieldDriver->_singleFileMode = ( !_fileSets.empty() ); - } - - // do not refer to time set if there is one step (issue 0020113) - if ( nbNewSteps == 1 ) - var._timeSetNumber = ""; - - } // loop on _fieldDrivers - - if ( nbOldMeshes + nbNewMeshes > 1 && !_variables.empty() ) - { - // if there are variables on a transient model, model should not change much, - // nb of entities in all parts with values must be same - if ( nbOldMeshes == 0 ) { - // TODO: check consistency - } - if ( toIgnoreIncompatibility() ) - cout << "Warning: EnSight file will be probably invalid " << _fileName << endl; - else - throw MEDEXCEPTION - (compatibilityPb(STRING("EnSight file will be invalid if fields refer to " - "the second mesh, which differ from the first one too much.\n" - "If you are sure in data correctness, you can suppress " - "this exception by calling setIgnoreIncompatibility(1)\n") - << _fileName)); - } - - // Write a file - - ofstream caseFile( _fileName.c_str(), ios::out ); - if ( !caseFile ) - throw MEDEXCEPTION(STRING("Can't open file for writing ") << _fileName); - - caseFile << "# generated by MEDMEM-to-EnSight driver" << endl << endl - << "FORMAT" << endl - << "type: " << (_format==ENSIGHT_GOLD ? "ensight gold" : "ensight") << endl - << endl - << "GEOMETRY" - << endl - << "model:\t" - << _model._timeSetNumber << " " - << _model._fileSetNumber << " " - << _model._fileName << " \t" - << _model._change_coords_only - << endl << endl; - - // write VARIABLE section - if ( !_variables.empty() ) - { - caseFile << "VARIABLE" << endl; - - map< int, _Variable>::iterator ivar = _variables.begin(); - for ( ; ivar != _variables.end(); ++ivar ) - { - _Variable& var = ivar->second; - caseFile << var._type << ": \t" - << var._timeSetNumber << " " - << var._fileSetNumber << " \t" - << var._name << " \t" - << var._fileNameOrData << endl; - } - caseFile << endl; - } - // write TIME section - if ( !_timeSets.empty() ) - { - caseFile << "TIME" << endl; - - map< int, _TimeSet>::iterator its = _timeSets.begin(); - for ( ; its != _timeSets.end(); ++its ) - { - _TimeSet & ts = its->second; - caseFile << "time set:\t" << ts._number << endl - << "number of steps:\t" << ts._times.size() << endl; - if ( !ts._fileIndex.empty() ) { - STRING numbers( "filename numbers:" ); - for ( unsigned i = 0; i < ts._fileIndex.size(); ++i ) { - if (int( numbers.size() + ts._fileIndex[i].size() + 2) > MAX_LINE_LENGTH ) { - caseFile << numbers << endl; - numbers = STRING(); - } - numbers << " " << ts._fileIndex[i]; - } - caseFile << numbers << endl; - } - STRING times( "time values:" ); - for ( unsigned i = 0; i < ts._times.size(); ++i ) { - if (int( times.size() + ts._times[i].size() + 2 ) > MAX_LINE_LENGTH ) { - caseFile << times << endl; - times = STRING(); - } - times << " " << ts._times[i]; - } - caseFile << times << endl; - } - } - // write FILE section - if ( !_fileSets.empty() ) - { - caseFile << "FILE" << endl; - - map< int, _FileSet >::iterator ifs = _fileSets.begin(); - for ( ; ifs != _fileSets.end(); ++ifs ) - { - _FileSet & fs = ifs->second; - caseFile << "file set: " << fs._number << endl; - - list::iterator nbSteps = fs._nbStepsInFile.begin(); - list::iterator fileIndex = fs._fileIndex.begin(); - for ( ; nbSteps != fs._nbStepsInFile.end(); ++nbSteps ) - { - if ( fileIndex != fs._fileIndex.end() ) - caseFile << "filename index: " << *fileIndex++; - caseFile << "number of steps: " << *nbSteps << endl; - } - } - } - - caseFile.close(); - -} // _CaseFileDriver::write() - - -//================================================================================ -/*! - * \brief _CaseFileDriver_User constructor - */ -//================================================================================ - -_CaseFileDriver_User::_CaseFileDriver_User(const string & caseFileName, - med_mode_acces mode) - : GENDRIVER( caseFileName, mode, ENSIGHT_DRIVER ), _imed(0) -{ -} - -//================================================================================ -/*! - * \brief take data from other driver - */ -//================================================================================ - -void _CaseFileDriver_User::merge( const GENDRIVER& driver) -{ - const _CaseFileDriver_User* other = dynamic_cast< const _CaseFileDriver_User* >( &driver ); - if ( other ) { - _dataFileName = other->_dataFileName ; - _isGoldFormat = other->_isGoldFormat ; - _transientMode = other->_transientMode ; - _singleFileMode = other->_singleFileMode ; - _indexInDataFile = other->_indexInDataFile; - _time = other->_time ; - _imed = other->_imed ; - _imedMapKey = other->_imedMapKey ; - } -} - -//================================================================================ -/*! - * \brief analyse if data file is binary - */ -//================================================================================ - -bool _CaseFileDriver_User::isBinaryDataFile(const string& dataFileName) -{ -#ifdef WIN32 - int _file = ::_open (dataFileName.c_str(), _O_RDONLY|_O_BINARY); -#else - int _file = ::open (dataFileName.c_str(), O_RDONLY); -#endif - char buf[81]; - int nBytesRead = ::read (_file, buf, 80); - - bool isBinary = true; - - const char cBin[] = "C Binary"; - const char fBin[] = "Fortran Binary"; - if ( strncmp( buf, cBin, sizeof(cBin)-1) != 0 && - strncmp( buf, fBin, sizeof(fBin)-1) != 0 ) - { - for ( int i = nBytesRead-1; i >= 0 && isBinary; --i ) - isBinary = ( buf[ i ] != '\n' ); - } - - ::close (_file); - - return isBinary; -} - -//================================================================================ -/*! - * \brief return part number to write support with, zero in failure case - */ -//================================================================================ - -int _CaseFileDriver_User::getPartNumber(const SUPPORT* support) const -{ - bool isGroup = ( dynamic_cast( support )); - bool isForField = ( dynamic_cast( this )); - medEntityMesh entity = support->getEntity(); - const GMESH* mesh = support->getMesh(); - - // for supports on all entities, reserve numbers corresponding to entity - bool isOnAll = support->isOnAllElements(); - if (!isOnAll && mesh ) { - int nbMeshElem = mesh->getNumberOfElements(entity, MED_ALL_ELEMENTS); - int nbSuppElem = support->getNumberOfElements(MED_ALL_ELEMENTS); - isOnAll = ( nbSuppElem == nbMeshElem ); - } - if ( !isGroup ) { - if ( !isOnAll ) - return 0; - else if ( entity == MED_NODE ) - return 1 + MED_CELL; // all nodes are described with all CELLs - else - return 1 + entity; - } - if ( isForField && isOnAll ) { - if ( entity == MED_NODE ) - return 1 + MED_CELL; // all nodes are described with all CELLs - else - return 1 + entity; - } - if ( !mesh ) - return 0; - - int partNum = MED_ALL_ENTITIES + 1; - for ( int ent = MED_CELL; ent < MED_ALL_ENTITIES; ++ent ) { - entity = (medEntityMesh) ent; - int nbGroups = mesh->getNumberOfGroups(entity); - if ( entity != support->getEntity() ) { - partNum += nbGroups; - } - else { - for ( int i=1; i<=nbGroups; ++i, ++partNum) - if ( support == mesh->getGroup( entity, i )) - return partNum; - } - } - throw MED_EXCEPTION - ( LOCALIZED( STRING("Can't find GROUP ") << support->getName() << " in its MESH")); - - return 0; -} - -//================================================================================ -/*! - * \brief Return true if we strore an enetuty to EnSight - */ -//================================================================================ - -bool _CaseFileDriver_User::isToWriteEntity(const medEntityMesh entity, - const GMESH* mesh) -{ - if ( entity == MED_NODE ) - return mesh->getNumberOfNodes() > 0; - - if ( mesh->getNumberOfElements( entity, MED_ALL_ELEMENTS ) < 1 ) - return false; - if ( entity == MED_CELL ) - return true; - int meshDim = mesh->getTypes(MED_CELL)[0] / 100; - if ( entity == MED_FACE ) - return ( meshDim == 3 || meshDim == 5 ); - if ( entity == MED_EDGE ) - return ( meshDim == 2 || meshDim == 4 ); - - return false; -} - -//================================================================================ -/*! - * \brief Return nodes of non-nodal support, which is not on all entities - */ -//================================================================================ - -void _CaseFileDriver_User::getSupportNodes(const SUPPORT* support, map & nodeIds) -{ - medEntityMesh entity = support->getEntity(); - - const medConnectivity conType = MED_NODAL; - const medGeometryElement allGeoms = MED_ALL_ELEMENTS; - const int * connectivity = 0; - const int * elemConnectivity = 0; - const int * index = 0; - const int * number = 0; - int j; - - if ( support->isOnAllElements() ) - { - if ( entity == MED_NODE ) { // all NODES - int numberOfCell = support->getNumberOfElements(allGeoms); - while ( numberOfCell ) { - nodeIds.insert( nodeIds.begin(), make_pair( numberOfCell, numberOfCell )); - --numberOfCell; - } - } - else { - const MESH* mesh = support->getMesh()->convertInMESH(); - int conLength = 0; - connectivity = mesh->getConnectivity (conType, entity, allGeoms); - conLength = mesh->getConnectivityLength(conType, entity, allGeoms); - while ( conLength-- ) nodeIds[ *connectivity++ ]; - mesh->removeReference(); - } - return; - } - - if ( entity == MED_NODE ) - { - number = support->getNumber(MED_ALL_ELEMENTS); - int numberOfCell = support->getNumberOfElements(MED_ALL_ELEMENTS); - for (j=0; j < numberOfCell; j++) - nodeIds.insert(nodeIds.end(), make_pair( number[j], j )); - return; - } - - number = support->getNumber(MED_ALL_ELEMENTS); - int numberOfCell = support->getNumberOfElements(MED_ALL_ELEMENTS); - const MESH* mesh = support->getMesh()->convertInMESH(); - index = mesh->getConnectivityIndex( MED_NODAL, entity); - connectivity = mesh->getConnectivity( MED_NODAL, entity, MED_ALL_ELEMENTS); - for ( j = 0; j < numberOfCell; ++j ) - { - int elem = number[j]; - elemConnectivity = connectivity + index[elem-1]-1; - const int* connEnd = connectivity + index[elem]-1; - while ( elemConnectivity < connEnd ) - nodeIds[ *elemConnectivity++ ]; - } - mesh->removeReference(); -} - -//================================================================================ -/*! - * \brief method called by mesh driver at reading to store data to be used by - * field driver - */ -//================================================================================ - -void _CaseFileDriver_User::setInterData(_InterMed* imed ) -{ - theInterMedMap[ _imedMapKey ] = imed; - if ( ENSIGHT_MESH_DRIVER* mDrv = dynamic_cast( this )) { - imed->_medMesh = dynamic_cast( mDrv->getMesh() ); - imed->_isOwnMedMesh = false; - } - else - imed->_medMesh = 0; -} - -//================================================================================ -/*! - * \brief for field driver to get mesh data - */ -//================================================================================ - -_InterMed* _CaseFileDriver_User::getInterData() -{ - return _imed = getMeshData( _imedMapKey ); -} - -//================================================================================ -/*! - * \brief return _SubPart by its description - */ -//================================================================================ - -_SubPart* _CaseFileDriver_User::getSubPart(const _SubPartDesc & descriptor) - throw (MEDEXCEPTION) -{ - if ( !_imed ) - _imed = getMeshData( _imedMapKey ); - - map< _SubPartDesc, _SubPart >::iterator descPart = - _imed->_subPartDescribed.find( descriptor ); - - if ( descPart != _imed->_subPartDescribed.end() ) - return & descPart->second; - - if ( descriptor == _SubPartDesc::globalCoordDesc() ) - return 0; // if the mesh is structured, there are no global coordinates (EnSight 6) - - throw MEDEXCEPTION(LOCALIZED(STRING("No mesh info for part ") << descriptor.partNumber() - << " " << descriptor.typeName())); -} - -//================================================================================ -/*! - * \brief return _Support by its description - */ -//================================================================================ - -_Support* _CaseFileDriver_User::getSupport(const _SupportDesc & descriptor, - const medEntityMesh entity) - throw (MEDEXCEPTION) -{ - const char* LOC = "_CaseFileDriver_User::getSupport(): "; - if ( !_imed ) - _imed = getMeshData( _imedMapKey ); - - _imed->treatGroupes(); - - if ( _imed->_supportDescribed.empty() && !_imed->_subPartDescribed.empty() ) - { - // fill _supportDescribed with _Support's corresponding to EnSight parts - for (unsigned int i=0; i < _imed->groupes.size(); ++i) - { - _groupe& grp = _imed->groupes[i]; - if ( !grp.medGroup ) continue; - - vector grpIndices(1,i); - if ( !grp.groupes.empty() ) - grpIndices.assign( grp.groupes.begin(), grp.groupes.end()); - - _SupportDesc supDescriptor; - // look for a subpart for each _groupe - vector::iterator grIndex = grpIndices.begin(), grIndexEnd = grpIndices.end(); - for ( ; grIndex != grIndexEnd; ++grIndex ) - { - map< _SubPartDesc, _SubPart >::iterator descSub; - for ( descSub = _imed->_subPartDescribed.begin(); - descSub != _imed->_subPartDescribed.end(); - ++descSub) - { - if ( descSub->second.myCellGroupIndex == *grIndex ) { - supDescriptor.insert( descSub->first ); - break; - } - } - } - if ( supDescriptor.size() == grpIndices.size() ) { - _Support & sup = _imed->_supportDescribed[ supDescriptor ]; - sup.setGroup( & grp ); - } - } - } - - // find the support by its description - map< _SupportDesc, _Support >::iterator descSup = - _imed->_supportDescribed.find( descriptor ); - - // Create a new support - if ( descSup == _imed->_supportDescribed.end() || !descSup->second.medSupport( entity )) - { - // create a _groupe composed of groups corresponding to subparts - _imed->groupes.push_back(_groupe()); - _groupe& grp = _imed->groupes.back(); - grp.groupes.reserve( descriptor.size() ); - - // to detect dimension change within a support group - set dimensions; - - // fill grp with sub-group indices - _SupportDesc::const_iterator subPartDesc = descriptor.begin(); - for ( ; subPartDesc != descriptor.end(); ++subPartDesc ) - { - const _SubPart* subPart = getSubPart(*subPartDesc); - if ( !subPart ) - throw MEDEXCEPTION(LOCALIZED(STRING("No mesh info for ") << *subPartDesc)); - - int groupIndex = - (entity == MED_NODE) ? subPart->myNodeGroupIndex : subPart->myCellGroupIndex; - if ( groupIndex < 1 ) { - if ( entity == MED_NODE ) - { - // make a _groupe of nodes - _imed->groupes.push_back(_groupe()); - groupIndex = subPart->myNodeGroupIndex = _imed->groupes.size(); - _groupe & groupe = _imed->groupes.back(); - groupe.mailles.resize( subPart->myNbNodes ); - - _maille ma( MED_POINT1, 1 ); - ma.sommets.resize( 1 ); - map< int, _noeud >::iterator n = subPart->myFirstNode; - for (int i = 0; i < subPart->myNbNodes; ++i, ++n ) { - ma.sommets[0] = n; - ma.setOrdre( n->second.number ); - groupe.mailles[i] = _imed->insert(ma); - } - } - else - { - throw MEDEXCEPTION(LOCALIZED(STRING("No cell info for ") << *subPartDesc)); - } - } - grp.groupes.push_back( groupIndex ); - - // find out subpart dimension - if ( entity != MED_NODE ) - dimensions.insert( _imed->groupes[ groupIndex-1 ].maille(0).dimensionWithPoly() ); - } - // check if MEDMEM allows creating such a support - if ( dimensions.size() > 1 ) - throw MEDEXCEPTION - (compatibilityPb(LOC) << "can't create a SUPPORT for the field from " - << _dataFileName << ", since it includes different mesh entities"); - - ENSIGHT_MESH_RDONLY_DRIVER::makeGroup( grp, *_imed ); - - // add _Support - descSup = _imed->_supportDescribed.insert( make_pair( descriptor, _Support() )).first; - _Support & sup = descSup->second; - sup.setGroup( & grp ); - - } // new SUPPORT creation - - _Support* sup = & descSup->second; - - // remove temporary mesh from med SUPPORT - if ( _imed->_isOwnMedMesh ) - { - if ( sup->medSupport( entity )->getMesh() == _imed->_medMesh ) - _imed->_medMesh->addReference(); // don't want _medMesh to die. - sup->medSupport( entity )->setMesh( 0 ); - sup->medSupport( entity )->setMeshName( _imed->_medMesh->getName() ); - } - - return sup; -} - -//================================================================================ -/*! - * \brief check possibility to open a file with a given mode - */ -//================================================================================ - -bool _CaseFileDriver_User::canOpenFile(const string& fileName, - med_mode_acces mode) -{ - bool ok = false; - if ( mode == WRONLY ) { - fstream file( fileName.c_str(), - ios::app | ios_base::out ); // not to overwrite it, just to check - ok = bool(file); - } - else { - fstream file( fileName.c_str(), ios::in ); - ok = bool(file); - } - return ok; -} - -//================================================================================ -/*! - * \brief _CaseFileDriver_User destructor - */ -//================================================================================ - -_CaseFileDriver_User::~_CaseFileDriver_User() -{ - if ( _imed ) - _imed->_nbUsers--; - unregister( this ); -} - -//================================================================================ -/*! - * \brief Search substring in a string - */ -//================================================================================ - -bool contains( const char* what, const char* inString ) -{ - size_t whatLen = strlen( what ); - size_t inLen = strlen( inString ); - return - ( search( inString, inString+inLen, what, what + whatLen) != inString+inLen ); -} - -//================================================================================ -/*! - * \brief store subPart data - */ -//================================================================================ - -void _InterMed::addSubPart(const _SubPart& theSubPart) -{ - if ( _needSubParts ) { - _SubPart & subPart = _subPartDescribed[ theSubPart.getDescriptor() ]; - subPart = theSubPart; - if ( subPart.myCellGroupIndex > 0 ) { - _groupe & groupe = this->groupes[ subPart.myCellGroupIndex-1 ]; - subPart.myFirstCell = groupe.mailles.begin(); - } - } -} -//================================================================================ -/*! - * \brief delete intermediate med data - */ -//================================================================================ - -_InterMed::~_InterMed() -{ - if ( _isOwnMedMesh ) - { - // remove MEDMEM groups not belonging to _medMesh - for (unsigned int i=0; i < _intermediateMED::groupes.size(); ++i) - { - _groupe& grp = _intermediateMED::groupes[i]; - if ( !grp.medGroup ) continue; - vector groups = _medMesh->getGroups( grp.medGroup->getEntity() ); - if ( find( groups.begin(), groups.end(), grp.medGroup ) == groups.end() ) - grp.medGroup->removeReference(); - } - if(_medMesh) _medMesh->removeReference(); - _medMesh=0; - } -} -//================================================================================ -/*! - * \brief For a node, find its index in the supporting GROUP - */ -//================================================================================ - -int _Support::getIndex( const pair& inode) -{ - if ( myNodeGroup->relocMap.empty() ) // on all and not self intersecting support - return abs( inode.second.number ); - - map::iterator ordreIndex = myNodeGroup->relocMap.find( abs( inode.second.number )); - if ( ordreIndex == myNodeGroup->relocMap.end() ) - throw MEDEXCEPTION(LOCALIZED(STRING("No index found for ") << inode.second)); -// map < int, int >::iterator numIndex = myNodeRelocMap.find( node->number ); -// if ( numIndex == myNodeRelocMap.end() ) -// throw MEDEXCEPTION(STRING("No index found for node ") << node->number); - - return ordreIndex->second; -} - -//================================================================================ -/*! - * \brief For a cell, return its index in the supporting GROUP - */ -//================================================================================ - -int _Support::getIndex( const _groupe::TMaille& cell) -{ - if ( myCellGroup->relocMap.empty() ) // on all and not self intersecting support - return cell->ordre(); - - map::iterator ordreIndex = myCellGroup->relocMap.find( cell->ordre() ); - if ( ordreIndex == myCellGroup->relocMap.end() ) - throw MEDEXCEPTION(LOCALIZED(STRING("No index found for ") << *cell)); - - return ordreIndex->second; -} - -//================================================================================ -/*! - * \brief Return med geom type for a subPart element - */ -//================================================================================ - -// medGeometryElement _Support::getType( const pair& node) -// { -// return myNodeGroup->medGroup.getTypes[0]; -// } - -// //================================================================================ -// /*! -// * \brief Return med geom type for a subPart element -// */ -// //================================================================================ - -// medGeometryElement _Support::getType( const _groupe::TMaille& cell) -// { -// return cell->geometricType; -// } - -//================================================================================ -/*! - * \brief Set med support - */ -//================================================================================ - -void _Support::setGroup( _groupe* group ) -{ - if ( group->medGroup ) { - if ( group->medGroup->getEntity() == MED_NODE ) - myNodeGroup = group; - else - myCellGroup = group; - } - else { - throw MEDEXCEPTION(LOCALIZED("_Support::setGroup(): med GROUP is NULL")); - } -} - -//================================================================================ -/*! - * \brief Return med group correspoding to entity - */ -//================================================================================ - -SUPPORT* _Support::medSupport( medEntityMesh entity ) -{ - if ( entity == MED_NODE ) - return myNodeGroup ? myNodeGroup->medGroup : 0; - else - return myCellGroup ? myCellGroup->medGroup : 0; -} - -//================================================================================ -/*! - * \brief print _SubPartDesc - */ -//================================================================================ - -std::ostream& operator << (std::ostream& os, const _SubPartDesc& desc) -{ - if ( desc == _SubPartDesc::globalCoordDesc() ) - os << "'global coordinates'"; - else - os << "<'part " << desc.partNumber() << "', '" << desc.typeName() << "'>"; - return os; -} - -//================================================================================ -/*! - * \brief Constructor of ASCIIFileReader - */ -//================================================================================ - -_ASCIIFileReader::_ASCIIFileReader(const string& fileName) throw (MEDEXCEPTION) -{ -#ifdef WIN32 - _file = ::_open (fileName.c_str(), _O_RDONLY|_O_BINARY); -#else - _file = ::open (fileName.c_str(), O_RDONLY); -#endif - if (_file >= 0) - { - _start = new char [BUFFER_SIZE]; - _ptr = _start; - _eptr = _start; - } - else - { - throw MEDEXCEPTION(STRING("Can't read from ")<= _start ) - isASCII = (*ptr-- == '\n'); - _isWin = ( *ptr == '\r'); - if ( !isASCII ) - throw MEDEXCEPTION(STRING("Not ASCII file ")< 0) { - char* tmpBuf = new char [nBytesRest]; - memcpy (tmpBuf, _ptr, nBytesRest); - memcpy (_start, tmpBuf, nBytesRest); - delete [] tmpBuf; - } else { - nBytesRest = 0; - } - _ptr = _start; - const int nBytesRead = ::read (_file, - &_start [nBytesRest], - BUFFER_SIZE - nBytesRest); - nBytesRest += nBytesRead; - _eptr = &_start [nBytesRest]; - - // skip spaces at file end - if ( nBytesRest < MAX_LINE_LENGTH ) { - while ( isspace( *_ptr )) _ptr++; - nBytesRest = _eptr - _ptr; - } - } - return nBytesRest < 1; -} - -//================================================================================ -/*! - * \brief read out given data - */ -//================================================================================ - -void _ASCIIFileReader::skip(int nbVals, int nbPerLine, int valWidth) -{ - int nbLines = (nbVals + nbPerLine - 1) / nbPerLine; - int width = nbVals * valWidth; - skip( width, nbLines ); -} - -//================================================================================ -/*! - * \brief read out width chars and nbLines line-ends - */ -//================================================================================ - -void _ASCIIFileReader::skip(int width, int nbLines) -{ - width += nbLines; // to skip '\n' - if ( _isWin ) - width += nbLines; // to skip '\r' - - _ptr += width; - int nBytesRest = _eptr - _ptr; - while ( nBytesRest < 0 ) { - width = -nBytesRest; - if ( eof() ) return; - _ptr += width; - nBytesRest = _eptr - _ptr; - } -} - -//================================================================================ -/*! - * \brief Read a next line from the file - */ -//================================================================================ - -char* _ASCIIFileReader::getLine() throw (MEDEXCEPTION) -{ - if ( eof() ) - throw MEDEXCEPTION("Unexpected EOF"); - - // Check the buffer for the end-of-line - char * ptr = _ptr; - while (true) - { - // Check for end-of-the-buffer, the ultimate criterion for termination - if (ptr >= _eptr) - { - //_eptr[-1] = '\0'; - _eptr[0] = '\0'; - break; - } - // seek the line-feed character - if (ptr[0] == '\n') - { - if ( ptr > _start && // avoid "Invalid read" error by valgrind - ptr[-1] == '\r') - ptr[-1] = '\0'; - ptr[0] = '\0'; - ++ptr; - break; - } - ++ptr; - } - // Output the result - char * line = _ptr; - _ptr = ptr; - - return line; -} - -//================================================================================ -/*! - * \brief - */ -//================================================================================ - -bool _ASCIIFileReader::lookAt( const char* text ) -{ - while ( isspace(*_ptr)) ++_ptr; - return ( strncmp( _ptr, text, strlen( text )) == 0 ); -} - -//================================================================================ -/*! - * \brief Read a next word from the file - */ -//================================================================================ - -string _ASCIIFileReader::getWord() -{ - if ( eof() ) - return ""; - - // skip spaces - while ( isspace(*_ptr)) ++_ptr; - if ( _ptr >= _eptr ) - return ""; - - // skip not spaces - char* word = _ptr++; - while ( !isspace(*_ptr)) ++_ptr; - - return string( word, _ptr - word ); -} - -//================================================================================ -/*! - * \brief Return true if TIME_STEP_BEG follows and skips TIME_STEP_BEG line - */ -//================================================================================ - -bool _ASCIIFileReader::isTimeStepBeginning() -{ - if ( eof() ) throw MEDEXCEPTION(LOCALIZED("Unexpected EOF")); - - while ( isspace(*_ptr)) ++_ptr; - - if ( strncmp( _ptr, TIME_STEP_BEG, TIME_STEP_BEG_LEN ) != 0 ) - return false; - - _ptr += TIME_STEP_BEG_LEN; - while ( isspace(*_ptr)) ++_ptr; - return true; -} - -//================================================================================ -/*! - * \brief Return true if TIME_STEP_END follows and skips TIME_STEP_END line - */ -//================================================================================ - -bool _ASCIIFileReader::isTimeStepEnd() -{ - if ( eof() ) return true; - - while ( isspace(*_ptr)) ++_ptr; - - if ( strncmp( _ptr, TIME_STEP_END, TIME_STEP_END_LEN ) != 0 ) - return false; - - _ptr += TIME_STEP_END_LEN; - while ( isspace(*_ptr)) ++_ptr; - return true; -} - - -//================================================================================ -/*! - * \brief divide a string into two parts - */ -//================================================================================ - -int _ASCIIFileReader::split(const string& str, - string & part1, - string & part2, - const char separator, - const bool fromBack) -{ - int nbParts = 0; - string parts[2]; - const char* ptr1 = str.c_str(); - const char* back = ptr1 + str.size(); - for (nbParts = 0; nbParts < 2; ++nbParts ) { - // skip spaces before the current part - while ( isspace(*ptr1)) ++ptr1; - if ( !*ptr1) break; - // find end of the part and beginning of the next part - const char* ptr2 = ptr1; - const char* nextBeg = back; - if ( nbParts > 0 ) { - ptr2 = back; - } - else if ( fromBack ) { - ptr2 = back; - string::size_type pos = str.rfind( separator ); - if ( pos != str.npos ) { - ptr2 = & str[ pos ]; - nextBeg = ptr2 + 1; - if ( separator != ' ') - while ( *nextBeg && *nextBeg == separator ) ++nextBeg; - } - } - else if ( separator == ' ' ) { - while ( *ptr2 && !isspace(*ptr2)) ++ptr2; - if ( *ptr2 ) nextBeg = ptr2 + 1; - } - else { - while ( *ptr2 && *ptr2 != separator ) ++ptr2; - if ( *ptr2 ) { - nextBeg = ptr2 + 1; - while ( *nextBeg && *nextBeg == separator ) ++nextBeg; - } - } - //if ( !*ptr2) --ptr2; - // skip spaces after the current part - while ( ptr2 > ptr1 && isspace(ptr2[-1])) --ptr2; - parts[ nbParts ] = string( ptr1, ptr2-ptr1 ); - ptr1 = nextBeg; - } - part1 = parts[0]; - part2 = parts[1]; - return nbParts; -} - -//================================================================================ -/*! - * \brief divide a string into parts, return nb of parts - */ -//================================================================================ - -int _ASCIIFileReader::split(const string& str, - list & parts, - const char separator, - const bool fromBack) -{ - parts.clear(); - if ( str.empty() ) - return 0; - int nbParts = 0; - const char* ptr1 = str.c_str(); - const char* back = ptr1 + str.size(); - if ( fromBack ) { - swap( ptr1, back ); - while (1) { - // skip spaces after the current part - while ( isspace(ptr1[-1])) --ptr1; - if ( ptr1 <= back ) break; - // find beginning of the part - const char* ptr2 = ptr1 - 1; - if ( separator == ' ' ) - while ( ptr2 > back && !isspace(ptr2[-1])) --ptr2; - else - while ( ptr2 > back && ptr2[-1] != separator ) --ptr2; - //if ( !*ptr2) --ptr2; - const char* sepPtr = ptr2; - // skip spaces before the current part - while ( isspace(*ptr2)) ++ptr2; - parts.push_back( string( ptr2, ptr1-ptr2 )); - ++nbParts; - ptr1 = sepPtr - 1; - } - } - else { - while (1) { - // skip spaces before the current part - while ( isspace(*ptr1)) ++ptr1; - if ( ptr1 >= back) break; - // find end of the part - const char* ptr2 = ptr1 + 1; - if ( separator == ' ' ) - while ( *ptr2 && !isspace(*ptr2)) ++ptr2; - else - while ( *ptr2 && *ptr2 != separator ) ++ptr2; - //if ( !*ptr2) --ptr2; - const char* sepPtr = ptr2; - // skip spaces after the current part - while ( ptr2 > ptr1 && isspace(ptr2[-1])) --ptr2; - parts.push_back( string( ptr1, ptr2-ptr1 )); - ++nbParts; - ptr1 = sepPtr + int( sepPtr < back ); - } - } - return nbParts; -} - -//================================================================================ -/*! - * \brief check if a string contains only digits - */ -//================================================================================ - -bool _ASCIIFileReader::isDigit(const string& str, const bool real) -{ - const char* s = str.c_str(); - if ( real ) { - while ( *s ) { - char c = *s++; - if ( !isdigit(c) && c!='-' && c!='+' && c!='.' && c!=',' && c!='E' && c!='e') - return false; - } - } - else { - while ( *s ) { - if ( !isdigit( *s++ )) - return false; - } - } - return true; -} - -//================================================================================ -/*! - * \brief Destructor of ASCIIFileReader closes its file - */ -//================================================================================ - -_ASCIIFileReader::~_ASCIIFileReader() -{ - if (_file >= 0) - { - ::close (_file); - delete [] _start; - } -} - -//================================================================================ -/*! - * \brief Constructor of _BinaryFileReader opens its file - */ -//================================================================================ - -_BinaryFileReader::_BinaryFileReader(const string& fileName) throw (MEDEXCEPTION) - : _exception(STRING("Unexpected EOF ") << fileName), _mySwapBytes(false) -{ -#ifdef WIN32 - _file = ::_open (fileName.c_str(), _O_RDONLY|_O_BINARY); -#else - _file = ::open (fileName.c_str(), O_RDONLY); -#endif - - if (_file < 0) - throw MEDEXCEPTION(STRING("Can't read from ") << fileName); - - _maxPos = ::lseek( _file, 0, SEEK_END); - _pos = ::lseek( _file, 0, SEEK_SET); -} - -//================================================================================ -/*! - * \brief Destructor of _BinaryFileWriter closes its file - */ -//================================================================================ - -_BinaryFileReader::~_BinaryFileReader() -{ - if (_file >= 0) - ::close (_file); -} - -//================================================================================ -/*! - * \brief rewind the file backward - */ -//================================================================================ - -void _BinaryFileReader::rewind() -{ - _pos = ::lseek( _file, 0, SEEK_SET); -} - -//================================================================================ -/*! - * \brief size of not read file portion in sizeof(int) - */ -//================================================================================ - -int _BinaryFileReader::moreValuesAvailable() const -{ - return (_maxPos - _pos) / sizeof(int); // believe that sizeof(int) == sizeof(float) -} - -//================================================================================ -/*! - * \brief Return true if the whole file has been read - */ -//================================================================================ - -bool _BinaryFileReader::eof() -{ - return _pos >= _maxPos; -} - -//================================================================================ -/*! - * \brief Skips given nb of bytes - */ -//================================================================================ - -void _BinaryFileReader::skip(int size) throw (MEDEXCEPTION) -{ - if ( _pos + size > _maxPos ) - throw _exception; - off_t newPos = ::lseek( _file, size, SEEK_CUR); - if ( newPos < _pos + size ) - throw _exception; - _pos = newPos; -} - -//================================================================================ -/*! - * \brief Read lines until TIME_STEP_BEG encounters - */ -//================================================================================ - -void _BinaryFileReader::skipTimeStepBeginning() throw (MEDEXCEPTION) -{ - bool tsbReached = false; - while ( !tsbReached ) { - TStrOwner line( getLine() ); - tsbReached = ( strncmp( line, TIME_STEP_BEG, TIME_STEP_BEG_LEN ) == 0 ); - } -} - -//================================================================================ -/*! - * \brief Constructor of _BinaryFileWriter opens its file - */ -//================================================================================ - -_BinaryFileWriter::_BinaryFileWriter(const string& fileName) throw (MEDEXCEPTION) - : _exception(STRING("Can't write into ") << fileName) -{ -#ifdef WIN32 - _file = ::_open (fileName.c_str(), _O_WRONLY|_O_BINARY|_O_TRUNC); -#else - _file = ::open (fileName.c_str(), O_WRONLY|O_TRUNC); //length shall be truncated to 0 -#endif - - if (_file < 0) - throw _exception; -} - -//================================================================================ -/*! - * \brief Destructor of _BinaryFileWriter closes its file - */ -//================================================================================ - -_BinaryFileWriter::~_BinaryFileWriter() -{ - if (_file >= 0) - ::close (_file); -} - -//================================================================================ -/*! - * \brief Write string - */ -//================================================================================ - -void _BinaryFileWriter::addString(const char* str) throw (MEDEXCEPTION) -{ - size_t len = strlen( str ); - if ((int) len > MAX_LINE_LENGTH ) - throw MEDEXCEPTION - (LOCALIZED(STRING("_BinaryFileWriter::addString(), too long string (>80):\n") << str)); - - string buffer( str, len ); - // avoid "Syscall param write(buf) points to uninitialised byte(s)" error by valgrind - buffer += string(MAX_LINE_LENGTH, ' '); - buffer[ len ] = '\0'; - buffer[ MAX_LINE_LENGTH-1 ] = '\0'; // to have line-end within - - add( buffer.c_str(), MAX_LINE_LENGTH ); -} - - - -} // end namespace MEDMEM_ENSIGHT diff --git a/src/MEDMEM/MEDMEM_EnsightUtils.hxx b/src/MEDMEM/MEDMEM_EnsightUtils.hxx deleted file mode 100644 index 8030342c1..000000000 --- a/src/MEDMEM/MEDMEM_EnsightUtils.hxx +++ /dev/null @@ -1,941 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : MEDMEM_EnsightUtils.hxx -// Created : Tue May 27 12:24:11 2008 -// Author : Edward AGAPOV (eap) -// -#ifndef MEDMEM_EnsightUtils_HeaderFile -#define MEDMEM_EnsightUtils_HeaderFile - -#include "MEDMEM_GenDriver.hxx" -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_DriverTools.hxx" -#include "MEDMEM_Mesh.hxx" -//#include "MEDMEM_Field.hxx" - -#include -#include -#include - -#ifdef WIN32 -# define isnan _isnan -#else -# include -#endif - -namespace MEDMEM { - - // ============================================================================== - /*! - * \brief Functions to set writing format. - * Default format is EnSight6 ASCII - */ - // ============================================================================== - - enum EnSightFormat { ENSIGHT_6, ENSIGHT_GOLD }; - - void MEDMEM_EXPORT setEnSightFormatForWriting (EnSightFormat format, bool isBinary); - - EnSightFormat getEnSightFormatForWriting(); - bool isBinaryEnSightFormatForWriting(); - - // ============================================================================== - /*! - * \brief To raise or not if MEDMEM-EnSight incompatibility encounters or suspected - * - * Default is to raise. - * To ignore incompatibility is useful for debug of EnSigt reading and - * for suppressing exceptions in some suspicious cases, for example writing - * several meshes and fields. - * Incompatibility exception includes "EnSight-MEDMEM compatibility problem" string. - * Not all incompatibility exceptions can be suppressed. - */ - // ============================================================================== - - void MEDMEM_EXPORT setIgnoreIncompatibility(bool toIgnore=true); -} - -namespace MEDMEM { - class ENSIGHT_MESH_RDONLY_DRIVER; - class ENSIGHT_FIELD_RDONLY_DRIVER; - class ENSIGHT_MESH_WRONLY_DRIVER; - class ENSIGHT_FIELD_WRONLY_DRIVER; -} - -// ============================================================================== -namespace MEDMEM_ENSIGHT { // INTERNAL MATTERS -// ============================================================================== - - class _CaseFileDriver; - class _CaseFileDriver_User; - struct _InterMed; - struct _SubPart; - struct _SubPartDesc; - struct _Support; - typedef std::set< _SubPartDesc > _SupportDesc; - - using namespace MED_EN; - using namespace MEDMEM; - using namespace std; - - // --------------------------------------------------------------- - /*! - * \brief Prepend "EnSight-MEDMEM compatibility problem" to the text - * of an exception - */ - STRING compatibilityPb(const string& exceptionText); - - // --------------------------------------------------------------- - /*! - * \brief To ignore incompatibility or not - */ - bool toIgnoreIncompatibility(); - - // --------------------------------------------------------------- - //!< search substring in a string - bool contains( const char* what, const char* inString ); - - // --------------------------------------------------------------- - /*! - * \brief EnSight element type name and an array to convert - * med connectivity to EnSight one - */ - struct TEnSightElemType - { - string _name; - vector _medIndex; - medGeometryElement _medType; - }; - // --------------------------------------------------------------- - /*! - * \brief Return EnSight type corresponding to med one - */ - const TEnSightElemType& getEnSightType(medGeometryElement medType); - - // --------------------------------------------------------------- - /*! - * \brief Return EnSight type having a given name - */ - const TEnSightElemType& getEnSightType(const string& typeName); - - // --------------------------------------------------------------- - /*! - * \brief Return true if typeName begins with "g_" - */ - inline bool isGhostType(const string& typeName) - { return ( typeName[0] == 'g' && typeName[1] == '_'); } - - // --------------------------------------------------------------- - /*! - * \brief Maximal EnSight line length - */ - const int MAX_LINE_LENGTH = 80; - - // --------------------------------------------------------------- - /*! - * \brief Maximal length of field name in EnSight - */ - const int MAX_FIELD_NAME_LENGTH = 19; - - // --------------------------------------------------------------- - /*! - * \brief Maximal length of field name in EnSight - */ - const string ILLEGAL_FIELD_NAME_CHARACTERS = " !@#$^()[]*/+-"; // '.,' ???? - - // --------------------------------------------------------------- - /*! - * \brief Width of fields in ASCII file - */ - const int INT_WIDTH_6 = 8; - const int INT_WIDTH_GOLD = 10; - const int FLT_WIDTH = 12; - - // --------------------------------------------------------------- - /*! - * \brief EnSight space dimension - */ - const int SPACE_DIM = 3; - - // --------------------------------------------------------------- - /*! - * \brief Time step data boundaries in single-file mode - */ - static const char* TIME_STEP_BEG = "BEGIN TIME STEP"; - static const char* TIME_STEP_END = "END TIME STEP"; - const size_t TIME_STEP_BEG_LEN = 15; - const size_t TIME_STEP_END_LEN = 13; - - - // --------------------------------------------------------------- - /*! - * \brief Cast value to float and protect from overflow - */ - static inline float _toFloat (const double & value) { - if ( value > FLT_MAX ) return FLT_MAX; - if ( value < -FLT_MAX ) return -FLT_MAX; - if ( isnan( value )) throw MEDEXCEPTION(compatibilityPb("NaN value not allowed")); - return float( value ); - } - static inline float _toFloat (const int & value) { return float( value ); } - static inline float _toFloat (const long & value) { return float( value ); } - -// ============================================================================== -/*! - * \brief Reader/writer of EnSight Case file - * - * Apart from it's major job, it - * o assures cooperation of MED and Mesh/Field drivers so that the Case file created - * by MED driver is not overwritten by Mesh driver called by MED driver. - */ -// ============================================================================== - -class _CaseFileDriver -{ -public: - _CaseFileDriver(const string& fileName, const _CaseFileDriver_User* creator); - ~_CaseFileDriver(); - - void read() throw (MEDEXCEPTION); - - // --------------- - // reading meshes - // --------------- - - int getNbMeshes() const; - - //!< sets all data necessary for meshDriver::read() - void setDataFileName(const int meshIndex, ENSIGHT_MESH_RDONLY_DRIVER* meshDriver); - - // --------------- - // reading fields - // --------------- - - int getNbVariables() const; - - int getNbVarSteps(const int variableIndex); - - //!< return variable index by variable name, return 0 if none found - int getVariableIndex(const string & varName) const; - - //!< sets all data necessary for fieldDriver::read(), returns meshIndex - int setDataFileName(const int varIndex, - const int stepIndex, - ENSIGHT_FIELD_RDONLY_DRIVER* fieldDriver); - - // -------- - // writing - // -------- - - //!< add a mesh to the Case file - void addMesh(const ENSIGHT_MESH_WRONLY_DRIVER* meshDriver); - - //!< add a field to the Case file - void addField(const ENSIGHT_FIELD_WRONLY_DRIVER * fieldDriver); - - //!< write and set necessary data to added drivers - void write() throw (MEDEXCEPTION); - -private: - - //!< throw if Case file has not been read else return false - bool checkWasRead() const throw (MEDEXCEPTION); - - //!< replace '*' in file name if any and return index in a file and time - int fixWildCardName(const int timeStep, - const std::string & ts, - const std::string & fs, - std::string & fileName, - std::string & time); - - // -------------------------------------------------------------------------------- - // GEOMETRY section - // model: [ts] [fs] filename [change_coords_only] - // ts = time set number as specified in TIME section. This is optional. - // fs = corresponding file set number as specified in FILE section below. - // (Note, if you specify fs, then ts is no longer optional and must also be - // specified.) - // filename = The filename of the appropriate file. - // -> Model or measured filenames for a static geometry case, as well as match, - // boundary, and rigid_body filenames will not contain "*" wildcards. - // -> Model or measured filenames for a changing geometry case will - // contain "*" wildcards. - // change_coords_only = The option to indicate that the changing geometry (as - // indicated by wildcards in the filename) is coords only. - // Otherwise, changing geometry connectivity will be - // assumed. - struct _Model { - string _timeSetNumber, _fileSetNumber; //!< ts, fs - string _fileName; //!< filename - string _change_coords_only; - }; - // -------------------------------------------------------------------------------- - // VARIABLE section - // ts = The corresponding time set number (or index) as specified in TIME - // section below. This is only required for transient constants and - // variables. - // fs = The corresponding file set number (or index) as specified in FILE - // section below. - // (Note, if you specify fs, then ts is no longer optional and must - // also be specified.) - // description = The variable (GUI) name (ex. Pressure, Velocity, etc.) - // const_value(s) = The constant value. If constants change over time, then ns (see - // TIME section below) constant values of ts. - // cvfilename = The filename containing the constant values, one value per time step. - // filename = The filename of the variable file. Note: only transient filenames - // contain "*" wildcards. - // Re_fn = The filename for the file containing the real values of the complex - // variable. - // Im_fn = The filename for the file containing the imaginary values of the - // complex variable. - // freq = The corresponding harmonic frequency of the complex variable. - // For complex variables where harmonic frequency is undefined, - // simply use the text string: UNDEFINED. - struct _Variable { - string _type; //!< constant|scalar|etc. - string _name; //!< description - string _timeSetNumber, _fileSetNumber; //!< [ts], [fs] - string _fileNameOrData; //!< [cv]filename|Re_fn Im_fn freq|const_value(s) - }; - // -------------------------------------------------------------------------------- - // FILE section - // fs = file set number. This is the number referenced in the GEOMETRY - // and VARIABLE sections above. - // ns = number of transient steps - // fi = file index number in the file name (replaces "*" in the filenames) - struct _FileSet { - int _number; //!< fs - std::list _nbStepsInFile; //!< ns - std::list _fileIndex; //!< fi - }; - // -------------------------------------------------------------------------------- - // TIME section - struct _TimeSet { - int _number; //!< ts - std::vector _fileIndex; //!< fn - std::vector _times; //!< times - - bool operator==(const _TimeSet& ts) const - { return ( _fileIndex == ts._fileIndex && _times == ts._times ); } - }; - -private: - - std::string _fileName; - std::string _directory; - EnSightFormat _format; - _Model _model; - std::map< int, _Variable> _variables; //!< map order number to variable data - std::map< int, _TimeSet > _timeSets; //!< map ts to time set data - std::map< int, _FileSet > _fileSets; //!< map fs to file set data - - const _CaseFileDriver_User* _user; //!< mesh/field driver - - std::list _meshDrivers; //!< added meshes - - typedef std::map > TFieldDriversByName; - TFieldDriversByName _fieldDrivers; //!< added field drivers groupped by name - - //!< to block all calls from a mesh/field driver governed by med driver - bool _blocked; -}; - - // ============================================================================== -/*! - * \brief Base of all Ensight drivers. - * It stores data passed from case file - */ -// ============================================================================== - -class MEDMEM_EXPORT _CaseFileDriver_User: public GENDRIVER -{ -protected: - - _CaseFileDriver_User(const std::string& caseFileName="", - MED_EN::med_mode_acces mode=MED_EN::RDWR); - - const std::string& getCaseFileName() const { return GENDRIVER::_fileName; } - - const std::string& getDataFileName() const { return _dataFileName; } - - bool isGoldFormat() const { return _isGoldFormat; } - - //!< returns true if there are several meshes/fields in a data file - bool isSingleFileMode() const { return _singleFileMode; } - - //!< index of meshes/fields in a data file, zero for static mesh/feild - int getIndexInDataFile() const { return _indexInDataFile; } - - //!< true if there are time steps, i.e. getTime() has sense - bool isTransientMode() const { return _transientMode; } - - //!< time of a step - double getTime() const { return atof(_time.c_str()); } - - // ------------------------------- - // pass mesh data to field driver - // ------------------------------- - - //!< for mesh driver to store data - void setInterData(_InterMed* imed); - - //!< for field driver to get mesh data - _InterMed* getInterData(); - - _SubPart* getSubPart(const _SubPartDesc & descriptor) throw (MEDEXCEPTION); - - _Support* getSupport(const _SupportDesc & descriptor, - const medEntityMesh entity) throw (MEDEXCEPTION); - - -public: - //!< return part number to write support with, zero in failure case - int getPartNumber(const SUPPORT* support) const; - - static bool canOpenFile(const string& fileName, med_mode_acces mode); - - static void getSupportNodes(const SUPPORT* sup, map & nodeIds); - - //!< analyse if data file is binary - static bool isBinaryDataFile(const string& dataFileName); - - static bool isTimeStepBeginning(const string& line) - { return ( line == TIME_STEP_BEG ); } - - static bool isTimeStepEnd(const char* line) - { return ( strncmp( line, TIME_STEP_END, TIME_STEP_END_LEN ) == 0 ); } - - static bool isToWriteEntity(const medEntityMesh entity, const GMESH* mesh); - - ~_CaseFileDriver_User(); - - void merge( const GENDRIVER& driver); - -private: - - friend class _CaseFileDriver; - - // members set by _CaseFileDriver::setDataFileName(...) and _CaseFileDriver::write() - std::string _dataFileName; - bool _isGoldFormat; - bool _transientMode; //!< true if there are time steps - bool _singleFileMode; //!< only one or several meshes/fields in a data file - int _indexInDataFile; //!< which meshes/fields in a data file - std::string _time; //!< time of a step - - _InterMed* _imed; //!< to be used by field driver - string _imedMapKey; //!< key in the map storing mesh data for usage by field drv - -}; - -// ============================================================================== -/*! - * \brief Descriptor of the sub-part: part number and elem type or "block" etc. - */ -// ============================================================================== - -struct _SubPartDesc: public std::pair -{ - _SubPartDesc(int partNumber=-1, - const std::string& typeName="") - : std::pair ( partNumber, typeName ) {} - - const int& partNumber() const { return this->first; } - const string& typeName() const { return this->second; } - - static _SubPartDesc globalCoordDesc() { return _SubPartDesc(-1,"coordinates"); } -}; - -std::ostream& operator << (std::ostream& os, const _SubPartDesc& desc); - -// ============================================================================== -/*! - * \brief A type within EnSight part. It stores data needed by field driver to - * know nb of values of a geometric type and what place they get in MED group - */ -// ============================================================================== - -struct _SubPart: public _SubPartDesc -{ - // _SubPart describes both nodes and elements since "block" describes the both. - // Mesh driver sets - // for cells: myNbCells and myCellGroupIndex - // for nodes: myNbNodes and myFirstNode - // GROUP of cells is created always, - // GROUP of nodes, only if nodal field support is required (see getSupport()) - - int myNbCells; //!< nb of cells - int myCellGroupIndex; //!< cell group id in _InterMed - _groupe::TMailleIter myFirstCell; //!< pointer to the first cell - - int myNbNodes; //!< nb of nodes - mutable int myNodeGroupIndex; //!< node group id in _InterMed - _maille::TNoeud myFirstNode; //!< pointer to the first node - - _SubPart(int partNumber=-1, - const std::string& typeName="") - : _SubPartDesc(partNumber,typeName), - myNbCells(0), myCellGroupIndex(-1), - myNbNodes(0), myNodeGroupIndex(-1) - {} - - _SubPartDesc getDescriptor() const { return _SubPartDesc( partNumber(), typeName() ); } -}; - -// ============================================================================== -/*! - * \brief EnSight variable support composed of _SubPart's - */ -// ============================================================================== - -struct _Support -{ - _groupe * myCellGroup; //!< cell group in _InterMed - _groupe * myNodeGroup; //!< node group in _InterMed - - _Support(): myCellGroup(0), myNodeGroup(0) {} - - void setGroup( _groupe* g ); - SUPPORT* medSupport( medEntityMesh entity ); - - int getIndex( const pair& node); - int getIndex( const _groupe::TMaille& cell); - -// medGeometryElement getType( const pair& node); -// medGeometryElement getType( const _groupe::TMaille& cell); -}; - -// ============================================================================== -/*! - * \brief Structure to temporarily store data read from EnSight geom file - */ -// ============================================================================== - -struct _InterMed : public _intermediateMED -{ - MESH* _medMesh; - bool _isOwnMedMesh; //!< whether to delete _medMesh - int _nbUsers; //!< to know when to delete _medMesh - - bool _needSubParts; //!< true if there are fields needing _SubPart data - - map< _SubPartDesc, _SubPart > _subPartDescribed; - - map< _SupportDesc, _Support > _supportDescribed; - - void addSubPart(const _SubPart& subPart); - - ~_InterMed(); -}; - -// ============================================================================== -/*! - * \brief Simple owner of C array - */ -// ============================================================================== - -template struct _ValueOwner { - T * myValues; - _ValueOwner(T* values):myValues(values) {} - ~_ValueOwner() { if ( myValues ) delete [] myValues; } - operator T*() { return myValues; } -private: - _ValueOwner(const _ValueOwner& other) {} // forbidden -}; -// instantiations -typedef _ValueOwner TStrOwner; -typedef _ValueOwner TIntOwner; -typedef _ValueOwner TDblOwner; -typedef _ValueOwner TFltOwner; - -// ============================================================================== -/*! - * \brief Iterator on values of a component - */ -// ============================================================================== - -template class _ValueIterator -{ -protected: - const T* myPtr; - int myDelta; -public: - _ValueIterator() // by default next() returns zero - : myPtr(zeroPtr()), myDelta( 0 ) {} - - _ValueIterator(const T* values, int delta): myPtr(values-delta), myDelta(delta) {} - - const T & next() { myPtr += myDelta; return *myPtr; } - - static const T* zeroPtr() { static T a0 = 0; return &a0; } -}; - -// ============================================================================== -/*! - * \brief Reader of ASCII files - */ -// ============================================================================== - -class _ASCIIFileReader -{ -public: - _ASCIIFileReader(const string& fileName) throw (MEDEXCEPTION); - - ~_ASCIIFileReader(); - - bool eof(); - - string getWord(); //!< never throws - - int getInt() throw (MEDEXCEPTION) { - if ( eof() ) throw MEDEXCEPTION("Unexpected EOF"); - return strtol(_ptr, &_ptr, 10); - } - float getReal() throw (MEDEXCEPTION) { - if ( eof() ) throw MEDEXCEPTION("Unexpected EOF"); -#ifdef WIN32 -#else - return strtof(_ptr, &_ptr); -#endif - } - //!< needed after getWord(), getInt() or getReal() to get a next line - void toNextLine() { - while (isspace(*_ptr)) if ((++_ptr)[-1]=='\n') break; - } - char* getLine() throw (MEDEXCEPTION); - - const char* getCurrentPtr() const { return _ptr; } - - bool lookAt( const char* text ); - - bool isTimeStepBeginning(); - - bool isTimeStepEnd(); - - //!< read out given data - void skip(int nbVals, int nbPerLine, int valWidth); - - //!< read out width chars and nbLines line-ends - void skip(int width, int nbLines); - - template - char* convertReals( const int nbValues, - const char* undefValue = 0, - set* undefIndices = 0, - const vector* partialIndices = 0, - const int nbPartialComponents = 0) - throw (MEDEXCEPTION) - { - T* result = new T[ nbValues ]; - T* ptrT = result; - if ( undefValue ) // fill undefIndices - { - undefIndices->clear(); - float undef = atof( undefValue ); - for ( int i = 0; i < nbValues; ++i, ++ptrT ) { - float value = getReal(); - (*ptrT) = (T) value; - if ( value == undef ) - undefIndices->insert( undefIndices->end(), i+1 ); - } - } - else if ( partialIndices ) - { - // partial variables are available in GOLD format only where - // values are in no-interlace - int shift = 1; - for ( int j = 1; j <= nbPartialComponents; ++j ) { - vector::const_iterator i = partialIndices->begin(), iEnd = partialIndices->end(); - while ( i != iEnd ) - result[ *i++ - shift ] = (T) getReal(); - shift += nbValues; - } - } - else - { - for ( int i = 0; i < nbValues; ++i, ++ptrT ) - (*ptrT) = (T) getReal(); - } - return (char*) result; - } - - //static string strip(char* & str); - - //!< divide a string into two parts - static int split(const string& str, - string & part1, - string & part2, - const char separator=' ', - const bool fromBack=false); - - //!< divide a string into parts, return nb of parts - static int split(const string& str, - std::list & parts, - const char separator=' ', - const bool fromBack=false); - - //!< check if string contains only digits - static bool isDigit(const string& str, const bool real=false); - -private: - - int _file; - char* _start; // buffer start - char* _ptr; // beginning of not read portion - char* _eptr; // end of buffer contents - - bool _isWin; - -};// class _ASCIIFileReader - - -// ============================================================================== -/*! - * \brief Reader of binary files - */ -// ============================================================================== - -class _BinaryFileReader -{ -public: - _BinaryFileReader(const string& fileName) throw (MEDEXCEPTION); - - ~_BinaryFileReader(); - - void rewind(); //!< rewind the file backward - - void swapBytes() //!< turn on swapping bytes - { _mySwapBytes = true; } - - int moreValuesAvailable() const; //!< size of not read file portion in sizeof(int) - - bool eof(); - - void skip(int size) throw (MEDEXCEPTION); - - void skipTimeStepBeginning() throw (MEDEXCEPTION); - - char* getLine() throw (MEDEXCEPTION) - { return get(80); } - - int* getInt(int nb) throw (MEDEXCEPTION) - { return get(nb,_mySwapBytes); } - - float* getFlt(int nb) throw (MEDEXCEPTION) - { return get(nb,_mySwapBytes); } - - ssize_t getPosition() const { return _pos; } - - template - char* convertReals( const int nbValues, - const char* undefValue = 0, - set* undefIndices = 0, - const vector* partialIndices = 0, - const int nbPartialComponents = 0 ) - throw (MEDEXCEPTION) - { - T* result = new T[ nbValues ]; - T* ptrT = result, *endT = result + nbValues; - int nb = partialIndices ? partialIndices->size() * nbPartialComponents : nbValues; - TFltOwner fltData( getFlt( nb )); - float* ptrFlt = fltData; - if ( undefValue ) // fill undefIndices - { - undefIndices->clear(); - float undef = atof( undefValue ); - while ( ptrT < endT ) { - float value = *ptrFlt++; - *ptrT++ = (T) value; - if ( std::abs( value - undef ) <= FLT_MIN ) - undefIndices->insert( undefIndices->end(), ptrT - result ); - } - } - else if ( partialIndices ) - { - // partial variables are available in GOLD format only where - // values are in no-interlace - int shift = 1; - for ( int j = 1; j <= nbPartialComponents; ++j ) { - vector::const_iterator i = partialIndices->begin(), iEnd = partialIndices->end(); - while ( i != iEnd ) - result[ *i++ - shift ] = (T) *ptrFlt++; - shift += nbValues; - } - } - else - { - while ( ptrT < endT ) - *ptrT++ = (T) *ptrFlt++; - } - return (char*) result; - } -private: - - int _file; //!< descriptor - MEDEXCEPTION _exception; //!< ready to raise exception - ssize_t _pos, _maxPos; //!< current position and end position - bool _mySwapBytes; //!< to swap bytes - - //!< read any data from file - template T* get(int nb, bool inverseBytes=false) - { - size_t bufSize = nb * sizeof( T ); - if ( int(bufSize) > _maxPos - _pos ) - throw _exception; - T* buf = new T[ nb ]; -#ifdef WIN32 -#else - ssize_t nBytesRead = ::read (_file, buf, bufSize ); - _pos += nBytesRead; - if ( int(nBytesRead) < int(bufSize) ) { - delete buf; - throw _exception; - } - if ( inverseBytes ) { // swap bytes - int* intBuf = ((int*) buf) - 1; - int* bufEnd = (int*)((char*) buf + nBytesRead); - while ( ++intBuf < bufEnd ) - *intBuf = MEDMEM::swapBytes( *intBuf ); - } -#endif - return buf; - } -}; - -// ============================================================================== -/*! - * \brief Writer of binary files - */ -// ============================================================================== - -class _BinaryFileWriter -{ -public: - _BinaryFileWriter(const string& fileName) throw (MEDEXCEPTION); - - ~_BinaryFileWriter(); - - //!< write a string - void addString(const char* str) throw (MEDEXCEPTION); - - //!< write a string - void addString(const string& str) throw (MEDEXCEPTION) - { addString( str.c_str() ); } - - //!< write an integer value - void addInt(const int value) throw (MEDEXCEPTION) - { add( &value, 1 ); } - - //!< write integer values - void addInt(const int* data, int nbValues) throw (MEDEXCEPTION) - { add( data, nbValues ); } - - //!< write integer values - void addInt(const vector< int >& data) throw (MEDEXCEPTION) - { add( &data[0], data.size() ); } - - //!< write any data as floats - template - void addReal(const T* data, int nbValues) throw (MEDEXCEPTION) - { - _RealData realData( data, nbValues ); - add( realData.values(), nbValues ); - } - - //!< write any data as floats - template - void addReal(vector< TValueIterator >& componentIt, - const int nbValues, - const medModeSwitch interlace) throw (MEDEXCEPTION) - { - _RealData realData( componentIt, nbValues, interlace ); - add( realData.values(), nbValues * componentIt.size() ); - } - -private: - - int _file; //!< descriptor - MEDEXCEPTION _exception; //!< ready to raise exception - - //!< write any data to file - template - void add(const T* data, int nbValues) throw (MEDEXCEPTION) - { -#ifdef WIN32 -#else - ssize_t nbWritten = ::write( _file, (const void *) data, nbValues * sizeof(T)); - if ( nbWritten < 0 ) throw _exception; -#endif - } - // ------------------------------------------------------------------------ - /*! - * \brief Container of temporary data converting any data to floats - */ - // ------------------------------------------------------------------------ - class _RealData { - PointerOf _floatData; - public: - //!< return pointer to float array - const float* values() { return _floatData; } - - //!< convert nbValues to floats - template - _RealData(const T* data, int nbValues) - { - if ( sizeof( T ) == sizeof( float )) - _floatData.set((const float*) data); - else { - _floatData.set(nbValues); - float* floatPtr = _floatData; - const T *tPtr = data, *tEnd = data + nbValues; - while ( tPtr < tEnd ) - *floatPtr++ = _toFloat( *tPtr++ ); - } - } - - //!< convert nbValues to floats in given interlace - template - _RealData(vector< TValueIterator >& componentIt, - const int nbValues, - const medModeSwitch interlace) - { - int nbComponents = componentIt.size(); - _floatData.set(nbValues * nbComponents); - float* floatPtr = _floatData; - if ( interlace == MED_FULL_INTERLACE && nbComponents > 1 ) { - for ( int i = 0; i < nbValues; ++i ) - for ( int j = 0; j < nbComponents; ++j ) - *floatPtr++ = _toFloat( componentIt[ j ].next() ); - } - else { - for ( int j = 0; j < nbComponents; ++j ) { - TValueIterator & values = componentIt[ j ]; - for ( int i = 0; i < nbValues; ++i ) - *floatPtr++ = _toFloat( values.next() ); - } - } - } - }; // class _RealData - -}; // class _BinaryFileWriter - -}// namespace MEDMEM_ENSIGHT - -#endif diff --git a/src/MEDMEM/MEDMEM_Exception.cxx b/src/MEDMEM/MEDMEM_Exception.cxx deleted file mode 100644 index d4f20a6c7..000000000 --- a/src/MEDMEM/MEDMEM_Exception.cxx +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -/* - File MedException.cxx -*/ - -#include "MEDMEM_Utilities.hxx" -#include "MEDMEM_Exception.hxx" - -using namespace std; -using namespace MEDMEM; - -extern "C" -{ -#include -#include -#include -} - -/*! - \internal - Function used to duplicate char * -*/ -char* duplicate( const char *const str ) ; -char* duplicate( const char *const str ) -{ - ASSERT_MED(str!=NULL) ; - const size_t length = strlen( str ) ; - ASSERT_MED(length>0) ; - char *new_str = new char[ 1+length ] ; - ASSERT_MED(new_str) ; - strcpy( new_str , str ) ; - return new_str ; -} - -/*! - \internal Default Constructor (Should not be used) -*/ -// ------------------------------------------------------ // -MEDEXCEPTION::MEDEXCEPTION( void ): exception() , _text(0) -// ------------------------------------------------------ // -{ - MESSAGE_MED( "You must user the standard builder : MEDEXCEPTION::MEDEXCEPTION( const char *text )" ) ; - INTERRUPTION_MED(1) ; -} - -namespace -{ -/*! - \internal - Function used to elaborate the text of the MEDEXCEPTION -*/ -// --------------------------------------------------------------------------------------- // -char *makeText( const char *text, const char *fileName, const unsigned int lineNumber ) -// --------------------------------------------------------------------------------------- // -{ - char *newText = 0 ; - - ASSERT_MED(text) ; - const size_t l1 = strlen(text) ; - - const char* prefix = "MED Exception" ; - const size_t l0 = strlen(prefix) ; - - if ( fileName ) - { - const size_t l2 = strlen(fileName) ; - - ASSERT_MED(lineNumber>=1) ; - const size_t l3 = 1+int(log10(float(lineNumber))) ; - - const size_t l4 = l0+l1+l2+l3+10+1 ; - newText = new char [ l4 ] ; - sprintf( newText , "%s in %s [%u] : %s" , prefix, fileName, lineNumber, text ) ; - ASSERT_MED(newText[l4-1] == '\0' ); - - } - else - { - newText = new char [ l0+l1+3+1 ] ; - sprintf( newText , "%s : %s" , prefix, text ) ; - } - ASSERT_MED(newText) ; - return newText ; -} -} - -/*! - Constructor : \n - It will create the text of the MEDEXCEPTION from the different parameters. - It will take the form : \n - MEDEXCEPTION, fileName, lineNumber and text of the exception -*/ -// ------------------------------------------------------------------------------------------------ // -MEDEXCEPTION::MEDEXCEPTION( const char *text, const char *fileName, const unsigned int lineNumber ) : - exception(), _text( makeText( text , fileName , lineNumber ) ) -// ------------------------------------------------------------------------------------------------ // -{ - MESSAGE_MED(_text); -} - -/*! - Destructor : \n - If necessary desallocates Memory -*/ - -// ------------------------------------// -MEDEXCEPTION::~MEDEXCEPTION() throw () -// ------------------------------------// -{ - if ( _text ) - { - delete [] _text ; - _text = 0 ; - } - ASSERT_MED(_text==NULL) ; -} - - -/*! - Copy Constructor : \n - Should not be used very often -*/ -// ----------------------------------------------------------------------- // -MEDEXCEPTION::MEDEXCEPTION( const MEDEXCEPTION &ex ): _text(duplicate(ex._text)) -// ----------------------------------------------------------------------- // -{ - ; -} -/*! - Operator << : put the message to the given stream. -*/ -// ------------------------------------------------------- // -ostream & MEDMEM::operator<<( ostream &os , const MEDEXCEPTION &ex ) -// ------------------------------------------------------- // -{ - os << ex._text ; - return os ; -} - -/*! - Return a char * which contain the message. -*/ -// ------------------------------------------------- // -const char* MEDEXCEPTION::what( void ) const throw () -// ------------------------------------------------- // -{ - return _text ; -} - - -// -------------------- class MED_DRIVER_NOT_FOUND_EXCEPTION - - -MED_DRIVER_NOT_FOUND_EXCEPTION::MED_DRIVER_NOT_FOUND_EXCEPTION(const MED_DRIVER_NOT_FOUND_EXCEPTION &ex ):MEDEXCEPTION ( ex ) {} - - -MED_DRIVER_NOT_FOUND_EXCEPTION::MED_DRIVER_NOT_FOUND_EXCEPTION -( - const char *text, const char *fileName/*=0*/, - const unsigned int lineNumber/*=0*/ - ) : MEDEXCEPTION(text, fileName, lineNumber) {} - -MED_DRIVER_NOT_FOUND_EXCEPTION::~MED_DRIVER_NOT_FOUND_EXCEPTION() throw (){} diff --git a/src/MEDMEM/MEDMEM_Exception.hxx b/src/MEDMEM/MEDMEM_Exception.hxx deleted file mode 100644 index 6bb0f78e3..000000000 --- a/src/MEDMEM/MEDMEM_Exception.hxx +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -/* - File MedException.hxx -*/ - -#ifndef MEDEXCEPTION_HXX -#define MEDEXCEPTION_HXX - -#include - -#include -#include - -using namespace std; - -#ifndef LOCALIZED -#define LOCALIZED(message) static_cast (message) , __FILE__ , __LINE__ -#endif - -#define MED_EXCEPTION MEDMEM::MEDEXCEPTION - -/*! - Class used to throws exception.\n - Inherits from public exception. -*/ -namespace MEDMEM { - class MEDEXCEPTION; - MEDMEM_EXPORT ostream & operator<< (ostream &os, const MEDEXCEPTION &ex ); -//--------------------------------------// - class MEDMEM_EXPORT MEDEXCEPTION : public std::exception -//--------------------------------------// -{ -private : - MEDEXCEPTION(void); - -protected : - char* _text ; - -public : - MEDEXCEPTION(const char *text, const char *fileName=0, - const unsigned int lineNumber=0 ); - MEDEXCEPTION(const MEDEXCEPTION &ex ); - ~MEDEXCEPTION() throw (); - friend ostream & operator<< (ostream &os, const MEDEXCEPTION &ex ); - virtual const char *what(void) const throw () ; -} ; - - -//---------------------------------------------------------// -class MEDMEM_EXPORT MED_DRIVER_NOT_FOUND_EXCEPTION : public MEDEXCEPTION -//---------------------------------------------------------// -{ -private : - MED_DRIVER_NOT_FOUND_EXCEPTION(void); - -public : - MED_DRIVER_NOT_FOUND_EXCEPTION(const char *text, const char *fileName=0, - const unsigned int lineNumber=0 ); - MED_DRIVER_NOT_FOUND_EXCEPTION(const MED_DRIVER_NOT_FOUND_EXCEPTION &ex ); - ~MED_DRIVER_NOT_FOUND_EXCEPTION() throw(); - -}; -} - -#endif /* MEDEXCEPTION_HXX */ diff --git a/src/MEDMEM/MEDMEM_Extractor.cxx b/src/MEDMEM/MEDMEM_Extractor.cxx deleted file mode 100644 index dba356cbd..000000000 --- a/src/MEDMEM/MEDMEM_Extractor.cxx +++ /dev/null @@ -1,1590 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : MEDMEM_Extractor.cxx -// Created : Thu Dec 18 11:10:11 2008 -// Author : Edward AGAPOV (eap) -// -#include "MEDMEM_Extractor.hxx" - -#include -#include -#include -#include - -#include - -#include - -using namespace MED_EN; -using namespace std; -using namespace MEDMEM; - -namespace { // local tools - - const int _POLYGON = -1; //!< map key to store connectivity of polygons - - const double _TOLER = 1e-12; - - //================================================================================ - /*! - * \brief calculate cross product of two vectors - */ - void crossProduct(const double* v1, const double* v2, double* res) - { - res[0] = v1[1] * v2[2] - v1[2] * v2[1]; - res[1] = v1[2] * v2[0] - v1[0] * v2[2]; - res[2] = v1[0] * v2[1] - v1[1] * v2[0]; - } - //================================================================================ - /*! - * \brief calculate dot product of two vectors - */ - double dotProduct(const double* v1, const double* v2) - { - return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2]; - } - //================================================================================ - /*! - * \brief Accessor to some ids. Provides operator[] and more-next access methods - */ - class TIter - { - const int *_cur, *_end; - public: - TIter(const int* start, const int* end):_cur(start), _end(end) {} - TIter(const int* start, int nb):_cur(start), _end(start+nb) {} - int size() const { return _end - _cur; } - int operator[] (int i) const { return _cur[i]; } - bool more() const { return _cur < _end; } - int next() { return *_cur++; } - const int* begin() const { return _cur; } - const int* end() const { return _end; } - }; - //================================================================================ - /*! - * \brief Edge linking two nodes, used to find equal edges and store edges in std containers - */ - struct TEdge: public pair - { - TEdge(const int n1=0, const int n2=0): pair(n1,n2) - { if ( n2 < n1 ) first = n2, second = n1; } - TEdge(const TIter& nodes, int i ) - { *this = TEdge( nodes[i], nodes[ (i+1)%nodes.size() ]); } - int node1() const { return first; } - int node2() const { return second; } - }; - //================================================================================ - /*! - * \brief Tool providing iteration on edges of the cell of given classical type - */ - struct TEdgeIterator - { - vector* _edges; - TEdgeIterator(const medGeometryElement type); - int getNbEdges() const { return _edges->size(); } - TEdge getEdge(int i, const int* cellConn ) const - { return TEdge( cellConn[(*_edges)[i].node1()], cellConn[(*_edges)[i].node2()]); } - TEdge getEdge(int i, const TIter& cellNodes ) const - { return TEdge( cellNodes[(*_edges)[i].node1()], cellNodes[(*_edges)[i].node2()]); } - }; - //================================================================================ - /*! - * \brief Comparator used to sort nodes of polygon - */ - struct TNodeCompare - { - const double* _coords; //!< coordinates of mesh nodes in full interlace - const double* _bc; //!< polygon barycentre - int _i1, _i2; //!< indices of two ordinates used to compare points - - TNodeCompare(const double* nodeCoords, int i1, int i2): - _coords(nodeCoords),_i1(i1),_i2(i2) {} - - void setBaryCenter(const double* bc) { _bc = bc; } - - bool operator()(const int pt1, const int pt2) { - const double* p1 = _coords + 3*(pt1-1); - const double* p2 = _coords + 3*(pt2-1); - // calculate angles of Op1 and Op2 with the i1 axis on plane (i1,i2) - double ang1 = atan2(p1[_i1] - _bc[0], p1[_i2] - _bc[1]); - double ang2 = atan2(p2[_i1] - _bc[0], p2[_i2] - _bc[1]); - return ang1 > ang2; - } - }; - //================================================================================ - /*! - * \brief Return tolerance to consider nodes coincident - */ - double getTolerance(const MESH* mesh ) - { - vector< vector > bb = mesh->getBoundingBox(); - double diagonal = 0; - for ( int j = 0; j < mesh->getSpaceDimension(); ++j ) { - double dist = bb[0][j] - bb[1][j]; - diagonal += dist*dist; - } - return sqrt( diagonal ) * 1e-7; - } - //================================================================================ - /*! - * \brief Line data and some methods - */ - struct TLine - { - const double* _dir; - const double* _coord; - int _maxDir; //!< index of maximal coordinate of _dir - TLine( const double* dir, const double* coord): _dir(dir), _coord(coord) { - _maxDir = 0; - if ( fabs( _dir[_maxDir] ) < fabs( _dir[1] )) _maxDir = 1; - if ( fabs( _dir[_maxDir] ) < fabs( _dir[2] )) _maxDir = 2; - } - //!< Check if intersection points coincide in _maxDir direction - bool isSame( const double* p1, const double* p2 ) const { - return fabs(p1[_maxDir] - p2[_maxDir]) < _TOLER; - } - }; - //================================================================================ - /*! - * \brief Result of transfixing a face - * - * TIntersection's make up a chain via _prevSection field. Depending on whether - * _prevSection is NULL or not, there are two types of TIntersection: - * . _prevSection == NULL: TIntersection ending the chain. It is TIntersection from - * which chain building starts. - * . _prevSection != NULL: intermediate TIntersection, stores cells cut by a result segment. - */ - struct TIntersection - { - double _point[3]; //!< coordinates of itersection - set _cells; //!< intersected cells - int _face; //!< intersected face of a cell - set _startNodes; //!< nodes around which to look for next intersection - TIntersection* _prevSection; //!< neighbor intersection - - TIntersection(): _face(-1), _prevSection(NULL) - {} - ~TIntersection() { - if ( _prevSection ) delete _prevSection; _prevSection=0; - } - void getRange( double& min, double& max, const int j ) const { - if ( _point[j] < min ) min = _point[j]; - if ( _point[j] > max ) max = _point[j]; - if ( _prevSection ) _prevSection->getRange( min, max, j ); - } - void reverse() { - if ( _prevSection ) { - _prevSection->reverse(); - _prevSection->_cells = _cells; - _prevSection->_prevSection = this; - _prevSection = NULL; - } - } - int size() const { return 1 + ( _prevSection ? _prevSection->size() : 0 ); } - }; - //================================================================================ - /*! - * \brief Provider of comfortable access to connectivity data of MESH - */ - struct TMeshData - { - int _dim; - double _tolerance; - const double* _coord; - const int* _cellConn; - const int* _cellConnIndex; - const int* _faceConn; - const int* _faceConnIndex; - const int* _face2Cell; - const int* _face2CellIndex; - const int* _cell2Face; - const int* _cell2FaceIndex; - const int* _node2Cell; - const int* _node2CellIndex; - TMeshData(const MESH &mesh) - { - _tolerance = getTolerance(&mesh); - _dim = mesh.getSpaceDimension(); - _coord = mesh.getCoordinates(MED_FULL_INTERLACE); - _cellConn = mesh.getConnectivity( MED_NODAL, MED_CELL, MED_ALL_ELEMENTS); - _cellConnIndex = mesh.getConnectivityIndex(MED_NODAL, MED_CELL); - _cell2Face = mesh.getConnectivity( MED_DESCENDING, MED_CELL, MED_ALL_ELEMENTS); - _cell2FaceIndex = mesh.getConnectivityIndex( MED_DESCENDING, MED_CELL ); - _face2Cell = mesh.getReverseConnectivity( MED_DESCENDING ); - _face2CellIndex = mesh.getReverseConnectivityIndex( MED_DESCENDING ); - _faceConn = mesh.getConnectivity( MED_NODAL, MED_FACE, MED_ALL_ELEMENTS); - _faceConnIndex = mesh.getConnectivityIndex(MED_NODAL, MED_FACE); - _node2Cell = mesh.getReverseConnectivity( MED_NODAL ); - _node2CellIndex = mesh.getReverseConnectivityIndex( MED_NODAL ); - } - double tolerance() const { - return _tolerance; } - const double* getNodeCoord( int node ) const { - return _coord + _dim*(node-1); } - TIter getFaces( int cell ) const { - return TIter( _cell2Face+_cell2FaceIndex[cell-1]-1, _cell2Face+_cell2FaceIndex[cell]-1 ); } - TIter getCellNodes( int cell ) const { - return TIter( _cellConn+_cellConnIndex[cell-1]-1, _cellConn+_cellConnIndex[cell]-1 ); } - TIter getFaceNodes( int face ) const { - face = abs(face); - return TIter( _faceConn+_faceConnIndex[face-1]-1, _faceConn+_faceConnIndex[face]-1 ); } - TIter getCellsByNode( int node ) const { - return TIter( _node2Cell+_node2CellIndex[node-1]-1, _node2Cell+_node2CellIndex[node]-1 ); } - TIter getCellsByFace( int face ) const { - face = abs(face); - return TIter( _face2Cell+_face2CellIndex[face-1]-1, _face2Cell+_face2CellIndex[face]-1 ); } - int isFreeFace( int face ) const { - TIter cells = getCellsByFace( face ); - return ( cells[1] == 0 ) ? cells[0] : 0; } - }; - //================================================================================ - /*! - * \brief Calculates face normal - * \retval bool - false if face has zero area - */ - bool calcFaceNormal( const int face, - const TMeshData& meshData, - double* norm) - { - TIter nodes = meshData.getFaceNodes( face ); - bool zeroArea = false; - int i = 0; - do { - const double* p1 = meshData.getNodeCoord( nodes[i] ); - const double* p2 = meshData.getNodeCoord( nodes[i+1] ); - const double* p3 = meshData.getNodeCoord( nodes[i+2] ); - double p2p1[3] = { p1[0]-p2[0], p1[1]-p2[1], p1[2]-p2[2] }; - double p2p3[3] = { p3[0]-p2[0], p3[1]-p2[1], p3[2]-p2[2] }; - crossProduct( p2p3, p2p1, norm ); - double normSize2 = dotProduct( norm, norm ); - zeroArea = (normSize2 < DBL_MIN); - } - while ( zeroArea && i < 2 ); - return zeroArea; - } - //================================================================================ - /*! - * \brief Fill set of cells sharing edge - */ - void getCellsSharingEdge( const TEdge& edge, const TMeshData& meshData, set & theCells ) - { - TIter cells = meshData.getCellsByNode( edge.node1() ); - while ( cells.more() ) { - int cell = cells.next(); - TIter nodes = meshData.getCellNodes( cell ); - TEdgeIterator edgeIter( medGeometryElement( 300 + nodes.size() )); - for ( int i = 0, nb = edgeIter.getNbEdges(); i < nb; ++i ) { - TEdge e = edgeIter.getEdge( i , nodes ); - if ( edge == e ) { - theCells.insert( cell ); - break; - } - } - } - } - bool canIntersect(const int cell, - const TMeshData& meshData, - const TLine& line); - - TIntersection* intersect(const int cell, - const TMeshData& meshData, - const TLine& line, - set& checkedCells, - TIntersection* prevInter=0); - -} // noname namespace - -namespace MEDMEM -{ - - //================================================================================ - /*! - * \brief Creates a tool - * \param inputField - input field - * - * The input field is supposed to comply with following conditions
    - *
  • it is constant by element (i.e. has 1 gauss point),
  • - *
  • it's support mesh does not contain poly elements,
  • - *
  • volumic elements have planar faces,
  • - *
  • surfasic elements have linear edges.
- */ - //================================================================================ - -Extractor::Extractor(const FIELD& inputField) throw (MEDEXCEPTION) -: _myInputField( & inputField ) -{ - const char* LOC = "Extractor::Extractor(inputField) :"; - - // Check if the input field complies with the conditions - - if ( !inputField.getSupport() ) - throw MEDEXCEPTION(STRING(LOC) << "InputField has NULL support"); - - medEntityMesh entity = inputField.getSupport()->getEntity(); - if ( entity == MED_NODE || entity == MED_EDGE ) - throw MEDEXCEPTION(STRING(LOC) << "InputField has invalid supporting entity"); - - if ( inputField.getSupport()->getNumberOfElements(MED_ALL_ELEMENTS) == 0 ) - throw MEDEXCEPTION(STRING(LOC) << "InputField has support of zero size"); - - if ( inputField.getGaussPresence() && inputField.getNumberOfGaussPoints()[0] > 1 ) - throw MEDEXCEPTION(STRING(LOC) << "InputField is not constant be element"); - - const GMESH* mesh = inputField.getSupport()->getMesh(); - if ( !mesh ) - throw MEDEXCEPTION(STRING(LOC) << "InputField has support with NULL mesh"); - - if ( mesh->getSpaceDimension() < 2 ) - throw MEDEXCEPTION(STRING(LOC) << "InputField with 1D support not acceptable"); - - if ( mesh->getNumberOfElements(MED_CELL, MED_POLYGON) > 0 || - mesh->getNumberOfElements(MED_CELL, MED_POLYHEDRA) > 0 ) - throw MEDEXCEPTION(STRING(LOC) << "InputField has supporting mesh with poly elements"); - - if ( mesh->getMeshDimension() < 2 ) - throw MEDEXCEPTION(STRING(LOC) << "Invalid entity dimension of connectivity"); - - _myInputField->addReference(); - _myInputMesh = mesh->convertInMESH(); -} - -Extractor::~Extractor() -{ - _myInputField->removeReference(); - _myInputMesh->removeReference(); -} - -//================================================================================ - /*! - * \brief Creates a field by cutting inputField by a plane - * \param coords - give a point to pass through by the plane - * \param normal - gives the plane normal - * \retval FIELD* - resulting field holding ownership of its support, - * which in its turn holds ownership of its mesh - * - * If the plane does not intersect the field, NULL is returned. - */ -//================================================================================ - -FIELD* Extractor::extractPlane(const double* coords, const double* normal) - throw (MEDEXCEPTION) -{ - const char* LOC = "Extractor::extractPlane(const double* coords, const double* normal) :"; - - // check agrument validity - if ( !coords || !normal ) - throw MEDEXCEPTION(STRING(LOC) << "NULL argument"); - - double normalSize = sqrt(normal[0]*normal[0] + normal[1]*normal[1] + normal[2]*normal[2]); - if ( normalSize <= DBL_MIN ) - throw MEDEXCEPTION(STRING(LOC) << "normal has zero size"); - - if ( _myInputField->getSupport()->getMesh()->getSpaceDimension() < 3 ) - throw MEDEXCEPTION(STRING(LOC) << "Extraction by plane is possible in 3D space only "); - - double norm[3] = { normal[0] / normalSize, normal[1] / normalSize, normal[2] / normalSize }; - - // cut mesh - map > new2oldCells; - MESH* mesh = divideEdges( coords, norm, new2oldCells ); - if ( !mesh ) return 0; - - FIELD* ret=makeField( new2oldCells, mesh ); - return ret; -} - -//================================================================================ - /*! - * \brief Creates a field by cutting inputField by a line - * \param coords - give a point to pass through by the line - * \param direction - gives a vector collinear to the line - * \retval FIELD* - resulting field holding ownership of its support, - * which in its turn holds ownership of its mesh - * - * If the line does not intersect the field, NULL is returned. - */ -//================================================================================ - -FIELD* Extractor::extractLine(const double* coords, const double* direction) - throw (MEDEXCEPTION) -{ - const char* LOC = "Extractor::extractLine(const double* coords, const double* direction) :"; - - // check agrument validity - if ( !coords || !direction ) - throw MEDEXCEPTION(STRING(LOC) << "NULL argument"); - - double directionSize = - sqrt(direction[0]*direction[0] + direction[1]*direction[1] + direction[2]*direction[2]); - if ( directionSize <= DBL_MIN ) - throw MEDEXCEPTION(STRING(LOC) << "direction has zero size"); - - const SUPPORT* support = _myInputField->getSupport(); - const medGeometryElement* inTypes = support->getTypes(); - const int meshDim = inTypes[ support->getNumberOfTypes()-1 ] / 100; - - if ( meshDim == 2 && support->getMesh()->getSpaceDimension() == 3 ) - throw MEDEXCEPTION(STRING(LOC) << "Extraction from 2D mesh not supported"); - - map > new2oldCells; - MESH* mesh = 0; - if ( meshDim == 2 ) - { - double norm[2] = { direction[1] / directionSize, - direction[0] / directionSize, }; - // cut mesh - mesh = divideEdges( coords, norm, new2oldCells ); - } - else - { - double dir[3] = { direction[0] / directionSize, - direction[1] / directionSize, - direction[2] / directionSize }; - mesh = transfixFaces( coords, dir, new2oldCells ); - } - - if ( !mesh ) return 0; - - FIELD*ret=makeField( new2oldCells, mesh ); - return ret; -} - -//================================================================================ -/*! - * \brief Creates a new field and fill it from the input one - * \param new2oldCells - mapping of new to old cells - * \retval FIELD* - resulting field - */ -//================================================================================ - -FIELD* Extractor::makeField( const map >& new2oldCells, - MESH* mesh ) const -{ - // make new field - int nbComp = _myInputField->getNumberOfComponents(); - const SUPPORT *sup = mesh->getSupportOnAll( MED_CELL ); - FIELD * outField = new FIELD( sup, nbComp ); - - outField->setComponentsNames ( _myInputField->getComponentsNames() ); - outField->setName ( STRING("Extracted from ")<< _myInputField->getName() ); - outField->setDescription ( STRING("Created by MEDMEM::Extractor")); - outField->setComponentsDescriptions( _myInputField->getComponentsDescriptions() ); - outField->setMEDComponentsUnits ( _myInputField->getMEDComponentsUnits() ); - - sup->removeReference(); // to delete mesh as soon as outField dies - - // put values to the new field - - double* outValues = const_cast( outField->getValue() ); - - map >::const_iterator new_olds, noEnd = new2oldCells.end(); - for ( new_olds = new2oldCells.begin(); new_olds != noEnd; ++new_olds ) - { - for ( int j = 0; j < nbComp; ++j ) - { - int ind = ( new_olds->first - 1 ) * nbComp + j; - outValues[ ind ] = 0.0; - set::const_iterator inCells = new_olds->second.begin(); - set::const_iterator inEnd = new_olds->second.end(); - for ( ; inCells != inEnd; ++inCells ) - outValues[ ind ] += _myInputField->getValueIJ( *inCells, j+1 ); - - outValues[ ind ] /= new_olds->second.size(); - } - } - return outField; -} - -//================================================================================ -/*! - * \brief Makes a mesh by dividing edges of cells of the input mesh by plane - * in 3D or by line in 2D. - * \param coords - give a point to pass through by the plane or the line - * \param normal - gives the normal to plane or line - * \param new2oldCells - output map of new cells to cut input cell - */ -//================================================================================ - -MESH* Extractor::divideEdges(const double* coords, - const double* normal, - map >& new2oldCells) -{ - const char* LOC = "Extractor::divideEdges()"; - - const SUPPORT* support = _myInputField->getSupport(); - medEntityMesh entity = support->getEntity(); - const MESH* inMesh = _myInputMesh;//support->getMesh(); - const medGeometryElement* inTypes = support->getTypes(); - - const int* inConn = inMesh->getConnectivity( MED_NODAL, entity, MED_ALL_ELEMENTS); - const int* inConnIndex = inMesh->getConnectivityIndex(MED_NODAL, entity); - const int spaceDim = inMesh->getSpaceDimension(); - const int meshDim = inTypes[ support->getNumberOfTypes()-1 ] / 100; - - - // connectivity of new cells by nb of nodes per cell - map< int, vector< int > > newConnByNbNodes; - int nbInputCells = support->getNumberOfElements( MED_ALL_ELEMENTS ); - int minNbNodesPerCell = 2, maxNbNodesPerCell = 2; - if ( meshDim == 3 ) { - newConnByNbNodes[ 3 ].reserve( nbInputCells/2 ); - newConnByNbNodes[ 4 ].reserve( nbInputCells/2 ); - minNbNodesPerCell = 3; - maxNbNodesPerCell = int (MED_POLYGON); // polygones allowed - } - else { - newConnByNbNodes[ 2 ].reserve( nbInputCells/2 ); - } - list nbNodesPerPolygon; // to make connectivity index of polygons - - // new cells - map< set, int> oldNodes2newCell; //!< map connectivity of all old nodes to new cell id - - // new nodes - map< TEdge, int > cutEdge2newNodeId; // ids of nodes located between extremities of old edge - map< int, int > oldNode2newNodeId; // ids of nodes coincident with old node - - // tolerance - double tol = getTolerance( inMesh ); - - - // ---------------------------------------------- - // compute distances of nodes from plane or line - // ---------------------------------------------- - - computeDistanceOfNodes(coords, normal); - - - // ---------- - // Cut edges - // ---------- - - int inCell = 0; - for ( int iType = 0; iType < support->getNumberOfTypes(); ++iType) // loop on geom types - { - medGeometryElement type = inTypes[ iType ]; - TEdgeIterator edges( type ); - - const int* inCells = 0; - if ( !support->isOnAllElements() ) - inCells = support->getNumber( type ); - - int nbInputCells = support->getNumberOfElements( type ); // loop on cells - for ( int i = 0; i < nbInputCells; ++i ) - { - int oldCell = inCells ? inCells[i] : ++inCell; - const int* cellConn = inConn + (inConnIndex[ oldCell-1 ] - 1); - - // Nodes of new mesh are either coincide with input nodes or lay on - // edges cut by plane. If at least one edge of a cell is cut in the middle - // then there will be the new cell, if the plane pass only through nodes of - // input cell then the new cell is not necessarily created. - - set oldNodes, newNodes; //!< cut old nodes, new nodes on edges - int nbEdgesOnPlane = 0; - for ( int iEdge = 0; iEdge < edges.getNbEdges(); ++iEdge ) // loop on cell edges - { - // Analyse edge position in relation to the cutting plane or line - const TEdge& edge = edges.getEdge( iEdge, cellConn ); - double dist1 = _myNodeDistance[ edge.node1()-1 ]; - double dist2 = _myNodeDistance[ edge.node2()-1 ]; - bool n1OnPlane = fabs( dist1 ) < tol; - bool n2OnPlane = fabs( dist2 ) < tol; - if ( n1OnPlane ) - oldNodes.insert( edge.node1() ); - if ( n2OnPlane ) - oldNodes.insert( edge.node2() ); - else if ( !n1OnPlane && dist1 * dist2 < 0 ) { - // edge intersected - int newNode = cutEdge2newNodeId.size() + oldNode2newNodeId.size() + 1; - int node = cutEdge2newNodeId.insert( make_pair( edge, newNode )).first->second; - newNodes.insert( node ); - } - nbEdgesOnPlane += int( n1OnPlane && n2OnPlane ); - } - int nbNodesInNewCell = oldNodes.size() + newNodes.size(); - if ( nbNodesInNewCell > maxNbNodesPerCell ) - throw MEDEXCEPTION(STRING(LOC) << "invalid input mesh"); - - if ( nbNodesInNewCell >= minNbNodesPerCell ) - { - // Associate new and old cells - int newCell = new2oldCells.size() + 1; - // detect equal new cells on boundaries of old cells - if ( newNodes.empty() && (int)oldNodes.size() == nbEdgesOnPlane + int(meshDim==2)) { - pair < map< set, int>::iterator, bool > it_unique = - oldNodes2newCell.insert( make_pair( oldNodes, newCell )); - if ( !it_unique.second ) { // equal new faces - int equalNewCell = it_unique.first->second; - new2oldCells[ equalNewCell ].insert( oldCell ); - continue; - } - } - set& oldCells = // add a set of old cells to the end of new2oldCells - new2oldCells.insert( new2oldCells.end(), make_pair(newCell, set()))->second; - oldCells.insert( oldCell ); - - // Store nodes - vector< int >& connectivity = - nbNodesInNewCell>4 ? newConnByNbNodes[_POLYGON] : newConnByNbNodes[nbNodesInNewCell]; - // nodes at edge intersection - set::iterator n, nEnd; - for ( n = newNodes.begin(), nEnd = newNodes.end(); n != nEnd; ++n ) - { - connectivity.push_back( *n ); - } - // nodes coincident with input nodes - for ( n = oldNodes.begin(), nEnd = oldNodes.end(); n != nEnd; ++n ) - { - int newNode = cutEdge2newNodeId.size() + oldNode2newNodeId.size() + 1; - int node = oldNode2newNodeId.insert( make_pair( *n, newNode )).first->second; - connectivity.push_back( node ); - } - if ( nbNodesInNewCell>4 ) - nbNodesPerPolygon.push_back( nbNodesInNewCell ); - } - } // loop on cells, cutting thier edges - - } // loop on geom types of input mesh - - - // ----------------- - // Make coordinates - // ----------------- - - int nbNodes = cutEdge2newNodeId.size() + oldNode2newNodeId.size(); - vector< double > resCoords( nbNodes * spaceDim ); - - const double* inCoords = inMesh->getCoordinates(MED_FULL_INTERLACE); - - // nodes in the middle of edges - map< TEdge, int >::iterator edge_node, enEnd = cutEdge2newNodeId.end(); - for ( edge_node = cutEdge2newNodeId.begin(); edge_node != enEnd; ++edge_node ) - { - int newNode = edge_node->second; - const TEdge& edge = edge_node->first; - - double* nodeCoords = & resCoords[ spaceDim * ( newNode-1 )]; - const double* n1Coords = inCoords + spaceDim * ( edge.node1()-1 ); - const double* n2Coords = inCoords + spaceDim * ( edge.node2()-1 ); - - double dist1 = _myNodeDistance[ edge.node1()-1 ]; - double dist2 = _myNodeDistance[ edge.node2()-1 ]; - double r1 = dist1 / ( dist1 - dist2 ); - - for ( int j = 0 ; j < spaceDim; ++j ) - nodeCoords[ j ] = ( 1.-r1 ) * n1Coords[ j ] + r1 * n2Coords[ j ]; - } - - // nodes coincident with input nodes - map< int, int >::iterator old_newNode, onEnd = oldNode2newNodeId.end(); - const size_t size = size_t( sizeof(double)*spaceDim ); - for ( old_newNode = oldNode2newNodeId.begin(); old_newNode != onEnd; ++old_newNode ) - { - double* newCoords = & resCoords[ spaceDim * ( old_newNode->second - 1 )]; - const double* oldCoords = inCoords + spaceDim * ( old_newNode->first - 1 ); - memcpy( newCoords, oldCoords, size ); - } - - // -------------------- - // Sort nodes of cells - // -------------------- - if ( nbNodes > 0 ) - sortNodes( newConnByNbNodes, &resCoords[0], coords, normal, nbNodesPerPolygon ); - - // ---------- - // Make mesh - // ---------- - - // count types - vector< medGeometryElement > types; - vector< int > nbCellByType; - map< int, vector< int > >::iterator nbNoConn, ncEnd =newConnByNbNodes.end(); - for ( nbNoConn = newConnByNbNodes.begin(); nbNoConn != ncEnd; ++nbNoConn ) - { - int nbNodesPerCell = nbNoConn->first; - int connSize = nbNoConn->second.size(); - if ( connSize == 0 ) continue; - if ( nbNodesPerCell >= 2 && nbNodesPerCell <= 4 ) - { - nbCellByType.push_back( connSize / nbNodesPerCell ); - types.push_back( medGeometryElement( (meshDim-1)*100 + nbNodesPerCell )); - } - else - { - nbCellByType.push_back( nbNodesPerPolygon.size() ); - types.push_back( MED_POLYGON ); - } - } - if ( types.empty() ) - return 0; - - MESHING* meshing = new MESHING(); - - meshing->setName(STRING("Cut of ") << inMesh->getName()); - meshing->setNumberOfTypes( types.size(), MED_CELL ); - meshing->setCoordinates( spaceDim, nbNodes, & resCoords[0], - inMesh->getCoordinatesSystem(), MED_FULL_INTERLACE ); - meshing->setTypes( &types[0], MED_CELL ); - meshing->setNumberOfElements( &nbCellByType[0], MED_CELL); - for ( unsigned i = 0; i < types.size(); ++i ) - if ( types[i] != MED_POLYGON ) - { - meshing->setConnectivity( MED_CELL, types[i], & newConnByNbNodes[ types[i]%100 ].front()); - } - else - { - // make index - vector index; - index.reserve( nbNodesPerPolygon.size()+1 ); - index.push_back( 1 ); - list::iterator nbNodes = nbNodesPerPolygon.begin(), nnEnd = nbNodesPerPolygon.end(); - for ( ; nbNodes != nnEnd; ++nbNodes ) - index.push_back( index.back() + *nbNodes ); - - meshing->setConnectivity( MED_CELL, types[i], & newConnByNbNodes[ _POLYGON ].front(), - & index[0]); - } - - return meshing; -} - -//================================================================================ -/*! - * \brief computes distance of each node from the plane or the line given by point and normal - */ -//================================================================================ - -void Extractor::computeDistanceOfNodes(const double* point, - const double* normal) -{ - const MESH* mesh = _myInputMesh; - const double * coord = mesh->getCoordinates(MED_FULL_INTERLACE); - const int spaceDim = mesh->getSpaceDimension(); - - _myNodeDistance.resize(mesh->getNumberOfNodes()); - - // compute dot product: normal * Vec(point,node) - for ( int i = 0; i < mesh->getNumberOfNodes(); ++i ) - { - _myNodeDistance[i] = 0.0; - for ( int j = 0; j < spaceDim; ++j, ++coord ) - { - _myNodeDistance[i] += normal[j] * (*coord - point[j]); - } - } -} - -//================================================================================ -/*! - * \brief Orient elements correctly and sort nodes of polygons - * \param connByNbNodes - map of nb of nodes per cell to cell connectivity to rearrange - * \param nodeCoords - coordinates of nodes of a new mesh in full interlace - * \param point - point on plane or line - * \param normal - normal to plane or line - * \param nbNodesPerPolygon - index of connByNbNodes[_POLYGON] connectivity - */ -//================================================================================ - -void Extractor::sortNodes( map< int, vector< int > >& connByNbNodes, - const double* nodeCoords, - const double* point, - const double* normal, - const list & nbNodesPerPolygon) -{ - const int spaceDim = _myInputField->getSupport()->getMesh()->getSpaceDimension(); - - if ( !connByNbNodes[2].empty() ) // 1D mesh - { - vector< int > & conn = connByNbNodes[2]; - if ( spaceDim == 2 ) - { - // Orient edges along an coordinate axis, - // select ordinate to check - int ind = (fabs(normal[0]) < fabs(normal[1])) ? 1 : 0; - // sorting - for ( unsigned i = 0; i < conn.size(); i += 2) { - const double* p1 = nodeCoords + spaceDim*(conn[i]-1); - const double* p2 = nodeCoords + spaceDim*(conn[i+1]-1); - if ( p1[ind] > p2[ind] ) - std::swap( conn[i], conn[i+1] ); - } - } - else - { - // Reverse if necessary adjacent edges if they have equal nodes - if ( conn.size() > 2 ) { - if ( conn[0] == conn[2] || conn[0] == conn[3] ) - std::swap( conn[0], conn[1] ); - int i; - for ( i = 2; i < (int)conn.size()-2; i += 2) { - if ( conn[i-1] == conn[i+1] ) - std::swap( conn[i], conn[i+1] ); - else if ( conn[i] == conn[i+2] || conn[i] == conn[i+3] ) - std::swap( conn[i], conn[i+1] ); - } - if ( conn[i+1] == conn[i-1] ) - std::swap( conn[i], conn[i+1] ); - } - } - return; - } - - // Fix order of nodes - - // select two ordinates for sorting - int i1 = 0, i2 = 1, i3 = 2; - if ( fabs( normal[i1] ) > fabs( normal[i3] )) swap( i1, i3 ); - if ( fabs( normal[i2] ) > fabs( normal[i3] )) swap( i2, i3 ); - - // comparator of nodes - TNodeCompare nodeCompare( nodeCoords, i1, i2 ); - - map< int, vector< int > >::iterator nbN_conn = connByNbNodes.begin(); - for ( ; nbN_conn != connByNbNodes.end(); ++nbN_conn ) - { - if ( nbN_conn->second.empty() ) continue; - - int * conn = & nbN_conn->second[0]; - int * connEnd = conn + nbN_conn->second.size(); - - int nbNodesPerFace = nbN_conn->first; - list::const_iterator nbPolyNodes, npEnd = nbNodesPerPolygon.end(); - - for ( nbPolyNodes = nbNodesPerPolygon.begin(); conn != connEnd; conn += nbNodesPerFace ) - { - if ( nbPolyNodes != npEnd ) - nbNodesPerFace = *nbPolyNodes++; - - // Sort nodes of polygons and quadrangles - - if ( nbNodesPerFace > 3 ) - { - // get barycenter - double bary[2] = { 0., 0. }; - for ( int i = 0; i < nbNodesPerFace; ++i ) { - const double* coord = nodeCoords + spaceDim*(conn[i]-1); - bary[0] += coord[i1]; bary[1] += coord[i2]; - } - bary[0] /= nbNodesPerFace; bary[1] /= nbNodesPerFace; - nodeCompare.setBaryCenter( bary ); - - // sorting - std::sort( conn, conn + nbNodesPerFace, nodeCompare); - } - - // Fix orientation of faces, orient them to have thier normal collinear with plane normal - - // calculate cross product of two adjacent segments - double dot = 0.; - int i = 0; - do { - const double* p1 = nodeCoords + spaceDim*(conn[i+0]-1); - const double* p2 = nodeCoords + spaceDim*(conn[i+1]-1); - const double* p3 = nodeCoords + spaceDim*(conn[i+2]-1); - double p2p1[2] = { p1[i1]-p2[i1] , p1[i2]-p2[i2] }; - double p2p3[2] = { p3[i1]-p2[i1] , p3[i2]-p2[i2] }; - dot = p2p3[1] * p2p1[0] - p2p3[0] * p2p1[1]; - ++i; - } - while ( dot == 0. && i+2 < nbNodesPerFace ); - - if ( dot * normal[i3] < 0. ) - std::reverse( conn, conn + nbNodesPerFace ); - } - } -} -//================================================================================ -/*! - * \brief Makes a 1D mesh by transfixing faces of 3D cells of input mesh by the line - * \param coords - give a point to pass through by the line - * \param direction - direction of the line - * \param new2oldCells - output map of new cells to cut input cell - */ -//================================================================================ - -MESH* Extractor::transfixFaces( const double* coords, - const double* direction, - map >& new2oldCells) -{ - const MESH* inMesh = _myInputMesh; - TMeshData inMeshData( *inMesh ); - TLine line( direction, coords ); - - const int nbFaces = inMesh->getNumberOfElements( MED_FACE, MED_ALL_ELEMENTS ); - const int dim = 3; - - // Intersect 1st domain - - vector< TIntersection*> chains; - vector< pair< double, double > > ranges; - int nbSegments = 0; // in the future mesh - - set checkedCells; - checkedCells.insert(0); // 0 is returned by getCellsByFace() for boundary faces - - int face = 1; - for ( ; face <= nbFaces; ++face ) { - if ( int soleCell = inMeshData.isFreeFace( face )) - if ( checkedCells.insert(soleCell).second && - canIntersect( soleCell, inMeshData, line )) - if ( TIntersection* chain = intersect( soleCell, inMeshData, line, checkedCells )) { - chains.push_back( chain ); - double min = DBL_MAX, max = -DBL_MAX; - chain->getRange( min, max, line._maxDir ); - ranges.push_back( make_pair( min, max )); - nbSegments += chain->size() - 1; - break; - } - } - if ( chains.empty() ) - return 0; - - // Intersect the rest domains - - for ( ; face <= nbFaces; ++face ) { - if ( int soleCell = inMeshData.isFreeFace( face )) - if ( checkedCells.insert(soleCell).second) - { - // check if at least one node of face is out of ranges of found chains - TIter nodes = inMeshData.getFaceNodes( face ); - bool isOut = false; - while ( nodes.more() && !isOut ) { - double coord = inMeshData.getNodeCoord( nodes.next() )[ line._maxDir ]; - bool isIn = false; - for ( unsigned i = 0; i < ranges.size() && !isIn; ++i ) { - const pair< double, double > & minMax = ranges[i]; - isIn = ( minMax.first < coord && coord < minMax.second ); - } - isOut = !isIn; - } - // try to intersect - if ( isOut && canIntersect( soleCell, inMeshData, line )) - if ( TIntersection* chain = intersect( soleCell, inMeshData, line, checkedCells )) { - chains.push_back( chain ); - double min = DBL_MAX, max = -DBL_MAX; - chain->getRange( min, max, line._maxDir ); - ranges.push_back( make_pair( min, max )); - nbSegments += chain->size() - 1; - } - } - } - - // Fill mesh data - - int nbNodes = nbSegments + chains.size(); - vector< double > resCoords( nbNodes * dim ); - vector< int > resConn; resConn.reserve( nbSegments * 2 ); - - int iNode = 1, iSeg = 1; - double* coord = & resCoords[0]; - const size_t cooSize = size_t( sizeof(double)*dim ); - - for ( unsigned i = 0; i < chains.size(); ++i ) { - TIntersection* section = chains[i]; - while ( section ) { - memcpy( coord, section->_point, cooSize ); - coord += dim; - if ( section->_prevSection ) { - resConn.push_back( iNode++ ); - resConn.push_back( iNode ); - new2oldCells[ iSeg++ ] = section->_cells; - } - section = section->_prevSection; - } - iNode++; - delete chains[i]; - } - - // Create mesh - - MESHING* meshing = new MESHING(); - - meshing->setName(STRING("Cut of ") << inMesh->getName()); - meshing->setNumberOfTypes( 1, MED_CELL ); - meshing->setCoordinates( dim, nbNodes, &resCoords[0], - inMesh->getCoordinatesSystem(), MED_FULL_INTERLACE ); - meshing->setTypes( &MED_SEG2, MED_CELL ); - meshing->setNumberOfElements( &nbSegments, MED_CELL); - meshing->setConnectivity( MED_CELL, MED_SEG2, & resConn[0]); - - return meshing; -} - -} // namespace MEDMEM - - -class MapGeoEdge : public map< medGeometryElement, vector* > -{ -public: - MapGeoEdge(); - ~MapGeoEdge(); -}; - -MapGeoEdge::MapGeoEdge() -{ - std::vector *edges=(*this)[MED_TRIA3]=(*this)[MED_TRIA6]=new vector(); - edges->reserve( 3 ); - edges->push_back( TEdge( 0, 1 )); - edges->push_back( TEdge( 1, 2 )); - edges->push_back( TEdge( 2, 0 )); - edges=(*this)[MED_QUAD4]=(*this)[MED_QUAD8]=new vector(); - edges->reserve( 4 ); - edges->push_back( TEdge( 0, 1 )); - edges->push_back( TEdge( 1, 2 )); - edges->push_back( TEdge( 2, 3 )); - edges->push_back( TEdge( 3, 0 )); - edges=(*this)[MED_TETRA4]=(*this)[MED_TETRA10]=new vector(); - edges->reserve( 6 ); - edges->push_back( TEdge( 0, 1 )); - edges->push_back( TEdge( 1, 2 )); - edges->push_back( TEdge( 2, 0 )); - edges->push_back( TEdge( 0, 3 )); - edges->push_back( TEdge( 1, 3 )); - edges->push_back( TEdge( 2, 3 )); - edges=(*this)[MED_HEXA8]=(*this)[MED_HEXA20]=new vector(); - edges->reserve( 12 ); - edges->push_back( TEdge( 0, 1 )); - edges->push_back( TEdge( 1, 2 )); - edges->push_back( TEdge( 2, 3 )); - edges->push_back( TEdge( 3, 0 )); - edges->push_back( TEdge( 4, 5 )); - edges->push_back( TEdge( 5, 6 )); - edges->push_back( TEdge( 6, 7 )); - edges->push_back( TEdge( 7, 4 )); - edges->push_back( TEdge( 0, 4 )); - edges->push_back( TEdge( 1, 5 )); - edges->push_back( TEdge( 2, 6 )); - edges->push_back( TEdge( 3, 7 )); - edges=(*this)[MED_PYRA5]=(*this)[MED_PYRA13]=new vector(); - edges->reserve( 8 ); - edges->push_back( TEdge( 0, 1 )); - edges->push_back( TEdge( 1, 2 )); - edges->push_back( TEdge( 2, 3 )); - edges->push_back( TEdge( 3, 0 )); - edges->push_back( TEdge( 0, 4 )); - edges->push_back( TEdge( 1, 4 )); - edges->push_back( TEdge( 2, 4 )); - edges->push_back( TEdge( 3, 4 )); - edges=(*this)[MED_PENTA6]=(*this)[MED_PENTA15]=new vector(); - edges->reserve( 9 ); - edges->push_back( TEdge( 0, 1 )); - edges->push_back( TEdge( 1, 2 )); - edges->push_back( TEdge( 2, 0 )); - edges->push_back( TEdge( 3, 4 )); - edges->push_back( TEdge( 4, 5 )); - edges->push_back( TEdge( 5, 3 )); - edges->push_back( TEdge( 0, 4 )); - edges->push_back( TEdge( 1, 5 )); - edges->push_back( TEdge( 2, 3 )); - (*this)[MED_NONE] = 0; - (*this)[MED_POINT1] = 0; - (*this)[MED_SEG2] = 0; - (*this)[MED_SEG3] = 0; - (*this)[MED_POLYGON] = 0; - (*this)[MED_POLYHEDRA] = 0; - (*this)[MED_ALL_ELEMENTS] = 0; -} - -MapGeoEdge::~MapGeoEdge() -{ - delete (*this)[MED_TRIA6]; - delete (*this)[MED_QUAD8]; - delete (*this)[MED_TETRA10]; - delete (*this)[MED_HEXA20]; - delete (*this)[MED_PYRA13]; - delete (*this)[MED_PENTA15]; -} - -//================================================================================ -/*! - * \brief Constructs TEdgeIterator on given classical cell type - */ -//================================================================================ - -TEdgeIterator::TEdgeIterator(const medGeometryElement type) -{ - static MapGeoEdge _edgesByType; - _edges = _edgesByType[type]; -} - -namespace { - -//================================================================================ -/*! - * \brief Transfixes a cell with a line. Returns a head of chain of intersections - * \param cell - cell id to transfixe - * \param meshData - input 3D mesh - * \param line - cutting line - * \param checkedCells - set of cell already tried - * \param prevInter - previosly found intersection. Used to build a chain of - * intersection via recursive call - */ -//================================================================================ - -TIntersection* intersect(const int cell, - const TMeshData& meshData, - const TLine& line, - set& checkedCells, - TIntersection* prevInter) -{ - TIntersection* newSection = 0; // section to find - TIntersection* auxSection = 0; // second section used when !prevInter - list< TIntersection > bndSections;// list of intersection on edges - - int avoidFace = prevInter ? prevInter->_face : -1; - - TIter faces = meshData.getFaces( cell ); - while ( faces.more() ) ///////// loop on faces of the cell - { - int face = abs( faces.next() ); - if ( face == avoidFace ) - continue; - TIter nodes = meshData.getFaceNodes( face ); - - // Get face normal - // ---------------- - - double faceNormal[3]; - bool zeroArea = calcFaceNormal( face, meshData, faceNormal ); - if ( zeroArea ) - continue; // next face - - // Is face parallel to line - // ------------------------- - - double dirDotNorm = dotProduct( line._dir, faceNormal ); - const double* pFace0 = meshData.getNodeCoord( nodes[0] ); - if ( fabs( dirDotNorm ) < _TOLER ) - { - // line || face, check if the line lays on the face - - double lf[3] = { line._coord[0] - pFace0[0], - line._coord[1] - pFace0[1], - line._coord[2] - pFace0[2] }; - double lfDotNorm = dotProduct( lf, faceNormal ); - if ( fabs( lfDotNorm ) < _TOLER ) - { - // ========================================================= - // Line lays on face. Intersect line with edges of the face - // ========================================================= - - // Calculate distance of nodes from the line - // ------------------------------------------ - double lineNormal[3]; - crossProduct( faceNormal, line._dir, lineNormal ); - vector dist( nodes.size(), 0.0 ); - for ( int n = 0; n < nodes.size(); ++n ) - { - const double* p = meshData.getNodeCoord( nodes[n] ); - for ( int j = 0; j < 3; ++j ) - dist[n] += lineNormal[j] * ( p[j] - line._coord[j] ); - } - // Find intersections - // ------------------- - vector pCoords; // intersection coordinates - set pAtNodes; // intersected nodes of the face - list cutEdges; // intersected edges - int nbPoints = 0; // nb intersections - pCoords.reserve(6); - for ( int n = 0; n < nodes.size() && nbPoints < 2; ++n ) - { - int n2 = (n+1) % nodes.size(); - double dist1 = dist[ n ]; - double dist2 = dist[ n2 ]; - bool n1OnLine = fabs( dist1 ) < meshData.tolerance(); - bool n2OnLine = fabs( dist2 ) < meshData.tolerance(); - if ( n1OnLine ) - pAtNodes.insert( nodes[n] ); - if ( n2OnLine ) - pAtNodes.insert( nodes[n2] ); - else if ( !n1OnLine && dist1 * dist2 < 0 ) { - const double* p1 = meshData.getNodeCoord( nodes[n] ); - const double* p2 = meshData.getNodeCoord( nodes[n2] ); - double r1 = dist1 / ( dist1 - dist2 ); - for ( int j = 0 ; j < 3; ++j ) - pCoords.push_back(( 1.-r1 ) * p1[ j ] + r1 * p2[ j ]); - cutEdges.push_back( TEdge( nodes[n], nodes[n2] )); - } - nbPoints = cutEdges.size() + pAtNodes.size(); - } - // coords of intersection are stored in pCoords in order: - // first go points on edges, then, points on nodes - if ( nbPoints == 2 && !pAtNodes.empty() ) { - set::iterator n = pAtNodes.begin(); - while ( pCoords.size() != 6 ) { // there must be coords of two points - const double* p = meshData.getNodeCoord( *n++ ); - for ( int j = 0 ; j < 3; ++j ) - pCoords.push_back( p[j] ); - } - } - // Store intersections - // -------------------- - if ( nbPoints == 2 ) - { - vector< TIntersection* > sections(nbPoints); - const double* intCoord = & pCoords[0]; - - for ( int i = 0; i < nbPoints; ++i, intCoord += 3 ) - { - // Set coords of intersection point - sections[i] = new TIntersection; - sections[i]->_point[0] = intCoord[0]; - sections[i]->_point[1] = intCoord[1]; - sections[i]->_point[2] = intCoord[2]; - - // Set intersected cells - if ( cutEdges.empty() ) { - // line can pass by edge shared by several cells - TEdge cutEdge( *pAtNodes.begin(), *pAtNodes.rbegin() ); - getCellsSharingEdge( cutEdge, meshData, sections[i]->_cells ); - } - if ( !cutEdges.empty() || sections[i]->_cells.empty() ) { - // line pass by face between two cells - TIter cells = meshData.getCellsByFace( face ); - while ( cells.more() ) - if ( int elem = cells.next() ) - sections[i]->_cells.insert( elem ); - } - // Not to check the face at next search - sections[i]->_face = face; - - // Set nodes to start search of next intersection from - if ( !cutEdges.empty() ) { - sections[i]->_startNodes.insert( cutEdges.front().node1() ); - sections[i]->_startNodes.insert( cutEdges.front().node2() ); - cutEdges.pop_front(); - } - else if ( pAtNodes.size() > 1 ) { - set::iterator p = pAtNodes.begin(); - if ( !line.isSame( intCoord, meshData.getNodeCoord( *p ))) - ++p; - sections[i]->_startNodes.insert( *p ); - pAtNodes.erase( p ); - } - else { - sections[i]->_startNodes.insert( *pAtNodes.begin() ); - } - } - if ( prevInter ) { - // Only one point is needed, exclude already found intersection - if ( line.isSame( prevInter->_point, sections[0]->_point )) - std::swap( sections[0], sections[1] ); - delete sections[1]; - sections[1] = 0; - } - newSection = sections[0]; - auxSection = sections[1]; - if ( auxSection ) - auxSection->_cells = newSection->_cells; - - bndSections.clear(); // remove already found intersections - - } // if ( nbPoints == 2 ) - - break; // from loop on faces of cell - - } // line lays on face - } - else - { - // ================================== - // Line intersects the plane of face - // ================================== - - // Find distance of intersection point from line origin - // t = faceNormal * ( pFace0 - line._coord ) / ( faceNormal * line._dir ) - - double pf0Coord[] = { pFace0[0] - line._coord[0], - pFace0[1] - line._coord[1], - pFace0[2] - line._coord[2] }; - double t = dotProduct( faceNormal, pf0Coord ) / dotProduct( faceNormal, line._dir ); - - // facePlane-line intersection point - double ip[] = { line._coord[0] + line._dir[0] * t, - line._coord[1] + line._dir[1] * t, - line._coord[2] + line._dir[2] * t}; - - if ( prevInter && line.isSame( ip, prevInter->_point )) - continue; - if ( !bndSections.empty() && line.isSame( ip, bndSections.back()._point )) - continue; - - // Check if intersection point (ip) is inside the face. - // ---------------------------------------------------- - - // do it in 2d, on the cartesian plane most normal to the face; - // find indices on that plane: i1, i2 - int i1 = 0, i2 = 1, i3 = 2; - if ( fabs( faceNormal[i1] ) > fabs( faceNormal[i3] )) swap( i1, i3 ); - if ( fabs( faceNormal[i2] ) > fabs( faceNormal[i3] )) swap( i2, i3 ); - if ( i2-i1 != 1 && i2 != 0 ) swap ( i1, i2 ); - - int inside = true, nbOnBoundary = 0; - TEdge cutEdge; - for ( int n = 0; n < nodes.size() && inside; ++n ) - { - const double* p0 = meshData.getNodeCoord( nodes[n] ); - const double* p1 = meshData.getNodeCoord( nodes[ (n+1) % nodes.size() ] ); - double sign = - faceNormal[i3]*((ip[i2] - p0[i2])*(p1[i1] - p0[i1]) - (ip[i1] - p0[i1])*(p1[i2] - p0[i2])); - if ( sign < -DBL_MIN ) - inside = false; - else if ( sign < DBL_MIN ) { - nbOnBoundary++; - cutEdge = TEdge( nodes, n ); - } - } - - // Store intersection point - // ------------------------- - if ( inside ) - { - TIntersection* section; - if ( !nbOnBoundary ) - section = new TIntersection; - else { - if ( bndSections.size() >= 2 ) - continue; // go to next face - bndSections.push_back( TIntersection() ); - section = & bndSections.back(); - // set nodes to start next searching from - if ( nbOnBoundary == 1 ) { - // edge is cut - section->_startNodes.insert( cutEdge.node1() ); - section->_startNodes.insert( cutEdge.node2() ); - } - else { // node is cut - const double* p1 = meshData.getNodeCoord( cutEdge.node1() ); - if ( fabs( ip[i1]-p1[i1] ) < _TOLER && fabs( ip[i2]-p1[i2] ) < _TOLER ) - section->_startNodes.insert( cutEdge.node1() ); - else - section->_startNodes.insert( cutEdge.node2() ); - } - } - section->_point[0] = ip[0]; - section->_point[1] = ip[1]; - section->_point[2] = ip[2]; - section->_face = face; - section->_cells.insert( cell ); - - if ( !nbOnBoundary ) - { - if ( !newSection ) - newSection = section; - else - auxSection = section; - if ( prevInter || auxSection ) { - bndSections.clear(); - break; // from loop on faces - } - } - } - } - } // loop on faces of cell - - // Care of intersections passing through edges - // -------------------------------------------- - - if ( !bndSections.empty() ) - { - if ( prevInter ) { // boundary section not equal to previous section - if ( !newSection ) - newSection = new TIntersection( bndSections.front() ); - } - else { - if ( !newSection ) { - newSection = new TIntersection( bndSections.front() ); - bndSections.pop_front(); - } - if ( !auxSection && !bndSections.empty() ) { - auxSection = new TIntersection( bndSections.front() ); - } - } - } - - // Find the rest of chain starting from the found sections - // -------------------------------------------------------- - - if ( newSection && ( prevInter || auxSection )) - { - TIntersection* chain[] = { newSection, auxSection }; - int chainLength[] = {0,0}; - for ( int i = 0; i < 2; ++i ) - { - TIntersection* section = chain[i]; - if ( !section ) continue; - // get cells to try to intersect next - set cellsToCheck; - if ( !section->_startNodes.empty() ) { - if ( section->_startNodes.size() == 1 ) { - TIter cells = meshData.getCellsByNode( *section->_startNodes.begin() ); - cellsToCheck.insert( cells.begin(), cells.end() ); - } - else { - TEdge cutEdge( *section->_startNodes.begin(), *section->_startNodes.rbegin() ); - getCellsSharingEdge( cutEdge, meshData, cellsToCheck ); - } - } - else { - TIter cells = meshData.getCellsByFace( section->_face ); - cellsToCheck.insert( cells.begin(), cells.end() ); - } - // find the rest intersections - chain[i] = 0; - set::iterator elem = cellsToCheck.begin(), elemEnd = cellsToCheck.end(); - for ( ; elem != elemEnd && !chain[i]; ++elem ) { - if ( checkedCells.insert( *elem ).second && - section->_cells.find( *elem ) == section->_cells.end() ) - { - chain[i] = intersect( *elem, meshData, line, checkedCells, section ); - } - } - if ( chain[i] ) - chainLength[i] = chain[i]->size(); - } - - // Connect just found sections into a chain - if ( prevInter ) { - newSection->_prevSection = prevInter; - } - else { - if ( chainLength[0] < chainLength[1] ) { - std::swap( chain[0], chain[1] ); - std::swap( newSection, auxSection ); - } - if ( chain[1] ) - chain[1]->reverse(); - newSection->_prevSection = auxSection; - } - - if ( chain[0] ) - return chain[0]; - return newSection; - } - else { - delete newSection; - } - - return 0; -} - -//================================================================================ -/*! - * \brief Evaluate if the line can intersect a cell - */ -//================================================================================ - -bool canIntersect(const int cell, - const TMeshData& meshData, - const TLine& line) -{ - // calculate bnd box of the cell - double min[] = { DBL_MAX,DBL_MAX,DBL_MAX }, max[] = { -DBL_MAX,-DBL_MAX,-DBL_MAX }; - - TIter cellNodes = meshData.getCellNodes( cell ); - for ( int n = 0; n < cellNodes.size(); ++n ) { - const double* node = meshData.getNodeCoord( cellNodes[n] ); - for ( int j = 0; j < 3; ++j ) { - if ( node[j] < min[j] ) min[j] = node[j]; - if ( node[j] > max[j] ) max[j] = node[j]; - } - } - double xmin = 0, xmax = 0, ymin = 0, ymax = 0, zmin, zmax; - double parmin, parmax, par1, par2; - bool xToSet, yToSet; - const double infinite = 1e100; - - if (fabs(line._dir[0])>0.) { - par1=(min[0]-line._coord[0])/line._dir[0]; - par2=(max[0]-line._coord[0])/line._dir[0]; - parmin=std::min(par1, par2); - parmax=std::max(par1, par2); - xToSet=true; - } - else { - if (line._coord[0]0.) { - par1=(min[1]-line._coord[1])/line._dir[1]; - par2=(max[1]-line._coord[1])/line._dir[1]; - if(parmax < std::min(par1,par2) || parmin > std::max(par1,par2)) - return false; - parmin=std::max(parmin, std::min(par1,par2)); - parmax=std::min(parmax, std::max(par1,par2)); - yToSet=true; - } - else { - if (line._coord[1]0.) { - par1=(min[2]-line._coord[2])/line._dir[2]; - par2=(max[2]-line._coord[2])/line._dir[2]; - if(parmax < std::min(par1,par2) || parmin > std::max(par1,par2)) - return false; - parmin=std::max(parmin, std::min(par1,par2)); - parmax=std::min(parmax, std::max(par1,par2)); - par1=line._coord[2]+parmin*line._dir[2]; - par2=line._coord[2]+parmax*line._dir[2]; - zmin=std::min(par1, par2); - zmax=std::max(par1, par2); - } - else { - if (line._coord[2] -#include -#include - -namespace MEDMEM -{ - /*! - * \brief Tool taking an input field and making a field of lower dimension - * by cutting the given field by a plane or a line. - * - * The following extractions are possible:
    - *
  • 3D -> 2D (3D mesh cut by plane)
  • - *
  • 3D -> 1D (3D mesh cut by line)
  • - *
  • 2D -> 1D (2D mesh cut by line in 2D space or by plane in 3D space)
- */ - class MEDMEM_EXPORT Extractor - { - /*! - * \brief Creates a tool - * \param inputField - input field - * - * The input field is supposed to comply with following conditions
    - *
  • it is constant by element (i.e. has 1 gauss point),
  • - *
  • it's support mesh does not contain poly elements,
  • - *
  • volumic elements have planar faces,
  • - *
  • surfasic elements have linear edges.
- */ - public: - Extractor(const FIELD& inputField) throw (MEDEXCEPTION); - ~Extractor(); - /*! - * \brief Creates a field by cutting inputField by a plane - * \param coords - give a point to pass through by the plane - * \param normal - gives the plane normal - * \retval FIELD* - resulting field holding ownership of its support, - * which in its turn holds ownership of its mesh - */ - FIELD* extractPlane(const double* coords, const double* normal) throw (MEDEXCEPTION); - - /*! - * \brief Creates a field by cutting inputField by a line - * \param coords - give a point to pass through by the line - * \param direction - gives a vector collinear to the line - * \retval FIELD* - resulting field holding ownership of its support, - * which in its turn holds ownership of its mesh - */ - FIELD* extractLine(const double* coords, const double* direction) throw (MEDEXCEPTION); - - private: - - MESH* divideEdges(const double* coords, - const double* normal, - std::map >& new2oldCells); - - MESH* transfixFaces( const double* coords, - const double* direction, - std::map >& new2oldCells); - - FIELD* makeField( const std::map >& new2oldCells, - MESH* mesh) const; - - void computeDistanceOfNodes(const double* point, const double* normal); - - void sortNodes( std::map< int, std::vector< int > >& connByNbNodes, - const double* nodeCoords, - const double* point, - const double* normal, - const std::list & nbNodesPerPolygon); - - - const FIELD* _myInputField; //!< input field - const MESH* _myInputMesh; //!< unstructured field support mesh - std::vector _myNodeDistance; //!< distance of input nodes to cutting tool - }; -} - -#endif diff --git a/src/MEDMEM/MEDMEM_Family.cxx b/src/MEDMEM/MEDMEM_Family.cxx deleted file mode 100644 index 058dfaafb..000000000 --- a/src/MEDMEM/MEDMEM_Family.cxx +++ /dev/null @@ -1,407 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -/* - File MEDMEM_Family.cxx -*/ - -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Family.hxx" - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -/* - Those defines are from the med File V2.1 and for this class they are fixed. -*/ - -#define MED_TAILLE_DESC 200 -#define MED_TAILLE_LNOM 80 - -FAMILY::FAMILY():_identifier(0), _numberOfAttribute(0), _numberOfGroup(0) -{ - MESSAGE_MED("FAMILY::FAMILY()"); -} - -FAMILY::FAMILY(GMESH* Mesh, int Identifier, string Name, int NumberOfAttribute, - int *AttributeIdentifier, int *AttributeValue, string AttributeDescription, - int NumberOfGroup, string GroupName, - int * MEDArrayNodeFamily, - int ** MEDArrayCellFamily, - int ** MEDArrayFaceFamily, - int ** MEDArrayEdgeFamily - ): SUPPORT(), - _identifier(Identifier), - _numberOfAttribute(NumberOfAttribute), - _numberOfGroup(NumberOfGroup) -{ - MESSAGE_MED("FAMILY(int Identifier, string Name, int NumberOfAttribute,int *AttributeIdentifier,int *AttributeValue,string AttributeDescription,int NumberOfGroup,string GroupName, int ** Number) : "< 0) - { - _attributeIdentifier.set(_numberOfAttribute,AttributeIdentifier); - _attributeValue.set(_numberOfAttribute,AttributeValue); - - _attributeDescription.resize(_numberOfAttribute); - for (int i=0;i in order to create - // the list of node numbers belonging to the family <_identifier> - int NumberOfNodes = _mesh->getNumberOfNodes(); - int NumberOfNodesInFamily = 0 ; - int * tmp_NodesList = new int[NumberOfNodes] ; // Un peu brutal...., oui mais ce n'est qu'un tableau de travail ! - for (int i=0; i0) - { - Find = true ; - - _entity = MED_NODE ; - - // family on all NODE - if (NumberOfNodesInFamily==NumberOfNodes) - { - _isOnAllElts = true ; - update(); - } - else - { - _numberOfGeometricType = 1 ; - - _geometricType.set(1) ; - - _geometricType[0]=MED_NONE ; - _isOnAllElts= false ; - - _numberOfElements.set(1) ; - - _numberOfElements[0]=NumberOfNodesInFamily ; - _totalNumberOfElements=NumberOfNodesInFamily; - - int * NumberIndex = new int[2]; - int * NumberValue = new int[NumberOfNodesInFamily]; - - NumberIndex[0]=1; //set the MEDSKYLINEARRAY Index table - NumberIndex[1]=1+NumberOfNodesInFamily; //set the MEDSKYLINEARRAY Index table - for(int i=0; i in order to create - // ?? the list of node numbers belonging to the family <_identifier> - if (!Find) - { - Find = build(MED_CELL,MEDArrayCellFamily) ; - } - // on face ? - if (!Find) - { - if ( _mesh->getNumberOfElements(MED_FACE, MED_ALL_ELEMENTS) > 0 ) - Find = build(MED_FACE,MEDArrayFaceFamily) ; - } - - // on edge ? - if (!Find) - { - if ( _mesh->getNumberOfElements(MED_EDGE, MED_ALL_ELEMENTS) > 0 ) - Find = build(MED_EDGE,MEDArrayEdgeFamily) ; - } - // That's all ! - - // if not find : no entity in familly !!! - if (!Find) - { - _numberOfGeometricType = 0 ; - _isOnAllElts = false ; - MESSAGE_MED ("FAMILY() : No entity found !") ; - } - - MESSAGE_MED("Well now ??? :::"); - - MESSAGE_MED("Name : "<< getName()); - MESSAGE_MED("Description : "<< getDescription()); - MESSAGE_MED("Mesh name : " << getMesh()->getName()); - MESSAGE_MED("Entity : "<< getEntity()); - MESSAGE_MED("Entity list :"); - if ( !isOnAllElements() ) - { - MESSAGE_MED("NumberOfTypes : "< - int numberOfTypes = _mesh->getNumberOfTypes(Entity) ; - const medGeometryElement * types = _mesh->getTypes(Entity) ; - - int * numberOfElementsInFamily = new int[numberOfTypes] ; - int numberOfElementTypesInFamily = 0 ; - - medGeometryElement * tmp_Types = new medGeometryElement[numberOfTypes]; - int ** tmp_ElementsLists = new int*[numberOfTypes] ; - int elementNumber = 1; - - - SCRUTE_MED(numberOfTypes); - - // we search for all elements in this family - for (int TypeNumber=0; TypeNumber < numberOfTypes; TypeNumber++) { - - int NumberOfElements = _mesh->getNumberOfElements(Entity,types[TypeNumber]) ; - int NumberOfElementsInThisFamily = 0 ; - int * ElementsOfThisFamilyNumber = FamilyNumber[TypeNumber]; - int * tmp_ElementsList = new int[NumberOfElements]; - - for (int i=0; i0) {// we have found some elements - numberOfElementsInFamily[numberOfElementTypesInFamily]=NumberOfElementsInThisFamily; - - int * ElementsList = new int[NumberOfElementsInThisFamily] ; - memcpy(ElementsList,tmp_ElementsList,sizeof(int)*NumberOfElementsInThisFamily); // RESIZE de tmp_NodesList serait plus efficace !!!!!!!! - - tmp_ElementsLists[numberOfElementTypesInFamily]=ElementsList ; - tmp_Types[numberOfElementTypesInFamily]=types[TypeNumber]; - numberOfElementTypesInFamily++; - } - delete[] tmp_ElementsList; - } - - // we define all attribut in SUPPORT : - if (numberOfElementTypesInFamily>0) // we have found elements - { - Find = true ; - _entity = Entity ; - _numberOfGeometricType = numberOfElementTypesInFamily ; - _geometricType.set(numberOfElementTypesInFamily) ; - - _isOnAllElts = false ; - - _numberOfElements.set(numberOfElementTypesInFamily) ; - _totalNumberOfElements=0; - - for (int i=0; igetNumberOfElements(Entity,MED_ALL_ELEMENTS)) - { - _isOnAllElts = true ; - update(); - // all others attributs are rights ! - for (int i=0; i<_numberOfGeometricType; i++) - delete[] tmp_ElementsLists[i]; - } - else - { - int *NumberValue = new int[_totalNumberOfElements]; - int *NumberIndex = new int[_numberOfGeometricType+1]; - NumberIndex[0]=1; - for (int i=0; i<_numberOfGeometricType; i++) - { - NumberIndex[i+1]=NumberIndex[i]+_numberOfElements[i]; - for (int j=NumberIndex[i]; j -#include "MEDMEM_Support.hxx" - -/*! - - This class describe a family of elements on an entity.\n - It inherits from support. \n - It contains a list of elements (by SUPPORT class inheritance) - and a description of some attributs.\n - - All families on one entity represent a mesh partition for this entity. - -*/ -namespace MEDMEM { - class FAMILY; - MEDMEM_EXPORT std::ostream & operator<<(std::ostream &os, FAMILY &my); - MEDMEM_EXPORT std::ostream & operator<<(std::ostream &os, const FAMILY &my) ; - -class MEDMEM_EXPORT FAMILY : virtual public SUPPORT -{ -protected : - /*! - \if developper - Identifier of the family in the mesh - Note : There is precisely one for each family. - \endif - */ - int _identifier ; - /*! - \if developper - Number of attribute of the family .\n - Note that attributes are numbered from 1 to N. - \endif - */ - int _numberOfAttribute ; - /*! - \if developper - Array of all attributes' identifiers. - There is one for each attribute. - \endif - */ - PointerOf _attributeIdentifier ; - /*! - \if developper - Array of all attributes' values. - There is one for each attribute. - \endif - */ - PointerOf _attributeValue ; - /*! - \if developper - Array of all attributes' descriptions. - There is one for each attribute. - \endif - */ - //PointerOf _attributeDescription ; - std::vector _attributeDescription ; - /*! - \if developper - Number of the group the family belongs to. - \endif - */ - int _numberOfGroup ; - /*! - \if developper - Name of the group the family belongs to. - \endif - */ - //PointerOf _groupName ; - std::vector _groupName ; - protected: -/*! Destructor. */ - virtual ~FAMILY(); -public: - /*! Constructor. */ - FAMILY(); - /*! - \if developper - Constructor to use with med driver. - \endif - */ - FAMILY( GMESH* Mesh, int Identifier, string Name, - int NumberOfAttribute, int *AttributeIdentifier, - int *AttributeValue, string AttributeDescription, - int NumberOfGroup, string GroupName, - int * MEDArrayNodeFamily, - int ** MEDArrayCellFamily, - int ** MEDArrayFaceFamily, - int ** MEDArrayEdgeFamily - ) ; - - /*! Copy Constructor. */ - FAMILY(const FAMILY & m); - - /*! Constructor with SUPPORT entry. */ - FAMILY(const SUPPORT & s); - - - FAMILY & operator=(const FAMILY &fam); - friend std::ostream & operator<<(std::ostream &os, FAMILY &my) ; - - friend std::ostream & operator<<(std::ostream &os, const FAMILY &my) ; - - bool build(MED_EN::medEntityMesh Entity,int **FamilyNumber); - - // Il faudrait mettre en cohérence les méthodes set - // avec l'opérateur d'affection ! Rmq from EF !!! - - inline void setIdentifier (int Identifier); - inline void setNumberOfAttributes (int NumberOfAttribute); - inline void setAttributesIdentifiers (int * AttributeIdentifier); - inline void setAttributesValues (int * AttributeValue); - inline void setAttributesDescriptions (std::string * AttributeDescription); - inline void setNumberOfGroups (int NumberOfGroups); - inline void setGroupsNames (std::string * GroupName, bool giveOwnership=false); - - inline int getIdentifier() const; - inline int getNumberOfAttributes() const; - inline const int * getAttributesIdentifiers() const; - inline const int * getAttributesValues() const; - inline const std::string* getAttributesDescriptions() const; - inline int getNumberOfGroups() const; - inline const std::string* getGroupsNames() const; - - // A FAIRE : VERIFIER LA VALIDITE DES PARAMETRES ! - inline int getAttributeIdentifier(int i) const; - inline int getAttributeValue(int i) const; - inline std::string getAttributeDescription(int i) const; - inline std::string getGroupName(int i) const; -}; - -// inline methods : -/*! Sets the attribute _identifier to Identifier. */ -//---------------------------------------------- -inline void FAMILY::setIdentifier(int Identifier) -//---------------------------------------------- -{ - _identifier = Identifier; -} - -/*! Sets the attribute _numberOfAttribute to NumberOfAttribute. */ -//-------------------------------------------------------------- -inline void FAMILY::setNumberOfAttributes(int NumberOfAttribute) -//-------------------------------------------------------------- -{ - _numberOfAttribute = NumberOfAttribute; -} - -/*! Sets the attribute _attributeIdentifier to AttributeIdentifier. */ -//--------------------------------------------------------------------- -inline void FAMILY::setAttributesIdentifiers(int * AttributeIdentifier) -//--------------------------------------------------------------------- -{ - //_attributeIdentifier = AttributeIdentifier ; - _attributeIdentifier.setShallowAndOwnership(AttributeIdentifier) ; -} - -/*! Sets the attribute _attributeValue to AttributeValue. */ -//----------------------------------------------------------- -inline void FAMILY::setAttributesValues(int * AttributeValue) -//----------------------------------------------------------- -{ - //_attributeValue = AttributeValue ; - _attributeValue.setShallowAndOwnership(AttributeValue) ; -} - -/*! Sets the attribute _attributeDescription to AttributeDescription. */ -//-------------------------------------------------------------------------- -inline void FAMILY::setAttributesDescriptions(std::string * AttributeDescription) -//-------------------------------------------------------------------------- -{ - //_attributeDescription = AttributeDescription ; - //_attributeDescription.setShallowAndOwnership(AttributeDescription) ; - int nbAttr = getNumberOfAttributes(); -// if(nbAttr<1) { -// std::string diagnosis; -// diagnosis="Can not set attributes descriptions - number of attributes is not set"; -// throw MEDMEM::MEDEXCEPTION(diagnosis.c_str()); -// } - _attributeDescription.resize(nbAttr); - for(int i=0; i -// if (giveOwnership) -// _groupName.setShallowAndOwnership(GroupName); -// else -// //_groupName = GroupName ; -// _groupName.set(_numberOfGroup, GroupName) ; - - int nbGr = getNumberOfGroups(); -// if(nbGr<1) { -// std::string diagnosis; -// diagnosis="Can not set groups names - number of groups is not set"; -// throw MEDMEM::MEDEXCEPTION(diagnosis.c_str()); -// } - if (giveOwnership) { - //_groupName.setShallowAndOwnership(GroupName); - _groupName.resize(nbGr); - for(int i=0; igetNumberOfElements(MED_ALL_ELEMENTS); - _componentsTypes.resize(NumberOfComponents); - _componentsNames.resize(NumberOfComponents); - _componentsDescriptions.resize(NumberOfComponents); - _componentsUnits.resize(NumberOfComponents); - _MEDComponentsUnits.resize(NumberOfComponents); - for(int i=0;iaddReference(); -} - -FIELD_& FIELD_::operator=(const FIELD_ &m) { - - if ( this == &m) return *this; - - _isRead = m._isRead ; - _isMinMax = m._isMinMax ; - _name = m._name; - _description = m._description; - if(_support!=m._support) - { - if(_support) - _support->removeReference(); - _support=m._support; //Cf Opérateur de recopie du Support? - if(_support) - _support->addReference(); - } - _numberOfComponents = m._numberOfComponents; - _numberOfValues = m._numberOfValues; - - _componentsTypes.resize(_numberOfComponents); - for (int i=0; i - - //_drivers = m._drivers ; // PG : Well, same driver, what about m destructor ! - - return *this; -} - -FIELD_::FIELD_(const FIELD_ &m) -{ - _isRead = m._isRead ; - _isMinMax = m._isMinMax ; - _name = m._name; - _description = m._description; - _support = m._support; - if(_support) - _support->addReference(); - _numberOfComponents = m._numberOfComponents; - _numberOfValues = m._numberOfValues; - copyGlobalInfo(m); - //_valueType = m._valueType; - // _valueType et _interlacingType doivent uniquement être recopiés - // par l'opérateur de recopie de FIELD - //_drivers = m._drivers ; // PG : Well, same driver, what about m destructor ! -} - -FIELD_::~FIELD_() -{ - MESSAGE_MED("~FIELD_()"); - - MESSAGE_MED("In this object FIELD_ there is(are) " << _drivers.size() << " driver(s)"); - - for (unsigned int index=0; index < _drivers.size(); index++ ) - { - SCRUTE_MED(_drivers[index]); - if ( _drivers[index] != NULL) delete _drivers[index]; - } - _drivers.clear(); - if(_support) - _support->removeReference(); - _support=0; -} - -/*! - \if developper - PROVISOIRE : retourne des volumes, surfaces ou longueurs suivant les cas - \endif -*/ -FIELD* FIELD_::_getFieldSize(const SUPPORT *subSupport) const -{ - FIELD* p_field_size; - - const SUPPORT* support = subSupport; - if ( !support ) - { - if ( getSupport()->getEntity() == MED_NODE ) - support = getSupport()->getMesh()->getSupportOnAll( MED_CELL ); - else - support = getSupport(); - support->addReference(); - } - const GMESH* mesh = getSupport()->getMesh(); - switch (getSupport()->getEntity()) - { - case MED_CELL : - switch (mesh->getMeshDimension() ) - { - case 1: - p_field_size=mesh->getLength( support ); - break; - case 2: - p_field_size=mesh->getArea( support ); - break; - case 3: - p_field_size=mesh->getVolume( support ); - break; - } - break; - - case MED_FACE : - p_field_size=mesh->getArea( support ); - break; - - case MED_EDGE : - p_field_size=mesh->getLength( support ); - break; - case MED_NODE : // issue 0020120: [CEA 206] normL2 on NODE field - { - switch (mesh->getMeshDimension() ) - { - case 1: - p_field_size=mesh->getLength( support ); - break; - case 2: - p_field_size=mesh->getArea( support ); - break; - case 3: - p_field_size=mesh->getVolume( support ); - break; - } - break; - } - } - if(!subSupport && support) - support->removeReference(); - return p_field_size; -} - - -/*! - \if developper - Check up the compatibility of field before computing sobolev norm - \endif -*/ -void FIELD_::_checkNormCompatibility(const FIELD* support_volume, - const bool nodalAllowed) const throw (MEDEXCEPTION) -{ - string diagnosis; - - if( getSupport()->getEntity() == MED_NODE) - { - if ( !nodalAllowed ) - { - diagnosis="Cannot compute sobolev norm on a field "+getName()+ - " : it has support on nodes!"; - throw MEDEXCEPTION(diagnosis.c_str()); - } - if ( !getSupport()->getMesh() ) - { - diagnosis="Cannot compute Lnorm of nodal field "+getName()+ - " : it's support has no mesh reference"; - throw MEDEXCEPTION(diagnosis.c_str()); - } - if ( !getSupport()->getMesh()->getIsAGrid() && - !( (const MESH*)getSupport()->getMesh() )->existConnectivity(MED_NODAL,MED_CELL) ) - { - diagnosis="Cannot compute Lnorm of nodal field"+getName()+ - " : it's supporting mesh has no nodal connectivity data"; - throw MEDEXCEPTION(diagnosis.c_str()); - } - } - - if (getNumberOfValues()*getNumberOfComponents()<= 0) // Size of array has to be strictly positive - { - diagnosis="Cannot compute the norm of "+getName()+ - " : it size is non positive!"; - throw MEDEXCEPTION(diagnosis.c_str()); - } - - if( getSupport()->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS) != getNumberOfValues() ) { - diagnosis="Cannot compute Lnorm of "+getName()+ - " : the suppors size not corresponded to number of elements!"; - throw MEDEXCEPTION(diagnosis.c_str()); - } - - if (getGaussPresence() ) { - diagnosis="Cannot compute Lnorm of "+getName()+ - " : Gauss numbers greater than one are not yet implemented!"; - throw MEDEXCEPTION(diagnosis.c_str()); - } - - if(support_volume) // if the user has supplied the volume - { - if ( getSupport()->getEntity() == MED_NODE ) - { - if (support_volume->getNumberOfValues()!= - getSupport()->getMesh()->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS)) - { - diagnosis="Cannot compute Lnorm of nodal field "+getName()+ - " : the volume furnished has wrong number of values"; - throw MEDEXCEPTION(diagnosis.c_str()); - } - return; - } - if(support_volume->getSupport()!=getSupport()) - { - diagnosis="Cannot compute Lnorm of "+getName()+ - " : the volume furnished has not the same support!"; - throw MEDEXCEPTION(diagnosis.c_str()); - } - if(support_volume->getNumberOfValues()!=getNumberOfValues()) - { - diagnosis="Cannot compute Lnorm of "+getName()+ - " : the volume furnished has not the same number of values!"; - throw MEDEXCEPTION(diagnosis.c_str()); - } - if( getSupport()->getNumberOfElements() != - support_volume->getSupport()->getNumberOfElements() ) { - diagnosis="Cannot compute Lnorm of "+getName()+ - " : the supports have not the same number of elements!"; - throw MEDEXCEPTION(diagnosis.c_str()); - } - } - -} - -/*! - \if developper - Check up the compatibility of fields before performing an arithmetic operation - \endif -*/ -void FIELD_::_checkFieldCompatibility(const FIELD_& m, const FIELD_& n, bool checkUnit) throw (MEDEXCEPTION) -{ - string diagnosis; - - // check-up, fill diagnosis if some incompatibility is found. - - // Ne pas vérifier l'entrelacement - // Le compilo s'en occupe Rmq from EF - - if(m._support != n._support) - { - if(!(*m._support==*n._support)) - diagnosis+="They don't have the same support!"; - } - else if(m._numberOfComponents != n._numberOfComponents) - diagnosis+="They don't have the same number of components!"; - else if (m._valueType != n._valueType) - diagnosis+="They don't have the same type!"; - else if(m._numberOfValues != n._numberOfValues) - diagnosis+="They don't have the same number of values!"; - else - { - if(checkUnit) - { - for(int i=0; ideepCompare(*n._support))) - diagnosis+="They don't have the same support!"; - } - else if (m._valueType != n._valueType) - diagnosis+="They don't have the same type!"; - else if(m._numberOfComponents != n._numberOfComponents) - diagnosis+="They don't have the same number of components!"; - else if(m._numberOfValues != n._numberOfValues) - diagnosis+="They don't have the same number of values!"; - else - { - if(checkUnit) - { - for(int i=0; i _componentsTypes ; - /*! - \if developper - Array of size _numberOfComponents - storing components names if any. - \endif - */ - vector _componentsNames; - /*! - \if developper - Array of size _numberOfComponents - storing components descriptions if any. - \endif - */ - vector _componentsDescriptions; - /*! - \if developper - Array of size _numberOfComponents - storing components units if any. - \endif - */ - vector _componentsUnits; - /*! - \if developper - Array of size _numberOfComponents - storing components units if any. - \endif - */ - vector _MEDComponentsUnits; - /*! - \if developper - Iteration number of the field. - \endif - */ - int _iterationNumber ; - /*! - \if developper - Time of the field. - \endif - */ - double _time; - /*! - \if developper - Order number of the field. - \endif - */ - int _orderNumber ; - /*! - \if developper - At the initialization step of the field using the constructors; this attribute, - the value type (integer or real) , is set automatically. There is a get method - but not a set method for this attribute. - \endif - */ - MED_EN::med_type_champ _valueType ; - /*! - \if developper - At the initialization step of the field using the constructors; this attribute, - the interlacing type (full interlace or no interlace field value storage), is set - automatically. There is a get method but not a set method for this attribute. - \endif - */ - MED_EN::medModeSwitch _interlacingType; - - vector _drivers; // Storage of the drivers currently in use - static void _checkFieldCompatibility(const FIELD_& m, const FIELD_& n, bool checkUnit=true) throw (MEDEXCEPTION); - static void _deepCheckFieldCompatibility(const FIELD_& m, const FIELD_& n, bool checkUnit=true) throw (MEDEXCEPTION); - void _checkNormCompatibility(const FIELD* p_field_volume=NULL, - const bool nodalAllowed = false) const throw (MEDEXCEPTION); - FIELD* _getFieldSize(const SUPPORT *subSupport=NULL) const; - public: - /*! - Constructor. - */ - FIELD_ (); - /*! \ifnot MEDMEM_ug - Constructor. -\endif - */ - FIELD_(const SUPPORT * Support, const int NumberOfComponents); - /*! \ifnot MEDMEM_ug - Copy constructor. -\endif - */ - FIELD_(const FIELD_ &m); - - /*! - Destructor. - */ - virtual ~FIELD_(); - -public: - - friend class MED_MED_RDONLY_DRIVER22; - friend class MED_MED_WRONLY_DRIVER22; - friend class MED_MED_RDWR_DRIVER22; - friend class VTK_MED_DRIVER; - - FIELD_& operator=(const FIELD_ &m); - - virtual void rmDriver(int index=0); - - /*! \if MEDMEM_ug - \addtogroup FIELD_io - @{ - \endif - */ - - /*! Creates a driver for reading/writing fields in a file. - \param driverType specifies the file type (MED_DRIVER, VTK_DRIVER) - \param fileName name of the output file - \param driverFieldName name of the field - \param access specifies whether the file is opened for read, write or both. - */ - - virtual int addDriver(driverTypes driverType, - const string & fileName="Default File Name.med", - const string & driverFieldName="Default Field Nam", - MED_EN::med_mode_acces access=MED_EN::RDWR) ; - - virtual int addDriver( GENDRIVER & driver); - virtual void read (driverTypes driverType, const std::string & fileName); - virtual void read (const GENDRIVER &); - virtual void read(int index=0); - virtual void openAppend( void ); - virtual void write(const GENDRIVER &, MED_EN::med_mode_acces medMode=MED_EN::RDWR); - virtual void write(driverTypes driverType, - const std::string & fileName, - MED_EN::med_mode_acces medMode=MED_EN::RDWR); - - /*! Triggers the writing of the field with respect to the driver handle - \a index given by \a addDriver(...) method. */ - virtual void write(int index=0); - /*!\if MEDMEM_ug @} \endif */ - - virtual void writeAppend(const GENDRIVER &); - virtual void writeAppend(int index=0, const string & driverName=""); - - inline void setName(const string Name); - inline string getName() const; - inline void setDescription(const string Description); - inline string getDescription() const; - inline const SUPPORT * getSupport() const; - inline void setSupport(const SUPPORT * support); - inline void setNumberOfComponents(const int NumberOfComponents); - inline int getNumberOfComponents() const; - inline void setNumberOfValues(const int NumberOfValues); - inline int getNumberOfValues() const; - inline void setComponentsNames(const string * ComponentsNames); - inline void setComponentName(int i, const string ComponentName); - inline const string * getComponentsNames() const; - inline string getComponentName(int i) const; - inline void setComponentsDescriptions(const string * ComponentsDescriptions); - inline void setComponentDescription(int i, const string ComponentDescription); - inline const string * getComponentsDescriptions() const; - inline string getComponentDescription(int i) const; - - // provisoire : en attendant de regler le probleme des unites ! - inline void setComponentsUnits(const UNIT * ComponentsUnits); - inline const UNIT * getComponentsUnits() const; - inline const UNIT * getComponentUnit(int i) const; - inline void setMEDComponentsUnits(const string * MEDComponentsUnits); - inline void setMEDComponentUnit(int i, const string MEDComponentUnit); - inline const string * getMEDComponentsUnits() const; - inline string getMEDComponentUnit(int i) const; - - inline void setIterationNumber(int IterationNumber); - inline int getIterationNumber() const; - inline void setTime(double Time); - inline double getTime() const; - inline void setOrderNumber(int OrderNumber); - inline int getOrderNumber() const; - - inline MED_EN::med_type_champ getValueType () const; - inline MED_EN::medModeSwitch getInterlacingType() const; - virtual inline bool getGaussPresence() const throw (MEDEXCEPTION); -protected: - void copyGlobalInfo(const FIELD_& m); -}; - -// ----------------- -// Methodes Inline -// ----------------- -/*! \if MEDMEM_ug -\addtogroup FIELD_getset -@{ -\endif -*/ -/*! - Sets FIELD name. The length should not exceed MED_TAILLE_NOM -as defined in Med (i.e. 32 characters). -*/ -inline void FIELD_::setName(const string Name) -{ - _name=Name; -} -/*! - Gets FIELD name. -*/ -inline string FIELD_::getName() const -{ - return _name; -} -/*! - Sets FIELD description. The length should not exceed MED_TAILLE_DESC as defined in Med (i.e. 200 characters). -*/ -inline void FIELD_::setDescription(const string Description) -{ - _description=Description; -} -/*! - Gets FIELD description. -*/ -inline string FIELD_::getDescription() const -{ - return _description; -} -/*! - Sets FIELD number of components. -*/ -inline void FIELD_::setNumberOfComponents(const int NumberOfComponents) -{ - _numberOfComponents=NumberOfComponents; - _componentsTypes.resize(_numberOfComponents); - _componentsNames.resize(_numberOfComponents); - _componentsDescriptions.resize(_numberOfComponents); - _componentsUnits.resize(_numberOfComponents); - _MEDComponentsUnits.resize(_numberOfComponents); -} -/*! - Gets FIELD number of components. -*/ -inline int FIELD_::getNumberOfComponents() const -{ - return _numberOfComponents ; -} -/*! - Sets FIELD number of values. - - It must be the same than in the associated SUPPORT object. -*/ -inline void FIELD_::setNumberOfValues(const int NumberOfValues) -{ - _numberOfValues=NumberOfValues; -} -/*! - Gets FIELD number of value. -*/ -inline int FIELD_::getNumberOfValues() const -{ - return _numberOfValues ; -} - -/*! - Sets FIELD components names. - - Duplicates the ComponentsNames string array to put components names in - FIELD. ComponentsNames size must be equal to number of components. -*/ -inline void FIELD_::setComponentsNames(const string * ComponentsNames) -{ - _componentsNames.resize(_numberOfComponents); - for (int i=0; i<_numberOfComponents; i++) - _componentsNames[i]=ComponentsNames[i] ; -} -/*! \ifnot MEDMEM_ug - Sets FIELD i^th component name. - - i must be >=1 and <= number of components. -\endif -*/ -inline void FIELD_::setComponentName(int i, const string ComponentName) -{ - const char * LOC = " FIELD_::setComponentName() : "; - BEGIN_OF_MED(LOC); - if( i<1 || i>_numberOfComponents ) - throw MEDEXCEPTION(STRING(LOC)<<" invalid index" ); - - _componentsNames[i-1]=ComponentName ; -} -/*! - Gets a reference to the string array which contain the components names. - - This Array size is equal to number of components -*/ -inline const string * FIELD_::getComponentsNames() const -{ - return &(_componentsNames[0]) ; -} -/*!\ifnot MEDMEM_ug - Gets the name of the i^th component. -\endif -*/ -inline string FIELD_::getComponentName(int i) const -{ - const char * LOC = " FIELD_::getComponentName() : "; - BEGIN_OF_MED(LOC); - if( i<1 || i>_numberOfComponents ) - throw MEDEXCEPTION(STRING(LOC)<<" invalid index" ); - - return _componentsNames[i-1] ; -} -/*! - Sets FIELD components descriptions. - - Duplicates the ComponentsDescriptions string array to put components - descriptions in FIELD. - ComponentsDescriptions size must be equal to number of components. -*/ -inline void FIELD_::setComponentsDescriptions(const string * ComponentsDescriptions) -{ - _componentsDescriptions.resize(_numberOfComponents); - for (int i=0; i<_numberOfComponents; i++) - _componentsDescriptions[i]=ComponentsDescriptions[i] ; -} -/*!\ifnot MEDMEM_ug - Sets FIELD i^th component description. - - i must be >=1 and <= number of components. -\endif -*/ -inline void FIELD_::setComponentDescription(int i,const string ComponentDescription) -{ - const char * LOC = " FIELD_::setComponentDescription() : "; - BEGIN_OF_MED(LOC); - if( i<1 || i>_numberOfComponents ) - throw MEDEXCEPTION(STRING(LOC)<<" invalid index" ); - - _componentsDescriptions[i-1]=ComponentDescription ; -} -/*! - Gets a reference to the string array which contain the components descriptions. - - This Array size is equal to number of components -*/ -inline const string * FIELD_::getComponentsDescriptions() const -{ - return &(_componentsDescriptions[0]); -} -/*!\ifnot MEDMEM_ug - Gets the description of the i^th component. -\endif -*/ -inline string FIELD_::getComponentDescription(int i) const -{ - const char * LOC = " FIELD_::setComponentDescription() : "; - BEGIN_OF_MED(LOC); - if( i<1 || i>_numberOfComponents ) - throw MEDEXCEPTION(STRING(LOC)<<" invalid index" ); - - return _componentsDescriptions[i-1]; -} - -/*!\ifnot MEDMEM_ug - \todo - Sets FIELD components UNIT. - - Duplicates the ComponentsUnits UNIT array to put components - units in FIELD. - ComponentsUnits size must be equal to number of components. -\endif -*/ -inline void FIELD_::setComponentsUnits(const UNIT * ComponentsUnits) -{ - _componentsUnits.resize(_numberOfComponents); - for (int i=0; i<_numberOfComponents; i++) - _componentsUnits[i]=ComponentsUnits[i] ; -} -/*!\ifnot MEDMEM_ug - Gets a reference to the UNIT array which contain the components units. - - This array size is equal to number of components -\endif -*/ -inline const UNIT * FIELD_::getComponentsUnits() const -{ - return &(_componentsUnits[0]); -} -/*!\ifnot MEDMEM_ug - Gets the UNIT of the i^th component. -\endif -*/ -inline const UNIT * FIELD_::getComponentUnit(int i) const -{ - const char * LOC = " FIELD_::getComponentUnit() : "; - BEGIN_OF_MED(LOC); - if( i<1 || i>_numberOfComponents ) - throw MEDEXCEPTION(STRING(LOC)<<" invalid index" ); - - return &_componentsUnits[i-1] ; -} -/*! - Sets FIELD components unit. - - Duplicates the MEDComponentsUnits string array to put components - units in FIELD. - MEDComponentsUnits size must be equal to number of components. - -*/ -inline void FIELD_::setMEDComponentsUnits(const string * MEDComponentsUnits) -{ - _MEDComponentsUnits.resize(_numberOfComponents); - for (int i=0; i<_numberOfComponents; i++) - _MEDComponentsUnits[i]=MEDComponentsUnits[i] ; -} -/*!\ifnot MEDMEM_ug - Sets FIELD i^th component unit. - - i must be >=1 and <= number of components. -\endif -*/ -inline void FIELD_::setMEDComponentUnit(int i, const string MEDComponentUnit) -{ - const char * LOC = " FIELD_::setMEDComponentUnit() : "; - BEGIN_OF_MED(LOC); - if( i<1 || i>_numberOfComponents ) - throw MEDEXCEPTION(STRING(LOC)<<" invalid index" ); - - _MEDComponentsUnits[i-1]=MEDComponentUnit ; -} -/*! - Gets a reference to the string array which contain the components units. - - This array size is equal to number of components -*/ -inline const string * FIELD_::getMEDComponentsUnits() const -{ - return &(_MEDComponentsUnits[0]); -} -/*! \ifnot MEDMEM_ug - Gets the string for unit of the i^th component. -\endif -*/ -inline string FIELD_::getMEDComponentUnit(int i) const -{ - const char * LOC = " FIELD_::getMEDComponentUnit() : "; - BEGIN_OF_MED(LOC); - if( i<1 || i>_numberOfComponents ) - throw MEDEXCEPTION(STRING(LOC)<<" invalid index" ); - - return _MEDComponentsUnits[i-1] ; -} -/*! - Sets the iteration number where FIELD has been calculated. -*/ -inline void FIELD_::setIterationNumber(int IterationNumber) -{ - _iterationNumber=IterationNumber; -} -/*! - Gets the iteration number where FIELD has been calculated. -*/ -inline int FIELD_::getIterationNumber() const -{ - return _iterationNumber ; -} -/*! - Sets the time when FIELD has been calculated. -*/ -inline void FIELD_::setTime(double Time) -{ - _time=Time ; -} -/*! - Gets the time when FIELD has been calculated. -*/ -inline double FIELD_::getTime() const -{ - return _time ; -} -/*! - Sets the order number where FIELD has been calculated. - - It corresponds to internal iteration during one time step. -*/ -inline void FIELD_::setOrderNumber(int OrderNumber) -{ - _orderNumber=OrderNumber ; -} -/*! - Gets the order number where FIELD has been calculated. -*/ -inline int FIELD_::getOrderNumber() const -{ - return _orderNumber ; -} -/*! - Gets a reference to the SUPPORT object associated to FIELD. -*/ -inline const SUPPORT * FIELD_::getSupport() const -{ - return _support ; -} -/*! - Sets the reference to the SUPPORT object associated to FIELD. - - Reference is not duplicate, so it must not be deleted. -*/ -inline void FIELD_::setSupport(const SUPPORT * support) -{ - //A.G. Addings for RC - if(_support!=support) - { - if(_support) - _support->removeReference(); - _support = support ; - if(_support) - _support->addReference(); - } -} -/*! - Gets the FIELD med value type (MED_INT32 or MED_REEL64). -*/ -inline MED_EN::med_type_champ FIELD_::getValueType () const -{ - return _valueType ; -} - -/*! - Gets the FIELD med interlacing type (MED_FULL_INTERLACE or MED_NO_INTERLACE). -*/ - inline MED_EN::medModeSwitch FIELD_::getInterlacingType () const -{ - return _interlacingType ; -} - /*!\if MEDMEM_ug @} \endif*/ - -/*!\if MEDMEM_ug -\addtogroup FIELD_gauss -@{ -\endif */ - -/*! - Determines whether the field stores several Gauss points per element. -*/ - inline bool FIELD_::getGaussPresence() const throw (MEDEXCEPTION) -{ - const char * LOC = "FIELD_::getGaussPresence() : "; - throw MEDEXCEPTION(STRING(LOC) << " This FIELD_ doesn't rely on a FIELD" ); -} - - /*!\if MEDMEM_ug @} \endif*/ - -} //End namespace MEDMEM - -///////////////////////// -// END OF CLASS FIELD_ // -///////////////////////// - -/*! - - This template class contains informations related with a FIELD : - - Values of the field, their type (real or integer), the storage mode (full interlace, - no interlace or no interlace by type). - -*/ - - -namespace MEDMEM { - - template class MED_FIELD_RDONLY_DRIVER; - template class MED_FIELD_WRONLY_DRIVER; - template class VTK_FIELD_DRIVER; - - - template class FIELD : public FIELD_ -{ -protected: - - typedef typename MEDMEM_ArrayInterface::Array ArrayNoGauss; - typedef typename MEDMEM_ArrayInterface::Array ArrayGauss; - typedef typename MEDMEM_ArrayInterface::Array ArrayNo; - typedef typename MEDMEM_ArrayInterface::Array ArrayFull; - typedef typename MEDMEM_ArrayInterface::Array ArrayNoByType; - typedef typename MEDMEM_ArrayInterface::Array ArrayNoByTypeGauss; - typedef MEDMEM_Array_ Array; - typedef T ElementType; - typedef INTERLACING_TAG InterlacingTag; - typedef map locMap; - - // array of value of type T - Array *_value ; - - // MESH, to be used for field reading from a file (if desired to link - // to existing support instead of new support creation for the field) - GMESH* _mesh; - - // extrema values - T _vmin; - T _vmax; - - map _gaussModel; //A changer quand les drivers seront template de l'entrelacement - - static T _scalarForPow; - static T pow(T x); - -private: - void _operation(const FIELD& m,const FIELD& n, const char* Op); - void _operationInitialize(const FIELD& m,const FIELD& n, const char* Op); - void _add_in_place(const FIELD& m,const FIELD& n); - void _sub_in_place(const FIELD& m,const FIELD& n); - void _mul_in_place(const FIELD& m,const FIELD& n); - void _div_in_place(const FIELD& m,const FIELD& n) throw (MEDEXCEPTION); -public: - FIELD(); - FIELD(const FIELD &m); - FIELD(const SUPPORT * Support, const int NumberOfComponents) throw (MEDEXCEPTION); - FIELD(driverTypes driverType, - const string & fileName, const string & fieldDriverName, - const int iterationNumber=-1, const int orderNumber=-1, - GMESH* mesh = 0) - throw (MEDEXCEPTION); - FIELD(const SUPPORT * Support, driverTypes driverType, - const string & fileName="", const string & fieldName="", - const int iterationNumber = -1, const int orderNumber = -1) - throw (MEDEXCEPTION); - ~FIELD(); - -public: - FIELD & operator=(const FIELD &m); - FIELD & operator=(T value); - FIELD *operator+(const FIELD& m) const; - FIELD *operator-(const FIELD& m) const; - FIELD *operator*(const FIELD& m) const; - FIELD *operator/(const FIELD& m) const; - FIELD *operator-() const; - FIELD& operator+=(const FIELD& m); - FIELD& operator-=(const FIELD& m); - FIELD& operator*=(const FIELD& m); - FIELD& operator/=(const FIELD& m); - - void applyLin(T a, T b, int icomp); - static FIELD* add(const FIELD& m, const FIELD& n); - static FIELD* addDeep(const FIELD& m, const FIELD& n); - static FIELD* sub(const FIELD& m, const FIELD& n); - static FIELD* subDeep(const FIELD& m, const FIELD& n); - static FIELD* mul(const FIELD& m, const FIELD& n); - static FIELD* mulDeep(const FIELD& m, const FIELD& n); - static FIELD* div(const FIELD& m, const FIELD& n); - static FIELD* divDeep(const FIELD& m, const FIELD& n); - double normMax() const throw (MEDEXCEPTION); - - //------- TDG and BS addings - - void getMinMax(T &vmin, T &vmax) throw (MEDEXCEPTION); - vector getHistogram(int &nbint) throw (MEDEXCEPTION); - FIELD* buildGradient() const throw (MEDEXCEPTION); - FIELD* buildNorm2Field() const throw (MEDEXCEPTION); - - //------------------- - - double norm2() const throw (MEDEXCEPTION); - void applyLin(T a, T b); - template void applyFunc(); - void applyPow(T scalar); - static FIELD* scalarProduct(const FIELD& m, const FIELD& n, bool deepCheck=false); - double normL2(int component, const FIELD * p_field_volume=NULL) const; - double normL2(const FIELD * p_field_volume=NULL) const; - double normL1(int component, const FIELD * p_field_volume=NULL) const; - double normL1(const FIELD * p_field_volume=NULL) const; - double integral(const SUPPORT *subSupport=NULL) const throw (MEDEXCEPTION); - FIELD* extract(const SUPPORT *subSupport) const throw (MEDEXCEPTION); - - friend class MED_FIELD_RDONLY_DRIVER; - friend class MED_FIELD_WRONLY_DRIVER; - friend class VTK_FIELD_DRIVER; - - void init (); - void rmDriver(int index=0); - int addDriver(driverTypes driverType, - const string & fileName="Default File Name.med", - const string & driverFieldName="Default Field Name", - MED_EN::med_mode_acces access=MED_EN::RDWR) ; - - int addDriver(GENDRIVER & driver); - - void allocValue(const int NumberOfComponents); - void allocValue(const int NumberOfComponents, const int LengthValue); - - void deallocValue(); - - inline void read(int index=0); - inline void read(const GENDRIVER & genDriver); - inline void read(driverTypes driverType, const std::string& filename); - inline void write(int index=0); - inline void write(const GENDRIVER &, MED_EN::med_mode_acces medMode=MED_EN::RDWR); - inline void write(driverTypes driverType, - const std::string& filename, - MED_EN::med_mode_acces medMode=MED_EN::RDWR); - - inline void writeAppend(int index=0, const string & driverName = ""); - inline void writeAppend(const GENDRIVER &); - - inline MEDMEM_Array_ * getArray() const throw (MEDEXCEPTION); - inline ArrayGauss * getArrayGauss() const throw (MEDEXCEPTION); - inline ArrayNoGauss * getArrayNoGauss() const throw (MEDEXCEPTION); - inline bool getGaussPresence() const throw (MEDEXCEPTION); - - inline int getValueLength() const throw (MEDEXCEPTION); - - /*! \if MEDMEM_ug -\addtogroup FIELD_value -@{ -\endif */ - /*! Returns a pointer to the value array.*/ - inline const T* getValue() const throw (MEDEXCEPTION); - inline const T* getRow(int i) const throw (MEDEXCEPTION); - inline const T* getColumn(int j) const throw (MEDEXCEPTION); -/*! - Returns the value of \f$ i^{th} \f$ element and \f$ j^{th}\f$ component. - This method only works with fields having no particular Gauss point -definition (i.e., fields having one value per element). - This method makes the retrieval of the value independent from the - interlacing pattern, but it is slower than the complete retrieval - obtained by the \b getValue() method. -*/ - - inline T getValueIJ(int i,int j) const throw (MEDEXCEPTION); - -/*! - Returns the \f$ j^{th}\f$ component of \f$ k^{th}\f$ Gauss points of \f$ i^{th}\f$ value. - This method is compatible with elements having more than one Gauss point. - This method makes the retrieval of the value independent from the - interlacing pattern, but it is slower than the complete retrieval - obtained by the \b getValue() method. -*/ - inline T getValueIJK(int i,int j,int k) const throw (MEDEXCEPTION); - - inline int getValueByTypeLength(int t) const throw (MEDEXCEPTION); - inline const T* getValueByType(int t) const throw (MEDEXCEPTION); - inline T getValueIJByType(int i,int j,int t) const throw (MEDEXCEPTION); - inline T getValueIJKByType(int i,int j,int k,int t) const throw (MEDEXCEPTION); - - /*! - The following example describes the creation of a FIELD. - - \example FIELDcreate.cxx - - \if MEDMEM_ug @} \endif */ - - bool getValueOnElement(int eltIdInSup,T* retValues) const throw (MEDEXCEPTION); - void getValueOnPoint(const double* coords, double* output) const throw (MEDEXCEPTION); - void getValueOnPoints(int nb_points, const double* coords, double* output) const throw (MEDEXCEPTION); - - const int getNumberOfGeometricTypes() const throw (MEDEXCEPTION); - const GAUSS_LOCALIZATION & getGaussLocalization(MED_EN::medGeometryElement geomElement) const throw (MEDEXCEPTION); - const GAUSS_LOCALIZATION * getGaussLocalizationPtr(MED_EN::medGeometryElement geomElement) const throw (MEDEXCEPTION); - const GAUSS_LOCALIZATION_* getGaussLocalizationRoot(MED_EN::medGeometryElement geomElement) const throw (MEDEXCEPTION); - void setGaussLocalization(MED_EN::medGeometryElement geomElement, const GAUSS_LOCALIZATION & gaussloc); - void setGaussLocalization(MED_EN::medGeometryElement geomElement, GAUSS_LOCALIZATION_* gaussloc); - const int * getNumberOfGaussPoints() const throw (MEDEXCEPTION); - const int getNumberOfGaussPoints( MED_EN::medGeometryElement geomElement) const throw (MEDEXCEPTION); - const int getNbGaussI(int i) const throw (MEDEXCEPTION); - const int * getNumberOfElements() const throw (MEDEXCEPTION); - const MED_EN::medGeometryElement * getGeometricTypes() const throw (MEDEXCEPTION); - bool isOnAllElements() const throw (MEDEXCEPTION); - - inline void setArray(MEDMEM_Array_ *value) throw (MEDEXCEPTION); - - FIELD* getGaussPointsCoordinates() const throw (MEDEXCEPTION); - - /*! \if MEDMEM_ug - \addtogroup FIELD_value -@{ -\endif - */ -/*! -This method makes it possible to have the field pointing to -an existing value array. The ordering of the elements in the value array must -conform to the MEDMEM ordering (I,K,J) : the outer loop is on the elements, -the intermediate loop is on the Gauss points, the inner loop is on -the components. -*/ - inline void setValue( T* value) throw (MEDEXCEPTION); - inline void setRow( int i, T* value) throw (MEDEXCEPTION); - inline void setColumn( int i, T* value) throw (MEDEXCEPTION); -/*! - Sets the value of \f$ i^{th} \f$ element and \f$ j^{th}\f$ component with \a value. -*/ - inline void setValueIJ(int i, int j, T value) throw (MEDEXCEPTION); - /*! \if MEDMEM_ug @} \endif */ - inline void setValueIJK(int i, int j, int k, T value) throw (MEDEXCEPTION); - inline void setValueIJByType(int i, int j, int t, T value) throw (MEDEXCEPTION); - inline void setValueIJKByType(int i, int j, int k, int t, T value) throw (MEDEXCEPTION); - - typedef void (*myFuncType)(const double *,T*); - void fillFromAnalytic(myFuncType f) throw (MEDEXCEPTION); - typedef void (*myFuncType2)(const T *,T*); - FIELD *execFunc(int nbOfComponents, myFuncType2 f) throw (MEDEXCEPTION); -}; -} - -#include "MEDMEM_DriverFactory.hxx" - -namespace MEDMEM { - -template T FIELD::_scalarForPow=1; - -// -------------------- -// Implemented Methods -// -------------------- - -/*! - Constructor with no parameter, most of the attribut members are set to NULL. -*/ -template -FIELD::FIELD():FIELD_() -{ - MESSAGE_MED("Constructeur FIELD sans parametre"); - - //INITIALISATION DE _valueType DS LE CONSTRUCTEUR DE FIELD_ - ASSERT_MED(FIELD_::_valueType == MED_EN::MED_UNDEFINED_TYPE); - FIELD_::_valueType=SET_VALUE_TYPE::_valueType; - - //INITIALISATION DE _interlacingType DS LE CONSTRUCTEUR DE FIELD_ - ASSERT_MED(FIELD_::_interlacingType == MED_EN::MED_UNDEFINED_INTERLACE); - FIELD_::_interlacingType=SET_INTERLACING_TYPE::_interlacingType; - - _value = ( ArrayNoGauss * ) NULL; - - _mesh = ( MESH* ) NULL; -} - - /*! -\addtogroup FIELD_constructors FIELD constructors -@{ - */ - -/*! - Constructor that allocates the value array with the dimensions provided by -\a NumberOfComponents and the dimension of \a Support. The value array is - allocated but not initialized. -This constructor does not allow the creation of fields with Gauss points. -\param Support support on which the field lies -\param NumberOfComponents number of components of the variable stored. For instance, -it will be 3 for a (vx,vy,vz) vector. - -\code -FIELD field (support, 3); -int nbelem = support->getNumberOfElements(MED_ALL_ELEMENTS); -for (int i=1; i<=nbelem; i++) - for (j=1; j<=3;j++) - field->setValueIJ(i,j,0.0); -\endcode -*/ -template -FIELD::FIELD(const SUPPORT * Support, - const int NumberOfComponents) throw (MEDEXCEPTION) : - FIELD_(Support, NumberOfComponents),_value(NULL) -{ - const char* LOC = "FIELD::FIELD(const SUPPORT * Support, const int NumberOfComponents)"; - BEGIN_OF_MED(LOC); - SCRUTE_MED(this); - - //INITIALISATION DE _valueType DS LE CONSTRUCTEUR DE FIELD_ - ASSERT_MED(FIELD_::_valueType == MED_EN::MED_UNDEFINED_TYPE) - FIELD_::_valueType=SET_VALUE_TYPE::_valueType; - - //INITIALISATION DE _interlacingType DS LE CONSTRUCTEUR DE FIELD_ - ASSERT_MED(FIELD_::_interlacingType == MED_EN::MED_UNDEFINED_INTERLACE) - FIELD_::_interlacingType=SET_INTERLACING_TYPE::_interlacingType; - - try - { - // becarefull about the numbre of gauss point - _numberOfValues = Support->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS); - } -#if defined(_DEBUG_) || defined(_DEBUG) - catch (MEDEXCEPTION &ex) -#else - catch (MEDEXCEPTION ) -#endif - { - MESSAGE_MED("No value defined ! ("< 0 ) - { - if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE_BY_TYPE ) - { - const int * nbelgeo = Support->getNumberOfElements(); - vector nbelgeoc( Support->getNumberOfTypes() + 1 ); - nbelgeoc[0] = 0; - for ( int t = 1; t < (int)nbelgeoc.size(); ++t ) - nbelgeoc[t] = nbelgeoc[t-1] + nbelgeo[t-1]; - _value = new ArrayNoByType (_numberOfComponents,_numberOfValues, - Support->getNumberOfTypes(), &nbelgeoc[0]); - } - else - { - _value = new ArrayNoGauss (_numberOfComponents,_numberOfValues); - } - _isRead = true ; - } - _mesh = ( MESH* ) NULL; - - END_OF_MED(LOC); -} - /*! -@} - */ -/*! - \if developper - \endif -*/ -template void FIELD::init () -{ -} - -/*! - Copy constructor. -*/ -template FIELD::FIELD(const FIELD & m): - FIELD_(m) -{ - MESSAGE_MED("Constructeur FIELD de recopie"); - - // RECOPIE PROFONDE <> de l'operateur= Rmq from EF - if (m._value != NULL) - { - if ( m.getGaussPresence() ) - _value = new ArrayGauss( *(static_cast< ArrayGauss * > (m._value) ) ,false); - else - _value = new ArrayNoGauss( *(static_cast< ArrayNoGauss * > (m._value)) ,false); - } - else - _value = (ArrayNoGauss *) NULL; - locMap::const_iterator it; - for ( it = m._gaussModel.begin();it != m._gaussModel.end(); it++ ) - _gaussModel[static_cast * > ((*it).second)->getType()]= - new GAUSS_LOCALIZATION( - *static_cast * > ( (*it).second ) - ); - - _valueType = m._valueType; - _interlacingType = m._interlacingType; - //drivers = m._drivers; - _mesh = m._mesh; - if(_mesh) - _mesh->addReference(); -} - -/*! - \if developper - Not implemented. - \endif -*/ -template -FIELD & FIELD::operator=(const FIELD &m) -{ - MESSAGE_MED("Appel de FIELD::operator=") ; - if ( this == &m) return *this; - - // copy values array - FIELD_::operator=(m); // Driver are ignored & ?copie su pointeur de Support? - - _value = m._value; //PROBLEME RECOPIE DES POINTEURS PAS COHERENT AVEC LE - //CONSTRUCTEUR PAR RECOPIE - //CF :Commentaire dans MEDMEM_Array - locMap::const_iterator it; - for ( it = m._gaussModel.begin();it != m._gaussModel.end(); it++ ) - _gaussModel[static_cast * > ((*it).second)->getType()]= - new GAUSS_LOCALIZATION( - *static_cast * > ( (*it).second ) - ); - - _valueType = m._valueType; - _interlacingType = m._interlacingType; - if(_mesh!=m._mesh) - { - if(_mesh) - _mesh->removeReference(); - _mesh = m._mesh; - if(_mesh) - _mesh->addReference(); - } - return *this; -} - -/*! - Initializes all the field values to \a value -*/ -template -FIELD & FIELD::operator=(T value) -{ - MESSAGE_MED("Appel de FIELD::operator= T") ; - int size=getNumberOfComponents()*getNumberOfValues(); - T* ptr= const_cast( getValue()); - for (int i=0; i< size; i++) - {*ptr++=value;} - - return *this; -} - -/*!\addtogroup FIELD_algo -@{ -*/ - -/*! - Overload addition operator. - This operation is authorized only for compatible fields that have the same support. - The compatibility checking includes equality tests of the folowing data members:\n - - _support - - _numberOfComponents - - _numberOfValues - - _componentsTypes - - _MEDComponentsUnits. - - The data members of the returned field are initialized, based on the first field, except for the name, - which is the combination of the two field's names and the operator. - Advised Utilisation in C++ : FIELD c = a + b; \n - In this case, the (recent) compilators perform optimisation and don't call the copy constructor. - When using python, this operator calls the copy constructor in any case. - The user has to be aware that when using operator + in associatives expressions like - a = b + c + d +e; \n - no optimisation is performed : the evaluation of last expression requires the construction of - 3 temporary fields. -*/ -template -FIELD *FIELD::operator+(const FIELD & m) const -{ - const char* LOC = "FIELD::operator+(const FIELD & m)"; - BEGIN_OF_MED(LOC); - FIELD_::_checkFieldCompatibility(*this, m); // may throw exception - - // Creation of the result - memory is allocated by FIELD constructor - FIELD *result=new FIELD(this->getSupport(),this->getNumberOfComponents()); - result->_operationInitialize(*this,m,"+"); // perform Atribute's initialization - result->_add_in_place(*this,m); // perform addition - - END_OF_MED(LOC); - return result; -} - -/*! Overloaded Operator += - * Operations are directly performed in the first field's array. - * This operation is authorized only for compatible fields that have the same support. - */ -template -FIELD& FIELD::operator+=(const FIELD & m) -{ - const char* LOC = "FIELD::operator+=(const FIELD & m)"; - BEGIN_OF_MED(LOC); - FIELD_::_checkFieldCompatibility(*this, m); // may throw exception - - const T* value1=m.getValue(); // get pointers to the values we are adding - - // get a non const pointer to the inside array of values and perform operation - T * value=const_cast (getValue()); - const int size=getNumberOfValues()*getNumberOfComponents(); // size of array - const T* endV=value+size; // pointer to the end of value - for(;value!=endV; value1++,value++) - *value += *value1; - END_OF_MED(LOC); - return *this; -} - - -/*! Addition of fields. Static member function. - * The function return a pointer to a new created field that holds the addition. - * Data members are checked for compatibility and initialized. - * The user is in charge of memory deallocation. - */ -template -FIELD* FIELD::add(const FIELD& m, const FIELD& n) -{ - const char* LOC = "FIELD::add(const FIELD & m, const FIELD& n)"; - BEGIN_OF_MED(LOC); - FIELD_::_checkFieldCompatibility(m, n); // may throw exception - - // Creation of a new field - FIELD* result = new FIELD(m.getSupport(), - m.getNumberOfComponents()); - result->_operationInitialize(m,n,"+"); // perform Atribute's initialization - result->_add_in_place(m,n); // perform addition - - END_OF_MED(LOC); - return result; -} - -/*! Same as add method except that field check is deeper. - */ -template -FIELD* FIELD::addDeep(const FIELD& m, const FIELD& n) -{ - const char* LOC = "FIELD::addDeep(const FIELD & m, const FIELD& n)"; - BEGIN_OF_MED(LOC); - FIELD_::_deepCheckFieldCompatibility(m, n); // may throw exception - - // Creation of a new field - FIELD* result = new FIELD(m.getSupport(), - m.getNumberOfComponents()); - result->_operationInitialize(m,n,"+"); // perform Atribute's initialization - result->_add_in_place(m,n); // perform addition - - END_OF_MED(LOC); - return result; -} - -/*! - Overload substraction operator. - This operation is authorized only for compatible fields that have the same support. - The compatibility checking includes equality tests of the folowing data members:\n - - _support - - _numberOfComponents - - _numberOfValues - - _componentsTypes - - _MEDComponentsUnits. - - The data members of the returned field are initialized, based on the first field, except for the name, - which is the combination of the two field's names and the operator. - Advised Utilisation in C++ : FIELD c = a - b; \n - In this case, the (recent) compilators perform optimisation and don't call the copy constructor. - When using python, this operator calls the copy constructor in any case. - The user has to be aware that when using operator - in associatives expressions like - a = b - c - d -e; \n - no optimisation is performed : the evaluation of last expression requires the construction of - 3 temporary fields. -*/ -template -FIELD *FIELD::operator-(const FIELD & m) const -{ - const char* LOC = "FIELD::operator-(const FIELD & m)"; - BEGIN_OF_MED(LOC); - FIELD_::_checkFieldCompatibility(*this, m); // may throw exception - - // Creation of the result - memory is allocated by FIELD constructor - FIELD *result=new FIELD(this->getSupport(),this->getNumberOfComponents()); - result->_operationInitialize(*this,m,"-"); // perform Atribute's initialization - result->_sub_in_place(*this,m); // perform substracion - - END_OF_MED(LOC); - return result; -} - -template -FIELD *FIELD::operator-() const -{ - const char* LOC = "FIELD::operator-()"; - BEGIN_OF_MED(LOC); - - // Creation of the result - memory is allocated by FIELD constructor - FIELD *result=new FIELD(this->getSupport(),this->getNumberOfComponents()); - // Atribute's initialization - result->setName("- "+getName()); - result->setComponentsNames(getComponentsNames()); - // not yet implemented setComponentType(getComponentType()); - result->setComponentsDescriptions(getComponentsDescriptions()); - result->setMEDComponentsUnits(getMEDComponentsUnits()); - result->setComponentsUnits(getComponentsUnits()); - result->setIterationNumber(getIterationNumber()); - result->setTime(getTime()); - result->setOrderNumber(getOrderNumber()); - - const T* value1=getValue(); - // get a non const pointer to the inside array of values and perform operation - T * value=const_cast (result->getValue()); - const int size=getNumberOfValues()*getNumberOfComponents(); // size of array - const T* endV=value+size; // pointer to the end of value - - for(;value!=endV; value1++,value++) - *value = -(*value1); - END_OF_MED(LOC); - return result; -} - -/*! Overloaded Operator -= - * Operations are directly performed in the first field's array. - * This operation is authorized only for compatible fields that have the same support. - */ -template -FIELD& FIELD::operator-=(const FIELD & m) -{ - const char* LOC = "FIELD::operator-=(const FIELD & m)"; - BEGIN_OF_MED(LOC); - FIELD_::_checkFieldCompatibility(*this, m); // may throw exception - - const T* value1=m.getValue(); - - // get a non const pointer to the inside array of values and perform operation - T * value=const_cast (getValue()); - const int size=getNumberOfValues()*getNumberOfComponents(); // size of array - const T* endV=value+size; // pointer to the end of value - - for(;value!=endV; value1++,value++) - *value -= *value1; - - END_OF_MED(LOC); - return *this; -} - - - -/*! Apply to a given field component the linear function x -> ax+b. - * calculation is done "in place". - */ -template void FIELD::applyLin(T a, T b, int icomp) -{ - // get a non const pointer to the inside array of values and perform operation in place - T * value=const_cast (getValue()); - - const int size=getNumberOfValues()*getNumberOfComponents(); // size of array - - if (size>0) // for a negative size, there is nothing to do - { - value+=icomp-1; - const T* lastvalue=value+size; // pointer to the end of value - - for(;value!=lastvalue; value+=getNumberOfComponents()) // apply linear transformation - *value = a*(*value)+b; - } -} - -/*! Substraction of fields. Static member function. - * The function return a pointer to a new created field that holds the substraction. - * Data members are checked for compatibility and initialized. - * The user is in charge of memory deallocation. - */ -template -FIELD* FIELD::sub(const FIELD& m, const FIELD& n) -{ - const char* LOC = "FIELD::sub(const FIELD & m, const FIELD& n)"; - BEGIN_OF_MED(LOC); - FIELD_::_checkFieldCompatibility(m, n); // may throw exception - - // Creation of a new field - FIELD* result = new FIELD(m.getSupport(), - m.getNumberOfComponents()); - result->_operationInitialize(m,n,"-"); // perform Atribute's initialization - result->_sub_in_place(m,n); // perform substraction - - END_OF_MED(LOC); - return result; -} - -/*! Same as sub method except that field check is deeper. - */ -template -FIELD* FIELD::subDeep(const FIELD& m, const FIELD& n) -{ - const char* LOC = "FIELD::subDeep(const FIELD & m, const FIELD& n)"; - BEGIN_OF_MED(LOC); - FIELD_::_deepCheckFieldCompatibility(m, n); // may throw exception - - // Creation of a new field - FIELD* result = new FIELD(m.getSupport(), - m.getNumberOfComponents()); - result->_operationInitialize(m,n,"-"); // perform Atribute's initialization - result->_sub_in_place(m,n); // perform substraction - - END_OF_MED(LOC); - return result; -} - -/*! - Overload multiplication operator. - This operation is authorized only for compatible fields that have the same support. - The compatibility checking includes equality tests of the folowing data members:\n - - _support - - _numberOfComponents - - _numberOfValues - - _componentsTypes - - _MEDComponentsUnits. - - The data members of the returned field are initialized, based on the first field, except for the name, - which is the combination of the two field's names and the operator. - Advised Utilisation in C++ : FIELD c = a * b; \n - In this case, the (recent) compilators perform optimisation and don't call the copy constructor. - When using python, this operator calls the copy constructor in any case. - The user has to be aware that when using operator * in associatives expressions like - a = b * c * d *e; \n - no optimisation is performed : the evaluation of last expression requires the construction of - 3 temporary fields. -*/ -template -FIELD *FIELD::operator*(const FIELD & m) const -{ - const char* LOC = "FIELD::operator*(const FIELD & m)"; - BEGIN_OF_MED(LOC); - FIELD_::_checkFieldCompatibility(*this, m, false); // may throw exception - - // Creation of the result - memory is allocated by FIELD constructor - FIELD *result=new FIELD(this->getSupport(),this->getNumberOfComponents()); - result->_operationInitialize(*this,m,"*"); // perform Atribute's initialization - result->_mul_in_place(*this,m); // perform multiplication - - END_OF_MED(LOC); - return result; -} - -/*! Overloaded Operator *= - * Operations are directly performed in the first field's array. - * This operation is authorized only for compatible fields that have the same support. - */ -template -FIELD& FIELD::operator*=(const FIELD & m) -{ - const char* LOC = "FIELD::operator*=(const FIELD & m)"; - BEGIN_OF_MED(LOC); - FIELD_::_checkFieldCompatibility(*this, m, false); // may throw exception - - const T* value1=m.getValue(); - - // get a non const pointer to the inside array of values and perform operation - T * value=const_cast (getValue()); - const int size=getNumberOfValues()*getNumberOfComponents(); // size of array - const T* endV=value+size; // pointer to the end of value - - for(;value!=endV; value1++,value++) - *value *= *value1; - - END_OF_MED(LOC); - return *this; -} - - -/*! Multiplication of fields. Static member function. - * The function return a pointer to a new created field that holds the multiplication. - * Data members are checked for compatibility and initialized. - * The user is in charge of memory deallocation. - */ -template -FIELD* FIELD::mul(const FIELD& m, const FIELD& n) -{ - const char* LOC = "FIELD::mul(const FIELD & m, const FIELD& n)"; - BEGIN_OF_MED(LOC); - FIELD_::_checkFieldCompatibility(m, n, false); // may throw exception - - // Creation of a new field - FIELD* result = new FIELD(m.getSupport(), - m.getNumberOfComponents()); - result->_operationInitialize(m,n,"*"); // perform Atribute's initialization - result->_mul_in_place(m,n); // perform multiplication - - END_OF_MED(LOC); - return result; -} - -/*! Same as mul method except that field check is deeper. - */ -template -FIELD* FIELD::mulDeep(const FIELD& m, const FIELD& n) -{ - const char* LOC = "FIELD::mulDeep(const FIELD & m, const FIELD& n)"; - BEGIN_OF_MED(LOC); - FIELD_::_deepCheckFieldCompatibility(m, n, false); // may throw exception - - // Creation of a new field - FIELD* result = new FIELD(m.getSupport(), - m.getNumberOfComponents()); - result->_operationInitialize(m,n,"*"); // perform Atribute's initialization - result->_mul_in_place(m,n); // perform multiplication - - END_OF_MED(LOC); - return result; -} - -/*! - Overload division operator. - This operation is authorized only for compatible fields that have the same support. - The compatibility checking includes equality tests of the folowing data members:\n - - _support - - _numberOfComponents - - _numberOfValues - - _componentsTypes - - _MEDComponentsUnits. - - The data members of the returned field are initialized, based on the first field, except for the name, - which is the combination of the two field's names and the operator. - Advised Utilisation in C++ : FIELD c = a / b; \n - In this case, the (recent) compilators perform optimisation and don't call the copy constructor. - When using python, this operator calls the copy constructor in any case. - The user has to be aware that when using operator / in associatives expressions like - a = b / c / d /e; \n - no optimisation is performed : the evaluation of last expression requires the construction of - 3 temporary fields. -*/ -template -FIELD *FIELD::operator/(const FIELD & m) const -{ - const char* LOC = "FIELD::operator/(const FIELD & m)"; - BEGIN_OF_MED(LOC); - FIELD_::_checkFieldCompatibility(*this, m, false); // may throw exception - - // Creation of the result - memory is allocated by FIELD constructor - FIELD *result=new FIELD(this->getSupport(),this->getNumberOfComponents()); - try - { - result->_operationInitialize(*this,m,"/"); // perform Atribute's initialization - result->_div_in_place(*this,m); // perform division - } - catch(MEDEXCEPTION& e) - { - result->removeReference(); - throw e; - } - - END_OF_MED(LOC); - return result; -} - - -/*! Overloaded Operator /= - * Operations are directly performed in the first field's array. - * This operation is authorized only for compatible fields that have the same support. - */ -template -FIELD& FIELD::operator/=(const FIELD & m) -{ - const char* LOC = "FIELD::operator/=(const FIELD & m)"; - BEGIN_OF_MED(LOC); - FIELD_::_checkFieldCompatibility(*this, m, false); // may throw exception - - const T* value1=m.getValue(); // get pointers to the values we are adding - - // get a non const pointer to the inside array of values and perform operation - T * value=const_cast (getValue()); - const int size=getNumberOfValues()*getNumberOfComponents(); // size of array - const T* endV=value+size; // pointer to the end of value - - for(;value!=endV; value1++,value++) - *value /= *value1; - - END_OF_MED(LOC); - return *this; -} - - -/*! Division of fields. Static member function. - * The function return a pointer to a new created field that holds the division. - * Data members are checked for compatibility and initialized. - * The user is in charge of memory deallocation. - */ -template -FIELD* FIELD::div(const FIELD& m, const FIELD& n) -{ - const char* LOC = "FIELD::div(const FIELD & m, const FIELD& n)"; - BEGIN_OF_MED(LOC); - FIELD_::_checkFieldCompatibility(m, n, false); // may throw exception - - // Creation of a new field - FIELD* result = new FIELD(m.getSupport(), - m.getNumberOfComponents()); - try - { - result->_operationInitialize(m,n,"/"); // perform Atribute's initialization - result->_div_in_place(m,n); // perform division - } - catch(MEDEXCEPTION& e) - { - result->removeReference(); - throw e; - } - END_OF_MED(LOC); - return result; -} - -/*! Same as div method except that field check is deeper. - */ -template -FIELD* FIELD::divDeep(const FIELD& m, const FIELD& n) -{ - const char* LOC = "FIELD::divDeep(const FIELD & m, const FIELD& n)"; - BEGIN_OF_MED(LOC); - FIELD_::_deepCheckFieldCompatibility(m, n, false); // may throw exception - - // Creation of a new field - FIELD* result = new FIELD(m.getSupport(), - m.getNumberOfComponents()); - try - { - result->_operationInitialize(m,n,"/"); // perform Atribute's initialization - result->_div_in_place(m,n); // perform division - } - catch(MEDEXCEPTION& e) - { - result->removeReference(); - throw e; - } - END_OF_MED(LOC); - return result; -} - - -/*! -@} -*/ - -/*! - \if developper - This internal method initialize the members of a new field created to hold the result of the operation Op . - Initialization is based on the first field, except for the name, which is the combination of the two field's names - and the operator. - \endif -*/ -template -void FIELD::_operationInitialize(const FIELD& m,const FIELD& n, const char* Op) -{ - MESSAGE_MED("Appel methode interne " << Op); - - // Atribute's initialization (copy of the first field's attributes) - // Other data members (_support, _numberOfValues) are initialized in the field's constr. - setName(m.getName()+" "+Op+" "+n.getName()); - setComponentsNames(m.getComponentsNames()); - setComponentsDescriptions(m.getComponentsDescriptions()); - setMEDComponentsUnits(m.getMEDComponentsUnits()); - - // The following data member may differ from field m to n. - // The initialization is done based on the first field. - - setComponentsUnits(m.getComponentsUnits()); - - setIterationNumber(m.getIterationNumber()); - setTime(m.getTime()); - setOrderNumber(m.getOrderNumber()); -} - - -/*! - \if developper - Internal method called by FIELD::operator+ and FIELD::add to perform addition "in place". - This method is applied to a just created field with medModeSwitch mode. - For this reason, the alternate mode doesn't need to be set to 0 after performing operation : - it doesn't exist! - \endif -*/ -template -void FIELD::_add_in_place(const FIELD& m,const FIELD& n) -{ - // get pointers to the values we are adding - const T* value1=m.getValue(); - const T* value2=n.getValue(); - // get a non const pointer to the inside array of values and perform operation - T * value=const_cast (getValue()); - - const int size=getNumberOfValues()*getNumberOfComponents(); - SCRUTE_MED(size); - const T* endV1=value1+size; - for(;value1!=endV1; value1++,value2++,value++) - *value=(*value1)+(*value2); -} - -/*! - \if developper - Internal method called by FIELD::operator- and FIELD::sub to perform substraction "in place". - This method is applied to a just created field with medModeSwitch mode. - For this reason, the alternate mode doesn't need to be set to 0 after performing operation : - it doesn't exist! - \endif -*/ -template -void FIELD::_sub_in_place(const FIELD& m,const FIELD& n) -{ - // get pointers to the values we are adding - const T* value1=m.getValue(); - const T* value2=n.getValue(); - // get a non const pointer to the inside array of values and perform operation - T * value=const_cast (getValue()); - - const int size=getNumberOfValues()*getNumberOfComponents(); - SCRUTE_MED(size); - const T* endV1=value1+size; - for(;value1!=endV1; value1++,value2++,value++) - *value=(*value1)-(*value2); -} - -/*! - \if developper - Internal method called by FIELD::operator* and FIELD::mul to perform multiplication "in place". - This method is applied to a just created field with medModeSwitch mode. - For this reason, the alternate mode doesn't need to be set to 0 after performing operation : - it doesn't exist! - \endif -*/ -template -void FIELD::_mul_in_place(const FIELD& m,const FIELD& n) -{ - // get pointers to the values we are adding - const T* value1=m.getValue(); - const T* value2=n.getValue(); - // get a non const pointer to the inside array of values and perform operation - T * value=const_cast (getValue()); - - const int size=getNumberOfValues()*getNumberOfComponents(); - SCRUTE_MED(size); - const T* endV1=value1+size; - for(;value1!=endV1; value1++,value2++,value++) - *value=(*value1)*(*value2); -} - -/*! - \if developper - Internal method called by FIELD::operator/ and FIELD::div to perform division "in place". - This method is applied to a just created field with medModeSwitch mode. - For this reason, the alternate mode doesn't need to be set to 0 after performing operation : - it doesn't exist! - \endif -*/ -template -void FIELD::_div_in_place(const FIELD& m,const FIELD& n) throw (MEDEXCEPTION) -{ - // get pointers to the values we are adding - const T* value1=m.getValue(); - const T* value2=n.getValue(); - // get a non const pointer to the inside array of values and perform operation - T * value=const_cast (getValue()); - - const int size=getNumberOfValues()*getNumberOfComponents(); - SCRUTE_MED(size); - const T* endV1=value1+size; - for(;value1!=endV1; value1++,value2++,value++){ - if ( *value2 == 0 ) { // FAIRE PLUTOT UN TRY CATCH Rmq from EF - string diagnosis; - diagnosis="FIELD::_div_in_place(...) : Divide by zero !"; - throw MEDEXCEPTION(diagnosis.c_str()); - } - *value=(*value1)/(*value2); - } -} - -/*! -\addtogroup FIELD_algo -@{ -*/ - -/*! Return maximum of all absolute values contained in the array (all elements and all components are browsed). - */ -template double FIELD::normMax() const throw (MEDEXCEPTION) -{ - const T* value=getValue(); // get pointer to the values - const int size=getNumberOfValues()*getNumberOfComponents(); - if (size <= 0) // Size of array has to be strictly positive - { - string diagnosis; - diagnosis="FIELD::normMax() : cannot compute the norm of "+getName()+ - " : it size is non positive!"; - throw MEDEXCEPTION(diagnosis.c_str()); - } - const T* lastvalue=value+size; // get pointer just after last value - const T* pMax=value; // pointer to the max value - const T* pMin=value; // pointer to the min value - - // get pointers to the max & min value of array - while ( ++value != lastvalue ) - { - if ( *pMin > *value ) - pMin=value; - if ( *pMax < *value ) - pMax=value; - } - - T Max= *pMax>(T) 0 ? *pMax : -*pMax; // Max=abs(*pMax) - T Min= *pMin>(T) 0 ? *pMin : -*pMin; // Min=abs(*pMin) - - return Max>Min ? double(Max) : double(Min); -} - -/*! Return Euclidian norm for all elements of the array. - */ -template double FIELD::norm2() const throw (MEDEXCEPTION) -{ - const T* value=this->getValue(); // get const pointer to the values - const int size=getNumberOfValues()*getNumberOfComponents(); // get size of array - if (size <= 0) // Size of array has to be strictly positive - { - string diagnosis; - diagnosis="FIELD::norm2() : cannot compute the norm of "+getName()+ - " : it size is non positive!"; - throw MEDEXCEPTION(diagnosis.c_str()); - } - const T* lastvalue=value+size; // point just after last value - - T result((T)0); // init - for( ; value!=lastvalue ; ++value) - result += (*value) * (*value); - - return std::sqrt(double(result)); -} - - -//------------- TDG and BS addings - -/*! Return Extrema of field - */ - template void FIELD::getMinMax(T &vmin, T &vmax) throw (MEDEXCEPTION) -{ - const T* value=getValue(); // get pointer to the values - const int size=getNumberOfValues()*getNumberOfComponents(); - const T* lastvalue=value+size; // point just after last value - - if (size <= 0){ // Size of array has to be strictly positive - - string diagnosis; - diagnosis="FIELD::getMinMax() : cannot compute the extremums of "+getName()+ - " : its size is non positive!"; - throw MEDEXCEPTION(diagnosis.c_str()); - } - - if (!_isMinMax){ - vmax=MinMax::getMin(); // init a max value - vmin=MinMax::getMax(); // init a min value - - for( ; value!=lastvalue ; ++value){ - if ( vmin > *value ) - vmin=*value; - if ( vmax < *value ) - vmax=*value; - } - _isMinMax=true; - _vmin=vmin; - _vmax=vmax; - } - else{ - vmin = _vmin; - vmax = _vmax; - } - -} - -/*! Return Histogram of field - */ - template vector FIELD::getHistogram(int &nbint) throw (MEDEXCEPTION) -{ - const T* value=getValue(); // get pointer to the values - const int size=getNumberOfValues()*getNumberOfComponents(); - const T* lastvalue=value+size; // point just after last value - - if (size <= 0){ // Size of array has to be strictly positive - - string diagnosis; - diagnosis="FIELD::getHistogram() : cannot compute the histogram of "+getName()+ - " : it size is non positive!"; - throw MEDEXCEPTION(diagnosis.c_str()); - } - - vector Histogram(nbint) ; - T vmin,vmax; - int j; - - for( j=0 ; j!=nbint ; j++) Histogram[j]=0 ; - - getMinMax(vmin,vmax); - for( ; value!=lastvalue ; ++value){ - if(*value==vmax) j = nbint-1; - else j = (int)(((double)nbint * (*value-vmin))/(vmax-vmin)); - Histogram[j]+=1 ; - } - - return Histogram ; - -} - -/*! Return vectorial gradient field - */ -template -FIELD* FIELD::buildGradient() const throw (MEDEXCEPTION) -{ - const char * LOC = "FIELD::buildGradient() : "; - BEGIN_OF_MED(LOC); - - // space dimension of input mesh - int spaceDim = getSupport()->getMesh()->getSpaceDimension(); - double *x = new double[spaceDim]; - - FIELD* Gradient = - new FIELD(getSupport(),spaceDim); - - string name("gradient of "); - name += getName(); - Gradient->setName(name); - string descr("gradient of "); - descr += getDescription(); - Gradient->setDescription(descr); - - if( _numberOfComponents > 1 ){ - delete Gradient; - delete [] x; - throw MEDEXCEPTION("gradient calculation only on scalar field"); - } - - for(int i=1;i<=spaceDim;i++){ - string nameC("gradient of "); - nameC += getName(); - Gradient->setComponentName(i,nameC); - Gradient->setComponentDescription(i,"gradient"); - string MEDComponentUnit = getMEDComponentUnit(1)+getSupport()->getMesh()->getCoordinatesUnits()[i-1]; - Gradient->setMEDComponentUnit(i,MEDComponentUnit); - } - - Gradient->setIterationNumber(getIterationNumber()); - Gradient->setOrderNumber(getOrderNumber()); - Gradient->setTime(getTime()); - - // typ of entity on what is field - MED_EN::medEntityMesh typ = getSupport()->getEntity(); - - const int *C; - const int *iC; - const int *revC; - const int *indC; - const double *coord; - int NumberOf; - - switch (typ) { - case MED_CELL: - case MED_FACE: - case MED_EDGE: - { - // read connectivity array to have the list of nodes contained by an element - C = getSupport()->getMesh()->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,typ,MED_ALL_ELEMENTS); - iC = getSupport()->getMesh()->getConnectivityIndex(MED_NODAL,typ); - // calculate reverse connectivity to have the list of elements which contains node i - revC = getSupport()->getMesh()->getReverseConnectivity(MED_NODAL,typ); - indC = getSupport()->getMesh()->getReverseConnectivityIndex(MED_NODAL,typ); - // coordinates of each node - coord = getSupport()->getMesh()->getCoordinates(MED_FULL_INTERLACE); - // number of elements - NumberOf = getSupport()->getNumberOfElements(MED_ALL_ELEMENTS); - // barycenter field of elements - FIELD* barycenter = getSupport()->getMesh()->getBarycenter(getSupport()); - - // calculate gradient vector for each element i - for (int i = 1; i < NumberOf + 1; i++) { - - // listElements contains elements which contains a node of element i - set listElements; - set ::iterator elemIt; - listElements.clear(); - - // for each node j of element i - for (int ij = iC[i-1]; ij < iC[i]; ij++) { - int j = C[ij-1]; - for (int k = indC[j-1]; k < indC[j]; k++) { - // c element contains node j - int c = revC[k-1]; - // we put the elements in set - if (c != i) - listElements.insert(c); - } - } - // coordinates of barycentre of element i in space of dimension spaceDim - for (int j = 0; j < spaceDim; j++) - x[j] = barycenter->getValueIJ(i,j+1); - - for (int j = 0; j < spaceDim; j++) { - // value of field of element i - double val = getValueIJ(i,1); - double grad = 0.; - // calculate gradient for each neighbor element - for (elemIt = listElements.begin(); elemIt != listElements.end(); elemIt++) { - int elem = *elemIt; - double d2 = 0.; - for (int l = 0; l < spaceDim; l++) { - // coordinate of barycenter of element elem - double xx = barycenter->getValueIJ(elem, l+1); - d2 += (x[l]-xx) * (x[l]-xx); - } - grad += (barycenter->getValueIJ(elem,j+1)-x[j])*(getValueIJ(elem,1)-val)/sqrt(d2); - } - if (listElements.size() != 0) grad /= listElements.size(); - Gradient->setValueIJ(i,j+1,grad); - } - } - delete barycenter; - } - break; - case MED_NODE: - // read connectivity array to have the list of nodes contained by an element - C = getSupport()->getMesh()->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,MED_ALL_ELEMENTS); - iC = getSupport()->getMesh()->getConnectivityIndex(MED_NODAL,MED_CELL); - // calculate reverse connectivity to have the list of elements which contains node i - revC=getSupport()->getMesh()->getReverseConnectivity(MED_NODAL,MED_CELL); - indC=getSupport()->getMesh()->getReverseConnectivityIndex(MED_NODAL,MED_CELL); - // coordinates of each node - coord = getSupport()->getMesh()->getCoordinates(MED_FULL_INTERLACE); - - // calculate gradient for each node - NumberOf = getSupport()->getNumberOfElements(MED_ALL_ELEMENTS); - for (int i=1; i listNodes; - set ::iterator nodeIt ; - listNodes.clear(); - for(int j=indC[i-1];jsetValueIJ(i,j+1,grad); - } - } - break; - case MED_ALL_ENTITIES: - delete [] x; - delete Gradient; - throw MEDEXCEPTION("gradient calculation not yet implemented on all elements"); - break; - } - - delete [] x; - - END_OF_MED(LOC); - return Gradient; -} - -/*! Return scalar norm2 field - */ -template -FIELD* FIELD::buildNorm2Field() const throw (MEDEXCEPTION) -{ - const char * LOC = "FIELD::buildNorm2Field() : "; - BEGIN_OF_MED(LOC); - - FIELD* Norm2Field = - new FIELD(getSupport(),1); - - string name("norm2 of "); - name += getName(); - Norm2Field->setName(name); - string descr("norm2 of "); - descr += getDescription(); - Norm2Field->setDescription(descr); - - string nameC("norm2 of "); - nameC += getName(); - Norm2Field->setComponentName(1,nameC); - Norm2Field->setComponentDescription(1,"norm2"); - string MEDComponentUnit = getMEDComponentUnit(1); - Norm2Field->setMEDComponentUnit(1,MEDComponentUnit); - - Norm2Field->setIterationNumber(getIterationNumber()); - Norm2Field->setOrderNumber(getOrderNumber()); - Norm2Field->setTime(getTime()); - - // calculate nom2 for each element - int NumberOf = getSupport()->getNumberOfElements(MED_ALL_ELEMENTS); - for (int i=1; isetValueIJ(i,1,sqrt(norm2)); - } - - END_OF_MED(LOC); - return Norm2Field; - -} - -/*! Apply to each (scalar) field component the template parameter T_function, - * which is a pointer to function. - * Since the pointer is known at compile time, the function is inlined into the inner loop! - * calculation is done "in place". - * Use examples : - * - * \code myField.applyFunc(); // apply sqare root function \endcode - * \code myField.applyFunc(); // apply your own created function \endcode - */ -template template -void FIELD::applyFunc() -{ - // get a non const pointer to the inside array of values and perform operation - T * value=const_cast (getValue()); - const int size=getNumberOfValues()*getNumberOfComponents(); // size of array - - if (size>0) // for a negative size, there is nothing to do - { - const T* lastvalue=value+size; // pointer to the end of value - for(;value!=lastvalue; ++value) // apply linear transformation - *value = T_function(*value); - } -} - -template T FIELD::pow(T x) -{ - return (T)::pow((double)x,FIELD::_scalarForPow); -} - -/*! Apply to each (scalar) field component the math function pow. - * calculation is done "in place". - * Use examples : - * - * \code myField.applyFunc(); // apply sqare root function \endcode - * \code myField.applyFunc(); // apply your own created function \endcode - */ -template void FIELD::applyPow(T scalar) -{ - FIELD::_scalarForPow=scalar; - applyFunc::pow>(); -} - -/*! Apply to each (scalar) field component the linear function x -> ax+b. - * calculation is done "in place". - */ -template void FIELD::applyLin(T a, T b) -{ - // get a non const pointer to the inside array of values and perform operation in place - T * value=const_cast (getValue()); - const int size=getNumberOfValues()*getNumberOfComponents(); // size of array - - if (size>0) // for a negative size, there is nothing to do - { - const T* lastvalue=value+size; // pointer to the end of value - for(;value!=lastvalue; ++value) // apply linear transformation - *value = a*(*value)+b; - } -} - - -/*! - * Return a pointer to a new field that holds the scalar product. Static member function. - * This operation is authorized only for compatible fields that have the same support. - * The compatibility checking includes equality tests of the folowing data members:\n - * - _support - * - _numberOfComponents - * - _numberOfValues - * - _componentsTypes - * - _MEDComponentsUnits. - * Data members are initialized. - * The new field point to the same support and has one component. - * Each value of it is the scalar product of the two argument's fields. - * The user is in charge of memory deallocation. - */ -template -FIELD* -FIELD::scalarProduct(const FIELD & m, const FIELD & n, bool deepCheck) -{ - if(!deepCheck) - FIELD_::_checkFieldCompatibility( m, n, false); // may throw exception - else - FIELD_::_deepCheckFieldCompatibility(m, n, false); - - // we need a MED_FULL_INTERLACE representation of m & n to compute the scalar product - // result type imply INTERLACING_TAG=FullInterlace for m & n - - const int numberOfElements=m.getNumberOfValues(); // strictly positive - const int NumberOfComponents=m.getNumberOfComponents(); // strictly positive - - // Creation & init of a the result field on the same support, with one component - // You have to be careful about the interlacing mode, because in the computation step, - // it seems to assume the the interlacing mode is the FullInterlacing - - FIELD* result = new FIELD(m.getSupport(),1); - result->setName( "scalarProduct ( " + m.getName() + " , " + n.getName() + " )" ); - result->setIterationNumber(m.getIterationNumber()); - result->setTime(m.getTime()); - result->setOrderNumber(m.getOrderNumber()); - - const T* value1=m.getValue(); // get const pointer to the values - const T* value2=n.getValue(); // get const pointer to the values - // get a non const pointer to the inside array of values and perform operation - T * value=const_cast (result->getValue()); - - const T* lastvalue=value+numberOfElements; // pointing just after last value of result - for ( ; value!=lastvalue ; ++value ) // loop on all elements - { - *value=(T)0; // initialize value - const T* endofRow=value1+NumberOfComponents; // pointing just after end of row - for ( ; value1 != endofRow; ++value1, ++value2) // computation of dot product - *value += (*value1) * (*value2); - } - return result; -} - -/*! Return L2 Norm of the field's component. - * Cannot be applied to a field with a support on nodes. - * If the optional p_field_volume argument is furnished, the volume is not re-calculated. - * For the nodal field, p_field_volume must be for all cells even if the field is partial. - */ -template -double FIELD::normL2(int component, - const FIELD * p_field_volume) const -{ - _checkNormCompatibility(p_field_volume, /*nodalAllowed=*/true); // may throw exception - if ( component<1 || component>getNumberOfComponents() ) - throw MEDEXCEPTION(STRING("FIELD::normL2() : The component argument should be between 1 and the number of components")); - - const FIELD * p_field_size=p_field_volume; - if(!p_field_volume) // if the user don't supply the volume - p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'implémentation dans mesh] - else - p_field_size->addReference(); - // get pointer to the element's volumes. MED_FULL_INTERLACE is the default mode for p_field_size - const double* vol=p_field_size->getValue(); - // Il n'est vraiment pas optimal de mixer des champs dans des modes d'entrelacement - // different juste pour le calcul - - - double integrale=0.0; - double totVol=0.0; - - if ( getSupport()->getEntity() == MED_NODE ) // issue 20120: [CEA 206] normL2 on NODE field - { - //Most frequently the FIELD is on the whole mesh and - // there is no need in optimizing iterations from supporting nodes-> back to cells, - // so we iterate just on all cells - const MESH * mesh = getSupport()->getMesh()->convertInMESH(); - const int nbCells = mesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS); - const int *C = mesh->getConnectivity(MED_NODAL,MED_CELL,MED_ALL_ELEMENTS); - const int *iC = mesh->getConnectivityIndex(MED_NODAL,MED_CELL); - for (int i = 0; i < nbCells; ++i, ++vol) { - // calculate integral on current element as average summ of values on all it's nodes - double curCellValue = 0; - try { // we expect exception with partial fields for nodes w/o values - for (int ij = iC[i]; ij < iC[i+1]; ij++) { - int node = C[ij-1]; - curCellValue += getValueIJ( node, component ); - } - } - catch ( MEDEXCEPTION ) { - continue; - } - int nbNodes = iC[i+1]-iC[i]; - curCellValue /= nbNodes; - integrale += (curCellValue * curCellValue) * std::abs(*vol); - totVol+=std::abs(*vol); - } - mesh->removeReference(); - } - else - { - if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE ) { - const T* value = getValue(); - value = value + (component-1) * getNumberOfValues(); - const T* lastvalue = value + getNumberOfValues(); // pointing just after the end of column - for (; value!=lastvalue ; ++value ,++vol) { - integrale += double((*value) * (*value)) * std::abs(*vol); - totVol+=std::abs(*vol); - } - } - else if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE_BY_TYPE ) { - ArrayNoByType* anArray = dynamic_cast< ArrayNoByType * > ( getArrayNoGauss() ); - for (int i=1; i <= anArray->getNbElem() ; i++, ++vol ) { - integrale += anArray->getIJ(i,component) * anArray->getIJ(i,component) * std::abs(*vol); - totVol+=std::abs(*vol); - } - } - else { // FULL_INTERLACE - ArrayFull* anArray = dynamic_cast< ArrayFull * > ( getArrayNoGauss() ); - for (int i=1; i <= anArray->getNbElem() ; i++, ++vol ) { - integrale += anArray->getIJ(i,component) * anArray->getIJ(i,component) * std::abs(*vol); - totVol+=std::abs(*vol); - } - } - } - - if(p_field_size) - p_field_size->removeReference(); // delete temporary volume field - - if( totVol <= 0) - throw MEDEXCEPTION(STRING("cannot compute sobolev norm : volume is not positive!")); - return integrale/totVol; -} - -/*! Return L2 Norm of the field. - * If the optional p_field_volume argument is furnished, the volume is not re-calculated. - * For the nodal field, p_field_volume must be for all cells even if the field is partial. - */ -template -double FIELD::normL2(const FIELD * p_field_volume) const -{ - _checkNormCompatibility(p_field_volume, /*nodalAllowed=*/true); // may throw exception - const FIELD * p_field_size=p_field_volume; - if(!p_field_volume) // if the user don't supply the volume - p_field_size=_getFieldSize(); // we calculate the volume - else - p_field_size->addReference(); - // get pointer to the element's volumes. MED_FULL_INTERLACE is the default mode for p_field_size - const double* vol=p_field_size->getValue(); - const double* lastvol=vol+getNumberOfValues(); // pointing just after the end of vol - - - double integrale=0.0; - double totVol=0.0; - - if ( getSupport()->getEntity() == MED_NODE ) // issue 20120: [CEA 206] normL2 on NODE field - { - //Most frequently the FIELD is on the whole mesh and - // there is no need in optimizing iterations from supporting nodes-> back to cells, - // so we iterate just on all cells - const MESH * mesh = getSupport()->getMesh()->convertInMESH(); - const int nbCells = mesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS); - const int *C = mesh->getConnectivity(MED_NODAL,MED_CELL,MED_ALL_ELEMENTS); - const int *iC = mesh->getConnectivityIndex(MED_NODAL,MED_CELL); - int nbComp = getNumberOfComponents(); - for (int i = 0; i < nbCells; ++i, ++vol) { - // calculate integral on current element as average summ of values on all it's nodes - int nbNodes = iC[i+1]-iC[i]; - vector< double > curCellValue( nbComp, 0 ); - try { // we expect exception with partial fields for nodes w/o values - for (int ij = iC[i]; ij < iC[i+1]; ij++) { - int node = C[ij-1]; - for ( int j = 0; j < nbComp; ++j ) - curCellValue[ j ] += getValueIJ( node, j+1 ) / nbNodes; - } - } - catch ( MEDEXCEPTION ) { - continue; - } - - for ( int j = 0; j < nbComp; ++j ) { - integrale += (curCellValue[j] * curCellValue[j]) * std::abs(*vol); - } - totVol+=std::abs(*vol); - } - mesh->removeReference(); - if ( nbCells > 0 && totVol == 0.) - throw MEDEXCEPTION("can't compute sobolev norm : " - "none of elements has values on all it's nodes"); - } - else - { - const double* p_vol=vol; - for (p_vol=vol; p_vol!=lastvol ; ++p_vol) // calculate total volume - totVol+=std::abs(*p_vol); - - if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE ) { - const T* value = getValue(); - for (int i=1; i<=getNumberOfComponents(); ++i) { // compute integral on all components - for (p_vol=vol; p_vol!=lastvol ; ++value ,++p_vol) { - integrale += (*value) * (*value) * std::abs(*p_vol); - } - } - } - else if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE_BY_TYPE ) { - ArrayNoByType* anArray = dynamic_cast< ArrayNoByType * > ( getArrayNoGauss() ); - for (int j=1; j<=anArray->getDim(); j++) { - int i = 1; - for (p_vol=vol; i<=anArray->getNbElem() || p_vol!=lastvol; i++, ++p_vol ) { - integrale += anArray->getIJ(i,j) * anArray->getIJ(i,j) * std::abs(*p_vol); - } - } - } - else { // FULL_INTERLACE - ArrayFull* anArray = dynamic_cast< ArrayFull * > ( getArrayNoGauss() ); - for (int j=1; j<=anArray->getDim(); j++) { - int i = 1; - for (p_vol=vol; i<=anArray->getNbElem() || p_vol!=lastvol; i++, ++p_vol ) { - integrale += anArray->getIJ(i,j) * anArray->getIJ(i,j) * std::abs(*p_vol); - } - } - } - } - if(p_field_size) - p_field_size->removeReference(); // delete temporary volume field - - if( totVol <= 0) - throw MEDEXCEPTION(STRING("cannot compute sobolev norm : volume is not positive!")); - return integrale/totVol; -} - -/*! Return L1 Norm of the field's component. - * If the optional p_field_volume argument is furnished, the volume is not re-calculated. - */ -template -double FIELD::normL1(int component, - const FIELD * p_field_volume) const -{ - _checkNormCompatibility(p_field_volume); // may throw exception - if ( component<1 || component>getNumberOfComponents() ) - throw MEDEXCEPTION(STRING("FIELD::normL1() : The component argument should be between 1 and the number of components")); - - const FIELD * p_field_size=p_field_volume; - if(!p_field_volume) // if the user don't supply the volume - p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'implÃÃÅ mentation dans mesh] - else - p_field_size->addReference(); - // get pointer to the element's volumes. MED_FULL_INTERLACE is the default mode for p_field_size - const double* vol = p_field_size->getValue(); - - double integrale=0.0; - double totVol=0.0; - - if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE ) { - const T* value = getValue(); - const T* lastvalue = value + getNumberOfValues(); // pointing just after the end of column - for (; value!=lastvalue ; ++value ,++vol) { - integrale += std::abs( *value * *vol ); - totVol+=std::abs(*vol); - } - } - else if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE_BY_TYPE ) { - ArrayNoByType* anArray = dynamic_cast< ArrayNoByType * > ( getArrayNoGauss() ); - for (int i=1; i <= anArray->getNbElem() ; i++, ++vol ) { - integrale += std::abs( anArray->getIJ(i,component) * (*vol)); - totVol+=std::abs(*vol); - } - } - else { // FULL_INTERLACE - ArrayFull* anArray = dynamic_cast< ArrayFull * > ( getArrayNoGauss() ); - for (int i=1; i <= anArray->getNbElem() ; i++, ++vol ) { - integrale += std::abs( anArray->getIJ(i,component) * *vol); - totVol+=std::abs(*vol); - } - } - - if(p_field_size) - p_field_size->removeReference(); // delete temporary volume field - if( totVol <= 0) - throw MEDEXCEPTION(STRING("cannot compute sobolev norm : volume is not positive!")); - return integrale/totVol; -} - -/*! Return L1 Norm of the field. - * Cannot be applied to a field with a support on nodes. - * If the optional p_field_volume argument is furnished, the volume is not re-calculated. - */ -template -double FIELD::normL1(const FIELD * p_field_volume) const -{ - _checkNormCompatibility(p_field_volume); // may throw exception - const FIELD * p_field_size=p_field_volume; - if(!p_field_volume) // if the user don't supply the volume - p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'implémentation dans mesh] - else - p_field_size->addReference(); - // get pointer to the element's volumes. MED_FULL_INTERLACE is the default mode for p_field_size - const double* vol = p_field_size->getValue(); - const double* lastvol = vol+getNumberOfValues(); // pointing just after the end of vol - - double integrale=0.0; - double totVol=0.0; - const double* p_vol=vol; - for (p_vol=vol; p_vol!=lastvol ; ++p_vol) // calculate total volume - totVol+=std::abs(*p_vol); - - if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE ) { - const T* value = getValue(); - for (int i=1; i<=getNumberOfComponents(); ++i) { // compute integral on all components - for (p_vol=vol; p_vol!=lastvol ; ++value ,++p_vol) { - integrale += std::abs( *value * *p_vol ); - } - } - } - else if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE_BY_TYPE ) { - ArrayNoByType* anArray = dynamic_cast< ArrayNoByType * > ( getArrayNoGauss() ); - for (int j=1; j<=anArray->getDim(); j++) { - int i = 1; - for (p_vol=vol; i<=anArray->getNbElem() || p_vol!=lastvol; i++, ++p_vol ) { - integrale += std::abs( anArray->getIJ(i,j) * *p_vol ); - } - } - } - else { // FULL_INTERLACE - ArrayFull* anArray = dynamic_cast< ArrayFull * > ( getArrayNoGauss() ); - for (int j=1; j<=anArray->getDim(); j++) { - int i = 1; - for (p_vol=vol; i<=anArray->getNbElem() || p_vol!=lastvol; i++, ++p_vol ) { - integrale += std::abs( anArray->getIJ(i,j) * *p_vol ); - } - } - } - if(p_field_size) - p_field_size->removeReference(); - if( totVol <= 0) - throw MEDEXCEPTION(STRING("cannot compute sobolev norm : volume is not positive!")); - return integrale/totVol; -} - -/*! - * \brief Return integral of the field. - * \param subSupport - optional part of a field to consider. - * \retval double - value of integral - */ -template -double FIELD::integral(const SUPPORT *subSupport) const throw (MEDEXCEPTION) -{ - const char* LOC = "FIELD<>::integral(subSupport): "; - - double integrale = 0; - - if (!subSupport ) subSupport = _support; - - // check feasibility - if ( getGaussPresence() ) - throw MEDEXCEPTION(STRING(LOC)<<"Gauss numbers greater than one are not yet implemented!"); - if ( subSupport->getEntity() != _support->getEntity()) - throw MEDEXCEPTION(STRING(LOC)<<"Different support entity of this field and subSupport"); - if ( subSupport->getEntity() == MED_EN::MED_NODE ) - throw MEDEXCEPTION(STRING(LOC)<<"Integral of nodal field not yet supported"); - - // analyze support - const int nbElems = subSupport->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS); - const bool subOnAll = ( subSupport->isOnAllElements() ); - const bool myOnAll = ( _support->isOnAllElements() ); - const int* subNums = !subOnAll ? subSupport->getNumber(MED_EN::MED_ALL_ELEMENTS) : 0; - const int* myNums = !myOnAll ? _support->getNumber(MED_EN::MED_ALL_ELEMENTS) : 0; - if ( !subOnAll && !subNums ) - throw MEDEXCEPTION(STRING(LOC)<<"Invalid support: no element numbers"); - if ( !myOnAll && !myNums ) - throw MEDEXCEPTION(STRING(LOC)<<"Invalid field support: no element numbers"); - if ( subOnAll && !myOnAll ) - return integral(NULL); - - // get size of elements - const FIELD * cellSize=_getFieldSize(subSupport); - const double* size = cellSize->getValue(); - const double* lastSize = size + nbElems; // pointing just after the end of size - - const T* value = getValue(); - - // calculate integrale - if ( (subOnAll && _support->isOnAllElements()) || subSupport == _support ) - { - const double* p_vol; - if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE ) - { - for (int j=1; j<=getNumberOfComponents(); ++j) - for ( p_vol=size; p_vol != lastSize; ++value ,++p_vol) - integrale += std::abs( *value * *p_vol ); - } - else if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE_BY_TYPE ) - { - typename ArrayNoByType::InterlacingPolicy* indexer = - dynamic_cast< typename ArrayNoByType::InterlacingPolicy * > ( getArrayNoGauss() ); - for (int i, j=1; j<=getNumberOfComponents(); j++) - for (i = 1, p_vol=size; p_vol!=lastSize; i++, ++p_vol ) - integrale += std::abs( value[indexer->getIndex(i,j)] * *p_vol ); - } - else // FULL_INTERLACE - { - for ( p_vol=size; p_vol != lastSize; ++p_vol) - for (int j=0; j index; - if ( _support->isOnAllElements() ) - { - index.set( subNums ); - } - else // find common of two partial supports - { - // hope that numbers are in increasing order - index.set( nbElems ); - for (int ii = 0; ii < nbElems; ii++) - index[ii] = 0; - bool allNumsFound = true; - int i = 0, iSub = 0; - for ( ; iSub < nbElems; ++iSub ) - { - while ( i < getNumberOfValues() && subNums[iSub] > myNums[i] ) - ++i; - if (i == getNumberOfValues() /*subNums[iSub] > myNums[i]*/) // no more myNums - { - index[iSub] = 0; // no such number in myNums - break; - } - else if ( subNums[iSub] == myNums[i] ) // elem number found - index[iSub] = ++i; // -- index counts from 1 - else // subNums[iSub] < myNums[i] - allNumsFound = (index[iSub] = 0); // no such number in myNums - } - if ( iSub != nbElems || !allNumsFound ) - { - // check if numbers are in increasing order - bool increasingOrder = true; - for ( iSub = 1; iSub < nbElems && increasingOrder; ++iSub ) - increasingOrder = ( subNums[iSub-1] < subNums[iSub] ); - for ( i = 1; i < getNumberOfValues() && increasingOrder; ++i ) - increasingOrder = ( myNums[i-1] < myNums[i] ); - - if ( !increasingOrder ) - for ( iSub = 0; iSub < nbElems; ++iSub ) - try - { - index[iSub] = _support->getValIndFromGlobalNumber( subNums[iSub] ); - } - catch (MEDEXCEPTION) - { - index[iSub] = 0; - } - } - } - - // calculation - if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE ) - { - for (int j=0; j ( getArrayNoGauss() ); - for (int j=1; j<=getNumberOfComponents(); j++) - for ( int i = 0; i < nbElems; ++i ) - if ( index[i] ) - integrale += std::abs( value[indexer->getIndex(index[i],j)] * size[i] ); - } - else // FULL_INTERLACE - { - const int dim = getNumberOfComponents(); - for ( int i = 0; i < nbElems; ++i ) - if ( index[i] ) - for (int j=0; jremoveReference(); - return integrale; -} - -/*! Return a new field (to deallocate with delete) lying on subSupport that is included by - * this->_support with corresponding values extracting from this->_value. - */ -template -FIELD* FIELD::extract(const SUPPORT *subSupport) const throw (MEDEXCEPTION) -{ - if(!subSupport->belongsTo(*_support)) - throw MEDEXCEPTION("FIELD::extract : subSupport not included in this->_support !"); - if(_support->isOnAllElements() && subSupport->isOnAllElements()) - return new FIELD(*this); - - FIELD *ret = new FIELD(subSupport, - _numberOfComponents); - - if(!ret->_value) - throw MEDEXCEPTION("FIELD::extract : invalid support detected !"); - - T* valuesToSet=(T*)ret->getValue(); - - int nbOfEltsSub=subSupport->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS); - const int *eltsSub=subSupport->getNumber(MED_EN::MED_ALL_ELEMENTS); - T* tempVals=new T[_numberOfComponents]; - for(int i=0;icopyGlobalInfo(*this); - return ret; -} -/*! -@} -*/ - -/*! - \addtogroup FIELD_io - @{ -*/ -/*! - Constructor with parameters; the object is set via a file and its associated - driver. For the moment only the MED_DRIVER is considered and if the last two - argument (iterationNumber and orderNumber) are not set; their default value - is -1. If the field fieldDriverName with the iteration number - iterationNumber and the order number orderNumber does not exist in the file - fieldDriverName; the constructor raises an exception. -*/ -template -FIELD::FIELD(const SUPPORT * Support, - driverTypes driverType, - const string & fileName/*=""*/, - const string & fieldDriverName/*=""*/, - const int iterationNumber, - const int orderNumber) throw (MEDEXCEPTION) -{ - const char* LOC = "template FIELD::FIELD(const SUPPORT * Support, driverTypes driverType, const string & fileName=\"\", const string & fieldName=\"\", const int iterationNumber=-1, const int orderNumber=-1) : "; - BEGIN_OF_MED(LOC); - - int current; - - init(); - - _mesh = ( MESH* ) NULL; - - //INITIALISATION DE _valueType DS LE CONSTRUCTEUR DE FIELD_ - ASSERT_MED(FIELD_::_valueType == MED_EN::MED_UNDEFINED_TYPE) - FIELD_::_valueType=SET_VALUE_TYPE::_valueType; - - //INITIALISATION DE _interlacingType DS LE CONSTRUCTEUR DE FIELD_ - ASSERT_MED(FIELD_::_interlacingType == MED_EN::MED_UNDEFINED_INTERLACE) - FIELD_::_interlacingType=SET_INTERLACING_TYPE::_interlacingType; - - _support = Support; - //A.G. Addings for RC - if(_support) - _support->addReference(); - // OCC 10/03/2006 -- According to the rules defined with help of - // MEDMEM_IntrelacingTraits class, it is not allowed to instantiate - // MEDMEM_Array<> template using INTERLACING_TAG parameter of - // FIELD template - MSVC++ 2003 compiler generated an error here. - // _value = (MEDMEM_Array *) NULL; - _value = NULL; - - _iterationNumber = iterationNumber; - _time = 0.0; - _orderNumber = orderNumber; - - current = addDriver(driverType,fileName,fieldDriverName,MED_EN::RDONLY); - - _drivers[current]->open(); - _drivers[current]->read(); - _drivers[current]->close(); - - END_OF_MED(LOC); -} - -/*! - If the mesh argument is not initialized or passed NULL, - this constructor, at least, allows to create a FIELD without creating any - SUPPORT then without having to load a MESH object, a support is created. It - provides the meshName related mesh but doesn't not set a mesh in the created - support. - If the passed mesh contains corresponding support, this support will be used - for the field. This support will be found in mesh by name of one of profiles, - on which the FIELD lays in MED-file. This has sense for the case, then MED-file - was created by MEDMEM, and so name of profile contains name of corresponding support. -*/ -template -FIELD::FIELD(driverTypes driverType, - const string & fileName, - const string & fieldDriverName, - const int iterationNumber, - const int orderNumber, - GMESH* mesh) - throw (MEDEXCEPTION) :FIELD_() -{ - int current; - const char* LOC = "FIELD::FIELD( driverTypes driverType, const string & fileName, string & fieldDriverName, int iterationNumber, int orderNumber) : "; - BEGIN_OF_MED(LOC); - - init(); - - _mesh = mesh; - if(_mesh) - _mesh->addReference(); - - //INITIALISATION DE _valueType DS LE CONSTRUCTEUR DE FIELD_ - ASSERT_MED(FIELD_::_valueType == MED_EN::MED_UNDEFINED_TYPE) - FIELD_::_valueType = SET_VALUE_TYPE::_valueType; - - //INITIALISATION DE _interlacingType DS LE CONSTRUCTEUR DE FIELD_ - ASSERT_MED(FIELD_::_interlacingType == MED_EN::MED_UNDEFINED_INTERLACE) - FIELD_::_interlacingType = SET_INTERLACING_TYPE::_interlacingType; - - _support = (SUPPORT *) NULL; - // OCC 10/03/2006 -- According to the rules defined with help of - // MEDMEM_IntrelacingTraits class, it is not allowed to instantiate - // MEDMEM_Array<> template using INTERLACING_TAG parameter of - // FIELD template - MSVC++ 2003 compiler generated an error here. - // _value = (MEDMEM_Array *) NULL; - _value = NULL; - - _iterationNumber = iterationNumber; - _time = 0.0; - _orderNumber = orderNumber; - - current = addDriver(driverType,fileName,fieldDriverName,MED_EN::RDONLY); - - _drivers[current]->open(); - _drivers[current]->read(); - _drivers[current]->close(); - - END_OF_MED(LOC); -} -/*! -@} -*/ - -/*! - Destructor. -*/ -template FIELD::~FIELD() -{ - const char* LOC = " Destructeur FIELD::~FIELD()"; - BEGIN_OF_MED(LOC); - SCRUTE_MED(this); - if (_value) delete _value; _value=0; - locMap::const_iterator it; - for ( it = _gaussModel.begin();it != _gaussModel.end(); it++ ) - delete (*it).second; - _gaussModel.clear(); - if(_mesh) - _mesh->removeReference(); - _mesh=0; - END_OF_MED(LOC); -} - -/*! - -*/ -template -void FIELD::allocValue(const int NumberOfComponents) -{ - const char* LOC = "FIELD::allocValue(const int NumberOfComponents)"; - BEGIN_OF_MED(LOC); - - _numberOfComponents = NumberOfComponents ; - _componentsTypes.resize(NumberOfComponents); - _componentsNames.resize(NumberOfComponents); - _componentsDescriptions.resize(NumberOfComponents); - _componentsUnits.resize(NumberOfComponents); - _MEDComponentsUnits.resize(NumberOfComponents); - for (int i=0;igetNumberOfElements(MED_EN::MED_ALL_ELEMENTS); - MESSAGE_MED(PREFIX_MED <<" : "<<_numberOfValues <<" et "<< NumberOfComponents); - - //EF : A modifier lors de l'intégration de la classe de localisation des points de gauss - _value = new ArrayNoGauss(_numberOfComponents,_numberOfValues); - - _isRead = true ; - } - catch (MEDEXCEPTION &ex) { - MESSAGE_MED("No value defined, problem with NumberOfComponents (and may be _support) size of MEDARRAY::_value !"); - // OCC 10/03/2006 -- According to the rules defined with help of - // MEDMEM_IntrelacingTraits class, it is not allowed to instantiate - // MEDMEM_Array<> template using INTERLACING_TAG parameter of - // FIELD template - MSVC++ 2003 compiler generated an error here. - // _value = (MEDMEM_Array *) NULL; - _value = NULL; - } - - SCRUTE_MED(_value); - END_OF_MED(LOC); -} - -/*! - -*/ -template -void FIELD::allocValue(const int NumberOfComponents, - const int LengthValue) -{ - const char* LOC = "void FIELD::allocValue(const int NumberOfComponents,const int LengthValue)"; - BEGIN_OF_MED(LOC); - - _numberOfComponents = NumberOfComponents ; - _componentsTypes.resize(NumberOfComponents); - _componentsNames.resize(NumberOfComponents); - _componentsDescriptions.resize(NumberOfComponents); - _componentsUnits.resize(NumberOfComponents); - _MEDComponentsUnits.resize(NumberOfComponents); - for (int i=0;i -void FIELD::deallocValue() -{ - const char* LOC = "void FIELD::deallocValue()"; - BEGIN_OF_MED(LOC); - _numberOfValues = 0 ; - _numberOfComponents = 0 ; - if (_value != NULL) { - delete _value; - _value = NULL; - } - - END_OF_MED(LOC); -} - - - -/*!\if MEDMEM_ug - -\addtogroup FIELD_io -@{ -\endif */ -// ----------------- -// Methodes Inline -// ----------------- - -/*! - Creates the specified driver and return its index reference to path to - read or write methods. - -\param driverType specifies the file type (MED_DRIVER or VTK_DRIVER) -\param fileName name of the output file -\param driverName name of the field -\param access access type (read, write or both) - -*/ - -template -int FIELD::addDriver(driverTypes driverType, - const string & fileName/*="Default File Name.med"*/, - const string & driverName/*="Default Field Name"*/, - MED_EN::med_mode_acces access) -{ - //jfa tmp (as last argument has no default value):const char * LOC = "FIELD::addDriver(driverTypes driverType, const string & fileName=\"Default File Name.med\",const string & driverName=\"Default Field Name\",MED_EN::med_mode_acces access) : "; - - GENDRIVER * driver; - - const char* LOC = "FIELD::addDriver(driverTypes driverType, const string & fileName,const string & driverName,MED_EN::med_mode_acces access) :"; - BEGIN_OF_MED(LOC); - - SCRUTE_MED(driverType); - - driver = DRIVERFACTORY::buildDriverForField(driverType,fileName,this,access); - - _drivers.push_back(driver); - - int current = _drivers.size()-1; - - _drivers[current]->setFieldName(driverName); - - END_OF_MED(LOC); - - return current; -} - -/*! - Read FIELD in the file specified in the driver given by its index. -*/ -template inline void FIELD::read(int index/*=0*/) -{ - const char * LOC = "FIELD::read(int index=0) : "; - BEGIN_OF_MED(LOC); - - if ( index>=0 && index<(int)_drivers.size() && _drivers[index] ) { - _drivers[index]->open(); - try - { - _drivers[index]->read(); - } - catch ( const MEDEXCEPTION& ex ) - { - _drivers[index]->close(); - throw ex; - } - _drivers[index]->close(); - } - else - throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) - << "The index given is invalid, index must be between 0 and |" - << _drivers.size() - ) - ); - END_OF_MED(LOC); -} - -/*! - Read FIELD with the driver. Additional information (name etc.) to select a field - must be set to the field. -*/ -template inline void FIELD::read(const GENDRIVER & driver ) -{ - const char* LOC = " FIELD::read(const GENDRIVER &) : "; - BEGIN_OF_MED(LOC); - - // For the case where driver does not know about me since it has been created through - // constructor witout parameters: create newDriver knowing me and get missing data - // from driver using merge() - std::auto_ptr newDriver( DRIVERFACTORY::buildDriverForField(driver.getDriverType(), - driver.getFileName(), - this, RDONLY)); - newDriver->merge( driver ); - - newDriver->open(); - try - { - newDriver->read(); - } - catch ( const MEDEXCEPTION& ex ) - { - newDriver->close(); - throw ex; - } - newDriver->close(); - - END_OF_MED(LOC); -} - -/*! - Read FIELD with driver of the given type. Additional information (name etc.) to select a field - must be set to the field. -*/ -template inline void FIELD::read(driverTypes driverType, const std::string& filename) -{ - const char* LOC = " FIELD::read(driverTypes driverType, const std::string& filename) : "; - BEGIN_OF_MED(LOC); - - std::auto_ptr newDriver( DRIVERFACTORY::buildDriverForField(driverType, filename, - this, RDONLY)); - newDriver->open(); - try - { - newDriver->read(); - } - catch ( const MEDEXCEPTION& ex ) - { - newDriver->close(); - throw ex; - } - newDriver->close(); - - END_OF_MED(LOC); -} - -/*! \if MEDMEM_ug @} \endif */ - -/*! - Duplicates the given driver and return its index reference to path to - read or write methods. -*/ -template -inline int FIELD::addDriver (GENDRIVER & driver ) -{ - int current; - - const char* LOC = "FIELD::addDriver(GENDRIVER &) : "; - BEGIN_OF_MED(LOC); - - GENDRIVER * newDriver = - DRIVERFACTORY::buildDriverForField(driver.getDriverType(), - driver.getFileName(), this, - driver.getAccessMode()); - _drivers.push_back(newDriver); - - current = _drivers.size()-1; - SCRUTE_MED(current); - driver.setId(current); - - newDriver->merge( driver ); - newDriver->setId(current); - - return current ; -} - -/*! - Remove the driver referenced by its index. -*/ -template -void FIELD::rmDriver (int index/*=0*/) -{ - const char * LOC = "FIELD::rmDriver (int index=0): "; - BEGIN_OF_MED(LOC); - - if ( index>=0 && index<(int)_drivers.size() && _drivers[index] ) { - MESSAGE_MED ("detruire"); - } - else - throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) - << "The inline void FIELD::write(int index/*=0*/) -{ - const char * LOC = "FIELD::write(int index=0, const string & driverName = \"\") : "; - BEGIN_OF_MED(LOC); - - if( index>=0 && index<(int)_drivers.size() && _drivers[index] ) { - _drivers[index]->open(); - try - { - _drivers[index]->write(); - } - catch ( const MEDEXCEPTION& ex ) - { - _drivers[index]->close(); - throw ex; - } - _drivers[index]->close(); - } - else - throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) - << "The index given is invalid, index must be between 0 and |" - << _drivers.size() - ) - ); - END_OF_MED(LOC); -} -/*! - Write FIELD with the given driver. -*/ -template inline void FIELD::write(const GENDRIVER & driver, MED_EN::med_mode_acces medMode/*=MED_EN::RDWR*/) -{ - const char* LOC = " FIELD::write(const GENDRIVER &) : "; - BEGIN_OF_MED(LOC); - - // For the case where driver does not know about me since it has been created through - // constructor witout parameters: create newDriver knowing me and get missing data - // from driver using merge() - std::auto_ptr newDriver( DRIVERFACTORY::buildDriverForField(driver.getDriverType(), - driver.getFileName(), - this, WRONLY)); - newDriver->merge( driver ); - if ( newDriver->getDriverType() == MED_DRIVER ) - newDriver->setAccessMode( MED_EN::med_mode_acces( getMedAccessMode( medMode ) )); - - newDriver->open(); - try - { - newDriver->write(); - } - catch ( const MEDEXCEPTION& ex ) - { - newDriver->close(); - throw ex; - } - newDriver->close(); - - END_OF_MED(LOC); -} - -/*! - Write FIELD with driver of the given type. -*/ -template inline void FIELD::write(driverTypes driverType, const std::string& filename, MED_EN::med_mode_acces medMode/*=MED_EN::RDWR*/) -{ - const char* LOC = " FIELD::write(driverTypes driverType, const std::string& filename) : "; - BEGIN_OF_MED(LOC); - - std::auto_ptr newDriver( DRIVERFACTORY::buildDriverForField(driverType, filename, - this, WRONLY)); - if ( newDriver->getDriverType() == MED_DRIVER ) - newDriver->setAccessMode( MED_EN::med_mode_acces( getMedAccessMode( medMode ) )); - - newDriver->open(); - try - { - newDriver->write(); - } - catch ( const MEDEXCEPTION& ex ) - { - newDriver->close(); - throw ex; - } - newDriver->close(); - - END_OF_MED(LOC); -} - -/*! \if MEDMEM_ug @} \endif */ -/*! - Write FIELD in the file specified in the driver given by its index. Use this - method for ASCII drivers (e.g. VTK_DRIVER) -*/ -template inline void FIELD::writeAppend(int index/*=0*/, const string & driverName /*= ""*/) -{ - const char * LOC = "FIELD::write(int index=0, const string & driverName = \"\") : "; - BEGIN_OF_MED(LOC); - - if( index>=0 && index<(int)_drivers.size() && _drivers[index] ) { - _drivers[index]->openAppend(); - if (driverName != "") _drivers[index]->setFieldName(driverName); - try - { - _drivers[index]->writeAppend(); - } - catch ( const MEDEXCEPTION& ex ) - { - _drivers[index]->close(); - throw ex; - } - _drivers[index]->close(); - } - else - throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) - << "The index given is invalid, index must be between 0 and |" - << _drivers.size() - ) - ); - END_OF_MED(LOC); -} - -/*! - \internal - Write FIELD with the driver which is equal to the given driver. - - Use by MED object. Use this method for ASCII drivers (e.g. VTK_DRIVER). -*/ -template inline void FIELD::writeAppend(const GENDRIVER & genDriver) -{ - const char* LOC = " FIELD::write(const GENDRIVER &) : "; - BEGIN_OF_MED(LOC); - - for (unsigned int index=0; index < _drivers.size(); index++ ) - if ( *_drivers[index] == genDriver ) { - _drivers[index]->openAppend(); - try - { - _drivers[index]->writeAppend(); - } - catch ( const MEDEXCEPTION& ex ) - { - _drivers[index]->close(); - throw ex; - } - _drivers[index]->close(); - } - - END_OF_MED(LOC); - -} - -/*! - Fills in already allocated retValues array the values related to eltIdInSup. - If the element does not exist in this->_support false is returned, true otherwise. -*/ -template -bool FIELD::getValueOnElement(int eltIdInSup,T* retValues) - const throw (MEDEXCEPTION) -{ - - if(eltIdInSup<1) - return false; - if(_support->isOnAllElements()) - { - int nbOfEltsThis=_support->getMesh()->getNumberOfElements(_support->getEntity(),MED_EN::MED_ALL_ELEMENTS); - if(eltIdInSup>nbOfEltsThis) - return false; - const T* valsThis=getValue(); - for(int j=0;j<_numberOfComponents;j++) - retValues[j]=valsThis[(eltIdInSup-1)*_numberOfComponents+j]; - return true; - } - else - { - int nbOfEltsThis=_support->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS); - const int *eltsThis=_support->getNumber(MED_EN::MED_ALL_ELEMENTS); - int iThis; - bool found=false; - for(iThis=0;iThis - void FIELD::getValueOnPoint(const double* coords, double* output) const throw (MEDEXCEPTION) - { - getValueOnPoints(1, coords, output); - } - - /*! - * \brief Retrieve values in given points - * \param nb_points - number of points - * \param coords - point coordinates - * \param output - output buffer - */ - template - void FIELD::getValueOnPoints(int nb_points, const double* coords, double* output) const throw (MEDEXCEPTION) - { - const char* LOC = " FIELD::getValueOnPoints(int nb_points, const double* coords, double* output) : "; - // check operation feasibility - if ( !getSupport() ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"NULL Support")); - if ( !getSupport()->getMesh() ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"NULL Mesh")); - if ( !_value ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"NULL _value")); - if ( getGaussPresence() ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not implemeneted for Gauss points")); - - MED_EN::medEntityMesh entity = getSupport()->getEntity(); - if ( entity != MED_EN::MED_CELL && - entity != MED_EN::MED_NODE ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support must be on CELLs or NODEs")); - - // initialize output value - for ( int j = 0; j < nb_points*getNumberOfComponents(); ++j ) - output[j] = 0.0; - - const MEDMEM::MESH* mesh = getSupport()->getMesh()->convertInMESH(); - MEDMEM::AutoDeref derefMesh( mesh ); - - const double* point = coords; - double* value = output; - - if ( entity == MED_EN::MED_CELL ) - { - MEDMEM::PointLocator pLocator (*mesh); - for ( int i = 0; i < nb_points; ++i) - { - // find the cell enclosing the point - std::list cellIds = pLocator.locate( point ); - int nbCells = cellIds.size(); - if ( nbCells < 1 ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Point is out of mesh")); - - // retrieve value - std::list::iterator iCell = cellIds.begin(); - for ( ; iCell != cellIds.end(); ++iCell ) - for ( int j = 1; j <= getNumberOfComponents(); ++j ) - value[j-1] += getValueIJ( *iCell, j ) / nbCells; - - // next point - point += mesh->getSpaceDimension(); - value += getNumberOfComponents(); - } - } - else // MED_EN::MED_NODE - { - const double * allCoords = mesh->getCoordinates( MED_EN::MED_FULL_INTERLACE ); - - MEDMEM::PointLocatorInSimplex pLocator (*mesh); - for ( int i = 0; i < nb_points; ++i) - { - // find nodes of the simplex enclosing the point - std::list nodeIds = pLocator.locate( point ); - int nbNodes = nodeIds.size(); - if ( nbNodes < 1 ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Point is out of mesh")); - if ( nbNodes != mesh->getMeshDimension() + 1 ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Invalid nb of points of simplex: "< nodeCoords( nbNodes ); - std::list::iterator iNode = nodeIds.begin(); - int n = 0; - for ( ; n < nbNodes; ++iNode, ++n ) - nodeCoords[n] = allCoords + (*iNode-1) * mesh->getSpaceDimension(); - - // compute wegths of simplex nodes - double nodeWgt[4]; - pLocator.getNodeWightsInSimplex( nodeCoords, coords, nodeWgt ); - - // retrieve value - for ( n = 0, iNode = nodeIds.begin(); iNode != nodeIds.end(); ++iNode, ++n ) - for ( int j = 1; j <= getNumberOfComponents(); ++j ) - value[j-1] += getValueIJ( *iNode, j ) * nodeWgt[ n ]; - - // next point - point += mesh->getSpaceDimension(); - value += getNumberOfComponents(); - } - } - } - - -/*! - Return the coordinates of the gauss points - The returned field has SPACEDIM components -*/ -template -FIELD* FIELD::getGaussPointsCoordinates() const - throw (MEDEXCEPTION) -{ - const char * LOC = "FIELD::getGaussPointsCoordinates() : "; - BEGIN_OF_MED(LOC); - - if (!getSupport()) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support not defined" )); - - const MEDMEM::MESH* mesh = getSupport()->getMesh()->convertInMESH(); - MEDMEM::AutoDeref derefMesh( mesh ); - - const double * coord = mesh->getCoordinates(MED_FULL_INTERLACE); - int spaceDim = mesh->getSpaceDimension(); - - //Init calculator of the gauss point coordinates - INTERP_KERNEL::GaussCoords calculator; - locMap::const_iterator it; - - int nb_type = getSupport()->getNumberOfTypes(); - int length_values = getSupport()->getNumberOfElements(MED_ALL_ELEMENTS); - const medGeometryElement* types = getSupport()->getTypes(); - medEntityMesh support_entity = getSupport()->getEntity(); - bool isOnAll = getSupport()->isOnAllElements(); - - const int* global_connectivity = 0; - const GAUSS_LOCALIZATION* gaussLock = NULL; - - typedef typename MEDMEM_ArrayInterface::Array ArrayCoord; - typedef typename MEDMEM_ArrayInterface::Array TArrayGauss; - - vector nbelgeoc, nbgaussgeo; - - nbelgeoc.resize(nb_type+1, 0); - nbgaussgeo.resize(nb_type+1, 0); - - for ( int iType = 0 ; iType < nb_type ; iType++ ) { - - medGeometryElement elem_type = types[iType] ; - if(elem_type == MED_EN::MED_POLYGON && elem_type == MED_EN::MED_POLYHEDRA ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad cell type : "< * > ((*it).second); - - ArrayCoord coord = gaussLock->getGsCoo(); - double* gaussCoord = new double[coord.getNbElem()*coord.getDim()]; - int idx = 0; - for( int i = 1 ; i <= coord.getNbElem() ; i++ ) { - for( int j = 1 ; j <= coord.getDim() ; j++ ) { - gaussCoord[idx++] = coord.getIJ(i,j); - } - } - - idx = 0; - ArrayCoord ref = gaussLock->getRefCoo(); - double* refCoord = new double[ref.getNbElem()*ref.getDim()]; - for( int i = 1 ; i <= ref.getNbElem() ; i++ ) { - for( int j = 1 ; j <= ref.getDim() ; j++ ) { - refCoord[idx++] = ref.getIJ(i,j); - } - } - - INTERP_KERNEL::NormalizedCellType normType; - switch(elem_type) { - case MED_EN::MED_SEG2 : normType = INTERP_KERNEL::NORM_SEG2;break; - case MED_EN::MED_SEG3 : normType = INTERP_KERNEL::NORM_SEG3;break; - default : normType = (INTERP_KERNEL::NormalizedCellType) ((((unsigned long)elem_type/100-2)*10) + ((unsigned long)elem_type%100)); - break; - } - - calculator.addGaussInfo(normType, - elem_type/100, - gaussCoord, - gaussLock->getNbGauss(), - refCoord, - elem_type%100 - ); - // Preapre Info for the gauss array - nbelgeoc [ iType+1 ] = nbelgeoc[ iType ] + getSupport()->getNumberOfElements(elem_type); - nbgaussgeo [ iType+1 ] = gaussLock->getNbGauss(); - - delete [] gaussCoord; - delete [] refCoord; - } - - FIELD* gpCoord = - new FIELD(getSupport(),spaceDim); - gpCoord->setName("Gauss Points Coordinates"); - gpCoord->setDescription("Gauss Points Coordinates"); - - for(int dimId = 1 ; dimId <= spaceDim; dimId++) { - switch(dimId) { - case 1: - gpCoord->setComponentName(dimId,"X"); - gpCoord->setComponentDescription(dimId,"X coordinate of the gauss point"); - break; - case 2: - gpCoord->setComponentName(dimId,"Y"); - gpCoord->setComponentDescription(dimId,"Y coordinate of the gauss point"); - break; - case 3: - gpCoord->setComponentName(dimId,"Z"); - gpCoord->setComponentDescription(dimId,"Z coordinate of the gauss point"); - break; - } - - gpCoord->setMEDComponentUnit(dimId, mesh->getCoordinatesUnits()[dimId-1]); - } - - gpCoord->setIterationNumber(getIterationNumber()); - gpCoord->setOrderNumber(getOrderNumber()); - gpCoord->setTime(getTime()); - - TArrayGauss *arrayGauss = new TArrayGauss(spaceDim, length_values, - nb_type, & nbelgeoc[0], & nbgaussgeo[0]); - gpCoord->setArray(arrayGauss); - - - - - //Calculation of the coordinates - int index = 1; - for ( int i = 0 ; i < nb_type ; i++ ) { - - medGeometryElement type = types[i] ; - INTERP_KERNEL::NormalizedCellType normType; - switch(type) { - case MED_EN::MED_SEG2 : normType = INTERP_KERNEL::NORM_SEG2;break; - case MED_EN::MED_SEG3 : normType = INTERP_KERNEL::NORM_SEG3;break; - default : normType = (INTERP_KERNEL::NormalizedCellType) ((((unsigned long)type/100-2)*10) + ((unsigned long)type%100)); - break; - } - - it = _gaussModel.find(type); - - gaussLock = static_cast * > ((*it).second); - int nb_entity_type = getSupport()->getNumberOfElements(type); - - - if (isOnAll) { - global_connectivity = mesh->getConnectivity(MED_NODAL,support_entity,type); - } - else { - const int * supp_number = getSupport()->getNumber(type); - const int * connectivity = mesh->getConnectivity(MED_NODAL,support_entity,MED_ALL_ELEMENTS); - const int * connectivityIndex = mesh->getConnectivityIndex(MED_NODAL,support_entity); - int * global_connectivity_tmp = new int[(type%100)*nb_entity_type]; - - for (int k_type = 0; k_typegetNbGauss(); k++ ) { - for( int dimId = 1; dimId <= spaceDim; dimId++ ) { - gpCoord->setValueIJK(index,dimId,(k+1),gCoord[resultIndex]); - resultIndex++; - } - } - delete [] gCoord; - delete [] Ni; - index++; - } - if (!isOnAll && type != MED_EN::MED_POLYHEDRA && type != MED_EN::MED_POLYGON) { - delete [] global_connectivity ; - } - } - END_OF_MED(LOC); - return gpCoord; -} - -/*! - \if developper - Destroy the MEDARRAY in FIELD and put the new one without copy. - \endif -*/ -template -inline void FIELD::setArray(MEDMEM_Array_ * Value) - throw (MEDEXCEPTION) -{ - if (NULL != _value) delete _value ; - _value=Value ; -} - -/*! - \if developper - Return a reference to the MEDARRAY in FIELD. - \endif -*/ -template -inline MEDMEM_Array_ * FIELD::getArray() const throw (MEDEXCEPTION) -{ - const char* LOC = "MEDMEM_Array_ * FIELD::getArray() : "; - BEGIN_OF_MED(LOC); - END_OF_MED(LOC); - return _value ; -} -template inline -typename MEDMEM_ArrayInterface::Array * -FIELD::getArrayGauss() const throw (MEDEXCEPTION) -{ - const char * LOC = "FIELD::getArrayGauss() : "; - BEGIN_OF_MED(LOC); - - if ( getGaussPresence() ) - return static_cast (_value); - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< - "The field has no Gauss Point")); - - END_OF_MED(LOC); - -} - -template inline -typename MEDMEM_ArrayInterface::Array * -FIELD::getArrayNoGauss() const throw (MEDEXCEPTION) -{ - const char * LOC = "FIELD::getArrayNoGauss() : "; - BEGIN_OF_MED(LOC); - - if ( ! getGaussPresence() ) - return static_cast < ArrayNoGauss * > (_value); - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< - "The field has Gauss Point")); - - END_OF_MED(LOC); -} - - -template inline bool -FIELD::getGaussPresence() const throw (MEDEXCEPTION) -{ - if (_value != NULL) - return _value->getGaussPresence(); - else - throw MEDEXCEPTION("FIELD::getGaussPresence() const : Can't call getGaussPresence on a null _value"); -} - -/*! - Return the actual length of the reference to values array returned by getValue. - Take care of number of components and number of Gauss points by geometric type -*/ -template -inline int FIELD::getValueLength() const - throw (MEDEXCEPTION) -{ - if ( getGaussPresence() ) - return static_cast(_value)->getArraySize() ; - else - return static_cast(_value)->getArraySize() ; -} - - -/*! \if MEDMEM_ug -\defgroup FIELD_value Field values - -These methods are provided for accessing the values of a field. -There are two ways to do so : one consists in using accessors -that retrieve elements or group of elements from the entire field. Typical use is -\verbatim -FIELD field(MED_DRIVER, "result.med","Pressure"); -double P0=field.getValueIJ(1,1); -\endverbatim - -Another way is to retrieve the pointer to the array that contains the -variable values. In this case, the user should be aware of the interlacing mode -so that no mistakes are made when retrieving the values. - -\verbatim -FIELD field(MED_DRIVER, "result.med","Pressure"); -double* ptrP=field.getValue(); -double P0=ptrP[0]; -\endverbatim - -@{ -\endif -*/ -/*! - Returns a reference to values array to read them. -*/ -template -inline const T* FIELD::getValue() const throw (MEDEXCEPTION) -{ - const char* LOC = "FIELD::getValue() : "; - BEGIN_OF_MED(LOC); - if ( getGaussPresence() ) - return static_cast(_value)->getPtr() ; - else - return static_cast(_value)->getPtr() ; -} -/*! - Returns a reference to \f$ i^{th} \f$ row - of FIELD values array. - If a faster accessor is intended you may use getArray() once, - then MEDMEM_Array accessors. - Be careful if field support is not on all elements getRow - use support->getValIndFromGlobalNumber(i). -*/ -template inline -const T* -FIELD::getRow(int i) const throw (MEDEXCEPTION) -{ - const char* LOC; LOC = "FIELD::getRow(int i) : "; - - int valIndex=-1; - if (_support) - valIndex = _support->getValIndFromGlobalNumber(i); - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support not defined" )); - - if ( getGaussPresence() ) - return static_cast(_value)->getRow(valIndex) ; - else - return static_cast(_value)->getRow(valIndex) ; -} - -/*! - Returns a reference to $j^{th}$ column - of FIELD values array. -*/ -template inline const T* -FIELD::getColumn(int j) const throw (MEDEXCEPTION) -{ - if ( getGaussPresence() ) - return static_cast(_value)->getColumn(j) ; - else - return static_cast(_value)->getColumn(j) ; -} - -/*! - Returns the value of $i^{th}$ element and $j^{th}$ component. - This method only works with fields having no particular Gauss point -definition (i.e., fields having one value per element). - This method makes the retrieval of the value independent from the - interlacing pattern, but it is slower than the complete retrieval - obtained by the \b getValue() method. -*/ -template inline T FIELD::getValueIJ(int i,int j) const throw (MEDEXCEPTION) -{ - const char * LOC = "getValueIJ(..)"; - int valIndex=-1; - if (_support) - valIndex = _support->getValIndFromGlobalNumber(i); - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support not defined" )); - - if ( getGaussPresence() ) - return static_cast(_value)->getIJ(valIndex,j) ; - else - return static_cast(_value)->getIJ(valIndex,j) ; -} - -/*! - Returns the $j^{th}$ component of $k^{th}$ Gauss points of $i^{th}$ value. - This method is compatible with elements having more than one Gauss point. - This method makes the retrieval of the value independent from the - interlacing pattern, but it is slower than the complete retrieval - obtained by the \b getValue() method. -*/ -template inline T FIELD::getValueIJK(int i,int j,int k) const throw (MEDEXCEPTION) -{ - const char * LOC = "getValueIJK(..)"; - int valIndex=-1; - if (_support) - valIndex = _support->getValIndFromGlobalNumber(i); - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support not defined" )); - - if ( getGaussPresence() ) - return static_cast(_value)->getIJK(valIndex,j,k) ; - else - return static_cast(_value)->getIJK(valIndex,j,k) ; -} -/*! \if MEDMEM_ug @} \endif */ - -/*! - Return number of values of a geomertic type in NoInterlaceByType mode -*/ -template -inline int FIELD::getValueByTypeLength(int t) const throw (MEDEXCEPTION) -{ - const char * LOC ="getValueByTypeLength() : "; - if ( getInterlacingType() != MED_EN::MED_NO_INTERLACE_BY_TYPE ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"not MED_NO_INTERLACE_BY_TYPE field" )); - - if ( getGaussPresence() ) { - ArrayNoByTypeGauss* array = static_cast(_value); - if ( t < 1 || t > array->getNbGeoType() ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Invalid type: "<< t )); - return array->getLengthOfType( t ); - } - else { - ArrayNoByType* array = static_cast(_value); - if ( t < 1 || t > array->getNbGeoType() ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Invalid type: "<< t )); - return array->getLengthOfType( t ); - } -} - -/*! - Return a reference to values array to read them. -*/ -template -inline const T* FIELD::getValueByType(int t) const throw (MEDEXCEPTION) -{ - if ( getInterlacingType() != MED_EN::MED_NO_INTERLACE_BY_TYPE ) - throw MEDEXCEPTION(LOCALIZED("getValueByType() : not MED_NO_INTERLACE_BY_TYPE field" )); - - if ( getGaussPresence() ) { - ArrayNoByTypeGauss* array = static_cast(_value); - return array->getPtr() + array->getIndex( t ); - } - else { - ArrayNoByType* array = static_cast(_value); - return array->getPtr() + array->getIndex( t ); - } -} - -/*! - Return the value of i^{th} element in indicated type t and j^{th} component. -*/ -template inline T FIELD::getValueIJByType(int i,int j, int t) const throw (MEDEXCEPTION) -{ - const char * LOC = "getValueIJByType(..)"; - if ( getInterlacingType() != MED_EN::MED_NO_INTERLACE_BY_TYPE ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"not MED_NO_INTERLACE_BY_TYPE field" )); - - if ( getGaussPresence() ) - return static_cast(_value)->getIJByType(i,j,t) ; - else - return static_cast(_value)->getIJByType(i,j,t) ; -} - -/*! - Return the j^{th} component of k^{th} gauss points of i^{th} value with type t. -*/ -template inline T FIELD::getValueIJKByType(int i,int j,int k,int t) const throw (MEDEXCEPTION) -{ - const char * LOC = "getValueIJKByType(..)"; - if ( getInterlacingType() != MED_EN::MED_NO_INTERLACE_BY_TYPE ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"not MED_NO_INTERLACE_BY_TYPE field" )); - - if ( getGaussPresence() ) - return static_cast(_value)->getIJKByType(i,j,k,t) ; - else - return static_cast(_value)->getIJKByType(i,j,k,t) ; -} - - -template const int FIELD::getNumberOfGeometricTypes() const throw (MEDEXCEPTION) -{ - const char * LOC = "getNumberOfGeometricTypes(..)"; - BEGIN_OF_MED(LOC); - if (_support) - return _support->getNumberOfTypes(); - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support not defined" )); - END_OF_MED(LOC); -} - -/*! \if MEDMEM_ug -\addtogroup FIELD_gauss -@{ -\endif - */ - -template const GAUSS_LOCALIZATION & -FIELD::getGaussLocalization(MED_EN::medGeometryElement geomElement) const throw (MEDEXCEPTION) -{ - const char * LOC ="getGaussLocalization(MED_EN::medGeometryElement geomElement) : "; - const GAUSS_LOCALIZATION_ * locPtr=0; - - locMap::const_iterator it; - if ( ( it = _gaussModel.find(geomElement)) != _gaussModel.end() ) { - locPtr = (*it).second; - return *static_cast *>(locPtr); - } - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Can't find any GaussLocalization on this geometric type" )); - -} - -template const GAUSS_LOCALIZATION * -FIELD::getGaussLocalizationPtr(MED_EN::medGeometryElement geomElement) const throw (MEDEXCEPTION) -{ - const char * LOC ="getGaussLocalizationPtr(MED_EN::medGeometryElement geomElement) : "; - const GAUSS_LOCALIZATION_ * locPtr=0; - - locMap::const_iterator it; - if ( ( it = _gaussModel.find(geomElement)) != _gaussModel.end() ) { - locPtr = (*it).second; - return static_cast *>(locPtr); - } - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Can't find any GaussLocalization on this geometric type" )); - -} - -/*! - * \brief Return GAUSS_LOCALIZATION_* whose interlacing type may differ from one of the field - */ -template const GAUSS_LOCALIZATION_ * -FIELD::getGaussLocalizationRoot(MED_EN::medGeometryElement geomElement) const throw (MEDEXCEPTION) -{ - const char * LOC ="getGaussLocalizationRoot(MED_EN::medGeometryElement geomElement) : "; - - locMap::const_iterator it; - if ( ( it = _gaussModel.find(geomElement)) != _gaussModel.end() ) { - return (*it).second; - } - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Can't find any GaussLocalization on this geometric type: "<< geomElement )); - -} - -/*! - * \brief Take onership of GAUSS_LOCALIZATION_* whose interlacing type may differ from one of the field - */ -template void -FIELD::setGaussLocalization(MED_EN::medGeometryElement geomElement, GAUSS_LOCALIZATION_* gaussloc) -{ - locMap::iterator it = _gaussModel.find(geomElement); - if ( it != _gaussModel.end() ) { - delete it->second; - it->second = gaussloc; - } - else { - _gaussModel[ geomElement ] = gaussloc; - } -} - - -template void -FIELD::setGaussLocalization(MED_EN::medGeometryElement geomElement, const GAUSS_LOCALIZATION& gaussloc) -{ - locMap::iterator it = _gaussModel.find(geomElement); - if ( it != _gaussModel.end() ) { - delete it->second; - it->second = new GAUSS_LOCALIZATION (gaussloc); - } - else { - _gaussModel[ geomElement ] = new GAUSS_LOCALIZATION (gaussloc); - } -} - -/*! - Returns number of Gauss points for this medGeometryElement. - - Note : - if there is no GAUSS_LOCALIZATION having this medGeometryElement but - the medGeometryElement exist in the SUPPORT, getNumberOfGaussPoints - return 1 -*/ -template const int FIELD::getNumberOfGaussPoints(MED_EN::medGeometryElement geomElement) const - throw (MEDEXCEPTION) -{ - const char * LOC ="getNumberOfGaussPoints(MED_EN::medGeometryElement geomElement) : "; - const GAUSS_LOCALIZATION_ * locPtr=0; - - locMap::const_iterator it; - if ( ( it = _gaussModel.find(geomElement)) != _gaussModel.end() ) { - locPtr = (*it).second; - return static_cast *>(locPtr)->getNbGauss(); - } - else - if (_support) - try { - if ( _support->getNumberOfElements(geomElement) ) return 1; - } catch ( MEDEXCEPTION & ex) { - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< "GeometricType not found !" )) ; - } - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support not defined" )); - - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Should never execute this!" )); - -} - -/*! - Returns number of Gauss points for each geometric type. - - Note : - if there is no gauss points whatever the geometric type is - it returns an exception. (renvoyer un tableau de 1 ?) -*/ -template const int * FIELD::getNumberOfGaussPoints() const - throw (MEDEXCEPTION) -{ - const char * LOC ="const int * getNumberOfGaussPoints(MED_EN::medGeometryElement geomElement) : "; - - if (_value) - if ( getGaussPresence() ) { - return static_cast(_value)->getNbGaussGeo()+1; - } else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"value hasn't Gauss points " )); - - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Value not defined" )); -} - -/*! - Returns number of Gauss points for element n°i. - The i index is a global index (take care of previous element - on different geometric type). -*/ -template const int FIELD::getNbGaussI(int i) const throw (MEDEXCEPTION) -{ - const char * LOC = "getNbGaussI(..)"; - - int valIndex=-1; - if (_support) - valIndex = _support->getValIndFromGlobalNumber(i); - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support not defined" )); - - if (_value) - if ( getGaussPresence() ) - return static_cast(_value)->getNbGauss(valIndex) ; - else - return static_cast(_value)->getNbGauss(valIndex) ; - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"_value not defined" )); -} -/*! -@} - */ - - -template const int * FIELD::getNumberOfElements() const throw (MEDEXCEPTION) -{ - const char * LOC = "getNumberOfElements(..)"; - BEGIN_OF_MED(LOC); - if (_support) - return _support->getNumberOfElements(); - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support not defined" )); - END_OF_MED(LOC); -} - -template const MED_EN::medGeometryElement * FIELD::getGeometricTypes() const throw (MEDEXCEPTION) -{ - const char * LOC = "getGeometricTypes(..)"; - BEGIN_OF_MED(LOC); - if (_support) - return _support->getTypes(); - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support not defined" )); - END_OF_MED(LOC); -} -template bool FIELD::isOnAllElements() const throw (MEDEXCEPTION) -{ - const char * LOC = "isOnAllElements(..)"; - BEGIN_OF_MED(LOC); - if (_support) - return _support->isOnAllElements(); - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support not defined" )); - END_OF_MED(LOC); -} - - -/*! \if MEDMEM_ug -\addtogroup FIELD_value -@{ -\endif */ - -/*! - Copy new values array in FIELD according to the given mode. - - Array must have right size. If not results are unpredicable. - In MED_FULL_INTERLACE mode, values are stored elementwise in X1,Y1,Z1,X2,Y2,Z2.. order. -In MED_NO_INTERLACE mode, values are stored componentwise in X1,X2,X3,...,Y1,Y2,Y3,... order. -*/ -template inline void FIELD::setValue( T* value) throw (MEDEXCEPTION) -{ - if ( getGaussPresence() ) - static_cast(_value)->setPtr(value) ; - else - static_cast(_value)->setPtr(value) ; -} - -/*! - Update values array in the j^{th} row of FIELD values array with the given ones and - according to specified mode. -*/ -template -inline void FIELD::setRow( int i, T* value) throw (MEDEXCEPTION) -{ - const char * LOC = "FIELD::setRow(int i, T* value) : "; - int valIndex=i; - if (_support) - valIndex = _support->getValIndFromGlobalNumber(i); - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support not define |" )); - - if ( getGaussPresence() ) - static_cast(_value)->setRow(valIndex, value) ; - else - static_cast(_value)->setRow(valIndex, value) ; -} - -/*! - Update values array in the $j^{th}$ column of FIELD values array with the given ones and - according to specified mode. -*/ -template -inline void FIELD::setColumn( int j, T* value) throw (MEDEXCEPTION) -{ - if ( getGaussPresence() ) - static_cast(_value)->setColumn(j, value) ; - else - static_cast(_value)->setColumn(j, value) ; -} - -/*! - Sets the value of i^{th} element and j^{th} component with the given one. -*/ -template inline void FIELD::setValueIJ(int i, int j, T value) throw (MEDEXCEPTION) -{ - const char * LOC = "FIELD::setValueIJ(int i, int j, T value) : "; - int valIndex=-1; - if (_support) - valIndex = _support->getValIndFromGlobalNumber(i); - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support not define |" )); - - if ( getGaussPresence() ) - static_cast(_value)->setIJ(valIndex,j,value) ; - else - static_cast(_value)->setIJ(valIndex,j,value) ; -} - -/*! - Set the value of i^{th} element, j^{th} component and k^{th} gauss point with the given one. -*/ -template inline void FIELD::setValueIJK(int i, int j, int k, T value) throw (MEDEXCEPTION) -{ - const char * LOC = "FIELD::setValueIJ(int i, int j, T value) : "; - int valIndex=-1; - if (_support) - valIndex = _support->getValIndFromGlobalNumber(i); - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support not define |" )); - - if ( getGaussPresence() ) - static_cast(_value)->setIJK(valIndex,j,k,value) ; - else - static_cast(_value)->setIJK(valIndex,j,k,value) ; -} - -/*! - Set the value of i^{th} element and j^{th} component with the given one. -*/ -template inline void FIELD::setValueIJByType(int i, int j, int t, T value) throw (MEDEXCEPTION) -{ - const char * LOC = "FIELD::setValueIJByType(int i, int j, int t, T value) : "; - if ( getInterlacingType() != MED_EN::MED_NO_INTERLACE_BY_TYPE ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"not MED_NO_INTERLACE_BY_TYPE field" )); - - if ( getGaussPresence() ) - return static_cast(_value)->setIJByType(i,j,t,value) ; - else - return static_cast(_value)->setIJByType(i,j,t,value) ; -} - -/*! - Set the value of component of k^{th} gauss points of i^{th} element and j^{th} component with the given one. -*/ -template inline void FIELD::setValueIJKByType(int i, int j, int k, int t, T value) throw (MEDEXCEPTION) -{ - const char * LOC = "FIELD::setValueIJKByType(int i, int j, int t, int k, T value) : "; - if ( getInterlacingType() != MED_EN::MED_NO_INTERLACE_BY_TYPE ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"not MED_NO_INTERLACE_BY_TYPE field" )); - - if ( getGaussPresence() ) - return static_cast(_value)->setIJKByType(i,j,k,t,value) ; - else - return static_cast(_value)->setIJKByType(i,j,k,t,value) ; -} -/*! \if MEDMEM_ug @} \endif */ - -/* - METHODS -*/ - -/*! - Fill array by using T_Analytic. - WARNING : "this" must have allocated its array by setting this->_support and this->_numberOfComponents properly. - Typically you should use it on a field built with constructor FIELD::FIELD(SUPPORT *,int nbOfComponents) - */ -template -void FIELD::fillFromAnalytic(myFuncType f) throw (MEDEXCEPTION) -{ - const char * LOC = "void FIELD::fillFromAnalytic(myFuncType f) : "; - int i,j; - if (_support == (SUPPORT *) NULL) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"No Support defined.")); - - const GMESH * mesh = _support->getMesh(); - int spaceDim = mesh->getSpaceDimension(); - const double * coord; - - const double * bary; - FIELD * barycenterField=0; - - double ** xyz=new double* [spaceDim]; - bool deallocateXyz=false; - if(_support->getEntity()==MED_EN::MED_NODE) - { - const MESH * unstructured = _support->getMesh()->convertInMESH(); - if (_support->isOnAllElements()) - { - coord=unstructured->getCoordinates(MED_EN::MED_NO_INTERLACE); - for(i=0; igetCoordinates(MED_EN::MED_FULL_INTERLACE); - const int * nodesNumber=_support->getNumber(MED_EN::MED_ALL_ELEMENTS); - for(i=0; iremoveReference(); - } - else - { - barycenterField = mesh->getBarycenter(_support); - bary = barycenterField->getValue(); - for(i=0; i_support and this->_numberOfComponents properly. - Typically you should use it on a field built with constructor FIELD::FIELD(SUPPORT *,int nbOfComponents) - */ -template -FIELD *FIELD::execFunc(int nbOfComponents, - myFuncType2 f) throw (MEDEXCEPTION) -{ - FIELD *ret=new FIELD(_support,nbOfComponents); - const T* valsInput=getValue(); - T* valsOutPut=(T*)ret->getValue(); - int i; - for(i=0;i<_numberOfValues;i++) - f(valsInput+i*_numberOfComponents,valsOutPut+i*nbOfComponents); - return ret; -} - -}//End namespace MEDMEM - -#endif /* FIELD_HXX */ diff --git a/src/MEDMEM/MEDMEM_FieldConvert.hxx b/src/MEDMEM/MEDMEM_FieldConvert.hxx deleted file mode 100644 index c131aebfb..000000000 --- a/src/MEDMEM/MEDMEM_FieldConvert.hxx +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef FIELD_CONVERT_HXX -#define FIELD_CONVERT_HXX - -//#include "MEDMEM_FieldForward.hxx" -#include "MEDMEM_Field.hxx" // issue 0021050: compilation with clang -#include "MEDMEM_ArrayInterface.hxx" -#include "MEDMEM_ArrayConvert.hxx" - -namespace MEDMEM { -class FIELD_; - -template FIELD * -FieldConvert(const FIELD & field ) -{ - typedef typename MEDMEM_ArrayInterface::Array ArrayFullNo; - typedef typename MEDMEM_ArrayInterface::Array ArrayFullGa; - - FIELD * myField = new FIELD(); - FIELD_ * myField_ = myField; - FIELD_ * field_ = &(const_cast< FIELD &> (field)); - *myField_ = *field_; // Opérateur d'affectation de FIELD_ OK - // *((FIELD_ *) myField) = (FIELD_ ) field; //Contructeur par recopie de FIELD_ Pourquoi? - - if ( field.getGaussPresence() ) { - ArrayFullGa * myArray = ArrayConvert( *(field.getArrayGauss()) ); - myField->setArray(myArray); - return myField; - } else { - ArrayFullNo * myArray = ArrayConvert( *(field.getArrayNoGauss()) ); - myField->setArray(myArray); - return myField; - } -} - -template FIELD * -FieldConvert(const FIELD & field ) -{ - typedef typename MEDMEM_ArrayInterface::Array ArrayNoNo; - typedef typename MEDMEM_ArrayInterface::Array ArrayNoGa; - - - FIELD * myField = new FIELD(); - FIELD_ * myField_ = myField; - FIELD_ * field_ = &(const_cast< FIELD &> (field)); - *myField_ = *field_; // Opérateur d'affectation de FIELD_ OK - // *((FIELD_*) myField) = (FIELD_) field; //Contructeur par recopie de FIELD_ Pourquoi? - - if ( field.getGaussPresence() ) { - ArrayNoGa * myArray = ArrayConvert( *(field.getArrayGauss()) ); - myField->setArray(myArray); - return myField; - } else { - ArrayNoNo * myArray = ArrayConvert( *(field.getArrayNoGauss()) ); - myField->setArray(myArray); - return myField; - } - -} - -template FIELD * -FieldConvert(const FIELD & field ) -{ - typedef typename MEDMEM_ArrayInterface::Array ArrayFullNo; - typedef typename MEDMEM_ArrayInterface::Array ArrayFullGa; - - FIELD * myField = new FIELD(); - FIELD_ * myField_ = myField; - FIELD_ * field_ = &(const_cast< FIELD &> (field)); - *myField_ = *field_; // Opérateur d'affectation de FIELD_ OK - // *((FIELD_ *) myField) = (FIELD_ ) field; //Contructeur par recopie de FIELD_ Pourquoi? - - if ( field.getGaussPresence() ) { - ArrayFullGa * myArray = ArrayConvert( *(field.getArrayGauss()) ); - myField->setArray(myArray); - return myField; - } else { - ArrayFullNo * myArray = ArrayConvert( *(field.getArrayNoGauss()) ); - myField->setArray(myArray); - return myField; - } -} - -} -#endif diff --git a/src/MEDMEM/MEDMEM_FieldForward.hxx b/src/MEDMEM/MEDMEM_FieldForward.hxx deleted file mode 100644 index 1334e7095..000000000 --- a/src/MEDMEM/MEDMEM_FieldForward.hxx +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef FIELD_FORWARD -#define FIELD_FORWARD - -#include "MEDMEM_Tags.hxx" - -namespace MEDMEM { - template class FIELD; - -} -#endif diff --git a/src/MEDMEM/MEDMEM_GMesh.cxx b/src/MEDMEM/MEDMEM_GMesh.cxx deleted file mode 100644 index 5c4c83580..000000000 --- a/src/MEDMEM/MEDMEM_GMesh.cxx +++ /dev/null @@ -1,1403 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// File : MEDMEM_GMesh.cxx -// Created : Fri Jul 23 12:32:18 2010 -// Author : Edward AGAPOV (eap) -// - -#include "MEDMEM_GMesh.hxx" - -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Group.hxx" -#include "MEDMEM_DriverFactory.hxx" - -using namespace MEDMEM; -using namespace MED_EN; -using namespace std; - -/*! -\defgroup GMESH_general MESH General information -These methods are related to the retrieval of general information about the mesh. - -\defgroup MESH_families Families and Groups handling -The methods described in this section enable the manipulation of families and groups. These -notions define subsets of MED elements in a mesh. They differ because families are non -overlapping (a mesh element is associated to zero or one family) while groups are more general. - -\defgroup MESH_io Mesh I/O -These methods describe how to read and write meshes. Generally speaking, meshes should be read -via a constructor and should be written with the write() method. - -*/ - -//================================================================================ -/*! Create an empty GMESH. */ -//================================================================================ - -GMESH::GMESH() -{ - init(); -} - -//================================================================================ -/*! - Copy constructor -*/ -//================================================================================ - -GMESH::GMESH(GMESH &m) -{ - _name = m._name; - _description = m._description; - _spaceDimension = m._spaceDimension; - - _familyNode = m._familyNode; - for (int i=0; i<(int)m._familyNode.size(); i++) - { - _familyNode[i] = new FAMILY(* m._familyNode[i]); - _familyNode[i]->setMesh(this); - removeReference(); - } - - _familyCell = m._familyCell; - for (int i=0; i<(int)m._familyCell.size(); i++) - { - _familyCell[i] = new FAMILY(* m._familyCell[i]); - _familyCell[i]->setMesh(this); - removeReference(); - } - - _familyFace = m._familyFace; - for (int i=0; i<(int)m._familyFace.size(); i++) - { - _familyFace[i] = new FAMILY(* m._familyFace[i]); - _familyFace[i]->setMesh(this); - removeReference(); - } - - _familyEdge = m._familyEdge; - for (int i=0; i<(int)m._familyEdge.size(); i++) - { - _familyEdge[i] = new FAMILY(* m._familyEdge[i]); - _familyEdge[i]->setMesh(this); - removeReference(); - } - - _groupNode = m._groupNode; - for (int i=0; i<(int)m._groupNode.size(); i++) - { - _groupNode[i] = new GROUP(* m._groupNode[i]); - _groupNode[i]->setMesh(this); - removeReference(); - } - - _groupCell = m._groupCell; - for (int i=0; i<(int)m._groupCell.size(); i++) - { - _groupCell[i] = new GROUP(* m._groupCell[i]); - _groupCell[i]->setMesh(this); - removeReference(); - } - - _groupFace = m._groupFace; - for (int i=0; i<(int)m._groupFace.size(); i++) - { - _groupFace[i] = new GROUP(* m._groupFace[i]); - _groupFace[i]->setMesh(this); - removeReference(); - } - - _groupEdge = m._groupEdge; - for (int i=0; i<(int)m._groupEdge.size(); i++) - { - _groupEdge[i] = new GROUP(* m._groupEdge[i]); - _groupEdge[i]->setMesh(this); - removeReference(); - } - - //_drivers = m._drivers; //Recopie des drivers? -} - -//================================================================================ -/*! - * \brief Destructor - */ -//================================================================================ - -GMESH::~GMESH() -{ - // if this is an automatic variable, be sure that destructor will be no more called - // due to cyclic dependencies with child reference counters (groups and families) - clearRefCouner(); - - for (unsigned i=0;i<_familyNode.size();i++) - { - // if another object refers to a family and it survive now, - // it sould not refer to a dead mesh - _familyNode[i]->setMesh(0); - _familyNode[i]->setMeshName( getName() ); - _familyNode[i]->removeReference(); - } - _familyNode.clear(); - for (unsigned i=0;i<_familyCell.size();i++) - { - _familyCell[i]->setMesh(0); - _familyCell[i]->setMeshName( getName() ); - _familyCell[i]->removeReference(); - } - _familyCell.clear(); - for (unsigned i=0;i<_familyFace.size();i++) - { - _familyFace[i]->setMesh(0); - _familyFace[i]->setMeshName( getName() ); - _familyFace[i]->removeReference(); - } - _familyFace.clear(); - for (unsigned i=0;i<_familyEdge.size();i++) - { - _familyEdge[i]->setMesh(0); - _familyEdge[i]->setMeshName( getName() ); - _familyEdge[i]->removeReference(); - } - _familyEdge.clear(); - for (unsigned i=0;i<_groupNode.size();i++) - { - _groupNode[i]->setMesh(0); - _groupNode[i]->setMeshName( getName() ); - _groupNode[i]->removeReference(); - } - _groupNode.clear(); - for (unsigned i=0;i<_groupCell.size();i++) - { - _groupCell[i]->setMesh(0); - _groupCell[i]->setMeshName( getName() ); - _groupCell[i]->removeReference(); - } - _groupCell.clear(); - for (unsigned i=0;i<_groupFace.size();i++) - { - _groupFace[i]->setMesh(0); - _groupFace[i]->setMeshName( getName() ); - _groupFace[i]->removeReference(); - } - _groupFace.clear(); - for (unsigned i=0;i<_groupEdge.size();i++) - { - _groupEdge[i]->setMesh(0); - _groupEdge[i]->setMeshName( getName() ); - _groupEdge[i]->removeReference(); - } - _groupEdge.clear(); - - map::iterator it = _entitySupport.begin(); - for(;it!=_entitySupport.end();it++) - if((*it).second != NULL) - { - (*it).second->setMesh(0); - (*it).second->setMeshName( getName() ); - (*it).second->removeReference(); - } - _entitySupport.clear(); - - for (unsigned int index=0; index < _drivers.size(); index++ ) - if ( _drivers[index] ) delete _drivers[index]; - _drivers.clear(); -} - -//================================================================================ -/*! - * \brief Initialization of fields - */ -//================================================================================ - -void GMESH::init() -{ - const char* LOC = "GMESH::init(): "; - BEGIN_OF_MED(LOC); - - _name ="NOT DEFINED"; - _spaceDimension=MED_INVALID; - - END_OF_MED(LOC); -} - -//================================================================================ -/*! - * \brief Copy operator - */ -//================================================================================ - -GMESH & GMESH::operator=(const GMESH &m) -{ - const char* LOC = "GMESH & GMESH::operator=(const GMESH &m) : "; - BEGIN_OF_MED(LOC); - MESSAGE_MED("Not yet implemented"); - END_OF_MED(LOC); - - return *this; -} - -//================================================================================ -/*! - * \brief Comparison - */ -//================================================================================ - -bool GMESH::operator==(const GMESH& other) const -{ - return this==&other; -} - -//================================================================================ -/*! - * \brief Print operator - */ -//================================================================================ - -ostream & MEDMEM::operator<<(ostream &os, const GMESH &myMesh) -{ - myMesh.printMySelf(os); - return os; -} - -/*! \if MEDMEM_ug -\addtogroup MESH_io -@{ -\endif -*/ -//================================================================================ -/*! - * \brief Add a %MESH driver of type %driverTypes (MED_DRIVER, ....) associated - * with file fileName. The meshname used in the file is driverName. - * addDriver returns an integer handler. - */ -//================================================================================ - -int GMESH::addDriver(driverTypes driverType, - const std::string & fileName, - const std::string & driverName, - MED_EN::med_mode_acces access) -{ - const char* LOC = "GMESH::addDriver(driverTypes driverType, const string & fileName=\"Default File Name.med\",const string & driverName=\"Default Mesh Name\",MED_EN::med_mode_acces access) : "; - BEGIN_OF_MED(LOC); - - GENDRIVER * driver; - - SCRUTE_MED(driverType); - - driver = DRIVERFACTORY::buildDriverForMesh(driverType,fileName,this,driverName,access) ; - - _drivers.push_back(driver); - - int current = _drivers.size()-1; - - _drivers[current]->setMeshName(driverName); - - END_OF_MED(LOC); - - return current; -} - -//================================================================================ -/*! Add an existing MESH driver. */ -//================================================================================ - -int GMESH::addDriver(GENDRIVER & driver) -{ - const char* LOC = "GMESH::addDriver(GENDRIVER &) : "; - BEGIN_OF_MED(LOC); - - // For the case where driver does not know about me since it has been created through - // constructor witout parameters: create newDriver knowing me and get missing data - // from driver using merge() - //GENDRIVER * newDriver = driver.copy() ; - GENDRIVER* newDriver = DRIVERFACTORY::buildDriverForMesh(driver.getDriverType(), - driver.getFileName(), this, - driver.getMeshName(), - driver.getAccessMode()); - _drivers.push_back(newDriver); - - int current = _drivers.size()-1; - driver.setId(current); - - newDriver->merge( driver ); - newDriver->setId( current ); - - return current; - - END_OF_MED(LOC); -} - -//================================================================================ -/*! Remove an existing MESH driver. */ -//================================================================================ - -void GMESH::rmDriver (int index/*=0*/) -{ - const char * LOC = "GMESH::rmDriver (int index=0): "; - BEGIN_OF_MED(LOC); - - if (index >= 0 && index < (int)_drivers.size() && _drivers[index]) - { - delete _drivers[index]; - _drivers[index] = 0; - } - else - throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) - << "The index given is invalid, index must be between 0 and |" - << _drivers.size() - )); - END_OF_MED(LOC); -} - -//================================================================================ -/*! - * \brief Read mesh from the file using given driver - * \param index - index of driver to use for reading - */ -//================================================================================ - -void GMESH::read(int index) -{ - const char * LOC = "GMESH::read(int index=0) : "; - BEGIN_OF_MED(LOC); - - if (index >= 0 && index < (int)_drivers.size() && _drivers[index]) - { - _drivers[index]->open(); - try - { - _drivers[index]->read(); - } - catch ( const MEDEXCEPTION& ex ) - { - _drivers[index]->close(); - throw ex; - } - _drivers[index]->close(); - } - else - throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) - << "The index given is invalid, index must be between 0 and |" - << _drivers.size() - )); - END_OF_MED(LOC); -} - -//================================================================================ -/*! - Reads GMESH using the given driver. -*/ -//================================================================================ - -void GMESH::read(const GENDRIVER & driver) -{ - // For the case where driver does not know about me since it has been created through - // constructor witout parameters: create newDriver knowing me and get missing data - // from driver using merge() - auto_ptr newDriver( DRIVERFACTORY::buildDriverForMesh(driver.getDriverType(), - driver.getFileName(), - this, - driver.getMeshName(), - driver.getAccessMode())); - newDriver->merge( driver ); - - newDriver->open(); - try - { - newDriver->read(); - } - catch ( const MEDEXCEPTION& ex ) - { - newDriver->close(); - throw ex; - } - newDriver->close(); -} - -//================================================================================ -/*! - * \brief Reads the GMESH - * \param driverType - type of driver to use for reading - * \param filename - file to read from - * \param meshname - name of a mesh to read - */ -//================================================================================ - -void GMESH::read(driverTypes driverType, - const std::string& filename, - const std::string& meshname) -{ - auto_ptr newDriver( DRIVERFACTORY::buildDriverForMesh(driverType, filename, - this, meshname, RDONLY)); - newDriver->open(); - try - { - newDriver->read(); - } - catch ( const MEDEXCEPTION& ex ) - { - newDriver->close(); - throw ex; - } - newDriver->close(); -} - -//================================================================================ -/*! Writes all the content of the MESH using driver referenced by the integer handle returned by a \a addDriver call. - - Example : -\verbatim -//... -// Attaching the driver to file "output.med", meshname "Mesh" -int driver_handle = mesh.addDriver(MED_DRIVER, "output.med", "Mesh"); -// Writing the content of mesh to the file -mesh.write(driver_handle); -\endverbatim -*/ -//================================================================================ - -void GMESH::write(int index) const -{ - const char * LOC = "GMESH::write(int index=0) : "; - BEGIN_OF_MED(LOC); - - if ( index > -1 && index < (int)_drivers.size() && _drivers[index] ) - { - _drivers[index]->open(); - try - { - _drivers[index]->write(); - } - catch ( const MEDEXCEPTION& ex ) - { - _drivers[index]->close(); - throw ex; - } - _drivers[index]->close(); - } - else - throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) - << "The index given is invalid, index must be between 0 and |" - << _drivers.size() - )); - END_OF_MED(LOC); -} - -//================================================================================ -/*! - Writes all the content of the GMESH using the given driver. -*/ -//================================================================================ - -void GMESH::write(const GENDRIVER & driver, MED_EN::med_mode_acces medMode/*=MED_EN::WRONLY*/) const -{ - // For the case where driver does not know about me since it has been created through - // constructor witout parameters: create newDriver knowing me and get missing data - // from driver using merge() - auto_ptr newDriver( DRIVERFACTORY::buildDriverForMesh(driver.getDriverType(), - driver.getFileName(), - const_cast( this ), - driver.getMeshName(), - MED_EN::WRONLY)); - newDriver->merge( driver ); -// if ( newDriver->getDriverType() == MED_DRIVER ) -// newDriver->setAccessMode( MED_EN::med_mode_acces( getMedAccessMode( medMode ))); - - newDriver->open(); - try - { - newDriver->write(); - } - catch ( const MEDEXCEPTION& ex ) - { - newDriver->close(); - throw ex; - } - newDriver->close(); -} - -//================================================================================ -/*! - * \brief Writes all the content of the GMESH - * \param driverType - type of driver to use for writing - * \param filename - file to write into - * \param meshname - mesh name - * \param medMode - file access mode - */ -//================================================================================ - -void GMESH::write(driverTypes driverType, - const std::string& filename, - const std::string& meshname, - MED_EN::med_mode_acces medMode/*=MED_EN::WRONLY*/) const -{ - auto_ptr newDriver - ( DRIVERFACTORY::buildDriverForMesh(driverType, filename, - const_cast ( this ), - meshname.empty() ? _name : meshname, - MED_EN::WRONLY)); - -// if ( newDriver->getDriverType() == MED_DRIVER ) -// newDriver->setAccessMode( MED_EN::med_mode_acces( getMedAccessMode( medMode ) )); - - newDriver->open(); - try - { - newDriver->write(); - } - catch ( const MEDEXCEPTION& ex ) - { - newDriver->close(); - throw ex; - } - newDriver->close(); -} -/*! \if MEDMEM_ug @} \endif */ - -/*! \if MEDMEM_ug -\addtogroup MESH_general -@{ -\endif -*/ - -//================================================================================ -/*! - * Sets the MESH name. Name should not exceed MED_TAILLE_NOM - length defined in Med (i.e. 32 characters). -*/ -//================================================================================ - -void GMESH::setName(std::string name) -{ - _name=name; //NOM interne à la classe -} - -//================================================================================ -/*! - *Gets the MESH name. - */ -//================================================================================ - -string GMESH::getName() const -{ - return _name; -} - -//================================================================================ -/*! Set the MESH description */ -/*! \ifnot MEDMEM_ug -Sets the MESH description. Description should not exceed MED_TAILLE_DESC length defined in Med (i.e. 200 characters). -\endif */ -//================================================================================ - -void GMESH::setDescription(std::string description) -{ - _description = description; //NOM interne à la classe -} - -//================================================================================ -/*! Gets the MESH description. The string returned contains - a short description of the mesh, which is stored for - information purposes only.*/ -//================================================================================ - -string GMESH::getDescription() const -{ - return _description; -} - -//================================================================================ -/*! Gets the dimension of the space in which the - mesh is described (2 for planar meshes, 3 for volumes and - 3D surfaces) . */ -//================================================================================ - -int GMESH::getSpaceDimension() const -{ - return _spaceDimension; -} - -/*! \if MEDMEM_ug -The retrieval of general information about a mesh is illustrated in the following C++ example. Its Python equivalent can be found in \a MESHgeneral.py. -This example illustrates how to retrieve the name, description, mesh and space dimensions. - -\example MESHgeneral.cxx -@} -\endif -*/ - -/*! \if MEDMEM_ug -\addtogroup MESH_families -@{ -\endif -*/ -//================================================================================ -/*! - Retrieves the number of families in the mesh for entity type \a entity -*/ -//================================================================================ - -int GMESH::getNumberOfFamilies (MED_EN::medEntityMesh entity) const -{ - switch (entity) { - case MED_EN::MED_NODE : return _familyNode.size(); - case MED_EN::MED_CELL : return _familyCell.size(); - case MED_EN::MED_FACE : return _familyFace.size(); - case MED_EN::MED_EDGE : return _familyEdge.size(); - default : - throw MEDEXCEPTION("MESH::getNumberOfFamilies : Unknown entity"); - } -} -//================================================================================ -/*! Returns the families of type \a entity present in the mesh as a vector of pointers */ -//================================================================================ - -const vector GMESH::getFamilies(MED_EN::medEntityMesh entity) const -{ - switch (entity) { - case MED_EN::MED_NODE : return _familyNode; - case MED_EN::MED_CELL : return _familyCell; - case MED_EN::MED_FACE : return _familyFace; - case MED_EN::MED_EDGE : return _familyEdge; - default : - throw MEDEXCEPTION("MESH::getFamilies : Unknown entity"); - } -} - -//================================================================================ -/*! - * \brief Return a family - * \param entity - entity of the family - * \param i - index of the family - * \retval const MEDMEM::FAMILY* - pointer to the family - */ -//================================================================================ - -const MEDMEM::FAMILY* GMESH::getFamily(MED_EN::medEntityMesh entity, int i) const -{ - if (i<=0) - throw MEDEXCEPTION("MESH::getFamily(i) : argument i must be > 0"); - const vector* Family; - switch (entity) { - case MED_EN::MED_NODE : Family = &_familyNode; break; - case MED_EN::MED_CELL : Family = &_familyCell; break; - case MED_EN::MED_FACE : Family = &_familyFace; break; - case MED_EN::MED_EDGE : Family = &_familyEdge; break; - default : - throw MEDEXCEPTION("MESH::getFamilies : Unknown entity"); - } - if (i>(int)Family->size()) - throw MEDEXCEPTION("MESH::getFamily(entity,i) : argument i must be <= _numberOfFamilies"); - return (*Family)[i-1]; -} - - -//================================================================================ -/*! Retrieves the number of groups in the mesh for entity type \a entity */ -//================================================================================ - -int GMESH::getNumberOfGroups (MED_EN::medEntityMesh entity) const -{ - switch (entity) { - case MED_EN::MED_NODE : return _groupNode.size(); - case MED_EN::MED_CELL : return _groupCell.size(); - case MED_EN::MED_FACE : return _groupFace.size(); - case MED_EN::MED_EDGE : return _groupEdge.size(); - default : - throw MEDEXCEPTION("MESH::getNumberOfGroups : Unknown entity"); - } -} -//================================================================================ -/*! Returns the groups of type \a entity present in the mesh as a vector of pointers. The GROUP class inheriting from the SUPPORT class, the - methods that can be used on these groups are explained in the related section.*/ -//================================================================================ - -const vector GMESH::getGroups(MED_EN::medEntityMesh entity) const -{ - switch (entity) { - case MED_EN::MED_NODE : return _groupNode; - case MED_EN::MED_CELL : return _groupCell; - case MED_EN::MED_FACE : return _groupFace; - case MED_EN::MED_EDGE : return _groupEdge; - default : - throw MEDEXCEPTION("MESH::getGroups : Unknown entity"); - } -} - -//================================================================================ -/*! - * \brief Return a group - * \param entity - entity of the group - * \param i - index of the group - * \retval const GROUP* - pointer to the group - */ -//================================================================================ - -const GROUP* GMESH::getGroup(MED_EN::medEntityMesh entity, int i) const -{ - const char * LOC = "GMESH::getGroup(medEntityMesh entity, int i) : "; - if (i<=0) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"argument i must be > 0")); - const vector* Group = 0; - switch (entity) { - case MED_EN::MED_NODE : Group = &_groupNode; break; - case MED_EN::MED_CELL : Group = &_groupCell; break; - case MED_EN::MED_FACE : Group = &_groupFace; break; - case MED_EN::MED_EDGE : Group = &_groupEdge; break; - default : - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Unknown entity")); - } - if (i>(int)Group->size()) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"argument i="<size())); - return (*Group)[i-1]; -} - -//================================================================================ -/*! Retrieves the group named \a name. - The method browses all the entities in order to find the group. - If two groups with the same name coexist, the first one found will be - returned. If no group with the correct name is found, the method throws - an exception. -*/ -//================================================================================ - -const GROUP* GMESH::getGroup(const string& name) const throw (MEDEXCEPTION) -{ - const vector* group_vectors [4]={&_groupNode, &_groupEdge,&_groupFace,&_groupCell}; - for (int ientity=0;ientity<4;ientity++) - for (unsigned igroup=0; igroup< group_vectors[ientity]->size();igroup++) - { - const vector& group_vect = *group_vectors[ientity]; - GROUP* group=group_vect[igroup]; - if (group->getName()==name) - return group; - } - cerr << "MESH::getGroup("<::const_iterator it = _entitySupport.find(entity); - - // find support and return is if exists - if(it != _entitySupport.end()) - return (*it).second; - else - { - //build, store and return support - GMESH* thisMesh = const_cast< GMESH* >( this ); - SUPPORT * aSupport = new SUPPORT; - string aSuppName = "SupportOnAll_"+entNames[entity]; - aSupport->setName( aSuppName ); - aSupport->setMesh( thisMesh ); - aSupport->setEntity( entity ); - aSupport->setAll( true ); - aSupport->update(); - - thisMesh->_entitySupport.insert(make_pair(entity,aSupport)); - thisMesh->removeReference(); - - return aSupport; - } -} - -/*! \if MEDMEM_ug @} \endif */ - -/*! \if MEDMEM_ug -\addtogroup MESH_advanced -@{ -\endif -*/ -//================================================================================ -/*! - Return a SUPPORT pointer on the union of all SUPPORTs in Supports. - You should delete this pointer after use to avoid memory leaks. -*/ -//================================================================================ - -SUPPORT * GMESH::mergeSupports(const std::vector Supports) throw (MEDEXCEPTION) -{ - const char * LOC = "GMESH::mergeSupports(const vector ) : " ; - BEGIN_OF_MED(LOC) ; - - SUPPORT * returnedSupport; - string returnedSupportName; - string returnedSupportDescription; - char * returnedSupportNameChar; - char * returnedSupportDescriptionChar; - int size = Supports.size(); - - if (size == 0) - throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << - " mergeSupports() does't accept zero size vector")); - - if (size == 1) - { - MESSAGE_MED(LOC <<" there is only one SUPPORT in the argument list, the method return a copy of this object !"); - SUPPORT * obj = const_cast (Supports[0]); - - returnedSupport = new SUPPORT(*obj); - - int lenName = strlen((Supports[0]->getName()).c_str()) + 8 + 1; - int lenDescription = strlen((Supports[0]->getDescription()).c_str()) + 8 + 1; - - returnedSupportNameChar = new char[lenName]; - returnedSupportDescriptionChar = new char[lenDescription]; - - returnedSupportNameChar = strcpy(returnedSupportNameChar,"Copy of "); - returnedSupportNameChar = strcat(returnedSupportNameChar,(Supports[0]->getName()).c_str()); - returnedSupportDescriptionChar = strcpy(returnedSupportDescriptionChar,"Copy of "); - returnedSupportDescriptionChar = strcat(returnedSupportDescriptionChar, - (Supports[0]->getDescription()).c_str()); - - returnedSupportName = string(returnedSupportNameChar); - returnedSupportDescription = string(returnedSupportDescriptionChar); - - returnedSupport->setName(returnedSupportName); - returnedSupport->setDescription(returnedSupportDescription); - - delete [] returnedSupportNameChar; - delete [] returnedSupportDescriptionChar; - } - else - { - SUPPORT * obj = const_cast (Supports[0]); - returnedSupport = new SUPPORT(*obj); - - int lenName = strlen((Supports[0]->getName()).c_str()) + 9 + 1; - int lenDescription = strlen((Supports[0]->getDescription()).c_str()) + 9 + 1; - - for(int i = 1;i (Supports[i]); - returnedSupport->blending(obj); - - if (i == (size-1)) - { - lenName = lenName + 5 + strlen((Supports[i]->getName()).c_str()); - lenDescription = lenDescription + 5 + - strlen((Supports[i]->getDescription()).c_str()); - } - else - { - lenName = lenName + 2 + strlen((Supports[i]->getName()).c_str()); - lenDescription = lenDescription + 2 + - strlen((Supports[i]->getDescription()).c_str()); - } - } - - returnedSupportNameChar = new char[lenName]; - returnedSupportDescriptionChar = new char[lenDescription]; - - returnedSupportNameChar = strcpy(returnedSupportNameChar,"Merge of "); - returnedSupportDescriptionChar = strcpy(returnedSupportDescriptionChar,"Merge of "); - - returnedSupportNameChar = strcat(returnedSupportNameChar,(Supports[0]->getName()).c_str()); - returnedSupportDescriptionChar = strcat(returnedSupportDescriptionChar, - (Supports[0]->getDescription()).c_str()); - - for(int i = 1;igetName()).c_str()); - returnedSupportDescriptionChar = strcat(returnedSupportDescriptionChar, - (Supports[i]->getDescription()).c_str()); - } - else - { - returnedSupportNameChar = strcat(returnedSupportNameChar,", "); - returnedSupportNameChar = strcat(returnedSupportNameChar, - (Supports[i]->getName()).c_str()); - - returnedSupportDescriptionChar = strcat(returnedSupportDescriptionChar,", "); - returnedSupportDescriptionChar = strcat(returnedSupportDescriptionChar, - (Supports[i]->getDescription()).c_str()); - } - } - - returnedSupportName = string(returnedSupportNameChar); - returnedSupport->setName(returnedSupportName); - - returnedSupportDescription = string(returnedSupportDescriptionChar); - returnedSupport->setDescription(returnedSupportDescription); - - delete [] returnedSupportNameChar; - delete [] returnedSupportDescriptionChar; - } - - END_OF_MED(LOC); - return returnedSupport; -} - -//================================================================================ -/*! - return a SUPPORT pointer on the intersection of all SUPPORTs in Supports. - The (SUPPORT *) NULL pointer is returned if the intersection is empty. - You should delete this pointer after use to avois memory leaks. -*/ -//================================================================================ - -SUPPORT * GMESH::intersectSupports(const std::vector Supports) throw (MEDEXCEPTION) -{ - const char* LOC = "MESH:::intersectSupports(const vector ) : "; - BEGIN_OF_MED(LOC); - - SUPPORT * returnedSupport; - string returnedSupportName; - string returnedSupportDescription; - char * returnedSupportNameChar; - char * returnedSupportDescriptionChar; - int size = Supports.size(); - - if (size == 1) - { - MESSAGE_MED(PREFIX_MED <<" there is only one SUPPORT in the argument list, the method return a copy of this object !"); - SUPPORT * obj = const_cast (Supports[0]); - - returnedSupport = new SUPPORT(*obj); - - int lenName = strlen((Supports[0]->getName()).c_str()) + 8 + 1; - int lenDescription = strlen((Supports[0]->getDescription()).c_str()) + 8 + 1; - - returnedSupportNameChar = new char[lenName]; - returnedSupportDescriptionChar = new char[lenDescription]; - - returnedSupportNameChar = strcpy(returnedSupportNameChar,"Copy of "); - returnedSupportNameChar = strcat(returnedSupportNameChar,(Supports[0]->getName()).c_str()); - returnedSupportDescriptionChar = strcpy(returnedSupportDescriptionChar,"Copy of "); - returnedSupportDescriptionChar = strcat(returnedSupportDescriptionChar, - (Supports[0]->getDescription()).c_str()); - - returnedSupportName = string(returnedSupportNameChar); - returnedSupportDescription = string(returnedSupportDescriptionChar); - - returnedSupport->setName(returnedSupportName); - returnedSupport->setDescription(returnedSupportDescription); - - delete [] returnedSupportNameChar; - delete [] returnedSupportDescriptionChar; - } - else - { - SUPPORT * obj = const_cast (Supports[0]); - returnedSupport = new SUPPORT(*obj); - - int lenName = strlen((Supports[0]->getName()).c_str()) + 16 + 1; - int lenDescription = strlen((Supports[0]->getDescription()).c_str()) + 16 + 1; - - for(int i = 1;i (Supports[i]); - returnedSupport->intersecting(obj); - - if (i == (size-1)) - { - lenName = lenName + 5 + strlen((Supports[i]->getName()).c_str()); - lenDescription = lenDescription + 5 + - strlen((Supports[i]->getDescription()).c_str()); - } - else - { - lenName = lenName + 2 + strlen((Supports[i]->getName()).c_str()); - lenDescription = lenDescription + 2 + - strlen((Supports[i]->getDescription()).c_str()); - } - } - if(returnedSupport != (SUPPORT *) NULL) - { - returnedSupportNameChar = new char[lenName]; - returnedSupportDescriptionChar = new char[lenDescription]; - - returnedSupportNameChar = strcpy(returnedSupportNameChar, - "Intersection of "); - returnedSupportDescriptionChar = - strcpy(returnedSupportDescriptionChar,"Intersection of "); - - returnedSupportNameChar = strcat(returnedSupportNameChar, - (Supports[0]->getName()).c_str()); - returnedSupportDescriptionChar = - strcat(returnedSupportDescriptionChar, - (Supports[0]->getDescription()).c_str()); - - for(int i = 1;igetName()).c_str()); - returnedSupportDescriptionChar = - strcat(returnedSupportDescriptionChar, - (Supports[i]->getDescription()).c_str()); - } - else - { - returnedSupportNameChar = strcat(returnedSupportNameChar, - ", "); - returnedSupportNameChar = - strcat(returnedSupportNameChar, - (Supports[i]->getName()).c_str()); - - returnedSupportDescriptionChar = - strcat(returnedSupportDescriptionChar,", "); - returnedSupportDescriptionChar = - strcat(returnedSupportDescriptionChar, - (Supports[i]->getDescription()).c_str()); - } - } - - returnedSupportName = string(returnedSupportNameChar); - returnedSupport->setName(returnedSupportName); - - returnedSupportDescription = string(returnedSupportDescriptionChar); - returnedSupport->setDescription(returnedSupportDescription); - - delete [] returnedSupportNameChar; - delete [] returnedSupportDescriptionChar; - } - } - - END_OF_MED(LOC); - return returnedSupport; -} - -/*! \if MEDMEM_ug - @} -\endif -*/ -/*! - Method created to factorize code. This method creates a new support on entity 'entity' (to deallocate) containing all the entities contained in - elements 'listOfElt' of entity 'entity'. -*/ -SUPPORT * GMESH::buildSupportOnElementsFromElementList(const list& listOfElt, MED_EN::medEntityMesh entity) const throw (MEDEXCEPTION) -{ - const char* LOC = "GMESH::buildSupportOnElementsFromElementList : "; - BEGIN_OF_MED(LOC); - SUPPORT * mySupport = new SUPPORT(); - mySupport->setMesh((MESH *)this); - mySupport->setName("Boundary"); - mySupport->setEntity( entity ); - mySupport->fillFromElementList(listOfElt); - END_OF_MED(LOC); - return mySupport ; -} - -// internal helper type -struct _cell -{ - std::vector groups; - MED_EN::medGeometryElement geometricType; - // to have geometricType good for nodal groups when MESH::getNumberOfTypes(MED_NODE)==0 - _cell():geometricType(MED_POINT1) {} -}; - -//================================================================================ -/*! - * Create families from groups. - * This function is automaticaly called whenever we ask for families that are not up-to-date. - * (The creation of families is delayed to the need of user.) - * If a new created family hapen to already exist, we keep the old one. - * (There is no way to know which family has change.) - */ -//================================================================================ - -void GMESH::createFamilies() -{ - int idFamNode = 0; // identifier for node families - int idFamElement = 0; // identifier for cell, face or edge families - - // Main loop on mesh's entities - for (medEntityMesh entity=MED_CELL; entity!=MED_ALL_ENTITIES; ++entity) - { - int numberofgroups = getNumberOfGroups(entity); - if(!numberofgroups) - continue; // no groups for this entity - - vector< vector > whichFamilyInGroup(numberofgroups); // this container is used to update groups at the end - - // make myFamilies points to the member corresponding to entity - vector* myFamilies; - switch ( entity ) - { - case MED_CELL : myFamilies = & _familyCell; break; - case MED_FACE : myFamilies = & _familyFace; break; - case MED_EDGE : myFamilies = & _familyEdge; break; - case MED_NODE : myFamilies = & _familyNode; break; - } - - vector myGroups=getGroups(entity); // get a copy of the groups ptr for the entity - // get a copy of the (old) family ptrs before clearing - vector myOldFamilies=getFamilies(entity); - myFamilies->clear(); - - - // 1 - Create a vector containing for each cell (of the entity) an information structure - // giving geometric type and the groups it belong to - - med_int numberOfTypes=0; - const medGeometryElement* geometricTypes = 0; - if ( entity != MED_NODE) - { - numberOfTypes = getNumberOfTypes(entity); - geometricTypes = getTypes(entity); - } - med_int numberOfCells=getNumberOfElements(entity, MED_ALL_ELEMENTS); // total number of cells for that entity - SCRUTE_MED(numberOfTypes); - SCRUTE_MED(numberOfCells); - vector< _cell > tab_cell(numberOfCells); - vector< _cell >::iterator cell = tab_cell.begin(); - for(med_int t=0; t!=numberOfTypes; ++t) - { - int nbCellsOfType = getNumberOfElements(entity,geometricTypes[t]); - for(int n=0; n!=nbCellsOfType; ++n, ++cell) - cell->geometricType=geometricTypes[t]; - } - - // 2 - Scan cells in groups and update in tab_cell the container of groups a cell belong to - - for (unsigned g=0; g!=myGroups.size(); ++g) - { - // scan cells that belongs to the group - const int* groupCells=myGroups[g]->getnumber()->getValue(); - int nbCells=myGroups[g]->getnumber()->getLength(); - for(int c=0; c!=nbCells; ++c) - tab_cell[groupCells[c]-1].groups.push_back(g); - } - - - // 3 - Scan the cells vector, genarate family name, and create a map associating the family names - // whith the vector of contained cells - - map< string,vector > tab_families; - map< string,vector >::iterator fam; - for(int n=0; n!=numberOfCells; ++n) - { - ostringstream key; // to generate the name of the family - key << "FAM"; - if(tab_cell[n].groups.empty()) // this cell don't belong to any group - key << "_NONE" << entity; - - for(vector::const_iterator it=tab_cell[n].groups.begin(); it!=tab_cell[n].groups.end(); ++it) - { - string groupName=myGroups[*it]->getName(); - if(groupName.empty()) - key << "_G" << *it; - else - key << "_" << groupName; - } - - tab_families[key.str()].push_back(n+1); // fill the vector of contained cells associated whith the family - } - - - // 4 - Scan the family map, create MED Families, check if it already exist. - - for( fam=tab_families.begin(); fam!=tab_families.end(); ++fam) - { - vector tab_types_geometriques; - medGeometryElement geometrictype=MED_NONE; - vector tab_index_types_geometriques; - vector tab_nombres_elements; - if ( fam->second.empty() ) - continue; // it is just a truncated long family name - - // scan family cells and fill the tab that are needed by the create a MED FAMILY - for( unsigned i=0; i!=fam->second.size(); ++i) - { - int ncell=fam->second[i]-1; - if(tab_cell[ncell].geometricType != geometrictype) - { - // new geometric type -> we store it and complete index tabs - if(!tab_index_types_geometriques.empty()) - tab_nombres_elements.push_back(i+1-tab_index_types_geometriques.back()); - tab_types_geometriques.push_back( (geometrictype=tab_cell[ncell].geometricType)); - tab_index_types_geometriques.push_back(i+1); - } - } - // store and complete index tabs for the last geometric type - tab_nombres_elements.push_back(fam->second.size()+1-tab_index_types_geometriques.back()); - tab_index_types_geometriques.push_back(fam->second.size()+1); - - // family name sould not be longer than MED_TAILLE_NOM - string famName = fam->first; - if ( famName.size() > MED_NAME_SIZE ) { - // try to cut off "FAM_" from the head - if ( famName.size() - 4 <= MED_NAME_SIZE ) { - famName = famName.substr(4); - } - else { // try to make a unique name by cutting off char by char from the tail - famName = famName.substr(0, MED_NAME_SIZE); - map< string,vector >::iterator foundName = tab_families.find( famName ); - while ( !famName.empty() && - ( foundName != tab_families.end() || famName[ famName.size()-1 ] == ' ' )) - { - famName = famName.substr( 0, famName.size() - 1 ); - foundName = tab_families.find( famName ); - } - } - tab_families[ famName ]; // add a new name in the table to assure uniqueness - } - - // create a MED FAMILY and fill it with the tabs we constructed - FAMILY* newFam = new FAMILY(); - newFam->setName(famName); - newFam->setMesh(this); - removeReference(); - newFam->setNumberOfGeometricType(tab_types_geometriques.size()); - newFam->setGeometricType(&tab_types_geometriques[0]); // we know the tab is not empy - newFam->setNumberOfElements(&tab_nombres_elements[0]); - newFam->setNumber(&tab_index_types_geometriques[0],&fam->second[0]); - newFam->setEntity(entity); - newFam->setAll( getNumberOfElements( entity, MED_ALL_ELEMENTS ) == fam->second.size() ); - - int idFam = 0; - - switch ( entity ) - { - case MED_NODE : - ++idFamNode; - idFam = idFamNode; - break; - case MED_CELL : - case MED_FACE : - case MED_EDGE : - ++idFamElement; - idFam = -idFamElement; - break; - } - - newFam->setIdentifier(idFam); - - // Update links between families and groups - - int ncell1=fam->second[0]-1; // number of first cell in family - int numberOfGroups=tab_cell[ncell1].groups.size(); // number of groups in the family - if(numberOfGroups) - { - newFam->setNumberOfGroups(numberOfGroups); - string * groupNames=new string[numberOfGroups]; - - // iterate on the groups the family belongs to - vector::const_iterator it=tab_cell[ncell1].groups.begin(); - for(int ng=0 ; it!=tab_cell[ncell1].groups.end(); ++it, ++ng) - { - whichFamilyInGroup[*it].push_back(newFam); - groupNames[ng]=myGroups[*it]->getName(); - } - newFam->setGroupsNames(groupNames); - delete [] groupNames; - } - - MESSAGE_MED(" MESH::createFamilies() entity " << entity << - " size " << myFamilies->size()); - - myFamilies->push_back(newFam); - } - - // delete old families - for (unsigned int i=0;iremoveReference(); - - // update references in groups - for (unsigned int i=0;isetNumberOfFamilies(whichFamilyInGroup[i].size()); - myGroups[i]->setFamilies(whichFamilyInGroup[i]); - } - - // re-scan the cells vector, and fill the family vector with cells. - // creation of support, check if it already exist. - } -} - -//================================================================================ -/*! - Create groups from families. - - It is used to create groups that have only one family - for meshes that come from codes that use families instead - of groups to define a subregion. -*/ -//================================================================================ - -void GMESH::createGroups() -{ - for (medEntityMesh entity=MED_CELL; entity!=MED_ALL_ENTITIES; ++entity) - { - // make myFamilies points to the member corresponding to entity - vector* myFamilies; - vector* myGroups; - switch ( entity ) - { - case MED_CELL : - myFamilies = & _familyCell; - myGroups = & _groupCell; - break; - case MED_FACE : - myFamilies = & _familyFace; - myGroups = & _groupFace; - break; - case MED_EDGE : - myFamilies = & _familyEdge; - myGroups = & _groupEdge; - break; - case MED_NODE : - myFamilies = & _familyNode; - myGroups = & _groupNode; - break; - } - - - for (unsigned i=0; i< myFamilies->size(); i++) - { - list fam_list; - fam_list.push_back((*myFamilies)[i]); - //creates a group with the family name and only one family - GROUP* group=new GROUP((*myFamilies)[i]->getName(),fam_list); - (*myGroups).push_back(group); - removeReference(); - } - } -} diff --git a/src/MEDMEM/MEDMEM_GMesh.hxx b/src/MEDMEM/MEDMEM_GMesh.hxx deleted file mode 100644 index ececc75ba..000000000 --- a/src/MEDMEM/MEDMEM_GMesh.hxx +++ /dev/null @@ -1,277 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// File : MEDMEM_GMesh.hxx -// Created : Fri Jul 23 10:17:08 2010 -// Author : Edward AGAPOV (eap) -// - -#ifndef __MEDMEM_GMesh_HXX__ -#define __MEDMEM_GMesh_HXX__ - -#include "MEDMEM.hxx" -#include "MEDMEM_define.hxx" -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_RCBase.hxx" -#include "MEDMEM_GenDriver.hxx" -#include "MEDMEM_FieldForward.hxx" -#include "MEDMEM_Support.hxx" - -#include - -namespace MEDMEM { - -class FAMILY; -class GROUP; -class SUPPORT; -class GMESH; -class MESH; - -MEDMEM_EXPORT std::ostream & operator<<(std::ostream &os, const GMESH &me); - -/*! - * \brief Base class of structured and unstructured meshes - */ -class MEDMEM_EXPORT GMESH: public RCBASE -{ - protected: - - std::string _name; - std::string _description; - int _spaceDimension; - - std::vector _familyNode; - std::vector _familyCell; - std::vector _familyFace; - std::vector _familyEdge; - - std::vector _groupNode; - std::vector _groupCell; - std::vector _groupFace; - std::vector _groupEdge; - - std::vector _drivers; // Storage of the drivers currently in use - - std::map _entitySupport; - - virtual bool isEmpty() const = 0; - - // Add your personnal driver line (step 2) - friend class MED_MESH_RDONLY_DRIVER; - friend class MED_MESH_WRONLY_DRIVER; - - friend class GIBI_MESH_RDONLY_DRIVER; - friend class GIBI_MESH_WRONLY_DRIVER; - friend class GIBI_MESH_RDWR_DRIVER; - - friend class PORFLOW_MESH_RDONLY_DRIVER; - friend class PORFLOW_MESH_WRONLY_DRIVER; - friend class PORFLOW_MESH_RDWR_DRIVER; - - friend class VTK_MESH_DRIVER; - - friend class ENSIGHT_MESH_RDONLY_DRIVER; - - public: - - GMESH(); - GMESH(GMESH &m); - virtual ~GMESH(); - - virtual void init(); - GMESH & operator=(const GMESH &m); - virtual bool operator==(const GMESH& other) const; - virtual bool deepCompare(const GMESH& other) const = 0; - - friend std::ostream & operator<<(std::ostream &os, const GMESH &me); - virtual void printMySelf(std::ostream &os) const = 0; - - int addDriver(driverTypes driverType, - const std::string & fileName ="Default File Name.med", - const std::string & driverName="Default Mesh Name", - MED_EN::med_mode_acces access=MED_EN::RDWR); - int addDriver(GENDRIVER & driver); - void rmDriver(int index=0); - - virtual void read(int index=0); - virtual void read(const GENDRIVER & genDriver); - virtual void read(driverTypes driverType, - const std::string& filename, - const std::string& meshname); - - virtual void write(int index=0) const ; - virtual void write(const GENDRIVER & genDriver, - MED_EN::med_mode_acces medMode=MED_EN::WRONLY) const; - virtual void write(driverTypes driverType, - const std::string& filename, - const std::string& meshname="", - MED_EN::med_mode_acces medMode=MED_EN::WRONLY) const; - - void setName(std::string name); - std::string getName() const; - - void setDescription(std::string description); - std::string getDescription() const; - - int getSpaceDimension() const; - virtual int getMeshDimension() const = 0; - - virtual bool getIsAGrid() const = 0; - - virtual std::string getCoordinatesSystem() const = 0; - virtual const std::string * getCoordinatesNames() const = 0; - virtual const std::string * getCoordinatesUnits() const = 0; - - virtual int getNumberOfNodes() const = 0; - virtual int getNumberOfTypes(MED_EN::medEntityMesh Entity) const = 0; - virtual int getNumberOfElements(MED_EN::medEntityMesh Entity, - MED_EN::medGeometryElement Type) const = 0; - virtual const MED_EN::medGeometryElement * getTypes(MED_EN::medEntityMesh Entity) const = 0; - virtual MED_EN::medGeometryElement getElementType(MED_EN::medEntityMesh Entity, - int Number) const = 0; - - - virtual int getNumberOfFamilies(MED_EN::medEntityMesh Entity) const; - virtual const std::vector getFamilies(MED_EN::medEntityMesh Entity) const; - virtual const FAMILY* getFamily(MED_EN::medEntityMesh Entity,int i) const; - - virtual int getNumberOfGroups(MED_EN::medEntityMesh Entity) const; - virtual const std::vector getGroups(MED_EN::medEntityMesh Entity) const; - virtual const GROUP* getGroup(MED_EN::medEntityMesh Entity,int i) const; - virtual const GROUP* getGroup(const std::string& name) const throw (MEDEXCEPTION); - - /*! - * \brief Return unstructured mesh. Call removeReference() after having finished using it!!! - */ - virtual const MESH * convertInMESH() const = 0; - - - virtual SUPPORT * getBoundaryElements(MED_EN::medEntityMesh Entity) const - throw (MEDEXCEPTION) = 0; - virtual SUPPORT * getSkin(const SUPPORT * Support3D) - throw (MEDEXCEPTION) = 0; - - virtual const SUPPORT * getSupportOnAll(MED_EN::medEntityMesh Entity) const - throw (MEDEXCEPTION); - - static SUPPORT * mergeSupports(const std::vector Supports) - throw (MEDEXCEPTION) ; - static SUPPORT * intersectSupports(const std::vector Supports) - throw (MEDEXCEPTION) ; - - virtual SUPPORT *buildSupportOnNodeFromElementList(const std::list& listOfElt, MED_EN::medEntityMesh entity) const throw (MEDEXCEPTION) = 0; - virtual void fillSupportOnNodeFromElementList(const std::list& listOfElt, SUPPORT *supportToFill) const throw (MEDEXCEPTION) = 0; - virtual SUPPORT *buildSupportOnElementsFromElementList(const std::list& listOfElt, MED_EN::medEntityMesh entity) const throw (MEDEXCEPTION); - - - virtual FIELD* getVolume (const SUPPORT * Support, bool isAbs = true) const - throw (MEDEXCEPTION) = 0; - // Support must be on 3D elements - virtual FIELD* getArea (const SUPPORT * Support) const - throw (MEDEXCEPTION) = 0; - // Support must be on 2D elements - virtual FIELD* getLength (const SUPPORT * Support) const - throw (MEDEXCEPTION) = 0; - // Support must be on 1D elements - virtual FIELD* getNormal (const SUPPORT * Support) const - throw (MEDEXCEPTION) = 0; - // Support must be on 2D elements - virtual FIELD* getBarycenter (const SUPPORT * Support) const - throw (MEDEXCEPTION) = 0; - - virtual vector< vector > getBoundingBox() const = 0; - - template static FIELD* mergeFields(const std::vector< FIELD * > & others, - bool meshCompare=false); - - void createFamilies(); - void createGroups(); -}; - -// ================================================================================================ -//Create a new FIELD that should be deallocated based on a SUPPORT that should be deallocated too. -// ================================================================================================ -template -FIELD * GMESH::mergeFields(const std::vector< FIELD * > & others, bool meshCompare) -{ - const char * LOC = "MESH::mergeFields(const vector< FIELD* >& others,bool meshCompare): "; - BEGIN_OF_MED(LOC); - int i,j; - if(others.size()==0) - return 0; - std::vector sup; - typename std::vector< FIELD* >::const_iterator iter; - iter = others.begin(); - MED_EN::med_type_champ valueType = (*iter)->getValueType(); - for(iter=others.begin();iter!=others.end();iter++) - { - MED_EN::med_type_champ valueTypeIter = (*iter)->getValueType(); - if (valueTypeIter != valueType) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Fields vector have not the same value type")); - - sup.push_back((SUPPORT *)(*iter)->getSupport()); - } - iter=others.begin(); - SUPPORT *retSup=mergeSupports(sup); - int retNumberOfComponents=(*iter)->getNumberOfComponents(); - FIELD *ret=new FIELD(retSup, retNumberOfComponents); - T* valuesToSet=(T*)ret->getValue(); - int nbOfEltsRetSup=retSup->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS); - T* tempValues=new T[retNumberOfComponents]; - if(retSup->isOnAllElements()) - { - for(i=0;igetValueOnElement(i+1,tempValues); - if(found) - for(j=0;jgetNumber(MED_EN::MED_ALL_ELEMENTS); - for(i=0;igetValueOnElement(eltsRetSup[i],tempValues); - if(found) - for(j=0;jremoveReference(); - delete [] tempValues; - END_OF_MED(LOC); - return ret; -} -} -#endif diff --git a/src/MEDMEM/MEDMEM_GaussLocalization.cxx b/src/MEDMEM/MEDMEM_GaussLocalization.cxx deleted file mode 100644 index b28ebd8b7..000000000 --- a/src/MEDMEM/MEDMEM_GaussLocalization.cxx +++ /dev/null @@ -1,1249 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : MEDMEM_GaussLocalization.cxx -// Created : Thu Dec 20 12:26:33 2007 -// Author : Edward AGAPOV (eap) -// -#include "MEDMEM_GaussLocalization.hxx" - -#include -#include - -#define EXCEPTION(type,msg) \ - MEDEXCEPTION(LOCALIZED(MEDMEM::STRING(#type)<< msg)) - -namespace // matters used by GAUSS_LOCALIZATION_::makeDefaultLocalization() -{ - typedef std::vector TDoubleVector; - typedef double* TCoordSlice; - typedef int TInt; - //--------------------------------------------------------------- - //! Shape function definitions - //--------------------------------------------------------------- - struct TShapeFun - { - TInt myDim; - TInt myNbRef; - TDoubleVector myRefCoord; - - TShapeFun(TInt theDim = 0, TInt theNbRef = 0) - :myDim(theDim),myNbRef(theNbRef),myRefCoord(theNbRef*theDim) {} - - TInt GetNbRef() const { return myNbRef; } - - TCoordSlice GetCoord(TInt theRefId) { return &myRefCoord[0] + theRefId * myDim; } - }; - //--------------------------------------------------------------- - /*! - * \brief Description of family of integration points - */ - //--------------------------------------------------------------- - struct TGaussDef - { - int myType; //!< element geometry (EGeometrieElement or med_geometrie_element) - TDoubleVector myRefCoords; //!< description of reference points - TDoubleVector myCoords; //!< coordinates of Gauss points - TDoubleVector myWeights; //!< weights, len(weights)== - - /*! - * \brief Creates definition of gauss points family - * \param geomType - element geometry (EGeometrieElement or med_geometrie_element) - * \param nbPoints - nb gauss point - * \param variant - [1-3] to choose the variant of definition - * - * Throws in case of invalid parameters - * variant == 1 refers to "Fonctions de forme et points d'integration - * des elements finis" v7.4 by J. PELLET, X. DESROCHES, 15/09/05 - * variant == 2 refers to the same doc v6.4 by J.P. LEFEBVRE, X. DESROCHES, 03/07/03 - * variant == 3 refers to the same doc v6.4, second variant for 2D elements - */ - TGaussDef(const int geomType, const int nbPoints, const int variant=1); - - int dim() const { return myType/100; } - int nbPoints() const { return myWeights.capacity(); } - - private: - void add(const double x, const double weight); - void add(const double x, const double y, const double weight); - void add(const double x, const double y, const double z, const double weight); - void setRefCoords(const TShapeFun& aShapeFun) { myRefCoords = aShapeFun.myRefCoord; } - }; - struct TSeg2a: TShapeFun { - TSeg2a(); - }; - struct TSeg3a: TShapeFun { - TSeg3a(); - }; - struct TTria3a: TShapeFun { - TTria3a(); - }; - struct TTria6a: TShapeFun { - TTria6a(); - }; - struct TTria3b: TShapeFun { - TTria3b(); - }; - struct TTria6b: TShapeFun { - TTria6b(); - }; - struct TQuad4a: TShapeFun { - TQuad4a(); - }; - struct TQuad8a: TShapeFun { - TQuad8a(); - }; - struct TQuad4b: TShapeFun { - TQuad4b(); - }; - struct TQuad8b: TShapeFun { - TQuad8b(); - }; - struct TTetra4a: TShapeFun { - TTetra4a(); - }; - struct TTetra10a: TShapeFun { - TTetra10a(); - }; - struct TTetra4b: TShapeFun { - TTetra4b(); - }; - struct TTetra10b: TShapeFun { - TTetra10b(); - }; - struct THexa8a: TShapeFun { - THexa8a(); - }; - struct THexa20a: TShapeFun { - THexa20a(TInt theDim = 3, TInt theNbRef = 20); - }; - struct THexa27a: THexa20a { - THexa27a(); - }; - struct THexa8b: TShapeFun { - THexa8b(); - }; - struct THexa20b: TShapeFun { - THexa20b(TInt theDim = 3, TInt theNbRef = 20); - }; - struct TPenta6a: TShapeFun { - TPenta6a(); - }; - struct TPenta6b: TShapeFun { - TPenta6b(); - }; - struct TPenta15a: TShapeFun { - TPenta15a(); - }; - struct TPenta15b: TShapeFun { - TPenta15b(); - }; - struct TPyra5a: TShapeFun { - TPyra5a(); - }; - struct TPyra5b: TShapeFun { - TPyra5b(); - }; - struct TPyra13a: TShapeFun { - TPyra13a(); - }; - struct TPyra13b: TShapeFun { - TPyra13b(); - }; - - void TGaussDef::add(const double x, const double weight) - { - if ( dim() != 1 ) - EXCEPTION( logic_error,"dim() != 1"); - if ( myWeights.capacity() == myWeights.size() ) - EXCEPTION( logic_error,"Extra gauss point"); - myCoords.push_back( x ); - myWeights.push_back( weight ); - } - void TGaussDef::add(const double x, const double y, const double weight) - { - if ( dim() != 2 ) - EXCEPTION( logic_error,"dim() != 2"); - if ( myWeights.capacity() == myWeights.size() ) - EXCEPTION( logic_error,"Extra gauss point"); - myCoords.push_back( x ); - myCoords.push_back( y ); - myWeights.push_back( weight ); - } - void TGaussDef::add(const double x, const double y, const double z, const double weight) - { - if ( dim() != 3 ) - EXCEPTION( logic_error,"dim() != 3"); - if ( myWeights.capacity() == myWeights.size() ) - EXCEPTION( logic_error,"Extra gauss point"); - myCoords.push_back( x ); - myCoords.push_back( y ); - myCoords.push_back( z ); - myWeights.push_back( weight ); - } - - //--------------------------------------------------------------- - TSeg2a::TSeg2a():TShapeFun(1,2) - { - TInt aNbRef = GetNbRef(); - for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ - TCoordSlice aCoord = GetCoord(aRefId); - switch(aRefId){ - case 0: aCoord[0] = -1.0; break; - case 1: aCoord[0] = 1.0; break; - } - } - } - //--------------------------------------------------------------- - TSeg3a::TSeg3a():TShapeFun(1,3) - { - TInt aNbRef = GetNbRef(); - for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ - TCoordSlice aCoord = GetCoord(aRefId); - switch(aRefId){ - case 0: aCoord[0] = -1.0; break; - case 1: aCoord[0] = 1.0; break; - case 2: aCoord[0] = 0.0; break; - } - } - } - //--------------------------------------------------------------- - TTria3a::TTria3a(): - TShapeFun(2,3) - { - TInt aNbRef = GetNbRef(); - for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ - TCoordSlice aCoord = GetCoord(aRefId); - switch(aRefId){ - case 0: aCoord[0] = -1.0; aCoord[1] = 1.0; break; - case 1: aCoord[0] = -1.0; aCoord[1] = -1.0; break; - case 2: aCoord[0] = 1.0; aCoord[1] = -1.0; break; - } - } - } - //--------------------------------------------------------------- - TTria6a::TTria6a():TShapeFun(2,6) - { - TInt aNbRef = GetNbRef(); - for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ - TCoordSlice aCoord = GetCoord(aRefId); - switch(aRefId){ - case 0: aCoord[0] = -1.0; aCoord[1] = 1.0; break; - case 1: aCoord[0] = -1.0; aCoord[1] = -1.0; break; - case 2: aCoord[0] = 1.0; aCoord[1] = -1.0; break; - - case 3: aCoord[0] = -1.0; aCoord[1] = 1.0; break; - case 4: aCoord[0] = 0.0; aCoord[1] = -1.0; break; - case 5: aCoord[0] = 0.0; aCoord[1] = 0.0; break; - } - } - } - //--------------------------------------------------------------- - TTria3b::TTria3b(): - TShapeFun(2,3) - { - TInt aNbRef = GetNbRef(); - for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ - TCoordSlice aCoord = GetCoord(aRefId); - switch(aRefId){ - case 0: aCoord[0] = 0.0; aCoord[1] = 0.0; break; - case 1: aCoord[0] = 1.0; aCoord[1] = 0.0; break; - case 2: aCoord[0] = 0.0; aCoord[1] = 1.0; break; - } - } - } - //--------------------------------------------------------------- - TTria6b::TTria6b(): - TShapeFun(2,6) - { - TInt aNbRef = GetNbRef(); - for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ - TCoordSlice aCoord = GetCoord(aRefId); - switch(aRefId){ - case 0: aCoord[0] = 0.0; aCoord[1] = 0.0; break; - case 1: aCoord[0] = 1.0; aCoord[1] = 0.0; break; - case 2: aCoord[0] = 0.0; aCoord[1] = 1.0; break; - - case 3: aCoord[0] = 0.5; aCoord[1] = 0.0; break; - case 4: aCoord[0] = 0.5; aCoord[1] = 0.5; break; - case 5: aCoord[0] = 0.0; aCoord[1] = 0.5; break; - } - } - } - //--------------------------------------------------------------- - TQuad4a::TQuad4a(): - TShapeFun(2,4) - { - TInt aNbRef = GetNbRef(); - for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ - TCoordSlice aCoord = GetCoord(aRefId); - switch(aRefId){ - case 0: aCoord[0] = -1.0; aCoord[1] = 1.0; break; - case 1: aCoord[0] = -1.0; aCoord[1] = -1.0; break; - case 2: aCoord[0] = 1.0; aCoord[1] = -1.0; break; - case 3: aCoord[0] = 1.0; aCoord[1] = 1.0; break; - } - } - } - //--------------------------------------------------------------- - TQuad8a::TQuad8a(): - TShapeFun(2,8) - { - TInt aNbRef = GetNbRef(); - for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ - TCoordSlice aCoord = GetCoord(aRefId); - switch(aRefId){ - case 0: aCoord[0] = -1.0; aCoord[1] = 1.0; break; - case 1: aCoord[0] = -1.0; aCoord[1] = -1.0; break; - case 2: aCoord[0] = 1.0; aCoord[1] = -1.0; break; - case 3: aCoord[0] = 1.0; aCoord[1] = 1.0; break; - - case 4: aCoord[0] = -1.0; aCoord[1] = 0.0; break; - case 5: aCoord[0] = 0.0; aCoord[1] = -1.0; break; - case 6: aCoord[0] = 1.0; aCoord[1] = 0.0; break; - case 7: aCoord[0] = 0.0; aCoord[1] = 1.0; break; - } - } - } - //--------------------------------------------------------------- - TQuad4b::TQuad4b(): - TShapeFun(2,4) - { - TInt aNbRef = GetNbRef(); - for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ - TCoordSlice aCoord = GetCoord(aRefId); - switch(aRefId){ - case 0: aCoord[0] = -1.0; aCoord[1] = -1.0; break; - case 1: aCoord[0] = 1.0; aCoord[1] = -1.0; break; - case 2: aCoord[0] = 1.0; aCoord[1] = 1.0; break; - case 3: aCoord[0] = -1.0; aCoord[1] = 1.0; break; - } - } - } - //--------------------------------------------------------------- - TQuad8b::TQuad8b(): - TShapeFun(2,8) - { - TInt aNbRef = GetNbRef(); - for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ - TCoordSlice aCoord = GetCoord(aRefId); - switch(aRefId){ - case 0: aCoord[0] = -1.0; aCoord[1] = -1.0; break; - case 1: aCoord[0] = 1.0; aCoord[1] = -1.0; break; - case 2: aCoord[0] = 1.0; aCoord[1] = 1.0; break; - case 3: aCoord[0] = -1.0; aCoord[1] = 1.0; break; - - case 4: aCoord[0] = 0.0; aCoord[1] = -1.0; break; - case 5: aCoord[0] = 1.0; aCoord[1] = 0.0; break; - case 6: aCoord[0] = 0.0; aCoord[1] = 1.0; break; - case 7: aCoord[0] = -1.0; aCoord[1] = 0.0; break; - } - } - } - //--------------------------------------------------------------- - TTetra4a::TTetra4a(): - TShapeFun(3,4) - { - TInt aNbRef = GetNbRef(); - for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ - TCoordSlice aCoord = GetCoord(aRefId); - switch(aRefId){ - case 0: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break; - case 1: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break; - case 2: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - case 3: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - } - } - } - //--------------------------------------------------------------- - TTetra10a::TTetra10a(): - TShapeFun(3,10) - { - TInt aNbRef = GetNbRef(); - for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ - TCoordSlice aCoord = GetCoord(aRefId); - switch(aRefId){ - case 0: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break; - case 1: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break; - case 2: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - case 3: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - - case 4: aCoord[0] = 0.0; aCoord[1] = 0.5; aCoord[2] = 0.5; break; - case 5: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 0.5; break; - case 6: aCoord[0] = 0.0; aCoord[1] = 0.5; aCoord[2] = 0.0; break; - - case 7: aCoord[0] = 0.5; aCoord[1] = 0.5; aCoord[2] = 0.0; break; - case 8: aCoord[0] = 0.5; aCoord[1] = 0.0; aCoord[2] = 0.5; break; - case 9: aCoord[0] = 0.5; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - } - } - } - //--------------------------------------------------------------- - TTetra4b::TTetra4b(): - TShapeFun(3,4) - { - TInt aNbRef = GetNbRef(); - for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ - TCoordSlice aCoord = GetCoord(aRefId); - switch(aRefId){ - case 0: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break; - case 2: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break; - case 1: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - case 3: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - } - } - } - //--------------------------------------------------------------- - TTetra10b::TTetra10b(): - TShapeFun(3,10) - { - TInt aNbRef = GetNbRef(); - for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ - TCoordSlice aCoord = GetCoord(aRefId); - switch(aRefId){ - case 0: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break; - case 2: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break; - case 1: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - case 3: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - - case 6: aCoord[0] = 0.0; aCoord[1] = 0.5; aCoord[2] = 0.5; break; - case 5: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 0.5; break; - case 4: aCoord[0] = 0.0; aCoord[1] = 0.5; aCoord[2] = 0.0; break; - - case 7: aCoord[0] = 0.5; aCoord[1] = 0.5; aCoord[2] = 0.0; break; - case 9: aCoord[0] = 0.5; aCoord[1] = 0.0; aCoord[2] = 0.5; break; - case 8: aCoord[0] = 0.5; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - } - } - } - //--------------------------------------------------------------- - THexa8a::THexa8a(): - TShapeFun(3,8) - { - TInt aNbRef = GetNbRef(); - for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ - TCoordSlice aCoord = GetCoord(aRefId); - switch(aRefId){ - case 0: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break; - case 1: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break; - case 2: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break; - case 3: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break; - case 4: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break; - case 5: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break; - case 6: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break; - case 7: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break; - } - } - } - //--------------------------------------------------------------- - THexa20a::THexa20a(TInt theDim, TInt theNbRef): - TShapeFun(theDim,theNbRef) - { - TInt aNbRef = myRefCoord.size(); - for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ - TCoordSlice aCoord = GetCoord(aRefId); - switch(aRefId){ - case 0: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break; - case 1: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break; - case 2: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break; - case 3: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break; - case 4: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break; - case 5: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break; - case 6: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break; - case 7: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break; - - case 8: aCoord[0] = 0.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break; - case 9: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = -1.0; break; - case 10: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break; - case 11: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = -1.0; break; - case 12: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = 0.0; break; - case 13: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = 0.0; break; - case 14: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break; - case 15: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break; - case 16: aCoord[0] = 0.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break; - case 17: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break; - case 18: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break; - case 19: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break; - } - } - } - //--------------------------------------------------------------- - THexa27a::THexa27a(): - THexa20a(3,27) - { - TInt aNbRef = myRefCoord.size(); - for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ - TCoordSlice aCoord = GetCoord(aRefId); - switch(aRefId){ - case 20: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = -1.0; break; - case 21: aCoord[0] = 0.0; aCoord[1] = -1.0; aCoord[2] = 0.0; break; - case 22: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - case 23: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break; - case 24: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - case 25: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break; - case 26: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - } - } - } - //--------------------------------------------------------------- - THexa8b::THexa8b(): - TShapeFun(3,8) - { - TInt aNbRef = GetNbRef(); - for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ - TCoordSlice aCoord = GetCoord(aRefId); - switch(aRefId){ - case 0: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break; - case 3: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break; - case 2: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break; - case 1: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break; - case 4: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break; - case 7: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break; - case 6: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break; - case 5: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break; - } - } - } - //--------------------------------------------------------------- - THexa20b::THexa20b(TInt theDim, TInt theNbRef): - TShapeFun(theDim,theNbRef) - { - TInt aNbRef = myRefCoord.size(); - for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ - TCoordSlice aCoord = GetCoord(aRefId); - switch(aRefId){ - case 0: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break; - case 3: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break; - case 2: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break; - case 1: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break; - case 4: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break; - case 7: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break; - case 6: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break; - case 5: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break; - - case 11: aCoord[0] = 0.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break; - case 10: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = -1.0; break; - case 9: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break; - case 8: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = -1.0; break; - case 16: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = 0.0; break; - case 19: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = 0.0; break; - case 18: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break; - case 17: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break; - case 15: aCoord[0] = 0.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break; - case 14: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break; - case 13: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break; - case 12: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break; - } - } - } - //--------------------------------------------------------------- - TPenta6a::TPenta6a(): - TShapeFun(3,6) - { - TInt aNbRef = myRefCoord.size(); - for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ - TCoordSlice aCoord = GetCoord(aRefId); - switch(aRefId){ - case 0: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break; - case 1: aCoord[0] = -1.0; aCoord[1] = -0.0; aCoord[2] = 1.0; break; - case 2: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - case 3: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break; - case 4: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break; - case 5: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - } - } - } - //--------------------------------------------------------------- - TPenta6b::TPenta6b(): - TShapeFun(3,6) - { - TInt aNbRef = myRefCoord.size(); - for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ - TCoordSlice aCoord = GetCoord(aRefId); - switch(aRefId){ - case 0: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break; - case 2: aCoord[0] = -1.0; aCoord[1] = -0.0; aCoord[2] = 1.0; break; - case 1: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - case 3: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break; - case 5: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break; - case 4: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - } - } - } - //--------------------------------------------------------------- - TPenta15a::TPenta15a(): - TShapeFun(3,15) - { - TInt aNbRef = myRefCoord.size(); - for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ - TCoordSlice aCoord = GetCoord(aRefId); - switch(aRefId){ - case 0: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break; - case 1: aCoord[0] = -1.0; aCoord[1] = -0.0; aCoord[2] = 1.0; break; - case 2: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - case 3: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break; - case 4: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break; - case 5: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - - case 6: aCoord[0] = -1.0; aCoord[1] = 0.5; aCoord[2] = 0.5; break; - case 7: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.5; break; - case 8: aCoord[0] = -1.0; aCoord[1] = 0.5; aCoord[2] = 0.0; break; - case 9: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break; - case 10: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break; - case 11: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - case 12: aCoord[0] = 1.0; aCoord[1] = 0.5; aCoord[2] = 0.5; break; - case 13: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.5; break; - case 14: aCoord[0] = 1.0; aCoord[1] = 0.5; aCoord[2] = 0.0; break; - } - } - } - //--------------------------------------------------------------- - TPenta15b::TPenta15b(): - TShapeFun(3,15) - { - TInt aNbRef = myRefCoord.size(); - for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ - TCoordSlice aCoord = GetCoord(aRefId); - switch(aRefId){ - case 0: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break; - case 2: aCoord[0] = -1.0; aCoord[1] = -0.0; aCoord[2] = 1.0; break; - case 1: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - case 3: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break; - case 5: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break; - case 4: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - - case 8: aCoord[0] = -1.0; aCoord[1] = 0.5; aCoord[2] = 0.5; break; - case 7: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.5; break; - case 6: aCoord[0] = -1.0; aCoord[1] = 0.5; aCoord[2] = 0.0; break; - case 12: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break; - case 14: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break; - case 13: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - case 11: aCoord[0] = 1.0; aCoord[1] = 0.5; aCoord[2] = 0.5; break; - case 10: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.5; break; - case 9: aCoord[0] = 1.0; aCoord[1] = 0.5; aCoord[2] = 0.0; break; - } - } - } - //--------------------------------------------------------------- - TPyra5a::TPyra5a(): - TShapeFun(3,5) - { - TInt aNbRef = myRefCoord.size(); - for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ - TCoordSlice aCoord = GetCoord(aRefId); - switch(aRefId){ - case 0: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - case 1: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break; - case 2: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - case 3: aCoord[0] = 0.0; aCoord[1] = -1.0; aCoord[2] = 0.0; break; - case 4: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break; - } - } - } - //--------------------------------------------------------------- - TPyra5b::TPyra5b(): - TShapeFun(3,5) - { - TInt aNbRef = myRefCoord.size(); - for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ - TCoordSlice aCoord = GetCoord(aRefId); - switch(aRefId){ - case 0: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - case 3: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break; - case 2: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - case 1: aCoord[0] = 0.0; aCoord[1] = -1.0; aCoord[2] = 0.0; break; - case 4: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break; - } - } - } - //--------------------------------------------------------------- - TPyra13a::TPyra13a(): - TShapeFun(3,13) - { - TInt aNbRef = myRefCoord.size(); - for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ - TCoordSlice aCoord = GetCoord(aRefId); - switch(aRefId){ - case 0: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - case 1: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break; - case 2: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - case 3: aCoord[0] = 0.0; aCoord[1] = -1.0; aCoord[2] = 0.0; break; - case 4: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break; - - case 5: aCoord[0] = 0.5; aCoord[1] = 0.5; aCoord[2] = 0.0; break; - case 6: aCoord[0] = -0.5; aCoord[1] = 0.5; aCoord[2] = 0.0; break; - case 7: aCoord[0] = -0.5; aCoord[1] = -0.5; aCoord[2] = 0.0; break; - case 8: aCoord[0] = 0.5; aCoord[1] = -0.5; aCoord[2] = 0.0; break; - case 9: aCoord[0] = 0.5; aCoord[1] = 0.0; aCoord[2] = 0.5; break; - case 10: aCoord[0] = 0.0; aCoord[1] = 0.5; aCoord[2] = 0.5; break; - case 11: aCoord[0] = -0.5; aCoord[1] = 0.0; aCoord[2] = 0.5; break; - case 12: aCoord[0] = 0.0; aCoord[1] = -0.5; aCoord[2] = 0.5; break; - } - } - } - //--------------------------------------------------------------- - TPyra13b::TPyra13b(): - TShapeFun(3,13) - { - TInt aNbRef = myRefCoord.size(); - for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ - TCoordSlice aCoord = GetCoord(aRefId); - switch(aRefId){ - case 0: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - case 3: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break; - case 2: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break; - case 1: aCoord[0] = 0.0; aCoord[1] = -1.0; aCoord[2] = 0.0; break; - case 4: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break; - - case 8: aCoord[0] = 0.5; aCoord[1] = 0.5; aCoord[2] = 0.0; break; - case 7: aCoord[0] = -0.5; aCoord[1] = 0.5; aCoord[2] = 0.0; break; - case 6: aCoord[0] = -0.5; aCoord[1] = -0.5; aCoord[2] = 0.0; break; - case 5: aCoord[0] = 0.5; aCoord[1] = -0.5; aCoord[2] = 0.0; break; - case 9: aCoord[0] = 0.5; aCoord[1] = 0.0; aCoord[2] = 0.5; break; - case 12: aCoord[0] = 0.0; aCoord[1] = 0.5; aCoord[2] = 0.5; break; - case 11: aCoord[0] = -0.5; aCoord[1] = 0.0; aCoord[2] = 0.5; break; - case 10: aCoord[0] = 0.0; aCoord[1] = -0.5; aCoord[2] = 0.5; break; - } - } - } - /*! - * \brief Fill definition of gauss points family - */ - - TGaussDef::TGaussDef(const int geom, const int nbGauss, const int variant) - { - myType = geom; - myCoords .reserve( nbGauss * dim() ); - myWeights.reserve( nbGauss ); - - switch ( geom ) { - - case MED_SEG2: - case MED_SEG3: - if (geom == MED_SEG2) setRefCoords( TSeg2a() ); - else setRefCoords( TSeg3a() ); - switch ( nbGauss ) { - case 1: { - add( 0.0, 2.0 ); break; - } - case 2: { - const double a = 0.577350269189626; - add( a, 1.0 ); - add( -a, 1.0 ); break; - } - case 3: { - const double a = 0.774596669241; - const double P1 = 1./1.8; - const double P2 = 1./1.125; - add( -a, P1 ); - add( 0, P2 ); - add( a, P1 ); break; - } - case 4: { - const double a = 0.339981043584856, b = 0.861136311594053; - const double P1 = 0.652145154862546, P2 = 0.347854845137454 ; - add( a, P1 ); - add( -a, P1 ); - add( b, P2 ); - add( -b, P2 ); break; - } - default: - EXCEPTION( logic_error,"Invalid nb of gauss points for SEG"< alfa - const double a = (6 + sqrt(15.))/21.; - const double b = (6 - sqrt(15.))/21.; - const double P1 = (155 + sqrt(15.))/2400.; - const double P2 = (155 - sqrt(15.))/2400.; //___ - add( -d, 1/3., 1/3., c1*9/80. );//___ - add( -d, a, a, c1*P1 ); - add( -d, 1-2*a, a, c1*P1 ); - add( -d, a, 1-2*a, c1*P1 );//___ - add( -d, b, b, c1*P2 ); - add( -d, 1-2*b, b, c1*P2 ); - add( -d, b, 1-2*b, c1*P2 );//___ - add( 0., 1/3., 1/3., c2*9/80. );//___ - add( 0., a, a, c2*P1 ); - add( 0., 1-2*a, a, c2*P1 ); - add( 0., a, 1-2*a, c2*P1 );//___ - add( 0., b, b, c2*P2 ); - add( 0., 1-2*b, b, c2*P2 ); - add( 0., b, 1-2*b, c2*P2 );//___ - add( d, 1/3., 1/3., c1*9/80. );//___ - add( d, a, a, c1*P1 ); - add( d, 1-2*a, a, c1*P1 ); - add( d, a, 1-2*a, c1*P1 );//___ - add( d, b, b, c1*P2 ); - add( d, 1-2*b, b, c1*P2 ); - add( d, b, 1-2*b, c1*P2 );//___ - break; - } - default: - EXCEPTION( logic_error,"Invalid nb of gauss points for PENTA: " < ( locName.c_str(), - typeGeo, - nGauss, - &gaussDef.myRefCoords[0], - &gaussDef.myCoords[0], - &gaussDef.myWeights[0] ); - return gsloc; - } -} diff --git a/src/MEDMEM/MEDMEM_GaussLocalization.hxx b/src/MEDMEM/MEDMEM_GaussLocalization.hxx deleted file mode 100644 index 5ce5d5769..000000000 --- a/src/MEDMEM/MEDMEM_GaussLocalization.hxx +++ /dev/null @@ -1,216 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef GAUSS_LOCALIZATION_HXX -#define GAUSS_LOCALIZATION_HXX - -#include -#include -#include "MEDMEM_define.hxx" -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_ArrayInterface.hxx" -#include "MEDMEM_nArray.hxx" -#include "MEDMEM_DriversDef.hxx" -#include "MEDMEM_SetInterlacingType.hxx" - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -namespace MEDMEM { - - class MEDMEM_EXPORT GAUSS_LOCALIZATION_ { - public: - virtual MED_EN::medModeSwitch getInterlacingType() const {return MED_EN::MED_UNDEFINED_INTERLACE;} - virtual ~GAUSS_LOCALIZATION_() {}; //Indispensable pour détruire le vrai objet pointé - - /*! - * \brief Creates a localization filled with default values. The caller gets pointer ownership - */ - static GAUSS_LOCALIZATION_* makeDefaultLocalization(const string & locName, - medGeometryElement typeGeo, - int nGauss) throw (MEDEXCEPTION); - }; - - template class GAUSS_LOCALIZATION; - - template ostream & operator<< (ostream &os, - const GAUSS_LOCALIZATION &loc); - - template class GAUSS_LOCALIZATION : public GAUSS_LOCALIZATION_{ - public: - typedef typename MEDMEM_ArrayInterface::Array ArrayNoGauss; - - protected: - - string _locName; - MED_EN::medGeometryElement _typeGeo; - int _nGauss; - ArrayNoGauss _cooRef; - ArrayNoGauss _cooGauss; - vector _wg; - MED_EN::medModeSwitch _interlacingType; - - public: - friend ostream & operator<< (ostream &os, - const GAUSS_LOCALIZATION &loc); - - GAUSS_LOCALIZATION() throw (MEDEXCEPTION); - GAUSS_LOCALIZATION(const string & locName, - const MED_EN::medGeometryElement typeGeo, - const int nGauss, - const ArrayNoGauss & cooRef, - const ArrayNoGauss & cooGauss, - const vector & wg) throw (MEDEXCEPTION); - - GAUSS_LOCALIZATION(const string & locName, - const MED_EN::medGeometryElement typeGeo, - const int nGauss, - const double * const cooRef, - const double * const cooGauss, - const double * const wg) throw (MEDEXCEPTION); - - //GAUSS_LOCALIZATION(const GAUSS_LOCALIZATION & loc); constructeur de recopie par défaut correct - virtual ~GAUSS_LOCALIZATION() {}; - GAUSS_LOCALIZATION & operator=(const GAUSS_LOCALIZATION & gaussLoc); - bool operator == (const GAUSS_LOCALIZATION &loc) const; - - string getName() const {return _locName;} - MED_EN::medGeometryElement getType() const {return _typeGeo;} - int getNbGauss() const {return _nGauss;} - const ArrayNoGauss& getRefCoo () const {return _cooRef;} //Ces tableaux sont petits - const ArrayNoGauss& getGsCoo () const {return _cooGauss;} //Ces tableaux sont petits - vector getWeight () const {return _wg;} //Ces tableaux sont petits - inline MED_EN::medModeSwitch getInterlacingType() const { return _interlacingType;} - - }; - template GAUSS_LOCALIZATION::GAUSS_LOCALIZATION() throw (MEDEXCEPTION) : - _typeGeo(MED_EN::MED_NONE), _nGauss(-1), - _interlacingType( SET_INTERLACING_TYPE::_interlacingType) - {} - - template GAUSS_LOCALIZATION::GAUSS_LOCALIZATION(const string & locName, - const MED_EN::medGeometryElement typeGeo, - const int nGauss, - const ArrayNoGauss & cooRef, - const ArrayNoGauss & cooGauss, - const vector & wg) throw (MEDEXCEPTION) : - _locName(locName),_typeGeo(typeGeo),_nGauss(nGauss),_cooRef(cooRef),_cooGauss(cooGauss),_wg(wg), - _interlacingType(SET_INTERLACING_TYPE::_interlacingType) - { - const char * LOC = "GAUSS_LOCALIZATION(locName,typeGeo, nGauss, const ArrayNoGauss & cooRef,..) : "; - BEGIN_OF_MED(LOC); - if (_cooRef.getDim() != _cooGauss.getDim() ) - throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"cooRef and cooGaus must have the same number of components")) ; - - if (_cooRef.getArraySize() != (_typeGeo%100)*(_typeGeo/100) ) - throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"cooRef size is " << _cooRef.getArraySize() - << " and should be (_typeGeo%100)*(_typeGeo/100) " - << (_typeGeo%100)*(_typeGeo/100))) ; - - if (_cooGauss.getArraySize() != _nGauss*(_typeGeo/100) ) - throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"cooGauss must be of size nGauss*(_typeGeo/100) " - << _nGauss*(_typeGeo/100) )); - if ((int)_wg.size() != _nGauss ) - throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"wg must be of size nGauss " - << _nGauss )); - - END_OF_MED(LOC); - } - - template GAUSS_LOCALIZATION::GAUSS_LOCALIZATION - (const string & locName, - const MED_EN::medGeometryElement typeGeo, - const int nGauss, - const double * const cooRef, - const double * const cooGauss, - const double * const wg) throw (MEDEXCEPTION) : - _locName(locName),_typeGeo(typeGeo),_nGauss(nGauss), - _cooRef(ArrayNoGauss(const_cast(cooRef),typeGeo/100,typeGeo%100)), - _cooGauss(ArrayNoGauss(const_cast(cooGauss),typeGeo/100,_nGauss)), - _wg(vector(wg,wg+nGauss)), - _interlacingType(SET_INTERLACING_TYPE::_interlacingType) - { - const char * LOC = "GAUSS_LOCALIZATION(locName,typeGeo, nGauss, const double * cooRef,..) :"; - BEGIN_OF_MED(LOC); - if (_cooRef.getDim() != _cooGauss.getDim() ) - throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"cooRef and cooGaus must have the same number of components")) ; - - if (_cooRef.getArraySize() != (_typeGeo%100)*(_typeGeo/100) ) - throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"cooRef must be of size (_typeGeo%100)*(_typeGeo/100) " - << (_typeGeo%100)*(_typeGeo/100))) ; - - if (_cooGauss.getArraySize() != _nGauss*(_typeGeo/100) ) - throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"cooGauss must be of size nGauss*(_typeGeo/100) " - << _nGauss*(_typeGeo/100) )); - if ((int)_wg.size() != _nGauss ) - throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"wg must be of size nGauss " - << _nGauss )); - END_OF_MED(LOC); - } - - template GAUSS_LOCALIZATION & - GAUSS_LOCALIZATION::operator=(const GAUSS_LOCALIZATION & gaussLoc) - { - if ( this == &gaussLoc) return *this; - - _locName = gaussLoc._locName; - _typeGeo = gaussLoc._typeGeo; - _nGauss = gaussLoc._nGauss; - //_cooRef.setPtr((double*)gaussLoc._cooRef.getPtr(), false, true); //utilisation de la copie superficielle par défaut n'est pas une bonne idée - //_cooGauss.setPtr((double*)gaussLoc._cooGauss.getPtr(), false, true); //dans l'opérateur = de MEDnArray - _cooRef = gaussLoc._cooRef; - _cooGauss = gaussLoc._cooGauss; - _wg = gaussLoc._wg; - - return *this; - } - - template bool - GAUSS_LOCALIZATION::operator == (const GAUSS_LOCALIZATION & gaussLoc) const { - return ( - _locName == gaussLoc._locName && - _typeGeo == gaussLoc._typeGeo && - _nGauss == gaussLoc._nGauss && - _cooRef == gaussLoc._cooRef && //utilisation de la copie superficielle par défaut n'est pas une bonne idée - _cooGauss == gaussLoc._cooGauss && //dans l'opérateur = de MEDnArray - _wg == gaussLoc._wg - ); - } - - - template ostream & operator<<(ostream &os, - const GAUSS_LOCALIZATION &loc) { - os << "Localization Name : " << loc._locName << endl; - os << "Geometric Type : " << MED_EN::geoNames[loc._typeGeo]<< endl; - os << "Number Of GaussPoints : " << loc._nGauss << endl; - os << "Ref. Element Coords : " << endl << loc._cooRef << endl; - os << "Gauss points Coords : " << endl << loc._cooGauss << endl; - os << "Gauss points weigth : " << endl ; - for(unsigned i=0; i= 0 ) _id=id; else _id = MED_INVALID ; - - END_OF_MED(LOC); -} - -int GENDRIVER::getId ( void) const -{ - const char* LOC = "int GENDRIVER::getId ( void) const "; - BEGIN_OF_MED(LOC); - - return _id ; -} - -string GENDRIVER::getFileName() const { - - const char* LOC = "string GENDRIVER::getFileName() const : "; - BEGIN_OF_MED(LOC); - - return _fileName; -} - - -void GENDRIVER::setFileName(const string & fileName) -{ - const char * LOC = "void GENDRIVER::setFileName(const string & fileName) : "; - BEGIN_OF_MED(LOC); - - if ( _status == MED_OPENED ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<" File |" << _fileName - << "| is still openned, close it before openning : | " << fileName << "|")); - else - _fileName = fileName; - - END_OF_MED(LOC); -} - -med_mode_acces GENDRIVER::getAccessMode() const -{ - const char* LOC = "med_mode_acces GENDRIVER::getAccessMode() const : "; - BEGIN_OF_MED(LOC); - - return _accessMode; -} - -void GENDRIVER::setAccessMode(med_mode_acces mode) -{ - _accessMode = mode; -} - -ostream & MEDMEM::operator<<(ostream &os,const GENDRIVER & drv) -{ - switch (drv._accessMode) - { - case RDONLY : - os<<"C'est un IO de READ"<read( genDriver ) if object was not passed to genDriver, -// then object asks driverFactory to create a driver initialized by object -// and fills the new driver up using merge( genDriver ) - -void GENDRIVER::merge ( const GENDRIVER &genDriver ) -{ - if ( _id == MED_INVALID ) - _id = genDriver._id; - if ( _fileName.empty() ) - _fileName = genDriver._fileName; - if ( _accessMode == MED_INVALID ) - _accessMode = genDriver._accessMode; - - if ( getMeshName().empty() ) - setMeshName( genDriver.getMeshName() ); - if ( getFieldName().empty() ) - setFieldName( genDriver.getFieldName() ); -} diff --git a/src/MEDMEM/MEDMEM_GenDriver.hxx b/src/MEDMEM/MEDMEM_GenDriver.hxx deleted file mode 100644 index 48a8b32bc..000000000 --- a/src/MEDMEM/MEDMEM_GenDriver.hxx +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef GENDRIVER_HXX -#define GENDRIVER_HXX - -#include - -#include - -#include "MEDMEM_define.hxx" -#include "MEDMEM_Utilities.hxx" - -/* Generic Read/Write Driver Class for Meshes & Fields */ - -using namespace std; - -/*! - - Virtual class GENDRIVER use by all driver. - -*/ -namespace MEDMEM { - - /* Modify the following line to add a new driver type (step 1) */ - typedef enum { MED_DRIVER = 0, GIBI_DRIVER = 1, PORFLOW_DRIVER = 2, - ENSIGHT_DRIVER = 250, VTK_DRIVER = 254, ASCII_DRIVER = 3, - NO_DRIVER = 255 } driverTypes; - - class GENDRIVER; - MEDMEM_EXPORT ostream & operator<<(ostream &os,const GENDRIVER &genDriver); - - class MEDMEM_EXPORT GENDRIVER { - -protected : - - int _id; // position in a vector of drivers in GMESH or FIELD_ - - /*File related part*/ - string _fileName; // The name of the file currently in use. - MED_EN::med_mode_acces _accessMode; // The file access mode set by the adequate construtor. - int _status; // The file status {MED_INVALID, MED_OPENED, MED_CLOSED } - driverTypes _driverType; - - -public: - /*! - Constructor. - */ - GENDRIVER(driverTypes driverType); - /*! - Constructor. - */ - GENDRIVER(const string & fileName, MED_EN::med_mode_acces accessMode, - driverTypes driverType); - /*! - Copy constructor. - */ - GENDRIVER(const GENDRIVER & genDriver); - - /*! - Destructor. - */ - virtual ~GENDRIVER(); - - /*! - Operator = : duplicate the given genDriver. - */ - GENDRIVER & operator=(const GENDRIVER & genDriver); - - /*! - Operator << : put GENDRIVER object information to the given stream - */ - friend ostream & operator<<(ostream &os,const GENDRIVER &genDriver); - - bool operator ==(const GENDRIVER &genDriver) const; - /*! - Open file. - */ - virtual void open ( void ) = 0; - /*! - Open file with the append option. This method is used especially - on ASCII drivers (e.g. VTK_DRIVER). - */ - virtual void openAppend ( void ); - /*! - Close file. - */ - virtual void close( void ) = 0; - /*! - Write object in opened file. - */ - virtual void write( void ) const = 0; - /*! - Write object in opened file. This method is used especially - on ASCII drivers (e.g. VTK_DRIVER). - */ - virtual void writeAppend( void ) const; - /*! - Read object in opened file. - */ - virtual void read ( void ) = 0; - - // needed to duplicate arrays - virtual GENDRIVER * copy ( void ) const = 0 ; - - // Take missing data from other driver. - // Intended for object->read( genDriver ) if object was not passed to genDriver - // (i.e. genDriver has been created through constructor without parameters), - // then object asks driverFactory to create a driver initialized by object - // and fills the new driver up using merge( genDriver ). - // Needed for drivers possessing specific data - virtual void merge ( const GENDRIVER &genDriver ); - - // MED related part - virtual void writeFrom ( void ) const; - virtual void readFileStruct ( void ); - // MESH related Part - virtual void setMeshName ( const string & meshName); - virtual string getMeshName() const; - // FIELD related Part - virtual void setFieldName ( const string & fieldName); - virtual string getFieldName() const; - - void setId ( int id = MED_EN::MED_INVALID ); - int getId ( void ) const ; - string getFileName () const; - virtual void setFileName ( const string & fileName); - virtual MED_EN::med_mode_acces getAccessMode() const; - virtual void setAccessMode(MED_EN::med_mode_acces mode); - driverTypes getDriverType() const { return _driverType; } -}; -} - - -#endif /* GENDRIVER_HXX */ diff --git a/src/MEDMEM/MEDMEM_GibiMeshDriver.cxx b/src/MEDMEM/MEDMEM_GibiMeshDriver.cxx deleted file mode 100644 index 2cdd07c1d..000000000 --- a/src/MEDMEM/MEDMEM_GibiMeshDriver.cxx +++ /dev/null @@ -1,4246 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include -#include -#include - -#include "MEDMEM_GibiMeshDriver.hxx" - -#ifdef HAS_XDR -// On windows, this file must be included first otherwise -// there is a conflict with the symbol GROUP when compiling the xdr support ... -#include -#endif - -#include "MEDMEM_DriversDef.hxx" - -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_Group.hxx" -#include "MEDMEM_Coordinate.hxx" -#include "MEDMEM_Connectivity.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_CellModel.hxx" -#include "MEDMEM_define.hxx" -#include "MEDMEM_DriverTools.hxx" - -namespace MEDMEM -{ -class FIELD_; -} - -#include -#include -#ifdef WIN32 -#include -#else -#include -#endif - -#include - -///// -using namespace std; -using namespace MED_EN; -using namespace MEDMEM; -///// - -// read or not non-named fields -//#define GIBI_READ_ONLY_NAMED_FIELD - -// to throw an exception when try to write a name longer than 8 or non-unique encounters -//#define THROW_ON_BAD_NAME - -// to see full dump of RESULTATS STRUCTURE INTERMEDIAIRES -#ifdef _DEBUG_ -// #undef MESSAGE_MED -// #define MESSAGE_MED(txt) std::cout << txt << endl; -// #undef INFOS_MED -// #define INFOS_MED(txt) std::cout << txt << endl; -#endif - -// Every memory allocation made in the MedDriver members function are desallocated in the Mesh destructor - -///// -//const size_t GIBI_MESH_DRIVER::nb_geometrie_gibi; - -const medGeometryElement GIBI_MESH_DRIVER::geomGIBItoMED[nb_geometrie_gibi] = - { /*1 */ MED_POINT1 ,/*2 */ MED_SEG2 ,/*3 */ MED_SEG3 ,/*4 */ MED_TRIA3 ,/*5 */ MED_NONE , - /*6 */ MED_TRIA6 ,/*7 */ MED_NONE ,/*8 */ MED_QUAD4 ,/*9 */ MED_NONE ,/*10*/ MED_QUAD8 , - /*11*/ MED_NONE ,/*12*/ MED_NONE ,/*13*/ MED_NONE ,/*14*/ MED_HEXA8 ,/*15*/ MED_HEXA20 , - /*16*/ MED_PENTA6 ,/*17*/ MED_PENTA15,/*18*/ MED_NONE ,/*19*/ MED_NONE ,/*20*/ MED_NONE , - /*21*/ MED_NONE ,/*22*/ MED_NONE ,/*23*/ MED_TETRA4 ,/*24*/ MED_TETRA10,/*25*/ MED_PYRA5 , - /*26*/ MED_PYRA13 ,/*27*/ MED_NONE ,/*28*/ MED_NONE ,/*29*/ MED_NONE ,/*30*/ MED_NONE , - /*31*/ MED_NONE ,/*32*/ MED_NONE ,/*33*/ MED_NONE ,/*34*/ MED_NONE ,/*35*/ MED_NONE , - /*36*/ MED_NONE ,/*37*/ MED_NONE ,/*38*/ MED_NONE ,/*39*/ MED_NONE ,/*40*/ MED_NONE , - /*41*/ MED_NONE ,/*42*/ MED_NONE ,/*43*/ MED_NONE ,/*44*/ MED_NONE ,/*45*/ MED_NONE , - /*46*/ MED_NONE ,/*47*/ MED_NONE }; - -enum Readable_Piles - { - PILE_SOUS_MAILLAGE=1, - PILE_NODES_FIELD =2, - PILE_TABLES =10, - PILE_LREEL =18, - PILE_LOGIQUES =24, - PILE_FLOATS =25, - PILE_INTEGERS =26, - PILE_STRINGS =27, - PILE_LMOTS =29, - PILE_NOEUDS =32, - PILE_COORDONNEES =33, - PILE_MODL =38, - PILE_FIELD =39, - PILE_LAST_READABLE=39 - }; - -//======================================================================= -//function : gibi2medGeom -//purpose : -//======================================================================= - -medGeometryElement GIBI_MESH_DRIVER::gibi2medGeom( size_t gibiTypeNb ) -{ - if ( gibiTypeNb < 1 || gibiTypeNb > 47 ) - return MED_NONE; - - return geomGIBItoMED[ gibiTypeNb - 1 ]; -} - -//======================================================================= -//function : med2gibiGeom -//purpose : -//======================================================================= - -int GIBI_MESH_DRIVER::med2gibiGeom( medGeometryElement medGeomType ) -{ - for ( int i = 0; i < nb_geometrie_gibi; i++ ) - if ( geomGIBItoMED[ i ] == medGeomType ) - return i + 1; - - return -1; -} - -//======================================================================= -//function : getGroupId -//purpose : -//======================================================================= - -static int getGroupId(const vector& support_ids, _intermediateMED* medi) -{ - int group_id = 0; - vector::const_iterator sb = support_ids.begin(), se = support_ids.end(); - if (support_ids.size() == 1 || // one or equal support ids - *std::max_element( sb, se ) == *std::min_element( sb, se )) - { - group_id = support_ids[0] - 1; - } - else - { - // try to find an existing group with the same sub-groups - set sup_set; - sup_set.insert( sb, se ); - - for ( group_id = 0; group_id < (int)medi->groupes.size(); ++group_id ) - { - if (sup_set.size() == medi->groupes[ group_id ].groupes.size() && - std::equal (sup_set.begin(), sup_set.end(), - medi->groupes[ group_id ].groupes.begin())) - break; - } - if ( group_id == (int)medi->groupes.size() ) - { - // no such a group, add a new one - medi->groupes.push_back( _groupe() ); - _groupe& new_grp = medi->groupes.back(); - new_grp.groupes.reserve( sup_set.size() ); - for ( set::iterator it = sup_set.begin(); it != sup_set.end(); it++ ) { - new_grp.groupes.push_back( *it ); - } - } - } - return group_id; -} - -//======================================================================= -//function : isNamedObject -//purpose : -//======================================================================= - -//#ifdef GIBI_READ_ONLY_NAMED_FIELD -static inline bool isNamedObject( int obj_index, const vector& indices_objets_nommes ) -{ - return ( std::find( indices_objets_nommes.begin(), indices_objets_nommes.end(), obj_index) - != indices_objets_nommes.end() ); -} -//#endif - -//======================================================================= -//function : setFieldNames -//purpose : set field names -//======================================================================= - -static void setFieldNames(const vector< _fieldBase* >& fields, - const vector& objets_nommes, - const vector& indices_objets_nommes) -{ - // set field names - unsigned i; - set fnames; - for ( i = 0; i < indices_objets_nommes.size(); ++i ) { - int fieldIndex = indices_objets_nommes[ i ]; - fnames.insert( objets_nommes[ i ]); - if ( fields[ fieldIndex - 1 ] ) - fields[ fieldIndex - 1 ]->_name = objets_nommes[ i ]; - } - int noNameIndex = 0; - for ( i = 0; i < fields.size(); ++i ) { - if ( !fields[ i ] ) { - if ( !isNamedObject( i+1, indices_objets_nommes )) - ++noNameIndex; - } - else if ( fields[ i ]->_name.empty() ) { - do { - fields[ i ]->_name = STRING("F_") << ++noNameIndex; - } while ( !fnames.insert( fields[ i ]->_name ).second ); - } - } -} - -//======================================================================= -//function : read -//purpose : -//======================================================================= - -#define GIBI_EQUAL(var_str, stat_str) \ - (strncmp (var_str, stat_str, strlen(stat_str)) == 0) -#define DUMP_LINE_NB " on line " << _lineNb - -bool GIBI_MESH_RDONLY_DRIVER::readFile (_intermediateMED* medi, bool readFields ) -{ - const char* LOC = "GIBI_MESH_RDONLY_DRIVER::readFile() : "; - BEGIN_OF_MED(LOC); - - // LECTURE DES DONNEES DS FICHIER GIBI - - Readable_Piles readable_Piles [] = { - PILE_SOUS_MAILLAGE, - PILE_NODES_FIELD, - PILE_TABLES, - PILE_LREEL, - PILE_LOGIQUES, - PILE_FLOATS, - PILE_INTEGERS, - PILE_STRINGS, - PILE_LMOTS, - PILE_NOEUDS, - PILE_COORDONNEES, - PILE_MODL, - PILE_FIELD, - PILE_LAST_READABLE - }; - // other known piles: - // PILE NUMERO 26 - Integers - // PILE NUMERO 25 - Floats - - char* ligne; // pour lire une ligne - const char* enregistrement_type=" ENREGISTREMENT DE TYPE"; - vector numero_noeuds; // tableau de travail (indices) - set donePiles; // already read piles - unsigned space_dimension = 0; - - // IMP 0020434: mapping GIBI names to MED names - list listGIBItoMED_mail; // to be read from PILE_TABLES, from table "MED_MAIL" - list listGIBItoMED_cham; // to be read from PILE_TABLES, from table "MED_CHAM" - list listGIBItoMED_comp; // to be read from PILE_TABLES, from table "MED_COMP" - map mapStrings; // to be read from PILE_STRINGS - vector<_fieldBase*> node_fields; - vector<_fieldBase*> cell_fields; - -#ifdef HAS_XDR - if ( _is_xdr) - { - _curPos = 0; - _iRead = 0; - _nbToRead = 0; - } -#endif - - while ( getNextLine(ligne, false)) // boucle externe de recherche de "ENREGISTREMENT DE TYPE" - { -#ifdef HAS_XDR - if ( !_is_xdr) -#endif - if ( !GIBI_EQUAL( ligne, enregistrement_type )) - continue; // "ENREGISTREMENT DE TYPE" non trouvé -> on lit la ligne suivante - - // lecture du numéro d'enregistrement - int numero_enregistrement; -#ifdef HAS_XDR - if(_is_xdr) - numero_enregistrement = getInt(); - else -#endif - numero_enregistrement = atoi( ligne + strlen(enregistrement_type) + 1 ); - - enum { ENREG_TYPE_2=2, ENREG_TYPE_4=4}; // énumération des types d'enregistrement traités -#ifdef HAS_XDR - enum { ENREG_TYPE_5=5, ENREG_TYPE_7=7}; // (only for xdr) -#endif - int numero_pile, nb_objets_nommes, nb_objets, nb_indices; - vector indices_objets_nommes; - vector objets_nommes; - - if (numero_enregistrement == ENREG_TYPE_4) - { -#ifdef HAS_XDR - if(_is_xdr) - { - getInt(); // skip NIVEAU - getInt(); // skip ERREUR - space_dimension = getInt(); - getFloat(); // skip DENSITE - } - else - { -#endif - getNextLine(ligne); - const char* s = " NIVEAU 15 NIVEAU ERREUR 0 DIMENSION"; - space_dimension = atoi( ligne + strlen( s ) + 1 ); - if ( !GIBI_EQUAL( ligne, " NIVEAU" ) || space_dimension < 1 ) { - INFOS_MED( " Could not read file: syntax error in type 4 record" << DUMP_LINE_NB ); - return false; - } -#ifdef HAS_XDR - } -#endif - } -#ifdef HAS_XDR - else if (numero_enregistrement == ENREG_TYPE_7) - { - if(_is_xdr) - { - getInt(); // skip NOMBRE INFO CASTEM2000 - getInt(); // skip IFOUR - getInt(); // skip NIFOUR - getInt(); // skip IFOMOD - getInt(); // skip IECHO - getInt(); // skip IIMPI - getInt(); // skip IOSPI - getInt(); // skip ISOTYP - getInt(); // skip NSDPGE - } - } -#endif - else if (numero_enregistrement == ENREG_TYPE_2 ) - { - if ( space_dimension == 0 ) { - INFOS_MED( "Missing ENREGISTREMENT DE TYPE 4" << DUMP_LINE_NB ); - return false; - } - // FORMAT(' PILE NUMERO',I4,'NBRE OBJETS NOMMES',I8,'NBRE OBJETS',I8) - getNextLine(ligne); -#ifdef HAS_XDR - if(_is_xdr) - { - initIntReading(3); - numero_pile = getInt(); next(); - nb_objets_nommes = getInt(); next(); - nb_objets = getInt(); next(); - } - else - { -#endif - const char *s1 = " PILE NUMERO", *s2 = "NBRE OBJETS NOMMES", *s3 = "NBRE OBJETS"; - if ( ! GIBI_EQUAL( ligne, s1 ) ) { - INFOS_MED( " Could not read file: error in type 2 record. " << ligne << DUMP_LINE_NB ); - return false; - } - ligne = ligne + strlen(s1); - numero_pile = atoi( ligne ); - ligne = ligne + 4 + strlen(s2); - nb_objets_nommes = atoi( ligne ); - ligne = ligne + 8 + strlen(s3); - nb_objets = atoi( ligne ); -#ifdef HAS_XDR - } -#endif - if ( nb_objets_nommes<0 || nb_objets<0 ) { - INFOS_MED(" Could not read file: " << nb_objets << " " < PILE_LAST_READABLE ) - break; // stop file reading - - // skip not readable piles - int i = -1; - while ( readable_Piles[ ++i ] != PILE_LAST_READABLE ) - if ( readable_Piles[ i ] == numero_pile ) - break; - if ( readable_Piles[ i ] != numero_pile ) -#ifdef HAS_XDR - { - if(_is_xdr) - { - cout << "XDR : NUMERO PILE " << numero_pile << " not implemented !!!" << endl ; - throw MEDEXCEPTION("XDR : NUMERO PILE not implemented !!!"); - } -#endif - continue; -#ifdef HAS_XDR - } -#endif - - // lecture des objets nommés et de leurs indices - objets_nommes.resize(nb_objets_nommes); - indices_objets_nommes.resize(nb_objets_nommes); - //indices_objets_nommes.resize(nb_objets); - for ( initNameReading( nb_objets_nommes ); more(); next() ) { - objets_nommes[ index() ] = getName(); - } - for ( initIntReading( nb_objets_nommes ); more(); next() ) - //for ( initIntReading( nb_objets ); more(); next() ) - indices_objets_nommes[ index() ] = getInt(); - - // boucle interne : lecture de la pile - - MESSAGE_MED(PREFIX_MED << "---- Traitement pile " << numero_pile); - - // ----------------------------------- - // MESH GROUPS - // ----------------------------------- - - if (numero_pile == PILE_SOUS_MAILLAGE ) // PILE NUMERO 1 - { - map strangeGroupType; - medi->groupes.reserve(nb_objets*2); // fields may add some groups - map< int , int > nbElemsByGeomType; - - for (int objet=0; objet!=nb_objets; ++objet) // pour chaque groupe - { - initIntReading( 5 ); - unsigned type_geom_castem = getInt(); next(); - unsigned nb_sous_maillage = getInt(); next(); - unsigned nb_reference = getInt(); next(); - unsigned nb_noeud = getInt(); next(); - unsigned nb_elements = getInt(); -#ifdef HAS_XDR - if(_is_xdr) next(); -#endif - - // le cas type_geom_castem=0 correspond aux maillages composites - if (type_geom_castem<0) { - INFOS_MED(" Error while reading file, bad geometric type:" << - type_geom_castem << DUMP_LINE_NB ); - return false; - } - - medi->groupes.push_back(_groupe()); - _groupe & groupe = medi->groupes.back(); - - // Issue 0021311. Allocate places for names of referring groups - // that will be possibly filled after reading long names from - // PILE_TABLES and PILE_STRINGS - groupe.refNames.resize( nb_reference ); - - // si le groupe se compose de sous-maillages (ie groupe composite) - if (type_geom_castem==0 && nb_sous_maillage>0) - { - // lecture des indices des sous-maillages, stockage. - // les mailles correspondant a ces sous_maillages seront inserees a la fin du case - groupe.groupes.resize( nb_sous_maillage ); - for ( initIntReading( nb_sous_maillage ); more(); next() ) { - groupe.groupes[ index() ] = getInt(); - } - if ( readFields ) - std::sort( groupe.groupes.begin(), groupe.groupes.end() ); - } - // lecture des references (non utilisé pour MED) - for ( i = 0; i < (int)nb_reference; i += 10 ) {// FORMAT(10I8) - getNextLine(ligne); - } -#ifdef HAS_XDR - if(_is_xdr) - { - for (initIntReading(nb_reference); more(); next()); - } -#endif - // lecture des couleurs (non utilisé pour MED) - for ( i = 0; i < (int)nb_elements; i += 10 ) { - getNextLine(ligne); - } -#ifdef HAS_XDR - if(_is_xdr) - { - for (initIntReading(nb_elements); more(); next()); - } -#endif - // not a composit group - if (type_geom_castem>0 && nb_sous_maillage==0) - { - medGeometryElement medType = gibi2medGeom(type_geom_castem); - - initIntReading( nb_elements * nb_noeud ); - if ( medType == MED_NONE ) { // look for group end - while ( more() ) - next(); - strangeGroupType.insert( make_pair( objet, type_geom_castem )); - continue; - } - if ( medType == MED_POINT1 ) - medType = MED_NONE; // issue 21199 - if ( nbElemsByGeomType.find( medType ) == nbElemsByGeomType.end()) - nbElemsByGeomType[ medType ] = 0; - int & order = nbElemsByGeomType[ medType ]; - - pair::iterator,bool> p; - pair::iterator,bool> p_no; - _noeud no; - no.coord.resize(space_dimension); - _maille ma( medType, nb_noeud ); - ma.sommets.resize(nb_noeud); - groupe.mailles.resize( nb_elements ); - - // lecture pour chaque maille des sommets et insertions - for ( i = 0; i < int(nb_elements); ++i ) - { - for (unsigned n = 0; n < nb_noeud; ++n, next() ) - { - if ( !more() ) { - INFOS_MED( " Error while reading elem nodes "); - return false; - } - no.number = getInt(); - p_no=medi->points.insert(make_pair(no.number, no)); - ma.sommets[n]=p_no.first; - } - ma.setOrdre( ++order ); - // on stocke dans le groupe un iterateur sur la maille - groupe.mailles[i] = medi->insert(ma); - } - } - } // loop on groups - - // set group names - for (i=0; i!=nb_objets_nommes; ++i) { - int grpID = indices_objets_nommes[i]; - _groupe & grp = medi->groupes[ grpID-1 ]; - if ( !grp.nom.empty() ) // a group has several names - { // create a group with subgroup grp and named grp.nom - medi->groupes.push_back(_groupe()); - medi->groupes.back().groupes.push_back( grpID ); - medi->groupes.back().nom = grp.nom; - } - grp.nom=objets_nommes[i]; - map::iterator it = strangeGroupType.find( grpID - 1 ); - if ( it != strangeGroupType.end() ) { -#ifdef _DEBUG - cout << "Skip " << grp.nom << " of not supported CASTEM type: " << it->second << endl; -#endif - //INFOS_MED( "Skip " << grp.nom << " of not supported CASTEM type: " << it->second ); - } - } - - }// Fin case PILE_SOUS_MAILLAGE - -#ifdef HAS_XDR - - // --------------------------------- - // --------------------------------- - - else if ( numero_pile == PILE_LREEL ) // PILE NUMERO 18 - { - if(_is_xdr) - { - for (int objet=0; objet!=nb_objets; ++objet) // pour chaque groupe - { - initIntReading(1); - int nb_vals = getInt(); - next(); - initDoubleReading(nb_vals); - for(i=0; i fixed_length ) - { - width = fixed_length; - } - else - { - width = remain_len; - } - initNameReading(1, width); - next(); - nb_char_tmp += width; - } - } - } - } // Fin case pile 29 - - // --------------------------------- - // --------------------------------- - - else if ( numero_pile == PILE_MODL ) // PILE NUMERO 38 - { - if(_is_xdr) - { - for (int objet=0; objet!=nb_objets; ++objet) // pour chaque groupe - { - // see wrmodl.eso - initIntReading(10); - int n1 = getInt() ; next(); - int nm2 = getInt() ; next(); - int nm3 = getInt() ; next(); - int nm4 = getInt() ; next(); - int nm5 = getInt() ; next(); - int n45 = getInt() ; next(); - /*int nm6 =*/ getInt() ; next(); - /*int nm7 =*/ getInt() ; next(); - next(); - next(); - int nm1 = n1 * n45; - int nm9 = n1 * 16; - for (initIntReading(nm1); more(); next()); - for (initIntReading(nm9); more(); next()); - for (initNameReading(nm5, 8); more(); next()); - for (initNameReading(nm2, 8); more(); next()); - for (initNameReading(nm3, 8); more(); next()); - for (initIntReading(nm4); more(); next()); - } - } - } // Fin case pile 38 - -#endif // HAS_XDR - - // --------------------------------- - // NODES - // --------------------------------- - - else if ( numero_pile == PILE_NOEUDS ) // PILE NUMERO 32 - { - getNextLine( ligne ); - std::vector place_noeuds; -#ifdef HAS_XDR - if(_is_xdr) - { - initIntReading(1); - nb_indices = getInt(); - next(); - } - else -#endif - nb_indices = atoi ( ligne ); - if (nb_indices != nb_objets) - { - INFOS_MED("Erreur de lecture dans enregistrement de pile " << - PILE_NOEUDS << DUMP_LINE_NB ); - return false; - } - - place_noeuds.resize(nb_objets); - for ( initIntReading( nb_objets ); more(); next() ) - place_noeuds[ index() ] = getInt(); - int max=(* std::max_element(place_noeuds.begin(),place_noeuds.end())); - - // numero_noeuds contient pour chacun des max noeuds qu'on va lire dans le case PILE_COORDONNEES - // son indice dans la connectivite du maillage. Cet indice correspond egalement a la cle du map - // medi->points ou l'on stocke les noeuds. - numero_noeuds.resize(max,-1); - for (unsigned i=0; i!=place_noeuds.size(); ++i) - numero_noeuds[place_noeuds[i]-1]=i+1; - } - - // --------------------------------------- - // COORDINATES - // --------------------------------------- - - else if ( numero_pile == PILE_COORDONNEES )// PILE NUMERO 33 - { - getNextLine( ligne ); - unsigned nb_reels; -#ifdef HAS_XDR - if(_is_xdr) - { - initIntReading(1); - nb_reels = getInt(); - next(); - } - else -#endif - nb_reels = atoi( ligne ); - // PROVISOIRE : certains fichier gibi n`ont - if (nb_reels < numero_noeuds.size()*(space_dimension)) { - INFOS_MED("Erreur de lecture dans enregistrement de pile " << - PILE_COORDONNEES << DUMP_LINE_NB ); - return false; - } - initDoubleReading( nb_reels ); - map< int, _noeud >::iterator pIt; - for (unsigned i=0; i!=numero_noeuds.size(); ++i) - { - // si le noeud est utilisé dans le maillage, - //on lit ses coordonnées et on les stocke dans la structure - if (( numero_noeuds[i] != -1 ) && - (( pIt = medi->points.find(numero_noeuds[i])) != medi->points.end())) - { - for (unsigned j=0; j!=space_dimension; ++j, next()) - pIt->second.coord[j] = getDouble(); -#ifdef HAS_XDR - if(_is_xdr) getDouble(); // skip density -#endif - next(); // on ne conserve pas la densite - } - else // sinon, on passe au noeud suivant - { - for (unsigned j=0; j!=space_dimension+1; ++j) -#ifdef HAS_XDR - { - if(_is_xdr) getDouble(); // skip ... -#endif - next(); -#ifdef HAS_XDR - } -#endif - } - } -#ifdef HAS_XDR - if(_is_xdr) - { - for(unsigned i=0; i!=nb_reels-numero_noeuds.size()*(space_dimension+1); ++i) - { - next(); // skip ... - } - } -#endif - } - - // --------------------------------------- - // NODE FIELDS - // --------------------------------------- - - else if ( numero_pile == PILE_NODES_FIELD && readFields ) // PILE NUMERO 2 - { - //vector< _fieldBase* > fields( nb_objets ); - node_fields.resize(nb_objets, (_fieldBase*)0); - for (int objet=0; objet!=nb_objets; ++objet) // pour chaque field - { - bool ignoreField = false; -#ifdef GIBI_READ_ONLY_NAMED_FIELD - ignoreField = !isNamedObject( objet+1, indices_objets_nommes ); - if ( ignoreField ) - INFOS_MED("Skip non-named field " << objet+1 << DUMP_LINE_NB); -#endif - - // EXAMPLE ( with no values ) - - // (1) 4 7 2 1 - // (2) -88 0 3 -89 0 1 -90 0 2 -91 - // (2) 0 1 - // (3) FX FY FZ FZ FX FY FLX - // (4) 0 0 0 0 0 0 0 - // (5) cree par muc pri - // (6) - // (7) 2 - - // (1): nb subcomponents, nb components(total), IFOUR, nb attributes - initIntReading( 4 ); - int i_sub, nb_sub = getInt(); next(); - int i_comp, total_nb_comp = getInt(); next(); - next(); // ignore IFOUR - int nb_attr = getInt(); -#ifdef HAS_XDR - if(_is_xdr) next(); -#endif - if ( nb_sub < 0 || total_nb_comp < 0 || nb_attr < 0 ) { - INFOS_MED("Error of field reading: wrong nb of components " - << nb_sub << " " << total_nb_comp << DUMP_LINE_NB); - return false; - } - // (2) loop on subcomponents of a field, for each read - // (a) support, (b) number of values and (c) number of components - vector support_ids( nb_sub ); - vector nb_values ( nb_sub ); - vector nb_comps ( nb_sub ); - int total_nb_values = 0; - initIntReading( nb_sub * 3 ); - for ( i_sub = 0; i_sub < nb_sub; ++i_sub ) - { - support_ids[ i_sub ] = -getInt(); next(); // (a) reference to support - if ( support_ids[ i_sub ] < 1 || support_ids[ i_sub ] > (int)medi->groupes.size() ) { - INFOS_MED("Error of field reading: wrong mesh reference "<< - support_ids[ i_sub ] << DUMP_LINE_NB ); - return false; - } - nb_values[ i_sub ] = getInt(); next(); // (b) nb points - total_nb_values += nb_values[ i_sub ]; - if ( nb_values[ i_sub ] < 0 ) { - INFOS_MED(" Wrong nb of points: " << nb_values[ i_sub ] << DUMP_LINE_NB ); - return false; - } - nb_comps[ i_sub ] = getInt(); next(); // (c) nb of components in i_sub - } - // create a field if there are values - _field* fdouble = 0; - if ( total_nb_values > 0 && !ignoreField ) - { - fdouble = new _field( MED_REEL64, nb_sub, total_nb_comp ); - medi->fields.push_back( node_fields[ objet ] = fdouble ); - } - // (3) component names - initNameReading( total_nb_comp, 4 ); - for ( i_sub = 0; i_sub < nb_sub; ++i_sub ) - { - // store support id and nb components of a sub - if ( fdouble ) - fdouble->_sub[ i_sub ].setData( nb_comps[ i_sub ], support_ids[ i_sub ] ); - for ( i_comp = 0; i_comp < nb_comps[ i_sub ]; ++i_comp, next() ) - { - ASSERT_MED( more() ); - // store component name - if ( fdouble ) - fdouble->_sub[ i_sub ].compName( i_comp ) = getName(); - } - } - // (4) nb harmonics ( ignored ) - for ( initIntReading( total_nb_comp ); more(); next() ) - ; - // (5) TYPE ( ignored ) - getNextLine( ligne ); -#ifdef HAS_XDR - if(_is_xdr) for (initNameReading(1, 71); more(); next()); -#endif - // (6) TITRE ( ignored ) - getNextLine( ligne ); -#ifdef HAS_XDR - if(_is_xdr) for (initNameReading(1, 71); more(); next()); -#endif - // (7) attributes ( ignored ) - for ( initIntReading( nb_attr ); more(); next() ) - ; - - for ( i_sub = 0; i_sub < nb_sub; ++i_sub ) - { - // loop on components: read values - initDoubleReading( nb_values[ i_sub ] * nb_comps[ i_sub ] ); - for ( i_comp = 0; i_comp < nb_comps[ i_sub ]; ++i_comp ) - { - vector* vals = 0; - if ( fdouble ) vals = & fdouble->addComponent( nb_values[ i_sub ] ); - for ( int i = 0; more() && i < nb_values[ i_sub ]; next(), ++i ) { - if ( vals ) (*vals)[ i ] = getDouble(); - } - } - } // loop on subcomponents of a field - - // set id of a group including all subs supports but only - // if all subs have the same components - if ( fdouble && fdouble->hasSameComponentsBySupport() ) - fdouble->_group_id = getGroupId( support_ids, medi ); - - } // end loop on field objects - - // set field names - setFieldNames( node_fields, objets_nommes, indices_objets_nommes ); - - } // Fin numero_pile == PILE_NODES_FIELD - - // ------------------------------------------------- - // FIELDS - // ------------------------------------------------- - - else if ( numero_pile == PILE_FIELD && readFields ) // PILE NUMERO 39 - { - // REAL EXAMPLE - - // (1) 1 2 6 16 - // (2) CARACTERISTIQUES - // (3) -15 317773 4 0 0 0 -2 0 3 - // (4) 317581 - // (5) 0 - // (6) 317767 317761 317755 317815 - // (7) YOUN NU H SIGY - // (8) REAL*8 REAL*8 REAL*8 REAL*8 - // (9) 1 1 0 0 - // (10) 2.00000000000000E+05 - // (11) 1 1 0 0 - // (12) 3.30000000000000E-01 - // (13) 1 1 0 0 - // (14) 1.00000000000000E+04 - // (15) 6 706 0 0 - // (16) 1.00000000000000E+02 1.00000000000000E+02 1.00000000000000E+02 - // (17) 1.00000000000000E+02 1.00000000000000E+02 1.00000000000000E+02 - // (18) ... - - //vector< _fieldBase* > fields( nb_objets, (_fieldBase*)0 ); - cell_fields.resize(nb_objets, (_fieldBase*)0); - for (int objet=0; objet!=nb_objets; ++objet) // pour chaque field - { - bool ignoreField = false; -#ifdef GIBI_READ_ONLY_NAMED_FIELD - ignoreField = !isNamedObject( objet+1, indices_objets_nommes ); - if ( ignoreField ) - INFOS_MED("Skip non-named field " << objet+1 << DUMP_LINE_NB); -#endif - initIntReading( 4 ); - int i_sub, nb_sub = getInt(); // (1) 2 6 - if ( nb_sub < 1 ) { - INFOS_MED("Error of field reading: wrong nb of subcomponents " << - nb_sub << DUMP_LINE_NB ); - return false; - } - next(); next(); next(); // skip (1) <nb_sub> 2 6 - int title_length = getInt(); // <title length> -#ifdef HAS_XDR - if(_is_xdr) next(); -#endif - string description; - if ( title_length ) { -#ifdef HAS_XDR - if(_is_xdr) - { - initNameReading(1, title_length); - description = getName(); - next(); - } - else - { -#endif - getNextLine( ligne ); // (2) title - const int len = 72; // line length - // title is right justified - description = string(ligne + len - title_length, title_length); - } -#ifdef HAS_XDR - } -#endif - // look for a line starting with '-' : <reference to support> -#ifdef HAS_XDR - if(_is_xdr) - { - initIntReading( nb_sub * 9 ); - } - else - { -#endif - do { - initIntReading( nb_sub * 9 ); - } while ( getInt() >= 0 ); -#ifdef HAS_XDR - } -#endif - int total_nb_comp = 0; - vector<int> support_ids( nb_sub ), nb_comp( nb_sub ); - for ( i_sub = 0; i_sub < nb_sub; ++i_sub ) - { // (3) - support_ids[ i_sub ] = -getInt(); next(); // <reference to support> - next(); // ignore <address> - nb_comp [ i_sub ] = getInt(); next(); // <nb of components in the sub> - for ( i = 0; i < 6; ++i ) // ignore 6 ints, in example 0 0 0 -2 0 3 - next(); - if ( support_ids[ i_sub ] < 1 || support_ids[ i_sub ] > (int)medi->groupes.size() ) { - INFOS_MED("Error of field reading: wrong mesh reference "<< - support_ids[ i_sub ] << DUMP_LINE_NB ); - return false; - } - if ( nb_comp[ i_sub ] < 0 /*1*/ ) { // [SALOME platform 0019886] - INFOS_MED("Error of field reading: wrong nb of components " << - nb_comp[ i_sub ] << DUMP_LINE_NB ); - return false; - } - total_nb_comp += nb_comp[ i_sub ]; - } - for ( initNameReading( nb_sub, 17 ); more(); next() ) - ; // (4) dummy strings - for ( initNameReading( nb_sub ); more(); next() ) - ; // (5) dummy strings - - // loop on subcomponents of a field, each of which refers to - // a certain support and has its own number of components; - // read component values - _field<double>* fdouble = 0; - _field<int>* fint = 0; - _fieldBase * fbase = 0; - for ( i_sub = 0; i_sub < nb_sub; ++ i_sub ) - { - vector<string> comp_names( nb_comp[ i_sub ]), comp_type( nb_comp[ i_sub ]); - for ( initIntReading( nb_comp[ i_sub ] ); more(); next() ) - ; // (6) nb_comp addresses of MELVAL structure - - // (7) component names - for ( initNameReading( nb_comp[ i_sub ] ); more(); next() ) - comp_names[ index() ] = getName(); - - // (8) component type - for ( initNameReading( nb_comp[ i_sub ], 17 ); more(); next() ) { // 17 is name width - comp_type[ index() ] = getName(); - // component types must be the same - if ( index() > 0 && comp_type[ index() ] != comp_type[ index() - 1] ) { - INFOS_MED( "Error of field reading: diff component types <" - << comp_type[ index() ] << "> != <" << comp_type[ index() - 1 ] - << ">" << DUMP_LINE_NB ); - return false; - } - } - // now type is known, create a field, one for all subs - bool isReal = (nb_comp[i_sub] > 0) ? (comp_type[0] == "REAL*8") : true; - if ( !ignoreField && !fbase && total_nb_comp ) { - if ( !isReal ) { - fbase = fint = new _field<int>( MED_INT32, nb_sub, total_nb_comp ); - INFOS_MED( "Warning: read NOT REAL field, type <" << comp_type[0] << ">" - << DUMP_LINE_NB); - } - else - fbase = fdouble = new _field<double>( MED_REEL64, nb_sub, total_nb_comp ); - medi->fields.push_back( cell_fields[ objet ] = fbase ); // medi->fields is a std::list - } - // store support id and nb components of a sub - if ( fbase ) { - fbase->_sub[ i_sub ].setData( nb_comp[ i_sub ], support_ids[ i_sub ]); - fbase->_description = description; - } - // loop on components: read values - for ( int i_comp = 0; i_comp < nb_comp[ i_sub ]; ++i_comp ) - { - // (9) nb of values -#ifdef HAS_XDR - if(_is_xdr) initIntReading( 4 ); - else initIntReading( 2 ); -#else - initIntReading( 2 ); -#endif - int nb_val_by_elem = getInt(); next(); - int nb_values = getInt(); -#ifdef HAS_XDR - if(_is_xdr) { next(); next(); next(); } -#endif - fbase->_sub[ i_sub ]._nb_gauss[ i_comp ] = nb_val_by_elem; - // (10) values - nb_values *= nb_val_by_elem; - if ( fbase ) { - if ( isReal ) { - vector<double> & vals = fdouble->addComponent( nb_values ); - for ( initDoubleReading( nb_values ); more(); next()) { - vals[ index() ] = getDouble(); - } - } - else { - vector<int> & vals = fint->addComponent( nb_values ); - for ( initIntReading( nb_values ); more(); next() ) { - vals[ index() ] = getInt(); - } - } - // store component name - fbase->_sub[ i_sub ].compName( i_comp ) = comp_names[ i_comp ]; - } - else { - for ( isReal ? initDoubleReading( nb_values ) : initIntReading( nb_values ); - more(); - next() ) ; - } - } - } // loop on subcomponents of a field - - // set id of a group including all sub supports but only - // if all subs have the same nb of components - if ( fbase && fbase->hasSameComponentsBySupport() ) - fbase->_group_id = getGroupId( support_ids, medi ); - - } // end loop on field objects - - // set field names - setFieldNames( cell_fields, objets_nommes, indices_objets_nommes ); - - } // numero_pile == PILE_FIELD && readFields - - // --------------------------------------- - // MED NAMES - // --------------------------------------- - - // IMP 0020434: mapping GIBI names to MED names - else if (numero_pile == PILE_TABLES) - { - const char * table_med_mail = "MED_MAIL"; - const char * table_med_cham = "MED_CHAM"; - const char * table_med_comp = "MED_COMP"; - - int table_med_mail_id = -1; - int table_med_cham_id = -1; - int table_med_comp_id = -1; - - for (int iname = 0; iname < nb_objets_nommes; iname++) { - if (strcmp(objets_nommes[iname].c_str(), table_med_mail) == 0) { - table_med_mail_id = indices_objets_nommes[iname]; - } - else if (strcmp(objets_nommes[iname].c_str(), table_med_cham) == 0) { - table_med_cham_id = indices_objets_nommes[iname]; - } - else if (strcmp(objets_nommes[iname].c_str(), table_med_comp) == 0) { - table_med_comp_id = indices_objets_nommes[iname]; - } - else { - } - } - //if (noms_med_id < 0) continue; - if (table_med_mail_id < 0 && table_med_cham_id < 0 && table_med_comp_id < 0) -#ifdef HAS_XDR - if(!_is_xdr) -#endif - continue; - - for (int itable = 1; itable <= nb_objets; itable++) { - // read tables "MED_MAIL", "MED_CHAM" and "MED_COMP", that keeps correspondence - // between GIBI names (8 symbols if any) and MED names (possibly longer) - initIntReading(1); - int nb_table_vals = getInt(); next(); - if (nb_table_vals < 0) { - INFOS_MED("Erreur de lecture dans enregistrement de pile " << - PILE_TABLES << DUMP_LINE_NB ); - return false; - } - - int name_i_med_pile; - initIntReading(nb_table_vals); - for (int i = 0; i < nb_table_vals/4; i++) - { - if (itable == table_med_mail_id || - itable == table_med_cham_id || - itable == table_med_comp_id) - { - nameGIBItoMED name_i; - name_i_med_pile = getInt(); next(); - name_i.med_id = getInt(); next(); - name_i.gibi_pile = getInt(); next(); - name_i.gibi_id = getInt(); next(); - - if (name_i_med_pile != PILE_STRINGS) { - // error: med(long) names are always kept in PILE_STRINGS - } - - if (itable == table_med_mail_id) { - if (name_i.gibi_pile != PILE_SOUS_MAILLAGE) { - // error: must be PILE_SOUS_MAILLAGE - } - listGIBItoMED_mail.push_back(name_i); - } - else if (itable == table_med_cham_id) { - if (name_i.gibi_pile != PILE_FIELD && - name_i.gibi_pile != PILE_NODES_FIELD) { - // error: must be PILE_FIELD or PILE_NODES_FIELD - } - listGIBItoMED_cham.push_back(name_i); - } - else if (itable == table_med_comp_id) { - if (name_i.gibi_pile != PILE_STRINGS) { - // error: gibi(short) names of components are kept in PILE_STRINGS - } - listGIBItoMED_comp.push_back(name_i); - } - else { - } - } - else - { - // pass table - next(); next(); next(); next(); - } - } - } // for (int itable = 0; itable < nb_objets; itable++) - } // numero_pile == PILE_TABLES - - // --------------------------------------- - // MED NAMES - // --------------------------------------- - - // IMP 0020434: mapping GIBI names to MED names - else if (numero_pile == PILE_STRINGS) - { - initIntReading(2); - int stringLen = getInt(); next(); - int nbSubStrings = getInt(); next(); - if (nbSubStrings != nb_objets) { - // error - } - string aWholeString; -#ifdef HAS_XDR - if(_is_xdr) - { - const int fixedLength = 71; - while ((int)aWholeString.length() < stringLen) { - int remainLen = stringLen - aWholeString.length(); - int len; - if ( remainLen > fixedLength ) - { - len = fixedLength; - } - else - { - len = remainLen; - } - initNameReading(1, len); - aWholeString += getName(); - next(); - } - } - else - { -#endif - string aCurrLine; - const int fixedLength = 71; - while ((int)aWholeString.length() < stringLen) { - getNextLine( ligne ); - int remainLen = stringLen - aWholeString.length(); - if ( remainLen > fixedLength ) - { - aWholeString += ligne + 1; - } - else - { - aWholeString += ligne + ( 72 - remainLen ); - } - } -#ifdef HAS_XDR - } -#endif - int prevOffset = 0; - int currOffset = 0; - initIntReading(nbSubStrings); - for (int istr = 1; istr <= nbSubStrings; istr++, next()) { - currOffset = getInt(); - // fill mapStrings - mapStrings[istr] = aWholeString.substr(prevOffset, currOffset - prevOffset); - prevOffset = currOffset; - } - } - - else if ( numero_pile >= PILE_LAST_READABLE ) - break; // stop file reading - - } // Fin case ENREG_TYPE_2 -#ifdef HAS_XDR - else if (numero_enregistrement == ENREG_TYPE_5 ) - { - if(_is_xdr) - { - break; - } - } -#endif -#ifdef HAS_XDR - else - { - if(_is_xdr) - { - cout << "XDR : ENREGISTREMENT DE TYPE " << numero_enregistrement << " not implemented !!!" << endl; - throw MEDEXCEPTION("XDR : ENREGISTREMENT DE TYPE not implemented !!!"); - } - } -#endif - } // fin de la boucle while de lecture externe - - // IMP 0020434: mapping GIBI names to MED names - // set med names to objects (mesh, fields, support, group or other) - if (listGIBItoMED_mail.size() > 0) { - set<int> treatedGroups; - list<nameGIBItoMED>::iterator itGIBItoMED = listGIBItoMED_mail.begin(); - for (; itGIBItoMED != listGIBItoMED_mail.end(); itGIBItoMED++) { - if ( (int)medi->groupes.size() < itGIBItoMED->gibi_id ) continue; - _groupe & grp = medi->groupes[itGIBItoMED->gibi_id - 1]; - // if there are several names for grp then the 1st name is the name - // of grp and the rest ones are names of groups referring grp (issue 0021311) - const bool isRefName = !treatedGroups.insert( itGIBItoMED->gibi_id ).second; - if ( !isRefName ) - grp.nom = mapStrings[ itGIBItoMED->med_id ]; - else - for ( unsigned i = 0; i < grp.refNames.size(); ++i ) - if ( grp.refNames[i].empty() ) - grp.refNames[i] = mapStrings[ itGIBItoMED->med_id ]; - } // iterate on listGIBItoMED_mail - } - if (listGIBItoMED_cham.size() > 0) { - list<nameGIBItoMED>::iterator itGIBItoMED = listGIBItoMED_cham.begin(); - for (; itGIBItoMED != listGIBItoMED_cham.end(); itGIBItoMED++) { - if (itGIBItoMED->gibi_pile == PILE_FIELD) { - cell_fields[itGIBItoMED->gibi_id - 1]->_name = mapStrings[itGIBItoMED->med_id]; - } - else if (itGIBItoMED->gibi_pile == PILE_NODES_FIELD) { - node_fields[itGIBItoMED->gibi_id - 1]->_name = mapStrings[itGIBItoMED->med_id]; - } - else { - } - } // iterate on listGIBItoMED_cham - } - if (listGIBItoMED_comp.size() > 0) { - list<nameGIBItoMED>::iterator itGIBItoMED = listGIBItoMED_comp.begin(); - for (; itGIBItoMED != listGIBItoMED_comp.end(); itGIBItoMED++) - { - string medName = mapStrings[itGIBItoMED->med_id]; - string gibiName = mapStrings[itGIBItoMED->gibi_id]; - - bool name_found = false; - for ( int isNodal = 0; isNodal < 2 && !name_found; ++isNodal ) - { - vector<_fieldBase*> & fields = isNodal ? node_fields : cell_fields; - for ( unsigned ifi = 0; ifi < fields.size() && !name_found; ifi++) - { - if (medName.find( fields[ifi]->_name + "." ) == 0 ) { - std::vector<_fieldBase::_sub_data>& aSubDs = fields[ifi]->_sub; - int nbSub = aSubDs.size(); - for (int isu = 0; isu < nbSub; isu++) { - for (int ico = 0; ico < aSubDs[isu].nbComponents(); ico++) { - if (aSubDs[isu].compName(ico) == gibiName) { - string medNameCompo = medName.substr( fields[ifi]->_name.size() + 1 ); - fields[ifi]->_sub[isu].compName(ico) = medNameCompo; - } - } - } - } - } - } - } // iterate on listGIBItoMED_comp - } - - // check if all needed piles present - if ( donePiles.find( PILE_SOUS_MAILLAGE ) != donePiles.end() ) - { - if (donePiles.find( PILE_NOEUDS ) == donePiles.end() ) { - INFOS_MED( " Missing pile " << PILE_NOEUDS ); - return false; - } - if (donePiles.find( PILE_COORDONNEES ) == donePiles.end()) { - INFOS_MED( " Missing pile " << PILE_COORDONNEES ); - return false; - } - } - - END_OF_MED(LOC); - return true; -} - -GIBI_MESH_DRIVER::GIBI_MESH_DRIVER(): - GENDRIVER(GIBI_DRIVER), - _mesh(( GMESH *) NULL), - _meshName("") -{ - MESSAGE_MED("GIBI_MESH_DRIVER()"); -} - -GIBI_MESH_DRIVER::GIBI_MESH_DRIVER(const string & fileName, - GMESH * ptrMesh, - MED_EN::med_mode_acces accessMode): - GENDRIVER(fileName, accessMode, GIBI_DRIVER), - _mesh(ptrMesh) -{ - MESSAGE_MED( "GIBI_MESH_DRIVER(" << fileName <<","<<accessMode ); - // mesh name construction from fileName - const string ext=".sauv"; // expected extension - int pos=fileName.find(ext,0); - int pos1=fileName.rfind('/'); - if ( pos < 0 || pos >= (int)fileName.size() ) pos = fileName.size(); -#ifdef WIN32 - if ( pos1 < 0 || pos1 >= (int)fileName.size() ) pos1 = fileName.rfind('\\'); -#endif - if ( pos1 < 0 || pos1 >= (int)fileName.size() ) pos1 = -1; - _meshName = string(fileName,pos1+1,pos-pos1-1); //get rid of directory & extension - SCRUTE_MED(_meshName); -} - -GIBI_MESH_DRIVER::GIBI_MESH_DRIVER(const GIBI_MESH_DRIVER & driver): - GENDRIVER(driver), - _mesh(driver._mesh), - _meshName(driver._meshName) -{ - MESSAGE_MED("GIBI_MESH_DRIVER(const GIBI_MESH_DRIVER & driver)"); -} - -GIBI_MESH_DRIVER::~GIBI_MESH_DRIVER() -{ - MESSAGE_MED("~GIBI_MESH_DRIVER()"); -} -void GIBI_MESH_DRIVER::setMeshName(const string & meshName) { _meshName = meshName; } -string GIBI_MESH_DRIVER::getMeshName() const { return _meshName; } - - -//---------------------------------- RDONLY PART ------------------------------------------ - -GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(): - GIBI_MESH_DRIVER(), - _File (-1),_start(0L),_ptr (0L),_eptr (0L) -{ -} -GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(const string & fileName,MESH * ptrMesh): - GIBI_MESH_DRIVER(fileName,ptrMesh,RDONLY), - _File (-1),_start(0L),_ptr (0L),_eptr (0L) -{ - MESSAGE_MED("GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER" - "(const string & fileName, MESH * ptrMesh) has been created, " - << fileName << ", " << RDONLY); -} -GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(const GIBI_MESH_RDONLY_DRIVER & driver): - GIBI_MESH_DRIVER(driver), - _File (-1),_start(0L),_ptr (0L),_eptr (0L) -{ -} - -GIBI_MESH_RDONLY_DRIVER::~GIBI_MESH_RDONLY_DRIVER() -{ - const char* LOC = "~GIBI_MESH_RDONLY_DRIVER()"; - BEGIN_OF_MED(LOC); - if (_File >= 0) - { -#ifdef HAS_XDR - if(_is_xdr) - { - xdr_destroy((XDR*)_xdrs); - free((XDR*)_xdrs); - fclose(_xdrs_file); - } -#endif - ::close (_File); - if (_start != 0L) - delete [] _start; - } - MESSAGE_MED("GIBI_MESH_RDONLY_DRIVER::~GIBI_MESH_RDONLY_DRIVER() has been destroyed"); -} -GENDRIVER * GIBI_MESH_RDONLY_DRIVER::copy(void) const -{ - return new GIBI_MESH_RDONLY_DRIVER(*this); -} - -//======================================================================= -//function : open -//purpose : -//======================================================================= - -const int GIBI_MaxOutputLen = 150; -const int GIBI_BufferSize = 16184; // for non-stream input - -void GIBI_MESH_RDONLY_DRIVER::open() - // throw (MEDEXCEPTION) -{ - if( _status == MED_OPENED ) - return; - - const char * LOC = "GIBI_MESH_RDONLY_DRIVER::open()"; - BEGIN_OF_MED(LOC); - -// MED_EN::med_mode_acces aMode = getAccessMode(); -// if ( aMode != MED_EN::MED_LECT && aMode != MED_EN::MED_REMP ) -// throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << " Bad file mode access ! " << aMode)); - -#ifdef WIN32 - _File = ::_open (_fileName.c_str(), _O_RDONLY|_O_BINARY); -#else - _File = ::open (_fileName.c_str(), O_RDONLY); -#endif - if (_File >= 0) - { - _start = new char [GIBI_BufferSize]; - _ptr = _start; - _eptr = _start; - _status = MED_OPENED; - _lineNb = 0; - } - else - { - _status = MED_CLOSED; - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Could not open file "<<_fileName - << " fd: " << _File)); - } - - // xdr - -#ifdef HAS_XDR - _is_xdr = false; - _xdrs_file = fdopen(_File, "r"); - _xdrs = (XDR *)malloc(sizeof(XDR)); - - xdrstdio_create((XDR*)_xdrs, _xdrs_file, XDR_DECODE); - - const int maxsize = 10; - char icha[maxsize+1]; - char *icha2=icha; - bool_t xdr_test = xdr_string((XDR*)_xdrs, &icha2, maxsize); - if(xdr_test) - { - icha[maxsize] = '\0'; - if(!strcmp(icha, "CASTEM XDR")) - { - _is_xdr = true; - } - } - - if(! _is_xdr) - { - xdr_destroy((XDR*)_xdrs); - free((XDR*)_xdrs); - fclose(_xdrs_file); -#ifdef WIN32 - _File = ::_open (_fileName.c_str(), _O_RDONLY|_O_BINARY); -#else - ::close (_File); // ? needed ? - _File = ::open (_fileName.c_str(), O_RDONLY); -#endif - } -#endif - - END_OF_MED(LOC); -} - -//======================================================================= -//function : close -//purpose : -//======================================================================= - -void GIBI_MESH_RDONLY_DRIVER::close() -{ - const char* LOC = "GIBI_MESH_DRIVER::close() "; - BEGIN_OF_MED(LOC); - if ( _status == MED_OPENED) { - if (_File >= 0) { -#ifdef HAS_XDR - if(_is_xdr) - { - xdr_destroy((XDR*)_xdrs); - free((XDR*)_xdrs); - fclose(_xdrs_file); - } -#endif - ::close (_File); - if (_start != 0L) - delete [] _start; - _File = -1; - } - _status = MED_CLOSED; - } - END_OF_MED(LOC); -} - -//======================================================================= -//function : getLine -//purpose : -//======================================================================= - -bool GIBI_MESH_RDONLY_DRIVER::getLine(char* & aLine) -{ -#ifdef HAS_XDR - if (_is_xdr) return true; -#endif - bool aResult = true; - // Check the state of the buffer; - // if there is too little left, read the next portion of data - int nBytesRest = _eptr - _ptr; - if (nBytesRest < GIBI_MaxOutputLen) - { - if (nBytesRest > 0) { - //memcpy (_start, _ptr, nBytesRest); - char* tmpBuf = new char [nBytesRest]; - memcpy (tmpBuf, _ptr, nBytesRest); - memcpy (_start, tmpBuf, nBytesRest); - delete [] tmpBuf; - } else - nBytesRest = 0; - _ptr = _start; - const int nBytesRead = ::read (_File, - &_start [nBytesRest], - GIBI_BufferSize - nBytesRest); - nBytesRest += nBytesRead; - _eptr = &_start [nBytesRest]; - } - // Check the buffer for the end-of-line - char * ptr = _ptr; - while (~0) - { - // Check for end-of-the-buffer, the ultimate criterion for termination - if (ptr >= _eptr) - { - if (nBytesRest <= 0) - aResult = false; - else - _eptr[-1] = '\0'; - break; - } - // seek the line-feed character - if (ptr[0] == '\n') - { - if (ptr[-1] == '\r') - ptr[-1] = '\0'; - ptr[0] = '\0'; - ++ptr; - break; - } - ++ptr; - } - // Output the result - aLine = _ptr; - _ptr = ptr; - _lineNb++; - - return aResult; -} - -//======================================================================= -//function : initNameReading -//purpose : -//======================================================================= - -void GIBI_MESH_RDONLY_DRIVER::initNameReading(int nbValues, int width) -{ -#ifdef HAS_XDR - if(_is_xdr) - { - _xdr_kind = _xdr_kind_char; - if(nbValues) - { - unsigned int nels = nbValues*width; - _xdr_cvals = (char*)malloc((nels+1)*sizeof(char)); - xdr_string((XDR*)_xdrs, &_xdr_cvals, nels); - _xdr_cvals[nels] = '\0'; - } - } -#endif - init( nbValues, 72 / ( width + 1 ), width, 1 ); -} - -//======================================================================= -//function : initIntReading -//purpose : -//======================================================================= - -void GIBI_MESH_RDONLY_DRIVER::initIntReading(int nbValues) -{ -#ifdef HAS_XDR - if(_is_xdr) - { - _xdr_kind = _xdr_kind_int; - if(nbValues) - { - unsigned int nels = nbValues; - unsigned int actual_nels; - _xdr_ivals = (int*)malloc(nels*sizeof(int)); - xdr_array((XDR*)_xdrs, (char **)&_xdr_ivals, &actual_nels, nels, sizeof(int), (xdrproc_t)xdr_int); - } - } -#endif - init( nbValues, 10, 8 ); -} - -//======================================================================= -//function : initDoubleReading -//purpose : -//======================================================================= - -void GIBI_MESH_RDONLY_DRIVER::initDoubleReading(int nbValues) -{ -#ifdef HAS_XDR - if(_is_xdr) - { - _xdr_kind = _xdr_kind_double; - if(nbValues) - { - unsigned int nels = nbValues; - unsigned int actual_nels; - _xdr_dvals = (double*)malloc(nels*sizeof(double)); - xdr_array((XDR*)_xdrs, (char **)&_xdr_dvals, &actual_nels, nels, sizeof(double), (xdrproc_t)xdr_double); - } - } -#endif - init( nbValues, 3, 22 ); -} - -//======================================================================= -//function : init -//purpose : -//======================================================================= - -void GIBI_MESH_RDONLY_DRIVER::init( int nbToRead, int nbPosInLine, int width, int shift ) -{ -#ifdef HAS_XDR - if(_is_xdr) - { - if(_iRead < _nbToRead) - { - cout << "_iRead, _nbToRead : " << _iRead << " " << _nbToRead << endl; - cout << "Unfinished iteration before new one !" << endl; - throw MEDEXCEPTION("Unfinished iteration before new one !"); - } - } -#endif - _nbToRead = nbToRead; - _nbPosInLine = nbPosInLine; - _width = width; - _shift = shift; - _iPos = _iRead = 0; - if ( _nbToRead ) { - getNextLine( _curPos ); - _curPos = _curPos + _shift; - } - else - _curPos = 0; -#ifdef HAS_XDR - if(_is_xdr && (_xdr_kind == _xdr_kind_char)) - _curPos = _xdr_cvals; -#endif -} - -//======================================================================= -//function : more -//purpose : -//======================================================================= - -bool GIBI_MESH_RDONLY_DRIVER::more() const -{ - bool result = false; - if(_iRead < _nbToRead) - { - if(_curPos) result = true; -#ifdef HAS_XDR - if(_is_xdr) result = true; -#endif - } - return result; -} - -//======================================================================= -//function : next -//purpose : line getting -//======================================================================= - -void GIBI_MESH_RDONLY_DRIVER::next() -{ - if ( !more() ) throw MEDEXCEPTION(LOCALIZED("!more()")); - ++_iRead; - ++_iPos; - if ( _iRead < _nbToRead ) { - if ( _iPos >= _nbPosInLine ) { - getNextLine( _curPos ); - _curPos = _curPos + _shift; - _iPos = 0; - } - else - _curPos = _curPos + _width + _shift; -#ifdef HAS_XDR - if(_is_xdr && (_xdr_kind == _xdr_kind_char)) - { - _curPos = _xdr_cvals + _iRead*_width; - } -#endif - } - else - { -#ifdef HAS_XDR - if(_is_xdr) - { - if(_xdr_kind == _xdr_kind_char) free(_xdr_cvals); - if(_xdr_kind == _xdr_kind_int) free(_xdr_ivals); - if(_xdr_kind == _xdr_kind_double) free(_xdr_dvals); - _xdr_kind = _xdr_kind_null; - } -#endif - _curPos = 0; - } -} - -//======================================================================= -//function : getName -//purpose : names reading -//======================================================================= - -string GIBI_MESH_RDONLY_DRIVER::getName() const -{ - int len = _width; - while (( _curPos[len-1] == ' ' || _curPos[len-1] == 0) && len > 0 ) - len--; - return string( _curPos, len ); -} - -//======================================================================= -//function : getInt -//purpose : int reading -//======================================================================= - -int GIBI_MESH_RDONLY_DRIVER::getInt() const -{ -#ifdef HAS_XDR - if(_is_xdr) - { - if(_iRead < _nbToRead) - { - return _xdr_ivals[_iRead]; - } - else - { - int result; - xdr_int((XDR*)_xdrs, &result); - return result; - } - } -#endif - // fix for two glued ints (issue 0021009): - // Line nb | File contents - // ------------------------------------------------------------------------------------ - // 53619905 | 1 2 6 8 - // 53619906 | SCALAIRE - // 53619907 | -63312600499 1 0 0 0 -2 0 2 - // where -63312600499 is actualy -633 and 12600499 - char hold=_curPos[_width]; - _curPos[_width] = '\0'; - int result = atoi(str()); - _curPos[_width] = hold; - return result; - //return atoi(str()); -} - -//======================================================================= -//function : getFloat -//purpose : float reading -//======================================================================= - -float GIBI_MESH_RDONLY_DRIVER::getFloat() const -{ -#ifdef HAS_XDR - if(_is_xdr) - { - float result; - xdr_float((XDR*)_xdrs, &result); - return result; - } -#endif - return getDouble(); -} - -//======================================================================= -//function : getDouble -//purpose : double reading -//======================================================================= - -double GIBI_MESH_RDONLY_DRIVER::getDouble() const -{ -#ifdef HAS_XDR - if(_is_xdr) - { - if(_iRead < _nbToRead) - { - return _xdr_dvals[_iRead]; - } - else - { - double result; - xdr_double((XDR*)_xdrs, &result); - return result; - } - } -#endif - - //return atof(str()); - - std::string aStr (str()); - - // Correction 1: add missing 'E' specifier - int aPosStart = aStr.find_first_not_of(" \t"); - if (aPosStart < (int)aStr.length()) { - int aPosSign = aStr.find_first_of("+-", aPosStart + 1); // pass the leading symbol, as it can be a sign - if (aPosSign < (int)aStr.length()) { - if (aStr[aPosSign - 1] != 'e' && aStr[aPosSign - 1] != 'E') - aStr.insert(aPosSign, "E", 1); - } - } - - // Correction 2: set "C" numeric locale to read numbers - // with dot decimal point separator, as it is in SAUVE files - //char* aCurLocale = setlocale(LC_NUMERIC, 0); - std::string aCurLocale = setlocale(LC_NUMERIC, 0); - setlocale(LC_NUMERIC, "C"); - double ret = atof(aStr.data()); - //setlocale(LC_NUMERIC, aCurLocale); - setlocale(LC_NUMERIC, aCurLocale.data()); - - return ret; -} - -//======================================================================= -//function : read -//purpose : -//======================================================================= - -void GIBI_MESH_RDONLY_DRIVER::read(void) throw (MEDEXCEPTION) -{ - const char * LOC = "_GIBI_RDONLY_DRIVER::read() : "; - BEGIN_OF_MED(LOC); - - if (_status!=MED_OPENED) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName << " is : " - << " (the file is not opened)." )); - if ( ! _mesh->isEmpty() ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Mesh object not empty : can't fill it!")); - - _intermediateMED medi; - try { - if ( readFile( &medi, false )) { - // impression résultats - MESSAGE_MED(LOC << "GIBI_MESH_RDONLY_DRIVER::read : RESULTATS STRUCTURE INTERMEDIAIRES : "); - MESSAGE_MED(LOC << medi ); - - fillMesh( &medi ); - updateSupports(); // create families from groups etc. - } - } - catch (MEDEXCEPTION &ex) - { - INFOS_MED( ex.what() ); - } - END_OF_MED(LOC); -} - -//======================================================================= -//function : getReverseVector -//purpose : -//======================================================================= - -static void getReverseVector (const medGeometryElement type, - vector<pair<int,int> > & swapVec ) -{ - const char* LOC = "void getReverseVector()"; - BEGIN_OF_MED(LOC); - swapVec.clear(); - - switch ( type ) { - case MED_TETRA4: - swapVec.resize(1); - swapVec[0] = make_pair( 1, 2 ); - break; - case MED_PYRA5: - swapVec.resize(1); - swapVec[0] = make_pair( 1, 3 ); - break; - case MED_PENTA6: - swapVec.resize(2); - swapVec[0] = make_pair( 1, 2 ); - swapVec[1] = make_pair( 4, 5 ); - break; - case MED_HEXA8: - swapVec.resize(2); - swapVec[0] = make_pair( 1, 3 ); - swapVec[1] = make_pair( 5, 7 ); - break; - case MED_TETRA10: - swapVec.resize(3); - swapVec[0] = make_pair( 1, 2 ); - swapVec[1] = make_pair( 4, 6 ); - swapVec[2] = make_pair( 8, 9 ); - break; - case MED_PYRA13: - swapVec.resize(4); - swapVec[0] = make_pair( 1, 3 ); - swapVec[1] = make_pair( 5, 8 ); - swapVec[2] = make_pair( 6, 7 ); - swapVec[3] = make_pair( 10, 12 ); - break; - case MED_PENTA15: - swapVec.resize(4); - swapVec[0] = make_pair( 1, 2 ); - swapVec[1] = make_pair( 4, 5 ); - swapVec[2] = make_pair( 6, 8 ); - swapVec[3] = make_pair( 9, 11 ); - break; - case MED_HEXA20: - swapVec.resize(7); - swapVec[0] = make_pair( 1, 3 ); - swapVec[1] = make_pair( 5, 7 ); - swapVec[2] = make_pair( 8, 11 ); - swapVec[3] = make_pair( 9, 10 ); - swapVec[4] = make_pair( 12, 15 ); - swapVec[5] = make_pair( 13, 14 ); - swapVec[6] = make_pair( 17, 19 ); - break; -// case MED_SEG3: no need to reverse edges -// swapVec.resize(1); -// swapVec[0] = make_pair( 1, 2 ); -// break; - case MED_TRIA6: - swapVec.resize(2); - swapVec[0] = make_pair( 1, 2 ); - swapVec[1] = make_pair( 3, 5 ); - break; - case MED_QUAD8: - swapVec.resize(3); - swapVec[0] = make_pair( 1, 3 ); - swapVec[1] = make_pair( 4, 7 ); - swapVec[2] = make_pair( 5, 6 ); - break; - default:; - } - END_OF_MED(LOC); -} - -//======================================================================= -//function : reverse -//purpose : inverse element orientation using vector of indices to swap -//======================================================================= - -static void reverse(const _maille & aMaille, const vector<pair<int,int> > & swapVec ) -{ - _maille* ma = (_maille*) & aMaille; - for ( unsigned i = 0; i < swapVec.size(); ++i ) { - std::swap( ma->sommets[ swapVec[i].first ], - ma->sommets[ swapVec[i].second ]); - } - if ( swapVec.empty() ) - ma->reverse = true; - else - ma->reverse = false; -} - -//======================================================================= -//function : getGibi2MedConnectivity -//purpose : return array of indices to transform GIBI connectivity to MED one -//======================================================================= - -static const int * getGibi2MedConnectivity( const medGeometryElement type ) -{ - static vector<const int*> conn; - static int hexa20 [] = {0,6,4,2, 12,18,16,14, 7,5,3,1, 19,17,15,13, 8,11,10,9}; - static int penta15[] = {0,2,4, 9,11,13, 1,3,5, 10,12,14, 6,8,7}; - static int pyra13 [] = {0,2,4,6, 12, 1,3,5,7, 8,9,10,11}; - static int tetra10[] = {0,2,4, 9, 1,3,5, 6,7,8}; - static int quad8 [] = {0,2,4,6, 1,3,5,7}; - static int tria6 [] = {0,2,4, 1,3,5}; - static int seg3 [] = {0,2,1}; - if ( conn.empty() ) { - conn.resize( MED_HEXA20 + 1, 0 ); - conn[ MED_HEXA20 ] = hexa20; - conn[ MED_PENTA15] = penta15; - conn[ MED_PYRA13 ] = pyra13; - conn[ MED_TETRA10] = tetra10; - conn[ MED_SEG3 ] = seg3; - conn[ MED_TRIA6 ] = tria6; - conn[ MED_QUAD8 ] = quad8; - } - return conn[ type ]; -} - -//======================================================================= -//function : fixConnectivity -//purpose : GIBI connectivity -> MED one -//======================================================================= - -static inline void fixConnectivity(const _maille & aMaille ) -{ - if ( const int * conn = getGibi2MedConnectivity( aMaille.geometricType )) { - _maille* ma = (_maille*) & aMaille; - //cout << "###### BEFORE fixConnectivity() " << *ma << endl; - vector< _maille::TNoeud > newSommets( ma->sommets.size() ); - for ( unsigned i = 0; i < newSommets.size(); ++i ) - newSommets[ i ] = ma->sommets[ conn[ i ]]; - ma->sommets = newSommets; - //cout << "###### AFTER fixConnectivity() " << *ma << endl; - } -} - -//======================================================================= -//function : orientElements -//purpose : -//======================================================================= - -static void orientElements( _intermediateMED& medi ) -{ - MESSAGE_MED("orientElements()"); - - set<_maille>::const_iterator elemIt, elemEnd; - - int type = -100; - vector< pair<int,int> > swapVec; - - bool isQuadratic = false; - - if ( medi.points.begin()->second.coord.size() == 2 ) { // space dimension - - // fix connectivity of quadratic edges - _maillageByDimIterator edgesIt( medi, /*dim=*/1); - while ( const set<_maille > * edges = edgesIt.nextType() ) - { - isQuadratic = getGibi2MedConnectivity( edgesIt.type() ); - if (isQuadratic ) - { - elemIt = edges->begin(), elemEnd = edges->end(); - for ( ; elemIt != elemEnd; ++elemIt ) - fixConnectivity( *elemIt ); - } - } - // -------------------------- - // Orient 2D faces clockwise - // -------------------------- - - _maillageByDimIterator faceMailIt( medi, /*dim=*/2 ); - while ( const set<_maille > * faces = faceMailIt.nextType() ) - { - isQuadratic = getGibi2MedConnectivity( faceMailIt.type() ); - elemIt = faces->begin(), elemEnd = faces->end(); - for ( ; elemIt != elemEnd; elemIt++ ) - { - // fix connectivity of quadratic faces - if ( isQuadratic ) - fixConnectivity( *elemIt ); - - // look for index of the most left node - int iLeft = 0, iNode, nbNodes = elemIt->sommets.size(); - if ( nbNodes > 4 ) // quadratic face - nbNodes /= 2; - double minX = elemIt->sommets[0]->second.coord[0]; - for ( iNode = 1; iNode < nbNodes; ++iNode ) - { - if ( minX > elemIt->sommets[ iNode ]->second.coord[ 0 ]) { - minX = elemIt->sommets[ iNode ]->second.coord[ 0 ]; - iLeft = iNode; - } - } - // indeces of the nodes neighboring the most left one - int iPrev = ( iLeft - 1 < 0 ) ? nbNodes - 1 : iLeft - 1; - int iNext = ( iLeft + 1 == nbNodes ) ? 0 : iLeft + 1; - // find components of prev-left and left-next vectors - double xP = elemIt->sommets[ iPrev ]->second.coord[ 0 ]; - double yP = elemIt->sommets[ iPrev ]->second.coord[ 1 ]; - double xN = elemIt->sommets[ iNext ]->second.coord[ 0 ]; - double yN = elemIt->sommets[ iNext ]->second.coord[ 1 ]; - double xL = elemIt->sommets[ iLeft ]->second.coord[ 0 ]; - double yL = elemIt->sommets[ iLeft ]->second.coord[ 1 ]; - double xPL = xL - xP, yPL = yL - yP; // components of prev-left vector - double xLN = xN - xL, yLN = yN - yL; // components of left-next vector - // normalise y of the vectors - double modPL = sqrt ( xPL * xPL + yPL * yPL ); - double modLN = sqrt ( xLN * xLN + yLN * yLN ); - if ( modLN > DBL_MIN && modPL > DBL_MIN ) - { - yPL /= modPL; - yLN /= modLN; - // summury direction of neighboring links must be positive - bool clockwise = ( yPL + yLN > 0 ); - if ( !clockwise ) { - if ( elemIt->geometricType != type ) { - type = elemIt->geometricType; - getReverseVector( type, swapVec ); - } - reverse( *elemIt, swapVec ); - } - } - } - } - } - else { - - // -------------------------------------- - // orient equally all connected 3D faces - // -------------------------------------- - // connectivity of quadratic faces will be fixed by fixConnectivity() - // in the next loop on elements - - // fill map of links and their faces - set<const _maille*> faces; - map<const _maille*, _groupe*> fgm; - map<_link, list<const _maille*> > linkFacesMap; - map<_link, list<const _maille*> >::iterator lfIt, lfIt2; - - medi.treatGroupes(); // erase groupes that wont be converted - for (unsigned int i=0; i!=medi.groupes.size(); ++i) - { - _groupe& grp = medi.groupes[i]; - _groupe::TMailleIter maIt=grp.mailles.begin(); - if ( maIt==grp.mailles.end() || (*maIt)->dimensionWithPoly() != 2 ) - continue; - for(; maIt!=grp.mailles.end(); ++maIt) { - if ( faces.insert( &(**maIt )).second ) { - for ( int j = 0; j < (int)(*maIt)->sommets.size(); ++j ) - linkFacesMap[ (*maIt)->link( j ) ].push_back( &(**maIt) ); - fgm.insert( make_pair( &(**maIt), &grp )); - } - } - } - // dump linkFacesMap -// for ( lfIt = linkFacesMap.begin(); lfIt!=linkFacesMap.end(); lfIt++) { -// cout<< "LINK: " << lfIt->first.first << "-" << lfIt->first.second << endl; -// list<const _maille*> & fList = lfIt->second; -// list<const _maille*>::iterator fIt = fList.begin(); -// for ( ; fIt != fList.end(); fIt++ ) -// cout << "\t" << **fIt << fgm[*fIt]->nom << endl; -// } - - // Each oriented link must appear in one face only, else a face is reversed. - - queue<const _maille*> faceQueue; // the queue contains well oriented faces - // whose neighbors orientation is to be checked - - bool manifold = true; - while ( !linkFacesMap.empty() ) - { - if ( faceQueue.empty() ) { - ASSERT_MED( !linkFacesMap.begin()->second.empty() ); - faceQueue.push( linkFacesMap.begin()->second.front() ); - } - while ( !faceQueue.empty() ) - { - const _maille* face = faceQueue.front(); - faceQueue.pop(); - - // loop on links of <face> - for ( int i = 0; i < (int)face->sommets.size(); ++i ) { - _link link = face->link( i ); - // find the neighbor faces - lfIt = linkFacesMap.find( link ); - int nbFaceByLink = 0; - list< const _maille* > ml; - if ( lfIt != linkFacesMap.end() ) - { - list<const _maille*> & fList = lfIt->second; - list<const _maille*>::iterator fIt = fList.begin(); - ASSERT_MED( fIt != fList.end() ); - for ( ; fIt != fList.end(); fIt++, nbFaceByLink++ ) { - ml.push_back( *fIt ); - if ( *fIt != face ) // wrongly oriented neighbor face - { - const _maille* badFace = *fIt; - // reverse and remove badFace from linkFacesMap - for ( int j = 0; j < (int)badFace->sommets.size(); ++j ) { - _link badlink = badFace->link( j ); - if ( badlink == link ) continue; - lfIt2 = linkFacesMap.find( badlink ); - if ( lfIt2 != linkFacesMap.end() ) { - list<const _maille*> & ff = lfIt2->second; - ff.erase( find( ff.begin(), ff.end(), badFace )); - if ( ff.empty() ) - linkFacesMap.erase( lfIt2 ); - } - } - badFace->reverse = true; // reverse - //INFOS_MED( "REVERSE " << *badFace ); - faceQueue.push( badFace ); - } - } - linkFacesMap.erase( lfIt ); - } - // add good neighbors to the queue - _link revLink( link.second, link.first ); - lfIt = linkFacesMap.find( revLink ); - if ( lfIt != linkFacesMap.end() ) - { - list<const _maille*> & fList = lfIt->second; - list<const _maille*>::iterator fIt = fList.begin(); - for ( ; fIt != fList.end(); fIt++, nbFaceByLink++ ) { - ml.push_back( *fIt ); - if ( *fIt != face ) - faceQueue.push( *fIt ); - } - linkFacesMap.erase( lfIt ); - } - if ( nbFaceByLink > 2 ) { - if ( manifold ) { - list<const _maille*>::iterator i = ml.begin(); - INFOS_MED(nbFaceByLink << " faces by 1 link:"); - for( ; i!= ml.end(); i++ ) { - INFOS_MED("in object " << fgm[ *i ]->nom); - INFOS_MED( **i ); - } - } - manifold = false; - } - } // loop on links of the being checked face - } // loop on the face queue - } // while ( !linkFacesMap.empty() ) - - if ( !manifold ) - INFOS_MED(" -> Non manifold mesh, faces orientation may be incorrect"); - - - // --------------------------------------------------- - // fix connectivity of quadratic elements - // --------------------------------------------------- - - for ( int dim = 1; dim <= 3; ++dim ) - { - _maillageByDimIterator mailIt( medi, dim ); - while ( const set<_maille > * elems = mailIt.nextType() ) - { - isQuadratic = getGibi2MedConnectivity( mailIt.type() ); - elemIt = elems->begin(), elemEnd = elems->end(); - for ( ; elemIt != elemEnd; elemIt++ ) - { - // GIBI connectivity -> MED one - if ( isQuadratic ) - fixConnectivity( *elemIt ); - - // reverse quadratic faces - if ( elemIt->reverse ) { - if ( elemIt->geometricType != type ) { - type = elemIt->geometricType; - getReverseVector( type, swapVec ); - } - reverse ( *elemIt, swapVec ); - } - } - } - } - - // --------------------------------------------------- - // Orient volumes according to MED conventions: - // normal of a bottom (first) face should be downward - // --------------------------------------------------- - - _maillageByDimIterator mailIt( medi, 3 ); - while ( const set<_maille > * elems = mailIt.nextType() ) - { - elemIt = elems->begin(), elemEnd = elems->end(); - int nbBottomNodes = 0; - switch ( elemIt->geometricType ) { - case MED_TETRA4: - case MED_TETRA10: - case MED_PENTA6: - case MED_PENTA15: - nbBottomNodes = 3; break; - case MED_PYRA5: - case MED_PYRA13: - case MED_HEXA8: - case MED_HEXA20: - nbBottomNodes = 4; break; - default: continue; - } - getReverseVector( elemIt->geometricType, swapVec ); - - for ( ; elemIt != elemEnd; elemIt++ ) - { - // find a normal to the bottom face - const _noeud* n[4] = { - &elemIt->sommets[0]->second, // 3 bottom nodes - &elemIt->sommets[1]->second, - &elemIt->sommets[2]->second, - &elemIt->sommets[nbBottomNodes]->second };// a top node - double vec01 [3] = { // vector n[0]-n[1] - n[1]->coord[0] - n[0]->coord[0], - n[1]->coord[1] - n[0]->coord[1], - n[1]->coord[2] - n[0]->coord[2], }; - double vec02 [3] = { // vector n[0]-n[2] - n[2]->coord[0] - n[0]->coord[0], - n[2]->coord[1] - n[0]->coord[1], - n[2]->coord[2] - n[0]->coord[2] }; - double normal [3] = { // vec01 ^ vec02 - vec01[1] * vec02[2] - vec01[2] * vec02[1], - vec01[2] * vec02[0] - vec01[0] * vec02[2], - vec01[0] * vec02[1] - vec01[1] * vec02[0] }; - // check if the 102 angle is convex - if ( nbBottomNodes > 3 ) { - const _noeud* n3 = &elemIt->sommets[nbBottomNodes-1]->second;// last bottom node - double vec03 [3] = { // vector n[0]-n3 - n3->coord[0] - n[0]->coord[0], - n3->coord[1] - n[0]->coord[1], - n3->coord[2] - n[0]->coord[2], }; - if ( fabs( normal[0]+normal[1]+normal[2] ) <= DBL_MIN ) { // vec01 || vec02 - normal[0] = vec01[1] * vec03[2] - vec01[2] * vec03[1]; // vec01 ^ vec03 - normal[1] = vec01[2] * vec03[0] - vec01[0] * vec03[2]; - normal[2] = vec01[0] * vec03[1] - vec01[1] * vec03[0]; - } - else { - double vec [3] = { // normal ^ vec01 - normal[1] * vec01[2] - normal[2] * vec01[1], - normal[2] * vec01[0] - normal[0] * vec01[2], - normal[0] * vec01[1] - normal[1] * vec01[0] }; - double dot2 = vec[0]*vec03[0] + vec[1]*vec03[1] + vec[2]*vec03[2]; // vec*vec03 - if ( dot2 < 0 ) { // concave -> reverse normal - normal[0] *= -1; - normal[1] *= -1; - normal[2] *= -1; - } - } - } - // direction from top to bottom - double tbDir[3]; - tbDir[0] = n[0]->coord[0] - n[3]->coord[0]; - tbDir[1] = n[0]->coord[1] - n[3]->coord[1]; - tbDir[2] = n[0]->coord[2] - n[3]->coord[2]; - // compare 2 directions: normal and top-bottom - double dot = normal[0]*tbDir[0] + normal[1]*tbDir[1] + normal[2]*tbDir[2]; - if ( dot < 0. ) // need reverse - { - reverse( *elemIt, swapVec ); - } - } // loop on volumes of one geometry - } // loop on 3D geometry types - - } // space dimension == 3 -} - -//======================================================================= -//function : fillMesh -//purpose : load data from medi to mesh -//======================================================================= - -void GIBI_MESH_RDONLY_DRIVER::fillMesh(_intermediateMED* _ptrMedi) -{ - const char* LOC = "GIBI_MESH_RDONLY_DRIVER::fillMesh(_intermediateMED* _ptrMedi) : "; - BEGIN_OF_MED(LOC); - - MESH* mesh = (MESH*)_mesh; - mesh->_name = _meshName; - - if (_ptrMedi) - { - if (!_maillageByDimIterator(*_ptrMedi).nextType() || - _ptrMedi->groupes.empty() || - _ptrMedi->points.empty()) { - INFOS_MED(" Error while reading file: the data read are not completed " ); - return; - } - // fix element orientation - orientElements( *_ptrMedi ); - - mesh->_spaceDimension = _ptrMedi->points.begin()->second.coord.size(); - mesh->_numberOfNodes = _ptrMedi->points.size(); - mesh->_coordinate = _ptrMedi->getCoordinate(); - - //Construction des groupes - _ptrMedi->getGroups(mesh->_groupCell, - mesh->_groupFace, - mesh->_groupEdge, - mesh->_groupNode, mesh); - - mesh->_connectivity = _ptrMedi->getConnectivity(); - } - END_OF_MED(LOC); -} - -//================================================================================ -/*! - * \brief Create families from groups etc. - */ -//================================================================================ - -void GIBI_MESH_RDONLY_DRIVER::updateSupports() -{ - _mesh->createFamilies(); - - // add attributes to families - set<string> famNames; - for (medEntityMesh entity=MED_CELL; entity<MED_ALL_ENTITIES; ++entity) - { - int i, nb = _mesh->getNumberOfFamilies(entity); - for ( i = 1; i <= nb; ++i ) { - FAMILY* f = const_cast<FAMILY*>( _mesh->getFamily( entity, i )); - f->setNumberOfAttributes( 1 ); - int* attIDs = new int[1]; - attIDs[0] = 1; - f->setAttributesIdentifiers( attIDs ); - int* attVals = new int[1]; - attVals[0] = 1; - f->setAttributesValues( attVals ); - string* attDescr = new string[1]; - attDescr[0] = "med_family"; - f->setAttributesDescriptions( attDescr ); - delete [] attDescr; - // limit a name length - if ( f->getName().length() > 31 ) { - ostringstream name; - name << "FAM" << f->getIdentifier(); - f->setName( name.str()); - } - // check if family is on the whole mesh entity - if (_mesh->getNumberOfElements( entity, MED_ALL_ELEMENTS ) == - f->getNumberOfElements( MED_ALL_ELEMENTS )) - f->setAll( true ); - } - // setAll() for groups - nb = _mesh->getNumberOfGroups(entity); - for ( i = 1; i <= nb; ++i ) { - GROUP * g = const_cast<GROUP*>( _mesh->getGroup( entity, i )); - if (_mesh->getNumberOfElements( entity, MED_ALL_ELEMENTS ) == - g->getNumberOfElements( MED_ALL_ELEMENTS )) - g->setAll( true ); - } - } -} - -void GIBI_MESH_RDONLY_DRIVER::write( void ) const - throw (MEDEXCEPTION) -{ - throw MEDEXCEPTION("GIBI_MESH_RDONLY_DRIVER::write : Can't write with a RDONLY driver !"); -} - - -/*--------------------- WRONLY PART -------------------------------*/ - -GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER():GIBI_MESH_DRIVER() -{ -} -GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER(const string & fileName, - GMESH * ptrMesh): - GIBI_MESH_DRIVER(fileName,ptrMesh,WRONLY) -{ - MESSAGE_MED("GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created"); -} -GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER(const GIBI_MESH_WRONLY_DRIVER & driver): - GIBI_MESH_DRIVER(driver) -{ -} -GIBI_MESH_WRONLY_DRIVER::~GIBI_MESH_WRONLY_DRIVER() -{ - //MESSAGE_MED("GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed"); -} -GENDRIVER * GIBI_MESH_WRONLY_DRIVER::copy(void) const -{ - return new GIBI_MESH_WRONLY_DRIVER(*this); -} -void GIBI_MESH_WRONLY_DRIVER::read (void) - throw (MEDEXCEPTION) -{ - throw MEDEXCEPTION("GIBI_MESH_WRONLY_DRIVER::read : Can't read with a WRONLY driver !"); -} - -//======================================================================= -//function : open -//purpose : -//======================================================================= - -void GIBI_MESH_WRONLY_DRIVER::open() - // throw (MEDEXCEPTION) -{ - if( _status == MED_OPENED ) - return; - - const char * LOC = "GIBI_MESH_DRIVER::open()"; - BEGIN_OF_MED(LOC); - - MED_EN::med_mode_acces aMode = getAccessMode(); - switch (aMode) { - case MED_EN::RDWR: - case MED_EN::WRONLY: // should never append !! - _gibi.open(_fileName.c_str(), ios::out); - break; - default: - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access ! " << aMode)); - } - //change for windows compilation - if ( !_gibi || -#ifdef WIN32 - !_gibi.is_open() -#else - !_gibi.rdbuf()->is_open() -#endif - ) - { - _status = MED_CLOSED; - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Could not open file "<<_fileName)); - } - else - { - _status = MED_OPENED; - } - END_OF_MED(LOC); -} - -//======================================================================= -//function : close -//purpose : -//======================================================================= - -void GIBI_MESH_WRONLY_DRIVER::close() - // throw (MEDEXCEPTION) -{ - const char* LOC = "GIBI_MESH_DRIVER::close() "; - BEGIN_OF_MED(LOC); - if ( _status == MED_OPENED) - { - _gibi.close(); - _status = MED_CLOSED; - } - END_OF_MED(LOC); -} - -//======================================================================= -//function : write -//purpose : -//======================================================================= - -void GIBI_MESH_WRONLY_DRIVER::write(void) const - throw (MEDEXCEPTION) -{ - const char* LOC = "void GIBI_MESH_WRONLY_DRIVER::write(void) const : "; - BEGIN_OF_MED(LOC); - - // we are going to modify the _gibi field - GIBI_MESH_WRONLY_DRIVER * me = const_cast<GIBI_MESH_WRONLY_DRIVER *>(this); -// try { - // IMP 0020434: mapping GIBI names to MED names - list<nameGIBItoMED> listGIBItoMED_mail; - list<nameGIBItoMED> listGIBItoMED_cham; - list<nameGIBItoMED> listGIBItoMED_comp; - me->writeSupportsAndMesh(listGIBItoMED_mail); - me->writeMEDNames(listGIBItoMED_mail, listGIBItoMED_cham, listGIBItoMED_comp); - me->writeLastRecord(); -// } -// catch (MEDEXCEPTION &ex) -// { -// INFOS_MED( ex.what() ); -// } - - END_OF_MED(LOC); -} - -//======================================================================= -//function : getName -//purpose : return cleaned up support name -//======================================================================= - -static string cleanName( const string& theName ) -{ - string name = theName; - if ( !name.empty() ) { - /* - // find a name string end - int i, len = name.length(); - for ( i = 0; i < len; ++i ) { - if ( name[i] == 0 ) - break; - } - // cut off trailing white spaces - while ( i > 0 && name[i-1] == ' ' ) - i--; - if ( i != len ) { - name = name.substr( 0, i ); - len = i; - } - */ - // cut off leading white spaces - string::size_type firstChar = name.find_first_not_of(" \t"); - if (firstChar < name.length()) - { - name = name.substr(firstChar); - } - else - { - name = ""; // only whitespaces there - remove them - } - // cut off trailing white spaces - string::size_type lastChar = name.find_last_not_of(" \t"); - if (lastChar < name.length()) { - name = name.substr(0, lastChar + 1); - } - } - return name; -} - -//======================================================================= -//function : addSupport -//purpose : -//======================================================================= - -bool GIBI_MESH_WRONLY_DRIVER::addSupport( const SUPPORT * support ) -{ - if ( !support ) - return false; - map<const SUPPORT*,supportData>::iterator su = _supports.find( support ); - if ( su != _supports.end() ) - return ( su->second.getNumberOfTypes() > 0 ); - - if ( support->getMesh() != _mesh ) - throw MEDEXCEPTION(LOCALIZED(STRING("cant write support of other mesh" ))); - - MESH* mesh = (MESH*)_mesh; - - // get sub-supports and define a support type name - string supType; - list<const SUPPORT*> sList; - const GROUP* group = dynamic_cast< const GROUP* >(support); - if ( group ) - { - if ( group->getNumberOfTypes() > 0 || group->isOnAllElements() ) - sList.push_back( group ); - else { - int iFam, nbFam = group->getNumberOfFamilies(); - for ( iFam = 1; iFam <= nbFam; ++iFam ) - sList.push_back( group->getFamily( iFam )); - } - supType = "group"; - } - else - { - sList.push_back( support ); - supType = dynamic_cast< const FAMILY* >(support) ? "family" : "support"; - } - - supportData & data = _supports[ support ]; - data._cleanName = cleanName( support->getName() ); - - // check if it is a writtable support, i.e. - // nodal connectivity for a support entity exists - medEntityMesh entity = support->getEntity(); - if ( entity != MED_NODE && !mesh->existConnectivity( MED_NODAL, entity )) { - INFOS_MED("Do not save " << supType << " of entity " << entity - << " named <" << data._cleanName << "> nodal connectivity not defined"); - return false; - } - - // fill supportData - list<const SUPPORT*>::iterator sIt = sList.begin(); - for ( ; sIt != sList.end(); sIt++ ) - { - bool onAll = (*sIt)->isOnAllElements(); - int nbTypes = 0; - if ( !onAll ) - nbTypes = (*sIt)->getNumberOfTypes(); - else - nbTypes = _mesh->getNumberOfTypes( entity ); - if ( nbTypes == 0 ) - continue; - const medGeometryElement* types = 0; - if ( !onAll ) - types = (*sIt)->getTypes(); - else if ( entity != MED_NODE ) - types = _mesh->getTypes( entity ); - for ( int iType = 0; iType < nbTypes; ++iType ) - { - if ( types && types[ iType ] > MED_HEXA20 ) - continue; // poly - medGeometryElement geomType = types ? types[ iType ] : MED_ALL_ELEMENTS; - const int * ptrElemIDs = 0; - int elemID1 = 0, nbElems = 0; - if ( onAll ) { - nbElems = _mesh->getNumberOfElements( entity, geomType ); - elemID1 = (entity == MED_NODE) ? 1 : mesh->getGlobalNumberingIndex (entity)[ iType ]; - } - else { - nbElems = (*sIt)->getNumberOfElements( geomType ); - ptrElemIDs = (*sIt)->getNumber( geomType ); - } - if ( geomType == 0 || ( entity == MED_NODE )) - geomType = MED_POINT1; - - data.addTypeData( geomType, nbElems, ptrElemIDs, elemID1 ); - } - } - - if ( data.getNumberOfTypes() == 0 ) { - INFOS_MED("Do not save " << supType << " of entity " << entity - << " named <" << data._cleanName << "> no geometric types"); - return false; - } - - return true; -} - -//======================================================================= -//function : getSupportIndex -//purpose : -//======================================================================= - -int GIBI_MESH_WRONLY_DRIVER::getSubMeshIdAndSize(const SUPPORT * support, - list<pair<int,int> > & idsAndSizes) const -{ - idsAndSizes.clear(); - map<const SUPPORT*,supportData>::const_iterator su = _supports.find( support ); - if ( su == _supports.end() ) - return 0; - - supportData * data = const_cast<supportData *>( & su->second ); - int id = data->_id; - if ( data->getNumberObjects() > data->getNumberOfTypes() ) - id++; - supportData::typeIterator tIt = data->_types.begin(); - for ( ; tIt != data->_types.end(); ++tIt ) - { - int size = 0; - list< typeData >& td = tIt->second; - list< typeData >::iterator tdIt = td.begin(); - for ( ; tdIt != td.end(); ++tdIt ) - size += tdIt->_nbElems; - idsAndSizes.push_back( make_pair( id++, size )); - } - return idsAndSizes.size(); -} - -// ============================================================ -// the class writes endl to the file as soon as <limit> fields -// have been written after the last endl -// ============================================================ - -class TFieldCounter -{ - fstream& _file; - int _count, _limit; - public: - TFieldCounter(fstream& f, int limit=0): _file(f), _limit(limit) { init(); } - void init(int limit=0) // init, is done by stop() as well - { if (limit) _limit = limit; _count = 0; } - void operator++(int) // next - { if ( ++_count == _limit ) { _file << endl; init(); }} - void stop() // init() and write endl if there was no endl after the last written field - { if ( _count ) _file << endl; init(); } -}; - -//======================================================================= -//function : writeElements -//purpose : ptrElemIDs and elemID1 provide two alternative ways of giving -// elements to write. -// If elemSet != 0 then an element is -// ( addElemInSet ? <written and added to elemSet> : <ignored if id is in elemSet>) -//======================================================================= - -void GIBI_MESH_WRONLY_DRIVER::writeElements (medGeometryElement geomType, - list< typeData >& typeDataList, - const int * nodalConnect, - const int * nodalConnectIndex) -{ - // ITYPEL : type de l'鬩ment 1=point, 2=segment ?eux noeuds... - // NBSOUS : nombre de sous parties dans cet objet, - // une sous partie par type d'鬩ments le composant. - // NBREF : nombre de sous r馩rences. Une r馩rence est par exemple le contour - // NBNOEL : nombre de noeuds par 鬩ment - // NBEL : nombre d'鬩ments - - int castemType = GIBI_MESH_DRIVER::med2gibiGeom( geomType ); - const char* zeroI8 = " 0"; // FORMAT(I8) - unsigned nbElemNodes = geomType % 100; - - // indices to transform MED connectivity to GIBI one - vector< int > toGibiConn; - toGibiConn.reserve( nbElemNodes ); - if ( const int * toMedConn = getGibi2MedConnectivity( geomType )) { - toGibiConn.resize( nbElemNodes ); - for ( unsigned i = 0; i < nbElemNodes; ++i ) - toGibiConn[ toMedConn[ i ]] = i; - } - else { - while ( toGibiConn.size() < nbElemNodes ) - toGibiConn.push_back( toGibiConn.size() ); - } - - // count total nb of elements - int nbElements = 0; - list< typeData >::iterator td = typeDataList.begin(); - for ( ; td != typeDataList.end(); td++ ) - nbElements += td->_nbElems; - - _gibi << setw(8) << castemType << // ITYPE - zeroI8 << // NBSOUS - zeroI8 << // NBREF - setw(8) << nbElemNodes << // NBNOEL - setw(8) << nbElements << // NBEL - endl; - - MESSAGE_MED("writeElements(): geomType=" << geomType << " nbElements= " << nbElements) - - // L 'enregistrement donnant le num? de la couleur des 鬩ments. - // * 8000 FORMAT(10I8) - TFieldCounter fcount( _gibi, 10 ); - int iElem = 0; - for ( ; iElem < nbElements; ++iElem, fcount++ ) - _gibi << zeroI8; - fcount.stop(); - - // Tableau des connectivité³® Description du premier 鬩ment puis du deuxiè­¥... - // ATTENTION il ne s'agit pas de la num?tation vraie, - // il faut la faire passer par le filtre du dernier tableau de la pile num? 32. - //int nbSkipped = 0; - - for ( td = typeDataList.begin(); td != typeDataList.end(); td++ ) - { - for ( int i = 0; i < td->_nbElems; i++ ) - { - iElem = td->_ptrElemIDs ? td->_ptrElemIDs[ i ] : td->_elemID1 + i; - if ( geomType == MED_POINT1 ) - { - _gibi << setw(8) << iElem; - fcount++; - } - else - { - int nodeId = nodalConnectIndex[ iElem - 1 ] - 1; - for ( unsigned iNode = 0; iNode < nbElemNodes; ++iNode, fcount++ ) { - _gibi << setw(8) << nodalConnect[ nodeId + toGibiConn[ iNode ]]; - } - } - } - } - - fcount.stop(); -} - -//======================================================================= -//function : addName -//purpose : make name uppercase and shorter than 9, add it to nameNbMap, -// raise if not unique -//======================================================================= -/* -void GIBI_MESH_WRONLY_DRIVER::addName(map<string,int>& nameMap, - string& theName, - int index, - string prefix) -{ - string name = cleanName( theName ); - if ( !name.empty() ) { - int len = name.length(); -#ifdef THROW_ON_BAD_NAME - if ( len > 8 ) - throw MEDEXCEPTION(STRING("Can't write name longer than 8: ") << name ); - - for ( int i = 0; i < len; ++i ) - name[i] = toupper( name[i] ); - if ( ! nameMap.insert( make_pair( name, index )).second ) - throw MEDEXCEPTION(STRING("Can't write not unique name: ") << name ); -#else - bool ok = ( len <= 8 && len > 0 ); - if ( ok ) { - for ( int i = 0; i < len; ++i ) - name[i] = toupper( name[i] ); - ok = nameMap.insert( make_pair( name, index )).second; - } - if ( !ok ) { - char *str=new char[ prefix.size() + 13 ]; - int j = 1; - do { - sprintf( str, "%s_%d", prefix.c_str(), nameMap.size()+j ); - ok = nameMap.insert( make_pair( str, index )).second; - j++; - } while ( !ok ); - INFOS_MED( "Save <" << name << "> as <" << str << ">"); - delete [] str; - } -#endif - } -} -*/ - -// Converts names like: -// MED: -// TEMPERATURE_FLUIDE -// TEMPERATURE_SOLIDE -// PRESSION -// NU -// VOLUM001 -// VOLUMOFOBJECT -// VOLUM002 -// -// GIBI: -// TEMPE001 -// TEMPE002 -// PRESSION -// NU -// VOLUM001 -// VOLUM003 -// VOLUM002 -void GIBI_MESH_WRONLY_DRIVER::addName (map<string,int>& nameMap, - map<string,int>& namePrefixesMap, - const string& theName, - int index) -{ - string name = cleanName(theName); - int ind = index; - - if (!name.empty()) { - int len = name.length(); - for (int i = 0; i < len; ++i) - name[i] = toupper(name[i]); - - bool doResave = false; // only for tracing - - // I. Save a short name as it is - if (len <= 8) { - INFOS_MED("Save <" << theName << "> as <" << name << ">"); - - map<string,int>::iterator it = nameMap.find(name); - if (it != nameMap.end()) { - // There is already such name in the map. - - // a. Replace in the map the old pair by the current one - int old_ind = nameMap[name]; - nameMap[name] = ind; - // b. Rebuild the old pair (which was in the map, - // it seems to be built automatically by step II) - ind = old_ind; - // continue with step II - doResave = true; // only for tracing - } - else { - // Save in the map - nameMap.insert(make_pair(name, ind)); - - // Update loc_index for this name (if last free characters represents a number) - // to avoid conflicts with long names, same in first 5 characters - if (len == 8) { - int new_loc_index = atoi(name.c_str() + 5); - if (new_loc_index > 0) { - // prefix - char str [6]; - strncpy(str, name.c_str(), 5); - str[5] = '\0'; - - if (namePrefixesMap.find(str) != namePrefixesMap.end()) { - int old_loc_index = namePrefixesMap[str]; - if (new_loc_index < old_loc_index) new_loc_index = old_loc_index; - } - namePrefixesMap[str] = new_loc_index; - } - } - return; - } - } // if (len <= 8) - - // II. Cut long name and add a numeric suffix - - // first 5 or less characters of the name - if (len > 5) len = 5; - char str [9]; - str[8] = '\0'; - int addr = 0; - strncpy(str, name.c_str(), len); - addr = len; - str[addr] = '\0'; - - // numeric suffix - int loc_index = 1; - if (namePrefixesMap.find(str) != namePrefixesMap.end()) - loc_index = namePrefixesMap[str] + 1; - namePrefixesMap[str] = loc_index; - - if (loc_index > 999) - throw MEDEXCEPTION(STRING("Can't write not unique name: ") << name); - - if (loc_index < 100) { - str[addr] = '0'; - addr++; - } - if (loc_index < 10) { - str[addr] = '0'; - addr++; - } - sprintf(str + addr, "%d", loc_index); - - nameMap.insert(make_pair(str, ind)); - if (doResave) { - INFOS_MED("Resave previous <" << name << "> as <" << str << ">"); - } - else { - INFOS_MED("Save <" << theName << "> as <" << str << ">"); - } - } -} - -//======================================================================= -//function : writeNames -//purpose : -//======================================================================= - -void GIBI_MESH_WRONLY_DRIVER::writeNames( map<string,int>& nameNbMap ) -{ - // La pile num? 1 est celle des objets de type maillage. - // La ligne suivante donne le nom des objets maillages sauvé³® - // * 8001 FORMAT(8(1X,A8)) - if ( !nameNbMap.empty() ) - { - TFieldCounter fcount( _gibi, 8 ); - _gibi << left; - map<string,int>::iterator nameNbIt = nameNbMap.begin(); - for ( ; nameNbIt != nameNbMap.end(); nameNbIt++, fcount++ ) { - _gibi << " " << setw(8) << nameNbIt->first; - } - fcount.stop(); - _gibi << right; - // La ligne suivante donne les num?s d'ordre, dans la pile, - // des objets nomm?cit?pr飩demment. - // * 8000 FORMAT(10I8) - nameNbIt = nameNbMap.begin(); - for ( fcount.init(10); nameNbIt != nameNbMap.end(); nameNbIt++, fcount++ ) - _gibi << setw(8) << nameNbIt->second; - fcount.stop(); - } -} - -//======================================================================= -//function : writeSupportsAndMesh -//purpose : -//======================================================================= - -void GIBI_MESH_WRONLY_DRIVER::writeSupportsAndMesh(list<nameGIBItoMED>& listGIBItoMED_mail) -{ - const char * LOC = "void GIBI_MESH_WRONLY_DRIVER::writeSupportsAndMesh() "; - BEGIN_OF_MED(LOC); - - if (_status!=MED_OPENED) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "file " << _fileName<< " is not opened." )); - if (!_mesh) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "can't write a NULL mesh" )); - - const MESH* mesh = _mesh->convertInMESH(); - AutoDeref meshDeref( mesh ); - - if (!mesh->getConnectivityptr()) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "can't write a mesh with NULL connectivity" )); - - // fill _supports with families and groups - medEntityMesh entity; - for (entity=MED_CELL; entity<MED_ALL_ENTITIES; ++entity) - { - int i, nb = _mesh->getNumberOfGroups(entity); - for ( i = 1; i <= nb; ++i ) - addSupport( _mesh->getGroup( entity, i )); -// nb = _mesh->getNumberOfFamilies(entity); -// for ( i = 1; i <= nb; ++i ) -// addSupport( _mesh->getFamily( entity, i )); - } - - // -------------------------------------------------------------------- - // Count total nb of objects: an object per an element type in support - // plus an object per an element type not used in _supports. - // Collect object names - // -------------------------------------------------------------------- - - vector<int> nbSuppElemsByType(MED_HEXA20+1,0); - map<string,int> nameNbMap; - map<string,int> namePrefixMap; - map<const SUPPORT*,supportData>::iterator supIt = _supports.begin(); - int i, nb_objects = 0; - for ( ; supIt != _supports.end(); supIt++ ) - { - supportData & data = supIt->second; - int nbSupObj = data.getNumberObjects(); - if ( nbSupObj == 0 ) - continue; - data._id = nb_objects + 1; - nb_objects += nbSupObj; - - //addName( nameNbMap, data._cleanName, data._id, "C" ); - addName(nameNbMap, namePrefixMap, data._cleanName, data._id); - - // IMP 0020434: mapping GIBI names to MED names - nameGIBItoMED aMEDName; - aMEDName.gibi_pile = PILE_SOUS_MAILLAGE; - aMEDName.gibi_id = data._id; - aMEDName.med_name = data._cleanName; - listGIBItoMED_mail.push_back(aMEDName); - - MESSAGE_MED( "obj " << data._id << " " << data._cleanName); - - // count elements: take into account supports on all elements and families only - const SUPPORT* support = supIt->first; - if ( support->isOnAllElements() || dynamic_cast< const FAMILY* >( support )) - { - supportData::typeIterator tIt = data._types.begin(); - for ( ; tIt != data._types.end(); ++tIt ) - if ( support->isOnAllElements() ) - { - nbSuppElemsByType[ tIt->first ] = INT_MAX / 100; - } - else - { - list< typeData >& td = tIt->second; - list< typeData >::iterator tdIt = td.begin(); - for ( ; tdIt != td.end(); ++tdIt ) - nbSuppElemsByType[ tIt->first] += tdIt->_nbElems; - } - } - } - - // count types of mesh elements that are not all in _supports - int iType, nbTypes; - entity = mesh->getConnectivityptr()->getEntity(); - for ( ; entity < MED_NODE; entity++ ) - { - nbTypes = _mesh->getNumberOfTypes( entity ); - if ( nbTypes == 0 || !mesh->existConnectivity( MED_NODAL, entity )) - continue; - const medGeometryElement* types = _mesh->getTypes( entity ); - for ( iType = 0; iType < nbTypes; ++iType ) - { - int nbElemInSups = nbSuppElemsByType[ types[ iType ]]; - int nbElemInMesh = _mesh->getNumberOfElements(entity, types[ iType ]); - if ( nbElemInSups < nbElemInMesh ) { - nb_objects++; - nbSuppElemsByType[ types[ iType ]] = -1; // to keep written elements of _supports - } - } - } - - // ------------ - // Write file - // ------------ - - // Premier paquet dont le nombre de lignes ne varie pas. - // On y trouve des indications g鮩rales. - const int dim = _mesh->getSpaceDimension(); - _gibi << " ENREGISTREMENT DE TYPE 4" << endl; - _gibi << " NIVEAU 15 NIVEAU ERREUR 0 DIMENSION " << dim <<endl; - _gibi << " DENSITE .00000E+00" << endl; - _gibi << " ENREGISTREMENT DE TYPE 7" << endl; - _gibi << " NOMBRE INFO CASTEM2000 8" <<endl; - _gibi << " IFOUR -1 NIFOUR 0 IFOMOD -1 IECHO 1 IIMPI 0 IOSPI 0 ISOTYP 1" << endl; - _gibi << " NSDPGE 0" << endl; - - // Deuxiè­¥ paquet qui d馩nit toutes les piles - // (une pile par type d'objet et certaines piles en plus). - // Un enregistrement de type 2 pr鶩ent de l'飲iture d'une nouvelle pile, - // celui de type 5 pr鶩ent de la fin. - // * 800 FORMAT (' ENREGISTREMENT DE TYPE', I4) - _gibi << " ENREGISTREMENT DE TYPE 2" << endl; - // * 801 FORMAT(' PILE NUMERO',I4,'NBRE OBJETS NOMMES',I8,'NBRE OBJETS',I8) - _gibi << " PILE NUMERO 1NBRE OBJETS NOMMES" << setw(8) << nameNbMap.size() << - "NBRE OBJETS" << setw(8) << nb_objects <<endl; - - writeNames( nameNbMap ); - - // Passage ?a description des objets les uns aprè³ les autres. - // Le premier enregistrement de chaque objet est composé ¤e 5 nombres repré³¥ntant : - // ITYPEL : type de l'鬩ment 1=point, 2=segment ?eux noeuds... - // NBSOUS : nombre de sous parties dans cet objet, - // une sous partie par type d'鬩ments le composant. - // NBREF : nombre de sous r馩rences. Une r馩rence est par exemple le contour - // NBNOEL : nombre de noeuds par 鬩ment - // NBEL : nombre d'鬩ments - // Si ITYPEL=0 alors NBSOUS diffé²¥nt de z?. Dans ce cas on lira la liste des positions, - // dans la pile des objets, des sous parties le composant. - // Si NBSOUS=0, NBNOEL et NBEL sont diffé²¥nts de z?, on trouve, au besoin, - // la liste des r馩rences , les num?s des couleurs puis les connectivité³® - - TFieldCounter fcount( _gibi, 10 ); - const char* zeroI8 = " 0"; // FORMAT(I8) - for ( supIt = _supports.begin(); supIt != _supports.end(); supIt++ ) - { - supportData & data = supIt->second; - int nbSupObj = data.getNumberObjects(); - if ( nbSupObj == 0 ) - continue; - MESSAGE_MED("support " << data._id << "<" << data._cleanName << ">"); - - // write a compound object - int nbTypes = data.getNumberOfTypes(); - if ( nbSupObj > nbTypes ) - { - _gibi << zeroI8 << setw(8) << nbTypes << zeroI8 << zeroI8 << zeroI8 << endl; - for ( int i_sub = 1; i_sub <= nbTypes; ++i_sub, fcount++ ) - _gibi << setw(8) << ( data._id + i_sub ); - fcount.stop(); - } - - // write components - entity = supIt->first->getEntity(); - const int * nodalConnect = 0, * nodalConnectIndex = 0; - if ( entity != MED_NODE ) { - nodalConnect = mesh->getConnectivity (MED_NODAL,entity,MED_ALL_ELEMENTS); - nodalConnectIndex = mesh->getConnectivityIndex (MED_NODAL,entity); - } - supportData::typeIterator tIt = data._types.begin(); - for ( ; tIt != data._types.end(); ++tIt ) - { - writeElements (tIt->first, - tIt->second, - nodalConnect, - nodalConnectIndex); - } - } // loop on _supports - - // Write elements that are not in _supports - - supportData data; - entity = mesh->getConnectivityptr()->getEntity(); - for ( ; entity < MED_NODE; entity++ ) - { - int nbTypes = _mesh->getNumberOfTypes( entity ); - if ( nbTypes == 0 || !mesh->existConnectivity( MED_NODAL, entity )) - continue; - const medGeometryElement* types = _mesh->getTypes( entity ); - const int * nbIndex = mesh->getGlobalNumberingIndex (entity); - const int * nodalConnect = 0, * nodalConnectIndex = 0; - nodalConnect = mesh->getConnectivity (MED_NODAL,entity,MED_ALL_ELEMENTS); - nodalConnectIndex = mesh->getConnectivityIndex (MED_NODAL,entity); - - for ( int iType = 1; iType <= nbTypes; ++iType ) - { - int nbElements = nbIndex[ iType ] - nbIndex[ iType - 1 ]; - medGeometryElement geomType = types[ iType - 1 ]; - if ( nbSuppElemsByType[ geomType ] >= nbElements ) - continue; // all elements are written with _supports - - int elemId1 = nbIndex[ iType - 1 ]; - data.addTypeData( geomType, nbElements, 0, elemId1 ); - - writeElements (geomType, - data._types[ geomType ], - nodalConnect, - nodalConnectIndex); - } - } - - // D颵t de la pile 32 (celle des points) - - int nbNodes = _mesh->getNumberOfNodes(); - _gibi << " ENREGISTREMENT DE TYPE 2" << endl; - _gibi << " PILE NUMERO 32NBRE OBJETS NOMMES 0" << - "NBRE OBJETS" << setw(8) << nbNodes << endl; - // Liste des noms de points - // * 8001 FORMAT(8(1X,A8)) - // No named nodes - // suit le nombre de noeuds - _gibi << setw(8) << nbNodes << endl; - // Le tableau suivant donne le filtre pour avoir le vrai num? des noeuds - // appartenant aux 鬩ments d飲its. Par exemple, si un 鬩ment, d飲it - // dans la pile 1, fait r馩rence ?n num? de noeud 駡l ? il faut le - // mettre 駡l ?2 - // * 8000 FORMAT(10I8) - for ( i = 0; i < nbNodes; ++i, fcount++ ) - _gibi << setw(8) << i + 1; - fcount.stop(); - - // D颵t de pile 33 (celle des configurations (coordonn?)) - _gibi << " ENREGISTREMENT DE TYPE 2" << endl; - _gibi << " PILE NUMERO 33NBRE OBJETS NOMMES 0NBRE OBJETS 1" << endl; - // Suit le nombre de points dont on donne les coordonn? - int nbValues = nbNodes * ( dim + 1 ); - _gibi << setw(8) << nbValues << endl; - // Les coordonn? sont donn? par noeuds. D'abord le premier puis le deuxiè­¥... - // Pour chaque noeuds, on donne les 2 ou 3 coordonn? plus la densité £ourante - // au moment de sa cré¡´ion. - // * 8003 FORMAT(1P,3E22.14) - _gibi.precision(14); - _gibi.setf( ios_base::scientific, ios_base::floatfield ); - _gibi.setf( ios_base::uppercase ); - const double * coords = mesh->getCoordinates(MED_FULL_INTERLACE); - int j = 0; - const double precision = 1.e-99; // PAL12077 - for ( fcount.init(3),i = 0; i < nbNodes; ++i, j += dim ) - { - for ( int iCoord = 0; iCoord < dim; ++iCoord, fcount++ ) { - double coo = coords[ j + iCoord ]; - bool zero = ( -precision < coo && coo < precision ); - _gibi << setw(22) << ( zero ? 0.0 : coo ); - } - _gibi << setw(22) << 0.0; // densite - fcount++; - } - fcount.stop(); - - END_OF_MED(LOC); -} - -//======================================================================= -//function : writeMEDNames -//purpose : -//======================================================================= -void GIBI_MESH_WRONLY_DRIVER::writeMEDNames (const list<nameGIBItoMED>& listGIBItoMED_mail, - const list<nameGIBItoMED>& listGIBItoMED_cham, - const list<nameGIBItoMED>& listGIBItoMED_comp) -{ - // IMP 0020434: mapping GIBI names to MED names - // Store correspondence between GIBI and MED names - // as one PILE_STRINGS and one PILE_TABLES - // (in three tables: MED_MAIL, MED_CHAM and MED_COMP) - - int nbNames_mail = listGIBItoMED_mail.size(); - int nbNames_cham = listGIBItoMED_cham.size(); - int nbNames_comp = listGIBItoMED_comp.size(); - - int nbTables = 0; - if (nbNames_mail) nbTables++; - if (nbNames_cham) nbTables++; - if (nbNames_comp) nbTables++; - - if (!nbTables) - return; - - // The whole string (concatenated names) - string theWholeString; - list<int> theOffsets; - int currOffset = 0; - - // The TABLE PILE - // * 800 FORMAT (' ENREGISTREMENT DE TYPE', I4) - _gibi << " ENREGISTREMENT DE TYPE 2" << endl; - // * 801 FORMAT(' PILE NUMERO',I4,'NBRE OBJETS NOMMES',I8,'NBRE OBJETS',I8) - _gibi << " PILE NUMERO 10NBRE OBJETS NOMMES" << setw(8) << nbTables << - "NBRE OBJETS" << setw(8) << nbTables << endl; // <nbTables> named tables - // Table names - if (nbNames_mail) - _gibi << " MED_MAIL"; - if (nbNames_cham) - _gibi << " MED_CHAM"; - if (nbNames_comp) - _gibi << " MED_COMP"; - _gibi << endl; - // Table indices - _gibi << setw(8) << 1; - if (nbTables > 1) _gibi << setw(8) << 2; - if (nbTables > 2) _gibi << setw(8) << 3; - _gibi << endl; - - int istr = 1; - - // Table MED_MAIL - if (nbNames_mail) { - // Provide unique MED names, to exclude conflicts on reading saved files - // (use case: read fra.med, save it to GIBI, read it from GIBI, - // save to MED again -> this new MED file is not readable) - set<string> medUniqueNames; - - _gibi << setw(8) << nbNames_mail*4 << endl; // Nb of table values - - TFieldCounter fcount1 (_gibi, 10); - _gibi << right; - list<nameGIBItoMED>::const_iterator itGIBItoMED = listGIBItoMED_mail.begin(); - for (; itGIBItoMED != listGIBItoMED_mail.end(); itGIBItoMED++, istr++) { - // PILE of i-th key(med name) - _gibi << setw(8) << 27; fcount1++; // PILE_STRINGS number is 27 - // ID of i-th key(med name) - _gibi << setw(8) << istr; fcount1++; - - // PILE of i-th value(gibi name) - _gibi << setw(8) << itGIBItoMED->gibi_pile; fcount1++; // PILE_SOUS_MAILLAGE number is 1 - // ID of i-th value(gibi name) - _gibi << setw(8) << itGIBItoMED->gibi_id; fcount1++; - - // check MED name to be unique - string aMedName = itGIBItoMED->med_name; - if (!medUniqueNames.insert(aMedName).second) { - string aMedNameNew; - int ind = 1; - char strInd [32]; - do { - sprintf(strInd, "_%d", ind++); - aMedNameNew = aMedName + strInd; - } while (!medUniqueNames.insert(aMedNameNew).second); - aMedName = aMedNameNew; - } - - // add to the string - theWholeString += aMedName; // MED name - - // add an offset - currOffset += aMedName.length(); - theOffsets.push_back(currOffset); - } - fcount1.stop(); - } - - // Table MED_CHAM - if (nbNames_cham) { - // Provide unique MED names, to exclude conflicts on reading saved files - // (use case: read fra.med, save it to GIBI, read it from GIBI, - // save to MED again -> this new MED file is not readable) - set<string> medUniqueNames; - - _gibi << setw(8) << nbNames_cham*4 << endl; // Nb of table values - - TFieldCounter fcount1 (_gibi, 10); - _gibi << right; - list<nameGIBItoMED>::const_iterator itGIBItoMED = listGIBItoMED_cham.begin(); - for (; itGIBItoMED != listGIBItoMED_cham.end(); itGIBItoMED++, istr++) { - // PILE of i-th key(med name) - _gibi << setw(8) << 27; fcount1++; // PILE_STRINGS number is 27 - // ID of i-th key(med name) - _gibi << setw(8) << istr; fcount1++; - - // PILE of i-th value(gibi name) - // PILE_NODES_FIELD number is 2, PILE_FIELD number is 39 - _gibi << setw(8) << itGIBItoMED->gibi_pile; fcount1++; - // ID of i-th value(gibi name) - _gibi << setw(8) << itGIBItoMED->gibi_id; fcount1++; - - // check MED name to be unique - string aMedName = itGIBItoMED->med_name; - if (!medUniqueNames.insert(aMedName).second) { - string aMedNameNew; - int ind = 1; - char strInd [32]; - do { - sprintf(strInd, "_%d", ind++); - aMedNameNew = aMedName + strInd; - } while (!medUniqueNames.insert(aMedNameNew).second); - aMedName = aMedNameNew; - } - - // add to the string - theWholeString += aMedName; // MED name - - // add an offset - currOffset += aMedName.length(); - theOffsets.push_back(currOffset); - } - fcount1.stop(); - } - - // Table MED_COMP - if (nbNames_comp) { - // for components, both key and value (long and short name) is in the STRING PILE - - _gibi << setw(8) << nbNames_comp*4 << endl; // Nb of table values - - TFieldCounter fcount1 (_gibi, 10); - _gibi << right; - list<nameGIBItoMED>::const_iterator itGIBItoMED = listGIBItoMED_comp.begin(); - for (; itGIBItoMED != listGIBItoMED_comp.end(); itGIBItoMED++, istr+=2) { - // PILE of i-th key(med name) - _gibi << setw(8) << 27; fcount1++; // PILE_STRINGS number is 27 - // ID of i-th key(med name) - _gibi << setw(8) << istr; fcount1++; - - // PILE of i-th value(gibi name) - _gibi << setw(8) << 27; fcount1++; // PILE_STRINGS number is 27 - // ID of i-th value(gibi name) - _gibi << setw(8) << istr + 1; fcount1++; - - // add to the string - string aMedName = itGIBItoMED->med_name; - string aGibiName = itGIBItoMED->gibi_name; - theWholeString += aMedName; // MED name - theWholeString += aGibiName; // GIBI name - - // add offsets - currOffset += aMedName.length(); - theOffsets.push_back(currOffset); - currOffset += aGibiName.length(); - theOffsets.push_back(currOffset); - } - fcount1.stop(); - } - - int nbNames = nbNames_mail + nbNames_cham + 2 * nbNames_comp; // tmp - - // The STRING PILE - // * 800 FORMAT (' ENREGISTREMENT DE TYPE', I4) - _gibi << " ENREGISTREMENT DE TYPE 2" << endl; - // * 801 FORMAT(' PILE NUMERO',I4,'NBRE OBJETS NOMMES',I8,'NBRE OBJETS',I8) - _gibi << " PILE NUMERO 27NBRE OBJETS NOMMES" << setw(8) << 0 << // No named strings - "NBRE OBJETS" << setw(8) << nbNames << endl; - - // Write IDs - //TFieldCounter fcount2 (_gibi, 10); - //_gibi << right; - //for (int jj = 1; jj <= nbNames; jj++) { - // _gibi << setw(8) << jj; fcount2++; - //} - //fcount2.stop(); - - // <LENGTH> <NB> - _gibi << setw(8) << theWholeString.length() - << setw(8) << nbNames << endl; - - // Write the whole string - const int fixedLength = 71; - int aPos = 0; - int aLen = theWholeString.length(); - for (; aPos < aLen; aPos += fixedLength) { - _gibi << setw(72) << theWholeString.substr(aPos, fixedLength) << endl; - } while (aPos < aLen); - - // Write the offsets - TFieldCounter fcount3 (_gibi, 10); - _gibi << right; - list<int>::iterator offsetIt = theOffsets.begin(); - for (; offsetIt != theOffsets.end(); offsetIt++) { - _gibi << setw(8) << (*offsetIt); fcount3++; - } - fcount3.stop(); -} - -//======================================================================= -//function : writeLastRecord -//purpose : -//======================================================================= - -void GIBI_MESH_WRONLY_DRIVER::writeLastRecord() -{ - _gibi << " ENREGISTREMENT DE TYPE 5" << endl; - _gibi << "LABEL AUTOMATIQUE : 1" << endl; -} - -/*--------------------- RDWR PART -------------------------------*/ - -GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER() - :GIBI_MESH_DRIVER(), GIBI_MESH_RDONLY_DRIVER(), GIBI_MESH_WRONLY_DRIVER() -{ -} -GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh): - GIBI_MESH_DRIVER(fileName,ptrMesh,RDWR), - GIBI_MESH_RDONLY_DRIVER(fileName,ptrMesh), - GIBI_MESH_WRONLY_DRIVER(fileName,ptrMesh) -{ - MESSAGE_MED("GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been created"); -} -GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER(const GIBI_MESH_RDWR_DRIVER & driver): - GIBI_MESH_DRIVER(driver), - GIBI_MESH_RDONLY_DRIVER(driver), - GIBI_MESH_WRONLY_DRIVER(driver) -{ - MESSAGE_MED("GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER(driver) has been created"); -} -GIBI_MESH_RDWR_DRIVER::~GIBI_MESH_RDWR_DRIVER() { - MESSAGE_MED("GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed"); -} -GENDRIVER * GIBI_MESH_RDWR_DRIVER::copy(void) const -{ - const char* LOC = "GIBI_MESH_RDWR_DRIVER::copy()"; - BEGIN_OF_MED(LOC); - GENDRIVER * driver = new GIBI_MESH_RDWR_DRIVER(*this); - END_OF_MED(LOC); - return driver; -} -void GIBI_MESH_RDWR_DRIVER::write(void) const - throw (MEDEXCEPTION) -{ - GIBI_MESH_RDWR_DRIVER * me = const_cast<GIBI_MESH_RDWR_DRIVER *>(this); - me->GIBI_MESH_WRONLY_DRIVER::open(); - me->GIBI_MESH_WRONLY_DRIVER::write(); - me->GIBI_MESH_WRONLY_DRIVER::close(); -} -void GIBI_MESH_RDWR_DRIVER::read (void) - throw (MEDEXCEPTION) -{ - const char* LOC = "GIBI_MESH_RDWR_DRIVER::read()"; - BEGIN_OF_MED(LOC); - GIBI_MESH_RDONLY_DRIVER::open(); - GIBI_MESH_RDONLY_DRIVER::read(); - GIBI_MESH_RDONLY_DRIVER::close(); - END_OF_MED(LOC); -} -void GIBI_MESH_RDWR_DRIVER::open() - // throw (MEDEXCEPTION) -{ -} -void GIBI_MESH_RDWR_DRIVER::close() - // throw (MEDEXCEPTION) -{ -} - -//============================== ==================================================== -//============================== FIELD Reading Driver ============================== -//============================== ==================================================== - -GIBI_MED_RDONLY_DRIVER::GIBI_MED_RDONLY_DRIVER():GIBI_MESH_RDONLY_DRIVER(),_fields(0) -{ -} -GIBI_MED_RDONLY_DRIVER::GIBI_MED_RDONLY_DRIVER(const string & fileName, vector<FIELD_*>& ptrFields): - GIBI_MESH_RDONLY_DRIVER(fileName,NULL), _fields( &ptrFields ) -{ - MESSAGE_MED("GIBI_MED_RDONLY_DRIVER(const string & fileName, vector<FIELD_*>&) has been created"); - _fileName = fileName; - _accessMode = RDONLY; -} -GIBI_MED_RDONLY_DRIVER::GIBI_MED_RDONLY_DRIVER(const GIBI_MED_RDONLY_DRIVER & driver): - GIBI_MESH_RDONLY_DRIVER( driver ), _fields( driver._fields ) -{ -} - -GIBI_MED_RDONLY_DRIVER::~GIBI_MED_RDONLY_DRIVER() -{ - if ( _mesh ) - _mesh->removeReference(); -} -GENDRIVER * GIBI_MED_RDONLY_DRIVER::copy ( void ) const -{ - return new GIBI_MED_RDONLY_DRIVER(*this); -} - -//======================================================================= -//function : read -//purpose : -//======================================================================= - -void GIBI_MED_RDONLY_DRIVER::read ( void ) throw (MEDEXCEPTION) -{ - const char * LOC = "GIBI_MED_RDONLY_DRIVER::read() : "; - BEGIN_OF_MED(LOC); - - if (_status!=MED_OPENED) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "file " << _fileName<<" is not opened." )); - - _mesh = new MESH; - - _intermediateMED medi; - try { - if ( !readFile( &medi, true ) ) - return; - - //MESSAGE_MED(LOC << medi ); - fillMesh( &medi ); - MESSAGE_MED(LOC << "GIBI_MED_RDONLY_DRIVER::read : RESULTATS STRUCTURE INTERMEDIAIRES : "); - MESSAGE_MED(LOC << medi ); - - list< FIELD_* > fields; - medi.getFields( fields ); - updateSupports(); // create families from groups etc. - MESSAGE_MED( "nb fields: " << fields.size() ); - - if ( _mesh->getName().empty() ) - _mesh->setName( "MESH" ); - - list< FIELD_* >::iterator it = fields.begin(); - for ( ; it != fields.end(); it++ ) - { - FIELD_* fld = *it; - int nbComponents = fld->getNumberOfComponents(); - if(nbComponents>0) { - UNIT* compoUnits = new UNIT[nbComponents]; - string* MEDcompoUnits = new string[nbComponents]; - for(int l = 0; l<nbComponents; l++) { - compoUnits[l] = UNIT("", ""); - MEDcompoUnits[l] = ""; - } - fld->setComponentsUnits(compoUnits); - fld->setMEDComponentsUnits(MEDcompoUnits); - delete [] compoUnits; - delete [] MEDcompoUnits; - } - // 0020466: [CEA] sauv2med : bad conversion - // Provide profile names for a partial field - const SUPPORT* sup = fld->getSupport(); - if ( sup && !sup->isOnAllElements() ) - { - vector<string> prof_names( sup->getNumberOfTypes() ); - for (unsigned itype=0; itype < prof_names.size(); itype++) - prof_names[itype]=STRING( sup->getName())<<"_type"<<sup->getTypes()[itype]; - ((SUPPORT*) sup)->setProfilNames( prof_names ); - } - _fields->push_back( *it ); - } - } - catch (MEDEXCEPTION &ex) - { - INFOS_MED( ex.what() ); - } - - END_OF_MED(LOC); -} - -//================================================================================ -/*! - * \brief Return a mesh created while reading fields. - * Call removeReference() after finishing using it. - */ -//================================================================================ - -MESH* GIBI_MED_RDONLY_DRIVER::getMesh() const -{ - if ( _mesh ) - _mesh->addReference(); - return (MESH*) _mesh; -} - - -//============================== ==================================================== -//============================== FIELD Writting Driver ============================== -//============================== ==================================================== - -GIBI_MED_WRONLY_DRIVER::GIBI_MED_WRONLY_DRIVER():GIBI_MESH_WRONLY_DRIVER() -{ -} -GIBI_MED_WRONLY_DRIVER::GIBI_MED_WRONLY_DRIVER(const string & fileName, - const vector<const FIELD_*>& fields, - GMESH * ptrMesh) - :GIBI_MESH_DRIVER(fileName,ptrMesh,WRONLY), - GIBI_MESH_WRONLY_DRIVER(fileName,ptrMesh), - _fields( fields ) -{ - const char * LOC = "GIBI_MED_WRONLY_DRIVER( fileName, vector<FIELD_*>&, MESH *)"; - BEGIN_OF_MED(LOC); - - if ( !_mesh ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << " Bad mesh " << _mesh )); - _fileName = fileName; - _accessMode = WRONLY; -} - -GIBI_MED_WRONLY_DRIVER::GIBI_MED_WRONLY_DRIVER(const GIBI_MED_WRONLY_DRIVER & driver): - GIBI_MESH_WRONLY_DRIVER( driver ), _fields( driver._fields ) -{ -} -GIBI_MED_WRONLY_DRIVER::~GIBI_MED_WRONLY_DRIVER() -{ -} -GENDRIVER * GIBI_MED_WRONLY_DRIVER::copy ( void ) const -{ - return new GIBI_MED_WRONLY_DRIVER(*this); -} - -//======================================================================= -//function : writeDataSection -//purpose : -//======================================================================= - -template< class T, class INTERLACING_TAG> -static void writeDataSection (fstream& file, - const FIELD<T, INTERLACING_TAG> * field, - const int id1, - const int id2) throw (MEDEXCEPTION) -{ - const char * LOC="writeDataSection (.....) :"; - BEGIN_OF_MED(LOC); - - int nbGauss, nbComp = field->getNumberOfComponents(); - - typedef typename MEDMEM_ArrayInterface<T,INTERLACING_TAG,NoGauss>::Array ArrayNoGauss; - typedef typename MEDMEM_ArrayInterface<T,INTERLACING_TAG,Gauss>::Array ArrayGauss; - - MEDMEM_Array_ * array = field->getArray(); - ArrayNoGauss * arrayNoGauss = 0; - ArrayGauss * arrayGauss = 0; - - if ( !array ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Field |"<< field->getName() - << "| not allocated")); - - if ( array->getGaussPresence() ) { - arrayGauss = field->getArrayGauss(); - nbGauss = arrayGauss->getNbGauss( id1 ); - } - else { - arrayNoGauss = field->getArrayNoGauss(); - nbGauss = 1; - } - - TFieldCounter fcount( file, 3 ); // 3 values on a line - -#ifdef CASTEM_FULL_INTERLACE - const int gauss_step = field->getInterlacingType() == MED_EN::MED_FULL_INTERLACE ? nbComp : 1; -#endif - const bool isNodal = ( field->getSupport()->getEntity() == MED_EN::MED_NODE ); - - for ( int iComp = 1; iComp <= nbComp; ++iComp ) - { - if ( !isNodal ) - file << setw(8) << nbGauss // nb scalar values by element - << setw(8) << ( id2 - id1 ) // total nb of scalar values - << setw(8) << 0 - << setw(8) << 0 - << endl; - - // * 8003 FORMAT(1P,3E22.14) - if ( arrayNoGauss ) { - for (int id = id1; id < id2; id++, fcount++ ) - file << setw(22) << arrayNoGauss->getIJ( id, iComp ); - } - else { -#ifdef CASTEM_FULL_INTERLACE - for (int id = id1; id < id2; id++ ) { - const T* val = & arrayGauss->getIJK( id, iComp, 1 ); - const T* valEnd = val + nbGauss * gauss_step; - for ( ; val < valEnd; val += gauss_step, fcount++ ) - file << setw(22) << *val; - } -#else - for ( int iGauss = 1; iGauss <= nbGauss; ++iGauss ) { - for (int id = id1; id < id2; id++, fcount++ ) - file << setw(22) << arrayGauss->getIJK( id, iComp, iGauss ); - } -#endif - } - fcount.stop(); - } - END_OF_MED(LOC); -} - -//======================================================================= -//function : write -//purpose : -//======================================================================= - -void GIBI_MED_WRONLY_DRIVER::write( void ) const throw (MEDEXCEPTION) -{ - const char* LOC = "void GIBI_MED_WRONLY_DRIVER::write(void) const : "; - BEGIN_OF_MED(LOC); - - // we are going to modify the _gibi field - GIBI_MED_WRONLY_DRIVER * me = const_cast<GIBI_MED_WRONLY_DRIVER *>(this); - - // get all fields on _mesh and add their support to be written - list<const FIELD_*> fields; - int iField, nbFields = _fields.size(); - list<int> nb_sub_list, nb_comp_list; - int nb_nodal_flds = 0; - - map<string,int> nameNbMap; - map<string,int> namePrefixMap; - list< string > orderedNames; - - list<pair<int,int> > subIdSizeList; // pair( <submesh id>, <submesh size> ); - list<pair<int,int> >::iterator idsize; - - // IMP 0020434: mapping GIBI names to MED names - list<nameGIBItoMED> listGIBItoMED_mail; - list<nameGIBItoMED> listGIBItoMED_cham; - list<nameGIBItoMED> listGIBItoMED_comp; - - for ( iField = 0; iField < nbFields; ++iField ) - { - int nb_sub = 0, nb_comp = 0; - const FIELD_ * f = _fields[ iField ]; - if ( f->getValueType() != MED_EN::MED_REEL64 ) - { - MESSAGE_MED("GIBI_MED_WRONLY_DRIVER::write( FIELD< int > ) not implemented"); - continue; - } - const SUPPORT * sup = f->getSupport(); - const medEntityMesh entity = sup->getEntity(); - - if ( me->addSupport( sup ) ) - { - if ( entity == MED_NODE ) fields.push_front( f ); - else fields.push_back( f ); - nb_sub += getSubMeshIdAndSize( sup, subIdSizeList ); - nb_comp += nb_sub * f->getNumberOfComponents(); - } - if ( nb_sub ) - { - if ( entity == MED_NODE ) - { - nb_sub_list.push_front ( nb_sub ); - orderedNames.push_front( f->getName() ); - nb_comp_list.push_front( nb_comp ); - nb_nodal_flds++; - } - else - { - nb_sub_list.push_back ( nb_sub ); - orderedNames.push_back( f->getName() ); - nb_comp_list.push_back( nb_comp ); - } - } - } - list< string >::iterator nameIt = orderedNames.begin(); - for ( iField = 0 ; nameIt != orderedNames.end(); ++nameIt, ++iField ) - { - const bool isNodal = iField < nb_nodal_flds; - int nb_obj = isNodal ? (iField + 1) : (iField - nb_nodal_flds + 1); - addName(nameNbMap, namePrefixMap, *nameIt, nb_obj); - - // IMP 0020434: mapping GIBI names to MED names - nameGIBItoMED aMEDName; - aMEDName.gibi_pile = isNodal ? PILE_NODES_FIELD : PILE_FIELD; - aMEDName.gibi_id = nb_obj; - aMEDName.med_name = *nameIt; - listGIBItoMED_cham.push_back(aMEDName); - } - - // write the mesh - - me->writeSupportsAndMesh(listGIBItoMED_mail); - - // write fields - - if ( !fields.empty() ) - { - fstream & gibi = me->_gibi; - - TFieldCounter fcount( gibi, 10 ); - - list<const FIELD_*>::const_iterator itF = fields.begin(); - list<int>::iterator itNbSub = nb_sub_list.begin(), itNbComp = nb_comp_list.begin(); - int nb_sub = 0, cur_nb_sub = 0, total_nb_comp = 0; - medEntityMesh entity = MED_INVALID; - - for ( iField = 0; itF != fields.end(); itF++, iField++ ) - { - const FIELD_* f = *itF; - - unsigned iComp, nbComp = unsigned( f->getNumberOfComponents() ); - - // IMP 0020434: mapping GIBI names to MED names - map<string, string> mapMedToGibi; - { - for (int ico = 0; ico < nbComp; ico++) - { - string compMedName = f->getComponentName(ico + 1); - compMedName = cleanName(compMedName); - mapMedToGibi[compMedName] = compMedName; - } - int compIndex = 1; - map<string, string>::iterator namesIt = mapMedToGibi.begin(); - for (; namesIt != mapMedToGibi.end(); namesIt++) - { - string compMedName = (*namesIt).first; - string compGibiName = compMedName; - if (compGibiName.size() > 4) { - // use new name in form "CXXX", where "XXX" is a number - do - { - char strCGN [32]; - strCGN[0] = 'C'; - int pos = 1; - if (compIndex < 100) strCGN[pos++] = '0'; - if (compIndex < 10 ) strCGN[pos++] = '0'; - sprintf(strCGN + pos, "%d", compIndex++); - compGibiName = strCGN; - } - while (mapMedToGibi.count(compGibiName) > 0); // real component name could be CXXX - - mapMedToGibi[compMedName] = compGibiName; - } - - compMedName = f->getName() + "." + compMedName; - nameGIBItoMED aMEDName; - aMEDName.med_name = compMedName; - aMEDName.gibi_pile = PILE_STRINGS; - aMEDName.gibi_name = compGibiName; - listGIBItoMED_comp.push_back(aMEDName); - } - } // IMP 0020434 - - if ( cur_nb_sub == nb_sub && itNbSub != nb_sub_list.end() ) - { - // Start writting another field - - const medEntityMesh nextEntity = f->getSupport()->getEntity(); - if ( nextEntity != entity ) - { - if ( entity == MED_INVALID || entity == MED_NODE ) - { - int nb_obj = ( nextEntity == MED_NODE ) ? nb_nodal_flds : orderedNames.size() - nb_nodal_flds; - gibi << " ENREGISTREMENT DE TYPE 2" << endl; - gibi << " PILE NUMERO" << ( nextEntity == MED_NODE ? " 2" : " 39" ); - gibi << "NBRE OBJETS NOMMES" << setw(8) << nameNbMap.size(); - gibi << "NBRE OBJETS" << setw(8) << nb_obj << endl; - - me->writeNames( nameNbMap ); - } - entity = f->getSupport()->getEntity(); - } - - total_nb_comp = *(itNbComp++); - nb_sub = *(itNbSub++); - - string description = (*itF)->getDescription(); - if ( description.size() > 72 ) - description = description.substr(0,72); - - if ( entity == MED_NODE ) - { - gibi << setw(8) << nb_sub - << setw(8) << total_nb_comp - << setw(8) << -1 // IFOUR - << setw(8) << 0 << endl; // nb attributes - } - else - { - gibi << setw(8) << nb_sub - << setw(8) << -1 - << setw(8) << 6 - << setw(8) << 72 /*description.size()*/ << endl; // PAL19100 - if ( !description.empty() ) - gibi << setw(72) << description << endl; - else - gibi << setw(72) << "Field" << endl; - gibi << setw(72) << " " << endl; - } - - // Sub Components section - - list<const FIELD_*>::const_iterator itF2 = itF; - int vals[9] = - { - 0, 0, 0, 0, 0, 0, 0, 0, 2 - }; - const int nbv = ( entity == MED_NODE ? 3 : 9 ); - vector< string > comp_names; - fcount.init(10); - cur_nb_sub = 0; - while ( itF2 != fields.end() && cur_nb_sub < nb_sub ) - { - const FIELD_* f = *itF2++; - vals[2] = f->getNumberOfComponents(); - getSubMeshIdAndSize( f->getSupport(), subIdSizeList ); - for ( idsize = subIdSizeList.begin(); idsize != subIdSizeList.end(); idsize++) - { - ++cur_nb_sub; - - vals[0] = -idsize->first; // support id - if ( entity == MED_NODE ) - vals[1] = idsize->second; // nb values - for ( int i = 0; i < nbv; ++i, fcount++ ) - gibi << setw(8) << vals[ i ]; - - for ( int i = 0; i < f->getNumberOfComponents(); ++i ) - comp_names.push_back( f->getComponentName( i+1 )); - } - } - fcount.stop(); - cur_nb_sub = 0; - - if ( entity == MED_NODE ) - { - // component names - fcount.init(8); - gibi << left; - { - for ( iComp = 0; iComp < comp_names.size(); ++iComp, fcount++ ) - { - string compMedName = cleanName(f->getComponentName(iComp + 1)); - string compName = mapMedToGibi[compMedName]; - gibi << " " << setw(8) << compName; - } - } - gibi << right; - fcount.stop(); - - // nb harmonics - fcount.init(10); - for ( int i = 0; i < total_nb_comp; ++i ) - gibi << setw(8) << 0; - fcount.stop(); - - gibi << endl; // TYPE - gibi << setw(72) << description << endl; - gibi << endl; // 0 attributes - } - else - { - // dummy strings - int i_sub; - for ( fcount.init(4), i_sub = 0; i_sub < nb_sub; ++i_sub, fcount++ ) - gibi << " "; - fcount.stop(); - - for ( fcount.init(8), i_sub = 0; i_sub < nb_sub; ++i_sub, fcount++ ) - gibi << " "; - fcount.stop(); - } - } // end writing common field data - - - // loop on sub-components - int id1 = 1; - getSubMeshIdAndSize( f->getSupport(), subIdSizeList ); - for ( idsize = subIdSizeList.begin(); idsize != subIdSizeList.end(); idsize++ ) - { - cur_nb_sub++; - if ( entity != MED_NODE ) - { - // component addresses - fcount.init(10); - for ( iComp = 0; iComp < nbComp; ++iComp, fcount++ ) - gibi << setw(8) << 777; // a good number - fcount.stop(); - // component names - gibi << left; - fcount.init(8); - for ( iComp = 0; iComp < nbComp; ++iComp, fcount++ ) - { - string compMedName = cleanName(f->getComponentName(iComp + 1)); - string compName = mapMedToGibi[compMedName]; - gibi << " " << setw(8) << compName; - } - fcount.stop(); - // component types - fcount.init(4); - for ( iComp = 0; iComp < nbComp; ++iComp, fcount++ ) - gibi << " " << setw(17) << "REAL*8"; - fcount.stop(); - gibi << right; - } - - // Data section - - int id2 = id1 + idsize->second; - - if ( f->getInterlacingType() == MED_NO_INTERLACE ) - writeDataSection( gibi, static_cast<const FIELD<double,NoInterlace > * >(f), - id1, id2 ); - else if ( f->getInterlacingType() == MED_FULL_INTERLACE ) - writeDataSection( gibi, static_cast<const FIELD<double,FullInterlace> * >(f), - id1, id2 ); - else - writeDataSection( gibi, static_cast<const FIELD<double,NoInterlaceByType> * >(f), - id1, id2 ); - - id1 = id2; - } - } // loop on fields - } - - // IMP 0020434: mapping GIBI names to MED names - me->writeMEDNames(listGIBItoMED_mail, listGIBItoMED_cham, listGIBItoMED_comp); - - me->writeLastRecord(); - - END_OF_MED(LOC); -} diff --git a/src/MEDMEM/MEDMEM_GibiMeshDriver.hxx b/src/MEDMEM/MEDMEM_GibiMeshDriver.hxx deleted file mode 100644 index 0c05a88a1..000000000 --- a/src/MEDMEM/MEDMEM_GibiMeshDriver.hxx +++ /dev/null @@ -1,494 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef GIBI_MESH_DRIVER_HXX -#define GIBI_MESH_DRIVER_HXX - -#include <MEDMEM.hxx> - -#include <string> -#include <vector> -#include <map> -#include <fstream> -#include <list> - -#include "MEDMEM_define.hxx" -#include "MEDMEM_GenDriver.hxx" - -#include "MEDMEM_STRING.hxx" -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_Utilities.hxx" - -#include "MEDMEM_FieldForward.hxx" - -///// -#include <sstream> -#include <iomanip> -///// - -#ifdef WIN32 -#else -#define HAS_XDR -#endif - -/*! - - Driver GIBI for MESH. - - Generic part : implement the readopen and close methods. - -*/ - -namespace MEDMEM { -class GMESH; -class MESH; -class FAMILY; -class GROUP; -class SUPPORT; -class CONNECTIVITY; -class FIELD_; -struct _intermediateMED; - -// IMP 0020434: mapping GIBI names to MED names -struct nameGIBItoMED { - // GIBI value - int gibi_pile; // PILE_SOUS_MAILLAGE or PILE_FIELD/PILE_NODES_FIELD, or PILE_STRINGS(for components) - int gibi_id; - string gibi_name; // used only for components - // MED value - // med_pile = 27; // PILE_STRINGS - int med_id; // used only on reading - string med_name; // used only on writing -}; - -class MEDMEM_EXPORT GIBI_MESH_DRIVER : public GENDRIVER -{ -protected: - - GMESH * _mesh; - std::string _meshName; - - // This enumeration is used to substitude static const - // memers data causing link errors on VC7 compiler. - enum - { - nb_geometrie_gibi = 47 - }; - // tableau de correspondance des types géométriques de CASTEM -> MED - //static const size_t nb_geometrie_gibi=47; - static const MED_EN::medGeometryElement geomGIBItoMED[nb_geometrie_gibi]; - ///// - -public : - - /*! - Constructor. - */ - GIBI_MESH_DRIVER() ; - /*! - Constructor. - */ - GIBI_MESH_DRIVER(const string & fileName, - GMESH * ptrMesh, - MED_EN::med_mode_acces accessMode) ; - /*! - Copy constructor. - */ - GIBI_MESH_DRIVER(const GIBI_MESH_DRIVER & driver) ; - - /*! - Destructor. - */ - virtual ~GIBI_MESH_DRIVER() ; - - virtual void write( void ) const = 0 ; - virtual void read ( void ) = 0 ; - - /*! - Set the name of the MESH asked in file. - - It could be different than the name of the MESH object. - */ - void setMeshName(const string & meshName) ; - /*! - Get the name of the MESH asked in file. - */ - string getMeshName() const ; - - static MED_EN::medGeometryElement gibi2medGeom( size_t gibiTypeNb ); - static int med2gibiGeom( MED_EN::medGeometryElement medGeomType ); - - private: - virtual GENDRIVER * copy ( void ) const = 0 ; - -}; - - -class MEDMEM_EXPORT GIBI_MESH_RDONLY_DRIVER : public virtual GIBI_MESH_DRIVER -{ -public : - - /*! - Constructor. - */ - GIBI_MESH_RDONLY_DRIVER() ; - /*! - Constructor. - */ - GIBI_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) ; - /*! - Copy constructor. - */ - GIBI_MESH_RDONLY_DRIVER(const GIBI_MESH_RDONLY_DRIVER & driver) ; - - /*! - Destructor. - */ - virtual ~GIBI_MESH_RDONLY_DRIVER() ; - - /*! - Return a MEDEXCEPTION : it is the read-only driver. - */ - void write( void ) const throw (MEDEXCEPTION); - /*! - Read MESH in the specified file. - */ - void read ( void ) throw (MEDEXCEPTION); - - void open(); - void close(); - -protected: - - bool readFile(_intermediateMED* medi, bool readFields ); - - void fillMesh(_intermediateMED* medi); - - void updateSupports(); - -private: - - GENDRIVER * copy ( void ) const ; - - // fields and methods for file reading - - bool getLine(char* & line); - bool getNextLine (char* & line, bool raiseIfNot = true ) throw (MEDEXCEPTION) - { - if ( getLine( line )) return true; - if ( raiseIfNot ) throw MEDEXCEPTION(LOCALIZED(STRING("Unexpected EOF on ln ")<<_lineNb)); - return false; - } - void initNameReading(int nbValues, int width = 8); // FORMAT(8(1X,A8)) - void initIntReading(int nbValues); // FORMAT(10I8) - void initDoubleReading(int nbValues); // FORMAT(1P,3E22.14) - void init( int nbToRead, int nbPosInLine, int width, int shift = 0 ); - bool more() const; - void next(); - char* str() const { return _curPos; } - int index() const { return _iRead; } - int getInt() const; - float getFloat() const; - double getDouble() const; - string getName() const; - - // line getting - int _File; - char* _start; - char* _ptr; - char* _eptr; - int _lineNb; - - // string reading - int _iPos, _nbPosInLine, _width, _shift; - int _iRead, _nbToRead; - char* _curPos; - - // xdr -#ifdef HAS_XDR - bool _is_xdr; - FILE* _xdrs_file; - void* _xdrs; - char* _xdr_cvals; - int* _xdr_ivals; - double* _xdr_dvals; - int _xdr_kind; - enum - { - _xdr_kind_null, - _xdr_kind_char, - _xdr_kind_int, - _xdr_kind_double - }; -#endif -}; - -/*! - - Driver Med for MESH : Write only. - - Implement write method. - -*/ - -class MEDMEM_EXPORT GIBI_MESH_WRONLY_DRIVER : public virtual GIBI_MESH_DRIVER { - -public : - - /*! - Constructor. - */ - GIBI_MESH_WRONLY_DRIVER() ; - /*! - Constructor. - */ - GIBI_MESH_WRONLY_DRIVER(const string & fileName, GMESH * ptrMesh) ; - /*! - Copy constructor. - */ - GIBI_MESH_WRONLY_DRIVER(const GIBI_MESH_WRONLY_DRIVER & driver) ; - - /*! - Destructor. - */ - virtual ~GIBI_MESH_WRONLY_DRIVER() ; - - /*! - Write MESH in the specified file. - */ - void write( void ) const throw (MEDEXCEPTION); - /*! - Return a MEDEXCEPTION : it is the write-only driver. - */ - void read ( void ) throw (MEDEXCEPTION); - - void open(); - void close(); - - protected: - - fstream _gibi; - - /*! - Add a support to write. Return true if a support will be written - */ - bool addSupport( const SUPPORT * support ); - /*! - return submesh id and size for a support. Call it after writeSupportsAndMesh() - */ - int getSubMeshIdAndSize(const SUPPORT * support, - std::list<std::pair<int,int> > & idsAndSizes ) const; - /*! - Write MESH and _supports. - */ - void writeSupportsAndMesh(list<nameGIBItoMED>& listGIBItoMED_mail); - /*! - * Store MED names of supports and fields. - * All MED names are written in STRINGS PILE, and the correspondence - * between GIBI and MED names is written as TABLE "noms_med" - */ - void writeMEDNames(const std::list<nameGIBItoMED>& listGIBItoMED_mail, - const std::list<nameGIBItoMED>& listGIBItoMED_cham, - const std::list<nameGIBItoMED>& listGIBItoMED_comp); - /*! - Write the record closing file - */ - void writeLastRecord(); - - //static void addName( map<string,int>& nameMap, string& name, int index, string prefix ); - static void addName( std::map<std::string,int>& nameMap, - std::map<std::string,int>& namePrefixesMap, - const std::string& name, - int index); - - void writeNames( std::map<std::string,int>& nameMap ); - - private: - - struct typeData - { - int _nbElems; - const int * _ptrElemIDs; // elem ids or - int _elemID1; // first elem id if isOnAllElements() - typeData( int nbElems=0, const int * ptrElemIDs=NULL, int elemID1=0 ) - : _nbElems(nbElems), _ptrElemIDs(ptrElemIDs), _elemID1(elemID1) {} - }; - struct supportData - { - typedef map< MED_EN::medGeometryElement, list< typeData > >::iterator typeIterator; - int _id; - string _cleanName; - map< MED_EN::medGeometryElement, list< typeData > > _types; - supportData(): _id(0) {} - int getNumberOfTypes() const { return _types.size(); } - int getNumberObjects() const - { return _types.size() < 2 ? _types.size() : _types.size() + !_cleanName.empty(); } - void addTypeData(MED_EN::medGeometryElement type, int nbElems, - const int * ptrElemIDs, int elemID1 ) - { _types[type].push_back( typeData( nbElems, ptrElemIDs, elemID1 )); } - }; - - void writeElements (MED_EN::medGeometryElement geomType, - list< typeData >& typeDataList, - const int * nodalConnect, - const int * nodalConnectIndex); - - map<const SUPPORT*, supportData> _supports; - - GENDRIVER * copy ( void ) const ; -}; - - -/*! - - Driver GIBI for MESH : Read write. - - Use read method from GIBI_MESH_RDONLY_DRIVER - - Use write method from GIBI_MESH_WRONLY_DRIVER - -*/ - -class MEDMEM_EXPORT GIBI_MESH_RDWR_DRIVER : public GIBI_MESH_RDONLY_DRIVER, public GIBI_MESH_WRONLY_DRIVER { - -public : - - /*! - Constructor. - */ - GIBI_MESH_RDWR_DRIVER() ; - /*! - Constructor. - */ - GIBI_MESH_RDWR_DRIVER(const std::string & fileName, MESH * ptrMesh) ; - /*! - Copy constructor. - */ - GIBI_MESH_RDWR_DRIVER(const GIBI_MESH_RDWR_DRIVER & driver) ; - - /*! - Destructor. - */ - ~GIBI_MESH_RDWR_DRIVER() ; - - /*! - Write MESH in the specified file. - */ - void write(void) const throw (MEDEXCEPTION); - /*! - Read MESH in the specified file. - */ - void read (void) throw (MEDEXCEPTION); - - void open(); - void close(); - - private: - GENDRIVER * copy(void) const ; - -}; - -class MEDMEM_EXPORT GIBI_MED_RDONLY_DRIVER : public GIBI_MESH_RDONLY_DRIVER { - - std::vector<FIELD_*> * _fields; - -public: - - /*! - Constructor. - */ - GIBI_MED_RDONLY_DRIVER() ; - /*! - Constructor. - */ - GIBI_MED_RDONLY_DRIVER(const std::string & fileName, std::vector<FIELD_*>& ptrFields) ; - /*! - Copy constructor. - */ - GIBI_MED_RDONLY_DRIVER(const GIBI_MED_RDONLY_DRIVER & driver) ; - - /*! - Destructor. - */ - virtual ~GIBI_MED_RDONLY_DRIVER() ; - - /*! - Read MESH and FIELDs in the specified file. - */ - void read ( void ) throw (MEDEXCEPTION); - - MESH* getMesh() const; - -private: - - GENDRIVER * copy ( void ) const ; - -}; - -/*! - - Driver Med for MESH : Write only. - - Implement write method. - -*/ - -class MEDMEM_EXPORT GIBI_MED_WRONLY_DRIVER : public GIBI_MESH_WRONLY_DRIVER { - - std::vector<const FIELD_*> _fields; - -public : - - /*! - Constructor. - */ - GIBI_MED_WRONLY_DRIVER() ; - /*! - Constructor. To write a mesh and all fields on it - */ - GIBI_MED_WRONLY_DRIVER(const std::string & fileName, - const std::vector<const FIELD_*>& fields, - GMESH * ptrMesh); - /*! - Copy constructor. - */ - GIBI_MED_WRONLY_DRIVER(const GIBI_MED_WRONLY_DRIVER & driver) ; - - /*! - Destructor. - */ - virtual ~GIBI_MED_WRONLY_DRIVER() ; - - /*! - Write MESH in the specified file. - */ - void write( void ) const throw (MEDEXCEPTION); - - //int getSupports(const FIELD_* field, list<const SUPPORT*>& supList) const; - -private: - - GENDRIVER * copy ( void ) const ; -}; - -} - - -#endif /* GIBI_MESH_DRIVER_HXX */ diff --git a/src/MEDMEM/MEDMEM_Grid.cxx b/src/MEDMEM/MEDMEM_Grid.cxx deleted file mode 100644 index 5a95cf081..000000000 --- a/src/MEDMEM/MEDMEM_Grid.cxx +++ /dev/null @@ -1,1213 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : MEDMEM_Grid.hxx -// Created : Wed Dec 18 08:35:26 2002 -// Descr : class containing structured mesh data -// Author : Edward AGAPOV (eap) -// Project : SALOME Pro -// Module : MED -// -#include "MEDMEM_Grid.hxx" -#include "MEDMEM_Meshing.hxx" -#include "MEDMEM_CellModel.hxx" -#include "MEDMEM_SkyLineArray.hxx" -#include "MEDMEM_DriverFactory.hxx" - -#include <memory> - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - - -// Block defining the comments for the MEDMEM_ug documentation - -/*! - -\defgroup GRID_axes Information about axes -This group of methods retrieves information about the axes of the grid. - -\defgroup GRID_connectivity Utility methods for defining element positions in the grid -These methods enable the user to convert a position on the grid to a global element number - -\defgroup GRID_constructors Constructors -These methods are the different constructors for the grid objects. - -*/ - -namespace -{ - const string* defaultStrings() - { - static const string str[3] = { "UNDEFINED", "UNDEFINED", "UNDEFINED" }; - return str; - } -} - -//======================================================================= -//function : GRID -//purpose : empty constructor -//======================================================================= - -GRID::GRID() { - init(); - MESSAGE_MED("A GRID CREATED"); -} -// -//======================================================================= -////function : GRID -////purpose : array constructor -////======================================================================= -/*! -\if MEDMEM_ug -\addtogroup GRID_constructors -@{ -\endif -*/ -/*! - * \brief Constructor specifying the axes of the grid - * - * This constructor describes the grid by specifying the location of the nodes on -each of the axis. The dimension of the grid is implicitly defined by the -size of vector \a xyz_array. - * - *\param xyz_array specifies the node coordinates for each direction - *\param coord_name names of the different coordinates - *\param coord_unit names of the different coordinate units - *\param type grid type (MED_POLAR, MED_CARTESIAN) -*/ -GRID::GRID(const std::vector<std::vector<double> >& xyz_array, - const std::vector<std::string>& coord_name, - const std::vector<std::string>& coord_unit, - const MED_EN::med_grid_type type) - :_gridType(type) -{ - init(); // PAL 12136 - _is_default_gridType = false; - - _spaceDimension = xyz_array.size(); - - // create a non allocated COORDINATE - _coordinate = new COORDINATE(_spaceDimension, &coord_name[0], &coord_unit[0]); - string coordinateSystem = "UNDEFINED"; - if( _gridType == MED_CARTESIAN) - coordinateSystem = "CARTESIAN"; - else if ( _gridType == MED_POLAR) - coordinateSystem = "CYLINDRICAL"; - _coordinate->setCoordinatesSystem(coordinateSystem); - - // set the GRID part - if (_spaceDimension>=1) - { - _iArrayLength=xyz_array[0].size(); - _iArray=new double[_iArrayLength]; - std::copy(xyz_array[0].begin(),xyz_array[0].end(),_iArray); - } - if (_spaceDimension>=2) - { - _jArrayLength=xyz_array[1].size(); - _jArray=new double[_jArrayLength]; - std::copy(xyz_array[1].begin(),xyz_array[1].end(),_jArray); - } - if (_spaceDimension>=3) - { - _kArrayLength=xyz_array[2].size(); - _kArray=new double[_kArrayLength]; - std::copy(xyz_array[2].begin(),xyz_array[2].end(),_kArray); - } -} - -//================================================================================ -/*! - * \brief Reads a GRID form the file - * \param driverType - type of driver to read the specified file - * \param fileName - the file name to read - * \param driverName - name of a grid to read - */ -//================================================================================ - -GRID::GRID(driverTypes driverType, const string & fileName, const string & driverName) -{ - - const char* LOC = "GRID::GRID(driverTypes , const string & , const string &) : "; - BEGIN_OF_MED(LOC); - - init(); - auto_ptr<GENDRIVER> myDriver (DRIVERFACTORY::buildDriverForMesh(driverType,fileName,this,driverName,RDONLY)); - myDriver->open(); - myDriver->read(); - myDriver->close(); - - END_OF_MED(LOC); -} - -/*!\if MEDMEM_ug @} \endif */ - -//======================================================================= -//function : GRID -//purpose : empty constructor -//======================================================================= - -GRID::GRID(const MED_EN::med_grid_type type) -{ - init(); - _gridType = type; - _is_default_gridType = false; - MESSAGE_MED("A TYPED GRID CREATED"); -} - -//======================================================================= -//function : GRID -//purpose : copying constructor -//======================================================================= - -GRID::GRID(const GRID& otherGrid) { - *this = otherGrid; -} - -//======================================================================= -//function : ~GRID -//purpose : destructor -//======================================================================= - -GRID::~GRID() { - MESSAGE_MED("GRID::~GRID() : Destroying the Grid"); - if ( _coordinate ) delete _coordinate; _coordinate = 0; - if ( _iArray != (double* ) NULL) delete [] _iArray; - if ( _jArray != (double* ) NULL) delete [] _jArray; - if ( _kArray != (double* ) NULL) delete [] _kArray; -} - -//======================================================================= -//function : init -//purpose : -//======================================================================= - -void GRID::init() -{ - GMESH::init(); - - _gridType = MED_CARTESIAN; - _is_default_gridType = true; - _coordinate = 0; - _iArray = _jArray = _kArray = (double* ) NULL; - _iArrayLength = _jArrayLength = _kArrayLength = 0; - -} - -//================================================================================ -/*! - * \brief Return true if contains no elements - */ -//================================================================================ - -bool GRID::isEmpty() const -{ - return !_iArrayLength && !_coordinate; -} - - -//======================================================================= -//function: operator= -//purpose : operator= -//======================================================================= - -GRID & GRID::operator=(const GRID & otherGrid) -{ - // NOT IMPLEMENTED - - GMESH::operator=(otherGrid); - return *this; -} - -//======================================================================= -/*! - Returns true if mesh \a other has same - coordinates (to 1E-15 precision ) and same connectivity as the calling object. - Information like name or description is not taken into account - for the comparison. -*/ -//======================================================================= - -bool GRID::deepCompare(const GMESH& gother) const -{ - if ( gother.getIsAGrid() != getIsAGrid()) - return false; - const GRID& other = static_cast<const GRID&>( gother ); - - if ( getSpaceDimension() != other.getSpaceDimension() ) - return false; - - if ( _gridType != other._gridType ) - return false; - - if( bool( _coordinate) != bool(other._coordinate)) - return false; - - if ( _coordinate->getNumberOfNodes() > 0 ) - { - if ( _coordinate->getNumberOfNodes() != other._coordinate->getNumberOfNodes() ) - return false; - const int size = _coordinate->getNumberOfNodes() * getSpaceDimension(); - const double* coord1=_coordinate->getCoordinates(MED_FULL_INTERLACE); - const double* coord2=other._coordinate->getCoordinates(MED_FULL_INTERLACE); - for(int i = 0 ; i < size; i++ ) - if ( !(fabs(coord1[i]-coord2[i])<1e-15)) - return false; - } - - if ( _iArrayLength != other._iArrayLength ) - return false; - if ( _jArrayLength != other._jArrayLength ) - return false; - if ( _kArrayLength != other._kArrayLength ) - return false; - - if ( bool(_iArray) != bool(other._iArray) ) - return false; - if ( bool(_jArray) != bool(other._jArray) ) - return false; - if ( bool(_kArray) != bool(other._kArray) ) - return false; - - if ( _iArray ) - for ( int i = 0; i < _iArrayLength; ++i ) - if ( !(fabs(_iArray[i]-other._iArray[i])<1e-15)) - return false; - if ( _jArray ) - for ( int i = 0; i < _jArrayLength; ++i ) - if ( !(fabs(_jArray[i]-other._jArray[i])<1e-15)) - return false; - if ( _kArray ) - for ( int i = 0; i < _kArrayLength; ++i ) - if ( !(fabs(_kArray[i]-other._kArray[i])<1e-15)) - return false; - - return true; -} - -//================================================================================ -/*! - * \brief print my contents - */ -//================================================================================ - -void GRID::printMySelf(std::ostream &os) const -{ - // TODO - cout << "NOT IMPLEMENTED" << endl; -} - -//================================================================================ -/*! - * \brief Create an unstructured MESH. Call removeReference() after having finished using it!!! - */ -//================================================================================ - -const MESH * GRID::convertInMESH() const -{ - MESHING* mesh = new MESHING; - mesh->setName( getName() ); - - int i, j, k; - - // --------------- - // 1. Coordinates - // --------------- - - PointerOf< double > coords; - if ( _gridType == MED_BODY_FITTED ) - { - if ( !_coordinate ) - throw MEDEXCEPTION - (LOCALIZED("GRID::convertInMESH() : _coordinate of MED_BODY_FITTED GRID not defined !")); - coords.set( _coordinate->getCoordinates(MED_FULL_INTERLACE)); - } - else - { - coords.set( getSpaceDimension() * getNumberOfNodes() ); - double* coord = coords; - switch ( getSpaceDimension() ) - { - case 3: - for (k=0; k < _kArrayLength; ++k) - for (j=0; j < _jArrayLength; ++j) - for (i=0; i < _iArrayLength; ++i) - *coord++ = _iArray[i], *coord++ = _jArray[j], *coord++ = _kArray[k]; - break; - - case 2: - for (j=0; j < _jArrayLength; ++j) - for (i=0; i < _iArrayLength; ++i) - *coord++ = _iArray[i], *coord++ = _jArray[j]; - break; - - case 1: - coords.set(_iArray); - break; - } - } - mesh->setCoordinates( getSpaceDimension(), - getNumberOfNodes(), - (const double *) coords, - getCoordinatesSystem(), - MED_EN::MED_FULL_INTERLACE); - mesh->setCoordinatesNames( getCoordinatesNames() ); - mesh->setCoordinatesUnits( getCoordinatesUnits() ); - - // ---------------- - // 2. Connectivity - // ---------------- - - // 2.1 Cells - // --------- - medEntityMesh subEntity; - { - mesh->setNumberOfTypes( getNumberOfTypes(MED_CELL), MED_CELL ); - mesh->setTypes( getTypes( MED_CELL), MED_CELL ); - int nbCells = getNumberOfElements( MED_CELL, MED_ALL_ELEMENTS ); - mesh->setNumberOfElements( &nbCells, MED_CELL ); - - vector<int> conn; - switch ( _spaceDimension ) - { - case 3: // HEXA8 - for ( k = 0; k < _kArrayLength-1; ++k ) - for ( j = 0; j < _jArrayLength-1; ++j ) - for ( i = 0; i < _iArrayLength-1; ++i ) - { - conn.push_back( getNodeNumber( i , j , k )); - conn.push_back( getNodeNumber( i , j+1, k )); - conn.push_back( getNodeNumber( i+1, j+1, k )); - conn.push_back( getNodeNumber( i+1, j , k )); - conn.push_back( getNodeNumber( i , j , k+1)); - conn.push_back( getNodeNumber( i , j+1, k+1)); - conn.push_back( getNodeNumber( i+1, j+1, k+1)); - conn.push_back( getNodeNumber( i+1, j , k+1)); - } - subEntity = MED_FACE; - break; - - case 2: // QUAD4 - for ( j = 0; j < _jArrayLength-1; ++j ) - for ( i = 0; i < _iArrayLength-1; ++i ) - { - int n1 = 1 + i + j*_iArrayLength; - conn.push_back( n1 ); - conn.push_back( n1 + _iArrayLength ); - conn.push_back( n1 + _iArrayLength + 1 ); - conn.push_back( n1 + 1 ); - } - subEntity = MED_EDGE; - break; - - case 1: // SEG2 - for ( i = 0; i < _iArrayLength-1; ++i ) - { - conn.push_back( i + 1 ); - conn.push_back( i + 2 ); - } - break; - } - mesh->setConnectivity( MED_CELL, getTypes(MED_CELL)[0], &conn[0] ); - } - - // 2.2 sub entities - // ----------------- - - if ( _spaceDimension > 1 ) - { - mesh->setNumberOfTypes( getNumberOfTypes(subEntity), subEntity ); - mesh->setTypes( getTypes( subEntity), subEntity ); - int nbCells = getNumberOfElements( subEntity, MED_ALL_ELEMENTS ); - mesh->setNumberOfElements( &nbCells, subEntity ); - - vector<int> conn; - switch ( _spaceDimension ) - { - case 3: // QUAD4 - - // normal to OX - for ( k = 0; k < _kArrayLength-1; ++k ) - for ( j = 0; j < _jArrayLength-1; ++j ) - for ( i = 0; i < _iArrayLength; ++i ) - { - conn.push_back( getNodeNumber( i, j , k )); - conn.push_back( getNodeNumber( i, j , k+1)); - conn.push_back( getNodeNumber( i, j+1, k+1)); - conn.push_back( getNodeNumber( i, j+1, k )); - } - // normal to OY - for ( k = 0; k < _kArrayLength-1; ++k ) - for ( j = 0; j < _jArrayLength; ++j ) - for ( i = 0; i < _iArrayLength-1; ++i ) - { - conn.push_back( getNodeNumber( i , j, k )); - conn.push_back( getNodeNumber( i+1, j, k )); - conn.push_back( getNodeNumber( i+1, j, k+1)); - conn.push_back( getNodeNumber( i , j, k+1)); - } - // normal to OZ - for ( k = 0; k < _kArrayLength; ++k ) - for ( j = 0; j < _jArrayLength-1; ++j ) - for ( i = 0; i < _iArrayLength-1; ++i ) - { - conn.push_back( getNodeNumber( i , j , k)); - conn.push_back( getNodeNumber( i , j+1, k)); - conn.push_back( getNodeNumber( i+1, j+1, k)); - conn.push_back( getNodeNumber( i+1, j , k)); - } - break; - - case 2: // SEG2 - - // || OX - for ( j = 0; j < _jArrayLength; ++j ) - for ( i = 0; i < _iArrayLength-1; ++i ) - { - int n1 = 1 + i + j*_iArrayLength; - conn.push_back( n1 ); - conn.push_back( n1 + 1 ); - } - // || OY - for ( j = 0; j < _jArrayLength-1; ++j ) - for ( i = 0; i < _iArrayLength; ++i ) - { - int n1 = 1 + i + j*_iArrayLength; - conn.push_back( n1 ); - conn.push_back( n1 + _iArrayLength ); - } - break; - - } - mesh->setConnectivity( subEntity, getTypes(subEntity)[0], &conn[0] ); - } - - // 3. Groups and Families - // ----------------------- - - const vector<GROUP*>* groups[] = { &_groupNode, &_groupCell, &_groupFace, &_groupEdge }; - for ( i = 0; i < 4; ++i ) - for ( j = 0; j < (int)groups[i]->size(); ++j ) - mesh->addGroup( * groups[i]->at( j )); - - return mesh; -} - -//======================================================================= -/*! - return the GRID Geometric type, without computing all connectivity -*/ -//======================================================================= - -const medGeometryElement * GRID::getTypes(MED_EN::medEntityMesh entity) const -{ - static const medGeometryElement _gridGeometry[4]={MED_HEXA8,MED_QUAD4,MED_SEG2,MED_POINT1}; - int i=0; - if(entity==MED_CELL) - { - i=3-_spaceDimension; - } - else if(entity==MED_FACE && _spaceDimension>2 ) - i=1; - else if(entity==MED_EDGE && _spaceDimension>1 ) - i=2; - else if(entity==MED_NODE && _spaceDimension>0) - i=3; - else - throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::getGeometricTypes : Entity not defined !")); - return &_gridGeometry[i]; -} - -//======================================================================= -//function : getArrayLength -//purpose : return array length. Axis = [1,2,3] meaning [i,j,k], -//======================================================================= -/*!\if MEDMEM_ug -\addtogroup GRID_axes -@{ -\endif -*/ -/*! Returns the number of nodes on axis number \a Axis (axis numbering starts at 1). -*/ -int GRID::getArrayLength( const int Axis ) const throw (MEDEXCEPTION) -{ - switch (Axis) { - case 1: return _iArrayLength; - case 2: return _jArrayLength; - case 3: return _kArrayLength; - default: - throw MED_EXCEPTION ( LOCALIZED( STRING("GRID::getArrayLength ( ") << Axis << ")")); - } - return 0; -} - -//======================================================================= -//function : getArrayValue -//purpose : return i-th array component. Axis = [1,2,3] meaning [i,j,k], -// exception if Axis out of [1-3] range -// exception if i is out of range 0 <= i < getArrayLength(Axis); -//======================================================================= -/*! -Returns the value of node coordinate \a i on axis \a Axis. - */ -const double GRID::getArrayValue (const int Axis, const int i) const throw (MEDEXCEPTION) -{ - if (i < 0 || i >= getArrayLength(Axis)) - throw MED_EXCEPTION - ( LOCALIZED(STRING("GRID::getArrayValue ( ") << Axis << ", " << i << ")")); - - switch (Axis) { - case 1: return _iArray[ i ]; - case 2: return _jArray[ i ]; - default: return _kArray[ i ]; - } - return 0.0; -} - -/*! -\if MEDMEM_ug -@} -\endif - */ - -/*! -\if MEDMEM_ug -\addtogroup GRID_connectivity -@{ -\endif -*/ -/*! -@{ -\name Position to number conversion methods -\a getXXXNumber methods enable the user to convert an \f$ (i,j,k)\f$ position into a global number in the array. - -Axis [1,2,3] means one of directions: along \a i, \a j or \a k. -For cell constituents (FACE or EDGE), Axis selects one of those having same \f$ (i, j, k )\f$ : -- a FACE which is normal to direction along given \a Axis; -- an EDGE going along given \a Axis. - \a i, \a j and \a k counts from zero. - -Exception for \a Axis out of range. -For 2D grids, \a k is a dummy argument. */ - -//================================================================================ -/*! Edge position to number conversion method*/ -//================================================================================ - -int GRID::getEdgeNumber(const int Axis, const int i, const int j, const int k) - const throw (MEDEXCEPTION) -{ - const char * LOC = "GRID::getEdgeNumber(Axis, i,j,k) :"; - - BEGIN_OF_MED(LOC); - - int Len[4] = {0,_iArrayLength, _jArrayLength, _kArrayLength }, I=1, J=2, K=3; - int maxAxis = Len[ K ] ? 3 : 2; - - if (Axis <= 0 || Axis > maxAxis) - throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Axis out of range: " << Axis)); - - Len[Axis]--; - int Nb = 1 + i + j*Len[ I ] + k*Len[ J ]*Len[ K ]; - Len[Axis]++ ; - - if (!Len[ K ]) - Len[ K ] = 1; - - if (Axis > 1) { // add all edges in i direction - Len[I]-- ; - Nb += Len[ I ]*Len[ J ]*Len[ K ]; - Len[I]++ ; - } - if (Axis > 2) { // add all edges in j direction - Len[J]-- ; - Nb += Len[ I ]*Len[ J ]*Len[ K ]; - } - - END_OF_MED(LOC); - - return Nb; -} - -//================================================================================ -/*! -Returns a NODE, EDGE, FACE, CELL number by its position in the grid. -Axis [1,2,3] means one of directions: along i, j or k -For Cell contituents (FACE or EDGE), Axis selects one of those having same (i,j,k): -- a FACE which is normal to direction along given Axis; -- an EDGE going along given Axis. -Exception for Axis out of range -*/ -//================================================================================ - -int GRID::getFaceNumber(const int Axis, const int i, const int j, const int k) - const throw (MEDEXCEPTION) -{ - const char * LOC = "GRID::getFaceNumber(Axis, i,j,k) :"; - - BEGIN_OF_MED(LOC); - -// if (Axis <= 0 || Axis > 3) - if (Axis < 0 || Axis > 3) - throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Axis = " << Axis)); - - int Len[4] = {0,_iArrayLength-1, _jArrayLength-1, _kArrayLength-1 }, I=1, J=2, K=3; - - Len[Axis]++; - int Nb = 1 + i + j*Len[ I ] + k*Len[ I ]*Len[ J ]; - Len[Axis]--; - - if (Axis > 1) // add all faces nornal to i direction - Nb += ( Len[ I ]+1 )*Len[ J ]*Len[ K ]; - - if (Axis > 2) // add all faces nornal to j direction - Nb += Len[ I ]*( Len[ J ]+1 )*Len[ K ]; - - END_OF_MED(LOC); - - return Nb; -} -/*! @} */ - - -/*! -@{ -\name Number to position conversion methods - -\a getXXXPosition functions enable the user to convert -a number into a \f$ (i,j,k) \f$ position. - Axis [1,2,3] means one of directions: along i, j or k - For Cell constituents (FACE or EDGE), Axis selects one of those having same (i,j,k): - - a FACE which is normal to direction along given Axis; - - an EDGE going along given Axis. - - Exception for Number out of range. -*/ - -//================================================================================ -/*! Node number to position conversion method */ -//================================================================================ - -void GRID::getNodePosition(const int Number, int& i, int& j, int& k) const - throw (MEDEXCEPTION) -{ - const char * LOC = "GRID::getNodePosition(Number, i,j,k) :"; - - BEGIN_OF_MED(LOC); - - if (Number <= 0 || Number > getNumberOfNodes() ) - throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Number is out of range: " << Number)); - - int Len[] = {_iArrayLength, _jArrayLength, _kArrayLength }, I=0, J=1; - // , K=2; !! UNUSED VARIABLE !! - - int ijLen = Len[I] * Len[J]; // nb in a full k layer - int kLen = (Number - 1) % ijLen; // nb in the non full k layer - - i = kLen % Len[J]; - j = kLen / Len[J]; - k = (Number - 1) / ijLen; - - ////cout <<" NODE POS: " << Number << " - " << i << ", " << j << ", " << k << endl; - - END_OF_MED(LOC); - -} - -//======================================================================= -//function : getCellPosition -//purpose : -//======================================================================= -/*! Cell number to position conversion method */ -void GRID::getCellPosition(const int Number, int& i, int& j, int& k) const - throw (MEDEXCEPTION) -{ - - const char* LOC = "GRID::getCellPosition(Number, i,j,k) :"; - BEGIN_OF_MED(LOC); - - int Len[4] = {0,_iArrayLength-1, _jArrayLength-1, _kArrayLength-1 }, I=1, J=2; - // , K=3; !! UNUSED VARIABLE !! - -// if (Number <= 0 || Number > getCellNumber(Len[I]-1, Len[J]-1, Len[K]-1)) -// throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Number is out of range: " << Number)); - - int ijLen = Len[I] * Len[J]; // nb in a full k layer - int kLen = (Number - 1) % ijLen; // nb in the non full k layer - - i = kLen % Len[J]; - j = kLen / Len[J]; - k = (Number - 1) / ijLen; - - END_OF_MED(LOC); -} - -//======================================================================= -//function : getEdgePosition -//purpose : -//======================================================================= -/*! Edge number to poistion conversion method*/ -void GRID::getEdgePosition(const int Number, int& Axis, int& i, int& j, int& k) - const throw (MEDEXCEPTION) -{ - const char * LOC = "GRID::getEdgePosition(Number, i,j,k) :"; - - BEGIN_OF_MED(LOC); - - if (!_jArrayLength) - throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "no edges in the grid: ")); - - if (Number <= 0) - throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Number is out of range: " << Number)); - - int Len[4] = {0,_iArrayLength, _jArrayLength, _kArrayLength }, I=1, J=2, K=3; - - int theNb = Number; - int maxAxis = _kArrayLength ? 3 : 2; - - for (Axis = 1; Axis <= maxAxis; ++Axis) - { - Len[Axis]--; // one less edge in Axis direction - - // max edge number in Axis direction - int maxNb = getEdgeNumber (Axis, Len[I]-1, Len[J]-1, Len[K]-1); - - if (theNb > maxNb) - { - Len[Axis]++; - theNb -= maxNb; - continue; - } - - if (theNb == maxNb) - { - i = Len[I]-1; - j = Len[J]-1; - k = Len[K]-1; - } - else - { - int ijLen = Len[I] * Len[J]; // nb in a full k layer - int kLen = (theNb - 1) % ijLen; // nb in the non full k layer - i = kLen % Len[J]; - j = kLen / Len[J]; - k = (theNb - 1) / ijLen; - } - - END_OF_MED(LOC); - - return; - } - - throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Number is out of range: " << Number)); -} - -//======================================================================= -//function : getFacePosition -//purpose : return position (i,j,k) of an entity #Number -// Axis [1,2,3] means one of directions: along i, j or k -// For Cell contituents (FACE or EDGE), Axis selects one of those having same (i,j,k): -// * a FACE which is normal to direction along given Axis; -// * an EDGE going along given Axis. -// Exception for Number out of range -//======================================================================= -/*! Face number to position convertion method*/ -void GRID::getFacePosition(const int Number, int& Axis, int& i, int& j, int& k) - const throw (MEDEXCEPTION) -{ - const char * LOC = "GRID::getFacePosition(Number, i,j,k) :"; - - BEGIN_OF_MED(LOC); - - if (_kArrayLength == 0) { - getCellPosition(Number, i, j, k); - Axis = 1; - return; - }; - - if (!_kArrayLength) - throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "no faces in the grid: ")); - - if ( Number <= 0 ) - throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Number is out of range: " << Number)); - - int Len[4] = {0,_iArrayLength-1, _jArrayLength-1, _kArrayLength-1 }, I=1, J=2, K=3; - int theNb = Number; - - for (Axis = 1; Axis <= 3; ++Axis) - { - Len[Axis]++; - - // max face number in Axis direction - int maxNb = getFaceNumber (Axis, Len[I]-1, Len[J]-1, Len[K]-1); - - if (theNb > maxNb) - { - Len[Axis]--; - theNb -= maxNb; - continue; - } - - if (theNb == maxNb) - { - i = Len[I]-1; - j = Len[J]-1; - k = Len[K]-1; - } - else - { - int ijLen = Len[I] * Len[J]; // nb in a full k layer - int kLen = (theNb - 1) % ijLen; // nb in the non full k layer - i = kLen % Len[J]; - j = kLen / Len[J]; - k = (theNb - 1) / ijLen; - } - - END_OF_MED(LOC); - - return; - } - - throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Number is out of range: " << Number)); -} -/*! -@} -\if MEDMEM_ug -@} -\endif -*/ - -//================================================================================ -/*! Get the number of different geometric types for a given entity type. - - medEntityMesh entity : MED_CELL, MED_FACE, MED_EDGE, MED_NODE, - MED_ALL_ENTITIES - -*/ -//================================================================================ - -int GRID::getNumberOfTypes(MED_EN::medEntityMesh entity) const -{ - MESSAGE_MED("GRID::getNumberOfTypes(medEntityMesh entity) : "<<entity); - return 1; // a grid has one type -} - -//================================================================================ -/*! - Return the number of element of given geometric type of given entity. Return 0 if query is not defined. -*/ -//================================================================================ - -int GRID::getNumberOfElements(MED_EN::medEntityMesh entity, MED_EN::medGeometryElement Type) const -{ - int numberOfElements=0; - - // Cas où le nombre d'éléments n'est pas nul - if (entity==MED_EN::MED_FACE && (Type==MED_EN::MED_QUAD4 || Type==MED_EN::MED_ALL_ELEMENTS) && getMeshDimension()>2) - numberOfElements= - (_iArrayLength-1)*(_jArrayLength-1)*(_kArrayLength )+ - (_iArrayLength-1)*(_jArrayLength )*(_kArrayLength-1)+ - (_iArrayLength )*(_jArrayLength-1)*(_kArrayLength-1); - - else if (entity==MED_EN::MED_EDGE && (Type==MED_EN::MED_SEG2 || Type==MED_EN::MED_ALL_ELEMENTS)) - if ( _spaceDimension==2) - numberOfElements=_iArrayLength*(_jArrayLength-1) + (_iArrayLength-1)*_jArrayLength; - else if ( _spaceDimension==1) - numberOfElements=_iArrayLength-1; - else // 3D - numberOfElements= - (_iArrayLength*(_jArrayLength-1) + (_iArrayLength-1)*_jArrayLength) * _kArrayLength + - _iArrayLength*_jArrayLength*(_kArrayLength-1); - - else if (entity==MED_EN::MED_NODE && (Type==MED_EN::MED_NONE || Type==MED_EN::MED_ALL_ELEMENTS) && _spaceDimension>0) - numberOfElements=getNumberOfNodes(); - - else if (entity==MED_EN::MED_CELL && _spaceDimension==3 && (Type==MED_EN::MED_HEXA8 || Type==MED_EN::MED_ALL_ELEMENTS) ) - numberOfElements=(_iArrayLength-1)*(_jArrayLength-1)*(_kArrayLength-1); - - else if (entity==MED_EN::MED_CELL && _spaceDimension==2 && (Type==MED_EN::MED_QUAD4 || Type==MED_EN::MED_ALL_ELEMENTS)) - numberOfElements=(_iArrayLength-1)*(_jArrayLength-1); - - else if (entity==MED_EN::MED_CELL && _spaceDimension==1 && (Type==MED_EN::MED_SEG2 || Type==MED_EN::MED_ALL_ELEMENTS) ) - numberOfElements=_iArrayLength-1; - - MESSAGE_MED("GRID::getNumberOfElements - entity=" << entity << " Type=" << Type); - MESSAGE_MED("_spaceDimension=" << _spaceDimension << " numberOfElements=" << numberOfElements); - - return numberOfElements; -} - -//================================================================================ -/*! - Return the geometric type of global element Number of entity Entity. -*/ -//================================================================================ - -MED_EN::medGeometryElement GRID::getElementType(MED_EN::medEntityMesh Entity,int Number) const -{ - return getTypes(Entity)[0]; -} - -//================================================================================ -/*! - * \brief Return mesh dimension - */ -//================================================================================ - -int GRID::getMeshDimension() const -{ - return getSpaceDimension(); -} - -//================================================================================ -/*! - * \brief It is a grid - */ -//================================================================================ - -bool GRID::getIsAGrid() const -{ - return true; -} - -//================================================================================ -/*! - * \brief Return number of nodes - */ -//================================================================================ - -int GRID::getNumberOfNodes() const -{ - if ( _gridType == MED_EN::MED_BODY_FITTED ) - return _coordinate ? _coordinate->getNumberOfNodes() : 0; - - switch ( _spaceDimension ) - { - case 3: return _iArrayLength * _jArrayLength * _kArrayLength; - case 2: return _iArrayLength * _jArrayLength; - case 1: return _iArrayLength; - } - return 0; -} - -//======================================================================= -/*! - * Returns "CARTESIAN", "CYLINDRICAL" or "SPHERICAL" - */ -//======================================================================= - -std::string GRID::getCoordinatesSystem() const -{ - return _coordinate ? _coordinate->getCoordinatesSystem() : defaultStrings()[0]; -} - -//======================================================================= -/*! - * Returns an array with names of coordinates. \n - * Example : \n - * - x,y,z \n - * - r,teta,phi \n - * - ... - */ -//======================================================================= - -const std::string * GRID::getCoordinatesNames() const -{ - return _coordinate ? _coordinate->getCoordinatesNames() : defaultStrings(); -} - -//======================================================================= -/*! - * Returns an array with units of coordinates (cm, m, mm, ...) - * It could be empty. We suppose we are IS (meter). - */ -//======================================================================= - -const std::string * GRID::getCoordinatesUnits() const -{ - return _coordinate ? _coordinate->getCoordinatesUnits() : defaultStrings(); -} - -//======================================================================= -/*! - Returns a support which reference all elements on the boundary of mesh. - For a d-dimensional mesh, a boundary element is defined as a d-1 dimension - element that is referenced by only one element in the full descending connectivity. - - This method can also return the list of nodes that belong to the boundary elements. - - WARNING: This method can recalculate descending connectivity from partial to full form, - so that partial SUPPORT on d-1 dimension elements becomes invalid. - - \param Entity entity on which the boundary is desired. It has to be either \a MED_NODE or the - d-1 dimension entity type (MED_FACE in 3D, MED_EDGE in 2D). -*/ -//======================================================================= - -SUPPORT * GRID::getBoundaryElements(MED_EN::medEntityMesh Entity) const throw (MEDEXCEPTION) -{ - const char * LOC = "GMESH::getBoundaryElements() : " ; - if ( _spaceDimension < 2 ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not implemented in " << _spaceDimension <<"D space !")); - - if ( _gridType == MED_POLAR) - throw MEDEXCEPTION("GRID::getBoundaryElements() : not implemented on MED_POLAR grig"); - - - medEntityMesh entityToParse=Entity; - if(_spaceDimension == 3) - if (Entity != MED_FACE) - { - if(Entity==MED_NODE) - entityToParse=MED_FACE; - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined in 3D mesh for entity "<<Entity<<" !")); - } - if(_spaceDimension == 2) - if(Entity != MED_EDGE) - { - if(Entity==MED_NODE) - entityToParse=MED_EDGE; - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined in 2D mesh for entity "<<Entity<<" !")); - } - list<int> bnd_elems1, bnd_elems2; - int numberOf = getNumberOfElements(entityToParse,MED_ALL_ELEMENTS) ; - - if ( _coordinate->getNumberOfNodes() > 0 ) // BODY FITTED - { - throw MEDEXCEPTION("GRID::getBoundaryElements() : not implemented on BOBY FITTED grig"); - } - else if ( entityToParse == MED_FACE ) // 3D CARTESIAN - { - const int nb_x = getArrayLength( 1 ) - 1; - const int nb_y = getArrayLength( 2 ) - 1; - const int nb_z = getArrayLength( 3 ) - 1; - // normal to OX - for ( int z = 0; z < nb_z; ++z ) - for ( int y = 0; y < nb_y; ++y ) - { - bnd_elems1.push_back( getFaceNumber( 1, 0, y, z )); - bnd_elems2.push_back( getFaceNumber( 1, nb_x, y, z )); - } - bnd_elems1.splice( bnd_elems1.end(), bnd_elems2 ); // to have ids in increasing order - - // normal to OY - for ( int z = 0; z < nb_z; ++z ) - for ( int x = 0; x < nb_x; ++x ) - { - bnd_elems1.push_back( getFaceNumber( 2, x, 0, z )); - bnd_elems2.push_back( getFaceNumber( 2, x, nb_y, z )); - } - bnd_elems1.splice( bnd_elems1.end(), bnd_elems2 ); - - // normal to OZ - for ( int y = 0; y < nb_y; ++y ) - for ( int x = 0; x < nb_x; ++x ) - { - bnd_elems1.push_back( getFaceNumber( 3, x, y, 0 )); - bnd_elems2.push_back( getFaceNumber( 3, x, y, nb_z )); - } - bnd_elems1.splice( bnd_elems1.end(), bnd_elems2 ); - } - else - { - const int nb_x = getArrayLength( 1 ) - 1; - const int nb_y = getArrayLength( 2 ) - 1; - // edge || OX - for ( int x = 0; x < nb_x; ++x ) - { - bnd_elems1.push_back( getEdgeNumber( 1, x, 0 )); - bnd_elems2.push_back( getEdgeNumber( 1, x, nb_y )); - } - bnd_elems1.splice( bnd_elems1.end(), bnd_elems2 ); // to have ids in increasing order - // edge || OY - for ( int y = 0; y < nb_y; ++y ) - { - bnd_elems1.push_back( getEdgeNumber( 2, y, 0 )); - bnd_elems2.push_back( getEdgeNumber( 2, y, nb_x )); - } - bnd_elems1.splice( bnd_elems1.end(), bnd_elems2 ); - } - - if ( bnd_elems1.empty() && numberOf != 0 ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"No boundary elements found by reverse descending connectivity for entity "<<Entity<<" !")); - - if ( Entity == MED_NODE ) - return buildSupportOnNodeFromElementList(bnd_elems1,entityToParse); - else - return buildSupportOnElementsFromElementList(bnd_elems1,entityToParse); -} - -SUPPORT * GRID::getSkin(const SUPPORT * Support3D) throw (MEDEXCEPTION) -{ - throw MEDEXCEPTION("GRID::getSkin() : Not implemented yet"); -} -SUPPORT *GRID::buildSupportOnNodeFromElementList(const std::list<int>& listOfElt, - MED_EN::medEntityMesh entity) const - throw (MEDEXCEPTION) -{ - throw MEDEXCEPTION("GRID::buildSupportOnNodeFromElementList() : Not implemented yet"); -} -void GRID::fillSupportOnNodeFromElementList(const std::list<int>& listOfElt, - SUPPORT * supportToFill) const - throw (MEDEXCEPTION) -{ - throw MEDEXCEPTION("GRID::fillSupportOnNodeFromElementList() : Not implemented yet"); -} - -FIELD<double>* GRID::getVolume (const SUPPORT * Support, bool isAbs) const - throw (MEDEXCEPTION) -{ - throw MEDEXCEPTION("GRID::getVolume() : Not implemented yet"); -} - -FIELD<double>* GRID::getArea (const SUPPORT * Support) const - throw (MEDEXCEPTION) -{ - throw MEDEXCEPTION("GRID::getArea() : Not implemented yet"); -} - -FIELD<double>* GRID::getLength (const SUPPORT * Support) const - throw (MEDEXCEPTION) -{ - throw MEDEXCEPTION("GRID::getLength() : Not implemented yet"); -} - -FIELD<double>* GRID::getNormal (const SUPPORT * Support) const - throw (MEDEXCEPTION) -{ - throw MEDEXCEPTION("GRID::getNormal() : Not implemented yet"); -} - -FIELD<double>* GRID::getBarycenter (const SUPPORT * Support) const - throw (MEDEXCEPTION) -{ - throw MEDEXCEPTION("GRID::getBarycenter() : Not implemented yet"); -} - -vector< vector<double> > GRID::getBoundingBox() const -{ - throw MEDEXCEPTION("GRID::getBoundingBox() : Not implemented yet"); -} diff --git a/src/MEDMEM/MEDMEM_Grid.hxx b/src/MEDMEM/MEDMEM_Grid.hxx deleted file mode 100644 index c9fa2098e..000000000 --- a/src/MEDMEM/MEDMEM_Grid.hxx +++ /dev/null @@ -1,253 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : MEDMEM_Grid.hxx -// Created : Wed Dec 18 08:35:26 2002 -// Descr : class containing structured mesh data -// Author : Edward AGAPOV (eap) -// Project : SALOME Pro -// Module : MED -// -#ifndef MEDMEM_Grid_HeaderFile -#define MEDMEM_Grid_HeaderFile - -#include <MEDMEM.hxx> - -#include "MEDMEM_Mesh.hxx" - -// class containing structured mesh data - -namespace MEDMEM { -class MEDMEM_EXPORT GRID: public GMESH -{ - protected: - //-----------------------// - // Fields - //-----------------------// - - // 1. grid type: MED_CARTESIAN, MED_POLAR, MED_BODY_FITTED - MED_EN::med_grid_type _gridType; - - // 2. node coordinates for MED_BODY_FITTED and coordinate names, units etc. - COORDINATE* _coordinate; - - // 2.1. i component array: X for MED_CARTESIAN, R for MED_POLAR - int _iArrayLength; - double* _iArray; - // 2.2. j component array: Y for MED_CARTESIAN, Theta for MED_POLAR - int _jArrayLength; - double* _jArray; - // 2.3. k component array: Z for both MED_CARTESIAN and MED_POLAR - int _kArrayLength; - double* _kArray; - - // 3. is _gridType a true value or just a default one - bool _is_default_gridType; - - // Suppose a READ Driver to do the following except filling _[ijk]Array's - // 1) fill GMESH fields: - // * _name - // * _spaceDimension - // * _numberOfNodesFamilies, _numberOfCellsFamilies, ect - // * _familyNode, _familyCell, etc - // * _numberOfNodesGroups, _numberOfCellsGroups, etc - // * _groupNode, _groupCell, etc - // * _ - // 2) create _coordinate without setting _coordinate->_coordinate and set: - // * _coordinate->_coordinateSystem - // * _coordinate->_coordinateName - // * _coordinate->_coordinateUnit - protected: - virtual bool isEmpty() const; - - - public: - //-----------------------// - // Public Methods - //-----------------------// - - GRID(); - GRID(const MED_EN::med_grid_type type); - GRID(const GRID &m); - GRID( driverTypes driverType, const string & fileName,const string & meshName); - GRID(const std::vector<std::vector<double> >& xyz_array, - const std::vector<std::string>& coord_name, - const std::vector<std::string>& coord_unit, - const MED_EN::med_grid_type type=MED_EN::MED_CARTESIAN); - GRID & operator=(const GRID &m); - virtual ~GRID(); - virtual void init(); - virtual bool deepCompare(const GMESH& other) const; - virtual void printMySelf(std::ostream &os) const; - - virtual const MESH * convertInMESH() const; - - virtual int getMeshDimension() const; - virtual bool getIsAGrid() const; - virtual int getNumberOfNodes() const; - - virtual std::string getCoordinatesSystem() const; - virtual const std::string * getCoordinatesNames() const; - virtual const std::string * getCoordinatesUnits() const; - - virtual int getNumberOfTypes(MED_EN::medEntityMesh Entity) const; - virtual int getNumberOfElements(MED_EN::medEntityMesh Entity, - MED_EN::medGeometryElement Type) const; - virtual const MED_EN::medGeometryElement * getTypes(MED_EN::medEntityMesh Entity) const; - virtual MED_EN::medGeometryElement getElementType(MED_EN::medEntityMesh Entity, - int Number) const; - - virtual SUPPORT * getBoundaryElements(MED_EN::medEntityMesh Entity) const - throw (MEDEXCEPTION); - virtual SUPPORT * getSkin(const SUPPORT * Support3D) - throw (MEDEXCEPTION); - virtual SUPPORT *buildSupportOnNodeFromElementList(const std::list<int>& listOfElt, MED_EN::medEntityMesh entity) const throw (MEDEXCEPTION); - virtual void fillSupportOnNodeFromElementList(const std::list<int>& listOfElt, SUPPORT *supportToFill) const throw (MEDEXCEPTION); - - virtual FIELD<double>* getVolume (const SUPPORT * Support, bool isAbs = true) const - throw (MEDEXCEPTION); - // Support must be on 3D elements - virtual FIELD<double>* getArea (const SUPPORT * Support) const - throw (MEDEXCEPTION); - // Support must be on 2D elements - virtual FIELD<double>* getLength (const SUPPORT * Support) const - throw (MEDEXCEPTION); - // Support must be on 1D elements - virtual FIELD<double>* getNormal (const SUPPORT * Support) const - throw (MEDEXCEPTION); - // Support must be on 2D elements - virtual FIELD<double>* getBarycenter (const SUPPORT * Support) const - throw (MEDEXCEPTION); - - virtual vector< vector<double> > getBoundingBox() const; - - - // Specific GRID methods - //-----------------------// - - inline int getNodeNumber(const int i, const int j=0, const int k=0) const; - // return a NODE number by its position in the grid. - // WARNING: be carefull, there is no check that i,j,k are within a good range - // A good range is: 0 <= X < getArrayLength( X_Axis ) - - inline int getCellNumber(const int i, const int j=0, const int k=0) const ; - // return a CELL number by its position in the grid. - // WARNING: be carefull, there is no check that i,j,k are within a good range - // A good range is: 0 <= X < (getArrayLength( X_Axis )-1) - - int getEdgeNumber(const int Axis, const int i, const int j=0, const int k=0) const throw (MEDEXCEPTION) ; - // return an EDGE number by its position in the grid. - // Axis [1,2,3] means one of directions: along i, j or k. - // It selects an edge of ones having same (i,j,k): - // * an EDGE going along given Axis. - // Exception for Axis out of range or when there is no edges in the grid (1D) - // WARNING: be carefull, there is no check that i,j,k are within a good range - // A good range is: - // 0 <= X < (getArrayLength( X_Axis )-1) - // 0 <= X < getArrayLength( NOT_X_Axis ) - - int getFaceNumber(const int Axis, const int i, const int j=0, const int k=0) const throw (MEDEXCEPTION) ; - // return a FACE number by its position in the grid. - // Axis [1,2,3] means one of directions: along i, j or k. - // It selects a face of ones having same (i,j,k): - // * a FACE which is normal to given Axis - // Exception for Axis out of range or when there is no faces in the grid (1,2D) - // WARNING: be carefull, there is no check that i,j,k are within a good range - // A good range is: - // 0 <= X < (getArrayLength( NOT_X_Axis )-1) - // 0 <= X < getArrayLength( X_Axis ) - - - void getNodePosition(const int Number, int& i, int& j, int& k) const throw (MEDEXCEPTION) ; - void getCellPosition(const int Number, int& i, int& j, int& k) const throw (MEDEXCEPTION) ; - void getEdgePosition(const int Number, int& Axis, int& i, int& j, int& k) const throw (MEDEXCEPTION) ; - void getFacePosition(const int Number, int& Axis, int& i, int& j, int& k) const throw (MEDEXCEPTION) ; - // return position (i,j,k) of an entity #Number - // Axis: [1,2,3], see get*Number for details - // Exception for Number out of range - - - // Access to fields - //-----------------------// - - inline MED_EN::med_grid_type getGridType() const; - // return MED_CARTESIAN, MED_POLAR or MED_BODY_FITTED - - int getArrayLength( const int Axis ) const throw (MEDEXCEPTION); - // return array length. Axis = [1,2,3] meaning [i,j,k], - // exception if Axis out of [1-3] range - - const double getArrayValue (const int Axis, const int i) const throw (MEDEXCEPTION) ; - // return i-th array component. Axis = [1,2,3] meaning [i,j,k], - // exception if Axis out of [1 - 3] range - // exception if i is out of range [0 - (getArrayLength(Axis)-1)]; - - inline void setGridType(MED_EN::med_grid_type gridType); - - - friend class MED_MESH_RDONLY_DRIVER; - friend class MED_MESH_WRONLY_DRIVER; - friend class ENSIGHT_MESH_RDONLY_DRIVER; -}; - - - //----------------------------------// - // Inline Methods Implementation - //----------------------------------// - -inline MED_EN::med_grid_type GRID::getGridType() const -{ - return _gridType; -} -//======================================================================= -//function : getNodeNumber -//purpose : -//======================================================================= - -inline int GRID::getNodeNumber(const int i, const int j, const int k) const -{ - return 1 + i + _iArrayLength * j + _iArrayLength * _jArrayLength * k; -} - -//======================================================================= -//function : getCellNumber -//purpose : -//======================================================================= - -inline int GRID::getCellNumber(const int i, const int j, const int k) const -{ - return 1 + i + (_iArrayLength-1) * j + (_iArrayLength-1) * (_jArrayLength-1) * k; -} - -//======================================================================= -//function : setGridType -//purpose : set the _gridType field od the class GRID -//======================================================================= - -inline void GRID::setGridType(MED_EN::med_grid_type gridType) -{ - _gridType = gridType; -} - -} - -#endif diff --git a/src/MEDMEM/MEDMEM_Group.cxx b/src/MEDMEM/MEDMEM_Group.cxx deleted file mode 100644 index 94e1f431e..000000000 --- a/src/MEDMEM/MEDMEM_Group.cxx +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -/* - File Group.cxx -*/ -#include <list> - -#include "MEDMEM_Group.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Mesh.hxx" - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -GROUP::GROUP():SUPPORT(),_numberOfFamilies(0),_family() -{ - MESSAGE_MED("GROUP()"); -} - -GROUP::~GROUP() -{ - MESSAGE_MED("~GROUP()"); -} - -GROUP & GROUP::operator=(const GROUP &group) -{ - MESSAGE_MED("GROUP::operator="); - if ( &group == this ) return *this; - SUPPORT::operator=(group); - _numberOfFamilies = group._numberOfFamilies ; - _family = group._family ; - return *this; -} - -ostream & MEDMEM::operator<<(ostream &os, GROUP &myGroup) -{ - os << (SUPPORT&) myGroup; - - int numberoffamilies = myGroup.getNumberOfFamilies(); - os << " - Families ("<<numberoffamilies<<") :"<<endl; - for (int j=1;j<numberoffamilies+1;j++) - os << " * "<<myGroup.getFamily(j)->getName().c_str()<<endl ; - - return os; -} - -GROUP::GROUP(const string & name, const list<FAMILY*> & families) throw (MEDEXCEPTION) -{ - const char * LOC = "GROUP( const string & , const list<FAMILY*> & ) : " ; - - BEGIN_OF_MED(LOC); - - MESSAGE_MED(LOC<<name); - - int numberOfFamilies = families.size(); - _name = name ; - _description = "GROUP"; - // description : none ! - // first FAMILY to set all ! - FAMILY * myFamily = families.front() ; - _mesh = myFamily->getMesh() ; - if(_mesh) - _mesh->addReference(); - _entity = myFamily->getEntity() ; - bool isOnAllElts = myFamily->isOnAllElements() ; - - SCRUTE_MED(isOnAllElts); - SCRUTE_MED(numberOfFamilies); - - - if ((numberOfFamilies==1) && (isOnAllElts)) - { - _numberOfFamilies = numberOfFamilies; - _isOnAllElts = isOnAllElts ; - _family.resize(_numberOfFamilies) ; - _family[0] = myFamily; - update(); - return; - } - else if ((!(numberOfFamilies==1)) && (isOnAllElts)) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "building of a GROUP object from several FAMILY, and one of them is on all entities" )) ; - - _numberOfGeometricType = myFamily->getNumberOfTypes() ; - - _geometricType.set(_numberOfGeometricType); - _numberOfElements.set(_numberOfGeometricType) ; - - const medGeometryElement * geometricType = myFamily->getTypes() ; - - SCRUTE_MED(_numberOfGeometricType); - - for (int i=0 ; i<_numberOfGeometricType; i++) { - _geometricType[i]= geometricType[i] ; - _numberOfElements[i]=myFamily->getNumberOfElements(geometricType[i]); - MESSAGE_MED(LOC << " Type : " << _geometricType[i] << " number of element(s) " << _numberOfElements[i]); - } - _isOnAllElts = false ; - - - MEDSKYLINEARRAY * famNumber = myFamily->getnumber(); - - const int * famNumberValue = myFamily->getNumber(MED_ALL_ELEMENTS); - - const int * famNumberIndex = myFamily->getNumberIndex(); - - int famNumberCount = famNumber->getNumberOf(); - int famNumberLength = famNumber->getLength(); - - SCRUTE_MED(famNumber); - SCRUTE_MED(famNumberCount); - SCRUTE_MED(famNumberLength); - SCRUTE_MED(famNumberValue); - SCRUTE_MED(famNumberIndex); - - _number = new MEDSKYLINEARRAY(famNumberCount,famNumberLength, - famNumberIndex,famNumberValue) ; - - _numberOfFamilies = families.size(); - - _family.resize(_numberOfFamilies) ; - list<FAMILY*>::const_iterator li ; - - int it = 0 ; - for (li=families.begin();li!=families.end();li++) { - blending(*li); - _family[it] = (*li) ; - it++ ; - } - - END_OF_MED(LOC); -} - -GROUP::GROUP(const GROUP & m):SUPPORT(m) -{ - _numberOfFamilies = m._numberOfFamilies; - _family = m._family; //Copie profonde dans FAMILY Rmq from EF -} - diff --git a/src/MEDMEM/MEDMEM_Group.hxx b/src/MEDMEM/MEDMEM_Group.hxx deleted file mode 100644 index 39374110f..000000000 --- a/src/MEDMEM/MEDMEM_Group.hxx +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -/* - File Group.hxx -*/ - -#ifndef GROUP_HXX -#define GROUP_HXX - -#include <MEDMEM.hxx> - -#include <vector> -#include <list> -#include "MEDMEM_Family.hxx" - - -/*! - - This class describe a group of elements on an entity.\n - It inherits from SUPPORT.\n - It is a blending of some FAMILY class.\n\n - -*/ - -namespace MEDMEM { - class FAMILY; - class GROUP; - MEDMEM_EXPORT std::ostream & operator<<(std::ostream &os, GROUP &my) ; - -class MEDMEM_EXPORT GROUP : virtual public SUPPORT -{ -protected : - /*! - \if developper - Number of families in the group. - \endif - */ - int _numberOfFamilies ; - /*! - \if developper - Vector of families in the group. - Note that Families are numbered from 1 to N. - \endif - */ - std::vector<FAMILY*> _family ; - protected: - /*! Destructor. */ - virtual ~GROUP(); - -public: - /*! Constructor. */ - GROUP(); - /*! Constructor. */ - GROUP(const std::string & name, const std::list<FAMILY*> & family) throw (MEDEXCEPTION) ; - /*! Copy Constructor. */ - GROUP(const GROUP & m); - - /*! Copy operator. */ - // PN ATTention il n y a pas de copie du vecteur Family ???? - GROUP & operator=(const GROUP &group); - - /*! Operator << */ - friend std::ostream & operator<<(std::ostream &os, GROUP &my) ; - - inline void setNumberOfFamilies(int numberOfFamilies); - inline void setFamilies(std::vector<FAMILY*> Family); - - inline int getNumberOfFamilies() const ; - inline std::vector<FAMILY*> getFamilies() const ; - inline FAMILY * getFamily(int i) const ; - -}; - -// inline method : - -/*! set the attribut _numberOfFamilies to numberOfFamilies */ -//---------------------------------------------------------- -inline void GROUP::setNumberOfFamilies(int numberOfFamilies) -//---------------------------------------------------------- -{ - _numberOfFamilies = numberOfFamilies; -} - - -/*! set the attribut _family to Family */ -//---------------------------------------------------- -inline void GROUP::setFamilies(std::vector<FAMILY*> Family) -//---------------------------------------------------- -{ - _family = Family; -} - -/*! returns number of families in the group */ -//-------------------------------------------- -inline int GROUP::getNumberOfFamilies() const -//------------------------------------------- -{ - return _numberOfFamilies; -} - -/*! returns the vector of families in the group */ -//------------------------------------------------ -inline std::vector<FAMILY*> GROUP::getFamilies() const -//------------------------------------------------ -{ - return _family; -} - -/*! returns a reference on family I of the group */ -//-------------------------------------------------- -FAMILY * GROUP::getFamily(int i) const -//-------------------------------------------------- -{ - return _family[i-1]; -} -}//End namespace MEDMEM - -#endif /* GROUP_HXX */ diff --git a/src/MEDMEM/MEDMEM_IndexCheckingPolicy.hxx b/src/MEDMEM/MEDMEM_IndexCheckingPolicy.hxx deleted file mode 100644 index 7054ff365..000000000 --- a/src/MEDMEM/MEDMEM_IndexCheckingPolicy.hxx +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef MEDMEM_INDEX_CHECKING_POLICY_HXX -#define MEDMEM_INDEX_CHECKING_POLICY_HXX - -#include <MEDMEM.hxx> - -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_STRING.hxx" - -namespace MEDMEM { - -class MEDMEM_EXPORT IndexCheckPolicy { -public : - inline void checkMoreThanZero(const std::string & classname, int index) const { - if (index <= 0) - throw MEDEXCEPTION(LOCALIZED(STRING("In ") << classname << ", index : " << index << " is less or equal to zero")); - } - inline void checkLessOrEqualThan(const std::string & classname, int max, int index) const { - if (index > max) - throw MEDEXCEPTION(LOCALIZED(STRING("In ") << classname << ", index : " << index << " is more than " << max )); - } - - inline void checkInInclusiveRange(const std::string & classname, int min, int max, int index) const { - if (index < min || index > max ) - throw MEDEXCEPTION(LOCALIZED(STRING("In ") << classname << ", index : " << index - << " not in rang [" << min << "," << max <<"]")); - } - - inline void checkEquality(const std::string & classname, int a, int b) const { - if ( a == b ) - throw MEDEXCEPTION(LOCALIZED(STRING("In ") << classname << ", Value shouldn't be : " << a )); - } - -}; - -class MEDMEM_EXPORT NoIndexCheckPolicy { -public : - inline void checkMoreThanZero(const string &classname, int index) const {} - inline void checkLessOrEqualThan(const std::string & classname, int max, int index) const {} - inline void checkInInclusiveRange(const std::string & classname, int min, int max, int index) const {} - inline void checkEquality(const std::string & classname, int a, int b) const {} -}; - -}// END NAMESPACE -#endif diff --git a/src/MEDMEM/MEDMEM_Init.cxx b/src/MEDMEM/MEDMEM_Init.cxx deleted file mode 100644 index 7fa334c67..000000000 --- a/src/MEDMEM/MEDMEM_Init.cxx +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include <stdlib.h> -#include <string.h> -#include <cassert> - -#include "MEDMEM_Utilities.hxx" -# ifdef MED_WITH_KERNEL -//#include "LocalTraceCollector.hxx" -# endif /* ifdef MED_WITH_KERNEL*/ - -namespace MEDMEM -{ - class INIT - { - public: - INIT(); - }; -} - -MEDMEM::INIT init; - -MEDMEM::INIT::INIT() -{ -#ifdef MED_WITH_KERNEL -// LocalTraceCollector::instance(); -#endif /* ifdef MED_WITH_KERNEL*/ - char* traceKind = getenv("SALOME_trace"); - - if (traceKind == NULL) - { -#ifndef WIN32 - setenv("SALOME_trace","local",1); -#else - _putenv("SALOME_trace=%TEMP%\\local"); -#endif - traceKind = getenv("SALOME_trace"); - assert(traceKind); - } - - MESSAGE_MED("Med Memory Initialization with $SALOME_trace = " << traceKind); -} diff --git a/src/MEDMEM/MEDMEM_InterlacingPolicy.hxx b/src/MEDMEM/MEDMEM_InterlacingPolicy.hxx deleted file mode 100644 index 609ab288e..000000000 --- a/src/MEDMEM/MEDMEM_InterlacingPolicy.hxx +++ /dev/null @@ -1,606 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef MEDMEM_INTERLACING_HXX -#define MEDMEM_INTERLACING_HXX - -#include <MEDMEM.hxx> - -#include <iostream> -#include "MEDMEM_Utilities.hxx" - -#include "MEDMEM_PointerOf.hxx" -#include "MEDMEM_define.hxx" - -namespace MEDMEM { - -class MEDMEM_EXPORT InterlacingPolicy { -protected: - ~InterlacingPolicy() {} //pour éviter qu'un utilisateur cast la class array en politique -public : - InterlacingPolicy(void) : _dim(0), _nbelem(0), - _arraySize(0), - _interlacing(MED_EN::MED_UNDEFINED_INTERLACE), - _gaussPresence(false) {} - - InterlacingPolicy(int nbelem, int dim, int arraySize=0, int interlacing=MED_EN::MED_UNDEFINED_INTERLACE) : - _dim(dim), - _nbelem(nbelem), - _arraySize(arraySize), - _interlacing(interlacing), - _gaussPresence(false) {} - - // Constructeur par recopie - InterlacingPolicy(const InterlacingPolicy & intpol, - bool shallowcopy = true) :_dim(intpol._dim), - _nbelem(intpol._nbelem), - _arraySize(intpol._arraySize), - _interlacing(intpol._interlacing), - _gaussPresence(intpol._gaussPresence) {} - - InterlacingPolicy & operator=(const InterlacingPolicy & intpol) { - if ( this == &intpol ) return *this; - const char* LOC = "InterlacingPolicy operator ="; - BEGIN_OF_MED(LOC); - - _dim = intpol._dim; - _nbelem = intpol._nbelem; //ne prend pas en compte les points de Gauss - _arraySize = intpol._arraySize; - _interlacing = intpol._interlacing; - _gaussPresence = intpol._gaussPresence; - - return *this; - } - - inline int getDim() const { return _dim; } - inline int getNbElem() const { return _nbelem; } - inline int getArraySize() const { return _arraySize; } - inline MED_EN::medModeSwitch getInterlacingType() const {return _interlacing;} - inline bool getGaussPresence() const { return _gaussPresence;} - virtual int getNbGauss(int i) const = 0; - - int _dim; - int _nbelem; - int _arraySize; - MED_EN::medModeSwitch _interlacing; - bool _gaussPresence; -}; - - -class MEDMEM_EXPORT FullInterlaceNoGaussPolicy : public InterlacingPolicy { - -protected: - ~FullInterlaceNoGaussPolicy() {} //pour éviter qu'un utilisateur cast la class array en politique - -public : - FullInterlaceNoGaussPolicy() : InterlacingPolicy() {} - FullInterlaceNoGaussPolicy(int nbelem, int dim) : - InterlacingPolicy(nbelem, dim, dim*nbelem,MED_EN::MED_FULL_INTERLACE) {} - - FullInterlaceNoGaussPolicy(const FullInterlaceNoGaussPolicy & policy, - bool shallowcopie=true) - : InterlacingPolicy(policy) {}; - - inline int getIndex(int i,int j) const { - return (i-1)*_dim + j-1; - } - - inline int getIndex(int i,int j,int k) const { - return (i-1)*_dim + j-1; - } - - inline int getNbGauss(int i) const { return 1; } - -}; - -class MEDMEM_EXPORT NoInterlaceNoGaussPolicy : public InterlacingPolicy { - -protected: - ~NoInterlaceNoGaussPolicy() {} //pour éviter qu'un utilisateur cast la class array en politique - -public : - - NoInterlaceNoGaussPolicy():InterlacingPolicy() {} - NoInterlaceNoGaussPolicy(int nbelem, int dim) : - InterlacingPolicy(nbelem, dim, dim*nbelem,MED_EN::MED_NO_INTERLACE) {} - - NoInterlaceNoGaussPolicy(const NoInterlaceNoGaussPolicy & policy, - bool shallowcopie=true) - : InterlacingPolicy(policy) {} - - inline int getIndex(int i,int j) const { - return (j-1)*_nbelem + i-1; - } - - inline int getIndex(int i,int j,int k) const { - return (j-1)*_nbelem + i-1; - } - - inline int getNbGauss(int i) const { return 1; } - -}; - -class MEDMEM_EXPORT NoInterlaceByTypeNoGaussPolicy : public InterlacingPolicy { - -protected: - ~NoInterlaceByTypeNoGaussPolicy() {} //pour éviter qu'un utilisateur cast la class array en politique - - PointerOf<int> _T; //!< type of element - PointerOf<int> _G; //!< where type begin - int _nbtypegeo; - PointerOf<int> _nbelegeoc; - -public : - - NoInterlaceByTypeNoGaussPolicy():InterlacingPolicy(),_nbtypegeo(-1) - { - } - - NoInterlaceByTypeNoGaussPolicy(int nbelem, int dim):InterlacingPolicy() - { - // constructor is incoorect for this type of interlace - throw MEDEXCEPTION(LOCALIZED("Wrong constructor of NoInterlaceByTypeNoGaussPolicy ")); - } - - NoInterlaceByTypeNoGaussPolicy(int nbelem, int dim, int nbtypegeo, - const int * const nbelgeoc) : - InterlacingPolicy(nbelem, dim, dim*nbelem,MED_EN::MED_NO_INTERLACE_BY_TYPE), - _nbtypegeo(nbtypegeo) - { - _nbelegeoc.set(_nbtypegeo+1,nbelgeoc); - _G.set(nbtypegeo+1); - _T.set(nbelem+1); - int elemno = 1; - int cumul = 0; - - for (int ntyp=1; ntyp <= nbtypegeo; ntyp++ ) { - int nbelcurtype = nbelgeoc[ntyp]-nbelgeoc[ntyp-1]; - for (int i=0; i < nbelcurtype; i++ ) { - _T[ elemno ] = ntyp; - elemno++; - }; - _G[ ntyp ] = cumul; - cumul += nbelcurtype*_dim; -#ifdef ARRAY_DEBUG - std::cout << "Valeur de cumul " << cumul << std::endl; -#endif - }; - - _arraySize = cumul; - -#ifdef ARRAY_DEBUG - for (int i =0; i< nbelem+1; i++ ) - std::cout << "Valeur de _T["<<i<<"] = "<<_T[i] << std::endl; -#endif - } - - NoInterlaceByTypeNoGaussPolicy(const NoInterlaceByTypeNoGaussPolicy & policy, - bool shallowcopie=true) - : InterlacingPolicy(policy),_nbtypegeo(policy._nbtypegeo) - { - //Seuls les tableaux de grande taille sont recopiés superficiellement - if(shallowcopie) - { - this->_G.set(policy._G); - this->_T.set(policy._T); - } - else - { - this->_G.set(_nbtypegeo+1,policy._G); - this->_T.set(_nbelem+1,policy._T); - } - - // Tableaux toujours recopiés par recopie profonde - this->_nbelegeoc.set(_nbtypegeo+1,policy._nbelegeoc); - } - - NoInterlaceByTypeNoGaussPolicy & operator=(const NoInterlaceByTypeNoGaussPolicy & policy) { - if ( this == &policy) return *this; - - const char* LOC = "NoInterlaceNoGaussPolicy operator ="; - BEGIN_OF_MED(LOC); - InterlacingPolicy::operator=(policy); - this->_G.set(policy._G); - this->_T.set(policy._T); - - // Tableaux toujours recopiés par recopie profonde - this->_nbtypegeo=policy._nbtypegeo; - this->_nbelegeoc.set(_nbtypegeo+1,policy._nbelegeoc); - - return *this; - } - inline int getIndex(int t) const { - return _G[t]; - } - - inline int getIndex(int i,int j) const { - int t = _T[i]; - return getIndexByType( i-(_nbelegeoc[t-1]-_nbelegeoc[0]), j, t ); - } - - inline int getIndex(int i,int j,int k) const { - return getIndex(i,j); - } - - inline int getIndexByType(int i,int j,int t) const { - return _G[t] + i-1 + (j-1)*(_nbelegeoc[t]-_nbelegeoc[t-1]); - } - - inline int getIndexByType(int i,int j,int k,int t) const { - return getIndexByType( i, j, t ); - } - - inline int getLengthOfType(int t) const { - return (_nbelegeoc[t]-_nbelegeoc[t-1]) * _dim; - } - - inline int getNbGauss(int i) const { return 1; } - - inline int getNbGeoType() const {return _nbtypegeo;} - - inline const int * const getNbElemGeoC() const {return _nbelegeoc;} - -}; - -class MEDMEM_EXPORT FullInterlaceGaussPolicy : public InterlacingPolicy { -protected: - ~FullInterlaceGaussPolicy() {} //pour éviter qu'un utilisateur cast la class array en politique -public : - - PointerOf<int> _G; - PointerOf<int> _S; - int _nbtypegeo; - PointerOf<int> _nbelegeoc; - PointerOf<int> _nbgaussgeo; - - FullInterlaceGaussPolicy():InterlacingPolicy(),_nbtypegeo(-1) { - InterlacingPolicy::_gaussPresence=true; - } - FullInterlaceGaussPolicy(int nbelem, int dim, int nbtypegeo, - const int * const nbelgeoc, const int * const nbgaussgeo) - : InterlacingPolicy(nbelem, dim, -1, MED_EN::MED_FULL_INTERLACE),_nbtypegeo(nbtypegeo) { - - InterlacingPolicy::_gaussPresence=true; - - _nbelegeoc.set(_nbtypegeo+1,nbelgeoc); - _nbgaussgeo.set(_nbtypegeo+1,nbgaussgeo); - _G.set(nbelem+1); - // _G[0] = 1; - _S.set(nbelem+1); - _S[0] = -1; - int cumul = 0; - int elemno = 0; - - // Construction of _G - for (int ntyp=1; ntyp <= nbtypegeo; ntyp++ ) { - for (int i=0; i < (nbelgeoc[ntyp]-nbelgeoc[ntyp-1]) ; i++ ) { - _G[ elemno ] = cumul + i*nbgaussgeo[ntyp]*dim + 1; - elemno++; - _S[ elemno ] = nbgaussgeo[ntyp]; - }; - cumul += (nbelgeoc[ntyp]-nbelgeoc[ntyp-1]) * nbgaussgeo[ntyp] * dim; -#ifdef ARRAY_DEBUG - std::cout << "Valeur de cumul " << cumul << std::endl; -#endif - }; - - _G[ elemno ] = cumul+1; - _arraySize = _G[ elemno ] -1 ; - -#ifdef ARRAY_DEBUG - for (int i =0; i< nbelem+1; i++ ) - std::cout << "Valeur de _G["<<i<<"] = "<<_G[i] << std::endl; -#endif - } - - FullInterlaceGaussPolicy(const FullInterlaceGaussPolicy & policy, - bool shallowcopie=true) - : InterlacingPolicy(policy),_nbtypegeo(policy._nbtypegeo) { - - //Seuls les tableaux de grande taille sont recopiés superficiellement - if(shallowcopie) { - this->_G.set(policy._G); - this->_S.set(policy._S); - } else { - this->_G.set(_nbelem+1,policy._G); - this->_S.set(_nbelem+1,policy._S); - } - // Tableaux toujours recopiés par recopie profonde - this->_nbelegeoc.set(_nbtypegeo+1,policy._nbelegeoc); - this->_nbgaussgeo.set(_nbtypegeo+1,policy._nbgaussgeo); - } - - FullInterlaceGaussPolicy & operator=(const FullInterlaceGaussPolicy & policy) { - const char* LOC = "FullInterlaceGaussPolicy operator ="; - BEGIN_OF_MED(LOC); - - if ( this == &policy) return *this; - - //Seuls les tableaux de grande taille sont recopiés superficiellement - InterlacingPolicy::operator=(policy); - this->_G.set(policy._G); - this->_S.set(policy._S); - - // Tableaux toujours recopiés par recopie profonde - this->_nbtypegeo=policy._nbtypegeo; - this->_nbelegeoc.set(_nbtypegeo+1,policy._nbelegeoc); - this->_nbgaussgeo.set(_nbtypegeo+1,policy._nbgaussgeo); - - return *this; - } - - inline int getIndex(int i,int j ) const { - return _G[i-1]-1 + (j-1); - } - - inline int getIndex(int i,int j, int k ) const { - //std::cout << "Index : " << _G[i-1]-1 + _dim *(k-1) + (j-1) << std::endl; - return _G[i-1]-1 + (k-1)*_dim + (j-1); - } - - inline int getNbGauss(int i) const { return _S[i]; } - - inline int getNbGeoType() const {return _nbtypegeo;} - - inline const int * const getNbElemGeoC() const {return _nbelegeoc;} - - inline const int * const getNbGaussGeo() const {return _nbgaussgeo;} - - -}; - -class MEDMEM_EXPORT NoInterlaceGaussPolicy : public InterlacingPolicy { - -protected: - ~NoInterlaceGaussPolicy() {} //pour éviter qu'un utilisateur cast la class array en politique - -public : - - PointerOf<int> _G; - PointerOf<int> _S; - int _nbtypegeo; - PointerOf<int> _nbelegeoc; - PointerOf<int> _nbgaussgeo; - // _cumul is used in getIndex() to access directly to the first value - // of a given dimension. - int _cumul; - - NoInterlaceGaussPolicy():InterlacingPolicy(),_nbtypegeo(-1),_cumul(0) { - InterlacingPolicy::_gaussPresence=true; - } - - NoInterlaceGaussPolicy(int nbelem, int dim, int nbtypegeo, - const int * const nbelgeoc, const int * const nbgaussgeo) - : InterlacingPolicy(nbelem, dim, -1, MED_EN::MED_NO_INTERLACE),_nbtypegeo(nbtypegeo) { - - InterlacingPolicy::_gaussPresence=true; - - _nbelegeoc.set(_nbtypegeo+1,nbelgeoc); - _nbgaussgeo.set(_nbtypegeo+1,nbgaussgeo); - _G.set(nbelem+1); - //_G[0] = 1; - _S.set(nbelem+1); - _S[0] = -1; - int elemno = 0; - - _cumul = 0; - for (int ntyp=1; ntyp <= nbtypegeo; ntyp++ ) { - for (int i=0; i < (nbelgeoc[ntyp]-nbelgeoc[ntyp-1]) ; i++ ) { - _G[ elemno ] = _cumul + i*nbgaussgeo[ntyp] + 1; - elemno++; - _S[ elemno ] = nbgaussgeo[ntyp]; - }; - _cumul += (nbelgeoc[ntyp]-nbelgeoc[ntyp-1]) * nbgaussgeo[ntyp]; -#ifdef ARRAY_DEBUG - std::cout << "Valeur de _cumul " << _cumul << std::endl; -#endif - }; - - _G[ elemno ] = _cumul+1; - _arraySize = ( _G[ elemno ] -1 ) * dim ; - -#ifdef ARRAY_DEBUG - for (int i =0; i< nbelem+1; i++ ) - std::cout << "Valeur de _G["<<i<<"] = "<<_G[i] << std::endl; -#endif - } - - - NoInterlaceGaussPolicy(const NoInterlaceGaussPolicy & policy, - bool shallowcopie=true) - : InterlacingPolicy(policy),_nbtypegeo(policy._nbtypegeo),_cumul(policy._cumul) - { - //Seuls les tableaux de grande taille sont recopiés superficiellement - if(shallowcopie) { - this->_G.set(policy._G); - this->_S.set(policy._S); - } else { - this->_G.set(_nbelem+1,policy._G); - this->_S.set(_nbelem+1,policy._S); - } - // Tableaux toujours recopiés par recopie profonde - this->_nbelegeoc.set(_nbtypegeo+1,policy._nbelegeoc); - this->_nbgaussgeo.set(_nbtypegeo+1,policy._nbgaussgeo); - } - - NoInterlaceGaussPolicy & operator=(const NoInterlaceGaussPolicy & policy) { - if ( this == &policy) return *this; - - const char* LOC = "NoInterlaceGaussPolicy operator ="; - BEGIN_OF_MED(LOC); - InterlacingPolicy::operator=(policy); - this->_G.set(policy._G); - this->_S.set(policy._S); - - this->_cumul = policy._cumul; - - // Tableaux toujours recopiés par recopie profonde - this->_nbtypegeo=policy._nbtypegeo; - this->_nbelegeoc.set(_nbtypegeo+1,policy._nbelegeoc); - this->_nbgaussgeo.set(_nbtypegeo+1,policy._nbgaussgeo); - - return *this; - } - - inline int getIndex(int i,int j ) const { - return _G[i-1]-1 + (j-1)*_cumul ; - } - - inline int getIndex(int i,int j, int k ) const { - return _G[i-1]-1 + (j-1)*_cumul + (k-1) ; - } - - inline int getNbGauss(int i) const { return _S[i]; } - - inline int getNbGeoType() const {return _nbtypegeo;} - - inline const int * const getNbElemGeoC() const {return _nbelegeoc;} - - inline const int * const getNbGaussGeo() const {return _nbgaussgeo;} - -}; - -class MEDMEM_EXPORT NoInterlaceByTypeGaussPolicy : public InterlacingPolicy { - -protected: - ~NoInterlaceByTypeGaussPolicy() {} //pour éviter qu'un utilisateur cast la class array en politique - - PointerOf<int> _T; //!< type of element - PointerOf<int> _G; //!< where type begin - int _nbtypegeo; - PointerOf<int> _nbelegeoc; - PointerOf<int> _nbgaussgeo; - -public : - - NoInterlaceByTypeGaussPolicy():InterlacingPolicy(),_nbtypegeo(-1) { - InterlacingPolicy::_gaussPresence=true; - } - - NoInterlaceByTypeGaussPolicy(int nbelem, int dim, int nbtypegeo, - const int * const nbelgeoc, const int * const nbgaussgeo) - : InterlacingPolicy(nbelem, dim, -1, MED_EN::MED_NO_INTERLACE_BY_TYPE),_nbtypegeo(nbtypegeo) { - - InterlacingPolicy::_gaussPresence=true; - - _nbelegeoc.set(_nbtypegeo+1,nbelgeoc); - _nbgaussgeo.set(_nbtypegeo+1,nbgaussgeo); - _G.set(_nbtypegeo+1); - _T.set(nbelem+1); - int elemno = 1; - int cumul = 0; - - for (int ntyp=1; ntyp <= nbtypegeo; ntyp++ ) { - int nbelcurtype = nbelgeoc[ntyp]-nbelgeoc[ntyp-1]; - for (int i=0; i < nbelcurtype; i++ ) { - _T[ elemno ] = ntyp; - elemno++; - }; - _G[ ntyp ] = cumul; - cumul += nbelcurtype * _dim * nbgaussgeo[ntyp]; -#ifdef ARRAY_DEBUG - std::cout << "Valeur de cumul " << cumul << std::endl; -#endif - }; - - _arraySize = cumul; - -#ifdef ARRAY_DEBUG - for (int i =0; i< nbelem+1; i++ ) - std::cout << "Valeur de _T["<<i<<"] = "<<_T[i] << std::endl; -#endif - } - - - NoInterlaceByTypeGaussPolicy(const NoInterlaceByTypeGaussPolicy & policy, - bool shallowcopie=true) - : InterlacingPolicy(policy),_nbtypegeo(policy._nbtypegeo) - { - //Seuls les tableaux de grande taille sont recopiés superficiellement - if(shallowcopie) { - this->_G.set(policy._G); - this->_T.set(policy._T); - } else { - this->_G.set(_nbtypegeo+1,policy._G); - this->_T.set(_nbelem+1,policy._T); - } - // Tableaux toujours recopiés par recopie profonde - this->_nbelegeoc.set(_nbtypegeo+1,policy._nbelegeoc); - this->_nbgaussgeo.set(_nbtypegeo+1,policy._nbgaussgeo); - } - - NoInterlaceByTypeGaussPolicy & operator=(const NoInterlaceByTypeGaussPolicy & policy) { - if ( this == &policy) return *this; - - const char* LOC = "NoInterlaceGaussPolicy operator ="; - BEGIN_OF_MED(LOC); - InterlacingPolicy::operator=(policy); - this->_G.set(policy._G); - this->_T.set(policy._T); - - // Tableaux toujours recopiés par recopie profonde - this->_nbtypegeo=policy._nbtypegeo; - this->_nbelegeoc.set(_nbtypegeo+1,policy._nbelegeoc); - this->_nbgaussgeo.set(_nbtypegeo+1,policy._nbgaussgeo); - - return *this; - } - - inline int getIndex(int t) const { - return _G[t]; - } - inline int getIndex(int i,int j ) const { - int t = _T[i]; - return getIndexByType( i-(_nbelegeoc[t-1]-_nbelegeoc[0]), j, t ); - } - - inline int getIndex(int i,int j, int k ) const { - return getIndex( i, j ) + (k-1); - } - - inline int getIndexByType(int i,int j,int t) const { - return _G[t] + (i-1 + (j-1)*(_nbelegeoc[t]-_nbelegeoc[t-1])) * _nbgaussgeo[t]; - } - - inline int getIndexByType(int i,int j,int k,int t) const { - return getIndexByType( i,j,t ) + (k-1); - } - - inline int getNbGauss(int i) const { return _nbgaussgeo[ _T[i] ]; } - - inline int getNbGaussByType(int t) const { return _nbgaussgeo[ t ]; } - - inline int getNbGeoType() const {return _nbtypegeo;} - - inline const int * const getNbElemGeoC() const {return _nbelegeoc;} - - inline const int * const getNbGaussGeo() const {return _nbgaussgeo;} - - inline int getLengthOfType(int t) const { - return (_nbelegeoc[t]-_nbelegeoc[t-1]) * _dim * _nbgaussgeo[t]; - } - -}; - -} //END NAMESPACE - -#endif diff --git a/src/MEDMEM/MEDMEM_InterlacingTraits.hxx b/src/MEDMEM/MEDMEM_InterlacingTraits.hxx deleted file mode 100644 index da51bb778..000000000 --- a/src/MEDMEM/MEDMEM_InterlacingTraits.hxx +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef MEDMEM_INTERLACING_TRAITS_HXX -#define MEDMEM_INTERLACING_TRAITS_HXX - -#include "MEDMEM_Tags.hxx" - -namespace MEDMEM { - -struct __ERROR_INTERLACING_GAUSS_TRAITS_POLICY_INSTANCIATED_WITH_INCORRECT_TYPE {}; - -template < class INTERLACE_TAG, class GAUSS_TAG> -struct MEDMEM_InterlacingTraits -{ - typedef __ERROR_INTERLACING_GAUSS_TRAITS_POLICY_INSTANCIATED_WITH_INCORRECT_TYPE Type; -}; - -template <> -struct MEDMEM_InterlacingTraits< FullInterlace, Gauss > -{ - typedef FullInterlaceGaussPolicy Type; -}; - -template <> -struct MEDMEM_InterlacingTraits< FullInterlace, NoGauss > -{ - typedef FullInterlaceNoGaussPolicy Type; -}; - -template <> -struct MEDMEM_InterlacingTraits< NoInterlace, Gauss > -{ - typedef NoInterlaceGaussPolicy Type; -}; - -template <> -struct MEDMEM_InterlacingTraits< NoInterlace, NoGauss > -{ - typedef NoInterlaceNoGaussPolicy Type; -}; - -template <> -struct MEDMEM_InterlacingTraits< NoInterlaceByType, Gauss > -{ - typedef NoInterlaceByTypeGaussPolicy Type; -}; - -template <> -struct MEDMEM_InterlacingTraits< NoInterlaceByType, NoGauss > -{ - typedef NoInterlaceByTypeNoGaussPolicy Type; -}; - -} // END NAMESPACE - -#endif diff --git a/src/MEDMEM/MEDMEM_MEDMEMchampLire.cxx b/src/MEDMEM/MEDMEM_MEDMEMchampLire.cxx deleted file mode 100644 index 5397c5e18..000000000 --- a/src/MEDMEM/MEDMEM_MEDMEMchampLire.cxx +++ /dev/null @@ -1,285 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_MEDMEMchampLire.hxx" -/* - * En attendant une correction de la gestion du mode d'accès au fichier dans MEDfichier - * on intègre la correction ici. - */ - -namespace med_2_3 { - extern "C" { - -# define ICI { \ - fflush(stdout); \ - fprintf(stderr, "%s [%d] : " , __FILE__ , __LINE__ ) ; \ - fflush(stderr) ; \ - } - -# define ISCRUTE_MED(entier) { \ - ICI ; \ - fprintf(stderr,"%s = %d\n",#entier,entier) ; \ - fflush(stderr) ; \ - } - -# define SSCRUTE_MED(chaine) { \ - ICI ; \ - fprintf(stderr,"%s = \"%s\"\n",#chaine,chaine) ; \ - fflush(stderr) ; \ - } -# define MESSAGE_MED(chaine) { \ - ICI ; \ - fprintf(stderr,"%s\n",chaine) ; \ - fflush(stderr) ; \ - } - - extern void _MEDmodeErreurVerrouiller(void); - -#include <med.h> -#include <med_outils.h> - -#include <string.h> -#include <stdlib.h> - - /* - * - Nom de la fonction : MEDchampLire - * - Description : Lecture d'un Champ Résultat - * - Parametres : - * - fid (IN) : ID du fichier HDF courant - * - maa (IN) : le nom du maillage sur lequel s'applique le champ - * - cha (IN) : le nom du champ - * - val (OUT) : valeurs du champ à lire - * - interlace(IN) : entrelacement voulu en mémoire {MED_FULL_INTERLACE,MED_NO_INTERLACE} - * - numco (IN) : n° de la composante à lire (MED_ALL si toutes) - * - profil (OUT) : nom du profil utilisé (MED_NOPFL si inutilisé) - * - pflmod (IN) : Indique comment lire les informations en mémoire { MED_COMPACT, MED_GLOBALE }. - * - type_ent (IN) : entité concerné par le champ {MED_NOEUD,MED_ARETE,MED_FACE,MED_MAILLE} - * - type_geo (IN) : type géométrique de l'entité concerné {MED_POINT,MED_SEG2 ......} - * - numdt (IN) : n° du pas de temps (MED_NOPDT si aucun) - * - numo (IN) : n° d'ordre utilisé MED_NONOR si inutile - * - Resultat : 0 en cas de succes, -1 sinon - */ - - /* REM : La taille de val allouée par l'utilisateur doit prendre en compte le nbre de points de gauss et le nbre de composantes*/ - - med_err - MEDMEMchampLire(med_idt fid,char *maa, char *cha, unsigned char *val,med_mode_switch interlace,med_int numco, - char * locname, char *profil, med_mode_profil pflmod, - med_entite_maillage type_ent, med_geometrie_element type_geo, - med_int numdt, med_int numo) - - { - med_err ret=-1; - med_idt gid=0, datagroup1=0, datagroup2=0,datagroup3=0; - med_int ncomp=0, chtype=0, ngauss=0, i=0, pfluse=0; - char nomdatagroup1[2*MED_TAILLE_NOM_ENTITE+2]="",nomdatagroup2[2*MED_MAX_PARA+1]=""; - char tmp1[MED_TAILLE_NOM_ENTITE+1]="", pfltmp[MED_TAILLE_NOM+1]=""; - char chemin[MED_TAILLE_CHA+MED_TAILLE_NOM+1]=""; - med_size psize=0; - med_int *pfltabtmp=0; - med_ssize *pfltab=0; - - /* - * On inhibe le gestionnaire d'erreur HDF 5 - */ - _MEDmodeErreurVerrouiller(); - - /* - * Si le Data Group cha n'existe pas => erreur - */ - strcpy(chemin,MED_CHA); - strcat(chemin,cha); - if ((gid = _MEDdatagroupOuvrir(fid,chemin)) < 0) - goto ERROR; - - /* Lecture du nbre de composantes du champ */ - - if (_MEDattrEntierLire(gid,MED_NOM_NCO,&ncomp) < 0) - goto ERROR; - - /* - * Si le Data Group de niveau 1 <type_ent>[.<type_geo>] n'existe pas => erreur - */ - if (_MEDnomEntite(nomdatagroup1,type_ent) < 0) - goto ERROR; - if ((type_ent != MED_NOEUD)) - { - if (_MEDnomGeometrie(tmp1,type_geo) < 0) - goto ERROR; - strcat(nomdatagroup1,"."); - strcat(nomdatagroup1,tmp1); - } - datagroup1 = 0; - if ( (datagroup1 = _MEDdatagroupOuvrir(gid,nomdatagroup1)) < 0 ) - goto ERROR; - - /* - * Si le Data Group de niveau 2 <numdt>.<numoo> n'existe pas => erreur - */ - sprintf(nomdatagroup2,"%*li%*li",MED_MAX_PARA,(long ) numdt,MED_MAX_PARA,(long ) numo); - - datagroup2 = 0; - if ( (datagroup2 = _MEDdatagroupOuvrir(datagroup1,nomdatagroup2)) < 0) - goto ERROR; - - /* - * Ouvre le datagroup de niveau 3 <maa> - */ - - if ( ! strcmp(maa,MED_NOREF) ) - if (_MEDattrStringLire(datagroup2,MED_NOM_MAI,MED_TAILLE_NOM,maa) < 0) - goto ERROR; - - datagroup3 = 0; - if ( (datagroup3 = _MEDdatagroupOuvrir(datagroup2,maa)) < 0 ) - goto ERROR; - - /* Gestion des profils*/ - - /* - * Lire le profil - */ - - if (_MEDattrStringLire(datagroup3,MED_NOM_PFL,MED_TAILLE_NOM,pfltmp) < 0) - goto ERROR; - - if ( pfluse = (strcmp(pfltmp,MED_NOPFLi) && strcmp(pfltmp,"")) ) /* le test MED_NOPFLi pour des raisons de compatibilité */ - { - strcpy(profil,pfltmp); - if ( (i = MEDnValProfil(fid,profil)) < 0 ) - goto ERROR; - else - psize = i; - - pfltabtmp = (med_int *) malloc (sizeof(med_int)*psize); - pfltab = (med_ssize *) malloc (sizeof(med_ssize)*psize); - if (MEDprofilLire(fid,pfltabtmp,profil) < 0) - goto ERROR; - for (i=0;i<psize;i++) - pfltab[i] = (med_ssize) pfltabtmp[i]; - - } - else { - psize = MED_NOPF; - strcpy(profil,MED_NOPFL); - } - - - /* Lire le nbre des points de GAUSS*/ - if (_MEDattrEntierLire(datagroup3,MED_NOM_NGA,&ngauss) < 0) { - MESSAGE_MED("Erreur à la lecture de l'attribut MED_NOM_NGA : "); - ISCRUTE_MED(ngauss);goto ERROR; - }; - - /* Lire l'identificateur de localisation des points de GAUSS*/ - if ( _MEDattrStringLire(datagroup3,MED_NOM_GAU,MED_TAILLE_NOM,locname) < 0) { - MESSAGE_MED("Erreur à la lecture de l'attribut MED_NOM_GAU : "); - SSCRUTE_MED(locname); goto ERROR; - } - - /* - * Lecture du champ - */ - - if (_MEDattrEntierLire(gid,MED_NOM_TYP,&chtype) < 0) - goto ERROR; - - switch(chtype) - { - case MED_FLOAT64 : - if ( _MEDdatasetNumLire(datagroup3,MED_NOM_CO,MED_FLOAT64, - interlace,ncomp,numco, - psize,pflmod,pfltab,ngauss,val)< 0) - goto ERROR; - break; - - case MED_INT32 : -#if defined(F77INT64) - if ( _MEDdatasetNumLire(datagroup3,MED_NOM_CO,MED_INT64, - interlace,ncomp,numco, - psize,pflmod,pfltab,ngauss,val)< 0) - goto ERROR; -#else - if ( _MEDdatasetNumLire(datagroup3,MED_NOM_CO,MED_INT32, - interlace,ncomp,numco, - psize,pflmod,pfltab,ngauss,val)< 0) - goto ERROR; -#endif - break; - - case MED_INT64 : -#if defined(F77INT64) - if ( _MEDdatasetNumLire(datagroup3,MED_NOM_CO,MED_INT64, - interlace,ncomp,numco, - psize,pflmod,pfltab,ngauss,val)< 0) - goto ERROR; -#else - goto ERROR; -#endif - break; - - default : - goto ERROR; - } - - /* - * On ferme tout - */ - - ret = 0; - - ERROR: - - if ( pfluse ) { free(pfltab); free(pfltabtmp);} - - if (datagroup3>0) if (_MEDdatagroupFermer(datagroup3) < 0) { - MESSAGE_MED("Impossible de fermer le datagroup : "); - ISCRUTE_MED(datagroup3); ret = -1; - } - - if (datagroup2>0) if (_MEDdatagroupFermer(datagroup2) < 0) { - MESSAGE_MED("Impossible de fermer le datagroup : "); - ISCRUTE_MED(datagroup2); ret = -1; - } - - if (datagroup1>0) if (_MEDdatagroupFermer(datagroup1) < 0) { - MESSAGE_MED("Impossible de fermer le datagroup : "); - ISCRUTE_MED(datagroup1); ret = -1; - } - - if (gid>0) if (_MEDdatagroupFermer(gid) < 0) { - MESSAGE_MED("Impossible de fermer le datagroup : "); - ISCRUTE_MED(gid); ret = -1; - } - - return ret; - } - - -#undef MESSAGE_MED -#undef SSCRUTE_MED -#undef ISCRUTE_MED - - } -} - - diff --git a/src/MEDMEM/MEDMEM_MEDMEMchampLire.hxx b/src/MEDMEM/MEDMEM_MEDMEMchampLire.hxx deleted file mode 100644 index db8b9c816..000000000 --- a/src/MEDMEM/MEDMEM_MEDMEMchampLire.hxx +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef MEDMEM_MEDMEMCHAMPLIRE_HXX -#define MEDMEM_MEDMEMCHAMPLIRE_HXX - -#include "MEDMEM.hxx" - -/* - * En attendant une correction de la gestion du mode d'accès au fichier dans MEDfichier - * on intègre la correction ici. - */ -namespace med_2_3 { - extern "C" { - -# define __UTILITES_H__ -#include <med_outils.h> -# undef __UTILITES_H__ - -#include <string.h> -#include <stdlib.h> - -MEDMEM_EXPORT med_err -MEDMEMchampLire(med_idt fid,char *maa, char *cha, unsigned char *val,med_mode_switch interlace,med_int numco, - char * locname, char *profil, med_mode_profil pflmod, - med_entite_maillage type_ent, med_geometrie_element type_geo, - med_int numdt, med_int numo); - - - } -} - -#endif diff --git a/src/MEDMEM/MEDMEM_MEDMEMgaussEcr.cxx b/src/MEDMEM/MEDMEM_MEDMEMgaussEcr.cxx deleted file mode 100644 index 52a015801..000000000 --- a/src/MEDMEM/MEDMEM_MEDMEMgaussEcr.cxx +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_MEDMEMgaussEcr.hxx" -/* - * En attendant une correction de la gestion du mode d'accès au fichier dans MEDfichier - * on intègre la correction ici. - */ - -namespace med_2_3 { - extern "C" { -# define ICI {\ - fflush(stdout);\ - fprintf(stderr, "%s [%d] : " , __FILE__ , __LINE__ ) ;\ - fflush(stderr) ;\ - } - -# define ISCRUTE_MED(entier) {\ - ICI ;\ - fprintf(stderr,"%s = %d\n",#entier,entier) ;\ - fflush(stderr) ;\ - } - -# define SSCRUTE_MED(chaine) {\ - ICI ;\ - fprintf(stderr,"%s = \"%s\"\n",#chaine,chaine) ;\ - fflush(stderr) ;\ - } -# define MESSAGE_MED(chaine) {\ - ICI ;\ - fprintf(stderr,"%s\n",chaine) ;\ - fflush(stderr) ;\ - } - - extern void _MEDmodeErreurVerrouiller(void); - - /* - * - Nom de la fonction : MEDgaussEcr - * - Description : Itérateur renvoyant (n°pdt,n°or), le nbre de point de GAUSS pour le type d'élément, - * et le maillage par défaut avec son eventuel lien à un autre fichier. - * - Parametres : - * - fid (IN) : ID du fichier HDF courant - * - type_geo (IN) : Le type géométrique de l'entité concerné {MED_POINT,MED_SEG2 ......} - * - refcoo (IN) : Les coordonnées des noeuds de l'élément de référence (tableau de taille(typegeo%100)*(typegeo/100) ) - * - mode_coo (IN) : Choix du type d'entrelacement utilisé en mémoire pour refcoo et gscoo - * { MED_FULL_INTERLACE(x1,y1,z1,x2,...)) , MED_NO_INTERLACE(x1,x2,y1,y2,z1,z2) } - * - ngauss (IN) : Nombre de points de Gauss pour l'élément de référence considéré - * - gscoo (IN) : Les coordonnées des points de Gauss pour l'élément de référence (tableau de taille ngauss*type_geo/100) - * - wg (IN) : Poids à appliquer aux points d'intégration (tableau de taille ngauss) - * - locname (IN) : Nom à associer à la localisation (MED_TAILLe_NOM) - - REM : - <locname> est à passer en paramètre de MEDchampEcrire. - */ - - med_err - MEDMEMgaussEcr(med_idt fid, med_geometrie_element type_geo, med_float *refcoo, med_mode_switch mode_coo, - med_int ngauss, med_float *gscoo, med_float * wg, char * locname ) - { - med_idt gid=0, chid=0; - med_size dimd[1]; - med_err ret = -1; - med_int typegeo = -1; - char chemin[MED_TAILLE_GAUSS+1]=""; - - /* - * On inhibe le gestionnaire d'erreur HDF 5 - */ - _MEDmodeErreurVerrouiller(); - - /* - * Si le groupe "GAUSS" n'existe pas, on le cree - */ - strncpy(chemin,MED_GAUSS,MED_TAILLE_GAUSS-1); - chemin[MED_TAILLE_GAUSS-1] = '\0'; - if ((gid = _MEDdatagroupOuvrir(fid,chemin)) < 0) - if ((gid = _MEDdatagroupCreer(fid,chemin)) < 0) { - MESSAGE_MED("Impossible de creer le groupe MED_GAUSS : "); - SSCRUTE_MED(chemin); goto ERROR; - } - - /* - * Si le groupe <locname> n'existe pas, on le cree - * Sinon => erreur - */ - if ((chid = _MEDdatagroupOuvrir(gid,locname)) >= 0) { - if ( false )//MED_MODE_ACCES != MED_LECTURE_ECRITURE ) - { - MESSAGE_MED("Le nom de localisation existe déjà : "); - SSCRUTE_MED(locname); goto ERROR; - } - } else - if ((chid = _MEDdatagroupCreer(gid,locname)) < 0) - goto ERROR; - - /* - * On stocke <ngauss> sous forme d'attribut - */ - if (_MEDattrEntierEcrire(chid,MED_NOM_NBR,&ngauss) < 0) { - MESSAGE_MED("Erreur à l'écriture de l'attribut MED_NOM_NBR : "); - ISCRUTE_MED(ngauss);goto ERROR; - }; - - /* - * On stocke <type_geo> sous forme d'attribut - */ - typegeo = (med_int) type_geo; - /* sizeof(enum) tjrs = sizeof(int) en C, or - sur machines 64 bits par défaut med_int==long, - du coup sur machines 64 bits _MEDattrEntierEcrire utilise - le type hdf NATIVE_LONG, ce qui pose un problème qd on passe - un enum. - */ - if (_MEDattrEntierEcrire(chid,MED_NOM_GEO,&typegeo) < 0) { - MESSAGE_MED("Erreur à l'écriture de l'attribut MED_NOM_GEO : "); - ISCRUTE_MED(type_geo);goto ERROR; - }; - - - /* - * On stocke les coordonnées de référence dans un dataset - */ - - dimd[0] = (type_geo%100)*(type_geo/100); - if ( _MEDdatasetNumEcrire(chid,MED_NOM_COO,MED_FLOAT64,mode_coo,(type_geo/100),MED_ALL,MED_NOPF,MED_NO_PFLMOD,0,MED_NOPG,dimd, - (unsigned char*) refcoo) < 0 ) { - MESSAGE_MED("Impossible d'ecrire le dataset : ");SSCRUTE_MED(MED_NOM_COO); - ISCRUTE_MED(dimd); goto ERROR; - } - - /* - * On stocke les points d'intégration dans un dataset - */ - - dimd[0] = ngauss*(type_geo/100); - if ( _MEDdatasetNumEcrire(chid,MED_NOM_GAU,MED_FLOAT64,mode_coo,(type_geo/100),MED_ALL,MED_NOPF,MED_NO_PFLMOD,0,MED_NOPG,dimd, - (unsigned char*) gscoo) < 0 ) { - MESSAGE_MED("Impossible d'ecrire le dataset : ");SSCRUTE_MED(MED_NOM_GAU); - ISCRUTE_MED(dimd); goto ERROR; - } - - /* - * On stocke les poids dans un dataset - */ - - dimd[0] = ngauss; - if ( _MEDdatasetNumEcrire(chid,MED_NOM_VAL,MED_FLOAT64,mode_coo,1,MED_ALL,MED_NOPF,MED_NO_PFLMOD,0,MED_NOPG,dimd, - (unsigned char*) wg) < 0 ) { - MESSAGE_MED("Impossible d'ecrire le dataset : ");SSCRUTE_MED(MED_NOM_VAL); - ISCRUTE_MED(dimd); goto ERROR; - } - - - ret = 0; - - ERROR: - - /* - * On ferme tout - */ - - if (chid>0) if (_MEDdatagroupFermer(chid) < 0) { - MESSAGE_MED("Impossible de fermer le datagroup : "); - ISCRUTE_MED(chid); ret = -1; - } - - if (gid>0) if (_MEDdatagroupFermer(gid) < 0) { - MESSAGE_MED("Impossible de fermer le datagroup : "); - ISCRUTE_MED(gid); ret = -1; - } - - return ret; - } - -#undef MESSAGE_MED -#undef SSCRUTE_MED -#undef ISCRUTE_MED - - } -} diff --git a/src/MEDMEM/MEDMEM_MEDMEMgaussEcr.hxx b/src/MEDMEM/MEDMEM_MEDMEMgaussEcr.hxx deleted file mode 100644 index 71b80f67a..000000000 --- a/src/MEDMEM/MEDMEM_MEDMEMgaussEcr.hxx +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef MEDMEM_MEDMEMGAUSSECR_HXX -#define MEDMEM_MEDMEMGAUSSECR_HXX - -#include "MEDMEM.hxx" - -/* - * En attendant une correction de la gestion du mode d'accès au fichier dans MEDfichier - * on intègre la correction ici. - */ -namespace med_2_3 { - extern "C" { - -# define __UTILITES_H__ -#include <med_outils.h> -# undef __UTILITES_H__ - -#include <string.h> -#include <stdlib.h> - -MEDMEM_EXPORT med_err -MEDMEMgaussEcr(med_idt fid, med_geometrie_element type_geo, med_float *refcoo, med_mode_switch mode_coo, - med_int ngauss, med_float *gscoo, med_float * wg, char * locname ); - - } -} - -#endif diff --git a/src/MEDMEM/MEDMEM_MEDMEMprofilEcr.cxx b/src/MEDMEM/MEDMEM_MEDMEMprofilEcr.cxx deleted file mode 100644 index a5f5da43b..000000000 --- a/src/MEDMEM/MEDMEM_MEDMEMprofilEcr.cxx +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_MEDMEMprofilEcr.hxx" -/* - * En attendant une correction de la gestion du mode d'accès au fichier dans MEDfichier - * on intègre la correction ici. - */ - -namespace med_2_3 { - extern "C" { - -# define ICI { \ - fflush(stdout); \ - fprintf(stderr, "%s [%d] : " , __FILE__ , __LINE__ ) ; \ - fflush(stderr) ; \ - } - -# define ISCRUTE_MED(entier) { \ - ICI ; \ - fprintf(stderr,"%s = %d\n",#entier,entier) ; \ - fflush(stderr) ; \ - } - -# define SSCRUTE_MED(chaine) { \ - ICI ; \ - fprintf(stderr,"%s = \"%s\"\n",#chaine,chaine) ; \ - fflush(stderr) ; \ - } -# define MESSAGE_MED(chaine) { \ - ICI ; \ - fprintf(stderr,"%s\n",chaine) ; \ - fflush(stderr) ; \ - } - - extern void _MEDmodeErreurVerrouiller(void); - -#include <med.h> -#include <med_outils.h> - -#include <string.h> -#include <stdlib.h> - - med_err - MEDMEMprofilEcr(med_idt fid,med_int *pflval,med_int n,char *profilname) - { - med_idt gid, chid; - med_size dimd[1]; - med_err ret; - char chemin[MED_TAILLE_PROFILS+1]; - - /* - * On inhibe le gestionnaire d'erreur HDF 5 - */ - _MEDmodeErreurVerrouiller(); - - /* - * Si le groupe "PROFILS" n'existe pas, on le cree - */ - strncpy(chemin,MED_PROFILS,MED_TAILLE_PROFILS-1); - chemin[MED_TAILLE_PROFILS-1] = '\0'; - if ((gid = _MEDdatagroupOuvrir(fid,chemin)) < 0) - if ((gid = _MEDdatagroupCreer(fid,chemin)) < 0) { - MESSAGE_MED("Impossible de creer le groupe MED_PROFILS : "); - SSCRUTE_MED(chemin); goto ERROR; - } - - /* - * Si le groupe "profilname" n'existe pas, on le cree - * Sinon => erreur - */ - if ((chid = _MEDdatagroupOuvrir(gid,profilname)) >= 0) { - if ( false )//MED_MODE_ACCES != MED_LECTURE_ECRITURE ) - { - MESSAGE_MED("Le profil existe déjà : "); - SSCRUTE_MED(profilname); goto ERROR; - } - } else - if ((chid = _MEDdatagroupCreer(gid,profilname)) < 0) - goto ERROR; - - /* - * On stocke "n" sous forme d'attribut - */ - if ((ret = _MEDattrEntierEcrire(chid,MED_NOM_NBR,&n)) < 0) { - MESSAGE_MED("Erreur à l'écriture de l'attribut MED_NOM_NBR : "); - ISCRUTE_MED(n); goto ERROR; - }; - - /* - * On stocke le profil dans un dataset - */ - dimd[0] = n; -#if defined(F77INT64) - ret = _MEDdatasetNumEcrire(chid,MED_NOM_PFL,MED_INT64,MED_NO_INTERLACE,MED_DIM1,MED_ALL,MED_NOPF,MED_NO_PFLMOD,0,MED_NOPG,dimd, - (unsigned char*) pflval); -#else - ret = _MEDdatasetNumEcrire(chid,MED_NOM_PFL,MED_INT32,MED_NO_INTERLACE,MED_DIM1,MED_ALL,MED_NOPF,MED_NO_PFLMOD,0,MED_NOPG,dimd, - (unsigned char*) pflval); -#endif - if (ret < 0 ) { - MESSAGE_MED("Impossible d'ecrire le dataset pflval de taille : "); - ISCRUTE_MED(n); goto ERROR; - } - - ret = 0; - ERROR: - /* - * On ferme tout - */ - if (chid>0) if (_MEDdatagroupFermer(chid) < 0) { - MESSAGE_MED("Impossible de fermer le datagroup : "); - ISCRUTE_MED(chid); ret = -1; - } - - if (gid>0) if (_MEDdatagroupFermer(gid) < 0) { - MESSAGE_MED("Impossible de fermer le datagroup : "); - ISCRUTE_MED(gid); ret = -1; - } - - return ret; - } - -#undef MESSAGE_MED -#undef SSCRUTE_MED -#undef ISCRUTE_MED - - } -} - - - - diff --git a/src/MEDMEM/MEDMEM_MEDMEMprofilEcr.hxx b/src/MEDMEM/MEDMEM_MEDMEMprofilEcr.hxx deleted file mode 100644 index 236ac343a..000000000 --- a/src/MEDMEM/MEDMEM_MEDMEMprofilEcr.hxx +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef MEDMEM_MEDMEMPROFILECR_HXX -#define MEDMEM_MEDMEMPROFILECR_HXX - -#include "MEDMEM.hxx" - -/* - * En attendant une correction de la gestion du mode d'accès au fichier dans MEDfichier - * on intègre la correction ici. - */ -namespace med_2_3 { - extern "C" { - -# define __UTILITES_H__ -#include <med_outils.h> -# undef __UTILITES_H__ - -#include <string.h> -#include <stdlib.h> - - MEDMEM_EXPORT med_err - MEDMEMprofilEcr(med_idt fid,med_int *pflval,med_int n,char *profilname); - - } -} - -#endif diff --git a/src/MEDMEM/MEDMEM_MedFieldDriver.hxx b/src/MEDMEM/MEDMEM_MedFieldDriver.hxx deleted file mode 100644 index 3d3f986c0..000000000 --- a/src/MEDMEM/MEDMEM_MedFieldDriver.hxx +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef MED_FIELD_DRIVER_HXX -#define MED_FIELD_DRIVER_HXX - -#include "MEDMEM_GenDriver.hxx" - -namespace MEDMEM { -template <class T> class MED_FIELD_RDWR_DRIVER; -template <class T> class MED_FIELD_RDONLY_DRIVER; -template <class T> class MED_FIELD_WRONLY_DRIVER; - -/*! - - Driver Med for FIELD. - - Generic part : implement open and close methods. - -*/ - -template <class T> class MED_FIELD_DRIVER : public GENDRIVER -{ -protected: - // Developement plus propre : - // - Il faudrait soit utiliser le type FIELD_ et ajouter à cette classe - // les accesseurs de FIELD<> utilisées dans les drivers - // - Ou bien avoir des drivers à deux paramètres template (le top) - // - Remarquez l'affreux cast dans le second constructeur : - // _ptrField( (FIELD<T> *) ptrField ) - // Cela cast toujours le ptrField en FullInterlace - // Cela ne pose cependant pas de pb de fonctionement aux drivers - FIELD<T> * _ptrField; - std::string _fieldName; - int _fieldNum; - med_2_3::med_idt _medIdt; - -public : - - MED_FIELD_DRIVER(); - - template <class INTERLACING_TAG> - MED_FIELD_DRIVER(const std::string & fileName, - FIELD<T, INTERLACING_TAG> * ptrField, - MED_EN::med_mode_acces accessMode); - - MED_FIELD_DRIVER(const MED_FIELD_DRIVER & fieldDriver); - - virtual ~MED_FIELD_DRIVER(); - - virtual void open() throw (MEDEXCEPTION); - virtual void close(); - virtual void write( void ) const = 0 ; - virtual void read ( void ) = 0 ; - /*! - Set the name of the FIELD asked in file. - - It could be different than the name of the FIELD object. - */ - virtual void setFieldName(const std::string & fieldName) { _fieldName = fieldName; } - /*! - Get the name of the FIELD asked in file. - */ - virtual std::string getFieldName() const { return _fieldName; } - -protected: - virtual GENDRIVER * copy ( void ) const = 0 ; - - bool createFieldSupportPart1(med_2_3::med_idt id, - const std::string & fieldName, - med_2_3::med_int ndt, - med_2_3::med_int od, - SUPPORT & support, - std::string & meshName, - std::vector<int> & numberOfElementsOfTypeC, - std::vector<int> & numberOfGaussPoint, - std::vector<std::string>& gaussModelName, - std::vector<std::string>& profilName, - int & totalNumberOfElWg, - MED_EN::medEntityMesh & fieldMedFileEntity, - MED_EN::medEntityMesh preferEntity=MED_EN::MED_ALL_ENTITIES - ) const throw (MEDEXCEPTION); - - void getMeshGeometricTypeFromFile(med_2_3::med_idt id, - std::string & meshName, - MED_EN::medEntityMesh entite, - std::vector<MED_EN::medGeometryElement> & geoType, - std::vector<int> & nbOfElOfType, - std::vector<int> & nbOfElOfTypeC - ) const throw(MEDEXCEPTION); - - void getMeshGeometricTypeFromMESH( const GMESH * meshPtr, - MED_EN::medEntityMesh entity, - std::vector<MED_EN::medGeometryElement> & geoType, - std::vector<int> &nbOfElOfType, - std::vector<int> &nbOfElOfTypeC - ) const throw(MEDEXCEPTION); - - int getMeshDimensionFromFile(med_2_3::med_idt id, const string & meshName) const; - - MED_EN::medEntityMesh getMEDMEMEntityFromMEDType(MED_EN::medGeometryElement type, - int mesh_dim) const; - -}; - -/*! - - Driver Med for FIELD : Read only. - - Implement read method. - -*/ - -template <class T> class MED_FIELD_RDONLY_DRIVER : public virtual MED_FIELD_DRIVER<T> -{ -public : - - MED_FIELD_RDONLY_DRIVER(); - - template <class INTERLACING_TAG> - MED_FIELD_RDONLY_DRIVER(const string & fileName, - FIELD<T, INTERLACING_TAG> * ptrField); - - MED_FIELD_RDONLY_DRIVER(const MED_FIELD_RDONLY_DRIVER & fieldDriver); - - virtual ~MED_FIELD_RDONLY_DRIVER() {}; - - void write( void ) const throw (MEDEXCEPTION) ; - void read ( void ) throw (MEDEXCEPTION) ; - -private: - GENDRIVER * copy( void ) const ; - -}; - -/*! - - Driver Med for FIELD : Write only. - - Implement write method. - -*/ - -template <class T> class MED_FIELD_WRONLY_DRIVER : public virtual MED_FIELD_DRIVER<T> -{ -public : - - MED_FIELD_WRONLY_DRIVER(); - - template <class INTERLACING_TAG> - MED_FIELD_WRONLY_DRIVER(const string & fileName, - FIELD<T, INTERLACING_TAG> * ptrField); - - MED_FIELD_WRONLY_DRIVER(const MED_FIELD_WRONLY_DRIVER & fieldDriver); - - virtual ~MED_FIELD_WRONLY_DRIVER(); - - /*! - Write FIELD in the specified file. - */ - void write( void ) const throw (MEDEXCEPTION) ; - /*! - Return a MEDEXCEPTION : it is the write-only driver. - */ - void read ( void ) throw (MEDEXCEPTION) ; - -private: - GENDRIVER * copy( void ) const ; - -}; - - -/*! - - Driver Med for FIELD : Read write. - - Use read method from MED_FIELD_RDONLY_DRIVER - - Use write method from MED_FIELD_WDONLY_DRIVER - -*/ - -template <class T> class MED_FIELD_RDWR_DRIVER : public MED_FIELD_RDONLY_DRIVER<T>, public MED_FIELD_WRONLY_DRIVER<T> -{ -public : - - MED_FIELD_RDWR_DRIVER(); - - template <class INTERLACING_TAG> - MED_FIELD_RDWR_DRIVER(const string & fileName, - FIELD<T, INTERLACING_TAG> * ptrField); - - MED_FIELD_RDWR_DRIVER(const MED_FIELD_RDWR_DRIVER & fieldDriver); - - /*! - Destructor. - */ - ~MED_FIELD_RDWR_DRIVER(); - - /*! - Write FIELD in the specified file. - */ - void write(void) const throw (MEDEXCEPTION) ; - /*! - Read FIELD in the specified file. - */ - void read (void) throw (MEDEXCEPTION) ; - -private: - GENDRIVER * copy( void ) const ; - -}; - -} //End namespace MEDMEM - -// implementation -#include "MEDMEM_MedFieldDriver.txx" - -#endif /* MED_FIELD_DRIVER_HXX */ diff --git a/src/MEDMEM/MEDMEM_MedFieldDriver.txx b/src/MEDMEM/MEDMEM_MedFieldDriver.txx deleted file mode 100644 index eebb28f25..000000000 --- a/src/MEDMEM/MEDMEM_MedFieldDriver.txx +++ /dev/null @@ -1,2248 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// File : MEDMEM_MedFieldDriver22.txx -// Created : Thu Jul 22 12:52:43 2010 -// Author : Edward AGAPOV (eap) -// -// This file contains impelementations of methods that must be included together with -// the template class declaration - -#ifndef MED_FIELD_DRIVER_TXX -#define MED_FIELD_DRIVER_TXX - -#include <algorithm> - -#include "MEDMEM_FieldConvert.hxx" -#include "MEDMEM_ArrayInterface.hxx" -#include "MEDMEM_ArrayConvert.hxx" - -#include "MEDMEM_STRING.hxx" -#include "MEDMEM_Exception.hxx" - -#include "MEDMEM_DriversDef.hxx" -#include "MEDMEM_MedFieldDriver.hxx" -#include "MEDMEM_Unit.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Group.hxx" -#include "MEDMEM_GaussLocalization.hxx" - -namespace MEDMEM -{ - -/*! - Constructor. -*/ -template <class T> -MED_FIELD_DRIVER<T>::MED_FIELD_DRIVER(): - GENDRIVER(MED_DRIVER), - _ptrField((FIELD<T> *) MED_NULL), - _fieldName(""),_fieldNum(MED_EN::MED_INVALID),_medIdt(MED_INVALID) -{} - -/*! - Constructor. -*/ -template <class T> -template <class INTERLACING_TAG> -MED_FIELD_DRIVER<T>::MED_FIELD_DRIVER(const string & fileName, - FIELD<T, INTERLACING_TAG> * ptrField, - MED_EN::med_mode_acces accessMode) - : GENDRIVER(fileName, accessMode, MED_DRIVER), - _ptrField((FIELD<T> *) ptrField), - _fieldName(""),_fieldNum(MED_EN::MED_INVALID),_medIdt(MED_INVALID) -{ -} - -/*! - Copy constructor. -*/ -template <class T> -MED_FIELD_DRIVER<T>::MED_FIELD_DRIVER(const MED_FIELD_DRIVER<T> & fieldDriver): - GENDRIVER(fieldDriver), - _ptrField(fieldDriver._ptrField), - _fieldName(fieldDriver._fieldName), - _fieldNum(fieldDriver._fieldNum), - _medIdt(fieldDriver._medIdt) -{ -} - -/*! - Destructor. -*/ -template <class T> -MED_FIELD_DRIVER<T>::~MED_FIELD_DRIVER() -{ - MESSAGE_MED("MED_FIELD_DRIVER<T>::~MED_FIELD_DRIVER() has been destroyed"); -} - -/*! - Open the file -*/ -template <class T> -void MED_FIELD_DRIVER<T>::open() throw (MEDEXCEPTION) -{ - const char * LOC = "MED_FIELD_DRIVER::open() "; - BEGIN_OF_MED(LOC); - - // we must set fieldname before open, because we must find field number in file (if it exist !!!) - if ( MED_FIELD_DRIVER<T>::_fileName == "" ) - throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) - << "_fileName is |\"\"|, please set a correct fileName before calling open()" - ) - ); - if ( MED_FIELD_DRIVER<T>::_status==MED_OPENED ) - return; - - int accessMode = MED_FIELD_DRIVER<T>::_accessMode; - if ( accessMode == MED_EN::RDWR ) - accessMode = med_2_3::MED_ACC_RDWR; - MESSAGE_MED(LOC<<"_fileName.c_str : "<< MED_FIELD_DRIVER<T>::_fileName.c_str()<<",mode : "<< MED_FIELD_DRIVER<T>::_accessMode); - MED_FIELD_DRIVER<T>::_medIdt = med_2_3::MEDfileOpen( MED_FIELD_DRIVER<T>::_fileName.c_str(),(med_2_3::med_access_mode) accessMode); - MESSAGE_MED(LOC<<"_medIdt : "<< MED_FIELD_DRIVER<T>::_medIdt ); - if (MED_FIELD_DRIVER<T>::_medIdt > 0) - MED_FIELD_DRIVER<T>::_status=MED_OPENED; - else { - MED_FIELD_DRIVER<T>::_status = MED_INVALID; - //MED_FIELD_DRIVER<T>::_medIdt = MED_INVALID; - throw MED_EXCEPTION (LOCALIZED( STRING(LOC) - << "Can't open |" << MED_FIELD_DRIVER<T>::_fileName - << "|, _medIdt : " << MED_FIELD_DRIVER<T>::_medIdt - ) - ); - } - - END_OF_MED(LOC); -} - -/*! - Close the file -*/ -template <class T> -void MED_FIELD_DRIVER<T>::close() -{ - const char* LOC = "MED_FIELD_DRIVER::close()"; - BEGIN_OF_MED(LOC); - med_2_3::med_int err = 0; - if (MED_FIELD_DRIVER<T>::_status == MED_OPENED) { - err=med_2_3::MEDfileClose(MED_FIELD_DRIVER<T>::_medIdt); - if ( err ) - cout << LOC << "can't CLOSE file"<<MED_FIELD_DRIVER<T>::_fileName<<endl; - //H5close(); // If we call H5close() all the files are closed. - MED_FIELD_DRIVER<T>::_status = MED_CLOSED; - MED_FIELD_DRIVER<T>::_medIdt = MED_INVALID; - MESSAGE_MED(" MED_FIELD_DRIVER::close() : MEDfermer : _medIdt= " << MED_FIELD_DRIVER<T>::_medIdt ); - MESSAGE_MED(" MED_FIELD_DRIVER::close() : MEDfermer : err = " << err ); - } - END_OF_MED(LOC); -} - - -/*! - Constructor. -*/ -template <class T> -MED_FIELD_RDONLY_DRIVER<T>::MED_FIELD_RDONLY_DRIVER():MED_FIELD_DRIVER<T>() -{ - this->GENDRIVER::_accessMode = MED_EN::RDONLY; -} - -/*! - Constructor. -*/ -template <class T> -template <class INTERLACING_TAG> -MED_FIELD_RDONLY_DRIVER<T>::MED_FIELD_RDONLY_DRIVER(const string & fileName, - FIELD<T, INTERLACING_TAG> * ptrField): - MED_FIELD_DRIVER<T>(fileName,ptrField,MED_EN::RDONLY) -{ - const char* LOC = "MED_FIELD_RDONLY_DRIVER::MED_FIELD_RDONLY_DRIVER(const string & fileName, const FIELD<T,INTERLACING_TAG> * ptrField)"; - BEGIN_OF_MED(LOC); - END_OF_MED(LOC); -} - -/*! - Copy constructor. -*/ -template <class T> -MED_FIELD_RDONLY_DRIVER<T>::MED_FIELD_RDONLY_DRIVER(const MED_FIELD_RDONLY_DRIVER & fieldDriver): - MED_FIELD_DRIVER<T>(fieldDriver) -{} - -/*! - - Cette méthode crée le SUPPORT du champ <fieldName> pour le - <n°de pas de temps,n°d'itération>=<ndt,od>. - - Le SUPPORT crée à pour nom <fieldName>Support et contient - la liste des types géométriques sur le premier type - d'entité trouvé (en MEDMEM on inderdit aux champs de reposer - sur plusieurs types d'entité). - Il contient également le nombre d'entités trouvées pour chaque - type géométrique. - Par défaut l'attribut onAll du SUPPORT est positionné à true car - cette routine ne lit rien de ce qui concerne les entités - du maillage associé. - La méthode renvoie true si elle réussit à créer le SUPPORT - demandé. - Le nom du maillage associé ( en MEDMEM on ne - supporte pas encore les maillages multiples ) est renvoyé dans <meshName>. - Deux tableaux directements exploitables par MEDMEMnArray sont renvoyés : - - numberOfElementsOfTypeC : nombres d'entités cumulés de chaque type géométrique - avec numberOfElementsOfTypeC[0]=1 et de taille nombre de types+1 - - numberOfGaussPoint : nombre de points de Gauss par type géométrique - avec numberOfGaussPoint[0]=1 et de taille nombre de types+1. - <preferEntity> argument (if not default) gives entity of already present support, - which is used to select entity if there are several of them. See issue - 20582: [CEA 368] MEDMEM don't work with a same field on NODES and CELLS -*/ - -template <class T> bool -MED_FIELD_DRIVER<T>::createFieldSupportPart1(med_2_3::med_idt id, - const string & fieldName, - med_2_3::med_int ndt, - med_2_3::med_int od, - SUPPORT & support, - string & meshName, - vector<int> & numberOfElementsOfTypeC, - vector<int> & numberOfGaussPoint, - std::vector<std::string>& gaussModelName, - std::vector<std::string>& profilName, - int & totalNumberOfElWg, - MED_EN::medEntityMesh & fieldMedFileEntity, - MED_EN::medEntityMesh preferEntity - ) const throw (MEDEXCEPTION) -{ - - //EF : Gérer le meshName pour le driver 2.2 - const char * LOC="MED_FIELD_DRIVER<T>::createFieldSupportPart1(...)"; - - BEGIN_OF_MED(LOC); - - map<int, list<MED_EN::medGeometryElement> > CellAndNodeEntities; - map<int, list<MED_EN::medGeometryElement> >::iterator currentEntity; - CellAndNodeEntities[MED_EN::MED_CELL] = MED_EN::meshEntities[MED_EN::MED_CELL]; - CellAndNodeEntities[MED_EN::MED_NODE] = MED_EN::meshEntities[MED_EN::MED_NODE]; - list< MED_EN::medGeometryElement >::const_iterator currentGeometry; - - MED_EN::medEntityMesh entityCurrent; - MED_EN::medGeometryElement geometryCurrent; - - MED_EN::medEntityMesh entity; - MED_EN::medEntityMesh medmem_entity; - - bool alreadyFoundAnEntity=false;//,alreadyFoundPdtIt = false; - int numberOfElements = 0; - int numberOfGeometricType = 0; - MED_EN::medGeometryElement geometricType[MED_N_CELL_GEO_FIXED_CON]; - int numberOfElementsOfType[MED_N_CELL_GEO_FIXED_CON]; - numberOfElementsOfTypeC.clear();numberOfGaussPoint.clear(); - numberOfElementsOfTypeC.resize(MED_N_CELL_GEO_FIXED_CON+1); - numberOfGaussPoint.resize(MED_N_CELL_GEO_FIXED_CON+1); - - med_2_3::med_int numdt=-1, numo=-1, ngauss=0, nbPdtIt=0; - char dtunit[MED_LNAME_SIZE+1]; - char maa[MED_NAME_SIZE+1]; - med_2_3::med_float dt=-1.0; - med_2_3::med_bool local; - med_2_3::med_err ret=1; - numberOfElementsOfTypeC[0] = 1; - numberOfGaussPoint[0] = 1; - totalNumberOfElWg = 0; - int field_dim=0; - - char pflnamep3[MED_NAME_SIZE+1] = ""; - int profilesizep3; - char locnamep3[MED_NAME_SIZE+1] = ""; - - /* Détermine le type d'entité et la liste des types géométriques associés - au champ <fieldName> */ - for (currentEntity = CellAndNodeEntities.begin(); - currentEntity != CellAndNodeEntities.end(); currentEntity++) { // loop on [CELL,NODE] - for (currentGeometry = (*currentEntity).second.begin(); - currentGeometry != (*currentEntity).second.end(); currentGeometry++) { - - entityCurrent = (*currentEntity).first ; - geometryCurrent = (*currentGeometry) ; - - medmem_entity = entityCurrent; - - // That is a difference between Med File and Med Memory (NB) - if (geometryCurrent == MED_EN::MED_SEG2 || geometryCurrent == MED_EN::MED_SEG3) - medmem_entity = MED_EN::MED_EDGE; - - if (geometryCurrent == MED_EN::MED_TRIA3 || geometryCurrent == MED_EN::MED_QUAD4 || - geometryCurrent == MED_EN::MED_TRIA6 || geometryCurrent == MED_EN::MED_QUAD8 || - geometryCurrent == MED_EN::MED_POLYGON) - medmem_entity = MED_EN::MED_FACE; - - // med3 porting - numberOfElements = med_2_3::MEDfieldnValueWithProfile - (id,fieldName.c_str(),ndt,od, - (med_2_3::med_entity_type) entityCurrent, - (med_2_3::med_geometry_type) geometryCurrent, - /*profileit=*/1,med_2_3::MED_COMPACT_PFLMODE, - pflnamep3,&profilesizep3,locnamep3,&ngauss); - - if ( numberOfElements <= 0 ) - numberOfElements = med_2_3::MEDfieldnValueWithProfile - (id,fieldName.c_str(),ndt,od, - (med_2_3::med_entity_type) ( entityCurrent = medmem_entity ), // try the other entity ! - (med_2_3::med_geometry_type) geometryCurrent, - /*profileit=*/1,med_2_3::MED_COMPACT_PFLMODE, - pflnamep3,&profilesizep3,locnamep3,&ngauss); - - if ( numberOfElements <= 0 ) - continue; - - if ( preferEntity != MED_EN::MED_ALL_ENTITIES ) //issue 20582: field on NODES and CELLS - { - bool preferNode = (preferEntity == MED_EN::MED_NODE); - bool foundNode = (medmem_entity == MED_EN::MED_NODE); - if ( preferNode != foundNode ) - continue; - } - - /* Verifie que le champ n'est pas défini sur un autre type d'entité */ - if ( alreadyFoundAnEntity ) - { - if ( medmem_entity != entity ) - { - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Field |" << fieldName - << "| with (ndt,or) = (" << ndt << "," - << od << ") must not be defined on different entity types" )); - } - } - //else - { - entity=medmem_entity; - fieldMedFileEntity = entityCurrent; - alreadyFoundAnEntity = true; - - //at this stage, the entity is only related to the geometry dimension - // with no relation to the mesh dimension - // therefore MED_CELL refer to 3D and MED_FACE to 2D - // the correct entity (which depends on the mesh dimension, is only - // determined later - - switch (entity) - { - case MED_NODE: - field_dim=0; - break; - case MED_EDGE: - field_dim=1; - break; - case MED_FACE: - field_dim=2; - break; - case MED_CELL: - field_dim=3; - break; - } - } - - if (/* (ret != 0) ||*/ (ngauss < 1 ) ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Error in MEDfieldnValueWithProfile for Field |" << fieldName - << "| with (ndt,or) = (" - << ndt << "," << od << ") for (entityType,geometricType)=(" - << MED_EN::entNames[entityCurrent] << "," - << MED_EN::geoNames[geometryCurrent] << ")" )); ; - - numberOfElementsOfType[numberOfGeometricType] = numberOfElements; - numberOfElementsOfTypeC[numberOfGeometricType+1]= - numberOfElementsOfTypeC[numberOfGeometricType] - + numberOfElementsOfType[numberOfGeometricType]; - numberOfGaussPoint[numberOfGeometricType+1] = ngauss; - geometricType[numberOfGeometricType]= geometryCurrent; - numberOfGeometricType++; - totalNumberOfElWg+=numberOfElements*ngauss; - - gaussModelName.push_back( locnamep3 ); - locnamep3[0] = '\0'; - profilName.push_back( pflnamep3 ); - pflnamep3[0] = '\0'; - } // End Second For - - } // End Premier For - - if ( numberOfGeometricType == 0 ) - return false; - - { - // Read mesh name and nb of timestamps in the field - med_2_3::med_field_type typchap3; - int nbCompp3=med_2_3::MEDfieldnComponentByName(id,fieldName.c_str()); - if ( nbCompp3 <= 0 ) - return false; - char *compNamesp3=new char[nbCompp3*MED_SNAME_SIZE+1]; - char *compUnitp3=new char[nbCompp3*MED_SNAME_SIZE+1]; - ret = med_2_3::MEDfieldInfoByName(id,fieldName.c_str(),maa,&local,&typchap3,compNamesp3,compUnitp3,dtunit,&nbPdtIt); - delete [] compNamesp3; - delete [] compUnitp3; - if ( ret < 0 ) - return false; - - - //VB commented out to allow for fields on multiple meshes - // if ( ! meshName.empty() ) - // if ( meshName != maa ) { - // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Field |" << fieldName << "| with (ndt,or) = (" - // << ndt << "," << od << ") for (entityType,geometricType)=(" - // << MED_EN::entNames[entityCurrent] << "," - // << MED_EN::geoNames[*currentGeometry] << ")" - // << "is defined on mesh |" << maa << "| not on mesh |" << meshName )); - if ( meshName.empty() ) - meshName = maa; - if ( meshName.empty() ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Can't get mesh name for field |" << fieldName - << "| using MEDfieldInfoByName()" )); - // Read the time - bool timeFound = false; - for ( med_2_3::med_int j=1; j <= nbPdtIt; j++ ) - { - ret = med_2_3::MEDfieldComputingStepInfo(id,fieldName.c_str(),j,&numdt,&numo,&dt); - if ( ret == MED_INVALID ) - throw MEDEXCEPTION(LOCALIZED( STRING(LOC) << ": can't read the " - << j << "-th timestamp info of field " << fieldName )); - if ( numdt == ndt && numo == od ) - { - MED_FIELD_DRIVER<T>::_ptrField->setTime(dt); - timeFound = true; - break; - } - } - if ( !timeFound ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Timestamp with (ndt,or) = (" - << ndt << "," << od << ") not found for field " << fieldName)); - } - - //retrieves the right medmem entity type from field_dim and mesh_dim - int mesh_dim = MED_FIELD_DRIVER<T>::getMeshDimensionFromFile(id,meshName); - //if (mesh_dim==2 && field_dim==2) // 0020644: [CEA 384] Problem with 1D no structured meshing - if (mesh_dim==field_dim) - entity=MED_CELL; - - if ( alreadyFoundAnEntity) { - support.setName(fieldName+" Support"); - support.setMeshName(meshName); // Vérifier que les différents noms de maillages lus soient identiques - support.setEntity(entity); - // REM : Le nombre <numberOfGeometricType> dans la précédente version du Driver - // était erronée pour un champ qui ne reposait pas sur toutes les entités géométriques - // du maillage mais dont le SUPPORT a été crée à partir des informations du maillage - // ( méthode qui était largement utilisée pour construire un SUPPORT). - support.setNumberOfGeometricType(numberOfGeometricType); - support.setGeometricType(geometricType); // Utile uniquement si setAll == false ? - support.setNumberOfElements(numberOfElementsOfType); //setNumberOfElements effectue une copie - // Par défaut considère que le champ repose sur tous les type géométriques du maillage - // Si ce n'est pas le cas les champs geometricType et numberOfElementsOfType du SUPPORT sont corrects - support.setAll(true); - numberOfElementsOfTypeC.resize(numberOfGeometricType+1); - numberOfGaussPoint.resize(numberOfGeometricType+1); - } - return alreadyFoundAnEntity; -} - -template <class T> MED_EN::medEntityMesh -MED_FIELD_DRIVER<T>::getMEDMEMEntityFromMEDType(medGeometryElement type, - int mesh_dim) const -{ - int elem_dim = type/100; - if (type==MED_POLYGON) elem_dim=2; - if (type==MED_POLYHEDRA) elem_dim=3; - - if (elem_dim==3) - return MED_CELL; - if (elem_dim==2) - { - if (mesh_dim==2) - return MED_CELL; - else if (mesh_dim==3) - return MED_FACE; - } - if (elem_dim==1) - return MED_EDGE; - if(elem_dim==0) - return MED_NODE; -} - - -template <class T> int -MED_FIELD_DRIVER<T>::getMeshDimensionFromFile(med_2_3::med_idt id, - const string & meshName) const -{ - const char* LOC = "MED_FIELD_DRIVER<T>::getMeshDimensionFromFile(...)"; - BEGIN_OF_MED(LOC); - - // BEGIN Issue 0020620: [CEA 378] Abort during MED mesh reading - // Find out if mesh is structured and read its dim if it is - med_2_3::med_int meshDim; - med_2_3::med_int spaceDimp3; - med_2_3::med_mesh_type meshType; - char meshNameInFile[MED_NAME_SIZE+1]; - char meshDescription[MED_COMMENT_SIZE+1]; - char dtunit[MED_LNAME_SIZE+1]; - med_2_3::med_sorting_type sorttypep3; - med_2_3::med_int nstepp3; - med_2_3::med_axis_type atp3; - // find mesh <meshName> - int numberOfMeshes = med_2_3::MEDnMesh(id); - for (int i = 1; i <= numberOfMeshes; ++i ) - { -#ifdef WIN32 - int naxis=max(3,med_2_3::MEDmeshnAxis(id,i)); -#else - int naxis=std::max(3,med_2_3::MEDmeshnAxis(id,i)); -#endif - char *axisname=new char[naxis*MED_SNAME_SIZE+1]; - char *axisunit=new char[naxis*MED_SNAME_SIZE+1]; - med_2_3::MEDmeshInfo(id, i ,meshNameInFile, &spaceDimp3, &meshDim, &meshType, meshDescription,dtunit,&sorttypep3,&nstepp3,&atp3,axisname,axisunit); - delete [] axisname; - delete [] axisunit; - if ( meshName == meshNameInFile ) - { - if ( meshType == med_2_3::MED_STRUCTURED_MESH ) - return meshDim; - break; - } - } - // END Issue 0020620: [CEA 378] Abort during MED mesh reading - - int numberOfGeometricType=0; - MED_EN::medGeometryElement geometricType[MED_N_CELL_GEO_FIXED_CON]; - med_2_3::med_int numberOfElements=0; - - /*in MED file, all entities are regarded as MED_CELL - (except for those related to descending connectivities), - whereas in MEDMEM the distinction between MED_CELL, MED_FACE and MED_EDGE exists - it is therefore necessary to distinguish the MED-file entity - that will be used for the call to MED-file - and the MEDMEM entity*/ - const MED_EN::medEntityMesh entity = MED_EN::MED_CELL; - - list<MED_EN::medGeometryElement>::const_iterator currentGeometry; - - med_2_3::med_int dtp3 = MED_NO_DT, itp3 = MED_NO_IT; - med_2_3::med_float dtfp3 = MED_NO_DT; - med_2_3::med_bool chp3,trp3; - med_2_3::MEDmeshComputationStepInfo(id,meshName.c_str(),1,&dtp3,&itp3,&dtfp3); - - for (currentGeometry = (MED_EN::meshEntities[entity]).begin(); - currentGeometry != (MED_EN::meshEntities[entity]).end(); currentGeometry++) - { - numberOfElements = - med_2_3::MEDmeshnEntity( id, meshName.c_str(), - dtp3,itp3, - med_2_3::MED_CELL,(med_2_3::med_geometry_type) *currentGeometry, - med_2_3::MED_CONNECTIVITY,med_2_3::MED_NODAL, - &chp3,&trp3); - if (numberOfElements <= 0) - continue; - - geometricType[numberOfGeometricType] = *currentGeometry; - - numberOfGeometricType++; - } - - //Because MEDFILE and MEDMEM differ on the definition of MED_CELL - //it is necessary to remove the cells that do not - //have maximum cell dimension in the range covered by geometricType - int maxdim=0; - for (int i=0; i<numberOfGeometricType; i++) - { - const CELLMODEL& model = CELLMODEL_Map::retrieveCellModel(geometricType[i]); - int dim = model.getDimension(); - if (dim>maxdim) maxdim=dim; - } - - return maxdim; - -} - -/*! - - Renvoie la liste <geoType> des types géométriques définis dans le maillage <meshName> - pour le type d'entité <entity>. - * < nbOfElOfType > contient le nombre d'entités de chaque type - * < numberOfElementsOfTypeC > contient le nombre d'entités cumulées de chaque type - avec numberOfElementsOfTypeC[0]=0; - * < allDimensions > controls dimension of returned types of entity == MED_CELL -*/ -template <class T> void -MED_FIELD_DRIVER<T>::getMeshGeometricTypeFromFile(med_2_3::med_idt id, - string & meshName, - MED_EN::medEntityMesh entity, - vector<MED_EN::medGeometryElement> & geoType, - vector<int> & nbOfElOfType, - vector<int> & nbOfElOfTypeC - ) const throw(MEDEXCEPTION) -{ - const char* LOC = "MED_FIELD_DRIVER<T>::getMeshGeometricTypeFromFile(...)"; - BEGIN_OF_MED(LOC); - - int numberOfGeometricType=0; - MED_EN::medGeometryElement geometricType[MED_N_CELL_GEO_FIXED_CON]; - int numberOfElementsOfType [MED_N_CELL_GEO_FIXED_CON]; - int numberOfElementsOfTypeC[MED_N_CELL_GEO_FIXED_CON+1]; - int dimOfType[MED_N_CELL_GEO_FIXED_CON]; - int maxdim=0; - med_2_3::med_int numberOfElements=0; - med_2_3::med_data_type quoi; - - /*in MED file, all entities are regarded as MED_CELL - (except for those related to descending connectivities), - whereas in MEDMEM the distinction between MED_CELL, MED_FACE and MED_EDGE exists - it is therefore necessary to distinguish the MED-file entity - that will be used for the call to MED-file - and the MEDMEM entity*/ - MED_EN::medEntityMesh medfile_entity; - if (entity==MED_EN::MED_NODE) - { - medfile_entity=MED_EN::MED_NODE; - quoi=med_2_3::MED_COORDINATE; - } - else - { - medfile_entity=MED_EN::MED_CELL; - quoi=med_2_3::MED_CONNECTIVITY; - } - - list<MED_EN::medGeometryElement>::const_iterator currentGeometry; - bool alreadyFoundAnEntity = false; - numberOfElementsOfTypeC[0]=0; - - for (currentGeometry = (MED_EN::meshEntities[entity]).begin(); - currentGeometry != (MED_EN::meshEntities[entity]).end(); currentGeometry++) - { - med_2_3::med_int dtp3,itp3; - med_2_3::med_float dtfp3; - med_2_3::med_bool chp3,trp3; - med_2_3::MEDmeshComputationStepInfo(id,meshName.c_str(),1,&dtp3,&itp3,&dtfp3); - numberOfElements = - med_2_3::MEDmeshnEntity(id,meshName.c_str(),dtp3,itp3,(med_2_3::med_entity_type) medfile_entity,(med_2_3::med_geometry_type) *currentGeometry,quoi,med_2_3::MED_NODAL,&chp3,&trp3); - - if (numberOfElements <= 0) - continue; - - alreadyFoundAnEntity = true; - numberOfElementsOfType[numberOfGeometricType] = numberOfElements; - numberOfElementsOfTypeC[numberOfGeometricType+1] = - numberOfElementsOfTypeC[numberOfGeometricType]+numberOfElements; - - MED_EN::medGeometryElement geomType = *currentGeometry; - geometricType[numberOfGeometricType] = geomType; - - //Because MEDFILE and MEDMEM differ on the definition of MED_CELL - //it is necessary to remove the cells that do not - //have maximum cell dimension in the range covered by geometricType - const CELLMODEL& model = CELLMODEL_Map::retrieveCellModel( geomType ); - const int dim = model.getDimension(); - dimOfType[ numberOfGeometricType ] = dim; - if (dim>maxdim) maxdim=dim; - - numberOfGeometricType++; - } - - nbOfElOfTypeC.push_back(0); - for (int i=0; i<numberOfGeometricType; i++) - { - if (dimOfType[i]==maxdim || entity != MED_CELL) - { - geoType.push_back(geometricType[i]); - int nbelems = numberOfElementsOfType[i]; - nbOfElOfType.push_back(nbelems); - nbOfElOfTypeC.push_back(nbOfElOfTypeC[nbOfElOfTypeC.size()-1]+nbelems); - } - } - - // geoType = vector<MED_EN::medGeometryElement>(geometricType,geometricType+numberOfGeometricType); - // nbOfElOfType = vector<int> (numberOfElementsOfType,numberOfElementsOfType+numberOfGeometricType); - // nbOfElOfTypeC = vector<int> (numberOfElementsOfTypeC,numberOfElementsOfTypeC+numberOfGeometricType+1); - -// for (int j =0 ; j<= numberOfGeometricType;++j) -// cout << "nbOfElOfTypeC["<<j<<"]="<<nbOfElOfTypeC[j]<<endl; - - END_OF_MED(LOC); -} - -/*! -reads the MESH object in order to retrieve the list of geometric types for a given entity -\param[in] meshPtr pointer to MESH -\param[in] entity entity for which the geom types are required -\param[out] geoType list of geom types -\param[out] nbOfElOfType vector containing the number of elements per type (size : ntype) -\param[out] nbOfElOfTypeC accumulated version of nbOfElType (size : ntype+1) - */ - -template <class T> void -MED_FIELD_DRIVER<T>::getMeshGeometricTypeFromMESH( const GMESH * meshPtr, - MED_EN::medEntityMesh entity, - std::vector<MED_EN::medGeometryElement> & geoType, - std::vector<int> &nbOfElOfType, - std::vector<int> &nbOfElOfTypeC) const throw(MEDEXCEPTION) -{ - const char LOC[] = "MED_FIELD_DRIVER<T>::getMeshGeometricTypeFromMESH(...) : "; - BEGIN_OF_MED(LOC); - - if (!meshPtr) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"ptrMesh must be non null" )); ; - - // Il est plus pratique de créer un support "onAll" - // pour calculer les tableaux du nombre d'entités cumulées - - const SUPPORT *mySupportFromMesh=meshPtr->getSupportOnAll(entity); - geoType = vector<MED_EN::medGeometryElement>(mySupportFromMesh->getTypes(), - mySupportFromMesh->getTypes()+mySupportFromMesh->getNumberOfTypes()); - nbOfElOfType.resize(mySupportFromMesh->getNumberOfTypes()); - nbOfElOfTypeC.resize(mySupportFromMesh->getNumberOfTypes()+1); - nbOfElOfTypeC[0]=0; - - for (int j=1; j<=mySupportFromMesh->getNumberOfTypes(); ++j) { - nbOfElOfType[j-1]=mySupportFromMesh->getNumberOfElements(geoType[j-1]); - nbOfElOfTypeC[j]+=nbOfElOfTypeC[j-1]+nbOfElOfType[j-1]; - } - END_OF_MED(LOC); -} - -/*--------------------- RDONLY PART -------------------------------*/ - -template <class T> GENDRIVER * MED_FIELD_RDONLY_DRIVER<T>::copy(void) const -{ - return new MED_FIELD_RDONLY_DRIVER<T>(*this); -} - -/*! - In MEDMEM, FIELDs lie on support which can be plain SUPPORT, FAMILY - or GROUP, while in MED-file, there is no link between the FAMILY and - GROUP notions and the FIELDs. FIELDs lie on profiles. - The problem arises from the fact that the MED write driver creates - profiles when treating fields that lie on MEDMEM::SUPPORT, - MEDMEM_FAMILY or MEDMEM::GROUP. The profile is named after the - support name : nameOfSupport_<type_of_geometric_entity>. - However, the read driver is unable to link supports and profiles - and it recreates a new support that corresponds to the field profile. - - To avoid this support recreation, pass the mesh to the FIELD's - constructor, and the field driver will find appropriate FAMILY or GROUP - in the mesh and use it for the field. - */ -template <class T> void MED_FIELD_RDONLY_DRIVER<T>::read(void) - throw (MEDEXCEPTION) -{ - const char * LOC = " MED_FIELD_RDONLY_DRIVER::read() " ; - BEGIN_OF_MED(LOC); - - typedef typename MEDMEM_ArrayInterface<T,NoInterlace,NoGauss>::Array ArrayNo; - typedef typename MEDMEM_ArrayInterface<T,NoInterlace,Gauss>::Array ArrayNoWg; - typedef typename MEDMEM_ArrayInterface<T,FullInterlace,NoGauss>::Array ArrayFull; - typedef typename MEDMEM_ArrayInterface<T,FullInterlace,Gauss>::Array ArrayFullWg; - typedef typename MEDMEM_ArrayInterface<T,NoInterlaceByType,NoGauss>::Array ArrayByType; - typedef typename MEDMEM_ArrayInterface<T,NoInterlaceByType,Gauss>::Array ArrayByTypeWg; - - if (MED_FIELD_DRIVER<T>::_status!=MED_OPENED) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": Method open must be called before method read.")) ; - - if ( ( MED_FIELD_DRIVER<T>::_fieldName.empty() ) && - ( MED_FIELD_DRIVER<T>::_ptrField->_name.empty() ) ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) - <<" neither <fieldName> is set in driver nor in object FIELD.")) ; - - // If _fieldName is not set in driver, try to use _ptrfield->_fieldName - if ( ( MED_FIELD_DRIVER<T>::_fieldName.empty() ) && - ( !MED_FIELD_DRIVER<T>::_ptrField->_name.empty() ) ) - MED_FIELD_DRIVER<T>::_fieldName=MED_FIELD_DRIVER<T>::_ptrField->_name; - - if ( MED_FIELD_DRIVER<T>::_fieldName.size() > MED_NAME_SIZE ) - { - SCRUTE_MED(MED_FIELD_DRIVER<T>::_fieldName.size()); - SCRUTE_MED(MED_NAME_SIZE); - -// throw MEDEXCEPTION(LOCALIZED(STRING(LOC) -// <<" <fieldName> size in object driver FIELD is > MED_NAME_SIZE .")); - - MESSAGE_MED(LOC << "Warning <fieldName> size in object driver FIELD is > MED_NAME_SIZE ."); - } - - const string & fieldName = MED_FIELD_DRIVER<T>::_fieldName; - - MED_EN::medModeSwitch interlacingType = MED_FIELD_DRIVER<T>::_ptrField->getInterlacingType(); - bool isFullInterlace = ( interlacingType == MED_EN::MED_FULL_INTERLACE ); - bool isNoInterlaceByType = ( interlacingType == MED_EN::MED_NO_INTERLACE_BY_TYPE );//PAL17011 - - MESSAGE_MED("###### "<<LOC<<" fieldNameDRIVER : "<< fieldName << " fieldName : "<< MED_FIELD_DRIVER<T>::_ptrField->_name); - -// EF : -// Si un support a été donnée au champ, pour des raisons de compatibilité avec -// les versions précédentes, ce support sera utilisé pour -// - Obtenir le nom du maillage sur lequel on veut lire le champ -// (eventuellement on pourrait l'utiliser pour selectionner un champ qui -// repose sur plusieurs maillages cf HOMARD-ASTER, ce qui n'est pas géré dans MEDMEM) -// - vérifier le type d'entité (MED_NOEUD xor MED_MAILLE xor MED_FACE xor MED_ARETE ) sur lequel -// il faut lire le champ qui est également retouvé. -// - Si le support défini une liste d'entité ( différente de MED_ALL_ELEMENTS), celle-ci est ignorée -// à la lecture et écrasé par soit : -// - onall, après avoir vérifié que la liste des types géométriques utilisés par le champ -// est égale à la liste des type géométriques définis dans le maillage associé -// pour tous le même type d'entité. -// - La sous liste des types géométriques utilisés (onAll quand même, cf commenataire ci-dessous ) -// - les listes de profils lus s'il en existe pour une sous liste de types -// géométriques - -// Si aucun support n'a été donné au champ : -// - A la lecture : Un support est crée et le type d'entité unique est lu -// (cf decision gt MED qu'un champ repose sur une entité unique ?), -// l'ensemble des types géométriques est lu, -// l'ensemble des profils par type géométrique est lu -// Le nom du maillage associé est lu mais le pointeur SUPPORT-MESH non initialisé - - - char tmpFieldName[MED_NAME_SIZE+1] ; - int err ; - int numberOfComponents = 0; - char * componentName = (char *) MED_NULL; - char * unitName = (char *) MED_NULL; - med_2_3::med_field_type type ; - med_2_3::med_idt id = MED_FIELD_DRIVER<T>::_medIdt; - bool needConversionToDouble = false,needConversionToInt64 = false; - - // we search for the "field med number" of <fieldName> - // Having found <fieldName>, variables <numberOfComponents>, - // <componentName>, <unitname>, <type> and attribute <_fieldNum> are set. - if (MED_FIELD_DRIVER<T>::_fieldNum==MED_INVALID) - { - int numberOfFields = med_2_3::MEDnField(id) ; - if ( numberOfFields <= 0 ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": There is no field found in the file !")); - - for (int i=1;i<=numberOfFields;i++) - { - numberOfComponents = med_2_3::MEDfieldnComponent(id,i) ; - - if ( numberOfComponents <= 0 ) - MESSAGE_MED(LOC<<"Be careful there is no components for field n°"<<i<<"in file |"<<MED_FIELD_DRIVER<T>::_fileName<<"| !"); - - componentName = new char[numberOfComponents*MED_SNAME_SIZE+1] ; - unitName = new char[numberOfComponents*MED_SNAME_SIZE+1] ; - char meshnamep3[MED_NAME_SIZE+1]; - med_2_3::med_bool localp3; - char dtunitp3[MED_LNAME_SIZE+1]; - med_2_3::med_int nstpp3; - err = med_2_3::MEDfieldInfo(id, i, tmpFieldName, meshnamep3, - &localp3, &type, componentName, - unitName, dtunitp3,&nstpp3) ; - - MESSAGE_MED("Field "<<i<<" : #" << tmpFieldName <<"# et recherche #"<<fieldName.c_str()<<"#"); - if ( !strcmp(tmpFieldName,fieldName.c_str()) ) { - MESSAGE_MED("FOUND FIELD "<< tmpFieldName <<" : "<<i); - MED_FIELD_DRIVER<T>::_fieldNum = i ; - break ; - } - // not found : release memory and search next field ! - delete[] componentName ; - delete[] unitName ; - } - } - - // Si aucun champ ne correspond les variables <componentName> et <unitName> ont été correctement - // désallouées dans la boucle de recherche - if (MED_FIELD_DRIVER<T>::_fieldNum==MED_INVALID) - throw MEDEXCEPTION(LOCALIZED( STRING(LOC) << ": Field "<< fieldName - << " not found in file " << MED_FIELD_DRIVER<T>::_fileName) ); - - MESSAGE_MED ("FieldNum : "<<MED_FIELD_DRIVER<T>::_fieldNum); - - if (numberOfComponents < 1) { - delete[] componentName; delete[] unitName; - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" no component found for field " - << fieldName)) ; - } - - // Verifie que l'on essaye pas de lire un champ double dans un FIELD<int> - switch ( (med_2_3::med_field_type) MED_FIELD_DRIVER<T>::_ptrField->_valueType ) { - case med_2_3::MED_INT : - case med_2_3::MED_INT32 : - case med_2_3::MED_INT64 : - if ( type == ( med_2_3::MED_FLOAT64 ) ) { - delete[] componentName; delete[] unitName; - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Field Type in file (" << type - <<") differs from FIELD object type (" << - MED_FIELD_DRIVER<T>::_ptrField->_valueType << ")" )) ; - } -#if defined(IRIX64) || defined(OSF1) ||defined(VPP5000) || defined(PCLINUX64) - if (MED_FIELD_DRIVER<T>::_ptrField->_valueType==MED_EN::MED_INT32 ) - needConversionToInt64=true; -#endif - break; - case med_2_3::MED_FLOAT64 : - if (type != med_2_3::MED_FLOAT64) - needConversionToDouble=true; - break; - default: - break; - } - - string meshName=""; - const GMESH * ptrMesh = 0; - bool haveSupport = false; - bool haveMesh = false; - MED_EN::medEntityMesh preferEntity = MED_EN::MED_ALL_ENTITIES; - if ( MED_FIELD_DRIVER<T>::_ptrField->getSupport() ) { - // Verif à faire sur la taille du meshName - ptrMesh = MED_FIELD_DRIVER<T>::_ptrField->getSupport()->getMesh(); - if ( ptrMesh) { - meshName = MED_FIELD_DRIVER<T>::_ptrField->getSupport()->getMesh()->getName() ; - haveMesh = true; - } - haveSupport = true; - preferEntity = MED_FIELD_DRIVER<T>::_ptrField->getSupport()->getEntity(); - } - else if ( MED_FIELD_DRIVER<T>::_ptrField->_mesh ) { - ptrMesh = MED_FIELD_DRIVER<T>::_ptrField->_mesh; - meshName = ptrMesh->getName() ; - haveMesh = true; - } - - // Cherche le type d'entité, le nombre d'entité par type géométrique sur le type d'entité - // (MED_MAILLE ou MED_NOEUD uniquement car MEDMEMOIRE ne gère pas la connectivité descendante). - // et crée le support correspondant. - SUPPORT * mySupport = new SUPPORT; - vector<int> numberOfElementsOfTypeC; - vector<int> numberOfGaussPoint; - vector<string> gaussModelName, profilName; - int totalNumberOfElWg=0; - MED_EN::medEntityMesh fieldMedFileEntity; - - bool found = this->createFieldSupportPart1(id,fieldName, - MED_FIELD_DRIVER<T>::_ptrField->_iterationNumber, - MED_FIELD_DRIVER<T>::_ptrField->_orderNumber, - *mySupport, meshName, - numberOfElementsOfTypeC, - numberOfGaussPoint, gaussModelName, profilName, - totalNumberOfElWg, fieldMedFileEntity, preferEntity); - - - if ( !found ) { - mySupport->removeReference(); delete[] componentName; delete[] unitName; - MED_FIELD_DRIVER<T>::_fieldNum = MED_INVALID ; - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Can't find any entity for field |" - << fieldName - << "| with (it,or) = (" - << MED_FIELD_DRIVER<T>::_ptrField->_iterationNumber << "," - << MED_FIELD_DRIVER<T>::_ptrField->_orderNumber << "), on mesh |" - << meshName << "|" )); - } - - - //int mesh_dim = MED_FIELD_DRIVER<T>::getMeshDimensionFromFile(id,meshName); - - MED_EN::medEntityMesh entityType = mySupport->getEntity(); - //Si un SUPPORT était donné, récupère son nom, sa description et - // le pointeur du maillage associé - if (! haveSupport) - meshName = mySupport->getMeshName(); - else { - // for bug 19782. Entity of support in field was set by med driver and was taken - // from the file without any analysis. It can differ from entity the support will - // have in MEDMEM. -// if ( entityType != MED_FIELD_DRIVER<T>::_ptrField->getSupport()->getEntity() ) { -// delete mySupport; delete[] componentName; delete[] unitName; -// MED_FIELD_DRIVER<T>::_fieldNum = MED_INVALID ; -// throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Given entity |" -// << MED_EN::entNames[MED_FIELD_DRIVER<T>::_ptrField-> -// getSupport()->getEntity()] -// << "| for field |" -// << fieldName -// << "| with (it,or) = (" -// << MED_FIELD_DRIVER<T>::_ptrField->_iterationNumber << "," -// << MED_FIELD_DRIVER<T>::_ptrField->_orderNumber << "), on mesh " -// << meshName << "| differs from found entity |" -// << MED_EN::entNames[entityType] << "|." -// )); -// } - // postpone name setting until profile analisys in order not to set "ON_ALL_entity" - // name to a partial support - //if ( entityType == MED_FIELD_DRIVER<T>::_ptrField->getSupport()->getEntity() ) - //mySupport->setName( MED_FIELD_DRIVER<T>::_ptrField->getSupport()->getName() ); - mySupport->setMesh( MED_FIELD_DRIVER<T>::_ptrField->getSupport()->getMesh() ); - mySupport->setDescription(MED_FIELD_DRIVER<T>::_ptrField->getSupport()->getDescription()); - } - - vector< MED_EN::medGeometryElement > MESHgeoType; - vector< int > MESHnbOfElOfType; - vector< int > MESHnbOfElOfTypeC; - if ( haveMesh ) - this->getMeshGeometricTypeFromMESH(ptrMesh,entityType,MESHgeoType, - MESHnbOfElOfType,MESHnbOfElOfTypeC); - // porting MED3 - med_2_3::med_int spceDimp3=-1,mdimp3; - med_2_3::med_mesh_type mtype; - char desccp3[MED_COMMENT_SIZE+1]; - char dttunittp3[MED_LNAME_SIZE+1]; - med_2_3::med_sorting_type sttp3; - med_2_3::med_int nsteppp3; - med_2_3::med_axis_type axxxppp3; -#ifdef WIN32 - int naxis=max(3,med_2_3::MEDmeshnAxisByName(id,meshName.c_str())); -#else - int naxis=std::max(3,med_2_3::MEDmeshnAxisByName(id,meshName.c_str())); -#endif - char *annp3=new char[naxis*MED_SNAME_SIZE+1]; - char *auup3=new char[naxis*MED_SNAME_SIZE+1]; - bool fileHasMesh=(med_2_3::MEDmeshInfoByName(id,meshName.c_str(),&spceDimp3,&mdimp3,&mtype,desccp3,dttunittp3,&sttp3,&nsteppp3,&axxxppp3,annp3,auup3)==0 && spceDimp3 > 0); - delete [] annp3; - delete [] auup3; - // end porting MED3 - vector< MED_EN::medGeometryElement > meshGeoType; - vector< int > meshNbOfElOfType; - vector< int > meshNbOfElOfTypeC; - // Si le maillage n'est pas trouvé les tableaux renvoyés sont vides - if (fileHasMesh) - { -// MED_EN::medEntityMesh entityTypeLoc = entityType; -// if (entityType == MED_EN::MED_FACE || entityType == MED_EN::MED_EDGE) entityTypeLoc = MED_EN::MED_CELL; - - this->getMeshGeometricTypeFromFile(id,meshName,entityType,meshGeoType, - meshNbOfElOfType,meshNbOfElOfTypeC); - } - - SCRUTE_MED(meshGeoType.size()); - SCRUTE_MED(MESHgeoType.size()); - SCRUTE_MED(meshNbOfElOfTypeC.size()); - SCRUTE_MED(MESHnbOfElOfTypeC.size()); - - if (meshGeoType.size() != MESHgeoType.size()) - { - for (unsigned i = 0; i<meshGeoType.size();i++) - MESSAGE_MED("debug meshGeotype " << meshGeoType[i]); - - for (unsigned i = 0; i<MESHgeoType.size();i++) - MESSAGE_MED("debug MESHgeoType. " << MESHgeoType[i]); - } - - if (meshNbOfElOfTypeC.size() == MESHnbOfElOfTypeC.size()) - { - for (unsigned i = 0; i<meshNbOfElOfTypeC.size();i++) - MESSAGE_MED("debug meshNbOfElOfTypeC " << meshNbOfElOfTypeC[i]); - - for (unsigned i = 0; i<MESHnbOfElOfTypeC.size();i++) - MESSAGE_MED("debug MESHnbOfElOfTypeC " << MESHnbOfElOfTypeC[i]); - } - - if (fileHasMesh && haveSupport ) - if ( ( meshGeoType != MESHgeoType ) || (meshNbOfElOfTypeC != MESHnbOfElOfTypeC) ) - { - MESSAGE_MED("Warning MedField driver 21 while getting mesh information from file for FIELD "<< fieldName - << " on entity " << MED_EN::entNames[entityType] - << " with (it,or) = (" - << MED_FIELD_DRIVER<T>::_ptrField->_iterationNumber << "," - << MED_FIELD_DRIVER<T>::_ptrField->_orderNumber << ")" - << " on mesh " << meshName - << " : geometric types or number of elements by type differs from MESH object !"); - -// throw MEDEXCEPTION(LOCALIZED( STRING(LOC) <<": Error while getting mesh information from file for FIELD "<< fieldName -// << " on entity " << MED_EN::entNames[entityType] -// << " with (it,or) = (" -// << MED_FIELD_DRIVER<T>::_ptrField->_iterationNumber << "," -// << MED_FIELD_DRIVER<T>::_ptrField->_orderNumber << ")" -// << " on mesh " << meshName -// << " : geometric types or number of elements by type differs from MESH object !" -// ) -// ); - } - - if ( !fileHasMesh && !haveSupport ) - throw MEDEXCEPTION(LOCALIZED( STRING(LOC) <<": Error while getting mesh information for FIELD "<< fieldName - << " on entity " << MED_EN::entNames[entityType] - << " with (it,or) = (" - << MED_FIELD_DRIVER<T>::_ptrField->_iterationNumber << "," - << MED_FIELD_DRIVER<T>::_ptrField->_orderNumber << ")" - << " on mesh " << meshName - << " : SUPPORT must contain a valid MESH reference or file must contain the associated MESH." - ) - ); - - - if (!fileHasMesh && haveSupport) { - meshNbOfElOfTypeC = MESHnbOfElOfTypeC; - meshGeoType = MESHgeoType; - meshNbOfElOfType = MESHnbOfElOfType; - } - - // Test si le Support du Champ repose ou non sur toutes les entités géométriques - // du maillage associé et positionne ou non l'attribut onAll du SUPPORT. - // Il ne s'agit pas de la gestion des profils - vector < MED_EN::medGeometryElement > v1( mySupport->getTypes(), - mySupport->getTypes()+mySupport->getNumberOfTypes() ); - vector<int> v2(numberOfElementsOfTypeC.size()); - transform(numberOfElementsOfTypeC.begin(), - numberOfElementsOfTypeC.end(),v2.begin(), bind2nd(plus<int>(),1)); - - if ( ( meshGeoType != v1 ) || meshNbOfElOfTypeC != v2 ) { - // ATTENTION : mySupport->setAll(false); - // Pb : On a envie de positionner onAll à faux si le champ n'est pas défini sur tous les - // types géométriques du maillage associé. - // Mais si onAll est false et si aucun profil n'est détecté par la suite, - // l'attribut SUPPORT->_number est censé être positionné quand même ! Que faire ? - // Si on veut être compatible avec la signification première de onAll, - // il faudrait créer des profils contenant toutes les entités pour chaque type géométrique - // du SUPPORT mais d'une part c'est dommage d'un point de vue de l'encombrement mémoire - // et d'autre part, à la réécriture du fichier MED on stockera des profils - // alors qu'il n'y en avait pas à l'origine (fichier MED différent après lecture/écriture) ! - // Si on laisse setAll à vrai il faut être sûr que les utilisateurs prennent les - // informations sur les types gémétrique au niveau du support et non pas du maillage. - // Solution : Signification du onAll -> onAllElements des type géométriques définis - // dans le SUPPORT et non du maillage associé (dans la plupart des cas si le fichier ne - // contient pas de profil, le champ est défini sur toutes les entités de tous les types - // géométriques définis dans le maillage). - } - - - // If an error occurs while reading the field, these allocated FIELD member will be deleted - - MED_FIELD_DRIVER<T>::_ptrField->_name = healName( fieldName ); - MED_FIELD_DRIVER<T>::_ptrField->_numberOfComponents = numberOfComponents ; - //MED_FIELD_DRIVER<T>::_ptrField->_componentsTypes = new int [numberOfComponents] ; - //MED_FIELD_DRIVER<T>::_ptrField->_componentsNames = new string[numberOfComponents] ; - //MED_FIELD_DRIVER<T>::_ptrField->_componentsUnits = new UNIT [numberOfComponents] ; - //MED_FIELD_DRIVER<T>::_ptrField->_componentsDescriptions = new string[numberOfComponents] ; - //MED_FIELD_DRIVER<T>::_ptrField->_MEDComponentsUnits = new string[numberOfComponents] ; - MED_FIELD_DRIVER<T>::_ptrField->_componentsTypes.resize(numberOfComponents); - MED_FIELD_DRIVER<T>::_ptrField->_componentsNames.resize(numberOfComponents); - MED_FIELD_DRIVER<T>::_ptrField->_componentsUnits.resize(numberOfComponents); - MED_FIELD_DRIVER<T>::_ptrField->_componentsDescriptions.resize(numberOfComponents); - MED_FIELD_DRIVER<T>::_ptrField->_MEDComponentsUnits.resize(numberOfComponents); - for (int i=0; i<numberOfComponents; i++) { - MED_FIELD_DRIVER<T>::_ptrField->_componentsTypes[i] = 1 ; - MED_FIELD_DRIVER<T>::_ptrField->_componentsNames[i] = string(componentName+i*MED_SNAME_SIZE,MED_SNAME_SIZE) ; - MED_FIELD_DRIVER<T>::_ptrField->_MEDComponentsUnits[i] = string(unitName+i*MED_SNAME_SIZE,MED_SNAME_SIZE) ; - SCRUTE_MED(MED_FIELD_DRIVER<T>::_ptrField->_componentsNames[i]); - SCRUTE_MED(MED_FIELD_DRIVER<T>::_ptrField->_MEDComponentsUnits[i]); - } - delete[] componentName; - delete[] unitName; - - int NumberOfTypes = mySupport->getNumberOfTypes() ; - const MED_EN::medGeometryElement *types = mySupport->getTypes() ; - T * myValues = new T[totalNumberOfElWg*numberOfComponents]; - const int * nbOfElOfType = mySupport->getNumberOfElements() ; - bool anyProfil = false; - int pflSize=0,index=0; - // Le vecteur de profil est dimensionné par rapport aux nombres de types - // géométriques du champ même si le champ n'a pas de profil MED FICHIER sur - // tous ses types géométriques car dans MEDMEM si onAllElement - // du SUPPORT est false il faut positionner un profil pour tous les types géométriques - // du SUPPORT - int profilSizeC = 0; - vector < int > profilSize (NumberOfTypes,0); - vector < string > profilNameList(NumberOfTypes); - vector < vector<med_2_3::med_int> > profilList (NumberOfTypes); // IPAL13481 - vector < vector<med_2_3::med_int> > profilListFromFile (NumberOfTypes); // IPAL13481 - //char * profilName = new char[MED_NAME_SIZE+1]; - - MESSAGE_MED ("NumberOfTypes : "<< NumberOfTypes); - MED_FIELD_DRIVER<T>::_ptrField->_numberOfValues=0 ; - - // PAL16681 (Read no interlace field from file) -> - // use medModeSwitch of a field in MEDchampLire() if there is one geometric type - // to exclude array conversion - med_2_3::med_switch_mode modswt = med_2_3::MED_FULL_INTERLACE; - // NOTE: field can be either of 3 medModeSwitch'es, MED_NO_INTERLACE_BY_TYPE added (PAL17011) - if ( ( NumberOfTypes == 1 && !isFullInterlace) || isNoInterlaceByType ) - modswt = med_2_3::MED_NO_INTERLACE; - - for (int typeNo=0; typeNo<NumberOfTypes; typeNo++) { - - int numberOfValuesWc= nbOfElOfType[typeNo]*numberOfGaussPoint[typeNo+1]*numberOfComponents; - //char * gaussModelName = new char[MED_NAME_SIZE+1]; - - MESSAGE_MED ("FIELD_NAME : "<< fieldName.c_str()); - MESSAGE_MED ("MESH_NAME : "<< meshName.c_str()); - MESSAGE_MED ("MED_ENTITE : "<< MED_EN::entNames[entityType]); - MESSAGE_MED ("MED_GEOM : "<< MED_EN::geoNames[types[typeNo]]); - MESSAGE_MED ("Iteration : "<< MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber()); - MESSAGE_MED ("Order : "<< MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber()); - MESSAGE_MED ("Time : "<< MED_FIELD_DRIVER<T>::_ptrField->getTime()); - MESSAGE_MED ("NumberOfElements : "<< nbOfElOfType[typeNo]); - MESSAGE_MED ("NumberOfComponents : "<< numberOfComponents); - MESSAGE_MED ("NumberOfGaussPts : "<< numberOfGaussPoint[typeNo+1]); - MESSAGE_MED ("NumberOfValuesWg : "<< nbOfElOfType[typeNo]*numberOfGaussPoint[typeNo+1]); - MESSAGE_MED ("NumberOfValuesWgWc : "<< numberOfValuesWc); - MESSAGE_MED ("Index : "<< index); - med_2_3::med_err ret=-1; - - med_2_3::med_int * myValuesTmp=0; - unsigned char* ptrTmp=0; - if (needConversionToDouble || needConversionToInt64 ) { - myValuesTmp = new med_2_3::med_int[numberOfValuesWc]; - ptrTmp = (unsigned char*) myValuesTmp; - } else - ptrTmp = (unsigned char*) &myValues[index]; - - //VERIFIER LE NBRE -// med_2_3::med_entite_maillage medfile_entity; -// if (entityType==MED_NODE) -// medfile_entity= (med_2_3::med_entite_maillage)MED_NODE; -// else -// medfile_entity= (med_2_3::med_entite_maillage)MED_CELL; - ret=med_2_3::MEDfieldValueWithProfileRd(id,fieldName.c_str(), - MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber(), - MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber(), - (med_2_3::med_entity_type) fieldMedFileEntity, - (med_2_3::med_geometry_type)types[typeNo], - med_2_3::MED_COMPACT_PFLMODE, - profilName[typeNo].c_str(),modswt,MED_ALL_CONSTITUENT, - (unsigned char*) ptrTmp); - - if (needConversionToDouble || needConversionToInt64 ) { - - if (needConversionToInt64 ) //utiliser un trait - for(int i=0;i<numberOfValuesWc;++i) - myValues[index+i]=(int)(myValuesTmp[i]); - else - for(int i=0;i<numberOfValuesWc;++i) - myValues[index+i]=myValuesTmp[i]; - delete[] myValuesTmp; - } - - if (ret < 0) - { - // The Field can't be read then we must delete all previously allocated members in FIELD - //for(int j=0; j<=i;j++) - // delete[] myValues[j]; - delete[] myValues; - //delete[] NumberOfValues ; - //delete[] profilName; - //delete[] gaussModelName; - //delete[] MED_FIELD_DRIVER<T>::_ptrField->_componentsTypes ; - //delete[] MED_FIELD_DRIVER<T>::_ptrField->_componentsNames ; - //delete[] MED_FIELD_DRIVER<T>::_ptrField->_componentsUnits ; - //delete[] MED_FIELD_DRIVER<T>::_ptrField->_componentsDescriptions ; - //delete[] MED_FIELD_DRIVER<T>::_ptrField->_MEDComponentsUnits ; - //MED_FIELD_DRIVER<T>::_ptrField->_componentsTypes = NULL ; - //MED_FIELD_DRIVER<T>::_ptrField->_componentsNames = NULL ; - //MED_FIELD_DRIVER<T>::_ptrField->_componentsUnits = NULL ; - //MED_FIELD_DRIVER<T>::_ptrField->_componentsDescriptions = NULL ; - //MED_FIELD_DRIVER<T>::_ptrField->_MEDComponentsUnits = NULL ; - MED_FIELD_DRIVER<T>::_ptrField->_componentsTypes.clear(); - MED_FIELD_DRIVER<T>::_ptrField->_componentsNames.clear(); - MED_FIELD_DRIVER<T>::_ptrField->_componentsUnits.clear(); - MED_FIELD_DRIVER<T>::_ptrField->_componentsDescriptions.clear(); - MED_FIELD_DRIVER<T>::_ptrField->_MEDComponentsUnits.clear(); - MED_FIELD_DRIVER<T>::_fieldNum = MED_INVALID ; // we have not found right field, so reset the field number - throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": ERROR while reading values")) ; - } - - index += numberOfValuesWc; - // Le support prend en compte le nombre de valeurs lié aux profils - MED_FIELD_DRIVER<T>::_ptrField->_numberOfValues+= - nbOfElOfType[typeNo];// Ne doit pas prendre en compte les points de Gauss - - // second et troisième test lié à un bug medfichier - if ( gaussModelName[typeNo][0] ) - { - int type_geo = (int) types[typeNo]; - int t1 = (type_geo%100)*(type_geo/100); - int ngauss = numberOfGaussPoint[typeNo+1]; - int t2 = ngauss*(type_geo/100); - med_2_3::med_float * refcoo = new med_2_3::med_float[t1]; - med_2_3::med_float * gscoo = new med_2_3::med_float[t2]; - med_2_3::med_float * wg = new med_2_3::med_float[ngauss]; - - if (med_2_3::MEDlocalizationRd(id, gaussModelName[typeNo].c_str(), modswt, refcoo, gscoo, wg ) < 0) - throw MEDEXCEPTION(LOCALIZED( STRING(LOC) <<": Error while reading Gauss Model |" - << gaussModelName[typeNo] << "| for FIELD "<< fieldName - << " on geometric type " << MED_EN::geoNames[types[typeNo]] - ) - ); - if (isFullInterlace ) { //serait inutile avec un driver template du type d'entrelacement - GAUSS_LOCALIZATION<FullInterlace> * loc; - loc = new GAUSS_LOCALIZATION<FullInterlace>(gaussModelName[typeNo],types[typeNo],ngauss, refcoo,gscoo, wg); - MED_FIELD_DRIVER<T>::_ptrField->_gaussModel[types[typeNo]]=loc; - } else { - GAUSS_LOCALIZATION<NoInterlace> * loc; - loc = new GAUSS_LOCALIZATION<NoInterlace>(gaussModelName[typeNo],types[typeNo],ngauss, refcoo,gscoo, wg); - MED_FIELD_DRIVER<T>::_ptrField->_gaussModel[types[typeNo]]=loc; - } -// cout << *MED_FIELD_DRIVER<T>::_ptrField->_gaussModel[types[typeNo]] << endl; - delete [] refcoo;delete [] gscoo; delete [] wg; - - } - //delete[] gaussModelName ; - - if ( profilName[typeNo] != MED_NO_PROFILE ) { - anyProfil = true; - pflSize = med_2_3::MEDprofileSizeByName(id,profilName[typeNo].c_str()); - if ( pflSize <= 0) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Error while reading the size of profil |" - << profilName[typeNo] << "|" )); - - profilSize[typeNo]=pflSize; - profilList[typeNo].resize(pflSize); - profilListFromFile[typeNo].resize(pflSize); - ret = med_2_3::MEDprofileRd(id,profilName[typeNo].c_str(),&profilList[typeNo][0]); // cf item 16 Effective STL // IPAL13481 - profilListFromFile[typeNo] = profilList[typeNo]; - profilNameList[typeNo]= healName(profilName[typeNo]); - } - } - - //delete[] profilName; - - //MESSAGE_MED ("Index : "<< index); - assert(index == totalNumberOfElWg*numberOfComponents); - assert(MED_FIELD_DRIVER<T>::_ptrField->_numberOfValues == mySupport->getNumberOfElements(MED_ALL_ELEMENTS)); - - if (anyProfil) - { - for (int typeNo=0; typeNo < NumberOfTypes; typeNo++) - { - MED_EN::medGeometryElement geomType = types[typeNo]; - - // Trouve l'index du type géométrique dans la liste des types géométriques du maillage - // correspondant au type géométrique du champ traité - vector<MED_EN::medGeometryElement>::iterator meshTypeNoIt = - find(meshGeoType.begin(),meshGeoType.end(),geomType); //Gérer l'exception - if (meshTypeNoIt == meshGeoType.end()) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<": Can't find "<< MED_EN::geoNames[geomType] - << " on entity " << MED_EN::entNames[entityType] - << " in geometric type list of mesh " << meshName)); - int meshTypeNo = meshTypeNoIt - meshGeoType.begin(); - - if (! profilList[typeNo].empty() ) - { - // for (int j =0 ; j< meshGeoType.size();++j) - // cout << "--MeshTypeNo : "<<meshTypeNo<<"-> meshNbOfElOfTypeC["<<j<<"]="<<meshNbOfElOfTypeC[j]<<endl; - // cout << "--typeNo--" << typeNo << endl; - // cout << "meshNbOfElOfTypeC["<<meshTypeNo<<"]=" << meshNbOfElOfTypeC[meshTypeNo] <<endl; - - // Transformer les numéros locaux d'entités medfichier en numéro global medmémoire - for (unsigned i = 0; i < profilList[typeNo].size(); i++) { - // Les numéros des entités commencent à 1 dans MEDfichier comme dans MEDmémoire - // meshNbOfElOfTypeC[0]=0 ...meshNbOfEltOfTypeC[meshTypeNo]= - // meshNbOfElOfTypeC[meshTypeNo-1]+nbrOfElem of meshTypeNo type - // rem1 : Si le meshTypeNo trouvé est 0 (premier type géométrique du maillage - // il ne faut pas décaler les numéros du profils qui commencent à 1 dans MEDFICHIER - // rem2 : meshNbOfElOfTypeC[NumberOfTypes] ne devrait jamais être utilisé - profilList[typeNo][i]+=meshNbOfElOfTypeC[meshTypeNo]; - } - } else { - // Créer le profil <MED_ALL> pour ce type géométrique - // uniquement pour renseigner le tableau skyline avec des accesseurs directs - // par type géométriques - // REM : Une conséquence est qu'à la réecriture le fichier contiendra des - // profils sur certains types géométriques alors qu'à la lecture il n'y en avait pas ! - // Solution : Stocker les noms des profils et les utiliser pour savoir si il y avait ou non - // un profil - int pflSize = meshNbOfElOfType[meshTypeNo]; - // profil = new int[pflSize]; - - profilList[typeNo].resize(pflSize); - profilSize[typeNo] = pflSize; - - for (int j = 1; j <= pflSize; j++) { - profilList[typeNo][j-1] = meshNbOfElOfTypeC[meshTypeNo] + j ; // index MEDMEM commence à 1 - } - profilNameList[typeNo] = MED_NO_PROFILE; //Information a utiliser pour la sauvegarde : PLUTOT MED_ALL - } - profilSizeC += profilList[typeNo].size(); - } - - MEDSKYLINEARRAY * skyLine = new MEDSKYLINEARRAY(profilList.size(), profilSizeC ); - vector<int> index(NumberOfTypes+1,0); - index[0]=1; - for( int typeNo=0; typeNo < NumberOfTypes; typeNo++ ) - index[typeNo+1]=index[typeNo]+profilSize[typeNo]; - skyLine->setIndex(&index[0]); - for (unsigned i=1; i <= profilList.size() ; i++) { - vector<int> aTmp(profilList[i-1].size()); // IPAL13481 - for (unsigned j=0; j < profilList[i-1].size(); j++) - aTmp[j] = (int) profilList[i-1][j]; - skyLine->setI(i,&aTmp[0]); - //skyLine->setI(i,&profilList[i-1][0]); - } - - MEDSKYLINEARRAY * skyLineFromFile = new MEDSKYLINEARRAY(profilListFromFile.size(), profilSizeC ); - skyLineFromFile->setIndex(&index[0]); - for (int i=1; i <= (int)profilListFromFile.size() ; i++) { - vector<int> aTmp(profilListFromFile[i-1].size()); // IPAL13481 - for (unsigned j=0; j < profilListFromFile[i-1].size(); j++) - aTmp[j] = (int) profilListFromFile[i-1][j]; - skyLineFromFile->setI(i,&aTmp[0]); - //skyLineFromFile->setI(i,&profilListFromFile[i-1][0]); - } - - mySupport->setAll(false); - mySupport->setpartial(skyLine,true); - mySupport->setpartial_fromfile(skyLineFromFile,true); - mySupport->setProfilNames(profilNameList); - - // update pointers - NumberOfTypes = mySupport->getNumberOfTypes(); - types = mySupport->getTypes(); - nbOfElOfType = mySupport->getNumberOfElements(); -// cout << "Valeurs du skyline du SUPPORT partiel crée : " << *skyLine << endl; - } - - // Créer un driver spécifique pour les modes MED_FULL_INTERLACE et MED_NO_INTERLACE - // serait plus efficace. - bool anyGauss = (numberOfGaussPoint != vector<int>(numberOfGaussPoint.size(),1)); - SCRUTE_MED(anyGauss); - MEDMEM_Array_ * Values; - if (anyGauss) { - SCRUTE_MED(mySupport->getNumberOfElements(MED_ALL_ELEMENTS) ); - SCRUTE_MED(NumberOfTypes); - SCRUTE_MED(numberOfElementsOfTypeC[NumberOfTypes]-1); - assert(mySupport->getNumberOfElements(MED_ALL_ELEMENTS) == (numberOfElementsOfTypeC[NumberOfTypes]-1) ); - // PAL16681. If NumberOfTypes == 1 then myValues is what should be - // in a field value, inspite of InterlacingType - if ( NumberOfTypes == 1 && modswt == med_2_3::MED_NO_INTERLACE ) - Values = new ArrayNoWg(myValues, - numberOfComponents, - numberOfElementsOfTypeC[NumberOfTypes]-1, - NumberOfTypes, - &numberOfElementsOfTypeC[0], - &numberOfGaussPoint[0], - true,true); - else if ( isNoInterlaceByType ) // PAL17011 (MEDMEM : no_interlace_by_type fields) - Values = new ArrayByTypeWg(myValues, - numberOfComponents, - numberOfElementsOfTypeC[NumberOfTypes]-1, - NumberOfTypes, - &numberOfElementsOfTypeC[0], - &numberOfGaussPoint[0], - true,true); - else - Values = new ArrayFullWg(myValues, - numberOfComponents, - numberOfElementsOfTypeC[NumberOfTypes]-1, - // Up : Prend en compte les profils et - // Ne prend pas en compte le nbre de composantes et - // le nombre de points de Gauss - NumberOfTypes, - &numberOfElementsOfTypeC[0], - &numberOfGaussPoint[0], - true,true); -// cout << "Valeurs du ArrayFullWg crée : " << endl << -// *(static_cast<ArrayFullWg*>(Values)) << endl; - } - else { - // PAL16681. If NumberOfTypes == 1 then myValues is what should be - // in a field value, inspite of InterlacingType - if ( NumberOfTypes == 1 && interlacingType == MED_EN::MED_NO_INTERLACE ) - Values = new ArrayNo(myValues,numberOfComponents,totalNumberOfElWg, - true,true); - else if ( isNoInterlaceByType ) // PAL17011 (MEDMEM : no_interlace_by_type fields) - Values = new ArrayByType(myValues,numberOfComponents,totalNumberOfElWg, - NumberOfTypes, &numberOfElementsOfTypeC[0], true,true); - else - Values = new ArrayFull(myValues,numberOfComponents,totalNumberOfElWg, - true,true); - } - if (MED_FIELD_DRIVER<T>::_ptrField->_value != NULL) - delete MED_FIELD_DRIVER<T>::_ptrField->_value; - - if ( NumberOfTypes != 1 && // PAL16681 - interlacingType == MED_EN::MED_NO_INTERLACE ) - { - // Convert MED_FULL_INTERLACE -> MED_NO_INTERLACE - if (Values->getGaussPresence()) - MED_FIELD_DRIVER<T>::_ptrField->_value=ArrayConvert(*static_cast<ArrayFullWg*>(Values)); - else - MED_FIELD_DRIVER<T>::_ptrField->_value=ArrayConvert(*static_cast<ArrayFull* >(Values)); - delete Values; - } - else - { - MED_FIELD_DRIVER<T>::_ptrField->_value=Values; - } - - MED_FIELD_DRIVER<T>::_ptrField->_isRead = true ; - - const GMESH* aMesh = MED_FIELD_DRIVER<T>::_ptrField->_mesh; - bool isFound = false, onlyMeshProvided = ( !haveSupport && aMesh ); - if ( !aMesh ) - aMesh = ptrMesh; // try to find FAMILY OR GROUP in ptrMesh but without being so stern - if ( aMesh && anyProfil) - { - int it = -1; - for (int typeNo = 0; (typeNo < NumberOfTypes) && (it == -1); typeNo++) { - if (strcmp(profilNameList[typeNo].c_str(), MED_NO_PROFILE) != 0) - it = typeNo; - } - // IMP 0019953: link between fields and families for MED 2.2 read driver - string aPN = profilNameList[it]; - MED_EN::medGeometryElement aPT = types[it]; - - ostringstream typestr; - typestr << "_type" << aPT; - string aSuff = typestr.str(); - - //- If the field profile name is toto_PFL and a family toto exists, - // the field will point to the corresponding FAMILY object. - const vector<FAMILY*> aFams = aMesh->getFamilies(entityType); - for (unsigned fi = 0; fi < aFams.size() && !isFound; fi++) { - FAMILY* aF = aFams[fi]; - string aFN_suff = aF->getName() + aSuff; - if (aPN == aFN_suff) { - isFound = true; - //family found - if(MED_FIELD_DRIVER<T>::_ptrField->_support) - MED_FIELD_DRIVER<T>::_ptrField->_support->removeReference(); - MED_FIELD_DRIVER<T>::_ptrField->_support = aF; //Prévenir l'utilisateur ? - aF->addReference(); - } - } - if (!isFound) { - // - If no family was found, lookup the groups and if a group toto - // exists, the field will point to the corresponding GROUP object. - const vector<GROUP*> aGrps = aMesh->getGroups(entityType); - for (unsigned gi = 0; gi < aGrps.size() && !isFound; gi++) { - GROUP* aG = aGrps[gi]; - string aGN_suff = aG->getName() + aSuff; - if (aPN == aGN_suff) { - isFound = true; - //group found - if(MED_FIELD_DRIVER<T>::_ptrField->_support) - MED_FIELD_DRIVER<T>::_ptrField->_support->removeReference(); - MED_FIELD_DRIVER<T>::_ptrField->_support = aG; //Prévenir l'utilisateur ? - aG->addReference(); - } - } - } - if (!isFound) { - // - If no family or group was found and the - // profile name is xxx_PFL, throw an exception - int pos = aPN.rfind(aSuff); - if (pos + aSuff.length() - 1 == aPN.length() && onlyMeshProvided ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) - << ": Can't find appropriate support (GROUP or FAMILY)" - << " in mesh " << meshName << " for field " << fieldName - << ", while one of its profiles " << aPN - << " was generated from a FAMILY or a GROUP")); - } - else { - // - Check that the found support has correct types - // and number of elements. If not, throw an exception - const SUPPORT* aSupp = MED_FIELD_DRIVER<T>::_ptrField->_support; - isFound = ( aSupp->getNumberOfTypes() == NumberOfTypes ); - if ( !isFound && onlyMeshProvided ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << ": Invalid support (GROUP or FAMILY) found in mesh " - << meshName << " for field " << fieldName << " by name of profile " - << aPN << ": different number of types in found support |" - << aSupp->getNumberOfTypes() << "| and in required |" - << NumberOfTypes << "|")); - - const MED_EN::medGeometryElement* aTypes = aSupp->getTypes(); - for (int it = 0; it < NumberOfTypes && isFound; it++) - { - MED_EN::medGeometryElement aType = aTypes[it]; - isFound = ( aType == types[it] ); - if ( !isFound && onlyMeshProvided ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << ": Invalid support (GROUP or FAMILY) found in mesh " - << meshName << " for field " << fieldName << " by name of profile " - << aPN << ": geometric type in found support |" << aType - << "| differs from required type |" << types[it] << "|")); - - isFound = ( isFound && aSupp->getNumberOfElements(aType) == nbOfElOfType[it] ); - if ( !isFound && onlyMeshProvided ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << ": Invalid support (GROUP or FAMILY) found in mesh " - << meshName << " for field " << fieldName << " by name of profile " - << aPN << ": number of elements of type " << aType - << " in found support |" << aSupp->getNumberOfElements(aType) - << "| differs from required |" << nbOfElOfType[it] << "|")); - } - } - } - - if (!isFound) - { - // No corresponding support (family or group) - // found in the mesh, use the newly created one - const MEDMEM::SUPPORT * & fieldSupport = MED_FIELD_DRIVER<T>::_ptrField->_support; - if ( fieldSupport ) - { - if ( mySupport->getEntity() == fieldSupport->getEntity() && - //not to set "ON_ALL_entity" name to a partial support - mySupport->isOnAllElements() == fieldSupport->isOnAllElements()) - mySupport->setName( fieldSupport->getName() ); - - fieldSupport->removeReference(); - } - fieldSupport = mySupport; //Prévenir l'utilisateur ? - if ( !fieldSupport->getMesh() && aMesh ) - fieldSupport->setMesh( aMesh ); - - // use one support instead of keeping many equal supports - if ( aMesh ) - { - const SUPPORT* supOnAll = aMesh->getSupportOnAll( fieldSupport->getEntity() ); - if ( fieldSupport->deepCompare( *supOnAll )) - MED_FIELD_DRIVER<T>::_ptrField->setSupport( supOnAll ); - } - } - else { - mySupport->removeReference(); - } - END_OF_MED(LOC); -} - -template <class T> void MED_FIELD_RDONLY_DRIVER<T>::write( void ) const - throw (MEDEXCEPTION) -{ - throw MEDEXCEPTION("MED_FIELD_RDONLY_DRIVER::write : Can't write with a RDONLY driver !"); -} - -/*--------------------- WRONLY PART -------------------------------*/ - -/*! - Constructor. -*/ -template <class T> -MED_FIELD_WRONLY_DRIVER<T>::MED_FIELD_WRONLY_DRIVER():MED_FIELD_DRIVER<T>() -{ - this->GENDRIVER::_accessMode = MED_EN::WRONLY; -} - -/*! - Constructor. -*/ -template <class T> -template <class INTERLACING_TAG> -MED_FIELD_WRONLY_DRIVER<T>::MED_FIELD_WRONLY_DRIVER(const string & fileName, - FIELD<T, INTERLACING_TAG> * ptrField): - MED_FIELD_DRIVER<T>(fileName,ptrField,MED_EN::WRONLY) -{ - const char* LOC = "MED_FIELD_WRONLY_DRIVER::MED_FIELD_WRONLY_DRIVER(const string & fileName, const FIELD<T,INTERLACING_TAG> * ptrField)"; - BEGIN_OF_MED(LOC); - END_OF_MED(LOC); -} - -/*! - Copy constructor. -*/ -template <class T> -MED_FIELD_WRONLY_DRIVER<T>::MED_FIELD_WRONLY_DRIVER(const MED_FIELD_WRONLY_DRIVER & fieldDriver): - MED_FIELD_DRIVER<T>(fieldDriver) -{} - -/*! - Destructor. -*/ -template <class T> -MED_FIELD_WRONLY_DRIVER<T>::~MED_FIELD_WRONLY_DRIVER() {} - -template <class T> GENDRIVER * MED_FIELD_WRONLY_DRIVER<T>::copy(void) const -{ - return new MED_FIELD_WRONLY_DRIVER<T>(*this); -} - -template <class T> void MED_FIELD_WRONLY_DRIVER<T>::read (void) - throw (MEDEXCEPTION) -{ - throw MEDEXCEPTION("MED_FIELD_WRONLY_DRIVER::read : Can't read with a WRONLY driver !"); -} - -template <class T> void MED_FIELD_WRONLY_DRIVER<T>::write(void) const - throw (MEDEXCEPTION) -{ - const char * LOC = "MED_FIELD_WRONLY_DRIVER::write(void) const " ; - BEGIN_OF_MED(LOC); - typedef typename MEDMEM_ArrayInterface<T,NoInterlace,NoGauss>::Array ArrayNo; - typedef typename MEDMEM_ArrayInterface<T,NoInterlace,Gauss>::Array ArrayNoWg; - typedef typename MEDMEM_ArrayInterface<T,FullInterlace,NoGauss>::Array ArrayFull; - typedef typename MEDMEM_ArrayInterface<T,FullInterlace,Gauss>::Array ArrayFullWg; - - typedef map<MED_EN::medGeometryElement,GAUSS_LOCALIZATION<FullInterlace>*> locMapFull; - typedef map<MED_EN::medGeometryElement,GAUSS_LOCALIZATION<NoInterlace>*> locMapNo; - typedef map<MED_EN::medGeometryElement,GAUSS_LOCALIZATION_*> locMap; - - med_2_3::med_idt id = MED_FIELD_DRIVER<T>::_medIdt; - - if (MED_FIELD_DRIVER<T>::_status!=MED_OPENED) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": Method open must be called before method write.")) ; - - string fieldName; - if ( ( MED_FIELD_DRIVER<T>::_fieldName.empty() ) && - ( MED_FIELD_DRIVER<T>::_ptrField->_name.empty() ) ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) - <<" neither <fieldName> is set in driver nor in object FIELD.")) ; - - // If _fieldName is not set in driver, try to use _ptrfield->_fieldName - if ( ( MED_FIELD_DRIVER<T>::_fieldName.empty() ) && - ( !MED_FIELD_DRIVER<T>::_ptrField->_name.empty() ) ) - fieldName = healName( MED_FIELD_DRIVER<T>::_ptrField->_name ); - else - fieldName = healName( MED_FIELD_DRIVER<T>::_fieldName ); - - //if ( ! MED_FIELD_DRIVER<T>::_ptrField->_isRead ) - // throw MEDEXCEPTION(LOCALIZED(STRING(LOC) - // <<" FIELD |"<<fieldName<<"| was not read but is being written")); - - SCRUTE_MED(fieldName); - if ( fieldName.size() > MED_NAME_SIZE ) { - fieldName = fieldName.substr(0,MED_NAME_SIZE); - MESSAGE_MED( "Be careful <fieldName> size must not be > MED_NAME_SIZE, using fieldName : |"<< fieldName <<"|." ); - } - - const SUPPORT * mySupport = MED_FIELD_DRIVER<T>::_ptrField->getSupport() ; - if ( ! mySupport ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) - <<" There is no SUPPORT associated with FIELD : " - << fieldName << ".")); - - bool onAll = mySupport->isOnAllElements(); - const locMap & gaussModel = MED_FIELD_DRIVER<T>::_ptrField->_gaussModel; - - - string meshName = healName( mySupport->getMeshName() ); - SCRUTE_MED(meshName); - if ( meshName.size() > MED_NAME_SIZE ) { - meshName = meshName.substr(0,MED_NAME_SIZE); - MESSAGE_MED( "Be careful <meshName> size must not be > MED_NAME_SIZE, using meshName : |"<< meshName <<"|." ); - } - MED_EN::medEntityMesh entityType = mySupport->getEntity(); - - // Reconstruit les listes contigues des noms de composantes et des unités - // Les noms sont tronqués à MED_SNAME_SIZE - int err ; - int component_count=MED_FIELD_DRIVER<T>::_ptrField->getNumberOfComponents(); - string component_name(component_count*MED_SNAME_SIZE,' ') ; - string component_unit(component_count*MED_SNAME_SIZE,' ') ; - - const string * listcomponent_name=MED_FIELD_DRIVER<T>::_ptrField->getComponentsNames() ; - const string * listcomponent_unit=MED_FIELD_DRIVER<T>::_ptrField->getMEDComponentsUnits() ; - if ( ! listcomponent_name || ! listcomponent_unit ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<" Udefined components of FIELD : " - << fieldName << ".")); - int length ; - for (int i=0; i < component_count ; i++) { - length = min(MED_SNAME_SIZE,(int)listcomponent_name[i].size()); - component_name.replace(i*MED_SNAME_SIZE,length, - listcomponent_name[i],0,length); - length = min(MED_SNAME_SIZE,(int)listcomponent_unit[i].size()); - component_unit.replace(i*MED_SNAME_SIZE,length, - listcomponent_unit[i],0,length); - } - - MESSAGE_MED("using component_name=|"<<component_name<<"|"); - MESSAGE_MED("using component_unit=|"<<component_unit<<"|"); - - MED_EN::med_type_champ ValueType=MED_FIELD_DRIVER<T>::_ptrField->getValueType() ; - - MESSAGE_MED("Template Type =|"<<ValueType<<"|"); - - // Vérifier si le champ existe déjà - char champName[MED_NAME_SIZE+1]; - char * compName, * compUnit ; - med_2_3::med_field_type type ; - bool Find = false ; - int n = med_2_3::MEDnField(id); - int nbComp = 0; - for (int i=1; i<=n; i++) { - nbComp = med_2_3::MEDfieldnComponent(id,i); - compName = new char[MED_SNAME_SIZE*nbComp+1]; - compUnit = new char[MED_SNAME_SIZE*nbComp+1]; - med_2_3::med_bool localmesh; - med_2_3::med_int nbstpp3; - char dtunit[MED_LNAME_SIZE+1]; - char mmmp3[MED_NAME_SIZE+1]; - err = med_2_3::MEDfieldInfo(id,i,champName,mmmp3,&localmesh,&type,compName,compUnit,dtunit,&nbstpp3); - if (err == 0) - if (!strcmp(champName,fieldName.c_str()) ) { - Find = true ; - break ; - } - delete[] compName ; - delete[] compUnit ; - } - - if (Find) { - // the same ? - if (nbComp != component_count) - throw MEDEXCEPTION( LOCALIZED (STRING(LOC) - <<": Field exist in file, but number of component are different : " - <<nbComp<<" in file and " - <<component_count<<" in memory." - ) - ); - // component name and unit - SCRUTE_MED(nbComp); - MESSAGE_MED(LOC<<" Component name in file : "<<compName); - MESSAGE_MED(LOC<<" Component name in memory : "<<component_name); - MESSAGE_MED(LOC<<" Component unit in file : "<<compUnit); - MESSAGE_MED(LOC<<" Component unit in memory : "<<component_unit); - delete[] compName ; - delete[] compUnit ; - - } else { - // Verify the field isn't yet created - - string dataGroupName = "/CHA/"; - dataGroupName += fieldName; - MESSAGE_MED(LOC << "|" << dataGroupName << "|" ); - med_2_3::med_idt gid = H5Gopen(id, dataGroupName.c_str() ); - - if ( gid < 0 ) - { // create field - string meshNameWr = meshName; - meshNameWr.resize( MED_NAME_SIZE + 1, '\0' ); // avoid "Invalid read" memory error - err=med_2_3::MEDfieldCr(id,fieldName.c_str(), - (med_2_3::med_field_type)ValueType, - component_count, - component_name.c_str(), - component_unit.c_str(), - "", - meshNameWr.c_str()); - - if ( err < 0 ) - throw MEDEXCEPTION( LOCALIZED (STRING(LOC) - << ": Error MEDchampCr : "<<err - ) - ); - } - else H5Gclose(gid); - } - - - - // On s'assure que le champ est dans le bon type d'entrelacement. - // REM : Il faudrait un driver par type d'entrelacement, ce qui eviterait - // de doubler l'utilisation de la taille mémoire si le champ n'est pas dans - // le bon mode. - FIELD<T,FullInterlace> * myField = 0; - MED_EN::medModeSwitch interlacingType = MED_FIELD_DRIVER<T>::_ptrField->getInterlacingType(); - bool isFullInterlace = ( interlacingType == MED_EN::MED_FULL_INTERLACE ); - bool isNoInterlaceByType = ( interlacingType == MED_EN::MED_NO_INTERLACE_BY_TYPE );//PAL17011 - med_2_3::med_switch_mode modswt = med_2_3::MED_FULL_INTERLACE; - - if ( isFullInterlace ) { - myField = MED_FIELD_DRIVER<T>::_ptrField; - } - else if ( isNoInterlaceByType ) { - // PAL17011, no need to convert, that is what this improvement is needed for - modswt = med_2_3::MED_NO_INTERLACE; - } - else { - myField = FieldConvert( *((FIELD<T,NoInterlace>*) MED_FIELD_DRIVER<T>::_ptrField )); - } - - // Il est necessaire de calculer le tableau - // du nombre d'entités cumulées de chaque type géométrique du maillage - // pour convertir les profils de la numérotation globale - // à la numérotation locale au type géométrique. - // Pour celà on établit ce tableau à partir de l'objet MESH si la relation SUPPORT-MESH existe. - // Si le maillage existe dans le fichier MED on essaye également de reconstituer ce tableau - // pour vérifier la cohérence des informations. - // Si la relation SUPPRT-MESH n'esiste pas on constitue le tableau uniquement à partir du fichier qui - // doit alors obligatoirement contenir le maillage. - const int * number, *numberIndex = 0; - string profilName; - vector<string> profilNameList; - vector<MED_EN::medGeometryElement> meshGeoType; - vector<int> meshNbOfElOfType; - vector<int> meshNbOfElOfTypeC; - vector<MED_EN::medGeometryElement> fileMeshGeoType; - vector<int> fileMeshNbOfElOfType; - vector<int> fileMeshNbOfElOfTypeC; - med_2_3::med_int fileHasMesh=0; - - if (!onAll) { - - number = mySupport->getNumber(MED_ALL_ELEMENTS); - numberIndex = mySupport->getNumberIndex(); - profilNameList=mySupport->getProfilNames(); - // porting MED3 - med_2_3::med_int spceDimp3,mdimp3; - med_2_3::med_mesh_type mtype; - char desccp3[MED_COMMENT_SIZE+1]; - char dttunittp3[MED_LNAME_SIZE+1]; - med_2_3::med_sorting_type sttp3; - med_2_3::med_int nsteppp3; - med_2_3::med_axis_type axxxppp3; - int naxis=med_2_3::MEDmeshnAxisByName(id,meshName.c_str()); - char *annp3=new char[naxis*MED_SNAME_SIZE+1]; - char *auup3=new char[naxis*MED_SNAME_SIZE+1]; - fileHasMesh=(med_2_3::MEDmeshInfoByName(id,meshName.c_str(),&spceDimp3,&mdimp3,&mtype,desccp3,dttunittp3,&sttp3,&nsteppp3,&axxxppp3,annp3,auup3)==0); - delete [] annp3; - delete [] auup3; - // end porting MED3 - const GMESH * meshPtr = mySupport->getMesh(); -// if(!meshPtr) -// throw MEDEXCEPTION( LOCALIZED (STRING(LOC) -// <<": Mesh in support is null" -// ) -// ); - - if (fileHasMesh) - this->getMeshGeometricTypeFromFile(id, meshName, - entityType, - fileMeshGeoType,fileMeshNbOfElOfType,fileMeshNbOfElOfTypeC); - - if (meshPtr) { - this->getMeshGeometricTypeFromMESH( meshPtr, entityType,meshGeoType, - meshNbOfElOfType, - meshNbOfElOfTypeC); - - if (fileHasMesh) - if ( ( fileMeshGeoType != meshGeoType ) || (fileMeshNbOfElOfTypeC != meshNbOfElOfTypeC) ) - throw MEDEXCEPTION(LOCALIZED( STRING(LOC) <<": Error while getting mesh information from file for FIELD "<< fieldName - << " on entity " << MED_EN::entNames[entityType] - << " with (it,or) = (" - << MED_FIELD_DRIVER<T>::_ptrField->_iterationNumber << "," - << MED_FIELD_DRIVER<T>::_ptrField->_orderNumber << ")" - << " on mesh " << meshName - << " : geometric types or number of elements by type differs from MESH object !" - ) - ); - - } - - if ( !fileHasMesh && meshPtr==0 ) - throw MEDEXCEPTION(LOCALIZED( STRING(LOC) <<": Error while getting mesh information for FIELD "<< fieldName - << " on entity " << MED_EN::entNames[entityType] - << " with (it,or) = (" - << MED_FIELD_DRIVER<T>::_ptrField->_iterationNumber << "," - << MED_FIELD_DRIVER<T>::_ptrField->_orderNumber << ")" - << " on mesh " << meshName - << " : SUPPORT must contain a valid MESH reference or file must contain the associated MESH." - ) - ); - - - if (fileHasMesh && !meshPtr) { - meshNbOfElOfTypeC = fileMeshNbOfElOfTypeC; - meshGeoType = fileMeshGeoType; - meshNbOfElOfType = fileMeshNbOfElOfType; - } - } - - const MED_EN::medGeometryElement * types = mySupport->getTypes() ; - int numberOfTypes = mySupport->getNumberOfTypes() ; - int numberOfElForMED = -1; - const T * value = NULL; - int index = 1 ; - - //converting MEDMEM type to MEDfile type - if (entityType != MED_EN::MED_NODE) - entityType = MED_EN::MED_CELL; - - // on boucle sur tout les types pour ecrire les tableaux de valeur - for (int typeNo=0;typeNo<numberOfTypes;typeNo++) { - - int numberOfElements = mySupport->getNumberOfElements(types[typeNo]) ; - //UP : prend en compte les profils, pas les points de Gauss - - //value = MED_FIELD_DRIVER<T>::_ptrField->getRow(index) ; - // rem 1 : le getRow du Array est différent de celui du FIELD si le SUPPORT contient - // des profils (les indices des valeurs ne se suivent pas forcément) - // rem 2 : Afin de respecter la norme MEDFICHIER, les indices contenus dans les - // profils doivent être croissant - if (onAll) { - - if ( isNoInterlaceByType ) { //PAL17011 - value = MED_FIELD_DRIVER<T>::_ptrField->getValueByType(typeNo+1); - //((ArrayNoByType *)MED_FIELD_DRIVER<T>::_ptrField->getArray())->getValueByType(i+1); - } - else { - value = myField->getRow(index); - } - profilName=MED_NO_PROFILE; - numberOfElForMED = numberOfElements; - - } else { - - if ( isNoInterlaceByType ) { //PAL17011 - value = MED_FIELD_DRIVER<T>::_ptrField->getValueByType(typeNo+1); - } - else { - value = myField->getRow(number[index-1]); - } - // PAL16854(Partial support on nodes) -> - //profilName = (profilNameList.size()>typeNo) ? profilNameList[typeNo].substr(0,MED_NAME_SIZE) : MED_NOPFL; - if (profilNameList[typeNo].size()>MED_NAME_SIZE) - profilName = healName( profilNameList[typeNo].substr(0,MED_NAME_SIZE) ); - else - profilName = healName( profilNameList[typeNo] ); - - // Rem : Si le SUPPORT n'est pas onAll mais que pour un type géométrique donné le nom - // du profil associé est MED_NOPFL alors le profil n'est pas écrit dans le fichier MED. - // Car en MEDMEMOIRE si le champ repose sur des éléments de deux types géométriques - // différents et est défini sur tous les éléments d'un type géométrique - // mais pas de l'autre, il existe tout de même des profils sur les deux types géométriques. - // Ce n'est pas le cas en MEDFICHIER. - vector<med_2_3::med_int> profil(&number[index-1],&(number[index-1])+numberOfElements); - - int meshTypeNo=0; - if ( entityType != MED_EN::MED_NODE ) // PAL16854(Partial support on nodes) - { - // Trouve l'index du type géométrique dans la liste des types géométriques du maillage - // correspondant au type géométrique du champ en cours de traitement - vector<MED_EN::medGeometryElement>::iterator meshTypeNoIt = - find(meshGeoType.begin(),meshGeoType.end(),types[typeNo]); - if ( meshTypeNoIt == meshGeoType.end() ) - throw MEDEXCEPTION(LOCALIZED( STRING(LOC) <<": Can't find "<< MED_EN::geoNames[types[typeNo]] - << " on entity " << MED_EN::entNames[entityType] - << " in geometric type list of mesh " << meshName - ) - ); - meshTypeNo = meshTypeNoIt - meshGeoType.begin(); - } - - if ( profilName == MED_NO_PROFILE && (int)profil.size() != meshNbOfElOfType[meshTypeNo] ) - throw MEDEXCEPTION(LOCALIZED( STRING(LOC) <<": Error while creating profil for FIELD "<< fieldName - << " on entity " << MED_EN::entNames[entityType] - << " and geometric type " << MED_EN::geoNames[types[typeNo]] << " with (it,or) = (" - << MED_FIELD_DRIVER<T>::_ptrField->_iterationNumber << "," - << MED_FIELD_DRIVER<T>::_ptrField->_orderNumber << "), with profilName " - << profilName << " on mesh " << meshName - << " : There is no profileName but profilsize (" <<profil.size() - << ") differs from number of elements in associated MESH (" - << meshNbOfElOfType[meshTypeNo] << ")." - ) - ); - - //REM : Ce n'est pas évident, mais lorsqu'il y a un profil, le nombre de valeurs - // que l'on indique à MEDchampEcr est le nombre de valeurs sans profil, d'où - // le nombre d'éléments du maillage sur le type géométrique courant. - numberOfElForMED = meshNbOfElOfType[meshTypeNo]; - - for (int ind=0;ind < numberOfElements;++ind) { -// cout << "number["<<index-1<<"]="<<number[index-1]<<endl; -// cout << "profil1["<<ind<<"]="<<profil[ind]<<endl; - profil[ind]-=meshNbOfElOfTypeC[meshTypeNo]; -// cout << "profil2["<<ind<<"]="<<profil[ind]<<endl; - } - - if ( profil[numberOfElements-1] > numberOfElForMED ) - throw MEDEXCEPTION(LOCALIZED( STRING(LOC) <<": Error while creating profil for FIELD "<< fieldName - << " on entity " << MED_EN::entNames[entityType] - << " and geometric type " << MED_EN::geoNames[types[typeNo]] << " with (it,or) = (" - << MED_FIELD_DRIVER<T>::_ptrField->_iterationNumber << "," - << MED_FIELD_DRIVER<T>::_ptrField->_orderNumber << "), with profilName " - << profilName << " on mesh " << meshName - << " : profil["<<numberOfElements-1<<"]=" << profil[numberOfElements-1] - << " must not be superior to field size without profil : " - << numberOfElForMED - ) - ); - - if ( med_2_3::MEDprofileWr(id,profilName.c_str(),numberOfElements,&profil[0]) < 0) - - throw MEDEXCEPTION(LOCALIZED( STRING(LOC) <<": Error while writing "<< numberOfElements - << " values for MED profil "<< profilName - ) - ); - } - - bool anyGauss = MED_FIELD_DRIVER<T>::_ptrField->getGaussPresence(); - string locName; - if ( anyGauss ) { - // cout << endl << "Nombre de points de Gauss à l'écriture de " << fieldName - // << " pour le type géométrique : " << MED_EN::geoNames[types[typeNo]] - // << " : " << myField->getNumberOfGaussPoints(types[typeNo]) << endl; - // cout << *mySupport << endl; - - const GAUSS_LOCALIZATION_ * locPtr=0; - locMap::const_iterator it; - if ( ( it = gaussModel.find(types[typeNo])) != gaussModel.end() ) - locPtr = (*it).second; - else - throw MEDEXCEPTION(LOCALIZED( STRING(LOC) <<": Error while creating Gauss Model for FIELD "<< fieldName - << " on entity " << MED_EN::entNames[entityType] - << " and geometric type " << MED_EN::geoNames[types[typeNo]] << " with (it,or) = (" - << MED_FIELD_DRIVER<T>::_ptrField->_iterationNumber << "," - << MED_FIELD_DRIVER<T>::_ptrField->_orderNumber << "), with profilName " - << profilName << " on mesh " << meshName - << " : Can't find a Gauss localisation model for this geometric type" - ) - ); - - int ngauss = -1; - int mdim=CELLMODEL_Map::retrieveCellModel(types[typeNo]).getDimension(); - if ( locPtr->getInterlacingType() == MED_EN::MED_FULL_INTERLACE ) { - const GAUSS_LOCALIZATION<FullInterlace> & loc=*(static_cast<const GAUSS_LOCALIZATION<FullInterlace> * >(locPtr)); - ngauss = loc.getNbGauss(); - locName=healName( loc.getName() ); - err=med_2_3::MEDlocalizationWr(id,locName.c_str(), - (med_2_3::med_geometry_type)loc.getType(), - mdim, - loc.getRefCoo().getPtr(), - med_2_3::MED_FULL_INTERLACE, - ngauss, - loc.getGsCoo().getPtr(), - &loc.getWeight()[0], - MED_NO_INTERPOLATION, MED_NO_MESH_SUPPORT); - - } else { - const GAUSS_LOCALIZATION<NoInterlace> & loc=*(static_cast<const GAUSS_LOCALIZATION<NoInterlace> * >(locPtr)); - ngauss = loc.getNbGauss(); - locName=healName( loc.getName() ); - err=med_2_3::MEDlocalizationWr(id,locName.c_str(), - (med_2_3::med_geometry_type)loc.getType(), - mdim, - loc.getRefCoo().getPtr(), - med_2_3::MED_NO_INTERLACE, - ngauss, - loc.getGsCoo().getPtr(), - &loc.getWeight()[0], - MED_NO_INTERPOLATION, - MED_NO_MESH_SUPPORT); - } - - if ( err != 0 ) - throw MEDEXCEPTION(LOCALIZED( STRING(LOC) <<": Error while writing Gauss Model for FIELD "<< fieldName - << " on entity " << MED_EN::entNames[entityType] - << " and geometric type " << MED_EN::geoNames[types[typeNo]] - ) - ); - - //numberOfElForMED *= mySupport->getNumberOfGaussPoints(types[typeNo]); //Deplacer la méthode dans FIELD - //numberOfElForMED *= ngauss; - } - - MESSAGE_MED("MED_FIELD_DRIVER<T>::_medIdt : "<<id); - MESSAGE_MED("meshName.c_str() : "<<meshName.c_str()); - MESSAGE_MED("MED_FIELD_DRIVER<T>::_ptrField->getName() : "<<MED_FIELD_DRIVER<T>::_ptrField->getName()); - MESSAGE_MED("MED_FIELD_DRIVER<T>::_fieldName : "<<MED_FIELD_DRIVER<T>::_fieldName); - MESSAGE_MED("value : "<<value); - MESSAGE_MED("numberOfElements : "<<numberOfElements); - MESSAGE_MED("numberOfElForMED : "<<numberOfElForMED); - MESSAGE_MED("entityType : "<<MED_EN::entNames[entityType]); - MESSAGE_MED("types[i] : "<<MED_EN::geoNames[types[typeNo]]); - if (myField) //myField may be NULL (PAL17011) - MESSAGE_MED("NumberOfGaussPoint[i] : "<<myField->getNumberOfGaussPoints(types[typeNo])); - MESSAGE_MED("MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber() : "<<MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber()); - MESSAGE_MED("MED_FIELD_DRIVER<T>::_ptrField->getTime() : "<<MED_FIELD_DRIVER<T>::_ptrField->getTime()); - MESSAGE_MED("MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber() : "<<MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber()); - - meshName.resize( MED_NAME_SIZE+1, '\0'); // for valgrind reporting "Invalid read of size 1" - - // Rem 1 : le nombre d'éléments passé à MEDchampEcr ne doit pas tenir compte de la taille - // des profils : c'est la taille du champ sans profil. - err=med_2_3::MEDfieldValueWithProfileWr(id,fieldName.c_str(), - MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber(), - MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber(), - MED_FIELD_DRIVER<T>::_ptrField->getTime(), - (med_2_3::med_entity_type)entityType, - (med_2_3::med_geometry_type)types[typeNo], - med_2_3::MED_COMPACT_PFLMODE, - profilName.c_str(), - locName.c_str(), - modswt,MED_ALL_CONSTITUENT, - numberOfElForMED, - (unsigned char*)value); - if (err < MED_VALID ) { - if ( !isFullInterlace ) - delete myField; - throw MEDEXCEPTION(LOCALIZED( STRING(LOC) <<": Error while writing "<< numberOfElements - << " values for FIELD "<< fieldName - << " on entity " << MED_EN::entNames[entityType] - << " and geometric type " << MED_EN::geoNames[types[typeNo]] - << " with (it,or) = (" - << MED_FIELD_DRIVER<T>::_ptrField->_iterationNumber << "," - << MED_FIELD_DRIVER<T>::_ptrField->_orderNumber << "), with profilName " - << profilName << " on mesh " << meshName - ) - ); - } - - index += numberOfElements ; //Ne doit pas prendre en compte le nombre de points de GAUSS - //ni les composantes. - - } - if ( !isFullInterlace ) delete myField; - - - END_OF_MED(LOC); -} - -/*--------------------- RDWR PART -------------------------------*/ - -/*! - Constructor. -*/ -template <class T> -MED_FIELD_RDWR_DRIVER<T>::MED_FIELD_RDWR_DRIVER():MED_FIELD_DRIVER<T>() -{ - this->GENDRIVER::_accessMode = MED_EN::RDWR; -} - -/*! - Constructor. -*/ -template <class T> -template <class INTERLACING_TAG> -MED_FIELD_RDWR_DRIVER<T>::MED_FIELD_RDWR_DRIVER(const string & fileName, - FIELD<T, INTERLACING_TAG> * ptrField): - MED_FIELD_DRIVER<T>(fileName,ptrField,MED_EN::RDWR), - MED_FIELD_RDONLY_DRIVER<T>(fileName,ptrField), - MED_FIELD_WRONLY_DRIVER<T>(fileName,ptrField) -{ - const char* LOC = "MED_FIELD_RDWR_DRIVER::MED_FIELD_RDWR_DRIVER(const string & fileName, const FIELD<T,INTERLACING_TAG> * ptrField)"; - BEGIN_OF_MED(LOC); - //_accessMode = MED_RDWR ; - END_OF_MED(LOC); -} - -/*! - Copy constructor. -*/ -template <class T> -MED_FIELD_RDWR_DRIVER<T>::MED_FIELD_RDWR_DRIVER(const MED_FIELD_RDWR_DRIVER<T> & fieldDriver): - MED_FIELD_DRIVER<T>(fieldDriver), - MED_FIELD_RDONLY_DRIVER<T>(fieldDriver), - MED_FIELD_WRONLY_DRIVER<T>(fieldDriver) -{} - -/*! - Destructor. -*/ -template <class T> -MED_FIELD_RDWR_DRIVER<T>::~MED_FIELD_RDWR_DRIVER() -{ -} - -template <class T> GENDRIVER * MED_FIELD_RDWR_DRIVER<T>::copy(void) const -{ - return new MED_FIELD_RDWR_DRIVER<T>(*this); -} - -template <class T> void MED_FIELD_RDWR_DRIVER<T>::write(void) const - throw (MEDEXCEPTION) -{ - const char* LOC = "MED_FIELD_RDWR_DRIVER::write(void)"; - BEGIN_OF_MED(LOC); - MED_FIELD_WRONLY_DRIVER<T>::write(); - END_OF_MED(LOC); -} - -template <class T> void MED_FIELD_RDWR_DRIVER<T>::read (void) - throw (MEDEXCEPTION) -{ - const char* LOC = "MED_FIELD_RDWR_DRIVER::read(void)"; - BEGIN_OF_MED(LOC); - MED_FIELD_RDONLY_DRIVER<T>::read(); - END_OF_MED(LOC); -} - -} // end namespace MEDMEM - -#endif diff --git a/src/MEDMEM/MEDMEM_MedFileBrowser.cxx b/src/MEDMEM/MEDMEM_MedFileBrowser.cxx deleted file mode 100644 index fc52ce8a0..000000000 --- a/src/MEDMEM/MEDMEM_MedFileBrowser.cxx +++ /dev/null @@ -1,436 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_MedFileBrowser.hxx" - -#include "MEDMEM_Utilities.hxx" -#include "MEDMEM_STRING.hxx" -#include "MEDMEM_DriversDef.hxx" -#include "MEDMEM_MedVersion.hxx" - -#include <set> - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -namespace -{ - /*! - * \brief Structure to open a med file and to close it at destruction - * (especially useful when we throw an exception) - */ - struct MED_FILE - { - med_2_3::med_idt _id; - MED_FILE(const string fileName) - { - _id = med_2_3::MEDfileOpen(fileName.c_str(),med_2_3::MED_ACC_RDONLY); - } - ~MED_FILE() - { - if ( _id > 0 ) - med_2_3::MEDfileClose(_id); - } - operator med_2_3::med_idt() const { return _id; } - }; -} -/*! - -\defgroup MEDFILEBROWSER_constructors Initialization - -\defgroup MEDFILEBROWSER_query Query methods -These methods enable the user to retrieve information -about a MED file structure, i.e. the meshes and fields it contains. - -*/ - -/*! \if MEDMEM_ug -\addtogroup MEDFILEBROWSER_constructors -@{ -\endif -*/ -//================================================================================ -/*! - * \brief Constructor of an empty MEDFILEBROWSER to be filled with \ref readFileStruct() - */ -//================================================================================ - -MEDFILEBROWSER::MEDFILEBROWSER() -{ -} - -//================================================================================ -/*! - * \brief This constructor constructs the MEDFILEBROWSER object from the file \a filename. - * Names of meshes and fields are read. - */ -//================================================================================ - -MEDFILEBROWSER::MEDFILEBROWSER(const std::string & fileName) throw (MED_EXCEPTION) -{ - readFileStruct( fileName ); -} - -//================================================================================ -/*! - * \brief Read names of meshes and fields from the file \a fileName - */ -//================================================================================ - -void MEDFILEBROWSER::readFileStruct(const std::string & fileName) throw (MEDEXCEPTION) -{ - const char * LOC = "MEDFILEBROWSER::readFileStruct() : "; - BEGIN_OF_MED(LOC); - - _fileName = fileName; - _meshes.clear(); - _fields.clear(); - - // ================= - // 1. Open the file - // ================= - - if ( _fileName.empty() ) - throw MED_EXCEPTION - ( LOCALIZED( STRING(LOC) << "_fileName is |\"\"|, please provide a correct fileName")); - - MED_EN::medFileVersion version = getMedFileVersion(_fileName); - if ( version == MED_EN::V21 ) - throw MED_EXCEPTION - ( LOCALIZED( STRING(LOC) << _fileName << " is med-2.1 file which is of no longer supported version")); - - MED_FILE medIdt(_fileName); - - if (medIdt < 0) - throw MED_EXCEPTION - (LOCALIZED( STRING(LOC)<< "Can't open |" << _fileName<< "|, medIdt : " << medIdt)); - - int err,i,j; - - // ========================================= - // 2. Read number of meshes and their names - // ========================================= - { - char meshName[MED_NAME_SIZE+1]=""; - char meshDescription[MED_COMMENT_SIZE+1]=""; - med_2_3::med_int meshDim; - med_2_3::med_mesh_type meshType; - - int numberOfMeshes = med_2_3::MEDnMesh(medIdt) ; - if ( numberOfMeshes <= 0 ) - MESSAGE_MED(LOC << "Be careful there is no mesh in file |"<<_fileName<<"| !"); - - for (i=1;i<=numberOfMeshes;i++) - { - //get information on the i^th mesh - int spaceDim; - int naxis=med_2_3::MEDmeshnAxis(medIdt,i); - med_2_3::med_axis_type axistype; - med_2_3::med_sorting_type stype; - char *axisname=new char[naxis*MED_SNAME_SIZE+1]; - char *axisunit=new char[naxis*MED_SNAME_SIZE+1]; - int nstep; - char dtunit[MED_COMMENT_SIZE+1]; - err = med_2_3::MEDmeshInfo(medIdt, i, meshName, &spaceDim, &meshDim, &meshType, meshDescription, dtunit, &stype, &nstep, &axistype, axisname, axisunit) ; - delete [] axisname; - delete [] axisunit; - if (err != MED_VALID) - throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << ": can't get information about the mesh #" << i << " of the file |" << _fileName << "| !")); - - // Don't want to prevent the user from reading other correct meshes -// if (meshType != med_2_3::MED_STRUCTURE && -// meshType != med_2_3::MED_NON_STRUCTURE ) -// throw MEDEXCEPTION -// (LOCALIZED(STRING(LOC) << "Bad mesh type of mesh #"<<i <<" in file |"<<_fileName<<"|")); - _meshes.insert( make_pair( string(meshName), meshType == med_2_3::MED_STRUCTURED_MESH )); - } - } - - // =================================================================== - // 3. Read number of fields and their (timeStepNumber,iterationNumber) - // =================================================================== - { - // char fieldName[MED_NAME_SIZE+1] = ""; - char fieldName[MED_NAME_SIZE+1] ; // to avoid a crash if the field name is longer than MED_NAME_SIZE.... - char * componentName = (char *) MED_NULL; - char * unitName = (char *) MED_NULL; - char meshName[MED_NAME_SIZE+1] ; - med_2_3::med_field_type type; - MESH_ENTITIES::const_iterator currentEntity; - list<MED_EN::medGeometryElement>::const_iterator currentGeometry; - med_2_3::med_int timeStepNumber = -1; - char timeStepUnit[MED_LNAME_SIZE+1] ; - double timeStep = 0.0; - med_2_3::med_int orderNumber = -1; - med_2_3::med_bool meshLink; - - int numberOfFields = med_2_3::MEDnField(medIdt) ; - - for (i=1;i<=numberOfFields;i++) - { - int numberOfComponents = med_2_3::MEDfieldnComponent(medIdt,i) ; - - componentName = new char[numberOfComponents*MED_SNAME_SIZE+1] ; - unitName = new char[numberOfComponents*MED_SNAME_SIZE+1] ; - int nstepsp3; - err = med_2_3::MEDfieldInfo(medIdt, i, fieldName, meshName, &meshLink, &type, componentName, - unitName, timeStepUnit, &nstepsp3) ; - delete[] componentName ; - delete[] unitName ; - - MESSAGE_MED("Field #" << i << " is named " << fieldName); - - if (err != MED_VALID) - throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << ": can't get information about the field #" << i <<" of the file |" << _fileName << "| !")); - - map< string, FIELD_DATA_ >::iterator name2data = - _fields.insert( make_pair( fieldName, FIELD_DATA_() )).first; - - FIELD_DATA_& fieldData = name2data->second; - fieldData._type = MED_EN::med_type_champ( type ); - - // find all dtid of this field - set<DT_IT_, LT_DT_IT_> set_dtit; - - for (j=1;j <= nstepsp3; j++) - { - err = med_2_3::MEDfieldComputingStepInfo(medIdt, fieldName, j, &timeStepNumber, &orderNumber, &timeStep); - - if (err == MED_VALID) // we have found for (*currentEntity).first and (*currentGeometry) - { - DT_IT_ dtIt; - if (timeStepNumber<0) timeStepNumber=-1 ; - dtIt.dt = timeStepNumber; - dtIt.it = orderNumber; - - set_dtit.insert( dtIt ); - } - } - fieldData._meshName = meshName; - fieldData._vec_dtit.assign( set_dtit.begin(), set_dtit.end() ); - - } // loop on numberOfFields - } - - END_OF_MED(LOC); -} -/*! \if MEDMEM_ug @} \endif */ - -/*! \if MEDMEM_ug -\addtogroup MEDFILEBROWSER_query -@{ -\endif -*/ - -//================================================================================ -/*! - * \brief Returns the name of a browsed file - */ -//================================================================================ - -std::string MEDFILEBROWSER::getFileName() const -{ - return _fileName; -} - -//================================================================================ -/*! - \brief Gets the number of meshes in med file. -*/ -//================================================================================ - -int MEDFILEBROWSER::getNumberOfMeshes ( void ) const -{ - return _meshes.size(); -} - -//================================================================================ -/*! - \brief Gets the number of fields in med file. -*/ -//================================================================================ - -int MEDFILEBROWSER::getNumberOfFields ( void ) const -{ - return _fields.size(); // we get number of field with different name -} - -//================================================================================ -/*! - \brief Gets the names of all meshes. - - meshNames is an in/out argument. - - It is a string array of size the - number of meshes. It must be allocated before calling - this method. All names are put in it. -*/ -//================================================================================ - -void MEDFILEBROWSER::getMeshNames ( std::string * meshNames ) const -{ - map< string, bool >::const_iterator name_isstruct = _meshes.begin(); - for ( int i=0; name_isstruct != _meshes.end(); ++i, ++name_isstruct ) - meshNames[i] = name_isstruct->first; -} - -//================================================================================ -/*! - \brief Gets the names of all MESH objects. - - Returns a vector<string> object which contain the name of all MESH objects. -*/ -//================================================================================ - -vector<string> MEDFILEBROWSER::getMeshNames () const -{ - vector<string> meshNames( _meshes.size() ); - map< string, bool >::const_iterator name_isstruct = _meshes.begin(); - for ( int i=0; name_isstruct != _meshes.end(); ++i, ++name_isstruct ) - meshNames[i] = name_isstruct->first; - return meshNames; -} - -//================================================================================ -/*! - \brief Gets the names of all fields. - - fieldNames is an in/out argument. - - It is an array of string of size the - number of fields. It must be allocated before calling - this method. All names are put in it. -*/ -//================================================================================ - -void MEDFILEBROWSER::getFieldNames ( std::string * fieldNames ) const -{ - map< string, FIELD_DATA_ >::const_iterator name_data = _fields.begin(); - for( int i = 0; name_data != _fields.end(); ++name_data, ++i ) - fieldNames[i] = name_data->first; -} - -//================================================================================ -/*! - \brief Gets the names of all fields. -*/ -//================================================================================ - -vector<string> MEDFILEBROWSER::getFieldNames () const -{ - vector<string> fieldNames( _fields.size() ); - map< string, FIELD_DATA_ >::const_iterator name_data = _fields.begin(); - for( int i = 0; name_data != _fields.end(); ++name_data, ++i ) - fieldNames[i] = name_data->first; - return fieldNames; -} - -//================================================================================ -/*! - * \brief Return true if mesh \a meshName is a structured one - */ -//================================================================================ - -bool MEDFILEBROWSER::isStructuredMesh(const std::string & meshName) const throw (MEDEXCEPTION) -{ - const char* LOC="MEDFILEBROWSER::isStructuredMesh(meshName)"; - - map< std::string, bool >::const_iterator name_isstruct = _meshes.find(meshName); - if ( name_isstruct == _meshes.end() ) - throw MEDEXCEPTION - ( LOCALIZED( STRING(LOC)<< "There is no known mesh named |"<< meshName - << "| in file |" << _fileName <<"|")); - - return name_isstruct->second; -} - -//================================================================================ -/*! - * \brief Return type of values of FIELD named \a fieldName - */ -//================================================================================ - -med_type_champ MEDFILEBROWSER::getFieldType(const std::string & fieldName) const throw (MEDEXCEPTION) -{ - const char* LOC="MEDFILEBROWSER::getFieldIteration (fieldName)"; - - std::map< std::string, FIELD_DATA_ >::const_iterator name_data = _fields.find(fieldName); - - if ( name_data == _fields.end() ) - throw MEDEXCEPTION - ( LOCALIZED( STRING(LOC)<< "There is no known field named |"<< fieldName - << "| in file |" << _fileName <<"|")); - - return name_data->second._type; -} - -//================================================================================ -/*! - * \brief Return name of mesh supporting the FIELD named \a fieldName - */ -//================================================================================ - -std::string MEDFILEBROWSER::getMeshName (const std::string & fieldName) const throw (MEDEXCEPTION) -{ - const char* LOC="MEDFILEBROWSER::getMeshName (fieldName)"; - - std::map< std::string, FIELD_DATA_ >::const_iterator name_data = _fields.find(fieldName); - - if ( name_data == _fields.end() ) - throw MEDEXCEPTION - ( LOCALIZED( STRING(LOC)<< "There is no known field named |"<< fieldName - << "| in file |" << _fileName <<"|")); - - return name_data->second._meshName; -} - -//================================================================================ -/*! - \brief Returns a vector<DT_IT_> which contain all iteration step for the FIELD - identified by its name. - - DT_IT_ definition is -\verbatim -typedef struct { int dt; int it; } DT_IT_; -\endverbatim - -\a dt represents the time iteration number, while \a it represents -the inner iteration number. -*/ -//================================================================================ - -vector<DT_IT_> MEDFILEBROWSER::getFieldIteration (const std::string & fieldName) const - throw (MED_EXCEPTION) -{ - const char* LOC="MEDFILEBROWSER::getFieldIteration (fieldName)"; - - std::map< std::string, FIELD_DATA_ >::const_iterator name_data = _fields.find(fieldName); - - if ( name_data == _fields.end() ) - throw MEDEXCEPTION - ( LOCALIZED( STRING(LOC)<< "There is no known field named |"<< fieldName - << "| in file |" << _fileName <<"|")); - - return name_data->second._vec_dtit; -} -/*!\if MEDMEM_ug @} \endif */ diff --git a/src/MEDMEM/MEDMEM_MedFileBrowser.hxx b/src/MEDMEM/MEDMEM_MedFileBrowser.hxx deleted file mode 100644 index debbe36d8..000000000 --- a/src/MEDMEM/MEDMEM_MedFileBrowser.hxx +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -# ifndef MEDFILEBROWSER_HXX -# define MEDFILEBROWSER_HXX - -#include "MEDMEM.hxx" -#include "MEDMEM_define.hxx" -#include "MEDMEM_Exception.hxx" - -#include <string> -#include <map> -#include <vector> - -namespace MEDMEM { - -typedef struct { int dt; int it; } DT_IT_; //!< { numero du pas de temps, numero d'ordre } -struct MEDMEM_EXPORT LT_DT_IT_ -{ - bool operator() (const DT_IT_ &p1, const DT_IT_ &p2) const - { - if ( p1.dt == p2.dt) - return p1.it < p2.it ; - else - return p1.dt < p2.dt ; - } -}; -typedef std::vector<DT_IT_> VEC_DT_IT_; - -/*! - * \brief Class giving access to names of meshes and fields contained in the med file - */ -class MEDMEM_EXPORT MEDFILEBROWSER -{ - std::string _fileName; - - std::map< std::string, bool > _meshes; //!< mesh name and isStructured flag - - typedef struct - { - MED_EN::med_type_champ _type; - std::string _meshName; - VEC_DT_IT_ _vec_dtit; - } FIELD_DATA_; - - std::map< std::string, FIELD_DATA_ > _fields; //!< field name and its type and "dtit" - -public: - - MEDFILEBROWSER(); - MEDFILEBROWSER (const std::string & fileName) throw (MEDEXCEPTION); - void readFileStruct(const std::string & fileName) throw (MEDEXCEPTION); - - std::string getFileName() const; - - int getNumberOfMeshes ( void ) const; - int getNumberOfFields ( void ) const; - - void getMeshNames ( std::string * meshNames ) const; - void getFieldNames ( std::string * fieldNames ) const; - - std::vector< std::string > getMeshNames () const; - std::vector< std::string > getFieldNames() const; - - bool isStructuredMesh(const std::string & meshName) const throw (MEDEXCEPTION); - - MED_EN::med_type_champ getFieldType (const std::string & fieldName) const throw (MEDEXCEPTION) ; - std::string getMeshName (const std::string & fieldName) const throw (MEDEXCEPTION) ; - VEC_DT_IT_ getFieldIteration (const std::string & fieldName) const throw (MEDEXCEPTION) ; -}; - -} - -#endif diff --git a/src/MEDMEM/MEDMEM_MedMeshDriver.cxx b/src/MEDMEM/MEDMEM_MedMeshDriver.cxx deleted file mode 100644 index 952905439..000000000 --- a/src/MEDMEM/MEDMEM_MedMeshDriver.cxx +++ /dev/null @@ -1,3028 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_GenDriver.hxx" -#include "MEDMEM_DriversDef.hxx" - -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Group.hxx" -#include "MEDMEM_Coordinate.hxx" -#include "MEDMEM_Connectivity.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_CellModel.hxx" -#include "MEDMEM_Grid.hxx" -#include "MEDMEM_MedVersion.hxx" - -using namespace std; -using namespace MED_EN; -using namespace MEDMEM; - -namespace med_2_3 { - extern "C" { - extern med_idt _MEDdatagroupOuvrir(med_idt pid, char *nom); - extern med_err _MEDdatagroupFermer(med_idt id); - } -} - -// Every memory allocation made in the MedDriver members function are desallocated in the Mesh destructor - -MED_MESH_DRIVER::MED_MESH_DRIVER(): - GENDRIVER(MED_DRIVER), - _ptrMesh(( GMESH *)MED_NULL), - _meshName(""), - _medIdt(MED_INVALID) -{ -} - -MED_MESH_DRIVER::MED_MESH_DRIVER(const std::string & fileName, - GMESH * ptrMesh, - MED_EN::med_mode_acces accessMode): - GENDRIVER(fileName, accessMode, MED_DRIVER), - _ptrMesh(ptrMesh), - _meshName(""), - _medIdt(MED_INVALID) -{ -} - -MED_MESH_DRIVER::MED_MESH_DRIVER(const MED_MESH_DRIVER & driver): - GENDRIVER(driver), - _ptrMesh(driver._ptrMesh), - _meshName(driver._meshName), - _medIdt(driver._medIdt) -{ - -} - -MED_MESH_DRIVER::~MED_MESH_DRIVER() -{ - MESSAGE_MED("MED_MESH_DRIVER::~MED_MESH_DRIVER()has been destroyed"); -} - -void MED_MESH_DRIVER::setMeshName(const string & meshName) -{ - _meshName = meshName; -} - -string MED_MESH_DRIVER::getMeshName() const -{ - return _meshName; -} - -void MED_MESH_DRIVER::open() -{ -const char * LOC = "MED_MESH_DRIVER::open()"; - BEGIN_OF_MED(LOC); - - int accessMode = getMedAccessMode( _accessMode ); - MESSAGE_MED(LOC<<" : _fileName.c_str : "<< _fileName.c_str()<<",mode : "<< accessMode); - _medIdt = med_2_3::MEDfileOpen(_fileName.c_str(),(med_2_3::med_access_mode) accessMode); - MESSAGE_MED(LOC<<" _medIdt : "<< _medIdt ); - if (_medIdt > 0) - _status = MED_OPENED; - else { - _medIdt = MED_INVALID; - _status = MED_CLOSED; - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Could not open file "<<_fileName<<" in mode "<<_accessMode)); - } - - END_OF_MED(LOC); -} - -void MED_MESH_DRIVER::close() -{ - const char * LOC = "MED_MESH_DRIVER::close() "; - BEGIN_OF_MED(LOC); - int err = 0; - if ( _status == MED_OPENED) { - - err = med_2_3::MEDfileClose(_medIdt); - // san -- MED5873 : Calling H5close() here leads to failure of SALOMEDS::StudyManager_i::_SaveAs() - // method during study saving process. MEDfermer() seems sufficient for closing a file. - //H5close(); // If we call H5close() all the files are closed. - if (err) - throw MEDEXCEPTION( LOCALIZED(STRING(LOC)<<" Error when closing file ! " << err)); - - MESSAGE_MED(LOC <<": _medIdt= " << _medIdt ); - MESSAGE_MED(LOC<<": MEDfermer : err = " << err ); - _status = MED_CLOSED; - _medIdt = MED_INVALID; - } - END_OF_MED(LOC); -} - -//A FAIRE UTILISER LES MAPS... -const med_2_3::med_geometry_type MED_MESH_DRIVER::all_cell_type[MED_N_CELL_GEO_FIXED_CON]= - { MED_POINT1,MED_SEG2,MED_SEG3,MED_SEG4,MED_TRIA3,MED_QUAD4,MED_TRIA6,MED_TRIA7,MED_QUAD8,MED_QUAD9, - MED_TETRA4,MED_PYRA5,MED_PENTA6,MED_HEXA8,MED_TETRA10,MED_OCTA12,MED_PYRA13, - MED_PENTA15, MED_HEXA20,MED_HEXA27}; - -const char * const MED_MESH_DRIVER::all_cell_type_tab [MED_N_CELL_GEO_FIXED_CON]= - { "MED_POINT1","MED_SEG2","MED_SEG3","MEDMEM_SEG4","MED_TRIA3","MED_QUAD4","MED_TRIA6","MEDMEM_TRIA7","MED_QUAD8","MEDMEM_QUAD9", - "MED_TETRA4","MED_PYRA5","MED_PENTA6","MED_HEXA8","MED_TETRA10","MEDMEM_OCTA12","MED_PYRA13", - "MED_PENTA15","MED_HEXA20","MEDMEM_HEXA27"}; - - -//---------------------------------- RDONLY PART ------------------------------------------------------------- - -MED_MESH_RDONLY_DRIVER::MED_MESH_RDONLY_DRIVER():MED_MESH_DRIVER(),_computeFaces(true) -{ - this->GENDRIVER::_accessMode = MED_EN::RDONLY; -} - -MED_MESH_RDONLY_DRIVER::MED_MESH_RDONLY_DRIVER(const string & fileName, - GMESH * ptrMesh): - MED_MESH_DRIVER(fileName,ptrMesh,RDONLY), - _computeFaces(true) -{ - MESSAGE_MED("MED_MESH_RDONLY_DRIVER::MED_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created"); -} - -MED_MESH_RDONLY_DRIVER::MED_MESH_RDONLY_DRIVER(const MED_MESH_RDONLY_DRIVER & driver): - MED_MESH_DRIVER(driver), - _computeFaces(driver._computeFaces) -{ -} - -MED_MESH_RDONLY_DRIVER::~MED_MESH_RDONLY_DRIVER() -{ - //MESSAGE_MED("MED_MESH_RDONLY_DRIVER::~MED_MESH_RDONLY_DRIVER() has been destroyed"); -} - -GENDRIVER * MED_MESH_RDONLY_DRIVER::copy(void) const -{ - return new MED_MESH_RDONLY_DRIVER(*this); -} - -void MED_MESH_RDONLY_DRIVER::merge ( const GENDRIVER& driver ) -{ - MED_MESH_DRIVER::merge( driver ); - - const MED_MESH_RDONLY_DRIVER* other = - dynamic_cast< const MED_MESH_RDONLY_DRIVER* >( &driver ); - if ( other ) { - _computeFaces = other->_computeFaces; - } -} - -void MED_MESH_RDONLY_DRIVER::write( void ) const -{ - throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER::write : Can't write with a RDONLY driver !"); -} - -void MED_MESH_RDONLY_DRIVER::read(void) -{ - const char * LOC = "MED_MESH_RDONLY_DRIVER::read() : "; - BEGIN_OF_MED(LOC); - if (_status != MED_OPENED) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName - << " is : " << _medIdt << " (the file is not opened).")); - - if ( ( _meshName.empty() ) && ( _ptrMesh->_name.empty() ) ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) - <<" neither <meshName> is set in driver nor in object MESH.")); - - // If _meshName is not set in driver, try to use _ptrMesh->_name - if ( ( _meshName.empty() ) && ( !_ptrMesh->_name.empty() ) ) - _meshName = _ptrMesh->_name; - - if ( _meshName.size() > MED_NAME_SIZE ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) - <<" <meshName> size in object driver MESH is > MED_TAILLE_NOM .")); - - _ptrMesh->_name = _meshName; - - // 0020058: Check version of med, which was used to save the file. - // 0020058: An assertion happens in MEDcoordLire(), if this version - // 0020058: is higher than the currently used version of med product. - med_2_3::med_int aMajor, aMinor, aRelease; - med_2_3::med_int aMajorCurr=3, aMinorCurr=1, aReleaseCurr=0; - - med_err aRet = med_2_3::MEDfileNumVersionRd(_medIdt, &aMajor, &aMinor, &aRelease); - - int aVersionHex = (aMajor << 16 | aMinor << 8 | aRelease); - int aVersionHexCurr = (aMajorCurr << 16 | aMinorCurr << 8 | aReleaseCurr); - - if (aRet != 0 || aVersionHex > aVersionHexCurr) { - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << " cannot read file " << _fileName - << " of version (" << aMajor << "." << aMinor << "." << aRelease - << ") higher than the currently used version of med (" - << aMajorCurr << "." << aMinorCurr << "." << aReleaseCurr << ").")); - } - // 0020058: end of version check - - SCRUTE_MED(_ptrMesh->getIsAGrid()); - - int numberOfMeshes = med_2_3::MEDnMesh(_medIdt); - if ( numberOfMeshes < 1 ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << " no meshes at all in file " << _fileName)); - - // check mesh nature, unstructured or not (PAL14113) - // and set space dimension - { - int naxis=med_2_3::MEDmeshnAxisByName(_medIdt,_meshName.c_str()); - if ( naxis < 0 ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << " no mesh |" << _meshName - << "| in file " << _fileName)); - if ( naxis == 0 ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Mesh |" << _meshName - << "| has invalid space dimension 0.")); - - med_2_3::med_int spaceDimension,meshDimension; - med_2_3::med_mesh_type meshType; - char commentp3[MED_COMMENT_SIZE+1]; - char dtunittp3[MED_LNAME_SIZE+1]; - med_2_3::med_sorting_type sttp3; - int nstep; - med_2_3::med_axis_type axtypp3; - naxis = std::max(3, naxis); // safe enough? - char *t1pp3=new char[naxis*MED_SNAME_SIZE+1]; - char *t2pp3=new char[naxis*MED_SNAME_SIZE+1]; - med_2_3::MEDmeshInfoByName(_medIdt,_meshName.c_str(),&spaceDimension,&meshDimension,&meshType,commentp3,dtunittp3,&sttp3,&nstep,&axtypp3,t1pp3,t2pp3); - delete [] t1pp3; - delete [] t2pp3; - - if ((meshType == med_2_3::MED_STRUCTURED_MESH ) != _ptrMesh->getIsAGrid()) - { - if ( _ptrMesh->getIsAGrid() ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Mesh type mismatch. " - "Class MESH must be used for an unstructured mesh")); - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Mesh type mismatch. " - "Class GRID must be used for a structured mesh")); - } - if ( meshDimension > spaceDimension ) - spaceDimension = meshDimension; - - if ( spaceDimension < 1 ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The space dimension |" << spaceDimension - << "| seems to be incorrect for the mesh : |" << _meshName << "|")); - _ptrMesh->_spaceDimension = spaceDimension; - - } - - if (_ptrMesh->getIsAGrid()) - { - getGRID(); - { - if (getFAMILY() != MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getFAMILY when the mesh is a grid")); - buildAllGroups(_ptrMesh->_groupNode, _ptrMesh->_familyNode); - } - END_OF_MED(LOC); - return; - } - - if (getCOORDINATE() != MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getCOORDINATE" )); - - if (getCONNECTIVITY() != MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getCOONECTIVITY")); - - if (getFAMILY() != MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getFAMILY" )); - - if (_computeFaces) - updateFamily(); - - // we build all groups - // on node - buildAllGroups(_ptrMesh->_groupNode,_ptrMesh->_familyNode); - // on cell - buildAllGroups(_ptrMesh->_groupCell,_ptrMesh->_familyCell); - - if (_ptrMesh->getMeshDimension() == 3) - // on face - buildAllGroups(_ptrMesh->_groupFace,_ptrMesh->_familyFace); -// else if (_ptrMesh->getMeshDimension() == 2) -- PAL13414 - if (_ptrMesh->getMeshDimension() > 1) - // on edge - buildAllGroups(_ptrMesh->_groupEdge,_ptrMesh->_familyEdge); - - _ptrMesh->_name = healName( _ptrMesh->_name ); - - END_OF_MED(LOC); -} - -//======================================================================= -//function : getGRID -//purpose : -//======================================================================= - -void MED_MESH_RDONLY_DRIVER::getGRID() -{ - const char * LOC = "MED_MESH_RDONLY_DRIVER::getGRID() : "; - BEGIN_OF_MED(LOC); - - if (_status!=MED_OPENED) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "med file is not opened")); - - GRID * ptrGrid = (GRID *) _ptrMesh; - - SCRUTE_MED(ptrGrid); - - int err, i; - - int numberOfMeshesInFile = med_2_3::MEDnMesh(_medIdt); - - if (numberOfMeshesInFile == MED_INVALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Problem in File where the mesh " << _meshName << " is supposed to be stored")); - int MeshDimension; - int SpaceDimensionRead; - string tmp_nom_coord (MED_SNAME_SIZE*(_ptrMesh->_spaceDimension)+1,' '); - string tmp_unit_coord(MED_SNAME_SIZE*(_ptrMesh->_spaceDimension)+1,' '); - char * tmp_nom = (const_cast <char *> ( tmp_nom_coord.c_str()) ); - char * tmp_unit= (const_cast <char *> ( tmp_unit_coord.c_str()) ); - med_2_3::med_axis_type rep; - med_2_3::med_int dtp3,itp3; - med_2_3::med_float ttpp3; - for (int index = 0; index < numberOfMeshesInFile; index++) - { - char meshName[MED_NAME_SIZE+1]=""; - char meshDescription[MED_COMMENT_SIZE+1]=""; - med_2_3::med_int meshDim; - med_2_3::med_mesh_type meshType; - med_2_3::med_int spaceDimp3; - char dtunittp3[MED_LNAME_SIZE+1]; - med_2_3::med_sorting_type stypp3; - med_2_3::med_int nstepp3; - int naxis=med_2_3::MEDmeshnAxis(_medIdt,(index+1)); - char *axisnamep3=new char[naxis*MED_SNAME_SIZE+1]; - char *axisunitp3=new char[naxis*MED_SNAME_SIZE+1]; - med_2_3::med_axis_type axtpp3; - err = med_2_3::MEDmeshInfo(_medIdt,(index+1),meshName, &spaceDimp3, &meshDim,&meshType, meshDescription, dtunittp3,&stypp3,&nstepp3,&axtpp3,axisnamep3,axisunitp3); - MESSAGE_MED(LOC<<": Mesh n°"<< (index+1) <<" nammed "<< meshName << " with the description " << meshDescription << " is structured"); - if (_meshName == string(meshName)) - { - _ptrMesh->_description = meshDescription; - _ptrMesh->_name = meshName; - MeshDimension=meshDim; - SpaceDimensionRead=spaceDimp3; - rep=axtpp3; - strncpy(tmp_nom,axisnamep3,naxis*_ptrMesh->_spaceDimension+1); - strncpy(tmp_unit,axisunitp3,naxis*_ptrMesh->_spaceDimension+1); - med_2_3::MEDmeshComputationStepInfo(_medIdt,meshName,1,&dtp3,&itp3,&ttpp3); - } - delete [] axisnamep3; - delete [] axisunitp3; - } - - MED_EN::med_grid_type gridType = ptrGrid->getGridType(); - if ( ptrGrid->_is_default_gridType ) - { - med_2_3::med_grid_type type; - MEDmeshGridTypeRd(_medIdt,_ptrMesh->_name.c_str(),&type); - gridType = ptrGrid->_gridType = (MED_EN::med_grid_type) type; - ptrGrid->_is_default_gridType = false; - } - - MESSAGE_MED(LOC<<": Mesh processed is nammed "<< _ptrMesh->_name << " with the description " << _ptrMesh->_description << " is structured with the type " << gridType); - - - if (MeshDimension == MED_INVALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The mesh dimension |" << - MeshDimension << "| seems to be incorrect " << - "for the mesh : |" << _meshName << "|")); - - // Read or get the dimension of the space for the mesh <_meshName> - int SpaceDimension = MeshDimension; - - if (SpaceDimensionRead != MED_INVALID) SpaceDimension = SpaceDimensionRead; - - _ptrMesh->_spaceDimension = SpaceDimension; - - - // Read Array length - int * ArrayLen[] = { & ptrGrid->_iArrayLength, - & ptrGrid->_jArrayLength, - & ptrGrid->_kArrayLength }; - - MESSAGE_MED(LOC << "The mesh is a " << _ptrMesh->getMeshDimension() << "D mesh on a " << _ptrMesh->_spaceDimension << "D space"); - - int NumberOfNodes; - - // if (gridType == MED_EN::MED_GRILLE_STANDARD) - if (gridType == MED_EN::MED_BODY_FITTED) - { - med_2_3::med_int * structure = new med_2_3::med_int[MeshDimension]; - - err = med_2_3::MEDmeshGridStructRd(_medIdt,_ptrMesh->_name.c_str(),dtp3,itp3,structure); - - if (err != MED_VALID) - throw MEDEXCEPTION(STRING(LOC) <<"Error in reading the structure of grid : |" << _meshName << "|" ); - - NumberOfNodes = 1; - - for (int idim = 0; idim < MeshDimension; idim++) - { - MESSAGE_MED(LOC<<"structure dim " << idim << " " << structure[idim]); - - ArrayLen [idim][0] = structure[idim]; - NumberOfNodes = NumberOfNodes*structure[idim]; - } - - delete [] structure; - - if ( NumberOfNodes == MED_INVALID ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The number of nodes |" << - NumberOfNodes << - "| seems to be incorrect " - << "for the mesh : |" << - _meshName << "|" )); - - // create coordinates and its structure - ptrGrid->_coordinate = new COORDINATE(SpaceDimension,NumberOfNodes, - MED_EN::MED_FULL_INTERLACE); - - err = med_2_3::MEDmeshNodeCoordinateRd(_medIdt,_ptrMesh->_name.c_str(),dtp3,itp3,med_2_3::MED_FULL_INTERLACE,const_cast<double *>(ptrGrid->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE))); - - if (err != MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't read coordinates of the |" << - NumberOfNodes << "| nodes for the mesh : |" << - _meshName << "| of space dimension |" << - SpaceDimension << "| with units names |" << - tmp_nom << "| and units |" << - tmp_unit << " |")); - - } - else if ((gridType == MED_EN::MED_CARTESIAN) || - (gridType == MED_EN::MED_POLAR)) - { - NumberOfNodes = 1; - - double * Array[] = { (double*) 0, (double*) 0, (double*) 0 }; - - for (int idim = 0; idim < _ptrMesh->getMeshDimension(); ++idim) - { - med_2_3::med_data_type table; - if (idim == 0) table = med_2_3::MED_COORDINATE_AXIS1; - else if (idim == 1) table = med_2_3::MED_COORDINATE_AXIS2; - else if (idim == 2) table = med_2_3::MED_COORDINATE_AXIS3; - - med_2_3::med_bool chgtpp3,trsfpp3; - int length = med_2_3::MEDmeshnEntity(_medIdt,_ptrMesh->_name.c_str(),dtp3,itp3,med_2_3::MED_NODE,MED_NONE,table,med_2_3::MED_NO_CMODE,&chgtpp3,&trsfpp3); - - if ( length <= MED_VALID ) - throw MEDEXCEPTION(STRING(LOC) <<"The number of nodes |" << length << - "| seems to be incorrect " - << "for the mesh : |" << _meshName << "|" ); - - ArrayLen [idim][0] = length; - NumberOfNodes *= length; - - Array [idim] = new double [ length ]; - - err = med_2_3::MEDmeshGridIndexCoordinateRd(_medIdt,_ptrMesh->_name.c_str(),dtp3,itp3,idim+1,Array [idim]); - - if (err != MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Error in reading coordinates indices " << - idim << "of the grid : |" << - _meshName << "|" )); - } - - ptrGrid->_iArray = Array[0]; - ptrGrid->_jArray = Array[1]; - ptrGrid->_kArray = Array[2]; - - // create coordinates - ptrGrid->_coordinate = new COORDINATE(SpaceDimension,NumberOfNodes, - MED_EN::MED_FULL_INTERLACE); - - if (gridType == MED_EN::MED_CARTESIAN) - rep = med_2_3::MED_CARTESIAN; - else if (gridType == MED_EN::MED_POLAR) - { - if (SpaceDimension == 2) rep = med_2_3::MED_CYLINDRICAL; - else if (SpaceDimension == 3) rep = med_2_3::MED_SPHERICAL; - } - } - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<" bad grid type : " << gridType)); - - // set coordinate names - - for (i=0; i<_ptrMesh->_spaceDimension; ++i ) - { - string myStringName(tmp_nom_coord,i*MED_SNAME_SIZE,MED_SNAME_SIZE); - string myStringUnit(tmp_unit_coord,i*MED_SNAME_SIZE,MED_SNAME_SIZE); - // suppress space at the end - int j; - for(j=MED_SNAME_SIZE-1;j>=0;j--) - if (myStringName[j] != ' ') break; - ptrGrid->_coordinate->_coordinateName[i]=string(myStringName,0,j+1); - for(j=MED_SNAME_SIZE-1;j>=0;j--) - if (myStringUnit[j] != ' ') break; - ptrGrid->_coordinate->_coordinateUnit[i]=string(myStringUnit,0,j+1); - } - - string coordinateSystem = "UNDEFINED"; - - if( rep == med_2_3::MED_CARTESIAN) coordinateSystem = "CARTESIAN"; - else if ( rep == med_2_3::MED_CYLINDRICAL) coordinateSystem = "CYLINDRICAL"; - else if ( rep == med_2_3::MED_SPHERICAL) coordinateSystem = "SPHERICAL"; - - ptrGrid->_coordinate->setCoordinatesSystem(coordinateSystem); - - END_OF_MED(LOC); -} - -//======================================================================= -//function : getCOORDINATE -// A FAIRE : RENVOYER DU VOID -//======================================================================= -int MED_MESH_RDONLY_DRIVER::getCOORDINATE() -{ - const char * LOC = "MED_MESH_RDONLY_DRIVER::getCOORDINATE() : "; - - BEGIN_OF_MED(LOC); - - if (_status==MED_OPENED) - { - int err; - int MeshDimension; - int SpaceDimensionRead; - med_2_3::med_mesh_type meshTypepp3; - char meshDescription[MED_COMMENT_SIZE+1]=""; - char dtunit[MED_LNAME_SIZE+1]; - med_2_3::med_sorting_type sortTypepp3; - int nstepp3; - med_2_3::med_axis_type axtypepp3; - // - string tmp_nom_coord (MED_SNAME_SIZE*_ptrMesh->_spaceDimension+1,'\0'); - string tmp_unit_coord(MED_SNAME_SIZE*_ptrMesh->_spaceDimension+1,'\0'); - char * tmp_nom = (const_cast <char *> ( tmp_nom_coord.c_str()) ); - char * tmp_unit= (const_cast <char *> ( tmp_unit_coord.c_str()) ); - // - err=med_2_3::MEDmeshInfoByName(_medIdt,_meshName.c_str(), - &SpaceDimensionRead,&MeshDimension, - &meshTypepp3,meshDescription, - dtunit,&sortTypepp3,&nstepp3, - &axtypepp3,tmp_nom,tmp_unit); - int dtp3,itp3; - med_2_3::med_float ttpp3; - med_2_3::MEDmeshComputationStepInfo(_medIdt,_meshName.c_str(),1,&dtp3,&itp3,&ttpp3); - - MESH* ptrMesh = dynamic_cast<MESH*>(_ptrMesh); - - // Read the number of nodes used in the mesh <_meshName> - // to be able to create a COORDINATE object - med_2_3::med_bool chgtpp3,trsfpp3; - int NumberOfNodes = med_2_3::MEDmeshnEntity(_medIdt,_meshName.c_str(), - dtp3,itp3,med_2_3::MED_NODE,MED_NONE, - med_2_3::MED_COORDINATE, - med_2_3::MED_NO_CMODE, - &chgtpp3,&trsfpp3); - if ( NumberOfNodes <= MED_VALID ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The number of nodes |" << NumberOfNodes - << "| seems to be incorrect for the mesh : |" << _meshName << "|" )); - ptrMesh->_numberOfNodes = NumberOfNodes; - - // create a COORDINATE object - if (ptrMesh->_coordinate) - delete ptrMesh->_coordinate; - ptrMesh->_coordinate = new COORDINATE(ptrMesh->_spaceDimension, NumberOfNodes, MED_EN::MED_FULL_INTERLACE); - - med_2_3::med_axis_type rep=axtypepp3; // ATTENTION ---> DOIT ETRE INTEGRE DS MESH EF: FAIT NON? - - err=MEDmeshNodeCoordinateRd(_medIdt,_ptrMesh->_name.c_str(),dtp3,itp3,med_2_3::MED_FULL_INTERLACE,const_cast<double *>(ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE))); - - if (err != MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't read coordinates of the |" << NumberOfNodes - << "| nodes for the mesh : |" << _meshName - << "| of space dimension |" << ptrMesh->_spaceDimension - << "| with units names |" << tmp_nom - << "| and units |" << tmp_unit - << " |")); - - for (int i=0;i<_ptrMesh->_spaceDimension;i++) { - string myStringName(tmp_nom_coord,i*MED_SNAME_SIZE,MED_SNAME_SIZE); - string myStringUnit(tmp_unit_coord,i*MED_SNAME_SIZE,MED_SNAME_SIZE); - // suppress space at the end - int j; - for(j=MED_SNAME_SIZE-1;j>=0;j--) - if (myStringName[j] != ' ') break; - ptrMesh->_coordinate->_coordinateName[i]=string(myStringName,0,j+1); - for(j=MED_SNAME_SIZE-1;j>=0;j--) - if (myStringUnit[j] != ' ') break; - ptrMesh->_coordinate->_coordinateUnit[i]=string(myStringUnit,0,j+1); - } - - // Pourquoi le stocker sous forme de chaîne ? - switch (rep) - { - case med_2_3::MED_CARTESIAN : - { - ptrMesh->_coordinate->_coordinateSystem = "CARTESIAN"; - break; - } - case med_2_3::MED_CYLINDRICAL : - { - ptrMesh->_coordinate->_coordinateSystem = "CYLINDRICAL"; - break; - } - case med_2_3::MED_SPHERICAL : - { - ptrMesh->_coordinate->_coordinateSystem = "SPHERICAL"; - break; - } - default : - { - ptrMesh->_coordinate->_coordinateSystem = "UNDEFINED"; // ?Erreur ? - break; - } - } - - // Read the unused optional node Names - if(MEDmeshnEntity(_medIdt,_ptrMesh->_name.c_str(),dtp3,itp3,med_2_3::MED_NODE,MED_NONE,med_2_3::MED_NAME,med_2_3::MED_NO_CMODE,&chgtpp3,&trsfpp3)>0) - MESSAGE_MED(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : WARNING : Nodes have names but we do not read them !"); - - // ??? Read the unused optional node Numbers ??? - med_2_3::med_int * tmp_node_number = new med_2_3::med_int[NumberOfNodes]; - if(MEDmeshnEntity(_medIdt,_ptrMesh->_name.c_str(),dtp3,itp3,med_2_3::MED_NODE,MED_NONE,med_2_3::MED_NUMBER,med_2_3::MED_NO_CMODE,&chgtpp3,&trsfpp3)>0) - { - err=MEDmeshEntityNumberRd(_medIdt,_ptrMesh->_name.c_str(),dtp3,itp3,med_2_3::MED_NODE,MED_NONE,tmp_node_number); - - MESSAGE_MED(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : Nodes have numbers, we DO TAKE care of them !"); - ptrMesh->_coordinate->_nodeNumber.set(NumberOfNodes); -#if defined(IRIX64) || defined(OSF1) || defined(VPP5000) || defined(PCLINUX64) - for(med_2_3::med_int i2=0;i2<NumberOfNodes;i2++) - ptrMesh->_coordinate->_nodeNumber[i2]=(int)(tmp_node_number[i2]); -#else - memcpy((int*)ptrMesh->_coordinate->_nodeNumber,tmp_node_number,sizeof(int)*NumberOfNodes); -#endif - - ////////////////////////////////////////////////////////////////////////////////////// - /// Modification pour prise en compte de la numérotation optionnelle des noeuds /// - ////////////////////////////////////////////////////////////////////////////////////// - /// - /// Calcule _optionnalToCanonicNodesNumbers de telle sorte que _optionnalToCanonicNodesNumbers[OptionnalNumber]==CanonicNumber - - // ptrMesh->_arePresentOptionnalNodesNumbers=1; - // for (int canonicNumber=1;canonicNumber<=NumberOfNodes;canonicNumber++) ptrMesh->_optionnalToCanonicNodesNumbers[tmp_node_number[canonicNumber-1]]=canonicNumber; - // ICI RETOUR A LA NORMALE::: AUCUNE PRISE EN COMPTE D'UN NUMEROTATION OPTIONNEL - ptrMesh->_arePresentOptionnalNodesNumbers=0; - } - else ptrMesh->_arePresentOptionnalNodesNumbers=0; - - ////////////////////////////////////////////////////////////////////////////////////// - - delete[] tmp_node_number; - - END_OF_MED(LOC); - return MED_VALID; - } - return MED_ERROR; -} - - -int MED_MESH_RDONLY_DRIVER::getCONNECTIVITY() -{ - const char * LOC = "MED_MESH_RDONLY_DRIVER::getCONNECTIVITY : "; - BEGIN_OF_MED(LOC); - - if (_status==MED_OPENED) - { - - int err = 0; - // read MED_CELL connectivity - CONNECTIVITY * Connectivity = new CONNECTIVITY(MED_CELL); - Connectivity->_numberOfNodes = _ptrMesh->getNumberOfNodes(); // EF : Pourquoi cet attribut est-il dans MESH et non dans COORDINATE ? - - // Try to read nodal connectivity of the cells <Connectivity->_nodal> - // then try to read descending connectivity <Connectivity->_descending> - // if neither nodal nor descending connectivity exists - // throw an exception. - err = getNodalConnectivity(Connectivity); - if (err!=MED_VALID) - { - Connectivity->_typeConnectivity = MED_DESCENDING; - err = getDescendingConnectivity(Connectivity); - } - else - getDescendingConnectivity(Connectivity); // we read it if there is one - - if (err!=MED_VALID) - { - delete Connectivity; - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "We could not read " << - "any Connectivity")); - } - - // commented since _ptrMesh->getMeshDimension() is based on connectivity - // which is not yet set -// if (Connectivity->_entityDimension != _ptrMesh->getMeshDimension()) -// MESSAGE_MED(LOC << "Small mesh dimension problem on the med file mounted in memory : diim stored " << _ptrMesh->getMeshDimension() << " dim computed using the connectivity " << Connectivity->_entityDimension); - - // At this point Connectivity->_typeConnectivity is either NODAL or DESCENDING - // If both connectivities are found Connectivity->_typeConnectivity is NODAL - // If space dimension is 3 - // try to read the nodal connectivity of the faces <ConnectivityFace->_nodal> then - // try to read the descending connectivity <ConnectivityFace->_descending> - // if there is no descending connectivity and the CELLS are - // defined in descending mode then throw an exception - - // PROVISOIRE : if we have some face or edge in MED_MAILLE, we don't read more. There could not be have face or edge !!!! - - if(Connectivity->_constituent==NULL) { - - if (Connectivity->_entityDimension == 3) { - MESSAGE_MED(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DES FACES..." ); - CONNECTIVITY * ConnectivityFace = new CONNECTIVITY(MED_EN::MED_FACE); - ConnectivityFace->_numberOfNodes = _ptrMesh->getNumberOfNodes(); - ConnectivityFace->_typeConnectivity = Connectivity->_typeConnectivity; // NODAL or DESCENDING - SCRUTE_MED(ConnectivityFace->_typeConnectivity); - if (Connectivity->_typeConnectivity == MED_DESCENDING) { - MESSAGE_MED(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DESCENDANTE DES FACES" ); - err = getDescendingConnectivity(ConnectivityFace); - if (err!=MED_VALID) - throw MEDEXCEPTION ( LOCALIZED(STRING(LOC) << "No FACE in descending connectivity")); - getNodalConnectivity(ConnectivityFace); // if any ! - } else { - MESSAGE_MED(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE NODALE DES FACES" ); - err = getNodalConnectivity(ConnectivityFace); - if (err!=MED_VALID) { // or error ????? we are in NODAL mode. - err = getDescendingConnectivity(ConnectivityFace); - } else - getDescendingConnectivity(ConnectivityFace); // if any ! - } - if (err!=MED_VALID) { - delete ConnectivityFace; - MESSAGE_MED(LOC<<"No FACE defined."); - } else { - MESSAGE_MED(LOC<<" SAUVEGARDE DE LA CONNECTIVITE DES FACES DANS L'OBJET CONNECTIVITY" ); - delete Connectivity->_constituent; - Connectivity->_constituent=ConnectivityFace; - } - } - - // read MED_EDGE connectivity - if (Connectivity->_entityDimension > 1) { // we are in 3 or 2D - MESSAGE_MED(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DES ARRETES...." ); - CONNECTIVITY * ConnectivityEdge = new CONNECTIVITY(MED_EDGE); - ConnectivityEdge->_numberOfNodes = _ptrMesh->getNumberOfNodes(); - ConnectivityEdge->_typeConnectivity = Connectivity->_typeConnectivity; - if (Connectivity->_typeConnectivity == MED_DESCENDING) { - MESSAGE_MED(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DESCENDANTE DES ARRETES" ); - err = getDescendingConnectivity(ConnectivityEdge); - if (err!=MED_VALID) - throw MEDEXCEPTION ( LOCALIZED(STRING(LOC) << "No EDGE in descending connectivity")); - getNodalConnectivity(ConnectivityEdge); // if any ! - } else { - MESSAGE_MED(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE NODALE DES ARRETES" ); - err = getNodalConnectivity(ConnectivityEdge); - if (err!=MED_VALID) { // or error ????? we are in NODAL mode. - err = getDescendingConnectivity(ConnectivityEdge); - } else - getDescendingConnectivity(ConnectivityEdge); // if any ! - } - if (err!=MED_VALID) { - delete ConnectivityEdge; - MESSAGE_MED(LOC<<"No EDGE defined."); - } else { - if (Connectivity->_entityDimension == 3) - if (Connectivity->_constituent != NULL) - Connectivity->_constituent->_constituent=ConnectivityEdge; - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< "EDGE defined but there are no FACE !")); - else { // IN 2D - MESSAGE_MED(LOC<<" SAUVEGARDE DE LA CONNECTIVITE DES ARETES DANS L'OBJET CONNECTIVITY" ); - Connectivity->_constituent=ConnectivityEdge; - } - } - } - } - MESH* ptrMesh = dynamic_cast<MESH*>(_ptrMesh); - if (ptrMesh->_connectivity) - delete ptrMesh->_connectivity; - ptrMesh->_connectivity = Connectivity; - - - END_OF_MED(LOC); - return MED_VALID; - } - return MED_ERROR; -} - -int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity) -{ - const char * LOC = "MED_MESH_RDONLY_DRIVER::getNodalConnectivity : "; - BEGIN_OF_MED(LOC); - med_2_3::med_bool chgtp3,trfp3; - med_2_3::med_err err; - - if (_status==MED_OPENED) - { - int dtp3,itp3; - med_2_3::med_float ttpp3; - med_2_3::MEDmeshComputationStepInfo(_medIdt,_meshName.c_str(),1,&dtp3,&itp3,&ttpp3); - // Get the type of entity to work on (previously set in the Connectivity Object) - med_2_3::med_entity_type Entity = (med_2_3::med_entity_type) Connectivity->getEntity(); - - // Get the number of cells of each type & store it in <tmp_cells_count>. - vector<int> tmp_cells_count; - vector<CELLMODEL> tmp_cell_models; // models of present types - int i; - const list<MED_EN::medGeometryElement>& all_cell_type = meshEntities[ Connectivity->getEntity() ]; - list<MED_EN::medGeometryElement>::const_iterator type_iter; - for ( type_iter = all_cell_type.begin(); type_iter != all_cell_type.end(); ++type_iter ) - { - int nb_cells; - if ( med_2_3::med_geometry_type(*type_iter) != MED_POLYGON && - med_2_3::med_geometry_type(*type_iter) != MED_POLYHEDRON ) - nb_cells=med_2_3::MEDmeshnEntity(_medIdt,_ptrMesh->_name.c_str(), - dtp3,itp3, - med_2_3::MED_CELL, - med_2_3::med_geometry_type(*type_iter), - med_2_3::MED_CONNECTIVITY,med_2_3::MED_NODAL, - &chgtp3,&trfp3); - else if ( med_2_3::med_geometry_type(*type_iter) == MED_POLYGON ) - nb_cells=med_2_3::MEDmeshnEntity(_medIdt,_ptrMesh->_name.c_str(), - dtp3,itp3, - med_2_3::MED_CELL, - MED_POLYGON, - med_2_3::MED_INDEX_NODE, - med_2_3::MED_NODAL, - &chgtp3,&trfp3) - 1; - else - nb_cells=med_2_3::MEDmeshnEntity(_medIdt,_ptrMesh->_name.c_str(), - dtp3,itp3, - med_2_3::MED_CELL, - MED_POLYHEDRON, - med_2_3::MED_INDEX_FACE, - med_2_3::MED_NODAL, - &chgtp3,&trfp3)-1; - /*med_2_3::MED_CONN,Entity, - med_2_3::med_geometry_type(*type_iter),med_2_3::MED_NOD);*/ - - // Get the greatest dimension of the cells : Connectivity->_entityDimension - // We suppose there is no cells used as faces in MED 2.2.x , this is forbidden !!! - // In version prior to 2.2.x, it is possible - if (nb_cells>0) - { - tmp_cells_count.push_back(nb_cells); - tmp_cell_models.push_back( CELLMODEL_Map::retrieveCellModel( *type_iter )); - Connectivity->_entityDimension=tmp_cell_models.back().getDimension(); - Connectivity->_numberOfTypes++; - } - } - - if (Connectivity->_numberOfTypes > 0) - { - // if MED version < 2.2.x, we read only entity with - // dimention = Connectivity->_entityDimension. Lesser dimension are face or edge ! - - med_2_3::med_int major, minor, release; - - if ( med_2_3::MEDfileNumVersionRd(_medIdt, &major, &minor, &release) != 0 ) - // error : we suppose we have not a good med file ! - return MED_ERROR; - - // we get MED version number - // If MED version is < 2.2 then the cells which dimension - // is lesser than the main dimension ( Connectivity->_entityDimension ) - // are either faces or edges - - vector<int> tmpEdgeCount, tmpFaceCount; - vector<MED_EN::medGeometryElement> edgeTypes, faceTypes; - if (Entity==med_2_3::MED_CELL) - { - Connectivity->_numberOfTypes=0; - - for ( i=0;i<int(tmp_cell_models.size());i++) - { - int dimension = tmp_cell_models[i].getDimension(); - if (Connectivity->_entityDimension == dimension) - Connectivity->_numberOfTypes++; - if (Connectivity->_entityDimension > dimension) - { - if (dimension == 2 ) - { - faceTypes.push_back( tmp_cell_models[i].getType() ); - tmpFaceCount.push_back( tmp_cells_count[i] ); - tmp_cells_count[i] = 0; - } - else if (dimension == 1 ) - { - edgeTypes.push_back( tmp_cell_models[i].getType() ); - tmpEdgeCount.push_back( tmp_cells_count[i] ); - tmp_cells_count[i] = 0; - } - else if (dimension == 0 ) - { - tmp_cells_count[i] = 0; - } - } - } - } - - // Retrieve connectivity size of poly elements - med_2_3::med_int polygonConnSize, polyhedraFacesIndexSize, polyhedraConnSize; - int polyhedraConnSizeWithFaceSeparators; - if ( tmp_cell_models.back().getType() == MED_EN::MED_POLYGON || - (!faceTypes.empty() && faceTypes.back() == MED_EN::MED_POLYGON )) - { - polygonConnSize = med_2_3::MEDmeshnEntity(_medIdt,_ptrMesh->_name.c_str(), - dtp3,itp3, - med_2_3::MED_CELL, - MED_POLYGON, - med_2_3::MED_CONNECTIVITY, - med_2_3::MED_NODAL, - &chgtp3,&trfp3); - } - if ( tmp_cell_models.back().getType() == MED_EN::MED_POLYHEDRA ) - { - polyhedraFacesIndexSize=MEDmeshnEntity(_medIdt,_ptrMesh->_name.c_str(), - dtp3,itp3, - med_2_3::MED_CELL, - MED_POLYHEDRON, - med_2_3::MED_INDEX_NODE, - med_2_3::MED_NODAL, - &chgtp3,&trfp3); - polyhedraConnSize=MEDmeshnEntity(_medIdt,_ptrMesh->_name.c_str(), - dtp3,itp3, - med_2_3::MED_CELL, - MED_POLYHEDRON, - med_2_3::MED_CONNECTIVITY, - med_2_3::MED_NODAL, - &chgtp3,&trfp3); - - int nbPolyherda = tmp_cells_count.back(); - int nbFaces = polyhedraFacesIndexSize - 1; - // connectivity of each but last face of each polyhedron ends with -1 - polyhedraConnSizeWithFaceSeparators = polyhedraConnSize + nbFaces - nbPolyherda; - } - - // bloc to read CELL : - { - // Prepare an array of indexes on the different cell types to create a MEDSKYLINEARRAY - // We use <tmp_cells_count> to calculate <Connectivity->_count> then we release it - Connectivity->_geometricTypes = new MED_EN::medGeometryElement [Connectivity->_numberOfTypes]; // Double emploi pour des raisons pratiques - Connectivity->_type = new CELLMODEL [Connectivity->_numberOfTypes]; // - if(Connectivity->_count) delete [] Connectivity->_count; - Connectivity->_count = new int [Connectivity->_numberOfTypes+1]; - Connectivity->_count[0] = 1; - - int size = 0; - int typeNumber=1; - vector<int> connSizeByType; - for ( i=0; i < (int)tmp_cells_count.size(); i++) - { // no point1 cell type (?) - if ( !tmp_cells_count[i] ) continue; // faces or edges - - Connectivity->_count[typeNumber]=Connectivity->_count[typeNumber-1]+tmp_cells_count[i]; - - Connectivity->_type[typeNumber-1] = tmp_cell_models[i]; - - Connectivity->_geometricTypes[typeNumber-1] = tmp_cell_models[i].getType(); - - // probleme avec les mailles de dimension < a dimension du maillage : - // Il faut oter le zero a la lecture est le remettre a l'ecriture : ce n'est pas fait !!!!! - // On interdit ce cas pour l'instant !!! - - switch (tmp_cell_models[i].getType() ) - { - case MED_EN::MED_POLYGON: - connSizeByType.push_back( polygonConnSize ); break; - case MED_EN::MED_POLYHEDRA: - connSizeByType.push_back( polyhedraConnSizeWithFaceSeparators ); break; - default: - connSizeByType.push_back - (tmp_cells_count[i] * tmp_cell_models[i].getNumberOfNodes() ); - } - size += connSizeByType.back(); - typeNumber++; - MESSAGE_MED(LOC << Connectivity->_count[typeNumber-1]-1 << " cells of type " - << tmp_cell_models[i].getName() ); - } - - // Creation of the MEDSKYLINEARRAY - PointerOf <int> NodalValue(size); - PointerOf <int> NodalIndex(Connectivity->_count[Connectivity->_numberOfTypes]); - NodalIndex[0]=1; - - // Fill the MEDSKYLINEARRAY by reading the MED file. - int j=0; - for ( i=0;i<Connectivity->_numberOfTypes;i++) - { - int tmp_numberOfCells = Connectivity->_count[i+1]-Connectivity->_count[i]; - PointerOf< med_2_3::med_int > tmp_ConnectivityArray( connSizeByType[i] ); - - switch ( Connectivity->_geometricTypes[i] ) - { - case MED_EN::MED_POLYGON: - { - PointerOf <med_2_3::med_int> PolygonsConnIndex( tmp_numberOfCells+1 ); - err = med_2_3::MEDmeshPolygonRd(_medIdt,_ptrMesh->_name.c_str(), - dtp3,itp3, - med_2_3::MED_CELL, - med_2_3::MED_NODAL, - PolygonsConnIndex, - tmp_ConnectivityArray); - if (err != MED_VALID) - { - MESSAGE_MED(LOC<<": MEDpolygoneConnLire returns "<<err); - return MED_ERROR; - } - int* polyindex = (int*)NodalIndex + Connectivity->_count[i] - 1; - int delta = polyindex[0] - PolygonsConnIndex[0]; - for ( j=0; j<=tmp_numberOfCells; j++) - polyindex[j]= delta + PolygonsConnIndex[ j ]; - break; - } - case MED_EN::MED_POLYHEDRA: - { - PointerOf< med_2_3::med_int> FacesIndex( polyhedraFacesIndexSize ); - PointerOf< med_2_3::med_int> PolyhedronIndex( tmp_numberOfCells+1 ); - err = med_2_3::MEDmeshPolyhedronRd(_medIdt,_ptrMesh->_name.c_str(), - dtp3,itp3, - med_2_3::MED_CELL, - med_2_3::MED_NODAL, - PolyhedronIndex, - FacesIndex, - tmp_ConnectivityArray); - if (err != MED_VALID) - { - MESSAGE_MED(LOC<<": MEDpolyedreConnLire returns "<<err); - return MED_ERROR; - } - // insert face separators - int* polyindex = NodalIndex + Connectivity->_count[i] - 1; - int k = NodalIndex[ Connectivity->_count[i]-1 ] - 1; - for ( j=0; j<tmp_numberOfCells; j++) - { - int k0 = k; - for ( int iface = PolyhedronIndex[j]; iface < PolyhedronIndex[j+1]; ++iface) - { - for ( int inode = FacesIndex[iface-1]; inode < FacesIndex[iface]; ++inode) - NodalValue[k++] = tmp_ConnectivityArray[inode-1]; - if ( iface+1 < PolyhedronIndex[j+1] ) - NodalValue[k++] = -1; - } - polyindex[j+1] = polyindex[j] + k - k0; - } - continue; // no need to copy tmp_ConnectivityArray - already done - //break; - } - default: - err = med_2_3::MEDmeshElementConnectivityRd(_medIdt,_ptrMesh->_name.c_str(), - dtp3,itp3, - med_2_3::MED_CELL, - med_2_3::med_geometry_type(Connectivity->_geometricTypes[i]), - med_2_3::MED_NODAL, - med_2_3::MED_FULL_INTERLACE, - tmp_ConnectivityArray - ); - if ( err != MED_VALID) - { - MESSAGE_MED(LOC<<": MEDconnLire returns "<<err); - return MED_ERROR; - } - int NumberOfNodeByCell = Connectivity->_type[i].getNumberOfNodes(); - // initialise index - for ( j=Connectivity->_count[i]; j<Connectivity->_count[i+1];j++) - NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByCell; - } - - // version originale sans prise en compte des numeros optionnels - // - int * ConnectivityArray = NodalValue + NodalIndex[Connectivity->_count[i]-1]-1; - for ( j=0; j<connSizeByType[i]; j++) - ConnectivityArray[j] = tmp_ConnectivityArray[j]; - - ////////////////////////////////////////////////////////////////////////////// - // Modification pour prise en compte de la numerotation optionnelle des noeuds /// - ////////////////////////////////////////////////////////////////////////////// - // - // Renumerote le tableau temporaire tmp_ConnectivityArray - // en utilisant _optionnalToCanonicNodesNumbers - // Le traitement est identique a la version originelle - // s'il n'y a pas de numerotation optionnelle - // - //if (_ptrMesh->_arePresentOptionnalNodesNumbers==1) - //{ - // for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++) - // ConnectivityArray[j*NumberOfNodeByCell+k] = _ptrMesh-> - // _optionnalToCanonicNodesNumbers[tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k]]; - //} - //else - //{ - // for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++) - // ConnectivityArray[j*NumberOfNodeByCell+k] = - // tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k]; - //} - //////////////////////////////////////////////////////////////////////////// - - } - - Connectivity->_nodal = new MEDSKYLINEARRAY(Connectivity->_count[Connectivity->_numberOfTypes]-1, - size, - NodalIndex, - NodalValue); - - } // end of bloc to read CELL - - // Get Face if any - // =============== - if (!faceTypes.empty()) - { - // Create a CONNECTIVITY constituent to put in the top level CONNECTIVITY recursive class - CONNECTIVITY * constituent = new CONNECTIVITY(faceTypes.size(),MED_EN::MED_FACE); - constituent->_numberOfNodes = _ptrMesh->getNumberOfNodes(); - constituent->_entityDimension = 2; - constituent->_count[0]=1; - - // In order to create the MEDSKYLINEARRAY of the constituent object we need : - // 1: - // To initialize the _count array of the constituent object - // (containning cumulated face count by geometric type) - // _count[0]=1 and _count[_numberOfTypes] give the size of NodalIndex - // 2: - // To calculate the total number of face nodes whatever the geometric type is. - // The result is the size of the array containning all the nodes : NodalValue - // 3 : - // To calculate the starting indexes of the different face types in NodalValue, - // this is the NodalIndex array. - - int size = 0; - vector<int> connSizeByType; - for ( i=0; i < (int)faceTypes.size(); i++) - { - constituent->_count[i+1] = constituent->_count[i] + tmpFaceCount[i]; - constituent->_type[i] = CELLMODEL_Map::retrieveCellModel( faceTypes[i] ); - constituent->_geometricTypes[i] = faceTypes[i]; - - if ( faceTypes[i] == MED_EN::MED_POLYGON ) - connSizeByType.push_back( polygonConnSize ); - else - connSizeByType.push_back( tmpFaceCount[i] * constituent->_type[i].getNumberOfNodes()); - size += connSizeByType.back(); - } - - // Creation of the MEDSKYLINEARRAY - PointerOf<int> NodalValue (size); - PointerOf<int> NodalIndex (constituent->_count[constituent->_numberOfTypes]); - NodalIndex[0]=1; - - // Fill the MEDSKYLINEARRAY by reading the MED file. - for ( i=0; i<constituent->_numberOfTypes; i++) - { - int NumberOfNodeByFace = constituent->_type[i].getNumberOfNodes(); - - // Il faut ajouter 1 pour le zero a la lecture !!! - // ATTENTION UNIQUEMENT POUR MED < 2.2.x - PointerOf< med_2_3::med_int> tmp_constituentArray; - - MESSAGE_MED(LOC << "Med file version used here " << major << " " << minor << " " << release); - - if ((major == 2) && (minor <= 1)) - tmp_constituentArray.set( connSizeByType[i] + tmpFaceCount[i] ); - else if ((major == 2) && (minor >= 2)) - { - tmp_constituentArray.set( connSizeByType[i] ); - MESSAGE_MED(LOC<<": WE ARE USING MED2.2 so there is no +1 for calculating the size of tmp_constituentArray !"); - } - else - tmp_constituentArray.set( connSizeByType[i] ); - - if ( constituent->_geometricTypes[i] == MED_EN::MED_POLYGON ) - { - PointerOf< med_2_3::med_int> PolygonsConnIndex( tmpFaceCount[i]+1 ); - err = med_2_3::MEDmeshPolygonRd(_medIdt,_ptrMesh->_name.c_str(), - dtp3,itp3, - med_2_3::MED_CELL, - med_2_3::MED_NODAL, - PolygonsConnIndex, - tmp_constituentArray); - - if (err != MED_VALID) - { - MESSAGE_MED(LOC<<": MEDpolygoneConnLire returns "<<err); - delete constituent; - return MED_ERROR; - } - int* polyindex = (int*)NodalIndex + constituent->_count[i] - 1; - int delta = polyindex[0] - PolygonsConnIndex[0]; - for ( int j=0; j<=tmpFaceCount[i]; j++) - polyindex[j]= delta + PolygonsConnIndex[ j ]; - } - else - { - med_2_3::med_geometry_type med_type = - (med_2_3::med_geometry_type) constituent->_type[i].getType(); - err = med_2_3::MEDmeshElementConnectivityRd(_medIdt,_ptrMesh->_name.c_str(), - dtp3,itp3, - med_2_3::MED_CELL, - med_type, - med_2_3::MED_NODAL, - med_2_3::MED_FULL_INTERLACE, - tmp_constituentArray - ); - if ( err != MED_VALID) - { - MESSAGE_MED(LOC<<": MEDconnLire returns "<<err); - delete constituent; - return MED_ERROR; - } - // initialise NodalIndex - for (int j=constituent->_count[i]; j<constituent->_count[i+1];j++) - NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByFace; - } - - int tmp_numberOfFaces = constituent->_count[i+1]-constituent->_count[i]; - - int * constituentArray = NodalValue + NodalIndex[constituent->_count[i]-1]-1; - - MESSAGE_MED(LOC << "Med file version used here " << major << " " << minor << " " << release); - if ((major == 2) && (minor <= 1)) - for (int j=0; j<tmp_numberOfFaces; j++) - for (int k=0; k<NumberOfNodeByFace; k++) - constituentArray[j*NumberOfNodeByFace+k]=tmp_constituentArray[j*(NumberOfNodeByFace+1)+k]; - else if (((major == 2) && (minor >= 2)) || (major > 2)) - for ( int j = 0; j < connSizeByType[i]; ++j ) - constituentArray[j]=tmp_constituentArray[j]; - } - - constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1, - size, - NodalIndex, - NodalValue); - Connectivity->_constituent = constituent; - } - - // get Edge if any - // =============== - if ( !edgeTypes.empty() ) - { - CONNECTIVITY * constituent = new CONNECTIVITY(tmpEdgeCount.size() ,MED_EDGE); - constituent->_numberOfNodes = _ptrMesh->getNumberOfNodes(); - constituent->_entityDimension = 1; - constituent->_count[0]=1; - - int size = 0; - for ( i=0; i<(int)edgeTypes.size(); i++) - { - constituent->_count[i+1]=constituent->_count[i]+tmpEdgeCount[i]; - constituent->_type[i]=CELLMODEL_Map::retrieveCellModel( edgeTypes[i] ); - constituent->_geometricTypes[i] = edgeTypes[i]; - - size+=tmpEdgeCount[i]*constituent->_type[i].getNumberOfNodes(); - } - - // Creation of the MEDSKYLINEARRAY - PointerOf< int > NodalValue( size ); - PointerOf< int > NodalIndex( constituent->_count[constituent->_numberOfTypes] ); - NodalIndex[0]=1; - - // Fill the MEDSKYLINEARRAY by reading the MED file. - for ( i=0; i<constituent->_numberOfTypes; i++) - { - med_2_3::med_geometry_type med_type = - (med_2_3::med_geometry_type) constituent->_type[i].getType(); - int NumberOfNodeByEdge = constituent->_type[i].getNumberOfNodes(); - - // initialise index - for (int j=constituent->_count[i]; j<constituent->_count[i+1];j++) - NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByEdge; - - int tmp_numberOfEdges = constituent->_count[i+1]-constituent->_count[i]; - // Il faut ajouter 1 pour le zero a la lecture !!! - - // ATTENTION UNIQUEMENT POUR MED < 2.2.x - med_2_3::med_int * tmp_constituentArray = NULL; - - MESSAGE_MED(LOC << "Med file version used here " << major << " " << minor << " " << release); - - if ((major == 2) && (minor <= 1)) - tmp_constituentArray = new med_2_3::med_int[(NumberOfNodeByEdge+1)*tmp_numberOfEdges]; - else if ((major == 2 && minor >= 2) || ( major > 2 )) - { - tmp_constituentArray = new med_2_3::med_int[NumberOfNodeByEdge*tmp_numberOfEdges]; - MESSAGE_MED(LOC<<": WE ARE USING MED2.2 so there is no +1 for calculating the size of tmp_constituentArray !"); - } - - err = med_2_3::MEDmeshElementConnectivityRd(_medIdt,_ptrMesh->_name.c_str(), - dtp3,itp3, - med_2_3::MED_CELL, - med_type, - med_2_3::MED_NODAL, - med_2_3::MED_FULL_INTERLACE, - tmp_constituentArray - ); - if ( err != MED_VALID) - { - MESSAGE_MED(LOC<<": MEDconnLire returns "<<err); - delete constituent; - delete[] tmp_constituentArray; - return MED_ERROR; - } - - int * constituentArray = NodalValue + NodalIndex[constituent->_count[i]-1]-1; - - // version originale sans prise en compte des numéros optionnels - // - int multi = 0; // quand est-ce que multi vaut 1 ?? en MED-fichier < 2.2 ?? - MESSAGE_MED(LOC << "Med file version used here " << major << " " << minor << " " << release); - - if ((major == 2) && (minor <= 1)) - for (int j=0; j<tmp_numberOfEdges; j++) - for (int k=0; k<NumberOfNodeByEdge; k++) - constituentArray[j*NumberOfNodeByEdge+k] = - tmp_constituentArray[j*(NumberOfNodeByEdge+multi)+k]; - else if ((major == 2 && minor >= 2) || (major > 2)) - for (int j=0; j<tmp_numberOfEdges; j++) - for (int k=0; k<NumberOfNodeByEdge; k++) - constituentArray[j*NumberOfNodeByEdge+k] = tmp_constituentArray[j*(NumberOfNodeByEdge)+k]; - - ////////////////////////////////////////////////////////////////////////////////////// - /// Modification pour prise en compte de la numérotation optionnelle des noeuds /// - ////////////////////////////////////////////////////////////////////////////////////// - /// - /// Rénumérote le tableau temporaire tmp_constituentArray en utilisant - /// _optionnalToCanonicNodesNumbers - /// Le traitement est identique à la version originelle - /// s'il n'y a pas de numérotation optionnelle - // - //if (_ptrMesh->_arePresentOptionnalNodesNumbers) - //{ - // for (int j=0; j<tmp_numberOfEdges; j++) for (int k=0; k<NumberOfNodeByEdge; k++) - // constituentArray[j*NumberOfNodeByEdge+k] = _ptrMesh-> - // _optionnalToCanonicNodesNumbers[tmp_constituentArray[j*(NumberOfNodeByEdge+1)+k]]; - //} - //else - //{ - // for (int j=0; j<tmp_numberOfEdges; j++) for (int k=0; k<NumberOfNodeByEdge; k++) - // constituentArray[j*NumberOfNodeByEdge+k]=tmp_constituentArray[j*(NumberOfNodeByEdge+1)+k]; - //} - ////////////////////////////////////////////////////////////////////////////////////// - - delete[] tmp_constituentArray; - } - - constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1, - size, - NodalIndex, - NodalValue); - - if (Connectivity->_entityDimension == 3) - { - if (Connectivity->_constituent==NULL) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Edges are defined but there are no Faces !")); - Connectivity->_constituent->_constituent = constituent; - } else - Connectivity->_constituent = constituent; - } - - } - - // If there is no nodal connectivity, we return MED_ERROR ! - if (Connectivity->_numberOfTypes == 0) - return MED_ERROR; - else - return MED_VALID; - } - return MED_ERROR; -} - -int MED_MESH_RDONLY_DRIVER::getFAMILY() -{ - const char * LOC = "MED_MESH_RDONLY_DRIVER::getFAMILY() : "; - BEGIN_OF_MED(LOC); - - if (_status==MED_OPENED) - { - int err = 0; - - int * MEDArrayNodeFamily = NULL; - int ** MEDArrayCellFamily = NULL; - int ** MEDArrayFaceFamily = NULL; - int ** MEDArrayEdgeFamily = NULL; - - // NODE : - MEDArrayNodeFamily = new int[_ptrMesh->getNumberOfNodes()]; - - err = getNodesFamiliesNumber(MEDArrayNodeFamily); - // error only if (_status!=MED_OPENED), other case exeception ! - // CELL - - MESSAGE_MED(LOC << "error returned from getNodesFamiliesNumber " << err); - - MEDArrayCellFamily = new int* [_ptrMesh->getNumberOfTypes(MED_CELL)]; - // ET SI IL N'Y A PAS DE CELLS ? - - const medGeometryElement * myTypes = _ptrMesh->getTypes(MED_CELL); - for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_CELL);i++) - MEDArrayCellFamily[i] = new - int[_ptrMesh->getNumberOfElements(MED_CELL,myTypes[i])]; - - err = getCellsFamiliesNumber(MEDArrayCellFamily,MED_CELL); - MESSAGE_MED(LOC << "error returned from getCellsFamiliesNumber for Cells " << err); - - if (_ptrMesh->getNumberOfElements( MED_EN::MED_FACE, MED_EN::MED_ALL_ELEMENTS )) - { - // FACE - MEDArrayFaceFamily = new int* [_ptrMesh->getNumberOfTypes(MED_FACE)]; - - myTypes = _ptrMesh->getTypes(MED_FACE); - for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_FACE);i++) - MEDArrayFaceFamily[i] = new int[ _ptrMesh->getNumberOfElements( MED_FACE,myTypes[i])]; - - err = getCellsFamiliesNumber(MEDArrayFaceFamily,MED_FACE); - MESSAGE_MED(LOC << "error returned from getCellsFamiliesNumber for Faces " << err); - } - if (_ptrMesh->getNumberOfElements( MED_EN::MED_EDGE, MED_EN::MED_ALL_ELEMENTS)) - { - // EDGE in 3D or 2D - MEDArrayEdgeFamily = new int* [_ptrMesh->getNumberOfTypes(MED_EDGE)]; - - const medGeometryElement *myTypes2 = _ptrMesh->getTypes(MED_EDGE); - for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++) - MEDArrayEdgeFamily[i] = new - int[_ptrMesh->getNumberOfElements(MED_EDGE,myTypes2[i])]; - - err = getCellsFamiliesNumber(MEDArrayEdgeFamily,MED_EDGE); - - MESSAGE_MED(LOC << "error returned from getCellsFamiliesNumber for Edges " << err); - } - - int NumberOfFamilies = med_2_3::MEDnFamily(_medIdt,_meshName.c_str()); - - if ( NumberOfFamilies < 1 ) // at least family 0 must exist - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"There is no FAMILY, FAMILY 0 must exists" )); - - SCRUTE_MED(NumberOfFamilies); - - vector<FAMILY*> &NodeFamilyVector = _ptrMesh->_familyNode; - vector<FAMILY*> &CellFamilyVector = _ptrMesh->_familyCell; - vector<FAMILY*> &FaceFamilyVector = _ptrMesh->_familyFace; - vector<FAMILY*> &EdgeFamilyVector = _ptrMesh->_familyEdge; - - int numberOfNodesFamilies = 0; - int numberOfCellsFamilies = 0; - int numberOfFacesFamilies = 0; - int numberOfEdgesFamilies = 0; - - - for (int i=0;i<NumberOfFamilies;i++) - { -#if defined(IRIX64) || defined(OSF1) || defined(VPP5000) || defined(PCLINUX64) - med_2_3::med_int tmp_NumberOfAttributes = med_2_3::MEDnFamily23Attribute(_medIdt,_meshName.c_str(),i+1); - med_2_3::med_int NumberOfAttributes = tmp_NumberOfAttributes; -#else - int NumberOfAttributes = med_2_3::MEDnFamily23Attribute(_medIdt,_meshName.c_str(),(i+1)); -#endif - - if (NumberOfAttributes < 0) - throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER::getFAMILY() : NumberOfAttributes" ); - -#if defined(IRIX64) || defined(OSF1) || defined(VPP5000) || defined(PCLINUX64) - med_2_3::med_int tmp_NumberOfGroups = med_2_3::MEDnFamilyGroup(_medIdt,_meshName.c_str(),i+1); - int NumberOfGroups = tmp_NumberOfGroups; -#else - int NumberOfGroups = med_2_3::MEDnFamilyGroup(_medIdt,_meshName.c_str(),i+1); -#endif - - if (NumberOfGroups < 0) - throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER::getFAMILY() : NumberOfGroups" ); - - int FamilyIdentifier; - string FamilyName(MED_NAME_SIZE,'\0'); - // 0020071: Crash of V4_1_4rc2 (of testMedMemGeneral.py) - // Pb with Mistrat_import22.med: it's zero family has non-empty AttributesIdentifier's and - // AttributesValues' but MEDnAttribut() returns 0 (0 is hardcoded for zero family). - // So we allocate nothing but MEDfamInfo() reads file contents so overwritting - // stranger's memory. Stupid solution: allocate more than MEDnAttribut() - const int iSafe = 10; - int * AttributesIdentifier = new int[NumberOfAttributes+iSafe]; - int * AttributesValues = new int[NumberOfAttributes+iSafe]; - string AttributesDescription(MED_COMMENT_SIZE*(NumberOfAttributes+iSafe),' '); - string GroupsNames(MED_LNAME_SIZE*NumberOfGroups+1,'\0'); -#if defined(IRIX64) || defined(OSF1) || defined(VPP5000) || defined(PCLINUX64) - med_2_3::med_int tmp_FamilyIdentifier; - med_2_3::med_int * tmp_AttributesIdentifier = new med_2_3::med_int[NumberOfAttributes+iSafe]; - med_2_3::med_int * tmp_AttributesValues = new med_2_3::med_int[NumberOfAttributes+iSafe]; - - err=med_2_3::MEDfamily23Info(_medIdt,_meshName.c_str(),i+1,const_cast <char *>(FamilyName.c_str()), - tmp_AttributesIdentifier,tmp_AttributesValues,const_cast <char *>(AttributesDescription.c_str()),&tmp_FamilyIdentifier,const_cast <char *>(GroupsNames.c_str())); - - FamilyIdentifier = tmp_FamilyIdentifier; - int ii; - for ( ii = 0; ii < NumberOfAttributes; ii++ ) { - AttributesIdentifier[ii] = tmp_AttributesIdentifier[ii]; - AttributesValues[ii] = tmp_AttributesValues[ii]; - } - NumberOfAttributes = tmp_NumberOfAttributes; - NumberOfGroups = tmp_NumberOfGroups; - delete [] tmp_AttributesIdentifier; - delete [] tmp_AttributesValues; -#else - err = med_2_3::MEDfamily23Info(_medIdt,_meshName.c_str(),i+1,const_cast <char *>(FamilyName.c_str()), - AttributesIdentifier,AttributesValues,const_cast <char *>(AttributesDescription.c_str()),&FamilyIdentifier,const_cast <char *>(GroupsNames.c_str())); -#endif - - - SCRUTE_MED(GroupsNames); - SCRUTE_MED(FamilyName); - SCRUTE_MED(err); - SCRUTE_MED(i); - - if (err != MED_VALID) - throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER::getFAMILY() : ERROR when get FAMILY informations" ); - - if (FamilyIdentifier != 0 ) - { - FAMILY * Family = new FAMILY(_ptrMesh,FamilyIdentifier,FamilyName, - NumberOfAttributes, - AttributesIdentifier, - AttributesValues, - AttributesDescription, - NumberOfGroups,GroupsNames, - MEDArrayNodeFamily, - MEDArrayCellFamily, - MEDArrayFaceFamily, - MEDArrayEdgeFamily); - - // All good ? - // if nothing found, delete Family - - /*! \todo TODO : once unit tests are ready, check that there is no side effect - and let the driver read empty families by removing the if case of the - few following lines */ - - if (Family->getNumberOfTypes() == 0) - { - MESSAGE_MED(LOC<<"Nothing found for family "<<FamilyName<< - " : skip"); - Family->removeReference(); - } - else - switch (Family->getEntity()) - { - case MED_EN::MED_NODE : - _ptrMesh->removeReference(); - NodeFamilyVector.push_back(Family); - numberOfNodesFamilies++; - break; - case MED_EN::MED_CELL : - _ptrMesh->removeReference(); - CellFamilyVector.push_back(Family); - numberOfCellsFamilies++; - break; - case MED_EN::MED_FACE : - _ptrMesh->removeReference(); - FaceFamilyVector.push_back(Family); - numberOfFacesFamilies++; - break; - case MED_EN::MED_EDGE : - _ptrMesh->removeReference(); - EdgeFamilyVector.push_back(Family); - numberOfEdgesFamilies++; - break; - } - } - - delete [] AttributesIdentifier; - delete [] AttributesValues; - } - - if (MEDArrayNodeFamily != NULL) - delete[] MEDArrayNodeFamily; - - if (MEDArrayCellFamily != NULL) - { - for (int i=0; i<_ptrMesh->getNumberOfTypes(MED_CELL); i++) - delete[] MEDArrayCellFamily[i]; - delete[] MEDArrayCellFamily; - } - - if (MEDArrayFaceFamily != NULL) - { - for (int i=0; i<_ptrMesh->getNumberOfTypes(MED_FACE); i++) - delete[] MEDArrayFaceFamily[i]; - delete[] MEDArrayFaceFamily; - } - - if (MEDArrayEdgeFamily != NULL) - { - for (int i=0; i<_ptrMesh->getNumberOfTypes(MED_EDGE); i++) - delete[] MEDArrayEdgeFamily[i]; - delete[] MEDArrayEdgeFamily; - } - - END_OF_MED(LOC); - return MED_VALID; - } - - return MED_ERROR; -} - -int MED_MESH_RDONLY_DRIVER::getNodesFamiliesNumber(int * MEDArrayNodeFamily) -{ - const char * LOC = "MED_MESH_RDONLY_DRIVER::getNodesFamiliesNumber() : "; - - BEGIN_OF_MED(LOC); - - if (_status==MED_OPENED) - { - - int dtp3,itp3; - med_2_3::med_float ttpp3; - med_2_3::MEDmeshComputationStepInfo(_medIdt,_ptrMesh->_name.c_str(),1,&dtp3,&itp3,&ttpp3); - int err = 0; - -#if defined(IRIX64) || defined(OSF1) || defined(VPP5000) || defined(PCLINUX64) - med_2_3::med_int * tmp_MEDArrayNodeFamily = new med_2_3::med_int[_ptrMesh->getNumberOfNodes()]; - err=med_2_3::MEDmeshEntityFamilyNumberRd(_medIdt,_ptrMesh->_name.c_str(),dtp3,itp3,med_2_3::MED_NODE,MED_NONE,tmp_MEDArrayNodeFamily); - int i; - for ( i = 0; i < _ptrMesh->getNumberOfNodes(); i++ ) - MEDArrayNodeFamily[i] = tmp_MEDArrayNodeFamily[i]; - delete [] tmp_MEDArrayNodeFamily; -#else - err=med_2_3::MEDmeshEntityFamilyNumberRd(_medIdt,_ptrMesh->_name.c_str(),dtp3,itp3,med_2_3::MED_NODE,MED_NONE,MEDArrayNodeFamily); -#endif - - if ( err != MED_VALID) - { - std::fill(MEDArrayNodeFamily,MEDArrayNodeFamily+_ptrMesh->getNumberOfNodes(),0); - //throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "There is no family for the |"<< _ptrMesh->getNumberOfNodes() << "| nodes in mesh |" << _ptrMesh->_name.c_str() << "|")); - } - - END_OF_MED(LOC); - return MED_VALID; - } - - return MED_ERROR; -} - -int MED_MESH_RDONLY_DRIVER::getCellsFamiliesNumber(int **MEDArrayFamily, - MED_EN::medEntityMesh entity) -{ - const char * LOC = "MED_MESH_RDONLY_DRIVER::getCellsFamiliesNumber "; - - BEGIN_OF_MED(LOC); - - if (_status==MED_OPENED) - { - int dtp3,itp3; - med_2_3::med_float ttpp3; - med_2_3::MEDmeshComputationStepInfo(_medIdt,_ptrMesh->_name.c_str(),1,&dtp3,&itp3,&ttpp3); - int i, err = 0; - const MED_EN::medGeometryElement *types=_ptrMesh->getTypes(entity); - for (i=0;i<_ptrMesh->getNumberOfTypes(entity);i++) - { -#if defined(IRIX64) || defined(OSF1) || defined(VPP5000) || defined(PCLINUX64) - int NumberOfCell=_ptrMesh->getNumberOfElements(entity,types[i]); - med_2_3::med_int * tmp_MEDArrayFamily = new med_2_3::med_int[NumberOfCell]; - err=med_2_3::MEDmeshEntityFamilyNumberRd(_medIdt,_ptrMesh->_name.c_str(),dtp3,itp3,(med_2_3::med_entity_type) entity,(med_2_3::med_geometry_type)types[i],tmp_MEDArrayFamily); - if (err != MED_VALID - && !_ptrMesh->getIsAGrid()) // it's normal for a grid (PAL14113) - { - err=med_2_3::MEDmeshEntityFamilyNumberRd(_medIdt,_ptrMesh->_name.c_str(),dtp3,itp3,med_2_3::MED_CELL,(med_2_3::med_geometry_type)types[i],tmp_MEDArrayFamily); - if (err != MED_VALID ) - { - std::fill(tmp_MEDArrayFamily,tmp_MEDArrayFamily+NumberOfCell,0); - //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Family not found for entity "<<entity<<" and geometric type "<<types[i])); - } - } - if (err == MED_VALID) { - int ii; - for ( ii = 0; ii < NumberOfCell; ii++ ) - MEDArrayFamily[i][ii] = tmp_MEDArrayFamily[ii]; - } - delete [] tmp_MEDArrayFamily; -#else - err=med_2_3::MEDmeshEntityFamilyNumberRd(_medIdt,_ptrMesh->_name.c_str(),dtp3,itp3,(med_2_3::med_entity_type) entity,(med_2_3::med_geometry_type)types[i],MEDArrayFamily[i]); - - if (err != MED_VALID - && !_ptrMesh->getIsAGrid() ) // it's normal for a grid (PAL14113) - { - err=med_2_3::MEDmeshEntityFamilyNumberRd(_medIdt,_ptrMesh->_name.c_str(),dtp3,itp3,med_2_3::MED_CELL,(med_2_3::med_geometry_type)types[i],MEDArrayFamily[i]); - - if (err != MED_VALID) - { - int NumberOfCell=_ptrMesh->getNumberOfElements(entity,types[i]); - std::fill(MEDArrayFamily[i],MEDArrayFamily[i]+NumberOfCell,0); - //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Family not found for entity "<<entity<<" and geometric type "<<types[i])); - } - } -#endif - } - return err ? MED_INVALID : MED_VALID; - } - return MED_ERROR; -} - -int MED_MESH_RDONLY_DRIVER::getDescendingConnectivity(CONNECTIVITY * Connectivity) -{ - if (_status==MED_OPENED) - { - MESSAGE_MED("MED_MESH_RDONLY_DRIVER::getDescendingConnectivity : "<<"call on the object " << Connectivity); - MESSAGE_MED("MED_MESH_RDONLY_DRIVER::getDescendingConnectivity : "<<"Not yet implemented !"); - } - return MED_ERROR; -} - -void MED_MESH_RDONLY_DRIVER::buildAllGroups(vector<GROUP*> & Groups, vector<FAMILY*> & Families) -{ - const char* LOC = "MED_MESH_RDONLY_DRIVER::buildAllGroups "; - BEGIN_OF_MED(LOC); - - int numberOfFamilies = Families.size() ; - map< string,list<FAMILY*> > groupsNames ; - for(int i=0; i<numberOfFamilies; i++) { - FAMILY * myFamily = Families[i] ; - int numberOfGroups_ = myFamily->getNumberOfGroups(); - for (int j=0; j<numberOfGroups_; j++) { - groupsNames[myFamily->getGroupName(j+1)].push_back(myFamily); - } - } - int numberOfGroups = groupsNames.size() ; - SCRUTE_MED(numberOfGroups); - Groups.resize(numberOfGroups); - map< string,list<FAMILY*> >::const_iterator currentGroup ; - int it = 0 ; - for(currentGroup=groupsNames.begin();currentGroup!=groupsNames.end();currentGroup++) { - GROUP * myGroup = new GROUP(healName((*currentGroup).first),(*currentGroup).second) ; - _ptrMesh->removeReference(); - Groups[it]=myGroup; - it++; - } - - END_OF_MED(LOC); -} - -void MED_MESH_RDONLY_DRIVER::updateFamily() -{ - const char* LOC = "MED_MESH_RDONLY_DRIVER::updateFamily() "; - BEGIN_OF_MED(LOC); - - // we need to update family on constituent if we have constituent, but no - // descending connectivity, so, we must calculate all constituent and - // numbering correctly family ! - if ( !_ptrMesh->getIsAGrid() ) - { - MESH* mesh = (MESH*) _ptrMesh; - mesh->_connectivity->updateFamily(_ptrMesh->_familyFace) ; // in 2d, do nothing - mesh->_connectivity->updateFamily(_ptrMesh->_familyEdge) ; // in 3d, do nothing - } - END_OF_MED(LOC); -} - -/*--------------------- WRONLY PART -------------------------------*/ - -MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER():MED_MESH_DRIVER() -{ - this->GENDRIVER::_accessMode = MED_EN::WRONLY; -} - -MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER(const string & fileName, - GMESH * ptrMesh, - MED_EN::med_mode_acces access): - MED_MESH_DRIVER(fileName,ptrMesh,access) -{ - MESSAGE_MED("MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created"); -} - -MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER(const MED_MESH_WRONLY_DRIVER & driver): - MED_MESH_DRIVER(driver) -{ -} - -MED_MESH_WRONLY_DRIVER::~MED_MESH_WRONLY_DRIVER() -{ - //MESSAGE_MED("MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed"); -} - -GENDRIVER * MED_MESH_WRONLY_DRIVER::copy(void) const -{ - return new MED_MESH_WRONLY_DRIVER(*this); -} - -void MED_MESH_WRONLY_DRIVER::read (void) -{ - throw MEDEXCEPTION("MED_MESH_WRONLY_DRIVER::read : Can't read with a WRONLY driver !"); -} - -void MED_MESH_WRONLY_DRIVER::write(void) const -{ - - if (_ptrMesh==NULL || _ptrMesh->getNumberOfNodes() < 1 ) - throw MEDEXCEPTION("Error trying to write an empty mesh"); - - const char * LOC = "void MED_MESH_WRONLY_DRIVER::write(void) const : "; - BEGIN_OF_MED(LOC); - - // we must first create mesh !! - MESSAGE_MED(LOC << "MeshName : |" << _meshName << "| FileName : |"<<_fileName<<"| MedIdt : | "<< _medIdt << "|"); - - if (_status!=MED_OPENED) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "File "<<_fileName<<" is not open. Open it before write !")); - - - string fieldName; - if ( ( _meshName.empty() ) && ( _ptrMesh->_name.empty() ) ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) - <<" neither <meshName> is set in driver nor in object MESH.")); - - // If _meshName is not set in driver, try to use _ptrmesh->_meshName - if ( ( _meshName.empty() ) && ( !_ptrMesh->_name.empty() ) ) - _meshName = healName(_ptrMesh->_name ); - - if ( _meshName.size() > MED_NAME_SIZE ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) - <<" <meshName> size in object driver MESH is > MED_NAME_SIZE .")); - - - if (_ptrMesh->getIsAGrid()) - { - if ( writeGRID() != MED_VALID ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeGRID()" )); - } - else - { - if (writeCoordinates()!=MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeCoordinates()" )); - - if (writeConnectivities(MED_EN::MED_CELL)!=MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_CELL)" )); - if (writeConnectivities(MED_EN::MED_FACE)!=MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_FACE)" )); - if (writeConnectivities(MED_EN::MED_EDGE)!=MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_EDGE)" )); - } - - if (writeFamilyNumbers() !=MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilyNumbers()" )); - - - // well we must first write zero family : - if (_status==MED_OPENED) { - int err; - // test if the family already exists (HDF trick waiting a MED evolution to be replaced) - string dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/FAMILLE_ZERO/"; - MESSAGE_MED("|"<<dataGroupFam<<"|"); - err =med_2_3::_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) ); - if ( err < MED_VALID ) { - SCRUTE_MED(err); - - char familyName[MED_NAME_SIZE+1]; - strcpy(familyName,"FAMILLE_ZERO"); - err = med_2_3::MEDfamilyCr(_medIdt,_meshName.c_str(),familyName,0,0,0); - - SCRUTE_MED(familyName); - - if ( err != MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't create family |FAMILLE_ZERO| with identifier |0| groups names || and attributes descriptions ||")); - } - else - med_2_3::_MEDdatagroupFermer(_medIdt); - - } - - MESSAGE_MED(LOC<<"writeFamilies(_ptrMesh->_familyNode)"); - if (writeFamilies(_ptrMesh->_familyNode) !=MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyNode)" )); - - MESSAGE_MED(LOC<<"writeFamilies(_ptrMesh->_familyCell)"); - if (writeFamilies(_ptrMesh->_familyCell) !=MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyCell)" )); - - MESSAGE_MED(LOC<<"writeFamilies(_ptrMesh->_familyFace)"); - if (writeFamilies(_ptrMesh->_familyFace) !=MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyFace)" )); - - MESSAGE_MED(LOC<<"writeFamilies(_ptrMesh->_familyEdge)"); - if (writeFamilies(_ptrMesh->_familyEdge) !=MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyEdge)" )); - - END_OF_MED(LOC); -} - -//======================================================================= -//function : writeGRID -//purpose : -//======================================================================= - -int MED_MESH_WRONLY_DRIVER::writeGRID() const -{ - const char * LOC = "MED_MESH_WRONLY_DRIVER::writeGRID() : "; - BEGIN_OF_MED(LOC); - - if (_status!=MED_OPENED) - { - MESSAGE_MED (LOC<<" Not open !!!"); - return MED_ERROR; - } - GRID * ptrGrid = (GRID*) _ptrMesh; - - med_2_3::med_err err = MED_ERROR; - med_2_3::med_axis_type rep; - string tmp_name(_ptrMesh->_spaceDimension*MED_SNAME_SIZE,' '); - string tmp_unit(_ptrMesh->_spaceDimension*MED_SNAME_SIZE,' '); - - // Test if the mesh <_meshName> already exists - // If it doesn't exists create it - // If it already exists verify if its space and mesh dimensions are the same - // as <_ptrMesh->_spaceDimension>, <_ptrMesh->getMeshDimension()> respectively - // rem : <_meshName> is the driver meshName not <ptrMesh->_meshName> - - med_2_3::med_int dtpp3,itpp3; - med_2_3::med_float ttpp3; - err=med_2_3::MEDmeshComputationStepInfo(_medIdt,_meshName.c_str(),1,&dtpp3,&itpp3,&ttpp3); - - int spaceDimension=-1; - int meshDimension=-1; - if(!err) - { - med_2_3::med_mesh_type ttmp3; - char commentp3[MED_COMMENT_SIZE+1]; - char dtunittp3[MED_LNAME_SIZE+1]; - med_2_3::med_sorting_type sttp3; - int nstep; - med_2_3::med_axis_type axtypp3; - int naxis=std::max( 3, med_2_3::MEDmeshnAxisByName(_medIdt,_meshName.c_str())); - char *t1pp3=new char[naxis*MED_SNAME_SIZE+1]; - char *t2pp3=new char[naxis*MED_SNAME_SIZE+1]; - med_2_3::MEDmeshInfoByName(_medIdt,_meshName.c_str(),&spaceDimension,&meshDimension,&ttmp3,commentp3,dtunittp3,&sttp3,&nstep,&axtypp3,t1pp3,t2pp3); - delete [] t1pp3; - delete [] t2pp3; - } - // Recompose the <_spaceDimension> strings in 1 string - int lengthString; - string valueString; - for (int i=0;i<_ptrMesh->_spaceDimension;i++) { - SCRUTE_MED(i); - valueString = ptrGrid->_coordinate->_coordinateName[i]; - lengthString = (MED_SNAME_SIZE<valueString.size())?MED_SNAME_SIZE:valueString.size(); - tmp_name.replace(i*MED_SNAME_SIZE,i*MED_SNAME_SIZE+lengthString,valueString,0,lengthString); - valueString = ptrGrid->_coordinate->_coordinateUnit[i]; - lengthString = (MED_SNAME_SIZE<valueString.size())?MED_SNAME_SIZE:valueString.size(); - tmp_unit.replace(i*MED_SNAME_SIZE,i*MED_SNAME_SIZE+lengthString,valueString,0,lengthString); - } - - if (err) // create a mesh in the file - { - // Pourquoi le stocker sous forme de chaîne ? - const string & coordinateSystem = ptrGrid->_coordinate->_coordinateSystem; - if (coordinateSystem == "CARTESIAN") - rep = med_2_3::MED_CARTESIAN; - else if ( coordinateSystem == "CYLINDRICAL") - rep = med_2_3::MED_CYLINDRICAL; - else if ( coordinateSystem == "SPHERICAL" ) - rep = med_2_3::MED_SPHERICAL; - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Grid |" << _meshName.c_str() << - "| doesn't have a valid coordinate system : |" - << ptrGrid->_coordinate->_coordinateSystem - << "|" )); - - _ptrMesh->_description.resize(MED_COMMENT_SIZE+1,'\0'); - char dtunitp3[MED_LNAME_SIZE+1]; - std::fill(dtunitp3,dtunitp3+MED_LNAME_SIZE+1,'\0'); - - err = med_2_3::MEDmeshCr(_medIdt,_meshName.c_str(), - _ptrMesh->getSpaceDimension(), - _ptrMesh->getMeshDimension(), - med_2_3::MED_STRUCTURED_MESH, - _ptrMesh->_description.c_str(), - dtunitp3,med_2_3::MED_SORT_DTIT, - rep, - const_cast <char *> (tmp_name.c_str()), - const_cast <char *> (tmp_unit.c_str())); - - if (err != MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to create Grid")); - else - MESSAGE_MED(LOC<<"Grid "<<_meshName<<" created in file "<<_fileName<<" !"); - - err = med_2_3::MEDmeshGridTypeWr(_medIdt,_meshName.c_str(), - (med_2_3::med_grid_type)ptrGrid->getGridType()); - if (err != MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Error in MEDmeshGridTypeWr()")); - - meshDimension = _ptrMesh->getMeshDimension(); - } - else if ((spaceDimension != _ptrMesh->_spaceDimension) && - (meshDimension != _ptrMesh->getMeshDimension())) - { - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Grid |" << _meshName.c_str() << - "| already exists in file |" << _fileName << - "| with space dimension |" << spaceDimension << - "| and mesh dimension |" << meshDimension << - "| but the space dimension and the mesh dimension of " - "the mesh we want to write are respectively |" - << _ptrMesh->_spaceDimension <<"|" << - _ptrMesh->getMeshDimension() <<"|" )); - } - - MED_EN::med_grid_type gridType = ptrGrid->getGridType(); - - if (err != MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to write the type of the Grid")); - - - med_2_3::med_int ArrayLen[] = { (med_2_3::med_int) ptrGrid->_iArrayLength, - (med_2_3::med_int) ptrGrid->_jArrayLength, - (med_2_3::med_int) ptrGrid->_kArrayLength }; - - // Write node coordinates for MED_BODY_FITTED grid - if (gridType == MED_EN::MED_BODY_FITTED) - { - // Write Coordinates and families - - err = med_2_3::MEDmeshNodeCoordinateWr(_medIdt,_meshName.c_str(), - MED_NO_DT,MED_NO_IT,MED_NO_DT, - med_2_3::MED_FULL_INTERLACE, - ptrGrid->getNumberOfNodes(), - ptrGrid->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE)); - - if (err != MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write coordinates of the grid |" << _meshName.c_str() << "| in file |" << _fileName - << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and" - << " with units names |" << tmp_name - << "| and units |" << tmp_unit - << " |")); - - med_2_3::med_int* structure = new med_2_3::med_int [meshDimension]; - - for (int idim = 0; idim < meshDimension; ++idim) - structure[idim] = ArrayLen [idim]; - - - err = med_2_3::MEDmeshGridStructWr(_medIdt,_meshName.c_str(), - MED_NO_DT,MED_NO_IT,MED_NO_DT, - structure); - - if (err != MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"error in writing the structure of the grid |" << _meshName.c_str())); - - delete [] structure; - } - else if ((gridType == MED_EN::MED_CARTESIAN) || - (gridType == MED_EN::MED_POLAR)) - { - // Write Arrays of Cartesian or Polar Grid - - double * Array[] = { ptrGrid->_iArray, - ptrGrid->_jArray, - ptrGrid->_kArray }; - - for (int idim = 0; idim < _ptrMesh->getMeshDimension(); ++idim) - { - string str_name = string (tmp_name,idim*MED_SNAME_SIZE, - MED_SNAME_SIZE); - string str_unit = string (tmp_unit,idim*MED_SNAME_SIZE, - MED_SNAME_SIZE); - - err = med_2_3::MEDmeshGridIndexCoordinateWr(_medIdt,_meshName.c_str(), - MED_NO_DT,MED_NO_IT,MED_NO_DT, - idim+1, - ArrayLen[idim], - Array[idim]); - - if (err != MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << - "Can't write grid coordinates for " << - idim << "-th dimention")); - } - } // end Write Cartesian or Polar Grid - - END_OF_MED(LOC); - return MED_VALID; -} - -//======================================================================= -//function : writeCoordinates -//purpose : -//======================================================================= - -int MED_MESH_WRONLY_DRIVER::writeCoordinates() const { - - const char * LOC = "int MED_MESH_WRONLY_DRIVER::writeCoordinates() const : "; - BEGIN_OF_MED(LOC); - - MESH * ptrMesh = (MESH*) _ptrMesh; - - med_2_3::med_err err = MED_ERROR; - med_2_3::med_axis_type rep; - string tmp_name(ptrMesh->_spaceDimension*MED_SNAME_SIZE+1,' '); - string tmp_unit(ptrMesh->_spaceDimension*MED_SNAME_SIZE+1,' '); - - // Recompose the <_spaceDimension> strings in 1 string - int lengthString; - string valueString; - for (int i=0;i<ptrMesh->_spaceDimension;i++) { - valueString = ptrMesh->_coordinate->_coordinateName[i]; - lengthString = (MED_SNAME_SIZE<valueString.size())?MED_SNAME_SIZE:valueString.size(); - tmp_name.replace(i*MED_SNAME_SIZE,i*MED_SNAME_SIZE+lengthString,valueString,0,lengthString); - valueString = ptrMesh->_coordinate->_coordinateUnit[i]; - lengthString = (MED_SNAME_SIZE<valueString.size())?MED_SNAME_SIZE:valueString.size(); - tmp_unit.replace(i*MED_SNAME_SIZE,i*MED_SNAME_SIZE+lengthString,valueString,0,lengthString); - } - // Pourquoi le stocker sous forme de chaîne ? - const string & coordinateSystem = ptrMesh->_coordinate->_coordinateSystem; - if (coordinateSystem == "CARTESIAN") - rep = med_2_3::MED_CARTESIAN; - else if ( coordinateSystem == "CYLINDRICAL") - rep = med_2_3::MED_CYLINDRICAL; - else if ( coordinateSystem == "SPHERICAL" ) - rep = med_2_3::MED_SPHERICAL; - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() << "| doesn't have a valid coordinate system : |" - << ptrMesh->_coordinate->_coordinateSystem - << "|" )); - // Test if the mesh <_meshName> already exists - // If it doesn't exists create it - // If it already exists verify if its space and mesh dimensions are the same - // as <ptrMesh->_spaceDimension>, <ptrMesh->getMeshDimension()> respectively - // rem : <_meshName> is the driver meshName not <ptrMesh->_meshName> - - med_2_3::med_int dtpp3,itpp3; - med_2_3::med_float ttpp3; - err=med_2_3::MEDmeshComputationStepInfo(_medIdt,_meshName.c_str(),1,&dtpp3,&itpp3,&ttpp3); - int spaceDimension=-1; - int meshDimension=-1; - if(!err) - { - med_2_3::med_mesh_type ttmp3; - char commentp3[MED_COMMENT_SIZE+1]; - char dtunittp3[MED_LNAME_SIZE+1]; - med_2_3::med_sorting_type sttp3; - int nstep; - med_2_3::med_axis_type axtypp3; - int naxis=med_2_3::MEDmeshnAxisByName(_medIdt,_meshName.c_str()); - if ( naxis > 0 ) - { - char *t1pp3=new char[naxis*MED_SNAME_SIZE+1]; - char *t2pp3=new char[naxis*MED_SNAME_SIZE+1]; - med_2_3::MEDmeshInfoByName(_medIdt,_meshName.c_str(),&spaceDimension,&meshDimension,&ttmp3,commentp3,dtunittp3,&sttp3,&nstep,&axtypp3,t1pp3,t2pp3); - delete [] t1pp3; - delete [] t2pp3; - } - else - { - err = MED_INVALID; - } - } - SCRUTE_MED(spaceDimension); - SCRUTE_MED(meshDimension); - SCRUTE_MED(ptrMesh->_spaceDimension); - SCRUTE_MED(ptrMesh->getMeshDimension()); - - if (err) - { - _ptrMesh->_description.resize(MED_COMMENT_SIZE+1,'\0'); - char dtunitp3[MED_LNAME_SIZE+1]; - std::fill(dtunitp3,dtunitp3+MED_LNAME_SIZE+1,'\0'); - - err = med_2_3::MEDmeshCr(_medIdt,_meshName.c_str(), - _ptrMesh->getSpaceDimension(), - _ptrMesh->getMeshDimension(), - med_2_3::MED_UNSTRUCTURED_MESH, - _ptrMesh->_description.c_str(), - dtunitp3, - med_2_3::MED_SORT_DTIT, - rep, - const_cast <char *> (tmp_name.c_str()), - const_cast <char *> (tmp_unit.c_str())); - - if (err < MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to create Mesh : |" << _meshName << "|")); - else - MESSAGE_MED(LOC<<"Mesh "<<_meshName<<" created in file "<<_fileName<<" !"); - } - else if ((spaceDimension != ptrMesh->_spaceDimension) && - (meshDimension != ptrMesh->getMeshDimension())) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() << - "| already exists in file |" << _fileName << - "| with space dimension |" << spaceDimension << - "| and mesh dimension |" << meshDimension << - "| but the space dimension and the mesh dimension of the mesh we want to write are respectively |" - << ptrMesh->_spaceDimension <<"|" << - ptrMesh->getMeshDimension() << "|")); - - err=med_2_3::MEDmeshNodeCoordinateWr(_medIdt,_meshName.c_str(),MED_NO_DT,MED_NO_IT,MED_NO_DT,med_2_3::MED_FULL_INTERLACE,ptrMesh->getNumberOfNodes(), - const_cast <double *> ( ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE))); - - if (err<0) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write coordinates of mesh |" << _meshName.c_str() << "| in file |" << _fileName - << "| with dimension |" << ptrMesh->_spaceDimension <<"| and" - << " with units names |" << tmp_name - << "| and units |" << tmp_unit - << " |")); - - - ////////////////////////////////////////////////////////////////////////////////////// - /// Modification pour prise en compte de la numérotation optionnelle des noeuds /// - ////////////////////////////////////////////////////////////////////////////////////// - /// - /// Ecrit les numéros optionnels des noeuds - /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle - - - if (ptrMesh->_arePresentOptionnalNodesNumbers==1) { - -#if defined(IRIX64) || defined(OSF1) || defined(VPP5000) || defined(PCLINUX64) - const int * NodesNumbers = ptrMesh->_coordinate->getNodesNumbers(); - med_2_3::med_int * tmp_NodesNumbers = new med_2_3::med_int[ptrMesh->getNumberOfNodes()]; - int ii; - for ( ii = 0; ii < ptrMesh->getNumberOfNodes(); ii++ ) - tmp_NodesNumbers[ii] = NodesNumbers[ii]; - err=med_2_3::MEDmeshEntityNumberWr(_medIdt,_meshName.c_str(),MED_NO_DT,MED_NO_IT,med_2_3::MED_NODE,MED_NONE,ptrMesh->getNumberOfNodes(), - tmp_NodesNumbers); - delete [] tmp_NodesNumbers; -#else - err=med_2_3::MEDmeshEntityNumberWr(_medIdt,_meshName.c_str(),MED_NO_DT,MED_NO_IT,med_2_3::MED_NODE,MED_NONE,ptrMesh->getNumberOfNodes(), - const_cast<med_int *>(ptrMesh->_coordinate->getNodesNumbers())); -#endif - - if (err != MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write optionnal numbers of mesh |" << - _meshName.c_str() << "| in file |" << - _fileName << " |")); - } - ////////////////////////////////////////////////////////////////////////////////////// - - END_OF_MED(LOC); - - return MED_VALID; -} - - - - -int MED_MESH_WRONLY_DRIVER::writeConnectivities(medEntityMesh entity) const -{ - const char * LOC="int MED_MESH_WRONLY_DRIVER::writeConnectivities() const : "; - BEGIN_OF_MED(LOC); - - med_2_3::med_err err; - - MESH * ptrMesh = (MESH*) _ptrMesh; - - if ( ptrMesh->_connectivity == (CONNECTIVITY *) NULL ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The connectivity is not defined in the MESH object ")); - - - if ( ptrMesh->existConnectivity(MED_NODAL,entity) ) - { - int numberOfTypes = ptrMesh->getNumberOfTypes(entity); - const medGeometryElement * types = ptrMesh->getTypes(entity); - const int * index = ptrMesh->getConnectivityIndex(MED_NODAL, entity); - - for (int i=0; i<numberOfTypes; i++) - { - int numberOfElements = ptrMesh->getNumberOfElements(entity,types[i]); - const int * connectivity = ptrMesh->getConnectivity(MED_NODAL, entity, types[i]); - int size = ptrMesh->getConnectivityLength(MED_NODAL, entity, types[i]); - - switch ( types[i] ) - { - case MED_EN::MED_POLYGON: - { - int nbStdCells = ptrMesh->getGlobalNumberingIndex(entity)[i]-1; - vector< med_2_3::med_int > connectivityArray( connectivity, connectivity + size ); - vector< med_2_3::med_int > tmp_Index( numberOfElements+1 ); - for ( unsigned j = 0; j < tmp_Index.size(); ++ j ) - tmp_Index[j] = index[ nbStdCells + j ] - index[ nbStdCells ] + 1; - err=med_2_3::MEDmeshPolygonWr(_medIdt,_meshName.c_str(), - MED_NO_DT,MED_NO_IT,MED_NO_DT, - med_2_3::MED_CELL, - med_2_3::MED_NODAL, - numberOfElements+1, - &tmp_Index[0], - &connectivityArray[0]); - - if (err<0) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polygons nodal connectivities of mesh |" - << _meshName.c_str() << "| in file |" << _fileName - << "| with dimension |" << ptrMesh->_spaceDimension <<"| and" - )); - break; - } - case MED_EN::MED_POLYHEDRA: - { - vector< med_2_3::med_int > PolyhedronIndex, PolyhedronFacesIndex, PolyhedronConnectivity; - PolyhedronIndex.push_back(1); - PolyhedronFacesIndex.push_back(1); - connectivity = ptrMesh->getConnectivity(MED_NODAL, entity, MED_ALL_ELEMENTS); - int nbStdCells = ptrMesh->getGlobalNumberingIndex(entity)[i]-1; - for ( int j = nbStdCells; j < nbStdCells+numberOfElements; ++j ) - { - for ( int k = index[j]; k < index[j+1]; ++k ) - if ( connectivity[k-1] == -1 ) - PolyhedronFacesIndex.push_back( PolyhedronConnectivity.size()+1 ); - else - PolyhedronConnectivity.push_back( connectivity[k-1] ); - PolyhedronIndex.push_back( PolyhedronFacesIndex.size()+1 ); - PolyhedronFacesIndex.push_back( PolyhedronConnectivity.size()+1 ); - } - err=med_2_3::MEDmeshPolyhedronWr(_medIdt,_meshName.c_str(), - MED_NO_DT,MED_NO_IT,MED_NO_DT, - med_2_3::MED_CELL, - med_2_3::MED_NODAL, - PolyhedronIndex.size(), - &PolyhedronIndex[0], - PolyhedronFacesIndex.size(), - &PolyhedronFacesIndex[0], - &PolyhedronConnectivity[0]); - if (err<0) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polyhedron nodal connectivities of mesh |" - << _meshName.c_str() << "| in file |" << _fileName - << "| with dimension |" << ptrMesh->_spaceDimension <<"| and" - )); - break; - } - default: - - vector< med_2_3::med_int > connectivityArray( connectivity, connectivity + size ); - err=med_2_3::MEDmeshElementConnectivityWr(_medIdt,_meshName.c_str(),MED_NO_DT,MED_NO_IT,MED_NO_DT,med_2_3::MED_CELL,(med_2_3::med_geometry_type)types[i], - med_2_3::MED_NODAL,med_2_3::MED_FULL_INTERLACE,numberOfElements,&connectivityArray[0]); - - if (err<0) // ETENDRE LES EXPLICATIONS - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" - << _meshName.c_str() << "| in file |" << _fileName - << "| with dimension |" << ptrMesh->_spaceDimension <<"| and")); - } - } - } - - - // Descending connectivity for classic geometric types - if ( ptrMesh->existConnectivity(MED_DESCENDING,entity) ) - { - int numberOfTypes = ptrMesh->getNumberOfTypes (entity); - const medGeometryElement * types = ptrMesh->getTypes (entity); - - for (int i=0; i<numberOfTypes; i++) - { - int numberOfElements = ptrMesh->getNumberOfElements (entity,types[i]); - const int * connectivity = ptrMesh->getConnectivity(MED_DESCENDING, entity, types[i]); - -#if defined(IRIX64) || defined(OSF1) || defined(VPP5000) || defined(PCLINUX64) - int lgth = ptrMesh->getConnectivityLength(MED_DESCENDING, entity, types[i]); - vector< med_2_3::med_int > tmp_Connectivity( connectivity, connectivity + lgth ); - err=med_2_3::MEDmeshElementConnectivityWr(_medIdt,_meshName.c_str(), - MED_NO_DT,MED_NO_IT,MED_NO_DT, - med_2_3::MED_CELL, - (med_2_3::med_geometry_type)types[i], - med_2_3::MED_DESCENDING, - med_2_3::MED_FULL_INTERLACE, - numberOfElements, - &tmp_Connectivity[0]); -#else - err=med_2_3::MEDmeshElementConnectivityWr(_medIdt,_meshName.c_str(), - MED_NO_DT,MED_NO_IT,MED_NO_DT, - med_2_3::MED_CELL, - (med_2_3::med_geometry_type)types[i], - med_2_3::MED_DESCENDING, - med_2_3::MED_FULL_INTERLACE, - numberOfElements, - const_cast<int *>(connectivity)); -#endif - - if (err<0) // ETENDRE LES EXPLICATIONS - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" - << _meshName.c_str() << "| in file |" << _fileName - << "| with dimension |" << ptrMesh->_spaceDimension <<"| and" - )); - - } - } - - END_OF_MED(LOC); - return MED_VALID; -} - -/*!creates a vector of families from a vector of groups - * - * \param myGroups input : vector of groups - * \param myFamilies output vector of families - * - * Routine is meant to be called to reconstruct families from existing groups - * typically for writing meshes created by MEDMEM::MESHING containing overlapping groups - * - * if the groups do not overlap, the vector of families will have the same size - * as the vector of groups - * otherwise, the size of the family vector will be larger -*/ - -void MED_MESH_WRONLY_DRIVER::groupFamilyConverter(const vector <GROUP*>& myGroups, vector <FAMILY*>& myFamilies ) const -{ - - const char* LOC = "MED_MESH_WRONLY_DRIVER::groupFamilyConverter"; - BEGIN_OF_MED(LOC); - if (myGroups.empty()) return; - -// if (!myFamilies.empty()) -// throw MEDEXCEPTION(LOCALIZED("Family vector must be empty on call " -// << "to groupFamilyConverter")); -// - //mapping elements to all the groups containing it - std::multimap <int,int> elem2groups; - for (int igroup=0; igroup< (int)myGroups.size(); igroup++) - { - const int*Number = myGroups[igroup]->getNumber(MED_ALL_ELEMENTS); - for (int ielem = 0; ielem< myGroups[igroup]->getNumberOfElements(MED_ALL_ELEMENTS); ielem++) - { - elem2groups.insert(make_pair(Number[ielem], igroup)); - } - } - - //creating a set of signatures for the groups intersections - std::multimap<vector<int>,int> signatures; - - typedef multimap<int,int>::iterator MI; - MI iter=elem2groups.begin(); - - while (iter!=elem2groups.end()) - { - vector<int> sign (1, iter -> second ); - int key = iter -> first; - iter ++; - while (iter!=elem2groups.end()&&iter-> first == key) - { - sign.push_back(iter -> second); - iter++; - } - signatures.insert(make_pair(sign,key)); - } - - elem2groups.clear(); - - //creating the families from the signatures mapping - //each signature will correspond to a new family - std::multimap<vector<int>,int>::const_iterator iter_signatures = signatures.begin(); - - //retrieving the entity type (all the groups have the same) - // node families are numbered above 0 - // cell families are numbered from -1 to -MAX_NB_GROUPS - // face falimies are numbered from -MAX_NB_GROUPS-1 to -2*MAX_NB_GROUPS - // edge families are numbered from -2*MAX_NB_GROUPS to -3*MAX_NB_GROUPS - // MAX_NB_GROUPS is defined in MEDMEM_define.hxx - - medEntityMesh entity = myGroups[0]->getEntity(); - MESH* mesh=(MESH*)myGroups[0]->getMesh(); - - int ifamily; - switch (entity) - { - case MED_NODE: - ifamily=1; - break; - case MED_CELL: - ifamily=-MAX_NB_GROUP; - break; - case MED_FACE: - ifamily=-2*MAX_NB_GROUP; - break; - case MED_EDGE: - ifamily=-3*MAX_NB_GROUP; - break; - } - - //browsing signatures to build all the families - //each signature corresponds to a new family - - while (iter_signatures!= signatures.end()) - { - const vector<int>& key= iter_signatures->first; - int size = signatures.count(key); - - list<int> numbers; - - for (int i=0; i< size; i++) - { - numbers.push_back(iter_signatures->second); - iter_signatures++; - } - - //TODO : see if build SupportOnElementFromElementList could not be built from another container - - // for nodes, the family is built directly from the node list - // for elements, it is built from the buildSupportOnElementsFromElementList - // which allocates a support - FAMILY* myFamily; - if (entity!=MED_NODE) - { - SUPPORT* support; - support=mesh->buildSupportOnElementsFromElementList(numbers, entity); - myFamily=new FAMILY(*support); - support->removeReference(); - } - else - { - myFamily= new FAMILY(); - myFamily->setMesh(mesh); - myFamily->fillFromNodeList(numbers); - } - - - // the identifier and the groups are set - myFamily->setIdentifier(ifamily); - myFamily->setNumberOfGroups(key.size()); - char family_name[MED_NAME_SIZE]; - - //if the family has one group to which only one family - //is associated, the name of the family underlying the group - //is given back to the family - if (key.size()==1 && myGroups[key[0]]->getNumberOfFamilies()==0) - { - vector<FAMILY*> families; - families.push_back(myFamily); - myGroups[key[0]]->setFamilies(families); - //it is necessary to use strncpy because group and family - //have different name sizes - strncpy(family_name,myGroups[key[0]]->getName().c_str(),MED_NAME_SIZE); - family_name[MED_NAME_SIZE-1]='\0'; - } - else - sprintf(family_name,"family%d",ifamily); - - myFamily->setName( healName( family_name )); - - string* groupnames=new string[key.size()]; - - for (int igroup=0; igroup<(int)key.size(); igroup++) - { - groupnames[igroup]=myGroups[key[igroup]]->getName(); - } - - myFamily->setGroupsNames(groupnames,true); - if(myFamily->getMesh()==_ptrMesh) - _ptrMesh->removeReference(); - myFamilies.push_back(myFamily); - ifamily++; - } - - //adding empty families corresponding to empty groups - for (size_t i=0; i<myGroups.size(); i++) - { - if (myGroups[i]->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)==0) - { - FAMILY* myFamily=new FAMILY(*(myGroups[i])); - char family_name[MED_NAME_SIZE]; - //it is necessary to use strncpy because group and family - //have different name sizes - strncpy(family_name,myGroups[i]->getName().c_str(),MED_NAME_SIZE); - family_name[MED_NAME_SIZE-1]='\0'; - myFamily->setName( healName( family_name )); - myFamily->setIdentifier(ifamily); - ifamily++; - vector<string> groupnames; - groupnames.push_back(myGroups[i]->getName()); - myFamily->setNumberOfGroups(1); - myFamily->setGroupsNames(&groupnames[0]); - if(myFamily->getMesh()==_ptrMesh) - _ptrMesh->removeReference(); - myFamilies.push_back(myFamily); - } - } - END_OF_MED(LOC); -} - -int MED_MESH_WRONLY_DRIVER::writeFamilyNumbers() const { - - const char * LOC="int MED_MESH_WRONLY_DRIVER::writeFamilyNumbers() const : "; - BEGIN_OF_MED(LOC); - - med_2_3::med_err err; - - // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArrayNodeFamily DOIT ETRE ENLEVER DE LA CLASSE MESH - - { // Node related block - - // We build the array from the families list objects : - int NumberOfNodes = _ptrMesh->getNumberOfNodes(); - med_2_3::med_int * MEDArrayNodeFamily = new med_2_3::med_int[NumberOfNodes]; - // family 0 by default - for (int i=0; i<NumberOfNodes; i++) - MEDArrayNodeFamily[i]=0; - vector<FAMILY*> * myFamilies = &_ptrMesh->_familyNode; - int NumberOfNodesFamilies = myFamilies->size(); - if (0 == NumberOfNodesFamilies) { - vector<GROUP*> myGroups = _ptrMesh->getGroups(MED_NODE); - - groupFamilyConverter(myGroups,*myFamilies); - - NumberOfNodesFamilies=myFamilies->size(); - } - for (int i=0; i<NumberOfNodesFamilies; i++) { - int FamilyIdentifier = (*myFamilies)[i]->getIdentifier(); - int TotalNumber = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS); - const int * Number = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS); - for (int j=0; j<TotalNumber; j++) - MEDArrayNodeFamily[Number[j]-1]=FamilyIdentifier; - } - err=med_2_3::MEDmeshEntityFamilyNumberWr(_medIdt,_meshName.c_str(),MED_NO_DT,MED_NO_IT,med_2_3::MED_NODE,MED_NONE,NumberOfNodes,MEDArrayNodeFamily); - - - if ( err != MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write node family for the |"<< NumberOfNodes - << "| nodes in mesh |" - << _ptrMesh->_name.c_str() << "|" )); - delete[] MEDArrayNodeFamily; - } - - { // CELLS RELATED BLOCK - medEntityMesh entity=MED_EN::MED_CELL; - // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH - if ((_ptrMesh->getIsAGrid()) || // PAL18712, GRID::existConnectivity() calls GRID::fillConnectivity() but it is not needed for writing GRID - (((MESH*)_ptrMesh)->existConnectivity(MED_NODAL,entity)) || - (((MESH*)_ptrMesh)->existConnectivity(MED_DESCENDING,entity))) - { - int numberOfTypes = _ptrMesh->getNumberOfTypes(entity); - const medGeometryElement * types = _ptrMesh->getTypes(entity); - - // We build the array from the families list objects : - int NumberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS); - int * MEDArrayFamily = new int[NumberOfElements]; - // family 0 by default - for (int i=0; i<NumberOfElements; i++) - MEDArrayFamily[i]=0; - vector<FAMILY*> * myFamilies = &_ptrMesh->_familyCell; - int NumberOfFamilies = myFamilies->size(); - if (0 == NumberOfFamilies) { - vector<GROUP*> myGroups = _ptrMesh->getGroups(entity); - groupFamilyConverter(myGroups,*myFamilies); - NumberOfFamilies=myFamilies->size(); - } - for (int i=0; i<NumberOfFamilies; i++) { - int FamilyIdentifier = (*myFamilies)[i]->getIdentifier(); - int TotalNumber = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS); - const int * Number = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS); - for (int ii=0; ii<TotalNumber; ii++) - MEDArrayFamily[Number[ii]-1]=FamilyIdentifier; - } - - int offset=0; -#if defined(IRIX64) || defined(OSF1) || defined(VPP5000) || defined(PCLINUX64) - vector < med_2_3::med_int > temp( MEDArrayFamily, MEDArrayFamily + NumberOfElements ); -#endif - for (int i=0; i<numberOfTypes; i++) - { - int typeNumberOfElements=_ptrMesh->getNumberOfElements(entity,types[i]); -#if defined(IRIX64) || defined(OSF1) || defined(VPP5000) || defined(PCLINUX64) - err=med_2_3::MEDmeshEntityFamilyNumberWr(_medIdt,_meshName.c_str(),MED_NO_DT,MED_NO_IT,med_2_3::MED_CELL,(med_2_3::med_geometry_type) types[i],typeNumberOfElements,&temp[0]+offset); -#else - err=med_2_3::MEDmeshEntityFamilyNumberWr(_medIdt,_meshName.c_str(),MED_NO_DT,MED_NO_IT,med_2_3::MED_CELL,(med_2_3::med_geometry_type) types[i],typeNumberOfElements,MEDArrayFamily+offset); -#endif - MESSAGE_MED("OK "<<i); - if ( err != MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< typeNumberOfElements - << "| cells of geometric type |" << geoNames[types[i]] <<"|in mesh |" - << _ptrMesh->_name.c_str() << "|" )); - offset+=typeNumberOfElements; - } - delete[] MEDArrayFamily; - } - } - - if (!_ptrMesh->getIsAGrid() || _ptrMesh->getMeshDimension() == 3 ) // for grid - only in 3D mesh - - { // FACE RELATED BLOCK - medEntityMesh entity=MED_EN::MED_FACE; - // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH - if ((_ptrMesh->getIsAGrid()) || // PAL18712, GRID::existConnectivity() calls GRID::fillConnectivity() but it is not needed for writing GRID - (((MESH*)_ptrMesh)->existConnectivity(MED_NODAL,entity)) || - (((MESH*)_ptrMesh)->existConnectivity(MED_DESCENDING,entity))) - { - int numberOfTypes = _ptrMesh->getNumberOfTypes(entity); - const medGeometryElement * types = _ptrMesh->getTypes(entity); - SCRUTE_MED(numberOfTypes); - - int numberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS); - int * familyArray = new int[numberOfElements]; - for (int i=0;i<numberOfElements;i++) - familyArray[i]=0; - - int numberOfFamilies = _ptrMesh->getNumberOfFamilies(entity); - vector<FAMILY*> * myFamilies = &_ptrMesh->_familyFace; - if (0 == numberOfFamilies) { - vector<GROUP*> myGroups = _ptrMesh->getGroups(entity); - - groupFamilyConverter(myGroups,*myFamilies); - - numberOfFamilies=myFamilies->size(); - } - for (int i=0;i<numberOfFamilies;i++) { - int familyNumber = (*myFamilies)[i]->getIdentifier(); - int numberOfFamilyElements = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS); - const int * myFamilyElements = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS); - for (int ii=0;ii<numberOfFamilyElements;ii++) - familyArray[myFamilyElements[ii]-1]=familyNumber; - } - - for (int i=0;i<numberOfElements;i++) - SCRUTE_MED(familyArray[i]); - -#if defined(IRIX64) || defined(OSF1) || defined(VPP5000) || defined(PCLINUX64) - vector< med_2_3::med_int > temp( familyArray, familyArray + numberOfElements); -#endif - int offset=0; - for (int i=0; i<numberOfTypes; i++) - { - int typeNumberOfElements = _ptrMesh->getNumberOfElements(entity,types[i]); -#if defined(IRIX64) || defined(OSF1) || defined(VPP5000) || defined(PCLINUX64) - err=med_2_3::MEDmeshEntityFamilyNumberWr(_medIdt,_meshName.c_str(),MED_NO_DT,MED_NO_IT,med_2_3::MED_CELL,(med_2_3::med_geometry_type) types[i],typeNumberOfElements,&temp[0]+offset); -#else - err=med_2_3::MEDmeshEntityFamilyNumberWr(_medIdt,_meshName.c_str(),MED_NO_DT,MED_NO_IT,med_2_3::MED_CELL,(med_2_3::med_geometry_type) types[i],typeNumberOfElements,familyArray+offset); -#endif - if ( err != MED_VALID) - { - if ( _ptrMesh->getIsAGrid() ) - { - if ( numberOfFamilies > 0 ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << - "Groups and families of FACEs in the structured " - "mesh are not supported by med file" )); - } - else - { - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << - "Can't write family for the |"<< typeNumberOfElements - << "| faces of geometric type |" << geoNames[types[i]] - << "| in mesh |" << _meshName << "|" )); - } - } - offset+=typeNumberOfElements; - } - delete[] familyArray; - } - } - - if (!_ptrMesh->getIsAGrid() || _ptrMesh->getMeshDimension() > 1 ) // for grid - only in 3D and 2D mesh - - { // EDGE RELATED BLOCK - medEntityMesh entity=MED_EN::MED_EDGE; - // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH - if ((_ptrMesh->getIsAGrid()) || // PAL18712, GRID::existConnectivity() calls GRID::fillConnectivity() but it is not needed for writing GRID - (((MESH*)_ptrMesh)->existConnectivity(MED_NODAL,entity) ) || - (((MESH*)_ptrMesh)->existConnectivity(MED_DESCENDING,entity) ) ) { - - int numberOfTypes = _ptrMesh->getNumberOfTypes (entity); - const medGeometryElement * types = _ptrMesh->getTypes (entity); - - int numberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS); - int * familyArray = new int[numberOfElements]; - for (int i=0;i<numberOfElements;i++) - familyArray[i]=0; - - int numberOfFamilies = _ptrMesh->getNumberOfFamilies(entity); - vector<FAMILY*> * myFamilies = &_ptrMesh->_familyEdge; - if (0 == numberOfFamilies) { - vector<GROUP*> myGroups = _ptrMesh->getGroups(entity); - - groupFamilyConverter(myGroups,*myFamilies); - - numberOfFamilies=myFamilies->size(); - - } - - for (int i=0;i<numberOfFamilies;i++) { - int familyNumber = (*myFamilies)[i]->getIdentifier(); - int numberOfFamilyElements = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS); - const int * myFamilyElements = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS); - for (int ii=0;ii<numberOfFamilyElements;ii++) - familyArray[myFamilyElements[ii]-1]=familyNumber; - } - - - for (int i=0;i<numberOfElements;i++) - SCRUTE_MED(familyArray[i]); - - - int typeCount = 0; -#if defined(IRIX64) || defined(OSF1) || defined(VPP5000) || defined(PCLINUX64) - vector< med_2_3::med_int > temp (familyArray, familyArray+numberOfElements ); -#endif - - for (int i=0; i<numberOfTypes; i++) - { - int typeNumberOfElements = _ptrMesh->getNumberOfElements(entity, types[i]); -#if defined(IRIX64) || defined(OSF1) || defined(VPP5000) || defined(PCLINUX64) - err=med_2_3::MEDmeshEntityFamilyNumberWr(_medIdt,_meshName.c_str(),MED_NO_DT,MED_NO_IT,med_2_3::MED_CELL,(med_2_3::med_geometry_type) types[i],typeNumberOfElements,&temp[0]+typeCount); -#else - err=med_2_3::MEDmeshEntityFamilyNumberWr(_medIdt,_meshName.c_str(),MED_NO_DT,MED_NO_IT,med_2_3::MED_CELL,(med_2_3::med_geometry_type) types[i],typeNumberOfElements,familyArray+typeCount); -#endif - if ( err != MED_VALID) - { - if ( _ptrMesh->getIsAGrid() ) - { - if ( numberOfFamilies > 0 ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << - "Groups and families of EDGEs in the structured " - " mesh are not supported by med file" )); - } - else - { - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |" - << _ptrMesh->getNumberOfElements(entity, types[i]) - << "| edges of geometric type |" - << geoNames[types[i]] <<"|in mesh |" - << _ptrMesh->_name.c_str() << "|" )); - } - } - typeCount += typeNumberOfElements; - } - delete[] familyArray; - } - } - - END_OF_MED(LOC); - return MED_VALID; -} - -int MED_MESH_WRONLY_DRIVER::writeFamilies(vector<FAMILY*> & families ) const -{ - - const char * LOC="int MED_MESH_WRONLY_DRIVER::writeFamilies(vector<FAMILY*> families) const : "; - BEGIN_OF_MED(LOC); - - med_2_3::med_err err; - - MESSAGE_MED(LOC<<" families.size() :"<<families.size()); - - for (unsigned int i=0; i< families.size(); i++) { - - int numberOfAttributes = families[i]->getNumberOfAttributes (); - string attributesDescriptions (numberOfAttributes*MED_COMMENT_SIZE,'\0'); - - // Recompose the attributes descriptions arg for MED - for (int j=0; j < numberOfAttributes; j++) - { - string attributeDescription = families[i]->getAttributeDescription(j+1); - - if ( attributeDescription.size() > MED_COMMENT_SIZE ) - throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the attribute description n° |" - << j+1 << "| of the family |" << families[i]->getName() - << "| with identifier |" << families[i]->getIdentifier() - << "| is |" << attributeDescription.size() - <<"| and is more than |" << MED_COMMENT_SIZE << "|")); - - int length = min(MED_COMMENT_SIZE,(int)attributeDescription.size()); - attributesDescriptions.replace(j*MED_COMMENT_SIZE,length, attributeDescription,0,length); - } - - - int numberOfGroups = families[i]->getNumberOfGroups(); - string groupsNames(numberOfGroups*MED_LNAME_SIZE,'\0'); - - // Recompose the groups names arg for MED - for (int j=0; j < numberOfGroups; j++) - { - string groupName = families[i]->getGroupName(j+1); - - if ( groupName.size() > MED_LNAME_SIZE ) - throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the group name n° |" - << j+1 << "| of the family |" << families[i]->getName() - << "| with identifier |" << families[i]->getIdentifier() - << "| is |" << groupName.size() - <<"| and is more than |" << MED_LNAME_SIZE << "|")); - - int length = min(MED_LNAME_SIZE,(int)groupName.size()); - groupsNames.replace(j*MED_LNAME_SIZE,length, groupName,0,length); - } - - // test if the family already exists (HDF trick waiting a MED evolution to be replaced) - - string dataGroupFam; - if (families[i]->getEntity() == MED_NODE) - dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/NOEUD/"+families[i]->getName()+"/"; - else - dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/ELEME/"+families[i]->getName()+"/"; - - SCRUTE_MED("|"<<dataGroupFam<<"|"); - err = med_2_3::_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) ); - if ( err < MED_VALID ) { - SCRUTE_MED(err); - if ( families[i]->getName().size() > MED_NAME_SIZE ) - throw MEDEXCEPTION - ( LOCALIZED(STRING(LOC) << "The size of the name of the family |" << i+1 - << "| |" << families[i]->getName() - << "| with identifier |" << families[i]->getIdentifier() << "| is |" - << families[i]->getName().size() <<"| and is more than |" - << MED_NAME_SIZE << "|")); - - MESSAGE_MED(LOC<<"families[i]->getName().c_str() : "<<families[i]->getName().c_str()); - MESSAGE_MED(LOC<<"_meshName.c_str() : "<<_meshName.c_str()); - MESSAGE_MED(LOC<<"families[i]->getIdentifier() : "<<families[i]->getIdentifier()); - MESSAGE_MED(LOC<<"numberOfAttributes : "<<numberOfAttributes); - - MESSAGE_MED(LOC<<"attributesDescriptions.c_str() : "<<attributesDescriptions.c_str()); - MESSAGE_MED(LOC<<"numberOfGroups : "<<numberOfGroups); - MESSAGE_MED(LOC<<"groupsNames.c_str() : "<<groupsNames.c_str()); -#if defined(IRIX64) || defined(OSF1) || defined(VPP5000) || defined(PCLINUX64) - int lgth=families[i]->getNumberOfAttributes(); - med_2_3::med_int * AttributesIdentifier2 = new med_2_3::med_int[lgth]; - med_2_3::med_int * AttributesValues2 = new med_2_3::med_int[lgth]; - for(med_2_3::med_int i2=0;i2<lgth;i2++) - { - AttributesIdentifier2[i2]=(med_2_3::med_int)(families[i]->getAttributesIdentifiers()[i2]); - AttributesValues2[i2]=(med_2_3::med_int)(families[i]->getAttributesValues()[i2]); - } - err = med_2_3::MEDfamilyCr(_medIdt,_meshName.c_str(),healName(families[i]->getName()).c_str(), - families[i]->getIdentifier(),numberOfGroups,groupsNames.c_str()); - /*err = med_2_3::MEDfamCr( _medIdt, - const_cast <char *> ( _meshName.c_str() ), - const_cast <char *> ( healName(families[i]->getName()).c_str() ), - families[i]->getIdentifier(), - AttributesIdentifier2, - AttributesValues2, - const_cast <char *> (attributesDescriptions.c_str()), - numberOfAttributes, - const_cast <char *> (groupsNames.c_str()), - numberOfGroups);*/ - delete [] AttributesIdentifier2; - delete [] AttributesValues2; -#else - err = med_2_3::MEDfamilyCr(_medIdt,_meshName.c_str(),healName(families[i]->getName()).c_str(), - families[i]->getIdentifier(),numberOfGroups,groupsNames.c_str()); - /*const_cast <char *> ( healName(families[i]->getName()).c_str() ), - families[i]->getIdentifier(), - (med_2_3::med_int*)families[i]->getAttributesIdentifiers(), - (med_2_3::med_int*)families[i]->getAttributesValues(), - const_cast <char *> (attributesDescriptions.c_str()), - numberOfAttributes, - const_cast <char *> (groupsNames.c_str()), - numberOfGroups); -------- attributes for MED3 ...*/ -#endif - SCRUTE_MED(err); - if (err != MED_VALID) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't create family |" << families[i]->getName() - << "| with identifier |" << families[i]->getIdentifier() - << "| groups names |" << groupsNames - << "| and attributes descriptions |" << attributesDescriptions << "|")); - } - else - med_2_3::_MEDdatagroupFermer(_medIdt); - - } - - END_OF_MED(LOC); - - return MED_VALID; -} - - - - -/*--------------------- RDWR PART -------------------------------*/ - -MED_MESH_RDWR_DRIVER::MED_MESH_RDWR_DRIVER() -{ - this->GENDRIVER::_accessMode = MED_EN::RDWR; -} - -MED_MESH_RDWR_DRIVER::MED_MESH_RDWR_DRIVER(const string & fileName, - GMESH * ptrMesh): - MED_MESH_DRIVER(fileName,ptrMesh,RDWR), - MED_MESH_RDONLY_DRIVER(fileName,ptrMesh), - MED_MESH_WRONLY_DRIVER(fileName,ptrMesh) -{ - MESSAGE_MED("MED_MESH_RDWR_DRIVER::MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been created"); -} - -MED_MESH_RDWR_DRIVER::MED_MESH_RDWR_DRIVER(const MED_MESH_RDWR_DRIVER & driver): - MED_MESH_DRIVER(driver), - MED_MESH_RDONLY_DRIVER(driver), - MED_MESH_WRONLY_DRIVER(driver) -{ -} - -MED_MESH_RDWR_DRIVER::~MED_MESH_RDWR_DRIVER() -{ - //MESSAGE_MED("MED_MESH_RDWR_DRIVER::MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed"); -} - -GENDRIVER * MED_MESH_RDWR_DRIVER::copy(void) const -{ - return new MED_MESH_RDWR_DRIVER(*this); -} - -void MED_MESH_RDWR_DRIVER::write(void) const -{ - MED_MESH_WRONLY_DRIVER::write(); -} -void MED_MESH_RDWR_DRIVER::read (void) -{ - MED_MESH_RDONLY_DRIVER::read(); -} diff --git a/src/MEDMEM/MEDMEM_MedMeshDriver.hxx b/src/MEDMEM/MEDMEM_MedMeshDriver.hxx deleted file mode 100644 index ec09e9276..000000000 --- a/src/MEDMEM/MEDMEM_MedMeshDriver.hxx +++ /dev/null @@ -1,281 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef MED_MESH_DRIVER_HXX -#define MED_MESH_DRIVER_HXX - -#include <MEDMEM.hxx> - -#include <string> -#include <vector> -#include "MEDMEM_define.hxx" -#include "MEDMEM_GenDriver.hxx" - -#include "MEDMEM_STRING.hxx" -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_Utilities.hxx" - -/*! - - Driver Med for MESH. - - Generic part : implement open and close methods. - -*/ - -namespace MEDMEM { -class GMESH; -class FAMILY; -class GROUP; -class CONNECTIVITY; -class MEDMEM_EXPORT MED_MESH_DRIVER : public GENDRIVER -{ -protected: - - GMESH * _ptrMesh; - mutable std::string _meshName; - med_2_3::med_idt _medIdt ; - - - -public : - - // all MED cell type - static const med_2_3::med_geometry_type all_cell_type[MED_N_CELL_GEO_FIXED_CON]; - - static const char * const all_cell_type_tab [MED_N_CELL_GEO_FIXED_CON]; - - /*! - Constructor. - */ - MED_MESH_DRIVER() ; - /*! - Constructor. - */ - MED_MESH_DRIVER(const std::string & fileName, - GMESH * ptrMesh, - MED_EN::med_mode_acces accessMode) ; - /*! - Copy constructor. - */ - MED_MESH_DRIVER(const MED_MESH_DRIVER & driver) ; - - /*! - Destructor. - */ - virtual ~MED_MESH_DRIVER() ; - - virtual void open(); - virtual void close(); - - virtual void write( void ) const = 0 ; - virtual void read ( void ) = 0 ; - - /*! - Set the name of the MESH asked in file. - - It could be different than the name of the MESH object. - */ - virtual void setMeshName(const std::string & meshName) ; - /*! - Get the name of the MESH asked in file. - */ - virtual std::string getMeshName() const ; - -public: - virtual GENDRIVER * copy ( void ) const = 0 ; - -}; - -/*! - - Driver Med for MESH : Read only. - - Implement read method. - -*/ - -class MEDMEM_EXPORT MED_MESH_RDONLY_DRIVER : public virtual MED_MESH_DRIVER -{ - -public : - - /*! - Constructor. - */ - MED_MESH_RDONLY_DRIVER() ; - /*! - Constructor. - */ - MED_MESH_RDONLY_DRIVER(const std::string & fileName, GMESH * ptrMesh) ; - /*! - Copy constructor. - */ - MED_MESH_RDONLY_DRIVER(const MED_MESH_RDONLY_DRIVER & driver) ; - /*! - Destructor. - */ - virtual ~MED_MESH_RDONLY_DRIVER() ; - - /*! - Return a MEDEXCEPTION : it is the read-only driver. - */ - void write( void ) const; - /*! - Read MESH in the specified file. - */ - void read ( void ); - /*! - * This method activate global faces computation from SCRATCH if a family on FACE exists in the MED file. - * This implies a complete renumbering of FACES. This is the default behaviour of this driver. - */ - void activateFacesComputation() { _computeFaces=true; } - /*! - * This method desactivate global face computation. - * That is to say that FACES described in file are supposed to - * be correct and complete. The consequence is that reading is much faster. Use with care ! - */ - void desactivateFacesComputation() { _computeFaces=false; } - -protected: - int getDescendingConnectivity(CONNECTIVITY * Connectivity); - void updateFamily() ; - void buildAllGroups(std::vector<GROUP*> & Groups, std::vector<FAMILY*> & Families) ; - -private: - int getCOORDINATE(); - int getCONNECTIVITY(); - int getFAMILY(); - int getNodalConnectivity(CONNECTIVITY * Connectivity) ; - int getNodesFamiliesNumber(int * MEDArrayNodeFamily) ; - int getCellsFamiliesNumber(int** Arrays, /*CONNECTIVITY* Connectivity, */MED_EN::medEntityMesh entity) ; - void getGRID (); - - GENDRIVER * copy ( void ) const ; - virtual void merge ( const GENDRIVER& driver ); - -private: - bool _computeFaces; -}; - -/*! - - Driver Med for MESH : Write only. - - Implement write method. - -*/ - -class MEDMEM_EXPORT MED_MESH_WRONLY_DRIVER : public virtual MED_MESH_DRIVER -{ -public : - - /*! - Constructor. - */ - MED_MESH_WRONLY_DRIVER() ; - /*! - Constructor. - */ - MED_MESH_WRONLY_DRIVER(const std::string & fileName, - GMESH * ptrMesh, - MED_EN::med_mode_acces access=MED_EN::WRONLY) ; - /*! - Copy constructor. - */ - MED_MESH_WRONLY_DRIVER(const MED_MESH_WRONLY_DRIVER & driver) ; - - /*! - Destructor. - */ - virtual ~MED_MESH_WRONLY_DRIVER() ; - - /*! - Return a MEDEXCEPTION : it is the write-only driver. - */ - void read ( void ); - - /*! - Write MESH in the specified file. - */ - void write( void ) const; - -private: - int writeCoordinates () const; - int writeConnectivities (MED_EN::medEntityMesh entity) const; - void groupFamilyConverter(const std::vector<GROUP*>& groups, - std::vector<FAMILY*>& families) const; - int writeFamilyNumbers () const; - int writeFamilies (std::vector<FAMILY*> & families) const; - int writeGRID() const; - - GENDRIVER * copy ( void ) const ; -}; - - -/*! - - Driver Med for MESH : Read write. - - Use read method from MED_MESH_RDONLY_DRIVER - - Use write method from MED_MESH_WRONLY_DRIVER - -*/ - -class MEDMEM_EXPORT MED_MESH_RDWR_DRIVER : public virtual MED_MESH_RDONLY_DRIVER, public virtual MED_MESH_WRONLY_DRIVER { - -public : - - /*! - Constructor. - */ - MED_MESH_RDWR_DRIVER() ; - /*! - Constructor. - */ - MED_MESH_RDWR_DRIVER(const std::string & fileName, GMESH * ptrMesh) ; - /*! - Copy constructor. - */ - MED_MESH_RDWR_DRIVER(const MED_MESH_RDWR_DRIVER & driver) ; - - /*! - Destructor. - */ - ~MED_MESH_RDWR_DRIVER() ; - - /*! - Write MESH in the specified file. - */ - void write(void) const; - /*! - Read MESH in the specified file. - */ - void read (void); - -private: - GENDRIVER * copy(void) const ; - -}; - -} - -#endif /* MED_MESH_DRIVER_HXX */ diff --git a/src/MEDMEM/MEDMEM_MedVersion.cxx b/src/MEDMEM/MEDMEM_MedVersion.cxx deleted file mode 100644 index fa1378294..000000000 --- a/src/MEDMEM/MEDMEM_MedVersion.cxx +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_MedVersion.hxx" -#include "MEDMEM_Utilities.hxx" - -using namespace MEDMEM; -using namespace MED_EN; - -medFileVersion MEDMEM::getMedFileVersion(const string & fileName) - throw (MEDEXCEPTION) -{ - medFileVersion version; - - med_2_3::med_idt fid22; - - med_2_3::med_err ret22; - - med_2_3::med_int major22; - med_2_3::med_int minor22; - med_2_3::med_int release22; - - med_2_3::med_access_mode access22 = med_2_3::MED_ACC_RDONLY; - - /* - Med Version 2.3 access to the file - */ - - fid22 = med_2_3::MEDfileOpen(fileName.c_str(),access22); - - if (fid22 < 0) - throw MEDEXCEPTION("Problem in getMedFileVersion(const string &) Med file V2.2 access"); - - ret22 = med_2_3::MEDfileNumVersionRd(fid22,&major22,&minor22,&release22); - - if (ret22 < 0) - throw MEDEXCEPTION("Problem in getMedFileVersion(const string &) Med file V2.2 version numbers reading"); - - if ((minor22 == -1) || (release22 == -1)) - { - MESSAGE_MED("getMedFileVersion the file may have been produced by a version 2.1.x x<5"); - minor22 = 1; - release22 = 5; - } - - ret22 = med_2_3::MEDfileClose(fid22); - - if (ret22 < 0) - throw MEDEXCEPTION("Problem in getMedFileVersion(const string &) Med file V2.2 file closing"); - - if (major22 == 2) - { - if (minor22 == 1) - version = V21; - else if (minor22 > 1) - version = V22; - } - else - version = V22; - - MESSAGE_MED("getMedFileVersion the version of the file is " << version); - - return version; -} - -med_2_3::med_access_mode MEDMEM::getMedAccessMode(MED_EN::med_mode_acces mode) -{ - //from med.h: - // MED_ACC_RDONLY, /**<Ouverture en lecture seule*/ - // MED_ACC_RDWR, /**<Ouverture en lecture/ecriture, si un élément existe il est écrasé*/ - // MED_ACC_RDEXT, /**<Ouverture en lecture/ecriture, si un élément existe une erreur est générée*/ - // MED_ACC_CREAT, /**<Créer le fichier s'il n'existe pas, l'écrase sinon*/ - // MED_ACC_UNDEF /**<Variable globale interne initialisée au mode d'ouverture*/ - switch ( mode ) { - case MED_EN::RDONLY: return med_2_3::MED_ACC_RDONLY; - case MED_EN::WRONLY: return med_2_3::MED_ACC_CREAT; - case MED_EN::RDWR: return med_2_3::MED_ACC_RDWR; - default: - return med_2_3::med_access_mode( mode ); - } -} diff --git a/src/MEDMEM/MEDMEM_MedVersion.hxx b/src/MEDMEM/MEDMEM_MedVersion.hxx deleted file mode 100644 index 2de188ea4..000000000 --- a/src/MEDMEM/MEDMEM_MedVersion.hxx +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef MED_VERSION_HXX -#define MED_VERSION_HXX - -#include "MEDMEM.hxx" - -#include <string> -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_define.hxx" - -namespace MEDMEM { - - MEDMEM_EXPORT MED_EN::medFileVersion getMedFileVersion(const string & fileName) - throw (MEDEXCEPTION); - - MEDMEM_EXPORT med_2_3::med_access_mode getMedAccessMode(MED_EN::med_mode_acces mode); -} - -#endif /* MED_VERSION_HXX */ diff --git a/src/MEDMEM/MEDMEM_Mesh.cxx b/src/MEDMEM/MEDMEM_Mesh.cxx deleted file mode 100644 index e45cd8411..000000000 --- a/src/MEDMEM/MEDMEM_Mesh.cxx +++ /dev/null @@ -1,1950 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -/* - File Mesh.cxx -*/ - -#include "MEDMEM_DriversDef.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_Mesh.hxx" - -#include "MEDMEM_Support.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Group.hxx" -#include "MEDMEM_Coordinate.hxx" -#include "MEDMEM_Connectivity.hxx" -#include "MEDMEM_CellModel.hxx" -#include "VolSurfFormulae.hxx" -#include "MEDMEM_DriverFactory.hxx" - -#include "PointLocator.hxx" - -#include <math.h> -#include <map> -#include <sstream> - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -#define MED_NOPDT -1 -#define MED_NONOR -1 - -// Block defining groups for the MEDMEM_ug documentation -/*! -\defgroup MESH_constructors MESH Constructors - -The MESH class provides only two constructors : a copy constructor and -a constructor enabling creation from file reading. The creation of -a user-defined mesh implies the use of the MESHING class. - -\defgroup MESH_advanced MESH Advanced features -These functions provide access to high-level manipulation of the meshes, giving -information about the cells or extracting supports from the mesh. - -\defgroup MESH_connectivity MESH Connectivity information -These methods are related to the extraction of connectivity information -from the mesh. - -\defgroup MESH_nodes MESH Nodes information -These methods are related to the extraction of information about the mesh nodes. - -*/ - -void MESH::init() -{ - const char* LOC = "MESH::init(): "; - BEGIN_OF_MED(LOC); - - GMESH::init(); - - delete _coordinate; - _coordinate = (COORDINATE *) NULL; - delete _connectivity; - _connectivity = (CONNECTIVITY *) NULL; - - _numberOfNodes = MED_INVALID; - - _arePresentOptionnalNodesNumbers = 0; - - END_OF_MED(LOC); -} - -/*! Create an empty MESH. */ -MESH::MESH():GMESH(),_coordinate(NULL),_connectivity(NULL) -{ - init(); -} - -/*! \if MEDMEM_ug - \addtogroup MESH_constructors - @{ -\endif -*/ -/*! - Copy constructor -*/ -MESH::MESH(MESH &m): GMESH(m) -{ - if (m._coordinate != NULL) - _coordinate = new COORDINATE(* m._coordinate); - else - _coordinate = (COORDINATE *) NULL; - - if (m._connectivity != NULL) - _connectivity = new CONNECTIVITY(* m._connectivity); - else - _connectivity = (CONNECTIVITY *) NULL; - - _numberOfNodes = m._numberOfNodes; - - _arePresentOptionnalNodesNumbers = m._arePresentOptionnalNodesNumbers; - _optionnalToCanonicNodesNumbers = m._optionnalToCanonicNodesNumbers; -} - -/*! -\if MEDMEM_ug -@} -\endif -*/ - -MESH::~MESH() -{ - MESSAGE_MED("MESH::~MESH() : Destroying the Mesh"); - - if (_coordinate != ((COORDINATE *) NULL)) delete _coordinate ; - if (_connectivity != ((CONNECTIVITY *) NULL)) delete _connectivity ; - _coordinate = 0; - _connectivity = 0; -} - -MESH & MESH::operator=(const MESH &m) -{ - const char* LOC = "MESH & MESH::operator=(const MESH &m) : "; - BEGIN_OF_MED(LOC); - - _name = m._name; - _description = m._description; - - if ( _coordinate ) delete _coordinate; - _coordinate = m._coordinate ? new COORDINATE ( *m._coordinate ) : 0; - if ( _connectivity ) delete _connectivity; - _connectivity = m._connectivity ? new CONNECTIVITY( *m._connectivity ) : 0; - - _spaceDimension = m._spaceDimension; - _numberOfNodes = m._numberOfNodes; - - _arePresentOptionnalNodesNumbers = m._arePresentOptionnalNodesNumbers; - _optionnalToCanonicNodesNumbers = m._optionnalToCanonicNodesNumbers; - - vector<FAMILY*>* fams[4] = { &_familyNode, &_familyCell, &_familyFace, &_familyEdge}; - const vector<FAMILY*>* mfams[4] = { &m._familyNode,&m._familyCell,&m._familyFace,&m._familyEdge }; - for ( int i = 0; i < 4; ++i ) - { - for ( int f = 0; f < fams[i]->size(); ++f ) - fams[i]->at(f)->removeReference(); - fams[i]->clear(); - fams[i]->reserve( mfams[i]->size() ); - for ( int f = 0; f < mfams[i]->size(); ++f ) - { - if ( mfams[i]->at(f) ) - { - fams[i]->push_back( new FAMILY( *mfams[i]->at(f) )); - fams[i]->back()->setMesh( this ); - } - } - } - vector<GROUP*>* groups[4] = { &_groupNode, &_groupCell, &_groupFace, &_groupEdge }; - const vector<GROUP*>* mgroups[4] = { &m._groupNode, &m._groupCell, &m._groupFace, &m._groupEdge }; - for ( int i = 0; i < 4; ++i ) - { - for ( int g = 0; g < groups[i]->size(); ++g ) - groups[i]->at(g)->removeReference(); - groups[i]->clear(); - groups[i]->reserve( mgroups[i]->size() ); - for ( int g = 0; g < mgroups[i]->size(); ++g ) - { - if ( mgroups[i]->at(g) ) - { - groups[i]->push_back( new GROUP( *mgroups[i]->at(g) )); - groups[i]->back()->setMesh( this ); - } - } - } - - for ( int drv = 0; drv < _drivers.size(); ++drv ) - delete _drivers[drv]; - _drivers.clear(); - _drivers.reserve( m._drivers.size()); - for ( int drv = 0; drv < m._drivers.size(); ++drv ) - if ( m._drivers[drv] ) - _drivers.push_back( m._drivers[drv]->copy() ); - - return *this; -} - -bool MESH::operator==(const MESH& other) const -{ - const char* LOC = "MESH::operator=="; - BEGIN_OF_MED(LOC); - return this==&other; -} - -/*!\if MEDMEM_ug -\addtogroup MESH_constructors -@{ -\endif -*/ -/*! - Creates a %MESH object using a %MESH driver of type %driverTypes (MED_DRIVER, GIBI_DRIVER, ...) associated with file \a fileName. As several meshes can coexist in the same file (notably in MED files) , the constructor takes a third argument that specifies the name of the mesh. - The constructor will throw an exception if the file does not exist, has no reading permissions or if the mesh does not exist in the file. -*/ -MESH::MESH(driverTypes driverType, const string & fileName/*=""*/, const string & driverName/*=""*/) throw (MEDEXCEPTION):_coordinate(0),_connectivity(0) -{ - const char * LOC = "MESH::MESH(driverTypes driverType, const string & fileName="", const string & driverName/="") : "; - BEGIN_OF_MED(LOC); - - int current; - init(); - GENDRIVER *myDriver=DRIVERFACTORY::buildDriverForMesh(driverType,fileName,this,driverName,RDONLY); - current = addDriver(*myDriver); - delete myDriver; - try - { - _drivers[current]->open(); - _drivers[current]->read(); - _drivers[current]->close(); - } - catch ( MED_EXCEPTION& e ) - { - if ( _drivers[current] ) - _drivers[current]->close(), delete _drivers[current]; - _drivers[current] = 0; - throw e; - } - - END_OF_MED(LOC); -} -/*!\if MEDMEM_ug - @} -\endif -*/ - -/*! - Returns true if mesh \a other has same - coordinates (to 1E-15 precision ) and same connectivity as the calling object. - Information like name or description is not taken into account - for the comparison. -*/ - -bool MESH::deepCompare(const GMESH& gother) const -{ - if ( gother.getIsAGrid() != getIsAGrid()) - return false; - const MESH& other = static_cast<const MESH&>( gother ); - - int size1=getSpaceDimension()*getNumberOfNodes(); - int size2=other.getSpaceDimension()*other.getNumberOfNodes(); - if(size1!=size2) - return false; - - const COORDINATE* CRD = other.getCoordinateptr(); - if( (!CRD && _coordinate) || (CRD && !(_coordinate)) ) { - return false; - } - - bool ret=true; - if( _coordinate ) { - const double* coord1=getCoordinates(MED_FULL_INTERLACE); - const double* coord2=other.getCoordinates(MED_FULL_INTERLACE); - for(int i=0;i<size1 && ret;i++) { - ret=(fabs(coord1[i]-coord2[i])<1e-15); - } - } - if(ret) { - const CONNECTIVITY* CNV = other.getConnectivityptr(); - if( (!CNV && _connectivity) || (CNV && !(_connectivity)) ) { - return false; - } - if(_connectivity) { - return _connectivity->deepCompare(*other._connectivity); - } - } - return ret; -} - -/*! - * \brief print my contents - */ -ostream & ::MEDMEM::operator<<(ostream &os, const MESH &myMesh) -{ - myMesh.printMySelf(os); - return os; -} -void MESH::printMySelf(ostream &os) const -{ - const MESH &myMesh = *this; - int spacedimension = myMesh.getSpaceDimension(); - int meshdimension = myMesh.getMeshDimension(); - int numberofnodes = myMesh.getNumberOfNodes(); - - if ( spacedimension == MED_INVALID ) { - os << " Empty mesh ..."; - return; - } - - os << "Space Dimension : " << spacedimension << endl << endl; - - os << "Mesh Dimension : " << meshdimension << endl << endl; - - if(myMesh.getCoordinateptr()) { - const double * coordinates = myMesh.getCoordinates(MED_FULL_INTERLACE); - - os << "SHOW NODES COORDINATES : " << endl; - os << "Name :" << endl; - const string * coordinatesnames = myMesh.getCoordinatesNames(); - if ( coordinatesnames ) { - for(int i=0; i<spacedimension ; i++) - { - os << " - " << coordinatesnames[i] << endl; - } - } - os << "Unit :" << endl; - const string * coordinatesunits = myMesh.getCoordinatesUnits(); - if ( coordinatesunits ) { - for(int i=0; i<spacedimension ; i++) - { - os << " - " << coordinatesunits[i] << endl; - } - } - for(int i=0; i<numberofnodes ; i++) - { - os << "Nodes " << i+1 << " : "; - for (int j=0; j<spacedimension ; j++) - os << coordinates[i*spacedimension+j] << " "; - os << endl; - } - } - - if(myMesh.getConnectivityptr()) { - os << endl << "SHOW CONNECTIVITY :" << endl; - os << *myMesh._connectivity << endl; - } - - medEntityMesh entity; - os << endl << "SHOW FAMILIES :" << endl << endl; - for (int k=1; k<=4; k++) - { - if (k==1) entity = MED_NODE; - if (k==2) entity = MED_CELL; - if (k==3) entity = MED_FACE; - if (k==4) entity = MED_EDGE; - int numberoffamilies = myMesh.getNumberOfFamilies(entity); - os << "NumberOfFamilies on "<< entNames[entity] <<" : "<<numberoffamilies<<endl; - using namespace MED_EN; - for (int i=1; i<numberoffamilies+1;i++) - { - os << * myMesh.getFamily(entity,i) << endl; - } - } - - os << endl << "SHOW GROUPS :" << endl << endl; - for (int k=1; k<=4; k++) - { - if (k==1) entity = MED_NODE; - if (k==2) entity = MED_CELL; - if (k==3) entity = MED_FACE; - if (k==4) entity = MED_EDGE; - int numberofgroups = myMesh.getNumberOfGroups(entity); - os << "NumberOfGroups on "<< entNames[entity] <<" : "<<numberofgroups<<endl; - using namespace MED_EN; - for (int i=1; i<numberofgroups+1;i++) - { - os << * myMesh.getGroup(entity,i) << endl; - } - } -} - -/*! \if MEDMEM_ug -\addtogroup MESH_general -@{ -\endif -*/ -/*! Gets the dimension of the mesh (2 for 2D- and 3D-surfaces, 3 for volumes). */ -int MESH::getMeshDimension() const -{ - int dim = -1; - if ( _connectivity ) - for ( int i = 0; i < _connectivity->getNumberOfTypes(MED_EN::MED_CELL); ++i ) - if ( _connectivity->getCellsTypes(MED_EN::MED_CELL)[i].getDimension() > dim ) - dim = _connectivity->getCellsTypes(MED_EN::MED_CELL)[i].getDimension(); - return dim; -} -/*! \if MEDMEM_ug @} \endif */ - -/*! - Get global number of element which have same connectivity than connectivity argument. - - It do not take care of connectivity order (3,4,7,10 is same as 7,3,10,4). - - Return -1 if not found. -*/ -int MESH::getElementNumber(MED_EN::medConnectivity ConnectivityType, - MED_EN::medEntityMesh Entity, - MED_EN::medGeometryElement Type, - int * connectivity) const -{ - const char* LOC="MESH::getElementNumber " ; - BEGIN_OF_MED(LOC) ; - - int numberOfValue ; // size of connectivity array - CELLMODEL myType(Type) ; - if (ConnectivityType==MED_DESCENDING) - numberOfValue = myType.getNumberOfConstituents(1) ; // faces (3D) or edges (2D) - else - numberOfValue = myType.getNumberOfNodes() ; // nodes - - const int * myReverseConnectivityValue = getReverseConnectivity(ConnectivityType,Entity) ; - const int * myReverseConnectivityIndex = getReverseConnectivityIndex(ConnectivityType,Entity) ; - - // First node or face/edge - int indexBegin = myReverseConnectivityIndex[connectivity[0]-1] ; - int indexEnd = myReverseConnectivityIndex[connectivity[0]] ; - - // list to put cells numbers - list<int> cellsList ; - list<int>::iterator itList ; - for (int i=indexBegin; i<indexEnd; i++) - cellsList.push_back(myReverseConnectivityValue[i-1]) ; - - // Foreach node or face/edge in cell, we search cells which are in common. - // At the end, we must have only one ! - - for (int i=1; i<numberOfValue; i++) { - int connectivity_i = connectivity[i] ; - for (itList=cellsList.begin();itList!=cellsList.end();/*itList++*/) { - bool find = false ; - for (int j=myReverseConnectivityIndex[connectivity_i-1]; j<myReverseConnectivityIndex[connectivity_i]; j++) { - if ((*itList)==myReverseConnectivityValue[j-1]) { - find=true ; - break ; - } - } - if (!find) - itList=cellsList.erase(itList++); - else - itList++; - } - } - - if (cellsList.size()>1) // we have more than one cell - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Found more than one element !")) ; - - if (cellsList.size()==0) - return -1; - - END_OF_MED(LOC); - - return cellsList.front() ; -} - -/*! -\addtogroup MESH_advanced -@{ -The methods described in this section are algorithms that perform a computation -and return a result in the form of a SUPPORT or a FIELD to the user. For large meshes, -as the returned information is not stored in the mesh but is rather computed, the -computation time can be large. -*/ - -/*! - Returns a support which reference all elements on the boundary of mesh. - For a d-dimensional mesh, a boundary element is defined as a d-1 dimension - element that is referenced by only one element in the full descending connectivity. - - This method can also return the list of nodes that belong to the boundary elements. - - WARNING: This method can recalculate descending connectivity from partial to full form, - so that partial SUPPORT on d-1 dimension elements becomes invalid. - - \param Entity entity on which the boundary is desired. It has to be either \a MED_NODE or the - d-1 dimension entity type (MED_FACE in 3D, MED_EDGE in 2D). -*/ -SUPPORT * MESH::getBoundaryElements(MED_EN::medEntityMesh Entity) const throw (MEDEXCEPTION) -{ - const char * LOC = "MESH::getBoundaryElements : " ; - BEGIN_OF_MED(LOC) ; - // some test : - // actually we could only get face (in 3D) and edge (in 2D) - medEntityMesh entityToParse=Entity; - if(_spaceDimension == 3) - if (Entity != MED_FACE) - { - if(Entity==MED_NODE) - entityToParse=MED_FACE; - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined in 3D mesh for entity "<<Entity<<" !")); - } - if(_spaceDimension == 2) - if(Entity != MED_EDGE) - { - if(Entity==MED_NODE) - entityToParse=MED_EDGE; - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined in 2D mesh for entity "<<Entity<<" !")); - } - - // assure that descending connectivity is full - if ( !_connectivity ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< "no connectivity defined in MESH !")); - _connectivity->calculateFullDescendingConnectivity(MED_CELL); - - const int * myConnectivityValue = getReverseConnectivity(MED_DESCENDING) ; - const int * myConnectivityIndex = getReverseConnectivityIndex(MED_DESCENDING) ; - int numberOf = getNumberOfElements(entityToParse,MED_ALL_ELEMENTS) ; - list<int> myElementsList; - - for (int i=0 ; i<numberOf; i++) - if (myConnectivityValue[myConnectivityIndex[i]] == 0) - myElementsList.push_back(i+1); - - if ( myElementsList.empty() && numberOf != 0 ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"No boundary elements found by reverse descending connectivity for entity "<<Entity<<" !")); - - if(Entity==MED_NODE) - return buildSupportOnNodeFromElementList(myElementsList,entityToParse); - else - return buildSupportOnElementsFromElementList(myElementsList,entityToParse); -} -/*! - @} -*/ - -/*! - Method that do the same thing as buildSupportOnNodeFromElementList except that a SUPPORT is not created. -*/ -void MESH::fillSupportOnNodeFromElementList(const list<int>& listOfElt, SUPPORT *supportToFill) const throw (MEDEXCEPTION) -{ - MED_EN::medEntityMesh entity=supportToFill->getEntity(); - supportToFill->setAll(false); - supportToFill->setMesh((MESH *)this); - - set<int> nodes; - if ( entity == MED_NODE ) - { - supportToFill->fillFromNodeList(listOfElt); - } - else - { - int lgth; - for(list<int>::const_iterator iter=listOfElt.begin();iter!=listOfElt.end();iter++) - { - const int *conn=_connectivity->getConnectivityOfAnElement(MED_NODAL,entity,*iter,lgth); - nodes.insert( conn, conn+lgth ); - } - list<int> nodesList( nodes.begin(), nodes.end() ); - supportToFill->fillFromNodeList( nodesList ); - } -} - -/*! - Method created to factorize code. This method creates a new support on NODE (to deallocate) containing all the nodes id contained in elements 'listOfElt' of - entity 'entity'. -*/ -SUPPORT *MESH::buildSupportOnNodeFromElementList(const list<int>& listOfElt,MED_EN::medEntityMesh entity) const throw (MEDEXCEPTION) -{ - SUPPORT * mySupport = new SUPPORT; - mySupport->setMesh((MESH *)this); - mySupport->setName("Boundary"); - mySupport->setEntity( entity ); - fillSupportOnNodeFromElementList(listOfElt,mySupport); - return mySupport; -} - -/*! -\addtogroup MESH_advanced -@{ -*/ -/*! Retrieves the volume of all the elements contained in \a Support. This method returns - a FIELD structure based on this support. It only works on MED_CELL for 3D meshes. -*/ -FIELD<double, FullInterlace>* MESH::getVolume(const SUPPORT *Support, bool isAbs) const throw (MEDEXCEPTION) -{ - const char * LOC = "MESH::getVolume(SUPPORT*) : "; - BEGIN_OF_MED(LOC); - - // Support must be on 3D elements - - // Make sure that the MESH class is the same as the MESH class attribut - // in the class Support - const GMESH* myMesh = Support->getMesh(); - if (this != myMesh) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh !")); - - int dim_space = getSpaceDimension(); - medEntityMesh support_entity = Support->getEntity(); - bool onAll = Support->isOnAllElements(); - - int nb_type, length_values; - const medGeometryElement* types; - int nb_entity_type; - // !!!! WARNING : use of nodal global numbering in the mesh !!!! - const int* global_connectivity; - nb_type = Support->getNumberOfTypes(); - length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS); - types = Support->getTypes(); - int index; - FIELD<double, FullInterlace>* Volume = - new FIELD<double, FullInterlace>(Support,1); - Volume->setName("VOLUME"); - Volume->setDescription("cells volume"); - Volume->setComponentName(1,"volume"); - Volume->setComponentDescription(1,"desc-comp"); - - string MEDComponentUnit = myMesh->getCoordinatesUnits()[0]+"*"+myMesh->getCoordinatesUnits()[1]+"*"+myMesh->getCoordinatesUnits()[2]; - - Volume->setMEDComponentUnit(1,MEDComponentUnit); - - Volume->setIterationNumber(0); - Volume->setOrderNumber(0); - Volume->setTime(0.0); - - typedef MEDMEM_ArrayInterface<double,FullInterlace,NoGauss>::Array ArrayNoGauss; - ArrayNoGauss *volume = Volume->getArrayNoGauss(); - - index = 1; - const double * coord = getCoordinates(MED_FULL_INTERLACE); - - for (int i=0;i<nb_type;i++) - { - medGeometryElement type = types[i] ; - double xvolume; - nb_entity_type = Support->getNumberOfElements(type); - if(type != MED_EN::MED_POLYHEDRA) - { - if (onAll) - { - global_connectivity = getConnectivity(MED_NODAL,support_entity,type); - } - else - { - const int * supp_number = Support->getNumber(type); - const int * connectivity = getConnectivity(MED_NODAL,support_entity,MED_ALL_ELEMENTS); - const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity); - int * global_connectivity_tmp = new int[(type%100)*nb_entity_type]; - - for (int k_type = 0; k_type<nb_entity_type; k_type++) { - for (int j_ent = 0; j_ent<(type%100); j_ent++) { - global_connectivity_tmp[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1]; - } - } - global_connectivity = global_connectivity_tmp ; - } - } - - switch (type) - { - case MED_TETRA4 : case MED_TETRA10 : - { - for (int tetra=0;tetra<nb_entity_type;tetra++) - { - int tetra_index = (type%100)*tetra; - int N1 = global_connectivity[tetra_index]-1; - int N2 = global_connectivity[tetra_index+1]-1; - int N3 = global_connectivity[tetra_index+2]-1; - int N4 = global_connectivity[tetra_index+3]-1; - xvolume=INTERP_KERNEL::calculateVolumeForTetra(coord+dim_space*N1,coord+dim_space*N2,coord+dim_space*N3,coord+dim_space*N4); - if(isAbs) - xvolume=fabs(xvolume); - volume->setIJ(index,1,xvolume) ; - index++; - } - break; - } - case MED_PYRA5 : case MED_PYRA13 : - { - for (int pyra=0;pyra<nb_entity_type;pyra++) - { - int pyra_index = (type%100)*pyra; - int N1 = global_connectivity[pyra_index]-1; - int N2 = global_connectivity[pyra_index+1]-1; - int N3 = global_connectivity[pyra_index+2]-1; - int N4 = global_connectivity[pyra_index+3]-1; - int N5 = global_connectivity[pyra_index+4]-1; - xvolume=INTERP_KERNEL::calculateVolumeForPyra(coord+dim_space*N1,coord+dim_space*N2,coord+dim_space*N3,coord+dim_space*N4,coord+dim_space*N5); - if(isAbs) - xvolume=fabs(xvolume); - volume->setIJ(index,1,xvolume) ; - index++; - } - break; - } - case MED_PENTA6 : case MED_PENTA15 : - { - for (int penta=0;penta<nb_entity_type;penta++) - { - int penta_index = (type%100)*penta; - int N1 = global_connectivity[penta_index]-1; - int N2 = global_connectivity[penta_index+1]-1; - int N3 = global_connectivity[penta_index+2]-1; - int N4 = global_connectivity[penta_index+3]-1; - int N5 = global_connectivity[penta_index+4]-1; - int N6 = global_connectivity[penta_index+5]-1; - xvolume=INTERP_KERNEL::calculateVolumeForPenta(coord+dim_space*N1,coord+dim_space*N2,coord+dim_space*N3,coord+dim_space*N4,coord+dim_space*N5,coord+dim_space*N6); - if(isAbs) - xvolume=fabs(xvolume); - volume->setIJ(index,1,xvolume) ; - index++; - } - break; - } - case MED_HEXA8 : case MED_HEXA20 : - { - for (int hexa=0;hexa<nb_entity_type;hexa++) - { - int hexa_index = (type%100)*hexa; - - int N1 = global_connectivity[hexa_index]-1; - int N2 = global_connectivity[hexa_index+1]-1; - int N3 = global_connectivity[hexa_index+2]-1; - int N4 = global_connectivity[hexa_index+3]-1; - int N5 = global_connectivity[hexa_index+4]-1; - int N6 = global_connectivity[hexa_index+5]-1; - int N7 = global_connectivity[hexa_index+6]-1; - int N8 = global_connectivity[hexa_index+7]-1; - xvolume=INTERP_KERNEL::calculateVolumeForHexa(coord+dim_space*N1,coord+dim_space*N2,coord+dim_space*N3,coord+dim_space*N4,coord+dim_space*N5,coord+dim_space*N6,coord+dim_space*N7,coord+dim_space*N8); - if(isAbs) - xvolume=fabs(xvolume); - volume->setIJ(index,1,xvolume) ; - index++; - } - break; - } - case MED_POLYHEDRA: - { - double bary[3]; - if(onAll) - { - for (int polyhs=0;polyhs<nb_entity_type;polyhs++) - { - int lgthNodes,iPts,iFaces,iPtsInFace; - int offsetWithClassicType=getGlobalNumberingIndex(support_entity)[i]-1; - int *nodes=_connectivity->getNodesOfPolyhedron(offsetWithClassicType+polyhs+1,lgthNodes); - int nbOfFaces,*nbOfNodesPerFaces; - int **nodes1=_connectivity->getNodesPerFaceOfPolyhedron(offsetWithClassicType+polyhs+1,nbOfFaces,nbOfNodesPerFaces); - double **pts=new double * [lgthNodes]; - double ***pts1=new double ** [nbOfFaces]; - for(iPts=0;iPts<lgthNodes;iPts++) - pts[iPts]=(double *)(coord+3*(nodes[iPts]-1)); - for(iFaces=0;iFaces<nbOfFaces;iFaces++) - { - pts1[iFaces]=new double* [nbOfNodesPerFaces[iFaces]]; - for(iPtsInFace=0;iPtsInFace<nbOfNodesPerFaces[iFaces];iPtsInFace++) - pts1[iFaces][iPtsInFace]=(double *)(coord+3*(nodes1[iFaces][iPtsInFace]-1)); - } - delete [] nodes1; - INTERP_KERNEL::calculateBarycenterDyn((const double **)pts,lgthNodes,3,bary); - delete [] nodes; - delete [] pts; - if(isAbs) - xvolume=INTERP_KERNEL::calculateVolumeForPolyhAbs((const double ***)pts1,nbOfNodesPerFaces,nbOfFaces,bary); - else - xvolume=INTERP_KERNEL::calculateVolumeForPolyh((const double ***)pts1,nbOfNodesPerFaces,nbOfFaces,bary); - delete [] nbOfNodesPerFaces; - for(iFaces=0;iFaces<nbOfFaces;iFaces++) - delete [] pts1[iFaces]; - delete [] pts1; - volume->setIJ(index,1,xvolume) ; - index++; - } - } - else - { - const int * supp_number = Support->getNumber(MED_EN::MED_POLYHEDRA); - for (int polyhs=0;polyhs<nb_entity_type;polyhs++) - { - int lgthNodes,iPts,iFaces,iPtsInFace; - int *nodes=_connectivity->getNodesOfPolyhedron(supp_number[polyhs],lgthNodes); - int nbOfFaces,*nbOfNodesPerFaces; - int **nodes1=_connectivity->getNodesPerFaceOfPolyhedron(supp_number[polyhs],nbOfFaces,nbOfNodesPerFaces); - double **pts=new double * [lgthNodes]; - double ***pts1=new double ** [nbOfFaces]; - for(iPts=0;iPts<lgthNodes;iPts++) - pts[iPts]=(double *)(coord+3*(nodes[iPts]-1)); - for(iFaces=0;iFaces<nbOfFaces;iFaces++) - { - pts1[iFaces]=new double* [nbOfNodesPerFaces[iFaces]]; - for(iPtsInFace=0;iPtsInFace<nbOfNodesPerFaces[iFaces];iPtsInFace++) - pts1[iFaces][iPtsInFace]=(double *)(coord+3*(nodes1[iFaces][iPtsInFace]-1)); - } - delete [] nodes1; - INTERP_KERNEL::calculateBarycenterDyn((const double **)pts,lgthNodes,3,bary); - delete [] nodes; - delete [] pts; - if(isAbs) - xvolume=INTERP_KERNEL::calculateVolumeForPolyhAbs((const double ***)pts1,nbOfNodesPerFaces,nbOfFaces,bary); - else - xvolume=INTERP_KERNEL::calculateVolumeForPolyh((const double ***)pts1,nbOfNodesPerFaces,nbOfFaces,bary); - delete [] nbOfNodesPerFaces; - for(iFaces=0;iFaces<nbOfFaces;iFaces++) - delete [] pts1[iFaces]; - delete [] pts1; - volume->setIJ(index,1,xvolume) ; - index++; - } - } - break; - } - default : - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get Volumes on it !")); - break; - } - - if (!onAll && type!=MED_EN::MED_POLYHEDRA) - delete [] global_connectivity ; - } - - return Volume; -} -/*! Retrieves the area of all the elements contained in \a Support. This method returns - a FIELD structure based on this support. It only works on MED_CELL for 2D meshes or MED_FACE - for 3D meshes. -*/ - -FIELD<double, FullInterlace>* MESH::getArea(const SUPPORT * Support) const throw (MEDEXCEPTION) -{ - const char * LOC = "MESH::getArea(SUPPORT*) : "; - BEGIN_OF_MED(LOC); - - // Support must be on 2D elements - - // Make sure that the MESH class is the same as the MESH class attribut - // in the class Support - const GMESH* myMesh = Support->getMesh(); - if (this != myMesh) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh !")); - - int dim_space = getSpaceDimension(); - medEntityMesh support_entity = Support->getEntity(); - bool onAll = Support->isOnAllElements(); - - int nb_type, length_values; - const medGeometryElement* types; - int nb_entity_type; - // !!!! WARNING : use of nodal global numbering in the mesh !!!! - const int* global_connectivity; - - nb_type = Support->getNumberOfTypes(); - length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS); - types = Support->getTypes(); - - int index; - FIELD<double, FullInterlace>* Area; - - Area = new FIELD<double, FullInterlace>(Support,1); - Area->setName("AREA"); - Area->setDescription("cells or faces area"); - - Area->setComponentName(1,"area"); - Area->setComponentDescription(1,"desc-comp"); - - /* string MEDComponentUnit = myMesh->getCoordinatesUnits()[0]+"*"+myMesh->getCoordinatesUnits()[1];*/ - - string MEDComponentUnit="trucmuch"; - - Area->setMEDComponentUnit(1,MEDComponentUnit); - - Area->setIterationNumber(0); - Area->setOrderNumber(0); - Area->setTime(0.0); - - double *area = (double *)Area->getValue(); - - const double * coord = getCoordinates(MED_FULL_INTERLACE); - index = 0; - - for (int i=0;i<nb_type;i++) - { - medGeometryElement type = types[i] ; - nb_entity_type = Support->getNumberOfElements(type); - const int *global_connectivityIndex = 0; - if(type != MED_EN::MED_POLYGON && type != MED_EN::MED_POLYHEDRA) - { - global_connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity); - if (onAll) - { - global_connectivity = getConnectivity(MED_NODAL,support_entity,type); - } - else - { - const int * supp_number = Support->getNumber(type); - const int * connectivity = getConnectivity(MED_NODAL,support_entity,MED_ALL_ELEMENTS); - int * global_connectivity_tmp = new int[(type%100)*nb_entity_type]; - - for (int k_type = 0; k_type<nb_entity_type; k_type++) { - for (int j_ent = 0; j_ent<(type%100); j_ent++) { - global_connectivity_tmp[k_type*(type%100)+j_ent] = connectivity[global_connectivityIndex[supp_number[k_type]-1]+j_ent-1]; - } - } - global_connectivity = global_connectivity_tmp ; - } - } - switch (type) - { - case MED_TRIA3 : case MED_TRIA6 : - { - for (int tria=0;tria<nb_entity_type;tria++) - { - int tria_index = (type%100)*tria; - - int N1 = global_connectivity[tria_index]-1; - int N2 = global_connectivity[tria_index+1]-1; - int N3 = global_connectivity[tria_index+2]-1; - - area[index]=INTERP_KERNEL::calculateAreaForTria(coord+(dim_space*N1), - coord+(dim_space*N2), - coord+(dim_space*N3),dim_space); - index++; - } - break; - } - case MED_QUAD4 : case MED_QUAD8 : - { - for (int quad=0;quad<nb_entity_type;quad++) - { - int quad_index = (type%100)*quad; - - int N1 = global_connectivity[quad_index]-1; - int N2 = global_connectivity[quad_index+1]-1; - int N3 = global_connectivity[quad_index+2]-1; - int N4 = global_connectivity[quad_index+3]-1; - - area[index]=INTERP_KERNEL::calculateAreaForQuad(coord+dim_space*N1, - coord+dim_space*N2, - coord+dim_space*N3, - coord+dim_space*N4,dim_space); - index++; - } - break; - } - case MED_POLYGON : - { - if(onAll) - { - int offsetWithClassicType=getGlobalNumberingIndex(support_entity)[i]-1; - const int * connectivity = _connectivity->getConnectivity(MED_NODAL,support_entity,MED_ALL_ELEMENTS); - const int * connectivity_index = _connectivity->getConnectivityIndex(MED_EN::MED_NODAL,support_entity) + offsetWithClassicType; - for (int polygs=0;polygs<nb_entity_type;polygs++) - { - int size=connectivity_index[polygs+1]-connectivity_index[polygs]; - double **pts=new double * [size]; - for(int iPts=0;iPts<size;iPts++) - pts[iPts]=(double *)(coord+dim_space*(connectivity[connectivity_index[polygs]+iPts-1]-1)); - area[index] = INTERP_KERNEL::calculateAreaForPolyg((const double **)pts,size,dim_space); - delete [] pts; - index++; - } - } - else - { - const int * supp_number = Support->getNumber(MED_EN::MED_POLYGON); - const int * connectivity = _connectivity->getConnectivity(MED_NODAL,support_entity,MED_ALL_ELEMENTS); - const int * connectivity_index = _connectivity->getConnectivityIndex(MED_EN::MED_NODAL,support_entity); - for (int polygs=0;polygs<nb_entity_type;polygs++) - { - int size=connectivity_index[supp_number[polygs]]-connectivity_index[supp_number[polygs]-1]; - double **pts=new double * [size]; - for(int iPts=0;iPts<size;iPts++) - pts[iPts]=(double *)(coord+dim_space*(connectivity[connectivity_index[supp_number[polygs]-1]+iPts-1]-1)); - area[index]=INTERP_KERNEL::calculateAreaForPolyg((const double **)pts,size,dim_space); - delete [] pts; - index++; - } - } - break; - } - default : - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get Areas on it !")); - break; - } - - if (!onAll) - if(type != MED_EN::MED_POLYGON && type != MED_EN::MED_POLYHEDRA) - delete [] global_connectivity ; - } - return Area; -} -/*! Retrieves the length of all the elements contained in \a Support. This method returns - a FIELD structure based on this support. It only works on MED_EDGE supports. -*/ -FIELD<double, FullInterlace>* MESH::getLength(const SUPPORT * Support) const throw (MEDEXCEPTION) -{ - const char * LOC = "MESH::getLength(SUPPORT*) : "; - BEGIN_OF_MED(LOC); - - // Support must be on 1D elements - - // Make sure that the MESH class is the same as the MESH class attribut - // in the class Support - const GMESH* myMesh = Support->getMesh(); - if (this != myMesh) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh !")); - - int dim_space = getSpaceDimension(); - medEntityMesh support_entity = Support->getEntity(); - bool onAll = Support->isOnAllElements(); - - int nb_type, length_values; - const medGeometryElement* types; - int nb_entity_type; - // !!!! WARNING : use of nodal global numbering in the mesh !!!! - const int* global_connectivity; - - nb_type = Support->getNumberOfTypes(); - length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS); - types = Support->getTypes(); - - int index; - FIELD<double, FullInterlace>* Length; - - Length = new FIELD<double, FullInterlace>(Support,1); - - typedef MEDMEM_ArrayInterface<double,FullInterlace,NoGauss>::Array ArrayNoGauss; - ArrayNoGauss * length = Length->getArrayNoGauss(); - - const double * coord = getCoordinates(MED_FULL_INTERLACE); - index = 1; - - for (int i=0;i<nb_type;i++) - { - medGeometryElement type = types[i] ; - double xlength; - - if (onAll) - { - nb_entity_type = getNumberOfElements(support_entity,type); - global_connectivity = getConnectivity(MED_NODAL,support_entity,type); - } - else - { - nb_entity_type = Support->getNumberOfElements(type); - const int * supp_number = Support->getNumber(type); - const int * connectivity = getConnectivity(MED_NODAL,support_entity,MED_ALL_ELEMENTS); - const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity); - int* global_connectivity_tmp = new int[(type%100)*nb_entity_type]; - - for (int k_type = 0; k_type<nb_entity_type; k_type++) { - for (int j_ent = 0; j_ent<(type%100); j_ent++) { - global_connectivity_tmp[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1]; - } - } - global_connectivity = global_connectivity_tmp ; - } - - switch (type) - { - case MED_SEG2 : case MED_SEG3 : - { - for (int edge=0;edge<nb_entity_type;edge++) - { - int edge_index = (type%100)*edge; - - int N1 = global_connectivity[edge_index]-1; - int N2 = global_connectivity[edge_index+1]-1; - - double x1 = coord[dim_space*N1]; - double x2 = coord[dim_space*N2]; - - double y1 = coord[dim_space*N1+1]; - double y2 = coord[dim_space*N2+1]; - - double z1, z2 ; z1 = 0.0 ; z2 = 0.0 ; if (dim_space==3) { - z1 = coord[dim_space*N1+2]; z2 = coord[dim_space*N2+2];} - - xlength = sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2) + - (z1 - z2)*(z1 - z2)); - - length->setIJ(index,1,xlength) ; - index++; - } - break; - } - default : - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get Lengths on it !")); - break; - } - - if (!onAll) delete [] global_connectivity ; - } - - return Length; -} - -/*! Retrieves the normal for all elements contained in SUPPORT \a Support. - The method is only functional for 2D supports for 3D meshes and 1D supports - for 2D meshes. It returns - a FIELD for which the number of components is equal to the dimension of the - mesh and which represents coordinates of the vector normal to the element. - The direction of the vector is undetermined. -*/ -FIELD<double, FullInterlace>* MESH::getNormal(const SUPPORT * Support) const throw (MEDEXCEPTION) -{ - const char * LOC = "MESH::getNormal(SUPPORT*) : "; - BEGIN_OF_MED(LOC); - - // Support must be on 2D or 1D elements - - // Make sure that the MESH class is the same as the MESH class attribut - // in the class Support - const GMESH* myMesh = Support->getMesh(); - if (this != myMesh) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh : pointeur problem !")); - - int dim_space = getSpaceDimension(); - int mesh_dim=getMeshDimension(); - medEntityMesh support_entity = Support->getEntity(); - bool onAll = Support->isOnAllElements(); - - if( support_entity!=MED_EDGE && (mesh_dim!=1 || support_entity!=MED_CELL) && ( mesh_dim!=2 || support_entity!=MED_CELL ) && ( mesh_dim!=3 || support_entity!=MED_FACE )) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"incompatible mesh dimension and entity")); - int nb_type, length_values; - const medGeometryElement* types; - int nb_entity_type; - // !!!! WARNING : use of nodal global numbering in the mesh !!!! - const int* global_connectivity; - - nb_type = Support->getNumberOfTypes(); - length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS); - types = Support->getTypes(); - - int index; - - FIELD<double, FullInterlace>* Normal = - new FIELD<double, FullInterlace>(Support,dim_space); - Normal->setName("NORMAL"); - Normal->setDescription("cells or faces normal"); - for (int k=1;k<=dim_space;k++) { - Normal->setComponentName(k,"normal"); - Normal->setComponentDescription(k,"desc-comp"); - Normal->setMEDComponentUnit(k,"unit"); - } - - Normal->setIterationNumber(MED_NOPDT); - Normal->setOrderNumber(MED_NONOR); - Normal->setTime(0.0); - double *normal = (double *)Normal->getValue(); - - const double * coord = getCoordinates(MED_FULL_INTERLACE); - index = 0; - - for (int i=0;i<nb_type;i++) - { - medGeometryElement type = types[i] ; - nb_entity_type = Support->getNumberOfElements(type); - - // Make sure we trying to get Normals on - // TRIA3 or TRIA6 or QUAD4 QUAD8 (2D) cells on a 3D mesh - // or on SEG2 or SEG3 (1D) cells on a 2D mesh - - if ( (((type==MED_TRIA3) || (type==MED_TRIA6) || - (type==MED_QUAD4) || (type==MED_QUAD8) || (type==MED_POLYGON)) && - (dim_space != 3)) || (((type==MED_SEG2) || (type==MED_SEG3)) && - (dim_space != 2)) ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh : dimension problem !")); - if(type != MED_EN::MED_POLYGON && type != MED_EN::MED_POLYHEDRA) - { - if (onAll) - { - global_connectivity = getConnectivity(MED_NODAL,support_entity,type); - } - else - { - const int * supp_number = Support->getNumber(type); - const int * connectivity = getConnectivity(MED_NODAL,support_entity,MED_ALL_ELEMENTS); - const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity); - int * global_connectivity_tmp = new int[(type%100)*nb_entity_type]; - - for (int k_type = 0; k_type<nb_entity_type; k_type++) { - for (int j_ent = 0; j_ent<(type%100); j_ent++) { - global_connectivity_tmp[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1]; - } - } - - global_connectivity = global_connectivity_tmp ; - } - } - - switch (type) - { - case MED_TRIA3 : case MED_TRIA6 : - { - for (int tria=0;tria<nb_entity_type;tria++) - { - int tria_index = (type%100)*tria; - int N1 = global_connectivity[tria_index]-1; - int N2 = global_connectivity[tria_index+1]-1; - int N3 = global_connectivity[tria_index+2]-1; - INTERP_KERNEL::calculateNormalForTria(coord+dim_space*N1,coord+dim_space*N2,coord+dim_space*N3,normal+3*index); - index++; - } - break; - } - case MED_QUAD4 : case MED_QUAD8 : - { - for (int quad=0;quad<nb_entity_type;quad++) - { - int quad_index = (type%100)*quad; - int N1 = global_connectivity[quad_index]-1; - int N2 = global_connectivity[quad_index+1]-1; - int N3 = global_connectivity[quad_index+2]-1; - int N4 = global_connectivity[quad_index+3]-1; - INTERP_KERNEL::calculateNormalForQuad(coord+dim_space*N1,coord+dim_space*N2,coord+dim_space*N3,coord+dim_space*N4,normal+3*index); - index++; - } - break; - } - case MED_SEG2 : case MED_SEG3 : - { - double xnormal1, xnormal2; - for (int edge=0;edge<nb_entity_type;edge++) - { - int edge_index = (type%100)*edge; - - int N1 = global_connectivity[edge_index]-1; - int N2 = global_connectivity[edge_index+1]-1; - - double x1 = coord[dim_space*N1]; - double x2 = coord[dim_space*N2]; - - double y1 = coord[dim_space*N1+1]; - double y2 = coord[dim_space*N2+1]; - - xnormal1 = -(y2-y1); - xnormal2 = x2-x1; - - normal[2*index] = xnormal1 ; - normal[2*index+1] = xnormal2 ; - - index++; - } - break; - } - case MED_POLYGON : - { - if(onAll) - { - int offsetWithClassicType=getGlobalNumberingIndex(support_entity)[i]-1; - const int * connectivity = _connectivity->getConnectivity(MED_NODAL,support_entity,MED_ALL_ELEMENTS); - const int * connectivity_index = _connectivity->getConnectivityIndex(MED_EN::MED_NODAL,support_entity) + offsetWithClassicType; - for (int polygs=0;polygs<nb_entity_type;polygs++) - { - int size=connectivity_index[polygs+1]-connectivity_index[polygs]; - double **pts=new double * [size]; - for(int iPts=0;iPts<size;iPts++) - pts[iPts]=(double *)(coord+dim_space*(connectivity[connectivity_index[polygs]+iPts-1])-1); - INTERP_KERNEL::calculateNormalForPolyg((const double **)pts,size,normal+3*index); - delete [] pts; - index++; - } - } - else - { - const int * supp_number = Support->getNumber(MED_EN::MED_POLYGON); - const int * connectivity = _connectivity->getConnectivity(MED_NODAL,support_entity,MED_ALL_ELEMENTS); - const int * connectivity_index = _connectivity->getConnectivityIndex(MED_EN::MED_NODAL,support_entity); - for (int polygs=0;polygs<nb_entity_type;polygs++) - { - int size=connectivity_index[supp_number[polygs]]-connectivity_index[supp_number[polygs]-1]; - double **pts=new double * [size]; - for(int iPts=0;iPts<size;iPts++) - pts[iPts]=(double *)(coord+dim_space*(connectivity[connectivity_index[supp_number[polygs]-1]+iPts-1])-1); - INTERP_KERNEL::calculateNormalForPolyg((const double **)pts,size,normal+3*index); - delete [] pts; - index++; - } - } - break; - } - default : - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get Normals on it !")); - break; - } - if (!onAll && type!=MED_EN::MED_POLYGON) - delete [] global_connectivity ; - } - END_OF_MED(LOC); - - return Normal; -} -/*!Returns the barycenter for each element in the support. The barycenter positions are returned - as a field with a number of components equal to the mesh dimension. - The barycenter computed by this method is actually the barycenter of the set of nodes of the elements, each having the same weight. -*/ -FIELD<double, FullInterlace>* MESH::getBarycenter(const SUPPORT * Support) const throw (MEDEXCEPTION) -{ - const char * LOC = "MESH::getBarycenter(SUPPORT*) : "; - const GMESH* myMesh = Support->getMesh(); - if (this != myMesh) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh !")); - - int dim_space = getSpaceDimension(); - medEntityMesh support_entity = Support->getEntity(); - bool onAll = Support->isOnAllElements(); - - int nb_type, length_values; - const medGeometryElement* types; - int nb_entity_type; - const int* global_connectivity; - - nb_type = Support->getNumberOfTypes(); - length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS); - types = Support->getTypes(); - - FIELD<double, FullInterlace>* Barycenter; - Barycenter = new FIELD<double, FullInterlace>(Support,dim_space); - Barycenter->setName("BARYCENTER"); - Barycenter->setDescription("cells or faces barycenter"); - - for (int k=0;k<dim_space;k++) { - int kp1 = k + 1; - Barycenter->setComponentName(kp1,myMesh->getCoordinatesNames()[k]); - Barycenter->setComponentDescription(kp1,"desc-comp"); - Barycenter->setMEDComponentUnit(kp1,myMesh->getCoordinatesUnits()[k]); - } - Barycenter->setIterationNumber(0); - Barycenter->setOrderNumber(0); - Barycenter->setTime(0.0); - double *barycenter=(double *)Barycenter->getValue(); - const double * coord = getCoordinates(MED_FULL_INTERLACE); - int index=0; - for (int i=0;i<nb_type;i++) - { - medGeometryElement type = types[i] ; - nb_entity_type = Support->getNumberOfElements(type); - if(type != MED_EN::MED_POLYGON && type != MED_EN::MED_POLYHEDRA ) - { - if (onAll) - { - global_connectivity = getConnectivity(MED_NODAL,support_entity,type); - } - else - { - const int * supp_number = Support->getNumber(type); - const int * connectivity = getConnectivity(MED_NODAL,support_entity,MED_ALL_ELEMENTS); - int * global_connectivity_tmp = new int[(type%100)*nb_entity_type]; - - for (int k_type = 0; k_type<nb_entity_type; k_type++) { - for (int j_ent = 0; j_ent<(type%100); j_ent++) { - const int *global_connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity); - global_connectivity_tmp[k_type*(type%100)+j_ent] = connectivity[global_connectivityIndex[supp_number[k_type]-1]+j_ent-1]; - } - } - global_connectivity = global_connectivity_tmp; - } - } - - switch (type) - { - case MED_TETRA4 : case MED_TETRA10 : - { - for (int tetra =0;tetra<nb_entity_type;tetra++) - { - int tetra_index = (type%100)*tetra; - - int N1 = global_connectivity[tetra_index]-1; - int N2 = global_connectivity[tetra_index+1]-1; - int N3 = global_connectivity[tetra_index+2]-1; - int N4 = global_connectivity[tetra_index+3]-1; - double *pts[4]; - pts[0]=(double *)coord+dim_space*N1; - pts[1]=(double *)coord+dim_space*N2; - pts[2]=(double *)coord+dim_space*N3; - pts[3]=(double *)coord+dim_space*N4; - INTERP_KERNEL::calculateBarycenter<4,3>((const double **)pts,barycenter+3*index); - index++; - } - break; - } - case MED_PYRA5 : case MED_PYRA13 : - { - for (int pyra=0;pyra<nb_entity_type;pyra++) - { - int pyra_index = (type%100)*pyra; - - int N1 = global_connectivity[pyra_index]-1; - int N2 = global_connectivity[pyra_index+1]-1; - int N3 = global_connectivity[pyra_index+2]-1; - int N4 = global_connectivity[pyra_index+3]-1; - int N5 = global_connectivity[pyra_index+4]-1; - double *pts[5]; - pts[0]=(double *)coord+dim_space*N1; - pts[1]=(double *)coord+dim_space*N2; - pts[2]=(double *)coord+dim_space*N3; - pts[3]=(double *)coord+dim_space*N4; - pts[4]=(double *)coord+dim_space*N5; - INTERP_KERNEL::calculateBarycenter<5,3>((const double **)pts,barycenter+3*index); - index++; - } - break; - } - case MED_PENTA6 : case MED_PENTA15 : - { - for (int penta=0;penta<nb_entity_type;penta++) - { - int penta_index = (type%100)*penta; - - int N1 = global_connectivity[penta_index]-1; - int N2 = global_connectivity[penta_index+1]-1; - int N3 = global_connectivity[penta_index+2]-1; - int N4 = global_connectivity[penta_index+3]-1; - int N5 = global_connectivity[penta_index+4]-1; - int N6 = global_connectivity[penta_index+5]-1; - double *pts[6]; - pts[0]=(double *)coord+dim_space*N1; - pts[1]=(double *)coord+dim_space*N2; - pts[2]=(double *)coord+dim_space*N3; - pts[3]=(double *)coord+dim_space*N4; - pts[4]=(double *)coord+dim_space*N5; - pts[5]=(double *)coord+dim_space*N6; - INTERP_KERNEL::calculateBarycenter<6,3>((const double **)pts,barycenter+3*index); - index++; - } - break; - } - case MED_HEXA8 : case MED_HEXA20 : - { - for (int hexa=0;hexa<nb_entity_type;hexa++) - { - int hexa_index = (type%100)*hexa; - - int N1 = global_connectivity[hexa_index]-1; - int N2 = global_connectivity[hexa_index+1]-1; - int N3 = global_connectivity[hexa_index+2]-1; - int N4 = global_connectivity[hexa_index+3]-1; - int N5 = global_connectivity[hexa_index+4]-1; - int N6 = global_connectivity[hexa_index+5]-1; - int N7 = global_connectivity[hexa_index+6]-1; - int N8 = global_connectivity[hexa_index+7]-1; - double *pts[8]; - pts[0]=(double *)coord+dim_space*N1; - pts[1]=(double *)coord+dim_space*N2; - pts[2]=(double *)coord+dim_space*N3; - pts[3]=(double *)coord+dim_space*N4; - pts[4]=(double *)coord+dim_space*N5; - pts[5]=(double *)coord+dim_space*N6; - pts[6]=(double *)coord+dim_space*N7; - pts[7]=(double *)coord+dim_space*N8; - INTERP_KERNEL::calculateBarycenter<8,3>((const double **)pts,barycenter+3*index); - index++; - } - break; - } - case MED_TRIA3 : case MED_TRIA6 : - { - for (int tria=0;tria<nb_entity_type;tria++) - { - int tria_index = (type%100)*tria; - int N1 = global_connectivity[tria_index]-1; - int N2 = global_connectivity[tria_index+1]-1; - int N3 = global_connectivity[tria_index+2]-1; - double *pts[3]; - pts[0]=(double *)coord+dim_space*N1; - pts[1]=(double *)coord+dim_space*N2; - pts[2]=(double *)coord+dim_space*N3; - if (dim_space==2) - INTERP_KERNEL::calculateBarycenter<3,2>((const double **)pts,barycenter+2*index); - else - INTERP_KERNEL::calculateBarycenter<3,3>((const double **)pts,barycenter+3*index); - index++; - } - break; - } - case MED_QUAD4 : case MED_QUAD8 : - { - for (int quad=0;quad<nb_entity_type;quad++) - { - int quad_index = (type%100)*quad; - int N1 = global_connectivity[quad_index]-1; - int N2 = global_connectivity[quad_index+1]-1; - int N3 = global_connectivity[quad_index+2]-1; - int N4 = global_connectivity[quad_index+3]-1; - double *pts[4]; - pts[0]=(double *)coord+dim_space*N1; - pts[1]=(double *)coord+dim_space*N2; - pts[2]=(double *)coord+dim_space*N3; - pts[3]=(double *)coord+dim_space*N4; - if (dim_space==2) - INTERP_KERNEL::calculateBarycenter<4,2>((const double **)pts,barycenter+2*index); - else - INTERP_KERNEL::calculateBarycenter<4,3>((const double **)pts,barycenter+3*index); - index++; - } - break; - } - case MED_SEG2 : case MED_SEG3 : - { - for (int edge=0;edge<nb_entity_type;edge++) - { - int edge_index = (type%100)*edge; - int N1 = global_connectivity[edge_index]-1; - int N2 = global_connectivity[edge_index+1]-1; - double *pts[2]; - pts[0]=(double *)coord+dim_space*N1; - pts[1]=(double *)coord+dim_space*N2; - if (dim_space==2) - INTERP_KERNEL::calculateBarycenter<2,2>((const double **)pts,barycenter+2*index); - else - INTERP_KERNEL::calculateBarycenter<2,3>((const double **)pts,barycenter+3*index); - index++; - } - break; - } - case MED_POLYGON : - { - if(onAll) - { - int offsetWithClassicType=getGlobalNumberingIndex(support_entity)[i]-1; - const int * connectivity = _connectivity->getConnectivity(MED_NODAL,support_entity,MED_ALL_ELEMENTS); - const int * connectivity_index = _connectivity->getConnectivityIndex(MED_EN::MED_NODAL,support_entity) + offsetWithClassicType; - for (int polygs=0;polygs<nb_entity_type;polygs++) - { - int size=connectivity_index[polygs+1]-connectivity_index[polygs]; - double **pts=new double * [size]; - for(int iPts=0;iPts<size;iPts++) - pts[iPts]=(double *)coord+dim_space*(connectivity[connectivity_index[polygs]+iPts-1]-1); - INTERP_KERNEL::calculateBarycenterDyn((const double **)pts,size,dim_space,barycenter+dim_space*index); - delete [] pts; - index++; - } - } - else - { - const int * supp_number = Support->getNumber(MED_EN::MED_POLYGON); - const int * connectivity = _connectivity->getConnectivity(MED_NODAL,support_entity,MED_ALL_ELEMENTS); - const int * connectivity_index = _connectivity->getConnectivityIndex(MED_EN::MED_NODAL,support_entity); - for (int polygs=0;polygs<nb_entity_type;polygs++) - { - int localPolygsNbP1=supp_number[polygs]; - int size=connectivity_index[localPolygsNbP1]-connectivity_index[localPolygsNbP1-1]; - double **pts=new double * [size]; - for(int iPts=0;iPts<size;iPts++) - pts[iPts]=(double *)coord+dim_space*(connectivity[connectivity_index[localPolygsNbP1-1]+iPts-1]-1); - INTERP_KERNEL::calculateBarycenterDyn((const double **)pts,size,dim_space,barycenter+dim_space*index); - delete [] pts; - index++; - } - } - break; - } - case MED_EN::MED_POLYHEDRA: - { - if(onAll) - { - for (int polyhs=0;polyhs<nb_entity_type;polyhs++) - { - int lgthNodes; - int offsetWithClassicType=getGlobalNumberingIndex(support_entity)[i]-1; - int *nodes=_connectivity->getNodesOfPolyhedron(offsetWithClassicType+polyhs+1,lgthNodes); - double **pts=new double * [lgthNodes]; - for(int iPts=0;iPts<lgthNodes;iPts++) - pts[iPts]=(double *)coord+3*(nodes[iPts]-1); - INTERP_KERNEL::calculateBarycenterDyn((const double **)pts,lgthNodes,3,barycenter+3*index); - delete [] pts; - delete [] nodes; - index++; - } - } - else - { - const int * supp_number = Support->getNumber(MED_EN::MED_POLYHEDRA); - for (int polyhs=0;polyhs<nb_entity_type;polyhs++) - { - int lgthNodes; - int *nodes=_connectivity->getNodesOfPolyhedron(supp_number[polyhs],lgthNodes); - double **pts=new double * [lgthNodes]; - for(int iPts=0;iPts<lgthNodes;iPts++) - pts[iPts]=(double *)coord+3*(nodes[iPts]-1); - INTERP_KERNEL::calculateBarycenterDyn((const double **)pts,lgthNodes,3,barycenter+3*index); - delete [] pts; - delete [] nodes; - index++; - } - } - break; - } - default : - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get a barycenter on it (in fact unknown type) !")); - break; - } - - if (!onAll) - if(type != MED_EN::MED_POLYGON && type != MED_EN::MED_POLYHEDRA) - delete [] global_connectivity; - } - return Barycenter; -} -/*! - @} -*/ - -bool MESH::isEmpty() const -{ - bool notempty = _name != "NOT DEFINED" || _coordinate != NULL || _connectivity != NULL || - _spaceDimension !=MED_INVALID || - _numberOfNodes !=MED_INVALID || _groupNode.size() != 0 || - _familyNode.size() != 0 || _groupCell.size() != 0 || - _familyCell.size() != 0 || _groupFace.size() != 0 || - _familyFace.size() != 0 || _groupEdge.size() != 0 || - _familyEdge.size() != 0; - return !notempty; -} - -//================================================================================ -/*! - * \brief Check nature of GMESH - */ -//================================================================================ - -bool MESH::getIsAGrid() const -{ - return false; -} - -/*! - * \brief Implement pure virtual method used to get MESH from GMESH - */ -const MESH* MESH::convertInMESH() const -{ - this->addReference(); - return this; -} - -/*! -\addtogroup MESH_advanced -@{ -*/ - -/*! - Retrieves the skin of support \a Support3D. This method is only available in 3D. - On output, it returns a MED_FACE support with the skin of all elements contained in support. - The skin is defined as the list of faces that are compnents of only one volume in the input - support. - - WARNING: This method can recalculate descending connectivity from partial to full form, - so that partial SUPPORT on MED_FACE on this mesh becomes invalid. -*/ -SUPPORT * MESH::getSkin(const SUPPORT * Support3D) throw (MEDEXCEPTION) -{ - const char * LOC = "MESH::getSkin : " ; - BEGIN_OF_MED(LOC) ; - // some test : - if (this != Support3D->getMesh()) - throw MEDEXCEPTION(STRING(LOC) << "no compatibility between *this and SUPPORT::_mesh !"); - if (getMeshDimension() != 3 || Support3D->getEntity() != MED_CELL) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Defined on 3D cells only")); - - // well, all rigth ! - SUPPORT * mySupport = new SUPPORT; - mySupport->setMesh((MESH *)this); - mySupport->setName("Skin"); - mySupport->setEntity( MED_FACE ); - - list<int> myElementsList; - int i,j, size = 0; - - // assure that descending connectivity is full - if ( !_connectivity ) - throw MEDEXCEPTION(STRING(LOC) << "no connectivity defined in MESH !"); - _connectivity->calculateFullDescendingConnectivity(MED_CELL); - if (Support3D->isOnAllElements()) - { - const int* value = getReverseConnectivity(MED_DESCENDING); - const int* index = getReverseConnectivityIndex(MED_DESCENDING); - - int nbFaces = getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS); - for (int i = 0; i < nbFaces; i++) - { - //a face is in skin if it is linked to one element or if one of the elements - //it is linked to is "virtual" - if ((index[i+1]-index[i]==1) || (value[index[i]-1]==0) || (value[index[i]]==0)) { - myElementsList.push_back( i+1 ); - size++; - } - } - } - else - { - map<int,int> FaceNbEncounterNb; - - int * myConnectivityValue = const_cast <int *> - (getConnectivity(MED_DESCENDING,MED_CELL, MED_ALL_ELEMENTS)); - int * myConnectivityIndex = const_cast <int *> (getConnectivityIndex(MED_DESCENDING, MED_CELL)); - int * myCellNbs = const_cast <int *> (Support3D->getnumber()->getValue()); - int nbCells = Support3D->getnumber()->getLength(); - for (i=0; i<nbCells; ++i) - { - int cellNb = myCellNbs [ i ]; - int faceFirst = myConnectivityIndex[ cellNb-1 ]; - int faceLast = myConnectivityIndex[ cellNb ]; - for (j = faceFirst; j < faceLast; ++j) - { - int faceNb = abs( myConnectivityValue [ j-1 ] ); - if (FaceNbEncounterNb.find( faceNb ) == FaceNbEncounterNb.end()) - FaceNbEncounterNb[ faceNb ] = 1; - else - FaceNbEncounterNb[ faceNb ] ++; - } - } - map<int,int>::iterator FaceNbEncounterNbItr; - for (FaceNbEncounterNbItr = FaceNbEncounterNb.begin(); - FaceNbEncounterNbItr != FaceNbEncounterNb.end(); - FaceNbEncounterNbItr ++) - if ((*FaceNbEncounterNbItr).second == 1) - { - myElementsList.push_back( (*FaceNbEncounterNbItr).first) ; - size++ ; - } - } - // Well, we must know how many geometric type we have found - int * myListArray = new int[size] ; - int id = 0 ; - list<int>::iterator myElementsListIt ; - for (myElementsListIt=myElementsList.begin();myElementsListIt!=myElementsList.end();myElementsListIt++) { - myListArray[id]=(*myElementsListIt) ; - id ++ ; - } - - int numberOfGeometricType ; - medGeometryElement* geometricType ; - int * geometricTypeNumber ; - int * numberOfEntities ; - int * mySkyLineArrayIndex ; - - int numberOfType = getNumberOfTypes(MED_FACE) ; - if (numberOfType == 1) // wonderfull : it's easy ! - { - numberOfGeometricType = 1 ; - geometricType = new medGeometryElement[1] ; - const medGeometryElement * allType = getTypes(MED_FACE); - geometricType[0] = allType[0] ; - geometricTypeNumber = new int[1] ; // not use, but initialized to nothing - geometricTypeNumber[0] = 0 ; - numberOfEntities = new int[1] ; - numberOfEntities[0] = size ; - mySkyLineArrayIndex = new int[2] ; - mySkyLineArrayIndex[0]=1 ; - mySkyLineArrayIndex[1]=1+size ; - } - else // hemmm - { - map<medGeometryElement,int> theType ; - for (myElementsListIt=myElementsList.begin();myElementsListIt!=myElementsList.end();myElementsListIt++) - { - medGeometryElement myType = getElementType(MED_FACE,*myElementsListIt) ; - if (theType.find(myType) != theType.end() ) - theType[myType]+=1 ; - else - theType[myType]=1 ; - } - numberOfGeometricType = theType.size() ; - geometricType = new medGeometryElement[numberOfGeometricType] ; - geometricTypeNumber = new int[numberOfGeometricType] ; // not use, but initialized to nothing - numberOfEntities = new int[numberOfGeometricType] ; - mySkyLineArrayIndex = new int[numberOfGeometricType+1] ; - int index = 0 ; - mySkyLineArrayIndex[0]=1 ; - map<medGeometryElement,int>::iterator theTypeIt ; - for (theTypeIt=theType.begin();theTypeIt!=theType.end();theTypeIt++) - { - geometricType[index] = (*theTypeIt).first ; - geometricTypeNumber[index] = 0 ; - numberOfEntities[index] = (*theTypeIt).second ; - mySkyLineArrayIndex[index+1]=mySkyLineArrayIndex[index]+numberOfEntities[index] ; - index++ ; - } - } - MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ; - - mySupport->setNumberOfGeometricType(numberOfGeometricType) ; - mySupport->setGeometricType(geometricType) ; - mySupport->setNumberOfElements(numberOfEntities) ; - mySupport->setNumber(mySkyLineArray) ; - - delete[] numberOfEntities; - delete[] geometricTypeNumber; - delete[] geometricType; - delete[] mySkyLineArrayIndex; - delete[] myListArray; - - END_OF_MED(LOC); - return mySupport ; - -} - - - -int MESH::getElementContainingPoint(const double *coord) -{ - if(_spaceDimension!=3 && _spaceDimension!=2) - throw MEDEXCEPTION("MESH::getElementContainingPoint : invalid _spaceDimension must be equal to 2 or 3 !!!"); - PointLocator loc(*this); - std::list<int> li=loc.locate(coord); - if(li.empty()) - return -1; - return li.front(); -} - -//! Converts MED_CELL connectivity to polyhedra connectivity -//! Converts MED_FACE connectivity to polygon connectivity -//! Wil work only for 3D meshes with nodal connectivity - -void MESH::convertToPoly() -{ - if (getMeshDimension()!=3) return; - - CONNECTIVITY* newpolygonconnectivity = 0; - CONNECTIVITY* newpolyhedraconnectivity = new CONNECTIVITY(MED_EN::MED_CELL); - - { - ////////////////////////////////////////////: - // First step : Treating polygons connectivity - /////////////////////////////////////////// - - int oldnbface = getNumberOfElements(MED_EN::MED_FACE,MED_EN::MED_ALL_ELEMENTS); - int nbTypes = oldnbface > 0 ? 1 : 0; - newpolygonconnectivity = new CONNECTIVITY(nbTypes, MED_EN::MED_FACE); - if ( nbTypes > 0 ) - { - medGeometryElement type = MED_POLYGON; - newpolygonconnectivity->setGeometricTypes( &type, MED_FACE ); - - const int count[] = { 1, oldnbface + 1 }; - newpolygonconnectivity->setCount( count, MED_FACE ); - - const int* oldconn = getConnectivity(MED_EN::MED_NODAL, MED_EN::MED_FACE, MED_EN::MED_ALL_ELEMENTS); - const int* oldconnindex= getConnectivityIndex(MED_EN::MED_NODAL,MED_EN::MED_FACE); - newpolygonconnectivity->setNodal( oldconn, MED_FACE, type, oldconnindex ); - - newpolygonconnectivity->setNumberOfNodes( getNumberOfNodes() ); - newpolygonconnectivity->setEntityDimension( 2 ); - } - } - /////////////////////////////////////////// - // 2nd step : Treating polyhedra connectivity - ////////////////////////////////////////// - { - vector<int> newconn; - vector<int> newindex(1,1); - - int nboldtypes=getNumberOfTypes(MED_EN::MED_CELL); - const MED_EN::medGeometryElement* oldtypes = getTypes(MED_EN::MED_CELL); - const int* oldconn = getConnectivity(MED_EN::MED_NODAL, MED_EN::MED_CELL, MED_EN::MED_ALL_ELEMENTS); - const int* oldconnindex= getConnectivityIndex(MED_EN::MED_NODAL,MED_EN::MED_CELL); - int oldnbelem = getNumberOfElements(MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS); - - for (int itype=0; itype<nboldtypes; itype++) - { - MED_EN::medGeometryElement type = oldtypes[itype]; - int nb_elems=getNumberOfElements(MED_EN::MED_CELL,type); - if ( type == MED_POLYHEDRA ) - { - const int* oldpolyindex = oldconnindex + getGlobalNumberingIndex( MED_CELL )[itype] - 1; - int oldpolyconnsize = oldpolyindex[nb_elems] - oldpolyindex[0]; - newconn.insert( newconn.end(), oldconn, oldconn + oldpolyconnsize ); - int delta = newindex.back() - oldpolyindex[0]; - for (int ielem=0; ielem<nb_elems; ielem++) - newindex.push_back( delta + oldpolyindex[ ielem+1 ]); - } - else - { - MEDMEM::CELLMODEL cellmodel(type); - int nbfacespertype = cellmodel.getNumberOfConstituents(1); - int nbnodespertype = cellmodel.getNumberOfNodes(); - for (int ielem=0; ielem<nb_elems; ielem++) - { - for (int iface=0; iface< nbfacespertype; iface++) - { - //local conn contains the local nodal connectivity for the iface-th face of type - const int* local_conn = cellmodel.getNodesConstituent(1,iface+1); - medGeometryElement facetype = cellmodel.getConstituentType(1,iface+1); - int nbface_nodes=facetype%100; - for ( int inode=0; inode<nbface_nodes;inode++) - newconn.push_back(oldconn[local_conn[inode]-1]); - if ( iface != nbfacespertype-1 ) - newconn.push_back(-1); - } - newindex.push_back( newconn.size() + 1 ); - oldconn += nbnodespertype; - } - } - } - int nbTypes = oldnbelem > 0 ? 1 : 0; - if ( newpolyhedraconnectivity ) delete newpolyhedraconnectivity; - newpolyhedraconnectivity = new CONNECTIVITY(nbTypes, MED_EN::MED_CELL); - if ( nbTypes > 0 ) - { - medGeometryElement type = MED_POLYHEDRA; - newpolyhedraconnectivity->setGeometricTypes( &type, MED_CELL ); - - const int count[] = { 1, oldnbelem + 1 }; - newpolyhedraconnectivity->setCount( count, MED_CELL ); - - newpolyhedraconnectivity->setNodal( &newconn[0], MED_CELL, type, &newindex[0] ); - - newpolyhedraconnectivity->setNumberOfNodes( getNumberOfNodes() ); - newpolyhedraconnectivity->setEntityDimension( 3 ); - } - } - - delete _connectivity; - - _connectivity=newpolyhedraconnectivity; - _connectivity->setConstituent(newpolygonconnectivity); - -} - -vector< vector<double> > MESH::getBoundingBox() const -{ - const double *myCoords=_coordinate->getCoordinates(MED_EN::MED_FULL_INTERLACE); - vector< vector<double> > ret(2); - int i,j; - ret[0].resize(_spaceDimension); - ret[1].resize(_spaceDimension); - for(i=0;i<_spaceDimension;i++) - { - ret[0][i]=1.e300; - ret[1][i]=-1.e300; - } - for(i=0;i<_coordinate->getNumberOfNodes();i++) - { - for(j=0;j<_spaceDimension;j++) - { - double tmp=myCoords[i*_spaceDimension+j]; - if(tmp<ret[0][j]) - ret[0][j]=tmp; - if(tmp>ret[1][j]) - ret[1][j]=tmp; - } - } - return ret; -} diff --git a/src/MEDMEM/MEDMEM_Mesh.hxx b/src/MEDMEM/MEDMEM_Mesh.hxx deleted file mode 100644 index a10f39f07..000000000 --- a/src/MEDMEM/MEDMEM_Mesh.hxx +++ /dev/null @@ -1,640 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com - -#ifndef MESH_HXX -#define MESH_HXX - -#include <MEDMEM.hxx> - -#include <string> -#include <vector> -#include <list> -#include <map> - -#include "MEDMEM_GMesh.hxx" -#include "MEDMEM_Utilities.hxx" -#include "MEDMEM_STRING.hxx" -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_define.hxx" -#include "MEDMEM_Coordinate.hxx" -#include "MEDMEM_Connectivity.hxx" -#include "MEDMEM_GenDriver.hxx" -#include "MEDMEM_RCBase.hxx" -#include "MEDMEM_FieldForward.hxx" - -namespace MEDMEM { - -class CELLMODEL; -class FAMILY; -class GROUP; -class SUPPORT; -class MESH; - -MEDMEM_EXPORT ostream & operator<<(ostream &os, const MESH &my); - -/*! This class contains all the informations related with a MESH : - - COORDINATES - - CONNECTIVITIES -*/ - -class MEDMEM_EXPORT MESH : public GMESH -{ - //-----------------------// - // Attributes - //-----------------------// - -protected : - - int _numberOfNodes; - mutable COORDINATE * _coordinate; - mutable CONNECTIVITY * _connectivity; - - ////////////////////////////////////////////////////////////////////////////////////// - /// Modification pour prise en compte de la numérotation optionnelle des noeuds /// - ////////////////////////////////////////////////////////////////////////////////////// - /// - /// La map suivante donne le lien numérotation optionnelle => numérotation cannonique - /// Elle sera calculée apres l'appel de MEDnumLire(...) - /// Et sera utilisée avant chaque appel a MEDconnLire(...) pour renuméroter toutes les mailles de façon canonique [1...n] - /// _coordinate->NodeNumber sera utilisé avant chaque appel à MEDconnEcri pour démunéroter les mailles en leur numérotation originelle - /// Ce traitement devrait prévenir tout plantage du aux numérotations optionnelles DES NOEUDS - /// Et ne ralentira que tres peu les traitements sans numéros optionnels - - int _arePresentOptionnalNodesNumbers; - map<int,int> _optionnalToCanonicNodesNumbers; - - //-----------------------// - // Methods - //-----------------------// - - public : - - // Add your personnal driver line (step 2) - friend class MED_MESH_RDONLY_DRIVER; - friend class MED_MESH_WRONLY_DRIVER; - - friend class MED_MED_RDONLY_DRIVER22; - friend class MED_MED_WRONLY_DRIVER22; - friend class MED_MED_RDWR_DRIVER22; - - friend class GIBI_MESH_RDONLY_DRIVER; - friend class GIBI_MESH_WRONLY_DRIVER; - friend class GIBI_MESH_RDWR_DRIVER; - - friend class PORFLOW_MESH_RDONLY_DRIVER; - friend class PORFLOW_MESH_WRONLY_DRIVER; - friend class PORFLOW_MESH_RDWR_DRIVER; - - friend class VTK_MESH_DRIVER; - - friend class ENSIGHT_MESH_RDONLY_DRIVER; - - public: - MESH(); - MESH(MESH &m); - virtual ~MESH(); - MESH( driverTypes driverType, const string & fileName="", - const string & meshName="") throw (MEDEXCEPTION); - public: - void init(); - MESH & operator=(const MESH &m); - virtual bool operator==(const MESH& other) const; - virtual bool deepCompare(const GMESH& other) const; - virtual bool isEmpty() const; - - friend ostream & operator<<(ostream &os, const MESH &my); - virtual void printMySelf(ostream &os) const; - - virtual int getMeshDimension() const; - virtual bool getIsAGrid() const; - virtual const MESH* convertInMESH() const; - - inline int getNumberOfNodes() const; - virtual inline const COORDINATE * getCoordinateptr() const; - inline string getCoordinatesSystem() const; - virtual inline const double * getCoordinates(MED_EN::medModeSwitch Mode) const; - virtual inline const double getCoordinate(int Number,int Axis) const; - inline const string * getCoordinatesNames() const; - inline const string * getCoordinatesUnits() const; - - virtual inline int getNumberOfTypes(MED_EN::medEntityMesh Entity) const; - virtual inline const MED_EN::medGeometryElement * getTypes(MED_EN::medEntityMesh Entity) const; - virtual inline const CELLMODEL * getCellsTypes(MED_EN::medEntityMesh Entity) const; - virtual inline string * getCellTypeNames(MED_EN::medEntityMesh Entity) const; - virtual inline const int * getGlobalNumberingIndex(MED_EN::medEntityMesh Entity) const; - virtual inline int getNumberOfElements(MED_EN::medEntityMesh Entity, - MED_EN::medGeometryElement Type) const; - virtual inline bool existConnectivity(MED_EN::medConnectivity ConnectivityType, - MED_EN::medEntityMesh Entity) const; - - virtual inline MED_EN::medGeometryElement getElementType(MED_EN::medEntityMesh Entity, - int Number) const; - virtual inline void calculateConnectivity(MED_EN::medConnectivity ConnectivityType, - MED_EN::medEntityMesh Entity) const ; - virtual inline int getConnectivityLength(MED_EN::medConnectivity ConnectivityType, - MED_EN::medEntityMesh Entity, - MED_EN::medGeometryElement Type) const; - virtual inline const int * getConnectivity(MED_EN::medConnectivity ConnectivityType, - MED_EN::medEntityMesh Entity, - MED_EN::medGeometryElement Type) const; - virtual inline const int * getConnectivityIndex(MED_EN::medConnectivity ConnectivityType, - MED_EN::medEntityMesh Entity) const; - - virtual int getElementNumber(MED_EN::medConnectivity ConnectivityType, - MED_EN::medEntityMesh Entity, - MED_EN::medGeometryElement Type, - int * connectivity) const; - virtual inline int getReverseConnectivityLength(MED_EN::medConnectivity ConnectivityType, - MED_EN::medEntityMesh Entity=MED_EN::MED_CELL) const; - virtual inline const int * getReverseConnectivity(MED_EN::medConnectivity ConnectivityType, - MED_EN::medEntityMesh Entity=MED_EN::MED_CELL) const; - virtual inline int getReverseConnectivityIndexLength(MED_EN::medConnectivity ConnectivityType, - MED_EN::medEntityMesh Entity=MED_EN::MED_CELL) const; - virtual inline const int * getReverseConnectivityIndex(MED_EN::medConnectivity ConnectivityType, - MED_EN::medEntityMesh Entity=MED_EN::MED_CELL) const; - - virtual inline const CONNECTIVITY* getConnectivityptr() const; - inline void setConnectivityptr(CONNECTIVITY*); - virtual SUPPORT * getBoundaryElements(MED_EN::medEntityMesh Entity) const - throw (MEDEXCEPTION); - virtual SUPPORT * getSkin(const SUPPORT * Support3D) - throw (MEDEXCEPTION); - - // Node DonneBarycentre(const Cell &m) const; - virtual FIELD<double>* getVolume (const SUPPORT * Support, bool isAbs = true) const - throw (MEDEXCEPTION); - // Support must be on 3D elements - virtual FIELD<double>* getArea (const SUPPORT * Support) const - throw (MEDEXCEPTION); - // Support must be on 2D elements - virtual FIELD<double>* getLength (const SUPPORT * Support) const - throw (MEDEXCEPTION); - // Support must be on 1D elements - virtual FIELD<double>* getNormal (const SUPPORT * Support) const - throw (MEDEXCEPTION); - // Support must be on 2D elements - virtual FIELD<double>* getBarycenter (const SUPPORT * Support) const - throw (MEDEXCEPTION); - // FIELD<int>* getNeighbourhood(SUPPORT * Support) const - // throw (MEDEXCEPTION); // Il faut preciser ! - - SUPPORT *buildSupportOnNodeFromElementList(const list<int>& listOfElt, MED_EN::medEntityMesh entity) const throw (MEDEXCEPTION); - void fillSupportOnNodeFromElementList(const list<int>& listOfElt, SUPPORT *supportToFill) const throw (MEDEXCEPTION); - int getElementContainingPoint(const double *coord); - vector< vector<double> > getBoundingBox() const; - void convertToPoly(); -}; - -// --------------------------------------- -// Methodes Inline -// --------------------------------------- - -inline const CONNECTIVITY* MESH::getConnectivityptr() const -{ -// checkGridFillConnectivity(); - return _connectivity; -} - -inline void MESH::setConnectivityptr(CONNECTIVITY* conn) -{ - if(_connectivity) - delete _connectivity; - _connectivity=conn; -} - -/*! \if MEDMEM_ug -\addtogroup MESH_nodes -@{ -\endif -*/ -/*! Gets the number of nodes used in the mesh. */ -inline int MESH::getNumberOfNodes() const -{ - return _numberOfNodes; -} - -/*! \ifnot MEDMEM_ug - Gets the COORDINATES object. Use it only if you need COORDINATES informations not provided by the MESH class. -\endif -*/ -inline const COORDINATE * MESH::getCoordinateptr() const -{ -// checkGridFillCoords(); - return _coordinate; -} - -/*! Retrieves the system in which coordinates are given (CARTESIAN,CYLINDRICAL,SPHERICAL). */ -inline string MESH::getCoordinatesSystem() const -{ - return _coordinate->getCoordinatesSystem(); -} - -/*! Gets the whole coordinates array in a given interlacing mode. The interlacing mode are : - - MED_NO_INTERLACE : X1 X2 Y1 Y2 Z1 Z2 - - MED_FULL_INTERLACE : X1 Y1 Z1 X2 Y2 Z2 - */ -inline const double * MESH::getCoordinates(MED_EN::medModeSwitch Mode) const -{ -// checkGridFillCoords(); - return _coordinate->getCoordinates(Mode); -} - -/*! Gets the coordinate number \a number on axis \a axis.*/ -inline const double MESH::getCoordinate(int number, int axis) const -{ -// checkGridFillCoords(); - return _coordinate->getCoordinate(number,axis); -} - -/*! Gets a pointer to the coordinate names array. -*/ -inline const string * MESH::getCoordinatesNames() const -{ - return _coordinate->getCoordinatesNames(); -} - -/*! Gets a pointer to the coordinate units array. -*/ -inline const string * MESH::getCoordinatesUnits() const -{ - return _coordinate->getCoordinatesUnits(); -} -/*!\if MEDMEM_ug - -Here is a small C++ example program for which the -Python version may be found in -\a MESHcoordinates.py. - -\example MESHcoordinates.cxx - -@} -\endif -*/ - -// int * MESH::getNodesNumbers() const -// { -// return nodesNumbers; -// } - -/*!\if MEDMEM_ug -\addtogroup MESH_connectivity -@{ -\endif -*/ - -/*! Gets the number of different geometric types for a given entity type. - - For example getNumberOfTypes(MED_CELL) would return 3 if the MESH - have some MED_TETRA4, MED_PYRA5 and MED_HEXA8 in it. - If entity is not defined, returns 0. - If there is no connectivity, returns an exception. - - \param entity entity type (MED_CELL, MED_FACE, MED_EDGE, MED_NODE, MED_ALL_ENTITIES) -*/ -inline int MESH::getNumberOfTypes(MED_EN::medEntityMesh entity) const -{ - MESSAGE_MED("MESH::getNumberOfTypes(medEntityMesh entity) : "<<entity); - if (entity == MED_EN::MED_NODE) - return 1; -// checkGridFillConnectivity(); - if (_connectivity != NULL) - return _connectivity->getNumberOfTypes(entity); - throw MEDEXCEPTION(LOCALIZED("MESH::getNumberOfTypes( medEntityMesh ) : Connectivity not defined !")); -} - -/*! - Gets the list of geometric types used by a given entity. - If entity is not defined, it returns an exception. -\param entity Entity type must be MED_CELL, MED_FACE, MED_EDGE or MED_ALL_ENTITIES. - Passing MED_NODE as an entity type will throw an exception. -*/ -inline const MED_EN::medGeometryElement * MESH::getTypes(MED_EN::medEntityMesh entity) const -{ - if (entity == MED_EN::MED_NODE) - throw MEDEXCEPTION(LOCALIZED("MESH::getTypes( medEntityMesh ) : No medGeometryElement with MED_NODE entity !")); - // return un tableau de taille 1 contenant MED_NONE, comme les supports pour etre coherent avec getNumberOfTypes ???? PG - -// checkGridFillConnectivity(); - if (_connectivity != NULL) - return _connectivity->getGeometricTypes(entity); - throw MEDEXCEPTION(LOCALIZED("MESH::getTypes( medEntityMesh ) : Connectivity not defined !")); -} -/*! \if MEDMEM_ug @} \endif */ - -/*! - Get the whole list of CELLMODEL used by cells of given type (medEntityMesh). - Passing MED_NODE as an entity type will throw an exception. -*/ -inline const CELLMODEL * MESH::getCellsTypes(MED_EN::medEntityMesh Entity) const -{ - // checkGridFillConnectivity(); - if (_connectivity != NULL) - return _connectivity->getCellsTypes(Entity); - throw MEDEXCEPTION(LOCALIZED("MESH::getCellsTypes( medEntityMesh ) : Connectivity not defined !")); -} - -/*! - Get an array (it should deleted after use) of the whole list of CELLMODEL - Name of a given type (medEntityMesh). - - REMARK : Don't use MED_NODE as medEntityMesh -*/ -inline string * MESH::getCellTypeNames(MED_EN::medEntityMesh Entity) const -{ - // checkGridFillConnectivity(); - if (_connectivity != NULL) - return _connectivity->getCellTypeNames(Entity); - throw MEDEXCEPTION(LOCALIZED("MESH::getCellTypesName( medEntityMesh ) : Connectivity not defined !")); -} -/*!\if MEDMEM_ug -\addtogroup MESH_connectivity -@{ -\endif -*/ - -/*! Returns an array of size NumberOfTypes+1 which contains, for each - geometric type of the given entity, the first global element number - of this type. - - For exemple, if we have a mesh with 5 triangles and 4 quadrangle : - - size of GlobalNumberingIndex is 3 - - GlobalNumberingIndex[0]=1 (the first type) - - GlobalNumberingIndex[1]=6 (the second type) - - GlobalNumberingIndex[2]=10 -*/ -inline const int * MESH::getGlobalNumberingIndex(MED_EN::medEntityMesh entity) const -{ - // checkGridFillConnectivity(); - if (_connectivity != NULL) - return _connectivity->getGlobalNumberingIndex(entity); - throw MEDEXCEPTION(LOCALIZED("MESH::getNumberOfTypes( medEntityMesh ) : Connectivity not defined !")); -} -/*! - Returns the number of elements of given geometric type of given entity. Returns 0 if query is not defined. - - Example : - - getNumberOfElements(MED_NODE,MED_NONE) : number of nodes - - getNumberOfElements(MED_NODE,MED_TRIA3) : returns 0 (not defined) - - getNumberOfElements(MED_FACE,MED_TRIA3) : returns number of triangle - elements defined in face entity (0 if not defined) - - getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) : returns total number - of elements defined in cell entity - */ -inline int MESH::getNumberOfElements(MED_EN::medEntityMesh entity, MED_EN::medGeometryElement Type) const -{ - if (entity==MED_EN::MED_NODE) - if ((Type==MED_EN::MED_NONE)|(Type==MED_EN::MED_ALL_ELEMENTS)) - return _numberOfNodes; - else - return 0; - //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"wrong medGeometryElement with MED_NODE")); - else - { -// checkGridFillConnectivity(); - if (_connectivity != (CONNECTIVITY*)NULL) - return _connectivity->getNumberOf(entity,Type); - else - return 0; - //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"connectivity not defined !")); - } -} -/*! \if MEDMEM_ug - -This example shows the use of connectivity retrieval methods on a mesh which -corresponds to the four-element mesh given in figure ??. Note -the use of connectivity and connnectivity index tables, and the -offsets used to convert Fortran-style numbering to C arrays. - -The output of this program reads : -\code -Number of types : 3 -Type #0 -Element 1 : 1 2 3 -Type #1 -Element 1 : 2 4 5 3 -Element 2 : 5 6 7 8 -Type #2 -Element 1 : 4 6 5 10 11 9 -\endcode - -\example read_example.cxx - -A more complete example involving descending connectivities -can be found in \c MESHconnectivities.cxx and \c MESHconnectivities.py. - -@} -\endif -*/ -/*! - Returns true if the wanted connectivity exist, else returns false - (to use before a getSomething method). - */ -inline bool MESH::existConnectivity(MED_EN::medConnectivity connectivityType, MED_EN::medEntityMesh entity) const -{ -// checkGridFillConnectivity(); - if (_connectivity==(CONNECTIVITY*)NULL) - throw MEDEXCEPTION("MESH::existConnectivity(medConnectivity,medEntityMesh) : no connectivity defined !"); - return _connectivity->existConnectivity(connectivityType,entity); -} -/*!\if MEDMEM_ug -\addtogroup MESH_connectivity -@{ -\endif -*/ - -/*! - Returns the geometric type of global element number \a Number of entity \a Entity. - - Throw an exception if \a Entity is not defined or if \a Numberis wrong. - */ -inline MED_EN::medGeometryElement MESH::getElementType(MED_EN::medEntityMesh Entity,int Number) const -{ - // checkGridFillConnectivity(); - if (_connectivity==(CONNECTIVITY*)NULL) - throw MEDEXCEPTION("MESH::getElementType(medEntityMesh,int) : no connectivity defined !"); - return _connectivity->getElementType(Entity,Number); -} -/*! -\if MEDMEM_ug -@} -\endif - */ - -/*! - Calculates the required connectivity. Returns an exception if this could not be - done. Do nothing if connectivity already exist. - */ - -inline void MESH::calculateConnectivity(MED_EN::medConnectivity ConnectivityType,MED_EN::medEntityMesh entity) const -{ - _connectivity->calculateConnectivity(ConnectivityType,entity); -} -/*! - Returns the corresponding length of the array returned by MESH::getConnectivity with exactly the same arguments. - Used particulary for wrapping CORBA and python. - */ -inline int MESH::getConnectivityLength(MED_EN::medConnectivity ConnectivityType,MED_EN::medEntityMesh entity, MED_EN::medGeometryElement Type) const -{ - int nbOfElm = getNumberOfElements(entity,Type); - int size; - - if (Type == MED_EN::MED_ALL_ELEMENTS) - { - size = getConnectivityIndex(ConnectivityType,entity)[nbOfElm]-1; - } - else - { - size = _connectivity->getConnectivityLength(ConnectivityType,entity,Type); // issue 19983 - } - return size; -} - -/*!\if MEDMEM_ug -\addtogroup MESH_connectivity -@{ -\endif -*/ - -/*! - Returns the required connectivity in mode \a Mode for the - geometric type \a Type of the entity type \a entity. -\a ConnectivityType specifies descending or nodal connectivity. - - To get connectivity for all geometric type, use \a Mode=MED_FULL_INTERLACE - and \a Type=MED_ALL_ELEMENTS. - You must also get the corresponding index array. - */ -inline const int * MESH::getConnectivity(MED_EN::medConnectivity ConnectivityType,MED_EN::medEntityMesh entity, MED_EN::medGeometryElement Type) const -{ - return _connectivity->getConnectivity(ConnectivityType,entity,Type); -} -/*! - Returns the required index array for a connectivity received in - MED_FULL_INTERLACE mode and MED_ALL_ELEMENTS type. - - This array allows to find connectivity of each element. - - Example : Connectivity of i-th element (1<=i<=NumberOfElement) begins - at index ConnectivityIndex[i-1] and ends at index ConnectivityIndex[i]-1 - in Connectivity array (Connectivity[ConnectivityIndex[i-1]-1] is the - first node of the element) - */ -inline const int * MESH::getConnectivityIndex(MED_EN::medConnectivity ConnectivityType, - MED_EN::medEntityMesh entity) const -{ - return _connectivity->getConnectivityIndex(ConnectivityType, entity); -} - -/*! -\if MEDMEM_ug -@} -\endif - */ - -/*! - Returns the corresponding length of the array returned by MESH::getReverseConnectivity with exactly the same arguments. - Used particulary for wrapping CORBA and python. - */ - -inline int MESH::getReverseConnectivityLength(MED_EN::medConnectivity ConnectivityType, - MED_EN::medEntityMesh Entity) const -{ - int spaceDim = getSpaceDimension(); - int nb; - - if (ConnectivityType == MED_EN::MED_NODAL) - { - nb = getNumberOfNodes(); - } - else - { - if (spaceDim == 2) - nb = getNumberOfElements(MED_EN::MED_EDGE, - MED_EN::MED_ALL_ELEMENTS); - else if (spaceDim == 3) - nb = getNumberOfElements(MED_EN::MED_FACE, - MED_EN::MED_ALL_ELEMENTS); - } - return getReverseConnectivityIndex(ConnectivityType,Entity)[nb]-1; -} -/*! - Returns the reverse connectivity required by ConnectivityType : - - If ConnectivityType=MED_NODAL : returns connectivity node-cell - - If ConnectivityType=MED_DESCENDING : returns connectivity face-cell - - You must get ReverseConnectivityIndex array to use it. - */ - -inline const int * MESH::getReverseConnectivity(MED_EN::medConnectivity ConnectivityType,MED_EN::medEntityMesh Entity/*=MED_CELL*/) const -{ - // checkGridFillConnectivity(); - if (NULL==_connectivity) - throw MEDEXCEPTION("MESH::getReverseConnectivity : no connectivity defined in MESH !"); - - return _connectivity->getReverseConnectivity(ConnectivityType,Entity); -} -/*! - Returns the corresponding length of the array returned by MESH::getReverseConnectivityIndex with exactly the same arguments. - Used particulary for wrapping CORBA and python. - */ -inline int MESH::getReverseConnectivityIndexLength(MED_EN::medConnectivity ConnectivityType, - MED_EN::medEntityMesh Entity) const -{ - int spaceDim = getSpaceDimension(); - - if (ConnectivityType == MED_EN::MED_NODAL) - { - return getNumberOfNodes()+1; - } - else - { - if (spaceDim == 2) - return getNumberOfElements(MED_EN::MED_EDGE,MED_EN::MED_ALL_ELEMENTS)+1; - else if (spaceDim == 3) - return getNumberOfElements(MED_EN::MED_FACE,MED_EN::MED_ALL_ELEMENTS)+1; - else - throw MEDEXCEPTION("Invalid dimension"); - } -} -/*! - Returns the index array required by ConnectivityType. - - This array allow to find reverse connectivity of each elements. - - Example : Reverse connectivity of i^{th} elements (1<=i<=NumberOfElement) - begin at index ReverseConnectivityIndex[i-1] and end at index - ReverseConnectivityIndex[i]-1 - in ReverseConnectivity array ( - ReverseConnectivity[ReverseConnectivityIndex[i-1]-1] - is the first value) - */ -inline const int * MESH::getReverseConnectivityIndex(MED_EN::medConnectivity ConnectivityType,MED_EN::medEntityMesh Entity/*=MED_CELL*/) const -{ - // checkGridFillConnectivity(); - if (NULL==_connectivity) - throw MEDEXCEPTION("MESH::getReverseConnectivityIndex : no connectivity defined in MESH !"); - - return _connectivity->getReverseConnectivityIndex(ConnectivityType,Entity); -} - -} - -#endif /* MESH_HXX */ diff --git a/src/MEDMEM/MEDMEM_MeshFuse.cxx b/src/MEDMEM/MEDMEM_MeshFuse.cxx deleted file mode 100644 index f57253bef..000000000 --- a/src/MEDMEM/MEDMEM_MeshFuse.cxx +++ /dev/null @@ -1,1060 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// File : MEDMEM_MeshFuse.cxx -// Created : Tue Jul 7 18:27:00 2009 -// Author : Edward AGAPOV (eap) - -#include "MEDMEM_MeshFuse.hxx" - -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Group.hxx" - -using namespace MEDMEM; -using namespace MED_EN; -using namespace std; - -#define _NODE_TYPE_ MED_NONE - -MeshFuse::MeshFuse():MESHING() -{ -} - -MeshFuse::~MeshFuse() -{ -} - -//================================================================================ -/*! - * \brief set global numbers of nodes if MeshFuse has been filled via MESHING - */ -//================================================================================ - -void MeshFuse::setNodeNumbers( const std::vector<int>& node_glob_numbers ) -{ - const char* LOC = "MeshFuse::setNodeNumbers(node_glob_numbers): "; - - if ( !_node_glob_numbers.empty() ) - throw MEDEXCEPTION(STRING(LOC)<<"node numbers has been already set"); - - if ( node_glob_numbers.size() != getNumberOfNodes() && - node_glob_numbers.size() > 0 && getNumberOfNodes() > 0 ) - throw MEDEXCEPTION - (STRING(LOC)<<"size of node_glob_numbers must be equal number of nodes in MeshFuse"); - - _node_glob_numbers = node_glob_numbers; -} - -//================================================================================ -/*! - * \brief Fuse me and other mesh - * \param mesh - mesh to concatenate - * \param node_glob_numbers - node numbers used to merge coincident meshes entities - */ -//================================================================================ - -void MeshFuse::concatenate( const MESH* mesh, const vector<int>& node_glob_numbers ) -{ - const char* LOC = "MeshFuse::concatenate( mesh, node_glob_numbers ): "; - if ( !mesh || mesh->getNumberOfNodes() == 0) return; - - _mesh = mesh; - - if ( this->getNumberOfNodes() < 1 ) - { - mesh->getCoordinates( MED_FULL_INTERLACE );// make fields filled in case of GRID - mesh->getConnectivityptr(); - - // just copy mesh - static_cast<MESH&>(*this) = *mesh; - - _node_glob_numbers = node_glob_numbers; - return; - } - // check feasibility - - if ( mesh->getNumberOfNodes() > 0 && node_glob_numbers.empty() ) - throw MEDEXCEPTION(STRING(LOC)<<"merging without node global numbers not implemented yet"); - - if ( mesh->getNumberOfNodes() != node_glob_numbers.size() ) - throw MEDEXCEPTION(STRING(LOC)<<"invalid number of node global numbers"); - - if ( mesh->getSpaceDimension() != this->getSpaceDimension() || - mesh->getMeshDimension() != this->getMeshDimension() ) - throw MEDEXCEPTION(STRING(LOC)<<"can't unite meshes with different dimensions so far, sorry"); - - // init - _merged_of_type.clear(); - for ( int i = 0; i < NB_INDICES; ++i ) - { - _nb_index[ i ].clear(); - _nb_index[ i ].resize( MED_ALL_ENTITIES ); - } - - // concatenation - - int final_nb_nodes = makeNewNodeIds( node_glob_numbers ); - - expandCoordinates(final_nb_nodes); - - expandConnectivity(final_nb_nodes); - - expandSupports(); - - // clear unnecessary data - _new_elem_ids_of_type.clear(); -} - -//================================================================================ -/*! - * \brief Return number of nodes in the expanded mesh - * \param add_glob_numbers - global ids of nodes to append - */ -//================================================================================ - -int MeshFuse::makeNewNodeIds(const vector<int>& add_glob_numbers) -{ - // remember merged added nodes and make an array of new ids of added nodes - vector<int>& merged = _merged_of_type [ _NODE_TYPE_ ]; - vector<int>& new_node_ids = _new_elem_ids_of_type[ _NODE_TYPE_ ]; - new_node_ids.resize( add_glob_numbers.size() ); - - // extand global node numbers - _node_glob_numbers.reserve( _node_glob_numbers.size() + add_glob_numbers.size()); - - map<int,int> glob_ids; // to map global ids to new local ones - for ( int i = 0; i < _node_glob_numbers.size(); ++i ) - glob_ids.insert( make_pair( _node_glob_numbers[i], i+1 )); - - int next_loc_id = getNumberOfNodes() + 1; - - for ( int i = 0; i < add_glob_numbers.size(); ++i ) - { - map<int,int>::iterator glob_loc = - glob_ids.insert( make_pair( add_glob_numbers[i], next_loc_id )).first; - - new_node_ids[i] = glob_loc->second; - - if ( new_node_ids[i] == next_loc_id ) // unique global number - { - next_loc_id++; - _node_glob_numbers.push_back( add_glob_numbers[i] ); - } - else - { - merged.push_back( i ); - } - } - _nb_index[ INIT_OLD ][ MED_NODE ][ _NODE_TYPE_ ] = getNumberOfNodes(); - _nb_index[ INIT_ADD ][ MED_NODE ][ _NODE_TYPE_ ] = add_glob_numbers.size(); - _nb_index[ RSLT_ADD ][ MED_NODE ][ _NODE_TYPE_ ] = add_glob_numbers.size() - merged.size(); - - return next_loc_id - 1; -} - -//================================================================================ -/*! - * \brief Update coordinates - */ -//================================================================================ - -void MeshFuse::expandCoordinates(int final_nb_nodes) -{ - const int dim = getSpaceDimension(); - - // create new coordinates - double* coord = new double[ final_nb_nodes * dim ]; - MEDARRAY<double> medarray( coord, dim, final_nb_nodes, MED_FULL_INTERLACE, - /*shallowCopy=*/true,/*ownershipOfValues=*/false); - // copy old coordinates - int nb_old_coord = getNumberOfNodes() * dim; - memcpy( coord, getCoordinates( MED_FULL_INTERLACE ), nb_old_coord * sizeof( double )); - - // set new coords - coord += nb_old_coord; - const double* add_coord =_mesh->getCoordinates( MED_FULL_INTERLACE ); - if ( _merged_of_type[ _NODE_TYPE_ ].empty()) - { - // no coincident nodes in the two meshes, just add coords - memcpy( coord, add_coord, _mesh->getNumberOfNodes() * dim * sizeof( double )); - } - else - { - // copy coord of only unique nodes - int first_added_node = getNumberOfNodes() + 1; - const vector<int>& new_node_ids = _new_elem_ids_of_type[ _NODE_TYPE_ ]; - for ( int n = 0; n < new_node_ids.size(); ++n ) - { - if ( new_node_ids[n] < first_added_node ) continue; // coincident node - memcpy( coord, add_coord + n * dim, dim * sizeof( double )); - coord += dim; - } - } - _coordinate->setCoordinates( &medarray, /*shallowCopy=*/true ); - - _numberOfNodes = final_nb_nodes; -} - -//================================================================================ -/*! - * \brief Concatenate connectivity of meshes - * - * Current implementation impies that cells can't coincide in the meshes - */ -//================================================================================ - -void MeshFuse::expandConnectivity(int final_nb_nodes) -{ - const medConnectivity nodal = MED_NODAL; - - // fill in _nb_index[ INIT_OLD ] - for ( medEntityMesh entity = MED_CELL; entity < MED_ALL_ENTITIES; ++entity ) - { - if ( existConnectivity( nodal, entity )) - { - const int * index = this->getGlobalNumberingIndex(entity); - const medGeometryElement* types = this->getTypes(entity); - int nb_types = this->getNumberOfTypes(entity); - for ( int t = 0; t < nb_types; ++t ) - _nb_index[ INIT_OLD ][ entity ][ types[t] ] = index[t+1]-index[0]; - } - } - - CONNECTIVITY *prev_connectivity = 0, *cell_connectivity = 0; - - // loop on all entities - for ( medEntityMesh entity = MED_CELL; entity < MED_ALL_ENTITIES; ++entity ) - { - if ( entity == MED_FACE && getMeshDimension() == 2 ) - continue; // there can be EDGE - - if ( !_mesh->existConnectivity( nodal, entity )) - { - // no entity in added mesh - if ( existConnectivity( nodal, entity ) && prev_connectivity ) - prev_connectivity->setConstituent - ( new CONNECTIVITY( *getConnectivityptr()->getConstituent( entity ))); - break; - } - if ( !existConnectivity( nodal, entity )) - { - // no entity in the old mesh - fully copy the added connectivity - CONNECTIVITY* connectivity = - new CONNECTIVITY( *_mesh->getConnectivityptr()->getConstituent( entity )); - connectivity->setNumberOfNodes( final_nb_nodes ); - updateNodeIds( connectivity ); - if ( entity == MED_CELL ) - cell_connectivity = connectivity; - else - cell_connectivity->setConstituent( connectivity ); - - break; - } - // Fill in _nb_index[ INIT_ADD ] - const int * index = _mesh->getGlobalNumberingIndex(entity); - const medGeometryElement* add_types = _mesh->getTypes(entity); - int nb_add_types = _mesh->getNumberOfTypes(entity); - for ( int t = 0; t < nb_add_types; ++t ) - _nb_index[ INIT_ADD ][ entity ][ add_types[t] ] = index[t+1]-index[0]; - - // Unite connectivities of std types - - // count types - set<medGeometryElement> types; - types.insert( this->getTypes(entity), this->getTypes(entity) + this->getNumberOfTypes(entity)); - types.insert(_mesh->getTypes(entity),_mesh->getTypes(entity) +_mesh->getNumberOfTypes(entity)); - - int sum_old = 0, sum_add = 0; - - // make all data - vector< TConnData > conn_of_type( types.size() ); - vector< medGeometryElement > type_vec( types.size() ); - vector< int > count(1,1); - set<medGeometryElement>::iterator type = types.begin(); - for ( int t = 0; type != types.end(); ++type, ++t ) - { - int max_conn_len = 0; - if ( this->getNumberOfElements( entity, *type )) - max_conn_len += this->getConnectivityLength( nodal, entity, *type); - if ( _mesh->getNumberOfElements( entity, *type )) - max_conn_len += _mesh->getConnectivityLength( nodal, entity, *type); - conn_of_type[t]._connectivity.reserve( max_conn_len ); - - int nb_old = appendConnectivity( conn_of_type[t], this, entity, *type ); - sum_old += nb_old; - _nb_index[ INIT_OLD ][ entity ][ *type ] = sum_old; - - int nb_add = appendConnectivity( conn_of_type[t],_mesh, entity, *type ); - sum_add += nb_add; - _nb_index[ RSLT_ADD ][ entity ][ *type ] = sum_add; - - count.push_back( count.back() + conn_of_type[t]._nb_elems ); - type_vec[t] = *type; - } - // make new connectivity - CONNECTIVITY* connectivity = new CONNECTIVITY( types.size(), entity ); - connectivity->setNumberOfNodes ( final_nb_nodes ); - connectivity->setGeometricTypes( &type_vec[0], entity ); - connectivity->setCount ( &count [0], entity ); - for ( int t = 0; t < types.size(); ++t ) - connectivity->setNodal( &conn_of_type[t]._connectivity[0], - entity, type_vec[t], - &conn_of_type[t]._index[0] ); - - // store connectivity of an entity - if ( !prev_connectivity ) - { - cell_connectivity = connectivity; - prev_connectivity = cell_connectivity; - } - else - { - prev_connectivity->setConstituent( connectivity ); - prev_connectivity = connectivity; - } - - } // loop on entities - - if ( cell_connectivity ) - { - delete _connectivity; - _connectivity = cell_connectivity; - } -} - -//================================================================================ -/*! - * \brief Update node ids in the copied connectivity of theadded mesh - */ -//================================================================================ - -void MeshFuse::updateNodeIds( CONNECTIVITY* connectivity ) -{ - const medConnectivity nodal = MED_NODAL; - const medGeometryElement type = MED_ALL_ELEMENTS; - - const vector<int>& new_node_ids = _new_elem_ids_of_type[ _NODE_TYPE_ ]; - - medEntityMesh entity = connectivity->getEntity(); - - for ( ; entity < MED_ALL_ENTITIES; entity++ ) - { - // Collect all connectivities with their lengths - - list< pair< const int*, int > > conn_len_list; - - if ( connectivity->existConnectivity( nodal, entity )) - conn_len_list.push_back - ( make_pair( connectivity->getConnectivity(nodal,entity,type), - connectivity->getConnectivityLength(nodal,entity,type))); - - // Convert them - - list< pair< const int*, int > >::iterator conn_len = conn_len_list.begin(); - for ( ; conn_len != conn_len_list.end(); ++conn_len ) - { - int* conn = (int* ) conn_len->first; - int* conn_end = conn + conn_len->second; - for ( ; conn < conn_end; ++conn ) - *conn = new_node_ids[ *conn-1 ]; - } - } -} - -//================================================================================ -/*! - * \brief Concatenate connectivities - * \param data - storage of resulting connectivities - * \param mesh - mesh to get connectivity from - * \param entity - mesh entity to process - * \param type - geom type to process - * \retval int - nb of appended elements - */ -//================================================================================ - -int MeshFuse::appendConnectivity( MeshFuse::TConnData& data, - const MESH* mesh, - medEntityMesh entity, - medGeometryElement type) -{ - // get connectivity of type - - const int* conn, *index = 0; - int nb_elem, conn_len; - - nb_elem = mesh->getNumberOfElements ( entity, type ); - if ( !nb_elem ) return 0; - conn = mesh->getConnectivity ( MED_NODAL, entity, type ); - index = mesh->getConnectivityIndex( MED_NODAL, entity ); - int shift = getElemNbShift( entity, type, (mesh == this ? INIT_OLD : INIT_ADD), /*prev=*/true); - index += shift; - conn_len = index[ nb_elem ] - index[ 0 ]; - - bool need_index = ( type == MED_POLYGON || type == MED_POLYHEDRA ); - if ( !need_index ) - data._index.resize( 1, 0 ); // for safe access to pointer even if no real index exists - - // Append - - int old_size = data._nb_elems; - data._nb_elems += nb_elem; - - if ( mesh == this ) - { - // append connectivity to data as is - data._connectivity.insert( data._connectivity.end(), conn, conn + conn_len ); - if ( need_index ) - { - if ( data._index.empty() ) - data._index.insert( data._index.end(), index, index + nb_elem + 1 ); - else - for ( int i = 0; i < nb_elem; ++i ) - data._index.push_back( data._index.back() + index[i+1] - index[i] ); - } - } - else - { - // convert connectivity of other mesh - - vector<int> other_conn( conn_len ); - const vector<int>& new_node_ids = _new_elem_ids_of_type[ _NODE_TYPE_ ]; - if ( type == MED_POLYHEDRA ) - { - for ( int n = 0; n < conn_len; ++n ) - if ( conn[ n ] > 0 ) - other_conn[ n ] = new_node_ids[ conn[ n ]-1 ]; - } - else - { - for ( int n = 0; n < conn_len; ++n ) - other_conn[ n ] = new_node_ids[ conn[ n ]-1 ]; - } - if ( entity == MED_CELL || _merged_of_type[ _NODE_TYPE_ ].empty() ) - { - // store converted connectivity in data - data._connectivity.insert( data._connectivity.end(), other_conn.begin(), other_conn.end()); - if ( need_index ) - { - if ( data._index.empty() && index[0] == 1 ) - data._index.insert( data._index.end(), index, index + nb_elem + 1 ); - else - { - data._index.push_back( 1 ); - for ( int i = 0; i < nb_elem; ++i ) - data._index.push_back( data._index.back() + index[i+1] - index[i] ); - } - } - } - else - { - // exclude coincident elements from connectivity - - if ( need_index && data._index.empty() ) - data._index.push_back( 1 ); - - // find added elements possibly(!) coincident with old ones - vector<int>& merged = _merged_of_type[ type ]; // to fill in - int first_added_node = _nb_index[ INIT_OLD ][ MED_NODE ][ _NODE_TYPE_ ] + 1; - for ( int i = 0; i < nb_elem; ++i ) - { - // count coincident nodes - int nb_coincident_nodes = 0; - for ( int n = index[i]; n < index[i+1]; ++n ) - nb_coincident_nodes += int( other_conn[ n-1 ] < first_added_node ); - - if ( nb_coincident_nodes == index[i+1] - index[i] ) - merged.push_back( i ); - } - // find old elements equal to merged, if no equal exist there is zero in array - vector<int>& equalo = _equalo_of_type[ type ]; - findEqualOldElements( entity, type, equalo ); - if ( equalo.size() < merged.size() ) - equalo.resize( merged.size(), 0 ); - - // fill connectivity - int rm_i = 0, nb_rm = 0; - for ( int i = 0; i < nb_elem; ++i ) - { - bool is_merged = ( rm_i < merged.size() && i == merged[rm_i] && equalo[rm_i] ); - if ( is_merged ) - { - data._nb_elems--; - rm_i++; - nb_rm++; - } - else - { - for ( int n = index[i]; n < index[i+1]; ++n ) - data._connectivity.push_back( other_conn[ n-1 ] ); - if ( need_index ) - data._index.push_back( data._index.back() + index[i+1] - index[i] ); - } - } - if ( nb_rm == 0 ) - merged.clear(), equalo.clear(); - } - } - return data._nb_elems - old_size; -} - -//================================================================================ -/*! - * \brief Return updated old support - */ -//================================================================================ - -template< class TSUPPORT > -TSUPPORT* MeshFuse::updateOldSupport(TSUPPORT* support) const -{ - if ( support->isOnAllElements() ) - { - //support->update(); -- this changes old nb elems to nb elems after fuse - } - else if ( support->getEntity() != MED_NODE ) - { - // element numbers of partial support change if some elements had been added - // before a type of the entity - const medGeometryElement* types = support->getTypes(); - int nb_types = support->getNumberOfTypes(); - MEDSKYLINEARRAY * number = support->getnumber(); - for ( int t = 0; t < nb_types; ++t ) - { - int shift = getElemNbShift( support->getEntity(), types[t], RSLT_ADD, /*prev=*/true); - if ( shift == 0 ) continue; - int nb_elems = support->getNumberOfElements( types[t] ); - for ( int j = 0; j < nb_elems; ++j ) - number->setIJ( t+1, j+1, number->getIJ( t+1, j+1 ) + shift ); - } - } - return support; -} - - -//================================================================================ -/*! - * \brief Creates a copy of support being added or extands the present one - * \param add_support - support of the added mesh - * \param same_name_support - the present support with the same name - * \retval SUPPORT* - resulting support - */ -//================================================================================ - -template< class TSUPPORT > -TSUPPORT* MeshFuse::makeSupport(const TSUPPORT* add_support, - TSUPPORT* same_name_support) -{ - if ( same_name_support && same_name_support->getEntity() != add_support->getEntity() ) - throw MEDEXCEPTION("MeshFuse: Supports with equal names and different entity!"); - - // make resulting support - - TSUPPORT* res_support = same_name_support; - if ( !same_name_support ) - { - res_support = new TSUPPORT; - res_support->setName ( add_support->getName() ); - res_support->setDescription( add_support->getDescription() ); - res_support->setEntity ( add_support->getEntity() ); - res_support->setMesh ( this ); - } - else if ( same_name_support->isOnAllElements() && add_support->isOnAllElements() ) - { - same_name_support->update(); - return same_name_support; - } - - // count nb of types - - set<medGeometryElement> add_types, old_types, all_types; - if ( res_support->getEntity() == MED_NODE ) - add_types.insert( _NODE_TYPE_ ); - else - add_types.insert( add_support->getTypes(), - add_support->getTypes() + add_support->getNumberOfTypes() ); - all_types = add_types; - if ( same_name_support ) - { - if ( same_name_support->getEntity() == MED_NODE ) - old_types.insert( _NODE_TYPE_ ); - else - old_types.insert(same_name_support->getTypes(), - same_name_support->getTypes()+same_name_support->getNumberOfTypes() ); - all_types.insert( old_types.begin(), old_types.end() ); - } - - // make all data - - int nb_geom_types = all_types.size(); - vector< medGeometryElement > geom_types( nb_geom_types ); - vector< vector< int > > elements( nb_geom_types ); - vector< int > nb_elements( nb_geom_types ); - vector< int > index( 1,1 ); - set<medGeometryElement>::iterator type = all_types.begin(); - for ( int t = 0; type != all_types.end(); ++type, ++t ) - { - uniteSupportElements( add_types.count( *type ) ? add_support : 0, - old_types.count( *type ) ? same_name_support : 0, - *type, - elements[ t ]); - nb_elements[ t ] = elements[ t ].size(); - index.push_back( index.back() + nb_elements[ t ] ); - } - - // set data to support - - res_support->setAll( false ); - res_support->setNumberOfGeometricType( nb_geom_types ); - res_support->setGeometricType( &geom_types[0] ); - res_support->setNumberOfElements( &nb_elements[0] ); - res_support->setNumber (new MEDSKYLINEARRAY( nb_geom_types, index[nb_geom_types]-1)); - res_support->getnumber()->setIndex( & index[0] ); - for ( int t = 0; t < nb_geom_types; ++t ) - res_support->getnumber()->setI( t+1, & elements[t][0] ); - - return res_support; -} - -//================================================================================ -/*! - * \brief Concatenate families and groups - */ -//================================================================================ - -void MeshFuse::expandSupports() -{ - // we unite supports hiving same names - - // make maps of updated old supports - map< string, FAMILY* > name_to_family; - map< string, GROUP* > name_to_group; - set<int> family_ids; - - vector<FAMILY*>* fams[4] = { &_familyNode, &_familyCell, &_familyFace, &_familyEdge}; - for ( int i = 0; i < 4; ++i ) - for ( int f = 0; f < fams[i]->size(); ++f ) - { - name_to_family.insert - ( make_pair( fams[i]->at(f)->getName(), updateOldSupport( fams[i]->at(f) ))); - family_ids.insert( fams[i]->at(f)->getIdentifier() ); - } - - vector<GROUP*>* groups[4] = { &_groupNode, &_groupCell, &_groupFace, &_groupEdge }; - for ( int i = 0; i < 4; ++i ) - for ( int g = 0; g < groups[i]->size(); ++g ) - { - name_to_group.insert - ( make_pair( groups[i]->at(g)->getName(), updateOldSupport( groups[i]->at(g) ))); - } - - // unite supports - vector<FAMILY*> add_fams[4]={ _mesh->getFamilies(MED_NODE), - _mesh->getFamilies(MED_CELL), - _mesh->getFamilies(MED_FACE), - _mesh->getFamilies(MED_EDGE) }; - for ( int i = 0; i < 4; ++i ) - for ( int f = 0; f < add_fams[i].size(); ++f ) - { - FAMILY* add_fam = add_fams[i][f]; - map<string,FAMILY*>::iterator name_fam = name_to_family.find( add_fam->getName()); - FAMILY* res_fam = makeSupport( add_fam, - name_fam == name_to_family.end() ? 0 : name_fam->second); - if ( name_to_family.insert( make_pair( res_fam->getName(), res_fam )).second ) - { - fams[ i ]->push_back( res_fam ); - int id = add_fam->getIdentifier(); - if ( family_ids.count ( id )) - id = ( id < 0 ) ? *family_ids.begin() - 1 : *family_ids.rbegin() + 1; - res_fam->setIdentifier( id ); - family_ids.insert( id ); - } - // update group names in a family - vector<string> res_gr_names( res_fam->getGroupsNames(), - res_fam->getGroupsNames()+res_fam->getNumberOfGroups()); - for ( int g = 0; g < add_fam->getNumberOfGroups(); ++g ) - if ( find( res_gr_names.begin(), res_gr_names.end(), add_fam->getGroupName(g+1)) - == res_gr_names.end()) - res_gr_names.push_back( add_fam->getGroupName( g+1 )); - if ( res_fam->getNumberOfGroups() < res_gr_names.size() ) - { - res_fam->setNumberOfGroups( res_gr_names.size() ); - res_fam->setGroupsNames( &res_gr_names[0] ); - } - } - - vector<GROUP*> add_grp[4] ={ _mesh->getGroups(MED_NODE), - _mesh->getGroups(MED_CELL), - _mesh->getGroups(MED_FACE), - _mesh->getGroups(MED_EDGE) }; - for ( int i = 0; i < 4; ++i ) - { - for ( int g = 0; g < add_grp[i].size(); ++g ) - { - map< string, GROUP* >::iterator name_grp = name_to_group.find( add_grp[i][g]->getName()); -// STRING out("OLD GRP: "); -// if ( name_grp == name_to_group.end() ) out << "none"; -// else out << *(name_grp->second); -// out._s << endl; -// out << "ADD GRP: " << *(add_grp[i][g]); out._s << endl; out << ""; - GROUP* res_grp = makeSupport( add_grp[i][g], - name_grp == name_to_group.end() ? 0 : name_grp->second); - if ( !name_to_group.count( res_grp->getName() )) - groups[ i ]->push_back( res_grp ); - if ( res_grp->getFamilies().size() < add_grp[i][g]->getFamilies().size() ) - { - res_grp->setFamilies( add_grp[i][g]->getFamilies() ); - res_grp->setNumberOfFamilies( add_grp[i][g]->getNumberOfFamilies() ); - } -// out << "RES GRP: " << *res_grp; -// cout << out << endl; - } - // update pointers to families in groups - for ( int g = 0; g < groups[i]->size(); ++g ) - { - GROUP* grp = groups[i]->at(g); - if ( grp->getNumberOfFamilies() < 1 ) continue; - vector<FAMILY*> fams = grp->getFamilies(); - for ( int f = 0; f < fams.size(); ++f ) - fams[f] = name_to_family[ fams[f]->getName() ]; - grp->setFamilies( fams ); - grp->setNumberOfFamilies( fams.size() ); - } - } -} - -//================================================================================ -/*! - * \brief Return shift for conversion of element numbers - * \param which - to select a global numbering index - * \param prev - true means "shift of type previous to given type" - */ -//================================================================================ - -int MeshFuse::getElemNbShift( const medEntityMesh& entity, - medGeometryElement type, - int which, bool prev ) const -{ - //if ( type == MED_NONE ) type = MED_POINT1; - - const TNbOfGeom & shift_of_type = _nb_index[ which ][ int(entity) ]; - - TNbOfGeom::const_iterator type_shift = shift_of_type.lower_bound( type ); - if ( type_shift == shift_of_type.end() ) - return shift_of_type.empty() ? 0 : shift_of_type.rbegin()->second; - - // get shift of exactly the type or of the previos type - if ( ( prev && type_shift->first == type ) || type_shift->first > type ) - { - if ( type_shift == shift_of_type.begin() ) - return 0; - else - type_shift--; - } - - return type_shift->second; -} - -//================================================================================ -/*! - * \brief Fills in elements of support of given type - * \param add_support - support of the added mesh - * \param old_support - the present support with the same name - * \param type - geometric type to process - * \param elements - output array of element - */ -//================================================================================ - -void MeshFuse::uniteSupportElements(const SUPPORT* add_support, - SUPPORT* old_support, - medGeometryElement type, - vector<int> & elements) -{ - int sup_type = ( type/100 == 0 ? MED_ALL_ELEMENTS : type ); - - const medEntityMesh entity = (add_support ? add_support : old_support )->getEntity(); - - // Add old elements - - int nb_add_elems = add_support ? add_support->getNumberOfElements( sup_type ) : 0; - int nb_old_elems = 0; - if ( old_support ) - { - nb_old_elems = old_support->getNumberOfElements( sup_type ); - elements.reserve( nb_old_elems + nb_add_elems ); - int add_shift = getElemNbShift( entity, type, RSLT_ADD, /*prev=*/1); - int old_shift = getElemNbShift( entity, type, INIT_OLD, /*prev=*/1); - int shift = 1 + add_shift + old_shift; - // convertion of numbers is already done in updateOldSupport() - if ( old_support->isOnAllElements() ) - for ( int i = 0; i < nb_old_elems; ++i ) - elements.push_back( i + shift ); - else - elements.insert( elements.end(), old_support->getNumber( sup_type ), - old_support->getNumber( sup_type ) + nb_old_elems ); - if ( nb_add_elems == 0 ) - return; - } - else - { - elements.reserve( nb_add_elems ); - } - - // Convert and add elements of the added support - - const int * add_elems = add_support->isOnAllElements() ? 0 : add_support->getNumber( sup_type ); - - int add_shift = getElemNbShift( entity, type, RSLT_ADD, /*prev=*/1); - int old_shift = getElemNbShift( entity, type, INIT_OLD, /*prev=*/0); - - if ( _merged_of_type[ type ].empty() ) - { - // no coicident elements in the old and the added meshes - just unite two lists - int shift = add_support->isOnAllElements() ? 1 + add_shift + old_shift : old_shift; - if ( add_support->isOnAllElements() ) - for ( int i = 0; i < nb_add_elems; ++i ) - elements.push_back( i + shift ); - else - for ( int i = 0; i < nb_add_elems; ++i ) - elements.push_back( add_elems[i] + shift ); - } - else - { - // some elements of the added mesh coincide with old ones, - // so conversion is not so easy, and some support members can - // be twice in it - skip them - vector<int> & new_elem_ids = _new_elem_ids_of_type[ type ]; - if ( new_elem_ids.empty() ) - makeNewElemIds( entity, type, new_elem_ids ); - - set< int > old_elems_in_support( elements.begin(), elements.end() ); - int last_old_nb = old_shift + add_shift; - int shift = 1 + getElemNbShift( entity, type, INIT_ADD, /*prev=*/1); - for ( int i = 0; i < nb_add_elems; ++i ) - { - int new_id = new_elem_ids[ add_elems ? add_elems[i]-shift : i ]; - if ( new_id > last_old_nb || old_elems_in_support.count( new_id ) == 0 ) - elements.push_back( new_id ); - } - } -} - -//================================================================================ -/*! - * \brief Fills in ids of elements of added mesh in the resulting mesh - * \param type - element type to treat - * \param new_ids - output array - */ -//================================================================================ - -void MeshFuse::makeNewElemIds(medEntityMesh entity, - medGeometryElement type, - vector< int > & new_ids) -{ - const char* LOC = "MeshFuse::makeNewElemIds(): "; - if ( entity == MED_NODE ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"we must not be here")); - - vector<int>& merged_i = _merged_of_type[ type ]; - vector<int>::iterator rm_i = merged_i.begin(); - - // find ids for merged added elements - vector< int >& old_ids = _equalo_of_type[ type ]; -// if ( old_ids.empty() && !merged_i.empty() ) -// findEqualOldElements( entity, type, old_ids ); - vector< int >::iterator old_id = old_ids.begin(); - - // nb of added elements - int add_nb_elems = _mesh->getNumberOfElements( entity, type ); - new_ids.resize( add_nb_elems ); - - // new id of the first added element - int old_shift = getElemNbShift( entity, type, INIT_OLD, /*prev=*/0); - int add_shift = getElemNbShift( entity, type, RSLT_ADD, /*prev=*/1); - int elem_id = old_shift + add_shift + 1; - - // all new ids - // (this works implying that numbers in SUPPORT are in inceasing order!) - for (int i_elem = 0; i_elem < add_nb_elems; ) - { - int i_until = ( rm_i == merged_i.end() ? add_nb_elems : *rm_i++ ); - // increase elem_id until the next merged element - while ( i_elem < i_until ) - new_ids[ i_elem++ ] = elem_id++; - // insert id of old element equal to merged one, if any - if ( i_elem < add_nb_elems ) - { - if ( *old_id ) - new_ids[ i_elem++ ] = *old_id++; - else - new_ids[ i_elem++ ] = elem_id++, old_id++; // no equal old elem exist - } - } -} - -//================================================================================ -/*! - * \brief Finds ids of elements of the old mesh equal to merged elements of the added one - */ -//================================================================================ - -void MeshFuse::findEqualOldElements(medEntityMesh entity, - medGeometryElement type, - vector< int > & old_ids) -{ - // poly element can coincide with any type of the same entity - const bool isPoly = ( type == MED_POLYGON || type == MED_POLYHEDRA ); - const medGeometryElement checkType = isPoly ? MED_ALL_ELEMENTS : type; - - if ( !_mesh->getNumberOfElements(entity, type) || - ! this->getNumberOfElements(entity, checkType) ) - return; - - int old_nb_elems_end, old_nb_elems_start; - if ( isPoly ) - { - old_nb_elems_start = 0; - old_nb_elems_end = this->getNumberOfElements( entity, MED_ALL_ELEMENTS ); - } - else - { - // if this method is called when connectivity of the entity is not yet concatenated: - old_nb_elems_start = getElemNbShift( entity, type, INIT_OLD, /*prev=*/true); - old_nb_elems_end = getElemNbShift( entity, type, INIT_OLD, /*prev=*/false); - // if this method is called after expandConnectivity() and this mesh contains all elements - // int old_nb_elems = - } - const int *old_conn, *old_index, *add_conn, *add_index; - add_conn = _mesh->getConnectivity( MED_NODAL, entity, type ); - old_conn = this->getConnectivity( MED_NODAL, entity, checkType ); - add_index = _mesh->getConnectivityIndex( MED_NODAL, entity ); - old_index = this->getConnectivityIndex( MED_NODAL, entity ); - - const vector<int>& new_node_ids = _new_elem_ids_of_type[ _NODE_TYPE_ ]; - - const vector<int>& merged_i = _merged_of_type[ type ]; - vector<int>::const_iterator rm_i = merged_i.begin(); - - old_ids.reserve( merged_i.size() ); - - for ( ; rm_i != merged_i.end(); ++rm_i ) // rm_i counts from 0 - { - // get nodes of rm_i-th added face - const int* add_elem_conn = add_conn + add_index[ *rm_i ]-1; - int nb_add_elem_nodes = add_index[ *rm_i+1 ] - add_index[ *rm_i ]; - set<int> add_elem_nodes; - for ( int n = 0; n < nb_add_elem_nodes; ++n ) - add_elem_nodes.insert( new_node_ids[ add_elem_conn[n]-1 ]); - - // look for equal old face among all old faces - const int* old_node = old_conn; - int new_node = *add_elem_nodes.begin(); - int found_old_elem = 0; - for ( int i = old_nb_elems_start; i < old_nb_elems_end && !found_old_elem; ++i ) - { - int nb_old_elem_nodes = old_index[ i+1 ] - old_index[ i ]; - for ( int j = 0; j < nb_old_elem_nodes; ++j, ++old_node ) - { - if ( new_node != *old_node ) continue; - // found common node, compare all nodes - const int* old_elem_conn = old_conn + old_index[ i ]-1; - set<int> old_elem_nodes( old_elem_conn, old_elem_conn + nb_old_elem_nodes); - if ( add_elem_nodes == old_elem_nodes ) - { - found_old_elem = i + 1; - break; - } - } - } - // Issue 0020809. Its possible that no old element exists -// if ( !found_old_elem ) -// throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"all nodes of added elements are merged " -// "but equal old element not found. " -// "Please check global nodes numbers.")); - old_ids.push_back( found_old_elem ); - } -} - -//================================================================================ -/*! - * \brief Unite numbers of elements taking into account their types - */ -//================================================================================ - -void MeshFuse::append( medEntityMesh entity, - vector<int>& numbers, - const vector<int>& add_numbers ) -{ - const char* LOC="MeshFuse::append(): "; - - int nb_types = getNumberOfTypes( entity ); - if ( numbers.empty() || add_numbers.empty() || - ( nb_types < 2 && _merged_of_type[ getElementType( entity, 1 )].empty() )) - { - numbers.insert( numbers.end(), add_numbers.begin(), add_numbers.end() ); - return; - } - - vector<int> result; - result.reserve( numbers.size() + add_numbers.size() ); - const int* old_nums = & numbers[0]; - const int* add_nums = & add_numbers[0]; - - MEDMEM::PointerOf<medGeometryElement> types; - types.setShallowAndOwnership( getTypes(entity)); - - for ( int t = 0; t < nb_types; ++t ) - { - int nb_old = - getElemNbShift( entity, types[t], INIT_OLD, /*prev=*/false) - - getElemNbShift( entity, types[t], INIT_OLD, /*prev=*/true); - int nb_add = - getElemNbShift( entity, types[t], INIT_ADD, /*prev=*/false) - - getElemNbShift( entity, types[t], INIT_ADD, /*prev=*/true); - - result.insert( result.end(), old_nums, old_nums + nb_old ); - old_nums += nb_old; - - const vector<int>& loc_merged = _merged_of_type[ types[t] ]; - if ( loc_merged.empty() ) - { - result.insert( result.end(), add_nums, add_nums + nb_add ); - } - else - { - vector<int>::const_iterator imerged = loc_merged.begin(); - vector<int>::const_iterator equalid = _equalo_of_type[ types[t] ].begin(); - - int from = 0, to = -1; - while ( from < nb_add ) - { - while ( imerged != loc_merged.end() && *equalid == 0 ) - imerged++, equalid++; - to = ( imerged == loc_merged.end() ? nb_add : ( equalid++, *imerged++ )); - if ( to > from ) - result.insert( result.end(), add_nums + from, add_nums + to ); - from = to + 1; - } - } - add_nums += nb_add; - } - if ( result.size() != getNumberOfElements( entity, MED_ALL_ELEMENTS )) - throw MED_EXCEPTION(MEDMEM::STRING(LOC) << "invalid nb of numbers of entity " << entity - << ": expect " << getNumberOfElements( entity, MED_ALL_ELEMENTS) - << " but get " << result.size()); - - numbers.swap(result); -} diff --git a/src/MEDMEM/MEDMEM_MeshFuse.hxx b/src/MEDMEM/MEDMEM_MeshFuse.hxx deleted file mode 100644 index a8cb82d2d..000000000 --- a/src/MEDMEM/MEDMEM_MeshFuse.hxx +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// File : MEDMEM_MeshFuse.hxx -// Created : Tue Jul 7 17:04:38 2009 -// Author : Edward AGAPOV (eap) - -#ifndef __MEDMEM_MeshFuse_HXX__ -#define __MEDMEM_MeshFuse_HXX__ - -#include "MEDMEM_Meshing.hxx" - -#include <vector> -#include <map> -#include <set> - -namespace MEDMEM -{ - /*! - * \brief Mesh able to concatenate other meshes - */ - class MEDMEM_EXPORT MeshFuse : public MESHING - { - public: - MeshFuse(); - virtual ~MeshFuse(); - - void concatenate( const MESH* mesh, const std::vector<int>& node_glob_numbers ); - - // unite glob_numbers and add_glob_numbers - void append( MED_EN::medEntityMesh entity, - std::vector<int>& glob_numbers, - const std::vector<int>& add_glob_numbers ); - - // if MeshFuse is filled via MESHING - void setNodeNumbers( const std::vector<int>& node_glob_numbers ); - - // return number collected during all concatenate()s - const std::vector<int> & getNodeNumbers() const { return _node_glob_numbers; } - - private: - - int makeNewNodeIds(const std::vector<int>& node_glob_numbers); - - void expandCoordinates(int final_nb_nodes); - - void expandConnectivity(int final_nb_nodes); - - void updateNodeIds( CONNECTIVITY* connectivity ); - - struct TConnData - { - int _nb_elems; - std::vector< int > _connectivity, _index; - - TConnData(): _nb_elems(0) {} - }; - - int appendConnectivity( TConnData& data, - const MESH* mesh, - MED_EN::medEntityMesh entity, - MED_EN::medGeometryElement type); - - template< class TSUPPORT > - TSUPPORT* updateOldSupport(TSUPPORT* support) const; - - template< class TSUPPORT > - TSUPPORT* makeSupport(const TSUPPORT* add_support, TSUPPORT* same_name_support); - - void expandSupports(); - - int getElemNbShift( const MED_EN::medEntityMesh& entity, - MED_EN::medGeometryElement type, - int which, bool prev ) const; - - void uniteSupportElements(const SUPPORT* add_support, - SUPPORT* old_support, - MED_EN::medGeometryElement type, - std::vector<int> & elements); - - void makeNewElemIds(MED_EN::medEntityMesh entity, - MED_EN::medGeometryElement type, - std::vector< int > & new_ids); - - void findEqualOldElements(MED_EN::medEntityMesh entity, - MED_EN::medGeometryElement type, - std::vector< int > & old_ids); - - private: - - const MESH* _mesh; // mesh to add - - std::vector<int> _node_glob_numbers; // global numbers of nodes - - // local ids of merged entities (whose all nodes are merged) of the added mesh - std::map< MED_EN::medGeometryElement, std::vector<int> > _merged_of_type; - // and corresponding ids of EQUAL elements (if any) of OLD mesh - std::map< MED_EN::medGeometryElement, std::vector<int> > _equalo_of_type; - - // ids in final mesh of added elements of a geom type filled in case of double elements - std::map< MED_EN::medGeometryElement, std::vector<int> > _new_elem_ids_of_type; - - // global numbering index by type: - // - of old mesh before addition - // - of added mesh before addition - // - of mesh added (taking merging into account) - enum { INIT_OLD=0, INIT_ADD, RSLT_ADD, NB_INDICES }; - typedef std::map< MED_EN::medGeometryElement, int > TNbOfGeom; - vector< TNbOfGeom > _nb_index[NB_INDICES]; // for each entity - - }; -} - -#endif diff --git a/src/MEDMEM/MEDMEM_Meshing.cxx b/src/MEDMEM/MEDMEM_Meshing.cxx deleted file mode 100644 index d38a8ab3b..000000000 --- a/src/MEDMEM/MEDMEM_Meshing.cxx +++ /dev/null @@ -1,406 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -/* - File MEDMEM_Meshing.cxx -*/ - -#include <string> - -#include "MEDMEM_Utilities.hxx" -#include "MEDMEM_STRING.hxx" -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_define.hxx" - -#include "MEDMEM_Meshing.hxx" -#include "MEDMEM_Group.hxx" - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -namespace MEDMEM { -/*! - -\defgroup MESHING_constructors Constructors - -\defgroup MESHING_general General information settings - -\defgroup MESHING_nodes Node coordinates settings - -\defgroup MESHING_connectivity Connectivity settings - -When defining the connectivity, MED_CELL elements connectivity -should be defined first. If necessary, constituent connectivities (MED_FACE and/or MED_EDGE) can be defined afterwards. - -\warning It should be kept in mind that when defining connectivities, -elements should be sorted in ascending type order (the type order -being defined by the number of nodes). - - -\defgroup MESHING_group Group creation - -\defgroup MESHING_poly Polygons and Polyhedra creation - -These methods belong to the meshing class and are necessary for -creating the connectivities of MED_POLYHEDRON and MED_POLYGON -elements. - -*/ - -/*! -\addtogroup MESHING_constructors - @{ -*/ - -/*! Creates an empty MESH. */ -MESHING::MESHING(): MESH() -{ - MESSAGE_MED("MESHING::MESHING()"); - SCRUTE_MED(_coordinate); - SCRUTE_MED(_connectivity); -} -/*! @} */ - -MESHING::~MESHING() -{ - MESSAGE_MED("Deleting MESHING !!"); -} - -/*! -\addtogroup MESHING_nodes - @{ */ - -/*! - Sets the whole coordinates array in a given system and interlacing mode. - The system coordinates are : - - "MED_CART" - - "MED_CYL" - - "MED_SPHER" - The interlacing mode are : - - MED_NO_INTERLACE : X1 X2 Y1 Y2 Z1 Z2 - - MED_FULL_INTERLACE : X1 Y1 Z1 X2 Y2 Z2 - -Example : -\verbatim -MESHING myMeshing ; -const int SpaceDimension=2; -const int NumberOfNodes=6; -int * Coordinates = new int[SpaceDimension*NumberOfNodes] ; -string System="CARTESIAN"; -medModeSwitch Mode = MED_FULL_INTERLACE ; -myMeshing.setCoordinates(SpaceDimension,NumberOfNodes,Coordinates,System,Mode); -\endverbatim - -*/ -void MESHING::setCoordinates(const int SpaceDimension, - const int NumberOfNodes, - const double * Coordinates, - const string System, - const MED_EN::medModeSwitch Mode) -{ - _spaceDimension = SpaceDimension; - _numberOfNodes = NumberOfNodes; - if (_connectivity) - _connectivity->setNumberOfNodes(NumberOfNodes); - - if ( !NumberOfNodes && !Coordinates ) - return; // enable using this method for setting SpaceDimension only - - SCRUTE_MED(_coordinate); - SCRUTE_MED(_connectivity); - - if ( _coordinate ) - delete _coordinate, _coordinate = 0; - _coordinate = new COORDINATE(SpaceDimension,NumberOfNodes,Mode); - _coordinate->setCoordinates(Mode,Coordinates); - _coordinate->setCoordinatesSystem(System); -} -/*! @} */ - -/*! - \addtogroup MESHING_general - @{ */ -/*! Sets the coordinate names array. -Coordinates names must not exceed the storage length -defined in MED-file : MED_TAILLE_PNOM (8). - -Example: -\verbatim -string coord[3]={"x","y","z"}; -meshing.setCoordinatesNames(coord); -\endverbatim -*/ -void MESHING::setCoordinatesNames(const string * name) -{ -// int SpaceDimension = getSpaceDimension() ; -// _coordinate->setCoordinatesNames(SpaceDimension,name); - _coordinate->setCoordinatesNames(name); -} - - - -/*! \ifnot MEDMEM_ug - Sets the (i+1)-th component of coordinate names array. - Coordinates names must not exceed the storage length -defined in MED-file : MED_TAILLE_PNOM (8). -\endif - -*/ -void MESHING::setCoordinateName(const string name, const int i) -{ - _coordinate->setCoordinateName(name,i); -} - -/*! Sets the coordinate unit names array - of size n*MED_TAILLE_PNOM. Coordinates units must not exceed the storage length -defined in MED-file : MED_TAILLE_PNOM (8). - -Example: -\verbatim -string coord[3]={"cm","cm","cm"}; -meshing.setCoordinatesUnits(coord); -\endverbatim -*/ -void MESHING::setCoordinatesUnits(const string * units) -{ -// int SpaceDimension = getSpaceDimension() ; -// _coordinate->setCoordinatesUnits(SpaceDimension,units); - _coordinate->setCoordinatesUnits(units); -} - -/*!\ifnot MEDMEM_ug - Sets the \f$ (i+1)^th \f$ component of the coordinate unit names array - ("cm ","cm ","cm ") of size n*MED_TAILLE_PNOM - \endif -*/ -void MESHING::setCoordinateUnit(const string unit, const int i) -{ - _coordinate->setCoordinateUnit(unit,i); -} -/*! @} */ - -/*! - \addtogroup MESHING_connectivity - @{ -*/ - -/*! - Creates a new connectivity object with the given number of type and - entity. If a connectivity already exist, it is deleted by the call. - - For exemple setNumberOfTypes(3,MED_CELL) creates a connectivity with 3 - medGeometryElement in MESH for MED_CELL entity (like MED_TETRA4, - MED_PYRA5 and MED_HEXA6 for example). - - Returns an exception if it could not create the connectivity (as if we set - MED_FACE connectivity before MED_CELL). -*/ -void MESHING::setNumberOfTypes(const int NumberOfTypes, - const MED_EN::medEntityMesh Entity) - throw (MEDEXCEPTION) -{ - const char * LOC = "MESHING::setNumberOfTypes( medEntityMesh ) : "; - - // No defined for MED_NODE ! - if (Entity == MED_NODE) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not required with MED_NODE !")); - - if (MED_CELL == Entity) { - SCRUTE_MED(_connectivity); - if (_connectivity ) - delete _connectivity ; - _connectivity = new CONNECTIVITY(NumberOfTypes,Entity) ; - _connectivity->setNumberOfNodes( _numberOfNodes ); - - } else { - - if (_connectivity == NULL) // we must have defined MED_CELL connectivity - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"No connectivity on MED_CELL defined !")); - - if (MED_FACE == Entity) - if (3 != getSpaceDimension()) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"No connectivity on MED_FACE could be defined in non 3D space !")); - - if (MED_EDGE == Entity) - { - if (3 == getSpaceDimension()) { - if (3 == getMeshDimension() && !_connectivity->existConnectivity(MED_NODAL,MED_FACE)) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"No connectivity on MED_FACE defined !")); - if (2 > getMeshDimension()) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Could not set connectivity on MED_EDGE !")); - } else { - if (2 != getSpaceDimension()) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Could not set connectivity on MED_EDGE !")); - } - } - // all right, we could create connectivity ! - CONNECTIVITY * myConnectivity = new CONNECTIVITY(NumberOfTypes,Entity) ; - myConnectivity->setNumberOfNodes(_connectivity->getNumberOfNodes()); - _connectivity->setConstituent(myConnectivity); - } -} - -/*! - Sets the list of geometric types used by a given entity. - medEntityMesh entity could be : MED_CELL, MED_FACE, MED_EDGE. - This method is used to set the differents geometrics types -({MED_TETRA4,MED_PYRA5,MED_HEXA8} for example). Geometric types should be given in increasing order of number of nodes for entity type \a entity. - - Remark : Don't use MED_NODE and MED_ALL_ENTITIES. - -If \a entity is not defined, the method will throw an exception. - -*/ - -void MESHING::setTypes(const MED_EN::medGeometryElement * Types, - const MED_EN::medEntityMesh entity) - throw (MEDEXCEPTION) -{ - if (entity == MED_NODE) - throw MEDEXCEPTION(LOCALIZED("MESHING::setTypes : Not defined with MED_NODE entity !")); - - if (_connectivity == NULL) - throw MEDEXCEPTION(LOCALIZED("MESHING::setTypes : No connectivity defined !")); - - _connectivity->setGeometricTypes(Types,entity); -} - -/*! - Sets the number of elements for each geometric type of given entity. - - Example : setNumberOfElements(\{12,23\},MED_FACE); - If there are two types of face (MED_TRIA3 and MED_QUAD4), - this sets 12 triangles and 23 quadrangles. -*/ -void MESHING::setNumberOfElements(const int * NumberOfElements, - const MED_EN::medEntityMesh Entity) - throw (MEDEXCEPTION) -{ - const char * LOC = "MESHING::setNumberOfElements(const int *, medEntityMesh) : " ; - - if (Entity==MED_NODE) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined with MED_NODE entity !")); - - if (_connectivity == (CONNECTIVITY*)NULL) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"No connectivity defined !")); - - int NumberOfTypes = getNumberOfTypes(Entity) ; - int * Count = new int[NumberOfTypes+1] ; - Count[0]=1 ; - for (int i=0; i<NumberOfTypes; i++) - Count[i+1]=Count[i]+NumberOfElements[i] ; - _connectivity->setCount(Count,Entity) ; - delete[] Count ; -} - -/*! - Sets the nodal connectivity for geometric type \a Type of entity \a Entity. - The nodal connectivity must be defined one element type at a time : - \a MED_ALL_ELEMENTS is not a valid \a Type argument. - To define connectivity of \a MED_POLYGON and \a MED_POLYHEDRA, \a PolyConnectivityIndex - is also necessary, which defines index of the first node of each element. - Connectiviy of polyhedron must contain -1 as a separator of faces. For example, - a tetrahedron with connectivity {1,2,3,4} can be represented as a polyhedron by the following arrays:<br> -Connectivity : {1,2,3,-1,2,3,4,-1,3,4,1,-1,4,1,2}<br> -Connectivity_index : {1,16} - - Example : - -\verbatim -MESHING myMeshing ; -myMeshing.setCoordinates(SpaceDimension,NumberOfNodes,Coordinates,System,Mode); -myMeshing.setNumberOfTypes(2,MED_CELL); -myMeshing.setTypes({MED_TRIA3,MED_QUAD4},MED_CELL); -myMeshing.setNumberOfElements({3,2},MED_CELL); // 3 MED_TRIA3 and 2 MED_QUAD4 -myMeshing.setConnectivity(MED_CELL,MED_TRIA3,{1,2,3,6,8,9,4,5,6}); -myMeshing.setConnectivity(MED_CELL,MED_QUAD4,{1,3,4,5,4,5,7,8}); -\endverbatim - - Example : setConnectivity(MED_FACE,MED_TRIA3,{1,2,3,1,4,2}) - Define 2 triangles face defined with nodes 1,2,3 and 1,4,2. -*/ -void MESHING::setConnectivity(const MED_EN::medEntityMesh Entity, - const MED_EN::medGeometryElement Type, - const int * Connectivity, - const int * PolyConnectivityIndex) - throw (MEDEXCEPTION) -{ - const char * LOC = "MESHING::setConnectivity : " ; - - if (Entity==MED_NODE) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined with MED_NODE entity !")); - - if (_connectivity == (CONNECTIVITY*)NULL) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"No connectivity defined !")); - - _connectivity->setNumberOfNodes(_numberOfNodes); - _connectivity->setNodal(Connectivity,Entity,Type,PolyConnectivityIndex) ; -} - -/*! @} */ - -/*! -\addtogroup MESHING_group - @{ */ - -/*!Adds group \a Group to the mesh. -This function registers the group in the list -of groups contained in the mesh, so that -when the mesh is used for file writing, the group -is written in the corresponding MED-file. -*/ - -void MESHING::addGroup(const GROUP & Group) - throw (MEDEXCEPTION) -{ - const char * LOC = "MESHING::addGroup : " ; - - GROUP * myGroup = new GROUP(Group) ; - if(myGroup->getMesh()==this) - { - removeReference(); - } - switch(Group.getEntity()){ - case MED_CELL : { - _groupCell.push_back(myGroup); - break; - } - case MED_FACE : { - _groupFace.push_back(myGroup); - break; - } - case MED_EDGE : { - _groupEdge.push_back(myGroup); - break; - } - case MED_NODE : { - _groupNode.push_back(myGroup); - break; - } - default : - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Entity !")); - } -} - -} -/*! @} */ diff --git a/src/MEDMEM/MEDMEM_Meshing.hxx b/src/MEDMEM/MEDMEM_Meshing.hxx deleted file mode 100644 index 6f4ef2a31..000000000 --- a/src/MEDMEM/MEDMEM_Meshing.hxx +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -/* - File MEDMEM_Meshing.hxx -*/ - -#ifndef MESHING_HXX -#define MESHING_HXX - -#include "MEDMEM.hxx" - -#include "MEDMEM_Mesh.hxx" - - -namespace MEDMEM { - -/*! - This class MESHING is a special class to set a MESH object. -*/ - -class MEDMEM_EXPORT MESHING: public MESH -{ - public : - MESHING(); - ~MESHING(); - - void setCoordinates (const int SpaceDimension, - const int NumberOfNodes, - const double * Coordinates, - const string System, - const MED_EN::medModeSwitch Mode) ; - void setCoordinatesNames (const string * names) ; - void setCoordinateName (const string name, const int i) ; - void setCoordinatesUnits (const string * units) ; - void setCoordinateUnit (const string unit, const int i) ; - - void setNumberOfTypes (const int NumberOfTypes, - const MED_EN::medEntityMesh Entity) throw (MEDEXCEPTION) ; - - void setTypes (const MED_EN::medGeometryElement * Types, - const MED_EN::medEntityMesh Entity) throw (MEDEXCEPTION) ; - - void setNumberOfElements (const int * NumberOfElements, - const MED_EN::medEntityMesh Entity) throw (MEDEXCEPTION) ; - - void setConnectivity (const MED_EN::medEntityMesh Entity, - const MED_EN::medGeometryElement Type, - const int * Connectivity, - const int * PolyConnectivityIndex=0) throw (MEDEXCEPTION) ; - - void addGroup (const GROUP & Group) throw (MEDEXCEPTION) ; -}; -} - -#endif /* MESHING_HXX */ diff --git a/src/MEDMEM/MEDMEM_ModulusArray.hxx b/src/MEDMEM/MEDMEM_ModulusArray.hxx deleted file mode 100644 index 3c3cbb5d9..000000000 --- a/src/MEDMEM/MEDMEM_ModulusArray.hxx +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __MEDMODULUSARRAY_H__ -#define __MEDMODULUSARRAY_H__ - -#include "MEDMEM.hxx" - -#include "MEDMEM_Utilities.hxx" -#include "MEDMEM_define.hxx" - - -/* - This class is use to set cyclic (modulus length) array. - (array[length+1]==array[1]) - - We use it in particular to compare faces nodes lists to know if - they are the same (positive or negative cycle) ! -*/ - -namespace MEDMEM { -class MEDMEM_EXPORT MEDMODULUSARRAY { -private: - // nb vertex nodes; only vertex nodes are in cycle - int _length ; - // total nb nodes; not vertex nodes exists in 2-nd order elements, - // only presence of not vertex nodes is checked by compare() - int _length2; - const int * _array ; - - inline bool compareNotVertexNodes(const MEDMODULUSARRAY &modulusArray) const; - -public: - MEDMODULUSARRAY(int length, const int * array) : - _length(length), _length2(length), _array(array) {} - - MEDMODULUSARRAY(int vertexLength, int totalLength, const int * array): - _length(vertexLength), _length2( totalLength ), _array(array) {} - - ~MEDMODULUSARRAY() {} - - inline const int operator[](const int &i) const ; - - inline int compare(const MEDMODULUSARRAY &modulusArray) const; - - const int *getArray(int& length) const { length=_length; return _array; } -}; - - -inline const int MEDMODULUSARRAY::operator[](const int &i) const -{ - int position = i%_length ; - //int position = i%_length2 ; - if (position < 0) - position+=_length ; - //position += _length2 ; - return _array[position] ; -} - -inline int MEDMODULUSARRAY::compare(const MEDMODULUSARRAY &modulusArray) const -{ - int ret = 0 ; - - if (modulusArray._length != _length || - modulusArray._length2 != _length2 ) - return ret ; - - if (_length==1) - { - if (_array[0]==modulusArray[0]) - return 1; - else - return 0; - } - - if (_length==2) { - if ((_array[0]==modulusArray[0])&(_array[1]==modulusArray[1])) - ret = 1; - else if ((_array[0]==modulusArray[1])&(_array[1]==modulusArray[0])) - ret = -1; - else - return 0; - if ( !compareNotVertexNodes( modulusArray ) ) - ret = 0; - return ret; - } - - //search if there is one start point in common in two array - for(int i=0;i<_length;i++) - if ( _array[0] == modulusArray[i] ) { - // we search if cycle is the same - if (_array[1]==modulusArray[i+1]){ // positive order - ret=1; - for(int j=2;j<_length;j++) - if (_array[j]!=modulusArray[i+j]) { - ret = 0 ; - break ; - } - } else if(_array[1]==modulusArray[i-1]) { //negative order - ret=-1; - for(int j=2;j<_length;j++) - if (_array[j]!=modulusArray[i-j]) { - ret = 0 ; - break ; - } - } - if (ret!=0) {// we have found it ! - if ( !compareNotVertexNodes( modulusArray ) ) - ret = 0; - break ; - } - // else we continue if there is another start point i - } - return ret ; -} - -/*! - * \brief Check presence of the same not vertex nodes - * \retval bool - comparison result - */ -inline bool MEDMODULUSARRAY::compareNotVertexNodes(const MEDMODULUSARRAY &modulusArray) const -{ - if ( _length2 > _length ) { - for ( int i = _length; i < _length2; ++i ) { - bool found = false; - for ( int j = _length; ( j < _length2 && !found ); ++j ) - found = ( _array[ i ] == modulusArray._array[ j ] ); - if ( !found ) - return false; - } - } - return true; -} - -} - -# endif /* # ifndef __MEDMODULUSARRAY_H__ */ - diff --git a/src/MEDMEM/MEDMEM_OptionManager.hxx b/src/MEDMEM/MEDMEM_OptionManager.hxx deleted file mode 100644 index 32684c267..000000000 --- a/src/MEDMEM/MEDMEM_OptionManager.hxx +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef _OPTION_MANAGER_HXX -#define _OPTION_MANAGER_HXX - -#include <string> -#include <map> -#include "MEDMEM_Exception.hxx" -namespace MEDMEM -{ - class OptionGeneric - { - //dummy method to have some polymorphism... - virtual void dummy()=0; - }; - - template < class T > - class Option : public OptionGeneric - { - private: - T * _var; - public: - Option( T defaut, T * var): - _var(var) - { - *_var= defaut; - } - void setValue(T value) - { - *_var=value; - } - T getValue() - { - return * _var; - } - - //dummy method to have some polymorphism... - void dummy(){} - }; - - class OptionManager - { - private: - std::map< std::string, OptionGeneric* > _optionList; - - public: - - ~OptionManager() - { - std::map< std::string, OptionGeneric*>::iterator mi; - for(mi = _optionList.begin() ; mi != _optionList.end() ; mi++) delete (*mi).second; - } - - template <class T> void registerOption( T * var, const std::string& name, T defaut) - { - OptionGeneric * newoption = new Option<T>( defaut, var); - _optionList.insert(make_pair(name, newoption)); - } - - template <class T> void getOption(const std::string& name, T& var) - { - if(_optionList.find(name) != _optionList.end()) - { - Option<T>* option_ptr = dynamic_cast<Option<T>*>(_optionList.find(name)->second); - var= option_ptr->getValue(); - } - else throw MEDEXCEPTION - ("Option is not listed, please register the option before using the getOption command"); - } - - template <class T> void setOption(const std::string& name, T value) - { - if(_optionList.find(name) != _optionList.end()) - { - Option<T>* option_ptr = dynamic_cast<Option<T>*>(_optionList.find(name)->second); - if (option_ptr != 0 ) - option_ptr->setValue(value); - else throw MEDEXCEPTION ("Error setOption: Option is registered with a different type"); - } - else throw MEDEXCEPTION - ("Option is not listed, please register the option before using the setOption command"); - } - - void setOption(const std::string& name, int value) - { - if(_optionList.find(name) != _optionList.end()) - { - Option<double>* option_double_ptr = dynamic_cast<Option<double>*> (_optionList.find(name)->second); - if (option_double_ptr!=0) - setOption(name,(double) value); - else - { - Option<int>* option_ptr =dynamic_cast<Option<int>*>(_optionList.find(name)->second); - if (option_ptr != 0 ) - option_ptr->setValue(value); - else throw MEDEXCEPTION ("Error setOption: Option is registered with a different type"); - } - } - else throw MEDEXCEPTION - ("Option is not listed, please register the option before using the setOption command"); - } - - }; -} - -#endif diff --git a/src/MEDMEM/MEDMEM_PointerOf.hxx b/src/MEDMEM/MEDMEM_PointerOf.hxx deleted file mode 100644 index c9c401c90..000000000 --- a/src/MEDMEM/MEDMEM_PointerOf.hxx +++ /dev/null @@ -1,267 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -# if ! defined( __PointerOf_HXX__ ) -# define __PointerOf_HXX__ - -#include <cstdlib> -#include <cstring> -#include "MEDMEM_Utilities.hxx" -#include "MEDMEM_Exception.hxx" - -/*! - The template class PointerOf embedding a standard pointer (_pointer) is in charge of - managing the pointed memory.\n - - the object PointerOf is the memory owner if a size is given at object construction. - In these cases, memory will be desallocated at object destruction. In all other cases, - the desallocator will only nullify pointers. -*/ -namespace MEDMEM { - -template <typename T> class PointerOf -{ -protected : - /*! pointer to the pointed memory */ - T* _pointer ; - /*! boolean setted to true if memory has to be desallocated */ - bool _done ; - -public : - PointerOf() ; - ~PointerOf() ; - PointerOf( const int &size ) ; - PointerOf( const T *pointer ) ; - PointerOf( const int &size, const T *pointer ) ; - PointerOf( const PointerOf<T> & pointerOf ) ; - ///PointerOf( const int &size, const PointerOf<T> & pointerOf ) ; - operator T*() ; - operator const T*() const ; - void set( const int &size ) ; - void set( const T *pointer ) ; - void set( const int &size, const T *pointer ) ; - void setShallowAndOwnership( const T *pointer ); - PointerOf<T>& operator=( const PointerOf<T> &pointer ) ; -} ; - -// ------------------------------------------------------------ // -// // -// Implementation // -// // -// ------------------------------------------------------------ // - -/*! Creates a null T* pointer and sets the boolean (for desallocation) to false. */ -template <typename T> PointerOf<T>::PointerOf() : _pointer(0), _done(false) -{ -} - -/*! Creates a standard T* pointer to the pointed memory. \n - The boolean for desallocation is setted to false. \n - Be aware : \n - - The "old" PointerOf always has propriety of the pointed memory. \n - - If the "old" PointerOf is detroyed, the "new" PointerOf points - a desallocated memory zone. */ -template <typename T> PointerOf<T>::PointerOf(const PointerOf<T> & pointerOf) : - _pointer((T*)(const T* const)pointerOf), _done(false) -{ - const char* LOC = "PointerOf<T>::PointerOf(const PointerOf<T> & pointerOf)"; - BEGIN_OF_MED(LOC); - MESSAGE_MED("Warning ! No Propriety Transfer"); - END_OF_MED(LOC); -} - -/*! - Duplicate array of size size pointed in pointerOf. -*/ -//template <typename T> PointerOf<T>::PointerOf( const int &size, const PointerOf<T> & pointerOf) : -// _pointer((size,(T*)pointerOf)) -//{ -//} - -/*! If size < 0, creates a null "T*" pointer\n - Else allocates memory and sets desallocation boolean to true.\n - Memory will be desallocated when erasing this PointerOf*/ -template <typename T> PointerOf<T>::PointerOf( const int &size ) -{ - if (size < 0) - { - _pointer=(T*)NULL; - _done=false; - } - else - { - _pointer = new T[ size ] ; - _done=true; - } -} - -/*! Creates a standard pointer to the memory zone pointed by T*. \n - T* owner is in charged of memory desallocation. \n - Memory will not be released when erasing this PointerOf*/ -template <typename T> PointerOf<T>::PointerOf( const T* pointer ) : _pointer( (T*)pointer ), _done(false) -{ -} - -/*! If size < 0, return an exception\n - Else duplicate array and sets desallocation boolean to true.\n - Memory will be desallocated when erasing this PointerOf*/ -template <typename T> PointerOf<T>::PointerOf( const int &size, const T* pointer) -{ - if (size < 0) - throw MEDEXCEPTION("PointerOf( const int,const T*) : array size < 0"); - - _pointer = new T[ size ] ; - memcpy(_pointer,pointer,size*sizeof(T)); - _done=true; -} - -/*! The destuctor desallocates memory if necessary (that is if the attribute _done equals true).\n - The attribute _pointer is nullified */ -template <typename T> PointerOf<T>::~PointerOf() -{ - if ( _pointer ) - { - if( _done ) - { - MESSAGE_MED("PointerOf<T>::~PointerOf() --> deleting _pointer") ; - delete [] _pointer ; - _done = false ; - } - else - { - MESSAGE_MED("_pointer is only nullified") ; - } - _pointer = 0 ; - } -} - -/*! Creates a standard pointer (T*) to the pointed memory. \n - The boolean for desallocation is setted to false. \n - Be aware : \n - - The "right" PointerOf always has propriety of the pointed memory. \n - - If the "right" PointerOf is detroyed, the "left" PointerOf points - a desallocated memory zone. - - it works the same way as PointerOf(const PointerOf<T> & pointerOf) */ -template <typename T> PointerOf<T>& PointerOf<T>::operator=( const PointerOf<T> &pointer ) -{ - const char* LOC = "PointerOf<T>::operator=( const PointerOf<T> &pointer )"; - BEGIN_OF_MED(LOC); - if ( &pointer != this ) - { - this->set( pointer._pointer ) ; - } - END_OF_MED(LOC); - return *this ; -} - -/*! Returns _pointer.*/ -template <typename T> PointerOf<T>::operator T*() -{ - return _pointer ; -} - - -/*! Returns _pointer.*/ -template <typename T> PointerOf<T>::operator const T*() const -{ - return _pointer ; -} - -/*! If necessary, released memory holded by PointerOf\n. - Else allocates memory and sets desallocation boolean to true.\n - Can be used in order to "nullify" an existing PointerOf\n - Memory will be desallocated when erasing this PointerOf*/ -template <typename T> void PointerOf<T>::set( const int &size ) -{ - if ( _pointer && _done ) - { - delete [] _pointer ; - _pointer=0 ; - } - // if (size < 0) TODO: analyse why it does not work - if (size <= 0) - { - _pointer=(T*)NULL; - } - else - { - _pointer = new T[ size ] ; - } - _done = true ; - return ; -} - -/*! If necessary, released memory holded by PointerOf\n. - Then, sets _pointer to the memory zone pointed by T*. \n - T* owner is in charged of memory desallocation. \n - memory will not be released when erasing this PointerOf*/ -template <typename T> void PointerOf<T>::set( const T *pointer ) -{ - MESSAGE_MED( "BEGIN PointerOf<T>::set( const T *pointer )" ) ; - SCRUTE_MED(pointer) ; - SCRUTE_MED(_done) ; - if ( _pointer && _done ) - { - MESSAGE_MED("PointerOf<T>::set --> deleting _pointer") ; - delete [] _pointer ; - _pointer=0 ; - _done=false ; - } - _pointer=(T*)pointer ; - _done=false ; - MESSAGE_MED( "END PointerOf<T>::set( const T *pointer )" ) ; - return ; -} - -/*! If necessary, released memory holded by PointerOf\n. - If size < 0, return an exception\n. - Else allocates memory and sets desallocation boolean to true.\n - Can be used in order to "nullify" an existing PointerOf\n - Memory will be desallocated when erasing this PointerOf*/ -template <typename T> void PointerOf<T>::set( const int &size, const T *pointer) -{ - if ( _pointer && _done ) - { - delete [] _pointer ; - _pointer = NULL ; - } - if (size < 0) - throw MEDEXCEPTION("PointerOf( const int,const T*) : array size < 0"); - - _pointer = new T[ size ] ; - memcpy(_pointer,pointer,size*sizeof(T)); - _done=true; - - return ; -} - -template <typename T> void PointerOf<T>::setShallowAndOwnership( const T *pointer ) -{ - if ( _pointer && _done ) - delete [] _pointer; - _pointer=(T*)pointer; - _done=true; -} - -}//End namespace MEDMEM - -# endif /* # if ! defined( __PointerOf_HXX__ ) */ diff --git a/src/MEDMEM/MEDMEM_PorflowMeshDriver.cxx b/src/MEDMEM/MEDMEM_PorflowMeshDriver.cxx deleted file mode 100644 index 64858b8ec..000000000 --- a/src/MEDMEM/MEDMEM_PorflowMeshDriver.cxx +++ /dev/null @@ -1,797 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_PorflowMeshDriver.hxx" -#include "MEDMEM_DriversDef.hxx" -#include "MEDMEM_DriverTools.hxx" - -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Group.hxx" -#include "MEDMEM_Coordinate.hxx" -#include "MEDMEM_Connectivity.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_CellModel.hxx" -#include "MEDMEM_define.hxx" -#include <string.h> -#include <ctype.h> -#include <iostream> -#include <sstream> -#include <iomanip> - -using namespace std; -using namespace MED_EN; -using namespace MEDMEM; - -// geometric types conversion from PORFLOW -> MED -//const size_t PORFLOW_MESH_DRIVER::nb_geometrie_porflow; -const medGeometryElement PORFLOW_MESH_DRIVER::geomPORFLOWtoMED[nb_geometrie_porflow] = - { /* 1 */ MED_TRIA3 ,/* 2 */ MED_QUAD4 ,/* 3 */ MED_TETRA4 ,/* 4 */ MED_PYRA5 , - /* 5 */ MED_PENTA6 ,/* 6 */ MED_HEXA8 }; -// indirection table from PORFLOW order to MED one for nodes numerotation in all PORFLOW geometries -//const size_t PORFLOW_MESH_DRIVER::nb_nodes_max; - -// conversion from porflow connectivity to MED connectivity -const int PORFLOW_MESH_DRIVER::numPORFLOWtoMED[nb_geometrie_porflow] [nb_nodes_max] = { - /* TRI3 */ { /*1*/ 1, /*2*/ 3, /*3*/ 2 }, - /* QUA4 */ { /*1*/ 1, /*2*/ 4, /*3*/ 3, /*4*/ 2 }, - /* TETRA4 */ { /*1*/ 1, /*2*/ 4, /*3*/ 3, /*4*/ 2 }, - /* PYRA5 */ { /*1*/ 1, /*2*/ 4, /*3*/ 3, /*4*/ 2, /*5*/ 5 }, - /* PENTA6 */ { /*1*/ 1, /*2*/ 3, /*3*/ 2, /*4*/ 4, /*5*/ 6, /*6*/ 5 }, - /* HEXA8 */ { /*1*/ 1, /*2*/ 4, /*3*/ 3, /*4*/ 2, /*5*/ 5, /*6*/ 8, /*7*/ 7, /*8*/ 6 } }; - -// Porflox nodal connectivity of faces - documented in Porflow user's manual -//const size_t PORFLOW_MESH_DRIVER::nb_faces_max; -//const size_t PORFLOW_MESH_DRIVER::nb_nodes2_max; -const int PORFLOW_MESH_DRIVER::connectivityPORFLOW[nb_geometrie_porflow][nb_faces_max][nb_nodes2_max]={ - //{/* TRI3 */ {3,1,0,0}, {1,2,0,0}, {2,3,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0} }, - //{/* QUA4 */ {1,4,0,0}, {2,3,0,0}, {1,2,0,0}, {3,4,0,0}, {0,0,0,0}, {0,0,0,0} }, - {/* TRI3 */ {1,3,0,0}, {2,1,0,0}, {3,2,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0} }, - {/* QUA4 */ {1,4,0,0}, {3,2,0,0}, {2,1,0,0}, {4,3,0,0}, {0,0,0,0}, {0,0,0,0} }, - {/* TETRA4 */ {1,3,4,0}, {1,4,2,0}, {4,3,2,0}, {1,2,3,0}, {0,0,0,0}, {0,0,0,0} }, - {/* PYRA5 */ {1,4,5,0}, {1,5,2,0}, {3,2,5,0}, {4,3,5,0}, {1,2,3,4}, {0,0,0,0} }, - {/* PENTA6 */ {1,3,6,4}, {2,1,4,5}, {3,2,5,6}, {1,2,3,0}, {4,6,5,0}, {0,0,0,0} }, - {/* HEXA8 */ {1,4,8,5}, {3,2,6,7}, {2,1,5,6}, {4,3,7,8}, {1,2,3,4}, {5,8,7,6} }, -}; - -// helper function -inline static bool isKeyWord(const string & line, const char * key); -inline static void locateFileName(const string& line, string::size_type& pos1, string::size_type& pos2); -inline static string getPorflowFileName(const string& line, const char * context); -inline static medGeometryElement get2DMedGeomType(int nbSommets); - - -// Every memory allocation made in the MedDriver members function are desallocated in the Mesh destructor - -PORFLOW_MESH_DRIVER::PORFLOW_MESH_DRIVER(): - GENDRIVER(PORFLOW_DRIVER), - _ptrMesh(( MESH *) NULL), - // A VOIR _medIdt(MED_INVALID), - _meshName("") -{ -} - -PORFLOW_MESH_DRIVER::PORFLOW_MESH_DRIVER(const string & fileName, - GMESH * ptrMesh, - MED_EN::med_mode_acces accessMode): - GENDRIVER(fileName, accessMode, PORFLOW_DRIVER), - _ptrMesh(0) -{ - if (ptrMesh) - _ptrMesh = const_cast<MESH*>( ptrMesh->convertInMESH() ); - // mesh name construction from fileName - const string ext=".inp"; // expected extension - string::size_type pos=fileName.find(ext,0); - string::size_type pos1=fileName.rfind('/'); -#ifdef WIN32 - if (pos1 == string::npos ) pos1=fileName.rfind('\\'); -#endif - if (pos1 != string::npos ) - _meshName = string(fileName,pos1+1,pos-pos1-1); //get rid of directory & extension - else - _meshName = string(fileName,0,pos); //get rid of directory & extension - SCRUTE_MED(_meshName); -} - -PORFLOW_MESH_DRIVER::PORFLOW_MESH_DRIVER(const PORFLOW_MESH_DRIVER & driver): - GENDRIVER(driver), - _ptrMesh(driver._ptrMesh), - // A VOIR _medIdt(MED_INVALID), - _meshName(driver._meshName) -{ - if (_ptrMesh) - _ptrMesh->addReference(); -} - -PORFLOW_MESH_DRIVER::~PORFLOW_MESH_DRIVER() -{ - if (_ptrMesh) - _ptrMesh->removeReference(); -} - -void PORFLOW_MESH_DRIVER::open() - throw (MEDEXCEPTION) -{ - const char * LOC = "PORFLOW_MESH_DRIVER::open()" ; - BEGIN_OF_MED(LOC); - - if (_status == MED_OPENED) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"File "<<_fileName<<" is already open")); - - _porflow.open(_fileName.c_str(), ios::in); - if(_porflow) - _status = MED_OPENED; - else - { - _status = MED_CLOSED; - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Could not open file "<<_fileName<<" in mode ios::in")); - } - END_OF_MED(LOC); -} - -void PORFLOW_MESH_DRIVER::close() - throw (MEDEXCEPTION) -{ - const char* LOC = "PORFLOW_MESH_DRIVER::close() "; - BEGIN_OF_MED(LOC); - if ( _status == MED_OPENED) { - _porflow.close(); - _status = MED_CLOSED; - } - END_OF_MED(LOC); -} - -void PORFLOW_MESH_DRIVER::setMeshName(const string & meshName) { _meshName = meshName; } -string PORFLOW_MESH_DRIVER::getMeshName() const { return _meshName; } - - -//---------------------------------- RDONLY PART ------------------------------------------------------------- - -PORFLOW_MESH_RDONLY_DRIVER::PORFLOW_MESH_RDONLY_DRIVER(): PORFLOW_MESH_DRIVER() -{ -} - -PORFLOW_MESH_RDONLY_DRIVER::PORFLOW_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh): - PORFLOW_MESH_DRIVER(fileName,ptrMesh,RDONLY) -{ - MESSAGE_MED("PORFLOW_MESH_RDONLY_DRIVER::PORFLOW_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created"); -} - -PORFLOW_MESH_RDONLY_DRIVER::PORFLOW_MESH_RDONLY_DRIVER(const PORFLOW_MESH_RDONLY_DRIVER & driver): - PORFLOW_MESH_DRIVER(driver) -{ -} - -PORFLOW_MESH_RDONLY_DRIVER::~PORFLOW_MESH_RDONLY_DRIVER() -{ - //MESSAGE_MED("PORFLOW_MESH_RDONLY_DRIVER::~PORFLOW_MESH_RDONLY_DRIVER() has been destroyed"); -} - -GENDRIVER * PORFLOW_MESH_RDONLY_DRIVER::copy(void) const -{ - return new PORFLOW_MESH_RDONLY_DRIVER(*this); -} - -// helper function to check if line starts with key -inline static bool isKeyWord(const string & line, const char * key) -{ - const int SIZE_KEY=4; - const char * pt=line.c_str(); - while( isspace(*pt) ) // get rid of leading blanks - ++pt; - return !strncmp(pt,key,SIZE_KEY); -} - -inline static void locateFileName(const string& line, string::size_type& pos1, string::size_type& pos2) -{ - pos1 = line.find('"',0); - if ( pos1 != string::npos ) // if we found " - pos2=line.find('"',pos1+1); // search a second " - else // we didn't succeed with double quotes, so we try single quotes - { - pos1 = line.find('\'',0); - if ( pos1 != string::npos ) // if we found ' - pos2=line.find('\'',pos1+1); // search a second ' - } -} - - -// helper fonction : inversion of PORFLOW_MESH_DRIVER::geomPORFLOWtoMED -// return the Porflow geometric type, -1 if not found -inline int PORFLOW_MESH_DRIVER::geomMEDtoPorflow(medGeometryElement medGeo) -{ - for (int g=0; g!=nb_geometrie_porflow; ++g) - if( medGeo == geomPORFLOWtoMED[g] ) - return g; - return -1; -} - - -// Correspondance between the number of nodes and the Med face geometric type -inline static medGeometryElement get2DMedGeomType(int nbSommets) -{ - switch (nbSommets) - { - case 2: - return MED_SEG2; - break; - case 3: - return MED_TRIA3; - break; - case 4: - return MED_QUAD4; - break; - } - return MED_NONE; -} - -// helper function to read a porflow file name (enclosed in single or double quotes) in line -inline static string getPorflowFileName(const string& line, const char * context) -{ - string::size_type pos1=string::npos; - string::size_type pos2=string::npos; - - locateFileName(line, pos1, pos2); - - // if we found a not empty filename - if (pos1 != string::npos && pos2 != string::npos && pos2>pos1+1) - return string(line,pos1+1,pos2-pos1-1); - - // else, we throw an exception - string diagnosis("PORFLOW_MESH_RDONLY_DRIVER::read() : Error after reading keyword "); - diagnosis+=context; - diagnosis+="\nNo filename was found enclosed in single or double quotes\n"; - throw MEDEXCEPTION(diagnosis.c_str()); -} - - -// helper function to read a porflow coordinate file ( .xyz ) -void PORFLOW_MESH_RDONLY_DRIVER::readPorflowCoordinateFile(const string & coorFileName,_intermediateMED & medi,const int space_dimension) -{ - - ifstream coorFile(coorFileName.c_str(), ios::in); - if(!coorFile) - { - string diagnosis("PORFLOW_MESH_RDONLY_DRIVER::read()\nError, can't open coordinates file :"); - diagnosis+=coorFileName; - throw MEDEXCEPTION(diagnosis.c_str()); - } - - // scan of the coord file - _noeud node; - node.coord.resize(space_dimension); - string buf_ligne; // to read a line - while ( getline(coorFile, buf_ligne) ) // we can't use input stream directly because some 2D files have "0.0" in third coordinate - { - istringstream buf(buf_ligne.c_str()); - buf >> node.number; - if (!buf) // for spaces at the end of the file - break; - for (int i=0; i!=space_dimension; ++i) - buf >> node.coord[i]; - medi.points.insert(make_pair(node.number,node)); - } - coorFile.close(); -} - -// helper function to read a porflow connectivity file ( .cnc ) -void PORFLOW_MESH_RDONLY_DRIVER::readPorflowConnectivityFile(bool hybride,const string & connecFileName,_intermediateMED & medi,std::vector<std::set<_maille>::iterator>& p_ma_table,int mesh_dimension) -{ - - ifstream connFile(connecFileName.c_str(), ios::in); - if(!connFile) - { - string diagnosis("PORFLOW_MESH_RDONLY_DRIVER::read()\nError, can't open connectivity file :"); - diagnosis+=connecFileName; - throw MEDEXCEPTION(diagnosis.c_str()); - } - - _maille maille; - unsigned int code, nodes_number, node, ordre; - set<_maille>::iterator p_ma; - - if (hybride) // "HYBR" key-word - while (connFile) - { - connFile >> ordre; - maille.setOrdre( ordre ); - if (!connFile) // for spaces at the end of the file - break; - connFile >> code; - connFile >> nodes_number; - maille.geometricType = geomPORFLOWtoMED[code-1]; - if(maille.geometricType%100!=(int)nodes_number) // following incohenrences founded in some porflow files! - { - MESSAGE_MED("WARNING : the read node number don't seem to be compatible with geometric type!"); - SCRUTE_MED(maille.geometricType); - SCRUTE_MED(nodes_number); - } - maille.sommets.resize(nodes_number); - for (unsigned i=0; i!=nodes_number; ++i) - { - connFile >> node; - maille.sommets[numPORFLOWtoMED[code-1][i]-1] = medi.points.find(node); - } - p_ma = medi.insert(maille); - if (maille.ordre() > p_ma_table.size()-1) // construction of a vector of iterators on _maille structures - p_ma_table.resize(2*maille.ordre()); - p_ma_table[maille.ordre()] = p_ma; - } - else // default case (or "VERT" key-word) - { - if (mesh_dimension == 2) // we have QUA4 - { - code = 2; - maille.geometricType = geomPORFLOWtoMED[code-1]; - nodes_number = 4; - maille.sommets.resize(nodes_number); - } - else if (mesh_dimension == 3) // we have HEXA8 - { - code = 6; - maille.geometricType = geomPORFLOWtoMED[code-1]; - nodes_number = 8; - maille.sommets.resize(nodes_number); - } - else - throw MEDEXCEPTION("PORFLOW_MESH_RDONLY_DRIVER::read()\nError, can't determine geometric type for this VERT mesh"); - while (connFile) - { - connFile >> ordre; maille.setOrdre(ordre); - if (!connFile) // for spaces at the end of the file - break; - for (unsigned i=0; i!=nodes_number; ++i) - { - connFile >> node; - maille.sommets[numPORFLOWtoMED[code-1][i]-1] = medi.points.find(node); - } - p_ma = medi.insert(maille); - if (maille.ordre() > p_ma_table.size()-1) // construction of a vector of iterators on _maille structures - p_ma_table.resize(2*maille.ordre()); - p_ma_table[maille.ordre()] = p_ma; - } - } - connFile.close(); -} - -void PORFLOW_MESH_RDONLY_DRIVER::read(void) - throw (MEDEXCEPTION) -{ - const char * LOC = "PORFLOW_MESH_RDONLY_DRIVER::read() : " ; - BEGIN_OF_MED(LOC); - - if (_status!=MED_OPENED) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName - << " is : " << " (the file is not opened)." )) ; - - // if _fileName contains a directory, extract the directory name - // the directory name will be used to locate the files included in _fileName. - string dirName; - string::size_type pos=_fileName.rfind('/'); -#ifdef WIN32 - if (pos == string::npos ) pos=_fileName.rfind('\\'); -#endif - if (pos != string::npos ) - dirName=string(_fileName, 0, pos+1); - - _intermediateMED medi; // structure de données intermédiaire pour conversion porflow->med - string buf_ligne; // pour lire une ligne - unsigned numberOfGridElement=0; // number of grid elements - unsigned space_dimension=2; // by default, the problem is assumed to be 2D - string coordinateSystem="CARTESIAN"; - bool hybride=false; - _groupe currentGroup; - vector<bool> isGroupAList; // vector to store the type of a group (ie PAIR or LIST) - bool processLoca=false; - string connFileName; - string coorFileName; - std::vector<std::set<_maille>::iterator> p_ma_table(10000); // store iterators for direct access by index - string small("abcdefghijklmnopqrstuvwxyz"); - - while ( getline(_porflow, buf_ligne) ) // scan .inp file and look for main keywords (LOCA, GRID, COOR & CONN) - { - - // Skip comments - if(buf_ligne[0]=='/') - continue; - - // look if there is a filename - string::size_type pos1=string::npos; - string::size_type pos2=string::npos; - locateFileName(buf_ligne, pos1, pos2); - - pos=0; - if (pos1!=string::npos && pos2!=string::npos) // if there is a file name in buf_line - // convert every char to upper, except those between pos1-pos2 (which correspond to a file name) - while ( (pos=buf_ligne.find_first_of(small,pos)) != string::npos ) - if (pos<pos1 || pos>pos2 ) - buf_ligne[pos]=toupper(buf_ligne[pos]); - else - ++pos; - else - // convert every char to upper - while ( (pos=buf_ligne.find_first_of(small,pos)) != string::npos ) - buf_ligne[pos]=toupper(buf_ligne[pos]); - - - // LOCA KEYWORD : - // expected syntax : - // - LOCA {PAIR} [ID=id] {N1,N2, ... ,Nn} : group specification by paired element & surface numbers - // - LOCA {LIST} [ID=id] {N1, ... ,Nn} : group specification by a list of elements - // the syntax corresponding to the use of input file is not implemented - if ( isKeyWord(buf_ligne,"LOCA") ) - { - MESSAGE_MED("Mot clé LOCA détecté"); - processLoca=true; - // if currentGroup is not empty, a group has been precessed - // -> we store it, clear currentGroup, and start the precessing of a new group - if ( !currentGroup.groupes.empty() ) - medi.groupes.push_back(currentGroup); - currentGroup.groupes.clear(); - currentGroup.nom.erase(); - if ( buf_ligne.find("PAIR",0) != string::npos ) - { - isGroupAList.push_back(false); - } - else if ( buf_ligne.find("LIST",0) != string::npos ) - { - isGroupAList.push_back(true); - } - else - throw MEDEXCEPTION("PORFLOW_MESH_RDONLY_DRIVER::read() : Error, after keyword LOCA, LIST or PAIR is expected\n"); - - pos=buf_ligne.find("ID=",0); - if ( pos != string::npos ) - { - istringstream buf(buf_ligne.c_str()+pos+3); - buf >> currentGroup.nom; - - // avoid problem in the following processing of elements if the group's name contains a digit - // -> we replace group's name with blanks - while( pos<buf_ligne.size() && !isspace( buf_ligne[pos] ) ) - buf_ligne[pos++]=' '; - } - } - - - // GRID KEYWORD : - // expected syntax : GRID {UNST} [THREE] {N1} [NODE] [N2] - // the syntax corresponding to structured grids is not implemented - else if ( isKeyWord(buf_ligne,"GRID") ) - { - MESSAGE_MED("Mot clé GRID détecté"); - processLoca=false; - pos=buf_ligne.find("UNST",0); - if ( pos != string::npos ) // unstructured grid - { - // we find the number of grid elements - string::size_type len=buf_ligne.size(); - while ( pos<len && !isdigit(buf_ligne[pos]) ) - ++pos; - if ( pos==len ) - throw MEDEXCEPTION("PORFLOW_MESH_RDONLY_DRIVER::read() : Error, number of grid elements unspecified!\n"); - istringstream buf(buf_ligne.c_str()+pos); - buf >> numberOfGridElement; - - pos=buf_ligne.find("THREE",0); - if ( pos != string::npos ) // if we find THREE, the problem is 3D - space_dimension=3; - } - else - { - throw MEDEXCEPTION("PORFLOW_MESH_RDONLY_DRIVER::read() : Error, structured grids are not yet supported!\n"); - } - } - - - // CONN KEYWORD : - // expected syntax : - // - CONN {HYBR} {filename} : vertex connectivity for mixed hybrid elements - // - CONN {VERT} {filename} : vertex connectivity for quad or hex elements - // the default option is HYBR - else if ( isKeyWord(buf_ligne,"CONN") ) - { - MESSAGE_MED("Mot clé CONN détecté"); - processLoca=false; - string fileCONN=getPorflowFileName(buf_ligne,"CONN"); - - if ( buf_ligne.find("HYBR",0) != string::npos ) - hybride=true; - - - if(fileCONN.rfind('/') == string::npos) - // no directory was specified -> we add dirName, which may be empty - - connFileName=dirName+fileCONN; - else - connFileName=fileCONN; - } - - - // COOR KEYWORD : - // expected syntax : COOR {VERT} {filename} - else if ( isKeyWord(buf_ligne,"COOR") ) - { - MESSAGE_MED("Mot clé COOR"); - processLoca=false; - string fileCOOR=getPorflowFileName(buf_ligne,"COOR"); - - pos=buf_ligne.find("VERT",0); - if ( pos == string::npos ) - throw MEDEXCEPTION("PORFLOW_MESH_RDONLY_DRIVER::read() : Error, after keyword COOR, we require VERT\n"); - - pos=buf_ligne.find("CYLI",0); - if ( pos != string::npos ) - coordinateSystem="CYLINDRICAL"; - - if(fileCOOR.rfind('/') == string::npos) - // no directory was specified -> we add dirName, which may be empty - coorFileName=dirName+fileCOOR; - else - coorFileName=fileCOOR; - } - - - if (processLoca) - { - // read group specification - - - // replace non digit caracters with blanks - string::iterator last_non_blank=buf_ligne.end(); - for (string::iterator it=buf_ligne.begin(); it!=buf_ligne.end(); ++it) - if ( !isdigit(*it) ) - *it=' '; - else - last_non_blank=it; - - if (last_non_blank != buf_ligne.end() ) // if the line is not blank - { - buf_ligne=string(buf_ligne.begin(),++last_non_blank); // suppress trailing blanks - - istringstream buf(buf_ligne.c_str()); - int i1; - buf >> i1; // we know the line is not blank - do - { - currentGroup.groupes.push_back(i1); - buf >> i1; - } - while ( buf ); - - } - } - - } - if ( !currentGroup.groupes.empty() ) // if necessary, add the last group to medi.groupes - medi.groupes.push_back(currentGroup); - - readPorflowCoordinateFile(coorFileName,medi,space_dimension); - readPorflowConnectivityFile(hybride,connFileName,medi,p_ma_table,space_dimension); - - - // Group processing : - // In the scan loop, we have store in medi.groupes.groupes either : - // - paired list of element and surface number (keyword PAIR) - // - an explicit list of element numbers (keyword LIST) - // What we stored (pairs or list) is remembered through vector isGroupAList. - // For both cases, we must convert these numbers to iterators to cells inside the set medi.maillage - // - in the LIST case, these cells already exist. - // - in the PAIR case, we have to create the corresponding 2D/1D faces - // scan groups - //for( std::vector<_groupe>::iterator i=medi.groupes.begin(); i!=medi.groupes.end(); ++i) - for( unsigned i=0; i!=medi.groupes.size(); ++i) - { - if ( isGroupAList[i] ) - { - // medi.groupes[i].groupes is a vector of element numbers; it points to it - medi.groupes[i].mailles.resize( medi.groupes[i].groupes.size() ); - std::vector<int>::const_iterator it=medi.groupes[i].groupes.begin(); - for(int j = 0 ; it!=medi.groupes[i].groupes.end(); ++it, ++j) - { - // insert the iterator to the corresponding cell we stored in p_ma_table - medi.groupes[i].mailles[j] = p_ma_table[*it]; - } - - } - else - { - int nelem=0; - int nface=0; - int ngeom=0; - int ielem=0; - std::set<_maille>::iterator p_ma; - _maille maille2D; - - // medi.groupes[i].groupes is a vector of paired element and surface numbers - // *it points to the element number, *(it+1) points to the surface number - std::vector<int>::const_iterator it=medi.groupes[i].groupes.begin(); - medi.groupes[i].mailles.resize( medi.groupes[i].groupes.size() / 2 ); - for( ; it!=medi.groupes[i].groupes.end(); ++it) - { - nelem=*it; - nface=*(++it); - p_ma=p_ma_table[nelem]; // points to the cell - ngeom=geomMEDtoPorflow(p_ma->geometricType); - - // create the face corresponding to nface - int l=0; - while( l<nb_nodes2_max && connectivityPORFLOW[ngeom][nface-1][l] ) - { - maille2D.sommets.push_back(p_ma->sommets[ numPORFLOWtoMED[ngeom][ connectivityPORFLOW[ngeom][nface-1][l++]-1 ]-1 ]); - } - - // the corresponding 2D MED geometric type depends upon the number of nodes - maille2D.sommets.resize(l); - maille2D.geometricType = get2DMedGeomType(l); - p_ma = medi.insert(maille2D); // we insert the face in our mesh - medi.groupes[i].mailles[ielem++]=p_ma; // and insert an iterator on it in our group - maille2D.sommets.clear(); - } - - } - medi.groupes[i].groupes.clear(); // we don't need element numbers anymore - - } - - p_ma_table.clear(); // we don't need it anymore - MESSAGE_MED(LOC << "PORFLOW_MESH_RDONLY_DRIVER::read : RESULTATS STRUCTURE INTERMEDIAIRES : "); - MESSAGE_MED(LOC << medi ); - // TRANSFORMATION EN STRUCTURES MED - if ( ! _ptrMesh->isEmpty() ) - { - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Mesh object not empty : can't fill it!")); - } - else if ( /*medi.maillage.size()==0 || */medi.groupes.size()==0 || medi.points.size()==0) - { - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << " Error while reading file " << _fileName - << " The data read are not completed " ) ) ; - } - else - { - _ptrMesh->_name = _meshName; - _ptrMesh->_spaceDimension = medi.points.begin()->second.coord.size(); - _ptrMesh->_numberOfNodes = medi.points.size(); - _ptrMesh->_coordinate = medi.getCoordinate(); - - //Construction des groupes - vector<GROUP *> groupCell, groupFace, groupEdge, groupNode; - medi.getGroups(groupCell, groupFace, groupEdge, groupNode, _ptrMesh); - _ptrMesh->_groupCell = groupCell; - _ptrMesh->_groupFace = groupFace; - _ptrMesh->_groupEdge = groupEdge; - _ptrMesh->_groupNode = groupNode; - - // appele en dernier car cette fonction detruit le maillage intermediaire! - _ptrMesh->_connectivity = medi.getConnectivity(); - MESSAGE_MED(LOC << "PORFLOW_MESH_RDONLY_DRIVER::read : FIN "); - - // calcul de la connectivite d-1 complete, avec renumerotation des groupes - // if (_ptrMesh->_spaceDimension==3) - // _ptrMesh->_connectivity->updateGroup(_ptrMesh->_groupFace) ; - // else if (_ptrMesh->_spaceDimension==2) - // _ptrMesh->_connectivity->updateGroup(_ptrMesh->_groupEdge) ; - - // Creation des familles ?artir des groupes - // NC : Cet appel pourra ?e diff鲩 quand la gestion de la cohé²¥nce famille/groupes sera assur饊 _ptrMesh->createFamilies(); - } - - - END_OF_MED(LOC); -} - -void PORFLOW_MESH_RDONLY_DRIVER::write( void ) const - throw (MEDEXCEPTION) -{ - throw MEDEXCEPTION("PORFLOW_MESH_RDONLY_DRIVER::write : Can't write with a RDONLY driver !"); -} - - -/*--------------------- WRONLY PART -------------------------------*/ - -PORFLOW_MESH_WRONLY_DRIVER::PORFLOW_MESH_WRONLY_DRIVER():PORFLOW_MESH_DRIVER() -{ -} - -PORFLOW_MESH_WRONLY_DRIVER::PORFLOW_MESH_WRONLY_DRIVER(const string & fileName, - GMESH * ptrMesh): - PORFLOW_MESH_DRIVER(fileName,ptrMesh,WRONLY) -{ - MESSAGE_MED("PORFLOW_MESH_WRONLY_DRIVER::PORFLOW_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created"); -} - -PORFLOW_MESH_WRONLY_DRIVER::PORFLOW_MESH_WRONLY_DRIVER(const PORFLOW_MESH_WRONLY_DRIVER & driver): - PORFLOW_MESH_DRIVER(driver) -{ -} - -PORFLOW_MESH_WRONLY_DRIVER::~PORFLOW_MESH_WRONLY_DRIVER() -{ - //MESSAGE_MED("PORFLOW_MESH_WRONLY_DRIVER::PORFLOW_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed"); -} - -GENDRIVER * PORFLOW_MESH_WRONLY_DRIVER::copy(void) const -{ - return new PORFLOW_MESH_WRONLY_DRIVER(*this); -} - -void PORFLOW_MESH_WRONLY_DRIVER::read (void) - throw (MEDEXCEPTION) -{ - throw MEDEXCEPTION("PORFLOW_MESH_WRONLY_DRIVER::read : Can't read with a WRONLY driver !"); -} - -void PORFLOW_MESH_WRONLY_DRIVER::write(void) const - throw (MEDEXCEPTION) -{ - const char * LOC = "void PORFLOW_MESH_WRONLY_DRIVER::write(void) const : "; - BEGIN_OF_MED(LOC); - - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< "Write Driver isn\'t implemented")); - - END_OF_MED(LOC); -} - - - -/*--------------------- RDWR PART -------------------------------*/ - -PORFLOW_MESH_RDWR_DRIVER::PORFLOW_MESH_RDWR_DRIVER(): - PORFLOW_MESH_DRIVER(), - PORFLOW_MESH_RDONLY_DRIVER(), - PORFLOW_MESH_WRONLY_DRIVER() -{ -} - -PORFLOW_MESH_RDWR_DRIVER::PORFLOW_MESH_RDWR_DRIVER(const string & fileName,MESH * ptrMesh): - PORFLOW_MESH_DRIVER(fileName,ptrMesh,RDWR), - PORFLOW_MESH_RDONLY_DRIVER(fileName,ptrMesh), - PORFLOW_MESH_WRONLY_DRIVER(fileName,ptrMesh) -{ - MESSAGE_MED("PORFLOW_MESH_RDWR_DRIVER::PORFLOW_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been created"); -} - -PORFLOW_MESH_RDWR_DRIVER::PORFLOW_MESH_RDWR_DRIVER(const PORFLOW_MESH_RDWR_DRIVER & driver): - PORFLOW_MESH_DRIVER(driver), - PORFLOW_MESH_RDONLY_DRIVER(driver), - PORFLOW_MESH_WRONLY_DRIVER(driver) -{ -} - -PORFLOW_MESH_RDWR_DRIVER::~PORFLOW_MESH_RDWR_DRIVER() { - //MESSAGE_MED("PORFLOW_MESH_RDWR_DRIVER::PORFLOW_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed"); -} - -GENDRIVER * PORFLOW_MESH_RDWR_DRIVER::copy(void) const -{ - return new PORFLOW_MESH_RDWR_DRIVER(*this); -} - -void PORFLOW_MESH_RDWR_DRIVER::write(void) const - throw (MEDEXCEPTION) -{ - PORFLOW_MESH_WRONLY_DRIVER::write(); -} -void PORFLOW_MESH_RDWR_DRIVER::read (void) - throw (MEDEXCEPTION) -{ - PORFLOW_MESH_RDONLY_DRIVER::read(); -} diff --git a/src/MEDMEM/MEDMEM_PorflowMeshDriver.hxx b/src/MEDMEM/MEDMEM_PorflowMeshDriver.hxx deleted file mode 100644 index a9a0a40ba..000000000 --- a/src/MEDMEM/MEDMEM_PorflowMeshDriver.hxx +++ /dev/null @@ -1,267 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef PORFLOW_MESH_DRIVER_HXX -#define PORFLOW_MESH_DRIVER_HXX - -#include "MEDMEM.hxx" - -#include <string> -#include <fstream> - -#include "MEDMEM_define.hxx" -#include "MEDMEM_GenDriver.hxx" -//#include "MEDMEM_DriverTools.hxx" - -#include "MEDMEM_STRING.hxx" -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_Utilities.hxx" - -#include <vector> -#include <set> - -/*! - - Driver PORFLOW for MESH. - - Generic part : implement the readopen and close methods. - -*/ - - -namespace MEDMEM { -class GMESH; -class MESH; -class FAMILY; -class GROUP; -class CONNECTIVITY; -struct _intermediateMED; -struct _maille; -class MEDMEM_EXPORT PORFLOW_MESH_DRIVER : public GENDRIVER -{ -protected: - - MESH * _ptrMesh; - // A VOIR FILE DESCRIPTEUR ? MED_FR::med_idt _medIdt; - string _meshName; - ifstream _porflow; - - // This enumeration is used to substitude static const - // memers data causing link errors on VC7 compiler. - enum - { - nb_geometrie_porflow = 6, - nb_nodes_max = 8, // maximal number of nodes for a porflow geometrie - nb_nodes2_max = 4, // maximal number of nodes for a 2D porflow geometrie - nb_faces_max = 6 // maximal number of faces for a porflow geometrie - }; - - // tableau de correspondance des types géométriques de PORFLOW -> MED - //static const size_t nb_geometrie_porflow = 6; - static const MED_EN::medGeometryElement geomPORFLOWtoMED[nb_geometrie_porflow]; - // indirection table from PORFLOW order to MED one for nodes numerotation in all PORFLOW geometries - //static const size_t nb_nodes_max = 8; // maximal number of nodes for a porflow geometrie - //static const size_t nb_nodes2_max = 4; // maximal number of nodes for a 2D porflow geometrie - //static const size_t nb_faces_max = 6; // maximal number of faces for a porflow geometrie - static const int numPORFLOWtoMED[nb_geometrie_porflow] [nb_nodes_max]; - static const int connectivityPORFLOW[nb_geometrie_porflow][nb_faces_max][nb_nodes2_max]; - inline static int geomMEDtoPorflow(MED_EN::medGeometryElement medGeo); - - -public : - - /*! - Constructor. - */ - PORFLOW_MESH_DRIVER() ; - /*! - Constructor. - */ - PORFLOW_MESH_DRIVER(const string & fileName, - GMESH * ptrMesh, - MED_EN::med_mode_acces accessMode) ; - /*! - Copy constructor. - */ - PORFLOW_MESH_DRIVER(const PORFLOW_MESH_DRIVER & driver) ; - - /*! - Destructor. - */ - virtual ~PORFLOW_MESH_DRIVER() ; - - void open() throw (MEDEXCEPTION); - void close() throw (MEDEXCEPTION); - - virtual void write( void ) const = 0 ; - virtual void read ( void ) = 0 ; - - /*! - Set the name of the MESH asked in file. - - It could be different than the name of the MESH object. - */ - void setMeshName(const string & meshName) ; - /*! - Get the name of the MESH asked in file. - */ - string getMeshName() const ; - -private: - virtual GENDRIVER * copy ( void ) const = 0 ; - -}; - - -class MEDMEM_EXPORT PORFLOW_MESH_RDONLY_DRIVER : public virtual PORFLOW_MESH_DRIVER -{ - -public : - - /*! - Constructor. - */ - PORFLOW_MESH_RDONLY_DRIVER() ; - /*! - Constructor. - */ - PORFLOW_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) ; - /*! - Copy constructor. - */ - PORFLOW_MESH_RDONLY_DRIVER(const PORFLOW_MESH_RDONLY_DRIVER & driver) ; - - /*! - Destructor. - */ - virtual ~PORFLOW_MESH_RDONLY_DRIVER() ; - - /*! - Return a MEDEXCEPTION : it is the read-only driver. - */ - void write( void ) const throw (MEDEXCEPTION); - /*! - Read MESH in the specified file. - */ - void read ( void ) throw (MEDEXCEPTION); - -private: - - GENDRIVER * copy ( void ) const ; - - static void readPorflowCoordinateFile(const string & coorFileName,_intermediateMED & medi,const int space_dimension); - static void readPorflowConnectivityFile(bool hybride,const string & connecFileName,_intermediateMED & medi,std::vector<set<_maille>::iterator>& p_ma_table,int mesh_dimension); - -}; - -/*! - - Driver Med for MESH : Write only. - - Implement write method. - -*/ - -class MEDMEM_EXPORT PORFLOW_MESH_WRONLY_DRIVER : public virtual PORFLOW_MESH_DRIVER { - -public : - - /*! - Constructor. - */ - PORFLOW_MESH_WRONLY_DRIVER() ; - /*! - Constructor. - */ - PORFLOW_MESH_WRONLY_DRIVER(const string & fileName, GMESH * ptrMesh) ; - /*! - Copy constructor. - */ - PORFLOW_MESH_WRONLY_DRIVER(const PORFLOW_MESH_WRONLY_DRIVER & driver) ; - - /*! - Destructor. - */ - virtual ~PORFLOW_MESH_WRONLY_DRIVER() ; - - /*! - Write MESH in the specified file. - */ - void write( void ) const throw (MEDEXCEPTION); - /*! - Return a MEDEXCEPTION : it is the write-only driver. - */ - void read ( void ) throw (MEDEXCEPTION); - -private: - - GENDRIVER * copy ( void ) const ; -}; - - -/*! - - Driver PORFLOW for MESH : Read write. - - Use read method from PORFLOW_MESH_RDONLY_DRIVER - - Use write method from PORFLOW_MESH_WRONLY_DRIVER - -*/ - -class MEDMEM_EXPORT PORFLOW_MESH_RDWR_DRIVER : public PORFLOW_MESH_RDONLY_DRIVER, public PORFLOW_MESH_WRONLY_DRIVER { - -public : - - /*! - Constructor. - */ - PORFLOW_MESH_RDWR_DRIVER() ; - /*! - Constructor. - */ - PORFLOW_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) ; - /*! - Copy constructor. - */ - PORFLOW_MESH_RDWR_DRIVER(const PORFLOW_MESH_RDWR_DRIVER & driver) ; - - /*! - Destructor. - */ - ~PORFLOW_MESH_RDWR_DRIVER() ; - - /*! - Write MESH in the specified file. - */ - void write(void) const throw (MEDEXCEPTION); - /*! - Read MESH in the specified file. - */ - void read (void) throw (MEDEXCEPTION); - -private: - GENDRIVER * copy(void) const ; - -}; -} - - -#endif /* PORFLOW_MESH_DRIVER_HXX */ diff --git a/src/MEDMEM/MEDMEM_RCBase.cxx b/src/MEDMEM/MEDMEM_RCBase.cxx deleted file mode 100644 index 34ca870fa..000000000 --- a/src/MEDMEM/MEDMEM_RCBase.cxx +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "MEDMEM_RCBase.hxx" -#ifdef _DEBUG_ -#include <iostream> -#endif - -MEDMEM::RCBASE::RCBASE():_cnt(1) -{ -} - -MEDMEM::RCBASE::~RCBASE() -{ -} -/*! - * \brief To be called at destructor beginning to avoid recursive calls of destructor - * in case of cyclic dependencies between reference counters like e.g. between - * the GMESH and the GROUPs it contains - */ -void MEDMEM::RCBASE::clearRefCouner() -{ - _cnt = -100; -} - -void MEDMEM::RCBASE::addReference() const -{ - _cnt++; -} - -bool MEDMEM::RCBASE::removeReference() const -{ - bool ret=((--_cnt)==0); - if(ret) - delete this; - return ret; -} - -MEDMEM::AutoDeref::AutoDeref(const RCBASE* obj): _obj(obj) -{ -} - -MEDMEM::AutoDeref::~AutoDeref() -{ - if ( _obj ) - { - _obj->removeReference(); - _obj = 0; - } -} diff --git a/src/MEDMEM/MEDMEM_RCBase.hxx b/src/MEDMEM/MEDMEM_RCBase.hxx deleted file mode 100644 index dead75044..000000000 --- a/src/MEDMEM/MEDMEM_RCBase.hxx +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __MEDMEM_RCBASE_HXX__ -#define __MEDMEM_RCBASE_HXX__ - -#include "MEDMEM.hxx" - -namespace MEDMEM { - - class MEDMEM_EXPORT RCBASE { - public: - RCBASE(); - void addReference() const; - bool removeReference() const; - protected: - void clearRefCouner(); - virtual ~RCBASE(); - private: - mutable int _cnt; - }; - - /*! - * \brief Class calling RCBASE::removeReference() at distruction. - * Useful to avoid memory leaks in case of exceptions; - * helps not to forget to delete anything, etc. - */ - class MEDMEM_EXPORT AutoDeref - { - public: - AutoDeref(const RCBASE* obj); - ~AutoDeref(); - private: - const RCBASE* _obj; - AutoDeref(const AutoDeref&); - AutoDeref& operator=(const AutoDeref&); - }; - -} - -#endif diff --git a/src/MEDMEM/MEDMEM_Remapper.cxx b/src/MEDMEM/MEDMEM_Remapper.cxx deleted file mode 100644 index 4865e3255..000000000 --- a/src/MEDMEM/MEDMEM_Remapper.cxx +++ /dev/null @@ -1,374 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_Remapper.hxx" -#include "MEDMEM_Exception.hxx" -#include "Interpolation.hxx" -#include "Interpolation2D.txx" -#include "Interpolation3D.txx" -#include "Interpolation3DSurf.hxx" - - - -// int InterpolationOptions::_printLevel=0; -// IntersectionType InterpolationOptions::_intersectionType=Triangulation; -// double InterpolationOptions::_precision=1e-12;; -// double InterpolationOptions::_medianPlane =0.5; -// bool InterpolationOptions::_doRotate =true; -// double InterpolationOptions::_boundingBoxAdjustment =0.1; -// int InterpolationOptions::_orientation =0; -// SplittingPolicy InterpolationOptions::_splittingPolicy =GENERAL_48; - -/*! - \defgroup medmemremapper MEDMEM::MEDMEM_REMAPPER - - \section overview Overview - - \c MEDMEM_REMAPPER enables conservative remapping of fields - between two sequential codes. - The computation is possible for 3D meshes and 2D meshes or 3D surfaces. It enables fast sequential localization, based on a bounding box tree structure. It is based on cell-cell intersection or on a point in element search, depending on the field type. Fields can either lie on cells (P0) or nodes (P1). - - A typical use of \c MEDMEM_REMAPPER encompasses two distinct phases : - - A setup phase during which the intersection volumes are computed and the interpolation matrix is stored. This corresponds to calling the \c MEDMEM_REMAPPER::prepare() method. - - A use phase during which the remappings are actually performed. This corresponds to the calls to transfer() and reverseTransfer() which actually performs the interpolation. - - The following code excerpt illutrates a typical use of the \c MEDMEM_REMAPPER class. - - \code - ... - std::string sourceFileName("source.med"); - MEDMEM::MESH med_source_mesh(MED_DRIVER,sourceFileName,"Source_Mesh"); - std::string targetFileName("target.med"); - MEDMEM::MESH med_target_mesh(MED_DRIVER,targetFileName,"Target_Mesh"); - FIELD<double> sourceField(MED_DRIVER,sourceFileName,"Density",0,0); - FIELD<double> targetField; - MEDMEM_Remapper mapper; - mapper.setOptionsDouble("Precision",1e-7); - mapper.setOptionsString("Intersection_type",Geometric2D); - mapper.prepare(med_source_mesh,med_target_mesh,"P0P1"); - mapper.transfer(sourceField,targetField); - //use targetField - ... - \endcode - - @{ - */ - -MEDMEM_REMAPPER::MEDMEM_REMAPPER():_matrix(0),_sourceMesh(0), _targetMesh(0), _sourceSupport(0), _targetSupport(0) -{ -} - -MEDMEM_REMAPPER::~MEDMEM_REMAPPER() -{ - delete _matrix; - if(_sourceMesh) - _sourceMesh->removeReference(); - if(_targetMesh) - _targetMesh->removeReference(); -// if(_sourceSupport) -// _sourceSupport->removeReference(); -// if(_targetSupport) -// _targetSupport->removeReference(); -} -/*! This method computes the intersection matrix between - * source \a mesh_source and \a mesh_target. It is a preliminary step - * that is necessary before calling the \c transfer() method. - * The method analyses the dimensions of the meshes and checks for compatibility. - * - */ -int MEDMEM_REMAPPER::prepare(const MEDMEM::MESH& mesh_source, const MEDMEM::MESH& mesh_target, const char *method) -{ - const int sm_spacedim = mesh_source.getSpaceDimension(); - const int tm_spacedim = mesh_target.getSpaceDimension(); - int sm_meshdim = mesh_source.getMeshDimension(); - int tm_meshdim = mesh_target.getMeshDimension(); - - delete _matrix; - _matrix= new INTERP_KERNEL::Matrix<double,INTERP_KERNEL::ALL_FORTRAN_MODE>; - - if(_sourceMesh) - _sourceMesh->removeReference(); - _sourceMesh= new MEDMEM::MESH((MEDMEM::MESH&)mesh_source); - if(_targetMesh) - _targetMesh->removeReference(); - _targetMesh= new MEDMEM::MESH((MEDMEM::MESH&)mesh_target); - - std::string methodC=method; - if(methodC == "P0P0"){ - _sourceFieldType = "P0"; - _targetFieldType = "P0"; - } - else if(methodC =="P0P1"){ - _sourceFieldType = "P0"; - _targetFieldType = "P1"; - } - else if(methodC == "P1P0"){ - _sourceFieldType = "P1"; - _targetFieldType = "P0"; - } - else if(methodC == "P1P1"){ - _sourceFieldType = "P1"; - _targetFieldType = "P1"; - } - else - throw INTERP_KERNEL::Exception("MEDMEM_REMAPPER::prepare: Invalid method specified ! Must be in : \"P0P0\" \"P0P1\" \"P1P0\" or \"P1P1\""); - - -// if(_sourceSupport) -// _sourceSupport->removeReference(); -// if(_targetSupport) -// _targetSupport->removeReference(); - if( _sourceFieldType == "P0") - _sourceSupport = ((MEDMEM::MESH *)_sourceMesh)->getSupportOnAll(MED_EN::MED_CELL); - else - _sourceSupport = ((MEDMEM::MESH *)_sourceMesh)->getSupportOnAll(MED_EN::MED_NODE); - if( _targetFieldType == "P0") - _targetSupport = ((MEDMEM::MESH *)_targetMesh)->getSupportOnAll(MED_EN::MED_CELL); - else - _targetSupport = ((MEDMEM::MESH *)_targetMesh)->getSupportOnAll(MED_EN::MED_NODE); - - if (tm_spacedim!=sm_spacedim || tm_meshdim!=sm_meshdim) - throw MEDEXCEPTION("incompatible mesh and/or space dimensions in meshes"); - if ((sm_spacedim==2)&&(sm_meshdim==2)) - { - MEDNormalizedUnstructuredMesh<2,2> source_mesh_wrapper(_sourceMesh); - MEDNormalizedUnstructuredMesh<2,2> target_mesh_wrapper(_targetMesh); - INTERP_KERNEL::Interpolation2D interpolation(*this); - _nb_cols = interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,*_matrix,method); - } - else if ((sm_spacedim==3)&&(sm_meshdim==3)) - { - MEDNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(_sourceMesh); - MEDNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(_targetMesh); - INTERP_KERNEL::Interpolation3D interpolation(*this); - _nb_cols = interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,*_matrix,method); - } - else if ((sm_spacedim==3)&&(sm_meshdim==2)) - { - MEDNormalizedUnstructuredMesh<3,2> source_mesh_wrapper(_sourceMesh); - MEDNormalizedUnstructuredMesh<3,2> target_mesh_wrapper(_targetMesh); - INTERP_KERNEL::Interpolation3DSurf interpolation(*this); - _nb_cols = interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,*_matrix,method); - } - else - throw MEDEXCEPTION("no Interpolation exists for the given mesh and space dimensions"); - - _nb_rows=(*_matrix).getNbRows(); - - _deno_multiply.resize(_nb_rows); - _matrix->rowSum(_deno_multiply); - _deno_reverse_multiply.resize(_nb_cols); - _matrix->colSum(_deno_reverse_multiply, _nb_cols); - - return 1; -} - - -/* - remaps a vector source field defined on the source mesh onto the target mesh using the intersection matrix - \param field_source : source field to be remapped - \param target_field : field resulting from the remapping on the target mesh -*/ -void MEDMEM_REMAPPER::transfer(const MEDMEM::FIELD<double>& field_source, MEDMEM::FIELD<double>& field_target) -{ - int source_nbcomp=field_source.getNumberOfComponents(); - int nb_source_values= field_source.getNumberOfValues(); - const double* value_source = field_source.getValue(); - - int target_nbcomp=field_target.getNumberOfComponents(); - double* value_target = const_cast<double*> (field_target.getValue()); - - double precision = getPrecision(); - - if (source_nbcomp != target_nbcomp) - throw MEDMEM::MEDEXCEPTION("MEDMEM_REMAPPER::transfer: incoherent number of components for source and target fields"); - if (_nb_cols != nb_source_values) - throw MEDMEM::MEDEXCEPTION("MEDMEM_REMAPPER::transfer: incoherent number of field values, cannot cannot multiply by interpolation matrix"); - - _matrix->multiply(value_source, value_target,source_nbcomp); - - for (int i=0; i< _nb_rows; i++) - if(fabs(_deno_multiply[i]) > precision) - for(int comp = 0; comp < source_nbcomp; comp++) - value_target[i*source_nbcomp+comp]/=_deno_multiply[i]; - else - for(int comp = 0; comp < source_nbcomp; comp++) - value_target[i*source_nbcomp+comp]=0.; -} - -/* - reverses the direct transfer remapping: a Vector field supported on the target mesh is remapped onto - the source mesh using the transpose of the intersection matrix - \param field_target : target field to be remapped - \param source_field : field resulting from the remapping on the source mesh -*/ -void MEDMEM_REMAPPER::reverseTransfer( MEDMEM::FIELD<double>& field_source, const MEDMEM::FIELD<double>& field_target) -{ - int source_nbcomp=field_source.getNumberOfComponents(); - double* value_source = const_cast<double*> (field_source.getValue()); - - int target_nbcomp=field_target.getNumberOfComponents(); - int nb_target_values= field_target.getNumberOfValues(); - const double* value_target = field_target.getValue(); - - double precision = getPrecision(); - - if (source_nbcomp != target_nbcomp) - throw MEDMEM::MEDEXCEPTION(" MEDMEM_REMAPPER::reverseTransfer: incoherent number of components for source and target fields"); - if (_nb_rows != nb_target_values) - throw MEDMEM::MEDEXCEPTION(" MEDMEM_REMAPPER::reverseTransfer: incoherent number of field values, cannot cannot multiply by interpolation matrix"); - - _matrix->transposeMultiply(value_target, value_source, _nb_cols,target_nbcomp);//transposeMultiply(input,output, nbcols,nbcomp) - - for (int i=0; i< _nb_cols; i++) - if(fabs(_deno_reverse_multiply[i]) > precision) - for(int comp = 0; comp < target_nbcomp; comp++) - value_source[i*target_nbcomp+comp]/=_deno_reverse_multiply[i]; - else - for(int comp = 0; comp < target_nbcomp; comp++) - value_source[i*target_nbcomp+comp]=0.; -} - -/* - remaps a vector source field defined on the source mesh onto the target mesh using the intersection matrix - \param field_source : source field to be remapped - \return : field resulting from the remapping on the target mesh -*/ -MEDMEM::FIELD<double> * MEDMEM_REMAPPER::transferField(const MEDMEM::FIELD<double>& field_source) -{ - int source_nbcomp=field_source.getNumberOfComponents(); - const double* value_source = field_source.getValue(); - int nb_source_values= field_source.getNumberOfValues(); - - double precision = getPrecision(); - - if (_nb_cols != nb_source_values) - throw MEDMEM::MEDEXCEPTION("MEDMEM_REMAPPER::transfer: incoherent number of field values, cannot cannot multiply by interpolation matrix"); - - MEDMEM::FIELD<double> * target_field = new MEDMEM::FIELD<double>(_targetSupport,source_nbcomp); - double* value_target = const_cast<double*> ((*target_field).getValue()); - - _matrix->multiply(value_source, value_target,source_nbcomp); - - for (int i=0; i< _nb_rows; i++) - if(fabs(_deno_multiply[i]) > precision) - for(int comp = 0; comp < source_nbcomp; comp++) - value_target[i*source_nbcomp+comp]/=_deno_multiply[i]; - else - for(int comp = 0; comp < source_nbcomp; comp++) - value_target[i*source_nbcomp+comp]=0.; - - return target_field; -} - -/* - reverses the direct transfer remapping: a Vector field supported on the target mesh is remapped onto - the source mesh using the transpose of the intersection matrix - \param field_target : target field to be remapped - \return : field resulting from the remapping on the source mesh -*/ -MEDMEM::FIELD<double> * MEDMEM_REMAPPER::reverseTransferField(const MEDMEM::FIELD<double>& field_target) -{ - int target_nbcomp=field_target.getNumberOfComponents(); - const double* value_target = field_target.getValue(); - int nb_target_values= field_target.getNumberOfValues(); - - double precision = getPrecision(); - - if (_nb_rows != nb_target_values) - throw MEDMEM::MEDEXCEPTION(" MEDMEM_REMAPPER::reverseTransfer: incoherent number of field values, cannot cannot transpose-multiply by interpolation matrix"); - - MEDMEM::FIELD<double> * source_field = new MEDMEM::FIELD<double>(_sourceSupport,target_nbcomp); - double* value_source = const_cast<double*> ((*source_field).getValue()); - - _matrix->transposeMultiply(value_target, value_source, _nb_cols,target_nbcomp);//transposeMultiply(input,output, nbcols,nbcomp) - - for (int i=0; i< _nb_cols; i++) - if(fabs(_deno_reverse_multiply[i]) > precision) - for(int comp = 0; comp < target_nbcomp; comp++) - value_source[i*target_nbcomp+comp]/=_deno_reverse_multiply[i]; - else - for(int comp = 0; comp < target_nbcomp; comp++) - value_source[i*target_nbcomp+comp]=0.; - - return source_field; -} - -int MEDMEM_REMAPPER::setOptionDouble(const std::string& key, double value) -{ - bool result = INTERP_KERNEL::InterpolationOptions::setOptionDouble(key,value); - - if(result) - return 1; - else - return 0; -} - -int MEDMEM_REMAPPER::setOptionInt(const std::string& key, int value) -{ - bool result = INTERP_KERNEL::InterpolationOptions::setOptionInt(key,value); - - if(result) - return 1; - else - return 0; -} - -int MEDMEM_REMAPPER::setOptionString(const std::string& key, std::string& value) -{ - bool result = INTERP_KERNEL::InterpolationOptions::setOptionString(key,value); - - if(result) - return 1; - else - return 0; -} - -/*! - \brief returns the volumes of the cells underlying the support \a support - - For 2D geometries, the returned field contains the areas. - For 3D geometries, the returned field contains the volumes. - - \param support : support whose cell volumes are required - \return field containing the volumes -*/ -MEDMEM::FIELD<double>* MEDMEM_REMAPPER::getSupportVolumes(const MEDMEM::SUPPORT& support) -{ - const MEDMEM::GMESH* mesh=support.getMesh(); - int dim = mesh->getMeshDimension(); - switch (dim) - { - case 2: - return mesh->getArea(&support); - case 3: - return mesh->getVolume(&support); - default: - throw MEDMEM::MEDEXCEPTION("interpolation is not available for this dimension"); - } -} - -void MEDMEM_REMAPPER::printMatrixInfo() -{ - std::cout << *_matrix << std::endl; -} - -/*! -@} -*/ diff --git a/src/MEDMEM/MEDMEM_Remapper.hxx b/src/MEDMEM/MEDMEM_Remapper.hxx deleted file mode 100644 index 9ecd1a9a8..000000000 --- a/src/MEDMEM/MEDMEM_Remapper.hxx +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef MEDMEM_REMAPPER_HXX_ -#define MEDMEM_REMAPPER_HXX_ - -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM.hxx" -#include "MEDNormalizedUnstructuredMesh.hxx" -#include "MEDNormalizedUnstructuredMesh.txx" -#include "InterpKernelMatrix.hxx" -#include "InterpolationOptions.hxx" - - - -class MEDMEM_EXPORT MEDMEM_REMAPPER : public INTERP_KERNEL::InterpolationOptions -{ -public: - MEDMEM_REMAPPER(); - virtual ~MEDMEM_REMAPPER(); - int prepare(const MEDMEM::MESH& source_mesh, const MEDMEM::MESH& target_mesh, const char *method); - void transfer(const MEDMEM::FIELD<double>& source_field, MEDMEM::FIELD<double>& target_field); - void reverseTransfer(MEDMEM::FIELD<double>& source_field, const MEDMEM::FIELD<double>& target_field); - MEDMEM::FIELD<double> * transferField(const MEDMEM::FIELD<double>& source_field); - MEDMEM::FIELD<double> * reverseTransferField(const MEDMEM::FIELD<double>& target_field); - void printMatrixInfo(); - int setOptionDouble(const std::string& key, double value); - int setOptionInt(const std::string& key, int value); - int setOptionString(const std::string& key, std::string& value); -private : - INTERP_KERNEL::Matrix<double, INTERP_KERNEL::ALL_FORTRAN_MODE>* _matrix; - MEDMEM::FIELD<double>* getSupportVolumes(const MEDMEM::SUPPORT& support); - std::vector<double> _deno_multiply; - std::vector<double> _deno_reverse_multiply; - int _nb_rows; - int _nb_cols; - string _sourceFieldType; - string _targetFieldType; - const MEDMEM::MESH * _sourceMesh; - const MEDMEM::MESH * _targetMesh; - const MEDMEM::SUPPORT * _sourceSupport; - const MEDMEM::SUPPORT * _targetSupport; -}; - - -#endif /*REMAPPER_HXX_*/ diff --git a/src/MEDMEM/MEDMEM_STRING.hxx b/src/MEDMEM/MEDMEM_STRING.hxx deleted file mode 100644 index 14b359da3..000000000 --- a/src/MEDMEM/MEDMEM_STRING.hxx +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -# ifndef MEDMEM_STRING_HXX -# define MEDMEM_STRING_HXX - -#include "MEDMEM.hxx" - -using namespace std; - -# include <string> -# include <sstream> - -/*! - A class to generate string from any type: - - here is a simple use case - STRING msgErr; - msgErr << "This Object cannot be instanciated by now ! Try "<< 11 << "times just to see what happens "; - throw SALOME_EXCEPTION (LOCALIZED(msgErr)) ; - */ -namespace MEDMEM { - class MEDMEM_EXPORT STRING : public string - { - - private : - ostringstream _s ; - - public : - - STRING() :string(), _s() - { - } - STRING(const STRING& s) :string(s) - { - _s << s ; - this->string::operator =( s ); - } - STRING& operator= (const STRING& s) - { - _s.str(""); - _s << s ; - - this->string::operator = ( _s.str() ) ; // freeze is true by now - - return *this ; - } - - ~STRING() - { - } - - operator const char * () const - { - // return const_cast <const char *> (this->c_str()) ; - return this->c_str(); - } - - template <class T> STRING( const T &valeur ) : string(), _s() - { - _s << valeur ; - - this->string::operator =( _s.str()); - } - - template <class T> STRING & operator<<( const T &valeur ) - { - _s << valeur ; - - this->string::operator = ( _s.str() ) ; // freeze is true by now - - return *this ; - } - } ; -} - -# endif diff --git a/src/MEDMEM/MEDMEM_SetInterlacingType.hxx b/src/MEDMEM/MEDMEM_SetInterlacingType.hxx deleted file mode 100644 index fca99f851..000000000 --- a/src/MEDMEM/MEDMEM_SetInterlacingType.hxx +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef MEDMEM_SET_INTERLACING_TYPE -#define MEDMEM_SET_INTERLACING_TYPE - -#include "MEDMEM_Tags.hxx" -using namespace MEDMEM; - -namespace { - - template < typename T > struct SET_INTERLACING_TYPE { - static const MED_EN::medModeSwitch _interlacingType = MED_EN::MED_UNDEFINED_INTERLACE; }; - template < > struct SET_INTERLACING_TYPE<FullInterlace>{ - static const MED_EN::medModeSwitch _interlacingType = MED_EN::MED_FULL_INTERLACE; }; - template < > struct SET_INTERLACING_TYPE<NoInterlace> { - static const MED_EN::medModeSwitch _interlacingType = MED_EN::MED_NO_INTERLACE; }; - template < > struct SET_INTERLACING_TYPE<NoInterlaceByType> { - static const MED_EN::medModeSwitch _interlacingType = MED_EN::MED_NO_INTERLACE_BY_TYPE; }; - -} -#endif diff --git a/src/MEDMEM/MEDMEM_SkyLineArray.cxx b/src/MEDMEM/MEDMEM_SkyLineArray.cxx deleted file mode 100644 index d627dab87..000000000 --- a/src/MEDMEM/MEDMEM_SkyLineArray.cxx +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_SkyLineArray.hxx" -#include "MEDMEM_Utilities.hxx" -#include <map> - -using namespace std; -using namespace MEDMEM; - -MEDSKYLINEARRAY::MEDSKYLINEARRAY(): _count(0), _length(0), - _index((int*)NULL),_value((int*)NULL) -{ - MESSAGE_MED("Constructeur MEDSKYLINEARRAY sans parametre"); -} - -MEDSKYLINEARRAY::MEDSKYLINEARRAY(const MEDSKYLINEARRAY &myArray): - _count(myArray._count),_length(myArray._length), - _index(_count+1),_value(_length) -{ - const char* LOC = "MEDSKYLINEARRAY(const MEDSKYLINEARRAY &)"; - BEGIN_OF_MED(LOC); - if ( myArray._index ) - memcpy(_index,myArray._index,sizeof(int)*(_count+1)); - if ( myArray._value ) - memcpy(_value,myArray._value,sizeof(int)*_length); - END_OF_MED(LOC); -} - -MEDSKYLINEARRAY::~MEDSKYLINEARRAY() -{ - MESSAGE_MED("Destructeur ~MEDSKYLINEARRAY"); - - //if (_index != NULL) delete [] _index; - //if (_value != NULL) delete [] _value; -} - -MEDSKYLINEARRAY::MEDSKYLINEARRAY(const int count, const int length): - _count(count), _length(length), - _index(_count+1),_value(_length) -{ - MESSAGE_MED("Constructeur MEDSKYLINEARRAY(count="<<count<<", length="<<length<<") avec parametres"); -} - -MEDSKYLINEARRAY::MEDSKYLINEARRAY(const int count, const int length, - const int* index, const int* value,bool shallowCopy): - _count(count), _length(length) -{ -// MESSAGE_MED("Constructeur MEDSKYLINEARRAY(count="<<count<<", length="<<length<<") avec parametres"); - if(shallowCopy) - { - _index.setShallowAndOwnership(index); - _value.setShallowAndOwnership(value); - } - else - { - _index.set(_count+1,index); - _value.set(_length,value); - } -} - -//creates the reverse array -//creates an array with count maxvalue, where maxvalue -//is the maximum of the value_ of the present array -//length is the same as present array -// -// For instance -// 1 : 2 4 -// 2 : 1 2 -// -//will give -// 1 : 2 -// 2 : 1 2 -// 3 : -// 4 : 1 - -MEDSKYLINEARRAY* MEDSKYLINEARRAY::makeReverseArray() -{ - multimap<int,int > reverse; - int size=0; - for (int i=0; i<_count;i++) - for (int j=_index[i];j<_index[i+1];j++) - { - int value=_value[j-1]; - reverse.insert(make_pair(value,i+1)); - if (value>size) size=value; - } - int* r_index=new int [size+1]; - int* r_value=new int [_length]; - r_index[0]=1; - pair<multimap<int,int>::iterator,multimap<int,int>::iterator>piter; - int* ptr_value=r_value; - for (int i=0; i<size;i++) - { - piter=reverse.equal_range(i); - int index_incr=0; - for (multimap<int,int>::iterator iter=piter.first; iter!=piter.second; iter++) - { - *ptr_value++=iter->second; - index_incr++; - } - r_index[i+1]=r_index[i]+index_incr; - } - return new MEDSKYLINEARRAY(size,_length,r_index,r_value,true); -} -ostream& MEDMEM::operator<<(ostream &os, const MEDSKYLINEARRAY &sky) { - os << "_count : " << sky._count << " ,_length : " << sky._length; - for (int i = 0; i < sky._count ; i++) { - os << endl << "Values of type n°" << i+1 << " (index["<<i<<"]="<< sky._index[i]<<") :" << endl; - for (int j=sky._index[i]-1;j < sky._index[i+1]-1;j++) - os << sky._value[j] << " " ; - } - return os; -} - -// void MEDSKYLINEARRAY::setMEDSKYLINEARRAY( const int count , const int length, int* index , int* value ) -// { -// MESSAGE_MED("void MEDSKYLINEARRAY::setMEDSKYLINEARRAY(count, length, index, value)"); -// _count = count ; -// _length = length ; - -// //if (_index != NULL) delete [] _index; -// //if (_value != NULL) delete [] _value; - -// _index.set(index); -// _value.set(value); -// } diff --git a/src/MEDMEM/MEDMEM_SkyLineArray.hxx b/src/MEDMEM/MEDMEM_SkyLineArray.hxx deleted file mode 100644 index 8e3971b91..000000000 --- a/src/MEDMEM/MEDMEM_SkyLineArray.hxx +++ /dev/null @@ -1,191 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -# ifndef __MEDSKYLINEARRAY_H__ -# define __MEDSKYLINEARRAY_H__ - -#include "MEDMEM.hxx" - -#include "MEDMEM_Exception.hxx" - -#include "MEDMEM_PointerOf.hxx" -#include "MEDMEM_define.hxx" - -#include <cstring> - -namespace MEDMEM { - class MEDSKYLINEARRAY; - MEDMEM_EXPORT ostream& operator<<(ostream &os, const MEDSKYLINEARRAY &sky); - -class MEDMEM_EXPORT MEDSKYLINEARRAY -{ -private : - int _count ; - int _length ; - PointerOf <int> _index ; // array of size _count+1 : _index[0]=1 and - // _index[_count]=length+1 - PointerOf <int> _value ; // array of size _length - -public : - // Attention, avec ce constructeur, il n'est possible de remplir le MEDSKYLINEARRAY - MEDSKYLINEARRAY(); - - // Constructeur par recopie - MEDSKYLINEARRAY( const MEDSKYLINEARRAY &myArray ); - - // Avec ce constructeur la mémoire pour le tableau de valeur et le - // tableau d'index est réservée. Il suffit d'effectuer les séquences - // d'appels suivantes pour initialiser le MEDSKYLINEARRAY - // 1) setIndex(index) puis <count> fois setI(i,&listValeurN°I) avec i dans 1..count - // rem : listValeurN°I est dupliquée - // 2) appeler <length> fois setIJ(i,j,valeur) avec i dans 1..count et avec j dans 1..count - MEDSKYLINEARRAY( const int count, const int length ); - - // Avec ce constructeur le MEDSKYLINEARRAY est complètement initialisé - // Si shallowCopy=false (par défaut) les tableaux d'index et de valeurs - // sont dupliqués - // Sinon le MEDSKYLINEARRAY prend directement les pointeurs et en devient - // propriétaire - MEDSKYLINEARRAY( const int count, const int length, - const int* index, const int* value, bool shallowCopy=false ); - - ~MEDSKYLINEARRAY(); - //void setMEDSKYLINEARRAY( const int count, const int length, int* index , int* value ) ; - - inline int getNumberOf() const; - inline int getLength() const; - inline const int* getIndex() const; - inline const int* getValue() const; - inline int getNumberOfI(int i) const throw (MEDEXCEPTION) ; - inline const int* getI(int i) const throw (MEDEXCEPTION) ; - inline int getIJ(int i, int j) const throw (MEDEXCEPTION) ; - inline int getIndexValue(int i) const throw (MEDEXCEPTION) ; - - inline void setIndex(const int* index) ; - inline void setI(const int i, const int* values) throw (MEDEXCEPTION) ; - inline void setIJ(int i, int j, int value) throw (MEDEXCEPTION) ; - inline void setIndexValue(int i, int value) throw (MEDEXCEPTION) ; - - friend ostream& operator<<(ostream &os, const MEDSKYLINEARRAY &sky); - MEDSKYLINEARRAY* makeReverseArray(); - -}; - -// --------------------------------------- -// Methodes Inline -// --------------------------------------- -inline int MEDSKYLINEARRAY::getNumberOf() const -{ - return _count ; -} -inline int MEDSKYLINEARRAY::getLength() const -{ - return _length ; -} -inline const int* MEDSKYLINEARRAY::getIndex() const -{ - return (const int*)_index ; -} -inline const int* MEDSKYLINEARRAY::getValue() const -{ - return (const int*)_value ; -} -inline int MEDSKYLINEARRAY::getNumberOfI(int i) const throw (MEDEXCEPTION) -{ - if (i<1) - throw MEDEXCEPTION("MEDSKYLINEARRAY::getNumberOfI : argument must be >= 1"); - if (i>_count) - throw MEDEXCEPTION("MEDSKYLINEARRAY::getNumberOfI : argument is out of range"); - return _index[i]-_index[i-1] ; -} -inline const int* MEDSKYLINEARRAY::getI(int i) const throw (MEDEXCEPTION) -{ - if (i<1) - throw MEDEXCEPTION("MEDSKYLINEARRAY::getI : argument must be >= 1"); - if (i>_count) - throw MEDEXCEPTION("MEDSKYLINEARRAY::getI : argument is out of range"); - return _value+_index[i-1]-1 ; -} -inline int MEDSKYLINEARRAY::getIJ(int i, int j) const throw (MEDEXCEPTION) -{ - if (i<1) - throw MEDEXCEPTION("MEDSKYLINEARRAY::getIJ : first argument must be >= 1"); - if (j<1) - throw MEDEXCEPTION("MEDSKYLINEARRAY::getIJ : second argument must be >= 1"); - if (i>_count) - throw MEDEXCEPTION("MEDSKYLINEARRAY::getIJ : first argument is out of range") ; - if (j>_index[i]) - throw MEDEXCEPTION("MEDSKYLINEARRAY::getIJ : second argument is out of range") ; - return _value[_index[i-1]+j-2] ; -} - -inline int MEDSKYLINEARRAY::getIndexValue(int i) const throw (MEDEXCEPTION) -{ - if (i<1) - throw MEDEXCEPTION("MEDSKYLINEARRAY::getIndexValue : argument must be >= 1"); - if (i>_index[_count]) - throw MEDEXCEPTION("MEDSKYLINEARRAY::getIndexValue : argument is out of range") ; - return _value[i-1] ; -} - -inline void MEDSKYLINEARRAY::setIndex(const int* index) -{ - memcpy((int*)_index,index,(_count+1)*sizeof(int)); -} - - -inline void MEDSKYLINEARRAY::setIJ(int i, int j, int value) throw (MEDEXCEPTION) -{ - if (i<1) - throw MEDEXCEPTION("MEDSKYLINEARRAY::setIJ : first argument must be >= 1"); - if (j<1) - throw MEDEXCEPTION("MEDSKYLINEARRAY::setIJ : second argument must be >= 1"); - if (i>_count) - throw MEDEXCEPTION("MEDSKYLINEARRAY::setIJ : first argument is out of range") ; - if (j>_index[i]) - throw MEDEXCEPTION("MEDSKYLINEARRAY::setIJ : second argument is out of range") ; - - _value[_index[i-1]+j-2]=value ; - -} - -inline void MEDSKYLINEARRAY::setI(const int i, const int * values) throw (MEDEXCEPTION) -{ - if (i<1) - throw MEDEXCEPTION("MEDSKYLINEARRAY::setI : index must be >= 1"); -; - if (i>_count) - throw MEDEXCEPTION("MEDSKYLINEARRAY::setI : index is out of range") ; - - memcpy(_value+_index[i-1]-1,values,(_index[i]-_index[i-1])*sizeof(int)) ; -} - -inline void MEDSKYLINEARRAY::setIndexValue(int i, int value) throw (MEDEXCEPTION) -{ - if (i<1) - throw MEDEXCEPTION("MEDSKYLINEARRAY::setIndexValue : argument must be >= 1"); - if (i>_index[_count]) - throw MEDEXCEPTION("MEDSKYLINEARRAY::setIndexValue : argument is out of range") ; - _value[i-1]=value ; -} -} -# endif diff --git a/src/MEDMEM/MEDMEM_Support.cxx b/src/MEDMEM/MEDMEM_Support.cxx deleted file mode 100644 index cacb5e8ef..000000000 --- a/src/MEDMEM/MEDMEM_Support.cxx +++ /dev/null @@ -1,1726 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -/* - File Support.cxx -*/ - -#include "MEDMEM_Support.hxx" -#include "MEDMEM_DriversDef.hxx" -#include "MEDMEM_GMesh.hxx" -#include "MEDMEM_Meshing.hxx" - -#include <set> -#include <algorithm> -#include <list> - -using namespace std; -using namespace MED_EN; -using namespace MEDMEM; - -#define MED_NBR_GEOMETRIE_MAILLE 15 - -/*! -\defgroup SUPPORT_general General information - -\defgroup SUPPORT_creation Creation methods -The creation of a support requires a number of information -which is supplied to the MedMem library with the following methods. -When the support is defined on all elements, the creation method is -very simple, for the element list is implicitly defined. - -\defgroup SUPPORT_query Query methods - -\defgroup SUPPORT_constructors Constructors - -\defgroup SUPPORT_advanced Advanced methods - -*/ - - - -/* This class is a generic class for family and group */ - -/*! - Constructor. -*/ -//-------------------------------------------------------------------------- -SUPPORT::SUPPORT(): _name(""), _description("None"), _mesh((GMESH*)NULL), - _entity(MED_CELL), _numberOfGeometricType(0), - _isOnAllElts(false), - _totalNumberOfElements(0), - _number((MEDSKYLINEARRAY*)NULL), - _number_fromfile(0) - //-------------------------------------------------------------------------- -{ - MESSAGE_MED("SUPPORT::SUPPORT()"); -} - -/*! -\addtogroup SUPPORT_constructors -@{ -*/ - -/*! - Constructor of a support lying on mesh \a Mesh. By default, - the support lies on all elements of type \a Entity. - Partial support can be described using \a setpartial method. - -\param Mesh Pointer to the mesh on which the support lies -\param Name Support name (should not exceed MED_TAILLE_NOM as defined in Med - i.e. 32 characters) -\param Entity Entity type of the support (MED_CELL,MED_FACE,MED_EDGE, MED_NODE) -*/ -//-------------------------------------------------------------------------- -// SUPPORT::SUPPORT(MESH* Mesh, string Name/*=""*/, medEntityMesh Entity/*=MED_CELL*/): -// _name(Name), _description("None"), _mesh(Mesh), _entity(Entity), -// _numberOfGeometricType(0), _isOnAllElts(true), -// _totalNumberOfElements(0), _number((MEDSKYLINEARRAY*)NULL),_number_fromfile(0) -// //-------------------------------------------------------------------------- -// { -// MESSAGE_MED("SUPPORT::SUPPORT(MESH*Mesh,string Name,medEntityMesh Entity)"); -// if(_mesh) -// _mesh->addReference(); -// update() ; -// } - -/*! - Copy constructor. -*/ -//-------------------------------------------------------------------------- -SUPPORT::SUPPORT(const SUPPORT & m):_number_fromfile(0) - //-------------------------------------------------------------------------- -{ - const char* LOC = "SUPPORT::SUPPORT(SUPPORT & m) : "; - BEGIN_OF_MED(LOC); - - _name = m._name ; - _description = m._description ; - _mesh = m._mesh ; // on recopie uniquement l'adresse - if(_mesh) - _mesh->addReference(); - _meshName = m._meshName; - _entity = m._entity; - _numberOfGeometricType = m._numberOfGeometricType; - - if (m._geometricType) - _geometricType.set(_numberOfGeometricType,m._geometricType); - - _isOnAllElts = m._isOnAllElts; - - if (m._numberOfElements) - _numberOfElements.set(_numberOfGeometricType,m._numberOfElements); - - _totalNumberOfElements = m._totalNumberOfElements; - - if ( m._number ) // m may be not filled SUPPORTClient - _number = new MEDSKYLINEARRAY(* m._number); - else - _number = (MEDSKYLINEARRAY *) NULL; - - _profilNames=m._profilNames; - - END_OF_MED(LOC); -} - -/*! - @} -*/ - -/*!\ifnot MEDMEM_ug - Affectation operator. operator = perform et deep copy except for attribute _mesh -\endif -*/ -//-------------------------------------------------------------------------- -SUPPORT & SUPPORT::operator=(const SUPPORT & m) - //-------------------------------------------------------------------------- -{ - const char* LOC = "SUPPORT::operator=(const SUPPORT & m) : "; - BEGIN_OF_MED(LOC); - - if ( this == &m ) return *this; - - _name = m._name; - _description = m._description; - if(m._mesh!=_mesh)//setMesh not used here due to _meshName update is this... - { - if(_mesh) - _mesh->removeReference(); - _mesh=m._mesh; - if(_mesh) - _mesh->addReference(); - } - _entity = m._entity; - _numberOfGeometricType = m._numberOfGeometricType; - if (m._geometricType) - _geometricType.set(_numberOfGeometricType,m._geometricType); - _isOnAllElts = m._isOnAllElts; - if (m._numberOfElements) - _numberOfElements.set(_numberOfGeometricType,m._numberOfElements); - _totalNumberOfElements = m._totalNumberOfElements; - - if (_number) delete _number; - if ( m._number ) // m may be not filled SUPPORTClient - _number = new MEDSKYLINEARRAY(* m._number); - else - _number = (MEDSKYLINEARRAY *) NULL; - - _profilNames=m._profilNames; - - END_OF_MED(LOC); - return *this; -} - -/*! - Destructor. -*/ -//----------------- -SUPPORT::~SUPPORT() - //----------------- -{ - MESSAGE_MED("Destructeur ~SUPPORT()"); - clearDataOnNumbers(); - if(_mesh) - _mesh->removeReference(); -} - -/*! - operator <<. -*/ -//-------------------------------------------------- -ostream & MEDMEM::operator<<(ostream &os, const SUPPORT &my) - //-------------------------------------------------- -{ - os << "Name : "<< my.getName() << endl ; - os << "Description : "<< my.getDescription() << endl ; - os << "Mesh ptr : "; - if (my.getMesh() == NULL) - os << " Mesh not defined." << endl ; - else - os << " Mesh defined." << endl; - os << "MeshName : "; - os << my.getMeshName() << endl ; - os << "Entity : "<<entNames[my._entity] << endl; - os << "Entity list : "<< endl; - if ( my._isOnAllElts ) - os << "Is on all entities."<< endl; - else { - os << "Is not on all entities. "<< endl; - if ( my._number ) // m may be not filled SUPPORTClient - os << *my.getNumber(MED_ALL_ELEMENTS); - } - int numberoftypes = my._numberOfGeometricType ; - os << "NumberOfTypes : "<<numberoftypes<<endl; - PointerOf<medGeometryElement> types = my._geometricType; - for (int j=0;j<numberoftypes;j++) { - int numberOfElements = my._numberOfElements ? my._numberOfElements[j] : -1; - os << " On Type "<<geoNames[types[j]] - <<" : there is(are) "<<numberOfElements<<" element(s) and " <<endl; - } - int nbProfilNames = my._profilNames.size(); - os<<"Number of profil names = "<<nbProfilNames<<endl; - for(int j=0; j<nbProfilNames; j++) { - os<<" Profil Name N"<<j+1<<" = "<<my._profilNames[j]<<endl; - } - return os ; -} - -/*! - Updade the SUPPORT attributs with right MESH information. - - It has an effect only if SUPPORT is on all elements. - - No more need in future release. -*/ -//------------------- -void SUPPORT::update() -//------------------- -{ - const char* LOC = "SUPPORT::update() : "; - BEGIN_OF_MED(LOC); - - if (_isOnAllElts && _mesh) - { - if (_entity == MED_NODE) - { - // BEGIN Issue 0020804: [CEA 399] Memory corruption ... in MEDMEMCppTest - //_numberOfGeometricType = 1; - setNumberOfGeometricType(1); - // END Issue 0020804 - - // BEGIN Issue 0020633: [CEA] Pb with 3D field creation fron another - // Use setGeometricType() in order to get _profilNames updated - //_geometricType.set(1); - //_geometricType[0]=MED_POINT1; - const MED_EN::medGeometryElement type = MED_NONE; - setGeometricType( & type ); - // END Issue 0020633: [CEA] Pb with 3D field creation fron another - _numberOfElements.set(1); - _numberOfElements[0]=_mesh->getNumberOfNodes(); - _totalNumberOfElements=_numberOfElements[0]; - } - else - { // we duplicate information from _mesh - // BEGIN Issue 0020804: [CEA 399] Memory corruption ... in MEDMEMCppTest - setNumberOfGeometricType(_mesh->getNumberOfTypes(_entity)); - // END Issue 0020804 - // BEGIN Issue 0020633: [CEA] Pb with 3D field creation fron another - if ( const medGeometryElement * allType = _mesh->getTypes(_entity)) - setGeometricType( allType ); - // END Issue 0020633: [CEA] Pb with 3D field creation fron another - _numberOfElements.set(_numberOfGeometricType); - _totalNumberOfElements=0; - for (int i=0;i<_numberOfGeometricType;i++) - { - _numberOfElements[i]=_mesh->getNumberOfElements(_entity,_geometricType[i]) ; - _totalNumberOfElements+=_numberOfElements[i]; - } - } - - if (_totalNumberOfElements <= 0) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"We have found no element for this support !")); - // set _number (issue 0021167) - { - vector<int> nums( _totalNumberOfElements ); - for ( unsigned i = 0; i < nums.size(); ++i ) - nums[i] = i+1; - - vector<int> index( _numberOfGeometricType + 1 ); - index[0] = 1; - for ( int i = 0; i < _numberOfGeometricType; ++i ) - index[i+1] = index[i] + _numberOfElements[i]; - - setNumber( & index[0], & nums[0] ); - } - } - END_OF_MED(LOC); -} - -/*! - Get the field value index (in fortran mode) from the support global number. - Becareful, it doesn't take care of the field number of components -*/ -//------------------- -int SUPPORT::getValIndFromGlobalNumber(const int number) const throw (MEDEXCEPTION) -//------------------- -{ - const char * LOC="getValIndFromGlobalNumber(const int number) : "; - - if (_isOnAllElts) return number; - - int nbOfEltsThis = getNumberOfElements(MED_ALL_ELEMENTS); - - const int *eltsThis = _number->getValue(); - - int iThis; - bool found=false; - - for(iThis=0;iThis<nbOfEltsThis && !found;) - if(eltsThis[iThis]==number) - { - found = true; - int valInd = iThis+1; - return valInd; - } - else - iThis++; - - if(!found) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Can't find the global number |" - << number << "| in Support |" - << getName() << "|" )); - - // It should never arrive here !! - return 0; -} - -/*! -\addtogroup SUPPORT_advanced -@{ - -*/ - -/*! - Blends the given SUPPORT mySupport into the calling object SUPPORT. - Example : -\verbatim -SUPPORT mySupport ; -SUPPORT myOtherSupport ; -... -mySupport.blending(myOtherSupport) ; -\endverbatim -Support \a mySupport now contains a union of the elements originally -contained in \a mySupport and \a myOtherSupport. -*/ -//------------------- -void SUPPORT::blending(const SUPPORT * mySupport) throw (MEDEXCEPTION) - //------------------- -{ - const char * LOC="SUPPORT::blending(SUPPORT *) : "; - BEGIN_OF_MED(LOC); - if (_entity!=mySupport->getEntity()) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Entities are different !")); - if(!(*_mesh == *mySupport->getMesh())) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Mesh are different !")); - if(_isOnAllElts) - return; - if(mySupport->isOnAllElements()) - { - *this=*mySupport; - return; - } - if(mySupport->_totalNumberOfElements==0) - return; - const int *ids=getNumber(MED_ALL_ELEMENTS); - set<int> idsSet(ids,ids+getNumberOfElements(MED_ALL_ELEMENTS)); - const int *idsMySupport=mySupport->getNumber(MED_ALL_ELEMENTS); - int mySupportSize=mySupport->getNumberOfElements(MED_ALL_ELEMENTS); - set<int>::iterator iter; - for(int i=0;i<mySupportSize;i++) - idsSet.insert(idsMySupport[i]); - int size=idsSet.size(); - - if(size!=0) - { - list<int> idsList; - for(iter=idsSet.begin();iter!=idsSet.end();iter++) - idsList.push_back(*iter); - - MESSAGE_MED(LOC << " size Set " << idsSet.size() << " size List " << idsList.size()); - - if(_entity==MED_NODE) - fillFromNodeList(idsList); - else - fillFromElementList(idsList); - } - else - clearDataOnNumbers(); - END_OF_MED(LOC); -} -/*! @} */ - -/*! -\addtogroup SUPPORT_creation -@{ -*/ - -/*! - This function allows the user to set a support not on all entities Entity, - it should be used after setting the mesh and the entity attributes at least. - -\param Description string describing the support for information purposes (should not exceed MED_TAILLE_DESC length - i.e. 200 characters) -\param NumberOfGeometricType number of geometric types contained in the support -\param TotalNumberOfElements number of elements in the support -\param GeometricType array describing the geometric types (must be consistent with the entity that was passed as an argument to the support constructor) -\param NumberOfElements array describing the number of elements for each type -\param NumberValue array of IDs of the elements that constitute the group. - -The following example refers to the mesh given in the mesh connectivity example. -It creates a group containing the two cells on the right (the quadratic triangle and the quadrangle on the right). - -\verbatim -// creating SUPPORT on cells with one value per cell -right_group = new SUPPORT; -right_group->setMesh(mesh); -right_group->setEntity( MED_CELL ); -right_group->setName("right group"); - -string description = "partial support"; -int number_of_types=2; -int number_of_elements=2; -medGeometryElement geom_types[2]={MED_QUAD4, MED_TRIA6}; -int number_of_elem_per_type[2]={1,1}; -int number_value[2]={3,4}; - -//defining the region of the support -right_group->setpartial(description, number_of_types, -number_of_elements, geom_types, -number_of_elem_per_type, number_value); -\endverbatim - -When MED_POLYGON or MED_POLYHEDRA elements are included in the support, -their global number should be given. For instance, on a mesh having ten MED_TRIA3 -and five MED_POLYGON, the number of the first polygonal element is 11. -*/ - -//------------------- -void SUPPORT::setpartial(const std::string& Description, - int NumberOfGeometricType, - int TotalNumberOfElements, - const medGeometryElement * GeometricType, - const int * NumberOfElements, - const int * NumberValue) -//------------------- -{ - const char * LOC = "SUPPORT::setpartial(string , int , int , medGeometryElement * , int * , int *) : " ; - BEGIN_OF_MED(LOC) ; - - _isOnAllElts = false ; - - _description=Description; - - _numberOfGeometricType=NumberOfGeometricType; - _geometricType.set(NumberOfGeometricType); - _numberOfElements.set(NumberOfGeometricType); - _totalNumberOfElements = TotalNumberOfElements; - - int * index = new int[_numberOfGeometricType+1]; - index[0]=1; - int elemDim = -1; - for (int i=0;i<_numberOfGeometricType;i++) { - if(GeometricType[i]/100 != elemDim) - { - if(i==0) - elemDim=GeometricType[i]/100; - else if ( CELLMODEL_Map::retrieveCellModel( GeometricType[i] ).getDimension() != - CELLMODEL_Map::retrieveCellModel( GeometricType[0] ).getDimension() ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"unhomogeneous geometric types (dimension) !")); - } - _geometricType[i] = GeometricType[i] ; - _numberOfElements[i] = NumberOfElements[i] ; - index[i+1] = index[i]+NumberOfElements[i] ; - } - - if (_number!=NULL) delete _number ; - _number = new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfElements,index,NumberValue); - - delete[] index ; - - // PAL16854(Partial support on nodes): - // giving a default value to profile names - vector<string> prof_names( NumberOfGeometricType); - for (int itype=0; itype < NumberOfGeometricType; itype++) - { - ostringstream typestr; - typestr<<_name<<"_type"<<_geometricType[itype]; - prof_names[itype]=typestr.str(); - } - setProfilNames(prof_names); - - END_OF_MED(LOC); -} - -/*! @} */ - -/*! -\ifnot MEDMEM_ug -This function allows the user to set a support not on all entities Entity, -it should be used after an initialisation of : -SUPPORT(GMESH* Mesh, string Name="", medEntityMesh Entity=MED_CELL) and -after calling at least setGeometricType and perharps setEntity. -It allocates and initialises all the attributs of the class SUPPORT but -doesn't set a description, a SUPPORT name, a meshName and an associated GMESH. -\endif -*/ - -//------------------- -void SUPPORT::setpartial(MEDSKYLINEARRAY * number, bool shallowCopy) throw (MEDEXCEPTION) - //------------------- -{ - const char * LOC = "SUPPORT::setpartial(MEDSKYLINEARRAY * number) : " ; - BEGIN_OF_MED(LOC) ; - - if ( ! _geometricType ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"SUPPORT must contains" - << " a geometric type list" )) ; - - _numberOfGeometricType = number->getNumberOf(); - - _numberOfElements.set(_numberOfGeometricType); - - for (int i=0; i< _numberOfGeometricType; i++) - _numberOfElements[i] = number->getNumberOfI(i+1); - - _totalNumberOfElements = number->getLength(); - - _isOnAllElts = false ; - - if (_number!=NULL) delete _number ; - - if ( shallowCopy ) - _number = number; - else - _number = new MEDSKYLINEARRAY(*number); - - END_OF_MED(LOC); -} - -void SUPPORT::setpartial_fromfile(MEDSKYLINEARRAY * number, bool shallowCopy) throw (MEDEXCEPTION) - //------------------- -{ - const char* LOC = "SUPPORT::setpartial_fromfile(MEDSKYLINEARRAY * number) : "; - BEGIN_OF_MED(LOC); - - if ( shallowCopy ) - _number_fromfile = number; - else - _number_fromfile = new MEDSKYLINEARRAY(*number); - - END_OF_MED(LOC); -} - -void SUPPORT::setProfilNames(const std::vector<std::string>& profilNames) throw (MEDEXCEPTION){ - - const char * LOC = "SUPPORT::setProfilNames(vector<string> profilNames) : " ; - BEGIN_OF_MED(LOC) ; - - if ( _isOnAllElts ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"SUPPORT shouldn't be on all elements" - << " while setting profil name list" )) ; - - if ( ! _geometricType || _numberOfGeometricType==0 ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"SUPPORT must contains" - << " a least one geometric type" )) ; - - if ( ! _number ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"SUPPORT must contains" - << " a profil number list before setting" - << " the associated profil name list" )) ; - - if ( ( (int)profilNames.size() != _number->getNumberOf() ) && - ( (int)profilNames.size() !=_numberOfGeometricType ) ) { - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The profil name list size : "<< profilNames.size() - << " must be equal to the number of geometric type : " - << _numberOfGeometricType << " (_number->getNumberOf() : " - << _number->getNumberOf() << " )" - )) ; - - } - - _profilNames = profilNames; - - END_OF_MED(LOC); - -} - -vector<string> SUPPORT::getProfilNames() const throw (MEDEXCEPTION) -{ - return _profilNames; -} - -/*! -\addtogroup SUPPORT_advanced -@{ -*/ - -/*! - This method gets the boundary elements of the mesh. The support has to be - build using SUPPORT() followed by setMesh(GMESH*) setName(string) and - setEntity(medEntityMesh) before using this method. -*/ -//------------------- -void SUPPORT::getBoundaryElements() throw (MEDEXCEPTION) - //------------------- -{ - const char * LOC = "SUPPORT::getBoundaryElements() : " ; - BEGIN_OF_MED(LOC) ; - - if (_mesh == (GMESH*)NULL) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"You shlould use the appropriate SUPPORT Constructor before calling this method")); - - int spaceDimension = _mesh->getSpaceDimension(); - - if (spaceDimension == 3) - if (_entity != MED_FACE) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined in 3D mesh for entity "<<_entity<<" !")); - if (spaceDimension == 2) - if (_entity != MED_EDGE) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined in 2D mesh for entity "<<_entity<<" !")); - - setAll(false); - - const MESH* mesh = _mesh->convertInMESH(); - const_cast<CONNECTIVITY*> - (mesh->getConnectivityptr())->calculateFullDescendingConnectivity(MED_CELL); - const int * myConnectivityValue = mesh->getReverseConnectivity(MED_DESCENDING) ; - const int * myConnectivityIndex = mesh->getReverseConnectivityIndex(MED_DESCENDING) ; - int numberOf = mesh->getNumberOfElements(_entity,MED_ALL_ELEMENTS) ; - list<int> myElementsList ; - int size = 0 ; - SCRUTE_MED(numberOf) ; - for (int i=0 ; i<numberOf; i++) - if (myConnectivityValue[myConnectivityIndex[i]] == 0) { - SCRUTE_MED(i+1) ; - myElementsList.push_back(i+1) ; - size++ ; - } - SCRUTE_MED(size) ; - // Well, we must know how many geometric type we have found - int * myListArray = new int[size] ; - int id = 0 ; - list<int>::iterator myElementsListIt ; - for (myElementsListIt=myElementsList.begin();myElementsListIt!=myElementsList.end();myElementsListIt++) { - myListArray[id]=(*myElementsListIt) ; - SCRUTE_MED(id); - SCRUTE_MED(myListArray[id]); - id ++ ; - } - - int numberOfGeometricType ; - medGeometryElement* geometricType ; - int * geometricTypeNumber ; - int * numberOfElements ; - int * mySkyLineArrayIndex ; - - int numberOfType = mesh->getNumberOfTypes(_entity) ; - if (numberOfType == 1) { // wonderfull : it's easy ! - numberOfGeometricType = 1 ; - geometricType = new medGeometryElement[1] ; - const medGeometryElement * allType = mesh->getTypes(_entity); - geometricType[0] = allType[0] ; - geometricTypeNumber = new int[1] ; // not use, but initialized to nothing - geometricTypeNumber[0] = 0 ; - numberOfElements = new int[1] ; - numberOfElements[0] = size ; - mySkyLineArrayIndex = new int[2] ; - mySkyLineArrayIndex[0]=1 ; - mySkyLineArrayIndex[1]=1+size ; - } - else {// hemmm - map<medGeometryElement,int> theType ; - for (myElementsListIt=myElementsList.begin();myElementsListIt!=myElementsList.end();myElementsListIt++) { - medGeometryElement myType = mesh->getElementType(_entity,*myElementsListIt) ; - if (theType.find(myType) != theType.end() ) - theType[myType]+=1 ; - else - theType[myType]=1 ; - } - numberOfGeometricType = theType.size() ; - geometricType = new medGeometryElement[numberOfGeometricType] ; - geometricTypeNumber = new int[numberOfGeometricType] ; // not use, but initialized to nothing - numberOfElements = new int[numberOfGeometricType] ; - mySkyLineArrayIndex = new int[numberOfGeometricType+1] ; - int index = 0 ; - mySkyLineArrayIndex[0]=1 ; - map<medGeometryElement,int>::iterator theTypeIt ; - for (theTypeIt=theType.begin();theTypeIt!=theType.end();theTypeIt++) { - geometricType[index] = (*theTypeIt).first ; - geometricTypeNumber[index] = 0 ; - numberOfElements[index] = (*theTypeIt).second ; - mySkyLineArrayIndex[index+1]=mySkyLineArrayIndex[index]+numberOfElements[index] ; - index++ ; - } - } - MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ; - - setNumberOfGeometricType(numberOfGeometricType) ; - setGeometricType(geometricType) ; - setNumberOfElements(numberOfElements) ; - - _number = new MEDSKYLINEARRAY(numberOfGeometricType,size); - - _number->setIndex(mySkyLineArrayIndex); - - for (int i=0;i<size;i++) - { - _number->setIndexValue(i+1,myListArray[i]); - } - - delete[] numberOfElements; - delete[] geometricTypeNumber; - delete[] geometricType; - delete[] mySkyLineArrayIndex; - delete[] myListArray; - delete mySkyLineArray; - - mesh->removeReference(); - - END_OF_MED(LOC); -} - -/*! - Intersects \a mySupport into the calling SUPPORT object. - If A.intersecting(B) is called, on output, \f$ A \f$ contains \f$A \cap B\f$. -*/ -//------------------- -void SUPPORT::intersecting(const SUPPORT * mySupport) throw (MEDEXCEPTION) -{ - const char * LOC="SUPPORT::intersecting(SUPPORT *) : "; - BEGIN_OF_MED(LOC); - if (_entity!=mySupport->getEntity()) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Entities are different !")); - if(!(*_mesh == *mySupport->getMesh())) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Mesh are different !")); - if(mySupport->isOnAllElements()) - return; - if(_isOnAllElts) - { - *this=*mySupport; - return; - } - if(_totalNumberOfElements==0) - return; - const int *ids=getNumber(MED_ALL_ELEMENTS); - set<int> idsSet(ids,ids+getNumberOfElements(MED_ALL_ELEMENTS)); - const int *idsMySupport=mySupport->getNumber(MED_ALL_ELEMENTS); - int mySupportSize=mySupport->getNumberOfElements(MED_ALL_ELEMENTS); - set<int> idsSetMySupport(idsMySupport,idsMySupport+mySupportSize); - set<int>::iterator iter; - list<int> idsList; - for(iter=idsSet.begin();iter!=idsSet.end();iter++) - if(idsSetMySupport.find(*iter)!=idsSetMySupport.end()) - idsList.push_back(*iter); - int size=idsSet.size(); - int sizeList = idsList.size(); - - MESSAGE_MED(LOC << " size Set " << idsSet.size() << " size List " << idsList.size()); - - if(size!=0 && sizeList != 0) - { - if(_entity==MED_NODE) - fillFromNodeList(idsList); - else - fillFromElementList(idsList); - } - else - { - clearDataOnNumbers(); - } - END_OF_MED(LOC); -} -/*! @} */ - -/*! - Method that cleans up all the fields related to _numbers. Defined for code factorization. -*/ -//-------------------------------------------------- -void MEDMEM::SUPPORT::clearDataOnNumbers() - //-------------------------------------------------- -{ - _numberOfGeometricType=0; - _totalNumberOfElements=0; - - if(_number) - { - delete _number; - _number=(MEDSKYLINEARRAY *) NULL; - } - if(_number_fromfile) - { - delete _number_fromfile; - _number_fromfile=0; - } -} - -/*! - operator == This operator does not compare attributs _name and _description. -*/ -//-------------------------------------------------- -bool MEDMEM::SUPPORT::operator == (const SUPPORT &support) const - //-------------------------------------------------- -{ - - const char* LOC = "bool SUPPORT::operator ==(const SUPPORT &support) const : "; - BEGIN_OF_MED(LOC); - - bool operatorReturn = false; - - operatorReturn = (*_mesh == *support._mesh) && (_entity == support._entity) && - (_numberOfGeometricType == support._numberOfGeometricType) && - ((_isOnAllElts && support._isOnAllElts) || (!_isOnAllElts && !support._isOnAllElts)) && - (_totalNumberOfElements == support._totalNumberOfElements) && - (_profilNames.size() == support._profilNames.size()); - - if (operatorReturn) - { - if (!_isOnAllElts) - { - for (int i=0; i<_numberOfGeometricType; i++) - { - operatorReturn = operatorReturn && - (_geometricType[i] == support._geometricType[i]) && - (_numberOfElements[i] == support._numberOfElements[i]); - - if (operatorReturn) - { - for (int j=0; j<_numberOfElements[i]; j++) - { - operatorReturn = operatorReturn && - (getNumber(_geometricType[i])[j] == - support.getNumber(_geometricType[i])[j]); - } - } - } - } - } - - END_OF_MED(LOC); - - return operatorReturn; -} - -void SUPPORT::changeElementsNbs(medEntityMesh entity, const int *renumberingFromOldToNew) -{ - if(entity != _entity) - throw MEDEXCEPTION("SUPPORT::changeElementsNbs : Renumbering on a mismatch entity"); - list<int> newNbs; - if(!_isOnAllElts) - { - const int *oldNbs=_number->getValue(); - for(int i=0;i<_totalNumberOfElements;i++) - newNbs.push_back(renumberingFromOldToNew[oldNbs[i]-1]); - newNbs.sort(); - fillFromElementList(newNbs); - } - else - update(); -} - -/*! - operator == + in case false a test if coordinates and connectivity of _mesh and support->_mesh are the same -*/ -bool MEDMEM::SUPPORT::deepCompare(const SUPPORT &support) const -{ - bool operatorReturn =(_entity == support._entity) && - (_numberOfGeometricType == support._numberOfGeometricType) && - ( (_isOnAllElts && support._isOnAllElts) || (!_isOnAllElts && !support._isOnAllElts) ) && - (_totalNumberOfElements == support._totalNumberOfElements); - if (operatorReturn) - { - if (!_isOnAllElts) - { - for (int i=0; i<_numberOfGeometricType && operatorReturn; i++) - { - operatorReturn = (_geometricType[i] == support._geometricType[i]) && - (_numberOfElements[i] == support._numberOfElements[i]); - if (operatorReturn) - { - for (int j=0; j<_numberOfElements[i]; j++) - { - operatorReturn = (getNumber(_geometricType[i])[j] == - support.getNumber(_geometricType[i])[j]); - } - } - } - } - } - if(operatorReturn) - operatorReturn = ( bool(_mesh) == bool(support._mesh)); - - if(operatorReturn) - { - if(!(*_mesh == *support._mesh)) - { - return _mesh->deepCompare(*support._mesh); - } - } - return operatorReturn; -} - -/*! - States if this is included in other. -*/ -bool MEDMEM::SUPPORT::belongsTo(const SUPPORT& other, bool deepCompare) const -{ - if(!(*_mesh == *other._mesh)) - { - if(!deepCompare) - return false; - if(!_mesh->deepCompare(*other._mesh)) - return false; - } - if(_entity!=other._entity) - return false; - if(other._isOnAllElts) - return true; - if(_isOnAllElts && !other._isOnAllElts) - return false; - if(_numberOfGeometricType>other._numberOfGeometricType) - return false; - for(int i=0; i<_numberOfGeometricType; i++) - { - medGeometryElement curGeomType=_geometricType[i]; - int iOther=-1; - for(int j=0; j<other._numberOfGeometricType; j++) - if(other._geometricType[j]==curGeomType) - iOther=j; - if(iOther==-1) - return false; - if(_numberOfElements[i]>other._numberOfElements[iOther]) - return false; - const int *numbers1=_number->getI(i+1); - const int *numbers2=other._number->getI(iOther+1); - for (int k=0; k<_numberOfElements[i]; k++) - { - bool found=false; - for(int l=0;l<other._numberOfElements[iOther] && !found;l++) - { - if(numbers1[k]==numbers2[l]) - found=true; - } - if(!found) - return false; - } - } - return true; -} -/*! - Method used to sort array of id. -*/ -int compareId(const void *x, const void *y); -int compareId(const void *x, const void *y) -{ - const int *x1=(const int *)x; - const int *y1=(const int *)y; - if(*x1<*y1) - return -1; - else if(*x1>*y1) - return 1; - else - return 0; -} - -/*! - performs a common operation : Sub builds a sorted int array that is obtained by supression of all ids contained - in array defined by (idsToSuppress,lgthIdsToSuppress) from array [start ... end] - Example sub(0,7,{1,2,5},3) => {0,3,4,6,7} - WARNING returned list should be deallocated ! -*/ -list<int> *MEDMEM::SUPPORT::sub(int start,int end,const int *idsToSuppress,int lgthIdsToSuppress) -{ - int size=end-start+1; - int sizeRet=size-lgthIdsToSuppress; - list<int> *ret; - if(sizeRet<0) - throw MEDEXCEPTION("MEDMEM::SUPPORT::sub"); - else if(sizeRet==0) - { - return 0; - } - if(idsToSuppress==0) - { - ret=new list<int>; - for(int l=0;l<size;l++) - ret->push_back(start+l); - return ret; - } - ret=new list<int>; - int *temp=new int[lgthIdsToSuppress+1]; - memcpy(temp,idsToSuppress,sizeof(int)*lgthIdsToSuppress); - temp[lgthIdsToSuppress] = -1; - qsort(temp,lgthIdsToSuppress,sizeof(int),compareId); - int k=0; - for(int i=start;i<=end;i++) - if(temp[k]!=i) - ret->push_back(i); - else - k++; - delete [] temp; - return ret; -} - -/*! - performs a common operation : Sub builds a sorted int array that is obtained by supression of all ids contained - in array defined by (idsToSuppress,lgthIdsToSuppress) from array [start ... end] - Example sub({1,3,4,5,6,7,9},7,{1,2,5},3) => {3,4,6,7,9} - WARNING returned list should be deallocated ! -*/ -list<int> *MEDMEM::SUPPORT::sub(const int *ids,int lgthIds,const int *idsToSuppress,int lgthIdsToSuppress) -{ - list<int> *ret; - int i,j=0; - if(lgthIds<0) - throw MEDEXCEPTION("MEDMEM::SUPPORT::sub"); - else if(lgthIds==0) - return 0; - ret=new list<int>; - int *temp1=new int[lgthIds]; - memcpy(temp1,ids,sizeof(int)*lgthIds); - qsort(temp1,lgthIds,sizeof(int),compareId); - int *temp2=new int[lgthIdsToSuppress]; - memcpy(temp2,idsToSuppress,sizeof(int)*lgthIdsToSuppress); - qsort(temp2,lgthIdsToSuppress,sizeof(int),compareId); - for(i=0;i<lgthIds;) - { - if(j>=lgthIdsToSuppress) - ret->push_back(temp1[i++]); - else if(temp1[i]>temp2[j]) - j++; - else if(temp1[i]<temp2[j]) - ret->push_back(temp1[i++]); - else - i++; - } - delete [] temp1; - delete [] temp2; - return ret; -} - -/*! - returns a new SUPPORT (responsability to caller to destroy it) - that is the complement to "this", lying on the same entity than "this". -*/ -SUPPORT *MEDMEM::SUPPORT::getComplement() const -{ - SUPPORT *ret; - const int nbOfElt=_mesh->getNumberOfElements(_entity,MED_ALL_ELEMENTS); - int nbOfEltInSupp=getNumberOfElements(MED_ALL_ELEMENTS); - if(_isOnAllElts || nbOfElt==nbOfEltInSupp) - { - ret=new SUPPORT; - ret->setMesh(_mesh); - ret->setEntity(_entity); - string name="Complement of "; - name+=_name; - ret->setName(name); - return ret; - } - const int *nbs=_number->getValue(); - list<int> *ids=sub(1,nbOfElt,nbs,nbOfEltInSupp); - if(_entity==MED_NODE) - ret=_mesh->buildSupportOnNodeFromElementList(*ids,_entity); - else - ret=_mesh->buildSupportOnElementsFromElementList(*ids,_entity); - delete ids; - return ret; -} - -/*! - returns a new support the user should delete. -*/ -SUPPORT *MEDMEM::SUPPORT::substract(const SUPPORT& other) const throw (MEDEXCEPTION) -{ - const char * LOC = "SUPPORT *MEDMEM::subtract(const SUPPORT * other) : "; - BEGIN_OF_MED(LOC); - SUPPORT *ret; - if (_entity!=other.getEntity()) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Entities are different !")); - if(!(*_mesh == *other.getMesh())) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Mesh are different !")); - if(other._isOnAllElts) - { - ret=new SUPPORT; - ret->setMesh(_mesh); - ret->setEntity(_entity); - return ret; - } - if(_isOnAllElts) - return other.getComplement(); - int nbOfEltInThis=getNumberOfElements(MED_ALL_ELEMENTS); - const int *nbsThis=_number->getValue(); - int nbOfEltInOther=other.getNumberOfElements(MED_ALL_ELEMENTS); - const int *nbsOther=other._number->getValue(); - list<int> *ids=sub(nbsThis,nbOfEltInThis,nbsOther,nbOfEltInOther); - if(_entity==MED_NODE) - ret=_mesh->buildSupportOnNodeFromElementList(*ids,_entity); - else - ret=_mesh->buildSupportOnElementsFromElementList(*ids,_entity); - delete ids; - return ret; - END_OF_MED(LOC); -} - -/*! - returns a new support the user has to delete. Entity is either MED_NODE to obtain node elements lying on boundary of "this" - or MED_FACE,MED_EDGE (depends on the this->_mesh dimension). -*/ -SUPPORT *MEDMEM::SUPPORT::getBoundaryElements(medEntityMesh Entity) const throw (MEDEXCEPTION) -{ - const char * LOC = "SUPPORT *MEDMEM::SUPPORT::getBoundaryElements(medEntityMesh Entity) : "; - BEGIN_OF_MED(LOC); - int spaceDimension=_mesh->getSpaceDimension(); - medEntityMesh baseEntity=Entity; - if (spaceDimension == 3) - { - if (Entity!=MED_FACE) - { - if(Entity==MED_NODE) - baseEntity=MED_FACE; - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined in 3D mesh for entity "<<Entity<<" !")); - } - } - if (spaceDimension == 2) - { - if (Entity!=MED_EDGE) - { - if(Entity==MED_NODE) - baseEntity=MED_EDGE; - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined in 2D mesh for entity "<<Entity<<" !")); - } - } - if(_isOnAllElts) - return _mesh->getBoundaryElements(Entity); - - const MESH* mesh = _mesh->convertInMESH(); - const int * myConnectivityValue=mesh->getReverseConnectivity(MED_DESCENDING); - const int * myConnectivityIndex=mesh->getReverseConnectivityIndex(MED_DESCENDING); - int numberOf=mesh->getNumberOfElements(baseEntity,MED_ALL_ELEMENTS); - const int *ids=_number->getValue(); - set<int> idsSet(ids,ids+_totalNumberOfElements); - list<int> myElementsList; - for (int i=0;i<numberOf;i++) - { - int nbOfDP1EntitySharing=0; - if(idsSet.find(myConnectivityValue[myConnectivityIndex[i]-1])!=idsSet.end()) - nbOfDP1EntitySharing++; - if(idsSet.find(myConnectivityValue[myConnectivityIndex[i]])!=idsSet.end()) - nbOfDP1EntitySharing++; - if(nbOfDP1EntitySharing==1) - myElementsList.push_back(i+1); - } - mesh->removeReference(); - - if(Entity==MED_NODE) - { - return mesh->buildSupportOnNodeFromElementList(myElementsList,baseEntity); - } - else - { - return mesh->buildSupportOnElementsFromElementList(myElementsList,baseEntity); - } -} - -/*! - * \brief Builds a nodal SUPPORT basing on nodes of this one - */ - -SUPPORT* SUPPORT::buildSupportOnNode() const throw (MEDEXCEPTION) -{ - const char * LOC = "SUPPORT *MEDMEM::SUPPORT::buildSupportOnNode() : "; - if ( !getMesh() ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"This SUPPORT has no mesh")); - - SUPPORT* nodalSupport = 0; - if ( isOnAllElements() ) - { - nodalSupport = const_cast<SUPPORT*>( getMesh()->getSupportOnAll( MED_NODE )); - nodalSupport->addReference(); - } - else - { - if ( !_numberOfElements ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"No element numbers in a partial support")); - string name("Support On Node built from "); - name += getName(); - - nodalSupport = new SUPPORT; - nodalSupport->setMesh( getMesh()); - nodalSupport->setName( name ); - nodalSupport->setEntity( MED_NODE ); - nodalSupport->setEntity( getEntity() ); - - const int * nums = _number->getValue(); - list<int> elems( nums, nums + _totalNumberOfElements ); - getMesh()->fillSupportOnNodeFromElementList( elems, nodalSupport ); - } - return nodalSupport; -} - -/*! - Method that fills this and updates all its attributes in order to lye on the the listOfNode. -*/ -void MEDMEM::SUPPORT::fillFromNodeList(const list<int>& listOfNode) throw (MEDEXCEPTION) -{ - setEntity(MED_NODE); - clearDataOnNumbers(); - int size=listOfNode.size(); - int totalNbInMesh=_mesh->getNumberOfElements(_entity,MED_ALL_ELEMENTS); - if(totalNbInMesh==size) - { - _isOnAllElts=true; - update(); - return; - } - else - _isOnAllElts=false; - int numberOfGeometricType=1; - medGeometryElement* geometricType=new medGeometryElement[1]; - geometricType[0]=MED_NONE; - int *numberOfElements=new int[1]; - numberOfElements[0]=size; - int *mySkyLineArrayIndex=new int[2]; - mySkyLineArrayIndex[0]=1; - mySkyLineArrayIndex[1]=1+numberOfElements[0]; - int *tab=new int[numberOfElements[0]]; - int i=0; - for(list<int>::const_iterator iter2=listOfNode.begin();iter2!=listOfNode.end();iter2++) - tab[i++]=*iter2; - MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY(1,numberOfElements[0],mySkyLineArrayIndex,tab,true); - setNumberOfGeometricType(numberOfGeometricType); - setGeometricType(geometricType); - setNumberOfElements(numberOfElements); - setNumber(mySkyLineArray); - - delete[] numberOfElements; - delete[] geometricType; -} - -/* - Method created to factorize code. This method fills the current SUPPORT on entity 'entity' containing all the entities contained in - elements 'listOfElt' of entity 'entity'. Warning this method should be called after both the attributes this->_mesh and this->_entity are correctly set. -*/ -void MEDMEM::SUPPORT::fillFromElementList(const list<int>& listOfElt) throw (MEDEXCEPTION) -{ - clearDataOnNumbers(); - int size=listOfElt.size(); - int totalNbInMesh=_mesh->getNumberOfElements(_entity,MED_ALL_ELEMENTS); - if(totalNbInMesh==size) - { - _isOnAllElts=true; - update(); - return; - } - else - _isOnAllElts=false; - // Well, we must know how many geometric type we have found - int * myListArray = new int[size] ; - int id = 0 ; - list<int>::const_iterator myElementsListIt ; - for (myElementsListIt=listOfElt.begin();myElementsListIt!=listOfElt.end();myElementsListIt++) - myListArray[id++]=(*myElementsListIt) ; - int numberOfGeometricType ; - medGeometryElement* geometricType ; - int * numberOfElements ; - int * mySkyLineArrayIndex ; - - int numberOfType = _mesh->getNumberOfTypes(_entity) ; - if (numberOfType == 1) - { - numberOfGeometricType = 1 ; - geometricType = new medGeometryElement[1] ; - geometricType[0] = _mesh->getTypes(_entity)[0]; - numberOfElements = new int[1] ; - numberOfElements[0] = size ; - mySkyLineArrayIndex = new int[2] ; - mySkyLineArrayIndex[0]=1 ; - mySkyLineArrayIndex[1]=1+size ; - } - else // hemmm - { - map<medGeometryElement,int> theType ; - for (myElementsListIt=listOfElt.begin();myElementsListIt!=listOfElt.end();myElementsListIt++) - { - medGeometryElement myType = _mesh->getElementType(_entity,*myElementsListIt) ; - if (theType.find(myType) != theType.end() ) - theType[myType]+=1 ; - else - theType[myType]=1 ; - } - numberOfGeometricType = theType.size() ; - geometricType = new medGeometryElement[numberOfGeometricType] ; - numberOfElements = new int[numberOfGeometricType] ; - mySkyLineArrayIndex = new int[numberOfGeometricType+1] ; - int index = 0 ; - mySkyLineArrayIndex[0]=1 ; - map<medGeometryElement,int>::iterator theTypeIt ; - for (theTypeIt=theType.begin();theTypeIt!=theType.end();theTypeIt++) - { - geometricType[index] = (*theTypeIt).first ; - numberOfElements[index] = (*theTypeIt).second ; - mySkyLineArrayIndex[index+1]=mySkyLineArrayIndex[index]+numberOfElements[index] ; - index++ ; - } - } - MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray,/*shallowCopy=*/true) ; - setNumberOfGeometricType(numberOfGeometricType) ; - setGeometricType(geometricType) ; - setNumberOfElements(numberOfElements) ; - setNumber(mySkyLineArray) ; - - delete[] numberOfElements; - delete[] geometricType; -} - -/*! \ifdef SUPPORT_advanced - -\brief creates a MESH that contains only the elements in the current support. - -The output mesh has no group, nor elements of connectivity lesser than that of the present support. Nodes are renumbered so that they are numberd from 1 to N in the new mesh. The order of the elements in the new mesh corresponds to that of the elements in the original support. -*/ -MESH* SUPPORT::makeMesh() const -{ - const char* LOC = "SUPPORT::makeMesh(): "; - if ( !_mesh ) - throw MED_EXCEPTION(STRING(LOC)<<" NULL mesh in support"); - if ( _entity == MED_NODE ) - throw MED_EXCEPTION(STRING(LOC)<<" unavailable for support on nodes"); - - //Creating the new mesh - - MESHING* newmesh = new MESHING(); - newmesh->setName( STRING("MeshFromSupport_") << getName() ); - - // set types info - const medGeometryElement* types = getTypes(); - int nb_types = _numberOfGeometricType; - newmesh->setNumberOfTypes ( nb_types, MED_CELL ); - newmesh->setTypes ( types, MED_CELL ); - newmesh->setNumberOfElements( _numberOfElements, MED_CELL); - - // browsing through elements to create a mapping between - // the new nodes and the old nodes and to create nodal connectivity - - const MESH* mesh = _mesh->convertInMESH(); - const medGeometryElement* all_mesh_types = mesh->getTypes( _entity ); - const int * num_index = mesh->getGlobalNumberingIndex( _entity ); - - map<int,int> oldnodes; // map old to new nodes - if ( types[nb_types-1] == MED_POLYHEDRA ) - oldnodes.insert( make_pair( -1, -1 )); // for face separators - int newid=1; - for (int itype=0; itype < _numberOfGeometricType;itype++) - { - medGeometryElement type = types[itype]; - int nbelems = getNumberOfElements(type); - - // get connectivity info - int shift = 1; // to pass from elem number to array index - const int* conn = mesh->getConnectivity(MED_NODAL,_entity,MED_ALL_ELEMENTS); - const int* index = mesh->getConnectivityIndex(MED_NODAL,_entity); - int t = 0; - while ( type != all_mesh_types[t] ) ++t; - shift+= num_index[ t ] - num_index[0]; - index+= num_index[ t ] - num_index[0]; - - // make and set new connectivity - if ( _isOnAllElts && _entity == MED_CELL ) - { - newmesh->setConnectivity( MED_CELL, type, conn, index ); - } - else // partial support or support of sub-entities - { - vector<int> new_conn, new_index; - new_conn.reserve ( nbelems * (type % 100) ); - new_index.reserve( nbelems + 1 ); - new_index.push_back(1); - - const int * nums = _isOnAllElts ? 0 : getNumber( type ); - - for (int i=0; i<nbelems; i++) - { - int ielem = nums ? nums[i]-shift : i; - const int* elem_node = conn + index[ ielem ] - 1; - const int* nodes_end = conn + index[ ielem+1 ] - 1; - for ( ; elem_node < nodes_end; ++elem_node ) - { - // make new connectivity - map<int,int>::iterator old_new = oldnodes.insert(make_pair( *elem_node, newid )).first; - new_conn.push_back( old_new->second ); - if ( old_new->second == newid ) - newid++; - } - new_index.push_back( new_index.back() + index[ ielem+1 ] - index[ ielem ] ); - } - // set new connectivity - newmesh->setConnectivity( MED_CELL, type, & new_conn[0], & new_index[0] ); - } - } - - //definition of coordinates - - int nb_nodes, spacedim = mesh->getSpaceDimension(); - const double*oldcoords = mesh->getCoordinates(MED_FULL_INTERLACE); - PointerOf<double> newcoords; - - if ( _isOnAllElts && _entity == MED_CELL ) - { - nb_nodes = mesh->getNumberOfNodes(); - newcoords.set( oldcoords ); - } - else - { - nb_nodes = oldnodes.size(); - newcoords.set( nb_nodes * spacedim); - for (std::map<int,int>::const_iterator iter=oldnodes.begin(); iter!=oldnodes.end();iter++) - std::copy( oldcoords+(iter->first-1 )*spacedim, - oldcoords+(iter->first )*spacedim, - newcoords+(iter->second-1)*spacedim); - } - newmesh->setCoordinates(spacedim, nb_nodes, newcoords, - mesh->getCoordinatesSystem(), MED_FULL_INTERLACE); - newmesh->setCoordinatesNames ( mesh->getCoordinatesNames() ); - newmesh->setCoordinatesUnits ( mesh->getCoordinatesUnits() ); - - mesh->removeReference(); - - return newmesh; -} -/*! - @} -*/ - -/*! set the reference _mesh to Mesh */ -//-------------------------------------- -void SUPPORT::setMesh(const GMESH *Mesh) const - //-------------------------------------- -{ - if(_mesh!=Mesh) - { - if(_mesh) - _mesh->removeReference(); - _mesh=Mesh; - _meshName = ""; - if(_mesh) - _mesh->addReference(); - } -} - -/*! returns the mesh name */ -//------------------------------------ -string SUPPORT::getMeshName() const - //------------------------------------ -{ - if (_mesh) - return _mesh->getName(); - else - return _meshName; -} - -/*!\if MEDMEM_ug -\addtogroup SUPPORT_query -@{ -\endif -*/ - -/*! - This method returns the number of all elements of the type GeometricType. - - If isOnAllElements is false, it returns the number of elements in the - support otherwise it returns number of elements in the mesh. - - Example : number of MED_TRIA3 or MED_ALL_ELEMENTS elements - in support. - - Note : If SUPPORT is defined on MED_NODE, use MED_ALL_ELEMENTS as - medGeometryElement GeometricType and it will return the number - of nodes in the support (or in the mesh). -*/ -//----------------------------------------------------------------------------- -int SUPPORT::getNumberOfElements(MED_EN::medGeometryElement GeometricType) const - throw (MEDEXCEPTION) -//----------------------------------------------------------------------------- -{ - if (GeometricType==MED_EN::MED_ALL_ELEMENTS) - return _totalNumberOfElements; - for (int i=0;i<_numberOfGeometricType;i++) - if (_geometricType[i]==GeometricType) - return ( _totalNumberOfElements < 1 ) ? 0 : _numberOfElements[i]; - throw MEDEXCEPTION("Support::getNumberOfElements : Geometric type not found !") ; -} - - /*! Returns the total number of elements in the support. */ -//----------------------------------------------------------------------------- -const int * SUPPORT::getNumberOfElements() const throw (MEDEXCEPTION) { -//----------------------------------------------------------------------------- - return _numberOfElements; -} - -/*! - Returns index of element number. - - Note : See getConnectivityIndex for details. -*/ -//------------------------------------------- -const int * SUPPORT::getNumberIndex() const -//------------------------------------------- - throw (MEDEXCEPTION) -{ - /* issue 0021167: [CEA 448] Supports management on all elements - if (_isOnAllElts) - throw MEDEXCEPTION("Support::getNumberIndex : Not defined, support is on all entity !") ; - */ - if ( !_number ) - throw MEDEXCEPTION("Support::getNumberIndex : numbers not set !") ; - return _number->getIndex() ; -} -/*! \if MEDMEM_ug -@} -\endif */ - -//--------------------------------------------------------------------- -MEDSKYLINEARRAY * SUPPORT::getnumber() const - throw (MEDEXCEPTION) -//--------------------------------------------------------------------- -{ - if (_number==NULL) - throw MEDEXCEPTION("Support::getnumber : Not defined !") ; - return _number ; -} - -//--------------------------------------------------------------------- -MEDSKYLINEARRAY * SUPPORT::getnumberFromFile() const - throw (MEDEXCEPTION) -//--------------------------------------------------------------------- -{ - if (_number_fromfile==NULL) - throw MEDEXCEPTION("Support::getnumberFromFile : Not defined !") ; - return _number_fromfile ; -} - -/*! - Returns an array which contains all number of given medGeometryElement. - - Numbering is global, ie numbers are bounded by 1 and - GMESH::getNumberOfElement(entity,MED_ALL_ELEMENTS) and not by 1 and - GMESH::getNumberOfElement(entity,geomElement). - - Note : If SUPPORT is defined on MED_NODE, use MED_NONE - medGeometryElement type. -*/ -//--------------------------------------------------------------------- -const int * SUPPORT::getNumber(MED_EN::medGeometryElement GeometricType) const - throw (MEDEXCEPTION) -//--------------------------------------------------------------------- -{ - /* issue 0021167: [CEA 448] Supports management on all elements - if (_isOnAllElts) - throw MEDEXCEPTION("Support::getNumber : Not defined, support is on all entity !") ; - */ - if (!_number) - { - if ( _isOnAllElts ) - //update(); - throw MEDEXCEPTION("Support::getNumber : not updated (update()) SUPPORT on all elements !") ; - else if ( _totalNumberOfElements > 0 ) - throw MEDEXCEPTION("Support::getNumber : wrong support, _number not defined !") ; - else - return NULL; - } - if (GeometricType==MED_EN::MED_ALL_ELEMENTS) - return _number->getValue() ; - for (int i=0;i<_numberOfGeometricType;i++) - if (_geometricType[i]==GeometricType) - return _number->getI(i+1) ; - throw MEDEXCEPTION("Support::getNumber : GeometricType not found !") ; -} - -//--------------------------------------------------------------------- -const int * SUPPORT::getNumberFromFile(MED_EN::medGeometryElement GeometricType) const - throw (MEDEXCEPTION) -//--------------------------------------------------------------------- -{ -// if (_isOnAllElts) -// throw MEDEXCEPTION("Support::getNumberFromFile : Not defined, support is on all entity !") ; - if (GeometricType==MED_EN::MED_ALL_ELEMENTS) - return _number_fromfile->getValue() ; - for (int i=0;i<_numberOfGeometricType;i++) - if (_geometricType[i]==GeometricType) - return _number_fromfile->getI(i+1) ; - throw MEDEXCEPTION("Support::getNumberFromFile : GeometricType not found !") ; -} - -/*! set the meshName if there is ni reference _mesh to Mesh */ -//-------------------------------------- -void SUPPORT::setMeshName(const std::string & meshName) -//-------------------------------------- -{ - if (_mesh) - throw MEDEXCEPTION("SUPPORT::setMeshName(const string & meshName) : Setting meshName is not possible when an associated mesh is set !") ; - - _meshName=meshName; -} - -/*! set the attribute _entity to Entity */ -//------------------------------------------ -void SUPPORT::setEntity(MED_EN::medEntityMesh Entity) -{ - _entity=Entity; - // 0021199: [CEA 458] MEDMEM::SUPPORT : geometric type when support is on node - // set geometric type -> MED_NONE - if ( _entity == MED_NODE ) - { - _numberOfGeometricType = 1; - const MED_EN::medGeometryElement nodeType = MED_EN::MED_NONE; - _geometricType.set(0); - setGeometricType( &nodeType ); - } -} - -/*! set the attribute _numberOfGeometricType to NumberOfGeometricType */ -//--------------------------------------------------------------------- -void SUPPORT::setNumberOfGeometricType(int NumberOfGeometricType) -//--------------------------------------------------------------------- -{ - _numberOfGeometricType=NumberOfGeometricType; - - _geometricType.set(0); - _numberOfElements.set(0); - _profilNames.resize( NumberOfGeometricType, "" ); -} - -/*! set the attribute _geometricType to geometricType */ -//--------------------------------------------------------------------- -void SUPPORT::setGeometricType(const MED_EN::medGeometryElement *GeometricType) -//--------------------------------------------------------------------- -{ - if (!_geometricType) - { - _geometricType.set(_numberOfGeometricType, GeometricType); - // 0021199: [CEA 458] MEDMEM::SUPPORT : geometric type when support is on node - // geometric type must be MED_NONE - if ( _entity == MED_NODE && _numberOfGeometricType == 1 && _geometricType[0] != MED_NONE ) - throw MEDEXCEPTION("SUPPORT::setGeometricType(), valid type for MED_NODE is MED_NONE "); - } - if (_profilNames.empty() || _profilNames[0].empty()) - { - // giving a default value to profile names - vector<string> prof_names( _numberOfGeometricType); - string name = healName( _name ); - for (int itype=0; itype < _numberOfGeometricType; itype++) - { - ostringstream typestr; - typestr<<name<<"_type"<<_geometricType[itype]; - prof_names[itype]=typestr.str(); - } - _profilNames=prof_names; - } -} - -/*! - Set the attribute _numberOfElements to NumberOfElements and - calculate the total number of elements. -*/ -//---------------------------------------------------------- -void SUPPORT::setNumberOfElements(const int *NumberOfElements) -//---------------------------------------------------------- -{ - if (_numberOfElements == NULL) - { - if (_numberOfGeometricType) - _numberOfElements.set(_numberOfGeometricType,NumberOfElements); - else - _numberOfElements.set(0); - } - _totalNumberOfElements = 0 ; - for (int i=0;i<_numberOfGeometricType;i++) - _totalNumberOfElements+=_numberOfElements[i]; -} - -/*! set the attribute _number to Number */ -//--------------------------------------------------- -void SUPPORT::setNumber(MEDSKYLINEARRAY * Number) -//--------------------------------------------------- -{ - /* issue 0021167: [CEA 448] Supports management on all elements - if ( _isOnAllElts ) - throw MEDEXCEPTION("SUPPORT::setNumber(MEDSKYLINEARRAY * Number) Support is on all elements") ; - */ - if (_number != NULL) delete _number ; - _number=Number; -} - -/*! set the attribute _number with index and value arrays */ -//--------------------------------------------------- -void SUPPORT::setNumber(const int * index, const int* value, bool shallowCopy) -//--------------------------------------------------- -{ - if (_number != NULL) delete _number ; - _number= new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfElements,index,value,shallowCopy); -} diff --git a/src/MEDMEM/MEDMEM_Support.hxx b/src/MEDMEM/MEDMEM_Support.hxx deleted file mode 100644 index 732836100..000000000 --- a/src/MEDMEM/MEDMEM_Support.hxx +++ /dev/null @@ -1,365 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -/* - File Support.hxx -*/ - -#ifndef SUPPORT_HXX -#define SUPPORT_HXX - -#include <MEDMEM.hxx> - -#include <list> -#include <vector> -#include <string> -#include <list> - -#include "MEDMEM_Utilities.hxx" -#include "MEDMEM_STRING.hxx" -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_define.hxx" -#include "MEDMEM_SkyLineArray.hxx" -#include "MEDMEM_RCBase.hxx" - - -namespace MEDMEM { - - class GMESH; - class MESH; - -/*! - - This class describe a support of elements on an entity of the mesh. - - It contains the list of meshes elements for an entity (MED_NODE, - MED_CELL, MED_FACE or MED_EDGE). - -*/ -class MEDMEM_EXPORT SUPPORT : public RCBASE -{ -protected: - /*! - \if developper - Support name. - \endif - */ - std::string _name; - - /*! - \if developper - Name of the associated mesh if the _mesh pointer - is NULL. - \endif - */ - mutable std::string _meshName; - - /*! - \if developper - Description of the support (optional). - \endif - */ - std::string _description; - - /*! - \if developper - Reference to the mesh on which the support is defined. - \endif - */ - mutable const GMESH * _mesh; - - /*! - \if developper - Type of entity on which the support is defined - (only one for each support). - \endif - */ - MED_EN::medEntityMesh _entity ; - - /*! - \if developper - Number of geometric type defined in the support. - \endif - */ - int _numberOfGeometricType; - - /*! - \if developper - Array of all geometric type defined in the support. - \endif - */ - PointerOf<MED_EN::medGeometryElement> _geometricType; - - /*! - \if developper - If true, we consider all entities of type _entity - defined in the associated mesh - \endif - */ - bool _isOnAllElts; - - /*! - \if developper - Index array of size _numberOfGeometricType wich contains - for each geometric type, the number of elements of this type. - \endif - */ - PointerOf<int> _numberOfElements; - - /*! - \if developper - Sum of each _numberOfElements component. - \endif - */ - int _totalNumberOfElements; - - // the two following arrays are defined only if _isOnAllElts is false : - - /*! - \if developper - Array of size _index[_numberOfType]-1 wich contain number of - entities of each geometric type. We use global numbering.\n - Defined only if _isOnAllElts is false. - \endif - */ - mutable MEDSKYLINEARRAY * _number; - - /*! - \if developper - Array of size _index[_numberOfType]-1 wich contain number of - entities of each geometric type. We use file numbering.\n - Defined only if _isOnAllElts is false. - \endif - */ - mutable MEDSKYLINEARRAY * _number_fromfile; - - /*! - \if developper - Array of size <_numberOfGeometricType> wich contain the profil name of - entities of each geometric type.\n - Defined only if _isOnAllElts is false. - If it exist an entities list on a geometric type in _number but there is no profil name associated - ( MED_NOPFL ) the MED driver will consider and verify this entities list as being all the - entities available on the associated mesh for this geometric type. - \endif - */ - - std::vector< std::string > _profilNames; -public: - SUPPORT(); - //SUPPORT(GMESH* Mesh, std::string Name="", MED_EN::medEntityMesh Entity=MED_EN::MED_CELL); - SUPPORT(const SUPPORT & m); -public: - friend MEDMEM_EXPORT ostream & operator<<(ostream &os,const SUPPORT &my); - - SUPPORT& operator=(const SUPPORT &support); - bool operator == (const SUPPORT &support) const; - bool deepCompare(const SUPPORT &support) const; - void update(); - - inline void setName(const std::string& Name); - inline void setDescription(const std::string& Description); - void setMesh(const GMESH *Mesh) const; - void setMeshName(const string & meshName); - inline void setAll(bool All); - void setEntity(MED_EN::medEntityMesh Entity); - void setNumberOfGeometricType(int NumberOfGeometricType); - void setGeometricType(const MED_EN::medGeometryElement *GeometricType); - void setNumberOfElements(const int *NumberOfElements); - void setNumber(MEDSKYLINEARRAY * Number); - void setNumber(const int * index, const int* value, bool shallowCopy=false); - - inline const std::string& getName() const; - inline const std::string& getDescription() const; - virtual inline const GMESH * getMesh() const; - std::string getMeshName() const; - inline MED_EN::medEntityMesh getEntity() const; - - inline bool isOnAllElements() const; - inline int getNumberOfTypes() const; - inline const MED_EN::medGeometryElement* getTypes() const ; - int getNumberOfElements(MED_EN::medGeometryElement GeometricType) const throw (MEDEXCEPTION); - const int * getNumberOfElements() const throw (MEDEXCEPTION); - virtual MEDSKYLINEARRAY * getnumber() const throw (MEDEXCEPTION); - virtual MEDSKYLINEARRAY * getnumberFromFile() const throw (MEDEXCEPTION); - virtual const int * getNumber(MED_EN::medGeometryElement GeometricType) const throw (MEDEXCEPTION); - virtual const int * getNumberFromFile(MED_EN::medGeometryElement GeometricType) const throw (MEDEXCEPTION); - virtual const int * getNumberIndex() const throw (MEDEXCEPTION); - virtual int getValIndFromGlobalNumber(const int number) const throw (MEDEXCEPTION); - - void blending(const SUPPORT * mySupport) throw (MEDEXCEPTION) ; - - // Les numéros d'entités dans les profils doivent être croissant - // pour respecter la norme MED - void setpartial(const std::string& Description, int NumberOfGeometricType, - int TotalNumberOfEntity, const MED_EN::medGeometryElement *GeometricType, - const int *NumberOfEntity, const int *NumberValue); - - void setpartial(MEDSKYLINEARRAY * number, bool shallowCopy=false) throw (MEDEXCEPTION); - - - void setpartial_fromfile(MEDSKYLINEARRAY * number, bool shallowCopy=false) throw (MEDEXCEPTION); - - // Si les noms de profils ne sont pas positionnés, les profils ne seront - // pas écrits par MEDFICHIER. - void setProfilNames(const std::vector<std::string>& profilNames) throw (MEDEXCEPTION); - //string getProfilName(const MED_EN::medGeometryElement GeometricType) const throw (MEDEXCEPTION); - std::vector<std::string> getProfilNames() const throw (MEDEXCEPTION); - - void getBoundaryElements() throw (MEDEXCEPTION); - void changeElementsNbs(MED_EN::medEntityMesh entity, const int *renumberingFromOldToNew); - void intersecting(const SUPPORT * mySupport) throw (MEDEXCEPTION) ; - bool belongsTo(const SUPPORT& other, bool deepCompare=false) const; - SUPPORT *getComplement() const; - SUPPORT *substract(const SUPPORT& other) const throw (MEDEXCEPTION) ; - SUPPORT *getBoundaryElements(MED_EN::medEntityMesh Entity) const throw (MEDEXCEPTION); - SUPPORT* buildSupportOnNode() const throw (MEDEXCEPTION); - void fillFromNodeList(const std::list<int>& listOfNode) throw (MEDEXCEPTION); - void fillFromElementList(const std::list<int>& listOfElt) throw (MEDEXCEPTION); - void clearDataOnNumbers(); - MESH* makeMesh() const; - protected: - virtual ~SUPPORT(); - protected: - static std::list<int> *sub(int start,int end,const int *idsToSuppress,int lgthIdsToSuppress); - static std::list<int> *sub(const int *ids,int lgthIds,const int *idsToSuppress,int lgthIdsToSuppress); -}; - -// _____________________ -// Methodes Inline -// _____________________ - -/*! set the attribute _name to Name */ -//-------------------------------------- -inline void SUPPORT::setName(const std::string& Name) -//-------------------------------------- -{ - _name=Name; -} - -/*! set the attribute _description to Description */ -//-------------------------------------------------- -inline void SUPPORT::setDescription(const std::string& Description) -//-------------------------------------------------- -{ - _description=Description; -} - - /*! \if MEDMEM_ug -\addtogroup SUPPORT_creation -@{ -\endif - */ - -/*! Creates a support on all elements of the type specified in the constructor. - - Even if _isonAllElts is true, geometric types defining the FIELD's SUPPORT - must be read from the SUPPORT not from the associated GMESH (the geometric - types defining the FIELD's SUPPORT may be a subset of the geometric types - defined in the GMESH even if for each SUPPORT geometric type all MESH entities - are used). -*/ -//------------------------------------------ -inline void SUPPORT::setAll(bool All) -//------------------------------------------ -{ - _isOnAllElts=All; -} - /*! \if MEDMEM_ug @} \endif */ - -/*! returns the name of the support. */ -//------------------------------------ -inline const std::string& SUPPORT::getName() const -//------------------------------------ -{ - return _name; -} - -/*! returns the description of the support. */ -//-------------------------------------------- -inline const std::string& SUPPORT::getDescription() const -//-------------------------------------------- -{ - return _description; -} - -/*! returns a reference to the mesh */ -//------------------------------------ -inline const GMESH * SUPPORT::getMesh() const -//------------------------------------ -{ - return _mesh; -} - -/*! - Returns true if all elements of this entity are - concerned, false otherwise. - If true, you must use mesh reference (getMesh) to get more information. -*/ -//------------------------------------------ -inline bool SUPPORT::isOnAllElements() const -//------------------------------------------ -{ - return _isOnAllElts; -} - -/*! - Returns number of geometric Types - defines in the support -*/ -//------------------------------------------ -inline int SUPPORT::getNumberOfTypes() const -//------------------------------------------ -{ - // if ((_isOnAllElts)&(_entity != MED_NODE)) - // return _mesh->getNumberOfTypes(_entity) ; - // else - return _numberOfGeometricType ; -} - -/*! - Returns the %medEntityMesh's type used by the support. - Note : A support deals only with one entity's type - (for example : MED_FACE or MED_NODE) -*/ -//--------------------------------------------- -inline MED_EN::medEntityMesh SUPPORT::getEntity() const -//--------------------------------------------- -{ - return _entity; -} - -/*! - If isOnAllElements is false, returns an array of %medGeometryElement - types used by the support. -*/ -//--------------------------------------------------- -inline const MED_EN::medGeometryElement * SUPPORT::getTypes() const -//--------------------------------------------------- -{ - return _geometricType; -} - -}//End namespace MEDMEM - - -#endif /* SUPPORT_HXX */ diff --git a/src/MEDMEM/MEDMEM_Tags.hxx b/src/MEDMEM/MEDMEM_Tags.hxx deleted file mode 100644 index 5878b2c2a..000000000 --- a/src/MEDMEM/MEDMEM_Tags.hxx +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef MEDMEM_TAGS_HXX -#define MEDMEM_TAGS_HXX - -namespace MEDMEM { - -struct Gauss {}; -struct NoGauss {}; -struct FullInterlace{}; -struct NoInterlace{}; -struct NoInterlaceByType{}; - -} - -#endif - - diff --git a/src/MEDMEM/MEDMEM_TopLevel.cxx b/src/MEDMEM/MEDMEM_TopLevel.cxx deleted file mode 100644 index 3f15f7dbc..000000000 --- a/src/MEDMEM/MEDMEM_TopLevel.cxx +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_TopLevel.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_DriverFactory.hxx" - -using namespace MED_EN; -using namespace MEDMEM; - -MESH *::MEDMEM::readMeshInFile(const std::string& fileName, const std::string& meshName) -{ - MESH *mesh = new MESH; - driverTypes type = DRIVERFACTORY::deduceDriverTypeFromFileName(fileName); - int id = mesh->addDriver(type,fileName,meshName,RDWR); - mesh->read(id); - return mesh; -} - -void ::MEDMEM::writeMeshToFile(const MESH *meshObj, const std::string& fileName) -{ - MESH *meshObjNoC = (MESH *)meshObj;//MED::write should be a const method ... As it's not the case - driverTypes type = DRIVERFACTORY::deduceDriverTypeFromFileName(fileName); - int id = meshObjNoC->addDriver(type,fileName,meshObjNoC->getName(),RDWR); - meshObjNoC->write(id); -} diff --git a/src/MEDMEM/MEDMEM_TopLevel.hxx b/src/MEDMEM/MEDMEM_TopLevel.hxx deleted file mode 100644 index 67b62b89b..000000000 --- a/src/MEDMEM/MEDMEM_TopLevel.hxx +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __MEDMEM_TOPLEVEL_HXX__ -#define __MEDMEM_TOPLEVEL_HXX__ - -#include "MEDMEM_FieldForward.hxx" -#include "MEDMEM_Exception.hxx" -#include <string> - -namespace MEDMEM -{ - class MED; - class MESH; -} - -namespace MEDMEM -{ - //read part - MEDMEM_EXPORT MESH *readMeshInFile(const std::string& fileName, const std::string& meshName); - template<class T> - FIELD<T> *readFieldInFile(const std::string& fileName, const std::string& fieldName); - //write part - MEDMEM_EXPORT void writeMeshToFile(const MESH *meshObj, const std::string& fileName); - template<class T> - void writeFieldToFile(const FIELD<T> *fieldObj, const std::string& fileName); -} - -#include "MEDMEM_Field.hxx" - -namespace MEDMEM -{ - template<class T> - FIELD<T> *readFieldInFile(const std::string& fileName, const std::string& fieldName) - { - FIELD<T> *ret=new FIELD<T>(); - ret->setName(fieldName); - driverTypes type=DRIVERFACTORY::deduceDriverTypeFromFileName(fileName); - int id=ret->addDriver(type,fileName,fieldName); - ret->read(id); - return ret; - } - - template<class T> - void writeFieldToFile(const FIELD<T> *fieldObj, const std::string& fileName) - { - FIELD<T> *fieldObjNoC=(FIELD<T> *)fieldObj; - driverTypes type=DRIVERFACTORY::deduceDriverTypeFromFileName(fileName); - int id=fieldObjNoC->addDriver(type, fileName, fieldObj->getName()); - fieldObjNoC->write(id); - } -} - -#endif diff --git a/src/MEDMEM/MEDMEM_TypeMeshDriver.cxx b/src/MEDMEM/MEDMEM_TypeMeshDriver.cxx deleted file mode 100644 index 267aea5e8..000000000 --- a/src/MEDMEM/MEDMEM_TypeMeshDriver.cxx +++ /dev/null @@ -1,244 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_TypeMeshDriver.hxx" -#include "MEDMEM_DriversDef.hxx" - -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Group.hxx" -#include "MEDMEM_Coordinate.hxx" -#include "MEDMEM_Connectivity.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_CellModel.hxx" - -using namespace std; -using namespace MEDMEM; - -// Every memory allocation made in the MedDriver members function are desallocated in the Mesh destructor - -TYPE_MESH_DRIVER::TYPE_MESH_DRIVER(): - GENDRIVER(), - _ptrMesh(( MESH *)MED_NULL), - // A VOIR _medIdt(MED_INVALID), - _meshName("") -{ -} - -TYPE_MESH_DRIVER::TYPE_MESH_DRIVER(const std::string & fileName, - MESH * ptrMesh, - MED_EN::med_mode_acces accessMode): - GENDRIVER(fileName,accessMode), - _ptrMesh(ptrMesh), - // A VOIR _medIdt(MED_INVALID), - _meshName("") -{ -} - -TYPE_MESH_DRIVER::TYPE_MESH_DRIVER(const TYPE_MESH_DRIVER & driver): - GENDRIVER(driver), - _ptrMesh(driver._ptrMesh), - // A VOIR _medIdt(MED_INVALID), - _meshName(driver._meshName) -{ -} - -TYPE_MESH_DRIVER::~TYPE_MESH_DRIVER() -{ -} - -void TYPE_MESH_DRIVER::open() - throw (MEDEXCEPTION) -{ - const char * LOC = "TYPE_MESH_DRIVER::open()" ; - BEGIN_OF_MED(LOC); - -// if (_medIdt > 0) -// _status = MED_OPENED; -// else { -// _medIdt = MED_INVALID; -// _status = MED_CLOSED; -// throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Could not open file "<<_fileName<<" in mode "<<_accessMode)); -// } - - END_OF_MED(LOC); -} - -void TYPE_MESH_DRIVER::close() - throw (MEDEXCEPTION) -{ - const char * LOC = "TYPE_MESH_DRIVER::close() " ; - BEGIN_OF_MED(LOC); - -// int err = 0; -// if ( _status == MED_OPENED) { -// err=MED_FR::MEDfermer(_medIdt); -// H5close(); // If we call H5close() all the files are closed. -// if (err != 0) -// throw MEDEXCEPTION( LOCALIZED(STRING(LOC) -// <<" Error when closing file !" -// ) -// ); -// _status = MED_CLOSED; -// _medIdt = MED_INVALID; -// } - - END_OF_MED(LOC); -} - -void TYPE_MESH_DRIVER::setMeshName(const string & meshName) { _meshName = meshName; }; -string TYPE_MESH_DRIVER::getMeshName() const { return _meshName; }; - - -//---------------------------------- RDONLY PART ------------------------------------------------------------- - -TYPE_MESH_RDONLY_DRIVER::TYPE_MESH_RDONLY_DRIVER(): TYPE_MESH_DRIVER() -{ -} - -TYPE_MESH_RDONLY_DRIVER::TYPE_MESH_RDONLY_DRIVER(const string & fileName, - MESH * ptrMesh): - TYPE_MESH_DRIVER(fileName,ptrMesh,MED_RDONLY) -{ - MESSAGE_MED("TYPE_MESH_RDONLY_DRIVER::TYPE_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created"); -} - -TYPE_MESH_RDONLY_DRIVER::TYPE_MESH_RDONLY_DRIVER(const TYPE_MESH_RDONLY_DRIVER & driver): - TYPE_MESH_DRIVER(driver) -{ -} - -TYPE_MESH_RDONLY_DRIVER::~TYPE_MESH_RDONLY_DRIVER() -{ - //MESSAGE_MED("TYPE_MESH_RDONLY_DRIVER::~TYPE_MESH_RDONLY_DRIVER() has been destroyed"); -} - -GENDRIVER * TYPE_MESH_RDONLY_DRIVER::copy(void) const -{ - return new TYPE_MESH_RDONLY_DRIVER(*this); -} - -void TYPE_MESH_RDONLY_DRIVER::read(void) - throw (MEDEXCEPTION) -{ - const char * LOC = "TYPE_MESH_RDONLY_DRIVER::read() : " ; - BEGIN_OF_MED(LOC); - - if (_status!=MED_OPENED) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName << " is : " << " (the file is not opened)." )) ; - - _ptrMesh->_name = _meshName; - - - END_OF_MED(LOC); -} - -void TYPE_MESH_RDONLY_DRIVER::write( void ) const - throw (MEDEXCEPTION) -{ - throw MEDEXCEPTION("TYPE_MESH_RDONLY_DRIVER::write : Can't write with a RDONLY driver !"); -} - - -/*--------------------- WRONLY PART -------------------------------*/ - -TYPE_MESH_WRONLY_DRIVER::TYPE_MESH_WRONLY_DRIVER():TYPE_MESH_DRIVER() -{ -} - -TYPE_MESH_WRONLY_DRIVER::TYPE_MESH_WRONLY_DRIVER(const string & fileName, - MESH * ptrMesh): - TYPE_MESH_DRIVER(fileName,ptrMesh,MED_WRONLY) -{ - MESSAGE_MED("TYPE_MESH_WRONLY_DRIVER::TYPE_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created"); -} - -TYPE_MESH_WRONLY_DRIVER::TYPE_MESH_WRONLY_DRIVER(const TYPE_MESH_WRONLY_DRIVER & driver): - TYPE_MESH_DRIVER(driver) -{ -} - -TYPE_MESH_WRONLY_DRIVER::~TYPE_MESH_WRONLY_DRIVER() -{ - //MESSAGE_MED("TYPE_MESH_WRONLY_DRIVER::TYPE_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed"); -} - -GENDRIVER * TYPE_MESH_WRONLY_DRIVER::copy(void) const -{ - return new TYPE_MESH_WRONLY_DRIVER(*this); -} - -void TYPE_MESH_WRONLY_DRIVER::read (void) - throw (MEDEXCEPTION) -{ - throw MEDEXCEPTION("TYPE_MESH_WRONLY_DRIVER::read : Can't read with a WRONLY driver !"); -} - -void TYPE_MESH_WRONLY_DRIVER::write(void) const - throw (MEDEXCEPTION) -{ - const char * LOC = "void TYPE_MESH_WRONLY_DRIVER::write(void) const : "; - BEGIN_OF_MED(LOC); - - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< "Write Driver isn\'t implemented")); - - END_OF_MED(LOC); -} - - - -/*--------------------- RDWR PART -------------------------------*/ - -TYPE_MESH_RDWR_DRIVER::TYPE_MESH_RDWR_DRIVER():TYPE_MESH_DRIVER() -{ -} - -TYPE_MESH_RDWR_DRIVER::TYPE_MESH_RDWR_DRIVER(const string & fileName, - MESH * ptrMesh): - TYPE_MESH_DRIVER(fileName,ptrMesh,MED_RDWR) -{ - MESSAGE_MED("TYPE_MESH_RDWR_DRIVER::TYPE_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been created"); -} - -TYPE_MESH_RDWR_DRIVER::TYPE_MESH_RDWR_DRIVER(const TYPE_MESH_RDWR_DRIVER & driver): - TYPE_MESH_RDONLY_DRIVER::TYPE_MESH_DRIVER(driver) -{ -} - -TYPE_MESH_RDWR_DRIVER::~TYPE_MESH_RDWR_DRIVER() { - //MESSAGE_MED("TYPE_MESH_RDWR_DRIVER::TYPE_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed"); -} - -GENDRIVER * TYPE_MESH_RDWR_DRIVER::copy(void) const -{ - return new TYPE_MESH_RDWR_DRIVER(*this); -} - -void TYPE_MESH_RDWR_DRIVER::write(void) const - throw (MEDEXCEPTION) -{ - TYPE_MESH_WRONLY_DRIVER::write(); -} -void TYPE_MESH_RDWR_DRIVER::read (void) - throw (MEDEXCEPTION) -{ - TYPE_MESH_RDONLY_DRIVER::read(); -} diff --git a/src/MEDMEM/MEDMEM_TypeMeshDriver.hxx b/src/MEDMEM/MEDMEM_TypeMeshDriver.hxx deleted file mode 100644 index 9866c03a4..000000000 --- a/src/MEDMEM/MEDMEM_TypeMeshDriver.hxx +++ /dev/null @@ -1,234 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef TYPE_MESH_DRIVER_HXX -#define TYPE_MESH_DRIVER_HXX - -#include "MEDMEM.hxx" - -#include <string> -#include <vector> - -#include "MEDMEM_define.hxx" -#include "MEDMEM_GenDriver.hxx" - -#include "MEDMEM_STRING.hxx" -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_Utilities.hxx" - -/*! - - Driver TYPE for MESH. - - Generic part : implement the readopen and close methods. - -*/ - - -namespace MEDMEM { -class MESH; -class FAMILY; -class GROUP; -class CONNECTIVITY; -class MEDMEM_EXPORT TYPE_MESH_DRIVER : public GENDRIVER -{ -protected: - - MESH * _ptrMesh; - // A VOIR FILE DESCRIPTEUR ? MED_FR::med_idt _medIdt; - string _meshName; - -public : - - /*! - Constructor. - */ - TYPE_MESH_DRIVER() ; - /*! - Constructor. - */ - TYPE_MESH_DRIVER(const std::string & fileName, - MESH * ptrMesh, - med_mode_acces accessMode) ; - /*! - Copy constructor. - */ - TYPE_MESH_DRIVER(const TYPE_MESH_DRIVER & driver) ; - - /*! - Destructor. - */ - virtual ~TYPE_MESH_DRIVER() ; - - void open() throw (MEDEXCEPTION); - void close() throw (MEDEXCEPTION); - - virtual void write( void ) const = 0 ; - virtual void read ( void ) = 0 ; - - /*! - Set the name of the MESH asked in file. - - It could be different than the name of the MESH object. - */ - void setMeshName(const string & meshName) ; - /*! - Get the name of the MESH asked in file. - */ - string getMeshName() const ; - -private: - virtual GENDRIVER * copy ( void ) const = 0 ; - -}; - - -class MEDMEM_EXPORT TYPE_MESH_RDONLY_DRIVER : public virtual TYPE_MESH_DRIVER -{ - -public : - - /*! - Constructor. - */ - TYPE_MESH_RDONLY_DRIVER() ; - /*! - Constructor. - */ - TYPE_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) ; - /*! - Copy constructor. - */ - TYPE_MESH_RDONLY_DRIVER(const TYPE_MESH_RDONLY_DRIVER & driver) ; - - /*! - Destructor. - */ - virtual ~TYPE_MESH_RDONLY_DRIVER() ; - - /*! - Return a MEDEXCEPTION : it is the read-only driver. - */ - void write( void ) const throw (MEDEXCEPTION); - /*! - Read MESH in the specified file. - */ - void read ( void ) throw (MEDEXCEPTION); - -private: - - GENDRIVER * copy ( void ) const ; - -}; - -/*! - - Driver Med for MESH : Write only. - - Implement write method. - -*/ - -class MEDMEM_EXPORT TYPE_MESH_WRONLY_DRIVER : public virtual TYPE_MESH_DRIVER { - -public : - - /*! - Constructor. - */ - TYPE_MESH_WRONLY_DRIVER() ; - /*! - Constructor. - */ - TYPE_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) ; - /*! - Copy constructor. - */ - TYPE_MESH_WRONLY_DRIVER(const TYPE_MESH_WRONLY_DRIVER & driver) ; - - /*! - Destructor. - */ - virtual ~TYPE_MESH_WRONLY_DRIVER() ; - - /*! - Write MESH in the specified file. - */ - void write( void ) const throw (MEDEXCEPTION); - /*! - Return a MEDEXCEPTION : it is the write-only driver. - */ - void read ( void ) throw (MEDEXCEPTION); - -private: - - GENDRIVER * copy ( void ) const ; -}; - - -/*! - - Driver TYPE for MESH : Read write. - - Use read method from TYPE_MESH_RDONLY_DRIVER - - Use write method from TYPE_MESH_WRONLY_DRIVER - -*/ - -class MEDMEM_EXPORT TYPE_MESH_RDWR_DRIVER : public TYPE_MESH_RDONLY_DRIVER, public TYPE_MESH_WRONLY_DRIVER { - -public : - - /*! - Constructor. - */ - TYPE_MESH_RDWR_DRIVER() ; - /*! - Constructor. - */ - TYPE_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) ; - /*! - Copy constructor. - */ - TYPE_MESH_RDWR_DRIVER(const TYPE_MESH_RDWR_DRIVER & driver) ; - - /*! - Destructor. - */ - ~TYPE_MESH_RDWR_DRIVER() ; - - /*! - Write MESH in the specified file. - */ - void write(void) const throw (MEDEXCEPTION); - /*! - Read MESH in the specified file. - */ - void read (void) throw (MEDEXCEPTION); - -private: - GENDRIVER * copy(void) const ; - -}; -}; - - -#endif /* TYPE_MESH_DRIVER_HXX */ diff --git a/src/MEDMEM/MEDMEM_Unit.cxx b/src/MEDMEM/MEDMEM_Unit.cxx deleted file mode 100644 index beccc3db8..000000000 --- a/src/MEDMEM/MEDMEM_Unit.cxx +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -/* - File MEDMEM_Unit.cxx - $Header$ -*/ - -#include "MEDMEM_Unit.hxx" - -using namespace std; -using namespace MEDMEM; - -UNIT::UNIT():_name(""),_description(""),_masse(0),_length(0),_time(0),_temperature(0),_matterQuantity(0),_currentStrength(0),_lightIntensity(0) { - MESSAGE_MED("UNIT()"); -} - -UNIT::UNIT(string Name, string Description):_name(Name),_description(Description),_masse(0),_length(0),_time(0),_temperature(0),_matterQuantity(0),_currentStrength(0),_lightIntensity(0) { - MESSAGE_MED("UNIT(string Name, string Description)"); -} - -UNIT::~UNIT() { - MESSAGE_MED("~UNIT()") ; -} - -UNIT & UNIT::operator=(const UNIT &unit) { - MESSAGE_MED("UNIT::operateur=") ; - _name=unit._name ; - _description=unit._description ; - _masse=unit._masse ; - _length=unit._length ; - _time=unit._time ; - _temperature=unit._temperature ; - _matterQuantity=unit._matterQuantity ; - _currentStrength=unit._currentStrength ; - _lightIntensity=unit._lightIntensity ; - return *this; -} diff --git a/src/MEDMEM/MEDMEM_Unit.hxx b/src/MEDMEM/MEDMEM_Unit.hxx deleted file mode 100644 index 68d08041d..000000000 --- a/src/MEDMEM/MEDMEM_Unit.hxx +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -/* - File Unit.hxx - $Header$ -*/ - -#ifndef UNIT_HXX -#define UNIT_HXX - -#include <MEDMEM.hxx> - -#include <string> - -#include "MEDMEM_Utilities.hxx" -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_define.hxx" - -namespace MEDMEM { -class MEDMEM_EXPORT UNIT { -protected: - string _name ; - string _description ; - - int _masse ; // kilogram (kg) - int _length ; // meter (m) - int _time ; // second (s) - int _temperature ; // Kelvin (K) - int _matterQuantity ; // mole (mol) - int _currentStrength ; // ampere (A) - int _lightIntensity ; // candela (cd) - - // Unit in IS ! - // Example : - // J = kg.m^2.s^(-2) - // so : Name="Joule",Masse=1,Length=2 and Time=-2, other are null - -public: - UNIT(); - UNIT(string Name, string Description); - ~UNIT(); - UNIT & operator=(const UNIT &unit); - - inline void setName(string Name) ; - inline void setDescription(string Description) ; - inline void setMasse(int Masse) ; - inline void setLength(int Length) ; - inline void setTime(int Time) ; - inline void setTemperature(int Temperature) ; - inline void setMatterQuantity(int MatterQuantity) ; - inline void setCurrentStrength(int CurrentStrength) ; - inline void setLightIntensity(int LightIntensity) ; - - inline string getName() const ; - inline string getDescription() const ; - inline int getMasse() const ; - inline int getLength() const ; - inline int getTime() const ; - inline int getTemperature() const ; - inline int getMatterQuantity() const ; - inline int getCurrentStrength() const ; - inline int getLightIntensity() const ; - -} ; - -// inline method : - -inline void UNIT::setName(string Name) { - _name = Name ; -} -inline void UNIT::setDescription(string Description) { - _description = Description ; -} -inline void UNIT::setMasse(int Masse) { - _masse=Masse ; -} -inline void UNIT::setLength(int Length) { - _length=Length ; -} -inline void UNIT::setTime(int Time) { - _time=Time ; -} -inline void UNIT::setTemperature(int Temperature) { - _temperature=Temperature ; -} -inline void UNIT::setMatterQuantity(int MatterQuantity) { - _matterQuantity=MatterQuantity ; -} -inline void UNIT::setCurrentStrength(int CurrentStrength) { - _currentStrength=CurrentStrength ; -} -inline void UNIT::setLightIntensity(int LightIntensity) { - _lightIntensity=LightIntensity ; -} - -inline string UNIT::getName() const { return _name ; } -inline string UNIT::getDescription() const { return _description ; } -inline int UNIT::getMasse() const { return _masse ; } -inline int UNIT::getLength() const { return _length ; } -inline int UNIT::getTime() const { return _time ; } -inline int UNIT::getTemperature() const { return _temperature ; } -inline int UNIT::getMatterQuantity() const { return _matterQuantity ; } -inline int UNIT::getCurrentStrength() const { return _currentStrength ; } -inline int UNIT::getLightIntensity() const { return _lightIntensity ; } -}//End namespace MEDMEM - -#endif /* UNIT_HXX */ diff --git a/src/MEDMEM/MEDMEM_Utilities.hxx b/src/MEDMEM/MEDMEM_Utilities.hxx deleted file mode 100644 index 40982ab57..000000000 --- a/src/MEDMEM/MEDMEM_Utilities.hxx +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __MEDMEM_UTILITIES -#define __MEDMEM_UTILITIES - -// standart Linux/Unix functions -#include <string> - -#ifndef WIN32 -#include <libgen.h> -#endif - -namespace MEDMEM -{ - inline std::string getBaseName( const std::string& dataname ) - { - std::string aBaseName = ""; -#ifndef WIN32 - aBaseName = basename((char*)dataname.c_str()); -#else - for ( int i = dataname.size()-1; i >= 0; i-- ) { - char aSymb = dataname[i]; - if ( dataname[i] == '\\' || dataname[i] == '/' ) - break; - aBaseName = dataname[i] + aBaseName; - } -#endif - return aBaseName; - } - - inline std::string getDirName(const std::string& dataname ) - { - std::string aDirName = ""; -#ifndef WIN32 - aDirName = dirname((char*)dataname.c_str()); -#else - bool aFindLine = false; - for ( int i = dataname.size()-1; i >= 0; i-- ) { - char aSymb = dataname[i]; - if ( !aFindLine ) - aFindLine = dataname[i] == '\\' || dataname[i] == '/'; - else - aDirName = dataname[i] + aDirName; - } - if ( !aFindLine ) - aDirName = '.'; -#endif - return aDirName; - } - - /*! - * \brief Make a name valid. So far, removes white spaces from name end - */ - inline std::string healName(const std::string& name ) - { - size_t last = name.size()-1; - while ( last >= 0 && ( isspace( name[last] ) || !name[last] )) - last--; - return name.substr( 0, last + 1 ); - } - - /*! - * Change order of bytes for other endianness - */ - inline int swapBytes(const int theValue) - { - return (0 | (( theValue & 0x000000ff ) << 24 ) - | (( theValue & 0x0000ff00 ) << 8 ) - | (( theValue & 0x00ff0000 ) >> 8 ) - | (( theValue >> 24 ) & 0x000000ff ) ); - } -} - -# include <cstdlib> -# include <iostream> -using namespace std; - -/* --- INFOS is always defined (without _DEBUG_): to be used for warnings, with release version --- */ - -# define HEREWEARE_MED {cout<<flush ; cerr << __FILE__ << " [" << __LINE__ << "] : " << flush ;} -# define INFOS_MED(chain) {HEREWEARE_MED ; cerr << chain << endl ;} -# define PYSCRIPT_MED(chain) {cout<<flush ; cerr << "---PYSCRIPT--- " << chain << endl ;} - - -/* --- To print date and time of compilation of current source on stdout --- */ - -# if defined ( __GNUC__ ) -# define COMPILER_MED "g++" ; -# elif defined ( __sun ) -# define COMPILER_MED "CC" ; -# elif defined ( __KCC ) -# define COMPILER_MED "KCC" ; -# elif defined ( __PGI ) -# define COMPILER_MED "pgCC" ; -# else -# define COMPILER_MED "undefined" ; -# endif - -# ifdef INFOS_COMPILATION_MED -# undef INFOS_COMPILATION_MED -# endif -# define INFOS_COMPILATION_MED {\ - cerr << flush;\ - cout << __FILE__ ;\ - cout << " [" << __LINE__ << "] : " ;\ - cout << "COMPILED with " << COMPILER_MED ;\ - cout << ", " << __DATE__ ; \ - cout << " at " << __TIME__ << endl ;\ - cout << "\n\n" ;\ - cout << flush ;\ -} - -#if ( defined(_DEBUG_) || defined(_DEBUG) ) && !defined(_NO_MED_TRACE_) - -/* --- the following MACROS are useful at debug time --- */ - -# define HERE_MED {cout<<flush ; cerr << "- Trace " << __FILE__ << " [" << __LINE__ << "] : " << flush ;} -# define SCRUTE_MED(var) {HERE_MED ; cerr << #var << "=" << var << endl ;} -# define MESSAGE_MED(chain) {HERE_MED ; cerr << chain << endl ;} -# define INTERRUPTION_MED(code) {HERE_MED ; cerr << "INTERRUPTION return code= " << code << endl ; exit(code) ;} - -# ifndef ASSERT_MED -# define ASSERT_MED(condition) if (!(condition)){ HERE_MED ; cerr << "CONDITION " << #condition << " NOT VERIFIED"<< endl ; INTERRUPTION_MED(1) ;} -# endif /* ASSERT_MED */ -#define REPERE_MED {cout<<flush ; cerr << " --------------" << endl << flush ;} -#define __PREFIX_MED const char* __LOC_MED -#define PREFIX_MED __LOC_MED -#define BEGIN_OF_MED(chain) __PREFIX_MED = chain; {REPERE_MED ; HERE_MED ; cerr << "Begin of: " << PREFIX_MED << endl ; REPERE_MED ; } -#define END_OF_MED(chain) {REPERE_MED ; HERE_MED ; cerr << "Normal end of: " << chain << endl ; REPERE_MED ; } - - -# else /* ifdef _DEBUG_*/ - - -# define HERE_MED -# define SCRUTE_MED(var) {} -# define MESSAGE_MED(chain) {} -# define INTERRUPTION_MED(code) {} - -# ifndef ASSERT_MED -# define ASSERT_MED(condition) {} -# endif /* ASSERT */ - -# define REPERE_MED -# define BEGIN_OF_MED(chain) const char* __LOC_MED; {__LOC_MED=chain;} -# define END_OF_MED(chain) const char* __LOC_END_MED; {__LOC_END_MED=chain;} - - -#endif /* ifdef _DEBUG_*/ - -#endif diff --git a/src/MEDMEM/MEDMEM_VtkFieldDriver.hxx b/src/MEDMEM/MEDMEM_VtkFieldDriver.hxx deleted file mode 100644 index 560f84410..000000000 --- a/src/MEDMEM/MEDMEM_VtkFieldDriver.hxx +++ /dev/null @@ -1,510 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef VTK_FIELD_DRIVER_HXX -#define VTK_FIELD_DRIVER_HXX - -#include <string> -#include <fstream> -#include <sstream> - -#include "MEDMEM_define.hxx" - -#include "MEDMEM_GenDriver.hxx" -#include "MEDMEM_Utilities.hxx" - -#include "MEDMEM_STRING.hxx" -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_Unit.hxx" -#include "MEDMEM_nArray.hxx" -#include "MEDMEM_ArrayConvert.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_CellModel.hxx" -#include "MEDMEM_VtkMeshDriver.hxx" - -#ifdef WIN32 -#include <io.h> -#else -#include <unistd.h> -#endif -#include <fcntl.h> - -/*! - - Driver Med for FIELD. - - Generic part : implement open and close methods. - -*/ - -namespace MEDMEM { -template <class T> class VTK_FIELD_DRIVER : public GENDRIVER -{ -protected: - - const FIELD<T> * _ptrField; - std::string _fieldName; - int _fieldNum; - - mutable ofstream * _vtkFile ; - mutable _VTK_BinaryWriter* _binaryFile; - -public : - - /*! - Constructor. - */ - VTK_FIELD_DRIVER():GENDRIVER(VTK_DRIVER), - _ptrField(0), _fieldName(""), _fieldNum(MED_EN::MED_INVALID), - _vtkFile(0), _binaryFile(0) - { - const char * LOC = "VTK_FIELD_DRIVER::VTK_FIELD_DRIVER() "; - BEGIN_OF_MED(LOC); - END_OF_MED(LOC); - } - /*! - Constructor. - */ - template <class INTERLACING_TAG> - VTK_FIELD_DRIVER(const std::string & fileName, - const FIELD<T, INTERLACING_TAG> * ptrField): - GENDRIVER(fileName, MED_EN::WRONLY, VTK_DRIVER), - _ptrField((const FIELD<T> *) ptrField), _fieldName(fileName),_fieldNum(MED_EN::MED_INVALID), - _vtkFile(0), _binaryFile(0) - { - const char* LOC = "VTK_FIELD_DRIVER::VTK_FIELD_DRIVER(const string & fileName, FIELD<T> * ptrField) "; - BEGIN_OF_MED(LOC); - END_OF_MED(LOC); - } - - /*! - Copy constructor. - */ - VTK_FIELD_DRIVER(const VTK_FIELD_DRIVER & fieldDriver): - GENDRIVER(fieldDriver), - _ptrField(fieldDriver._ptrField), - _fieldName(fieldDriver._fieldName), - _fieldNum(fieldDriver._fieldNum), - _vtkFile(0), _binaryFile(0) - { - } - - /*! - Destructor. - */ - ~VTK_FIELD_DRIVER() - { - const char* LOC = "VTK_FIELD_DRIVER::~VTK_FIELD_DRIVER()"; - BEGIN_OF_MED(LOC); - - close(); - - if ( _vtkFile ) delete _vtkFile ; - if ( _binaryFile ) delete _binaryFile; - - _vtkFile = 0; - _binaryFile = 0; - - END_OF_MED(LOC); - } - - void openConst(bool append=false) const throw (MEDEXCEPTION) - { - const char * LOC = "VTK_FIELD_DRIVER::openConst()" ; - BEGIN_OF_MED(LOC); - - if ( _fileName == "" ) - throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) - << "_fileName is |\"\"|, please set a correct fileName before calling open()")); - - if ( DRIVERFACTORY::getVtkBinaryFormatForWriting() ) - { - if ( _vtkFile ) - { - closeConst(); - delete _vtkFile; - _vtkFile = 0; - } - if ( !_binaryFile ) - _binaryFile = new _VTK_BinaryWriter( _fileName ); - else - _binaryFile->close(); - if (!_binaryFile->open(append)) - { - delete _binaryFile; - _binaryFile = 0; - throw MED_EXCEPTION( LOCALIZED( STRING(LOC) << "Could not open file "<< _fileName)); - } - } - else - { - if ( _binaryFile ) - { - _binaryFile->close(); - delete _binaryFile; - _binaryFile = 0; - } - - if (!_vtkFile ) - _vtkFile = new ofstream(); - else - (*_vtkFile).close(); - - if ( append ) - (*_vtkFile).open(_fileName.c_str(), ofstream::out | ofstream::app); - else - (*_vtkFile).open(_fileName.c_str()); - - if (!(*_vtkFile)) - { - delete _vtkFile; - _vtkFile = 0; - throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "Could not open file "<< _fileName)); - } - } - END_OF_MED(LOC); - } - - void openConstAppend() const throw (MEDEXCEPTION) - { - openConst(true); - } - - void open() throw (MEDEXCEPTION) - { - openConst() ; - } - - void openAppend() throw (MEDEXCEPTION) - { - openConst(true) ; - } - - void closeConst() const throw (MEDEXCEPTION) - { - const char * LOC = "VTK_FIELD_DRIVER::closeConst() " ; - BEGIN_OF_MED(LOC); - - if ( _vtkFile ) - { - if ((*_vtkFile).is_open()) - (*_vtkFile).close(); - - if ( (*_vtkFile) && _vtkFile->is_open() ) - throw MED_EXCEPTION( LOCALIZED( STRING(LOC) << "Could not close file "<< _fileName)); - } - if ( _binaryFile ) - { - _binaryFile->close(); - delete _binaryFile; - _binaryFile = 0; - } - - END_OF_MED(LOC); - } - - void close() { - closeConst() ; - } - - /*! - Set the name of the FIELD asked in file. - - It could be different than the name of the FIELD object. - */ - void setFieldName(const string & fieldName) ; - - /*! - Get the name of the FIELD asked in file. - */ - string getFieldName() const ; - - /*! - Return a MEDEXCEPTION : it is the write-only driver. - */ - void read ( void ) throw (MEDEXCEPTION) ; - - /*! - Write FIELD in the specified file, with its mesh through its support - which has to be on all entities (excluding the faces in 3d and edges - in 2d). - */ - void write( void ) const throw (MEDEXCEPTION) ; - - /*! - Write FIELD in the specified file, the mesh is supposed to be - written in this file. The field support has to be on all entities - (excluding the faces in 3d and edges in 2d). - */ - void writeAppend( void ) const throw (MEDEXCEPTION); - -private: - GENDRIVER * copy ( void ) const ; - -}; - - /*-------------------------*/ - /* template implementation */ - /*-------------------------*/ - -/*--------------------- DRIVER PART -------------------------------*/ - -template <class T> void VTK_FIELD_DRIVER<T>::setFieldName(const string & fieldName) -{ - _fieldName = fieldName; -} - -template <class T> string VTK_FIELD_DRIVER<T>::getFieldName() const -{ - return _fieldName; -} - -template <class T> GENDRIVER * VTK_FIELD_DRIVER<T>::copy(void) const -{ - VTK_FIELD_DRIVER<T> * myDriver = new VTK_FIELD_DRIVER<T>(*this); - - return myDriver ; -} - -template <class T> void VTK_FIELD_DRIVER<T>::read (void) - throw (MEDEXCEPTION) -{ - throw MEDEXCEPTION("VTK_FIELD_DRIVER::read : Can't read with a VTK driver because it is write only driver !"); -} - -//================================================================================ -/*! - * \brief Write - */ -//================================================================================ - -template <class T> void VTK_FIELD_DRIVER<T>::write(void) const - throw (MEDEXCEPTION) -{ - const char * LOC = "VTK_FIELD_DRIVER::write(void) const " ; - BEGIN_OF_MED(LOC); - - // we get the Support and its associated Mesh - - const SUPPORT * supportField = _ptrField->getSupport(); - const GMESH * meshField = supportField->getMesh(); - if (! meshField ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": mesh was not read before writing")) ; - - // first, write mesh - { - VTK_MESH_DRIVER meshDriver( _fileName, meshField ); - meshDriver.write(); - } - - // write field - writeAppend(); -} - -//================================================================================ -/*! - * \brief Write append - */ -//================================================================================ - -template <class T> void VTK_FIELD_DRIVER<T>::writeAppend(void) const - throw (MEDEXCEPTION) -{ - const char * LOC = "VTK_FIELD_DRIVER::writeAppend(void) const " ; - BEGIN_OF_MED(LOC); - - // we get the Support and its associated Mesh - - const SUPPORT * supportField = _ptrField->getSupport(); - const GMESH * meshField = supportField->getMesh(); - MED_EN::medEntityMesh entitySupport = supportField->getEntity(); - - if (! meshField ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": mesh was not read before writing")) ; - - if ( _ptrField->getGaussPresence() ) - throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" which use Gauss Points !" << entitySupport)); - - if (!(supportField->isOnAllElements())) - throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" which is not on all entities of the mesh !" << entitySupport)); - - - // Well we must open vtk file first, because there are - // no other driver than MED for VTK that do it ! - openConstAppend() ; - - // first : field on node - // fields is on all node ! - - // second : field on cell - // fields is on all cell ! - - int dt = _ptrField->getIterationNumber(); - int it = _ptrField->getOrderNumber(); - - ostringstream name ; - string nameField = _ptrField->getName(); - name << nameField << "_" << dt << "_" << it ; - - // BEGIN issue 0020610: [CEA 371] VTK field driver : save many fields. - // POINT_DATA and CELL_DATA must encounters once - STRING dataStr; - if (entitySupport == MED_EN::MED_NODE) - dataStr << "POINT_DATA " << meshField->getNumberOfNodes() ; - else if (entitySupport == MED_EN::MED_CELL) - dataStr << "CELL_DATA " << meshField->getNumberOfElements(MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS); - else - throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" which is not on all nodes or cells but it's on !" << entitySupport)); - - // check if dataStr is already present in the file - bool toWriteDataStr = true; -#ifdef WIN32 - int vtkFile = ::_open (_fileName.c_str(), _O_RDONLY|_O_BINARY); -#else - int vtkFile = ::open (_fileName.c_str(), O_RDONLY); -#endif - if ( vtkFile > 0 ) - { -#ifdef WIN32 - ssize_t fileSize = ::_lseek( vtkFile, 0, SEEK_END); ::lseek( vtkFile, 0, SEEK_SET); - char* buf = new char[ fileSize ]; - ::_read (vtkFile, buf, fileSize ); -#else - ssize_t fileSize = ::lseek( vtkFile, 0, SEEK_END); ::lseek( vtkFile, 0, SEEK_SET); - char* buf = new char[ fileSize ]; - ::read (vtkFile, buf, fileSize ); -#endif - char *vtkData = buf, *vtkDataEnd = buf+fileSize-dataStr.size(); - while ( ++vtkData < vtkDataEnd && toWriteDataStr ) - toWriteDataStr = ( strncmp( dataStr.data(), vtkData, dataStr.size()) != 0 ); - delete [] buf; -#ifdef WIN32 - ::_close (vtkFile); -#else - ::close (vtkFile); -#endif - } - std::ostringstream vtkFileStr; // to collect labels - if ( _binaryFile ) - vtkFileStr << endl; - if ( toWriteDataStr ) - vtkFileStr << dataStr << endl; - // END issue 0020610: [CEA 371] VTK field driver : save many fields - - int NomberOfValue = supportField->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS) ; - int NomberOfComponents = _ptrField->getNumberOfComponents() ; - - MED_EN::med_type_champ fieldType = _ptrField->getValueType() ; - - SCRUTE_MED(name.str()); - SCRUTE_MED(fieldType); - - std::string typeStr; - switch (fieldType) - { - case MED_EN::MED_INT32 : - { - typeStr = " int"; break ; - } - case MED_EN::MED_REEL64 : - { - typeStr = " float"; break ; - } - default : - { - throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<< name.str() <<" the type is not int or double !")); - } - } - - if (NomberOfComponents==3) - vtkFileStr << "VECTORS " << name.str() << typeStr << endl ; - else if (NomberOfComponents<=4) - { - vtkFileStr << "SCALARS " << name.str() << typeStr << " " << NomberOfComponents << endl ; - vtkFileStr << "LOOKUP_TABLE default" << endl ; - } - else - throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" there are more than 4 components !")); - - const T * value ; - MEDMEM_Array_ * tmpArray = 0; - if ( _ptrField->getInterlacingType() == MED_EN::MED_FULL_INTERLACE ) - { - value = _ptrField->getValue(); - } - else if ( _ptrField->getInterlacingType() == MED_EN::MED_NO_INTERLACE_BY_TYPE ) - { - MEDMEM_Array_ * ptrArray = _ptrField->getArray(); - MEDMEM_Array<T,NoInterlaceByTypeNoGaussPolicy> * temp = dynamic_cast<MEDMEM_Array<T,NoInterlaceByTypeNoGaussPolicy> * > ( ptrArray ); - MEDMEM_Array<T,NoInterlaceNoGaussPolicy> * array = ArrayConvert2No( *temp ); - tmpArray = array; - value = array->getPtr(); - } - else - { - MEDMEM_Array_ * ptrArray = _ptrField->getArray(); - MEDMEM_Array<T,NoInterlaceNoGaussPolicy> * temp = dynamic_cast<MEDMEM_Array<T,NoInterlaceNoGaussPolicy> * > ( ptrArray ); - MEDMEM_Array<T,FullInterlaceNoGaussPolicy> * array = ArrayConvert( *temp ); - tmpArray = array; - value = array->getPtr(); - } - - if ( _vtkFile ) // ASCII - { - (*_vtkFile) << vtkFileStr.str(); - for (int i=0; i<NomberOfValue; i++) - { - for(int j=0; j<NomberOfComponents; j++) - (*_vtkFile) << value[j*NomberOfValue+i] << " " ; - (*_vtkFile) << endl ; - } - } - else // BINARY - { - std::string str = vtkFileStr.str(); - _binaryFile->write( str.data(), str.size() ); - // Though type "double" is available in VTK but actually it does not work - // (at least paraview shows wrong values) - if ( fieldType == MED_EN::MED_REEL64 ) - { - vector<float> floatValue(NomberOfValue * NomberOfComponents ); - for ( unsigned i = 0; i < floatValue.size(); ++i ) - floatValue[i]=float( value[i] ); - _binaryFile->write( &floatValue[0], NomberOfValue * NomberOfComponents ); - } - else - { - _binaryFile->write( value, NomberOfValue * NomberOfComponents ); - } - } - - if ( _ptrField->getInterlacingType() != MED_EN::MED_FULL_INTERLACE ) - delete tmpArray; - - closeConst(); - - END_OF_MED(LOC); -} -}//End namespace MEDMEM - -#endif /* VTK_FIELD_DRIVER_HXX */ diff --git a/src/MEDMEM/MEDMEM_VtkMedDriver.cxx b/src/MEDMEM/MEDMEM_VtkMedDriver.cxx deleted file mode 100644 index 4efb52c53..000000000 --- a/src/MEDMEM/MEDMEM_VtkMedDriver.cxx +++ /dev/null @@ -1,245 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_VtkMedDriver.hxx" - -#include <sstream> - -#include "MEDMEM_define.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_CellModel.hxx" - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -VTK_MED_DRIVER::VTK_MED_DRIVER(): GENDRIVER(VTK_DRIVER), _fields(0) -{ -} - - -VTK_MED_DRIVER::VTK_MED_DRIVER(const string & fileName, - const vector< const FIELD_* >& fields): - GENDRIVER(fileName, MED_EN::RDWR, VTK_DRIVER), _fields( fields ) -{ -} - -VTK_MED_DRIVER::VTK_MED_DRIVER(const VTK_MED_DRIVER & driver): - GENDRIVER(driver), _fields(driver._fields) -{ -} - -VTK_MED_DRIVER::~VTK_MED_DRIVER() -{ - const char* LOC = "VTK_MED_DRIVER::~VTK_MED_DRIVER()"; - BEGIN_OF_MED(LOC); - - END_OF_MED(LOC); -} - -GENDRIVER * VTK_MED_DRIVER::copy() const -{ - return new VTK_MED_DRIVER(*this) ; -} - -void VTK_MED_DRIVER::openConst() const -{ - const char * LOC ="VTK_MED_DRIVER::open() : "; - BEGIN_OF_MED(LOC); - - if ( _fileName == "" ) - throw MED_EXCEPTION( LOCALIZED( STRING(LOC) - << "_fileName is |\"\"|, please set a correct fileName before calling open()")); - - // check if can open the file - ofstream _vtkFile; - _vtkFile.open(_fileName.c_str()); - if (!_vtkFile) - throw MED_EXCEPTION( LOCALIZED( STRING(LOC) << "Could not open file "<< _fileName)); - - END_OF_MED(LOC); -} - -void VTK_MED_DRIVER::open() { - openConst() ; -} - -void VTK_MED_DRIVER::closeConst() const { - - const char* LOC = "VTK_MED_DRIVER::close() : "; - BEGIN_OF_MED(LOC); - END_OF_MED(LOC); -} - -void VTK_MED_DRIVER::close() { - closeConst() ; -} - - -void VTK_MED_DRIVER::write() const -{ - const char* LOC = "VTK_MED_DRIVER::write() : "; - BEGIN_OF_MED(LOC); - - // VTK supports only one dataset per a file (in Simple Legacy Formats) - // so we write the first mesh only - - const int NumberOfMeshes = ( !_fields.empty() ) ? 1 : 0; - int err_count = 0; - - for (int i=0; i<NumberOfMeshes; i++) - { - const GMESH * myMesh = _fields.at(i)->getSupport()->getMesh(); - writeMesh(myMesh) ; - for (unsigned j=0; j<_fields.size(); j++) - { - const FIELD_ * myField = _fields.at(j); - try - { - if( myMesh == myField->getSupport()->getMesh() ) - { - if (MED_NODE == myField->getSupport()->getEntity()) - { - if (myField->getSupport()->isOnAllElements()) - { - writeField(myField,STRING(myField->getName()) << "_" << myField->getIterationNumber() << "_" << myField->getOrderNumber() ) ; - } - else - { - MESSAGE_MED(PREFIX_MED << "Could not write field "<<myField->getName()<<" which is not on all nodes !"); - } - } - } - } - catch ( MED_EXCEPTION& e ) - { - err_count++; - MESSAGE_MED(PREFIX_MED << "Could not write field "<<myField->getName()<<" : "<<e.what()); - } - } - - // second : field on cell - for (unsigned j=0; j<_fields.size(); j++) - { - const FIELD_ * myField = _fields.at(j); - try - { - if( myMesh == myField->getSupport()->getMesh() ) - { - if (MED_CELL == myField->getSupport()->getEntity()) - { - if (myField->getSupport()->isOnAllElements()) - { - writeField(myField,STRING(myField->getName()) << "_" << myField->getIterationNumber() << "_" << myField->getOrderNumber() ); - } - else - { - MESSAGE_MED(PREFIX_MED << "Could not write field "<<myField->getName()<<" which is not on all cells !"); - } - } - } - } - catch ( MED_EXCEPTION& e ) - { - err_count++; - MESSAGE_MED(PREFIX_MED << "Could not write field "<<myField->getName()<<" : "<<e.what()); - } - } - } // loop on meshes - - if (err_count > 0) - throw MED_EXCEPTION( LOCALIZED( STRING(LOC) << "Some errors have been found during writing !" ) ); - END_OF_MED(LOC); -} - -void VTK_MED_DRIVER::writeMesh(const GMESH * myMesh) const -{ - const char * LOC = "VTK_MED_DRIVER::writeMesh() : "; - BEGIN_OF_MED(LOC); - - VTK_MESH_DRIVER meshDriver( _fileName, myMesh ); - meshDriver.write(); - - END_OF_MED(LOC); -} - -void VTK_MED_DRIVER::writeField(const FIELD_ * myField,string name) const -{ - const char* LOC = "VTK_MED_DRIVER::writeField() : "; - BEGIN_OF_MED(LOC); - - med_type_champ type = myField->getValueType() ; - GENDRIVER* driver = 0; - switch (type) - { - case MED_INT32 : - - if ( myField->getInterlacingType() == MED_FULL_INTERLACE ) - driver = new VTK_FIELD_DRIVER<int>(_fileName, - static_cast< const FIELD<int,FullInterlace>* >(myField)); - - else if ( myField->getInterlacingType() == MED_NO_INTERLACE_BY_TYPE ) - driver = new VTK_FIELD_DRIVER<int>(_fileName, - static_cast< const FIELD<int,NoInterlaceByType>* >(myField)); - - else - driver = new VTK_FIELD_DRIVER<int>(_fileName, - static_cast< const FIELD<int,NoInterlace>* >(myField)); - break; - - case MED_REEL64 : - - if ( myField->getInterlacingType() == MED_FULL_INTERLACE ) - driver = new VTK_FIELD_DRIVER<double>(_fileName, - static_cast< const FIELD<double,FullInterlace>* >(myField)); - - else if ( myField->getInterlacingType() == MED_NO_INTERLACE_BY_TYPE ) - driver = new VTK_FIELD_DRIVER<double>(_fileName, - static_cast< const FIELD<double,NoInterlaceByType>*>(myField)); - - else - driver = new VTK_FIELD_DRIVER<double>(_fileName, - static_cast< const FIELD<double,NoInterlace>* >(myField)); - break; - - default : - { - MESSAGE_MED(PREFIX_MED << "Could not write field "<<name<<" the type is not int or double !"); - } - } - - if ( driver ) - { - driver->writeAppend(); - delete driver; - } - END_OF_MED(LOC); -} - -// void VTK_MED_DRIVER::writeSupport(SUPPORT * mySupport) const { -// const char* LOC = "VTK_MED_DRIVER::writeSupport(SUPPORT *) : "; -// BEGIN_OF_MED(LOC); -// MESSAGE_MED(PREFIX_MED << "Not yet implemented, acting on the object " << *mySupport); -// END_OF_MED(LOC); -// } diff --git a/src/MEDMEM/MEDMEM_VtkMedDriver.hxx b/src/MEDMEM/MEDMEM_VtkMedDriver.hxx deleted file mode 100644 index 222e855fa..000000000 --- a/src/MEDMEM/MEDMEM_VtkMedDriver.hxx +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef VTK_MED_DRIVER_HXX -#define VTK_MED_DRIVER_HXX - -#include "MEDMEM.hxx" - -#include <string> -#include "MEDMEM_STRING.hxx" -#include "MEDMEM_Utilities.hxx" -#include "MEDMEM_Exception.hxx" - -#include "MEDMEM_GenDriver.hxx" - -#include <fstream> -#include <vector> - -using namespace std ; - - -namespace MEDMEM { -class GMESH; -class SUPPORT; -class FIELD_; -class MED; -// This driver pilots within a VTK class read/write accesses of fields/meshes -class MEDMEM_EXPORT VTK_MED_DRIVER : public GENDRIVER -{ -protected: - - const std::vector< const FIELD_* > _fields; - -private: - VTK_MED_DRIVER(); - - void open() ; - void close() ; - void openConst() const ; - void closeConst() const ; - -public : - VTK_MED_DRIVER(const string & fileName, const std::vector< const FIELD_* >& fields); - VTK_MED_DRIVER(const VTK_MED_DRIVER & driver); - ~VTK_MED_DRIVER(); - // OPERATEUR DE RECOPIE AVEC _vtkFile ?? - - //virtual void write ( void ) ; - void write ( void ) const ; - virtual void read ( void ) {} ; - // virtual void writeFrom ( void ) const ; - // virtual void read ( void ) ; - GENDRIVER * copy (void ) const ; - -private : - void writeMesh(const GMESH * myMesh) const ; - void writeField(const FIELD_ * myField, std::string name) const ; -// void writeSupport(SUPPORT * mySupport) const ; - -}; -} - - -#endif /* VTK_MED_DRIVER_HXX */ diff --git a/src/MEDMEM/MEDMEM_VtkMeshDriver.cxx b/src/MEDMEM/MEDMEM_VtkMeshDriver.cxx deleted file mode 100644 index 9d74d54d8..000000000 --- a/src/MEDMEM/MEDMEM_VtkMeshDriver.cxx +++ /dev/null @@ -1,549 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_VtkMeshDriver.hxx" - -#include "MEDMEM_DriversDef.hxx" - -#include "MEDMEM_CellModel.hxx" -#include "MEDMEM_Connectivity.hxx" -#include "MEDMEM_Coordinate.hxx" -#include "MEDMEM_DriverFactory.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Grid.hxx" -#include "MEDMEM_Group.hxx" -#include "MEDMEM_Mesh.hxx" - -#include <fcntl.h> -#include <sstream> - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -VTK_MESH_DRIVER::VTK_MESH_DRIVER(): GENDRIVER(VTK_DRIVER), - _ptrMesh((MESH * const)MED_NULL) -{ - //_vtkFile = new ofstream(); - _vtkFile = 0; - _binaryFile = 0; - // What about _id in Gendriver ? - // _driverType ??? -} - -VTK_MESH_DRIVER::VTK_MESH_DRIVER(const string & fileName, const GMESH * ptrMesh) : - GENDRIVER(fileName, WRONLY, VTK_DRIVER), - _ptrMesh(ptrMesh) -{ - - // Send an exception because a VTK_MESH_DRIVER object cannot be instantied - // from a file and there is no read for that kind of driver - - // throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "This driver is only used to write in VTK format So thie object can not be instantied using a file!")); - - // _ptrMesh->addDriver(*this); // OU RECUPERER L'ID. - MESSAGE_MED("VTK_MESH_DRIVER::VTK_MESH_DRIVER(const string & fileName, MESH * ptrMesh) : " - << "WARNING this driver is only used to write in VTK format So the object can not be instantied using a file!"); - - //_vtkFile = new ofstream(); - _vtkFile = 0; - _binaryFile = 0; -} - -VTK_MESH_DRIVER::VTK_MESH_DRIVER(const VTK_MESH_DRIVER & driver): - GENDRIVER(driver), - _ptrMesh(driver._ptrMesh), - _meshName(driver._meshName) -{ - // next string commented by skl for bug NPAL14840 - //_ptrMesh->addDriver(*this); - //_vtkFile = new ofstream(); - _vtkFile = 0; - _binaryFile = 0; -} - -VTK_MESH_DRIVER::~VTK_MESH_DRIVER() -{ - const char* LOC = "VTK_MESH_DRIVER::~VTK_MESH_DRIVER()"; - BEGIN_OF_MED(LOC); - - close(); - - SCRUTE_MED(_vtkFile); - - if ( _vtkFile ) - delete _vtkFile ; - if ( _binaryFile ) - delete _binaryFile; - - _vtkFile = 0; - _binaryFile = 0; - - SCRUTE_MED(_vtkFile); - - END_OF_MED(LOC); -} - -void VTK_MESH_DRIVER::openConst() const throw (MEDEXCEPTION) -{ - const char * LOC = "VTK_MESH_DRIVER::openConst() " ; - BEGIN_OF_MED(LOC); - - MESSAGE_MED(LOC<<" : _fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode); - - if ( _fileName == "" ) - throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) - << "_fileName is |\"\"|, please set a correct fileName before calling open()")); - - if ( DRIVERFACTORY::getVtkBinaryFormatForWriting() ) - { - if ( _vtkFile ) - { - closeConst(); - delete _vtkFile; - _vtkFile = 0; - } - if ( !_binaryFile ) - { - _binaryFile = new _VTK_BinaryWriter( _fileName ); - if (!_binaryFile->open()) - { - delete _binaryFile; - _binaryFile = 0; - throw MED_EXCEPTION( LOCALIZED( STRING(LOC) << "Could not open file "<< _fileName)); - } - } - } - else - { - if ( _binaryFile ) - { - closeConst(); - delete _binaryFile; - _binaryFile = 0; - } - - if (!_vtkFile ) - _vtkFile = new ofstream(); - if (!(*_vtkFile).is_open()) - (*_vtkFile).open(_fileName.c_str()) ; - - if (!(*_vtkFile)) - { - delete _vtkFile; - _vtkFile = 0; - throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "Could not open file "<< _fileName)); - } - } - END_OF_MED(LOC); -} - -void VTK_MESH_DRIVER::open() { - openConst() ; -} - -void VTK_MESH_DRIVER::closeConst() const throw (MEDEXCEPTION) -{ - const char * LOC = "VTK_MESH_DRIVER::closeConst() " ; - BEGIN_OF_MED(LOC); - - if ( _vtkFile ) - { - if ((*_vtkFile).is_open()) - (*_vtkFile).close(); - - if ( (*_vtkFile) && _vtkFile->is_open() ) - throw MED_EXCEPTION( LOCALIZED( STRING(LOC) << "Could not close file "<< _fileName)); - } - if ( _binaryFile ) - { - _binaryFile->close(); - delete _binaryFile; - ((VTK_MESH_DRIVER*)this)->_binaryFile = 0; - } - END_OF_MED(LOC); -} - -void VTK_MESH_DRIVER::close() { - closeConst() ; -} - -void VTK_MESH_DRIVER::setMeshName(const string & meshName) { _meshName = meshName; } -string VTK_MESH_DRIVER::getMeshName() const { return _meshName; } - -void VTK_MESH_DRIVER::read(void) throw (MEDEXCEPTION) -{ - const char * LOC = "VTK_MESH_DRIVER::read() : " ; - BEGIN_OF_MED(LOC); - - // Send an exception - - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "This driver is only used to write in VTK format !")); - - END_OF_MED(LOC); -} - - -void VTK_MESH_DRIVER::write(void) const - throw (MEDEXCEPTION) -{ - const char * LOC = "void VTK_MESH_DRIVER::write(void) const : "; - BEGIN_OF_MED(LOC); - - if ( !_ptrMesh ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Mesh is NULL")); - - // Well we must open vtk file first, because there are - // no other driver than MED for VTK that do it ! - - int SpaceDimension = _ptrMesh->getSpaceDimension() ; - int NumberOfNodes = _ptrMesh->getNumberOfNodes() ; - if ( SpaceDimension < 1 ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Mesh is empty")); - - openConst(); - - const MESH* mesh = _ptrMesh->convertInMESH(); - char buf[256]; - const char* header = "# vtk DataFile Version 2.0\n"; - const char* title = "maillage from MedMemory\n"; - const char* dataset = "DATASET UNSTRUCTURED_GRID\n"; - if ( _vtkFile ) // ASCII - { - (*_vtkFile) << header ; - (*_vtkFile) << title ; - (*_vtkFile) << "ASCII" << endl ; - (*_vtkFile) << dataset ; - // put points (all point are in 3D, so if we are in 1D or 2D, we complete by zero ! - (*_vtkFile) << "POINTS " << NumberOfNodes << " float" << endl ; - const double *coordinate = mesh->getCoordinates(MED_FULL_INTERLACE) ; - string missingCoord = SpaceDimension==3 ? "" : SpaceDimension==2 ? "0" : "0 0"; - for (int i=0;i<NumberOfNodes;i++) - { - for (int j=0;j<SpaceDimension;j++) - (*_vtkFile) << coordinate[i*SpaceDimension+j] << " "; - (*_vtkFile) << missingCoord << endl; - } - } - else // BINARY - { - const char* format = "BINARY\n"; - writeBinary( header, strlen(header) ); - writeBinary( title, strlen(title) ); - writeBinary( format, strlen(format) ); - writeBinary( dataset, strlen(dataset) ); - - // put points (all point are in 3D, so if we are in 1D or 2D, we complete by zero ! - //sprintf(buf,"POINTS %d double\n", NumberOfNodes); - sprintf(buf,"POINTS %d float\n", NumberOfNodes); - writeBinary( buf, strlen(buf) ); - const double *coordinate = mesh->getCoordinates(MED_FULL_INTERLACE) ; - //PointerOf<double> coordBuf( SpaceDimension==3 ? 0 : NumberOfNodes * 3 ); - //double * toCoord = coordBuf; - PointerOf<float> coordBuf( NumberOfNodes * 3 ); - float * toCoord = coordBuf; - switch( SpaceDimension ) - { - case 3: - for (int i=0;i<NumberOfNodes;i++) - { - *toCoord++ = (float)*coordinate++; - *toCoord++ = (float)*coordinate++; - *toCoord++ = (float)*coordinate++; - } - break; - case 2: - for (int i=0;i<NumberOfNodes;i++) - { - *toCoord++ = (float)*coordinate++; - *toCoord++ = (float)*coordinate++; - *toCoord++ = 0; - } - break; - case 1: - for (int i=0;i<NumberOfNodes;i++) - { - *toCoord++ = (float)*coordinate++; - *toCoord++ = 0; - *toCoord++ = 0; - } - break; -// coordBuf.set( coordinate ); -// break; -// case 2: -// for (int i=0;i<NumberOfNodes;i++) -// { -// *toCoord++ = *coordinate++; -// *toCoord++ = *coordinate++; -// *toCoord++ = 0; -// } -// break; -// case 1: -// for (int i=0;i<NumberOfNodes;i++) -// { -// *toCoord++ = *coordinate++; -// *toCoord++ = 0; -// *toCoord++ = 0; -// } -// break; - } - //writeBinary( (double*) coordBuf, NumberOfNodes * 3 ); - writeBinary( (float*) coordBuf, NumberOfNodes * 3 ); - } - - // we put connectivity - // how many cells and how many value in connectivity : - int cells_types_count = mesh->getNumberOfTypes(MED_CELL) ; - int cells_sum = mesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) ; - const CELLMODEL * cells_type = mesh->getCellsTypes(MED_CELL) ; - - const int * connectivityIndex = mesh->getConnectivityIndex(MED_NODAL,MED_CELL) ; - int connectivity_sum = connectivityIndex[cells_sum]-1 ; - - sprintf(buf,"\nCELLS %d %d\n", cells_sum, connectivity_sum+cells_sum); - if ( _vtkFile ) - (*_vtkFile) << buf ; - else - writeBinary( buf, strlen(buf) ); - - for (int i=0;i<cells_types_count;i++) { - int *filter = (int*) NULL ; // index in vtk connectivity - switch (cells_type[i].getType()) - { - case MED_POINT1 : { - filter = new int[1] ; - filter[0] = 0 ; - break ; - } - case MED_SEG2 : { - filter = new int[2] ; - filter[0] = 0 ; - filter[1] = 1 ; - break ; - } - case MED_SEG3 : { - break ; - } - case MED_TRIA3 : { - filter = new int[3] ; - filter[0] = 0 ; - filter[1] = 1 ; - filter[2] = 2 ; - break ; - } - case MED_QUAD4 : { - filter = new int[4] ; - filter[0] = 0 ; - filter[1] = 1 ; - filter[2] = 2 ; - filter[3] = 3 ; - break ; - } - case MED_TRIA6 : { - break ; - } - case MED_QUAD8 : { - break ; - } - case MED_TETRA4 : { - filter = new int[4] ; - filter[0] = 0 ; - filter[1] = 1 ; - filter[2] = 3 ; // 3td element in med are 4th in vtk (array begin at 0 !) - filter[3] = 2 ; // 4th element in med are 3rd in vtk (array begin at 0 !) - break ; - } - case MED_PYRA5 : { - filter = new int[5] ; - filter[0] = 0 ; - filter[1] = 3 ; // 2nd element in med are 4th in vtk (array begin at 0 !) - filter[2] = 2 ; - filter[3] = 1 ; // 4th element in med are 2nd in vtk (array begin at 0 !) - filter[4] = 4 ; - break ; - } - case MED_PENTA6 : { - filter = new int[6] ; - filter[0] = 0 ; - filter[1] = 1 ; - filter[2] = 2 ; - filter[3] = 3 ; - filter[4] = 4 ; - filter[5] = 5 ; - break ; - } - case MED_HEXA8 : { - filter = new int[8] ; - filter[0] = 0 ; - filter[1] = 3 ; - filter[2] = 2 ; - filter[3] = 1 ; - filter[4] = 4 ; - filter[5] = 7 ; - filter[6] = 6 ; - filter[7] = 5 ; - break ; - } - case MED_TETRA10 : { - break ; - } - case MED_PYRA13 : { - break ; - } - case MED_PENTA15 : { - break ; - } - case MED_HEXA20 : { - break ; - } - default : { - break ; - } - } - if (filter==NULL) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": MED element type not supported yet : " << cells_type[i].getName() ) ) ; - int nodes_cell = cells_type[i].getNumberOfNodes(); - int numberOfCell = mesh->getNumberOfElements(MED_CELL,cells_type[i].getType()) ; - const int * connectivityArray = mesh->getConnectivity(MED_NODAL,MED_CELL,cells_type[i].getType()); - if ( _vtkFile ) - { - for (int j=0;j<numberOfCell;j++) - { - (*_vtkFile) << nodes_cell << " " ; - for (int k=0;k<nodes_cell;k++) - (*_vtkFile) << connectivityArray[j*nodes_cell+filter[k]] - 1 << " " ; - (*_vtkFile) << endl ; - } - } - else // BINARY - { - int dataSize = numberOfCell * ( nodes_cell+1 ); - PointerOf<int> cellData( dataSize ); - for (int *pCellData = cellData, j = 0; j < numberOfCell; j++) - { - *pCellData++ = nodes_cell; - for (int k=0;k<nodes_cell;k++) - *pCellData++ = connectivityArray[j*nodes_cell+filter[k]] - 1; - } - writeBinary( (int*) cellData, dataSize ); - } - if (filter != NULL) - delete[] filter ; - } - sprintf(buf,"\nCELL_TYPES %d\n", cells_sum); - if ( _vtkFile ) - (*_vtkFile) << buf ; - else - writeBinary( buf, strlen(buf) ); - - for (int i=0;i<cells_types_count;i++) { - int vtkType = 0 ; - switch (cells_type[i].getType()) - { - case MED_POINT1 :vtkType = 1 ;break ; - case MED_SEG2 :vtkType = 3 ;break ; - case MED_SEG3 :vtkType = 0 ;break ; - case MED_TRIA3 :vtkType = 5 ;break ; - case MED_QUAD4 :vtkType = 9 ;break ; - case MED_TRIA6 :vtkType = 0 ;break ; - case MED_QUAD8 :vtkType = 0 ;break ; - case MED_TETRA4 :vtkType = 10 ;break ; - case MED_PYRA5 :vtkType = 14 ;break ; - case MED_PENTA6 :vtkType = 13 ;break ; - case MED_HEXA8 :vtkType = 12 ;break ; - case MED_TETRA10 :vtkType = 0 ;break ; - case MED_PYRA13 :vtkType = 0 ;break ; - case MED_PENTA15 :vtkType = 0 ;break ; - case MED_HEXA20 :vtkType = 0 ;break ; - default :vtkType = 0 ;break ; - } - if (vtkType == 0) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": MED element type not supported yet : " << cells_type[i].getType() ) ) ; - int numberOfCell = mesh->getNumberOfElements(MED_CELL,cells_type[i].getType()) ; - if ( _vtkFile ) - { - for (int j=0;j<numberOfCell;j++) - (*_vtkFile) << vtkType << endl ; - } - else - { - vector< int > type( numberOfCell, vtkType ); - writeBinary( &type[0], type.size() ); - } - } - mesh->removeReference(); - - closeConst(); - - END_OF_MED(LOC); -} - -GENDRIVER * VTK_MESH_DRIVER::copy(void) const -{ - return new VTK_MESH_DRIVER(*this); -} - -////////////////////////////////////////////////////////////////////////////////////////// -// _VTK_BinaryWriter -////////////////////////////////////////////////////////////////////////////////////////// - -_VTK_BinaryWriter::_VTK_BinaryWriter(const std::string file):_fileName(file),_binaryFile(0) -{ -} - -bool _VTK_BinaryWriter::open(bool append) const -{ - if ( !_binaryFile ) - { - // workaround to create file with good access rights - if ( !append ) - fstream(_fileName.c_str(), ios_base::out); - - // opening - _VTK_BinaryWriter* mutableMe =(_VTK_BinaryWriter*) this; - int append_flag = 0; -#ifdef WIN32 - if ( append ) append_flag = _O_APPEND; - mutableMe->_binaryFile = ::_open (_fileName.c_str(), _O_WRONLY|_O_BINARY|append_flag); -#else - if ( append ) append_flag = O_APPEND; - mutableMe->_binaryFile = ::open (_fileName.c_str(), O_WRONLY|append_flag); -#endif - if (_binaryFile < 0) - mutableMe->_binaryFile = 0; - } - return _binaryFile; -} - -bool _VTK_BinaryWriter::close() const -{ - if ( _binaryFile ) - { -#ifdef WIN32 - ::_close (_binaryFile); -#else - ::close (_binaryFile); -#endif - ((_VTK_BinaryWriter*)this)->_binaryFile = 0; - } - return true; -} diff --git a/src/MEDMEM/MEDMEM_VtkMeshDriver.hxx b/src/MEDMEM/MEDMEM_VtkMeshDriver.hxx deleted file mode 100644 index fe69a70e2..000000000 --- a/src/MEDMEM/MEDMEM_VtkMeshDriver.hxx +++ /dev/null @@ -1,167 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef VTK_MESH_DRIVER_HXX -#define VTK_MESH_DRIVER_HXX - -#include <cstring> - -#include "MEDMEM.hxx" - -#include <string> -#include <vector> -#include "MEDMEM_define.hxx" -#include "MEDMEM_GenDriver.hxx" - -#include "MEDMEM_STRING.hxx" -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_Utilities.hxx" - -#include <fstream> - -#ifndef WIN32 -# include <unistd.h> -#endif - - -/*! - - Driver Vtk for MESH (only for writing). - - Generic part : implement open and close methods. - -*/ -namespace MEDMEM { -class GMESH; -class FAMILY; -class GROUP; -class CONNECTIVITY; -class MEDMEM_EXPORT _VTK_BinaryWriter; - -class MEDMEM_EXPORT VTK_MESH_DRIVER : public GENDRIVER -{ -protected: - - const GMESH * _ptrMesh; - std::string _meshName; - mutable std::ofstream * _vtkFile ; // The _vtkFile used to write Meshes to _filename - mutable _VTK_BinaryWriter* _binaryFile; - -public : - - /*! - Constructor. - */ - VTK_MESH_DRIVER() ; - /*! - Constructor. - */ - VTK_MESH_DRIVER(const std::string & fileName, const GMESH * ptrMesh) ; - /*! - Copy constructor. - */ - VTK_MESH_DRIVER(const VTK_MESH_DRIVER & driver) ; - - /*! - Destructor. - */ - ~VTK_MESH_DRIVER() ; - - void open() ; - void close() ; - - void openConst() const throw (MEDEXCEPTION); - void closeConst() const throw (MEDEXCEPTION); - - void write( void ) const throw (MEDEXCEPTION) ; - void read ( void ) throw (MEDEXCEPTION) ; - - /*! - Set the name of the MESH asked in file. - - It could be different than the name of the MESH object. - */ - void setMeshName(const string & meshName) ; - /*! - Get the name of the MESH asked in file. - */ - string getMeshName() const ; - -private: - GENDRIVER * copy ( void ) const; - - template <typename T> - void writeBinary(const T* data, int nbValues) const throw (MEDEXCEPTION); -}; - -class MEDMEM_EXPORT _VTK_BinaryWriter -{ - std::string _fileName; - int _binaryFile; -public: - _VTK_BinaryWriter(const std::string file); - bool open(bool append=false) const; - bool close() const; - - template <typename T> - void write(const T* data, int nbValues) const throw (MEDEXCEPTION) - { - // DEBUG -// if ( sizeof(T) == sizeof(char)) -// cout << data ; -// else -// for ( int i=0; i < nbValues;++i ) -// cout << data[i] << " "; - const void* toWrite = (const void* ) data; - T* swappedData = 0; - if ( sizeof(T) != sizeof(char)) - { - // inverse bytes - toWrite = (const void* )( swappedData = new T[ nbValues ]); - memcpy( swappedData, data, nbValues * sizeof(T)); - int* intBuf = ((int*) swappedData) - 1; - int* bufEnd = (int*)((char*) swappedData + nbValues * sizeof(T)); - while ( ++intBuf < bufEnd ) - *intBuf = swapBytes( *intBuf ); - } -#ifdef WIN32 - ssize_t nbWritten = ::_write( _binaryFile, toWrite, nbValues * sizeof(T)); -#else - ssize_t nbWritten = ::write( _binaryFile, toWrite, nbValues * sizeof(T)); -#endif - if ( swappedData ) - delete [] swappedData; - if ( nbWritten < 0 ) - throw MEDEXCEPTION(LOCALIZED(STRING("_VTK_BinaryWriter::Failed to write into ")<< _fileName)); - } -}; - -template <typename T> -void VTK_MESH_DRIVER::writeBinary(const T* data, int nbValues) const throw (MEDEXCEPTION) -{ - _binaryFile->write( data, nbValues ); -} - -} - - -#endif /* VTK_MESH_DRIVER_HXX */ diff --git a/src/MEDMEM/MEDMEM_define.hxx b/src/MEDMEM/MEDMEM_define.hxx deleted file mode 100644 index 24062c79c..000000000 --- a/src/MEDMEM/MEDMEM_define.hxx +++ /dev/null @@ -1,353 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef DEFINE_HXX -#define DEFINE_HXX - -#include <stdio.h> -#include <iostream> -#include <string> -#include <assert.h> - -// UTILE AUX DEUX NAMESPACES -#include <hdf5.h> - -namespace med_2_3 { - extern "C" { - #include <med.h> - med_err MEDfieldComputingStepInfo(const med_idt fid, - const char * const fieldname, - const int csit, - med_int * const numdt, - med_int * const numit, - med_float * const dt); - - med_err MEDmeshEntityFamilyNumberRd(const med_idt fid, - const char* const meshname, - const med_int numdt, - const med_int numit, - const med_entity_type entitype, - const med_geometry_type geotype, - med_int * const number); - - med_err MEDmeshEntityNumberRd(const med_idt fid, - const char* const meshname, - const med_int numdt, - const med_int numit, - const med_entity_type entitype, - const med_geometry_type geotype, - med_int * const number); - - med_err MEDfieldCr( const med_idt fid, - const char * const fieldname, - const med_field_type fieldtype, - const med_int nbofcomponent, - const char * const componentname, - const char * const componentunit, - const char * const dtunit, - const char * const meshname); - } -} - -namespace MED_EN { - extern "C" { // on est la - -// #define MED_NULL (void *) NULL -// #define MED_MAX_PARA 20 - -// #define MED_TAILLE_DESC 200 -// #define MED_TAILLE_IDENT 8 -// #define MED_TAILLE_NOM 32 -// #define MED_TAILLE_LNOM 80 -// #define MED_TAILLE_PNOM 8 - -#ifdef MED_NONE -#undef MED_NONE -#endif -#ifdef MED_POINT1 -#undef MED_POINT1 -#endif -#ifdef MED_SEG2 -#undef MED_SEG2 -#endif -#ifdef MED_SEG3 -#undef MED_SEG3 -#endif -#ifdef MED_TRIA3 -#undef MED_TRIA3 -#endif -#ifdef MED_QUAD4 -#undef MED_QUAD4 -#endif -#ifdef MED_TRIA6 -#undef MED_TRIA6 -#endif -#ifdef MED_QUAD8 -#undef MED_QUAD8 -#endif -#ifdef MED_TETRA4 -#undef MED_TETRA4 -#endif -#ifdef MED_PYRA5 -#undef MED_PYRA5 -#endif -#ifdef MED_PENTA6 -#undef MED_PENTA6 -#endif -#ifdef MED_HEXA8 -#undef MED_HEXA8 -#endif -#ifdef MED_TETRA10 -#undef MED_TETRA10 -#endif -#ifdef MED_PYRA13 -#undef MED_PYRA13 -#endif -#ifdef MED_PENTA15 -#undef MED_PENTA15 -#endif -#ifdef MED_HEXA20 -#undef MED_HEXA20 -#endif -#ifdef MED_POLYGON -#undef MED_POLYGON -#endif -#ifdef MED_POLYHEDRA -#undef MED_POLYHEDRA -#endif -#ifdef MED_ALL_ELEMENTS -#undef MED_ALL_ELEMENTS -#endif - - typedef long medGeometryElement; - const medGeometryElement MED_NONE = 0; - const medGeometryElement MED_POINT1 = 1; - const medGeometryElement MED_SEG2 = 102; - const medGeometryElement MED_SEG3 = 103; - const medGeometryElement MED_TRIA3 = 203; - const medGeometryElement MED_QUAD4 = 204; - const medGeometryElement MED_TRIA6 = 206; - const medGeometryElement MED_QUAD8 = 208; - const medGeometryElement MED_TETRA4 = 304; - const medGeometryElement MED_PYRA5 = 305; - const medGeometryElement MED_PENTA6 = 306; - const medGeometryElement MED_HEXA8 = 308; - const medGeometryElement MED_TETRA10 = 310; - const medGeometryElement MED_PYRA13 = 313; - const medGeometryElement MED_PENTA15 = 315; - const medGeometryElement MED_HEXA20 = 320; - const medGeometryElement MED_POLYGON = 400; - const medGeometryElement MED_POLYHEDRA = 500; - const medGeometryElement MED_ALL_ELEMENTS = 999; - - typedef long medEntityMesh; - const medEntityMesh MED_CELL = 0; - const medEntityMesh MED_FACE = 1; - const medEntityMesh MED_EDGE = 2; - const medEntityMesh MED_NODE = 3; - const medEntityMesh MED_ALL_ENTITIES = 4; - - typedef long medModeSwitch; - const medModeSwitch MED_FULL_INTERLACE = 0; - const medModeSwitch MED_NO_INTERLACE = 1; - const medModeSwitch MED_NO_INTERLACE_BY_TYPE = 2; - const medModeSwitch MED_UNDEFINED_INTERLACE = 3; - - typedef long medConnectivity; - const medConnectivity MED_NODAL = 0; - const medConnectivity MED_DESCENDING = 1; - - typedef enum {MED_CARTESIAN, MED_POLAR, MED_BODY_FITTED} med_grid_type; - - //typedef enum {MED_LECT,MED_ECRI,MED_REMP,MED_CREA} med_mode_acces; - typedef enum {RDONLY,WRONLY,RDWR} med_mode_acces; - - typedef enum {ASCENDING=7,DESCENDING=77} med_sort_direc; - - typedef enum {MED_REEL64=6, MED_INT32=24,MED_INT64=26, MED_UNDEFINED_TYPE=0} med_type_champ; - -// #define MED_NBR_GEOMETRIE_MAILLE 15 -// #define MED_NBR_GEOMETRIE_FACE 4 -// #define MED_NBR_GEOMETRIE_ARETE 2 - -typedef enum {MED_CART, MED_CYL, MED_SPHER} med_repere; - -typedef enum {MED_FAUX, MED_VRAI} med_booleen ; - -typedef enum {MED_GROUPE, MED_ATTR, MED_FAMILLE} med_dim_famille; - -typedef enum {MED_COMP, MED_DTYPE} med_dim_champ; - -typedef enum {MED_HDF_VERSION, MED_VERSION, MED_FICH_DES} med_fich_info; - -// #define MED_NOPG 1 /* -> pas de point de Gauss */ -// #define MED_NOPFL "" /* -> pas de profils utilisateur */ -// #define MED_NOPFLi " " /* Variable Interne */ -// #define MED_NOPF 0 /* -> pas de profils pour _MEDdataseNnumEcrire */ -// #define MED_NOPDT -1 /* rem: pas de pas de temps negatifs */ -// #define MED_NONOR -1 /* rem: pas de n°ordre negatif */ -// #define MED_DIM1 1 /* PAS */ -// //#define MED_ALL 0 !!!!! NB: WARNING MED_ALL deja utilise dans l'enum medGeometryElement !!!!!!!! -// #define MED_ALL 0 - -#if defined(SUN4SOL2) || defined(PCLINUX) || defined(PCLINUX64_32) || defined(OSF1_32) || defined(IRIX64_32) || defined(RS6000) -/* interface C/FORTRAN */ -/* this true only with g77 and gcc : we must change it to use directly NOMF_... and INT32 or INT64 - it will be more simple to understand and to use ! */ -// #define NOMF_POST_UNDERSCORE - -/* correspondance des types avec HDF 5 */ -typedef hsize_t med_size; -typedef hssize_t med_ssize; - //typedef hid_t med_idt; -typedef herr_t med_err; - -/* types elementaires */ -typedef int med_int; -typedef double med_float; -#endif - -#if defined(HP9000) -/* correspondance des types avec HDF 5 */ -typedef hsize_t med_size; -typedef hssize_t med_ssize; - //typedef hid_t med_idt; -typedef herr_t med_err; - -/* types elementaires */ -typedef int med_int; -typedef double med_float; -#endif - -#if defined(IRIX64) || defined(OSF1) || defined(VPP5000) || defined(PCLINUX64) -// #define NOMF_POST_UNDERSCORE - -/* correspondance des types avec HDF 5 */ -typedef hsize_t med_size; -typedef hssize_t med_ssize; - //typedef hid_t med_idt; -typedef herr_t med_err; - -/* types elementaires */ -typedef long med_int; -typedef double med_float; -#endif - - -#if defined(PPRO_NT) -/* correspondance des types avec HDF 5 */ -typedef hsize_t med_size; -typedef hssize_t med_ssize; - //typedef hid_t med_idt; -typedef herr_t med_err; - -/* types elementaires */ -typedef int med_int; -typedef double med_float; -#endif - - -// #if defined(NOMF_PRE_UNDERSCORE) && defined(NOMF_POST_UNDERSCORE) -// # define NOMF(x) _##x##_ -// #endif -// #if defined(NOMF_PRE_UNDERSCORE) && !defined(NOMF_POST_UNDERSCORE) -// # define NOMF(x) _##x -// #endif -// #if !defined(NOMF_PRE_UNDERSCORE) && defined(NOMF_POST_UNDERSCORE) -// # define NOMF(x) x##_ -// #endif -// #if !defined(NOMF_PRE_UNDERSCORE) && !defined(NOMF_POST_UNDERSCORE) -// # define NOMF(x) x -// #endif - - //#include "med_proto.h" - - } - - // valeurs des algos de connexites - const int FRACT_ALGO = 10; - const int MAX_LOOP = 200; -// fin - -// Valeurs de IO_MED -//#define READ 0 -//#define WRITE 1 - - - const int MED_CLOSED = 0; - const int MED_OPENED = 1; - const int MED_INVALID = -1; - const int MED_ERROR = -1; - const int MED_VALID = 0; -//#define MED_NULL NULL - -//#define MED_RDONLY RDONLY -//// rem: MED_WRONLY=MED_ECR n'empêche malheureusement pas de lire le fichier -//// mais permet de conserver l'existant. Attention à la création d'objet -//// ne prenant pas de paramètre de type mode d'accès il faut tester si il -//// est déjà présent dans le fichier. Si MED_WRONLY=MED_REMP le fichier est -//// réinitialisé. Cf une évolution de MED. -//#define MED_WRONLY WRONLY -//#define MED_RDWR RDWR -//#define MED_CREATE MED_CREA -// Fin - - const int longueur_string = 100; - const double PRECISION = 0.0000001; - const int MED_UNDEFINED = -1; - -// type des connectivites -//#define CONN_NOD 0 -//#define CONN_DESC_PART 1 -//#define CONN_DESC_TOT 2 - -// valeurs de type_interpolation - const int P1 = 0; - const int pseudo_P2 = 1; - const int trilineaire = 2; - const int P2_adapte = 3; - const int VF_conservatif = 4; - const int VF_non_conservatif = 5; - // valeurs de type_mapping - const int connexite = 0; - const int conn_octree = 1; - const int brutal = 2; -// valeurs des type_support - const int support_noeud = 0; - const int support_maille = 1; -// retour des fonctions - //const int OK = 0; - //const int KO = 1; - -//maximum number of groups handled by the Family Group converter - const int MAX_NB_GROUP = 100000; - /* - enum definition for the used Med File version V2.1 or V2.2 - because of incompatibility between them. - */ - - typedef enum {V21 = 26, V22 = 75} medFileVersion; - -// fin -} -// End Of NameSpace MED_EN - -#endif /* DEFINE_HXX */ diff --git a/src/MEDMEM/MEDMEM_nArray.hxx b/src/MEDMEM/MEDMEM_nArray.hxx deleted file mode 100644 index 8f3e38552..000000000 --- a/src/MEDMEM/MEDMEM_nArray.hxx +++ /dev/null @@ -1,404 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef MEDMEM_ARRAY_HXX -#define MEDMEM_ARRAY_HXX - -#include "MEDMEM.hxx" - -#include "MEDMEM_InterlacingPolicy.hxx" -#include "MEDMEM_IndexCheckingPolicy.hxx" - -#include "MEDMEM_PointerOf.hxx" -#include "MEDMEM_define.hxx" - -namespace MEDMEM { - -class MEDMEM_EXPORT MEDMEM_Array_ { -public: - //virtual void dummy() {}; - virtual bool getGaussPresence() const { return false; } - virtual MED_EN::medModeSwitch getInterlacingType() const {return MED_EN::MED_UNDEFINED_INTERLACE;} - virtual ~MEDMEM_Array_() {}; //Indispensable pour détruire le vrai objet pointé -}; - -template < class ARRAY_ELEMENT_TYPE, - class INTERLACING_POLICY=FullInterlaceNoGaussPolicy, - class CHECKING_POLICY=IndexCheckPolicy > -class MEDMEM_Array : public INTERLACING_POLICY, public CHECKING_POLICY, public MEDMEM_Array_ { - -public : - - typedef ARRAY_ELEMENT_TYPE ElementType; - typedef INTERLACING_POLICY InterlacingPolicy; - typedef CHECKING_POLICY CheckingPolicy; - -public : - MEDMEM_Array():_array( ( ElementType *) NULL) {}; //Interdit le constructeur par défaut, peut pas à cause du FIELD - - ~MEDMEM_Array() { - // PointerOf s'occupe de la desallocation. - }; - - // Le mot clé inline permettra d'instancier le constructeur uniquement - // s'il est appelé ( ...NoGaussPolicy) - // Rem : Le constructeur de la policy demandée est appelé - inline MEDMEM_Array(int dim, int nbelem) : InterlacingPolicy(nbelem,dim) - { - CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",nbelem); - CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",dim); - _array.set(InterlacingPolicy::_arraySize); - }; - - // Le mot clé inline permettra d'instancier le constructeur uniquement - // s'il est appelé NoInterlaceByTypeNoGaussPolicy(...) - // Rem : Le constructeur de la policy demandée est appelé - inline MEDMEM_Array(int dim, int nbelem, - int nbtypegeo, const int * const nbelgeoc) - : InterlacingPolicy(nbelem, dim, nbtypegeo, nbelgeoc) - { - CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",nbelem); - CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",dim); - _array.set(InterlacingPolicy::_arraySize); - }; - - // Le mot clé inline permettra d'instancier le constructeur uniquement - // s'il est appelé ( ...NoGaussPolicy) - // Rem : Le constructeur de la policy demandée est appelé - inline MEDMEM_Array( ElementType * values, int dim, int nbelem, - bool shallowCopy=false, - bool ownershipOfValues=false) : InterlacingPolicy(nbelem,dim) - { - CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",nbelem); - CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",dim); - if(shallowCopy) - - if(ownershipOfValues) - _array.setShallowAndOwnership((const ElementType *)values); - else - _array.set((const ElementType*)values); - - else // Cas par défaut - _array.set(InterlacingPolicy::_arraySize,values); - - } - - // Le mot clé inline permettra d'instancier le constructeur uniquement - // s'il est appelé NoInterlaceByTypeNoGaussPolicy(...) - // Rem : Le constructeur de la policy demandée est appelé - inline MEDMEM_Array( ElementType * values, int dim, int nbelem, - int nbtypegeo, const int * const nbelgeoc, - bool shallowCopy=false, - bool ownershipOfValues=false) - : InterlacingPolicy(nbelem, dim, nbtypegeo, nbelgeoc) - { - CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",nbelem); - CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",dim); - if(shallowCopy) - - if(ownershipOfValues) - _array.setShallowAndOwnership((const ElementType *)values); - else - _array.set((const ElementType*)values); - - else // Cas par défaut - _array.set(InterlacingPolicy::_arraySize,values); - - } - - // Le mot clé inline permettra d'instancier le constructeur uniquement - // s'il est appelé ( ...GaussPolicy) - // Rem : Le constructeur de la policy demandée est appelé - inline MEDMEM_Array(int dim, int nbelem, int nbtypegeo, - const int * const nbelgeoc, const int * const nbgaussgeo) - : InterlacingPolicy(nbelem, dim, nbtypegeo, nbelgeoc, nbgaussgeo) - { - CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",nbelem); - CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",dim); - CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",nbtypegeo); - _array.set(InterlacingPolicy::_arraySize); - }; - - - // Le mot clé inline permettra d'instancier le constructeur uniquement - // s'il est appelé ( ...GaussPolicy) - // Rem : Le constructeur de la policy demandée est appelé - inline MEDMEM_Array(ElementType * values, int dim, int nbelem, int nbtypegeo, - const int * const nbelgeoc, const int * const nbgaussgeo, - bool shallowCopy=false, - bool ownershipOfValues=false) - : InterlacingPolicy(nbelem, dim, nbtypegeo, nbelgeoc, nbgaussgeo) - { - CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",nbelem); - CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",dim); - CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",nbtypegeo); - - if(shallowCopy) - - if(ownershipOfValues) - _array.setShallowAndOwnership((const ElementType *)values); - else - _array.set((const ElementType*)values); - - else - _array.set(InterlacingPolicy::_arraySize,values); - - }; - - // Constructeur de recopie pour un MEDMEM_Array avec les mêmes - // paramètres template qu'à la construction - inline MEDMEM_Array(const MEDMEM_Array & array, bool shallowCopy=false) - :InterlacingPolicy(array,shallowCopy) - { - if (shallowCopy) - this->_array.set(array._array); // Le propriétaire reste le ARRAY initial - else - this->_array.set(InterlacingPolicy::_arraySize,array._array); - } - - - // L'utilisation d'une copie superficielle pour l'opérateur d'affectation - // ne me parait pas être une bonne ideé : Compatibilité ancienne version MEDARRAY? - inline MEDMEM_Array<ElementType,InterlacingPolicy,CheckingPolicy> & - operator=( const MEDMEM_Array & array) { - if ( this == &array) return *this; - const char* LOC = "MEDMEM_Array operator ="; - BEGIN_OF_MED(LOC); - InterlacingPolicy::operator=(array); //Appel des classes de base ? - - this->_array.set(array._array); // Le propriétaire reste le ARRAY initial - - return *this; - } - - MED_EN::medModeSwitch getInterlacingType() const { - return InterlacingPolicy::getInterlacingType(); - } - - bool getGaussPresence() const { - return InterlacingPolicy::getGaussPresence(); - } - - ElementType * getPtr() { - return _array; - } - - const ElementType * getPtr() const { - return _array; - } - - void setPtr(ElementType * values, bool shallowCopy=false, - bool ownershipOfValues=false) { - - if(shallowCopy) - - if(ownershipOfValues) - _array.setShallowAndOwnership((const ElementType *)values); - else - _array.set((const ElementType*)values); - - else - _array.set(InterlacingPolicy::_arraySize,values); - } - - inline const ElementType * getRow(int i) const { - CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array",1,InterlacingPolicy::_nbelem,i); - // Empêche l'utilisation de getRow en mode MED_NO_INTERLACE - // Ne devrait pas dépendre de la politique check - CHECKING_POLICY::checkEquality("MEDMEM_Array (Interlace test)", - MED_EN::MED_NO_INTERLACE, - InterlacingPolicy::_interlacing ); - return &(_array[ InterlacingPolicy::getIndex(i,1) ]); - - } - - void setRow(int i,const ElementType * const value) { - CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array",1,InterlacingPolicy::_nbelem,i); - // setRow fonctionne - // dans les deux modes d'entrelacement. - - // int index = -1; - for (int j =1; j <= InterlacingPolicy::getDim(); j++) { - for (int k = 1 ; k <= InterlacingPolicy::getNbGauss(i); k++) { - _array[InterlacingPolicy::getIndex(i,j,k)] = value[InterlacingPolicy::getIndex(1,j,k)]; - //index++; - //_array[InterlacingPolicy::getIndex(i,j,k)] = value[index]; - } - } - } - - inline const ElementType * getColumn(int j) const { - CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array",1,InterlacingPolicy::_dim,j); - CHECKING_POLICY::checkEquality("MEDMEM_Array (Interlace test)", - MED_EN::MED_FULL_INTERLACE, InterlacingPolicy::_interlacing ); - return &(_array[ InterlacingPolicy::getIndex(1,j) ]); - } - - void setColumn(int j, const ElementType * const value) { - CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array",1,InterlacingPolicy::_dim,j); - // setColumn fonctionne - // dans les deux modes d'entrelacement. - - int index = -1; - for (int i=1; i <= InterlacingPolicy::getNbElem(); i++) { - for (int k = 1 ; k <= InterlacingPolicy::getNbGauss(i); k++) { - //_array[InterlacingPolicy::getIndex(i,j,k)] = value[InterlacingPolicy::getIndex(i,1,k)]; - index++; - _array[InterlacingPolicy::getIndex(i,j,k)] = value[index]; - } - } - } - - - inline const ElementType & getIJ(int i, int j) const { - CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array",1,InterlacingPolicy::_nbelem,i); - CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array",1,InterlacingPolicy::_dim,j); - return _array[ InterlacingPolicy::getIndex(i,j) ]; - } - - inline const ElementType & getIJK(int i, int j, int k ) const { - CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array",1,InterlacingPolicy::_nbelem,i); - CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array",1,InterlacingPolicy::_dim,j); - CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array",1,InterlacingPolicy::getNbGauss(i),k); - - return _array[ InterlacingPolicy::getIndex(i,j,k) ]; - }; - - inline const ElementType & getIJByType(int i, int j, int t) const { - if ( getInterlacingType() != MED_EN::MED_NO_INTERLACE_BY_TYPE ) - throw MEDEXCEPTION(LOCALIZED(STRING("Wrong interlacing type ") << getInterlacingType())); - CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array",1,InterlacingPolicy::_nbelem,i); - CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array",1,InterlacingPolicy::_dim,j); - CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array",1,InterlacingPolicy::getNbGeoType(),t); - if ( InterlacingPolicy::getGaussPresence() ) - return _array[ ((NoInterlaceByTypeGaussPolicy*)this)->getIndexByType(i,j,t) ]; - else - return _array[ ((NoInterlaceByTypeNoGaussPolicy*)this)->getIndexByType(i,j,t) ]; - } - - inline const ElementType & getIJKByType(int i, int j, int k, int t) const { - if ( getInterlacingType() != MED_EN::MED_NO_INTERLACE_BY_TYPE ) - throw MEDEXCEPTION(LOCALIZED(STRING("Wrong interlacing type ") << getInterlacingType())); - CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array",1,InterlacingPolicy::_nbelem,i); - CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array",1,InterlacingPolicy::getNbGeoType(),t); - CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array",1,InterlacingPolicy::_dim,j); - - if ( InterlacingPolicy::getGaussPresence() ) { - // not compilable on Debian40 -// CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array", -// 1,((NoInterlaceByTypeGaussPolicy*)this)->getNbGaussByType(t),k); - int kmax = ((NoInterlaceByTypeGaussPolicy*)this)->getNbGaussByType(t); - if ( k < 1 || k > kmax ) - throw MEDEXCEPTION(LOCALIZED(STRING("MEDMEM_Array::getIJKByType(), ") - << " k : " << k << " not in rang [1," << kmax <<"]")); - return _array[ ((NoInterlaceByTypeGaussPolicy*)this)->getIndexByType(i,j,k,t) ]; - } - else { - CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array",1,InterlacingPolicy::getNbGauss(i),k); - return _array[ ((NoInterlaceByTypeNoGaussPolicy*)this)->getIndexByType(i,j,k,t) ]; - } - }; - - inline void setIJ(int i, int j, const ElementType & value) { //autre signature avec - CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array",1,InterlacingPolicy::_nbelem,i); - CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array",1,InterlacingPolicy::_dim,j); - - _array[ InterlacingPolicy::getIndex(i,j) ] = value; // retour ElementType & ? - }; - - inline void setIJByType(int i, int j, int t, const ElementType & value) { //autre signature avec - if ( getInterlacingType() != MED_EN::MED_NO_INTERLACE_BY_TYPE ) - throw MEDEXCEPTION(LOCALIZED(STRING("Wrong interlacing type ") << getInterlacingType())); - CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array",1,InterlacingPolicy::_nbelem,i); - CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array",1,InterlacingPolicy::_dim,j); - CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array",1,InterlacingPolicy::getNbGeoType(),t); - - if ( InterlacingPolicy::getGaussPresence() ) - _array[ ((NoInterlaceByTypeGaussPolicy*)this)->getIndexByType(i,j,t) ] = value; - else - _array[ ((NoInterlaceByTypeNoGaussPolicy*)this)->getIndexByType(i,j,t) ] = value; - }; - - inline void setIJK(int i, int j, int k, const ElementType & value) { //autre signature avec - CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array",1,InterlacingPolicy::_nbelem,i); - CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array",1,InterlacingPolicy::_dim,j); - CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array",1,InterlacingPolicy::getNbGauss(i),k); - - _array[ InterlacingPolicy::getIndex(i,j,k) ] = value; // retour ElementType & ? - }; - - inline void setIJKByType(int i, int j, int k, int t, const ElementType & value) { //autre signature avec - if ( getInterlacingType() != MED_EN::MED_NO_INTERLACE_BY_TYPE ) - throw MEDEXCEPTION(LOCALIZED(STRING("Wrong interlacing type ") << getInterlacingType())); - CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array",1,InterlacingPolicy::_nbelem,i); - CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array",1,InterlacingPolicy::_dim,j); - CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array",1,InterlacingPolicy::getNbGeoType(),t); - - if ( InterlacingPolicy::getGaussPresence() ) { - // not compilable on Debian40 -// CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array", -// 1,((NoInterlaceByTypeGaussPolicy*)this)->getNbGaussByType(t),k); - int kmax = ((NoInterlaceByTypeGaussPolicy*)this)->getNbGaussByType(t); - if ( k < 1 || k > kmax ) - throw MEDEXCEPTION(LOCALIZED(STRING("MEDMEM_Array::getIJKByType(), ") - << " k : " << k << " not in rang [1," << kmax <<"]")); - _array[ ((NoInterlaceByTypeGaussPolicy*)this)->getIndexByType(i,j,k,t) ] = value; - } - else { - CHECKING_POLICY::checkInInclusiveRange("MEDMEM_Array",1,InterlacingPolicy::getNbGauss(i),k); - _array[ ((NoInterlaceByTypeNoGaussPolicy*)this)->getIndexByType(i,j,k,t) ] = value; - } - }; - - bool operator == (const MEDMEM_Array & array ) const { - - if ( this == &array ) return true; - - int size = array.getArraySize(); - if ( size != this->getArraySize() ) return false; - - ARRAY_ELEMENT_TYPE * arrayPtr = - const_cast<MEDMEM_Array &>(array).getPtr(); - for (int i=0; i < size; ++i) - if (_array[i] != arrayPtr[i]) return false; - - return true; - } - - friend ostream & operator<<(ostream & os, const MEDMEM_Array & array) { - - for (int i=1;i<=array.getNbElem();++i) { - for (int j=1; j<=array.getDim();++j) - for (int k=1;k<=array.getNbGauss(i);++k) - os << "Value [" << i << "," << j << "," << k << "] = " << array.getIJK(i,j,k) << ", "; - os << endl; - } - return os; - } - -private: - - PointerOf<ElementType> _array; -}; - -} //END NAMESPACE -#endif diff --git a/src/MEDMEM/MEDNormalizedUnstructuredMesh.hxx b/src/MEDMEM/MEDNormalizedUnstructuredMesh.hxx deleted file mode 100644 index 053eec6d5..000000000 --- a/src/MEDMEM/MEDNormalizedUnstructuredMesh.hxx +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __MEDNORMALIZEDUNSTRUCTUREDMESH_HXX__ -#define __MEDNORMALIZEDUNSTRUCTUREDMESH_HXX__ - -#include "INTERPKERNELDefines.hxx" -#include "NormalizedUnstructuredMesh.hxx" - -namespace MEDMEM -{ - class MESH; -} - -template<int SPACEDIM,int MESHDIM> -class MEDNormalizedUnstructuredMesh : public INTERP_KERNEL::GenericMesh -{ -public: - static const int MY_SPACEDIM=SPACEDIM; - static const int MY_MESHDIM=MESHDIM; - typedef int MyConnType; - static const INTERP_KERNEL::NumberingPolicy My_numPol=INTERP_KERNEL::ALL_FORTRAN_MODE; -public: - MEDNormalizedUnstructuredMesh(const MEDMEM::MESH *mesh); - ~MEDNormalizedUnstructuredMesh(); - void getBoundingBox(double *boundingBox) const; - INTERP_KERNEL::NormalizedCellType getTypeOfElement(int eltId) const; - unsigned char getNumberOfNodesOfElement(int eltId) const; - unsigned long getNumberOfElements() const; - unsigned long getNumberOfNodes() const; - const int *getConnectivityPtr() const; - const double *getCoordinatesPtr() const; - const int *getConnectivityIndexPtr() const; - void releaseTempArrays(); -protected: - void prepare(); -protected: - const MEDMEM::MESH *_meshInMedMode; - int *_conn_for_interp; - bool _own_conn_for_interp; - int *_conn_index_for_interp; - bool _own_conn_index_for_interp; -}; - -#endif diff --git a/src/MEDMEM/MEDNormalizedUnstructuredMesh.txx b/src/MEDMEM/MEDNormalizedUnstructuredMesh.txx deleted file mode 100644 index 488132ce2..000000000 --- a/src/MEDMEM/MEDNormalizedUnstructuredMesh.txx +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef __MEDNORMALIZEDUNSTRUCTUREDMESH_TXX__ -#define __MEDNORMALIZEDUNSTRUCTUREDMESH_TXX__ - -#include "MEDNormalizedUnstructuredMesh.hxx" -#include "InterpKernelException.hxx" - -#include "MEDMEM_Mesh.hxx" - -template<int SPACEDIM,int MESHDIM> -MEDNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::MEDNormalizedUnstructuredMesh(const MEDMEM::MESH *mesh):_meshInMedMode(mesh), - _conn_for_interp(0), - _own_conn_for_interp(false), - _conn_index_for_interp(0), - _own_conn_index_for_interp(false) -{ - prepare(); -} - -template<int SPACEDIM,int MESHDIM> -MEDNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::~MEDNormalizedUnstructuredMesh() -{ - releaseTempArrays(); -} - -template<int SPACEDIM,int MESHDIM> -void MEDNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getBoundingBox(double *boundingBox) const -{ - vector< vector<double> > ret=_meshInMedMode->getBoundingBox(); - //low left corner - int i; - for(i=0;i<SPACEDIM;i++) - boundingBox[i]=ret[0][i]; - for(i=0;i<SPACEDIM;i++) - boundingBox[i+SPACEDIM]=ret[1][i]; -} - -template<int SPACEDIM,int MESHDIM> -INTERP_KERNEL::NormalizedCellType MEDNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getTypeOfElement(int eltId) const -{ - MED_EN::medGeometryElement type=_meshInMedMode->getElementType(MED_EN::MED_CELL,eltId); - if(type==MED_EN::MED_POLYGON) - return INTERP_KERNEL::NORM_POLYGON; - if(type==MED_EN::MED_POLYHEDRA) - return INTERP_KERNEL::NORM_POLYHED; - return (INTERP_KERNEL::NormalizedCellType)(((unsigned long)type/100-2)*10+((unsigned long)type%100)); -} - -template<int SPACEDIM,int MESHDIM> -unsigned char MEDNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getNumberOfNodesOfElement(int eltId) const -{ - if(_meshInMedMode->getElementType(MED_EN::MED_CELL,eltId)!=MED_EN::MED_POLYHEDRA) - return (unsigned char) (_conn_index_for_interp[eltId]-_conn_index_for_interp[eltId-1]); - else - { - return (unsigned char)(_conn_index_for_interp[eltId]-_conn_index_for_interp[eltId-1])- - std::count(_conn_for_interp+_conn_index_for_interp[eltId-1]-1,_conn_for_interp+_conn_index_for_interp[eltId]-1,-1); - } -} - -template<int SPACEDIM,int MESHDIM> -unsigned long MEDNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getNumberOfElements() const -{ - return _meshInMedMode->getNumberOfElements(MED_EN::MED_CELL, MED_EN::MED_ALL_ELEMENTS); -} - -template<int SPACEDIM,int MESHDIM> -unsigned long MEDNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getNumberOfNodes() const -{ - return _meshInMedMode->getNumberOfNodes(); -} - -template<int SPACEDIM,int MESHDIM> -const int *MEDNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getConnectivityPtr() const -{ - return _conn_for_interp; -} - -template<int SPACEDIM,int MESHDIM> -const double *MEDNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getCoordinatesPtr() const -{ - return _meshInMedMode->getCoordinates(MED_EN::MED_FULL_INTERLACE); -} - -template<int SPACEDIM,int MESHDIM> -const int *MEDNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getConnectivityIndexPtr() const -{ - return _conn_index_for_interp; -} - -template<int SPACEDIM,int MESHDIM> -void MEDNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::releaseTempArrays() -{ - if(_own_conn_for_interp) - delete [] _conn_for_interp; - if(_own_conn_index_for_interp) - delete [] _conn_index_for_interp; - _conn_for_interp=0; - _conn_index_for_interp=0; - _own_conn_for_interp=false; - _own_conn_index_for_interp=false; -} - -template<int SPACEDIM,int MESHDIM> -void MEDNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::prepare() -{ - releaseTempArrays(); - _conn_for_interp=(int *)_meshInMedMode->getConnectivity(MED_EN::MED_NODAL,MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS); - _own_conn_for_interp=false; - _conn_index_for_interp=(int *)_meshInMedMode->getConnectivityIndex(MED_EN::MED_NODAL, MED_EN::MED_CELL); - _own_conn_index_for_interp=false; -} - -#endif diff --git a/src/MEDMEM/Makefile.am b/src/MEDMEM/Makefile.am deleted file mode 100644 index a18195d0c..000000000 --- a/src/MEDMEM/Makefile.am +++ /dev/null @@ -1,166 +0,0 @@ -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# MED MEDMEM : MED files in memory -# -include $(top_srcdir)/adm_local/unix/make_common_starter.am - -# first '.' says that this folder must be compiled before Test (MEDMEM/Test uses MEDMEM) -#if CPPUNIT_IS_OK -# SUBDIRS=. Test -#endif - -#DIST_SUBDIRS= Test - -lib_LTLIBRARIES= libmedmem.la - -salomeinclude_HEADERS= \ -MEDMEM_PointerOf.hxx \ -MEDMEM_CellModel.hxx \ -MEDMEM_Connectivity.hxx \ -MEDMEM_Coordinate.hxx \ -MEDMEM_define.hxx \ -MEDMEM_DriversDef.hxx \ -MEDMEM_DriverFactory.hxx \ -MEDMEM_DriverFactory.ixx \ -MEDMEM_Family.hxx \ -MEDMEM_Field.hxx \ -MEDMEM_GenDriver.hxx \ -MEDMEM_Group.hxx \ -MEDMEM_Array.hxx \ -MEDMEM_Exception.hxx \ -MEDMEM_MedFieldDriver.hxx \ -MEDMEM_MedFieldDriver.txx \ -MEDMEM_AsciiFieldDriver.hxx \ -MEDMEM_MedMeshDriver.hxx \ -MEDMEM_GibiMeshDriver.hxx \ -MEDMEM_PorflowMeshDriver.hxx \ -MEDMEM_DriverTools.hxx \ -MEDMEM_ModulusArray.hxx \ -MEDMEM_SkyLineArray.hxx \ -MEDMEM_VtkMedDriver.hxx \ -MEDMEM_VtkMeshDriver.hxx \ -MEDMEM_VtkFieldDriver.hxx \ -MEDMEM_Mesh.hxx \ -MEDMEM_Meshing.hxx \ -MEDMEM_STRING.hxx \ -MEDMEM_Support.hxx \ -MEDMEM_Unit.hxx \ -MEDMEM_Grid.hxx \ -MEDMEM_RCBase.hxx \ -MEDMEM_MedVersion.hxx \ -MEDMEM_TopLevel.hxx \ -MEDMEM_Utilities.hxx \ -MEDMEM_ArrayInterface.hxx \ -MEDMEM_IndexCheckingPolicy.hxx \ -MEDMEM_InterlacingPolicy.hxx \ -MEDMEM_InterlacingTraits.hxx \ -MEDMEM_nArray.hxx \ -MEDMEM_Tags.hxx \ -MEDMEM_FieldConvert.hxx \ -MEDMEM_ArrayConvert.hxx \ -MEDMEM_FieldForward.hxx \ -MEDMEM_GaussLocalization.hxx \ -MEDMEM_SetInterlacingType.hxx\ -MEDMEM_ConnectZone.hxx \ -MEDMEM_EnsightMedDriver.hxx \ -MEDMEM_EnsightMeshDriver.hxx \ -MEDMEM_EnsightFieldDriver.hxx \ -MEDMEM.hxx \ -MEDMEM_OptionManager.hxx \ -MEDMEM_EnsightUtils.hxx \ -MEDMEM_Extractor.hxx \ -MEDMEM_Remapper.hxx \ -PointLocator.hxx \ -MEDNormalizedUnstructuredMesh.hxx \ -MEDNormalizedUnstructuredMesh.txx \ -MEDMEM_GMesh.hxx \ -MEDMEM_MeshFuse.hxx \ -MEDMEM_MedFileBrowser.hxx - -dist_libmedmem_la_SOURCES= \ -MEDMEM_Init.cxx \ -MEDMEM_RCBase.cxx \ -MEDMEM_CellModel.cxx \ -MEDMEM_Connectivity.cxx \ -MEDMEM_Coordinate.cxx \ -MEDMEM_DriversDef.cxx \ -MEDMEM_DriverFactory.cxx \ -MEDMEM_Family.cxx \ -MEDMEM_Field.cxx \ -MEDMEM_GenDriver.cxx \ -MEDMEM_Group.cxx \ -MEDMEM_Exception.cxx \ -MEDMEM_MedMeshDriver.cxx \ -MEDMEM_GibiMeshDriver.cxx \ -MEDMEM_PorflowMeshDriver.cxx \ -MEDMEM_SkyLineArray.cxx \ -MEDMEM_Mesh.cxx \ -MEDMEM_Meshing.cxx \ -MEDMEM_Support.cxx \ -MEDMEM_Unit.cxx \ -MEDMEM_VtkMedDriver.cxx \ -MEDMEM_VtkMeshDriver.cxx \ -MEDMEM_Grid.cxx \ -MEDMEM_MedVersion.cxx \ -MEDMEM_TopLevel.cxx \ -MEDMEM_ConnectZone.cxx \ -MEDMEM_EnsightMedDriver.cxx \ -MEDMEM_EnsightFieldDriver.cxx \ -MEDMEM_EnsightUtils.cxx \ -MEDMEM_EnsightMeshDriver.cxx \ -MEDMEM_DriverTools.cxx \ -MEDMEM_GaussLocalization.cxx \ -MEDMEM_Extractor.cxx \ -PointLocator.cxx \ -MEDMEM_Remapper.cxx \ -MEDMEM_GMesh.cxx \ -MEDMEM_MeshFuse.cxx \ -MEDMEM_MedFileBrowser.cxx - -#libmedmem_la_LDFLAGS= -L$(top_builddir)/lib@LIB_LOCATION_SUFFIX@/salome -# libmedmem_la_CPPFLAGS= $(MED3_INCLUDES) $(HDF5_INCLUDES) @CXXTMPDPTHFLAGS@ -libmedmem_la_CPPFLAGS= $(MED3_INCLUDES) $(HDF5_INCLUDES) $(XDR_CPPFLAGS) \ - -I$(srcdir)/../INTERP_KERNEL \ - -I$(srcdir)/../INTERP_KERNEL/Bases \ - -I$(srcdir)/../INTERP_KERNEL/Geometric2D \ - -I$(srcdir)/../INTERP_KERNEL/GaussPoints -libmedmem_la_CXXFLAGS= @CXXTMPDPTHFLAGS@ - -# change motivated by the bug KERNEL4778. -libmedmem_la_LDFLAGS=$(MED3_LIBS_C_ONLY) $(HDF5_LIBS) $(XDR_LIBS) \ - $(STDLIB) ../INTERP_KERNEL/libinterpkernel.la - -AM_CPPFLAGS+= $(libmedmem_la_CPPFLAGS) -AM_CXXFLAGS+= $(libmedmem_la_CXXFLAGS) -LDADD= $(libmedmem_la_LDFLAGS) -lm libmedmem.la - -OBSOLETE_FILES = \ - MEDMEM_MEDMEMchampLire.hxx \ - MEDMEM_MEDMEMchampLire.cxx \ - MEDMEM_MEDMEMgaussEcr.hxx \ - MEDMEM_MEDMEMgaussEcr.cxx \ - MEDMEM_MEDMEMprofilEcr.hxx \ - MEDMEM_MEDMEMprofilEcr.cxx \ - MEDMEM_TypeMeshDriver.cxx \ - MEDMEM_TypeMeshDriver.hxx \ - checkScript \ - DataTest - -EXTRA_DIST += $(OBSOLETE_FILES) diff --git a/src/MEDMEM/PointLocator.cxx b/src/MEDMEM/PointLocator.cxx deleted file mode 100644 index 5d07c0595..000000000 --- a/src/MEDMEM/PointLocator.cxx +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDNormalizedUnstructuredMesh.txx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Exception.hxx" -#include "PointLocatorAlgos.txx" -#include "PointLocator.hxx" - -#include <list> - -MEDMEM::PointLocator::PointLocator(const MEDMEM::MESH& mesh) -{ - int meshdim=mesh.getMeshDimension(); - int spacedim=mesh.getSpaceDimension(); - if (meshdim != spacedim) throw MEDMEM::MEDEXCEPTION("Locator is not implemented for meshdim != spacedim"); - switch (meshdim) - { - case 2: - _medmesh = new MEDNormalizedUnstructuredMesh<2,2> (&mesh); - _point_locator=new INTERP_KERNEL::PointLocatorAlgos<MEDNormalizedUnstructuredMesh<2,2> >(*(static_cast<MEDNormalizedUnstructuredMesh<2,2>* >(_medmesh))); - break; - case 3: - _medmesh = new MEDNormalizedUnstructuredMesh<3,3> (&mesh); - _point_locator=new INTERP_KERNEL::PointLocatorAlgos<MEDNormalizedUnstructuredMesh<3,3> >(*(static_cast<MEDNormalizedUnstructuredMesh<3,3>* >(_medmesh))); - break; - } -} - -MEDMEM::PointLocator::~PointLocator() -{ - delete _medmesh; - delete _point_locator; -} - -std::list<int> MEDMEM::PointLocator::locate(const double* x) -{ - return _point_locator->locates(x,1e-12); -} - -MEDMEM::PointLocatorInSimplex::PointLocatorInSimplex(const MEDMEM::MESH& mesh) -{ - int meshdim=mesh.getMeshDimension(); - int spacedim=mesh.getSpaceDimension(); - if (meshdim != spacedim) throw MEDMEM::MEDEXCEPTION("Locator is not implemented for meshdim != spacedim"); - switch (meshdim) - { - case 2: - _medmesh = new MEDNormalizedUnstructuredMesh<2,2> (&mesh); - _point_locator=new INTERP_KERNEL::PointLocatorInSimplex<MEDNormalizedUnstructuredMesh<2,2> >(*(static_cast<MEDNormalizedUnstructuredMesh<2,2>* >(_medmesh))); - break; - case 3: - _medmesh = new MEDNormalizedUnstructuredMesh<3,3> (&mesh); - _point_locator=new INTERP_KERNEL::PointLocatorInSimplex<MEDNormalizedUnstructuredMesh<3,3> >(*(static_cast<MEDNormalizedUnstructuredMesh<3,3>* >(_medmesh))); - break; - } -} - -void MEDMEM::PointLocatorInSimplex::getNodeWightsInSimplex( const std::vector<const double*>& nodes, - const double* p, double* weghts ) -{ - INTERP_KERNEL::barycentric_coords( nodes, p, weghts ); -} diff --git a/src/MEDMEM/PointLocator.hxx b/src/MEDMEM/PointLocator.hxx deleted file mode 100644 index 3819122cd..000000000 --- a/src/MEDMEM/PointLocator.hxx +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef _POINT_LOCATOR_HXX_ -#define _POINT_LOCATOR_HXX_ - -#include "MEDMEM.hxx" - -#include <list> -#include <vector> - -namespace INTERP_KERNEL -{ - class GenericMesh; - class GenericPointLocatorAlgos; -} - -namespace MEDMEM -{ - class MESH; - - class MEDMEM_EXPORT PointLocator - { - public: - PointLocator(const MEDMEM::MESH& mesh); - virtual ~PointLocator(); - std::list<int> locate(const double* x); - protected: - PointLocator() {} - INTERP_KERNEL::GenericMesh *_medmesh; - INTERP_KERNEL::GenericPointLocatorAlgos* _point_locator; - }; - - class MEDMEM_EXPORT PointLocatorInSimplex : public PointLocator - { - public: - PointLocatorInSimplex(const MEDMEM::MESH& mesh); - - static void getNodeWightsInSimplex( const std::vector<const double*>& nodes, - const double* p, double* weghts ); - }; -} - -#endif diff --git a/src/MEDMEM/checkScript b/src/MEDMEM/checkScript deleted file mode 100755 index 0839785af..000000000 --- a/src/MEDMEM/checkScript +++ /dev/null @@ -1,96 +0,0 @@ -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -./test_MEDMEM_nArray > Essai1 -./test_copie_fieldT pointe.med maa1 fieldnodeint > Essai2 -./med_test pointe.med maa1 fieldnodeint > Essai3 -./med_test pointe.med maa1 fieldnodedouble > Essai4 -./test_copie_fieldT pointe.med maa1 fieldnodeint > Essai5 -./test_copie_fieldT pointe.med maa1 fieldnodedouble > Essai6 -./test_MEDMEM_Array > Essai7 -./test_MEDMEM_CellModel > Essai8 -./test_MEDMEM_Meshing Essai9 -h5dump Essai9.med > Essai9.log && rm Essai9.med -./test_MEDMEM_ModulusArray > Essai10 -./test_MEDMEM_SkyLineArray > Essai12 -./test_operation_fielddouble pointe.med maa1 fieldnodedouble > Essai13 -./test_operation_fielddouble pointe.med maa1 fieldcelldouble > Essai14 -./test_operation_fieldint pointe.med maa1 fieldnodeint > Essai15 -./test_operation_fieldint pointe.med maa1 fieldcellint > Essai16 -#./test_porflow_driver Essai17 -./testUArray > Essai18 -./testUCellModel > Essai19 -./testUCoordinate > Essai20 -./testUGeoNameMeshEntities > Essai21 -./testUMedException > Essai22 -./testUModulusArray > Essai23 -./test_affect_medarray > Essai24 -./test_copie_connectivity pointe.med maa1 > Essai25 -./test_copie_coordinate pointe.med maa1 > Essai26 -./test_copie_family pointe.med maa1 > Essai27 -./test_copie_field_ pointe.med maa1 fieldnodedouble > Essai28 -./test_copie_group pointe.med maa1 > Essai29 -./test_copie_medarray pointe.med maa1 > Essai30 -./test_copie_mesh pointe.med maa1 > Essai31 -./test_copie_support pointe.med maa1 > Essai32 -#./test_gibi_driver pointe.med maa1 > Essai33 -./duplicateMED pointe.med Essai34 - -#RESUZERODEPL____________________ 1 1 sur NOEUDS, 3 composantes, 1 points de Gauss, taille de profil 18 -#RESUZEROERRE_ELGA_NORE__________ 1 1 sur TETRA10, 6 composantes, 1 points de Gauss, taille de profil 3 -#RESUZEROSIEF_ELGA_DEPL__________ 1 1 sur TETRA10, 6 composantes, 5 points de Gauss, taille de profil 3 -#RESUZEROSIGM_ELNO_DEPL__________ 1 1 sur TETRA10, 6 composantes, 10 points de Gauss, taille de profil 3 - -rm -f Copy_nomesh_zzzz121b_without_tr6.med Copy_withmesh_zzzz121b_without_tr6.med && ./test_profil_MedFieldDriver zzzz121b_without_tr6.med RESUZERODEPL____________________ 1 1 > Essai35 -rm -f Copy_nomesh_zzzz121b_without_tr6.med Copy_withmesh_zzzz121b_without_tr6.med && ./test_profil_MedFieldDriver zzzz121b_without_tr6.med RESUZEROERRE_ELGA_NORE__________ 1 1 > Essai36 -rm -f Copy_nomesh_zzzz121b_without_tr6.med Copy_withmesh_zzzz121b_without_tr6.med && ./test_profil_gauss_MedFieldDriver zzzz121b_without_tr6.med RESUZEROSIEF_ELGA_DEPL__________ 1 1 > Essai37 -rm -f Copy_nomesh_zzzz121b_without_tr6.med Copy_withmesh_zzzz121b_without_tr6.med && ./test_profil_gauss_MedFieldDriver zzzz121b_without_tr6.med RESUZEROSIGM_ELNO_DEPL__________ 1 1 > Essai38 - -# Le fichier maill.00.med ne peut pas passer en mode 2 -# - En MODE 1 il faut débrayer la génération du fichier Copy_withmesh_maill.00.med et utiliser celui fourni. -# - En MODE 2, le problème est qu'à la lecture du fichier (qui contient SEG2 TRIA3 et QUAD4) le driver mesh crée de nouveaux SEG2 or -# le champ qui a été chargé au préalable a pris le maillage contenu dans le fichier comme référence du coup à la réécriture des numéros -# de profils il décale d'un nombre d'entités cumulées trop important. - -# MODE 1 avec modif du fichier test -#cp maill.00_nofield.med Copy_withmesh_maill.00.med;./test_profil_MedFieldDriver maill.00.med Indicateur_d_erreur_00 2 2 -# MODE 3 en activant uniquement le mode 3 -##rm -f Copy_withmesh_maill.00.med Copy_nomesh_maill.00.med && cp maill.00_nofield.med Copy_withmesh_maill.00.med;cp maill.00_nomesh.med Copy_nomesh_maill.00.med;./test_profil_MedFieldDriver maill.00.med Indicateur_d_erreur_00 2 2 - -#Indicateur_d_erreur_00 1 1 TRIA3, 1 composante, 1 point de Gauss, pas de profil -#Indicateur_d_erreur_00 1 1 QUAD4, 1 composante, 1 point de Gauss, pas de profil - -#Indicateur_d_erreur_00 2 2 TRIA3, 1 composante, 1 point de Gauss, taille de profil 4 -#Indicateur_d_erreur_00 2 2 QAUD4, 1 composante, 1 point de Gauss, taille de profil 2 - -#Indicateur_d_erreur_00 3 3 TRIA3, 1 composante, 3 point de Gauss, pas de profil -#Indicateur_d_erreur_00 3 3 QAUD4, 1 composante, 4 point de Gauss, pas de prrofil - -#Indicateur_d_erreur_00 4 4 TRIA3, 1 composante, 3 point de Gauss, taille de profil 4 -#Indicateur_d_erreur_00 4 4 QAUD4, 1 composante, 4 point de Gauss, taille de profil 2 - -rm Copy*; ./test_profil_MedFieldDriver maill.00_without_seg2.med Indicateur_d_erreur_00 1 1 > Essai39 -rm Copy*; ./test_profil_MedFieldDriver maill.00_without_seg2.med Indicateur_d_erreur_00 2 2 > Essai40 -rm Copy*; ./test_profil_gauss_MedFieldDriver maill.00_without_seg2.med Indicateur_d_erreur_00 3 3 > Essai41 -rm Copy*; ./test_profil_gauss_MedFieldDriver maill.00_without_seg2.med Indicateur_d_erreur_00 4 4 > Essai42 - - -- 2.39.2