TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Source_QC_Chaleur.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 <Fluide_Quasi_Compressible.h>
17#include <Source_QC_Chaleur.h>
18#include <Schema_Temps_base.h>
19#include <Equation_base.h>
20#include <kokkos++.h>
21#include <TRUSTArray_kokkos.tpp>
22
23Implemente_base(Source_QC_Chaleur,"Source_QC_Chaleur",Source_Chaleur_Fluide_Dilatable_base);
24
26{
27 os <<que_suis_je()<< finl;
28 return os;
29}
30
32{
33 return is;
34}
35
36
37DoubleTab& Source_QC_Chaleur::ajouter(DoubleTab& resu) const
38{
40 {
41 ajouter_blocs({}, resu);
42 return resu;
43 }
44 return ajouter_(resu);
45}
46
47
48/*! @brief Adds the source terms.
49 *
50 * @return (Entree&)
51 */
52DoubleTab& Source_QC_Chaleur::ajouter_(DoubleTab& resu) const
53{
54 double dt_= mon_equation->schema_temps().temps_courant() - mon_equation->schema_temps().temps_precedent();
55
56 if (dt_<=0) return resu; // Do not compute this source term if dt<=0
57
58 /*
59 * The source term corresponds to :
60 * d P_tot / d t = del P / del t + u.grad(P_tot)
61 * Here grad(P_tot) = 0 (uniform in space)
62 */
63
64 const Fluide_Quasi_Compressible& FQC = ref_cast(Fluide_Quasi_Compressible,le_fluide.valeur());
65 double Pth = FQC.pression_th(), Pthn = FQC.pression_thn();
66 double dpth = ( Pth - Pthn ) / dt_;
67 // resu+=dpth*volumes*porosites
68 int nsom = resu.dimension(0);
69 CDoubleArrView volumes_v = volumes.view_ro();
70 CDoubleArrView porosites_v = porosites.view_ro();
71 // ToDo_Kokkos: DoubleArrView resu_v = resu.view_rw(); with resu as DoubleTab
72 DoubleTabView resu_v = resu.view_rw();
73 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), nsom, KOKKOS_LAMBDA(
74 const int i)
75 {
76 resu_v(i, 0) += dpth * volumes_v(i) * porosites_v(i);
77 });
78 end_gpu_timer(__KERNEL_NAME__);
79 /* Ne marche pas detect inf en debug: */
80 /* DoubleVect vol(volumes);
81 vol*=porosites;
82 ajoute_alpha_v(resu, dpth, vol); */
83 return resu;
84}
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Fluide_Quasi_Compressible class This class represents a quasi-compressible fluid,.
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
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
Base class for output streams.
Definition Sortie.h:52
Additional source term for the heat equation when the fluid is quasi-compressible.
class Source_QC_Chaleur
DoubleTab & ajouter(DoubleTab &) const override
virtual public_for_cuda DoubleTab & ajouter_(DoubleTab &) const
Adds the source terms.
virtual int has_interface_blocs() const
Definition Source_base.h:68
virtual void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl={ }) const
std::enable_if_t< is_default_exec_space< EXEC_SPACE >, View< _TYPE_, _SHAPE_ > > view_rw()
Definition TRUSTTab.h:291
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133