TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_P1NC_implementation.h
1/****************************************************************************
2* Copyright (c) 2025, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#ifndef Champ_P1NC_implementation_included
17#define Champ_P1NC_implementation_included
18
19#include <Champ_implementation_divers.h>
20#include <Champ_implementation_P1.h>
21#include <Frontiere_dis_base.h>
22#include <Matrice_Morse_Sym.h>
23#include <Equation_base.h>
24#include <SolveurSys.h>
25#include <TRUSTTab.h>
26
27class Champ_Fonc_P1NC;
28class Champ_P1NC;
29class Domaine_VEF;
30
32{
33public:
36
38
39 KOKKOS_INLINE_FUNCTION double fonction_forme_2D_v(double x, double y, int le_poly, int face, CIntTabView sommet_poly, CDoubleTabView coord) const
40 {
41 return 1 - 2 * coord_barycentrique_P1_triangle(sommet_poly, coord, x, y, le_poly, face);
42 }
43
44 KOKKOS_INLINE_FUNCTION double fonction_forme_3D_v(double x, double y, double z, int le_poly, int face, CIntTabView sommet_poly, CDoubleTabView coord) const
45 {
46 return 1 - 3 * coord_barycentrique_P1_tetraedre(sommet_poly, coord, x, y, z, le_poly, face);
47 }
48
49 inline double fonction_forme_2D(double x, double y, int le_poly, int face, const IntTab& sommet_poly, const DoubleTab& coord) const
50 {
51 return 1 - 2 * coord_barycentrique_P1_triangle(sommet_poly, coord, x, y, le_poly, face);
52 }
53
54 inline double fonction_forme_3D(double x, double y, double z, int le_poly, int face, const IntTab& sommet_poly, const DoubleTab& coord) const
55 {
56 return 1 - 3 * coord_barycentrique_P1_tetraedre(sommet_poly, coord, x, y, z, le_poly, face);
57 }
58
59 inline double coord_barycentrique(const IntTab& sommet_poly, const DoubleTab& coord, double x, double y, int le_poly, int face) const
60 {
61 return coord_barycentrique_P1_triangle(sommet_poly, coord, x, y, le_poly, face);
62 }
63
64 inline double coord_barycentrique(const IntTab& sommet_poly, const DoubleTab& coord, double x, double y, double z, int le_poly, int face) const
65 {
66 return coord_barycentrique_P1_tetraedre(sommet_poly, coord, x, y, z, le_poly, face);
67 }
68
69 // Returns in val the interpolated field value at coordinates position in element le_poly
70 DoubleVect& valeur_a_elem(const DoubleVect& position, DoubleVect& val, int le_poly) const override;
71 // Returns the value of component ncomp of the interpolated field at coordinates position in element le_poly
72 double valeur_a_elem_compo(const DoubleVect& position, int le_poly, int ncomp) const override;
73 // Returns in valeurs the field values interpolated at element centroids
74 DoubleTab& valeur_aux_centres_de_gravite(const Domaine&, DoubleTab& valeurs) const;
75 // Returns in valeurs the field values interpolated at coordinates positions of elements les_polys
76 DoubleTab& valeur_aux_elems(const DoubleTab& positions, const IntVect& les_polys, DoubleTab& valeurs) const override;
77 // Returns the values of component ncomp of the field interpolated at coordinates positions of elements les_polys
78 DoubleVect& valeur_aux_elems_compo(const DoubleTab& positions, const IntVect& les_polys, DoubleVect& valeurs, int ncomp) const override ;
79 // Returns in ch_som the field values interpolated at vertices
80 DoubleTab& valeur_aux_sommets(const Domaine& dom, DoubleTab& ch_som) const override;
81 // Returns in ch_som the values of component ncomp of the field interpolated at vertices
82 DoubleVect& valeur_aux_sommets_compo(const Domaine& dom, DoubleVect& ch_som, int ncomp) const override;
83 // Returns the value of component ncomp of the field at vertex num_som on element le_poly
84 double valeur_a_sommet_compo(int num_som, int le_poly, int ncomp) const;
85 KOKKOS_INLINE_FUNCTION
86 double valeur_a_sommet_compo(int num_som, int num_elem, int ncomp, CIntTabView elem_faces, CIntTabView sommet_elem, CDoubleTabView ch) const;
87
88 DoubleTab& valeur_aux_elems_smooth(const DoubleTab& positions, const IntVect& les_polys, DoubleTab& valeurs);
89 DoubleVect& valeur_aux_elems_compo_smooth(const DoubleTab& positions, const IntVect& les_polys, DoubleVect& valeurs, int ncomp);
90
91 DoubleTab& remplir_coord_noeuds(DoubleTab& positions) const override;
92 int remplir_coord_noeuds_et_polys(DoubleTab& positions,
93 IntVect& polys) const override;
94 int imprime_P1NC(Sortie&, int) const;
95 void filtrer_L2(DoubleTab& ) const;
96 void filtrer_H1(DoubleTab& ) const;
97 void filtrer_resu(DoubleTab& ) const;
98
99 DoubleTab& ch_som() { return ch_som_; }
100 DoubleVect& ch_som_vect() { return ch_som_vect_; }
101
102 inline const Matrice_Morse_Sym& get_MatP1NC2P1_L2() const { return MatP1NC2P1_L2; }
103 inline const SolveurSys& get_solveur_L2() const { return solveur_L2; }
105 inline const Matrice_Morse_Sym& get_MatP1NC2P1_H1() const { return MatP1NC2P1_H1; }
106 inline const SolveurSys& get_solveur_L2_H1() const { return solveur_L2_H1; }
107 inline const SolveurSys& get_solveur_H1() const { return solveur_H1; }
108
109 int nb_colonnes_tot();
110 int nb_colonnes();
111 void dimensionner_Mat_Bloc_Morse_Sym(Matrice& matrice_tmp);
112 void Mat_Morse_to_Mat_Bloc(Matrice& matrice_tmp);
113
114protected :
116 // Matrix for parallel computation
118
122 virtual const Domaine_VEF& domaine_vef() const =0;
123 friend DoubleTab& valeur_P1_L2(Champ_P1NC&, const Domaine&);
124 friend DoubleTab& valeur_P1_L2(Champ_Fonc_P1NC&, const Domaine&);
125 friend DoubleTab& valeur_P1_H1(const Champ_P1NC&, const Domaine&, DoubleTab&);
126 DoubleTab ch_som_;
127 DoubleVect ch_som_vect_;
129
130 friend int construire_MatP1NC2P1_L2(Champ_P1NC&, const Domaine&);
131 friend int construire_MatP1NC2P1_H1(Champ_P1NC&, const Domaine&, double&);
132
133 friend int construire_secmem_L2(Champ_P1NC&, const Domaine&, DoubleTab&);
134 friend int construire_secmem_H1(Champ_P1NC&, const Domaine&, DoubleTab&, const double);
135
138
139 friend DoubleTab& valeur_P1_L2_H1(Champ_P1NC&,const Domaine&,DoubleTab& );
140 friend int test(Champ_P1NC&,const Domaine&);
141
142 inline DoubleTab& trace(const Frontiere_dis_base& fr, const DoubleTab& y, DoubleTab& x,int distant) const;
143};
144
145inline DoubleTab& Champ_P1NC_implementation::trace(const Frontiere_dis_base& fr, const DoubleTab& y, DoubleTab& x,int distant) const
146{
147 if (distant)
148 fr.frontiere().trace_face_distant(y, x);
149 else
150 {
151 fr.frontiere().trace_face_local(y, x);
153 }
154 return x;
155}
156
157#endif /* Champ_P1NC_implementation_included */
class Champ_Fonc_P1NC
double valeur_a_sommet_compo(int num_som, int le_poly, int ncomp) const
const SolveurSys & get_solveur_H1() const
DoubleTab & valeur_aux_sommets(const Domaine &dom, DoubleTab &ch_som) const override
virtual const Domaine_VEF & domaine_vef() const =0
const SolveurSys & get_solveur_L2() const
double valeur_a_elem_compo(const DoubleVect &position, int le_poly, int ncomp) const override
friend DoubleTab & valeur_P1_H1(const Champ_P1NC &, const Domaine &, DoubleTab &)
DoubleTab & trace(const Frontiere_dis_base &fr, const DoubleTab &y, DoubleTab &x, int distant) const
DoubleVect & valeur_aux_elems_compo(const DoubleTab &positions, const IntVect &les_polys, DoubleVect &valeurs, int ncomp) const override
DoubleTab & remplir_coord_noeuds(DoubleTab &positions) const override
double coord_barycentrique(const IntTab &sommet_poly, const DoubleTab &coord, double x, double y, double z, int le_poly, int face) const
DoubleVect & valeur_aux_elems_compo_smooth(const DoubleTab &positions, const IntVect &les_polys, DoubleVect &valeurs, int ncomp)
double coord_barycentrique(const IntTab &sommet_poly, const DoubleTab &coord, double x, double y, int le_poly, int face) const
double fonction_forme_3D(double x, double y, double z, int le_poly, int face, const IntTab &sommet_poly, const DoubleTab &coord) const
friend int construire_secmem_L2(Champ_P1NC &, const Domaine &, DoubleTab &)
const Matrice_Morse_Sym & get_MatP1NC2P1_H1() const
const Matrice_Morse_Sym & get_MatP1NC2P1_L2_H1() const
void dimensionner_Mat_Bloc_Morse_Sym(Matrice &matrice_tmp)
DoubleVect & valeur_aux_sommets_compo(const Domaine &dom, DoubleVect &ch_som, int ncomp) const override
int remplir_coord_noeuds_et_polys(DoubleTab &positions, IntVect &polys) const override
void Mat_Morse_to_Mat_Bloc(Matrice &matrice_tmp)
DoubleTab & valeur_aux_elems_smooth(const DoubleTab &positions, const IntVect &les_polys, DoubleTab &valeurs)
friend int construire_MatP1NC2P1_H1(Champ_P1NC &, const Domaine &, double &)
KOKKOS_INLINE_FUNCTION double fonction_forme_3D_v(double x, double y, double z, int le_poly, int face, CIntTabView sommet_poly, CDoubleTabView coord) const
friend int construire_MatP1NC2P1_L2(Champ_P1NC &, const Domaine &)
DoubleTab & valeur_aux_centres_de_gravite(const Domaine &, DoubleTab &valeurs) const
Computes values at the centers of gravity for a P1NC field.
DoubleTab & valeur_aux_elems(const DoubleTab &positions, const IntVect &les_polys, DoubleTab &valeurs) const override
friend int test(Champ_P1NC &, const Domaine &)
friend DoubleTab & valeur_P1_L2(Champ_P1NC &, const Domaine &)
Project the P1NC field "cha" onto the P1 field space.
const SolveurSys & get_solveur_L2_H1() const
const Matrice_Morse_Sym & get_MatP1NC2P1_L2() const
friend int construire_secmem_H1(Champ_P1NC &, const Domaine &, DoubleTab &, const double)
friend DoubleTab & valeur_P1_L2_H1(Champ_P1NC &, const Domaine &, DoubleTab &)
KOKKOS_INLINE_FUNCTION double fonction_forme_2D_v(double x, double y, int le_poly, int face, CIntTabView sommet_poly, CDoubleTabView coord) const
double fonction_forme_2D(double x, double y, int le_poly, int face, const IntTab &sommet_poly, const DoubleTab &coord) const
DoubleVect & valeur_a_elem(const DoubleVect &position, DoubleVect &val, int le_poly) const override
class Domaine_VEF
Definition Domaine_VEF.h:53
virtual void trace_face_distant(const DoubleTab &, DoubleTab &) const
virtual void trace_face_local(const DoubleTab &, DoubleTab &) const
class Frontiere_dis_base Class representing a discretized boundary.
const Frontiere & frontiere() const
Returns the associated geometric boundary.
Matrice_Morse_Sym class - Represents a sparse symmetric matrix M stored in Morse format.
Matrice class - Generic class in the matrix hierarchy.
Definition Matrice.h:34
class SolveurSys A SolveurSys represents any class
Definition SolveurSys.h:32
Base class for output streams.
Definition Sortie.h:52
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")