TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_Input_P0_Composite.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 <Champ_Input_P0_Composite.h>
17#include <Discretisation_base.h>
18#include <Champ_Fonc_MED.h>
19#include <Champ_Uniforme.h>
20#include <Probleme_base.h>
21#include <Domaine_dis_base.h>
22#include <Param.h>
23
24Implemente_instanciable(Champ_Input_P0_Composite,"Champ_Input_P0_Composite",Champ_Fonc_P0_base);
25// XD champ_input_p0_composite champ_input_base champ_input_p0_composite BRACE Field used to define a classical champ
26// XD_CONT input p0 field (for ICoCo), but with a predefined field for the initial state.
27// XD attr initial_field field_base initial_field OPT The field used for initialization
28// XD attr input_field champ_input_p0 input_field OPT The input field for ICoCo
29
30Sortie& Champ_Input_P0_Composite::printOn(Sortie& os) const { return os; }
31
33{
34 Cerr << "Reading of data for " << que_suis_je() << finl;
35 Param param(que_suis_je());
36 param.ajouter("initial_field", &champ_initial_);
37 param.ajouter("input_field", &champ_input_, Param::REQUIRED);
38 param.lire_avec_accolades_depuis(is);
39
40 // Put initial field at elem if needed
41 if ( is_initialized() )
42 {
43 if (champ_initial_->nb_comp() != champ_input_.nb_comp())
44 {
45 Cerr << "WHAT ?? Go to the Champ_Input_P0_Composite field and define the same number of components for the fields !!!" << finl;
47 }
48
49 const Discretisation_base& disc = champ_input_.z_probleme().discretisation();
50 const int ncomp = champ_initial_->nb_comp();
51 if (domaine_dis_base().nb_elem_tot() == champ_initial_->valeurs().dimension_tot(0)) { /* do nothing */ }
52 else if (sub_type(Champ_Fonc_MED,champ_initial_.valeur()))
53 {
54 OWN_PTR(Champ_Don_base) tmp_fld;
55 disc.discretiser_champ("champ_elem",domaine_dis_base(),"neant","neant",ncomp ,0.,tmp_fld);
56 tmp_fld->affecter(champ_initial_.valeur()); // interpolate ...
57 champ_initial_.detach();
58 disc.discretiser_champ("champ_elem",domaine_dis_base(),"neant","neant",ncomp,0.,champ_initial_);
59 champ_initial_->valeurs() = tmp_fld->valeurs();
60 }
61 else if (sub_type(Champ_Uniforme,champ_initial_.valeur())) // blabla ...
62 {
63 const double val = champ_initial_->valeurs()(0,0);
64 champ_initial_.detach();
65 disc.discretiser_champ("champ_elem",domaine_dis_base(),"neant","neant",ncomp,0.,champ_initial_);
66 champ_initial_->valeurs() = val;
67 }
68 else
69 {
70 Cerr << "Error in the readOn of : " << que_suis_je() << finl;
71 Cerr << "The initial field type is not yet treated ! Call the 911 !" << finl;
73 }
74 }
75 return is;
76}
const Domaine_dis_base & domaine_dis_base() const override
void discretiser_champ(const Motcle &directive, const Domaine_dis_base &z, const Nom &nom, const Nom &unite, int nb_comp, int nb_pas_dt, double temps, OWN_PTR(Champ_Inc_base)&champ, const Nom &sous_type=NOM_VIDE) const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
@ REQUIRED
Definition Param.h:115
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
Classe de base des flux de sortie.
Definition Sortie.h:52