Herezh_dev/herezh_pp/Util/Algo_Integ1D_2.cc

94 lines
3.3 KiB
C++
Executable file

// This file is part of the Herezh++ application.
//
// The finite element software Herezh++ is dedicated to the field
// of mechanics for large transformations of solid structures.
// It is developed by Gérard Rio (APP: IDDN.FR.010.0106078.000.R.P.2006.035.20600)
// INSTITUT DE RECHERCHE DUPUY DE LÔME (IRDL) <https://www.irdl.fr/>.
//
// Herezh++ is distributed under GPL 3 license ou ultérieure.
//
// Copyright (C) 1997-2021 Université Bretagne Sud (France)
// AUTHOR : Gérard Rio
// E-MAIL : gerardrio56@free.fr
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//
// For more information, please consult: <https://herezh.irdl.fr/>.
#ifndef Algo_Integ1D_deja_inclus
#include "Algo_Integ1D.h"
#endif
// METHODES PUBLIQUES template :
// intégration d'une fonction à l'aide de la méthode de Gauss
//
// en entrée:
// *Pt_fonc : pointeur de la fonction
// tfin : temps finale
// deltat : plage d'intégration
// nbptGauss : nombre de point de Gauss
// en sortie :
// renvoie la valeur de l'intégrale de t0 à t0+deltat
template <class T>
double Algo_Integ1D::IntegGauss(const double& tfin, T& instance
,double (T::*Pt_fonc) (const double & t)
,const double& deltat)
{ double integral = 0.;
Vecteur const & wi = seg.TaWi();
int nbi = seg.Nbi();
// on intègre suivant les points de Gauss
double t0=tfin-deltat;
for (int i=1;i<=nbi;i++)
{double thetai = seg.CoorPtInteg(i)(1); // coordonnée entre -1 et 1
double t = 0.5 * ((1.-thetai)*t0 + (1.+thetai)*tfin);
integral += (instance.*Pt_fonc)(t) * wi(i);
};
// on prend en compte le jacobien
integral *= deltat * 0.5;
// retour
return integral;
}
// intégration d'une fonction à l'aide de la méthode de Gauss
// mais ici avec un intervalle fixé de -1 à 1
// en entrée:
// *Pt_fonc : pointeur de la fonction, qui est fonction d'une valeur qui
// doit varier de -1 à 1 (donc il faut faire les interpolations nécessaires)
// deltat : plage d'intégration
// en sortie :
// renvoie la valeur de l'intégrale de t0 à t0+deltat
template <class T>
double Algo_Integ1D::IntegGauss( T& instance
,double (T::*Pt_fonc) (const double & theta)
,const double& deltat)
{ double integral = 0.;
Vecteur const & wi = seg.TaWi();
int nbi = seg.Nbi();
// on intègre suivant les points de Gauss
for (int i=1;i<=nbi;i++)
{double thetai = seg.CoorPtInteg(i)(1); // coordonnée entre -1 et 1
integral += (instance.*Pt_fonc)(thetai) * wi(i);
};
// on prend en compte le jacobien
integral *= deltat * 0.5;
// retour
return integral;
}