int order_col, int order_data);
private:
using ForcesAndSourcesCore::dataOnElement;
private:
using ForcesAndSourcesCore::ForcesAndSourcesCore;
};
static inline std::map<long int, MatrixDouble>
mapRefCoords;
};
PetscInt numVecs = 1,
Vec vecsToMapFrom[] = PETSC_NULLPTR,
Vec vecsToMapTo[] = PETSC_NULLPTR);
MoFEMErrorCode
reSetUp(std::vector<std::string> L2Fields,
std::vector<int> L2Oders,
std::vector<std::string> H1Fields,
std::vector<int> H1Orders,
std::vector<std::string> HdivFields,
std::vector<int> HdivOrders, BitRefLevel bIt);
private:
boost::shared_ptr<DomainEle>
feRhs;
boost::shared_ptr<DomainEle>
feLhs;
BitRefLevel parent_bit, BitRefLevel child_bit);
MoFEMErrorCode
projectResults(BitRefLevel parent_bit, BitRefLevel child_bit);
BitRefLevel parent_bit, BitRefLevel child_bit,
PetscInt numVecs, Vec vecsToMapFrom[],
Vec vecsToMapTo[]);
};
feRhs = boost::make_shared<DomainEle>(m_field);
feLhs = boost::make_shared<DomainEle>(m_field);
}
BitRefLevel parent_bit,
BitRefLevel child_bit,
PetscInt num_vecs,
Vec vecs_to_map_from[],
Vec vecs_to_map_to[]) {
vecs_to_map_from, vecs_to_map_to);
};
SmartPetscObj<DM> &intermediate_dm,
BitRefLevel parent_bit,
BitRefLevel child_bit) {
MOFEM_LOG(
"REMESHING", Sev::inform) <<
"Set up sub DM for mapping";
auto create_sub_dm = [&]() {
auto create_impl = [&]() {
CHKERR DMSetType(sub_dm,
"DMMOFEM");
MOFEM_LOG(
"REMESHING", Sev::inform) <<
"Created sub DM";
auto ref_entities_ptr = boost::make_shared<Range>();
auto child_mask = parent_bit;
child_bit, child_mask.flip(),
SPACE_DIM, *ref_entities_ptr);
moab::Interface::UNION);
ref_entities_ptr->merge(edges);
verts, moab::Interface::UNION);
ref_entities_ptr->merge(verts);
for (auto f : {"U", "FLUX"}) {
}
parent_bit | child_bit);
};
};
MOFEM_LOG(
"REMESHING", Sev::inform) <<
"Set up sub DM for mapping <= done";
};
std::vector<int> L2_orders,
std::vector<std::string> H1_fields,
std::vector<int> H1_orders,
std::vector<std::string> Hdiv_fields,
std::vector<int> Hdiv_orders,
auto add_ents_order_to_field =
const std::initializer_list<std::string> &
f,
const std::initializer_list<EntityType> &
t,
int _order) {
}
}
};
for (
size_t i = 0;
i < L2_fields.size(); ++
i) {
}
for (
size_t i = 0;
i < H1_fields.size(); ++
i) {
CHKERR add_ents_order_to_field(
m_field, {H1_fields[
i]}, {MBTRI, MBEDGE},
1);
}
for (
size_t i = 0;
i < Hdiv_fields.size(); ++
i) {
CHKERR add_ents_order_to_field(
m_field, {Hdiv_fields[
i]}, {MBTRI, MBEDGE},
}
CHKERR skin.find_skin(0, faces,
false, skin_edges);
#ifdef ADD_CONTACT
auto filter_blocks = [&](auto skin) {
bool is_contact_block = false;
m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(
std::regex(
(boost::format("%s(.*)") % "CONTACT").str()
))
) {
is_contact_block =
true;
<<
"Find contact block set: " <<
m->getName();
auto meshset =
m->getMeshset();
Range contact_meshset_range;
meshset,
SPACE_DIM - 1, contact_meshset_range,
true);
contact_meshset_range);
contact_range.merge(contact_meshset_range);
}
if (is_contact_block) {
<< "Nb entities in contact surface: " << contact_range.size();
skin = intersect(skin, contact_range);
}
return skin;
};
auto sigma_trace_ents = filter_blocks(skin_edges);
#endif
skin_edges, MBEDGE,
simple->getBoundaryFEName());
};
BitRefLevel child_bit) {
feRhs->getOpPtrVector().clear();
feLhs->getOpPtrVector().clear();
MOFEM_LOG(
"REMESHING", Sev::inform) <<
"Cleared FEs";
feRhs->getRuleHook = vol_rule;
feLhs->getRuleHook = vol_rule;
auto get_child_op = [&](auto &pip) {
auto op_this_child =
new OpLoopThis<DomainEle>(
m_field,
simple->getDomainFEName(), child_bit,
parent_bit.flip(), Sev::noisy);
auto fe_child_ptr = op_this_child->getThisFEPtr();
fe_child_ptr->getRuleHook = [](
int,
int,
int p) {
return -1; };
child_bit, parent_bit.flip(), MBEDGE, child_edges);
CHKERR setDGSetIntegrationPoints<2>(
fe_child_ptr->setRuleHook, [](int, int, int p) { return 2 * p; },
boost::make_shared<Range>(child_edges));
pip.push_back(op_this_child);
return fe_child_ptr;
};
auto get_field_eval_op = [&](auto fe_child_ptr) {
auto field_eval_data = field_eval_ptr->getData<
DomainEle>();
field_eval_data,
simple->getDomainFEName(), parent_bit,
auto new_T_ptr = boost::make_shared<MatrixDouble>();
auto old_T_ptr = boost::make_shared<MatrixDouble>();
auto new_TAU_ptr = boost::make_shared<MatrixDouble>();
auto old_TAU_ptr = boost::make_shared<MatrixDouble>();
auto new_EP_ptr = boost::make_shared<MatrixDouble>();
auto old_EP_ptr = boost::make_shared<MatrixDouble>();
auto new_U_ptr = boost::make_shared<MatrixDouble>();
auto old_U_ptr = boost::make_shared<MatrixDouble>();
auto new_flux_ptr = boost::make_shared<MatrixDouble>();
auto old_flux_ptr = boost::make_shared<MatrixDouble>();
if (auto fe_eval_ptr = field_eval_data->feMethodPtr.lock()) {
fe_eval_ptr->getRuleHook = [](
int,
int,
int p) {
return -1; };
fe_eval_ptr->getOpPtrVector().push_back(
new OpCalculateVectorFieldValues<1>("T", old_T_ptr));
fe_eval_ptr->getOpPtrVector().push_back(
new OpCalculateVectorFieldValues<1>("TAU", old_TAU_ptr));
fe_eval_ptr->getOpPtrVector().push_back(
new OpCalculateVectorFieldValues<size_symm>("EP", old_EP_ptr));
fe_eval_ptr->getOpPtrVector().push_back(
new OpCalculateVectorFieldValues<SPACE_DIM>("U", old_U_ptr));
fe_eval_ptr->getOpPtrVector().push_back(
new OpCalculateHVecVectorField<3>("FLUX", old_flux_ptr));
} else {
"Field evaluator method pointer is expired");
}
auto op_ptr = field_eval_ptr->getDataOperator<
SPACE_DIM>(
{
{old_T_ptr, new_T_ptr},
{old_TAU_ptr, new_TAU_ptr},
{old_EP_ptr, new_EP_ptr},
{old_U_ptr, new_U_ptr},
{old_flux_ptr, new_flux_ptr}
},
fe_child_ptr->getOpPtrVector().push_back(op_ptr);
using FieldTupleVec = std::vector<
std::tuple<std::string, boost::shared_ptr<MatrixDouble>, int>>;
return std::make_pair(
std::vector<std::pair<std::string, boost::shared_ptr<MatrixDouble>>>{
{"T", new_T_ptr}, {"TAU", new_TAU_ptr}, {"EP", new_EP_ptr}},
std::vector<std::pair<std::string, boost::shared_ptr<MatrixDouble>>>{
{"U", new_U_ptr}, {"FLUX", new_flux_ptr}}
);
};
auto dg_projection_base = [&](auto fe_child_ptr, auto vec_data_ptr) {
auto entity_data_l2 = boost::make_shared<EntitiesFieldData>(MBENTITYSET);
auto mass_ptr = boost::make_shared<MatrixDouble>();
auto coeffs_ptr = boost::make_shared<MatrixDouble>();
constexpr int projection_order = 2;
for (
auto &[
field_name, data_ptr] : vec_data_ptr.first) {
fe_child_ptr->getOpPtrVector().push_back(new OpDGProjectionMassMatrix(
fe_child_ptr->getOpPtrVector().push_back(new OpDGProjectionCoefficients(
data_ptr, coeffs_ptr, mass_ptr, entity_data_l2,
op_set_coeffs->doWorkRhsHook =
[coeffs_ptr](DataOperator *base_op_ptr,
int side, EntityType
type,
EntitiesFieldData::EntData &data) -> MoFEMErrorCode {
auto field_ents = data.getFieldEntities();
auto nb_dofs = data.getIndices().size();
if (!field_ents.size())
if (auto e_ptr = field_ents[0]) {
auto field_ent_data = e_ptr->getEntFieldData();
std::copy(coeffs_ptr->data().data(),
coeffs_ptr->data().data() + nb_dofs,
field_ent_data.begin());
}
};
fe_child_ptr->getOpPtrVector().push_back(op_set_coeffs);
}
for (auto &p : vec_data_ptr.second) {
auto data_ptr = p.second;
using OpDomainMass = FormsIntegrators<DomainEleOp>::Assembly<
fe_child_ptr->getOpPtrVector().push_back(
using OpVec = FormsIntegrators<DomainEleOp>::Assembly<
fe_child_ptr->getOpPtrVector().push_back(
}
using OpDomainMass = FormsIntegrators<DomainEleOp>::Assembly<
fe_child_ptr->getOpPtrVector().push_back(
using OpVec = FormsIntegrators<DomainEleOp>::Assembly<
fe_child_ptr->getOpPtrVector().push_back(
}
}
};
auto fe_child_ptr = get_child_op(
feRhs->getOpPtrVector());
CHKERR dg_projection_base(fe_child_ptr, get_field_eval_op(fe_child_ptr));
MOFEM_LOG(
"REMESHING", Sev::inform) <<
"Before looping FEs";
MOFEM_LOG(
"REMESHING", Sev::inform) <<
"After looping RHS";
};
SmartPetscObj<DM> &sub_dm, SmartPetscObj<DM> &intermediate_dm,
BitRefLevel parent_bit, BitRefLevel child_bit, PetscInt num_vecs,
Vec vecs_to_map_from[], Vec vecs_to_map_to[]) {
auto post_proc = [&](auto dm, std::string file_name) {
auto T_ptr = boost::make_shared<VectorDouble>();
auto TAU_ptr = boost::make_shared<VectorDouble>();
auto EP_ptr = boost::make_shared<MatrixDouble>();
auto U_ptr = boost::make_shared<MatrixDouble>();
auto FLUX_ptr = boost::make_shared<MatrixDouble>();
auto post_proc_fe = boost::make_shared<PostProcEle>(
m_field);
using OpPPMap = OpPostProcMapInMoab<SPACE_DIM, SPACE_DIM>;
post_proc_fe->getOpPtrVector().push_back(
new OpCalculateScalarFieldValues("T", T_ptr));
post_proc_fe->getOpPtrVector().push_back(
new OpCalculateScalarFieldValues("TAU", TAU_ptr));
post_proc_fe->getOpPtrVector().push_back(
new OpCalculateTensor2SymmetricFieldValues<SPACE_DIM>("EP", EP_ptr));
post_proc_fe->getOpPtrVector().push_back(
new OpCalculateVectorFieldValues<SPACE_DIM>("U", U_ptr));
post_proc_fe->getOpPtrVector().push_back(
new OpCalculateHVecVectorField<3, SPACE_DIM>("FLUX", FLUX_ptr));
post_proc_fe->getOpPtrVector().push_back(
new OpPPMap(
post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
{{"T", T_ptr}, {"TAU", TAU_ptr}},
{{"U", U_ptr}, {"FLUX", FLUX_ptr}},
{},
{{"EP", EP_ptr}}
)
);
MOFEM_LOG(
"WORLD", Sev::inform) <<
"Just before looping post_proc_fe";
{
post_proc_fe, 0,
auto &post_proc_moab = post_proc_fe->getPostProcMesh();
auto output_name = "out_all_rank_" +
file_name + ".h5m";
CHKERR post_proc_moab.write_file(output_name.c_str());
}
{
auto &post_proc_moab = post_proc_fe->getPostProcMesh();
auto output_name = "out_only_on_rank" +
file_name + ".h5m";
CHKERR post_proc_moab.write_file(output_name.c_str());
}
};
auto null_fe = boost::shared_ptr<FEMethod>();
int size;
CHKERR VecGetSize(vec, &size);
SmartPetscObj<Mat> mat;
if (size)
CHKERR KSPSetOperators(ksp, mat, mat);
CHKERR KSPSetFromOptions(ksp);
feRhs->ksp_A = mat;
feRhs->ksp_B = mat;
feRhs->ksp_f = vec;
feRhs->data_ctx =
PetscData::CtxSetF | PetscData::CtxSetA | PetscData::CtxSetB;
SCATTER_FORWARD);
CHKERR VecGhostUpdateBegin(tmp_D, INSERT_VALUES, SCATTER_FORWARD);
CHKERR VecGhostUpdateEnd(tmp_D, INSERT_VALUES, SCATTER_FORWARD);
for (
int i = 0;
i < num_vecs; ++
i) {
CHKERR VecGhostUpdateBegin(vecs_to_map_from[
i], INSERT_VALUES,
SCATTER_FORWARD);
CHKERR VecGhostUpdateEnd(vecs_to_map_from[
i], INSERT_VALUES,
SCATTER_FORWARD);
INSERT_VALUES, SCATTER_REVERSE);
if (size)
CHKERR VecGhostUpdateBegin(vec, INSERT_VALUES, SCATTER_FORWARD);
CHKERR VecGhostUpdateEnd(vec, INSERT_VALUES, SCATTER_FORWARD);
CHKERR projectResults(parent_bit, child_bit);
if (size) {
CHKERR MatAssemblyBegin(mat, MAT_FINAL_ASSEMBLY);
CHKERR MatAssemblyEnd(mat, MAT_FINAL_ASSEMBLY);
CHKERR KSPSolve(ksp, vec, sol);
CHKERR VecGhostUpdateBegin(sol, INSERT_VALUES, SCATTER_FORWARD);
CHKERR VecGhostUpdateEnd(sol, INSERT_VALUES, SCATTER_FORWARD);
SCATTER_REVERSE);
}
INSERT_VALUES, SCATTER_FORWARD);
CHKERR VecGhostUpdateBegin(vecs_to_map_to[
i], INSERT_VALUES,
SCATTER_FORWARD);
CHKERR VecGhostUpdateEnd(vecs_to_map_to[
i], INSERT_VALUES, SCATTER_FORWARD);
CHKERR post_proc(intermediate_dm,
"map_" + std::to_string(
i));
}
SCATTER_REVERSE);
MOFEM_LOG(
"REMESHING", Sev::inform) <<
"Mapped thermoplastic state variables";
};
#define MOFEM_LOG_SYNCHRONISE(comm)
Synchronise "SYNC" channel.
void simple(double P1[], double P2[], double P3[], double c[], const int N)
ElementsAndOps< SPACE_DIM >::DomainEle DomainEle
constexpr int SPACE_DIM
[Define dimension]
DomainEle::UserDataOperator DomainEleOp
Finire element operator type.
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 1, FIELD_DIM > OpDomainMass
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
@ L2
field with C-1 continuity
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_ATOM_TEST_INVALID
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
constexpr int order
Order displacement.
PetscErrorCode DMMoFEMSetIsPartitioned(DM dm, PetscBool is_partitioned)
PetscErrorCode DMMoFEMCreateSubDM(DM subdm, DM dm, const char problem_name[])
Must be called by user to set Sub DM MoFEM data structures.
PetscErrorCode DMMoFEMAddElement(DM dm, std::string fe_name)
add element to dm
PetscErrorCode DMMoFEMSetSquareProblem(DM dm, PetscBool square_problem)
set squared problem
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
set local (or ghosted) vector values on mesh for partition only
PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, const char field_name[])
auto createDMVector(DM dm)
Get smart vector from DM.
PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, const char field_name[])
auto createDMMatrix(DM dm)
Get smart matrix from DM.
PetscErrorCode DMoFEMMeshToGlobalVector(DM dm, Vec g, InsertMode mode, ScatterMode scatter_mode)
set ghosted vector values on all existing mesh entities
PetscErrorCode DMSubDMSetUp_MoFEM(DM subdm)
PetscErrorCode DMoFEMLoopFiniteElementsUpAndLowRank(DM dm, const char fe_name[], MoFEM::FEMethod *method, int low_rank, int up_rank, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
Executes FEMethod for finite elements in DM.
virtual MoFEMErrorCode build_finite_elements(int verb=DEFAULT_VERBOSITY)=0
Build finite elements.
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 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.
virtual MoFEMErrorCode modify_problem_mask_ref_level_set_bit(const std::string &name_problem, const BitRefLevel &bit)=0
set dof mask ref level for problem
virtual MoFEMErrorCode modify_problem_ref_level_set_bit(const std::string &name_problem, const BitRefLevel &bit)=0
set ref level for problem
FTensor::Index< 'i', SPACE_DIM > i
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
auto createKSP(MPI_Comm comm)
PetscErrorCode DMMoFEMSetDestroyProblem(DM dm, PetscBool destroy_problem)
auto createDM(MPI_Comm comm, const std::string dm_type_name)
Creates smart DM object.
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
constexpr double t
plate stiffness
constexpr auto field_name
FTensor::Index< 'm', 3 > m
virtual int get_comm_size() const =0
virtual moab::Interface & get_moab()=0
virtual MoFEMErrorCode build_adjacencies(const Range &ents, int verb=DEFAULT_VERBOSITY)=0
build adjacencies
virtual MPI_Comm & get_comm() const =0
virtual int get_comm_rank() const =0
Deprecated interface functions.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
MoFEMErrorCode operator()(ForcesAndSourcesCore *fe_raw_ptr, int order_row, int order_col, int order_data)
static std::map< long int, MatrixDouble > mapRefCoords
MoFEMErrorCode solveMap(SmartPetscObj< DM > &subDM, SmartPetscObj< DM > &intermediateDM, BitRefLevel parent_bit, BitRefLevel child_bit, PetscInt numVecs, Vec vecsToMapFrom[], Vec vecsToMapTo[])
MoFEMErrorCode postProcess()
SmartPetscObj< DM > intermediateDM
MoFEMErrorCode mapFields(SmartPetscObj< DM > &intermediateDM, BitRefLevel parentBit, BitRefLevel childBit, PetscInt numVecs=1, Vec vecsToMapFrom[]=PETSC_NULLPTR, Vec vecsToMapTo[]=PETSC_NULLPTR)
SolutionMapping(MoFEM::Interface &m_field)
boost::shared_ptr< DomainEle > feRhs
MoFEMErrorCode reSetUp(std::vector< std::string > L2Fields, std::vector< int > L2Oders, std::vector< std::string > H1Fields, std::vector< int > H1Orders, std::vector< std::string > HdivFields, std::vector< int > HdivOrders, BitRefLevel bIt)
MoFEMErrorCode setUp(SmartPetscObj< DM > &subDM, SmartPetscObj< DM > &intermediateDM, BitRefLevel parent_bit, BitRefLevel child_bit)
MoFEMErrorCode projectResults(BitRefLevel parent_bit, BitRefLevel child_bit)
MoFEM::Interface & m_field
boost::shared_ptr< DomainEle > feLhs
SmartPetscObj< DM > subDM
PetscBool is_distributed_mesh
int num_refinement_levels
int geom_order
Order if fixed.