v0.16.3
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Friends | List of all members
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_TAPE > tapesTags
 
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< adouble > a_sTrain
 
ublas::vector< adouble > a_plasticStrain
 
ublas::vector< adouble > a_internalVariables
 
ublas::vector< adouble > a_sTress
 
ublas::vector< adouble > a_internalFluxes
 
adouble a_w
 
adouble a_y
 
adouble a_h
 

Friends

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

Detailed Description

Closest point projection algorithm.

Definition at line 146 of file ADOLCPlasticity.hpp.

Member Enumeration Documentation

◆ TypesTags

Constructor & Destructor Documentation

◆ ClosestPointProjection()

ADOLCPlasticity::ClosestPointProjection::ClosestPointProjection ( )
Examples
/home/lk58p/mofem_install/vanilla_dev_release/mofem-cephas/mofem/users_modules/adolc-plasticity/src/ADOLCPlasticityMaterialModels.hpp, and mofem/users_modules/adolc-plasticity/src/ADOLCPlasticity.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}
#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

◆ calculateA()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::calculateA ( )
Examples
mofem/users_modules/adolc-plasticity/src/ADOLCPlasticity.hpp.

Definition at line 388 of file ClosestPointProjection.cpp.

388 {
390 // matrix A
391 CHKERR MatZeroEntries(A);
392 // row 0 (Strain)
394 MatrixDouble a01 = prod(partial2HSigmaFlux, D);
395 for (int ii = 0; ii < 6; ii++) {
396 for (int jj = 0; jj < 6; jj++) {
397 dataA(ii, jj) = deltaGamma * a00(ii, jj);
398 }
399 for (unsigned int jj = 0; jj < nbInternalVariables; jj++) {
400 dataA(ii, 6 + jj) = deltaGamma * a01(ii, jj);
401 }
402 dataA(ii, ii) -= 1;
403 }
404 for (int ii = 0; ii < 6; ii++) {
406 }
407 // row 1 (Fluxes)
408 MatrixDouble a11 = prod(partial2HFlux, D);
409 MatrixDouble a10 =
411 for (unsigned int ii = 0; ii < nbInternalVariables; ii++) {
412 for (int jj = 0; jj < 6; jj++) {
413 dataA(6 + ii, jj) += deltaGamma * a10(ii, jj);
414 }
415 for (unsigned int jj = 0; jj < nbInternalVariables; jj++) {
416 dataA(6 + ii, 6 + jj) += deltaGamma * a11(ii, jj);
417 }
418 dataA(6 + ii, 6 + ii) -= 1;
419 }
420 for (unsigned int ii = 0; ii < nbInternalVariables; ii++) {
421 dataA(6 + ii, 6 + nbInternalVariables) = partialHFlux[ii];
422 }
423 // row 3 (Plastic multiplier)
424 VectorDouble partial_y_sigma_c =
426 VectorDouble partial_y_flux_d = prod(trans(D), partialYFlux);
427 for (unsigned int dd = 0; dd < partial_y_sigma_c.size(); dd++) {
428 dataA(6 + nbInternalVariables, dd) = partial_y_sigma_c[dd];
429 }
430 for (unsigned int dd = 0; dd < partial_y_flux_d.size(); dd++) {
431 dataA(6 + nbInternalVariables, 6 + dd) = partial_y_flux_d[dd];
432 }
434 CHKERR MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY);
435 CHKERR MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY);
437}
#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
mofem/users_modules/adolc-plasticity/src/ADOLCPlasticity.hpp.

Definition at line 366 of file ClosestPointProjection.cpp.

366 {
368
369 auto plastic_strain = getPlasticStrain();
370 auto internal_variables = getInternalVariables();
371
372 // Residual
373 double *array;
374 CHKERR VecGetArray(R, &array);
375 for (int ii = 0; ii < 6; ii++) {
376 array[ii] = -plastic_strain[ii] + plasticStrain0[ii] +
378 }
379 for (unsigned int ii = 0; ii < nbInternalVariables; ii++) {
380 array[6 + ii] = -internal_variables[ii] + internalVariables0[ii] +
382 }
383 array[6 + nbInternalVariables] = y;
384 CHKERR VecRestoreArray(R, &array);
386}

◆ codedHessianW()

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

◆ consistentTangent()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::consistentTangent ( )

Calculate consistent tangent matrix.

Examples
mofem/users_modules/adolc-plasticity/src/ADOLCPlasticity.hpp.

Definition at line 513 of file ClosestPointProjection.cpp.

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

◆ createMatAVecR()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::createMatAVecR ( )
Examples
mofem/users_modules/adolc-plasticity/src/ADOLCPlasticity.hpp.

Definition at line 322 of file ClosestPointProjection.cpp.

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

◆ evaluatePotentials()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::evaluatePotentials ( )
Examples
mofem/users_modules/adolc-plasticity/src/ADOLCPlasticity.hpp.

Definition at line 342 of file ClosestPointProjection.cpp.

342 {
344 CHKERR recordW();
345 CHKERR recordY();
346 CHKERR recordH();
348}
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
mofem/users_modules/adolc-plasticity/src/ADOLCPlasticity.hpp.

Definition at line 165 of file ADOLCPlasticity.hpp.

165 {
167 }
auto getVectorAdaptor(T1 ptr, const size_t n)
Get Vector adaptor.
Definition Templates.hpp:49

◆ getInternalFluxes()

VectorAdaptor ADOLCPlasticity::ClosestPointProjection::getInternalFluxes ( )
inline

◆ getInternalVariables()

VectorAdaptor ADOLCPlasticity::ClosestPointProjection::getInternalVariables ( )
inline

◆ getPlasticStrain()

VectorAdaptor ADOLCPlasticity::ClosestPointProjection::getPlasticStrain ( )
inline
Examples
mofem/users_modules/adolc-plasticity/src/ADOLCPlasticity.hpp.

Definition at line 156 of file ADOLCPlasticity.hpp.

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

◆ getStress()

VectorAdaptor ADOLCPlasticity::ClosestPointProjection::getStress ( )
inline
Examples
mofem/users_modules/adolc-plasticity/src/ADOLCPlasticity.hpp.

Definition at line 168 of file ADOLCPlasticity.hpp.

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

◆ getTotalStrain()

VectorAdaptor ADOLCPlasticity::ClosestPointProjection::getTotalStrain ( )
inline
Examples
mofem/users_modules/adolc-plasticity/src/ADOLCPlasticity.hpp.

Definition at line 159 of file ADOLCPlasticity.hpp.

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

◆ playH()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::playH ( )
Examples
mofem/users_modules/adolc-plasticity/src/ADOLCPlasticity.hpp.

Definition at line 238 of file ClosestPointProjection.cpp.

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

◆ playH_NoHessian()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::playH_NoHessian ( )
Examples
mofem/users_modules/adolc-plasticity/src/ADOLCPlasticity.hpp.

Definition at line 295 of file ClosestPointProjection.cpp.

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

◆ playPotentials()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::playPotentials ( )

◆ playPotentials_NoHessian()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::playPotentials_NoHessian ( )

◆ playW()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::playW ( )
Examples
mofem/users_modules/adolc-plasticity/src/ADOLCPlasticity.hpp.

Definition at line 124 of file ClosestPointProjection.cpp.

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

◆ playW_NoHessian()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::playW_NoHessian ( )
Examples
mofem/users_modules/adolc-plasticity/src/ADOLCPlasticity.hpp.

Definition at line 181 of file ClosestPointProjection.cpp.

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

◆ playY()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::playY ( )
Examples
mofem/users_modules/adolc-plasticity/src/ADOLCPlasticity.hpp.

Definition at line 200 of file ClosestPointProjection.cpp.

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

◆ playY_NoGradient()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::playY_NoGradient ( )
Examples
mofem/users_modules/adolc-plasticity/src/ADOLCPlasticity.hpp.

Definition at line 225 of file ClosestPointProjection.cpp.

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

◆ recordH()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::recordH ( )

Record flow potential.

Examples
mofem/users_modules/adolc-plasticity/src/ADOLCPlasticity.hpp.

Definition at line 98 of file ClosestPointProjection.cpp.

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

◆ recordTapes()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::recordTapes ( )

Record tapes.

Examples
mofem/users_modules/adolc-plasticity/src/ADOLCPlasticity.hpp.

Definition at line 613 of file ClosestPointProjection.cpp.

613 {
617 auto tmp_active = getVectorAdaptor(&(active[0]), 12 + nbInternalVariables);
618 auto tmp_gradient =
620 activeVariablesW.swap(tmp_active);
621 gradientW.swap(tmp_gradient);
624}
bool active

◆ recordW()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::recordW ( )

Record strain energy.

Examples
mofem/users_modules/adolc-plasticity/src/ADOLCPlasticity.hpp.

Definition at line 42 of file ClosestPointProjection.cpp.

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

◆ recordY()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::recordY ( )

Record yield function.

Examples
mofem/users_modules/adolc-plasticity/src/ADOLCPlasticity.hpp.

Definition at line 72 of file ClosestPointProjection.cpp.

72 {
74
75 auto stress = getStress();
76 auto internal_fluxes = getInternalFluxes();
77
79 {
80 // active variables
81 a_sTress.resize(6, false);
82 for (int ii = 0; ii < 6; ii++) {
83 a_sTress[ii] <<= stress[ii];
84 }
86 for (unsigned int ii = 0; ii < nbInternalVariables; ii++) {
87 a_internalFluxes[ii] <<= internal_fluxes[ii];
88 }
89 // evaluete functions
91 // return variables
92 a_y >>= y;
93 }
94 trace_off();
96}
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
mofem/users_modules/adolc-plasticity/src/ADOLCPlasticity.hpp.

Definition at line 283 of file ADOLCPlasticity.hpp.

284 {
285 return 0;
286 }

◆ snesCreate()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::snesCreate ( )

Create nested snes.

Examples
mofem/users_modules/adolc-plasticity/src/ADOLCPlasticity.hpp.

Definition at line 439 of file ClosestPointProjection.cpp.

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

◆ solveClosestProjection()

MoFEMErrorCode ADOLCPlasticity::ClosestPointProjection::solveClosestProjection ( )

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

Examples
mofem/users_modules/adolc-plasticity/src/ADOLCPlasticity.hpp.

Definition at line 464 of file ClosestPointProjection.cpp.

464 {
466
467 auto plastic_strain = getPlasticStrain();
468 auto internal_variables = getInternalVariables();
469
470 {
471 double *array;
472 CHKERR VecGetArray(Chi, &array);
473 for (int ii = 0; ii < 6; ii++) {
474 array[ii] = plastic_strain[ii];
475 }
476 int nb_internal_variables = nbInternalVariables;
477 for (unsigned int ii = 0; ii < nb_internal_variables; ii++) {
478 array[6 + ii] = internal_variables[ii];
479 }
480 deltaGamma = 0;
481 CHKERR VecRestoreArray(Chi, &array);
482 }
483
484 CHKERR SNESSolve(sNes, PETSC_NULLPTR, Chi);
485 SNESConvergedReason reason;
486 CHKERR SNESGetConvergedReason(sNes, &reason);
487 if (reason < 0) {
488 int its;
489 CHKERR SNESGetIterationNumber(sNes, &its);
490 MOFEM_LOG_C("ADOLCPlasticitySelf", Sev::warning,
491 "Plasticity Closest Point Projection - number of Newton "
492 "iterations = %d",
493 its);
494 plastic_strain = plasticStrain0;
495 internal_variables = internalVariables0;
496 deltaGamma = 0;
497 } else {
498 double *array;
499 CHKERR VecGetArray(Chi, &array);
500 for (int ii = 0; ii < 6; ii++) {
501 plastic_strain[ii] = array[ii];
502 }
503 int nb_internal_variables = nbInternalVariables;
504 for (unsigned int ii = 0; ii < nb_internal_variables; ii++) {
505 internal_variables[ii] = array[6 + ii];
506 }
507 deltaGamma = array[6 + nb_internal_variables];
508 CHKERR VecRestoreArray(Chi, &array);
509 }
511}
#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
mofem/users_modules/adolc-plasticity/src/ADOLCPlasticity.hpp.

Definition at line 588 of file ClosestPointProjection.cpp.

588 {
591 cp = (ClosestPointProjection *)ctx;
592
593 auto plastic_strain = cp->getPlasticStrain();
594 auto internal_variables = cp->getInternalVariables();
595
596 {
597 const double *array;
598 CHKERR VecGetArrayRead(chi, &array);
599 for (auto ii = 0; ii < 6; ii++) {
600 plastic_strain[ii] = array[ii];
601 }
602 for (auto ii = 0; ii < cp->nbInternalVariables; ii++) {
603 internal_variables[ii] = array[6 + ii];
604 }
605 cp->deltaGamma = array[6 + cp->nbInternalVariables];
606 CHKERR VecRestoreArrayRead(chi, &array);
607 }
608 CHKERR cp->playPotentials();
609 CHKERR cp->calculateA();
611}

◆ ADOLCPlasticityRes

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

Function executed by nested SENES at evaluationg residual.

Examples
mofem/users_modules/adolc-plasticity/src/ADOLCPlasticity.hpp.

Definition at line 562 of file ClosestPointProjection.cpp.

562 {
565 cp = (ClosestPointProjection *)ctx;
566
567 auto plastic_strain = cp->getPlasticStrain();
568 auto internal_variables = cp->getInternalVariables();
569
570 {
571 const double *array;
572 CHKERR VecGetArrayRead(chi, &array);
573 for (auto ii = 0; ii < 6; ii++) {
574 plastic_strain[ii] = array[ii];
575 }
576 for (auto ii = 0; ii < cp->nbInternalVariables; ii++) {
577 internal_variables[ii] = array[6 + ii];
578 }
579 cp->deltaGamma = array[6 + cp->nbInternalVariables];
580 CHKERR VecRestoreArrayRead(chi, &array);
581 }
582 CHKERR cp->playPotentials_NoHessian();
583 CHKERR cp->calculateR(r);
584
586}

Member Data Documentation

◆ A

SmartPetscObj<Mat> ADOLCPlasticity::ClosestPointProjection::A

◆ 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

◆ Cep

MatrixDouble ADOLCPlasticity::ClosestPointProjection::Cep

◆ Chi

SmartPetscObj<Vec> ADOLCPlasticity::ClosestPointProjection::Chi

◆ Cp

MatrixDouble ADOLCPlasticity::ClosestPointProjection::Cp

◆ D

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

◆ dataA

ublas::matrix<double, ublas::column_major> ADOLCPlasticity::ClosestPointProjection::dataA

◆ dChi

SmartPetscObj<Vec> ADOLCPlasticity::ClosestPointProjection::dChi

◆ deltaGamma

double ADOLCPlasticity::ClosestPointProjection::deltaGamma

◆ Ep

MatrixDouble ADOLCPlasticity::ClosestPointProjection::Ep

◆ gradientH

VectorDouble ADOLCPlasticity::ClosestPointProjection::gradientH

◆ gradientW

VectorAdaptor ADOLCPlasticity::ClosestPointProjection::gradientW

◆ gradientY

VectorDouble ADOLCPlasticity::ClosestPointProjection::gradientY

◆ h

double ADOLCPlasticity::ClosestPointProjection::h

◆ hessianH

MatrixDouble ADOLCPlasticity::ClosestPointProjection::hessianH

◆ hessianW

MatrixDouble ADOLCPlasticity::ClosestPointProjection::hessianW

◆ implHessianW

PetscBool ADOLCPlasticity::ClosestPointProjection::implHessianW

◆ integrationRule

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

Definition at line 149 of file ADOLCPlasticity.hpp.

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

◆ internalVariables0

VectorDouble ADOLCPlasticity::ClosestPointProjection::internalVariables0

◆ 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
mofem/users_modules/adolc-plasticity/src/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
mofem/users_modules/adolc-plasticity/src/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
mofem/users_modules/adolc-plasticity/src/ADOLCPlasticity.hpp.

Definition at line 327 of file ADOLCPlasticity.hpp.

◆ partialHFlux

VectorAdaptor ADOLCPlasticity::ClosestPointProjection::partialHFlux

◆ partialHSigma

VectorAdaptor ADOLCPlasticity::ClosestPointProjection::partialHSigma

◆ partialWStrainPlasticStrain

MatrixDouble ADOLCPlasticity::ClosestPointProjection::partialWStrainPlasticStrain

◆ partialYFlux

VectorAdaptor ADOLCPlasticity::ClosestPointProjection::partialYFlux

◆ partialYSigma

VectorAdaptor ADOLCPlasticity::ClosestPointProjection::partialYSigma

◆ plasticStrain0

VectorDouble ADOLCPlasticity::ClosestPointProjection::plasticStrain0

◆ R

SmartPetscObj<Vec> ADOLCPlasticity::ClosestPointProjection::R

◆ sNes

SmartPetscObj<SNES> ADOLCPlasticity::ClosestPointProjection::sNes

◆ tapesTags

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

◆ w

double ADOLCPlasticity::ClosestPointProjection::w

◆ y

double ADOLCPlasticity::ClosestPointProjection::y

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