I am still working on the implementation of the assembling in tensor product spaces. For that I need the local mass matrix of HCurl-functions. My resulting matrix seems mostly right, but there are a few entries that are wrong. It changes each time which entries are influenced. The error only occurs when I use a python script with python3. If I use the interface of jupyter notebook, my matrix is correct.
The local matices seem to be correct therefore I guess that it is a problem with AddElementMatrixSymmetric or rather a data race condition in IterateElements.
How can I slove it?
The code with this problem is as follows:
[code] template
void CalcElementMatrix_tpy(const FiniteElement & fely,
const ElementTransformation &eltrans_y, LocalHeap & lhy,
FlatMatrix elmaty)
{
const HCurlFiniteElement & fely_cast =
dynamic_cast<const HCurlFiniteElement&>(fely);
ELEMENT_TYPE eltypey = fely_cast.ElementType();
int ndy = fely_cast.GetNDof();
const IntegrationRule & ir_voly =
SelectIntegrationRule (eltypey, 2*fely_cast.Order());
MatrixFixWidth<Dy,double> shapey(ndy);
elmaty = 0.0;
for (int l = 0; l < ir_voly.Size(); l++)
{
HeapReset hr(lhy);
const MappedIntegrationPoint<Dy,Dy> sip(ir_voly[l], eltrans_y);
BaseMappedIntegrationPoint & mip = eltrans_y(ir_voly[l], lhy);
fely_cast.CalcMappedShape (mip, shapey);
elmaty += ir_voly[l].Weight() *sip.GetMeasure()* shapey * Trans (shapey);
}
}
...
shared_ptr MyMaxwellAssemble(shared_ptr fes_in,
shared_ptr f_coef)
{
…
IterateElements(*fes_y, VOL, lhy, [&] (FESpace::Element ely, LocalHeap &lhy)
{
const ElementTransformation& eltrans_y = ma_y->GetTrafo(ely, lhy);
const FiniteElement& fely = fes_y->GetFE(ely,lhy);
FlatArray dofsy = ely.GetDofs();
FlatMatrix<> elmat_fesy(dofsy.Size(),lhy);
CalcElementMatrix_tpy<2>(fely,eltrans_y,lhy,elmat_fesy);
maty->AddElementMatrixSymmetric(dofsy,elmat_fesy);
});
…
}[/code]