v0.13.2
Loading...
Searching...
No Matches
Classes | Typedefs | Functions | Variables
ContactOps Namespace Reference

Classes

struct  BoundaryBCs
 
struct  CommonData
 [Common data] More...
 
struct  DomainBCs
 
struct  Monitor
 
struct  OpAssembleTraction
 
struct  OpConstrainBoundaryLhs_dTraction
 
struct  OpConstrainBoundaryLhs_dU
 
struct  OpConstrainBoundaryRhs
 
struct  PostProcEleByDim
 
struct  PostProcEleByDim< 2 >
 
struct  PostProcEleByDim< 3 >
 

Typedefs

using DomainRhsBCs = NaturalBC< DomainEleOp >::Assembly< A >::LinearForm< I >
 
using OpDomainRhsBCs = DomainRhsBCs::OpFlux< DomainBCs, 1, SPACE_DIM >
 
using BoundaryRhsBCs = NaturalBC< BoundaryEleOp >::Assembly< A >::LinearForm< I >
 
using OpBoundaryRhsBCs = BoundaryRhsBCs::OpFlux< BoundaryBCs, 1, SPACE_DIM >
 
using BoundaryLhsBCs = NaturalBC< BoundaryEleOp >::Assembly< A >::BiLinearForm< I >
 
using OpBoundaryLhsBCs = BoundaryLhsBCs::OpFlux< BoundaryBCs, 1, SPACE_DIM >
 
using PostProcEleDomain = PostProcEleByDim< SPACE_DIM >::PostProcEleDomain
 
using SideEle = PostProcEleByDim< SPACE_DIM >::SideEle
 
using PostProcEleBdy = PostProcEleByDim< SPACE_DIM >::PostProcEleBdy
 

Functions

MoFEMErrorCode addMatBlockOps (MoFEM::Interface &m_field, boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &pipeline, std::string field_name, std::string block_name, boost::shared_ptr< MatrixDouble > mat_D_Ptr, Sev sev)
 
template<typename T1 , typename T2 >
double surface_distance_function (double t, FTensor::Tensor1< T1, 3 > &t_coords, FTensor::Tensor1< T2, SPACE_DIM > &t_traction)
 
template<typename T1 , typename T2 >
FTensor::Tensor1< double, 3 > grad_surface_distance_function (double t, FTensor::Tensor1< T1, 3 > &t_coords, FTensor::Tensor1< T2, SPACE_DIM > &t_traction)
 
template<typename T1 , typename T2 >
FTensor::Tensor2_symmetric< double, 3 > hess_surface_distance_function (double t, FTensor::Tensor1< T1, 3 > &t_coords, FTensor::Tensor1< T2, SPACE_DIM > &t_traction)
 
double sign (double x)
 
double w (const double sdf, const double tn)
 
double constrain (double sdf, double tn)
 

Variables

FTensor::Index< 'i', SPACE_DIMi
 [Common data] More...
 
FTensor::Index< 'j', SPACE_DIMj
 
FTensor::Index< 'k', SPACE_DIMk
 
FTensor::Index< 'l', SPACE_DIMl
 

Typedef Documentation

◆ BoundaryLhsBCs

Definition at line 104 of file contact.cpp.

◆ BoundaryRhsBCs

Definition at line 102 of file contact.cpp.

◆ DomainRhsBCs

Definition at line 100 of file contact.cpp.

◆ OpBoundaryLhsBCs

Definition at line 105 of file contact.cpp.

◆ OpBoundaryRhsBCs

Definition at line 103 of file contact.cpp.

◆ OpDomainRhsBCs

Definition at line 101 of file contact.cpp.

◆ PostProcEleBdy

using ContactOps::PostProcEleBdy = typedef PostProcEleByDim<SPACE_DIM>::PostProcEleBdy

Definition at line 26 of file PostProcContact.hpp.

◆ PostProcEleDomain

using ContactOps::PostProcEleDomain = typedef PostProcEleByDim<SPACE_DIM>::PostProcEleDomain

Definition at line 24 of file PostProcContact.hpp.

◆ SideEle

using ContactOps::SideEle = typedef PostProcEleByDim<SPACE_DIM>::SideEle

Definition at line 25 of file PostProcContact.hpp.

Function Documentation

◆ addMatBlockOps()

MoFEMErrorCode ContactOps::addMatBlockOps ( MoFEM::Interface m_field,
boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &  pipeline,
std::string  field_name,
std::string  block_name,
boost::shared_ptr< MatrixDouble >  mat_D_Ptr,
Sev  sev 
)

[Calculate elasticity tensor]

[Calculate elasticity tensor]

Definition at line 755 of file contact.cpp.

759 {
761
762 struct OpMatBlocks : public DomainEleOp {
763 OpMatBlocks(std::string field_name, boost::shared_ptr<MatrixDouble> m,
764 double bulk_modulus_K, double shear_modulus_G,
765 MoFEM::Interface &m_field, Sev sev,
766 std::vector<const CubitMeshSets *> meshset_vec_ptr)
767 : DomainEleOp(field_name, DomainEleOp::OPROW), matDPtr(m),
768 bulkModulusKDefault(bulk_modulus_K),
769 shearModulusGDefault(shear_modulus_G) {
770 std::fill(&(doEntities[MBEDGE]), &(doEntities[MBMAXTYPE]), false);
771 CHK_THROW_MESSAGE(extractBlockData(m_field, meshset_vec_ptr, sev),
772 "Can not get data from block");
773 }
774
775 MoFEMErrorCode doWork(int side, EntityType type,
778
779 for (auto &b : blockData) {
780
781 if (b.blockEnts.find(getFEEntityHandle()) != b.blockEnts.end()) {
782 CHKERR getMatDPtr(matDPtr, b.bulkModulusK, b.shearModulusG);
784 }
785 }
786
787 CHKERR getMatDPtr(matDPtr, bulkModulusKDefault, shearModulusGDefault);
789 }
790
791 private:
792 boost::shared_ptr<MatrixDouble> matDPtr;
793
794 struct BlockData {
795 double bulkModulusK;
796 double shearModulusG;
797 Range blockEnts;
798 };
799
800 double bulkModulusKDefault;
801 double shearModulusGDefault;
802 std::vector<BlockData> blockData;
803
805 extractBlockData(MoFEM::Interface &m_field,
806 std::vector<const CubitMeshSets *> meshset_vec_ptr,
807 Sev sev) {
809
810 for (auto m : meshset_vec_ptr) {
811 MOFEM_TAG_AND_LOG("WORLD", sev, "MatBlock") << *m;
812 std::vector<double> block_data;
813 CHKERR m->getAttributes(block_data);
814 if (block_data.size() != 2) {
815 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
816 "Expected that block has two attribute");
817 }
818 auto get_block_ents = [&]() {
819 Range ents;
820 CHKERR
821 m_field.get_moab().get_entities_by_handle(m->meshset, ents, true);
822 return ents;
823 };
824
825 double young_modulus = block_data[0];
826 double poisson_ratio = block_data[1];
827 double bulk_modulus_K = young_modulus / (3 * (1 - 2 * poisson_ratio));
828 double shear_modulus_G = young_modulus / (2 * (1 + poisson_ratio));
829
830 MOFEM_TAG_AND_LOG("WORLD", sev, "MatBlock")
831 << "E = " << young_modulus << " nu = " << poisson_ratio;
832
833 blockData.push_back(
834 {bulk_modulus_K, shear_modulus_G, get_block_ents()});
835 }
836 MOFEM_LOG_CHANNEL("WORLD");
838 }
839
840 MoFEMErrorCode getMatDPtr(boost::shared_ptr<MatrixDouble> mat_D_ptr,
841 double bulk_modulus_K, double shear_modulus_G) {
843 //! [Calculate elasticity tensor]
844 auto set_material_stiffness = [&]() {
850 double A = (SPACE_DIM == 2)
851 ? 2 * shear_modulus_G /
852 (bulk_modulus_K + (4. / 3.) * shear_modulus_G)
853 : 1;
854 auto t_D = getFTensor4DdgFromMat<SPACE_DIM, SPACE_DIM, 0>(*mat_D_ptr);
855 t_D(i, j, k, l) =
856 2 * shear_modulus_G * ((t_kd(i, k) ^ t_kd(j, l)) / 4.) +
857 A * (bulk_modulus_K - (2. / 3.) * shear_modulus_G) * t_kd(i, j) *
858 t_kd(k, l);
859 };
860 //! [Calculate elasticity tensor]
861 constexpr auto size_symm = (SPACE_DIM * (SPACE_DIM + 1)) / 2;
862 mat_D_ptr->resize(size_symm * size_symm, 1);
863 set_material_stiffness();
865 }
866 };
867
868 double bulk_modulus_K = young_modulus / (3 * (1 - 2 * poisson_ratio));
869 double shear_modulus_G = young_modulus / (2 * (1 + poisson_ratio));
870 pipeline.push_back(new OpMatBlocks(
871 field_name, mat_D_Ptr, bulk_modulus_K, shear_modulus_G, m_field, sev,
872
873 // Get blockset using regular expression
874 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(std::regex(
875
876 (boost::format("%s(.*)") % block_name).str()
877
878 ))
879
880 ));
881
883}
#define MOFEM_TAG_AND_LOG(channel, severity, tag)
Tag and log in channel.
Definition: LogManager.hpp:359
constexpr int SPACE_DIM
Kronecker Delta class symmetric.
double young_modulus
Definition: contact.cpp:121
double poisson_ratio
Definition: contact.cpp:122
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
Definition: definitions.h:595
#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
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
#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 double shear_modulus_G
Definition: elastic.cpp:60
constexpr double bulk_modulus_K
Definition: elastic.cpp:59
FTensor::Index< 'm', SPACE_DIM > m
constexpr auto t_kd
SeverityLevel
Severity levels.
Definition: LogManager.hpp:33
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
Definition: LogManager.hpp:284
MoFEMErrorCode getCubitMeshsetPtr(const int ms_id, const CubitBCType cubit_bc_type, const CubitMeshSets **cubit_meshset_ptr) const
get cubit meshset
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'l', 3 > l
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
constexpr AssemblyType A
double young_modulus
Definition: plastic.cpp:99
constexpr auto size_symm
Definition: plastic.cpp:33
constexpr auto field_name
virtual moab::Interface & get_moab()=0
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.
Deprecated interface functions.
Data on single entity (This is passed as argument to DataOperator::doWork)
Interface for managing meshsets containing materials and boundary conditions.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.

◆ constrain()

double ContactOps::constrain ( double  sdf,
double  tn 
)
inline
Examples
ContactOps.hpp.

Definition at line 268 of file ContactOps.hpp.

268 {
269 const auto s = sign(w(sdf, tn));
270 return (1 - s) / 2;
271}
Definition: sdf.py:1

◆ grad_surface_distance_function()

template<typename T1 , typename T2 >
FTensor::Tensor1< double, 3 > ContactOps::grad_surface_distance_function ( double  t,
FTensor::Tensor1< T1, 3 > &  t_coords,
FTensor::Tensor1< T2, SPACE_DIM > &  t_traction 
)
inline
Examples
ContactOps.hpp.

Definition at line 221 of file ContactOps.hpp.

222 {
223#ifdef PYTHON_SFD
224 if (auto sdf_ptr = sdfPythonWeakPtr.lock()) {
225 std::vector<double> grad_sdf;
227 sdf_ptr->evalGradSdf(t, t_coords(0), t_coords(1), t_coords(2),
228 t_traction(0), t_traction(1),
229 (SPACE_DIM == 3) ? t_traction(2) : 0, grad_sdf),
230 "Failed python call");
231 return FTensor::Tensor1<double, 3>{grad_sdf[0], grad_sdf[1], grad_sdf[2]};
232 }
233#endif
234 return FTensor::Tensor1<double, 3>{0., 1., 0.};
235};
#define CHK_MOAB_THROW(err, msg)
Check error code of MoAB function and throw MoFEM exception.
Definition: definitions.h:576
constexpr double t
plate stiffness
Definition: plate.cpp:59

◆ hess_surface_distance_function()

template<typename T1 , typename T2 >
FTensor::Tensor2_symmetric< double, 3 > ContactOps::hess_surface_distance_function ( double  t,
FTensor::Tensor1< T1, 3 > &  t_coords,
FTensor::Tensor1< T2, SPACE_DIM > &  t_traction 
)
inline
Examples
ContactOps.hpp.

Definition at line 239 of file ContactOps.hpp.

240 {
241#ifdef PYTHON_SFD
242 if (auto sdf_ptr = sdfPythonWeakPtr.lock()) {
243 std::vector<double> hess_sdf;
245 sdf_ptr->evalHessSdf(t, t_coords(0), t_coords(1), t_coords(2),
246 t_traction(0), t_traction(1),
247 (SPACE_DIM == 3) ? t_traction(2) : 0, hess_sdf),
248 "Failed python call");
249 return FTensor::Tensor2_symmetric<double, 3>{hess_sdf[0], hess_sdf[1],
250 hess_sdf[2], hess_sdf[3],
251 hess_sdf[4], hess_sdf[5]};
252 }
253#endif
254 return FTensor::Tensor2_symmetric<double, 3>{0., 0., 0., 0., 0., 0.};
255};

◆ sign()

double ContactOps::sign ( double  x)
inline
Examples
ContactOps.hpp.

Definition at line 257 of file ContactOps.hpp.

257 {
258 if (x == 0)
259 return 0;
260 else if (x > 0)
261 return 1;
262 else
263 return -1;
264};

◆ surface_distance_function()

template<typename T1 , typename T2 >
double ContactOps::surface_distance_function ( double  t,
FTensor::Tensor1< T1, 3 > &  t_coords,
FTensor::Tensor1< T2, SPACE_DIM > &  t_traction 
)
inline
Examples
ContactOps.hpp.

Definition at line 204 of file ContactOps.hpp.

205 {
206#ifdef PYTHON_SFD
207 if (auto sdf_ptr = sdfPythonWeakPtr.lock()) {
208 double sdf;
209 CHK_MOAB_THROW(sdf_ptr->evalSdf(t, t_coords(0), t_coords(1), t_coords(2),
210 t_traction(0), t_traction(1),
211 (SPACE_DIM == 3) ? t_traction(2) : 0, sdf),
212 "Failed python call");
213 return sdf;
214 }
215#endif
216 return t_coords(1) + 0.5;
217};

◆ w()

double ContactOps::w ( const double  sdf,
const double  tn 
)
inline
Examples
ContactOps.hpp.

Definition at line 266 of file ContactOps.hpp.

266{ return sdf - cn * tn; }
double cn
Definition: contact.cpp:124

Variable Documentation

◆ i

FTensor::Index<'i', SPACE_DIM> ContactOps::i

[Common data]

[Surface distance function from python] [Surface distance function from python]

Examples
ContactOps.hpp.

Definition at line 166 of file ContactOps.hpp.

◆ j

FTensor::Index<'j', SPACE_DIM> ContactOps::j
Examples
ContactOps.hpp.

Definition at line 167 of file ContactOps.hpp.

◆ k

FTensor::Index<'k', SPACE_DIM> ContactOps::k
Examples
ContactOps.hpp.

Definition at line 168 of file ContactOps.hpp.

◆ l

FTensor::Index<'l', SPACE_DIM> ContactOps::l
Examples
ContactOps.hpp.

Definition at line 169 of file ContactOps.hpp.