v0.16.0
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 "tutorials/cor-12_cohesive_interface/src/ArcLengthTools.hpp"

Collaboration diagram for ArcLengthCtx:
[legend]

Public Member Functions

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

Public Attributes

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

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}\).

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 63 of file ArcLengthTools.hpp.

Constructor & Destructor Documentation

◆ ~ArcLengthCtx() [1/2]

virtual ArcLengthCtx::~ArcLengthCtx ( )
virtualdefault

◆ ArcLengthCtx() [1/2]

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

Definition at line 37 of file ArcLengthTools.cpp.

40 : mField(m_field), dx2(0), F_lambda2(0), res_lambda(0) {
41
42 auto create_f_lambda = [&]() {
44 CHKERR m_field.getInterface<VecManager>()->vecCreateGhost(problem_name, ROW,
45 F_lambda);
46 CHKERR VecSetOption(F_lambda, VEC_IGNORE_NEGATIVE_INDICES, PETSC_TRUE);
48 };
49
50 auto vec_duplicate = [&]() {
57 };
58
59 auto zero_vectors = [&]() {
61 CHKERR VecZeroEntries(F_lambda);
62 CHKERR VecZeroEntries(db);
63 CHKERR VecZeroEntries(xLambda);
64 CHKERR VecZeroEntries(x0);
65 CHKERR VecZeroEntries(dx);
67 };
68
69 auto find_lambda_dof = [&]() {
71
72 const Problem *problem_ptr;
73 CHKERR m_field.get_problem(problem_name, &problem_ptr);
74 boost::shared_ptr<NumeredDofEntity_multiIndex> dofs_ptr_no_const =
75 problem_ptr->getNumeredRowDofsPtr();
76 auto bit_number = m_field.get_field_bit_number(field_name);
77 auto dIt = dofs_ptr_no_const->get<Unique_mi_tag>().lower_bound(
79 auto hi_dit = dofs_ptr_no_const->get<Unique_mi_tag>().upper_bound(
81 if (std::distance(dIt, hi_dit) != 1)
82 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "%s",
83 ("can not find unique LAMBDA (load factor) but found " +
84 boost::lexical_cast<std::string>(std::distance(dIt, hi_dit)))
85 .c_str());
86 arcDofRawPtr = (*dIt).get();
88 };
89
90 auto create_ghost_vecs = [&]() {
92 Vec ghost_d_lambda, ghost_diag;
93 if ((unsigned int)mField.get_comm_rank() == arcDofRawPtr->getPart()) {
94 CHKERR VecCreateGhostWithArray(mField.get_comm(), 1, 1, 0, PETSC_NULLPTR,
95 &dLambda, &ghost_d_lambda);
96
97 CHKERR VecCreateGhostWithArray(mField.get_comm(), 1, 1, 0, PETSC_NULLPTR,
98 &dIag, &ghost_diag);
99 } else {
100 int one[] = {0};
101 CHKERR VecCreateGhostWithArray(mField.get_comm(), 0, 1, 1, one, &dLambda,
102 &ghost_d_lambda);
103 CHKERR VecCreateGhostWithArray(mField.get_comm(), 0, 1, 1, one, &dIag,
104 &ghost_diag);
105 }
106 dLambda = 0;
107 dIag = 0;
108 ghosTdLambda = SmartPetscObj<Vec>(ghost_d_lambda);
109 ghostDiag = SmartPetscObj<Vec>(ghost_diag);
111 };
112
113 CHKERRABORT(PETSC_COMM_SELF, create_f_lambda());
114 CHKERRABORT(PETSC_COMM_SELF, vec_duplicate());
115 CHKERRABORT(PETSC_COMM_SELF, zero_vectors());
116 CHKERRABORT(PETSC_COMM_SELF, find_lambda_dof());
117 CHKERRABORT(PETSC_COMM_SELF, create_ghost_vecs());
118}
@ ROW
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
virtual const Problem * get_problem(const std::string problem_name) const =0
Get the problem object.
const FTensor::Tensor2< T, Dim, Dim > Vec
SmartPetscObj< Vec > vectorDuplicate(Vec vec)
Create duplicate vector of smart vector.
constexpr auto field_name
SmartPetscObj< Vec > xLambda
solution of eq. K*xLambda = F_lambda
double res_lambda
f_lambda - s
NumeredDofEntity * arcDofRawPtr
double F_lambda2
inner_prod(F_lambda,F_lambda);
SmartPetscObj< Vec > dx
dx = x-x0
double dIag
diagonal value
double dx2
inner_prod(dX,dX)
MoFEM::Interface & mField
SmartPetscObj< Vec > F_lambda
F_lambda reference load vector.
SmartPetscObj< Vec > ghostDiag
SmartPetscObj< Vec > ghosTdLambda
double dLambda
increment of load factor
SmartPetscObj< Vec > db
db derivative of f(dx*dx), i.e. db = d[ f(dx*dx) ]/dx
SmartPetscObj< Vec > x0
displacement vector at beginning of step
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 reference to pointer of interface.
Vector manager is used to create vectors \mofem_vectors.
#define ArcFunctionBegin

◆ ~ArcLengthCtx() [2/2]

virtual ArcLengthCtx::~ArcLengthCtx ( )
virtualdefault

◆ ArcLengthCtx() [2/2]

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

Member Function Documentation

◆ getFieldData() [1/2]

FieldData & ArcLengthCtx::getFieldData ( )
inline

Get value of load factor.

Definition at line 115 of file ArcLengthTools.hpp.

115{ return arcDofRawPtr->getFieldData(); }

◆ getFieldData() [2/2]

FieldData & ArcLengthCtx::getFieldData ( )
inline

Get value of load factor.

Definition at line 117 of file ArcLengthTools.hpp.

117{ return arcDofRawPtr->getFieldData(); }

◆ getPart() [1/2]

int ArcLengthCtx::getPart ( )
inline

Get proc owning lambda dof.

Definition at line 119 of file ArcLengthTools.hpp.

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

◆ getPart() [2/2]

int ArcLengthCtx::getPart ( )
inline

Get proc owning lambda dof.

Definition at line 121 of file ArcLengthTools.hpp.

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

◆ getPetscGlobalDofIdx() [1/2]

DofIdx ArcLengthCtx::getPetscGlobalDofIdx ( )
inline

Get global index of load factor.

Definition at line 105 of file ArcLengthTools.hpp.

105 {
106 return arcDofRawPtr->getPetscGlobalDofIdx();
107 };

◆ getPetscGlobalDofIdx() [2/2]

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() [1/2]

DofIdx ArcLengthCtx::getPetscLocalDofIdx ( )
inline

Get local index of load factor.

Definition at line 111 of file ArcLengthTools.hpp.

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

◆ getPetscLocalDofIdx() [2/2]

DofIdx ArcLengthCtx::getPetscLocalDofIdx ( )
inline

Get local index of load factor.

Definition at line 113 of file ArcLengthTools.hpp.

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

◆ setAlphaBeta() [1/2]

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 27 of file ArcLengthTools.cpp.

27 {
29 this->alpha = alpha;
30 this->beta = beta;
31 MOFEM_LOG_C("ARC_LENGTH", Sev::inform,
32 "\tSet alpha = %6.4e beta = %6.4e",
33 this->alpha, this->beta);
35}
#define MOFEM_LOG_C(channel, severity, format,...)
double alpha
displacement scaling factor
double beta
force scaling factor

◆ setAlphaBeta() [2/2]

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

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

◆ setS() [1/2]

MoFEMErrorCode ArcLengthCtx::setS ( double  s)

set arc radius

Definition at line 20 of file ArcLengthTools.cpp.

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

◆ setS() [2/2]

MoFEMErrorCode ArcLengthCtx::setS ( double  s)

set arc radius

Member Data Documentation

◆ alpha

double ArcLengthCtx::alpha

displacement scaling factor

Definition at line 71 of file ArcLengthTools.hpp.

◆ arcDofRawPtr

NumeredDofEntity * ArcLengthCtx::arcDofRawPtr
private

Definition at line 122 of file ArcLengthTools.hpp.

◆ beta

double ArcLengthCtx::beta

force scaling factor

Definition at line 70 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 83 of file ArcLengthTools.hpp.

◆ dIag

double ArcLengthCtx::dIag

diagonal value

Definition at line 76 of file ArcLengthTools.hpp.

◆ dLambda

double ArcLengthCtx::dLambda

increment of load factor

Definition at line 74 of file ArcLengthTools.hpp.

◆ dx

SmartPetscObj< Vec > ArcLengthCtx::dx

dx = x-x0

Definition at line 86 of file ArcLengthTools.hpp.

◆ dx2

double ArcLengthCtx::dx2

inner_prod(dX,dX)

Definition at line 78 of file ArcLengthTools.hpp.

◆ F_lambda

SmartPetscObj< Vec > ArcLengthCtx::F_lambda

F_lambda reference load vector.

Definition at line 81 of file ArcLengthTools.hpp.

◆ F_lambda2

double ArcLengthCtx::F_lambda2

inner_prod(F_lambda,F_lambda);

Definition at line 79 of file ArcLengthTools.hpp.

◆ ghostDiag

SmartPetscObj< Vec > ArcLengthCtx::ghostDiag

Definition at line 75 of file ArcLengthTools.hpp.

◆ ghosTdLambda

SmartPetscObj< Vec > ArcLengthCtx::ghosTdLambda

Definition at line 73 of file ArcLengthTools.hpp.

◆ mField

MoFEM::Interface & ArcLengthCtx::mField

Definition at line 67 of file ArcLengthTools.hpp.

◆ res_lambda

double ArcLengthCtx::res_lambda

f_lambda - s

Definition at line 80 of file ArcLengthTools.hpp.

◆ s

double ArcLengthCtx::s

arc length radius

Definition at line 69 of file ArcLengthTools.hpp.

◆ x0

SmartPetscObj< Vec > ArcLengthCtx::x0

displacement vector at beginning of step

Definition at line 85 of file ArcLengthTools.hpp.

◆ xLambda

SmartPetscObj< Vec > ArcLengthCtx::xLambda

solution of eq. K*xLambda = F_lambda

Definition at line 84 of file ArcLengthTools.hpp.


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