15#include <boost/math/constants/constants.hpp>
16#include <boost/math/special_functions/lambert_w.hpp>
28 auto zero_field = [&](
const std::string &
field_name) {
32 CHKERR is_mng->isCreateProblemFieldAndRankLocal(
35 CHKERR ISGetIndices(is, &index_ptr);
37 CHKERR ISGetLocalSize(is, &size);
39 CHKERR VecGetArray(solution, &array);
40 for (
int ii = 0; ii != size; ++ii) {
41 array[index_ptr[ii]] = 0;
43 CHKERR VecRestoreArray(solution, &array);
44 CHKERR ISRestoreIndices(is, &index_ptr);
55 <<
"Resetting incremental stretch and rotation after H1 transfer";
58 CHKERR VecGhostUpdateBegin(solution, INSERT_VALUES, SCATTER_FORWARD);
59 CHKERR VecGhostUpdateEnd(solution, INSERT_VALUES, SCATTER_FORWARD);
73 auto create_post_step_ksp = [&]() {
83 GAUSS>::OpBaseTimesVector<1, 3, 3>;
84 auto fe_lhs = boost::make_shared<DomainEle>(ep_ptr->
mField);
85 auto fe_rhs = boost::make_shared<DomainEle>(ep_ptr->
mField);
87 fe_lhs->getUserPolynomialBase() = boost::shared_ptr<BaseFunction>(
89 fe_rhs->getUserPolynomialBase() = boost::shared_ptr<BaseFunction>(
92 EshelbianPlasticity::AddHOOps<SPACE_DIM, SPACE_DIM, SPACE_DIM>::add(
96 EshelbianPlasticity::AddHOOps<SPACE_DIM, SPACE_DIM, SPACE_DIM>::add(
100 fe_lhs->getOpPtrVector().push_back(
102 auto w_ptr = boost::make_shared<MatrixDouble>();
103 fe_rhs->getOpPtrVector().push_back(
105 fe_rhs->getOpPtrVector().push_back(
122 CHKERR KSPAppendOptionsPrefix(ksp,
"prjspatial_");
123 CHKERR KSPSetFromOptions(ksp);
134 prjKsp = create_post_step_ksp();
154 MOFEM_LOG(
"EP", Sev::inform) <<
"Pre step";
157 CHKERR TSGetTime(ts, &time);
161 auto debug_crack = [&]() {
164 PetscBool debug_crack_mesh = PETSC_FALSE;
166 &debug_crack_mesh, PETSC_NULLPTR);
167 if (debug_crack_mesh) {
170 const std::string &block_name,
172 std::vector<EntityHandle> &r) {
177 std::regex((boost::format(
"%s(.*)") % block_name).str())
181 for (
auto bc : bcs) {
184 bc->getMeshset(), dim, ents,
true);
186 r.push_back(bc->getMeshset());
203 *meshset_ptr, 3, tets);
206 std::vector<EntityHandle> meshsets;
207 meshsets.push_back(*meshset_ptr);
217 CHKERR TSGetStepNumber(ts, &time_step);
218 std::string file_name =
219 "crack_meshsets_" + std::to_string(time_step) +
".h5m";
221 nullptr, meshsets.data(),
222 static_cast<int>(meshsets.size()));
239 CHKERR TSGetSolution(ts, &T);
252 CHKERR TSGetTime(ts, &time);
254 MOFEM_LOG(
"EP", Sev::inform) <<
"Solve H1 post-step";
257 CHKERR VecGhostUpdateBegin(
prjD, INSERT_VALUES, SCATTER_FORWARD);
258 CHKERR VecGhostUpdateEnd(
prjD, INSERT_VALUES, SCATTER_FORWARD);
265 CHKERR TSGetSolution(ts, &T);
272 MOFEM_LOG(
"EP", Sev::inform) <<
"Calculate Griffith force";
277 "Energy release selector not handled");
280 std::numeric_limits<double>::epsilon()) {
281 MOFEM_LOG(
"EP", Sev::inform) <<
"Calculate faces orientation";
289 PetscBool local_stop = PETSC_FALSE;
290 PetscBool global_stop = PETSC_FALSE;
294 const double area_increase =
299 "Stopping crack growth. Area increase: %3.12e, "
300 "average Griffiths energy: %3.12e, critical Griffiths "
304 local_stop = PETSC_TRUE;
308 MPI_Bcast(&local_stop, 1, MPIU_BOOL, 0, PETSC_COMM_WORLD);
309 global_stop = local_stop;
312 TSSetConvergedReason(ts, TS_CONVERGED_USER);
Eshelbian plasticity interface.
#define MOFEM_LOG_C(channel, severity, format,...)
ElementsAndOps< SPACE_DIM >::DomainEle DomainEle
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 1, FIELD_DIM > OpDomainMass
#define MAX_DOFS_ON_ENTITY
Maximal number of DOFs on entity.
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_DATA_INCONSISTENCY
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode, RowColData rc=RowColData::COL)
set local (or ghosted) vector values on mesh for partition only
PetscErrorCode DMMoFEMKSPSetComputeRHS(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
set KSP right hand side evaluation function
auto createDMVector(DM dm, RowColData rc=RowColData::COL)
Get smart vector from DM.
PetscErrorCode DMMoFEMKSPSetComputeOperators(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
Set KSP operators and push mofem finite element methods.
#define MOFEM_LOG(channel, severity)
Log.
MoFEMErrorCode getCubitMeshsetPtr(const int ms_id, const CubitBCType cubit_bc_type, const CubitMeshSets **cubit_meshset_ptr) const
get cubit meshset
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
auto createKSP(MPI_Comm comm)
PetscErrorCode PetscOptionsGetBool(PetscOptions *, const char pre[], const char name[], PetscBool *bval, PetscBool *set)
SmartPetscObj< Vec > vectorDuplicate(Vec vec)
Create duplicate vector of smart vector.
auto get_temp_meshset_ptr(moab::Interface &moab)
Create smart pointer to temporary meshset.
constexpr auto field_name
CGG User Polynomial Base.
boost::shared_ptr< Range > frontAdjEdges
MoFEM::Interface & mField
const std::string spatialL2Disp
static enum SolverType solverType
const std::string materialH1Positions
static PetscBool crackingOn
static double griffithEnergy
Griffith energy.
const std::string elementVolumeName
static enum RotSelector gradApproximator
boost::shared_ptr< Range > maxMovedFaces
const std::string spatialH1Disp
static double maxCrackExtension
static double crackingStartTime
MoFEMErrorCode calculateCrackArea(boost::shared_ptr< double > &area_ptr)
MoFEMErrorCode calculateOrientation(const int tag, bool set_orientation)
MoFEMErrorCode setNewFrontCoordinates()
MoFEMErrorCode projectGeometry(const EntityHandle meshset=0, double time=0)
MoFEMErrorCode projectMaterialTags(const EntityHandle meshset=0)
const std::string rotAxis
SmartPetscObj< DM > dmPrjSpatial
Projection spatial displacement.
boost::shared_ptr< double > currentCrackAreaPtr
double avgGriffithsEnergy
MoFEMErrorCode addCrackSurfaces(const bool debug=false)
MoFEMErrorCode calculateFaceMaterialForce(const int tag, TS ts, SmartPetscObj< Vec > *adjoint_gradient_vector=nullptr)
static int addCrackMeshsetId
static enum EnergyReleaseSelector energyReleaseSelector
SmartPetscObj< Vec > solTSStep
const std::string stretchTensor
static MoFEMErrorCode preStepFun(TS ts)
static SmartPetscObj< Vec > prjF
static boost::shared_ptr< FEMethod > preProcRhs
static SmartPetscObj< Vec > prjD
static SmartPetscObj< KSP > prjKsp
static MoFEMErrorCode postStepDestroy()
static MoFEMErrorCode postStepFun(TS ts)
static EshelbianCore * epPtr
static MoFEMErrorCode postStepInitialise(EshelbianCore *ep_ptr)
static SmartPetscObj< DM > prjDM
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =0
virtual int get_comm_rank() const =0
Deprecated interface functions.
Section manager is used to create indexes and sections.
Interface for managing meshsets containing materials and boundary conditions.
Specialization for MatrixDouble vector field values calculation.
intrusive_ptr for managing petsc objects
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Volume finite element base.