From: secher Date: Tue, 3 Apr 2007 14:21:12 +0000 (+0000) Subject: new version of ensight driver X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e79342643d3d1f51e007db03168fe2f5d467b0b0;p=modules%2Ffilter.git new version of ensight driver --- diff --git a/adm_local/unix/make_commence.in b/adm_local/unix/make_commence.in index 43dfcdd..e3d27df 100644 --- a/adm_local/unix/make_commence.in +++ b/adm_local/unix/make_commence.in @@ -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@ diff --git a/adm_local/unix/make_omniorb.in b/adm_local/unix/make_omniorb.in index 84679a9..01055d3 100644 --- a/adm_local/unix/make_omniorb.in +++ b/adm_local/unix/make_omniorb.in @@ -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 diff --git a/idl/FILTER_Gen.idl b/idl/FILTER_Gen.idl index c0de06f..75001a1 100644 --- a/idl/FILTER_Gen.idl +++ b/idl/FILTER_Gen.idl @@ -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); diff --git a/src/FILTER/Filter_Gen_i.cxx b/src/FILTER/Filter_Gen_i.cxx index 4238838..25d03bb 100755 --- a/src/FILTER/Filter_Gen_i.cxx +++ b/src/FILTER/Filter_Gen_i.cxx @@ -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 *newIField = NULL; if (dynamic_cast*>(field)){ - if(!isReferenceField) + if(!isReferenceField){ // read input field on input file myDField = new FIELD(MEDMEM::MED_DRIVER,_file,fieldsNames[i],myIteration[j].dt,myIteration[j].it); - else + } + else{ myDField = _myDField; + } // create new output field newDField = new FIELD(newSup,field->getNumberOfComponents()); newDField->setName(myDField->getName()); @@ -548,9 +556,10 @@ void Filter_Gen_i::projectFieldsOnDecimateMesh() throw(SALOME_FILTER::FILTER_Gen newIField = new FIELD(newSup,field->getNumberOfComponents()); newIField->setName(myIField->getName()); } + numberOfComponents = field->getNumberOfComponents(); // loop on nodes on new field - for (int k=1; kgetValueIJ(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; diff --git a/src/FILTER/Filter_Gen_i.hxx b/src/FILTER/Filter_Gen_i.hxx index 0268e64..6870a56 100644 --- a/src/FILTER/Filter_Gen_i.hxx +++ b/src/FILTER/Filter_Gen_i.hxx @@ -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); diff --git a/src/FILTER/Makefile.in b/src/FILTER/Makefile.in index 42a8f11..ab2e256 100644 --- a/src/FILTER/Makefile.in +++ b/src/FILTER/Makefile.in @@ -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 index 0000000..0639478 --- /dev/null +++ b/src/FILTER/field2nodes.cxx @@ -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 +#include + +#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 << " " << endl ; + exit(-1); +} + +int main (int argc, char ** argv) { + + string filenameIN ; + string filenameOUT; + set listElements; + set ::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 << "( "< MeshName = myMed.getMeshNames() ; + for (int i=0; iread() ; + cout << "-> Mesh "<addDriver(MED_DRIVER,filenameOUT,MeshName[i],MED_EN::MED_ECRI); + myMed.getMesh(MeshName[i])->write(id); + cout << "-> Mesh "< Read all fields " ; + int NumberOfFields = myMed.getNumberOfFields() ; + cout << "( "< FieldName = myMed.getFieldNames() ; + for (int i=0; i FieldIteration = myMed.getFieldIteration(FieldName[i]) ; + cout << "-> Field "<read() ; + cout << " * Iteration "<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 *volume = myField->getSupport()->getMesh()->getVolume(myField->getSupport()); + if (dynamic_cast*>(myField)){ + FIELD *myDField = (MEDMEM::FIELD*)myField; + FIELD *newDField = new FIELD(sup,NumberOfComponents); + newDField->setName(myField->getName()); + double *val = new double[NumberOfComponents]; + for (int k=1; kgetValueIJ(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 "< *myIField = (MEDMEM::FIELD*)myField; + FIELD *newIField = new FIELD(sup,NumberOfComponents); + newIField->setName(myField->getName()); + double *val = new double[NumberOfComponents]; + for (int k=1; kgetValueIJ(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 "<addDriver(MED_DRIVER,filenameOUT,FieldName[i],MED_EN::MED_ECRI); + myField->write(id); + cout << " * Iteration "<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,