v0.15.0
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
OpCalculateRotationAndSpatialGradient Struct Reference

#include "users_modules/eshelbian_plasticity/src/EshelbianOperators.hpp"

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

Public Member Functions

 OpCalculateRotationAndSpatialGradient (boost::shared_ptr< DataAtIntegrationPts > data_ptr, double alpha_omega=0)
 
MoFEMErrorCode doWork (int side, EntityType type, EntData &data)
 Operator for linear form, usually to calculate values on right hand side.
 
- Public Member Functions inherited from MoFEM::VolumeElementForcesAndSourcesCore::UserDataOperator
int getNumNodes ()
 get element number of nodes
 
const EntityHandlegetConn ()
 get element connectivity
 
double getVolume () const
 element volume (linear geometry)
 
doublegetVolume ()
 element volume (linear geometry)
 
FTensor::Tensor2< double *, 3, 3 > & getJac ()
 get element Jacobian
 
FTensor::Tensor2< double *, 3, 3 > & getInvJac ()
 get element inverse Jacobian
 
VectorDoublegetCoords ()
 nodal coordinates
 
VolumeElementForcesAndSourcesCoregetVolumeFE () const
 return pointer to Generic Volume Finite Element object
 
- Public Member Functions inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
 UserDataOperator (const FieldSpace space, const char type=OPSPACE, const bool symm=true)
 
 UserDataOperator (const std::string field_name, const char type, const bool symm=true)
 
 UserDataOperator (const std::string row_field_name, const std::string col_field_name, const char type, const bool symm=true)
 
boost::shared_ptr< const NumeredEntFiniteElementgetNumeredEntFiniteElementPtr () const
 Return raw pointer to NumeredEntFiniteElement.
 
EntityHandle getFEEntityHandle () const
 Return finite element entity handle.
 
int getFEDim () const
 Get dimension of finite element.
 
EntityType getFEType () const
 Get dimension of finite element.
 
boost::weak_ptr< SideNumbergetSideNumberPtr (const int side_number, const EntityType type)
 Get the side number pointer.
 
EntityHandle getSideEntity (const int side_number, const EntityType type)
 Get the side entity.
 
int getNumberOfNodesOnElement () const
 Get the number of nodes on finite element.
 
MoFEMErrorCode getProblemRowIndices (const std::string filed_name, const EntityType type, const int side, VectorInt &indices) const
 Get row indices.
 
MoFEMErrorCode getProblemColIndices (const std::string filed_name, const EntityType type, const int side, VectorInt &indices) const
 Get col indices.
 
const FEMethodgetFEMethod () const
 Return raw pointer to Finite Element Method object.
 
int getOpType () const
 Get operator types.
 
void setOpType (const OpType type)
 Set operator type.
 
void addOpType (const OpType type)
 Add operator type.
 
int getNinTheLoop () const
 get number of finite element in the loop
 
int getLoopSize () const
 get size of elements in the loop
 
std::string getFEName () const
 Get name of the element.
 
ForcesAndSourcesCoregetPtrFE () const
 
ForcesAndSourcesCoregetSidePtrFE () const
 
ForcesAndSourcesCoregetRefinePtrFE () const
 
const PetscData::SwitchesgetDataCtx () const
 
const KspMethod::KSPContext getKSPCtx () const
 
const SnesMethod::SNESContext getSNESCtx () const
 
const TSMethod::TSContext getTSCtx () const
 
Vec getKSPf () const
 
Mat getKSPA () const
 
Mat getKSPB () const
 
Vec getSNESf () const
 
Vec getSNESx () const
 
Mat getSNESA () const
 
Mat getSNESB () const
 
Vec getTSu () const
 
Vec getTSu_t () const
 
Vec getTSu_tt () const
 
Vec getTSf () const
 
Mat getTSA () const
 
Mat getTSB () const
 
int getTSstep () const
 
double getTStime () const
 
double getTStimeStep () const
 
double getTSa () const
 
double getTSaa () const
 
MatrixDoublegetGaussPts ()
 matrix of integration (Gauss) points for Volume Element
 
auto getFTensor0IntegrationWeight ()
 Get integration weights.
 
MatrixDoublegetCoordsAtGaussPts ()
 Gauss points and weight, matrix (nb. of points x 3)
 
auto getFTensor1CoordsAtGaussPts ()
 Get coordinates at integration points assuming linear geometry.
 
double getMeasure () const
 get measure of element
 
doublegetMeasure ()
 get measure of element
 
MoFEMErrorCode loopSide (const string &fe_name, ForcesAndSourcesCore *side_fe, const size_t dim, const EntityHandle ent_for_side=0, boost::shared_ptr< Range > fe_range=nullptr, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy, AdjCache *adj_cache=nullptr)
 User calls this function to loop over elements on the side of face. This function calls finite element with its operator to do calculations.
 
MoFEMErrorCode loopThis (const string &fe_name, ForcesAndSourcesCore *this_fe, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 User calls this function to loop over the same element using a different set of integration points. This function calls finite element with its operator to do calculations.
 
MoFEMErrorCode loopParent (const string &fe_name, ForcesAndSourcesCore *parent_fe, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 User calls this function to loop over parent elements. This function calls finite element with its operator to do calculations.
 
MoFEMErrorCode loopChildren (const string &fe_name, ForcesAndSourcesCore *child_fe, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 User calls this function to loop over parent elements. This function calls finite element with its operator to do calculations.
 
MoFEMErrorCode loopRange (const string &fe_name, ForcesAndSourcesCore *range_fe, boost::shared_ptr< Range > fe_range, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 Iterate over range of elements.
 
- Public Member Functions inherited from MoFEM::DataOperator
 DataOperator (const bool symm=true)
 
virtual ~DataOperator ()=default
 
virtual MoFEMErrorCode doWork (int row_side, int col_side, EntityType row_type, EntityType col_type, EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)
 Operator for bi-linear form, usually to calculate values on left hand side.
 
virtual MoFEMErrorCode opLhs (EntitiesFieldData &row_data, EntitiesFieldData &col_data)
 
virtual MoFEMErrorCode opRhs (EntitiesFieldData &data, const bool error_if_no_base=false)
 
bool getSymm () const
 Get if operator uses symmetry of DOFs or not.
 
void setSymm ()
 set if operator is executed taking in account symmetry
 
void unSetSymm ()
 unset if operator is executed for non symmetric problem
 

Private Attributes

boost::shared_ptr< DataAtIntegrationPtsdataAtPts
 data at integration pts
 
double alphaOmega
 

Additional Inherited Members

- Public Types inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
enum  OpType {
  OPROW = 1 << 0 , OPCOL = 1 << 1 , OPROWCOL = 1 << 2 , OPSPACE = 1 << 3 ,
  OPLAST = 1 << 3
}
 Controls loop over entities on element. More...
 
using AdjCache = std::map< EntityHandle, std::vector< boost::weak_ptr< NumeredEntFiniteElement > > >
 
- Public Types inherited from MoFEM::DataOperator
using DoWorkLhsHookFunType = boost::function< MoFEMErrorCode(DataOperator *op_ptr, int row_side, int col_side, EntityType row_type, EntityType col_type, EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)>
 
using DoWorkRhsHookFunType = boost::function< MoFEMErrorCode(DataOperator *op_ptr, int side, EntityType type, EntitiesFieldData::EntData &data)>
 
- Public Attributes inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
char opType
 
std::string rowFieldName
 
std::string colFieldName
 
FieldSpace sPace
 
- Public Attributes inherited from MoFEM::DataOperator
DoWorkLhsHookFunType doWorkLhsHook
 
DoWorkRhsHookFunType doWorkRhsHook
 
bool sYmm
 If true assume that matrix is symmetric structure.
 
std::array< bool, MBMAXTYPE > doEntities
 If true operator is executed for entity.
 
booldoVertices
 \deprectaed If false skip vertices
 
booldoEdges
 \deprectaed If false skip edges
 
booldoQuads
 \deprectaed
 
booldoTris
 \deprectaed
 
booldoTets
 \deprectaed
 
booldoPrisms
 \deprectaed
 
- Static Public Attributes inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
static const char *const OpTypeNames []
 
- Protected Member Functions inherited from MoFEM::VolumeElementForcesAndSourcesCore::UserDataOperator
MoFEMErrorCode setPtrFE (ForcesAndSourcesCore *ptr)
 
- Protected Attributes inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
ForcesAndSourcesCoreptrFE
 

Detailed Description

Examples
EshelbianPlasticity.cpp.

Definition at line 292 of file EshelbianOperators.hpp.

Constructor & Destructor Documentation

◆ OpCalculateRotationAndSpatialGradient()

OpCalculateRotationAndSpatialGradient::OpCalculateRotationAndSpatialGradient ( boost::shared_ptr< DataAtIntegrationPts data_ptr,
double  alpha_omega = 0 
)
inline

Definition at line 294 of file EshelbianOperators.hpp.

297 alphaOmega(alpha_omega) {}
@ NOSPACE
Definition definitions.h:83
VolumeElementForcesAndSourcesCore::UserDataOperator VolUserDataOperator
@ OPSPACE
operator do Work is execute on space data
boost::shared_ptr< DataAtIntegrationPts > dataAtPts
data at integration pts

Member Function Documentation

◆ doWork()

MoFEMErrorCode OpCalculateRotationAndSpatialGradient::doWork ( int  side,
EntityType  type,
EntData data 
)
virtual

Operator for linear form, usually to calculate values on right hand side.

Reimplemented from MoFEM::DataOperator.

Examples
EshelbianOperators.cpp.

Definition at line 97 of file EshelbianOperators.cpp.

99 {
101
102 auto ts_ctx = getTSCtx();
103 int nb_integration_pts = getGaussPts().size2();
104
105 // space size indices
113
114 // sym size indices
116
117 auto t_L = symm_L_tensor();
118
119 dataAtPts->hAtPts.resize(9, nb_integration_pts, false);
120 dataAtPts->hdOmegaAtPts.resize(9 * 3, nb_integration_pts, false);
121 dataAtPts->hdLogStretchAtPts.resize(9 * 6, nb_integration_pts, false);
122
123 dataAtPts->leviKirchhoffAtPts.resize(3, nb_integration_pts, false);
124 dataAtPts->leviKirchhoffdOmegaAtPts.resize(9, nb_integration_pts, false);
125 dataAtPts->leviKirchhoffdLogStreatchAtPts.resize(3 * size_symm,
126 nb_integration_pts, false);
127 dataAtPts->leviKirchhoffPAtPts.resize(9 * 3, nb_integration_pts, false);
128
129 dataAtPts->adjointPdstretchAtPts.resize(9, nb_integration_pts, false);
130 dataAtPts->adjointPdUAtPts.resize(size_symm, nb_integration_pts, false);
131 dataAtPts->adjointPdUdPAtPts.resize(9 * size_symm, nb_integration_pts, false);
132 dataAtPts->adjointPdUdOmegaAtPts.resize(3 * size_symm, nb_integration_pts,
133 false);
134 dataAtPts->rotMatAtPts.resize(9, nb_integration_pts, false);
135 dataAtPts->stretchTensorAtPts.resize(6, nb_integration_pts, false);
136 dataAtPts->diffStretchTensorAtPts.resize(36, nb_integration_pts, false);
137 dataAtPts->eigenVals.resize(3, nb_integration_pts, false);
138 dataAtPts->eigenVecs.resize(9, nb_integration_pts, false);
139 dataAtPts->nbUniq.resize(nb_integration_pts, false);
140 dataAtPts->eigenValsC.resize(3, nb_integration_pts, false);
141 dataAtPts->eigenVecsC.resize(9, nb_integration_pts, false);
142 dataAtPts->nbUniqC.resize(nb_integration_pts, false);
143
144 dataAtPts->logStretch2H1AtPts.resize(6, nb_integration_pts, false);
145 dataAtPts->logStretchTotalTensorAtPts.resize(6, nb_integration_pts, false);
146
147 dataAtPts->internalStressAtPts.resize(9, nb_integration_pts, false);
148 dataAtPts->internalStressAtPts.clear();
149
150 // Calculated values
151 auto t_h = getFTensor2FromMat<3, 3>(dataAtPts->hAtPts);
152 auto t_h_domega = getFTensor3FromMat<3, 3, 3>(dataAtPts->hdOmegaAtPts);
153 auto t_h_dlog_u =
154 getFTensor3FromMat<3, 3, size_symm>(dataAtPts->hdLogStretchAtPts);
155 auto t_levi_kirchhoff = getFTensor1FromMat<3>(dataAtPts->leviKirchhoffAtPts);
156 auto t_levi_kirchhoff_domega =
157 getFTensor2FromMat<3, 3>(dataAtPts->leviKirchhoffdOmegaAtPts);
158 auto t_levi_kirchhoff_dstreach = getFTensor2FromMat<3, size_symm>(
159 dataAtPts->leviKirchhoffdLogStreatchAtPts);
160 auto t_levi_kirchhoff_dP =
161 getFTensor3FromMat<3, 3, 3>(dataAtPts->leviKirchhoffPAtPts);
162 auto t_approx_P_adjoint__dstretch =
163 getFTensor2FromMat<3, 3>(dataAtPts->adjointPdstretchAtPts);
164 auto t_approx_P_adjoint_log_du =
165 getFTensor1FromMat<size_symm>(dataAtPts->adjointPdUAtPts);
166 auto t_approx_P_adjoint_log_du_dP =
167 getFTensor3FromMat<3, 3, size_symm>(dataAtPts->adjointPdUdPAtPts);
168 auto t_approx_P_adjoint_log_du_domega =
169 getFTensor2FromMat<3, size_symm>(dataAtPts->adjointPdUdOmegaAtPts);
170 auto t_R = getFTensor2FromMat<3, 3>(dataAtPts->rotMatAtPts);
171 auto t_u = getFTensor2SymmetricFromMat<3>(dataAtPts->stretchTensorAtPts);
172 auto t_diff_u =
173 getFTensor4DdgFromMat<3, 3, 1>(dataAtPts->diffStretchTensorAtPts);
174 auto t_eigen_vals = getFTensor1FromMat<3>(dataAtPts->eigenVals);
175 auto t_eigen_vecs = getFTensor2FromMat<3, 3>(dataAtPts->eigenVecs);
176 auto &nbUniq = dataAtPts->nbUniq;
177 auto t_nb_uniq =
178 FTensor::Tensor0<FTensor::PackPtr<int *, 1>>(nbUniq.data().data());
179 auto t_eigen_vals_C = getFTensor1FromMat<3>(dataAtPts->eigenValsC);
180 auto t_eigen_vecs_C = getFTensor2FromMat<3, 3>(dataAtPts->eigenVecsC);
181 auto &nbUniqC = dataAtPts->nbUniqC;
182 auto t_nb_uniq_C =
183 FTensor::Tensor0<FTensor::PackPtr<int *, 1>>(nbUniqC.data().data());
184
185 auto t_log_stretch_total =
186 getFTensor2SymmetricFromMat<3>(dataAtPts->logStretchTotalTensorAtPts);
187 auto t_log_u2_h1 =
188 getFTensor2SymmetricFromMat<3>(dataAtPts->logStretch2H1AtPts);
189
190 // Field values
191 auto t_grad_h1 = getFTensor2FromMat<3, 3>(dataAtPts->wGradH1AtPts);
192 auto t_omega = getFTensor1FromMat<3>(dataAtPts->rotAxisAtPts);
193 auto t_approx_P = getFTensor2FromMat<3, 3>(dataAtPts->approxPAtPts);
194 auto t_log_u =
195 getFTensor2SymmetricFromMat<3>(dataAtPts->logStretchTensorAtPts);
196
197 auto next = [&]() {
198 // calculated values
199 ++t_h;
200 ++t_h_domega;
201 ++t_h_dlog_u;
202 ++t_levi_kirchhoff;
203 ++t_levi_kirchhoff_domega;
204 ++t_levi_kirchhoff_dstreach;
205 ++t_levi_kirchhoff_dP;
206 ++t_approx_P_adjoint__dstretch;
207 ++t_approx_P_adjoint_log_du;
208 ++t_approx_P_adjoint_log_du_dP;
209 ++t_approx_P_adjoint_log_du_domega;
210 ++t_R;
211 ++t_u;
212 ++t_diff_u;
213 ++t_eigen_vals;
214 ++t_eigen_vecs;
215 ++t_nb_uniq;
216 ++t_eigen_vals_C;
217 ++t_eigen_vecs_C;
218 ++t_nb_uniq_C;
219 ++t_log_u2_h1;
220 ++t_log_stretch_total;
221 // field values
222 ++t_omega;
223 ++t_grad_h1;
224 ++t_approx_P;
225 ++t_log_u;
226 };
227
230
231 auto bound_eig = [&](auto &eig) {
233 const auto zero = std::exp(std::numeric_limits<double>::min_exponent);
234 const auto large = std::exp(std::numeric_limits<double>::max_exponent);
235 for (int ii = 0; ii != 3; ++ii) {
236 eig(ii) = std::min(std::max(zero, eig(ii)), large);
237 }
239 };
240
241 auto calculate_log_stretch = [&]() {
244 eigen_vec(i, j) = t_log_u(i, j);
245 if (computeEigenValuesSymmetric(eigen_vec, eig) != MB_SUCCESS) {
246 MOFEM_LOG("SELF", Sev::error) << "Failed to compute eigen values";
247 }
248 // CHKERR bound_eig(eig);
249 // rare case when two eigen values are equal
250 t_nb_uniq = get_uniq_nb<3>(&eig(0));
251 if (t_nb_uniq < 3) {
252 sort_eigen_vals(eig, eigen_vec);
253 }
254 t_eigen_vals(i) = eig(i);
255 t_eigen_vecs(i, j) = eigen_vec(i, j);
256 t_u(i, j) =
257 EigenMatrix::getMat(t_eigen_vals, t_eigen_vecs, EshelbianCore::f)(i, j);
258 auto get_t_diff_u = [&]() {
259 return EigenMatrix::getDiffMat(t_eigen_vals, t_eigen_vecs,
261 t_nb_uniq);
262 };
263 t_diff_u(i, j, k, l) = get_t_diff_u()(i, j, k, l);
265 t_Ldiff_u(i, j, L) = t_diff_u(i, j, m, n) * t_L(m, n, L);
266 return t_Ldiff_u;
267 };
268
269 auto calculate_total_stretch = [&](auto &t_h1) {
270 if (EshelbianCore::gradApproximator == NO_H1_CONFIGURATION) {
271
272 t_log_u2_h1(i, j) = 0;
273 t_log_stretch_total(i, j) = t_log_u(i, j);
274
277 t_R_h1(i, j) = t_kd(i, j);
278 t_inv_u_h1(i, j) = t_symm_kd(i, j);
279
280 return std::make_pair(t_R_h1, t_inv_u_h1);
281
282 } else {
283
286
288 t_C_h1(i, j) = t_h1(k, i) * t_h1(k, j);
289 eigen_vec(i, j) = t_C_h1(i, j);
290 if (computeEigenValuesSymmetric(eigen_vec, eig) != MB_SUCCESS) {
291 MOFEM_LOG("SELF", Sev::error) << "Failed to compute eigen values";
292 }
293 // rare case when two eigen values are equal
294 t_nb_uniq_C = get_uniq_nb<3>(&eig(0));
295 if (t_nb_uniq_C < 3) {
296 sort_eigen_vals(eig, eigen_vec);
297 }
298 if (EshelbianCore::stretchSelector >= StretchSelector::LOG) {
299 CHKERR bound_eig(eig);
300 }
301 t_eigen_vals_C(i) = eig(i);
302 t_eigen_vecs_C(i, j) = eigen_vec(i, j);
303
304 t_log_u2_h1(i, j) =
305 EigenMatrix::getMat(eig, eigen_vec, EshelbianCore::inv_f)(i, j);
306 t_log_stretch_total(i, j) = t_log_u2_h1(i, j) / 2 + t_log_u(i, j);
307
308 auto f_inv_sqrt = [](auto e) { return 1. / std::sqrt(e); };
310 t_inv_u_h1(i, j) = EigenMatrix::getMat(eig, eigen_vec, f_inv_sqrt)(i, j);
312 t_R_h1(i, j) = t_h1(i, o) * t_inv_u_h1(o, j);
313
314 return std::make_pair(t_R_h1, t_inv_u_h1);
315 }
316 };
317
318 auto no_h1_loop = [&]() {
320
322 case LARGE_ROT:
323 break;
324 case SMALL_ROT:
325 break;
326 default:
327 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
328 "rotSelector should be large");
329 };
330
331 for (int gg = 0; gg != nb_integration_pts; ++gg) {
332
334
336 t_h1(i, j) = t_kd(i, j);
337
338 // calculate streach
339 auto t_Ldiff_u = calculate_log_stretch();
340
341 // calculate total stretch
342 auto [t_R_h1, t_inv_u_h1] = calculate_total_stretch(t_h1);
343
348
350
351 // rotation
353 case LARGE_ROT:
354 t_R(i, j) = LieGroups::SO3::exp(t_omega, t_omega.l2())(i, j);
355 t_diff_R(i, j, k) =
356 LieGroups::SO3::diffExp(t_omega, t_omega.l2())(i, j, k);
357 // left
358 t_diff_Rr(i, j, l) = t_R(i, k) * levi_civita(k, j, l);
359 t_diff_diff_Rr(i, j, l, m) = t_diff_R(i, k, m) * levi_civita(k, j, l);
360 // right
361 t_diff_Rl(i, j, l) = levi_civita(i, k, l) * t_R(k, j);
362 t_diff_diff_Rl(i, j, l, m) = levi_civita(i, k, l) * t_diff_R(k, j, m);
363 break;
364
365 default:
366 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
367 "rotationSelector not handled");
368 }
369
370 constexpr double half_r = 1 / 2.;
371 constexpr double half_l = 1 / 2.;
372
373 // calculate gradient
374 t_h(i, k) = t_R(i, l) * t_u(l, k);
375
376 // Adjoint stress
377 t_approx_P_adjoint__dstretch(l, k) =
378 (t_R(i, l) * t_approx_P(i, k) + t_R(i, k) * t_approx_P(i, l));
379 t_approx_P_adjoint__dstretch(l, k) /= 2.;
380
381 t_approx_P_adjoint_log_du(L) =
382 (t_approx_P_adjoint__dstretch(l, k) * t_Ldiff_u(l, k, L) +
383 t_approx_P_adjoint__dstretch(k, l) * t_Ldiff_u(l, k, L) +
384 t_approx_P_adjoint__dstretch(l, k) * t_Ldiff_u(k, l, L) +
385 t_approx_P_adjoint__dstretch(k, l) * t_Ldiff_u(k, l, L)) /
386 4.;
387
388 // Kirchhoff stress
389 t_levi_kirchhoff(m) =
390
391 half_r * (t_diff_Rr(i, l, m) * (t_u(l, k) * t_approx_P(i, k)) +
392 t_diff_Rr(i, k, m) * (t_u(l, k) * t_approx_P(i, l)))
393
394 +
395
396 half_l * (t_diff_Rl(i, l, m) * (t_u(l, k) * t_approx_P(i, k)) +
397 t_diff_Rl(i, k, m) * (t_u(l, k) * t_approx_P(i, l)));
398 t_levi_kirchhoff(m) /= 2.;
399
401
402 if (EshelbianCore::symmetrySelector == SYMMETRIC) {
403 t_h_domega(i, k, m) = half_r * (t_diff_Rr(i, l, m) * t_u(l, k))
404
405 +
406
407 half_l * (t_diff_Rl(i, l, m) * t_u(l, k));
408 } else {
409 t_h_domega(i, k, m) = t_diff_R(i, l, m) * t_u(l, k);
410 }
411
412 t_h_dlog_u(i, k, L) = t_R(i, l) * t_Ldiff_u(l, k, L);
413
414 t_approx_P_adjoint_log_du_dP(i, k, L) =
415 t_R(i, l) * (t_Ldiff_u(l, k, L) + t_Ldiff_u(k, l, L)) / 2.;
416
417 if (EshelbianCore::symmetrySelector == SYMMETRIC) {
419 t_A(k, l, m) = t_diff_Rr(i, l, m) * t_approx_P(i, k) +
420 t_diff_Rr(i, k, m) * t_approx_P(i, l);
421 t_A(k, l, m) /= 2.;
423 t_B(k, l, m) = t_diff_Rl(i, l, m) * t_approx_P(i, k) +
424 t_diff_Rl(i, k, m) * t_approx_P(i, l);
425 t_B(k, l, m) /= 2.;
426
427 t_approx_P_adjoint_log_du_domega(m, L) =
428 half_r * (t_A(k, l, m) *
429 (t_Ldiff_u(k, l, L) + t_Ldiff_u(k, l, L)) / 2) +
430 half_l * (t_B(k, l, m) *
431 (t_Ldiff_u(k, l, L) + t_Ldiff_u(k, l, L)) / 2);
432 } else {
434 t_A(k, l, m) = t_diff_R(i, l, m) * t_approx_P(i, k);
435 t_approx_P_adjoint_log_du_domega(m, L) =
436 t_A(k, l, m) * t_Ldiff_u(k, l, L);
437 }
438
439 t_levi_kirchhoff_dstreach(m, L) =
440 half_r *
441 (t_diff_Rr(i, l, m) * (t_Ldiff_u(l, k, L) * t_approx_P(i, k)))
442
443 +
444
445 half_l *
446 (t_diff_Rl(i, l, m) * (t_Ldiff_u(l, k, L) * t_approx_P(i, k)));
447
448 t_levi_kirchhoff_dP(m, i, k) =
449 half_r * t_diff_Rr(i, l, m) * (t_u(l, k))
450
451 +
452
453 half_l * t_diff_Rl(i, l, m) * (t_u(l, k));
454
455 t_levi_kirchhoff_domega(m, n) =
456 half_r *
457 (t_diff_diff_Rr(i, l, m, n) * (t_u(l, k) * t_approx_P(i, k)) +
458 t_diff_diff_Rr(i, k, m, n) * (t_u(l, k) * t_approx_P(i, l)))
459
460 +
461
462 half_l *
463 (t_diff_diff_Rl(i, l, m, n) * (t_u(l, k) * t_approx_P(i, k)) +
464 t_diff_diff_Rl(i, k, m, n) * (t_u(l, k) * t_approx_P(i, l)));
465 t_levi_kirchhoff_domega(m, n) /= 2.;
466 }
467
468 next();
469 }
470
472 };
473
474 auto large_loop = [&]() {
476
478 case LARGE_ROT:
479 break;
480 case SMALL_ROT:
481 break;
482 default:
483 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
484 "rotSelector should be large");
485 };
486
487 for (int gg = 0; gg != nb_integration_pts; ++gg) {
488
490
494 t_h1(i, j) = t_kd(i, j);
495 break;
496 case LARGE_ROT:
497 t_h1(i, j) = t_grad_h1(i, j) + t_kd(i, j);
498 break;
499 default:
500 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
501 "gradApproximator not handled");
502 };
503
504 // calculate streach
505 auto t_Ldiff_u = calculate_log_stretch();
506 // calculate total stretch
507 auto [t_R_h1, t_inv_u_h1] = calculate_total_stretch(t_h1);
508
510 t_h_u(l, k) = t_u(l, o) * t_h1(o, k);
512 t_Ldiff_h_u(l, k, L) = t_Ldiff_u(l, o, L) * t_h1(o, k);
513
518
520
521 // rotation
523 case LARGE_ROT:
524 t_R(i, j) = LieGroups::SO3::exp(t_omega, t_omega.l2())(i, j);
525 t_diff_R(i, j, k) =
526 LieGroups::SO3::diffExp(t_omega, t_omega.l2())(i, j, k);
527 // left
528 t_diff_Rr(i, j, l) = t_R(i, k) * levi_civita(k, j, l);
529 t_diff_diff_Rr(i, j, l, m) = t_diff_R(i, k, m) * levi_civita(k, j, l);
530 // right
531 t_diff_Rl(i, j, l) = levi_civita(i, k, l) * t_R(k, j);
532 t_diff_diff_Rl(i, j, l, m) = levi_civita(i, k, l) * t_diff_R(k, j, m);
533 break;
534 case SMALL_ROT:
535 t_R(i, k) = t_kd(i, k) + levi_civita(i, k, l) * t_omega(l);
536 t_diff_R(i, j, k) = levi_civita(i, j, k);
537 // left
538 t_diff_Rr(i, j, l) = levi_civita(i, j, l);
539 t_diff_diff_Rr(i, j, l, m) = 0;
540 // right
541 t_diff_Rl(i, j, l) = levi_civita(i, j, l);
542 t_diff_diff_Rl(i, j, l, m) = 0;
543 break;
544
545 default:
546 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
547 "rotationSelector not handled");
548 }
549
550 constexpr double half_r = 1 / 2.;
551 constexpr double half_l = 1 / 2.;
552
553 // calculate gradient
554 t_h(i, k) = t_R(i, l) * t_h_u(l, k);
555
556 // Adjoint stress
557 t_approx_P_adjoint__dstretch(l, o) =
558 (t_R(i, l) * t_approx_P(i, k)) * t_h1(o, k);
559 t_approx_P_adjoint_log_du(L) =
560 t_approx_P_adjoint__dstretch(l, o) * t_Ldiff_u(l, o, L);
561
562 // Kirchhoff stress
563 t_levi_kirchhoff(m) =
564
565 half_r * ((t_diff_Rr(i, l, m) * (t_h_u(l, k)) * t_approx_P(i, k)))
566
567 +
568
569 half_l * ((t_diff_Rl(i, l, m) * (t_h_u(l, k)) * t_approx_P(i, k)));
570
572
573 if (EshelbianCore::symmetrySelector == SYMMETRIC) {
574 t_h_domega(i, k, m) = half_r * (t_diff_Rr(i, l, m) * t_h_u(l, k))
575
576 +
577
578 half_l * (t_diff_Rl(i, l, m) * t_h_u(l, k));
579 } else {
580 t_h_domega(i, k, m) = t_diff_R(i, l, m) * t_h_u(l, k);
581 }
582
583 t_h_dlog_u(i, k, L) = t_R(i, l) * t_Ldiff_h_u(l, k, L);
584
585 t_approx_P_adjoint_log_du_dP(i, k, L) =
586 t_R(i, l) * t_Ldiff_h_u(l, k, L);
587
588 if (EshelbianCore::symmetrySelector == SYMMETRIC) {
590 t_A(m, L, i, k) = t_diff_Rr(i, l, m) * t_Ldiff_h_u(l, k, L);
592 t_B(m, L, i, k) = t_diff_Rl(i, l, m) * t_Ldiff_h_u(l, k, L);
593
594 t_approx_P_adjoint_log_du_domega(m, L) =
595 half_r * (t_A(m, L, i, k) * t_approx_P(i, k))
596
597 +
598
599 half_l * (t_B(m, L, i, k) * t_approx_P(i, k));
600 } else {
602 t_A(m, L, i, k) = t_diff_R(i, l, m) * t_Ldiff_h_u(l, k, L);
603 t_approx_P_adjoint_log_du_domega(m, L) =
604 t_A(m, L, i, k) * t_approx_P(i, k);
605 }
606
607 t_levi_kirchhoff_dstreach(m, L) =
608 half_r *
609 (t_diff_Rr(i, l, m) * (t_Ldiff_h_u(l, k, L) * t_approx_P(i, k)))
610
611 +
612
613 half_l * (t_diff_Rl(i, l, m) *
614 (t_Ldiff_h_u(l, k, L) * t_approx_P(i, k)));
615
616 t_levi_kirchhoff_dP(m, i, k) =
617
618 half_r * (t_diff_Rr(i, l, m) * t_h_u(l, k))
619
620 +
621
622 half_l * (t_diff_Rl(i, l, m) * t_h_u(l, k));
623
624 t_levi_kirchhoff_domega(m, n) =
625 half_r *
626 (t_diff_diff_Rr(i, l, m, n) * (t_h_u(l, k) * t_approx_P(i, k)))
627
628 +
629
630 half_l *
631 (t_diff_diff_Rl(i, l, m, n) * (t_h_u(l, k) * t_approx_P(i, k)));
632 }
633
634 next();
635 }
636
638 };
639
640 auto moderate_loop = [&]() {
642
644 case LARGE_ROT:
645 break;
646 case SMALL_ROT:
647 break;
648 default:
649 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
650 "rotSelector should be large");
651 };
652
653 for (int gg = 0; gg != nb_integration_pts; ++gg) {
654
656
659 case MODERATE_ROT:
660 t_h1(i, j) = t_grad_h1(i, j) + t_kd(i, j);
661 break;
662 default:
663 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
664 "gradApproximator not handled");
665 };
666
667 // calculate streach
668 auto t_Ldiff_u = calculate_log_stretch();
669 // calculate total stretch
670 auto [t_R_h1, t_inv_u_h1] = calculate_total_stretch(t_h1);
671
673 t_h_u(l, k) = (t_symm_kd(l, o) + t_log_u(l, o)) * t_h1(o, k);
675 t_L_h(l, k, L) = t_L(l, o, L) * t_h1(o, k);
676
681
683
684 // rotation
686 case LARGE_ROT:
687 t_R(i, j) = LieGroups::SO3::exp(t_omega, t_omega.l2())(i, j);
688 t_diff_R(i, j, k) =
689 LieGroups::SO3::diffExp(t_omega, t_omega.l2())(i, j, k);
690 // left
691 t_diff_Rr(i, j, l) = t_R(i, k) * levi_civita(k, j, l);
692 t_diff_diff_Rr(i, j, l, m) = t_diff_R(i, k, m) * levi_civita(k, j, l);
693 // right
694 t_diff_Rl(i, j, l) = levi_civita(i, k, l) * t_R(k, j);
695 t_diff_diff_Rl(i, j, l, m) = levi_civita(i, k, l) * t_diff_R(k, j, m);
696 break;
697 case SMALL_ROT:
698 t_R(i, k) = t_kd(i, k) + levi_civita(i, k, l) * t_omega(l);
699 t_diff_R(i, j, l) = levi_civita(i, j, l);
700 // left
701 t_diff_Rr(i, j, l) = levi_civita(i, j, l);
702 t_diff_diff_Rr(i, j, l, m) = 0;
703 // right
704 t_diff_Rl(i, j, l) = levi_civita(i, j, l);
705 t_diff_diff_Rl(i, j, l, m) = 0;
706 break;
707
708 default:
709 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
710 "rotationSelector not handled");
711 }
712
713 constexpr double half_r = 1 / 2.;
714 constexpr double half_l = 1 / 2.;
715
716 // calculate gradient
717 t_h(i, k) = t_R(i, l) * t_h_u(l, k);
718
719 // Adjoint stress
720 t_approx_P_adjoint__dstretch(l, o) =
721 (t_R(i, l) * t_approx_P(i, k)) * t_h1(o, k);
722
723 t_approx_P_adjoint_log_du(L) =
724 t_approx_P_adjoint__dstretch(l, o) * t_L(l, o, L);
725
726 // Kirchhoff stress
727 t_levi_kirchhoff(m) =
728
729 half_r * ((t_diff_Rr(i, l, m) * (t_h_u(l, k)) * t_approx_P(i, k)))
730
731 +
732
733 half_l * ((t_diff_Rl(i, l, m) * (t_h_u(l, k)) * t_approx_P(i, k)));
734
736
737 if (EshelbianCore::symmetrySelector == SYMMETRIC) {
738 t_h_domega(i, k, m) = half_r * (t_diff_Rr(i, l, m) * t_h_u(l, k))
739
740 +
741
742 half_l * (t_diff_Rl(i, l, m) * t_h_u(l, k));
743 } else {
744 t_h_domega(i, k, m) = t_diff_R(i, l, m) * t_h_u(l, k);
745 }
746
747 t_h_dlog_u(i, k, L) = t_R(i, l) * t_L_h(l, k, L);
748
749 t_approx_P_adjoint_log_du_dP(i, k, L) = t_R(i, l) * t_L_h(l, k, L);
750
751 if (EshelbianCore::symmetrySelector == SYMMETRIC) {
753 t_A(m, L, i, k) = t_diff_Rr(i, l, m) * t_L_h(l, k, L);
755 t_B(m, L, i, k) = t_diff_Rl(i, l, m) * t_L_h(l, k, L);
756 t_approx_P_adjoint_log_du_domega(m, L) =
757 half_r * (t_A(m, L, i, k) * t_approx_P(i, k))
758
759 +
760
761 half_l * (t_B(m, L, i, k) * t_approx_P(i, k));
762 } else {
764 t_A(m, L, i, k) = t_diff_R(i, l, m) * t_L_h(l, k, L);
765 t_approx_P_adjoint_log_du_domega(m, L) =
766 t_A(m, L, i, k) * t_approx_P(i, k);
767 }
768
769 t_levi_kirchhoff_dstreach(m, L) =
770 half_r * (t_diff_Rr(i, l, m) * (t_L_h(l, k, L) * t_approx_P(i, k)))
771
772 +
773
774 half_l * (t_diff_Rl(i, l, m) * (t_L_h(l, k, L) * t_approx_P(i, k)));
775
776 t_levi_kirchhoff_dP(m, i, k) =
777
778 half_r * (t_diff_Rr(i, l, m) * t_h_u(l, k))
779
780 +
781
782 half_l * (t_diff_Rl(i, l, m) * t_h_u(l, k));
783
784 t_levi_kirchhoff_domega(m, n) =
785 half_r *
786 (t_diff_diff_Rr(i, l, m, n) * (t_h_u(l, k) * t_approx_P(i, k)))
787
788 +
789
790 half_l *
791 (t_diff_diff_Rl(i, l, m, n) * (t_h_u(l, k) * t_approx_P(i, k)));
792 }
793
794 next();
795 }
796
798 };
799
800 auto small_loop = [&]() {
803 case SMALL_ROT:
804 break;
805 default:
806 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
807 "rotSelector should be small");
808 };
809
810 for (int gg = 0; gg != nb_integration_pts; ++gg) {
811
814 case SMALL_ROT:
815 t_h1(i, j) = t_kd(i, j);
816 break;
817 default:
818 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
819 "gradApproximator not handled");
820 };
821
822 // calculate streach
824
825 if (EshelbianCore::stretchSelector > LINEAR) {
826 t_Ldiff_u(i, j, L) = calculate_log_stretch()(i, j, L);
827 } else {
828 t_u(i, j) = t_symm_kd(i, j) + t_log_u(i, j);
829 t_Ldiff_u(i, j, L) = t_L(i, j, L);
830 }
831 t_log_u2_h1(i, j) = 0;
832 t_log_stretch_total(i, j) = t_log_u(i, j);
833
835 t_h(i, j) = levi_civita(i, j, k) * t_omega(k) + t_u(i, j);
836
837 t_h_domega(i, j, k) = levi_civita(i, j, k);
838 t_h_dlog_u(i, j, L) = t_Ldiff_u(i, j, L);
839
840 // Adjoint stress
841 t_approx_P_adjoint__dstretch(i, j) = t_approx_P(i, j);
842 t_approx_P_adjoint_log_du(L) =
843 t_approx_P_adjoint__dstretch(i, j) * t_Ldiff_u(i, j, L);
844 t_approx_P_adjoint_log_du_dP(i, j, L) = t_Ldiff_u(i, j, L);
845 t_approx_P_adjoint_log_du_domega(m, L) = 0;
846
847 // Kirchhoff stress
848 t_levi_kirchhoff(k) = levi_civita(i, j, k) * t_approx_P(i, j);
849 t_levi_kirchhoff_dstreach(m, L) = 0;
850 t_levi_kirchhoff_dP(k, i, j) = levi_civita(i, j, k);
851 t_levi_kirchhoff_domega(m, n) = 0;
852
853 next();
854 }
855
857 };
858
861 CHKERR no_h1_loop();
862 break;
863 case LARGE_ROT:
864 CHKERR large_loop();
866 break;
867 case MODERATE_ROT:
868 CHKERR moderate_loop();
870 break;
871 case SMALL_ROT:
872 CHKERR small_loop();
874 break;
875 default:
876 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
877 "gradApproximator not handled");
878 break;
879 };
880
882}
#define FTENSOR_INDEX(DIM, I)
constexpr int SPACE_DIM
Kronecker Delta class symmetric.
Kronecker Delta class.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
constexpr auto t_kd
#define MOFEM_LOG(channel, severity)
Log.
FTensor::Index< 'i', SPACE_DIM > i
const double n
refractive index of diffusive medium
MoFEM::TsCtx * ts_ctx
FTensor::Index< 'l', 3 > l
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
auto getMat(A &&t_val, B &&t_vec, Fun< double > f)
Get the Mat object.
auto getDiffMat(A &&t_val, B &&t_vec, Fun< double > f, Fun< double > d_f, const int nb)
Get the Diff Mat object.
constexpr std::enable_if<(Dim0<=2 &&Dim1<=2), Tensor2_Expr< Levi_Civita< T >, T, Dim0, Dim1, i, j > >::type levi_civita(const Index< i, Dim0 > &, const Index< j, Dim1 > &)
levi_civita functions to make for easy adhoc use
auto sort_eigen_vals(FTensor::Tensor1< double, DIM > &eig, FTensor::Tensor2< double, DIM, DIM > &eigen_vec)
Definition HenckyOps.hpp:41
MoFEMErrorCode computeEigenValuesSymmetric(const MatrixDouble &mat, VectorDouble &eig, MatrixDouble &eigen_vec)
compute eigenvalues of a symmetric matrix using lapack dsyev
auto symm_L_tensor(FTensor::Number< DIM >)
constexpr auto size_symm
Definition plastic.cpp:42
FTensor::Index< 'm', 3 > m
static enum StretchSelector stretchSelector
static enum RotSelector rotSelector
static enum RotSelector gradApproximator
static enum SymmetrySelector symmetrySelector
static boost::function< double(const double)> f
static boost::function< double(const double)> d_f
static boost::function< double(const double)> inv_f
static auto diffExp(A &&t_w_vee, B &&theta)
Definition Lie.hpp:79
static auto exp(A &&t_w_vee, B &&theta)
Definition Lie.hpp:48
MatrixDouble & getGaussPts()
matrix of integration (Gauss) points for Volume Element

Member Data Documentation

◆ alphaOmega

double OpCalculateRotationAndSpatialGradient::alphaOmega
private

Definition at line 303 of file EshelbianOperators.hpp.

◆ dataAtPts

boost::shared_ptr<DataAtIntegrationPts> OpCalculateRotationAndSpatialGradient::dataAtPts
private

data at integration pts

Definition at line 302 of file EshelbianOperators.hpp.


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