static private void DoCellj(int j, DGField f, GridData NewGrid, int pDeg, int[] TargMappingIdx_j, double[][] ReDistDGCoords_j, int l, GridCorrelation Old2NewCorr, int N0rcv, int N0acc, int Np, double[] ReDistDGCoords_jl, double[] Coords_j) { Debug.Assert(ReDistDGCoords_j.Length == TargMappingIdx_j.Length); int iKref = NewGrid.Cells.GetRefElementIndex(j); Debug.Assert(Coords_j.Length == Np); Debug.Assert(ReDistDGCoords_jl.Length == Np); for (int n = 0; n < Np; n++) { Coords_j[n] = f.Coordinates[j, N0acc + n]; } int L = ReDistDGCoords_j.Length; if (TargMappingIdx_j.Length == 1) { // ++++++++++ // refinement // ++++++++++ Debug.Assert(l == 0); MultidimensionalArray Trafo = Old2NewCorr.GetSubdivBasisTransform(iKref, TargMappingIdx_j[0], pDeg); for (int n = 0; n < Np; n++) { ReDistDGCoords_jl[n] = ReDistDGCoords_j[0][N0rcv + n]; } Trafo.gemv(1.0, ReDistDGCoords_jl, 1.0, Coords_j, transpose: false); } else { // ++++++++++ // coarsening // ++++++++++ var Trafo = Old2NewCorr.GetSubdivBasisTransform(iKref, TargMappingIdx_j[l], pDeg); for (int n = 0; n < Np; n++) { ReDistDGCoords_jl[n] = ReDistDGCoords_j[l][N0rcv + n]; } Trafo.gemv(1.0, ReDistDGCoords_jl, 1.0, Coords_j, transpose: true); } for (int n = 0; n < Np; n++) { f.Coordinates[j, N0acc + n] = Coords_j[n]; } }
static private void DoCellj(int j, DGField f, GridData NewGrid, int pDeg, int[] TargMappingIdx_j, double[][] ReDistDGCoords_j, int l, GridCorrelation Old2NewCorr, int N0rcv, int N0acc, int Np, double[] ReDistDGCoords_jl, double[] Coords_j) { Debug.Assert(ReDistDGCoords_j.Length == TargMappingIdx_j.Length); Debug.Assert(object.ReferenceEquals(NewGrid, f.GridDat)); int iKref = NewGrid.Cells.GetRefElementIndex(j); Debug.Assert(Coords_j.Length == Np); Debug.Assert(ReDistDGCoords_jl.Length == Np); for (int n = 0; n < Np; n++) { Coords_j[n] = f.Coordinates[j, N0acc + n]; // for coarsening, we 'touch' each cell multiple times -- therefore, values must be accumulated } int L = ReDistDGCoords_j.Length; if (TargMappingIdx_j.Length == 1) { // ++++++++++ // refinement // ++++++++++ Debug.Assert(l == 0); MultidimensionalArray Trafo = Old2NewCorr.GetSubdivBasisTransform(iKref, TargMappingIdx_j[0], pDeg).Item1; double scale = Old2NewCorr.GetSubdivBasisTransform(iKref, TargMappingIdx_j[0], pDeg).Item2; for (int n = 0; n < Np; n++) { ReDistDGCoords_jl[n] = ReDistDGCoords_j[0][N0rcv + n]; } Trafo.gemv(1.0, ReDistDGCoords_jl, 1.0, Coords_j, transpose: false); BckTrafo(Coords_j, Np, 0, NewGrid, j, pDeg, scale.Sqrt()); } else { // ++++++++++ // coarsening // ++++++++++ var Trafo = Old2NewCorr.GetSubdivBasisTransform(iKref, TargMappingIdx_j[l], pDeg).Item1; double scale = Old2NewCorr.GetSubdivBasisTransform(iKref, TargMappingIdx_j[l], pDeg).Item2; for (int n = 0; n < Np; n++) { ReDistDGCoords_jl[n] = ReDistDGCoords_j[l][N0rcv + n]; } //if (!Oasch) { // Trafo.gemv(1.0, ReDistDGCoords_jl, 1.0, Coords_j, transpose: true); //} else { double[] buf = new double[Np]; Trafo.gemv(1.0, ReDistDGCoords_jl, 1.0, buf, transpose: true); BckTrafo(buf, Np, 0, NewGrid, j, pDeg, 1.0 / scale.Sqrt()); Coords_j.AccV(1.0, buf); //} } for (int n = 0; n < Np; n++) { f.Coordinates[j, N0acc + n] = Coords_j[n]; } }