v0.16.0
Loading...
Searching...
No Matches
Static Public Member Functions | Static Private Attributes | List of all members
EshelbianPlasticity::TSElasticPostStep Struct Reference

#include "users_modules/eshelbian_plasticity/src/TSElasticPostStep.hpp"

Collaboration diagram for EshelbianPlasticity::TSElasticPostStep:
[legend]

Static Public Member Functions

static MoFEMErrorCode postStepInitialise (EshelbianCore *ep_ptr)
 
static MoFEMErrorCode postStepDestroy ()
 
static MoFEMErrorCode preStepFun (TS ts)
 
static MoFEMErrorCode postStepFun (TS ts)
 

Static Private Attributes

static SmartPetscObj< KSP > prjKsp
 
static SmartPetscObj< Vec > prjD
 
static SmartPetscObj< Vec > prjF
 
static SmartPetscObj< DM > prjDM
 
static EshelbianCoreepPtr
 
static boost::shared_ptr< FEMethodpreProcRhs
 

Detailed Description

Definition at line 17 of file TSElasticPostStep.hpp.

Member Function Documentation

◆ postStepDestroy()

MoFEMErrorCode EshelbianPlasticity::TSElasticPostStep::postStepDestroy ( )
static

Definition at line 142 of file TSElasticPostStep.cpp.

142 {
144 prjKsp.reset();
145 prjD.reset();
146 prjF.reset();
147 prjDM.reset();
148 preProcRhs.reset();
150};
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
static boost::shared_ptr< FEMethod > preProcRhs

◆ postStepFun()

MoFEMErrorCode EshelbianPlasticity::TSElasticPostStep::postStepFun ( TS  ts)
static

Definition at line 248 of file TSElasticPostStep.cpp.

248 {
250
251 double time;
252 CHKERR TSGetTime(ts, &time);
253
254 MOFEM_LOG("EP", Sev::inform) << "Solve H1 post-step";
255 CHKERR VecZeroEntries(prjF);
256 CHKERR KSPSolve(prjKsp, prjF, prjD);
257 CHKERR VecGhostUpdateBegin(prjD, INSERT_VALUES, SCATTER_FORWARD);
258 CHKERR VecGhostUpdateEnd(prjD, INSERT_VALUES, SCATTER_FORWARD);
259 CHKERR DMoFEMMeshToLocalVector(prjDM, prjD, INSERT_VALUES, SCATTER_REVERSE);
260
261 // The projected H1 field now carries the accepted deformation. Reset the
262 // incremental stretch and rotation before crack calculations and TS
263 // monitors so that the accepted increment is not applied a second time.
264 Vec T;
265 CHKERR TSGetSolution(ts, &T);
266 CHKERR resetIncrementalKinematics(epPtr, T);
267
270 case GRIFFITH_FORCE:
272 MOFEM_LOG("EP", Sev::inform) << "Calculate Griffith force";
274 break;
275 default:
276 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
277 "Energy release selector not handled");
278 };
280 std::numeric_limits<double>::epsilon()) {
281 MOFEM_LOG("EP", Sev::inform) << "Calculate faces orientation";
283 }
285 }
286
287 CHKERR VecZeroEntries(epPtr->solTSStep);
288
289 PetscBool local_stop = PETSC_FALSE;
290 PetscBool global_stop = PETSC_FALSE;
294 const double area_increase =
296 if (area_increase > EshelbianCore::maxCrackExtension ||
298 MOFEM_LOG_C("EP", Sev::warning,
299 "Stopping crack growth. Area increase: %3.12e, "
300 "average Griffiths energy: %3.12e, critical Griffiths "
301 "energy: %3.12e",
302 area_increase, epPtr->avgGriffithsEnergy,
304 local_stop = PETSC_TRUE;
305 }
306 }
307
308 MPI_Bcast(&local_stop, 1, MPIU_BOOL, 0, PETSC_COMM_WORLD);
309 global_stop = local_stop;
310
311 if (global_stop) {
312 TSSetConvergedReason(ts, TS_CONVERGED_USER);
313 }
314 break;
315 default:
316 break;
317 }
318
320};
#define MOFEM_LOG_C(channel, severity, format,...)
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
#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
Definition DMMoFEM.cpp:514
#define MOFEM_LOG(channel, severity)
Log.
const FTensor::Tensor2< T, Dim, Dim > Vec
MoFEM::Interface & mField
static enum SolverType solverType
static PetscBool crackingOn
static double griffithEnergy
Griffith energy.
static double maxCrackExtension
static double crackingStartTime
MoFEMErrorCode calculateCrackArea(boost::shared_ptr< double > &area_ptr)
MoFEMErrorCode calculateOrientation(const int tag, bool set_orientation)
boost::shared_ptr< double > currentCrackAreaPtr
double avgGriffithsEnergy
MoFEMErrorCode calculateFaceMaterialForce(const int tag, TS ts, SmartPetscObj< Vec > *adjoint_gradient_vector=nullptr)
static enum EnergyReleaseSelector energyReleaseSelector
SmartPetscObj< Vec > solTSStep
virtual int get_comm_rank() const =0

◆ postStepInitialise()

MoFEMErrorCode EshelbianPlasticity::TSElasticPostStep::postStepInitialise ( EshelbianCore ep_ptr)
static

Definition at line 68 of file TSElasticPostStep.cpp.

68 {
70
71 epPtr = ep_ptr;
72
73 auto create_post_step_ksp = [&]() {
74 auto ksp = createKSP(epPtr->mField.get_comm());
75
76 auto set_up = [&]() {
79 using DomainEleOp = DomainEle::UserDataOperator;
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);
86
87 fe_lhs->getUserPolynomialBase() = boost::shared_ptr<BaseFunction>(
88 new CGGUserPolynomialBase(nullptr, true));
89 fe_rhs->getUserPolynomialBase() = boost::shared_ptr<BaseFunction>(
90 new CGGUserPolynomialBase(nullptr, true));
91 CHKERR
92 EshelbianPlasticity::AddHOOps<SPACE_DIM, SPACE_DIM, SPACE_DIM>::add(
93 fe_lhs->getOpPtrVector(), {L2}, ep_ptr->materialH1Positions,
94 ep_ptr->frontAdjEdges);
95 CHKERR
96 EshelbianPlasticity::AddHOOps<SPACE_DIM, SPACE_DIM, SPACE_DIM>::add(
97 fe_rhs->getOpPtrVector(), {L2}, ep_ptr->materialH1Positions,
98 ep_ptr->frontAdjEdges);
99
100 fe_lhs->getOpPtrVector().push_back(
101 new OpDomainMass(ep_ptr->spatialH1Disp, ep_ptr->spatialH1Disp));
102 auto w_ptr = boost::make_shared<MatrixDouble>();
103 fe_rhs->getOpPtrVector().push_back(
105 fe_rhs->getOpPtrVector().push_back(
106 new OpRhs(ep_ptr->spatialH1Disp, w_ptr));
107
109 ep_ptr->elementVolumeName, fe_lhs,
110 nullptr, nullptr);
112 ep_ptr->elementVolumeName, fe_rhs, nullptr,
113 nullptr);
114
115 // preProcRhs = boost::make_shared<FEMethod>();
116 // struct MinusOne : public ScalingMethod {
117 // double getScale(const double time) { return -time; }
118 // };
119 // preProcRhs->preProcessHook = EssentialPreProc<DisplacementCubitBcData>(
120 // ep_ptr->mField, preProcRhs, {boost::make_shared<MinusOne>()});
121
122 CHKERR KSPAppendOptionsPrefix(ksp, "prjspatial_");
123 CHKERR KSPSetFromOptions(ksp);
124 CHKERR KSPSetDM(ksp, ep_ptr->dmPrjSpatial);
125 CHKERR KSPSetUp(ksp);
127 };
128
129 CHK_THROW_MESSAGE(set_up(), "set up");
130
131 return ksp;
132 };
133
134 prjKsp = create_post_step_ksp();
137 prjDM = ep_ptr->dmPrjSpatial;
138
140};
ElementsAndOps< SPACE_DIM >::DomainEle DomainEle
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 1, FIELD_DIM > OpDomainMass
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
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
Definition DMMoFEM.cpp:627
auto createDMVector(DM dm, RowColData rc=RowColData::COL)
Get smart vector from DM.
Definition DMMoFEM.hpp:1237
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.
Definition DMMoFEM.cpp:668
@ GAUSS
Gaussian quadrature integration.
@ PETSC
Standard PETSc assembly.
auto createKSP(MPI_Comm comm)
SmartPetscObj< Vec > vectorDuplicate(Vec vec)
Create duplicate vector of smart vector.
CGG User Polynomial Base.
boost::shared_ptr< Range > frontAdjEdges
const std::string spatialL2Disp
const std::string materialH1Positions
const std::string elementVolumeName
const std::string spatialH1Disp
SmartPetscObj< DM > dmPrjSpatial
Projection spatial displacement.
virtual MPI_Comm & get_comm() const =0
Specialization for MatrixDouble vector field values calculation.

◆ preStepFun()

MoFEMErrorCode EshelbianPlasticity::TSElasticPostStep::preStepFun ( TS  ts)
static

Definition at line 152 of file TSElasticPostStep.cpp.

152 {
154 MOFEM_LOG("EP", Sev::inform) << "Pre step";
155
156 double time;
157 CHKERR TSGetTime(ts, &time);
158
160
161 auto debug_crack = [&]() {
163
164 PetscBool debug_crack_mesh = PETSC_FALSE;
165 CHKERR PetscOptionsGetBool(PETSC_NULLPTR, "", "-debug_crack_mesh",
166 &debug_crack_mesh, PETSC_NULLPTR);
167 if (debug_crack_mesh) {
168
169 auto append_meshsets_from_block = [](MoFEM::Interface &m_field,
170 const std::string &block_name,
171 const int dim,
172 std::vector<EntityHandle> &r) {
174 auto mesh_mng = m_field.getInterface<MeshsetsManager>();
175 auto bcs = mesh_mng->getCubitMeshsetPtr(
176
177 std::regex((boost::format("%s(.*)") % block_name).str())
178
179 );
180
181 for (auto bc : bcs) {
182 Range ents;
183 CHKERR m_field.get_moab().get_entities_by_dimension(
184 bc->getMeshset(), dim, ents, true);
185 if (!ents.empty()) {
186 r.push_back(bc->getMeshset());
187 }
188 }
189
191 };
192
193 if (!epPtr->mField.get_comm_rank()) {
194 if (epPtr->maxMovedFaces) {
196 ->addEntitiesToMeshset(BLOCKSET, epPtr->addCrackMeshsetId,
198 }
199
200 auto meshset_ptr = get_temp_meshset_ptr(epPtr->mField.get_moab());
201 Range tets;
202 CHKERR epPtr->mField.get_moab().get_entities_by_dimension(
203 *meshset_ptr, 3, tets);
204 CHKERR epPtr->mField.get_moab().add_entities(*meshset_ptr, tets);
205
206 std::vector<EntityHandle> meshsets;
207 meshsets.push_back(*meshset_ptr);
208
209 CHKERR append_meshsets_from_block(epPtr->mField, "CRACK", 2,
210 meshsets);
211 CHKERR append_meshsets_from_block(epPtr->mField, "FRONT", 1,
212 meshsets);
213 CHKERR append_meshsets_from_block(epPtr->mField, "EDGE", 1,
214 meshsets);
215
216 int time_step = 0;
217 CHKERR TSGetStepNumber(ts, &time_step);
218 std::string file_name =
219 "crack_meshsets_" + std::to_string(time_step) + ".h5m";
220 CHKERR epPtr->mField.get_moab().write_file(file_name.c_str(), "MOAB",
221 nullptr, meshsets.data(),
222 static_cast<int>(meshsets.size()));
223 }
224 }
225
227 };
228
231 CHKERR debug_crack();
233 }
234 CHKERR epPtr->projectGeometry(0, time);
236 }
237
238 Vec T;
239 CHKERR TSGetSolution(ts, &T);
240
241 CHKERR VecCopy(T, epPtr->solTSStep);
242 CHKERR VecGhostUpdateBegin(epPtr->solTSStep, INSERT_VALUES, SCATTER_FORWARD);
243 CHKERR VecGhostUpdateEnd(epPtr->solTSStep, INSERT_VALUES, SCATTER_FORWARD);
244
246}
@ BLOCKSET
MoFEMErrorCode getCubitMeshsetPtr(const int ms_id, const CubitBCType cubit_bc_type, const CubitMeshSets **cubit_meshset_ptr) const
get cubit meshset
PetscErrorCode PetscOptionsGetBool(PetscOptions *, const char pre[], const char name[], PetscBool *bval, PetscBool *set)
auto get_temp_meshset_ptr(moab::Interface &moab)
Create smart pointer to temporary meshset.
int r
Definition sdf.py:205
boost::shared_ptr< Range > maxMovedFaces
MoFEMErrorCode setNewFrontCoordinates()
MoFEMErrorCode projectGeometry(const EntityHandle meshset=0, double time=0)
MoFEMErrorCode projectMaterialTags(const EntityHandle meshset=0)
MoFEMErrorCode addCrackSurfaces(const bool debug=false)
static int addCrackMeshsetId
virtual moab::Interface & get_moab()=0
Deprecated interface functions.
Interface for managing meshsets containing materials and boundary conditions.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.

Member Data Documentation

◆ epPtr

EshelbianCore* EshelbianPlasticity::TSElasticPostStep::epPtr
inlinestaticprivate

Definition at line 29 of file TSElasticPostStep.hpp.

◆ preProcRhs

boost::shared_ptr<FEMethod> EshelbianPlasticity::TSElasticPostStep::preProcRhs
inlinestaticprivate

Definition at line 30 of file TSElasticPostStep.hpp.

◆ prjD

SmartPetscObj<Vec> EshelbianPlasticity::TSElasticPostStep::prjD
inlinestaticprivate

Definition at line 26 of file TSElasticPostStep.hpp.

◆ prjDM

SmartPetscObj<DM> EshelbianPlasticity::TSElasticPostStep::prjDM
inlinestaticprivate

Definition at line 28 of file TSElasticPostStep.hpp.

◆ prjF

SmartPetscObj<Vec> EshelbianPlasticity::TSElasticPostStep::prjF
inlinestaticprivate

Definition at line 27 of file TSElasticPostStep.hpp.

◆ prjKsp

SmartPetscObj<KSP> EshelbianPlasticity::TSElasticPostStep::prjKsp
inlinestaticprivate

Definition at line 25 of file TSElasticPostStep.hpp.


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