int* conn=new int[triofield._nodes_per_elem];
for (int i=0; i<triofield._nb_elems;i++)
{
- for(int j=0;j<triofield._nodes_per_elem;j++)
- {
- conn[j]=(triofield._connectivity)[i*triofield._nodes_per_elem+j];
- }
- _local_mesh->insertNextCell(elemtype,triofield._nodes_per_elem,conn);
+ for(int j=0;j<triofield._nodes_per_elem;j++)
+ {
+ conn[j]=(triofield._connectivity)[i*triofield._nodes_per_elem+j];
+ }
+ _local_mesh->insertNextCell(elemtype,triofield._nodes_per_elem,conn);
}
delete[] conn;
int nb_case=triofield.nb_values();
if (triofield._type==0)
{
- _field = new ParaMEDMEM::ParaFIELD(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME,_mesh, *_comp_topology );
-
+ _field = new ParaMEDMEM::ParaFIELD(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME,_mesh, *_comp_topology );
+
}
else
{
- _field = new ParaMEDMEM::ParaFIELD(ParaMEDMEM::ON_NODES,ParaMEDMEM::ONE_TIME,_mesh, *_comp_topology );
-
+ _field = new ParaMEDMEM::ParaFIELD(ParaMEDMEM::ON_NODES,ParaMEDMEM::ONE_TIME,_mesh, *_comp_topology );
+
}
if (triofield._field!=0)
{
- // _field = new ParaMEDMEM::ParaFIELD(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME,_mesh, *_comp_topology );
+ // _field = new ParaMEDMEM::ParaFIELD(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME,_mesh, *_comp_topology );
_field->getField()->setNature(ParaMEDMEM::ConservativeVolumic);
ParaMEDMEM::DataArrayDouble *fieldArr=_field->getField()->getArray();
_field->getField()->setName(triofield.getName().c_str());
//field on the receiving end
else
{
- // _field = new ParaMEDMEM::ParaFIELD(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME,_mesh, *_comp_topology );
+ // _field = new ParaMEDMEM::ParaFIELD(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME,_mesh, *_comp_topology );
_field->getField()->setNature(ParaMEDMEM::ConservativeVolumic);
_field->getField()->setName(triofield.getName().c_str());
_field->getField()->setTime(triofield._time1,0,triofield._itnumber);
for (int i=0;i<_nb_elems;i++)
{
for (int j=0;j<_nodes_per_elem;j++)
- os << " "<<_connectivity[i*_nodes_per_elem+j];
+ os << " "<<_connectivity[i*_nodes_per_elem+j];
os<<endl;
}
for (int i=0;i<_nbnodes;i++)
{
for (int j=0;j<_space_dim;j++)
- os <<" "<< _coords[i*_space_dim+j] ;
+ os <<" "<< _coords[i*_space_dim+j] ;
os << endl;
}
{
os <<1<<endl;
for (int i=0;i<nb_values();i++)
- {
- for (int j=0;j<_nb_field_components;j++)
- os <<" "<< _field[i*_nb_field_components+j];
- os << endl;
- }
+ {
+ for (int j=0;j<_nb_field_components;j++)
+ os <<" "<< _field[i*_nb_field_components+j];
+ os << endl;
+ }
}
else
{
for (int i=0;i<_nb_elems;i++)
{
for (int j=0;j<_nodes_per_elem;j++)
- in>>_connectivity[i*_nodes_per_elem+j];
+ in>>_connectivity[i*_nodes_per_elem+j];
}
if (_coords)
for (int i=0;i<_nbnodes;i++)
{
for (int j=0;j<_space_dim;j++)
- in>> _coords[i*_space_dim+j] ;
+ in>> _coords[i*_space_dim+j] ;
}
if (test)
{
if (_field)
- delete [] _field;
+ delete [] _field;
_field=new double[_nb_field_components*nb_values()];
for (int i=0;i<nb_values();i++)
- {
- for (int j=0;j<_nb_field_components;j++)
- in>> _field[i*_nb_field_components+j];
-
- }
+ {
+ for (int j=0;j<_nb_field_components;j++)
+ in>> _field[i*_nb_field_components+j];
+
+ }
}
else
{
_nb_field_components=NewField._nb_field_components;
if (!NewField._connectivity)
- _connectivity=0;
+ _connectivity=0;
else {
_connectivity=new int[_nodes_per_elem*_nb_elems];
memcpy( _connectivity,NewField._connectivity,_nodes_per_elem*_nb_elems*sizeof(int));
}
if (!NewField._coords)
- _coords=0;
+ _coords=0;
else {
_coords=new double[_nbnodes*_space_dim];
memcpy( _coords,NewField._coords,_nbnodes*_space_dim*sizeof(double));
#include <ICoCoField.hxx>
namespace ICoCo
{
- /*!
- \brief structure for coupling Trio codes via the ICoCo interface
+ /*!
+ \brief structure for coupling Trio codes via the ICoCo interface
- This structure contains all the necessary information
- for constructing a ParaMEDMEM::ParaFIELD (with the addition of the MPI
- communicator). The ICoCo API specifies two kinds of calls for
- the ICoCo::Field : either with the mesh only or with the entire information (mesh and field).
- This structure can therefore be left without _time, _nb_field_components, _field
- information, which are related to the field values.
+ This structure contains all the necessary information
+ for constructing a ParaMEDMEM::ParaFIELD (with the addition of the MPI
+ communicator). The ICoCo API specifies two kinds of calls for
+ the ICoCo::Field : either with the mesh only or with the entire information (mesh and field).
+ This structure can therefore be left without _time, _nb_field_components, _field
+ information, which are related to the field values.
- _coords and _connectivity tables are always owned by the TrioField.
+ _coords and _connectivity tables are always owned by the TrioField.
- */
+ */
class TrioField:public Field
{
public:
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;
f.rmDriver(id)
nbcell2dboost=m.getNumberOfElementsWithPoly(MED_CELL,MED_ALL_ELEMENTS)
-connectivite=[2,6,13,11,11,13,14,12,6,5,15,13,12,14,10,4,13,15,16,14,5,1,7,15,14,16,9,10,15,7,8,16,16,8,3,9]
+connectivite=[2,6,13,11, 11,13,14,12, 6,5,15,13, 12,14,10,4, 13,15,16,14,5,1,7,15,14,16,9,10,15,7,8,16,16,8,3,9]
connectivite_index=[1,5,9,13,17,21,25,29,33,37]
conn=m.getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,MED_QUAD4)
conn_index=m.getConnectivityIndex(MED_NODAL,MED_CELL);
print "TEST 2D Boost with polygons"
method="BOOST"
string_to_execute="'"+dir_renumber+" "+dir_mesh+"/"+filename+" "+meshname+" "+method+" "+dir_mesh+"/out_"+filename+"'"
+print string_to_execute
eval("os.system("+string_to_execute+")")
m = MESH(MED_DRIVER,dir_mesh+"/out_"+filename,meshname)
nbcell2dpolyboost=m.getNumberOfElementsWithPoly(MED_CELL,MED_ALL_ELEMENTS)
-connectivite=[2,5,9,10,11,10,9,12,5,6,8,9,4,11,12,16,12,9,8,13,6,1,7,8,16,12,13,15,13,8,7,14,15,13,14,3]
+connectivite=[11,10,9,12, 15,13,14,3, 6,1,7,8, 4,11,12,16, 2,5,9,10, 5,6,8,9,16,12,13,15,12,9,8,13,13,8,7,14]
connectivite_index=[1,5,9,13,17,21,25,29,33,37]
conn=m.getPolygonsConnectivity(MED_FULL_INTERLACE,MED_CELL)
+print "getNumberOfTypesWithPoly(MED_CELL)", m.getNumberOfTypesWithPoly(MED_CELL)
+print "getNumberOfTypes(MED_CELL)", m.getNumberOfTypes(MED_CELL)
+print "getNumberOfTypesWithPoly(MED_FACE)", m.getNumberOfTypesWithPoly(MED_FACE)
conn_index=m.getPolygonsConnectivityIndex(MED_FULL_INTERLACE,MED_CELL);
conn2dpolyboost=(len(conn)==len(connectivite))
+print len(conn), len(connectivite), conn
if conn2dpolyboost:
for i in range(0,len(connectivite)):
conn2dpolyboost=conn2dpolyboost&(conn[i]==connectivite[i])
for i in range(0,len(connectivite_index)):
conn_index2dpolyboost=conn_index2dpolyboost&(conn_index[i]==connectivite_index[i])
PolyBoost2D=conn2dpolyboost&conn_index2dpolyboost&(nbcell2dpolyboost==9)
+print "conn2dpolyboost",conn2dpolyboost,"conn_index2dpolyboost",conn_index2dpolyboost,nbcell2dpolyboost
+sys.exit(1)
os.remove(dir_mesh+"/out_"+filename)
print "TEST 2D Metis with polygons"