v0.14.0
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
RollerRigidBody Struct Reference

#include <users_modules/multifield_plasticity/src/RigidBodies.hpp>

Inheritance diagram for RollerRigidBody:
[legend]
Collaboration diagram for RollerRigidBody:
[legend]

Public Member Functions

 RollerRigidBody (VectorDouble c_coords, VectorDouble roller_disp, int id)
 
MoFEMErrorCode getRollerDataForTag ()
 
Tensor1< double, 3 > getNormal (Tensor1< TPack3, 3 > &t_coords, Tensor1< TPack1, 3 > &t_disp)
 
Tensor1< double, 3 > getNormal (Tensor1< TPack3, 3 > &t_coords, Tensor1< double, 3 > &t_disp)
 
Tensor1< double, 3 > getNormal (Tensor1< double, 3 > &t_coords, Tensor1< double, 3 > &t_disp)
 
Tensor2< double, 3, 3 > getDiffNormal (Tensor1< TPack3, 3 > &t_coords, Tensor1< TPack1, 3 > &t_disp, Tensor1< TPack1, 3 > &t_normal)
 
double getGap (Tensor1< TPack3, 3 > &t_coords)
 
Tensor1< double, 3 > getdGap (Tensor1< TPack3, 3 > &t_coords, Tensor1< TPack1, 3 > &t_normal)
 
MoFEMErrorCode getBodyOptions ()
 
template<typename T1 , typename T2 >
Tensor1< double, 3 > & getNormalImpl (Tensor1< T1, 3 > &t_coords, Tensor1< T2, 3 > &t_disp)
 
template<typename T1 , typename T2 , typename T3 >
Tensor2< double, 3, 3 > getDiffNormalImpl (Tensor1< T1, 3 > &t_coords, Tensor1< T2, 3 > &t_disp, Tensor1< T3, 3 > &t_normal)
 
template<typename T1 >
double getGapImpl (Tensor1< T1, 3 > &t_coords)
 
template<typename T1 , typename T2 >
Tensor1< double, 3 > getdGapImpl (Tensor1< T1, 3 > &t_coords, Tensor1< T2, 3 > &t_normal)
 
- Public Member Functions inherited from RigidBodyData
 RigidBodyData (VectorDouble c_coords, VectorDouble roller_disp, int id)
 
 RigidBodyData ()=delete
 
virtual ~RigidBodyData ()
 
virtual Tensor1< double, 3 > getNormal (Tensor1< TPack3, 3 > &t_coords, Tensor1< TPack1, 3 > &t_disp)=0
 
virtual Tensor1< double, 3 > getNormal (Tensor1< TPack3, 3 > &t_coords, Tensor1< double, 3 > &t_disp)=0
 
virtual Tensor1< double, 3 > getNormal (Tensor1< double, 3 > &t_coords, Tensor1< double, 3 > &t_disp)=0
 
virtual Tensor2< double, 3, 3 > getDiffNormal (Tensor1< TPack3, 3 > &t_coords, Tensor1< TPack1, 3 > &t_disp, Tensor1< TPack1, 3 > &t_normal)=0
 
virtual double getGap (Tensor1< TPack3, 3 > &t_coords)=0
 
virtual Tensor1< double, 3 > getdGap (Tensor1< TPack3, 3 > &t_coords, Tensor1< TPack1, 3 > &t_normal)=0
 
virtual MoFEMErrorCode getBodyOptions ()=0
 
MoFEMErrorCode computeRotationMatrix ()
 
Tensor1< double, 3 > getBodyOffset ()
 
template<typename T1 , typename T2 >
Tensor1< double, 3 > & getPointCoords (Tensor1< T1, 3 > &t_coords, Tensor1< T2, 3 > &t_disp)
 
MoFEMErrorCode saveBasicDataOnTag (moab::Interface &moab_debug, EntityHandle &vertex)
 
virtual MoFEMErrorCode getRollerDataForTag ()=0
 

Public Attributes

double angleA
 
double angleB
 
double rAdius
 
double fIllet
 
double torusRadius
 
double hEight
 
double coneRadiusA
 
double coneTopRadiusA
 
double coneOffsetA
 
double coneRadiusB
 
double coneTopRadiusB
 
double coneOffsetB
 
- Public Attributes inherited from RigidBodyData
const int iD
 
Index< 'i', 3 > i
 
Index< 'j', 3 > j
 
Index< 'k', 3 > k
 
VectorDouble originCoords
 
VectorDouble rollerDisp
 
VectorDouble BodyDispScaled
 
VectorDouble BodyDirectionScaled
 
double gAp
 
Tensor1< double, 3 > tNormal
 
Tensor1< double, 3 > dGap
 
Tensor1< double, 3 > pointCoords
 
Tensor1< double, 3 > closestPoint
 
Tensor1< double, 3 > defaultOrientation
 
Tensor1< double, 3 > oRientation
 
Tensor2< double, 3, 3 > rotationMat
 
Tensor2< double, 3, 3 > diffNormal
 
boost::shared_ptr< TimeAccelerogrammethodOpForRollerPosition
 
boost::shared_ptr< TimeAccelerogrammethodOpForRollerDirection
 
int bodyType
 
array< double, 9 > dataForTags
 

Additional Inherited Members

- Public Types inherited from RigidBodyData
using TPack3 = PackPtr< double *, 3 >
 
using TPack1 = PackPtr< double *, 1 >
 

Detailed Description

Definition at line 741 of file RigidBodies.hpp.

Constructor & Destructor Documentation

◆ RollerRigidBody()

RollerRigidBody::RollerRigidBody ( VectorDouble  c_coords,
VectorDouble  roller_disp,
int  id 
)
inline

Definition at line 758 of file RigidBodies.hpp.

759 : RigidBodyData(c_coords, roller_disp, id) {}
RigidBodyData()=delete

Member Function Documentation

◆ getBodyOptions()

MoFEMErrorCode RollerRigidBody::getBodyOptions ( )
inlinevirtual

Implements RigidBodyData.

Definition at line 801 of file RigidBodies.hpp.

801 {
803 PetscBool rflg;
804 int nb_dirs = 3;
805
806 CHKERR PetscOptionsBegin(PETSC_COMM_WORLD, "", "", "");
807 string param = "-radius" + to_string(iD);
808 CHKERR PetscOptionsScalar(param.c_str(), "set roller radius", "", rAdius,
809 &rAdius, PETSC_NULL);
810 param = "-fillet" + to_string(iD);
811 CHKERR PetscOptionsScalar(param.c_str(), "set torus small radius", "",
812 fIllet, &fIllet, PETSC_NULL);
813 param = "-angle_a" + to_string(iD);
814 CHKERR PetscOptionsScalar(param.c_str(), "set roller angle of attack", "",
815 angleA, &angleA, PETSC_NULL);
816 param = "-angle_b" + to_string(iD);
817 CHKERR PetscOptionsScalar(param.c_str(), "set roller back angle", "",
818 angleB, &angleB, PETSC_NULL);
819 hEight = 3 * fIllet;
820 param = "-height" + to_string(iD);
821 CHKERR PetscOptionsScalar(param.c_str(), "set roller height (optional)", "",
822 hEight, &hEight, PETSC_NULL);
823 param = "-direction" + to_string(iD);
824 CHKERR PetscOptionsGetRealArray(NULL, NULL, param.c_str(), &oRientation(0),
825 &nb_dirs, &rflg);
826 ierr = PetscOptionsEnd();
827 CHKERRG(ierr);
828 if (rflg)
830
831 // cP = make_shared<ArbitrarySurfaceData>(rAdius, fIllet);
832
834 angleA = std::tan(angleA * M_PI / 180);
835 angleB = std::tan(angleB * M_PI / 180);
836
837 coneRadiusA = torusRadius + fIllet / sqrt(1 + angleA * angleA);
839 coneOffsetA = -fIllet * angleA / sqrt(1 + angleA * angleA) - hEight / 2.;
840
843 coneOffsetB = fIllet * angleB / sqrt(1 + angleB * angleB) + hEight / 2.;
844
846 }
static PetscErrorCode ierr
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:483
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
#define CHKERR
Inline error check.
Definition: definitions.h:535
PetscErrorCode PetscOptionsGetRealArray(PetscOptions *, const char pre[], const char name[], PetscReal dval[], PetscInt *nmax, PetscBool *set)
Tensor1< double, 3 > oRientation
Definition: RigidBodies.hpp:44
MoFEMErrorCode computeRotationMatrix()
Definition: RigidBodies.hpp:91
const int iD
Definition: RigidBodies.hpp:30

◆ getdGap()

Tensor1< double, 3 > RollerRigidBody::getdGap ( Tensor1< TPack3, 3 > &  t_coords,
Tensor1< TPack1, 3 > &  t_normal 
)
inlinevirtual

Implements RigidBodyData.

Definition at line 796 of file RigidBodies.hpp.

797 {
798 return getdGapImpl(t_coords, t_normal);
799 }
Tensor1< double, 3 > getdGapImpl(Tensor1< T1, 3 > &t_coords, Tensor1< T2, 3 > &t_normal)

◆ getdGapImpl()

template<typename T1 , typename T2 >
Tensor1< double, 3 > RollerRigidBody::getdGapImpl ( Tensor1< T1, 3 > &  t_coords,
Tensor1< T2, 3 > &  t_normal 
)
inline

Definition at line 984 of file RigidBodies.hpp.

985 {
986 return dGap;
987 };
Tensor1< double, 3 > dGap
Definition: RigidBodies.hpp:40

◆ getDiffNormal()

Tensor2< double, 3, 3 > RollerRigidBody::getDiffNormal ( Tensor1< TPack3, 3 > &  t_coords,
Tensor1< TPack1, 3 > &  t_disp,
Tensor1< TPack1, 3 > &  t_normal 
)
inlinevirtual

Implements RigidBodyData.

Definition at line 786 of file RigidBodies.hpp.

788 {
789 return getDiffNormalImpl(t_coords, t_disp, t_normal);
790 }
Tensor2< double, 3, 3 > getDiffNormalImpl(Tensor1< T1, 3 > &t_coords, Tensor1< T2, 3 > &t_disp, Tensor1< T3, 3 > &t_normal)

◆ getDiffNormalImpl()

template<typename T1 , typename T2 , typename T3 >
Tensor2< double, 3, 3 > RollerRigidBody::getDiffNormalImpl ( Tensor1< T1, 3 > &  t_coords,
Tensor1< T2, 3 > &  t_disp,
Tensor1< T3, 3 > &  t_normal 
)
inline

Definition at line 958 of file RigidBodies.hpp.

960 {
961 Tensor2<double, 3, 3> diff_normal;
962 Tensor1<double, 3> norm_diff;
963 const double clean_gap = gAp;
964 const double eps = 1e-8;
965 for (int ii = 0; ii != 3; ++ii) {
966 Tensor1<double, 3> pert_disp{t_disp(0), t_disp(1), t_disp(2)};
967 pert_disp(ii) += eps;
968 auto pert_normal = getNormal(t_coords, pert_disp);
969 norm_diff(i) = (pert_normal(i) - t_normal(i)) / eps;
970 dGap(ii) = (gAp - clean_gap) / eps;
971
972 for (int jj = 0; jj != 3; ++jj) {
973 diff_normal(jj, ii) = norm_diff(jj);
974 }
975 }
976 return diff_normal;
977 };
static const double eps
Index< 'i', 3 > i
Definition: RigidBodies.hpp:31
Tensor1< double, 3 > getNormal(Tensor1< TPack3, 3 > &t_coords, Tensor1< TPack1, 3 > &t_disp)

◆ getGap()

double RollerRigidBody::getGap ( Tensor1< TPack3, 3 > &  t_coords)
inlinevirtual

Implements RigidBodyData.

Definition at line 792 of file RigidBodies.hpp.

792 {
793 return getGapImpl(t_coords);
794 }
double getGapImpl(Tensor1< T1, 3 > &t_coords)

◆ getGapImpl()

template<typename T1 >
double RollerRigidBody::getGapImpl ( Tensor1< T1, 3 > &  t_coords)
inline

Definition at line 979 of file RigidBodies.hpp.

979 {
980 return gAp;
981 };

◆ getNormal() [1/3]

Tensor1< double, 3 > RollerRigidBody::getNormal ( Tensor1< double, 3 > &  t_coords,
Tensor1< double, 3 > &  t_disp 
)
inlinevirtual

Implements RigidBodyData.

Definition at line 781 of file RigidBodies.hpp.

782 {
783 return getNormalImpl(t_coords, t_disp);
784 }
Tensor1< double, 3 > & getNormalImpl(Tensor1< T1, 3 > &t_coords, Tensor1< T2, 3 > &t_disp)

◆ getNormal() [2/3]

Tensor1< double, 3 > RollerRigidBody::getNormal ( Tensor1< TPack3, 3 > &  t_coords,
Tensor1< double, 3 > &  t_disp 
)
inlinevirtual

Implements RigidBodyData.

Definition at line 777 of file RigidBodies.hpp.

778 {
779 return getNormalImpl(t_coords, t_disp);
780 }

◆ getNormal() [3/3]

Tensor1< double, 3 > RollerRigidBody::getNormal ( Tensor1< TPack3, 3 > &  t_coords,
Tensor1< TPack1, 3 > &  t_disp 
)
inlinevirtual

Implements RigidBodyData.

Definition at line 773 of file RigidBodies.hpp.

774 {
775 return getNormalImpl(t_coords, t_disp);
776 }

◆ getNormalImpl()

template<typename T1 , typename T2 >
Tensor1< double, 3 > & RollerRigidBody::getNormalImpl ( Tensor1< T1, 3 > &  t_coords,
Tensor1< T2, 3 > &  t_disp 
)
inline

Definition at line 849 of file RigidBodies.hpp.

850 {
851 auto t_d = getPointCoords(t_coords, t_disp);
853 pointCoords(i) = rotationMat(i, j) * t_d(j);
854 t_d(i) = pointCoords(i);
855
856 const double inv_eps = 1e6;
857 array<double, 3> gaps;
858 const double half_height = hEight / 2.;
859
860 double cone_apex_offset_a = coneOffsetA + half_height;
861 double cone_apex_offset_b = coneOffsetB - half_height;
862
863 // https://computergraphics.stackexchange.com/questions/7485/glsl-shapes-signed-distance-field-implementation-explanation
864 auto sd_infinite_cone = [&](Tensor1<double, 3> p, double slope) {
865 double c1 = 1. / sqrt(1 + (slope * slope));
866 double c2 = c1 * slope;
867 auto prod = sqrt(p(0) * p(0) + p(1) * p(1));
868 auto prod2 = sqrt(1 + slope * slope);
869 tNormal(0) = p(0) / (prod2 * prod);
870 tNormal(1) = p(1) / (prod2 * prod);
871 tNormal(2) = slope / prod2;
872 return c1 * prod + c2 * p(2);
873 };
874
875 const double full_h_a = -cone_apex_offset_a + coneRadiusA / angleA;
876 const double full_h_b = cone_apex_offset_b + coneTopRadiusB / angleB;
877
878 Tensor1<double, 3> t_apx_1(t_d(0), t_d(1), t_d(2) - full_h_a);
879 Tensor1<double, 3> t_apx_2(t_d(0), t_d(1), t_d(2) + full_h_b);
880
881 auto torus_dist = [&]() {
882 const double prod = sqrt(pow(t_d(0), 2) + pow(t_d(1), 2));
883 const double prod2 = sqrt(pow(-torusRadius + prod, 2) + pow(t_d(2), 2));
884 tNormal(0) = (t_d(0) * (-torusRadius + prod)) / (prod * prod2);
885 tNormal(1) = (t_d(1) * (-torusRadius + prod)) / (prod * prod2);
886 tNormal(2) = t_d(2) / prod2;
887 return -fIllet + prod2;
888 };
889
890 gaps[0] = torus_dist();
891 gaps[1] = t_d(2) < -cone_apex_offset_a ? inv_eps
892 : sd_infinite_cone(t_apx_1, angleA);
893 gaps[2] = t_d(2) > -cone_apex_offset_b ? inv_eps
894 : sd_infinite_cone(t_apx_2, -angleB);
895
896 int nb = distance(gaps.begin(), std::min_element(gaps.begin(), gaps.end()));
897 gAp = gaps[nb];
898
899 switch (nb) {
900 case 0: {
901 torus_dist();
902 break;
903 }
904 case 1: {
905 // compute normal for cone A
906 sd_infinite_cone(t_apx_1, angleA);
907 break;
908 }
909 case 2: {
910 // compute normal for cone b
911 sd_infinite_cone(t_apx_2, -angleB);
912 } break;
913 }
914
915 // // for debugging
916 // auto my_rand_mn = [](double M, double N) {
917 // return M + (rand() / (RAND_MAX / (N - M)));
918 // };
919 // auto t_off = getBodyOffset();
920 // std::ofstream afile("cone_pts.csv", std::ios::ate);
921 // if (afile.is_open()) {
922 // afile << "x,y,z\n";
923 // Tensor1<double, 3> p(0, 0, 0);
924 // for (int n = 0; n != 1e6; n++) {
925 // double x = my_rand_mn(-1.5, 1.5);
926 // double y = my_rand_mn(-1.5, 1.5);
927 // double z = my_rand_mn(-1, 1);
928 // Tensor1<double, 3> coords(x, y, z);
929
930 // t_d(i) = coords(i);
931 // t_dc1(i) = coords(i);
932 // t_dc2(i) = coords(i);
933 // t_dc1(2) -= full_h_a;
934 // t_dc2(2) += full_h_b;
935
936 // gaps[0] = torus_dist();
937 // gaps[1] = t_d(2) < -cone_apex_offset_a ? inv_eps :
938 // sd_infinite_cone(t_dc1, angleA); gaps[2] = t_d(2) >
939 // -cone_apex_offset_b ? inv_eps : sd_infinite_cone(t_dc2, -angleB);
940
941 // if (gaps[0] < 0 || gaps[1] < 0 || gaps[2] < 0) {
942
943 // afile << x + t_off(0) << "," << y + t_off(1) << "," << z + t_off(2)
944 // << "\n";
945 // }
946 // }
947 // afile.close();
948 // }
949
951 auto normal_copy = tNormal;
952 tNormal(i) = rotationMat(j, i) * normal_copy(j);
953
954 return tNormal;
955 };
static Index< 'p', 3 > p
Tensor1< T, Tensor_Dim > normalize()
Tensor1< double, 3 > pointCoords
Definition: RigidBodies.hpp:41
Tensor1< double, 3 > tNormal
Definition: RigidBodies.hpp:39
Tensor1< double, 3 > & getPointCoords(Tensor1< T1, 3 > &t_coords, Tensor1< T2, 3 > &t_disp)
Tensor2< double, 3, 3 > rotationMat
Definition: RigidBodies.hpp:45
Index< 'j', 3 > j
Definition: RigidBodies.hpp:32

◆ getRollerDataForTag()

MoFEMErrorCode RollerRigidBody::getRollerDataForTag ( )
inlinevirtual

Implements RigidBodyData.

Definition at line 761 of file RigidBodies.hpp.

761 {
764 dataForTags[0] = rAdius;
765 dataForTags[1] = fIllet;
766 dataForTags[2] = hEight;
767 dataForTags[4] = angleA;
768 dataForTags[5] = angleB;
769
771 }
@ ROLLER
Definition: RigidBodies.hpp:23
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:440
array< double, 9 > dataForTags
Definition: RigidBodies.hpp:55

Member Data Documentation

◆ angleA

double RollerRigidBody::angleA

Definition at line 743 of file RigidBodies.hpp.

◆ angleB

double RollerRigidBody::angleB

Definition at line 744 of file RigidBodies.hpp.

◆ coneOffsetA

double RollerRigidBody::coneOffsetA

Definition at line 752 of file RigidBodies.hpp.

◆ coneOffsetB

double RollerRigidBody::coneOffsetB

Definition at line 756 of file RigidBodies.hpp.

◆ coneRadiusA

double RollerRigidBody::coneRadiusA

Definition at line 750 of file RigidBodies.hpp.

◆ coneRadiusB

double RollerRigidBody::coneRadiusB

Definition at line 754 of file RigidBodies.hpp.

◆ coneTopRadiusA

double RollerRigidBody::coneTopRadiusA

Definition at line 751 of file RigidBodies.hpp.

◆ coneTopRadiusB

double RollerRigidBody::coneTopRadiusB

Definition at line 755 of file RigidBodies.hpp.

◆ fIllet

double RollerRigidBody::fIllet

Definition at line 746 of file RigidBodies.hpp.

◆ hEight

double RollerRigidBody::hEight

Definition at line 748 of file RigidBodies.hpp.

◆ rAdius

double RollerRigidBody::rAdius

Definition at line 745 of file RigidBodies.hpp.

◆ torusRadius

double RollerRigidBody::torusRadius

Definition at line 747 of file RigidBodies.hpp.


The documentation for this struct was generated from the following file: