65 {
67
71
73
75 ->evalFEAtThePoint<DIM>(
80
81 auto process_scalar_field =
82 [](const std::string label,
83 const boost::shared_ptr<VectorDouble> scalarFieldPtr) {
84 if (scalarFieldPtr->size()) {
85 auto t_scalar_holder = getFTensor0FromVec(*scalarFieldPtr);
86
88 << "For " << label << " field, " << t_scalar_holder;
89 }
90 };
91
92 auto process_vector_field =
93 [](const std::string label,
94 const boost::shared_ptr<MatrixDouble> vecFieldPtr) {
95 if (vecFieldPtr->size1()) {
96 auto t_vec_holder = getFTensor1FromMat<DIM>(*vecFieldPtr);
97
98 std::string vec_holder_string = "";
99 for (
int i = 0;
i < DIM;
i++) {
100 vec_holder_string +=
101 " " + boost::lexical_cast<std::string>(t_vec_holder(
i));
102 }
103
105 << "For " << label << " field," << vec_holder_string;
106 }
107 };
108
109 auto process_sym_tensor_field =
110 [](const std::string label,
111 const boost::shared_ptr<MatrixDouble> symTensorFieldPtr) {
112 if (symTensorFieldPtr->size1()) {
113 auto t_sym_tensor_holder =
114 getFTensor2SymmetricFromMat<DIM>(*symTensorFieldPtr);
115
116 std::string sym_tensor_holder_string = "";
117 for (
int i = 0;
i < DIM;
i++) {
118 for (
int j =
i;
j < DIM;
j++) {
119 sym_tensor_holder_string +=
120 ", entry " + boost::lexical_cast<std::string>(
i) +
121 boost::lexical_cast<std::string>(
j) +
" = ";
122 sym_tensor_holder_string +=
123 boost::lexical_cast<std::string>(t_sym_tensor_holder(
i,
j));
124 }
125 }
126
128 << "For " << label << " field" << sym_tensor_holder_string;
129 }
130 };
131
132 auto process_tensor_field =
133 [](const std::string label,
134 const boost::shared_ptr<MatrixDouble> tensorFieldPtr) {
135 if (tensorFieldPtr->size1()) {
136 auto t_tensor_holder =
137 getFTensor2FromMat<DIM, DIM>(*tensorFieldPtr);
138
139 std::string tensor_holder_string = "";
140 for (
int i = 0;
i < DIM;
i++) {
141 for (
int j = 0;
j < DIM;
j++) {
142 tensor_holder_string +=
143 ", entry " + boost::lexical_cast<std::string>(
i) +
144 boost::lexical_cast<std::string>(
j) +
" = ";
145 tensor_holder_string +=
146 boost::lexical_cast<std::string>(t_tensor_holder(
i,
j));
147 }
148 }
149
151 << "For " << label << " field" << tensor_holder_string;
152 }
153 };
154
157 const std::string &label = pair.first;
158 const boost::shared_ptr<VectorDouble> &ptr = pair.second;
159
160 if (ptr) {
161 process_scalar_field(label, ptr);
162 }
163 }
164 }
165
168 const std::string &label = pair.first;
169 const boost::shared_ptr<MatrixDouble> &ptr = pair.second;
170
171 if (ptr) {
172 process_vector_field(label, ptr);
173 }
174 }
175 }
176
179 const std::string &label = pair.first;
180 const boost::shared_ptr<MatrixDouble> &ptr = pair.second;
181
182 if (ptr) {
183 process_sym_tensor_field(label, ptr);
184 }
185 }
186 }
187
190 const std::string &label = pair.first;
191 const boost::shared_ptr<MatrixDouble> &ptr = pair.second;
192
193 if (ptr) {
194 process_tensor_field(label, ptr);
195 }
196 }
197 }
198 }
199
201
202 auto make_vtk = [&]() {
207 "out_plastic_" + boost::lexical_cast<std::string>(ts_step) + ".h5m");
208 }
211 getCacheWeakPtr());
213 "out_skin_plastic_" + boost::lexical_cast<std::string>(ts_step) +
214 ".h5m");
215 }
217 };
218
219 auto calculate_reaction = [&]() {
221 auto pip = m_field_ptr->
getInterface<PipelineManager>();
222 if (!pip->getEvaluationFE())
223 return 0;
225 pip->getEvaluationFE()->f =
r;
227 CHKERR pip->loopFiniteElementsEvaluation();
228
229#ifndef NDEBUG
230 auto post_proc_residual = [&](auto dm, auto f_res, auto out_name) {
232 auto post_proc_fe =
233 boost::make_shared<PostProcBrokenMeshInMoab<DomainEle>>(*m_field_ptr);
234 using OpPPMap = OpPostProcMapInMoab<DIM, DIM>;
235 auto u_vec = boost::make_shared<MatrixDouble>();
236 post_proc_fe->getOpPtrVector().push_back(
237 new OpCalculateVectorFieldValues<DIM>("U", u_vec, f_res));
238 post_proc_fe->getOpPtrVector().push_back(
239
241
242 post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
243
244 {},
245
246 {{"RES", u_vec}},
247
248 {}, {})
249
250 );
251
253 post_proc_fe->writeFile("res.h5m");
255 };
256
257 CHKERR post_proc_residual(
dM, r,
"reaction");
258#endif
259
261 };
262
263 auto print_max_min = [&](auto &tuple, const std::string msg) {
265 CHKERR VecScatterBegin(std::get<1>(tuple), ts_u, std::get<0>(tuple),
266 INSERT_VALUES, SCATTER_FORWARD);
267 CHKERR VecScatterEnd(std::get<1>(tuple), ts_u, std::get<0>(tuple),
268 INSERT_VALUES, SCATTER_FORWARD);
269 double max, min;
270 CHKERR VecMax(std::get<0>(tuple), PETSC_NULLPTR, &max);
271 CHKERR VecMin(std::get<0>(tuple), PETSC_NULLPTR, &min);
272 MOFEM_LOG_C(
"PLASTICITY", Sev::inform,
"%s time %3.4e min %3.4e max %3.4e",
273 msg.c_str(), ts_t, min, max);
275 };
276
277 int se = 1;
279 if (!(ts_step % se)) {
281 }
282 CHKERR calculate_reaction();
285 if (DIM == 3)
287
289}
#define MOFEM_LOG_SEVERITY_SYNC(comm, severity)
Synchronise "SYNC" on curtain severity level.
#define MOFEM_LOG_C(channel, severity, format,...)
void simple(double P1[], double P2[], double P3[], double c[], const int N)
#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()
#define CHKERR
Inline error check.
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 DMoFEMGetInterfacePtr(DM dm, MoFEM::Interface **m_field_ptr)
Get pointer to MoFEM::Interface.
#define MOFEM_LOG(channel, severity)
Log.
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'j', 3 > j
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
virtual MPI_Comm & get_comm() const =0
virtual int get_comm_rank() const =0
Deprecated interface functions.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
PetscBool do_eval_field
Evaluate field.