SheafSystem  0.0.0.0
linear_2d.cc
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
18 // Implementation for class linear_2d
19 
20 #include "SheafSystem/linear_2d.h"
21 
22 #include "SheafSystem/assert_contract.h"
23 #include "SheafSystem/block.h"
24 #include "SheafSystem/std_cmath.h"
25 #include "SheafSystem/std_iostream.h"
26 #include "SheafSystem/std_limits.h"
27 
28 using namespace std;
29 using namespace fiber_bundle; // Workaround for MS C++ bug.
30 
31 // ===========================================================
32 // LINEAR_2D FACET
33 // ===========================================================
34 
38 {
39  // Preconditions:
40 
41  // Body:
42 
43  _basis_values = _basis_value_buffer;
44  _basis_deriv_values = _basis_deriv_value_buffer;
45  _jacobian_values = _jacobian_value_buffer;
46 
47  // Postconditions:
48 
49  ensure(invariant());
50 
51  // Exit:
52 
53  return;
54 }
55 
56 
59 linear_2d(const linear_2d& xother)
60 {
61  // Preconditions:
62 
63  // Body:
64 
65  _basis_values = _basis_value_buffer;
66  _basis_deriv_values = _basis_deriv_value_buffer;
67  _jacobian_values = _jacobian_value_buffer;
68 
69  // Postconditions:
70 
71  ensure(invariant());
72 
73  // Exit:
74 
75  return;
76 }
77 
81 {
82  // Preconditions:
83 
84  // Body:
85 
86  // Postconditions:
87 
88  return;
89 }
90 
91 // ===========================================================
92 // LINEAR_FCN_SPACE FACET
93 // ===========================================================
94 
96 int
98 dl() const
99 {
100  int result;
101 
102  // Preconditions:
103 
104 
105  // Body:
106 
107  result = DL;
108 
109  // Postconditions:
110 
111  ensure(result == 3);
112 
113  // Exit:
114 
115  return result;
116 }
117 
118 void
120 basis_at_coord(const dof_type xlocal_coord[], size_type xlocal_coord_ub)
121 {
122  // Preconditions:
123 
124  require(xlocal_coord != 0);
125  require(xlocal_coord_ub >= db());
126 
127  // Body:
128 
129  // Evaluate the interpolation functions.
130 
131  _basis_values[0] = xlocal_coord[0];
132  _basis_values[1] = xlocal_coord[1];
133  _basis_values[2] = 1.0 - (_basis_values[0] + _basis_values[1]);
134 
135  // Postconditions:
136 
137  ensure(invariant());
138 
139  // Exit:
140 
141  return;
142 }
143 
145 void
147 basis_derivs_at_coord(const dof_type xlocal_coords[],
148  size_type xlocal_coords_ub)
149 {
150  // Preconditions:
151 
152  require(xlocal_coords != 0);
153  require(xlocal_coords_ub >= 3);
154 
155  // Body:
156 
157  // Evaluate the derivatives of the interpolation functions.
158  // The derivatives are interleaved (N,r[0], N,s[0], N,t[0],
159  // N,r[1], N,s[1], N,t[1], ...).
160 
161  // Here the basis functions are in terms of barycentric coordinates.
162  // given barycentric coordinates L0, L1, L2 (L0+L1+L2=1) where we use
163  // the the convention that L2 = 1-L0-L1.
164 
165  // The basis fumctions are:
166  // N0(r, s, t) = r;
167  // N1(r, s, t) = s;
168  // N2(r, s, t) = 1-r-s;
169 
170  // Note that the basis functions are linear in r,s.
171  // Therefore the derivatives are constant and the
172  // local coordinates are not needed in their evaluation.
173 
174  // Derivatives with respect to r.
175 
176  _basis_deriv_value_buffer[ 0] = 1.0;
177  _basis_deriv_value_buffer[ 2] = 0.0;
178  _basis_deriv_value_buffer[ 4] = -1.0;
179 
180  // Derivatives with respect to s.
181 
182  _basis_deriv_value_buffer[ 1] = 0.0;
183  _basis_deriv_value_buffer[ 3] = 1.0;
184  _basis_deriv_value_buffer[ 5] = -1.0;
185 
186  // Postconditions:
187 
188  ensure(invariant());
189 
190  // Exit:
191 
192  return;
193 }
194 
195 // ===========================================================
196 // INTEGRABLE_SECTION_EVALUATOR FACET
197 // ===========================================================
198 
202 jacobian_determinant(const dof_type xcoord_dofs[],
203  size_type xcoord_dofs_ub,
204  size_type xdf,
205  const coord_type xlocal_coords[],
206  size_type xlocal_coords_ub)
207 {
208  // Precondition: xdf = 2 or xdf = 3 ?.
209 
210  // Preconditions:
211 
212  require(xcoord_dofs != 0);
213  require(xcoord_dofs_ub >= dl()*db());
214  require(xdf == 2 || xdf == 3);
215 
216  // Get the jacobian matrix.
217 
218  jacobian(xcoord_dofs, xcoord_dofs_ub, xdf, xlocal_coords, xlocal_coords_ub);
219  const value_type* jvalues = jacobian_values();
220 
221  //===========================================================================
222 
223  // Form the metric tensor g = [J]'*[J] (' == transpose).
224 
225  value_type g00 = 0.0;
226  value_type g01 = 0.0;
227  value_type g11 = 0.0;
228 
229  // Jacobian matrix has dimensions xdf x 2.
230 
231  // Just do the matrix multiplication in place (for efficiency).
232 
233  int index = 0;
234  for(int i=0; i<xdf; ++i)
235  {
236  value_type Ji0 = jvalues[index++];
237  value_type Ji1 = jvalues[index++];
238 
239  g00 += Ji0*Ji0;
240  g01 += Ji0*Ji1;
241  g11 += Ji1*Ji1;
242  }
243 
244  // Metric tensor is symmetric, so g10 = g01.
245 
246  value_type g10 = g01;
247 
248  // Evaulate the determinant of the metrix tensor
249 
250  value_type det = g00*g11 - g01*g10;
251 
252  // The "jacobian determinant" is the square root of det;
253 
254  value_type result = sqrt(fabs(det));
255 
256  //===========================================================================
257 
258  return result;
259 }
260 
264 volume(const dof_type xcoord_dofs[], size_type xcoord_dofs_ub, size_type xdf)
265 {
266  // Preconditions:
267 
269 
270  require(xcoord_dofs != 0);
271  require(xcoord_dofs_ub >= dl()*db());
272 
273  // Body:
274 
275  // Coordinates dofs are interleaved (x0, y0, x1, y1, ...).
276 
277  // Here we use the following equation for xdf == 2:
278  //
279  // 2*Volume = | 1 x0 y0 |
280  // | 1 x1 y1 |
281  // | 1 x2 y2 |
282 
283  // Note that the "volume" is actually the area
284  // (we assume a unit thickness).
285 
286  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
287 
288  // Testing:
289 
290  // coord_type local_coords[3] = {1.0/3.0, 1.0/3.0, 1.0/3.0};
291  // value_type det = jacobian_determinant(xcoord_dofs, xcoord_dofs_ub, xdf,
292  // local_coords, 3);
293  // cout << "+++++++++++++ jacobian_determinant = " << det << endl;
294 
295  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
296 
297  value_type result = 0.0;
298 
301 
302  if(xdf == 2)
303  {
304  double x0 = xcoord_dofs[0];
305  double x1 = xcoord_dofs[2];
306  double x2 = xcoord_dofs[4];
307 
308  double y0 = xcoord_dofs[1];
309  double y1 = xcoord_dofs[3];
310  double y2 = xcoord_dofs[5];
311 
312  result = 0.5*((x1-x0)*(y2-y0)-(x2-x0)*(y1-y0));
313  }
314  else
315  {
316  double sum = 0.0;
317  for(int i=0; i<xdf; ++i)
318  {
319  // The coordinate dofs are interlaced (x0, y0, z0, x1,...).
320 
321  int index = i;
322  double a0 = xcoord_dofs[index];
323  double a1 = xcoord_dofs[index+xdf];
324  double a2 = xcoord_dofs[index+2*xdf];
325 
326  double a10 = a1 - a0;
327  double a20 = a2 - a0;
328 
329  index++;
330  if(index == xdf)
331  index = 0;
332 
333  double b0 = xcoord_dofs[index];
334  double b1 = xcoord_dofs[index+xdf];
335  double b2 = xcoord_dofs[index+2*xdf];
336 
337  double b10 = b1 - b0;
338  double b20 = b2 - b0;
339 
340  double v = a10*b20 - a20*b10;
341 
342  // Sum the squares.
343 
344  sum += v*v;
345  }
346 
347  // Area is one half the square root of sum.
348 
349  result = 0.5*sqrt(sum*sum);
350  }
351 
352  // Postconditions:
353 
354  ensure(invariant());
355 
356  // Exit:
357 
358  return result;
359 }
360 
362 void
364 integrate(const dof_type xcoord_dofs[],
365  size_type xcoord_dofs_ub,
366  size_type xdf,
367  const dof_type xintegrands[],
368  size_type xintegrands_ub,
369  value_type xresult_integrals[],
370  size_type xresult_integrals_ub)
371 {
373 
374  // Preconditions:
375 
376  require(xcoord_dofs != 0);
377  require(xcoord_dofs_ub >= dl()*db());
378  require(xintegrands != 0);
379  require(xintegrands_ub >= dl());
380  require(xresult_integrals != 0);
381  require(xresult_integrals_ub > 0);
382 
383  // Body:
384 
385  double area = volume(xcoord_dofs, xcoord_dofs_ub, xdf);
386  double third_area = area/3.0;
387 
388  for(int i=0; i<xresult_integrals_ub; ++i)
389  {
390  dof_type fn = 0.0;
391  const dof_type* integrands_n = &xintegrands[i*3];
392 
393  for(int k=0; k<3; ++k)
394  {
395  fn += integrands_n[k];
396  }
397 
398  xresult_integrals[i] = fn*third_area;
399  }
400 
401  // Postconditions:
402 
403  ensure(invariant());
404 
405  // Exit:
406 
407  return;
408 }
409 
411 void
413 integrate(const dof_type xcoord_dofs[],
414  size_type xcoord_dofs_ub,
415  size_type xdf,
416  const dof_type xintegrands[],
417  value_type xresult_integrals[],
418  size_type xresult_integrals_ub)
419 {
421 
422  // Preconditions:
423 
424  require(xcoord_dofs != 0);
425  require(xcoord_dofs_ub >= dl()*db());
426  require(xintegrands != 0);
427  //require(xintegrands_ub >= dl());
428  require(xresult_integrals != 0);
429  require(xresult_integrals_ub > 0);
430 
431  // Body:
432 
433  double vol = volume(xcoord_dofs, xcoord_dofs_ub, xdf);
434  double v3 = vol/3.0;
435 
436  for(int i=0; i<xresult_integrals_ub; ++i)
437  {
438  xresult_integrals[i] = xintegrands[i]*v3;
439  }
440 
441  // Postconditions:
442 
443  ensure(invariant());
444 
445  // Exit:
446 
447  return;
448 }
449 
451 void
453 integrate(const dof_type xcoord_dofs[],
454  size_type xcoord_dofs_ub,
455  size_type xdf,
456  const dof_type xintegrand,
457  value_type xresult_integrals[],
458  size_type xresult_integrals_ub)
459 {
461 
462  // Preconditions:
463 
464  require(xcoord_dofs != 0);
465  require(xcoord_dofs_ub >= dl()*db());
466  require(xresult_integrals != 0);
467  require(xresult_integrals_ub >= dl());
468 
469  // Body:
470 
471  double vol = volume(xcoord_dofs, xcoord_dofs_ub, xdf);
472 
473  value_type value = xintegrand*vol/3.0;
474 
475  for(int i=0; i<xresult_integrals_ub; ++i)
476  {
477  xresult_integrals[i] = value;
478  }
479 
480  // Postconditions:
481 
482  ensure(invariant());
483 
484  // Exit:
485 
486  return;
487 }
488 
490 void
493  coord_type xresult[],
494  size_type xresult_ub)
495 {
496  // Preconditions:
497 
498  require((0 <= xindex) && (xindex < dof_ct()));
499  require(xresult_ub >= db());
500 
501  // Body:
502 
503  // Local coordinates of the gauss points.
504 
505  static const double d = 1.0/3.0;
506 
507  xresult[0] = d;
508  xresult[1] = d;
509  xresult[2] = d;
510 
511  // Postconditions:
512 
513  ensure(in_standard_domain(xresult, xresult_ub));
514 
515  // Exit:
516 
517  return;
518 }
519 
520 // ===========================================================
521 // DIFFERENTIABLE_SECTION_EVALUATOR FACET
522 // ===========================================================
523 
525 void
527 dxi_local(size_type xlocal_coord_index,
528  const dof_type xsource_dofs[],
529  size_type xsource_dofs_ub,
530  dof_type xresult_dofs[],
531  size_type xresult_dofs_ub) const
532 {
533  // Preconditions:
534 
535  require(xlocal_coord_index < db());
536  require(xsource_dofs != 0);
537  //require(xsource_dofs_ub >= dof_ct());
538  require(xresult_dofs != 0);
539  //require(xresult_dofs_ub >= dof_ct());
540 
541  // Body:
542 
543  // The 1st derivatives are constant for linear 2d.
544 
545  dof_type derivative = xsource_dofs[xlocal_coord_index] - xsource_dofs[2];
546 
547  for(int i=0; i<3; ++i)
548  xresult_dofs[i] = derivative;
549 
550  // Postconditions:
551 
552  // Exit:
553 
554  return;
555 }
556 
558 void
560 jacobian(const dof_type xcoord_dofs[],
561  size_type xcoord_dofs_ub,
562  size_type xdf,
563  const dof_type xlocal_coords[],
564  size_type xlocal_coords_ub)
565 {
566 
569 
570  // Preconditions:
571 
573 
574  require(xcoord_dofs != 0);
575  require(xcoord_dofs_ub >= xdf*dl());
576  require(xdf == 2 || xdf == 3);
577  require(xlocal_coords != 0);
578  require(xlocal_coords_ub >= 2);
579  require(jacobian_values() != 0);
580 
581  // Body:
582 
583  // Get the derivatives of the basis functions at the
584  // specified local coordinates.
585 
586  int local_coords_ct = 3;
587 
588  basis_derivs_at_coord(xlocal_coords, local_coords_ct);
589  const value_type* derivs = basis_deriv_values();
590 
591  // Iterate over the columns of the jacobian matrix
592  // (columns correspond to the derivatives w.r.t. the local coordinates.)
593 
594  for(int i=0; i<local_coords_ct; ++i)
595  {
596  // Iterate over the rows of the jacobian matrix
597  // (rows correspond to the global coordinates.)
598 
599  for(int j=0; j<xdf; ++j)
600  {
601  // Iterate over the nodes and sum the product of the derivatives and
602  // the global nodal coordinates.
603 
604  value_type sum = 0.0;
605 
606  for(int k=0; k<dl(); ++k)
607  {
608  // Derivatives and coordinate dofs are "interleaved".
609 
610  value_type deriv = derivs[local_coords_ct*k+i];
611  value_type coord = xcoord_dofs[xdf*k+j];
612 
613  sum += deriv*coord;
614 
615  cout << "++++++++++++++++++++++++++++++++++" << endl;
616  cout << " deriv = " << deriv << endl;
617  cout << " coord = " << coord << endl;
618  cout << " sum = " << sum << endl;
619  cout << "++++++++++++++++++++++++++++++++++" << endl;
620  }
621 
622  // Store the sum in the appropriate location in the Jacobian matrix.
623 
624  int ij = local_coords_ct*j+i;
625  _jacobian_values[ij] = sum;
626  }
627  }
628 
629  // Postconditions:
630 
631  ensure(invariant());
632 
633  // Exit:
634 
635  return;
636 }
637 
638 // ===========================================================
639 // DOMAIN FACET
640 // ===========================================================
641 
643 int
645 db() const
646 {
647  int result;
648 
649  // Preconditions:
650 
651 
652  // Body:
653 
654  result = 2;
655 
656  // Postconditions:
657 
658  ensure(result == 2);
659 
660  // Exit:
661 
662  return result;
663 }
664 
665 
667 void
670  coord_type xresult[],
671  size_type xresult_ub) const
672 {
673  // Preconditions:
674 
675  require((0 <= xindex) && (xindex < dof_ct()));
676  require(xresult_ub >= db());
677 
678  // Body:
679 
680  static const coord_type lcoords[3][2] =
681  {
682  {
683  1.0, 0.0
684  }
685  , {0.0, 1.0}, {0.0, 0.0}
686  } ;
687 
688  xresult[0] = lcoords[xindex][0];
689  xresult[1] = lcoords[xindex][1];
690 
691  // Postconditions:
692 
693  ensure(in_standard_domain(xresult, xresult_ub));
694 
695  // Exit:
696 
697  return;
698 }
699 
701 void
703 center(coord_type xresult[], size_type xresult_ub) const
704 {
705  // Preconditions:
706 
707  require(xresult != 0);
708  require(xresult_ub >= db());
709 
710  // Body:
711 
712  static coord_type one_third =
713  static_cast<coord_type>(1.0)/static_cast<coord_type>(3.0);
714 
715  xresult[0] = one_third;
716  xresult[1] = one_third;
717 
718  // Postconditions:
719 
720 
721  // Exit:
722 
723  return;
724 }
725 
727 void
729 edge_center(pod_index_type xi, coord_type xresult[], size_type xresult_ub) const
730 {
731  // Preconditions:
732 
733  require(xresult != 0);
734  require(xresult_ub >= db());
735 
736  // Body:
737 
738  // Edge indexing: edges are numbered 0, 1, 2 going CCW from
739  // vertex 0. This numbering is consistent with the usual
740  // connectivity ordering for any 2D cell, but conflicts with
741  // the natural edge indexing of simplices in barycentric coordinates,
742  // in which the i-th edge is oppposite the i-th vertex.
743  //
744  // Barycentric coordinate view: i-th edge is opposite
745  // i-th vertex, i-th coordinate axis is perpendicular
746  // to ith edge, 0 at i-th edge, 1 at i-th vertex.
747  //
748  //
749  // 2
750  // * *
751  // edge * *
752  // 1 * *
753  // * * edge 0
754  // * *
755  // * *
756  // * *
757  // 0***************1
758  // edge 2
759  //
760  //
761  // Vector coordinate view:
762  //
763  //
764  // ^
765  // v
766  //
767  // 1
768  // * *
769  // * *
770  // edge * * edge
771  // 1 * * 0
772  // * *
773  // * *
774  // 2*************0 -> u
775  // edge 2
776  //
777  //
778 
779  static const coord_type lcoords[3][2] =
780  {
781  {
782  0.5, 0.5
783  },
784  { 0.0, 0.5 },
785  { 0.5, 0.0 }
786  };
787 
788  xresult[0] = lcoords[xi][0];
789  xresult[1] = lcoords[xi][1];
790 
791  // Postconditions:
792 
793 
794  // Exit:
795 
796  return;
797 }
798 
800 void
803 {
804  // Preconditions:
805 
806  require(precondition_of(center(xresult.base(), xresult.ub())));
807 
808  // Body:
809 
810  edge_center(xi, xresult.base(), xresult.ub());
811  xresult.set_ct(db());
812 
813  // Postconditions:
814 
815  ensure(postcondition_of(edge_center(xresult.base(), xresult.ub())));
816  ensure(xresult.ct() == db());
817 
818  // Exit:
819 
820  return;
821 }
822 
824 bool
826 in_standard_domain(const dof_type xlocal_coords[],
827  size_type xlocal_coords_ub) const
828 {
829  // Preconditions:
830 
831  require(xlocal_coords != 0);
832  require(xlocal_coords_ub >= 2);
833 
834  // Body:
835 
836  dof_type u = xlocal_coords[0];
837  dof_type v = xlocal_coords[1];
838 
839  // "Extend" the bounds by the dof type epsilon (attempting
840  // to ensure that the boundary is included in the domain).
841 
842  dof_type zero = 0.0 - 1000.0*numeric_limits<dof_type>::epsilon();
843  dof_type one = 1.0 + 1000.0*numeric_limits<dof_type>::epsilon();
844 
845  // bool result = (u >= zero) && (u <= one) && (v >= zero) && (v <= one);
846  bool result = (u >= zero) && (u <= one) && (v >= zero) && (v <= one - u);
847 
848  // Postconditions:
849 
850  // Exit:
851 
852  return result;
853 
854 }
855 
856 // ===========================================================
857 // EVALUATION FACET
858 // ===========================================================
859 
861 void
863 coord_at_value(const dof_type xdofs[],
864  size_type xdofs_ub,
865  const dof_type xglobal_coords[],
866  size_type xglobal_coord_ub,
867  dof_type xlocal_coords[],
868  size_type xlocal_coords_ub) const
869 {
870  // Preconditions:
871 
872  require(xdofs != 0);
873  require(xdofs_ub >= 6);
874  require(xglobal_coords != 0);
875  require(xglobal_coord_ub >= 2);
876  require(xlocal_coords != 0);
877  require(xlocal_coords_ub >= 2);
878 
879  // Body:
880 
881  // Dofs are assumed to be interleaved (x0. y0, x1, y1, x2, y2).
882 
883  dof_type x0 = xdofs[0];
884  dof_type x1 = xdofs[2];
885  dof_type x2 = xdofs[4];
886 
887  dof_type y0 = xdofs[1];
888  dof_type y1 = xdofs[3];
889  dof_type y2 = xdofs[5];
890 
891  dof_type x_global = xglobal_coords[0];
892  dof_type y_global = xglobal_coords[1];
893 
894  double a0 = x1*y2 - x2*y1;
895  double a1 = x2*y0 - x0*y2;
896  double a2 = x0*y1 - x1*y0;
897 
898  double b0 = y1 - y2;
899  double b1 = y2 - y0;
900  //double b2 = y0 - y1;
901 
902  double c0 = x2 - x1;
903  double c1 = x0 - x2;
904  //double c2 = x1 - x0;
905 
906  double area_x_2 = a0 + a1 + a2;
907 
908  double basis0 = (a0 + b0*x_global + c0*y_global) / area_x_2;
909  double basis1 = (a1 + b1*x_global + c1*y_global) / area_x_2;
910  //double basis2 = (a2 + b2*x_global + c2*y_global) / area_x_2;
911 
912  //double basis2 = 1.0 - (basis0 + basis1);
913 
914 #ifdef DIAGNOSTIC_OUTPUT
915 
916  cout << "basis0 = " << basis0 << endl;
917  cout << "basis1 = " << basis1 << endl;
918  cout << "basis2 = " << 1.0 - (basis0 + basis1) << endl;
919 #endif
920 
921  // Return 2 local (area) coordinates and later generate the third
922  // from the fact that they sum to 1 (ie: basis0 + basis1 + basis2 = 1).
923 
924  xlocal_coords[0] = basis0;
925  xlocal_coords[1] = basis1;
926 
927  // Return non null only if the search point is inside the element
928  // or on the element boundary.
929 
930  //if((basis0 >= 0.0) && (basis1 >= 0.0) && (basis2 >= 0.0))
931  // result = xlocal_coords;
932 
933  // Postconditions:
934 
935  ensure(invariant());
936 
937  //ensure(result != 0 ? result == xlocal_coords : true);
938 
940 
941  // ensure(unexecutable(result != 0
942  // ? value_at_coord_ua(xdofs, xdofs_ub, xcoords, xcoords_ub) == xvalue
943  // : true));
944 
945  //return result;
946 
947 }
948 
949 // ===========================================================
950 // ANY FACET
951 // ===========================================================
952 
956 clone() const
957 {
958  linear_2d* result;
959 
960  // Preconditions:
961 
962  // Body:
963 
964  result = new linear_2d();
965 
966  // Postconditions:
967 
968  ensure(result != 0);
969  //ensure(invariant());
970  ensure(result->invariant());
971  ensure(is_same_type(result));
972 
973  return result;
974 }
975 
976 
981 {
982  // Preconditions:
983 
984  require(is_ancestor_of(&xother));
985 
986  // Body:
987 
989 
990  not_implemented();
991 
992  // Postconditions:
993 
994  ensure(invariant());
995 
996  return *this;
997 }
998 
1002 operator=(const linear_2d& xother)
1003 {
1004 
1005  // Preconditions:
1006 
1007  require(is_ancestor_of(&xother));
1008 
1009  // Body:
1010 
1011  not_implemented();
1012 
1013  // Postconditions:
1014 
1015  ensure(invariant());
1016 
1017  // Exit:
1018 
1019  return *this;
1020 }
1021 
1022 
1024 bool
1026 invariant() const
1027 {
1028  bool result = true;
1029 
1030  // Preconditions:
1031 
1032  // Body:
1033 
1034  // Must satisfy base class invariant.
1035 
1036  result = result && linear_fcn_space::invariant();
1037 
1038  if(invariant_check())
1039  {
1040  // Prevent recursive calls to invariant.
1041 
1042  disable_invariant_check();
1043 
1044  invariance(basis_values() != 0);
1045 
1046  // Finished, turn invariant checking back on.
1047 
1048  enable_invariant_check();
1049  }
1050 
1051  // Postconditions:
1052 
1053  return result;
1054 }
1055 
1057 bool
1059 is_ancestor_of(const any* xother) const
1060 {
1061 
1062  // Preconditions:
1063 
1064  require(xother != 0);
1065 
1066  // Body:
1067 
1068  // True if other conforms to this
1069 
1070  bool result = dynamic_cast<const linear_2d*>(xother) != 0;
1071 
1072  // Postconditions:
1073 
1074  return result;
1075 
1076 }
1077 
1078 // ===========================================================
1079 // PRIVATE MEMBERS
1080 // ===========================================================
SHEAF_DLL_SPEC void sqrt(const sec_at0 &x0, sec_at0 &xresult, bool xauto_access)
Compute sqrt of x0 (sqrt(x0)) (pre-allocated version).
Definition: sec_at0.cc:1556
virtual void center(coord_type xresult[], size_type xresult_ub) const
The local coordinates at the center of the evaluator.
Definition: linear_2d.cc:703
index_type ub() const
The upper bound on the storage array. The number of items current allocated in the storage array...
size_type ct() const
The number of items currently in use.
virtual bool is_ancestor_of(const any *xother) const
Conformance test; true if other conforms to this.
Definition: linear_2d.cc:1059
virtual int dl() const
The dimension of this function space.
Definition: linear_2d.cc:98
STL namespace.
virtual ~linear_2d()
Destructor.
Definition: linear_2d.cc:80
sec_vd_dof_type dof_type
The type of degree of freedom.
virtual bool in_standard_domain(const dof_type xlocal_coords[], size_type xlocal_coords_ub) const
Return true if the specified local coordinates are in the "standard" domain; otherwise return false...
Definition: linear_2d.cc:826
virtual void coord_at_value(const dof_type xdofs[], size_type xdofs_ub, const dof_type xglobal_coords[], size_type xglobal_coord_ub, dof_type xlocal_coords[], size_type xlocal_coords_ub) const
The local coordinates of a point at which the field has the value xvalue. The dofs are assumed to be ...
Definition: linear_2d.cc:863
void gauss_point(pod_index_type xindex, coord_type xresult[], size_type xresult_ub)
The local coordinates of the gauss point with index xindex.
Definition: linear_2d.cc:492
linear_2d()
Default constructor.
Definition: linear_2d.cc:37
Abstract base class with useful features for all objects.
Definition: any.h:39
virtual void dxi_local(size_type xlocal_coord_index, const dof_type xsource_dofs[], size_type xsource_dofs_ub, dof_type xresult_dofs[], size_type xresult_dofs_ub) const
First partial derivative of this with respect to local coordinate xlocal_coord_index.
Definition: linear_2d.cc:527
virtual linear_2d * clone() const
Virtual constructor, creates a new instance of the same type as this.
Definition: linear_2d.cc:956
pointer_type base() const
The underlying storage array.
virtual int db() const
The base dimension; the dimension of the local coordinates (independent variable).
Definition: linear_2d.cc:645
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
void edge_center(pod_index_type xi, coord_type xresult[], size_type xresult_ub) const
The local cordinates of the xi-th edge.
Definition: linear_2d.cc:729
chart_point_coord_type coord_type
The type of local coordinate; the scalar type for the local coordinate vector space.
vd_value_type value_type
The type of component in the value; the scalar type in the range vector space.
void jacobian(const dof_type xcoord_dofs[], size_type xcoord_dofs_ub, size_type xdf, const dof_type xlocal_coords[], size_type xlocal_coords_ub)
Jacobian matrix.
Definition: linear_2d.cc:560
SHEAF_DLL_SPEC void fabs(const sec_at0 &x0, sec_at0 &xresult, bool xauto_access)
Compute fabs of x0 (fabs(x0)) (pre-allocated version).
Definition: sec_at0.cc:1331
An abstract local section evaluator; a map from {local coordinates x dofs} to section value...
value_type volume(const dof_type xcoord_dofs[], size_type xcoord_dofs_ub, size_type xdf)
Volume for specified coordinate dofs xcoord_dofs and fiber space dimension xdf.
Definition: linear_2d.cc:264
void basis_derivs_at_coord(const dof_type xlocal_coord[], size_type xlocal_coord_ub)
Computes the value of the derivatives of each basis function at local coordinates xlocal_coord...
Definition: linear_2d.cc:147
virtual linear_2d & operator=(const section_evaluator &xother)
Assignment operator.
Definition: linear_2d.cc:980
A section evaluator using linear interpolation over a triangular 2D domain.
Definition: linear_2d.h:39
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
virtual void integrate(const dof_type xcoord_dofs[], size_type xcoord_dofs_ub, size_type xdf, const dof_type xintegrands[], size_type xintegrands_ub, value_type xresult_integrals[], size_type xresult_integrals_ub)
Computes the value of the integral of the integrand array...
Definition: linear_2d.cc:364
virtual void local_coordinates(pod_index_type xindex, coord_type xresult[], size_type xresult_ub) const
The local coordinates of the dof with local index xindex.
Definition: linear_2d.cc:669
value_type jacobian_determinant(const dof_type xcoord_dofs[], size_type xcoord_dofs_ub, size_type xdf, const coord_type xlocal_coords[], size_type xlocal_coords_ub)
Determinant of Jacobian matrix (square)
Definition: linear_2d.cc:202
An auto_block with a no-initialization initialization policy.
Namespace for the fiber_bundles component of the sheaf system.
virtual void basis_at_coord(const dof_type xlocal_coord[], size_type xlocal_coord_ub)
Computes the value of each basis function at local coordinates xlocal_coord.
Definition: linear_2d.cc:120
virtual bool invariant() const
Class invariant.
Definition: linear_2d.cc:1026