v0.14.0
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
OpElasticTools::OpCalculateLogStressTangent< TANGENT > Struct Template Reference

#include <users_modules/multifield_plasticity/src/ElasticOperators.hpp>

Inheritance diagram for OpElasticTools::OpCalculateLogStressTangent< TANGENT >:
[legend]
Collaboration diagram for OpElasticTools::OpCalculateLogStressTangent< TANGENT >:
[legend]

Public Member Functions

 OpCalculateLogStressTangent (const std::string field_name, boost::shared_ptr< CommonData > common_data_ptr, boost::shared_ptr< MatrixDouble > mat_D_ptr)
 
MoFEMErrorCode doWork (int side, EntityType type, EntData &data)
 Operator for linear form, usually to calculate values on right hand side. More...
 
- Public Member Functions inherited from MoFEM::VolumeElementForcesAndSourcesCore::UserDataOperator
int getNumNodes ()
 get element number of nodes More...
 
const EntityHandlegetConn ()
 get element connectivity More...
 
double getVolume () const
 element volume (linear geometry) More...
 
doublegetVolume ()
 element volume (linear geometry) More...
 
FTensor::Tensor2< double *, 3, 3 > & getJac ()
 get element Jacobian More...
 
FTensor::Tensor2< double *, 3, 3 > & getInvJac ()
 get element inverse Jacobian More...
 
VectorDoublegetCoords ()
 nodal coordinates More...
 
VolumeElementForcesAndSourcesCoregetVolumeFE () const
 return pointer to Generic Volume Finite Element object More...
 
- Public Member Functions inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
 UserDataOperator (const FieldSpace space, const char type=OPSPACE, const bool symm=true)
 
 UserDataOperator (const std::string field_name, const char type, const bool symm=true)
 
 UserDataOperator (const std::string row_field_name, const std::string col_field_name, const char type, const bool symm=true)
 
boost::shared_ptr< const NumeredEntFiniteElementgetNumeredEntFiniteElementPtr () const
 Return raw pointer to NumeredEntFiniteElement. More...
 
EntityHandle getFEEntityHandle () const
 Return finite element entity handle. More...
 
int getFEDim () const
 Get dimension of finite element. More...
 
EntityType getFEType () const
 Get dimension of finite element. More...
 
boost::weak_ptr< SideNumbergetSideNumberPtr (const int side_number, const EntityType type)
 Get the side number pointer. More...
 
EntityHandle getSideEntity (const int side_number, const EntityType type)
 Get the side entity. More...
 
int getNumberOfNodesOnElement () const
 Get the number of nodes on finite element. More...
 
MoFEMErrorCode getProblemRowIndices (const std::string filed_name, const EntityType type, const int side, VectorInt &indices) const
 Get row indices. More...
 
MoFEMErrorCode getProblemColIndices (const std::string filed_name, const EntityType type, const int side, VectorInt &indices) const
 Get col indices. More...
 
const FEMethodgetFEMethod () const
 Return raw pointer to Finite Element Method object. More...
 
int getOpType () const
 Get operator types. More...
 
void setOpType (const OpType type)
 Set operator type. More...
 
void addOpType (const OpType type)
 Add operator type. More...
 
int getNinTheLoop () const
 get number of finite element in the loop More...
 
int getLoopSize () const
 get size of elements in the loop More...
 
std::string getFEName () const
 Get name of the element. More...
 
ForcesAndSourcesCoregetPtrFE () const
 
ForcesAndSourcesCoregetSidePtrFE () const
 
ForcesAndSourcesCoregetRefinePtrFE () const
 
const PetscData::SwitchesgetDataCtx () const
 
const KspMethod::KSPContext getKSPCtx () const
 
const SnesMethod::SNESContext getSNESCtx () const
 
const TSMethod::TSContext getTSCtx () const
 
Vec getKSPf () const
 
Mat getKSPA () const
 
Mat getKSPB () const
 
Vec getSNESf () const
 
Vec getSNESx () const
 
Mat getSNESA () const
 
Mat getSNESB () const
 
Vec getTSu () const
 
Vec getTSu_t () const
 
Vec getTSu_tt () const
 
Vec getTSf () const
 
Mat getTSA () const
 
Mat getTSB () const
 
int getTSstep () const
 
double getTStime () const
 
double getTStimeStep () const
 
double getTSa () const
 
double getTSaa () const
 
MatrixDoublegetGaussPts ()
 matrix of integration (Gauss) points for Volume Element More...
 
auto getFTensor0IntegrationWeight ()
 Get integration weights. More...
 
MatrixDoublegetCoordsAtGaussPts ()
 Gauss points and weight, matrix (nb. of points x 3) More...
 
auto getFTensor1CoordsAtGaussPts ()
 Get coordinates at integration points assuming linear geometry. More...
 
double getMeasure () const
 get measure of element More...
 
doublegetMeasure ()
 get measure of element More...
 
MoFEMErrorCode loopSide (const string &fe_name, ForcesAndSourcesCore *side_fe, const size_t dim, const EntityHandle ent_for_side=0, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy, AdjCache *adj_cache=nullptr)
 User calls this function to loop over elements on the side of face. This function calls finite element with its operator to do calculations. More...
 
MoFEMErrorCode loopThis (const string &fe_name, ForcesAndSourcesCore *this_fe, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 User calls this function to loop over the same element using a different set of integration points. This function calls finite element with its operator to do calculations. More...
 
MoFEMErrorCode loopParent (const string &fe_name, ForcesAndSourcesCore *parent_fe, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 User calls this function to loop over parent elements. This function calls finite element with its operator to do calculations. More...
 
MoFEMErrorCode loopChildren (const string &fe_name, ForcesAndSourcesCore *child_fe, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 User calls this function to loop over parent elements. This function calls finite element with its operator to do calculations. More...
 
- Public Member Functions inherited from MoFEM::DataOperator
 DataOperator (const bool symm=true)
 
virtual ~DataOperator ()=default
 
virtual MoFEMErrorCode doWork (int row_side, int col_side, EntityType row_type, EntityType col_type, EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)
 Operator for bi-linear form, usually to calculate values on left hand side. More...
 
virtual MoFEMErrorCode opLhs (EntitiesFieldData &row_data, EntitiesFieldData &col_data)
 
virtual MoFEMErrorCode doWork (int side, EntityType type, EntitiesFieldData::EntData &data)
 Operator for linear form, usually to calculate values on right hand side. More...
 
virtual MoFEMErrorCode opRhs (EntitiesFieldData &data, const bool error_if_no_base=false)
 
bool getSymm () const
 Get if operator uses symmetry of DOFs or not. More...
 
void setSymm ()
 set if operator is executed taking in account symmetry More...
 
void unSetSymm ()
 unset if operator is executed for non symmetric problem More...
 

Private Attributes

boost::shared_ptr< CommonDatacommonDataPtr
 
boost::shared_ptr< MatrixDouble > matDPtr
 

Additional Inherited Members

- Public Types inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
enum  OpType {
  OPROW = 1 << 0 , OPCOL = 1 << 1 , OPROWCOL = 1 << 2 , OPSPACE = 1 << 3 ,
  OPLAST = 1 << 3
}
 Controls loop over entities on element. More...
 
using AdjCache = std::map< EntityHandle, std::vector< boost::weak_ptr< NumeredEntFiniteElement > > >
 
- Public Types inherited from MoFEM::DataOperator
using DoWorkLhsHookFunType = boost::function< MoFEMErrorCode(DataOperator *op_ptr, int row_side, int col_side, EntityType row_type, EntityType col_type, EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)>
 
using DoWorkRhsHookFunType = boost::function< MoFEMErrorCode(DataOperator *op_ptr, int side, EntityType type, EntitiesFieldData::EntData &data)>
 
- Public Attributes inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
char opType
 
std::string rowFieldName
 
std::string colFieldName
 
FieldSpace sPace
 
- Public Attributes inherited from MoFEM::DataOperator
DoWorkLhsHookFunType doWorkLhsHook
 
DoWorkRhsHookFunType doWorkRhsHook
 
bool sYmm
 If true assume that matrix is symmetric structure. More...
 
std::array< bool, MBMAXTYPE > doEntities
 If true operator is executed for entity. More...
 
booldoVertices
 \deprectaed If false skip vertices More...
 
booldoEdges
 \deprectaed If false skip edges More...
 
booldoQuads
 \deprectaed More...
 
booldoTris
 \deprectaed More...
 
booldoTets
 \deprectaed More...
 
booldoPrisms
 \deprectaed More...
 
- Static Public Attributes inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
static const char *const OpTypeNames []
 
- Protected Member Functions inherited from MoFEM::VolumeElementForcesAndSourcesCore::UserDataOperator
MoFEMErrorCode setPtrFE (ForcesAndSourcesCore *ptr)
 
virtual MoFEMErrorCode setPtrFE (ForcesAndSourcesCore *ptr)
 
- Protected Attributes inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
ForcesAndSourcesCoreptrFE
 

Detailed Description

template<bool TANGENT>
struct OpElasticTools::OpCalculateLogStressTangent< TANGENT >

Definition at line 867 of file ElasticOperators.hpp.

Constructor & Destructor Documentation

◆ OpCalculateLogStressTangent()

template<bool TANGENT>
OpElasticTools::OpCalculateLogStressTangent< TANGENT >::OpCalculateLogStressTangent ( const std::string  field_name,
boost::shared_ptr< CommonData common_data_ptr,
boost::shared_ptr< MatrixDouble >  mat_D_ptr 
)

Definition at line 176 of file ElasticOperators.cpp.

180 commonDataPtr(common_data_ptr), matDPtr(mat_D_ptr) {
181 // Operator is only executed for vertices
182 std::fill(&doEntities[MBEDGE], &doEntities[MBMAXTYPE], false);
183}
constexpr auto field_name
std::array< bool, MBMAXTYPE > doEntities
If true operator is executed for entity.
@ OPROW
operator doWork function is executed on FE rows
boost::shared_ptr< MatrixDouble > matDPtr
boost::shared_ptr< CommonData > commonDataPtr

Member Function Documentation

◆ doWork()

template<bool TANGENT>
MoFEMErrorCode OpElasticTools::OpCalculateLogStressTangent< TANGENT >::doWork ( int  side,
EntityType  type,
EntData data 
)
virtual

Operator for linear form, usually to calculate values on right hand side.

Reimplemented from MoFEM::DataOperator.

Definition at line 186 of file ElasticOperators.cpp.

188 {
190
191 const size_t nb_gauss_pts = data.getN().size1();
192 auto t_D = getFTensor4DdgFromMat<3, 3, 0>(*matDPtr);
193 auto t_stress = getFTensor2SymmetricFromMat<3>(*(commonDataPtr->mStressPtr));
194 commonDataPtr->mPiolaStressPtr->resize(9, nb_gauss_pts, false);
195 auto t_piola = getFTensor2FromMat<3, 3>(*(commonDataPtr->mPiolaStressPtr));
196 auto F = getFTensor2FromMat<3, 3>(*(commonDataPtr->mDeformationGradient));
197 auto C = getFTensor2SymmetricFromMat<3>(*(commonDataPtr->matC));
198 auto t_eigen_vec = getFTensor2FromMat<3, 3>(*(commonDataPtr->matEigenVector));
199 auto t_eigen = getFTensor1FromMat<3>(*(commonDataPtr->matEigenVal));
200
201 MatrixDouble &dP_dF = *(commonDataPtr->materialTangent);
202 dP_dF.resize(81, nb_gauss_pts, false);
203 auto t_dP_dF = getFTensor4FromMat<3, 3, 3, 3>(dP_dF);
204
205 MatrixDouble &dE_dF = *(commonDataPtr->dE_dF_mat);
206 dE_dF.resize(81, nb_gauss_pts, false);
207 auto t_dE_dF = getFTensor4FromMat<3, 3, 3, 3>(dE_dF);
208
209 constexpr auto t_kd = Kronecker_Delta<int>();
211 // Ddg<double, 3, 3> TL_test;
213
214 for (size_t gg = 0; gg != nb_gauss_pts; ++gg) {
216 dC_dF(i, j, k, l) = (t_kd(i, l) * F(k, j)) + (t_kd(j, l) * F(k, i));
217 auto dlogC_dC = calculate_lagrangian_moduli_TL<TANGENT>(t_stress, t_eigen,
218 t_eigen_vec, TL);
219
220 t_dE_dF(i, j, k, l) = dlogC_dC(i, j, m, n) * dC_dF(m, n, k, l);
221 t_dE_dF(i, j, k, l) *= 0.5;
222
223 if (TANGENT) {
224 S(k, l) = t_stress(i, j) * dlogC_dC(i, j, k, l);
225 t_piola(i, l) = F(i, k) * S(k, l);
226
227 FTensor::Ddg<double, 3, 3> P_D_P_plus_TL;
228 P_D_P_plus_TL(i, j, k, l) =
229 TL(i, j, k, l) +
230 (dlogC_dC(i, j, o, p) * t_D(o, p, m, n)) * dlogC_dC(m, n, k, l);
231 P_D_P_plus_TL(i, j, k, l) *= 0.5;
232
233 t_dP_dF(i, j, m, n) = t_kd(i, m) * (t_kd(k, n) * S(k, j));
234 t_dP_dF(i, j, m, n) +=
235 F(i, k) * (P_D_P_plus_TL(k, j, o, p) * dC_dF(o, p, m, n));
236
237 // auto Piola = to_non_symm(t_stress);
238 // auto D1_from_fddsa321p = getDTensorFunction(*commonDataPtr, F, Piola);
239 // auto test_lukasz =
240 // test_projection_lukasz(C, t_stress, t_eigen, t_eigen_vec, TL_test);
241 // test_lukasz(i, j, k, l) *= 2;
242 // TL_test(i, j, k, l) *= 4;
243 // string wait;
244 } else {
245 // auto dlogC_dC = calculate_lagrangian_moduli_TL<false>(
246 // t_stress, t_eigen, t_eigen_vec, TL);
247 S(k, l) = t_stress(i, j) * dlogC_dC(i, j, k, l);
248 t_piola(i, l) = F(i, k) * S(k, l);
249 }
250 if (false && TANGENT) {
251 if (getTStime() > 0.2) {
252 {
253 Ddg<double, 3, 3> TL3_lukasz;
254 cout << "NEW IMPLEMENTATION" << endl;
255 MeasureTime time1;
256 for (int ii = 0; ii != 1000; ii++)
257 auto P_proj_lukasz = test_projection_lukasz(
258 C, t_stress, t_eigen, t_eigen_vec, TL3_lukasz);
259 }
260 Ddg<double, 3, 3> dummy33;
261 {
262 cout << "NEW IMPLEMENTATION" << endl;
263 MeasureTime time1;
264 for (int ii = 0; ii != 1000; ii++)
265 auto P_proj_ = calculate_lagrangian_moduli_TL<true>(
266 t_stress, t_eigen, t_eigen_vec, dummy33);
267 }
268 {
269 cout << "(OLD) FINITE DIFFERENCE" << endl;
270 auto Piola = to_non_symm(t_stress);
271 MeasureTime time1;
272 for (int ii = 0; ii != 1000; ii++)
273 auto D1_from_fddsap = getDTensorFunction(*commonDataPtr, F, Piola);
274 }
275 {
276 cout << "EIGENVALUES (LAPACK)" << endl;
277 MeasureTime time1;
278 for (int ii = 0; ii != 1000; ii++)
279 CHKERR get_eigen_val_and_proj_lapack(C, t_eigen, t_eigen_vec);
280 }
281 }
282
283 // double sum = 0;
284 // double sum2 = 0;
285 // double sum3 = 0;
286 // double sum0 = 0;
287 // for (int i = 0; i != 3; ++i)
288 // for (int j = 0; j != 3; ++j)
289 // for (int k = 0; k != 3; ++k)
290 // for (int l = 0; l != 3; ++l) {
291 // // sum0 += abs(P3_prop_lag(i, j, k, l) - dlogC_dC_test(i, j, k,
292 // l));
293 // // sum += abs(P_Proj_lukasz(i, j, k, l) - dlogC_dC_test(i, j,
294 // k, l)); sum2 += abs(dP_dF(i, j, k, l) - D1(i, j, k, l)); sum3
295 // +=
296 // abs(myDFin_lukasz(i, j, k, l) - D1_from_fd_LAG(i, j, k,
297 // l));
298 // // if (abs(myDFinFinFin(i, j, k, l) - D1(i, j, k, l)) > 1e-6)
299 // // cout << i << j << k << l << " "
300 // // << myDFinFinFin(i, j, k, l) / D1(i, j, k, l) << endl;
301 // }
302 if (getTStime() > 0.2)
303 string wait;
304 }
305
306 ++t_piola;
307 ++t_eigen;
308 ++t_eigen_vec;
309 ++t_dP_dF;
310 ++t_dE_dF;
311 ++t_stress;
312 ++F;
313 ++C;
314 }
315
317}
static Index< 'o', 3 > o
static Index< 'p', 3 > p
Kronecker Delta class.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
#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
FTensor::Index< 'n', SPACE_DIM > n
FTensor::Index< 'm', SPACE_DIM > m
@ F
constexpr auto t_kd
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'l', 3 > l
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
MoFEMErrorCode get_eigen_val_and_proj_lapack(const Tensor2_symmetric< T, 3 > &X, Tensor1< T, 3 > &lambda, Tensor2< T, 3, 3 > &eig_vec)
Tensor4< double, 3, 3, 3, 3 > getDTensorFunction(CommonData &common_data, Tensor2< T, 3, 3 > &F, Tensor2< double, 3, 3 > &t_stress)
auto to_non_symm(T &symm)
auto test_projection_lukasz(Tensor2_symmetric< T, 3 > &X, Tensor2_symmetric< TP, 3 > &stress, Tensor1< T, 3 > &lambda, Tensor2< T, 3, 3 > &eig_vec, Ddg< T3, 3, 3 > &TLs3)
MatrixDouble & getN(const FieldApproximationBase base)
get base functions this return matrix (nb. of rows is equal to nb. of Gauss pts, nb....

Member Data Documentation

◆ commonDataPtr

template<bool TANGENT>
boost::shared_ptr<CommonData> OpElasticTools::OpCalculateLogStressTangent< TANGENT >::commonDataPtr
private

Definition at line 874 of file ElasticOperators.hpp.

◆ matDPtr

template<bool TANGENT>
boost::shared_ptr<MatrixDouble> OpElasticTools::OpCalculateLogStressTangent< TANGENT >::matDPtr
private

Definition at line 875 of file ElasticOperators.hpp.


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