]> https://gitweb.dealii.org/ - dealii.git/commit
Do not a priori allocate memory for objects that will later be re-sized. 12859/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 21 Oct 2021 23:10:09 +0000 (17:10 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Mon, 25 Oct 2021 19:05:50 +0000 (13:05 -0600)
commit2523db8db6981779983c236259498f23c4c9e385
tree0b326d5546c0e2835985e51fdb0a28200aed52be
parenteba66bf47d99c1e2615a7b2e55c44b23071471bd
Do not a priori allocate memory for objects that will later be re-sized.

Here, this is the case for a CopyData object to be used in WorkStream: We have
to give WorkStrean::run() an exemplar of these CopyData objects from which
it will create a concrete object for each task (=cell or face) that will
then be worked on. We initialize the exemplar's '.data' object to a concrete
size, but this size will later be ignored and instead we resize things
to whatever we actually need in one place because we don't really know
what the correct size is going to be a priori. As a consequence, just omit
the original sizing and leave the 'exemplar.data' object empty until the
point where we know the size for a concrete object that we obtain by
copying the examplar.

As a side note: This is in DataOutFaces. The DataOut class doesn't do the
initial sizing -- I suspect that we had that code at some point in the past
and got rid of the initial sizing a few years ago but didn't make the same
change for DataOutFaces. It is also possible that that change was made
as part of the simplex transition in DataOut, but DataOutFaces was never
actually transitioned and doesn't work for simplices right now. (That's
what I'm working on right now, of course.)
source/numerics/data_out.cc
source/numerics/data_out_faces.cc

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.