v0.15.0
Loading...
Searching...
No Matches
SolutionMapping.hpp
/** \file SolutionMapping.hpp
* \example SolutionMapping.hpp
*/
#include <DGProjection.hpp>
MoFEMErrorCode operator()(ForcesAndSourcesCore *fe_raw_ptr, int order_row,
int order_col, int order_data);
private:
struct Fe : public ForcesAndSourcesCore {
using ForcesAndSourcesCore::dataOnElement;
private:
using ForcesAndSourcesCore::ForcesAndSourcesCore;
};
static inline std::map<long int, MatrixDouble> mapRefCoords;
};
MoFEMErrorCode mapFields(SmartPetscObj<DM> &intermediateDM,
BitRefLevel parentBit, BitRefLevel childBit,
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:
BitRefLevel parentBit, childBit;
SmartPetscObj<DM> subDM, intermediateDM;
boost::shared_ptr<DomainEle> feRhs;
boost::shared_ptr<DomainEle> feLhs;
MoFEMErrorCode setUp(SmartPetscObj<DM> &subDM,
SmartPetscObj<DM> &intermediateDM,
BitRefLevel parent_bit, BitRefLevel child_bit);
MoFEMErrorCode projectResults(BitRefLevel parent_bit, BitRefLevel child_bit);
MoFEMErrorCode solveMap(SmartPetscObj<DM> &subDM,
SmartPetscObj<DM> &intermediateDM,
BitRefLevel parent_bit, BitRefLevel child_bit,
PetscInt numVecs, Vec vecsToMapFrom[],
Vec vecsToMapTo[]);
MoFEMErrorCode postProcess();
};
SolutionMapping::SolutionMapping(MoFEM::Interface &m_field) : m_field(m_field) {
feRhs = boost::make_shared<DomainEle>(m_field);
feLhs = boost::make_shared<DomainEle>(m_field);
}
MoFEMErrorCode SolutionMapping::mapFields(SmartPetscObj<DM> &intermediate_dm,
BitRefLevel parent_bit,
BitRefLevel child_bit,
PetscInt num_vecs,
Vec vecs_to_map_from[],
Vec vecs_to_map_to[]) {
CHKERR setUp(subDM, intermediate_dm, parent_bit, child_bit);
CHKERR solveMap(subDM, intermediate_dm, parent_bit, child_bit, num_vecs,
vecs_to_map_from, vecs_to_map_to);
};
MoFEMErrorCode SolutionMapping::setUp(SmartPetscObj<DM> &sub_dm,
SmartPetscObj<DM> &intermediate_dm,
BitRefLevel parent_bit,
BitRefLevel child_bit) {
MOFEM_LOG("REMESHING", Sev::inform) << "Set up sub DM for mapping";
Simple *simple = m_field.getInterface<Simple>();
Range sub_dm_elems;
auto create_sub_dm = [&]() {
sub_dm = createDM(m_field.get_comm(), "DMMOFEM");
auto create_impl = [&]() {
CHKERR DMSetType(sub_dm, "DMMOFEM");
CHKERR DMMoFEMCreateSubDM(sub_dm, intermediate_dm, "SUB_MAPPING");
CHKERR DMMoFEMAddElement(sub_dm, simple->getDomainFEName());
CHKERR DMMoFEMSetSquareProblem(sub_dm, PETSC_TRUE);
CHKERR DMMoFEMSetDestroyProblem(sub_dm, PETSC_TRUE);
MOFEM_LOG("REMESHING", Sev::inform) << "Created sub DM";
// get only refinement bit DOFs
auto ref_entities_ptr = boost::make_shared<Range>();
auto child_mask = parent_bit;
CHKERR m_field.getInterface<BitRefManager>()->getEntitiesByDimAndRefLevel(
child_bit, child_mask.flip(), SPACE_DIM, *ref_entities_ptr);
Range edges;
CHKERR m_field.get_moab().get_adjacencies(*ref_entities_ptr,
SPACE_DIM - 1, true, edges,
moab::Interface::UNION);
ref_entities_ptr->merge(edges);
Range verts;
CHKERR m_field.get_moab().get_adjacencies(*ref_entities_ptr, 0, true,
verts, moab::Interface::UNION);
ref_entities_ptr->merge(verts);
for (auto f : {"U", "FLUX"}) {
CHKERR DMMoFEMAddSubFieldRow(sub_dm, f, ref_entities_ptr);
CHKERR DMMoFEMAddSubFieldCol(sub_dm, f, ref_entities_ptr);
}
parent_bit | child_bit);
BitRefLevel().set());
};
CHKERR create_impl();
};
CHK_THROW_MESSAGE(create_sub_dm(), "failed to create sub dm");
MOFEM_LOG("REMESHING", Sev::inform) << "Set up sub DM for mapping <= done";
};
MoFEMErrorCode SolutionMapping::reSetUp(std::vector<std::string> L2_fields,
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,
BitRefLevel bit) {
Simple *simple = m_field.getInterface<Simple>();
auto add_ents_order_to_field =
const std::initializer_list<std::string> &f,
const std::initializer_list<EntityType> &t, int _order) {
for (auto _f : f) {
for (auto _t : t) {
CHKERR m_field.set_field_order(0, _t, _f, _order);
}
}
};
for (size_t i = 0; i < L2_fields.size(); ++i) {
CHKERR add_ents_order_to_field(m_field, {L2_fields[i]}, {MBTRI},
L2_orders[i]);
}
for (size_t i = 0; i < H1_fields.size(); ++i) {
CHKERR add_ents_order_to_field(m_field, {H1_fields[i]}, {MBTRI, MBEDGE},
H1_orders[i]);
CHKERR m_field.set_field_order(0, MBVERTEX, {H1_fields[i]},
1); // H1 only supports 1st order on vertices
}
for (size_t i = 0; i < Hdiv_fields.size(); ++i) {
CHKERR add_ents_order_to_field(m_field, {Hdiv_fields[i]}, {MBTRI, MBEDGE},
Hdiv_orders[i]);
}
Skinner skin(&m_field.get_moab());
Range faces;
CHKERR m_field.getInterface<BitRefManager>()->getEntitiesByTypeAndRefLevel(
BitRefLevel().set(), MBTRI, faces);
Range skin_edges;
CHKERR skin.find_skin(0, faces, false, skin_edges);
#ifdef ADD_CONTACT
auto filter_blocks = [&](auto skin) {
bool is_contact_block = false;
Range contact_range;
for (auto m :
m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(std::regex(
(boost::format("%s(.*)") % "CONTACT").str()
))
) {
is_contact_block =
true; ///< blocs interation is collective, so that is set irrespective
///< if there are entities in given rank or not in the block
MOFEM_LOG("CONTACT", Sev::inform)
<< "Find contact block set: " << m->getName();
auto meshset = m->getMeshset();
Range contact_meshset_range;
CHKERR m_field.get_moab().get_entities_by_dimension(
meshset, SPACE_DIM - 1, contact_meshset_range, true);
CHKERR m_field.getInterface<CommInterface>()->synchroniseEntities(
contact_meshset_range);
contact_range.merge(contact_meshset_range);
}
if (is_contact_block) {
MOFEM_LOG("SYNC", Sev::inform)
<< "Nb entities in contact surface: " << contact_range.size();
skin = intersect(skin, contact_range);
}
return skin;
};
auto sigma_trace_ents = filter_blocks(skin_edges);
CHKERR m_field.set_field_order(0, MBTRI, "SIGMA", 0);
CHKERR m_field.add_ents_to_field_by_type(sigma_trace_ents, MBEDGE, "SIGMA");
CHKERR m_field.set_field_order(sigma_trace_ents, "SIGMA", order - 1);
#endif // ADD_CONTACT
simple->getDomainFEName());
skin_edges, MBEDGE, simple->getBoundaryFEName());
};
BitRefLevel child_bit) {
feRhs->getOpPtrVector().clear();
feLhs->getOpPtrVector().clear();
MOFEM_LOG("REMESHING", Sev::inform) << "Cleared FEs";
Simple *simple = m_field.getInterface<Simple>();
auto vol_rule = [](int, int, int ao) { return 2 * ao + geom_order; };
feRhs->getRuleHook = vol_rule;
feLhs->getRuleHook = vol_rule;
// OpLoopThis, is child operator, and is use to execute
// fe_child_ptr, only on bit ref level and mask
// for child elements
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; };
Range child_edges;
CHKERR m_field.getInterface<BitRefManager>()->getEntitiesByTypeAndRefLevel(
child_bit, parent_bit.flip(), MBEDGE, child_edges);
// set integration rule, such that integration points are not on flipped edge
CHKERR setDGSetIntegrationPoints<2>( // Currently only implemented for 2D
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;
};
// Use field evaluator to calculate field values on parent bitref level,
// i.e. elements which were flipped.
auto get_field_eval_op = [&](auto fe_child_ptr) {
auto field_eval_ptr = m_field.getInterface<FieldEvaluatorInterface>();
// Get pointer of FieldEvaluator data. Note finite element and method
// set integrating points is destroyed when this pointer is releases
auto field_eval_data = field_eval_ptr->getData<DomainEle>();
// Build tree for particular element
CHKERR field_eval_ptr->buildTree<SPACE_DIM>(
field_eval_data, simple->getDomainFEName(), parent_bit,
BitRefLevel().set());
// You can add more fields here
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));
constexpr int size_symm = (SPACE_DIM * (SPACE_DIM + 1)) / 2;
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}
},
simple->getDomainFEName(), field_eval_data, 0, m_field.get_comm_size(),
parent_bit, child_bit.flip(), MF_EXIST, QUIET);
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}}
);
};
// calculate coefficients on child (flipped) elements
auto dg_projection_base = [&](auto fe_child_ptr, auto vec_data_ptr) {
// constexpr int projection_order = order;
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; // use order 2 for DG projection
for (auto &[field_name, data_ptr] : vec_data_ptr.first) {
fe_child_ptr->getOpPtrVector().push_back(new OpDGProjectionMassMatrix(
projection_order, mass_ptr, entity_data_l2, AINSWORTH_LEGENDRE_BASE,
L2));
fe_child_ptr->getOpPtrVector().push_back(new OpDGProjectionCoefficients(
data_ptr, coeffs_ptr, mass_ptr, entity_data_l2,
// set coefficients to flipped element
auto op_set_coeffs = new DomainEleOp(field_name, DomainEleOp::OPROW);
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 field_name = p.first;
auto data_ptr = p.second;
if (field_name == "U") {
using OpDomainMass = FormsIntegrators<DomainEleOp>::Assembly<
// assemble to global matrix, since this is H1 (you will do the shame for Hcurl of Hdiv)
auto beta = [](const double, const double, const double) { return 1; };
fe_child_ptr->getOpPtrVector().push_back(
using OpVec = FormsIntegrators<DomainEleOp>::Assembly<
fe_child_ptr->getOpPtrVector().push_back(
new OpVec(field_name, data_ptr, beta));
}
if (field_name == "FLUX") {
using OpDomainMass = FormsIntegrators<DomainEleOp>::Assembly<
// assemble to global matrix, since this is H1 (you will do the shame for Hcurl of Hdiv)
auto beta = [](const double, const double, const double) { return 1; };
fe_child_ptr->getOpPtrVector().push_back(
using OpVec = FormsIntegrators<DomainEleOp>::Assembly<
fe_child_ptr->getOpPtrVector().push_back(
new OpVec(field_name, data_ptr, beta));
}
}
};
// create child operator, and fe_child_ptr element in it
auto fe_child_ptr = get_child_op(feRhs->getOpPtrVector());
// run dg projection, note that get_field_eval_op,
// pass data_ptr values used to project and calculate coefficients
CHKERR dg_projection_base(fe_child_ptr, get_field_eval_op(fe_child_ptr));
MOFEM_LOG("REMESHING", Sev::inform) << "Before looping FEs";
subDM, simple->getDomainFEName(), feRhs, 0, m_field.get_comm_size());
// CHKERR DMoFEMLoopFiniteElementsUpAndLowRank(subDM, simple->getDomainFEName(),
// feRhs, m_field.get_comm_rank(),
// m_field.get_comm_rank());
MOFEM_LOG("REMESHING", Sev::inform) << "After looping RHS";
// CHKERR DMoFEMLoopFiniteElementsUpAndLowRank(
// subDM, simple->getDomainFEName(), feLhs, 0, m_field.get_comm_size());
// MOFEM_LOG("REMESHING", Sev::inform) << "After looping LHS";
};
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 simple = m_field.getInterface<Simple>();
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_" +
std::to_string(m_field.get_comm_rank()) + "_" +
file_name + ".h5m";
CHKERR post_proc_moab.write_file(output_name.c_str());
}
{
dm, simple->getDomainFEName(), post_proc_fe, m_field.get_comm_rank(),
auto &post_proc_moab = post_proc_fe->getPostProcMesh();
auto output_name = "out_only_on_rank" +
std::to_string(m_field.get_comm_rank()) + "_" +
file_name + ".h5m";
CHKERR post_proc_moab.write_file(output_name.c_str());
}
};
auto null_fe = boost::shared_ptr<FEMethod>();
// CHKERR DMMoFEMKSPSetComputeOperators(sub_dm, simple->getDomainFEName(), feLhs,
// null_fe, null_fe);
// CHKERR DMMoFEMKSPSetComputeRHS(sub_dm, simple->getDomainFEName(), feRhs,
// null_fe, null_fe);
auto vec = createDMVector(sub_dm);
int size;
CHKERR VecGetSize(vec, &size);
SmartPetscObj<Mat> mat;
if (size)
mat = createDMMatrix(sub_dm);
auto sol = createDMVector(sub_dm);
auto ksp = createKSP(m_field.get_comm());
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;
// We create a temp_D to store current state of the mesh. We doing to preserve
// whatever is currently stored on entities, we will restore it to keep it as
// it was before.
auto tmp_D = createDMVector(intermediate_dm);
CHKERR DMoFEMMeshToLocalVector(intermediate_dm, tmp_D, INSERT_VALUES,
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) {
// load data to intermediate dm from vecs_to_map_from[i]
CHKERR VecGhostUpdateBegin(vecs_to_map_from[i], INSERT_VALUES,
SCATTER_FORWARD);
CHKERR VecGhostUpdateEnd(vecs_to_map_from[i], INSERT_VALUES,
SCATTER_FORWARD);
CHKERR DMoFEMMeshToGlobalVector(intermediate_dm, vecs_to_map_from[i],
INSERT_VALUES, SCATTER_REVERSE);
if (size)
CHKERR MatZeroEntries(mat);
CHKERR VecZeroEntries(vec);
CHKERR VecGhostUpdateBegin(vec, INSERT_VALUES, SCATTER_FORWARD);
CHKERR VecGhostUpdateEnd(vec, INSERT_VALUES, SCATTER_FORWARD);
// map
CHKERR projectResults(parent_bit, child_bit);
if (size) {
CHKERR VecAssemblyBegin(vec);
CHKERR VecAssemblyEnd(vec);
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);
CHKERR DMoFEMMeshToGlobalVector(sub_dm, sol, INSERT_VALUES,
SCATTER_REVERSE);
}
// update data
CHKERR DMoFEMMeshToLocalVector(intermediate_dm, vecs_to_map_to[i],
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));
}
CHKERR DMoFEMMeshToLocalVector(intermediate_dm, tmp_D, INSERT_VALUES,
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)
Definition acoustic.cpp:69
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
@ QUIET
@ MF_EXIST
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
Definition definitions.h:60
#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
Definition definitions.h:88
#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
Order displacement.
PetscErrorCode DMMoFEMSetIsPartitioned(DM dm, PetscBool is_partitioned)
Definition DMMoFEM.cpp:1113
PetscErrorCode DMMoFEMCreateSubDM(DM subdm, DM dm, const char problem_name[])
Must be called by user to set Sub DM MoFEM data structures.
Definition DMMoFEM.cpp:215
PetscErrorCode DMMoFEMAddElement(DM dm, std::string fe_name)
add element to dm
Definition DMMoFEM.cpp:488
PetscErrorCode DMMoFEMSetSquareProblem(DM dm, PetscBool square_problem)
set squared problem
Definition DMMoFEM.cpp:450
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:514
PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, const char field_name[])
Definition DMMoFEM.cpp:238
auto createDMVector(DM dm)
Get smart vector from DM.
Definition DMMoFEM.hpp:1234
PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, const char field_name[])
Definition DMMoFEM.cpp:280
auto createDMMatrix(DM dm)
Get smart matrix from DM.
Definition DMMoFEM.hpp:1191
PetscErrorCode DMoFEMMeshToGlobalVector(DM dm, Vec g, InsertMode mode, ScatterMode scatter_mode)
set ghosted vector values on all existing mesh entities
Definition DMMoFEM.cpp:525
PetscErrorCode DMSubDMSetUp_MoFEM(DM subdm)
Definition DMMoFEM.cpp:1344
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.
Definition DMMoFEM.cpp:557
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.
@ PETSC
Standard PETSc assembly.
#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
auto bit
set bit
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.
Definition Types.hpp:40
auto createKSP(MPI_Comm comm)
PetscErrorCode DMMoFEMSetDestroyProblem(DM dm, PetscBool destroy_problem)
Definition DMMoFEM.cpp:434
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
Definition plate.cpp:58
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
BitRefLevel parentBit
@ FLIPPED_BIT
PetscBool is_distributed_mesh
int num_refinement_levels
constexpr auto size_symm
Definition plastic.cpp:42
int geom_order
Order if fixed.
Definition plastic.cpp:141