[ET Trac] [Einstein Toolkit] #1449: CarpetLib dh:gfs needs to be traversed in order of variable index

Einstein Toolkit trac-noreply at einsteintoolkit.org
Wed Oct 9 00:06:43 CDT 2013


#1449: CarpetLib dh:gfs needs to be traversed in order of variable index
--------------------+-------------------------------------------------------
 Reporter:  rhaas   |       Owner:  eschnett           
     Type:  defect  |      Status:  new                
 Priority:  major   |   Milestone:                     
Component:  Carpet  |     Version:  development version
 Keywords:          |  
--------------------+-------------------------------------------------------
 Commit 9166952 "CarpetLib: Store registered gh, dh, th, gf, data etc. via
 sets, not via lists" replaced list<ggf*> dh::gfs by set<ggf*> dh::gfs.
 Unfortunately some code assumes that these containers are iterated over
 from varindex=0 to the last varindex. The set however is sorted by the
 address of the ggf structures it holds (the list was sorted by creation
 order which apparently happened to coincide with the variable index).

 The bug manifests when storage is allocated for vectors of grid functions
 (eg vel[]) and recompose_allocate is called on vel[1] before vel[0]. Since
 only vel[0] actually allocactes memory vel[1] tries to refer to this
 memory and assert()s when trying to access not yet existing timelevels.

 The attached patches (each!) fix the issues, once by using a vector<ggf*>
 indexed by the varindex which allows for simple iterators but comes at the
 price of having to deal with NULL pointers for not-yet registered ggfs.

 The second uses a map<int,ggf*> which avoids this problem but comes at the
 price of having to deal with pairs for iterators.

 Making the set<ggf*> sorted by variable index is possible but awkward
 since C++ requires the sorting callback (type) to be part of the set type,
 ie one needs something like set<ggf*,bool(*)(ggf*const,ggf*const)> as the
 type of the container.

-- 
Ticket URL: <https://trac.einsteintoolkit.org/ticket/1449>
Einstein Toolkit <http://einsteintoolkit.org>
The Einstein Toolkit


More information about the Trac mailing list