src/IplPaws/PawsFieldDataSource.cpp

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 /***************************************************************************
00003  *
00004  * The IPPL Framework
00005  * 
00006  * This program was prepared by PSI. 
00007  * All rights in the program are reserved by PSI.
00008  * Neither PSI nor the author(s)
00009  * makes any warranty, express or implied, or assumes any liability or
00010  * responsibility for the use of this software
00011  *
00012  * Visit http://www.acl.lanl.gov/POOMS for more details
00013  *
00014  ***************************************************************************/
00015 
00016 // -*- C++ -*-
00017 /***************************************************************************
00018  *
00019  * The IPPL Framework
00020  * 
00021  *
00022  * Visit http://people.web.psi.ch/adelmann/ for more details
00023  *
00024  ***************************************************************************/
00025 
00026 #include <iostream.h>
00027 #include "IpplPaws/PawsFieldDataSource.h"
00028 #include "IpplPaws/PawsFieldData.h"
00029 #include "IpplPaws/PawsDataConnect.h"
00030 #include "Message/Communicate.h"
00031 #include "Utility/IpplInfo.h"
00032 #include "Utility/Pstring.h"
00033 
00034 // PAWS include files
00035 #include "Paws/Paws.h"
00036 
00038 // constructor: the name, the connection, the transfer method,
00039 // the field to connect, and the parent node.
00040 template<class T, unsigned Dim, class M, class C>
00041 PawsFieldDataSource<T,Dim,M,C>::PawsFieldDataSource(const char *nm,
00042                                                     DataConnect *dc,
00043                                                     int tm,
00044                                                     Field_t &F)
00045   : DataSourceObject(nm, &F, dc, tm), myField(F) {
00046  
00047   string filestring = "paws";
00048   if (string(dc->ID()) != filestring) {
00049     ERRORMSG("Illegal DataConnect object for Paws Data Object." << endl);
00050     Connection = 0;
00051   } else {
00052     // get the data connection pointer for a PAWS connection
00053     pdc = (PawsDataConnect *)dc;
00054 
00055     // figure out the transfer method
00056     if (TransferMethod == DataSource::DEFAULT)
00057       TransferMethod = dc->getDefaultTransferMethod();
00058 
00059     int mode = PAWS_OUT;
00060 
00061     if (TransferMethod == DataSource::INPUT)
00062       mode = PAWS_IN;
00063     else if (TransferMethod == DataSource::OUTPUT)
00064       mode = PAWS_OUT;
00065     else if (TransferMethod == DataSource::BOTH)
00066       mode = PAWS_INOUT;
00067 
00068     // create a PawsFieldData object, the main interface from the IPPL Field
00069     // to the PAWS data transfer capabilities.  It creates/uses the DLRep and DLDesc
00070     // objects to get the domain and storage information, to calculate
00071     // send/receive schedules, and to pack and unpack data during transfers.
00072     // NOTE: it can communicate using PAWS STANDARD
00073     pawsdata = new PawsFieldData_t(nm, &F, mode,
00074                               PAWS_SYNC, PAWS_COLUMN,
00075                               *(pdc->getPawsApp())); 
00076   }
00077 }
00078 
00079 
00081 // destructor
00082 template<class T, unsigned Dim, class M, class C>
00083 PawsFieldDataSource<T,Dim,M,C>::~PawsFieldDataSource() {
00084   //Inform dbgmsg("PawsFieldDataSource::~PawsFieldDataSource",
00085   //              INFORM_ALL_NODES);
00086 
00087   //dbgmsg << "Deleting the PawsFieldData object ..." << endl;
00088   if (pawsdata != 0 && pdc != 0) {
00089     //dbgmsg << "Waiting at barrier before deleting PawsFieldData ..." << endl;
00090     //Ippl::Comm->barrier();
00091     pdc->barrier();
00092     delete pawsdata;
00093   }
00094 
00095 }
00096 
00097 
00099 // Update the object, that is, make sure the receiver of the data has a
00100 // current and consistent snapshot of the current state.  Return success.
00101 template<class T, unsigned Dim, class M, class C>
00102 bool PawsFieldDataSource<T,Dim,M,C>::update() {
00103 
00104   pdc->barrier();
00105 
00106   if (TransferMethod == DataSource::OUTPUT ||
00107       TransferMethod == DataSource::BOTH) {
00108 
00109     pawsdata->send();
00110 
00111   } else if (TransferMethod == DataSource::INPUT ||
00112              TransferMethod == DataSource::BOTH) {
00113 
00114     pawsdata->receive();
00115   }
00116 
00117   return true;
00118 }
00119 
00120 
00122 // Indicate to the receiver that we're allowing them time to manipulate the
00123 // data (e.g., for a viz program, to rotate it, change representation, etc.)
00124 // This should only return when the manipulation is done.
00125 template<class T, unsigned Dim, class M, class C>
00126 void PawsFieldDataSource<T,Dim,M,C>::interact(const char *) {
00127   pdc->poll();
00128 }
00129 
00130 
00131 /***************************************************************************
00132  * $RCSfile: PawsFieldDataSource.cpp,v $   $Author: adelmann $
00133  * $Revision: 1.1.1.1 $   $Date: 2003/01/23 07:40:32 $
00134  * IPPL_VERSION_ID: $Id: PawsFieldDataSource.cpp,v 1.1.1.1 2003/01/23 07:40:32 adelmann Exp $ 
00135  ***************************************************************************/

Generated on Mon Jan 16 13:23:49 2006 for IPPL by  doxygen 1.4.6