18 auto core_log = logging::core::get();
21 "ADOLCPlasticityWold"));
23 "ADOLCPlasticitySync"));
25 "ADOLCPlasticitySelf"));
54 for (
int ii = 0; ii < 6; ii++) {
58 for (
int ii = 0; ii < 6; ii++) {
83 for (
int ii = 0; ii < 6; ii++) {
109 for (
int ii = 0; ii < 6; ii++) {
128 int adloc_return_value = 0;
131 if (r < adloc_return_value) {
133 "ADOL-C function evaluation with error");
137 if (r < adloc_return_value) {
139 "ADOL-C function evaluation with error");
152 if (r < adloc_return_value) {
154 "ADOL-C function evaluation with error");
162 for (
int ii = 0; ii < 6; ii++) {
163 for (
int jj = 0; jj < 6; jj++) {
167 C.resize(6, 6,
false);
168 for (
int ii = 0; ii < 6; ii++) {
169 for (
int jj = 0; jj <= ii; jj++) {
175 for (
unsigned int jj = 0; jj <= ii; jj++) {
186 int adloc_return_value = 0;
189 if (r < adloc_return_value) {
191 "ADOL-C function evaluation with error");
195 if (r < adloc_return_value) {
197 "ADOL-C function evaluation with error");
206 int adloc_return_value = 0;
208 active_variables_yh.size(), &active_variables_yh[0], &
y);
209 if (r < adloc_return_value) {
211 "ADOL-C function evaluation with error");
213 gradientY.resize(active_variables_yh.size());
216 if (r < adloc_return_value) {
218 "ADOL-C function evaluation with error");
232 int adloc_return_value = 0;
234 active_variables_yh.size(), &active_variables_yh[0], &
y);
235 if (r < adloc_return_value) {
237 "ADOL-C function evaluation with error");
245 int adloc_return_value = 0;
247 active_variables_yh.size(), &active_variables_yh[0], &
h);
248 if (r < adloc_return_value) {
250 "ADOL-C function evaluation with error");
252 gradientH.resize(active_variables_yh.size());
255 if (r < adloc_return_value) {
257 "ADOL-C function evaluation with error");
261 vector<double *> hessian_h(active_variables_yh.size());
262 for (
int dd = 0; dd < active_variables_yh.size(); dd++) {
266 &active_variables_yh[0], &hessian_h[0]);
267 if (r < adloc_return_value) {
269 "ADOL-C function evaluation with error");
278 for (
int ii = 0; ii < 6; ii++) {
279 for (
int jj = 0; jj <= ii; jj++) {
285 for (
unsigned int jj = 0; jj <= ii; jj++) {
291 for (
int ii = 0; ii < 6; ii++) {
302 int adloc_return_value = 0;
304 active_variables_yh.size(), &active_variables_yh[0], &
h);
305 if (r < adloc_return_value) {
307 "ADOL-C function evaluation with error");
309 gradientH.resize(active_variables_yh.size());
312 if (r < adloc_return_value) {
314 "ADOL-C function evaluation with error");
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);
380 for (
int ii = 0; ii < 6; ii++) {
389 CHKERR VecRestoreArray(
R, &array);
400 for (
int ii = 0; ii < 6; ii++) {
401 for (
int jj = 0; jj < 6; jj++) {
409 for (
int ii = 0; ii < 6; ii++) {
417 for (
int jj = 0; jj < 6; jj++) {
423 dataA(6 + ii, 6 + ii) -= 1;
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++) {
435 for (
unsigned int dd = 0; dd < partial_y_flux_d.size(); dd++) {
439 CHKERR MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY);
440 CHKERR MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY);
452 SNESLineSearch line_search;
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);
460 CHKERR SNESLineSearchSetType(line_search, SNESLINESEARCHBT);
479 for (
int ii = 0; ii < 6; ii++) {
480 array[ii] = plastic_strain[ii];
483 for (
unsigned int ii = 0; ii < nb_internal_variables; ii++) {
484 array[6 + ii] = internal_variables[ii];
491 SNESConvergedReason reason;
497 "ADOLCPlasticitySelf", Sev::warning,
498 "Plasticity Closest Point Projection - number of Newton iterations = %d",
506 for (
int ii = 0; ii < 6; ii++) {
507 plastic_strain[ii] = array[ii];
510 for (
unsigned int ii = 0; ii < nb_internal_variables; ii++) {
511 internal_variables[ii] = array[6 + ii];
513 deltaGamma = array[6 + nb_internal_variables];
524 Ep.resize(6, 6,
false);
528 MatrixDouble alpha_row;
534 for (
int dd = 0; dd < 6; dd++) {
539 for (
auto ii = 0; ii < 6; ii++) {
540 array[ii] = ep_row(ii, dd);
543 array[6 + ii] = alpha_row(ii, dd);
545 array[
n] = y_row[dd];
547 CHKERR VecRestoreArray(
R, &array);
556 for (
auto ii = 0; ii < 6; ii++) {
557 Ep(ii, dd) = array[ii];
562 Cp.resize(6, 6,
false);
563 noalias(
Cp) = prod(
C,
Ep);
564 Cep.resize(6, 6,
false);
579 CHKERR VecGetArrayRead(chi, &array);
580 for (
auto ii = 0; ii < 6; ii++) {
581 plastic_strain[ii] = array[ii];
584 internal_variables[ii] = array[6 + ii];
587 CHKERR VecRestoreArrayRead(chi, &array);
606 CHKERR VecGetArrayRead(chi, &array);
607 for (
auto ii = 0; ii < 6; ii++) {
608 plastic_strain[ii] = array[ii];
611 internal_variables[ii] = array[6 + ii];
614 CHKERR VecRestoreArrayRead(chi, &array);
#define MOFEM_LOG_C(channel, severity, format,...)
#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.
const double n
refractive index of diffusive medium
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.
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()
friend MoFEMErrorCode ADOLCPlasticityRes(SNES, Vec, Vec, void *ctx)
Function executed by nested SENES at evaluationg residual.
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()
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
friend MoFEMErrorCode ADOLCPlasticityJac(SNES, Vec, Mat, Mat, void *ctx)
Function executed by nested SENES at evaluationg tangent matrix.
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