v0.13.2
Loading...
Searching...
No Matches
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) {}
ArcLengthCtx * arcPtrRaw
boost::shared_ptr< ArcLengthCtx > arcPtr
SmartPetscObj< Mat > Aij

◆ ~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);
174 CHKERR VecRestoreArray(ksp_x, &array);
175 }
176 } break;
177 default:
178 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
179 }
180
182}
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
@ MOFEM_NOT_IMPLEMENTED
Definition: definitions.h:32
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
#define CHKERR
Inline error check.
Definition: definitions.h:535
constexpr double lambda
const FTensor::Tensor2< T, Dim, Dim > Vec
DofIdx getPetscLocalDofIdx()
Get local index of load factor.
MoFEM::Interface & mField
int getPart()
Get proc owning lambda dof.
DofIdx getPetscGlobalDofIdx()
Get global index of load factor.
virtual MPI_Comm & get_comm() const =0
virtual int get_comm_rank() const =0

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}
SmartPetscObj< Vec > db
db derivative of f(dx*dx), i.e. db = d[ f(dx*dx) ]/dx
SmartPetscObj< Vec > F_lambda
F_lambda reference load vector.
double dIag
diagonal value
shell matrix for arc-length method
MoFEMErrorCode setLambda(Vec ksp_x, double *lambda, ScatterMode scattermode)

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: