TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Champ_Q1NC_implementation.h
1/****************************************************************************
2* Copyright (c) 2022, 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_Q1NC_implementation_included
17#define Champ_Q1NC_implementation_included
18
19#include <Champ_implementation_divers.h>
20#include <Frontiere_dis_base.h>
21#include <Frontiere.h>
22#include <TRUSTTab.h>
23
24class Domaine_VEF;
25
27{
28public:
30 inline double fonction_forme_2D(double x, double y, int le_poly, int face);
31 inline static double fonction_forme_2D_normalise(double x, double y, int face);
32 inline double fonction_forme_3D(double x, double y, double z, int le_poly, int face);
33 inline static double fonction_forme_3D_normalise(double x, double y, double z, int face);
34 static DoubleTab& Derivee_fonction_forme_2D_normalise(double u, double v, DoubleTab& DF);
35 static DoubleTab& Derivee_fonction_forme_3D_normalise(double u, double v, double w, DoubleTab& DF);
36
37 DoubleVect& valeur_a_elem(const DoubleVect& position, DoubleVect& val, int le_poly) const override;
38 double calcule_valeur_a_elem_compo(double xs, double ys, double zs, int le_poly, int ncomp) const;
39 double valeur_a_elem_compo(const DoubleVect& position, int le_poly, int ncomp) const override;
40 double valeur_a_sommet_compo(int num_som, int le_poly, int ncomp) const;
41 DoubleTab& valeur_aux_elems(const DoubleTab& positions, const IntVect& les_polys, DoubleTab& valeurs) const override;
42 DoubleVect& valeur_aux_elems_compo(const DoubleTab& positions, const IntVect& les_polys, DoubleVect& valeurs, int ncomp) const override;
43 DoubleTab& valeur_aux_sommets(const Domaine&, DoubleTab&) const override;
44 DoubleVect& valeur_aux_sommets_compo(const Domaine&, DoubleVect&, int) const override;
45 DoubleTab& remplir_coord_noeuds(DoubleTab& positions) const override;
46 int remplir_coord_noeuds_et_polys(DoubleTab& positions, IntVect& polys) const override;
47 void transforme_coord2D();
48 void transforme_coord3D();
49
50protected:
51 virtual const Domaine_VEF& domaine_vef() const =0;
52 inline DoubleTab& trace(const Frontiere_dis_base& fr, const DoubleTab& y, DoubleTab& x, int distant) const;
53 // virtual void dimensionner_array() = 0;
54 // DoubleVect dummy;
55 DoubleTab tab_param;
56};
57
58inline double Champ_Q1NC_implementation::fonction_forme_2D(double x, double y, int le_poly, int face)
59{
60 double ksi, eta;
61 ksi = tab_param(le_poly, 0) * x + tab_param(le_poly, 1) * y + tab_param(le_poly, 2);
62 eta = tab_param(le_poly, 3) * x + tab_param(le_poly, 4) * y + tab_param(le_poly, 5);
63 double fonction_de_forme = 1.;
64 fonction_de_forme *= fonction_forme_2D_normalise(ksi, eta, face);
65 // Cerr << "fonction_de_forme " << fonction_de_forme << finl;
66 return fonction_de_forme;
67}
68
69inline double Champ_Q1NC_implementation::fonction_forme_3D(double x, double y, double z, int le_poly, int face)
70{
71 double ksi, eta, psi;
72
73 ksi = tab_param(le_poly, 0) * x + tab_param(le_poly, 1) * y + tab_param(le_poly, 2) * z + tab_param(le_poly, 3);
74 eta = tab_param(le_poly, 4) * x + tab_param(le_poly, 5) * y + tab_param(le_poly, 6) * z + tab_param(le_poly, 7);
75 psi = tab_param(le_poly, 8) * x + tab_param(le_poly, 9) * y + tab_param(le_poly, 10) * z + tab_param(le_poly, 11);
76 double fonction_de_forme = 1.;
77
78 fonction_de_forme *= fonction_forme_3D_normalise(ksi, eta, psi, face);
79
80 // Cerr << "ksi " << ksi << " eta " << eta << " psi " << psi << finl;
81 return fonction_de_forme;
82
83}
84
85inline double Champ_Q1NC_implementation::fonction_forme_2D_normalise(double ksi, double eta, int face)
86{
87 // la fonction de forme est calculer dans la base (ksi), (eta).
88 // aux milieu des faces.
89 // Psi1(x,y) = 0.25 - 0.5ksi + 0.25(ksi^2 - eta^2)
90 // Psi2(x,y) = 0.25 - 0.5eta - 0.25(ksi^2 - eta^2)
91 // Psi3(x,y) = 0.25 + 0.5ksi + 0.25(ksi^2 - eta^2)
92 // Psi4(x,y) = 0.25 + 0.5eta - 0.25(ksi^2 - eta^2)
93
94 double fonction_de_forme_normalisee, carre_ksi = ksi * ksi, carre_eta = eta * eta;
95
96 switch(face)
97 {
98 case 0:
99 {
100 fonction_de_forme_normalisee = 0.25 - 0.5 * ksi + 0.25 * (carre_ksi - carre_eta);
101 break;
102 }
103 case 1:
104 {
105 fonction_de_forme_normalisee = 0.25 - 0.5 * eta - 0.25 * (carre_ksi - carre_eta);
106 break;
107 }
108 case 2:
109 {
110 fonction_de_forme_normalisee = 0.25 + 0.5 * ksi + 0.25 * (carre_ksi - carre_eta);
111 break;
112 }
113 case 3:
114 {
115 fonction_de_forme_normalisee = 0.25 + 0.5 * eta - 0.25 * (carre_ksi - carre_eta);
116 break;
117 }
118 default:
119 {
120 Cerr << "Erreur dans Champ_Q1NC_implementation::fonction_forme_2D : " << finl;
121 Cerr << "Un quadrangle n'a pas " << face << " faces" << finl;
123 fonction_de_forme_normalisee = -1;
124 }
125 }
126 return fonction_de_forme_normalisee;
127}
128
129inline double Champ_Q1NC_implementation::fonction_forme_3D_normalise(double ksi, double eta, double psi, int face)
130{
131 // la fonction de forme est calculer dans la base (ksi), (eta), (psi).
132 // aux milieu des faces.
133
134 // Psi0(x,y,z) = 1/6. - 0.5ksi + 1/3.(ksi^2 - eta^2) + 1/6.(eta^2 - psi^2)
135 // Psi1(x,y,z) = 1/6. - 0.5eta - 1/6.(ksi^2 - eta^2) + 1/6.(eta^2 - psi^2)
136
137 // Psi2(x,y,z) = 1/6. - 0.5psi - 1/6.(ksi^2 - eta^2) + 1/6.(eta^2 - psi^2)
138 // Psi3(x,y,z) = 1/6. + 0.5ksi + 1/3.(ksi^2 - eta^2) + 1/6.(eta^2 - psi^2)
139
140 // Psi4(x,y,z) = 1/6. + 0.5eta - 1/6.(ksi^2 - eta^2) + 1/6.(eta^2 - psi^2)
141 // Psi5(x,y,z) = 1/6. + 0.5psi - 1/6.(ksi^2 - eta^2) + 1/6.(eta^2 - psi^2)
142
143 double fonction_de_forme_normalisee;
144 double six = 1. / 6., tier = 1. / 3., carre_ksi = ksi * ksi, carre_eta = eta * eta, carre_psi = psi * psi;
145 switch(face)
146 {
147 case 0:
148 {
149 fonction_de_forme_normalisee = six - 0.5 * ksi + tier * (carre_ksi - carre_eta) + six * (carre_eta - carre_psi);
150 break;
151 }
152 case 1:
153 {
154 fonction_de_forme_normalisee = six - 0.5 * eta - six * (carre_ksi - carre_eta) + six * (carre_eta - carre_psi);
155 break;
156 }
157 case 2:
158 {
159 fonction_de_forme_normalisee = six - 0.5 * psi - six * (carre_ksi - carre_eta) - tier * (carre_eta - carre_psi);
160 break;
161 }
162 case 3:
163 {
164 fonction_de_forme_normalisee = six + 0.5 * ksi + tier * (carre_ksi - carre_eta) + six * (carre_eta - carre_psi);
165 break;
166 }
167 case 4:
168 {
169 fonction_de_forme_normalisee = six + 0.5 * eta - six * (carre_ksi - carre_eta) + six * (carre_eta - carre_psi);
170 break;
171 }
172 case 5:
173 {
174 fonction_de_forme_normalisee = six + 0.5 * psi - six * (carre_ksi - carre_eta) - tier * (carre_eta - carre_psi);
175 break;
176 }
177 default:
178 {
179 Cerr << "Erreur dans Champ_Q1NC_implementation::fonction_forme_2D : " << finl;
180 Cerr << "Un quadrangle n'a pas " << face << " faces" << finl;
181 fonction_de_forme_normalisee = -1;
183 }
184 }
185 return fonction_de_forme_normalisee;
186}
187
188inline DoubleTab& Champ_Q1NC_implementation::trace(const Frontiere_dis_base& fr, const DoubleTab& y, DoubleTab& x, int distant) const
189{
190 if (distant)
191 fr.frontiere().trace_face_distant(y, x);
192 else
193 fr.frontiere().trace_face_local(y, x);
194 // useless ? x.echange_espace_virtuel();
195 return x;
196}
197
198#endif
DoubleTab & trace(const Frontiere_dis_base &fr, const DoubleTab &y, DoubleTab &x, int distant) const
DoubleTab & valeur_aux_elems(const DoubleTab &positions, const IntVect &les_polys, DoubleTab &valeurs) const override
DoubleTab & valeur_aux_sommets(const Domaine &, DoubleTab &) const override
static double fonction_forme_3D_normalise(double x, double y, double z, int face)
static double fonction_forme_2D_normalise(double x, double y, int face)
double calcule_valeur_a_elem_compo(double xs, double ys, double zs, int le_poly, int ncomp) const
double valeur_a_elem_compo(const DoubleVect &position, int le_poly, int ncomp) const override
DoubleTab & remplir_coord_noeuds(DoubleTab &positions) const override
DoubleVect & valeur_aux_sommets_compo(const Domaine &, DoubleVect &, int) const override
virtual const Domaine_VEF & domaine_vef() const =0
int remplir_coord_noeuds_et_polys(DoubleTab &positions, IntVect &polys) const override
static DoubleTab & Derivee_fonction_forme_3D_normalise(double u, double v, double w, DoubleTab &DF)
double valeur_a_sommet_compo(int num_som, int le_poly, int ncomp) const
double fonction_forme_3D(double x, double y, double z, int le_poly, int face)
static DoubleTab & Derivee_fonction_forme_2D_normalise(double u, double v, DoubleTab &DF)
DoubleVect & valeur_aux_elems_compo(const DoubleTab &positions, const IntVect &les_polys, DoubleVect &valeurs, int ncomp) const override
double fonction_forme_2D(double x, double y, int le_poly, int face)
DoubleVect & valeur_a_elem(const DoubleVect &position, DoubleVect &val, int le_poly) const override
class Domaine_VEF
Definition Domaine_VEF.h:54
virtual void trace_face_distant(const DoubleTab &, DoubleTab &) const
virtual void trace_face_local(const DoubleTab &, DoubleTab &) const
classe Frontiere_dis_base Classe representant une frontiere discretisee.
const Frontiere & frontiere() const
Renvoie la frontiere geometrique associee.
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455