Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

PressureProfileReduction Class Reference

List of all members.

Public Member Functions

 PressureProfileReduction (int rtag, int numslabs, int numpartitions, const char *myname, int outputfreq)
 ~PressureProfileReduction ()
void getData (int firsttimestep, int step, const Lattice &lattice, BigReal *total)

Constructor & Destructor Documentation

PressureProfileReduction::PressureProfileReduction int  rtag,
int  numslabs,
int  numpartitions,
const char *  myname,
int  outputfreq
[inline]
 

Definition at line 69 of file Controller.C.

References average(), BigReal, ReductionMgr::Object(), and ReductionMgr::willRequire().

00071   : nslabs(numslabs), freq(outputfreq) {
00072     name = strdup(myname);
00073     nelements = 3*nslabs * numpartitions;
00074     reduction = ReductionMgr::Object()->willRequire(rtag,nelements);
00075 
00076     average = new BigReal[nelements];
00077     count = 0;
00078   }

PressureProfileReduction::~PressureProfileReduction  )  [inline]
 

Definition at line 79 of file Controller.C.

00079                               {
00080     delete [] average;
00081     delete reduction;
00082     free(name);
00083   }


Member Function Documentation

void PressureProfileReduction::getData int  firsttimestep,
int  step,
const Lattice lattice,
BigReal total
[inline]
 

Definition at line 85 of file Controller.C.

References average(), BigReal, iout, RequireReduction::item(), PRESSUREFACTOR, RequireReduction::require(), and Lattice::volume().

Referenced by Controller::printEnergies().

00086                       {
00087     reduction->require();
00088 
00089     int i;
00090     double inv_volume = 1.0 / lattice.volume();
00091     // accumulate the pressure profile computed for this step into the average.
00092     int arraysize = 3*nslabs;
00093     for (i=0; i<nelements; i++) {
00094       BigReal val = reduction->item(i) * inv_volume;
00095       average[i] += val;
00096       total[i % arraysize] += val;
00097     }
00098     count++;
00099     if (!(step % freq)) {
00100       // convert NAMD internal virial to pressure in units of bar 
00101       BigReal scalefac = PRESSUREFACTOR * nslabs;
00102  
00103       iout << "PPROFILE" << name << ": " << step << " ";
00104       if (step == firsttimestep) {
00105         // output pressure profile for this step
00106         for (i=0; i<nelements; i++) 
00107           iout << reduction->item(i)*scalefac*inv_volume << " ";
00108       } else {
00109         // output pressure profile averaged over the last Freq steps.
00110         scalefac /= count;
00111         for (i=0; i<nelements; i++) 
00112           iout << average[i]*scalefac << " ";
00113       }
00114       iout << "\n" << endi; 
00115       // Clear the average for the next block
00116       memset(average, 0, nelements*sizeof(BigReal));
00117       count = 0;
00118     }
00119   }


The documentation for this class was generated from the following file:
Generated on Fri Oct 10 04:07:50 2008 for NAMD by  doxygen 1.3.9.1