Select Git revision
-
Christophe Geuzaine authored
initializing the api now sets General.Terminal=1 (to print messages by default) and General.AbortOnError=2 (to throw an exception as soon as an error happens) - cf. #1043
Christophe Geuzaine authoredinitializing the api now sets General.Terminal=1 (to print messages by default) and General.AbortOnError=2 (to throw an exception as soon as an error happens) - cf. #1043
Cal_Value.cpp 81.96 KiB
// GetDP - Copyright (C) 1997-2018 P. Dular and C. Geuzaine, University of Liege
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to the public mailing list <getdp@onelab.info>.
//
// Contributor(s):
// Johan Gyselinck
//
#include <sstream>
#include <string.h>
#include <math.h>
#include "ProData.h"
#include "ProDefine.h"
#include "Cal_Value.h"
#include "Message.h"
extern struct CurrentData Current ;
#define SQU(a) ((a)*(a))
/* ------------------------------------------------------------------------ */
/* O p e r a t o r s o n V a l u e s */
/* ------------------------------------------------------------------------ */
/* Warning: the pointers V1 and R or V2 and R can be identical. You must */
/* use temporary variables in your computations: you can only */
/* affect to R at the very last time (when you're sure you will */
/* not use V1 or V2 any more). */
/* ------------------------------------------------------------------------ */
static double a0;
static double a1 [NBR_MAX_HARMONIC * MAX_DIM] ;
static double a2 [NBR_MAX_HARMONIC * MAX_DIM] ;
static double b1 [NBR_MAX_HARMONIC * MAX_DIM] ;
static double b2 [NBR_MAX_HARMONIC * MAX_DIM] ;
static double b3 [NBR_MAX_HARMONIC * MAX_DIM] ;
static double c1 [NBR_MAX_HARMONIC * MAX_DIM] ;
static double c2 [NBR_MAX_HARMONIC * MAX_DIM] ;
static double c3 [NBR_MAX_HARMONIC * MAX_DIM] ;
static double tmp[27][NBR_MAX_HARMONIC * MAX_DIM] ;
static int TENSOR_SYM_MAP[] = {0,1,2,1,3,4,2,4,5};
static int TENSOR_DIAG_MAP[] = {0,-1,-1,-1,1,-1,-1,-1,2};
void Cal_ComplexProduct(double V1[], double V2[], double P[])
{
P[0] = V1[0] * V2[0] - V1[MAX_DIM] * V2[MAX_DIM] ;
P[MAX_DIM] = V1[0] * V2[MAX_DIM] + V1[MAX_DIM] * V2[0] ;
}
void Cal_ComplexDivision(double V1[], double V2[], double P[])
{
double Mod2 ;
Mod2 = SQU(V2[0]) + SQU(V2[MAX_DIM]) ;
if(!Mod2){ Message::Error("Division by zero in 'Cal_ComplexDivision'"); return; }
P[0] = ( V1[0] * V2[0] + V1[MAX_DIM] * V2[MAX_DIM]) / Mod2 ;
P[MAX_DIM] = (- V1[0] * V2[MAX_DIM] + V1[MAX_DIM] * V2[0]) / Mod2 ;
}
void Cal_ComplexInvert(double V1[], double P[])
{
double Mod2 ;
Mod2 = SQU(V1[0]) + SQU(V1[MAX_DIM]) ;
if(!Mod2){ Message::Error("Division by zero in 'Cal_ComplexInvert'"); return; }
P[0] = V1[0] / Mod2 ;
P[MAX_DIM] = - V1[MAX_DIM] / Mod2 ;
}