X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDLoader%2FMEDFileBlowStrEltUp.cxx;h=60ce09bbad3a5b9646ad6e18bb034f1514c0d171;hb=cb60c693f70bbafac8acc530636ad0439190d272;hp=0d614de1d83d98c5cb94dc02054e4c5651ace396;hpb=eb4b9a0f16f682485df7baf6c2eb5fed34c988f4;p=tools%2Fmedcoupling.git diff --git a/src/MEDLoader/MEDFileBlowStrEltUp.cxx b/src/MEDLoader/MEDFileBlowStrEltUp.cxx index 0d614de1d..60ce09bba 100644 --- a/src/MEDLoader/MEDFileBlowStrEltUp.cxx +++ b/src/MEDLoader/MEDFileBlowStrEltUp.cxx @@ -336,9 +336,15 @@ public: private: void checkUniqueLoc(const std::string& loc) const; static MCAuto 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 BuildMeshFromEpaisseur(INTERP_KERNEL::NormalizedCellType gt, const DataArrayDouble *thikness, const std::string& pfl, const MEDFileFieldLoc& loc, const MEDFileEltStruct4Mesh *zeStr, const MEDFileUMesh *mesh, const MEDFileUMesh *section, const MEDFileFieldGlobsReal *globs); + static MCAuto BuildMeshPipeSEG3(const DataArrayDouble *angle, const DataArrayDouble *scale, const std::string& pfl, const MEDFileFieldLoc& loc, const MEDFileEltStruct4Mesh *zeStr, const MEDFileUMesh *mesh, const MEDFileUMesh *section, const MEDFileFieldGlobsReal *globs); + static MCAuto BuildMeshCommon(INTERP_KERNEL::NormalizedCellType gt, const std::string& pfl, const MEDFileFieldLoc& loc, const MEDFileEltStruct4Mesh *zeStr, const MEDFileUMesh *mesh, const MEDFileUMesh *section, const MEDFileFieldGlobsReal *globs, MCAuto& ptsForLoc); static MCAuto 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[]; + static const char ANGLE[]; + static const char SCALE[]; + static const char EPAISSEUR[]; private: std::vector _locs; std::vector _pfl; @@ -347,6 +353,12 @@ private: const char LocInfo::ANGLE_DE_VRILLE[]="ANGLE DE VRILLE"; +const char LocInfo::ANGLE[]="ANGLE"; + +const char LocInfo::SCALE[]="SCALE"; + +const char LocInfo::EPAISSEUR[]="EPAISSEUR"; + LocInfo::LocInfo(const std::vector& fw) { std::size_t sz(fw.size()); @@ -371,7 +383,7 @@ void LocInfo::checkUniqueLoc(const std::string& loc) const } } -MCAuto 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 LocInfo::BuildMeshCommon(INTERP_KERNEL::NormalizedCellType gt, const std::string& pfl, const MEDFileFieldLoc& loc, const MEDFileEltStruct4Mesh *zeStr, const MEDFileUMesh *mesh, const MEDFileUMesh *section, const MEDFileFieldGlobsReal *globs, MCAuto& ptsForLoc) { MCAuto conn(zeStr->getConn()); conn=conn->deepCopy(); conn->rearrange(1); @@ -383,27 +395,39 @@ MCAuto LocInfo::BuildMeshFromAngleVrille(INTERP_KERNEL::Normali geoMesh=umesh->buildUnstructured(); } // - MCConstAuto angleVrille; if(!pfl.empty()) { const DataArrayInt *pflArr(globs->getProfile(pfl)); geoMesh=geoMesh->buildPartOfMySelf(pflArr->begin(),pflArr->end(),true); - angleVrille=angleDeVrille->selectByTupleIdSafe(pflArr->begin(),pflArr->end()); } - else - angleVrille.takeRef(angleDeVrille); // MCAuto fakeF(MEDCouplingFieldDouble::New(ON_GAUSS_PT)); fakeF->setMesh(geoMesh); - int nbg(loc.getGaussWeights().size()); fakeF->setGaussLocalizationOnType(gt,loc.getRefCoords(),loc.getGaussCoords(),loc.getGaussWeights()); - MCAuto ptsForLoc(fakeF->getLocalizationOfDiscr()); + ptsForLoc=fakeF->getLocalizationOfDiscr(); + // + return geoMesh; +} + +MCAuto 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 ptsForLoc; + MCAuto geoMesh(BuildMeshCommon(gt,pfl,loc,zeStr,mesh,section,globs,ptsForLoc)); + // + MCConstAuto angleVrille; + if(!pfl.empty()) + { + const DataArrayInt *pflArr(globs->getProfile(pfl)); + angleVrille=angleDeVrille->selectByTupleIdSafe(pflArr->begin(),pflArr->end()); + } + else + angleVrille.takeRef(angleDeVrille); // MCAuto dir(geoMesh->buildDirectionVectorField()); MCAuto rot(dir->getArray()->fromCartToSpher()); - int nbCells(geoMesh->getNumberOfCells()),nbCompo(ptsForLoc->getNumberOfComponents()); + int nbCompo(ptsForLoc->getNumberOfComponents()); MCAuto secPts(section->getCoords()->changeNbOfComponents(nbCompo,0.)); - int nbSecPts(secPts->getNumberOfTuples()); + int nbSecPts(secPts->getNumberOfTuples()),nbCells(geoMesh->getNumberOfCells()),nbg(loc.getGaussWeights().size()); { const int TAB[3]={2,0,1}; std::vector v(TAB,TAB+3); @@ -434,21 +458,155 @@ MCAuto LocInfo::BuildMeshFromAngleVrille(INTERP_KERNEL::Normali return resu; } +MCAuto LocInfo::BuildMeshFromEpaisseur(INTERP_KERNEL::NormalizedCellType gt, const DataArrayDouble *thikness, const std::string& pfl, const MEDFileFieldLoc& loc, const MEDFileEltStruct4Mesh *zeStr, const MEDFileUMesh *mesh, const MEDFileUMesh *section, const MEDFileFieldGlobsReal *globs) +{ + MCAuto ptsForLoc; + MCAuto geoMesh(BuildMeshCommon(gt,pfl,loc,zeStr,mesh,section,globs,ptsForLoc)); + int nbSecPts(section->getNumberOfNodes()),nbCells(geoMesh->getNumberOfCells()),nbg(loc.getGaussWeights().size()); + MCConstAuto zeThikness; + if(!pfl.empty()) + { + const DataArrayInt *pflArr(globs->getProfile(pfl)); + geoMesh=geoMesh->buildPartOfMySelf(pflArr->begin(),pflArr->end(),true); + zeThikness=thikness->selectByTupleIdSafe(pflArr->begin(),pflArr->end()); + } + else + zeThikness.takeRef(thikness); + MCAuto orthoArr; + { + MCAuto ortho(geoMesh->buildOrthogonalField()); + orthoArr.takeRef(ortho->getArray()); + } + int nbCompo(orthoArr->getNumberOfComponents()); + MCAuto secPts(section->getCoords()->duplicateEachTupleNTimes(nbCompo)); + secPts->rearrange(nbCompo); + std::vector< MCAuto > arrs(nbCells*nbg); + for(int j=0;jgetIJ(j,0)); + MCAuto fact(DataArrayDouble::New()); fact->alloc(1,nbCompo); + std::copy(orthoArr->begin()+j*nbCompo,orthoArr->begin()+(j+1)*nbCompo,fact->getPointer()); + std::transform(fact->begin(),fact->end(),fact->getPointer(),std::bind2nd(std::multiplies(),thck/2.)); + MCAuto p(DataArrayDouble::Multiply(secPts,fact)); + for(int l=0;l p2(p->deepCopy()); + for(int k=0;kapplyLin(1.,ptsForLoc->getIJ(j*nbg+l,k),k); + arrs[j*nbg+l]=p2; + } + } + std::vector arrs2(VecAutoToVecOfCstPt(arrs)); + MCAuto resu(DataArrayDouble::Aggregate(arrs2)); + return resu; +} + +MCAuto LocInfo::BuildMeshPipeSEG3(const DataArrayDouble *angle, const DataArrayDouble *scale, const std::string& pfl, const MEDFileFieldLoc& loc, const MEDFileEltStruct4Mesh *zeStr, const MEDFileUMesh *mesh, const MEDFileUMesh *section, const MEDFileFieldGlobsReal *globs) +{ + static const char MSG1[]="BuildMeshPipeSEG3 : not recognized pattern ! Send mail to anthony.geay@edf.fr with corresponding MED file !"; + MCAuto ptsForLoc; + MCAuto geoMesh(BuildMeshCommon(INTERP_KERNEL::NORM_SEG3,pfl,loc,zeStr,mesh,section,globs,ptsForLoc)); + int nbSecPts(section->getNumberOfNodes()),nbCells(geoMesh->getNumberOfCells()),nbg(loc.getGaussWeights().size()); + MCConstAuto zeAngle,zeScale; + if(!pfl.empty()) + { + const DataArrayInt *pflArr(globs->getProfile(pfl)); + geoMesh=geoMesh->buildPartOfMySelf(pflArr->begin(),pflArr->end(),true); + zeAngle=angle->selectByTupleIdSafe(pflArr->begin(),pflArr->end()); + zeScale=scale->selectByTupleIdSafe(pflArr->begin(),pflArr->end()); + } + else + { + zeAngle.takeRef(angle); + zeScale.takeRef(scale); + } + if(zeAngle->getNumberOfComponents()!=3 || zeScale->getNumberOfComponents()!=2 || nbg!=3) + throw INTERP_KERNEL::Exception(MSG1); + MCAuto dir; + { + MCAuto geoMesh2(geoMesh->deepCopy()); + geoMesh2->convertQuadraticCellsToLinear(); + dir=geoMesh2->buildDirectionVectorField(); + } + MCAuto rot(dir->getArray()->fromCartToSpher()); + int nbCompo(ptsForLoc->getNumberOfComponents()); + MCAuto secPts(section->getCoords()->changeNbOfComponents(nbCompo,0.)); + { + const int TAB[3]={2,0,1}; + std::vector 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 > arrs(nbCells*nbg); + for(int j=0;j 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<3;l++) + { + MCAuto p3(p->deepCopy()); + DataArrayDouble::Rotate3DAlg(CENTER,dir->getArray()->begin()+j*3,zeAngle->getIJ(j,l),nbSecPts,p3->begin(),p3->getPointer()); + MCAuto p2(p3->deepCopy()); + for(int k=0;kapplyLin(1.,ptsForLoc->getIJ(j*nbg+l,k),k); + arrs[j*nbg+l]=p2; + } + } + std::vector arrs2(VecAutoToVecOfCstPt(arrs)); + MCAuto resu(DataArrayDouble::Aggregate(arrs2)); + return resu; +} + MCAuto 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 >& vars(zeStr->getVars()); - if(vars.size()!=1) - throw INTERP_KERNEL::Exception(MSG1); - MCAuto zeArr(vars[0]); - if(zeArr.isNull()) - throw INTERP_KERNEL::Exception(MSG1); - MCAuto zeArr2(DynamicCast(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); + if(vars.size()==1) + { + MCAuto zeArr(vars[0]); + if(zeArr.isNull()) + throw INTERP_KERNEL::Exception(MSG1); + MCAuto zeArr2(DynamicCast(zeArr)); + if(zeArr2.isNull()) + throw INTERP_KERNEL::Exception(MSG1); + if(zeArr2->getName()==ANGLE_DE_VRILLE || zeArr2->getName()==ANGLE) + return BuildMeshFromAngleVrille(gt,zeArr2,pfl,loc,zeStr,mesh,section,globs); + if(zeArr2->getName()==EPAISSEUR || zeArr2->getName()==SCALE) + return BuildMeshFromEpaisseur(gt,zeArr2,pfl,loc,zeStr,mesh,section,globs); + } + if(vars.size()==2) + { + MCAuto zeArr0(vars[0]),zeArr1(vars[1]); + if(zeArr0.isNull() || zeArr1.isNull()) + throw INTERP_KERNEL::Exception(MSG1); + MCAuto zeArr00(DynamicCastSafe(zeArr0)),zeArr11(DynamicCastSafe(zeArr1)); + switch(gt) + { + case INTERP_KERNEL::NORM_SEG3: + { + MCAuto angle,scale; + if(zeArr00->getName()==ANGLE) + angle=zeArr00; + if(zeArr00->getName()==SCALE) + scale=zeArr00; + if(zeArr11->getName()==ANGLE) + angle=zeArr11; + if(zeArr11->getName()==SCALE) + scale=zeArr11; + if(angle.isNull() || scale.isNull()) + throw INTERP_KERNEL::Exception(MSG1); + return BuildMeshPipeSEG3(angle,scale,pfl,loc,zeStr,mesh,section,globs); + } + default: + throw INTERP_KERNEL::Exception(MSG1); + } + } + throw INTERP_KERNEL::Exception(MSG1); } MCAuto LocInfo::generateNonClassicalData(int zePos, const MEDFileUMesh *mesh, const MEDFileFieldGlobsReal *globs) const @@ -849,7 +1007,7 @@ MCAuto MEDFileBlowStrEltUp::splitFieldsPerLoc(const MEDFileFields for(int j=0;j<(*it)->getNumberOfFields();j++) { MCAuto fmts((*it)->getFieldAtPos(j)); - DealWithConflictNames(fmts,allZeOutFields); + //DealWithConflictNames(fmts,allZeOutFields);// uncomment to have a writable data structure allZeOutFields->pushField(fmts); } }