v0.14.0
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(
79  FieldEntity::getLoBitNumberUId(bit_number));
80  auto hi_dit = dofs_ptr_no_const->get<Unique_mi_tag>().upper_bound(
81  FieldEntity::getHiBitNumberUId(bit_number));
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 }

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 }

◆ 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 }

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 121 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:
ArcLengthCtx::res_lambda
double res_lambda
f_lambda - s
Definition: ArcLengthTools.hpp:82
MoFEM::UnknownInterface::getInterface
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Definition: UnknownInterface.hpp:93
ArcLengthCtx::mField
MoFEM::Interface & mField
Definition: ArcLengthTools.hpp:69
ArcFunctionBegin
#define ArcFunctionBegin
Definition: ArcLengthTools.cpp:13
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
ArcLengthCtx::dLambda
double dLambda
increment of load factor
Definition: ArcLengthTools.hpp:76
MoFEM::CoreInterface::get_field_bit_number
virtual FieldBitNumber get_field_bit_number(const std::string name) const =0
get field bit number
MoFEM::CoreInterface::get_comm_rank
virtual int get_comm_rank() const =0
MoFEM::CoreInterface::get_problem
virtual const Problem * get_problem(const std::string problem_name) const =0
Get the problem object.
MoFEM::NumeredDofEntity::getPart
unsigned int getPart() const
Definition: DofsMultiIndices.hpp:250
ArcLengthCtx::beta
double beta
force scaling factor
Definition: ArcLengthTools.hpp:72
ArcLengthCtx::alpha
double alpha
displacement scaling factor
Definition: ArcLengthTools.hpp:73
ArcLengthCtx::dx2
double dx2
inner_prod(dX,dX)
Definition: ArcLengthTools.hpp:80
ROW
@ ROW
Definition: definitions.h:136
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
ArcLengthCtx::xLambda
SmartPetscObj< Vec > xLambda
solution of eq. K*xLambda = F_lambda
Definition: ArcLengthTools.hpp:86
MOFEM_LOG_C
#define MOFEM_LOG_C(channel, severity, format,...)
Definition: LogManager.hpp:311
MoFEM::Problem::getNumeredRowDofsPtr
auto & getNumeredRowDofsPtr() const
get access to numeredRowDofsPtr storing DOFs on rows
Definition: ProblemsMultiIndices.hpp:82
ArcLengthCtx::arcDofRawPtr
NumeredDofEntity * arcDofRawPtr
Definition: ArcLengthTools.hpp:121
ArcLengthCtx::x0
SmartPetscObj< Vec > x0
displacement vector at beginning of step
Definition: ArcLengthTools.hpp:87
ArcLengthCtx::F_lambda2
double F_lambda2
inner_prod(F_lambda,F_lambda);
Definition: ArcLengthTools.hpp:81
MoFEM::VecManager
Vector manager is used to create vectors \mofem_vectors.
Definition: VecManager.hpp:23
ArcLengthCtx::dx
SmartPetscObj< Vec > dx
dx = x-x0
Definition: ArcLengthTools.hpp:88
field_name
constexpr auto field_name
Definition: poisson_2d_homogeneous.cpp:13
ArcLengthCtx::dIag
double dIag
diagonal value
Definition: ArcLengthTools.hpp:78
ArcLengthCtx::ghostDiag
SmartPetscObj< Vec > ghostDiag
Definition: ArcLengthTools.hpp:77
MoFEM::vectorDuplicate
SmartPetscObj< Vec > vectorDuplicate(Vec vec)
Create duplicate vector of smart vector.
Definition: PetscSmartObj.hpp:221
MoFEM::Exceptions::ierr
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76
EigenMatrix::Vec
const FTensor::Tensor2< T, Dim, Dim > Vec
Definition: MatrixFunction.hpp:66
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
ArcLengthCtx::ghosTdLambda
SmartPetscObj< Vec > ghosTdLambda
Definition: ArcLengthTools.hpp:75
MoFEM::Unique_mi_tag
Definition: TagMultiIndices.hpp:18
MoFEM::Problem
keeps basic data about problem
Definition: ProblemsMultiIndices.hpp:54
MoFEM::SmartPetscObj< Vec >
ArcLengthCtx::s
double s
arc length radius
Definition: ArcLengthTools.hpp:71
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
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:359