gmsh-TingyuanDoc
0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
|
Go to the documentation of this file.
6 #ifndef FUNCTION_SPACE_H
7 #define FUNCTION_SPACE_H
64 virtual int getId(
void)
const = 0;
69 const std::vector<int> &comp,
70 std::vector<Dof> &keys)
const
73 "this function is defined to get Dofs of vertex %d on element %d",
91 virtual void f(
MElement *ele,
double u,
double v,
double w,
92 std::vector<ValType> &vals)
const = 0;
94 std::vector<ValType> &vals)
const
98 std::vector<GradType> &grads)
const = 0;
100 std::vector<GradType> &grads)
const
104 std::vector<HessType> &hess)
const = 0;
106 std::vector<HessType> &hess)
const
110 MElement *ele,
double u,
double v,
double w,
111 std::vector<ThirdDevType> &third)
const {};
113 MElement *ele,
double u,
double v,
double w,
114 std::vector<ThirdDevType> &third)
const {};
135 virtual void f(
MElement *ele,
double u,
double v,
double w,
136 std::vector<ValType> &vals)
const
146 int curpos = vals.size();
147 vals.resize(curpos + ndofs);
152 std::vector<GradType> &grads)
const
162 grads.reserve(grads.size() + ndofs);
163 double gradsuvw[256][3];
170 for(
int i = 0; i < ndofs; ++i)
172 GradType(invjac[0][0] * gradsuvw[i][0] + invjac[0][1] * gradsuvw[i][1] +
173 invjac[0][2] * gradsuvw[i][2],
174 invjac[1][0] * gradsuvw[i][0] + invjac[1][1] * gradsuvw[i][1] +
175 invjac[1][2] * gradsuvw[i][2],
176 invjac[2][0] * gradsuvw[i][0] + invjac[2][1] * gradsuvw[i][1] +
177 invjac[2][2] * gradsuvw[i][2]));
182 std::vector<HessType> &hess)
const
192 hess.reserve(hess.size() + ndofs);
194 double hessuvw[256][3][3];
197 for(
int i = 0; i < ndofs; ++i) {
198 hesst(0, 0) = hessuvw[i][0][0];
199 hesst(0, 1) = hessuvw[i][0][1];
200 hesst(0, 2) = hessuvw[i][0][2];
201 hesst(1, 0) = hessuvw[i][1][0];
202 hesst(1, 1) = hessuvw[i][1][1];
203 hesst(1, 2) = hessuvw[i][1][2];
204 hesst(2, 0) = hessuvw[i][2][0];
205 hesst(2, 1) = hessuvw[i][2][1];
206 hesst(2, 2) = hessuvw[i][2][2];
207 hess.push_back(hesst);
211 std::vector<GradType> &grads)
const
221 grads.reserve(grads.size() + ndofs);
222 double gradsuvw[256][3];
224 for(
int i = 0; i < ndofs; ++i)
225 grads.push_back(
GradType(gradsuvw[i][0], gradsuvw[i][1], gradsuvw[i][2]));
232 std::vector<Dof> &keys)
const
234 int ndofs = ele->getNumShapeFunctions();
235 keys.reserve(keys.size() + ndofs);
236 for(
int i = 0; i < ndofs; ++i)
getKeys(ele->getShapeFunctionNode(i), keys);
254 virtual void f(
MElement *ele,
double u,
double v,
double w,
255 std::vector<ValType> &vals)
const
259 int curpos = vals.size();
260 vals.resize(curpos + ndofs);
265 std::vector<GradType> &grads)
const
269 grads.reserve(grads.size() + ndofs);
270 double gradsuvw[256][3];
277 for(
int i = 0; i < ndofs; ++i)
279 GradType(invjac[0][0] * gradsuvw[i][0] + invjac[0][1] * gradsuvw[i][1] +
280 invjac[0][2] * gradsuvw[i][2],
281 invjac[1][0] * gradsuvw[i][0] + invjac[1][1] * gradsuvw[i][1] +
282 invjac[1][2] * gradsuvw[i][2],
283 invjac[2][0] * gradsuvw[i][0] + invjac[2][1] * gradsuvw[i][1] +
284 invjac[2][2] * gradsuvw[i][2]));
289 std::vector<HessType> &hess)
const
293 hess.reserve(hess.size() + ndofs);
295 double hessuvw[256][3][3];
298 for(
int i = 0; i < ndofs; ++i) {
299 hesst(0, 0) = hessuvw[i][0][0];
300 hesst(0, 1) = hessuvw[i][0][1];
301 hesst(0, 2) = hessuvw[i][0][2];
302 hesst(1, 0) = hessuvw[i][1][0];
303 hesst(1, 1) = hessuvw[i][1][1];
304 hesst(1, 2) = hessuvw[i][1][2];
305 hesst(2, 0) = hessuvw[i][2][0];
306 hesst(2, 1) = hessuvw[i][2][1];
307 hesst(2, 2) = hessuvw[i][2][2];
308 hess.push_back(hesst);
312 std::vector<GradType> &grads)
const
316 grads.reserve(grads.size() + ndofs);
317 double gradsuvw[256][3];
319 for(
int i = 0; i < ndofs; ++i)
320 grads.push_back(
GradType(gradsuvw[i][0], gradsuvw[i][1], gradsuvw[i][2]));
323 std::vector<ValType> &vals)
const
327 vals.reserve(vals.size() + ndofs);
328 double valsuvw[1256];
330 for(
int i = 0; i < ndofs; ++i) vals.push_back(valsuvw[i]);
338 std::vector<Dof> &keys)
const
340 if(ele->getParent()) ele = ele->getParent();
341 int ndofs = ele->getNumShapeFunctions();
342 keys.reserve(keys.size() + ndofs);
343 for(
int i = 0; i < ndofs; ++i)
getKeys(ele->getShapeFunctionNode(i), keys);
364 comp.push_back(comp_);
369 const T &mult2,
int comp2_)
374 comp.push_back(comp1_);
375 comp.push_back(comp2_);
380 const T &mult2,
int comp2_,
const T &mult3,
387 comp.push_back(comp1_);
388 comp.push_back(comp2_);
389 comp.push_back(comp3_);
394 virtual void f(
MElement *ele,
double u,
double v,
double w,
395 std::vector<ValType> &vals)
const
397 std::vector<double> valsd;
399 int nbdofs = valsd.size();
400 int nbcomp =
comp.size();
401 int curpos = vals.size();
402 vals.reserve(curpos + nbcomp * nbdofs);
403 for(
int j = 0; j < nbcomp; ++j) {
404 for(
int i = 0; i < nbdofs; ++i) vals.push_back(
multipliers[j] * valsd[i]);
409 std::vector<GradType> &grads)
const
411 std::vector<SVector3> gradsd;
413 int nbdofs = gradsd.size();
414 int nbcomp =
comp.size();
415 int curpos = grads.size();
416 grads.reserve(curpos + nbcomp * nbdofs);
418 for(
int j = 0; j < nbcomp; ++j) {
419 for(
int i = 0; i < nbdofs; ++i) {
421 grads.push_back(val);
426 std::vector<HessType> &hess)
const
431 std::vector<GradType> &grads)
const
433 std::vector<SVector3> gradsd;
435 int nbdofs = gradsd.size();
436 int nbcomp =
comp.size();
437 int curpos = grads.size();
438 grads.reserve(curpos + nbcomp * nbdofs);
440 for(
int j = 0; j < nbcomp; ++j) {
441 for(
int i = 0; i < nbdofs; ++i) {
443 grads.push_back(val);
456 std::vector<Dof> bufk;
459 int nbdofs = bufk.size();
460 int nbcomp =
comp.size();
461 int curpos = keys.size();
462 keys.reserve(curpos + nbcomp * nbdofs);
463 for(
int j = 0; j < nbcomp; ++j) {
464 for(
int i = 0; i < nk; ++i) {
548 typedef typename std::vector<FunctionSpace<T> *>::iterator
iterFS;
558 template <
class T1,
class T2>
564 template <
class T1,
class T2,
class T3>
571 template <
class T1,
class T2,
class T3,
class T4>
579 template <
class T1>
void insert(
const T1 &t) {
_spaces.push_back(
new T(t)); }
584 virtual void f(
MElement *ele,
double u,
double v,
double w,
585 std::vector<ValType> &vals)
const
588 (*it)->f(ele, u, v, w, vals);
592 std::vector<GradType> &grads)
const
595 (*it)->gradf(ele, u, v, w, grads);
599 std::vector<HessType> &hess)
const
602 (*it)->hessfuvw(ele, u, v, w, hess);
609 ndofs += (*it)->getNumKeys(ele);
616 (*it)->getKeys(ele, keys);
632 std::vector<HessType> &hess)
const
640 virtual void f(
MElement *ele,
double u,
double v,
double w,
641 std::vector<ValType> &vals)
const;
642 virtual void gradf(
MElement *ele,
double u,
double v,
double w,
643 std::vector<GradType> &grads)
const;
648 template <
class T,
class F>
661 std::vector<HessType> &hess)
const
668 virtual void f(
MElement *ele,
double u,
double v,
double w,
669 std::vector<ValType> &vals)
const;
670 virtual void gradf(
MElement *ele,
double u,
double v,
double w,
671 std::vector<GradType> &grads)
const;
678 std::vector<ValType> &vals)
const
688 std::vector<ValType> valsd;
691 int nbdofs = valsd.size();
692 int curpos = vals.size();
693 vals.reserve(curpos + nbdofs);
699 elep->
pnt(u, v, w, p);
701 _funcEnrichment->setElement(elep);
702 func = (*_funcEnrichment)(p.
x(), p.
y(), p.
z());
703 for(
int i = 0; i < nbdofs; i++) {
704 vals.push_back(valsd[i] * func);
711 std::vector<GradType> &grads)
const
721 std::vector<GradType> gradsd;
724 int nbdofs = gradsd.size();
727 std::vector<ValType> valsd;
730 int curpos = grads.size();
731 grads.reserve(curpos + nbdofs);
737 elep->
pnt(u, v, w, p);
738 _funcEnrichment->setElement(elep);
739 _funcEnrichment->gradient(p.
x(), p.
y(), p.
z(),
df[0],
df[1],
df[2]);
744 _funcEnrichment->setElement(elep);
745 func = (*_funcEnrichment)(p.
x(), p.
y(), p.
z());
747 for(
int i = 0; i < nbdofs; i++) {
749 tensprod(valsd[i], gradfuncenrich, GradFunc);
750 grads.push_back(gradsd[i] * func + GradFunc);
777 std::vector<Dof> bufk;
778 bufk.reserve(normalk);
780 int normaldofs = bufk.size();
781 int nbdofs = normaldofs;
783 int curpos = keys.size();
784 keys.reserve(curpos + nbdofs);
788 for(
int i = 0; i < nbdofs; i++) {
799 template <
class T,
class F>
801 std::vector<ValType> &vals)
const
810 std::vector<ValType> valsd;
812 _spacebase->f(elep, u, v, w, valsd);
814 int normalk = _spacebase->getNumKeys(elep);
815 std::vector<Dof> bufk;
816 bufk.reserve(normalk);
817 _spacebase->getKeys(elep, bufk);
819 for(
int i = 0; i < bufk.size(); i++) {
820 if((*_filter)(bufk[i])) vals.push_back(valsd[i]);
824 template <
class T,
class F>
827 std::vector<GradType> &grads)
const
837 std::vector<GradType> gradsd;
838 _spacebase->gradf(elep, u, v, w, gradsd);
841 int normalk = _spacebase->getNumKeys(elep);
842 std::vector<Dof> bufk;
843 bufk.reserve(normalk);
844 _spacebase->getKeys(elep, bufk);
846 for(
int i = 0; i < bufk.size(); i++) {
847 if((*_filter)(bufk[i])) grads.push_back(gradsd[i]);
851 template <
class T,
class F>
862 int normalk = _spacebase->getNumKeys(elep);
863 std::vector<Dof> bufk;
864 bufk.reserve(normalk);
865 _spacebase->getKeys(elep, bufk);
867 for(
int i = 0; i < bufk.size(); i++) {
868 if((*_filter)(bufk[i])) nbdofs = nbdofs + 1;
873 template <
class T,
class F>
875 std::vector<Dof> &keys)
const
883 int normalk = _spacebase->getNumKeys(elep);
885 std::vector<Dof> bufk;
886 bufk.reserve(normalk);
887 _spacebase->getKeys(elep, bufk);
889 for(
int i = 0; i < bufk.size(); i++) {
890 if((*_filter)(bufk[i])) keys.push_back(bufk[i]);
virtual std::size_t getNum() const
virtual void gradfuvw(MElement *ele, double u, double v, double w, std::vector< GradType > &grads) const
TensorialTraits< double >::GradType GradType
virtual void getKeys(MElement *ele, std::vector< Dof > &keys) const
virtual void getKeys(MVertex *ver, std::vector< Dof > &keys) const
CompositeFunctionSpace(const T1 &t)
TensorialTraits< T >::ThirdDevType ThirdDevType
virtual void gradf(MElement *ele, double u, double v, double w, std::vector< GradType > &grads) const
TensorialTraits< T >::HessType HessType
double inv3x3(double mat[3][3], double inv[3][3])
virtual void gradf(MElement *ele, double u, double v, double w, std::vector< GradType > &grads) const
TensorialTraits< double >::HessType HessType
virtual void hessf(MElement *ele, double u, double v, double w, std::vector< HessType > &hess) const
virtual void gradf(MElement *ele, double u, double v, double w, std::vector< GradType > &grads) const
FunctionSpace< T > * _spacebase
virtual int getTypeForMSH() const
TensorialTraits< T >::HessType HessType
TensorialTraits< T >::HessType HessType
virtual int getId(void) const
xFemFunctionSpace(FunctionSpace< T > *spacebase, simpleFunctionOnElement< double > *funcEnrichment)
static void Warning(const char *fmt,...)
CompositeFunctionSpace(const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4)
static void getTwoIntsFromType(int t, int &i1, int &i2)
TensorialTraits< double >::GradType GradType
void tensprod(const SVector3 &a, const SVector3 &b, STensor3 &c)
virtual MElement * getParent() const
std::size_t getNum() const
TensorialTraits< T >::HessType HessType
std::vector< FunctionSpace< T > * >::iterator iterFS
TensorialTraits< T >::ValType ValType
TensorialTraits< T >::GradType GradType
ScalarToAnyFunctionSpace(const T2 &SFS, const T &mult1, int comp1_, const T &mult2, int comp2_)
virtual void hessfuvw(MElement *ele, double u, double v, double w, std::vector< HessType > &hess) const
TensorialTraits< double >::HessType HessType
virtual void hessfuvw(MElement *ele, double u, double v, double w, std::vector< HessType > &hess) const
virtual FunctionSpaceBase * clone(const int id) const
virtual void getHessShapeFunctions(double u, double v, double w, double s[][3][3], int order=-1) const
~CompositeFunctionSpace(void)
virtual void hessfuvw(MElement *ele, double u, double v, double w, std::vector< HessType > &hess) const
FunctionSpace< double > * ScalarFS
virtual void fuvw(MElement *ele, double u, double v, double w, std::vector< ValType > &vals) const
virtual int getNumKeys(MElement *ele) const
virtual void f(MElement *ele, double u, double v, double w, std::vector< ValType > &vals) const
ScalarToAnyFunctionSpace(const T2 &SFS, const T &mult1, int comp1_, const T &mult2, int comp2_, const T &mult3, int comp3_)
TensorialTraits< SVector3 >::GradType GradType
virtual void f(MElement *ele, double u, double v, double w, std::vector< ValType > &vals) const
virtual void gradfuvw(MElement *ele, double u, double v, double w, std::vector< GradType > &grads) const
virtual void f(MElement *ele, double u, double v, double w, std::vector< ValType > &vals) const
virtual void hessfuvw(MElement *ele, double u, double v, double w, std::vector< HessType > &hess) const
virtual void gradfuvw(MElement *ele, double u, double v, double w, std::vector< GradType > &grads) const
VectorLagrangeFunctionSpace(int id, Along comp1)
TensorialTraits< double >::ValType ValType
static int createTypeWithTwoInts(int i1, int i2)
int getType(int parentType, int order, bool serendip=false)
virtual int getNumKeys(MElement *ele) const
virtual int getId(void) const =0
virtual void fuvw(MElement *ele, double u, double v, double w, std::vector< ValType > &vals) const
static const SVector3 BasisVectors[3]
virtual int getNumKeys(MElement *ele) const =0
virtual void getKeys(MElement *ele, std::vector< Dof > &keys) const
TensorialTraits< double >::ValType ValType
virtual std::size_t getNumShapeFunctions() const
virtual void getKeys(MElement *ele, std::vector< Dof > &keys) const
virtual void hessfuvw(MElement *ele, double u, double v, double w, std::vector< HessType > &hess) const
static const SVector3 BasisVectors[3]
virtual void f(MElement *ele, double u, double v, double w, std::vector< ValType > &vals) const =0
virtual int getNumKeys(MElement *ele) const
virtual void thirdDevf(MElement *ele, double u, double v, double w, std::vector< ThirdDevType > &third) const
Quaternion mult(const Quaternion &A, const Quaternion &B)
FunctionSpace< T > * _spacebase
VectorLagrangeFunctionSpaceOfElement(int id)
virtual void hessfuvw(MElement *ele, double u, double v, double w, std::vector< HessType > &hess) const =0
std::vector< FunctionSpace< T > * > _spaces
CompositeFunctionSpace(const T1 &t1, const T2 &t2, const T3 &t3)
ScalarToAnyFunctionSpace(const T2 &SFS, const T &mult, int comp_)
virtual void getKeys(MElement *ele, std::vector< Dof > &keys) const
TensorialTraits< T >::GradType GradType
virtual void gradfuvw(MElement *ele, double u, double v, double w, std::vector< GradType > &grads) const
virtual void getKeys(MElement *ele, std::vector< Dof > &keys) const =0
virtual void hessfuvw(MElement *ele, double u, double v, double w, std::vector< HessType > &hess) const
virtual void pnt(double u, double v, double w, SPoint3 &p) const
void df(int n, double u, double *val)
virtual void getKeys(MElement *ele, std::vector< Dof > &keys) const
VectorLagrangeFunctionSpace(int id, Along comp1, Along comp2)
ScalarLagrangeFunctionSpaceOfElement(int i=0)
virtual void f(MElement *ele, double u, double v, double w, std::vector< ValType > &vals) const
virtual void gradf(MElement *ele, double u, double v, double w, std::vector< GradType > &grads) const
virtual void gradf(MElement *ele, double u, double v, double w, std::vector< GradType > &grads) const
virtual void movePointFromParentSpaceToElementSpace(double &u, double &v, double &w) const
virtual ~ScalarToAnyFunctionSpace()
TensorialTraits< SVector3 >::ValType ValType
virtual int getNumKeys(MElement *ele) const
ScalarLagrangeFunctionSpace(int i=0)
virtual void f(MElement *ele, double u, double v, double w, std::vector< ValType > &vals) const
TensorialTraits< T >::ValType ValType
TensorialTraits< T >::GradType GradType
virtual void f(MElement *ele, double u, double v, double w, std::vector< ValType > &vals) const
TensorialTraits< T >::ValType ValType
VectorLagrangeFunctionSpaceOfElement(int id, Along comp1)
virtual void getShapeFunctions(double u, double v, double w, double s[], int order=-1) const
virtual int getNumKeys(MElement *ele) const
virtual void getKeysOnVertex(MElement *ele, MVertex *v, const std::vector< int > &comp, std::vector< Dof > &keys) const
virtual void getKeys(MElement *ele, std::vector< Dof > &keys) const =0
virtual double getJacobian(const fullMatrix< double > &gsf, double jac[3][3]) const
VectorLagrangeFunctionSpaceOfElement(int id, Along comp1, Along comp2)
virtual void thirdDevfuvw(MElement *ele, double u, double v, double w, std::vector< ThirdDevType > &third) const
TensorialTraits< SVector3 >::GradType GradType
TensorialTraits< T >::HessType HessType
virtual int getNumKeys(MElement *ele) const =0
TensorialTraits< T >::ValType ValType
virtual void getKeys(MElement *ele, std::vector< Dof > &keys) const
simpleFunctionOnElement< double > * _funcEnrichment
virtual ~FunctionSpaceBase()
virtual void gradf(MElement *ele, double u, double v, double w, std::vector< GradType > &grads) const
virtual void gradf(MElement *ele, double u, double v, double w, std::vector< GradType > &grads) const =0
virtual int getNumKeys(MElement *ele) const
CompositeFunctionSpace(const T1 &t1, const T2 &t2)
VectorLagrangeFunctionSpace(int id, Along comp1, Along comp2, Along comp3)
TensorialTraits< SVector3 >::ValType ValType
TensorialTraits< T >::ValType ValType
virtual void getKeys(MVertex *ver, std::vector< Dof > &keys) const
TensorialTraits< T >::GradType GradType
VectorLagrangeFunctionSpaceOfElement(int id, Along comp1, Along comp2, Along comp3)
virtual void getGradShapeFunctions(double u, double v, double w, double s[][3], int order=-1) const
std::vector< T > multipliers
VectorLagrangeFunctionSpace(int id)
TensorialTraits< T >::GradType GradType