SmartPetscObj<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)
};
private:
std::tuple<SmartPetscObj<Vec>, SmartPetscObj<VecScatter>>
uXScatter;
std::tuple<SmartPetscObj<Vec>, SmartPetscObj<VecScatter>>
uYScatter;
std::tuple<SmartPetscObj<Vec>, SmartPetscObj<VecScatter>>
uZScatter;
boost::shared_ptr<std::map<std::string, boost::shared_ptr<VectorDouble>>>
boost::shared_ptr<std::map<std::string, boost::shared_ptr<MatrixDouble>>>
boost::shared_ptr<std::map<std::string, boost::shared_ptr<MatrixDouble>>>
boost::shared_ptr<std::map<std::string, boost::shared_ptr<MatrixDouble>>>
protected:
};
CHKERR DMoFEMGetInterfacePtr(dM, &m_field_ptr);
->evalFEAtThePoint<DIM>(
fieldEvalCoords.data(), 1e-12,
simple->getProblemName(),
simple->getDomainFEName(), fieldEvalData,
auto process_scalar_field =
[](const std::string label,
const boost::shared_ptr<VectorDouble> scalarFieldPtr) {
if (scalarFieldPtr->size()) {
auto t_scalar_holder = getFTensor0FromVec(*scalarFieldPtr);
<< "For " << label << " field, " << t_scalar_holder;
}
};
auto process_vector_field =
[](const std::string label,
const boost::shared_ptr<MatrixDouble> vecFieldPtr) {
if (vecFieldPtr->size1()) {
auto t_vec_holder = getFTensor1FromMat<DIM>(*vecFieldPtr);
std::string vec_holder_string = "";
for (
int i = 0;
i < DIM;
i++) {
vec_holder_string +=
" " + boost::lexical_cast<std::string>(t_vec_holder(
i));
}
<< "For " << label << " field," << vec_holder_string;
}
};
auto process_sym_tensor_field =
[](const std::string label,
const boost::shared_ptr<MatrixDouble> symTensorFieldPtr) {
if (symTensorFieldPtr->size1()) {
auto t_sym_tensor_holder =
getFTensor2SymmetricFromMat<DIM>(*symTensorFieldPtr);
std::string sym_tensor_holder_string = "";
for (
int i = 0;
i < DIM;
i++) {
for (
int j =
i;
j < DIM;
j++) {
sym_tensor_holder_string +=
", entry " + boost::lexical_cast<std::string>(
i) +
boost::lexical_cast<std::string>(
j) +
" = ";
sym_tensor_holder_string +=
boost::lexical_cast<std::string>(t_sym_tensor_holder(
i,
j));
}
}
<< "For " << label << " field" << sym_tensor_holder_string;
}
};
auto process_tensor_field =
[](const std::string label,
const boost::shared_ptr<MatrixDouble> tensorFieldPtr) {
if (tensorFieldPtr->size1()) {
auto t_tensor_holder =
getFTensor2FromMat<DIM, DIM>(*tensorFieldPtr);
std::string tensor_holder_string = "";
for (
int i = 0;
i < DIM;
i++) {
for (
int j = 0;
j < DIM;
j++) {
tensor_holder_string +=
", entry " + boost::lexical_cast<std::string>(
i) +
boost::lexical_cast<std::string>(
j) +
" = ";
tensor_holder_string +=
boost::lexical_cast<std::string>(t_tensor_holder(
i,
j));
}
}
<< "For " << label << " field" << tensor_holder_string;
}
};
auto process_fields = [](auto &fieldPtr, auto process_field) {
for (const auto &pair : fieldPtr) {
const std::string &label = pair.first;
const boost::shared_ptr<MatrixDouble> &ptr = pair.second;
if (ptr) {
process_field(label, ptr);
}
}
};
if (scalarFieldPtrs) {
for (const auto &pair : *scalarFieldPtrs) {
const std::string &label = pair.first;
const boost::shared_ptr<VectorDouble> &ptr = pair.second;
if (ptr) {
process_scalar_field(label, ptr);
}
}
}
if (vecFieldPtrs) {
for (const auto &pair : *vecFieldPtrs) {
const std::string &label = pair.first;
const boost::shared_ptr<MatrixDouble> &ptr = pair.second;
if (ptr) {
process_vector_field(label, ptr);
}
}
}
if (symTensorFieldPtrs) {
for (const auto &pair : *symTensorFieldPtrs) {
const std::string &label = pair.first;
const boost::shared_ptr<MatrixDouble> &ptr = pair.second;
if (ptr) {
process_sym_tensor_field(label, ptr);
}
}
}
if (tensorFieldPtrs) {
for (const auto &pair : *tensorFieldPtrs) {
const std::string &label = pair.first;
const boost::shared_ptr<MatrixDouble> &ptr = pair.second;
if (ptr) {
process_tensor_field(label, ptr);
}
}
}
}
auto make_vtk = [&]() {
if (postProcFe) {
CHKERR DMoFEMLoopFiniteElements(dM,
"dFE", postProcFe, getCacheWeakPtr());
"out_plastic_" + boost::lexical_cast<std::string>(ts_step) + ".h5m");
}
if (skinPostProcFe) {
CHKERR DMoFEMLoopFiniteElements(dM,
"bFE", skinPostProcFe,
getCacheWeakPtr());
CHKERR skinPostProcFe->writeFile(
"out_skin_plastic_" + boost::lexical_cast<std::string>(ts_step) +
".h5m");
}
};
auto calculate_reaction = [&]() {
auto r = createDMVector(dM);
reactionFe->f = r;
CHKERR DMoFEMLoopFiniteElements(dM,
"dFE", reactionFe, getCacheWeakPtr());
#ifndef NDEBUG
auto post_proc_residual = [&](auto dm, auto f_res, auto out_name) {
auto post_proc_fe =
boost::make_shared<PostProcBrokenMeshInMoab<DomainEle>>(*m_field_ptr);
using OpPPMap = OpPostProcMapInMoab<DIM, DIM>;
auto u_vec = boost::make_shared<MatrixDouble>();
post_proc_fe->getOpPtrVector().push_back(
new OpCalculateVectorFieldValues<DIM>("U", u_vec, f_res));
post_proc_fe->getOpPtrVector().push_back(
post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
{},
{{"RES", u_vec}},
{}, {})
);
CHKERR DMoFEMLoopFiniteElements(dM,
"dFE", post_proc_fe);
post_proc_fe->writeFile("res.h5m");
};
CHKERR post_proc_residual(dM, r,
"reaction");
#endif
};
auto print_max_min = [&](auto &tuple, const std::string msg) {
CHKERR VecScatterBegin(std::get<1>(tuple), ts_u, std::get<0>(tuple),
INSERT_VALUES, SCATTER_FORWARD);
CHKERR VecScatterEnd(std::get<1>(tuple), ts_u, std::get<0>(tuple),
INSERT_VALUES, SCATTER_FORWARD);
double max, min;
CHKERR VecMax(std::get<0>(tuple), PETSC_NULLPTR, &max);
CHKERR VecMin(std::get<0>(tuple), PETSC_NULLPTR, &min);
MOFEM_LOG_C(
"PLASTICITY", Sev::inform,
"%s time %3.4e min %3.4e max %3.4e",
msg.c_str(), ts_t, min, max);
};
int se = 1;
CHKERR PetscOptionsGetInt(PETSC_NULLPTR,
"",
"-save_every", &se, PETSC_NULLPTR);
if (!(ts_step % se)) {
}
if (reactionFe)
CHKERR print_max_min(uXScatter,
"Ux");
CHKERR print_max_min(uYScatter,
"Uy");
if (DIM == 3)
CHKERR print_max_min(uZScatter,
"Uz");
}
};
#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.
#define MOFEM_LOG(channel, severity)
Log.
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'j', 3 > j
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
PetscBool do_eval_field
Evaluate field.
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.
[Push operators to pipeline]
boost::shared_ptr< std::map< std::string, boost::shared_ptr< MatrixDouble > > > symTensorFieldPtrs
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uXScatter
boost::shared_ptr< SetPtsData > fieldEvalData
boost::shared_ptr< std::map< std::string, boost::shared_ptr< MatrixDouble > > > vecFieldPtrs
MoFEMErrorCode operator()()
boost::shared_ptr< DomainEle > reactionFe
MoFEMErrorCode preProcess()
boost::shared_ptr< std::map< std::string, boost::shared_ptr< VectorDouble > > > scalarFieldPtrs
boost::shared_ptr< SkinPostProcEle > skinPostProcFe
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uYScatter
Monitor(SmartPetscObj< 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)
MoFEMErrorCode postProcess()
boost::shared_ptr< std::map< std::string, boost::shared_ptr< MatrixDouble > > > tensorFieldPtrs
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uZScatter
std::array< double, 3 > fieldEvalCoords
boost::shared_ptr< PostProcEle > postProcFe