TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
distances_EF.h
1/****************************************************************************
2* Copyright (c) 2023, 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#ifndef distances_EF_inclus
17#define distances_EF_inclus
18#include <Domaine_EF.h>
19double norm_vit_lp_k(const DoubleTab& vit,int face,int face_b,const Domaine_EF& domaine,ArrOfDouble& val,int is_defilante);
20double norm_vit_lp(const ArrOfDouble& vit,int face,const Domaine_EF& domaine,ArrOfDouble& val);
21double norm_3D_vit1(const DoubleTab& vit,int fac,int num1,
22 const Domaine_EF& domaine,
23 double& val1,double& val2,double& val3);
24double norm_2D_vit1_k(const DoubleTab& vit,int fac,int num1,
25 const Domaine_EF& domaine,
26 double& val1,double& val2);
27double norm_3D_vit2(const DoubleTab& vit,int fac,int num1,
28 const Domaine_EF& domaine,
29 double& val1,double& val2,double& val3);
30double norm_2D_vit2_k(const DoubleTab& vit,int fac,int num1,
31 const Domaine_EF& domaine,
32 double& val1,double& val2);
33double distance_2D(int fac,int elem,const Domaine_EF& domaine);
34
35double distance_3D(int fac,int elem,const Domaine_EF& domaine);
36double distance_face_elem(int fac,int elem,const Domaine_EF& domaine);
37
38// Fonctions inlinees pour optimisation
39inline double vitesse_tangentielle(const double& v0,const double& v1,const double& r0,const double& r1)
40{
41 // On prend fabs car mathematiquement la valeur est >=0
42 return sqrt(std::fabs(carre(v0)+carre(v1)-carre(v0*r0+v1*r1)));
43}
44inline double vitesse_tangentielle(const double& v0,const double& v1,const double& v2,const double& r0,const double& r1,const double& r2)
45{
46 // On prend fabs car mathematiquement la valeur est >=0
47 return sqrt(std::fabs(carre(v0)+carre(v1)+carre(v2)-carre(v0*r0+v1*r1+v2*r2)));
48}
49
50inline void calcule_r0r1(const DoubleTab& face_normale, int& fac, double& r0, double& r1)
51{
52 r0=face_normale(fac,0);
53 r1=face_normale(fac,1);
54 double tmp=1/sqrt(r0*r0+r1*r1);
55 r0*=tmp;
56 r1*=tmp;
57}
58
59inline void calcule_r0r1r2(const DoubleTab& face_normale, int& fac, double& r0, double& r1, double& r2)
60{
61 r0=face_normale(fac,0);
62 r1=face_normale(fac,1);
63 r2=face_normale(fac,2);
64 double tmp=1/sqrt(r0*r0+r1*r1+r2*r2);
65 r0*=tmp;
66 r1*=tmp;
67 r2*=tmp;
68}
69
70inline double distance_face(int fac,int fac1,const Domaine_EF& domaine)
71{
72 int dimension=Objet_U::dimension;
73 const DoubleTab& xv = domaine.xv(); // centre de gravite des faces
74 const DoubleTab& face_normale = domaine.face_normales();
75 double r0,r1;
76 double x0=xv(fac,0);
77 double y0=xv(fac,1);
78 double x1=xv(fac1,0);
79 double y1=xv(fac1,1);
80 if (dimension==3)
81 {
82 double r2;
83 double z0=xv(fac,2);
84 double z1=xv(fac1,2);
85 calcule_r0r1r2(face_normale,fac,r0,r1,r2);
86 return std::fabs(r0*(x1-x0)+r1*(y1-y0)+r2*(z1-z0));
87 }
88 else
89 {
90 calcule_r0r1(face_normale,fac,r0,r1);
91 return std::fabs(r0*(x1-x0)+r1*(y1-y0));
92 }
93}
94#endif
class Domaine_EF
Definition Domaine_EF.h:59
static int dimension
Definition Objet_U.h:99