gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
elasticitySolver.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 <string.h>
7 #include "GmshConfig.h"
8 #include "elasticitySolver.h"
9 #include "linearSystemCSR.h"
10 #include "linearSystemPETSc.h"
11 #include "linearSystemFull.h"
12 #include "Numeric.h"
13 #include "GModel.h"
14 #include "OS.h"
15 #include "functionSpace.h"
16 #include "terms.h"
17 #include "solverAlgorithms.h"
18 #include "quadratureRules.h"
19 #include "solverField.h"
20 #include "MPoint.h"
21 #include "gmshLevelset.h"
22 
23 #if defined(HAVE_POST)
24 #include "PView.h"
25 #include "PViewData.h"
26 #endif
27 
28 /*
29 static void printLinearSystem(linearSystem<double> *lsys, int size)
30 {
31  if(!lsys->isAllocated()){printf("Linear system not allocated\n"); return;}
32  double valeur;
33  printf("K\n");
34  for (int i = 0; i < size; i++){
35  for (int j = 0; j < size; j++ ){
36  lsys->getFromMatrix (i, j, valeur);
37  printf ("%g ", valeur) ;
38  }
39  printf("\n");
40  }
41  printf("b\n");
42  for (int i = 0; i < size; i++){
43  lsys->getFromRightHandSide(i, valeur);
44  printf("%g\n", valeur);
45  }
46  printf("x\n");
47  for (int i = 0; i < size; i++){
48  lsys->getFromSolution(i, valeur);
49  printf("%g\n", valeur);
50  }
51 }
52 */
53 
55 {
56  pModel = model;
57  _dim = pModel->getNumRegions() ? 3 : 2;
58  _tag = tag;
59  pAssembler = nullptr;
61  if(_dim == 2)
65 }
66 
67 void elasticitySolver::setMesh(const std::string &meshFileName, int dim)
68 {
69  pModel = new GModel();
70  pModel->readMSH(meshFileName.c_str());
71  _dim = pModel->getNumRegions() ? 3 : 2;
72 
73  if(LagSpace) delete LagSpace;
74  if(dim == 3 || _dim == 3)
76  else if(dim == 2 || _dim == 2)
80 
81  for(std::size_t i = 0; i < LagrangeMultiplierSpaces.size(); i++)
84 }
85 
87 {
88  std::string sysname = "A";
89  if(!pAssembler || !pAssembler->getLinearSystem(sysname) ||
91  return;
92  double valeur;
93  FILE *f = Fopen("K.txt", "w");
94  if(f) {
95  for(int i = 0; i < pAssembler->sizeOfR(); i++) {
96  for(int j = 0; j < pAssembler->sizeOfR(); j++) {
97  pAssembler->getLinearSystem(sysname)->getFromMatrix(i, j, valeur);
98  fprintf(f, "%+e ", valeur);
99  }
100  fprintf(f, "\n");
101  }
102  fclose(f);
103  }
104  f = Fopen("b.txt", "w");
105  if(f) {
106  for(int i = 0; i < pAssembler->sizeOfR(); i++) {
107  pAssembler->getLinearSystem(sysname)->getFromRightHandSide(i, valeur);
108  fprintf(f, "%+e\n", valeur);
109  }
110  fclose(f);
111  }
112 }
113 
115 {
116  std::string sysname = "A";
117  if(pAssembler && pAssembler->getLinearSystem(sysname))
118  delete pAssembler->getLinearSystem(sysname);
119 
120 #if defined(HAVE_PETSC)
122 #elif defined(HAVE_GMM)
124 #else
126 #endif
127 
128  assemble(lsys);
129  // printLinearSystem(lsys,pAssembler->sizeOfR());
130  lsys->systemSolve();
131  printf("-- done solving!\n");
132 
133  double energ = 0;
135  for(std::size_t i = 0; i < elasticFields.size(); i++) {
138  elasticFields[i]._nu);
139  BilinearTermToScalarTerm Elastic_Energy_Term(Eterm);
140  Assemble(Elastic_Energy_Term, elasticFields[i].g->begin(),
141  elasticFields[i].g->end(), Integ_Bulk, energ);
142  }
143  printf("elastic energy=%f\n", energ);
144 }
145 
147 {
149 
150  double energ = 0;
151  for(std::size_t i = 0; i < elasticFields.size(); i++) {
154  elasticFields[i]._nu);
155  BilinearTermToScalarTerm Elastic_Energy_Term(Eterm);
156  Assemble(Elastic_Energy_Term, elasticFields[i].g->begin(),
157  elasticFields[i].g->end(), Integ_Bulk, energ);
158  }
159  printf("elastic energy=%f\n", energ);
160 }
161 
162 void elasticitySolver::readInputFile(const std::string &fn)
163 {
164  FILE *f = Fopen(fn.c_str(), "r");
165  if(!f) {
166  Msg::Error("Could not open file '%s'", fn.c_str());
167  return;
168  }
169  char what[256];
170  while(!feof(f)) {
171  if(fscanf(f, "%s", what) != 1) {
172  fclose(f);
173  return;
174  }
175  if(what[0] == '#') {
176  char buffer[1024];
177  if(fgets(buffer, sizeof(buffer), f) == nullptr)
178  Msg::Error("Cannot read line.");
179  }
180  else if(!strcmp(what, "ElasticDomain")) {
181  elasticField field;
182  int physical;
183  if(fscanf(f, "%d %lf %lf", &physical, &field._e, &field._nu) != 3) {
184  fclose(f);
185  return;
186  }
187  field._tag = _tag;
188  field.g = new groupOfElements(_dim, physical);
189  elasticFields.push_back(field);
190  }
191  else if(!strcmp(what, "LagrangeMultipliers")) {
193  int physical;
194  double d1, d2, d3, val;
195  if(fscanf(f, "%d %lf %lf %lf %lf %lf %d", &physical, &field._tau, &d1,
196  &d2, &d3, &val, &field._tag) != 7) {
197  fclose(f);
198  return;
199  }
200  SVector3 sv(d1, d2, d3);
201  field._d = sv.unit();
202  field._f = new simpleFunction<double>(val);
203  field.g = new groupOfElements(_dim - 1, physical);
204  LagrangeMultiplierFields.push_back(field);
205  LagrangeMultiplierSpaces.push_back(
207  }
208  else if(!strcmp(what, "Void")) {
209  elasticField field;
210  int physical;
211  if(fscanf(f, "%d", &physical) != 1) {
212  fclose(f);
213  return;
214  }
215  field._e = field._nu = 0;
216  field.g = new groupOfElements(_dim, physical);
217  field._tag = 0;
218  elasticFields.push_back(field);
219  }
220  else if(!strcmp(what, "NodeDisplacement")) {
221  double val;
222  int node, comp;
223  if(fscanf(f, "%d %d %lf", &node, &comp, &val) != 3) {
224  fclose(f);
225  return;
226  }
227  dirichletBC diri;
228  diri.g = new groupOfElements(0, node);
229  diri._f = new simpleFunction<double>(val);
230  diri._comp = comp;
231  diri._tag = node;
233  allDirichlet.push_back(diri);
234  }
235  else if(!strcmp(what, "EdgeDisplacement")) {
236  double val;
237  int edge, comp;
238  if(fscanf(f, "%d %d %lf", &edge, &comp, &val) != 3) {
239  fclose(f);
240  return;
241  }
242  dirichletBC diri;
243  diri.g = new groupOfElements(1, edge);
244  diri._f = new simpleFunction<double>(val);
245  diri._comp = comp;
246  diri._tag = edge;
248  allDirichlet.push_back(diri);
249  }
250  else if(!strcmp(what, "FaceDisplacement")) {
251  double val;
252  int face, comp;
253  if(fscanf(f, "%d %d %lf", &face, &comp, &val) != 3) {
254  fclose(f);
255  return;
256  }
257  dirichletBC diri;
258  diri.g = new groupOfElements(2, face);
259  diri._f = new simpleFunction<double>(val);
260  diri._comp = comp;
261  diri._tag = face;
263  allDirichlet.push_back(diri);
264  }
265  else if(!strcmp(what, "NodeForce")) {
266  double val1, val2, val3;
267  int node;
268  if(fscanf(f, "%d %lf %lf %lf", &node, &val1, &val2, &val3) != 4) {
269  fclose(f);
270  return;
271  }
272  neumannBC neu;
273  neu.g = new groupOfElements(0, node);
274  neu._f = new simpleFunction<SVector3>(SVector3(val1, val2, val3));
275  neu._tag = node;
277  allNeumann.push_back(neu);
278  }
279  else if(!strcmp(what, "EdgeForce")) {
280  double val1, val2, val3;
281  int edge;
282  if(fscanf(f, "%d %lf %lf %lf", &edge, &val1, &val2, &val3) != 4) {
283  fclose(f);
284  return;
285  }
286  neumannBC neu;
287  neu.g = new groupOfElements(1, edge);
288  neu._f = new simpleFunction<SVector3>(SVector3(val1, val2, val3));
289  neu._tag = edge;
291  allNeumann.push_back(neu);
292  }
293  else if(!strcmp(what, "FaceForce")) {
294  double val1, val2, val3;
295  int face;
296  if(fscanf(f, "%d %lf %lf %lf", &face, &val1, &val2, &val3) != 4) {
297  fclose(f);
298  return;
299  }
300  neumannBC neu;
301  neu.g = new groupOfElements(2, face);
302  neu._f = new simpleFunction<SVector3>(SVector3(val1, val2, val3));
303  neu._tag = face;
305  allNeumann.push_back(neu);
306  }
307  else if(!strcmp(what, "VolumeForce")) {
308  double val1, val2, val3;
309  int volume;
310  if(fscanf(f, "%d %lf %lf %lf", &volume, &val1, &val2, &val3) != 4) {
311  fclose(f);
312  return;
313  }
314  neumannBC neu;
315  neu.g = new groupOfElements(3, volume);
316  neu._f = new simpleFunction<SVector3>(SVector3(val1, val2, val3));
317  neu._tag = volume;
319  allNeumann.push_back(neu);
320  }
321  else if(!strcmp(what, "MeshFile")) {
322  char name[245];
323  if(fscanf(f, "%s", name) != 1) {
324  fclose(f);
325  return;
326  }
327  setMesh(name);
328  }
329  else if(!strcmp(what, "CutMeshPlane")) {
330  double a, b, c, d;
331  if(fscanf(f, "%lf %lf %lf %lf", &a, &b, &c, &d) != 4) {
332  fclose(f);
333  return;
334  }
335  int tag = 1;
336  gLevelsetPlane ls(a, b, c, d, tag);
337  pModel = pModel->buildCutGModel(&ls);
338  pModel->writeMSH("cutMesh.msh");
339  }
340  else if(!strcmp(what, "CutMeshSphere")) {
341  double x, y, z, r;
342  if(fscanf(f, "%lf %lf %lf %lf", &x, &y, &z, &r) != 4) {
343  fclose(f);
344  return;
345  }
346  int tag = 1;
347  gLevelsetSphere ls(x, y, z, r, tag);
348  pModel = pModel->buildCutGModel(&ls);
349  pModel->writeMSH("cutMesh.msh");
350  }
351  else if(!strcmp(what, "CutMeshMathExpr")) {
352  char expr[256];
353  if(fscanf(f, "%s", expr) != 1) {
354  fclose(f);
355  return;
356  }
357  std::string exprS(expr);
358  int tag = 1;
359  gLevelsetMathEval ls(exprS, tag);
360  pModel = pModel->buildCutGModel(&ls);
361  pModel->writeMSH("cutMesh.msh");
362  }
363  else {
364  Msg::Error("Invalid input : '%s'", what);
365  }
366  }
367  fclose(f);
368 }
369 
371 {
373  pModel->writeMSH("cutMesh.msh");
374 }
375 
376 void elasticitySolver::setElasticDomain(int phys, double E, double nu)
377 {
378  elasticField field;
379  field._e = E;
380  field._nu = nu;
381  field._tag = _tag;
382  field.g = new groupOfElements(_dim, phys);
383  elasticFields.push_back(field);
384 }
385 
387  const SVector3 &d, int tag,
389 {
391  field._tau = tau;
392  field._tag = tag;
393  field._f = f;
394  field._d = d.unit();
395  field.g = new groupOfElements(
396  _dim - 1, phys); // LM applied on entity of dimension = dim-1!
397  LagrangeMultiplierFields.push_back(field);
398  LagrangeMultiplierSpaces.push_back(
400 }
401 
402 void elasticitySolver::changeLMTau(int tag, double tau)
403 {
404  for(std::size_t i = 0; i < LagrangeMultiplierFields.size(); i++) {
405  if(LagrangeMultiplierFields[i]._tag == tag) {
406  LagrangeMultiplierFields[i]._tau = tau;
407  }
408  }
409 }
410 
411 void elasticitySolver::setEdgeDisp(int edge, int comp,
413 {
414  dirichletBC diri;
415  diri.g = new groupOfElements(1, edge);
416  diri._f = f;
417  diri._comp = comp;
418  diri._tag = edge;
420  allDirichlet.push_back(diri);
421 }
422 
423 void elasticitySolver::addDirichletBC(int dim, int entityId, int component,
424  double value)
425 {
426  dirichletBC diri;
427  diri.g = new groupOfElements(dim, entityId);
428  diri._f = new simpleFunction<double>(value);
429  diri._comp = component;
430  diri._tag = entityId;
431  switch(dim) {
432  case 0: diri.onWhat = BoundaryCondition::ON_VERTEX; break;
433  case 1: diri.onWhat = BoundaryCondition::ON_EDGE; break;
434  case 2: diri.onWhat = BoundaryCondition::ON_FACE; break;
435  default: {
436  delete diri.g;
437  delete diri._f;
438  return;
439  }
440  }
441  allDirichlet.push_back(diri);
442 }
443 
444 void elasticitySolver::addDirichletBC(int dim, std::string phys, int component,
445  double value)
446 {
447  int entityId = pModel->getPhysicalNumber(dim, phys);
448  addDirichletBC(dim, entityId, component, value);
449 }
450 
451 void elasticitySolver::addNeumannBC(int dim, int entityId,
452  const std::vector<double> value)
453 {
454  if(value.size() != 3) return;
455  neumannBC neu;
456  neu.g = new groupOfElements(dim, entityId);
457  neu._f = new simpleFunction<SVector3>(SVector3(value[0], value[1], value[2]));
458  neu._tag = entityId;
459  switch(dim) {
460  case 0: neu.onWhat = BoundaryCondition::ON_VERTEX; break;
461  case 1: neu.onWhat = BoundaryCondition::ON_EDGE; break;
462  case 2: neu.onWhat = BoundaryCondition::ON_FACE; break;
463  default: {
464  delete neu.g;
465  delete neu._f;
466  return;
467  }
468  }
469  allNeumann.push_back(neu);
470 }
471 
472 void elasticitySolver::addNeumannBC(int dim, std::string phys,
473  const std::vector<double> value)
474 {
475  int entityId = pModel->getPhysicalNumber(dim, phys);
476  addNeumannBC(dim, entityId, value);
477 }
478 
479 void elasticitySolver::addElasticDomain(int physical, double e, double nu)
480 {
481  elasticField field;
482  field._tag = _tag;
483  field._e = e;
484  field._nu = nu;
485  field.g = new groupOfElements(_dim, physical);
486  elasticFields.push_back(field);
487 }
488 
489 void elasticitySolver::addElasticDomain(std::string phys, double e, double nu)
490 {
491  int entityId = pModel->getPhysicalNumber(_dim, phys);
492  addElasticDomain(entityId, e, nu);
493 }
494 
496 {
497  if(pAssembler) delete pAssembler;
498  pAssembler = new dofManager<double>(lsys);
499 
500  // we first do all fixations. the behavior of the dofManager is to
501  // give priority to fixations : when a dof is fixed, it cannot be
502  // numbered afterwards
503 
504  // Dirichlet conditions
505  for(std::size_t i = 0; i < allDirichlet.size(); i++) {
506  FilterDofComponent filter(allDirichlet[i]._comp);
507  FixNodalDofs(*LagSpace, allDirichlet[i].g->begin(),
508  allDirichlet[i].g->end(), *pAssembler, *allDirichlet[i]._f,
509  filter);
510  }
511  // LagrangeMultipliers
512  for(std::size_t i = 0; i < LagrangeMultiplierFields.size(); ++i) {
513  std::size_t j = 0;
514  for(; j < LagrangeMultiplierSpaces.size(); j++)
515  if(LagrangeMultiplierSpaces[j]->getId() ==
517  break;
519  LagrangeMultiplierFields[i].g->begin(),
520  LagrangeMultiplierFields[i].g->end(), *pAssembler);
521  }
522  // Elastic Fields
523  for(std::size_t i = 0; i < elasticFields.size(); ++i) {
524  if(elasticFields[i]._e != 0.)
525  NumberDofs(*LagSpace, elasticFields[i].g->begin(),
526  elasticFields[i].g->end(), *pAssembler);
527  }
528  // Voids
529  for(std::size_t i = 0; i < elasticFields.size(); ++i) {
530  if(elasticFields[i]._e == 0.)
531  FixVoidNodalDofs(*LagSpace, elasticFields[i].g->begin(),
532  elasticFields[i].g->end(), *pAssembler);
533  }
534  // Neumann conditions
535  GaussQuadrature Integ_Boundary(GaussQuadrature::Val);
536 
537  for(std::size_t i = 0; i < allNeumann.size(); i++) {
538  LoadTerm<SVector3> Lterm(*LagSpace, allNeumann[i]._f);
539  Assemble(Lterm, *LagSpace, allNeumann[i].g->begin(), allNeumann[i].g->end(),
540  Integ_Boundary, *pAssembler);
541  }
542  // Assemble cross term, laplace term and rhs term for LM
543  GaussQuadrature Integ_LagrangeMult(GaussQuadrature::ValVal);
545  for(std::size_t i = 0; i < LagrangeMultiplierFields.size(); i++) {
546  std::size_t j = 0;
547  for(; j < LagrangeMultiplierSpaces.size(); j++)
548  if(LagrangeMultiplierSpaces[j]->getId() ==
550  break;
551  printf("Lagrange Mult Lag\n");
555  Assemble(LagTerm, *LagSpace, *(LagrangeMultiplierSpaces[j]),
556  LagrangeMultiplierFields[i].g->begin(),
557  LagrangeMultiplierFields[i].g->end(), Integ_LagrangeMult,
558  *pAssembler);
559 
560  printf("Lagrange Mult Lap\n");
562  -LagrangeMultiplierFields[i]._tau);
563  Assemble(LapTerm, *(LagrangeMultiplierSpaces[j]),
564  LagrangeMultiplierFields[i].g->begin(),
565  LagrangeMultiplierFields[i].g->end(), Integ_Laplace, *pAssembler);
566 
567  printf("Lagrange Mult Load\n");
570  Assemble(Lterm, *(LagrangeMultiplierSpaces[j]),
571  LagrangeMultiplierFields[i].g->begin(),
572  LagrangeMultiplierFields[i].g->end(), Integ_Boundary, *pAssembler);
573  }
574  // Assemble elastic term for
576  for(std::size_t i = 0; i < elasticFields.size(); i++) {
577  printf("Elastic\n");
579  elasticFields[i]._nu);
580  Assemble(Eterm, *LagSpace, elasticFields[i].g->begin(),
581  elasticFields[i].g->end(), Integ_Bulk, *pAssembler);
582  }
583 
584  printf("nDofs=%d\n", pAssembler->sizeOfR());
585  printf("nFixed=%d\n", pAssembler->sizeOfF());
586 }
587 
588 void elasticitySolver::computeEffectiveStiffness(std::vector<double> stiff)
589 {
590  double st[6] = {0., 0., 0., 0., 0., 0.};
591  double volTot = 0.;
592  for(std::size_t i = 0; i < elasticFields.size(); ++i) {
593  double E = elasticFields[i]._e;
594  double nu = elasticFields[i]._nu;
596  for(auto it =
597  elasticFields[i].g->begin();
598  it != elasticFields[i].g->end(); ++it) {
599  MElement *e = *it;
600  double vol = e->getVolume() * e->getVolumeSign();
601  int nbVertex = e->getNumVertices();
602  std::vector<SVector3> val(nbVertex);
603 
604  double valx[256];
605  double valy[256];
606  double valz[256];
607  for(int k = 0; k < nbVertex; k++) {
608  MVertex *v = e->getVertex(k);
609  MPoint p(v);
610  Field.f(&p, 0, 0, 0, val[k]);
611  valx[k] = val[k](0);
612  valy[k] = val[k](1);
613  valz[k] = val[k](2);
614  }
615 
616  double gradux[3];
617  double graduy[3];
618  double graduz[3];
619  SPoint3 center = e->barycenterUVW();
620  double u = center.x(), v = center.y(), w = center.z();
621  e->interpolateGrad(valx, u, v, w, gradux);
622  e->interpolateGrad(valy, u, v, w, graduy);
623  e->interpolateGrad(valz, u, v, w, graduz);
624 
625  double eps[6] = {gradux[0],
626  graduy[1],
627  graduz[2],
628  0.5 * (gradux[1] + graduy[0]),
629  0.5 * (gradux[2] + graduz[0]),
630  0.5 * (graduy[2] + graduz[1])};
631 
632  double A = E / (1. + nu);
633  double B = A * (nu / (1. - 2 * nu));
634  double trace = eps[0] + eps[1] + eps[2];
635  st[0] += (A * eps[0] + B * trace) * vol;
636  st[1] += (A * eps[1] + B * trace) * vol;
637  st[2] += (A * eps[2] + B * trace) * vol;
638  st[3] += (A * eps[3]) * vol;
639  st[4] += (A * eps[4]) * vol;
640  st[5] += (A * eps[5]) * vol;
641  volTot += vol;
642  }
643  }
644  for(int i = 0; i < 6; i++) stiff[i] = st[i] / volTot;
645 }
646 
647 void elasticitySolver::computeEffectiveStrain(std::vector<double> strain)
648 {
649  double st[6] = {0., 0., 0., 0., 0., 0.};
650  double volTot = 0.;
651  for(std::size_t i = 0; i < elasticFields.size(); ++i) {
653  for(auto it =
654  elasticFields[i].g->begin();
655  it != elasticFields[i].g->end(); ++it) {
656  MElement *e = *it;
657  double vol = e->getVolume() * e->getVolumeSign();
658  int nbVertex = e->getNumVertices();
659  std::vector<SVector3> val(nbVertex);
660 
661  double valx[256];
662  double valy[256];
663  double valz[256];
664  for(int k = 0; k < nbVertex; k++) {
665  MVertex *v = e->getVertex(k);
666  MPoint p(v);
667  Field.f(&p, 0, 0, 0, val[k]);
668  valx[k] = val[k](0);
669  valy[k] = val[k](1);
670  valz[k] = val[k](2);
671  }
672 
673  double gradux[3];
674  double graduy[3];
675  double graduz[3];
676  SPoint3 center = e->barycenterUVW();
677  double u = center.x(), v = center.y(), w = center.z();
678  e->interpolateGrad(valx, u, v, w, gradux);
679  e->interpolateGrad(valy, u, v, w, graduy);
680  e->interpolateGrad(valz, u, v, w, graduz);
681 
682  st[0] += gradux[0] * vol;
683  st[1] += graduy[1] * vol;
684  st[2] += graduz[2] * vol;
685  st[3] += 0.5 * (gradux[1] + graduy[0]) * vol;
686  st[4] += 0.5 * (gradux[2] + graduz[0]) * vol;
687  st[5] += 0.5 * (graduy[2] + graduz[1]) * vol;
688  volTot += vol;
689  }
690  }
691  for(int i = 0; i < 6; i++) strain[i] = st[i] / volTot;
692 }
693 
697 {
698  std::cout << "compute displacement error" << std::endl;
699  double err = 0.;
700  std::set<MVertex *> v;
701  std::map<MVertex *, MElement *> vCut;
702  for(std::size_t i = 0; i < elasticFields.size(); ++i) {
703  if(elasticFields[i]._e == 0.) continue;
704  for(auto it =
705  elasticFields[i].g->begin();
706  it != elasticFields[i].g->end(); ++it) {
707  MElement *e = *it;
708  if(e->getParent()) {
709  for(std::size_t j = 0; j < e->getNumVertices(); ++j) {
710  if(vCut.find(e->getVertex(j)) == vCut.end())
711  vCut[e->getVertex(j)] = e->getParent();
712  }
713  }
714  else {
715  for(std::size_t j = 0; j < e->getNumVertices(); ++j)
716  v.insert(e->getVertex(j));
717  }
718  }
719  }
721  for(auto it = v.begin(); it != v.end(); ++it) {
722  SVector3 val;
723  MPoint p(*it);
724  Field.f(&p, 0, 0, 0, val);
725  SVector3 sol((*f0)((*it)->x(), (*it)->y(), (*it)->z()),
726  (*f1)((*it)->x(), (*it)->y(), (*it)->z()),
727  (*f2)((*it)->x(), (*it)->y(), (*it)->z()));
728  double diff = normSq(sol - val);
729  err += diff;
730  }
731  for(auto it = vCut.begin();
732  it != vCut.end(); ++it) {
733  SVector3 val;
734  double uvw[3];
735  double xyz[3] = {it->first->x(), it->first->y(), it->first->z()};
736  it->second->xyz2uvw(xyz, uvw);
737  Field.f(it->second, uvw[0], uvw[1], uvw[2], val);
738  SVector3 sol((*f0)(xyz[0], xyz[1], xyz[2]), (*f1)(xyz[0], xyz[1], xyz[2]),
739  (*f2)(xyz[0], xyz[1], xyz[2]));
740  double diff = normSq(sol - val);
741  err += diff;
742  }
743  printf("Displacement Error = %g\n", sqrt(err));
744  return sqrt(err);
745 }
746 
750 {
751  double val = 0.0;
753  for(std::size_t i = 0; i < elasticFields.size(); ++i) {
754  for(auto it =
755  elasticFields[i].g->begin();
756  it != elasticFields[i].g->end(); ++it) {
757  MElement *e = *it;
758  int npts;
759  IntPt *GP;
760  double jac[3][3];
761  int integrationOrder = 2 * (e->getPolynomialOrder() + 5);
762  e->getIntegrationPoints(integrationOrder, &npts, &GP);
763  for(int j = 0; j < npts; j++) {
764  double u = GP[j].pt[0];
765  double v = GP[j].pt[1];
766  double w = GP[j].pt[2];
767  double weight = GP[j].weight;
768  double detJ = fabs(e->getJacobian(u, v, w, jac));
769  SPoint3 p;
770  e->pnt(u, v, w, p);
771  SVector3 FEMVALUE;
772  solField.f(e, u, v, w, FEMVALUE);
773  SVector3 sol((*f0)(p.x(), p.y(), p.z()), (*f1)(p.x(), p.y(), p.z()),
774  (*f2)(p.x(), p.y(), p.z()));
775  double diff = normSq(sol - FEMVALUE);
776  val += diff * detJ * weight;
777  }
778  }
779  }
780  printf("L2Norm = %g\n", sqrt(val));
781  return sqrt(val);
782 }
783 
785 {
786  return 0;
787 }
788 
789 #if defined(HAVE_POST)
790 
791 PView *elasticitySolver::buildErrorView(const std::string postFileName,
795 {
796  std::cout << "build Error View" << std::endl;
797  std::map<int, std::vector<double> > data;
798 
800  for(std::size_t i = 0; i < elasticFields.size(); ++i) {
801  for(auto it =
802  elasticFields[i].g->begin();
803  it != elasticFields[i].g->end(); ++it) {
804  MElement *e = *it;
805  int npts;
806  IntPt *GP;
807  double jac[3][3];
808  int integrationOrder = 2 * (e->getPolynomialOrder() + 5);
809  e->getIntegrationPoints(integrationOrder, &npts, &GP);
810  double val = 0.0;
811  for(int j = 0; j < npts; j++) {
812  double u = GP[j].pt[0];
813  double v = GP[j].pt[1];
814  double w = GP[j].pt[2];
815  double weight = GP[j].weight;
816  double detJ = fabs(e->getJacobian(u, v, w, jac));
817  SPoint3 p;
818  e->pnt(u, v, w, p);
819  SVector3 FEMVALUE;
820  solField.f(e, u, v, w, FEMVALUE);
821  SVector3 sol((*f0)(p.x(), p.y(), p.z()), (*f1)(p.x(), p.y(), p.z()),
822  (*f2)(p.x(), p.y(), p.z()));
823  double diff = normSq(sol - FEMVALUE);
824  val += diff * detJ * weight;
825  }
826  std::vector<double> vec;
827  vec.push_back(sqrt(val));
828  data[e->getNum()] = vec;
829  }
830  }
831 
832  PView *pv = new PView(postFileName, "ElementData", pModel, data, 0.0, 1);
833  return pv;
834 }
835 
836 PView *elasticitySolver::buildDisplacementView(const std::string postFileName)
837 {
838  std::cout << "build Displacement View" << std::endl;
839  std::set<MVertex *> v;
840  std::map<MVertex *, MElement *> vCut;
841  for(std::size_t i = 0; i < elasticFields.size(); ++i) {
842  if(elasticFields[i]._e == 0.) continue;
843  for(auto it =
844  elasticFields[i].g->begin();
845  it != elasticFields[i].g->end(); ++it) {
846  MElement *e = *it;
847  if(e->getParent()) {
848  for(std::size_t j = 0; j < e->getNumVertices(); ++j) {
849  if(vCut.find(e->getVertex(j)) == vCut.end())
850  vCut[e->getVertex(j)] = e->getParent();
851  }
852  }
853  else {
854  for(std::size_t j = 0; j < e->getNumVertices(); ++j)
855  v.insert(e->getVertex(j));
856  }
857  }
858  }
859  std::map<int, std::vector<double> > data;
861  for(auto it = v.begin(); it != v.end(); ++it) {
862  SVector3 val;
863  MPoint p(*it);
864  Field.f(&p, 0, 0, 0, val);
865  std::vector<double> vec(3);
866  vec[0] = val(0);
867  vec[1] = val(1);
868  vec[2] = val(2);
869  data[(*it)->getNum()] = vec;
870  }
871  for(auto it = vCut.begin();
872  it != vCut.end(); ++it) {
873  SVector3 val;
874  double uvw[3];
875  double xyz[3] = {it->first->x(), it->first->y(), it->first->z()};
876  it->second->xyz2uvw(xyz, uvw);
877  Field.f(it->second, uvw[0], uvw[1], uvw[2], val);
878  std::vector<double> vec(3);
879  vec[0] = val(0);
880  vec[1] = val(1);
881  vec[2] = val(2);
882  data[it->first->getNum()] = vec;
883  }
884  PView *pv = new PView(postFileName, "NodeData", pModel, data, 0.0);
885  return pv;
886 }
887 
888 PView *elasticitySolver::buildStressesView(const std::string postFileName)
889 {
890  double sti[6] = {0., 0., 0., 0., 0., 0.};
891  double str[6] = {0., 0., 0., 0., 0., 0.};
892  double volTot = 0.;
893  std::cout << "build stresses view" << std::endl;
894  std::map<int, std::vector<double> > data;
895  for(std::size_t i = 0; i < elasticFields.size(); ++i) {
896  double E = elasticFields[i]._e;
897  double nu = elasticFields[i]._nu;
899  for(auto it =
900  elasticFields[i].g->begin();
901  it != elasticFields[i].g->end(); ++it) {
902  MElement *e = *it;
903  double vol = e->getVolume() * e->getVolumeSign();
904  int nbVertex = e->getNumVertices();
905  std::vector<SVector3> val(nbVertex);
906 
907  double valx[256];
908  double valy[256];
909  double valz[256];
910  for(int k = 0; k < nbVertex; k++) {
911  MVertex *v = e->getVertex(k);
912  MPoint p(v);
913  Field.f(&p, 0, 0, 0, val[k]);
914  valx[k] = val[k](0);
915  valy[k] = val[k](1);
916  valz[k] = val[k](2);
917  }
918 
919  double gradux[3];
920  double graduy[3];
921  double graduz[3];
922  SPoint3 center = e->barycenterUVW();
923  double u = center.x(), v = center.y(), w = center.z();
924  e->interpolateGrad(valx, u, v, w, gradux);
925  e->interpolateGrad(valy, u, v, w, graduy);
926  e->interpolateGrad(valz, u, v, w, graduz);
927 
928  double eps[6] = {gradux[0],
929  graduy[1],
930  graduz[2],
931  0.5 * (gradux[1] + graduy[0]),
932  0.5 * (gradux[2] + graduz[0]),
933  0.5 * (graduy[2] + graduz[1])};
934 
935  double A = E / (1. + nu);
936  double B = A * (nu / (1. - 2 * nu));
937  double trace = eps[0] + eps[1] + eps[2];
938  double sxx = A * eps[0] + B * trace;
939  double syy = A * eps[1] + B * trace;
940  double szz = A * eps[2] + B * trace;
941  double sxy = A * eps[3];
942  double sxz = A * eps[4];
943  double syz = A * eps[5];
944 
945  std::vector<double> vec(9);
946  vec[0] = sxx;
947  vec[1] = sxy;
948  vec[2] = sxz;
949  vec[3] = sxy;
950  vec[4] = syy;
951  vec[5] = syz;
952  vec[6] = sxz;
953  vec[7] = syz;
954  vec[8] = szz;
955 
956  data[e->getNum()] = vec;
957 
958  for(int k = 0; k < 6; k++) str[k] += eps[k] * vol;
959  sti[0] += sxx * vol;
960  sti[1] += syy * vol;
961  sti[2] += szz * vol;
962  sti[3] += sxy * vol;
963  sti[4] += sxz * vol;
964  sti[5] += syz * vol;
965  volTot += vol;
966  }
967  }
968  for(int i = 0; i < 6; i++) {
969  str[i] = str[i] / volTot;
970  sti[i] = sti[i] / volTot;
971  }
972  printf("effective stiffn = ");
973  for(int i = 0; i < 6; i++) printf("%g ", sti[i]);
974  printf("\n");
975  printf("effective strain = ");
976  for(int i = 0; i < 6; i++) printf("%g ", str[i]);
977  printf("\n");
978 
979  PView *pv = new PView(postFileName, "ElementData", pModel, data, 0.0);
980  return pv;
981 }
982 
983 PView *elasticitySolver::buildStrainView(const std::string postFileName)
984 {
985  std::cout << "build strain view" << std::endl;
986  std::map<int, std::vector<double> > data;
987  for(std::size_t i = 0; i < elasticFields.size(); ++i) {
989  for(auto it =
990  elasticFields[i].g->begin();
991  it != elasticFields[i].g->end(); ++it) {
992  MElement *e = *it;
993  int nbVertex = e->getNumVertices();
994  std::vector<SVector3> val(nbVertex);
995 
996  double valx[256];
997  double valy[256];
998  double valz[256];
999  for(int k = 0; k < nbVertex; k++) {
1000  MVertex *v = e->getVertex(k);
1001  MPoint p(v);
1002  Field.f(&p, 0, 0, 0, val[k]);
1003  valx[k] = val[k](0);
1004  valy[k] = val[k](1);
1005  valz[k] = val[k](2);
1006  }
1007 
1008  double gradux[3];
1009  double graduy[3];
1010  double graduz[3];
1011  double u = 0.33, v = 0.33, w = 0.0;
1012  e->interpolateGrad(valx, u, v, w, gradux);
1013  e->interpolateGrad(valy, u, v, w, graduy);
1014  e->interpolateGrad(valz, u, v, w, graduz);
1015 
1016  std::vector<double> vec(9);
1017  vec[0] = gradux[0];
1018  vec[4] = graduy[1];
1019  vec[8] = graduy[2];
1020  vec[1] = vec[3] = 0.5 * (gradux[0] + graduy[1]);
1021  vec[2] = vec[6] = 0.5 * (gradux[0] + graduz[2]);
1022  vec[5] = vec[7] = 0.5 * (gradux[1] + graduz[2]);
1023 
1024  data[e->getNum()] = vec;
1025  }
1026  }
1027  PView *pv = new PView(postFileName, "ElementData", pModel, data, 0.0);
1028  return pv;
1029 }
1030 
1031 PView *
1032 elasticitySolver::buildLagrangeMultiplierView(const std::string &postFileName,
1033  int tag)
1034 {
1035  std::cout << "build Lagrange Multiplier View" << std::endl;
1036  std::size_t t = 0;
1037  if(tag != -1)
1038  for(; t < LagrangeMultiplierSpaces.size(); t++)
1039  if(LagrangeMultiplierSpaces[t]->getId() == tag) break;
1040  if(t == LagrangeMultiplierSpaces.size()) return new PView();
1041  std::set<MVertex *> v;
1042  for(std::size_t i = 0; i < LagrangeMultiplierFields.size(); ++i) {
1043  for(auto it =
1044  LagrangeMultiplierFields[i].g->begin();
1045  it != LagrangeMultiplierFields[i].g->end(); ++it) {
1046  MElement *e = *it;
1047  for(std::size_t j = 0; j < e->getNumVertices(); ++j)
1048  v.insert(e->getVertex(j));
1049  }
1050  }
1051  std::map<int, std::vector<double> > data;
1053  for(auto it = v.begin(); it != v.end(); ++it) {
1054  double val;
1055  MPoint p(*it);
1056  Field.f(&p, 0, 0, 0, val);
1057  std::vector<double> vec;
1058  vec.push_back(val);
1059  data[(*it)->getNum()] = vec;
1060  }
1061  PView *pv = new PView(postFileName, "NodeData", pModel, data, 0.0);
1062  return pv;
1063 }
1064 
1065 PView *elasticitySolver::buildElasticEnergyView(const std::string postFileName)
1066 {
1067  std::cout << "build Elastic Energy View" << std::endl;
1068  std::map<int, std::vector<double> > data;
1070  for(std::size_t i = 0; i < elasticFields.size(); ++i) {
1071  if(elasticFields[i]._e == 0.) continue;
1074  elasticFields[i]._nu);
1075  BilinearTermToScalarTerm Elastic_Energy_Term(Eterm);
1076  ScalarTermConstant<double> One(1.0);
1077  for(auto it =
1078  elasticFields[i].g->begin();
1079  it != elasticFields[i].g->end(); ++it) {
1080  MElement *e = *it;
1081  double energ;
1082  double vol;
1083  IntPt *GP;
1084  int npts = Integ_Bulk.getIntPoints(e, &GP);
1085  Elastic_Energy_Term.get(e, npts, GP, energ);
1086  One.get(e, npts, GP, vol);
1087  std::vector<double> vec;
1088  vec.push_back(energ / vol);
1089  data[e->getNum()] = vec;
1090  }
1091  }
1092  PView *pv = new PView(postFileName, "ElementData", pModel, data, 0.0);
1093  return pv;
1094 }
1095 
1096 PView *elasticitySolver::buildVolumeView(const std::string postFileName)
1097 {
1098  std::cout << "build Volume View";
1099  std::map<int, std::vector<double> > data;
1100  double voltot = 0;
1101  double length = 0;
1103  for(std::size_t i = 0; i < elasticFields.size(); ++i) {
1104  ScalarTermConstant<double> One(1.0);
1105  for(auto it =
1106  elasticFields[i].g->begin();
1107  it != elasticFields[i].g->end(); ++it) {
1108  MElement *e = *it;
1109  double vol;
1110  IntPt *GP;
1111  int npts = Integ_Vol.getIntPoints(e, &GP);
1112  One.get(e, npts, GP, vol);
1113  voltot += vol;
1114  std::vector<double> vec;
1115  vec.push_back(vol);
1116  data[e->getNum()] = vec;
1117  }
1118  }
1119  for(std::size_t i = 0; i < LagrangeMultiplierFields.size(); ++i) {
1120  ScalarTermConstant<double> One(1.0);
1121  for(auto it =
1122  LagrangeMultiplierFields[i].g->begin();
1123  it != LagrangeMultiplierFields[i].g->end(); ++it) {
1124  MElement *e = *it;
1125  double l;
1126  IntPt *GP;
1127  int npts = Integ_Vol.getIntPoints(e, &GP);
1128  One.get(e, npts, GP, l);
1129  length += l;
1130  }
1131  std::cout << " : length " << LagrangeMultiplierFields[i]._tag << " = "
1132  << length;
1133  length = 0;
1134  }
1135  PView *pv = new PView(postFileName, "ElementData", pModel, data, 0.0, 1);
1136  std::cout << " / total vol = " << voltot << std::endl;
1137  return pv;
1138 }
1139 
1140 PView *elasticitySolver::buildVonMisesView(const std::string postFileName)
1141 {
1142  std::cout << "build elastic view" << std::endl;
1143  std::map<int, std::vector<double> > data;
1145  for(std::size_t i = 0; i < elasticFields.size(); ++i) {
1148  elasticFields[i]._nu);
1149  BilinearTermToScalarTerm Elastic_Energy_Term(Eterm);
1150  for(auto it =
1151  elasticFields[i].g->begin();
1152  it != elasticFields[i].g->end(); ++it) {
1153  MElement *e = *it;
1154  double energ;
1155  IntPt *GP;
1156  int npts = Integ_Bulk.getIntPoints(e, &GP);
1157  Elastic_Energy_Term.get(e, npts, GP, energ);
1158  std::vector<double> vec;
1159  vec.push_back(energ);
1160  data[(*it)->getNum()] = vec;
1161  }
1162  }
1163  PView *pv = new PView(postFileName, "ElementData", pModel, data, 0.0);
1164  return pv;
1165 }
1166 
1167 #endif
MElement::getNum
virtual std::size_t getNum() const
Definition: MElement.h:68
elasticitySolver::LagrangeMultiplierFields
std::vector< LagrangeMultiplierField > LagrangeMultiplierFields
Definition: elasticitySolver.h:68
elasticitySolver::allDirichlet
std::vector< dirichletBC > allDirichlet
Definition: elasticitySolver.h:72
terms.h
gLevelsetMathEval
Definition: gmshLevelset.h:341
elasticitySolver::changeLMTau
void changeLMTau(int tag, double tau)
Definition: elasticitySolver.cpp:402
LagrangeMultiplierField::_tau
double _tau
Definition: elasticitySolver.h:25
FixVoidNodalDofs
void FixVoidNodalDofs(FunctionSpaceBase &space, Iterator itbegin, Iterator itend, Assembler &assembler)
Definition: solverAlgorithms.h:305
linearSystemFull
Definition: linearSystemFull.h:17
PView
Definition: PView.h:27
FilterDofComponent
Definition: solverAlgorithms.h:231
VectorLagrangeFunctionSpace
Definition: functionSpace.h:510
GaussQuadrature::ValVal
@ ValVal
Definition: quadratureRules.h:38
LoadTerm
Definition: terms.h:317
elasticitySolver::computeEffectiveStrain
void computeEffectiveStrain(std::vector< double > strain)
Definition: elasticitySolver.cpp:647
elasticitySolver::_tag
int _tag
Definition: elasticitySolver.h:60
linearSystemPETSc
Definition: linearSystemPETSc.h:150
MElement::getIntegrationPoints
virtual void getIntegrationPoints(int pOrder, int *npts, IntPt **pts)
Definition: MElement.h:436
OS.h
neumannBC::_f
simpleFunction< SVector3 > * _f
Definition: elasticitySolver.h:53
LagrangeMultiplierField::_tag
int _tag
Definition: elasticitySolver.h:23
c
static double c(int i, int j, fullMatrix< double > &CA, const std::vector< SPoint3 > &P, const std::vector< SPoint3 > &Q)
Definition: discreteFrechetDistance.cpp:15
MVertex
Definition: MVertex.h:24
elasticitySolver::assemble
void assemble(linearSystem< double > *lsys)
Definition: elasticitySolver.cpp:495
BoundaryCondition::_tag
int _tag
Definition: elasticitySolver.h:39
dirichletBC::_f
simpleFunction< double > * _f
Definition: elasticitySolver.h:48
Msg::Error
static void Error(const char *fmt,...)
Definition: GmshMessage.cpp:482
LagrangeMultiplierField
Definition: elasticitySolver.h:22
linearSystemPETSc.h
SPoint3
Definition: SPoint3.h:14
LegendrePolynomials::f
void f(int n, double u, double *val)
Definition: orthogonalBasis.cpp:77
NumberDofs
void NumberDofs(FunctionSpaceBase &space, Iterator itbegin, Iterator itend, Assembler &assembler)
Definition: solverAlgorithms.h:314
MElement::getParent
virtual MElement * getParent() const
Definition: MElement.h:231
elasticitySolver::readInputFile
void readInputFile(const std::string &meshFileName)
Definition: elasticitySolver.cpp:162
SVector3
Definition: SVector3.h:16
PView.h
LoadTermOnBorder
Definition: terms.h:383
solverAlgorithms.h
linearSystemCSR.h
elasticField::_nu
double _nu
Definition: elasticitySolver.h:34
MPoint.h
elasticField::_e
double _e
Definition: elasticitySolver.h:34
groupOfElements
Definition: groupOfElements.h:24
elasticField::_tag
int _tag
Definition: elasticitySolver.h:32
GModel::buildCutGModel
GModel * buildCutGModel(gLevelset *ls, bool cutElem=true, bool saveTri=false)
Definition: GModel.cpp:3376
PViewData.h
IntPt::pt
double pt[3]
Definition: GaussIntegration.h:13
dofManager::sizeOfR
virtual int sizeOfR() const
Definition: dofManager.h:606
MElement::getNumVertices
virtual std::size_t getNumVertices() const =0
linearSystem::getFromRightHandSide
virtual void getFromRightHandSide(int _row, scalar &val) const =0
VectorLagrangeFunctionSpace::VECTOR_Y
@ VECTOR_Y
Definition: functionSpace.h:515
elasticitySolver::addElasticDomain
void addElasticDomain(int tag, double e, double nu)
Definition: elasticitySolver.cpp:479
LagrangeMultiplierField::_d
SVector3 _d
Definition: elasticitySolver.h:26
Fopen
FILE * Fopen(const char *f, const char *mode)
Definition: OS.cpp:273
GModel::readMSH
int readMSH(const std::string &name)
Definition: GModelIO_MSH.cpp:12
elasticitySolver::_dim
int _dim
Definition: elasticitySolver.h:60
BoundaryCondition::ON_EDGE
@ ON_EDGE
Definition: elasticitySolver.h:40
elasticField::g
groupOfElements * g
Definition: elasticitySolver.h:33
MElement::getVertex
virtual const MVertex * getVertex(int num) const =0
SPoint3::x
double x(void) const
Definition: SPoint3.h:125
IsotropicElasticTerm
Definition: terms.h:289
elasticitySolver::LagrangeMultiplierSpaces
std::vector< FunctionSpace< double > * > LagrangeMultiplierSpaces
Definition: elasticitySolver.h:63
solverField.h
elasticitySolver::computeDisplacementError
double computeDisplacementError(simpleFunction< double > *f0, simpleFunction< double > *f1, simpleFunction< double > *f2)
Definition: elasticitySolver.cpp:694
IntPt::weight
double weight
Definition: GaussIntegration.h:14
SolverField
Definition: solverField.h:25
MElement::interpolateGrad
void interpolateGrad(double val[], double u, double v, double w, double f[], int stride=1, double invjac[3][3]=nullptr, int order=-1)
Definition: MElement.cpp:1230
simpleFunction< double >
elasticitySolver::setLagrangeMultipliers
void setLagrangeMultipliers(int phys, double tau, const SVector3 &d, int tag, simpleFunction< double > *f)
Definition: elasticitySolver.cpp:386
linearSystemBase::isAllocated
virtual bool isAllocated() const =0
VectorLagrangeFunctionSpace::VECTOR_X
@ VECTOR_X
Definition: functionSpace.h:515
BoundaryCondition::onWhat
location onWhat
Definition: elasticitySolver.h:41
gLevelset
Definition: gmshLevelset.h:64
BoundaryCondition::g
groupOfElements * g
Definition: elasticitySolver.h:42
Assemble
void Assemble(BilinearTermBase &term, FunctionSpaceBase &space, Iterator itbegin, Iterator itend, QuadratureBase &integrator, Assembler &assembler)
Definition: solverAlgorithms.h:19
elasticitySolver::allNeumann
std::vector< neumannBC > allNeumann
Definition: elasticitySolver.h:70
linearSystemFull::systemSolve
virtual int systemSolve()
Definition: linearSystemFull.h:77
elasticField
Definition: elasticitySolver.h:31
MElement::getVolume
virtual double getVolume()
Definition: MElement.cpp:567
elasticitySolver::cutMesh
void cutMesh(gLevelset *ls)
Definition: elasticitySolver.cpp:370
Numeric.h
GModel
Definition: GModel.h:44
LagrangeMultiplierField::g
groupOfElements * g
Definition: elasticitySolver.h:24
dofManager::sizeOfF
virtual int sizeOfF() const
Definition: dofManager.h:610
elasticitySolver::postSolve
void postSolve()
Definition: elasticitySolver.cpp:146
elasticitySolver::addNeumannBC
void addNeumannBC(int dim, int entityId, const std::vector< double > value)
Definition: elasticitySolver.cpp:451
LaplaceTerm
Definition: terms.h:238
SPoint3::y
double y(void) const
Definition: SPoint3.h:127
SVector3::unit
SVector3 unit() const
Definition: SVector3.h:48
GaussQuadrature::GradGrad
@ GradGrad
Definition: quadratureRules.h:38
elasticitySolver::LagSpace
FunctionSpace< SVector3 > * LagSpace
Definition: elasticitySolver.h:62
dofManager< double >
elasticitySolver::elasticitySolver
elasticitySolver(int tag)
Definition: elasticitySolver.h:75
GModel::getNumRegions
std::size_t getNumRegions() const
Definition: GModel.h:344
elasticitySolver::computeL2Norm
double computeL2Norm(simpleFunction< double > *f0, simpleFunction< double > *f1, simpleFunction< double > *f2)
Definition: elasticitySolver.cpp:747
MElement
Definition: MElement.h:30
LagrangeMultiplierField::_f
simpleFunction< double > * _f
Definition: elasticitySolver.h:27
elasticitySolver::pModel
GModel * pModel
Definition: elasticitySolver.h:59
BoundaryCondition::ON_VERTEX
@ ON_VERTEX
Definition: elasticitySolver.h:40
elasticitySolver::setMesh
virtual void setMesh(const std::string &meshFileName, int dim=0)
Definition: elasticitySolver.cpp:67
BoundaryCondition::ON_FACE
@ ON_FACE
Definition: elasticitySolver.h:40
linearSystemFull.h
Field
Definition: Field.h:103
elasticitySolver::setElasticDomain
void setElasticDomain(int phys, double E, double nu)
Definition: elasticitySolver.cpp:376
SVector3::x
double x(void) const
Definition: SVector3.h:30
gLevelsetSphere
Definition: gmshLevelset.h:163
linearSystemCSRGmm
Definition: linearSystemCSR.h:176
dirichletBC::_comp
int _comp
Definition: elasticitySolver.h:47
dirichletBC
Definition: elasticitySolver.h:46
length
double length(Quaternion &q)
Definition: Camera.cpp:346
GModel::writeMSH
int writeMSH(const std::string &name, double version=2.2, bool binary=false, bool saveAll=false, bool saveParametric=false, double scalingFactor=1.0, int elementStartNum=0, int saveSinglePartition=0, bool append=false)
Definition: GModelIO_MSH.cpp:76
MElement::pnt
virtual void pnt(double u, double v, double w, SPoint3 &p) const
Definition: MElement.cpp:1072
linearSystem::getFromMatrix
virtual void getFromMatrix(int _row, int _col, scalar &val) const =0
elasticitySolver::pAssembler
dofManager< double > * pAssembler
Definition: elasticitySolver.h:61
BoundaryCondition::ON_VOLUME
@ ON_VOLUME
Definition: elasticitySolver.h:40
IntPt
Definition: GaussIntegration.h:12
quadratureRules.h
gLevelsetPlane
Definition: gmshLevelset.h:187
z
const double z
Definition: GaussQuadratureQuad.cpp:56
dofManager::getLinearSystem
virtual linearSystem< dataMat > * getLinearSystem(std::string &name)
Definition: dofManager.h:628
elasticitySolver.h
BilinearTermToScalarTerm
Definition: terms.h:77
ScalarTermConstant
Definition: terms.h:60
MPoint
Definition: MPoint.h:16
elasticitySolver::elasticFields
std::vector< elasticField > elasticFields
Definition: elasticitySolver.h:66
elasticitySolver::computeEffectiveStiffness
void computeEffectiveStiffness(std::vector< double > stiff)
Definition: elasticitySolver.cpp:588
GaussQuadrature::Val
@ Val
Definition: quadratureRules.h:38
elasticitySolver::setEdgeDisp
void setEdgeDisp(int edge, int comp, simpleFunction< double > *f)
Definition: elasticitySolver.cpp:411
SPoint3::z
double z(void) const
Definition: SPoint3.h:129
MElement::getVolumeSign
virtual int getVolumeSign()
Definition: MElement.cpp:580
neumannBC
Definition: elasticitySolver.h:52
MElement::getJacobian
virtual double getJacobian(const fullMatrix< double > &gsf, double jac[3][3]) const
Definition: MElement.cpp:868
FixNodalDofs
void FixNodalDofs(FunctionSpaceBase &space, MElement *e, Assembler &assembler, simpleFunction< typename Assembler::dataVec > &fct, FilterDof &filter)
Definition: solverAlgorithms.h:270
GModel.h
LagrangeMultiplierTerm
Definition: terms.h:339
normSq
double normSq(const SVector3 &v)
Definition: SVector3.h:148
elasticitySolver::addDirichletBC
void addDirichletBC(int dim, int entityId, int component, double value)
Definition: elasticitySolver.cpp:423
MElement::getPolynomialOrder
virtual int getPolynomialOrder() const
Definition: MElement.h:78
elasticitySolver::exportKb
void exportKb()
Definition: elasticitySolver.cpp:86
ScalarLagrangeFunctionSpaceOfElement
Definition: functionSpace.h:121
elasticitySolver::computeLagNorm
double computeLagNorm(int tag, simpleFunction< double > *f)
Definition: elasticitySolver.cpp:784
MElement::barycenterUVW
virtual SPoint3 barycenterUVW() const
Definition: MElement.cpp:550
gmshLevelset.h
functionSpace.h
linearSystem
Definition: linearSystem.h:38
GModel::getPhysicalNumber
int getPhysicalNumber(const int &dim, const std::string &name)
Definition: GModel.cpp:980
elasticitySolver::solve
void solve()
Definition: elasticitySolver.cpp:114
GaussQuadrature
Definition: quadratureRules.h:36
SolverField::f
virtual void f(MElement *ele, double u, double v, double w, ValType &val) const
Definition: solverField.h:53