72 CHKERR DMoFEMGetInterfacePtr(dM, &m_field_ptr);
78 ->evalFEAtThePoint<DIM>(
79 fieldEvalCoords.data(), 1e-12,
simple->getProblemName(),
80 simple->getDomainFEName(), fieldEvalData,
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);
91 <<
"For " << label <<
" field, " << t_scalar_holder;
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);
101 std::string vec_holder_string =
"";
102 for (
int i = 0;
i < DIM;
i++) {
104 " " + boost::lexical_cast<std::string>(t_vec_holder(
i));
108 <<
"For " << label <<
" field," << vec_holder_string;
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);
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));
131 <<
"For " << label <<
" field" << sym_tensor_holder_string;
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);
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));
154 <<
"For " << label <<
" field" << tensor_holder_string;
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;
164 process_field(label, ptr);
169 if (scalarFieldPtrs) {
170 for (
const auto &pair : *scalarFieldPtrs) {
171 const std::string &label = pair.first;
172 const boost::shared_ptr<VectorDouble> &ptr = pair.second;
175 process_scalar_field(label, ptr);
181 for (
const auto &pair : *vecFieldPtrs) {
182 const std::string &label = pair.first;
183 const boost::shared_ptr<MatrixDouble> &ptr = pair.second;
186 process_vector_field(label, ptr);
191 if (symTensorFieldPtrs) {
192 for (
const auto &pair : *symTensorFieldPtrs) {
193 const std::string &label = pair.first;
194 const boost::shared_ptr<MatrixDouble> &ptr = pair.second;
197 process_sym_tensor_field(label, ptr);
202 if (tensorFieldPtrs) {
203 for (
const auto &pair : *tensorFieldPtrs) {
204 const std::string &label = pair.first;
205 const boost::shared_ptr<MatrixDouble> &ptr = pair.second;
208 process_tensor_field(label, ptr);
216 auto make_vtk = [&]() {
219 CHKERR DMoFEMLoopFiniteElements(dM,
"dFE", postProcFe, getCacheWeakPtr());
220 CHKERR postProcFe->writeFile(
221 "out_plastic_" + boost::lexical_cast<std::string>(ts_step) +
".h5m");
223 if (skinPostProcFe) {
224 CHKERR DMoFEMLoopFiniteElements(dM,
"bFE", skinPostProcFe,
226 CHKERR skinPostProcFe->writeFile(
227 "out_skin_plastic_" + boost::lexical_cast<std::string>(ts_step) +
233 auto calculate_reaction = [&]() {
235 auto r = createDMVector(dM);
238 CHKERR DMoFEMLoopFiniteElements(dM,
"dFE", reactionFe, getCacheWeakPtr());
241 auto post_proc_residual = [&](
auto dm,
auto f_res,
auto out_name) {
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(
253 post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
263 CHKERR DMoFEMLoopFiniteElements(dM,
"dFE", post_proc_fe);
264 post_proc_fe->writeFile(
"res.h5m");
268 CHKERR post_proc_residual(dM, r,
"reaction");
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);
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);
289 CHKERR PetscOptionsGetInt(PETSC_NULLPTR,
"",
"-save_every", &se, PETSC_NULLPTR);
290 if (!(ts_step % se)) {
294 CHKERR calculate_reaction();
295 CHKERR print_max_min(uXScatter,
"Ux");
296 CHKERR print_max_min(uYScatter,
"Uy");
298 CHKERR print_max_min(uZScatter,
"Uz");
Monitor(DM dm, std::pair< boost::shared_ptr< PostProcEle >, boost::shared_ptr< SkinPostProcEle > > pair_post_proc_fe, boost::shared_ptr< DomainEle > reaction_fe, std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > ux_scatter, std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uy_scatter, std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uz_scatter, std::array< double, 3 > pass_field_eval_coords, boost::shared_ptr< SetPtsData > pass_field_eval_data, boost::shared_ptr< std::map< std::string, boost::shared_ptr< VectorDouble > > > scalar_field_ptrs, boost::shared_ptr< std::map< std::string, boost::shared_ptr< MatrixDouble > > > vec_field_ptrs, boost::shared_ptr< std::map< std::string, boost::shared_ptr< MatrixDouble > > > sym_tensor_field_ptrs, boost::shared_ptr< std::map< std::string, boost::shared_ptr< MatrixDouble > > > tensor_field_ptrs)