20 #include "SheafSystem/linear_3d.h" 22 #include "SheafSystem/assert_contract.h" 23 #include "SheafSystem/std_cmath.h" 24 #include "SheafSystem/std_iostream.h" 25 #include "SheafSystem/std_limits.h" 42 _basis_values = _basis_value_buffer;
43 _basis_deriv_values = _basis_deriv_value_buffer;
44 _jacobian_values = _jacobian_value_buffer;
64 _basis_values = _basis_value_buffer;
65 _basis_deriv_values = _basis_deriv_value_buffer;
66 _jacobian_values = _jacobian_value_buffer;
95 double a10,
double a11,
double a12,
96 double a20,
double a21,
double a22)
98 double result = a00*(a11*a22-a12*a21)
99 - a10*(a01*a22-a02*a21)
100 + a20*(a01*a12-a02*a11);
139 require(xlocal_coord != 0);
140 require(xlocal_coord_ub >= db());
146 _basis_values[0] = xlocal_coord[0];
147 _basis_values[1] = xlocal_coord[1];
148 _basis_values[2] = xlocal_coord[2];
149 _basis_values[3] = 1.0 - (_basis_values[0] + _basis_values[1] + _basis_values[2]);
168 require(xlocal_coords != 0);
169 require(xlocal_coords_ub >= 3);
193 _basis_deriv_value_buffer[ 0] = 1.0;
194 _basis_deriv_value_buffer[ 3] = 0.0;
195 _basis_deriv_value_buffer[ 6] = 0.0;
196 _basis_deriv_value_buffer[ 9] = -1.0;
200 _basis_deriv_value_buffer[ 1] = 0.0;
201 _basis_deriv_value_buffer[ 4] = 1.0;
202 _basis_deriv_value_buffer[ 7] = 0.0;
203 _basis_deriv_value_buffer[10] = -1.0;
207 _basis_deriv_value_buffer[ 2] = 0.0;
208 _basis_deriv_value_buffer[ 5] = 0.0;
209 _basis_deriv_value_buffer[ 8] = 1.0;
210 _basis_deriv_value_buffer[11] = -1.0;
238 require(xcoord_dofs != 0);
239 require(xcoord_dofs_ub >= dl()*db());
240 require(xdf == 2 || xdf == 3);
244 jacobian(xcoord_dofs, xcoord_dofs_ub, xdf, xlocal_coords, xlocal_coords_ub);
245 const value_type* jvalues = jacobian_values();
263 for(
int i=0; i<xdf; ++i)
286 - g10*(g01*g22-g02*g21)
287 + g20*(g01*g12-g02*g11);
330 value_type result = determinant_3x3(x1, y1, z1, x2, y2, z2, x3, y3, z3)
331 - determinant_3x3(x0, y0, z0, x2, y2, z2, x3, y3, z3)
332 + determinant_3x3(x0, y0, z0, x1, y1, z1, x3, y3, z3)
333 - determinant_3x3(x0, y0, z0, x1, y1, z1, x2, y2, z2);
355 require(xcoord_dofs != 0);
356 require(xcoord_dofs_ub >= dl()*db());
357 require(xintegrands != 0);
358 require(xintegrands_ub >= dl());
359 require(xresult_integrals != 0);
360 require(xresult_integrals_ub > 0);
364 double vol = volume(xcoord_dofs, xcoord_dofs_ub, 3);
365 double quarter_vol = 0.25*vol;
367 for(
int i=0; i<xresult_integrals_ub; ++i)
370 const dof_type* integrands_n = &xintegrands[i*4];
372 for(
int k=0; k<4; ++k)
374 fn += integrands_n[k];
377 xresult_integrals[i] = fn*quarter_vol;
433 require(xcoord_dofs != 0);
434 require(xcoord_dofs_ub >= dl()*db());
435 require(xresult_integrals != 0);
436 require(xresult_integrals_ub >= dl());
440 double vol = volume(xcoord_dofs, xcoord_dofs_ub, 3);
444 for(
int i=0; i<xresult_integrals_ub; ++i)
446 xresult_integrals[i] = value;
502 require((0 <= xindex) && (xindex < dof_ct()));
503 require(xresult_ub >= db());
509 static const double d = 0.25;
518 ensure(in_standard_domain(xresult, xresult_ub));
540 require(xlocal_coord_index < db());
541 require(xsource_dofs != 0);
543 require(xresult_dofs != 0);
550 dof_type derivative = xsource_dofs[xlocal_coord_index] - xsource_dofs[3];
552 for(
int i=0; i<4; ++i)
553 xresult_dofs[i] = derivative;
575 require(xcoord_dofs != 0);
576 require(xcoord_dofs_ub >= xdf*dl());
577 require(xdf == 2 || xdf == 3);
578 require(xlocal_coords != 0);
579 require(xlocal_coords_ub >= 2);
580 require(jacobian_values() != 0);
587 int local_coords_ct = 3;
589 basis_derivs_at_coord(xlocal_coords, local_coords_ct);
590 const value_type* derivs = basis_deriv_values();
595 for(
int i=0; i<local_coords_ct; ++i)
600 for(
int j=0; j<xdf; ++j)
607 for(
int k=0; k<dl(); ++k)
611 value_type deriv = derivs[local_coords_ct*k+i];
616 cout <<
"++++++++++++++++++++++++++++++++++" << endl;
617 cout <<
" deriv = " << deriv << endl;
618 cout <<
" coord = " << coord << endl;
619 cout <<
" sum = " << sum << endl;
620 cout <<
"++++++++++++++++++++++++++++++++++" << endl;
625 int ij = local_coords_ct*j+i;
626 _jacobian_values[ij] = sum;
676 require((0 <= xindex) && (xindex < dof_ct()));
677 require(xresult_ub >= db());
686 , {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}, {0.0, 0.0, 0.0}
689 xresult[0] = lcoords[xindex][0];
690 xresult[1] = lcoords[xindex][1];
691 xresult[2] = lcoords[xindex][2];
695 ensure(in_standard_domain(xresult, xresult_ub));
709 require(xresult != 0);
710 require(xresult_ub >= db());
717 xresult[0] = one_fourth;
718 xresult[1] = one_fourth;
719 xresult[2] = one_fourth;
737 require(xlocal_coords != 0);
738 require(xlocal_coords_ub >= 2);
749 dof_type zero = 0.0 - 1000.0*numeric_limits<dof_type>::epsilon();
750 dof_type one = 1.0 + 1000.0*numeric_limits<dof_type>::epsilon();
752 bool result = (u >= zero) && (u <= one) &&
753 (v >= zero) && (v <= one) &&
754 (w >= zero) && (w <= one);
781 require(xdofs_ub >= 9);
782 require(xglobal_coords != 0);
783 require(xglobal_coord_ub >= 3);
784 require(xlocal_coords != 0);
785 require(xlocal_coords_ub >= 3);
809 dof_type x_global = xglobal_coords[0];
810 dof_type y_global = xglobal_coords[1];
811 dof_type z_global = xglobal_coords[2];
815 double a01 = x0*y1-x1*y0;
816 double a02 = x0*y2-x2*y0;
817 double a03 = x0*y3-x3*y0;
818 double a12 = x1*y2-x2*y1;
819 double a13 = x1*y3-x3*y1;
820 double a23 = x2*y3-x3*y2;
873 double z00 = a23*z1 + a31*z2 + a12*z3;
874 double z01 = b23*z1 + b31*z2 + b12*z3;
875 double z02 = c32*z1 + c13*z2 + c21*z3;
876 double z03 = a32 + a21 + a13;
878 double z10 = a32*z0 + a03*z2 + a20*z3;
879 double z11 = b32*z0 + b03*z2 + b20*z3;
880 double z12 = c23*z0 + c30*z2 + c02*z3;
881 double z13 = a23 + a02 + a30;
883 double z20 = a13*z0 + a30*z1 + a01*z3;
884 double z21 = b13*z0 + b30*z1 + b01*z3;
885 double z22 = c31*z0 + c03*z1 + c10*z3;
886 double z23 = a31 + a10 + a03;
888 double z30 = a21*z0 + a02*z1 + a10*z2;
902 double det = z00 + z10 + z20 + z30;
906 double shape0 = (z00 + z01*x_global + z02*y_global + z03*z_global) / det;
907 double shape1 = (z10 + z11*x_global + z12*y_global + z13*z_global) / det;
908 double shape2 = (z20 + z21*x_global + z22*y_global + z23*z_global) / det;
912 double shape3 = 1.0 - (shape0 + shape1 + shape2);
923 xlocal_coords[0] = shape0;
924 xlocal_coords[1] = shape1;
925 xlocal_coords[2] = shape2;
959 ensure(is_same_type(result));
974 require(is_ancestor_of(&xother));
995 require(is_ancestor_of(&xother));
1003 ensure(invariant());
1023 result = result && linear_fcn_space::invariant();
1025 if(invariant_check())
1029 disable_invariant_check();
1031 invariance(basis_values() != 0);
1035 enable_invariant_check();
1051 require(xother != 0);
1057 bool result =
dynamic_cast<const linear_3d*
>(xother) != 0;
virtual linear_3d * clone() const
Virtual constructor, creates a new instance of the same type as this.
SHEAF_DLL_SPEC void sqrt(const sec_at0 &x0, sec_at0 &xresult, bool xauto_access)
Compute sqrt of x0 (sqrt(x0)) (pre-allocated version).
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.
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)
virtual bool is_ancestor_of(const any *xother) const
Conformance test; true if other conforms to this.
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...
sec_vd_dof_type dof_type
The type of degree of freedom.
A section evaluator using linear interpolation over a tetrahedral 3D domain.
virtual bool invariant() const
Class invariant.
Abstract base class with useful features for all objects.
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...
virtual int db() const
The base dimension; the dimension of the local coordinates (independent variable).
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.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
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.
chart_point_coord_type coord_type
The type of local coordinate; the scalar type for the local coordinate vector space.
linear_3d()
Default constructor.
vd_value_type value_type
The type of component in the value; the scalar type in the range vector space.
SHEAF_DLL_SPEC void fabs(const sec_at0 &x0, sec_at0 &xresult, bool xauto_access)
Compute fabs of x0 (fabs(x0)) (pre-allocated version).
virtual void dxi_local(size_type xcrd, const dof_type xsource_dofs[], size_type xsource_dofs_ub, dof_type xresult_dofs[], size_type xresult_dofs_ub) const
1st partial derivative of this with respect to local coordinate xcrd.
An abstract local section evaluator; a map from {local coordinates x dofs} to section value...
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 ...
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.
virtual void center(coord_type xresult[], size_type xresult_ub) const
The local coordinates at the center of the evaluator.
int_type pod_index_type
The plain old data index type.
void basis_derivs_at_coord(const dof_type xlocal_coords[], size_type xlocal_coords_ub)
Computes the value of the derivatives of each basis function at local coordinates xlocal_coords...
virtual linear_3d & operator=(const section_evaluator &xother)
Assignment operator.
virtual int dl() const
The dimension of this function space.
virtual ~linear_3d()
Destructor.
Namespace for the fiber_bundles component of the sheaf system.
double determinant_3x3(double a00, double a01, double a02, double a10, double a11, double a12, double a20, double a21, double a22)
///
void gauss_point(pod_index_type xindex, coord_type xresult[], size_type xresult_ub)
The local coordinates of the gauss point with index xindex.