28 MEDCouplingUMesh *maillage_bulles_mcu,
31 const int nbOfNodes = maillage_bulles_ft_ijk.
nb_sommets();
35 auto coo_ptr = maillage_bulles_ft_ijk.
sommets().
addr();
36 DAD coordsArr = DataArrayDouble::New();
37 coordsArr->useArray(coo_ptr,
false, MEDCoupling::DeallocType::CPP_DEALLOC, nbOfNodes, 3);
38 maillage_bulles_mcu->setCoords(coordsArr);
42 const auto nbFacettes = maillage_bulles_ft_ijk.
nb_facettes();
43 const auto connectivity = maillage_bulles_ft_ijk.
facettes();
44 MCT mcu_connectivity = DataArrayIdType::New();
45 mcu_connectivity->alloc(4 * nbFacettes, 1);
46 auto mcu_connectivity_ptr = mcu_connectivity->getPointer();
47 MCT mc_conn_idx = DataArrayIdType::New();
48 mc_conn_idx->alloc(nbFacettes + 1, 1);
49 auto mc_conn_idx_ptr = mc_conn_idx->getPointer();
50 for (
int ifa7 = 0; ifa7 < nbFacettes; ifa7++)
52 mcu_connectivity_ptr[4 * ifa7] = 3;
53 mcu_connectivity_ptr[4 * ifa7 + 1] = connectivity(ifa7, 0);
54 mcu_connectivity_ptr[4 * ifa7 + 2] = connectivity(ifa7, 1);
55 mcu_connectivity_ptr[4 * ifa7 + 3] = connectivity(ifa7, 2);
56 mc_conn_idx_ptr[ifa7] = 4 * ifa7;
58 mc_conn_idx_ptr[nbFacettes] = 4 * nbFacettes;
59 maillage_bulles_mcu->setConnectivity(mcu_connectivity, mc_conn_idx,
true);
60 maillage_bulles_mcu->zipConnectivityTraducer(0);
61 maillage_bulles_mcu->zipCoordsTraducer();
108 const double intersect_pt,
110 DataArrayIdType *cutcellsid,
111 bool& plan_cut_some_bubble,
112 MCU& mesh1dfil)
const
114 double intersect[3] = {0., 0., 0.};
115 double vect_norm[3] = {0., 0., 0.};
116 intersect[dim] = intersect_pt;
118 std::vector<int> COO2KEEP(2);
119 get_coo_to_keep(dim, COO2KEEP);
127 mesh1dfil->checkConsistencyLight();
128 const DataArrayDouble *coords = mesh1dfil->getCoords();
129 for (
int x = 0; x < 3; x++)
132 double maxi = -10000;
135 for (
int c = 0; c < coords->getNumberOfTuples(); c++)
137 const auto val = coords->getIJ(c, x);
145 Cout <<
"coord fil min dans la direction " << x <<
" : " << mini << finl;
146 Cout <<
"coord fil max dans la direction " << x <<
" : " << maxi << finl;
148 const auto connectivity = mesh1dfil->getNodalConnectivity();
149 const int nb_compo =
static_cast<int>(connectivity->getNumberOfComponents());
150 Cout <<
"Connectivity fil : " << finl;
151 Cout <<
"Nb nodes : " << connectivity->getNumberOfTuples() << finl;
152 Cout <<
"Nb compo : " << nb_compo << finl;
153 print_umesh_conn(connectivity);
154 Cout <<
"Youpi la coupe marche" << finl;
156 catch (INTERP_KERNEL::Exception&)
158 mesh1dfil = MEDCouplingUMesh::New();
159 plan_cut_some_bubble =
false;
161 if (plan_cut_some_bubble)
165 mesh1dfil->mergeNodes(EPS_, areNodesMerged, nbOfNodes);
166 mesh1dfil->zipCoordsTraducer();
167 mesh1dfil->zipConnectivityTraducer(0);
168 DataArrayDouble *coord = mesh1dfil->getCoords();
169 std::vector<unsigned long> COO2KEEPLONG(begin(COO2KEEP), end(COO2KEEP));
170 DAD coords = coord->keepSelectedComponents(COO2KEEPLONG);
171 mesh1dfil->setCoords(coords);
177 const DataArrayIdType *new_to_old_id,
178 const mcIdType n_tot_mesh2d,
179 DataArrayIdType *tab_id_subcells,
180 DataArrayIdType *tab_id_cut_cell)
const
188 const auto n_new_to_old = new_to_old_id->getNumberOfTuples();
189 const auto new_to_old_id_ptr = new_to_old_id->getConstPointer();
191 MCT temp = DataArrayIdType::New();
192 temp->alloc(n_tot_mesh2d, 2);
193 temp->fillWithValue(-1);
194 mcIdType *temp_ptr = temp->getPointer();
201 auto n_cut = n_new_to_old - n_tot_mesh2d;
206 tab_id_cut_cell->alloc(n_cut, 1);
207 tab_id_cut_cell->fillWithValue(-1);
213 tab_id_subcells->alloc(n_cut, max_authorized_nb_of_components_ + 1);
214 tab_id_subcells->fillWithValue(-1);
215 mcIdType *tab_id_subcells_ptr = tab_id_subcells->getPointer();
219 for (
int i_new = 0; i_new < n_new_to_old; i_new++)
221 const auto i_old = new_to_old_id_ptr[i_new];
222 assert(i_old < n_tot_mesh2d);
223 if (temp_ptr[2 * i_old] == -1)
224 temp_ptr[2 * i_old] = i_new;
228 if (tab_id_subcells_ptr[(max_authorized_nb_of_components_ + 1) * ind] == -1)
234 tab_id_subcells_ptr[(max_authorized_nb_of_components_ + 1) * ind] = temp_ptr[2 * i_old];
235 tab_id_subcells_ptr[(max_authorized_nb_of_components_ + 1) * ind + 1] = i_new;
238 temp_ptr[2 * i_old + 1] = ind;
248 const mcIdType ind_tuple = temp_ptr[2 * i_old + 1];
249 assert(ind_tuple >= 0);
250 int last_compo_remplie = 1;
252 for (
int i_compo = 1; tab_id_subcells_ptr[(max_authorized_nb_of_components_ + 1) * ind_tuple + i_compo] > -1;
255 last_compo_remplie = i_compo;
257 assert(last_compo_remplie > 0);
258 tab_id_subcells_ptr[(max_authorized_nb_of_components_ + 1) * ind_tuple + last_compo_remplie + 1] = i_new;
264 tab_id_cut_cell->reAlloc(ind);
265 tab_id_subcells->reAlloc(ind);
343 const IJK_Field_vector3_double& normale_of_interf,
344 const DataArrayDouble *vector,
345 const int dim,
const int i_plan,
346 const int nx,
const DataArrayIdType *ids_old,
347 DataArrayIdType *ids_new)
const
349 const mcIdType *ids_old_ptr = ids_old->getConstPointer();
350 mcIdType *ids_new_ptr = ids_new->getPointer();
351 const double *vector_ptr = vector->getConstPointer();
352 const int n_compo_ids_IJ =
static_cast<int>(ids_new->getNumberOfComponents());
353 const int n_compo_v =
static_cast<int>(vector->getNumberOfComponents());
354 const mcIdType n_tup_v = vector->getNumberOfTuples();
355 std::vector<int> coo2keep(2);
356 get_coo_to_keep(dim, coo2keep);
364 for (
int i_diph = 0; i_diph < n_tup_v; i_diph++)
366 std::array<int, 3> coo_ijk = {0, 0, 0};
372 double scal_prod = 0.;
373 for (
int c = 0; c < 2; c++)
385 const double normale_of_interf_cell = normale_of_interf[coo2keep[c]](coo_ijk[0], coo_ijk[1], coo_ijk[2]);
386 double normale_of_interf_next_cell;
388 normale_of_interf_next_cell = normale_of_interf[coo2keep[c]](coo_ijk[0] + 1, coo_ijk[1], coo_ijk[2]);
390 normale_of_interf_next_cell = normale_of_interf[coo2keep[c]](coo_ijk[0], coo_ijk[1] + 1, coo_ijk[2]);
392 normale_of_interf_next_cell = normale_of_interf[coo2keep[c]](coo_ijk[0], coo_ijk[1], coo_ijk[2] + 1);
394 const double normale_of_interf_moy = (normale_of_interf_cell + normale_of_interf_next_cell) / 2.;
395 const double scal_prod_compo = vector_ptr[n_compo_v * i_diph + c] * normale_of_interf_moy;
396 scal_prod += scal_prod_compo;
406 ids_new_ptr[n_compo_ids_IJ * i_diph] = ids_new_ptr[n_compo_ids_IJ * i_diph + 1];
469 const IJK_Field_vector3_double& normale_of_interf,
470 IJK_Field_vector3_double& surfaces,
480 std::vector<int> N = {splitting.get_nb_elem_local(0) + 1, splitting.get_nb_elem_local(1) + 1,
481 splitting.get_nb_elem_local(2) + 1
483 Cerr <<
"Dimensions du cas : ";
484 for (
int c = 0; c < 3; c++)
485 Cerr <<
", " << N[c];
494 std::vector<int> COO2KEEP(2);
495 std::array<int, 3> COOINV;
497 for (
int d = 0; d < 3; d++)
499 get_coo_to_keep(d, COO2KEEP);
500 get_coo_inv_to_keep(d, COOINV);
508 const auto X1 = COO2KEEP[0];
509 DAD xarr = DataArrayDouble::New();
510 xarr->alloc(N[X1], 1);
512 const auto dx = geom.get_constant_delta(X1);
513 const auto xmin = geom.get_origin(X1) + dx * splitting.get_offset_local(X1);
516 auto xarr_ptr = xarr->getPointer();
517 for (
int c = 0; c < xarr->getNumberOfTuples(); c++)
523 const int X2 = COO2KEEP[1];
524 DAD yarr = DataArrayDouble::New();
525 yarr->alloc(N[X2], 1);
527 const auto dy = geom.get_constant_delta(X2);
528 const auto ymin = geom.get_origin(X2) + dy * splitting.get_offset_local(X2);
530 auto yarr_ptr = yarr->getPointer();
531 for (
int c = 0; c < yarr->getNumberOfTuples(); c++)
537 MCC cmesh = MEDCouplingCMesh::New();
538 cmesh->setCoords(xarr, yarr);
539 MCU mesh = cmesh->buildUnstructured();
540 mesh->setName(
"Plan_IJ_IK_JK");
543 mesh->changeSpaceDimension(3);
544 const double vect[3] = {0., 0., -1.};
545 mesh->orientCorrectly2DCells(vect,
false);
546 mesh->changeSpaceDimension(2);
547 mesh->zipCoordsTraducer();
548 const mcIdType n_cell_tot = mesh->getNumberOfCells();
550 MEDCoupling::WriteUMesh(
"mesh.med", mesh,
true);
552 DAD zarr = DataArrayDouble::New();
553 zarr->alloc(N[d], 1);
555 const auto dz = geom.get_constant_delta(d);
556 const auto zmin = geom.get_origin(d) + dz * splitting.get_offset_local(d);
558 auto zarr_ptr = zarr->getPointer();
559 const mcIdType n_tup_zarr = zarr->getNumberOfTuples();
560 for (
int c = 0; c < n_tup_zarr; c++)
570 for (
int i_plan = 0; i_plan < N[d]; i_plan++)
572 MCT cellId = DataArrayIdType::New();
573 bool plan_cut_some_bubble =
true;
574 MCU mesh1D = MEDCouplingUMesh::New();
575 slice_bubble(zarr_ptr[i_plan], d, cellId, plan_cut_some_bubble, mesh1D);
580 if (plan_cut_some_bubble)
583 Cerr <<
"Point d'intersection : " << zarr_ptr[i_plan] << finl;
584 Cerr <<
"Direction : " << d << finl;
587 Cerr <<
"Mesh 1D coordinates : " << finl;
588 print_double_med(mesh1D->getCoords());
589 Cerr <<
"Mesh 1D connectivity" << finl;
590 print_umesh_conn(mesh1D->getNodalConnectivity());
602 mesh1D->zipCoordsTraducer();
603 mesh1D->zipConnectivityTraducer(2);
605 MEDCoupling::WriteUMesh(
"mesh1d.med", mesh1D,
true);
613 MCT cellOrder = mesh1D->orderConsecutiveCells1D();
620 MCU mesh1D_ordered = mesh1D->buildPartOfMySelf(cellOrder->begin(), cellOrder->end(),
false);
621 mesh1D_ordered->zipConnectivityTraducer(2);
622 mesh1D_ordered->zipCoordsTraducer();
623 Cerr <<
"Mesh 1D connectivity cell ordered" << finl;
624 print_umesh_conn(mesh1D_ordered->getNodalConnectivity());
628 Cerr <<
"Mesh 1D connectivity nodes ordered" << finl;
629 print_umesh_conn(mesh1D_ordered->getNodalConnectivity());
630 mesh1D_ordered->checkConsistencyLight();
642 MEDCoupling::WriteUMesh(
"mesh1d_ordered.med", mesh1D_ordered,
true);
654 MCU merge0, mesh_filaire_decoupe0;
655 MCT cellIdInMesh2d0, mesh1dmergeId0;
657 MEDCouplingUMesh *merge0Ptr(0), *meshFilDecoupePtr(0);
658 DataArrayIdType *cellIdInMesh2d0Ptr(0), *mesh1dmergeId0Ptr(0);
660 MEDCouplingUMesh::Intersect2DMeshWith1DLine(mesh, mesh1D_ordered, EPS_, merge0Ptr, meshFilDecoupePtr,
661 cellIdInMesh2d0Ptr, mesh1dmergeId0Ptr);
663 mesh_filaire_decoupe0 = meshFilDecoupePtr;
664 cellIdInMesh2d0 = cellIdInMesh2d0Ptr;
665 mesh1dmergeId0 = mesh1dmergeId0Ptr;
670 merge0->setName(
"Merge0");
671 MEDCoupling::WriteUMesh(
"merge0.med", merge0,
true);
675 DAD bary0 = merge0->computeCellCenterOfMass();
676 DAD surf0 = merge0->getMeasureField(
false)->getArray();
680 MCT cellsIdinMesh0 = DataArrayIdType::New();
681 MCT cIcellsIdinMesh0 = DataArrayIdType::New();
682 findCommonTuples(cellIdInMesh2d0, n_cell_tot, cellsIdinMesh0, cIcellsIdinMesh0);
689 DAD vect0 = DataArrayDouble::New();
727 const mcIdType n_diph = cellsIdinMesh0->getNumberOfTuples();
728 const int n_compo_subcell =
static_cast<int>(cellsIdinMesh0->getNumberOfComponents());
729 const mcIdType *subcellPtr = cellsIdinMesh0->getConstPointer();
730 const mcIdType *cIPtr = cIcellsIdinMesh0->getConstPointer();
731 const double *surf0Ptr = surf0->getConstPointer();
732 const double *bary0Ptr = bary0->getConstPointer();
733 const int n_compo_bary =
static_cast<int>(bary0->getNumberOfComponents());
735 for (mcIdType c = 0; c < n_diph; c++)
739 const mcIdType i_cell_cart = cIPtr[c];
743 const mcIdType i_subcell = subcellPtr[c * n_compo_subcell];
744 std::array<int, 3> coo_inv {0, 0, 0};
749 const double surf_vap = surf0Ptr[i_subcell];
750 surfaces[d](coo_inv[0], coo_inv[1], coo_inv[2]) = surf_vap;
752 const double bary_x1 = bary0Ptr[i_subcell * n_compo_bary];
753 barycentres[X1][d](coo_inv[0], coo_inv[1], coo_inv[2]) = bary_x1;
754 const double bary_x2 = bary0Ptr[i_subcell * n_compo_bary + 1];
755 barycentres[X2][d](coo_inv[0], coo_inv[1], coo_inv[2]) = bary_x2;
756 barycentres[d][d](coo_inv[0], coo_inv[1], coo_inv[2]) = zarr_ptr[i_plan];
761 for (
int c = 0; c < 3; c++)
763 for (
int cc = 0; cc < 3; cc++)
764 barycentres[c][cc].echange_espace_virtuel(barycentres[0][0].ghost());
794 IJK_Field_vector3_double& surface_vapeur_par_face,
795 const IJK_Field_double& indicatrice_ft)
797 const int ni = surface_vapeur_par_face[0].ni();
798 const int nj = surface_vapeur_par_face[0].nj();
799 const int nk = surface_vapeur_par_face[0].nk();
800 const double eps_diph = 10.e-6;
801 int n_faces_mouilles = 0;
802 double surf_cell = 1.;
803 for (
int dir = 0; dir < 3; dir++)
806 for (
int c = 0; c < 3; c++)
809 surf_cell *= ref_domaine_->get_constant_delta(c);
811 for (
int i = 0; i < ni; i++)
812 for (
int j = 0; j < nj; j++)
813 for (
int k = 0; k < nk; k++)
815 double& surf_vap = surface_vapeur_par_face[dir](i, j, k);
816 if ( (surf_vap / surf_cell > eps_diph)
817 and (surf_vap / surf_cell < 1. - eps_diph))
825 double mean_indic = 0.;
827 mean_indic = (indicatrice_ft(i - 1, j, k) + indicatrice_ft(i, j, k)) / 2.;
829 mean_indic = (indicatrice_ft(i, j - 1, k) + indicatrice_ft(i, j, k)) / 2.;
831 mean_indic = (indicatrice_ft(i, j, k - 1) + indicatrice_ft(i, j, k)) / 2.;
832 bool test = (mean_indic < 0.5);
834 surf_vap = (test ? surf_cell : 0.);
838 return n_faces_mouilles;
843 DataArrayIdType *n = mesh1D->getNodalConnectivity();
844 mcIdType *n_ptr = n->getPointer();
845 DataArrayIdType *nI = mesh1D->getNodalConnectivityIndex();
846 const mcIdType *nI_ptr = nI->getConstPointer();
847 mcIdType n_cells = mesh1D->getNumberOfCells();
848 Cerr <<
"Coordonnees de mesh1D : " << finl;
849 print_double_med(mesh1D->getCoords());
852 mcIdType last_node, second_node;
854 mcIdType node0, node1, node2, node3;
856 for (mcIdType i_cell = 0; i_cell < n_cells; i_cell++)
863 assert(i_cell + 1 < n_cells);
864 node0 = n_ptr[nI_ptr[i_cell] + 1];
865 node1 = n_ptr[nI_ptr[i_cell] + 2];
866 node2 = n_ptr[nI_ptr[i_cell + 1] + 1];
867 node3 = n_ptr[nI_ptr[i_cell + 1] + 2];
868 if ((node0 == node2) || (node0 == node3))
872 n_ptr[nI_ptr[i_cell] + 1] = last_node;
873 n_ptr[nI_ptr[i_cell] + 2] = second_node;
875 else if ((node1 == node2) || (node1 == node3))
881 throw "Erreur au debut d'une boucle deux element ne se suivent pas";
888 node0 = n_ptr[nI_ptr[i_cell] + 1];
889 node1 = n_ptr[nI_ptr[i_cell] + 2];
892 if (node1 == second_node)
894 n_ptr[nI_ptr[i_cell] + 1] = node1;
895 n_ptr[nI_ptr[i_cell] + 2] = node0;
898 else if (node0 == second_node)
914 if (second_node == last_node)
This class encapsulates all the information related to the eulerian mesh for TrioIJK.