| 458 | } |
| 459 | |
| 460 | double ContactEnergy::CalcEnergy(const FiniteElement& primary_fel, |
| 461 | const FiniteElement& secondary_fel, |
| 462 | const BaseMappedIntegrationRule& primary_mir, |
| 463 | FlatVector<double> elx, |
| 464 | LocalHeap& lh) |
| 465 | { |
| 466 | ProxyUserData ud(trial_proxies.Size(), lh); |
| 467 | const_cast<ElementTransformation&>(primary_mir.GetTransformation()).userdata = &ud; |
| 468 | ud.fel = & primary_fel; |
| 469 | |
| 470 | for(auto proxy : trial_proxies) |
| 471 | { |
| 472 | IntRange trial_range = proxy->IsOther() ? |
| 473 | IntRange(proxy->Evaluator()->BlockDim() * primary_fel.GetNDof(), elx.Size()) |
| 474 | : IntRange(0, proxy->Evaluator()->BlockDim() * primary_fel.GetNDof()); |
| 475 | ud.AssignMemory(proxy, primary_mir.Size(), proxy->Dimension(), lh); |
| 476 | if(proxy->IsOther()) |
| 477 | proxy->Evaluator()->Apply(secondary_fel, *primary_mir.GetOtherMIR(), elx.Range(trial_range), |
| 478 | ud.GetMemory(proxy), lh); |
| 479 | else |
| 480 | proxy->Evaluator()->Apply(primary_fel, primary_mir, elx.Range(trial_range), |
| 481 | ud.GetMemory(proxy), lh); |
| 482 | } |
| 483 | |
| 484 | FlatMatrix<> values(primary_mir.Size(), 1, lh); |
| 485 | cf->Evaluate(primary_mir, values); |
| 486 | |
| 487 | double sum = 0.; |
| 488 | for (int i = 0; i < primary_mir.Size(); i++) |
| 489 | sum += primary_mir[i].GetWeight() * values(i,0); |
| 490 | return sum; |
| 491 | } |
| 492 | |
| 493 | void ContactEnergy::ApplyAdd(const FiniteElement& primary_fel, |
| 494 | const FiniteElement& secondary_fel, |