src/Field/Field.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/Field.h"
00028 #include "Field/IndexedField.h"
00029 #include "DataSource/MakeDataSource.h"
00030 #include "Index/SIndex.h"
00031 #include "SubField/SubField.h"
00032 #include "Utility/IpplStats.h"
00033 #include "Profile/Profiler.h"
00034 
00035 //=============================================================================
00036 // Global functions
00037 //=============================================================================
00038 
00039 //-----------------------------------------------------------------------------
00040 // Wrappers for internal mesh object constructor calls:
00041 //-----------------------------------------------------------------------------
00042 // Generic case, report unimplemented mesh type:
00043 // (Compiler limitations doesn't allow this yet; user will get an obscure
00044 // compile error instead of this runtime error if he specifies an unsupported
00045 // mesh type for the Field Mesh parameter --tjw):
00046 // template<class T, unsigned Dim, class M, class C>
00047 // M* makeMesh(Field<T,Dim,M,C>& f)
00048 // {
00049 //   ERRORMSG("makeMesh() invoked from Field(): unimplemented mesh type" << endl);
00050 // }
00051 
00052 // Generic makeMesh function
00053 template<class T, unsigned Dim, class M, class C>
00054 M* makeMesh(Field<T,Dim,M,C>& f)
00055 { 
00056   TAU_TYPE_STRING(taustr, "MeshType* (" + CT(f) + " )" );
00057   TAU_PROFILE("makeMesh()", taustr, TAU_FIELD);
00058   
00059   NDIndex<Dim> ndi;
00060   ndi = f.getLayout().getDomain();
00061   return (new M(ndi));
00062 }
00063 
00064 /*
00065 // Specialization for UniformCartesian
00066 template<class T, unsigned Dim, class MFLOAT, class C>
00067 UniformCartesian<Dim,MFLOAT>*
00068 makeMesh(Field<T,Dim,UniformCartesian<Dim,MFLOAT>,C>& f)
00069 { 
00070   TAU_TYPE_STRING(taustr, "UniformCartesian<Dim,MFLOAT>* (" + CT(f) + " )" );
00071   TAU_PROFILE("makeMesh()", taustr, TAU_FIELD);
00072   
00073   NDIndex<Dim> ndi;
00074   ndi = f.getLayout().getDomain();
00075   return (new UniformCartesian<Dim,MFLOAT>(ndi));
00076 }
00077 
00078 // Specialization for Cartesian
00079 template<class T, unsigned Dim, class MFLOAT, class C>
00080 Cartesian<Dim,MFLOAT>*
00081 makeMesh(Field<T,Dim,Cartesian<Dim,MFLOAT>,C>& f)
00082 {
00083   TAU_TYPE_STRING(taustr, "Cartesian<Dim,MFLOAT>* (" + CT(f) + " )" );
00084   TAU_PROFILE("makeMesh()", taustr, TAU_FIELD);
00085 
00086   NDIndex<Dim> ndi;
00087   ndi = f.getLayout().getDomain();
00088   return (new Cartesian<Dim,MFLOAT>(ndi));
00089 }
00090 */
00091 
00092 //=============================================================================
00093 // Field member functions
00094 //=============================================================================
00095 
00096 
00098 // A default constructor, which should be used only if the user calls the
00099 // 'initialize' function before doing anything else.  There are no special
00100 // checks in the rest of the Field methods to check that the Field has
00101 // been properly initialized
00102 template<class T, unsigned Dim, class M, class C>
00103 Field<T,Dim,M,C>::Field() {
00104   TAU_TYPE_STRING(taustr, CT(*this) + " void ()" );
00105   TAU_PROFILE("Field::Field()", taustr, TAU_FIELD); 
00106   store_mesh(0, true);
00107 }
00108 
00109 
00111 // Field destructor
00112 template<class T, unsigned Dim, class M, class C>
00113 Field<T,Dim,M,C>::~Field() {
00114   TAU_TYPE_STRING(taustr, CT(*this) + " void ()" );
00115   TAU_PROFILE("Field::~Field()", taustr, TAU_FIELD); 
00116   delete_mesh();
00117 }
00118 
00119 
00121 // Create a new Field with a given layout and optional guard cells.
00122 // The default type of BCond lets you add new ones dynamically.
00123 // The makeMesh() global function is a way to allow for different types of
00124 // constructor arguments for different mesh types.
00125 template<class T, unsigned Dim, class M, class C>
00126 Field<T,Dim,M,C>::Field(Layout_t & l) : BareField<T,Dim>(l) {
00127   TAU_TYPE_STRING(taustr, CT(*this) + " void (" + CT(l) + " )" );
00128   TAU_PROFILE("Field::Field()", taustr, TAU_FIELD); 
00129   store_mesh(makeMesh(*this), true);
00130 }
00131 
00132 template<class T, unsigned Dim, class M, class C>
00133 Field<T,Dim,M,C>::Field(Layout_t & l, const GuardCellSizes<Dim>& gc)
00134   : BareField<T,Dim>(l,gc) {
00135   TAU_TYPE_STRING(taustr, CT(*this) + " void (" + CT(l) + ", " + CT(gc) + " )" );
00136   TAU_PROFILE("Field::Field()", taustr, TAU_FIELD); 
00137   store_mesh(makeMesh(*this), true);
00138 }
00139 
00140 template<class T, unsigned Dim, class M, class C>
00141 Field<T,Dim,M,C>::Field(Layout_t & l, const BConds<T,Dim,M,C>& bc)
00142   : BareField<T,Dim>(l), Bc(bc) {
00143   TAU_TYPE_STRING(taustr, "void (" + CT(l) + ", " + CT(bc) + " )" );
00144   TAU_PROFILE("Field::Field()", taustr, TAU_FIELD); 
00145   store_mesh(makeMesh(*this), true);
00146 }
00147 
00148 template<class T, unsigned Dim, class M, class C>
00149 Field<T,Dim,M,C>::Field(Layout_t & l, const GuardCellSizes<Dim>& gc,
00150                         const BConds<T,Dim,M,C>& bc)
00151   : BareField<T,Dim>(l,gc), Bc(bc) {
00152   TAU_TYPE_STRING(taustr, "void (" + CT(l) + ", " + CT(gc) + ", " + CT(bc) + " )" );
00153   TAU_PROFILE("Field::Field()", taustr, TAU_FIELD); 
00154   store_mesh(makeMesh(*this), true);
00155 }
00156 
00157 template<class T, unsigned Dim, class M, class C>
00158 Field<T,Dim,M,C>::Field(Layout_t & l, const BConds<T,Dim,M,C>& bc,
00159                         const GuardCellSizes<Dim>& gc)
00160   : BareField<T,Dim>(l,gc), Bc(bc) {
00161   TAU_TYPE_STRING(taustr, "void (" + CT(l) + ", " + CT(bc) + ", " + CT(gc) + " )" );
00162   TAU_PROFILE("Field::Field()", taustr, TAU_FIELD); 
00163   store_mesh(makeMesh(*this), true);
00164 }
00165 
00166 template<class T, unsigned Dim, class M, class C>
00167 Field<T,Dim,M,C>::Field(FieldSpec<T,Dim,M,C>& spec)
00168   : BareField<T,Dim>( (Layout_t &) spec.get_Layout(), spec.get_GC()),
00169     Bc(spec.get_BC()) {
00170   TAU_TYPE_STRING(taustr, "void (" + CT(spec) + " )" );
00171   TAU_PROFILE("Field::Field()", taustr, TAU_FIELD); 
00172   store_mesh(makeMesh(*this), true);
00173 }
00174 
00175 
00177 // Constructors which include a Mesh object as argument
00178 template<class T, unsigned Dim, class M, class C>
00179 Field<T,Dim,M,C>::Field(Mesh_t& m, Layout_t & l)
00180   : BareField<T,Dim>(l) {
00181   TAU_TYPE_STRING(taustr, CT(*this) + " void (Mesh_t, " + CT(l) + " )" );
00182   TAU_PROFILE("Field::Field()", taustr, TAU_FIELD); 
00183   store_mesh(&m, false);
00184 }
00185 
00186 template<class T, unsigned Dim, class M, class C>
00187 Field<T,Dim,M,C>::Field(Mesh_t& m, Layout_t & l,
00188                         const GuardCellSizes<Dim>& gc)
00189   : BareField<T,Dim>(l,gc) {
00190   TAU_TYPE_STRING(taustr, CT(*this) + " void (Mesh_t, " + CT(l) + ", " + CT(gc) 
00191     + " )" );
00192   TAU_PROFILE("Field::Field()", taustr, TAU_FIELD); 
00193   store_mesh(&m, false);
00194 }
00195 
00196 template<class T, unsigned Dim, class M, class C>
00197 Field<T,Dim,M,C>::Field(Mesh_t& m, Layout_t & l,
00198                         const BConds<T,Dim,M,C>& bc)
00199   : BareField<T,Dim>(l), Bc(bc) {
00200   TAU_TYPE_STRING(taustr, "void (Mesh_t, " + CT(l) + ", " + CT(bc) + " )" );
00201   TAU_PROFILE("Field::Field()", taustr, TAU_FIELD); 
00202   store_mesh(&m, false);
00203 }
00204 
00205 template<class T, unsigned Dim, class M, class C>
00206 Field<T,Dim,M,C>::Field(Mesh_t& m, Layout_t & l,
00207                         const GuardCellSizes<Dim>& gc,
00208                         const BConds<T,Dim,M,C>& bc)
00209   : BareField<T,Dim>(l,gc), Bc(bc) {
00210   TAU_TYPE_STRING(taustr, "void (Mesh_t, " + CT(l) + ", " + CT(gc) + ", " +  CT(bc) 
00211     + " )" );
00212   TAU_PROFILE("Field::Field()", taustr, TAU_FIELD); 
00213   store_mesh(&m, false);
00214 }
00215 
00216 template<class T, unsigned Dim, class M, class C>
00217 Field<T,Dim,M,C>::Field(Mesh_t& m, Layout_t & l,
00218                         const BConds<T,Dim,M,C>& bc,
00219                         const GuardCellSizes<Dim>& gc)
00220   : BareField<T,Dim>(l,gc), Bc(bc) {
00221   TAU_TYPE_STRING(taustr, "void (Mesh_t, " + CT(l) + ", " + CT(bc) + ", " +  CT(gc) 
00222     + " )" );
00223   TAU_PROFILE("Field::Field()", taustr, TAU_FIELD); 
00224   store_mesh(&m, false);
00225 }
00226 
00227 template<class T, unsigned Dim, class M, class C>
00228 Field<T,Dim,M,C>::Field(Mesh_t& m, FieldSpec<T,Dim,M,C>& spec)
00229   : BareField<T,Dim>( (Layout_t &) spec.get_Layout(), spec.get_GC()),
00230     Bc(spec.get_BC()) {
00231   TAU_TYPE_STRING(taustr, "void (Mesh_t, " + CT(spec) + " )" );
00232   TAU_PROFILE("Field::Field()", taustr, TAU_FIELD); 
00233   store_mesh(&m, false);
00234 }
00235 
00236 
00238 // Initialize the Field, if it was constructed from the default constructor.
00239 // This should NOT be called if the Field was constructed by providing
00240 // a FieldLayout or FieldSpec
00241 template<class T, unsigned Dim, class M, class C>
00242 void Field<T,Dim,M,C>::initialize(Layout_t & l) {
00243   TAU_TYPE_STRING(taustr, CT(*this) + " void (" + CT(l) + " )" );
00244   TAU_PROFILE("Field::initialize()", taustr, TAU_FIELD); 
00245   BareField<T,Dim>::initialize(l);
00246   store_mesh(makeMesh(*this), true);
00247 }
00248 
00249 template<class T, unsigned Dim, class M, class C>
00250 void Field<T,Dim,M,C>::initialize(Layout_t & l,
00251                                   const GuardCellSizes<Dim>& gc) {
00252   TAU_TYPE_STRING(taustr, CT(*this) + " void (" + CT(l) + ", " + CT(gc) +  " )" );
00253   TAU_PROFILE("Field::initialize()", taustr, TAU_FIELD); 
00254   BareField<T,Dim>::initialize(l,gc);
00255   store_mesh(makeMesh(*this), true);
00256 }
00257 
00258 template<class T, unsigned Dim, class M, class C>
00259 void Field<T,Dim,M,C>::initialize(Layout_t & l,
00260                                   const BConds<T,Dim,M,C>& bc) {
00261   TAU_TYPE_STRING(taustr, "void (" + CT(l) + ", " + CT(bc) +  " )" );
00262   TAU_PROFILE("Field::initialize()", taustr, TAU_FIELD); 
00263   BareField<T,Dim>::initialize(l);
00264   Bc = bc;
00265   store_mesh(makeMesh(*this), true);
00266 }
00267 
00268 template<class T, unsigned Dim, class M, class C>
00269 void Field<T,Dim,M,C>::initialize(Layout_t & l,
00270                                   const GuardCellSizes<Dim>& gc,
00271                                   const BConds<T,Dim,M,C>& bc) {
00272   TAU_TYPE_STRING(taustr, "void (" + CT(l) + ", " + CT(gc) + ", " + CT(bc) +  " )" );
00273   TAU_PROFILE("Field::initialize()", taustr, TAU_FIELD); 
00274   BareField<T,Dim>::initialize(l,gc);
00275   Bc = bc;
00276   store_mesh(makeMesh(*this), true);
00277 }
00278 
00279 template<class T, unsigned Dim, class M, class C>
00280 void Field<T,Dim,M,C>::initialize(Layout_t & l,
00281                                   const BConds<T,Dim,M,C>& bc,
00282                                   const GuardCellSizes<Dim>& gc) {
00283   TAU_TYPE_STRING(taustr, "void (" + CT(l) + ", " + CT(bc) + ", " + CT(gc) +  " )" );
00284   TAU_PROFILE("Field::initialize()", taustr, TAU_FIELD); 
00285   BareField<T,Dim>::initialize(l,gc);
00286   Bc = bc;
00287   store_mesh(makeMesh(*this), true);
00288 }
00289 
00290 template<class T, unsigned Dim, class M, class C>
00291 void Field<T,Dim,M,C>::initialize(FieldSpec<T,Dim,M,C>& spec) {
00292   TAU_TYPE_STRING(taustr, "void (" + CT(spec) + " )" );
00293   TAU_PROFILE("Field::initialize()", taustr, TAU_FIELD); 
00294   BareField<T,Dim>::initialize( (Layout_t &) spec.get_Layout(),
00295                                 spec.get_GC());
00296   Bc = spec.get_BC();
00297   store_mesh(makeMesh(*this), true);
00298 }
00299 
00300 
00302 // Initialize the Field, also specifying a mesh
00303 template<class T, unsigned Dim, class M, class C>
00304 void Field<T,Dim,M,C>::initialize(Mesh_t& m, Layout_t & l) {
00305   TAU_TYPE_STRING(taustr, CT(*this) + " void (Mesh_t, " + CT(l) + " )" );
00306   TAU_PROFILE("Field::initialize()", taustr, TAU_FIELD); 
00307   BareField<T,Dim>::initialize(l);
00308   store_mesh(&m, false);
00309 }
00310 
00311 template<class T, unsigned Dim, class M, class C>
00312 void Field<T,Dim,M,C>::initialize(Mesh_t& m, Layout_t & l,
00313                                   const GuardCellSizes<Dim>& gc) {
00314   TAU_TYPE_STRING(taustr, CT(*this) + " void (Mesh_t, " + CT(l) + ", " + CT(gc) 
00315     + " )" );
00316   TAU_PROFILE("Field::initialize()", taustr, TAU_FIELD); 
00317   BareField<T,Dim>::initialize(l,gc);
00318   store_mesh(&m, false);
00319 }
00320 
00321 template<class T, unsigned Dim, class M, class C>
00322 void Field<T,Dim,M,C>::initialize(Mesh_t& m, Layout_t & l,
00323                                   const BConds<T,Dim,M,C>& bc) {
00324   TAU_TYPE_STRING(taustr, "void (Mesh_t, " + CT(l) + ", " + CT(bc) + " )" );
00325   TAU_PROFILE("Field::initialize()", taustr, TAU_FIELD); 
00326   BareField<T,Dim>::initialize(l);
00327   Bc = bc;
00328   store_mesh(&m, false);
00329 }
00330 
00331 template<class T, unsigned Dim, class M, class C>
00332 void Field<T,Dim,M,C>::initialize(Mesh_t& m, Layout_t & l,
00333                                   const GuardCellSizes<Dim>& gc,
00334                                   const BConds<T,Dim,M,C>& bc) {
00335   TAU_TYPE_STRING(taustr, "void (Mesh_t, " + CT(l) + ", " + CT(gc) + ", " +  CT(bc) 
00336     + " )" );
00337   TAU_PROFILE("Field::initialize()", taustr, TAU_FIELD); 
00338   BareField<T,Dim>::initialize(l,gc);
00339   Bc = bc;
00340   store_mesh(&m, false);
00341 }
00342 
00343 template<class T, unsigned Dim, class M, class C>
00344 void Field<T,Dim,M,C>::initialize(Mesh_t& m, Layout_t & l,
00345                                   const BConds<T,Dim,M,C>& bc,
00346                                   const GuardCellSizes<Dim>& gc) {
00347   TAU_TYPE_STRING(taustr, "void (Mesh_t, " + CT(l) + ", " + CT(bc) + ", " +  CT(gc) 
00348     + " )" );
00349   TAU_PROFILE("Field::initialize()", taustr, TAU_FIELD); 
00350   BareField<T,Dim>::initialize(l,gc);
00351   Bc = bc;
00352   store_mesh(&m, false);
00353 }
00354 
00355 template<class T, unsigned Dim, class M, class C>
00356 void Field<T,Dim,M,C>::initialize(Mesh_t& m, FieldSpec<T,Dim,M,C>& spec) {
00357   TAU_TYPE_STRING(taustr, "void (Mesh_t, " + CT(spec) + " )" );
00358   TAU_PROFILE("Field::initialize()", taustr, TAU_FIELD); 
00359   BareField<T,Dim>::initialize( (Layout_t &) spec.get_Layout(),
00360                                 spec.get_GC());
00361   Bc = spec.get_BC();
00362   store_mesh(&m, false);
00363 }
00364 
00365 
00367 // If you make any modifications using an iterator, you must call this.
00368 template<class T, unsigned Dim, class M, class C>
00369 void Field<T,Dim,M,C>::fillGuardCells(bool reallyFill) const {
00370   TAU_TYPE_STRING(taustr, CT(*this) + " void ()" );
00371   TAU_PROFILE("Field::fillGuardCells()", taustr, TAU_FIELD); 
00372 
00373   // Fill the internal guard cells.
00374   BareField<T,Dim>::fillGuardCells(reallyFill);
00375 
00376   // Handle the user-supplied boundary conditions. If we're not supposed
00377   // to really fill the guard cells and the BC does not change physical
00378   // cells, don't bother.
00379   if (reallyFill || Bc.changesPhysicalCells()) {
00380     // cast away const, so we can apply BC's
00381     Field<T,Dim,M,C>& ncf = const_cast<Field<T,Dim,M,C>&>(*this);
00382     ncf.getBConds().apply(ncf);
00383     INCIPPLSTAT(incBoundaryConditions);
00384   }
00385 }
00386 
00387 
00389 // When we apply a bracket it converts the type
00390 // to IndexedField so that we can check at compile time
00391 // that we have the right number of indexes and brackets.
00392 template<class T, unsigned Dim, class M, class C>
00393 IndexedField<T,Dim,1,M,C> Field<T,Dim,M,C>::operator[](const Index& idx) {
00394   TAU_TYPE_STRING(taustr, CT(*this) + " IndexedField<T,Dim,1,M,C> (Index )" );
00395   TAU_PROFILE("Field::operator[]()", taustr, TAU_FIELD); 
00396   return IndexedField<T,Dim,1,M,C>(*this,idx);
00397 }
00398 
00399 
00401 // Also allow using an integer instead of a whole Index
00402 template<class T, unsigned Dim, class M, class C>
00403 IndexedField<T,Dim,1,M,C> Field<T,Dim,M,C>::operator[](int i) {
00404   TAU_TYPE_STRING(taustr, CT(*this) + " IndexedField<T,Dim,1,M,C> (int )" );
00405   TAU_PROFILE("Field::operator[]()", taustr, TAU_FIELD); 
00406   return IndexedField<T,Dim,1,M,C>(*this,i);
00407 }
00408 
00409 
00411 // Also allow using a single NDIndex instead of N Index objects:
00412 template<class T, unsigned D, class M, class C>
00413 IndexedField<T,D,D,M,C> Field<T,D,M,C>::operator[](const NDIndex<D>& n) {
00414   TAU_TYPE_STRING(taustr, CT(*this) + " IndexedField<T,D,D,M,C> (" + CT(n) + " )" );
00415   TAU_PROFILE("Field::operator[]()", taustr, TAU_FIELD); 
00416   return IndexedField<T,D,D,M,C>(*this,n);
00417 }
00418 
00419 
00421 // Also allow using a sparse index
00422 template<class T, unsigned D, class M, class C>
00423 SubField<T,D,M,C,SIndex<D> > Field<T,D,M,C>::operator[](const SIndex<D>& s) {
00424   TAU_TYPE_STRING(taustr, CT(*this) + " SubField<T,D,M,C,SIndex<D>> (" +CT(s) + " )" );
00425   TAU_PROFILE("Field::operator[]()", taustr, TAU_FIELD); 
00426   return SubField<T,D,M,C,SIndex<D> >(*this, s);
00427 }
00428 
00429 
00431 // I/O (special stuff not inherited from BareField):
00432 // Print out contents of Centering class
00433 template<class T, unsigned Dim, class M, class C>
00434 void Field<T,Dim,M,C>::print_Centerings(ostream& out) {
00435   TAU_TYPE_STRING(taustr, CT(*this) + " void (ostream )" );
00436   TAU_PROFILE("Field::print_Centerings()", taustr, TAU_FIELD | TAU_IO); 
00437   Centering_t::print_Centerings(out);
00438 }
00439 
00440 
00442 // Repartition onto a new layout, or when the mesh changes
00443 template<class T, unsigned Dim, class M, class C>
00444 void Field<T,Dim,M,C>::Repartition(UserList *userlist) {
00445   TAU_TYPE_STRING(taustr, CT(*this) + " void (UserList * )" );
00446   TAU_PROFILE("Field::Repartition()", taustr, TAU_FIELD ); 
00447 
00448   // see if the userlist corresponds to our current mesh
00449   if (mesh != 0 && mesh->get_Id() == userlist->getUserListID()) {
00450     // for now, we don't care if the mesh changes ... but we might later
00451   } else {
00452     // the layout has changed, so redistribute our data
00453 
00454     // Cast to the proper type of FieldLayout.
00455     Layout_t *newLayout = (Layout_t *)( userlist );
00456 
00457     // Build a new temporary field on the new layout.
00458     Field<T,Dim,M,C> tempField(get_mesh(), *newLayout, this->getGC(), getBConds());
00459 
00460     // Copy our data over to the new layout.
00461     tempField = *this;
00462 
00463     // Copy back the pointers to the new local fields.
00464     BareField<T,Dim>::Locals_ac = tempField.Locals_ac;
00465 
00466     INCIPPLSTAT(incRepartitions);
00467   }
00468 }
00469 
00470 
00472 // Tell this object that an object is being deleted
00473 template<class T, unsigned Dim, class M, class C>
00474 void Field<T,Dim,M,C>::notifyUserOfDelete(UserList *userlist) {
00475   TAU_TYPE_STRING(taustr, CT(*this) + " void (UserList * )" );
00476   TAU_PROFILE("Field::notifyUserOfDelete()", taustr, TAU_FIELD ); 
00477   // see if the userlist corresponds to our current mesh
00478   if (mesh != 0 && mesh->get_Id() == userlist->getUserListID()) {
00479     mesh = 0;
00480   } else {
00481     // since this is not for our mesh, defer to the base class function
00482     BareField<T,Dim>::notifyUserOfDelete(userlist);
00483   }
00484 }
00485 
00486 
00488 // a virtual function which is called by this base class to get a
00489 // specific instance of DataSourceObject based on the type of data
00490 // and the connection method (the argument to the call).
00491 template<class T, unsigned Dim, class M, class C>
00492 DataSourceObject *Field<T,Dim,M,C>::createDataSourceObject(const char *nm,
00493                                                            DataConnect *dc,
00494                                                            int tm) {
00495   TAU_TYPE_STRING(taustr, CT(*this) 
00496     + "DataSourceObject * (char *, DataConnect *, int)");
00497   TAU_PROFILE("Field::createDataSourceObject()", taustr, TAU_FIELD ); 
00498   return make_DataSourceObject(nm, dc, tm, *this);
00499 }
00500 
00501 
00503 // store the given mesh object pointer, and the flag whether we use it or not
00504 template<class T, unsigned Dim, class M, class C>
00505 void Field<T,Dim,M,C>::store_mesh(Mesh_t* m, bool WeOwn) {
00506   TAU_TYPE_STRING(taustr, CT(*this) + " void (Mesh_t *, bool)");
00507   TAU_PROFILE("Field::store_mesh()", taustr, TAU_FIELD ); 
00508   mesh = m;
00509   WeOwnMesh = WeOwn;
00510   if (mesh != 0)
00511     mesh->checkin(*this);
00512 }
00513 
00514 
00516 // delete the mesh object, if necessary; otherwise, just zero the pointer
00517 template<class T, unsigned Dim, class M, class C>
00518 void Field<T,Dim,M,C>::delete_mesh() {
00519   TAU_TYPE_STRING(taustr, CT(*this) + " void ()");
00520   TAU_PROFILE("Field::delete_mesh()", taustr, TAU_FIELD ); 
00521   if (mesh != 0) {
00522     mesh->checkout(*this);
00523     if (WeOwnMesh)
00524       delete mesh;
00525     mesh = 0;
00526   }
00527 }
00528 
00529 
00530 /***************************************************************************
00531  * $RCSfile: Field.cpp,v $   $Author: adelmann $
00532  * $Revision: 1.1.1.1 $   $Date: 2003/01/23 07:40:26 $
00533  * IPPL_VERSION_ID: $Id: Field.cpp,v 1.1.1.1 2003/01/23 07:40:26 adelmann Exp $ 
00534  ***************************************************************************/

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