if(!umesh)
throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::generateMeshes : Blow up of Stru Elt not managed yet for unstructured meshes !");
//
- std::vector< MCAuto<MEDFileFields> > elts2;
- std::vector< MCAuto<MEDFileUMesh> > elts3;
- MCAuto<MEDFileFields> classicalSEFields(splitFieldsPerLoc(*elt,umesh,elts2,elts3));
+ MCAuto<MEDFileFields> classicalSEFields(splitFieldsPerLoc(*elt,umesh,msOut,allZeOutFields));
if(classicalSEFields.isNotNull())
{
MCAuto<MEDFileUMesh> mOut;
msOut->pushMesh(mOut);
dealWithSEInFields(ps[0].second,classicalSEFields,zeStr,fsOut1,allZeOutFields);
}
- /*for(std::vector< MCAuto<MEDFileFields> >::iterator elt2=elts2.begin();elt2!=elts2.end();elt2++)
- {
- }*/
}
}
fs->killStructureElements();
MEDFileBlowStrEltUp bu(fsSEOnly,ms,ses);
bu.generate(ms,fs);
+ fs->killStructureElementsInGlobs();
}
//
LocInfo(const std::vector<FieldWalker2>& fw);
bool operator==(const LocInfo& other) const { return _locs==other._locs && _pfl==other._pfl; }
void push(const std::string& loc, const std::string& pfl) { checkUniqueLoc(loc); _locs.push_back(loc); _pfl.push_back(pfl); }
- void generateNonClassicalData(const MEDFileUMesh *mesh, const MEDFileFieldGlobsReal *globs) const;
+ MCAuto<MEDFileUMesh> generateNonClassicalData(int zePos, const MEDFileUMesh *mesh, const MEDFileFieldGlobsReal *globs) const;
private:
void checkUniqueLoc(const std::string& loc) const;
+ static MCAuto<DataArrayDouble> BuildMeshFromAngleVrille(INTERP_KERNEL::NormalizedCellType gt, const DataArrayDouble *angleDeVrille, const std::string& pfl, const MEDFileFieldLoc& loc, const MEDFileEltStruct4Mesh *zeStr, const MEDFileUMesh *mesh, const MEDFileUMesh *section, const MEDFileFieldGlobsReal *globs);
+ static MCAuto<DataArrayDouble> BuildMeshFromStructure(INTERP_KERNEL::NormalizedCellType gt, const std::string& pfl, const MEDFileFieldLoc& loc, const MEDFileEltStruct4Mesh *zeStr, const MEDFileUMesh *mesh, const MEDFileUMesh *section, const MEDFileFieldGlobsReal *globs);
+public:
+ static const char ANGLE_DE_VRILLE[];
private:
std::vector<std::string> _locs;
std::vector<std::string> _pfl;
};
+const char LocInfo::ANGLE_DE_VRILLE[]="ANGLE DE VRILLE";
+
LocInfo::LocInfo(const std::vector<FieldWalker2>& fw)
{
std::size_t sz(fw.size());
}
}
-void LocInfo::generateNonClassicalData(const MEDFileUMesh *mesh, const MEDFileFieldGlobsReal *globs) const
+MCAuto<DataArrayDouble> LocInfo::BuildMeshFromAngleVrille(INTERP_KERNEL::NormalizedCellType gt, const DataArrayDouble *angleDeVrille, const std::string& pfl, const MEDFileFieldLoc& loc, const MEDFileEltStruct4Mesh *zeStr, const MEDFileUMesh *mesh, const MEDFileUMesh *section, const MEDFileFieldGlobsReal *globs)
+{
+ MCAuto<DataArrayInt> conn(zeStr->getConn());
+ conn=conn->deepCopy(); conn->rearrange(1);
+ MCAuto<MEDCouplingUMesh> geoMesh;
+ {
+ MCAuto<MEDCoupling1SGTUMesh> umesh(MEDCoupling1SGTUMesh::New("",gt));
+ umesh->setCoords(mesh->getCoords());
+ umesh->setNodalConnectivity(conn);
+ geoMesh=umesh->buildUnstructured();
+ }
+ //
+ MCAuto<DataArrayDouble> angleVrille(angleDeVrille->deepCopy());
+ if(!pfl.empty())
+ {
+ const DataArrayInt *pflArr(globs->getProfile(pfl));
+ geoMesh=geoMesh->buildPartOfMySelf(pflArr->begin(),pflArr->end(),true);
+ angleVrille=angleVrille->selectByTupleIdSafe(pflArr->begin(),pflArr->end());
+ }
+ //
+ MCAuto<MEDCouplingFieldDouble> fakeF(MEDCouplingFieldDouble::New(ON_GAUSS_PT));
+ fakeF->setMesh(geoMesh);
+ int nbg(loc.getGaussWeights().size());
+ fakeF->setGaussLocalizationOnType(gt,loc.getRefCoords(),loc.getGaussCoords(),loc.getGaussWeights());
+ MCAuto<DataArrayDouble> ptsForLoc(fakeF->getLocalizationOfDiscr());
+ //
+ MCAuto<DataArrayDouble> rot;
+ {
+ MCAuto<MEDCouplingFieldDouble> dir(geoMesh->buildDirectionVectorField());
+ rot=dir->getArray()->fromCartToSpher();
+ }
+ int nbCells(geoMesh->getNumberOfCells()),nbCompo(ptsForLoc->getNumberOfComponents());
+ MCAuto<DataArrayDouble> secPts(section->getCoords()->changeNbOfComponents(nbCompo,0.));
+ int nbSecPts(secPts->getNumberOfTuples());
+ {
+ const int TAB[3]={2,0,1};
+ std::vector<int> v(TAB,TAB+3);
+ secPts=secPts->keepSelectedComponents(v);
+ }
+ const double CENTER[3]={0.,0.,0.},AX0[3]={0.,0.,1.};
+ double AX1[3]; AX1[2]=0.;
+ std::vector< MCAuto<DataArrayDouble> > arrs(nbCells*nbg);
+ for(int j=0;j<nbCells;j++)
+ {
+ MCAuto<DataArrayDouble> p(secPts->deepCopy());
+ double ang0(rot->getIJ(j,2));
+ DataArrayDouble::Rotate3DAlg(CENTER,AX0,ang0,nbSecPts,p->begin(),p->getPointer());
+ AX1[0]=-sin(ang0); AX1[1]=cos(ang0);// rot Oy around OZ
+ double ang1(M_PI/2.-rot->getIJ(j,1));
+ DataArrayDouble::Rotate3DAlg(CENTER,AX1,ang1,nbSecPts,p->begin(),p->getPointer());
+ for(int l=0;l<nbg;l++)
+ {
+ MCAuto<DataArrayDouble> p2(p->deepCopy());
+ for(int k=0;k<nbCompo;k++)
+ p2->applyLin(1.,ptsForLoc->getIJ(j*nbg+l,k),k);
+ arrs[j*nbg+l]=p2;
+ }
+ }
+ std::vector<const DataArrayDouble *> arrs2(VecAutoToVecOfCstPt(arrs));
+ MCAuto<DataArrayDouble> resu(DataArrayDouble::Aggregate(arrs2));
+ return resu;
+}
+
+MCAuto<DataArrayDouble> LocInfo::BuildMeshFromStructure(INTERP_KERNEL::NormalizedCellType gt, const std::string& pfl, const MEDFileFieldLoc& loc, const MEDFileEltStruct4Mesh *zeStr, const MEDFileUMesh *mesh, const MEDFileUMesh *section, const MEDFileFieldGlobsReal *globs)
+{
+ static const char MSG1[]="BuildMeshFromStructure : not recognized pattern ! Send mail to anthony.geay@edf.fr with corresponding MED file !";
+ const std::vector< MCAuto<DataArray> >& vars(zeStr->getVars());
+ if(vars.size()!=1)
+ throw INTERP_KERNEL::Exception(MSG1);
+ MCAuto<DataArray> zeArr(vars[0]);
+ if(zeArr.isNull())
+ throw INTERP_KERNEL::Exception(MSG1);
+ MCAuto<DataArrayDouble> zeArr2(DynamicCast<DataArray,DataArrayDouble>(zeArr));
+ if(zeArr2.isNull())
+ throw INTERP_KERNEL::Exception(MSG1);
+ if(zeArr2->getName()!=ANGLE_DE_VRILLE)
+ throw INTERP_KERNEL::Exception(MSG1);
+ return BuildMeshFromAngleVrille(gt,zeArr2,pfl,loc,zeStr,mesh,section,globs);
+}
+
+MCAuto<MEDFileUMesh> LocInfo::generateNonClassicalData(int zePos, const MEDFileUMesh *mesh, const MEDFileFieldGlobsReal *globs) const
{
static const char MSG1[]="LocInfo::generateNonClassicalData : no spec for GAUSS on StructureElement with more than one cell !";
std::size_t sz(_locs.size());
+ std::vector< MCAuto<DataArrayDouble> > arrs(sz);
for(std::size_t i=0;i<sz;i++)
{
const MEDFileFieldLoc& loc(globs->getLocalization(_locs[i]));
std::ostringstream oss; oss << "LocInfo::generateNonClassicalData : : no geo type with name " << se->getName() << " in " << mesh->getName() << " !";
throw INTERP_KERNEL::Exception(oss.str());
}
- MCAuto<DataArrayInt> conn(zeStr->getConn());
- conn=conn->deepCopy(); conn->rearrange(1);
- MCAuto<MEDCouplingUMesh> geoMesh;
- {
- MCAuto<MEDCoupling1SGTUMesh> umesh(MEDCoupling1SGTUMesh::New("",gt));
- umesh->setCoords(mesh->getCoords());
- umesh->setNodalConnectivity(conn);
- geoMesh=umesh->buildUnstructured();
- }
- //
- std::string pfl(_pfl[i]);
- if(!pfl.empty())
- {
- const DataArrayInt *pflArr(globs->getProfile(pfl));
- geoMesh=geoMesh->buildPartOfMySelf(pflArr->begin(),pflArr->end(),true);
- }
- //
- geoMesh->writeVTK("geo.vtu");
- //
- MCAuto<MEDCouplingFieldDouble> fakeF(MEDCouplingFieldDouble::New(ON_GAUSS_PT));
- fakeF->setMesh(geoMesh);
- int nbg(loc.getGaussWeights().size());
- fakeF->setGaussLocalizationOnType(gt,loc.getRefCoords(),loc.getGaussCoords(),loc.getGaussWeights());
- MCAuto<DataArrayDouble> ptsForLoc(fakeF->getLocalizationOfDiscr());
- {
- MCAuto<MEDCouplingUMesh> ptsForLoc1(MEDCouplingUMesh::Build0DMeshFromCoords(ptsForLoc));
- ptsForLoc1->writeVTK("pts.vtu");
- }
- //
- MCAuto<DataArrayDouble> rot;
- {
- MCAuto<MEDCouplingFieldDouble> dir(geoMesh->buildDirectionVectorField());
- rot=dir->getArray()->fromCartToSpher();
- }
- int nbCells(geoMesh->getNumberOfCells()),nbCompo(ptsForLoc->getNumberOfComponents());
- MCAuto<DataArrayDouble> secPts(section->getCoords()->changeNbOfComponents(nbCompo,0.));
- int nbSecPts(secPts->getNumberOfTuples());
- {
- const int TAB[3]={2,0,1};
- std::vector<int> v(TAB,TAB+3);
- secPts=secPts->keepSelectedComponents(v);
- }
- const double CENTER[3]={0.,0.,0.},AX0[3]={0.,0.,1.};
- double AX1[3]; AX1[2]=0.;
- std::vector< MCAuto<DataArrayDouble> > arrs(nbCells*nbg);
- for(int j=0;j<nbCells;j++)
- {
- MCAuto<DataArrayDouble> p(secPts->deepCopy());
- double ang0(rot->getIJ(j,2));
- DataArrayDouble::Rotate3DAlg(CENTER,AX0,ang0,nbSecPts,p->begin(),p->getPointer());
- AX1[0]=-sin(ang0); AX1[1]=cos(ang0);// rot Oy around OZ
- double ang1(M_PI/2.-rot->getIJ(j,1));
- DataArrayDouble::Rotate3DAlg(CENTER,AX1,ang1,nbSecPts,p->begin(),p->getPointer());
- for(int l=0;l<nbg;l++)
- {
- MCAuto<DataArrayDouble> p2(p->deepCopy());
- for(int k=0;k<nbCompo;k++)
- p2->applyLin(1.,ptsForLoc->getIJ(j*nbg+l,k),k);
- arrs[j*nbg+l]=p2;
- }
- }
- std::vector<const DataArrayDouble *> arrs2(VecAutoToVecOfCstPt(arrs));
- MCAuto<DataArrayDouble> resu(DataArrayDouble::Aggregate(arrs2));
- MCAuto<MEDCouplingUMesh> mresu(MEDCouplingUMesh::Build0DMeshFromCoords(resu));
- {
- mresu->setName("mesh");
- std::ostringstream oss; oss << "mresu_" << i << ".vtu";
- mresu->writeVTK(oss.str());
- }
- std::cerr << "kkkk " << mesh << " " << meshLoc << std::endl;
+ arrs[i]=BuildMeshFromStructure(gt,_pfl[i],loc,zeStr,mesh,section,globs);
}
+ std::vector<const DataArrayDouble *> arrs2(VecAutoToVecOfCstPt(arrs));
+ MCAuto<DataArrayDouble> resu(DataArrayDouble::Aggregate(arrs2));
+ MCAuto<MEDFileUMesh> ret(MEDFileUMesh::New());
+ ret->setCoords(resu);
+ std::ostringstream meshName; meshName << mesh->getName() << "_on_" << sz << "_sections" << "_" << zePos;
+ ret->setName(meshName.str());
+ return ret;
}
FieldWalker2::FieldWalker2(const MEDFileFieldPerMeshPerTypePerDisc *pmptpd)
public:
LocSpliter(const MEDFileFieldGlobsReal *globs):_globs(globs),_fw(0) { }
MCAuto<MEDFileFields> getClassical() const { return _classical; }
- void generateNonClassicalData(const MEDFileUMesh *mesh) const;
+ void generateNonClassicalData(const MEDFileUMesh *mesh, std::vector< MCAuto<MEDFileFields> >& outFields, std::vector< MCAuto<MEDFileUMesh> >& outMeshes) const;
private:
void newFieldEntry(const MEDFileAnyTypeFieldMultiTSWithoutSDA *field);
void endFieldEntry(const MEDFileAnyTypeFieldMultiTSWithoutSDA *field);
{
if(_fw->isEmpty())
return ;
+ MCAuto<MEDFileAnyTypeFieldMultiTS> f(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(field)));
if(_fw->isClassical())
{
if(_classical.isNull())
_classical=MEDFileFields::New();
_classical->shallowCpyGlobs(*_globs);
}
- MCAuto<MEDFileAnyTypeFieldMultiTS> f(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(field)));
_classical->pushField(f);
}
else
if(it==_locs.end())
{
_locs.push_back(elt);
+ MCAuto<MEDFileFields> zeF(MEDFileFields::New());
+ zeF->shallowCpyGlobs(*_globs);
+ zeF->pushField(f);
+ _fields_on_locs.push_back(zeF);
}
else
{
+ MCAuto<MEDFileFields> zeF(_fields_on_locs[std::distance(_locs.begin(),it)]);
+ zeF->pushField(f);
}
- std::cerr << "lkk " << _locs.size() << std::endl;
}
}
-void LocSpliter::generateNonClassicalData(const MEDFileUMesh *mesh) const
+void LocSpliter::generateNonClassicalData(const MEDFileUMesh *mesh, std::vector< MCAuto<MEDFileFields> >& outFields, std::vector< MCAuto<MEDFileUMesh> >& outMeshes) const
{
- for(std::vector<LocInfo>::const_iterator it=_locs.begin();it!=_locs.end();it++)
+ int i(0);
+ for(std::vector<LocInfo>::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
{
- (*it).generateNonClassicalData(mesh,_globs);
+ MCAuto<MEDFileUMesh> m((*it).generateNonClassicalData(i,mesh,_globs));
+ outMeshes.push_back(m);
+ MCAuto<MEDCouplingUMesh> mcm(MEDCouplingUMesh::Build0DMeshFromCoords(m->getCoords()));
+ mcm->setName(m->getName());
+ MCAuto<MEDFileFields> fs(_fields_on_locs[i]);
+ MCAuto<MEDFileFields> outFs(MEDFileFields::New());
+ for(int j=0;j<fs->getNumberOfFields();j++)
+ {
+ MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsNC(fs->getFieldAtPos(j));
+ MCAuto<MEDFileFieldMultiTS> fmts(DynamicCastSafe<MEDFileAnyTypeFieldMultiTS,MEDFileFieldMultiTS>(fmtsNC));
+ MCAuto<MEDFileFieldMultiTS> outFmts(MEDFileFieldMultiTS::New());
+ for(int k=0;k<fmts->getNumberOfTS();k++)
+ {
+ MCAuto<MEDFileField1TS> outF1t(MEDFileField1TS::New());
+ MCAuto<MEDFileField1TS> f1ts(fmts->getTimeStepAtPos(k));
+ int t2,t3;
+ double t1(f1ts->getTime(t2,t3));
+ MCAuto<MEDCouplingFieldDouble> mcf(MEDCouplingFieldDouble::New(ON_NODES));
+ mcf->setArray(f1ts->getUndergroundDataArray());
+ mcf->setTime(t1,t2,t3);
+ mcf->setName(f1ts->getName());
+ mcf->setMesh(mcm);
+ outF1t->setFieldNoProfileSBT(mcf);
+ outFmts->pushBackTimeStep(outF1t);
+ }
+ outFs->pushField(outFmts);
+ }
+ outFields.push_back(outFs);
}
}
_fw->newPerMeshPerTypePerDisc(pmptpd);
}
-MCAuto<MEDFileFields> MEDFileBlowStrEltUp::splitFieldsPerLoc(const MEDFileFields *fields, const MEDFileUMesh *mesh, std::vector< MCAuto<MEDFileFields> >& outFields, std::vector< MCAuto<MEDFileUMesh> >& outMeshes)
+MCAuto<MEDFileFields> MEDFileBlowStrEltUp::splitFieldsPerLoc(const MEDFileFields *fields, const MEDFileUMesh *mesh, MEDFileMeshes *msOut, MEDFileFields *allZeOutFields)
{
LocSpliter ls(fields);
fields->accept(ls);
- ls.generateNonClassicalData(mesh);
+ std::vector< MCAuto<MEDFileFields> > outFields;
+ std::vector< MCAuto<MEDFileUMesh> > outMeshes;
+ ls.generateNonClassicalData(mesh,outFields,outMeshes);
+ for(std::vector< MCAuto<MEDFileFields> >::iterator it=outFields.begin();it!=outFields.end();it++)
+ {
+ for(int j=0;j<(*it)->getNumberOfFields();j++)
+ {
+ MCAuto<MEDFileAnyTypeFieldMultiTS> fmts((*it)->getFieldAtPos(j));
+ allZeOutFields->pushField(fmts);
+ }
+ }
+ for(std::vector< MCAuto<MEDFileUMesh> >::iterator it=outMeshes.begin();it!=outMeshes.end();it++)
+ msOut->pushMesh(*it);
return ls.getClassical();
}