TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Joints.cpp
1/****************************************************************************
2* Copyright (c) 2024, 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 <Joints.h>
17
18Implemente_instanciable_32_64(Joints_32_64, "Joints", LIST(Joint_32_64<_T_>));
19
20template <typename _SIZE_>
21Sortie& Joints_32_64<_SIZE_>::printOn(Sortie& os) const { return LIST(Joint_32_64<_SIZE_>)::printOn(os); }
22
23template <typename _SIZE_>
24Entree& Joints_32_64<_SIZE_>::readOn(Entree& is) { return LIST(Joint_32_64<_SIZE_>)::readOn(is); }
25
26/*! @brief Associates a domain with all joints in the list.
27 *
28 * The joints in the list will belong to this domain.
29 *
30 * @param un_domaine The domain to associate with the joints.
31 */
32template <typename _SIZE_>
34{
35 for (auto& itr : *this) itr.associer_domaine(un_domaine);
36}
37
38/*! @brief Returns the total number of faces in all Joints_32_64 in the list.
39 *
40 * This is the sum of faces over all joints in the list.
41 *
42 * @return Total number of faces across all joints in the list.
43 */
44template <typename _SIZE_>
46{
47 int_t nombre = 0;
48 for (const auto &itr : *this) nombre += itr.nb_faces();
49
50 return nombre;
51}
52
53/*! @brief Returns the number of faces of the specified type contained in the joint list.
54 *
55 * This is the sum of faces of the given type over all joints in the list.
56 *
57 * @param type The face type to count.
58 * @return Number of faces of the specified type contained in the joint list.
59 */
60template <typename _SIZE_>
61_SIZE_ Joints_32_64<_SIZE_>::nb_faces(Type_Face type) const
62{
63 int_t nombre = 0;
64 for (const auto &itr : *this)
65 if (type == itr.faces().type_face())
66 nombre += itr.nb_faces();
67
68 return nombre;
69}
70
71/*! @brief Compresses the joint list by merging joints sharing the same neighboring PE.
72 *
73 */
74template <typename _SIZE_>
76{
77 Cerr << "Joints_32_64<_SIZE_>::comprimer() - Start" << finl;
78 IntVect fait(this->size());
79 int rang1 = 0, rang2 = 0;
80
81 auto& list = this->get_stl_list();
82 for (auto &itr : list)
83 {
84 if (!fait(rang1))
85 {
86 fait(rang1) = 1;
87 Joint_t& joint1 = itr;
88 rang2 = rang1;
89
90 for (auto &itr2 : list)
91 {
92 if (!fait(rang2))
93 {
94 Joint_t& joint2 = itr2;
95 if (joint1.PEvoisin() == joint2.PEvoisin())
96 {
97 Cerr << "agglomeration of joints " << joint1.le_nom() << " and " << joint2.le_nom() << finl;
98 fait(rang2) = 1;
99 joint1.nommer(joint1.le_nom() + joint2.le_nom());
100
101 // Concatenation of faces
102 joint1.ajouter_faces(joint2.les_sommets_des_faces());
103
104 // Concatenation of vertices ???
105 Cerr << "Concatenation of nodes ?" << finl;
107
108 joint2.dimensionner(0);
109 }
110 }
111 rang2++;
112 }
113 }
114 ++rang1;
115 }
116
117 for (auto itr = list.begin(); itr != list.end(); )
118 {
119 Joint_t& joint1 = *itr;
120 if (joint1.nb_faces() == 0)
121 itr = list.erase(itr);
122 else
123 ++itr;
124 }
125 Cerr << "Joints_32_64<_SIZE_>::comprimer() - End" << finl;
126}
127
128/*! @brief Returns a reference to the joint whose neighboring PE is the specified one.
129 *
130 * @param pe A PE index.
131 * @return Reference to the joint whose neighboring PE is pe.
132 * @throws Error if the specified neighboring PE is not found in the joint list.
133 */
134template <typename _SIZE_>
136{
137 for (auto &itr : *this)
138 {
139 Joint_t& joint = itr;
140 int pe_joint = joint.PEvoisin();
141 if (pe == pe_joint) return joint;
142 }
143 Cerr << "Error in Joints_32_64<_SIZE_>::joint_PE : joint not found" << finl;
145 throw;
146}
147
148
149template class Joints_32_64<int>;
150#if INT_is_64_ == 2
151template class Joints_32_64<trustIdType>;
152#endif
153
154
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
void nommer(const Nom &) override
Gives a name to the boundary.
Definition Frontiere.cpp:74
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Frontiere.h:49
int_t nb_faces() const
Returns the number of faces of the boundary.
Definition Frontiere.h:59
IntTab_t & les_sommets_des_faces()
Returns the vertices of the boundary faces.
The Joint class is a Frontiere that contains the joint faces and vertices with the neighboring domain...
Definition Joint.h:34
void dimensionner(int)
Definition Joint.cpp:76
void ajouter_faces(const IntTab_t &)
Adds faces to the boundary (to the joint). See Frontiere::ajouter_faces(const IntTab&).
Definition Joint.cpp:89
int PEvoisin() const
Definition Joint.h:49
Joints class — represents a list of Joint objects.
Definition Joints.h:28
void comprimer()
Compresses the joint list by merging joints sharing the same neighboring PE.
Definition Joints.cpp:75
Domaine_32_64< _SIZE_ > Domaine_t
Definition Joints.h:34
int_t nb_faces() const
Returns the total number of faces in all Joints_32_64 in the list.
Definition Joints.cpp:45
_SIZE_ int_t
Definition Joints.h:33
Joint_32_64< _SIZE_ > Joint_t
Definition Joints.h:35
void associer_domaine(const Domaine_t &)
Associates a domain with all joints in the list.
Definition Joints.cpp:33
Joint_t & joint_PE(int pe)
Returns a reference to the joint whose neighboring PE is the specified one.
Definition Joints.cpp:135
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Base class for output streams.
Definition Sortie.h:52