int NomberOfNodesPerCell = Types[i]%100 ;
const int * Connectivity =
myMesh.getConnectivity(MED_FULL_INTERLACE,
- MED_NODAL,
- MED_CELL,
- myType);
+ MED_NODAL,
+ MED_CELL,
+ myType);
for (int j=0; j<NumberOfElements; j++){
cout << "Element "<< j+1 <<" : " ;
for (int k=0; k<NomberOfNodesPerCell; k++)
- cout << Connectivity[j*NomberOfNodesPerCell+k]<<" ";
+ cout << Connectivity[j*NomberOfNodesPerCell+k]<<" ";
cout << endl ;
}
}
int NumberOfElements = myMesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS);
const int * DescendingConnectivity =
myMesh.getConnectivity(MED_FULL_INTERLACE,
- MED_DESCENDING,
- MED_CELL,
- MED_ALL_ELEMENTS);
+ MED_DESCENDING,
+ MED_CELL,
+ MED_ALL_ELEMENTS);
const int * DescendingConnectivityIndex =
myMesh.getConnectivityIndex(MED_DESCENDING,MED_CELL);
for (int i=0; i<NumberOfElements; i++) {
int IndexEnd = ReverseDescendingConnectivityIndex[i+1] ;
for (int j=IndexBegin;j<IndexEnd;j++)
// Index value begin at 1 so use j-1
- cout << ReverseDescendingConnectivity[j-1] << " " ;
+ cout << ReverseDescendingConnectivity[j-1] << " " ;
cout << endl ;
}
}
// this example use global access with index array
const int * ConstituentConnectivity =
myMesh.getConnectivity(MED_FULL_INTERLACE,
- MED_NODAL,
- ConstituentEntity,
- MED_ALL_ELEMENTS);
+ MED_NODAL,
+ ConstituentEntity,
+ MED_ALL_ELEMENTS);
const int * ConstituentConnectivityIndex =
myMesh.getConnectivityIndex(MED_NODAL,ConstituentEntity);
for (int i=0; i<NumberOfConstituents; i++) {
int IndexBegin = ConnectivityIndex[j];
int IndexEnd = ConnectivityIndex[j+1];
for (int k=IndexBegin; k<IndexEnd; k++)
- cout << Connectivity[k-1]<<" ";
+ cout << Connectivity[k-1]<<" ";
cout << endl ;
}
}
string Name = myMesh.getName() ;
if (Name != MeshName) {
cout << "Error when reading mesh name : We ask for mesh #"
- << MeshName <<"# and we get mesh #"<< Name <<"#"<< endl << endl ;
+ << MeshName <<"# and we get mesh #"<< Name <<"#"<< endl << endl ;
return -1;
}
_coeffs(0), _cols(0), _is_configured(false)
{
_nb_rows=matrix.size();
- _auxiliary_matrix.resize(_nb_rows);
+ _auxiliary_matrix.resize(_nb_rows);
for (int i=0; i<_nb_rows; i++)
{
- typename std::map<int,T>::iterator it;
+ typename std::map<int,T>::iterator it;
for (it=matrix[i].begin(); it != matrix[i].end(); it++)
_auxiliary_matrix[i].push_back(*it);//MN: pq push_back plutot que simple affectation?
}
/*!
Matrix multiplies vector \a input and stores the result in
vector \a output.
- input and output are supposed to represent the same field
- discretised on two different on meshes.
- nb_comp is the number of components of the fields input and output
+ input and output are supposed to represent the same field
+ discretised on two different on meshes.
+ nb_comp is the number of components of the fields input and output
The vector pointed by \a input must be dimensioned
to the number of columns times nb_comp while the vector pointed by output must be
dimensioned to the number of rows times nb_comp.
output[i]=0;
for (unsigned int j=_ncols_offset[i]; j< _ncols_offset[i+1]; j++) {
int icol = _cols[j];
- for(int comp = 0; comp < nb_comp; comp++)
- output[i*nb_comp+comp]+=input[icol*nb_comp+comp]*_coeffs[j];
+ for(int comp = 0; comp < nb_comp; comp++)
+ output[i*nb_comp+comp]+=input[icol*nb_comp+comp]*_coeffs[j];
}
}
}
- /*!
+ /*!
Transpose-multiplies vector \a input and stores the result in
vector \a output.
- nb_cols is the number of columns of the matrix, (it is not an attribute of the class)
+ nb_cols is the number of columns of the matrix, (it is not an attribute of the class)
The vector pointed by \a input must be dimensioned
to the number of lines _nb_rows while the vector pointed by output must be
dimensioned to the number of columns nb_cols.
if (!_is_configured)
configure();
- for (int icol=0; icol< nb_cols; icol++)
- output[icol]=0.;
+ for (int icol=0; icol< nb_cols; icol++)
+ output[icol]=0.;
for (int i=0; i< _nb_rows; i++)
{
- for (unsigned int j=_ncols_offset[i]; j< _ncols_offset[i+1]; j++) {
+ for (unsigned int j=_ncols_offset[i]; j< _ncols_offset[i+1]; j++) {
int icol = _cols[j];
output[icol]+=input[i]*_coeffs[j];
}
}
}
- /*!
+ /*!
Transpose-multiplies vector \a input and stores the result in
vector \a output.
- input and output are supposed to represent the same field
- discretised on two different on meshes.
- nb_comp is the number of components of the fields input and output
- nb_cols is the number of columns of the matrix, (it is not an attribute of the class)
+ input and output are supposed to represent the same field
+ discretised on two different on meshes.
+ nb_comp is the number of components of the fields input and output
+ nb_cols is the number of columns of the matrix, (it is not an attribute of the class)
The vector pointed by \a input must be dimensioned
to _nb_rows*nb_comp while the vector pointed by output must be
dimensioned to nb_cols*nb_comp.
if (!_is_configured)
configure();
- for (int icol=0; icol< nb_cols; icol++)
- output[icol]=0.;
+ for (int icol=0; icol< nb_cols; icol++)
+ output[icol]=0.;
for (int i=0; i< _nb_rows; i++)
{
- for (unsigned int j=_ncols_offset[i]; j< _ncols_offset[i+1]; j++) {
+ for (unsigned int j=_ncols_offset[i]; j< _ncols_offset[i+1]; j++) {
int icol = _cols[j];
- for(int comp = 0; comp < nb_comp; comp++)
- output[icol*nb_comp+comp]+=input[i*nb_comp+comp]*_coeffs[j];
+ for(int comp = 0; comp < nb_comp; comp++)
+ output[icol*nb_comp+comp]+=input[i*nb_comp+comp]*_coeffs[j];
}
}
}
-
+
/*
- Sums the coefficients of each column of the matrix
- nb_cols is the number of columns of the matrix, (it is not an attribute of the class)
- The vector output must be dimensioned to nb_cols
- */
- void colSum(std::vector< T >& output, int nb_cols)
- {
- if (!_is_configured)
+ Sums the coefficients of each column of the matrix
+ nb_cols is the number of columns of the matrix, (it is not an attribute of the class)
+ The vector output must be dimensioned to nb_cols
+ */
+ void colSum(std::vector< T >& output, int nb_cols)
+ {
+ if (!_is_configured)
configure();
-
- for (int icol=0; icol< nb_cols; icol++)
- output[icol]=0.;
+
+ for (int icol=0; icol< nb_cols; icol++)
+ output[icol]=0.;
for (int i=0; i< _nb_rows; i++)
{
- for (unsigned int j=_ncols_offset[i]; j< _ncols_offset[i+1]; j++) {
+ for (unsigned int j=_ncols_offset[i]; j< _ncols_offset[i+1]; j++) {
int icol = _cols[j];
output[icol]+=_coeffs[j];
}
}
- }
+ }
- /*
- Sums the coefficients of each row of the matrix
- The vector output must be dimensioned to _nb_rows
- */
- void rowSum(std::vector< T >& output)
- {
- if (!_is_configured)
+ /*
+ Sums the coefficients of each row of the matrix
+ The vector output must be dimensioned to _nb_rows
+ */
+ void rowSum(std::vector< T >& output)
+ {
+ if (!_is_configured)
configure();
-
- for (int i=0; i< _nb_rows; i++)
+
+ for (int i=0; i< _nb_rows; i++)
{
output[i]=0;
for (unsigned int j=_ncols_offset[i]; j< _ncols_offset[i+1]; j++)
output[i]+=_coeffs[j];
- }
- }
+ }
+ }
- /*! This operation freezes the profile of the matrix
+ /*! This operation freezes the profile of the matrix
and puts it under a CSR form so that it becomes
efficient both in terms of memory occupation and
in terms of multiplication */
return _auxiliary_matrix[irow];
}
- int getNbRows()
- {
- return _nb_rows;
- }
+ int getNbRows()
+ {
+ return _nb_rows;
+ }
};
bool intersects = (bbtemp[idim*2]<bb2[idim*2+1])
&& (bb2[idim*2]<bbtemp[idim*2+1]) ;
if (!intersects)
- {
- delete [] bbtemp;
- return false;
- }
+ {
+ delete [] bbtemp;
+ return false;
+ }
}
delete [] bbtemp;
return true;
MEDCouplingUMesh *MEDCouplingBasicsTest::build3DTargetMesh_1()
{
double targetCoords[81]={ 0., 0., 0., 50., 0., 0. , 200., 0., 0. , 0., 50., 0., 50., 50., 0. , 200., 50., 0., 0., 200., 0., 50., 200., 0. , 200., 200., 0. ,
- 0., 0., 50., 50., 0., 50. , 200., 0., 50. , 0., 50., 50., 50., 50., 50. , 200., 50., 50., 0., 200., 50., 50., 200., 50. , 200., 200., 50. ,
- 0., 0., 200., 50., 0., 200. , 200., 0., 200. , 0., 50., 200., 50., 50., 200. , 200., 50., 200., 0., 200., 200., 50., 200., 200. , 200., 200., 200. };
+ 0., 0., 50., 50., 0., 50. , 200., 0., 50. , 0., 50., 50., 50., 50., 50. , 200., 50., 50., 0., 200., 50., 50., 200., 50. , 200., 200., 50. ,
+ 0., 0., 200., 50., 0., 200. , 200., 0., 200. , 0., 50., 200., 50., 50., 200. , 200., 50., 200., 0., 200., 200., 50., 200., 200. , 200., 200., 200. };
int targetConn[64]={0,1,4,3,9,10,13,12, 1,2,5,4,10,11,14,13, 3,4,7,6,12,13,16,15, 4,5,8,7,13,14,17,16,
- 9,10,13,12,18,19,22,21, 10,11,14,13,19,20,23,22, 12,13,16,15,21,22,25,24, 13,14,17,16,22,23,26,25};
+ 9,10,13,12,18,19,22,21, 10,11,14,13,19,20,23,22, 12,13,16,15,21,22,25,24, 13,14,17,16,22,23,26,25};
MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
targetMesh->setMeshDimension(3);
targetMesh->allocateCells(12);
char *attdes=new char[MED_TAILLE_DESC*natt+1];
char *gro=new char[MED_TAILLE_LNOM*ngro+1];
MEDfamInfo(fid,(char *)meshName,i+1,nomfam,&numfam,attide,attval,attdes,&natt,gro,&ngro);
- for(int j=0;j<ngro;j++)
- {
- std::string cur=buildStringFromFortran(gro+j*MED_TAILLE_LNOM,MED_TAILLE_LNOM);
- if(std::find(ret.begin(),ret.end(),cur)==ret.end())
- ret.push_back(cur);
- }
+ for(int j=0;j<ngro;j++)
+ {
+ std::string cur=buildStringFromFortran(gro+j*MED_TAILLE_LNOM,MED_TAILLE_LNOM);
+ if(std::find(ret.begin(),ret.end(),cur)==ret.end())
+ ret.push_back(cur);
+ }
delete [] attdes;
delete [] gro;
delete [] attide;
char *gro=new char[MED_TAILLE_LNOM*ngro+1];
MEDfamInfo(fid,(char *)meshName,i+1,nomfam,&numfam,attide,attval,attdes,&natt,gro,&ngro);
std::string cur=buildStringFromFortran(nomfam,sizeof(nomfam));
- if(std::find(fams.begin(),fams.end(),cur)!=fams.end())
- ret.push_back(numfam);
+ if(std::find(fams.begin(),fams.end(),cur)!=fams.end())
+ ret.push_back(numfam);
delete [] attdes;
delete [] gro;
delete [] attide;
char *gro=new char[MED_TAILLE_LNOM*ngro+1];
MEDfamInfo(fid,(char *)meshName,i+1,nomfam,&numfam,attide,attval,attdes,&natt,gro,&ngro);
std::string cur=buildStringFromFortran(nomfam,sizeof(nomfam));
- for(int j=0;j<ngro;j++)
- {
- std::string cur=buildStringFromFortran(gro+j*MED_TAILLE_LNOM,MED_TAILLE_LNOM);
- if(std::find(grps.begin(),grps.end(),cur)!=grps.end())
- {
- ret.push_back(numfam);
- break;
- }
- }
+ for(int j=0;j<ngro;j++)
+ {
+ std::string cur=buildStringFromFortran(gro+j*MED_TAILLE_LNOM,MED_TAILLE_LNOM);
+ if(std::find(grps.begin(),grps.end(),cur)!=grps.end())
+ {
+ ret.push_back(numfam);
+ break;
+ }
+ }
delete [] attdes;
delete [] gro;
delete [] attide;
unsigned ret=0;
for(typename std::list<T>::const_iterator iter=conn.begin();iter!=conn.end();iter++)
{
- unsigned curDim=INTERP_KERNEL::CellModel::getCellModel((*iter).getType()).getDimension();
- if(ret<curDim)
- ret=curDim;
+ unsigned curDim=INTERP_KERNEL::CellModel::getCellModel((*iter).getType()).getDimension();
+ if(ret<curDim)
+ ret=curDim;
}
return ret;
}
{
for(typename std::list<T>::iterator iter=conn.begin();iter!=conn.end();)
{
- unsigned curDim=INTERP_KERNEL::CellModel::getCellModel((*iter).getType()).getDimension();
- if(curDim!=meshDim)
- {
- (*iter).releaseArray();
- iter=conn.erase(iter);
- }
- else
- iter++;
+ unsigned curDim=INTERP_KERNEL::CellModel::getCellModel((*iter).getType()).getDimension();
+ if(curDim!=meshDim)
+ {
+ (*iter).releaseArray();
+ iter=conn.erase(iter);
+ }
+ else
+ iter++;
}
}
};
void tradMEDFileCoreFrmt2MEDCouplingUMesh(const std::list<MEDLoader::MEDConnOfOneElemType>& medConnFrmt,
- DataArrayInt* &conn,
- DataArrayInt* &connIndex,
- const std::vector<int>& familiesToKeep)
+ DataArrayInt* &conn,
+ DataArrayInt* &connIndex,
+ const std::vector<int>& familiesToKeep)
{
bool keepAll=familiesToKeep.empty();
if(medConnFrmt.empty())
{
- conn=0;
- connIndex=0;
- return ;
+ conn=0;
+ connIndex=0;
+ return ;
}
std::list<MEDLoader::MEDConnOfOneElemType>::const_iterator iter=medConnFrmt.begin();
int totalNbOfCells=0;
int totalNbOfMedConn=0;
for(;iter!=medConnFrmt.end();iter++)
{
- const INTERP_KERNEL::CellModel& cellMod=INTERP_KERNEL::CellModel::getCellModel((*iter).getType());
- if(keepAll)
+ const INTERP_KERNEL::CellModel& cellMod=INTERP_KERNEL::CellModel::getCellModel((*iter).getType());
+ if(keepAll)
totalNbOfCells+=(*iter).getLength();
- else
- for(std::vector<int>::const_iterator iter2=familiesToKeep.begin();iter2!=familiesToKeep.end();iter2++)
+ else
+ for(std::vector<int>::const_iterator iter2=familiesToKeep.begin();iter2!=familiesToKeep.end();iter2++)
totalNbOfCells+=std::count((*iter).getFam(),(*iter).getFam()+(*iter).getLength(),*iter2);
- if(!cellMod.isDynamic())
- if(keepAll)
- totalNbOfMedConn+=(*iter).getLength()*cellMod.getNumberOfNodes();
- else
- for(std::vector<int>::const_iterator iter2=familiesToKeep.begin();iter2!=familiesToKeep.end();iter2++)
- totalNbOfMedConn+=std::count((*iter).getFam(),(*iter).getFam()+(*iter).getLength(),*iter2)*cellMod.getNumberOfNodes();
- else
+ if(!cellMod.isDynamic())
+ if(keepAll)
+ totalNbOfMedConn+=(*iter).getLength()*cellMod.getNumberOfNodes();
+ else
+ for(std::vector<int>::const_iterator iter2=familiesToKeep.begin();iter2!=familiesToKeep.end();iter2++)
+ totalNbOfMedConn+=std::count((*iter).getFam(),(*iter).getFam()+(*iter).getLength(),*iter2)*cellMod.getNumberOfNodes();
+ else
if(keepAll)
totalNbOfMedConn+=(*iter).getConnLength();
else
int *connPtr=conn->getPointer();
for(iter=medConnFrmt.begin();iter!=medConnFrmt.end();iter++)
{
- INTERP_KERNEL::NormalizedCellType type=(*iter).getType();
- const int *sourceConn=(*iter).getArray();
+ INTERP_KERNEL::NormalizedCellType type=(*iter).getType();
+ const int *sourceConn=(*iter).getArray();
const int *sourceIndex=(*iter).getIndex();
- const INTERP_KERNEL::CellModel& cellMod=INTERP_KERNEL::CellModel::getCellModel(type);
- int nbOfCellsInCurType;
- int nbOfNodesIn1Cell=cellMod.getNumberOfNodes();
+ const INTERP_KERNEL::CellModel& cellMod=INTERP_KERNEL::CellModel::getCellModel(type);
+ int nbOfCellsInCurType;
+ int nbOfNodesIn1Cell=cellMod.getNumberOfNodes();
nbOfCellsInCurType=(*iter).getLength();
bool isDyn=cellMod.isDynamic();
int *tmpConnPtr;
const int *connIdxPtr=connIndex->getPointer();
for(int i=0;i<nbOfElem;i++)
{
- int delta=connIdxPtr[1]-connIdxPtr[0];
- if(*connPtr==type)
- {
- conn4MEDFile.insert(conn4MEDFile.end(),connPtr+1,connPtr+delta);
- ret++;
+ int delta=connIdxPtr[1]-connIdxPtr[0];
+ if(*connPtr==type)
+ {
+ conn4MEDFile.insert(conn4MEDFile.end(),connPtr+1,connPtr+delta);
+ ret++;
}
- connIdxPtr++;
- connPtr+=delta;
+ connIdxPtr++;
+ connPtr+=delta;
}
std::transform(conn4MEDFile.begin(),conn4MEDFile.end(),conn4MEDFile.begin(),std::bind2nd(std::plus<int>(),1));
return ret;
for(int i=0;i<nbOfElem;i++)
{
int delta=connIdxPtr[1]-connIdxPtr[0];
- if(*connPtr==INTERP_KERNEL::NORM_POLYGON)
- {
- conn4MEDFile.insert(conn4MEDFile.end(),connPtr+1,connPtr+delta);
+ if(*connPtr==INTERP_KERNEL::NORM_POLYGON)
+ {
+ conn4MEDFile.insert(conn4MEDFile.end(),connPtr+1,connPtr+delta);
connIndex4MEDFile.push_back(connIndex4MEDFile.back()+delta-1);
- ret++;
+ ret++;
}
connIdxPtr++;
- connPtr+=delta;
+ connPtr+=delta;
}
std::transform(conn4MEDFile.begin(),conn4MEDFile.end(),conn4MEDFile.begin(),std::bind2nd(std::plus<int>(),1));
return ret;
{
int my_stop;
int my_stop_temp = stop?1:0;
-
+
if (s==sync_and)
MPI_Allreduce(&my_stop_temp,&my_stop,1,MPI_INTEGER,MPI_MIN,MPI_COMM_WORLD);
else if (s==sync_or)
for (int i=4;i<8;i++)
{
for (int d=0;d<3;d++)
- coords[i*3+d]=coords[(i-4)*3+d];
+ coords[i*3+d]=coords[(i-4)*3+d];
coords[i*3+1]+=1e-5;
}
{
champ_emetteur._field=new double[champ_emetteur._nb_elems];
for (int ele=0;ele<champ_emetteur._nb_elems;ele++)
- champ_emetteur._field[ele]=1;
+ champ_emetteur._field[ele]=1;
champ_emetteur._has_field_ownership=true;
}
cout << compti << " CLOCK " << (clocki-clock0)*1.e-6 << endl;
for (int non_unif=0;non_unif<2;non_unif++)
{
- // if (champ_recepteur._field)
- // delete [] champ_recepteur._field;
- champ_recepteur._field=0;
- // champ_recepteur._has_field_ownership=false;
+ // if (champ_recepteur._field)
+ // delete [] champ_recepteur._field;
+ champ_recepteur._field=0;
+ // champ_recepteur._has_field_ownership=false;
- if (cas=="emetteur")
- if (non_unif)
- champ_emetteur._field[0]=40;
- bool ok=false; // Is the time interval successfully solved ?
+ if (cas=="emetteur")
+ if (non_unif)
+ champ_emetteur._field[0]=40;
+ bool ok=false; // Is the time interval successfully solved ?
- // Loop on the time interval tries
- if(1) {
+ // Loop on the time interval tries
+ if(1) {
- if (cas=="emetteur")
- dec_emetteur.attachLocalField((ICoCo::Field*) &champ_emetteur);
- else
- dec_emetteur.attachLocalField((ICoCo::Field*) &champ_recepteur);
+ if (cas=="emetteur")
+ dec_emetteur.attachLocalField((ICoCo::Field*) &champ_emetteur);
+ else
+ dec_emetteur.attachLocalField((ICoCo::Field*) &champ_recepteur);
dec_emetteur.setNature(ConservativeVolumic);
- if(init)
+ if(init)
dec_emetteur.synchronize();
- init=false;
-
- if (cas=="emetteur") {
- dec_emetteur.sendData();
- affiche(champ_emetteur);
- }
- else if (cas=="recepteur") {
- dec_emetteur.recvData();
- affiche(champ_recepteur);
- }
- else
+ init=false;
+
+ if (cas=="emetteur") {
+ dec_emetteur.sendData();
+ affiche(champ_emetteur);
+ }
+ else if (cas=="recepteur") {
+ dec_emetteur.recvData();
+ affiche(champ_recepteur);
+ }
+ else
throw 0;
}
- stop=true;
+ stop=true;
}
}
}
using namespace ParaMEDMEM;
void testIntersectionDEC_2D(const string& filename1, const string& meshname1,
- const string& filename2, const string& meshname2,
- int nproc_source, double epsilon, bool tri, bool all);
+ const string& filename2, const string& meshname2,
+ int nproc_source, double epsilon, bool tri, bool all);
void get_time( float *telps, float *tuser, float *tsys, float *tcpu );
int main(int argc, char *argv[])
}
void testIntersectionDEC_2D(const string& filename_xml1, const string& meshname1,
- const string& filename_xml2, const string& meshname2,
- int nproc_source, double epsilon, bool tri, bool all)
+ const string& filename_xml2, const string& meshname2,
+ int nproc_source, double epsilon, bool tri, bool all)
{
float tcpu, tcpu_u, tcpu_s, telps;
int size;
paramesh=new ParaMESH (mesh,*target_group,"target mesh");
ParaMEDMEM::ComponentTopology comptopo;
parafield = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);
-
+
int nb_local=mesh->getNumberOfCells();
double *value=parafield->getField()->getArray()->getPointer();
for(int ielem=0; ielem<nb_local;ielem++)