src/Field/IndexedBareField.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 files
00027 #include "Field/IndexedBareField.h"
00028 #include "Utility/IpplInfo.h"
00029 #include "Utility/PAssert.h"
00030 #include "Profile/Profiler.h"
00031 #include "FieldLayout/FieldLayout.h"
00032 
00033 #ifdef IPPL_STDSTL
00034 #include <vector>
00035 using std::vector;
00036 #else
00037 #include <vector.h>
00038 #endif
00039 
00040 #ifdef IPPL_USE_STANDARD_HEADERS
00041 #include <iostream>
00042 using namespace std;
00043 #else
00044 #include <iostream.h>
00045 #endif
00046 
00047 //----------------------------------------------------------------------
00048 
00049 //MWERKS: moved this member template into class definition, in 
00050 //MWERKS: IndexedBareField.h
00051 // template<class T, unsigned D1>
00052 // template<unsigned int D2>
00053 // bool
00054 // IndexedBareFieldIterator<T,D1>::plugBase(const NDIndex<D2>& i)
00055 
00057 
00058 
00059 template< class T, unsigned Dim, unsigned Brackets >
00060 void 
00061 IndexedBareField<T,Dim,Brackets>::write(ostream& out)
00062 {
00063   TAU_TYPE_STRING(taustr, CT(*this) + " void (ostream )" );
00064   TAU_PROFILE("IndexedBareField::write()", taustr, TAU_FIELD | TAU_IO);
00065   // make sure we have the right number of brackets
00066   PInsist(Dim == Brackets,
00067           "Field not fully indexed in IndexedBareField::write!!");
00068   NDIndex<Dim> testIndex;
00069   for (unsigned d=0; d<Dim; d++)
00070     testIndex[d] = Indexes[d];
00071 
00072   // make a BareField which will store the subset
00073   FieldLayout<Dim> subfl(testIndex);
00074   BareField<T,Dim> subset(subfl);
00075 
00076   // assign values to this subfield
00077   //  my_indexed_assign(subset, A, testIndex);
00078   assign(subset[testIndex], A[testIndex]);
00079 
00080   // finally, print out the subfield
00081   out << subset;
00082 }
00083 
00084 
00086 
00087 template<class T, unsigned Dim, unsigned Brackets>
00088 void
00089 IndexedBareField<T,Dim,Brackets>::getsingle(T& r)
00090 {
00091   TAU_TYPE_STRING(taustr, CT(*this) + " void (" + CT(r) + " )" );
00092   TAU_PROFILE("IndexedBareField::getsingle()", taustr, TAU_FIELD);
00093   A.getsingle(Indexes, r);
00094 }
00095 
00097 // Return a single value.
00098 template<class T, unsigned Dim, unsigned Brackets>
00099 T
00100 IndexedBareField<T,Dim,Brackets>::get()
00101 {
00102   T r;
00103   TAU_TYPE_STRING(taustr, CT(*this) + " " + CT(r) + " ()" );
00104   TAU_PROFILE("IndexedBareField::get()", taustr, TAU_FIELD);
00105   getsingle(r);
00106   return r;
00107 }
00108 
00109 /***************************************************************************
00110  * $RCSfile: IndexedBareField.cpp,v $   $Author: adelmann $
00111  * $Revision: 1.1.1.1 $   $Date: 2003/01/23 07:40:26 $
00112  * IPPL_VERSION_ID: $Id: IndexedBareField.cpp,v 1.1.1.1 2003/01/23 07:40:26 adelmann Exp $ 
00113  ***************************************************************************/

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