v0.13.2
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Contact Struct Reference
Collaboration diagram for Contact:
[legend]

Public Member Functions

 Contact (MoFEM::Interface &m_field)
 
MoFEMErrorCode runProblem ()
 [Run problem] More...
 

Private Member Functions

MoFEMErrorCode setupProblem ()
 [Run problem] More...
 
MoFEMErrorCode createCommonData ()
 [Set up problem] More...
 
MoFEMErrorCode bC ()
 [Create common data] More...
 
MoFEMErrorCode OPs ()
 [Boundary condition] More...
 
MoFEMErrorCode tsSolve ()
 [Push operators to pip] More...
 
MoFEMErrorCode postProcess ()
 [Solve] More...
 
MoFEMErrorCode checkResults ()
 [Postprocess results] More...
 

Private Attributes

MoFEM::InterfacemField
 
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uXScatter
 
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uYScatter
 
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uZScatter
 
boost::shared_ptr< std::vector< unsigned char > > boundaryMarker
 

Detailed Description

Definition at line 138 of file contact.cpp.

Constructor & Destructor Documentation

◆ Contact()

Contact::Contact ( MoFEM::Interface m_field)
inline

Definition at line 140 of file contact.cpp.

140: mField(m_field) {}
MoFEM::Interface & mField
Definition: contact.cpp:145

Member Function Documentation

◆ bC()

MoFEMErrorCode Contact::bC ( )
private

[Create common data]

[Boundary condition]

Definition at line 330 of file contact.cpp.

330 {
332 auto bc_mng = mField.getInterface<BcManager>();
334
335 for (auto f : {"U", "SIGMA"}) {
336 CHKERR bc_mng->removeBlockDOFsOnEntities(simple->getProblemName(),
337 "REMOVE_X", f, 0, 0);
338 CHKERR bc_mng->removeBlockDOFsOnEntities(simple->getProblemName(),
339 "REMOVE_Y", f, 1, 1);
340 CHKERR bc_mng->removeBlockDOFsOnEntities(simple->getProblemName(),
341 "REMOVE_Z", f, 2, 2);
342 CHKERR bc_mng->removeBlockDOFsOnEntities(simple->getProblemName(),
343 "REMOVE_ALL", f, 0, 3);
344 }
345
346 CHKERR bc_mng->removeBlockDOFsOnEntities(simple->getProblemName(), "FIX_X",
347 "SIGMA", 0, 0, false, true);
348 CHKERR bc_mng->removeBlockDOFsOnEntities(simple->getProblemName(), "FIX_Y",
349 "SIGMA", 1, 1, false, true);
350 CHKERR bc_mng->removeBlockDOFsOnEntities(simple->getProblemName(), "FIX_Z",
351 "SIGMA", 2, 2, false, true);
352 CHKERR bc_mng->removeBlockDOFsOnEntities(simple->getProblemName(), "FIX_ALL",
353 "SIGMA", 0, 3, false, true);
354 CHKERR bc_mng->removeBlockDOFsOnEntities(
355 simple->getProblemName(), "NO_CONTACT", "SIGMA", 0, 3, false, true);
356
357 // Note remove has to be always before push. Then node marking will be
358 // corrupted.
359 CHKERR bc_mng->pushMarkDOFsOnEntities<DisplacementCubitBcData>(
360 simple->getProblemName(), "U");
361 boundaryMarker = bc_mng->getMergedBlocksMarker(vector<string>{"FIX_", "ROTATE_"});
362
364}
void simple(double P1[], double P2[], double P3[], double c[], const int N)
Definition: acoustic.cpp:69
#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
boost::shared_ptr< std::vector< unsigned char > > boundaryMarker
Definition: contact.cpp:158
Simple interface for fast problem set-up.
Definition: BcManager.hpp:24
Definition of the displacement bc data structure.
Definition: BCData.hpp:72
Simple interface for fast problem set-up.
Definition: Simple.hpp:27
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.

◆ checkResults()

MoFEMErrorCode Contact::checkResults ( )
private

[Postprocess results]

[Check]

Definition at line 699 of file contact.cpp.

699{ return 0; }

◆ createCommonData()

MoFEMErrorCode Contact::createCommonData ( )
private

[Set up problem]

[Create common data]

Definition at line 290 of file contact.cpp.

290 {
292
293 auto get_options = [&]() {
295 CHKERR PetscOptionsGetScalar(PETSC_NULL, "", "-young_modulus",
296 &young_modulus, PETSC_NULL);
297 CHKERR PetscOptionsGetScalar(PETSC_NULL, "", "-poisson_ratio",
298 &poisson_ratio, PETSC_NULL);
299 CHKERR PetscOptionsGetScalar(PETSC_NULL, "", "-rho", &rho, PETSC_NULL);
300 CHKERR PetscOptionsGetScalar(PETSC_NULL, "", "-cn", &cn, PETSC_NULL);
301 CHKERR PetscOptionsGetScalar(PETSC_NULL, "", "-spring_stiffness",
302 &spring_stiffness, PETSC_NULL);
303 CHKERR PetscOptionsGetScalar(PETSC_NULL, "", "-alpha_dumping",
304 &alpha_dumping, PETSC_NULL);
305
306 MOFEM_LOG("CONTACT", Sev::inform) << "Young modulus " << young_modulus;
307 MOFEM_LOG("CONTACT", Sev::inform) << "Poisson_ratio " << poisson_ratio;
308 MOFEM_LOG("CONTACT", Sev::inform) << "Density " << rho;
309 MOFEM_LOG("CONTACT", Sev::inform) << "cn " << cn;
310 MOFEM_LOG("CONTACT", Sev::inform)
311 << "spring_stiffness " << spring_stiffness;
312 MOFEM_LOG("CONTACT", Sev::inform) << "alpha_dumping " << alpha_dumping;
313
315 };
316
317 CHKERR get_options();
318
319#ifdef PYTHON_SFD
320 sdfPythonPtr = boost::make_shared<SDFPython>();
321 CHKERR sdfPythonPtr->sdfInit("sdf.py");
322 sdfPythonWeakPtr = sdfPythonPtr;
323#endif
324
326}
double young_modulus
Definition: contact.cpp:121
double alpha_dumping
Definition: contact.cpp:127
double spring_stiffness
Definition: contact.cpp:125
double rho
Definition: contact.cpp:123
double poisson_ratio
Definition: contact.cpp:122
double cn
Definition: contact.cpp:124
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:308
PetscErrorCode PetscOptionsGetScalar(PetscOptions *, const char pre[], const char name[], PetscScalar *dval, PetscBool *set)

◆ OPs()

MoFEMErrorCode Contact::OPs ( )
private

[Boundary condition]

[Push operators to pip]

Definition at line 368 of file contact.cpp.

368 {
371 auto *pip_mng = mField.getInterface<PipelineManager>();
372 auto bc_mng = mField.getInterface<BcManager>();
373 auto time_scale = boost::make_shared<TimeScale>();
374
375 auto add_domain_base_ops = [&](auto &pip) {
377 "GEOMETRY"*/);
378 };
379
380 auto common_data_ptr = boost::make_shared<ContactOps::CommonData>();
381 auto henky_common_data_ptr = boost::make_shared<HenckyOps::CommonData>();
382 henky_common_data_ptr->matGradPtr = common_data_ptr->mGradPtr();
383 henky_common_data_ptr->matDPtr = common_data_ptr->mDPtr();
384
385 auto add_domain_ops_lhs = [&](auto &pip) {
386 pip.push_back(new OpSetBc("U", true, boundaryMarker));
387
388 CHKERR addMatBlockOps(mField, pip, "U", "MAT_ELASTIC",
389 common_data_ptr->mDPtr(), Sev::verbose);
390
392 "U", common_data_ptr->mGradPtr()));
393 pip.push_back(
394 new OpCalculateEigenVals<SPACE_DIM>("U", henky_common_data_ptr));
395 pip.push_back(new OpCalculateLogC<SPACE_DIM>("U", henky_common_data_ptr));
396 pip.push_back(
397 new OpCalculateLogC_dC<SPACE_DIM>("U", henky_common_data_ptr));
398 pip.push_back(
399 new OpCalculateHenckyStress<SPACE_DIM>("U", henky_common_data_ptr));
400 pip.push_back(
401 new OpCalculatePiolaStress<SPACE_DIM>("U", henky_common_data_ptr));
402 pip.push_back(new OpHenckyTangent<SPACE_DIM>("U", henky_common_data_ptr));
403 pip.push_back(
404 new OpKPiola("U", "U", henky_common_data_ptr->getMatTangent()));
405
406 if (!is_quasi_static) {
407 auto get_inertia_and_mass_dumping = [this](const double, const double,
408 const double) {
409 auto *pip_mng = mField.getInterface<PipelineManager>();
410 auto &fe_domain_lhs = pip_mng->getDomainLhsFE();
411 return rho * fe_domain_lhs->ts_aa + alpha_dumping * fe_domain_lhs->ts_a;
412 };
413 pip.push_back(new OpMass("U", "U", get_inertia_and_mass_dumping));
414 } else if (alpha_dumping > 0) {
415 auto get_mass_dumping = [this](const double, const double,
416 const double) {
417 auto *pip_mng = mField.getInterface<PipelineManager>();
418 auto &fe_domain_lhs = pip_mng->getDomainLhsFE();
419 return alpha_dumping * fe_domain_lhs->ts_a;
420 };
421 pip.push_back(new OpMass("U", "U", get_mass_dumping));
422 }
423
424 auto unity = []() { return 1; };
425 pip.push_back(new OpMixDivULhs("SIGMA", "U", unity, true));
426 pip.push_back(new OpLambdaGraULhs("SIGMA", "U", unity, true));
427
428 pip.push_back(new OpUnSetBc("U"));
429 };
430
431 auto add_domain_ops_rhs = [&](auto &pip) {
432 pip.push_back(new OpSetBc("U", true, boundaryMarker));
433
435 pip, mField, "U", {time_scale}, Sev::inform);
436
437 CHKERR addMatBlockOps(mField, pip, "U", "MAT_ELASTIC",
438 common_data_ptr->mDPtr(), Sev::inform);
440 "U", common_data_ptr->mGradPtr()));
441
442 pip.push_back(
443 new OpCalculateEigenVals<SPACE_DIM>("U", henky_common_data_ptr));
444 pip.push_back(new OpCalculateLogC<SPACE_DIM>("U", henky_common_data_ptr));
445 pip.push_back(
446 new OpCalculateLogC_dC<SPACE_DIM>("U", henky_common_data_ptr));
447 pip.push_back(
448 new OpCalculateHenckyStress<SPACE_DIM>("U", henky_common_data_ptr));
449 pip.push_back(
450 new OpCalculatePiolaStress<SPACE_DIM>("U", henky_common_data_ptr));
451 pip.push_back(new OpInternalForcePiola(
452 "U", henky_common_data_ptr->getMatFirstPiolaStress()));
453
455 "U", common_data_ptr->contactDispPtr()));
456
458 "SIGMA", common_data_ptr->contactStressPtr()));
460 "SIGMA", common_data_ptr->contactStressDivergencePtr()));
461
462 pip.push_back(new OpMixDivURhs("SIGMA", common_data_ptr->contactDispPtr(),
463 [](double, double, double) { return 1; }));
464 pip.push_back(
465 new OpMixLambdaGradURhs("SIGMA", common_data_ptr->mGradPtr()));
466
467 pip.push_back(new OpMixUTimesDivLambdaRhs(
468 "U", common_data_ptr->contactStressDivergencePtr()));
469 pip.push_back(
470 new OpMixUTimesLambdaRhs("U", common_data_ptr->contactStressPtr()));
471
472 // only in case of dynamics
473 if (!is_quasi_static) {
474 auto mat_acceleration = boost::make_shared<MatrixDouble>();
476 "U", mat_acceleration));
477 pip.push_back(new OpInertiaForce(
478 "U", mat_acceleration, [](double, double, double) { return rho; }));
479 }
480 if (alpha_dumping > 0) {
481 auto mat_velocity = boost::make_shared<MatrixDouble>();
482 pip.push_back(
483 new OpCalculateVectorFieldValuesDot<SPACE_DIM>("U", mat_velocity));
484 pip.push_back(
485 new OpInertiaForce("U", mat_velocity, [](double, double, double) {
486 return alpha_dumping;
487 }));
488 }
489 pip.push_back(new OpUnSetBc("U"));
490 };
491
492 auto add_boundary_base_ops = [&](auto &pip) {
494 "GEOMETRY"*/);
496 "U", common_data_ptr->contactDispPtr()));
498 "SIGMA", common_data_ptr->contactTractionPtr()));
499 };
500
501 auto add_boundary_ops_lhs = [&](auto &pip) {
505 mField, pip, simple->getProblemName(), "U");
506 pip.push_back(new OpSetBc("U", true, boundaryMarker));
508 pip, mField, "U", Sev::inform);
509 pip.push_back(new OpConstrainBoundaryLhs_dU("SIGMA", "U", common_data_ptr));
510 pip.push_back(new OpConstrainBoundaryLhs_dTraction("SIGMA", "SIGMA",
511 common_data_ptr));
512
513 if (spring_stiffness > 0)
514 pip.push_back(new OpSpringLhs(
515 "U", "U",
516
517 [this](double, double, double) { return spring_stiffness; }
518
519 ));
520
521 pip.push_back(new OpUnSetBc("U"));
523 };
524
525 auto add_boundary_ops_rhs = [&](auto &pip) {
527
528 auto u_mat_ptr = boost::make_shared<MatrixDouble>();
529 pip.push_back(new OpCalculateVectorFieldValues<SPACE_DIM>("U", u_mat_ptr));
532 mField, pip, simple->getProblemName(), "U", u_mat_ptr,
533 {boost::make_shared<TimeScale>()}); // note displacements have no
534 // scaling
535
536 pip.push_back(new OpSetBc("U", true, boundaryMarker));
538 pip, mField, "U", {time_scale}, Sev::inform);
539 pip.push_back(new OpConstrainBoundaryRhs("SIGMA", common_data_ptr));
540 if (spring_stiffness > 0)
541 pip.push_back(new OpSpringRhs(
542 "U", common_data_ptr->contactDispPtr(),
543 [this](double, double, double) { return spring_stiffness; }));
544 pip.push_back(new OpUnSetBc("U"));
546 };
547
548 add_domain_base_ops(pip_mng->getOpDomainLhsPipeline());
549 add_domain_base_ops(pip_mng->getOpDomainRhsPipeline());
550 add_domain_ops_lhs(pip_mng->getOpDomainLhsPipeline());
551 add_domain_ops_rhs(pip_mng->getOpDomainRhsPipeline());
552
553 add_boundary_base_ops(pip_mng->getOpBoundaryLhsPipeline());
554 add_boundary_base_ops(pip_mng->getOpBoundaryRhsPipeline());
555 CHKERR add_boundary_ops_lhs(pip_mng->getOpBoundaryLhsPipeline());
556 CHKERR add_boundary_ops_rhs(pip_mng->getOpBoundaryRhsPipeline());
557
558 auto integration_rule_vol = [](int, int, int approx_order) {
559 return 2 * approx_order + geom_order - 1;
560 };
561 CHKERR pip_mng->setDomainRhsIntegrationRule(integration_rule_vol);
562 CHKERR pip_mng->setDomainLhsIntegrationRule(integration_rule_vol);
563 auto integration_rule_boundary = [](int, int, int approx_order) {
564 return 2 * approx_order + geom_order - 1;
565 };
566 CHKERR pip_mng->setBoundaryRhsIntegrationRule(integration_rule_boundary);
567 CHKERR pip_mng->setBoundaryLhsIntegrationRule(integration_rule_boundary);
568
570}
FormsIntegrators< DomainEleOp >::Assembly< A >::LinearForm< GAUSS >::OpMixDivTimesU< 3, SPACE_DIM, SPACE_DIM > OpMixDivURhs
Definition: contact.cpp:62
FormsIntegrators< BoundaryEleOp >::Assembly< PETSC >::LinearForm< I >::OpBaseTimesVector< 1, SPACE_DIM, 1 > OpSpringRhs
Definition: contact.cpp:72
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< I >::OpMixDivTimesVec< SPACE_DIM > OpMixDivULhs
[Operators used for contact]
Definition: contact.cpp:58
constexpr int geom_order
Definition: contact.cpp:118
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< I >::OpGradTimesTensor< 1, SPACE_DIM, SPACE_DIM > OpInternalForcePiola
Definition: contact.cpp:93
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< I >::OpMixTensorTimesGradU< SPACE_DIM > OpMixLambdaGradURhs
Definition: contact.cpp:64
FormsIntegrators< DomainEleOp >::Assembly< A >::BiLinearForm< GAUSS >::OpMass< 1, SPACE_DIM > OpMass
[Operators used for contact]
Definition: contact.cpp:77
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< I >::OpMixTensorTimesGrad< SPACE_DIM > OpLambdaGraULhs
Definition: contact.cpp:60
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< I >::OpGradTimesTensor< 1, SPACE_DIM, SPACE_DIM > OpMixUTimesLambdaRhs
Definition: contact.cpp:68
FormsIntegrators< DomainEleOp >::Assembly< A >::BiLinearForm< GAUSS >::OpGradTensorGrad< 1, SPACE_DIM, SPACE_DIM, 1 > OpKPiola
[Essential boundary conditions]
Definition: contact.cpp:91
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< I >::OpMixVecTimesDivLambda< SPACE_DIM > OpMixUTimesDivLambdaRhs
Definition: contact.cpp:66
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< I >::OpBaseTimesVector< 1, SPACE_DIM, 1 > OpInertiaForce
Definition: contact.cpp:79
FormsIntegrators< BoundaryEleOp >::Assembly< PETSC >::BiLinearForm< I >::OpMass< 1, SPACE_DIM > OpSpringLhs
Definition: contact.cpp:70
constexpr bool is_quasi_static
Definition: contact.cpp:115
@ H1
continuous field
Definition: definitions.h:85
@ HDIV
field with continuous normal traction
Definition: definitions.h:87
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)
Definition: contact.cpp:760
static constexpr int approx_order
Add operators pushing bases from local to physical configuration.
Essential boundary conditions.
Definition: Essential.hpp:101
Calculate divergence of tonsorial field using vectorial base.
Calculate tenor field using vectorial base, i.e. Hdiv/Hcurl.
Calculate trace of vector (Hdiv/Hcurl) space.
Get field gradients at integration pts for scalar filed rank 0, i.e. vector field.
Approximate field values for given petsc vector.
Get values at integration pts for tensor filed rank 1, i.e. vector field.
Set indices on entities on finite element.
PipelineManager interface.

◆ postProcess()

MoFEMErrorCode Contact::postProcess ( )
private

[Solve]

[Postprocess results]

Definition at line 695 of file contact.cpp.

695{ return 0; }

◆ runProblem()

MoFEMErrorCode Contact::runProblem ( )

[Run problem]

Definition at line 166 of file contact.cpp.

166 {
170 CHKERR bC();
171 CHKERR OPs();
172 CHKERR tsSolve();
176}
MoFEMErrorCode tsSolve()
[Push operators to pip]
Definition: contact.cpp:574
MoFEMErrorCode setupProblem()
[Run problem]
Definition: contact.cpp:180
MoFEMErrorCode OPs()
[Boundary condition]
Definition: contact.cpp:368
MoFEMErrorCode createCommonData()
[Set up problem]
Definition: contact.cpp:290
MoFEMErrorCode postProcess()
[Solve]
Definition: contact.cpp:695
MoFEMErrorCode checkResults()
[Postprocess results]
Definition: contact.cpp:699
MoFEMErrorCode bC()
[Create common data]
Definition: contact.cpp:330

◆ setupProblem()

MoFEMErrorCode Contact::setupProblem ( )
private

[Run problem]

[Set up problem]

Definition at line 180 of file contact.cpp.

180 {
183
184 CHKERR PetscOptionsGetInt(PETSC_NULL, "", "-order", &order, PETSC_NULL);
185 // CHKERR PetscOptionsGetInt(PETSC_NULL, "", "-geom_order", &geom_order,
186 // PETSC_NULL);
187 MOFEM_LOG("CONTACT", Sev::inform) << "Order " << order;
188 MOFEM_LOG("CONTACT", Sev::inform) << "Geom order " << geom_order;
189
190 // Select base
191 enum bases { AINSWORTH, DEMKOWICZ, LASBASETOPT };
192 const char *list_bases[LASBASETOPT] = {"ainsworth", "demkowicz"};
193 PetscInt choice_base_value = AINSWORTH;
194 CHKERR PetscOptionsGetEList(PETSC_NULL, NULL, "-base", list_bases,
195 LASBASETOPT, &choice_base_value, PETSC_NULL);
196
198 switch (choice_base_value) {
199 case AINSWORTH:
201 MOFEM_LOG("CONTACT", Sev::inform)
202 << "Set AINSWORTH_LEGENDRE_BASE for displacements";
203 break;
204 case DEMKOWICZ:
206 MOFEM_LOG("CONTACT", Sev::inform)
207 << "Set DEMKOWICZ_JACOBI_BASE for displacements";
208 break;
209 default:
210 base = LASTBASE;
211 break;
212 }
213
214 // Note: For tets we have only H1 Ainsworth base, for Hex we have only H1
215 // Demkowicz base. We need to implement Demkowicz H1 base on tet.
216 CHKERR simple->addDomainField("U", H1, base, SPACE_DIM);
217 CHKERR simple->addBoundaryField("U", H1, base, SPACE_DIM);
218 CHKERR simple->addDomainField("SIGMA", CONTACT_SPACE, DEMKOWICZ_JACOBI_BASE,
219 SPACE_DIM);
220 CHKERR simple->addBoundaryField("SIGMA", CONTACT_SPACE, DEMKOWICZ_JACOBI_BASE,
221 SPACE_DIM);
222 // CHKERR simple->addDataField("GEOMETRY", H1, base, SPACE_DIM);
223
224
225 CHKERR simple->setFieldOrder("U", order);
226 // CHKERR simple->setFieldOrder("SIGMA", 0);
227 // CHKERR simple->setFieldOrder("GEOMETRY", geom_order);
228
229 auto get_skin = [&]() {
230 Range body_ents;
231 CHKERR mField.get_moab().get_entities_by_dimension(0, SPACE_DIM, body_ents);
232 Skinner skin(&mField.get_moab());
233 Range skin_ents;
234 CHKERR skin.find_skin(0, body_ents, false, skin_ents);
235 return skin_ents;
236 };
237
238 auto filter_blocks = [&](auto skin) {
239 Range contact_range;
240 for (auto m :
242
243 (boost::format("%s(.*)") % "CONTACT").str()
244
245 ))
246
247 ) {
248 MOFEM_LOG("CONTACT", Sev::inform)
249 << "Find contact block set: " << m->getName();
250 auto meshset = m->getMeshset();
251 CHKERR mField.get_moab().get_entities_by_dimension(meshset, SPACE_DIM - 1,
252 contact_range, true);
253
254 MOFEM_LOG("SYNC", Sev::inform)
255 << "Nb entities in contact surface: " << contact_range.size();
257 CHKERR mField.getInterface<CommInterface>()->synchroniseEntities(
258 contact_range);
259 skin = intersect(skin, contact_range);
260 }
261 return skin;
262 };
263
264 auto filter_true_skin = [&](auto skin) {
265 Range boundary_ents;
266 ParallelComm *pcomm =
267 ParallelComm::get_pcomm(&mField.get_moab(), MYPCOMM_INDEX);
268 CHKERR pcomm->filter_pstatus(skin, PSTATUS_SHARED | PSTATUS_MULTISHARED,
269 PSTATUS_NOT, -1, &boundary_ents);
270 return boundary_ents;
271 };
272
273 auto boundary_ents = filter_true_skin(filter_blocks(get_skin()));
274 CHKERR simple->setFieldOrder("SIGMA", 0);
275 CHKERR simple->setFieldOrder("SIGMA", order - 1, &boundary_ents);
276
277 CHKERR simple->setUp();
278
279 // auto project_ho_geometry = [&]() {
280 // Projection10NodeCoordsOnField ent_method(mField, "GEOMETRY");
281 // return mField.loop_dofs("GEOMETRY", ent_method);
282 // };
283 // CHKERR project_ho_geometry();
284
286}
#define MOFEM_LOG_SYNCHRONISE(comm)
Synchronise "SYNC" channel.
Definition: LogManager.hpp:345
constexpr int SPACE_DIM
Definition: contact.cpp:42
int order
Definition: contact.cpp:117
constexpr FieldSpace CONTACT_SPACE
Definition: contact.cpp:54
FieldApproximationBase
approximation base
Definition: definitions.h:58
@ LASTBASE
Definition: definitions.h:69
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
Definition: definitions.h:60
@ DEMKOWICZ_JACOBI_BASE
Definition: definitions.h:66
#define MYPCOMM_INDEX
default communicator number PCOMM
Definition: definitions.h:215
FTensor::Index< 'm', SPACE_DIM > m
MoFEMErrorCode getCubitMeshsetPtr(const int ms_id, const CubitBCType cubit_bc_type, const CubitMeshSets **cubit_meshset_ptr) const
get cubit meshset
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
PetscErrorCode PetscOptionsGetEList(PetscOptions *, const char pre[], const char name[], const char *const *list, PetscInt next, PetscInt *value, PetscBool *set)
Managing BitRefLevels.
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =0
Interface for managing meshsets containing materials and boundary conditions.

◆ tsSolve()

MoFEMErrorCode Contact::tsSolve ( )
private

[Push operators to pip]

[Solve]

Definition at line 574 of file contact.cpp.

574 {
576
579 ISManager *is_manager = mField.getInterface<ISManager>();
580
581 auto set_section_monitor = [&](auto solver) {
583 SNES snes;
584 CHKERR TSGetSNES(solver, &snes);
585 PetscViewerAndFormat *vf;
586 CHKERR PetscViewerAndFormatCreate(PETSC_VIEWER_STDOUT_WORLD,
587 PETSC_VIEWER_DEFAULT, &vf);
588 CHKERR SNESMonitorSet(
589 snes,
590 (MoFEMErrorCode(*)(SNES, PetscInt, PetscReal, void *))SNESMonitorFields,
591 vf, (MoFEMErrorCode(*)(void **))PetscViewerAndFormatDestroy);
593 };
594
595 auto scatter_create = [&](auto D, auto coeff) {
597 CHKERR is_manager->isCreateProblemFieldAndRank(simple->getProblemName(),
598 ROW, "U", coeff, coeff, is);
599 int loc_size;
600 CHKERR ISGetLocalSize(is, &loc_size);
601 Vec v;
602 CHKERR VecCreateMPI(mField.get_comm(), loc_size, PETSC_DETERMINE, &v);
603 VecScatter scatter;
604 CHKERR VecScatterCreate(D, is, v, PETSC_NULL, &scatter);
605 return std::make_tuple(SmartPetscObj<Vec>(v),
607 };
608
609 auto set_time_monitor = [&](auto dm, auto solver) {
611 boost::shared_ptr<Monitor> monitor_ptr(
613 boost::shared_ptr<ForcesAndSourcesCore> null;
614 CHKERR DMMoFEMTSSetMonitor(dm, solver, simple->getDomainFEName(),
615 monitor_ptr, null, null);
617 };
618
619 auto set_fieldsplit_preconditioner = [&](auto solver) {
621
622 SNES snes;
623 CHKERR TSGetSNES(solver, &snes);
624 KSP ksp;
625 CHKERR SNESGetKSP(snes, &ksp);
626 PC pc;
627 CHKERR KSPGetPC(ksp, &pc);
628 PetscBool is_pcfs = PETSC_FALSE;
629 PetscObjectTypeCompare((PetscObject)pc, PCFIELDSPLIT, &is_pcfs);
630
631 // Setup fieldsplit (block) solver - optional: yes/no
632 if (is_pcfs == PETSC_TRUE) {
633 auto bc_mng = mField.getInterface<BcManager>();
634 auto name_prb = simple->getProblemName();
635 auto is_all_bc = bc_mng->getBlockIS(name_prb, "FIX_X", "U", 0, 0);
636 is_all_bc = bc_mng->getBlockIS(name_prb, "FIX_Y", "U", 1, 1, is_all_bc);
637 is_all_bc = bc_mng->getBlockIS(name_prb, "FIX_Z", "U", 2, 2, is_all_bc);
638 is_all_bc = bc_mng->getBlockIS(name_prb, "FIX_ALL", "U", 0, 2, is_all_bc);
639 int is_all_bc_size;
640 CHKERR ISGetSize(is_all_bc, &is_all_bc_size);
641 MOFEM_LOG("CONTACT", Sev::inform)
642 << "Field split block size " << is_all_bc_size;
643 CHKERR PCFieldSplitSetIS(pc, PETSC_NULL,
644 is_all_bc); // boundary block
645 }
646
648 };
649
650 auto dm = simple->getDM();
651 auto D = createDMVector(dm);
652
654
655 uXScatter = scatter_create(D, 0);
656 uYScatter = scatter_create(D, 1);
657 if (SPACE_DIM == 3)
658 uZScatter = scatter_create(D, 2);
659
660 if (is_quasi_static) {
661 auto solver = pip_mng->createTSIM();
662 auto D = createDMVector(dm);
663 CHKERR set_section_monitor(solver);
664 CHKERR set_time_monitor(dm, solver);
665 CHKERR TSSetSolution(solver, D);
666 CHKERR TSSetFromOptions(solver);
667 CHKERR set_fieldsplit_preconditioner(solver);
668 CHKERR TSSetUp(solver);
669 CHKERR TSSolve(solver, NULL);
670 } else {
671 auto solver = pip_mng->createTSIM2();
672 auto dm = simple->getDM();
673 auto D = createDMVector(dm);
674 auto DD = vectorDuplicate(D);
675 CHKERR set_section_monitor(solver);
676 CHKERR set_time_monitor(dm, solver);
677 CHKERR TS2SetSolution(solver, D, DD);
678 CHKERR TSSetFromOptions(solver);
679 CHKERR set_fieldsplit_preconditioner(solver);
680 CHKERR TSSetUp(solver);
681 CHKERR TSSolve(solver, NULL);
682 }
683
685
686 CHKERR VecGhostUpdateBegin(D, INSERT_VALUES, SCATTER_FORWARD);
687 CHKERR VecGhostUpdateEnd(D, INSERT_VALUES, SCATTER_FORWARD);
688 CHKERR DMoFEMMeshToLocalVector(dm, D, INSERT_VALUES, SCATTER_REVERSE);
689
691}
@ ROW
Definition: definitions.h:123
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
set local (or ghosted) vector values on mesh for partition only
Definition: DMMoFEM.cpp:509
auto createDMVector(DM dm)
Get smart vector from DM.
Definition: DMMoFEM.hpp:1003
double D
const double v
phase velocity of light in medium (cm/ns)
const FTensor::Tensor2< T, Dim, Dim > Vec
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
PetscErrorCode DMMoFEMTSSetMonitor(DM dm, TS ts, const std::string fe_name, boost::shared_ptr< MoFEM::FEMethod > method, boost::shared_ptr< MoFEM::BasicMethod > pre_only, boost::shared_ptr< MoFEM::BasicMethod > post_only)
Set Monitor To TS solver.
Definition: DMMoFEM.cpp:1042
SmartPetscObj< Vec > vectorDuplicate(Vec vec)
Create duplicate vector of smart vector.
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uYScatter
Definition: contact.cpp:156
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uXScatter
Definition: contact.cpp:155
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uZScatter
Definition: contact.cpp:157
static SmartPetscObj< Vec > totalTraction
Definition: ContactOps.hpp:21
static auto createTotalTraction(MoFEM::Interface &m_field)
Definition: ContactOps.hpp:23
Section manager is used to create indexes and sections.
Definition: ISManager.hpp:23
intrusive_ptr for managing petsc objects

Member Data Documentation

◆ boundaryMarker

boost::shared_ptr<std::vector<unsigned char> > Contact::boundaryMarker
private

Definition at line 158 of file contact.cpp.

◆ mField

MoFEM::Interface& Contact::mField
private

Definition at line 145 of file contact.cpp.

◆ uXScatter

std::tuple<SmartPetscObj<Vec>, SmartPetscObj<VecScatter> > Contact::uXScatter
private

Definition at line 155 of file contact.cpp.

◆ uYScatter

std::tuple<SmartPetscObj<Vec>, SmartPetscObj<VecScatter> > Contact::uYScatter
private

Definition at line 156 of file contact.cpp.

◆ uZScatter

std::tuple<SmartPetscObj<Vec>, SmartPetscObj<VecScatter> > Contact::uZScatter
private

Definition at line 157 of file contact.cpp.


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