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

Explicit first order conservation laws for solid dynamics

/**
* \file dynamic_first_order_con_law.cpp
* \example dynamic_first_order_con_law.cpp
*
* Explicit first order conservation laws for solid dynamics
*
*/
#include <MoFEM.hpp>
using namespace MoFEM;
template <typename T> inline double trace(FTensor::Tensor2<T, 2, 2> &t_stress) {
constexpr double third = boost::math::constants::third<double>();
return (t_stress(0, 0) + t_stress(1, 1));
};
template <typename T> inline double trace(FTensor::Tensor2<T, 3, 3> &t_stress) {
constexpr double third = boost::math::constants::third<double>();
return (t_stress(0, 0) + t_stress(1, 1) + t_stress(2, 2));
};
constexpr int SPACE_DIM =
EXECUTABLE_DIMENSION; //< Space dimension of problem, mesh
using DomainEleOp = DomainEle::UserDataOperator;
using BoundaryEle =
using BoundaryEleOp = BoundaryEle::UserDataOperator;
template <int DIM> struct PostProcEleByDim;
template <> struct PostProcEleByDim<2> {
};
template <> struct PostProcEleByDim<3> {
};
GAUSS>::OpBaseTimesVector<1, SPACE_DIM, 0>;
DomainNaturalBC::OpFlux<NaturalMeshsetTypeVectorScaling<BLOCKSET>, 1,
IntegrationType::GAUSS>::OpBaseTimesVector<1, SPACE_DIM * SPACE_DIM, 1>;
using OpForce = BoundaryNaturalBC::OpFlux<NaturalForceMeshsets, 1, SPACE_DIM>;
/** \brief Save field DOFS on vertices/tags
*/
constexpr double omega = 1.;
constexpr double young_modulus = 1.;
constexpr double poisson_ratio = 0.;
double bulk_modulus_K = young_modulus / (3. * (1. - 2. * poisson_ratio));
double shear_modulus_G = young_modulus / (2. * (1. + poisson_ratio));
double mu = young_modulus / (2. * (1. + poisson_ratio));
((1. + poisson_ratio) * (1. - 2. * poisson_ratio));
// Operator to Calculate F
template <int DIM_0, int DIM_1>
struct OpCalculateFStab : public ForcesAndSourcesCore::UserDataOperator {
OpCalculateFStab(boost::shared_ptr<MatrixDouble> def_grad_ptr,
boost::shared_ptr<MatrixDouble> def_grad_stab_ptr,
boost::shared_ptr<MatrixDouble> def_grad_dot_ptr,
double tau_F_ptr, double xi_F_ptr,
boost::shared_ptr<MatrixDouble> grad_x_ptr,
boost::shared_ptr<MatrixDouble> grad_vel_ptr)
defGradPtr(def_grad_ptr), defGradStabPtr(def_grad_stab_ptr),
defGradDotPtr(def_grad_dot_ptr), tauFPtr(tau_F_ptr), xiF(xi_F_ptr),
gradxPtr(grad_x_ptr), gradVelPtr(grad_vel_ptr) {}
MoFEMErrorCode doWork(int side, EntityType type,
DataForcesAndSourcesCore::EntData &data) {
// Define Indicies
// Number of Gauss points
const size_t nb_gauss_pts = getGaussPts().size2();
defGradStabPtr->resize(DIM_0 * DIM_1, nb_gauss_pts, false);
defGradStabPtr->clear();
// Extract matrix from data matrix
// tau_F = alpha deltaT
auto tau_F = tauFPtr;
double xi_F = xiF;
for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
// Stabilised Deformation Gradient
t_Fstab(i, j) = t_F(i, j) + tau_F * (t_gradVel(i, j) - t_F_dot(i, j)) +
xi_F * (t_gradx(i, j) - t_F(i, j));
++t_F;
++t_Fstab;
++t_gradVel;
++t_F_dot;
++t_gradx;
}
}
private:
double tauFPtr;
double xiF;
boost::shared_ptr<MatrixDouble> defGradPtr;
boost::shared_ptr<MatrixDouble> defGradStabPtr;
boost::shared_ptr<MatrixDouble> defGradDotPtr;
boost::shared_ptr<MatrixDouble> gradxPtr;
boost::shared_ptr<MatrixDouble> gradVelPtr;
};
// Operator to Calculate P
template <int DIM_0, int DIM_1>
struct OpCalculatePiola : public ForcesAndSourcesCore::UserDataOperator {
OpCalculatePiola(double shear_modulus, double bulk_modulus, double m_u,
double lambda_lamme,
boost::shared_ptr<MatrixDouble> first_piola_ptr,
boost::shared_ptr<MatrixDouble> def_grad_ptr)
shearModulus(shear_modulus), bulkModulus(bulk_modulus), mU(m_u),
lammeLambda(lambda_lamme), firstPiolaPtr(first_piola_ptr),
defGradPtr(def_grad_ptr) {}
MoFEMErrorCode doWork(int side, EntityType type,
DataForcesAndSourcesCore::EntData &data) {
// Define Indicies
// Define Kronecker Delta
// Number of Gauss points
const size_t nb_gauss_pts = getGaussPts().size2();
// Resize Piola
firstPiolaPtr->resize(DIM_0 * DIM_1, nb_gauss_pts, false); // ignatios check
firstPiolaPtr->clear();
// Extract matrix from data matrix
const double two_o_three = 2. / 3.;
const double trace_t_dk = DIM_0;
for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
t_P(i, j) = shearModulus * (t_F(i, j) + t_F(j, i) - 2. * t_kd(i, j) -
two_o_three * trace(t_F) * t_kd(i, j) +
two_o_three * trace_t_dk * t_kd(i, j)) +
bulkModulus * trace(t_F) * t_kd(i, j) -
bulkModulus * trace_t_dk * t_kd(i, j);
++t_F;
++t_P;
}
}
private:
double shearModulus;
double bulkModulus;
double mU;
double lammeLambda;
boost::shared_ptr<MatrixDouble> firstPiolaPtr;
boost::shared_ptr<MatrixDouble> defGradPtr;
};
template <int DIM>
struct OpCalculateDisplacement : public ForcesAndSourcesCore::UserDataOperator {
OpCalculateDisplacement(boost::shared_ptr<MatrixDouble> spatial_pos_ptr,
boost::shared_ptr<MatrixDouble> reference_pos_ptr,
boost::shared_ptr<MatrixDouble> u_ptr)
xPtr(spatial_pos_ptr), XPtr(reference_pos_ptr), uPtr(u_ptr) {}
MoFEMErrorCode doWork(int side, EntityType type,
DataForcesAndSourcesCore::EntData &data) {
// Define Indicies
FTensor::Index<'i', DIM> i;
// Number of Gauss points
const size_t nb_gauss_pts = getGaussPts().size2();
uPtr->resize(DIM, nb_gauss_pts, false); // ignatios check
uPtr->clear();
// Extract matrix from data matrix
for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
t_u(i) = t_x(i) - t_X(i);
++t_u;
++t_x;
++t_X;
}
}
private:
boost::shared_ptr<MatrixDouble> xPtr;
boost::shared_ptr<MatrixDouble> XPtr;
boost::shared_ptr<MatrixDouble> uPtr;
};
template <int DIM_0, int DIM_1>
: public ForcesAndSourcesCore::UserDataOperator {
double shear_modulus, double bulk_modulus, double m_u,
double lambda_lamme, boost::shared_ptr<MatrixDouble> first_piola_ptr,
boost::shared_ptr<MatrixDouble> def_grad_ptr,
boost::shared_ptr<MatrixDouble> inv_def_grad_ptr,
boost::shared_ptr<VectorDouble> det)
shearModulus(shear_modulus), bulkModulus(bulk_modulus), mU(m_u),
lammeLambda(lambda_lamme), firstPiolaPtr(first_piola_ptr),
defGradPtr(def_grad_ptr), invDefGradPtr(inv_def_grad_ptr), dEt(det) {}
MoFEMErrorCode doWork(int side, EntityType type,
DataForcesAndSourcesCore::EntData &data) {
// Define Indicies
// Define Kronecker Delta
// Number of Gauss points
const size_t nb_gauss_pts = getGaussPts().size2();
// Resize Piola
firstPiolaPtr->resize(DIM_0 * DIM_1, nb_gauss_pts, false); // ignatios check
firstPiolaPtr->clear();
// Extract matrix from data matrix
auto t_det = getFTensor0FromVec<1>(*dEt);
const double two_o_three = 2. / 3.;
const double one_o_three = 1. / 3.;
const double bulk_mod = bulkModulus;
const double shear_mod = shearModulus;
for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
// Nearly incompressible NH
// volumetric part
t_P(i, j) = bulk_mod * (t_det - 1.) * t_det * t_inv_F(j, i);
// deviatoric part
t_P(i, j) +=
shear_mod * pow(t_det, two_o_three) *
(t_F(i, j) - one_o_three * (t_F(l, k) * t_F(l, k)) * t_inv_F(j, i));
++t_F;
++t_P;
++t_inv_F;
++t_det;
}
}
private:
double shearModulus;
double bulkModulus;
double mU;
double lammeLambda;
boost::shared_ptr<MatrixDouble> firstPiolaPtr;
boost::shared_ptr<MatrixDouble> defGradPtr;
boost::shared_ptr<MatrixDouble> invDefGradPtr;
boost::shared_ptr<VectorDouble> dEt;
};
template <int DIM_0, int DIM_1>
: public ForcesAndSourcesCore::UserDataOperator {
boost::shared_ptr<MatrixDouble> def_grad_ptr,
boost::shared_ptr<MatrixDouble> grad_tensor_ptr)
defGradPtr(def_grad_ptr), gradTensorPtr(grad_tensor_ptr) {}
MoFEMErrorCode doWork(int side, EntityType type,
DataForcesAndSourcesCore::EntData &data) {
// Define Indicies
// Define Kronecker Delta
// Number of Gauss points
const size_t nb_gauss_pts = getGaussPts().size2();
// Resize Piola
defGradPtr->resize(DIM_0 * DIM_1, nb_gauss_pts, false);
defGradPtr->clear();
// Extract matrix from data matrix
for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
t_F(i, j) = t_H(i, j) + t_kd(i, j);
++t_F;
++t_H;
}
}
private:
boost::shared_ptr<MatrixDouble> gradTensorPtr;
boost::shared_ptr<MatrixDouble> defGradPtr;
};
struct Example;
struct TSPrePostProc {
TSPrePostProc() = default;
virtual ~TSPrePostProc() = default;
/**
* @brief Used to setup TS solver
*
* @param ts
* @return MoFEMErrorCode
*/
// SmartPetscObj<VecScatter> getScatter(Vec x, Vec y, enum FR fr);
static MoFEMErrorCode tsPostStage(TS ts, PetscReal stagetime,
PetscInt stageindex, Vec *Y);
static MoFEMErrorCode tsPostStep(TS ts);
static MoFEMErrorCode tsPreStep(TS ts);
};
static boost::weak_ptr<TSPrePostProc> tsPrePostProc;
double getScale(const double time) {
return sin(2. * M_PI * MoFEM::TimeScale::getScale(time));
};
};
struct CommonData {
SmartPetscObj<Mat> M; ///< Mass matrix
SmartPetscObj<KSP> ksp; ///< Linear solver
};
struct Example {
Example(MoFEM::Interface &m_field) : mField(m_field) {}
private:
friend struct TSPrePostProc;
struct DynamicFirstOrderConsSinusTimeScale : public MoFEM::TimeScale {
double getScale(const double time) { return 0.001 * sin(0.1 * time); };
};
struct DynamicFirstOrderConsConstantTimeScale : public MoFEM::TimeScale {
double getScale(const double time) { return 0.001; };
};
};
//! [Run problem]
}
//! [Run problem]
//! [Read mesh]
CHKERR simple->getOptions();
CHKERR simple->loadFile();
}
//! [Read mesh]
//! [Set up problem]
enum bases { AINSWORTH, DEMKOWICZ, LASBASETOPT };
const char *list_bases[LASBASETOPT] = {"ainsworth", "demkowicz"};
PetscInt choice_base_value = AINSWORTH;
CHKERR PetscOptionsGetEList(PETSC_NULL, NULL, "-base", list_bases,
LASBASETOPT, &choice_base_value, PETSC_NULL);
switch (choice_base_value) {
case AINSWORTH:
MOFEM_LOG("WORLD", Sev::inform)
<< "Set AINSWORTH_LEGENDRE_BASE for displacements";
break;
case DEMKOWICZ:
MOFEM_LOG("WORLD", Sev::inform)
<< "Set DEMKOWICZ_JACOBI_BASE for displacements";
break;
default:
break;
}
// Add field
CHKERR simple->addDomainField("V", H1, base, SPACE_DIM);
CHKERR simple->addBoundaryField("V", H1, base, SPACE_DIM);
CHKERR simple->addDomainField("F", H1, base, SPACE_DIM * SPACE_DIM);
CHKERR simple->addDataField("x_1", H1, base, SPACE_DIM);
CHKERR simple->addDataField("x_2", H1, base, SPACE_DIM);
CHKERR simple->addDataField("F_0", H1, base, SPACE_DIM * SPACE_DIM);
CHKERR simple->addDataField("F_dot", H1, base, SPACE_DIM * SPACE_DIM);
CHKERR simple->addDataField("GEOMETRY", H1, base, SPACE_DIM);
int order = 2;
CHKERR PetscOptionsGetInt(PETSC_NULL, "", "-order", &order, PETSC_NULL);
CHKERR simple->setFieldOrder("V", order);
CHKERR simple->setFieldOrder("F", order);
CHKERR simple->setFieldOrder("F_0", order);
CHKERR simple->setFieldOrder("F_dot", order);
CHKERR simple->setFieldOrder("x_1", order);
CHKERR simple->setFieldOrder("x_2", order);
CHKERR simple->setFieldOrder("GEOMETRY", order);
CHKERR simple->setUp();
auto project_ho_geometry = [&]() {
Projection10NodeCoordsOnField ent_method_x(mField, "x_1");
CHKERR mField.loop_dofs("x_1", ent_method_x);
Projection10NodeCoordsOnField ent_method_x_2(mField, "x_2");
CHKERR mField.loop_dofs("x_2", ent_method_x_2);
Projection10NodeCoordsOnField ent_method(mField, "GEOMETRY");
return mField.loop_dofs("GEOMETRY", ent_method);
};
CHKERR project_ho_geometry();
}
//! [Set up problem]
//! [Boundary condition]
auto bc_mng = mField.getInterface<BcManager>();
auto *pipeline_mng = mField.getInterface<PipelineManager>();
auto time_scale = boost::make_shared<TimeScale>();
PetscBool sin_time_function = PETSC_FALSE;
CHKERR PetscOptionsGetBool(PETSC_NULL, "", "-sin_time_function",
&sin_time_function, PETSC_NULL);
if (sin_time_function)
time_scale = boost::make_shared<DynamicFirstOrderConsSinusTimeScale>();
else
time_scale = boost::make_shared<DynamicFirstOrderConsConstantTimeScale>();
pipeline_mng->getBoundaryExplicitRhsFE().reset();
pipeline_mng->getOpBoundaryExplicitRhsPipeline(), {NOSPACE}, "GEOMETRY");
CHKERR BoundaryNaturalBC::AddFluxToPipeline<OpForce>::add(
pipeline_mng->getOpBoundaryExplicitRhsPipeline(), mField, "V",
{time_scale}, "FORCE", Sev::inform);
auto integration_rule = [](int, int, int approx_order) {
return 2 * approx_order;
};
CHKERR pipeline_mng->setBoundaryExplicitRhsIntegrationRule(integration_rule);
CHKERR pipeline_mng->setDomainExplicitRhsIntegrationRule(integration_rule);
CHKERR bc_mng->removeBlockDOFsOnEntities<DisplacementCubitBcData>(
simple->getProblemName(), "V");
auto get_pre_proc_hook = [&]() {
mField, pipeline_mng->getDomainExplicitRhsFE(), {time_scale});
};
pipeline_mng->getDomainExplicitRhsFE()->preProcessHook = get_pre_proc_hook();
}
//! [Boundary condition]
MoFEMErrorCode TSPrePostProc::tsPostStage(TS ts, PetscReal stagetime,
PetscInt stageindex, Vec *Y) {
// cerr << "tsPostStage " <<"\n";
if (auto ptr = tsPrePostProc.lock()) {
auto &m_field = ptr->fsRawPtr->mField;
auto *simple = m_field.getInterface<Simple>();
auto *pipeline_mng = m_field.getInterface<PipelineManager>();
auto fb = m_field.getInterface<FieldBlas>();
double dt;
CHKERR TSGetTimeStep(ts, &dt);
double time;
CHKERR TSGetTime(ts, &time);
PetscInt num_stages;
Vec *stage_solutions;
CHKERR TSGetStages(ts, &num_stages, &stage_solutions);
PetscPrintf(PETSC_COMM_WORLD, "Check timestep %d time %e dt %e\n",
num_stages, time, dt);
const double inv_num_step = (double)num_stages;
CHKERR fb->fieldCopy(1., "x_1", "x_2");
CHKERR fb->fieldAxpy(dt, "V", "x_2");
CHKERR fb->fieldCopy(1., "x_2", "x_1");
CHKERR fb->fieldCopy(-inv_num_step / dt, "F_0", "F_dot");
CHKERR fb->fieldAxpy(inv_num_step / dt, "F", "F_dot");
CHKERR fb->fieldCopy(1., "F", "F_0");
}
}
if (auto ptr = tsPrePostProc.lock()) {
auto &m_field = ptr->fsRawPtr->mField;
auto fb = m_field.getInterface<FieldBlas>();
double dt;
CHKERR TSGetTimeStep(ts, &dt);
double time;
CHKERR TSGetTime(ts, &time);
}
}
if (auto ptr = tsPrePostProc.lock()) {
auto &m_field = ptr->fsRawPtr->mField;
auto *simple = m_field.getInterface<Simple>();
auto *pipeline_mng = m_field.getInterface<PipelineManager>();
double dt;
CHKERR TSGetTimeStep(ts, &dt);
double time;
CHKERR TSGetTime(ts, &time);
int step_num;
CHKERR TSGetStepNumber(ts, &step_num);
}
}
//! [Push operators to pipeline]
auto *pipeline_mng = mField.getInterface<PipelineManager>();
auto get_body_force = [this](const double, const double, const double) {
t_source(i) = 0.;
t_source(0) = 0.1;
t_source(1) = 1.;
return t_source;
};
// specific time scaling
auto get_time_scale = [this](const double time) {
return sin(time * omega * M_PI);
};
auto apply_rhs = [&](auto &pip) {
"GEOMETRY");
// Calculate Gradient of velocity
auto mat_v_grad_ptr = boost::make_shared<MatrixDouble>();
"V", mat_v_grad_ptr));
auto gravity_vector_ptr = boost::make_shared<MatrixDouble>();
gravity_vector_ptr->resize(SPACE_DIM, 1);
auto set_body_force = [&]() {
auto t_force = getFTensor1FromMat<SPACE_DIM, 0>(*gravity_vector_ptr);
double unit_weight = 0.;
CHKERR PetscOptionsGetReal(PETSC_NULL, "", "-unit_weight", &unit_weight,
PETSC_NULL);
t_force(i) = 0;
if (SPACE_DIM == 2) {
t_force(1) = -unit_weight;
} else if (SPACE_DIM == 3) {
t_force(2) = unit_weight;
}
};
CHKERR set_body_force();
pip.push_back(new OpBodyForce("V", gravity_vector_ptr,
[](double, double, double) { return 1.; }));
// Calculate unknown F
auto mat_H_tensor_ptr = boost::make_shared<MatrixDouble>();
"F", mat_H_tensor_ptr));
// // Calculate F
double tau = 0.2;
CHKERR PetscOptionsGetReal(PETSC_NULL, "", "-tau", &tau, PETSC_NULL);
double xi = 0.;
CHKERR PetscOptionsGetReal(PETSC_NULL, "", "-xi", &xi, PETSC_NULL);
// Calculate P stab
auto one = [&](const double, const double, const double) {
return 3. * bulk_modulus_K;
};
auto minus_one = [](const double, const double, const double) {
return -1.;
};
auto mat_dot_F_tensor_ptr = boost::make_shared<MatrixDouble>();
"F_dot", mat_dot_F_tensor_ptr));
// Calculate Gradient of Spatial Positions
auto mat_x_grad_ptr = boost::make_shared<MatrixDouble>();
"x_2", mat_x_grad_ptr));
auto mat_F_tensor_ptr = boost::make_shared<MatrixDouble>();
mat_F_tensor_ptr, mat_H_tensor_ptr));
auto mat_F_stab_ptr = boost::make_shared<MatrixDouble>();
mat_F_tensor_ptr, mat_F_stab_ptr, mat_dot_F_tensor_ptr, tau, xi,
mat_x_grad_ptr, mat_v_grad_ptr));
PetscBool is_linear_elasticity = PETSC_TRUE;
CHKERR PetscOptionsGetBool(PETSC_NULL, "", "-is_linear_elasticity",
&is_linear_elasticity, PETSC_NULL);
auto mat_P_stab_ptr = boost::make_shared<MatrixDouble>();
if (is_linear_elasticity) {
mat_F_stab_ptr));
} else {
auto inv_F = boost::make_shared<MatrixDouble>();
auto det_ptr = boost::make_shared<VectorDouble>();
pip.push_back(
new OpInvertMatrix<SPACE_DIM>(mat_F_stab_ptr, det_ptr, inv_F));
// OpCalculatePiolaIncompressibleNH
mat_F_stab_ptr, inv_F, det_ptr));
}
pip.push_back(new OpGradTimesTensor2("V", mat_P_stab_ptr, minus_one));
pip.push_back(new OpRhsTestPiola("F", mat_v_grad_ptr, one));
};
CHKERR apply_rhs(pipeline_mng->getOpDomainExplicitRhsPipeline());
auto integration_rule = [](int, int, int approx_order) {
return 2 * approx_order;
};
CHKERR pipeline_mng->setDomainExplicitRhsIntegrationRule(integration_rule);
}
//! [Push operators to pipeline]
/**
* @brief Monitor solution
*
* This functions is called by TS solver at the end of each step. It is used
* to output results to the hard drive.
*/
struct Monitor : public FEMethod {
boost::shared_ptr<PostProcEle> post_proc,
boost::shared_ptr<PostProcFaceEle> post_proc_bdry,
boost::shared_ptr<MatrixDouble> velocity_field_ptr,
boost::shared_ptr<MatrixDouble> x2_field_ptr,
boost::shared_ptr<MatrixDouble> geometry_field_ptr,
std::array<double, 3> pass_field_eval_coords,
boost::shared_ptr<SetPtsData> pass_field_eval_data)
: dM(dm), mField(m_field), postProc(post_proc),
postProcBdy(post_proc_bdry), velocityFieldPtr(velocity_field_ptr),
x2FieldPtr(x2_field_ptr), geometryFieldPtr(geometry_field_ptr),
fieldEvalCoords(pass_field_eval_coords),
fieldEvalData(pass_field_eval_data){};
// cerr << "wagawaga\n";
if (SPACE_DIM == 3) {
fieldEvalCoords.data(), 1e-12, simple->getProblemName(),
simple->getDomainFEName(), fieldEvalData, mField.get_comm_rank(),
} else {
fieldEvalCoords.data(), 1e-12, simple->getProblemName(),
simple->getDomainFEName(), fieldEvalData, mField.get_comm_rank(),
}
if (velocityFieldPtr->size1()) {
double u_x = t_x2_field(0) - t_geom(0);
double u_y = t_x2_field(1) - t_geom(1);
double u_z = t_x2_field(2) - t_geom(2);
MOFEM_LOG("SYNC", Sev::inform)
<< "Velocities x: " << t_vel(0) << " y: " << t_vel(1)
<< " z: " << t_vel(2) << "\n";
MOFEM_LOG("SYNC", Sev::inform) << "Displacement x: " << u_x
<< " y: " << u_y << " z: " << u_z << "\n";
}
std::regex((boost::format("%s(.*)") % "Data_Vertex").str()))) {
Range ents;
mField.get_moab().get_entities_by_dimension(m->getMeshset(), 0, ents,
true);
auto print_vets = [](boost::shared_ptr<FieldEntity> ent_ptr) {
if (!(ent_ptr->getPStatus() & PSTATUS_NOT_OWNED)) {
MOFEM_LOG("SYNC", Sev::inform)
<< "Velocities: " << ent_ptr->getEntFieldData()[0] << " "
<< ent_ptr->getEntFieldData()[1] << " "
<< ent_ptr->getEntFieldData()[2] << "\n";
}
};
CHKERR mField.getInterface<FieldBlas>()->fieldLambdaOnEntities(
print_vets, "V", &ents);
}
PetscBool print_volume = PETSC_FALSE;
CHKERR PetscOptionsGetBool(PETSC_NULL, "", "-print_volume", &print_volume,
PETSC_NULL);
PetscBool print_skin = PETSC_FALSE;
CHKERR PetscOptionsGetBool(PETSC_NULL, "", "-print_skin", &print_skin,
PETSC_NULL);
CHKERR PetscOptionsGetInt(PETSC_NULL, "", "-save_step",
&save_every_nth_step, PETSC_NULL);
if (print_volume) {
CHKERR postProc->writeFile(
"out_step_" + boost::lexical_cast<std::string>(ts_step) + ".h5m");
}
if (print_skin) {
CHKERR postProcBdy->writeFile(
"out_boundary_" + boost::lexical_cast<std::string>(ts_step) +
".h5m");
}
}
}
private:
boost::shared_ptr<PostProcEle> postProc;
boost::shared_ptr<PostProcFaceEle> postProcBdy;
boost::shared_ptr<MatrixDouble> velocityFieldPtr;
boost::shared_ptr<MatrixDouble> x2FieldPtr;
boost::shared_ptr<MatrixDouble> geometryFieldPtr;
std::array<double, 3> fieldEvalCoords;
boost::shared_ptr<SetPtsData> fieldEvalData;
};
//! [Solve]
auto *pipeline_mng = mField.getInterface<PipelineManager>();
auto dm = simple->getDM();
auto calculate_stress_ops = [&](auto &pip) {
auto v_ptr = boost::make_shared<MatrixDouble>();
pip.push_back(new OpCalculateVectorFieldValues<SPACE_DIM>("V", v_ptr));
auto X_ptr = boost::make_shared<MatrixDouble>();
pip.push_back(
new OpCalculateVectorFieldValues<SPACE_DIM>("GEOMETRY", X_ptr));
auto x_ptr = boost::make_shared<MatrixDouble>();
pip.push_back(new OpCalculateVectorFieldValues<SPACE_DIM>("x_1", x_ptr));
// Calculate unknown F
auto mat_H_tensor_ptr = boost::make_shared<MatrixDouble>();
"F", mat_H_tensor_ptr));
auto u_ptr = boost::make_shared<MatrixDouble>();
pip.push_back(new OpCalculateDisplacement<SPACE_DIM>(x_ptr, X_ptr, u_ptr));
// Calculate P
auto mat_F_ptr = boost::make_shared<MatrixDouble>();
mat_F_ptr, mat_H_tensor_ptr));
PetscBool is_linear_elasticity = PETSC_TRUE;
CHKERR PetscOptionsGetBool(PETSC_NULL, "", "-is_linear_elasticity",
&is_linear_elasticity, PETSC_NULL);
auto mat_P_ptr = boost::make_shared<MatrixDouble>();
if (is_linear_elasticity) {
mat_F_ptr));
} else {
auto inv_F = boost::make_shared<MatrixDouble>();
auto det_ptr = boost::make_shared<VectorDouble>();
pip.push_back(new OpInvertMatrix<SPACE_DIM>(mat_F_ptr, det_ptr, inv_F));
mat_F_ptr, inv_F, det_ptr));
}
auto mat_v_grad_ptr = boost::make_shared<MatrixDouble>();
"V", mat_v_grad_ptr));
return boost::make_tuple(v_ptr, X_ptr, x_ptr, mat_P_ptr, mat_F_ptr, u_ptr);
};
auto post_proc_boundary = [&]() {
auto boundary_post_proc_fe = boost::make_shared<PostProcFaceEle>(mField);
boundary_post_proc_fe->getOpPtrVector(), {}, "GEOMETRY");
auto op_loop_side =
new OpLoopSide<SideEle>(mField, simple->getDomainFEName(), SPACE_DIM);
// push ops to side element, through op_loop_side operator
auto [boundary_v_ptr, boundary_X_ptr, boundary_x_ptr, boundary_mat_P_ptr,
boundary_mat_F_ptr, boundary_u_ptr] =
calculate_stress_ops(op_loop_side->getOpPtrVector());
boundary_post_proc_fe->getOpPtrVector().push_back(op_loop_side);
boundary_post_proc_fe->getOpPtrVector().push_back(
new OpPPMap(
boundary_post_proc_fe->getPostProcMesh(),
boundary_post_proc_fe->getMapGaussPts(),
OpPPMap::DataMapVec{},
OpPPMap::DataMapMat{{"V", boundary_v_ptr},
{"GEOMETRY", boundary_X_ptr},
{"x", boundary_x_ptr},
{"U", boundary_u_ptr}},
OpPPMap::DataMapMat{{"FIRST_PIOLA", boundary_mat_P_ptr},
{"F", boundary_mat_F_ptr}},
OpPPMap::DataMapMat{}
)
);
return boundary_post_proc_fe;
};
// Add monitor to time solver
double rho = 1.;
CHKERR PetscOptionsGetReal(PETSC_NULL, "", "-density", &rho, PETSC_NULL);
auto get_rho = [rho](const double, const double, const double) {
return rho;
};
SmartPetscObj<Mat> M; ///< Mass matrix
SmartPetscObj<KSP> ksp; ///< Linear solver
auto ts_pre_post_proc = boost::make_shared<TSPrePostProc>();
tsPrePostProc = ts_pre_post_proc;
CHKERR MatZeroEntries(M);
boost::shared_ptr<DomainEle> vol_mass_ele(new DomainEle(mField));
vol_mass_ele->B = M;
auto integration_rule = [](int, int, int approx_order) {
return 2 * approx_order;
};
vol_mass_ele->getRuleHook = integration_rule;
vol_mass_ele->getOpPtrVector().push_back(new OpMassV("V", "V", get_rho));
vol_mass_ele->getOpPtrVector().push_back(new OpMassF("F", "F"));
CHKERR DMoFEMLoopFiniteElements(dm, simple->getDomainFEName(), vol_mass_ele);
CHKERR MatAssemblyBegin(M, MAT_FINAL_ASSEMBLY);
CHKERR MatAssemblyEnd(M, MAT_FINAL_ASSEMBLY);
auto lumpVec = createDMVector(simple->getDM());
CHKERR MatGetRowSum(M, lumpVec);
CHKERR MatZeroEntries(M);
CHKERR MatDiagonalSet(M, lumpVec, INSERT_VALUES);
// Create and septup KSP (linear solver), we need this to calculate g(t,u) =
// M^-1G(t,u)
ksp = createKSP(mField.get_comm());
CHKERR KSPSetOperators(ksp, M, M);
CHKERR KSPSetFromOptions(ksp);
CHKERR KSPSetUp(ksp);
auto solve_boundary_for_g = [&]() {
if (*(pipeline_mng->getBoundaryExplicitRhsFE()->vecAssembleSwitch)) {
CHKERR VecGhostUpdateBegin(pipeline_mng->getBoundaryExplicitRhsFE()->ts_F,
ADD_VALUES, SCATTER_REVERSE);
CHKERR VecGhostUpdateEnd(pipeline_mng->getBoundaryExplicitRhsFE()->ts_F,
ADD_VALUES, SCATTER_REVERSE);
CHKERR VecAssemblyBegin(pipeline_mng->getBoundaryExplicitRhsFE()->ts_F);
CHKERR VecAssemblyEnd(pipeline_mng->getBoundaryExplicitRhsFE()->ts_F);
*(pipeline_mng->getBoundaryExplicitRhsFE()->vecAssembleSwitch) = false;
auto D =
smartVectorDuplicate(pipeline_mng->getBoundaryExplicitRhsFE()->ts_F);
CHKERR KSPSolve(ksp, pipeline_mng->getBoundaryExplicitRhsFE()->ts_F, D);
CHKERR VecGhostUpdateBegin(D, INSERT_VALUES, SCATTER_FORWARD);
CHKERR VecGhostUpdateEnd(D, INSERT_VALUES, SCATTER_FORWARD);
CHKERR VecCopy(D, pipeline_mng->getBoundaryExplicitRhsFE()->ts_F);
}
};
pipeline_mng->getBoundaryExplicitRhsFE()->postProcessHook =
solve_boundary_for_g;
ts = pipeline_mng->createTSEX(dm);
// Field eval
PetscBool field_eval_flag = PETSC_TRUE;
boost::shared_ptr<MatrixDouble> velocity_field_ptr;
boost::shared_ptr<MatrixDouble> geometry_field_ptr;
boost::shared_ptr<MatrixDouble> spatial_position_field_ptr;
boost::shared_ptr<SetPtsData> field_eval_data;
std::array<double, 3> field_eval_coords = {0.5, 0.5, 5.};
int dim = 3;
CHKERR PetscOptionsGetRealArray(NULL, NULL, "-field_eval_coords",
field_eval_coords.data(), &dim,
&field_eval_flag);
if (field_eval_flag) {
field_eval_data =
mField.getInterface<FieldEvaluatorInterface>()->getData<DomainEle>();
if (SPACE_DIM == 3) {
field_eval_data, simple->getDomainFEName());
} else {
field_eval_data, simple->getDomainFEName());
}
field_eval_data->setEvalPoints(field_eval_coords.data(), 1);
auto no_rule = [](int, int, int) { return -1; };
auto fe_ptr = field_eval_data->feMethodPtr.lock();
fe_ptr->getRuleHook = no_rule;
velocity_field_ptr = boost::make_shared<MatrixDouble>();
geometry_field_ptr = boost::make_shared<MatrixDouble>();
spatial_position_field_ptr = boost::make_shared<MatrixDouble>();
fe_ptr->getOpPtrVector().push_back(
new OpCalculateVectorFieldValues<SPACE_DIM>("V", velocity_field_ptr));
fe_ptr->getOpPtrVector().push_back(
geometry_field_ptr));
fe_ptr->getOpPtrVector().push_back(
"x_2", spatial_position_field_ptr));
}
auto post_proc_domain = [&]() {
auto post_proc_fe_vol = boost::make_shared<PostProcEle>(mField);
auto [boundary_v_ptr, boundary_X_ptr, boundary_x_ptr, boundary_mat_P_ptr,
boundary_mat_F_ptr, boundary_u_ptr] =
calculate_stress_ops(post_proc_fe_vol->getOpPtrVector());
post_proc_fe_vol->getOpPtrVector().push_back(
new OpPPMap(
post_proc_fe_vol->getPostProcMesh(),
post_proc_fe_vol->getMapGaussPts(),
{},
{{"V", boundary_v_ptr},
{"GEOMETRY", boundary_X_ptr},
{"x", boundary_x_ptr},
{"U", boundary_u_ptr}},
{{"FIRST_PIOLA", boundary_mat_P_ptr}, {"F", boundary_mat_F_ptr}},
{}
)
);
return post_proc_fe_vol;
};
boost::shared_ptr<FEMethod> null_fe;
auto monitor_ptr = boost::make_shared<Monitor>(
SmartPetscObj<DM>(dm, true), mField, post_proc_domain(),
post_proc_boundary(), velocity_field_ptr, spatial_position_field_ptr,
geometry_field_ptr, field_eval_coords, field_eval_data);
CHKERR DMMoFEMTSSetMonitor(dm, ts, simple->getDomainFEName(), null_fe,
null_fe, monitor_ptr);
double ftime = 1;
// CHKERR TSSetMaxTime(ts, ftime);
CHKERR TSSetExactFinalTime(ts, TS_EXACTFINALTIME_MATCHSTEP);
auto T = createDMVector(simple->getDM());
CHKERR DMoFEMMeshToLocalVector(simple->getDM(), T, INSERT_VALUES,
SCATTER_FORWARD);
CHKERR TSSetSolution(ts, T);
CHKERR TSSetFromOptions(ts);
auto fb = mField.getInterface<FieldBlas>();
CHKERR TSSetPostStage(ts, TSPrePostProc::tsPostStage);
CHKERR TSSetPostStep(ts, TSPrePostProc::tsPostStep);
CHKERR TSSetPreStep(ts, TSPrePostProc::tsPreStep);
boost::shared_ptr<ForcesAndSourcesCore> null;
if (auto ptr = tsPrePostProc.lock()) {
ptr->fsRawPtr = this;
CHKERR TSSetUp(ts);
CHKERR TSSolve(ts, NULL);
CHKERR TSGetTime(ts, &ftime);
}
}
//! [Solve]
//! [Postprocess results]
PetscBool test_flg = PETSC_FALSE;
CHKERR PetscOptionsGetBool(PETSC_NULL, "", "-test", &test_flg, PETSC_NULL);
if (test_flg) {
auto T = createDMVector(simple->getDM());
CHKERR DMoFEMMeshToLocalVector(simple->getDM(), T, INSERT_VALUES,
SCATTER_FORWARD);
double nrm2;
CHKERR VecNorm(T, NORM_2, &nrm2);
MOFEM_LOG("EXAMPLE", Sev::inform) << "Regression norm " << nrm2;
constexpr double regression_value = 0.0194561;
if (fabs(nrm2 - regression_value) > 1e-2)
SETERRQ(PETSC_COMM_WORLD, MOFEM_ATOM_TEST_INVALID,
"Regression test failed; wrong norm value.");
}
}
//! [Postprocess results]
//! [Check]
}
//! [Check]
static char help[] = "...\n\n";
int main(int argc, char *argv[]) {
// Initialisation of MoFEM/PETSc and MOAB data structures
const char param_file[] = "param_file.petsc";
MoFEM::Core::Initialize(&argc, &argv, param_file, help);
// Add logging channel for example
auto core_log = logging::core::get();
core_log->add_sink(
LogManager::createSink(LogManager::getStrmWorld(), "EXAMPLE"));
LogManager::setLog("EXAMPLE");
MOFEM_LOG_TAG("EXAMPLE", "example");
try {
//! [Register MoFEM discrete manager in PETSc]
DMType dm_name = "DMMOFEM";
//! [Register MoFEM discrete manager in PETSc
//! [Create MoAB]
moab::Core mb_instance; ///< mesh database
moab::Interface &moab = mb_instance; ///< mesh database interface
//! [Create MoAB]
//! [Create MoFEM]
MoFEM::Core core(moab); ///< finite element database
MoFEM::Interface &m_field = core; ///< finite element database interface
//! [Create MoFEM]
//! [Example]
Example ex(m_field);
CHKERR ex.runProblem();
//! [Example]
}
}
constexpr double third
ForcesAndSourcesCore::UserDataOperator UserDataOperator
#define MOFEM_LOG_SEVERITY_SYNC(comm, severity)
Synchronise "SYNC" on curtain severity level.
void simple(double P1[], double P2[], double P3[], double c[], const int N)
Definition acoustic.cpp:69
static char help[]
int main()
constexpr int SPACE_DIM
constexpr int SPACE_DIM
ElementsAndOps< SPACE_DIM >::BoundaryEle BoundaryEle
ElementsAndOps< SPACE_DIM >::DomainEle DomainEle
[Define dimension]
Kronecker Delta class.
@ QUIET
#define CATCH_ERRORS
Catch errors.
@ MF_EXIST
FieldApproximationBase
approximation base
Definition definitions.h:58
@ LASTBASE
Definition definitions.h:69
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base nme:nme847.
Definition definitions.h:60
@ DEMKOWICZ_JACOBI_BASE
Definition definitions.h:66
@ H1
continuous field
Definition definitions.h:85
@ NOSPACE
Definition definitions.h:83
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_ATOM_TEST_INVALID
Definition definitions.h:40
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
constexpr int order
PostProcEleByDim< SPACE_DIM >::PostProcEleDomain PostProcEleDomain
static boost::weak_ptr< TSPrePostProc > tsPrePostProc
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpBaseTimesVector< 1, SPACE_DIM, 1 > OpInertiaForce
FormsIntegrators< DomainEleOp >::Assembly< AssemblyType::PETSC >::LinearForm< IntegrationType::GAUSS >::OpBaseTimesVector< 1, SPACE_DIM *SPACE_DIM, 1 > OpRhsTestPiola
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 1, SPACE_DIM > OpMassV
constexpr int SPACE_DIM
FormsIntegrators< DomainEleOp >::Assembly< AssemblyType::PETSC >::LinearForm< IntegrationType::GAUSS >::OpGradTimesTensor< 1, SPACE_DIM, SPACE_DIM > OpGradTimesTensor2
FieldEvaluatorInterface::SetPtsData SetPtsData
NaturalBC< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS > DomainNaturalBC
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 1, SPACE_DIM *SPACE_DIM > OpMassF
DomainNaturalBC::OpFlux< NaturalMeshsetTypeVectorScaling< BLOCKSET >, 1, SPACE_DIM > OpBodyForceVector
constexpr double omega
Save field DOFS on vertices/tags.
PostProcEleByDim< SPACE_DIM >::PostProcEleBdy PostProcEleBdy
PostProcBrokenMeshInMoab< FaceElementForcesAndSourcesCore > PostProcFaceEle
FormsIntegrators< DomainEleOp >::Assembly< AssemblyType::PETSC >::LinearForm< IntegrationType::GAUSS >::OpGradTimesTensor< 1, SPACE_DIM, SPACE_DIM > OpGradTimesPiola
double trace(FTensor::Tensor2< T, 2, 2 > &t_stress)
double bulk_modulus_K
double shear_modulus_G
static boost::weak_ptr< TSPrePostProc > tsPrePostProc
auto integration_rule
constexpr auto t_kd
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
set local (or ghosted) vector values on mesh for partition only
Definition DMMoFEM.cpp:523
PetscErrorCode DMCreateMatrix_MoFEM(DM dm, Mat *M)
Definition DMMoFEM.cpp:1197
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
Definition DMMoFEM.cpp:43
PetscErrorCode DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
Executes FEMethod for finite elements in DM.
Definition DMMoFEM.cpp:586
auto createDMVector(DM dm)
Get smart vector from DM.
Definition DMMoFEM.hpp:1099
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
virtual MoFEMErrorCode loop_dofs(const Problem *problem_ptr, const std::string &field_name, RowColData rc, DofMethod &method, int lower_rank, int upper_rank, int verb=DEFAULT_VERBOSITY)=0
Make a loop over dofs.
MoFEMErrorCode getCubitMeshsetPtr(const int ms_id, const CubitBCType cubit_bc_type, const CubitMeshSets **cubit_meshset_ptr) const
get cubit meshset
FTensor::Index< 'i', SPACE_DIM > i
double dt
double D
FTensor::Index< 'l', 3 > l
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
auto createKSP(MPI_Comm comm)
PetscErrorCode DMMoFEMTSSetMonitor(DM dm, TS ts, const std::string fe_name, boost::shared_ptr< MoFEM::FEMethod > method, boost::shared_ptr< MoFEM::BasicMethod > pre_only, boost::shared_ptr< MoFEM::BasicMethod > post_only)
Set Monitor To TS solver.
Definition DMMoFEM.cpp:1056
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
DEPRECATED SmartPetscObj< Vec > smartVectorDuplicate(Vec vec)
PetscErrorCode PetscOptionsGetReal(PetscOptions *, const char pre[], const char name[], PetscReal *dval, PetscBool *set)
PetscErrorCode PetscOptionsGetBool(PetscOptions *, const char pre[], const char name[], PetscBool *bval, PetscBool *set)
PetscErrorCode PetscOptionsGetRealArray(PetscOptions *, const char pre[], const char name[], PetscReal dval[], PetscInt *nmax, PetscBool *set)
FTensor::Tensor1< FTensor::PackPtr< T *, S >, Tensor_Dim > getFTensor1FromMat(ublas::matrix< T, L, A > &data)
Get tensor rank 1 (vector) form data matrix.
FTensor::Tensor2< FTensor::PackPtr< double *, 1 >, Tensor_Dim1, Tensor_Dim2 > getFTensor2FromMat(MatrixDouble &data)
Get tensor rank 2 (matrix) form data matrix.
static auto getFTensor0FromVec(ublas::vector< T, A > &data)
Get tensor rank 0 (scalar) form data vector.
PetscErrorCode PetscOptionsGetEList(PetscOptions *, const char pre[], const char name[], const char *const *list, PetscInt next, PetscInt *value, PetscBool *set)
FTensor::Index< 'M', 3 > M
FormsIntegrators< DomainEleOp >::Assembly< A >::LinearForm< I >::OpGradTimesTensor< 1, FIELD_DIM, SPACE_DIM > OpGradTimesTensor
int save_every_nth_step
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
double young_modulus
Young modulus.
Definition plastic.cpp:121
double rho
Definition plastic.cpp:140
#define EXECUTABLE_DIMENSION
Definition plastic.cpp:13
double poisson_ratio
Poisson ratio.
Definition plastic.cpp:122
ElementsAndOps< SPACE_DIM >::SideEle SideEle
Definition plastic.cpp:61
static constexpr int approx_order
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 1, SPACE_DIM > OpMass
[Only used with Hooke equation (linear material model)]
Definition seepage.cpp:56
constexpr double mu
constexpr double omega
FTensor::Index< 'i', 3 > i
FTensor::Index< 'm', 3 > m
SmartPetscObj< Mat > M
Mass matrix.
SmartPetscObj< KSP > ksp
Linear solver.
double getScale(const double time)
Get scaling at given time.
double getScale(const double time)
Get scaling at given time.
[Example]
Definition plastic.cpp:213
MoFEMErrorCode boundaryCondition()
[Set up problem]
MoFEMErrorCode assembleSystem()
[Push operators to pipeline]
MoFEMErrorCode readMesh()
[Run problem]
FieldApproximationBase base
Definition plot_base.cpp:68
MoFEMErrorCode checkResults()
[Postprocess results]
MoFEMErrorCode solveSystem()
[Solve]
Example(MoFEM::Interface &m_field)
Definition plastic.cpp:215
MoFEMErrorCode runProblem()
[Run problem]
Definition plastic.cpp:253
MoFEM::Interface & mField
Definition plastic.cpp:223
MoFEMErrorCode setupProblem()
[Run problem]
Definition plastic.cpp:272
MoFEMErrorCode outputResults()
[Solve]
double getScale(const double time)
Get scaling at given time.
boost::weak_ptr< CacheTuple > getCacheWeakPtr() const
Get the cache weak ptr object.
Simple interface for fast problem set-up.
Definition BcManager.hpp:25
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =0
virtual int get_comm_rank() const =0
Core (interface) class.
Definition Core.hpp:82
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
Definition Core.cpp:72
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition Core.cpp:112
Deprecated interface functions.
Definition of the displacement bc data structure.
Definition BCData.hpp:76
Data on single entity (This is passed as argument to DataOperator::doWork)
Class (Function) to enforce essential constrains.
Definition Essential.hpp:25
Basic algebra on fields.
Definition FieldBlas.hpp:21
Field evaluator interface.
structure to get information form mofem into EntitiesFieldData
Interface for managing meshsets containing materials and boundary conditions.
Assembly methods.
Definition Natural.hpp:65
Get values at integration pts for tensor filed rank 2, i.e. matrix field.
Get values at integration pts for tensor filed rank 1, i.e. vector field.
Element used to execute operators on side of the element.
Post post-proc data at points from hash maps.
PipelineManager interface.
Projection of edge entities with one mid-node on hierarchical basis.
Simple interface for fast problem set-up.
Definition Simple.hpp:27
intrusive_ptr for managing petsc objects
PetscInt ts_step
time step number
Force scale operator for reading two columns.
double getScale(const double time)
Get scaling at a given time.
TimeScale(std::string file_name="", bool error_if_file_not_given=false, ScalingFun def_scaling_fun=[](double time) { return time;})
TimeScale constructor.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
[Push operators to pipeline]
boost::shared_ptr< PostProcFaceEle > postProcBdy
std::array< double, 3 > fieldEvalCoords
MoFEM::Interface & mField
Monitor(SmartPetscObj< DM > dm, MoFEM::Interface &m_field, boost::shared_ptr< PostProcEle > post_proc, boost::shared_ptr< PostProcFaceEle > post_proc_bdry, boost::shared_ptr< MatrixDouble > velocity_field_ptr, boost::shared_ptr< MatrixDouble > x2_field_ptr, boost::shared_ptr< MatrixDouble > geometry_field_ptr, std::array< double, 3 > pass_field_eval_coords, boost::shared_ptr< SetPtsData > pass_field_eval_data)
boost::shared_ptr< MatrixDouble > geometryFieldPtr
SmartPetscObj< DM > dM
MoFEMErrorCode postProcess()
function is run at the end of loop
boost::shared_ptr< MatrixDouble > velocityFieldPtr
boost::shared_ptr< SetPtsData > fieldEvalData
boost::shared_ptr< MatrixDouble > x2FieldPtr
boost::shared_ptr< PostProcEle > postProc
MoFEMErrorCode doWork(int side, EntityType type, DataForcesAndSourcesCore::EntData &data)
boost::shared_ptr< MatrixDouble > defGradPtr
boost::shared_ptr< MatrixDouble > gradTensorPtr
OpCalculateDeformationGradient(boost::shared_ptr< MatrixDouble > def_grad_ptr, boost::shared_ptr< MatrixDouble > grad_tensor_ptr)
boost::shared_ptr< MatrixDouble > XPtr
boost::shared_ptr< MatrixDouble > uPtr
MoFEMErrorCode doWork(int side, EntityType type, DataForcesAndSourcesCore::EntData &data)
OpCalculateDisplacement(boost::shared_ptr< MatrixDouble > spatial_pos_ptr, boost::shared_ptr< MatrixDouble > reference_pos_ptr, boost::shared_ptr< MatrixDouble > u_ptr)
boost::shared_ptr< MatrixDouble > xPtr
boost::shared_ptr< MatrixDouble > gradxPtr
MoFEMErrorCode doWork(int side, EntityType type, DataForcesAndSourcesCore::EntData &data)
OpCalculateFStab(boost::shared_ptr< MatrixDouble > def_grad_ptr, boost::shared_ptr< MatrixDouble > def_grad_stab_ptr, boost::shared_ptr< MatrixDouble > def_grad_dot_ptr, double tau_F_ptr, double xi_F_ptr, boost::shared_ptr< MatrixDouble > grad_x_ptr, boost::shared_ptr< MatrixDouble > grad_vel_ptr)
boost::shared_ptr< MatrixDouble > defGradStabPtr
boost::shared_ptr< MatrixDouble > gradVelPtr
boost::shared_ptr< MatrixDouble > defGradPtr
boost::shared_ptr< MatrixDouble > defGradDotPtr
OpCalculatePiola(double shear_modulus, double bulk_modulus, double m_u, double lambda_lamme, boost::shared_ptr< MatrixDouble > first_piola_ptr, boost::shared_ptr< MatrixDouble > def_grad_ptr)
MoFEMErrorCode doWork(int side, EntityType type, DataForcesAndSourcesCore::EntData &data)
boost::shared_ptr< MatrixDouble > defGradPtr
boost::shared_ptr< MatrixDouble > firstPiolaPtr
OpCalculatePiolaIncompressibleNH(double shear_modulus, double bulk_modulus, double m_u, double lambda_lamme, boost::shared_ptr< MatrixDouble > first_piola_ptr, boost::shared_ptr< MatrixDouble > def_grad_ptr, boost::shared_ptr< MatrixDouble > inv_def_grad_ptr, boost::shared_ptr< VectorDouble > det)
boost::shared_ptr< VectorDouble > dEt
MoFEMErrorCode doWork(int side, EntityType type, DataForcesAndSourcesCore::EntData &data)
boost::shared_ptr< MatrixDouble > invDefGradPtr
boost::shared_ptr< MatrixDouble > defGradPtr
boost::shared_ptr< MatrixDouble > firstPiolaPtr
Set of functions called by PETSc solver used to refine and update mesh.
static MoFEMErrorCode tsPostStep(TS ts)
virtual ~TSPrePostProc()=default
Example * fsRawPtr
static MoFEMErrorCode tsPreStep(TS ts)
TSPrePostProc()=default
static MoFEMErrorCode tsPostStage(TS ts, PetscReal stagetime, PetscInt stageindex, Vec *Y)
[Boundary condition]
MoFEMErrorCode tsSetUp(TS ts)
Used to setup TS solver.
BoundaryNaturalBC::OpFlux< NaturalForceMeshsets, 1, SPACE_DIM > OpForce
DomainNaturalBCRhs::OpFlux< NaturalMeshsetType< BLOCKSET >, 1, SPACE_DIM > OpBodyForce
NaturalBC< BoundaryEleOp >::Assembly< PETSC >::LinearForm< GAUSS > BoundaryNaturalBC
[Body and heat source]