TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Domaine_EF_axi.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 <Domaine_EF_axi.h>
17#include <DomaineAxi1d.h>
18#include <Domaine_Cl_dis_base.h>
19#include <Equation_base.h>
20#include <Milieu_base.h>
21
22Implemente_instanciable( Domaine_EF_axi, "Domaine_EF_axi", Domaine_EF ) ;
23
25{
27 return os;
28}
29
31{
33 return is;
34}
35
37{
38 const IntTab& les_elems=domaine().les_elems() ;
39 int nbsom_face=nb_som_face();
40 int nbelem=nb_elem_tot();
41 int nbsom_elem=domaine().nb_som_elem();
42 const IntTab& elemfaces=elem_faces_;
43 int nbface_elem=domaine().nb_faces_elem();
44
45 const DoubleTab& les_coords = domaine_axi().coord_sommets();
46
47 const DoubleVect& surf = face_surfaces();
48
49 for (int elem=0; elem<nbelem; elem++)
50 {
51 double x0 = origine_repere_(elem,0);
52 double y0 = origine_repere_(elem,1);
53
54 for (int i=0; i<nbsom_elem; i++)
55 {
56 // search for contributing faces, this is not optimal
57 for (int f=0; f<nbface_elem; f++)
58 {
59 int face=elemfaces(elem,f);
60 for (int s=0; s<nbsom_face; s++)
61 {
62 // search for contributing faces, this is not optimal
63 if (face_sommets_(face,s)==les_elems(elem,i))
64 {
65 double x1 = les_coords(les_elems(elem,0),0);
66 double x2 = les_coords(les_elems(elem,1),0);
67 double y1 = les_coords(les_elems(elem,0),1);
68 double y2 = les_coords(les_elems(elem,1),1);
69
70 double r1 = sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0));
71 double r2 = sqrt((x2-x0)*(x2-x0)+(y2-y0)*(y2-y0));
72
73 for (int j=0; j<dimension; j++)
74 {
75 if (surf(face)>0)
76 bij(elem,i,j)+=face_normales(face,j)*oriente_normale(face,elem)*(r1+r2)*M_PI/surf(face);
77 else
78 bij(elem,i,j)+=face_normales(face,j)*oriente_normale(face,elem)*(r1+r2)*M_PI;
79 }
80 }
81 }
82 }
83 }
84 }
85}
86
88{
89 int nbelem=domaine().nb_elem();
90 int nb_som_elem=domaine().nb_som_elem();
91 assert(nb_som_elem==2);
92
93 IPhi_.resize(nbelem,nb_som_elem);
95 // Scatter::creer_tableau_distribue(domaine().domaine(), JOINT_ITEM::ELEMENT, IPhi_);
97
98 const IntTab& les_elems=domaine().les_elems() ;
99
100 const DoubleTab& les_coords = domaine_axi().coord_sommets();
101
102 for (int elem=0; elem<nbelem; elem++)
103 {
104 double x1 = les_coords(les_elems(elem,0),0);
105 double x2 = les_coords(les_elems(elem,1),0);
106 double y1 = les_coords(les_elems(elem,0),1);
107 double y2 = les_coords(les_elems(elem,1),1);
108
109 double x0 = origine_repere_(elem,0);
110 double y0 = origine_repere_(elem,1);
111
112 double r1 = sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0));
113 double r2 = sqrt((x2-x0)*(x2-x0)+(y2-y0)*(y2-y0));
114 IPhi_(elem,0) = (M_PI/3.)*(r2*r2+r1*r2-2.*r1*r1);
115 IPhi_(elem,1) = (M_PI/3.)*(2.*r2*r2-r1*r2-r1*r1);
116
117 for (int s=0; s<nb_som_elem; s++)
118 IPhi_thilde_(elem,s)=IPhi_(elem,s)*zcl.equation().milieu().porosite_elem(elem);
119 }
120
121 IPhi_.echange_espace_virtuel();
122 IPhi_thilde_.echange_espace_virtuel();
123}
124
126{
127 DomaineAxi1d& domax = domaine_axi();
128
131
132 if (domax.has_champ_origine())
133 {
134 const Champ_base& orig = domax.champ_origine();
135 DoubleTab positions;
136 domax.calculer_centres_gravite(positions);
137 orig.valeur_aux(positions, origine_repere_);
138 }
139 else
140 {
142 Process::exit("Error, origine should be explicitly defined with ModifyDomaineAxi1D keyword.");
143 }
145}
146
148{
149 if (!domaine().axi1d())
150 {
151 Cerr << "*****************************************************************************" << finl;
152 Cerr << " Error in " << que_suis_je() << " : the type of domain " << domaine().que_suis_je();
153 Cerr << " is not compatible" << finl;
154 Cerr << " with the discretisation EF_axi. " << finl;
155 Cerr << " Please use the discretization EF or define a domain of type DomaineAxi1d." << finl;
156 Cerr << "*****************************************************************************" << finl;
158 }
159}
160
169
170const DomaineAxi1d& Domaine_EF_axi::domaine_axi() const
171{
172 return ref_cast(DomaineAxi1d,domaine());
173}
174
176{
177 return ref_cast(DomaineAxi1d,domaine());
178}
179
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
virtual DoubleTab & valeur_aux(const DoubleTab &positions, DoubleTab &valeurs) const
Causes an error! Must be overridden by derived classes.
void associer_origine_repere(const DoubleTab_t &orig)
bool has_champ_origine() const
const Champ_base & champ_origine() const
int nb_som_elem() const
Returns the number of vertices of the geometric elements that make up the domain.
Definition Domaine.h:474
virtual void creer_tableau_elements(Array_base &, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT) const
Creates a parallel array of values at elements.
Definition Domaine.cpp:850
void calculer_centres_gravite(DoubleTab_t &xp) const
Calculates the centers of gravity of the domain elements.
Definition Domaine.h:503
IntTab_t & les_elems()
Definition Domaine.h:129
int_t nb_elem() const
Definition Domaine.h:131
int nb_faces_elem(int=0) const
Returns the number of faces of type i of the geometric elements that make up the domain.
Definition Domaine.h:484
const DoubleTab_t & coord_sommets() const
Definition Domaine.h:112
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
: class Domaine_EF_axi
void discretiser() override
DoubleTab origine_repere_
void calculer_Bij_gen(DoubleTab &bij_) override
void remplir_tableau_origine()
void verifie_compatibilite_domaine() override
const DomaineAxi1d & domaine_axi() const
void calculer_IPhi(const Domaine_Cl_dis_base &zcl) override
class Domaine_EF
Definition Domaine_EF.h:56
DoubleTab IPhi_thilde_
Definition Domaine_EF.h:97
void discretiser() override
DoubleTab IPhi_
Definition Domaine_EF.h:97
void typer_elem(Domaine &domaine_geom) override
virtual const DoubleVect & face_surfaces() const
Definition Domaine_VF.h:51
IntTab face_sommets_
Definition Domaine_VF.h:223
int nb_som_face() const
Returns the number of vertices per face.
Definition Domaine_VF.h:493
IntTab elem_faces_
Definition Domaine_VF.h:222
int oriente_normale(int f, int e) const
Definition Domaine_VF.h:194
virtual DoubleTab & face_normales()
Definition Domaine_VF.h:48
int nb_elem_tot() const
const Domaine & domaine() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual const Milieu_base & milieu() const =0
DoubleVect & porosite_elem()
Definition Milieu_base.h:58
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
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
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
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