// TimeInterpolationMethod DECOptions::_timeInterpolationMethod=WithoutTimeInterp;
// bool DECOptions::_asynchronous = false;
// bool DECOptions::_forcedRenormalization = false;
-
+
// AllToAllMethod DECOptions::_allToAllMethod = Native;
- /*! \addtogroup dec
- @{
- */
+ /*! \addtogroup dec
+ @{
+ */
DEC::DEC(ProcessorGroup& source_group, ProcessorGroup& target_group):_local_field(0),
- _source_group(&source_group),
- _target_group(&target_group),
- _owns_field(false),
- _icoco_field(0)
+ _source_group(&source_group),
+ _target_group(&target_group),
+ _owns_field(false),
+ _icoco_field(0)
{
_union_group = source_group.fuse(target_group);
}
DEC::~DEC()
{
// delete _union_group;
- if (_owns_field)
- delete _local_field;
- delete _icoco_field;
+ if (_owns_field)
+ delete _local_field;
+ delete _icoco_field;
delete _union_group;
}
- /*! Attaches a local field to a DEC.
-If the processor is on the receiving end of the DEC, the field
-will be updated by a recvData() call.
-Reversely, if the processor is on the sending end, the field will be read, possibly transformed, and sent appropriately to the other side.
- */
- void DEC::attachLocalField(const ParaFIELD* field)
- {
- _local_field=field;
- _comm_interface=&(field->getTopology()->getProcGroup()->getCommInterface());
- }
-
- /*! Attaches a local field to a DEC. The method will test whether the processor
-is on the source or the target side and will associate the mesh underlying the
-field to the local side.
-
-If the processor is on the receiving end of the DEC, the field
-will be updated by a recvData() call.
-Reversely, if the processor is on the sending end, the field will be read, possibly transformed,
- and sent appropriately to the other side.
- */
-
- void DEC::attachLocalField(MEDMEM::FIELD<double>* field)
- {
- ProcessorGroup* local_group;
- if (_source_group->containsMyRank())
- local_group=_source_group;
- else if (_target_group->containsMyRank())
- local_group=_target_group;
- else
- throw MEDMEM::MEDEXCEPTION("Invalid procgroup for field attachment to DEC");
-
- _local_field= new ParaFIELD(field, *local_group);
- _owns_field=true;
- _comm_interface=&(local_group->getCommInterface());
- }
-
- /*!
- Attaches a local field to a DEC.
- If the processor is on the receiving end of the DEC, the field
- will be updated by a recvData() call.
- Reversely, if the processor is on the sending end, the field will be read, possibly transformed, and sent appropriately to the other side.
- The field type is a generic ICoCo Field, so that the DEC can couple a number of different fields :
- - a ICoCo::MEDField, that is created from a MEDMEM structure
- - a ICOCo::TrioField, that is created from tables extracted from a TRIO-U structure.
-
- */
-
- void DEC::attachLocalField(const ICoCo::Field* field)
- {
- const ICoCo::MEDField* medfield =dynamic_cast<const ICoCo::MEDField*> (field);
- if(medfield !=0)
- {
- attachLocalField(medfield->getField());
- return;
- }
- const ICoCo::TrioField* triofield=dynamic_cast<const ICoCo::TrioField*> (field);
- if (triofield !=0)
- {
- ProcessorGroup* localgroup;
- if (_source_group->containsMyRank()) localgroup=_source_group;
- else localgroup=_target_group;
- _icoco_field=new ICoCo::MEDField(*const_cast<ICoCo::TrioField* >(triofield), *localgroup);
- // _owns_field = true;
- attachLocalField(_icoco_field);
- return;
- }
- throw MEDMEM::MEDEXCEPTION("incompatible field type");
- }
-
- /*!
- Computes the field norm over its support
- on the source side and renormalizes the field on the target side
- so that the norms match.
+ /*! Attaches a local field to a DEC.
+ If the processor is on the receiving end of the DEC, the field
+ will be updated by a recvData() call.
+ Reversely, if the processor is on the sending end, the field will be read, possibly transformed, and sent appropriately to the other side.
+ */
+ void DEC::attachLocalField(const ParaFIELD* field)
+ {
+ _local_field=field;
+ _comm_interface=&(field->getTopology()->getProcGroup()->getCommInterface());
+ }
+
+ /*! Attaches a local field to a DEC. The method will test whether the processor
+ is on the source or the target side and will associate the mesh underlying the
+ field to the local side.
+
+ If the processor is on the receiving end of the DEC, the field
+ will be updated by a recvData() call.
+ Reversely, if the processor is on the sending end, the field will be read, possibly transformed,
+ and sent appropriately to the other side.
+ */
+
+ void DEC::attachLocalField(MEDMEM::FIELD<double>* field)
+ {
+ ProcessorGroup* local_group;
+ if (_source_group->containsMyRank())
+ local_group=_source_group;
+ else if (_target_group->containsMyRank())
+ local_group=_target_group;
+ else
+ throw MEDMEM::MEDEXCEPTION("Invalid procgroup for field attachment to DEC");
+
+ _local_field= new ParaFIELD(field, *local_group);
+ _owns_field=true;
+ _comm_interface=&(local_group->getCommInterface());
+ }
+
+ /*!
+ Attaches a local field to a DEC.
+ If the processor is on the receiving end of the DEC, the field
+ will be updated by a recvData() call.
+ Reversely, if the processor is on the sending end, the field will be read, possibly transformed, and sent appropriately to the other side.
+ The field type is a generic ICoCo Field, so that the DEC can couple a number of different fields :
+ - a ICoCo::MEDField, that is created from a MEDMEM structure
+ - a ICOCo::TrioField, that is created from tables extracted from a TRIO-U structure.
+
+ */
+
+ void DEC::attachLocalField(const ICoCo::Field* field)
+ {
+ const ICoCo::MEDField* medfield =dynamic_cast<const ICoCo::MEDField*> (field);
+ if(medfield !=0)
+ {
+ attachLocalField(medfield->getField());
+ return;
+ }
+ const ICoCo::TrioField* triofield=dynamic_cast<const ICoCo::TrioField*> (field);
+ if (triofield !=0)
+ {
+ ProcessorGroup* localgroup;
+ if (_source_group->containsMyRank()) localgroup=_source_group;
+ else localgroup=_target_group;
+ _icoco_field=new ICoCo::MEDField(*const_cast<ICoCo::TrioField* >(triofield), *localgroup);
+ // _owns_field = true;
+ attachLocalField(_icoco_field);
+ return;
+ }
+ throw MEDMEM::MEDEXCEPTION("incompatible field type");
+ }
+
+ /*!
+ Computes the field norm over its support
+ on the source side and renormalizes the field on the target side
+ so that the norms match.
\f[
I_{source}=\sum_{i=1}^{n_{source}}V_{i}.|\Phi^{source}_{i}|^2,
\f[
I_{target}=\sum_{i=1}^{n_{target}}V_{i}.|\Phi^{target}_{i}|^2,
\f]
-
+
\f[
\Phi^{target}:=\Phi^{target}.\sqrt{I_{source}/I_{target}}.
\f]
- */
- void DEC::renormalizeTargetField()
- {
- if (_source_group->containsMyRank())
- for (int icomp=0; icomp<_local_field->getField()->getNumberOfComponents(); icomp++)
- {
- double total_norm = _local_field->getVolumeIntegral(icomp+1);
- double source_norm = total_norm;
- _comm_interface->broadcast(&source_norm, 1, MPI_DOUBLE, 0,* dynamic_cast<MPIProcessorGroup*>(_union_group)->getComm());
-
- }
- if (_target_group->containsMyRank())
- {
- for (int icomp=0; icomp<_local_field->getField()->getNumberOfComponents(); icomp++)
- {
- double total_norm = _local_field->getVolumeIntegral(icomp+1);
- double source_norm=total_norm;
- _comm_interface->broadcast(&source_norm, 1, MPI_DOUBLE, 0,* dynamic_cast<MPIProcessorGroup*>(_union_group)->getComm());
-
- if (abs(total_norm)>1e-100)
- _local_field->getField()->applyLin(source_norm/total_norm,0.0,icomp+1);
- }
- }
- }
- /*! @} */
+ */
+ void DEC::renormalizeTargetField()
+ {
+ if (_source_group->containsMyRank())
+ for (int icomp=0; icomp<_local_field->getField()->getNumberOfComponents(); icomp++)
+ {
+ double total_norm = _local_field->getVolumeIntegral(icomp+1);
+ double source_norm = total_norm;
+ _comm_interface->broadcast(&source_norm, 1, MPI_DOUBLE, 0,* dynamic_cast<MPIProcessorGroup*>(_union_group)->getComm());
+
+ }
+ if (_target_group->containsMyRank())
+ {
+ for (int icomp=0; icomp<_local_field->getField()->getNumberOfComponents(); icomp++)
+ {
+ double total_norm = _local_field->getVolumeIntegral(icomp+1);
+ double source_norm=total_norm;
+ _comm_interface->broadcast(&source_norm, 1, MPI_DOUBLE, 0,* dynamic_cast<MPIProcessorGroup*>(_union_group)->getComm());
+
+ if (abs(total_norm)>1e-100)
+ _local_field->getField()->applyLin(source_norm/total_norm,0.0,icomp+1);
+ }
+ }
+ }
+ /*! @} */
}
ParaMESH::ParaMESH(MEDMEM::driverTypes driver_type, const string& filename,
const ProcessorGroup& group)
-throw (MEDMEM::MEDEXCEPTION) :_has_mesh_ownership(true) {
-
+throw (MEDMEM::MEDEXCEPTION) :_has_mesh_ownership(true)
+{
const char* LOC = "MEDSPLITTER::MESHCollectionDriver::read()";
BEGIN_OF(LOC);
-
-
+
+
string meshstring;
char file[256];
char meshname[MED_TAILLE_NOM];
int domain_id=group.myRank();
-
+
// reading ascii master file
try{
- MESSAGE("Start reading");
+ MESSAGE("Start reading");
ifstream asciiinput(filename.c_str());
char charbuffer[512];
asciiinput.getline(charbuffer,512);
-
+
while (charbuffer[0]=='#')
- {
- asciiinput.getline(charbuffer,512);
- }
+ {
+ asciiinput.getline(charbuffer,512);
+ }
//reading number of domains
int nbdomain=atoi(charbuffer);
cout << "nb domain"<<nbdomain<<endl;
// asciiinput>>nbdomain;
-
+
string mesh;
- int idomain;
- string host;
- string medfilename;
-
+ int idomain;
+ string host;
+ string medfilename;
+
for (int i=0; i<=domain_id;i++)
+ {
+ //reading information about the domain
+
+
+ asciiinput >> mesh >> idomain >> meshstring >> host >> medfilename;
+
+ if (idomain!=i+1)
{
- //reading information about the domain
-
-
- asciiinput >> mesh >> idomain >> meshstring >> host >> medfilename;
-
- if (idomain!=i+1)
- {
- cerr<<"Error : domain must be written from 1 to N in asciifile descriptor"<<endl;
- throw (MEDEXCEPTION("Error : domain must be written from 1 to N in asciifile descriptor"));
- }
- strcpy(meshname,meshstring.c_str());
- strcpy(file,medfilename.c_str());
+ cerr<<"Error : domain must be written from 1 to N in asciifile descriptor"<<endl;
+ throw (MEDEXCEPTION("Error : domain must be written from 1 to N in asciifile descriptor"));
}
+ strcpy(meshname,meshstring.c_str());
+ strcpy(file,medfilename.c_str());
+ }
_name=meshstring;
- ///////////////////////////////////////////
- // treatment of the domain that corresponds
- // to the local id
- ///////////////////////////////////////////
- _mesh=new MEDMEM::MESH(driver_type,file, meshname);
-
- //reading MEDSPLITTER::CONNECTZONEs NODE/NODE and CELL/CELL
- med_2_3::med_idt fid = med_2_3::MEDouvrir(file,med_2_3::MED_LECTURE);
- med_2_3::med_int njoint = med_2_3::MEDnJoint(fid, meshname);
- for (int ijoint=1; ijoint<=njoint; ijoint++)
- {
- int distant;
- char joint_description[MED_TAILLE_DESC];
- char name[MED_TAILLE_NOM];
- char name_distant[MED_TAILLE_NOM];
- // cout << "arguments"<< fid<<" "<<file<<" "<<ijoint<<" "<<name<<" "<<joint_description<<" "<<distant<<" "<<name_distant<<endl;
- int ncorr = med_2_3::MEDjointInfo(fid,meshname, ijoint, name,
- joint_description,
- &distant, name_distant);
- cout << "Found " << ncorr <<"correspondances in joint "<<ijoint<<endl;
-
- for (int ic=1; ic<=ncorr; ic++)
- {
- med_2_3::med_entite_maillage cor_typent_local;
- med_2_3::med_geometrie_element cor_typgeo_local;
- med_2_3::med_entite_maillage cor_typent_dist;
- med_2_3::med_geometrie_element cor_typgeo_dist;
-
-
- int ncouples;
- ncouples = med_2_3::MEDjointTypeCorres(fid, meshname, name, ic,
- &cor_typent_local, &cor_typgeo_local,
- &cor_typent_dist, &cor_typgeo_dist
- );
- int* node_corresp=new int[ncouples];
- if (cor_typent_local == med_2_3::MED_NOEUD && cor_typent_dist == med_2_3::MED_NOEUD)
- {
-
- med_2_3::MEDjointLire(fid, meshname, name,
- node_corresp,ncouples,
- cor_typent_local, cor_typgeo_local,
- cor_typent_dist, cor_typgeo_dist
- );
- }
- //constructing the connect zone and adding it to the connect zone list
- MEDMEM::CONNECTZONE* cz = new MEDMEM::CONNECTZONE();
- cz->setName(string(name));
- cz->setDescription(joint_description);
- cz->setLocalDomainNumber(domain_id);
- cz->setDistantDomainNumber(distant);
- //cz->setLocalMesh((m_collection->getMesh())[i]);
- //cz->setDistantMesh((m_collection->getMesh())[distant]);
- cz->setNodeCorresp(node_corresp,ncouples);
- _connect_zone.push_back(cz);
-
- }//loop on correspondances
- }//loop on joints
-
- //
- // Reading global numbering
- //
- int ncell=_mesh->getNumberOfElements(MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS);
- int * array=new int[ncell];
- int offset=0;
- MESSAGE("Reading cell global numbering for mesh "<< domain_id);
- MED_EN::MESH_ENTITIES::const_iterator currentEntity;
- list<MED_EN::medGeometryElement>::const_iterator iter;
- currentEntity = MED_EN::meshEntities.find(MED_EN::MED_CELL);
- char meshchar[MED_TAILLE_NOM];
- strcpy(meshchar,_mesh->getName().c_str());
- for (iter = (*currentEntity).second.begin();iter != (*currentEntity).second.end(); iter++)
- {
- MED_EN::medGeometryElement type=*iter;
- if (type/100 != _mesh->getMeshDimension()) continue;
- int ntype = _mesh->getNumberOfElements(MED_EN::MED_CELL,type);
- if (ntype==0) continue;
- med_2_3::MEDglobalNumLire(fid,meshname, array+offset, ntype,
- med_2_3::MED_MAILLE, (med_2_3::med_geometrie_element)type);
- offset+=ntype;
- }
- _cellglobal=array;
-
- MESSAGE("Reading node global numbering");
- int nnode= _mesh->getNumberOfNodes();
- array=new int[nnode];
- med_2_3::MEDglobalNumLire(fid,meshname, array, nnode,
- med_2_3::MED_NOEUD, med_2_3::MED_POINT1);
- _nodeglobal=array;
-
- MESSAGE("Reading face global numbering for mesh "<<domain_id);
- int nbface=_mesh->getNumberOfElements(MED_EN::MED_FACE,MED_EN::MED_ALL_ELEMENTS);
- array=new int[nbface];
- currentEntity = MED_EN::meshEntities.find(MED_EN::MED_FACE);
- offset=0;
- for (iter = (*currentEntity).second.begin();iter != (*currentEntity).second.end(); iter++)
- {
- MED_EN::medGeometryElement type=*iter;
- if (type/100 != _mesh->getMeshDimension()-1) continue;
- int ntype = _mesh->getNumberOfElements(MED_EN::MED_FACE,type);
- if (ntype==0) continue;
- med_2_3::MEDglobalNumLire(fid,meshname, array+offset, ntype,
- med_2_3::MED_FACE, (med_2_3::med_geometrie_element)type);
- offset+=ntype;
- }
- _faceglobal=array;
-// faceglobal[i]=0;
+ ///////////////////////////////////////////
+ // treatment of the domain that corresponds
+ // to the local id
+ ///////////////////////////////////////////
+ _mesh=new MEDMEM::MESH(driver_type,file, meshname);
+
+ //reading MEDSPLITTER::CONNECTZONEs NODE/NODE and CELL/CELL
+ med_2_3::med_idt fid = med_2_3::MEDouvrir(file,med_2_3::MED_LECTURE);
+ med_2_3::med_int njoint = med_2_3::MEDnJoint(fid, meshname);
+ for (int ijoint=1; ijoint<=njoint; ijoint++)
+ {
+ int distant;
+ char joint_description[MED_TAILLE_DESC];
+ char name[MED_TAILLE_NOM];
+ char name_distant[MED_TAILLE_NOM];
+ // cout << "arguments"<< fid<<" "<<file<<" "<<ijoint<<" "<<name<<" "<<joint_description<<" "<<distant<<" "<<name_distant<<endl;
+ int ncorr = med_2_3::MEDjointInfo(fid,meshname, ijoint, name,
+ joint_description,
+ &distant, name_distant);
+ cout << "Found " << ncorr <<"correspondances in joint "<<ijoint<<endl;
+
+ for (int ic=1; ic<=ncorr; ic++)
+ {
+ med_2_3::med_entite_maillage cor_typent_local;
+ med_2_3::med_geometrie_element cor_typgeo_local;
+ med_2_3::med_entite_maillage cor_typent_dist;
+ med_2_3::med_geometrie_element cor_typgeo_dist;
+
+
+ int ncouples;
+ ncouples = med_2_3::MEDjointTypeCorres(fid, meshname, name, ic,
+ &cor_typent_local, &cor_typgeo_local,
+ &cor_typent_dist, &cor_typgeo_dist
+ );
+ int* node_corresp=new int[ncouples];
+ if (cor_typent_local == med_2_3::MED_NOEUD && cor_typent_dist == med_2_3::MED_NOEUD)
+ {
+
+ med_2_3::MEDjointLire(fid, meshname, name,
+ node_corresp,ncouples,
+ cor_typent_local, cor_typgeo_local,
+ cor_typent_dist, cor_typgeo_dist
+ );
+ }
+ //constructing the connect zone and adding it to the connect zone list
+ MEDMEM::CONNECTZONE* cz = new MEDMEM::CONNECTZONE();
+ cz->setName(string(name));
+ cz->setDescription(joint_description);
+ cz->setLocalDomainNumber(domain_id);
+ cz->setDistantDomainNumber(distant);
+ //cz->setLocalMesh((m_collection->getMesh())[i]);
+ //cz->setDistantMesh((m_collection->getMesh())[distant]);
+ cz->setNodeCorresp(node_corresp,ncouples);
+ _connect_zone.push_back(cz);
+
+ }//loop on correspondances
+ }//loop on joints
+
+ //
+ // Reading global numbering
+ //
+ int ncell=_mesh->getNumberOfElements(MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS);
+ int * array=new int[ncell];
+ int offset=0;
+ MESSAGE("Reading cell global numbering for mesh "<< domain_id);
+ MED_EN::MESH_ENTITIES::const_iterator currentEntity;
+ list<MED_EN::medGeometryElement>::const_iterator iter;
+ currentEntity = MED_EN::meshEntities.find(MED_EN::MED_CELL);
+ char meshchar[MED_TAILLE_NOM];
+ strcpy(meshchar,_mesh->getName().c_str());
+ for (iter = (*currentEntity).second.begin();iter != (*currentEntity).second.end(); iter++)
+ {
+ MED_EN::medGeometryElement type=*iter;
+ if (type/100 != _mesh->getMeshDimension()) continue;
+ int ntype = _mesh->getNumberOfElements(MED_EN::MED_CELL,type);
+ if (ntype==0) continue;
+ med_2_3::MEDglobalNumLire(fid,meshname, array+offset, ntype,
+ med_2_3::MED_MAILLE, (med_2_3::med_geometrie_element)type);
+ offset+=ntype;
+ }
+ _cellglobal=array;
+
+ MESSAGE("Reading node global numbering");
+ int nnode= _mesh->getNumberOfNodes();
+ array=new int[nnode];
+ med_2_3::MEDglobalNumLire(fid,meshname, array, nnode,
+ med_2_3::MED_NOEUD, med_2_3::MED_POINT1);
+ _nodeglobal=array;
+
+ MESSAGE("Reading face global numbering for mesh "<<domain_id);
+ int nbface=_mesh->getNumberOfElements(MED_EN::MED_FACE,MED_EN::MED_ALL_ELEMENTS);
+ array=new int[nbface];
+ currentEntity = MED_EN::meshEntities.find(MED_EN::MED_FACE);
+ offset=0;
+ for (iter = (*currentEntity).second.begin();iter != (*currentEntity).second.end(); iter++)
+ {
+ MED_EN::medGeometryElement type=*iter;
+ if (type/100 != _mesh->getMeshDimension()-1) continue;
+ int ntype = _mesh->getNumberOfElements(MED_EN::MED_FACE,type);
+ if (ntype==0) continue;
+ med_2_3::MEDglobalNumLire(fid,meshname, array+offset, ntype,
+ med_2_3::MED_FACE, (med_2_3::med_geometrie_element)type);
+ offset+=ntype;
+ }
+ _faceglobal=array;
+ // faceglobal[i]=0;
med_2_3::MEDfermer(fid);
-
+
_block_topology=new BlockTopology(group,ncell);
-
- MESSAGE("end of read");
-
+
+ MESSAGE("end of read");
+
}//of try
catch(...)
- {
- cerr << "I/O error reading parallel MED file"<<endl;
- throw;
- }
-
-
+ {
+ cerr << "I/O error reading parallel MED file"<<endl;
+ throw;
+ }
+
+
//creation of topology from mesh and connect zones
//m_collection->setTopology(
- // new ParallelTopology((m_collection->getMesh()),(m_collection->getCZ()),cellglobal,nodeglobal,faceglobal)
- // );
-
- END_OF("MEDSPLITTER::MESHCollectionDriver::read()")
-};
+ // new ParallelTopology((m_collection->getMesh()),(m_collection->getCZ()),cellglobal,nodeglobal,faceglobal)
+ // );
+
+ END_OF(LOC);
+}
/*! Constructor for creating a ParaMESH from a local mesh and
* a processor group. Constructor must be called by all the processors
* in the group. */
ParaMESH::ParaMESH(MEDMEM::MESH& subdomain_mesh, const ProcessorGroup& proc_group, const string& name):
-_mesh(&subdomain_mesh),
-_my_domain_id(proc_group.myRank()),
-_block_topology (new BlockTopology(proc_group, subdomain_mesh.getNumberOfElements(MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS))),
-_has_mesh_ownership(false)
+ _mesh(&subdomain_mesh),
+ _my_domain_id(proc_group.myRank()),
+ _block_topology (new BlockTopology(proc_group, subdomain_mesh.getNumberOfElements(MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS))),
+ _has_mesh_ownership(false)
{
- ostringstream stream;
- stream<<name<<"_"<<_my_domain_id+1;
- _name=stream.str();
+ ostringstream stream;
+ stream<<name<<"_"<<_my_domain_id+1;
+ _name=stream.str();
_cellglobal = new int[subdomain_mesh.getNumberOfElements(MED_EN::MED_CELL, MED_EN::MED_ALL_ELEMENTS)];
int offset = _block_topology->localToGlobal(make_pair(_my_domain_id,0));
for (int i=0; i<subdomain_mesh.getNumberOfElements(MED_EN::MED_CELL, MED_EN::MED_ALL_ELEMENTS); i++)
- {
- _cellglobal[i]=offset+i;
- }
+ {
+ _cellglobal[i]=offset+i;
+ }
}
*/
void ParaMESH::write(MEDMEM::driverTypes driverType, const string& master_filename)
-throw (MEDMEM::MEDEXCEPTION){
-
+throw (MEDMEM::MEDEXCEPTION)
+{
const char* LOC = "ParaMEDMEM::ParaMESH::write()";
BEGIN_OF(LOC);
-
- if (!_block_topology->getProcGroup()->containsMyRank()) return;
-
- int myrank=_block_topology->getProcGroup()->myRank();
- cout << "Myrank in write " << myrank<<endl;
-
- int nbdomains= _block_topology->getProcGroup()->size();
- vector<string> filename(nbdomains);
-
- //loop on the domains
- for (int i=0; i<nbdomains;i++)
- {
- char distfilename[256];
-
- ostringstream suffix;
-
- suffix << master_filename<< i+1 <<".med";
-
- strcpy(distfilename,suffix.str().c_str());
- filename[i]=string(distfilename);
- MESSAGE("File name "<<string(distfilename));
- }
-
- //creation of the master file by proc 0 on ProgGroup
- if (myrank==0)
- {
- MESSAGE("Master File Name "<<master_filename);
- ofstream file(master_filename.c_str());
- if (!file) throw (MEDEXCEPTION("Unable to create master file"));
- file <<"#MED Fichier V 2.3"<<" "<<endl;
- file <<"#"<<" "<<endl;
- file<<nbdomains<<" "<<endl;
- for (int i=0; i<nbdomains;i++)
- {
- //updating the ascii description file
- file << _name <<" "<< i+1 << " "<< _name <<"_"<<i+1<< " localhost " << filename[i] << " "<<endl;
- }
-
- }
-
- int id=_mesh->addDriver(MEDMEM::MED_DRIVER,filename[myrank],_name);
-
- MESSAGE("Start writing");
- _mesh->write(id);
- _mesh->rmDriver(id);
- END_OF("ParaMEDMEM::ParaMESH::write()");
+
+ if (!_block_topology->getProcGroup()->containsMyRank()) return;
+
+ int myrank=_block_topology->getProcGroup()->myRank();
+ cout << "Myrank in write " << myrank<<endl;
+
+ int nbdomains= _block_topology->getProcGroup()->size();
+ vector<string> filename(nbdomains);
+
+ //loop on the domains
+ for (int i=0; i<nbdomains;i++)
+ {
+ char distfilename[256];
+
+ ostringstream suffix;
+
+ suffix << master_filename<< i+1 <<".med";
+
+ strcpy(distfilename,suffix.str().c_str());
+ filename[i]=string(distfilename);
+ MESSAGE("File name "<<string(distfilename));
+ }
+
+ //creation of the master file by proc 0 on ProgGroup
+ if (myrank==0)
+ {
+ MESSAGE("Master File Name "<<master_filename);
+ ofstream file(master_filename.c_str());
+ if (!file) throw (MEDEXCEPTION("Unable to create master file"));
+ file <<"#MED Fichier V 2.3"<<" "<<endl;
+ file <<"#"<<" "<<endl;
+ file<<nbdomains<<" "<<endl;
+ for (int i=0; i<nbdomains;i++)
+ {
+ //updating the ascii description file
+ file << _name <<" "<< i+1 << " "<< _name <<"_"<<i+1<< " localhost " << filename[i] << " "<<endl;
+ }
+
+ }
+
+ int id=_mesh->addDriver(MEDMEM::MED_DRIVER,filename[myrank],_name);
+
+ MESSAGE("Start writing");
+ _mesh->write(id);
+ _mesh->rmDriver(id);
+ END_OF(LOC);
};
const int* ParaMESH::getGlobalNumbering(const MED_EN::medEntityMesh entity)const
{
- switch (entity)
- {
- case MED_CELL:
- return _cellglobal;
- case MED_FACE :
- return _faceglobal;
- case MED_EDGE :
- return _edgeglobal;
- case MED_NODE:
- return _nodeglobal;
- default :
- return 0;
- }
+ switch (entity)
+ {
+ case MED_CELL:
+ return _cellglobal;
+ case MED_FACE :
+ return _faceglobal;
+ case MED_EDGE :
+ return _edgeglobal;
+ case MED_NODE:
+ return _nodeglobal;
+ default :
+ return 0;
+ }
}
}