TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_Generique_Interpolation.cpp
1/****************************************************************************
2* Copyright (c) 2026, 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 <Champ_Generique_Interpolation.h>
17#include <Postraitement.h>
18#include <Discretisation_base.h>
19#include <Domaine_VF.h>
20#include <Synonyme_info.h>
21#include <Param.h>
22#include <Domaine_dis_cache.h>
23#include <Champ_Inc_P0_base.h>
24#include <Champ_Fonc_P0_base.h>
25
26Implemente_instanciable_sans_constructeur(Champ_Generique_Interpolation,"Champ_Post_Interpolation|Interpolation",Champ_Gen_de_Champs_Gen);
27
28/*! @brief see reset()
29 *
30 */
31Champ_Generique_Interpolation::Champ_Generique_Interpolation()
32{
33 // default values
34 reset();
35}
36
37//see Champ_Gen_de_Champs_Gen::readOn
39{
41 set_localisation(localisation_);
42 set_methode(methode_);
43
44 return is;
45}
46
47/*! @brief invalid call
48 *
49 */
51{
52 exit();
53 return os;
54}
55
56// localisation : interpolation localisation (elem or som)
57// domaine : interpolation domain (optional)
58// methode : type of calculation method "calculer_champ_post" (optional, only one method available)
60{
61// XD interpolation champ_post_de_champs_post interpolation INHERITS_BRACE To create a field which is an interpolation
62// XD_CONT of the field given by the keyword source.
64 param.ajouter("localisation",&localisation_,Param::REQUIRED); // XD_ADD_P chaine
65 // XD_CONT type_loc indicate where is done the interpolation (elem for element or som for node).
66 param.ajouter("methode",&methode_); // XD_ADD_P chaine
67 // XD_CONT The optional keyword methode is limited to calculer_champ_post for the moment.
68 param.ajouter("domaine",&nom_domaine_lu_); // XD_ADD_P chaine
69 // XD_CONT the domain name where the interpolation is done (by default, the calculation domain)
70 param.ajouter("optimisation_sous_maillage",&optimisation_demande_); // XD_ADD_P dico
71 // XD_CONT not_set
72 param.dictionnaire("default",-1); // XD_ADD_DICO not_set
73 param.dictionnaire("yes",1); // XD_ADD_DICO not_set
74 param.dictionnaire("no",0); // XD_ADD_DICO not_set
75
76}
77/*! @brief Restore the initial configuration of the object: localisation not specified, source not specified, methode=calculer_champ_post, native domain
78 *
79 */
81{
82 nom_domaine_lu_ = "";
83 localisation_ = "";
84 methode_ = "calculer_champ_post";
85 domaine_.reset();
87 optimisation_sous_maillage_=-1;
88 optimisation_demande_=-1;
89}
90
91/*! @brief Class initialization: initialization of the requested localisation.
92 *
93 * Valid parameters: elem, som, faces, elem_dg.
94 *
95 */
97{
98 Motcles localisations(4);
99 localisations[0] = "elem";
100 localisations[1] = "som";
101 localisations[2] = "faces";
102 localisations[3] = "elem_dg";
103 int ok = 0;
104 if (localisations.search(loc) >= 0)
105 {
106 localisation_ = loc;
107 ok = 1;
108 }
109 else
110 {
111 Cerr << "Error in Champ_Generique_Interpolation::set_localisation\n"
112 << " Keyword read : " << loc << "\n The localizations allowed are " << localisations << finl;
113 if (exit_on_error)
114 {
115 exit();
116 }
117 }
118 return ok;
119}
120
121/*! @brief Class initialization: initialization of the interpolation method. Valid parameters: calculer_champ_post
122 *
123 * (Ideas for the future: assign, assign with integral...)
124 *
125 */
126int Champ_Generique_Interpolation::set_methode(const Motcle& methode, int exit_on_error)
127{
128 Motcles methodes_interpolation(1);
129 methodes_interpolation[0] = "calculer_champ_post";
130 int ok = 0;
131 if (methodes_interpolation.search(methode) >= 0)
132 {
133 methode_ = methode;
134 ok = 1;
135 }
136 else
137 {
138 Cerr << "Error in Champ_Generique_Interpolation::set_methode\n"
139 << " Keyword read : " << methode << "\n The methods allowed are " << methodes_interpolation << finl;
140 if (exit_on_error)
141 {
142 exit();
143 }
144 }
145 return ok;
146}
147
148/*! @brief Class initialization: initialization of the interpolation domain. Valid parameters: "" => native domain, or the name of a Domaine object known to the interpreter
149 *
150 */
151int Champ_Generique_Interpolation::set_domaine(const Nom& nom_domaine, int exit_on_error)
152{
153 int ok = 0;
154 if (nom_domaine == "")
155 {
156 domaine_.reset(); // null reference => native domain of the field
157 ok = 1;
158 }
159 else
160 {
161 const Objet_U& ob = interprete().objet(nom_domaine);
162 if (!sub_type(Domaine, ob))
163 {
164 Cerr << "Error in Champ_Generique_Interpolation::set_domaine(nom_domaine)\n"
165 << " The object " << nom_domaine << " is not a domain" << finl;
166 if (exit_on_error)
167 {
168 exit();
169 }
170 }
171 else
172 {
173 domaine_ = ref_cast(Domaine, ob);
174 }
175 }
176 return ok;
177}
178
179/*! @brief Interpolation of the source field based on the requested method, localisation, and domain.
180 *
181 */
183{
184 OWN_PTR(Champ_base) espace_stockage_source_tmp;
185 const Champ_base& source = get_source(0).get_champ_without_evaluation(espace_stockage_source_tmp);
186 if (localisation_ == "")
187 {
188 Cerr << "Error in Champ_Generique_Interpolation::get_champ()\n"
189 << " Localisation has not been initialized" << finl;
190 exit();
191 }
192 else if (source.is_basis_function() or source.is_quadrature())
193 {
194 if (localisation_=="elem")
195 {
196 return get_source(0).get_champ(espace_stockage_source_);
197 }
198 else if (localisation_!="elem_dg")
199 {
200 Cerr << "Error in Champ_Generique_Interpolation::get_champ\n"
201 << "with DG the only possible localisation for Transformation is \"elem\"" << finl;
202 exit();
203 }
204 }
205
206 if (methode_ == "calculer_champ_post")
207 {
209 }
210 else
211 {
212 Cerr << "Champ_Generique_Interpolation::get_champ : methode " << methode_ << " uncoded" << finl;
213 exit();
214 }
215
216 return espace_stockage_;
217}
218
220{
221
222 OWN_PTR(Champ_base) espace_stockage_source_tmp;
223 const Champ_base& source = get_source(0).get_champ_without_evaluation(espace_stockage_source_tmp);
224 // Domain on which we interpolate the field:
225 // if domaine_ is a null reference, we take the native domain of the field.
226
227 const Noms compo = get_property("composantes");
228 const Noms nom_champ = get_property("nom");
229 const Noms syno = get_property("synonyms");
230
231 int ncomp;
232 //We set identifiant_appel_ to nom_champ[0] in the case where it equals ??
233 if (identifiant_appel_=="??")
234 {
235 ncomp = -1;
236 }
237 else
238 {
239 ncomp = Champ_Generique_base::composante(identifiant_appel_,nom_champ[0],compo,syno);
240 }
241
242 //Creation of the storage space field
243 Nature_du_champ nature_source = (ncomp==-1)?source.nature_du_champ():scalaire;
244 nature_source = source.nature_du_champ();
245 int nb_comp = source.nb_comp();
246
247 OWN_PTR(Champ_Fonc_base) es_tmp;
248 espace_stockage = creer_espace_stockage(nature_source,nb_comp,es_tmp);
249 return espace_stockage;
250}
251/*! @brief Interpolation of the source field using Champ_base::calculer_champ_xxx_post
252 *
253 */
255{
256 const Champ_base& source0 = get_source(0).get_champ(espace_stockage_source_);
257 OWN_PTR(Champ_base) source_bis;
258
259 if (optimisation_sous_maillage_==-1)
260 {
261 source_bis=source0;
262 //source.typer(source0.que_suis_je());
263
264 }
265 const Champ_base& source = ((optimisation_sous_maillage_==-1)?source_bis.valeur():source0);
266 Nom nom_champ_interpole;
267
268 // Domain on which we interpolate the field:
269 // if domaine_ is a null reference, we take the native domain of the field.
270 const Domaine& domaine = get_ref_domain();
271 const Noms compo = get_property("composantes");
272 const Noms nom_champ = get_property("nom");
273 const Noms syno = get_property("synonyms");
274
275 int ncomp;
276 //We set identifiant_appel_ to nom_champ[0] in the case where it equals ??
277 if (identifiant_appel_=="??")
278 {
279 ncomp = -1;
280 }
281 else
282 {
283 ncomp = Champ_Generique_base::composante(identifiant_appel_,nom_champ[0],compo,syno);
284 }
285
286 //Creation of the storage space field
287 Nature_du_champ nature_source = (ncomp==-1)?source.nature_du_champ():scalaire;
288 nature_source = source.nature_du_champ();
289 int nb_comp = source.nb_comp();
290 if (!espace_stockage_)
291 creer_espace_stockage(nature_source, nb_comp, espace_stockage_);
292 espace_stockage_->changer_temps(source.temps());
293
294 //double default_value=-1e35;
295 //espace_stockage.valeurs()=default_value;
296 int decal=10;
297 if (optimisation_sous_maillage_==-1)
298 {
299 espace_stockage_->valeurs()=0;
300 // first call with different mesh (or forced), we try to see if we can optimize
301 // we set the source field values to val(i)=i, to recover the cell number afterwards
302 DoubleTab& val=source_bis->valeurs();
303
304 int dim0 = val.dimension_tot(0);
305 for (int i=0; i<dim0; i++)
306 for (int j=0; j<nb_comp; j++)
307 val(i,j) = i+decal;
308 }
309
310 //Evaluation of the storage space field values
311 DoubleTab& espace_valeurs = espace_stockage_->valeurs();
312
313 if (optimisation_sous_maillage_==1)
314 {
315 const DoubleTab& val_temp= source.valeurs();
316 int dim0 = espace_valeurs.dimension(0);
317 for (int i=0; i<dim0; i++)
318 if (ncomp==-1)
319 for (int j=0; j<nb_comp; j++)
320 {
321 int n=renumerotation_maillage_[i];
322 if (n>=0)
323 espace_valeurs(i,j) = val_temp(n,j);
324 }
325 else espace_valeurs(i, ncomp) = val_temp[renumerotation_maillage_[i]];
326
327 espace_valeurs.echange_espace_virtuel();
328 return espace_stockage_;
329 }
330
331 int imax = espace_valeurs.dimension(0);
332 if (localisation_ == "elem" || localisation_=="elem_DG")
333 {
334 const int nb_elements = domaine.nb_elem();
335 nb_comp = espace_stockage_->nb_comp(); // with DG, espace_stockage has smaller dimension than source
336 if (ncomp==-1)
337 {
338 DoubleTrav val_temp;
339 source.calculer_valeurs_elem_post(val_temp,
340 nb_elements,
341 nom_champ_interpole,
342 domaine);
343 if (val_temp.isDataOnDevice())
344 {
345 CDoubleTabView val_temp_v = val_temp.view_ro();
346 DoubleTabView espace_valeurs_v = espace_valeurs.view_wo();
347 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__),
348 Kokkos::MDRangePolicy < Kokkos::Rank < 2 >> ({ 0, 0 },
349 {imax, nb_comp}), KOKKOS_LAMBDA(
350 const int i,
351 const int j)
352 {
353 espace_valeurs_v(i, j) = val_temp_v(i, j);
354 });
355 end_gpu_timer(__KERNEL_NAME__);
356 }
357 else
358 {
359 for (int i_val=0; i_val<imax; i_val++)
360 for (int j_val=0; j_val<nb_comp; j_val++)
361 espace_valeurs(i_val,j_val) = val_temp(i_val,j_val);
362 }
363 }
364 else
365 //We build a value array with nb_comp components even if ncomp!=-1
366 {
367 DoubleTrav val_temp;
368 source.calculer_valeurs_elem_compo_post(val_temp,
369 ncomp,
370 nb_elements,
371 nom_champ_interpole,
372 domaine);
373 if (val_temp.isDataOnDevice())
374 {
375 CDoubleArrView val_temp_v = static_cast<const DoubleVect&>(val_temp).view_ro();
376 DoubleTabView espace_valeurs_v = espace_valeurs.view_wo();
377 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__),
378 Kokkos::MDRangePolicy < Kokkos::Rank < 2 >> ({ 0, 0 },
379 {val_temp.dimension(0), nb_comp}), KOKKOS_LAMBDA(
380 const int i,
381 const int j)
382 {
383 if (j == ncomp)
384 espace_valeurs_v(i, j) = val_temp_v(i);
385 });
386 end_gpu_timer(__KERNEL_NAME__);
387 }
388 else
389 {
390 int dim0 = val_temp.dimension(0);
391 for (int i=0; i<dim0; i++)
392 for (int j=0; j<nb_comp; j++)
393 if (j==ncomp)
394 espace_valeurs(i,j) = val_temp(i);
395 }
396 }
397 }
398 else if (localisation_=="som")
399 {
400 const int nb_sommets = domaine.nb_som();
401 // PL: update the virtual space of the source:
402 OWN_PTR(Champ_base) copie_source;
403 copie_source = source;
404 copie_source->valeurs().echange_espace_virtuel();
405 if (ncomp==-1)
406 {
407 DoubleTrav val_temp;
408 copie_source->calculer_valeurs_som_post(val_temp,
409 nb_sommets,
410 nom_champ_interpole,
411 domaine);
412 if (val_temp.isDataOnDevice())
413 {
414 CDoubleTabView val_temp_v = val_temp.view_ro();
415 DoubleTabView espace_valeurs_v = espace_valeurs.view_wo();
416 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__),
417 Kokkos::MDRangePolicy < Kokkos::Rank < 2 >> ({ 0, 0 },
418 {imax, nb_comp}), KOKKOS_LAMBDA(
419 const int i,
420 const int j)
421 {
422 espace_valeurs_v(i, j) = val_temp_v(i, j);
423 });
424 end_gpu_timer(__KERNEL_NAME__);
425 }
426 else
427 {
428 for (int i_val=0; i_val<imax; i_val++)
429 for (int j_val=0; j_val<nb_comp; j_val++)
430 espace_valeurs(i_val,j_val) = val_temp(i_val,j_val);
431 }
432 }
433 else
434 //We build a value array with nb_comp components even if ncomp!=-1
435 {
436 DoubleTrav val_temp;
437 copie_source->calculer_valeurs_som_compo_post(val_temp,
438 ncomp,
439 nb_sommets,
440 nom_champ_interpole,
441 domaine);
442 if (val_temp.isDataOnDevice())
443 {
444 CDoubleArrView val_temp_v = static_cast<const DoubleVect&>(val_temp).view_ro();
445 DoubleTabView espace_valeurs_v = espace_valeurs.view_wo();
446 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__),
447 Kokkos::MDRangePolicy < Kokkos::Rank < 2 >> ({ 0, 0 },
448 {val_temp.dimension(0), nb_comp}), KOKKOS_LAMBDA(
449 const int i,
450 const int j)
451 {
452 if (j == ncomp)
453 espace_valeurs_v(i, j) = val_temp_v(i);
454 });
455 end_gpu_timer(__KERNEL_NAME__);
456 }
457 else
458 {
459 int dim0 = val_temp.dimension(0);
460 for (int i=0; i<dim0; i++)
461 for (int j=0; j<nb_comp; j++)
462 if (j==ncomp)
463 espace_valeurs(i,j) = val_temp(i);
464 }
465 }
466 }
467 else
468 {
469 espace_stockage_->affecter(source);
470 }
471
472 if (optimisation_sous_maillage_==-1)
473 {
474 // we recompute the correct field
475
476 DoubleTab& val=espace_valeurs;
477 int dim0 = val.dimension_tot(0);
478 ArrOfInt& renumerotation_maillage=ref_cast_non_const(ArrOfInt, renumerotation_maillage_);
479 renumerotation_maillage.resize_array(dim0);
480 int ok=1;
481
482 for (int i=0; (i<dim0)&& ok; i++)
483 {
484 double v;
485 v=espace_valeurs(i,0) ;
486
487 int iproche=-1;
488 if (v>0)
489 {
490 iproche=int(v+0.1); // we add 0.1 for the case where v equals i-epsilon
491 if (std::fabs(iproche-v)>1e-5)
492 {
493 ok=0;
494 Cerr<<nom_champ[0]<<" optimisation ko "<< finl;
495
496 }
497 }
498 renumerotation_maillage[i]=iproche-decal;
499
500 }
501
502 int test=(int)mp_min(ok);
503 if (test)
504 {
505 ref_cast_non_const(Champ_Generique_Interpolation,(*this)).optimisation_sous_maillage_=0;
506 OWN_PTR(Champ_base) espace_stockage_test;
507 espace_stockage_test = get_champ_with_calculer_champ_post();
508 ref_cast_non_const(Champ_Generique_Interpolation,(*this)).optimisation_sous_maillage_=test;
510 espace_stockage_test->valeurs()-=espace_stockage_->valeurs();
511 double dmax= mp_max_abs_vect(espace_stockage_test->valeurs());
512 if (dmax > 1e-7)
513 {
514 Cerr<<nom_champ[0]<<" optimisation ko "<< dmax<<finl;
515 exit();
516 }
517 else
518 Cerr<<nom_champ[0]<<" optimisation ok "<< dmax<<finl;
519 }
520
521 else
522 {
523 if (optimisation_demande_==1)
524 {
525 Cerr<<nom_champ[0]<<" optimisation not allowed "<<finl;
526 exit();
527 }
528 }
529 ref_cast_non_const(Champ_Generique_Interpolation,(*this)).optimisation_sous_maillage_=test;
531 }
532
533 espace_valeurs.echange_espace_virtuel();
534 return espace_stockage_;
535}
536
538{
539 OWN_PTR(Champ_base) champ_a_ecrire;
540 get_champ(champ_a_ecrire);
541 return champ_a_ecrire->valeurs();
542}
543
545{
546 const DoubleTab& val = get_ref_values();
547 // Create a copy of the array
548 values = val;
549}
550
552{
553 Entity loc;
554 if (localisation_=="elem"||localisation_=="elem_DG")
555 loc = Entity::ELEMENT;
556 else if (localisation_=="som")
557 loc = Entity::NODE;
558 else if (localisation_=="faces")
559 loc = Entity::FACE;
560 else
561 {
562 Cerr << "Error of type : localisation should be specified to elem or som or faces for the defined field " << nom_post_ << finl;
563 throw Champ_Generique_erreur("INVALID");
564 }
565 return loc;
566}
567
569{
570 if (domaine_)
571 {
572 return domaine_.valeur();
573 }
574 else
575 {
576 return get_source(0).get_ref_domain();
577 }
578}
579
581{
582 const Domaine& dom = get_ref_domain();
583 domain = dom;
584}
585
587{
588 const DoubleTab& coord = get_ref_domain().coord_sommets();
589 return coord;
590}
591
593{
594 const DoubleTab& coord = get_ref_coordinates();
595 coordinates = coord;
596}
597
599{
600
601 Motcles motcles(2);
602 motcles[0] = "composantes";
603 motcles[1] = "synonyms";
604 int rang = motcles.search(query);
605 switch(rang)
606 {
607
608 case 0:
609 {
610 Noms source_compos = get_source(0).get_property("composantes");
611 int nb_comp = source_compos.size();
612 Noms compo(nb_comp);
613
614 if (compo_.size()>1)
615 {
616 //The field was created by a macro and the compo_ attribute of Champ_Generique_base was filled
617 //This allows reproducing the component names in the lml files
618 compo=compo_;
619 }
620 else
621 {
622 for (int i=0; i<nb_comp; i++)
623 {
624 Nom nume(i);
625 compo[i] = nom_post_+nume;
626 }
627 }
628 return compo;
629 }
630 case 1:
631 {
632 if (syno_.size()>0)
633 {
634 return syno_;
635 }
636 return get_source(0).get_property("synonyms");
637 }
638
639 }
640
642
643}
644//Name the field as a source by default
645//nom_champ_source + "_" + localisation_ + "_" +nom_dom_interp;
647{
648 if (nom_post_=="??")
649 {
650 Nom nom_post_source, nom_champ_source, nom_dom_interp;
651 const Noms nom = get_source(0).get_property("nom");
652 nom_champ_source = nom[0];
653 nom_dom_interp = get_ref_domain().le_nom();
654 nom_post_source = nom_champ_source + "_" + localisation_ + "_" +nom_dom_interp;
655 nommer(nom_post_source);
656 }
657}
658
660{
661 return syno_=noms;
662}
664{
665 return compo_=noms;
666}
667
669{
671 // Verifications:
672 if (get_nb_sources() != 1)
673 {
674 Cerr << "Error in Champ_Generique_Interpolation::readOn\n"
675 << " You must specify exactly 1 \"Source\"." << finl;
676 exit();
677 }
678 // If the read domain is not the calculation domain, we set the domain
679 const Domaine& domaine_calcul = get_source(0).get_ref_domain();
680 if (optimisation_demande_!=1)
681 optimisation_sous_maillage_=0;
682 if ( (nom_domaine_lu_!="") && (nom_domaine_lu_!=domaine_calcul.le_nom()) )
683 {
684 set_domaine(nom_domaine_lu_);
685 }
686 else
687 {
688 // sub-mesh optimization not needed
689 if (optimisation_demande_==-1)
690 optimisation_sous_maillage_=0;
691 }
692
694}
696{
697 if (domaine_)
698 {
699 if (!le_dom_dis)
700 {
701 Cerr << "Error in Interpolation definition:" << finl;
702 Cerr << "The domain " << domaine_->le_nom() << " is not built." << finl;
703 exit();
704 }
705 return le_dom_dis.valeur();
706 }
707 else
708 {
710 }
711}
712
714{
715 Motcle directive;
716
717 if (localisation_=="elem")
718 {
719 OWN_PTR(Champ_base) espace_stockage_source_tmp;
720 const Champ_base& ch = get_source(0).get_champ_without_evaluation(espace_stockage_source_tmp);
721 directive = ch.is_basis_function() ? "champ_elem_DG" : (ch.is_quadrature() ? "champ_fonc_quad_DG" : "champ_elem");
722 }
723 else if (localisation_=="elem_DG")
724 directive = "champ_elem";
725 else if (localisation_=="som")
726 directive = "champ_sommets";
727 else if (localisation_=="faces")
728 directive = "champ_face";
729 else
730 {
731 Cerr<<"Localisation "<<localisation_<<" is not recognized by "<<que_suis_je()<<finl;
732 exit();
733 }
734
735 return directive;
736}
737
738//Discretisation of the interpolation domain if it is not the calculation domain
739//This discretisation is necessary to associate a discretized domain to the storage space
740//in the get_champ() method
742{
743 if (domaine_)
744 {
745 const Probleme_base& Pb = get_ref_pb_base();
746 const Discretisation_base& discr = Pb.discretisation();
747 Nom type_discr = discr.que_suis_je();
748 if (type_discr == "VEFPreP1B") type_discr = "VEF";
749 // we do not create faces unless we want a face interpolation or we have polyhedra
750 // Nom type = sub_type(Poly_geom_base, domaine_->type_elem().valeur()) ? "Domaine_" : "NO_FACE_Domaine_";
751 Nom type = "NO_FACE_Domaine_";
752 if (localisation_=="faces")
753 {
754 type="Domaine_";
755 // We verify that face localisation is possible on the domain (otherwise elem or som)
756 if (domaine_->type_elem()->nb_som_face()<=2 && dimension==3)
757 {
758 Cerr << "'localisation faces' is not possible in 3D on the 2D surface mesh " << domaine_->le_nom() << " with the field: " << get_property("NOM")[0] << finl;
759 Cerr << "Please use 'localisation elem' instead." << finl;
760 exit();
761 }
762 }
763 type += type_discr;
764 le_dom_dis = Domaine_dis_cache::Build_or_get(type, domaine_.valeur());
765 }
766}
class Champ_Fonc_base Base class of fields that are functions of a calculated quantity
Base class of generic fields having other generic fields as source. The use of the class methods reli...
const Noms get_property(const Motcle &query) const override
Returns the requested property.
void completer(const Postraitement_base &post) override
const Probleme_base & get_ref_pb_base() const override
Returns the problem that carries the target field.
virtual const Champ_Generique_base & get_source(int i) const
void set_param(Param &param) const override
const Domaine_dis_base & get_ref_domaine_dis_base() const override
Returns a ref to the discretized domain on which the storage space will be evaluated.
A generic field constructed as an interpolation of another generic field (interpolation at vertices o...
void get_copy_domain(Domaine &) const override
Creates a copy of the domain on which the storage space will be evaluated.
const Noms & fixer_noms_compo(const Noms &noms) override
const Motcle get_directive_pour_discr() const override
Returns the directive (champ_elem, champ_sommets, champ_face or pression) to launch the discretizatio...
void completer(const Postraitement_base &post) override
void set_param(Param &param) const override
const DoubleTab & get_ref_values() const override
Returns a reference to the array of discrete values if it exists in memory.
const DoubleTab & get_ref_coordinates() const override
Returns a reference to the array of coordinates of the vertices of the mesh supporting the field,...
void reset() override
Restore the initial configuration of the object: localisation not specified, source not specified,...
virtual int set_domaine(const Nom &nom_domaine, int exit_on_error=1)
Class initialization: initialization of the interpolation domain. Valid parameters: "" => native doma...
const Domaine_dis_base & get_ref_domaine_dis_base() const override
Returns a ref to the discretized domain on which the storage space will be evaluated.
const Domaine & get_ref_domain() const override
Returns a ref to the domain on which the storage space will be evaluated.
virtual const Champ_base & get_champ_with_calculer_champ_post() const
Interpolation of the source field using Champ_base::calculer_champ_xxx_post.
Entity get_localisation(const int index=-1) const override
Returns the type of geometric entities on which the discrete values are attached (NODE for a P1 field...
void get_copy_values(DoubleTab &) const override
Fills the values array with the discrete values of the field (creates a copy).
virtual int set_methode(const Motcle &methode, int exit_on_error=1)
Class initialization: initialization of the interpolation method. Valid parameters: calculer_champ_po...
const Noms get_property(const Motcle &query) const override
Returns the requested property.
void get_copy_coordinates(DoubleTab &) const override
const Champ_base & get_champ(OWN_PTR(Champ_base)&espace_stockage) const override
Interpolation of the source field based on the requested method, localisation, and domain.
const Champ_base & get_champ_without_evaluation(OWN_PTR(Champ_base)&espace_stockage) const override
virtual int set_localisation(const Motcle &localisation, int exit_on_error=1)
Class initialization: initialization of the requested localisation.
const Noms & fixer_noms_synonyms(const Noms &noms) override
virtual const Noms get_property(const Motcle &query) const
Returns the requested property.
static int composante(const Nom &nom_test, const Nom &nom, const Noms &composantes, const Noms &synonyms)
virtual const Champ_base & get_champ(OWN_PTR(Champ_base) &espace_stockage) const =0
virtual const Champ_base & get_champ_without_evaluation(OWN_PTR(Champ_base)&espace_stockage) const =0
void nommer(const Nom &nom) override
Assigns a name to the Objet_U. Virtual method to override.
virtual const Domaine & get_ref_domain() const
Returns a ref to the domain on which the storage space will be evaluated.
virtual DoubleTab & valeurs()=0
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
void calculer_valeurs_elem_post(DoubleTab &valeurs, int nbelem, Nom &nom_post, const Domaine &dom) const
void calculer_valeurs_elem_compo_post(DoubleTab &valeurs, int ncomp, int nbelem, Nom &nom_post, const Domaine &dom) const
double temps() const
Returns the time of the field.
class Discretisation_base This class represents a spatial discretization scheme, which
const DoubleTab_t & coord_sommets() const
Definition Domaine.h:112
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
static Domaine_dis_base & Build_or_get(const Nom &type, const Domaine &dom, const Discretisation_base *disc=nullptr)
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual int nb_comp() const
Definition Field_base.h:56
bool is_quadrature() const
Definition Field_base.h:81
virtual Nature_du_champ nature_du_champ() const
Definition Field_base.h:77
bool is_basis_function() const
Definition Field_base.h:80
static Objet_U & objet(const Nom &)
See Interprete_bloc::objet_global(). BM: the Interprete class is not the best place for this.
A character string (Nom) in uppercase.
Definition Motcle.h:26
An array of Motcle objects.
Definition Motcle.h:63
int search(const Motcle &t) const
Definition Motcle.cpp:319
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
An array of character strings (VECT(Nom)).
Definition Noms.h:26
const Interprete & interprete() const
Definition Objet_U.cpp:211
static int dimension
Definition Objet_U.h:94
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
Objet_U()
Default constructor: assigns a unique identifier to the object (object_id_) and registers the object ...
Definition Objet_U.cpp:54
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
void dictionnaire(const char *option_name, int value)
Add an (option name, integer value) entry to the dictionary attached to a previously registered integ...
Definition Param.cpp:293
void ajouter(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
Definition Param.cpp:364
@ REQUIRED
Definition Param.h:115
Base class for all post-processing objects.
class Probleme_base It is a Probleme_U that is not a coupling.
const Discretisation_base & discretisation() const
Returns the discretization associated with the problem.
static double mp_min(double)
Definition Process.cpp:391
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
void resize_array(_SIZE_ new_size, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
bool isDataOnDevice() const
std::enable_if_t< is_default_exec_space< EXEC_SPACE >, View< _TYPE_, _SHAPE_ > > view_wo()
Definition TRUSTTab.h:276
_SIZE_ dimension_tot(int) const override
Definition TRUSTTab.tpp:160
std::enable_if_t< is_default_exec_space< EXEC_SPACE >, ConstView< _TYPE_, _SHAPE_ > > view_ro() const
Definition TRUSTTab.h:261
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")