From 5c4273475d5000d617f70d3cd4ac0584f4056d8e Mon Sep 17 00:00:00 2001
From: Florian Atteneder <florian.atteneder@uni-jena.de>
Date: Thu, 29 Aug 2024 19:28:08 +0000
Subject: [PATCH] TCI: tci's should setup their own vandermonde matrices
 (https://git.tpi.uni-jena.de/dg/dg1d.jl/-/merge_requests/217)

---
 src/TCI/minmod.jl            |  1 -
 src/TCI/modaldecayaverage.jl | 11 +++++++----
 src/TCI/modaldecayhighest.jl |  8 ++++++--
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/TCI/minmod.jl b/src/TCI/minmod.jl
index 192019cb..c87c0a01 100644
--- a/src/TCI/minmod.jl
+++ b/src/TCI/minmod.jl
@@ -11,7 +11,6 @@ function compute_indicator!(
     tci::Minmod)
 
   @unpack mesh       = tci
-  @unpack D          = mesh.element
   @unpack invdetJ    = get_static_variables(mesh.cache)
 
   Npts, K = layout(mesh)
diff --git a/src/TCI/modaldecayaverage.jl b/src/TCI/modaldecayaverage.jl
index a4f19ed1..12b20c65 100644
--- a/src/TCI/modaldecayaverage.jl
+++ b/src/TCI/modaldecayaverage.jl
@@ -2,7 +2,8 @@ Base.@kwdef struct ModalDecayAverage{T_Mesh<:Mesh1d} <: AbstractTCI
   mesh::T_Mesh
   threshold_min::Float64
   threshold_max::Float64
-  # buffers
+  # helpers/buffers
+  invV::Matrix{Float64}
   uh::Vector{Float64}
   uh_perfect::Vector{Float64}
   uh_mod::Vector{Float64}
@@ -29,7 +30,10 @@ function ModalDecayAverage(mesh, threshold_min, threshold_max)
   lsq_x = @. - log(rng_N)
   lsq_y = deepcopy(lsq_x)
 
-  return ModalDecayAverage(mesh, threshold_min, threshold_max,
+  V = dg1d.vandermonde_matrix_legendre(mesh.element.z)
+  invV = inv(V)
+
+  return ModalDecayAverage(mesh, threshold_min, threshold_max, invV,
                            uh, uh_perfect, uh_mod, lsq_x, lsq_y)
 end
 
@@ -39,9 +43,8 @@ function compute_indicator!(
     u,      # inputs
     tci::ModalDecayAverage)
 
-  @unpack mesh, threshold_min, threshold_max, uh,
+  @unpack mesh, threshold_min, threshold_max, uh, invV,
           uh_mod, uh_perfect, lsq_x, lsq_y = tci
-  @unpack D, invV = mesh.element
 
   L       = layout(mesh)
   Npts, K = L
diff --git a/src/TCI/modaldecayhighest.jl b/src/TCI/modaldecayhighest.jl
index 2194ed32..86e003b0 100644
--- a/src/TCI/modaldecayhighest.jl
+++ b/src/TCI/modaldecayhighest.jl
@@ -2,7 +2,9 @@ Base.@kwdef struct ModalDecayHighest{T_Mesh<:Mesh1d} <: AbstractTCI
   mesh::T_Mesh
   threshold_min::Float64
   threshold_max::Float64
-  # buffers
+  # helpers/buffers
+  V::Matrix{Float64}
+  invV::Matrix{Float64}
   uh_mod::Vector{Float64}
   uh_mod_high::Vector{Float64}
 end
@@ -14,7 +16,9 @@ function ModalDecayHighest(mesh, threshold_min, threshold_max)
   # storage for modal coefficients
   uh_mod = zeros(Float64, Npts)
   uh_mod_high = zeros(Float64, Npts)
-  return ModalDecayHighest(mesh, threshold_min, threshold_max, uh_mod, uh_mod_high)
+  V = dg1d.vandermonde_matrix_legendre(mesh.element.z)
+  invV = inv(V)
+  return ModalDecayHighest(mesh, threshold_min, threshold_max, V, invV, uh_mod, uh_mod_high)
 end
 
 
-- 
GitLab