gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
SElement.cpp
Go to the documentation of this file.
1 // Gmsh - Copyright (C) 1997-2022 C. Geuzaine, J.-F. Remacle
2 //
3 // See the LICENSE.txt file in the Gmsh root directory for license information.
4 // Please report all issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
5 
6 #include "SElement.h"
7 
8 // FIXME: this will change in the future (the base SElement should no
9 // contain anything except the MElement). More advanced solvers will
10 // derive and/or add containers for additional storage
11 
12 /*
13 class SFunctionSpace{
14 
15 }
16 
17 class SFunctionSpaceXFEM : class SFunctionSpace{
18 
19 }
20 
21 etc.
22 
23  */
24 
26  *SElement::_enrichement_t = nullptr;
27 
28 void SElement::gradNodalFunctions(double u, double v, double w,
29  double invjac[3][3], double Grads[][3],
30  simpleFunction<double> *_enrichement)
31 {
32  double grads[256][3];
33  _e->getGradShapeFunctions(u, v, w, grads);
34 
35  int nbSF = getNumNodalShapeFunctions();
36  for(int j = 0; j < nbSF; j++) {
37  Grads[j][0] = invjac[0][0] * grads[j][0] + invjac[0][1] * grads[j][1] +
38  invjac[0][2] * grads[j][2];
39  Grads[j][1] = invjac[1][0] * grads[j][0] + invjac[1][1] * grads[j][1] +
40  invjac[1][2] * grads[j][2];
41  Grads[j][2] = invjac[2][0] * grads[j][0] + invjac[2][1] * grads[j][1] +
42  invjac[2][2] * grads[j][2];
43  }
44 
45  if(_enrichement) {
46  const int N = getNumNodalShapeFunctions();
47  SPoint3 p;
48  double sf[256];
49  _e->getShapeFunctions(u, v, w, sf);
50  // FIXME : re-use sf for computing coordinates
51  _e->pnt(u, v, w, p);
52  double E = (*_enrichement)(p.x(), p.y(), p.z());
53  double dEdx, dEdy, dEdz;
54  _enrichement_s->gradient(p.x(), p.y(), p.z(), dEdx, dEdy, dEdz);
55  for(int i = 0; i < N; i++) {
56  Grads[i][0] = Grads[i][0] * E + dEdx * sf[i];
57  Grads[i][1] = Grads[i][1] * E + dEdy * sf[i];
58  Grads[i][2] = Grads[i][2] * E + dEdz * sf[i];
59  }
60  }
61 }
62 
63 void SElement::nodalFunctions(double u, double v, double w, double s[],
64  simpleFunction<double> *_enrichement)
65 {
66  _e->getShapeFunctions(u, v, w, s);
67  if(_enrichement) {
68  const int N = getNumNodalShapeFunctions();
69  SPoint3 p;
70  // FIXME : re-use s for computing coordinates
71  _e->pnt(u, v, w, p);
72  double E = (*_enrichement)(p.x(), p.y(), p.z());
73  for(int i = 0; i < N; i++) {
74  s[i] *= E;
75  }
76  }
77 }
78 
79 void SElement::gradNodalShapeFunctions(double u, double v, double w,
80  double invjac[3][3], double grads[][3])
81 {
82  gradNodalFunctions(u, v, w, invjac, grads, _enrichement_s);
83 }
84 
85 void SElement::gradNodalTestFunctions(double u, double v, double w,
86  double invjac[3][3], double grads[][3])
87 {
88  gradNodalFunctions(u, v, w, invjac, grads, _enrichement_t);
89 }
90 
91 void SElement::nodalShapeFunctions(double u, double v, double w, double s[])
92 {
93  nodalFunctions(u, v, w, s, _enrichement_s);
94 }
95 
96 void SElement::nodalTestFunctions(double u, double v, double w, double s[])
97 {
98  nodalFunctions(u, v, w, s, _enrichement_t);
99 }
100 
102 {
103  if(_e->getParent()) return _e->getParent()->getNumVertices();
104  return _e->getNumVertices();
105 }
106 
108 {
109  if(_e->getParent()) return _e->getParent()->getNumVertices();
110  return _e->getNumVertices();
111 }
SElement::_e
MElement * _e
Definition: SElement.h:21
SElement::gradNodalFunctions
void gradNodalFunctions(double u, double v, double w, double invjac[3][3], double grad[][3], simpleFunction< double > *_enrichment)
Definition: SElement.cpp:28
SElement::getNumNodalShapeFunctions
int getNumNodalShapeFunctions() const
Definition: SElement.cpp:101
simpleFunction::gradient
virtual void gradient(double x, double y, double z, scalar &dfdx, scalar &dfdy, scalar &dfdz) const
Definition: simpleFunction.h:25
SPoint3
Definition: SPoint3.h:14
MElement::getParent
virtual MElement * getParent() const
Definition: MElement.h:231
SElement::nodalTestFunctions
void nodalTestFunctions(double u, double v, double w, double s[])
Definition: SElement.cpp:96
MElement::getNumVertices
virtual std::size_t getNumVertices() const =0
SPoint3::x
double x(void) const
Definition: SPoint3.h:125
SElement::_enrichement_s
static simpleFunction< double > * _enrichement_s
Definition: SElement.h:24
simpleFunction< double >
SElement::_enrichement_t
static simpleFunction< double > * _enrichement_t
Definition: SElement.h:24
SElement.h
SElement::nodalFunctions
void nodalFunctions(double u, double v, double w, double s[], simpleFunction< double > *_enrichement)
Definition: SElement.cpp:63
SPoint3::y
double y(void) const
Definition: SPoint3.h:127
SElement::gradNodalTestFunctions
void gradNodalTestFunctions(double u, double v, double w, double invjac[3][3], double grad[][3])
Definition: SElement.cpp:85
MElement::pnt
virtual void pnt(double u, double v, double w, SPoint3 &p) const
Definition: MElement.cpp:1072
SElement::nodalShapeFunctions
void nodalShapeFunctions(double u, double v, double w, double s[])
Definition: SElement.cpp:91
MElement::getShapeFunctions
virtual void getShapeFunctions(double u, double v, double w, double s[], int order=-1) const
Definition: MElement.cpp:458
SElement::getNumNodalTestFunctions
int getNumNodalTestFunctions() const
Definition: SElement.cpp:107
SPoint3::z
double z(void) const
Definition: SPoint3.h:129
SElement::gradNodalShapeFunctions
void gradNodalShapeFunctions(double u, double v, double w, double invjac[3][3], double grad[][3])
Definition: SElement.cpp:79
MElement::getGradShapeFunctions
virtual void getGradShapeFunctions(double u, double v, double w, double s[][3], int order=-1) const
Definition: MElement.cpp:468