00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
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
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00098
00099
00100
00101
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
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
00122
00123
00124
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
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
00239
00240
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
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
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
00374 BareField<T,Dim>::fillGuardCells(reallyFill);
00375
00376
00377
00378
00379 if (reallyFill || Bc.changesPhysicalCells()) {
00380
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
00390
00391
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
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
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
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
00432
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
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
00449 if (mesh != 0 && mesh->get_Id() == userlist->getUserListID()) {
00450
00451 } else {
00452
00453
00454
00455 Layout_t *newLayout = (Layout_t *)( userlist );
00456
00457
00458 Field<T,Dim,M,C> tempField(get_mesh(), *newLayout, this->getGC(), getBConds());
00459
00460
00461 tempField = *this;
00462
00463
00464 BareField<T,Dim>::Locals_ac = tempField.Locals_ac;
00465
00466 INCIPPLSTAT(incRepartitions);
00467 }
00468 }
00469
00470
00472
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
00478 if (mesh != 0 && mesh->get_Id() == userlist->getUserListID()) {
00479 mesh = 0;
00480 } else {
00481
00482 BareField<T,Dim>::notifyUserOfDelete(userlist);
00483 }
00484 }
00485
00486
00488
00489
00490
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
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
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
00532
00533
00534