TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Ch_front_input_P1.cpp
1/****************************************************************************
2* Copyright (c) 2025, 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 <Ch_front_input_P1.h>
17#include <Probleme_base.h>
18#include <Schema_Temps_base.h>
19#include <Interprete.h>
20#include <Domaine.h>
21#include <Frontiere_dis_base.h>
22#include <communications.h>
23#include <Roue.h>
24#include <Convert_ICoCoTrioField.h>
25
26
27Implemente_instanciable(Ch_front_input_P1,"Ch_front_input_P1",Ch_front_input);
28
29
31{
32 return Ch_front_input::readOn(is);
33}
34
36{
37 return Ch_front_input::printOn(os);
38}
39
40int Ch_front_input_P1::initialiser(double temps, const Champ_Inc_base& inco)
41{
42 if (!Ch_front_input::initialiser(temps,inco))
43 return 0;
44
45 /* mis sans ch_fr_input ...
46 const DoubleTab& sommets_org=(mon_pb->domaine().les_sommets());
47 DoubleTab& sommets=sommets_;
48 sommets=sommets_org;
49
50
51 IntTab& faces=faces_;
52 faces=(frontiere_dis().frontiere().faces().les_sommets());
53
54 int ntot=0;
55 ArrOfInt marqueur(sommets_org.dimension(0));
56 marqueur=-1;
57 for (int f=0;f<faces.dimension(0);f++)
58 {
59 for (int s=0;s<faces.dimension(1);s++)
60 {
61 int som=faces(f,s);
62 if (marqueur(som)==-1)
63 {
64
65 marqueur(som)=ntot;
66 for (int dir=0;dir<dimension;dir++)
67 {
68 sommets(ntot,dir)=sommets_org(som,dir);
69 }
70 ntot++;
71 }
72 }
73 }
74 sommets.resize(ntot,dimension);
75
76
77 // rebuild the faces
78 for (int f=0;f<faces.dimension(0);f++)
79 for (int s=0;s<faces.dimension(1);s++)
80 faces(f,s)=faces(f,marqueur(s));
81
82 */
83 int ntot=sommets_.dimension(0);
84 les_valeurs_som->fixer_nb_cases(les_valeurs->nb_cases());
85 for (int i=0; i<les_valeurs_som->nb_cases(); i++)
87
88//Cerr<<" ici "<< les_valeurs->valeurs()<<finl;
89 if (initial_value_.size_array()!=0)
90 {
91 for (int i=0; i<les_valeurs_som->nb_cases(); i++)
92 for (int j=0; j<ntot; j++)
93 for (int c=0; c<nb_comp(); c++)
95 }
96 ;
97 return 1;
98}
99
100double Ch_front_input_P1::valeur_au_temps_et_au_point(double temps,int som,double x,double y, double z,int comp) const
101{
102 const DoubleTab& sommets=sommets_;
103 for (int som2=0; som2<sommets.dimension(0); som2++)
104 {
105 if ((dimension<3)||(est_egal(sommets(som2,2),z)))
106
107 if ((dimension<2)||(est_egal(sommets(som2,1),y)))
108 if (est_egal(sommets(som2,0),x))
109
110 return les_valeurs_som[1].valeurs()(som2,comp);
111
112 }
113
114 Cerr<<" point not found "<<finl;
115 exit();
116 return -1.;
117}
118void Ch_front_input_P1::getTemplate(TrioField& afield) const
119{
120 afield.clear();
121 afield.setName(le_nom().getChar());
122 afield._type=1;
123 afield._time1=mon_pb->presentTime();
124 afield._time2=mon_pb->futureTime();
125
126 afield._nb_field_components=nb_comp();
127
128 const DoubleTab& sommets=sommets_;
129
130 const IntTab& faces=faces_;
131
132 assert(sommets.nb_dim()==2);
133 assert(faces.nb_dim()==2);
134
135 afield._space_dim=sommets.dimension(1);
136 afield._mesh_dim=afield._space_dim-1;
137 afield._nbnodes=sommets.dimension(0);
138 afield._nodes_per_elem = mp_max(faces.dimension(1));
139 afield._nb_elems=faces.dimension(0);
140
141 // Includes all the nodes, even those not used in connectivity
142 // order is x y z x y z x y z
143 affecte_double_avec_doubletab(&afield._coords,sommets);
144 affecte_int_avec_inttab(&afield._connectivity,faces);
145}
146
147
148void Ch_front_input_P1::setValue(const TrioField& afield)
149{
150 // exit();
151 //Cerr<<afield._nb_elems<<" cii "<<les_valeurs_som[1].valeurs().dimension(0)<<finl;
152 for (int i=1; i<les_valeurs_som->nb_cases(); i++)
154 //Cout<<" IIIIIIII "<<les_valeurs_som[1].valeurs()<<finl;
155 calculer_derivee_en_temps(afield._time1,afield._time2);
156}
class Ch_front_input
int initialiser(double temps, const Champ_Inc_base &inco) override
Initialization at the beginning of calculation.
void getTemplate(TrioField &afield) const override
Provides afield with a name, a time interval, components, and no field ownership.
double valeur_au_temps_et_au_point(double temps, int som, double x, double y, double z, int comp) const override
void setValue(const TrioField &afield) override
Uses the first value in afield as uniform value, regardless of geometry.
class Ch_front_input
DoubleTab sommets_
int initialiser(double temps, const Champ_Inc_base &inco) override
Initialization at the beginning of calculation.
Class Champ_Inc_base.
void setValueOnTab(const TrioField &afield, DoubleTab &tab)
ArrOfDouble initial_value_
virtual DoubleTab & valeurs() override
Returns the array of field values.
virtual void calculer_derivee_en_temps(double t1, double t2)
Computes the rate of change of the field between t1 and t2 and stores it in Gpoint_.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
const Nom & le_nom() const override
Returns the name of the field.
virtual int nb_comp() const
Definition Field_base.h:56
static int dimension
Definition Objet_U.h:94
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
static double mp_max(double)
Definition Process.cpp:379
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
int nb_dim() const
Definition TRUSTTab.h:199
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133