18 auto core_log = logging::core::get();
21 "ADOLCPlasticityWold"));
23 "ADOLCPlasticitySync"));
25 "ADOLCPlasticitySelf"));
53 for (
int ii = 0; ii < 6; ii++) {
57 for (
int ii = 0; ii < 6; ii++) {
82 for (
int ii = 0; ii < 6; ii++) {
108 for (
int ii = 0; ii < 6; ii++) {
127 int adloc_return_value = 0;
130 if (r < adloc_return_value) {
132 "ADOL-C function evaluation with error");
136 if (r < adloc_return_value) {
138 "ADOL-C function evaluation with error");
151 if (r < adloc_return_value) {
153 "ADOL-C function evaluation with error");
161 for (
int ii = 0; ii < 6; ii++) {
162 for (
int jj = 0; jj < 6; jj++) {
166 C.resize(6, 6,
false);
167 for (
int ii = 0; ii < 6; ii++) {
168 for (
int jj = 0; jj <= ii; jj++) {
174 for (
unsigned int jj = 0; jj <= ii; jj++) {
184 int adloc_return_value = 0;
187 if (r < adloc_return_value) {
189 "ADOL-C function evaluation with error");
193 if (r < adloc_return_value) {
195 "ADOL-C function evaluation with error");
204 int adloc_return_value = 0;
206 active_variables_yh.size(), &active_variables_yh[0], &
y);
207 if (r < adloc_return_value) {
209 "ADOL-C function evaluation with error");
211 gradientY.resize(active_variables_yh.size());
214 if (r < adloc_return_value) {
216 "ADOL-C function evaluation with error");
229 int adloc_return_value = 0;
231 active_variables_yh.size(), &active_variables_yh[0], &
y);
232 if (r < adloc_return_value) {
234 "ADOL-C function evaluation with error");
242 int adloc_return_value = 0;
244 active_variables_yh.size(), &active_variables_yh[0], &
h);
245 if (r < adloc_return_value) {
247 "ADOL-C function evaluation with error");
249 gradientH.resize(active_variables_yh.size());
252 if (r < adloc_return_value) {
254 "ADOL-C function evaluation with error");
258 vector<double *> hessian_h(active_variables_yh.size());
259 for (
int dd = 0; dd < active_variables_yh.size(); dd++) {
263 &active_variables_yh[0], &hessian_h[0]);
264 if (r < adloc_return_value) {
266 "ADOL-C function evaluation with error");
275 for (
int ii = 0; ii < 6; ii++) {
276 for (
int jj = 0; jj <= ii; jj++) {
282 for (
unsigned int jj = 0; jj <= ii; jj++) {
288 for (
int ii = 0; ii < 6; ii++) {
299 int adloc_return_value = 0;
301 active_variables_yh.size(), &active_variables_yh[0], &
h);
302 if (r < adloc_return_value) {
304 "ADOL-C function evaluation with error");
306 gradientH.resize(active_variables_yh.size());
309 if (r < adloc_return_value) {
311 "ADOL-C function evaluation with error");
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);
375 for (
int ii = 0; ii < 6; ii++) {
384 CHKERR VecRestoreArray(
R, &array);
395 for (
int ii = 0; ii < 6; ii++) {
396 for (
int jj = 0; jj < 6; jj++) {
404 for (
int ii = 0; ii < 6; ii++) {
412 for (
int jj = 0; jj < 6; jj++) {
418 dataA(6 + ii, 6 + ii) -= 1;
427 for (
unsigned int dd = 0; dd < partial_y_sigma_c.size(); dd++) {
430 for (
unsigned int dd = 0; dd < partial_y_flux_d.size(); dd++) {
434 CHKERR MatAssemblyBegin(
A, MAT_FINAL_ASSEMBLY);
435 CHKERR MatAssemblyEnd(
A, MAT_FINAL_ASSEMBLY);
447 SNESLineSearch line_search;
451 CHKERR PCSetType(pc, PCLU);
452 CHKERR SNESSetTolerances(
sNes, 1e-8, 1e-6, 1e-12, 20, 1000);
455 CHKERR SNESLineSearchSetType(line_search, SNESLINESEARCHBT);
473 for (
int ii = 0; ii < 6; ii++) {
474 array[ii] = plastic_strain[ii];
477 for (
unsigned int ii = 0; ii < nb_internal_variables; ii++) {
478 array[6 + ii] = internal_variables[ii];
485 SNESConvergedReason reason;
491 "Plasticity Closest Point Projection - number of Newton "
500 for (
int ii = 0; ii < 6; ii++) {
501 plastic_strain[ii] = array[ii];
504 for (
unsigned int ii = 0; ii < nb_internal_variables; ii++) {
505 internal_variables[ii] = array[6 + ii];
507 deltaGamma = array[6 + nb_internal_variables];
517 Ep.resize(6, 6,
false);
527 for (
int dd = 0; dd < 6; dd++) {
532 for (
auto ii = 0; ii < 6; ii++) {
533 array[ii] = ep_row(ii, dd);
536 array[6 + ii] = alpha_row(ii, dd);
538 array[
n] = y_row[dd];
540 CHKERR VecRestoreArray(
R, &array);
549 for (
auto ii = 0; ii < 6; ii++) {
550 Ep(ii, dd) = array[ii];
555 Cp.resize(6, 6,
false);
556 noalias(
Cp) = prod(
C,
Ep);
557 Cep.resize(6, 6,
false);
572 CHKERR VecGetArrayRead(chi, &array);
573 for (
auto ii = 0; ii < 6; ii++) {
574 plastic_strain[ii] = array[ii];
577 internal_variables[ii] = array[6 + ii];
580 CHKERR VecRestoreArrayRead(chi, &array);
598 CHKERR VecGetArrayRead(chi, &array);
599 for (
auto ii = 0; ii < 6; ii++) {
600 plastic_strain[ii] = array[ii];
603 internal_variables[ii] = array[6 + ii];
606 CHKERR VecRestoreArrayRead(chi, &array);
#define MOFEM_LOG_C(channel, severity, format,...)
SmartPetscObj< Vec > gradient
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_OPERATION_UNSUCCESSFUL
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#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.
MoFEMErrorCode ADOLCPlasticityJac(SNES, Vec, Mat, Mat, void *ctx)
Internal SNES function used at integration points to calulate tangent matrix.
MoFEMErrorCode ADOLCPlasticityRes(SNES snes, Vec chi, Vec r, void *ctx)
Internal SNES function used at integration points to calulate stress.
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
VectorShallowArrayAdaptor< double > VectorAdaptor
implementation of Data Operators for Forces and Sources
auto getVectorAdaptor(T1 ptr, const size_t n)
Get Vector adaptor.
auto createSNES(MPI_Comm comm)
PetscErrorCode PetscOptionsGetBool(PetscOptions *, const char pre[], const char name[], PetscBool *bval, PetscBool *set)
Closest point projection algorithm.
friend MoFEMErrorCode ADOLCPlasticityJac(SNES, Vec, Mat, Mat, void *ctx)
Function executed by nested SENES at evaluationg tangent matrix.
VectorAdaptor activeVariablesW
MatrixDouble partial2HSigmaFlux
VectorAdaptor getInternalFluxes()
MoFEMErrorCode playY_NoGradient()
ublas::vector< adouble > a_internalFluxes
MoFEMErrorCode recordTapes()
Record tapes.
ublas::vector< adouble > a_plasticStrain
std::array< int, LAST_TAPE > tapesTags
MoFEMErrorCode solveClosestProjection()
Solve nonlinear system of equations to find stress, internal fluxes, and Lagrange plastic multiplier.
VectorAdaptor partialYFlux
MatrixDouble partialWStrainPlasticStrain
MoFEMErrorCode recordH()
Record flow potential.
MoFEMErrorCode evaluatePotentials()
MoFEMErrorCode recordY()
Record yield function.
virtual MoFEMErrorCode flowPotential()=0
Set flow potential.
VectorAdaptor getActiveVariablesYH()
ublas::symmetric_matrix< double, ublas::lower > partial2HFlux
MoFEMErrorCode recordW()
Record strain energy.
VectorAdaptor partialHFlux
ublas::symmetric_matrix< double, ublas::lower > D
MoFEMErrorCode calculateA()
VectorDouble internalVariables0
VectorAdaptor partialHSigma
MoFEMErrorCode playH_NoHessian()
ublas::vector< adouble > a_internalVariables
VectorAdaptor getTotalStrain()
friend MoFEMErrorCode ADOLCPlasticityRes(SNES, Vec, Vec, void *ctx)
Function executed by nested SENES at evaluationg residual.
ublas::symmetric_matrix< double, ublas::lower > C
virtual MoFEMErrorCode codedHessianW(vector< double * >)
VectorAdaptor partialYSigma
MoFEMErrorCode playPotentials_NoHessian()
SmartPetscObj< Vec > dChi
SmartPetscObj< SNES > sNes
virtual MoFEMErrorCode yieldFunction()=0
Set yield function.
VectorAdaptor getInternalVariables()
MoFEMErrorCode calculateR(Vec R)
MoFEMErrorCode createMatAVecR()
ublas::vector< adouble > a_sTress
MoFEMErrorCode consistentTangent()
Calculate consistent tangent matrix.
MoFEMErrorCode playW_NoHessian()
ublas::symmetric_matrix< double, ublas::lower > partial2HSigma
VectorAdaptor getPlasticStrain()
ublas::vector< adouble > a_sTrain
ublas::matrix< double, ublas::column_major > dataA
VectorDouble plasticStrain0
virtual MoFEMErrorCode freeHemholtzEnergy()=0
Set Hemholtz energy.
MoFEMErrorCode playPotentials()
VectorAdaptor getStress()
MoFEMErrorCode snesCreate()
Create nested snes.
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.
intrusive_ptr for managing petsc objects