Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
tensor.c File Reference
#include "moab/FindPtFuncs.h"
+ Include dependency graph for tensor.c:

Go to the source code of this file.

Functions

static void mxm_cc (const realType *A, unsigned na, const realType *B, unsigned nb, realType *C, unsigned nc)
 
static void mxm_rc (const realType *A, unsigned na, const realType *B, unsigned nb, realType *C, unsigned nc)
 
static void mxm_cr (const realType *A, unsigned na, const realType *B, unsigned nb, realType *C, unsigned nc)
 
static void mxv_c (realType *y, unsigned ny, const realType *A, const realType *x, unsigned nx)
 
static void mxv_r (realType *y, unsigned ny, const realType *A, const realType *x, unsigned nx)
 
static realType inner (const realType *u, const realType *v, unsigned n)
 
void tensor_c1 (const realType *R, unsigned mr, unsigned nr, const realType *u, realType *v)
 
void tensor_r1 (const realType *R, unsigned mr, unsigned nr, const realType *u, realType *v)
 
void tensor_c2 (const realType *R, unsigned mr, unsigned nr, const realType *S, unsigned ms, unsigned ns, const realType *u, realType *v, realType *W)
 
void tensor_r2 (const realType *R, unsigned mr, unsigned nr, const realType *S, unsigned ms, unsigned ns, const realType *u, realType *v, realType *W)
 
void tensor_c3 (const realType *R, unsigned mr, unsigned nr, const realType *S, unsigned ms, unsigned ns, const realType *T, unsigned mt, unsigned nt, const realType *u, realType *v, realType *W, realType *Z)
 
void tensor_r3 (const realType *R, unsigned mr, unsigned nr, const realType *S, unsigned ms, unsigned ns, const realType *T, unsigned mt, unsigned nt, const realType *u, realType *v, realType *W, realType *Z)
 
realType tensor_i1 (const realType *Jr, unsigned nr, const realType *u)
 
realType tensor_i2 (const realType *Jr, unsigned nr, const realType *Js, unsigned ns, const realType *u, realType *work)
 
realType tensor_i3 (const realType *Jr, unsigned nr, const realType *Js, unsigned ns, const realType *Jt, unsigned nt, const realType *u, realType *work)
 
realType tensor_ig1 (const realType *Jr, const realType *Dr, unsigned nr, const realType *u, realType *g)
 
realType tensor_ig2 (const realType *Jr, const realType *Dr, unsigned nr, const realType *Js, const realType *Ds, unsigned ns, const realType *u, realType *g, realType *work)
 
realType tensor_ig3 (const realType *Jr, const realType *Dr, unsigned nr, const realType *Js, const realType *Ds, unsigned ns, const realType *Jt, const realType *Dt, unsigned nt, const realType *u, realType *g, realType *work)
 

Function Documentation

◆ inner()

static realType inner ( const realType u,
const realType v,
unsigned  n 
)
static

Definition at line 132 of file tensor.c.

133 {
134  const realType* u_end = u + n;
135  realType sum = *u++ * *v++;
136  while( u != u_end )
137  {
138  sum += *u++ * *v++;
139  }
140  return sum;
141 }

References moab::sum().

Referenced by run_quality_optimizer(), tensor_i1(), tensor_i2(), tensor_i3(), tensor_ig1(), tensor_ig2(), and tensor_ig3().

◆ mxm_cc()

static void mxm_cc ( const realType A,
unsigned  na,
const realType B,
unsigned  nb,
realType C,
unsigned  nc 
)
static

Definition at line 13 of file tensor.c.

14 {
15  unsigned i, j, k;
16  realType* Ccol = C;
17  const realType* Bcol = B;
18  for( j = 0; j < nc; ++j, Ccol += na, Bcol += nb )
19  {
20  const realType* Acol = A;
21  for( i = 0; i < na; ++i )
22  Ccol[i] = 0;
23  for( k = 0; k < nb; ++k, Acol += na )
24  for( i = 0; i < na; ++i )
25  Ccol[i] += Acol[i] * Bcol[k];
26  }
27 }

Referenced by tensor_c2(), tensor_c3(), tensor_r2(), and tensor_r3().

◆ mxm_cr()

static void mxm_cr ( const realType A,
unsigned  na,
const realType B,
unsigned  nb,
realType C,
unsigned  nc 
)
static

Definition at line 46 of file tensor.c.

47 {
48  unsigned i, j, k;
49  const realType *Acol = A, *Brow = B;
50  for( i = 0; i < na * nc; ++i )
51  C[i] = 0;
52  for( k = 0; k < nb; ++k, Acol += na, Brow += nc )
53  {
54  realType* Ccol = C;
55  for( j = 0; j < nc; ++j, Ccol += na )
56  for( i = 0; i < na; ++i )
57  Ccol[i] += Acol[i] * Brow[j];
58  }
59 }

Referenced by tensor_c2(), and tensor_c3().

◆ mxm_rc()

static void mxm_rc ( const realType A,
unsigned  na,
const realType B,
unsigned  nb,
realType C,
unsigned  nc 
)
static

Definition at line 29 of file tensor.c.

30 {
31  unsigned i, j, k;
32  realType* Ccol = C;
33  const realType* Bcol = B;
34  for( j = 0; j < nc; ++j, Ccol += na, Bcol += nb )
35  {
36  const realType* Arow = A;
37  for( i = 0; i < na; ++i, Arow += nb )
38  {
39  Ccol[i] = 0;
40  for( k = 0; k < nb; ++k )
41  Ccol[i] += Arow[k] * Bcol[k];
42  }
43  }
44 }

Referenced by tensor_r2(), and tensor_r3().

◆ mxv_c()

static void mxv_c ( realType y,
unsigned  ny,
const realType A,
const realType x,
unsigned  nx 
)
static

Definition at line 89 of file tensor.c.

90 {
91  realType *yp = y, *y_end = y + ny;
92  const realType* x_end = x + nx;
93  realType xk = *x;
94  do
95  {
96  *yp++ = *A++ * xk;
97  } while( yp != y_end );
98  for( ++x; x != x_end; ++x )
99  {
100  xk = *x;
101  yp = y;
102  do
103  {
104  *yp++ += *A++ * xk;
105  } while( yp != y_end );
106  }
107 }

Referenced by tensor_c1().

◆ mxv_r()

static void mxv_r ( realType y,
unsigned  ny,
const realType A,
const realType x,
unsigned  nx 
)
static

Definition at line 109 of file tensor.c.

110 {
111  realType* y_end = y + ny;
112  const realType* x_end = x + nx;
113  do
114  {
115  const realType* xp = x;
116  realType sum = *A++ * *xp++;
117  while( xp != x_end )
118  {
119  sum += *A++ * *xp++;
120  }
121  *y++ = sum;
122  } while( y != y_end );
123 }

References moab::sum().

Referenced by tensor_i2(), tensor_i3(), tensor_ig2(), tensor_ig3(), and tensor_r1().

◆ tensor_c1()

void tensor_c1 ( const realType R,
unsigned  mr,
unsigned  nr,
const realType u,
realType v 
)

Definition at line 155 of file tensor.c.

156 {
157  mxv_c( v, mr, R, u, nr );
158 }

References mxv_c(), nr, and moab::R.

◆ tensor_c2()

void tensor_c2 ( const realType R,
unsigned  mr,
unsigned  nr,
const realType S,
unsigned  ms,
unsigned  ns,
const realType u,
realType v,
realType W 
)

Definition at line 166 of file tensor.c.

175 {
176  mxm_cc( R, mr, u, nr, W, ns );
177  mxm_cr( W, mr, S, ns, v, ms );
178 }

References mxm_cc(), mxm_cr(), nr, and moab::R.

◆ tensor_c3()

void tensor_c3 ( const realType R,
unsigned  mr,
unsigned  nr,
const realType S,
unsigned  ms,
unsigned  ns,
const realType T,
unsigned  mt,
unsigned  nt,
const realType u,
realType v,
realType W,
realType Z 
)

Definition at line 197 of file tensor.c.

210 {
211  unsigned n, mrns = mr * ns, mrms = mr * ms;
212  realType* Zp = Z;
213  mxm_cc( R, mr, u, nr, W, ns * nt );
214  for( n = 0; n < nt; ++n, W += mrns, Zp += mrms )
215  mxm_cr( W, mr, S, ns, Zp, ms );
216  mxm_cr( Z, mrms, T, nt, v, mt );
217 }

References mxm_cc(), mxm_cr(), nr, and moab::R.

◆ tensor_i1()

realType tensor_i1 ( const realType Jr,
unsigned  nr,
const realType u 
)

Definition at line 255 of file tensor.c.

256 {
257  return inner( Jr, u, nr );
258 }

References inner(), and nr.

Referenced by opt_edge_hess_2(), opt_edge_hess_3(), opt_edge_intp_2(), and opt_edge_intp_3().

◆ tensor_i2()

realType tensor_i2 ( const realType Jr,
unsigned  nr,
const realType Js,
unsigned  ns,
const realType u,
realType work 
)

Definition at line 261 of file tensor.c.

267 {
268  mxv_r( work, ns, u, Jr, nr );
269  return inner( Js, work, ns );
270 }

References inner(), mxv_r(), and nr.

Referenced by moab::SpectralQuad::evalFcn(), moab::Element::SpectralQuad::evaluate(), moab::Element::SpectralQuad::evaluate_scalar_field(), findpt_eval_2(), opt_face_hess_3(), and opt_face_intp_3().

◆ tensor_i3()

realType tensor_i3 ( const realType Jr,
unsigned  nr,
const realType Js,
unsigned  ns,
const realType Jt,
unsigned  nt,
const realType u,
realType work 
)

Definition at line 273 of file tensor.c.

281 {
282  realType* work2 = work + nt;
283  mxv_r( work2, ns * nt, u, Jr, nr );
284  mxv_r( work, nt, work2, Js, ns );
285  return inner( Jt, work, nt );
286 }

References inner(), mxv_r(), and nr.

Referenced by moab::Element::SpectralHex::evaluate(), moab::element_utility::Spectral_hex_map< _Matrix >::evaluate(), moab::Element::SpectralHex::evaluate_scalar_field(), moab::element_utility::Spectral_hex_map< _Matrix >::evaluate_scalar_field(), findpt_eval_3(), and moab::ElemUtil::hex_eval().

◆ tensor_ig1()

realType tensor_ig1 ( const realType Jr,
const realType Dr,
unsigned  nr,
const realType u,
realType g 
)

Definition at line 304 of file tensor.c.

305 {
306  *g = inner( Dr, u, nr );
307  return inner( Jr, u, nr );
308 }

References inner(), and nr.

Referenced by opt_edge_intp_2(), and opt_edge_intp_3().

◆ tensor_ig2()

realType tensor_ig2 ( const realType Jr,
const realType Dr,
unsigned  nr,
const realType Js,
const realType Ds,
unsigned  ns,
const realType u,
realType g,
realType work 
)

Definition at line 311 of file tensor.c.

320 {
321  realType *a = work, *ar = a + ns;
322  mxv_r( a, ns, u, Jr, nr );
323  mxv_r( ar, ns, u, Dr, nr );
324  g[0] = inner( Js, ar, ns );
325  g[1] = inner( Ds, a, ns );
326  return inner( Js, a, ns );
327 }

References inner(), mxv_r(), and nr.

Referenced by obbox_calc_2(), opt_area_intp_2(), opt_face_hess_3(), and opt_face_intp_3().

◆ tensor_ig3()

realType tensor_ig3 ( const realType Jr,
const realType Dr,
unsigned  nr,
const realType Js,
const realType Ds,
unsigned  ns,
const realType Jt,
const realType Dt,
unsigned  nt,
const realType u,
realType g,
realType work 
)

Definition at line 330 of file tensor.c.

342 {
343  unsigned nsnt = ns * nt;
344  realType *a = work, *ar = a + nsnt, *b = ar + nsnt, *br = b + ns, *bs = br + ns;
345  mxv_r( a, nsnt, u, Jr, nr );
346  mxv_r( ar, nsnt, u, Dr, nr );
347  mxv_r( b, nt, a, Js, ns );
348  mxv_r( br, nt, ar, Js, ns );
349  mxv_r( bs, nt, a, Ds, ns );
350  g[0] = inner( Jt, br, nt );
351  g[1] = inner( Jt, bs, nt );
352  g[2] = inner( Dt, b, nt );
353  return inner( Jt, b, nt );
354 }

References inner(), mxv_r(), and nr.

Referenced by obbox_calc_3(), and opt_vol_intp_3().

◆ tensor_r1()

void tensor_r1 ( const realType R,
unsigned  mr,
unsigned  nr,
const realType u,
realType v 
)

Definition at line 160 of file tensor.c.

161 {
162  mxv_r( v, mr, R, u, nr );
163 }

References mxv_r(), nr, and moab::R.

◆ tensor_r2()

void tensor_r2 ( const realType R,
unsigned  mr,
unsigned  nr,
const realType S,
unsigned  ms,
unsigned  ns,
const realType u,
realType v,
realType W 
)

Definition at line 181 of file tensor.c.

190 {
191  mxm_rc( R, mr, u, nr, W, ns );
192  mxm_cc( W, mr, S, ns, v, ms );
193 }

References mxm_cc(), mxm_rc(), nr, and moab::R.

◆ tensor_r3()

void tensor_r3 ( const realType R,
unsigned  mr,
unsigned  nr,
const realType S,
unsigned  ms,
unsigned  ns,
const realType T,
unsigned  mt,
unsigned  nt,
const realType u,
realType v,
realType W,
realType Z 
)

Definition at line 221 of file tensor.c.

234 {
235  unsigned n, mrns = mr * ns, mrms = mr * ms;
236  realType* Zp = Z;
237  mxm_rc( R, mr, u, nr, W, ns * nt );
238  for( n = 0; n < nt; ++n, W += mrns, Zp += mrms )
239  mxm_cc( W, mr, S, ns, Zp, ms );
240  mxm_cc( Z, mrms, T, nt, v, mt );
241 }

References mxm_cc(), mxm_rc(), nr, and moab::R.