]> SALOME platform Git repositories - modules/filter.git/commitdiff
Salome HOME
new version of ensight driver
authorsecher <secher>
Tue, 3 Apr 2007 14:21:12 +0000 (14:21 +0000)
committersecher <secher>
Tue, 3 Apr 2007 14:21:12 +0000 (14:21 +0000)
adm_local/unix/make_commence.in
adm_local/unix/make_omniorb.in
idl/FILTER_Gen.idl
src/FILTER/Filter_Gen_i.cxx
src/FILTER/Filter_Gen_i.hxx
src/FILTER/Makefile.in
src/FILTER/field2nodes.cxx [new file with mode: 0644]
src/FILTERGUI/FILTER_msg_en.po
src/FILTERGUI/SelectParams.cxx

index 43dfcdd8ddb00628af1d1438266222ab45ffa6e6..e3d27df07f5f6966eb201244775e848a415dadfc 100644 (file)
@@ -169,7 +169,7 @@ CORBA_INCLUDES    = @CORBA_INCLUDES@
 CORBA_LIBS        = @CORBA_LIBS@
 CORBA_CXXFLAGS    = @CORBA_CXXFLAGS@
 
-IDLCXXFLAGS = -bcxx @IDLCXXFLAGS@ -I$(top_srcdir)/idl -I$(top_builddir)/idl/salome -I$(KERNEL_ROOT_DIR)/idl/salome
+IDLCXXFLAGS = -bcxx @IDLCXXFLAGS@ -I$(top_srcdir)/idl -I$(top_builddir)/idl/salome -I$(KERNEL_ROOT_DIR)/idl/salome -I$(MED_ROOT_DIR)/idl/salome 
 IDLPYFLAGS  = @IDLPYFLAGS@
 
 IDL = @IDL@
index 84679a9eae2714fb62791581229ae25e6874523d..01055d37fff77ad7136705057c441db84b88d5b5 100644 (file)
@@ -22,6 +22,9 @@
 %$(OMNIORB_IDL_CLN_CXX) %$(OMNIORB_IDL_CLN_H): ${top_srcdir}/idl/%.idl
        $(OMNIORB_IDL) $(IDLCXXFLAGS) $(OMNIORB_IDLCXXFLAGS) $<
 
+%$(OMNIORB_IDL_CLN_CXX) %$(OMNIORB_IDL_CLN_H): ${MED_ROOT_DIR}/idl/salome/%.idl
+       $(OMNIORB_IDL) $(IDLCXXFLAGS) $(OMNIORB_IDLCXXFLAGS) $<
+
 # dependncies between idl files
 depend_idl: .depidl
 
index c0de06fb519e0302b4d8baca8334960dac95a24c..75001a15477f0436c8293bc64a19e70a32ec0b49 100644 (file)
@@ -59,7 +59,7 @@ module SALOME_FILTER
     void buildGradient() raises(FilterError);
     void getMinMax(out double min,out double max,in ref_func rf);
     LongSeq getHistogram(in long size,in ref_func rf);
-    void generateCriteria(in long nbthresh,in double fthresh,in double sthresh,in boolean areaFlag) raises(FilterError);
+    void generateCriteria(in long nbthresh,in double fthresh,in double sthresh,in boolean areaFlag,in ref_func rf) raises(FilterError);
     void createEnsightInputFiles();
     void filtering();
     void projectFieldsOnDecimateMesh() raises(FilterError);
index 4238838c8db1bd8284283f4134dc12f709d6bfcd..25d03bbec5b2872fd8e82db2f791153072a3e810 100755 (executable)
@@ -287,7 +287,7 @@ LongSeq* Filter_Gen_i::getHistogram(CORBA::Long size,ref_func rf)
   return seq;
 }
 
-void Filter_Gen_i::generateCriteria(CORBA::Long nbthresh,CORBA::Double fthresh,CORBA::Double sthresh,CORBA::Boolean areaFlag) throw(SALOME_FILTER::FILTER_Gen::FilterError)
+void Filter_Gen_i::generateCriteria(CORBA::Long nbthresh,CORBA::Double fthresh,CORBA::Double sthresh,CORBA::Boolean areaFlag,ref_func rf) throw(SALOME_FILTER::FILTER_Gen::FilterError)
 {
   double val, min, max;
   double sigmaV;
@@ -460,9 +460,15 @@ void Filter_Gen_i::projectFieldsOnDecimateMesh() throw(SALOME_FILTER::FILTER_Gen
 {
   string command;
 
+  // read of new mesh in ensight file
+  MESH* myMesh = new MESH();
+  ENSIGHT_MESH_RDONLY_DRIVER myEnsightMeshDriver("/tmp/output.case", myMesh) ;
+  myMesh->addDriver(ENSIGHT_DRIVER,"/tmp/output.case","myMesh",MED_EN::MED_LECT);
+  myMesh->read() ;
+
   // have to call ensight driver MED to generate output MED file from filtoo output
-  _newMed = new ::MED(ENSIGHT_DRIVER,"/tmp/output.case");
-  _newMed->read();
+  _newMed = new ::MED();
+  _newMed->addMesh(myMesh);
 
   // destroy filtoo output files
 //   command = "cd /tmp;rm -f output.*";
@@ -529,11 +535,13 @@ void Filter_Gen_i::projectFieldsOnDecimateMesh() throw(SALOME_FILTER::FILTER_Gen
          FIELD<int> *newIField = NULL;
 
          if (dynamic_cast<MEDMEM::FIELD<double>*>(field)){
-           if(!isReferenceField)
+           if(!isReferenceField){
              // read input field on input file
              myDField = new FIELD<double>(MEDMEM::MED_DRIVER,_file,fieldsNames[i],myIteration[j].dt,myIteration[j].it);
-           else
+           }
+           else{
              myDField = _myDField;
+           }
            // create new output field
            newDField = new FIELD<double>(newSup,field->getNumberOfComponents());
            newDField->setName(myDField->getName());
@@ -548,9 +556,10 @@ void Filter_Gen_i::projectFieldsOnDecimateMesh() throw(SALOME_FILTER::FILTER_Gen
            newIField = new FIELD<int>(newSup,field->getNumberOfComponents());
            newIField->setName(myIField->getName());
          }
+         numberOfComponents = field->getNumberOfComponents();
          
          // loop on nodes on new field
-         for (int k=1; k<numberOfNodes+1; k++){
+         for (int k=1; k<=numberOfNodes; k++){
            // read number of nodes on input field
            int l = getNodeNumber(k);
            double dval;
@@ -564,8 +573,9 @@ void Filter_Gen_i::projectFieldsOnDecimateMesh() throw(SALOME_FILTER::FILTER_Gen
                ival = myIField->getValueIJ(l,c);
              
              // write value on new field
-             if(newDField)
+             if(newDField){
                newDField->setValueIJ(k,c,dval);
+             }
              else
                newIField->setValueIJ(k,c,ival);
            }
@@ -576,7 +586,7 @@ void Filter_Gen_i::projectFieldsOnDecimateMesh() throw(SALOME_FILTER::FILTER_Gen
          else
            _newMed->addField(newIField);
          
-         // Destroy input field if not referecne field
+         // Destroy input field if not reference field
          if(!isReferenceField)
            if(myDField){
              delete myDField->getSupport();
@@ -611,11 +621,11 @@ void Filter_Gen_i::readMapping()
 
 int Filter_Gen_i::getNodeNumber(int num)
 {
-  int oldnum = _map[num];
+  int oldnum = _map[num-1];
 
   // if new node get neighbour node
   if(oldnum == 0)
-    oldnum = _map[getNeighbourVertex(num)];
+    oldnum = _map[getNeighbourVertex(num)-1];
   
   return oldnum;
 }
@@ -639,18 +649,18 @@ int Filter_Gen_i::getNeighbourVertex(int num) throw(SALOME_Exception)
       // search neighbour node which are in old mesh
       for(int j=_connI[i-1];j<_connI[i];j++){
        nnum = _conn[j-1];
-       if( _map[nnum] != 0)
+       if( _map[nnum-1] != 0)
          break;
       }
 
       // if neighbour node in old mesh: go out loop, else continue
-      if(_map[nnum]!=0)
+      if(_map[nnum-1]!=0)
        break;
     }
   }
 
   // if no neighbour node in old mesh: throw exception
-  if(_map[nnum]==0)
+  if(_map[nnum-1]==0)
     throw SALOME_Exception("None of the neighbour node are in old mesh!!");
 
   return nnum;
index 0268e64c7994a04e542f501a7cd02c8b804f5d62..6870a56f408cea7f6039ac7497f846d18b3d4873 100644 (file)
@@ -64,7 +64,7 @@ public:
   void buildGradient()  throw(SALOME_FILTER::FILTER_Gen::FilterError);
   void getMinMax(CORBA::Double& imin, CORBA::Double& imax,SALOME_FILTER::ref_func rf);
   SALOME_FILTER::LongSeq* getHistogram(CORBA::Long size,SALOME_FILTER::ref_func rf);
-  void generateCriteria(CORBA::Long nbthresh,CORBA::Double fthresh,CORBA::Double thresh,CORBA::Boolean areaFlag) throw(SALOME_FILTER::FILTER_Gen::FilterError);
+  void generateCriteria(CORBA::Long nbthresh,CORBA::Double fthresh,CORBA::Double thresh,CORBA::Boolean areaFlag,SALOME_FILTER::ref_func rf) throw(SALOME_FILTER::FILTER_Gen::FilterError);
   void createEnsightInputFiles();
   void filtering();
   void projectFieldsOnDecimateMesh() throw(SALOME_FILTER::FILTER_Gen::FilterError);
index 42a8f11f4d70fc9d0468034d924a66408231656f..ab2e256f93c2469c9d82754d9d352ca30e2c4c64 100644 (file)
@@ -43,16 +43,17 @@ LIB_SRC = Filter_Gen_i.cxx
 LIB_SERVER_IDL = FILTER_Gen.idl SALOME_Component.idl SALOME_ContainerManager.idl \
                 SALOME_Exception.idl 
 
-LIB_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_ModuleCatalog.idl SALOME_Comm.idl SALOME_GenericObj.idl
+LIB_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_ModuleCatalog.idl SALOME_Comm.idl SALOME_GenericObj.idl MED_Gen.idl
 
 EXPORT_HEADERS = Filter_Gen_i.hxx
 
 # Executables targets
-BIN =
+BIN = field2nodes
 BIN_SRC =
 
 LDFLAGS= -L$(top_builddir)/lib@LIB_LOCATION_SUFFIX@/salome
-LDFLAGSFORBIN= -L$(top_builddir)/lib@LIB_LOCATION_SUFFIX@/salome
+LDFLAGSFORBIN= -L$(top_builddir)/lib@LIB_LOCATION_SUFFIX@/salome 
+#LDFLAGSFORBIN+=-lm $(MED2_LIBS) $(HDF5_LIBS)
 
 # additionnal information to compil and link file
 
@@ -61,6 +62,6 @@ CXXFLAGS += $(OCC_CXXFLAGS) ${KERNEL_CXXFLAGS}
 
 LDFLAGS+=  $(OCC_LIBS) $(HDF5_LIBS) ${KERNEL_LDFLAGS} \
        -lSalomeContainer -lSalomeHDFPersist -lSalomeDS -lSalomeNS -lRegistry -lOpUtil \
-       ${MED_LDFLAGS} -lMEDMEMImpl -lmedmem
+       ${MED_LDFLAGS} -lMEDMEMImpl -lmedmem -lmed_V2_1
 
 @CONCLUDE@
diff --git a/src/FILTER/field2nodes.cxx b/src/FILTER/field2nodes.cxx
new file mode 100644 (file)
index 0000000..0639478
--- /dev/null
@@ -0,0 +1,188 @@
+// Copyright (C) 2005  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<string>
+#include<deque>
+
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_define.hxx"
+
+#include "MEDMEM_Med.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Family.hxx"
+#include "MEDMEM_Support.hxx"
+#include "MEDMEM_Field.hxx"
+
+using namespace std;
+using namespace MEDMEM;
+
+void usage(char * name)
+{
+  cout << " ERROR ABOUT SYNTAX " << endl ;
+  cout << "  " << name << " <input med file> <output med file> " << endl ;
+  exit(-1);
+}
+
+int main (int argc, char ** argv) {
+
+  string filenameIN ;
+  string filenameOUT;
+  set <int> listElements;
+  set <int>::iterator elemIt ;
+  
+  if ( argc == 3 ) {
+    filenameIN  = argv[1] ;
+    filenameOUT = argv[2] ;
+    cout << "-> reading all into the Med file " << filenameIN << " and writing all into the Ensight file " << filenameOUT <<  endl ;
+
+    MED myMed(MED_DRIVER,filenameIN) ;
+
+    cout << "-> Read all meshes "  ;
+    int NumberOfMeshes = myMed.getNumberOfMeshes() ;
+    cout << "( "<<NumberOfMeshes << " ) :" << endl ;
+    deque<string> MeshName = myMed.getMeshNames() ;
+    for (int i=0; i<NumberOfMeshes; i++) {
+      myMed.getMesh(MeshName[i])->read() ;
+      cout << "-> Mesh "<<i+1<<", named "<<MeshName[i]<<" is read !" << endl;
+      int id = myMed.getMesh(MeshName[i])->addDriver(MED_DRIVER,filenameOUT,MeshName[i],MED_EN::MED_ECRI);
+      myMed.getMesh(MeshName[i])->write(id);
+      cout << "-> Mesh "<<i+1<<", named "<<MeshName[i]<<" is written !" << endl;
+    }
+
+    myMed.updateSupport() ;
+    
+    cout << "-> Read all fields " ;
+    int NumberOfFields = myMed.getNumberOfFields() ;
+    cout << "( "<<NumberOfFields << " ) :" << endl;
+    deque<string> FieldName = myMed.getFieldNames() ;
+    for (int i=0; i<NumberOfFields; i++) {
+      deque<DT_IT_> FieldIteration = myMed.getFieldIteration(FieldName[i]) ;
+      cout << "-> Field "<<i+1<<", named "<<FieldName[i] << " :" << endl ;
+      int NumberOfIteration = FieldIteration.size() ;
+      cout << "    Number of iteration pair : "<< NumberOfIteration << endl;
+      for (int j=0; j<NumberOfIteration; j++) {
+       FIELD_ * myField = myMed.getField(FieldName[i],FieldIteration[j].dt,FieldIteration[j].it) ;
+       
+       myField->read() ;
+       cout << "    * Iteration "<<FieldIteration[j].dt<<" and  order number "<<FieldIteration[j].it<<" ) is read !" << endl;
+
+       int NumberOfComponents = myField->getNumberOfComponents();
+       switch(myField->getSupport()->getEntity()){
+       case MED_CELL:
+         cout << "*************************** CHAMP AUX CELLULES" << endl;
+         MESH *mesh = myMed.getField(FieldName[i],FieldIteration[j].dt,FieldIteration[j].it)->getSupport()->getMesh();
+         SUPPORT *sup = new SUPPORT(mesh,"Support",MED_NODE);
+         // read number of nodes
+         int NumberOfNodes = sup->getNumberOfElements(MED_ALL_ELEMENTS);
+         // calculate reverse connectivity to have the list of elements which contains node i
+         const int *revC = myField->getSupport()->getMesh()->getReverseConnectivity(MED_NODAL,MED_CELL);
+         const int *indC = myField->getSupport()->getMesh()->getReverseConnectivityIndex(MED_NODAL,MED_CELL);
+         // calculate volume field on mesh
+         FIELD<double> *volume = myField->getSupport()->getMesh()->getVolume(myField->getSupport());
+         if (dynamic_cast<MEDMEM::FIELD<double>*>(myField)){
+           FIELD<double> *myDField = (MEDMEM::FIELD<double>*)myField;
+           FIELD<double> *newDField = new FIELD<double>(sup,NumberOfComponents);
+           newDField->setName(myField->getName());
+           double *val = new double[NumberOfComponents];
+           for (int k=1; k<NumberOfNodes+1; k++){
+             // listElements contains elements which contains a node of element i
+             listElements.clear();
+             for(int j=indC[k-1];j<indC[k];j++){
+               // c element contains node i
+               int c=revC[j-1];
+               listElements.insert(c);
+             }
+
+             // calculate field value on node i 
+             double sigmaV = 0.;
+             for(int j=0;j<NumberOfComponents;j++)
+               val[j] = 0.;
+             for(elemIt=listElements.begin();elemIt!=listElements.end();elemIt++){
+               int elem = *elemIt;
+               double vol = volume->getValueIJ(elem,1);
+               if( vol != 0. ){
+                 sigmaV += 1./vol;
+                 for(int j=1;j<=NumberOfComponents;j++)
+                   val[j] += myDField->getValueIJ(elem,j)/vol;
+               }
+             }
+             for(int j=1;j<=NumberOfComponents;j++)
+               newDField->setValueIJ(k,j,val[j]/sigmaV);
+           }
+           delete [] val;
+           int id = newDField->addDriver(MED_DRIVER,filenameOUT,FieldName[i],MED_EN::MED_ECRI);
+           newDField->write(id);
+           cout << "    * Iteration "<<FieldIteration[j].dt<<" and  order number "<<FieldIteration[j].it<<" ) is written !" << endl;
+         }
+         else{
+           FIELD<int> *myIField = (MEDMEM::FIELD<int>*)myField;
+           FIELD<int> *newIField = new FIELD<int>(sup,NumberOfComponents);
+           newIField->setName(myField->getName());
+           double *val = new double[NumberOfComponents];
+           for (int k=1; k<NumberOfNodes+1; k++){
+             // listElements contains elements which contains a node of element i
+             listElements.clear();
+             for(int j=indC[k-1];j<indC[k];j++){
+               // c element contains node i
+               int c=revC[j-1];
+               listElements.insert(c);
+             }
+
+             // calculate field value on node i 
+             double sigmaV = 0.;
+             for(int j=0;j<NumberOfComponents;j++)
+               val[j] = 0.;
+             for(elemIt=listElements.begin();elemIt!=listElements.end();elemIt++){
+               int elem = *elemIt;
+               double vol = volume->getValueIJ(elem,1);
+               if( vol != 0. ){
+                 sigmaV += 1./vol;
+                 for(int j=1;j<=NumberOfComponents;j++)
+                   val[j] += ((double)myIField->getValueIJ(elem,j))/vol;
+               }
+             }
+             for(int j=1;j<=NumberOfComponents;j++)
+               newIField->setValueIJ(k,j,(int)(val[j]/sigmaV));
+           }
+           delete [] val;
+           int id = newIField->addDriver(MED_DRIVER,filenameOUT,FieldName[i],MED_EN::MED_ECRI);
+           newIField->write(id);
+           cout << "    * Iteration "<<FieldIteration[j].dt<<" and  order number "<<FieldIteration[j].it<<" ) is written !" << endl;
+         }
+         break;
+       case MED_FACE:
+         cout << "*************************** CHAMP AUX FACES" << endl;
+         break;
+       case MED_EDGE:
+         cout << "*************************** CHAMP AUX ARETES" << endl;
+         break;
+       case MED_NODE:
+         cout << "*************************** CHAMP AUX NOEUDS" << endl;
+         int id = myField->addDriver(MED_DRIVER,filenameOUT,FieldName[i],MED_EN::MED_ECRI);
+         myField->write(id);
+         cout << "    * Iteration "<<FieldIteration[j].dt<<" and  order number "<<FieldIteration[j].it<<" ) is written !" << endl;
+         break;
+       }
+
+      }
+    }
+
+  }
+  else usage(argv[0]);
+}
index 8f05252846060daef16d5e42633340665522fc85..68ce9a69cf40736dd30997d8cc907526f001f010 100644 (file)
@@ -54,11 +54,11 @@ msgstr "Filtering parameters"
 
 #: SelectParams.cxx:136
 msgid "FILTER_INPUT_FILE"
-msgstr "Input Mesh : "
+msgstr "Input File : "
 
 #: SelectParams.cxx:141
 msgid "FILTER_INPUT_MESH"
-msgstr "Input File : "
+msgstr "Input Mesh : "
 
 #: SelectParams.cxx:146
 msgid "FILTER_INPUT_FIELD"
index 346a59da498663078d57ea59bbf0788431fdabd5..7c38138e375bf348c7be4f16c7318378a87d3fd8 100644 (file)
@@ -606,7 +606,12 @@ void SelectParams::process() throw(SALOME_Exception)
       nbthresh = 1;
     else
       nbthresh = 2;
-    _filter->generateCriteria(nbthresh,_fthresh,_sthresh,_myExt->isChecked());
+    SALOME_FILTER::ref_func rf;
+    if(_myFieldB->isChecked())
+      rf = SALOME_FILTER::F_FIELD;
+    else
+      rf = SALOME_FILTER::F_GRAD;
+    _filter->generateCriteria(nbthresh,_fthresh,_sthresh,_myExt->isChecked(),rf);
   }
   catch (SALOME_FILTER::FILTER_Gen::FilterError){
     QMessageBox::information( this,