v0.14.0
Loading...
Searching...
No Matches
EshelbianPlasticity.cpp

Eshelbian plasticity implementation.

Eshelbian plasticity implementation

/**
* \file EshelbianPlasticity.cpp
* \example EshelbianPlasticity.cpp
*
* \brief Eshelbian plasticity implementation
*/
#include <MoFEM.hpp>
using namespace MoFEM;
#include <boost/math/constants/constants.hpp>
#include <cholesky.hpp>
#ifdef PYTHON_SFD
#include <boost/python.hpp>
#include <boost/python/def.hpp>
namespace bp = boost::python;
#pragma message "With PYTHON_SFD"
#else
#pragma message "Without PYTHON_SFD"
#endif
EshelbianCore::query_interface(boost::typeindex::type_index type_index,
UnknownInterface **iface) const {
*iface = const_cast<EshelbianCore *>(this);
return 0;
}
if (evalRhs)
if (evalLhs)
}
: mField(m_field), piolaStress("P"), eshelbyStress("S"),
spatialL2Disp("wL2"), spatialH1Disp("wH1"), materialL2Disp("W"),
streachTensor("u"), rotAxis("omega"), materialGradient("G"),
tauField("TAU"), lambdaField("LAMBDA"), bubbleField("BUBBLE"),
elementVolumeName("EP"), naturalBcElement("NATURAL_BC"),
essentialBcElement("ESSENTIAL_BC"), skinElement("SKIN_ELEMENT"),
contactElement("CONTACT_ELEMENT") {
ierr = getOptions();
CHKERRABORT(PETSC_COMM_WORLD, ierr);
}
const char *list_rots[] = {"small", "moderate", "large"};
PetscInt choice_rot = rotSelector;
const char *list_stretches[] = {"linear", "log"};
PetscInt choice_stretch = StretchSelector::LOG;
CHKERR PetscOptionsBegin(PETSC_COMM_WORLD, "", "Eshelbian plasticity",
"none");
CHKERR PetscOptionsInt("-space_order", "approximation oder for space", "",
spaceOrder, &spaceOrder, PETSC_NULL);
CHKERR PetscOptionsInt("-material_order", "approximation oder for material",
"", materialOrder, &materialOrder, PETSC_NULL);
alphaU = 0;
CHKERR PetscOptionsScalar("-viscosity_alpha_u", "viscosity", "", alphaU,
&alphaU, PETSC_NULL);
alphaW = 0;
CHKERR PetscOptionsScalar("-viscosity_alpha_w", "viscosity", "", alphaW,
&alphaW, PETSC_NULL);
alphaRho = 0;
CHKERR PetscOptionsScalar("-density_alpha_rho", "density", "", alphaRho,
&alphaRho, PETSC_NULL);
precEps = 0;
CHKERR PetscOptionsScalar("-preconditioner_eps", "preconditioner_eps", "",
precEps, &precEps, PETSC_NULL);
CHKERR PetscOptionsScalar("-preconditioner_eps_omega", "preconditioner_eps",
"", precEpsOmega, &precEpsOmega, PETSC_NULL);
precEpsW = 0;
CHKERR PetscOptionsScalar("-preconditioner_eps_w", "preconditioner_eps", "",
precEpsW, &precEpsW, PETSC_NULL);
CHKERR PetscOptionsEList("-rotations", "rotations", "", list_rots,
LARGE_ROT + 1, list_rots[choice_rot], &choice_rot,
PETSC_NULL);
CHKERR PetscOptionsScalar("-exponent_base", "exponent_base", "", exponentBase,
&exponentBase, PETSC_NULL);
CHKERR PetscOptionsEList(
"-stretches", "stretches", "", list_stretches, StretchSelector::LOG + 1,
list_stretches[choice_stretch], &choice_stretch, PETSC_NULL);
ierr = PetscOptionsEnd();
rotSelector = static_cast<RotSelector>(choice_rot);
switch (choice_stretch) {
break;
f = f_log;
break;
default:
SETERRQ(mField.get_comm(), MOFEM_DATA_INCONSISTENCY, "Unknown stretch");
break;
};
MOFEM_LOG("EP", Sev::inform) << "spaceOrder " << spaceOrder;
MOFEM_LOG("EP", Sev::inform) << "materialOrder " << materialOrder;
MOFEM_LOG("EP", Sev::inform) << "alphaU " << alphaU;
MOFEM_LOG("EP", Sev::inform) << "alphaW " << alphaW;
MOFEM_LOG("EP", Sev::inform) << "alphaRho " << alphaRho;
MOFEM_LOG("EP", Sev::inform) << "precEps " << precEps;
MOFEM_LOG("EP", Sev::inform) << "precEpsOmega " << precEpsOmega;
MOFEM_LOG("EP", Sev::inform) << "precEpsW " << precEpsW;
MOFEM_LOG("EP", Sev::inform) << "Rotations " << list_rots[rotSelector];
if (exponentBase != exp(1))
MOFEM_LOG("EP", Sev::inform) << "Base exponent " << exponentBase;
else
MOFEM_LOG("EP", Sev::inform) << "Base exponent e";
MOFEM_LOG("EP", Sev::inform) << "Stretch " << list_stretches[choice_stretch];
}
Range tets;
CHKERR mField.get_moab().get_entities_by_type(meshset, MBTET, tets);
Range tets_skin_part;
Skinner skin(&mField.get_moab());
CHKERR skin.find_skin(0, tets, false, tets_skin_part);
ParallelComm *pcomm =
ParallelComm::get_pcomm(&mField.get_moab(), MYPCOMM_INDEX);
Range tets_skin;
CHKERR pcomm->filter_pstatus(tets_skin_part,
PSTATUS_SHARED | PSTATUS_MULTISHARED,
PSTATUS_NOT, -1, &tets_skin);
for (auto &v : *bcSpatialDispVecPtr) {
tets_skin = subtract(tets_skin, v.faces);
}
for (auto &v : *bcSpatialRotationVecPtr) {
tets_skin = subtract(tets_skin, v.faces);
}
for (auto &v : *bcSpatialTraction) {
tets_skin = subtract(tets_skin, v.faces);
}
auto subtract_faces_where_displacements_are_applied =
[&](const std::string block_name) {
auto msh_mng = mField.getInterface<MeshsetsManager>();
auto reg_exp = std::regex((boost::format("%s(.*)") % block_name).str());
for (auto m : msh_mng->getCubitMeshsetPtr(reg_exp)) {
Range faces;
CHKERR m->getMeshsetIdEntitiesByDimension(mField.get_moab(),
SPACE_DIM - 1, faces, true);
tets_skin = subtract(tets_skin, faces);
MOFEM_LOG("EP", Sev::inform)
<< "Subtracting " << m->getName() << " " << faces.size();
}
};
CHKERR subtract_faces_where_displacements_are_applied("CONTACT");
Range faces;
CHKERR mField.get_moab().get_adjacencies(tets, 2, true, faces,
moab::Interface::UNION);
Range faces_not_on_the_skin = subtract(faces, tets_skin);
auto add_hdiv_field = [&](const std::string field_name, const int order,
const int dim) {
MB_TAG_SPARSE, MF_ZERO);
CHKERR mField.set_field_order(faces_not_on_the_skin, field_name, order);
};
auto add_l2_field = [this, meshset](const std::string field_name,
const int order, const int dim) {
MB_TAG_DENSE, MF_ZERO);
};
auto add_h1_field = [this, meshset](const std::string field_name,
const int order, const int dim) {
MB_TAG_DENSE, MF_ZERO);
CHKERR mField.set_field_order(meshset, MBVERTEX, field_name, 1);
};
auto add_bubble_field = [this, meshset](const std::string field_name,
const int order, const int dim) {
// Modify field
auto field_order_table =
const_cast<Field *>(field_ptr)->getFieldOrderTable();
auto get_cgg_bubble_order_zero = [](int p) { return 0; };
auto get_cgg_bubble_order_tet = [](int p) {
};
field_order_table[MBVERTEX] = get_cgg_bubble_order_zero;
field_order_table[MBEDGE] = get_cgg_bubble_order_zero;
field_order_table[MBTRI] = get_cgg_bubble_order_zero;
field_order_table[MBTET] = get_cgg_bubble_order_tet;
};
// spatial fields
CHKERR add_hdiv_field(piolaStress, spaceOrder, 3);
CHKERR add_bubble_field(bubbleField, spaceOrder, 1);
CHKERR add_l2_field(spatialL2Disp, spaceOrder - 1, 3);
CHKERR add_l2_field(rotAxis, spaceOrder - 1, 3);
CHKERR add_l2_field(streachTensor, spaceOrder, 6);
// material fields
// CHKERR add_hdiv_field(eshelbyStress, materialOrder, 3);
// CHKERR add_l2_field(materialGradient, materialOrder - 1, 9);
// CHKERR add_l2_field(materialL2Disp, materialOrder - 1, 3);
// CHKERR add_l2_field(tauField, materialOrder - 1, 1);
// CHKERR add_l2_field(lambdaField, materialOrder - 1, 1);
// Add history filedes
// CHKERR add_l2_field(materialGradient + "0", materialOrder - 1, 9);
// spatial displacement
CHKERR add_h1_field(spatialH1Disp, spaceOrder, 3);
}
// set finite element fields
auto add_field_to_fe = [this](const std::string fe,
const std::string field_name) {
};
// CHKERR add_field_to_fe(elementVolumeName, eshelbyStress);
CHKERR add_field_to_fe(elementVolumeName, rotAxis);
// CHKERR add_field_to_fe(elementVolumeName, materialGradient);
// CHKERR mField.modify_finite_element_add_field_data(elementVolumeName,
// materialGradient +
// "0");
}
// build finite elements data structures
}
auto bc_elements_add_to_range = [&](const std::string block_name, Range &r) {
auto mesh_mng = mField.getInterface<MeshsetsManager>();
auto bcs = mesh_mng->getCubitMeshsetPtr(
std::regex((boost::format("%s(.*)") % block_name).str())
);
for (auto bc : bcs) {
Range faces;
CHKERR bc->getMeshsetIdEntitiesByDimension(mField.get_moab(), 2, faces,
true);
r.merge(faces);
}
};
// set finite element fields
auto add_field_to_fe = [this](const std::string fe,
const std::string field_name) {
};
Range natural_bc_elements;
for (auto &v : *bcSpatialDispVecPtr) {
natural_bc_elements.merge(v.faces);
}
}
for (auto &v : *bcSpatialRotationVecPtr) {
natural_bc_elements.merge(v.faces);
}
}
Range essentail_bc_elements;
for (auto &v : *bcSpatialTraction) {
essentail_bc_elements.merge(v.faces);
}
}
CHKERR mField.add_ents_to_finite_element_by_type(natural_bc_elements, MBTRI,
CHKERR add_field_to_fe(naturalBcElement, piolaStress);
// CHKERR add_field_to_fe(naturalBcElement, eshelbyStress);
CHKERR mField.add_ents_to_finite_element_by_type(essentail_bc_elements, MBTRI,
// CHKERR add_field_to_fe(essentialBcElement, eshelbyStress);
auto get_skin = [&]() {
Range body_ents;
CHKERR mField.get_moab().get_entities_by_dimension(0, SPACE_DIM, body_ents);
Skinner skin(&mField.get_moab());
Range skin_ents;
CHKERR skin.find_skin(0, body_ents, false, skin_ents);
return skin_ents;
};
auto filter_true_skin = [&](auto &&skin) {
Range boundary_ents;
ParallelComm *pcomm =
ParallelComm::get_pcomm(&mField.get_moab(), MYPCOMM_INDEX);
CHKERR pcomm->filter_pstatus(skin, PSTATUS_SHARED | PSTATUS_MULTISHARED,
PSTATUS_NOT, -1, &boundary_ents);
return boundary_ents;
};
auto skin = filter_true_skin(get_skin());
CHKERR add_field_to_fe(skinElement, piolaStress);
// CHKERR add_field_to_fe(skinElement, eshelbyStress);
Range contact_range;
CHKERR bc_elements_add_to_range("CONTACT", contact_range);
MOFEM_LOG("EP", Sev::inform) << "Contact elements " << contact_range.size();
CHKERR add_field_to_fe(contactElement, piolaStress);
}
// find adjacencies between finite elements and dofs
// Create coupled problem
dM = createDM(mField.get_comm(), "DMMOFEM");
CHKERR DMMoFEMCreateMoFEM(dM, &mField, "ESHELBY_PLASTICITY", bit,
BitRefLevel().set());
CHKERR DMMoFEMSetDestroyProblem(dM, PETSC_TRUE);
CHKERR DMMoFEMSetIsPartitioned(dM, PETSC_TRUE);
CHKERR DMMoFEMAddElement(dM, elementVolumeName);
CHKERR DMMoFEMAddElement(dM, naturalBcElement);
CHKERR DMMoFEMAddElement(dM, essentialBcElement);
CHKERR DMMoFEMAddElement(dM, contactElement);
CHKERR DMMoFEMAddElement(dM, skinElement);
mField.getInterface<ProblemsManager>()->buildProblemFromFields = PETSC_TRUE;
CHKERR DMSetUp(dM);
mField.getInterface<ProblemsManager>()->buildProblemFromFields = PETSC_FALSE;
auto remove_dofs_on_essential_spatial_stress_boundary =
[&](const std::string prb_name) {
for (int d : {0, 1, 2})
prb_name, piolaStress, (*bcSpatialFreeTraction)[d], d, d, 0,
};
CHKERR remove_dofs_on_essential_spatial_stress_boundary("ESHELBY_PLASTICITY");
// Create elastic sub-problem
dmElastic = createDM(mField.get_comm(), "DMMOFEM");
CHKERR DMMoFEMCreateSubDM(dmElastic, dM, "ELASTIC_PROBLEM");
CHKERR DMMoFEMSetDestroyProblem(dmElastic, PETSC_TRUE);
CHKERR DMMoFEMAddSubFieldRow(dmElastic, piolaStress.c_str());
CHKERR DMMoFEMAddSubFieldRow(dmElastic, bubbleField.c_str());
CHKERR DMMoFEMAddSubFieldRow(dmElastic, streachTensor.c_str());
CHKERR DMMoFEMAddSubFieldRow(dmElastic, rotAxis.c_str());
CHKERR DMMoFEMAddSubFieldRow(dmElastic, spatialL2Disp.c_str());
CHKERR DMMoFEMAddElement(dmElastic, elementVolumeName);
CHKERR DMMoFEMAddElement(dmElastic, naturalBcElement);
CHKERR DMMoFEMAddElement(dmElastic, essentialBcElement);
CHKERR DMMoFEMAddElement(dmElastic, contactElement);
CHKERR DMMoFEMSetSquareProblem(dmElastic, PETSC_TRUE);
CHKERR DMMoFEMSetIsPartitioned(dmElastic, PETSC_TRUE);
CHKERR DMSetUp(dmElastic);
{
PetscSection section;
CHKERR mField.getInterface<ISManager>()->sectionCreate("ELASTIC_PROBLEM",
&section);
CHKERR DMSetSection(dmElastic, section);
CHKERR DMSetGlobalSection(dmElastic, section);
CHKERR PetscSectionDestroy(&section);
}
dmPrjSpatial = createDM(mField.get_comm(), "DMMOFEM");
CHKERR DMMoFEMCreateSubDM(dmPrjSpatial, dM, "PROJECT_SPATIAL");
CHKERR DMMoFEMSetDestroyProblem(dmPrjSpatial, PETSC_TRUE);
CHKERR DMMoFEMAddSubFieldRow(dmPrjSpatial, spatialH1Disp.c_str());
CHKERR DMMoFEMAddElement(dmPrjSpatial, elementVolumeName);
CHKERR DMMoFEMSetSquareProblem(dmPrjSpatial, PETSC_TRUE);
CHKERR DMMoFEMSetIsPartitioned(dmPrjSpatial, PETSC_TRUE);
CHKERR DMSetUp(dmPrjSpatial);
}
BcDisp::BcDisp(std::string name, std::vector<double> &attr, Range &faces)
: blockName(name), faces(faces) {
vals.resize(3, false);
flags.resize(3, false);
for (int ii = 0; ii != 3; ++ii) {
vals[ii] = attr[ii];
flags[ii] = static_cast<int>(attr[ii + 3]);
}
MOFEM_LOG("EP", Sev::inform) << "Add BCDisp " << name;
MOFEM_LOG("EP", Sev::inform)
<< "Add BCDisp vals " << vals[0] << " " << vals[1] << " " << vals[2];
MOFEM_LOG("EP", Sev::inform)
<< "Add BCDisp flags " << flags[0] << " " << flags[1] << " " << flags[2];
MOFEM_LOG("EP", Sev::inform) << "Add BCDisp nb. of faces " << faces.size();
}
BcRot::BcRot(std::string name, std::vector<double> &attr, Range &faces)
: blockName(name), faces(faces) {
vals.resize(3, false);
for (int ii = 0; ii != 3; ++ii) {
vals[ii] = attr[ii];
}
theta = attr[3];
}
TractionBc::TractionBc(std::string name, std::vector<double> &attr,
Range &faces)
: blockName(name), faces(faces) {
vals.resize(3, false);
flags.resize(3, false);
for (int ii = 0; ii != 3; ++ii) {
vals[ii] = attr[ii];
flags[ii] = static_cast<int>(attr[ii + 3]);
}
MOFEM_LOG("EP", Sev::inform) << "Add BCForce " << name;
MOFEM_LOG("EP", Sev::inform)
<< "Add BCForce vals " << vals[0] << " " << vals[1] << " " << vals[2];
MOFEM_LOG("EP", Sev::inform)
<< "Add BCForce flags " << flags[0] << " " << flags[1] << " " << flags[2];
MOFEM_LOG("EP", Sev::inform) << "Add BCForce nb. of faces " << faces.size();
}
boost::shared_ptr<TractionFreeBc> &bc_ptr,
const std::string contact_set_name) {
// get skin from all tets
Range tets;
CHKERR mField.get_moab().get_entities_by_type(meshset, MBTET, tets);
Range tets_skin_part;
Skinner skin(&mField.get_moab());
CHKERR skin.find_skin(0, tets, false, tets_skin_part);
ParallelComm *pcomm =
ParallelComm::get_pcomm(&mField.get_moab(), MYPCOMM_INDEX);
Range tets_skin;
CHKERR pcomm->filter_pstatus(tets_skin_part,
PSTATUS_SHARED | PSTATUS_MULTISHARED,
PSTATUS_NOT, -1, &tets_skin);
bc_ptr->resize(3);
for (int dd = 0; dd != 3; ++dd)
(*bc_ptr)[dd] = tets_skin;
for (auto &v : *bcSpatialDispVecPtr) {
if (v.flags[0])
(*bc_ptr)[0] = subtract((*bc_ptr)[0], v.faces);
if (v.flags[1])
(*bc_ptr)[1] = subtract((*bc_ptr)[1], v.faces);
if (v.flags[2])
(*bc_ptr)[2] = subtract((*bc_ptr)[2], v.faces);
}
for (auto &v : *bcSpatialRotationVecPtr) {
(*bc_ptr)[0] = subtract((*bc_ptr)[0], v.faces);
(*bc_ptr)[1] = subtract((*bc_ptr)[1], v.faces);
(*bc_ptr)[2] = subtract((*bc_ptr)[2], v.faces);
}
// remove contact
std::regex((boost::format("%s(.*)") % contact_set_name).str()))) {
Range faces;
CHKERR m->getMeshsetIdEntitiesByDimension(mField.get_moab(), 2, faces,
true);
(*bc_ptr)[0] = subtract((*bc_ptr)[0], faces);
(*bc_ptr)[1] = subtract((*bc_ptr)[1], faces);
(*bc_ptr)[2] = subtract((*bc_ptr)[2], faces);
}
// for (int dd = 0; dd != 3; ++dd) {
// EntityHandle meshset;
// CHKERR mField.get_moab().create_meshset(MESHSET_SET, meshset);
// CHKERR mField.get_moab().add_entities(meshset, (*bc_ptr)[dd]);
// std::string file_name = disp_block_set_name +
// "_traction_free_bc_" + boost::lexical_cast<std::string>(dd) + ".vtk";
// CHKERR mField.get_moab().write_file(file_name.c_str(), " VTK ", "",
// &meshset, 1);
// CHKERR mField.get_moab().delete_entities(&meshset, 1);
// }
}
/**
* @brief Set integration rule on element
* \param order on row
* \param order on column
* \param order on data
*
* Use maximal oder on data in order to determine integration rule
*
*/
struct VolRule {
int operator()(int p_row, int p_col, int p_data) const {
return p_data + p_data + (p_data - 1);
}
};
struct FaceRule {
int operator()(int p_row, int p_col, int p_data) const { return 2 * p_data; }
};
struct CGGUserPolynomialBase : public BaseFunction {
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index,
*iface = const_cast<CGGUserPolynomialBase *>(this);
return 0;
}
boost::shared_ptr<BaseFunctionCtx> ctx_ptr) {
cTx = ctx_ptr->getInterface<EntPolynomialBaseCtx>();
int nb_gauss_pts = pts.size2();
if (!nb_gauss_pts) {
}
if (pts.size1() < 3) {
SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
"Wrong dimension of pts, should be at least 3 rows with "
"coordinates");
}
switch (cTx->sPace) {
case HDIV:
break;
default:
SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "Not yet implemented");
}
}
private:
// This should be used only in case USER_BASE is selected
if (cTx->bAse != USER_BASE) {
SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
"Wrong base, should be USER_BASE");
}
// get access to data structures on element
EntitiesFieldData &data = cTx->dAta;
// Get approximation order on element. Note that bubble functions are only
// on tetrahedron.
const int order = data.dataOnEntities[MBTET][0].getOrder();
/// number of integration points
const int nb_gauss_pts = pts.size2();
// number of base functions
// calculate shape functions, i.e. barycentric coordinates
shapeFun.resize(nb_gauss_pts, 4, false);
CHKERR ShapeMBTET(&*shapeFun.data().begin(), &pts(0, 0), &pts(1, 0),
&pts(2, 0), nb_gauss_pts);
// direvatives of shape functions
double diff_shape_fun[12];
CHKERR ShapeDiffMBTET(diff_shape_fun);
const int nb_base_functions = NBVOLUMETET_CCG_BUBBLE(order);
// get base functions and set size
MatrixDouble &phi = data.dataOnEntities[MBTET][0].getN(USER_BASE);
phi.resize(nb_gauss_pts, 9 * nb_base_functions, false);
// finally calculate base functions
&phi(0, 0), &phi(0, 1), &phi(0, 2),
&phi(0, 3), &phi(0, 4), &phi(0, 5),
&phi(0, 6), &phi(0, 7), &phi(0, 8));
CHKERR CGG_BubbleBase_MBTET(order, &shapeFun(0, 0), diff_shape_fun, t_phi,
nb_gauss_pts);
}
};
const int tag, const bool do_rhs, const bool do_lhs,
boost::shared_ptr<VolumeElementForcesAndSourcesCore> &fe) {
fe = boost::make_shared<VolumeElementForcesAndSourcesCore>(mField);
fe->getUserPolynomialBase() =
boost::shared_ptr<BaseFunction>(new CGGUserPolynomialBase());
{HDIV, H1, L2});
// set integration rule
fe->getRuleHook = VolRule();
if (!dataAtPts) {
boost::shared_ptr<DataAtIntegrationPts>(new DataAtIntegrationPts());
}
// calculate fields values
fe->getOpPtrVector().push_back(new OpCalculateHVecTensorField<3, 3>(
piolaStress, dataAtPts->getApproxPAtPts()));
fe->getOpPtrVector().push_back(new OpCalculateHTensorTensorField<3, 3>(
bubbleField, dataAtPts->getApproxPAtPts(), MBMAXTYPE));
fe->getOpPtrVector().push_back(new OpCalculateHVecTensorDivergence<3, 3>(
piolaStress, dataAtPts->getDivPAtPts()));
// fe->getOpPtrVector().push_back(new OpCalculateHVecTensorField<3, 3>(
// eshelbyStress, dataAtPts->getApproxSigmaAtPts()));
// fe->getOpPtrVector().push_back(new OpCalculateHVecTensorDivergence<3, 3>(
// eshelbyStress, dataAtPts->getDivSigmaAtPts()));
fe->getOpPtrVector().push_back(new OpCalculateTensor2SymmetricFieldValues<3>(
streachTensor, dataAtPts->getLogStreachTensorAtPts(), MBTET));
fe->getOpPtrVector().push_back(new OpCalculateVectorFieldValues<3>(
rotAxis, dataAtPts->getRotAxisAtPts(), MBTET));
// fe->getOpPtrVector().push_back(new OpCalculateTensor2FieldValues<3, 3>(
// materialGradient, dataAtPts->getBigGAtPts(), MBTET));
// fe->getOpPtrVector().push_back(new OpCalculateTensor2FieldValues<3, 3>(
// materialGradient + "0", dataAtPts->getBigG0AtPts(), MBTET));
fe->getOpPtrVector().push_back(new OpCalculateVectorFieldValues<3>(
spatialL2Disp, dataAtPts->getSmallWAtPts(), MBTET));
// velocities
fe->getOpPtrVector().push_back(new OpCalculateVectorFieldValuesDot<3>(
spatialL2Disp, dataAtPts->getSmallWDotAtPts(), MBTET));
fe->getOpPtrVector().push_back(
streachTensor, dataAtPts->getLogStreachDotTensorAtPts(), MBTET));
fe->getOpPtrVector().push_back(new OpCalculateVectorFieldValuesDot<3>(
rotAxis, dataAtPts->getRotAxisDotAtPts(), MBTET));
// acceleration
if (std::abs(alphaRho) > std::numeric_limits<double>::epsilon()) {
fe->getOpPtrVector().push_back(new OpCalculateVectorFieldValuesDotDot<3>(
spatialL2Disp, dataAtPts->getSmallWDotDotAtPts(), MBTET));
}
// calculate other derived quantities
fe->getOpPtrVector().push_back(
new OpCalculateRotationAndSpatialGradient(dataAtPts));
// evaluate integration points
fe->getOpPtrVector().push_back(physicalEquations->returnOpJacobian(
tag, do_rhs, do_lhs, dataAtPts, physicalEquations));
}
const int tag, const bool add_elastic, const bool add_material,
boost::shared_ptr<VolumeElementForcesAndSourcesCore> &fe_rhs,
boost::shared_ptr<VolumeElementForcesAndSourcesCore> &fe_lhs) {
auto time_scale = boost::make_shared<TimeScale>();
// Right hand side
CHKERR setBaseVolumeElementOps(tag, true, false, fe_rhs);
// elastic
if (add_elastic) {
fe_rhs->getOpPtrVector().push_back(
new OpSpatialEquilibrium(spatialL2Disp, dataAtPts, alphaW, alphaRho));
fe_rhs->getOpPtrVector().push_back(
new OpSpatialRotation(rotAxis, dataAtPts));
fe_rhs->getOpPtrVector().push_back(
new OpSpatialPhysical(streachTensor, dataAtPts, alphaU));
fe_rhs->getOpPtrVector().push_back(
new OpSpatialConsistencyP(piolaStress, dataAtPts));
fe_rhs->getOpPtrVector().push_back(
new OpSpatialConsistencyBubble(bubbleField, dataAtPts));
fe_rhs->getOpPtrVector().push_back(
new OpSpatialConsistencyDivTerm(piolaStress, dataAtPts));
// Body forces
using BodyNaturalBC =
Assembly<PETSC>::LinearForm<GAUSS>;
using OpBodyForce =
BodyNaturalBC::OpFlux<NaturalMeshsetType<BLOCKSET>, 1, 3>;
CHKERR BodyNaturalBC::AddFluxToPipeline<OpBodyForce>::add(
fe_rhs->getOpPtrVector(), mField, "w", {time_scale}, "BODY_FORCE",
Sev::inform);
}
// Left hand side
CHKERR setBaseVolumeElementOps(tag, true, true, fe_lhs);
// elastic
if (add_elastic) {
fe_lhs->getOpPtrVector().push_back(new OpSpatialPhysical_du_du(
fe_lhs->getOpPtrVector().push_back(new OpSpatialPhysical_du_dBubble(
fe_lhs->getOpPtrVector().push_back(new OpSpatialEquilibrium_dw_dP(
fe_lhs->getOpPtrVector().push_back(new OpSpatialEquilibrium_dw_dw(
fe_lhs->getOpPtrVector().push_back(new OpSpatialConsistency_dP_domega(
fe_lhs->getOpPtrVector().push_back(new OpSpatialConsistency_dBubble_domega(
fe_lhs->getOpPtrVector().push_back(new OpSpatialPhysical_du_dP(
fe_lhs->getOpPtrVector().push_back(new OpSpatialPhysical_du_domega(
fe_lhs->getOpPtrVector().push_back(new OpSpatialRotation_domega_dP(
fe_lhs->getOpPtrVector().push_back(new OpSpatialRotation_domega_dBubble(
fe_lhs->getOpPtrVector().push_back(
new OpSpatialRotation_domega_domega(rotAxis, rotAxis, dataAtPts));
fe_lhs->getOpPtrVector().push_back(new OpSpatialRotation_domega_du(
// Stabilisation
if constexpr (A == AssemblyType::SCHUR) {
// Note that we assemble to AMat, however Assembly<SCHUR> assemble by
// default to PMat
fe_lhs->getOpPtrVector().push_back(
new OpMassStab(rotAxis, rotAxis, [this](double, double, double) {
return precEpsOmega;
}));
if (std::abs(alphaRho + alphaW) <
std::numeric_limits<double>::epsilon()) {
fe_lhs->getOpPtrVector().push_back(new OpMassStab(
[this](double, double, double) { return precEpsW; }));
}
}
if (add_material) {
}
}
}
const bool add_elastic, const bool add_material,
boost::shared_ptr<FaceElementForcesAndSourcesCore> &fe_rhs,
boost::shared_ptr<FaceElementForcesAndSourcesCore> &fe_lhs) {
fe_rhs = boost::make_shared<FaceElementForcesAndSourcesCore>(mField);
fe_lhs = boost::make_shared<FaceElementForcesAndSourcesCore>(mField);
// set integration rule
fe_rhs->getRuleHook = FaceRule();
fe_lhs->getRuleHook = FaceRule();
{HDIV});
{HDIV});
if (add_elastic) {
fe_rhs->getOpPtrVector().push_back(
fe_rhs->getOpPtrVector().push_back(
}
}
boost::shared_ptr<FaceElementForcesAndSourcesCore> &fe_rhs,
boost::shared_ptr<FaceElementForcesAndSourcesCore> &fe_lhs) {
/* The above code is written in C++ and it appears to be defining and using
various operations on boundary elements and side elements. */
fe_rhs = boost::make_shared<BoundaryEle>(mField);
fe_lhs = boost::make_shared<BoundaryEle>(mField);
fe_rhs->getRuleHook = FaceRule();
fe_lhs->getRuleHook = FaceRule();
{HDIV});
{HDIV});
auto adj_cache =
boost::make_shared<ForcesAndSourcesCore::UserDataOperator::AdjCache>();
auto get_op_side = [&](auto disp_ptr, auto col_ent_data_ptr) {
auto op_loop_side = new OpLoopSide<SideEle>(
mField, elementVolumeName, SPACE_DIM, Sev::noisy, adj_cache);
op_loop_side->getSideFEPtr()->getUserPolynomialBase() =
boost::shared_ptr<BaseFunction>(new CGGUserPolynomialBase());
op_loop_side->getOpPtrVector(), {HDIV, H1, L2});
op_loop_side->getOpPtrVector().push_back(
if (col_ent_data_ptr != nullptr) {
op_loop_side->getOpPtrVector().push_back(
spatialL2Disp, col_ent_data_ptr));
}
return op_loop_side;
};
auto add_ops_lhs = [&](auto &pip) {
auto col_ent_data_ptr = boost::make_shared<EntitiesFieldData::EntData>();
auto common_data_ptr = boost::make_shared<ContactOps::CommonData>();
pip.push_back(
get_op_side(common_data_ptr->contactDispPtr(), col_ent_data_ptr));
piolaStress, common_data_ptr->contactTractionPtr()));
piolaStress, common_data_ptr, col_ent_data_ptr));
piolaStress, common_data_ptr));
};
auto add_ops_rhs = [&](auto &pip) {
auto common_data_ptr = boost::make_shared<ContactOps::CommonData>();
piolaStress, common_data_ptr->contactTractionPtr()));
pip.push_back(get_op_side(common_data_ptr->contactDispPtr(), nullptr));
piolaStress, common_data_ptr));
};
CHKERR add_ops_lhs(fe_lhs->getOpPtrVector());
CHKERR add_ops_rhs(fe_rhs->getOpPtrVector());
}
auto adj_cache =
boost::make_shared<ForcesAndSourcesCore::UserDataOperator::AdjCache>();
auto get_op_contact_bc = [&]() {
auto op_loop_side = new OpLoopSide<SideEle>(
mField, contactElement, SPACE_DIM - 1, Sev::noisy, adj_cache);
return op_loop_side;
};
auto op_contact_bc = get_op_contact_bc();
elasticFeLhs->getOpPtrVector().push_back(op_contact_bc);
CHKERR setContactElementOps(contactRhs, op_contact_bc->getSideFEPtr());
}
boost::shared_ptr<FEMethod> null;
boost::shared_ptr<FeTractionBc> spatial_traction_bc(
new FeTractionBc(mField, piolaStress, bcSpatialTraction));
if (std::abs(alphaRho) > std::numeric_limits<double>::epsilon()) {
CHKERR DMMoFEMTSSetI2Function(dm, DM_NO_ELEMENT, null, spatial_traction_bc,
null);
CHKERR DMMoFEMTSSetI2Function(dm, elementVolumeName, elasticFeRhs, null,
null);
CHKERR DMMoFEMTSSetI2Function(dm, naturalBcElement, elasticBcRhs, null,
null);
CHKERR DMMoFEMTSSetI2Function(dm, contactElement, contactRhs, null, null);
CHKERR DMMoFEMTSSetI2Function(dm, DM_NO_ELEMENT, null, null,
spatial_traction_bc);
CHKERR DMMoFEMTSSetI2Jacobian(dm, elementVolumeName, elasticFeLhs, null,
null);
CHKERR DMMoFEMTSSetI2Jacobian(dm, naturalBcElement, elasticBcLhs, null,
null);
} else {
CHKERR DMMoFEMTSSetIFunction(dm, DM_NO_ELEMENT, null, spatial_traction_bc,
null);
CHKERR DMMoFEMTSSetIFunction(dm, elementVolumeName, elasticFeRhs, null,
null);
CHKERR DMMoFEMTSSetIFunction(dm, naturalBcElement, elasticBcRhs, null,
null);
CHKERR DMMoFEMTSSetIFunction(dm, contactElement, contactRhs, null, null);
CHKERR DMMoFEMTSSetIFunction(dm, DM_NO_ELEMENT, null, null,
spatial_traction_bc);
CHKERR DMMoFEMTSSetIJacobian(dm, elementVolumeName, elasticFeLhs, null,
null);
CHKERR DMMoFEMTSSetIJacobian(dm, naturalBcElement, elasticBcLhs, null,
null);
}
}
prjKsp; ///< KSP for projection spatial displacement on H1 space
SmartPetscObj<Vec> prjD; ///< Unknown vector for projection spatial displacement
SmartPetscObj<Vec> prjF; ///< RHS for projection spatial displacement on H1
///< space
MoFEMErrorCode EshelbianCore::solveElastic(TS ts, Mat m, Vec f, Vec x) {
#ifdef PYTHON_SFD
boost::shared_ptr<ContactOps::SDFPython> sdf_python_ptr;
auto file_exists = [](std::string myfile) {
std::ifstream file(myfile.c_str());
if (file) {
return true;
}
return false;
};
if (file_exists("sdf.py")) {
MOFEM_LOG("EP", Sev::inform) << "sdf.py file found";
sdf_python_ptr = boost::make_shared<ContactOps::SDFPython>();
CHKERR sdf_python_ptr->sdfInit("sdf.py");
ContactOps::sdfPythonWeakPtr = sdf_python_ptr;
} else {
MOFEM_LOG("EP", Sev::warning) << "sdf.py file NOT found";
}
#else
#endif
boost::shared_ptr<TsCtx> ts_ctx;
CHKERR DMMoFEMGetTsCtx(dmElastic, ts_ctx);
CHKERR TSMonitorSet(ts, TsMonitorSet, ts_ctx.get(), PETSC_NULL);
struct Monitor : public FEMethod {
EshelbianCore &eP;
boost::shared_ptr<SetPtsData> dataFieldEval;
boost::shared_ptr<VolEle> volPostProcEnergy;
boost::shared_ptr<double> gEnergy;
Monitor(EshelbianCore &ep)
: eP(ep),
dataFieldEval(ep.mField.getInterface<FieldEvaluatorInterface>()
->getData<VolEle>()),
volPostProcEnergy(new VolEle(ep.mField)), gEnergy(new double) {
ierr = ep.mField.getInterface<FieldEvaluatorInterface>()->buildTree3D(
dataFieldEval, "EP");
CHKERRABORT(PETSC_COMM_WORLD, ierr);
auto no_rule = [](int, int, int) { return -1; };
auto set_element_for_field_eval = [&]() {
boost::shared_ptr<Ele> vol_ele(dataFieldEval->feMethodPtr.lock());
vol_ele->getRuleHook = no_rule;
vol_ele->getUserPolynomialBase() =
boost::shared_ptr<BaseFunction>(new CGGUserPolynomialBase());
vol_ele->getOpPtrVector(), {HDIV, H1, L2});
vol_ele->getOpPtrVector().push_back(
eP.piolaStress, eP.dataAtPts->getApproxPAtPts()));
vol_ele->getOpPtrVector().push_back(
eP.bubbleField, eP.dataAtPts->getApproxPAtPts(), MBMAXTYPE));
vol_ele->getOpPtrVector().push_back(
eP.streachTensor, eP.dataAtPts->getLogStreachTensorAtPts(),
MBTET));
vol_ele->getOpPtrVector().push_back(new OpCalculateVectorFieldValues<3>(
eP.rotAxis, eP.dataAtPts->getRotAxisAtPts(), MBTET));
// vol_ele->getOpPtrVector().push_back(
// new OpCalculateTensor2FieldValues<3, 3>(
// eP.materialGradient, eP.dataAtPts->getBigGAtPts(), MBTET));
vol_ele->getOpPtrVector().push_back(new OpCalculateVectorFieldValues<3>(
eP.spatialL2Disp, eP.dataAtPts->getSmallWAtPts(), MBTET));
vol_ele->getOpPtrVector().push_back(
new OpCalculateRotationAndSpatialGradient(eP.dataAtPts));
};
auto set_element_for_post_process = [&]() {
volPostProcEnergy->getRuleHook = VolRule();
// Right hand side
// CHKERR eP.setBaseVolumeElementOps(tag, true, false,
// volPostProcEnergy);
volPostProcEnergy->getUserPolynomialBase() =
boost::shared_ptr<BaseFunction>(new CGGUserPolynomialBase());
volPostProcEnergy->getOpPtrVector(), {HDIV, H1, L2});
volPostProcEnergy->getOpPtrVector().push_back(
eP.piolaStress, eP.dataAtPts->getApproxPAtPts()));
volPostProcEnergy->getOpPtrVector().push_back(
eP.bubbleField, eP.dataAtPts->getApproxPAtPts(), MBMAXTYPE));
volPostProcEnergy->getOpPtrVector().push_back(
eP.streachTensor, eP.dataAtPts->getLogStreachTensorAtPts(),
MBTET));
volPostProcEnergy->getOpPtrVector().push_back(
eP.rotAxis, eP.dataAtPts->getRotAxisAtPts(), MBTET));
// volPostProcEnergy->getOpPtrVector().push_back(
// new OpCalculateTensor2FieldValues<3, 3>(
// eP.materialGradient, eP.dataAtPts->getBigGAtPts(), MBTET));
volPostProcEnergy->getOpPtrVector().push_back(
eP.spatialL2Disp, eP.dataAtPts->getSmallWAtPts(), MBTET));
volPostProcEnergy->getOpPtrVector().push_back(
new OpCalculateRotationAndSpatialGradient(eP.dataAtPts));
volPostProcEnergy->getOpPtrVector().push_back(
new OpCalculateStrainEnergy(eP.spatialL2Disp, eP.dataAtPts,
gEnergy));
};
set_element_for_field_eval();
set_element_for_post_process();
}
MoFEMErrorCode preProcess() { return 0; }
MoFEMErrorCode operator()() { return 0; }
MoFEMErrorCode postProcess() {
// auto get_str_time = [](auto ts_t) {
// std::ostringstream ss;
// ss << boost::str(boost::format("%d") %
// static_cast<int>(std::ceil(ts_t * 1e6)));
// std::string s = ss.str();
// return s;
// };
auto get_step = [](auto ts_step) {
std::ostringstream ss;
ss << boost::str(boost::format("%d") % static_cast<int>(ts_step));
std::string s = ss.str();
return s;
};
PetscViewer viewer;
CHKERR PetscViewerBinaryOpen(
PETSC_COMM_WORLD, ("restart_" + get_step(ts_step) + ".dat").c_str(),
FILE_MODE_WRITE, &viewer);
CHKERR VecView(ts_u, viewer);
CHKERR PetscViewerDestroy(&viewer);
CHKERR eP.postProcessResults(1, "out_sol_elastic_" + get_step(ts_step) +
".h5m");
// Loop boundary elements with traction boundary conditions
*gEnergy = 0;
CHKERR eP.mField.loop_finite_elements(problemPtr->getName(), "EP",
*volPostProcEnergy);
double body_energy = 0;
MPI_Allreduce(gEnergy.get(), &body_energy, 1, MPI_DOUBLE, MPI_SUM,
eP.mField.get_comm());
MOFEM_LOG_C("EP", Sev::inform, "Step %d time %3.4g strain energy %3.6e",
ts_step, ts_t, body_energy);
auto post_proc_at_points = [&](std::array<double, 3> point,
std::string str) {
dataFieldEval->setEvalPoints(point.data(), point.size() / 3);
struct OpPrint : public VolOp {
EshelbianCore &eP;
std::array<double, 3> point;
std::string str;
OpPrint(EshelbianCore &ep, std::array<double, 3> &point,
std::string &str)
: VolOp(ep.spatialL2Disp, VolOp::OPROW), eP(ep), point(point),
str(str) {}
MoFEMErrorCode doWork(int side, EntityType type,
if (type == MBTET) {
if (getGaussPts().size2()) {
auto t_h = getFTensor2FromMat<3, 3>(eP.dataAtPts->hAtPts);
auto t_approx_P =
getFTensor2FromMat<3, 3>(eP.dataAtPts->approxPAtPts);
const double jac = determinantTensor3by3(t_h);
t_cauchy(i, j) = (1. / jac) * (t_approx_P(i, k) * t_h(j, k));
auto add = [&]() {
std::ostringstream s;
s << str << " elem " << getFEEntityHandle() << " ";
return s.str();
};
auto print_tensor = [](auto &t) {
std::ostringstream s;
s << t;
return s.str();
};
std::ostringstream print;
MOFEM_LOG("EPSYNC", Sev::inform)
<< add() << "comm rank " << eP.mField.get_comm_rank();
MOFEM_LOG("EPSYNC", Sev::inform)
<< add() << "point " << getVectorAdaptor(point.data(), 3);
MOFEM_LOG("EPSYNC", Sev::inform)
<< add() << "coords at gauss pts " << getCoordsAtGaussPts();
MOFEM_LOG("EPSYNC", Sev::inform)
<< add() << "w " << eP.dataAtPts->wAtPts;
MOFEM_LOG("EPSYNC", Sev::inform)
<< add() << "Piola " << eP.dataAtPts->approxPAtPts;
MOFEM_LOG("EPSYNC", Sev::inform)
<< add() << "Cauchy " << print_tensor(t_cauchy);
}
}
}
};
if (auto fe_ptr = dataFieldEval->feMethodPtr.lock()) {
fe_ptr->getOpPtrVector().push_back(new OpPrint(eP, point, str));
CHKERR eP.mField.getInterface<FieldEvaluatorInterface>()
->evalFEAtThePoint3D(
point.data(), 1e-12, problemPtr->getName(), "EP",
dataFieldEval, eP.mField.get_comm_rank(),
eP.mField.get_comm_rank(), nullptr, MF_EXIST, QUIET);
fe_ptr->getOpPtrVector().pop_back();
}
};
// Points for Cook beam
std::array<double, 3> pointA = {48., 60., 0.};
CHKERR post_proc_at_points(pointA, "Point A");
MOFEM_LOG_SYNCHRONISE(eP.mField.get_comm());
std::array<double, 3> pointB = {48. / 2., 44. + (60. - 44.) / 2., 0.};
CHKERR post_proc_at_points(pointB, "Point B");
MOFEM_LOG_SYNCHRONISE(eP.mField.get_comm());
std::array<double, 3> pointC = {48. / 2., (44. - 0.) / 2., 0.};
CHKERR post_proc_at_points(pointC, "Point C");
MOFEM_LOG_SYNCHRONISE(eP.mField.get_comm());
}
};
boost::shared_ptr<FEMethod> monitor_ptr(new Monitor(*this));
ts_ctx->getLoopsMonitor().push_back(
CHKERR TSAppendOptionsPrefix(ts, "elastic_");
CHKERR TSSetFromOptions(ts);
CHKERR TSSetDM(ts, dmElastic);
SNES snes;
CHKERR TSGetSNES(ts, &snes);
PetscViewerAndFormat *vf;
CHKERR PetscViewerAndFormatCreate(PETSC_VIEWER_STDOUT_WORLD,
PETSC_VIEWER_DEFAULT, &vf);
CHKERR SNESMonitorSet(
snes,
(MoFEMErrorCode(*)(SNES, PetscInt, PetscReal, void *))SNESMonitorFields,
vf, (MoFEMErrorCode(*)(void **))PetscViewerAndFormatDestroy);
PetscSection section;
CHKERR DMGetSection(dmElastic, &section);
int num_fields;
CHKERR PetscSectionGetNumFields(section, &num_fields);
for (int ff = 0; ff != num_fields; ff++) {
const char *field_name;
CHKERR PetscSectionGetFieldName(section, ff, &field_name);
MOFEM_LOG_C("EP", Sev::inform, "Field %d name %s", ff, field_name);
}
CHKERR DMoFEMMeshToLocalVector(dmElastic, x, INSERT_VALUES, SCATTER_FORWARD);
CHKERR VecGhostUpdateBegin(x, INSERT_VALUES, SCATTER_FORWARD);
CHKERR VecGhostUpdateEnd(x, INSERT_VALUES, SCATTER_FORWARD);
// Adding field split solver
boost::shared_ptr<SetUpSchur> schur_ptr;
if constexpr (A == AssemblyType::SCHUR) {
auto p = matDuplicate(m, MAT_DO_NOT_COPY_VALUES);
// If density is larger than zero, use dynamic time solver
if (std::abs(alphaRho) > std::numeric_limits<double>::epsilon()) {
CHKERR TSSetI2Function(ts, f, PETSC_NULL, PETSC_NULL);
CHKERR TSSetI2Jacobian(ts, m, p, PETSC_NULL, PETSC_NULL);
} else {
CHKERR TSSetIFunction(ts, f, PETSC_NULL, PETSC_NULL);
CHKERR TSSetIJacobian(ts, m, p, PETSC_NULL, PETSC_NULL);
}
KSP ksp;
CHKERR SNESGetKSP(snes, &ksp);
PC pc;
CHKERR KSPGetPC(ksp, &pc);
mField, SmartPetscObj<Mat>(m, true), p, &*this);
CHKERR schur_ptr->setUp(ksp);
elasticFeLhs->preProcessHook = [&]() {
*(elasticFeLhs->matAssembleSwitch) = false;
CHKERR schur_ptr->preProc();
};
elasticFeLhs->postProcessHook = [&]() {
};
elasticBcLhs->preProcessHook = [&]() {
};
elasticBcLhs->preProcessHook = [&]() {
*(elasticBcLhs->matAssembleSwitch) = false;
CHKERR schur_ptr->postProc();
};
}
if (std::abs(alphaRho) > std::numeric_limits<double>::epsilon()) {
Vec xx;
CHKERR VecDuplicate(x, &xx);
CHKERR VecZeroEntries(xx);
CHKERR TS2SetSolution(ts, x, xx);
CHKERR VecDestroy(&xx);
} else {
CHKERR TSSetSolution(ts, x);
}
auto create_post_step_ksp = [this]() {
auto ksp = createKSP(mField.get_comm());
auto set_up = [&]() {
GAUSS>::OpBaseTimesVector<1, 3, 1>;
auto fe_lhs = boost::make_shared<DomainEle>(mField);
auto fe_rhs = boost::make_shared<DomainEle>(mField);
fe_lhs->getUserPolynomialBase() =
boost::shared_ptr<BaseFunction>(new CGGUserPolynomialBase());
fe_rhs->getUserPolynomialBase() =
boost::shared_ptr<BaseFunction>(new CGGUserPolynomialBase());
fe_lhs->getOpPtrVector().push_back(
auto w_ptr = boost::make_shared<MatrixDouble>();
fe_rhs->getOpPtrVector().push_back(
fe_rhs->getOpPtrVector().push_back(new OpRhs(spatialH1Disp, w_ptr));
CHKERR DMMoFEMKSPSetComputeOperators(dmPrjSpatial, elementVolumeName,
fe_lhs, nullptr, nullptr);
CHKERR DMMoFEMKSPSetComputeRHS(dmPrjSpatial, elementVolumeName, fe_rhs,
nullptr, nullptr);
CHKERR KSPAppendOptionsPrefix(ksp, "prjspatial_");
CHKERR KSPSetFromOptions(ksp);
CHKERR KSPSetDM(ksp, dmPrjSpatial);
CHKERR KSPSetUp(ksp);
};
CHK_THROW_MESSAGE(set_up(), "set up");
return ksp;
};
prjKsp = create_post_step_ksp();
prjD = createDMVector(dmPrjSpatial);
prjF = vectorDuplicate(prjD);
auto post_step_fun = [](TS ts) {
MOFEM_LOG("EP", Sev::inform) << "Post step";
CHKERR VecZeroEntries(prjF);
CHKERR KSPSolve(prjKsp, prjF, prjD);
CHKERR VecGhostUpdateBegin(prjD, INSERT_VALUES, SCATTER_FORWARD);
CHKERR VecGhostUpdateEnd(prjD, INSERT_VALUES, SCATTER_FORWARD);
CHKERR DMoFEMMeshToLocalVector(prjDM, prjD, INSERT_VALUES, SCATTER_REVERSE);
};
CHKERR TSSetUp(ts);
CHKERR TSSetPostStep(ts, post_step_fun);
CHKERR TSSolve(ts, PETSC_NULL);
prjKsp.reset();
prjD.reset();
prjF.reset();
prjDM.reset();
// CHKERR TSGetSNES(ts, &snes);
int lin_solver_iterations;
CHKERR SNESGetLinearSolveIterations(snes, &lin_solver_iterations);
MOFEM_LOG("EP", Sev::inform)
<< "Number of linear solver iterations " << lin_solver_iterations;
PetscBool test_cook_flg = PETSC_FALSE;
CHKERR PetscOptionsGetBool(PETSC_NULL, "", "-test_cook", &test_cook_flg,
PETSC_NULL);
if (test_cook_flg) {
constexpr int expected_lin_solver_iterations = 11;
// if (lin_solver_iterations != expected_lin_solver_iterations)
// SETERRQ2(
// PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
// "Expected number of iterations is different than expected %d !=
// %d", lin_solver_iterations, expected_lin_solver_iterations);
}
}
const std::string file) {
if (!dataAtPts) {
boost::shared_ptr<DataAtIntegrationPts>(new DataAtIntegrationPts());
}
auto domain_ops = [&](auto &fe) {
fe.getUserPolynomialBase() =
boost::shared_ptr<BaseFunction>(new CGGUserPolynomialBase());
{HDIV, H1, L2});
fe.getOpPtrVector().push_back(new OpCalculateHVecTensorField<3, 3>(
piolaStress, dataAtPts->getApproxPAtPts()));
fe.getOpPtrVector().push_back(new OpCalculateHTensorTensorField<3, 3>(
bubbleField, dataAtPts->getApproxPAtPts(), MBMAXTYPE));
fe.getOpPtrVector().push_back(new OpCalculateHTensorTensorField<3, 3>(
bubbleField, dataAtPts->getApproxPAtPts(), MBMAXTYPE));
fe.getOpPtrVector().push_back(new OpCalculateTensor2SymmetricFieldValues<3>(
streachTensor, dataAtPts->getLogStreachTensorAtPts(), MBTET));
fe.getOpPtrVector().push_back(new OpCalculateVectorFieldValues<3>(
rotAxis, dataAtPts->getRotAxisAtPts(), MBTET));
// fe.getOpPtrVector().push_back(new OpCalculateTensor2FieldValues<3, 3>(
// materialGradient, dataAtPts->getBigGAtPts(), MBTET));
fe.getOpPtrVector().push_back(new OpCalculateVectorFieldValues<3>(
spatialL2Disp, dataAtPts->getSmallWAtPts(), MBTET));
fe.getOpPtrVector().push_back(new OpCalculateVectorFieldValues<3>(
spatialH1Disp, dataAtPts->getUAtPtr()));
// evaluate derived quantities
fe.getOpPtrVector().push_back(
new OpCalculateRotationAndSpatialGradient(dataAtPts));
// evaluate integration points
fe.getOpPtrVector().push_back(physicalEquations->returnOpJacobian(
tag, true, false, dataAtPts, physicalEquations));
};
CHKERR domain_ops(*(op_loop_side->getSideFEPtr()));
post_proc.getOpPtrVector().push_back(op_loop_side);
post_proc.getOpPtrVector().push_back(new OpPostProcDataStructure(
post_proc.getPostProcMesh(), post_proc.getMapGaussPts(), spatialL2Disp,
CHKERR DMoFEMLoopFiniteElements(dM, skinElement.c_str(), &post_proc);
CHKERR post_proc.writeFile(file.c_str());
}
//! [Getting norms]
auto post_proc_norm_fe =
boost::make_shared<VolumeElementForcesAndSourcesCore>(mField);
auto post_proc_norm_rule_hook = [](int, int, int p) -> int {
return 2 * (p);
};
post_proc_norm_fe->getRuleHook = post_proc_norm_rule_hook;
post_proc_norm_fe->getUserPolynomialBase() =
boost::shared_ptr<BaseFunction>(new CGGUserPolynomialBase());
post_proc_norm_fe->getOpPtrVector(), {L2, H1, HDIV});
enum NORMS { U_NORM_L2 = 0, U_NORM_H1, PIOLA_NORM, U_ERROR_L2, LAST_NORM };
auto norms_vec =
createVectorMPI(mField.get_comm(), LAST_NORM, PETSC_DETERMINE);
CHKERR VecZeroEntries(norms_vec);
auto u_l2_ptr = boost::make_shared<MatrixDouble>();
auto u_h1_ptr = boost::make_shared<MatrixDouble>();
post_proc_norm_fe->getOpPtrVector().push_back(
post_proc_norm_fe->getOpPtrVector().push_back(
post_proc_norm_fe->getOpPtrVector().push_back(
new OpCalcNormL2Tensor1<SPACE_DIM>(u_l2_ptr, norms_vec, U_NORM_L2));
post_proc_norm_fe->getOpPtrVector().push_back(
new OpCalcNormL2Tensor1<SPACE_DIM>(u_h1_ptr, norms_vec, U_NORM_H1));
post_proc_norm_fe->getOpPtrVector().push_back(
new OpCalcNormL2Tensor1<SPACE_DIM>(u_l2_ptr, norms_vec, U_ERROR_L2,
u_h1_ptr));
auto piola_ptr = boost::make_shared<MatrixDouble>();
post_proc_norm_fe->getOpPtrVector().push_back(
post_proc_norm_fe->getOpPtrVector().push_back(
new OpCalcNormL2Tensor2<3, 3>(piola_ptr, norms_vec, PIOLA_NORM));
*post_proc_norm_fe);
CHKERR VecAssemblyBegin(norms_vec);
CHKERR VecAssemblyEnd(norms_vec);
const double *norms;
CHKERR VecGetArrayRead(norms_vec, &norms);
MOFEM_LOG("EP", Sev::inform) << "norm_u: " << std::sqrt(norms[U_NORM_L2]);
MOFEM_LOG("EP", Sev::inform) << "norm_u_h1: " << std::sqrt(norms[U_NORM_H1]);
MOFEM_LOG("EP", Sev::inform)
<< "norm_error_u_l2: " << std::sqrt(norms[U_ERROR_L2]);
MOFEM_LOG("EP", Sev::inform)
<< "norm_piola: " << std::sqrt(norms[PIOLA_NORM]);
CHKERR VecRestoreArrayRead(norms_vec, &norms);
}
//! [Getting norms]
struct SetUpSchurImpl : public EshelbianCore::SetUpSchur {
SmartPetscObj<Mat> p, EshelbianCore *ep_core_ptr)
: SetUpSchur(), mField(m_field), M(m), P(p), epCorePtr(ep_core_ptr) {
if (S) {
"Is expected that schur matrix is not allocated. This is "
"possible only is PC is set up twice");
}
}
virtual ~SetUpSchurImpl() { S.reset(); }
MoFEMErrorCode setUp(KSP solver);
private:
EshelbianCore *epCorePtr;
};
auto get_ents_by_dim = [&](int dim) {
Range ents;
CHKERR mField.get_moab().get_entities_by_dimension(0, dim, ents);
return ents;
};
std::vector<std::string> schur_field_list{
std::vector<std::string> field_list{epCorePtr->piolaStress};
auto create_schur_dm = [&](SmartPetscObj<DM> &dm_sub) {
dm_sub = createDM(mField.get_comm(), "DMMOFEM");
CHKERR DMMoFEMCreateSubDM(dm_sub, epCorePtr->dmElastic, "SUB_SCHUR");
CHKERR DMMoFEMSetSquareProblem(dm_sub, PETSC_TRUE);
CHKERR DMMoFEMSetIsPartitioned(dm_sub, PETSC_TRUE);
CHKERR DMMoFEMAddElement(dm_sub, epCorePtr->elementVolumeName);
CHKERR DMMoFEMAddElement(dm_sub, epCorePtr->naturalBcElement);
auto faces_ptr = boost::make_shared<Range>(get_ents_by_dim(SPACE_DIM - 1));
std::vector<boost::shared_ptr<Range>> dm_range_list{faces_ptr};
if (field_list.size() != dm_range_list.size()) {
SETERRQ(PETSC_COMM_WORLD, MOFEM_DATA_INCONSISTENCY,
"Both ranges should have the same size");
}
int r_idx = 0;
for (auto f : field_list) {
MOFEM_LOG("EP", Sev::inform) << "Add schur field: " << f;
CHKERR DMMoFEMAddSubFieldRow(dm_sub, f.c_str(), dm_range_list[r_idx]);
CHKERR DMMoFEMAddSubFieldCol(dm_sub, f.c_str(), dm_range_list[r_idx]);
++r_idx;
}
CHKERR DMSetUp(dm_sub);
};
auto create_a00_is = [&](SmartPetscObj<IS> &is_a00) {
auto vols = get_ents_by_dim(SPACE_DIM);
std::vector<SmartPetscObj<IS>> is_vec;
std::vector<Range *> range_list_ptr(schur_field_list.size(), nullptr);
range_list_ptr.back() = &vols;
int r_idx = 0;
for (auto f : schur_field_list) {
CHKERR mField.getInterface<ISManager>()->isCreateProblemFieldAndRank(
"ELASTIC_PROBLEM", ROW, f, 0, MAX_DOFS_ON_ENTITY, is,
range_list_ptr[r_idx]);
is_vec.push_back(is);
++r_idx;
}
if (is_vec.size()) {
is_a00 = is_vec[0];
for (auto i = 1; i < is_vec.size(); ++i) {
IS is_union_raw;
CHKERR ISExpand(is_a00, is_vec[i], &is_union_raw);
is_a00 = SmartPetscObj<IS>(is_union_raw);
}
CHKERR ISSort(is_a00);
}
};
PC pc;
CHKERR KSPSetFromOptions(solver);
CHKERR KSPGetPC(solver, &pc);
PetscBool is_pcfs = PETSC_FALSE;
PetscObjectTypeCompare((PetscObject)pc, PCFIELDSPLIT, &is_pcfs);
if (is_pcfs) {
SmartPetscObj<DM> schur_dm, a00_dm;
CHKERR create_schur_dm(schur_dm);
CHKERR create_a00_is(isA00);
if (S) {
"Is expected that schur matrix is not allocated. This is "
"possible only is PC is set up twice");
}
S = createDMMatrix(schur_dm);
auto set_ops = [&]() {
std::vector<boost::shared_ptr<Range>> ranges_list(schur_field_list.size(),
nullptr);
ranges_list.back() =
boost::make_shared<Range>(get_ents_by_dim(SPACE_DIM));
std::vector<SmartPetscObj<AO>> ao_list(schur_field_list.size(),
std::vector<SmartPetscObj<Mat>> mat_list(schur_field_list.size(),
std::vector<bool> symm_list(schur_field_list.size(), false);
auto dm_is = getDMSubData(schur_dm)->getSmartRowIs();
aoUp = createAOMappingIS(dm_is, PETSC_NULL);
ao_list.back() = aoUp;
mat_list.back() = S;
epCorePtr->elasticFeLhs->getOpPtrVector().push_front(
epCorePtr->elasticFeLhs->getOpPtrVector().push_back(
new OpSchurAssembleEnd<SCHUR_DGESV>(schur_field_list, ranges_list,
ao_list, mat_list, symm_list,
false));
epCorePtr->elasticBcLhs->getOpPtrVector().push_front(
epCorePtr->elasticBcLhs->getOpPtrVector().push_back(
new OpSchurAssembleEnd<SCHUR_DGESV>(schur_field_list, ranges_list,
ao_list, mat_list, symm_list,
false));
};
auto set_pc = [&]() {
CHKERR PCFieldSplitSetIS(pc, NULL, isA00);
CHKERR PCFieldSplitSetSchurPre(pc, PC_FIELDSPLIT_SCHUR_PRE_USER, S);
};
CHKERR set_ops();
CHKERR set_pc();
} else {
epCorePtr->elasticFeLhs->getOpPtrVector().push_front(
epCorePtr->elasticFeLhs->getOpPtrVector().push_back(
new OpSchurAssembleEnd<SCHUR_DGESV>({}, {}, {}, {}, {}));
epCorePtr->elasticBcLhs->getOpPtrVector().push_front(
epCorePtr->elasticBcLhs->getOpPtrVector().push_back(
new OpSchurAssembleEnd<SCHUR_DGESV>({}, {}, {}, {}, {}));
}
}
MOFEM_LOG("EP", Sev::verbose) << "Zero Schur";
CHKERR MatZeroEntries(S);
}
CHKERR MatZeroEntries(M);
CHKERR MatZeroEntries(P);
}
if (S) {
MOFEM_LOG("EP", Sev::verbose) << "Assemble Schur";
CHKERR MatAssemblyBegin(S, MAT_FINAL_ASSEMBLY);
CHKERR MatAssemblyEnd(S, MAT_FINAL_ASSEMBLY);
}
CHKERR MatAssemblyBegin(M, MAT_FINAL_ASSEMBLY);
CHKERR MatAssemblyEnd(M, MAT_FINAL_ASSEMBLY);
CHKERR MatAssemblyBegin(P, MAT_FINAL_ASSEMBLY);
CHKERR MatAssemblyEnd(P, MAT_FINAL_ASSEMBLY);
CHKERR MatAXPY(P, 1, M, SAME_NONZERO_PATTERN);
}
boost::shared_ptr<EshelbianCore::SetUpSchur>
EshelbianCore *ep_core_ptr) {
return boost::shared_ptr<SetUpSchur>(
new SetUpSchurImpl(m_field, m, p, ep_core_ptr));
}
auto bc_mng = mField.getInterface<BcManager>();
CHKERR bc_mng->pushMarkDOFsOnEntities<DisplacementCubitBcData>(
"", piolaStress, false, false);
bcSpatialDispVecPtr = boost::make_shared<BcDispVec>();
for (auto bc : bc_mng->getBcMapByBlockName()) {
if (auto disp_bc = bc.second->dispBcPtr) {
MOFEM_LOG("EP", Sev::noisy) << *disp_bc;
std::vector<double> block_attributes(6, 0.);
if (disp_bc->data.flag1 == 1) {
block_attributes[0] = disp_bc->data.value1;
block_attributes[3] = 1;
}
if (disp_bc->data.flag2 == 1) {
block_attributes[1] = disp_bc->data.value2;
block_attributes[4] = 1;
}
if (disp_bc->data.flag3 == 1) {
block_attributes[2] = disp_bc->data.value3;
block_attributes[5] = 1;
}
auto faces = bc.second->bcEnts.subset_by_dimension(2);
bcSpatialDispVecPtr->emplace_back(bc.first, block_attributes, faces);
}
}
// old way of naming blocksets for displacement BCs
CHKERR getBc(bcSpatialDispVecPtr, "SPATIAL_DISP_BC", 6);
}
auto bc_mng = mField.getInterface<BcManager>();
CHKERR bc_mng->pushMarkDOFsOnEntities<ForceCubitBcData>("", piolaStress,
false, false);
bcSpatialTraction = boost::make_shared<TractionBcVec>();
for (auto bc : bc_mng->getBcMapByBlockName()) {
if (auto force_bc = bc.second->forceBcPtr) {
std::vector<double> block_attributes(6, 0.);
block_attributes[0] = -force_bc->data.value3 * force_bc->data.value1;
block_attributes[3] = 1;
block_attributes[1] = -force_bc->data.value4 * force_bc->data.value1;
block_attributes[4] = 1;
block_attributes[2] = -force_bc->data.value5 * force_bc->data.value1;
block_attributes[5] = 1;
auto faces = bc.second->bcEnts.subset_by_dimension(2);
bcSpatialTraction->emplace_back(bc.first, block_attributes, faces);
}
}
CHKERR getBc(bcSpatialTraction, "SPATIAL_TRACTION_BC", 6);
}
} // namespace EshelbianPlasticity
static Index< 'p', 3 > p
Implementation of tonsorial bubble base div(v) = 0.
#define NBVOLUMETET_CCG_BUBBLE(P)
Bubble function for CGG H div space.
#define DM_NO_ELEMENT
Definition: DMMoFEM.hpp:10
Eshelbian plasticity interface.
#define MOFEM_LOG_SYNCHRONISE(comm)
Synchronise "SYNC" channel.
Definition: LogManager.hpp:345
#define MOFEM_LOG_C(channel, severity, format,...)
Definition: LogManager.hpp:311
static PetscErrorCode ierr
constexpr int SPACE_DIM
ElementsAndOps< SPACE_DIM >::DomainEle DomainEle
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 1, FIELD_DIM > OpDomainMass
ElementsAndOps< SPACE_DIM >::BoundaryEle BoundaryEle
cholesky decomposition
@ QUIET
Definition: definitions.h:208
@ NOISY
Definition: definitions.h:211
@ ROW
Definition: definitions.h:123
@ MF_ZERO
Definition: definitions.h:98
@ MF_EXIST
Definition: definitions.h:100
#define MAX_DOFS_ON_ENTITY
Maximal number of DOFs on entity.
Definition: definitions.h:236
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
Definition: definitions.h:60
@ USER_BASE
user implemented approximation base
Definition: definitions.h:68
@ DEMKOWICZ_JACOBI_BASE
Definition: definitions.h:66
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
Definition: definitions.h:595
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
@ L2
field with C-1 continuity
Definition: definitions.h:88
@ H1
continuous field
Definition: definitions.h:85
@ HDIV
field with continuous normal traction
Definition: definitions.h:87
#define MYPCOMM_INDEX
default communicator number PCOMM
Definition: definitions.h:215
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:483
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
@ MOFEM_NOT_IMPLEMENTED
Definition: definitions.h:32
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
#define CHKERR
Inline error check.
Definition: definitions.h:535
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:440
FieldEvaluatorInterface::SetPtsData SetPtsData
PostProcEleByDim< SPACE_DIM >::SideEle SideEle
const int dim
PetscErrorCode ShapeDiffMBTET(double *diffN)
calculate derivatives of shape functions
Definition: fem_tools.c:319
PetscErrorCode ShapeMBTET(double *N, const double *G_X, const double *G_Y, const double *G_Z, int DIM)
calculate shape functions
Definition: fem_tools.c:306
FTensor::Index< 'm', SPACE_DIM > m
static double phi
virtual MoFEMErrorCode add_finite_element(const std::string &fe_name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
add finite element
virtual MoFEMErrorCode build_finite_elements(int verb=DEFAULT_VERBOSITY)=0
Build finite elements.
virtual MoFEMErrorCode modify_finite_element_add_field_col(const std::string &fe_name, const std::string name_row)=0
set field col which finite element use
virtual MoFEMErrorCode add_ents_to_finite_element_by_type(const EntityHandle entities, const EntityType type, const std::string &name, const bool recursive=true)=0
add entities to finite element
virtual MoFEMErrorCode modify_finite_element_add_field_data(const std::string &fe_name, const std::string name_filed)=0
set finite element field data
virtual MoFEMErrorCode modify_finite_element_add_field_row(const std::string &fe_name, const std::string name_row)=0
set field row which finite element use
virtual const Field * get_field_structure(const std::string &name, enum MoFEMTypes bh=MF_EXIST) const =0
get field structure
virtual MoFEMErrorCode build_fields(int verb=DEFAULT_VERBOSITY)=0
virtual MoFEMErrorCode set_field_order(const EntityHandle meshset, const EntityType type, const std::string &name, const ApproximationOrder order, int verb=DEFAULT_VERBOSITY)=0
Set order approximation of the entities in the field.
virtual MoFEMErrorCode add_ents_to_field_by_type(const Range &ents, const EntityType type, const std::string &name, int verb=DEFAULT_VERBOSITY)=0
Add entities to field meshset.
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:308
virtual MoFEMErrorCode loop_finite_elements(const std::string problem_name, const std::string &fe_name, FEMethod &method, boost::shared_ptr< NumeredEntFiniteElement_multiIndex > fe_ptr=nullptr, MoFEMTypes bh=MF_EXIST, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr(), int verb=DEFAULT_VERBOSITY)=0
Make a loop over finite elements.
MoFEMErrorCode getCubitMeshsetPtr(const int ms_id, const CubitBCType cubit_bc_type, const CubitMeshSets **cubit_meshset_ptr) const
get cubit meshset
MoFEMErrorCode removeDofsOnEntities(const std::string problem_name, const std::string field_name, const Range ents, const int lo_coeff=0, const int hi_coeff=MAX_DOFS_ON_ENTITY, const int lo_order=0, const int hi_order=100, int verb=VERBOSE, const bool debug=false)
Remove DOFs from problem.
auto bit
set bit
FTensor::Index< 'i', SPACE_DIM > i
const double v
phase velocity of light in medium (cm/ns)
MoFEM::TsCtx * ts_ctx
Definition: level_set.cpp:1884
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
FormsIntegrators< DomainEleOp >::Assembly< USER_ASSEMBLE >::LinearForm< GAUSS >::OpSource< 1, 3 > OpBodyForce
double dd_f_linear(const double v)
double f_log(const double v)
SmartPetscObj< DM > prjDM
static boost::function< double(const double)> d_f
double d_f_linear(const double v)
static boost::function< double(const double)> f
double dd_f_log(const double v)
double f_linear(const double v)
MoFEMErrorCode CGG_BubbleBase_MBTET(const int p, const double *N, const double *diffN, FTensor::Tensor2< FTensor::PackPtr< double *, 9 >, 3, 3 > &phi, const int gdim)
Calculate CGGT tonsorial bubble base.
static boost::function< double(const double)> dd_f
SmartPetscObj< Vec > prjD
Unknown vector for projection spatial displacement.
SmartPetscObj< Vec > prjF
double d_f_log(const double v)
static enum RotSelector rotSelector
SmartPetscObj< KSP > prjKsp
KSP for projection spatial displacement on H1 space.
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
UBlasMatrix< double > MatrixDouble
Definition: Types.hpp:77
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:40
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
constexpr AssemblyType A
constexpr double t
plate stiffness
Definition: plate.cpp:59
constexpr auto field_name
BcDisp(std::string name, std::vector< double > &attr, Range &faces)
BcRot(std::string name, std::vector< double > &attr, Range &faces)
MoFEMErrorCode getValueHdivForCGGBubble(MatrixDouble &pts)
MoFEMErrorCode getValue(MatrixDouble &pts, boost::shared_ptr< BaseFunctionCtx > ctx_ptr)
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, BaseFunctionUnknownInterface **iface) const
static boost::shared_ptr< SetUpSchur > createSetUpSchur(MoFEM::Interface &m_field, SmartPetscObj< Mat > m, SmartPetscObj< Mat > p, EshelbianCore *ep_core_ptr)
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
Getting interface of core database.
boost::shared_ptr< FaceElementForcesAndSourcesCore > elasticBcLhs
boost::shared_ptr< VolumeElementForcesAndSourcesCore > elasticFeLhs
MoFEMErrorCode postProcessResults(const int tag, const std::string file)
MoFEMErrorCode addBoundaryFiniteElement(const EntityHandle meshset=0)
MoFEMErrorCode addDMs(const BitRefLevel bit=BitRefLevel().set(0))
boost::shared_ptr< VolumeElementForcesAndSourcesCore > elasticFeRhs
MoFEMErrorCode setElasticElementOps(const int tag)
boost::shared_ptr< DataAtIntegrationPts > dataAtPts
MoFEMErrorCode solveElastic(TS ts, Mat m, Vec f, Vec x)
MoFEMErrorCode getBc(boost::shared_ptr< BC > &bc_vec_ptr, const std::string block_name, const int nb_attributes)
MoFEMErrorCode setBaseVolumeElementOps(const int tag, const bool do_rhs, const bool do_lhs, boost::shared_ptr< VolumeElementForcesAndSourcesCore > &fe)
boost::shared_ptr< BcRotVec > bcSpatialRotationVecPtr
MoFEMErrorCode setContactElementOps(boost::shared_ptr< FaceElementForcesAndSourcesCore > &fe_rhs, boost::shared_ptr< FaceElementForcesAndSourcesCore > &fe_lhs)
MoFEMErrorCode setFaceElementOps(const bool add_elastic, const bool add_material, boost::shared_ptr< FaceElementForcesAndSourcesCore > &fe_rhs, boost::shared_ptr< FaceElementForcesAndSourcesCore > &fe_lhs)
EshelbianCore(MoFEM::Interface &m_field)
SmartPetscObj< DM > dM
Coupled problem all fields.
MoFEMErrorCode addVolumeFiniteElement(const EntityHandle meshset=0)
SmartPetscObj< DM > dmElastic
Elastic problem.
boost::shared_ptr< BcDispVec > bcSpatialDispVecPtr
boost::shared_ptr< PhysicalEquations > physicalEquations
MoFEMErrorCode setVolumeElementOps(const int tag, const bool add_elastic, const bool add_material, boost::shared_ptr< VolumeElementForcesAndSourcesCore > &fe_rhs, boost::shared_ptr< VolumeElementForcesAndSourcesCore > &fe_lhs)
boost::shared_ptr< FaceElementForcesAndSourcesCore > contactRhs
MoFEMErrorCode gettingNorms()
[Getting norms]
boost::shared_ptr< TractionFreeBc > bcSpatialFreeTraction
boost::shared_ptr< TractionBcVec > bcSpatialTraction
MoFEMErrorCode addFields(const EntityHandle meshset=0)
boost::shared_ptr< FaceElementForcesAndSourcesCore > elasticBcRhs
SmartPetscObj< DM > dmPrjSpatial
Projection spatial displacement.
MoFEMErrorCode getTractionFreeBc(const EntityHandle meshset, boost::shared_ptr< TractionFreeBc > &bc_ptr, const std::string contact_set_name)
Remove all, but entities where kinematic constrains are applied.
int operator()(int p_row, int p_col, int p_data) const
virtual MoFEMErrorCode evaluateRhs(EntData &data)=0
virtual MoFEMErrorCode evaluateLhs(EntData &data)=0
MoFEMErrorCode doWork(int side, EntityType type, EntData &data)
TractionBc(std::string name, std::vector< double > &attr, Range &faces)
int operator()(int p_row, int p_col, int p_data) const
Set integration rule to boundary elements.
Add operators pushing bases from local to physical configuration.
Simple interface for fast problem set-up.
Definition: BcManager.hpp:25
virtual moab::Interface & get_moab()=0
virtual bool check_finite_element(const std::string &name) const =0
Check if finite element is in database.
virtual MoFEMErrorCode build_adjacencies(const Range &ents, int verb=DEFAULT_VERBOSITY)=0
build adjacencies
virtual MPI_Comm & get_comm() const =0
virtual MoFEMErrorCode add_field(const std::string &name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
Add field.
Deprecated interface functions.
Definition of the displacement bc data structure.
Definition: BCData.hpp:72
Class used to pass element data to calculate base functions on tet,triangle,edge.
Data on single entity (This is passed as argument to DataOperator::doWork)
data structure for finite element entity
std::array< boost::ptr_vector< EntData >, MBMAXTYPE > dataOnEntities
Field evaluator interface.
boost::shared_ptr< SPD > getData(const double *ptr=nullptr, const int nb_eval_points=0, const double eps=1e-12, VERBOSITY_LEVELS verb=QUIET)
Get the Data object.
Provide data structure for (tensor) field approximation.
Definition of the force bc data structure.
Definition: BCData.hpp:134
@ OPROW
operator doWork function is executed on FE rows
structure to get information form mofem into EntitiesFieldData
Section manager is used to create indexes and sections.
Definition: ISManager.hpp:23
Interface for managing meshsets containing materials and boundary conditions.
Natural boundary conditions.
Definition: Natural.hpp:57
Get norm of input MatrixDouble for Tensor1.
Get norm of input MatrixDouble for Tensor2.
Calculate tenor field using tensor base, i.e. Hdiv/Hcurl.
Calculate divergence of tonsorial field using vectorial base.
Calculate tenor field using vectorial base, i.e. Hdiv/Hcurl.
Calculate trace of vector (Hdiv/Hcurl) space.
Calculate symmetric tensor field rates ant integratio pts.
Calculate symmetric tensor field values at integration pts.
Approximate field values for given petsc vector.
Get values at integration pts for tensor filed rank 1, i.e. vector field.
Element used to execute operators on side of the element.
Clear Schur complement internal data.
Definition: Schur.hpp:22
Assemble Schur complement.
Definition: Schur.hpp:104
Problem manager is used to build and partition problems.
intrusive_ptr for managing petsc objects
FEMethodsSequence & getLoopsMonitor()
Get the loops to do Monitor object.
Definition: TsCtx.hpp:108
base class for all interface classes
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.
Base volume element used to integrate on skeleton.
[Push operators to pipeline]
Set integration rule.
VolEle::UserDataOperator VolOp
VolumeElementForcesAndSourcesCore VolEle