void SolveM (FlatVector<double> res, FlatVector<double> vecu, LocalHeap & lh) { int ne = ma->GetNE(); const L2HighOrderFESpace & fes = dynamic_cast<const L2HighOrderFESpace&> (*gfu->GetFESpace()); #pragma omp single timer_mass.Start(); #pragma omp for for (int i = 0; i < ne; i++) { IntRange dn = fes.GetElementDofs (i); vecu.Range (dn) = elementdata[i]->invmass * res.Range (dn); } #pragma omp single timer_mass.Stop(); }
void CalcConvection (FlatVector<double> vecu, FlatVector<double> conv, LocalHeap & lh) { const L2HighOrderFESpace & fes = dynamic_cast<const L2HighOrderFESpace&> (*gfu->GetFESpace()); #pragma omp single timer_element.Start(); int ne = ma->GetNE(); #pragma omp for for (int i = 0; i < ne; i++) { HeapReset hr(lh); const ScalarFiniteElement<D> & fel = static_cast<const ScalarFiniteElement<D>&> (fes.GetFE (i, lh)); const IntegrationRule ir(fel.ElementType(), 2*fel.Order()); FlatMatrixFixWidth<D> flowip = elementdata[i]->flowip; /* // use this for time-dependent flow MappedIntegrationRule<D,D> mir(ir, ma->GetTrafo (i, 0, lh), lh); FlatMatrixFixWidth<D> flowip(mir.Size(), lh); cfflow -> Evaluate (mir, flowip); for (int j = 0; j < ir.Size(); j++) { Vec<D> flow = mir[j].GetJacobianInverse() * flowip.Row(j); flow *= mir[j].GetWeight(); flowip.Row(j) = flow; } */ IntRange dn = fes.GetElementDofs (i); int nipt = ir.Size(); FlatVector<> elui(nipt, lh); FlatMatrixFixWidth<D> flowui (nipt, lh); fel.Evaluate (ir, vecu.Range (dn), elui); flowui = flowip; for (int k = 0; k < nipt; k++) flowui.Row(k) *= elui(k); fel.EvaluateGradTrans (ir, flowui, conv.Range(dn)); } #pragma omp single { timer_element.Stop(); timer_facet.Start(); } int nf = ma->GetNFacets(); #pragma omp for for (int i = 0; i < nf; i++) { HeapReset hr(lh); const FacetData & fai = *facetdata[i]; if (fai.elnr[1] != -1) { const DGFiniteElement<D> & fel1 = static_cast<const DGFiniteElement<D>&> (fes.GetFE (fai.elnr[0], lh)); const DGFiniteElement<D> & fel2 = static_cast<const DGFiniteElement<D>&> (fes.GetFE (fai.elnr[1], lh)); const DGFiniteElement<D-1> & felfacet = static_cast<const DGFiniteElement<D-1>&> (fes.GetFacetFE (i, lh)); IntRange dn1 = fes.GetElementDofs (fai.elnr[0]); IntRange dn2 = fes.GetElementDofs (fai.elnr[1]); int ndoffacet = felfacet.GetNDof(); int ndof1 = fel1.GetNDof(); int ndof2 = fel2.GetNDof(); FlatVector<> aelu1(ndof1, lh), aelu2(ndof2, lh); FlatVector<> trace1(ndoffacet, lh), trace2(ndoffacet, lh); fel1.GetTrace (fai.facetnr[0], vecu.Range (dn1), trace1); fel2.GetTrace (fai.facetnr[1], vecu.Range (dn2), trace2); IntegrationRule ir(felfacet.ElementType(), 2*felfacet.Order()); int nip = ir.Size(); FlatVector<> flown = fai.flown; FlatVector<> tracei1(nip, lh), tracei2(nip, lh); FlatVector<> tracei(nip, lh); felfacet.Evaluate (ir, trace1, tracei1); felfacet.Evaluate (ir, trace2, tracei2); for (int j = 0; j < nip; j++) tracei(j) = flown(j) * ( (flown(j) > 0) ? tracei1(j) : tracei2(j) ); felfacet.EvaluateTrans (ir, tracei, trace1); fel1.GetTraceTrans (fai.facetnr[0], trace1, aelu1); fel2.GetTraceTrans (fai.facetnr[1], trace1, aelu2); #pragma omp critical (addres) { conv.Range (dn1) -= aelu1; conv.Range (dn2) += aelu2; } } else { const DGFiniteElement<D> & fel1 = dynamic_cast<const DGFiniteElement<D>&> (fes.GetFE (fai.elnr[0], lh)); const DGFiniteElement<D-1> & felfacet = dynamic_cast<const DGFiniteElement<D-1>&> (fes.GetFacetFE (i, lh)); IntRange dn1 = fes.GetElementDofs (fai.elnr[0]); int ndoffacet = felfacet.GetNDof(); int ndof1 = fel1.GetNDof(); FlatVector<> elu1(ndof1, lh); FlatVector<> trace1(ndoffacet, lh); fel1.GetTrace (fai.facetnr[0], vecu.Range (dn1), trace1); IntegrationRule ir(felfacet.ElementType(), 2*felfacet.Order()); int nip = ir.Size(); FlatVector<> flown = fai.flown; FlatVector<> tracei1(nip, lh), tracei(nip, lh); felfacet.Evaluate (ir, trace1, tracei1); for (int j = 0; j < nip; j++) tracei(j) = flown(j) * ( (flown(j) > 0) ? tracei1(j) : 0 ); felfacet.EvaluateTrans (ir, tracei, trace1); fel1.GetTraceTrans (fai.facetnr[0], trace1, elu1); #pragma omp critical (addres) { conv.Range (dn1) -= elu1; } } } #pragma omp single timer_facet.Stop(); }