v0.14.0
Public Member Functions | Public Attributes | List of all members
SimpleContactProblem::OpMakeVtkSlave Struct Reference

Operator for the simple contact element. More...

#include <users_modules/mortar_contact/src/SimpleContact.hpp>

Inheritance diagram for SimpleContactProblem::OpMakeVtkSlave:
[legend]
Collaboration diagram for SimpleContactProblem::OpMakeVtkSlave:
[legend]

Public Member Functions

 OpMakeVtkSlave (MoFEM::Interface &m_field, string field_name, boost::shared_ptr< CommonDataSimpleContact > common_data, moab::Interface &moab_out, StateTagSide state_tag_side=NO_TAG, Range post_proc_surface=Range())
 
MoFEMErrorCode doWork (int side, EntityType type, EntData &data)
 

Public Attributes

MoFEM::InterfacemField
 
boost::shared_ptr< CommonDataSimpleContactcommonDataSimpleContact
 
moab::Interface & moabOut
 
StateTagSide stateTagSide
 
Range postProcSurface
 

Detailed Description

Operator for the simple contact element.

Prints to .vtk file pre-calculated gaps, Lagrange multipliers and their product the gauss points on the slave triangle.

Definition at line 2186 of file SimpleContact.hpp.

Constructor & Destructor Documentation

◆ OpMakeVtkSlave()

SimpleContactProblem::OpMakeVtkSlave::OpMakeVtkSlave ( MoFEM::Interface m_field,
string  field_name,
boost::shared_ptr< CommonDataSimpleContact common_data,
moab::Interface &  moab_out,
StateTagSide  state_tag_side = NO_TAG,
Range  post_proc_surface = Range() 
)
inline

Definition at line 2194 of file SimpleContact.hpp.

2199  : ContactOp(field_name, UserDataOperator::OPROW, ContactOp::FACESLAVE),
2200  mField(m_field), commonDataSimpleContact(common_data),
2201  moabOut(moab_out), stateTagSide(state_tag_side),
2202  postProcSurface(post_proc_surface) {}

Member Function Documentation

◆ doWork()

MoFEMErrorCode SimpleContactProblem::OpMakeVtkSlave::doWork ( int  side,
EntityType  type,
EntData data 
)

Definition at line 2197 of file SimpleContact.cpp.

2199  {
2201 
2202  if (type != MBVERTEX)
2204 
2205  const EntityHandle prism_ent = getFEEntityHandle();
2206  EntityHandle tri_ent;
2207  if (stateTagSide == MASTER_SIDE) {
2208  CHKERR mField.get_moab().side_element(prism_ent, 2, 3, tri_ent);
2209  }
2210  if (stateTagSide == SLAVE_SIDE) {
2211  CHKERR mField.get_moab().side_element(prism_ent, 2, 4, tri_ent);
2212  }
2213 
2214  int nb_dofs = data.getFieldData().size();
2215  if (nb_dofs == 0)
2217  int nb_gauss_pts = data.getN().size1();
2218 
2219  double def_val = 0.;
2220 
2221  Tag th_gap;
2222  CHKERR moabOut.tag_get_handle("GAP", 1, MB_TYPE_DOUBLE, th_gap,
2223  MB_TAG_CREAT | MB_TAG_SPARSE, &def_val);
2224 
2225  Tag th_lag_mult;
2226  CHKERR moabOut.tag_get_handle("LAGMULT", 1, MB_TYPE_DOUBLE, th_lag_mult,
2227  MB_TAG_CREAT | MB_TAG_SPARSE, &def_val);
2228 
2229  Tag th_lag_gap_prod;
2230  CHKERR moabOut.tag_get_handle("LAG_GAP_PROD", 1, MB_TYPE_DOUBLE,
2231  th_lag_gap_prod, MB_TAG_CREAT | MB_TAG_SPARSE,
2232  &def_val);
2233 
2234  int def_val_int = 0;
2235 
2236  Tag th_state;
2237  CHKERR moabOut.tag_get_handle("STATE", 1, MB_TYPE_INTEGER, th_state,
2238  MB_TAG_CREAT | MB_TAG_SPARSE, &def_val_int);
2239 
2240  Tag th_state_side;
2241  if (stateTagSide > 0) {
2242  CHKERR mField.get_moab().tag_get_handle(
2243  "STATE", 1, MB_TYPE_INTEGER, th_state_side,
2244  MB_TAG_CREAT | MB_TAG_SPARSE, &def_val_int);
2245  }
2246 
2247  auto get_tag_pos = [&](const std::string name) {
2248  Tag th;
2249  constexpr std::array<double, 3> def_vals = {0, 0, 0};
2250  CHKERR moabOut.tag_get_handle(name.c_str(), 3, MB_TYPE_DOUBLE, th,
2251  MB_TAG_CREAT | MB_TAG_SPARSE,
2252  def_vals.data());
2253  return th;
2254  };
2255  auto th_pos_master = get_tag_pos("MASTER_SPATIAL_POSITION");
2256  auto th_pos_slave = get_tag_pos("SLAVE_SPATIAL_POSITION");
2257  auto th_master_coords = get_tag_pos("MASTER_GAUSS_PTS_COORDS");
2258 
2259  // FIXME: why getFEEntityHandle ?
2260  EntityHandle new_vertex = getFEEntityHandle();
2261 
2262  auto t_gap_ptr = getFTensor0FromVec(*commonDataSimpleContact->gapPtr);
2263 
2264  auto t_lagrange_slave =
2265  getFTensor0FromVec(*commonDataSimpleContact->lagMultAtGaussPtsPtr);
2266  auto t_lag_gap_prod_slave =
2268  auto t_position_master = getFTensor1FromMat<3>(
2269  *commonDataSimpleContact->positionAtGaussPtsMasterPtr);
2270  auto t_position_slave = getFTensor1FromMat<3>(
2271  *commonDataSimpleContact->positionAtGaussPtsSlavePtr);
2272 
2273  auto get_ftensor_coords_at_gauss_pts_slave = [&](auto &coords_at_gauss_pts) {
2274  auto ptr = &*coords_at_gauss_pts.data().begin();
2275  return FTensor::Tensor1<FTensor::PackPtr<double *, 3>, 3>(&ptr[0], &ptr[1],
2276  &ptr[2]);
2277  };
2278  auto t_coords_at_gauss_pts_slave =
2279  get_ftensor_coords_at_gauss_pts_slave(getCoordsAtGaussPtsSlave());
2280  auto t_coords_at_gauss_pts_master =
2281  get_ftensor_coords_at_gauss_pts_slave(getCoordsAtGaussPtsMaster());
2282 
2283  auto t_state_ptr =
2284  getFTensor0FromVec(*commonDataSimpleContact->gaussPtsStatePtr);
2285 
2286  auto set_float_precision = [](const double x) {
2287  if (std::abs(x) < std::numeric_limits<float>::epsilon())
2288  return 0.;
2289  else
2290  return x;
2291  };
2292 
2293  std::array<double, 3> pos_vec;
2294 
2295  auto get_vec_ptr = [&](auto t) {
2296  for (int dd = 0; dd != 3; ++dd)
2297  pos_vec[dd] = set_float_precision(t(dd));
2298  return pos_vec.data();
2299  };
2300 
2301  int count_active_pts = 0;
2302 
2303  for (int gg = 0; gg != nb_gauss_pts; ++gg) {
2304 
2305  int state = 0;
2306  if (t_state_ptr > 0.5) {
2307  state = 1;
2308  ++count_active_pts;
2309  }
2310 
2311  bool output_at_gauss_pts = true;
2312  if (!postProcSurface.empty()) {
2313  Range tri_ents;
2314  CHKERR mField.get_moab().get_adjacencies(
2315  &prism_ent, 1, 2, false, tri_ents, moab::Interface::UNION);
2316  tri_ents = tri_ents.subset_by_type(MBTRI);
2317  if (intersect(postProcSurface, tri_ents).empty())
2318  output_at_gauss_pts = false;
2319  }
2320 
2321  if (output_at_gauss_pts) {
2322  CHKERR moabOut.create_vertex(get_vec_ptr(t_coords_at_gauss_pts_slave),
2323  new_vertex);
2324 
2325  double gap_vtk = set_float_precision(t_gap_ptr);
2326  CHKERR moabOut.tag_set_data(th_gap, &new_vertex, 1, &gap_vtk);
2327 
2328  double lag_gap_prod_vtk = set_float_precision(t_lag_gap_prod_slave);
2329  CHKERR moabOut.tag_set_data(th_lag_gap_prod, &new_vertex, 1,
2330  &lag_gap_prod_vtk);
2331 
2332  double lagrange_slave_vtk = set_float_precision(t_lagrange_slave);
2333  CHKERR moabOut.tag_set_data(th_lag_mult, &new_vertex, 1,
2334  &lagrange_slave_vtk);
2335 
2336  CHKERR moabOut.tag_set_data(th_state, &new_vertex, 1, &state);
2337 
2338  CHKERR moabOut.tag_set_data(th_pos_master, &new_vertex, 1,
2339  get_vec_ptr(t_position_master));
2340  CHKERR moabOut.tag_set_data(th_pos_slave, &new_vertex, 1,
2341  get_vec_ptr(t_position_slave));
2342 
2343  CHKERR moabOut.tag_set_data(th_master_coords, &new_vertex, 1,
2344  get_vec_ptr(t_coords_at_gauss_pts_master));
2345  }
2346 
2347  ++t_gap_ptr;
2348  ++t_lagrange_slave;
2349  ++t_lag_gap_prod_slave;
2350  ++t_position_master;
2351  ++t_position_slave;
2352  ++t_coords_at_gauss_pts_slave;
2353  ++t_coords_at_gauss_pts_master;
2354  ++t_state_ptr;
2355  }
2356 
2357  if (stateTagSide > 0) {
2358  int state_side = 0;
2359  if (count_active_pts >= nb_gauss_pts / 2) {
2360  state_side = 1;
2361  }
2362  CHKERR mField.get_moab().tag_set_data(th_state_side, &tri_ent, 1,
2363  &state_side);
2364  }
2365 
2367 }

Member Data Documentation

◆ commonDataSimpleContact

boost::shared_ptr<CommonDataSimpleContact> SimpleContactProblem::OpMakeVtkSlave::commonDataSimpleContact

Definition at line 2189 of file SimpleContact.hpp.

◆ mField

MoFEM::Interface& SimpleContactProblem::OpMakeVtkSlave::mField

Definition at line 2188 of file SimpleContact.hpp.

◆ moabOut

moab::Interface& SimpleContactProblem::OpMakeVtkSlave::moabOut

Definition at line 2190 of file SimpleContact.hpp.

◆ postProcSurface

Range SimpleContactProblem::OpMakeVtkSlave::postProcSurface

Definition at line 2192 of file SimpleContact.hpp.

◆ stateTagSide

StateTagSide SimpleContactProblem::OpMakeVtkSlave::stateTagSide

Definition at line 2191 of file SimpleContact.hpp.


The documentation for this struct was generated from the following files:
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:460
FTensor::Tensor1
Definition: Tensor1_value.hpp:8
EntityHandle
MoFEM::th
Tag th
Definition: Projection10NodeCoordsOnField.cpp:122
MoFEM::EntitiesFieldData::EntData::getFieldData
const VectorDouble & getFieldData() const
get dofs values
Definition: EntitiesFieldData.hpp:1254
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
SimpleContactProblem::OpMakeVtkSlave::postProcSurface
Range postProcSurface
Definition: SimpleContact.hpp:2192
MoFEM::CoreInterface::get_moab
virtual moab::Interface & get_moab()=0
convert.type
type
Definition: convert.py:64
MoFEM::getFTensor0FromVec
static auto getFTensor0FromVec(ublas::vector< T, A > &data)
Get tensor rank 0 (scalar) form data vector.
Definition: Templates.hpp:135
SimpleContactProblem::OpMakeVtkSlave::commonDataSimpleContact
boost::shared_ptr< CommonDataSimpleContact > commonDataSimpleContact
Definition: SimpleContact.hpp:2189
SimpleContactProblem::OpMakeVtkSlave::moabOut
moab::Interface & moabOut
Definition: SimpleContact.hpp:2190
t
constexpr double t
plate stiffness
Definition: plate.cpp:58
field_name
constexpr auto field_name
Definition: poisson_2d_homogeneous.cpp:13
SimpleContactProblem::OpMakeVtkSlave::stateTagSide
StateTagSide stateTagSide
Definition: SimpleContact.hpp:2191
Range
FTensor::dd
const Tensor2_symmetric_Expr< const ddTensor0< T, Dim, i, j >, typename promote< T, double >::V, Dim, i, j > dd(const Tensor0< T * > &a, const Index< i, Dim > index1, const Index< j, Dim > index2, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
Definition: ddTensor0.hpp:33
SimpleContactProblem::ContactOp
ContactPrismElementForcesAndSourcesCore::UserDataOperator ContactOp
Definition: SimpleContact.hpp:30
MoFEM::EntitiesFieldData::EntData::getN
MatrixDouble & getN(const FieldApproximationBase base)
get base functions this return matrix (nb. of rows is equal to nb. of Gauss pts, nb....
Definition: EntitiesFieldData.hpp:1318
SimpleContactProblem::SLAVE_SIDE
@ SLAVE_SIDE
Definition: SimpleContact.hpp:2177
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
SimpleContactProblem::MASTER_SIDE
@ MASTER_SIDE
Definition: SimpleContact.hpp:2177
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359
MoFEM::ForcesAndSourcesCore::UserDataOperator::OPROW
@ OPROW
operator doWork function is executed on FE rows
Definition: ForcesAndSourcesCore.hpp:567
SimpleContactProblem::OpMakeVtkSlave::mField
MoFEM::Interface & mField
Definition: SimpleContact.hpp:2188