v0.13.2
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Private Attributes | List of all members
ArcLengthCtx Struct Reference

Store variables for ArcLength analysis. More...

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

Collaboration diagram for ArcLengthCtx:
[legend]

Public Member Functions

virtual ~ArcLengthCtx ()=default
 
MoFEMErrorCode setS (double s)
 set arc radius More...
 
MoFEMErrorCode setAlphaBeta (double alpha, double beta)
 set parameters controlling arc-length equations alpha controls off diagonal therms beta controls diagonal therm More...
 
 ArcLengthCtx (MoFEM::Interface &m_field, const std::string &problem_name, const std::string &field_name="LAMBDA")
 
DofIdx getPetscGlobalDofIdx ()
 Get global index of load factor. More...
 
DofIdx getPetscLocalDofIdx ()
 Get local index of load factor. More...
 
FieldData & getFieldData ()
 Get value of load factor. More...
 
int getPart ()
 Get proc owning lambda dof. More...
 

Public Attributes

MoFEM::InterfacemField
 
double s
 arc length radius More...
 
double beta
 force scaling factor More...
 
double alpha
 displacement scaling factor More...
 
SmartPetscObj< Vec > ghosTdLambda
 
double dLambda
 increment of load factor More...
 
SmartPetscObj< Vec > ghostDiag
 
double dIag
 diagonal value More...
 
double dx2
 inner_prod(dX,dX) More...
 
double F_lambda2
 inner_prod(F_lambda,F_lambda); More...
 
double res_lambda
 f_lambda - s More...
 
SmartPetscObj< Vec > F_lambda
 F_lambda reference load vector. More...
 
SmartPetscObj< Vec > db
 db derivative of f(dx*dx), i.e. db = d[ f(dx*dx) ]/dx More...
 
SmartPetscObj< Vec > xLambda
 solution of eq. K*xLambda = F_lambda More...
 
SmartPetscObj< Vec > x0
 displacement vector at beginning of step More...
 
SmartPetscObj< Vec > dx
 dx = x-x0 More...
 

Private Attributes

NumeredDofEntity * arcDofRawPtr
 

Detailed Description

Store variables for ArcLength analysis.

The constrain function if given by

\[ r_\lambda = f_\lambda(\mathbf{x},\lambda) - s^2 \]

where \(f_\lambda(\mathbf{x},\lambda)\) is some constrain function, which has general form given by

\[ f_\lambda(\mathbf{x},\lambda) = \alpha f(\Delta\mathbf{x}) + \beta^2 \Delta\lambda^2 \| \mathbf{F}_{\lambda} \|^2 \]

where for example \(f(\mathbf{x})=\|\Delta\mathbf{x}\|^2\) is some user defined function evaluating increments vector of degrees of freedom \(\Delta\mathbf{x}\). The increment vector is

\[ \Delta \mathbf{x} = \mathbf{x}-\mathbf{x}_0 \]

and

\[ \Delta \lambda = \lambda-\lambda_0. \]

For convenience we assume that

\[ \frac{\partial f}{\partial \mathbf{x}}\Delta \mathbf{x} = \textrm{d}\mathbf{b} \Delta \mathbf{x}, \]

as result linearised constrain equation takes form

\[ \textrm{d}\mathbf{b} \delta \Delta x + D \delta \Delta\lambda - r_{\lambda} = 0 \]

where

\[ D = 2\beta^2 \Delta\lambda \| \mathbf{F}_{\lambda} \|^2. \]

User need to implement functions calculating \(f(\mathbf{x},\lambda)\), i.e. function \(f(\|\Delta\mathbf{x}\|^2)\) and its derivative, \(\textrm{d}\mathbf{b}\).

Definition at line 65 of file ArcLengthTools.hpp.

Constructor & Destructor Documentation

◆ ~ArcLengthCtx()

virtual ArcLengthCtx::~ArcLengthCtx ( )
virtualdefault

◆ ArcLengthCtx()

ArcLengthCtx::ArcLengthCtx ( MoFEM::Interface m_field,
const std::string &  problem_name,
const std::string &  field_name = "LAMBDA" 
)

Definition at line 38 of file ArcLengthTools.cpp.

41 : mField(m_field), dx2(0), F_lambda2(0), res_lambda(0) {
42
43 auto create_f_lambda = [&]() {
45 CHKERR m_field.getInterface<VecManager>()->vecCreateGhost(problem_name, ROW,
46 F_lambda);
47 CHKERR VecSetOption(F_lambda, VEC_IGNORE_NEGATIVE_INDICES, PETSC_TRUE);
49 };
50
51 auto vec_duplicate = [&]() {
58 };
59
60 auto zero_vectors = [&]() {
62 CHKERR VecZeroEntries(F_lambda);
63 CHKERR VecZeroEntries(db);
64 CHKERR VecZeroEntries(xLambda);
65 CHKERR VecZeroEntries(x0);
66 CHKERR VecZeroEntries(dx);
68 };
69
70 auto find_lambda_dof = [&]() {
72
73 const Problem *problem_ptr;
74 CHKERR m_field.get_problem(problem_name, &problem_ptr);
75 boost::shared_ptr<NumeredDofEntity_multiIndex> dofs_ptr_no_const =
76 problem_ptr->getNumeredRowDofsPtr();
77 auto bit_number = m_field.get_field_bit_number(field_name);
78 auto dIt = dofs_ptr_no_const->get<Unique_mi_tag>().lower_bound(
80 auto hi_dit = dofs_ptr_no_const->get<Unique_mi_tag>().upper_bound(
82 if (std::distance(dIt, hi_dit) != 1)
83 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
84 ("can not find unique LAMBDA (load factor) but found " +
85 boost::lexical_cast<std::string>(std::distance(dIt, hi_dit)))
86 .c_str());
87 arcDofRawPtr = (*dIt).get();
89 };
90
91 auto create_ghost_vecs = [&]() {
93 Vec ghost_d_lambda, ghost_diag;
94 if ((unsigned int)mField.get_comm_rank() == arcDofRawPtr->getPart()) {
95 CHKERR VecCreateGhostWithArray(mField.get_comm(), 1, 1, 0, PETSC_NULL,
96 &dLambda, &ghost_d_lambda);
97
98 CHKERR VecCreateGhostWithArray(mField.get_comm(), 1, 1, 0, PETSC_NULL,
99 &dIag, &ghost_diag);
100 } else {
101 int one[] = {0};
102 CHKERR VecCreateGhostWithArray(mField.get_comm(), 0, 1, 1, one, &dLambda,
103 &ghost_d_lambda);
104 CHKERR VecCreateGhostWithArray(mField.get_comm(), 0, 1, 1, one, &dIag,
105 &ghost_diag);
106 }
107 dLambda = 0;
108 dIag = 0;
109 ghosTdLambda = SmartPetscObj<Vec>(ghost_d_lambda);
110 ghostDiag = SmartPetscObj<Vec>(ghost_diag);
112 };
113
114 ierr = create_f_lambda();
115 CHKERRABORT(PETSC_COMM_SELF, ierr);
116
117 ierr = vec_duplicate();
118 CHKERRABORT(PETSC_COMM_SELF, ierr);
119
120 ierr = zero_vectors();
121 CHKERRABORT(PETSC_COMM_SELF, ierr);
122
123 ierr = find_lambda_dof();
124 CHKERRABORT(PETSC_COMM_SELF, ierr);
125
126 ierr = create_ghost_vecs();
127 CHKERRABORT(PETSC_COMM_SELF, ierr);
128}
#define ArcFunctionBegin
@ ROW
Definition: definitions.h:123
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
#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
virtual const Problem * get_problem(const std::string problem_name) const =0
Get the problem object.
const FTensor::Tensor2< T, Dim, Dim > Vec
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76
SmartPetscObj< Vec > smartVectorDuplicate(SmartPetscObj< Vec > &vec)
Create duplicate vector of smart vector.
constexpr auto field_name
SmartPetscObj< Vec > db
db derivative of f(dx*dx), i.e. db = d[ f(dx*dx) ]/dx
double res_lambda
f_lambda - s
SmartPetscObj< Vec > dx
dx = x-x0
SmartPetscObj< Vec > F_lambda
F_lambda reference load vector.
MoFEM::Interface & mField
double F_lambda2
inner_prod(F_lambda,F_lambda);
double dIag
diagonal value
double dx2
inner_prod(dX,dX)
SmartPetscObj< Vec > ghostDiag
SmartPetscObj< Vec > x0
displacement vector at beginning of step
double dLambda
increment of load factor
SmartPetscObj< Vec > ghosTdLambda
NumeredDofEntity * arcDofRawPtr
SmartPetscObj< Vec > xLambda
solution of eq. K*xLambda = F_lambda
virtual FieldBitNumber get_field_bit_number(const std::string name) const =0
get field bit number
virtual MPI_Comm & get_comm() const =0
virtual int get_comm_rank() const =0
static UId getHiBitNumberUId(const FieldBitNumber bit_number)
static UId getLoBitNumberUId(const FieldBitNumber bit_number)
unsigned int getPart() const
keeps basic data about problem
auto & getNumeredRowDofsPtr() const
get access to numeredRowDofsPtr storing DOFs on rows
intrusive_ptr for managing petsc objects
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.
Vector manager is used to create vectors \mofem_vectors.
Definition: VecManager.hpp:23

Member Function Documentation

◆ getFieldData()

FieldData & ArcLengthCtx::getFieldData ( )
inline

Get value of load factor.

Definition at line 117 of file ArcLengthTools.hpp.

117{ return arcDofRawPtr->getFieldData(); }

◆ getPart()

int ArcLengthCtx::getPart ( )
inline

Get proc owning lambda dof.

Definition at line 121 of file ArcLengthTools.hpp.

121{ return arcDofRawPtr->getPart(); };

◆ getPetscGlobalDofIdx()

DofIdx ArcLengthCtx::getPetscGlobalDofIdx ( )
inline

Get global index of load factor.

Definition at line 107 of file ArcLengthTools.hpp.

107 {
108 return arcDofRawPtr->getPetscGlobalDofIdx();
109 };

◆ getPetscLocalDofIdx()

DofIdx ArcLengthCtx::getPetscLocalDofIdx ( )
inline

Get local index of load factor.

Definition at line 113 of file ArcLengthTools.hpp.

113{ return arcDofRawPtr->getPetscLocalDofIdx(); };

◆ setAlphaBeta()

MoFEMErrorCode ArcLengthCtx::setAlphaBeta ( double  alpha,
double  beta 
)

set parameters controlling arc-length equations alpha controls off diagonal therms beta controls diagonal therm

Definition at line 29 of file ArcLengthTools.cpp.

29 {
31 this->alpha = alpha;
32 this->beta = beta;
33 MOFEM_LOG_C("WORLD", Sev::inform, "\tSet alpha = %6.4e beta = %6.4e",
34 this->alpha, this->beta);
36}
#define MOFEM_LOG_C(channel, severity, format,...)
Definition: LogManager.hpp:304
double alpha
displacement scaling factor
double beta
force scaling factor

◆ setS()

MoFEMErrorCode ArcLengthCtx::setS ( double  s)

set arc radius

Definition at line 22 of file ArcLengthTools.cpp.

22 {
24 this->s = s;
25 MOFEM_LOG_C("WORLD", Sev::inform, "\tSet s = %6.4e", this->s);
27}
double s
arc length radius

Member Data Documentation

◆ alpha

double ArcLengthCtx::alpha

displacement scaling factor

Definition at line 73 of file ArcLengthTools.hpp.

◆ arcDofRawPtr

NumeredDofEntity* ArcLengthCtx::arcDofRawPtr
private

Definition at line 124 of file ArcLengthTools.hpp.

◆ beta

double ArcLengthCtx::beta

force scaling factor

Definition at line 72 of file ArcLengthTools.hpp.

◆ db

SmartPetscObj<Vec> ArcLengthCtx::db

db derivative of f(dx*dx), i.e. db = d[ f(dx*dx) ]/dx

Definition at line 85 of file ArcLengthTools.hpp.

◆ dIag

double ArcLengthCtx::dIag

diagonal value

Definition at line 78 of file ArcLengthTools.hpp.

◆ dLambda

double ArcLengthCtx::dLambda

increment of load factor

Definition at line 76 of file ArcLengthTools.hpp.

◆ dx

SmartPetscObj<Vec> ArcLengthCtx::dx

dx = x-x0

Definition at line 88 of file ArcLengthTools.hpp.

◆ dx2

double ArcLengthCtx::dx2

inner_prod(dX,dX)

Definition at line 80 of file ArcLengthTools.hpp.

◆ F_lambda

SmartPetscObj<Vec> ArcLengthCtx::F_lambda

F_lambda reference load vector.

Definition at line 83 of file ArcLengthTools.hpp.

◆ F_lambda2

double ArcLengthCtx::F_lambda2

inner_prod(F_lambda,F_lambda);

Definition at line 81 of file ArcLengthTools.hpp.

◆ ghostDiag

SmartPetscObj<Vec> ArcLengthCtx::ghostDiag

Definition at line 77 of file ArcLengthTools.hpp.

◆ ghosTdLambda

SmartPetscObj<Vec> ArcLengthCtx::ghosTdLambda

Definition at line 75 of file ArcLengthTools.hpp.

◆ mField

MoFEM::Interface& ArcLengthCtx::mField

Definition at line 69 of file ArcLengthTools.hpp.

◆ res_lambda

double ArcLengthCtx::res_lambda

f_lambda - s

Definition at line 82 of file ArcLengthTools.hpp.

◆ s

double ArcLengthCtx::s

arc length radius

Definition at line 71 of file ArcLengthTools.hpp.

◆ x0

SmartPetscObj<Vec> ArcLengthCtx::x0

displacement vector at beginning of step

Definition at line 87 of file ArcLengthTools.hpp.

◆ xLambda

SmartPetscObj<Vec> ArcLengthCtx::xLambda

solution of eq. K*xLambda = F_lambda

Definition at line 86 of file ArcLengthTools.hpp.


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