TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Intersections_Elem_Facettes_Data.cpp
1/****************************************************************************
2* Copyright (c) 2015 - 2016, 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 <Intersections_Elem_Facettes_Data.h>
17
18/*! @brief Ajoute une entree a la liste doublement chainee d'intersections entre la facette d'interface num_facette et l'element eulerien num_element.
19 *
20 * Le numero d'element doit verifier 0 <= num_element < domaine.nb_elem()
21 * Si le numero de facette est superieur a la taille de l'index des facettes,
22 * on agrandit l'index.
23 *
24 */
26 int num_element,
27 double fraction_surface_intersection,
28 double contrib_volume_phase1,
29 double contrib_barycentre_phase1[3],
30 double contrib_aire_faces_phase1[3],
31 double contrib_barycentre_faces_phase1[3][2],
32 double barycentre_u,
33 double barycentre_v,
34 double barycentre_w)
35{
36 // Verification de taille de l'index des facettes
37 int nb_facettes = index_facette_element_.size_array();
38 if (num_facette >= nb_facettes)
39 {
40 index_facette_element_.resize_array(num_facette+1);
41 for (int i = nb_facettes; i <= num_facette; i++)
42 index_facette_element_[i] = -1;
43 }
44
45 // Verification de taille du tableau de donnees des intersections
46 if (data_allocated_size < data_real_size+1)
47 {
48 data_allocated_size = (data_real_size+1)*2;
50 new Intersections_Elem_Facettes_Data[data_allocated_size];
51 if (data_real_size > 0)
52 for (int i=0; i<data_real_size; i++)
53 new_data[i] = data[i];
54 if (data)
55 delete[] data;
56 data = new_data;
57 }
58 // Ajout de la nouvelle entree en debut de liste (pour eviter d'avoir a
59 // chercher la fin...)
60 {
61 // Indice de l'intersection entre l'element et la premiere facette
62 int& lindex_elem = index_elem_facette_[num_element];
63 // Indice de l'intersection entre la facette et le premier element
64 int& lindex_facette = index_facette_element_[num_facette];
65 Intersections_Elem_Facettes_Data& new_entry = data[data_real_size];
66 // Indice de l'intersection de la meme facette avec l'element suivant
67 new_entry.index_element_suivant_ = lindex_facette;
68 // Indice de l'intersection du meme element avec la facette suivante
69 new_entry.index_facette_suivante_ = lindex_elem;
70 new_entry.numero_facette_ = num_facette;
71 new_entry.numero_element_ = num_element;
72#ifdef AVEC_BUG_SURFACES
73 new_entry.surface_intersection_ = fraction_surface_intersection;
74#else
75 new_entry.fraction_surface_intersection_ = fraction_surface_intersection;
76#endif
77 new_entry.contrib_volume_phase1_ = contrib_volume_phase1;
78 new_entry.contrib_aire_faces_phase1_[0] = contrib_aire_faces_phase1[0];
79 new_entry.contrib_aire_faces_phase1_[1] = contrib_aire_faces_phase1[1];
80 new_entry.contrib_aire_faces_phase1_[2] = contrib_aire_faces_phase1[2];
81 new_entry.contrib_barycentre_phase1_[0] = contrib_barycentre_phase1[0];
82 new_entry.contrib_barycentre_phase1_[1] = contrib_barycentre_phase1[1];
83 new_entry.contrib_barycentre_phase1_[2] = contrib_barycentre_phase1[2];
84 new_entry.contrib_barycentre_faces_phase1_[0][0] = contrib_barycentre_faces_phase1[0][0];
85 new_entry.contrib_barycentre_faces_phase1_[0][1] = contrib_barycentre_faces_phase1[0][1];
86 new_entry.contrib_barycentre_faces_phase1_[1][0] = contrib_barycentre_faces_phase1[1][0];
87 new_entry.contrib_barycentre_faces_phase1_[1][1] = contrib_barycentre_faces_phase1[1][1];
88 new_entry.contrib_barycentre_faces_phase1_[2][0] = contrib_barycentre_faces_phase1[2][0];
89 new_entry.contrib_barycentre_faces_phase1_[2][1] = contrib_barycentre_faces_phase1[2][1];
90 new_entry.barycentre_[0] = barycentre_u;
91 new_entry.barycentre_[1] = barycentre_v;
92 new_entry.barycentre_[2] = barycentre_w;
93 lindex_elem = data_real_size;
94 lindex_facette = data_real_size;
95 }
96 data_real_size++;
97}
98
100 : data_allocated_size(0), data_real_size(0), data(0)
101{
102}
103
105{
106 if (data)
107 delete[] data;
108 data = 0;
109}
110
111void Intersections_Elem_Facettes::reset(int nb_elements_euleriens,
112 int nb_facettes)
113{
114 data_real_size = 0;
115 index_elem_facette_.resize_array(nb_elements_euleriens);
116 index_elem_facette_ = -1;
117 index_facette_element_.resize_array(nb_facettes);
118 index_facette_element_ = -1;
119}
120
122 ArrOfInt& liste_elements) const
123{
124 liste_elements.resize_array(0);
125 if (num_facette >= index_facette_element_.size_array())
126 // Aucune intersection n'a ete ajoutee pour cette facette,
127 // elle ne figure meme pas dans l'index
128 return;
129
130 int index = index_facette_element_[num_facette];
131 for (; index >= 0; index = data[index].index_element_suivant_)
132 {
133 const int element = data[index].numero_element_;
134 liste_elements.append_array(element);
135 }
136}
137
139 ArrOfInt& liste_facettes) const
140{
141 liste_facettes.resize_array(0);
142 int index = index_elem_facette_[num_element];
143 for (; index >= 0; index = data[index].index_facette_suivante_)
144 {
145 const int facette = data[index].numero_facette_;
146 liste_facettes.append_array(facette);
147 }
148}
149
150/*! @brief Renvoie un tableau de taille domaine.
151 *
152 * nb_elem(): pour un element 0 <= elem < domaine.nb_elem(),
153 * index_elem()[elem] est l'indice de la premiere intersection entre l'element
154 * et les facettes du maillage lagrangien (voir description de la classe)
155 *
156 */
158{
159 return index_elem_facette_;
160}
161
162/*! @brief Renvoie un tableau de taille "nombre de facettes de l'interface" pour un element 0 <= facette < nb_facettes,
163 *
164 * index_facette()[facette] est l'indice de la premiere intersection entre
165 * la facette et les elements du maillage lagrangien
166 * (voir description de la classe)
167 *
168 */
170{
171 return index_facette_element_;
172}
173
174/*! @brief operateur de copie
175 *
176 */
178{
179 if (&ief != this)
180 {
181 index_elem_facette_ = ief.index_elem();
182 if (ief.index_elem().size_array() > 0)
183 {
184 assert(index_elem_facette_.size_array() > 0);
185 }
186
187 index_facette_element_ = ief.index_facette();
188 data_allocated_size = ief.data_allocated_size;
189 data_real_size = ief.data_real_size;
190
191 if (data)
192 delete [] data;
193 data = new Intersections_Elem_Facettes_Data[data_allocated_size];
194 int i;
195 for (i=0 ; i<data_real_size; i++)
196 {
197 data[i] = ief.data[i];
198 }
199 }
200 return *this;
201}
void ajoute_intersection(int num_facette, int num_element, double surface_intersection, double contrib_volume_phase1, double contrib_barycentre_phase1[3], double contrib_aire_faces_phase1[3], double contrib_barycentre_faces_phase1[3][2], double barycentre_u, double barycentre_v, double barycentre_w)
Ajoute une entree a la liste doublement chainee d'intersections entre la facette d'interface num_face...
void reset(int nb_elements_euleriens=0, int nb_facettes=0)
const ArrOfInt & index_elem() const
Renvoie un tableau de taille domaine.
void get_liste_elements_traverses(int num_facette, ArrOfInt &liste_elements) const
const ArrOfInt & index_facette() const
Renvoie un tableau de taille "nombre de facettes de l'interface" pour un element 0 <= facette < nb_fa...
const Intersections_Elem_Facettes & operator=(const Intersections_Elem_Facettes &ief)
operateur de copie
void get_liste_facettes_traversantes(int num_element, ArrOfInt &liste_facettes) const
void append_array(_TYPE_ valeur)
_SIZE_ size_array() const
void resize_array(_SIZE_ new_size, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)