v0.13.0
Public Member Functions | Public Attributes | List of all members
TorusRigidBody Struct Reference

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

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

Public Member Functions

 TorusRigidBody (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)
 
template<typename T1 , typename T2 >
Tensor1< double, 3 > & getNormalImpl (Tensor1< T1, 3 > &t_coords, Tensor1< T2, 3 > &t_disp)
 
template<typename T1 >
double getGapImpl (Tensor1< T1, 3 > &t_coords)
 
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 , typename T2 >
Tensor1< double, 3 > getdGapImpl (Tensor1< T1, 3 > &t_coords, Tensor1< T2, 3 > &t_normal)
 
virtual MoFEMErrorCode getBodyOptions ()
 
- Public Member Functions inherited from RigidBodyData
 RigidBodyData (VectorDouble c_coords, VectorDouble roller_disp, int id)
 
 RigidBodyData ()=delete
 
virtual ~RigidBodyData ()
 
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)
 

Public Attributes

double rAdius
 
double innerRadius
 
- 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
 
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
 
string positionDataParamName
 
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 562 of file RigidBodies.hpp.

Constructor & Destructor Documentation

◆ TorusRigidBody()

TorusRigidBody::TorusRigidBody ( VectorDouble  c_coords,
VectorDouble  roller_disp,
int  id 
)

Definition at line 566 of file RigidBodies.hpp.

567  : RigidBodyData(c_coords, roller_disp, id), rAdius(1), innerRadius(0.5) {
568  // , cP(R, r, 1)
569  // compute rotation matrix here
570  }
RigidBodyData()=delete

Member Function Documentation

◆ getBodyOptions()

virtual MoFEMErrorCode TorusRigidBody::getBodyOptions ( )
virtual

Implements RigidBodyData.

Definition at line 682 of file RigidBodies.hpp.

682  {
684  PetscBool rflg;
685  int nb_dirs = 3;
686  CHKERR PetscOptionsBegin(PETSC_COMM_WORLD, "", "", "");
687  string param = "-inner_radius" + to_string(iD);
688  CHKERR PetscOptionsScalar(param.c_str(), "set torus small radius", "", innerRadius,
689  &innerRadius, PETSC_NULL);
690  param = "-radius" + to_string(iD);
691  CHKERR PetscOptionsScalar(param.c_str(), "set torus large Radius", "", rAdius,
692  &rAdius, PETSC_NULL);
693  param = "-direction" + to_string(iD);
694  CHKERR PetscOptionsGetRealArray(NULL, NULL, param.c_str(), &oRientation(0),
695  &nb_dirs, &rflg);
696  ierr = PetscOptionsEnd();
697  CHKERRG(ierr);
698 
699  if (rflg)
701 
702  // cP = make_shared<ArbitrarySurfaceData>(R, r);
703 
705  }
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:496
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
#define CHKERR
Inline error check.
Definition: definitions.h:548
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:87
PetscErrorCode PetscOptionsGetRealArray(PetscOptions *, const char pre[], const char name[], PetscReal dval[], PetscInt *nmax, PetscBool *set)
Tensor1< double, 3 > oRientation
Definition: RigidBodies.hpp:43
MoFEMErrorCode computeRotationMatrix()
Definition: RigidBodies.hpp:85
const int iD
Definition: RigidBodies.hpp:30

◆ getdGap()

Tensor1<double, 3> TorusRigidBody::getdGap ( Tensor1< TPack3, 3 > &  t_coords,
Tensor1< TPack1, 3 > &  t_normal 
)
virtual

Implements RigidBodyData.

Definition at line 602 of file RigidBodies.hpp.

603  {
604  return getdGapImpl(t_coords, t_normal);
605  }
Tensor1< double, 3 > getdGapImpl(Tensor1< T1, 3 > &t_coords, Tensor1< T2, 3 > &t_normal)

◆ getdGapImpl()

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

Definition at line 677 of file RigidBodies.hpp.

678  {
679  return dGap;
680  };
Tensor1< double, 3 > dGap
Definition: RigidBodies.hpp:39

◆ getDiffNormal()

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

Implements RigidBodyData.

Definition at line 593 of file RigidBodies.hpp.

595  {
596  return getDiffNormalImpl(t_coords, t_disp, t_normal);
597  }
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> TorusRigidBody::getDiffNormalImpl ( Tensor1< T1, 3 > &  t_coords,
Tensor1< T2, 3 > &  t_disp,
Tensor1< T3, 3 > &  t_normal 
)

Definition at line 655 of file RigidBodies.hpp.

657  {
658  Tensor2<double, 3, 3> diff_normal;
659  Tensor1<double, 3> norm_diff;
660  const double clean_gap = gAp;
661  const double eps = 1e-8;
662  for (int ii = 0; ii != 3; ++ii) {
663  Tensor1<double, 3> pert_disp{t_disp(0), t_disp(1), t_disp(2)};
664  pert_disp(ii) += eps;
665  auto pert_normal = getNormal(t_coords, pert_disp);
666  norm_diff(i) = (pert_normal(i) - t_normal(i)) / eps;
667  dGap(ii) = (gAp - clean_gap) / eps;
668 
669  for (int jj = 0; jj != 3; ++jj) {
670  diff_normal(jj, ii) = norm_diff(jj);
671  }
672  }
673  return diff_normal;
674  };
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 TorusRigidBody::getGap ( Tensor1< TPack3, 3 > &  t_coords)
virtual

Implements RigidBodyData.

Definition at line 599 of file RigidBodies.hpp.

599  {
600  return getGapImpl(t_coords);
601  }
double getGapImpl(Tensor1< T1, 3 > &t_coords)

◆ getGapImpl()

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

Definition at line 650 of file RigidBodies.hpp.

650  {
651  return gAp;
652  };

◆ getNormal() [1/3]

Tensor1<double, 3> TorusRigidBody::getNormal ( Tensor1< double, 3 > &  t_coords,
Tensor1< double, 3 > &  t_disp 
)
virtual

Implements RigidBodyData.

Definition at line 588 of file RigidBodies.hpp.

589  {
590  return getNormalImpl(t_coords, t_disp);
591  }
Tensor1< double, 3 > & getNormalImpl(Tensor1< T1, 3 > &t_coords, Tensor1< T2, 3 > &t_disp)

◆ getNormal() [2/3]

Tensor1<double, 3> TorusRigidBody::getNormal ( Tensor1< TPack3, 3 > &  t_coords,
Tensor1< double, 3 > &  t_disp 
)
virtual

Implements RigidBodyData.

Definition at line 584 of file RigidBodies.hpp.

585  {
586  return getNormalImpl(t_coords, t_disp);
587  }

◆ getNormal() [3/3]

Tensor1<double, 3> TorusRigidBody::getNormal ( Tensor1< TPack3, 3 > &  t_coords,
Tensor1< TPack1, 3 > &  t_disp 
)
virtual

Implements RigidBodyData.

Definition at line 580 of file RigidBodies.hpp.

581  {
582  return getNormalImpl(t_coords, t_disp);
583  }

◆ getNormalImpl()

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

Definition at line 608 of file RigidBodies.hpp.

609  {
610 
611  auto t_d = getPointCoords(t_coords, t_disp);
612  pointCoords(i) = rotationMat(i, j) * t_d(j);
613  t_d(i) = pointCoords(i);
614 
615  // cP->tt = 1;
616  // cP->rr = 1.;
617  // cP->R1 = 0;
618  // cP->PrintTorusDebug();
619  // cP->PrintTorusAnimDebug();
620 
621  // auto closest_pt_toroid = cP->getClosestPointToToroid(t_d);
622  // closestPoint(i) = closest_pt_toroid(i);
623 
624  // tNormal(j) = t_d(j) - closestPoint(j);
625  // if (cP->isPointInsideTorus(t_d))
626  // tNormal(i) *= -1;
627  // tNormal.normalize();
628 
629  // gAp = tNormal(i) * (t_d(i) - closestPoint(i));
630 
631  // https: // iquilezles.org/www/articles/distfunctions/distfunctions.htm
632  const double x = t_d(0);
633  const double y = t_d(1);
634  const double z = t_d(2);
635  const double RR = rAdius - innerRadius;
636  const double prod = sqrt(pow(x, 2) + pow(y, 2));
637  const double prod2 = sqrt(pow(-RR + prod, 2) + pow(z, 2));
638  gAp = -innerRadius + prod2;
639  tNormal(0) = (x * (-RR + prod)) / (prod * prod2);
640  tNormal(1) = (y * (-RR + prod)) / (prod * prod2);
641  tNormal(2) = z / prod2;
642  tNormal.normalize();
643 
644  auto normal_copy = tNormal;
645  tNormal(i) = rotationMat(j, i) * normal_copy(j);
646 
647  return tNormal;
648  };
Tensor1< double, 3 > pointCoords
Definition: RigidBodies.hpp:40
Tensor1< double, 3 > tNormal
Definition: RigidBodies.hpp:38
Tensor1< double, 3 > & getPointCoords(Tensor1< T1, 3 > &t_coords, Tensor1< T2, 3 > &t_disp)
Tensor2< double, 3, 3 > rotationMat
Definition: RigidBodies.hpp:44
Index< 'j', 3 > j
Definition: RigidBodies.hpp:32

◆ getRollerDataForTag()

MoFEMErrorCode TorusRigidBody::getRollerDataForTag ( )
virtual

Implements RigidBodyData.

Definition at line 572 of file RigidBodies.hpp.

572  {
574  bodyType = TORUS;
575  dataForTags[0] = rAdius;
578  }
@ TORUS
Definition: RigidBodies.hpp:22
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:460
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:453
array< double, 9 > dataForTags
Definition: RigidBodies.hpp:50

Member Data Documentation

◆ innerRadius

double TorusRigidBody::innerRadius

Definition at line 565 of file RigidBodies.hpp.

◆ rAdius

double TorusRigidBody::rAdius

Definition at line 564 of file RigidBodies.hpp.


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