v0.15.0
Loading...
Searching...
No Matches
ADOLCPlasticity::ClosestPointProjection Struct Referenceabstract

Closest point projection algorithm. More...

#include "users_modules/adolc-plasticity/src/ADOLCPlasticity.hpp"

Inheritance diagram for ADOLCPlasticity::ClosestPointProjection:
[legend]
Collaboration diagram for ADOLCPlasticity::ClosestPointProjection:
[legend]

Public Types

enum  TypesTags { W = 0 , Y , H , LAST_TAPE }
 

Public Member Functions

VectorAdaptor getPlasticStrain ()
 
VectorAdaptor getTotalStrain ()
 
VectorAdaptor getInternalVariables ()
 
VectorAdaptor getActiveVariablesYH ()
 
VectorAdaptor getStress ()
 
VectorAdaptor getInternalFluxes ()
 
 ClosestPointProjection ()
 
MoFEMErrorCode recordW ()
 Record strain energy.
 
MoFEMErrorCode recordY ()
 Record yield function.
 
MoFEMErrorCode recordH ()
 Record flow potential.
 
MoFEMErrorCode playW ()
 
MoFEMErrorCode playW_NoHessian ()
 
MoFEMErrorCode playY ()
 
MoFEMErrorCode playY_NoGradient ()
 
MoFEMErrorCode playH ()
 
MoFEMErrorCode playH_NoHessian ()
 
MoFEMErrorCode createMatAVecR ()
 
MoFEMErrorCode evaluatePotentials ()
 
MoFEMErrorCode playPotentials ()
 
MoFEMErrorCode playPotentials_NoHessian ()
 
MoFEMErrorCode calculateR (Vec R)
 
MoFEMErrorCode calculateA ()
 
MoFEMErrorCode snesCreate ()
 Create nested snes.
 
MoFEMErrorCode solveClosestProjection ()
 Solve nonlinear system of equations to find stress, internal fluxes, and Lagrange plastic multiplier.
 
MoFEMErrorCode consistentTangent ()
 Calculate consistent tangent matrix.
 
MoFEMErrorCode recordTapes ()
 Record tapes.
 
virtual MoFEMErrorCode addMatBlockOps (MoFEM::Interface &m_field, boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &pip, std::string block_name, Sev sev)
 Get model parameters from blocks.
 
virtual MoFEMErrorCode setParams (short tag, bool &recalculate_elastic_tangent)
 Set parameters for ADOL-C of constitutive relations.
 
virtual MoFEMErrorCode freeHemholtzEnergy ()=0
 Set Hemholtz energy.
 
virtual MoFEMErrorCode yieldFunction ()=0
 Set yield function.
 
virtual MoFEMErrorCode flowPotential ()=0
 Set flow potential.
 
virtual MoFEMErrorCode codedHessianW (vector< double * >)
 

Public Attributes

int nbInternalVariables
 
boost::function< int(int, int, int)> integrationRule
 
VectorDouble internalVariables0
 
VectorDouble plasticStrain0
 
std::array< int, LAST_TAPEtapesTags
 
VectorAdaptor activeVariablesW
 
VectorAdaptor gradientW
 
double w
 
double y
 
double h
 
double deltaGamma
 
MatrixDouble Ep
 
MatrixDouble Cp
 
MatrixDouble Cep
 
ublas::symmetric_matrix< double, ublas::lower > C
 
ublas::symmetric_matrix< double, ublas::lower > D
 
PetscBool implHessianW
 
MatrixDouble hessianW
 
VectorDouble gradientY
 
VectorDouble gradientH
 
MatrixDouble hessianH
 
MatrixDouble partialWStrainPlasticStrain
 
VectorAdaptor partialYSigma
 
VectorAdaptor partialYFlux
 
VectorAdaptor partialHSigma
 
VectorAdaptor partialHFlux
 
ublas::symmetric_matrix< double, ublas::lower > partial2HSigma
 
ublas::symmetric_matrix< double, ublas::lower > partial2HFlux
 
MatrixDouble partial2HSigmaFlux
 
SmartPetscObj< Mat > A
 
SmartPetscObj< Vec > R
 
SmartPetscObj< Vec > Chi
 
SmartPetscObj< Vec > dChi
 
ublas::matrix< double, ublas::column_major > dataA
 
SmartPetscObj< SNES > sNes
 
ublas::vector< adoublea_sTrain
 
ublas::vector< adoublea_plasticStrain
 
ublas::vector< adoublea_internalVariables
 
ublas::vector< adoublea_sTress
 
ublas::vector< adoublea_internalFluxes
 
adouble a_w
 
adouble a_y
 
adouble a_h
 

Friends

MoFEMErrorCode ADOLCPlasticityRes (SNES snes, Vec chi, Vec r, void *ctx)
 Function executed by nested SENES at evaluationg residual.
 
MoFEMErrorCode ADOLCPlasticityJac (SNES snes, Vec chi, Mat A, Mat, void *ctx)
 Function executed by nested SENES at evaluationg tangent matrix.
 

Detailed Description

Closest point projection algorithm.

Definition at line 145 of file ADOLCPlasticity.hpp.

Member Enumeration Documentation

◆ TypesTags

Constructor & Destructor Documentation

◆ ClosestPointProjection()

ADOLCPlasticity::ClosestPointProjection::ClosestPointProjection ( )
Examples
ADOLCPlasticity.hpp, and ADOLCPlasticityMaterialModels.hpp.

Definition at line 15 of file ClosestPointProjection.cpp.

15 {
16
17 if (!LogManager::checkIfChannelExist("ADOLCPlasticityWold")) {
18 auto core_log = logging::core::get();
19
21 "ADOLCPlasticityWold"));
23 "ADOLCPlasticitySync"));
25 "ADOLCPlasticitySelf"));
26
27 LogManager::setLog("ADOLCPlasticityWold");
28 LogManager::setLog("ADOLCPlasticitySync");
29 LogManager::setLog("ADOLCPlasticitySelf");
30
31 MOFEM_LOG_TAG("ADOLCPlasticityWold", "ADOL-C Plasticity");
32 MOFEM_LOG_TAG("ADOLCPlasticitySync", "ADOL-C Plasticity");
33 MOFEM_LOG_TAG("ADOLCPlasticitySelf", "ADOL-C Plasticity");
34 }
35
36 tapesTags = {0, 1, 2}; //< set tapes default tags
37
38 implHessianW = PETSC_FALSE;
39 CHKERR PetscOptionsGetBool(PETSC_NULLPTR, "-impl_hessianW", &implHessianW, 0);
40
41}
#define CHKERR
Inline error check.
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
PetscErrorCode PetscOptionsGetBool(PetscOptions *, const char pre[], const char name[], PetscBool *bval, PetscBool *set)
std::array< int, LAST_TAPE > tapesTags
static boost::shared_ptr< SinkType > createSink(boost::shared_ptr< std::ostream > stream_ptr, std::string comm_filter)
Create a sink object.
static boost::shared_ptr< std::ostream > getStrmWorld()
Get the strm world object.
static boost::shared_ptr< std::ostream > getStrmSync()
Get the strm sync object.
static bool checkIfChannelExist(const std::string channel)
Check if channel exist.
static boost::shared_ptr< std::ostream > getStrmSelf()
Get the strm self object.

Member Function Documentation

◆ addMatBlockOps()

virtual MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::addMatBlockOps ( MoFEM::Interface & m_field,
boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > & pip,
std::string block_name,
Sev sev )
inlinevirtual

Get model parameters from blocks.

Reimplemented in ADOLCPlasticity::HeterogeneousParaboloidalPlasticity, ADOLCPlasticity::J2Plasticity< 3 >, and ADOLCPlasticity::ParaboloidalPlasticity.

Examples
ADOLCPlasticity.hpp.

Definition at line 269 of file ADOLCPlasticity.hpp.

271 {
272 return 0;
273 }

◆ calculateA()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::calculateA ( )
Examples
ADOLCPlasticity.hpp.

Definition at line 393 of file ClosestPointProjection.cpp.

393 {
395 // matrix A
396 CHKERR MatZeroEntries(A);
397 // row 0 (Strain)
399 MatrixDouble a01 = prod(partial2HSigmaFlux, D);
400 for (int ii = 0; ii < 6; ii++) {
401 for (int jj = 0; jj < 6; jj++) {
402 dataA(ii, jj) = deltaGamma * a00(ii, jj);
403 }
404 for (unsigned int jj = 0; jj < nbInternalVariables; jj++) {
405 dataA(ii, 6 + jj) = deltaGamma * a01(ii, jj);
406 }
407 dataA(ii, ii) -= 1;
408 }
409 for (int ii = 0; ii < 6; ii++) {
411 }
412 // row 1 (Fluxes)
413 MatrixDouble a11 = prod(partial2HFlux, D);
414 MatrixDouble a10 =
416 for (unsigned int ii = 0; ii < nbInternalVariables; ii++) {
417 for (int jj = 0; jj < 6; jj++) {
418 dataA(6 + ii, jj) += deltaGamma * a10(ii, jj);
419 }
420 for (unsigned int jj = 0; jj < nbInternalVariables; jj++) {
421 dataA(6 + ii, 6 + jj) += deltaGamma * a11(ii, jj);
422 }
423 dataA(6 + ii, 6 + ii) -= 1;
424 }
425 for (unsigned int ii = 0; ii < nbInternalVariables; ii++) {
426 dataA(6 + ii, 6 + nbInternalVariables) = partialHFlux[ii];
427 }
428 // row 3 (Plastic multiplier)
429 VectorDouble partial_y_sigma_c =
431 VectorDouble partial_y_flux_d = prod(trans(D), partialYFlux);
432 for (unsigned int dd = 0; dd < partial_y_sigma_c.size(); dd++) {
433 dataA(6 + nbInternalVariables, dd) = partial_y_sigma_c[dd];
434 }
435 for (unsigned int dd = 0; dd < partial_y_flux_d.size(); dd++) {
436 dataA(6 + nbInternalVariables, 6 + dd) = partial_y_flux_d[dd];
437 }
439 CHKERR MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY);
440 CHKERR MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY);
442}
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
const Tensor2_symmetric_Expr< const ddTensor0< T, Dim, i, j >, typename promote< T, double >::V, Dim, i, j > dd(const Tensor0< T * > &a, const Index< i, Dim > index1, const Index< j, Dim > index2, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
Definition ddTensor0.hpp:33
ublas::symmetric_matrix< double, ublas::lower > partial2HFlux
ublas::symmetric_matrix< double, ublas::lower > D
ublas::symmetric_matrix< double, ublas::lower > partial2HSigma
ublas::matrix< double, ublas::column_major > dataA

◆ calculateR()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::calculateR ( Vec R)
Examples
ADOLCPlasticity.hpp.

Definition at line 371 of file ClosestPointProjection.cpp.

371 {
373
374 auto plastic_strain = getPlasticStrain();
375 auto internal_variables = getInternalVariables();
376
377 // Residual
378 double *array;
379 CHKERR VecGetArray(R, &array);
380 for (int ii = 0; ii < 6; ii++) {
381 array[ii] = -plastic_strain[ii] + plasticStrain0[ii] +
383 }
384 for (unsigned int ii = 0; ii < nbInternalVariables; ii++) {
385 array[6 + ii] = -internal_variables[ii] + internalVariables0[ii] +
387 }
388 array[6 + nbInternalVariables] = y;
389 CHKERR VecRestoreArray(R, &array);
391}

◆ codedHessianW()

virtual MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::codedHessianW ( vector< double * > )
inlinevirtual

◆ consistentTangent()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::consistentTangent ( )

Calculate consistent tangent matrix.

Examples
ADOLCPlasticity.hpp.

Definition at line 520 of file ClosestPointProjection.cpp.

520 {
524 Ep.resize(6, 6, false);
525 MatrixDouble ep_row; // inrement internal varaibles as result of incremen of
526 // total strain
527 ep_row = deltaGamma * prod(partial2HSigma, C);
528 MatrixDouble alpha_row;
529 alpha_row = deltaGamma * prod(trans(partial2HSigmaFlux), C);
530 VectorDouble y_row;
531 y_row = prod(C, partialYSigma);
532 const int n = 6 + nbInternalVariables;
533 // Iterate strains
534 for (int dd = 0; dd < 6; dd++) {
535 CHKERR VecZeroEntries(R);
536 double *array;
537 CHKERR VecGetArray(R, &array);
538 {
539 for (auto ii = 0; ii < 6; ii++) {
540 array[ii] = ep_row(ii, dd);
541 }
542 for (auto ii = 0; ii < nbInternalVariables; ii++) {
543 array[6 + ii] = alpha_row(ii, dd);
544 }
545 array[n] = y_row[dd];
546 }
547 CHKERR VecRestoreArray(R, &array);
548 CHKERR VecAssemblyBegin(R);
549 CHKERR VecAssemblyEnd(R);
550
551 KSP ksp;
552 CHKERR SNESGetKSP(sNes, &ksp);
553 CHKERR KSPSolve(ksp, R, dChi);
554 CHKERR VecGetArray(dChi, &array);
555 {
556 for (auto ii = 0; ii < 6; ii++) {
557 Ep(ii, dd) = array[ii];
558 }
559 }
560 CHKERR VecRestoreArray(dChi, &array);
561 }
562 Cp.resize(6, 6, false);
563 noalias(Cp) = prod(C, Ep);
564 Cep.resize(6, 6, false);
565 noalias(Cep) = C + Cp;
567}
const double n
refractive index of diffusive medium
ublas::symmetric_matrix< double, ublas::lower > C

◆ createMatAVecR()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::createMatAVecR ( )
Examples
ADOLCPlasticity.hpp.

Definition at line 325 of file ClosestPointProjection.cpp.

325 {
327 PetscInt n;
328 n = 1 + 6 + nbInternalVariables;
329 dataA.resize(n, n, false);
330 Mat A_tmp;
331 Vec R_tmp, Chi_tmp, dChi_tmp;
332 CHKERR MatCreateSeqDense(PETSC_COMM_SELF, n, n, &dataA(0, 0), &A_tmp);
333 CHKERR VecCreateSeq(PETSC_COMM_SELF, n, &R_tmp);
334 CHKERR VecCreateSeq(PETSC_COMM_SELF, n, &Chi_tmp);
335 CHKERR VecCreateSeq(PETSC_COMM_SELF, n, &dChi_tmp);
336
337 A = SmartPetscObj<Mat>(A_tmp);
338 R = SmartPetscObj<Vec>(R_tmp);
339 Chi = SmartPetscObj<Vec>(Chi_tmp);
340 dChi = SmartPetscObj<Vec>(dChi_tmp);
341
343}
intrusive_ptr for managing petsc objects

◆ evaluatePotentials()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::evaluatePotentials ( )
Examples
ADOLCPlasticity.hpp.

Definition at line 346 of file ClosestPointProjection.cpp.

346 {
348 CHKERR recordW();
349 CHKERR recordY();
350 CHKERR recordH();
352}
MoFEMErrorCode recordH()
Record flow potential.
MoFEMErrorCode recordY()
Record yield function.
MoFEMErrorCode recordW()
Record strain energy.

◆ flowPotential()

virtual MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::flowPotential ( )
pure virtual

◆ freeHemholtzEnergy()

virtual MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::freeHemholtzEnergy ( )
pure virtual

◆ getActiveVariablesYH()

VectorAdaptor ADOLCPlasticity::ClosestPointProjection::getActiveVariablesYH ( )
inline
Examples
ADOLCPlasticity.hpp.

Definition at line 164 of file ADOLCPlasticity.hpp.

164 {
166 }
auto getVectorAdaptor(T1 ptr, const size_t n)
Get Vector adaptor.
Definition Templates.hpp:31

◆ getInternalFluxes()

VectorAdaptor ADOLCPlasticity::ClosestPointProjection::getInternalFluxes ( )
inline
Examples
ADOLCPlasticity.hpp.

Definition at line 170 of file ADOLCPlasticity.hpp.

170 {
172 }

◆ getInternalVariables()

VectorAdaptor ADOLCPlasticity::ClosestPointProjection::getInternalVariables ( )
inline
Examples
ADOLCPlasticity.hpp.

Definition at line 161 of file ADOLCPlasticity.hpp.

◆ getPlasticStrain()

VectorAdaptor ADOLCPlasticity::ClosestPointProjection::getPlasticStrain ( )
inline
Examples
ADOLCPlasticity.hpp.

Definition at line 155 of file ADOLCPlasticity.hpp.

155 {
156 return getVectorAdaptor(&(activeVariablesW[0]), 6);
157 }

◆ getStress()

VectorAdaptor ADOLCPlasticity::ClosestPointProjection::getStress ( )
inline
Examples
ADOLCPlasticity.hpp.

Definition at line 167 of file ADOLCPlasticity.hpp.

167 {
168 return getVectorAdaptor(&(gradientW[6]), 6);
169 }

◆ getTotalStrain()

VectorAdaptor ADOLCPlasticity::ClosestPointProjection::getTotalStrain ( )
inline
Examples
ADOLCPlasticity.hpp.

Definition at line 158 of file ADOLCPlasticity.hpp.

158 {
159 return getVectorAdaptor(&(activeVariablesW[6]), 6);
160 }

◆ playH()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::playH ( )
Examples
ADOLCPlasticity.hpp.

Definition at line 241 of file ClosestPointProjection.cpp.

241 {
243 auto active_variables_yh = getActiveVariablesYH();
244 int r;
245 int adloc_return_value = 0;
246 r = ::function(tapesTags[ClosestPointProjection::H], 1,
247 active_variables_yh.size(), &active_variables_yh[0], &h);
248 if (r < adloc_return_value) {
249 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
250 "ADOL-C function evaluation with error");
251 }
252 gradientH.resize(active_variables_yh.size());
253 r = gradient(tapesTags[ClosestPointProjection::H], active_variables_yh.size(),
254 &active_variables_yh[0], &gradientH[0]);
255 if (r < adloc_return_value) {
256 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
257 "ADOL-C function evaluation with error");
258 }
259 hessianH.resize(6 + nbInternalVariables, 6 + nbInternalVariables, false);
260 hessianH.clear();
261 vector<double *> hessian_h(active_variables_yh.size());
262 for (int dd = 0; dd < active_variables_yh.size(); dd++) {
263 hessian_h[dd] = &hessianH(dd, 0);
264 }
265 r = hessian(tapesTags[ClosestPointProjection::H], active_variables_yh.size(),
266 &active_variables_yh[0], &hessian_h[0]);
267 if (r < adloc_return_value) {
268 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
269 "ADOL-C function evaluation with error");
270 }
272 VectorAdaptor(6, ublas::shallow_array_adaptor<double>(6, &gradientH[0]));
275 ublas::shallow_array_adaptor<double>(nbInternalVariables, &gradientH[6]));
276 partialHFlux *= -1;
277 partial2HSigma.resize(6, 6, false);
278 for (int ii = 0; ii < 6; ii++) {
279 for (int jj = 0; jj <= ii; jj++) {
280 partial2HSigma(ii, jj) = hessianH(ii, jj);
281 }
282 }
284 for (unsigned int ii = 0; ii < nbInternalVariables; ii++) {
285 for (unsigned int jj = 0; jj <= ii; jj++) {
286 partial2HFlux(ii, jj) = -hessianH(6 + ii, 6 + jj);
287 }
288 }
289 partial2HSigmaFlux.resize(6, nbInternalVariables, false);
290 partial2HSigmaFlux.clear();
291 for (int ii = 0; ii < 6; ii++) {
292 for (unsigned int jj = 0; jj < nbInternalVariables; jj++) {
293 partial2HSigmaFlux(ii, jj) = -hessianH(6 + jj, ii);
294 }
295 }
297}
@ MOFEM_OPERATION_UNSUCCESSFUL
Definition definitions.h:34
VectorShallowArrayAdaptor< double > VectorAdaptor
Definition Types.hpp:115
int r
Definition sdf.py:8

◆ playH_NoHessian()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::playH_NoHessian ( )
Examples
ADOLCPlasticity.hpp.

Definition at line 298 of file ClosestPointProjection.cpp.

298 {
300 auto active_variables_yh = getActiveVariablesYH();
301 int r;
302 int adloc_return_value = 0;
303 r = ::function(tapesTags[ClosestPointProjection::H], 1,
304 active_variables_yh.size(), &active_variables_yh[0], &h);
305 if (r < adloc_return_value) {
306 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
307 "ADOL-C function evaluation with error");
308 }
309 gradientH.resize(active_variables_yh.size());
310 r = gradient(tapesTags[ClosestPointProjection::H], active_variables_yh.size(),
311 &active_variables_yh[0], &gradientH[0]);
312 if (r < adloc_return_value) {
313 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
314 "ADOL-C function evaluation with error");
315 }
317 VectorAdaptor(6, ublas::shallow_array_adaptor<double>(6, &gradientH[0]));
320 ublas::shallow_array_adaptor<double>(nbInternalVariables, &gradientH[6]));
321 partialHFlux *= -1;
323}

◆ playPotentials()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::playPotentials ( )

◆ playPotentials_NoHessian()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::playPotentials_NoHessian ( )

◆ playW()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::playW ( )
Examples
ADOLCPlasticity.hpp.

Definition at line 125 of file ClosestPointProjection.cpp.

125 {
127 int r;
128 int adloc_return_value = 0;
129 r = ::function(tapesTags[ClosestPointProjection::W], 1,
130 activeVariablesW.size(), &activeVariablesW[0], &w);
131 if (r < adloc_return_value) {
132 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
133 "ADOL-C function evaluation with error");
134 }
136 &activeVariablesW[0], &gradientW[0]);
137 if (r < adloc_return_value) {
138 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
139 "ADOL-C function evaluation with error");
140 }
141
142 hessianW.resize(activeVariablesW.size(), activeVariablesW.size(), false);
143 hessianW.clear();
144 vector<double *> hessian_w(activeVariablesW.size());
145 for (unsigned int dd = 0; dd < activeVariablesW.size(); dd++) {
146 hessian_w[dd] = &hessianW(dd, 0);
147 }
148 if (!implHessianW) {
149 // call adolc hessian (energy, active variables)
151 &activeVariablesW[0], &hessian_w[0]);
152 if (r < adloc_return_value) {
153 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
154 "ADOL-C function evaluation with error");
155 }
156 } else {
157 // call hard coded hessian depending on material model
158 CHKERR codedHessianW(hessian_w);
159 }
160
161 partialWStrainPlasticStrain.resize(6, 6, false);
162 for (int ii = 0; ii < 6; ii++) {
163 for (int jj = 0; jj < 6; jj++) {
164 partialWStrainPlasticStrain(ii, jj) = hessianW(6 + ii, jj);
165 }
166 }
167 C.resize(6, 6, false);
168 for (int ii = 0; ii < 6; ii++) {
169 for (int jj = 0; jj <= ii; jj++) {
170 C(ii, jj) = hessianW(6 + ii, 6 + jj);
171 }
172 }
174 for (unsigned int ii = 0; ii < nbInternalVariables; ii++) {
175 for (unsigned int jj = 0; jj <= ii; jj++) {
176 D(ii, jj) = hessianW(12 + ii, 12 + jj);
177 }
178 }
180}
virtual MoFEMErrorCode codedHessianW(vector< double * >)

◆ playW_NoHessian()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::playW_NoHessian ( )
Examples
ADOLCPlasticity.hpp.

Definition at line 183 of file ClosestPointProjection.cpp.

183 {
185 int r;
186 int adloc_return_value = 0;
187 r = ::function(tapesTags[ClosestPointProjection::W], 1,
188 activeVariablesW.size(), &activeVariablesW[0], &w);
189 if (r < adloc_return_value) {
190 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
191 "ADOL-C function evaluation with error");
192 }
194 &activeVariablesW[0], &gradientW[0]);
195 if (r < adloc_return_value) {
196 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
197 "ADOL-C function evaluation with error");
198 }
200}

◆ playY()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::playY ( )
Examples
ADOLCPlasticity.hpp.

Definition at line 202 of file ClosestPointProjection.cpp.

202 {
204 auto active_variables_yh = getActiveVariablesYH();
205 int r;
206 int adloc_return_value = 0;
207 r = ::function(tapesTags[ClosestPointProjection::Y], 1,
208 active_variables_yh.size(), &active_variables_yh[0], &y);
209 if (r < adloc_return_value) {
210 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
211 "ADOL-C function evaluation with error");
212 }
213 gradientY.resize(active_variables_yh.size());
214 r = gradient(tapesTags[ClosestPointProjection::Y], active_variables_yh.size(),
215 &active_variables_yh[0], &gradientY[0]);
216 if (r < adloc_return_value) {
217 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
218 "ADOL-C function evaluation with error");
219 }
221 VectorAdaptor(6, ublas::shallow_array_adaptor<double>(6, &gradientY[0]));
224 ublas::shallow_array_adaptor<double>(nbInternalVariables, &gradientY[6]));
226}

◆ playY_NoGradient()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::playY_NoGradient ( )
Examples
ADOLCPlasticity.hpp.

Definition at line 228 of file ClosestPointProjection.cpp.

228 {
230 auto active_variables_yh = getActiveVariablesYH();
231 int r;
232 int adloc_return_value = 0;
233 r = ::function(tapesTags[ClosestPointProjection::Y], 1,
234 active_variables_yh.size(), &active_variables_yh[0], &y);
235 if (r < adloc_return_value) {
236 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
237 "ADOL-C function evaluation with error");
238 }
240}

◆ recordH()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::recordH ( )

Record flow potential.

Examples
ADOLCPlasticity.hpp.

Definition at line 99 of file ClosestPointProjection.cpp.

99 {
101
102 auto stress = getStress();
103 auto internal_fluxes = getInternalFluxes();
104
106 {
107 // active variables
108 a_sTress.resize(6, false);
109 for (int ii = 0; ii < 6; ii++) {
110 a_sTress[ii] <<= stress[ii];
111 }
113 for (unsigned int ii = 0; ii < nbInternalVariables; ii++) {
114 a_internalFluxes[ii] <<= internal_fluxes[ii];
115 }
116 // evaluete functions
118 // return variables
119 a_h >>= h;
120 }
121 trace_off();
123}
virtual MoFEMErrorCode flowPotential()=0
Set flow potential.

◆ recordTapes()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::recordTapes ( )

Record tapes.

Examples
ADOLCPlasticity.hpp.

Definition at line 621 of file ClosestPointProjection.cpp.

621 {
624 VectorDouble gradient(12 + nbInternalVariables);
625 auto tmp_active = getVectorAdaptor(&(active[0]), 12 + nbInternalVariables);
626 auto tmp_gradient =
627 getVectorAdaptor(&(gradient[0]), 12 + nbInternalVariables);
628 activeVariablesW.swap(tmp_active);
629 gradientW.swap(tmp_gradient);
632}

◆ recordW()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::recordW ( )

Record strain energy.

Examples
ADOLCPlasticity.hpp.

Definition at line 43 of file ClosestPointProjection.cpp.

43 {
45
46 auto plastic_strain = getPlasticStrain();
47 auto total_strain = getTotalStrain();
48 auto internal_variables = getInternalVariables();
49
51 {
52 // active variables
53 a_plasticStrain.resize(6, false);
54 for (int ii = 0; ii < 6; ii++) {
55 a_plasticStrain[ii] <<= plastic_strain[ii];
56 }
57 a_sTrain.resize(6, false);
58 for (int ii = 0; ii < 6; ii++) {
59 a_sTrain[ii] <<= total_strain[ii];
60 }
62 for (unsigned int ii = 0; ii < nbInternalVariables; ii++) {
63 a_internalVariables[ii] <<= internal_variables[ii];
64 }
65 // evaluete functions
67 a_w >>= w;
68 }
69 trace_off();
71}
virtual MoFEMErrorCode freeHemholtzEnergy()=0
Set Hemholtz energy.

◆ recordY()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::recordY ( )

Record yield function.

Examples
ADOLCPlasticity.hpp.

Definition at line 73 of file ClosestPointProjection.cpp.

73 {
75
76 auto stress = getStress();
77 auto internal_fluxes = getInternalFluxes();
78
80 {
81 // active variables
82 a_sTress.resize(6, false);
83 for (int ii = 0; ii < 6; ii++) {
84 a_sTress[ii] <<= stress[ii];
85 }
87 for (unsigned int ii = 0; ii < nbInternalVariables; ii++) {
88 a_internalFluxes[ii] <<= internal_fluxes[ii];
89 }
90 // evaluete functions
92 // return variables
93 a_y >>= y;
94 }
95 trace_off();
97}
virtual MoFEMErrorCode yieldFunction()=0
Set yield function.

◆ setParams()

virtual MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::setParams ( short tag,
bool & recalculate_elastic_tangent )
inlinevirtual

Set parameters for ADOL-C of constitutive relations.

Parameters
tag[in] - tag of the tape
recalculate_elastic_tangent[out] - if setParam set it to true, tangent matrix for elastic domain should be recalculated

Reimplemented in ADOLCPlasticity::J2Plasticity< 3 >, and ADOLCPlasticity::ParaboloidalPlasticity.

Examples
ADOLCPlasticity.hpp.

Definition at line 282 of file ADOLCPlasticity.hpp.

283 {
284 return 0;
285 }

◆ snesCreate()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::snesCreate ( )

Create nested snes.

Examples
ADOLCPlasticity.hpp.

Definition at line 444 of file ClosestPointProjection.cpp.

444 {
446 sNes = createSNES(PETSC_COMM_SELF);
447 CHKERR SNESSetFunction(sNes, R, ADOLCPlasticityRes, (void *)this);
448 CHKERR SNESSetJacobian(sNes, A, A, ADOLCPlasticityJac, (void *)this);
449
450 KSP ksp;
451 PC pc;
452 SNESLineSearch line_search;
453 CHKERR SNESGetKSP(sNes, &ksp);
454 CHKERR KSPGetPC(ksp, &pc);
455 CHKERR KSPSetType(ksp, KSPPREONLY);
456 CHKERR PCSetType(pc, PCLU);
457 CHKERR SNESSetTolerances(sNes, 1e-8, 1e-6, 1e-12, 20, 1000);
458 CHKERR SNESGetLineSearch(sNes, &line_search);
459 // CHKERR SNESLineSearchSetType(line_search, SNESLINESEARCHBASIC);
460 CHKERR SNESLineSearchSetType(line_search, SNESLINESEARCHBT);
461 // CHKERR SNESLineSearchSetType(line_search, SNESLINESEARCHL2);
462
463 CHKERR SNESAppendOptionsPrefix(sNes, "cp_");
464 CHKERR SNESSetFromOptions(sNes);
465
467}
auto createSNES(MPI_Comm comm)
friend MoFEMErrorCode ADOLCPlasticityRes(SNES, Vec, Vec, void *ctx)
Function executed by nested SENES at evaluationg residual.
friend MoFEMErrorCode ADOLCPlasticityJac(SNES, Vec, Mat, Mat, void *ctx)
Function executed by nested SENES at evaluationg tangent matrix.

◆ solveClosestProjection()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::solveClosestProjection ( )

Solve nonlinear system of equations to find stress, internal fluxes, and Lagrange plastic multiplier.

Examples
ADOLCPlasticity.hpp.

Definition at line 470 of file ClosestPointProjection.cpp.

470 {
472
473 auto plastic_strain = getPlasticStrain();
474 auto internal_variables = getInternalVariables();
475
476 {
477 double *array;
478 CHKERR VecGetArray(Chi, &array);
479 for (int ii = 0; ii < 6; ii++) {
480 array[ii] = plastic_strain[ii];
481 }
482 int nb_internal_variables = nbInternalVariables;
483 for (unsigned int ii = 0; ii < nb_internal_variables; ii++) {
484 array[6 + ii] = internal_variables[ii];
485 }
486 deltaGamma = 0;
487 CHKERR VecRestoreArray(Chi, &array);
488 }
489
490 CHKERR SNESSolve(sNes, PETSC_NULLPTR, Chi);
491 SNESConvergedReason reason;
492 CHKERR SNESGetConvergedReason(sNes, &reason);
493 if (reason < 0) {
494 int its;
495 CHKERR SNESGetIterationNumber(sNes, &its);
497 "ADOLCPlasticitySelf", Sev::warning,
498 "Plasticity Closest Point Projection - number of Newton iterations = %d",
499 its);
500 plastic_strain = plasticStrain0;
501 internal_variables = internalVariables0;
502 deltaGamma = 0;
503 } else {
504 double *array;
505 CHKERR VecGetArray(Chi, &array);
506 for (int ii = 0; ii < 6; ii++) {
507 plastic_strain[ii] = array[ii];
508 }
509 int nb_internal_variables = nbInternalVariables;
510 for (unsigned int ii = 0; ii < nb_internal_variables; ii++) {
511 internal_variables[ii] = array[6 + ii];
512 }
513 deltaGamma = array[6 + nb_internal_variables];
514 CHKERR VecRestoreArray(Chi, &array);
515 }
517}
#define MOFEM_LOG_C(channel, severity, format,...)

◆ yieldFunction()

virtual MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::yieldFunction ( )
pure virtual

Friends And Related Symbol Documentation

◆ ADOLCPlasticityJac

MoFEMErrorCode ADOLCPlasticityJac ( SNES snes,
Vec chi,
Mat A,
Mat ,
void * ctx )
friend

Function executed by nested SENES at evaluationg tangent matrix.

Examples
ADOLCPlasticity.hpp.

Definition at line 595 of file ClosestPointProjection.cpp.

596 {
599 cp = (ClosestPointProjection *)ctx;
600
601 auto plastic_strain = cp->getPlasticStrain();
602 auto internal_variables = cp->getInternalVariables();
603
604 {
605 const double *array;
606 CHKERR VecGetArrayRead(chi, &array);
607 for (auto ii = 0; ii < 6; ii++) {
608 plastic_strain[ii] = array[ii];
609 }
610 for (auto ii = 0; ii < cp->nbInternalVariables; ii++) {
611 internal_variables[ii] = array[6 + ii];
612 }
613 cp->deltaGamma = array[6 + cp->nbInternalVariables];
614 CHKERR VecRestoreArrayRead(chi, &array);
615 }
616 CHKERR cp->playPotentials();
617 CHKERR cp->calculateA();
619}

◆ ADOLCPlasticityRes

MoFEMErrorCode ADOLCPlasticityRes ( SNES snes,
Vec chi,
Vec r,
void * ctx )
friend

Function executed by nested SENES at evaluationg residual.

Examples
ADOLCPlasticity.hpp.

Definition at line 569 of file ClosestPointProjection.cpp.

569 {
572 cp = (ClosestPointProjection *)ctx;
573
574 auto plastic_strain = cp->getPlasticStrain();
575 auto internal_variables = cp->getInternalVariables();
576
577 {
578 const double *array;
579 CHKERR VecGetArrayRead(chi, &array);
580 for (auto ii = 0; ii < 6; ii++) {
581 plastic_strain[ii] = array[ii];
582 }
583 for (auto ii = 0; ii < cp->nbInternalVariables; ii++) {
584 internal_variables[ii] = array[6 + ii];
585 }
586 cp->deltaGamma = array[6 + cp->nbInternalVariables];
587 CHKERR VecRestoreArrayRead(chi, &array);
588 }
589 CHKERR cp->playPotentials_NoHessian();
590 CHKERR cp->calculateR(r);
591
593}

Member Data Documentation

◆ A

SmartPetscObj<Mat> ADOLCPlasticity::ClosestPointProjection::A
Examples
ADOLCPlasticity.hpp.

Definition at line 329 of file ADOLCPlasticity.hpp.

◆ a_h

adouble ADOLCPlasticity::ClosestPointProjection::a_h

◆ a_internalFluxes

ublas::vector<adouble> ADOLCPlasticity::ClosestPointProjection::a_internalFluxes

◆ a_internalVariables

ublas::vector<adouble> ADOLCPlasticity::ClosestPointProjection::a_internalVariables

◆ a_plasticStrain

ublas::vector<adouble> ADOLCPlasticity::ClosestPointProjection::a_plasticStrain

◆ a_sTrain

ublas::vector<adouble> ADOLCPlasticity::ClosestPointProjection::a_sTrain

◆ a_sTress

ublas::vector<adouble> ADOLCPlasticity::ClosestPointProjection::a_sTress

◆ a_w

adouble ADOLCPlasticity::ClosestPointProjection::a_w

◆ a_y

adouble ADOLCPlasticity::ClosestPointProjection::a_y

◆ activeVariablesW

VectorAdaptor ADOLCPlasticity::ClosestPointProjection::activeVariablesW

◆ C

ublas::symmetric_matrix<double, ublas::lower> ADOLCPlasticity::ClosestPointProjection::C
Examples
ADOLCPlasticity.hpp.

Definition at line 188 of file ADOLCPlasticity.hpp.

◆ Cep

MatrixDouble ADOLCPlasticity::ClosestPointProjection::Cep
Examples
ADOLCPlasticity.hpp.

Definition at line 187 of file ADOLCPlasticity.hpp.

◆ Chi

SmartPetscObj<Vec> ADOLCPlasticity::ClosestPointProjection::Chi
Examples
ADOLCPlasticity.hpp.

Definition at line 331 of file ADOLCPlasticity.hpp.

◆ Cp

MatrixDouble ADOLCPlasticity::ClosestPointProjection::Cp
Examples
ADOLCPlasticity.hpp.

Definition at line 187 of file ADOLCPlasticity.hpp.

◆ D

ublas::symmetric_matrix<double, ublas::lower> ADOLCPlasticity::ClosestPointProjection::D
Examples
ADOLCPlasticity.hpp.

Definition at line 188 of file ADOLCPlasticity.hpp.

◆ dataA

ublas::matrix<double, ublas::column_major> ADOLCPlasticity::ClosestPointProjection::dataA
Examples
ADOLCPlasticity.hpp.

Definition at line 333 of file ADOLCPlasticity.hpp.

◆ dChi

SmartPetscObj<Vec> ADOLCPlasticity::ClosestPointProjection::dChi
Examples
ADOLCPlasticity.hpp.

Definition at line 332 of file ADOLCPlasticity.hpp.

◆ deltaGamma

double ADOLCPlasticity::ClosestPointProjection::deltaGamma
Examples
ADOLCPlasticity.hpp.

Definition at line 186 of file ADOLCPlasticity.hpp.

◆ Ep

MatrixDouble ADOLCPlasticity::ClosestPointProjection::Ep
Examples
ADOLCPlasticity.hpp.

Definition at line 187 of file ADOLCPlasticity.hpp.

◆ gradientH

VectorDouble ADOLCPlasticity::ClosestPointProjection::gradientH
Examples
ADOLCPlasticity.hpp.

Definition at line 215 of file ADOLCPlasticity.hpp.

◆ gradientW

VectorAdaptor ADOLCPlasticity::ClosestPointProjection::gradientW
Examples
ADOLCPlasticity.hpp.

Definition at line 180 of file ADOLCPlasticity.hpp.

◆ gradientY

VectorDouble ADOLCPlasticity::ClosestPointProjection::gradientY
Examples
ADOLCPlasticity.hpp.

Definition at line 211 of file ADOLCPlasticity.hpp.

◆ h

double ADOLCPlasticity::ClosestPointProjection::h
Examples
ADOLCPlasticity.hpp.

Definition at line 184 of file ADOLCPlasticity.hpp.

◆ hessianH

MatrixDouble ADOLCPlasticity::ClosestPointProjection::hessianH
Examples
ADOLCPlasticity.hpp.

Definition at line 216 of file ADOLCPlasticity.hpp.

◆ hessianW

MatrixDouble ADOLCPlasticity::ClosestPointProjection::hessianW
Examples
ADOLCPlasticity.hpp.

Definition at line 207 of file ADOLCPlasticity.hpp.

◆ implHessianW

PetscBool ADOLCPlasticity::ClosestPointProjection::implHessianW
Examples
ADOLCPlasticity.hpp.

Definition at line 190 of file ADOLCPlasticity.hpp.

◆ integrationRule

boost::function<int(int, int, int)> ADOLCPlasticity::ClosestPointProjection::integrationRule
Initial value:
= [](int, int, int p) {
return 2 * (p - 1);
}
Examples
ADOLCPlasticity.hpp.

Definition at line 148 of file ADOLCPlasticity.hpp.

148 {
149 return 2 * (p - 1);
150 };

◆ internalVariables0

VectorDouble ADOLCPlasticity::ClosestPointProjection::internalVariables0
Examples
ADOLCPlasticity.hpp.

Definition at line 152 of file ADOLCPlasticity.hpp.

◆ nbInternalVariables

int ADOLCPlasticity::ClosestPointProjection::nbInternalVariables

◆ partial2HFlux

ublas::symmetric_matrix<double, ublas::lower> ADOLCPlasticity::ClosestPointProjection::partial2HFlux

Second partial derivative of flow potential with respect to internal fluxes

Examples
ADOLCPlasticity.hpp.

Definition at line 324 of file ADOLCPlasticity.hpp.

◆ partial2HSigma

ublas::symmetric_matrix<double, ublas::lower> ADOLCPlasticity::ClosestPointProjection::partial2HSigma

Second partial derivative of flow potential with respect to stresses and internal

Examples
ADOLCPlasticity.hpp.

Definition at line 321 of file ADOLCPlasticity.hpp.

◆ partial2HSigmaFlux

MatrixDouble ADOLCPlasticity::ClosestPointProjection::partial2HSigmaFlux

Mixed decond partial derivative of flow potential with respect to stresses and internal fluxes

Examples
ADOLCPlasticity.hpp.

Definition at line 327 of file ADOLCPlasticity.hpp.

◆ partialHFlux

VectorAdaptor ADOLCPlasticity::ClosestPointProjection::partialHFlux
Examples
ADOLCPlasticity.hpp.

Definition at line 316 of file ADOLCPlasticity.hpp.

◆ partialHSigma

VectorAdaptor ADOLCPlasticity::ClosestPointProjection::partialHSigma
Examples
ADOLCPlasticity.hpp.

Definition at line 314 of file ADOLCPlasticity.hpp.

◆ partialWStrainPlasticStrain

MatrixDouble ADOLCPlasticity::ClosestPointProjection::partialWStrainPlasticStrain
Examples
ADOLCPlasticity.hpp.

Definition at line 308 of file ADOLCPlasticity.hpp.

◆ partialYFlux

VectorAdaptor ADOLCPlasticity::ClosestPointProjection::partialYFlux
Examples
ADOLCPlasticity.hpp.

Definition at line 312 of file ADOLCPlasticity.hpp.

◆ partialYSigma

VectorAdaptor ADOLCPlasticity::ClosestPointProjection::partialYSigma
Examples
ADOLCPlasticity.hpp.

Definition at line 310 of file ADOLCPlasticity.hpp.

◆ plasticStrain0

VectorDouble ADOLCPlasticity::ClosestPointProjection::plasticStrain0
Examples
ADOLCPlasticity.hpp.

Definition at line 153 of file ADOLCPlasticity.hpp.

◆ R

SmartPetscObj<Vec> ADOLCPlasticity::ClosestPointProjection::R
Examples
ADOLCPlasticity.hpp.

Definition at line 330 of file ADOLCPlasticity.hpp.

◆ sNes

SmartPetscObj<SNES> ADOLCPlasticity::ClosestPointProjection::sNes
Examples
ADOLCPlasticity.hpp.

Definition at line 334 of file ADOLCPlasticity.hpp.

◆ tapesTags

std::array<int, LAST_TAPE> ADOLCPlasticity::ClosestPointProjection::tapesTags

◆ w

double ADOLCPlasticity::ClosestPointProjection::w
Examples
ADOLCPlasticity.hpp.

Definition at line 182 of file ADOLCPlasticity.hpp.

◆ y

double ADOLCPlasticity::ClosestPointProjection::y
Examples
ADOLCPlasticity.hpp.

Definition at line 183 of file ADOLCPlasticity.hpp.


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