00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #define NEED_STAMP
00043 #define LOCAL_MODULE MOD_DUMPER
00044
00045 #include "../common/common.h"
00046 #include "dumper_vgroupe.h"
00047 #include "../md/lib_md.h"
00048
00049 template <typename Domain,unsigned int Dim>
00050 void DumperVGroupe<Domain,Dim>::SetParam(char* key,double value){
00051
00052 }
00053
00054 template <typename Domain,unsigned int Dim>
00055 void DumperVGroupe<Domain,Dim>::Init(){
00056
00057 nb_tranches = NB_TRANCHES;
00058 if (Dim == 1)
00059 nb_tranches = Dumper<Domain,Dim>::dom.getContener().nbElem();
00060
00061 deplacements_par_tranche = new double[nb_tranches];
00062 nb_par_tranche = new unsigned int[nb_tranches];
00063
00064
00065 char temp[255];
00066 snprintf(temp,255,"%s_vgroupe.plot",Dumper<Domain,Dim>::base_name);
00067 output[0] = fopen(temp,"wb+");
00068 }
00069
00070 template <typename Domain,unsigned int Dim>
00071 void DumperVGroupe<Domain,Dim>::Dump(){
00072 UnitsConverter unit;
00073 unit.SetReadUnits(UnitsConverter::AtomsUnits);
00074
00075
00076
00077 unsigned int couche_index=0;
00078 unsigned int cpt = 0;
00079
00080 typedef typename Domain::RefDof RefAtom;
00081 typedef typename Domain::ContenerDofs ContenerAtoms;
00082 typedef typename Domain::IteratorDofs IteratorAtoms;
00083
00084 ContenerAtoms & c = Dumper<Domain,Dim>::dom.getContener();
00085 IteratorAtoms & it = c.GetIterator();
00086 RefAtom at = it.GetFirst();
00087
00088 memset(nb_par_tranche,0,sizeof(int)*nb_tranches);
00089 memset(deplacements_par_tranche,0,sizeof(double)*nb_tranches);
00090
00091 at = it.GetFirst();
00092 while (!it.end())
00093 {
00094 double d;
00095 if (Dim == 1)
00096 d = fabs(at.position0(0));
00097 else if (Dim == 2)
00098 d = ipow(at.position0(0),2)+ipow(at.position0(1),2);
00099 else if (Dim == 3)
00100 d = ipow(at.position0(0),2)+ipow(at.position0(1),2)+ipow(at.position0(2),2);
00101
00102
00103
00104 DUMP("le d trouve = " << d,DBG_ALL);
00105
00106
00107 DUMP("le d rapporte dans 0..1 = " << d,DBG_ALL);
00108
00109 couche_index = static_cast<unsigned int>(nb_tranches*d);
00110 if (Dim == 1) couche_index = cpt;
00111 DUMP("couche_index trouve = " << couche_index,DBG_ALL);
00112
00113
00114
00115 double ux = (at.position(0) - at.position0(0))*unit.etalon_metre;
00116 double uy = (at.position(1) - at.position0(1))*unit.etalon_metre;
00117 double uz = (at.position(2) - at.position0(2))*unit.etalon_metre;
00118
00119 double dep = sqrt(ux*ux+uy*uy+uz*uz);
00120 if (Dim == 1)
00121 dep = ux;
00122 DUMP("deplacement calcule = " << dep,DBG_ALL);
00123
00124 deplacements_par_tranche[couche_index] += dep;
00125
00126 ++nb_par_tranche[couche_index];
00127
00128 DUMP("deplacement_par_tranche[" << couche_index << "]= " << deplacements_par_tranche[couche_index],DBG_ALL);
00129 DUMP("nb_par_tranche[" << couche_index << "]= " << nb_par_tranche[couche_index],DBG_ALL);
00130 at = it.GetNext();
00131 ++cpt;
00132 }
00133
00134 delete ⁢
00135
00136 for (unsigned int k=0;k < nb_tranches;++k)
00137 {
00138
00139 if (nb_par_tranche[couche_index] == 0) continue;
00140 DUMP("deplacement_moy_par_tranche[" << couche_index << "]= " << deplacements_par_tranche[k] << "/" << nb_par_tranche[couche_index],DBG_ALL);
00141 fprintf(output[0],"%d\t%d\t%.15e\n",Dumper<Domain,Dim>::dump_step,k+1,deplacements_par_tranche[k]/nb_par_tranche[couche_index]);
00142 }
00143 }
00144
00145 #ifdef USING_STAMP
00146 template class DumperVGroupe<DomainStamp,1>;
00147 template class DumperVGroupe<DomainStamp,2>;
00148 template class DumperVGroupe<DomainStamp,3>;
00149 #endif