dumper_atom_vgroup.cpp

Go to the documentation of this file.
00001 /* ./dumper/dumper_atom_vgroup.cpp 
00002 **********************************
00003 Copyright INRIA and CEA 
00004 
00005 author : Guillaume ANCIAUX (anciaux@labri.fr, g.anciaux@laposte.net)
00006 
00007 The LibMultiScale is a C++ parallel framework for the multiscale
00008 coupling methods dedicated to material simulations. This framework
00009 provides an API which makes it possible to program coupled simulations
00010 and integration of already existing codes.
00011 
00012 This Project is done in a collaboration between INRIA Futurs Bordeaux
00013 within ScAlApplix team and CEA/DPTA Ile de France. 
00014 
00015 This software is governed by the CeCILL-C license under French law and
00016 abiding by the rules of distribution of free software.  You can  use, 
00017 modify and/ or redistribute the software under the terms of the CeCILL-C
00018 license as circulated by CEA, CNRS and INRIA at the following URL
00019 "http://www.cecill.info". 
00020 
00021 As a counterpart to the access to the source code and  rights to copy,
00022 modify and redistribute granted by the license, users are provided only
00023 with a limited warranty  and the software's author,  the holder of the
00024 economic rights,  and the successive licensors  have only  limited
00025 liability. 
00026 
00027 In this respect, the user's attention is drawn to the risks associated
00028 with loading,  using,  modifying and/or developing or reproducing the
00029 software by the user in light of its specific status of free software,
00030 that may mean  that it is complicated to manipulate,  and  that  also
00031 therefore means  that it is reserved for developers  and  experienced
00032 professionals having in-depth computer knowledge. Users are therefore
00033 encouraged to load and test the software's suitability as regards their
00034 requirements in conditions enabling the security of their systems and/or 
00035 data to be ensured and,  more generally, to use and operate it in the 
00036 same conditions as regards security. 
00037 
00038 The fact that you are presently reading this means that you have had
00039 knowledge of the CeCILL-C license and that you accept its terms.
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   /* j'initialise les tranches pour la projection */
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   /* je creer le fichier pour le dump de la vitesse de groupe */
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   //  Boule & b = static_cast<Boule &>(*this->geom);
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       /* la distance au centre de la boule est utilise pour caracteriser la projection dans l'espace des phases */
00103 
00104       DUMP("le d trouve = " << d,DBG_ALL);
00105       //      d = (d - b.Rmin())/(b.Rmax()-b.Rmin());
00106 
00107       DUMP("le d rapporte dans 0..1 = " << d,DBG_ALL);
00108       /* petit calcul simpliste pour trouver la tranche d'oignon que l'ont veux */
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       /* prepare le deplacement */
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       /* on additionne le deplacement de chaque atome dans la couche qui le concerne */
00124       deplacements_par_tranche[couche_index] += dep;
00125       /* on augmente le nombre d'atomes dans la couche - il faudra faire la moyenne a la fin !*/
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 &it;
00135   
00136   for (unsigned int k=0;k < nb_tranches;++k)
00137     {
00138       /* on dump directement la moyenne */
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

Generated on Fri Sep 7 13:12:34 2007 for LibMultiScale by  doxygen 1.5.2