File: SElement.cpp

package info (click to toggle)
gmsh 4.7.1%2Bds1-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 95,484 kB
  • sloc: cpp: 566,747; ansic: 150,384; yacc: 7,198; python: 6,130; java: 3,486; lisp: 622; lex: 621; makefile: 613; perl: 571; sh: 439; xml: 415; javascript: 113; pascal: 35; modula3: 32
file content (111 lines) | stat: -rw-r--r-- 3,345 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Gmsh - Copyright (C) 1997-2020 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// issues on https://gitlab.onelab.info/gmsh/gmsh/issues.

#include "SElement.h"

// FIXME: this will change in the future (the base SElement should no
// contain anything except the MElement). More advanced solvers will
// derive and/or add containers for additional storage

/*
class SFunctionSpace{

}

class SFunctionSpaceXFEM : class SFunctionSpace{

}

etc.

 */

simpleFunction<double> *SElement::_enrichement_s = 0,
                       *SElement::_enrichement_t = 0;

void SElement::gradNodalFunctions(double u, double v, double w,
                                  double invjac[3][3], double Grads[][3],
                                  simpleFunction<double> *_enrichement)
{
  double grads[256][3];
  _e->getGradShapeFunctions(u, v, w, grads);

  int nbSF = getNumNodalShapeFunctions();
  for(int j = 0; j < nbSF; j++) {
    Grads[j][0] = invjac[0][0] * grads[j][0] + invjac[0][1] * grads[j][1] +
                  invjac[0][2] * grads[j][2];
    Grads[j][1] = invjac[1][0] * grads[j][0] + invjac[1][1] * grads[j][1] +
                  invjac[1][2] * grads[j][2];
    Grads[j][2] = invjac[2][0] * grads[j][0] + invjac[2][1] * grads[j][1] +
                  invjac[2][2] * grads[j][2];
  }

  if(_enrichement) {
    const int N = getNumNodalShapeFunctions();
    SPoint3 p;
    double sf[256];
    _e->getShapeFunctions(u, v, w, sf);
    // FIXME : re-use sf for computing coordinates
    _e->pnt(u, v, w, p);
    double E = (*_enrichement)(p.x(), p.y(), p.z());
    double dEdx, dEdy, dEdz;
    _enrichement_s->gradient(p.x(), p.y(), p.z(), dEdx, dEdy, dEdz);
    for(int i = 0; i < N; i++) {
      Grads[i][0] = Grads[i][0] * E + dEdx * sf[i];
      Grads[i][1] = Grads[i][1] * E + dEdy * sf[i];
      Grads[i][2] = Grads[i][2] * E + dEdz * sf[i];
    }
  }
}

void SElement::nodalFunctions(double u, double v, double w, double s[],
                              simpleFunction<double> *_enrichement)
{
  _e->getShapeFunctions(u, v, w, s);
  if(_enrichement) {
    const int N = getNumNodalShapeFunctions();
    SPoint3 p;
    // FIXME : re-use s for computing coordinates
    _e->pnt(u, v, w, p);
    double E = (*_enrichement)(p.x(), p.y(), p.z());
    for(int i = 0; i < N; i++) {
      s[i] *= E;
    }
  }
}

void SElement::gradNodalShapeFunctions(double u, double v, double w,
                                       double invjac[3][3], double grads[][3])
{
  gradNodalFunctions(u, v, w, invjac, grads, _enrichement_s);
}

void SElement::gradNodalTestFunctions(double u, double v, double w,
                                      double invjac[3][3], double grads[][3])
{
  gradNodalFunctions(u, v, w, invjac, grads, _enrichement_t);
}

void SElement::nodalShapeFunctions(double u, double v, double w, double s[])
{
  nodalFunctions(u, v, w, s, _enrichement_s);
}

void SElement::nodalTestFunctions(double u, double v, double w, double s[])
{
  nodalFunctions(u, v, w, s, _enrichement_t);
}

int SElement::getNumNodalShapeFunctions() const
{
  if(_e->getParent()) return _e->getParent()->getNumVertices();
  return _e->getNumVertices();
}

int SElement::getNumNodalTestFunctions() const
{
  if(_e->getParent()) return _e->getParent()->getNumVertices();
  return _e->getNumVertices();
}