v0.15.0
Loading...
Searching...
No Matches
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.
 
 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
 
VectorDoublegetNormal ()
 get triangle normal
 
VectorDoublegetTangent1 ()
 get triangle tangent 1
 
VectorDoublegetTangent2 ()
 get triangle tangent 2
 
auto getFTensor1Normal ()
 get normal as tensor
 
auto getFTensor1Tangent1 ()
 get tangentOne as tensor
 
auto getFTensor1Tangent2 ()
 get tangentTwo as tensor
 
int getNumNodes ()
 get element number of nodes
 
const EntityHandlegetConn ()
 get element connectivity
 
VectorDoublegetCoords ()
 get triangle coordinates
 
auto getFTensor1Coords ()
 get get coords at gauss points
 
MatrixDoublegetNormalsAtGaussPts ()
 if higher order geometry return normals at Gauss pts.
 
ublas::matrix_row< MatrixDoublegetNormalsAtGaussPts (const int gg)
 if higher order geometry return normals at Gauss pts.
 
MatrixDoublegetTangent1AtGaussPts ()
 if higher order geometry return tangent vector to triangle at Gauss pts.
 
MatrixDoublegetTangent2AtGaussPts ()
 if higher order geometry return tangent vector to triangle at Gauss pts.
 
auto getFTensor1NormalsAtGaussPts ()
 get normal at integration points
 
auto getFTensor1Tangent1AtGaussPts ()
 get tangent 1 at integration points
 
auto getFTensor1Tangent2AtGaussPts ()
 get tangent 2 at integration points
 
FaceElementForcesAndSourcesCoregetFaceFE ()
 return pointer to Generic Triangle Finite Element object
 
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.
 
EntityHandle getFEEntityHandle () const
 Return finite element entity handle.
 
int getFEDim () const
 Get dimension of finite element.
 
EntityType getFEType () const
 Get dimension of finite element.
 
boost::weak_ptr< SideNumbergetSideNumberPtr (const int side_number, const EntityType type)
 Get the side number pointer.
 
EntityHandle getSideEntity (const int side_number, const EntityType type)
 Get the side entity.
 
int getNumberOfNodesOnElement () const
 Get the number of nodes on finite element.
 
MoFEMErrorCode getProblemRowIndices (const std::string filed_name, const EntityType type, const int side, VectorInt &indices) const
 Get row indices.
 
MoFEMErrorCode getProblemColIndices (const std::string filed_name, const EntityType type, const int side, VectorInt &indices) const
 Get col indices.
 
const FEMethodgetFEMethod () const
 Return raw pointer to Finite Element Method object.
 
int getOpType () const
 Get operator types.
 
void setOpType (const OpType type)
 Set operator type.
 
void addOpType (const OpType type)
 Add operator type.
 
int getNinTheLoop () const
 get number of finite element in the loop
 
int getLoopSize () const
 get size of elements in the loop
 
std::string getFEName () const
 Get name of the element.
 
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
 
auto getFTensor0IntegrationWeight ()
 Get integration weights.
 
MatrixDoublegetCoordsAtGaussPts ()
 Gauss points and weight, matrix (nb. of points x 3)
 
auto getFTensor1CoordsAtGaussPts ()
 Get coordinates at integration points assuming linear geometry.
 
double getMeasure () const
 get measure of element
 
doublegetMeasure ()
 get measure of element
 
MoFEMErrorCode loopSide (const string &fe_name, ForcesAndSourcesCore *side_fe, const size_t dim, const EntityHandle ent_for_side=0, boost::shared_ptr< Range > fe_range=nullptr, 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.
 
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.
 
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.
 
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.
 
MoFEMErrorCode loopRange (const string &fe_name, ForcesAndSourcesCore *range_fe, boost::shared_ptr< Range > fe_range, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 Iterate over range of elements.
 
- Public Member Functions inherited from MoFEM::DataOperator
 DataOperator (const bool symm=true)
 
virtual ~DataOperator ()=default
 
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.
 
virtual MoFEMErrorCode opRhs (EntitiesFieldData &data, const bool error_if_no_base=false)
 
bool getSymm () const
 Get if operator uses symmetry of DOFs or not.
 
void setSymm ()
 set if operator is executed taking in account symmetry
 
void unSetSymm ()
 unset if operator is executed for non symmetric problem
 

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.
 
std::array< bool, MBMAXTYPE > doEntities
 If true operator is executed for entity.
 
booldoVertices
 \deprectaed If false skip vertices
 
booldoEdges
 \deprectaed If false skip edges
 
booldoQuads
 \deprectaed
 
booldoTris
 \deprectaed
 
booldoTets
 \deprectaed
 
booldoPrisms
 \deprectaed
 

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
 
- Public Types inherited from MoFEM::DataOperator
using DoWorkLhsHookFunType
 
using DoWorkRhsHookFunType
 
- Static Public Attributes inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
static const char *const OpTypeNames []
 
- Protected Member Functions inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
- Protected Attributes inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
ForcesAndSourcesCoreptrFE
 

Detailed Description

Definition at line 253 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 319 of file SpringElement.hpp.

325 field_name_1.c_str(), field_name_2.c_str(), OPROWCOL),
326 commonDataPtr(common_data_ptr), dAta(data) {
327 sYmm = false;
328 }
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
261 FTensor::Index<'i', 3> i;
262 FTensor::Index<'j', 3> j;
263 FTensor::Index<'k', 3> k;
264 FTensor::Index<'l', 3> l;
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 =
303 auto t_init_solution_at_gauss_point =
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()
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
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
FTensor::Tensor2< FTensor::PackPtr< double *, S >, DIM1, DIM2 > getFTensor2FromArray(MatrixDouble &data, const size_t rr, const size_t cc=0)
FTensor::Tensor1< FTensor::PackPtr< T *, S >, Tensor_Dim > getFTensor1FromMat(ublas::matrix< T, L, A > &data)
Get tensor rank 1 (vector) form data matrix.
MoFEMErrorCode MatSetValues(Mat M, const EntitiesFieldData::EntData &row_data, const EntitiesFieldData::EntData &col_data, const double *ptr, InsertMode iora)
Assemble PETSc matrix.
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 256 of file SpringElement.hpp.

◆ dAta

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

Definition at line 257 of file SpringElement.hpp.

◆ locKs

MatrixDouble MetaSpringBC::OpSpringKs_dX::locKs

Definition at line 259 of file SpringElement.hpp.

◆ transLocKs

MatrixDouble MetaSpringBC::OpSpringKs_dX::transLocKs

Definition at line 260 of file SpringElement.hpp.


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