TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Sous_domaine_VF.cpp
1/****************************************************************************
2* Copyright (c) 2023, 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 <Sous_Domaine.h>
17#include <Sous_domaine_VF.h>
18
19Implemente_instanciable(Sous_domaine_VF,"Sous_domaine_VF",Sous_domaine_dis_base);
21{
22
23 Cerr << "Sous_domaine_VF::printOn" << finl;
24
25 os << "les_faces : " << finl;
26 les_faces_.ecrit(os);
27
28 os << "premiere_face_bord_0 : " << finl;
29 os << premiere_face_bord_0_ << finl;
30
31 os << "premiere_face_bord_1 : " << finl;
32 os << premiere_face_bord_1_ << finl;
33
34 os << "premiere_face_bord : " << finl;
35 os << premiere_face_bord_ << finl;
36
37 return os ;
38}
39
40
42{
43 Cerr << "Sous_domaine_VF::readOn" << finl;
44
45 les_faces_.lit(is);
49 return is ;
50}
51
52////////////////////////////////////////////////////////////////
53// //
54// Main function: discretiser //
55// //
56////////////////////////////////////////////////////////////////
57
59{
60 //Cerr << "Sous_domaine_VF::discretiser : discretization of the sub-domain " << le_sous_domaine->le_nom() << "... ";
61
62 le_dom_VF=ref_cast(Domaine_VF,le_dom_dis.valeur());
63
64 int nb_faces_tot=le_dom_VF->nb_faces_tot();
65
66 // Temporary storage:
67 IntTab faces_internes;
68 faces_internes.resize(nb_faces_tot);
69 int nb_faces_internes=0;
70
71 IntTab faces_bord_0;
72 faces_bord_0.resize(nb_faces_tot);
73 int nb_faces_bord_0=0;
74
75 IntTab faces_bord_1;
76 faces_bord_1.resize(nb_faces_tot);
77 int nb_faces_bord_1=0;
78
79 IntTab faces_bord;
80 faces_bord.resize(nb_faces_tot);
81 int nb_faces_bord=0;
82
83 IntTab elem_app;
84 elem_app.resize(le_dom_VF->nb_elem_tot());
85 elem_app=0;
86
87 // Fill elem_app
88 for (int i=0; i<le_sous_domaine->nb_elem_tot(); i++)
89 elem_app[le_sous_domaine.valeur()(i)]=1;
90
91 // Loop over faces
92 for (int i=0; i<nb_faces_tot; i++)
93 {
94 int elem0,elem1;
95 // Which elements are its neighbours?
96 elem0=le_dom_VF->face_voisins(i,0);
97 elem1=le_dom_VF->face_voisins(i,1);
98 // Fill temporary arrays.
99 if (elem1==-1) // face on the domain boundary
100 {
101 if (elem_app[elem0]) // in the sub-domain
102 {
103 faces_bord(nb_faces_bord++)=i;
104 }
105 }
106 else if (elem0==-1) // face on the domain boundary
107 {
108 if (elem_app[elem1]) // in the sub-domain
109 {
110 faces_bord(nb_faces_bord++)=i;
111 }
112 }
113 else // face internal to the domain
114 {
115 if (elem_app[elem0] && elem_app[elem1]) // internal to the sub-domain
116 {
117 faces_internes(nb_faces_internes++)=i;
118 }
119 else if (elem_app[elem0]) // only elem0 is in the sub-domain
120 {
121 faces_bord_0(nb_faces_bord_0++)=i;
122 }
123 else if (elem_app[elem1]) // only elem1 is in the sub-domain
124 {
125 faces_bord_1(nb_faces_bord_1++)=i;
126 }
127 }
128 }
129
130 // Group the results
131 premiere_face_bord_0_ = nb_faces_internes;
134 les_faces_.resize(premiere_face_bord_+nb_faces_bord);
135 for (int i=0; i<nb_faces_internes; i++)
136 les_faces_(i)=faces_internes(i);
137 for (int i=0; i<nb_faces_bord_0; i++)
138 les_faces_(premiere_face_bord_0_+i)=faces_bord_0(i);
139 for (int i=0; i<nb_faces_bord_1; i++)
140 les_faces_(premiere_face_bord_1_+i)=faces_bord_1(i);
141 for (int i=0; i<nb_faces_bord; i++)
142 les_faces_(premiere_face_bord_+i)=faces_bord(i);
143
144 // Compute interlaced volumes
145 const DoubleVect& volumes=le_dom_VF->volumes();
146 volumes_entrelaces_.resize(nb_faces_bord_0+nb_faces_bord_1);
147 for (int i=0; i<nb_faces_bord_0; i++)
148 {
149 volumes_entrelaces_(i)=volumes(le_dom_VF->face_voisins(les_faces_(premiere_face_bord_0_+i),0));
150 }
151 for (int i=0; i<nb_faces_bord_1; i++)
152 {
153 volumes_entrelaces_(nb_faces_bord_0+i)=volumes(le_dom_VF->face_voisins(les_faces_(premiere_face_bord_1_+i),1));
154 }
155
156 // Display the volume of the sub-domains (can be useful)
157 double volume_sous_domaine=0;
158 for (int j=0; j<le_sous_domaine->nb_elem_tot(); j++)
159 {
160 // Count only real cells
161 if (le_sous_domaine.valeur()(j)<le_dom_VF->domaine().nb_elem())
162 volume_sous_domaine+=volumes(le_sous_domaine.valeur()(j));
163 }
164 volume_sous_domaine=mp_sum(volume_sous_domaine);
165 if (je_suis_maitre())
166 Cerr << "Volume of sub-domain " << le_sous_domaine->le_nom() << ": " << volume_sous_domaine << finl;
167}
class Domaine_VF
Definition Domaine_VF.h:44
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
static double mp_sum(double)
Computes the sum of x over all processors in the current group.
Definition Process.cpp:145
static int je_suis_maitre()
Returns 1 if on the master processor of the current group (i.e. me() == 0), 0 otherwise.
Definition Process.cpp:82
Base class for output streams.
Definition Sortie.h:52
This abstract class contains the geometrical subdomain information common to finite-volume methods (V...
DoubleTab volumes_entrelaces_
void discretiser() override
Generates les_faces by iterating over the faces of domaine_dis and identifying which neighbours belon...
This class is at the base of the discretized sub-domain hierarchy. At the time of domain discretizati...
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469