Back to index

salome-med  6.5.0
Public Member Functions | Private Member Functions | Private Attributes
MEDSPLITTER::MESHCollectionMedAsciiDriver Class Reference

#include <MEDSPLITTER_MESHCollectionMedAsciiDriver.hxx>

Collaboration diagram for MEDSPLITTER::MESHCollectionMedAsciiDriver:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 MESHCollectionMedAsciiDriver (MESHCollection *)
virtual ~MESHCollectionMedAsciiDriver ()
int read (char *, ParaDomainSelector *sel=0)
 reads a MED File v>=2.3 and mounts the corresponding meshes in memory the connect zones are created from the joints
void write (char *, ParaDomainSelector *sel=0)
 writes the collection of meshes in a MED v2.3 file with the connect zones being written as joints
void readFields (vector< MEDMEM::FIELD< int > * > &filenames, char *fieldname, int itnumber, int ordernumber)
void readFields (vector< MEDMEM::FIELD< double > * > &filenames, char *fieldname, int itnumber, int ordernumber)
void writeFields (vector< MEDMEM::FIELD< int > * > &filenames, char *fieldname)
void writeFields (vector< MEDMEM::FIELD< double > * > &filenames, char *fieldname)

Private Member Functions

template<class T >
void _readFields (vector< MEDMEM::FIELD< T > * > &filenames, char *fieldname, int itnumber, int ordernumber)
template<class T >
void _writeFields (vector< MEDMEM::FIELD< T > * > &filenames, char *fieldname)

Private Attributes

std::string _master_filename

Detailed Description

Definition at line 28 of file MEDSPLITTER_MESHCollectionMedAsciiDriver.hxx.


Constructor & Destructor Documentation

Definition at line 62 of file MEDSPLITTER_MESHCollectionMedAsciiDriver.cxx.

                                                                                    :MESHCollectionDriver(collection)
{
}

Definition at line 33 of file MEDSPLITTER_MESHCollectionMedAsciiDriver.hxx.

{}

Member Function Documentation

template<class T >
void MEDSPLITTER::MESHCollectionMedAsciiDriver::_readFields ( vector< MEDMEM::FIELD< T > * > &  filenames,
char *  fieldname,
int  itnumber,
int  ordernumber 
) [private]

Here is the caller graph for this function:

template<class T >
void MEDSPLITTER::MESHCollectionMedAsciiDriver::_writeFields ( vector< MEDMEM::FIELD< T > * > &  filenames,
char *  fieldname 
) [private]

Here is the caller graph for this function:

int MESHCollectionMedAsciiDriver::read ( char *  filename,
ParaDomainSelector *  domainSelector = 0 
)

reads a MED File v>=2.3 and mounts the corresponding meshes in memory the connect zones are created from the joints

Parameters:
filenameascii file containing the list of MED v2.3 files

Definition at line 73 of file MEDSPLITTER_MESHCollectionMedAsciiDriver.cxx.

{

  const char* LOC = "MEDSPLITTER::MESHCollectionDriver::read()";
  BEGIN_OF_MED(LOC);

  //ditributed meshes
  vector<int*> cellglobal;
  vector<int*> nodeglobal;
  vector<int*> faceglobal;

  int nbdomain;

  // reading ascii master file
  try{
    MESSAGE_MED("Start reading");
    ifstream asciiinput(filename);

    if (!asciiinput)     
      throw MEDEXCEPTION("MEDSPLITTER read - Master File does not exist");

    char charbuffer[512];
    asciiinput.getline(charbuffer,512);

    while (charbuffer[0]=='#')
    {
      asciiinput.getline(charbuffer,512);
    }

    //reading number of domains
    nbdomain=atoi(charbuffer);
    cout << "nb domain "<<nbdomain<<endl;
    //    asciiinput>>nbdomain;
    _filename.resize(nbdomain);
    _meshname.resize(nbdomain);
    (_collection->getMesh()).resize(nbdomain);
    cellglobal.resize(nbdomain);
    nodeglobal.resize(nbdomain);
    faceglobal.resize(nbdomain);

    if (nbdomain == 0)
      throw MEDEXCEPTION("Empty ASCII master file");
    for (int i=0; i<nbdomain;i++)
    {

      //reading information about the domain
      string mesh;
      int idomain;
      string host;
      cellglobal[i]=0;
      faceglobal[i]=0;
      nodeglobal[i]=0;

      asciiinput >> mesh >> idomain >> _meshname[i] >> host >> _filename[i];

      //Setting the name of the global mesh (which is the same
      //for all the subdomains)
      if (i==0)
        _collection->setName(mesh);

      if (idomain!=i+1)
      {
        cerr<<"Error : domain must be written from 1 to N in asciifile descriptor"<<endl;
        return 1;
      }
      if ( !domainSelector || domainSelector->isMyDomain(i))
        readSubdomain(cellglobal,faceglobal,nodeglobal, i);

    }//loop on domains
    MESSAGE_MED("end of read");
  }//of try
  catch(...)
  {
    cerr << "I/O error reading parallel MED file"<<endl;
    throw;
  }

  //creation of topology from mesh and connect zones
  ParallelTopology* aPT = new ParallelTopology
    ((_collection->getMesh()), (_collection->getCZ()), cellglobal, nodeglobal, faceglobal);
  _collection->setTopology(aPT);

  for (int i=0; i<nbdomain; i++)
  {
    if (cellglobal[i]!=0) delete[] cellglobal[i];
    if (nodeglobal[i]!=0) delete[] nodeglobal[i];
    if (faceglobal[i]!=0) delete[] faceglobal[i];
  }

  END_OF_MED(LOC);
  return 0;
}
void MEDSPLITTER::MESHCollectionMedAsciiDriver::readFields ( vector< MEDMEM::FIELD< int > * > &  filenames,
char *  fieldname,
int  itnumber,
int  ordernumber 
) [inline]

Definition at line 39 of file MEDSPLITTER_MESHCollectionMedAsciiDriver.hxx.

    {
      _readFields(filenames,fieldname,itnumber,ordernumber);
    }

Here is the call graph for this function:

void MEDSPLITTER::MESHCollectionMedAsciiDriver::readFields ( vector< MEDMEM::FIELD< double > * > &  filenames,
char *  fieldname,
int  itnumber,
int  ordernumber 
) [inline]

Definition at line 44 of file MEDSPLITTER_MESHCollectionMedAsciiDriver.hxx.

    {
      _readFields(filenames,fieldname,itnumber,ordernumber);
    }

Here is the call graph for this function:

void MESHCollectionMedAsciiDriver::write ( char *  filename,
ParaDomainSelector *  domainSelector = 0 
)

writes the collection of meshes in a MED v2.3 file with the connect zones being written as joints

Parameters:
filenamename of the ascii file containing the meshes description

Definition at line 172 of file MEDSPLITTER_MESHCollectionMedAsciiDriver.cxx.

{

  const char* LOC = "MEDSPLITTER::MESHCollectionDriver::write()";
  BEGIN_OF_MED(LOC);

  int nbdomains= _collection->getMesh().size();
  _filename.resize(nbdomains);

  //loop on the domains
  for (int idomain=0; idomain<nbdomains;idomain++)
  {
    char distfilename[256];

    ostringstream suffix;
    suffix << filename<< idomain+1 <<".med";

    strcpy(distfilename,suffix.str().c_str());

    _filename[idomain]=string(distfilename);

    MESSAGE_MED("File name "<<string(distfilename));

    if ( !domainSelector || domainSelector->isMyDomain( idomain ) )
    {
      if ( !_collection->getMesh()[idomain]->getConnectivityptr() ) continue;//empty domain

      int id=(_collection->getMesh())[idomain]->addDriver(MEDMEM::MED_DRIVER,distfilename,(_collection->getMesh())[idomain]->getName(),MED_EN::WRONLY);

      MESSAGE_MED("Start writing");
      (_collection->getMesh())[idomain]->write(id);

      writeSubdomain(idomain, nbdomains, distfilename, domainSelector);
    }
  }

  // write master file
  if ( !domainSelector || domainSelector->rank() == 0 )
  {
    ofstream file(filename);

    file <<"#MED Fichier V 2.3"<<" "<<endl;
    file <<"#"<<" "<<endl;
    file<<_collection->getMesh().size()<<" "<<endl;

    for (int idomain=0; idomain<nbdomains;idomain++)
      file << _collection->getName() <<" "<< idomain+1 << " "
           << (_collection->getMesh())[idomain]->getName() << " localhost "
           << _filename[idomain] << " "<<endl;
  }

  END_OF_MED(LOC);

}
void MEDSPLITTER::MESHCollectionMedAsciiDriver::writeFields ( vector< MEDMEM::FIELD< int > * > &  filenames,
char *  fieldname 
) [inline]

Definition at line 50 of file MEDSPLITTER_MESHCollectionMedAsciiDriver.hxx.

    {
      _writeFields( filenames, fieldname);
    }

Here is the call graph for this function:

void MEDSPLITTER::MESHCollectionMedAsciiDriver::writeFields ( vector< MEDMEM::FIELD< double > * > &  filenames,
char *  fieldname 
) [inline]

Definition at line 55 of file MEDSPLITTER_MESHCollectionMedAsciiDriver.hxx.

    {
      _writeFields( filenames, fieldname);
    }

Here is the call graph for this function:


Member Data Documentation

Definition at line 70 of file MEDSPLITTER_MESHCollectionMedAsciiDriver.hxx.


The documentation for this class was generated from the following files: