TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Assembleur_P_VDF_Q4.cpp
1/****************************************************************************
2* Copyright (c) 2026, 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#include <Assembleur_P_VDF_Q4.h>
17#include <Matrice_Bloc.h>
18#include <Milieu_base.h>
19#include <Domaine_Cl_VDF.h>
20#include <Domaine_VDF.h>
21
22Implemente_instanciable(Assembleur_P_VDF_Q4,"Assembleur_P_VDF_Q4",Assembleur_base);
23
25{
26 return s << que_suis_je() << " " << le_nom() ;
27}
28
30{
32}
33
35{
36 Cerr << "Assembleur_P_VDF_Q4::assembler " << finl;
37 Cerr << "Assemblage de la matrice Q4 en cours..." << finl;
38 const IntTab& FaceSoms = le_dom_VDF->face_sommets();
39 const IntTab& FaceVois = le_dom_VDF->face_voisins();
40 const IntVect& Orientation = le_dom_VDF->orientation();
41 int face, som0,som1;
42 int nbfaces = le_dom_VDF->nb_faces(), nbsom = le_dom_VDF->nb_som();
43 const DoubleVect& volumes_entrelaces = le_dom_VDF->volumes_entrelaces();
44 const DoubleVect& porosite_face = eqn_->milieu().porosite_face();
45 const DoubleTab& CoordSom = le_dom_VDF->domaine().coord_sommets();
46 double surf,vol,por,val, r;
47 int ori, elem0,elem1;
48 //construction matrice
49 la_matrice.typer("Matrice_Morse");
50 Matrice_Morse& mat = ref_cast(Matrice_Morse,la_matrice.valeur());
51 mat.dimensionner(nbsom,0);
52 IntVect rang_voisins(nbsom);
53 auto& tab1 = mat.get_set_tab1();
54 auto& tab2 = mat.get_set_tab2();
55 auto& coeff = mat.get_set_coeff();
56
57 tab1 = 0;
58 tab2 = 0;
59 coeff = 0;
60 rang_voisins = 1;
61 for (face=0 ; face<nbfaces ; face++)
62 {
63 som0 = FaceSoms(face,0);
64 som1 = FaceSoms(face,1);
65 rang_voisins(som0)++;
66 rang_voisins(som1)++;
67 }
68 tab1(0) = 1;
69 for (som0=0 ; som0<nbsom ; som0++)
70 {
71 tab1(som0+1) = rang_voisins(som0) + tab1(som0);
72 }
73 rang_voisins = 1;
74 mat.dimensionner(nbsom,tab1(nbsom)-1);
75 //calcul coefficient matrice
76 for (face=0 ; face<nbfaces ; face++)
77 {
78 ori = Orientation(face);
79 som0 = FaceSoms(face,0);
80 som1 = FaceSoms(face,1);
81 elem0 = FaceVois(face,0);
82 elem1 = FaceVois(face,1);
83 if (elem0>-1 && elem1>-1)
84 {
85 surf = 0.5* (le_dom_VDF->dim_elem(elem0,ori) + le_dom_VDF->dim_elem(elem1,ori));
86 }
87 else if (elem0>-1)
88 {
89 surf = le_dom_VDF->dim_elem(elem0,ori);
90 }
91 else
92 {
93 surf = 0.;
94 surf = le_dom_VDF->dim_elem(elem1,ori);
95 }
96 if (bidim_axi/* && ori==1*/)
97 {
98 r = 0.5*(CoordSom(som0,0)+CoordSom(som1,0));
99 surf = r * surf * 2 * M_PI;
100 }
101 vol = volumes_entrelaces(face);
102 por = porosite_face(face);
103 val = surf*surf /vol * por;
104#ifdef _AFFDEBUG
105 if (le_dom_VDF->nb_som()<400)
106 {
107 Cerr<<"face="<<face<<" ori="<<ori<<" soms="<<som0<<"/"<<som1<<" coordsom="<<CoordSom(som0,0)<<"/"<<CoordSom(som0,1);
108 Cerr<<" "<<CoordSom(som1,0)<<"/"<<CoordSom(som1,1)<<" elems="<<FaceVois(face,0)<<"/"<<FaceVois(face,1)<<" dim_elems/2=";
109 if (FaceVois(face,0)>-1)
110 Cerr<<le_dom_VDF->dim_elem(FaceVois(face,0),ori)/2.<<" / ";
111 else
112 Cerr<<"--- / ";
113 if (FaceVois(face,1)>-1)
114 Cerr<<le_dom_VDF->dim_elem(FaceVois(face,1),ori)/2.<<" ";
115 else
116 Cerr<<"--- ";
117 Cerr<<" surf="<<surf<<" vol="<<vol<<" val="<<val<<finl;
118 }
119#endif
120
121 tab2(tab1(som0)-1) = som0+1;
122 tab2(tab1(som1)-1) = som1+1;
123 mat(som0,som0) += val;
124 mat(som1,som1) += val;
125 //if (coeff(tab1(som0)+rang_voisins(som0)-1)!=-1) {
126 tab2(tab1(som0)+rang_voisins(som0)-1) = som1+1;
127 mat(som0,som1) -= val;
128 rang_voisins(som0)++;
129 tab2(tab1(som1)+rang_voisins(som1)-1) = som0+1;
130 mat(som1,som0) -= val;
131 rang_voisins(som1)++;
132 //}
133 }
134 Cerr << "Fin de l'assemblage de la matrice Q4" << finl;
135 return 1;
136}
137
139{
140 return 1;
141}
142
143int Assembleur_P_VDF_Q4::modifier_secmem(const DoubleTab& tab_secmem_, DoubleVect& secmem)
144{
145 const DoubleTab& CoordSommets = le_dom_VDF->domaine().coord_sommets();
146 const IntTab& FaceSoms = le_dom_VDF->face_sommets();
147 const IntTab& FaceVois = le_dom_VDF->face_voisins();
148 const IntVect& Orientation = le_dom_VDF->orientation();
149 const DoubleTab& CoordSom = le_dom_VDF->domaine().coord_sommets();
150 int face, som0,som1, ori, invori, elem0,elem1;
151 int nbfaces = le_dom_VDF->nb_faces(), nbsom = le_dom_VDF->nb_som();
152 double surf, r;
153
154 secmem.resize(nbsom);
155 secmem = 0.;
156
157 for (face=0 ; face<nbfaces ; face++)
158 {
159 surf = 0.;
160 ori = Orientation(face);
161 som0 = FaceSoms(face,0);
162 som1 = FaceSoms(face,1);
163 elem0 = FaceVois(face,0);
164 elem1 = FaceVois(face,1);
165 if (elem0>-1 && elem1>-1)
166 {
167 surf = 0.5* (le_dom_VDF->dim_elem(elem0,ori) + le_dom_VDF->dim_elem(elem1,ori));
168 }
169 else if (elem0>-1)
170 {
171 surf = le_dom_VDF->dim_elem(elem0,ori);
172 }
173 else if (elem1>-1)
174 {
175 surf = le_dom_VDF->dim_elem(elem1,ori);
176 }
177 else
178 {
179 assert(0==1);
180 }
181 if (bidim_axi/* && ori==1*/)
182 {
183 r = 0.5*(CoordSom(som0,0)+CoordSom(som1,0));
184 surf = r * surf * 2 * M_PI;
185 }
186 if (ori==0)
187 invori = 1;
188 else
189 invori = 0;
190 if (CoordSommets(som1,invori)>CoordSommets(som0,invori))
191 {
192 secmem(som0) += tab_secmem_(face) * surf;
193 secmem(som1) -= tab_secmem_(face) * surf;
194 }
195 else
196 {
197 secmem(som0) -= tab_secmem_(face) * surf;
198 secmem(som1) += tab_secmem_(face) * surf;
199 }
200 secmem.echange_espace_virtuel();
201 }
202
203 return 1;
204}
205
207{
208 Cerr<<"Assembleur_P_VDF_Q4::modifier_solution"<<finl;
209 return 1;
210}
211
213{
214 return le_dom_VDF.valeur();
215}
216
218{
219 return le_dom_Cl_VDF.valeur();
220}
221
223{
224 le_dom_VDF = ref_cast(Domaine_VDF, le_dom_dis);
225}
226
228{
229 le_dom_Cl_VDF =ref_cast(Domaine_Cl_VDF, le_dom_Cl_dis);
230}
231
233{
234 eqn_ = Eqn;
235}
const Domaine_Cl_dis_base & domaine_Cl_dis_base() const override
int modifier_secmem(DoubleTab &) override
int assembler(Matrice &) override
void completer(const Equation_base &) override
void associer_domaine_dis_base(const Domaine_dis_base &) override
const Domaine_dis_base & domaine_dis_base() const override
void associer_domaine_cl_dis_base(const Domaine_Cl_dis_base &) override
int modifier_solution(DoubleTab &) override
class Domaine_Cl_VDF
classe Domaine_Cl_dis_base Les objets Domaine_Cl_dis_base representent les conditions aux limites
class Domaine_VDF
Definition Domaine_VDF.h:64
classe Domaine_dis_base Cette classe est la base de la hierarchie des domaines discretisees.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
classe Equation_base Le role d'une equation est le calcul d'un ou plusieurs champs....
Classe Matrice_Morse Represente une matrice M (creuse), non necessairement carree.
auto & get_set_tab2()
void dimensionner(int n, _SIZE_ nnz)
Size the matrix with n lines and n columns and nnz zero-values coefficients.
auto & get_set_coeff()
auto & get_set_tab1()
Classe Matrice Classe generique de la hierarchie des matrices.
Definition Matrice.h:34
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
virtual const Nom & le_nom() const
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette implementation.
Definition Objet_U.cpp:319
static int bidim_axi
Definition Objet_U.h:102
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
Classe de base des flux de sortie.
Definition Sortie.h:52
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTVect.tpp:91
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")