Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
RayMeshIntersectionUnitTest.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2023 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* MeshIntersectionUnitTest.cc (C) 2000-2023 */
9/* */
10/* Service de test des variables. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/ArcanePrecomp.h"
15#include "arcane/utils/ScopedPtr.h"
16
17#include "arcane/BasicUnitTest.h"
18#include "arcane/IMesh.h"
19#include "arcane/IItemFamily.h"
20#include "arcane/IParticleFamily.h"
21#include "arcane/IRayMeshIntersection.h"
22#include "arcane/IParallelMng.h"
23#include "arcane/ItemVector.h"
24#include "arcane/ServiceBuilder.h"
25
26#include "arcane/tests/ArcaneTestGlobal.h"
27
28#include "arcane/tests/RayMeshIntersectionUnitTest_axl.h"
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
32
33namespace ArcaneTest
34{
35using namespace Arcane;
36
37/*---------------------------------------------------------------------------*/
38/*---------------------------------------------------------------------------*/
43: public ArcaneRayMeshIntersectionUnitTestObject
44{
45 public:
46
48
49 public:
50
51 void initializeTest() override;
52 void executeTest() override;
53
54 private:
55
56 void _testReferences(Integer nb_ref);
57 void _testUsed();
58};
59
60/*---------------------------------------------------------------------------*/
61/*---------------------------------------------------------------------------*/
62
63ARCANE_REGISTER_SERVICE_RAYMESHINTERSECTIONUNITTEST(RayMeshIntersectionUnitTest,
65
66/*---------------------------------------------------------------------------*/
67/*---------------------------------------------------------------------------*/
68
69RayMeshIntersectionUnitTest::
70RayMeshIntersectionUnitTest(const ServiceBuildInfo& mb)
71: ArcaneRayMeshIntersectionUnitTestObject(mb)
72{
73}
74
75/*---------------------------------------------------------------------------*/
76/*---------------------------------------------------------------------------*/
77
78void RayMeshIntersectionUnitTest::
79executeTest()
80{
81 IParallelMng* pm = mesh()->parallelMng();
82 Int32 my_rank = pm->commRank();
83 Int32 nb_rank = pm->commSize();
84 info() << "EXEC TEST rank=" << my_rank << " nb_rank=" << nb_rank;
85 // Creation de n rayons
86 Integer n0 = 15; // 40 pour un plus gros test.
87 Integer nb_segment = (n0*n0) / nb_rank;
94 for( Integer i=0; i<nb_segment; ++i ){
95 Integer index = i + nb_segment*my_rank;
96 const Int32 ipx = index / n0;
97 const Int32 ipy = index % n0;
98 Real px = static_cast<Real>(ipx);
99 Real py = static_cast<Real>(ipy);
100 segments_position[i] = Real3(7.0,py/10.0-py/5.0,px/10.0-px/5.0);
101 segments_direction[i] = Real3(-1.0-(px/5.0),(py/20.0)-(py/10.0),0.5-(px/10.0));
102 info() << " SEGMENT: pos=" << segments_position[i] << " dir=" << segments_direction[i];
103
104 }
106 //IRayMeshIntersection* mi = createBasicRayMeshIntersection(mesh());
107
108 //IServiceMng* sm = subDomain()->serviceMng();
109 //FactoryT<IRayMeshIntersection> factory(sm);
111 auto mi(sb.createReference("BasicRayMeshIntersection"));
112
113 // Calcul avec les segments
116
117 // Calcul avec les rayons sous forme de particule
118 IItemFamily* ray_family = mesh()->findItemFamily(IK_Particle,"Rays",true);
121 for( Integer i=0; i<nb_segment; ++i )
122 uids[i] = (i+(nb_segment*my_rank)+1);
123 IParticleFamily* pf = ray_family->toParticleFamily();
124 pf->addParticles(uids,local_ids);
125 ray_family->endUpdate();
133 // Pour test, supprime quelques rayons
134 {
136 for( Integer i=0; i<(nb_segment/10); ++i ){
137 to_remove_rays.add(i*5);
138 }
139 pf->removeParticles(to_remove_rays);
140 pf->endUpdate();
141 }
142
144 Particle p = *iitem;
145 pf->setParticleCell(p,Cell());
146 rays_position[p] = segments_position[p.localId()];
147 rays_direction[p] = segments_direction[p.localId()];
148 rays_orig_face[p] = NULL_ITEM_LOCAL_ID;
149 }
152 info() << "Print rays infos";
153 FaceInfoListView faces_internal(mesh()->faceFamily());
155 Particle ray = *ipart;
157 if (face_lid!=NULL_ITEM_ID)
158 info() << "Ray uid=" << ray.uniqueId()
159 << " pos=" << rays_position[ipart]
160 << " dir=" << rays_direction[ipart]
161 << " intersect_face_lid=" << face_lid
162 << " intersect_face_uid=" << faces_internal[face_lid].uniqueId()
163 << " d=" << rays_distance[ipart]
164 << " p=" << rays_intersection[ipart];
165 }
166}
167
168/*---------------------------------------------------------------------------*/
169/*---------------------------------------------------------------------------*/
170
171void RayMeshIntersectionUnitTest::
172initializeTest()
173{
174}
175
176/*---------------------------------------------------------------------------*/
177/*---------------------------------------------------------------------------*/
178
179} // namespace ArcaneTest
180
181/*---------------------------------------------------------------------------*/
182/*---------------------------------------------------------------------------*/
#define ENUMERATE_PARTICLE(name, group)
Enumérateur générique d'un groupe de particules.
Maille d'un maillage.
Definition Item.h:1178
Vue sur les informations des faces.
Interface d'une famille d'entités.
Interface du gestionnaire de parallélisme pour un sous-domaine.
virtual Int32 commRank() const =0
Rang de cette instance dans le communicateur.
virtual Int32 commSize() const =0
Nombre d'instance dans le communicateur.
Interface d'une famille de particules.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Variable scalaire sur un type d'entité du maillage.
Particule.
Definition Item.h:1383
Classe gérant un vecteur de réel de dimension 3.
Definition Real3.h:132
Structure contenant les informations pour créer un service.
Paramètres nécessaires à la construction d'une variable.
Vecteur 1D de données avec sémantique par valeur (style STL).
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
@ IK_Particle
Entité de maillage de genre particule.