v0.14.0
Public Member Functions | Public Attributes | Private Attributes | Friends | List of all members
ArcLengthMatShell Struct Reference

shell matrix for arc-length method More...

#include <users_modules/basic_finite_elements/src/ArcLengthTools.hpp>

Collaboration diagram for ArcLengthMatShell:
[legend]

Public Member Functions

 ArcLengthMatShell (Mat aij, boost::shared_ptr< ArcLengthCtx > arc_ptr, string problem_name)
 
virtual ~ArcLengthMatShell ()=default
 
DEPRECATED ArcLengthMatShell (Mat aij, ArcLengthCtx *arc_ptr_raw, string problem_name)
 
MoFEMErrorCode setLambda (Vec ksp_x, double *lambda, ScatterMode scattermode)
 

Public Attributes

SmartPetscObj< Mat > Aij
 
string problemName
 
ArcLengthCtxarcPtrRaw
 

Private Attributes

boost::shared_ptr< ArcLengthCtxarcPtr
 

Friends

MoFEMErrorCode ArcLengthMatMultShellOp (Mat A, Vec x, Vec f)
 

Detailed Description

shell matrix for arc-length method

Shell matrix which has structure:

\[ \left[ \begin{array}{cc} \mathbf{K} & -\mathbf{F}_\lambda \\ \textrm{d}\mathbf{b} & D \end{array} \right] \left\{ \begin{array}{c} \delta \Delta \mathbf{x} \\ \delta \Delta \lambda \end{array} \right\} = \left[ \begin{array}{c} -\mathbf{f}_\textrm{int} \\ -r_\lambda \end{array} \right] \]

Definition at line 205 of file ArcLengthTools.hpp.

Constructor & Destructor Documentation

◆ ArcLengthMatShell() [1/2]

ArcLengthMatShell::ArcLengthMatShell ( Mat  aij,
boost::shared_ptr< ArcLengthCtx arc_ptr,
string  problem_name 
)

Definition at line 137 of file ArcLengthTools.cpp.

140  : Aij(aij, true), problemName(problem_name), arcPtrRaw(arc_ptr.get()),
141  arcPtr(arc_ptr) {}

◆ ~ArcLengthMatShell()

virtual ArcLengthMatShell::~ArcLengthMatShell ( )
virtualdefault

◆ ArcLengthMatShell() [2/2]

ArcLengthMatShell::ArcLengthMatShell ( Mat  aij,
ArcLengthCtx arc_ptr_raw,
string  problem_name 
)
Deprecated:
use constructor with shared_ptr

Definition at line 133 of file ArcLengthTools.cpp.

135  : Aij(aij, true), problemName(problem_name), arcPtrRaw(arc_ptr_raw) {}

Member Function Documentation

◆ setLambda()

MoFEMErrorCode ArcLengthMatShell::setLambda ( Vec  ksp_x,
double lambda,
ScatterMode  scattermode 
)

Definition at line 143 of file ArcLengthTools.cpp.

144  {
146 
147  int part = arcPtrRaw->getPart();
148  int rank = arcPtrRaw->mField.get_comm_rank();
149 
150  switch (scattermode) {
151  case SCATTER_FORWARD: {
152  Vec lambda_ghost;
153  if (rank == part) {
154  CHKERR VecCreateGhostWithArray(arcPtrRaw->mField.get_comm(), 1, 1, 0,
155  PETSC_NULL, lambda, &lambda_ghost);
156  } else {
157  int one[] = {0};
158  CHKERR VecCreateGhostWithArray(arcPtrRaw->mField.get_comm(), 0, 1, 1, one,
159  lambda, &lambda_ghost);
160  }
161  int idx = arcPtrRaw->getPetscGlobalDofIdx();
162  if (part == rank) {
163  CHKERR VecGetValues(ksp_x, 1, &idx, lambda);
164  }
165  CHKERR VecGhostUpdateBegin(lambda_ghost, INSERT_VALUES, SCATTER_FORWARD);
166  CHKERR VecGhostUpdateEnd(lambda_ghost, INSERT_VALUES, SCATTER_FORWARD);
167  CHKERR VecDestroy(&lambda_ghost);
168  } break;
169  case SCATTER_REVERSE: {
170  if (arcPtrRaw->getPetscLocalDofIdx() != -1) {
171  PetscScalar *array;
172  CHKERR VecGetArray(ksp_x, &array);
173  array[arcPtrRaw->getPetscLocalDofIdx()] = *lambda;
174  CHKERR VecRestoreArray(ksp_x, &array);
175  }
176  } break;
177  default:
178  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
179  }
180 
182 }

Friends And Related Function Documentation

◆ ArcLengthMatMultShellOp

MoFEMErrorCode ArcLengthMatMultShellOp ( Mat  A,
Vec  x,
Vec  f 
)
friend

mult operator for Arc Length Shell Mat

Definition at line 184 of file ArcLengthTools.cpp.

184  {
186  void *void_ctx;
187  CHKERR MatShellGetContext(A, &void_ctx);
188  ArcLengthMatShell *ctx = static_cast<ArcLengthMatShell *>(void_ctx);
189  CHKERR MatMult(ctx->Aij, x, f);
190  double lambda;
191  CHKERR ctx->setLambda(x, &lambda, SCATTER_FORWARD);
192  double db_dot_x;
193  CHKERR VecDot(ctx->arcPtrRaw->db, x, &db_dot_x);
194  double f_lambda;
195  f_lambda = ctx->arcPtrRaw->dIag * lambda + db_dot_x;
196  CHKERR ctx->setLambda(f, &f_lambda, SCATTER_REVERSE);
197  CHKERR VecAXPY(f, lambda, ctx->arcPtrRaw->F_lambda);
199 }

Member Data Documentation

◆ Aij

SmartPetscObj<Mat> ArcLengthMatShell::Aij

Definition at line 207 of file ArcLengthTools.hpp.

◆ arcPtr

boost::shared_ptr<ArcLengthCtx> ArcLengthMatShell::arcPtr
private

Definition at line 223 of file ArcLengthTools.hpp.

◆ arcPtrRaw

ArcLengthCtx* ArcLengthMatShell::arcPtrRaw

Definition at line 209 of file ArcLengthTools.hpp.

◆ problemName

string ArcLengthMatShell::problemName

Definition at line 208 of file ArcLengthTools.hpp.


The documentation for this struct was generated from the following files:
ArcLengthCtx::mField
MoFEM::Interface & mField
Definition: ArcLengthTools.hpp:69
ArcLengthMatShell
shell matrix for arc-length method
Definition: ArcLengthTools.hpp:205
ArcLengthCtx::db
SmartPetscObj< Vec > db
db derivative of f(dx*dx), i.e. db = d[ f(dx*dx) ]/dx
Definition: ArcLengthTools.hpp:85
MoFEM::CoreInterface::get_comm
virtual MPI_Comm & get_comm() const =0
MoFEM::CoreInterface::get_comm_rank
virtual int get_comm_rank() const =0
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
ArcLengthCtx::getPetscGlobalDofIdx
DofIdx getPetscGlobalDofIdx()
Get global index of load factor.
Definition: ArcLengthTools.hpp:107
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:535
ArcLengthMatShell::setLambda
MoFEMErrorCode setLambda(Vec ksp_x, double *lambda, ScatterMode scattermode)
Definition: ArcLengthTools.cpp:143
ArcLengthMatShell::arcPtrRaw
ArcLengthCtx * arcPtrRaw
Definition: ArcLengthTools.hpp:209
ArcLengthMatShell::Aij
SmartPetscObj< Mat > Aij
Definition: ArcLengthTools.hpp:207
ArcLengthCtx::getPetscLocalDofIdx
DofIdx getPetscLocalDofIdx()
Get local index of load factor.
Definition: ArcLengthTools.hpp:113
ArcLengthCtx::dIag
double dIag
diagonal value
Definition: ArcLengthTools.hpp:78
ArcLengthCtx::getPart
int getPart()
Get proc owning lambda dof.
Definition: ArcLengthTools.hpp:121
HenckyOps::f
auto f
Definition: HenckyOps.hpp:15
lambda
static double lambda
Definition: incompressible_elasticity.cpp:199
EigenMatrix::Vec
const FTensor::Tensor2< T, Dim, Dim > Vec
Definition: MatrixFunction.hpp:66
ArcLengthMatShell::arcPtr
boost::shared_ptr< ArcLengthCtx > arcPtr
Definition: ArcLengthTools.hpp:223
ArcLengthMatShell::problemName
string problemName
Definition: ArcLengthTools.hpp:208
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
MOFEM_NOT_IMPLEMENTED
@ MOFEM_NOT_IMPLEMENTED
Definition: definitions.h:32
ArcLengthCtx::F_lambda
SmartPetscObj< Vec > F_lambda
F_lambda reference load vector.
Definition: ArcLengthTools.hpp:83
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346