Library NumAnalysis.FEM.FE_transf

This file is part of the Rocq Numerical Analysis library
Copyright (C) Boldo, Clément, Martin, Mayero, Mouhcine
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the COPYING file for more details.

Bibliography

[Ern] Alexandre Ern, Éléments finis, Aide-mémoire, Dunod/L'Usine Nouvelle, 2005, https://www.dunod.com/sciences-techniques/aide-memoire-elements-finis.

From NumAnalysis Require Import stdlib_wR ssr_wMC.

From Coquelicot Require Import Hierarchy.
Close Scope R_scope.

From NumAnalysis Require Import Algebra_wDep.
From NumAnalysis Require Import geometry.
From NumAnalysis Require Import poly_Pdk poly_LagPd1_ref geom_transf_affine FE.

Local Open Scope Monoid_scope.
Local Open Scope Group_scope.
Local Open Scope Ring_scope.

Section Transf.

Context {d : nat}.

Context {phi : 'R^d → 'R^d}.
Hypothesis Hphi : bijective phi.
Hypothesis Hphi1 : aff_map_ms phi.

Lemma transf_am_Pdk : ∀ k, preimage (pullback phi) (Pdk d k) = Pdk d k.
Proof.
intros; unfold preimage; apply subset_ext_equiv; split; intro;
    [apply Pdk_pullback_am_rev | apply Pdk_pullback_am]; easy.
Qed.

End Transf.

Section TFE_Def.

Transformation of an FE of any shape through a bijective mapping of the geometric space R^d, shape and ndof are kept fixed.

Context {d : nat}.
Context {phi : 'R^d → 'R^d}.
Hypothesis Hphi : bijective phi.

Variable fe_in : FE d.

Definition TFE_K_vertices : [0..nvtx (fe_in)) → 'R^d :=
  mapF phi (K_vertices fe_in).

Definition TFE_P_approx : FRd d → Prop :=
  preimage (pullback phi) (P_approx fe_in).

Lemma TFE_P_approx_has_dim : has_dim TFE_P_approx (ndof fe_in).
Proof.
assert (H1 : bijective (@pullback _ _ R phi)) by now apply pullback_bij.
assert (H2 : surjective (@pullback _ _ R phi)) by now apply bij_surj.
apply (lm_has_dim_rev (pullback_lm _) H1).
rewrite image_preimage Rg_is_full// inter_full_r; apply fe_in.
Qed.

Definition TFE_S_dof : [0..ndof fe_in) → FRd d → R :=
  mapF (pushforward phi) (S_dof fe_in).

Lemma TFE_S_dof_lm : ∀ i, lin_map (TFE_S_dof i).
Proof. intro; apply pushforward_lm, (S_dof_lm fe_in _). Qed.

Lemma TFE_unisolvence_inj : KerS0 TFE_P_approx (gather TFE_S_dof).
Proof.
intros f Hf1 Hf2; apply (bij_inj (pullback_bij Hphi)).
apply (unisolvence_inj fe_in); easy.
Qed.

Definition TFE : FE d :=
  mk_FE (shape fe_in) TFE_K_vertices
    TFE_P_approx_has_dim TFE_S_dof_lm TFE_unisolvence_inj.

Lemma TFE_K_geom : K_geom TFE = convex_hull (mapF phi (K_vertices fe_in)).
Proof. easy. Qed.

Lemma pullback_bijS : bijS TFE_P_approx (P_approx fe_in) (pullback phi).
Proof.
apply (BijS (pullback (f_inv Hphi))); repeat split.
apply funS_preimage.
apply funS_preimage_can; [apply pullback_inv_can_l | apply pullback_inv_can_r].
intros g _; apply pullback_inv_can_l.
intros g _; apply pullback_inv_can_r.
Qed.

Lemma TFE_shape_fun :
  shape_fun TFE = mapF (pullback (f_inv Hphi)) (shape_fun fe_in).
Proof.
extF i; rewrite pullback_inv_eq; apply f_inv_eq_equiv; move: i; apply extF_rev.
apply eq_sym, (is_predual_dof_uniq _
    (shape_fun fe_in) (mapF (pullback phi) (shape_fun TFE)));
    [apply shape_fun_correct | apply (shape_fun_correct TFE)].
Qed.

[Ern] Prop 4.5, Eq (4.13), pp. 79-80.
[ErnGuermond] Prop 9.3 (for k=0), p. 103.
Ip (f o T) = (Ip f) o T.
Lemma TFE_local_interp :
  ∀ f,
    local_interp fe_in (pullback phi f) = pullback phi (local_interp TFE f).
Proof.
intro; unfold local_interp; rewrite TFE_shape_fun
    (lm_lc (@pullback_lm _ _ _ R_ModuleSpace phi))
    -mapF_comp pullback_inv_eq f_inv_id_r; easy.
Qed.

End TFE_Def.

Lemma TFE_ext :
  ∀ {d} (fe_in : FE d)
      {phi1 phi2} (H1 : bijective phi1) (H2 : bijective phi2),
    phi1 = phi2 → TFE H1 fe_in = TFE H2 fe_in.
Proof. intros; subst; f_equal; apply proof_irrel. Qed.

Section TFE_vtx_Def.

Specialization of the previous transformation to the simplex case (with affinely independent vertices) where the mapping if specified by the output vertices (simplex shape, and ndof are kept fixed).

Context {d : nat}.

Variable fe_in : FE d.
Hypothesis Hshp_in : shape fe_in = Simplex.
Let vtx_in := castF (nvtx_Simplex Hshp_in) (K_vertices fe_in).
Hypothesis Hvtx_in : aff_indep_ms vtx_in.

Variable vtx_out : [0..d] → 'R^d.
Hypothesis Hvtx_out : aff_indep_ms vtx_out.
Let phi_vtx := T_geom vtx_out \o T_geom_inv Hvtx_in.

Lemma Hphi_vtx : bijective phi_vtx.
Proof.
unfold phi_vtx; apply bij_comp; [now apply T_geom_bij | apply f_inv_bij].
Qed.

Definition TFE_vtx := TFE Hphi_vtx fe_in.

Lemma TFE_vtx_K_vertices_rev :
  vtx_out = castF (nvtx_Simplex Hshp_in) (K_vertices TFE_vtx).
Proof.
extF; simpl; rewrite -mapF_castF; fold vtx_in; unfold phi_vtx.
rewrite mapF_correct comp_correct T_geom_inv_vtx T_geom_vtx; easy.
Qed.

Lemma TFE_vtx_K_geom : K_geom TFE_vtx = convex_hull vtx_out.
Proof.
apply convex_hull_castF with (nvtx_Simplex Hshp_in), TFE_vtx_K_vertices_rev.
Qed.

End TFE_vtx_Def.

Section TFE_vtx_from_ref_Def.

Specialization of the previous transformation to the case where input vertices are the reference vertices (simplex shape, and ndof are kept fixed).