v0.13.2
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
MetaSpringBC::OpSpringKs_dX Struct Reference

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

Inheritance diagram for MetaSpringBC::OpSpringKs_dX:
[legend]
Collaboration diagram for MetaSpringBC::OpSpringKs_dX:
[legend]

Public Member Functions

MoFEMErrorCode doWork (int row_side, int col_side, EntityType row_type, EntityType col_type, EntData &row_data, EntData &col_data)
 Compute part of the left-hand side. More...
 
 OpSpringKs_dX (boost::shared_ptr< MetaSpringBC::DataAtIntegrationPtsSprings > &common_data_ptr, MetaSpringBC::BlockOptionDataSprings &data, const std::string field_name_1, const std::string field_name_2)
 
- Public Member Functions inherited from MoFEM::FaceElementForcesAndSourcesCore::UserDataOperator
double getArea ()
 get area of face More...
 
double getMeasure ()
 get measure of element More...
 
VectorDoublegetNormal ()
 get triangle normal More...
 
VectorDoublegetTangent1 ()
 get triangle tangent 1 More...
 
VectorDoublegetTangent2 ()
 get triangle tangent 2 More...
 
auto getFTensor1Normal ()
 get normal as tensor More...
 
auto getFTensor1Tangent1 ()
 get tangentOne as tensor More...
 
auto getFTensor1Tangent2 ()
 get tangentTwo as tensor More...
 
int getNumNodes ()
 get element number of nodes More...
 
const EntityHandlegetConn ()
 get element connectivity More...
 
VectorDoublegetCoords ()
 get triangle coordinates More...
 
auto getFTensor1Coords ()
 get get coords at gauss points More...
 
MatrixDoublegetNormalsAtGaussPts ()
 if higher order geometry return normals at Gauss pts. More...
 
ublas::matrix_row< MatrixDoublegetNormalsAtGaussPts (const int gg)
 if higher order geometry return normals at Gauss pts. More...
 
MatrixDoublegetTangent1AtGaussPts ()
 if higher order geometry return tangent vector to triangle at Gauss pts. More...
 
MatrixDoublegetTangent2AtGaussPts ()
 if higher order geometry return tangent vector to triangle at Gauss pts. More...
 
auto getFTensor1NormalsAtGaussPts ()
 get normal at integration points More...
 
auto getFTensor1Tangent1AtGaussPts ()
 get tangent 1 at integration points More...
 
auto getFTensor1Tangent2AtGaussPts ()
 get tangent 2 at integration points More...
 
FaceElementForcesAndSourcesCoregetFaceFE ()
 return pointer to Generic Triangle Finite Element object More...
 
MoFEMErrorCode loopSideVolumes (const string fe_name, VolumeElementForcesAndSourcesCoreOnSide &fe_method)
 
- 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)
 User call this function to loop over elements on the side of face. This function calls finite element with is operator to do calculations. More...
 
MoFEMErrorCode loopThis (const string &fe_name, ForcesAndSourcesCore *parent_fe, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 User call this function to loop over parent elements. This function calls finite element with is 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 call this function to loop over parent elements. This function calls finite element with is 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 call this function to loop over parent elements. This function calls finite element with is 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...
 

Public Attributes

boost::shared_ptr< MetaSpringBC::DataAtIntegrationPtsSpringscommonDataPtr
 
MetaSpringBC::BlockOptionDataSpringsdAta
 
MatrixDouble locKs
 
MatrixDouble transLocKs
 
- 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...
 

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...
 
- 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)>
 
- Static Public Attributes inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
static const char *const OpTypeNames []
 
virtual MoFEMErrorCode setPtrFE (ForcesAndSourcesCore *ptr)
 
- Protected Attributes inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
ForcesAndSourcesCoreptrFE
 

Detailed Description

Definition at line 254 of file SpringElement.hpp.

Constructor & Destructor Documentation

◆ OpSpringKs_dX()

MetaSpringBC::OpSpringKs_dX::OpSpringKs_dX ( boost::shared_ptr< MetaSpringBC::DataAtIntegrationPtsSprings > &  common_data_ptr,
MetaSpringBC::BlockOptionDataSprings data,
const std::string  field_name_1,
const std::string  field_name_2 
)
inline

Definition at line 320 of file SpringElement.hpp.

326 field_name_1.c_str(), field_name_2.c_str(), OPROWCOL),
327 commonDataPtr(common_data_ptr), dAta(data) {
328 sYmm = false;
329 }
boost::shared_ptr< MetaSpringBC::DataAtIntegrationPtsSprings > commonDataPtr
MetaSpringBC::BlockOptionDataSprings & dAta
bool sYmm
If true assume that matrix is symmetric structure.
@ OPROWCOL
operator doWork is executed on FE rows &columns

Member Function Documentation

◆ doWork()

MoFEMErrorCode MetaSpringBC::OpSpringKs_dX::doWork ( int  row_side,
int  col_side,
EntityType  row_type,
EntityType  col_type,
EntData row_data,
EntData col_data 
)
virtual

Compute part of the left-hand side.

Computes the linearisation of the material component with respect to a variation of material coordinates \((\Delta\mathbf{X})\):

\[ \textrm{D} f^{\textrm{(face)}}_s(\mathbf{x}, \mathbf{X}, \delta\mathbf{x}) [\Delta\mathbf{X}] = -\int\limits_{\mathcal{T}_{\xi}} \, 0.5 (k_{\rm n} - k_{\rm s}) \cdot \left\{ \left[ \frac{\partial\mathbf{X}} {\partial\xi} \cdot \left(\frac{\partial\Delta \mathbf{X}}{\partial\eta}\times\delta\mathbf{x}\right) -\frac{\partial\mathbf{X}} {\partial\eta} \cdot \left(\frac{\partial\Delta \mathbf{X}}{\partial\xi}\times \delta\mathbf{x}\right)\right] \otimes \dfrac{\mathbf{N}}{\|\mathbf{N}\|} + \dfrac{\mathbf{N}}{\|\mathbf{N}\|} \otimes \left[ \frac{\partial\mathbf{X}} {\partial\xi} \cdot \left(\frac{\partial\Delta \mathbf{X}}{\partial\eta}\times\delta\mathbf{x}\right) -\frac{\partial\mathbf{X}} {\partial\eta} \cdot \left(\frac{\partial\Delta \mathbf{X}}{\partial\xi}\times \delta\mathbf{x}\right)\right] - \dfrac{\mathbf{N} \otimes \mathbf{N}}{{\| \mathbf{N} \|}^3} \left[ \frac{\partial\mathbf{X}} {\partial\xi} \cdot \left(\frac{\partial\Delta \mathbf{X}}{\partial\eta}\times\delta\mathbf{x}\right) -\frac{\partial\mathbf{X}} {\partial\eta} \cdot \left(\frac{\partial\Delta \mathbf{X}}{\partial\xi}\times \delta\mathbf{x}\right)\right] \mathbf{N} \right \} \textrm{d}\xi\textrm{d}\eta \\ +\int\limits_{\mathcal{T}_{\xi}} 0.5 k_{\rm s} \left[ \frac{\partial\mathbf{X}} {\partial\xi} \cdot \left(\frac{\partial\Delta \mathbf{X}}{\partial\eta}\times\delta\mathbf{x}\right) -\frac{\partial\mathbf{X}} {\partial\eta} \cdot \left(\frac{\partial\Delta \mathbf{X}}{\partial\xi}\times \delta\mathbf{x}\right)\right] {\mathbf N}^{\intercal} \cdot {\mathbf I} ( {\mathbf x} - {\mathbf X} ) \textrm{d}\xi\textrm{d}\eta -\int\limits_{\mathcal{T}_{\xi}} {{\delta \mathbf{x}^T} \cdot \left[ k_{\rm n} \left( {\mathbf N} \otimes {\mathbf N} \right) + k_{\rm t} \left( {\mathbf I} - {\mathbf N} \otimes {\mathbf N} \right) \right] \Delta {\mathbf X} } \textrm{d}\xi\textrm{d}\eta \]

Reimplemented from MoFEM::DataOperator.

Definition at line 228 of file SpringElement.cpp.

232 {
234
235 // check if the volumes have associated degrees of freedom
236 const int row_nb_dofs = row_data.getIndices().size();
237 if (!row_nb_dofs)
239
240 const int col_nb_dofs = col_data.getIndices().size();
241 if (!col_nb_dofs)
243
244 if (dAta.tRis.find(getFEEntityHandle()) == dAta.tRis.end()) {
246 }
247
248 CHKERR commonDataPtr->getBlockData(dAta);
249 // size associated to the entity
250 locKs.resize(row_nb_dofs, col_nb_dofs, false);
251 locKs.clear();
252
253 // get number of Gauss points
254 const int row_nb_gauss_pts = row_data.getN().size1();
255 if (!row_nb_gauss_pts) // check if number of Gauss point <> 0
257
258 // get intergration weights
259 auto t_w = getFTensor0IntegrationWeight();
260
265
266 auto make_vec_der = [&](auto t_N, auto t_1, auto t_2) {
268 t_n(i, j) = 0;
269 t_n(i, j) += FTensor::levi_civita(i, j, k) * t_2(k) * t_N(0);
270 t_n(i, j) -= FTensor::levi_civita(i, j, k) * t_1(k) * t_N(1);
271 return t_n;
272 };
273
274 auto make_vec_der_2 = [&](auto t_N, auto t_1, auto t_2) {
276 t_normal(i) = FTensor::levi_civita(i, j, k) * t_1(j) * t_2(k);
277 const double normal_norm = std::sqrt(t_normal(i) * t_normal(i));
279 t_n(i, j) = 0;
280 t_n(i, j) += FTensor::levi_civita(i, j, k) * t_2(k) * t_N(0);
281 t_n(i, j) -= FTensor::levi_civita(i, j, k) * t_1(k) * t_N(1);
283 t_result(i, j) = 0;
284 t_result(i, j) =
285 t_n(i, j) / normal_norm - t_normal(i) * t_n(k, j) * t_normal(k) /
286 (normal_norm * normal_norm * normal_norm);
287 return t_result;
288 };
289
290 const double normal_stiffness = commonDataPtr->springStiffnessNormal;
291 const double tangent_stiffness = commonDataPtr->springStiffnessTangent;
292
293 // create a 3d vector to be used as the normal to the face with length equal
294 // to the face area
296 FTensor::Tensor2<double, 3, 3> t_normal_projection;
297 FTensor::Tensor2<double, 3, 3> t_tangent_projection;
298 FTensor::Tensor1<double, 3> t_displacement_at_gauss_point;
299
300 // Extract solution at Gauss points
301 auto t_solution_at_gauss_point =
302 getFTensor1FromMat<3>(*commonDataPtr->xAtPts);
303 auto t_init_solution_at_gauss_point =
304 getFTensor1FromMat<3>(*commonDataPtr->xInitAtPts);
305
306 auto t_1 = getFTensor1FromMat<3>(commonDataPtr->tangent1);
307 auto t_2 = getFTensor1FromMat<3>(commonDataPtr->tangent2);
308
309 constexpr auto t_kd = FTensor::Kronecker_Delta<int>();
310
311 auto normal_at_gp = getFTensor1FromMat<3>(commonDataPtr->normalVector);
312
313 // loop over the Gauss points
314 for (int gg = 0; gg != row_nb_gauss_pts; gg++) {
315 // get area and integration weight
316 t_normal(i) = normal_at_gp(i);
317 const double normal_length = std::sqrt(t_normal(k) * t_normal(k));
318 t_normal(i) = t_normal(i) / normal_length;
319
320 t_normal_projection(i, j) = t_normal(i) * t_normal(j);
321 t_tangent_projection(i, j) = t_normal_projection(i, j);
322 t_tangent_projection(0, 0) -= 1;
323 t_tangent_projection(1, 1) -= 1;
324 t_tangent_projection(2, 2) -= 1;
325
326 double w = 0.5 * t_w;
327
328 t_displacement_at_gauss_point(i) =
329 t_solution_at_gauss_point(i) - t_init_solution_at_gauss_point(i);
330
331 auto t_row_base_func = row_data.getFTensor0N(gg, 0);
332
333 for (int rr = 0; rr != row_nb_dofs / 3; rr++) {
334 auto t_col_base_func = col_data.getFTensor0N(gg, 0);
335 auto t_N = col_data.getFTensor1DiffN<2>(gg, 0);
336 auto assemble_m = getFTensor2FromArray<3, 3, 3>(locKs, 3 * rr);
337 for (int cc = 0; cc != col_nb_dofs / 3; cc++) {
338 auto t_d_n = make_vec_der(t_N, t_1, t_2);
339 auto t_d_n_2 = make_vec_der_2(t_N, t_1, t_2);
340
341 assemble_m(i, j) -= w * normal_length * t_col_base_func *
342 normal_stiffness * t_row_base_func *
343 t_normal_projection(i, j);
344
345 assemble_m(i, j) += w * normal_length * t_col_base_func *
346 tangent_stiffness * t_row_base_func *
347 t_tangent_projection(i, j);
348
349 assemble_m(i, j) +=
350 w * (normal_stiffness - tangent_stiffness) * t_row_base_func *
351 (t_d_n(i, j) * (t_normal(k) * t_displacement_at_gauss_point(k)) +
352 normal_length * t_normal(i) *
353 (t_d_n_2(k, j) * t_displacement_at_gauss_point(k)));
354 // constexpr auto t_kd = FTensor::Kronecker_Delta_symmetric<int>();
355 assemble_m(i, j) += w * (t_d_n(l, j) * t_normal(l)) *
356 tangent_stiffness * t_row_base_func * t_kd(i, k) *
357 t_displacement_at_gauss_point(k);
358
359 ++t_col_base_func;
360 ++t_N;
361 ++assemble_m;
362 }
363 ++t_row_base_func;
364 }
365 // move to next integration weight
366 ++t_w;
367 ++t_solution_at_gauss_point;
368 ++t_init_solution_at_gauss_point;
369 ++t_1;
370 ++t_2;
371 ++normal_at_gp;
372 }
373
374 // Add computed values of spring stiffness to the global LHS matrix
375 CHKERR MatSetValues(getKSPB(), row_data, col_data, &locKs(0, 0), ADD_VALUES);
376
378}
Kronecker Delta class.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
#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
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
constexpr std::enable_if<(Dim0<=2 &&Dim1<=2), Tensor2_Expr< Levi_Civita< T >, T, Dim0, Dim1, i, j > >::type levi_civita(const Index< i, Dim0 > &, const Index< j, Dim1 > &)
levi_civita functions to make for easy adhoc use
MoFEMErrorCode MatSetValues(Mat M, const EntitiesFieldData::EntData &row_data, const EntitiesFieldData::EntData &col_data, const double *ptr, InsertMode iora)
Assemble PETSc matrix.
double w(const double g, const double t)
FTensor::Tensor1< FTensor::PackPtr< double *, Tensor_Dim >, Tensor_Dim > getFTensor1DiffN(const FieldApproximationBase base)
Get derivatives of base functions.
FTensor::Tensor0< FTensor::PackPtr< double *, 1 > > getFTensor0N(const FieldApproximationBase base)
Get base function as Tensor0.
MatrixDouble & getN(const FieldApproximationBase base)
get base functions this return matrix (nb. of rows is equal to nb. of Gauss pts, nb....
const VectorInt & getIndices() const
Get global indices of dofs on entity.
EntityHandle getFEEntityHandle() const
Return finite element entity handle.
auto getFTensor0IntegrationWeight()
Get integration weights.

Member Data Documentation

◆ commonDataPtr

boost::shared_ptr<MetaSpringBC::DataAtIntegrationPtsSprings> MetaSpringBC::OpSpringKs_dX::commonDataPtr

Definition at line 257 of file SpringElement.hpp.

◆ dAta

MetaSpringBC::BlockOptionDataSprings& MetaSpringBC::OpSpringKs_dX::dAta

Definition at line 258 of file SpringElement.hpp.

◆ locKs

MatrixDouble MetaSpringBC::OpSpringKs_dX::locKs

Definition at line 260 of file SpringElement.hpp.

◆ transLocKs

MatrixDouble MetaSpringBC::OpSpringKs_dX::transLocKs

Definition at line 261 of file SpringElement.hpp.


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