int NumberOfComponents = myField->getNumberOfComponents();
switch(myField->getSupport()->getEntity()){
case MED_CELL:
- cout << "*************************** CHAMP AUX CELLULES" << endl;
- MESH *mesh = myField->getSupport()->getMesh();
+ {
+ cout << "*************************** CHAMP AUX CELLULES" << endl;
+ MESH *mesh = myField->getSupport()->getMesh();
- // create new support for new field
- SUPPORT *newSup;
- if( myField->getSupport()->isOnAllElements() )
- newSup = new SUPPORT(mesh,"Support",MED_NODE);
- else{
- int nbe = myField->getSupport()->getNumberOfElements(MED_ALL_ELEMENTS);
- const int *numb = myField->getSupport()->getNumber(MED_ALL_ELEMENTS);
- list<int> myList;
- for(int k=0;k<nbe;k++){
- myList.push_back(numb[k]);
- supset.insert(numb[k]);
- }
- newSup = mesh->buildSupportOnNodeFromElementList(myList,MED_CELL);
- }
+ // create new support for new field
+ SUPPORT *newSup;
+ if( myField->getSupport()->isOnAllElements() )
+ newSup = new SUPPORT(mesh,"Support",MED_NODE);
+ else{
+ int nbe = myField->getSupport()->getNumberOfElements(MED_ALL_ELEMENTS);
+ const int *numb = myField->getSupport()->getNumber(MED_ALL_ELEMENTS);
+ list<int> myList;
+ for(int k=0;k<nbe;k++){
+ myList.push_back(numb[k]);
+ supset.insert(numb[k]);
+ }
+ newSup = mesh->buildSupportOnNodeFromElementList(myList,MED_CELL);
+ }
- // read number of nodes
- int NumberOfNodes = newSup->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);
- int ivol;
- // calculate volume field on mesh
- for(int k=0;k<NumberOfMeshes;k++)
- if(strcmp(mesh->getName().c_str(),MeshName[k].c_str())==0)
- ivol = k;
- if( volume[ivol] == NULL )
- volume[ivol] = 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>(newSup,NumberOfComponents);
- newDField->setName(myField->getName());
- newDField->setIterationNumber(FieldIteration[j].dt);
- newDField->setOrderNumber(FieldIteration[j].it);
- newDField->setTime(myDField->getTime());
- double *val = new double[NumberOfComponents];
- if( newSup->isOnAllElements() ){
- for (int k=1; k<NumberOfNodes+1; k++){
- // listElements contains elements which contains a node of element i
- listElements.clear();
- for(int l=indC[k-1];l<indC[k];l++){
- // c element contains node k
- int c=revC[l-1];
- listElements.insert(c);
- }
-
- // calculate field value on node k
- double sigmaV = 0.;
- for(int l=0;l<NumberOfComponents;l++)
- val[l] = 0.;
- for(elemIt=listElements.begin();elemIt!=listElements.end();elemIt++){
- int elem = *elemIt;
- double vol = volume[ivol]->getValueIJ(elem,1);
- if( vol != 0. ){
- sigmaV += 1./vol;
- for(int l=1;l<=NumberOfComponents;l++)
- val[l-1] += myDField->getValueIJ(elem,l)/vol;
- }
- }
- for(int l=1;l<=NumberOfComponents;l++)
- newDField->setValueIJ(k,l,val[l-1]/sigmaV);
- }
- }
- else{
- const int *numb = newSup->getNumber(MED_ALL_ELEMENTS);
- for (int k=1; k<=NumberOfNodes; k++){
- int kk = numb[k-1];
- // listElements contains elements which contains a node of element i
- listElements.clear();
- for(int l=indC[kk-1];l<indC[kk];l++){
- // c element contains node k
- int c=revC[l-1];
- // add c element only if it is in partial support
- ssIt = supset.find(c);
- if(ssIt!=supset.end())
- listElements.insert(c);
- }
-
- // calculate field value on node k
- double sigmaV = 0.;
- for(int l=0;l<NumberOfComponents;l++)
- val[l] = 0.;
- for(elemIt=listElements.begin();elemIt!=listElements.end();elemIt++){
- int elem = *elemIt;
- double vol = volume[ivol]->getValueIJ(elem,1);
- if( vol != 0. ){
- sigmaV += 1./vol;
- for(int l=1;l<=NumberOfComponents;l++)
- val[l-1] += myDField->getValueIJ(elem,l)/vol;
- }
- }
- for(int l=1;l<=NumberOfComponents;l++)
- newDField->setValueIJ(k,l,val[l-1]/sigmaV);
- }
- }
- delete [] val;
- int id = newDField->addDriver(MED_DRIVER,filenameOUT,FieldName[i],MED_EN::MED_ECRI);
- newDField->write(id);
- delete newSup;
- delete newDField;
- 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>(newSup,NumberOfComponents);
- newIField->setName(myField->getName());
- newIField->setIterationNumber(FieldIteration[j].dt);
- newIField->setOrderNumber(FieldIteration[j].it);
- newIField->setTime(myIField->getTime());
- double *val = new double[NumberOfComponents];
- if( newSup->isOnAllElements() ){
- for (int k=1; k<NumberOfNodes+1; k++){
- // listElements contains elements which contains a node of element i
- listElements.clear();
- for(int l=indC[k-1];l<indC[k];l++){
- // c element contains node i
- int c=revC[l-1];
- listElements.insert(c);
- }
+ // read number of nodes
+ int NumberOfNodes = newSup->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);
+ int ivol;
+ // calculate volume field on mesh
+ for(int k=0;k<NumberOfMeshes;k++)
+ if(strcmp(mesh->getName().c_str(),MeshName[k].c_str())==0)
+ ivol = k;
+ if( volume[ivol] == NULL )
+ volume[ivol] = 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>(newSup,NumberOfComponents);
+ newDField->setName(myField->getName());
+ newDField->setIterationNumber(FieldIteration[j].dt);
+ newDField->setOrderNumber(FieldIteration[j].it);
+ newDField->setTime(myDField->getTime());
+ double *val = new double[NumberOfComponents];
+ if( newSup->isOnAllElements() ){
+ for (int k=1; k<NumberOfNodes+1; k++){
+ // listElements contains elements which contains a node of element i
+ listElements.clear();
+ for(int l=indC[k-1];l<indC[k];l++){
+ // c element contains node k
+ int c=revC[l-1];
+ listElements.insert(c);
+ }
- // calculate field value on node k
- double sigmaV = 0.;
- for(int l=0;l<NumberOfComponents;l++)
- val[l] = 0.;
- for(elemIt=listElements.begin();elemIt!=listElements.end();elemIt++){
- int elem = *elemIt;
- double vol = volume[ivol]->getValueIJ(elem,1);
- if( vol != 0. ){
- sigmaV += 1./vol;
- for(int l=1;l<=NumberOfComponents;l++)
- val[l-1] += ((double)myIField->getValueIJ(elem,l))/vol;
- }
- }
- for(int l=1;l<=NumberOfComponents;l++)
- newIField->setValueIJ(k,l,(int)(val[l-1]/sigmaV));
- }
- }
- else{
- const int *numb = newSup->getNumber(MED_ALL_ELEMENTS);
- for (int k=1; k<=NumberOfNodes; k++){
- int kk = numb[k-1];
- // listElements contains elements which contains a node of element i
- listElements.clear();
- for(int l=indC[kk-1];l<indC[kk];l++){
- // c element contains node k
- int c=revC[l-1];
- // add c element only if it is in partial support
- ssIt = supset.find(c);
- if(ssIt!=supset.end())
- listElements.insert(c);
- }
-
- // calculate field value on node k
- double sigmaV = 0.;
- for(int l=0;l<NumberOfComponents;l++)
- val[l] = 0.;
- for(elemIt=listElements.begin();elemIt!=listElements.end();elemIt++){
- int elem = *elemIt;
- double vol = volume[ivol]->getValueIJ(elem,1);
- if( vol != 0. ){
- sigmaV += 1./vol;
- for(int l=1;l<=NumberOfComponents;l++)
- val[l-1] += myIField->getValueIJ(elem,l)/vol;
- }
- }
- for(int l=1;l<=NumberOfComponents;l++)
- newIField->setValueIJ(k,l,(int)(val[l-1]/sigmaV));
- }
- }
- delete [] val;
- int id = newIField->addDriver(MED_DRIVER,filenameOUT,FieldName[i],MED_EN::MED_ECRI);
- newIField->write(id);
- delete newSup;
- delete newIField;
- cout << " * Iteration "<<FieldIteration[j].dt<<" and order number "<<FieldIteration[j].it<<" ) is written !" << endl;
- }
+ // calculate field value on node k
+ double sigmaV = 0.;
+ for(int l=0;l<NumberOfComponents;l++)
+ val[l] = 0.;
+ for(elemIt=listElements.begin();elemIt!=listElements.end();elemIt++){
+ int elem = *elemIt;
+ double vol = volume[ivol]->getValueIJ(elem,1);
+ if( vol != 0. ){
+ sigmaV += 1./vol;
+ for(int l=1;l<=NumberOfComponents;l++)
+ val[l-1] += myDField->getValueIJ(elem,l)/vol;
+ }
+ }
+ for(int l=1;l<=NumberOfComponents;l++)
+ newDField->setValueIJ(k,l,val[l-1]/sigmaV);
+ }
+ }
+ else{
+ const int *numb = newSup->getNumber(MED_ALL_ELEMENTS);
+ for (int k=1; k<=NumberOfNodes; k++){
+ int kk = numb[k-1];
+ // listElements contains elements which contains a node of element i
+ listElements.clear();
+ for(int l=indC[kk-1];l<indC[kk];l++){
+ // c element contains node k
+ int c=revC[l-1];
+ // add c element only if it is in partial support
+ ssIt = supset.find(c);
+ if(ssIt!=supset.end())
+ listElements.insert(c);
+ }
+
+ // calculate field value on node k
+ double sigmaV = 0.;
+ for(int l=0;l<NumberOfComponents;l++)
+ val[l] = 0.;
+ for(elemIt=listElements.begin();elemIt!=listElements.end();elemIt++){
+ int elem = *elemIt;
+ double vol = volume[ivol]->getValueIJ(elem,1);
+ if( vol != 0. ){
+ sigmaV += 1./vol;
+ for(int l=1;l<=NumberOfComponents;l++)
+ val[l-1] += myDField->getValueIJ(elem,l)/vol;
+ }
+ }
+ for(int l=1;l<=NumberOfComponents;l++)
+ newDField->setValueIJ(k,l,val[l-1]/sigmaV);
+ }
+ }
+ delete [] val;
+ int id = newDField->addDriver(MED_DRIVER,filenameOUT,FieldName[i],MED_EN::MED_ECRI);
+ newDField->write(id);
+ delete newSup;
+ delete newDField;
+ 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>(newSup,NumberOfComponents);
+ newIField->setName(myField->getName());
+ newIField->setIterationNumber(FieldIteration[j].dt);
+ newIField->setOrderNumber(FieldIteration[j].it);
+ newIField->setTime(myIField->getTime());
+ double *val = new double[NumberOfComponents];
+ if( newSup->isOnAllElements() ){
+ for (int k=1; k<NumberOfNodes+1; k++){
+ // listElements contains elements which contains a node of element i
+ listElements.clear();
+ for(int l=indC[k-1];l<indC[k];l++){
+ // c element contains node i
+ int c=revC[l-1];
+ listElements.insert(c);
+ }
+
+ // calculate field value on node k
+ double sigmaV = 0.;
+ for(int l=0;l<NumberOfComponents;l++)
+ val[l] = 0.;
+ for(elemIt=listElements.begin();elemIt!=listElements.end();elemIt++){
+ int elem = *elemIt;
+ double vol = volume[ivol]->getValueIJ(elem,1);
+ if( vol != 0. ){
+ sigmaV += 1./vol;
+ for(int l=1;l<=NumberOfComponents;l++)
+ val[l-1] += ((double)myIField->getValueIJ(elem,l))/vol;
+ }
+ }
+ for(int l=1;l<=NumberOfComponents;l++)
+ newIField->setValueIJ(k,l,(int)(val[l-1]/sigmaV));
+ }
+ }
+ else{
+ const int *numb = newSup->getNumber(MED_ALL_ELEMENTS);
+ for (int k=1; k<=NumberOfNodes; k++){
+ int kk = numb[k-1];
+ // listElements contains elements which contains a node of element i
+ listElements.clear();
+ for(int l=indC[kk-1];l<indC[kk];l++){
+ // c element contains node k
+ int c=revC[l-1];
+ // add c element only if it is in partial support
+ ssIt = supset.find(c);
+ if(ssIt!=supset.end())
+ listElements.insert(c);
+ }
+
+ // calculate field value on node k
+ double sigmaV = 0.;
+ for(int l=0;l<NumberOfComponents;l++)
+ val[l] = 0.;
+ for(elemIt=listElements.begin();elemIt!=listElements.end();elemIt++){
+ int elem = *elemIt;
+ double vol = volume[ivol]->getValueIJ(elem,1);
+ if( vol != 0. ){
+ sigmaV += 1./vol;
+ for(int l=1;l<=NumberOfComponents;l++)
+ val[l-1] += myIField->getValueIJ(elem,l)/vol;
+ }
+ }
+ for(int l=1;l<=NumberOfComponents;l++)
+ newIField->setValueIJ(k,l,(int)(val[l-1]/sigmaV));
+ }
+ }
+ delete [] val;
+ int id = newIField->addDriver(MED_DRIVER,filenameOUT,FieldName[i],MED_EN::MED_ECRI);
+ newIField->write(id);
+ delete newSup;
+ delete newIField;
+ cout << " * Iteration "<<FieldIteration[j].dt<<" and order number "<<FieldIteration[j].it<<" ) is written !" << endl;
+ }
+ }
break;
case MED_FACE:
cout << "*************************** CHAMP AUX FACES" << endl;