From: Frederic D. <de...@us...> - 2004-03-31 08:26:46
|
Update of /cvsroot/fudaa/fudaa_devel/dodico/src/org/fudaa/dodico/reflux/io In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9937/src/org/fudaa/dodico/reflux/io Modified Files: CrbWriter.java INPFileFormat.java RefluxSolutionInitWriter.java RefluxSolutionInitReader.java Log Message: Maj pour solutions initiales Index: INPFileFormat.java =================================================================== RCS file: /cvsroot/fudaa/fudaa_devel/dodico/src/org/fudaa/dodico/reflux/io/INPFileFormat.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** INPFileFormat.java 16 Mar 2004 16:47:28 -0000 1.17 --- INPFileFormat.java 31 Mar 2004 08:14:29 -0000 1.18 *************** *** 56,59 **** --- 56,67 ---- type_= H2dFileFormatType.PROJET.getId(); } + + public static String getINPExtension(){ + return "inp"; + } + + public static String getSolution2DExtension(){ + return "sov"; + } public boolean containsGrid() { *************** *** 74,80 **** return (H2dRefluxDicoModel)super.getDico(); } public String getClTransitoireFileExtension() { ! return CLTransitoireFileFormat.getInstance().getExtensions()[0]; } public DicoEntite[] getContributionEntite() { return getEntitesForHeading( --- 82,94 ---- return (H2dRefluxDicoModel)super.getDico(); } + /** + * @return l'extension des fichiers cl transitoire utilises + */ public String getClTransitoireFileExtension() { ! return "clv"; } + /** + * @return les mot-clés contribution + */ public DicoEntite[] getContributionEntite() { return getEntitesForHeading( *************** *** 83,86 **** --- 97,103 ---- "Contribution coefficients" }); } + /** + * @return les mot-clés impression + */ public DicoEntite[] getPrintEntite() { return getEntitesForHeading(new String[] { "Impression", "Print" }); *************** *** 98,116 **** } public String getPnTransitoireFileExtension() { ! return PnTransitoireFileFormat.getInstance().getExtensions()[0]; } public String getSolutionInitFileExtension() { ! return ".siv"; } public String getSolutionFileExtension() { ! return ".sov"; } public String getSolutionFinaleExtension() { ! return ".sfv"; } public String getCLTransitoireFichier(String[] _f) { return DodicoLib.findStringEndWith(_f, getClTransitoireFileExtension()); } public String getPnTransitoireFichier(String[] _f) { return DodicoLib.findStringEndWith(_f, getPnTransitoireFileExtension()); --- 115,155 ---- } + /** + * @return "pnv" + */ public String getPnTransitoireFileExtension() { ! return "pnv"; } + /** + * @return "siv" + */ public String getSolutionInitFileExtension() { ! return "siv"; } + /** + * @return "sov" + */ public String getSolutionFileExtension() { ! return "sov"; } + /** + * @return "sfv" + */ public String getSolutionFinaleExtension() { ! return "sfv"; } + + + /** + * @param _f le tableau a parcourir + * @return le fichier contant l'extension clv + */ public String getCLTransitoireFichier(String[] _f) { return DodicoLib.findStringEndWith(_f, getClTransitoireFileExtension()); } + /** + * @param _f le tableau a parcourir + * @return le fichier contant l'extension pnv + */ public String getPnTransitoireFichier(String[] _f) { return DodicoLib.findStringEndWith(_f, getPnTransitoireFileExtension()); *************** *** 125,128 **** --- 164,175 ---- } + /** + * @param _f le tableau de recherche + * @return l'element du tableau contenant la bonne extension + */ + public String getSolution(String[] _f) { + return DodicoLib.findStringEndWith(_f, getSolutionFileExtension()); + } + public H2dBcType getClType(int _id) { Index: RefluxSolutionInitReader.java =================================================================== RCS file: /cvsroot/fudaa/fudaa_devel/dodico/src/org/fudaa/dodico/reflux/io/RefluxSolutionInitReader.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RefluxSolutionInitReader.java 16 Mar 2004 16:47:28 -0000 1.1 --- RefluxSolutionInitReader.java 31 Mar 2004 08:14:29 -0000 1.2 *************** *** 18,25 **** --- 18,30 ---- import org.fudaa.dodico.commun.DodicoAnalyze; import org.fudaa.dodico.commun.DodicoResource; + import org.fudaa.dodico.commun.ProgressionInterface; import org.fudaa.dodico.commun.ProgressionUpdater; + import org.fudaa.dodico.ef.EfElement; + import org.fudaa.dodico.ef.EfGrid; + import org.fudaa.dodico.fichiers.FileOperationSynthese; import org.fudaa.dodico.fichiers.FileReadOperationAbstract; import org.fudaa.dodico.fortran.FortranBinaryInputStream; import org.fudaa.dodico.fortran.FortranInterface; + import org.fudaa.dodico.h2d.reflux.H2dRefluxSICourant2D; *************** *** 101,103 **** --- 106,147 ---- }; } + + /** + * Lit le fichier si, attention : les niveaux d'eau sont transformés en hauteur d'eau + * @param _g le maillage associé + * @param _f le fichier siv a lire + * @param _prog la barre de progression + * @return la synthese contenant une instance de H2dRefluxSICourant2D + */ + public static FileOperationSynthese loadSI(EfGrid _g, File _f, ProgressionInterface _prog) { + FileOperationSynthese init = RefluxSolutionInitFileFormat.getInstance() + .getLastVersionInstance().read(_f, _prog); + if (init.containsFatalError()) { + init.setSource(null); + return init; + } + double[] vals = (double[]) init.getSource(); + double[][] si = new double[3][_g.getPtsNb()]; + int idxDone = 0; + int nbPt = _g.getPtsNb(); + int temp; + if (_prog != null) _prog.setProgression(30); + int idxInVal = 0; + idxDone = 0; + temp = vals.length; + ProgressionUpdater up = new ProgressionUpdater(_prog); + up.setValue(3, nbPt, 30, 70); + up.majProgessionStateOnly(); + while (idxInVal < temp) { + si[0][idxDone] = vals[idxInVal++]; + si[1][idxDone] = vals[idxInVal++]; + if (!_g.isMiddlePoint(idxDone)) { + si[2][idxDone] = vals[idxInVal++]-_g.getPt(idxDone).getZ(); + } + up.majAvancement(); + idxDone++; + } + init.setSource(new H2dRefluxSICourant2D(si[0], si[1], si[2])); + return init; + } } Index: CrbWriter.java =================================================================== RCS file: /cvsroot/fudaa/fudaa_devel/dodico/src/org/fudaa/dodico/reflux/io/CrbWriter.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CrbWriter.java 12 Feb 2004 15:32:47 -0000 1.2 --- CrbWriter.java 31 Mar 2004 08:14:29 -0000 1.3 *************** *** 13,21 **** import org.fudaa.ctulu.CtuluLib; - - import org.fudaa.dodico.commun.DodicoAnalyze; - import org.fudaa.dodico.commun.DodicoLib; import org.fudaa.dodico.commun.DodicoResource; import org.fudaa.dodico.commun.ProgressionInterface; import org.fudaa.dodico.fichiers.FileFormatVersion; import org.fudaa.dodico.fichiers.FileOpWriterCharSimpleAbstract; --- 13,19 ---- import org.fudaa.ctulu.CtuluLib; import org.fudaa.dodico.commun.DodicoResource; import org.fudaa.dodico.commun.ProgressionInterface; + import org.fudaa.dodico.commun.ProgressionUpdater; import org.fudaa.dodico.fichiers.FileFormatVersion; import org.fudaa.dodico.fichiers.FileOpWriterCharSimpleAbstract; *************** *** 29,47 **** */ public class CrbWriter extends FileOpWriterCharSimpleAbstract { CrbFileFormat.CRBVersion v_; - public CrbWriter(CrbFileFormat.CRBVersion _v) { - v_= _v; } /** ! * */ protected void _write(Object _o) { if (_o instanceof H2dEvolution[]) ! writeEvol((H2dEvolution[])_o); ! else ! analyze_.addFatalError(DodicoResource.getS("Données invalides")); ! } --- 27,48 ---- */ public class CrbWriter extends FileOpWriterCharSimpleAbstract { + CrbFileFormat.CRBVersion v_; + /** + * @param _v la version a utiliser + */ + public CrbWriter(CrbFileFormat.CRBVersion _v) { + v_ = _v; } /** ! * * */ protected void _write(Object _o) { if (_o instanceof H2dEvolution[]) ! writeEvol((H2dEvolution[]) _o); ! else ! analyze_.addFatalError(DodicoResource.getS("Données invalides")); } *************** *** 51,125 **** } try { ! FortranWriter w= new FortranWriter(out_); w.setLineSeparator(lineSep_); w.stringField(1, v_.getVersionName()); w.stringField(0, "*!$ Version"); ! w.writeFields(new int[] { 12, 10 }); ! int n= _evol.length; int nbPoint; ! int step= DodicoLib.getStep(n); ! int pourcStep= (int) (100 / step); ! int pas= (int) (n / step); ! int pMax= pas; ! int pourc=0; ! int[] fmtEntete= new int[] { 20, 1, 5 }; ! int[] fmtCorps= new int[] { 10, 1, 10 }; ! for (int i= 0; i < n; i++) { ! H2dEvolution e= _evol[i]; w.intField(2, e.getPasTempNb()); ! String nom= e.getNom(); if ((nom == null) || (nom.length() == 0)) { ! nom= "C " + CtuluLib.getString(i); } w.stringField(0, nom); w.writeFields(fmtEntete); ! nbPoint=e.getPasTempNb(); ! for(int j=0;j<nbPoint;j++){ w.doubleField(0, e.getQuickPasDeTemps(j)); w.doubleField(2, e.getQuickValue(j)); w.writeFields(fmtCorps); } ! if (progress_!=null) { ! if (i > pMax) { ! pourc += pourcStep; ! progress_.setProgression(pourc); ! pMax += pas; ! } ! } } } catch (IOException e) { analyze_.manageException(e); } - } /** ! * */ public FileFormatVersion getVersion() { return v_; } ! ! public FileOperationSynthese write(H2dEvolution[] _evol){ ! if (progress_ != null) ! progress_.setDesc( ! getOperationDescription() + CtuluLib.ESPACE + getVersion()); writeEvol(_evol); return closeOperation(_evol); } ! ! ! public final FileOperationSynthese write( ! H2dEvolution[] _o, ! File _f, ! ProgressionInterface _inter) { setFile(_f); setProgressReceiver(_inter); return write(_o); } - - - - } --- 52,122 ---- } try { ! FortranWriter w = new FortranWriter(out_); w.setLineSeparator(lineSep_); w.stringField(1, v_.getVersionName()); w.stringField(0, "*!$ Version"); ! w.writeFields(new int[] { 12, 10}); ! int n = _evol.length; int nbPoint; ! ProgressionUpdater up = new ProgressionUpdater(progress_); ! up.setValue(4, n); ! up.majProgessionStateOnly(); ! int[] fmtEntete = new int[] { 20, 1, 5}; ! int[] fmtCorps = new int[] { 10, 1, 10}; ! for (int i = 0; i < n; i++) { ! H2dEvolution e = _evol[i]; w.intField(2, e.getPasTempNb()); ! String nom = e.getNom(); if ((nom == null) || (nom.length() == 0)) { ! nom = "C " + CtuluLib.getString(i); } w.stringField(0, nom); w.writeFields(fmtEntete); ! nbPoint = e.getPasTempNb(); ! for (int j = 0; j < nbPoint; j++) { w.doubleField(0, e.getQuickPasDeTemps(j)); w.doubleField(2, e.getQuickValue(j)); w.writeFields(fmtCorps); } ! up.majAvancement(); } } catch (IOException e) { analyze_.manageException(e); } } + /** ! * @return la version utilisee */ public FileFormatVersion getVersion() { return v_; } ! ! /** ! * @param _evol ! * @return ! */ ! public FileOperationSynthese write(H2dEvolution[] _evol) { ! if (progress_ != null) ! progress_.setDesc( ! getOperationDescription() + CtuluLib.ESPACE + getVersion()); writeEvol(_evol); return closeOperation(_evol); } ! ! /** ! * @param _o les evolutions a enregistrer ! * @param _f le fichier ! * @param _inter la barre de progression ! * @return la synthese de l'operation ! */ public final FileOperationSynthese write( ! H2dEvolution[] _o, ! File _f, ! ProgressionInterface _inter) { setFile(_f); setProgressReceiver(_inter); return write(_o); } } Index: RefluxSolutionInitWriter.java =================================================================== RCS file: /cvsroot/fudaa/fudaa_devel/dodico/src/org/fudaa/dodico/reflux/io/RefluxSolutionInitWriter.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RefluxSolutionInitWriter.java 16 Mar 2004 16:47:28 -0000 1.1 --- RefluxSolutionInitWriter.java 31 Mar 2004 08:14:29 -0000 1.2 *************** *** 14,23 **** --- 14,30 ---- import java.io.IOException; import java.io.OutputStream; + import org.fudaa.dodico.commun.DodicoAnalyze; import org.fudaa.dodico.commun.DodicoResource; + import org.fudaa.dodico.commun.ProgressionInterface; import org.fudaa.dodico.commun.ProgressionUpdater; + import org.fudaa.dodico.ef.EfGrid; + import org.fudaa.dodico.fichiers.FileOperationSynthese; import org.fudaa.dodico.fichiers.FileWriteOperationAbstract; import org.fudaa.dodico.fortran.FortranBinaryOutputStream; import org.fudaa.dodico.fortran.FortranInterface; + import org.fudaa.dodico.h2d.reflux.H2dRefluxSolutionInit2DWriterInterface; + + import sun.security.krb5.internal.ccache.an; *************** *** 59,63 **** try { out = new FileOutputStream(_f); ! } catch (FileNotFoundException _e) { return; } --- 66,72 ---- try { out = new FileOutputStream(_f); ! } catch (IOException _e) { ! analyze_.manageException(_e); ! _e.printStackTrace(); return; } *************** *** 67,75 **** private void setOut(OutputStream _out) { ! try{ ! out_ = new FortranBinaryOutputStream(_out,true); } ! catch(IOException e){ ! out_=null; } } --- 76,85 ---- private void setOut(OutputStream _out) { ! try { ! out_ = new FortranBinaryOutputStream(_out, true); } ! catch (IOException e) { ! e.printStackTrace(); ! out_ = null; } } *************** *** 79,105 **** */ protected void _write(Object _o) { ! if(!(_o instanceof double[])){ _donneesInvalides(_o); } ! else _write((double[])_o); } ! protected void _write(double[] _data) { ! if(out_==null){ analyze_.addFatalError(DodicoResource.getS("Le flux de sortie est nul")); } ! try{ ! ProgressionUpdater up=new ProgressionUpdater(progress_); ! up.setValue(4,_data.length); ! for (int i= 0; i < _data.length; i++){ ! out_.writeDoublePrecision(_data[i]); ! up.majAvancement(); } ! out_.writeRecord(); } ! catch(IOException e){ analyze_.manageException(e); } ! } } --- 89,149 ---- */ protected void _write(Object _o) { ! if (!(_o instanceof double[])) { _donneesInvalides(_o); } ! else _write((double[]) _o); } ! protected void _write(double[] _data) { ! if (out_ == null) { analyze_.addFatalError(DodicoResource.getS("Le flux de sortie est nul")); + return; } ! if(_data==null){ ! analyze_.addFatalError(DodicoResource.getS("Les données sont nulles")); ! return; } ! try { ! ProgressionUpdater up = new ProgressionUpdater(progress_); ! up.setValue(4, _data.length); ! for (int i = 0; i < _data.length; i++) { ! out_.writeDoublePrecision(_data[i]); ! up.majAvancement(); ! } ! out_.writeRecord(); } ! catch (IOException e) { analyze_.manageException(e); } ! } ! ! ! /** ! * @param _g le maillage associe ! * @param _f le fichier de dest ! * @param _init l'interface contenant les valeurs a ecrire ! * @param _prog la progression ! * @return la synthese de l'ecriture contenant le tableau de double generee comme source ! */ ! public static FileOperationSynthese writeSI(EfGrid _g, H2dRefluxSolutionInit2DWriterInterface _init, ! File _f, ProgressionInterface _prog) { ! int nbPt = _g.getPtsNb(); ! double[] vals = new double[nbPt * 3]; ! if (_prog != null) _prog.setProgression(30); ! int idxInVal = 0; ! ProgressionUpdater up = new ProgressionUpdater(_prog); ! up.setValue(3, nbPt, 30, 70); ! up.majProgessionStateOnly(); ! for (int i = 0; i < nbPt; i++) { ! vals[idxInVal++] = _init.getU(i); ! vals[idxInVal++] = _init.getV(i); ! if (_g.isExtremePoint(i)) { ! vals[idxInVal++] = _init.getH(i)+_g.getPt(i).getZ(); ! } ! } ! double[] fvals = new double[idxInVal]; ! System.arraycopy(vals, 0, fvals, 0, fvals.length); ! return RefluxSolutionInitFileFormat.getInstance().getLastVersionInstance().write(_f, fvals, ! _prog); } } |