Builds the affine tet problem and assembles the diagnostic matrix.
291 {
293
294 int comm_size = 0;
295 MPI_Comm_size(PETSC_COMM_WORLD, &comm_size);
296 if (comm_size != 1) {
298 "affine_tet_stress_gram is a serial diagnostic; run with -np 1");
299 }
300
301 DMType dm_name = "DMMOFEM";
303
304 moab::Core moab_core;
305 moab::Interface &moab = moab_core;
306 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
307 if (pcomm == nullptr) {
308 pcomm = new ParallelComm(&moab, PETSC_COMM_SELF);
309 }
310
311 EntityHandle meshset;
313
316
319 meshset, 3, bit_level0);
320
322
323 PetscBool material_set;
324 CHKERR PetscOptionsHasName(
nullptr,
nullptr,
"-material", &material_set);
325 if (!material_set)
326 CHKERR PetscOptionsSetValue(
nullptr,
"-material",
"hencky");
328
329 ep.bcSpatialDispVecPtr = boost::make_shared<BcDispVec>();
330 ep.bcSpatialRotationVecPtr = boost::make_shared<BcRotVec>();
331 ep.bcSpatialTractionVecPtr = boost::make_shared<TractionBcVec>();
332 ep.bcSpatialAnalyticalTractionVecPtr =
333 boost::make_shared<AnalyticalTractionBcVec>();
334 ep.bcSpatialPressureVecPtr = boost::make_shared<PressureBcVec>();
335 ep.bcSpatialNormalDisplacementVecPtr =
336 boost::make_shared<NormalDisplacementBcVec>();
337 ep.bcSpatialAnalyticalDisplacementVecPtr =
338 boost::make_shared<AnalyticalDisplacementBcVec>();
339 ep.externalStrainVecPtr = boost::make_shared<ExternalStrainVec>();
340 ep.bcSpatialFreeTractionVecPtr = boost::make_shared<TractionFreeBc>();
341 CHKERR ep.getTractionFreeBc(meshset, ep.bcSpatialFreeTractionVecPtr,
342 "CONTACT");
343
344 CHKERR ep.resolveDissipationEntities(meshset);
345 CHKERR ep.addFields(meshset, include_bubble);
346 CHKERR ep.projectGeometry(meshset, 0.0);
347 CHKERR ep.addVolumeFiniteElement(meshset, include_bubble);
349
360
362 CHKERR VecZeroEntries(ep.solTSStep);
363
370
371 switch (matrix_type) {
375 if (include_bubble) {
378 }
379 break;
381 if (!include_bubble) {
383 "P-only diagnostic is implemented for -diag_matrix_type gram");
384 }
385 for (
const auto field_name : {ep.stretchTensor, ep.bubbleField,
386 ep.piolaStress, ep.rotAxis,
387 ep.spatialL2Disp}) {
390 }
391 break;
392 }
394
395 auto fe_lhs = boost::make_shared<VolumeElementForcesAndSourcesCore>(m_field);
396 CHKERR ep.setBaseVolumeElementOps(
adolc_tag,
false,
true,
false, fe_lhs,
397 include_bubble);
398 switch (matrix_type) {
400 if (include_bubble) {
401 CHKERR ep.pushStressGramOps(fe_lhs);
402 } else {
403 CHKERR ep.pushPiolaStressGramOps(fe_lhs);
404 }
405 break;
407 CHKERR ep.pushVolumeA00Ops(fe_lhs);
408 break;
409 }
410
416 fe_lhs->ts_u = ep.solTSStep;
417 fe_lhs->ts_u_t = ep.solTSStep;
418 fe_lhs->ts_a = 0.0;
422 CHKERR MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY);
423 CHKERR MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY);
424
427
429 rel_rank_tol, check_full_rank, view_matrix);
430
432}
static MoFEMErrorCode analyseDenseStressBlock(const MatrixDouble &dense, const DiagnosticMatrixType matrix_type, const PetscBool include_bubble, const double rel_rank_tol, const PetscBool check_full_rank, const PetscBool view_matrix)
Prints a compact rank summary for the assembled matrix.
static MoFEMErrorCode getDenseMatrix(Mat A, MatrixDouble &dense)
Copies a PETSc matrix into a dense uBLAS matrix.
static MoFEMErrorCode createAffineTet(moab::Interface &moab, EntityHandle &meshset)
Creates one unit affine tetrahedron mesh.
#define MYPCOMM_INDEX
default communicator number PCOMM
PetscErrorCode DMMoFEMSetIsPartitioned(DM dm, PetscBool is_partitioned)
PetscErrorCode DMMoFEMCreateSubDM(DM subdm, DM dm, const char problem_name[])
Must be called by user to set Sub DM MoFEM data structures.
PetscErrorCode DMMoFEMAddElement(DM dm, std::string fe_name)
add element to dm
PetscErrorCode DMMoFEMSetSquareProblem(DM dm, PetscBool square_problem)
set squared problem
PetscErrorCode DMMoFEMCreateMoFEM(DM dm, MoFEM::Interface *m_field_ptr, const char problem_name[], const MoFEM::BitRefLevel bit_level, const MoFEM::BitRefLevel bit_mask=MoFEM::BitRefLevel().set())
Must be called by user to set MoFEM data structures.
PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, const char field_name[])
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
PetscErrorCode DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
Executes FEMethod for finite elements in DM.
auto createDMVector(DM dm, RowColData rc=RowColData::COL)
Get smart vector from DM.
PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, const char field_name[])
auto createDMMatrix(DM dm)
Get smart matrix from DM.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
PetscErrorCode DMMoFEMSetDestroyProblem(DM dm, PetscBool destroy_problem)
auto createDM(MPI_Comm comm, const std::string dm_type_name)
Creates smart DM object.
constexpr auto field_name
static MoFEMErrorCode create(EshelbianCore &ep)
Select and configure the material before registering fields and DMs.
virtual MoFEMErrorCode build_adjacencies(const Range &ents, int verb=DEFAULT_VERBOSITY)=0
build adjacencies
virtual MPI_Comm & get_comm() const =0
Deprecated interface functions.
static constexpr Switches CtxSetA
Jacobian matrix switch.
static constexpr Switches CtxSetX
Solution vector switch.
static constexpr Switches CtxSetX_T
First time derivative switch.
static constexpr Switches CtxSetB
Preconditioner matrix switch.
Problem manager is used to build and partition problems.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.