New issue 123: Replace resize() with assign() in make_assemblers_*
https://bitbucket.org/ESDLab/openfcst/issues/123/replace-resize-with-assign-in
Mohamad Ghadban:
Currently, we use resize\(\) to initialize containers in the make\_assemblers\_\* functions e.g.,
`phi_xLi_cell.resize( this->n_q_points_cell, std::vector<double>( (cell_info.fe(this->xLi.fetype_index)).dofs_per_cell ) );`
The issue with the resize\(\) function is that it does not change the size of the inner vectors if the new size of the outer vector is less than or equal to its old size in case the above line of code is called more than once. This becomes a problem when using domain decomposition when, for example, a variable is solved for in one layer but not in the other. For example, if we have two layers A and B in which we solve for electron transport such that:
1. In layer A, we solve for variable phi\_s only
2. In layer B, we solve for variables phi\_s that is coupled with variable u1 at the cell level
Then for each layer, the FESystem in the parameter file would be something like:
set Element = FESystem\[FE\_Q\(1\)-FE\_Nothing\(\)\] # phi\_s, --- \(layer A\)
set Element = FESystem\[FE\_Q\(1\)-FE\_Q\(1\)\] # phi\_s, u1 \(layer B\)
Now, if while looping over the cells to assemble, for example, the equation residual, we first enter a cell that belongs to layer A, then the inner vectors of `phi_xLi_cell` will have a size of zero because `(cell_info.fe(this->xLi.fetype_index)).dofs_per_cell )`returns the number of DOFs corresponding to an FE\_Nothing element.
However, if later on we enter a cell that belongs to layer B and assuming the outer vector size remains unchanged, the inner vector size will remain zero despite `cell_info.fe(this->xLi.fetype_index)).dofs_per_cell` evaluating to a nonzero number. This happens because resize\(\) does not destroy old vectors. This eventually leads to a segmentation fault when trying to fill the inner vectors of `phi_xLi_cell`.
Therefore, to fix this issue, resize\(\) should be replaced with assign\(\) which destroys old vectors and builds new ones.
Responsible: Mohamad Ghadban