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 if (scalarFieldPtrs) {
159 for (
const auto &pair : *scalarFieldPtrs) {
160 const std::string &label = pair.first;
161 const boost::shared_ptr<VectorDouble> &ptr = pair.second;
164 process_scalar_field(label, ptr);
170 for (
const auto &pair : *vecFieldPtrs) {
171 const std::string &label = pair.first;
172 const boost::shared_ptr<MatrixDouble> &ptr = pair.second;
175 process_vector_field(label, ptr);
180 if (symTensorFieldPtrs) {
181 for (
const auto &pair : *symTensorFieldPtrs) {
182 const std::string &label = pair.first;
183 const boost::shared_ptr<MatrixDouble> &ptr = pair.second;
186 process_sym_tensor_field(label, ptr);
191 if (tensorFieldPtrs) {
192 for (
const auto &pair : *tensorFieldPtrs) {
193 const std::string &label = pair.first;
194 const boost::shared_ptr<MatrixDouble> &ptr = pair.second;
197 process_tensor_field(label, ptr);
205 auto make_vtk = [&]() {
208 CHKERR DMoFEMLoopFiniteElements(dM,
"dFE", postProcFe, getCacheWeakPtr());
209 CHKERR postProcFe->writeFile(
210 "out_plastic_" + boost::lexical_cast<std::string>(ts_step) +
".h5m");
212 if (skinPostProcFe) {
213 CHKERR DMoFEMLoopFiniteElements(dM,
"bFE", skinPostProcFe,
215 CHKERR skinPostProcFe->writeFile(
216 "out_skin_plastic_" + boost::lexical_cast<std::string>(ts_step) +
222 auto calculate_reaction = [&]() {
224 auto r = createDMVector(dM);
227 CHKERR DMoFEMLoopFiniteElements(dM,
"dFE", reactionFe, getCacheWeakPtr());
230 auto post_proc_residual = [&](
auto dm,
auto f_res,
auto out_name) {
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(
242 post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
252 CHKERR DMoFEMLoopFiniteElements(dM,
"dFE", post_proc_fe);
253 post_proc_fe->writeFile(
"res.h5m");
257 CHKERR post_proc_residual(dM, r,
"reaction");
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);
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);
278 CHKERR PetscOptionsGetInt(PETSC_NULLPTR,
"",
"-save_every", &se, PETSC_NULLPTR);
279 if (!(ts_step % se)) {
283 CHKERR calculate_reaction();
284 CHKERR print_max_min(uXScatter,
"Ux");
285 CHKERR print_max_min(uYScatter,
"Uy");
287 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)