68 {
70
74
76
78 ->evalFEAtThePoint<DIM>(
83
84 auto process_scalar_field =
85 [](const std::string label,
86 const boost::shared_ptr<VectorDouble> scalarFieldPtr) {
87 if (scalarFieldPtr->size()) {
88 auto t_scalar_holder = getFTensor0FromVec(*scalarFieldPtr);
89
91 << "For " << label << " field, " << t_scalar_holder;
92 }
93 };
94
95 auto process_vector_field =
96 [](const std::string label,
97 const boost::shared_ptr<MatrixDouble> vecFieldPtr) {
98 if (vecFieldPtr->size1()) {
99 auto t_vec_holder = getFTensor1FromMat<DIM>(*vecFieldPtr);
100
101 std::string vec_holder_string = "";
102 for (
int i = 0;
i < DIM;
i++) {
103 vec_holder_string +=
104 " " + boost::lexical_cast<std::string>(t_vec_holder(
i));
105 }
106
108 << "For " << label << " field," << vec_holder_string;
109 }
110 };
111
112 auto process_sym_tensor_field =
113 [](const std::string label,
114 const boost::shared_ptr<MatrixDouble> symTensorFieldPtr) {
115 if (symTensorFieldPtr->size1()) {
116 auto t_sym_tensor_holder =
117 getFTensor2SymmetricFromMat<DIM>(*symTensorFieldPtr);
118
119 std::string sym_tensor_holder_string = "";
120 for (
int i = 0;
i < DIM;
i++) {
121 for (
int j =
i;
j < DIM;
j++) {
122 sym_tensor_holder_string +=
123 ", entry " + boost::lexical_cast<std::string>(
i) +
124 boost::lexical_cast<std::string>(
j) +
" = ";
125 sym_tensor_holder_string +=
126 boost::lexical_cast<std::string>(t_sym_tensor_holder(
i,
j));
127 }
128 }
129
131 << "For " << label << " field" << sym_tensor_holder_string;
132 }
133 };
134
135 auto process_tensor_field =
136 [](const std::string label,
137 const boost::shared_ptr<MatrixDouble> tensorFieldPtr) {
138 if (tensorFieldPtr->size1()) {
139 auto t_tensor_holder =
140 getFTensor2FromMat<DIM, DIM>(*tensorFieldPtr);
141
142 std::string tensor_holder_string = "";
143 for (
int i = 0;
i < DIM;
i++) {
144 for (
int j = 0;
j < DIM;
j++) {
145 tensor_holder_string +=
146 ", entry " + boost::lexical_cast<std::string>(
i) +
147 boost::lexical_cast<std::string>(
j) +
" = ";
148 tensor_holder_string +=
149 boost::lexical_cast<std::string>(t_tensor_holder(
i,
j));
150 }
151 }
152
154 << "For " << label << " field" << tensor_holder_string;
155 }
156 };
157
158 auto process_fields = [](auto &fieldPtr, auto process_field) {
159 for (const auto &pair : fieldPtr) {
160 const std::string &label = pair.first;
161 const boost::shared_ptr<MatrixDouble> &ptr = pair.second;
162
163 if (ptr) {
164 process_field(label, ptr);
165 }
166 }
167 };
168
171 const std::string &label = pair.first;
172 const boost::shared_ptr<VectorDouble> &ptr = pair.second;
173
174 if (ptr) {
175 process_scalar_field(label, ptr);
176 }
177 }
178 }
179
182 const std::string &label = pair.first;
183 const boost::shared_ptr<MatrixDouble> &ptr = pair.second;
184
185 if (ptr) {
186 process_vector_field(label, ptr);
187 }
188 }
189 }
190
193 const std::string &label = pair.first;
194 const boost::shared_ptr<MatrixDouble> &ptr = pair.second;
195
196 if (ptr) {
197 process_sym_tensor_field(label, ptr);
198 }
199 }
200 }
201
204 const std::string &label = pair.first;
205 const boost::shared_ptr<MatrixDouble> &ptr = pair.second;
206
207 if (ptr) {
208 process_tensor_field(label, ptr);
209 }
210 }
211 }
212 }
213
215
216 auto make_vtk = [&]() {
221 "out_plastic_" + boost::lexical_cast<std::string>(ts_step) + ".h5m");
222 }
225 getCacheWeakPtr());
227 "out_skin_plastic_" + boost::lexical_cast<std::string>(ts_step) +
228 ".h5m");
229 }
231 };
232
233 auto calculate_reaction = [&]() {
239
240#ifndef NDEBUG
241 auto post_proc_residual = [&](auto dm, auto f_res, auto out_name) {
243 auto post_proc_fe =
244 boost::make_shared<PostProcBrokenMeshInMoab<DomainEle>>(*m_field_ptr);
245 using OpPPMap = OpPostProcMapInMoab<DIM, DIM>;
246 auto u_vec = boost::make_shared<MatrixDouble>();
247 post_proc_fe->getOpPtrVector().push_back(
248 new OpCalculateVectorFieldValues<DIM>("U", u_vec, f_res));
249 post_proc_fe->getOpPtrVector().push_back(
250
252
253 post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
254
255 {},
256
257 {{"RES", u_vec}},
258
259 {}, {})
260
261 );
262
264 post_proc_fe->writeFile("res.h5m");
266 };
267
268 CHKERR post_proc_residual(
dM, r,
"reaction");
269#endif
270
272 };
273
274 auto print_max_min = [&](auto &tuple, const std::string msg) {
276 CHKERR VecScatterBegin(std::get<1>(tuple), ts_u, std::get<0>(tuple),
277 INSERT_VALUES, SCATTER_FORWARD);
278 CHKERR VecScatterEnd(std::get<1>(tuple), ts_u, std::get<0>(tuple),
279 INSERT_VALUES, SCATTER_FORWARD);
280 double max, min;
281 CHKERR VecMax(std::get<0>(tuple), PETSC_NULLPTR, &max);
282 CHKERR VecMin(std::get<0>(tuple), PETSC_NULLPTR, &min);
283 MOFEM_LOG_C(
"PLASTICITY", Sev::inform,
"%s time %3.4e min %3.4e max %3.4e",
284 msg.c_str(), ts_t, min, max);
286 };
287
288 int se = 1;
290 if (!(ts_step % se)) {
292 }
294 CHKERR calculate_reaction();
297 if (DIM == 3)
299
301}
#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.